document-model 2.7.0 → 2.8.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 (51) hide show
  1. package/dist/browser/cjs/document-model.js +2 -2
  2. package/dist/browser/cjs/document.js +2 -2
  3. package/dist/browser/cjs/index.js +2 -2
  4. package/dist/{node/cjs/internal/index-D3g-pNfj.js → browser/cjs/internal/index-C1zE8gB2.js} +2 -2
  5. package/dist/browser/cjs/internal/index-C1zE8gB2.js.map +1 -0
  6. package/dist/browser/cjs/internal/{index-Bw5CBBzd.js → index-lPRldkww.js} +2 -2
  7. package/dist/browser/cjs/internal/{index-Bw5CBBzd.js.map → index-lPRldkww.js.map} +1 -1
  8. package/dist/browser/cjs/internal/{object--q7pfp1w.js → object-Cwxm4B8F.js} +514 -502
  9. package/dist/browser/cjs/internal/object-Cwxm4B8F.js.map +1 -0
  10. package/dist/browser/es/document-model.js +2 -2
  11. package/dist/browser/es/document.js +2 -2
  12. package/dist/browser/es/index.js +2 -2
  13. package/dist/browser/es/internal/{index-BxwF1TSy.js → index-D7g8OoD_.js} +2 -2
  14. package/dist/browser/es/internal/{index-BxwF1TSy.js.map → index-D7g8OoD_.js.map} +1 -1
  15. package/dist/browser/es/internal/{index-CAeTm1rC.js → index-DB3PHVmg.js} +2 -2
  16. package/dist/browser/es/internal/index-DB3PHVmg.js.map +1 -0
  17. package/dist/browser/es/internal/{object-Ce5PU4Jl.js → object-ivG479sP.js} +514 -502
  18. package/dist/browser/es/internal/object-ivG479sP.js.map +1 -0
  19. package/dist/browser/src/document/utils/crypto.d.ts +1 -1
  20. package/dist/browser/src/document/utils/node.d.ts +2 -2
  21. package/dist/browser/src/document-model/gen/schema/zod.d.ts +42 -42
  22. package/dist/node/cjs/document-model.js +2 -2
  23. package/dist/node/cjs/document.js +2 -2
  24. package/dist/node/cjs/index.js +2 -2
  25. package/dist/node/cjs/internal/{index-DN4JFG8x.js → index-5zAjb9ey.js} +2 -2
  26. package/dist/node/cjs/internal/{index-DN4JFG8x.js.map → index-5zAjb9ey.js.map} +1 -1
  27. package/dist/{browser/cjs/internal/index-D4hLw2sB.js → node/cjs/internal/index-Dsv6Zoey.js} +2 -2
  28. package/dist/node/cjs/internal/index-Dsv6Zoey.js.map +1 -0
  29. package/dist/node/cjs/internal/{object-BQxrSeG7.js → object-DgmfygmD.js} +511 -499
  30. package/dist/node/cjs/internal/object-DgmfygmD.js.map +1 -0
  31. package/dist/node/es/document-model.js +2 -2
  32. package/dist/node/es/document.js +2 -2
  33. package/dist/node/es/index.js +2 -2
  34. package/dist/node/es/internal/{index-BFweBcJ_.js → index-CA0xV5XL.js} +2 -2
  35. package/dist/node/es/internal/index-CA0xV5XL.js.map +1 -0
  36. package/dist/node/es/internal/{index-DqBMm_QB.js → index-CmgkUOei.js} +2 -2
  37. package/dist/node/es/internal/{index-DqBMm_QB.js.map → index-CmgkUOei.js.map} +1 -1
  38. package/dist/node/es/internal/{object-BFAL5P1X.js → object-890lc6IO.js} +511 -499
  39. package/dist/node/es/internal/object-890lc6IO.js.map +1 -0
  40. package/dist/node/src/document/utils/crypto.d.ts +1 -1
  41. package/dist/node/src/document/utils/node.d.ts +2 -2
  42. package/dist/node/src/document-model/gen/schema/zod.d.ts +42 -42
  43. package/package.json +9 -9
  44. package/dist/browser/cjs/internal/index-D4hLw2sB.js.map +0 -1
  45. package/dist/browser/cjs/internal/object--q7pfp1w.js.map +0 -1
  46. package/dist/browser/es/internal/index-CAeTm1rC.js.map +0 -1
  47. package/dist/browser/es/internal/object-Ce5PU4Jl.js.map +0 -1
  48. package/dist/node/cjs/internal/index-D3g-pNfj.js.map +0 -1
  49. package/dist/node/cjs/internal/object-BQxrSeG7.js.map +0 -1
  50. package/dist/node/es/internal/index-BFweBcJ_.js.map +0 -1
  51. package/dist/node/es/internal/object-BFAL5P1X.js.map +0 -1
@@ -149,594 +149,604 @@ function getDefaultExportFromCjs(x) {
149
149
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
150
150
  }
151
151
  var safeStableStringify = { exports: {} };
