@napi-rs/wasm-runtime
Advanced tools
+23
-1
@@ -11,2 +11,3 @@ 'use strict'; | ||
| if (value === null) return 1 | ||
| if (isBuffer(value)) return 10 | ||
| const t = typeof value; | ||
@@ -21,2 +22,14 @@ if (t === 'boolean') return 2 | ||
| /** | ||
| * @param {unknown} value | ||
| * @returns {value is Uint8Array} | ||
| */ | ||
| const isBuffer = (value) => { | ||
| const BufferCtor = globalThis.Buffer; | ||
| if (typeof BufferCtor?.isBuffer === 'function') { | ||
| return BufferCtor.isBuffer(value) | ||
| } | ||
| return value instanceof Uint8Array && value.constructor?.name === 'Buffer' | ||
| }; | ||
| const RESPONSE_HEADER_SIZE = 16; | ||
@@ -62,2 +75,4 @@ const RESPONSE_PAYLOAD_SIZE = 10240; | ||
| } | ||
| case 10: | ||
| return new Uint8Array(value) | ||
| case 6: { | ||
@@ -134,2 +149,9 @@ function storeConstructor(obj, memfs, processed = new WeakSet()) { | ||
| if (type === 4) return new TextDecoder().decode(payload.slice()) | ||
| if (type === 10) { | ||
| const BufferCtor = globalThis.Buffer; | ||
| if (typeof BufferCtor?.from === 'function') { | ||
| return BufferCtor.from(payload) | ||
| } | ||
| return payload.slice() | ||
| } | ||
| if (type === 6) { | ||
@@ -214,3 +236,3 @@ const obj = JSON.parse( | ||
| * 0..4 status(int32_t): 21(waiting) 0(success) 1(error) | ||
| * 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported) | ||
| * 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) 10(buffer) -1(unsupported) | ||
| * 9..16 payload_size(uint32_t) <= 10240 | ||
@@ -217,0 +239,0 @@ * 16..16 + payload_size payload_content |
+23
-1
@@ -9,2 +9,3 @@ // @ts-check | ||
| if (value === null) return 1 | ||
| if (isBuffer(value)) return 10 | ||
| const t = typeof value | ||
@@ -19,2 +20,14 @@ if (t === 'boolean') return 2 | ||
| /** | ||
| * @param {unknown} value | ||
| * @returns {value is Uint8Array} | ||
| */ | ||
| const isBuffer = (value) => { | ||
| const BufferCtor = globalThis.Buffer | ||
| if (typeof BufferCtor?.isBuffer === 'function') { | ||
| return BufferCtor.isBuffer(value) | ||
| } | ||
| return value instanceof Uint8Array && value.constructor?.name === 'Buffer' | ||
| } | ||
| const RESPONSE_HEADER_SIZE = 16 | ||
@@ -60,2 +73,4 @@ const RESPONSE_PAYLOAD_SIZE = 10240 | ||
| } | ||
| case 10: | ||
| return new Uint8Array(value) | ||
| case 6: { | ||
@@ -132,2 +147,9 @@ function storeConstructor(obj, memfs, processed = new WeakSet()) { | ||
| if (type === 4) return new TextDecoder().decode(payload.slice()) | ||
| if (type === 10) { | ||
| const BufferCtor = globalThis.Buffer | ||
| if (typeof BufferCtor?.from === 'function') { | ||
| return BufferCtor.from(payload) | ||
| } | ||
| return payload.slice() | ||
| } | ||
| if (type === 6) { | ||
@@ -212,3 +234,3 @@ const obj = JSON.parse( | ||
| * 0..4 status(int32_t): 21(waiting) 0(success) 1(error) | ||
| * 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) -1(unsupported) | ||
| * 5..8 type(napi_valuetype): 0(undefined) 1(null) 2(boolean) 3(number) 4(string) 6(jsonstring) 9(bigint) 10(buffer) -1(unsupported) | ||
| * 9..16 payload_size(uint32_t) <= 10240 | ||
@@ -215,0 +237,0 @@ * 16..16 + payload_size payload_content |
+6
-6
| { | ||
| "name": "@napi-rs/wasm-runtime", | ||
| "version": "1.1.4", | ||
| "version": "1.1.5", | ||
| "type": "module", | ||
@@ -30,3 +30,3 @@ "description": "Runtime and polyfill for wasm targets", | ||
| "@rollup/plugin-alias": "^6.0.0", | ||
| "@rollup/plugin-commonjs": "^29.0.0", | ||
| "@rollup/plugin-commonjs": "^29.0.3", | ||
| "@rollup/plugin-inject": "^5.0.5", | ||
@@ -38,8 +38,8 @@ "@rollup/plugin-json": "^6.1.0", | ||
| "events": "^3.3.0", | ||
| "memfs": "^4.50.0", | ||
| "node-inspect-extracted": "^3.2.2", | ||
| "memfs": "^4.57.6", | ||
| "node-inspect-extracted": "^3.3.2", | ||
| "path-browserify": "^1.0.1", | ||
| "process": "^0.11.10", | ||
| "readable-stream": "^4.7.0", | ||
| "rollup": "^4.53.1", | ||
| "rollup": "^4.61.1", | ||
| "rollup-plugin-polyfill-node": "^0.13.0", | ||
@@ -49,3 +49,3 @@ "tslib": "^2.8.1" | ||
| "dependencies": { | ||
| "@tybys/wasm-util": "^0.10.1" | ||
| "@tybys/wasm-util": "^0.10.2" | ||
| }, | ||
@@ -52,0 +52,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
6259084
0.11%1608
2.68%Updated