@open-artifact/wasm-sheets 0.0.0-stage → 0.9.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +5 -2
- package/generated/open_artifact_sheets.d.ts +67 -0
- package/generated/open_artifact_sheets.js +285 -0
- package/generated/open_artifact_sheets_bg.wasm +0 -0
- package/package.json +42 -4
- package/src/index.d.ts +25 -0
- package/src/index.js +33 -0
- package/src/module-url.d.ts +2 -0
- package/src/module-url.js +2 -0
- package/src/node.d.ts +9 -0
- package/src/node.js +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @open-artifact/wasm-sheets
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
Part of [Open Artifact](https://github.com/JimLiu/open-artifact): slide decks, design canvases and whiteboards an agent makes
|
|
6
|
+
and you view, edit and comment on in one local page. Source: [`packages/wasm-sheets`](https://github.com/JimLiu/open-artifact/tree/main/packages/wasm-sheets).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Generated by scripts/build-wasm.mjs from crates/open-artifact-sheets. Do not edit.
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One workbook, as the page's worker holds it.
|
|
7
|
+
*/
|
|
8
|
+
export class WorkbookSession {
|
|
9
|
+
free(): void;
|
|
10
|
+
[Symbol.dispose](): void;
|
|
11
|
+
/**
|
|
12
|
+
* A request about this workbook, as JSON; its answer, as JSON.
|
|
13
|
+
*/
|
|
14
|
+
answerJson(request: string): string;
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A request that needs no workbook, as JSON; its answer, as JSON.
|
|
20
|
+
*/
|
|
21
|
+
export function answerUtilityRequestJson(request: string): string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Every function a formula may call, with its family, its arguments and what it answers.
|
|
25
|
+
*/
|
|
26
|
+
export function functionDescriptionsJson(): string;
|
|
27
|
+
|
|
28
|
+
export function start(): void;
|
|
29
|
+
|
|
30
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
31
|
+
|
|
32
|
+
export interface InitOutput {
|
|
33
|
+
readonly memory: WebAssembly.Memory;
|
|
34
|
+
readonly __wbg_workbooksession_free: (a: number, b: number) => void;
|
|
35
|
+
readonly answerUtilityRequestJson: (a: number, b: number) => [number, number];
|
|
36
|
+
readonly functionDescriptionsJson: () => [number, number];
|
|
37
|
+
readonly start: () => void;
|
|
38
|
+
readonly workbooksession_answerJson: (a: number, b: number, c: number) => [number, number];
|
|
39
|
+
readonly workbooksession_new: () => number;
|
|
40
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
41
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
42
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
43
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
44
|
+
readonly __wbindgen_start: () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
51
|
+
* a precompiled `WebAssembly.Module`.
|
|
52
|
+
*
|
|
53
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
54
|
+
*
|
|
55
|
+
* @returns {InitOutput}
|
|
56
|
+
*/
|
|
57
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
61
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
62
|
+
*
|
|
63
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
64
|
+
*
|
|
65
|
+
* @returns {Promise<InitOutput>}
|
|
66
|
+
*/
|
|
67
|
+
export default function __wbg_init (module_or_path: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// Generated by scripts/build-wasm.mjs from crates/open-artifact-sheets. Do not edit.
|
|
2
|
+
/**
|
|
3
|
+
* One workbook, as the page's worker holds it.
|
|
4
|
+
*/
|
|
5
|
+
export class WorkbookSession {
|
|
6
|
+
__destroy_into_raw() {
|
|
7
|
+
const ptr = this.__wbg_ptr;
|
|
8
|
+
this.__wbg_ptr = 0;
|
|
9
|
+
WorkbookSessionFinalization.unregister(this);
|
|
10
|
+
return ptr;
|
|
11
|
+
}
|
|
12
|
+
free() {
|
|
13
|
+
const ptr = this.__destroy_into_raw();
|
|
14
|
+
wasm.__wbg_workbooksession_free(ptr, 0);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A request about this workbook, as JSON; its answer, as JSON.
|
|
18
|
+
* @param {string} request
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
answerJson(request) {
|
|
22
|
+
let deferred2_0;
|
|
23
|
+
let deferred2_1;
|
|
24
|
+
try {
|
|
25
|
+
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
26
|
+
const len0 = WASM_VECTOR_LEN;
|
|
27
|
+
const ret = wasm.workbooksession_answerJson(this.__wbg_ptr, ptr0, len0);
|
|
28
|
+
deferred2_0 = ret[0];
|
|
29
|
+
deferred2_1 = ret[1];
|
|
30
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
31
|
+
} finally {
|
|
32
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
constructor() {
|
|
36
|
+
const ret = wasm.workbooksession_new();
|
|
37
|
+
this.__wbg_ptr = ret >>> 0;
|
|
38
|
+
WorkbookSessionFinalization.register(this, this.__wbg_ptr, this);
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (Symbol.dispose) WorkbookSession.prototype[Symbol.dispose] = WorkbookSession.prototype.free;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A request that needs no workbook, as JSON; its answer, as JSON.
|
|
46
|
+
* @param {string} request
|
|
47
|
+
* @returns {string}
|
|
48
|
+
*/
|
|
49
|
+
export function answerUtilityRequestJson(request) {
|
|
50
|
+
let deferred2_0;
|
|
51
|
+
let deferred2_1;
|
|
52
|
+
try {
|
|
53
|
+
const ptr0 = passStringToWasm0(request, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
54
|
+
const len0 = WASM_VECTOR_LEN;
|
|
55
|
+
const ret = wasm.answerUtilityRequestJson(ptr0, len0);
|
|
56
|
+
deferred2_0 = ret[0];
|
|
57
|
+
deferred2_1 = ret[1];
|
|
58
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
59
|
+
} finally {
|
|
60
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Every function a formula may call, with its family, its arguments and what it answers.
|
|
66
|
+
* @returns {string}
|
|
67
|
+
*/
|
|
68
|
+
export function functionDescriptionsJson() {
|
|
69
|
+
let deferred1_0;
|
|
70
|
+
let deferred1_1;
|
|
71
|
+
try {
|
|
72
|
+
const ret = wasm.functionDescriptionsJson();
|
|
73
|
+
deferred1_0 = ret[0];
|
|
74
|
+
deferred1_1 = ret[1];
|
|
75
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
76
|
+
} finally {
|
|
77
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function start() {
|
|
82
|
+
wasm.start();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function __wbg_get_imports() {
|
|
86
|
+
const import0 = {
|
|
87
|
+
__proto__: null,
|
|
88
|
+
__wbg___wbindgen_throw_81fc77679af83bc6: function(arg0, arg1) {
|
|
89
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
90
|
+
},
|
|
91
|
+
__wbg_error_4aac316f05be0ae7: function(arg0, arg1) {
|
|
92
|
+
console.error(getStringFromWasm0(arg0, arg1));
|
|
93
|
+
},
|
|
94
|
+
__wbg_now_b6a06de0b62c1c1e: function() {
|
|
95
|
+
const ret = performance.now();
|
|
96
|
+
return ret;
|
|
97
|
+
},
|
|
98
|
+
__wbindgen_init_externref_table: function() {
|
|
99
|
+
const table = wasm.__wbindgen_externrefs;
|
|
100
|
+
const offset = table.grow(4);
|
|
101
|
+
table.set(0, undefined);
|
|
102
|
+
table.set(offset + 0, undefined);
|
|
103
|
+
table.set(offset + 1, null);
|
|
104
|
+
table.set(offset + 2, true);
|
|
105
|
+
table.set(offset + 3, false);
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
__proto__: null,
|
|
110
|
+
"./open_artifact_sheets_bg.js": import0,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const WorkbookSessionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
115
|
+
? { register: () => {}, unregister: () => {} }
|
|
116
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_workbooksession_free(ptr >>> 0, 1));
|
|
117
|
+
|
|
118
|
+
function getStringFromWasm0(ptr, len) {
|
|
119
|
+
ptr = ptr >>> 0;
|
|
120
|
+
return decodeText(ptr, len);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let cachedUint8ArrayMemory0 = null;
|
|
124
|
+
function getUint8ArrayMemory0() {
|
|
125
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
126
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
127
|
+
}
|
|
128
|
+
return cachedUint8ArrayMemory0;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
132
|
+
if (realloc === undefined) {
|
|
133
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
134
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
135
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
136
|
+
WASM_VECTOR_LEN = buf.length;
|
|
137
|
+
return ptr;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let len = arg.length;
|
|
141
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
142
|
+
|
|
143
|
+
const mem = getUint8ArrayMemory0();
|
|
144
|
+
|
|
145
|
+
let offset = 0;
|
|
146
|
+
|
|
147
|
+
for (; offset < len; offset++) {
|
|
148
|
+
const code = arg.charCodeAt(offset);
|
|
149
|
+
if (code > 0x7F) break;
|
|
150
|
+
mem[ptr + offset] = code;
|
|
151
|
+
}
|
|
152
|
+
if (offset !== len) {
|
|
153
|
+
if (offset !== 0) {
|
|
154
|
+
arg = arg.slice(offset);
|
|
155
|
+
}
|
|
156
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
157
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
158
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
159
|
+
|
|
160
|
+
offset += ret.written;
|
|
161
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
WASM_VECTOR_LEN = offset;
|
|
165
|
+
return ptr;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
169
|
+
cachedTextDecoder.decode();
|
|
170
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
171
|
+
let numBytesDecoded = 0;
|
|
172
|
+
function decodeText(ptr, len) {
|
|
173
|
+
numBytesDecoded += len;
|
|
174
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
175
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
176
|
+
cachedTextDecoder.decode();
|
|
177
|
+
numBytesDecoded = len;
|
|
178
|
+
}
|
|
179
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const cachedTextEncoder = new TextEncoder();
|
|
183
|
+
|
|
184
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
185
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
186
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
187
|
+
view.set(buf);
|
|
188
|
+
return {
|
|
189
|
+
read: arg.length,
|
|
190
|
+
written: buf.length
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
let WASM_VECTOR_LEN = 0;
|
|
196
|
+
|
|
197
|
+
let wasmModule, wasm;
|
|
198
|
+
function __wbg_finalize_init(instance, module) {
|
|
199
|
+
wasm = instance.exports;
|
|
200
|
+
wasmModule = module;
|
|
201
|
+
cachedUint8ArrayMemory0 = null;
|
|
202
|
+
wasm.__wbindgen_start();
|
|
203
|
+
return wasm;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async function __wbg_load(module, imports) {
|
|
207
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
208
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
209
|
+
try {
|
|
210
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
213
|
+
|
|
214
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
215
|
+
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);
|
|
216
|
+
|
|
217
|
+
} else { throw e; }
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const bytes = await module.arrayBuffer();
|
|
222
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
223
|
+
} else {
|
|
224
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
225
|
+
|
|
226
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
227
|
+
return { instance, module };
|
|
228
|
+
} else {
|
|
229
|
+
return instance;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function expectedResponseType(type) {
|
|
234
|
+
switch (type) {
|
|
235
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
236
|
+
}
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function initSync(module) {
|
|
242
|
+
if (wasm !== undefined) return wasm;
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
if (module !== undefined) {
|
|
246
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
247
|
+
({module} = module)
|
|
248
|
+
} else {
|
|
249
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
const imports = __wbg_get_imports();
|
|
254
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
255
|
+
module = new WebAssembly.Module(module);
|
|
256
|
+
}
|
|
257
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
258
|
+
return __wbg_finalize_init(instance, module);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
async function __wbg_init(module_or_path) {
|
|
262
|
+
if (wasm !== undefined) return wasm;
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
if (module_or_path !== undefined) {
|
|
266
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
267
|
+
({module_or_path} = module_or_path)
|
|
268
|
+
} else {
|
|
269
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
const imports = __wbg_get_imports();
|
|
275
|
+
|
|
276
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
277
|
+
module_or_path = fetch(module_or_path);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
281
|
+
|
|
282
|
+
return __wbg_finalize_init(instance, module);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-artifact/wasm-sheets",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.9.0",
|
|
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
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"default": "./src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"./node": {
|
|
12
|
+
"types": "./src/node.d.ts",
|
|
13
|
+
"default": "./src/node.js"
|
|
14
|
+
},
|
|
15
|
+
"./module-url": {
|
|
16
|
+
"types": "./src/module-url.d.ts",
|
|
17
|
+
"default": "./src/module-url.js"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"src",
|
|
23
|
+
"generated",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"NOTICE"
|
|
26
|
+
],
|
|
27
|
+
"license": "Apache-2.0",
|
|
28
|
+
"author": {
|
|
29
|
+
"name": "Jim Liu 宝玉",
|
|
30
|
+
"url": "https://github.com/JimLiu"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/JimLiu/open-artifact#readme",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/JimLiu/open-artifact.git",
|
|
36
|
+
"directory": "packages/wasm-sheets"
|
|
37
|
+
},
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/JimLiu/open-artifact/issues"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Sheets workbook engine (`crates/open-artifact-sheets`). Everything
|
|
3
|
+
* crosses as JSON text: a request goes in, its answer comes out. Instantiate
|
|
4
|
+
* once with the module's bytes (or a compiled module), then make sessions.
|
|
5
|
+
*/
|
|
6
|
+
/** One workbook and every request about it. */
|
|
7
|
+
export interface EngineSession {
|
|
8
|
+
/** A request about this workbook, as JSON text; its answer, as JSON text. */
|
|
9
|
+
answerJson(request: string): string;
|
|
10
|
+
/** Frees the workbook; the session cannot be used afterwards. */
|
|
11
|
+
free(): void;
|
|
12
|
+
}
|
|
13
|
+
/** The engine, instantiated. */
|
|
14
|
+
export interface SheetsEngine {
|
|
15
|
+
/** A new, empty workbook session. */
|
|
16
|
+
session(): EngineSession;
|
|
17
|
+
/** A request that needs no workbook (locales, number formats, time zones…), as JSON text. */
|
|
18
|
+
utilityJson(request: string): string;
|
|
19
|
+
/** Every function a formula may call, as JSON text. */
|
|
20
|
+
functionDescriptionsJson(): string;
|
|
21
|
+
}
|
|
22
|
+
/** Instantiates the engine from the module's bytes or a compiled module (once per realm). */
|
|
23
|
+
export declare function instantiateSheetsEngine(module: BufferSource | WebAssembly.Module): SheetsEngine;
|
|
24
|
+
/** Fetches and instantiates the engine (a page's worker). */
|
|
25
|
+
export declare function loadSheetsEngine(url: string | URL): Promise<SheetsEngine>;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Sheets workbook engine (`crates/open-artifact-sheets`). Everything
|
|
3
|
+
* crosses as JSON text: a request goes in, its answer comes out. Instantiate
|
|
4
|
+
* once with the module's bytes (or a compiled module), then make sessions.
|
|
5
|
+
*/
|
|
6
|
+
import * as glue from '../generated/open_artifact_sheets.js';
|
|
7
|
+
let instantiated = false;
|
|
8
|
+
function engineOf() {
|
|
9
|
+
return {
|
|
10
|
+
session: () => {
|
|
11
|
+
const session = new glue.WorkbookSession();
|
|
12
|
+
return { answerJson: (request) => session.answerJson(request), free: () => session.free() };
|
|
13
|
+
},
|
|
14
|
+
utilityJson: (request) => glue.answerUtilityRequestJson(request),
|
|
15
|
+
functionDescriptionsJson: () => glue.functionDescriptionsJson(),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/** Instantiates the engine from the module's bytes or a compiled module (once per realm). */
|
|
19
|
+
export function instantiateSheetsEngine(module) {
|
|
20
|
+
if (!instantiated) {
|
|
21
|
+
glue.initSync({ module });
|
|
22
|
+
instantiated = true;
|
|
23
|
+
}
|
|
24
|
+
return engineOf();
|
|
25
|
+
}
|
|
26
|
+
/** Fetches and instantiates the engine (a page's worker). */
|
|
27
|
+
export async function loadSheetsEngine(url) {
|
|
28
|
+
if (!instantiated) {
|
|
29
|
+
await glue.default({ module_or_path: url });
|
|
30
|
+
instantiated = true;
|
|
31
|
+
}
|
|
32
|
+
return engineOf();
|
|
33
|
+
}
|
package/src/node.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine in Node: the module read from disk. A bundled CLI sets
|
|
3
|
+
* `OPEN_ARTIFACT_SHEETS_WASM` (or ships the file as `sheets.wasm` beside
|
|
4
|
+
* itself); unbundled, it is read from `generated/`.
|
|
5
|
+
*/
|
|
6
|
+
import { type SheetsEngine } from './index.ts';
|
|
7
|
+
export type { EngineSession, SheetsEngine } from './index.ts';
|
|
8
|
+
/** The engine, instantiated on first use. */
|
|
9
|
+
export declare function sheetsEngine(): SheetsEngine;
|
package/src/node.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine in Node: the module read from disk. A bundled CLI sets
|
|
3
|
+
* `OPEN_ARTIFACT_SHEETS_WASM` (or ships the file as `sheets.wasm` beside
|
|
4
|
+
* itself); unbundled, it is read from `generated/`.
|
|
5
|
+
*/
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { instantiateSheetsEngine } from "./index.js";
|
|
9
|
+
const FILE = 'open_artifact_sheets_bg.wasm';
|
|
10
|
+
function modulePath() {
|
|
11
|
+
const named = process.env.OPEN_ARTIFACT_SHEETS_WASM;
|
|
12
|
+
if (named)
|
|
13
|
+
return named;
|
|
14
|
+
const beside = fileURLToPath(new URL('./sheets.wasm', import.meta.url));
|
|
15
|
+
if (existsSync(beside))
|
|
16
|
+
return beside;
|
|
17
|
+
return fileURLToPath(new URL(`../generated/${FILE}`, import.meta.url));
|
|
18
|
+
}
|
|
19
|
+
let engine = null;
|
|
20
|
+
/** The engine, instantiated on first use. */
|
|
21
|
+
export function sheetsEngine() {
|
|
22
|
+
engine ??= instantiateSheetsEngine(new WebAssembly.Module(readFileSync(modulePath())));
|
|
23
|
+
return engine;
|
|
24
|
+
}
|