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