@ownables/platform-node 0.3.0 → 0.5.1
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/README.md +30 -0
- package/dist/core/src/index.d.ts +2 -0
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/index.js +2 -0
- package/dist/core/src/index.js.map +1 -1
- package/dist/core/src/interfaces/core.d.ts +5 -1
- package/dist/core/src/interfaces/core.d.ts.map +1 -1
- package/dist/core/src/ownableErrorMessage.d.ts +2 -0
- package/dist/core/src/ownableErrorMessage.d.ts.map +1 -0
- package/dist/core/src/ownableErrorMessage.js +20 -0
- package/dist/core/src/ownableErrorMessage.js.map +1 -0
- package/dist/core/src/services/EventChain.service.d.ts +2 -0
- package/dist/core/src/services/EventChain.service.d.ts.map +1 -1
- package/dist/core/src/services/EventChain.service.js +2 -1
- package/dist/core/src/services/EventChain.service.js.map +1 -1
- package/dist/core/src/services/Ownable.service.d.ts +7 -3
- package/dist/core/src/services/Ownable.service.d.ts.map +1 -1
- package/dist/core/src/services/Ownable.service.js +28 -18
- package/dist/core/src/services/Ownable.service.js.map +1 -1
- package/dist/core/src/services/Polling.service.js +1 -1
- package/dist/core/src/services/Polling.service.js.map +1 -1
- package/dist/core/src/services/WorkerRPC.service.d.ts +37 -0
- package/dist/core/src/services/WorkerRPC.service.d.ts.map +1 -0
- package/dist/core/src/services/WorkerRPC.service.js +219 -0
- package/dist/core/src/services/WorkerRPC.service.js.map +1 -0
- package/dist/core/src/services/workerSource.d.ts +2 -0
- package/dist/core/src/services/workerSource.d.ts.map +1 -0
- package/dist/core/src/services/workerSource.js +72 -0
- package/dist/core/src/services/workerSource.js.map +1 -0
- package/dist/core/src/types/EventChainStore.d.ts +1 -0
- package/dist/core/src/types/EventChainStore.d.ts.map +1 -1
- package/dist/core/src/types/OwnableRuntime.d.ts +3 -1
- package/dist/core/src/types/OwnableRuntime.d.ts.map +1 -1
- package/dist/core/src/types/TypedPackage.d.ts +3 -0
- package/dist/core/src/types/TypedPackage.d.ts.map +1 -1
- package/dist/platform-node/src/services/NodeSandboxOwnableRPC.service.d.ts +15 -12
- package/dist/platform-node/src/services/NodeSandboxOwnableRPC.service.d.ts.map +1 -1
- package/dist/platform-node/src/services/NodeSandboxOwnableRPC.service.js +114 -131
- package/dist/platform-node/src/services/NodeSandboxOwnableRPC.service.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { decode, encode } from 'cbor-x';
|
|
2
|
+
export default class WorkerRPC {
|
|
3
|
+
worker;
|
|
4
|
+
ownableId;
|
|
5
|
+
widgetWindow = null;
|
|
6
|
+
_queue = Promise.resolve();
|
|
7
|
+
constructor(id) {
|
|
8
|
+
this.ownableId = id;
|
|
9
|
+
}
|
|
10
|
+
wrapWorkerError(context, err) {
|
|
11
|
+
if (err instanceof Error)
|
|
12
|
+
return err;
|
|
13
|
+
if (typeof ErrorEvent !== 'undefined' && err instanceof ErrorEvent) {
|
|
14
|
+
const parts = [
|
|
15
|
+
context,
|
|
16
|
+
err.message || 'worker script error',
|
|
17
|
+
err.filename ? `at ${err.filename}:${err.lineno}:${err.colno}` : '',
|
|
18
|
+
].filter(Boolean);
|
|
19
|
+
const wrapped = new Error(parts.join(' '));
|
|
20
|
+
wrapped.cause = err;
|
|
21
|
+
return wrapped;
|
|
22
|
+
}
|
|
23
|
+
if (typeof MessageEvent !== 'undefined' && err instanceof MessageEvent) {
|
|
24
|
+
const wrapped = new Error(`${context}: worker message deserialization error`);
|
|
25
|
+
wrapped.cause = err;
|
|
26
|
+
return wrapped;
|
|
27
|
+
}
|
|
28
|
+
if (err instanceof Event) {
|
|
29
|
+
const eventLike = err;
|
|
30
|
+
const details = [
|
|
31
|
+
eventLike?.message,
|
|
32
|
+
eventLike?.filename
|
|
33
|
+
? `at ${eventLike.filename}:${eventLike.lineno ?? '?'}:${eventLike.colno ?? '?'}`
|
|
34
|
+
: '',
|
|
35
|
+
]
|
|
36
|
+
.filter((v) => typeof v === 'string' && v.trim() !== '')
|
|
37
|
+
.join(' ');
|
|
38
|
+
const wrapped = new Error(`${context}: worker emitted ${err.type} event${details ? ` (${details})` : ''}`);
|
|
39
|
+
wrapped.cause = err;
|
|
40
|
+
return wrapped;
|
|
41
|
+
}
|
|
42
|
+
const wrapped = new Error(`${context}: ${String(err)}`);
|
|
43
|
+
wrapped.cause = err;
|
|
44
|
+
return wrapped;
|
|
45
|
+
}
|
|
46
|
+
async initialize(js, wasm) {
|
|
47
|
+
return await new Promise((resolve, reject) => {
|
|
48
|
+
const blob = new Blob([js], { type: 'application/javascript' });
|
|
49
|
+
const blobURL = URL.createObjectURL(blob);
|
|
50
|
+
this.worker = new Worker(blobURL, { type: 'module' });
|
|
51
|
+
let settled = false;
|
|
52
|
+
const onMessage = (event) => {
|
|
53
|
+
if (settled)
|
|
54
|
+
return;
|
|
55
|
+
settled = true;
|
|
56
|
+
cleanup();
|
|
57
|
+
if (event.data?.err) {
|
|
58
|
+
const raw = event.data.err;
|
|
59
|
+
if (raw.includes('__wbindgen_placeholder__')) {
|
|
60
|
+
reject(new Error('Ownable package is incompatible with this runtime (wasm-bindgen imports detected). Rebuild and re-import the package with Host ABI v1.'));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
reject(new Error(`Ownable worker init failed: ${raw}`));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (event.data?.success) {
|
|
67
|
+
resolve();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
reject(new Error('Ownable worker init failed: invalid init response'));
|
|
71
|
+
};
|
|
72
|
+
const onError = (event) => {
|
|
73
|
+
if (settled)
|
|
74
|
+
return;
|
|
75
|
+
settled = true;
|
|
76
|
+
cleanup();
|
|
77
|
+
reject(this.wrapWorkerError('Ownable worker init failed', event));
|
|
78
|
+
};
|
|
79
|
+
const onMessageError = (event) => {
|
|
80
|
+
if (settled)
|
|
81
|
+
return;
|
|
82
|
+
settled = true;
|
|
83
|
+
cleanup();
|
|
84
|
+
reject(this.wrapWorkerError('Ownable worker init failed', event));
|
|
85
|
+
};
|
|
86
|
+
const cleanup = () => {
|
|
87
|
+
URL.revokeObjectURL(blobURL);
|
|
88
|
+
this.worker.removeEventListener('message', onMessage);
|
|
89
|
+
this.worker.removeEventListener('error', onError);
|
|
90
|
+
this.worker.removeEventListener('messageerror', onMessageError);
|
|
91
|
+
};
|
|
92
|
+
this.worker.addEventListener('message', onMessage);
|
|
93
|
+
this.worker.addEventListener('error', onError);
|
|
94
|
+
this.worker.addEventListener('messageerror', onMessageError);
|
|
95
|
+
this.worker.postMessage({ type: 'init', wasm });
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
setWidgetWindow(win) {
|
|
99
|
+
this.widgetWindow = win ?? null;
|
|
100
|
+
}
|
|
101
|
+
terminate() {
|
|
102
|
+
this.worker?.terminate();
|
|
103
|
+
}
|
|
104
|
+
attributesToDict(attributes) {
|
|
105
|
+
return Object.fromEntries(attributes.map((a) => [a.key, a.value]));
|
|
106
|
+
}
|
|
107
|
+
decodeEnvelope(output) {
|
|
108
|
+
const envelope = decode(output instanceof Uint8Array ? output : new Uint8Array(output));
|
|
109
|
+
if (!envelope.success) {
|
|
110
|
+
throw new Error(`Ownable ABI call failed: ${envelope.error_code || 'UNKNOWN'} ${envelope.error_message || ''}`.trim());
|
|
111
|
+
}
|
|
112
|
+
const payload = envelope.payload ?? new Uint8Array();
|
|
113
|
+
return decode(payload);
|
|
114
|
+
}
|
|
115
|
+
workerCall(type, request, state) {
|
|
116
|
+
const call = () => new Promise((resolve, reject) => {
|
|
117
|
+
if (!this.worker) {
|
|
118
|
+
reject(new Error(`Unable to ${type}: not initialized`));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let settled = false;
|
|
122
|
+
const onMessage = (event) => {
|
|
123
|
+
if (settled)
|
|
124
|
+
return;
|
|
125
|
+
settled = true;
|
|
126
|
+
cleanup();
|
|
127
|
+
if (event.data?.err) {
|
|
128
|
+
reject(new Error(`Ownable ${type} failed: ${event.data.err}`));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (!event.data?.output) {
|
|
132
|
+
reject(new Error(`Ownable ${type} failed: empty worker output`));
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
try {
|
|
136
|
+
const decoded = this.decodeEnvelope(event.data.output);
|
|
137
|
+
const nextState = decoded.mem?.state_dump ?? state;
|
|
138
|
+
resolve({ response: decoded.result, state: nextState || [] });
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const onError = (event) => {
|
|
145
|
+
if (settled)
|
|
146
|
+
return;
|
|
147
|
+
settled = true;
|
|
148
|
+
cleanup();
|
|
149
|
+
reject(this.wrapWorkerError(`Ownable ${type} failed`, event));
|
|
150
|
+
};
|
|
151
|
+
const onMessageError = (event) => {
|
|
152
|
+
if (settled)
|
|
153
|
+
return;
|
|
154
|
+
settled = true;
|
|
155
|
+
cleanup();
|
|
156
|
+
reject(this.wrapWorkerError(`Ownable ${type} failed`, event));
|
|
157
|
+
};
|
|
158
|
+
const cleanup = () => {
|
|
159
|
+
this.worker.removeEventListener('message', onMessage);
|
|
160
|
+
this.worker.removeEventListener('error', onError);
|
|
161
|
+
this.worker.removeEventListener('messageerror', onMessageError);
|
|
162
|
+
};
|
|
163
|
+
this.worker.addEventListener('message', onMessage);
|
|
164
|
+
this.worker.addEventListener('error', onError);
|
|
165
|
+
this.worker.addEventListener('messageerror', onMessageError);
|
|
166
|
+
const input = encode(request);
|
|
167
|
+
this.worker.postMessage({ type, input });
|
|
168
|
+
});
|
|
169
|
+
const next = this._queue.then(call, call);
|
|
170
|
+
this._queue = next.catch(() => { });
|
|
171
|
+
return next;
|
|
172
|
+
}
|
|
173
|
+
async instantiate(msg, info) {
|
|
174
|
+
const { response, state } = await this.workerCall('instantiate', { msg, info });
|
|
175
|
+
const parsed = decode(response);
|
|
176
|
+
return {
|
|
177
|
+
attributes: this.attributesToDict(parsed.attributes),
|
|
178
|
+
state,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
async execute(msg, info, state) {
|
|
182
|
+
const { response, state: newState } = await this.workerCall('execute', { msg, info, mem: { state_dump: state } }, state);
|
|
183
|
+
return this.toExecuteResult(decode(response), newState);
|
|
184
|
+
}
|
|
185
|
+
async externalEvent(msg, info, state) {
|
|
186
|
+
const { response, state: newState } = await this.workerCall('external_event', {
|
|
187
|
+
msg: msg.msg,
|
|
188
|
+
info,
|
|
189
|
+
ownable_id: this.ownableId,
|
|
190
|
+
mem: { state_dump: state },
|
|
191
|
+
}, state);
|
|
192
|
+
return this.toExecuteResult(decode(response), newState);
|
|
193
|
+
}
|
|
194
|
+
toExecuteResult(response, state) {
|
|
195
|
+
return {
|
|
196
|
+
attributes: this.attributesToDict(response.attributes),
|
|
197
|
+
events: (response.events || []).map((e) => ({
|
|
198
|
+
type: e.type,
|
|
199
|
+
attributes: this.attributesToDict(e.attributes),
|
|
200
|
+
})),
|
|
201
|
+
data: response.data ?? '',
|
|
202
|
+
state,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
async queryRaw(msg, state) {
|
|
206
|
+
return (await this.workerCall('query', { msg, mem: { state_dump: state } }, state)).response;
|
|
207
|
+
}
|
|
208
|
+
async query(msg, state) {
|
|
209
|
+
const bytes = await this.queryRaw(msg, state);
|
|
210
|
+
return JSON.parse(new TextDecoder().decode(bytes));
|
|
211
|
+
}
|
|
212
|
+
async refresh(state) {
|
|
213
|
+
if (!this.widgetWindow)
|
|
214
|
+
return;
|
|
215
|
+
const widgetState = await this.query({ get_widget_state: {} }, state);
|
|
216
|
+
this.widgetWindow.postMessage({ ownable_id: this.ownableId, state: widgetState }, '*');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=WorkerRPC.service.js.map
|
|
@@ -0,0 +1 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AAM,KAAK,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAgB;QAC5B,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,OAAO;QAC/B,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE,gBAAgB,EAAE,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;QACtE,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,CAAC;IACzF,CAAC;CACF"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const DEFAULT_WORKER_SOURCE = "let wasm;\nlet exportsRef;\nlet memory;\n\nfunction toU8Array(value) {\n if (value instanceof Uint8Array) return value;\n if (value instanceof ArrayBuffer) return new Uint8Array(value);\n if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n throw new Error(\"invalid wasm payload: expected ArrayBuffer or TypedArray\");\n}\n\nfunction unpackPtrLen(packed) {\n const value = typeof packed === \"bigint\" ? packed : BigInt(packed);\n const ptr = Number(value & 0xffffffffn);\n const len = Number((value >> 32n) & 0xffffffffn);\n return { ptr, len };\n}\n\nfunction invoke(type, inputBytes) {\n if (!exportsRef || !memory) throw new Error(\"WASM not initialized\");\n\n const len = inputBytes.length >>> 0;\n const inPtr = exportsRef.ownable_alloc(len);\n if (len > 0) new Uint8Array(memory.buffer, inPtr, len).set(inputBytes);\n\n let packed;\n try {\n switch (type) {\n case \"instantiate\": packed = exportsRef.ownable_instantiate(inPtr, len); break;\n case \"execute\": packed = exportsRef.ownable_execute(inPtr, len); break;\n case \"query\": packed = exportsRef.ownable_query(inPtr, len); break;\n case \"external_event\": packed = exportsRef.ownable_external_event(inPtr, len); break;\n default: throw new Error(`unknown message type ${type}`);\n }\n } finally {\n exportsRef.ownable_free(inPtr, len);\n }\n\n const { ptr: outPtr, len: outLen } = unpackPtrLen(packed);\n const output = outLen > 0\n ? new Uint8Array(new Uint8Array(memory.buffer, outPtr, outLen))\n : new Uint8Array();\n if (outLen > 0) exportsRef.ownable_free(outPtr, outLen);\n return output;\n}\n\naddEventListener(\"message\", async (e) => {\n try {\n const { type: messageType } = e.data || {};\n\n if (messageType === \"init\") {\n const wasmBytes = toU8Array(e.data.wasm);\n const { instance } = await WebAssembly.instantiate(wasmBytes, {});\n wasm = instance;\n exportsRef = wasm.exports;\n memory = exportsRef.memory;\n self.postMessage({ success: true, msg: \"WASM instantiated successfully\" });\n return;\n }\n\n if (!wasm) throw new Error(\"WASM not initialized\");\n\n const { type, input } = e.data;\n const inBytes = new Uint8Array(input || new ArrayBuffer(0));\n const output = invoke(type, inBytes);\n self.postMessage({ output }, [output.buffer]);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n self.postMessage({ err: message });\n }\n});";
|
|
2
|
+
//# sourceMappingURL=workerSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerSource.d.ts","sourceRoot":"","sources":["../../../../../core/src/services/workerSource.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,2/EAsE9B,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const DEFAULT_WORKER_SOURCE = `let wasm;
|
|
2
|
+
let exportsRef;
|
|
3
|
+
let memory;
|
|
4
|
+
|
|
5
|
+
function toU8Array(value) {
|
|
6
|
+
if (value instanceof Uint8Array) return value;
|
|
7
|
+
if (value instanceof ArrayBuffer) return new Uint8Array(value);
|
|
8
|
+
if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
9
|
+
throw new Error("invalid wasm payload: expected ArrayBuffer or TypedArray");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function unpackPtrLen(packed) {
|
|
13
|
+
const value = typeof packed === "bigint" ? packed : BigInt(packed);
|
|
14
|
+
const ptr = Number(value & 0xffffffffn);
|
|
15
|
+
const len = Number((value >> 32n) & 0xffffffffn);
|
|
16
|
+
return { ptr, len };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function invoke(type, inputBytes) {
|
|
20
|
+
if (!exportsRef || !memory) throw new Error("WASM not initialized");
|
|
21
|
+
|
|
22
|
+
const len = inputBytes.length >>> 0;
|
|
23
|
+
const inPtr = exportsRef.ownable_alloc(len);
|
|
24
|
+
if (len > 0) new Uint8Array(memory.buffer, inPtr, len).set(inputBytes);
|
|
25
|
+
|
|
26
|
+
let packed;
|
|
27
|
+
try {
|
|
28
|
+
switch (type) {
|
|
29
|
+
case "instantiate": packed = exportsRef.ownable_instantiate(inPtr, len); break;
|
|
30
|
+
case "execute": packed = exportsRef.ownable_execute(inPtr, len); break;
|
|
31
|
+
case "query": packed = exportsRef.ownable_query(inPtr, len); break;
|
|
32
|
+
case "external_event": packed = exportsRef.ownable_external_event(inPtr, len); break;
|
|
33
|
+
default: throw new Error(\`unknown message type \${type}\`);
|
|
34
|
+
}
|
|
35
|
+
} finally {
|
|
36
|
+
exportsRef.ownable_free(inPtr, len);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const { ptr: outPtr, len: outLen } = unpackPtrLen(packed);
|
|
40
|
+
const output = outLen > 0
|
|
41
|
+
? new Uint8Array(new Uint8Array(memory.buffer, outPtr, outLen))
|
|
42
|
+
: new Uint8Array();
|
|
43
|
+
if (outLen > 0) exportsRef.ownable_free(outPtr, outLen);
|
|
44
|
+
return output;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
addEventListener("message", async (e) => {
|
|
48
|
+
try {
|
|
49
|
+
const { type: messageType } = e.data || {};
|
|
50
|
+
|
|
51
|
+
if (messageType === "init") {
|
|
52
|
+
const wasmBytes = toU8Array(e.data.wasm);
|
|
53
|
+
const { instance } = await WebAssembly.instantiate(wasmBytes, {});
|
|
54
|
+
wasm = instance;
|
|
55
|
+
exportsRef = wasm.exports;
|
|
56
|
+
memory = exportsRef.memory;
|
|
57
|
+
self.postMessage({ success: true, msg: "WASM instantiated successfully" });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!wasm) throw new Error("WASM not initialized");
|
|
62
|
+
|
|
63
|
+
const { type, input } = e.data;
|
|
64
|
+
const inBytes = new Uint8Array(input || new ArrayBuffer(0));
|
|
65
|
+
const output = invoke(type, inBytes);
|
|
66
|
+
self.postMessage({ output }, [output.buffer]);
|
|
67
|
+
} catch (err) {
|
|
68
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
69
|
+
self.postMessage({ err: message });
|
|
70
|
+
}
|
|
71
|
+
});`;
|
|
72
|
+
//# sourceMappingURL=workerSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workerSource.js","sourceRoot":"","sources":["../../../../../core/src/services/workerSource.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsEjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventChainStore.d.ts","sourceRoot":"","sources":["../../../../../core/src/types/EventChainStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
1
|
+
{"version":3,"file":"EventChainStore.d.ts","sourceRoot":"","sources":["../../../../../core/src/types/EventChainStore.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,IAAI,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
|
|
@@ -9,7 +9,7 @@ export interface CosmWasmEvent {
|
|
|
9
9
|
attributes: TypedDict<string>;
|
|
10
10
|
}
|
|
11
11
|
export interface OwnableRPC {
|
|
12
|
-
|
|
12
|
+
initialize: (js: string, wasm: Uint8Array) => Promise<void>;
|
|
13
13
|
instantiate: (msg: TypedDict, info: CosmWasmMessageInfo) => Promise<{
|
|
14
14
|
attributes: TypedDict<string>;
|
|
15
15
|
state: StateDump;
|
|
@@ -28,6 +28,8 @@ export interface OwnableRPC {
|
|
|
28
28
|
}>;
|
|
29
29
|
query: (msg: TypedDict, state: StateDump) => Promise<any>;
|
|
30
30
|
refresh: (state: StateDump) => Promise<void>;
|
|
31
|
+
terminate: () => void;
|
|
32
|
+
setWidgetWindow: (win: unknown | null) => void;
|
|
31
33
|
}
|
|
32
34
|
export interface StateSnapshot {
|
|
33
35
|
eventIndex: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OwnableRuntime.d.ts","sourceRoot":"","sources":["../../../../../core/src/types/OwnableRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,KAAK,CAAC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,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,IAAI,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,iBAAiB,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACzE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import type { CosmWasmEvent, CosmWasmMessageInfo, OwnableRPC, StateDump } from '@ownables/core';
|
|
2
2
|
import type TypedDict from '@ownables/core/types/TypedDict';
|
|
3
|
-
import type { NodeSandboxOptions } from '../types/PlatformNode';
|
|
4
3
|
export default class NodeSandboxOwnableRPC implements OwnableRPC {
|
|
5
4
|
private ownableId;
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
private
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
private
|
|
12
|
-
private
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
private exportsRef;
|
|
6
|
+
private memory;
|
|
7
|
+
private widgetWindow;
|
|
8
|
+
private _queue;
|
|
9
|
+
constructor(id?: string);
|
|
10
|
+
private unpackPtrLen;
|
|
11
|
+
private ensureInitialized;
|
|
12
|
+
initialize(_js: string, wasm: Uint8Array): Promise<void>;
|
|
13
|
+
setWidgetWindow(win: unknown | null): void;
|
|
14
|
+
terminate(): void;
|
|
15
|
+
private invoke;
|
|
16
|
+
private decodeEnvelope;
|
|
17
|
+
private workerCall;
|
|
18
|
+
private attributesToDict;
|
|
16
19
|
instantiate(msg: TypedDict, info: CosmWasmMessageInfo): Promise<{
|
|
17
20
|
attributes: TypedDict<string>;
|
|
18
21
|
state: StateDump;
|
|
19
22
|
}>;
|
|
23
|
+
private toExecuteResult;
|
|
20
24
|
execute(msg: TypedDict, info: CosmWasmMessageInfo, state: StateDump): Promise<{
|
|
21
25
|
attributes: TypedDict<string>;
|
|
22
26
|
events: Array<CosmWasmEvent>;
|
|
@@ -29,7 +33,6 @@ export default class NodeSandboxOwnableRPC implements OwnableRPC {
|
|
|
29
33
|
data: string;
|
|
30
34
|
state: StateDump;
|
|
31
35
|
}>;
|
|
32
|
-
private queryRaw;
|
|
33
36
|
query(msg: TypedDict, state: StateDump): Promise<unknown>;
|
|
34
37
|
refresh(_state: StateDump): Promise<void>;
|
|
35
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeSandboxOwnableRPC.service.d.ts","sourceRoot":"","sources":["../../../../src/services/NodeSandboxOwnableRPC.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NodeSandboxOwnableRPC.service.d.ts","sourceRoot":"","sources":["../../../../src/services/NodeSandboxOwnableRPC.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,KAAK,SAAS,MAAM,gCAAgC,CAAC;AA8B5D,MAAM,CAAC,OAAO,OAAO,qBAAsB,YAAW,UAAU;IAC9D,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,MAAM,CAAmC;IACjD,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,MAAM,CAAmC;gBAErC,EAAE,SAAK;IAInB,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,iBAAiB;IAOnB,U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