document-model 1.6.0 → 1.7.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 +2 -2
- package/dist/browser/cjs/index.js +2 -2
- package/dist/browser/cjs/internal/{index-BImZF-Wk.js → index-BllCzBc9.js} +11 -3
- package/dist/browser/cjs/internal/index-BllCzBc9.js.map +1 -0
- package/dist/browser/cjs/internal/{index-vlbA6Asd.js → index-DTRXQ2Nf.js} +5 -10
- package/dist/browser/{es/internal/index-CuhiYn-8.js.map → cjs/internal/index-DTRXQ2Nf.js.map} +1 -1
- package/dist/browser/cjs/internal/{object-9Wvjprnm.js → object-Bf9_woMQ.js} +302 -320
- package/dist/browser/cjs/internal/object-Bf9_woMQ.js.map +1 -0
- package/dist/browser/es/document-model.js +2 -2
- package/dist/browser/es/document.js +8 -8
- package/dist/browser/es/index.js +2 -2
- package/dist/browser/es/internal/{index-CuhiYn-8.js → index-BAvDobTr.js} +5 -10
- package/dist/{node/es/internal/index-BNAE-_Hg.js.map → browser/es/internal/index-BAvDobTr.js.map} +1 -1
- package/dist/browser/es/internal/index-Db40bdYP.js +58 -0
- package/dist/browser/es/internal/index-Db40bdYP.js.map +1 -0
- package/dist/browser/es/internal/{object-CyAog_F_.js → object-CY74acQg.js} +327 -345
- package/dist/browser/es/internal/object-CY74acQg.js.map +1 -0
- package/dist/browser/src/document/actions/creators.d.ts +1 -1
- package/dist/browser/src/document/schema/zod.d.ts +18 -18
- package/dist/browser/src/document/types.d.ts +12 -1
- package/dist/browser/src/document/utils/base.d.ts +1 -1
- package/dist/browser/src/document/utils/crypto.d.ts +10 -0
- package/dist/browser/src/document/utils/index.d.ts +1 -0
- package/dist/browser/src/document/utils/node.d.ts +3 -2
- package/dist/browser/src/document-model/gen/schema/zod.d.ts +177 -177
- package/dist/browser/src/document-model/index.d.ts +3 -3
- package/dist/node/cjs/document-model.js +2 -2
- package/dist/node/cjs/document.js +2 -2
- package/dist/node/cjs/index.js +2 -2
- package/dist/node/cjs/internal/{index-DWeC8dwW.js → index-aABa-Hb0.js} +5 -10
- package/dist/node/cjs/internal/{index-DWeC8dwW.js.map → index-aABa-Hb0.js.map} +1 -1
- package/dist/node/cjs/internal/{index-CJIU8iX-.js → index-kI4cPPpE.js} +11 -3
- package/dist/node/cjs/internal/index-kI4cPPpE.js.map +1 -0
- package/dist/node/cjs/internal/{object-op6YzhH1.js → object-BMm0OLWL.js} +148 -59
- package/dist/node/cjs/internal/object-BMm0OLWL.js.map +1 -0
- package/dist/node/es/document-model.js +2 -2
- package/dist/node/es/document.js +8 -8
- package/dist/node/es/index.js +2 -2
- package/dist/node/es/internal/{index-BNAE-_Hg.js → index-B0WPutmO.js} +5 -10
- package/dist/{browser/cjs/internal/index-vlbA6Asd.js.map → node/es/internal/index-B0WPutmO.js.map} +1 -1
- package/dist/node/es/internal/index-MkEgGMJR.js +58 -0
- package/dist/node/es/internal/index-MkEgGMJR.js.map +1 -0
- package/dist/node/es/internal/{object-BuK9PFjs.js → object-VZ_AS47_.js} +173 -84
- package/dist/node/es/internal/object-VZ_AS47_.js.map +1 -0
- package/dist/node/src/document/actions/creators.d.ts +1 -1
- package/dist/node/src/document/schema/zod.d.ts +18 -18
- package/dist/node/src/document/types.d.ts +12 -1
- package/dist/node/src/document/utils/base.d.ts +1 -1
- package/dist/node/src/document/utils/crypto.d.ts +10 -0
- package/dist/node/src/document/utils/index.d.ts +1 -0
- package/dist/node/src/document/utils/node.d.ts +3 -2
- package/dist/node/src/document-model/gen/schema/zod.d.ts +177 -177
- package/dist/node/src/document-model/index.d.ts +3 -3
- package/package.json +2 -1
- package/dist/browser/cjs/internal/index-BImZF-Wk.js.map +0 -1
- package/dist/browser/cjs/internal/object-9Wvjprnm.js.map +0 -1
- package/dist/browser/es/internal/index-Drp90r05.js +0 -50
- package/dist/browser/es/internal/index-Drp90r05.js.map +0 -1
- package/dist/browser/es/internal/object-CyAog_F_.js.map +0 -1
- package/dist/node/cjs/internal/index-CJIU8iX-.js.map +0 -1
- package/dist/node/cjs/internal/object-op6YzhH1.js.map +0 -1
- package/dist/node/es/internal/index-B_7z_4EV.js +0 -50
- package/dist/node/es/internal/index-B_7z_4EV.js.map +0 -1
- package/dist/node/es/internal/object-BuK9PFjs.js.map +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { j as ab2hex, k as buildOperationSignature, m as buildOperationSignatureMessage, n as buildOperationSignatureParams, o as buildSignedOperation, p as calculateSkipsLeft, f as createAction, b as createDocument, a as createExtendedState, c as createReducer, q as createUnsafeReducer, r as createZip, t as documentHelpers, u as getLocalFile, v as getRemoteFile, w as getUnixTimestamp, x as hashDocument, y as hashKey, z as hex2ab, i as isBaseAction, A as isNoopOperation, C as isSameDocument, D as isUndoRedo, l as loadFromFile, e as loadFromInput, E as mapSkippedOperations, F as parseResultingState, G as readOnly, H as replayDocument, I as replayOperations, s as saveToFile, d as saveToFileHandle, J as sortMappedOperations, K as sortOperations, L as validateOperations, M as verifyOperationSignature, B as BaseDocument, h as BaseActions, g as applyMixins, N as baseReducer, O as mutableBaseReducer, P as processUndoRedo, Q as updateDocument, R as updateHeader, S as zod } from "./object-VZ_AS47_.js";
|
|
2
|
+
const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3
|
+
__proto__: null,
|
|
4
|
+
ab2hex,
|
|
5
|
+
buildOperationSignature,
|
|
6
|
+
buildOperationSignatureMessage,
|
|
7
|
+
buildOperationSignatureParams,
|
|
8
|
+
buildSignedOperation,
|
|
9
|
+
calculateSkipsLeft,
|
|
10
|
+
createAction,
|
|
11
|
+
createDocument,
|
|
12
|
+
createExtendedState,
|
|
13
|
+
createReducer,
|
|
14
|
+
createUnsafeReducer,
|
|
15
|
+
createZip,
|
|
16
|
+
documentHelpers,
|
|
17
|
+
getLocalFile,
|
|
18
|
+
getRemoteFile,
|
|
19
|
+
getUnixTimestamp,
|
|
20
|
+
hashDocument,
|
|
21
|
+
hashKey,
|
|
22
|
+
hex2ab,
|
|
23
|
+
isBaseAction,
|
|
24
|
+
isNoopOperation,
|
|
25
|
+
isSameDocument,
|
|
26
|
+
isUndoRedo,
|
|
27
|
+
loadFromFile,
|
|
28
|
+
loadFromInput,
|
|
29
|
+
mapSkippedOperations,
|
|
30
|
+
parseResultingState,
|
|
31
|
+
readOnly,
|
|
32
|
+
replayDocument,
|
|
33
|
+
replayOperations,
|
|
34
|
+
saveToFile,
|
|
35
|
+
saveToFileHandle,
|
|
36
|
+
sortMappedOperations,
|
|
37
|
+
sortOperations,
|
|
38
|
+
validateOperations,
|
|
39
|
+
verifyOperationSignature
|
|
40
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
41
|
+
const Document = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
42
|
+
__proto__: null,
|
|
43
|
+
BaseDocument,
|
|
44
|
+
actions: BaseActions,
|
|
45
|
+
applyMixins,
|
|
46
|
+
baseReducer,
|
|
47
|
+
mutableBaseReducer,
|
|
48
|
+
processUndoRedo,
|
|
49
|
+
updateDocument,
|
|
50
|
+
updateHeader,
|
|
51
|
+
utils: index,
|
|
52
|
+
z: zod
|
|
53
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
54
|
+
export {
|
|
55
|
+
Document as D,
|
|
56
|
+
index as i
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=index-MkEgGMJR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-MkEgGMJR.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,16 +1,13 @@
|
|
|
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
|
-
var __publicField = (obj, key, value) =>
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
7
4
|
import { create, castDraft, unsafe } from "mutative";
|
|
8
5
|
import { z } from "zod";
|
|
9
|
-
import JSZip from "jszip";
|
|
10
6
|
import crypto$1 from "crypto";
|
|
11
7
|
import fs from "fs";
|
|
12
8
|
import https from "https";
|
|
13
9
|
import { join } from "path";
|
|
10
|
+
import JSZip from "jszip";
|
|
14
11
|
const isDefinedNonNullAny = (v) => v !== void 0 && v !== null;
|
|
15
12
|
const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
|
|
16
13
|
const Load_StateSchema = z.enum(["LOAD_STATE"]);
|
|
@@ -274,8 +271,7 @@ var safeStableStringify = { exports: {} };
|
|
|
274
271
|
if (value) {
|
|
275
272
|
return (value2) => {
|
|
276
273
|
let message = `Object can not safely be stringified. Received type ${typeof value2}`;
|
|
277
|
-
if (typeof value2 !== "function")
|
|
278
|
-
message += ` (${value2.toString()})`;
|
|
274
|
+
if (typeof value2 !== "function") message += ` (${value2.toString()})`;
|
|
279
275
|
throw new Error(message);
|
|
280
276
|
};
|
|
281
277
|
}
|
|
@@ -924,13 +920,142 @@ const REDO = "REDO";
|
|
|
924
920
|
const PRUNE = "PRUNE";
|
|
925
921
|
const LOAD_STATE = "LOAD_STATE";
|
|
926
922
|
const NOOP = "NOOP";
|
|
923
|
+
function writeFile(path, name, data) {
|
|
924
|
+
const filePath = join(path, name);
|
|
925
|
+
fs.mkdirSync(path, { recursive: true });
|
|
926
|
+
return new Promise((resolve, reject) => {
|
|
927
|
+
try {
|
|
928
|
+
fs.writeFile(filePath, data, {}, (err) => {
|
|
929
|
+
if (err) {
|
|
930
|
+
reject(err);
|
|
931
|
+
} else {
|
|
932
|
+
resolve(filePath);
|
|
933
|
+
}
|
|
934
|
+
});
|
|
935
|
+
} catch (error) {
|
|
936
|
+
reject(error);
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
function readFile(path) {
|
|
941
|
+
return fs.readFileSync(path);
|
|
942
|
+
}
|
|
943
|
+
function fetchFile(url) {
|
|
944
|
+
return new Promise((resolve, reject) => {
|
|
945
|
+
https.get(url, (resp) => {
|
|
946
|
+
const data = [];
|
|
947
|
+
const mimeType = resp.headers["content-type"];
|
|
948
|
+
resp.on("data", (chunk) => {
|
|
949
|
+
data.push(chunk);
|
|
950
|
+
});
|
|
951
|
+
resp.on("end", () => {
|
|
952
|
+
resolve({ buffer: Buffer.concat(data), mimeType });
|
|
953
|
+
});
|
|
954
|
+
}).on("error", (err) => {
|
|
955
|
+
reject(err);
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
const getFile = async (file) => {
|
|
960
|
+
return readFile(file);
|
|
961
|
+
};
|
|
962
|
+
const hash = (data, algorithm = "sha1") => {
|
|
963
|
+
return crypto$1.createHash(algorithm).update(data).digest("base64");
|
|
964
|
+
};
|
|
965
|
+
function getUnixTimestamp(date) {
|
|
966
|
+
return (new Date(date).getTime() / 1e3).toFixed(0);
|
|
967
|
+
}
|
|
968
|
+
function buildOperationSignatureParams({
|
|
969
|
+
documentId,
|
|
970
|
+
signer,
|
|
971
|
+
operation,
|
|
972
|
+
previousStateHash
|
|
973
|
+
}) {
|
|
974
|
+
const { timestamp, scope, id, type } = operation;
|
|
975
|
+
return [
|
|
976
|
+
getUnixTimestamp(timestamp),
|
|
977
|
+
// timestamp,
|
|
978
|
+
signer.app.key,
|
|
979
|
+
// signer public key
|
|
980
|
+
hash(
|
|
981
|
+
// hash (docID, scope, operationID, operationName, operationInput)
|
|
982
|
+
[documentId, scope, id, type, cjsModule(operation.input)].join(
|
|
983
|
+
""
|
|
984
|
+
)
|
|
985
|
+
),
|
|
986
|
+
previousStateHash
|
|
987
|
+
// state hash that the operation was applied to
|
|
988
|
+
];
|
|
989
|
+
}
|
|
990
|
+
const textEncode = new TextEncoder();
|
|
991
|
+
function buildOperationSignatureMessage(params) {
|
|
992
|
+
const message = params.join("");
|
|
993
|
+
const prefix = "Signed Operation:\n" + message.length.toString();
|
|
994
|
+
return textEncode.encode(prefix + message);
|
|
995
|
+
}
|
|
996
|
+
function ab2hex(ab) {
|
|
997
|
+
return Array.prototype.map.call(
|
|
998
|
+
new Uint8Array(ab),
|
|
999
|
+
(x) => ("00" + x.toString(16)).slice(-2)
|
|
1000
|
+
).join("");
|
|
1001
|
+
}
|
|
1002
|
+
function hex2ab(hex) {
|
|
1003
|
+
var _a;
|
|
1004
|
+
return new Uint8Array(
|
|
1005
|
+
((_a = hex.match(/[\da-f]{2}/gi)) == null ? void 0 : _a.map(function(h) {
|
|
1006
|
+
return parseInt(h, 16);
|
|
1007
|
+
})) ?? []
|
|
1008
|
+
);
|
|
1009
|
+
}
|
|
1010
|
+
async function buildOperationSignature(context, signMethod) {
|
|
1011
|
+
const params = buildOperationSignatureParams(context);
|
|
1012
|
+
const message = buildOperationSignatureMessage(params);
|
|
1013
|
+
const signature = await signMethod(message);
|
|
1014
|
+
return [...params, `0x${ab2hex(signature)}`];
|
|
1015
|
+
}
|
|
1016
|
+
async function buildSignedOperation(action, reducer, document, context, signHandler) {
|
|
1017
|
+
var _a, _b;
|
|
1018
|
+
const result = reducer(document, action, void 0, {
|
|
1019
|
+
reuseHash: true,
|
|
1020
|
+
reuseOperationResultingState: true
|
|
1021
|
+
});
|
|
1022
|
+
const operation = result.operations[action.scope].at(-1);
|
|
1023
|
+
if (!operation) {
|
|
1024
|
+
throw new Error("Action was not applied");
|
|
1025
|
+
}
|
|
1026
|
+
const previousStateHash = ((_a = result.operations[action.scope].at(-2)) == null ? void 0 : _a.hash) ?? "";
|
|
1027
|
+
const signature = await buildOperationSignature(
|
|
1028
|
+
{
|
|
1029
|
+
...context,
|
|
1030
|
+
operation,
|
|
1031
|
+
previousStateHash
|
|
1032
|
+
},
|
|
1033
|
+
signHandler
|
|
1034
|
+
);
|
|
1035
|
+
return {
|
|
1036
|
+
...operation,
|
|
1037
|
+
context: {
|
|
1038
|
+
...operation.context,
|
|
1039
|
+
signer: {
|
|
1040
|
+
...(_b = operation.context) == null ? void 0 : _b.signer,
|
|
1041
|
+
...context.signer,
|
|
1042
|
+
signatures: [...context.signer.signatures ?? [], signature]
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
async function verifyOperationSignature(signature, signer, verifyHandler) {
|
|
1048
|
+
const publicKey = signer.app.key;
|
|
1049
|
+
const params = signature.slice(0, 4);
|
|
1050
|
+
const signatureBytes = hex2ab(signature[4]);
|
|
1051
|
+
const expectedMessage = buildOperationSignatureMessage(params);
|
|
1052
|
+
return verifyHandler(publicKey, signatureBytes, expectedMessage);
|
|
1053
|
+
}
|
|
927
1054
|
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"] };
|
|
928
1055
|
Object.freeze(types);
|
|
929
1056
|
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
930
|
-
if (kind === "a" && !f)
|
|
931
|
-
|
|
932
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
933
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1057
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1058
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
934
1059
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
935
1060
|
};
|
|
936
1061
|
var _Mime_extensionToType, _Mime_typeToExtension, _Mime_typeToExtensions;
|
|
@@ -1013,48 +1138,6 @@ class Mime {
|
|
|
1013
1138
|
}
|
|
1014
1139
|
_Mime_extensionToType = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtension = /* @__PURE__ */ new WeakMap(), _Mime_typeToExtensions = /* @__PURE__ */ new WeakMap();
|
|
1015
1140
|
const mime = new Mime(types)._freeze();
|
|
1016
|
-
function writeFile(path, name, data) {
|
|
1017
|
-
const filePath = join(path, name);
|
|
1018
|
-
fs.mkdirSync(path, { recursive: true });
|
|
1019
|
-
return new Promise((resolve, reject) => {
|
|
1020
|
-
try {
|
|
1021
|
-
fs.writeFile(filePath, data, {}, (err) => {
|
|
1022
|
-
if (err) {
|
|
1023
|
-
reject(err);
|
|
1024
|
-
} else {
|
|
1025
|
-
resolve(filePath);
|
|
1026
|
-
}
|
|
1027
|
-
});
|
|
1028
|
-
} catch (error) {
|
|
1029
|
-
reject(error);
|
|
1030
|
-
}
|
|
1031
|
-
});
|
|
1032
|
-
}
|
|
1033
|
-
function readFile(path) {
|
|
1034
|
-
return fs.readFileSync(path);
|
|
1035
|
-
}
|
|
1036
|
-
function fetchFile(url) {
|
|
1037
|
-
return new Promise((resolve, reject) => {
|
|
1038
|
-
https.get(url, (resp) => {
|
|
1039
|
-
const data = [];
|
|
1040
|
-
const mimeType = resp.headers["content-type"];
|
|
1041
|
-
resp.on("data", (chunk) => {
|
|
1042
|
-
data.push(chunk);
|
|
1043
|
-
});
|
|
1044
|
-
resp.on("end", () => {
|
|
1045
|
-
resolve({ buffer: Buffer.concat(data), mimeType });
|
|
1046
|
-
});
|
|
1047
|
-
}).on("error", (err) => {
|
|
1048
|
-
reject(err);
|
|
1049
|
-
});
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
const getFile = async (file) => {
|
|
1053
|
-
return readFile(file);
|
|
1054
|
-
};
|
|
1055
|
-
const hash = (data, algorithm = "sha1") => {
|
|
1056
|
-
return crypto$1.createHash(algorithm).update(data).digest("base64");
|
|
1057
|
-
};
|
|
1058
1141
|
function validateOperations(operations) {
|
|
1059
1142
|
const errors = [];
|
|
1060
1143
|
const scopes = Object.keys(operations);
|
|
@@ -1124,8 +1207,7 @@ function garbageCollect(sortedOperations) {
|
|
|
1124
1207
|
function addUndo(sortedOperations) {
|
|
1125
1208
|
const operationsCopy = [...sortedOperations];
|
|
1126
1209
|
const latestOperation = operationsCopy[operationsCopy.length - 1];
|
|
1127
|
-
if (!latestOperation)
|
|
1128
|
-
return operationsCopy;
|
|
1210
|
+
if (!latestOperation) return operationsCopy;
|
|
1129
1211
|
if (latestOperation.type === "NOOP") {
|
|
1130
1212
|
operationsCopy.push({
|
|
1131
1213
|
...latestOperation,
|
|
@@ -1597,7 +1679,7 @@ function updateOperations(document, action, skip = 0) {
|
|
|
1597
1679
|
nextIndex = action.index;
|
|
1598
1680
|
operationId = action.id;
|
|
1599
1681
|
} else {
|
|
1600
|
-
operationId = v4();
|
|
1682
|
+
operationId = "id" in action ? action.id : v4();
|
|
1601
1683
|
}
|
|
1602
1684
|
operations.push({
|
|
1603
1685
|
...action,
|
|
@@ -1645,8 +1727,7 @@ function processUndoRedo(document, action, skip) {
|
|
|
1645
1727
|
function processSkipOperation(document, action, customReducer, skipValue, reuseOperationResultingState = false, resultingStateParser = parseResultingState) {
|
|
1646
1728
|
const scope = action.scope;
|
|
1647
1729
|
const latestOperation = document.operations[scope].at(-1);
|
|
1648
|
-
if (!latestOperation)
|
|
1649
|
-
return document;
|
|
1730
|
+
if (!latestOperation) return document;
|
|
1650
1731
|
const documentOperations = garbageCollectDocumentOperations(
|
|
1651
1732
|
{
|
|
1652
1733
|
...document.operations,
|
|
@@ -2322,17 +2403,25 @@ function applyMixins(derivedCtor, constructors) {
|
|
|
2322
2403
|
});
|
|
2323
2404
|
}
|
|
2324
2405
|
export {
|
|
2325
|
-
|
|
2406
|
+
isNoopOperation as A,
|
|
2326
2407
|
BaseDocument as B,
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
|
|
2408
|
+
isSameDocument as C,
|
|
2409
|
+
isUndoRedo as D,
|
|
2410
|
+
mapSkippedOperations as E,
|
|
2411
|
+
parseResultingState as F,
|
|
2412
|
+
readOnly as G,
|
|
2413
|
+
replayDocument as H,
|
|
2414
|
+
replayOperations as I,
|
|
2415
|
+
sortMappedOperations as J,
|
|
2416
|
+
sortOperations as K,
|
|
2417
|
+
validateOperations as L,
|
|
2418
|
+
verifyOperationSignature as M,
|
|
2419
|
+
baseReducer as N,
|
|
2420
|
+
mutableBaseReducer as O,
|
|
2421
|
+
processUndoRedo as P,
|
|
2422
|
+
updateDocument as Q,
|
|
2423
|
+
updateHeader as R,
|
|
2424
|
+
zod as S,
|
|
2336
2425
|
createExtendedState as a,
|
|
2337
2426
|
createDocument as b,
|
|
2338
2427
|
createReducer as c,
|
|
@@ -2342,22 +2431,22 @@ export {
|
|
|
2342
2431
|
applyMixins as g,
|
|
2343
2432
|
BaseActions as h,
|
|
2344
2433
|
isBaseAction as i,
|
|
2345
|
-
|
|
2346
|
-
|
|
2434
|
+
ab2hex as j,
|
|
2435
|
+
buildOperationSignature as k,
|
|
2347
2436
|
loadFromFile as l,
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2437
|
+
buildOperationSignatureMessage as m,
|
|
2438
|
+
buildOperationSignatureParams as n,
|
|
2439
|
+
buildSignedOperation as o,
|
|
2440
|
+
calculateSkipsLeft as p,
|
|
2441
|
+
createUnsafeReducer as q,
|
|
2442
|
+
createZip as r,
|
|
2354
2443
|
saveToFile as s,
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2444
|
+
documentHelpers as t,
|
|
2445
|
+
getLocalFile as u,
|
|
2446
|
+
getRemoteFile as v,
|
|
2447
|
+
getUnixTimestamp as w,
|
|
2448
|
+
hashDocument as x,
|
|
2449
|
+
hashKey as y,
|
|
2450
|
+
hex2ab as z
|
|
2362
2451
|
};
|
|
2363
|
-
//# sourceMappingURL=object-
|
|
2452
|
+
//# sourceMappingURL=object-VZ_AS47_.js.map
|