@metapages/metapage 1.8.15 → 1.8.16
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.
- package/dist/index.js +44 -46
- package/dist/index.js.map +1 -1
- package/dist/metapage/Metaframe.d.ts +1 -1
- package/dist/metapage/Metaframe.d.ts.map +1 -1
- package/dist/metapage/Metapage.d.ts +10 -10
- package/dist/metapage/Metapage.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/metapage/Metaframe.ts +24 -19
- package/src/metapage/Metapage.ts +36 -17
package/dist/index.js
CHANGED
|
@@ -162,7 +162,7 @@ function se(t, e) {
|
|
|
162
162
|
}
|
|
163
163
|
function qt(t, e = []) {
|
|
164
164
|
if (Object.hasOwnProperty.call(t, "key")) {
|
|
165
|
-
const n = t.parent.copy, s = P(
|
|
165
|
+
const n = t.parent.copy, s = P(pe(n, t.key));
|
|
166
166
|
if (s !== null && (s == null ? void 0 : s.original) !== t.original)
|
|
167
167
|
return null;
|
|
168
168
|
const i = t.parent.type === 3, o = i ? Array.from(t.parent.setMap.keys()).indexOf(t.key) : t.key;
|
|
@@ -183,7 +183,7 @@ function qt(t, e = []) {
|
|
|
183
183
|
function we(t) {
|
|
184
184
|
return Array.isArray(t) ? 1 : t instanceof Map ? 2 : t instanceof Set ? 3 : 0;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function pe(t, e) {
|
|
187
187
|
return we(t) === 2 ? t.get(e) : t[e];
|
|
188
188
|
}
|
|
189
189
|
function Te(t, e, n) {
|
|
@@ -193,7 +193,7 @@ function et(t, e) {
|
|
|
193
193
|
const n = P(t);
|
|
194
194
|
return (n ? Y(n) : t)[e];
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function fe(t, e) {
|
|
197
197
|
return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
|
|
198
198
|
}
|
|
199
199
|
function ot(t) {
|
|
@@ -210,7 +210,7 @@ function _e(t, e) {
|
|
|
210
210
|
function Tn(t, e) {
|
|
211
211
|
for (let n = 0; n < e.length - 1; n += 1) {
|
|
212
212
|
const s = e[n];
|
|
213
|
-
if (t =
|
|
213
|
+
if (t = pe(we(t) === 3 ? Array.from(t) : t, s), typeof t != "object")
|
|
214
214
|
throw new Error(`Cannot resolve patch at '${e.join("/")}'.`);
|
|
215
215
|
}
|
|
216
216
|
return t;
|
|
@@ -367,7 +367,7 @@ function Yt(t, e, n) {
|
|
|
367
367
|
}
|
|
368
368
|
function kn(t, e) {
|
|
369
369
|
const n = t.type === 3 ? t.setMap : t.copy;
|
|
370
|
-
t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && Yt(
|
|
370
|
+
t.finalities.revoke.length > 1 && t.assignedMap.get(e) && n && Yt(pe(n, e), t.finalities.handledSet, t.options);
|
|
371
371
|
}
|
|
372
372
|
function at(t) {
|
|
373
373
|
t.type === 3 && t.copy && (t.copy.clear(), t.setMap.forEach((e) => {
|
|
@@ -388,13 +388,13 @@ function vt(t, e, n, s) {
|
|
|
388
388
|
i && (i.callbacks || (i.callbacks = []), i.callbacks.push((o, r) => {
|
|
389
389
|
var a;
|
|
390
390
|
const u = t.type === 3 ? t.setMap : t.copy;
|
|
391
|
-
if (pe(
|
|
391
|
+
if (fe(pe(u, e), n)) {
|
|
392
392
|
let l = i.original;
|
|
393
393
|
i.copy && (l = i.copy), at(t), ut(t, s, o, r), t.options.enableAutoFreeze && (t.options.updatedValues = (a = t.options.updatedValues) !== null && a !== void 0 ? a : /* @__PURE__ */ new WeakMap(), t.options.updatedValues.set(l, i.original)), Te(u, e, l);
|
|
394
394
|
}
|
|
395
395
|
}), t.options.enableAutoFreeze && i.finalities !== t.finalities && (t.options.enableAutoFreeze = !1)), se(n, t.options) && t.finalities.draft.push(() => {
|
|
396
396
|
const o = t.type === 3 ? t.setMap : t.copy;
|
|
397
|
-
pe(
|
|
397
|
+
fe(pe(o, e), n) && kn(t, e);
|
|
398
398
|
});
|
|
399
399
|
}
|
|
400
400
|
function Hn(t, e, n, s, i) {
|
|
@@ -445,8 +445,8 @@ function Hn(t, e, n, s, i) {
|
|
|
445
445
|
}
|
|
446
446
|
function Nn({ original: t, copy: e, assignedMap: n }, s, i, o, r) {
|
|
447
447
|
n.forEach((a, u) => {
|
|
448
|
-
const l =
|
|
449
|
-
if (
|
|
448
|
+
const l = pe(t, u), c = Fe(pe(e, u)), d = a ? Ie(t, u) ? G.Replace : G.Add : G.Remove;
|
|
449
|
+
if (fe(l, c) && d === G.Replace)
|
|
450
450
|
return;
|
|
451
451
|
const g = s.concat(u), v = _e(g, r);
|
|
452
452
|
i.push(d === G.Remove ? { op: d, path: v } : { op: d, path: v, value: c }), o.push(d === G.Add ? { op: G.Remove, path: v } : d === G.Remove ? { op: G.Add, path: v, value: l } : { op: G.Replace, path: v, value: l });
|
|
@@ -509,7 +509,7 @@ const ze = (t, e, n = !1) => {
|
|
|
509
509
|
},
|
|
510
510
|
set(t, e) {
|
|
511
511
|
const n = P(this), s = Y(n);
|
|
512
|
-
return (!s.has(t) || !
|
|
512
|
+
return (!s.has(t) || !fe(s.get(t), e)) && (X(n), ue(n), n.assignedMap.set(t, !0), n.copy.set(t, e), vt(n, t, e, $e)), this;
|
|
513
513
|
},
|
|
514
514
|
delete(t) {
|
|
515
515
|
if (!this.has(t))
|
|
@@ -734,7 +734,7 @@ const ze = (t, e, n = !1) => {
|
|
|
734
734
|
if (o != null && o.set)
|
|
735
735
|
return o.set.call(t.proxy, n), !0;
|
|
736
736
|
const r = et(Y(t), e), a = P(r);
|
|
737
|
-
return a &&
|
|
737
|
+
return a && fe(a.original, n) ? (t.copy[e] = n, t.assignedMap = (s = t.assignedMap) !== null && s !== void 0 ? s : /* @__PURE__ */ new Map(), t.assignedMap.set(e, !1), !0) : (fe(n, r) && (n !== void 0 || Ie(t.original, e)) || (X(t), ue(t), Ie(t.original, e) && fe(n, t.original[e]) ? t.assignedMap.delete(e) : t.assignedMap.set(e, !0), t.copy[e] = n, vt(t, e, n, $e)), !0);
|
|
738
738
|
},
|
|
739
739
|
has(t, e) {
|
|
740
740
|
return e in Y(t);
|
|
@@ -786,7 +786,7 @@ function Rt(t) {
|
|
|
786
786
|
var v, y;
|
|
787
787
|
const R = P(u);
|
|
788
788
|
let w = c.type === 3 ? c.setMap : c.copy;
|
|
789
|
-
const $ =
|
|
789
|
+
const $ = pe(w, s), b = P($);
|
|
790
790
|
if (b) {
|
|
791
791
|
let A = b.original;
|
|
792
792
|
b.operated && (A = bt($)), at(b), ut(b, $e, d, g), c.options.enableAutoFreeze && (c.options.updatedValues = (v = c.options.updatedValues) !== null && v !== void 0 ? v : /* @__PURE__ */ new WeakMap(), c.options.updatedValues.set(A, b.original)), Te(w, s, A);
|
|
@@ -877,7 +877,7 @@ function tn(t) {
|
|
|
877
877
|
} else
|
|
878
878
|
s = t;
|
|
879
879
|
return wt(s, (o, r) => {
|
|
880
|
-
if (e && pe(
|
|
880
|
+
if (e && fe(pe(e.original, o), r))
|
|
881
881
|
return;
|
|
882
882
|
const a = tn(r);
|
|
883
883
|
a !== r && (s === t && i(), Te(s, o, a));
|
|
@@ -933,7 +933,7 @@ const Vn = (t) => {
|
|
|
933
933
|
const E = (O) => {
|
|
934
934
|
const H = P($);
|
|
935
935
|
if (!be(O)) {
|
|
936
|
-
if (O !== void 0 && !
|
|
936
|
+
if (O !== void 0 && !fe(O, $) && (H != null && H.operated))
|
|
937
937
|
throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
|
|
938
938
|
const L = O == null ? void 0 : O[Ln];
|
|
939
939
|
if (L) {
|
|
@@ -991,7 +991,7 @@ const Jn = gt(fetch), nn = async (t, e) => {
|
|
|
991
991
|
throw "Metapage definition null";
|
|
992
992
|
if (!t.version)
|
|
993
993
|
throw `Missing "version" key in metapage definition: ${JSON.stringify(t)}`;
|
|
994
|
-
let n =
|
|
994
|
+
let n = he(t.version);
|
|
995
995
|
if (n === e)
|
|
996
996
|
return t;
|
|
997
997
|
let s = t;
|
|
@@ -999,23 +999,23 @@ const Jn = gt(fetch), nn = async (t, e) => {
|
|
|
999
999
|
switch (n) {
|
|
1000
1000
|
case "0.2": {
|
|
1001
1001
|
if (j(e, n) > 0)
|
|
1002
|
-
s = Xn(s), n =
|
|
1002
|
+
s = Xn(s), n = he(s.version);
|
|
1003
1003
|
else
|
|
1004
1004
|
throw `Cannot convert from version ${n} to ${e}`;
|
|
1005
1005
|
break;
|
|
1006
1006
|
}
|
|
1007
1007
|
case "0.3": {
|
|
1008
|
-
j(e, n) > 0 ? (s = Qn(s), n =
|
|
1008
|
+
j(e, n) > 0 ? (s = Qn(s), n = he(s.version)) : (s = qn(s), n = he(s.version));
|
|
1009
1009
|
break;
|
|
1010
1010
|
}
|
|
1011
1011
|
case "1": {
|
|
1012
|
-
j(e, n) > 0 ? (s = es(s), n =
|
|
1012
|
+
j(e, n) > 0 ? (s = es(s), n = he(s.version)) : (s = Yn(s), n = he(s.version));
|
|
1013
1013
|
break;
|
|
1014
1014
|
}
|
|
1015
1015
|
case "2": {
|
|
1016
1016
|
if (j(e, n) > 0)
|
|
1017
1017
|
throw `Cannot convert from version ${n} to ${e}, 1 is the latest version`;
|
|
1018
|
-
s = Zn(s), n =
|
|
1018
|
+
s = Zn(s), n = he(s.version);
|
|
1019
1019
|
break;
|
|
1020
1020
|
}
|
|
1021
1021
|
default:
|
|
@@ -1035,7 +1035,7 @@ const Jn = gt(fetch), nn = async (t, e) => {
|
|
|
1035
1035
|
}), es = (t) => C(t, (e) => {
|
|
1036
1036
|
var n, s;
|
|
1037
1037
|
return e.version = "2", (n = e == null ? void 0 : e.meta) != null && n.keywords && (e.meta.tags = e.meta.keywords, delete e.meta.keywords), (s = e == null ? void 0 : e.meta) != null && s.author && (e.meta.authors = [e.meta.author], delete e.meta.author), e;
|
|
1038
|
-
}),
|
|
1038
|
+
}), he = (t) => {
|
|
1039
1039
|
if (t === "latest")
|
|
1040
1040
|
return Le;
|
|
1041
1041
|
if (j(t, "0.2") < 0)
|
|
@@ -1189,7 +1189,7 @@ var Ue = function(t) {
|
|
|
1189
1189
|
for (n = 0; n < s; n += 3)
|
|
1190
1190
|
i += Oe[e[n] >> 2], i += Oe[(e[n] & 3) << 4 | e[n + 1] >> 4], i += Oe[(e[n + 1] & 15) << 2 | e[n + 2] >> 6], i += Oe[e[n + 2] & 63];
|
|
1191
1191
|
return s % 3 === 2 ? i = i.substring(0, i.length - 1) + "=" : s % 3 === 1 && (i = i.substring(0, i.length - 2) + "=="), i;
|
|
1192
|
-
},
|
|
1192
|
+
}, de = function(t) {
|
|
1193
1193
|
var e = t.length * 0.75, n = t.length, s, i = 0, o, r, a, u;
|
|
1194
1194
|
t[t.length - 1] === "=" && (e--, t[t.length - 2] === "=" && e--);
|
|
1195
1195
|
var l = new ArrayBuffer(e), c = new Uint8Array(l);
|
|
@@ -1277,18 +1277,18 @@ const Ke = async (t) => C(t, async (e) => {
|
|
|
1277
1277
|
const e = t, n = e._c;
|
|
1278
1278
|
if (n === Blob.name) {
|
|
1279
1279
|
const r = t;
|
|
1280
|
-
return new Blob([
|
|
1280
|
+
return new Blob([de(e.value)], {
|
|
1281
1281
|
type: r.fileType
|
|
1282
1282
|
});
|
|
1283
1283
|
} else if (n === File.name) {
|
|
1284
1284
|
const r = t;
|
|
1285
|
-
return new File([
|
|
1285
|
+
return new File([de(e.value)], r.name, {
|
|
1286
1286
|
type: r.fileType,
|
|
1287
1287
|
lastModified: r.lastModified
|
|
1288
1288
|
});
|
|
1289
1289
|
} else if (n === ArrayBuffer.name)
|
|
1290
|
-
return
|
|
1291
|
-
const s = t, i =
|
|
1290
|
+
return de(e.value);
|
|
1291
|
+
const s = t, i = de(s.value), o = s._c;
|
|
1292
1292
|
try {
|
|
1293
1293
|
return new globalThis[o](i);
|
|
1294
1294
|
} catch {
|
|
@@ -1299,7 +1299,7 @@ const Ke = async (t) => C(t, async (e) => {
|
|
|
1299
1299
|
return;
|
|
1300
1300
|
const e = t, n = e._c;
|
|
1301
1301
|
if (n === Blob.name) {
|
|
1302
|
-
const r = t, a = new Blob([
|
|
1302
|
+
const r = t, a = new Blob([de(e.value)], {
|
|
1303
1303
|
type: r.fileType
|
|
1304
1304
|
});
|
|
1305
1305
|
return new File([a], "file", {
|
|
@@ -1307,17 +1307,17 @@ const Ke = async (t) => C(t, async (e) => {
|
|
|
1307
1307
|
});
|
|
1308
1308
|
} else if (n === File.name) {
|
|
1309
1309
|
const r = t;
|
|
1310
|
-
return new File([
|
|
1310
|
+
return new File([de(e.value)], r.name, {
|
|
1311
1311
|
type: r.fileType,
|
|
1312
1312
|
lastModified: r.lastModified
|
|
1313
1313
|
});
|
|
1314
1314
|
} else if (n === ArrayBuffer.name) {
|
|
1315
|
-
const r =
|
|
1315
|
+
const r = de(e.value);
|
|
1316
1316
|
return new File([r], "file", {
|
|
1317
1317
|
type: "application/octet-stream"
|
|
1318
1318
|
});
|
|
1319
1319
|
}
|
|
1320
|
-
const s = t, i =
|
|
1320
|
+
const s = t, i = de(s.value), o = s._c;
|
|
1321
1321
|
try {
|
|
1322
1322
|
const r = new globalThis[o](i);
|
|
1323
1323
|
return new File([r], "file", {
|
|
@@ -1334,10 +1334,10 @@ var q;
|
|
|
1334
1334
|
(function(t) {
|
|
1335
1335
|
t.InputsUpdate = "InputsUpdate", t.OutputsUpdate = "OutputsUpdate", t.SetupIframeClientRequest = "SetupIframeClientRequest", t.SetupIframeServerResponseAck = "SetupIframeServerResponseAck", t.HashParamsUpdate = "HashParamsUpdate";
|
|
1336
1336
|
})(q || (q = {}));
|
|
1337
|
-
var
|
|
1337
|
+
var me;
|
|
1338
1338
|
(function(t) {
|
|
1339
1339
|
t.InputsUpdate = "InputsUpdate", t.MessageAck = "MessageAck", t.SetupIframeServerResponse = "SetupIframeServerResponse";
|
|
1340
|
-
})(
|
|
1340
|
+
})(me || (me = {}));
|
|
1341
1341
|
const Li = -32700, Ti = -32600, Pi = -32601, Di = -32602, ki = -32603;
|
|
1342
1342
|
function Hi(t) {
|
|
1343
1343
|
switch (typeof t) {
|
|
@@ -1852,20 +1852,20 @@ class ie extends Ot.EventEmitter {
|
|
|
1852
1852
|
let s = e.data;
|
|
1853
1853
|
if (s.jsonrpc === "2.0") {
|
|
1854
1854
|
var n = s.method;
|
|
1855
|
-
if (!(n ==
|
|
1856
|
-
this.log(`window.message: received message but jsonrpc.parentId=${s.parentId} _parentId=${this._parentId} jsonrpc.iframeId=${s.iframeId} id=${this.id}`);
|
|
1855
|
+
if (!(n == "SetupIframeServerResponse" || s.parentId == this._parentId && s.iframeId == this.id)) {
|
|
1856
|
+
this.log(`window.message: received message (method=${n}) but jsonrpc.parentId=${s.parentId} _parentId=${this._parentId} jsonrpc.iframeId=${s.iframeId} id=${this.id}`);
|
|
1857
1857
|
return;
|
|
1858
1858
|
}
|
|
1859
1859
|
switch (n) {
|
|
1860
|
-
case
|
|
1860
|
+
case me.SetupIframeServerResponse:
|
|
1861
1861
|
this._resolveSetupIframeServerResponse(s.params);
|
|
1862
1862
|
break;
|
|
1863
|
-
case
|
|
1863
|
+
case me.InputsUpdate:
|
|
1864
1864
|
if (this._state !== ae.Ready)
|
|
1865
1865
|
throw "Got InputsUpdate but metaframe is not MetaframeLoadingState.Ready";
|
|
1866
1866
|
this.setInternalInputsAndNotify(s.params.inputs);
|
|
1867
1867
|
break;
|
|
1868
|
-
case
|
|
1868
|
+
case me.MessageAck:
|
|
1869
1869
|
this.debug && this.log(`ACK: ${JSON.stringify(s)}`);
|
|
1870
1870
|
break;
|
|
1871
1871
|
default:
|
|
@@ -2981,7 +2981,7 @@ Error: ${n != null && n.message ? n == null ? void 0 : n.message : n == null ? v
|
|
|
2981
2981
|
},
|
|
2982
2982
|
version: Wt
|
|
2983
2983
|
};
|
|
2984
|
-
this.sendRpcInternal(
|
|
2984
|
+
this.sendRpcInternal(me.SetupIframeServerResponse, e);
|
|
2985
2985
|
}
|
|
2986
2986
|
registered(e) {
|
|
2987
2987
|
if (this.log({ m: "MetapageIFrameRpcClient.registered", inputs: this.inputs }), !this._loaded) {
|
|
@@ -2993,7 +2993,7 @@ Error: ${n != null && n.message ? n == null ? void 0 : n.message : n == null ? v
|
|
|
2993
2993
|
}
|
|
2994
2994
|
}
|
|
2995
2995
|
async sendInputs(e) {
|
|
2996
|
-
e && (e = await Ke(e), !this.isDisposed() && this.sendRpc(
|
|
2996
|
+
e && (e = await Ke(e), !this.isDisposed() && this.sendRpc(me.InputsUpdate, {
|
|
2997
2997
|
inputs: e,
|
|
2998
2998
|
parentId: this._parentId
|
|
2999
2999
|
}));
|
|
@@ -3016,7 +3016,7 @@ Error: ${n != null && n.message ? n == null ? void 0 : n.message : n == null ? v
|
|
|
3016
3016
|
var n = {
|
|
3017
3017
|
message: e
|
|
3018
3018
|
};
|
|
3019
|
-
this.sendRpc(
|
|
3019
|
+
this.sendRpc(me.MessageAck, n);
|
|
3020
3020
|
}
|
|
3021
3021
|
}
|
|
3022
3022
|
log(e) {
|
|
@@ -3056,7 +3056,7 @@ const ge = C({
|
|
|
3056
3056
|
inputs: {},
|
|
3057
3057
|
outputs: {}
|
|
3058
3058
|
}
|
|
3059
|
-
}, (t) => t), Vi = (t) =>
|
|
3059
|
+
}, (t) => t), Vi = (t) => he(t), Ri = (t, e) => !!(!e || e === "**" || t === e || _i.isMatch(t, e)), Oi = "bcbcbc";
|
|
3060
3060
|
class ee extends Ns {
|
|
3061
3061
|
static async from(e, n) {
|
|
3062
3062
|
if (e == null)
|
|
@@ -3324,13 +3324,11 @@ class ee extends Ns {
|
|
|
3324
3324
|
return;
|
|
3325
3325
|
var n = r.method;
|
|
3326
3326
|
const a = r.iframeId;
|
|
3327
|
-
if (!a)
|
|
3327
|
+
if (!a || n !== "SetupIframeClientRequest" && r.parentId !== this._id)
|
|
3328
3328
|
return;
|
|
3329
3329
|
const u = this.getMetaframe(a);
|
|
3330
|
-
if (!u)
|
|
3331
|
-
this.error(`💥 onMessage no metaframe id=${a}`);
|
|
3330
|
+
if (!u)
|
|
3332
3331
|
return;
|
|
3333
|
-
}
|
|
3334
3332
|
switch (r._messageCount = ++this._internalReceivedMessageCounter, this.debug && this.log(`processing ${JSON.stringify(r, null, " ").substring(0, 500)}`), n) {
|
|
3335
3333
|
case q.SetupIframeClientRequest:
|
|
3336
3334
|
u.register();
|
|
@@ -3575,7 +3573,7 @@ export {
|
|
|
3575
3573
|
Di as INVALID_PARAMS,
|
|
3576
3574
|
Ti as INVALID_REQUEST,
|
|
3577
3575
|
q as JsonRpcMethodsFromChild,
|
|
3578
|
-
|
|
3576
|
+
me as JsonRpcMethodsFromParent,
|
|
3579
3577
|
Mi as METAFRAME_JSON_FILE,
|
|
3580
3578
|
Ii as METAPAGE_KEY_DEFINITION,
|
|
3581
3579
|
Ci as METAPAGE_KEY_STATE,
|
|
@@ -3607,7 +3605,7 @@ export {
|
|
|
3607
3605
|
Bi as generateNonce,
|
|
3608
3606
|
Vi as getLibraryVersionMatching,
|
|
3609
3607
|
te as getMatchingMetaframeVersion,
|
|
3610
|
-
|
|
3608
|
+
he as getMatchingMetapageVersion,
|
|
3611
3609
|
wi as getMetaframeDefinitionFromUrl,
|
|
3612
3610
|
bi as getMetapageDefinitionFromUrl,
|
|
3613
3611
|
Ni as getUrlParam,
|