@powerhousedao/shared 6.2.0-dev.4 → 6.2.0-dev.40

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.
Files changed (97) hide show
  1. package/dist/clis/args/access-token.mjs +1 -1
  2. package/dist/clis/args/{common-BQ2pvhCr.d.mts → common-Cr8LZG55.d.mts} +7 -4
  3. package/dist/clis/args/{common-BQ2pvhCr.d.mts.map → common-Cr8LZG55.d.mts.map} +1 -1
  4. package/dist/clis/args/{common-fPNESurz.mjs → common-dbsvksvf.mjs} +7 -2
  5. package/dist/clis/args/common-dbsvksvf.mjs.map +1 -0
  6. package/dist/clis/args/common.d.mts +2 -2
  7. package/dist/clis/args/common.mjs +2 -2
  8. package/dist/clis/args/connect.d.mts +18 -0
  9. package/dist/clis/args/connect.d.mts.map +1 -1
  10. package/dist/clis/args/connect.mjs +9 -2
  11. package/dist/clis/args/connect.mjs.map +1 -1
  12. package/dist/clis/args/{generate-CTTdiwMD.mjs → generate-Cs5okckF.mjs} +2 -2
  13. package/dist/clis/args/{generate-CTTdiwMD.mjs.map → generate-Cs5okckF.mjs.map} +1 -1
  14. package/dist/clis/args/generate.mjs +1 -1
  15. package/dist/clis/args/{help-CfBzQJpL.mjs → help-BkF9Cxud.mjs} +3 -3
  16. package/dist/clis/args/{help-CfBzQJpL.mjs.map → help-BkF9Cxud.mjs.map} +1 -1
  17. package/dist/clis/args/help.mjs +1 -1
  18. package/dist/clis/args/index.d.mts +3 -3
  19. package/dist/clis/args/index.mjs +4 -4
  20. package/dist/clis/args/init.d.mts +3 -0
  21. package/dist/clis/args/init.d.mts.map +1 -1
  22. package/dist/clis/args/init.mjs +9 -3
  23. package/dist/clis/args/init.mjs.map +1 -1
  24. package/dist/clis/args/inspect.mjs +1 -1
  25. package/dist/clis/args/install.mjs +1 -1
  26. package/dist/clis/args/list.mjs +1 -1
  27. package/dist/clis/args/login.mjs +1 -1
  28. package/dist/clis/args/migrate.mjs +1 -1
  29. package/dist/clis/args/publish.mjs +1 -1
  30. package/dist/clis/args/registry.mjs +1 -1
  31. package/dist/clis/args/service-C88bN_g_.d.mts +22 -0
  32. package/dist/clis/args/service-C88bN_g_.d.mts.map +1 -0
  33. package/dist/clis/args/service.d.mts +1 -1
  34. package/dist/clis/args/service.mjs +1 -1
  35. package/dist/clis/args/switchboard.mjs +1 -1
  36. package/dist/clis/args/uninstall.mjs +1 -1
  37. package/dist/clis/args/unpublish.mjs +1 -1
  38. package/dist/clis/args/vetra.d.mts +6 -0
  39. package/dist/clis/args/vetra.d.mts.map +1 -1
  40. package/dist/clis/args/vetra.mjs +7 -1
  41. package/dist/clis/args/vetra.mjs.map +1 -1
  42. package/dist/clis/build-config.d.mts.map +1 -1
  43. package/dist/clis/build-config.mjs +2 -1
  44. package/dist/clis/build-config.mjs.map +1 -1
  45. package/dist/clis/constants.d.mts +22 -98
  46. package/dist/clis/constants.d.mts.map +1 -1
  47. package/dist/clis/constants.mjs +47 -12
  48. package/dist/clis/constants.mjs.map +1 -1
  49. package/dist/clis/index.d.mts +72 -103
  50. package/dist/clis/index.d.mts.map +1 -1
  51. package/dist/clis/index.mjs +94 -19
  52. package/dist/clis/index.mjs.map +1 -1
  53. package/dist/{config-loader-DORViRnN.js → config-loader-237452Tn.js} +5 -1
  54. package/dist/config-loader-237452Tn.js.map +1 -0
  55. package/dist/connect/config-loader.d.ts +1 -1
  56. package/dist/connect/config-loader.js +1 -1
  57. package/dist/connect/index.d.ts +19 -1
  58. package/dist/connect/index.d.ts.map +1 -1
  59. package/dist/connect/index.js +19 -1
  60. package/dist/connect/index.js.map +1 -1
  61. package/dist/document-drive/index.d.ts +2 -2
  62. package/dist/document-model/index.d.ts +4 -4
  63. package/dist/document-model/index.js +315 -4
  64. package/dist/document-model/index.js.map +1 -1
  65. package/dist/document-model/mock.d.ts +1 -1
  66. package/dist/document-model/mock.js +7 -2
  67. package/dist/document-model/mock.js.map +1 -1
  68. package/dist/document-model/utils.d.ts +1 -1
  69. package/dist/{index-CxGZy8_i.d.ts → index-DLx4nU83.d.ts} +41 -3
  70. package/dist/index-DLx4nU83.d.ts.map +1 -0
  71. package/dist/index.d.ts +4 -4
  72. package/dist/{mock-CbrXTFOF.d.ts → mock-CBcf78ra.d.ts} +2 -2
  73. package/dist/mock-CBcf78ra.d.ts.map +1 -0
  74. package/dist/processors/index.d.ts +1 -1
  75. package/dist/registry/index.d.ts +4 -3
  76. package/dist/registry/index.d.ts.map +1 -1
  77. package/dist/registry/index.js +2 -1
  78. package/dist/registry/index.js.map +1 -1
  79. package/dist/registry/manifest-slim.d.ts +17 -0
  80. package/dist/registry/manifest-slim.d.ts.map +1 -0
  81. package/dist/registry/manifest-slim.js +57 -0
  82. package/dist/registry/manifest-slim.js.map +1 -0
  83. package/dist/{types-Daq_zHP_.d.ts → types-BFTKHmzr.d.ts} +9 -4
  84. package/dist/{types-Daq_zHP_.d.ts.map → types-BFTKHmzr.d.ts.map} +1 -1
  85. package/dist/types-Bo4Rb8Yf.d.ts +2492 -0
  86. package/dist/types-Bo4Rb8Yf.d.ts.map +1 -0
  87. package/dist/{types-CdiI9CJ9.d.ts → types-CgGSyOl6.d.ts} +2 -2
  88. package/dist/{types-CdiI9CJ9.d.ts.map → types-CgGSyOl6.d.ts.map} +1 -1
  89. package/package.json +16 -3
  90. package/dist/clis/args/common-fPNESurz.mjs.map +0 -1
  91. package/dist/clis/args/service-Bzt4_WtZ.d.mts +0 -106
  92. package/dist/clis/args/service-Bzt4_WtZ.d.mts.map +0 -1
  93. package/dist/config-loader-DORViRnN.js.map +0 -1
  94. package/dist/index-CxGZy8_i.d.ts.map +0 -1
  95. package/dist/mock-CbrXTFOF.d.ts.map +0 -1
  96. package/dist/types-DFeAUtLQ.d.ts +0 -21023
  97. package/dist/types-DFeAUtLQ.d.ts.map +0 -1
