document-model 2.12.0 → 2.13.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/browser/cjs/document-model.js +2 -2
- package/dist/browser/cjs/document.js +3 -3
- package/dist/browser/cjs/index.js +2 -2
- package/dist/browser/cjs/internal/{creators-BFR88wjA.js → creators-c2maywyy.js} +17 -34
- package/dist/browser/cjs/internal/creators-c2maywyy.js.map +1 -0
- package/dist/browser/cjs/internal/{index-CQbaipWs.js → index-CTDPLYkV.js} +3 -2
- package/dist/browser/cjs/internal/index-CTDPLYkV.js.map +1 -0
- package/dist/{node/cjs/internal/index-TqZ14nZp.js → browser/cjs/internal/index-DDUYrJUg.js} +4 -4
- package/dist/browser/cjs/internal/index-DDUYrJUg.js.map +1 -0
- package/dist/browser/cjs/internal/{index-sKyQchiV.js → index-DeM7OezK.js} +3 -3
- package/dist/browser/cjs/internal/{index-sKyQchiV.js.map → index-DeM7OezK.js.map} +1 -1
- package/dist/browser/cjs/internal/{object-Cffgxa2p.js → object-WukT1Feq.js} +2 -2
- package/dist/browser/cjs/internal/{object-Cffgxa2p.js.map → object-WukT1Feq.js.map} +1 -1
- package/dist/browser/cjs/utils.js +2 -1
- package/dist/browser/cjs/utils.js.map +1 -1
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +3 -3
- package/dist/browser/es/index.js +2 -2
- package/dist/browser/es/internal/{creators-B8Nq9c1o.js → creators-CkhiX4CP.js} +36 -53
- package/dist/browser/es/internal/creators-CkhiX4CP.js.map +1 -0
- package/dist/browser/es/internal/{index-BoZSovTG.js → index-BRVlDkPn.js} +3 -3
- package/dist/browser/es/internal/{index-BoZSovTG.js.map → index-BRVlDkPn.js.map} +1 -1
- package/dist/browser/es/internal/{index-BH94ELCG.js → index-CHpkSkeZ.js} +3 -2
- package/dist/browser/es/internal/index-CHpkSkeZ.js.map +1 -0
- package/dist/browser/es/internal/{index-BBMtae0d.js → index-uWY5kwkt.js} +4 -4
- package/dist/browser/es/internal/index-uWY5kwkt.js.map +1 -0
- package/dist/browser/es/internal/{object-4B35tX7x.js → object-CJHsId9H.js} +2 -2
- package/dist/browser/es/internal/{object-4B35tX7x.js.map → object-CJHsId9H.js.map} +1 -1
- package/dist/browser/es/utils.js +21 -20
- package/dist/browser/src/document/reducer.d.ts.map +1 -1
- package/dist/browser/src/document/utils/browser.d.ts +1 -0
- package/dist/browser/src/document/utils/browser.d.ts.map +1 -1
- package/dist/browser/src/document/utils/crypto.d.ts +1 -0
- package/dist/browser/src/document/utils/crypto.d.ts.map +1 -1
- package/dist/browser/src/document/utils/node.d.ts +2 -1
- package/dist/browser/src/document/utils/node.d.ts.map +1 -1
- package/dist/node/cjs/document-model.js +6 -6
- package/dist/node/cjs/document.js +3 -3
- package/dist/node/cjs/index.js +2 -2
- package/dist/node/cjs/internal/{creators-cVAOzgAh.js → creators-B5g3rJKI.js} +35 -55
- package/dist/node/cjs/internal/creators-B5g3rJKI.js.map +1 -0
- package/dist/node/cjs/internal/{index-kuBJXCvW.js → index-CYhNqyfA.js} +7 -7
- package/dist/node/cjs/internal/{index-kuBJXCvW.js.map → index-CYhNqyfA.js.map} +1 -1
- package/dist/node/cjs/internal/{index-Zf6dGXol.js → index-Cdxqd-qQ.js} +3 -2
- package/dist/node/cjs/internal/index-Cdxqd-qQ.js.map +1 -0
- package/dist/{browser/cjs/internal/index-B4JwoOCW.js → node/cjs/internal/index-DHkzUhZg.js} +4 -4
- package/dist/node/cjs/internal/index-DHkzUhZg.js.map +1 -0
- package/dist/node/cjs/internal/{object-DrxUkgaL.js → object-CpAsa3Oe.js} +2 -2
- package/dist/node/cjs/internal/{object-DrxUkgaL.js.map → object-CpAsa3Oe.js.map} +1 -1
- package/dist/node/cjs/utils.js +2 -1
- package/dist/node/cjs/utils.js.map +1 -1
- package/dist/node/es/document-model.js +6 -6
- package/dist/node/es/document.js +3 -3
- package/dist/node/es/index.js +2 -2
- package/dist/node/es/internal/{creators-Cb-W0me8.js → creators-B6tCK8Ir.js} +37 -57
- package/dist/node/es/internal/creators-B6tCK8Ir.js.map +1 -0
- package/dist/node/es/internal/{index-DaOQbHFb.js → index-CJxdcyKO.js} +3 -2
- package/dist/node/es/internal/index-CJxdcyKO.js.map +1 -0
- package/dist/node/es/internal/{index-nspj7nvI.js → index-dVqoH-Pd.js} +7 -7
- package/dist/node/es/internal/{index-nspj7nvI.js.map → index-dVqoH-Pd.js.map} +1 -1
- package/dist/node/es/internal/{index-D3XxyPtg.js → index-mUxH6TbI.js} +4 -4
- package/dist/node/es/internal/index-mUxH6TbI.js.map +1 -0
- package/dist/node/es/internal/{object-8ji4ZOox.js → object-Bj_Xyrvk.js} +2 -2
- package/dist/node/es/internal/{object-8ji4ZOox.js.map → object-Bj_Xyrvk.js.map} +1 -1
- package/dist/node/es/utils.js +21 -20
- package/dist/node/src/document/reducer.d.ts.map +1 -1
- package/dist/node/src/document/utils/browser.d.ts +1 -0
- package/dist/node/src/document/utils/browser.d.ts.map +1 -1
- package/dist/node/src/document/utils/crypto.d.ts +1 -0
- package/dist/node/src/document/utils/crypto.d.ts.map +1 -1
- package/dist/node/src/document/utils/node.d.ts +2 -1
- package/dist/node/src/document/utils/node.d.ts.map +1 -1
- package/package.json +5 -6
- package/dist/browser/cjs/internal/creators-BFR88wjA.js.map +0 -1
- package/dist/browser/cjs/internal/index-B4JwoOCW.js.map +0 -1
- package/dist/browser/cjs/internal/index-CQbaipWs.js.map +0 -1
- package/dist/browser/es/internal/creators-B8Nq9c1o.js.map +0 -1
- package/dist/browser/es/internal/index-BBMtae0d.js.map +0 -1
- package/dist/browser/es/internal/index-BH94ELCG.js.map +0 -1
- package/dist/node/cjs/internal/creators-cVAOzgAh.js.map +0 -1
- package/dist/node/cjs/internal/index-TqZ14nZp.js.map +0 -1
- package/dist/node/cjs/internal/index-Zf6dGXol.js.map +0 -1
- package/dist/node/es/internal/creators-Cb-W0me8.js.map +0 -1
- package/dist/node/es/internal/index-D3XxyPtg.js.map +0 -1
- package/dist/node/es/internal/index-DaOQbHFb.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { I as InvalidActionInputError, t as InvalidActionInputZodError, v as ab2hex, w as buildOperationSignature, x as buildOperationSignatureMessage, y as buildOperationSignatureParams, A as buildSignedOperation, f as createAction, b as createDocument, a as createExtendedState, c as createReducer, C as createUnsafeReducer, D as createZip, E as documentHelpers, F as
|
|
1
|
+
import { I as InvalidActionInputError, t as InvalidActionInputZodError, v as ab2hex, w as buildOperationSignature, x as buildOperationSignatureMessage, y as buildOperationSignatureParams, A as buildSignedOperation, f as createAction, b as createDocument, a as createExtendedState, c as createReducer, C as createUnsafeReducer, D as createZip, E as documentHelpers, F as generateId, G as getDocumentLastModified, H as getLocalFile, J as getRemoteFile, K as getUnixTimestamp, L as hashDocument, M as hashKey, N as hex2ab, i as isBaseAction, O as isNoopOperation, P as isSameDocument, Q as isUndo, R as isUndoRedo, l as loadFromFile, e as loadFromInput, S as mapSkippedOperations, T as parseResultingState, r as readOnly, U as replayDocument, V as replayOperations, s as saveToFile, d as saveToFileHandle, W as sortMappedOperations, X as sortOperations, Y as validateOperations, Z as verifyOperationSignature } from "./creators-CkhiX4CP.js";
|
|
2
2
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
3
|
__proto__: null,
|
|
4
4
|
InvalidActionInputError,
|
|
@@ -15,6 +15,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
15
15
|
createUnsafeReducer,
|
|
16
16
|
createZip,
|
|
17
17
|
documentHelpers,
|
|
18
|
+
generateId,
|
|
18
19
|
getDocumentLastModified,
|
|
19
20
|
getLocalFile,
|
|
20
21
|
getRemoteFile,
|
|
@@ -44,4 +45,4 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
44
45
|
export {
|
|
45
46
|
index as i
|
|
46
47
|
};
|
|
47
|
-
//# sourceMappingURL=index-
|
|
48
|
+
//# sourceMappingURL=index-CHpkSkeZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CHpkSkeZ.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as BaseActions, g as baseReducer, m as mutableBaseReducer, p as processUndoRedo, u as updateDocument, h as updateHeader, z as zod } from "./creators-
|
|
2
|
-
import { B as BaseDocument, a as applyMixins } from "./object-
|
|
3
|
-
import { i as index } from "./index-
|
|
1
|
+
import { B as BaseActions, g as baseReducer, m as mutableBaseReducer, p as processUndoRedo, u as updateDocument, h as updateHeader, z as zod } from "./creators-CkhiX4CP.js";
|
|
2
|
+
import { B as BaseDocument, a as applyMixins } from "./object-CJHsId9H.js";
|
|
3
|
+
import { i as index } from "./index-CHpkSkeZ.js";
|
|
4
4
|
const Document = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
5
5
|
__proto__: null,
|
|
6
6
|
BaseDocument,
|
|
@@ -17,4 +17,4 @@ const Document = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
|
|
|
17
17
|
export {
|
|
18
18
|
Document as D
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=index-
|
|
20
|
+
//# sourceMappingURL=index-uWY5kwkt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-uWY5kwkt.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,7 @@ 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
4
|
import "mutative";
|
|
5
|
-
import { s as saveToFile, l as loadFromFile, r as readOnly, j as setName, k as undo, n as redo, o as prune, q as loadState } from "./creators-
|
|
5
|
+
import { s as saveToFile, l as loadFromFile, r as readOnly, j as setName, k as undo, n as redo, o as prune, q as loadState } from "./creators-CkhiX4CP.js";
|
|
6
6
|
class BaseDocument {
|
|
7
7
|
/**
|
|
8
8
|
* Constructs a BaseDocument instance with an initial state.
|
|
@@ -181,4 +181,4 @@ export {
|
|
|
181
181
|
BaseDocument as B,
|
|
182
182
|
applyMixins as a
|
|
183
183
|
};
|
|
184
|
-
//# sourceMappingURL=object-
|
|
184
|
+
//# sourceMappingURL=object-CJHsId9H.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-
|
|
1
|
+
{"version":3,"file":"object-CJHsId9H.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":[],"mappings":";;;;;AAoBO,MAAe,aAA+C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUnE,YACE,SACA,UACA,gBACA;AAbQ;AACF;AACA;AAYN,SAAK,WAAW;AAChB,SAAK,YAAY;AACjB,SAAK,kBAAkB;AAAA,EAAA;AAAA;AAAA;AAA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G, H, J, K, L, M,
|
|
1
|
+
import { I, t, v, w, x, y, A, f, b, a, c, C, D, E, F, G, H, J, K, L, M, N, i, O, P, Q, R, l, e, S, T, r, U, V, s, d, W, X, Y, Z } from "./internal/creators-CkhiX4CP.js";
|
|
2
2
|
export {
|
|
3
3
|
I as InvalidActionInputError,
|
|
4
4
|
t as InvalidActionInputZodError,
|
|
@@ -14,30 +14,31 @@ export {
|
|
|
14
14
|
C as createUnsafeReducer,
|
|
15
15
|
D as createZip,
|
|
16
16
|
E as documentHelpers,
|
|
17
|
-
F as
|
|
18
|
-
G as
|
|
19
|
-
H as
|
|
20
|
-
J as
|
|
21
|
-
K as
|
|
22
|
-
L as
|
|
23
|
-
M as
|
|
17
|
+
F as generateId,
|
|
18
|
+
G as getDocumentLastModified,
|
|
19
|
+
H as getLocalFile,
|
|
20
|
+
J as getRemoteFile,
|
|
21
|
+
K as getUnixTimestamp,
|
|
22
|
+
L as hashDocument,
|
|
23
|
+
M as hashKey,
|
|
24
|
+
N as hex2ab,
|
|
24
25
|
i as isBaseAction,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
O as isNoopOperation,
|
|
27
|
+
P as isSameDocument,
|
|
28
|
+
Q as isUndo,
|
|
29
|
+
R as isUndoRedo,
|
|
29
30
|
l as loadFromFile,
|
|
30
31
|
e as loadFromInput,
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
S as mapSkippedOperations,
|
|
33
|
+
T as parseResultingState,
|
|
33
34
|
r as readOnly,
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
U as replayDocument,
|
|
36
|
+
V as replayOperations,
|
|
36
37
|
s as saveToFile,
|
|
37
38
|
d as saveToFileHandle,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
W as sortMappedOperations,
|
|
40
|
+
X as sortOperations,
|
|
41
|
+
Y as validateOperations,
|
|
42
|
+
Z as verifyOperationSignature
|
|
42
43
|
};
|
|
43
44
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../src/document/reducer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../../../src/document/reducer.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,UAAU,EAMX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAK,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,MAAM,EACN,QAAQ,EACR,qBAAqB,EACrB,SAAS,EAET,cAAc,EAEf,MAAM,SAAS,CAAC;AAUjB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA0B1C;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,EAC7C,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,MAAM,GACb,CAAC,CASH;AAsED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAC/C,QAAQ,EAAE,CAAC,EACX,MAAM,EAAE,MAAM,EACd,IAAI,SAAI,EACR,uBAAuB,UAAQ,KAUhC;AA8BD,KAAK,qBAAqB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI;IACnD,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5B,MAAM,EAAE,CAAC,GAAG,UAAU,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,uBAAuB,EAAE,OAAO,CAAC;CAClC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EACpD,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC3B,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,MAAM,GACX,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAShC;AAoID;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAChD,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,GAAG,UAAU,GAAG,SAAS,EAClC,aAAa,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7C,QAAQ,CAAC,EAAE,cAAc,EACzB,OAAO,GAAE,cAAmB,qBAiK7B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EACvD,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC3B,MAAM,EAAE,CAAC,GAAG,UAAU,GAAG,SAAS,EAClC,aAAa,EAAE,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC7C,QAAQ,CAAC,EAAE,cAAc,EACzB,OAAO,GAAE,cAAmB,qBAwG7B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
|
+
export declare function generateUUID(): `${string}-${string}-${string}-${string}-${string}`;
|
|
2
3
|
export declare function writeFile(path: string, name: string, stream: Uint8Array): Promise<string>;
|
|
3
4
|
export declare function readFile(path: string): void;
|
|
4
5
|
export declare function fetchFile(url: string): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../../src/document/utils/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKrC,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,QAEpC;AAED,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAE9C;AAED,eAAO,MAAM,OAAO,SAAgB,MAAM,kBAEzC,CAAC;AAEF,eAAO,MAAM,IAAI,SACT,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,QAAQ,+BASvD,CAAC"}
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../../../src/document/utils/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAKrC,wBAAgB,YAAY,wDAM3B;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,UAAU,GACjB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,QAEpC;AAED,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAE9C;AAED,eAAO,MAAM,OAAO,SAAgB,MAAM,kBAEzC,CAAC;AAEF,eAAO,MAAM,IAAI,SACT,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,QAAQ,+BASvD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Action, ActionSigner, BaseAction, Document, Operation, OperationSignatureContext, OperationSigningHandler, OperationVerificationHandler, Reducer, Signature } from '../types';
|
|
2
|
+
export declare function generateId(method?: "UUIDv4"): string;
|
|
2
3
|
export declare function getUnixTimestamp(date: Date | string): string;
|
|
3
4
|
export declare function buildOperationSignatureParams({ documentId, signer, operation, previousStateHash, }: OperationSignatureContext): [string, string, string, string];
|
|
4
5
|
export declare function buildOperationSignatureMessage(params: [string, string, string, string]): Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../../../src/document/utils/crypto.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,UAAU,EACV,QAAQ,EACR,SAAS,EACT,yBAAyB,EACzB,uBAAuB,EACvB,4BAA4B,EAC5B,OAAO,EACP,SAAS,EACV,MAAM,UAAU,CAAC;AAGlB,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,UAAU,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,GAClB,EAAE,yBAAyB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAW9D;AAID,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACvC,UAAU,CAIZ;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,WAAW,GAAG,eAAe,GAAG,MAAM,CAKhE;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,2BAMjC;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,yBAAyB,EAClC,UAAU,EAAE,uBAAuB,GAClC,OAAO,CAAC,SAAS,CAAC,CAKpB;AAED,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAC/D,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACxB,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACzB,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC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3C,OAAO,EAAE,yBAAyB,EAClC,UAAU,EAAE,uBAAuB,GAClC,OAAO,CAAC,SAAS,CAAC,CAKpB;AAED,wBAAsB,oBAAoB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAC/D,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACxB,OAAO,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACzB,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC3B,OAAO,EAAE,IAAI,CAAC,yBAAyB,EAAE,WAAW,GAAG,mBAAmB,CAAC,EAC3E,WAAW,EAAE,uBAAuB,GACnC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CA+BpC;AAED,wBAAsB,wBAAwB,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EACnE,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,EACxC,aAAa,EAAE,4BAA4B,GAC1C,OAAO,CAAC,OAAO,CAAC,CAMlB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { default as crypto } from 'crypto';
|
|
1
|
+
import { default as crypto, RandomUUIDOptions } from 'node:crypto';
|
|
2
|
+
export declare function generateUUID(options?: RandomUUIDOptions): `${string}-${string}-${string}-${string}-${string}`;
|
|
2
3
|
export declare function writeFile(path: string, name: string, data: Uint8Array): Promise<string>;
|
|
3
4
|
export declare function readFile(path: string): Buffer<ArrayBufferLike>;
|
|
4
5
|
export declare function fetchFile(url: string): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../../src/document/utils/node.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../../../src/document/utils/node.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAKxD,wBAAgB,YAAY,CAAC,OAAO,CAAC,EAAE,iBAAiB,uDAEvD;AAED,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,GACf,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,2BAEpC;AAED,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBhD;AAED,eAAO,MAAM,OAAO,SAAgB,MAAM,qCAEzC,CAAC;AAEF,eAAO,MAAM,IAAI,SAAU,MAAM,CAAC,UAAU,+BAE3C,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./internal/creators-
|
|
3
|
+
require("./internal/creators-B5g3rJKI.js");
|
|
4
4
|
require("mutative");
|
|
5
5
|
require("zod");
|
|
6
|
-
require("crypto");
|
|
7
|
-
require("fs");
|
|
8
|
-
require("https");
|
|
9
|
-
require("path");
|
|
10
6
|
require("jszip");
|
|
11
|
-
|
|
7
|
+
require("node:crypto");
|
|
8
|
+
require("node:fs");
|
|
9
|
+
require("node:https");
|
|
10
|
+
require("node:path");
|
|
11
|
+
const documentModel = require("./internal/index-CYhNqyfA.js");
|
|
12
12
|
exports.Document = documentModel.Document;
|
|
13
13
|
exports.DocumentModel = documentModel.DocumentModel$1;
|
|
14
14
|
exports.actions = documentModel.actions;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const creators = require("./internal/creators-
|
|
4
|
-
const object = require("./internal/object-
|
|
5
|
-
const utils = require("./internal/index-
|
|
3
|
+
const creators = require("./internal/creators-B5g3rJKI.js");
|
|
4
|
+
const object = require("./internal/object-CpAsa3Oe.js");
|
|
5
|
+
const utils = require("./internal/index-Cdxqd-qQ.js");
|
|
6
6
|
exports.actions = creators.BaseActions;
|
|
7
7
|
exports.baseReducer = creators.baseReducer;
|
|
8
8
|
exports.mutableBaseReducer = creators.mutableBaseReducer;
|
package/dist/node/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const document = require("./internal/index-
|
|
4
|
-
const documentModel = require("./internal/index-
|
|
3
|
+
const document = require("./internal/index-DHkzUhZg.js");
|
|
4
|
+
const documentModel = require("./internal/index-CYhNqyfA.js");
|
|
5
5
|
const DocumentModels = {
|
|
6
6
|
"powerhouse/document": document.Document,
|
|
7
7
|
"powerhouse/document-model": documentModel.DocumentModel
|
|
@@ -5,10 +5,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5
5
|
const JSZip = require("jszip");
|
|
6
6
|
const zod$1 = require("zod");
|
|
7
7
|
const mutative = require("mutative");
|
|
8
|
-
const crypto
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
const https = require("https");
|
|
11
|
-
const
|
|
8
|
+
const crypto = require("node:crypto");
|
|
9
|
+
const fs = require("node:fs");
|
|
10
|
+
const https = require("node:https");
|
|
11
|
+
const node_path = require("node:path");
|
|
12
12
|
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
13
13
|
const definedNonNullAnySchema = zod$1.z.any().refine((v) => isDefinedNonNullAny(v));
|
|
14
14
|
const Load_StateSchema = zod$1.z.enum(["LOAD_STATE"]);
|
|
@@ -749,41 +749,12 @@ ${originalIndentation}`;
|
|
|
749
749
|
var safeStableStringifyExports = requireSafeStableStringify();
|
|
750
750
|
const cjsModule = /* @__PURE__ */ getDefaultExportFromCjs(safeStableStringifyExports);
|
|
751
751
|
cjsModule.configure;
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
function rng() {
|
|
755
|
-
if (!getRandomValues) {
|
|
756
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
757
|
-
if (!getRandomValues) {
|
|
758
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
return getRandomValues(rnds8);
|
|
762
|
-
}
|
|
763
|
-
const byteToHex = [];
|
|
764
|
-
for (let i = 0; i < 256; ++i) {
|
|
765
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
752
|
+
function generateUUID(options) {
|
|
753
|
+
return crypto.randomUUID(options);
|
|
766
754
|
}
|
|
767
|
-
function
|
|
768
|
-
|
|
769
|
-
}
|
|
770
|
-
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
771
|
-
const native = {
|
|
772
|
-
randomUUID
|
|
773
|
-
};
|
|
774
|
-
function v4(options, buf, offset) {
|
|
775
|
-
if (native.randomUUID && !buf && !options) {
|
|
776
|
-
return native.randomUUID();
|
|
777
|
-
}
|
|
778
|
-
options = options || {};
|
|
779
|
-
const rnds = options.random || (options.rng || rng)();
|
|
780
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
781
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
782
|
-
return unsafeStringify(rnds);
|
|
783
|
-
}
|
|
784
|
-
function writeFile(path$1, name, data) {
|
|
785
|
-
const filePath = path.join(path$1, name);
|
|
786
|
-
fs.mkdirSync(path$1, { recursive: true });
|
|
755
|
+
function writeFile(path, name, data) {
|
|
756
|
+
const filePath = node_path.join(path, name);
|
|
757
|
+
fs.mkdirSync(path, { recursive: true });
|
|
787
758
|
return new Promise((resolve, reject) => {
|
|
788
759
|
try {
|
|
789
760
|
fs.writeFile(filePath, data, {}, (err) => {
|
|
@@ -798,8 +769,8 @@ function writeFile(path$1, name, data) {
|
|
|
798
769
|
}
|
|
799
770
|
});
|
|
800
771
|
}
|
|
801
|
-
function readFile(
|
|
802
|
-
return fs.readFileSync(
|
|
772
|
+
function readFile(path) {
|
|
773
|
+
return fs.readFileSync(path);
|
|
803
774
|
}
|
|
804
775
|
function fetchFile(url) {
|
|
805
776
|
return new Promise((resolve, reject) => {
|
|
@@ -821,8 +792,16 @@ const getFile = async (file) => {
|
|
|
821
792
|
return readFile(file);
|
|
822
793
|
};
|
|
823
794
|
const hash = (data, algorithm = "sha1") => {
|
|
824
|
-
return crypto
|
|
795
|
+
return crypto.createHash(algorithm).update(data).digest("base64");
|
|
825
796
|
};
|
|
797
|
+
function generateId(method) {
|
|
798
|
+
if (method && method.toString() !== "UUIDv4") {
|
|
799
|
+
throw new Error(
|
|
800
|
+
`Id generation method not supported: "${method.toString()}"`
|
|
801
|
+
);
|
|
802
|
+
}
|
|
803
|
+
return generateUUID();
|
|
804
|
+
}
|
|
826
805
|
function getUnixTimestamp(date) {
|
|
827
806
|
return (new Date(date).getTime() / 1e3).toFixed(0);
|
|
828
807
|
}
|
|
@@ -970,12 +949,12 @@ class Mime {
|
|
|
970
949
|
}
|
|
971
950
|
return this;
|
|
972
951
|
}
|
|
973
|
-
getType(
|
|
974
|
-
if (typeof
|
|
952
|
+
getType(path) {
|
|
953
|
+
if (typeof path !== "string")
|
|
975
954
|
return null;
|
|
976
|
-
const last =
|
|
955
|
+
const last = path.replace(/^.*[/\\]/, "").toLowerCase();
|
|
977
956
|
const ext = last.replace(/^.*\./, "").toLowerCase();
|
|
978
|
-
const hasPath = last.length <
|
|
957
|
+
const hasPath = last.length < path.length;
|
|
979
958
|
const hasDot = ext.length < last.length - 1;
|
|
980
959
|
if (!hasDot && hasPath)
|
|
981
960
|
return null;
|
|
@@ -1427,7 +1406,7 @@ const createZip = async (document) => {
|
|
|
1427
1406
|
}
|
|
1428
1407
|
return zip;
|
|
1429
1408
|
};
|
|
1430
|
-
const saveToFile = async (document,
|
|
1409
|
+
const saveToFile = async (document, path, extension, name) => {
|
|
1431
1410
|
const zip = await createZip(document);
|
|
1432
1411
|
const file = await zip.generateAsync({
|
|
1433
1412
|
type: "uint8array",
|
|
@@ -1436,7 +1415,7 @@ const saveToFile = async (document, path2, extension, name) => {
|
|
|
1436
1415
|
const fileName = name ?? document.name;
|
|
1437
1416
|
const fileExtension = `.${extension}.zip`;
|
|
1438
1417
|
return writeFile(
|
|
1439
|
-
|
|
1418
|
+
path,
|
|
1440
1419
|
fileName.endsWith(fileExtension) ? fileName : `${fileName}${fileExtension}`,
|
|
1441
1420
|
file
|
|
1442
1421
|
);
|
|
@@ -1448,8 +1427,8 @@ const saveToFileHandle = async (document, input) => {
|
|
|
1448
1427
|
await writable.write(blob);
|
|
1449
1428
|
await writable.close();
|
|
1450
1429
|
};
|
|
1451
|
-
const loadFromFile = async (
|
|
1452
|
-
const file = readFile(
|
|
1430
|
+
const loadFromFile = async (path, reducer, options) => {
|
|
1431
|
+
const file = readFile(path);
|
|
1453
1432
|
return loadFromInput(file, reducer, options);
|
|
1454
1433
|
};
|
|
1455
1434
|
const loadFromInput = async (input, reducer, options) => {
|
|
@@ -1515,10 +1494,10 @@ async function getRemoteFile(url) {
|
|
|
1515
1494
|
...attributes
|
|
1516
1495
|
};
|
|
1517
1496
|
}
|
|
1518
|
-
async function getLocalFile(
|
|
1519
|
-
const buffer = await getFile(
|
|
1520
|
-
const mimeType = mime.getType(
|
|
1521
|
-
const attributes = getFileAttributes(
|
|
1497
|
+
async function getLocalFile(path) {
|
|
1498
|
+
const buffer = await getFile(path);
|
|
1499
|
+
const mimeType = mime.getType(path) || "application/octet-stream";
|
|
1500
|
+
const attributes = getFileAttributes(path);
|
|
1522
1501
|
const data = buffer.toString("base64");
|
|
1523
1502
|
return { data, hash: hash(data), mimeType, ...attributes };
|
|
1524
1503
|
}
|
|
@@ -1692,7 +1671,7 @@ function updateOperations(document, action, skip = 0, reuseLastOperationIndex =
|
|
|
1692
1671
|
operationId = action.id;
|
|
1693
1672
|
timestamp = action.timestamp;
|
|
1694
1673
|
} else {
|
|
1695
|
-
operationId = "id" in action ? action.id :
|
|
1674
|
+
operationId = "id" in action ? action.id : generateId();
|
|
1696
1675
|
}
|
|
1697
1676
|
operations.push({
|
|
1698
1677
|
...action,
|
|
@@ -2315,6 +2294,7 @@ exports.createReducer = createReducer;
|
|
|
2315
2294
|
exports.createUnsafeReducer = createUnsafeReducer;
|
|
2316
2295
|
exports.createZip = createZip;
|
|
2317
2296
|
exports.documentHelpers = documentHelpers;
|
|
2297
|
+
exports.generateId = generateId;
|
|
2318
2298
|
exports.getDocumentLastModified = getDocumentLastModified;
|
|
2319
2299
|
exports.getLocalFile = getLocalFile;
|
|
2320
2300
|
exports.getRemoteFile = getRemoteFile;
|
|
@@ -2350,4 +2330,4 @@ exports.updateHeader = updateHeader;
|
|
|
2350
2330
|
exports.validateOperations = validateOperations;
|
|
2351
2331
|
exports.verifyOperationSignature = verifyOperationSignature;
|
|
2352
2332
|
exports.zod = zod;
|
|
2353
|
-
//# sourceMappingURL=creators-
|
|
2333
|
+
//# sourceMappingURL=creators-B5g3rJKI.js.map
|