@metapages/metapage 1.8.12 → 1.8.15

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 (72) hide show
  1. package/dist/index.js +3633 -77
  2. package/dist/index.js.map +1 -1
  3. package/dist/metapage/metapageRenderer.d.ts +2 -0
  4. package/dist/metapage/metapageRenderer.d.ts.map +1 -1
  5. package/package.json +2 -2
  6. package/src/metapage/metapageRenderer.ts +3 -0
  7. package/dist/_virtual/_commonjsHelpers.js +0 -9
  8. package/dist/_virtual/_commonjsHelpers.js.map +0 -1
  9. package/dist/_virtual/fetch-retry.umd.js +0 -5
  10. package/dist/_virtual/fetch-retry.umd.js.map +0 -1
  11. package/dist/_virtual/index.js +0 -5
  12. package/dist/_virtual/index.js.map +0 -1
  13. package/dist/_virtual/utils.js +0 -5
  14. package/dist/_virtual/utils.js.map +0 -1
  15. package/dist/metapage/Constants.js +0 -10
  16. package/dist/metapage/Constants.js.map +0 -1
  17. package/dist/metapage/Metaframe.js +0 -232
  18. package/dist/metapage/Metaframe.js.map +0 -1
  19. package/dist/metapage/Metapage.js +0 -362
  20. package/dist/metapage/Metapage.js.map +0 -1
  21. package/dist/metapage/MetapageIFrameRpcClient.js +0 -219
  22. package/dist/metapage/MetapageIFrameRpcClient.js.map +0 -1
  23. package/dist/metapage/MetapageTools.js +0 -74
  24. package/dist/metapage/MetapageTools.js.map +0 -1
  25. package/dist/metapage/Shared.js +0 -34
  26. package/dist/metapage/Shared.js.map +0 -1
  27. package/dist/metapage/conversions-metaframe.js +0 -143
  28. package/dist/metapage/conversions-metaframe.js.map +0 -1
  29. package/dist/metapage/conversions-metapage.js +0 -97
  30. package/dist/metapage/conversions-metapage.js.map +0 -1
  31. package/dist/metapage/data.js +0 -140
  32. package/dist/metapage/data.js.map +0 -1
  33. package/dist/metapage/events.js +0 -8
  34. package/dist/metapage/events.js.map +0 -1
  35. package/dist/metapage/jsonrpc.js +0 -13
  36. package/dist/metapage/jsonrpc.js.map +0 -1
  37. package/dist/metapage/jsonrpc2.js +0 -22
  38. package/dist/metapage/jsonrpc2.js.map +0 -1
  39. package/dist/metapage/metapageRenderer.js +0 -178
  40. package/dist/metapage/metapageRenderer.js.map +0 -1
  41. package/dist/metapage/util.js +0 -45
  42. package/dist/metapage/util.js.map +0 -1
  43. package/dist/metapage/versions.js +0 -8
  44. package/dist/metapage/versions.js.map +0 -1
  45. package/dist/node_modules/@metapages/hash-query/dist/core/index.js +0 -149
  46. package/dist/node_modules/@metapages/hash-query/dist/core/index.js.map +0 -1
  47. package/dist/node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js +0 -21
  48. package/dist/node_modules/base64-arraybuffer/dist/base64-arraybuffer.es5.js.map +0 -1
  49. package/dist/node_modules/compare-versions/lib/esm/compareVersions.js +0 -9
  50. package/dist/node_modules/compare-versions/lib/esm/compareVersions.js.map +0 -1
  51. package/dist/node_modules/compare-versions/lib/esm/utils.js +0 -29
  52. package/dist/node_modules/compare-versions/lib/esm/utils.js.map +0 -1
  53. package/dist/node_modules/eventemitter3/index.js +0 -116
  54. package/dist/node_modules/eventemitter3/index.js.map +0 -1
  55. package/dist/node_modules/fast-json-stable-stringify/index.js +0 -44
  56. package/dist/node_modules/fast-json-stable-stringify/index.js.map +0 -1
  57. package/dist/node_modules/fetch-retry/dist/fetch-retry.umd.js +0 -95
  58. package/dist/node_modules/fetch-retry/dist/fetch-retry.umd.js.map +0 -1
  59. package/dist/node_modules/mutative/dist/mutative.esm.js +0 -854
  60. package/dist/node_modules/mutative/dist/mutative.esm.js.map +0 -1
  61. package/dist/node_modules/picomatch-browser/index.js +0 -8
  62. package/dist/node_modules/picomatch-browser/index.js.map +0 -1
  63. package/dist/node_modules/picomatch-browser/lib/constants.js +0 -175
  64. package/dist/node_modules/picomatch-browser/lib/constants.js.map +0 -1
  65. package/dist/node_modules/picomatch-browser/lib/parse.js +0 -454
  66. package/dist/node_modules/picomatch-browser/lib/parse.js.map +0 -1
  67. package/dist/node_modules/picomatch-browser/lib/picomatch.js +0 -78
  68. package/dist/node_modules/picomatch-browser/lib/picomatch.js.map +0 -1
  69. package/dist/node_modules/picomatch-browser/lib/scan.js +0 -185
  70. package/dist/node_modules/picomatch-browser/lib/scan.js.map +0 -1
  71. package/dist/node_modules/picomatch-browser/lib/utils.js +0 -25
  72. package/dist/node_modules/picomatch-browser/lib/utils.js.map +0 -1
