clawpowers 1.1.4 → 2.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/CHANGELOG.md +126 -0
- package/COMPATIBILITY.md +13 -0
- package/KNOWN_LIMITATIONS.md +19 -0
- package/LICENSE +44 -0
- package/LICENSING.md +10 -0
- package/README.md +378 -210
- package/SECURITY.md +52 -0
- package/dist/index.d.ts +1477 -0
- package/dist/index.js +3464 -0
- package/dist/index.js.map +1 -0
- package/native/Cargo.lock +4863 -0
- package/native/Cargo.toml +73 -0
- package/native/crates/canonical/Cargo.toml +24 -0
- package/native/crates/canonical/src/lib.rs +673 -0
- package/native/crates/compression/Cargo.toml +20 -0
- package/native/crates/compression/benches/compression_bench.rs +42 -0
- package/native/crates/compression/src/lib.rs +393 -0
- package/native/crates/evm-eth/Cargo.toml +13 -0
- package/native/crates/evm-eth/src/lib.rs +105 -0
- package/native/crates/fee/Cargo.toml +15 -0
- package/native/crates/fee/src/lib.rs +281 -0
- package/native/crates/index/Cargo.toml +16 -0
- package/native/crates/index/src/lib.rs +277 -0
- package/native/crates/policy/Cargo.toml +17 -0
- package/native/crates/policy/src/lib.rs +614 -0
- package/native/crates/security/Cargo.toml +22 -0
- package/native/crates/security/src/lib.rs +478 -0
- package/native/crates/tokens/Cargo.toml +13 -0
- package/native/crates/tokens/src/lib.rs +534 -0
- package/native/crates/verification/Cargo.toml +23 -0
- package/native/crates/verification/src/lib.rs +333 -0
- package/native/crates/wallet/Cargo.toml +20 -0
- package/native/crates/wallet/src/lib.rs +261 -0
- package/native/crates/x402/Cargo.toml +30 -0
- package/native/crates/x402/src/lib.rs +423 -0
- package/native/ffi/Cargo.toml +34 -0
- package/native/ffi/build.rs +4 -0
- package/native/ffi/index.node +0 -0
- package/native/ffi/src/lib.rs +352 -0
- package/native/ffi/tests/integration.rs +354 -0
- package/native/pyo3/Cargo.toml +26 -0
- package/native/pyo3/pyproject.toml +16 -0
- package/native/pyo3/src/lib.rs +407 -0
- package/native/pyo3/tests/test_smoke.py +180 -0
- package/native/wasm/Cargo.toml +44 -0
- package/native/wasm/pkg/.gitignore +6 -0
- package/native/wasm/pkg/clawpowers_wasm.d.ts +208 -0
- package/native/wasm/pkg/clawpowers_wasm.js +872 -0
- package/native/wasm/pkg/clawpowers_wasm_bg.wasm +0 -0
- package/native/wasm/pkg/clawpowers_wasm_bg.wasm.d.ts +40 -0
- package/native/wasm/pkg/package.json +17 -0
- package/native/wasm/pkg-node/.gitignore +6 -0
- package/native/wasm/pkg-node/clawpowers_wasm.d.ts +143 -0
- package/native/wasm/pkg-node/clawpowers_wasm.js +798 -0
- package/native/wasm/pkg-node/clawpowers_wasm_bg.wasm +0 -0
- package/native/wasm/pkg-node/clawpowers_wasm_bg.wasm.d.ts +40 -0
- package/native/wasm/pkg-node/package.json +13 -0
- package/native/wasm/src/lib.rs +433 -0
- package/package.json +71 -44
- package/src/skills/catalog.ts +435 -0
- package/src/skills/executor.ts +56 -0
- package/src/skills/index.ts +3 -0
- package/src/skills/itp/SKILL.md +112 -0
- package/src/skills/loader.ts +193 -0
- package/.claude-plugin/manifest.json +0 -19
- package/.codex/INSTALL.md +0 -36
- package/.cursor-plugin/manifest.json +0 -21
- package/.opencode/INSTALL.md +0 -52
- package/ARCHITECTURE.md +0 -69
- package/bin/clawpowers.js +0 -625
- package/bin/clawpowers.sh +0 -91
- package/docs/demo/clawpowers-demo.cast +0 -197
- package/docs/demo/clawpowers-demo.gif +0 -0
- package/docs/launch-images/25-skills-breakdown.jpg +0 -0
- package/docs/launch-images/clawpowers-vs-superpowers.jpg +0 -0
- package/docs/launch-images/economic-code-optimization.jpg +0 -0
- package/docs/launch-images/native-vs-bridge-2.jpg +0 -0
- package/docs/launch-images/native-vs-bridge.jpg +0 -0
- package/docs/launch-images/post1-hero-lobster.jpg +0 -0
- package/docs/launch-images/post2-dashboard.jpg +0 -0
- package/docs/launch-images/post3-superpowers.jpg +0 -0
- package/docs/launch-images/post4-before-after.jpg +0 -0
- package/docs/launch-images/post5-install-now.jpg +0 -0
- package/docs/launch-images/ultimate-stack.jpg +0 -0
- package/docs/launch-posts.md +0 -76
- package/docs/quickstart-first-transaction.md +0 -204
- package/gemini-extension.json +0 -32
- package/hooks/session-start +0 -205
- package/hooks/session-start.cmd +0 -43
- package/hooks/session-start.js +0 -163
- package/runtime/demo/README.md +0 -78
- package/runtime/demo/x402-mock-server.js +0 -230
- package/runtime/feedback/analyze.js +0 -621
- package/runtime/feedback/analyze.sh +0 -546
- package/runtime/init.js +0 -210
- package/runtime/init.sh +0 -178
- package/runtime/metrics/collector.js +0 -361
- package/runtime/metrics/collector.sh +0 -308
- package/runtime/payments/ledger.js +0 -305
- package/runtime/payments/ledger.sh +0 -262
- package/runtime/payments/pipeline.js +0 -455
- package/runtime/persistence/store.js +0 -433
- package/runtime/persistence/store.sh +0 -303
- package/skill.json +0 -106
- package/skills/agent-bounties/SKILL.md +0 -553
- package/skills/agent-payments/SKILL.md +0 -479
- package/skills/brainstorming/SKILL.md +0 -233
- package/skills/content-pipeline/SKILL.md +0 -282
- package/skills/cross-project-knowledge/SKILL.md +0 -345
- package/skills/dispatching-parallel-agents/SKILL.md +0 -305
- package/skills/economic-code-optimization/SKILL.md +0 -265
- package/skills/executing-plans/SKILL.md +0 -255
- package/skills/finishing-a-development-branch/SKILL.md +0 -260
- package/skills/formal-verification-lite/SKILL.md +0 -441
- package/skills/learn-how-to-learn/SKILL.md +0 -235
- package/skills/market-intelligence/SKILL.md +0 -323
- package/skills/meta-skill-evolution/SKILL.md +0 -325
- package/skills/prospecting/SKILL.md +0 -454
- package/skills/receiving-code-review/SKILL.md +0 -225
- package/skills/requesting-code-review/SKILL.md +0 -206
- package/skills/security-audit/SKILL.md +0 -353
- package/skills/self-healing-code/SKILL.md +0 -369
- package/skills/subagent-driven-development/SKILL.md +0 -244
- package/skills/systematic-debugging/SKILL.md +0 -355
- package/skills/test-driven-development/SKILL.md +0 -416
- package/skills/using-clawpowers/SKILL.md +0 -160
- package/skills/using-git-worktrees/SKILL.md +0 -261
- package/skills/validator/SKILL.md +0 -281
- package/skills/verification-before-completion/SKILL.md +0 -254
- package/skills/writing-plans/SKILL.md +0 -276
- package/skills/writing-skills/SKILL.md +0 -260
|
@@ -0,0 +1,872 @@
|
|
|
1
|
+
/* @ts-self-types="./clawpowers_wasm.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Opaque handle to an in-memory CanonicalStore.
|
|
5
|
+
*/
|
|
6
|
+
export class WasmCanonicalStore {
|
|
7
|
+
__destroy_into_raw() {
|
|
8
|
+
const ptr = this.__wbg_ptr;
|
|
9
|
+
this.__wbg_ptr = 0;
|
|
10
|
+
WasmCanonicalStoreFinalization.unregister(this);
|
|
11
|
+
return ptr;
|
|
12
|
+
}
|
|
13
|
+
free() {
|
|
14
|
+
const ptr = this.__destroy_into_raw();
|
|
15
|
+
wasm.__wbg_wasmcanonicalstore_free(ptr, 0);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Export all records as JSON for IndexedDB persistence.
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
exportJson() {
|
|
22
|
+
let deferred2_0;
|
|
23
|
+
let deferred2_1;
|
|
24
|
+
try {
|
|
25
|
+
const ret = wasm.wasmcanonicalstore_exportJson(this.__wbg_ptr);
|
|
26
|
+
var ptr1 = ret[0];
|
|
27
|
+
var len1 = ret[1];
|
|
28
|
+
if (ret[3]) {
|
|
29
|
+
ptr1 = 0; len1 = 0;
|
|
30
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
31
|
+
}
|
|
32
|
+
deferred2_0 = ptr1;
|
|
33
|
+
deferred2_1 = len1;
|
|
34
|
+
return getStringFromWasm0(ptr1, len1);
|
|
35
|
+
} finally {
|
|
36
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get a record by UUID. Returns JSON or null.
|
|
41
|
+
* @param {string} id
|
|
42
|
+
* @returns {string | undefined}
|
|
43
|
+
*/
|
|
44
|
+
get(id) {
|
|
45
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
46
|
+
const len0 = WASM_VECTOR_LEN;
|
|
47
|
+
const ret = wasm.wasmcanonicalstore_get(this.__wbg_ptr, ptr0, len0);
|
|
48
|
+
if (ret[3]) {
|
|
49
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
50
|
+
}
|
|
51
|
+
let v2;
|
|
52
|
+
if (ret[0] !== 0) {
|
|
53
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
54
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
55
|
+
}
|
|
56
|
+
return v2;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get a record by content hash. Returns JSON or null.
|
|
60
|
+
* @param {string} hash
|
|
61
|
+
* @returns {string | undefined}
|
|
62
|
+
*/
|
|
63
|
+
getByHash(hash) {
|
|
64
|
+
const ptr0 = passStringToWasm0(hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
65
|
+
const len0 = WASM_VECTOR_LEN;
|
|
66
|
+
const ret = wasm.wasmcanonicalstore_getByHash(this.__wbg_ptr, ptr0, len0);
|
|
67
|
+
if (ret[3]) {
|
|
68
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
69
|
+
}
|
|
70
|
+
let v2;
|
|
71
|
+
if (ret[0] !== 0) {
|
|
72
|
+
v2 = getStringFromWasm0(ret[0], ret[1]).slice();
|
|
73
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
74
|
+
}
|
|
75
|
+
return v2;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Import records from JSON (e.g., loaded from IndexedDB).
|
|
79
|
+
* @param {string} json
|
|
80
|
+
* @returns {number}
|
|
81
|
+
*/
|
|
82
|
+
importJson(json) {
|
|
83
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
84
|
+
const len0 = WASM_VECTOR_LEN;
|
|
85
|
+
const ret = wasm.wasmcanonicalstore_importJson(this.__wbg_ptr, ptr0, len0);
|
|
86
|
+
if (ret[2]) {
|
|
87
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
88
|
+
}
|
|
89
|
+
return ret[0] >>> 0;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Insert a record. Input: JSON with {namespace, content, metadata, provenance}.
|
|
93
|
+
* Returns the record UUID as a string.
|
|
94
|
+
* @param {string} json
|
|
95
|
+
* @returns {string}
|
|
96
|
+
*/
|
|
97
|
+
insert(json) {
|
|
98
|
+
let deferred3_0;
|
|
99
|
+
let deferred3_1;
|
|
100
|
+
try {
|
|
101
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
102
|
+
const len0 = WASM_VECTOR_LEN;
|
|
103
|
+
const ret = wasm.wasmcanonicalstore_insert(this.__wbg_ptr, ptr0, len0);
|
|
104
|
+
var ptr2 = ret[0];
|
|
105
|
+
var len2 = ret[1];
|
|
106
|
+
if (ret[3]) {
|
|
107
|
+
ptr2 = 0; len2 = 0;
|
|
108
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
109
|
+
}
|
|
110
|
+
deferred3_0 = ptr2;
|
|
111
|
+
deferred3_1 = len2;
|
|
112
|
+
return getStringFromWasm0(ptr2, len2);
|
|
113
|
+
} finally {
|
|
114
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a new in-memory canonical store.
|
|
119
|
+
*/
|
|
120
|
+
constructor() {
|
|
121
|
+
const ret = wasm.wasmcanonicalstore_new();
|
|
122
|
+
if (ret[2]) {
|
|
123
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
124
|
+
}
|
|
125
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
126
|
+
WasmCanonicalStoreFinalization.register(this, this.__wbg_ptr, this);
|
|
127
|
+
return this;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Query records by namespace. Returns JSON array.
|
|
131
|
+
* @param {string} namespace
|
|
132
|
+
* @param {number} limit
|
|
133
|
+
* @returns {string}
|
|
134
|
+
*/
|
|
135
|
+
queryNamespace(namespace, limit) {
|
|
136
|
+
let deferred3_0;
|
|
137
|
+
let deferred3_1;
|
|
138
|
+
try {
|
|
139
|
+
const ptr0 = passStringToWasm0(namespace, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
140
|
+
const len0 = WASM_VECTOR_LEN;
|
|
141
|
+
const ret = wasm.wasmcanonicalstore_queryNamespace(this.__wbg_ptr, ptr0, len0, limit);
|
|
142
|
+
var ptr2 = ret[0];
|
|
143
|
+
var len2 = ret[1];
|
|
144
|
+
if (ret[3]) {
|
|
145
|
+
ptr2 = 0; len2 = 0;
|
|
146
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
147
|
+
}
|
|
148
|
+
deferred3_0 = ptr2;
|
|
149
|
+
deferred3_1 = len2;
|
|
150
|
+
return getStringFromWasm0(ptr2, len2);
|
|
151
|
+
} finally {
|
|
152
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Soft-delete a record. Returns true if the record existed.
|
|
157
|
+
* @param {string} id
|
|
158
|
+
* @returns {boolean}
|
|
159
|
+
*/
|
|
160
|
+
softDelete(id) {
|
|
161
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
162
|
+
const len0 = WASM_VECTOR_LEN;
|
|
163
|
+
const ret = wasm.wasmcanonicalstore_softDelete(this.__wbg_ptr, ptr0, len0);
|
|
164
|
+
if (ret[2]) {
|
|
165
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
166
|
+
}
|
|
167
|
+
return ret[0] !== 0;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Verify record integrity. Returns true if hash matches.
|
|
171
|
+
* @param {string} id
|
|
172
|
+
* @returns {boolean}
|
|
173
|
+
*/
|
|
174
|
+
verifyIntegrity(id) {
|
|
175
|
+
const ptr0 = passStringToWasm0(id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
176
|
+
const len0 = WASM_VECTOR_LEN;
|
|
177
|
+
const ret = wasm.wasmcanonicalstore_verifyIntegrity(this.__wbg_ptr, ptr0, len0);
|
|
178
|
+
if (ret[2]) {
|
|
179
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
180
|
+
}
|
|
181
|
+
return ret[0] !== 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (Symbol.dispose) WasmCanonicalStore.prototype[Symbol.dispose] = WasmCanonicalStore.prototype.free;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Compute approximate distance between two CompressedVector JSONs.
|
|
188
|
+
* @param {string} a_json
|
|
189
|
+
* @param {string} b_json
|
|
190
|
+
* @param {number} dimensions
|
|
191
|
+
* @returns {number}
|
|
192
|
+
*/
|
|
193
|
+
export function approximateDistance(a_json, b_json, dimensions) {
|
|
194
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
195
|
+
const len0 = WASM_VECTOR_LEN;
|
|
196
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
197
|
+
const len1 = WASM_VECTOR_LEN;
|
|
198
|
+
const ret = wasm.approximateDistance(ptr0, len0, ptr1, len1, dimensions);
|
|
199
|
+
if (ret[2]) {
|
|
200
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
201
|
+
}
|
|
202
|
+
return ret[0];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Calculate a transaction fee.
|
|
207
|
+
* Returns JSON: `{"gross_amount": ..., "fee_amount": ..., "net_amount": ...}`
|
|
208
|
+
* @param {string} amount_json
|
|
209
|
+
* @param {string} fee_type
|
|
210
|
+
* @param {bigint | null} [tx_fee_bps]
|
|
211
|
+
* @param {bigint | null} [swap_fee_bps]
|
|
212
|
+
* @returns {string}
|
|
213
|
+
*/
|
|
214
|
+
export function calculateFee(amount_json, fee_type, tx_fee_bps, swap_fee_bps) {
|
|
215
|
+
let deferred4_0;
|
|
216
|
+
let deferred4_1;
|
|
217
|
+
try {
|
|
218
|
+
const ptr0 = passStringToWasm0(amount_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
219
|
+
const len0 = WASM_VECTOR_LEN;
|
|
220
|
+
const ptr1 = passStringToWasm0(fee_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
221
|
+
const len1 = WASM_VECTOR_LEN;
|
|
222
|
+
const ret = wasm.calculateFee(ptr0, len0, ptr1, len1, !isLikeNone(tx_fee_bps), isLikeNone(tx_fee_bps) ? BigInt(0) : tx_fee_bps, !isLikeNone(swap_fee_bps), isLikeNone(swap_fee_bps) ? BigInt(0) : swap_fee_bps);
|
|
223
|
+
var ptr3 = ret[0];
|
|
224
|
+
var len3 = ret[1];
|
|
225
|
+
if (ret[3]) {
|
|
226
|
+
ptr3 = 0; len3 = 0;
|
|
227
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
228
|
+
}
|
|
229
|
+
deferred4_0 = ptr3;
|
|
230
|
+
deferred4_1 = len3;
|
|
231
|
+
return getStringFromWasm0(ptr3, len3);
|
|
232
|
+
} finally {
|
|
233
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Compress a float32 vector. Input: JSON array of f32. Output: CompressedVector JSON.
|
|
239
|
+
* @param {string} vector_json
|
|
240
|
+
* @param {number} dimensions
|
|
241
|
+
* @returns {string}
|
|
242
|
+
*/
|
|
243
|
+
export function compressVector(vector_json, dimensions) {
|
|
244
|
+
let deferred3_0;
|
|
245
|
+
let deferred3_1;
|
|
246
|
+
try {
|
|
247
|
+
const ptr0 = passStringToWasm0(vector_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
248
|
+
const len0 = WASM_VECTOR_LEN;
|
|
249
|
+
const ret = wasm.compressVector(ptr0, len0, dimensions);
|
|
250
|
+
var ptr2 = ret[0];
|
|
251
|
+
var len2 = ret[1];
|
|
252
|
+
if (ret[3]) {
|
|
253
|
+
ptr2 = 0; len2 = 0;
|
|
254
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
255
|
+
}
|
|
256
|
+
deferred3_0 = ptr2;
|
|
257
|
+
deferred3_1 = len2;
|
|
258
|
+
return getStringFromWasm0(ptr2, len2);
|
|
259
|
+
} finally {
|
|
260
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Compute Keccak-256 hash of raw bytes (EVM-compatible). Returns `0x` + 64 hex chars.
|
|
266
|
+
* @param {Uint8Array} bytes
|
|
267
|
+
* @returns {string}
|
|
268
|
+
*/
|
|
269
|
+
export function computeKeccak256(bytes) {
|
|
270
|
+
let deferred2_0;
|
|
271
|
+
let deferred2_1;
|
|
272
|
+
try {
|
|
273
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
274
|
+
const len0 = WASM_VECTOR_LEN;
|
|
275
|
+
const ret = wasm.computeKeccak256(ptr0, len0);
|
|
276
|
+
deferred2_0 = ret[0];
|
|
277
|
+
deferred2_1 = ret[1];
|
|
278
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
279
|
+
} finally {
|
|
280
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Compute SHA-256 hash of content string.
|
|
286
|
+
* @param {string} content
|
|
287
|
+
* @returns {string}
|
|
288
|
+
*/
|
|
289
|
+
export function computeSha256(content) {
|
|
290
|
+
let deferred2_0;
|
|
291
|
+
let deferred2_1;
|
|
292
|
+
try {
|
|
293
|
+
const ptr0 = passStringToWasm0(content, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
294
|
+
const len0 = WASM_VECTOR_LEN;
|
|
295
|
+
const ret = wasm.computeSha256(ptr0, len0);
|
|
296
|
+
deferred2_0 = ret[0];
|
|
297
|
+
deferred2_1 = ret[1];
|
|
298
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
299
|
+
} finally {
|
|
300
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Decompress a CompressedVector JSON back to a float32 array JSON.
|
|
306
|
+
* @param {string} compressed_json
|
|
307
|
+
* @param {number} dimensions
|
|
308
|
+
* @returns {string}
|
|
309
|
+
*/
|
|
310
|
+
export function decompressVector(compressed_json, dimensions) {
|
|
311
|
+
let deferred3_0;
|
|
312
|
+
let deferred3_1;
|
|
313
|
+
try {
|
|
314
|
+
const ptr0 = passStringToWasm0(compressed_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
315
|
+
const len0 = WASM_VECTOR_LEN;
|
|
316
|
+
const ret = wasm.decompressVector(ptr0, len0, dimensions);
|
|
317
|
+
var ptr2 = ret[0];
|
|
318
|
+
var len2 = ret[1];
|
|
319
|
+
if (ret[3]) {
|
|
320
|
+
ptr2 = 0; len2 = 0;
|
|
321
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
322
|
+
}
|
|
323
|
+
deferred3_0 = ptr2;
|
|
324
|
+
deferred3_1 = len2;
|
|
325
|
+
return getStringFromWasm0(ptr2, len2);
|
|
326
|
+
} finally {
|
|
327
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* Ethereum address from 32-byte secp256k1 private key (`0x` + 20 bytes, EIP-55 checksum).
|
|
333
|
+
* @param {Uint8Array} private_key
|
|
334
|
+
* @returns {string}
|
|
335
|
+
*/
|
|
336
|
+
export function deriveEthereumAddress(private_key) {
|
|
337
|
+
let deferred3_0;
|
|
338
|
+
let deferred3_1;
|
|
339
|
+
try {
|
|
340
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
341
|
+
const len0 = WASM_VECTOR_LEN;
|
|
342
|
+
const ret = wasm.deriveEthereumAddress(ptr0, len0);
|
|
343
|
+
var ptr2 = ret[0];
|
|
344
|
+
var len2 = ret[1];
|
|
345
|
+
if (ret[3]) {
|
|
346
|
+
ptr2 = 0; len2 = 0;
|
|
347
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
348
|
+
}
|
|
349
|
+
deferred3_0 = ptr2;
|
|
350
|
+
deferred3_1 = len2;
|
|
351
|
+
return getStringFromWasm0(ptr2, len2);
|
|
352
|
+
} finally {
|
|
353
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Uncompressed public key: 64 bytes (x || y), no `0x04` prefix.
|
|
359
|
+
* @param {Uint8Array} private_key
|
|
360
|
+
* @returns {Uint8Array}
|
|
361
|
+
*/
|
|
362
|
+
export function derivePublicKey(private_key) {
|
|
363
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
364
|
+
const len0 = WASM_VECTOR_LEN;
|
|
365
|
+
const ret = wasm.derivePublicKey(ptr0, len0);
|
|
366
|
+
if (ret[3]) {
|
|
367
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
368
|
+
}
|
|
369
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
370
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
371
|
+
return v2;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Evaluate a write request against a firewall.
|
|
376
|
+
* Input JSON: {namespace, content, trust_level, source, allowed_namespaces?, blocked_patterns?, max_content_length?}
|
|
377
|
+
* Returns JSON: {"decision": "allow"|"deny"|"sanitize", "reason"?: ..., "sanitized"?: ...}
|
|
378
|
+
* @param {string} json
|
|
379
|
+
* @returns {string}
|
|
380
|
+
*/
|
|
381
|
+
export function evaluateWriteFirewall(json) {
|
|
382
|
+
let deferred3_0;
|
|
383
|
+
let deferred3_1;
|
|
384
|
+
try {
|
|
385
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
386
|
+
const len0 = WASM_VECTOR_LEN;
|
|
387
|
+
const ret = wasm.evaluateWriteFirewall(ptr0, len0);
|
|
388
|
+
var ptr2 = ret[0];
|
|
389
|
+
var len2 = ret[1];
|
|
390
|
+
if (ret[3]) {
|
|
391
|
+
ptr2 = 0; len2 = 0;
|
|
392
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
393
|
+
}
|
|
394
|
+
deferred3_0 = ptr2;
|
|
395
|
+
deferred3_1 = len2;
|
|
396
|
+
return getStringFromWasm0(ptr2, len2);
|
|
397
|
+
} finally {
|
|
398
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Returns a list of modules available in this WASM build.
|
|
404
|
+
* @returns {string}
|
|
405
|
+
*/
|
|
406
|
+
export function getAvailableModules() {
|
|
407
|
+
let deferred1_0;
|
|
408
|
+
let deferred1_1;
|
|
409
|
+
try {
|
|
410
|
+
const ret = wasm.getAvailableModules();
|
|
411
|
+
deferred1_0 = ret[0];
|
|
412
|
+
deferred1_1 = ret[1];
|
|
413
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
414
|
+
} finally {
|
|
415
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Get the default token registry as JSON.
|
|
421
|
+
* @returns {string}
|
|
422
|
+
*/
|
|
423
|
+
export function getDefaultTokenRegistry() {
|
|
424
|
+
let deferred2_0;
|
|
425
|
+
let deferred2_1;
|
|
426
|
+
try {
|
|
427
|
+
const ret = wasm.getDefaultTokenRegistry();
|
|
428
|
+
var ptr1 = ret[0];
|
|
429
|
+
var len1 = ret[1];
|
|
430
|
+
if (ret[3]) {
|
|
431
|
+
ptr1 = 0; len1 = 0;
|
|
432
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
433
|
+
}
|
|
434
|
+
deferred2_0 = ptr1;
|
|
435
|
+
deferred2_1 = len1;
|
|
436
|
+
return getStringFromWasm0(ptr1, len1);
|
|
437
|
+
} finally {
|
|
438
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* Returns the version and build info.
|
|
444
|
+
* @returns {string}
|
|
445
|
+
*/
|
|
446
|
+
export function getVersion() {
|
|
447
|
+
let deferred1_0;
|
|
448
|
+
let deferred1_1;
|
|
449
|
+
try {
|
|
450
|
+
const ret = wasm.getVersion();
|
|
451
|
+
deferred1_0 = ret[0];
|
|
452
|
+
deferred1_1 = ret[1];
|
|
453
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
454
|
+
} finally {
|
|
455
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* ECDSA sign 32-byte message hash → 65 bytes (r || s || recovery_id).
|
|
461
|
+
* @param {Uint8Array} private_key
|
|
462
|
+
* @param {Uint8Array} message_hash
|
|
463
|
+
* @returns {Uint8Array}
|
|
464
|
+
*/
|
|
465
|
+
export function signEcdsa(private_key, message_hash) {
|
|
466
|
+
const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_malloc);
|
|
467
|
+
const len0 = WASM_VECTOR_LEN;
|
|
468
|
+
const ptr1 = passArray8ToWasm0(message_hash, wasm.__wbindgen_malloc);
|
|
469
|
+
const len1 = WASM_VECTOR_LEN;
|
|
470
|
+
const ret = wasm.signEcdsa(ptr0, len0, ptr1, len1);
|
|
471
|
+
if (ret[3]) {
|
|
472
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
473
|
+
}
|
|
474
|
+
var v3 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
475
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
476
|
+
return v3;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Add two TokenAmount JSONs. Returns the sum as JSON.
|
|
481
|
+
* @param {string} a_json
|
|
482
|
+
* @param {string} b_json
|
|
483
|
+
* @returns {string}
|
|
484
|
+
*/
|
|
485
|
+
export function tokenAmountAdd(a_json, b_json) {
|
|
486
|
+
let deferred4_0;
|
|
487
|
+
let deferred4_1;
|
|
488
|
+
try {
|
|
489
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
490
|
+
const len0 = WASM_VECTOR_LEN;
|
|
491
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
492
|
+
const len1 = WASM_VECTOR_LEN;
|
|
493
|
+
const ret = wasm.tokenAmountAdd(ptr0, len0, ptr1, len1);
|
|
494
|
+
var ptr3 = ret[0];
|
|
495
|
+
var len3 = ret[1];
|
|
496
|
+
if (ret[3]) {
|
|
497
|
+
ptr3 = 0; len3 = 0;
|
|
498
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
499
|
+
}
|
|
500
|
+
deferred4_0 = ptr3;
|
|
501
|
+
deferred4_1 = len3;
|
|
502
|
+
return getStringFromWasm0(ptr3, len3);
|
|
503
|
+
} finally {
|
|
504
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Create a TokenAmount from a human-readable f64 value and decimal count.
|
|
510
|
+
* Returns JSON: `{"raw": "...", "decimals": N}`
|
|
511
|
+
* @param {number} human
|
|
512
|
+
* @param {number} decimals
|
|
513
|
+
* @returns {string}
|
|
514
|
+
*/
|
|
515
|
+
export function tokenAmountFromHuman(human, decimals) {
|
|
516
|
+
let deferred2_0;
|
|
517
|
+
let deferred2_1;
|
|
518
|
+
try {
|
|
519
|
+
const ret = wasm.tokenAmountFromHuman(human, decimals);
|
|
520
|
+
var ptr1 = ret[0];
|
|
521
|
+
var len1 = ret[1];
|
|
522
|
+
if (ret[3]) {
|
|
523
|
+
ptr1 = 0; len1 = 0;
|
|
524
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
525
|
+
}
|
|
526
|
+
deferred2_0 = ptr1;
|
|
527
|
+
deferred2_1 = len1;
|
|
528
|
+
return getStringFromWasm0(ptr1, len1);
|
|
529
|
+
} finally {
|
|
530
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Multiply a TokenAmount by basis points. Returns result as JSON.
|
|
536
|
+
* @param {string} json
|
|
537
|
+
* @param {bigint} bps
|
|
538
|
+
* @returns {string}
|
|
539
|
+
*/
|
|
540
|
+
export function tokenAmountMulBps(json, bps) {
|
|
541
|
+
let deferred3_0;
|
|
542
|
+
let deferred3_1;
|
|
543
|
+
try {
|
|
544
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
545
|
+
const len0 = WASM_VECTOR_LEN;
|
|
546
|
+
const ret = wasm.tokenAmountMulBps(ptr0, len0, bps);
|
|
547
|
+
var ptr2 = ret[0];
|
|
548
|
+
var len2 = ret[1];
|
|
549
|
+
if (ret[3]) {
|
|
550
|
+
ptr2 = 0; len2 = 0;
|
|
551
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
552
|
+
}
|
|
553
|
+
deferred3_0 = ptr2;
|
|
554
|
+
deferred3_1 = len2;
|
|
555
|
+
return getStringFromWasm0(ptr2, len2);
|
|
556
|
+
} finally {
|
|
557
|
+
wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Subtract two TokenAmount JSONs. Returns the difference as JSON.
|
|
563
|
+
* @param {string} a_json
|
|
564
|
+
* @param {string} b_json
|
|
565
|
+
* @returns {string}
|
|
566
|
+
*/
|
|
567
|
+
export function tokenAmountSub(a_json, b_json) {
|
|
568
|
+
let deferred4_0;
|
|
569
|
+
let deferred4_1;
|
|
570
|
+
try {
|
|
571
|
+
const ptr0 = passStringToWasm0(a_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
572
|
+
const len0 = WASM_VECTOR_LEN;
|
|
573
|
+
const ptr1 = passStringToWasm0(b_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
574
|
+
const len1 = WASM_VECTOR_LEN;
|
|
575
|
+
const ret = wasm.tokenAmountSub(ptr0, len0, ptr1, len1);
|
|
576
|
+
var ptr3 = ret[0];
|
|
577
|
+
var len3 = ret[1];
|
|
578
|
+
if (ret[3]) {
|
|
579
|
+
ptr3 = 0; len3 = 0;
|
|
580
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
581
|
+
}
|
|
582
|
+
deferred4_0 = ptr3;
|
|
583
|
+
deferred4_1 = len3;
|
|
584
|
+
return getStringFromWasm0(ptr3, len3);
|
|
585
|
+
} finally {
|
|
586
|
+
wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Convert a TokenAmount JSON back to a human-readable f64.
|
|
592
|
+
* @param {string} json
|
|
593
|
+
* @returns {number}
|
|
594
|
+
*/
|
|
595
|
+
export function tokenAmountToHuman(json) {
|
|
596
|
+
const ptr0 = passStringToWasm0(json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
597
|
+
const len0 = WASM_VECTOR_LEN;
|
|
598
|
+
const ret = wasm.tokenAmountToHuman(ptr0, len0);
|
|
599
|
+
if (ret[2]) {
|
|
600
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
601
|
+
}
|
|
602
|
+
return ret[0];
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* @param {Uint8Array} public_key
|
|
607
|
+
* @param {Uint8Array} message_hash
|
|
608
|
+
* @param {Uint8Array} signature
|
|
609
|
+
* @returns {boolean}
|
|
610
|
+
*/
|
|
611
|
+
export function verifyEcdsa(public_key, message_hash, signature) {
|
|
612
|
+
const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_malloc);
|
|
613
|
+
const len0 = WASM_VECTOR_LEN;
|
|
614
|
+
const ptr1 = passArray8ToWasm0(message_hash, wasm.__wbindgen_malloc);
|
|
615
|
+
const len1 = WASM_VECTOR_LEN;
|
|
616
|
+
const ptr2 = passArray8ToWasm0(signature, wasm.__wbindgen_malloc);
|
|
617
|
+
const len2 = WASM_VECTOR_LEN;
|
|
618
|
+
const ret = wasm.verifyEcdsa(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
619
|
+
if (ret[2]) {
|
|
620
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
621
|
+
}
|
|
622
|
+
return ret[0] !== 0;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function __wbg_get_imports() {
|
|
626
|
+
const import0 = {
|
|
627
|
+
__proto__: null,
|
|
628
|
+
__wbg_Error_7c536b7a8123d334: function(arg0, arg1) {
|
|
629
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
630
|
+
return ret;
|
|
631
|
+
},
|
|
632
|
+
__wbg___wbindgen_throw_bd5a70920abf0236: function(arg0, arg1) {
|
|
633
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
634
|
+
},
|
|
635
|
+
__wbg_getRandomValues_d49329ff89a07af1: function() { return handleError(function (arg0, arg1) {
|
|
636
|
+
globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
|
|
637
|
+
}, arguments); },
|
|
638
|
+
__wbg_getTime_60f8d1fb5b61be64: function(arg0) {
|
|
639
|
+
const ret = arg0.getTime();
|
|
640
|
+
return ret;
|
|
641
|
+
},
|
|
642
|
+
__wbg_new_0_1211b165db93342c: function() {
|
|
643
|
+
const ret = new Date();
|
|
644
|
+
return ret;
|
|
645
|
+
},
|
|
646
|
+
__wbindgen_init_externref_table: function() {
|
|
647
|
+
const table = wasm.__wbindgen_externrefs;
|
|
648
|
+
const offset = table.grow(4);
|
|
649
|
+
table.set(0, undefined);
|
|
650
|
+
table.set(offset + 0, undefined);
|
|
651
|
+
table.set(offset + 1, null);
|
|
652
|
+
table.set(offset + 2, true);
|
|
653
|
+
table.set(offset + 3, false);
|
|
654
|
+
},
|
|
655
|
+
};
|
|
656
|
+
return {
|
|
657
|
+
__proto__: null,
|
|
658
|
+
"./clawpowers_wasm_bg.js": import0,
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
const WasmCanonicalStoreFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
663
|
+
? { register: () => {}, unregister: () => {} }
|
|
664
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmcanonicalstore_free(ptr >>> 0, 1));
|
|
665
|
+
|
|
666
|
+
function addToExternrefTable0(obj) {
|
|
667
|
+
const idx = wasm.__externref_table_alloc();
|
|
668
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
669
|
+
return idx;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
673
|
+
ptr = ptr >>> 0;
|
|
674
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
function getStringFromWasm0(ptr, len) {
|
|
678
|
+
ptr = ptr >>> 0;
|
|
679
|
+
return decodeText(ptr, len);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
let cachedUint8ArrayMemory0 = null;
|
|
683
|
+
function getUint8ArrayMemory0() {
|
|
684
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
685
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
686
|
+
}
|
|
687
|
+
return cachedUint8ArrayMemory0;
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function handleError(f, args) {
|
|
691
|
+
try {
|
|
692
|
+
return f.apply(this, args);
|
|
693
|
+
} catch (e) {
|
|
694
|
+
const idx = addToExternrefTable0(e);
|
|
695
|
+
wasm.__wbindgen_exn_store(idx);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
function isLikeNone(x) {
|
|
700
|
+
return x === undefined || x === null;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
704
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
705
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
706
|
+
WASM_VECTOR_LEN = arg.length;
|
|
707
|
+
return ptr;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
711
|
+
if (realloc === undefined) {
|
|
712
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
713
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
714
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
715
|
+
WASM_VECTOR_LEN = buf.length;
|
|
716
|
+
return ptr;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
let len = arg.length;
|
|
720
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
721
|
+
|
|
722
|
+
const mem = getUint8ArrayMemory0();
|
|
723
|
+
|
|
724
|
+
let offset = 0;
|
|
725
|
+
|
|
726
|
+
for (; offset < len; offset++) {
|
|
727
|
+
const code = arg.charCodeAt(offset);
|
|
728
|
+
if (code > 0x7F) break;
|
|
729
|
+
mem[ptr + offset] = code;
|
|
730
|
+
}
|
|
731
|
+
if (offset !== len) {
|
|
732
|
+
if (offset !== 0) {
|
|
733
|
+
arg = arg.slice(offset);
|
|
734
|
+
}
|
|
735
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
736
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
737
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
738
|
+
|
|
739
|
+
offset += ret.written;
|
|
740
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
WASM_VECTOR_LEN = offset;
|
|
744
|
+
return ptr;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function takeFromExternrefTable0(idx) {
|
|
748
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
749
|
+
wasm.__externref_table_dealloc(idx);
|
|
750
|
+
return value;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
754
|
+
cachedTextDecoder.decode();
|
|
755
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
756
|
+
let numBytesDecoded = 0;
|
|
757
|
+
function decodeText(ptr, len) {
|
|
758
|
+
numBytesDecoded += len;
|
|
759
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
760
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
761
|
+
cachedTextDecoder.decode();
|
|
762
|
+
numBytesDecoded = len;
|
|
763
|
+
}
|
|
764
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
const cachedTextEncoder = new TextEncoder();
|
|
768
|
+
|
|
769
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
770
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
771
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
772
|
+
view.set(buf);
|
|
773
|
+
return {
|
|
774
|
+
read: arg.length,
|
|
775
|
+
written: buf.length
|
|
776
|
+
};
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
let WASM_VECTOR_LEN = 0;
|
|
781
|
+
|
|
782
|
+
let wasmModule, wasm;
|
|
783
|
+
function __wbg_finalize_init(instance, module) {
|
|
784
|
+
wasm = instance.exports;
|
|
785
|
+
wasmModule = module;
|
|
786
|
+
cachedUint8ArrayMemory0 = null;
|
|
787
|
+
wasm.__wbindgen_start();
|
|
788
|
+
return wasm;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
async function __wbg_load(module, imports) {
|
|
792
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
793
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
794
|
+
try {
|
|
795
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
796
|
+
} catch (e) {
|
|
797
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
798
|
+
|
|
799
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
800
|
+
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);
|
|
801
|
+
|
|
802
|
+
} else { throw e; }
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
const bytes = await module.arrayBuffer();
|
|
807
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
808
|
+
} else {
|
|
809
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
810
|
+
|
|
811
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
812
|
+
return { instance, module };
|
|
813
|
+
} else {
|
|
814
|
+
return instance;
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
function expectedResponseType(type) {
|
|
819
|
+
switch (type) {
|
|
820
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
821
|
+
}
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
function initSync(module) {
|
|
827
|
+
if (wasm !== undefined) return wasm;
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
if (module !== undefined) {
|
|
831
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
832
|
+
({module} = module)
|
|
833
|
+
} else {
|
|
834
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
const imports = __wbg_get_imports();
|
|
839
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
840
|
+
module = new WebAssembly.Module(module);
|
|
841
|
+
}
|
|
842
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
843
|
+
return __wbg_finalize_init(instance, module);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
async function __wbg_init(module_or_path) {
|
|
847
|
+
if (wasm !== undefined) return wasm;
|
|
848
|
+
|
|
849
|
+
|
|
850
|
+
if (module_or_path !== undefined) {
|
|
851
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
852
|
+
({module_or_path} = module_or_path)
|
|
853
|
+
} else {
|
|
854
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (module_or_path === undefined) {
|
|
859
|
+
module_or_path = new URL('clawpowers_wasm_bg.wasm', import.meta.url);
|
|
860
|
+
}
|
|
861
|
+
const imports = __wbg_get_imports();
|
|
862
|
+
|
|
863
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
864
|
+
module_or_path = fetch(module_or_path);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
868
|
+
|
|
869
|
+
return __wbg_finalize_init(instance, module);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
export { initSync, __wbg_init as default };
|