@powerhousedao/shared 6.0.2-staging.7 → 6.0.2-staging.9
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/dist/actions-UH5nIJcP.d.ts +21068 -0
- package/dist/actions-UH5nIJcP.d.ts.map +1 -0
- package/dist/clis/args/access-token.mjs +1 -1
- package/dist/clis/args/{common-Bc8EcW9w.mjs → common-DPYlcz-d.mjs} +7 -1
- package/dist/clis/args/common-DPYlcz-d.mjs.map +1 -0
- package/dist/clis/args/common.mjs +1 -1
- package/dist/clis/args/connect.mjs +1 -1
- package/dist/clis/args/{generate-DNGRYRdp.mjs → generate-BJPBa0mK.mjs} +2 -2
- package/dist/clis/args/{generate-DNGRYRdp.mjs.map → generate-BJPBa0mK.mjs.map} +1 -1
- package/dist/clis/args/generate.mjs +1 -1
- package/dist/clis/args/{help-CFAVJzhI.mjs → help-rztSuf9S.mjs} +3 -3
- package/dist/clis/args/{help-CFAVJzhI.mjs.map → help-rztSuf9S.mjs.map} +1 -1
- package/dist/clis/args/help.mjs +1 -1
- package/dist/clis/args/index.d.mts +1 -1
- package/dist/clis/args/index.mjs +3 -3
- package/dist/clis/args/init.mjs +1 -1
- package/dist/clis/args/inspect.mjs +1 -1
- package/dist/clis/args/install.mjs +1 -1
- package/dist/clis/args/list.mjs +1 -1
- package/dist/clis/args/login.mjs +1 -1
- package/dist/clis/args/migrate.mjs +1 -1
- package/dist/clis/args/publish.mjs +1 -1
- package/dist/clis/args/registry.mjs +1 -1
- package/dist/clis/args/service-LXIFUZ_8.d.mts +106 -0
- package/dist/clis/args/service-LXIFUZ_8.d.mts.map +1 -0
- package/dist/clis/args/service.d.mts +1 -1
- package/dist/clis/args/service.mjs +1 -1
- package/dist/clis/args/switchboard.mjs +1 -1
- package/dist/clis/args/uninstall.mjs +1 -1
- package/dist/clis/args/unpublish.mjs +1 -1
- package/dist/clis/args/vetra.d.mts +3 -0
- package/dist/clis/args/vetra.d.mts.map +1 -1
- package/dist/clis/args/vetra.mjs +6 -1
- package/dist/clis/args/vetra.mjs.map +1 -1
- package/dist/clis/constants.d.mts +248 -1
- package/dist/clis/constants.d.mts.map +1 -1
- package/dist/clis/constants.mjs +139 -9
- package/dist/clis/constants.mjs.map +1 -1
- package/dist/clis/index.d.mts +275 -9
- package/dist/clis/index.d.mts.map +1 -1
- package/dist/clis/index.mjs +176 -15
- package/dist/clis/index.mjs.map +1 -1
- package/dist/clis/utils.d.mts +11 -1
- package/dist/clis/utils.d.mts.map +1 -1
- package/dist/clis/utils.mjs +17 -2
- package/dist/clis/utils.mjs.map +1 -1
- package/dist/document-drive/index.d.ts +2 -2
- package/dist/document-model/index.d.ts +3 -3
- package/dist/document-model/index.js +133 -54
- package/dist/document-model/index.js.map +1 -1
- package/dist/{index-dcU9nj_u.d.ts → index-DhPr5zSB.d.ts} +5 -6
- package/dist/index-DhPr5zSB.d.ts.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/processors/index.d.ts +1 -1
- package/dist/registry/index.d.ts +1 -1
- package/dist/registry/index.js +6 -0
- package/dist/registry/index.js.map +1 -1
- package/dist/{types-DyMP31mD.d.ts → types-WzwAClp2.d.ts} +2 -2
- package/dist/{types-DyMP31mD.d.ts.map → types-WzwAClp2.d.ts.map} +1 -1
- package/package.json +3 -3
- package/dist/actions-_5ZcthYq.d.ts +0 -2444
- package/dist/actions-_5ZcthYq.d.ts.map +0 -1
- package/dist/clis/args/common-Bc8EcW9w.mjs.map +0 -1
- package/dist/clis/args/service-C88bN_g_.d.mts +0 -22
- package/dist/clis/args/service-C88bN_g_.d.mts.map +0 -1
- package/dist/index-dcU9nj_u.d.ts.map +0 -1
|
@@ -2,6 +2,7 @@ import { a as buildOperationSignatureParams, c as hex2ab, i as buildOperationSig
|
|
|
2
2
|
import { generateMock } from "./mock.js";
|
|
3
3
|
import { ZodError, z } from "zod";
|
|
4
4
|
import { stringify } from "safe-stable-stringify";
|
|
5
|
+
import { strFromU8, strToU8, unzip, zip } from "fflate";
|
|
5
6
|
import { castDraft, create, unsafe } from "mutative";
|
|
6
7
|
import { pascalCase } from "change-case";
|
|
7
8
|
//#region document-model/errors.ts
|
|
@@ -57,6 +58,7 @@ const Load_StateSchema = z.enum(["LOAD_STATE"]);
|
|
|
57
58
|
const PruneSchema = z.enum(["PRUNE"]);
|
|
58
59
|
const RedoSchema = z.enum(["REDO"]);
|
|
59
60
|
const Set_NameSchema = z.enum(["SET_NAME"]);
|
|
61
|
+
const Set_PreferredEditorSchema = z.enum(["SET_PREFERRED_EDITOR"]);
|
|
60
62
|
const UndoSchema = z.enum(["UNDO"]);
|
|
61
63
|
function OperationScopeSchema() {
|
|
62
64
|
return z.string();
|
|
@@ -67,6 +69,7 @@ function DocumentActionSchema() {
|
|
|
67
69
|
PruneActionSchema(),
|
|
68
70
|
RedoActionSchema(),
|
|
69
71
|
SetNameActionSchema(),
|
|
72
|
+
SetPreferredEditorActionSchema(),
|
|
70
73
|
UndoActionSchema()
|
|
71
74
|
]);
|
|
72
75
|
}
|
|
@@ -139,6 +142,18 @@ function SetNameActionSchema() {
|
|
|
139
142
|
scope: z.literal("global")
|
|
140
143
|
});
|
|
141
144
|
}
|
|
145
|
+
function SetPreferredEditorActionInputSchema() {
|
|
146
|
+
return z.object({ preferredEditor: z.string().nullable() });
|
|
147
|
+
}
|
|
148
|
+
function SetPreferredEditorActionSchema() {
|
|
149
|
+
return z.object({
|
|
150
|
+
id: z.string(),
|
|
151
|
+
timestampUtcMs: z.string().datetime(),
|
|
152
|
+
input: SetPreferredEditorActionInputSchema(),
|
|
153
|
+
type: Set_PreferredEditorSchema,
|
|
154
|
+
scope: z.literal("header")
|
|
155
|
+
});
|
|
156
|
+
}
|
|
142
157
|
function UndoActionInputSchema() {
|
|
143
158
|
return z.object({ count: z.number() });
|
|
144
159
|
}
|
|
@@ -289,29 +304,29 @@ function DocumentModelInputSchema() {
|
|
|
289
304
|
function DocumentModelGlobalStateSchema() {
|
|
290
305
|
return z.object({
|
|
291
306
|
__typename: z.literal("DocumentModelGlobalState").optional(),
|
|
292
|
-
author: AuthorSchema(),
|
|
293
|
-
description: z.string(),
|
|
294
|
-
extension: z.string(),
|
|
295
307
|
id: z.string(),
|
|
296
308
|
name: z.string(),
|
|
309
|
+
author: AuthorSchema(),
|
|
310
|
+
extension: z.string(),
|
|
311
|
+
description: z.string(),
|
|
297
312
|
specifications: z.array(DocumentSpecificationSchema())
|
|
298
313
|
});
|
|
299
314
|
}
|
|
300
315
|
function DocumentSpecificationSchema() {
|
|
301
316
|
return z.object({
|
|
302
317
|
__typename: z.literal("DocumentSpecification").optional(),
|
|
303
|
-
changeLog: z.array(z.string()),
|
|
304
|
-
modules: z.array(ModuleSchema()),
|
|
305
318
|
state: ScopeStateSchema(),
|
|
306
|
-
|
|
319
|
+
modules: z.array(ModuleSchema()),
|
|
320
|
+
version: z.number().int(),
|
|
321
|
+
changeLog: z.array(z.string())
|
|
307
322
|
});
|
|
308
323
|
}
|
|
309
324
|
function ModuleSchema() {
|
|
310
325
|
return z.object({
|
|
311
326
|
__typename: z.literal("ModuleSpecification").optional(),
|
|
312
|
-
description: z.string().nullable(),
|
|
313
327
|
id: z.string(),
|
|
314
328
|
name: z.string(),
|
|
329
|
+
description: z.string().nullable(),
|
|
315
330
|
operations: z.array(OperationSpecificationSchema())
|
|
316
331
|
});
|
|
317
332
|
}
|
|
@@ -324,24 +339,24 @@ function MoveOperationInputSchema() {
|
|
|
324
339
|
function OperationSpecificationSchema() {
|
|
325
340
|
return z.object({
|
|
326
341
|
__typename: z.literal("OperationSpecification").optional(),
|
|
327
|
-
description: z.string().nullable(),
|
|
328
|
-
errors: z.array(OperationErrorSchema()),
|
|
329
|
-
examples: z.array(CodeExampleSchema()),
|
|
330
342
|
id: z.string(),
|
|
331
343
|
name: z.string().nullable(),
|
|
332
|
-
|
|
344
|
+
description: z.string().nullable(),
|
|
333
345
|
schema: z.string().nullable(),
|
|
334
346
|
template: z.string().nullable(),
|
|
347
|
+
reducer: z.string().nullable(),
|
|
348
|
+
errors: z.array(OperationErrorSchema()),
|
|
349
|
+
examples: z.array(CodeExampleSchema()),
|
|
335
350
|
scope: OperationScopeSchema()
|
|
336
351
|
});
|
|
337
352
|
}
|
|
338
353
|
function OperationErrorSchema() {
|
|
339
354
|
return z.object({
|
|
340
355
|
__typename: z.literal("OperationErrorSpecification").optional(),
|
|
341
|
-
code: z.string().nullable(),
|
|
342
|
-
description: z.string().nullable(),
|
|
343
356
|
id: z.string(),
|
|
344
357
|
name: z.string().nullable(),
|
|
358
|
+
code: z.string().nullable(),
|
|
359
|
+
description: z.string().nullable(),
|
|
345
360
|
template: z.string().nullable()
|
|
346
361
|
});
|
|
347
362
|
}
|
|
@@ -483,15 +498,15 @@ function SetStateSchemaInputSchema() {
|
|
|
483
498
|
function StateSchema() {
|
|
484
499
|
return z.object({
|
|
485
500
|
__typename: z.literal("State").optional(),
|
|
501
|
+
schema: z.string(),
|
|
486
502
|
examples: z.array(CodeExampleSchema()),
|
|
487
|
-
initialValue: z.string()
|
|
488
|
-
schema: z.string()
|
|
503
|
+
initialValue: z.string()
|
|
489
504
|
});
|
|
490
505
|
}
|
|
491
506
|
function ScopeStateSchema() {
|
|
492
507
|
return z.object({
|
|
493
|
-
|
|
494
|
-
|
|
508
|
+
local: StateSchema(),
|
|
509
|
+
global: StateSchema()
|
|
495
510
|
});
|
|
496
511
|
}
|
|
497
512
|
function UpdateChangeLogItemInputSchema() {
|
|
@@ -714,6 +729,14 @@ async function verifyOperationSignature(signature, signer, verifyHandler) {
|
|
|
714
729
|
* @category Actions
|
|
715
730
|
*/
|
|
716
731
|
const setName = (name) => createAction("SET_NAME", typeof name === "string" ? { name } : name, void 0, SetNameActionInputSchema, "global");
|
|
732
|
+
/**
|
|
733
|
+
* Changes the preferred editor recorded in the document header meta.
|
|
734
|
+
*
|
|
735
|
+
* Passing `null` clears the preferred editor.
|
|
736
|
+
*
|
|
737
|
+
* @category Actions
|
|
738
|
+
*/
|
|
739
|
+
const setPreferredEditor = (input) => createAction("SET_PREFERRED_EDITOR", typeof input === "object" && input !== null ? input : { preferredEditor: input }, void 0, SetPreferredEditorActionInputSchema, "header");
|
|
717
740
|
const setModelName = (input) => createAction("SET_MODEL_NAME", { ...input }, void 0, SetModelNameInputSchema, "global");
|
|
718
741
|
const setModelId = (input) => createAction("SET_MODEL_ID", { ...input }, void 0, SetModelIdInputSchema, "global");
|
|
719
742
|
const setModelExtension = (input) => createAction("SET_MODEL_EXTENSION", { ...input }, void 0, SetModelExtensionInputSchema, "global");
|
|
@@ -765,6 +788,7 @@ const reorderChangeLogItems = (input) => createAction("REORDER_CHANGE_LOG_ITEMS"
|
|
|
765
788
|
const releaseNewVersion = () => createAction("RELEASE_NEW_VERSION", {}, void 0, void 0, "global");
|
|
766
789
|
const baseActions = {
|
|
767
790
|
setName,
|
|
791
|
+
setPreferredEditor,
|
|
768
792
|
undo,
|
|
769
793
|
redo,
|
|
770
794
|
prune,
|
|
@@ -1616,6 +1640,7 @@ function isUndo(action) {
|
|
|
1616
1640
|
function isDocumentAction(action) {
|
|
1617
1641
|
return [
|
|
1618
1642
|
"SET_NAME",
|
|
1643
|
+
"SET_PREFERRED_EDITOR",
|
|
1619
1644
|
"UNDO",
|
|
1620
1645
|
"REDO",
|
|
1621
1646
|
"PRUNE",
|
|
@@ -2211,6 +2236,27 @@ function setNameOperation(document, input) {
|
|
|
2211
2236
|
}
|
|
2212
2237
|
};
|
|
2213
2238
|
}
|
|
2239
|
+
function setPreferredEditorOperation(document, input) {
|
|
2240
|
+
const existingMeta = document.header.meta ?? {};
|
|
2241
|
+
if (input.preferredEditor) return {
|
|
2242
|
+
...document,
|
|
2243
|
+
header: {
|
|
2244
|
+
...document.header,
|
|
2245
|
+
meta: {
|
|
2246
|
+
...existingMeta,
|
|
2247
|
+
preferredEditor: input.preferredEditor
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
};
|
|
2251
|
+
const { preferredEditor: _removed, ...rest } = existingMeta;
|
|
2252
|
+
return {
|
|
2253
|
+
...document,
|
|
2254
|
+
header: {
|
|
2255
|
+
...document.header,
|
|
2256
|
+
meta: rest
|
|
2257
|
+
}
|
|
2258
|
+
};
|
|
2259
|
+
}
|
|
2214
2260
|
function undoOperation(document, action, skip) {
|
|
2215
2261
|
const { scope } = action;
|
|
2216
2262
|
return create({
|
|
@@ -2372,6 +2418,7 @@ function _baseReducer(document, action, wrappedReducer) {
|
|
|
2372
2418
|
const parsedAction = DocumentActionSchema().parse(action);
|
|
2373
2419
|
switch (parsedAction.type) {
|
|
2374
2420
|
case "SET_NAME": return setNameOperation(document, parsedAction.input);
|
|
2421
|
+
case "SET_PREFERRED_EDITOR": return setPreferredEditorOperation(document, parsedAction.input);
|
|
2375
2422
|
case "PRUNE": return pruneOperation(document, parsedAction.input, wrappedReducer);
|
|
2376
2423
|
case "LOAD_STATE": return loadStateOperation(document, parsedAction.input);
|
|
2377
2424
|
default: return document;
|
|
@@ -2517,16 +2564,16 @@ function baseReducer(document, action, customReducer, dispatch, options = {}) {
|
|
|
2517
2564
|
});
|
|
2518
2565
|
} catch (error) {
|
|
2519
2566
|
const actionScopeOps = newDocument.operations[_action.scope];
|
|
2520
|
-
if (!actionScopeOps) throw new Error(`No operations found for scope: ${_action.scope}
|
|
2567
|
+
if (!actionScopeOps) throw new Error(`No operations found for scope: ${_action.scope}`, { cause: error });
|
|
2521
2568
|
const lastOperationIndex = actionScopeOps.length - 1;
|
|
2522
2569
|
const draftScopeOps = draft.operations[_action.scope];
|
|
2523
|
-
if (!draftScopeOps) throw new Error(`No operations found in draft for scope: ${_action.scope}
|
|
2570
|
+
if (!draftScopeOps) throw new Error(`No operations found in draft for scope: ${_action.scope}`, { cause: error });
|
|
2524
2571
|
draftScopeOps[lastOperationIndex].error = error.message;
|
|
2525
2572
|
draftScopeOps[lastOperationIndex].skip = 0;
|
|
2526
2573
|
if (shouldProcessSkipOperation) {
|
|
2527
2574
|
draft.state = castDraft({ ...document.state });
|
|
2528
2575
|
const documentScopeOps = document.operations[_action.scope];
|
|
2529
|
-
if (!documentScopeOps) throw new Error(`No operations found for scope: ${_action.scope}
|
|
2576
|
+
if (!documentScopeOps) throw new Error(`No operations found for scope: ${_action.scope}`, { cause: error });
|
|
2530
2577
|
draft.operations = castDraft({
|
|
2531
2578
|
...document.operations,
|
|
2532
2579
|
[_action.scope]: [...documentScopeOps, { ...draftScopeOps[lastOperationIndex] }]
|
|
@@ -2625,6 +2672,7 @@ const RESERVED_OPERATION_NAMES = [
|
|
|
2625
2672
|
"PRUNE",
|
|
2626
2673
|
"LOAD_STATE",
|
|
2627
2674
|
"SET_NAME",
|
|
2675
|
+
"SET_PREFERRED_EDITOR",
|
|
2628
2676
|
"NOOP"
|
|
2629
2677
|
];
|
|
2630
2678
|
/**
|
|
@@ -3190,18 +3238,50 @@ const documentModelReducer = createReducer(documentModelStateReducer);
|
|
|
3190
3238
|
//#endregion
|
|
3191
3239
|
//#region document-model/files.ts
|
|
3192
3240
|
const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3241
|
+
function zipAsync(data) {
|
|
3242
|
+
return new Promise((resolve, reject) => {
|
|
3243
|
+
zip(data, (err, out) => err ? reject(err) : resolve(out));
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
function unzipAsync(data) {
|
|
3247
|
+
return new Promise((resolve, reject) => {
|
|
3248
|
+
unzip(data, (err, out) => err ? reject(err) : resolve(out));
|
|
3249
|
+
});
|
|
3250
|
+
}
|
|
3251
|
+
const BASE64_RE = /^[A-Za-z0-9+/]+={0,2}$/;
|
|
3252
|
+
function isLikelyBase64(s) {
|
|
3253
|
+
if (s.length === 0 || s.length % 4 !== 0) return false;
|
|
3254
|
+
return BASE64_RE.test(s);
|
|
3255
|
+
}
|
|
3256
|
+
function binaryStringToUint8Array(s) {
|
|
3257
|
+
const arr = new Uint8Array(s.length);
|
|
3258
|
+
for (let i = 0; i < s.length; i++) arr[i] = s.charCodeAt(i) & 255;
|
|
3259
|
+
return arr;
|
|
3260
|
+
}
|
|
3261
|
+
function base64ToUint8Array(s) {
|
|
3262
|
+
if (typeof atob === "function") return binaryStringToUint8Array(atob(s));
|
|
3263
|
+
const BufferCtor = globalThis.Buffer;
|
|
3264
|
+
if (!BufferCtor) throw new Error("Cannot decode base64 string: neither `atob` nor `Buffer` is available in this environment");
|
|
3265
|
+
return BufferCtor.from(s, "base64");
|
|
3266
|
+
}
|
|
3267
|
+
async function toUint8Array(input) {
|
|
3268
|
+
if (input instanceof Uint8Array) return input;
|
|
3269
|
+
if (input instanceof ArrayBuffer) return new Uint8Array(input);
|
|
3270
|
+
if (typeof Blob !== "undefined" && input instanceof Blob) return new Uint8Array(await input.arrayBuffer());
|
|
3271
|
+
if (Array.isArray(input)) return new Uint8Array(input);
|
|
3272
|
+
if (typeof input === "string") return isLikelyBase64(input) ? base64ToUint8Array(input) : binaryStringToUint8Array(input);
|
|
3273
|
+
throw new Error("Unsupported FileInput type");
|
|
3274
|
+
}
|
|
3275
|
+
function jsonEntry(value) {
|
|
3276
|
+
return strToU8(JSON.stringify(value, null, 2));
|
|
3196
3277
|
}
|
|
3197
3278
|
async function createZip(document) {
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
return zip;
|
|
3279
|
+
return zipAsync({
|
|
3280
|
+
"header.json": jsonEntry(document.header),
|
|
3281
|
+
"state.json": jsonEntry(document.initialState || {}),
|
|
3282
|
+
"current-state.json": jsonEntry(document.state || {}),
|
|
3283
|
+
"operations.json": jsonEntry(filterDocumentOperationsResultingState(document.operations))
|
|
3284
|
+
});
|
|
3205
3285
|
}
|
|
3206
3286
|
/**
|
|
3207
3287
|
* Creates a minimal ZIP backup from strand data.
|
|
@@ -3209,7 +3289,6 @@ async function createZip(document) {
|
|
|
3209
3289
|
* Creates a ZIP with minimal header and empty operations.
|
|
3210
3290
|
*/
|
|
3211
3291
|
async function createMinimalZip(data) {
|
|
3212
|
-
const JSZip = await loadJSZip();
|
|
3213
3292
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3214
3293
|
const header = {
|
|
3215
3294
|
id: data.documentId,
|
|
@@ -3225,30 +3304,32 @@ async function createMinimalZip(data) {
|
|
|
3225
3304
|
revision: {},
|
|
3226
3305
|
lastModifiedAtUtcIso: now
|
|
3227
3306
|
};
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3307
|
+
return zipAsync({
|
|
3308
|
+
"header.json": jsonEntry(header),
|
|
3309
|
+
"state.json": jsonEntry(data.state),
|
|
3310
|
+
"current-state.json": jsonEntry(data.state),
|
|
3311
|
+
"operations.json": jsonEntry({})
|
|
3312
|
+
});
|
|
3234
3313
|
}
|
|
3235
3314
|
async function baseSaveToFileHandle(document, input) {
|
|
3236
|
-
const
|
|
3315
|
+
const data = await createZip(document);
|
|
3237
3316
|
const writable = await input.createWritable();
|
|
3238
|
-
await writable.write(
|
|
3317
|
+
await writable.write(new Uint8Array(data));
|
|
3239
3318
|
await writable.close();
|
|
3240
3319
|
}
|
|
3241
|
-
|
|
3242
|
-
const
|
|
3243
|
-
if (!
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
const
|
|
3250
|
-
if (!
|
|
3251
|
-
const
|
|
3320
|
+
function readEntry(files, name) {
|
|
3321
|
+
const entry = files[name];
|
|
3322
|
+
if (!entry) throw new Error(`${name} not found in document zip`);
|
|
3323
|
+
return strFromU8(entry);
|
|
3324
|
+
}
|
|
3325
|
+
async function loadFromZipData(data, reducer, options) {
|
|
3326
|
+
const files = await unzipAsync(data);
|
|
3327
|
+
if (!files["state.json"]) throw new Error("Initial state not found");
|
|
3328
|
+
const initialState = JSON.parse(readEntry(files, "state.json"));
|
|
3329
|
+
if (!files["header.json"]) throw new Error("Document header not found - file format may be outdated");
|
|
3330
|
+
const header = JSON.parse(readEntry(files, "header.json"));
|
|
3331
|
+
if (!files["operations.json"]) throw new Error("Operations history not found");
|
|
3332
|
+
const clearedOperations = garbageCollectDocumentOperations(JSON.parse(readEntry(files, "operations.json")));
|
|
3252
3333
|
const operationsError = validateOperations(clearedOperations);
|
|
3253
3334
|
if (operationsError.length) {
|
|
3254
3335
|
const errorMessages = operationsError.map((err) => err.message);
|
|
@@ -3260,9 +3341,7 @@ async function loadFromZip(zip, reducer, options) {
|
|
|
3260
3341
|
};
|
|
3261
3342
|
}
|
|
3262
3343
|
async function baseLoadFromInput(input, reducer, options) {
|
|
3263
|
-
|
|
3264
|
-
await zip.loadAsync(input);
|
|
3265
|
-
return loadFromZip(zip, reducer, options);
|
|
3344
|
+
return loadFromZipData(await toUint8Array(input), reducer, options);
|
|
3266
3345
|
}
|
|
3267
3346
|
const documentModelLoadFromInput = (input) => {
|
|
3268
3347
|
return baseLoadFromInput(input, documentModelReducer);
|
|
@@ -3382,6 +3461,6 @@ function createState(baseState, globalState, localState) {
|
|
|
3382
3461
|
};
|
|
3383
3462
|
}
|
|
3384
3463
|
//#endregion
|
|
3385
|
-
export { AddChangeLogItemInputSchema, AddModuleInputSchema, AddOperationErrorInputSchema, AddOperationExampleInputSchema, AddOperationInputSchema, AddStateExampleInputSchema, AuthorSchema, BaseDocumentHeaderSchema, BaseDocumentStateSchema, CodeExampleSchema, ConfigEntrySchema, ConfigEntryTypeSchema, DeleteChangeLogItemInputSchema, DeleteModuleInputSchema, DeleteOperationErrorInputSchema, DeleteOperationExampleInputSchema, DeleteOperationInputSchema, DeleteStateExampleInputSchema, DocumentActionSchema, DocumentFileSchema, DocumentModelGlobalStateSchema, DocumentModelHeaderSchema, DocumentModelInputSchema, DocumentModelPHStateSchema, DocumentModelSchema, DocumentSpecificationSchema, FileSystemError, HASH_ALGORITHM_SHA1, HASH_ALGORITHM_SHA256, HASH_ALGORITHM_SHA512, HASH_ENCODING_BASE64, HASH_ENCODING_HEX, HashMismatchError, IntegrityIssueSubType, IntegrityIssueType, InvalidActionInputError, InvalidActionInputZodError, LoadStateActionInputSchema, LoadStateActionSchema, LoadStateActionStateInputSchema, Load_StateSchema, ManifestSchema, ModuleSchema, MoveOperationInputSchema, OperationErrorSchema, OperationScopeSchema, OperationSpecificationSchema, PowerhouseModuleSchema, PowerhouseModulesSchema, PruneActionInputSchema, PruneActionSchema, PruneSchema, PublisherSchema, RESERVED_OPERATION_NAMES, RedoActionInputSchema, RedoActionSchema, RedoSchema, ReorderChangeLogItemsInputSchema, ReorderModuleOperationsInputSchema, ReorderModulesInputSchema, ReorderOperationErrorsInputSchema, ReorderOperationExamplesInputSchema, ReorderStateExamplesInputSchema, ScopeStateSchema, SetAuthorNameInputSchema, SetAuthorWebsiteInputSchema, SetInitialStateInputSchema, SetModelDescriptionInputSchema, SetModelExtensionInputSchema, SetModelIdInputSchema, SetModelNameInputSchema, SetModuleDescriptionInputSchema, SetModuleNameInputSchema, SetNameActionInputSchema, SetNameActionSchema, SetOperationDescriptionInputSchema, SetOperationErrorCodeInputSchema, SetOperationErrorDescriptionInputSchema, SetOperationErrorNameInputSchema, SetOperationErrorTemplateInputSchema, SetOperationNameInputSchema, SetOperationReducerInputSchema, SetOperationSchemaInputSchema, SetOperationScopeInputSchema, SetOperationTemplateInputSchema, SetStateSchemaInputSchema, Set_NameSchema, StateSchema, UndoActionInputSchema, UndoActionSchema, UndoSchema, UpdateChangeLogItemInputSchema, UpdateOperationExampleInputSchema, UpdateStateExampleInputSchema, ab2hex, actionContext, actionFromAction, actionSigner, actions, addChangeLogItem, addModule, addOperation, addOperationError, addOperationExample, addStateExample, addUndo, assertIsDocumentModelDocument, assertIsDocumentModelState, attachBranch, baseActions, baseCreateDocument, baseLoadFromInput, baseReducer, baseSaveToFileHandle, buildOperationSignature, buildOperationSignatureMessage, buildOperationSignatureParams, buildSignedAction, checkCleanedOperationsIntegrity, checkOperationsIntegrity, createAction, createAuthState, createBaseState, createDocumentState, createGlobalState, createLocalState, createMinimalZip, createPresignedHeader, createReducer, createSignedHeader, createSignedHeaderForSigner, createState, createVerificationSigner, createZip, defaultAuthState, defaultBaseState, defaultDocumentState, defaultGlobalState, defaultLocalState, defaultPHState, definedNonNullAnySchema, deleteChangeLogItem, deleteModule, deleteOperation, deleteOperationError, deleteOperationExample, deleteStateExample, deriveOperationId, diffOperations, documentModelActions, documentModelDocumentType, documentModelFileExtension, documentModelGlobalState, documentModelHeaderReducer, documentModelInitialGlobalState, documentModelInitialLocalState, documentModelLoadFromInput, documentModelModuleReducer, documentModelOperationErrorReducer, documentModelOperationExampleReducer, documentModelOperationReducer, documentModelReducer, documentModelSaveToFileHandle, documentModelStateReducer, documentModelStateSchemaReducer, documentModelVersioningReducer, fetchFileBrowser, filterDocumentOperationsResultingState, filterDuplicatedOperations, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, generateId, generateMock, getAllOperationNames, getDocumentLastModified, getFileBrowser, getUnixTimestamp, groupOperationsByScope, hashBrowser, hashDocumentStateForScope, hex2ab, isDefinedNonNullAny, isDocumentAction, isDocumentModelDocument, isDocumentModelState, isNoopOperation, isReservedOperationName, isUndo, isUndoRedo, loadState, loadStateOperation, mapSkippedOperations, mapSkippedOperationsV2, merge, moveOperation, nextSkipNumber, noop, operationExampleCreators, operationFromAction, operationFromOperation, operationWithContext, operationsAreEqual, parseResultingState, precedes, prepareOperations, processUndoRedo, prune, pruneOperation, readFileBrowser, readOnly, redo, redoOperation, releaseNewVersion, removeExistingOperations, reorderChangeLogItems, reorderModuleOperations, reorderModules, reorderOperationErrors, reorderOperationExamples, reorderStateExamples, replayDocument, replayOperations, reshuffleByTimestamp, reshuffleByTimestampAndIndex, setAuthorName, setAuthorWebsite, setInitialState, setModelDescription, setModelExtension, setModelId, setModelName, setModuleDescription, setModuleName, setName, setNameOperation, setOperationDescription, setOperationErrorCode, setOperationErrorDescription, setOperationErrorName, setOperationErrorTemplate, setOperationName, setOperationReducer, setOperationSchema, setOperationScope, setOperationTemplate, setStateSchema, sign, skipHeaderOperations, sortMappedOperations, sortOperations, split, undo, undoOperation, undoOperationV2, updateChangeLogItem, updateDocument, updateHeaderRevision, updateOperationExample, updateStateExample, validateHeader, validateInitialState, validateModule, validateModuleOperation, validateModules, validateOperationName, validateOperations, validateStateSchemaName, verify, verifyOperationSignature, writeFileBrowser };
|
|
3464
|
+
export { AddChangeLogItemInputSchema, AddModuleInputSchema, AddOperationErrorInputSchema, AddOperationExampleInputSchema, AddOperationInputSchema, AddStateExampleInputSchema, AuthorSchema, BaseDocumentHeaderSchema, BaseDocumentStateSchema, CodeExampleSchema, ConfigEntrySchema, ConfigEntryTypeSchema, DeleteChangeLogItemInputSchema, DeleteModuleInputSchema, DeleteOperationErrorInputSchema, DeleteOperationExampleInputSchema, DeleteOperationInputSchema, DeleteStateExampleInputSchema, DocumentActionSchema, DocumentFileSchema, DocumentModelGlobalStateSchema, DocumentModelHeaderSchema, DocumentModelInputSchema, DocumentModelPHStateSchema, DocumentModelSchema, DocumentSpecificationSchema, FileSystemError, HASH_ALGORITHM_SHA1, HASH_ALGORITHM_SHA256, HASH_ALGORITHM_SHA512, HASH_ENCODING_BASE64, HASH_ENCODING_HEX, HashMismatchError, IntegrityIssueSubType, IntegrityIssueType, InvalidActionInputError, InvalidActionInputZodError, LoadStateActionInputSchema, LoadStateActionSchema, LoadStateActionStateInputSchema, Load_StateSchema, ManifestSchema, ModuleSchema, MoveOperationInputSchema, OperationErrorSchema, OperationScopeSchema, OperationSpecificationSchema, PowerhouseModuleSchema, PowerhouseModulesSchema, PruneActionInputSchema, PruneActionSchema, PruneSchema, PublisherSchema, RESERVED_OPERATION_NAMES, RedoActionInputSchema, RedoActionSchema, RedoSchema, ReorderChangeLogItemsInputSchema, ReorderModuleOperationsInputSchema, ReorderModulesInputSchema, ReorderOperationErrorsInputSchema, ReorderOperationExamplesInputSchema, ReorderStateExamplesInputSchema, ScopeStateSchema, SetAuthorNameInputSchema, SetAuthorWebsiteInputSchema, SetInitialStateInputSchema, SetModelDescriptionInputSchema, SetModelExtensionInputSchema, SetModelIdInputSchema, SetModelNameInputSchema, SetModuleDescriptionInputSchema, SetModuleNameInputSchema, SetNameActionInputSchema, SetNameActionSchema, SetOperationDescriptionInputSchema, SetOperationErrorCodeInputSchema, SetOperationErrorDescriptionInputSchema, SetOperationErrorNameInputSchema, SetOperationErrorTemplateInputSchema, SetOperationNameInputSchema, SetOperationReducerInputSchema, SetOperationSchemaInputSchema, SetOperationScopeInputSchema, SetOperationTemplateInputSchema, SetPreferredEditorActionInputSchema, SetPreferredEditorActionSchema, SetStateSchemaInputSchema, Set_NameSchema, Set_PreferredEditorSchema, StateSchema, UndoActionInputSchema, UndoActionSchema, UndoSchema, UpdateChangeLogItemInputSchema, UpdateOperationExampleInputSchema, UpdateStateExampleInputSchema, ab2hex, actionContext, actionFromAction, actionSigner, actions, addChangeLogItem, addModule, addOperation, addOperationError, addOperationExample, addStateExample, addUndo, assertIsDocumentModelDocument, assertIsDocumentModelState, attachBranch, baseActions, baseCreateDocument, baseLoadFromInput, baseReducer, baseSaveToFileHandle, buildOperationSignature, buildOperationSignatureMessage, buildOperationSignatureParams, buildSignedAction, checkCleanedOperationsIntegrity, checkOperationsIntegrity, createAction, createAuthState, createBaseState, createDocumentState, createGlobalState, createLocalState, createMinimalZip, createPresignedHeader, createReducer, createSignedHeader, createSignedHeaderForSigner, createState, createVerificationSigner, createZip, defaultAuthState, defaultBaseState, defaultDocumentState, defaultGlobalState, defaultLocalState, defaultPHState, definedNonNullAnySchema, deleteChangeLogItem, deleteModule, deleteOperation, deleteOperationError, deleteOperationExample, deleteStateExample, deriveOperationId, diffOperations, documentModelActions, documentModelDocumentType, documentModelFileExtension, documentModelGlobalState, documentModelHeaderReducer, documentModelInitialGlobalState, documentModelInitialLocalState, documentModelLoadFromInput, documentModelModuleReducer, documentModelOperationErrorReducer, documentModelOperationExampleReducer, documentModelOperationReducer, documentModelReducer, documentModelSaveToFileHandle, documentModelStateReducer, documentModelStateSchemaReducer, documentModelVersioningReducer, fetchFileBrowser, filterDocumentOperationsResultingState, filterDuplicatedOperations, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, generateId, generateMock, getAllOperationNames, getDocumentLastModified, getFileBrowser, getUnixTimestamp, groupOperationsByScope, hashBrowser, hashDocumentStateForScope, hex2ab, isDefinedNonNullAny, isDocumentAction, isDocumentModelDocument, isDocumentModelState, isNoopOperation, isReservedOperationName, isUndo, isUndoRedo, loadState, loadStateOperation, mapSkippedOperations, mapSkippedOperationsV2, merge, moveOperation, nextSkipNumber, noop, operationExampleCreators, operationFromAction, operationFromOperation, operationWithContext, operationsAreEqual, parseResultingState, precedes, prepareOperations, processUndoRedo, prune, pruneOperation, readFileBrowser, readOnly, redo, redoOperation, releaseNewVersion, removeExistingOperations, reorderChangeLogItems, reorderModuleOperations, reorderModules, reorderOperationErrors, reorderOperationExamples, reorderStateExamples, replayDocument, replayOperations, reshuffleByTimestamp, reshuffleByTimestampAndIndex, setAuthorName, setAuthorWebsite, setInitialState, setModelDescription, setModelExtension, setModelId, setModelName, setModuleDescription, setModuleName, setName, setNameOperation, setOperationDescription, setOperationErrorCode, setOperationErrorDescription, setOperationErrorName, setOperationErrorTemplate, setOperationName, setOperationReducer, setOperationSchema, setOperationScope, setOperationTemplate, setPreferredEditor, setPreferredEditorOperation, setStateSchema, sign, skipHeaderOperations, sortMappedOperations, sortOperations, split, undo, undoOperation, undoOperationV2, updateChangeLogItem, updateDocument, updateHeaderRevision, updateOperationExample, updateStateExample, validateHeader, validateInitialState, validateModule, validateModuleOperation, validateModules, validateOperationName, validateOperations, validateStateSchemaName, verify, verifyOperationSignature, writeFileBrowser };
|
|
3386
3465
|
|
|
3387
3466
|
//# sourceMappingURL=index.js.map
|