@@ -1,854 +0,0 @@
1
- const h = {
2
- Remove: "remove",
3
- Replace: "replace",
4
- Add: "add"
5
- }, ce = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), be = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), W = Symbol.iterator, m = {
6
- mutable: "mutable",
7
- immutable: "immutable"
8
- }, Q = {};
9
- function $(e, n) {
10
- return e instanceof Map ? e.has(n) : Object.prototype.hasOwnProperty.call(e, n);
11
- }
12
- function te(e, n) {
13
- if (n in e) {
14
- let o = Reflect.getPrototypeOf(e);
15
- for (; o; ) {
16
- const t = Reflect.getOwnPropertyDescriptor(o, n);
17
- if (t)
18
- return t;
19
- o = Reflect.getPrototypeOf(o);
20
- }
21
- }
22
- }
23
- function w(e) {
24
- var n;
25
- return (n = e.copy) !== null && n !== void 0 ? n : e.original;
26
- }
27
- function D(e) {
28
- return !!u(e);
29
- }
30
- function u(e) {
31
- return typeof e != "object" ? null : e == null ? void 0 : e[ce];
32
- }
33
- function Z(e) {
34
- var n;
35
- const o = u(e);
36
- return o ? (n = o.copy) !== null && n !== void 0 ? n : o.original : e;
37
- }
38
- function M(e, n) {
39
- if (!e || typeof e != "object")
40
- return !1;
41
- let o;
42
- return Object.getPrototypeOf(e) === Object.prototype || Array.isArray(e) || e instanceof Map || e instanceof Set || !!(n != null && n.mark) && ((o = n.mark(e, m)) === m.immutable || typeof o == "function");
43
- }
44
- function le(e, n = []) {
45
- if (Object.hasOwnProperty.call(e, "key")) {
46
- const o = e.parent.copy, t = u(A(o, e.key));
47
- if (t !== null && (t == null ? void 0 : t.original) !== e.original)
48
- return null;
49
- const r = e.parent.type === 3, l = r ? Array.from(e.parent.setMap.keys()).indexOf(e.key) : e.key;
50
- if (!(r && o.size > l || $(o, l)))
51
- return null;
52
- n.push(l);
53
- }
54
- if (e.parent)
55
- return le(e.parent, n);
56
- n.reverse();
57
- try {
58
- ye(e.copy, n);
59
- } catch {
60
- return null;
61
- }
62
- return n;
63
- }
64
- function F(e) {
65
- return Array.isArray(e) ? 1 : e instanceof Map ? 2 : e instanceof Set ? 3 : 0;
66
- }
67
- function A(e, n) {
68
- return F(e) === 2 ? e.get(n) : e[n];
69
- }
70
- function N(e, n, o) {
71
- F(e) === 2 ? e.set(n, o) : e[n] = o;
72
- }
73
- function Y(e, n) {
74
- const o = u(e);
75
- return (o ? w(o) : e)[n];
76
- }
77
- function _(e, n) {
78
- return e === n ? e !== 0 || 1 / e === 1 / n : e !== e && n !== n;
79
- }
80
- function L(e) {
81
- if (e)
82
- for (; e.finalities.revoke.length > 0; )
83
- e.finalities.revoke.pop()();
84
- }
85
- function x(e, n) {
86
- return n ? e : [""].concat(e).map((o) => {
87
- const t = `${o}`;
88
- return t.indexOf("/") === -1 && t.indexOf("~") === -1 ? t : t.replace(/~/g, "~0").replace(/\//g, "~1");
89
- }).join("/");
90
- }
91
- function ye(e, n) {
92
- for (let o = 0; o < n.length - 1; o += 1) {
93
- const t = n[o];
94
- if (e = A(F(e) === 3 ? Array.from(e) : e, t), typeof e != "object")
95
- throw new Error(`Cannot resolve patch at '${n.join("/")}'.`);
96
- }
97
- return e;
98
- }
99
- function we(e) {
100
- const n = Object.create(Object.getPrototypeOf(e));
101
- return Reflect.ownKeys(e).forEach((o) => {
102
- let t = Reflect.getOwnPropertyDescriptor(e, o);
103
- if (t.enumerable && t.configurable && t.writable) {
104
- n[o] = e[o];
105
- return;
106
- }
107
- t.writable || (t.writable = !0, t.configurable = !0), (t.get || t.set) && (t = {
108
- configurable: !0,
109
- writable: !0,
110
- enumerable: t.enumerable,
111
- value: e[o]
112
- }), Reflect.defineProperty(n, o, t);
113
- }), n;
114
- }
115
- const me = Object.prototype.propertyIsEnumerable;
116
- function ae(e, n) {
117
- let o;
118
- if (Array.isArray(e))
119
- return Array.prototype.concat.call(e);
120
- if (e instanceof Set)
121
- return new Set(e.values());
122
- if (e instanceof Map)
123
- return new Map(e);
124
- if (n != null && n.mark && (o = n.mark(e, m), o !== void 0) && o !== m.mutable) {
125
- if (o === m.immutable)
126
- return we(e);
127
- if (typeof o == "function") {
128
- if (n.enablePatches || n.enableAutoFreeze)
129
- throw new Error("You can't use mark and patches or auto freeze together.");
130
- return o();
131
- }
132
- throw new Error(`Unsupported mark result: ${o}`);
133
- } else if (typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype) {
134
- const t = {};
135
- return Object.keys(e).forEach((r) => {
136
- t[r] = e[r];
137
- }), Object.getOwnPropertySymbols(e).forEach((r) => {
138
- me.call(e, r) && (t[r] = e[r]);
139
- }), t;
140
- } else
141
- throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
142
- }
143
- function b(e) {
144
- e.copy || (e.copy = ae(e.original, e.options));
145
- }
146
- function T(e) {
147
- if (!M(e))
148
- return Z(e);
149
- if (Array.isArray(e))
150
- return e.map(T);
151
- if (e instanceof Map)
152
- return new Map(Array.from(e.entries()).map(([o, t]) => [o, T(t)]));
153
- if (e instanceof Set)
154
- return new Set(Array.from(e).map(T));
155
- const n = Object.create(Object.getPrototypeOf(e));
156
- for (const o in e)
157
- n[o] = T(e[o]);
158
- return n;
159
- }
160
- function H(e) {
161
- return D(e) ? T(e) : e;
162
- }
163
- function j(e) {
164
- var n;
165
- e.assignedMap = (n = e.assignedMap) !== null && n !== void 0 ? n : /* @__PURE__ */ new Map(), e.operated || (e.operated = !0, e.parent && j(e.parent));
166
- }
167
- function re() {
168
- throw new Error("Cannot modify frozen object");
169
- }
170
- function C(e, n, o, t, r) {
171
- {
172
- o = o ?? /* @__PURE__ */ new WeakMap(), t = t ?? [], r = r ?? [];
173
- const i = o.has(e) ? o.get(e) : e;
174
- if (t.length > 0) {
175
- const s = t.indexOf(i);
176
- if (i && typeof i == "object" && s !== -1)
177
- throw t[0] === i ? new Error("Forbids circular reference") : new Error(`Forbids circular reference: ~/${r.slice(0, s).map((a, c) => {
178
- if (typeof a == "symbol")
179
- return `[${a.toString()}]`;
180
- const f = t[c];
181
- return typeof a == "object" && (f instanceof Map || f instanceof Set) ? Array.from(f.keys()).indexOf(a) : a;
182
- }).join("/")}`);
183
- t.push(i), r.push(n);
184
- } else
185
- t.push(i);
186
- }
187
- if (Object.isFrozen(e) || D(e)) {
188
- t.pop(), r.pop();
189
- return;
190
- }
191
- switch (F(e)) {
192
- case 2:
193
- for (const [s, a] of e)
194
- C(s, s, o, t, r), C(a, s, o, t, r);
195
- e.set = e.clear = e.delete = re;
196
- break;
197
- case 3:
198
- for (const s of e)
199
- C(s, s, o, t, r);
200
- e.add = e.clear = e.delete = re;
201
- break;
202
- case 1:
203
- Object.freeze(e);
204
- let i = 0;
205
- for (const s of e)
206
- C(s, i, o, t, r), i += 1;
207
- break;
208
- default:
209
- Object.freeze(e), Object.keys(e).forEach((s) => {
210
- const a = e[s];
211
- C(a, s, o, t, r);
212
- });
213
- }
214
- t.pop(), r.pop();
215
- }
216
- function g(e, n) {
217
- const o = F(e);
218
- if (o === 0)
219
- Reflect.ownKeys(e).forEach((t) => {
220
- n(t, e[t], e);
221
- });
222
- else if (o === 1) {
223
- let t = 0;
224
- for (const r of e)
225
- n(t, r, e), t += 1;
226
- } else
227
- e.forEach((t, r) => n(r, t, e));
228
- }
229
- function fe(e, n, o) {
230
- if (D(e) || !M(e, o) || n.has(e) || Object.isFrozen(e))
231
- return;
232
- const t = e instanceof Set, r = t ? /* @__PURE__ */ new Map() : void 0;
233
- if (n.add(e), g(e, (l, i) => {
234
- var s;
235
- if (D(i)) {
236
- const a = u(i);
237
- b(a);
238
- const c = !((s = a.assignedMap) === null || s === void 0) && s.size || a.operated ? a.copy : a.original;
239
- N(t ? r : e, l, c);
240
- } else
241
- fe(i, n, o);
242
- }), r) {
243
- const l = e, i = Array.from(l);
244
- l.clear(), i.forEach((s) => {
245
- l.add(r.has(s) ? r.get(s) : s);
246
- });
247
- }
248
- }
249
- function ve(e, n) {
250
- const o = e.type === 3 ? e.setMap : e.copy;
251
- e.finalities.revoke.length > 1 && e.assignedMap.get(n) && o && fe(A(o, n), e.finalities.handledSet, e.options);
252
- }
253
- function B(e) {
254
- e.type === 3 && e.copy && (e.copy.clear(), e.setMap.forEach((n) => {
255
- e.copy.add(Z(n));
256
- }));
257
- }
258
- function X(e, n, o, t) {
259
- if (e.operated && e.assignedMap && e.assignedMap.size > 0 && !e.finalized) {
260
- if (o && t) {
261
- const l = le(e);
262
- l && n(e, l, o, t);
263
- }
264
- e.finalized = !0;
265
- }
266
- }
267
- function k(e, n, o, t) {
268
- const r = u(o);
269
- r && (r.callbacks || (r.callbacks = []), r.callbacks.push((l, i) => {
270
- var s;
271
- const a = e.type === 3 ? e.setMap : e.copy;
272
- if (_(A(a, n), o)) {
273
- let c = r.original;
274
- r.copy && (c = r.copy), B(e), X(e, t, l, i), e.options.enableAutoFreeze && (e.options.updatedValues = (s = e.options.updatedValues) !== null && s !== void 0 ? s : /* @__PURE__ */ new WeakMap(), e.options.updatedValues.set(c, r.original)), N(a, n, c);
275
- }
276
- }), e.options.enableAutoFreeze && r.finalities !== e.finalities && (e.options.enableAutoFreeze = !1)), M(o, e.options) && e.finalities.draft.push(() => {
277
- const l = e.type === 3 ? e.setMap : e.copy;
278
- _(A(l, n), o) && ve(e, n);
279
- });
280
- }
281
- function Me(e, n, o, t, r) {
282
- let { original: l, assignedMap: i, options: s } = e, a = e.copy;
283
- a.length < l.length && ([l, a] = [a, l], [o, t] = [t, o]);
284
- for (let c = 0; c < l.length; c += 1)
285
- if (i.get(c.toString()) && a[c] !== l[c]) {
286
- const f = n.concat([c]), p = x(f, r);
287
- o.push({
288
- op: h.Replace,
289
- path: p,
290
- // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
291
- value: H(a[c])
292
- }), t.push({
293
- op: h.Replace,
294
- path: p,
295
- // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
296
- value: H(l[c])
297
- });
298
- }
299
- for (let c = l.length; c < a.length; c += 1) {
300
- const f = n.concat([c]), p = x(f, r);
301
- o.push({
302
- op: h.Add,
303
- path: p,
304
- // If it is a draft, it needs to be deep cloned, and it may also be non-draft.
305
- value: H(a[c])
306
- });
307
- }
308
- if (l.length < a.length) {
309
- const { arrayLengthAssignment: c = !0 } = s.enablePatches;
310
- if (c) {
311
- const f = n.concat(["length"]), p = x(f, r);
312
- t.push({
313
- op: h.Replace,
314
- path: p,
315
- value: l.length
316
- });
317
- } else
318
- for (let f = a.length; l.length < f; f -= 1) {
319
- const p = n.concat([f - 1]), O = x(p, r);
320
- t.push({
321
- op: h.Remove,
322
- path: O
323
- });
324
- }
325
- }
326
- }
327
- function Oe({ original: e, copy: n, assignedMap: o }, t, r, l, i) {
328
- o.forEach((s, a) => {
329
- const c = A(e, a), f = H(A(n, a)), p = s ? $(e, a) ? h.Replace : h.Add : h.Remove;
330
- if (_(c, f) && p === h.Replace)
331
- return;
332
- const O = t.concat(a), v = x(O, i);
333
- r.push(p === h.Remove ? { op: p, path: v } : { op: p, path: v, value: f }), l.push(p === h.Add ? { op: h.Remove, path: v } : p === h.Remove ? { op: h.Add, path: v, value: c } : { op: h.Replace, path: v, value: c });
334
- });
335
- }
336
- function Re({ original: e, copy: n }, o, t, r, l) {
337
- let i = 0;
338
- e.forEach((s) => {
339
- if (!n.has(s)) {
340
- const a = o.concat([i]), c = x(a, l);
341
- t.push({
342
- op: h.Remove,
343
- path: c,
344
- value: s
345
- }), r.unshift({
346
- op: h.Add,
347
- path: c,
348
- value: s
349
- });
350
- }
351
- i += 1;
352
- }), i = 0, n.forEach((s) => {
353
- if (!e.has(s)) {
354
- const a = o.concat([i]), c = x(a, l);
355
- t.push({
356
- op: h.Add,
357
- path: c,
358
- value: s
359
- }), r.unshift({
360
- op: h.Remove,
361
- path: c,
362
- value: s
363
- });
364
- }
365
- i += 1;
366
- });
367
- }
368
- function K(e, n, o, t) {
369
- const { pathAsArray: r = !0 } = e.options.enablePatches;
370
- switch (e.type) {
371
- case 0:
372
- case 2:
373
- return Oe(e, n, o, t, r);
374
- case 1:
375
- return Me(e, n, o, t, r);
376
- case 3:
377
- return Re(e, n, o, t, r);
378
- }
379
- }
380
- let ze = !1;
381
- const U = (e, n, o = !1) => {
382
- if (typeof e == "object" && e !== null && (!M(e, n) || o) && !ze)
383
- throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
384
- }, q = {
385
- get size() {
386
- return w(u(this)).size;
387
- },
388
- has(e) {
389
- return w(u(this)).has(e);
390
- },
391
- set(e, n) {
392
- const o = u(this), t = w(o);
393
- return (!t.has(e) || !_(t.get(e), n)) && (b(o), j(o), o.assignedMap.set(e, !0), o.copy.set(e, n), k(o, e, n, K)), this;
394
- },
395
- delete(e) {
396
- if (!this.has(e))
397
- return !1;
398
- const n = u(this);
399
- return b(n), j(n), n.original.has(e) ? n.assignedMap.set(e, !1) : n.assignedMap.delete(e), n.copy.delete(e), !0;
400
- },
401
- clear() {
402
- const e = u(this);
403
- if (this.size) {
404
- b(e), j(e), e.assignedMap = /* @__PURE__ */ new Map();
405
- for (const [n] of e.original)
406
- e.assignedMap.set(n, !1);
407
- e.copy.clear();
408
- }
409
- },
410
- forEach(e, n) {
411
- const o = u(this);
412
- w(o).forEach((t, r) => {
413
- e.call(n, this.get(r), r, this);
414
- });
415
- },
416
- get(e) {
417
- var n, o;
418
- const t = u(this), r = w(t).get(e), l = ((o = (n = t.options).mark) === null || o === void 0 ? void 0 : o.call(n, r, m)) === m.mutable;
419
- if (t.options.strict && U(r, t.options, l), l || t.finalized || !M(r, t.options) || r !== t.original.get(e))
420
- return r;
421
- const i = Q.createDraft({
422
- original: r,
423
- parentDraft: t,
424
- key: e,
425
- finalities: t.finalities,
426
- options: t.options
427
- });
428
- return b(t), t.copy.set(e, i), i;
429
- },
430
- keys() {
431
- return w(u(this)).keys();
432
- },
433
- values() {
434
- const e = this.keys();
435
- return {
436
- [W]: () => this.values(),
437
- next: () => {
438
- const n = e.next();
439
- return n.done ? n : {
440
- done: !1,
441
- value: this.get(n.value)
442
- };
443
- }
444
- };
445
- },
446
- entries() {
447
- const e = this.keys();
448
- return {
449
- [W]: () => this.entries(),
450
- next: () => {
451
- const n = e.next();
452
- if (n.done)
453
- return n;
454
- const o = this.get(n.value);
455
- return {
456
- done: !1,
457
- value: [n.value, o]
458
- };
459
- }
460
- };
461
- },
462
- [W]() {
463
- return this.entries();
464
- }
465
- }, je = Reflect.ownKeys(q), ie = (e, n, { isValuesIterator: o }) => () => {
466
- var t, r;
467
- const l = n.next();
468
- if (l.done)
469
- return l;
470
- const i = l.value;
471
- let s = e.setMap.get(i);
472
- const a = u(s), c = ((r = (t = e.options).mark) === null || r === void 0 ? void 0 : r.call(t, s, m)) === m.mutable;
473
- if (e.options.strict && U(i, e.options, c), !c && !a && M(i, e.options) && !e.finalized && e.original.has(i)) {
474
- const f = Q.createDraft({
475
- original: i,
476
- parentDraft: e,
477
- key: i,
478
- finalities: e.finalities,
479
- options: e.options
480
- });
481
- e.setMap.set(i, f), s = f;
482
- } else
483
- a && (s = a.proxy);
484
- return {
485
- done: !1,
486
- value: o ? s : [s, s]
487
- };
488
- }, G = {
489
- get size() {
490
- return u(this).setMap.size;
491
- },
492
- has(e) {
493
- const n = u(this);
494
- if (n.setMap.has(e))
495
- return !0;
496
- b(n);
497
- const o = u(e);
498
- return !!(o && n.setMap.has(o.original));
499
- },
500
- add(e) {
501
- const n = u(this);
502
- return this.has(e) || (b(n), j(n), n.assignedMap.set(e, !0), n.setMap.set(e, e), k(n, e, e, K)), this;
503
- },
504
- delete(e) {
505
- if (!this.has(e))
506
- return !1;
507
- const n = u(this);
508
- b(n), j(n);
509
- const o = u(e);
510
- return o && n.setMap.has(o.original) ? (n.assignedMap.set(o.original, !1), n.setMap.delete(o.original)) : (!o && n.setMap.has(e) ? n.assignedMap.set(e, !1) : n.assignedMap.delete(e), n.setMap.delete(e));
511
- },
512
- clear() {
513
- if (!this.size)
514
- return;
515
- const e = u(this);
516
- b(e), j(e);
517
- for (const n of e.original)
518
- e.assignedMap.set(n, !1);
519
- e.setMap.clear();
520
- },
521
- values() {
522
- const e = u(this);
523
- b(e);
524
- const n = e.setMap.keys();
525
- return {
526
- [Symbol.iterator]: () => this.values(),
527
- next: ie(e, n, { isValuesIterator: !0 })
528
- };
529
- },
530
- entries() {
531
- const e = u(this);
532
- b(e);
533
- const n = e.setMap.keys();
534
- return {
535
- [Symbol.iterator]: () => this.entries(),
536
- next: ie(e, n, {
537
- isValuesIterator: !1
538
- })
539
- };
540
- },
541
- keys() {
542
- return this.values();
543
- },
544
- [W]() {
545
- return this.values();
546
- },
547
- forEach(e, n) {
548
- const o = this.values();
549
- let t = o.next();
550
- for (; !t.done; )
551
- e.call(n, t.value, t.value, this), t = o.next();
552
- }
553
- }, Ee = Reflect.ownKeys(G), ue = /* @__PURE__ */ new WeakSet(), pe = {
554
- get(e, n, o) {
555
- var t, r;
556
- const l = (t = e.copy) === null || t === void 0 ? void 0 : t[n];
557
- if (l && ue.has(l))
558
- return l;
559
- if (n === ce)
560
- return e;
561
- let i;
562
- if (e.options.mark) {
563
- const c = n === "size" && (e.original instanceof Map || e.original instanceof Set) ? Reflect.get(e.original, n) : Reflect.get(e.original, n, o);
564
- if (i = e.options.mark(c, m), i === m.mutable)
565
- return e.options.strict && U(c, e.options, !0), c;
566
- }
567
- const s = w(e);
568
- if (s instanceof Map && je.includes(n)) {
569
- if (n === "size")
570
- return Object.getOwnPropertyDescriptor(q, "size").get.call(e.proxy);
571
- const c = q[n];
572
- if (c)
573
- return c.bind(e.proxy);
574
- }
575
- if (s instanceof Set && Ee.includes(n)) {
576
- if (n === "size")
577
- return Object.getOwnPropertyDescriptor(G, "size").get.call(e.proxy);
578
- const c = G[n];
579
- if (c)
580
- return c.bind(e.proxy);
581
- }
582
- if (!$(s, n)) {
583
- const c = te(s, n);
584
- return c ? "value" in c ? c.value : (
585
- // !case: support for getter
586
- (r = c.get) === null || r === void 0 ? void 0 : r.call(e.proxy)
587
- ) : void 0;
588
- }
589
- const a = s[n];
590
- if (e.options.strict && U(a, e.options), e.finalized || !M(a, e.options))
591
- return a;
592
- if (a === Y(e.original, n)) {
593
- if (b(e), e.copy[n] = ee({
594
- original: e.original[n],
595
- parentDraft: e,
596
- key: e.type === 1 ? Number(n) : n,
597
- finalities: e.finalities,
598
- options: e.options
599
- }), typeof i == "function") {
600
- const c = u(e.copy[n]);
601
- return b(c), j(c), c.copy;
602
- }
603
- return e.copy[n];
604
- }
605
- return a;
606
- },
607
- set(e, n, o) {
608
- var t;
609
- if (e.type === 3 || e.type === 2)
610
- throw new Error("Map/Set draft does not support any property assignment.");
611
- let r;
612
- if (e.type === 1 && n !== "length" && !(Number.isInteger(r = Number(n)) && r >= 0 && (n === 0 || r === 0 || String(r) === String(n))))
613
- throw new Error("Only supports setting array indices and the 'length' property.");
614
- const l = te(w(e), n);
615
- if (l != null && l.set)
616
- return l.set.call(e.proxy, o), !0;
617
- const i = Y(w(e), n), s = u(i);
618
- return s && _(s.original, o) ? (e.copy[n] = o, e.assignedMap = (t = e.assignedMap) !== null && t !== void 0 ? t : /* @__PURE__ */ new Map(), e.assignedMap.set(n, !1), !0) : (_(o, i) && (o !== void 0 || $(e.original, n)) || (b(e), j(e), $(e.original, n) && _(o, e.original[n]) ? e.assignedMap.delete(n) : e.assignedMap.set(n, !0), e.copy[n] = o, k(e, n, o, K)), !0);
619
- },
620
- has(e, n) {
621
- return n in w(e);
622
- },
623
- ownKeys(e) {
624
- return Reflect.ownKeys(w(e));
625
- },
626
- getOwnPropertyDescriptor(e, n) {
627
- const o = w(e), t = Reflect.getOwnPropertyDescriptor(o, n);
628
- return t && {
629
- writable: !0,
630
- configurable: e.type !== 1 || n !== "length",
631
- enumerable: t.enumerable,
632
- value: o[n]
633
- };
634
- },
635
- getPrototypeOf(e) {
636
- return Reflect.getPrototypeOf(e.original);
637
- },
638
- setPrototypeOf() {
639
- throw new Error("Cannot call 'setPrototypeOf()' on drafts");
640
- },
641
- defineProperty() {
642
- throw new Error("Cannot call 'defineProperty()' on drafts");
643
- },
644
- deleteProperty(e, n) {
645
- var o;
646
- return e.type === 1 ? pe.set.call(this, e, n, void 0, e.proxy) : (Y(e.original, n) !== void 0 || n in e.original ? (b(e), j(e), e.assignedMap.set(n, !1)) : (e.assignedMap = (o = e.assignedMap) !== null && o !== void 0 ? o : /* @__PURE__ */ new Map(), e.assignedMap.delete(n)), e.copy && delete e.copy[n], !0);
647
- }
648
- };
649
- function ee(e) {
650
- const { original: n, parentDraft: o, key: t, finalities: r, options: l } = e, i = F(n), s = {
651
- type: i,
652
- finalized: !1,
653
- parent: o,
654
- original: n,
655
- copy: null,
656
- proxy: null,
657
- finalities: r,
658
- options: l,
659
- // Mapping of draft Set items to their corresponding draft values.
660
- setMap: i === 3 ? new Map(n.entries()) : void 0
661
- };
662
- (t || "key" in e) && (s.key = t);
663
- const { proxy: a, revoke: c } = Proxy.revocable(i === 1 ? Object.assign([], s) : s, pe);
664
- if (r.revoke.push(c), ue.add(a), s.proxy = a, o) {
665
- const f = o;
666
- f.finalities.draft.push((p, O) => {
667
- var v, I;
668
- const ne = u(a);
669
- let P = f.type === 3 ? f.setMap : f.copy;
670
- const R = A(P, t), y = u(R);
671
- if (y) {
672
- let z = y.original;
673
- y.operated && (z = Z(R)), B(y), X(y, K, p, O), f.options.enableAutoFreeze && (f.options.updatedValues = (v = f.options.updatedValues) !== null && v !== void 0 ? v : /* @__PURE__ */ new WeakMap(), f.options.updatedValues.set(z, y.original)), N(P, t, z);
674
- }
675
- (I = ne.callbacks) === null || I === void 0 || I.forEach((z) => {
676
- z(p, O);
677
- });
678
- });
679
- } else {
680
- const f = u(a);
681
- f.finalities.draft.push((p, O) => {
682
- B(f), X(f, K, p, O);
683
- });
684
- }
685
- return a;
686
- }
687
- Q.createDraft = ee;
688
- function _e(e, n, o, t, r) {
689
- var l;
690
- const i = u(e), s = (l = i == null ? void 0 : i.original) !== null && l !== void 0 ? l : e, a = !!n.length;
691
- if (i != null && i.operated)
692
- for (; i.finalities.draft.length > 0; )
693
- i.finalities.draft.pop()(o, t);
694
- const c = a ? n[0] : i ? i.operated ? i.copy : i.original : e;
695
- return i && L(i), r && C(c, c, i == null ? void 0 : i.options.updatedValues), [
696
- c,
697
- o && a ? [{ op: h.Replace, path: [], value: n[0] }] : o,
698
- t && a ? [{ op: h.Replace, path: [], value: s }] : t
699
- ];
700
- }
701
- function Ae(e, n) {
702
- var o;
703
- const t = {
704
- draft: [],
705
- revoke: [],
706
- handledSet: /* @__PURE__ */ new WeakSet()
707
- };
708
- let r, l;
709
- n.enablePatches && (r = [], l = []);
710
- const s = ((o = n.mark) === null || o === void 0 ? void 0 : o.call(n, e, m)) === m.mutable || !M(e, n) ? e : ee({
711
- original: e,
712
- parentDraft: null,
713
- finalities: t,
714
- options: n
715
- });
716
- return [
717
- s,
718
- (a = []) => {
719
- const [c, f, p] = _e(s, a, r, l, n.enableAutoFreeze);
720
- return n.enablePatches ? [c, f, p] : c;
721
- }
722
- ];
723
- }
724
- function J(e) {
725
- const { rootDraft: n, value: o, useRawReturn: t = !1, isRoot: r = !0 } = e;
726
- g(o, (l, i, s) => {
727
- const a = u(i);
728
- if (a && n && a.finalities === n.finalities) {
729
- e.isContainDraft = !0;
730
- const c = a.original;
731
- if (s instanceof Set) {
732
- const f = Array.from(s);
733
- s.clear(), f.forEach((p) => s.add(l === p ? c : p));
734
- } else
735
- N(s, l, c);
736
- } else
737
- typeof i == "object" && i !== null && (e.value = i, e.isRoot = !1, J(e));
738
- }), r && (e.isContainDraft || console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance."), t && console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value."));
739
- }
740
- function de(e) {
741
- const n = u(e);
742
- if (!M(e, n == null ? void 0 : n.options))
743
- return e;
744
- const o = F(e);
745
- if (n && !n.operated)
746
- return n.original;
747
- let t;
748
- function r() {
749
- t = o === 2 ? new Map(e) : o === 3 ? Array.from(n.setMap.values()) : ae(e, n == null ? void 0 : n.options);
750
- }
751
- if (n) {
752
- n.finalized = !0;
753
- try {
754
- r();
755
- } finally {
756
- n.finalized = !1;
757
- }
758
- } else
759
- t = e;
760
- return g(t, (l, i) => {
761
- if (n && _(A(n.original, l), i))
762
- return;
763
- const s = de(i);
764
- s !== i && (t === e && r(), N(t, l, s));
765
- }), o === 3 ? new Set(t) : t;
766
- }
767
- function se(e) {
768
- if (!D(e))
769
- throw new Error(`current() is only used for Draft, parameter: ${e}`);
770
- return de(e);
771
- }
772
- const Pe = (e) => {
773
- if (e !== void 0 && Object.prototype.toString.call(e) !== "[object Object]")
774
- throw new Error(`Invalid options: ${String(e)}, 'options' should be an object.`);
775
- return function n(o, t, r) {
776
- var l, i, s;
777
- if (typeof o == "function" && typeof t != "function")
778
- return function(d, ...E) {
779
- return n(d, (S) => o.call(this, S, ...E), t);
780
- };
781
- const a = o, c = t;
782
- let f = r;
783
- if (typeof t != "function" && (f = t), f !== void 0 && Object.prototype.toString.call(f) !== "[object Object]")
784
- throw new Error(`Invalid options: ${f}, 'options' should be an object.`);
785
- f = Object.assign(Object.assign({}, e), f);
786
- const p = D(a) ? se(a) : a, O = Array.isArray(f.mark) ? (d, E) => {
787
- for (const S of f.mark) {
788
- if (typeof S != "function")
789
- throw new Error(`Invalid mark: ${S}, 'mark' should be a function.`);
790
- const V = S(d, E);
791
- if (V)
792
- return V;
793
- }
794
- } : f.mark, v = (l = f.enablePatches) !== null && l !== void 0 ? l : !1, I = (i = f.strict) !== null && i !== void 0 ? i : !1, P = {
795
- enableAutoFreeze: (s = f.enableAutoFreeze) !== null && s !== void 0 ? s : !1,
796
- mark: O,
797
- strict: I,
798
- enablePatches: v
799
- };
800
- if (!M(p, P) && typeof p == "object" && p !== null)
801
- throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
802
- const [R, y] = Ae(p, P);
803
- if (typeof t != "function") {
804
- if (!M(p, P))
805
- throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
806
- return [R, y];
807
- }
808
- let z;
809
- try {
810
- z = c(R);
811
- } catch (d) {
812
- throw L(u(R)), d;
813
- }
814
- const oe = (d) => {
815
- const E = u(R);
816
- if (!D(d)) {
817
- if (d !== void 0 && !_(d, R) && (E != null && E.operated))
818
- throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
819
- const V = d == null ? void 0 : d[be];
820
- if (V) {
821
- const he = V[0];
822
- return P.strict && typeof d == "object" && d !== null && J({
823
- rootDraft: E,
824
- value: d,
825
- useRawReturn: !0
826
- }), y([he]);
827
- }
828
- if (d !== void 0)
829
- return typeof d == "object" && d !== null && J({ rootDraft: E, value: d }), y([d]);
830
- }
831
- if (d === R || d === void 0)
832
- return y([]);
833
- const S = u(d);
834
- if (P === S.options) {
835
- if (S.operated)
836
- throw new Error("Cannot return a modified child draft.");
837
- return y([se(d)]);
838
- }
839
- return y([d]);
840
- };
841
- return z instanceof Promise ? z.then(oe, (d) => {
842
- throw L(u(R)), d;
843
- }) : oe(z);
844
- };
845
- }, Se = Pe();
846
- Object.prototype.constructor.toString();
847
- export {
848
- Se as create,
849
- se as current,
850
- D as isDraft,
851
- M as isDraftable,
852
- Pe as makeCreator
853
- };
854
- //# sourceMappingURL=mutative.esm.js.map