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