152
- (function(module2, exports2) {
153
- const { hasOwnProperty } = Object.prototype;
154
- const stringify = configure();
155
- stringify.configure = configure;
156
- stringify.stringify = stringify;
157
- stringify.default = stringify;
158
- exports2.stringify = stringify;
159
- exports2.configure = configure;
160
- module2.exports = stringify;
161
- const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
162
- function strEscape(str) {
163
- if (str.length < 5e3 && !strEscapeSequencesRegExp.test(str)) {
164
- return `"${str}"`;
165
- }
166
- return JSON.stringify(str);
167
- }
168
- function sort(array, comparator) {
169
- if (array.length > 200 || comparator) {
170
- return array.sort(comparator);
152
+ var hasRequiredSafeStableStringify;
153
+ function requireSafeStableStringify() {
154
+ if (hasRequiredSafeStableStringify) return safeStableStringify.exports;
155
+ hasRequiredSafeStableStringify = 1;
156
+ (function(module2, exports2) {
157
+ const { hasOwnProperty } = Object.prototype;
158
+ const stringify = configure();
159
+ stringify.configure = configure;
160
+ stringify.stringify = stringify;
161
+ stringify.default = stringify;
162
+ exports2.stringify = stringify;
163
+ exports2.configure = configure;
164
+ module2.exports = stringify;
165
+ const strEscapeSequencesRegExp = /[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;
166
+ function strEscape(str) {
167
+ if (str.length < 5e3 && !strEscapeSequencesRegExp.test(str)) {
168
+ return `"${str}"`;
169
+ }
170
+ return JSON.stringify(str);
171
171
  }
172
- for (let i = 1; i < array.length; i++) {
173
- const currentValue = array[i];
174
- let position = i;
175
- while (position !== 0 && array[position - 1] > currentValue) {
176
- array[position] = array[position - 1];
177
- position--;
172
+ function sort(array, comparator) {
173
+ if (array.length > 200 || comparator) {
174
+ return array.sort(comparator);
175
+ }
176
+ for (let i = 1; i < array.length; i++) {
177
+ const currentValue = array[i];
178
+ let position = i;
179
+ while (position !== 0 && array[position - 1] > currentValue) {
180
+ array[position] = array[position - 1];
181
+ position--;
182
+ }
183
+ array[position] = currentValue;
178
184
  }
179
- array[position] = currentValue;
185
+ return array;
180
186
  }
181
- return array;
182
- }
183
- const typedArrayPrototypeGetSymbolToStringTag = Object.getOwnPropertyDescriptor(
184
- Object.getPrototypeOf(
187
+ const typedArrayPrototypeGetSymbolToStringTag = Object.getOwnPropertyDescriptor(
185
188
  Object.getPrototypeOf(
186
- new Int8Array()
187
- )
188
- ),
189
- Symbol.toStringTag
190
- ).get;
191
- function isTypedArrayWithEntries(value) {
192
- return typedArrayPrototypeGetSymbolToStringTag.call(value) !== void 0 && value.length !== 0;
193
- }
194
- function stringifyTypedArray(array, separator, maximumBreadth) {
195
- if (array.length < maximumBreadth) {
196
- maximumBreadth = array.length;
197
- }
198
- const whitespace = separator === "," ? "" : " ";
199
- let res = `"0":${whitespace}${array[0]}`;
200
- for (let i = 1; i < maximumBreadth; i++) {
201
- res += `${separator}"${i}":${whitespace}${array[i]}`;
189
+ Object.getPrototypeOf(
190
+ new Int8Array()
191
+ )
192
+ ),
193
+ Symbol.toStringTag
194
+ ).get;
195
+ function isTypedArrayWithEntries(value) {
196
+ return typedArrayPrototypeGetSymbolToStringTag.call(value) !== void 0 && value.length !== 0;
202
197
  }
203
- return res;
204
- }
205
- function getCircularValueOption(options) {
206
- if (hasOwnProperty.call(options, "circularValue")) {
207
- const circularValue = options.circularValue;
208
- if (typeof circularValue === "string") {
209
- return `"${circularValue}"`;
198
+ function stringifyTypedArray(array, separator, maximumBreadth) {
199
+ if (array.length < maximumBreadth) {
200
+ maximumBreadth = array.length;
210
201
  }
211
- if (circularValue == null) {
212
- return circularValue;
202
+ const whitespace = separator === "," ? "" : " ";
203
+ let res = `"0":${whitespace}${array[0]}`;
204
+ for (let i = 1; i < maximumBreadth; i++) {
205
+ res += `${separator}"${i}":${whitespace}${array[i]}`;
213
206
  }
214
- if (circularValue === Error || circularValue === TypeError) {
215
- return {
216
- toString() {
217
- throw new TypeError("Converting circular structure to JSON");
218
- }
219
- };
220
- }
221
- throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
207
+ return res;
222
208
  }
223
- return '"[Circular]"';
224
- }
225
- function getDeterministicOption(options) {
226
- let value;
227
- if (hasOwnProperty.call(options, "deterministic")) {
228
- value = options.deterministic;
229
- if (typeof value !== "boolean" && typeof value !== "function") {
230
- throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');
209
+ function getCircularValueOption(options) {
210
+ if (hasOwnProperty.call(options, "circularValue")) {
211
+ const circularValue = options.circularValue;
212
+ if (typeof circularValue === "string") {
213
+ return `"${circularValue}"`;
214
+ }
215
+ if (circularValue == null) {
216
+ return circularValue;
217
+ }
218
+ if (circularValue === Error || circularValue === TypeError) {
219
+ return {
220
+ toString() {
221
+ throw new TypeError("Converting circular structure to JSON");
222
+ }
223
+ };
224
+ }
225
+ throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined');
231
226
  }
227
+ return '"[Circular]"';
232
228
  }
233
- return value === void 0 ? true : value;
234
- }
235
- function getBooleanOption(options, key) {
236
- let value;
237
- if (hasOwnProperty.call(options, key)) {
238
- value = options[key];
239
- if (typeof value !== "boolean") {
240
- throw new TypeError(`The "${key}" argument must be of type boolean`);
229
+ function getDeterministicOption(options) {
230
+ let value;
231
+ if (hasOwnProperty.call(options, "deterministic")) {
232
+ value = options.deterministic;
233
+ if (typeof value !== "boolean" && typeof value !== "function") {
234
+ throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');
235
+ }
241
236
  }
237
+ return value === void 0 ? true : value;
242
238
  }
243
- return value === void 0 ? true : value;
244
- }
245
- function getPositiveIntegerOption(options, key) {
246
- let value;
247
- if (hasOwnProperty.call(options, key)) {
248
- value = options[key];
249
- if (typeof value !== "number") {
250
- throw new TypeError(`The "${key}" argument must be of type number`);
251
- }
252
- if (!Number.isInteger(value)) {
253
- throw new TypeError(`The "${key}" argument must be an integer`);
254
- }
255
- if (value < 1) {
256
- throw new RangeError(`The "${key}" argument must be >= 1`);
239
+ function getBooleanOption(options, key) {
240
+ let value;
241
+ if (hasOwnProperty.call(options, key)) {
242
+ value = options[key];
243
+ if (typeof value !== "boolean") {
244
+ throw new TypeError(`The "${key}" argument must be of type boolean`);
245
+ }
257
246
  }
247
+ return value === void 0 ? true : value;
258
248
  }
259
- return value === void 0 ? Infinity : value;
260
- }
261
- function getItemCount(number) {
262
- if (number === 1) {
263
- return "1 item";
264
- }
265
- return `${number} items`;
266
- }
267
- function getUniqueReplacerSet(replacerArray) {
268
- const replacerSet = /* @__PURE__ */ new Set();
269
- for (const value of replacerArray) {
270
- if (typeof value === "string" || typeof value === "number") {
271
- replacerSet.add(String(value));
249
+ function getPositiveIntegerOption(options, key) {
250
+ let value;
251
+ if (hasOwnProperty.call(options, key)) {
252
+ value = options[key];
253
+ if (typeof value !== "number") {
254
+ throw new TypeError(`The "${key}" argument must be of type number`);
255
+ }
256
+ if (!Number.isInteger(value)) {
257
+ throw new TypeError(`The "${key}" argument must be an integer`);
258
+ }
259
+ if (value < 1) {
260
+ throw new RangeError(`The "${key}" argument must be >= 1`);
261
+ }
272
262
  }
263
+ return value === void 0 ? Infinity : value;
273
264
  }
274
- return replacerSet;
275
- }
276
- function getStrictOption(options) {
277
- if (hasOwnProperty.call(options, "strict")) {
278
- const value = options.strict;
279
- if (typeof value !== "boolean") {
280
- throw new TypeError('The "strict" argument must be of type boolean');
281
- }
282
- if (value) {
283
- return (value2) => {
284
- let message = `Object can not safely be stringified. Received type ${typeof value2}`;
285
- if (typeof value2 !== "function") message += ` (${value2.toString()})`;
286
- throw new Error(message);
287
- };
265
+ function getItemCount(number) {
266
+ if (number === 1) {
267
+ return "1 item";
288
268
  }
269
+ return `${number} items`;
289
270
  }
290
- }
291
- function configure(options) {
292
- options = { ...options };
293
- const fail = getStrictOption(options);
294
- if (fail) {
295
- if (options.bigint === void 0) {
296
- options.bigint = false;
271
+ function getUniqueReplacerSet(replacerArray) {
272
+ const replacerSet = /* @__PURE__ */ new Set();
273
+ for (const value of replacerArray) {
274
+ if (typeof value === "string" || typeof value === "number") {
275
+ replacerSet.add(String(value));
276
+ }
297
277
  }
298
- if (!("circularValue" in options)) {
299
- options.circularValue = Error;
278
+ return replacerSet;
279
+ }
280
+ function getStrictOption(options) {
281
+ if (hasOwnProperty.call(options, "strict")) {
282
+ const value = options.strict;
283
+ if (typeof value !== "boolean") {
284
+ throw new TypeError('The "strict" argument must be of type boolean');
285
+ }
286
+ if (value) {
287
+ return (value2) => {
288
+ let message = `Object can not safely be stringified. Received type ${typeof value2}`;
289
+ if (typeof value2 !== "function") message += ` (${value2.toString()})`;
290
+ throw new Error(message);
291
+ };
292
+ }
300
293
  }
301
294
  }
302
- const circularValue = getCircularValueOption(options);
303
- const bigint = getBooleanOption(options, "bigint");
304
- const deterministic = getDeterministicOption(options);
305
- const comparator = typeof deterministic === "function" ? deterministic : void 0;
306
- const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
307
- const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
308
- function stringifyFnReplacer(key, parent, stack, replacer, spacer, indentation) {
309
- let value = parent[key];
310
- if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
311
- value = value.toJSON(key);
295
+ function configure(options) {
296
+ options = { ...options };
297
+ const fail = getStrictOption(options);
298
+ if (fail) {
299
+ if (options.bigint === void 0) {
300
+ options.bigint = false;
301
+ }
302
+ if (!("circularValue" in options)) {
303
+ options.circularValue = Error;
304
+ }
312
305
  }
313
- value = replacer.call(parent, key, value);
314
- switch (typeof value) {
315
- case "string":
316
- return strEscape(value);
317
- case "object": {
318
- if (value === null) {
319
- return "null";
320
- }
321
- if (stack.indexOf(value) !== -1) {
322
- return circularValue;
323
- }
324
- let res = "";
325
- let join = ",";
326
- const originalIndentation = indentation;
327
- if (Array.isArray(value)) {
328
- if (value.length === 0) {
329
- return "[]";
306
+ const circularValue = getCircularValueOption(options);
307
+ const bigint = getBooleanOption(options, "bigint");
308
+ const deterministic = getDeterministicOption(options);
309
+ const comparator = typeof deterministic === "function" ? deterministic : void 0;
310
+ const maximumDepth = getPositiveIntegerOption(options, "maximumDepth");
311
+ const maximumBreadth = getPositiveIntegerOption(options, "maximumBreadth");
312
+ function stringifyFnReplacer(key, parent, stack, replacer, spacer, indentation) {
313
+ let value = parent[key];
314
+ if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
315
+ value = value.toJSON(key);
316
+ }
317
+ value = replacer.call(parent, key, value);
318
+ switch (typeof value) {
319
+ case "string":
320
+ return strEscape(value);
321
+ case "object": {
322
+ if (value === null) {
323
+ return "null";
324
+ }
325
+ if (stack.indexOf(value) !== -1) {
326
+ return circularValue;
327
+ }
328
+ let res = "";
329
+ let join = ",";
330
+ const originalIndentation = indentation;
331
+ if (Array.isArray(value)) {
332
+ if (value.length === 0) {
333
+ return "[]";
334
+ }
335
+ if (maximumDepth < stack.length + 1) {
336
+ return '"[Array]"';
337
+ }
338
+ stack.push(value);
339
+ if (spacer !== "") {
340
+ indentation += spacer;
341
+ res += `
342
+ ${indentation}`;
343
+ join = `,
344
+ ${indentation}`;
345
+ }
346
+ const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
347
+ let i = 0;
348
+ for (; i < maximumValuesToStringify - 1; i++) {
349
+ const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
350
+ res += tmp2 !== void 0 ? tmp2 : "null";
351
+ res += join;
352
+ }
353
+ const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
354
+ res += tmp !== void 0 ? tmp : "null";
355
+ if (value.length - 1 > maximumBreadth) {
356
+ const removedKeys = value.length - maximumBreadth - 1;
357
+ res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
358
+ }
359
+ if (spacer !== "") {
360
+ res += `
361
+ ${originalIndentation}`;
362
+ }
363
+ stack.pop();
364
+ return `[${res}]`;
365
+ }
366
+ let keys = Object.keys(value);
367
+ const keyLength = keys.length;
368
+ if (keyLength === 0) {
369
+ return "{}";
330
370
  }
331
371
  if (maximumDepth < stack.length + 1) {
332
- return '"[Array]"';
372
+ return '"[Object]"';
333
373
  }
334
- stack.push(value);
374
+ let whitespace = "";
375
+ let separator = "";
335
376
  if (spacer !== "") {
336
377
  indentation += spacer;
337
- res += `
338
- ${indentation}`;
339
378
  join = `,
340
379
  ${indentation}`;
380
+ whitespace = " ";
341
381
  }
342
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
343
- let i = 0;
344
- for (; i < maximumValuesToStringify - 1; i++) {
345
- const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
346
- res += tmp2 !== void 0 ? tmp2 : "null";
347
- res += join;
348
- }
349
- const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
350
- res += tmp !== void 0 ? tmp : "null";
351
- if (value.length - 1 > maximumBreadth) {
352
- const removedKeys = value.length - maximumBreadth - 1;
353
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
382
+ const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
383
+ if (deterministic && !isTypedArrayWithEntries(value)) {
384
+ keys = sort(keys, comparator);
354
385
  }
355
- if (spacer !== "") {
356
- res += `
357
- ${originalIndentation}`;
386
+ stack.push(value);
387
+ for (let i = 0; i < maximumPropertiesToStringify; i++) {
388
+ const key2 = keys[i];
389
+ const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
390
+ if (tmp !== void 0) {
391
+ res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
392
+ separator = join;
393
+ }
358
394
  }
359
- stack.pop();
360
- return `[${res}]`;
361
- }
362
- let keys = Object.keys(value);
363
- const keyLength = keys.length;
364
- if (keyLength === 0) {
365
- return "{}";
366
- }
367
- if (maximumDepth < stack.length + 1) {
368
- return '"[Object]"';
369
- }
370
- let whitespace = "";
371
- let separator = "";
372
- if (spacer !== "") {
373
- indentation += spacer;
374
- join = `,
375
- ${indentation}`;
376
- whitespace = " ";
377
- }
378
- const maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
379
- if (deterministic && !isTypedArrayWithEntries(value)) {
380
- keys = sort(keys, comparator);
381
- }
382
- stack.push(value);
383
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
384
- const key2 = keys[i];
385
- const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
386
- if (tmp !== void 0) {
387
- res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
395
+ if (keyLength > maximumBreadth) {
396
+ const removedKeys = keyLength - maximumBreadth;
397
+ res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
388
398
  separator = join;
389
399
  }
390
- }
391
- if (keyLength > maximumBreadth) {
392
- const removedKeys = keyLength - maximumBreadth;
393
- res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
394
- separator = join;
395
- }
396
- if (spacer !== "" && separator.length > 1) {
397
- res = `
400
+ if (spacer !== "" && separator.length > 1) {
401
+ res = `
398
402
  ${indentation}${res}
399
403
  ${originalIndentation}`;
404
+ }
405
+ stack.pop();
406
+ return `{${res}}`;
400
407
  }
401
- stack.pop();
402
- return `{${res}}`;
408
+ case "number":
409
+ return isFinite(value) ? String(value) : fail ? fail(value) : "null";
410
+ case "boolean":
411
+ return value === true ? "true" : "false";
412
+ case "undefined":
413
+ return void 0;
414
+ case "bigint":
415
+ if (bigint) {
416
+ return String(value);
417
+ }
418
+ // fallthrough
419
+ default:
420
+ return fail ? fail(value) : void 0;
403
421
  }
404
- case "number":
405
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
406
- case "boolean":
407
- return value === true ? "true" : "false";
408
- case "undefined":
409
- return void 0;
410
- case "bigint":
411
- if (bigint) {
412
- return String(value);
413
- }
414
- default:
415
- return fail ? fail(value) : void 0;
416
- }
417
- }
418
- function stringifyArrayReplacer(key, value, stack, replacer, spacer, indentation) {
419
- if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
420
- value = value.toJSON(key);
421
422
  }
422
- switch (typeof value) {
423
- case "string":
424
- return strEscape(value);
425
- case "object": {
426
- if (value === null) {
427
- return "null";
428
- }
429
- if (stack.indexOf(value) !== -1) {
430
- return circularValue;
431
- }
432
- const originalIndentation = indentation;
433
- let res = "";
434
- let join = ",";
435
- if (Array.isArray(value)) {
436
- if (value.length === 0) {
437
- return "[]";
423
+ function stringifyArrayReplacer(key, value, stack, replacer, spacer, indentation) {
424
+ if (typeof value === "object" && value !== null && typeof value.toJSON === "function") {
425
+ value = value.toJSON(key);
426
+ }
427
+ switch (typeof value) {
428
+ case "string":
429
+ return strEscape(value);
430
+ case "object": {
431
+ if (value === null) {
432
+ return "null";
438
433
  }
439
- if (maximumDepth < stack.length + 1) {
440
- return '"[Array]"';
434
+ if (stack.indexOf(value) !== -1) {
435
+ return circularValue;
436
+ }
437
+ const originalIndentation = indentation;
438
+ let res = "";
439
+ let join = ",";
440
+ if (Array.isArray(value)) {
441
+ if (value.length === 0) {
442
+ return "[]";
443
+ }
444
+ if (maximumDepth < stack.length + 1) {
445
+ return '"[Array]"';
446
+ }
447
+ stack.push(value);
448
+ if (spacer !== "") {
449
+ indentation += spacer;
450
+ res += `
451
+ ${indentation}`;
452
+ join = `,
453
+ ${indentation}`;
454
+ }
455
+ const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
456
+ let i = 0;
457
+ for (; i < maximumValuesToStringify - 1; i++) {
458
+ const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
459
+ res += tmp2 !== void 0 ? tmp2 : "null";
460
+ res += join;
461
+ }
462
+ const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
463
+ res += tmp !== void 0 ? tmp : "null";
464
+ if (value.length - 1 > maximumBreadth) {
465
+ const removedKeys = value.length - maximumBreadth - 1;
466
+ res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
467
+ }
468
+ if (spacer !== "") {
469
+ res += `
470
+ ${originalIndentation}`;
471
+ }
472
+ stack.pop();
473
+ return `[${res}]`;
441
474
  }
442
475
  stack.push(value);
476
+ let whitespace = "";
443
477
  if (spacer !== "") {
444
478
  indentation += spacer;
445
- res += `
446
- ${indentation}`;
447
479
  join = `,
448
480
  ${indentation}`;
481
+ whitespace = " ";
449
482
  }
450
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
451
- let i = 0;
452
- for (; i < maximumValuesToStringify - 1; i++) {
453
- const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
454
- res += tmp2 !== void 0 ? tmp2 : "null";
455
- res += join;
483
+ let separator = "";
484
+ for (const key2 of replacer) {
485
+ const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
486
+ if (tmp !== void 0) {
487
+ res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
488
+ separator = join;
489
+ }
456
490
  }
457
- const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
458
- res += tmp !== void 0 ? tmp : "null";
459
- if (value.length - 1 > maximumBreadth) {
460
- const removedKeys = value.length - maximumBreadth - 1;
461
- res += `${join}"... ${getItemCount(removedKeys)} not stringified"`;
462
- }
463
- if (spacer !== "") {
464
- res += `
491
+ if (spacer !== "" && separator.length > 1) {
492
+ res = `
493
+ ${indentation}${res}
465
494
  ${originalIndentation}`;
466
495
  }
467
496
  stack.pop();
468
- return `[${res}]`;
497
+ return `{${res}}`;
469
498
  }
470
- stack.push(value);
471
- let whitespace = "";
472
- if (spacer !== "") {
473
- indentation += spacer;
474
- join = `,
475
- ${indentation}`;
476
- whitespace = " ";
477
- }
478
- let separator = "";
479
- for (const key2 of replacer) {
480
- const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
481
- if (tmp !== void 0) {
482
- res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
483
- separator = join;
499
+ case "number":
500
+ return isFinite(value) ? String(value) : fail ? fail(value) : "null";
501
+ case "boolean":
502
+ return value === true ? "true" : "false";
503
+ case "undefined":
504
+ return void 0;
505
+ case "bigint":
506
+ if (bigint) {
507
+ return String(value);
484
508
  }
485
- }
486
- if (spacer !== "" && separator.length > 1) {
487
- res = `
488
- ${indentation}${res}
489
- ${originalIndentation}`;
490
- }
491
- stack.pop();
492
- return `{${res}}`;
509
+ // fallthrough
510
+ default:
511
+ return fail ? fail(value) : void 0;
493
512
  }
494
- case "number":
495
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
496
- case "boolean":
497
- return value === true ? "true" : "false";
498
- case "undefined":
499
- return void 0;
500
- case "bigint":
501
- if (bigint) {
502
- return String(value);
503
- }
504
- default:
505
- return fail ? fail(value) : void 0;
506
513
  }
507
- }
508
- function stringifyIndent(key, value, stack, spacer, indentation) {
509
- switch (typeof value) {
510
- case "string":
511
- return strEscape(value);
512
- case "object": {
513
- if (value === null) {
514
- return "null";
515
- }
516
- if (typeof value.toJSON === "function") {
517
- value = value.toJSON(key);
518
- if (typeof value !== "object") {
519
- return stringifyIndent(key, value, stack, spacer, indentation);
520
- }
514
+ function stringifyIndent(key, value, stack, spacer, indentation) {
515
+ switch (typeof value) {
516
+ case "string":
517
+ return strEscape(value);
518
+ case "object": {
521
519
  if (value === null) {
522
520
  return "null";
523
521
  }
524
- }
525
- if (stack.indexOf(value) !== -1) {
526
- return circularValue;
527
- }
528
- const originalIndentation = indentation;
529
- if (Array.isArray(value)) {
530
- if (value.length === 0) {
531
- return "[]";
522
+ if (typeof value.toJSON === "function") {
523
+ value = value.toJSON(key);
524
+ if (typeof value !== "object") {
525
+ return stringifyIndent(key, value, stack, spacer, indentation);
526
+ }
527
+ if (value === null) {
528
+ return "null";
529
+ }
532
530
  }
533
- if (maximumDepth < stack.length + 1) {
534
- return '"[Array]"';
531
+ if (stack.indexOf(value) !== -1) {
532
+ return circularValue;
535
533
  }
536
- stack.push(value);
537
- indentation += spacer;
538
- let res2 = `
534
+ const originalIndentation = indentation;
535
+ if (Array.isArray(value)) {
536
+ if (value.length === 0) {
537
+ return "[]";
538
+ }
539
+ if (maximumDepth < stack.length + 1) {
540
+ return '"[Array]"';
541
+ }
542
+ stack.push(value);
543
+ indentation += spacer;
544
+ let res2 = `
539
545
  ${indentation}`;
540
- const join2 = `,
546
+ const join2 = `,
541
547
  ${indentation}`;
542
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
543
- let i = 0;
544
- for (; i < maximumValuesToStringify - 1; i++) {
545
- const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
546
- res2 += tmp2 !== void 0 ? tmp2 : "null";
547
- res2 += join2;
548
+ const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
549
+ let i = 0;
550
+ for (; i < maximumValuesToStringify - 1; i++) {
551
+ const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
552
+ res2 += tmp2 !== void 0 ? tmp2 : "null";
553
+ res2 += join2;
554
+ }
555
+ const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
556
+ res2 += tmp !== void 0 ? tmp : "null";
557
+ if (value.length - 1 > maximumBreadth) {
558
+ const removedKeys = value.length - maximumBreadth - 1;
559
+ res2 += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
560
+ }
561
+ res2 += `
562
+ ${originalIndentation}`;
563
+ stack.pop();
564
+ return `[${res2}]`;
548
565
  }
549
- const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
550
- res2 += tmp !== void 0 ? tmp : "null";
551
- if (value.length - 1 > maximumBreadth) {
552
- const removedKeys = value.length - maximumBreadth - 1;
553
- res2 += `${join2}"... ${getItemCount(removedKeys)} not stringified"`;
566
+ let keys = Object.keys(value);
567
+ const keyLength = keys.length;
568
+ if (keyLength === 0) {
569
+ return "{}";
554
570
  }
555
- res2 += `
556
- ${originalIndentation}`;
557
- stack.pop();
558
- return `[${res2}]`;
559
- }
560
- let keys = Object.keys(value);
561
- const keyLength = keys.length;
562
- if (keyLength === 0) {
563
- return "{}";
564
- }
565
- if (maximumDepth < stack.length + 1) {
566
- return '"[Object]"';
567
- }
568
- indentation += spacer;
569
- const join = `,
571
+ if (maximumDepth < stack.length + 1) {
572
+ return '"[Object]"';
573
+ }
574
+ indentation += spacer;
575
+ const join = `,
570
576
  ${indentation}`;
571
- let res = "";
572
- let separator = "";
573
- let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
574
- if (isTypedArrayWithEntries(value)) {
575
- res += stringifyTypedArray(value, join, maximumBreadth);
576
- keys = keys.slice(value.length);
577
- maximumPropertiesToStringify -= value.length;
578
- separator = join;
579
- }
580
- if (deterministic) {
581
- keys = sort(keys, comparator);
582
- }
583
- stack.push(value);
584
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
585
- const key2 = keys[i];
586
- const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
587
- if (tmp !== void 0) {
588
- res += `${separator}${strEscape(key2)}: ${tmp}`;
577
+ let res = "";
578
+ let separator = "";
579
+ let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
580
+ if (isTypedArrayWithEntries(value)) {
581
+ res += stringifyTypedArray(value, join, maximumBreadth);
582
+ keys = keys.slice(value.length);
583
+ maximumPropertiesToStringify -= value.length;
589
584
  separator = join;
590
585
  }
591
- }
592
- if (keyLength > maximumBreadth) {
593
- const removedKeys = keyLength - maximumBreadth;
594
- res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
595
- separator = join;
596
- }
597
- if (separator !== "") {
598
- res = `
586
+ if (deterministic) {
587
+ keys = sort(keys, comparator);
588
+ }
589
+ stack.push(value);
590
+ for (let i = 0; i < maximumPropertiesToStringify; i++) {
591
+ const key2 = keys[i];
592
+ const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
593
+ if (tmp !== void 0) {
594
+ res += `${separator}${strEscape(key2)}: ${tmp}`;
595
+ separator = join;
596
+ }
597
+ }
598
+ if (keyLength > maximumBreadth) {
599
+ const removedKeys = keyLength - maximumBreadth;
600
+ res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
601
+ separator = join;
602
+ }
603
+ if (separator !== "") {
604
+ res = `
599
605
  ${indentation}${res}
600
606
  ${originalIndentation}`;
607
+ }
608
+ stack.pop();
609
+ return `{${res}}`;
601
610
  }
602
- stack.pop();
603
- return `{${res}}`;
611
+ case "number":
612
+ return isFinite(value) ? String(value) : fail ? fail(value) : "null";
613
+ case "boolean":
614
+ return value === true ? "true" : "false";
615
+ case "undefined":
616
+ return void 0;
617
+ case "bigint":
618
+ if (bigint) {
619
+ return String(value);
620
+ }
621
+ // fallthrough
622
+ default:
623
+ return fail ? fail(value) : void 0;
604
624
  }
605
- case "number":
606
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
607
- case "boolean":
608
- return value === true ? "true" : "false";
609
- case "undefined":
610
- return void 0;
611
- case "bigint":
612
- if (bigint) {
613
- return String(value);
614
- }
615
- default:
616
- return fail ? fail(value) : void 0;
617
625
  }
618
- }
619
- function stringifySimple(key, value, stack) {
620
- switch (typeof value) {
621
- case "string":
622
- return strEscape(value);
623
- case "object": {
624
- if (value === null) {
625
- return "null";
626
- }
627
- if (typeof value.toJSON === "function") {
628
- value = value.toJSON(key);
629
- if (typeof value !== "object") {
630
- return stringifySimple(key, value, stack);
631
- }
626
+ function stringifySimple(key, value, stack) {
627
+ switch (typeof value) {
628
+ case "string":
629
+ return strEscape(value);
630
+ case "object": {
632
631
  if (value === null) {
633
632
  return "null";
634
633
  }
635
- }
636
- if (stack.indexOf(value) !== -1) {
637
- return circularValue;
638
- }
639
- let res = "";
640
- const hasLength = value.length !== void 0;
641
- if (hasLength && Array.isArray(value)) {
642
- if (value.length === 0) {
643
- return "[]";
634
+ if (typeof value.toJSON === "function") {
635
+ value = value.toJSON(key);
636
+ if (typeof value !== "object") {
637
+ return stringifySimple(key, value, stack);
638
+ }
639
+ if (value === null) {
640
+ return "null";
641
+ }
642
+ }
643
+ if (stack.indexOf(value) !== -1) {
644
+ return circularValue;
645
+ }
646
+ let res = "";
647
+ const hasLength = value.length !== void 0;
648
+ if (hasLength && Array.isArray(value)) {
649
+ if (value.length === 0) {
650
+ return "[]";
651
+ }
652
+ if (maximumDepth < stack.length + 1) {
653
+ return '"[Array]"';
654
+ }
655
+ stack.push(value);
656
+ const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
657
+ let i = 0;
658
+ for (; i < maximumValuesToStringify - 1; i++) {
659
+ const tmp2 = stringifySimple(String(i), value[i], stack);
660
+ res += tmp2 !== void 0 ? tmp2 : "null";
661
+ res += ",";
662
+ }
663
+ const tmp = stringifySimple(String(i), value[i], stack);
664
+ res += tmp !== void 0 ? tmp : "null";
665
+ if (value.length - 1 > maximumBreadth) {
666
+ const removedKeys = value.length - maximumBreadth - 1;
667
+ res += `,"... ${getItemCount(removedKeys)} not stringified"`;
668
+ }
669
+ stack.pop();
670
+ return `[${res}]`;
671
+ }
672
+ let keys = Object.keys(value);
673
+ const keyLength = keys.length;
674
+ if (keyLength === 0) {
675
+ return "{}";
644
676
  }
645
677
  if (maximumDepth < stack.length + 1) {
646
- return '"[Array]"';
678
+ return '"[Object]"';
679
+ }
680
+ let separator = "";
681
+ let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
682
+ if (hasLength && isTypedArrayWithEntries(value)) {
683
+ res += stringifyTypedArray(value, ",", maximumBreadth);
684
+ keys = keys.slice(value.length);
685
+ maximumPropertiesToStringify -= value.length;
686
+ separator = ",";
687
+ }
688
+ if (deterministic) {
689
+ keys = sort(keys, comparator);
647
690
  }
648
691
  stack.push(value);
649
- const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
650
- let i = 0;
651
- for (; i < maximumValuesToStringify - 1; i++) {
652
- const tmp2 = stringifySimple(String(i), value[i], stack);
653
- res += tmp2 !== void 0 ? tmp2 : "null";
654
- res += ",";
692
+ for (let i = 0; i < maximumPropertiesToStringify; i++) {
693
+ const key2 = keys[i];
694
+ const tmp = stringifySimple(key2, value[key2], stack);
695
+ if (tmp !== void 0) {
696
+ res += `${separator}${strEscape(key2)}:${tmp}`;
697
+ separator = ",";
698
+ }
655
699
  }
656
- const tmp = stringifySimple(String(i), value[i], stack);
657
- res += tmp !== void 0 ? tmp : "null";
658
- if (value.length - 1 > maximumBreadth) {
659
- const removedKeys = value.length - maximumBreadth - 1;
660
- res += `,"... ${getItemCount(removedKeys)} not stringified"`;
700
+ if (keyLength > maximumBreadth) {
701
+ const removedKeys = keyLength - maximumBreadth;
702
+ res += `${separator}"...":"${getItemCount(removedKeys)} not stringified"`;
661
703
  }
662
704
  stack.pop();
663
- return `[${res}]`;
664
- }
665
- let keys = Object.keys(value);
666
- const keyLength = keys.length;
667
- if (keyLength === 0) {
668
- return "{}";
669
- }
670
- if (maximumDepth < stack.length + 1) {
671
- return '"[Object]"';
672
- }
673
- let separator = "";
674
- let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
675
- if (hasLength && isTypedArrayWithEntries(value)) {
676
- res += stringifyTypedArray(value, ",", maximumBreadth);
677
- keys = keys.slice(value.length);
678
- maximumPropertiesToStringify -= value.length;
679
- separator = ",";
705
+ return `{${res}}`;
680
706
  }
681
- if (deterministic) {
682
- keys = sort(keys, comparator);
683
- }
684
- stack.push(value);
685
- for (let i = 0; i < maximumPropertiesToStringify; i++) {
686
- const key2 = keys[i];
687
- const tmp = stringifySimple(key2, value[key2], stack);
688
- if (tmp !== void 0) {
689
- res += `${separator}${strEscape(key2)}:${tmp}`;
690
- separator = ",";
707
+ case "number":
708
+ return isFinite(value) ? String(value) : fail ? fail(value) : "null";
709
+ case "boolean":
710
+ return value === true ? "true" : "false";
711
+ case "undefined":
712
+ return void 0;
713
+ case "bigint":
714
+ if (bigint) {
715
+ return String(value);
691
716
  }
692
- }
693
- if (keyLength > maximumBreadth) {
694
- const removedKeys = keyLength - maximumBreadth;
695
- res += `${separator}"...":"${getItemCount(removedKeys)} not stringified"`;
696
- }
697
- stack.pop();
698
- return `{${res}}`;
717
+ // fallthrough
718
+ default:
719
+ return fail ? fail(value) : void 0;
699
720
  }
700
- case "number":
701
- return isFinite(value) ? String(value) : fail ? fail(value) : "null";
702
- case "boolean":
703
- return value === true ? "true" : "false";
704
- case "undefined":
705
- return void 0;
706
- case "bigint":
707
- if (bigint) {
708
- return String(value);
709
- }
710
- default:
711
- return fail ? fail(value) : void 0;
712
721
  }
713
- }
714
- function stringify2(value, replacer, space) {
715
- if (arguments.length > 1) {
716
- let spacer = "";
717
- if (typeof space === "number") {
718
- spacer = " ".repeat(Math.min(space, 10));
719
- } else if (typeof space === "string") {
720
- spacer = space.slice(0, 10);
721
- }
722
- if (replacer != null) {
723
- if (typeof replacer === "function") {
724
- return stringifyFnReplacer("", { "": value }, [], replacer, spacer, "");
722
+ function stringify2(value, replacer, space) {
723
+ if (arguments.length > 1) {
724
+ let spacer = "";
725
+ if (typeof space === "number") {
726
+ spacer = " ".repeat(Math.min(space, 10));
727
+ } else if (typeof space === "string") {
728
+ spacer = space.slice(0, 10);
725
729
  }
726
- if (Array.isArray(replacer)) {
727
- return stringifyArrayReplacer("", value, [], getUniqueReplacerSet(replacer), spacer, "");
730
+ if (replacer != null) {
731
+ if (typeof replacer === "function") {
732
+ return stringifyFnReplacer("", { "": value }, [], replacer, spacer, "");
733
+ }
734
+ if (Array.isArray(replacer)) {
735
+ return stringifyArrayReplacer("", value, [], getUniqueReplacerSet(replacer), spacer, "");
736
+ }
737
+ }
738
+ if (spacer.length !== 0) {
739
+ return stringifyIndent("", value, [], spacer, "");
728
740
  }
729
741
  }
730
- if (spacer.length !== 0) {
731
- return stringifyIndent("", value, [], spacer, "");
732
- }
742
+ return stringifySimple("", value, []);
733
743
  }
734
- return stringifySimple("", value, []);
744
+ return stringify2;
735
745
  }
736
- return stringify2;
737
- }
738
- })(safeStableStringify, safeStableStringify.exports);
739
- var safeStableStringifyExports = safeStableStringify.exports;
746
+ })(safeStableStringify, safeStableStringify.exports);
747
+ return safeStableStringify.exports;
748
+ }
749
+ var safeStableStringifyExports = requireSafeStableStringify();
740
750
  const cjsModule = /* @__PURE__ */ getDefaultExportFromCjs(safeStableStringifyExports);
741
751
  cjsModule.configure;
742
752
  let getRandomValues;
@@ -1653,6 +1663,7 @@ function updateOperations(document, action, skip = 0, reuseLastOperationIndex =
1653
1663
  const latestOperation = operations.at(-1);
1654
1664
  const lastOperationIndex = (latestOperation == null ? void 0 : latestOperation.index) ?? -1;
1655
1665
  let nextIndex = reuseLastOperationIndex ? lastOperationIndex : lastOperationIndex + 1;
1666
+ let timestamp = (/* @__PURE__ */ new Date()).toISOString();
1656
1667
  if ("index" in action) {
1657
1668
  if (action.index - skip > nextIndex) {
1658
1669
  throw new Error(
@@ -1661,6 +1672,7 @@ function updateOperations(document, action, skip = 0, reuseLastOperationIndex =
1661
1672
  }
1662
1673
  nextIndex = action.index;
1663
1674
  operationId = action.id;
1675
+ timestamp = action.timestamp;
1664
1676
  } else {
1665
1677
  operationId = "id" in action ? action.id : v4();
1666
1678
  }
@@ -1668,7 +1680,7 @@ function updateOperations(document, action, skip = 0, reuseLastOperationIndex =
1668
1680
  ...action,
1669
1681
  id: operationId,
1670
1682
  index: nextIndex,
1671
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1683
+ timestamp,
1672
1684
  hash: "",
1673
1685
  scope,
1674
1686
  skip,
@@ -2478,4 +2490,4 @@ exports.updateHeader = updateHeader;
2478
2490
  exports.validateOperations = validateOperations;
2479
2491
  exports.verifyOperationSignature = verifyOperationSignature;
2480
2492
  exports.zod = zod;
2481
- //# sourceMappingURL=object-BQxrSeG7.js.map
2493
+ //# sourceMappingURL=object-DgmfygmD.js.map