document-model 2.11.0 → 2.12.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.
Files changed (95) hide show
  1. package/dist/browser/cjs/document-model.js +3 -2
  2. package/dist/browser/cjs/document-model.js.map +1 -1
  3. package/dist/browser/cjs/document.js +11 -10
  4. package/dist/browser/cjs/document.js.map +1 -1
  5. package/dist/browser/cjs/index.js +2 -2
  6. package/dist/browser/cjs/internal/{object-BdIbCX0K.js → creators-BFR88wjA.js} +32 -180
  7. package/dist/browser/cjs/internal/creators-BFR88wjA.js.map +1 -0
  8. package/dist/browser/cjs/internal/index-B4JwoOCW.js +19 -0
  9. package/dist/browser/cjs/internal/index-B4JwoOCW.js.map +1 -0
  10. package/dist/browser/cjs/internal/index-CQbaipWs.js +46 -0
  11. package/dist/browser/cjs/internal/index-CQbaipWs.js.map +1 -0
  12. package/dist/browser/cjs/internal/{index-hPntrUvN.js → index-sKyQchiV.js} +56 -55
  13. package/dist/{node/cjs/internal/index-Bsyn7lZ0.js.map → browser/cjs/internal/index-sKyQchiV.js.map} +1 -1
  14. package/dist/browser/cjs/internal/object-Cffgxa2p.js +183 -0
  15. package/dist/browser/cjs/internal/object-Cffgxa2p.js.map +1 -0
  16. package/dist/browser/cjs/utils.js +43 -0
  17. package/dist/browser/cjs/utils.js.map +1 -0
  18. package/dist/browser/es/document-model.js +3 -2
  19. package/dist/browser/es/document-model.js.map +1 -1
  20. package/dist/browser/es/document.js +12 -11
  21. package/dist/browser/es/document.js.map +1 -1
  22. package/dist/browser/es/index.js +2 -2
  23. package/dist/browser/es/internal/{object-oB7gkKNr.js → creators-B8Nq9c1o.js} +67 -215
  24. package/dist/browser/es/internal/creators-B8Nq9c1o.js.map +1 -0
  25. package/dist/browser/es/internal/index-BBMtae0d.js +20 -0
  26. package/dist/browser/es/internal/index-BBMtae0d.js.map +1 -0
  27. package/dist/browser/es/internal/index-BH94ELCG.js +47 -0
  28. package/dist/browser/es/internal/index-BH94ELCG.js.map +1 -0
  29. package/dist/browser/es/internal/{index-D_fwH6L3.js → index-BoZSovTG.js} +4 -3
  30. package/dist/{node/es/internal/index-D4oqm7Ua.js.map → browser/es/internal/index-BoZSovTG.js.map} +1 -1
  31. package/dist/browser/es/internal/object-4B35tX7x.js +184 -0
  32. package/dist/browser/es/internal/object-4B35tX7x.js.map +1 -0
  33. package/dist/browser/es/utils.js +43 -0
  34. package/dist/browser/es/utils.js.map +1 -0
  35. package/dist/browser/src/document/utils/base.d.ts.map +1 -1
  36. package/dist/browser/src/document/utils/errors.d.ts +10 -0
  37. package/dist/browser/src/document/utils/errors.d.ts.map +1 -0
  38. package/dist/browser/src/document/utils/index.d.ts +1 -0
  39. package/dist/browser/src/document/utils/index.d.ts.map +1 -1
  40. package/dist/browser/utils.d.ts +2 -0
  41. package/dist/browser/vite.config.d.ts.map +1 -1
  42. package/dist/node/cjs/document-model.js +3 -2
  43. package/dist/node/cjs/document-model.js.map +1 -1
  44. package/dist/node/cjs/document.js +11 -10
  45. package/dist/node/cjs/document.js.map +1 -1
  46. package/dist/node/cjs/index.js +2 -2
  47. package/dist/node/cjs/internal/{object-DqFXYK4g.js → creators-cVAOzgAh.js} +32 -180
  48. package/dist/node/cjs/internal/creators-cVAOzgAh.js.map +1 -0
  49. package/dist/node/cjs/internal/index-TqZ14nZp.js +19 -0
  50. package/dist/node/cjs/internal/index-TqZ14nZp.js.map +1 -0
  51. package/dist/node/cjs/internal/index-Zf6dGXol.js +46 -0
  52. package/dist/node/cjs/internal/index-Zf6dGXol.js.map +1 -0
  53. package/dist/node/cjs/internal/{index-Bsyn7lZ0.js → index-kuBJXCvW.js} +56 -55
  54. package/dist/{browser/cjs/internal/index-hPntrUvN.js.map → node/cjs/internal/index-kuBJXCvW.js.map} +1 -1
  55. package/dist/node/cjs/internal/object-DrxUkgaL.js +183 -0
  56. package/dist/node/cjs/internal/object-DrxUkgaL.js.map +1 -0
  57. package/dist/node/cjs/utils.js +43 -0
  58. package/dist/node/cjs/utils.js.map +1 -0
  59. package/dist/node/es/document-model.js +3 -2
  60. package/dist/node/es/document-model.js.map +1 -1
  61. package/dist/node/es/document.js +12 -11
  62. package/dist/node/es/document.js.map +1 -1
  63. package/dist/node/es/index.js +2 -2
  64. package/dist/node/es/internal/{object-2XgKQb4s.js → creators-Cb-W0me8.js} +67 -215
  65. package/dist/node/es/internal/creators-Cb-W0me8.js.map +1 -0
  66. package/dist/node/es/internal/index-D3XxyPtg.js +20 -0
  67. package/dist/node/es/internal/index-D3XxyPtg.js.map +1 -0
  68. package/dist/node/es/internal/index-DaOQbHFb.js +47 -0
  69. package/dist/node/es/internal/index-DaOQbHFb.js.map +1 -0
  70. package/dist/node/es/internal/{index-D4oqm7Ua.js → index-nspj7nvI.js} +4 -3
  71. package/dist/{browser/es/internal/index-D_fwH6L3.js.map → node/es/internal/index-nspj7nvI.js.map} +1 -1
  72. package/dist/node/es/internal/object-8ji4ZOox.js +184 -0
  73. package/dist/node/es/internal/object-8ji4ZOox.js.map +1 -0
  74. package/dist/node/es/utils.js +43 -0
  75. package/dist/node/es/utils.js.map +1 -0
  76. package/dist/node/src/document/utils/base.d.ts.map +1 -1
  77. package/dist/node/src/document/utils/errors.d.ts +10 -0
  78. package/dist/node/src/document/utils/errors.d.ts.map +1 -0
  79. package/dist/node/src/document/utils/index.d.ts +1 -0
  80. package/dist/node/src/document/utils/index.d.ts.map +1 -1
  81. package/dist/node/utils.d.ts +2 -0
  82. package/dist/node/vite.config.d.ts.map +1 -1
  83. package/package.json +11 -1
  84. package/dist/browser/cjs/internal/index-B62DRxDu.js +0 -58
  85. package/dist/browser/cjs/internal/index-B62DRxDu.js.map +0 -1
  86. package/dist/browser/cjs/internal/object-BdIbCX0K.js.map +0 -1
  87. package/dist/browser/es/internal/index-CPWf201E.js +0 -59
  88. package/dist/browser/es/internal/index-CPWf201E.js.map +0 -1
  89. package/dist/browser/es/internal/object-oB7gkKNr.js.map +0 -1
  90. package/dist/node/cjs/internal/index-DozfRrse.js +0 -58
  91. package/dist/node/cjs/internal/index-DozfRrse.js.map +0 -1
  92. package/dist/node/cjs/internal/object-DqFXYK4g.js.map +0 -1
  93. package/dist/node/es/internal/index-Bf87b5UD.js +0 -59
  94. package/dist/node/es/internal/index-Bf87b5UD.js.map +0 -1
  95. package/dist/node/es/internal/object-2XgKQb4s.js.map +0 -1
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ require("mutative");
6
+ const creators = require("./creators-BFR88wjA.js");
7
+ class BaseDocument {
8
+ /**
9
+ * Constructs a BaseDocument instance with an initial state.
10
+ * @param reducer - The reducer function that updates the state.
11
+ * @param document - The initial state of the document.
12
+ */
13
+ constructor(reducer, document, signalDispatch) {
14
+ __publicField(this, "_document");
15
+ __publicField(this, "_reducer");
16
+ __publicField(this, "_signalDispatch");
17
+ this._reducer = reducer;
18
+ this._document = document;
19
+ this._signalDispatch = signalDispatch;
20
+ }
21
+ /**
22
+ * Dispatches an action to update the state of the document.
23
+ * @param action - The action to dispatch.
24
+ * @returns The Document instance.
25
+ */
26
+ dispatch(action, options) {
27
+ this._document = this._reducer(
28
+ this._document,
29
+ action,
30
+ this._signalDispatch,
31
+ options
32
+ );
33
+ return this;
34
+ }
35
+ /**
36
+ * Saves the state of the document to a file.
37
+ * @param path - The file path where the state should be saved.
38
+ * @param extension - The file extension to use when saving the state.
39
+ * @returns The file path where the state was saved.
40
+ */
41
+ saveToFile(path, extension, name) {
42
+ return creators.saveToFile(this._document, path, extension, name);
43
+ }
44
+ /**
45
+ * Loads the state of the document from a file.
46
+ * @param path - The file path where the state is stored.
47
+ */
48
+ async loadFromFile(path) {
49
+ this._document = await creators.loadFromFile(path, this._reducer);
50
+ }
51
+ /**
52
+ * Loads the state of the document from a file and returns it.
53
+ * @param path - The file path where the state is stored.
54
+ * @param reducer - The reducer function that updates the state.
55
+ * @returns The state of the document.
56
+ */
57
+ static async stateFromFile(path, reducer) {
58
+ const state = await creators.loadFromFile(path, reducer);
59
+ return state;
60
+ }
61
+ /**
62
+ * Gets the current state of the document.
63
+ */
64
+ get state() {
65
+ return creators.readOnly(this._document.state);
66
+ }
67
+ /**
68
+ * Gets the list of operations performed on the document.
69
+ */
70
+ get operations() {
71
+ return creators.readOnly(this._document.operations);
72
+ }
73
+ /**
74
+ * Gets the name of the document.
75
+ */
76
+ get name() {
77
+ return this._document.name;
78
+ }
79
+ /**
80
+ * Gets the type of document.
81
+ */
82
+ get documentType() {
83
+ return this._document.documentType;
84
+ }
85
+ /**
86
+ * Gets the timestamp of the date the document was created.
87
+ */
88
+ get created() {
89
+ return this._document.created;
90
+ }
91
+ /**
92
+ * Gets the timestamp of the date the document was last modified.
93
+ */
94
+ get lastModified() {
95
+ return this._document.lastModified;
96
+ }
97
+ /**
98
+ * Gets the global revision number of the document.
99
+ */
100
+ get revision() {
101
+ return this._document.revision.global;
102
+ }
103
+ getRevision(scope) {
104
+ return this._document.revision[scope];
105
+ }
106
+ /**
107
+ * Gets the initial state of the document.
108
+ */
109
+ get initialState() {
110
+ return creators.readOnly(this._document.initialState);
111
+ }
112
+ /**
113
+ * Returns the current document as an object
114
+ */
115
+ toDocument() {
116
+ return creators.readOnly(this._document);
117
+ }
118
+ /**
119
+ * Gets the attachment associated with the given key.
120
+ * @param attachment - The key of the attachment to retrieve.
121
+ */
122
+ getAttachment(attachment) {
123
+ return this._document.attachments[attachment];
124
+ }
125
+ /**
126
+ * Sets the name of the document.
127
+ * @param name - The new name of the document.
128
+ */
129
+ setName(name) {
130
+ this.dispatch(creators.setName(name));
131
+ return this;
132
+ }
133
+ /**
134
+ * Reverts a number of actions from the document.
135
+ * @param count - The number of actions to revert.
136
+ */
137
+ undo(count) {
138
+ this.dispatch(creators.undo(count));
139
+ return this;
140
+ }
141
+ /**
142
+ * Reapplies a number of actions to the document.
143
+ * @param count - The number of actions to reapply.
144
+ */
145
+ redo(count) {
146
+ this.dispatch(creators.redo(count));
147
+ return this;
148
+ }
149
+ /**
150
+ * Removes a range of operations from the document.
151
+ * @param start - The starting index of the range to remove.
152
+ * @param end - The ending index of the range to remove.
153
+ */
154
+ prune(start, end) {
155
+ this.dispatch(creators.prune(start, end));
156
+ return this;
157
+ }
158
+ /**
159
+ * Loads a document state and a set of operations.
160
+ * @param state - The state to load.
161
+ * @param operations - The operations to apply to the document.
162
+ */
163
+ loadState(state, operations) {
164
+ this.dispatch(creators.loadState(state, operations));
165
+ return this;
166
+ }
167
+ }
168
+ function applyMixins(derivedCtor, constructors) {
169
+ constructors.forEach((baseCtor) => {
170
+ Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
171
+ Object.defineProperty(
172
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
173
+ derivedCtor.prototype,
174
+ name,
175
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
176
+ Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || /* @__PURE__ */ Object.create(null)
177
+ );
178
+ });
179
+ });
180
+ }
181
+ exports.BaseDocument = BaseDocument;
182
+ exports.applyMixins = applyMixins;
183
+ //# sourceMappingURL=object-Cffgxa2p.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-Cffgxa2p.js","sources":["../../../../src/document/object.ts"],"sourcesContent":["import { loadState, prune, redo, setName, undo } from \"./actions\";\nimport type { BaseAction } from \"./actions/types\";\nimport type { SignalDispatch } from \"./signal\";\nimport type {\n Action,\n AttachmentRef,\n Document,\n ExtendedState,\n OperationScope,\n Reducer,\n ReducerOptions,\n} from \"./types\";\nimport { loadFromFile, readOnly, saveToFile } from \"./utils\";\n\n/**\n * This is an abstract class representing a document and provides methods\n * for creating and manipulating documents.\n * @typeparam T - The type of data stored in the document.\n * @typeparam A - The type of action the document can take.\n */\nexport abstract class BaseDocument<T, A extends Action, L = unknown> {\n protected _document: Document<T, A, L>;\n private _reducer: Reducer<T, A, L>;\n private _signalDispatch?: SignalDispatch;\n\n /**\n * Constructs a BaseDocument instance with an initial state.\n * @param reducer - The reducer function that updates the state.\n * @param document - The initial state of the document.\n */\n constructor(\n reducer: Reducer<T, A, L>,\n document: Document<T, A, L>,\n signalDispatch?: SignalDispatch,\n ) {\n this._reducer = reducer;\n this._document = document;\n this._signalDispatch = signalDispatch;\n }\n\n /**\n * Dispatches an action to update the state of the document.\n * @param action - The action to dispatch.\n * @returns The Document instance.\n */\n protected dispatch(action: A | BaseAction, options?: ReducerOptions) {\n this._document = this._reducer(\n this._document,\n action,\n this._signalDispatch,\n options,\n );\n return this;\n }\n\n /**\n * Saves the state of the document to a file.\n * @param path - The file path where the state should be saved.\n * @param extension - The file extension to use when saving the state.\n * @returns The file path where the state was saved.\n */\n protected saveToFile(path: string, extension: string, name?: string) {\n return saveToFile(this._document, path, extension, name);\n }\n\n /**\n * Loads the state of the document from a file.\n * @param path - The file path where the state is stored.\n */\n async loadFromFile(path: string) {\n this._document = await loadFromFile<T, A, L>(path, this._reducer);\n }\n\n /**\n * Loads the state of the document from a file and returns it.\n * @param path - The file path where the state is stored.\n * @param reducer - The reducer function that updates the state.\n * @returns The state of the document.\n */\n protected static async stateFromFile<T, A extends Action, L>(\n path: string,\n reducer: Reducer<T, A, L>,\n ) {\n const state = await loadFromFile<T, A, L>(path, reducer);\n return state;\n }\n\n /**\n * Gets the current state of the document.\n */\n get state() {\n return readOnly(this._document.state);\n }\n\n /**\n * Gets the list of operations performed on the document.\n */\n get operations() {\n return readOnly(this._document.operations);\n }\n\n /**\n * Gets the name of the document.\n */\n get name() {\n return this._document.name;\n }\n\n /**\n * Gets the type of document.\n */\n get documentType() {\n return this._document.documentType;\n }\n\n /**\n * Gets the timestamp of the date the document was created.\n */\n get created() {\n return this._document.created;\n }\n\n /**\n * Gets the timestamp of the date the document was last modified.\n */\n get lastModified() {\n return this._document.lastModified;\n }\n\n /**\n * Gets the global revision number of the document.\n */\n get revision() {\n return this._document.revision.global;\n }\n\n getRevision(scope: OperationScope) {\n return this._document.revision[scope];\n }\n\n /**\n * Gets the initial state of the document.\n */\n get initialState() {\n return readOnly(this._document.initialState);\n }\n\n /**\n * Returns the current document as an object\n */\n public toDocument() {\n return readOnly(this._document);\n }\n\n /**\n * Gets the attachment associated with the given key.\n * @param attachment - The key of the attachment to retrieve.\n */\n public getAttachment(attachment: AttachmentRef) {\n return this._document.attachments[attachment];\n }\n\n /**\n * Sets the name of the document.\n * @param name - The new name of the document.\n */\n public setName(name: string) {\n this.dispatch(setName(name));\n return this;\n }\n\n /**\n * Reverts a number of actions from the document.\n * @param count - The number of actions to revert.\n */\n public undo(count: number) {\n this.dispatch(undo(count));\n return this;\n }\n\n /**\n * Reapplies a number of actions to the document.\n * @param count - The number of actions to reapply.\n */\n public redo(count: number) {\n this.dispatch(redo(count));\n return this;\n }\n /**\n * Removes a range of operations from the document.\n * @param start - The starting index of the range to remove.\n * @param end - The ending index of the range to remove.\n */\n public prune(start?: number | undefined, end?: number | undefined) {\n this.dispatch(prune(start, end));\n return this;\n }\n\n /**\n * Loads a document state and a set of operations.\n * @param state - The state to load.\n * @param operations - The operations to apply to the document.\n */\n public loadState(\n state: Pick<ExtendedState<T, L>, \"state\" | \"name\">,\n operations: number,\n ) {\n this.dispatch(loadState(state, operations));\n return this;\n }\n}\n/**\n * Applies multiple mixins to a base class.\n * Used to have separate mixins to group methods by actions.\n *\n * @remarks\n * {@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}\n *\n * @param derivedCtor - The class to apply the mixins to.\n * @param constructors - The constructors of the mixins.\n */\n\nexport function applyMixins(derivedCtor: any, constructors: any[]) {\n constructors.forEach((baseCtor) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {\n Object.defineProperty(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n derivedCtor.prototype,\n name,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access\n Object.getOwnPropertyDescriptor(baseCtor.prototype, name) ||\n Object.create(null),\n );\n });\n });\n}\n"],"names":["saveToFile","loadFromFile","readOnly","setName","undo","redo","prune","loadState"],"mappings":"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"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const creators = require("./internal/creators-BFR88wjA.js");
4
+ exports.InvalidActionInputError = creators.InvalidActionInputError;
5
+ exports.InvalidActionInputZodError = creators.InvalidActionInputZodError;
6
+ exports.ab2hex = creators.ab2hex;
7
+ exports.buildOperationSignature = creators.buildOperationSignature;
8
+ exports.buildOperationSignatureMessage = creators.buildOperationSignatureMessage;
9
+ exports.buildOperationSignatureParams = creators.buildOperationSignatureParams;
10
+ exports.buildSignedOperation = creators.buildSignedOperation;
11
+ exports.createAction = creators.createAction;
12
+ exports.createDocument = creators.createDocument;
13
+ exports.createExtendedState = creators.createExtendedState;
14
+ exports.createReducer = creators.createReducer;
15
+ exports.createUnsafeReducer = creators.createUnsafeReducer;
16
+ exports.createZip = creators.createZip;
17
+ exports.documentHelpers = creators.documentHelpers;
18
+ exports.getDocumentLastModified = creators.getDocumentLastModified;
19
+ exports.getLocalFile = creators.getLocalFile;
20
+ exports.getRemoteFile = creators.getRemoteFile;
21
+ exports.getUnixTimestamp = creators.getUnixTimestamp;
22
+ exports.hashDocument = creators.hashDocument;
23
+ exports.hashKey = creators.hashKey;
24
+ exports.hex2ab = creators.hex2ab;
25
+ exports.isBaseAction = creators.isBaseAction;
26
+ exports.isNoopOperation = creators.isNoopOperation;
27
+ exports.isSameDocument = creators.isSameDocument;
28
+ exports.isUndo = creators.isUndo;
29
+ exports.isUndoRedo = creators.isUndoRedo;
30
+ exports.loadFromFile = creators.loadFromFile;
31
+ exports.loadFromInput = creators.loadFromInput;
32
+ exports.mapSkippedOperations = creators.mapSkippedOperations;
33
+ exports.parseResultingState = creators.parseResultingState;
34
+ exports.readOnly = creators.readOnly;
35
+ exports.replayDocument = creators.replayDocument;
36
+ exports.replayOperations = creators.replayOperations;
37
+ exports.saveToFile = creators.saveToFile;
38
+ exports.saveToFileHandle = creators.saveToFileHandle;
39
+ exports.sortMappedOperations = creators.sortMappedOperations;
40
+ exports.sortOperations = creators.sortOperations;
41
+ exports.validateOperations = creators.validateOperations;
42
+ exports.verifyOperationSignature = creators.verifyOperationSignature;
43
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,7 +1,8 @@
1
- import "./internal/object-oB7gkKNr.js";
1
+ import "./internal/creators-B8Nq9c1o.js";
2
2
  import "mutative";