@@ -24,6 +24,21 @@ var InvalidActionInputZodError = class extends InvalidActionInputError {
24
24
  this.name = "InvalidActionInputZodError";
25
25
  }
26
26
  };
27
+ /**
28
+ * Error thrown when attempting to downgrade a document version.
29
+ */
30
+ var DowngradeNotSupportedError = class extends Error {
31
+ documentType;
32
+ fromVersion;
33
+ toVersion;
34
+ constructor(documentType, fromVersion, toVersion) {
35
+ super(`Downgrade not supported for ${documentType}: cannot upgrade from version ${fromVersion} to ${toVersion}`);
36
+ this.name = "DowngradeNotSupportedError";
37
+ this.documentType = documentType;
38
+ this.fromVersion = fromVersion;
39
+ this.toVersion = toVersion;
40
+ }
41
+ };
27
42
  var HashMismatchError = class extends Error {
28
43
  _scope;
29
44
  _document;
@@ -3397,6 +3412,284 @@ const documentModelStateReducer = (state, action) => {
3397
3412
  };
3398
3413
  const documentModelReducer = createReducer(documentModelStateReducer);
3399
3414
  //#endregion
3415
+ //#region document-model/upgrades.ts
3416
+ function applyInitialState(document, action) {
3417
+ const input = action.input;
3418
+ const newState = input.initialState || input.state;
3419
+ if (newState) {
3420
+ document.state = {
3421
+ ...document.state,
3422
+ ...newState
3423
+ };
3424
+ document.initialState = document.state;
3425
+ }
3426
+ }
3427
+ /**
3428
+ * Applies an UPGRADE_DOCUMENT action to a document.
3429
+ * Handles all upgrade scenarios including initial upgrades, no-ops, and multi-step upgrades.
3430
+ *
3431
+ * Behavior based on fromVersion/toVersion:
3432
+ * - fromVersion === toVersion (and fromVersion > 0): No-op - return unchanged document
3433
+ * - fromVersion > toVersion: Throw DowngradeNotSupportedError
3434
+ * - All other cases: Apply upgradePath transitions (if provided), then apply initialState, set version
3435
+ */
3436
+ function applyUpgradeDocumentAction(document, action, upgradePath) {
3437
+ const fromVersion = action.input.fromVersion;
3438
+ const toVersion = action.input.toVersion;
3439
+ if (fromVersion === toVersion && fromVersion > 0) return document;
3440
+ if (fromVersion > toVersion) throw new DowngradeNotSupportedError(document.header.documentType, fromVersion, toVersion);
3441
+ if (upgradePath) for (const transition of upgradePath) document = transition.upgradeReducer(document, action);
3442
+ applyInitialState(document, action);
3443
+ document.state.document = {
3444
+ ...document.state.document,
3445
+ version: toVersion
3446
+ };
3447
+ return document;
3448
+ }
3449
+ /**
3450
+ * Applies a DELETE_DOCUMENT action to a document.
3451
+ * Marks the document as deleted in the document scope state.
3452
+ */
3453
+ function applyDeleteDocumentAction(document, action) {
3454
+ const deletedAt = action.timestampUtcMs || (/* @__PURE__ */ new Date()).toISOString();
3455
+ document.state = {
3456
+ ...document.state,
3457
+ document: {
3458
+ ...document.state.document,
3459
+ isDeleted: true,
3460
+ deletedAtUtcIso: deletedAt
3461
+ }
3462
+ };
3463
+ return document;
3464
+ }
3465
+ /**
3466
+ * Computes the ordered list of upgrade transitions needed to move from
3467
+ * fromVersion to toVersion using the provided manifest.
3468
+ * Walks keys v(fromVersion+1)..v(toVersion) and throws a descriptive Error
3469
+ * if the manifest is absent or any step is missing.
3470
+ */
3471
+ function computeUpgradeTransitions(manifest, fromVersion, toVersion) {
3472
+ if (!manifest) throw new Error(`No upgrade manifest provided for transition from version ${fromVersion} to ${toVersion}`);
3473
+ const transitions = [];
3474
+ const upgrades = manifest.upgrades;
3475
+ for (let v = fromVersion + 1; v <= toVersion; v++) {
3476
+ const key = `v${v}`;
3477
+ const transition = upgrades[key];
3478
+ if (!transition) throw new Error(`Upgrade manifest for "${manifest.documentType}" is missing step "${key}" (from v${fromVersion} to v${toVersion}). Available keys: ${Object.keys(upgrades).join(", ")}`);
3479
+ transitions.push(transition);
3480
+ }
3481
+ return transitions;
3482
+ }
3483
+ //#endregion
3484
+ //#region document-model/versioned-replay.ts
3485
+ const NON_DOMAIN_SCOPES$1 = new Set(["auth", "document"]);
3486
+ function highestReducerVersion(reducers) {
3487
+ const keys = Object.keys(reducers).map(Number);
3488
+ if (keys.length === 0) throw new Error("VersionedReplayConfig.reducers must not be empty");
3489
+ return Math.max(...keys);
3490
+ }
3491
+ /**
3492
+ * Version-aware document replay. Replays a versioned document through per-version
3493
+ * reducers, applying upgrade transitions at segment boundaries.
3494
+ *
3495
+ * Algorithm (D5):
3496
+ * a. Build spine from operations["document"]. Empty spine or no upgrades → legacy fallback.
3497
+ * b. Collect UPGRADE_DOCUMENT ops from the spine.
3498
+ * c. Seed state from the creation upgrade (fromVersion===0). Missing seed with validated
3499
+ * upgrades throws; otherwise falls back to legacy.
3500
+ * d. Identify validated upgrades (fromVersion > 0, version increases). Compute per-scope
3501
+ * boundaries using revision snapshot (preferred) or timestamp fallback.
3502
+ * e. Loop over version segments, replaying each scope's ops through the matching reducer,
3503
+ * then applying the upgrade transition before the next segment.
3504
+ * f. Set header.revision["document"], verify per-scope hashes against state at op-time
3505
+ * (not post-upgrade state) when checkHashes is false, and map timestamps from input.
3506
+ *
3507
+ * operations must include ALL scopes (document scope is NOT stripped).
3508
+ * reuseOperationResultingState is ignored by this function — zip operations never carry
3509
+ * resultingState.
3510
+ */
3511
+ function replayDocumentVersioned(initialState, operations, config, header, dispatch, options) {
3512
+ const { checkHashes = true, skipIndexValidation } = options || {};
3513
+ const protocolVersion = header.protocolVersions?.["base-reducer"] ?? 1;
3514
+ const spine = (operations["document"] ?? []).slice().sort((a, b) => a.index - b.index);
3515
+ const upgrades = spine.filter((op) => op.action.type === "UPGRADE_DOCUMENT");
3516
+ const legacyFallback = () => {
3517
+ const domainOps = Object.fromEntries(Object.entries(operations).filter(([s]) => !NON_DOMAIN_SCOPES$1.has(s)));
3518
+ const latestVersion = highestReducerVersion(config.reducers);
3519
+ const reducer = config.reducers[latestVersion];
3520
+ return {
3521
+ ...replayDocument(initialState, domainOps, reducer, header, dispatch, {}, options),
3522
+ operations
3523
+ };
3524
+ };
3525
+ if (spine.length === 0 || upgrades.length === 0) return legacyFallback();
3526
+ const seedOp = upgrades[0];
3527
+ if (!seedOp) return legacyFallback();
3528
+ const seedAction = seedOp.action;
3529
+ if (seedAction.input.fromVersion !== 0) return legacyFallback();
3530
+ const seedInput = seedAction.input;
3531
+ const seedState = seedInput.initialState ?? seedInput.state;
3532
+ if (!seedState) {
3533
+ const validatedUpgradeCount = upgrades.filter((op) => {
3534
+ const a = op.action;
3535
+ return a.input.fromVersion > 0 && a.input.fromVersion < a.input.toVersion;
3536
+ }).length;
3537
+ if (validatedUpgradeCount > 0) throw new Error(`Cannot reconstruct versioned history: the creation UPGRADE_DOCUMENT operation carries no initialState, but the document has ${validatedUpgradeCount} version-changing upgrade(s) recorded after creation. Pre-migration states cannot be reconstructed without the seeded initialState.`);
3538
+ return legacyFallback();
3539
+ }
3540
+ const startVersion = seedAction.input.toVersion;
3541
+ const validatedUpgrades = upgrades.filter((op) => {
3542
+ const a = op.action;
3543
+ return a.input.fromVersion > 0 && a.input.fromVersion < a.input.toVersion;
3544
+ });
3545
+ const domainScopes = Object.keys(operations).filter((s) => !NON_DOMAIN_SCOPES$1.has(s));
3546
+ const scopeOps = {};
3547
+ for (const s of domainScopes) scopeOps[s] = (operations[s] ?? []).slice().sort((a, b) => a.index - b.index);
3548
+ const boundaries = validatedUpgrades.map((upgradeOp) => {
3549
+ const revisionSnapshot = upgradeOp.action.input.revision;
3550
+ const upgradeTimestamp = upgradeOp.timestampUtcMs;
3551
+ const boundary = {};
3552
+ for (const s of domainScopes) {
3553
+ const ops = scopeOps[s] ?? [];
3554
+ if (revisionSnapshot !== void 0) {
3555
+ const rev = revisionSnapshot[s] ?? 0;
3556
+ let b = 0;
3557
+ for (let j = 0; j < ops.length; j++) if ((ops[j]?.index ?? 0) < rev) b = j + 1;
3558
+ boundary[s] = b;
3559
+ } else {
3560
+ let b = ops.length;
3561
+ for (let j = 0; j < ops.length; j++) if ((ops[j]?.timestampUtcMs ?? "") >= upgradeTimestamp) {
3562
+ b = j;
3563
+ break;
3564
+ }
3565
+ boundary[s] = b;
3566
+ }
3567
+ }
3568
+ return boundary;
3569
+ });
3570
+ for (let i = 1; i < boundaries.length; i++) for (const s of domainScopes) {
3571
+ const prev = boundaries[i - 1]?.[s] ?? 0;
3572
+ const curr = boundaries[i]?.[s] ?? 0;
3573
+ if (boundaries[i]) boundaries[i][s] = Math.max(prev, curr);
3574
+ }
3575
+ const allScopes = new Set([
3576
+ ...Object.keys(operations),
3577
+ "global",
3578
+ "local"
3579
+ ]);
3580
+ const initialOperations = {};
3581
+ for (const s of allScopes) initialOperations[s] = [];
3582
+ let document = {
3583
+ header,
3584
+ state: seedState,
3585
+ initialState: seedState,
3586
+ operations: initialOperations,
3587
+ clipboard: []
3588
+ };
3589
+ let currentVersion = startVersion;
3590
+ const segmentEndHashPerScope = /* @__PURE__ */ new Map();
3591
+ for (let k = 0; k <= validatedUpgrades.length; k++) {
3592
+ const reducer = config.reducers[currentVersion];
3593
+ if (!reducer) {
3594
+ const available = Object.keys(config.reducers).join(", ");
3595
+ throw new Error(`No reducer registered for document version ${currentVersion}. Available versions: ${available}`);
3596
+ }
3597
+ for (const s of domainScopes) {
3598
+ const ops = scopeOps[s] ?? [];
3599
+ const segStart = k === 0 ? 0 : boundaries[k - 1]?.[s] ?? 0;
3600
+ const segEnd = k < validatedUpgrades.length ? boundaries[k]?.[s] ?? ops.length : ops.length;
3601
+ const segOps = ops.slice(segStart, segEnd);
3602
+ for (const op of segOps) {
3603
+ document = reducer(document, op.action, dispatch, {
3604
+ ignoreSkipOperations: true,
3605
+ checkHashes,
3606
+ skipIndexValidation,
3607
+ replayOptions: { operation: op },
3608
+ protocolVersion
3609
+ });
3610
+ segmentEndHashPerScope.set(s, hashDocumentStateForScope(document, s));
3611
+ }
3612
+ }
3613
+ const prevUpgradeSpineIdx = k === 0 ? -1 : spine.indexOf(validatedUpgrades[k - 1]);
3614
+ const nextUpgradeSpineIdx = k < validatedUpgrades.length ? spine.indexOf(validatedUpgrades[k]) : spine.length;
3615
+ for (let si = prevUpgradeSpineIdx + 1; si < nextUpgradeSpineIdx; si++) {
3616
+ const spineOp = spine[si];
3617
+ if (!spineOp) continue;
3618
+ const spineActionType = spineOp.action.type;
3619
+ if (spineActionType === "CREATE_DOCUMENT" || spineActionType === "UPGRADE_DOCUMENT") continue;
3620
+ if (spineActionType === "DELETE_DOCUMENT") document = applyDeleteDocumentAction(document, spineOp.action);
3621
+ else document = reducer(document, spineOp.action, dispatch, {
3622
+ ignoreSkipOperations: true,
3623
+ checkHashes,
3624
+ skipIndexValidation,
3625
+ replayOptions: { operation: spineOp },
3626
+ protocolVersion
3627
+ });
3628
+ }
3629
+ if (k < validatedUpgrades.length) {
3630
+ const upgradeAction = validatedUpgrades[k].action;
3631
+ const fromVer = upgradeAction.input.fromVersion;
3632
+ const toVer = upgradeAction.input.toVersion;
3633
+ const transitions = computeUpgradeTransitions(config.upgradeManifest, fromVer, toVer);
3634
+ document = applyUpgradeDocumentAction(document, upgradeAction, transitions);
3635
+ currentVersion = toVer;
3636
+ }
3637
+ }
3638
+ const lastSpineOp = spine.at(-1);
3639
+ if (lastSpineOp !== void 0 && validatedUpgrades.length > 0) document = {
3640
+ ...document,
3641
+ header: {
3642
+ ...document.header,
3643
+ revision: {
3644
+ ...document.header.revision,
3645
+ document: lastSpineOp.index + 1
3646
+ }
3647
+ }
3648
+ };
3649
+ if (!checkHashes) {
3650
+ const allReplayedOps = domainScopes.flatMap((s) => scopeOps[s] ?? []);
3651
+ for (const scope of Object.keys(document.state)) {
3652
+ const capturedHash = segmentEndHashPerScope.get(scope);
3653
+ const scopeHash = capturedHash !== void 0 ? capturedHash : hashDocumentStateForScope(document, scope);
3654
+ for (let i = allReplayedOps.length - 1; i >= 0; i--) {
3655
+ const operation = allReplayedOps[i];
3656
+ if (!operation || operation.action.scope !== scope) continue;
3657
+ if (operation.hash !== scopeHash) throw new HashMismatchError(scope, document, operation);
3658
+ else break;
3659
+ }
3660
+ }
3661
+ }
3662
+ const allResultScopes = new Set([
3663
+ ...Object.keys(document.operations),
3664
+ ...Object.keys(operations),
3665
+ "global",
3666
+ "local"
3667
+ ]);
3668
+ allResultScopes.delete("document");
3669
+ const resultOperations = {};
3670
+ for (const s of allResultScopes) resultOperations[s] = (document.operations[s] ?? []).map((op, index) => ({
3671
+ ...op,
3672
+ timestamp: operations[s]?.[index]?.timestampUtcMs ?? op.timestampUtcMs
3673
+ }));
3674
+ const lastModified = header.lastModifiedAtUtcIso ? header.lastModifiedAtUtcIso : Object.values(resultOperations).reduce((acc, curr) => {
3675
+ if (!curr) return acc;
3676
+ const last = curr.at(-1);
3677
+ if (last && last.timestampUtcMs > acc) return last.timestampUtcMs;
3678
+ return acc;
3679
+ }, document.header.lastModifiedAtUtcIso);
3680
+ return {
3681
+ ...document,
3682
+ header: {
3683
+ ...document.header,
3684
+ lastModifiedAtUtcIso: lastModified
3685
+ },
3686
+ operations: {
3687
+ ...operations,
3688
+ ...resultOperations
3689
+ }
3690
+ };
3691
+ }
3692
+ //#endregion
3400
3693
  //#region document-model/files.ts
3401
3694
  const NON_DOMAIN_SCOPES = new Set(["auth", "document"]);
3402
3695
  function zipAsync(data) {
@@ -3483,7 +3776,7 @@ function readEntry(files, name) {
3483
3776
  if (!entry) throw new Error(`${name} not found in document zip`);
3484
3777
  return strFromU8(entry);
3485
3778
  }
3486
- async function loadFromZipData(data, reducer, options) {
3779
+ async function parseZipData(data) {
3487
3780
  const files = await unzipAsync(data);
3488
3781
  if (!files["state.json"]) throw new Error("Initial state not found");
3489
3782
  const initialState = JSON.parse(readEntry(files, "state.json"));
@@ -3496,14 +3789,32 @@ async function loadFromZipData(data, reducer, options) {
3496
3789
  const errorMessages = operationsError.map((err) => err.message);
3497
3790
  throw new Error(errorMessages.join("\n"));
3498
3791
  }
3792
+ return {
3793
+ initialState,
3794
+ header,
3795
+ clearedOperations
3796
+ };
3797
+ }
3798
+ async function loadFromZipData(data, reducer, options) {
3799
+ const { initialState, header, clearedOperations } = await parseZipData(data);
3499
3800
  return {
3500
3801
  ...replayDocument(initialState, Object.fromEntries(Object.entries(clearedOperations).filter(([scope]) => !NON_DOMAIN_SCOPES.has(scope))), reducer, header, void 0, {}, options),
3501
3802
  operations: clearedOperations
3502
3803
  };
3503
3804
  }
3805
+ async function loadFromZipDataVersioned(data, config, options) {
3806
+ const { initialState, header, clearedOperations } = await parseZipData(data);
3807
+ return {
3808
+ ...replayDocumentVersioned(initialState, clearedOperations, config, header, void 0, options),
3809
+ operations: clearedOperations
3810
+ };
3811
+ }
3504
3812
  async function baseLoadFromInput(input, reducer, options) {
3505
3813
  return loadFromZipData(await toUint8Array(input), reducer, options);
3506
3814
  }
3815
+ async function baseLoadFromInputVersioned(input, config, options) {
3816
+ return loadFromZipDataVersioned(await toUint8Array(input), config, options);
3817
+ }
3507
3818
  const documentModelLoadFromInput = (input) => {
3508
3819
  return baseLoadFromInput(input, documentModelReducer);
3509
3820
  };
@@ -3519,8 +3830,8 @@ function readFileBrowser(path) {
3519
3830
  function fetchFileBrowser(url) {
3520
3831
  throw FileSystemError;
3521
3832
  }
3522
- const getFileBrowser = async (file) => {
3523
- return readFileBrowser(file);
3833
+ const getFileBrowser = (file) => {
3834
+ return Promise.resolve().then(() => readFileBrowser(file));
3524
3835
  };
3525
3836
  //#endregion
3526
3837
  //#region document-model/state.ts
@@ -3622,6 +3933,6 @@ function createState(baseState, globalState, localState) {
3622
3933
  };
3623
3934
  }
3624
3935
  //#endregion
3625
- export { AddChangeLogItemInputSchema, AddModuleInputSchema, AddOperationErrorInputSchema, AddOperationExampleInputSchema, AddOperationInputSchema, AddStateExampleInputSchema, AuthorSchema, BaseDocumentHeaderSchema, BaseDocumentStateSchema, CodeExampleSchema, ConfigEntrySchema, ConfigEntryTypeSchema, DeleteChangeLogItemInputSchema, DeleteModuleInputSchema, DeleteOperationErrorInputSchema, DeleteOperationExampleInputSchema, DeleteOperationInputSchema, DeleteStateExampleInputSchema, DocumentActionSchema, 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, OPERATION_NAME_PATTERN, 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, assertModuleIdUnique, assertOperationErrorIdUnique, assertOperationExampleIdUnique, assertOperationIdUnique, 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, findModuleOrThrow, findOperationErrorOrThrow, findOperationExampleOrThrow, findOperationOrThrow, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, generateId, generateMock, getAllOperationNames, getDocumentLastModified, getFileBrowser, getUnixTimestamp, groupOperationsByScope, hashBrowser, hashDocumentStateForScope, hex2ab, isDefinedNonNullAny, isDocumentAction, isDocumentModelDocument, isDocumentModelState, isNoopOperation, isReservedOperationName, isUndo, isUndoRedo, isValidOperationNameFormat, 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 };
3936
+ export { AddChangeLogItemInputSchema, AddModuleInputSchema, AddOperationErrorInputSchema, AddOperationExampleInputSchema, AddOperationInputSchema, AddStateExampleInputSchema, AuthorSchema, BaseDocumentHeaderSchema, BaseDocumentStateSchema, CodeExampleSchema, ConfigEntrySchema, ConfigEntryTypeSchema, DeleteChangeLogItemInputSchema, DeleteModuleInputSchema, DeleteOperationErrorInputSchema, DeleteOperationExampleInputSchema, DeleteOperationInputSchema, DeleteStateExampleInputSchema, DocumentActionSchema, DocumentModelGlobalStateSchema, DocumentModelHeaderSchema, DocumentModelInputSchema, DocumentModelPHStateSchema, DocumentModelSchema, DocumentSpecificationSchema, DowngradeNotSupportedError, 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, OPERATION_NAME_PATTERN, 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, applyDeleteDocumentAction, applyUpgradeDocumentAction, assertIsDocumentModelDocument, assertIsDocumentModelState, assertModuleIdUnique, assertOperationErrorIdUnique, assertOperationExampleIdUnique, assertOperationIdUnique, attachBranch, baseActions, baseCreateDocument, baseLoadFromInput, baseLoadFromInputVersioned, baseReducer, baseSaveToFileHandle, buildOperationSignature, buildOperationSignatureMessage, buildOperationSignatureParams, buildSignedAction, checkCleanedOperationsIntegrity, checkOperationsIntegrity, computeUpgradeTransitions, 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, findModuleOrThrow, findOperationErrorOrThrow, findOperationExampleOrThrow, findOperationOrThrow, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, generateId, generateMock, getAllOperationNames, getDocumentLastModified, getFileBrowser, getUnixTimestamp, groupOperationsByScope, hashBrowser, hashDocumentStateForScope, hex2ab, isDefinedNonNullAny, isDocumentAction, isDocumentModelDocument, isDocumentModelState, isNoopOperation, isReservedOperationName, isUndo, isUndoRedo, isValidOperationNameFormat, 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, replayDocumentVersioned, 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 };
3626
3937
 
3627
3938
  //# sourceMappingURL=index.js.map