@open-artifact/wasm-sheets 0.10.0 → 0.12.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.
|
@@ -12,6 +12,11 @@ export class WorkbookSession {
|
|
|
12
12
|
* A request about this workbook, as JSON; its answer, as JSON.
|
|
13
13
|
*/
|
|
14
14
|
answerJson(request: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* A request about this workbook, as JSON; its answer, as JSON, with a packed read's cell blocks sent to `sink`
|
|
17
|
+
* in index order.
|
|
18
|
+
*/
|
|
19
|
+
answerWithCells(request: string, sink: any): string;
|
|
15
20
|
constructor();
|
|
16
21
|
}
|
|
17
22
|
|
|
@@ -36,6 +41,7 @@ export interface InitOutput {
|
|
|
36
41
|
readonly functionDescriptionsJson: () => [number, number];
|
|
37
42
|
readonly start: () => void;
|
|
38
43
|
readonly workbooksession_answerJson: (a: number, b: number, c: number) => [number, number];
|
|
44
|
+
readonly workbooksession_answerWithCells: (a: number, b: number, c: number, d: any) => [number, number];
|
|
39
45
|
readonly workbooksession_new: () => number;
|
|
40
46
|
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
41
47
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
@@ -32,6 +32,27 @@ export class WorkbookSession {
|
|
|
32
32
|
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* A request about this workbook, as JSON; its answer, as JSON, with a packed read's cell blocks sent to `sink`
|
|
37
|
+
* in index order.
|
|
38
|
+
* @param {string} request
|
|
39
|
+
* @param {any} sink
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
answerWithCells(request, sink) {
|
|
43
|
+
let deferred2_0;
|
|
44
|
+
let deferred2_1;
|
|
45
|
+
try {
|
|
46
|
+
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
47
|
+
const len0 = WASM_VECTOR_LEN;
|
|
48
|
+
const ret = wasm.workbooksession_answerWithCells(this.__wbg_ptr, ptr0, len0, sink);
|
|
49
|
+
deferred2_0 = ret[0];
|
|
50
|
+
deferred2_1 = ret[1];
|
|
51
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
52
|
+
} finally {
|
|
53
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
35
56
|
constructor() {
|
|
36
57
|
const ret = wasm.workbooksession_new();
|
|
37
58
|
this.__wbg_ptr = ret >>> 0;
|
|
@@ -95,6 +116,9 @@ function __wbg_get_imports() {
|
|
|
95
116
|
const ret = performance.now();
|
|
96
117
|
return ret;
|
|
97
118
|
},
|
|
119
|
+
__wbg_take_ef05fcde3118d089: function(arg0, arg1, arg2, arg3, arg4) {
|
|
120
|
+
arg0.take(getArrayU8FromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
121
|
+
},
|
|
98
122
|
__wbindgen_init_externref_table: function() {
|
|
99
123
|
const table = wasm.__wbindgen_externrefs;
|
|
100
124
|
const offset = table.grow(4);
|
|
@@ -115,6 +139,11 @@ const WorkbookSessionFinalization = (typeof FinalizationRegistry === 'undefined'
|
|
|
115
139
|
? { register: () => {}, unregister: () => {} }
|
|
116
140
|
: new FinalizationRegistry(ptr => wasm.__wbg_workbooksession_free(ptr >>> 0, 1));
|
|
117
141
|
|
|
142
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
143
|
+
ptr = ptr >>> 0;
|
|
144
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
145
|
+
}
|
|
146
|
+
|
|
118
147
|
function getStringFromWasm0(ptr, len) {
|
|
119
148
|
ptr = ptr >>> 0;
|
|
120
149
|
return decodeText(ptr, len);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-artifact/wasm-sheets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "The Sheets workbook engine compiled from crates/open-artifact-sheets to WebAssembly (generated/, built by scripts/build-wasm.mjs). The module is a file of its own: pages fetch it in their worker, Node reads it from disk.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
package/src/index.d.ts
CHANGED
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
* crosses as JSON text: a request goes in, its answer comes out. Instantiate
|
|
4
4
|
* once with the module's bytes (or a compiled module), then make sessions.
|
|
5
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* One block of cells from a packed read: little-endian lists of numbers and the block's texts, which the lists
|
|
8
|
+
* point into. An answer names its blocks by the order they came in, from 0.
|
|
9
|
+
*/
|
|
10
|
+
export interface PackedCellBlock {
|
|
11
|
+
lists: Uint8Array;
|
|
12
|
+
texts: string;
|
|
13
|
+
}
|
|
6
14
|
/** One workbook and every request about it. */
|
|
7
15
|
export interface EngineSession {
|
|
8
16
|
/** A request about this workbook, as JSON text; its answer, as JSON text. */
|
|
9
17
|
answerJson(request: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* The same, for a request whose answer may carry cells in blocks (`readWorkbookWithCellsPacked`,
|
|
20
|
+
* `readRowsWithCellsPacked`): each block goes to `take` before the answer comes back.
|
|
21
|
+
*/
|
|
22
|
+
answerWithCells(request: string, take: (block: PackedCellBlock) => void): string;
|
|
10
23
|
/** Frees the workbook; the session cannot be used afterwards. */
|
|
11
24
|
free(): void;
|
|
12
25
|
}
|
package/src/index.js
CHANGED
|
@@ -9,7 +9,12 @@ function engineOf() {
|
|
|
9
9
|
return {
|
|
10
10
|
session: () => {
|
|
11
11
|
const session = new glue.WorkbookSession();
|
|
12
|
-
return {
|
|
12
|
+
return {
|
|
13
|
+
answerJson: (request) => session.answerJson(request),
|
|
14
|
+
// The lists arrive as a view of the module's memory, which the next call may move: keep a copy.
|
|
15
|
+
answerWithCells: (request, take) => session.answerWithCells(request, { take: (lists, texts) => take({ lists: lists.slice(), texts }) }),
|
|
16
|
+
free: () => session.free(),
|
|
17
|
+
};
|
|
13
18
|
},
|
|
14
19
|
utilityJson: (request) => glue.answerUtilityRequestJson(request),
|
|
15
20
|
functionDescriptionsJson: () => glue.functionDescriptionsJson(),
|
package/src/node.d.ts
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* itself); unbundled, it is read from `generated/`.
|
|
5
5
|
*/
|
|
6
6
|
import { type SheetsEngine } from './index.ts';
|
|
7
|
-
export type { EngineSession, SheetsEngine } from './index.ts';
|
|
7
|
+
export type { EngineSession, PackedCellBlock, SheetsEngine } from './index.ts';
|
|
8
8
|
/** The engine, instantiated on first use. */
|
|
9
9
|
export declare function sheetsEngine(): SheetsEngine;
|