document-model 2.20.0 → 2.21.1
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/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/{browser/src → src}/document/actions/creators.d.ts +3 -2
- package/dist/src/document/actions/creators.d.ts.map +1 -0
- package/dist/{node/src/document/actions/creators.d.ts → src/document/actions/creators.js} +17 -9
- package/dist/src/document/actions/operations.d.ts +23 -0
- package/dist/src/document/actions/operations.d.ts.map +1 -0
- package/dist/src/document/actions/operations.js +130 -0
- package/dist/src/document/actions/types.d.ts +16 -0
- package/dist/src/document/actions/types.d.ts.map +1 -0
- package/dist/src/document/actions/types.js +6 -0
- package/dist/{browser/src → src}/document/object.d.ts +16 -14
- package/dist/src/document/object.d.ts.map +1 -0
- package/dist/{node/src/document/object.d.ts → src/document/object.js} +92 -30
- package/dist/src/document/reducer.d.ts +49 -0
- package/dist/src/document/reducer.d.ts.map +1 -0
- package/dist/src/document/reducer.js +341 -0
- package/dist/{browser/src → src}/document/schema/types.d.ts +1 -1
- package/dist/src/document/schema/types.d.ts.map +1 -0
- package/dist/src/document/schema/types.js +1 -0
- package/dist/{browser/src → src}/document/schema/zod.d.ts +20 -20
- package/dist/src/document/schema/zod.d.ts.map +1 -0
- package/dist/src/document/schema/zod.js +112 -0
- package/dist/{node/src → src}/document/signal.d.ts +9 -9
- package/dist/src/document/signal.d.ts.map +1 -0
- package/dist/src/document/signal.js +1 -0
- package/dist/src/document/types.d.ts +302 -0
- package/dist/src/document/types.d.ts.map +1 -0
- package/dist/src/document/types.js +1 -0
- package/dist/src/document/utils/base.d.ts +84 -0
- package/dist/src/document/utils/base.d.ts.map +1 -0
- package/dist/src/document/utils/base.js +328 -0
- package/dist/{browser/src → src}/document/utils/browser.d.ts +1 -1
- package/dist/src/document/utils/browser.d.ts.map +1 -0
- package/dist/src/document/utils/browser.js +46 -0
- package/dist/src/document/utils/crypto.d.ts +11 -0
- package/dist/src/document/utils/crypto.d.ts.map +1 -0
- package/dist/src/document/utils/crypto.js +79 -0
- package/dist/src/document/utils/document-helpers.d.ts +78 -0
- package/dist/src/document/utils/document-helpers.d.ts.map +1 -0
- package/dist/src/document/utils/document-helpers.js +410 -0
- package/dist/{browser/src → src}/document/utils/errors.d.ts +1 -1
- package/dist/src/document/utils/errors.d.ts.map +1 -0
- package/dist/src/document/utils/errors.js +18 -0
- package/dist/{browser/src → src}/document/utils/file.d.ts +9 -8
- package/dist/src/document/utils/file.d.ts.map +1 -0
- package/dist/src/document/utils/file.js +155 -0
- package/dist/{browser/src → src}/document/utils/node.d.ts +2 -2
- package/dist/src/document/utils/node.d.ts.map +1 -0
- package/dist/src/document/utils/node.js +54 -0
- package/dist/src/document/utils/validation.d.ts +3 -0
- package/dist/src/document/utils/validation.d.ts.map +1 -0
- package/dist/src/document/utils/validation.js +22 -0
- package/dist/src/document-model/custom/reducers/header.d.ts +3 -0
- package/dist/src/document-model/custom/reducers/header.d.ts.map +1 -0
- package/dist/src/document-model/custom/reducers/header.js +22 -0
- package/dist/src/document-model/custom/reducers/module.d.ts +3 -0
- package/dist/src/document-model/custom/reducers/module.d.ts.map +1 -0
- package/dist/src/document-model/custom/reducers/module.js +40 -0
- package/dist/src/document-model/custom/reducers/operation-error.d.ts +3 -0
- package/dist/src/document-model/custom/reducers/operation-error.d.ts.map +1 -0
- package/dist/src/document-model/custom/reducers/operation-error.js +93 -0
- package/dist/src/document-model/custom/reducers/operation-example.d.ts +3 -0
- package/dist/src/document-model/custom/reducers/operation-example.d.ts.map +1 -0
- package/dist/src/document-model/custom/reducers/operation-example.js +52 -0
- package/dist/src/document-model/custom/reducers/operation.d.ts +3 -0
- package/dist/src/document-model/custom/reducers/operation.d.ts.map +1 -0
- package/dist/src/document-model/custom/reducers/operation.js +124 -0
- package/dist/src/document-model/custom/reducers/state.d.ts +3 -0
- package/dist/src/document-model/custom/reducers/state.d.ts.map +1 -0
- package/dist/src/document-model/custom/reducers/state.js +70 -0
- package/dist/src/document-model/custom/reducers/versioning.d.ts +8 -0
- package/dist/src/document-model/custom/reducers/versioning.d.ts.map +1 -0
- package/dist/src/document-model/custom/reducers/versioning.js +22 -0
- package/dist/{browser/src → src}/document-model/custom/utils.d.ts +3 -3
- package/dist/src/document-model/custom/utils.d.ts.map +1 -0
- package/dist/src/document-model/custom/utils.js +104 -0
- package/dist/src/document-model/gen/actions.d.ts +16 -0
- package/dist/src/document-model/gen/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/actions.js +7 -0
- package/dist/src/document-model/gen/constants.d.ts +7 -0
- package/dist/src/document-model/gen/constants.d.ts.map +1 -0
- package/dist/src/document-model/gen/constants.js +33 -0
- package/dist/src/document-model/gen/creators.d.ts +8 -0
- package/dist/src/document-model/gen/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/creators.js +7 -0
- package/dist/src/document-model/gen/document-model.d.ts +3 -0
- package/dist/src/document-model/gen/document-model.d.ts.map +1 -0
- package/dist/src/document-model/gen/document-model.js +541 -0
- package/dist/src/document-model/gen/header/actions.d.ts +10 -0
- package/dist/src/document-model/gen/header/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/header/actions.js +1 -0
- package/dist/{browser/src → src}/document-model/gen/header/creators.d.ts +2 -2
- package/dist/src/document-model/gen/header/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/header/creators.js +9 -0
- package/dist/src/document-model/gen/header/object.d.ts +13 -0
- package/dist/src/document-model/gen/header/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/header/object.js +22 -0
- package/dist/{node/src → src}/document-model/gen/header/operations.d.ts +2 -2
- package/dist/src/document-model/gen/header/operations.d.ts.map +1 -0
- package/dist/src/document-model/gen/header/operations.js +1 -0
- package/dist/src/document-model/gen/module/actions.d.ts +9 -0
- package/dist/src/document-model/gen/module/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/module/actions.js +1 -0
- package/dist/{node/src → src}/document-model/gen/module/creators.d.ts +2 -2
- package/dist/src/document-model/gen/module/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/module/creators.js +8 -0
- package/dist/src/document-model/gen/module/object.d.ts +12 -0
- package/dist/src/document-model/gen/module/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/module/object.js +19 -0
- package/dist/{browser/src → src}/document-model/gen/module/operations.d.ts +2 -2
- package/dist/src/document-model/gen/module/operations.d.ts.map +1 -0
- package/dist/src/document-model/gen/module/operations.js +1 -0
- package/dist/src/document-model/gen/object.d.ts +30 -0
- package/dist/src/document-model/gen/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/object.js +46 -0
- package/dist/src/document-model/gen/operation/actions.d.ts +14 -0
- package/dist/src/document-model/gen/operation/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation/actions.js +1 -0
- package/dist/{browser/src → src}/document-model/gen/operation/creators.d.ts +2 -2
- package/dist/src/document-model/gen/operation/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation/creators.js +19 -0
- package/dist/{node/src → src}/document-model/gen/operation/object.d.ts +6 -5
- package/dist/src/document-model/gen/operation/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation/object.js +34 -0
- package/dist/{browser/src → src}/document-model/gen/operation/operations.d.ts +2 -2
- package/dist/src/document-model/gen/operation/operations.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation/operations.js +1 -0
- package/dist/src/document-model/gen/operation-error/actions.d.ts +11 -0
- package/dist/src/document-model/gen/operation-error/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-error/actions.js +1 -0
- package/dist/{node/src → src}/document-model/gen/operation-error/creators.d.ts +2 -2
- package/dist/src/document-model/gen/operation-error/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-error/creators.js +16 -0
- package/dist/{node/src → src}/document-model/gen/operation-error/object.d.ts +6 -5
- package/dist/src/document-model/gen/operation-error/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-error/object.js +25 -0
- package/dist/{browser/src → src}/document-model/gen/operation-error/operations.d.ts +2 -2
- package/dist/src/document-model/gen/operation-error/operations.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-error/operations.js +1 -0
- package/dist/src/document-model/gen/operation-example/actions.d.ts +8 -0
- package/dist/src/document-model/gen/operation-example/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-example/actions.js +1 -0
- package/dist/{browser/src → src}/document-model/gen/operation-example/creators.d.ts +2 -2
- package/dist/src/document-model/gen/operation-example/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-example/creators.js +13 -0
- package/dist/src/document-model/gen/operation-example/object.d.ts +12 -0
- package/dist/src/document-model/gen/operation-example/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-example/object.js +16 -0
- package/dist/{browser/src → src}/document-model/gen/operation-example/operations.d.ts +2 -2
- package/dist/src/document-model/gen/operation-example/operations.d.ts.map +1 -0
- package/dist/src/document-model/gen/operation-example/operations.js +1 -0
- package/dist/src/document-model/gen/reducer.d.ts +5 -0
- package/dist/src/document-model/gen/reducer.d.ts.map +1 -0
- package/dist/src/document-model/gen/reducer.js +192 -0
- package/dist/{node/src → src}/document-model/gen/schema/types.d.ts +5 -1
- package/dist/src/document-model/gen/schema/types.d.ts.map +1 -0
- package/dist/src/document-model/gen/schema/types.js +1 -0
- package/dist/{browser/src → src}/document-model/gen/schema/zod.d.ts +198 -198
- package/dist/src/document-model/gen/schema/zod.d.ts.map +1 -0
- package/dist/src/document-model/gen/schema/zod.js +393 -0
- package/dist/src/document-model/gen/state/actions.d.ts +10 -0
- package/dist/src/document-model/gen/state/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/state/actions.js +1 -0
- package/dist/{browser/src → src}/document-model/gen/state/creators.d.ts +2 -2
- package/dist/src/document-model/gen/state/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/state/creators.js +9 -0
- package/dist/src/document-model/gen/state/object.d.ts +13 -0
- package/dist/src/document-model/gen/state/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/state/object.js +22 -0
- package/dist/{browser/src → src}/document-model/gen/state/operations.d.ts +2 -2
- package/dist/src/document-model/gen/state/operations.d.ts.map +1 -0
- package/dist/src/document-model/gen/state/operations.js +1 -0
- package/dist/src/document-model/gen/types.d.ts +7 -0
- package/dist/src/document-model/gen/types.d.ts.map +1 -0
- package/dist/src/document-model/gen/types.js +1 -0
- package/dist/src/document-model/gen/utils.d.ts +11 -0
- package/dist/src/document-model/gen/utils.d.ts.map +1 -0
- package/dist/src/document-model/gen/utils.js +29 -0
- package/dist/src/document-model/gen/versioning/actions.d.ts +9 -0
- package/dist/src/document-model/gen/versioning/actions.d.ts.map +1 -0
- package/dist/src/document-model/gen/versioning/actions.js +1 -0
- package/dist/{browser/src → src}/document-model/gen/versioning/creators.d.ts +2 -2
- package/dist/src/document-model/gen/versioning/creators.d.ts.map +1 -0
- package/dist/src/document-model/gen/versioning/creators.js +12 -0
- package/dist/src/document-model/gen/versioning/object.d.ts +13 -0
- package/dist/src/document-model/gen/versioning/object.d.ts.map +1 -0
- package/dist/src/document-model/gen/versioning/object.js +19 -0
- package/dist/{browser/src → src}/document-model/gen/versioning/operations.d.ts +2 -2
- package/dist/src/document-model/gen/versioning/operations.d.ts.map +1 -0
- package/dist/src/document-model/gen/versioning/operations.js +1 -0
- package/dist/src/document-model/module.d.ts +3 -0
- package/dist/src/document-model/module.d.ts.map +1 -0
- package/dist/src/document-model/module.js +12 -0
- package/dist/src/document-model/types.d.ts +4 -0
- package/dist/src/document-model/types.d.ts.map +1 -0
- package/dist/src/document-model/types.js +1 -0
- package/dist/test/document/crypto.test.d.ts.map +1 -0
- package/dist/test/document/crypto.test.js +180 -0
- package/dist/test/document/event-vs-command.test.d.ts.map +1 -0
- package/dist/test/document/event-vs-command.test.js +168 -0
- package/dist/test/document/local.test.d.ts.map +1 -0
- package/dist/test/document/local.test.js +247 -0
- package/dist/test/document/object.test.d.ts.map +1 -0
- package/dist/test/document/object.test.js +12 -0
- package/dist/test/document/operation-id.test.d.ts.map +1 -0
- package/dist/test/document/operation-id.test.js +158 -0
- package/dist/test/document/prune.test.d.ts.map +1 -0
- package/dist/test/document/prune.test.js +176 -0
- package/dist/test/document/reducer.test.d.ts.map +1 -0
- package/dist/test/document/reducer.test.js +268 -0
- package/dist/test/document/skip-operations.test.d.ts.map +1 -0
- package/dist/test/document/skip-operations.test.js +441 -0
- package/dist/test/document/undo-redo.test.d.ts.map +1 -0
- package/dist/test/document/undo-redo.test.js +376 -0
- package/dist/test/document/utils.test.d.ts.map +1 -0
- package/dist/test/document/utils.test.js +151 -0
- package/dist/test/document-helpers/addUndo.test.d.ts.map +1 -0
- package/dist/test/document-helpers/addUndo.test.js +119 -0
- package/dist/test/document-helpers/attachBranch.test.d.ts.map +1 -0
- package/dist/test/document-helpers/attachBranch.test.js +363 -0
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +1 -0
- package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js +251 -0
- package/dist/test/document-helpers/conflictResolution.test.d.ts.map +1 -0
- package/dist/test/document-helpers/conflictResolution.test.js +108 -0
- package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +1 -0
- package/dist/test/document-helpers/filterDuplicatedOperations.test.js +125 -0
- package/dist/test/document-helpers/garbageCollect.test.d.ts.map +1 -0
- package/dist/test/document-helpers/garbageCollect.test.js +135 -0
- package/dist/test/document-helpers/groupOperationsByScope.test.d.ts.map +1 -0
- package/dist/test/document-helpers/groupOperationsByScope.test.js +97 -0
- package/dist/test/document-helpers/merge.test.d.ts.map +1 -0
- package/dist/test/document-helpers/merge.test.js +905 -0
- package/dist/test/document-helpers/nextSkipNumber.test.d.ts.map +1 -0
- package/dist/test/document-helpers/nextSkipNumber.test.js +134 -0
- package/dist/test/document-helpers/prepareOperations.test.d.ts.map +1 -0
- package/dist/test/document-helpers/prepareOperations.test.js +303 -0
- package/dist/test/document-helpers/removeExistingOperations.test.d.ts.map +1 -0
- package/dist/test/document-helpers/removeExistingOperations.test.js +149 -0
- package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +1 -0
- package/dist/test/document-helpers/reshuffleByTimestamp.test.js +147 -0
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +1 -0
- package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js +199 -0
- package/dist/test/document-helpers/skipHeaderOperations.test.d.ts.map +1 -0
- package/dist/test/document-helpers/skipHeaderOperations.test.js +73 -0
- package/dist/test/document-helpers/sortOperations.test.d.ts.map +1 -0
- package/dist/test/document-helpers/sortOperations.test.js +100 -0
- package/dist/test/document-helpers/split.test.d.ts.map +1 -0
- package/dist/test/document-helpers/split.test.js +120 -0
- package/dist/{browser/test → test}/document-helpers/utils.d.ts +1 -1
- package/dist/test/document-helpers/utils.d.ts.map +1 -0
- package/dist/test/document-helpers/utils.js +21 -0
- package/dist/test/document-model/object.test.d.ts.map +1 -0
- package/dist/test/document-model/object.test.js +242 -0
- package/dist/test/document-model/replay.test.d.ts.map +1 -0
- package/dist/test/document-model/replay.test.js +137 -0
- package/dist/test/document-model/skip-operations.test.d.ts.map +1 -0
- package/dist/test/document-model/skip-operations.test.js +216 -0
- package/dist/test/document-model/validation.test.d.ts.map +1 -0
- package/dist/test/document-model/validation.test.js +257 -0
- package/dist/test/document-model/zip.test.d.ts.map +1 -0
- package/dist/test/document-model/zip.test.js +80 -0
- package/dist/test/helpers.d.ts +31 -0
- package/dist/test/helpers.d.ts.map +1 -0
- package/dist/test/helpers.js +69 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/dist/vitest.config.js +6 -0
- package/package.json +16 -53
- package/dist/browser/cjs/document-model.js +0 -21
- package/dist/browser/cjs/document-model.js.map +0 -1
- package/dist/browser/cjs/document.js +0 -16
- package/dist/browser/cjs/document.js.map +0 -1
- package/dist/browser/cjs/index.js +0 -14
- package/dist/browser/cjs/index.js.map +0 -1
- package/dist/browser/cjs/internal/creators-DJg3Kd1P.js +0 -2901
- package/dist/browser/cjs/internal/creators-DJg3Kd1P.js.map +0 -1
- package/dist/browser/cjs/internal/index-CGExio27.js +0 -2216
- package/dist/browser/cjs/internal/index-CGExio27.js.map +0 -1
- package/dist/browser/cjs/internal/index-CQg4iLBq.js +0 -19
- package/dist/browser/cjs/internal/index-CQg4iLBq.js.map +0 -1
- package/dist/browser/cjs/internal/index-DcdJY5J3.js +0 -47
- package/dist/browser/cjs/internal/index-DcdJY5J3.js.map +0 -1
- package/dist/browser/cjs/internal/object-C3OfcOUa.js +0 -183
- package/dist/browser/cjs/internal/object-C3OfcOUa.js.map +0 -1
- package/dist/browser/cjs/package.json +0 -1
- package/dist/browser/cjs/utils.js +0 -44
- package/dist/browser/cjs/utils.js.map +0 -1
- package/dist/browser/document-model.d.ts +0 -2
- package/dist/browser/document.d.ts +0 -2
- package/dist/browser/es/document-model.js +0 -21
- package/dist/browser/es/document-model.js.map +0 -1
- package/dist/browser/es/document.js +0 -16
- package/dist/browser/es/document.js.map +0 -1
- package/dist/browser/es/index.js +0 -14
- package/dist/browser/es/index.js.map +0 -1
- package/dist/browser/es/internal/creators-Dir4K_-h.js +0 -2902
- package/dist/browser/es/internal/creators-Dir4K_-h.js.map +0 -1
- package/dist/browser/es/internal/index-BxCiP58y.js +0 -48
- package/dist/browser/es/internal/index-BxCiP58y.js.map +0 -1
- package/dist/browser/es/internal/index-HlkIVQZ6.js +0 -2217
- package/dist/browser/es/internal/index-HlkIVQZ6.js.map +0 -1
- package/dist/browser/es/internal/index-qYp7hG3r.js +0 -20
- package/dist/browser/es/internal/index-qYp7hG3r.js.map +0 -1
- package/dist/browser/es/internal/object-CzFSgK3q.js +0 -184
- package/dist/browser/es/internal/object-CzFSgK3q.js.map +0 -1
- package/dist/browser/es/package.json +0 -1
- package/dist/browser/es/utils.js +0 -44
- package/dist/browser/es/utils.js.map +0 -1
- package/dist/browser/index.d.ts +0 -6
- package/dist/browser/src/document/actions/creators.d.ts.map +0 -1
- package/dist/browser/src/document/actions/index.d.ts +0 -15
- package/dist/browser/src/document/actions/index.d.ts.map +0 -1
- package/dist/browser/src/document/actions/types.d.ts +0 -16
- package/dist/browser/src/document/actions/types.d.ts.map +0 -1
- package/dist/browser/src/document/index.d.ts +0 -7
- package/dist/browser/src/document/index.d.ts.map +0 -1
- package/dist/browser/src/document/object.d.ts.map +0 -1
- package/dist/browser/src/document/reducer.d.ts +0 -66
- package/dist/browser/src/document/reducer.d.ts.map +0 -1
- package/dist/browser/src/document/schema/index.d.ts +0 -3
- package/dist/browser/src/document/schema/index.d.ts.map +0 -1
- package/dist/browser/src/document/schema/types.d.ts.map +0 -1
- package/dist/browser/src/document/schema/zod.d.ts.map +0 -1
- package/dist/browser/src/document/signal.d.ts +0 -30
- package/dist/browser/src/document/signal.d.ts.map +0 -1
- package/dist/browser/src/document/types.d.ts +0 -292
- package/dist/browser/src/document/types.d.ts.map +0 -1
- package/dist/browser/src/document/utils/base.d.ts +0 -89
- package/dist/browser/src/document/utils/base.d.ts.map +0 -1
- package/dist/browser/src/document/utils/browser.d.ts.map +0 -1
- package/dist/browser/src/document/utils/crypto.d.ts +0 -11
- package/dist/browser/src/document/utils/crypto.d.ts.map +0 -1
- package/dist/browser/src/document/utils/document-helpers.d.ts +0 -74
- package/dist/browser/src/document/utils/document-helpers.d.ts.map +0 -1
- package/dist/browser/src/document/utils/errors.d.ts.map +0 -1
- package/dist/browser/src/document/utils/file.d.ts.map +0 -1
- package/dist/browser/src/document/utils/index.d.ts +0 -8
- package/dist/browser/src/document/utils/index.d.ts.map +0 -1
- package/dist/browser/src/document/utils/node.d.ts.map +0 -1
- package/dist/browser/src/document/utils/validation.d.ts +0 -3
- package/dist/browser/src/document/utils/validation.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/reducers/header.d.ts +0 -3
- package/dist/browser/src/document-model/custom/reducers/header.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/reducers/module.d.ts +0 -3
- package/dist/browser/src/document-model/custom/reducers/module.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts +0 -3
- package/dist/browser/src/document-model/custom/reducers/operation-error.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts +0 -3
- package/dist/browser/src/document-model/custom/reducers/operation-example.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/reducers/operation.d.ts +0 -3
- package/dist/browser/src/document-model/custom/reducers/operation.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/reducers/state.d.ts +0 -3
- package/dist/browser/src/document-model/custom/reducers/state.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/reducers/versioning.d.ts +0 -3
- package/dist/browser/src/document-model/custom/reducers/versioning.d.ts.map +0 -1
- package/dist/browser/src/document-model/custom/utils.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/actions.d.ts +0 -16
- package/dist/browser/src/document-model/gen/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/creators.d.ts +0 -8
- package/dist/browser/src/document-model/gen/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/document-model.d.ts +0 -3
- package/dist/browser/src/document-model/gen/document-model.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/header/actions.d.ts +0 -10
- package/dist/browser/src/document-model/gen/header/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/header/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/header/object.d.ts +0 -13
- package/dist/browser/src/document-model/gen/header/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/header/operations.d.ts +0 -11
- package/dist/browser/src/document-model/gen/header/operations.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/index.d.ts +0 -6
- package/dist/browser/src/document-model/gen/index.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/module/actions.d.ts +0 -9
- package/dist/browser/src/document-model/gen/module/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/module/creators.d.ts +0 -8
- package/dist/browser/src/document-model/gen/module/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/module/object.d.ts +0 -12
- package/dist/browser/src/document-model/gen/module/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/module/operations.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/object.d.ts +0 -29
- package/dist/browser/src/document-model/gen/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation/actions.d.ts +0 -14
- package/dist/browser/src/document-model/gen/operation/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation/object.d.ts +0 -17
- package/dist/browser/src/document-model/gen/operation/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation/operations.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-error/actions.d.ts +0 -11
- package/dist/browser/src/document-model/gen/operation-error/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-error/creators.d.ts +0 -10
- package/dist/browser/src/document-model/gen/operation-error/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-error/object.d.ts +0 -14
- package/dist/browser/src/document-model/gen/operation-error/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-error/operations.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-example/actions.d.ts +0 -8
- package/dist/browser/src/document-model/gen/operation-example/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-example/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-example/object.d.ts +0 -11
- package/dist/browser/src/document-model/gen/operation-example/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/operation-example/operations.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/reducer.d.ts +0 -6
- package/dist/browser/src/document-model/gen/reducer.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/schema/index.d.ts +0 -3
- package/dist/browser/src/document-model/gen/schema/index.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/schema/types.d.ts +0 -454
- package/dist/browser/src/document-model/gen/schema/types.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/schema/zod.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/state/actions.d.ts +0 -10
- package/dist/browser/src/document-model/gen/state/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/state/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/state/object.d.ts +0 -13
- package/dist/browser/src/document-model/gen/state/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/state/operations.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/types.d.ts +0 -9
- package/dist/browser/src/document-model/gen/types.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/utils.d.ts +0 -7
- package/dist/browser/src/document-model/gen/utils.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/versioning/actions.d.ts +0 -9
- package/dist/browser/src/document-model/gen/versioning/actions.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/versioning/creators.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/versioning/object.d.ts +0 -12
- package/dist/browser/src/document-model/gen/versioning/object.d.ts.map +0 -1
- package/dist/browser/src/document-model/gen/versioning/operations.d.ts.map +0 -1
- package/dist/browser/src/document-model/index.d.ts +0 -77
- package/dist/browser/src/document-model/index.d.ts.map +0 -1
- package/dist/browser/src/index.d.ts +0 -25
- package/dist/browser/src/index.d.ts.map +0 -1
- package/dist/browser/test/document/crypto.test.d.ts.map +0 -1
- package/dist/browser/test/document/event-vs-command.test.d.ts.map +0 -1
- package/dist/browser/test/document/local.test.d.ts.map +0 -1
- package/dist/browser/test/document/object.test.d.ts.map +0 -1
- package/dist/browser/test/document/operation-id.test.d.ts.map +0 -1
- package/dist/browser/test/document/prune.test.d.ts.map +0 -1
- package/dist/browser/test/document/reducer.test.d.ts.map +0 -1
- package/dist/browser/test/document/skip-operations.test.d.ts.map +0 -1
- package/dist/browser/test/document/undo-redo.test.d.ts.map +0 -1
- package/dist/browser/test/document/utils.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/addUndo.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/attachBranch.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/merge.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/sortOperations.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/split.test.d.ts.map +0 -1
- package/dist/browser/test/document-helpers/utils.d.ts.map +0 -1
- package/dist/browser/test/document-model/object.test.d.ts.map +0 -1
- package/dist/browser/test/document-model/replay.test.d.ts.map +0 -1
- package/dist/browser/test/document-model/skip-operations.test.d.ts.map +0 -1
- package/dist/browser/test/document-model/validation.test.d.ts.map +0 -1
- package/dist/browser/test/document-model/zip.test.d.ts.map +0 -1
- package/dist/browser/test/helpers.d.ts +0 -40
- package/dist/browser/test/helpers.d.ts.map +0 -1
- package/dist/browser/utils.d.ts +0 -2
- package/dist/browser/vite.config.d.ts +0 -3
- package/dist/browser/vite.config.d.ts.map +0 -1
- package/dist/browser/vitest.config.d.ts +0 -3
- package/dist/browser/vitest.config.d.ts.map +0 -1
- package/dist/node/cjs/document-model.js +0 -25
- package/dist/node/cjs/document-model.js.map +0 -1
- package/dist/node/cjs/document.js +0 -16
- package/dist/node/cjs/document.js.map +0 -1
- package/dist/node/cjs/index.js +0 -14
- package/dist/node/cjs/index.js.map +0 -1
- package/dist/node/cjs/internal/creators-ZpkFlacS.js +0 -2684
- package/dist/node/cjs/internal/creators-ZpkFlacS.js.map +0 -1
- package/dist/node/cjs/internal/index-B9N2GsMZ.js +0 -47
- package/dist/node/cjs/internal/index-B9N2GsMZ.js.map +0 -1
- package/dist/node/cjs/internal/index-ClITlWIV.js +0 -19
- package/dist/node/cjs/internal/index-ClITlWIV.js.map +0 -1
- package/dist/node/cjs/internal/index-DVgdtYs7.js +0 -2220
- package/dist/node/cjs/internal/index-DVgdtYs7.js.map +0 -1
- package/dist/node/cjs/internal/object-DVKEoARn.js +0 -183
- package/dist/node/cjs/internal/object-DVKEoARn.js.map +0 -1
- package/dist/node/cjs/package.json +0 -1
- package/dist/node/cjs/utils.js +0 -44
- package/dist/node/cjs/utils.js.map +0 -1
- package/dist/node/document-model.d.ts +0 -2
- package/dist/node/document.d.ts +0 -2
- package/dist/node/es/document-model.js +0 -25
- package/dist/node/es/document-model.js.map +0 -1
- package/dist/node/es/document.js +0 -16
- package/dist/node/es/document.js.map +0 -1
- package/dist/node/es/index.js +0 -14
- package/dist/node/es/index.js.map +0 -1
- package/dist/node/es/internal/creators-0lHfLHX0.js +0 -2685
- package/dist/node/es/internal/creators-0lHfLHX0.js.map +0 -1
- package/dist/node/es/internal/index-BOhJLvSm.js +0 -48
- package/dist/node/es/internal/index-BOhJLvSm.js.map +0 -1
- package/dist/node/es/internal/index-CxWihLAA.js +0 -2221
- package/dist/node/es/internal/index-CxWihLAA.js.map +0 -1
- package/dist/node/es/internal/index-bxdb71Hw.js +0 -20
- package/dist/node/es/internal/index-bxdb71Hw.js.map +0 -1
- package/dist/node/es/internal/object-Bl-LmXHF.js +0 -184
- package/dist/node/es/internal/object-Bl-LmXHF.js.map +0 -1
- package/dist/node/es/package.json +0 -1
- package/dist/node/es/utils.js +0 -44
- package/dist/node/es/utils.js.map +0 -1
- package/dist/node/index.d.ts +0 -6
- package/dist/node/src/document/actions/creators.d.ts.map +0 -1
- package/dist/node/src/document/actions/index.d.ts +0 -15
- package/dist/node/src/document/actions/index.d.ts.map +0 -1
- package/dist/node/src/document/actions/types.d.ts +0 -16
- package/dist/node/src/document/actions/types.d.ts.map +0 -1
- package/dist/node/src/document/index.d.ts +0 -7
- package/dist/node/src/document/index.d.ts.map +0 -1
- package/dist/node/src/document/object.d.ts.map +0 -1
- package/dist/node/src/document/reducer.d.ts +0 -66
- package/dist/node/src/document/reducer.d.ts.map +0 -1
- package/dist/node/src/document/schema/index.d.ts +0 -3
- package/dist/node/src/document/schema/index.d.ts.map +0 -1
- package/dist/node/src/document/schema/types.d.ts +0 -177
- package/dist/node/src/document/schema/types.d.ts.map +0 -1
- package/dist/node/src/document/schema/zod.d.ts +0 -99
- package/dist/node/src/document/schema/zod.d.ts.map +0 -1
- package/dist/node/src/document/signal.d.ts.map +0 -1
- package/dist/node/src/document/types.d.ts +0 -292
- package/dist/node/src/document/types.d.ts.map +0 -1
- package/dist/node/src/document/utils/base.d.ts +0 -89
- package/dist/node/src/document/utils/base.d.ts.map +0 -1
- package/dist/node/src/document/utils/browser.d.ts +0 -11
- package/dist/node/src/document/utils/browser.d.ts.map +0 -1
- package/dist/node/src/document/utils/crypto.d.ts +0 -11
- package/dist/node/src/document/utils/crypto.d.ts.map +0 -1
- package/dist/node/src/document/utils/document-helpers.d.ts +0 -74
- package/dist/node/src/document/utils/document-helpers.d.ts.map +0 -1
- package/dist/node/src/document/utils/errors.d.ts +0 -10
- package/dist/node/src/document/utils/errors.d.ts.map +0 -1
- package/dist/node/src/document/utils/file.d.ts +0 -49
- package/dist/node/src/document/utils/file.d.ts.map +0 -1
- package/dist/node/src/document/utils/index.d.ts +0 -8
- package/dist/node/src/document/utils/index.d.ts.map +0 -1
- package/dist/node/src/document/utils/node.d.ts +0 -11
- package/dist/node/src/document/utils/node.d.ts.map +0 -1
- package/dist/node/src/document/utils/validation.d.ts +0 -3
- package/dist/node/src/document/utils/validation.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/reducers/header.d.ts +0 -3
- package/dist/node/src/document-model/custom/reducers/header.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/reducers/module.d.ts +0 -3
- package/dist/node/src/document-model/custom/reducers/module.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/reducers/operation-error.d.ts +0 -3
- package/dist/node/src/document-model/custom/reducers/operation-error.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/reducers/operation-example.d.ts +0 -3
- package/dist/node/src/document-model/custom/reducers/operation-example.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/reducers/operation.d.ts +0 -3
- package/dist/node/src/document-model/custom/reducers/operation.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/reducers/state.d.ts +0 -3
- package/dist/node/src/document-model/custom/reducers/state.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/reducers/versioning.d.ts +0 -3
- package/dist/node/src/document-model/custom/reducers/versioning.d.ts.map +0 -1
- package/dist/node/src/document-model/custom/utils.d.ts +0 -8
- package/dist/node/src/document-model/custom/utils.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/actions.d.ts +0 -16
- package/dist/node/src/document-model/gen/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/creators.d.ts +0 -8
- package/dist/node/src/document-model/gen/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/document-model.d.ts +0 -3
- package/dist/node/src/document-model/gen/document-model.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/header/actions.d.ts +0 -10
- package/dist/node/src/document-model/gen/header/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/header/creators.d.ts +0 -9
- package/dist/node/src/document-model/gen/header/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/header/object.d.ts +0 -13
- package/dist/node/src/document-model/gen/header/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/header/operations.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/index.d.ts +0 -6
- package/dist/node/src/document-model/gen/index.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/module/actions.d.ts +0 -9
- package/dist/node/src/document-model/gen/module/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/module/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/module/object.d.ts +0 -12
- package/dist/node/src/document-model/gen/module/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/module/operations.d.ts +0 -10
- package/dist/node/src/document-model/gen/module/operations.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/object.d.ts +0 -29
- package/dist/node/src/document-model/gen/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation/actions.d.ts +0 -14
- package/dist/node/src/document-model/gen/operation/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation/creators.d.ts +0 -13
- package/dist/node/src/document-model/gen/operation/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation/operations.d.ts +0 -15
- package/dist/node/src/document-model/gen/operation/operations.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-error/actions.d.ts +0 -11
- package/dist/node/src/document-model/gen/operation-error/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-error/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-error/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-error/operations.d.ts +0 -12
- package/dist/node/src/document-model/gen/operation-error/operations.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-example/actions.d.ts +0 -8
- package/dist/node/src/document-model/gen/operation-example/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-example/creators.d.ts +0 -7
- package/dist/node/src/document-model/gen/operation-example/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-example/object.d.ts +0 -11
- package/dist/node/src/document-model/gen/operation-example/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/operation-example/operations.d.ts +0 -9
- package/dist/node/src/document-model/gen/operation-example/operations.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/reducer.d.ts +0 -6
- package/dist/node/src/document-model/gen/reducer.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/schema/index.d.ts +0 -3
- package/dist/node/src/document-model/gen/schema/index.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/schema/types.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/schema/zod.d.ts +0 -454
- package/dist/node/src/document-model/gen/schema/zod.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/state/actions.d.ts +0 -10
- package/dist/node/src/document-model/gen/state/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/state/creators.d.ts +0 -9
- package/dist/node/src/document-model/gen/state/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/state/object.d.ts +0 -13
- package/dist/node/src/document-model/gen/state/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/state/operations.d.ts +0 -11
- package/dist/node/src/document-model/gen/state/operations.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/types.d.ts +0 -9
- package/dist/node/src/document-model/gen/types.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/utils.d.ts +0 -7
- package/dist/node/src/document-model/gen/utils.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/versioning/actions.d.ts +0 -9
- package/dist/node/src/document-model/gen/versioning/actions.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/versioning/creators.d.ts +0 -8
- package/dist/node/src/document-model/gen/versioning/creators.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/versioning/object.d.ts +0 -12
- package/dist/node/src/document-model/gen/versioning/object.d.ts.map +0 -1
- package/dist/node/src/document-model/gen/versioning/operations.d.ts +0 -10
- package/dist/node/src/document-model/gen/versioning/operations.d.ts.map +0 -1
- package/dist/node/src/document-model/index.d.ts +0 -77
- package/dist/node/src/document-model/index.d.ts.map +0 -1
- package/dist/node/src/index.d.ts +0 -25
- package/dist/node/src/index.d.ts.map +0 -1
- package/dist/node/test/document/crypto.test.d.ts +0 -2
- package/dist/node/test/document/crypto.test.d.ts.map +0 -1
- package/dist/node/test/document/event-vs-command.test.d.ts +0 -2
- package/dist/node/test/document/event-vs-command.test.d.ts.map +0 -1
- package/dist/node/test/document/local.test.d.ts +0 -2
- package/dist/node/test/document/local.test.d.ts.map +0 -1
- package/dist/node/test/document/object.test.d.ts +0 -2
- package/dist/node/test/document/object.test.d.ts.map +0 -1
- package/dist/node/test/document/operation-id.test.d.ts +0 -2
- package/dist/node/test/document/operation-id.test.d.ts.map +0 -1
- package/dist/node/test/document/prune.test.d.ts +0 -2
- package/dist/node/test/document/prune.test.d.ts.map +0 -1
- package/dist/node/test/document/reducer.test.d.ts +0 -2
- package/dist/node/test/document/reducer.test.d.ts.map +0 -1
- package/dist/node/test/document/skip-operations.test.d.ts +0 -2
- package/dist/node/test/document/skip-operations.test.d.ts.map +0 -1
- package/dist/node/test/document/undo-redo.test.d.ts +0 -2
- package/dist/node/test/document/undo-redo.test.d.ts.map +0 -1
- package/dist/node/test/document/utils.test.d.ts +0 -2
- package/dist/node/test/document/utils.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/addUndo.test.d.ts +0 -2
- package/dist/node/test/document-helpers/addUndo.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/attachBranch.test.d.ts +0 -2
- package/dist/node/test/document-helpers/attachBranch.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -2
- package/dist/node/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/conflictResolution.test.d.ts +0 -2
- package/dist/node/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/filterDuplicatedOperations.test.d.ts +0 -2
- package/dist/node/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/garbageCollect.test.d.ts +0 -2
- package/dist/node/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/groupOperationsByScope.test.d.ts +0 -2
- package/dist/node/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/merge.test.d.ts +0 -2
- package/dist/node/test/document-helpers/merge.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/nextSkipNumber.test.d.ts +0 -2
- package/dist/node/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/prepareOperations.test.d.ts +0 -2
- package/dist/node/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/removeExistingOperations.test.d.ts +0 -2
- package/dist/node/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/reshuffleByTimestamp.test.d.ts +0 -2
- package/dist/node/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -2
- package/dist/node/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/skipHeaderOperations.test.d.ts +0 -2
- package/dist/node/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/sortOperations.test.d.ts +0 -2
- package/dist/node/test/document-helpers/sortOperations.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/split.test.d.ts +0 -2
- package/dist/node/test/document-helpers/split.test.d.ts.map +0 -1
- package/dist/node/test/document-helpers/utils.d.ts +0 -8
- package/dist/node/test/document-helpers/utils.d.ts.map +0 -1
- package/dist/node/test/document-model/object.test.d.ts +0 -2
- package/dist/node/test/document-model/object.test.d.ts.map +0 -1
- package/dist/node/test/document-model/replay.test.d.ts +0 -2
- package/dist/node/test/document-model/replay.test.d.ts.map +0 -1
- package/dist/node/test/document-model/skip-operations.test.d.ts +0 -2
- package/dist/node/test/document-model/skip-operations.test.d.ts.map +0 -1
- package/dist/node/test/document-model/validation.test.d.ts +0 -2
- package/dist/node/test/document-model/validation.test.d.ts.map +0 -1
- package/dist/node/test/document-model/zip.test.d.ts +0 -2
- package/dist/node/test/document-model/zip.test.d.ts.map +0 -1
- package/dist/node/test/helpers.d.ts +0 -40
- package/dist/node/test/helpers.d.ts.map +0 -1
- package/dist/node/utils.d.ts +0 -2
- package/dist/node/vite.config.d.ts +0 -3
- package/dist/node/vite.config.d.ts.map +0 -1
- package/dist/node/vitest.config.d.ts +0 -3
- package/dist/node/vitest.config.d.ts.map +0 -1
- /package/dist/{browser/test → test}/document/crypto.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/event-vs-command.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/local.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/object.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/operation-id.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/prune.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/reducer.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/skip-operations.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/undo-redo.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document/utils.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/addUndo.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/attachBranch.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/conflictResolution.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/filterDuplicatedOperations.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/garbageCollect.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/groupOperationsByScope.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/merge.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/nextSkipNumber.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/prepareOperations.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/removeExistingOperations.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/reshuffleByTimestamp.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/skipHeaderOperations.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/sortOperations.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-helpers/split.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-model/object.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-model/replay.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-model/skip-operations.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-model/validation.test.d.ts +0 -0
- /package/dist/{browser/test → test}/document-model/zip.test.d.ts +0 -0
|
@@ -1,2685 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import JSZip from "jszip";
|
|
5
|
-
import { z, ZodError } from "zod";
|
|
6
|
-
import { create, castDraft, unsafe } from "mutative";
|
|
7
|
-
import crypto from "node:crypto";
|
|
8
|
-
import fs from "node:fs";
|
|
9
|
-
import https from "node:https";
|
|
10
|
-
import { join } from "node:path";
|
|
11
|
-
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
12
|
-
const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
|
|
13
|
-
const Load_StateSchema = z.enum(["LOAD_STATE"]);
|
|
14
|
-
const PruneSchema = z.enum(["PRUNE"]);
|
|
15
|
-
const RedoSchema = z.enum(["REDO"]);
|
|
16
|
-
const Set_NameSchema = z.enum(["SET_NAME"]);
|
|
17
|
-
const UndoSchema = z.enum(["UNDO"]);
|
|
18
|
-
function ActionSchema() {
|
|
19
|
-
return z.object({
|
|
20
|
-
__typename: z.literal("Action").optional(),
|
|
21
|
-
type: z.string()
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
function OperationScopeSchema() {
|
|
25
|
-
return z.literal("global").or(z.literal("local"));
|
|
26
|
-
}
|
|
27
|
-
function BaseActionSchema() {
|
|
28
|
-
return z.union([
|
|
29
|
-
LoadStateActionSchema(),
|
|
30
|
-
PruneActionSchema(),
|
|
31
|
-
RedoActionSchema(),
|
|
32
|
-
SetNameActionSchema(),
|
|
33
|
-
UndoActionSchema()
|
|
34
|
-
]);
|
|
35
|
-
}
|
|
36
|
-
function DocumentFileSchema() {
|
|
37
|
-
return z.object({
|
|
38
|
-
__typename: z.literal("DocumentFile").optional(),
|
|
39
|
-
data: z.string(),
|
|
40
|
-
extension: z.string().nullable(),
|
|
41
|
-
fileName: z.string().nullable(),
|
|
42
|
-
mimeType: z.string()
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function LoadStateActionSchema() {
|
|
46
|
-
return z.object({
|
|
47
|
-
input: z.lazy(() => LoadStateActionInputSchema()),
|
|
48
|
-
type: Load_StateSchema,
|
|
49
|
-
scope: OperationScopeSchema()
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
function LoadStateActionInputSchema() {
|
|
53
|
-
return z.object({
|
|
54
|
-
operations: z.number(),
|
|
55
|
-
state: z.lazy(() => LoadStateActionStateInputSchema())
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
function LoadStateActionStateInputSchema() {
|
|
59
|
-
return z.object({
|
|
60
|
-
data: z.unknown().nullish(),
|
|
61
|
-
name: z.string()
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function OperationSchema() {
|
|
65
|
-
return z.object({
|
|
66
|
-
__typename: z.literal("Operation").optional(),
|
|
67
|
-
hash: z.string(),
|
|
68
|
-
index: z.number(),
|
|
69
|
-
timestamp: z.string().datetime(),
|
|
70
|
-
type: z.string()
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
function PruneActionSchema() {
|
|
74
|
-
return z.object({
|
|
75
|
-
input: z.lazy(() => PruneActionInputSchema()),
|
|
76
|
-
type: PruneSchema,
|
|
77
|
-
scope: OperationScopeSchema()
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
function PruneActionInputSchema() {
|
|
81
|
-
return z.object({
|
|
82
|
-
end: z.number().nullish(),
|
|
83
|
-
start: z.number().nullish()
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
const RedoActionInputSchema = z.number;
|
|
87
|
-
function RedoActionSchema() {
|
|
88
|
-
return z.object({
|
|
89
|
-
input: RedoActionInputSchema(),
|
|
90
|
-
type: RedoSchema,
|
|
91
|
-
scope: OperationScopeSchema()
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const SetNameActionInputSchema = z.string;
|
|
95
|
-
function SetNameActionSchema() {
|
|
96
|
-
return z.object({
|
|
97
|
-
input: SetNameActionInputSchema(),
|
|
98
|
-
type: Set_NameSchema,
|
|
99
|
-
scope: z.literal("global")
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
function SetNameOperationSchema() {
|
|
103
|
-
return z.object({
|
|
104
|
-
__typename: z.literal("SetNameOperation").optional(),
|
|
105
|
-
hash: z.string(),
|
|
106
|
-
index: z.number(),
|
|
107
|
-
input: z.string(),
|
|
108
|
-
timestamp: z.string().datetime(),
|
|
109
|
-
type: z.string()
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
const UndoActionInputSchema = z.number;
|
|
113
|
-
function UndoActionSchema() {
|
|
114
|
-
return z.object({
|
|
115
|
-
input: UndoActionInputSchema(),
|
|
116
|
-
type: UndoSchema,
|
|
117
|
-
scope: OperationScopeSchema()
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
const zod = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
121
|
-
__proto__: null,
|
|
122
|
-
ActionSchema,
|
|
123
|
-
BaseActionSchema,
|
|
124
|
-
DocumentFileSchema,
|
|
125
|
-
LoadStateActionInputSchema,
|
|
126
|
-
LoadStateActionSchema,
|
|
127
|
-
LoadStateActionStateInputSchema,
|
|
128
|
-
Load_StateSchema,
|
|
129
|
-
OperationSchema,
|
|
130
|
-
OperationScopeSchema,
|
|
131
|
-
PruneActionInputSchema,
|
|
132
|
-
PruneActionSchema,
|
|
133
|
-
PruneSchema,
|
|
134
|
-
RedoActionInputSchema,
|
|
135
|
-
RedoActionSchema,
|
|
136
|
-
RedoSchema,
|
|
137
|
-
SetNameActionInputSchema,
|
|
138
|
-
SetNameActionSchema,
|
|
139
|
-
SetNameOperationSchema,
|
|
140
|
-
Set_NameSchema,
|
|
141
|
-
UndoActionInputSchema,
|
|
142
|
-
UndoActionSchema,
|
|
143
|
-
UndoSchema,
|
|
144
|
-
definedNonNullAnySchema,
|
|
145
|
-
isDefinedNonNullAny
|
|
146
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
147
|
-
function getDefaultExportFromCjs(x) {
|
|
148
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
149
|
-
}
|
|
150
|
-
var safeStableStringify = { exports: {} };
|
|
151
|
-
var hasRequiredSafeStableStringify;
|
|
152
|
-
function requireSafeStableStringify() {
|
|
153
|
-
if (hasRequiredSafeStableStringify) return safeStableStringify.exports;
|
|
154
|
-
hasRequiredSafeStableStringify = 1;
|
|
155
|
-
(function(module, exports) {
|
|
156
|
-
const { hasOwnProperty } = Object.prototype;
|
|
157
|
-
const stringify = configure();
|
|
158
|
-
stringify.configure = configure;
|
|
159
|
-
stringify.stringify = stringify;
|
|
160
|
-
stringify.default = stringify;
|
|
161
|
-
exports.stringify = stringify;
|
|
162
|
-
exports.configure = configure;
|
|
163
|
-
module.exports = stringify;
|
|
164
|
-
const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
|
|
165
|
-
function strEscape(str) {
|
|
166
|
-
if (str.length < 5e3 && !strEscapeSequencesRegExp.test(str)) {
|
|
167
|
-
return `"${str}"`;
|
|
168
|
-
}
|
|
169
|
-
return JSON.stringify(str);
|
|
170
|
-
}
|
|
171
|
-
function sort(array, comparator) {
|
|
172
|
-
if (array.length > 200 || comparator) {
|
|
173
|
-
return array.sort(comparator);
|
|
174
|
-
}
|
|
175
|
-
for (let i = 1; i < array.length; i++) {
|
|
176
|
-
const currentValue = array[i];
|
|
177
|
-
let position = i;
|
|
178
|
-
while (position !== 0 && array[position - 1] > currentValue) {
|
|
179
|
-
array[position] = array[position - 1];
|
|
180
|
-
position--;
|
|
181
|
-
}
|
|
182
|
-
array[position] = currentValue;
|
|
183
|
-
}
|
|
184
|
-
return array;
|
|
185
|
-
}
|
|
186
|
-
const typedArrayPrototypeGetSymbolToStringTag = Object.getOwnPropertyDescriptor(
|
|
187
|
-
Object.getPrototypeOf(
|
|
188
|
-
Object.getPrototypeOf(
|
|
189
|
-
new Int8Array()
|
|
190
|
-
)
|
|
191
|
-
),
|
|
192
|
-
Symbol.toStringTag
|
|
193
|
-
).get;
|
|
194
|
-
function isTypedArrayWithEntries(value) {
|
|
195
|
-
return typedArrayPrototypeGetSymbolToStringTag.call(value) !== void 0 && value.length !== 0;
|
|
196
|
-
}
|
|
197
|
-
function stringifyTypedArray(array, separator, maximumBreadth) {
|
|
198
|
-
if (array.length < maximumBreadth) {
|
|
199
|
-
maximumBreadth = array.length;
|
|
200
|
-
}
|
|
201
|
-
const whitespace = separator === "," ? "" : " ";
|
|
202
|
-
let res = `"0":${whitespace}${array[0]}`;
|
|
203
|
-
for (let i = 1; i < maximumBreadth; i++) {
|
|
204
|
-
res += `${separator}"${i}":${whitespace}${array[i]}`;
|
|
205
|
-
}
|
|
206
|
-
return res;
|
|
207
|
-
}
|
|
208
|
-
function getCircularValueOption(options) {
|
|
209
|
-
if (hasOwnProperty.call(options, "circularValue")) {
|
|
210
|
-
const circularValue = options.circularValue;
|
|
211
|
-
if (typeof circularValue === "string") {
|
|
212
|
-
return `"${circularValue}"`;
|
|
213
|
-
}
|
|
214
|
-
if (circularValue == null) {
|
|
215
|
-
return circularValue;
|
|
216
|
-
}
|
|
217
|
-
if (circularValue === Error || circularValue === TypeError) {
|
|
218
|
-
return {
|
|
219
|
-
toString() {
|
|
220
|
-
throw new TypeError("Converting circular structure to JSON");
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
|
|
225
|
-
}
|
|
226
|
-
return '"[Circular]"';
|
|
227
|
-
}
|
|
228
|
-
function getDeterministicOption(options) {
|
|
229
|
-
let value;
|
|
230
|
-
if (hasOwnProperty.call(options, "deterministic")) {
|
|
231
|
-
value = options.deterministic;
|
|
232
|
-
if (typeof value !== "boolean" && typeof value !== "function") {
|
|
233
|
-
throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return value === void 0 ? true : value;
|
|
237
|
-
}
|
|
238
|
-
function getBooleanOption(options, key) {
|
|
239
|
-
let value;
|
|
240
|
-
if (hasOwnProperty.call(options, key)) {
|
|
241
|
-
value = options[key];
|
|
242
|
-
if (typeof value !== "boolean") {
|
|
243
|
-
throw new TypeError(`The "${key}" argument must be of type boolean`);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
return value === void 0 ? true : value;
|
|
247
|
-
}
|
|
248
|
-
function getPositiveIntegerOption(options, key) {
|
|
249
|
-
let value;
|
|
250
|
-
if (hasOwnProperty.call(options, key)) {
|
|
251
|
-
value = options[key];
|
|
252
|
-
if (typeof value !== "number") {
|
|
253
|
-
throw new TypeError(`The "${key}" argument must be of type number`);
|
|
254
|
-
}
|
|
255
|
-
if (!Number.isInteger(value)) {
|
|
256
|
-
throw new TypeError(`The "${key}" argument must be an integer`);
|
|
257
|
-
}
|
|
258
|
-
if (value < 1) {
|
|
259
|
-
throw new RangeError(`The "${key}" argument must be >= 1`);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
return value === void 0 ? Infinity : value;
|
|
263
|
-
}
|
|
264
|
-
function getItemCount(number) {
|
|
265
|
-
if (number === 1) {
|
|
266
|
-
return "1 item";
|
|
267
|
-
}
|
|
268
|
-
return `${number} items`;
|
|
269
|
-
}
|
|
270
|
-
function getUniqueReplacerSet(replacerArray) {
|
|
271
|
-
const replacerSet = /* @__PURE__ */ new Set();
|
|
272
|
-
for (const value of replacerArray) {
|
|
273
|
-
if (typeof value === "string" || typeof value === "number") {
|
|
274
|
-
replacerSet.add(String(value));
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
return replacerSet;
|
|
278
|
-
}
|
|
279
|
-
function getStrictOption(options) {
|
|
280
|
-
if (hasOwnProperty.call(options, "strict")) {
|
|
281
|
-
const value = options.strict;
|
|
282
|
-
if (typeof value !== "boolean") {
|
|
283
|
-
throw new TypeError('The "strict" argument must be of type boolean');
|
|
284
|
-
}
|
|
285
|
-
if (value) {
|
|
286
|
-
return (value2) => {
|
|
287
|
-
let message = `Object can not safely be stringified. Received type ${typeof value2}`;
|
|
288
|
-
if (typeof value2 !== "function") message += ` (${value2.toString()})`;
|
|
289
|
-
throw new Error(message);
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function configure(options) {
|
|
295
|
-
options = { ...options };
|
|
296
|
-
const fail = getStrictOption(options);
|
|
297
|
-
if (fail) {
|
|
298
|
-
if (options.bigint === void 0) {
|
|
299
|
-
options.bigint = false;
|
|
300
|
-
}
|
|
301
|
-
if (!("circularValue" in options)) {
|
|
302
|
-
options.circularValue = Error;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
const circularValue = getCircularValueOption(options);
|
|
306
|
-
const bigint = getBooleanOption(options, "bigint");
|
|
307
|
-
const deterministic = getDeterministicOption(options);
|
|
308
|
-
const comparator = typeof deterministic === "function" ? deterministic : void 0;
|
|
309
|
-
const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
|
|
310
|
-
const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
|
|
311
|
-
function stringifyFnReplacer(key, parent, stack, replacer, spacer, indentation) {
|
|
312
|
-
let value = parent[key];
|
|
313
|
-
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
|
|
314
|
-
value = value.toJSON(key);
|
|
315
|
-
}
|
|
316
|
-
value = replacer.call(parent, key, value);
|
|
317
|
-
switch (typeof value) {
|
|
318
|
-
case "string":
|
|
319
|
-
return strEscape(value);
|
|
320
|
-
case "object": {
|
|
321
|
-
if (value === null) {
|
|
322
|
-
return "null";
|
|
323
|
-
}
|
|
324
|
-
if (stack.indexOf(value) !== -1) {
|
|
325
|
-
return circularValue;
|
|
326
|
-
}
|
|
327
|
-
let res = "";
|
|
328
|
-
let join2 = ",";
|
|
329
|
-
const originalIndentation = indentation;
|
|
330
|
-
if (Array.isArray(value)) {
|
|
331
|
-
if (value.length === 0) {
|
|
332
|
-
return "[]";
|
|
333
|
-
}
|
|
334
|
-
if (maximumDepth < stack.length + 1) {
|
|
335
|
-
return '"[Array]"';
|
|
336
|
-
}
|
|
337
|
-
stack.push(value);
|
|
338
|
-
if (spacer !== "") {
|
|
339
|
-
indentation += spacer;
|
|
340
|
-
res += `
|
|
341
|
-
${indentation}`;
|
|
342
|
-
join2 = `,
|
|
343
|
-
${indentation}`;
|
|
344
|
-
}
|
|
345
|
-
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
346
|
-
let i = 0;
|
|
347
|
-
for (; i < maximumValuesToStringify - 1; i++) {
|
|
348
|
-
const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
349
|
-
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
350
|
-
res += join2;
|
|
351
|
-
}
|
|
352
|
-
const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
|
|
353
|
-
res += tmp !== void 0 ? tmp : "null";
|
|
354
|
-
if (value.length - 1 > maximumBreadth) {
|
|
355
|
-
const removedKeys = value.length - maximumBreadth - 1;
|
|
356
|
-
res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
357
|
-
}
|
|
358
|
-
if (spacer !== "") {
|
|
359
|
-
res += `
|
|
360
|
-
${originalIndentation}`;
|
|
361
|
-
}
|
|
362
|
-
stack.pop();
|
|
363
|
-
return `[${res}]`;
|
|
364
|
-
}
|
|
365
|
-
let keys = Object.keys(value);
|
|
366
|
-
const keyLength = keys.length;
|
|
367
|
-
if (keyLength === 0) {
|
|
368
|
-
return "{}";
|
|
369
|
-
}
|
|
370
|
-
if (maximumDepth < stack.length + 1) {
|
|
371
|
-
return '"[Object]"';
|
|
372
|
-
}
|
|
373
|
-
let whitespace = "";
|
|
374
|
-
let separator = "";
|
|
375
|
-
if (spacer !== "") {
|
|
376
|
-
indentation += spacer;
|
|
377
|
-
join2 = `,
|
|
378
|
-
${indentation}`;
|
|
379
|
-
whitespace = " ";
|
|
380
|
-
}
|
|
381
|
-
const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
382
|
-
if (deterministic && !isTypedArrayWithEntries(value)) {
|
|
383
|
-
keys = sort(keys, comparator);
|
|
384
|
-
}
|
|
385
|
-
stack.push(value);
|
|
386
|
-
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
387
|
-
const key2 = keys[i];
|
|
388
|
-
const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
|
|
389
|
-
if (tmp !== void 0) {
|
|
390
|
-
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
391
|
-
separator = join2;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
if (keyLength > maximumBreadth) {
|
|
395
|
-
const removedKeys = keyLength - maximumBreadth;
|
|
396
|
-
res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
|
|
397
|
-
separator = join2;
|
|
398
|
-
}
|
|
399
|
-
if (spacer !== "" && separator.length > 1) {
|
|
400
|
-
res = `
|
|
401
|
-
${indentation}${res}
|
|
402
|
-
${originalIndentation}`;
|
|
403
|
-
}
|
|
404
|
-
stack.pop();
|
|
405
|
-
return `{${res}}`;
|
|
406
|
-
}
|
|
407
|
-
case "number":
|
|
408
|
-
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
409
|
-
case "boolean":
|
|
410
|
-
return value === true ? "true" : "false";
|
|
411
|
-
case "undefined":
|
|
412
|
-
return void 0;
|
|
413
|
-
case "bigint":
|
|
414
|
-
if (bigint) {
|
|
415
|
-
return String(value);
|
|
416
|
-
}
|
|
417
|
-
// fallthrough
|
|
418
|
-
default:
|
|
419
|
-
return fail ? fail(value) : void 0;
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
function stringifyArrayReplacer(key, value, stack, replacer, spacer, indentation) {
|
|
423
|
-
if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
|
|
424
|
-
value = value.toJSON(key);
|
|
425
|
-
}
|
|
426
|
-
switch (typeof value) {
|
|
427
|
-
case "string":
|
|
428
|
-
return strEscape(value);
|
|
429
|
-
case "object": {
|
|
430
|
-
if (value === null) {
|
|
431
|
-
return "null";
|
|
432
|
-
}
|
|
433
|
-
if (stack.indexOf(value) !== -1) {
|
|
434
|
-
return circularValue;
|
|
435
|
-
}
|
|
436
|
-
const originalIndentation = indentation;
|
|
437
|
-
let res = "";
|
|
438
|
-
let join2 = ",";
|
|
439
|
-
if (Array.isArray(value)) {
|
|
440
|
-
if (value.length === 0) {
|
|
441
|
-
return "[]";
|
|
442
|
-
}
|
|
443
|
-
if (maximumDepth < stack.length + 1) {
|
|
444
|
-
return '"[Array]"';
|
|
445
|
-
}
|
|
446
|
-
stack.push(value);
|
|
447
|
-
if (spacer !== "") {
|
|
448
|
-
indentation += spacer;
|
|
449
|
-
res += `
|
|
450
|
-
${indentation}`;
|
|
451
|
-
join2 = `,
|
|
452
|
-
${indentation}`;
|
|
453
|
-
}
|
|
454
|
-
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
455
|
-
let i = 0;
|
|
456
|
-
for (; i < maximumValuesToStringify - 1; i++) {
|
|
457
|
-
const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
458
|
-
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
459
|
-
res += join2;
|
|
460
|
-
}
|
|
461
|
-
const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
|
|
462
|
-
res += tmp !== void 0 ? tmp : "null";
|
|
463
|
-
if (value.length - 1 > maximumBreadth) {
|
|
464
|
-
const removedKeys = value.length - maximumBreadth - 1;
|
|
465
|
-
res += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
466
|
-
}
|
|
467
|
-
if (spacer !== "") {
|
|
468
|
-
res += `
|
|
469
|
-
${originalIndentation}`;
|
|
470
|
-
}
|
|
471
|
-
stack.pop();
|
|
472
|
-
return `[${res}]`;
|
|
473
|
-
}
|
|
474
|
-
stack.push(value);
|
|
475
|
-
let whitespace = "";
|
|
476
|
-
if (spacer !== "") {
|
|
477
|
-
indentation += spacer;
|
|
478
|
-
join2 = `,
|
|
479
|
-
${indentation}`;
|
|
480
|
-
whitespace = " ";
|
|
481
|
-
}
|
|
482
|
-
let separator = "";
|
|
483
|
-
for (const key2 of replacer) {
|
|
484
|
-
const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
|
|
485
|
-
if (tmp !== void 0) {
|
|
486
|
-
res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
|
|
487
|
-
separator = join2;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
if (spacer !== "" && separator.length > 1) {
|
|
491
|
-
res = `
|
|
492
|
-
${indentation}${res}
|
|
493
|
-
${originalIndentation}`;
|
|
494
|
-
}
|
|
495
|
-
stack.pop();
|
|
496
|
-
return `{${res}}`;
|
|
497
|
-
}
|
|
498
|
-
case "number":
|
|
499
|
-
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
500
|
-
case "boolean":
|
|
501
|
-
return value === true ? "true" : "false";
|
|
502
|
-
case "undefined":
|
|
503
|
-
return void 0;
|
|
504
|
-
case "bigint":
|
|
505
|
-
if (bigint) {
|
|
506
|
-
return String(value);
|
|
507
|
-
}
|
|
508
|
-
// fallthrough
|
|
509
|
-
default:
|
|
510
|
-
return fail ? fail(value) : void 0;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
function stringifyIndent(key, value, stack, spacer, indentation) {
|
|
514
|
-
switch (typeof value) {
|
|
515
|
-
case "string":
|
|
516
|
-
return strEscape(value);
|
|
517
|
-
case "object": {
|
|
518
|
-
if (value === null) {
|
|
519
|
-
return "null";
|
|
520
|
-
}
|
|
521
|
-
if (typeof value.toJSON === "function") {
|
|
522
|
-
value = value.toJSON(key);
|
|
523
|
-
if (typeof value !== "object") {
|
|
524
|
-
return stringifyIndent(key, value, stack, spacer, indentation);
|
|
525
|
-
}
|
|
526
|
-
if (value === null) {
|
|
527
|
-
return "null";
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
if (stack.indexOf(value) !== -1) {
|
|
531
|
-
return circularValue;
|
|
532
|
-
}
|
|
533
|
-
const originalIndentation = indentation;
|
|
534
|
-
if (Array.isArray(value)) {
|
|
535
|
-
if (value.length === 0) {
|
|
536
|
-
return "[]";
|
|
537
|
-
}
|
|
538
|
-
if (maximumDepth < stack.length + 1) {
|
|
539
|
-
return '"[Array]"';
|
|
540
|
-
}
|
|
541
|
-
stack.push(value);
|
|
542
|
-
indentation += spacer;
|
|
543
|
-
let res2 = `
|
|
544
|
-
${indentation}`;
|
|
545
|
-
const join3 = `,
|
|
546
|
-
${indentation}`;
|
|
547
|
-
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
548
|
-
let i = 0;
|
|
549
|
-
for (; i < maximumValuesToStringify - 1; i++) {
|
|
550
|
-
const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
551
|
-
res2 += tmp2 !== void 0 ? tmp2 : "null";
|
|
552
|
-
res2 += join3;
|
|
553
|
-
}
|
|
554
|
-
const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
|
|
555
|
-
res2 += tmp !== void 0 ? tmp : "null";
|
|
556
|
-
if (value.length - 1 > maximumBreadth) {
|
|
557
|
-
const removedKeys = value.length - maximumBreadth - 1;
|
|
558
|
-
res2 += `${join3}"... ${getItemCount(removedKeys)} not stringified"`;
|
|
559
|
-
}
|
|
560
|
-
res2 += `
|
|
561
|
-
${originalIndentation}`;
|
|
562
|
-
stack.pop();
|
|
563
|
-
return `[${res2}]`;
|
|
564
|
-
}
|
|
565
|
-
let keys = Object.keys(value);
|
|
566
|
-
const keyLength = keys.length;
|
|
567
|
-
if (keyLength === 0) {
|
|
568
|
-
return "{}";
|
|
569
|
-
}
|
|
570
|
-
if (maximumDepth < stack.length + 1) {
|
|
571
|
-
return '"[Object]"';
|
|
572
|
-
}
|
|
573
|
-
indentation += spacer;
|
|
574
|
-
const join2 = `,
|
|
575
|
-
${indentation}`;
|
|
576
|
-
let res = "";
|
|
577
|
-
let separator = "";
|
|
578
|
-
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
579
|
-
if (isTypedArrayWithEntries(value)) {
|
|
580
|
-
res += stringifyTypedArray(value, join2, maximumBreadth);
|
|
581
|
-
keys = keys.slice(value.length);
|
|
582
|
-
maximumPropertiesToStringify -= value.length;
|
|
583
|
-
separator = join2;
|
|
584
|
-
}
|
|
585
|
-
if (deterministic) {
|
|
586
|
-
keys = sort(keys, comparator);
|
|
587
|
-
}
|
|
588
|
-
stack.push(value);
|
|
589
|
-
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
590
|
-
const key2 = keys[i];
|
|
591
|
-
const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
|
|
592
|
-
if (tmp !== void 0) {
|
|
593
|
-
res += `${separator}${strEscape(key2)}: ${tmp}`;
|
|
594
|
-
separator = join2;
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
if (keyLength > maximumBreadth) {
|
|
598
|
-
const removedKeys = keyLength - maximumBreadth;
|
|
599
|
-
res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
|
|
600
|
-
separator = join2;
|
|
601
|
-
}
|
|
602
|
-
if (separator !== "") {
|
|
603
|
-
res = `
|
|
604
|
-
${indentation}${res}
|
|
605
|
-
${originalIndentation}`;
|
|
606
|
-
}
|
|
607
|
-
stack.pop();
|
|
608
|
-
return `{${res}}`;
|
|
609
|
-
}
|
|
610
|
-
case "number":
|
|
611
|
-
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
612
|
-
case "boolean":
|
|
613
|
-
return value === true ? "true" : "false";
|
|
614
|
-
case "undefined":
|
|
615
|
-
return void 0;
|
|
616
|
-
case "bigint":
|
|
617
|
-
if (bigint) {
|
|
618
|
-
return String(value);
|
|
619
|
-
}
|
|
620
|
-
// fallthrough
|
|
621
|
-
default:
|
|
622
|
-
return fail ? fail(value) : void 0;
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
function stringifySimple(key, value, stack) {
|
|
626
|
-
switch (typeof value) {
|
|
627
|
-
case "string":
|
|
628
|
-
return strEscape(value);
|
|
629
|
-
case "object": {
|
|
630
|
-
if (value === null) {
|
|
631
|
-
return "null";
|
|
632
|
-
}
|
|
633
|
-
if (typeof value.toJSON === "function") {
|
|
634
|
-
value = value.toJSON(key);
|
|
635
|
-
if (typeof value !== "object") {
|
|
636
|
-
return stringifySimple(key, value, stack);
|
|
637
|
-
}
|
|
638
|
-
if (value === null) {
|
|
639
|
-
return "null";
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
if (stack.indexOf(value) !== -1) {
|
|
643
|
-
return circularValue;
|
|
644
|
-
}
|
|
645
|
-
let res = "";
|
|
646
|
-
const hasLength = value.length !== void 0;
|
|
647
|
-
if (hasLength && Array.isArray(value)) {
|
|
648
|
-
if (value.length === 0) {
|
|
649
|
-
return "[]";
|
|
650
|
-
}
|
|
651
|
-
if (maximumDepth < stack.length + 1) {
|
|
652
|
-
return '"[Array]"';
|
|
653
|
-
}
|
|
654
|
-
stack.push(value);
|
|
655
|
-
const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
|
|
656
|
-
let i = 0;
|
|
657
|
-
for (; i < maximumValuesToStringify - 1; i++) {
|
|
658
|
-
const tmp2 = stringifySimple(String(i), value[i], stack);
|
|
659
|
-
res += tmp2 !== void 0 ? tmp2 : "null";
|
|
660
|
-
res += ",";
|
|
661
|
-
}
|
|
662
|
-
const tmp = stringifySimple(String(i), value[i], stack);
|
|
663
|
-
res += tmp !== void 0 ? tmp : "null";
|
|
664
|
-
if (value.length - 1 > maximumBreadth) {
|
|
665
|
-
const removedKeys = value.length - maximumBreadth - 1;
|
|
666
|
-
res += `,"... ${getItemCount(removedKeys)} not stringified"`;
|
|
667
|
-
}
|
|
668
|
-
stack.pop();
|
|
669
|
-
return `[${res}]`;
|
|
670
|
-
}
|
|
671
|
-
let keys = Object.keys(value);
|
|
672
|
-
const keyLength = keys.length;
|
|
673
|
-
if (keyLength === 0) {
|
|
674
|
-
return "{}";
|
|
675
|
-
}
|
|
676
|
-
if (maximumDepth < stack.length + 1) {
|
|
677
|
-
return '"[Object]"';
|
|
678
|
-
}
|
|
679
|
-
let separator = "";
|
|
680
|
-
let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
|
|
681
|
-
if (hasLength && isTypedArrayWithEntries(value)) {
|
|
682
|
-
res += stringifyTypedArray(value, ",", maximumBreadth);
|
|
683
|
-
keys = keys.slice(value.length);
|
|
684
|
-
maximumPropertiesToStringify -= value.length;
|
|
685
|
-
separator = ",";
|
|
686
|
-
}
|
|
687
|
-
if (deterministic) {
|
|
688
|
-
keys = sort(keys, comparator);
|
|
689
|
-
}
|
|
690
|
-
stack.push(value);
|
|
691
|
-
for (let i = 0; i < maximumPropertiesToStringify; i++) {
|
|
692
|
-
const key2 = keys[i];
|
|
693
|
-
const tmp = stringifySimple(key2, value[key2], stack);
|
|
694
|
-
if (tmp !== void 0) {
|
|
695
|
-
res += `${separator}${strEscape(key2)}:${tmp}`;
|
|
696
|
-
separator = ",";
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
if (keyLength > maximumBreadth) {
|
|
700
|
-
const removedKeys = keyLength - maximumBreadth;
|
|
701
|
-
res += `${separator}"...":"${getItemCount(removedKeys)} not stringified"`;
|
|
702
|
-
}
|
|
703
|
-
stack.pop();
|
|
704
|
-
return `{${res}}`;
|
|
705
|
-
}
|
|
706
|
-
case "number":
|
|
707
|
-
return isFinite(value) ? String(value) : fail ? fail(value) : "null";
|
|
708
|
-
case "boolean":
|
|
709
|
-
return value === true ? "true" : "false";
|
|
710
|
-
case "undefined":
|
|
711
|
-
return void 0;
|
|
712
|
-
case "bigint":
|
|
713
|
-
if (bigint) {
|
|
714
|
-
return String(value);
|
|
715
|
-
}
|
|
716
|
-
// fallthrough
|
|
717
|
-
default:
|
|
718
|
-
return fail ? fail(value) : void 0;
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
function stringify2(value, replacer, space) {
|
|
722
|
-
if (arguments.length > 1) {
|
|
723
|
-
let spacer = "";
|
|
724
|
-
if (typeof space === "number") {
|
|
725
|
-
spacer = " ".repeat(Math.min(space, 10));
|
|
726
|
-
} else if (typeof space === "string") {
|
|
727
|
-
spacer = space.slice(0, 10);
|
|
728
|
-
}
|
|
729
|
-
if (replacer != null) {
|
|
730
|
-
if (typeof replacer === "function") {
|
|
731
|
-
return stringifyFnReplacer("", { "": value }, [], replacer, spacer, "");
|
|
732
|
-
}
|
|
733
|
-
if (Array.isArray(replacer)) {
|
|
734
|
-
return stringifyArrayReplacer("", value, [], getUniqueReplacerSet(replacer), spacer, "");
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
if (spacer.length !== 0) {
|
|
738
|
-
return stringifyIndent("", value, [], spacer, "");
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
return stringifySimple("", value, []);
|
|
742
|
-
}
|
|
743
|
-
return stringify2;
|
|
744
|
-
}
|
|
745
|
-
})(safeStableStringify, safeStableStringify.exports);
|
|
746
|
-
return safeStableStringify.exports;
|
|
747
|
-
}
|
|
748
|
-
var safeStableStringifyExports = requireSafeStableStringify();
|
|
749
|
-
const cjsModule = /* @__PURE__ */ getDefaultExportFromCjs(safeStableStringifyExports);
|
|
750
|
-
cjsModule.configure;
|
|
751
|
-
function generateUUID(options) {
|
|
752
|
-
return crypto.randomUUID(options);
|
|
753
|
-
}
|
|
754
|
-
function writeFile(path, name, data) {
|
|
755
|
-
const filePath = join(path, name);
|
|
756
|
-
fs.mkdirSync(path, { recursive: true });
|
|
757
|
-
return new Promise((resolve, reject) => {
|
|
758
|
-
try {
|
|
759
|
-
fs.writeFile(filePath, data, {}, (err) => {
|
|
760
|
-
if (err) {
|
|
761
|
-
reject(err);
|
|
762
|
-
} else {
|
|
763
|
-
resolve(filePath);
|
|
764
|
-
}
|
|
765
|
-
});
|
|
766
|
-
} catch (error) {
|
|
767
|
-
reject(error);
|
|
768
|
-
}
|
|
769
|
-
});
|
|
770
|
-
}
|
|
771
|
-
function readFile(path) {
|
|
772
|
-
return fs.readFileSync(path);
|
|
773
|
-
}
|
|
774
|
-
function fetchFile(url) {
|
|
775
|
-
return new Promise((resolve, reject) => {
|
|
776
|
-
https.get(url, (resp) => {
|
|
777
|
-
const data = [];
|
|
778
|
-
const mimeType = resp.headers["content-type"];
|
|
779
|
-
resp.on("data", (chunk) => {
|
|
780
|
-
data.push(chunk);
|
|
781
|
-
});
|
|
782
|
-
resp.on("end", () => {
|
|
783
|
-
resolve({ buffer: Buffer.concat(data), mimeType });
|
|
784
|
-
});
|
|
785
|
-
}).on("error", (err) => {
|
|
786
|
-
reject(err);
|
|
787
|
-
});
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
const getFile = async (file) => {
|
|
791
|
-
return readFile(file);
|
|
792
|
-
};
|
|
793
|
-
const hash = (data, algorithm = "sha1") => {
|
|
794
|
-
return crypto.createHash(algorithm).update(data).digest("base64");
|
|
795
|
-
};
|
|
796
|
-
function generateId(method) {
|
|
797
|
-
if (method && method.toString() !== "UUIDv4") {
|
|
798
|
-
throw new Error(
|
|
799
|
-
`Id generation method not supported: "${method.toString()}"`
|
|
800
|
-
);
|
|
801
|
-
}
|
|
802
|
-
return generateUUID();
|
|
803
|
-
}
|
|
804
|
-
function getUnixTimestamp(date) {
|
|
805
|
-
return (new Date(date).getTime() / 1e3).toFixed(0);
|
|
806
|
-
}
|
|
807
|
-
function buildOperationSignatureParams({
|
|
808
|
-
documentId,
|
|
809
|
-
signer,
|
|
810
|
-
operation,
|
|
811
|
-
previousStateHash
|
|
812
|
-
}) {
|
|
813
|
-
const { timestamp, scope, id, type } = operation;
|
|
814
|
-
return [
|
|
815
|
-
getUnixTimestamp(timestamp),
|
|
816
|
-
// timestamp,
|
|
817
|
-
signer.app.key,
|
|
818
|
-
// signer public key
|
|
819
|
-
hash(
|
|
820
|
-
// hash (docID, scope, operationID, operationName, operationInput)
|
|
821
|
-
[documentId, scope, id, type, cjsModule(operation.input)].join("")
|
|
822
|
-
),
|
|
823
|
-
previousStateHash
|
|
824
|
-
// state hash that the operation was applied to
|
|
825
|
-
];
|
|
826
|
-
}
|
|
827
|
-
const textEncode = new TextEncoder();
|
|
828
|
-
function buildOperationSignatureMessage(params) {
|
|
829
|
-
const message = params.join("");
|
|
830
|
-
const prefix = "Signed Operation:\n" + message.length.toString();
|
|
831
|
-
return textEncode.encode(prefix + message);
|
|
832
|
-
}
|
|
833
|
-
function ab2hex(ab) {
|
|
834
|
-
const view = ArrayBuffer.isView(ab) ? ab : new Uint8Array(ab);
|
|
835
|
-
return Array.prototype.map.call(view, (x) => ("00" + x.toString(16)).slice(-2)).join("");
|
|
836
|
-
}
|
|
837
|
-
function hex2ab(hex) {
|
|
838
|
-
var _a;
|
|
839
|
-
return new Uint8Array(
|
|
840
|
-
((_a = hex.match(/[\da-f]{2}/gi)) == null ? void 0 : _a.map(function(h) {
|
|
841
|
-
return parseInt(h, 16);
|
|
842
|
-
})) ?? []
|
|
843
|
-
);
|
|
844
|
-
}
|
|
845
|
-
async function buildOperationSignature(context, signMethod) {
|
|
846
|
-
const params = buildOperationSignatureParams(context);
|
|
847
|
-
const message = buildOperationSignatureMessage(params);
|
|
848
|
-
const signature = await signMethod(message);
|
|
849
|
-
return [...params, `0x${ab2hex(signature)}`];
|
|
850
|
-
}
|
|
851
|
-
async function buildSignedOperation(action, reducer, document, context, signHandler) {
|
|
852
|
-
var _a, _b;
|
|
853
|
-
const result = reducer(document, action, void 0, {
|
|
854
|
-
reuseHash: true,
|
|
855
|
-
reuseOperationResultingState: true
|
|
856
|
-
});
|
|
857
|
-
const operation = result.operations[action.scope].at(-1);
|
|
858
|
-
if (!operation) {
|
|
859
|
-
throw new Error("Action was not applied");
|
|
860
|
-
}
|
|
861
|
-
const previousStateHash = ((_a = result.operations[action.scope].at(-2)) == null ? void 0 : _a.hash) ?? "";
|
|
862
|
-
const signature = await buildOperationSignature(
|
|
863
|
-
{
|
|
864
|
-
...context,
|
|
865
|
-
operation,
|
|
866
|
-
previousStateHash
|
|
867
|
-
},
|
|
868
|
-
signHandler
|
|
869
|
-
);
|
|
870
|
-
return {
|
|
871
|
-
...operation,
|
|
872
|
-
context: {
|
|
873
|
-
...operation.context,
|
|
874
|
-
signer: {
|
|
875
|
-
...(_b = operation.context) == null ? void 0 : _b.signer,
|
|
876
|
-
...context.signer,
|
|
877
|
-
signatures: [...context.signer.signatures ?? [], signature]
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
async function verifyOperationSignature(signature, signer, verifyHandler) {
|
|
883
|
-
const publicKey = signer.app.key;
|
|
884
|
-
const params = signature.slice(0, 4);
|
|
885
|
-
const signatureBytes = hex2ab(signature[4]);
|
|
886
|
-
const expectedMessage = buildOperationSignatureMessage(params);
|
|
887
|
-
return verifyHandler(publicKey, signatureBytes, expectedMessage);
|
|
888
|
-
}
|
|
889
|
-
class InvalidActionInputError extends Error {
|
|
890
|
-
constructor(data) {
|
|
891
|
-
super();
|
|
892
|
-
__publicField(this, "data");
|
|
893
|
-
this.name = "InvalidActionInputError";
|
|
894
|
-
this.data = data;
|
|
895
|
-
this.message = this.message || `Invalid action input: ${JSON.stringify(data, null, 2)}`;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
class InvalidActionInputZodError extends InvalidActionInputError {
|
|
899
|
-
constructor(issues) {
|
|
900
|
-
super(issues);
|
|
901
|
-
__publicField(this, "issues");
|
|
902
|
-
this.issues = issues;
|
|
903
|
-
this.name = "InvalidActionInputZodError";
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
const types = {
|
|
907
|
-
"application/andrew-inset": ["ez"],
|
|
908
|
-
"application/appinstaller": ["appinstaller"],
|
|
909
|
-
"application/applixware": ["aw"],
|
|
910
|
-
"application/appx": ["appx"],
|
|
911
|
-
"application/appxbundle": ["appxbundle"],
|
|
912
|
-
"application/atom+xml": ["atom"],
|
|
913
|
-
"application/atomcat+xml": ["atomcat"],
|
|
914
|
-
"application/atomdeleted+xml": ["atomdeleted"],
|
|
915
|
-
"application/atomsvc+xml": ["atomsvc"],
|
|
916
|
-
"application/atsc-dwd+xml": ["dwd"],
|
|
917
|
-
"application/atsc-held+xml": ["held"],
|
|
918
|
-
"application/atsc-rsat+xml": ["rsat"],
|
|
919
|
-
"application/automationml-aml+xml": ["aml"],
|
|
920
|
-
"application/automationml-amlx+zip": ["amlx"],
|
|
921
|
-
"application/bdoc": ["bdoc"],
|
|
922
|
-
"application/calendar+xml": ["xcs"],
|
|
923
|
-
"application/ccxml+xml": ["ccxml"],
|
|
924
|
-
"application/cdfx+xml": ["cdfx"],
|
|
925
|
-
"application/cdmi-capability": ["cdmia"],
|
|
926
|
-
"application/cdmi-container": ["cdmic"],
|
|
927
|
-
"application/cdmi-domain": ["cdmid"],
|
|
928
|
-
"application/cdmi-object": ["cdmio"],
|
|
929
|
-
"application/cdmi-queue": ["cdmiq"],
|
|
930
|
-
"application/cpl+xml": ["cpl"],
|
|
931
|
-
"application/cu-seeme": ["cu"],
|
|
932
|
-
"application/cwl": ["cwl"],
|
|
933
|
-
"application/dash+xml": ["mpd"],
|
|
934
|
-
"application/dash-patch+xml": ["mpp"],
|
|
935
|
-
"application/davmount+xml": ["davmount"],
|
|
936
|
-
"application/docbook+xml": ["dbk"],
|
|
937
|
-
"application/dssc+der": ["dssc"],
|
|
938
|
-
"application/dssc+xml": ["xdssc"],
|
|
939
|
-
"application/ecmascript": ["ecma"],
|
|
940
|
-
"application/emma+xml": ["emma"],
|
|
941
|
-
"application/emotionml+xml": ["emotionml"],
|
|
942
|
-
"application/epub+zip": ["epub"],
|
|
943
|
-
"application/exi": ["exi"],
|
|
944
|
-
"application/express": ["exp"],
|
|
945
|
-
"application/fdf": ["fdf"],
|
|
946
|
-
"application/fdt+xml": ["fdt"],
|
|
947
|
-
"application/font-tdpfr": ["pfr"],
|
|
948
|
-
"application/geo+json": ["geojson"],
|
|
949
|
-
"application/gml+xml": ["gml"],
|
|
950
|
-
"application/gpx+xml": ["gpx"],
|
|
951
|
-
"application/gxf": ["gxf"],
|
|
952
|
-
"application/gzip": ["gz"],
|
|
953
|
-
"application/hjson": ["hjson"],
|
|
954
|
-
"application/hyperstudio": ["stk"],
|
|
955
|
-
"application/inkml+xml": ["ink", "inkml"],
|
|
956
|
-
"application/ipfix": ["ipfix"],
|
|
957
|
-
"application/its+xml": ["its"],
|
|
958
|
-
"application/java-archive": ["jar", "war", "ear"],
|
|
959
|
-
"application/java-serialized-object": ["ser"],
|
|
960
|
-
"application/java-vm": ["class"],
|
|
961
|
-
"application/javascript": ["*js"],
|
|
962
|
-
"application/json": ["json", "map"],
|
|
963
|
-
"application/json5": ["json5"],
|
|
964
|
-
"application/jsonml+json": ["jsonml"],
|
|
965
|
-
"application/ld+json": ["jsonld"],
|
|
966
|
-
"application/lgr+xml": ["lgr"],
|
|
967
|
-
"application/lost+xml": ["lostxml"],
|
|
968
|
-
"application/mac-binhex40": ["hqx"],
|
|
969
|
-
"application/mac-compactpro": ["cpt"],
|
|
970
|
-
"application/mads+xml": ["mads"],
|
|
971
|
-
"application/manifest+json": ["webmanifest"],
|
|
972
|
-
"application/marc": ["mrc"],
|
|
973
|
-
"application/marcxml+xml": ["mrcx"],
|
|
974
|
-
"application/mathematica": ["ma", "nb", "mb"],
|
|
975
|
-
"application/mathml+xml": ["mathml"],
|
|
976
|
-
"application/mbox": ["mbox"],
|
|
977
|
-
"application/media-policy-dataset+xml": ["mpf"],
|
|
978
|
-
"application/mediaservercontrol+xml": ["mscml"],
|
|
979
|
-
"application/metalink+xml": ["metalink"],
|
|
980
|
-
"application/metalink4+xml": ["meta4"],
|
|
981
|
-
"application/mets+xml": ["mets"],
|
|
982
|
-
"application/mmt-aei+xml": ["maei"],
|
|
983
|
-
"application/mmt-usd+xml": ["musd"],
|
|
984
|
-
"application/mods+xml": ["mods"],
|
|
985
|
-
"application/mp21": ["m21", "mp21"],
|
|
986
|
-
"application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"],
|
|
987
|
-
"application/msix": ["msix"],
|
|
988
|
-
"application/msixbundle": ["msixbundle"],
|
|
989
|
-
"application/msword": ["doc", "dot"],
|
|
990
|
-
"application/mxf": ["mxf"],
|
|
991
|
-
"application/n-quads": ["nq"],
|
|
992
|
-
"application/n-triples": ["nt"],
|
|
993
|
-
"application/node": ["cjs"],
|
|
994
|
-
"application/octet-stream": [
|
|
995
|
-
"bin",
|
|
996
|
-
"dms",
|
|
997
|
-
"lrf",
|
|
998
|
-
"mar",
|
|
999
|
-
"so",
|
|
1000
|
-
"dist",
|
|
1001
|
-
"distz",
|
|
1002
|
-
"pkg",
|
|
1003
|
-
"bpk",
|
|
1004
|
-
"dump",
|
|
1005
|
-
"elc",
|
|
1006
|
-
"deploy",
|
|
1007
|
-
"exe",
|
|
1008
|
-
"dll",
|
|
1009
|
-
"deb",
|
|
1010
|
-
"dmg",
|
|
1011
|
-
"iso",
|
|
1012
|
-
"img",
|
|
1013
|
-
"msi",
|
|
1014
|
-
"msp",
|
|
1015
|
-
"msm",
|
|
1016
|
-
"buffer"
|
|
1017
|
-
],
|
|
1018
|
-
"application/oda": ["oda"],
|
|
1019
|
-
"application/oebps-package+xml": ["opf"],
|
|
1020
|
-
"application/ogg": ["ogx"],
|
|
1021
|
-
"application/omdoc+xml": ["omdoc"],
|
|
1022
|
-
"application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"],
|
|
1023
|
-
"application/oxps": ["oxps"],
|
|
1024
|
-
"application/p2p-overlay+xml": ["relo"],
|
|
1025
|
-
"application/patch-ops-error+xml": ["xer"],
|
|
1026
|
-
"application/pdf": ["pdf"],
|
|
1027
|
-
"application/pgp-encrypted": ["pgp"],
|
|
1028
|
-
"application/pgp-keys": ["asc"],
|
|
1029
|
-
"application/pgp-signature": ["sig", "*asc"],
|
|
1030
|
-
"application/pics-rules": ["prf"],
|
|
1031
|
-
"application/pkcs10": ["p10"],
|
|
1032
|
-
"application/pkcs7-mime": ["p7m", "p7c"],
|
|
1033
|
-
"application/pkcs7-signature": ["p7s"],
|
|
1034
|
-
"application/pkcs8": ["p8"],
|
|
1035
|
-
"application/pkix-attr-cert": ["ac"],
|
|
1036
|
-
"application/pkix-cert": ["cer"],
|
|
1037
|
-
"application/pkix-crl": ["crl"],
|
|
1038
|
-
"application/pkix-pkipath": ["pkipath"],
|
|
1039
|
-
"application/pkixcmp": ["pki"],
|
|
1040
|
-
"application/pls+xml": ["pls"],
|
|
1041
|
-
"application/postscript": ["ai", "eps", "ps"],
|
|
1042
|
-
"application/provenance+xml": ["provx"],
|
|
1043
|
-
"application/pskc+xml": ["pskcxml"],
|
|
1044
|
-
"application/raml+yaml": ["raml"],
|
|
1045
|
-
"application/rdf+xml": ["rdf", "owl"],
|
|
1046
|
-
"application/reginfo+xml": ["rif"],
|
|
1047
|
-
"application/relax-ng-compact-syntax": ["rnc"],
|
|
1048
|
-
"application/resource-lists+xml": ["rl"],
|
|
1049
|
-
"application/resource-lists-diff+xml": ["rld"],
|
|
1050
|
-
"application/rls-services+xml": ["rs"],
|
|
1051
|
-
"application/route-apd+xml": ["rapd"],
|
|
1052
|
-
"application/route-s-tsid+xml": ["sls"],
|
|
1053
|
-
"application/route-usd+xml": ["rusd"],
|
|
1054
|
-
"application/rpki-ghostbusters": ["gbr"],
|
|
1055
|
-
"application/rpki-manifest": ["mft"],
|
|
1056
|
-
"application/rpki-roa": ["roa"],
|
|
1057
|
-
"application/rsd+xml": ["rsd"],
|
|
1058
|
-
"application/rss+xml": ["rss"],
|
|
1059
|
-
"application/rtf": ["rtf"],
|
|
1060
|
-
"application/sbml+xml": ["sbml"],
|
|
1061
|
-
"application/scvp-cv-request": ["scq"],
|
|
1062
|
-
"application/scvp-cv-response": ["scs"],
|
|
1063
|
-
"application/scvp-vp-request": ["spq"],
|
|
1064
|
-
"application/scvp-vp-response": ["spp"],
|
|
1065
|
-
"application/sdp": ["sdp"],
|
|
1066
|
-
"application/senml+xml": ["senmlx"],
|
|
1067
|
-
"application/sensml+xml": ["sensmlx"],
|
|
1068
|
-
"application/set-payment-initiation": ["setpay"],
|
|
1069
|
-
"application/set-registration-initiation": ["setreg"],
|
|
1070
|
-
"application/shf+xml": ["shf"],
|
|
1071
|
-
"application/sieve": ["siv", "sieve"],
|
|
1072
|
-
"application/smil+xml": ["smi", "smil"],
|
|
1073
|
-
"application/sparql-query": ["rq"],
|
|
1074
|
-
"application/sparql-results+xml": ["srx"],
|
|
1075
|
-
"application/sql": ["sql"],
|
|
1076
|
-
"application/srgs": ["gram"],
|
|
1077
|
-
"application/srgs+xml": ["grxml"],
|
|
1078
|
-
"application/sru+xml": ["sru"],
|
|
1079
|
-
"application/ssdl+xml": ["ssdl"],
|
|
1080
|
-
"application/ssml+xml": ["ssml"],
|
|
1081
|
-
"application/swid+xml": ["swidtag"],
|
|
1082
|
-
"application/tei+xml": ["tei", "teicorpus"],
|
|
1083
|
-
"application/thraud+xml": ["tfi"],
|
|
1084
|
-
"application/timestamped-data": ["tsd"],
|
|
1085
|
-
"application/toml": ["toml"],
|
|
1086
|
-
"application/trig": ["trig"],
|
|
1087
|
-
"application/ttml+xml": ["ttml"],
|
|
1088
|
-
"application/ubjson": ["ubj"],
|
|
1089
|
-
"application/urc-ressheet+xml": ["rsheet"],
|
|
1090
|
-
"application/urc-targetdesc+xml": ["td"],
|
|
1091
|
-
"application/voicexml+xml": ["vxml"],
|
|
1092
|
-
"application/wasm": ["wasm"],
|
|
1093
|
-
"application/watcherinfo+xml": ["wif"],
|
|
1094
|
-
"application/widget": ["wgt"],
|
|
1095
|
-
"application/winhlp": ["hlp"],
|
|
1096
|
-
"application/wsdl+xml": ["wsdl"],
|
|
1097
|
-
"application/wspolicy+xml": ["wspolicy"],
|
|
1098
|
-
"application/xaml+xml": ["xaml"],
|
|
1099
|
-
"application/xcap-att+xml": ["xav"],
|
|
1100
|
-
"application/xcap-caps+xml": ["xca"],
|
|
1101
|
-
"application/xcap-diff+xml": ["xdf"],
|
|
1102
|
-
"application/xcap-el+xml": ["xel"],
|
|
1103
|
-
"application/xcap-ns+xml": ["xns"],
|
|
1104
|
-
"application/xenc+xml": ["xenc"],
|
|
1105
|
-
"application/xfdf": ["xfdf"],
|
|
1106
|
-
"application/xhtml+xml": ["xhtml", "xht"],
|
|
1107
|
-
"application/xliff+xml": ["xlf"],
|
|
1108
|
-
"application/xml": ["xml", "xsl", "xsd", "rng"],
|
|
1109
|
-
"application/xml-dtd": ["dtd"],
|
|
1110
|
-
"application/xop+xml": ["xop"],
|
|
1111
|
-
"application/xproc+xml": ["xpl"],
|
|
1112
|
-
"application/xslt+xml": ["*xsl", "xslt"],
|
|
1113
|
-
"application/xspf+xml": ["xspf"],
|
|
1114
|
-
"application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"],
|
|
1115
|
-
"application/yang": ["yang"],
|
|
1116
|
-
"application/yin+xml": ["yin"],
|
|
1117
|
-
"application/zip": ["zip"],
|
|
1118
|
-
"audio/3gpp": ["*3gpp"],
|
|
1119
|
-
"audio/aac": ["adts", "aac"],
|
|
1120
|
-
"audio/adpcm": ["adp"],
|
|
1121
|
-
"audio/amr": ["amr"],
|
|
1122
|
-
"audio/basic": ["au", "snd"],
|
|
1123
|
-
"audio/midi": ["mid", "midi", "kar", "rmi"],
|
|
1124
|
-
"audio/mobile-xmf": ["mxmf"],
|
|
1125
|
-
"audio/mp3": ["*mp3"],
|
|
1126
|
-
"audio/mp4": ["m4a", "mp4a"],
|
|
1127
|
-
"audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"],
|
|
1128
|
-
"audio/ogg": ["oga", "ogg", "spx", "opus"],
|
|
1129
|
-
"audio/s3m": ["s3m"],
|
|
1130
|
-
"audio/silk": ["sil"],
|
|
1131
|
-
"audio/wav": ["wav"],
|
|
1132
|
-
"audio/wave": ["*wav"],
|
|
1133
|
-
"audio/webm": ["weba"],
|
|
1134
|
-
"audio/xm": ["xm"],
|
|
1135
|
-
"font/collection": ["ttc"],
|
|
1136
|
-
"font/otf": ["otf"],
|
|
1137
|
-
"font/ttf": ["ttf"],
|
|
1138
|
-
"font/woff": ["woff"],
|
|
1139
|
-
"font/woff2": ["woff2"],
|
|
1140
|
-
"image/aces": ["exr"],
|
|
1141
|
-
"image/apng": ["apng"],
|
|
1142
|
-
"image/avci": ["avci"],
|
|
1143
|
-
"image/avcs": ["avcs"],
|
|
1144
|
-
"image/avif": ["avif"],
|
|
1145
|
-
"image/bmp": ["bmp", "dib"],
|
|
1146
|
-
"image/cgm": ["cgm"],
|
|
1147
|
-
"image/dicom-rle": ["drle"],
|
|
1148
|
-
"image/dpx": ["dpx"],
|
|
1149
|
-
"image/emf": ["emf"],
|
|
1150
|
-
"image/fits": ["fits"],
|
|
1151
|
-
"image/g3fax": ["g3"],
|
|
1152
|
-
"image/gif": ["gif"],
|
|
1153
|
-
"image/heic": ["heic"],
|
|
1154
|
-
"image/heic-sequence": ["heics"],
|
|
1155
|
-
"image/heif": ["heif"],
|
|
1156
|
-
"image/heif-sequence": ["heifs"],
|
|
1157
|
-
"image/hej2k": ["hej2"],
|
|
1158
|
-
"image/hsj2": ["hsj2"],
|
|
1159
|
-
"image/ief": ["ief"],
|
|
1160
|
-
"image/jls": ["jls"],
|
|
1161
|
-
"image/jp2": ["jp2", "jpg2"],
|
|
1162
|
-
"image/jpeg": ["jpeg", "jpg", "jpe"],
|
|
1163
|
-
"image/jph": ["jph"],
|
|
1164
|
-
"image/jphc": ["jhc"],
|
|
1165
|
-
"image/jpm": ["jpm", "jpgm"],
|
|
1166
|
-
"image/jpx": ["jpx", "jpf"],
|
|
1167
|
-
"image/jxl": ["jxl"],
|
|
1168
|
-
"image/jxr": ["jxr"],
|
|
1169
|
-
"image/jxra": ["jxra"],
|
|
1170
|
-
"image/jxrs": ["jxrs"],
|
|
1171
|
-
"image/jxs": ["jxs"],
|
|
1172
|
-
"image/jxsc": ["jxsc"],
|
|
1173
|
-
"image/jxsi": ["jxsi"],
|
|
1174
|
-
"image/jxss": ["jxss"],
|
|
1175
|
-
"image/ktx": ["ktx"],
|
|
1176
|
-
"image/ktx2": ["ktx2"],
|
|
1177
|
-
"image/png": ["png"],
|
|
1178
|
-
"image/sgi": ["sgi"],
|
|
1179
|
-
"image/svg+xml": ["svg", "svgz"],
|
|
1180
|
-
"image/t38": ["t38"],
|
|
1181
|
-
"image/tiff": ["tif", "tiff"],
|
|
1182
|
-
"image/tiff-fx": ["tfx"],
|
|
1183
|
-
"image/webp": ["webp"],
|
|
1184
|
-
"image/wmf": ["wmf"],
|
|
1185
|
-
"message/disposition-notification": ["disposition-notification"],
|
|
1186
|
-
"message/global": ["u8msg"],
|
|
1187
|
-
"message/global-delivery-status": ["u8dsn"],
|
|
1188
|
-
"message/global-disposition-notification": ["u8mdn"],
|
|
1189
|
-
"message/global-headers": ["u8hdr"],
|
|
1190
|
-
"message/rfc822": ["eml", "mime"],
|
|
1191
|
-
"model/3mf": ["3mf"],
|
|
1192
|
-
"model/gltf+json": ["gltf"],
|
|
1193
|
-
"model/gltf-binary": ["glb"],
|
|
1194
|
-
"model/iges": ["igs", "iges"],
|
|
1195
|
-
"model/jt": ["jt"],
|
|
1196
|
-
"model/mesh": ["msh", "mesh", "silo"],
|
|
1197
|
-
"model/mtl": ["mtl"],
|
|
1198
|
-
"model/obj": ["obj"],
|
|
1199
|
-
"model/prc": ["prc"],
|
|
1200
|
-
"model/step+xml": ["stpx"],
|
|
1201
|
-
"model/step+zip": ["stpz"],
|
|
1202
|
-
"model/step-xml+zip": ["stpxz"],
|
|
1203
|
-
"model/stl": ["stl"],
|
|
1204
|
-
"model/u3d": ["u3d"],
|
|
1205
|
-
"model/vrml": ["wrl", "vrml"],
|
|
1206
|
-
"model/x3d+binary": ["*x3db", "x3dbz"],
|
|
1207
|
-
"model/x3d+fastinfoset": ["x3db"],
|
|
1208
|
-
"model/x3d+vrml": ["*x3dv", "x3dvz"],
|
|
1209
|
-
"model/x3d+xml": ["x3d", "x3dz"],
|
|
1210
|
-
"model/x3d-vrml": ["x3dv"],
|
|
1211
|
-
"text/cache-manifest": ["appcache", "manifest"],
|
|
1212
|
-
"text/calendar": ["ics", "ifb"],
|
|
1213
|
-
"text/coffeescript": ["coffee", "litcoffee"],
|
|
1214
|
-
"text/css": ["css"],
|
|
1215
|
-
"text/csv": ["csv"],
|
|
1216
|
-
"text/html": ["html", "htm", "shtml"],
|
|
1217
|
-
"text/jade": ["jade"],
|
|
1218
|
-
"text/javascript": ["js", "mjs"],
|
|
1219
|
-
"text/jsx": ["jsx"],
|
|
1220
|
-
"text/less": ["less"],
|
|
1221
|
-
"text/markdown": ["md", "markdown"],
|
|
1222
|
-
"text/mathml": ["mml"],
|
|
1223
|
-
"text/mdx": ["mdx"],
|
|
1224
|
-
"text/n3": ["n3"],
|
|
1225
|
-
"text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"],
|
|
1226
|
-
"text/richtext": ["rtx"],
|
|
1227
|
-
"text/rtf": ["*rtf"],
|
|
1228
|
-
"text/sgml": ["sgml", "sgm"],
|
|
1229
|
-
"text/shex": ["shex"],
|
|
1230
|
-
"text/slim": ["slim", "slm"],
|
|
1231
|
-
"text/spdx": ["spdx"],
|
|
1232
|
-
"text/stylus": ["stylus", "styl"],
|
|
1233
|
-
"text/tab-separated-values": ["tsv"],
|
|
1234
|
-
"text/troff": ["t", "tr", "roff", "man", "me", "ms"],
|
|
1235
|
-
"text/turtle": ["ttl"],
|
|
1236
|
-
"text/uri-list": ["uri", "uris", "urls"],
|
|
1237
|
-
"text/vcard": ["vcard"],
|
|
1238
|
-
"text/vtt": ["vtt"],
|
|
1239
|
-
"text/wgsl": ["wgsl"],
|
|
1240
|
-
"text/xml": ["*xml"],
|
|
1241
|
-
"text/yaml": ["yaml", "yml"],
|
|
1242
|
-
"video/3gpp": ["3gp", "3gpp"],
|
|
1243
|
-
"video/3gpp2": ["3g2"],
|
|
1244
|
-
"video/h261": ["h261"],
|
|
1245
|
-
"video/h263": ["h263"],
|
|
1246
|
-
"video/h264": ["h264"],
|
|
1247
|
-
"video/iso.segment": ["m4s"],
|
|
1248
|
-
"video/jpeg": ["jpgv"],
|
|
1249
|
-
"video/jpm": ["*jpm", "*jpgm"],
|
|
1250
|
-
"video/mj2": ["mj2", "mjp2"],
|
|
1251
|
-
"video/mp2t": ["ts", "m2t", "m2ts", "mts"],
|
|
1252
|
-
"video/mp4": ["mp4", "mp4v", "mpg4"],
|
|
1253
|
-
"video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"],
|
|
1254
|
-
"video/ogg": ["ogv"],
|
|
1255
|
-
"video/quicktime": ["qt", "mov"],
|
|
1256
|
-
"video/webm": ["webm"]
|
|
1257
|
-
};
|
|
1258
|
-
Object.freeze(types);
|
|
1259
|
-
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
1260
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1261
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1262
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1263
|
-
};
|
|
1264
|
-
var _Mime_extensionToType, _Mime_typeToExtension, _Mime_typeToExtensions;
|
|
1265
|
-
class Mime {
|
|
1266
|
-
constructor(...args) {
|
|
1267
|
-
_Mime_extensionToType.set(this, /* @__PURE__ */ new Map());
|
|
1268
|
-
_Mime_typeToExtension.set(this, /* @__PURE__ */ new Map());
|
|
1269
|
-
_Mime_typeToExtensions.set(this, /* @__PURE__ */ new Map());
|
|
1270
|
-
for (const arg of args) {
|
|
1271
|
-
this.define(arg);
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
define(typeMap, force = false) {
|
|
1275
|
-
for (let [type, extensions] of Object.entries(typeMap)) {
|
|
1276
|
-
type = type.toLowerCase();
|
|
1277
|
-
extensions = extensions.map((ext) => ext.toLowerCase());
|
|
1278
|
-
if (!__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").has(type)) {
|
|
1279
|
-
__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").set(type, /* @__PURE__ */ new Set());
|
|
1280
|
-
}
|
|
1281
|
-
const allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
|
|
1282
|
-
let first = true;
|
|
1283
|
-
for (let extension of extensions) {
|
|
1284
|
-
const starred = extension.startsWith("*");
|
|
1285
|
-
extension = starred ? extension.slice(1) : extension;
|
|
1286
|
-
allExtensions == null ? void 0 : allExtensions.add(extension);
|
|
1287
|
-
if (first) {
|
|
1288
|
-
__classPrivateFieldGet(this, _Mime_typeToExtension, "f").set(type, extension);
|
|
1289
|
-
}
|
|
1290
|
-
first = false;
|
|
1291
|
-
if (starred)
|
|
1292
|
-
continue;
|
|
1293
|
-
const currentType = __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(extension);
|
|
1294
|
-
if (currentType && currentType != type && !force) {
|
|
1295
|
-
throw new Error(`"${type} -> ${extension}" conflicts with "${currentType} -> ${extension}". Pass \`force=true\` to override this definition.`);
|
|
1296
|
-
}
|
|
1297
|
-
__classPrivateFieldGet(this, _Mime_extensionToType, "f").set(extension, type);
|
|
1298
|
-
}
|
|
1299
|
-
}
|
|
1300
|
-
return this;
|
|
1301
|
-
}
|
|
1302
|
-
getType(path) {
|
|
1303
|
-
if (typeof path !== "string")
|
|
1304
|
-
return null;
|
|
1305
|
-
const last = path.replace(/^.*[/\\]/, "").toLowerCase();
|
|
1306
|
-
const ext = last.replace(/^.*\./, "").toLowerCase();
|
|
1307
|
-
const hasPath = last.length < path.length;
|
|
1308
|
-
const hasDot = ext.length < last.length - 1;
|
|
1309
|
-
if (!hasDot && hasPath)
|
|
1310
|
-
return null;
|
|
1311
|
-
return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
|
|
1312
|
-
}
|
|
1313
|
-
getExtension(type) {
|
|
1314
|
-
var _a;
|
|
1315
|
-
if (typeof type !== "string")
|
|
1316
|
-
return null;
|
|
1317
|
-
type = (_a = type == null ? void 0 : type.split) == null ? void 0 : _a.call(type, ";")[0];
|
|
1318
|
-
return (type && __classPrivateFieldGet(this, _Mime_typeToExtension, "f").get(type.trim().toLowerCase())) ?? null;
|
|
1319
|
-
}
|
|
1320
|
-
getAllExtensions(type) {
|
|
1321
|
-
if (typeof type !== "string")
|
|
1322
|
-
return null;
|
|
1323
|
-
return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type.toLowerCase()) ?? null;
|
|
1324
|
-
}
|
|
1325
|
-
_freeze() {
|
|
1326
|
-
this.define = () => {
|
|
1327
|
-
throw new Error("define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances");
|
|
1328
|
-
};
|
|
1329
|
-
Object.freeze(this);
|
|
1330
|
-
for (const extensions of __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").values()) {
|
|
1331
|
-
Object.freeze(extensions);
|
|
1332
|
-
}
|
|
1333
|
-
return this;
|
|
1334
|
-
}
|
|
1335
|
-
_getTestState() {
|
|
1336
|
-
return {
|
|
1337
|
-
types: __classPrivateFieldGet(this, _Mime_extensionToType, "f"),
|
|
1338
|
-
extensions: __classPrivateFieldGet(this, _Mime_typeToExtension, "f")
|
|
1339
|
-
};
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
_Mime_extensionToType = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtension = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtensions = /* @__PURE__ */ new WeakMap();
|
|
1343
|
-
const mime = new Mime(types)._freeze();
|
|
1344
|
-
function validateOperations(operations) {
|
|
1345
|
-
const errors = [];
|
|
1346
|
-
const scopes = Object.keys(operations);
|
|
1347
|
-
for (const scope of scopes) {
|
|
1348
|
-
const ops = operations[scope].sort((a, b) => a.index - b.index);
|
|
1349
|
-
let opIndex = -1;
|
|
1350
|
-
for (let i = 0; i < ops.length; i++) {
|
|
1351
|
-
opIndex = opIndex + 1 + ops[i].skip;
|
|
1352
|
-
if (ops[i].index !== opIndex) {
|
|
1353
|
-
errors.push({
|
|
1354
|
-
message: `Invalid operation index ${ops[i].index} at position ${i}`,
|
|
1355
|
-
details: {
|
|
1356
|
-
position: i,
|
|
1357
|
-
operation: ops[i],
|
|
1358
|
-
scope: ops[i].scope
|
|
1359
|
-
}
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
return errors;
|
|
1365
|
-
}
|
|
1366
|
-
var IntegrityIssueType = /* @__PURE__ */ ((IntegrityIssueType2) => {
|
|
1367
|
-
IntegrityIssueType2["UNEXPECTED_INDEX"] = "UNEXPECTED_INDEX";
|
|
1368
|
-
return IntegrityIssueType2;
|
|
1369
|
-
})(IntegrityIssueType || {});
|
|
1370
|
-
var IntegrityIssueSubType = /* @__PURE__ */ ((IntegrityIssueSubType2) => {
|
|
1371
|
-
IntegrityIssueSubType2["DUPLICATED_INDEX"] = "DUPLICATED_INDEX";
|
|
1372
|
-
IntegrityIssueSubType2["MISSING_INDEX"] = "MISSING_INDEX";
|
|
1373
|
-
return IntegrityIssueSubType2;
|
|
1374
|
-
})(IntegrityIssueSubType || {});
|
|
1375
|
-
function checkCleanedOperationsIntegrity(sortedOperations) {
|
|
1376
|
-
const result = [];
|
|
1377
|
-
let currentIndex = -1;
|
|
1378
|
-
for (const nextOperation of sortedOperations) {
|
|
1379
|
-
const nextIndex = nextOperation.index - nextOperation.skip;
|
|
1380
|
-
if (nextIndex !== currentIndex + 1) {
|
|
1381
|
-
result.push({
|
|
1382
|
-
operation: {
|
|
1383
|
-
index: nextOperation.index,
|
|
1384
|
-
skip: nextOperation.skip
|
|
1385
|
-
},
|
|
1386
|
-
issue: "UNEXPECTED_INDEX",
|
|
1387
|
-
category: nextIndex > currentIndex + 1 ? "MISSING_INDEX" : "DUPLICATED_INDEX",
|
|
1388
|
-
message: `Expected index ${currentIndex + 1} with skip 0 or equivalent, got index ${nextOperation.index} with skip ${nextOperation.skip}`
|
|
1389
|
-
});
|
|
1390
|
-
}
|
|
1391
|
-
currentIndex = nextOperation.index;
|
|
1392
|
-
}
|
|
1393
|
-
return result;
|
|
1394
|
-
}
|
|
1395
|
-
function garbageCollect(sortedOperations) {
|
|
1396
|
-
var _a, _b, _c;
|
|
1397
|
-
const result = [];
|
|
1398
|
-
let i = sortedOperations.length - 1;
|
|
1399
|
-
while (i > -1) {
|
|
1400
|
-
result.unshift(sortedOperations[i]);
|
|
1401
|
-
const skipUntil = (((_a = sortedOperations[i]) == null ? void 0 : _a.index) || 0) - (((_b = sortedOperations[i]) == null ? void 0 : _b.skip) || 0) - 1;
|
|
1402
|
-
let j = i - 1;
|
|
1403
|
-
while (j > -1 && (((_c = sortedOperations[j]) == null ? void 0 : _c.index) || 0) > skipUntil) {
|
|
1404
|
-
j--;
|
|
1405
|
-
}
|
|
1406
|
-
i = j;
|
|
1407
|
-
}
|
|
1408
|
-
return result;
|
|
1409
|
-
}
|
|
1410
|
-
function addUndo(sortedOperations) {
|
|
1411
|
-
const operationsCopy = [...sortedOperations];
|
|
1412
|
-
const latestOperation = operationsCopy[operationsCopy.length - 1];
|
|
1413
|
-
if (!latestOperation) return operationsCopy;
|
|
1414
|
-
if (latestOperation.type === "NOOP") {
|
|
1415
|
-
operationsCopy.push({
|
|
1416
|
-
...latestOperation,
|
|
1417
|
-
index: latestOperation.index,
|
|
1418
|
-
type: "NOOP",
|
|
1419
|
-
skip: nextSkipNumber(sortedOperations)
|
|
1420
|
-
});
|
|
1421
|
-
} else {
|
|
1422
|
-
operationsCopy.push({
|
|
1423
|
-
type: "NOOP",
|
|
1424
|
-
index: latestOperation.index + 1,
|
|
1425
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1426
|
-
input: {},
|
|
1427
|
-
skip: 1,
|
|
1428
|
-
scope: latestOperation.scope,
|
|
1429
|
-
hash: latestOperation.hash
|
|
1430
|
-
});
|
|
1431
|
-
}
|
|
1432
|
-
return operationsCopy;
|
|
1433
|
-
}
|
|
1434
|
-
function sortOperations$1(operations) {
|
|
1435
|
-
return operations.slice().sort((a, b) => a.skip - b.skip).sort((a, b) => a.index - b.index);
|
|
1436
|
-
}
|
|
1437
|
-
const reshuffleByTimestamp = (startIndex, opsA, opsB) => {
|
|
1438
|
-
return [...opsA, ...opsB].sort(
|
|
1439
|
-
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
|
1440
|
-
).map((op, i) => ({
|
|
1441
|
-
...op,
|
|
1442
|
-
index: startIndex.index + i,
|
|
1443
|
-
skip: i === 0 ? startIndex.skip : 0
|
|
1444
|
-
}));
|
|
1445
|
-
};
|
|
1446
|
-
const reshuffleByTimestampAndIndex = (startIndex, opsA, opsB) => {
|
|
1447
|
-
return [...opsA, ...opsB].sort(
|
|
1448
|
-
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
|
1449
|
-
).sort((a, b) => a.index - b.index).map((op, i) => ({
|
|
1450
|
-
...op,
|
|
1451
|
-
index: startIndex.index + i,
|
|
1452
|
-
skip: i === 0 ? startIndex.skip : 0
|
|
1453
|
-
}));
|
|
1454
|
-
};
|
|
1455
|
-
function operationsAreEqual(op1, op2) {
|
|
1456
|
-
return cjsModule(op1) === cjsModule(op2);
|
|
1457
|
-
}
|
|
1458
|
-
function attachBranch(trunk, newBranch) {
|
|
1459
|
-
const trunkCopy = garbageCollect(sortOperations$1(trunk.slice()));
|
|
1460
|
-
const newOperations = garbageCollect(sortOperations$1(newBranch.slice()));
|
|
1461
|
-
if (trunkCopy.length < 1) {
|
|
1462
|
-
return [newOperations, []];
|
|
1463
|
-
}
|
|
1464
|
-
const result = [];
|
|
1465
|
-
let enteredBranch = false;
|
|
1466
|
-
while (newOperations.length > 0) {
|
|
1467
|
-
const newOperationCandidate = newOperations[0];
|
|
1468
|
-
let nextTrunkOperation = trunkCopy.shift();
|
|
1469
|
-
while (nextTrunkOperation && precedes(nextTrunkOperation, newOperationCandidate)) {
|
|
1470
|
-
result.push(nextTrunkOperation);
|
|
1471
|
-
nextTrunkOperation = trunkCopy.shift();
|
|
1472
|
-
}
|
|
1473
|
-
if (!nextTrunkOperation) {
|
|
1474
|
-
enteredBranch = true;
|
|
1475
|
-
} else if (!enteredBranch) {
|
|
1476
|
-
if (operationsAreEqual(nextTrunkOperation, newOperationCandidate)) {
|
|
1477
|
-
newOperations.shift();
|
|
1478
|
-
result.push(nextTrunkOperation);
|
|
1479
|
-
} else {
|
|
1480
|
-
trunkCopy.unshift(nextTrunkOperation);
|
|
1481
|
-
enteredBranch = true;
|
|
1482
|
-
}
|
|
1483
|
-
}
|
|
1484
|
-
if (enteredBranch) {
|
|
1485
|
-
let nextAppend = newOperations.shift();
|
|
1486
|
-
while (nextAppend) {
|
|
1487
|
-
result.push(nextAppend);
|
|
1488
|
-
nextAppend = newOperations.shift();
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
if (!enteredBranch) {
|
|
1493
|
-
let nextAppend = trunkCopy.shift();
|
|
1494
|
-
while (nextAppend) {
|
|
1495
|
-
result.push(nextAppend);
|
|
1496
|
-
nextAppend = trunkCopy.shift();
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
return [garbageCollect(result), trunkCopy];
|
|
1500
|
-
}
|
|
1501
|
-
function precedes(op1, op2) {
|
|
1502
|
-
return op1.index < op2.index || op1.index === op2.index && op1.id === op2.id && op1.skip < op2.skip;
|
|
1503
|
-
}
|
|
1504
|
-
function split(sortedTargetOperations, sortedMergeOperations) {
|
|
1505
|
-
const commonOperations = [];
|
|
1506
|
-
const targetDiffOperations = [];
|
|
1507
|
-
const mergeDiffOperations = [];
|
|
1508
|
-
const maxLength = Math.max(
|
|
1509
|
-
sortedTargetOperations.length,
|
|
1510
|
-
sortedMergeOperations.length
|
|
1511
|
-
);
|
|
1512
|
-
let splitHappened = false;
|
|
1513
|
-
for (let i = 0; i < maxLength; i++) {
|
|
1514
|
-
const targetOperation = sortedTargetOperations[i];
|
|
1515
|
-
const mergeOperation = sortedMergeOperations[i];
|
|
1516
|
-
if (targetOperation && mergeOperation) {
|
|
1517
|
-
if (!splitHappened && operationsAreEqual(targetOperation, mergeOperation)) {
|
|
1518
|
-
commonOperations.push(targetOperation);
|
|
1519
|
-
} else {
|
|
1520
|
-
splitHappened = true;
|
|
1521
|
-
targetDiffOperations.push(targetOperation);
|
|
1522
|
-
mergeDiffOperations.push(mergeOperation);
|
|
1523
|
-
}
|
|
1524
|
-
} else if (targetOperation) {
|
|
1525
|
-
targetDiffOperations.push(targetOperation);
|
|
1526
|
-
} else if (mergeOperation) {
|
|
1527
|
-
mergeDiffOperations.push(mergeOperation);
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
return [commonOperations, targetDiffOperations, mergeDiffOperations];
|
|
1531
|
-
}
|
|
1532
|
-
function merge(sortedTargetOperations, sortedMergeOperations, reshuffle) {
|
|
1533
|
-
const [_commonOperations, _targetOperations, _mergeOperations] = split(
|
|
1534
|
-
garbageCollect(sortedTargetOperations),
|
|
1535
|
-
garbageCollect(sortedMergeOperations)
|
|
1536
|
-
);
|
|
1537
|
-
const maxCommonIndex = getMaxIndex(_commonOperations);
|
|
1538
|
-
const nextIndex = 1 + Math.max(
|
|
1539
|
-
maxCommonIndex,
|
|
1540
|
-
getMaxIndex(_targetOperations),
|
|
1541
|
-
getMaxIndex(_mergeOperations)
|
|
1542
|
-
);
|
|
1543
|
-
const filteredMergeOperations = filterDuplicatedOperations(
|
|
1544
|
-
_mergeOperations,
|
|
1545
|
-
_targetOperations
|
|
1546
|
-
);
|
|
1547
|
-
const newOperationHistory = reshuffle(
|
|
1548
|
-
{
|
|
1549
|
-
index: nextIndex,
|
|
1550
|
-
skip: nextIndex - (maxCommonIndex + 1)
|
|
1551
|
-
},
|
|
1552
|
-
_targetOperations,
|
|
1553
|
-
filteredMergeOperations
|
|
1554
|
-
);
|
|
1555
|
-
return _commonOperations.concat(newOperationHistory);
|
|
1556
|
-
}
|
|
1557
|
-
function getMaxIndex(sortedOperations) {
|
|
1558
|
-
const lastElement = sortedOperations[sortedOperations.length - 1];
|
|
1559
|
-
if (!lastElement) {
|
|
1560
|
-
return -1;
|
|
1561
|
-
}
|
|
1562
|
-
return lastElement.index;
|
|
1563
|
-
}
|
|
1564
|
-
function nextSkipNumber(sortedOperations) {
|
|
1565
|
-
var _a, _b, _c;
|
|
1566
|
-
if (sortedOperations.length < 1) {
|
|
1567
|
-
return -1;
|
|
1568
|
-
}
|
|
1569
|
-
const cleanedOperations = garbageCollect(sortedOperations);
|
|
1570
|
-
let nextSkip = (((_a = cleanedOperations[cleanedOperations.length - 1]) == null ? void 0 : _a.skip) || 0) + 1;
|
|
1571
|
-
if (cleanedOperations.length > 1) {
|
|
1572
|
-
nextSkip += ((_b = cleanedOperations[cleanedOperations.length - 2]) == null ? void 0 : _b.skip) || 0;
|
|
1573
|
-
}
|
|
1574
|
-
return (((_c = cleanedOperations[cleanedOperations.length - 1]) == null ? void 0 : _c.index) || -1) < nextSkip ? -1 : nextSkip;
|
|
1575
|
-
}
|
|
1576
|
-
const checkOperationsIntegrity = (operations) => {
|
|
1577
|
-
return checkCleanedOperationsIntegrity(
|
|
1578
|
-
garbageCollect(sortOperations$1(operations))
|
|
1579
|
-
);
|
|
1580
|
-
};
|
|
1581
|
-
const groupOperationsByScope = (operations) => {
|
|
1582
|
-
const result = operations.reduce((acc, operation) => {
|
|
1583
|
-
var _a;
|
|
1584
|
-
if (!acc[operation.scope]) {
|
|
1585
|
-
acc[operation.scope] = [];
|
|
1586
|
-
}
|
|
1587
|
-
(_a = acc[operation.scope]) == null ? void 0 : _a.push(operation);
|
|
1588
|
-
return acc;
|
|
1589
|
-
}, {});
|
|
1590
|
-
return result;
|
|
1591
|
-
};
|
|
1592
|
-
const prepareOperations = (operationsHistory, newOperations) => {
|
|
1593
|
-
var _a;
|
|
1594
|
-
const result = {
|
|
1595
|
-
integrityIssues: [],
|
|
1596
|
-
validOperations: [],
|
|
1597
|
-
invalidOperations: [],
|
|
1598
|
-
duplicatedOperations: []
|
|
1599
|
-
};
|
|
1600
|
-
const sortedOperationsHistory = sortOperations$1(operationsHistory);
|
|
1601
|
-
const sortedOperations = sortOperations$1(newOperations);
|
|
1602
|
-
const integrityErrors = checkCleanedOperationsIntegrity([
|
|
1603
|
-
...sortedOperationsHistory,
|
|
1604
|
-
...sortedOperations
|
|
1605
|
-
]);
|
|
1606
|
-
const missingIndexErrors = integrityErrors.filter(
|
|
1607
|
-
(integrityIssue) => integrityIssue.category === "MISSING_INDEX"
|
|
1608
|
-
/* MISSING_INDEX */
|
|
1609
|
-
);
|
|
1610
|
-
const firstMissingIndexOperation = (_a = [...missingIndexErrors].sort((a, b) => b.operation.index - a.operation.index).pop()) == null ? void 0 : _a.operation;
|
|
1611
|
-
for (const newOperation of sortedOperations) {
|
|
1612
|
-
if (firstMissingIndexOperation && newOperation.index >= firstMissingIndexOperation.index) {
|
|
1613
|
-
result.invalidOperations.push(newOperation);
|
|
1614
|
-
continue;
|
|
1615
|
-
}
|
|
1616
|
-
const isDuplicatedOperation = integrityErrors.some((integrityError) => {
|
|
1617
|
-
return integrityError.operation.index === newOperation.index && integrityError.operation.skip === newOperation.skip && integrityError.category === "DUPLICATED_INDEX";
|
|
1618
|
-
});
|
|
1619
|
-
if (isDuplicatedOperation) {
|
|
1620
|
-
result.duplicatedOperations.push(newOperation);
|
|
1621
|
-
continue;
|
|
1622
|
-
}
|
|
1623
|
-
result.validOperations.push(newOperation);
|
|
1624
|
-
}
|
|
1625
|
-
result.integrityIssues.push(...integrityErrors);
|
|
1626
|
-
return result;
|
|
1627
|
-
};
|
|
1628
|
-
function removeExistingOperations(newOperations, operationsHistory) {
|
|
1629
|
-
return newOperations.filter((newOperation) => {
|
|
1630
|
-
return !operationsHistory.some((historyOperation) => {
|
|
1631
|
-
return newOperation.type === "NOOP" && newOperation.skip === 0 && newOperation.index === historyOperation.index || newOperation.index === historyOperation.index && newOperation.skip === historyOperation.skip && newOperation.scope === historyOperation.scope && newOperation.hash === historyOperation.hash && newOperation.type === historyOperation.type;
|
|
1632
|
-
});
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
function skipHeaderOperations(operations, skipHeaderOperation) {
|
|
1636
|
-
const [lastOperation] = sortOperations$1(operations).slice(-1);
|
|
1637
|
-
const lastIndex = (lastOperation == null ? void 0 : lastOperation.index) ?? -1;
|
|
1638
|
-
const nextIndex = lastIndex + 1;
|
|
1639
|
-
const skipOperationIndex = {
|
|
1640
|
-
...skipHeaderOperation,
|
|
1641
|
-
index: skipHeaderOperation.index ?? nextIndex
|
|
1642
|
-
};
|
|
1643
|
-
if (skipOperationIndex.index < lastIndex) {
|
|
1644
|
-
throw new Error(
|
|
1645
|
-
`The skip header operation index must be greater than or equal to ${lastIndex}`
|
|
1646
|
-
);
|
|
1647
|
-
}
|
|
1648
|
-
const clearedOperations = garbageCollect(
|
|
1649
|
-
sortOperations$1([...operations, skipOperationIndex])
|
|
1650
|
-
);
|
|
1651
|
-
return (clearedOperations || []).slice(0, -1);
|
|
1652
|
-
}
|
|
1653
|
-
function garbageCollectDocumentOperations(documentOperations) {
|
|
1654
|
-
const clearedOperations = Object.entries(documentOperations).reduce(
|
|
1655
|
-
(acc, entry) => {
|
|
1656
|
-
const [scope, ops] = entry;
|
|
1657
|
-
return {
|
|
1658
|
-
...acc,
|
|
1659
|
-
[scope]: garbageCollect(sortOperations$1(ops))
|
|
1660
|
-
};
|
|
1661
|
-
},
|
|
1662
|
-
{}
|
|
1663
|
-
);
|
|
1664
|
-
return {
|
|
1665
|
-
...clearedOperations
|
|
1666
|
-
};
|
|
1667
|
-
}
|
|
1668
|
-
function filterDuplicatedOperations(targetOperations, sourceOperations) {
|
|
1669
|
-
return targetOperations.filter((op) => {
|
|
1670
|
-
if (op.id) {
|
|
1671
|
-
return !sourceOperations.some((targetOp) => targetOp.id === op.id);
|
|
1672
|
-
}
|
|
1673
|
-
return true;
|
|
1674
|
-
});
|
|
1675
|
-
}
|
|
1676
|
-
function filterDocumentOperationsResultingState(documentOperations) {
|
|
1677
|
-
if (!documentOperations) {
|
|
1678
|
-
return {};
|
|
1679
|
-
}
|
|
1680
|
-
const entries = Object.entries(documentOperations);
|
|
1681
|
-
return entries.reduce(
|
|
1682
|
-
(acc, [scope, operations]) => ({
|
|
1683
|
-
...acc,
|
|
1684
|
-
[scope]: operations.map((op) => {
|
|
1685
|
-
const { resultingState, ...restProps } = op;
|
|
1686
|
-
return restProps;
|
|
1687
|
-
})
|
|
1688
|
-
}),
|
|
1689
|
-
{}
|
|
1690
|
-
);
|
|
1691
|
-
}
|
|
1692
|
-
function diffOperations(clearedOperationsA, clearedOperationsB) {
|
|
1693
|
-
return clearedOperationsA.filter(
|
|
1694
|
-
(operationA) => !clearedOperationsB.some(
|
|
1695
|
-
(operationB) => operationA.index === operationB.index
|
|
1696
|
-
)
|
|
1697
|
-
);
|
|
1698
|
-
}
|
|
1699
|
-
const documentHelpers = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1700
|
-
__proto__: null,
|
|
1701
|
-
IntegrityIssueSubType,
|
|
1702
|
-
IntegrityIssueType,
|
|
1703
|
-
addUndo,
|
|
1704
|
-
attachBranch,
|
|
1705
|
-
checkCleanedOperationsIntegrity,
|
|
1706
|
-
checkOperationsIntegrity,
|
|
1707
|
-
diffOperations,
|
|
1708
|
-
filterDocumentOperationsResultingState,
|
|
1709
|
-
filterDuplicatedOperations,
|
|
1710
|
-
garbageCollect,
|
|
1711
|
-
garbageCollectDocumentOperations,
|
|
1712
|
-
groupOperationsByScope,
|
|
1713
|
-
merge,
|
|
1714
|
-
nextSkipNumber,
|
|
1715
|
-
operationsAreEqual,
|
|
1716
|
-
precedes,
|
|
1717
|
-
prepareOperations,
|
|
1718
|
-
removeExistingOperations,
|
|
1719
|
-
reshuffleByTimestamp,
|
|
1720
|
-
reshuffleByTimestampAndIndex,
|
|
1721
|
-
skipHeaderOperations,
|
|
1722
|
-
sortOperations: sortOperations$1,
|
|
1723
|
-
split
|
|
1724
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
1725
|
-
const createZip = async (document) => {
|
|
1726
|
-
const zip = new JSZip();
|
|
1727
|
-
const { name, revision, documentType, created, lastModified } = document;
|
|
1728
|
-
const header = {
|
|
1729
|
-
name,
|
|
1730
|
-
revision,
|
|
1731
|
-
documentType,
|
|
1732
|
-
created,
|
|
1733
|
-
lastModified
|
|
1734
|
-
};
|
|
1735
|
-
zip.file("header.json", JSON.stringify(header, null, 2));
|
|
1736
|
-
zip.file("state.json", JSON.stringify(document.initialState || {}, null, 2));
|
|
1737
|
-
zip.file("current-state.json", JSON.stringify(document.state || {}, null, 2));
|
|
1738
|
-
zip.file(
|
|
1739
|
-
"operations.json",
|
|
1740
|
-
JSON.stringify(
|
|
1741
|
-
filterDocumentOperationsResultingState(document.operations),
|
|
1742
|
-
null,
|
|
1743
|
-
2
|
|
1744
|
-
)
|
|
1745
|
-
);
|
|
1746
|
-
if (document.attachments) {
|
|
1747
|
-
const attachments = Object.keys(document.attachments);
|
|
1748
|
-
attachments.forEach((key) => {
|
|
1749
|
-
const { data, ...attributes } = document.attachments[key];
|
|
1750
|
-
zip.file(key, data, {
|
|
1751
|
-
base64: true,
|
|
1752
|
-
createFolders: true,
|
|
1753
|
-
comment: JSON.stringify(attributes)
|
|
1754
|
-
});
|
|
1755
|
-
});
|
|
1756
|
-
}
|
|
1757
|
-
return zip;
|
|
1758
|
-
};
|
|
1759
|
-
const saveToFile = async (document, path, extension, name) => {
|
|
1760
|
-
const zip = await createZip(document);
|
|
1761
|
-
const file = await zip.generateAsync({
|
|
1762
|
-
type: "uint8array",
|
|
1763
|
-
streamFiles: true
|
|
1764
|
-
});
|
|
1765
|
-
const fileName = name ?? document.name;
|
|
1766
|
-
const fileExtension = `.${extension}.zip`;
|
|
1767
|
-
return writeFile(
|
|
1768
|
-
path,
|
|
1769
|
-
fileName.endsWith(fileExtension) ? fileName : `${fileName}${fileExtension}`,
|
|
1770
|
-
file
|
|
1771
|
-
);
|
|
1772
|
-
};
|
|
1773
|
-
const saveToFileHandle = async (document, input) => {
|
|
1774
|
-
const zip = await createZip(document);
|
|
1775
|
-
const blob = await zip.generateAsync({ type: "blob" });
|
|
1776
|
-
const writable = await input.createWritable();
|
|
1777
|
-
await writable.write(blob);
|
|
1778
|
-
await writable.close();
|
|
1779
|
-
};
|
|
1780
|
-
const loadFromFile = async (path, reducer, options) => {
|
|
1781
|
-
const file = readFile(path);
|
|
1782
|
-
return loadFromInput(file, reducer, options);
|
|
1783
|
-
};
|
|
1784
|
-
const loadFromInput = async (input, reducer, options) => {
|
|
1785
|
-
const zip = new JSZip();
|
|
1786
|
-
await zip.loadAsync(input);
|
|
1787
|
-
return loadFromZip(zip, reducer, options);
|
|
1788
|
-
};
|
|
1789
|
-
async function loadFromZip(zip, reducer, options) {
|
|
1790
|
-
const initialStateZip = zip.file("state.json");
|
|
1791
|
-
if (!initialStateZip) {
|
|
1792
|
-
throw new Error("Initial state not found");
|
|
1793
|
-
}
|
|
1794
|
-
const initialStateStr = await initialStateZip.async("string");
|
|
1795
|
-
const initialState = JSON.parse(initialStateStr);
|
|
1796
|
-
const headerZip = zip.file("header.json");
|
|
1797
|
-
let header = void 0;
|
|
1798
|
-
if (headerZip) {
|
|
1799
|
-
header = JSON.parse(await headerZip.async("string"));
|
|
1800
|
-
}
|
|
1801
|
-
const operationsZip = zip.file("operations.json");
|
|
1802
|
-
if (!operationsZip) {
|
|
1803
|
-
throw new Error("Operations history not found");
|
|
1804
|
-
}
|
|
1805
|
-
const operations = JSON.parse(
|
|
1806
|
-
await operationsZip.async("string")
|
|
1807
|
-
);
|
|
1808
|
-
const clearedOperations = garbageCollectDocumentOperations(operations);
|
|
1809
|
-
const operationsError = validateOperations(clearedOperations);
|
|
1810
|
-
if (operationsError.length) {
|
|
1811
|
-
const errorMessages = operationsError.map((err) => err.message);
|
|
1812
|
-
throw new Error(errorMessages.join("\n"));
|
|
1813
|
-
}
|
|
1814
|
-
let result = replayDocument(
|
|
1815
|
-
initialState,
|
|
1816
|
-
clearedOperations,
|
|
1817
|
-
reducer,
|
|
1818
|
-
void 0,
|
|
1819
|
-
header,
|
|
1820
|
-
{},
|
|
1821
|
-
options
|
|
1822
|
-
);
|
|
1823
|
-
if (header) {
|
|
1824
|
-
result = {
|
|
1825
|
-
...result,
|
|
1826
|
-
...header
|
|
1827
|
-
};
|
|
1828
|
-
}
|
|
1829
|
-
return result;
|
|
1830
|
-
}
|
|
1831
|
-
function getFileAttributes(file) {
|
|
1832
|
-
const extension = file.replace(/^.*\./, "") || void 0;
|
|
1833
|
-
const fileName = file.replace(/^.*[/\\]/, "") || void 0;
|
|
1834
|
-
return { extension, fileName };
|
|
1835
|
-
}
|
|
1836
|
-
async function getRemoteFile(url) {
|
|
1837
|
-
const { buffer, mimeType = "application/octet-stream" } = await fetchFile(url);
|
|
1838
|
-
const attributes = getFileAttributes(url);
|
|
1839
|
-
const data = buffer.toString("base64");
|
|
1840
|
-
return {
|
|
1841
|
-
data,
|
|
1842
|
-
hash: hash(data),
|
|
1843
|
-
mimeType,
|
|
1844
|
-
...attributes
|
|
1845
|
-
};
|
|
1846
|
-
}
|
|
1847
|
-
async function getLocalFile(path) {
|
|
1848
|
-
const buffer = await getFile(path);
|
|
1849
|
-
const mimeType = mime.getType(path) || "application/octet-stream";
|
|
1850
|
-
const attributes = getFileAttributes(path);
|
|
1851
|
-
const data = buffer.toString("base64");
|
|
1852
|
-
return { data, hash: hash(data), mimeType, ...attributes };
|
|
1853
|
-
}
|
|
1854
|
-
function setNameOperation(document, name) {
|
|
1855
|
-
return { ...document, name };
|
|
1856
|
-
}
|
|
1857
|
-
function undoOperation(document, action, skip) {
|
|
1858
|
-
const { scope, input } = action;
|
|
1859
|
-
const defaultResult = {
|
|
1860
|
-
document,
|
|
1861
|
-
action,
|
|
1862
|
-
skip,
|
|
1863
|
-
reuseLastOperationIndex: false
|
|
1864
|
-
};
|
|
1865
|
-
return create(defaultResult, (draft) => {
|
|
1866
|
-
const operations = [...document.operations[scope]];
|
|
1867
|
-
const sortedOperations = sortOperations$1(operations);
|
|
1868
|
-
draft.action = noop(scope);
|
|
1869
|
-
const lastOperation = sortedOperations.at(-1);
|
|
1870
|
-
let nextIndex = (lastOperation == null ? void 0 : lastOperation.index) ?? -1;
|
|
1871
|
-
const isNewNoop = (lastOperation == null ? void 0 : lastOperation.type) !== "NOOP";
|
|
1872
|
-
if (isNewNoop) {
|
|
1873
|
-
nextIndex = nextIndex + 1;
|
|
1874
|
-
} else {
|
|
1875
|
-
draft.reuseLastOperationIndex = true;
|
|
1876
|
-
}
|
|
1877
|
-
const nextOperationHistory = isNewNoop ? [...sortedOperations, { index: nextIndex, skip: 0 }] : sortedOperations;
|
|
1878
|
-
draft.skip = nextSkipNumber(nextOperationHistory);
|
|
1879
|
-
if (lastOperation && draft.skip > lastOperation.skip + 1) {
|
|
1880
|
-
draft.skip = draft.skip + 1;
|
|
1881
|
-
}
|
|
1882
|
-
if (draft.skip < 0) {
|
|
1883
|
-
throw new Error(
|
|
1884
|
-
`Cannot undo: you can't undo more operations than the ones in the scope history`
|
|
1885
|
-
);
|
|
1886
|
-
}
|
|
1887
|
-
});
|
|
1888
|
-
}
|
|
1889
|
-
function redoOperation(document, action, skip) {
|
|
1890
|
-
const { scope, input } = action;
|
|
1891
|
-
const defaultResult = {
|
|
1892
|
-
document,
|
|
1893
|
-
action,
|
|
1894
|
-
skip,
|
|
1895
|
-
reuseLastOperationIndex: false
|
|
1896
|
-
};
|
|
1897
|
-
return create(defaultResult, (draft) => {
|
|
1898
|
-
if (draft.skip > 0) {
|
|
1899
|
-
throw new Error(
|
|
1900
|
-
`Cannot redo: skip value from reducer cannot be used with REDO action`
|
|
1901
|
-
);
|
|
1902
|
-
}
|
|
1903
|
-
if (input > 1) {
|
|
1904
|
-
throw new Error(`Cannot redo: you can only redo one operation at a time`);
|
|
1905
|
-
}
|
|
1906
|
-
if (input < 1) {
|
|
1907
|
-
throw new Error(`Invalid REDO action: invalid redo input value`);
|
|
1908
|
-
}
|
|
1909
|
-
if (draft.document.clipboard.length < 1) {
|
|
1910
|
-
throw new Error(`Cannot redo: no operations in the clipboard`);
|
|
1911
|
-
}
|
|
1912
|
-
const operationIndex = draft.document.clipboard.findLastIndex(
|
|
1913
|
-
(op) => op.scope === scope
|
|
1914
|
-
);
|
|
1915
|
-
if (operationIndex < 0) {
|
|
1916
|
-
throw new Error(
|
|
1917
|
-
`Cannot redo: no operations in clipboard for scope "${scope}"`
|
|
1918
|
-
);
|
|
1919
|
-
}
|
|
1920
|
-
const operation = draft.document.clipboard.splice(operationIndex, 1)[0];
|
|
1921
|
-
draft.action = castDraft({
|
|
1922
|
-
type: operation.type,
|
|
1923
|
-
scope: operation.scope,
|
|
1924
|
-
input: operation.input
|
|
1925
|
-
});
|
|
1926
|
-
});
|
|
1927
|
-
}
|
|
1928
|
-
function pruneOperation(document, action, wrappedReducer) {
|
|
1929
|
-
const { scope } = action;
|
|
1930
|
-
const operations = document.operations[scope];
|
|
1931
|
-
let {
|
|
1932
|
-
input: { start, end }
|
|
1933
|
-
} = action;
|
|
1934
|
-
start = start || 0;
|
|
1935
|
-
end = end || operations.length;
|
|
1936
|
-
const actionsToPrune = operations.slice(start, end);
|
|
1937
|
-
const actionsToKeepStart = operations.slice(0, start);
|
|
1938
|
-
const actionsToKeepEnd = operations.slice(end);
|
|
1939
|
-
const newDocument = replayOperations(
|
|
1940
|
-
document.initialState,
|
|
1941
|
-
{
|
|
1942
|
-
...document.operations,
|
|
1943
|
-
[scope]: actionsToKeepStart.concat(actionsToPrune)
|
|
1944
|
-
},
|
|
1945
|
-
wrappedReducer
|
|
1946
|
-
);
|
|
1947
|
-
const { name, state: newState } = newDocument;
|
|
1948
|
-
const loadStateIndex = actionsToKeepStart.length;
|
|
1949
|
-
const loadStateTimestamp = actionsToKeepStart.length ? actionsToKeepStart[actionsToKeepStart.length - 1].timestamp : actionsToKeepEnd.length ? actionsToKeepEnd[0].timestamp : (/* @__PURE__ */ new Date()).toISOString();
|
|
1950
|
-
return replayOperations(
|
|
1951
|
-
document.initialState,
|
|
1952
|
-
{
|
|
1953
|
-
...document.operations,
|
|
1954
|
-
[scope]: [
|
|
1955
|
-
...actionsToKeepStart,
|
|
1956
|
-
{
|
|
1957
|
-
...loadState({ name, state: newState }, actionsToPrune.length),
|
|
1958
|
-
timestamp: loadStateTimestamp,
|
|
1959
|
-
index: loadStateIndex,
|
|
1960
|
-
hash: hashDocument({ state: newState }, "global")
|
|
1961
|
-
},
|
|
1962
|
-
...actionsToKeepEnd.map((action2, index) => ({
|
|
1963
|
-
...action2,
|
|
1964
|
-
index: loadStateIndex + index + 1
|
|
1965
|
-
}))
|
|
1966
|
-
]
|
|
1967
|
-
},
|
|
1968
|
-
wrappedReducer
|
|
1969
|
-
);
|
|
1970
|
-
}
|
|
1971
|
-
function loadStateOperation(oldDocument, newDocument) {
|
|
1972
|
-
return {
|
|
1973
|
-
...oldDocument,
|
|
1974
|
-
name: newDocument.name,
|
|
1975
|
-
state: newDocument.state ?? { global: {}, local: {} }
|
|
1976
|
-
};
|
|
1977
|
-
}
|
|
1978
|
-
const SET_NAME = "SET_NAME";
|
|
1979
|
-
const UNDO = "UNDO";
|
|
1980
|
-
const REDO = "REDO";
|
|
1981
|
-
const PRUNE = "PRUNE";
|
|
1982
|
-
const LOAD_STATE = "LOAD_STATE";
|
|
1983
|
-
const NOOP = "NOOP";
|
|
1984
|
-
function getNextRevision(document, action) {
|
|
1985
|
-
let latestOperation;
|
|
1986
|
-
if ("index" in action) {
|
|
1987
|
-
latestOperation = { ...action };
|
|
1988
|
-
} else {
|
|
1989
|
-
latestOperation = document.operations[action.scope].at(-1);
|
|
1990
|
-
}
|
|
1991
|
-
return ((latestOperation == null ? void 0 : latestOperation.index) ?? -1) + 1;
|
|
1992
|
-
}
|
|
1993
|
-
function updateHeader(document, action) {
|
|
1994
|
-
return {
|
|
1995
|
-
...document,
|
|
1996
|
-
revision: {
|
|
1997
|
-
...document.revision,
|
|
1998
|
-
[action.scope]: getNextRevision(document, action)
|
|
1999
|
-
},
|
|
2000
|
-
lastModified: getDocumentLastModified(document)
|
|
2001
|
-
};
|
|
2002
|
-
}
|
|
2003
|
-
function updateOperations(document, action, skip = 0, reuseLastOperationIndex = false) {
|
|
2004
|
-
if ([UNDO, REDO, PRUNE].includes(action.type)) {
|
|
2005
|
-
return document;
|
|
2006
|
-
}
|
|
2007
|
-
const { scope } = action;
|
|
2008
|
-
const operations = document.operations[scope].slice();
|
|
2009
|
-
let operationId;
|
|
2010
|
-
const latestOperation = operations.at(-1);
|
|
2011
|
-
const lastOperationIndex = (latestOperation == null ? void 0 : latestOperation.index) ?? -1;
|
|
2012
|
-
let nextIndex = reuseLastOperationIndex ? lastOperationIndex : lastOperationIndex + 1;
|
|
2013
|
-
let timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2014
|
-
if ("index" in action) {
|
|
2015
|
-
if (action.index - skip > nextIndex) {
|
|
2016
|
-
throw new Error(
|
|
2017
|
-
`Missing operations: expected ${nextIndex} with skip 0 or equivalent, got index ${action.index} with skip ${skip}`
|
|
2018
|
-
);
|
|
2019
|
-
}
|
|
2020
|
-
nextIndex = action.index;
|
|
2021
|
-
operationId = action.id;
|
|
2022
|
-
timestamp = action.timestamp;
|
|
2023
|
-
} else {
|
|
2024
|
-
operationId = "id" in action ? action.id : generateId();
|
|
2025
|
-
}
|
|
2026
|
-
operations.push({
|
|
2027
|
-
...action,
|
|
2028
|
-
id: operationId,
|
|
2029
|
-
index: nextIndex,
|
|
2030
|
-
timestamp,
|
|
2031
|
-
hash: "",
|
|
2032
|
-
scope,
|
|
2033
|
-
skip,
|
|
2034
|
-
error: void 0
|
|
2035
|
-
});
|
|
2036
|
-
return {
|
|
2037
|
-
...document,
|
|
2038
|
-
operations: { ...document.operations, [scope]: operations }
|
|
2039
|
-
};
|
|
2040
|
-
}
|
|
2041
|
-
function updateDocument(document, action, skip = 0, reuseLastOperationIndex = false) {
|
|
2042
|
-
let newDocument = updateOperations(
|
|
2043
|
-
document,
|
|
2044
|
-
action,
|
|
2045
|
-
skip,
|
|
2046
|
-
reuseLastOperationIndex
|
|
2047
|
-
);
|
|
2048
|
-
newDocument = updateHeader(newDocument, action);
|
|
2049
|
-
return newDocument;
|
|
2050
|
-
}
|
|
2051
|
-
function _baseReducer(document, action, wrappedReducer) {
|
|
2052
|
-
BaseActionSchema().parse(action);
|
|
2053
|
-
switch (action.type) {
|
|
2054
|
-
case SET_NAME:
|
|
2055
|
-
return setNameOperation(document, action.input);
|
|
2056
|
-
case PRUNE:
|
|
2057
|
-
return pruneOperation(document, action, wrappedReducer);
|
|
2058
|
-
case LOAD_STATE:
|
|
2059
|
-
return loadStateOperation(document, action.input.state);
|
|
2060
|
-
default:
|
|
2061
|
-
return document;
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
function processUndoRedo(document, action, skip) {
|
|
2065
|
-
switch (action.type) {
|
|
2066
|
-
case UNDO:
|
|
2067
|
-
return undoOperation(document, action, skip);
|
|
2068
|
-
case REDO:
|
|
2069
|
-
return redoOperation(document, action, skip);
|
|
2070
|
-
default:
|
|
2071
|
-
return { document, action, skip, reuseLastOperationIndex: false };
|
|
2072
|
-
}
|
|
2073
|
-
}
|
|
2074
|
-
function processSkipOperation(document, action, customReducer, skipValue, reuseOperationResultingState = false, resultingStateParser = parseResultingState) {
|
|
2075
|
-
const scope = action.scope;
|
|
2076
|
-
const latestOperation = document.operations[scope].at(-1);
|
|
2077
|
-
if (!latestOperation) return document;
|
|
2078
|
-
const documentOperations = garbageCollectDocumentOperations({
|
|
2079
|
-
...document.operations,
|
|
2080
|
-
[scope]: skipHeaderOperations(
|
|
2081
|
-
document.operations[scope],
|
|
2082
|
-
latestOperation
|
|
2083
|
-
)
|
|
2084
|
-
});
|
|
2085
|
-
let scopeState = void 0;
|
|
2086
|
-
const lastRemainingOperation = documentOperations[scope].at(-1);
|
|
2087
|
-
if (reuseOperationResultingState && (lastRemainingOperation == null ? void 0 : lastRemainingOperation.resultingState)) {
|
|
2088
|
-
scopeState = resultingStateParser(lastRemainingOperation.resultingState);
|
|
2089
|
-
} else {
|
|
2090
|
-
const { state } = replayOperations(
|
|
2091
|
-
document.initialState,
|
|
2092
|
-
documentOperations,
|
|
2093
|
-
customReducer,
|
|
2094
|
-
void 0,
|
|
2095
|
-
void 0,
|
|
2096
|
-
void 0,
|
|
2097
|
-
void 0,
|
|
2098
|
-
{
|
|
2099
|
-
reuseHash: true,
|
|
2100
|
-
reuseOperationResultingState,
|
|
2101
|
-
operationResultingStateParser: resultingStateParser
|
|
2102
|
-
}
|
|
2103
|
-
);
|
|
2104
|
-
scopeState = state[scope];
|
|
2105
|
-
}
|
|
2106
|
-
return {
|
|
2107
|
-
...document,
|
|
2108
|
-
state: {
|
|
2109
|
-
...document.state,
|
|
2110
|
-
[scope]: scopeState
|
|
2111
|
-
},
|
|
2112
|
-
operations: garbageCollectDocumentOperations({
|
|
2113
|
-
...document.operations
|
|
2114
|
-
})
|
|
2115
|
-
};
|
|
2116
|
-
}
|
|
2117
|
-
function processUndoOperation(document, scope, customReducer, reuseOperationResultingState = false, resultingStateParser = parseResultingState) {
|
|
2118
|
-
const operations = [...document.operations[scope]];
|
|
2119
|
-
const sortedOperations = sortOperations$1(operations);
|
|
2120
|
-
sortedOperations.pop();
|
|
2121
|
-
const documentOperations = garbageCollectDocumentOperations({
|
|
2122
|
-
...document.operations
|
|
2123
|
-
});
|
|
2124
|
-
const clearedOperations = [...documentOperations[scope]];
|
|
2125
|
-
const diff = diffOperations(
|
|
2126
|
-
garbageCollect(sortedOperations),
|
|
2127
|
-
clearedOperations
|
|
2128
|
-
);
|
|
2129
|
-
const doc = replayOperations(
|
|
2130
|
-
document.initialState,
|
|
2131
|
-
documentOperations,
|
|
2132
|
-
customReducer,
|
|
2133
|
-
void 0,
|
|
2134
|
-
void 0,
|
|
2135
|
-
void 0,
|
|
2136
|
-
void 0,
|
|
2137
|
-
{
|
|
2138
|
-
reuseHash: true,
|
|
2139
|
-
reuseOperationResultingState,
|
|
2140
|
-
operationResultingStateParser: resultingStateParser
|
|
2141
|
-
}
|
|
2142
|
-
);
|
|
2143
|
-
const clipboard = sortOperations$1(
|
|
2144
|
-
[...document.clipboard, ...diff].filter((op) => op.type !== "NOOP")
|
|
2145
|
-
).reverse();
|
|
2146
|
-
return { ...doc, clipboard };
|
|
2147
|
-
}
|
|
2148
|
-
function baseReducer(document, action, customReducer, dispatch, options = {}) {
|
|
2149
|
-
const {
|
|
2150
|
-
skip,
|
|
2151
|
-
ignoreSkipOperations = false,
|
|
2152
|
-
reuseHash = false,
|
|
2153
|
-
reuseOperationResultingState = false,
|
|
2154
|
-
operationResultingStateParser
|
|
2155
|
-
} = options;
|
|
2156
|
-
let _action = { ...action };
|
|
2157
|
-
let skipValue = skip || 0;
|
|
2158
|
-
let newDocument = { ...document };
|
|
2159
|
-
let reuseLastOperationIndex = false;
|
|
2160
|
-
const shouldProcessSkipOperation = !ignoreSkipOperations && (skipValue > 0 || "index" in _action && _action.skip > 0);
|
|
2161
|
-
if (isUndoRedo(_action)) {
|
|
2162
|
-
const {
|
|
2163
|
-
skip: calculatedSkip,
|
|
2164
|
-
action: transformedAction,
|
|
2165
|
-
document: processedDocument,
|
|
2166
|
-
reuseLastOperationIndex: reuseIndex
|
|
2167
|
-
} = processUndoRedo(document, _action, skipValue);
|
|
2168
|
-
_action = transformedAction;
|
|
2169
|
-
skipValue = calculatedSkip;
|
|
2170
|
-
newDocument = processedDocument;
|
|
2171
|
-
reuseLastOperationIndex = reuseIndex;
|
|
2172
|
-
} else {
|
|
2173
|
-
newDocument = {
|
|
2174
|
-
...newDocument,
|
|
2175
|
-
clipboard: []
|
|
2176
|
-
};
|
|
2177
|
-
}
|
|
2178
|
-
if (isBaseAction(_action)) {
|
|
2179
|
-
newDocument = _baseReducer(newDocument, _action, customReducer);
|
|
2180
|
-
}
|
|
2181
|
-
newDocument = updateDocument(
|
|
2182
|
-
newDocument,
|
|
2183
|
-
_action,
|
|
2184
|
-
skipValue,
|
|
2185
|
-
reuseLastOperationIndex
|
|
2186
|
-
);
|
|
2187
|
-
const isUndoAction = isUndo(action);
|
|
2188
|
-
if (isUndoAction) {
|
|
2189
|
-
const result = processUndoOperation(
|
|
2190
|
-
newDocument,
|
|
2191
|
-
action.scope,
|
|
2192
|
-
customReducer
|
|
2193
|
-
);
|
|
2194
|
-
return result;
|
|
2195
|
-
}
|
|
2196
|
-
if (shouldProcessSkipOperation) {
|
|
2197
|
-
newDocument = processSkipOperation(
|
|
2198
|
-
newDocument,
|
|
2199
|
-
_action,
|
|
2200
|
-
customReducer,
|
|
2201
|
-
skipValue,
|
|
2202
|
-
reuseOperationResultingState,
|
|
2203
|
-
operationResultingStateParser
|
|
2204
|
-
);
|
|
2205
|
-
}
|
|
2206
|
-
newDocument = create(newDocument, (draft) => {
|
|
2207
|
-
try {
|
|
2208
|
-
const newState = customReducer(draft.state, _action, dispatch);
|
|
2209
|
-
if (newState) {
|
|
2210
|
-
unsafe(() => {
|
|
2211
|
-
draft.state = castDraft(newState);
|
|
2212
|
-
});
|
|
2213
|
-
} else {
|
|
2214
|
-
}
|
|
2215
|
-
} catch (error) {
|
|
2216
|
-
const lastOperationIndex = newDocument.operations[_action.scope].length - 1;
|
|
2217
|
-
draft.operations[_action.scope][lastOperationIndex].error = error.message;
|
|
2218
|
-
draft.operations[_action.scope][lastOperationIndex].skip = 0;
|
|
2219
|
-
if (shouldProcessSkipOperation) {
|
|
2220
|
-
draft.state = castDraft({ ...document.state });
|
|
2221
|
-
draft.operations = castDraft({
|
|
2222
|
-
...document.operations,
|
|
2223
|
-
[_action.scope]: [
|
|
2224
|
-
...document.operations[_action.scope],
|
|
2225
|
-
{
|
|
2226
|
-
...draft.operations[_action.scope][lastOperationIndex]
|
|
2227
|
-
}
|
|
2228
|
-
]
|
|
2229
|
-
});
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
});
|
|
2233
|
-
if ([UNDO, REDO, PRUNE].includes(_action.type)) {
|
|
2234
|
-
return newDocument;
|
|
2235
|
-
}
|
|
2236
|
-
const scope = _action.scope || "global";
|
|
2237
|
-
const hash2 = reuseHash && Object.prototype.hasOwnProperty.call(_action, "hash") ? _action.hash : hashDocument(newDocument, scope);
|
|
2238
|
-
const lastOperation = newDocument.operations[scope].at(-1);
|
|
2239
|
-
if (lastOperation) {
|
|
2240
|
-
lastOperation.hash = hash2;
|
|
2241
|
-
if (reuseOperationResultingState) {
|
|
2242
|
-
lastOperation.resultingState = newDocument.state[scope];
|
|
2243
|
-
}
|
|
2244
|
-
if (!isBaseAction(_action) && _action.attachments) {
|
|
2245
|
-
_action.attachments.forEach((attachment) => {
|
|
2246
|
-
const { hash: hash22, ...file } = attachment;
|
|
2247
|
-
newDocument.attachments[hash22] = {
|
|
2248
|
-
...file
|
|
2249
|
-
};
|
|
2250
|
-
});
|
|
2251
|
-
}
|
|
2252
|
-
}
|
|
2253
|
-
return newDocument;
|
|
2254
|
-
}
|
|
2255
|
-
function mutableBaseReducer(document, action, customReducer, dispatch, options = {}) {
|
|
2256
|
-
const {
|
|
2257
|
-
skip,
|
|
2258
|
-
ignoreSkipOperations = false,
|
|
2259
|
-
reuseHash = false,
|
|
2260
|
-
reuseOperationResultingState = false,
|
|
2261
|
-
operationResultingStateParser
|
|
2262
|
-
} = options;
|
|
2263
|
-
const _action = { ...action };
|
|
2264
|
-
const skipValue = skip || 0;
|
|
2265
|
-
let newDocument = { ...document };
|
|
2266
|
-
const shouldProcessSkipOperation = !ignoreSkipOperations && (skipValue > 0 || "index" in _action && _action.skip > 0);
|
|
2267
|
-
if (isBaseAction(_action)) {
|
|
2268
|
-
newDocument = _baseReducer(newDocument, _action, customReducer);
|
|
2269
|
-
}
|
|
2270
|
-
newDocument = updateDocument(newDocument, _action, skipValue);
|
|
2271
|
-
if (shouldProcessSkipOperation) {
|
|
2272
|
-
newDocument = processSkipOperation(
|
|
2273
|
-
newDocument,
|
|
2274
|
-
_action,
|
|
2275
|
-
customReducer,
|
|
2276
|
-
skipValue,
|
|
2277
|
-
reuseOperationResultingState,
|
|
2278
|
-
operationResultingStateParser
|
|
2279
|
-
);
|
|
2280
|
-
}
|
|
2281
|
-
try {
|
|
2282
|
-
const newState = customReducer(
|
|
2283
|
-
newDocument.state,
|
|
2284
|
-
_action,
|
|
2285
|
-
dispatch
|
|
2286
|
-
);
|
|
2287
|
-
if (newState) {
|
|
2288
|
-
newDocument.state = newState;
|
|
2289
|
-
}
|
|
2290
|
-
} catch (error) {
|
|
2291
|
-
const lastOperationIndex = newDocument.operations[_action.scope].length - 1;
|
|
2292
|
-
newDocument.operations[_action.scope][lastOperationIndex].error = error.message;
|
|
2293
|
-
newDocument.operations[_action.scope][lastOperationIndex].skip = 0;
|
|
2294
|
-
if (shouldProcessSkipOperation) {
|
|
2295
|
-
newDocument.state = { ...document.state };
|
|
2296
|
-
newDocument.operations = {
|
|
2297
|
-
...document.operations,
|
|
2298
|
-
[_action.scope]: [
|
|
2299
|
-
...document.operations[_action.scope],
|
|
2300
|
-
{
|
|
2301
|
-
...newDocument.operations[_action.scope][lastOperationIndex]
|
|
2302
|
-
}
|
|
2303
|
-
]
|
|
2304
|
-
};
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
if ([UNDO, REDO, PRUNE].includes(_action.type)) {
|
|
2308
|
-
return newDocument;
|
|
2309
|
-
}
|
|
2310
|
-
const scope = _action.scope || "global";
|
|
2311
|
-
const hash2 = reuseHash && Object.prototype.hasOwnProperty.call(_action, "hash") ? _action.hash : hashDocument(newDocument, scope);
|
|
2312
|
-
const lastOperation = newDocument.operations[scope].at(-1);
|
|
2313
|
-
if (lastOperation) {
|
|
2314
|
-
lastOperation.hash = hash2;
|
|
2315
|
-
if (reuseOperationResultingState) {
|
|
2316
|
-
lastOperation.resultingState = newDocument.state[scope];
|
|
2317
|
-
}
|
|
2318
|
-
if (!isBaseAction(_action) && _action.attachments) {
|
|
2319
|
-
_action.attachments.forEach((attachment) => {
|
|
2320
|
-
const { hash: hash22, ...file } = attachment;
|
|
2321
|
-
newDocument.attachments[hash22] = {
|
|
2322
|
-
...file
|
|
2323
|
-
};
|
|
2324
|
-
});
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
return newDocument;
|
|
2328
|
-
}
|
|
2329
|
-
function isNoopOperation(op) {
|
|
2330
|
-
return op.type === NOOP && op.skip !== void 0 && op.skip > 0 && op.hash !== void 0;
|
|
2331
|
-
}
|
|
2332
|
-
function isUndoRedo(action) {
|
|
2333
|
-
return [UNDO, REDO].includes(action.type);
|
|
2334
|
-
}
|
|
2335
|
-
function isUndo(action) {
|
|
2336
|
-
return action.type === UNDO;
|
|
2337
|
-
}
|
|
2338
|
-
function isBaseAction(action) {
|
|
2339
|
-
return [SET_NAME, UNDO, REDO, PRUNE, LOAD_STATE].includes(action.type);
|
|
2340
|
-
}
|
|
2341
|
-
function createAction(type, input, attachments, validator, scope = "global") {
|
|
2342
|
-
if (!type) {
|
|
2343
|
-
throw new Error("Empty action type");
|
|
2344
|
-
}
|
|
2345
|
-
if (typeof type !== "string") {
|
|
2346
|
-
throw new Error(`Invalid action type: ${JSON.stringify(type)}`);
|
|
2347
|
-
}
|
|
2348
|
-
const action = { type, input, scope };
|
|
2349
|
-
if (attachments) {
|
|
2350
|
-
action.attachments = attachments;
|
|
2351
|
-
}
|
|
2352
|
-
try {
|
|
2353
|
-
validator == null ? void 0 : validator().parse(action.input);
|
|
2354
|
-
} catch (error) {
|
|
2355
|
-
if (error instanceof ZodError) {
|
|
2356
|
-
throw new InvalidActionInputZodError(error.issues);
|
|
2357
|
-
} else {
|
|
2358
|
-
throw new InvalidActionInputError(error);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return action;
|
|
2362
|
-
}
|
|
2363
|
-
function createReducer(reducer, documentReducer = baseReducer) {
|
|
2364
|
-
return (document, action, dispatch, options) => {
|
|
2365
|
-
return documentReducer(document, action, reducer, dispatch, options);
|
|
2366
|
-
};
|
|
2367
|
-
}
|
|
2368
|
-
function createUnsafeReducer(reducer, documentReducer = mutableBaseReducer) {
|
|
2369
|
-
return (document, action, dispatch, options) => {
|
|
2370
|
-
return documentReducer(document, action, reducer, dispatch, options);
|
|
2371
|
-
};
|
|
2372
|
-
}
|
|
2373
|
-
const createExtendedState = (initialState, createState) => {
|
|
2374
|
-
return {
|
|
2375
|
-
name: "",
|
|
2376
|
-
documentType: "",
|
|
2377
|
-
revision: {
|
|
2378
|
-
global: 0,
|
|
2379
|
-
local: 0
|
|
2380
|
-
},
|
|
2381
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2382
|
-
lastModified: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2383
|
-
attachments: {},
|
|
2384
|
-
...initialState,
|
|
2385
|
-
state: (createState == null ? void 0 : createState(initialState == null ? void 0 : initialState.state)) ?? ((initialState == null ? void 0 : initialState.state) ?? { global: {}, local: {} })
|
|
2386
|
-
};
|
|
2387
|
-
};
|
|
2388
|
-
const createDocument = (initialState, createState) => {
|
|
2389
|
-
const state = createExtendedState(
|
|
2390
|
-
initialState,
|
|
2391
|
-
createState
|
|
2392
|
-
);
|
|
2393
|
-
return {
|
|
2394
|
-
...state,
|
|
2395
|
-
initialState: state,
|
|
2396
|
-
operations: { global: [], local: [] },
|
|
2397
|
-
clipboard: []
|
|
2398
|
-
};
|
|
2399
|
-
};
|
|
2400
|
-
const hashDocument = (document, scope = "global") => {
|
|
2401
|
-
return hash(cjsModule(document.state[scope] || ""));
|
|
2402
|
-
};
|
|
2403
|
-
const hashKey = (date, randomLimit = 1e3) => {
|
|
2404
|
-
const random = Math.random() * randomLimit;
|
|
2405
|
-
return hash(`${(date ?? /* @__PURE__ */ new Date()).toISOString()}${random}`);
|
|
2406
|
-
};
|
|
2407
|
-
function readOnly(value) {
|
|
2408
|
-
return Object.freeze(value);
|
|
2409
|
-
}
|
|
2410
|
-
function mapSkippedOperations(operations, skippedHeadOperations) {
|
|
2411
|
-
const ops = [...operations];
|
|
2412
|
-
let skipped = skippedHeadOperations || 0;
|
|
2413
|
-
let latestOpIndex = ops.length > 0 ? ops[ops.length - 1].index : 0;
|
|
2414
|
-
const scopeOpsWithIgnore = [];
|
|
2415
|
-
for (const operation of ops.reverse()) {
|
|
2416
|
-
if (skipped > 0) {
|
|
2417
|
-
const operationsDiff = latestOpIndex - operation.index;
|
|
2418
|
-
skipped -= operationsDiff;
|
|
2419
|
-
}
|
|
2420
|
-
if (skipped < 0) {
|
|
2421
|
-
throw new Error("Invalid operation index, missing operations");
|
|
2422
|
-
}
|
|
2423
|
-
const mappedOp = {
|
|
2424
|
-
ignore: skipped > 0,
|
|
2425
|
-
operation
|
|
2426
|
-
};
|
|
2427
|
-
const operationSkip = operation.skip > 0 ? operation.skip + 1 : 0;
|
|
2428
|
-
if (operationSkip > 0 && operationSkip > skipped) {
|
|
2429
|
-
const skipDiff = operationSkip - skipped;
|
|
2430
|
-
skipped = skipped + skipDiff;
|
|
2431
|
-
}
|
|
2432
|
-
latestOpIndex = operation.index;
|
|
2433
|
-
scopeOpsWithIgnore.push(mappedOp);
|
|
2434
|
-
}
|
|
2435
|
-
return scopeOpsWithIgnore.reverse();
|
|
2436
|
-
}
|
|
2437
|
-
function sortOperations(operations) {
|
|
2438
|
-
return Object.values(operations).flatMap((array) => array).sort(
|
|
2439
|
-
(a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime()
|
|
2440
|
-
);
|
|
2441
|
-
}
|
|
2442
|
-
function sortMappedOperations(operations) {
|
|
2443
|
-
return Object.values(operations).flatMap((array) => array).sort(
|
|
2444
|
-
(a, b) => new Date(a.operation.timestamp).getTime() - new Date(b.operation.timestamp).getTime()
|
|
2445
|
-
);
|
|
2446
|
-
}
|
|
2447
|
-
function getDocumentLastModified(document) {
|
|
2448
|
-
var _a;
|
|
2449
|
-
const sortedOperations = sortOperations(document.operations);
|
|
2450
|
-
const timestamp = ((_a = sortedOperations.at(-1)) == null ? void 0 : _a.timestamp) || document.initialState.lastModified;
|
|
2451
|
-
return timestamp;
|
|
2452
|
-
}
|
|
2453
|
-
function replayOperations(initialState, clearedOperations, reducer, dispatch, header, documentReducer = baseReducer, skipHeaderOperations2 = {}, options) {
|
|
2454
|
-
const wrappedReducer = createReducer(reducer, documentReducer);
|
|
2455
|
-
return replayDocument(
|
|
2456
|
-
initialState,
|
|
2457
|
-
clearedOperations,
|
|
2458
|
-
wrappedReducer,
|
|
2459
|
-
dispatch,
|
|
2460
|
-
header,
|
|
2461
|
-
skipHeaderOperations2,
|
|
2462
|
-
options
|
|
2463
|
-
);
|
|
2464
|
-
}
|
|
2465
|
-
function replayDocument(initialState, operations, reducer, dispatch, header, skipHeaderOperations2 = {}, options) {
|
|
2466
|
-
const {
|
|
2467
|
-
checkHashes = true,
|
|
2468
|
-
reuseOperationResultingState,
|
|
2469
|
-
operationResultingStateParser = parseResultingState
|
|
2470
|
-
} = options || {};
|
|
2471
|
-
let documentState = initialState;
|
|
2472
|
-
const operationsToReplay = [];
|
|
2473
|
-
const initialOperations = {
|
|
2474
|
-
global: [],
|
|
2475
|
-
local: []
|
|
2476
|
-
};
|
|
2477
|
-
if (reuseOperationResultingState) {
|
|
2478
|
-
for (const [scope, scopeOperations] of Object.entries(operations)) {
|
|
2479
|
-
const index = scopeOperations.findLastIndex((s) => !!s.resultingState);
|
|
2480
|
-
if (index < 0) {
|
|
2481
|
-
operationsToReplay.push(...scopeOperations);
|
|
2482
|
-
continue;
|
|
2483
|
-
}
|
|
2484
|
-
const opWithState = scopeOperations[index];
|
|
2485
|
-
try {
|
|
2486
|
-
const scopeState = operationResultingStateParser(
|
|
2487
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-unnecessary-type-assertion
|
|
2488
|
-
opWithState.resultingState
|
|
2489
|
-
);
|
|
2490
|
-
documentState = {
|
|
2491
|
-
...documentState,
|
|
2492
|
-
state: {
|
|
2493
|
-
...documentState.state,
|
|
2494
|
-
// TODO how to deal with attachments?
|
|
2495
|
-
[scope]: scopeState
|
|
2496
|
-
}
|
|
2497
|
-
};
|
|
2498
|
-
initialOperations[scope].push(
|
|
2499
|
-
...scopeOperations.slice(0, index + 1)
|
|
2500
|
-
);
|
|
2501
|
-
operationsToReplay.push(...scopeOperations.slice(index + 1));
|
|
2502
|
-
} catch {
|
|
2503
|
-
operationsToReplay.push(...scopeOperations);
|
|
2504
|
-
}
|
|
2505
|
-
}
|
|
2506
|
-
} else {
|
|
2507
|
-
operationsToReplay.push(...Object.values(operations).flat());
|
|
2508
|
-
}
|
|
2509
|
-
const document = createDocument(documentState);
|
|
2510
|
-
document.initialState = initialState;
|
|
2511
|
-
document.operations = initialOperations;
|
|
2512
|
-
let result = document;
|
|
2513
|
-
if (operationsToReplay.length) {
|
|
2514
|
-
result = operationsToReplay.reduce((document2, operation) => {
|
|
2515
|
-
const doc = reducer(document2, operation, dispatch, {
|
|
2516
|
-
skip: operation.skip,
|
|
2517
|
-
ignoreSkipOperations: true,
|
|
2518
|
-
reuseHash: !checkHashes
|
|
2519
|
-
});
|
|
2520
|
-
return doc;
|
|
2521
|
-
}, document);
|
|
2522
|
-
} else {
|
|
2523
|
-
for (const scopeOperations of Object.values(initialOperations)) {
|
|
2524
|
-
const lastOperation = scopeOperations.at(-1);
|
|
2525
|
-
if (lastOperation) {
|
|
2526
|
-
result = updateHeader(result, lastOperation);
|
|
2527
|
-
}
|
|
2528
|
-
}
|
|
2529
|
-
}
|
|
2530
|
-
if (!checkHashes) {
|
|
2531
|
-
for (const scope of Object.keys(result.state)) {
|
|
2532
|
-
for (let i = operationsToReplay.length - 1; i >= 0; i--) {
|
|
2533
|
-
const operation = operationsToReplay[i];
|
|
2534
|
-
if (operation.scope !== scope) {
|
|
2535
|
-
continue;
|
|
2536
|
-
}
|
|
2537
|
-
if (operation.hash !== hashDocument(result, scope)) {
|
|
2538
|
-
throw new Error(`Hash mismatch for scope ${scope}`);
|
|
2539
|
-
} else {
|
|
2540
|
-
break;
|
|
2541
|
-
}
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
|
-
const resultOperations = Object.keys(
|
|
2546
|
-
result.operations
|
|
2547
|
-
).reduce(
|
|
2548
|
-
(acc, key) => {
|
|
2549
|
-
const scope = key;
|
|
2550
|
-
return {
|
|
2551
|
-
...acc,
|
|
2552
|
-
[scope]: [
|
|
2553
|
-
...result.operations[scope].map((operation, index) => {
|
|
2554
|
-
var _a;
|
|
2555
|
-
return {
|
|
2556
|
-
...operation,
|
|
2557
|
-
timestamp: ((_a = operations[scope][index]) == null ? void 0 : _a.timestamp) ?? operation.timestamp
|
|
2558
|
-
};
|
|
2559
|
-
})
|
|
2560
|
-
]
|
|
2561
|
-
};
|
|
2562
|
-
},
|
|
2563
|
-
{ global: [], local: [] }
|
|
2564
|
-
);
|
|
2565
|
-
const lastModified = Object.values(resultOperations).reduce((acc, curr) => {
|
|
2566
|
-
const operation = curr.at(-1);
|
|
2567
|
-
if (operation && operation.timestamp > acc) {
|
|
2568
|
-
acc = operation.timestamp;
|
|
2569
|
-
}
|
|
2570
|
-
return acc;
|
|
2571
|
-
}, initialState.lastModified);
|
|
2572
|
-
return { ...result, operations: resultOperations, lastModified };
|
|
2573
|
-
}
|
|
2574
|
-
function isSameDocument(documentA, documentB) {
|
|
2575
|
-
return cjsModule(documentA) === cjsModule(documentB);
|
|
2576
|
-
}
|
|
2577
|
-
function parseResultingState(state) {
|
|
2578
|
-
const stateType = typeof state;
|
|
2579
|
-
if (stateType === "string") {
|
|
2580
|
-
return JSON.parse(state);
|
|
2581
|
-
} else if (stateType === "object") {
|
|
2582
|
-
return state;
|
|
2583
|
-
} else {
|
|
2584
|
-
throw new Error(`Providing resulting state is of type: ${stateType}`);
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
|
-
const setName = (name) => createAction(
|
|
2588
|
-
"SET_NAME",
|
|
2589
|
-
name,
|
|
2590
|
-
void 0,
|
|
2591
|
-
SetNameActionInputSchema,
|
|
2592
|
-
void 0
|
|
2593
|
-
);
|
|
2594
|
-
const undo = (skip = 1, scope = "global") => createAction(
|
|
2595
|
-
"UNDO",
|
|
2596
|
-
skip,
|
|
2597
|
-
void 0,
|
|
2598
|
-
UndoActionInputSchema,
|
|
2599
|
-
scope
|
|
2600
|
-
);
|
|
2601
|
-
const redo = (count = 1, scope = "global") => createAction(
|
|
2602
|
-
"REDO",
|
|
2603
|
-
count,
|
|
2604
|
-
void 0,
|
|
2605
|
-
RedoActionInputSchema,
|
|
2606
|
-
scope
|
|
2607
|
-
);
|
|
2608
|
-
const prune = (start, end, scope = "global") => createAction(
|
|
2609
|
-
"PRUNE",
|
|
2610
|
-
{ start, end },
|
|
2611
|
-
void 0,
|
|
2612
|
-
PruneActionInputSchema,
|
|
2613
|
-
scope
|
|
2614
|
-
);
|
|
2615
|
-
const loadState = (state, operations) => createAction(
|
|
2616
|
-
"LOAD_STATE",
|
|
2617
|
-
{ state, operations },
|
|
2618
|
-
void 0,
|
|
2619
|
-
LoadStateActionInputSchema
|
|
2620
|
-
);
|
|
2621
|
-
const noop = (scope = "global") => createAction("NOOP", {}, void 0, void 0, scope);
|
|
2622
|
-
const BaseActions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2623
|
-
__proto__: null,
|
|
2624
|
-
loadState,
|
|
2625
|
-
noop,
|
|
2626
|
-
prune,
|
|
2627
|
-
redo,
|
|
2628
|
-
setName,
|
|
2629
|
-
undo
|
|
2630
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
2631
|
-
export {
|
|
2632
|
-
buildSignedOperation as A,
|
|
2633
|
-
BaseActions as B,
|
|
2634
|
-
createUnsafeReducer as C,
|
|
2635
|
-
createZip as D,
|
|
2636
|
-
documentHelpers as E,
|
|
2637
|
-
generateId as F,
|
|
2638
|
-
getDocumentLastModified as G,
|
|
2639
|
-
getLocalFile as H,
|
|
2640
|
-
InvalidActionInputError as I,
|
|
2641
|
-
getRemoteFile as J,
|
|
2642
|
-
getUnixTimestamp as K,
|
|
2643
|
-
hashDocument as L,
|
|
2644
|
-
hashKey as M,
|
|
2645
|
-
hex2ab as N,
|
|
2646
|
-
isNoopOperation as O,
|
|
2647
|
-
isSameDocument as P,
|
|
2648
|
-
isUndo as Q,
|
|
2649
|
-
isUndoRedo as R,
|
|
2650
|
-
mapSkippedOperations as S,
|
|
2651
|
-
parseResultingState as T,
|
|
2652
|
-
replayDocument as U,
|
|
2653
|
-
replayOperations as V,
|
|
2654
|
-
sortMappedOperations as W,
|
|
2655
|
-
sortOperations as X,
|
|
2656
|
-
validateOperations as Y,
|
|
2657
|
-
verifyOperationSignature as Z,
|
|
2658
|
-
createExtendedState as a,
|
|
2659
|
-
createDocument as b,
|
|
2660
|
-
createReducer as c,
|
|
2661
|
-
saveToFileHandle as d,
|
|
2662
|
-
loadFromInput as e,
|
|
2663
|
-
createAction as f,
|
|
2664
|
-
baseReducer as g,
|
|
2665
|
-
updateHeader as h,
|
|
2666
|
-
isBaseAction as i,
|
|
2667
|
-
setName as j,
|
|
2668
|
-
undo as k,
|
|
2669
|
-
loadFromFile as l,
|
|
2670
|
-
mutableBaseReducer as m,
|
|
2671
|
-
redo as n,
|
|
2672
|
-
prune as o,
|
|
2673
|
-
processUndoRedo as p,
|
|
2674
|
-
loadState as q,
|
|
2675
|
-
readOnly as r,
|
|
2676
|
-
saveToFile as s,
|
|
2677
|
-
InvalidActionInputZodError as t,
|
|
2678
|
-
updateDocument as u,
|
|
2679
|
-
ab2hex as v,
|
|
2680
|
-
buildOperationSignature as w,
|
|
2681
|
-
buildOperationSignatureMessage as x,
|
|
2682
|
-
buildOperationSignatureParams as y,
|
|
2683
|
-
zod as z
|
|
2684
|
-
};
|
|
2685
|
-
//# sourceMappingURL=creators-0lHfLHX0.js.map
|