3
+ import "zod";
3
4
  import "jszip";
4
- import { b, a, c, d, m, r, u, v, g, h, f, e, z } from "./internal/index-D_fwH6L3.js";
5
+ import { b, a, c, d, m, r, u, v, g, h, f, e, z } from "./internal/index-BoZSovTG.js";
5
6
  export {
6
7
  b as Document,
7
8
  a as DocumentModel,
@@ -1 +1 @@
1
- {"version":3,"file":"document-model.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"document-model.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -1,15 +1,16 @@
1
- import { B, h, g, O, P, Q, R, S, T } from "./internal/object-oB7gkKNr.js";
2
- import { i } from "./internal/index-CPWf201E.js";
1
+ import { B, g, m, p, u, h, z } from "./internal/creators-B8Nq9c1o.js";
2
+ import { B as B2, a } from "./internal/object-4B35tX7x.js";
3
+ import { i } from "./internal/index-BH94ELCG.js";
3
4
  export {
4
- B as BaseDocument,
5
- h as actions,
6
- g as applyMixins,
7
- O as baseReducer,
8
- P as mutableBaseReducer,
9
- Q as processUndoRedo,
10
- R as updateDocument,
11
- S as updateHeader,
5
+ B2 as BaseDocument,
6
+ B as actions,
7
+ a as applyMixins,
8
+ g as baseReducer,
9
+ m as mutableBaseReducer,
10
+ p as processUndoRedo,
11
+ u as updateDocument,
12
+ h as updateHeader,
12
13
  i as utils,
13
- T as z
14
+ z
14
15
  };
15
16
  //# sourceMappingURL=document.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"document.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
@@ -1,5 +1,5 @@
1
- import { D as Document } from "./internal/index-CPWf201E.js";
2
- import { D as DocumentModel } from "./internal/index-D_fwH6L3.js";
1
+ import { D as Document } from "./internal/index-BBMtae0d.js";
2
+ import { D as DocumentModel } from "./internal/index-BoZSovTG.js";
3
3
  const DocumentModels = {
4
4
  "powerhouse/document": Document,
5
5
  "powerhouse/document-model": DocumentModel
@@ -1,9 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { create, castDraft, unsafe } from "mutative";
5
- import { z } from "zod";
6
4
  import JSZip from "jszip";
5
+ import { z, ZodError } from "zod";
6
+ import { create, castDraft, unsafe } from "mutative";
7
7
  const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
8
8
  const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
9
9
  const Load_StateSchema = z.enum(["LOAD_STATE"]);
@@ -1122,6 +1122,23 @@ async function verifyOperationSignature(signature, signer, verifyHandler) {
1122
1122
  const expectedMessage = buildOperationSignatureMessage(params);
1123
1123
  return verifyHandler(publicKey, signatureBytes, expectedMessage);
1124
1124
  }
1125
+ class InvalidActionInputError extends Error {
1126
+ constructor(data) {
1127
+ super();
1128
+ __publicField(this, "data");
1129
+ this.name = "InvalidActionInputError";
1130
+ this.data = data;
1131
+ this.message = this.message || `Invalid action input: ${JSON.stringify(data, null, 2)}`;
1132
+ }
1133
+ }
1134
+ class InvalidActionInputZodError extends InvalidActionInputError {
1135
+ constructor(issues) {
1136
+ super(issues);
1137
+ __publicField(this, "issues");
1138
+ this.issues = issues;
1139
+ this.name = "InvalidActionInputZodError";
1140
+ }
1141
+ }
1125
1142
  const types = { "application/andrew-inset": ["ez"], "application/appinstaller": ["appinstaller"], "application/applixware": ["aw"], "application/appx": ["appx"], "application/appxbundle": ["appxbundle"], "application/atom+xml": ["atom"], "application/atomcat+xml": ["atomcat"], "application/atomdeleted+xml": ["atomdeleted"], "application/atomsvc+xml": ["atomsvc"], "application/atsc-dwd+xml": ["dwd"], "application/atsc-held+xml": ["held"], "application/atsc-rsat+xml": ["rsat"], "application/automationml-aml+xml": ["aml"], "application/automationml-amlx+zip": ["amlx"], "application/bdoc": ["bdoc"], "application/calendar+xml": ["xcs"], "application/ccxml+xml": ["ccxml"], "application/cdfx+xml": ["cdfx"], "application/cdmi-capability": ["cdmia"], "application/cdmi-container": ["cdmic"], "application/cdmi-domain": ["cdmid"], "application/cdmi-object": ["cdmio"], "application/cdmi-queue": ["cdmiq"], "application/cpl+xml": ["cpl"], "application/cu-seeme": ["cu"], "application/cwl": ["cwl"], "application/dash+xml": ["mpd"], "application/dash-patch+xml": ["mpp"], "application/davmount+xml": ["davmount"], "application/docbook+xml": ["dbk"], "application/dssc+der": ["dssc"], "application/dssc+xml": ["xdssc"], "application/ecmascript": ["ecma"], "application/emma+xml": ["emma"], "application/emotionml+xml": ["emotionml"], "application/epub+zip": ["epub"], "application/exi": ["exi"], "application/express": ["exp"], "application/fdf": ["fdf"], "application/fdt+xml": ["fdt"], "application/font-tdpfr": ["pfr"], "application/geo+json": ["geojson"], "application/gml+xml": ["gml"], "application/gpx+xml": ["gpx"], "application/gxf": ["gxf"], "application/gzip": ["gz"], "application/hjson": ["hjson"], "application/hyperstudio": ["stk"], "application/inkml+xml": ["ink", "inkml"], "application/ipfix": ["ipfix"], "application/its+xml": ["its"], "application/java-archive": ["jar", "war", "ear"], "application/java-serialized-object": ["ser"], "application/java-vm": ["class"], "application/javascript": ["*js"], "application/json": ["json", "map"], "application/json5": ["json5"], "application/jsonml+json": ["jsonml"], "application/ld+json": ["jsonld"], "application/lgr+xml": ["lgr"], "application/lost+xml": ["lostxml"], "application/mac-binhex40": ["hqx"], "application/mac-compactpro": ["cpt"], "application/mads+xml": ["mads"], "application/manifest+json": ["webmanifest"], "application/marc": ["mrc"], "application/marcxml+xml": ["mrcx"], "application/mathematica": ["ma", "nb", "mb"], "application/mathml+xml": ["mathml"], "application/mbox": ["mbox"], "application/media-policy-dataset+xml": ["mpf"], "application/mediaservercontrol+xml": ["mscml"], "application/metalink+xml": ["metalink"], "application/metalink4+xml": ["meta4"], "application/mets+xml": ["mets"], "application/mmt-aei+xml": ["maei"], "application/mmt-usd+xml": ["musd"], "application/mods+xml": ["mods"], "application/mp21": ["m21", "mp21"], "application/mp4": ["*mp4", "*mpg4", "mp4s", "m4p"], "application/msix": ["msix"], "application/msixbundle": ["msixbundle"], "application/msword": ["doc", "dot"], "application/mxf": ["mxf"], "application/n-quads": ["nq"], "application/n-triples": ["nt"], "application/node": ["cjs"], "application/octet-stream": ["bin", "dms", "lrf", "mar", "so", "dist", "distz", "pkg", "bpk", "dump", "elc", "deploy", "exe", "dll", "deb", "dmg", "iso", "img", "msi", "msp", "msm", "buffer"], "application/oda": ["oda"], "application/oebps-package+xml": ["opf"], "application/ogg": ["ogx"], "application/omdoc+xml": ["omdoc"], "application/onenote": ["onetoc", "onetoc2", "onetmp", "onepkg"], "application/oxps": ["oxps"], "application/p2p-overlay+xml": ["relo"], "application/patch-ops-error+xml": ["xer"], "application/pdf": ["pdf"], "application/pgp-encrypted": ["pgp"], "application/pgp-keys": ["asc"], "application/pgp-signature": ["sig", "*asc"], "application/pics-rules": ["prf"], "application/pkcs10": ["p10"], "application/pkcs7-mime": ["p7m", "p7c"], "application/pkcs7-signature": ["p7s"], "application/pkcs8": ["p8"], "application/pkix-attr-cert": ["ac"], "application/pkix-cert": ["cer"], "application/pkix-crl": ["crl"], "application/pkix-pkipath": ["pkipath"], "application/pkixcmp": ["pki"], "application/pls+xml": ["pls"], "application/postscript": ["ai", "eps", "ps"], "application/provenance+xml": ["provx"], "application/pskc+xml": ["pskcxml"], "application/raml+yaml": ["raml"], "application/rdf+xml": ["rdf", "owl"], "application/reginfo+xml": ["rif"], "application/relax-ng-compact-syntax": ["rnc"], "application/resource-lists+xml": ["rl"], "application/resource-lists-diff+xml": ["rld"], "application/rls-services+xml": ["rs"], "application/route-apd+xml": ["rapd"], "application/route-s-tsid+xml": ["sls"], "application/route-usd+xml": ["rusd"], "application/rpki-ghostbusters": ["gbr"], "application/rpki-manifest": ["mft"], "application/rpki-roa": ["roa"], "application/rsd+xml": ["rsd"], "application/rss+xml": ["rss"], "application/rtf": ["rtf"], "application/sbml+xml": ["sbml"], "application/scvp-cv-request": ["scq"], "application/scvp-cv-response": ["scs"], "application/scvp-vp-request": ["spq"], "application/scvp-vp-response": ["spp"], "application/sdp": ["sdp"], "application/senml+xml": ["senmlx"], "application/sensml+xml": ["sensmlx"], "application/set-payment-initiation": ["setpay"], "application/set-registration-initiation": ["setreg"], "application/shf+xml": ["shf"], "application/sieve": ["siv", "sieve"], "application/smil+xml": ["smi", "smil"], "application/sparql-query": ["rq"], "application/sparql-results+xml": ["srx"], "application/sql": ["sql"], "application/srgs": ["gram"], "application/srgs+xml": ["grxml"], "application/sru+xml": ["sru"], "application/ssdl+xml": ["ssdl"], "application/ssml+xml": ["ssml"], "application/swid+xml": ["swidtag"], "application/tei+xml": ["tei", "teicorpus"], "application/thraud+xml": ["tfi"], "application/timestamped-data": ["tsd"], "application/toml": ["toml"], "application/trig": ["trig"], "application/ttml+xml": ["ttml"], "application/ubjson": ["ubj"], "application/urc-ressheet+xml": ["rsheet"], "application/urc-targetdesc+xml": ["td"], "application/voicexml+xml": ["vxml"], "application/wasm": ["wasm"], "application/watcherinfo+xml": ["wif"], "application/widget": ["wgt"], "application/winhlp": ["hlp"], "application/wsdl+xml": ["wsdl"], "application/wspolicy+xml": ["wspolicy"], "application/xaml+xml": ["xaml"], "application/xcap-att+xml": ["xav"], "application/xcap-caps+xml": ["xca"], "application/xcap-diff+xml": ["xdf"], "application/xcap-el+xml": ["xel"], "application/xcap-ns+xml": ["xns"], "application/xenc+xml": ["xenc"], "application/xfdf": ["xfdf"], "application/xhtml+xml": ["xhtml", "xht"], "application/xliff+xml": ["xlf"], "application/xml": ["xml", "xsl", "xsd", "rng"], "application/xml-dtd": ["dtd"], "application/xop+xml": ["xop"], "application/xproc+xml": ["xpl"], "application/xslt+xml": ["*xsl", "xslt"], "application/xspf+xml": ["xspf"], "application/xv+xml": ["mxml", "xhvml", "xvml", "xvm"], "application/yang": ["yang"], "application/yin+xml": ["yin"], "application/zip": ["zip"], "audio/3gpp": ["*3gpp"], "audio/aac": ["adts", "aac"], "audio/adpcm": ["adp"], "audio/amr": ["amr"], "audio/basic": ["au", "snd"], "audio/midi": ["mid", "midi", "kar", "rmi"], "audio/mobile-xmf": ["mxmf"], "audio/mp3": ["*mp3"], "audio/mp4": ["m4a", "mp4a"], "audio/mpeg": ["mpga", "mp2", "mp2a", "mp3", "m2a", "m3a"], "audio/ogg": ["oga", "ogg", "spx", "opus"], "audio/s3m": ["s3m"], "audio/silk": ["sil"], "audio/wav": ["wav"], "audio/wave": ["*wav"], "audio/webm": ["weba"], "audio/xm": ["xm"], "font/collection": ["ttc"], "font/otf": ["otf"], "font/ttf": ["ttf"], "font/woff": ["woff"], "font/woff2": ["woff2"], "image/aces": ["exr"], "image/apng": ["apng"], "image/avci": ["avci"], "image/avcs": ["avcs"], "image/avif": ["avif"], "image/bmp": ["bmp", "dib"], "image/cgm": ["cgm"], "image/dicom-rle": ["drle"], "image/dpx": ["dpx"], "image/emf": ["emf"], "image/fits": ["fits"], "image/g3fax": ["g3"], "image/gif": ["gif"], "image/heic": ["heic"], "image/heic-sequence": ["heics"], "image/heif": ["heif"], "image/heif-sequence": ["heifs"], "image/hej2k": ["hej2"], "image/hsj2": ["hsj2"], "image/ief": ["ief"], "image/jls": ["jls"], "image/jp2": ["jp2", "jpg2"], "image/jpeg": ["jpeg", "jpg", "jpe"], "image/jph": ["jph"], "image/jphc": ["jhc"], "image/jpm": ["jpm", "jpgm"], "image/jpx": ["jpx", "jpf"], "image/jxr": ["jxr"], "image/jxra": ["jxra"], "image/jxrs": ["jxrs"], "image/jxs": ["jxs"], "image/jxsc": ["jxsc"], "image/jxsi": ["jxsi"], "image/jxss": ["jxss"], "image/ktx": ["ktx"], "image/ktx2": ["ktx2"], "image/png": ["png"], "image/sgi": ["sgi"], "image/svg+xml": ["svg", "svgz"], "image/t38": ["t38"], "image/tiff": ["tif", "tiff"], "image/tiff-fx": ["tfx"], "image/webp": ["webp"], "image/wmf": ["wmf"], "message/disposition-notification": ["disposition-notification"], "message/global": ["u8msg"], "message/global-delivery-status": ["u8dsn"], "message/global-disposition-notification": ["u8mdn"], "message/global-headers": ["u8hdr"], "message/rfc822": ["eml", "mime"], "model/3mf": ["3mf"], "model/gltf+json": ["gltf"], "model/gltf-binary": ["glb"], "model/iges": ["igs", "iges"], "model/jt": ["jt"], "model/mesh": ["msh", "mesh", "silo"], "model/mtl": ["mtl"], "model/obj": ["obj"], "model/prc": ["prc"], "model/step+xml": ["stpx"], "model/step+zip": ["stpz"], "model/step-xml+zip": ["stpxz"], "model/stl": ["stl"], "model/u3d": ["u3d"], "model/vrml": ["wrl", "vrml"], "model/x3d+binary": ["*x3db", "x3dbz"], "model/x3d+fastinfoset": ["x3db"], "model/x3d+vrml": ["*x3dv", "x3dvz"], "model/x3d+xml": ["x3d", "x3dz"], "model/x3d-vrml": ["x3dv"], "text/cache-manifest": ["appcache", "manifest"], "text/calendar": ["ics", "ifb"], "text/coffeescript": ["coffee", "litcoffee"], "text/css": ["css"], "text/csv": ["csv"], "text/html": ["html", "htm", "shtml"], "text/jade": ["jade"], "text/javascript": ["js", "mjs"], "text/jsx": ["jsx"], "text/less": ["less"], "text/markdown": ["md", "markdown"], "text/mathml": ["mml"], "text/mdx": ["mdx"], "text/n3": ["n3"], "text/plain": ["txt", "text", "conf", "def", "list", "log", "in", "ini"], "text/richtext": ["rtx"], "text/rtf": ["*rtf"], "text/sgml": ["sgml", "sgm"], "text/shex": ["shex"], "text/slim": ["slim", "slm"], "text/spdx": ["spdx"], "text/stylus": ["stylus", "styl"], "text/tab-separated-values": ["tsv"], "text/troff": ["t", "tr", "roff", "man", "me", "ms"], "text/turtle": ["ttl"], "text/uri-list": ["uri", "uris", "urls"], "text/vcard": ["vcard"], "text/vtt": ["vtt"], "text/wgsl": ["wgsl"], "text/xml": ["*xml"], "text/yaml": ["yaml", "yml"], "video/3gpp": ["3gp", "3gpp"], "video/3gpp2": ["3g2"], "video/h261": ["h261"], "video/h263": ["h263"], "video/h264": ["h264"], "video/iso.segment": ["m4s"], "video/jpeg": ["jpgv"], "video/jpm": ["*jpm", "*jpgm"], "video/mj2": ["mj2", "mjp2"], "video/mp2t": ["ts"], "video/mp4": ["mp4", "mp4v", "mpg4"], "video/mpeg": ["mpeg", "mpg", "mpe", "m1v", "m2v"], "video/ogg": ["ogv"], "video/quicktime": ["qt", "mov"], "video/webm": ["webm"] };
1126
1143
  Object.freeze(types);
1127
1144
  var __classPrivateFieldGet = function(receiver, state, kind, f) {
@@ -2219,7 +2236,11 @@ function createAction(type, input, attachments, validator, scope = "global") {
2219
2236
  try {
2220
2237
  validator == null ? void 0 : validator().parse(action.input);
2221
2238
  } catch (error) {
2222
- throw new Error(`Invalid action input: ${error}`);
2239
+ if (error instanceof ZodError) {
2240
+ throw new InvalidActionInputZodError(error.issues);
2241
+ } else {
2242
+ throw new InvalidActionInputError(error);
2243
+ }
2223
2244
  }
2224
2245
  return action;
2225
2246
  }
@@ -2491,226 +2512,57 @@ const BaseActions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
2491
2512
  setName,
2492
2513
  undo
2493
2514
  }, Symbol.toStringTag, { value: "Module" }));
2494
- class BaseDocument {
2495
- /**
2496
- * Constructs a BaseDocument instance with an initial state.
2497
- * @param reducer - The reducer function that updates the state.
2498
- * @param document - The initial state of the document.
2499
- */
2500
- constructor(reducer, document, signalDispatch) {
2501
- __publicField(this, "_document");
2502
- __publicField(this, "_reducer");
2503
- __publicField(this, "_signalDispatch");
2504
- this._reducer = reducer;
2505
- this._document = document;
2506
- this._signalDispatch = signalDispatch;
2507
- }
2508
- /**
2509
- * Dispatches an action to update the state of the document.
2510
- * @param action - The action to dispatch.
2511
- * @returns The Document instance.
2512
- */
2513
- dispatch(action, options) {
2514
- this._document = this._reducer(
2515
- this._document,
2516
- action,
2517
- this._signalDispatch,
2518
- options
2519
- );
2520
- return this;
2521
- }
2522
- /**
2523
- * Saves the state of the document to a file.
2524
- * @param path - The file path where the state should be saved.
2525
- * @param extension - The file extension to use when saving the state.
2526
- * @returns The file path where the state was saved.
2527
- */
2528
- saveToFile(path, extension, name) {
2529
- return saveToFile(this._document, path, extension, name);
2530
- }
2531
- /**
2532
- * Loads the state of the document from a file.
2533
- * @param path - The file path where the state is stored.
2534
- */
2535
- async loadFromFile(path) {
2536
- this._document = await loadFromFile(path, this._reducer);
2537
- }
2538
- /**
2539
- * Loads the state of the document from a file and returns it.
2540
- * @param path - The file path where the state is stored.
2541
- * @param reducer - The reducer function that updates the state.
2542
- * @returns The state of the document.
2543
- */
2544
- static async stateFromFile(path, reducer) {
2545
- const state = await loadFromFile(path, reducer);
2546
- return state;
2547
- }
2548
- /**
2549
- * Gets the current state of the document.
2550
- */
2551
- get state() {
2552
- return readOnly(this._document.state);
2553
- }
2554
- /**
2555
- * Gets the list of operations performed on the document.
2556
- */
2557
- get operations() {
2558
- return readOnly(this._document.operations);
2559
- }
2560
- /**
2561
- * Gets the name of the document.
2562
- */
2563
- get name() {
2564
- return this._document.name;
2565
- }
2566
- /**
2567
- * Gets the type of document.
2568
- */
2569
- get documentType() {
2570
- return this._document.documentType;
2571
- }
2572
- /**
2573
- * Gets the timestamp of the date the document was created.
2574
- */
2575
- get created() {
2576
- return this._document.created;
2577
- }
2578
- /**
2579
- * Gets the timestamp of the date the document was last modified.
2580
- */
2581
- get lastModified() {
2582
- return this._document.lastModified;
2583
- }
2584
- /**
2585
- * Gets the global revision number of the document.
2586
- */
2587
- get revision() {
2588
- return this._document.revision.global;
2589
- }
2590
- getRevision(scope) {
2591
- return this._document.revision[scope];
2592
- }
2593
- /**
2594
- * Gets the initial state of the document.
2595
- */
2596
- get initialState() {
2597
- return readOnly(this._document.initialState);
2598
- }
2599
- /**
2600
- * Returns the current document as an object
2601
- */
2602
- toDocument() {
2603
- return readOnly(this._document);
2604
- }
2605
- /**
2606
- * Gets the attachment associated with the given key.
2607
- * @param attachment - The key of the attachment to retrieve.
2608
- */
2609
- getAttachment(attachment) {
2610
- return this._document.attachments[attachment];
2611
- }
2612
- /**
2613
- * Sets the name of the document.
2614
- * @param name - The new name of the document.
2615
- */
2616
- setName(name) {
2617
- this.dispatch(setName(name));
2618
- return this;
2619
- }
2620
- /**
2621
- * Reverts a number of actions from the document.
2622
- * @param count - The number of actions to revert.
2623
- */
2624
- undo(count) {
2625
- this.dispatch(undo(count));
2626
- return this;
2627
- }
2628
- /**
2629
- * Reapplies a number of actions to the document.
2630
- * @param count - The number of actions to reapply.
2631
- */
2632
- redo(count) {
2633
- this.dispatch(redo(count));
2634
- return this;
2635
- }
2636
- /**
2637
- * Removes a range of operations from the document.
2638
- * @param start - The starting index of the range to remove.
2639
- * @param end - The ending index of the range to remove.
2640
- */
2641
- prune(start, end) {
2642
- this.dispatch(prune(start, end));
2643
- return this;
2644
- }
2645
- /**
2646
- * Loads a document state and a set of operations.
2647
- * @param state - The state to load.
2648
- * @param operations - The operations to apply to the document.
2649
- */
2650
- loadState(state, operations) {
2651
- this.dispatch(loadState(state, operations));
2652
- return this;
2653
- }
2654
- }
2655
- function applyMixins(derivedCtor, constructors) {
2656
- constructors.forEach((baseCtor) => {
2657
- Object.getOwnPropertyNames(baseCtor.prototype).forEach((name) => {
2658
- Object.defineProperty(
2659
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
2660
- derivedCtor.prototype,
2661
- name,
2662
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
2663
- Object.getOwnPropertyDescriptor(baseCtor.prototype, name) || /* @__PURE__ */ Object.create(null)
2664
- );
2665
- });
2666
- });
2667
- }
2668
2515
  export {
2669
- isNoopOperation as A,
2670
- BaseDocument as B,
2671
- isSameDocument as C,
2672
- isUndo as D,
2673
- isUndoRedo as E,
2674
- mapSkippedOperations as F,
2675
- parseResultingState as G,
2676
- readOnly as H,
2677
- replayDocument as I,
2678
- replayOperations as J,
2679
- sortMappedOperations as K,
2680
- sortOperations as L,
2681
- validateOperations as M,
2682
- verifyOperationSignature as N,
2683
- baseReducer as O,
2684
- mutableBaseReducer as P,
2685
- processUndoRedo as Q,
2686
- updateDocument as R,
2687
- updateHeader as S,
2688
- zod as T,
2516
+ buildSignedOperation as A,
2517
+ BaseActions as B,
2518
+ createUnsafeReducer as C,
2519
+ createZip as D,
2520
+ documentHelpers as E,
2521
+ getDocumentLastModified as F,
2522
+ getLocalFile as G,
2523
+ getRemoteFile as H,
2524
+ InvalidActionInputError as I,
2525
+ getUnixTimestamp as J,
2526
+ hashDocument as K,
2527
+ hashKey as L,
2528
+ hex2ab as M,
2529
+ isNoopOperation as N,
2530
+ isSameDocument as O,
2531
+ isUndo as P,
2532
+ isUndoRedo as Q,
2533
+ mapSkippedOperations as R,
2534
+ parseResultingState as S,
2535
+ replayDocument as T,
2536
+ replayOperations as U,
2537
+ sortMappedOperations as V,
2538
+ sortOperations as W,
2539
+ validateOperations as X,
2540
+ verifyOperationSignature as Y,
2689
2541
  createExtendedState as a,
2690
2542
  createDocument as b,
2691
2543
  createReducer as c,
2692
2544
  saveToFileHandle as d,
2693
2545
  loadFromInput as e,
2694
2546
  createAction as f,
2695
- applyMixins as g,
2696
- BaseActions as h,
2547
+ baseReducer as g,
2548
+ updateHeader as h,
2697
2549
  isBaseAction as i,
2698
- ab2hex as j,
2699
- buildOperationSignature as k,
2550
+ setName as j,
2551
+ undo as k,
2700
2552
  loadFromFile as l,
2701
- buildOperationSignatureMessage as m,
2702
- buildOperationSignatureParams as n,
2703
- buildSignedOperation as o,
2704
- createUnsafeReducer as p,
2705
- createZip as q,
2706
- documentHelpers as r,
2553
+ mutableBaseReducer as m,
2554
+ redo as n,
2555
+ prune as o,
2556
+ processUndoRedo as p,
2557
+ loadState as q,
2558
+ readOnly as r,
2707
2559
  saveToFile as s,
2708
- getDocumentLastModified as t,
2709
- getLocalFile as u,
2710
- getRemoteFile as v,
2711
- getUnixTimestamp as w,
2712
- hashDocument as x,
2713
- hashKey as y,
2714
- hex2ab as z
2560
+ InvalidActionInputZodError as t,
2561
+ updateDocument as u,
2562
+ ab2hex as v,
2563
+ buildOperationSignature as w,
2564
+ buildOperationSignatureMessage as x,
2565
+ buildOperationSignatureParams as y,
2566
+ zod as z
2715
2567
  };
2716
- //# sourceMappingURL=object-oB7gkKNr.js.map
2568
+ //# sourceMappingURL=creators-B8Nq9c1o.js.map