Skip to content

Commit

Permalink
feat: update assemblyscript
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jan 21, 2024
1 parent 747fbfd commit 4360a21
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 53 deletions.
13 changes: 5 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
"md:wasm:watch": "chokidar --initial \"examples/markdown-parser/assembly/**/*\" -c \"run-s md:wasm:build\"",
"md:ts:watch": "chokidar --initial \"examples/markdown-parser/assembly/**/*\" -c \"run-s md:ts:build\"",
"md:js:watch": "chokidar --initial \"examples/markdown-parser/**/*\" -c \"rollup -c --environment MD,DEV\"",
"md:wasm:build": "asc examples/markdown-parser/assembly/index.ts --transform ./dist/transform.cjs.js -b dist/examples/markdown-parser/index.wasm -t dist/examples/markdown-parser/index.wat --sourceMap dist/examples/markdown-parser/index.wasm.map --runtime incremental --exportRuntime",
"md:wasm:build": "asc examples/markdown-parser/assembly/index.ts --transform ./dist/transform.cjs.js -o dist/examples/markdown-parser/index.wasm -t dist/examples/markdown-parser/index.wat --sourceMap dist/examples/markdown-parser/index.wasm.map --runtime incremental --exportRuntime",
"md:ts:build": "tsc --project examples/markdown-parser/assembly/ --outDir dist/ts/ --module \"es2015\"",
"md:js:build": "rollup -c --environment MD,PROD",
"md:deploy": "run-s build md:build md:deploy:gh-pages",
"md:deploy:gh-pages": "gh-pages -d dist/examples/markdown-parser"
},
"devDependencies": {
"@assemblyscript/loader": "~0.19.23",
"@assemblyscript/loader": "~0.27.22",
"@babel/core": "^7.23.6",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-export-default-from": "^7.23.3",
Expand All @@ -52,7 +52,7 @@
"@rollup/plugin-json": "^6.1.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.5",
"assemblyscript": "~0.19.23",
"assemblyscript": "~0.27.22",
"chokidar-cli": "^3.0.0",
"cpy-cli": "^5.0.0",
"desm": "^1.3.0",
Expand Down Expand Up @@ -116,10 +116,7 @@
],
"homepage": "https://github.com/torch2424/as-bind#readme",
"peerDependencies": {
"@assemblyscript/loader": "0.19.x",
"assemblyscript": "0.19.x"
},
"dependencies": {
"visitor-as": "~0.8.0"
"@assemblyscript/loader": "0.27.x",
"assemblyscript": "0.27.x"
}
}
53 changes: 18 additions & 35 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/test-runner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Express from "express";
import Mocha from "mocha";
import { glob } from "glob";
import pptr from "puppeteer";
import asc from "assemblyscript/cli/asc";
import asc from "assemblyscript/dist/asc.js";
import AsBind from "../dist/as-bind.cjs.js";

const require = createRequire(import.meta.url);
Expand Down
18 changes: 9 additions & 9 deletions transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import {
CommonFlags,
NodeKind,
ElementKind,
Transform,
IdentifierExpression,
FunctionPrototype,
StringLiteralExpression,
Module,
Function,
DeclaredElement,
Type
} from "visitor-as/as";
} from "assemblyscript/dist/assemblyscript.js";
import { Transform } from "assemblyscript/dist/transform.js";
import { TypeDef } from "./lib/types";

function isInternalElement(element: DeclaredElement) {
Expand Down Expand Up @@ -77,18 +77,18 @@ export default class AsBindTransform extends Transform {
const flatExportedFunctions = [
...this.program.elementsByDeclaration.values()
]
.filter(el => elementHasFlag(el, CommonFlags.MODULE_EXPORT))
.filter(el => elementHasFlag(el, CommonFlags.ModuleExport))
.filter(el => !isInternalElement(el))
.filter(
el => el.declaration.kind === NodeKind.FUNCTIONDECLARATION
el => el.declaration.kind === NodeKind.FunctionDeclaration
) as FunctionPrototype[];
const flatImportedFunctions = [
...this.program.elementsByDeclaration.values()
]
.filter(el => elementHasFlag(el, CommonFlags.DECLARE))
.filter(el => elementHasFlag(el, CommonFlags.Declare))
.filter(el => !isInternalElement(el))
.filter(
v => v.declaration.kind === NodeKind.FUNCTIONDECLARATION
v => v.declaration.kind === NodeKind.FunctionDeclaration
) as FunctionPrototype[];

const typeIds: TypeDef["typeIds"] = {};
Expand All @@ -108,8 +108,8 @@ export default class AsBindTransform extends Transform {

const iFunction = importedFunction.instances.get("")!;

let external_module;
let external_name;
let external_module: string | undefined;
let external_name: string | undefined;

let decorators = iFunction.declaration.decorators;

Expand Down Expand Up @@ -147,7 +147,7 @@ export default class AsBindTransform extends Transform {
importedFunctionName = external_name;
} else if (
iFunction.parent &&
iFunction.parent.kind === ElementKind.NAMESPACE
iFunction.parent.kind === ElementKind.Namespace
) {
importedFunctionName = iFunction.parent.name + "." + iFunction.name;
}
Expand Down

0 comments on commit 4360a21

Please sign in to comment.