From 14258636ed89f824c6c74bd25dad7bbcd45c683f Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Wed, 27 Dec 2023 01:45:00 -0800 Subject: [PATCH] feat: update assemblyscript --- package.json | 13 +++++------ pnpm-lock.yaml | 53 +++++++++++++++----------------------------- test/test-runner.mjs | 2 +- transform.ts | 18 +++++++-------- 4 files changed, 33 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index 58de1ac..927b27b 100644 --- a/package.json +++ b/package.json @@ -32,14 +32,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", @@ -51,7 +51,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", @@ -115,10 +115,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" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d10987..27fd8d7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,15 +4,10 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -dependencies: - visitor-as: - specifier: ~0.8.0 - version: 0.8.0(assemblyscript@0.19.23) - devDependencies: '@assemblyscript/loader': - specifier: ~0.19.23 - version: 0.19.23 + specifier: ~0.27.22 + version: 0.27.22 '@babel/core': specifier: ^7.23.6 version: 7.23.6 @@ -47,8 +42,8 @@ devDependencies: specifier: ^11.1.5 version: 11.1.5(rollup@4.9.1)(tslib@2.6.2)(typescript@5.3.3) assemblyscript: - specifier: ~0.19.23 - version: 0.19.23 + specifier: ~0.27.22 + version: 0.27.22 chokidar-cli: specifier: ^3.0.0 version: 3.0.0 @@ -144,8 +139,8 @@ packages: '@jridgewell/trace-mapping': 0.3.20 dev: true - /@assemblyscript/loader@0.19.23: - resolution: {integrity: sha512-ulkCYfFbYj01ie1MDOyxv2F6SpRN1TOj7fQxbP07D6HmeR+gr2JLSmINKjga2emB+b1L2KGrFKBTc+e00p54nw==} + /@assemblyscript/loader@0.27.22: + resolution: {integrity: sha512-bcFSC0cfd/Lx3OcM9gqBcBd7JECWQd8WQbk4eWj6T4CIhPaJuHMyvEiGR0y3JhPJwPmoorR03nd1hCqm3thyrg==} dev: true /@babel/code-frame@7.23.5: @@ -2064,13 +2059,14 @@ packages: engines: {node: '>=12'} dev: true - /assemblyscript@0.19.23: - resolution: {integrity: sha512-fwOQNZVTMga5KRsfY80g7cpOl4PsFQczMwHzdtgoqLXaYhkhavufKb0sB0l3T1DUxpAufA0KNhlbpuuhZUwxMA==} + /assemblyscript@0.27.22: + resolution: {integrity: sha512-6ClobsR4Hxn6K0daYp/+n9qWTqVbpdVeSGSVDqRvUEz66vvFb8atS6nLm+fnQ54JXuXmzLQy0uWYYgB8G59btQ==} + engines: {node: '>=16', npm: '>=7'} hasBin: true dependencies: - binaryen: 102.0.0-nightly.20211028 + binaryen: 116.0.0-nightly.20231102 long: 5.2.3 - source-map-support: 0.5.21 + dev: true /ast-types@0.13.4: resolution: {integrity: sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==} @@ -2151,9 +2147,10 @@ packages: engines: {node: '>=8'} dev: true - /binaryen@102.0.0-nightly.20211028: - resolution: {integrity: sha512-GCJBVB5exbxzzvyt8MGDv/MeUjs6gkXDvf4xOIItRBptYl0Tz5sm1o/uG95YK0L0VeG5ajDu3hRtkBP2kzqC5w==} + /binaryen@116.0.0-nightly.20231102: + resolution: {integrity: sha512-aPU9tlKdw/gcXx6u4PxtDgOtGjg/ZKnYdk23ctYb70GxZgPhWnGWmnBt01aV5dt5yFFo2V4rbB7SzpSFhViFQA==} hasBin: true + dev: true /bl@4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} @@ -2263,6 +2260,7 @@ packages: /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + dev: true /buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} @@ -4821,10 +4819,6 @@ packages: resolution: {integrity: sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==} dev: true - /lodash.clonedeep@4.5.0: - resolution: {integrity: sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==} - dev: false - /lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} dev: true @@ -4887,6 +4881,7 @@ packages: /long@5.2.3: resolution: {integrity: sha512-lcHwpNoggQTObv5apGNCTdJrO69eHOZMi4BNC+rTLER8iHAqGrUVeLh/irVIM7zTw2bOXA8T6uNPeujwOLg/2Q==} + dev: true /lowercase-keys@2.0.0: resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==} @@ -7044,10 +7039,12 @@ packages: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 + dev: true /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + dev: true /spdx-correct@3.2.0: resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} @@ -7400,10 +7397,6 @@ packages: escape-string-regexp: 1.0.5 dev: true - /ts-mixer@5.4.1: - resolution: {integrity: sha512-Zo9HgPCtNouDgJ+LGtrzVOjSg8+7WGQktIKLwAfaNrlOK1mWGlz1ejsAF/YqUEqAGjUTeB5fEg8gH9Aui6w9xA==} - dev: false - /tslib@1.14.1: resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} dev: true @@ -7665,16 +7658,6 @@ packages: engines: {node: '>= 0.8'} dev: true - /visitor-as@0.8.0(assemblyscript@0.19.23): - resolution: {integrity: sha512-tW9Vfr2AnGCckcfujL7QPbfrY7D0hNcYwi5DWx8wBfBjgCWhfIXEEojqS5JrzRnQI+LllTEUfGAIdLaxaaBNpw==} - peerDependencies: - assemblyscript: ^0.19.22 - dependencies: - assemblyscript: 0.19.23 - lodash.clonedeep: 4.5.0 - ts-mixer: 5.4.1 - dev: false - /wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} dependencies: diff --git a/test/test-runner.mjs b/test/test-runner.mjs index 0e569e6..fb96068 100644 --- a/test/test-runner.mjs +++ b/test/test-runner.mjs @@ -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); diff --git a/transform.ts b/transform.ts index bff19f5..1f5d80a 100644 --- a/transform.ts +++ b/transform.ts @@ -2,7 +2,6 @@ import { CommonFlags, NodeKind, ElementKind, - Transform, IdentifierExpression, FunctionPrototype, StringLiteralExpression, @@ -10,7 +9,8 @@ import { 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) { @@ -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"] = {}; @@ -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; @@ -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; }