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
|
@@ -3,7 +3,7 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
5
|
require("mutative");
|
|
6
|
-
const creators = require("./creators-
|
|
6
|
+
const creators = require("./creators-c2maywyy.js");
|
|
7
7
|
class BaseDocument {
|
|
8
8
|
/**
|
|
9
9
|
* Constructs a BaseDocument instance with an initial state.
|
|
@@ -180,4 +180,4 @@ function applyMixins(derivedCtor, constructors) {
|
|
|
180
180
|
}
|
|
181
181
|
exports.BaseDocument = BaseDocument;
|
|
182
182
|
exports.applyMixins = applyMixins;
|
|
183
|
-
//# sourceMappingURL=object-
|
|
183
|
+
//# sourceMappingURL=object-WukT1Feq.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-
|
|
1
|
+
{"version":3,"file":"object-WukT1Feq.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","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aAAA;AAAA;AAAA,QAEL,YAAY;AAAA,QACZ;AAAA;AAAA,QAEA,OAAO,yBAAyB,SAAS,WAAW,IAAI,KACtD,uBAAO,OAAO,IAAI;AAAA,MACtB;AAAA,IAAA,CACD;AAAA,EAAA,CACF;AACH;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const creators = require("./internal/creators-
|
|
3
|
+
const creators = require("./internal/creators-c2maywyy.js");
|
|
4
4
|
exports.InvalidActionInputError = creators.InvalidActionInputError;
|
|
5
5
|
exports.InvalidActionInputZodError = creators.InvalidActionInputZodError;
|
|
6
6
|
exports.ab2hex = creators.ab2hex;
|
|
@@ -15,6 +15,7 @@ exports.createReducer = creators.createReducer;
|
|
|
15
15
|
exports.createUnsafeReducer = creators.createUnsafeReducer;
|
|
16
16
|
exports.createZip = creators.createZip;
|
|
17
17
|
exports.documentHelpers = creators.documentHelpers;
|
|
18
|
+
exports.generateId = creators.generateId;
|
|
18
19
|
exports.getDocumentLastModified = creators.getDocumentLastModified;
|
|
19
20
|
exports.getLocalFile = creators.getLocalFile;
|
|
20
21
|
exports.getRemoteFile = creators.getRemoteFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "./internal/creators-
|
|
1
|
+
import "./internal/creators-CkhiX4CP.js";
|
|
2
2
|
import "mutative";
|
|
3
3
|
import "zod";
|
|
4
4
|
import "jszip";
|
|
5
|
-
import { b, a, c, d, m, r, u, v, g, h, f, e, z } from "./internal/index-
|
|
5
|
+
import { b, a, c, d, m, r, u, v, g, h, f, e, z } from "./internal/index-BRVlDkPn.js";
|
|
6
6
|
export {
|
|
7
7
|
b as Document,
|
|
8
8
|
a as DocumentModel,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B, g, m, p, u, h, z } from "./internal/creators-
|
|
2
|
-
import { B as B2, a } from "./internal/object-
|
|
3
|
-
import { i } from "./internal/index-
|
|
1
|
+
import { B, g, m, p, u, h, z } from "./internal/creators-CkhiX4CP.js";
|
|
2
|
+
import { B as B2, a } from "./internal/object-CJHsId9H.js";
|
|
3
|
+
import { i } from "./internal/index-CHpkSkeZ.js";
|
|
4
4
|
export {
|
|
5
5
|
B2 as BaseDocument,
|
|
6
6
|
B as actions,
|
package/dist/browser/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as Document } from "./internal/index-
|
|
2
|
-
import { D as DocumentModel } from "./internal/index-
|
|
1
|
+
import { D as Document } from "./internal/index-uWY5kwkt.js";
|
|
2
|
+
import { D as DocumentModel } from "./internal/index-BRVlDkPn.js";
|
|
3
3
|
const DocumentModels = {
|
|
4
4
|
"powerhouse/document": Document,
|
|
5
5
|
"powerhouse/document-model": DocumentModel
|
|
@@ -744,38 +744,6 @@ ${originalIndentation}`;
|
|
|
744
744
|
var safeStableStringifyExports = requireSafeStableStringify();
|
|
745
745
|
const cjsModule = /* @__PURE__ */ getDefaultExportFromCjs(safeStableStringifyExports);
|
|
746
746
|
cjsModule.configure;
|
|
747
|
-
let getRandomValues;
|
|
748
|
-
const rnds8 = new Uint8Array(16);
|
|
749
|
-
function rng() {
|
|
750
|
-
if (!getRandomValues) {
|
|
751
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
752
|
-
if (!getRandomValues) {
|
|
753
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
return getRandomValues(rnds8);
|
|
757
|
-
}
|
|
758
|
-
const byteToHex = [];
|
|
759
|
-
for (let i = 0; i < 256; ++i) {
|
|
760
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
761
|
-
}
|
|
762
|
-
function unsafeStringify(arr, offset = 0) {
|
|
763
|
-
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
|
|
764
|
-
}
|
|
765
|
-
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
766
|
-
const native = {
|
|
767
|
-
randomUUID
|
|
768
|
-
};
|
|
769
|
-
function v4(options, buf, offset) {
|
|
770
|
-
if (native.randomUUID && !buf && !options) {
|
|
771
|
-
return native.randomUUID();
|
|
772
|
-
}
|
|
773
|
-
options = options || {};
|
|
774
|
-
const rnds = options.random || (options.rng || rng)();
|
|
775
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
776
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
777
|
-
return unsafeStringify(rnds);
|
|
778
|
-
}
|
|
779
747
|
const K = [
|
|
780
748
|
1518500249 | 0,
|
|
781
749
|
1859775393 | 0,
|
|
@@ -1004,6 +972,12 @@ function isBE() {
|
|
|
1004
972
|
return buf[0] === 254;
|
|
1005
973
|
}
|
|
1006
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
|
+
}
|
|
1007
981
|
function writeFile(path, name, stream) {
|
|
1008
982
|
throw FileSystemError;
|
|
1009
983
|
}
|
|
@@ -1037,6 +1011,14 @@ function hashUIntArray(data, algorithm = "sha1") {
|
|
|
1037
1011
|
}
|
|
1038
1012
|
return createHash().update(data).digest();
|
|
1039
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
|
+
}
|
|
1040
1022
|
function getUnixTimestamp(date) {
|
|
1041
1023
|
return (new Date(date).getTime() / 1e3).toFixed(0);
|
|
1042
1024
|
}
|
|
@@ -1905,7 +1887,7 @@ function updateOperations(document, action, skip = 0, reuseLastOperationIndex =
|
|
|
1905
1887
|
operationId = action.id;
|
|
1906
1888
|
timestamp = action.timestamp;
|
|
1907
1889
|
} else {
|
|
1908
|
-
operationId = "id" in action ? action.id :
|
|
1890
|
+
operationId = "id" in action ? action.id : generateId();
|
|
1909
1891
|
}
|
|
1910
1892
|
operations.push({
|
|
1911
1893
|
...action,
|
|
@@ -2518,26 +2500,27 @@ export {
|
|
|
2518
2500
|
createUnsafeReducer as C,
|
|
2519
2501
|
createZip as D,
|
|
2520
2502
|
documentHelpers as E,
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2503
|
+
generateId as F,
|
|
2504
|
+
getDocumentLastModified as G,
|
|
2505
|
+
getLocalFile as H,
|
|
2524
2506
|
InvalidActionInputError as I,
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2507
|
+
getRemoteFile as J,
|
|
2508
|
+
getUnixTimestamp as K,
|
|
2509
|
+
hashDocument as L,
|
|
2510
|
+
hashKey as M,
|
|
2511
|
+
hex2ab as N,
|
|
2512
|
+
isNoopOperation as O,
|
|
2513
|
+
isSameDocument as P,
|
|
2514
|
+
isUndo as Q,
|
|
2515
|
+
isUndoRedo as R,
|
|
2516
|
+
mapSkippedOperations as S,
|
|
2517
|
+
parseResultingState as T,
|
|
2518
|
+
replayDocument as U,
|
|
2519
|
+
replayOperations as V,
|
|
2520
|
+
sortMappedOperations as W,
|
|
2521
|
+
sortOperations as X,
|
|
2522
|
+
validateOperations as Y,
|
|
2523
|
+
verifyOperationSignature as Z,
|
|
2541
2524
|
createExtendedState as a,
|
|
2542
2525
|
createDocument as b,
|
|
2543
2526
|
createReducer as c,
|
|
@@ -2565,4 +2548,4 @@ export {
|
|
|
2565
2548
|
buildOperationSignatureParams as y,
|
|
2566
2549
|
zod as z
|
|
2567
2550
|
};
|
|
2568
|
-
//# sourceMappingURL=creators-
|
|
2551
|
+
//# sourceMappingURL=creators-CkhiX4CP.js.map
|