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