@opengeni/artifact-tool 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +190 -0
- package/README.md +104 -0
- package/dist/bounded-zip.d.ts +28 -0
- package/dist/chunk-4BSENMAE.js +39 -0
- package/dist/chunk-4BSENMAE.js.map +1 -0
- package/dist/chunk-4FRFNNBM.js +276 -0
- package/dist/chunk-4FRFNNBM.js.map +1 -0
- package/dist/chunk-5XIA6KHZ.js +49 -0
- package/dist/chunk-5XIA6KHZ.js.map +1 -0
- package/dist/chunk-66CT2ZRP.js +2229 -0
- package/dist/chunk-66CT2ZRP.js.map +1 -0
- package/dist/chunk-72SYDU4O.js +319 -0
- package/dist/chunk-72SYDU4O.js.map +1 -0
- package/dist/chunk-B2ZJRZDA.js +279 -0
- package/dist/chunk-B2ZJRZDA.js.map +1 -0
- package/dist/chunk-DCTLTNPW.js +2458 -0
- package/dist/chunk-DCTLTNPW.js.map +1 -0
- package/dist/chunk-FGZM4FQ6.js +473 -0
- package/dist/chunk-FGZM4FQ6.js.map +1 -0
- package/dist/chunk-HTJBLBDE.js +591 -0
- package/dist/chunk-HTJBLBDE.js.map +1 -0
- package/dist/chunk-IYFXZQ34.js +5306 -0
- package/dist/chunk-IYFXZQ34.js.map +1 -0
- package/dist/chunk-J6N7IR44.js +172 -0
- package/dist/chunk-J6N7IR44.js.map +1 -0
- package/dist/chunk-N2IHNWBS.js +1002 -0
- package/dist/chunk-N2IHNWBS.js.map +1 -0
- package/dist/chunk-NAG44K67.js +549 -0
- package/dist/chunk-NAG44K67.js.map +1 -0
- package/dist/chunk-O24KTEGP.js +33 -0
- package/dist/chunk-O24KTEGP.js.map +1 -0
- package/dist/chunk-PI2AZVGK.js +2074 -0
- package/dist/chunk-PI2AZVGK.js.map +1 -0
- package/dist/chunk-Q2FFHEY7.js +40 -0
- package/dist/chunk-Q2FFHEY7.js.map +1 -0
- package/dist/chunk-RBGQADXA.js +57 -0
- package/dist/chunk-RBGQADXA.js.map +1 -0
- package/dist/chunk-U5G2BKM2.js +613 -0
- package/dist/chunk-U5G2BKM2.js.map +1 -0
- package/dist/chunk-VOJHMSM3.js +39 -0
- package/dist/chunk-VOJHMSM3.js.map +1 -0
- package/dist/chunk-VUNV25KB.js +16 -0
- package/dist/chunk-VUNV25KB.js.map +1 -0
- package/dist/chunk-XIFUNVBO.js +101 -0
- package/dist/chunk-XIFUNVBO.js.map +1 -0
- package/dist/chunk-ZCJYRJGB.js +489 -0
- package/dist/chunk-ZCJYRJGB.js.map +1 -0
- package/dist/chunk-ZZXPEE4S.js +2260 -0
- package/dist/chunk-ZZXPEE4S.js.map +1 -0
- package/dist/document-docx-api.d.ts +49 -0
- package/dist/document-docx-codec.d.ts +9 -0
- package/dist/document-docx-codec.js +4765 -0
- package/dist/document-docx-codec.js.map +1 -0
- package/dist/document-docx-import.d.ts +261 -0
- package/dist/document-docx-packer.d.ts +18 -0
- package/dist/document-docx-state.d.ts +12 -0
- package/dist/document-render.d.ts +3 -0
- package/dist/document-render.js +492 -0
- package/dist/document-render.js.map +1 -0
- package/dist/document.d.ts +432 -0
- package/dist/document.js +37 -0
- package/dist/document.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/file-blob.d.ts +11 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -0
- package/dist/inspection.d.ts +12 -0
- package/dist/kernel.d.ts +101 -0
- package/dist/lib-GQLPACFK.js +9746 -0
- package/dist/lib-GQLPACFK.js.map +1 -0
- package/dist/materializer-cli-entry.d.ts +2 -0
- package/dist/materializer-cli-entry.js +29 -0
- package/dist/materializer-cli-entry.js.map +1 -0
- package/dist/materializer-cli.d.ts +24 -0
- package/dist/materializer-cli.js +24 -0
- package/dist/materializer-cli.js.map +1 -0
- package/dist/native-raster.d.ts +10 -0
- package/dist/native.d.ts +129 -0
- package/dist/native.js +31 -0
- package/dist/native.js.map +1 -0
- package/dist/office-import.d.ts +48 -0
- package/dist/office-import.js +154 -0
- package/dist/office-import.js.map +1 -0
- package/dist/presentation-pptx-api.d.ts +60 -0
- package/dist/presentation-pptx-import.d.ts +5 -0
- package/dist/presentation-pptx-state-digest-765CZZED.js +10 -0
- package/dist/presentation-pptx-state-digest-765CZZED.js.map +1 -0
- package/dist/presentation-pptx-state-digest.d.ts +3 -0
- package/dist/presentation-pptx-state.d.ts +4 -0
- package/dist/presentation-pptx-xml.d.ts +29 -0
- package/dist/presentation-pptx.d.ts +5 -0
- package/dist/presentation-pptx.js +2365 -0
- package/dist/presentation-pptx.js.map +1 -0
- package/dist/presentation-render.d.ts +29 -0
- package/dist/presentation-render.js +375 -0
- package/dist/presentation-render.js.map +1 -0
- package/dist/presentation.d.ts +565 -0
- package/dist/presentation.js +71 -0
- package/dist/presentation.js.map +1 -0
- package/dist/production-composite.d.ts +68 -0
- package/dist/production-document.d.ts +2 -0
- package/dist/production-document.js +176 -0
- package/dist/production-document.js.map +1 -0
- package/dist/production-native-codecs.d.ts +94 -0
- package/dist/production-presentation.d.ts +2 -0
- package/dist/production-presentation.js +176 -0
- package/dist/production-presentation.js.map +1 -0
- package/dist/production-sha256.d.ts +2 -0
- package/dist/production-spreadsheet-native.d.ts +12 -0
- package/dist/production-spreadsheet.d.ts +2 -0
- package/dist/production-spreadsheet.js +176 -0
- package/dist/production-spreadsheet.js.map +1 -0
- package/dist/production.d.ts +96 -0
- package/dist/raster-image.d.ts +34 -0
- package/dist/reference.d.ts +17 -0
- package/dist/reference.js +574 -0
- package/dist/reference.js.map +1 -0
- package/dist/runtime-cli-entry.d.ts +2 -0
- package/dist/runtime-cli-entry.js +21 -0
- package/dist/runtime-cli-entry.js.map +1 -0
- package/dist/runtime-cli.d.ts +76 -0
- package/dist/runtime-cli.js +26 -0
- package/dist/runtime-cli.js.map +1 -0
- package/dist/runtime-development.d.ts +73 -0
- package/dist/runtime-development.js +30 -0
- package/dist/runtime-development.js.map +1 -0
- package/dist/runtime-receipt.d.ts +19 -0
- package/dist/runtime.d.ts +355 -0
- package/dist/runtime.js +42 -0
- package/dist/runtime.js.map +1 -0
- package/dist/snapshot.d.ts +26 -0
- package/dist/snapshot.js +61 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/spreadsheet-address.d.ts +18 -0
- package/dist/spreadsheet-file.d.ts +17 -0
- package/dist/spreadsheet-formula.d.ts +67 -0
- package/dist/spreadsheet-image.d.ts +17 -0
- package/dist/spreadsheet-render.d.ts +5 -0
- package/dist/spreadsheet-render.js +752 -0
- package/dist/spreadsheet-render.js.map +1 -0
- package/dist/spreadsheet-types.d.ts +155 -0
- package/dist/spreadsheet-xlsx-api.d.ts +88 -0
- package/dist/spreadsheet-xlsx-codec.d.ts +16 -0
- package/dist/spreadsheet-xlsx-codec.js +16 -0
- package/dist/spreadsheet-xlsx-codec.js.map +1 -0
- package/dist/spreadsheet-xlsx-state.d.ts +16 -0
- package/dist/spreadsheet.d.ts +724 -0
- package/dist/spreadsheet.js +67 -0
- package/dist/spreadsheet.js.map +1 -0
- package/package.json +129 -0
- package/src/bounded-zip.ts +450 -0
- package/src/document-docx-api.ts +64 -0
- package/src/document-docx-codec.ts +2253 -0
- package/src/document-docx-import.ts +3814 -0
- package/src/document-docx-packer.ts +72 -0
- package/src/document-docx-state.ts +59 -0
- package/src/document-render.ts +615 -0
- package/src/document.ts +2800 -0
- package/src/errors.ts +45 -0
- package/src/file-blob.ts +43 -0
- package/src/index.ts +4 -0
- package/src/inspection.ts +50 -0
- package/src/kernel.ts +525 -0
- package/src/materializer-cli-entry.ts +11 -0
- package/src/materializer-cli.ts +743 -0
- package/src/native-raster.ts +141 -0
- package/src/native.ts +390 -0
- package/src/office-import.ts +243 -0
- package/src/presentation-pptx-api.ts +107 -0
- package/src/presentation-pptx-import.ts +2065 -0
- package/src/presentation-pptx-state-digest.ts +46 -0
- package/src/presentation-pptx-state.ts +18 -0
- package/src/presentation-pptx-xml.ts +473 -0
- package/src/presentation-pptx.ts +447 -0
- package/src/presentation-render.ts +532 -0
- package/src/presentation.ts +2599 -0
- package/src/production-composite.ts +805 -0
- package/src/production-document.ts +2 -0
- package/src/production-native-codecs.ts +1141 -0
- package/src/production-presentation.ts +2 -0
- package/src/production-sha256.ts +150 -0
- package/src/production-spreadsheet-native.ts +686 -0
- package/src/production-spreadsheet.ts +2 -0
- package/src/production.ts +1022 -0
- package/src/raster-image.ts +586 -0
- package/src/reference.ts +17 -0
- package/src/runtime-cli-entry.ts +13 -0
- package/src/runtime-cli.ts +670 -0
- package/src/runtime-development.ts +689 -0
- package/src/runtime-receipt.ts +169 -0
- package/src/runtime.ts +1463 -0
- package/src/snapshot.ts +88 -0
- package/src/spreadsheet-address.ts +90 -0
- package/src/spreadsheet-file.ts +71 -0
- package/src/spreadsheet-formula.ts +1212 -0
- package/src/spreadsheet-image.ts +242 -0
- package/src/spreadsheet-render.ts +985 -0
- package/src/spreadsheet-types.ts +171 -0
- package/src/spreadsheet-xlsx-api.ts +123 -0
- package/src/spreadsheet-xlsx-codec.ts +3063 -0
- package/src/spreadsheet-xlsx-state.ts +191 -0
- package/src/spreadsheet.ts +5195 -0
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
// src/production-composite.ts
|
|
2
|
+
var ROOT_KEY = "$root";
|
|
3
|
+
var PROXY_METADATA = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
var QUERY_METHODS = /* @__PURE__ */ new Set([
|
|
5
|
+
"allStoryBlocks",
|
|
6
|
+
"arrayBuffer",
|
|
7
|
+
"at",
|
|
8
|
+
"entries",
|
|
9
|
+
"every",
|
|
10
|
+
"export",
|
|
11
|
+
"filter",
|
|
12
|
+
"find",
|
|
13
|
+
"findIndex",
|
|
14
|
+
"findLast",
|
|
15
|
+
"findLastIndex",
|
|
16
|
+
"forBlock",
|
|
17
|
+
"forEach",
|
|
18
|
+
"getActiveWorksheet",
|
|
19
|
+
"getCell",
|
|
20
|
+
"getItem",
|
|
21
|
+
"getItemAt",
|
|
22
|
+
"getRange",
|
|
23
|
+
"getRangeByIndexes",
|
|
24
|
+
"getUsedRange",
|
|
25
|
+
"help",
|
|
26
|
+
"includes",
|
|
27
|
+
"indexOf",
|
|
28
|
+
"inspect",
|
|
29
|
+
"inspectRecord",
|
|
30
|
+
"join",
|
|
31
|
+
"keys",
|
|
32
|
+
"lastIndexOf",
|
|
33
|
+
"layoutSnapshot",
|
|
34
|
+
"map",
|
|
35
|
+
"ownsObject",
|
|
36
|
+
"reduce",
|
|
37
|
+
"reduceRight",
|
|
38
|
+
"render",
|
|
39
|
+
"resolve",
|
|
40
|
+
"resize",
|
|
41
|
+
"serialize",
|
|
42
|
+
"slice",
|
|
43
|
+
"some",
|
|
44
|
+
"summary",
|
|
45
|
+
"text",
|
|
46
|
+
"toJSON",
|
|
47
|
+
"toLocaleString",
|
|
48
|
+
"toProto",
|
|
49
|
+
"toString",
|
|
50
|
+
"trace",
|
|
51
|
+
"values"
|
|
52
|
+
]);
|
|
53
|
+
var ARRAY_CALLBACK_METHODS = /* @__PURE__ */ new Set([
|
|
54
|
+
"every",
|
|
55
|
+
"filter",
|
|
56
|
+
"find",
|
|
57
|
+
"findIndex",
|
|
58
|
+
"findLast",
|
|
59
|
+
"findLastIndex",
|
|
60
|
+
"flatMap",
|
|
61
|
+
"forEach",
|
|
62
|
+
"map",
|
|
63
|
+
"reduce",
|
|
64
|
+
"reduceRight",
|
|
65
|
+
"some"
|
|
66
|
+
]);
|
|
67
|
+
var ARRAY_MUTATION_METHODS = /* @__PURE__ */ new Set([
|
|
68
|
+
"copyWithin",
|
|
69
|
+
"fill",
|
|
70
|
+
"pop",
|
|
71
|
+
"push",
|
|
72
|
+
"reverse",
|
|
73
|
+
"shift",
|
|
74
|
+
"sort",
|
|
75
|
+
"splice",
|
|
76
|
+
"unshift"
|
|
77
|
+
]);
|
|
78
|
+
var CompositeArtifactState = class {
|
|
79
|
+
modality;
|
|
80
|
+
namespace;
|
|
81
|
+
#root;
|
|
82
|
+
#native;
|
|
83
|
+
#nativeData;
|
|
84
|
+
#revision;
|
|
85
|
+
#disposedError;
|
|
86
|
+
#disposed = false;
|
|
87
|
+
#mutationDepth = 0;
|
|
88
|
+
#asyncMutation = false;
|
|
89
|
+
#reconcileProjection;
|
|
90
|
+
#prepareMutation;
|
|
91
|
+
#proxies = /* @__PURE__ */ new Map();
|
|
92
|
+
#functions = /* @__PURE__ */ new Map();
|
|
93
|
+
#changeListeners = /* @__PURE__ */ new Set();
|
|
94
|
+
#installProjection;
|
|
95
|
+
#readProperty;
|
|
96
|
+
#captureAuxiliary;
|
|
97
|
+
#restoreAuxiliary;
|
|
98
|
+
constructor(input) {
|
|
99
|
+
this.modality = input.modality;
|
|
100
|
+
this.namespace = input.namespace;
|
|
101
|
+
this.#root = input.root;
|
|
102
|
+
this.#native = input.reconciliation.session;
|
|
103
|
+
this.#nativeData = input.reconciliation.data;
|
|
104
|
+
this.#revision = safeRevision(this.#native.revision());
|
|
105
|
+
this.#reconcileProjection = input.reconcile;
|
|
106
|
+
this.#prepareMutation = input.prepareMutation;
|
|
107
|
+
this.#installProjection = input.installProjection;
|
|
108
|
+
this.#readProperty = input.readProperty;
|
|
109
|
+
this.#captureAuxiliary = input.captureAuxiliary;
|
|
110
|
+
this.#restoreAuxiliary = input.restoreAuxiliary;
|
|
111
|
+
this.#disposedError = new Error(`${input.modality} artifact is disposed`);
|
|
112
|
+
this.#installProjection?.(this.#root, this);
|
|
113
|
+
}
|
|
114
|
+
get root() {
|
|
115
|
+
this.assertUsable();
|
|
116
|
+
return this.#root;
|
|
117
|
+
}
|
|
118
|
+
get native() {
|
|
119
|
+
this.assertUsable();
|
|
120
|
+
return this.#native;
|
|
121
|
+
}
|
|
122
|
+
get nativeData() {
|
|
123
|
+
this.assertUsable();
|
|
124
|
+
return this.#nativeData;
|
|
125
|
+
}
|
|
126
|
+
/** Monotonic facade revision across retained and rare replacement sessions. */
|
|
127
|
+
get revision() {
|
|
128
|
+
this.assertUsable();
|
|
129
|
+
return this.#revision;
|
|
130
|
+
}
|
|
131
|
+
/** True only inside one explicit/public mutation transaction. */
|
|
132
|
+
get inMutation() {
|
|
133
|
+
return this.#mutationDepth > 0;
|
|
134
|
+
}
|
|
135
|
+
proxy() {
|
|
136
|
+
return this.wrap(rootLocator());
|
|
137
|
+
}
|
|
138
|
+
rawRoot() {
|
|
139
|
+
this.assertUsable();
|
|
140
|
+
return this.#root;
|
|
141
|
+
}
|
|
142
|
+
assertUsable() {
|
|
143
|
+
if (this.#disposed) throw this.#disposedError;
|
|
144
|
+
if (this.#asyncMutation && this.#mutationDepth === 0) {
|
|
145
|
+
throw new Error(`${this.modality} artifact mutation is still in progress`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
onWorkbookChange(listener) {
|
|
149
|
+
this.assertUsable();
|
|
150
|
+
if (this.modality !== "spreadsheet") {
|
|
151
|
+
throw new Error("Workbook change listeners are only available for spreadsheets");
|
|
152
|
+
}
|
|
153
|
+
this.#changeListeners.add(listener);
|
|
154
|
+
return () => this.#changeListeners.delete(listener);
|
|
155
|
+
}
|
|
156
|
+
dispose() {
|
|
157
|
+
if (this.#disposed) return;
|
|
158
|
+
this.#native.dispose();
|
|
159
|
+
this.#changeListeners.clear();
|
|
160
|
+
this.#proxies.clear();
|
|
161
|
+
this.#functions.clear();
|
|
162
|
+
this.#disposed = true;
|
|
163
|
+
}
|
|
164
|
+
mutate(operation, hint) {
|
|
165
|
+
this.assertUsable();
|
|
166
|
+
if (this.#mutationDepth > 0) return operation();
|
|
167
|
+
const prepared = this.#prepareMutation?.(hint, this) ?? null;
|
|
168
|
+
const acceptedRoot = prepared ? null : cloneProjectionGraph(this.#root);
|
|
169
|
+
const acceptedAuxiliary = prepared ? void 0 : this.#captureAuxiliary?.(this.#root);
|
|
170
|
+
this.#mutationDepth = 1;
|
|
171
|
+
let result;
|
|
172
|
+
try {
|
|
173
|
+
result = operation();
|
|
174
|
+
} catch (cause) {
|
|
175
|
+
if (acceptedRoot) this.#restoreProjection(acceptedRoot, acceptedAuxiliary);
|
|
176
|
+
this.#mutationDepth = 0;
|
|
177
|
+
throw cause;
|
|
178
|
+
}
|
|
179
|
+
if (isPromiseLike(result)) {
|
|
180
|
+
this.#asyncMutation = true;
|
|
181
|
+
return result.then(
|
|
182
|
+
(value) => {
|
|
183
|
+
try {
|
|
184
|
+
this.#acceptProjection(hint, prepared, value);
|
|
185
|
+
return value;
|
|
186
|
+
} catch (cause) {
|
|
187
|
+
if (acceptedRoot) this.#restoreProjection(acceptedRoot, acceptedAuxiliary);
|
|
188
|
+
else this.#poisonAfterIncrementalFailure();
|
|
189
|
+
throw cause;
|
|
190
|
+
} finally {
|
|
191
|
+
this.#mutationDepth = 0;
|
|
192
|
+
this.#asyncMutation = false;
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
(cause) => {
|
|
196
|
+
if (acceptedRoot) this.#restoreProjection(acceptedRoot, acceptedAuxiliary);
|
|
197
|
+
this.#mutationDepth = 0;
|
|
198
|
+
this.#asyncMutation = false;
|
|
199
|
+
throw cause;
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
this.#acceptProjection(hint, prepared, result);
|
|
205
|
+
return result;
|
|
206
|
+
} catch (cause) {
|
|
207
|
+
if (acceptedRoot) this.#restoreProjection(acceptedRoot, acceptedAuxiliary);
|
|
208
|
+
else this.#poisonAfterIncrementalFailure();
|
|
209
|
+
throw cause;
|
|
210
|
+
} finally {
|
|
211
|
+
this.#mutationDepth = 0;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
wrap(locator) {
|
|
215
|
+
this.assertUsable();
|
|
216
|
+
const existing = this.#proxies.get(locator.key);
|
|
217
|
+
if (existing) return existing;
|
|
218
|
+
const current = locator.resolve(this.#root);
|
|
219
|
+
if (!isProxyCandidate(current)) return current;
|
|
220
|
+
const target = Array.isArray(current) ? [] : {};
|
|
221
|
+
const proxy = new Proxy(target, this.#handler(locator));
|
|
222
|
+
this.#proxies.set(locator.key, proxy);
|
|
223
|
+
PROXY_METADATA.set(proxy, {
|
|
224
|
+
state: this,
|
|
225
|
+
locator
|
|
226
|
+
});
|
|
227
|
+
return proxy;
|
|
228
|
+
}
|
|
229
|
+
#handler(locator) {
|
|
230
|
+
return {
|
|
231
|
+
get: (_target, member) => {
|
|
232
|
+
this.assertUsable();
|
|
233
|
+
const owner = locator.resolve(this.#root);
|
|
234
|
+
if (!isObject(owner)) return void 0;
|
|
235
|
+
if (locator.key === ROOT_KEY) {
|
|
236
|
+
if (member === "batch") {
|
|
237
|
+
return this.#rootFunction("batch", (callback) => {
|
|
238
|
+
if (typeof callback !== "function") {
|
|
239
|
+
throw new TypeError("Artifact batch callback must be a function");
|
|
240
|
+
}
|
|
241
|
+
return this.mutate(() => callback(this.proxy()), {
|
|
242
|
+
member: "batch",
|
|
243
|
+
owner: this.#root,
|
|
244
|
+
arguments: [callback]
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
if (member === "dispose") return this.#rootFunction("dispose", () => this.dispose());
|
|
249
|
+
if (member === "onChange" && this.modality === "spreadsheet") {
|
|
250
|
+
return this.#rootFunction("onChange", (listener) => {
|
|
251
|
+
if (typeof listener !== "function")
|
|
252
|
+
throw new TypeError("Workbook listener must be a function");
|
|
253
|
+
return this.onWorkbookChange(listener);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
if (member === "recalculate" && this.modality === "spreadsheet") {
|
|
257
|
+
return this.#rootFunction("recalculate", () => void 0);
|
|
258
|
+
}
|
|
259
|
+
if (member === "revision" && (this.modality === "spreadsheet" || this.modality === "document")) {
|
|
260
|
+
return this.#revision;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (Array.isArray(owner) && member === Symbol.iterator) {
|
|
264
|
+
return this.#arrayIterator(locator, owner);
|
|
265
|
+
}
|
|
266
|
+
const projected = this.#readProperty?.(owner, member, this);
|
|
267
|
+
const value = projected?.handled === true ? projected.value : Reflect.get(owner, member, owner);
|
|
268
|
+
if (typeof value === "function") {
|
|
269
|
+
const functionKey = `${locator.key}.${propertyKey(member)}`;
|
|
270
|
+
const cached = this.#functions.get(functionKey);
|
|
271
|
+
if (cached) return cached;
|
|
272
|
+
const wrapped = (...args) => {
|
|
273
|
+
this.assertUsable();
|
|
274
|
+
const currentOwner = locator.resolve(this.#root);
|
|
275
|
+
if (!isObject(currentOwner)) throw new Error("Artifact object no longer exists");
|
|
276
|
+
const currentMethod = Reflect.get(currentOwner, member, currentOwner);
|
|
277
|
+
if (typeof currentMethod !== "function")
|
|
278
|
+
throw new TypeError(`${String(member)} is not callable`);
|
|
279
|
+
const invocationArgs = Array.isArray(currentOwner) && ARRAY_CALLBACK_METHODS.has(member) ? this.#arrayCallbackArguments(locator, args) : args.map(unwrapArtifactValue);
|
|
280
|
+
const invoke = () => currentMethod.apply(currentOwner, invocationArgs);
|
|
281
|
+
const mutates = Array.isArray(currentOwner) ? ARRAY_MUTATION_METHODS.has(member) : !QUERY_METHODS.has(member);
|
|
282
|
+
const result = mutates ? this.mutate(invoke, { member, owner: currentOwner, arguments: invocationArgs }) : invoke();
|
|
283
|
+
return this.#wrapReturn(locator, member, result);
|
|
284
|
+
};
|
|
285
|
+
this.#functions.set(functionKey, wrapped);
|
|
286
|
+
return wrapped;
|
|
287
|
+
}
|
|
288
|
+
return this.#wrapProperty(locator, member, value);
|
|
289
|
+
},
|
|
290
|
+
set: (_target, member, value) => {
|
|
291
|
+
this.assertUsable();
|
|
292
|
+
const owner = locator.resolve(this.#root);
|
|
293
|
+
if (!isObject(owner)) throw new Error("Artifact object no longer exists");
|
|
294
|
+
return this.mutate(() => Reflect.set(owner, member, unwrapArtifactValue(value), owner), {
|
|
295
|
+
member,
|
|
296
|
+
owner,
|
|
297
|
+
arguments: [unwrapArtifactValue(value)]
|
|
298
|
+
});
|
|
299
|
+
},
|
|
300
|
+
deleteProperty: (_target, member) => {
|
|
301
|
+
this.assertUsable();
|
|
302
|
+
const owner = locator.resolve(this.#root);
|
|
303
|
+
if (!isObject(owner)) throw new Error("Artifact object no longer exists");
|
|
304
|
+
return this.mutate(() => Reflect.deleteProperty(owner, member), {
|
|
305
|
+
member,
|
|
306
|
+
owner,
|
|
307
|
+
arguments: []
|
|
308
|
+
});
|
|
309
|
+
},
|
|
310
|
+
has: (_target, member) => {
|
|
311
|
+
const owner = locator.resolve(this.#root);
|
|
312
|
+
return isObject(owner) && member in owner;
|
|
313
|
+
},
|
|
314
|
+
getPrototypeOf: () => {
|
|
315
|
+
const owner = locator.resolve(this.#root);
|
|
316
|
+
return isObject(owner) ? Object.getPrototypeOf(owner) : null;
|
|
317
|
+
},
|
|
318
|
+
ownKeys: (target) => {
|
|
319
|
+
const owner = locator.resolve(this.#root);
|
|
320
|
+
const keys = isObject(owner) ? Reflect.ownKeys(owner) : [];
|
|
321
|
+
if (Array.isArray(target) && !keys.includes("length")) keys.push("length");
|
|
322
|
+
return keys;
|
|
323
|
+
},
|
|
324
|
+
getOwnPropertyDescriptor: (target, member) => {
|
|
325
|
+
if (Array.isArray(target) && member === "length") {
|
|
326
|
+
return Reflect.getOwnPropertyDescriptor(target, "length");
|
|
327
|
+
}
|
|
328
|
+
const owner = locator.resolve(this.#root);
|
|
329
|
+
const descriptor = isObject(owner) ? Reflect.getOwnPropertyDescriptor(owner, member) : void 0;
|
|
330
|
+
return descriptor ? { ...descriptor, configurable: true } : void 0;
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
#acceptProjection(hint, prepared, result) {
|
|
335
|
+
if (prepared) {
|
|
336
|
+
const changed = prepared.commit(result);
|
|
337
|
+
if (changed) {
|
|
338
|
+
this.#revision = Math.max(this.#revision + 1, safeRevision(this.#native.revision()));
|
|
339
|
+
this.#emitWorkbookChange(hint);
|
|
340
|
+
}
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
const accepted = this.#reconcileProjection(this.#root);
|
|
344
|
+
const previous = this.#native;
|
|
345
|
+
this.#native = accepted.session;
|
|
346
|
+
this.#nativeData = accepted.data;
|
|
347
|
+
this.#revision = Math.max(this.#revision + 1, safeRevision(this.#native.revision()));
|
|
348
|
+
try {
|
|
349
|
+
previous.dispose();
|
|
350
|
+
} catch {
|
|
351
|
+
}
|
|
352
|
+
this.#emitWorkbookChange(hint);
|
|
353
|
+
}
|
|
354
|
+
#poisonAfterIncrementalFailure() {
|
|
355
|
+
try {
|
|
356
|
+
this.#native.dispose();
|
|
357
|
+
} finally {
|
|
358
|
+
this.#disposed = true;
|
|
359
|
+
this.#changeListeners.clear();
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
#restoreProjection(root, auxiliary) {
|
|
363
|
+
this.#root = root;
|
|
364
|
+
this.#installProjection?.(this.#root, this);
|
|
365
|
+
this.#restoreAuxiliary?.(this.#root, auxiliary);
|
|
366
|
+
}
|
|
367
|
+
#emitWorkbookChange(hint) {
|
|
368
|
+
if (this.modality !== "spreadsheet" || this.#changeListeners.size === 0) return;
|
|
369
|
+
const root = this.#root;
|
|
370
|
+
const owner = hint.owner;
|
|
371
|
+
const ownerSheet = typeof owner?.id === "string" && owner.id.startsWith("ws/") ? owner.id : typeof owner?.worksheet?.id === "string" ? owner.worksheet.id : null;
|
|
372
|
+
const sheetIds = ownerSheet ? [ownerSheet] : (root.worksheets?.items ?? []).map((sheet) => sheet.id).filter((id) => typeof id === "string");
|
|
373
|
+
const member = String(hint.member).toLowerCase();
|
|
374
|
+
const reason = member.includes("format") || member.includes("style") ? "format" : member.includes("comment") || member.includes("reply") ? "comment" : member.includes("width") || member.includes("height") ? "dimension" : member.includes("chart") || member.includes("image") || member.includes("shape") || member.includes("sparkline") ? "drawing" : member.includes("sheet") || member === "add" || member === "name" ? "structure" : "content";
|
|
375
|
+
const change = Object.freeze({
|
|
376
|
+
revision: this.#revision,
|
|
377
|
+
sheetIds: Object.freeze([...new Set(sheetIds)].sort()),
|
|
378
|
+
reason
|
|
379
|
+
});
|
|
380
|
+
for (const listener of this.#changeListeners) listener(change);
|
|
381
|
+
}
|
|
382
|
+
#rootFunction(name, implementation) {
|
|
383
|
+
const key = `${ROOT_KEY}.${name}`;
|
|
384
|
+
const existing = this.#functions.get(key);
|
|
385
|
+
if (existing) return existing;
|
|
386
|
+
this.#functions.set(key, implementation);
|
|
387
|
+
return implementation;
|
|
388
|
+
}
|
|
389
|
+
#wrapProperty(parent, member, value) {
|
|
390
|
+
if (!isProxyCandidate(value)) return value;
|
|
391
|
+
const stable = this.#stableLocator(value);
|
|
392
|
+
return this.wrap(stable ?? propertyLocator(parent, member));
|
|
393
|
+
}
|
|
394
|
+
#wrapReturn(parent, member, value) {
|
|
395
|
+
if (isPromiseLike(value)) {
|
|
396
|
+
return value.then((resolved) => this.#wrapReturn(parent, member, resolved));
|
|
397
|
+
}
|
|
398
|
+
if (!isProxyCandidate(value)) return value;
|
|
399
|
+
const stable = this.#stableLocator(value);
|
|
400
|
+
if (stable) return this.wrap(stable);
|
|
401
|
+
if (isRangeLike(value)) return this.wrap(rangeLocator(value));
|
|
402
|
+
return value;
|
|
403
|
+
}
|
|
404
|
+
#stableLocator(value) {
|
|
405
|
+
const id = Reflect.get(value, "id");
|
|
406
|
+
if (typeof id !== "string") return null;
|
|
407
|
+
const root = this.#root;
|
|
408
|
+
if (typeof root.resolve !== "function") return null;
|
|
409
|
+
try {
|
|
410
|
+
if (root.resolve(id) !== value) return null;
|
|
411
|
+
} catch {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
414
|
+
return {
|
|
415
|
+
key: `id:${id}`,
|
|
416
|
+
resolve: (candidateRoot) => {
|
|
417
|
+
const resolve = candidateRoot.resolve;
|
|
418
|
+
if (typeof resolve !== "function") throw new Error(`Artifact cannot resolve ${id}`);
|
|
419
|
+
return resolve.call(candidateRoot, id);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
#arrayIterator(locator, owner) {
|
|
424
|
+
const current = () => locator.resolve(this.#root);
|
|
425
|
+
const wrap = (index, value) => this.#wrapProperty(locator, String(index), value);
|
|
426
|
+
return function* iterator() {
|
|
427
|
+
for (let index = 0; index < owner.length; index += 1) {
|
|
428
|
+
const currentArray = current();
|
|
429
|
+
if (!Array.isArray(currentArray) || index >= currentArray.length) return;
|
|
430
|
+
yield wrap(index, currentArray[index]);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
#arrayCallbackArguments(locator, args) {
|
|
435
|
+
if (typeof args[0] !== "function") return args.map(unwrapArtifactValue);
|
|
436
|
+
const callback = args[0];
|
|
437
|
+
const thisArg = args[1];
|
|
438
|
+
const wrapChild = (index, value) => this.#wrapProperty(locator, String(index), value);
|
|
439
|
+
const wrappedArray = () => this.wrap(locator);
|
|
440
|
+
const wrappedCallback = function(value, index) {
|
|
441
|
+
const child = typeof index === "number" ? wrapChild(index, value) : value;
|
|
442
|
+
return callback.call(thisArg ?? this, child, index, wrappedArray());
|
|
443
|
+
};
|
|
444
|
+
return [wrappedCallback, thisArg];
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
function stateOf(value) {
|
|
448
|
+
if (!isObject(value)) return null;
|
|
449
|
+
return PROXY_METADATA.get(value)?.state ?? null;
|
|
450
|
+
}
|
|
451
|
+
function requireCompositeState(value, modality) {
|
|
452
|
+
const state = stateOf(value);
|
|
453
|
+
if (!state) throw new TypeError("Expected an artifact created by the production facade");
|
|
454
|
+
state.assertUsable();
|
|
455
|
+
if (modality && state.modality !== modality) {
|
|
456
|
+
throw new TypeError(`Expected a ${modality} artifact`);
|
|
457
|
+
}
|
|
458
|
+
return state;
|
|
459
|
+
}
|
|
460
|
+
function unwrapArtifactValue(value) {
|
|
461
|
+
if (!isObject(value)) return value;
|
|
462
|
+
const metadata = PROXY_METADATA.get(value);
|
|
463
|
+
if (metadata) return metadata.locator.resolve(metadata.state.rawRoot());
|
|
464
|
+
if (Array.isArray(value)) return value.map(unwrapArtifactValue);
|
|
465
|
+
if (!isPlainObject(value)) return value;
|
|
466
|
+
const output = {};
|
|
467
|
+
for (const key of Reflect.ownKeys(value))
|
|
468
|
+
output[key] = unwrapArtifactValue(Reflect.get(value, key));
|
|
469
|
+
return output;
|
|
470
|
+
}
|
|
471
|
+
function rootLocator() {
|
|
472
|
+
return { key: ROOT_KEY, resolve: (root) => root };
|
|
473
|
+
}
|
|
474
|
+
function propertyLocator(parent, member) {
|
|
475
|
+
return {
|
|
476
|
+
key: `${parent.key}.${propertyKey(member)}`,
|
|
477
|
+
resolve(root) {
|
|
478
|
+
const owner = parent.resolve(root);
|
|
479
|
+
if (!isObject(owner)) throw new Error("Artifact parent object no longer exists");
|
|
480
|
+
return Reflect.get(owner, member, owner);
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
function rangeLocator(range) {
|
|
485
|
+
const worksheet = Reflect.get(range, "worksheet");
|
|
486
|
+
const address = Reflect.get(range, "address");
|
|
487
|
+
if (typeof worksheet?.id !== "string" || !Number.isInteger(address?.row) || !Number.isInteger(address?.col) || !Number.isInteger(address?.rowCount) || !Number.isInteger(address?.colCount)) {
|
|
488
|
+
throw new Error("Cannot locate spreadsheet range");
|
|
489
|
+
}
|
|
490
|
+
const row = address.row;
|
|
491
|
+
const col = address.col;
|
|
492
|
+
const rowCount = address.rowCount;
|
|
493
|
+
const colCount = address.colCount;
|
|
494
|
+
const sheetId = worksheet.id;
|
|
495
|
+
return {
|
|
496
|
+
key: `range:${sheetId}:${row}:${col}:${rowCount}:${colCount}`,
|
|
497
|
+
resolve(root) {
|
|
498
|
+
const workbook = root;
|
|
499
|
+
const sheet = workbook.resolve?.(sheetId);
|
|
500
|
+
if (!sheet || typeof sheet.getRangeByIndexes !== "function") {
|
|
501
|
+
throw new Error(`Worksheet no longer exists: ${sheetId}`);
|
|
502
|
+
}
|
|
503
|
+
return sheet.getRangeByIndexes(row, col, rowCount, colCount);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
function isRangeLike(value) {
|
|
508
|
+
const address = Reflect.get(value, "address");
|
|
509
|
+
const worksheet = Reflect.get(value, "worksheet");
|
|
510
|
+
return isObject(address) && isObject(worksheet) && typeof Reflect.get(worksheet, "id") === "string";
|
|
511
|
+
}
|
|
512
|
+
function isProxyCandidate(value) {
|
|
513
|
+
if (!isObject(value)) return false;
|
|
514
|
+
if (value instanceof Date || value instanceof RegExp || value instanceof ArrayBuffer || ArrayBuffer.isView(value) || value instanceof Blob || value instanceof Map || value instanceof Set || value instanceof Promise || Object.isFrozen(value)) {
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
return true;
|
|
518
|
+
}
|
|
519
|
+
function cloneProjectionGraph(root) {
|
|
520
|
+
return cloneGraph(root, /* @__PURE__ */ new Map());
|
|
521
|
+
}
|
|
522
|
+
function cloneGraph(value, seen) {
|
|
523
|
+
if (!isObject(value) || typeof value === "function") return value;
|
|
524
|
+
const known = seen.get(value);
|
|
525
|
+
if (known !== void 0) return known;
|
|
526
|
+
if (value instanceof Date) return new Date(value.getTime());
|
|
527
|
+
if (value instanceof RegExp) return new RegExp(value.source, value.flags);
|
|
528
|
+
if (value instanceof ArrayBuffer) return value.slice(0);
|
|
529
|
+
if (ArrayBuffer.isView(value)) {
|
|
530
|
+
if (value instanceof DataView) {
|
|
531
|
+
return new DataView(
|
|
532
|
+
value.buffer.slice(value.byteOffset, value.byteOffset + value.byteLength)
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
const constructor = value.constructor;
|
|
536
|
+
return new constructor(value);
|
|
537
|
+
}
|
|
538
|
+
if (value instanceof Blob) return value.slice(0, value.size, value.type);
|
|
539
|
+
if (value instanceof Map) {
|
|
540
|
+
const output2 = /* @__PURE__ */ new Map();
|
|
541
|
+
seen.set(value, output2);
|
|
542
|
+
for (const [key, entry] of value) output2.set(cloneGraph(key, seen), cloneGraph(entry, seen));
|
|
543
|
+
return output2;
|
|
544
|
+
}
|
|
545
|
+
if (value instanceof Set) {
|
|
546
|
+
const output2 = /* @__PURE__ */ new Set();
|
|
547
|
+
seen.set(value, output2);
|
|
548
|
+
for (const entry of value) output2.add(cloneGraph(entry, seen));
|
|
549
|
+
return output2;
|
|
550
|
+
}
|
|
551
|
+
if (value instanceof WeakMap || value instanceof WeakSet || value instanceof Promise)
|
|
552
|
+
return value;
|
|
553
|
+
const output = Array.isArray(value) ? [] : Object.create(Object.getPrototypeOf(value));
|
|
554
|
+
seen.set(value, output);
|
|
555
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
556
|
+
if (Array.isArray(value) && key === "length") continue;
|
|
557
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(value, key);
|
|
558
|
+
if (!descriptor) continue;
|
|
559
|
+
if ("value" in descriptor) descriptor.value = cloneGraph(descriptor.value, seen);
|
|
560
|
+
Reflect.defineProperty(output, key, descriptor);
|
|
561
|
+
}
|
|
562
|
+
if (Object.isFrozen(value)) Object.freeze(output);
|
|
563
|
+
else if (Object.isSealed(value)) Object.seal(output);
|
|
564
|
+
else if (!Object.isExtensible(value)) Object.preventExtensions(output);
|
|
565
|
+
return output;
|
|
566
|
+
}
|
|
567
|
+
function safeRevision(value) {
|
|
568
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
569
|
+
throw new RangeError("Native artifact revision exceeds the JavaScript safe-integer range");
|
|
570
|
+
}
|
|
571
|
+
return Number(value);
|
|
572
|
+
}
|
|
573
|
+
function propertyKey(value) {
|
|
574
|
+
return typeof value === "symbol" ? `symbol:${value.description ?? ""}` : String(value);
|
|
575
|
+
}
|
|
576
|
+
function isPromiseLike(value) {
|
|
577
|
+
return isObject(value) && typeof Reflect.get(value, "then") === "function";
|
|
578
|
+
}
|
|
579
|
+
function isObject(value) {
|
|
580
|
+
return typeof value === "object" && value !== null || typeof value === "function";
|
|
581
|
+
}
|
|
582
|
+
function isPlainObject(value) {
|
|
583
|
+
const prototype = Object.getPrototypeOf(value);
|
|
584
|
+
return prototype === Object.prototype || prototype === null;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
export {
|
|
588
|
+
CompositeArtifactState,
|
|
589
|
+
requireCompositeState
|
|
590
|
+
};
|
|
591
|
+
//# sourceMappingURL=chunk-HTJBLBDE.js.map
|