@cratestack/cbor-web 0.5.2
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/LICENSE +21 -0
- package/README.md +65 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +63 -0
- package/dist/index.js.map +1 -0
- package/dist/wasm-pkg/cratestack_cbor_wasm.js +615 -0
- package/dist/wasm-pkg/cratestack_cbor_wasm_bg.wasm +0 -0
- package/package.json +44 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Stephane Segning
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @cratestack/cbor-web
|
|
2
|
+
|
|
3
|
+
A `wasm-bindgen` build of `cratestack-codec-cbor`'s `CborCodec` for browser
|
|
4
|
+
CrateStack RPC clients — the browser half of `@cratestack/cbor-node`'s
|
|
5
|
+
epic (#285). Same Rust encode/decode logic the server and Rust client
|
|
6
|
+
already use, reachable from browser JavaScript with no CBOR reimplemented
|
|
7
|
+
in TypeScript.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @cratestack/cbor-web
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
`createCborCodec()` performs the one-time WASM module instantiation and
|
|
18
|
+
resolves to a plain object satisfying `CratestackRpcCodec` from
|
|
19
|
+
`@cratestack/ts-types`. Every `encode`/`decode` call on the returned
|
|
20
|
+
object is synchronous — the async cost is paid once, not per call:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
import { createCborCodec } from "@cratestack/cbor-web";
|
|
24
|
+
|
|
25
|
+
const codec = await createCborCodec();
|
|
26
|
+
|
|
27
|
+
const bytes = codec.encode({ hello: "world" });
|
|
28
|
+
const value = codec.decode(bytes);
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### With a generated CrateStack client
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { createCborCodec } from "@cratestack/cbor-web";
|
|
35
|
+
import { createClient } from "./generated/client.js";
|
|
36
|
+
|
|
37
|
+
const client = createClient({
|
|
38
|
+
baseUrl: "https://api.example.com",
|
|
39
|
+
codec: await createCborCodec(),
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Error handling
|
|
44
|
+
|
|
45
|
+
Malformed CBOR input on `decode`, or a value `encode` can't represent,
|
|
46
|
+
throws a catchable JS `Error` — never a WASM trap that would poison the
|
|
47
|
+
module for subsequent calls (see `crates/cratestack-cbor-wasm/src/wasm.rs`
|
|
48
|
+
for why that distinction matters).
|
|
49
|
+
|
|
50
|
+
## Bundlers
|
|
51
|
+
|
|
52
|
+
Ships a `wasm-pack --target web` build: the `.wasm` asset is resolved via
|
|
53
|
+
`new URL('cratestack_cbor_wasm_bg.wasm', import.meta.url)`, which Vite,
|
|
54
|
+
webpack 5, and Next.js all handle as a static asset without extra config.
|
|
55
|
+
Verified against `examples/embedded-browser-vite`.
|
|
56
|
+
|
|
57
|
+
## See Also
|
|
58
|
+
|
|
59
|
+
- `@cratestack/cbor-node` — the Node/native counterpart (napi-rs).
|
|
60
|
+
- `crates/cratestack-cbor-wasm` — the wasm-bindgen crate this package wraps.
|
|
61
|
+
- `crates/cratestack-codec-cbor` — the underlying, unchanged Rust codec.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CratestackRpcCodec } from "@cratestack/ts-types";
|
|
2
|
+
/**
|
|
3
|
+
* Performs the one-time WASM module instantiation and resolves to a plain
|
|
4
|
+
* object satisfying {@link CratestackRpcCodec}. Every `encode`/`decode`
|
|
5
|
+
* call on the returned object is synchronous — the async cost is paid
|
|
6
|
+
* once here, never per call, so this composes with the existing
|
|
7
|
+
* (synchronous) `CratestackRpcCodec` contract without changing its shape.
|
|
8
|
+
*
|
|
9
|
+
* Safe to call more than once: later calls resolve once the same
|
|
10
|
+
* in-flight (or already-completed) instantiation settles, they don't
|
|
11
|
+
* re-instantiate the module.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const codec = await createCborCodec();
|
|
16
|
+
* const bytes = codec.encode({ hello: "world" });
|
|
17
|
+
* const value = codec.decode(bytes);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function createCborCodec(): Promise<CratestackRpcCodec>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA2B/D;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAqBnE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Generated by `wasm-pack build --target web` from `crates/cratestack-cbor-wasm`
|
|
2
|
+
// (see `pnpm run wasm:build` / `../../examples/scripts/wasm-build.mjs`) — not
|
|
3
|
+
// hand-written, regenerated on every build, excluded from lint/format (see
|
|
4
|
+
// root `biome.json`) and from git (see `.gitignore`).
|
|
5
|
+
import init, { contentType, decode, encode } from "./wasm-pkg/cratestack_cbor_wasm.js";
|
|
6
|
+
// Memoized across calls so concurrent/repeated `createCborCodec()` callers
|
|
7
|
+
// share one WASM instantiation instead of re-fetching/re-compiling the
|
|
8
|
+
// module. Only a *successful* init is cached — a failed attempt (e.g. the
|
|
9
|
+
// `.wasm` asset 404s under a bundler misconfiguration) resets the memo so
|
|
10
|
+
// the next call gets a fresh chance rather than replaying the same
|
|
11
|
+
// rejection forever.
|
|
12
|
+
let initPromise = null;
|
|
13
|
+
function ensureInitialized() {
|
|
14
|
+
if (!initPromise) {
|
|
15
|
+
initPromise = init()
|
|
16
|
+
.then(() => undefined)
|
|
17
|
+
.catch((error) => {
|
|
18
|
+
initPromise = null;
|
|
19
|
+
throw error;
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return initPromise;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Performs the one-time WASM module instantiation and resolves to a plain
|
|
26
|
+
* object satisfying {@link CratestackRpcCodec}. Every `encode`/`decode`
|
|
27
|
+
* call on the returned object is synchronous — the async cost is paid
|
|
28
|
+
* once here, never per call, so this composes with the existing
|
|
29
|
+
* (synchronous) `CratestackRpcCodec` contract without changing its shape.
|
|
30
|
+
*
|
|
31
|
+
* Safe to call more than once: later calls resolve once the same
|
|
32
|
+
* in-flight (or already-completed) instantiation settles, they don't
|
|
33
|
+
* re-instantiate the module.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* const codec = await createCborCodec();
|
|
38
|
+
* const bytes = codec.encode({ hello: "world" });
|
|
39
|
+
* const value = codec.decode(bytes);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export async function createCborCodec() {
|
|
43
|
+
await ensureInitialized();
|
|
44
|
+
return {
|
|
45
|
+
contentType: contentType(),
|
|
46
|
+
encode(value) {
|
|
47
|
+
// Malformed/unrepresentable input throws a real `Error` (see
|
|
48
|
+
// crates/cratestack-cbor-wasm/src/wasm.rs) — never a wasm trap, so
|
|
49
|
+
// it's a normal catchable exception here, not a poisoned module.
|
|
50
|
+
//
|
|
51
|
+
// The cast is TypeScript 5.7+ typed-array generics noise, not a
|
|
52
|
+
// real type mismatch: `Uint8Array` satisfies `BufferSource`
|
|
53
|
+
// (part of the `BodyInit` union) at runtime and per the DOM spec —
|
|
54
|
+
// see the same pattern in
|
|
55
|
+
// crates/cratestack-client-typescript/templates/src/grpc-web-runtime.ts.j2.
|
|
56
|
+
return encode(value);
|
|
57
|
+
},
|
|
58
|
+
decode(bytes) {
|
|
59
|
+
return decode(bytes);
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,iFAAiF;AACjF,8EAA8E;AAC9E,2EAA2E;AAC3E,sDAAsD;AACtD,OAAO,IAAI,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAEvF,2EAA2E;AAC3E,uEAAuE;AACvE,0EAA0E;AAC1E,0EAA0E;AAC1E,mEAAmE;AACnE,qBAAqB;AACrB,IAAI,WAAW,GAAyB,IAAI,CAAC;AAE7C,SAAS,iBAAiB;IACxB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,IAAI,EAAE;aACjB,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;aACrB,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,WAAW,GAAG,IAAI,CAAC;YACnB,MAAM,KAAK,CAAC;QACd,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,iBAAiB,EAAE,CAAC;IAE1B,OAAO;QACL,WAAW,EAAE,WAAW,EAAE;QAC1B,MAAM,CAAC,KAAc;YACnB,6DAA6D;YAC7D,mEAAmE;YACnE,iEAAiE;YACjE,EAAE;YACF,gEAAgE;YAChE,4DAA4D;YAC5D,mEAAmE;YACnE,0BAA0B;YAC1B,4EAA4E;YAC5E,OAAO,MAAM,CAAC,KAAK,CAAa,CAAC;QACnC,CAAC;QACD,MAAM,CAAC,KAAiB;YACtB,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
/* @ts-self-types="./cratestack_cbor_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mirrors `CborCodec::CONTENT_TYPE` ("application/cbor") — kept as a
|
|
5
|
+
* function rather than a duplicated JS-side string literal so there is
|
|
6
|
+
* exactly one source of truth for the value.
|
|
7
|
+
* @returns {string}
|
|
8
|
+
*/
|
|
9
|
+
export function contentType() {
|
|
10
|
+
let deferred1_0;
|
|
11
|
+
let deferred1_1;
|
|
12
|
+
try {
|
|
13
|
+
const ret = wasm.contentType();
|
|
14
|
+
deferred1_0 = ret[0];
|
|
15
|
+
deferred1_1 = ret[1];
|
|
16
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
17
|
+
} finally {
|
|
18
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Decodes CBOR bytes into a plain JS value. Malformed input surfaces as
|
|
24
|
+
* a rejected/thrown `Error`, never a trap — see the module doc comment.
|
|
25
|
+
*
|
|
26
|
+
* Two `serde_wasm_bindgen` default `Serializer` behaviors would otherwise
|
|
27
|
+
* corrupt the result, so this builds an explicit `Serializer` instead of
|
|
28
|
+
* using the `to_value` convenience function:
|
|
29
|
+
* - `serialize_maps_as_objects(true)` — the default turns Rust maps
|
|
30
|
+
* (including `serde_json::Value::Object`) into JS `Map` instances,
|
|
31
|
+
* not plain `{}` objects. A `Map` round-trips fine through explicit
|
|
32
|
+
* `.get()`/`.entries()` calls, but silently renders as `"{}"` under
|
|
33
|
+
* `JSON.stringify`, which isn't what a `decode(bytes): unknown`
|
|
34
|
+
* caller expects.
|
|
35
|
+
* - `serialize_missing_as_null(true)` — the default serializes both
|
|
36
|
+
* `serialize_none()` and `serialize_unit()` (what `serde_json::Value
|
|
37
|
+
* ::Null`'s own `Serialize` impl calls) as JS `undefined`, not
|
|
38
|
+
* `null`. An object property set to `undefined` is silently dropped
|
|
39
|
+
* by `JSON.stringify`, which is what made this look like data loss
|
|
40
|
+
* during development rather than a `null`-vs-`undefined` mismatch.
|
|
41
|
+
* @param {Uint8Array} bytes
|
|
42
|
+
* @returns {any}
|
|
43
|
+
*/
|
|
44
|
+
export function decode(bytes) {
|
|
45
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
46
|
+
const len0 = WASM_VECTOR_LEN;
|
|
47
|
+
const ret = wasm.decode(ptr0, len0);
|
|
48
|
+
if (ret[2]) {
|
|
49
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
50
|
+
}
|
|
51
|
+
return takeFromExternrefTable0(ret[0]);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Encodes an arbitrary JS value as CBOR bytes.
|
|
56
|
+
*
|
|
57
|
+
* `value` is deserialized into an owned `serde_json::Value` first (JS has
|
|
58
|
+
* no notion of the concrete Rust types `CborCodec::encode<T>` is generic
|
|
59
|
+
* over), then re-serialized through `EncodableValue` — see
|
|
60
|
+
* `json_bridge.rs` for why that indirection exists rather than encoding
|
|
61
|
+
* the `serde_json::Value` tree directly.
|
|
62
|
+
* @param {any} value
|
|
63
|
+
* @returns {Uint8Array}
|
|
64
|
+
*/
|
|
65
|
+
export function encode(value) {
|
|
66
|
+
const ret = wasm.encode(value);
|
|
67
|
+
if (ret[3]) {
|
|
68
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
69
|
+
}
|
|
70
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
71
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
72
|
+
return v1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Runs once when the wasm module is instantiated (part of the generated
|
|
77
|
+
* `init()` glue) — before this, any panic elsewhere in the module would
|
|
78
|
+
* surface as an opaque "unreachable executed" trap in the browser
|
|
79
|
+
* console; after, it's a readable stack trace.
|
|
80
|
+
*/
|
|
81
|
+
export function start() {
|
|
82
|
+
wasm.start();
|
|
83
|
+
}
|
|
84
|
+
function __wbg_get_imports() {
|
|
85
|
+
const import0 = {
|
|
86
|
+
__proto__: null,
|
|
87
|
+
__wbg_Error_fdd633d4bb5dd76a: function(arg0, arg1) {
|
|
88
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
89
|
+
return ret;
|
|
90
|
+
},
|
|
91
|
+
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
92
|
+
const ret = String(arg1);
|
|
93
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
94
|
+
const len1 = WASM_VECTOR_LEN;
|
|
95
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
96
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
97
|
+
},
|
|
98
|
+
__wbg___wbindgen_bigint_get_as_i64_d9e915702856f831: function(arg0, arg1) {
|
|
99
|
+
const v = arg1;
|
|
100
|
+
const ret = typeof(v) === 'bigint' ? v : undefined;
|
|
101
|
+
getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
|
|
102
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
103
|
+
},
|
|
104
|
+
__wbg___wbindgen_boolean_get_edaed31a367ce1bd: function(arg0) {
|
|
105
|
+
const v = arg0;
|
|
106
|
+
const ret = typeof(v) === 'boolean' ? v : undefined;
|
|
107
|
+
return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
|
|
108
|
+
},
|
|
109
|
+
__wbg___wbindgen_debug_string_8a447059637473e2: function(arg0, arg1) {
|
|
110
|
+
const ret = debugString(arg1);
|
|
111
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
112
|
+
const len1 = WASM_VECTOR_LEN;
|
|
113
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
114
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
115
|
+
},
|
|
116
|
+
__wbg___wbindgen_in_4990f46af709e33c: function(arg0, arg1) {
|
|
117
|
+
const ret = arg0 in arg1;
|
|
118
|
+
return ret;
|
|
119
|
+
},
|
|
120
|
+
__wbg___wbindgen_is_bigint_90b5ccfe67c78460: function(arg0) {
|
|
121
|
+
const ret = typeof(arg0) === 'bigint';
|
|
122
|
+
return ret;
|
|
123
|
+
},
|
|
124
|
+
__wbg___wbindgen_is_function_acc5528be2b923f2: function(arg0) {
|
|
125
|
+
const ret = typeof(arg0) === 'function';
|
|
126
|
+
return ret;
|
|
127
|
+
},
|
|
128
|
+
__wbg___wbindgen_is_object_0beba4a1980d3eea: function(arg0) {
|
|
129
|
+
const val = arg0;
|
|
130
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
131
|
+
return ret;
|
|
132
|
+
},
|
|
133
|
+
__wbg___wbindgen_is_string_1fca8072260dd261: function(arg0) {
|
|
134
|
+
const ret = typeof(arg0) === 'string';
|
|
135
|
+
return ret;
|
|
136
|
+
},
|
|
137
|
+
__wbg___wbindgen_jsval_eq_4e8c38722cb8ff51: function(arg0, arg1) {
|
|
138
|
+
const ret = arg0 === arg1;
|
|
139
|
+
return ret;
|
|
140
|
+
},
|
|
141
|
+
__wbg___wbindgen_jsval_loose_eq_4b9aba9e5b3c4582: function(arg0, arg1) {
|
|
142
|
+
const ret = arg0 == arg1;
|
|
143
|
+
return ret;
|
|
144
|
+
},
|
|
145
|
+
__wbg___wbindgen_number_get_1cc01dd708740256: function(arg0, arg1) {
|
|
146
|
+
const obj = arg1;
|
|
147
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
148
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
149
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
150
|
+
},
|
|
151
|
+
__wbg___wbindgen_string_get_71bb4348194e31f0: function(arg0, arg1) {
|
|
152
|
+
const obj = arg1;
|
|
153
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
154
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
155
|
+
var len1 = WASM_VECTOR_LEN;
|
|
156
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
157
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
158
|
+
},
|
|
159
|
+
__wbg___wbindgen_throw_ea4887a5f8f9a9db: function(arg0, arg1) {
|
|
160
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
161
|
+
},
|
|
162
|
+
__wbg_call_8e98ed2f3c86c4b5: function() { return handleError(function (arg0, arg1) {
|
|
163
|
+
const ret = arg0.call(arg1);
|
|
164
|
+
return ret;
|
|
165
|
+
}, arguments); },
|
|
166
|
+
__wbg_done_b62d4a7d2286852a: function(arg0) {
|
|
167
|
+
const ret = arg0.done;
|
|
168
|
+
return ret;
|
|
169
|
+
},
|
|
170
|
+
__wbg_entries_c261c3fa1f281256: function(arg0) {
|
|
171
|
+
const ret = Object.entries(arg0);
|
|
172
|
+
return ret;
|
|
173
|
+
},
|
|
174
|
+
__wbg_error_a6fa202b58aa1cd3: function(arg0, arg1) {
|
|
175
|
+
let deferred0_0;
|
|
176
|
+
let deferred0_1;
|
|
177
|
+
try {
|
|
178
|
+
deferred0_0 = arg0;
|
|
179
|
+
deferred0_1 = arg1;
|
|
180
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
181
|
+
} finally {
|
|
182
|
+
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
__wbg_get_197a3fe98f169e38: function(arg0, arg1) {
|
|
186
|
+
const ret = arg0[arg1 >>> 0];
|
|
187
|
+
return ret;
|
|
188
|
+
},
|
|
189
|
+
__wbg_get_9a29be2cb383ed9a: function() { return handleError(function (arg0, arg1) {
|
|
190
|
+
const ret = Reflect.get(arg0, arg1);
|
|
191
|
+
return ret;
|
|
192
|
+
}, arguments); },
|
|
193
|
+
__wbg_get_unchecked_54a4374c38e08460: function(arg0, arg1) {
|
|
194
|
+
const ret = arg0[arg1 >>> 0];
|
|
195
|
+
return ret;
|
|
196
|
+
},
|
|
197
|
+
__wbg_instanceof_ArrayBuffer_2a7bb09fee70c2da: function(arg0) {
|
|
198
|
+
let result;
|
|
199
|
+
try {
|
|
200
|
+
result = arg0 instanceof ArrayBuffer;
|
|
201
|
+
} catch (_) {
|
|
202
|
+
result = false;
|
|
203
|
+
}
|
|
204
|
+
const ret = result;
|
|
205
|
+
return ret;
|
|
206
|
+
},
|
|
207
|
+
__wbg_instanceof_Map_afa18d5840c04c15: function(arg0) {
|
|
208
|
+
let result;
|
|
209
|
+
try {
|
|
210
|
+
result = arg0 instanceof Map;
|
|
211
|
+
} catch (_) {
|
|
212
|
+
result = false;
|
|
213
|
+
}
|
|
214
|
+
const ret = result;
|
|
215
|
+
return ret;
|
|
216
|
+
},
|
|
217
|
+
__wbg_instanceof_Uint8Array_f080092dc70f5d58: function(arg0) {
|
|
218
|
+
let result;
|
|
219
|
+
try {
|
|
220
|
+
result = arg0 instanceof Uint8Array;
|
|
221
|
+
} catch (_) {
|
|
222
|
+
result = false;
|
|
223
|
+
}
|
|
224
|
+
const ret = result;
|
|
225
|
+
return ret;
|
|
226
|
+
},
|
|
227
|
+
__wbg_isArray_145a34fd0a38d37b: function(arg0) {
|
|
228
|
+
const ret = Array.isArray(arg0);
|
|
229
|
+
return ret;
|
|
230
|
+
},
|
|
231
|
+
__wbg_isSafeInteger_a3389a198582f5f6: function(arg0) {
|
|
232
|
+
const ret = Number.isSafeInteger(arg0);
|
|
233
|
+
return ret;
|
|
234
|
+
},
|
|
235
|
+
__wbg_iterator_cc47ba25a2be735a: function() {
|
|
236
|
+
const ret = Symbol.iterator;
|
|
237
|
+
return ret;
|
|
238
|
+
},
|
|
239
|
+
__wbg_length_589238bdcf171f0e: function(arg0) {
|
|
240
|
+
const ret = arg0.length;
|
|
241
|
+
return ret;
|
|
242
|
+
},
|
|
243
|
+
__wbg_length_c6054974c0a6cdb9: function(arg0) {
|
|
244
|
+
const ret = arg0.length;
|
|
245
|
+
return ret;
|
|
246
|
+
},
|
|
247
|
+
__wbg_new_227d7c05414eb861: function() {
|
|
248
|
+
const ret = new Error();
|
|
249
|
+
return ret;
|
|
250
|
+
},
|
|
251
|
+
__wbg_new_2e117a478906f062: function() {
|
|
252
|
+
const ret = new Object();
|
|
253
|
+
return ret;
|
|
254
|
+
},
|
|
255
|
+
__wbg_new_3444eb7412549f0b: function() {
|
|
256
|
+
const ret = new Map();
|
|
257
|
+
return ret;
|
|
258
|
+
},
|
|
259
|
+
__wbg_new_36e147a8ced3c6e0: function() {
|
|
260
|
+
const ret = new Array();
|
|
261
|
+
return ret;
|
|
262
|
+
},
|
|
263
|
+
__wbg_new_81880fb5002cb255: function(arg0) {
|
|
264
|
+
const ret = new Uint8Array(arg0);
|
|
265
|
+
return ret;
|
|
266
|
+
},
|
|
267
|
+
__wbg_next_0c4066e251d2eff9: function() { return handleError(function (arg0) {
|
|
268
|
+
const ret = arg0.next();
|
|
269
|
+
return ret;
|
|
270
|
+
}, arguments); },
|
|
271
|
+
__wbg_next_402fa10b59ab20c3: function(arg0) {
|
|
272
|
+
const ret = arg0.next;
|
|
273
|
+
return ret;
|
|
274
|
+
},
|
|
275
|
+
__wbg_prototypesetcall_d721637c7ca66eb8: function(arg0, arg1, arg2) {
|
|
276
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
277
|
+
},
|
|
278
|
+
__wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
|
|
279
|
+
arg0[arg1] = arg2;
|
|
280
|
+
},
|
|
281
|
+
__wbg_set_9a1d61e17de7054c: function(arg0, arg1, arg2) {
|
|
282
|
+
const ret = arg0.set(arg1, arg2);
|
|
283
|
+
return ret;
|
|
284
|
+
},
|
|
285
|
+
__wbg_set_dc601f4a69da0bc2: function(arg0, arg1, arg2) {
|
|
286
|
+
arg0[arg1 >>> 0] = arg2;
|
|
287
|
+
},
|
|
288
|
+
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
289
|
+
const ret = arg1.stack;
|
|
290
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
291
|
+
const len1 = WASM_VECTOR_LEN;
|
|
292
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
293
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
294
|
+
},
|
|
295
|
+
__wbg_value_49f783bb59765962: function(arg0) {
|
|
296
|
+
const ret = arg0.value;
|
|
297
|
+
return ret;
|
|
298
|
+
},
|
|
299
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
300
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
301
|
+
const ret = arg0;
|
|
302
|
+
return ret;
|
|
303
|
+
},
|
|
304
|
+
__wbindgen_cast_0000000000000002: function(arg0) {
|
|
305
|
+
// Cast intrinsic for `I64 -> Externref`.
|
|
306
|
+
const ret = arg0;
|
|
307
|
+
return ret;
|
|
308
|
+
},
|
|
309
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
310
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
311
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
312
|
+
return ret;
|
|
313
|
+
},
|
|
314
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
315
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
316
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
317
|
+
return ret;
|
|
318
|
+
},
|
|
319
|
+
__wbindgen_init_externref_table: function() {
|
|
320
|
+
const table = wasm.__wbindgen_externrefs;
|
|
321
|
+
const offset = table.grow(4);
|
|
322
|
+
table.set(0, undefined);
|
|
323
|
+
table.set(offset + 0, undefined);
|
|
324
|
+
table.set(offset + 1, null);
|
|
325
|
+
table.set(offset + 2, true);
|
|
326
|
+
table.set(offset + 3, false);
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
return {
|
|
330
|
+
__proto__: null,
|
|
331
|
+
"./cratestack_cbor_wasm_bg.js": import0,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function addToExternrefTable0(obj) {
|
|
336
|
+
const idx = wasm.__externref_table_alloc();
|
|
337
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
338
|
+
return idx;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
function debugString(val) {
|
|
342
|
+
// primitive types
|
|
343
|
+
const type = typeof val;
|
|
344
|
+
if (type == 'number' || type == 'boolean' || val == null) {
|
|
345
|
+
return `${val}`;
|
|
346
|
+
}
|
|
347
|
+
if (type == 'string') {
|
|
348
|
+
return `"${val}"`;
|
|
349
|
+
}
|
|
350
|
+
if (type == 'symbol') {
|
|
351
|
+
const description = val.description;
|
|
352
|
+
if (description == null) {
|
|
353
|
+
return 'Symbol';
|
|
354
|
+
} else {
|
|
355
|
+
return `Symbol(${description})`;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (type == 'function') {
|
|
359
|
+
const name = val.name;
|
|
360
|
+
if (typeof name == 'string' && name.length > 0) {
|
|
361
|
+
return `Function(${name})`;
|
|
362
|
+
} else {
|
|
363
|
+
return 'Function';
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
// objects
|
|
367
|
+
if (Array.isArray(val)) {
|
|
368
|
+
const length = val.length;
|
|
369
|
+
let debug = '[';
|
|
370
|
+
if (length > 0) {
|
|
371
|
+
debug += debugString(val[0]);
|
|
372
|
+
}
|
|
373
|
+
for(let i = 1; i < length; i++) {
|
|
374
|
+
debug += ', ' + debugString(val[i]);
|
|
375
|
+
}
|
|
376
|
+
debug += ']';
|
|
377
|
+
return debug;
|
|
378
|
+
}
|
|
379
|
+
// Test for built-in
|
|
380
|
+
const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
|
|
381
|
+
let className;
|
|
382
|
+
if (builtInMatches && builtInMatches.length > 1) {
|
|
383
|
+
className = builtInMatches[1];
|
|
384
|
+
} else {
|
|
385
|
+
// Failed to match the standard '[object ClassName]'
|
|
386
|
+
return toString.call(val);
|
|
387
|
+
}
|
|
388
|
+
if (className == 'Object') {
|
|
389
|
+
// we're a user defined class or Object
|
|
390
|
+
// JSON.stringify avoids problems with cycles, and is generally much
|
|
391
|
+
// easier than looping through ownProperties of `val`.
|
|
392
|
+
try {
|
|
393
|
+
return 'Object(' + JSON.stringify(val) + ')';
|
|
394
|
+
} catch (_) {
|
|
395
|
+
return 'Object';
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
// errors
|
|
399
|
+
if (val instanceof Error) {
|
|
400
|
+
return `${val.name}: ${val.message}\n${val.stack}`;
|
|
401
|
+
}
|
|
402
|
+
// TODO we could test for more things here, like `Set`s and `Map`s.
|
|
403
|
+
return className;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
407
|
+
ptr = ptr >>> 0;
|
|
408
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
let cachedDataViewMemory0 = null;
|
|
412
|
+
function getDataViewMemory0() {
|
|
413
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
414
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
415
|
+
}
|
|
416
|
+
return cachedDataViewMemory0;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
function getStringFromWasm0(ptr, len) {
|
|
420
|
+
return decodeText(ptr >>> 0, len);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
let cachedUint8ArrayMemory0 = null;
|
|
424
|
+
function getUint8ArrayMemory0() {
|
|
425
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
426
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
427
|
+
}
|
|
428
|
+
return cachedUint8ArrayMemory0;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function handleError(f, args) {
|
|
432
|
+
try {
|
|
433
|
+
return f.apply(this, args);
|
|
434
|
+
} catch (e) {
|
|
435
|
+
const idx = addToExternrefTable0(e);
|
|
436
|
+
wasm.__wbindgen_exn_store(idx);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function isLikeNone(x) {
|
|
441
|
+
return x === undefined || x === null;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
445
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
446
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
447
|
+
WASM_VECTOR_LEN = arg.length;
|
|
448
|
+
return ptr;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
452
|
+
if (realloc === undefined) {
|
|
453
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
454
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
455
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
456
|
+
WASM_VECTOR_LEN = buf.length;
|
|
457
|
+
return ptr;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
let len = arg.length;
|
|
461
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
462
|
+
|
|
463
|
+
const mem = getUint8ArrayMemory0();
|
|
464
|
+
|
|
465
|
+
let offset = 0;
|
|
466
|
+
|
|
467
|
+
for (; offset < len; offset++) {
|
|
468
|
+
const code = arg.charCodeAt(offset);
|
|
469
|
+
if (code > 0x7F) break;
|
|
470
|
+
mem[ptr + offset] = code;
|
|
471
|
+
}
|
|
472
|
+
if (offset !== len) {
|
|
473
|
+
if (offset !== 0) {
|
|
474
|
+
arg = arg.slice(offset);
|
|
475
|
+
}
|
|
476
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
477
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
478
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
479
|
+
|
|
480
|
+
offset += ret.written;
|
|
481
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
WASM_VECTOR_LEN = offset;
|
|
485
|
+
return ptr;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function takeFromExternrefTable0(idx) {
|
|
489
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
490
|
+
wasm.__externref_table_dealloc(idx);
|
|
491
|
+
return value;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
495
|
+
cachedTextDecoder.decode();
|
|
496
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
497
|
+
let numBytesDecoded = 0;
|
|
498
|
+
function decodeText(ptr, len) {
|
|
499
|
+
numBytesDecoded += len;
|
|
500
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
501
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
502
|
+
cachedTextDecoder.decode();
|
|
503
|
+
numBytesDecoded = len;
|
|
504
|
+
}
|
|
505
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const cachedTextEncoder = new TextEncoder();
|
|
509
|
+
|
|
510
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
511
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
512
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
513
|
+
view.set(buf);
|
|
514
|
+
return {
|
|
515
|
+
read: arg.length,
|
|
516
|
+
written: buf.length
|
|
517
|
+
};
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
let WASM_VECTOR_LEN = 0;
|
|
522
|
+
|
|
523
|
+
let wasmModule, wasmInstance, wasm;
|
|
524
|
+
function __wbg_finalize_init(instance, module) {
|
|
525
|
+
wasmInstance = instance;
|
|
526
|
+
wasm = instance.exports;
|
|
527
|
+
wasmModule = module;
|
|
528
|
+
cachedDataViewMemory0 = null;
|
|
529
|
+
cachedUint8ArrayMemory0 = null;
|
|
530
|
+
wasm.__wbindgen_start();
|
|
531
|
+
return wasm;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
async function __wbg_load(module, imports) {
|
|
535
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
536
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
537
|
+
try {
|
|
538
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
539
|
+
} catch (e) {
|
|
540
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
541
|
+
|
|
542
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
543
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
544
|
+
|
|
545
|
+
} else { throw e; }
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const bytes = await module.arrayBuffer();
|
|
550
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
551
|
+
} else {
|
|
552
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
553
|
+
|
|
554
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
555
|
+
return { instance, module };
|
|
556
|
+
} else {
|
|
557
|
+
return instance;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
function expectedResponseType(type) {
|
|
562
|
+
switch (type) {
|
|
563
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
564
|
+
}
|
|
565
|
+
return false;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
function initSync(module) {
|
|
570
|
+
if (wasm !== undefined) return wasm;
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
if (module !== undefined) {
|
|
574
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
575
|
+
({module} = module)
|
|
576
|
+
} else {
|
|
577
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
const imports = __wbg_get_imports();
|
|
582
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
583
|
+
module = new WebAssembly.Module(module);
|
|
584
|
+
}
|
|
585
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
586
|
+
return __wbg_finalize_init(instance, module);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
async function __wbg_init(module_or_path) {
|
|
590
|
+
if (wasm !== undefined) return wasm;
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
if (module_or_path !== undefined) {
|
|
594
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
595
|
+
({module_or_path} = module_or_path)
|
|
596
|
+
} else {
|
|
597
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
if (module_or_path === undefined) {
|
|
602
|
+
module_or_path = new URL('cratestack_cbor_wasm_bg.wasm', import.meta.url);
|
|
603
|
+
}
|
|
604
|
+
const imports = __wbg_get_imports();
|
|
605
|
+
|
|
606
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
607
|
+
module_or_path = fetch(module_or_path);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
611
|
+
|
|
612
|
+
return __wbg_finalize_init(instance, module);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cratestack/cbor-web",
|
|
3
|
+
"version": "0.5.2",
|
|
4
|
+
"description": "wasm-bindgen CBOR codec for browser CrateStack RPC clients. Async one-time WASM init, synchronous encode/decode after — backed by the same Rust CborCodec the server and Rust client already use.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/cratestack/cratestack.git",
|
|
9
|
+
"directory": "packages/cratestack-cbor-web"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://cratestack.dev",
|
|
12
|
+
"bugs": "https://github.com/cratestack/cratestack/issues",
|
|
13
|
+
"keywords": ["cratestack", "cstack", "rpc", "cbor", "wasm", "codec"],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"wasm:build": "node ../../examples/scripts/wasm-build.mjs --crate ../../crates/cratestack-cbor-wasm --target web --out-dir ../../packages/cratestack-cbor-web/src/wasm-pkg",
|
|
27
|
+
"wasm:build:dev": "node ../../examples/scripts/wasm-build.mjs --crate ../../crates/cratestack-cbor-wasm --target web --out-dir ../../packages/cratestack-cbor-web/src/wasm-pkg --dev",
|
|
28
|
+
"prebuild": "pnpm run wasm:build",
|
|
29
|
+
"build": "tsc -p tsconfig.json && mkdir -p dist/wasm-pkg && cp src/wasm-pkg/cratestack_cbor_wasm.js src/wasm-pkg/cratestack_cbor_wasm_bg.wasm dist/wasm-pkg/",
|
|
30
|
+
"pretest": "pnpm run wasm:build:dev",
|
|
31
|
+
"test": "vitest run",
|
|
32
|
+
"lint": "biome check ."
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@cratestack/ts-types": "0.5.2"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"typescript": "^5.7.0",
|
|
39
|
+
"vitest": "^3.0.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
}
|
|
44
|
+
}
|