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,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const creators = require("./creators-
|
|
2
|
+
const creators = require("./creators-B5g3rJKI.js");
|
|
3
3
|
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
4
4
|
__proto__: null,
|
|
5
5
|
InvalidActionInputError: creators.InvalidActionInputError,
|
|
@@ -16,6 +16,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
16
16
|
createUnsafeReducer: creators.createUnsafeReducer,
|
|
17
17
|
createZip: creators.createZip,
|
|
18
18
|
documentHelpers: creators.documentHelpers,
|
|
19
|
+
generateId: creators.generateId,
|
|
19
20
|
getDocumentLastModified: creators.getDocumentLastModified,
|
|
20
21
|
getLocalFile: creators.getLocalFile,
|
|
21
22
|
getRemoteFile: creators.getRemoteFile,
|
|
@@ -43,4 +44,4 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
43
44
|
verifyOperationSignature: creators.verifyOperationSignature
|
|
44
45
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
45
46
|
exports.index = index;
|
|
46
|
-
//# sourceMappingURL=index-
|
|
47
|
+
//# sourceMappingURL=index-Cdxqd-qQ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Cdxqd-qQ.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const creators = require("./creators-
|
|
3
|
-
const object = require("./object-
|
|
4
|
-
const utils = require("./index-
|
|
2
|
+
const creators = require("./creators-B5g3rJKI.js");
|
|
3
|
+
const object = require("./object-CpAsa3Oe.js");
|
|
4
|
+
const utils = require("./index-Cdxqd-qQ.js");
|
|
5
5
|
const Document = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
6
6
|
__proto__: null,
|
|
7
7
|
BaseDocument: object.BaseDocument,
|
|
@@ -16,4 +16,4 @@ const Document = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
|
|
|
16
16
|
z: creators.zod
|
|
17
17
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
18
18
|
exports.Document = Document;
|
|
19
|
-
//# sourceMappingURL=index-
|
|
19
|
+
//# sourceMappingURL=index-DHkzUhZg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DHkzUhZg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;"}
|
|
@@ -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-B5g3rJKI.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-CpAsa3Oe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object-
|
|
1
|
+
{"version":3,"file":"object-CpAsa3Oe.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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"}
|
package/dist/node/cjs/utils.js
CHANGED
|
@@ -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-B5g3rJKI.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,12 +1,12 @@
|
|
|
1
|
-
import "./internal/creators-
|
|
1
|
+
import "./internal/creators-B6tCK8Ir.js";
|
|
2
2
|
import "mutative";
|
|
3
3
|
import "zod";
|
|
4
|
-
import "crypto";
|
|
5
|
-
import "fs";
|
|
6
|
-
import "https";
|
|
7
|
-
import "path";
|
|
8
4
|
import "jszip";
|
|
9
|
-
import
|
|
5
|
+
import "node:crypto";
|
|
6
|
+
import "node:fs";
|
|
7
|
+
import "node:https";
|
|
8
|
+
import "node:path";
|
|
9
|
+
import { b, a, c, d, m, r, u, v, g, h, f, e, z } from "./internal/index-dVqoH-Pd.js";
|
|
10
10
|
export {
|
|
11
11
|
b as Document,
|
|
12
12
|
a as DocumentModel,
|
package/dist/node/es/document.js
CHANGED
|
@@ -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-B6tCK8Ir.js";
|
|
2
|
+
import { B as B2, a } from "./internal/object-Bj_Xyrvk.js";
|
|
3
|
+
import { i } from "./internal/index-CJxdcyKO.js";
|
|
4
4
|
export {
|
|
5
5
|
B2 as BaseDocument,
|
|
6
6
|
B as actions,
|
package/dist/node/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-mUxH6TbI.js";
|
|
2
|
+
import { D as DocumentModel } from "./internal/index-dVqoH-Pd.js";
|
|
3
3
|
const DocumentModels = {
|
|
4
4
|
"powerhouse/document": Document,
|
|
5
5
|
"powerhouse/document-model": DocumentModel
|
|
@@ -4,10 +4,10 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import JSZip from "jszip";
|
|
5
5
|
import { z, ZodError } from "zod";
|
|
6
6
|
import { create, castDraft, unsafe } from "mutative";
|
|
7
|
-
import crypto
|
|
8
|
-
import fs from "fs";
|
|
9
|
-
import https from "https";
|
|
10
|
-
import { join } from "path";
|
|
7
|
+
import crypto from "node:crypto";
|
|
8
|
+
import fs from "node:fs";
|
|
9
|
+
import https from "node:https";
|
|
10
|
+
import { join } from "node:path";
|
|
11
11
|
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
12
12
|
const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
|
|
13
13
|
const Load_StateSchema = z.enum(["LOAD_STATE"]);
|
|
@@ -748,37 +748,8 @@ ${originalIndentation}`;
|
|
|
748
748
|
var safeStableStringifyExports = requireSafeStableStringify();
|
|
749
749
|
const cjsModule = /* @__PURE__ */ getDefaultExportFromCjs(safeStableStringifyExports);
|
|
750
750
|
cjsModule.configure;
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
function rng() {
|
|
754
|
-
if (!getRandomValues) {
|
|
755
|
-
getRandomValues = typeof crypto !== "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
756
|
-
if (!getRandomValues) {
|
|
757
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
758
|
-
}
|
|
759
|
-
}
|
|
760
|
-
return getRandomValues(rnds8);
|
|
761
|
-
}
|
|
762
|
-
const byteToHex = [];
|
|
763
|
-
for (let i = 0; i < 256; ++i) {
|
|
764
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
765
|
-
}
|
|
766
|
-
function unsafeStringify(arr, offset = 0) {
|
|
767
|
-
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]];
|
|
768
|
-
}
|
|
769
|
-
const randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
770
|
-
const native = {
|
|
771
|
-
randomUUID
|
|
772
|
-
};
|
|
773
|
-
function v4(options, buf, offset) {
|
|
774
|
-
if (native.randomUUID && !buf && !options) {
|
|
775
|
-
return native.randomUUID();
|
|
776
|
-
}
|
|
777
|
-
options = options || {};
|
|
778
|
-
const rnds = options.random || (options.rng || rng)();
|
|
779
|
-
rnds[6] = rnds[6] & 15 | 64;
|
|
780
|
-
rnds[8] = rnds[8] & 63 | 128;
|
|
781
|
-
return unsafeStringify(rnds);
|
|
751
|
+
function generateUUID(options) {
|
|
752
|
+
return crypto.randomUUID(options);
|
|
782
753
|
}
|
|
783
754
|
function writeFile(path, name, data) {
|
|
784
755
|
const filePath = join(path, name);
|
|
@@ -820,8 +791,16 @@ const getFile = async (file) => {
|
|
|
820
791
|
return readFile(file);
|
|
821
792
|
};
|
|
822
793
|
const hash = (data, algorithm = "sha1") => {
|
|
823
|
-
return crypto
|
|
794
|
+
return crypto.createHash(algorithm).update(data).digest("base64");
|
|
824
795
|
};
|
|
796
|
+
function generateId(method) {
|
|
797
|
+
if (method && method.toString() !== "UUIDv4") {
|
|
798
|
+
throw new Error(
|
|
799
|
+
`Id generation method not supported: "${method.toString()}"`
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
return generateUUID();
|
|
803
|
+
}
|
|
825
804
|
function getUnixTimestamp(date) {
|
|
826
805
|
return (new Date(date).getTime() / 1e3).toFixed(0);
|
|
827
806
|
}
|
|
@@ -1691,7 +1670,7 @@ function updateOperations(document, action, skip = 0, reuseLastOperationIndex =
|
|
|
1691
1670
|
operationId = action.id;
|
|
1692
1671
|
timestamp = action.timestamp;
|
|
1693
1672
|
} else {
|
|
1694
|
-
operationId = "id" in action ? action.id :
|
|
1673
|
+
operationId = "id" in action ? action.id : generateId();
|
|
1695
1674
|
}
|
|
1696
1675
|
operations.push({
|
|
1697
1676
|
...action,
|
|
@@ -2304,26 +2283,27 @@ export {
|
|
|
2304
2283
|
createUnsafeReducer as C,
|
|
2305
2284
|
createZip as D,
|
|
2306
2285
|
documentHelpers as E,
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2286
|
+
generateId as F,
|
|
2287
|
+
getDocumentLastModified as G,
|
|
2288
|
+
getLocalFile as H,
|
|
2310
2289
|
InvalidActionInputError as I,
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2290
|
+
getRemoteFile as J,
|
|
2291
|
+
getUnixTimestamp as K,
|
|
2292
|
+
hashDocument as L,
|
|
2293
|
+
hashKey as M,
|
|
2294
|
+
hex2ab as N,
|
|
2295
|
+
isNoopOperation as O,
|
|
2296
|
+
isSameDocument as P,
|
|
2297
|
+
isUndo as Q,
|
|
2298
|
+
isUndoRedo as R,
|
|
2299
|
+
mapSkippedOperations as S,
|
|
2300
|
+
parseResultingState as T,
|
|
2301
|
+
replayDocument as U,
|
|
2302
|
+
replayOperations as V,
|
|
2303
|
+
sortMappedOperations as W,
|
|
2304
|
+
sortOperations as X,
|
|
2305
|
+
validateOperations as Y,
|
|
2306
|
+
verifyOperationSignature as Z,
|
|
2327
2307
|
createExtendedState as a,
|
|
2328
2308
|
createDocument as b,
|
|
2329
2309
|
createReducer as c,
|
|
@@ -2351,4 +2331,4 @@ export {
|
|
|
2351
2331
|
buildOperationSignatureParams as y,
|
|
2352
2332
|
zod as z
|
|
2353
2333
|
};
|
|
2354
|
-
//# sourceMappingURL=creators-
|
|
2334
|
+
//# sourceMappingURL=creators-B6tCK8Ir.js.map
|