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