bantou 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/nitro.json +13 -0
- package/.output/public/_nuxt/BmGsA4i2.js +1 -0
- package/.output/public/_nuxt/D_G6gzEa.js +1 -0
- package/.output/public/_nuxt/builds/latest.json +1 -0
- package/.output/public/_nuxt/builds/meta/1a8fc623-6671-445b-bdd3-c3d073520a3a.json +1 -0
- package/.output/public/_nuxt/entry.CZSvzYhH.css +1 -0
- package/.output/public/_nuxt/error-404.C3wqHTJz.css +1 -0
- package/.output/public/_nuxt/error-500.D6rBzoDj.css +1 -0
- package/.output/public/_nuxt/pdFQkwM_.js +4 -0
- package/.output/server/chunks/_/error-500.mjs +20 -0
- package/.output/server/chunks/_/error-500.mjs.map +1 -0
- package/.output/server/chunks/nitro/nitro.mjs +5870 -0
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -0
- package/.output/server/chunks/routes/mcp.mjs +22 -0
- package/.output/server/chunks/routes/mcp.mjs.map +1 -0
- package/.output/server/chunks/routes/renderer.mjs +462 -0
- package/.output/server/chunks/routes/renderer.mjs.map +1 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs +4 -0
- package/.output/server/chunks/virtual/_virtual_spa-template.mjs.map +1 -0
- package/.output/server/chunks/virtual/precomputed.mjs +4 -0
- package/.output/server/chunks/virtual/precomputed.mjs.map +1 -0
- package/.output/server/index.mjs +18 -0
- package/.output/server/index.mjs.map +1 -0
- package/.output/server/node_modules/@babel/parser/lib/index.js +14657 -0
- package/.output/server/node_modules/@babel/parser/package.json +50 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js +64 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js +16 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js +32 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js +246 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/package.json +1 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js +41 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +429 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js +971 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js +58 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +961 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +228 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js +51 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js +1137 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js +92 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js +239 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js +2065 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js +87 -0
- package/.output/server/node_modules/@modelcontextprotocol/sdk/package.json +165 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/index.mjs +349 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/package.json +44 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/watcher.wasm +0 -0
- package/.output/server/node_modules/@parcel/watcher-wasm/wrapper.js +88 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/index.mjs +12 -0
- package/.output/server/node_modules/@unagents/messenger-broker/dist/shared/messenger-broker.B8W77sqB.mjs +1177 -0
- package/.output/server/node_modules/@unagents/messenger-broker/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/index.mjs +9 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CfQVmH_Z.mjs +975 -0
- package/.output/server/node_modules/@unagents/messenger-client/dist/shared/messenger-client.CoDKzubj.mjs +1000 -0
- package/.output/server/node_modules/@unagents/messenger-client/package.json +37 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/dist/index.mjs +103 -0
- package/.output/server/node_modules/@unagents/messenger-protocol/package.json +29 -0
- package/.output/server/node_modules/@vue/compiler-core/dist/compiler-core.cjs.prod.js +6802 -0
- package/.output/server/node_modules/@vue/compiler-core/package.json +58 -0
- package/.output/server/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.prod.js +729 -0
- package/.output/server/node_modules/@vue/compiler-dom/package.json +57 -0
- package/.output/server/node_modules/@vue/compiler-ssr/dist/compiler-ssr.cjs.js +1420 -0
- package/.output/server/node_modules/@vue/compiler-ssr/package.json +34 -0
- package/.output/server/node_modules/@vue/reactivity/dist/reactivity.cjs.prod.js +1933 -0
- package/.output/server/node_modules/@vue/reactivity/package.json +55 -0
- package/.output/server/node_modules/@vue/runtime-core/dist/runtime-core.cjs.prod.js +7085 -0
- package/.output/server/node_modules/@vue/runtime-core/package.json +52 -0
- package/.output/server/node_modules/@vue/runtime-dom/dist/runtime-dom.cjs.prod.js +1917 -0
- package/.output/server/node_modules/@vue/runtime-dom/package.json +60 -0
- package/.output/server/node_modules/@vue/server-renderer/dist/server-renderer.cjs.prod.js +951 -0
- package/.output/server/node_modules/@vue/server-renderer/package.json +53 -0
- package/.output/server/node_modules/@vue/shared/dist/shared.cjs.prod.js +655 -0
- package/.output/server/node_modules/@vue/shared/package.json +47 -0
- package/.output/server/node_modules/ajv/dist/ajv.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/code.js +156 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/index.js +697 -0
- package/.output/server/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
- package/.output/server/node_modules/ajv/dist/compile/errors.js +123 -0
- package/.output/server/node_modules/ajv/dist/compile/index.js +242 -0
- package/.output/server/node_modules/ajv/dist/compile/names.js +28 -0
- package/.output/server/node_modules/ajv/dist/compile/ref_error.js +12 -0
- package/.output/server/node_modules/ajv/dist/compile/resolve.js +155 -0
- package/.output/server/node_modules/ajv/dist/compile/rules.js +26 -0
- package/.output/server/node_modules/ajv/dist/compile/util.js +178 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/index.js +520 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
- package/.output/server/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
- package/.output/server/node_modules/ajv/dist/core.js +618 -0
- package/.output/server/node_modules/ajv/dist/refs/data.json +13 -0
- package/.output/server/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
- package/.output/server/node_modules/ajv/dist/runtime/equal.js +7 -0
- package/.output/server/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
- package/.output/server/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/.output/server/node_modules/ajv/dist/runtime/validation_error.js +11 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/code.js +131 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
- package/.output/server/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
- package/.output/server/node_modules/ajv/package.json +126 -0
- package/.output/server/node_modules/ajv-formats/dist/formats.js +208 -0
- package/.output/server/node_modules/ajv-formats/dist/index.js +37 -0
- package/.output/server/node_modules/ajv-formats/dist/limit.js +69 -0
- package/.output/server/node_modules/ajv-formats/package.json +74 -0
- package/.output/server/node_modules/consola/dist/chunks/prompt.mjs +280 -0
- package/.output/server/node_modules/consola/dist/core.mjs +512 -0
- package/.output/server/node_modules/consola/dist/index.mjs +651 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DRwqZj3T.mjs +72 -0
- package/.output/server/node_modules/consola/dist/shared/consola.DXBYu-KD.mjs +288 -0
- package/.output/server/node_modules/consola/dist/utils.mjs +54 -0
- package/.output/server/node_modules/consola/package.json +136 -0
- package/.output/server/node_modules/content-type/index.js +225 -0
- package/.output/server/node_modules/content-type/package.json +42 -0
- package/.output/server/node_modules/cookie-es/dist/index.mjs +268 -0
- package/.output/server/node_modules/cookie-es/package.json +46 -0
- package/.output/server/node_modules/crossws/dist/_chunks/_request.mjs +83 -0
- package/.output/server/node_modules/crossws/dist/_chunks/adapter.mjs +234 -0
- package/.output/server/node_modules/crossws/dist/_chunks/error.mjs +7 -0
- package/.output/server/node_modules/crossws/dist/_chunks/libs/ws.mjs +6 -0
- package/.output/server/node_modules/crossws/dist/_chunks/node.mjs +220 -0
- package/.output/server/node_modules/crossws/dist/_chunks/peer.mjs +208 -0
- package/.output/server/node_modules/crossws/dist/adapters/node.mjs +1 -0
- package/.output/server/node_modules/crossws/package.json +115 -0
- package/.output/server/node_modules/defu/dist/defu.mjs +69 -0
- package/.output/server/node_modules/defu/package.json +48 -0
- package/.output/server/node_modules/destr/dist/index.mjs +72 -0
- package/.output/server/node_modules/destr/package.json +47 -0
- package/.output/server/node_modules/devalue/index.js +17 -0
- package/.output/server/node_modules/devalue/package.json +39 -0
- package/.output/server/node_modules/devalue/src/base64.js +60 -0
- package/.output/server/node_modules/devalue/src/constants.js +12 -0
- package/.output/server/node_modules/devalue/src/operations.js +221 -0
- package/.output/server/node_modules/devalue/src/parse.js +279 -0
- package/.output/server/node_modules/devalue/src/stringify.js +433 -0
- package/.output/server/node_modules/devalue/src/uneval.js +698 -0
- package/.output/server/node_modules/devalue/src/utils.js +190 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode-codepoint.js +77 -0
- package/.output/server/node_modules/entities/dist/commonjs/decode.js +568 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-html.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/generated/decode-data-xml.js +7 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/bin-trie-flags.js +21 -0
- package/.output/server/node_modules/entities/dist/commonjs/internal/decode-shared.js +31 -0
- package/.output/server/node_modules/entities/dist/commonjs/package.json +3 -0
- package/.output/server/node_modules/entities/package.json +120 -0
- package/.output/server/node_modules/estree-walker/dist/umd/estree-walker.js +344 -0
- package/.output/server/node_modules/estree-walker/package.json +37 -0
- package/.output/server/node_modules/fast-deep-equal/index.js +46 -0
- package/.output/server/node_modules/fast-deep-equal/package.json +61 -0
- package/.output/server/node_modules/fast-uri/index.js +711 -0
- package/.output/server/node_modules/fast-uri/lib/schemes.js +272 -0
- package/.output/server/node_modules/fast-uri/lib/utils.js +799 -0
- package/.output/server/node_modules/fast-uri/package.json +68 -0
- package/.output/server/node_modules/get-port-please/dist/index.mjs +430 -0
- package/.output/server/node_modules/get-port-please/package.json +39 -0
- package/.output/server/node_modules/h3/dist/index.mjs +2498 -0
- package/.output/server/node_modules/h3/package.json +75 -0
- package/.output/server/node_modules/hookable/dist/index.mjs +257 -0
- package/.output/server/node_modules/hookable/package.json +54 -0
- package/.output/server/node_modules/http-shutdown/index.js +85 -0
- package/.output/server/node_modules/http-shutdown/package.json +32 -0
- package/.output/server/node_modules/iron-webcrypto/dist/index.js +298 -0
- package/.output/server/node_modules/iron-webcrypto/package.json +72 -0
- package/.output/server/node_modules/is-extglob/index.js +20 -0
- package/.output/server/node_modules/is-extglob/package.json +69 -0
- package/.output/server/node_modules/is-glob/index.js +150 -0
- package/.output/server/node_modules/is-glob/package.json +81 -0
- package/.output/server/node_modules/jiti/dist/jiti.cjs +1 -0
- package/.output/server/node_modules/jiti/lib/jiti.mjs +29 -0
- package/.output/server/node_modules/jiti/package.json +146 -0
- package/.output/server/node_modules/json-schema-traverse/index.js +93 -0
- package/.output/server/node_modules/json-schema-traverse/package.json +43 -0
- package/.output/server/node_modules/listhen/dist/chunks/xdg-open.mjs +1069 -0
- package/.output/server/node_modules/listhen/dist/index.mjs +19 -0
- package/.output/server/node_modules/listhen/dist/shared/listhen.tqe5I1Rl.mjs +1040 -0
- package/.output/server/node_modules/listhen/package.json +84 -0
- package/.output/server/node_modules/napi-wasm/index.mjs +1371 -0
- package/.output/server/node_modules/napi-wasm/package.json +33 -0
- package/.output/server/node_modules/node-forge/lib/aes.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/aesCipherSuites.js +282 -0
- package/.output/server/node_modules/node-forge/lib/asn1-validator.js +91 -0
- package/.output/server/node_modules/node-forge/lib/asn1.js +1522 -0
- package/.output/server/node_modules/node-forge/lib/baseN.js +186 -0
- package/.output/server/node_modules/node-forge/lib/cipher.js +230 -0
- package/.output/server/node_modules/node-forge/lib/cipherModes.js +1027 -0
- package/.output/server/node_modules/node-forge/lib/des.js +496 -0
- package/.output/server/node_modules/node-forge/lib/ed25519.js +1091 -0
- package/.output/server/node_modules/node-forge/lib/forge.js +13 -0
- package/.output/server/node_modules/node-forge/lib/hmac.js +146 -0
- package/.output/server/node_modules/node-forge/lib/index.js +33 -0
- package/.output/server/node_modules/node-forge/lib/jsbn.js +1294 -0
- package/.output/server/node_modules/node-forge/lib/kem.js +168 -0
- package/.output/server/node_modules/node-forge/lib/log.js +319 -0
- package/.output/server/node_modules/node-forge/lib/md.all.js +13 -0
- package/.output/server/node_modules/node-forge/lib/md.js +11 -0
- package/.output/server/node_modules/node-forge/lib/md5.js +289 -0
- package/.output/server/node_modules/node-forge/lib/mgf.js +12 -0
- package/.output/server/node_modules/node-forge/lib/mgf1.js +57 -0
- package/.output/server/node_modules/node-forge/lib/oids.js +180 -0
- package/.output/server/node_modules/node-forge/lib/pbe.js +1029 -0
- package/.output/server/node_modules/node-forge/lib/pbkdf2.js +211 -0
- package/.output/server/node_modules/node-forge/lib/pem.js +413 -0
- package/.output/server/node_modules/node-forge/lib/pkcs1.js +276 -0
- package/.output/server/node_modules/node-forge/lib/pkcs12.js +1081 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7.js +1260 -0
- package/.output/server/node_modules/node-forge/lib/pkcs7asn1.js +410 -0
- package/.output/server/node_modules/node-forge/lib/pki.js +102 -0
- package/.output/server/node_modules/node-forge/lib/prime.js +297 -0
- package/.output/server/node_modules/node-forge/lib/prng.js +419 -0
- package/.output/server/node_modules/node-forge/lib/pss.js +241 -0
- package/.output/server/node_modules/node-forge/lib/random.js +191 -0
- package/.output/server/node_modules/node-forge/lib/rc2.js +410 -0
- package/.output/server/node_modules/node-forge/lib/rsa.js +2014 -0
- package/.output/server/node_modules/node-forge/lib/sha1.js +319 -0
- package/.output/server/node_modules/node-forge/lib/sha256.js +327 -0
- package/.output/server/node_modules/node-forge/lib/sha512.js +561 -0
- package/.output/server/node_modules/node-forge/lib/ssh.js +236 -0
- package/.output/server/node_modules/node-forge/lib/tls.js +4334 -0
- package/.output/server/node_modules/node-forge/lib/util.js +2652 -0
- package/.output/server/node_modules/node-forge/lib/x509.js +3257 -0
- package/.output/server/node_modules/node-forge/package.json +123 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/buffer/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/_polyfill/events/node.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/dist/index.mjs +1 -0
- package/.output/server/node_modules/node-mock-http/package.json +63 -0
- package/.output/server/node_modules/nostics/dist/formatters/ansi.mjs +19 -0
- package/.output/server/node_modules/nostics/dist/index.mjs +194 -0
- package/.output/server/node_modules/nostics/package.json +126 -0
- package/.output/server/node_modules/pathe/dist/index.mjs +19 -0
- package/.output/server/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +249 -0
- package/.output/server/node_modules/pathe/package.json +61 -0
- package/.output/server/node_modules/picomatch/index.js +17 -0
- package/.output/server/node_modules/picomatch/lib/constants.js +184 -0
- package/.output/server/node_modules/picomatch/lib/parse.js +1425 -0
- package/.output/server/node_modules/picomatch/lib/picomatch.js +361 -0
- package/.output/server/node_modules/picomatch/lib/scan.js +403 -0
- package/.output/server/node_modules/picomatch/lib/utils.js +72 -0
- package/.output/server/node_modules/picomatch/package.json +83 -0
- package/.output/server/node_modules/radix3/dist/index.mjs +262 -0
- package/.output/server/node_modules/radix3/package.json +52 -0
- package/.output/server/node_modules/source-map-js/lib/array-set.js +121 -0
- package/.output/server/node_modules/source-map-js/lib/base64-vlq.js +140 -0
- package/.output/server/node_modules/source-map-js/lib/base64.js +67 -0
- package/.output/server/node_modules/source-map-js/lib/binary-search.js +111 -0
- package/.output/server/node_modules/source-map-js/lib/mapping-list.js +79 -0
- package/.output/server/node_modules/source-map-js/lib/quick-sort.js +141 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-consumer.js +1236 -0
- package/.output/server/node_modules/source-map-js/lib/source-map-generator.js +446 -0
- package/.output/server/node_modules/source-map-js/lib/source-node.js +420 -0
- package/.output/server/node_modules/source-map-js/lib/util.js +594 -0
- package/.output/server/node_modules/source-map-js/package.json +71 -0
- package/.output/server/node_modules/source-map-js/source-map.js +8 -0
- package/.output/server/node_modules/std-env/dist/index.mjs +1 -0
- package/.output/server/node_modules/std-env/package.json +43 -0
- package/.output/server/node_modules/tinyclip/dist/index.js +143 -0
- package/.output/server/node_modules/tinyclip/package.json +48 -0
- package/.output/server/node_modules/ufo/dist/index.mjs +645 -0
- package/.output/server/node_modules/ufo/package.json +48 -0
- package/.output/server/node_modules/uncrypto/dist/crypto.node.mjs +16 -0
- package/.output/server/node_modules/uncrypto/package.json +60 -0
- package/.output/server/node_modules/unhead/dist/client.mjs +22 -0
- package/.output/server/node_modules/unhead/dist/legacy.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/minify.mjs +183 -0
- package/.output/server/node_modules/unhead/dist/parser.mjs +518 -0
- package/.output/server/node_modules/unhead/dist/plugins.mjs +782 -0
- package/.output/server/node_modules/unhead/dist/server.mjs +99 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.BEmVMkeA.mjs +673 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bf_fPVYA.mjs +6 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.Bm4Y6XQI.mjs +17 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C5Bksi2B.mjs +49 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CGPOfp5O.mjs +32 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CHEy9ana.mjs +7 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.C_7zwq8E.mjs +11 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.CaeaMM5q.mjs +19 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D7HkBzZn.mjs +59 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.D9VfQWNo.mjs +240 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DD4N5B4k.mjs +224 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DGl9jcjg.mjs +196 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DJuZwX9c.mjs +400 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DkxnqlHC.mjs +264 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.DspMpm6y.mjs +48 -0
- package/.output/server/node_modules/unhead/dist/shared/unhead.o8j9utSy.mjs +208 -0
- package/.output/server/node_modules/unhead/dist/stream/client.mjs +33 -0
- package/.output/server/node_modules/unhead/dist/stream/iife.mjs +2 -0
- package/.output/server/node_modules/unhead/dist/stream/server.mjs +446 -0
- package/.output/server/node_modules/unhead/dist/utils.mjs +7 -0
- package/.output/server/node_modules/unhead/package.json +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/cloudflared.mjs +179 -0
- package/.output/server/node_modules/untun/dist/_chunks/log.mjs +27 -0
- package/.output/server/node_modules/untun/dist/index.mjs +47 -0
- package/.output/server/node_modules/untun/package.json +44 -0
- package/.output/server/node_modules/uqr/dist/index.mjs +739 -0
- package/.output/server/node_modules/uqr/package.json +69 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.js +80 -0
- package/.output/server/node_modules/vue/dist/vue.cjs.prod.js +66 -0
- package/.output/server/node_modules/vue/index.js +7 -0
- package/.output/server/node_modules/vue/index.mjs +1 -0
- package/.output/server/node_modules/vue/package.json +112 -0
- package/.output/server/node_modules/vue/server-renderer/index.mjs +1 -0
- package/.output/server/node_modules/vue-bundle-renderer/dist/runtime.mjs +687 -0
- package/.output/server/node_modules/vue-bundle-renderer/package.json +66 -0
- package/.output/server/node_modules/zod/index.js +7 -0
- package/.output/server/node_modules/zod/package.json +147 -0
- package/.output/server/node_modules/zod/v3/ZodError.js +143 -0
- package/.output/server/node_modules/zod/v3/errors.js +9 -0
- package/.output/server/node_modules/zod/v3/external.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/errorUtil.js +6 -0
- package/.output/server/node_modules/zod/v3/helpers/parseUtil.js +109 -0
- package/.output/server/node_modules/zod/v3/helpers/typeAliases.js +1 -0
- package/.output/server/node_modules/zod/v3/helpers/util.js +133 -0
- package/.output/server/node_modules/zod/v3/index.js +4 -0
- package/.output/server/node_modules/zod/v3/locales/en.js +109 -0
- package/.output/server/node_modules/zod/v3/package.json +7 -0
- package/.output/server/node_modules/zod/v3/types.js +3697 -0
- package/.output/server/node_modules/zod/v4/classic/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/classic/coerce.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/compat.js +31 -0
- package/.output/server/node_modules/zod/v4/classic/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/classic/errors.js +57 -0
- package/.output/server/node_modules/zod/v4/classic/external.js +17 -0
- package/.output/server/node_modules/zod/v4/classic/from-json-schema.js +881 -0
- package/.output/server/node_modules/zod/v4/classic/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/classic/index.js +4 -0
- package/.output/server/node_modules/zod/v4/classic/iso.js +15 -0
- package/.output/server/node_modules/zod/v4/classic/package.json +7 -0
- package/.output/server/node_modules/zod/v4/classic/parse.js +16 -0
- package/.output/server/node_modules/zod/v4/classic/schemas.js +1535 -0
- package/.output/server/node_modules/zod/v4/core/api.js +1107 -0
- package/.output/server/node_modules/zod/v4/core/checks.js +516 -0
- package/.output/server/node_modules/zod/v4/core/compile.js +1866 -0
- package/.output/server/node_modules/zod/v4/core/core.js +141 -0
- package/.output/server/node_modules/zod/v4/core/doc.js +38 -0
- package/.output/server/node_modules/zod/v4/core/errors.js +267 -0
- package/.output/server/node_modules/zod/v4/core/index.js +19 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-generator.js +99 -0
- package/.output/server/node_modules/zod/v4/core/json-schema-processors.js +843 -0
- package/.output/server/node_modules/zod/v4/core/json-schema.js +1 -0
- package/.output/server/node_modules/zod/v4/core/memoizer.js +311 -0
- package/.output/server/node_modules/zod/v4/core/package.json +7 -0
- package/.output/server/node_modules/zod/v4/core/parse.js +175 -0
- package/.output/server/node_modules/zod/v4/core/regexes.js +156 -0
- package/.output/server/node_modules/zod/v4/core/registries.js +51 -0
- package/.output/server/node_modules/zod/v4/core/schemas.js +2636 -0
- package/.output/server/node_modules/zod/v4/core/to-json-schema.js +651 -0
- package/.output/server/node_modules/zod/v4/core/util.js +873 -0
- package/.output/server/node_modules/zod/v4/core/versions.js +5 -0
- package/.output/server/node_modules/zod/v4/core/visit.js +169 -0
- package/.output/server/node_modules/zod/v4/index.js +4 -0
- package/.output/server/node_modules/zod/v4/locales/ar.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/az.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/be.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/bg.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/bn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ca.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ckb.js +133 -0
- package/.output/server/node_modules/zod/v4/locales/cs.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/da.js +120 -0
- package/.output/server/node_modules/zod/v4/locales/de.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/el.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/en.js +125 -0
- package/.output/server/node_modules/zod/v4/locales/eo.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/es.js +136 -0
- package/.output/server/node_modules/zod/v4/locales/fa.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/fi.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/fr-CA.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/fr.js +129 -0
- package/.output/server/node_modules/zod/v4/locales/gu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/he.js +221 -0
- package/.output/server/node_modules/zod/v4/locales/hi.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/hr.js +126 -0
- package/.output/server/node_modules/zod/v4/locales/hu.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/hy.js +158 -0
- package/.output/server/node_modules/zod/v4/locales/id.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/index.js +63 -0
- package/.output/server/node_modules/zod/v4/locales/is.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/it.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ja.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ka.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/kh.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/km.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/kn.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/ko.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/lt.js +207 -0
- package/.output/server/node_modules/zod/v4/locales/mk.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ms.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/ne.js +111 -0
- package/.output/server/node_modules/zod/v4/locales/nl.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/nn.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/no.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ota.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/package.json +7 -0
- package/.output/server/node_modules/zod/v4/locales/pl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/ps.js +119 -0
- package/.output/server/node_modules/zod/v4/locales/pt-BR.js +143 -0
- package/.output/server/node_modules/zod/v4/locales/pt.js +142 -0
- package/.output/server/node_modules/zod/v4/locales/ro.js +122 -0
- package/.output/server/node_modules/zod/v4/locales/ru.js +168 -0
- package/.output/server/node_modules/zod/v4/locales/sk.js +116 -0
- package/.output/server/node_modules/zod/v4/locales/sl.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/sv.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/ta.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tg.js +117 -0
- package/.output/server/node_modules/zod/v4/locales/th.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/tk.js +107 -0
- package/.output/server/node_modules/zod/v4/locales/tr.js +110 -0
- package/.output/server/node_modules/zod/v4/locales/ua.js +5 -0
- package/.output/server/node_modules/zod/v4/locales/uk.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/ur.js +115 -0
- package/.output/server/node_modules/zod/v4/locales/uz.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/vi.js +113 -0
- package/.output/server/node_modules/zod/v4/locales/yo.js +112 -0
- package/.output/server/node_modules/zod/v4/locales/zh-CN.js +114 -0
- package/.output/server/node_modules/zod/v4/locales/zh-TW.js +112 -0
- package/.output/server/node_modules/zod/v4/mini/checks.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/coerce.js +22 -0
- package/.output/server/node_modules/zod/v4/mini/deep-partial.js +13 -0
- package/.output/server/node_modules/zod/v4/mini/external.js +16 -0
- package/.output/server/node_modules/zod/v4/mini/in-out.js +36 -0
- package/.output/server/node_modules/zod/v4/mini/iso.js +34 -0
- package/.output/server/node_modules/zod/v4/mini/package.json +7 -0
- package/.output/server/node_modules/zod/v4/mini/parse.js +1 -0
- package/.output/server/node_modules/zod/v4/mini/schemas.js +1002 -0
- package/.output/server/node_modules/zod/v4/package.json +7 -0
- package/.output/server/node_modules/zod/v4-mini/index.js +3 -0
- package/.output/server/node_modules/zod/v4-mini/package.json +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Options.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/Refs.js +22 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/errorMessages.js +14 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js +8 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/index.js +40 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/package.json +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseDef.js +62 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parseTypes.js +1 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/any.js +17 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/array.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js +49 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js +5 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/date.js +46 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/default.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js +7 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/map.js +26 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js +16 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/never.js +11 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/null.js +10 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js +33 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/number.js +52 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/object.js +72 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js +21 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/record.js +61 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/set.js +20 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/string.js +352 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js +32 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js +6 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/union.js +80 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js +4 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/selectParser.js +105 -0
- package/.output/server/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js +87 -0
- package/.output/server/node_modules/zod-to-json-schema/package.json +85 -0
- package/.output/server/package.json +64 -0
- package/README.md +226 -23
- package/bin/bantou.mjs +33 -0
- package/package.json +18 -8
- package/protocol/PROTOCOL.md +26 -0
- package/protocol/protocol.json +92 -0
- package/dist/cap.js +0 -7
- package/dist/cli.js +0 -27
- package/dist/config.js +0 -23
- package/dist/daemon.js +0 -23
- package/dist/session.js +0 -7
- package/dist/workspace.js +0 -8
|
@@ -0,0 +1,1371 @@
|
|
|
1
|
+
const NAPI_OK = 0;
|
|
2
|
+
const NAPI_GENERIC_FAILURE = 9;
|
|
3
|
+
const NAPI_PENDING_EXCEPTION = 10;
|
|
4
|
+
const NAPI_CANCELED = 11;
|
|
5
|
+
const NAPI_HANDLE_SCOPE_MISMATCH = 13;
|
|
6
|
+
const NAPI_NO_EXTERNAL_BUFFERS_ALLOWED = 22;
|
|
7
|
+
|
|
8
|
+
// https://nodejs.org/api/n-api.html#napi_property_attributes
|
|
9
|
+
const NAPI_WRITABLE = 1 << 0;
|
|
10
|
+
const NAPI_ENUMERABLE = 1 << 1;
|
|
11
|
+
const NAPI_CONFIGURABLE = 1 << 2;
|
|
12
|
+
const NAPI_STATIC = 1 << 10;
|
|
13
|
+
|
|
14
|
+
// https://nodejs.org/api/n-api.html#napi_typedarray_type
|
|
15
|
+
const typedArrays = [
|
|
16
|
+
Int8Array,
|
|
17
|
+
Uint8Array,
|
|
18
|
+
Uint8ClampedArray,
|
|
19
|
+
Int16Array,
|
|
20
|
+
Uint16Array,
|
|
21
|
+
Int32Array,
|
|
22
|
+
Uint32Array,
|
|
23
|
+
Float32Array,
|
|
24
|
+
Float64Array,
|
|
25
|
+
BigInt64Array,
|
|
26
|
+
BigUint64Array
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
const environments = [];
|
|
30
|
+
|
|
31
|
+
export class Environment {
|
|
32
|
+
scopes = [];
|
|
33
|
+
referenceId = 1;
|
|
34
|
+
references = new Map();
|
|
35
|
+
deferred = [null];
|
|
36
|
+
wrappedObjects = new WeakMap();
|
|
37
|
+
externalObjects = new WeakMap();
|
|
38
|
+
buffers = new Map();
|
|
39
|
+
instanceData = 0;
|
|
40
|
+
pendingException = null;
|
|
41
|
+
|
|
42
|
+
constructor(instance) {
|
|
43
|
+
this.id = environments.length;
|
|
44
|
+
environments.push(this);
|
|
45
|
+
|
|
46
|
+
this.instance = instance;
|
|
47
|
+
this.table = instance.exports.__indirect_function_table;
|
|
48
|
+
this.exports = {};
|
|
49
|
+
|
|
50
|
+
this.pushScope();
|
|
51
|
+
let values = this.scopes[this.scopes.length - 1];
|
|
52
|
+
let exports = values.length;
|
|
53
|
+
values.push(this.exports);
|
|
54
|
+
|
|
55
|
+
try {
|
|
56
|
+
if (this.instance.exports.napi_register_module_v1) {
|
|
57
|
+
this.instance.exports.napi_register_module_v1(this.id, exports);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (this.instance.exports.napi_register_wasm_v1) {
|
|
61
|
+
this.instance.exports.napi_register_wasm_v1(this.id, exports);
|
|
62
|
+
}
|
|
63
|
+
} finally {
|
|
64
|
+
this.popScope();
|
|
65
|
+
if (this.pendingException) {
|
|
66
|
+
let e = this.pendingException;
|
|
67
|
+
this.pendingException = null;
|
|
68
|
+
throw e;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
destroy() {
|
|
74
|
+
environments[this.id] = undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getString(ptr, len = strlen(this.memory, ptr)) {
|
|
78
|
+
return decoder.decode(this.memory.subarray(ptr, Math.max(0, ptr + len)));
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
pushScope() {
|
|
82
|
+
let id = this.scopes.length;
|
|
83
|
+
this.scopes.push(id ? [...this.scopes[id - 1]] : [undefined, null, globalThis, true, false]);
|
|
84
|
+
return id;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
popScope() {
|
|
88
|
+
this.scopes.pop();
|
|
89
|
+
|
|
90
|
+
// Update any buffers with values which might have been modified in WASM copy.
|
|
91
|
+
for (let [buffer, slice] of this.buffers) {
|
|
92
|
+
// Ignore if buffer or slice has been detached.
|
|
93
|
+
if (buffer.byteLength && slice.byteLength) {
|
|
94
|
+
buffer.set(slice);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.buffers.clear();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get(idx) {
|
|
102
|
+
return this.scopes[this.scopes.length - 1][idx];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
set(idx, value) {
|
|
106
|
+
this.scopes[this.scopes.length - 1][idx] = value;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
pushValue(value, scope = this.scopes.length - 1) {
|
|
110
|
+
let values = this.scopes[scope];
|
|
111
|
+
let id = values.length;
|
|
112
|
+
values.push(value);
|
|
113
|
+
return id;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
createValue(value, result, scope) {
|
|
117
|
+
if (typeof value === 'boolean') {
|
|
118
|
+
this.setPointer(result, value ? 3 : 4);
|
|
119
|
+
return NAPI_OK;
|
|
120
|
+
} else if (typeof value === 'undefined') {
|
|
121
|
+
this.setPointer(result, 0);
|
|
122
|
+
return NAPI_OK;
|
|
123
|
+
} else if (value === null) {
|
|
124
|
+
this.setPointer(result, 1);
|
|
125
|
+
return NAPI_OK;
|
|
126
|
+
} else if (value === globalThis) {
|
|
127
|
+
this.setPointer(result, 2);
|
|
128
|
+
return NAPI_OK;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let id = this.pushValue(value, scope);
|
|
132
|
+
this.setPointer(result, id);
|
|
133
|
+
return NAPI_OK;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
setPointer(ptr, value) {
|
|
137
|
+
this.u32[ptr >> 2] = value;
|
|
138
|
+
return NAPI_OK;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_u32 = new Uint32Array();
|
|
142
|
+
get u32() {
|
|
143
|
+
if (this._u32.byteLength === 0) {
|
|
144
|
+
this._u32 = new Uint32Array(this.instance.exports.memory.buffer);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return this._u32;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
_i32 = new Int32Array();
|
|
151
|
+
get i32() {
|
|
152
|
+
if (this._i32.byteLength === 0) {
|
|
153
|
+
this._i32 = new Int32Array(this.instance.exports.memory.buffer);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return this._i32;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
_u16 = new Uint16Array();
|
|
160
|
+
get u16() {
|
|
161
|
+
if (this._u16.byteLength === 0) {
|
|
162
|
+
this._u16 = new Uint16Array(this.instance.exports.memory.buffer);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return this._u16;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_u64 = new BigUint64Array();
|
|
169
|
+
get u64() {
|
|
170
|
+
if (this._u64.byteLength === 0) {
|
|
171
|
+
this._u64 = new BigUint64Array(this.instance.exports.memory.buffer);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return this._u64;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
_i64 = new BigInt64Array();
|
|
178
|
+
get i64() {
|
|
179
|
+
if (this._i64.byteLength === 0) {
|
|
180
|
+
this._i64 = new BigInt64Array(this.instance.exports.memory.buffer);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return this._i64;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
_f64 = new Float64Array();
|
|
187
|
+
get f64() {
|
|
188
|
+
if (this._f64.byteLength === 0) {
|
|
189
|
+
this._f64 = new Float64Array(this.instance.exports.memory.buffer);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return this._f64;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
_buf = new Uint8Array();
|
|
196
|
+
get memory() {
|
|
197
|
+
if (this._buf.byteLength === 0) {
|
|
198
|
+
this._buf = new Uint8Array(this.instance.exports.memory.buffer);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return this._buf;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
getBufferInfo(buf, ptr) {
|
|
205
|
+
if (this.buffers.has(buf)) {
|
|
206
|
+
let b = this.buffers.get(buf);
|
|
207
|
+
this.setPointer(ptr, b.byteOffset);
|
|
208
|
+
return b.byteLength;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (buf instanceof ArrayBuffer) {
|
|
212
|
+
let b = this.copyBuffer(new Uint8Array(buf));
|
|
213
|
+
this.setPointer(ptr, b.byteOffset);
|
|
214
|
+
return b.byteLength;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// If this is a view into WASM memory, no copies needed.
|
|
218
|
+
if (buf.buffer === this.instance.exports.memory.buffer) {
|
|
219
|
+
this.setPointer(ptr, buf.byteOffset);
|
|
220
|
+
return buf.byteLength;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
let b = this.copyBuffer(new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength));
|
|
224
|
+
this.setPointer(ptr, b.byteOffset);
|
|
225
|
+
return b.byteLength;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
copyBuffer(data) {
|
|
229
|
+
let ptr = this.instance.exports.napi_wasm_malloc(data.byteLength);
|
|
230
|
+
let mem = this.memory;
|
|
231
|
+
mem.set(data, ptr);
|
|
232
|
+
let buf = mem.subarray(ptr, ptr + data.byteLength);
|
|
233
|
+
this.buffers.set(data, buf);
|
|
234
|
+
return buf;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
createFunction(cb, data) {
|
|
238
|
+
let env = this;
|
|
239
|
+
let fn = env.table.get(cb);
|
|
240
|
+
let func = function (...args) {
|
|
241
|
+
let scope = env.pushScope();
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
let values = env.scopes[scope];
|
|
245
|
+
let info = values.length;
|
|
246
|
+
values.push({
|
|
247
|
+
thisArg: this,
|
|
248
|
+
args,
|
|
249
|
+
data,
|
|
250
|
+
newTarget: new.target
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
let res = fn(env.id, info);
|
|
254
|
+
return env.get(res);
|
|
255
|
+
} finally {
|
|
256
|
+
env.popScope();
|
|
257
|
+
if (env.pendingException) {
|
|
258
|
+
let e = env.pendingException;
|
|
259
|
+
env.pendingException = null;
|
|
260
|
+
throw e;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
return func;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
readPropertyDescriptor(ptr) {
|
|
269
|
+
// https://nodejs.org/api/n-api.html#napi_property_descriptor
|
|
270
|
+
let buf = this.u32;
|
|
271
|
+
let utf8name = buf[ptr++];
|
|
272
|
+
let nameValue = buf[ptr++];
|
|
273
|
+
let method = buf[ptr++];
|
|
274
|
+
let getter = buf[ptr++];
|
|
275
|
+
let setter = buf[ptr++];
|
|
276
|
+
let val = buf[ptr++];
|
|
277
|
+
let attrs = buf[ptr++];
|
|
278
|
+
let data = buf[ptr++];
|
|
279
|
+
|
|
280
|
+
let name = utf8name ? this.getString(utf8name) : this.get(nameValue);
|
|
281
|
+
let writable = Boolean(attrs & NAPI_WRITABLE);
|
|
282
|
+
let enumerable = Boolean(attrs & NAPI_ENUMERABLE);
|
|
283
|
+
let configurable = Boolean(attrs & NAPI_CONFIGURABLE);
|
|
284
|
+
let isStatic = Boolean(attrs & NAPI_STATIC);
|
|
285
|
+
let get = getter ? this.createFunction(getter, data) : undefined;
|
|
286
|
+
let set = setter ? this.createFunction(setter, data) : undefined;
|
|
287
|
+
let value = method ? this.createFunction(method, data) : val ? this.get(val) : undefined;
|
|
288
|
+
|
|
289
|
+
let descriptor = {
|
|
290
|
+
name,
|
|
291
|
+
static: isStatic,
|
|
292
|
+
configurable,
|
|
293
|
+
enumerable
|
|
294
|
+
};
|
|
295
|
+
if (get || set) {
|
|
296
|
+
descriptor.get = get;
|
|
297
|
+
descriptor.set = set;
|
|
298
|
+
} else if (value) {
|
|
299
|
+
descriptor.writable = writable;
|
|
300
|
+
descriptor.value = value;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
return descriptor;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const decoder = new TextDecoder("utf-8", { ignoreBOM: true, fatal: true });
|
|
308
|
+
const latin1Decoder = new TextDecoder('latin1');
|
|
309
|
+
const utf16Decoder = new TextDecoder('utf-16');
|
|
310
|
+
const encoder = new TextEncoder();
|
|
311
|
+
|
|
312
|
+
class FinalizeRecord {
|
|
313
|
+
constructor(env, finalize, hint, data) {
|
|
314
|
+
this.env = env;
|
|
315
|
+
this.finalize = finalize;
|
|
316
|
+
this.hint = hint;
|
|
317
|
+
this.data = data;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const finalizationRegistry = new FinalizationRegistry(buffer => {
|
|
322
|
+
if (buffer.finalize) {
|
|
323
|
+
buffer.finalize(buffer.env, buffer.data, buffer.hint);
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
class ExternalValue {}
|
|
328
|
+
|
|
329
|
+
const threadsafeFunctions = [];
|
|
330
|
+
|
|
331
|
+
class ThreadSafeFunction {
|
|
332
|
+
constructor(env, fn, nativeFn, context) {
|
|
333
|
+
this.env = env;
|
|
334
|
+
this.fn = fn;
|
|
335
|
+
this.nativeFn = nativeFn;
|
|
336
|
+
this.context = context;
|
|
337
|
+
this.id = threadsafeFunctions.length;
|
|
338
|
+
threadsafeFunctions.push(this);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const asyncWork = [null];
|
|
343
|
+
|
|
344
|
+
class AsyncWork {
|
|
345
|
+
constructor(env, execute, complete, data) {
|
|
346
|
+
this.env = env;
|
|
347
|
+
this.execute = execute;
|
|
348
|
+
this.complete = complete;
|
|
349
|
+
this.data = data;
|
|
350
|
+
this.id = asyncWork.length;
|
|
351
|
+
asyncWork.push(this);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
export const napi = {
|
|
356
|
+
napi_open_handle_scope(env_id, result) {
|
|
357
|
+
let env = environments[env_id];
|
|
358
|
+
let id = env.pushScope();
|
|
359
|
+
return env.setPointer(result, id);
|
|
360
|
+
},
|
|
361
|
+
napi_close_handle_scope(env_id, scope) {
|
|
362
|
+
let env = environments[env_id];
|
|
363
|
+
if (scope !== env.scopes.length - 1) {
|
|
364
|
+
return NAPI_HANDLE_SCOPE_MISMATCH;
|
|
365
|
+
}
|
|
366
|
+
env.popScope();
|
|
367
|
+
return NAPI_OK;
|
|
368
|
+
},
|
|
369
|
+
napi_open_escapable_handle_scope(env_id, result) {
|
|
370
|
+
let env = environments[env_id];
|
|
371
|
+
let id = env.pushScope();
|
|
372
|
+
return env.setPointer(result, id);
|
|
373
|
+
},
|
|
374
|
+
napi_close_escapable_handle_scope(env_id, scope) {
|
|
375
|
+
let env = environments[env_id];
|
|
376
|
+
if (scope !== env.scopes.length - 1) {
|
|
377
|
+
return NAPI_HANDLE_SCOPE_MISMATCH;
|
|
378
|
+
}
|
|
379
|
+
env.popScope();
|
|
380
|
+
return NAPI_OK;
|
|
381
|
+
},
|
|
382
|
+
napi_escape_handle(env_id, scope_id, escapee, result) {
|
|
383
|
+
let env = environments[env_id];
|
|
384
|
+
let value = env.get(escapee);
|
|
385
|
+
// Create a value in the outer scope.
|
|
386
|
+
return env.createValue(value, result, scope_id - 1);
|
|
387
|
+
},
|
|
388
|
+
napi_create_object(env_id, result) {
|
|
389
|
+
let env = environments[env_id];
|
|
390
|
+
return env.createValue({}, result);
|
|
391
|
+
},
|
|
392
|
+
napi_set_property(env_id, object, key, value) {
|
|
393
|
+
let env = environments[env_id];
|
|
394
|
+
let obj = env.get(object);
|
|
395
|
+
let name = env.get(key);
|
|
396
|
+
let val = env.get(value);
|
|
397
|
+
obj[name] = val;
|
|
398
|
+
return NAPI_OK;
|
|
399
|
+
},
|
|
400
|
+
napi_get_property(env_id, object, key, result) {
|
|
401
|
+
let env = environments[env_id];
|
|
402
|
+
let obj = env.get(object);
|
|
403
|
+
let name = env.get(key);
|
|
404
|
+
return env.createValue(obj[name], result);
|
|
405
|
+
},
|
|
406
|
+
napi_delete_property(env_id, object, key, result) {
|
|
407
|
+
let env = environments[env_id];
|
|
408
|
+
let obj = env.get(object);
|
|
409
|
+
let name = env.get(key);
|
|
410
|
+
let res = false;
|
|
411
|
+
try {
|
|
412
|
+
res = delete obj[name];
|
|
413
|
+
} catch (err) {}
|
|
414
|
+
if (result) {
|
|
415
|
+
env.memory[result] = res ? 1 : 0;
|
|
416
|
+
}
|
|
417
|
+
return NAPI_OK;
|
|
418
|
+
},
|
|
419
|
+
napi_has_property(env_id, object, key, result) {
|
|
420
|
+
let env = environments[env_id];
|
|
421
|
+
let obj = env.get(object);
|
|
422
|
+
let name = env.get(key);
|
|
423
|
+
// return env.setPointer(result, name in obj ? 1 : 0);
|
|
424
|
+
env.memory[result] = name in obj ? 1 : 0;
|
|
425
|
+
return NAPI_OK;
|
|
426
|
+
},
|
|
427
|
+
napi_has_own_property(env_id, object, key, result) {
|
|
428
|
+
let env = environments[env_id];
|
|
429
|
+
let obj = env.get(object);
|
|
430
|
+
let name = env.get(key);
|
|
431
|
+
env.memory[result] = obj.hasOwnProperty(name) ? 1 : 0;
|
|
432
|
+
return NAPI_OK;
|
|
433
|
+
},
|
|
434
|
+
napi_set_named_property(env_id, object, utf8Name, value) {
|
|
435
|
+
let env = environments[env_id];
|
|
436
|
+
let obj = env.get(object);
|
|
437
|
+
let val = env.get(value);
|
|
438
|
+
let name = env.getString(utf8Name);
|
|
439
|
+
obj[name] = val;
|
|
440
|
+
return NAPI_OK;
|
|
441
|
+
},
|
|
442
|
+
napi_get_named_property(env_id, object, utf8Name, result) {
|
|
443
|
+
let env = environments[env_id];
|
|
444
|
+
let obj = env.get(object);
|
|
445
|
+
let name = env.getString(utf8Name);
|
|
446
|
+
return env.createValue(obj[name], result);
|
|
447
|
+
},
|
|
448
|
+
napi_has_named_property(env_id, object, utf8Name, result) {
|
|
449
|
+
let env = environments[env_id];
|
|
450
|
+
let obj = env.get(object);
|
|
451
|
+
let name = env.getString(utf8Name);
|
|
452
|
+
env.memory[result] = name in obj ? 1 : 0;
|
|
453
|
+
return NAPI_OK;
|
|
454
|
+
},
|
|
455
|
+
napi_get_property_names(env_id, object, result) {
|
|
456
|
+
let env = environments[env_id];
|
|
457
|
+
let obj = env.get(object);
|
|
458
|
+
let properties = Object.keys(obj);
|
|
459
|
+
return env.createValue(properties, result);
|
|
460
|
+
},
|
|
461
|
+
napi_get_all_property_names(env_id, object, key_mode, key_filter, key_conversion, result) {
|
|
462
|
+
throw new Error('not implemented');
|
|
463
|
+
},
|
|
464
|
+
napi_define_properties(env_id, object, property_count, properties) {
|
|
465
|
+
let env = environments[env_id];
|
|
466
|
+
let obj = env.get(object);
|
|
467
|
+
let ptr = properties >> 2;
|
|
468
|
+
for (let i = 0; i < property_count; i++) {
|
|
469
|
+
let descriptor = env.readPropertyDescriptor(ptr);
|
|
470
|
+
Object.defineProperty(obj, descriptor.name, descriptor);
|
|
471
|
+
ptr += 8;
|
|
472
|
+
}
|
|
473
|
+
return NAPI_OK;
|
|
474
|
+
},
|
|
475
|
+
napi_object_freeze(env_id, object) {
|
|
476
|
+
let env = environments[env_id];
|
|
477
|
+
let obj = env.get(object);
|
|
478
|
+
Object.freeze(obj);
|
|
479
|
+
return NAPI_OK;
|
|
480
|
+
},
|
|
481
|
+
napi_object_seal(env_id, object) {
|
|
482
|
+
let env = environments[env_id];
|
|
483
|
+
let obj = env.get(object);
|
|
484
|
+
Object.seal(obj);
|
|
485
|
+
return NAPI_OK;
|
|
486
|
+
},
|
|
487
|
+
napi_get_prototype(env_id, object, result) {
|
|
488
|
+
let env = environments[env_id];
|
|
489
|
+
let obj = env.get(object);
|
|
490
|
+
return env.createValue(Object.getPrototypeOf(obj), result);
|
|
491
|
+
},
|
|
492
|
+
napi_define_class(env_id, utf8name, length, constructor, data, property_count, properties, result) {
|
|
493
|
+
let env = environments[env_id];
|
|
494
|
+
let func = env.createFunction(constructor, data);
|
|
495
|
+
|
|
496
|
+
Object.defineProperty(func, 'name', {
|
|
497
|
+
value: env.getString(utf8name, length),
|
|
498
|
+
configurable: true
|
|
499
|
+
});
|
|
500
|
+
|
|
501
|
+
let ptr = properties >> 2;
|
|
502
|
+
for (let i = 0; i < property_count; i++) {
|
|
503
|
+
let descriptor = env.readPropertyDescriptor(ptr);
|
|
504
|
+
if (descriptor.static) {
|
|
505
|
+
Object.defineProperty(func, descriptor.name, descriptor);
|
|
506
|
+
} else {
|
|
507
|
+
Object.defineProperty(func.prototype, descriptor.name, descriptor);
|
|
508
|
+
}
|
|
509
|
+
ptr += 8;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return env.createValue(func, result);
|
|
513
|
+
},
|
|
514
|
+
napi_create_reference(env_id, value, refcount, result) {
|
|
515
|
+
let env = environments[env_id];
|
|
516
|
+
let id = env.referenceId++;
|
|
517
|
+
env.references.set(id, {
|
|
518
|
+
value: env.get(value),
|
|
519
|
+
refcount
|
|
520
|
+
});
|
|
521
|
+
return env.setPointer(result, id);
|
|
522
|
+
},
|
|
523
|
+
napi_delete_reference(env_id, ref) {
|
|
524
|
+
let env = environments[env_id];
|
|
525
|
+
env.references.delete(ref);
|
|
526
|
+
return NAPI_OK;
|
|
527
|
+
},
|
|
528
|
+
napi_get_reference_value(env_id, ref, result) {
|
|
529
|
+
let env = environments[env_id];
|
|
530
|
+
let reference = env.references.get(ref);
|
|
531
|
+
return env.createValue(reference.value, result);
|
|
532
|
+
},
|
|
533
|
+
napi_reference_ref(env_id, ref, result) {
|
|
534
|
+
let env = environments[env_id];
|
|
535
|
+
let reference = env.references.get(ref);
|
|
536
|
+
reference.refcount++;
|
|
537
|
+
return env.setPointer(result, reference.refcount);
|
|
538
|
+
},
|
|
539
|
+
napi_reference_unref(env_id, ref, result) {
|
|
540
|
+
let env = environments[env_id];
|
|
541
|
+
let reference = env.references.get(ref);
|
|
542
|
+
if (reference.refcount === 0) {
|
|
543
|
+
return NAPI_GENERIC_FAILURE;
|
|
544
|
+
}
|
|
545
|
+
reference.refcount--;
|
|
546
|
+
return env.setPointer(result, reference.refcount);
|
|
547
|
+
},
|
|
548
|
+
napi_add_env_cleanup_hook() {
|
|
549
|
+
return NAPI_OK;
|
|
550
|
+
},
|
|
551
|
+
napi_remove_env_cleanup_hook() {
|
|
552
|
+
return NAPI_OK;
|
|
553
|
+
},
|
|
554
|
+
napi_add_async_cleanup_hook() {
|
|
555
|
+
return NAPI_OK;
|
|
556
|
+
},
|
|
557
|
+
napi_remove_async_cleanup_hook() {
|
|
558
|
+
return NAPI_OK;
|
|
559
|
+
},
|
|
560
|
+
napi_set_instance_data(env_id, data, finalize_cb, finalize_hint) {
|
|
561
|
+
let env = environments[env_id];
|
|
562
|
+
env.instanceData = data;
|
|
563
|
+
return NAPI_OK;
|
|
564
|
+
},
|
|
565
|
+
napi_get_instance_data(env_id, data) {
|
|
566
|
+
let env = environments[env_id];
|
|
567
|
+
return env.setPointer(data, env.instanceData);
|
|
568
|
+
},
|
|
569
|
+
napi_get_boolean(env_id, value, result) {
|
|
570
|
+
let env = environments[env_id];
|
|
571
|
+
return env.setPointer(result, value ? 3 : 4);
|
|
572
|
+
},
|
|
573
|
+
napi_get_value_bool(env_id, value, result) {
|
|
574
|
+
let env = environments[env_id];
|
|
575
|
+
let val = env.get(value);
|
|
576
|
+
env.memory[result] = val ? 1 : 0;
|
|
577
|
+
return NAPI_OK;
|
|
578
|
+
},
|
|
579
|
+
napi_create_int32(env_id, value, result) {
|
|
580
|
+
let env = environments[env_id];
|
|
581
|
+
return env.createValue(value, result);
|
|
582
|
+
},
|
|
583
|
+
napi_get_value_int32(env_id, value, result) {
|
|
584
|
+
let env = environments[env_id];
|
|
585
|
+
let val = env.get(value);
|
|
586
|
+
env.i32[result >> 2] = val;
|
|
587
|
+
return NAPI_OK;
|
|
588
|
+
},
|
|
589
|
+
napi_create_uint32(env_id, value, result) {
|
|
590
|
+
let env = environments[env_id];
|
|
591
|
+
return env.createValue(value, result);
|
|
592
|
+
},
|
|
593
|
+
napi_get_value_uint32(env_id, value, result) {
|
|
594
|
+
let env = environments[env_id];
|
|
595
|
+
let val = env.get(value);
|
|
596
|
+
return env.setPointer(result, val);
|
|
597
|
+
},
|
|
598
|
+
napi_create_int64(env_id, value, result) {
|
|
599
|
+
let env = environments[env_id];
|
|
600
|
+
return env.createValue(Number(value), result);
|
|
601
|
+
},
|
|
602
|
+
napi_get_value_int64(env_id, value, result) {
|
|
603
|
+
let env = environments[env_id];
|
|
604
|
+
let val = env.get(value);
|
|
605
|
+
env.i64[result >> 3] = val;
|
|
606
|
+
return NAPI_OK;
|
|
607
|
+
},
|
|
608
|
+
napi_create_double(env_id, value, result) {
|
|
609
|
+
let env = environments[env_id];
|
|
610
|
+
return env.createValue(value, result);
|
|
611
|
+
},
|
|
612
|
+
napi_get_value_double(env_id, value, result) {
|
|
613
|
+
let env = environments[env_id];
|
|
614
|
+
let val = env.get(value);
|
|
615
|
+
env.f64[result >> 3] = val;
|
|
616
|
+
return NAPI_OK;
|
|
617
|
+
},
|
|
618
|
+
napi_create_bigint_int64(env_id, value, result) {
|
|
619
|
+
let env = environments[env_id];
|
|
620
|
+
return env.createValue(BigInt.asIntN(64, value), result);
|
|
621
|
+
},
|
|
622
|
+
napi_get_value_bigint_int64(env_id, value, result, lossless) {
|
|
623
|
+
let env = environments[env_id];
|
|
624
|
+
let val = env.get(value);
|
|
625
|
+
env.i64[result >> 3] = val;
|
|
626
|
+
if (lossless) {
|
|
627
|
+
env.memory[lossless] = BigInt.asIntN(64, val) === val ? 1 : 0;
|
|
628
|
+
}
|
|
629
|
+
return NAPI_OK;
|
|
630
|
+
},
|
|
631
|
+
napi_create_bigint_uint64(env_id, value, result) {
|
|
632
|
+
let env = environments[env_id];
|
|
633
|
+
return env.createValue(BigInt.asUintN(64, value), result);
|
|
634
|
+
},
|
|
635
|
+
napi_get_value_bigint_uint64(env_id, value, result, lossless) {
|
|
636
|
+
let env = environments[env_id];
|
|
637
|
+
let val = env.get(value);
|
|
638
|
+
env.u64[result >> 3] = val;
|
|
639
|
+
if (lossless) {
|
|
640
|
+
env.memory[lossless] = BigInt.asUintN(64, val) === val ? 1 : 0;
|
|
641
|
+
}
|
|
642
|
+
return NAPI_OK;
|
|
643
|
+
},
|
|
644
|
+
napi_create_bigint_words(env_id, sign_bit, word_count, words, result) {
|
|
645
|
+
let env = environments[env_id];
|
|
646
|
+
let buf = env.u64;
|
|
647
|
+
let ptr = words >> 3;
|
|
648
|
+
let res = 0n;
|
|
649
|
+
let shift = 0n;
|
|
650
|
+
|
|
651
|
+
for (let i = 0; i < word_count; i++) {
|
|
652
|
+
let word = buf[ptr++];
|
|
653
|
+
res += word << shift;
|
|
654
|
+
shift += 64n;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
res *= BigInt((-1) ** sign_bit);
|
|
658
|
+
return env.createValue(res, result);
|
|
659
|
+
},
|
|
660
|
+
napi_get_value_bigint_words(env_id, value, sign_bit, word_count, words) {
|
|
661
|
+
let env = environments[env_id];
|
|
662
|
+
let val = env.get(value);
|
|
663
|
+
let count = env.u32[word_count >> 2];
|
|
664
|
+
|
|
665
|
+
if (sign_bit) {
|
|
666
|
+
env.i32[sign_bit] = val < 0n ? 1 : 0;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
let i = 0;
|
|
670
|
+
if (words) {
|
|
671
|
+
let mask = (1n << 64n) - 1n;
|
|
672
|
+
let buf = env.u64;
|
|
673
|
+
let ptr = words >> 3;
|
|
674
|
+
if (val < 0n) {
|
|
675
|
+
val = -val;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
for (; i < count && val !== 0n; i++) {
|
|
679
|
+
buf[ptr++] = val & mask;
|
|
680
|
+
val >>= 64n;
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
while (val > 0n) {
|
|
685
|
+
i++;
|
|
686
|
+
val >>= 64n;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
return env.setPointer(word_count, i);
|
|
690
|
+
},
|
|
691
|
+
napi_get_null(env_id, result) {
|
|
692
|
+
let env = environments[env_id];
|
|
693
|
+
return env.setPointer(result, 1);
|
|
694
|
+
},
|
|
695
|
+
napi_create_array(env_id, result) {
|
|
696
|
+
let env = environments[env_id];
|
|
697
|
+
return env.createValue([], result);
|
|
698
|
+
},
|
|
699
|
+
napi_create_array_with_length(env_id, length, result) {
|
|
700
|
+
let env = environments[env_id];
|
|
701
|
+
return env.createValue(new Array(length), result);
|
|
702
|
+
},
|
|
703
|
+
napi_set_element(env_id, object, index, value) {
|
|
704
|
+
let env = environments[env_id];
|
|
705
|
+
let obj = env.get(object);
|
|
706
|
+
let val = env.get(value);
|
|
707
|
+
obj[index] = val;
|
|
708
|
+
return NAPI_OK;
|
|
709
|
+
},
|
|
710
|
+
napi_get_element(env_id, object, index, result) {
|
|
711
|
+
let env = environments[env_id];
|
|
712
|
+
let obj = env.get(object);
|
|
713
|
+
let val = obj[index];
|
|
714
|
+
return env.createValue(val, result);
|
|
715
|
+
},
|
|
716
|
+
napi_has_element(env_id, object, index, result) {
|
|
717
|
+
let env = environments[env_id];
|
|
718
|
+
let obj = env.get(object);
|
|
719
|
+
env.memory[result] = obj.hasOwnProperty(index) ? 1 : 0;
|
|
720
|
+
return NAPI_OK;
|
|
721
|
+
},
|
|
722
|
+
napi_delete_element(env_id, object, index, result) {
|
|
723
|
+
let env = environments[env_id];
|
|
724
|
+
let obj = env.get(object);
|
|
725
|
+
let res = false;
|
|
726
|
+
try {
|
|
727
|
+
res = delete obj[index];
|
|
728
|
+
} catch (err) {}
|
|
729
|
+
if (result) {
|
|
730
|
+
env.memory[result] = res ? 1 : 0;
|
|
731
|
+
}
|
|
732
|
+
return NAPI_OK;
|
|
733
|
+
},
|
|
734
|
+
napi_get_array_length(env_id, value, result) {
|
|
735
|
+
let env = environments[env_id];
|
|
736
|
+
let val = env.get(value);
|
|
737
|
+
return env.setPointer(result, val.length);
|
|
738
|
+
},
|
|
739
|
+
napi_get_undefined(env_id, result) {
|
|
740
|
+
let env = environments[env_id];
|
|
741
|
+
return env.setPointer(result, 0);
|
|
742
|
+
},
|
|
743
|
+
napi_create_function(env_id, utf8name, length, cb, data, result) {
|
|
744
|
+
let env = environments[env_id];
|
|
745
|
+
let func = env.createFunction(cb, data);
|
|
746
|
+
|
|
747
|
+
Object.defineProperty(func, 'name', {
|
|
748
|
+
value: env.getString(utf8name, length),
|
|
749
|
+
configurable: true
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
return env.createValue(func, result);
|
|
753
|
+
},
|
|
754
|
+
napi_call_function(env_id, recv, func, argc, argv, result) {
|
|
755
|
+
let env = environments[env_id];
|
|
756
|
+
let thisArg = env.get(recv);
|
|
757
|
+
let fn = env.get(func);
|
|
758
|
+
let args = new Array(argc);
|
|
759
|
+
let mem = env.u32;
|
|
760
|
+
for (let i = 0; i < argc; i++) {
|
|
761
|
+
args[i] = env.get(mem[argv >> 2]);
|
|
762
|
+
argv += 4;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
try {
|
|
766
|
+
let res = fn.apply(thisArg, args);
|
|
767
|
+
return env.createValue(res, result);
|
|
768
|
+
} catch (err) {
|
|
769
|
+
env.pendingException = err;
|
|
770
|
+
return NAPI_PENDING_EXCEPTION;
|
|
771
|
+
}
|
|
772
|
+
},
|
|
773
|
+
napi_new_instance(env_id, cons, argc, argv, result) {
|
|
774
|
+
let env = environments[env_id];
|
|
775
|
+
let Class = env.get(cons);
|
|
776
|
+
let args = new Array(argc);
|
|
777
|
+
let mem = env.u32;
|
|
778
|
+
for (let i = 0; i < argc; i++) {
|
|
779
|
+
args[i] = env.get(mem[argv >> 2]);
|
|
780
|
+
argv += 4;
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
try {
|
|
784
|
+
let value = new Class(...args);
|
|
785
|
+
return env.createValue(value, result);
|
|
786
|
+
} catch (err) {
|
|
787
|
+
env.pendingException = err;
|
|
788
|
+
return NAPI_PENDING_EXCEPTION;
|
|
789
|
+
}
|
|
790
|
+
},
|
|
791
|
+
napi_get_cb_info(env_id, cbinfo, argc, argv, thisArg, data) {
|
|
792
|
+
let env = environments[env_id];
|
|
793
|
+
let info = env.get(cbinfo);
|
|
794
|
+
env.setPointer(argc, info.args.length);
|
|
795
|
+
for (let i = 0; i < info.args.length; i++) {
|
|
796
|
+
env.createValue(info.args[i], argv);
|
|
797
|
+
argv += 4;
|
|
798
|
+
}
|
|
799
|
+
env.createValue(info.thisArg, thisArg);
|
|
800
|
+
env.setPointer(data, info.data);
|
|
801
|
+
return NAPI_OK;
|
|
802
|
+
},
|
|
803
|
+
napi_get_new_target(env_id, cbinfo, result) {
|
|
804
|
+
let env = environments[env_id];
|
|
805
|
+
let info = env.get(cbinfo);
|
|
806
|
+
return env.createValue(info.newTarget, result);
|
|
807
|
+
},
|
|
808
|
+
napi_create_threadsafe_function(
|
|
809
|
+
env_id,
|
|
810
|
+
func,
|
|
811
|
+
async_resource,
|
|
812
|
+
async_resource_name,
|
|
813
|
+
max_queue_size,
|
|
814
|
+
initial_thread_count,
|
|
815
|
+
thread_finalize_data,
|
|
816
|
+
thread_finalize_cb,
|
|
817
|
+
context,
|
|
818
|
+
call_js_cb,
|
|
819
|
+
result
|
|
820
|
+
) {
|
|
821
|
+
let env = environments[env_id];
|
|
822
|
+
let fn = func ? env.get(func) : undefined;
|
|
823
|
+
let cb = call_js_cb ? env.table.get(call_js_cb) : undefined;
|
|
824
|
+
let f = new ThreadSafeFunction(env, fn, cb, context);
|
|
825
|
+
|
|
826
|
+
if (thread_finalize_cb) {
|
|
827
|
+
let cb = env.table.get(thread_finalize_cb);
|
|
828
|
+
finalizationRegistry.register(f, new FinalizeRecord(env_id, cb, 0, f.id));
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
env.setPointer(result, f.id);
|
|
832
|
+
return NAPI_OK;
|
|
833
|
+
},
|
|
834
|
+
napi_ref_threadsafe_function() {
|
|
835
|
+
return NAPI_OK;
|
|
836
|
+
},
|
|
837
|
+
napi_unref_threadsafe_function() {
|
|
838
|
+
return NAPI_OK;
|
|
839
|
+
},
|
|
840
|
+
napi_acquire_threadsafe_function() {
|
|
841
|
+
return NAPI_OK;
|
|
842
|
+
},
|
|
843
|
+
napi_release_threadsafe_function(func, mode) {
|
|
844
|
+
threadsafeFunctions[func] = undefined;
|
|
845
|
+
return NAPI_OK;
|
|
846
|
+
},
|
|
847
|
+
napi_call_threadsafe_function(func, data, is_blocking) {
|
|
848
|
+
let f = threadsafeFunctions[func];
|
|
849
|
+
f.env.pushScope();
|
|
850
|
+
try {
|
|
851
|
+
if (f.nativeFn) {
|
|
852
|
+
let id = f.fn ? f.env.pushValue(f.fn) : 0;
|
|
853
|
+
f.nativeFn(f.env.id, id, f.context, data);
|
|
854
|
+
} else if (f.fn) {
|
|
855
|
+
f.fn();
|
|
856
|
+
}
|
|
857
|
+
} finally {
|
|
858
|
+
f.env.popScope();
|
|
859
|
+
}
|
|
860
|
+
},
|
|
861
|
+
napi_get_threadsafe_function_context(func, result) {
|
|
862
|
+
let f = threadsafeFunctions[func];
|
|
863
|
+
f.env.setPointer(result, f.context);
|
|
864
|
+
return NAPI_OK;
|
|
865
|
+
},
|
|
866
|
+
napi_create_async_work(env_id, async_resource, async_resource_name, execute, complete, data, result) {
|
|
867
|
+
let env = environments[env_id];
|
|
868
|
+
let executeFn = execute ? env.table.get(execute) : undefined;
|
|
869
|
+
let completeFn = complete ? env.table.get(complete) : undefined;
|
|
870
|
+
let w = new AsyncWork(env, executeFn, completeFn, data);
|
|
871
|
+
env.setPointer(result, w.id);
|
|
872
|
+
return NAPI_OK;
|
|
873
|
+
},
|
|
874
|
+
napi_delete_async_work(env, work) {
|
|
875
|
+
asyncWork[work] = undefined;
|
|
876
|
+
return NAPI_OK;
|
|
877
|
+
},
|
|
878
|
+
napi_queue_async_work(env, work) {
|
|
879
|
+
queueMicrotask(() => {
|
|
880
|
+
let w = asyncWork[work];
|
|
881
|
+
if (w) {
|
|
882
|
+
w.execute(env, w.data);
|
|
883
|
+
w.complete(env, NAPI_OK, w.data);
|
|
884
|
+
}
|
|
885
|
+
});
|
|
886
|
+
return NAPI_OK;
|
|
887
|
+
},
|
|
888
|
+
napi_cancel_async_work() {
|
|
889
|
+
let w = asyncWork[work];
|
|
890
|
+
w.complete(env, NAPI_CANCELED, w.data);
|
|
891
|
+
asyncWork[work] = undefined;
|
|
892
|
+
return NAPI_OK;
|
|
893
|
+
},
|
|
894
|
+
napi_throw(env_id, error) {
|
|
895
|
+
let env = environments[env_id];
|
|
896
|
+
env.pendingException = env.get(error);
|
|
897
|
+
return NAPI_OK;
|
|
898
|
+
},
|
|
899
|
+
napi_throw_error(env_id, code, msg) {
|
|
900
|
+
let env = environments[env_id];
|
|
901
|
+
let err = new Error(env.getString(msg));
|
|
902
|
+
err.code = code;
|
|
903
|
+
env.pendingException = err;
|
|
904
|
+
return NAPI_OK;
|
|
905
|
+
},
|
|
906
|
+
napi_throw_type_error(env_id, code, msg) {
|
|
907
|
+
let env = environments[env_id];
|
|
908
|
+
let err = new TypeError(env.getString(msg));
|
|
909
|
+
err.code = code;
|
|
910
|
+
env.pendingException = err;
|
|
911
|
+
return NAPI_OK;
|
|
912
|
+
},
|
|
913
|
+
napi_throw_range_error(env_id, code, msg) {
|
|
914
|
+
let env = environments[env_id];
|
|
915
|
+
let err = new RangeError(env.getString(msg));
|
|
916
|
+
err.code = code;
|
|
917
|
+
env.pendingException = err;
|
|
918
|
+
return NAPI_OK;
|
|
919
|
+
},
|
|
920
|
+
napi_create_error(env_id, code, msg, result) {
|
|
921
|
+
let env = environments[env_id];
|
|
922
|
+
let err = new Error(env.get(msg));
|
|
923
|
+
err.code = env.get(code);
|
|
924
|
+
return env.createValue(err, result);
|
|
925
|
+
},
|
|
926
|
+
napi_create_type_error(env_id, code, msg, result) {
|
|
927
|
+
let env = environments[env_id];
|
|
928
|
+
let err = new TypeError(env.get(msg));
|
|
929
|
+
err.code = env.get(code);
|
|
930
|
+
return env.createValue(err, result);
|
|
931
|
+
},
|
|
932
|
+
napi_create_range_error(env_id, code, msg, result) {
|
|
933
|
+
let env = environments[env_id];
|
|
934
|
+
let err = new RangeError(env.get(msg));
|
|
935
|
+
err.code = env.get(code);
|
|
936
|
+
return env.createValue(err, result);
|
|
937
|
+
},
|
|
938
|
+
napi_get_and_clear_last_exception(env_id, result) {
|
|
939
|
+
let env = environments[env_id];
|
|
940
|
+
let e = env.pendingException;
|
|
941
|
+
env.pendingException = null;
|
|
942
|
+
return env.createValue(e, result);
|
|
943
|
+
},
|
|
944
|
+
napi_is_exception_pending(env_id, result) {
|
|
945
|
+
let env = environments[env_id];
|
|
946
|
+
env.memory[result] = env.pendingException ? 1 : 0;
|
|
947
|
+
return NAPI_OK;
|
|
948
|
+
},
|
|
949
|
+
napi_fatal_exception(env_id, err) {
|
|
950
|
+
throw new Error('not implemented');
|
|
951
|
+
},
|
|
952
|
+
napi_fatal_error(location, location_len, message, message_len) {
|
|
953
|
+
throw new Error('not implemented');
|
|
954
|
+
},
|
|
955
|
+
napi_get_global(env_id, result) {
|
|
956
|
+
let env = environments[env_id];
|
|
957
|
+
return env.setPointer(result, 2);
|
|
958
|
+
},
|
|
959
|
+
napi_create_buffer(env_id, length, data, result) {
|
|
960
|
+
let env = environments[env_id];
|
|
961
|
+
let ptr = env.instance.exports.napi_wasm_malloc(length);
|
|
962
|
+
if (data) {
|
|
963
|
+
env.setPointer(data, ptr);
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
// Return a view into WASM memory.
|
|
967
|
+
let buf = typeof globalThis.Buffer !== 'undefined'
|
|
968
|
+
? globalThis.Buffer.from(env.memory.buffer, ptr, length)
|
|
969
|
+
: env.memory.subarray(ptr, ptr + length);
|
|
970
|
+
return env.createValue(buf, result);
|
|
971
|
+
},
|
|
972
|
+
napi_create_buffer_copy(env_id, length, data, result_data, result) {
|
|
973
|
+
let env = environments[env_id];
|
|
974
|
+
let ptr = env.instance.exports.napi_wasm_malloc(length);
|
|
975
|
+
env.memory.set(env.memory.subarray(data, data + length), ptr);
|
|
976
|
+
if (result_data) {
|
|
977
|
+
env.setPointer(result_data, ptr);
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// Return a view into WASM memory.
|
|
981
|
+
let res = typeof globalThis.Buffer !== 'undefined'
|
|
982
|
+
? globalThis.Buffer.from(env.memory.buffer, ptr, length)
|
|
983
|
+
: env.memory.subarray(ptr, ptr + length);
|
|
984
|
+
return env.createValue(res, result);
|
|
985
|
+
},
|
|
986
|
+
napi_create_external_buffer(env_id, length, data, finalize_cb, finalize_hint, result) {
|
|
987
|
+
let env = environments[env_id];
|
|
988
|
+
let buf = typeof globalThis.Buffer !== 'undefined'
|
|
989
|
+
? globalThis.Buffer.from(env.memory.buffer, data, length)
|
|
990
|
+
: env.memory.subarray(data, data + length);
|
|
991
|
+
if (finalize_cb) {
|
|
992
|
+
let cb = env.table.get(finalize_cb);
|
|
993
|
+
finalizationRegistry.register(buf, new FinalizeRecord(env_id, cb, finalize_hint, data));
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
return env.createValue(buf, result);
|
|
997
|
+
},
|
|
998
|
+
napi_get_buffer_info(env_id, value, data, length) {
|
|
999
|
+
let env = environments[env_id];
|
|
1000
|
+
let buf = env.get(value);
|
|
1001
|
+
let len = env.getBufferInfo(buf, data);
|
|
1002
|
+
return env.setPointer(length, len);
|
|
1003
|
+
},
|
|
1004
|
+
napi_create_arraybuffer(env_id, length, data, result) {
|
|
1005
|
+
let env = environments[env_id];
|
|
1006
|
+
let buf = new ArrayBuffer(length);
|
|
1007
|
+
if (data) {
|
|
1008
|
+
// This copies the ArrayBuffer into the WASM memory.
|
|
1009
|
+
env.getBufferInfo(buf, data);
|
|
1010
|
+
}
|
|
1011
|
+
return env.createValue(buf, result);
|
|
1012
|
+
},
|
|
1013
|
+
napi_create_external_arraybuffer(env_id, data, length, finalize_cb, finalize_hint, result) {
|
|
1014
|
+
// There is no way to actually create an external ArrayBuffer without copying.
|
|
1015
|
+
// You can only create typed arrays as subarrays, not ArrayBuffer.
|
|
1016
|
+
return NAPI_NO_EXTERNAL_BUFFERS_ALLOWED;
|
|
1017
|
+
},
|
|
1018
|
+
napi_get_arraybuffer_info(env_id, value, data, length) {
|
|
1019
|
+
let env = environments[env_id];
|
|
1020
|
+
let len = env.getBufferInfo(env.get(value), data);
|
|
1021
|
+
return env.setPointer(length, len);
|
|
1022
|
+
},
|
|
1023
|
+
napi_detach_arraybuffer(env_id, arraybuffer) {
|
|
1024
|
+
let env = environments[env_id];
|
|
1025
|
+
let buffer = env.get(arraybuffer);
|
|
1026
|
+
if (typeof structuredClone === 'function') {
|
|
1027
|
+
structuredClone(buffer, {transfer: [buffer]});
|
|
1028
|
+
}
|
|
1029
|
+
return NAPI_OK;
|
|
1030
|
+
},
|
|
1031
|
+
napi_is_detached_arraybuffer(env_id, arraybuffer, result) {
|
|
1032
|
+
let env = environments[env_id];
|
|
1033
|
+
let buffer = env.get(arraybuffer);
|
|
1034
|
+
env.memory[result] = buffer.byteLength === 0 ? 1 : 0; // ??
|
|
1035
|
+
return NAPI_OK;
|
|
1036
|
+
},
|
|
1037
|
+
napi_create_typedarray(env_id, type, length, arraybuffer, offset, result) {
|
|
1038
|
+
let env = environments[env_id];
|
|
1039
|
+
let Class = typedArrays[type];
|
|
1040
|
+
let buffer = env.get(arraybuffer);
|
|
1041
|
+
let buf = new Class(buffer, offset, length);
|
|
1042
|
+
return env.createValue(buf, result);
|
|
1043
|
+
},
|
|
1044
|
+
napi_create_dataview(env_id, byte_length, arraybuffer, byte_offset, result) {
|
|
1045
|
+
let env = environments[env_id];
|
|
1046
|
+
let buffer = env.get(arraybuffer);
|
|
1047
|
+
let view = new DataView(buffer, byte_offset, byte_length);
|
|
1048
|
+
return env.createValue(view, result);
|
|
1049
|
+
},
|
|
1050
|
+
napi_get_typedarray_info(env_id, typedarray, type, length, data, arraybuffer, byte_offset) {
|
|
1051
|
+
let env = environments[env_id];
|
|
1052
|
+
let val = env.get(typedarray);
|
|
1053
|
+
env.setPointer(type, typedArrays.indexOf(val.constructor));
|
|
1054
|
+
env.setPointer(length, val.length);
|
|
1055
|
+
env.getBufferInfo(val, data);
|
|
1056
|
+
env.createValue(val.buffer, arraybuffer);
|
|
1057
|
+
return env.setPointer(byte_offset, val.byteOffset);
|
|
1058
|
+
},
|
|
1059
|
+
napi_get_dataview_info(env_id, dataview, byte_length, data, arraybuffer, byte_offset) {
|
|
1060
|
+
let env = environments[env_id];
|
|
1061
|
+
let val = env.get(dataview);
|
|
1062
|
+
env.setPointer(byte_length, val.byteLength);
|
|
1063
|
+
env.getBufferInfo(val, data);
|
|
1064
|
+
env.createValue(val.buffer, arraybuffer);
|
|
1065
|
+
return env.setPointer(byte_offset, val.byteOffset);
|
|
1066
|
+
},
|
|
1067
|
+
napi_create_string_utf8(env_id, str, length, result) {
|
|
1068
|
+
let env = environments[env_id];
|
|
1069
|
+
let s = decoder.decode(env.memory.subarray(str, str + length));
|
|
1070
|
+
return env.createValue(s, result);
|
|
1071
|
+
},
|
|
1072
|
+
napi_get_value_string_utf8(env_id, value, buf, bufsize, result) {
|
|
1073
|
+
let env = environments[env_id];
|
|
1074
|
+
let val = env.get(value);
|
|
1075
|
+
if (buf == 0) {
|
|
1076
|
+
return env.setPointer(result, utf8Length(val));
|
|
1077
|
+
}
|
|
1078
|
+
let res = encoder.encodeInto(val, env.memory.subarray(buf, buf + bufsize - 1));
|
|
1079
|
+
env.memory[buf + res.written] = 0; // null terminate
|
|
1080
|
+
return env.setPointer(result, res.written);
|
|
1081
|
+
},
|
|
1082
|
+
napi_create_string_latin1(env_id, str, length, result) {
|
|
1083
|
+
let env = environments[env_id];
|
|
1084
|
+
let s = latin1Decoder.decode(env.memory.subarray(str, str + length));
|
|
1085
|
+
return env.createValue(s, result);
|
|
1086
|
+
},
|
|
1087
|
+
napi_get_value_string_latin1(env_id, value, buf, bufsize, result) {
|
|
1088
|
+
let env = environments[env_id];
|
|
1089
|
+
let val = env.get(value);
|
|
1090
|
+
if (buf == 0) {
|
|
1091
|
+
return env.setPointer(result, val.length);
|
|
1092
|
+
}
|
|
1093
|
+
let mem = env.memory;
|
|
1094
|
+
let len = Math.min(val.length, bufsize - 1);
|
|
1095
|
+
for (let i = 0; i < len; i++) {
|
|
1096
|
+
let code = val.charCodeAt(i);
|
|
1097
|
+
mem[buf++] = code;
|
|
1098
|
+
}
|
|
1099
|
+
mem[buf] = 0; // null terminate
|
|
1100
|
+
return env.setPointer(result, len);
|
|
1101
|
+
},
|
|
1102
|
+
napi_create_string_utf16(env_id, str, length, result) {
|
|
1103
|
+
let env = environments[env_id];
|
|
1104
|
+
let s = utf16Decoder.decode(env.memory.subarray(str, str + length * 2));
|
|
1105
|
+
return env.createValue(s, result);
|
|
1106
|
+
},
|
|
1107
|
+
napi_get_value_string_utf16(env_id, value, buf, bufsize, result) {
|
|
1108
|
+
let env = environments[env_id];
|
|
1109
|
+
let val = env.get(value);
|
|
1110
|
+
if (buf == 0) {
|
|
1111
|
+
return env.setPointer(result, val.length);
|
|
1112
|
+
}
|
|
1113
|
+
let mem = env.u16;
|
|
1114
|
+
let ptr = buf >> 1;
|
|
1115
|
+
let len = Math.min(val.length, bufsize - 1);
|
|
1116
|
+
for (let i = 0; i < len; i++) {
|
|
1117
|
+
let code = val.charCodeAt(i);
|
|
1118
|
+
mem[ptr++] = code;
|
|
1119
|
+
}
|
|
1120
|
+
mem[ptr] = 0; // null terminate
|
|
1121
|
+
return env.setPointer(result, len);
|
|
1122
|
+
},
|
|
1123
|
+
napi_create_date(env_id, time, result) {
|
|
1124
|
+
let env = environments[env_id];
|
|
1125
|
+
return env.createValue(new Date(time), result);
|
|
1126
|
+
},
|
|
1127
|
+
napi_get_date_value(env_id, value, result) {
|
|
1128
|
+
let env = environments[env_id];
|
|
1129
|
+
let date = env.get(value);
|
|
1130
|
+
env.f64[result >> 3] = date.valueOf();
|
|
1131
|
+
},
|
|
1132
|
+
napi_create_symbol(env_id, description, result) {
|
|
1133
|
+
let env = environments[env_id];
|
|
1134
|
+
let desc = env.get(description);
|
|
1135
|
+
return env.createValue(Symbol(desc), result);
|
|
1136
|
+
},
|
|
1137
|
+
napi_coerce_to_bool(env_id, value, result) {
|
|
1138
|
+
let env = environments[env_id];
|
|
1139
|
+
return env.createValue(Boolean(env.get(value)), result);
|
|
1140
|
+
},
|
|
1141
|
+
napi_coerce_to_number(env_id, value, result) {
|
|
1142
|
+
let env = environments[env_id];
|
|
1143
|
+
return env.createValue(Number(env.get(value)), result);
|
|
1144
|
+
},
|
|
1145
|
+
napi_coerce_to_object(env_id, value, result) {
|
|
1146
|
+
let env = environments[env_id];
|
|
1147
|
+
return env.createValue(Object(env.get(value)), result);
|
|
1148
|
+
},
|
|
1149
|
+
napi_coerce_to_string(env_id, value, result) {
|
|
1150
|
+
let env = environments[env_id];
|
|
1151
|
+
return env.createValue(String(env.get(value)), result);
|
|
1152
|
+
},
|
|
1153
|
+
napi_typeof(env_id, value, result) {
|
|
1154
|
+
let env = environments[env_id];
|
|
1155
|
+
let val = env.get(value);
|
|
1156
|
+
return env.setPointer(result, (() => {
|
|
1157
|
+
switch (typeof val) {
|
|
1158
|
+
case 'undefined':
|
|
1159
|
+
return 0;
|
|
1160
|
+
case 'boolean':
|
|
1161
|
+
return 2;
|
|
1162
|
+
case 'number':
|
|
1163
|
+
return 3;
|
|
1164
|
+
case 'string':
|
|
1165
|
+
return 4;
|
|
1166
|
+
case 'symbol':
|
|
1167
|
+
return 5;
|
|
1168
|
+
case 'object':
|
|
1169
|
+
if (val === null) {
|
|
1170
|
+
return 1;
|
|
1171
|
+
} else if (val instanceof ExternalValue) {
|
|
1172
|
+
return 8;
|
|
1173
|
+
}
|
|
1174
|
+
return 6;
|
|
1175
|
+
case 'function':
|
|
1176
|
+
return 7;
|
|
1177
|
+
case 'bigint':
|
|
1178
|
+
return 9;
|
|
1179
|
+
}
|
|
1180
|
+
})());
|
|
1181
|
+
},
|
|
1182
|
+
napi_instanceof(env_id, object, constructor, result) {
|
|
1183
|
+
let env = environments[env_id];
|
|
1184
|
+
let obj = env.get(object);
|
|
1185
|
+
let cons = env.get(constructor);
|
|
1186
|
+
env.memory[result] = obj instanceof cons ? 1 : 0;
|
|
1187
|
+
return NAPI_OK;
|
|
1188
|
+
},
|
|
1189
|
+
napi_is_array(env_id, value, result) {
|
|
1190
|
+
let env = environments[env_id];
|
|
1191
|
+
let val = env.get(value);
|
|
1192
|
+
env.memory[result] = Array.isArray(val) ? 1 : 0;
|
|
1193
|
+
return NAPI_OK;
|
|
1194
|
+
},
|
|
1195
|
+
napi_is_buffer(env_id, value, result) {
|
|
1196
|
+
let env = environments[env_id];
|
|
1197
|
+
let val = env.get(value);
|
|
1198
|
+
env.memory[result] = (typeof globalThis.Buffer !== 'undefined' ? globalThis.Buffer.isBuffer(val) : val instanceof Uint8Array) ? 1 : 0;
|
|
1199
|
+
return NAPI_OK;
|
|
1200
|
+
},
|
|
1201
|
+
napi_is_date(env_id, value, result) {
|
|
1202
|
+
let env = environments[env_id];
|
|
1203
|
+
let val = env.get(value);
|
|
1204
|
+
env.memory[result] = val instanceof Date ? 1 : 0;
|
|
1205
|
+
return NAPI_OK;
|
|
1206
|
+
},
|
|
1207
|
+
napi_is_error(env_id, value, result) {
|
|
1208
|
+
let env = environments[env_id];
|
|
1209
|
+
let err = env.get(value);
|
|
1210
|
+
env.memory[result] = err instanceof Error ? 1 : 0;
|
|
1211
|
+
return NAPI_OK;
|
|
1212
|
+
},
|
|
1213
|
+
napi_is_typedarray(env_id, value, result) {
|
|
1214
|
+
let env = environments[env_id];
|
|
1215
|
+
let buf = env.get(value);
|
|
1216
|
+
env.memory[result] = ArrayBuffer.isView(buf) && !(buf instanceof DataView) ? 1 : 0;
|
|
1217
|
+
return NAPI_OK;
|
|
1218
|
+
},
|
|
1219
|
+
napi_is_dataview(env_id, value, result) {
|
|
1220
|
+
let env = environments[env_id];
|
|
1221
|
+
let val = env.get(value);
|
|
1222
|
+
env.memory[result] = val instanceof DataView ? 1 : 0;
|
|
1223
|
+
return NAPI_OK;
|
|
1224
|
+
},
|
|
1225
|
+
napi_strict_equals(env_id, lhs, rhs, result) {
|
|
1226
|
+
let env = environments[env_id];
|
|
1227
|
+
env.memory[result] = env.get(lhs) === env.get(rhs) ? 1 : 0;
|
|
1228
|
+
return NAPI_OK;
|
|
1229
|
+
},
|
|
1230
|
+
napi_wrap(env_id, js_object, native_object, finalize_cb, finalize_hint, result) {
|
|
1231
|
+
let env = environments[env_id];
|
|
1232
|
+
let obj = env.get(js_object);
|
|
1233
|
+
env.wrappedObjects.set(obj, native_object);
|
|
1234
|
+
if (finalize_cb) {
|
|
1235
|
+
let cb = env.table.get(finalize_cb);
|
|
1236
|
+
finalizationRegistry.register(obj, new FinalizeRecord(env_id, cb, finalize_hint, native_object));
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
if (result) {
|
|
1240
|
+
return napi.napi_create_reference(env_id, js_object, 1, result);
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
return NAPI_OK;
|
|
1244
|
+
},
|
|
1245
|
+
napi_unwrap(env_id, js_object, result) {
|
|
1246
|
+
let env = environments[env_id];
|
|
1247
|
+
let obj = env.get(js_object);
|
|
1248
|
+
let native_object = env.wrappedObjects.get(obj);
|
|
1249
|
+
env.setPointer(result, native_object);
|
|
1250
|
+
return NAPI_OK;
|
|
1251
|
+
},
|
|
1252
|
+
napi_remove_wrap(env_id, js_object, result) {
|
|
1253
|
+
let env = environments[env_id];
|
|
1254
|
+
let obj = env.get(js_object);
|
|
1255
|
+
let native_object = env.wrappedObjects.get(obj);
|
|
1256
|
+
finalizationRegistry.unregister(obj);
|
|
1257
|
+
env.wrappedObjects.delete(obj);
|
|
1258
|
+
return env.setPointer(result, native_object);
|
|
1259
|
+
},
|
|
1260
|
+
napi_type_tag_object(env_id, js_object, type_tag) {
|
|
1261
|
+
throw new Error('not implemented');
|
|
1262
|
+
},
|
|
1263
|
+
napi_check_object_type_tag(env_id, js_object, type_tag) {
|
|
1264
|
+
throw new Error('not implemented');
|
|
1265
|
+
},
|
|
1266
|
+
napi_add_finalizer(env_id, js_object, native_object, finalize_cb, finalize_hint, result) {
|
|
1267
|
+
let env = environments[env_id];
|
|
1268
|
+
let obj = env.get(js_object);
|
|
1269
|
+
let cb = env.table.get(finalize_cb);
|
|
1270
|
+
finalizationRegistry.register(obj, new FinalizeRecord(env_id, cb, finalize_hint, native_object));
|
|
1271
|
+
if (result) {
|
|
1272
|
+
return napi.napi_create_reference(env_id, js_object, 1, result);
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
return NAPI_OK;
|
|
1276
|
+
},
|
|
1277
|
+
napi_create_promise(env_id, deferred, promise) {
|
|
1278
|
+
let env = environments[env_id];
|
|
1279
|
+
let p = new Promise((resolve, reject) => {
|
|
1280
|
+
let id = env.deferred.length;
|
|
1281
|
+
env.deferred.push({resolve, reject});
|
|
1282
|
+
env.setPointer(deferred, id);
|
|
1283
|
+
});
|
|
1284
|
+
return env.createValue(p, promise);
|
|
1285
|
+
},
|
|
1286
|
+
napi_resolve_deferred(env_id, deferred, resolution) {
|
|
1287
|
+
let env = environments[env_id];
|
|
1288
|
+
let { resolve } = env.deferred[deferred];
|
|
1289
|
+
let value = env.get(resolution);
|
|
1290
|
+
resolve(value);
|
|
1291
|
+
env.deferred[deferred] = undefined;
|
|
1292
|
+
return NAPI_OK;
|
|
1293
|
+
},
|
|
1294
|
+
napi_reject_deferred(env_id, deferred, rejection) {
|
|
1295
|
+
let env = environments[env_id];
|
|
1296
|
+
let { reject } = env.deferred[deferred];
|
|
1297
|
+
let value = env.get(rejection);
|
|
1298
|
+
reject(value);
|
|
1299
|
+
env.deferred[deferred] = undefined;
|
|
1300
|
+
return NAPI_OK;
|
|
1301
|
+
},
|
|
1302
|
+
napi_is_promise(env_id, value, result) {
|
|
1303
|
+
let env = environments[env_id];
|
|
1304
|
+
let val = env.get(value);
|
|
1305
|
+
env.memory[result] = val instanceof Promise ? 1 : 0;
|
|
1306
|
+
return NAPI_OK;
|
|
1307
|
+
},
|
|
1308
|
+
napi_run_script(env_id, script, result) {
|
|
1309
|
+
let env = environments[env_id];
|
|
1310
|
+
let source = env.get(script);
|
|
1311
|
+
let res = (0, eval)(source);
|
|
1312
|
+
return env.createValue(res, result);
|
|
1313
|
+
},
|
|
1314
|
+
napi_create_external(env_id, data, finalize_cb, finalize_hint, result) {
|
|
1315
|
+
let env = environments[env_id];
|
|
1316
|
+
let external = new ExternalValue;
|
|
1317
|
+
env.externalObjects.set(external, data);
|
|
1318
|
+
if (finalize_cb) {
|
|
1319
|
+
let cb = env.table.get(finalize_cb);
|
|
1320
|
+
finalizationRegistry.register(external, new FinalizeRecord(env_id, cb, finalize_hint, data));
|
|
1321
|
+
}
|
|
1322
|
+
return env.createValue(external, result);
|
|
1323
|
+
},
|
|
1324
|
+
napi_get_value_external(env_id, value, result) {
|
|
1325
|
+
let env = environments[env_id];
|
|
1326
|
+
let external = env.get(value);
|
|
1327
|
+
let val = env.externalObjects.get(external);
|
|
1328
|
+
return env.setPointer(result, val);
|
|
1329
|
+
},
|
|
1330
|
+
napi_adjust_external_memory() {
|
|
1331
|
+
return NAPI_OK;
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
|
|
1335
|
+
function strlen(buf, ptr) {
|
|
1336
|
+
let len = 0;
|
|
1337
|
+
while (buf[ptr] !== 0) {
|
|
1338
|
+
len++;
|
|
1339
|
+
ptr++;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
return len;
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
function utf8Length(string) {
|
|
1346
|
+
let len = 0;
|
|
1347
|
+
for (let i = 0; i < string.length; i++) {
|
|
1348
|
+
let c = string.charCodeAt(i);
|
|
1349
|
+
|
|
1350
|
+
if (c >= 0xd800 && c <= 0xdbff && i < string.length - 1) {
|
|
1351
|
+
let c2 = string.charCodeAt(++i);
|
|
1352
|
+
if ((c2 & 0xfc00) === 0xdc00) {
|
|
1353
|
+
c = ((c & 0x3ff) << 10) + (c2 & 0x3ff) + 0x10000;
|
|
1354
|
+
} else {
|
|
1355
|
+
// unmatched surrogate.
|
|
1356
|
+
i--;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if ((c & 0xffffff80) === 0) {
|
|
1361
|
+
len++;
|
|
1362
|
+
} else if ((c & 0xfffff800) === 0) {
|
|
1363
|
+
len += 2;
|
|
1364
|
+
} else if ((c & 0xffff0000) === 0) {
|
|
1365
|
+
len += 3;
|
|
1366
|
+
} else if ((c & 0xffe00000) === 0) {
|
|
1367
|
+
len += 4;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
return len;
|
|
1371
|
+
}
|