@metapages/metapage 1.10.5 → 1.10.7
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/README.md +7 -7
- package/dist/index.js +96 -84
- package/dist/index.js.map +1 -1
- package/dist/metapage/Metapage.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/metapage/Metapage.ts +40 -1
- package/src/metapage/MetapageIFrameRpcClient.ts +1 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
renderMetapage,
|
|
37
37
|
Metapage,
|
|
38
38
|
Metaframe,
|
|
39
|
-
} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.
|
|
39
|
+
} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.7";
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
## Quick Start
|
|
@@ -82,7 +82,7 @@ The `renderMetapage` function the `react-grid-layout` layout in `metapage.json`:
|
|
|
82
82
|
If you're building a component to use in a metapage:
|
|
83
83
|
|
|
84
84
|
```javascript
|
|
85
|
-
import { Metaframe } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.
|
|
85
|
+
import { Metaframe } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.7";
|
|
86
86
|
|
|
87
87
|
const metaframe = new Metaframe();
|
|
88
88
|
|
|
@@ -223,7 +223,7 @@ metaframe.onInput("file", (file) => {
|
|
|
223
223
|
<div id="metapage-container"></div>
|
|
224
224
|
|
|
225
225
|
<script type="module">
|
|
226
|
-
import { renderMetapage } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.
|
|
226
|
+
import { renderMetapage } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.7";
|
|
227
227
|
|
|
228
228
|
const definition = await fetch(
|
|
229
229
|
"https://metapage.io/m/87ae11673508447e883b598bf7da9c5d/metapage.json",
|
|
@@ -258,7 +258,7 @@ metaframe.onInput("file", (file) => {
|
|
|
258
258
|
### Building a Metaframe Component
|
|
259
259
|
|
|
260
260
|
```javascript
|
|
261
|
-
import { Metaframe } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.
|
|
261
|
+
import { Metaframe } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.7";
|
|
262
262
|
|
|
263
263
|
const metaframe = new Metaframe();
|
|
264
264
|
|
|
@@ -335,7 +335,7 @@ Metaframes can read and write to their URL hash parameters:
|
|
|
335
335
|
import {
|
|
336
336
|
getHashParamValueJsonFromWindow,
|
|
337
337
|
setHashParamValueJsonInWindow,
|
|
338
|
-
} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.
|
|
338
|
+
} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.7";
|
|
339
339
|
|
|
340
340
|
// Read from URL hash
|
|
341
341
|
const config = getHashParamValueJsonFromWindow("config");
|
|
@@ -621,7 +621,7 @@ Example minimal metaframe:
|
|
|
621
621
|
</head>
|
|
622
622
|
<body>
|
|
623
623
|
<script type="module">
|
|
624
|
-
import { Metaframe } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.
|
|
624
|
+
import { Metaframe } from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.7";
|
|
625
625
|
|
|
626
626
|
const metaframe = new Metaframe();
|
|
627
627
|
|
|
@@ -645,7 +645,7 @@ import {
|
|
|
645
645
|
MetapageDefinition,
|
|
646
646
|
MetaframeInputMap,
|
|
647
647
|
MetapageInstanceInputs,
|
|
648
|
-
} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.
|
|
648
|
+
} from "https://cdn.jsdelivr.net/npm/@metapages/metapage@1.10.7";
|
|
649
649
|
|
|
650
650
|
const definition: MetapageDefinition = {
|
|
651
651
|
metaframes: {
|
package/dist/index.js
CHANGED
|
@@ -1017,7 +1017,7 @@ const Bn = (t) => {
|
|
|
1017
1017
|
throw je(T(M)), O;
|
|
1018
1018
|
}) : P(E);
|
|
1019
1019
|
};
|
|
1020
|
-
},
|
|
1020
|
+
}, I = Bn();
|
|
1021
1021
|
Object.prototype.constructor.toString();
|
|
1022
1022
|
const Vs = (t) => {
|
|
1023
1023
|
var s, n, i;
|
|
@@ -1040,7 +1040,7 @@ const Vs = (t) => {
|
|
|
1040
1040
|
throw "Metapage definition null";
|
|
1041
1041
|
if (!t.version) {
|
|
1042
1042
|
const n = Vs(t);
|
|
1043
|
-
t =
|
|
1043
|
+
t = I(t, (i) => {
|
|
1044
1044
|
i.version = n;
|
|
1045
1045
|
});
|
|
1046
1046
|
}
|
|
@@ -1067,7 +1067,7 @@ const Vs = (t) => {
|
|
|
1067
1067
|
throw "Metapage definition null";
|
|
1068
1068
|
if (!t.version) {
|
|
1069
1069
|
const i = Vs(t);
|
|
1070
|
-
t =
|
|
1070
|
+
t = I(t, (o) => {
|
|
1071
1071
|
o.version = i;
|
|
1072
1072
|
});
|
|
1073
1073
|
}
|
|
@@ -1102,17 +1102,17 @@ const Vs = (t) => {
|
|
|
1102
1102
|
throw `Unknow version ${s} to ${e}`;
|
|
1103
1103
|
}
|
|
1104
1104
|
return n;
|
|
1105
|
-
}, Wn = (t) =>
|
|
1105
|
+
}, Wn = (t) => I(t, (e) => {
|
|
1106
1106
|
e.version = "0.3";
|
|
1107
|
-
}), Gn = (t) =>
|
|
1107
|
+
}), Gn = (t) => I(t, (e) => {
|
|
1108
1108
|
e.version = "0.2";
|
|
1109
|
-
}), Jn = (t) =>
|
|
1109
|
+
}), Jn = (t) => I(t, (e) => {
|
|
1110
1110
|
const s = e;
|
|
1111
1111
|
delete s.plugins, s.version = "1";
|
|
1112
|
-
}), Qn = (t) =>
|
|
1112
|
+
}), Qn = (t) => I(t, (e) => (e.version = "0.3", e)), Kn = (t) => I(t, (e) => {
|
|
1113
1113
|
var s, n;
|
|
1114
1114
|
return e.version = "1", (s = e == null ? void 0 : e.meta) != null && s.tags && (e.meta.keywords = e.meta.tags, delete e.meta.tags), (n = e == null ? void 0 : e.meta) != null && n.authors && (e.meta.author = e.meta.authors[0], delete e.meta.authors), e;
|
|
1115
|
-
}), Xn = (t) =>
|
|
1115
|
+
}), Xn = (t) => I(t, (e) => {
|
|
1116
1116
|
var s, n;
|
|
1117
1117
|
return e.version = "2", (s = e == null ? void 0 : e.meta) != null && s.keywords && (e.meta.tags = e.meta.keywords, delete e.meta.keywords), (n = e == null ? void 0 : e.meta) != null && n.author && (e.meta.authors = [e.meta.author], delete e.meta.author), e;
|
|
1118
1118
|
}), wt = (t) => {
|
|
@@ -1146,7 +1146,7 @@ const Vs = (t) => {
|
|
|
1146
1146
|
throw "Metaframe definition null";
|
|
1147
1147
|
if (!t.version) {
|
|
1148
1148
|
const n = Ws(t);
|
|
1149
|
-
t =
|
|
1149
|
+
t = I(t, (i) => {
|
|
1150
1150
|
i.version = n;
|
|
1151
1151
|
});
|
|
1152
1152
|
}
|
|
@@ -1173,7 +1173,7 @@ const Vs = (t) => {
|
|
|
1173
1173
|
throw "Metaframe definition null";
|
|
1174
1174
|
if (!t.version) {
|
|
1175
1175
|
const i = Ws(t);
|
|
1176
|
-
t =
|
|
1176
|
+
t = I(t, (o) => {
|
|
1177
1177
|
o.version = i;
|
|
1178
1178
|
});
|
|
1179
1179
|
}
|
|
@@ -1221,11 +1221,11 @@ const Vs = (t) => {
|
|
|
1221
1221
|
return;
|
|
1222
1222
|
const s = await Zn(t);
|
|
1223
1223
|
return s != null && s.hashParams && (s.hashParams = Yn(s.hashParams)), s;
|
|
1224
|
-
}, ei = (t) =>
|
|
1224
|
+
}, ei = (t) => I(t, (e) => {
|
|
1225
1225
|
e.version = "0.3", delete e.allow;
|
|
1226
|
-
}), si = (t) =>
|
|
1226
|
+
}), si = (t) => I(t, (e) => {
|
|
1227
1227
|
e.version = "0.4";
|
|
1228
|
-
}), ni = (t) =>
|
|
1228
|
+
}), ni = (t) => I(t, (e) => {
|
|
1229
1229
|
if (e.version = "0.5", !(e != null && e.metadata))
|
|
1230
1230
|
return;
|
|
1231
1231
|
const s = e.metadata.title;
|
|
@@ -1234,7 +1234,7 @@ const Vs = (t) => {
|
|
|
1234
1234
|
delete e.metadata.descriptionUrl, e.metadata.description = n;
|
|
1235
1235
|
const i = e.metadata.keywords;
|
|
1236
1236
|
delete e.metadata.keywords, e.metadata.tags = i;
|
|
1237
|
-
}), ii = (t) =>
|
|
1237
|
+
}), ii = (t) => I(t, (e) => {
|
|
1238
1238
|
if (e.version = "0.4", !(e != null && e.metadata))
|
|
1239
1239
|
return;
|
|
1240
1240
|
const s = e.metadata.name;
|
|
@@ -1243,24 +1243,24 @@ const Vs = (t) => {
|
|
|
1243
1243
|
delete e.metadata.description, e.metadata.descriptionUrl = n;
|
|
1244
1244
|
const i = e.metadata.tags;
|
|
1245
1245
|
delete e.metadata.tags, e.metadata.keywords = i;
|
|
1246
|
-
}), ri = (t) =>
|
|
1246
|
+
}), ri = (t) => I(t, (e) => {
|
|
1247
1247
|
var s;
|
|
1248
1248
|
e.version = "1", (s = e == null ? void 0 : e.metadata) != null && s.operations && delete e.metadata.operations;
|
|
1249
|
-
}), oi = (t) =>
|
|
1249
|
+
}), oi = (t) => I(t, (e) => {
|
|
1250
1250
|
var s;
|
|
1251
1251
|
e.version = "0.6", (s = e == null ? void 0 : e.metadata) != null && s.operations && delete e.metadata.operations;
|
|
1252
|
-
}), ai = (t) =>
|
|
1252
|
+
}), ai = (t) => I(t, (e) => {
|
|
1253
1253
|
var s, n;
|
|
1254
1254
|
return e.version = "1", (s = e == null ? void 0 : e.metadata) != null && s.authors && (e.metadata.author = (n = e == null ? void 0 : e.metadata) == null ? void 0 : n.authors[0], delete e.metadata.authors), e;
|
|
1255
|
-
}), ui = (t) =>
|
|
1255
|
+
}), ui = (t) => I(t, (e) => {
|
|
1256
1256
|
var s;
|
|
1257
1257
|
return e.version = "2", (s = e == null ? void 0 : e.metadata) != null && s.author && (e.metadata.authors = [
|
|
1258
1258
|
e.metadata.author
|
|
1259
1259
|
], delete e.metadata.author), e;
|
|
1260
|
-
}), ci = (t) =>
|
|
1260
|
+
}), ci = (t) => I(t, (e) => {
|
|
1261
1261
|
var s;
|
|
1262
1262
|
e.version = "0.6", (s = e == null ? void 0 : e.metadata) != null && s.operations && delete e.metadata.operations;
|
|
1263
|
-
}), li = (t) =>
|
|
1263
|
+
}), li = (t) => I(t, (e) => {
|
|
1264
1264
|
var s;
|
|
1265
1265
|
e.version = "0.5", (s = e == null ? void 0 : e.metadata) != null && s.operations && delete e.metadata.operations;
|
|
1266
1266
|
}), ot = (t) => {
|
|
@@ -2175,10 +2175,10 @@ function Li(t) {
|
|
|
2175
2175
|
}
|
|
2176
2176
|
return t;
|
|
2177
2177
|
}
|
|
2178
|
-
var
|
|
2178
|
+
var C;
|
|
2179
2179
|
(function(t) {
|
|
2180
2180
|
t.Inputs = "inputs", t.Outputs = "outputs", t.State = "state", t.Definition = "definition", t.DefinitionUpdate = "definitionupdate", t.Error = "error", t.Warning = "warning", t.UrlHashUpdate = "urlhashupdate", t.Message = "Message";
|
|
2181
|
-
})(
|
|
2181
|
+
})(C || (C = {}));
|
|
2182
2182
|
var q;
|
|
2183
2183
|
(function(t) {
|
|
2184
2184
|
t.InputsUpdate = "InputsUpdate", t.OutputsUpdate = "OutputsUpdate", t.SetupIframeClientRequest = "SetupIframeClientRequest", t.SetupIframeServerResponseAck = "SetupIframeServerResponseAck", t.HashParamsUpdate = "HashParamsUpdate";
|
|
@@ -2520,7 +2520,7 @@ class rr extends os.EventEmitter {
|
|
|
2520
2520
|
return this._definition;
|
|
2521
2521
|
}
|
|
2522
2522
|
}
|
|
2523
|
-
const de = (t, e) => e ?
|
|
2523
|
+
const de = (t, e) => e ? I(t, (s) => {
|
|
2524
2524
|
Object.keys(e).forEach((n) => {
|
|
2525
2525
|
e[n] === void 0 ? delete s[n] : s[n] = e[n];
|
|
2526
2526
|
});
|
|
@@ -3742,7 +3742,7 @@ class zr extends os.EventEmitter {
|
|
|
3742
3742
|
s = s.substring(1);
|
|
3743
3743
|
s = window.location.protocol + "//" + window.location.hostname + (window.location.port && window.location.port != "" ? ":" + window.location.port : "") + "/" + s;
|
|
3744
3744
|
}
|
|
3745
|
-
if (this.url = s, this._metapage = e, this._debug = r, r) {
|
|
3745
|
+
if (this.url = s, this._metapage = e, this._debug = r, r && !s.startsWith("data:")) {
|
|
3746
3746
|
var a = new URL(this.url);
|
|
3747
3747
|
a.searchParams.set(Gt.mp_debug, "true"), this.url = a.href;
|
|
3748
3748
|
}
|
|
@@ -3793,7 +3793,7 @@ class zr extends os.EventEmitter {
|
|
|
3793
3793
|
return this._definition = s, this._definition;
|
|
3794
3794
|
} catch (s) {
|
|
3795
3795
|
var e = this.getDefinitionUrl();
|
|
3796
|
-
this.emit(
|
|
3796
|
+
this.emit(C.Warning, `Failed to fetch or convert: ${e}
|
|
3797
3797
|
Error: ${s != null && s.message ? s == null ? void 0 : s.message : s == null ? void 0 : s.toString()}`);
|
|
3798
3798
|
}
|
|
3799
3799
|
}
|
|
@@ -3807,9 +3807,9 @@ Error: ${s != null && s.message ? s == null ? void 0 : s.message : s == null ? v
|
|
|
3807
3807
|
const s = e;
|
|
3808
3808
|
if (this.inputs = de(this.inputs, e), this.inputs === s)
|
|
3809
3809
|
return this;
|
|
3810
|
-
if (this._loaded || (this._sendInputsAfterRegistration = !0), this._iframe.parentNode && this._loaded && this.sendInputs(e), this.emit(
|
|
3810
|
+
if (this._loaded || (this._sendInputsAfterRegistration = !0), this._iframe.parentNode && this._loaded && this.sendInputs(e), this.emit(C.Inputs, this.inputs), this._metapage.listenerCount(C.Inputs) > 0) {
|
|
3811
3811
|
var n = {};
|
|
3812
|
-
n[this.id] = e, this._metapage.emit(
|
|
3812
|
+
n[this.id] = e, this._metapage.emit(C.Inputs, n);
|
|
3813
3813
|
}
|
|
3814
3814
|
return this;
|
|
3815
3815
|
}
|
|
@@ -3822,28 +3822,28 @@ Error: ${s != null && s.message ? s == null ? void 0 : s.message : s == null ? v
|
|
|
3822
3822
|
const s = e;
|
|
3823
3823
|
if (this.outputs = de(this.outputs, e), this.outputs === s)
|
|
3824
3824
|
return this;
|
|
3825
|
-
if (this.emit(
|
|
3825
|
+
if (this.emit(C.Outputs, e), this._metapage.listenerCount(C.Outputs) > 0) {
|
|
3826
3826
|
var n = {};
|
|
3827
|
-
n[this.id] = e, this._metapage.emit(
|
|
3827
|
+
n[this.id] = e, this._metapage.emit(C.Outputs, n);
|
|
3828
3828
|
}
|
|
3829
3829
|
}
|
|
3830
3830
|
onInputs(e) {
|
|
3831
|
-
return this.addListenerReturnDisposer(
|
|
3831
|
+
return this.addListenerReturnDisposer(C.Inputs, e);
|
|
3832
3832
|
}
|
|
3833
3833
|
onInput(e, s) {
|
|
3834
3834
|
var n = function(i) {
|
|
3835
3835
|
i.hasOwnProperty(e) && s(i[e]);
|
|
3836
3836
|
};
|
|
3837
|
-
return this.addListenerReturnDisposer(
|
|
3837
|
+
return this.addListenerReturnDisposer(C.Inputs, n);
|
|
3838
3838
|
}
|
|
3839
3839
|
onOutputs(e) {
|
|
3840
|
-
return this.addListenerReturnDisposer(
|
|
3840
|
+
return this.addListenerReturnDisposer(C.Outputs, e);
|
|
3841
3841
|
}
|
|
3842
3842
|
onOutput(e, s) {
|
|
3843
3843
|
var n = function(i) {
|
|
3844
3844
|
i.hasOwnProperty(e) && s(i[e]);
|
|
3845
3845
|
};
|
|
3846
|
-
return this.addListenerReturnDisposer(
|
|
3846
|
+
return this.addListenerReturnDisposer(C.Outputs, n);
|
|
3847
3847
|
}
|
|
3848
3848
|
isDisposed() {
|
|
3849
3849
|
return this.inputs === void 0;
|
|
@@ -3934,7 +3934,7 @@ Error: ${s != null && s.message ? s == null ? void 0 : s.message : s == null ? v
|
|
|
3934
3934
|
}
|
|
3935
3935
|
}
|
|
3936
3936
|
}
|
|
3937
|
-
const vt =
|
|
3937
|
+
const vt = I({
|
|
3938
3938
|
metaframes: {
|
|
3939
3939
|
inputs: {},
|
|
3940
3940
|
outputs: {}
|
|
@@ -3954,7 +3954,7 @@ class nt extends rr {
|
|
|
3954
3954
|
return n.debug = (s == null ? void 0 : s.debug) || !1, n.setDefinition(e);
|
|
3955
3955
|
}
|
|
3956
3956
|
constructor(e) {
|
|
3957
|
-
super(), this._state = vt, this._metaframes =
|
|
3957
|
+
super(), this._state = vt, this._metaframes = I({}, (s) => s), this.debug = Fe(), this._originalSecretHashParams = {}, this._originalSecretQueryParams = {}, this._injectedSecrets = {}, this._injectedQuerySecrets = {}, this._internalReceivedMessageCounter = 0, this._cachedInputLookupMap = I({}, (s) => s), this._inputMap = {}, this._id = e && e.id ? e.id : or(), this._consoleBackgroundColor = e && e.color ? e.color : Vr, this.addPipe = this.addPipe.bind(this), this.dispose = this.dispose.bind(this), this.addMetaframe = this.addMetaframe.bind(this), this.getInputsFromOutput = this.getInputsFromOutput.bind(this), this.getMetaframe = this.getMetaframe.bind(this), this.getMetaframeIds = this.getMetaframeIds.bind(this), this.getMetaframe = this.getMetaframe.bind(this), this.getMetaframes = this.getMetaframes.bind(this), this.getState = this.getState.bind(this), this.getStateMetaframes = this.getStateMetaframes.bind(this), this.isValidJSONRpcMessage = this.isValidJSONRpcMessage.bind(this), this.log = this.log.bind(this), this.logInternal = this.logInternal.bind(this), this.metaframeIds = this.metaframeIds.bind(this), this.metaframes = this.metaframes.bind(this), this.onMessage = this.onMessage.bind(this), this.onMessageJsonRpc = this.onMessageJsonRpc.bind(this), this.removeAll = this.removeAll.bind(this), this.removeMetaframe = this.removeMetaframe.bind(this), this.setDebugFromUrlParams = this.setDebugFromUrlParams.bind(this), this.setDefinition = this.setDefinition.bind(this), this.updateDefinition = this.updateDefinition.bind(this), this.setInput = this.setInput.bind(this), this.setInputs = this.setInputs.bind(this), this.setOutputs = this.setOutputs.bind(this), this.onInputs = this.onInputs.bind(this), this.onOutputs = this.onOutputs.bind(this), this.onState = this.onState.bind(this), this.setMetaframeOutputs = this.setMetaframeOutputs.bind(this), this.setInputStateOnlyMetaframeInputValue = this.setInputStateOnlyMetaframeInputValue.bind(this), this.setInputStateOnlyMetaframeInputMap = this.setInputStateOnlyMetaframeInputMap.bind(this), this.setInputStateOnlyMetapageInstanceInputs = this.setInputStateOnlyMetapageInstanceInputs.bind(this), this.setOutputStateOnlyMetaframeInputValue = this.setOutputStateOnlyMetaframeInputValue.bind(this), this.setOutputStateOnlyMetaframeInputMap = this.setOutputStateOnlyMetaframeInputMap.bind(this), this.setOutputStateOnlyMetapageInstanceInputs = this.setOutputStateOnlyMetapageInstanceInputs.bind(this), this.setMetadata = this.setMetadata.bind(this), this.setMetaframeClientInputAndSentClientEvent = this.setMetaframeClientInputAndSentClientEvent.bind(this), this.setState = this.setState.bind(this), this.isDisposed = this.isDisposed.bind(this), this._emitDefinitionEvent = this._emitDefinitionEvent.bind(this), this._emitDefinitionUpdateEvent = this._emitDefinitionUpdateEvent.bind(this), ve().then(() => {
|
|
3958
3958
|
this.isDisposed() || (window.addEventListener("message", this.onMessage), this.log("Initialized"));
|
|
3959
3959
|
});
|
|
3960
3960
|
}
|
|
@@ -3967,13 +3967,13 @@ class nt extends rr {
|
|
|
3967
3967
|
};
|
|
3968
3968
|
}
|
|
3969
3969
|
onInputs(e) {
|
|
3970
|
-
return this.addListenerReturnDisposer(
|
|
3970
|
+
return this.addListenerReturnDisposer(C.Inputs, e);
|
|
3971
3971
|
}
|
|
3972
3972
|
onOutputs(e) {
|
|
3973
|
-
return this.addListenerReturnDisposer(
|
|
3973
|
+
return this.addListenerReturnDisposer(C.Outputs, e);
|
|
3974
3974
|
}
|
|
3975
3975
|
onState(e) {
|
|
3976
|
-
return this.addListenerReturnDisposer(
|
|
3976
|
+
return this.addListenerReturnDisposer(C.State, e);
|
|
3977
3977
|
}
|
|
3978
3978
|
setDebugFromUrlParams() {
|
|
3979
3979
|
const e = new URL(window.location.href);
|
|
@@ -3983,10 +3983,10 @@ class nt extends rr {
|
|
|
3983
3983
|
return this._state;
|
|
3984
3984
|
}
|
|
3985
3985
|
setState(e) {
|
|
3986
|
-
this._state =
|
|
3986
|
+
this._state = I(e, (s) => s), this.getMetaframeIds().forEach((s) => {
|
|
3987
3987
|
var n, i;
|
|
3988
3988
|
(n = this.getMetaframe(s)) == null || n.setInputs(this._state.metaframes.inputs[s]), (i = this.getMetaframe(s)) == null || i.setOutputs(this._state.metaframes.outputs[s]);
|
|
3989
|
-
}), this.listenerCount(
|
|
3989
|
+
}), this.listenerCount(C.State) > 0 && vt !== this._state && this.emit(C.State, this._state);
|
|
3990
3990
|
}
|
|
3991
3991
|
getStateMetaframes() {
|
|
3992
3992
|
return this._state.metaframes;
|
|
@@ -4002,6 +4002,8 @@ class nt extends rr {
|
|
|
4002
4002
|
this.log(`Warning: Cannot inject secrets for unknown metaframe: ${s}`);
|
|
4003
4003
|
return;
|
|
4004
4004
|
}
|
|
4005
|
+
if (i.url.startsWith("data:"))
|
|
4006
|
+
return;
|
|
4005
4007
|
this._injectedSecrets[s] || (this._injectedSecrets[s] = {}), this._injectedQuerySecrets[s] || (this._injectedQuerySecrets[s] = {}), this._originalSecretHashParams[s] || (this._originalSecretHashParams[s] = {}), this._originalSecretQueryParams[s] || (this._originalSecretQueryParams[s] = {});
|
|
4006
4008
|
const o = new URL(i.url);
|
|
4007
4009
|
n.hashParams && Object.entries(n.hashParams).forEach(([c, l]) => {
|
|
@@ -4023,13 +4025,13 @@ class nt extends rr {
|
|
|
4023
4025
|
}), Object.entries(this._injectedQuerySecrets[s]).forEach(([c, l]) => {
|
|
4024
4026
|
const f = btoa(encodeURIComponent(l));
|
|
4025
4027
|
r.searchParams.set(c, f);
|
|
4026
|
-
}), i.url = r.href, (u = (a = this._definition) == null ? void 0 : a.metaframes) != null && u[s] && (this._definition =
|
|
4028
|
+
}), i.url = r.href, (u = (a = this._definition) == null ? void 0 : a.metaframes) != null && u[s] && (this._definition = I(this._definition, (c) => {
|
|
4027
4029
|
c.metaframes[s].url = r.href;
|
|
4028
4030
|
}));
|
|
4029
4031
|
});
|
|
4030
4032
|
}
|
|
4031
4033
|
_getDefinitionWithoutSecrets() {
|
|
4032
|
-
return Object.keys(this._injectedSecrets).length === 0 && Object.keys(this._injectedQuerySecrets).length === 0 ? this._definition :
|
|
4034
|
+
return Object.keys(this._injectedSecrets).length === 0 && Object.keys(this._injectedQuerySecrets).length === 0 ? this._definition : I(this._definition, (e) => {
|
|
4033
4035
|
(/* @__PURE__ */ new Set([
|
|
4034
4036
|
...Object.keys(this._injectedSecrets),
|
|
4035
4037
|
...Object.keys(this._injectedQuerySecrets)
|
|
@@ -4038,7 +4040,7 @@ class nt extends rr {
|
|
|
4038
4040
|
if (!((l = e.metaframes) != null && l[n]))
|
|
4039
4041
|
return;
|
|
4040
4042
|
const i = this._metaframes[n];
|
|
4041
|
-
if (!i)
|
|
4043
|
+
if (!i || i.url.startsWith("data:"))
|
|
4042
4044
|
return;
|
|
4043
4045
|
let o = i.url;
|
|
4044
4046
|
const r = this._injectedSecrets[n] || {}, a = this._originalSecretHashParams[n] || {};
|
|
@@ -4083,21 +4085,29 @@ class nt extends rr {
|
|
|
4083
4085
|
(!n.metaframes || !n.metaframes[f]) && (u[f] = this._metaframes[f]);
|
|
4084
4086
|
}), Object.keys(u).forEach((f) => {
|
|
4085
4087
|
this.removeMetaframe(f);
|
|
4086
|
-
}), s && (this._state =
|
|
4088
|
+
}), s && (this._state = I(s, (f) => f));
|
|
4087
4089
|
const c = {};
|
|
4088
4090
|
return n.metaframes && Object.keys(n.metaframes).forEach((f) => {
|
|
4089
4091
|
if (!this._metaframes.hasOwnProperty(f)) {
|
|
4090
4092
|
const p = n.metaframes[f], g = this.addMetaframe(f, p);
|
|
4091
4093
|
c[f] = g;
|
|
4092
4094
|
}
|
|
4093
|
-
}),
|
|
4095
|
+
}), n.metaframes && (Object.keys(n.metaframes).forEach((f) => {
|
|
4096
|
+
if (c[f])
|
|
4097
|
+
return;
|
|
4098
|
+
this._inputMap = I(this._inputMap, (g) => {
|
|
4099
|
+
delete g[f];
|
|
4100
|
+
});
|
|
4101
|
+
const p = n.metaframes[f];
|
|
4102
|
+
p.inputs && p.inputs.forEach((g) => this.addPipe(f, g));
|
|
4103
|
+
}), this._cachedInputLookupMap = I({}, (f) => f)), (/* @__PURE__ */ new Set([
|
|
4094
4104
|
...Object.keys(i),
|
|
4095
4105
|
...Object.keys(o)
|
|
4096
4106
|
])).forEach((f) => {
|
|
4097
4107
|
var p, g, m, _, v;
|
|
4098
4108
|
if (this._metaframes[f]) {
|
|
4099
4109
|
const M = i[f] || {}, w = o[f] || {}, E = this._metaframes[f], P = (m = (g = (p = this._definition) == null ? void 0 : p.metaframes) == null ? void 0 : g[f]) == null ? void 0 : m.url;
|
|
4100
|
-
if (!P)
|
|
4110
|
+
if (!P || P.startsWith("data:"))
|
|
4101
4111
|
return;
|
|
4102
4112
|
let O = new URL(P);
|
|
4103
4113
|
if (Object.keys(M).length > 0) {
|
|
@@ -4119,7 +4129,7 @@ class nt extends rr {
|
|
|
4119
4129
|
}), Object.entries(w).forEach(([$, D]) => {
|
|
4120
4130
|
const b = btoa(encodeURIComponent(D));
|
|
4121
4131
|
O.searchParams.set($, b);
|
|
4122
|
-
}), E.url = O.href, (v = (_ = this._definition) == null ? void 0 : _.metaframes) != null && v[f] && (this._definition =
|
|
4132
|
+
}), E.url = O.href, (v = (_ = this._definition) == null ? void 0 : _.metaframes) != null && v[f] && (this._definition = I(this._definition, ($) => {
|
|
4123
4133
|
$.metaframes[f].url = O.href;
|
|
4124
4134
|
}));
|
|
4125
4135
|
}
|
|
@@ -4128,7 +4138,7 @@ class nt extends rr {
|
|
|
4128
4138
|
async setDefinition(e, s) {
|
|
4129
4139
|
const n = this._definition, { newDefinition: i } = await this._applyDefinition(e, s);
|
|
4130
4140
|
return this.isDisposed() ? this : (n !== ln && window.setTimeout(() => {
|
|
4131
|
-
!this.isDisposed() && i === this._definition && (this._emitDefinitionEvent(), s && this.listenerCount(
|
|
4141
|
+
!this.isDisposed() && i === this._definition && (this._emitDefinitionEvent(), s && this.listenerCount(C.State) > 0 && vt !== this._state && this.emit(C.State, this._state));
|
|
4132
4142
|
}, 0), this);
|
|
4133
4143
|
}
|
|
4134
4144
|
async updateDefinition(e, s) {
|
|
@@ -4137,26 +4147,26 @@ class nt extends rr {
|
|
|
4137
4147
|
if (!this.isDisposed()) {
|
|
4138
4148
|
this._emitDefinitionUpdateEvent(n, i);
|
|
4139
4149
|
const o = Object.keys(n).length > 0 || Object.keys(i).length > 0;
|
|
4140
|
-
this.listenerCount(
|
|
4150
|
+
this.listenerCount(C.State) > 0 && (o || s && vt !== this._state) && this.emit(C.State, this._state);
|
|
4141
4151
|
}
|
|
4142
4152
|
}, 0), this);
|
|
4143
4153
|
}
|
|
4144
4154
|
setMetadata(e) {
|
|
4145
|
-
this._definition =
|
|
4155
|
+
this._definition = I(this._definition, (s) => {
|
|
4146
4156
|
s.meta = e;
|
|
4147
4157
|
}), this._emitDefinitionEvent();
|
|
4148
4158
|
}
|
|
4149
4159
|
_emitDefinitionEvent() {
|
|
4150
|
-
if (this.listenerCount(
|
|
4160
|
+
if (this.listenerCount(C.Definition) > 0) {
|
|
4151
4161
|
const e = {
|
|
4152
4162
|
definition: this._getDefinitionWithoutSecrets(),
|
|
4153
4163
|
metaframes: this._metaframes
|
|
4154
4164
|
};
|
|
4155
|
-
this.emit(
|
|
4165
|
+
this.emit(C.Definition, e);
|
|
4156
4166
|
}
|
|
4157
4167
|
}
|
|
4158
4168
|
_emitDefinitionUpdateEvent(e, s) {
|
|
4159
|
-
if (this.listenerCount(
|
|
4169
|
+
if (this.listenerCount(C.DefinitionUpdate) > 0) {
|
|
4160
4170
|
const n = {
|
|
4161
4171
|
definition: this._getDefinitionWithoutSecrets(),
|
|
4162
4172
|
metaframes: {
|
|
@@ -4165,30 +4175,30 @@ class nt extends rr {
|
|
|
4165
4175
|
removed: s
|
|
4166
4176
|
}
|
|
4167
4177
|
};
|
|
4168
|
-
this.emit(
|
|
4178
|
+
this.emit(C.DefinitionUpdate, n);
|
|
4169
4179
|
}
|
|
4170
4180
|
}
|
|
4171
4181
|
addPipe(e, s) {
|
|
4172
|
-
this._inputMap =
|
|
4182
|
+
this._inputMap = I(this._inputMap, (n) => {
|
|
4173
4183
|
n[e] || (n[e] = []), n[e].push(s);
|
|
4174
4184
|
});
|
|
4175
4185
|
}
|
|
4176
4186
|
removeMetaframe(e) {
|
|
4177
|
-
this._metaframes[e] && (this._metaframes[e].dispose(), this._metaframes =
|
|
4187
|
+
this._metaframes[e] && (this._metaframes[e].dispose(), this._metaframes = I(this._metaframes, (s) => {
|
|
4178
4188
|
delete s[e];
|
|
4179
|
-
}), this._state =
|
|
4189
|
+
}), this._state = I(this._state, (s) => {
|
|
4180
4190
|
delete s.metaframes.inputs[e], delete s.metaframes.outputs[e];
|
|
4181
|
-
}), this._inputMap =
|
|
4191
|
+
}), this._inputMap = I(this._inputMap, (s) => {
|
|
4182
4192
|
delete s[e], Object.keys(s).forEach((n) => {
|
|
4183
4193
|
const i = s[n];
|
|
4184
4194
|
let o = 0;
|
|
4185
4195
|
for (; o <= i.length; )
|
|
4186
4196
|
i[o] && i[o].metaframe === e ? i.splice(o, 1) : o++;
|
|
4187
4197
|
});
|
|
4188
|
-
}), delete this._injectedSecrets[e], delete this._injectedQuerySecrets[e], delete this._originalSecretHashParams[e], delete this._originalSecretQueryParams[e], this._cachedInputLookupMap =
|
|
4198
|
+
}), delete this._injectedSecrets[e], delete this._injectedQuerySecrets[e], delete this._originalSecretHashParams[e], delete this._originalSecretQueryParams[e], this._cachedInputLookupMap = I({}, (s) => s));
|
|
4189
4199
|
}
|
|
4190
4200
|
removeAll() {
|
|
4191
|
-
Object.keys(this._metaframes).forEach((e) => this._metaframes[e].dispose()), this._metaframes =
|
|
4201
|
+
Object.keys(this._metaframes).forEach((e) => this._metaframes[e].dispose()), this._metaframes = I({}, (e) => e), this._state = vt, this._inputMap = I({}, (e) => e), this._cachedInputLookupMap = I({}, (e) => e), this._injectedSecrets = {}, this._injectedQuerySecrets = {}, this._originalSecretHashParams = {}, this._originalSecretQueryParams = {};
|
|
4192
4202
|
}
|
|
4193
4203
|
metaframes() {
|
|
4194
4204
|
return this.getMetaframes();
|
|
@@ -4216,10 +4226,10 @@ class nt extends rr {
|
|
|
4216
4226
|
if (!s.url)
|
|
4217
4227
|
throw this.emitErrorMessage(`Metaframe definition missing url id=${e}`), `Metaframe definition missing url id=${e}`;
|
|
4218
4228
|
var n = new zr(this, s.url, e, this._id, this._consoleBackgroundColor, this.debug).setMetapage(this);
|
|
4219
|
-
return this._metaframes =
|
|
4229
|
+
return this._metaframes = I(this._metaframes, (i) => {
|
|
4220
4230
|
i[e] = n;
|
|
4221
|
-
}), n.addListener(
|
|
4222
|
-
this.emit(
|
|
4231
|
+
}), n.addListener(C.Error, (i) => {
|
|
4232
|
+
this.emit(C.Error, {
|
|
4223
4233
|
metaframeId: n.id,
|
|
4224
4234
|
metaframeUrl: n.url,
|
|
4225
4235
|
error: i
|
|
@@ -4236,12 +4246,12 @@ class nt extends rr {
|
|
|
4236
4246
|
this.logInternal(e, "f00", this._consoleBackgroundColor), this.emitErrorMessage(`${e}`);
|
|
4237
4247
|
}
|
|
4238
4248
|
emitErrorMessage(e) {
|
|
4239
|
-
this.emit(
|
|
4249
|
+
this.emit(C.Error, e);
|
|
4240
4250
|
}
|
|
4241
4251
|
getInputsFromOutput(e, s) {
|
|
4242
|
-
return this._cachedInputLookupMap[e] || (this._cachedInputLookupMap =
|
|
4243
|
-
n[e] =
|
|
4244
|
-
})), this._cachedInputLookupMap[e][s] || (this._cachedInputLookupMap =
|
|
4252
|
+
return this._cachedInputLookupMap[e] || (this._cachedInputLookupMap = I(this._cachedInputLookupMap, (n) => {
|
|
4253
|
+
n[e] = I({}, (i) => i);
|
|
4254
|
+
})), this._cachedInputLookupMap[e][s] || (this._cachedInputLookupMap = I(this._cachedInputLookupMap, (n) => {
|
|
4245
4255
|
var i = [];
|
|
4246
4256
|
n[e][s] = i, Object.keys(this._inputMap).forEach((o) => {
|
|
4247
4257
|
o !== e && this._inputMap[o].forEach((r) => {
|
|
@@ -4266,7 +4276,7 @@ class nt extends rr {
|
|
|
4266
4276
|
}
|
|
4267
4277
|
setInput(e, s, n) {
|
|
4268
4278
|
var i, o;
|
|
4269
|
-
typeof e == "object" ? this.setInputStateOnlyMetapageInstanceInputs(e) : typeof s == "string" ? this.setInputStateOnlyMetaframeInputValue(e, s, n) : this.setInputStateOnlyMetaframeInputMap(e, s || {}), this.setMetaframeClientInputAndSentClientEvent(e, s, n), (this.listenerCount(
|
|
4279
|
+
typeof e == "object" ? this.setInputStateOnlyMetapageInstanceInputs(e) : typeof s == "string" ? this.setInputStateOnlyMetaframeInputValue(e, s, n) : this.setInputStateOnlyMetaframeInputMap(e, s || {}), this.setMetaframeClientInputAndSentClientEvent(e, s, n), (this.listenerCount(C.State) > 0 || this.listenerCount(C.Inputs) > 0) && vt !== this._state && (this.emit(C.State, this._state), this.emit(C.Inputs, (o = (i = this._state) == null ? void 0 : i.metaframes) == null ? void 0 : o.inputs));
|
|
4270
4280
|
}
|
|
4271
4281
|
setMetaframeClientInputAndSentClientEvent(e, s, n) {
|
|
4272
4282
|
if (typeof e == "object") {
|
|
@@ -4313,7 +4323,7 @@ class nt extends rr {
|
|
|
4313
4323
|
this._setStateOnlyMetaframeInputMap(!0, e, s);
|
|
4314
4324
|
}
|
|
4315
4325
|
_setStateOnlyMetaframeInputValue(e, s, n, i) {
|
|
4316
|
-
this._state =
|
|
4326
|
+
this._state = I(this._state, (o) => {
|
|
4317
4327
|
if (!this._metaframes.hasOwnProperty(s))
|
|
4318
4328
|
throw `No metaframe: ${s}`;
|
|
4319
4329
|
o.metaframes || (o.metaframes = { inputs: {}, outputs: {} }), e ? o.metaframes.inputs || (o.metaframes.inputs = {}) : o.metaframes.outputs || (o.metaframes.outputs = {});
|
|
@@ -4322,7 +4332,7 @@ class nt extends rr {
|
|
|
4322
4332
|
});
|
|
4323
4333
|
}
|
|
4324
4334
|
_setStateOnlyMetaframeInputMap(e, s, n) {
|
|
4325
|
-
!n || Object.keys(n).length === 0 || (this._state =
|
|
4335
|
+
!n || Object.keys(n).length === 0 || (this._state = I(this._state, (i) => {
|
|
4326
4336
|
if (!this._metaframes.hasOwnProperty(s))
|
|
4327
4337
|
throw `No metaframe: ${s}`;
|
|
4328
4338
|
let r = e ? i.metaframes.inputs : i.metaframes.outputs;
|
|
@@ -4332,7 +4342,7 @@ class nt extends rr {
|
|
|
4332
4342
|
}));
|
|
4333
4343
|
}
|
|
4334
4344
|
_setStateOnlyMetaframes(e, s) {
|
|
4335
|
-
!s || Object.keys(s).length === 0 || (this._state =
|
|
4345
|
+
!s || Object.keys(s).length === 0 || (this._state = I(this._state, (n) => {
|
|
4336
4346
|
Object.keys(s).forEach((i) => {
|
|
4337
4347
|
var o = s[i];
|
|
4338
4348
|
if (typeof o != "object")
|
|
@@ -4402,19 +4412,21 @@ class nt extends rr {
|
|
|
4402
4412
|
});
|
|
4403
4413
|
}), r && (this.setInputStateOnlyMetapageInstanceInputs(l), Object.keys(l).forEach((f) => {
|
|
4404
4414
|
this._metaframes[f].setInputs(l[f]);
|
|
4405
|
-
})), this.listenerCount(
|
|
4415
|
+
})), this.listenerCount(C.State) > 0 && vt !== this._state && this.emit(C.State, this._state), this.debug && o.ack({ jsonrpc: e, state: this._state });
|
|
4406
4416
|
} else
|
|
4407
4417
|
this.error(`missing metaframe=${n}`);
|
|
4408
4418
|
break;
|
|
4409
4419
|
case q.InputsUpdate:
|
|
4410
4420
|
var a = e.params;
|
|
4411
|
-
this.debug && this.log(`inputs ${JSON.stringify(a)} from ${n}`), this._metaframes[n] ? (this.setInputStateOnlyMetaframeInputMap(n, a), this._metaframes[n].setInputs(a), this.listenerCount(
|
|
4421
|
+
this.debug && this.log(`inputs ${JSON.stringify(a)} from ${n}`), this._metaframes[n] ? (this.setInputStateOnlyMetaframeInputMap(n, a), this._metaframes[n].setInputs(a), this.listenerCount(C.State) > 0 && vt !== this._state && this.emit(C.State, this._state), this.debug && this._metaframes[n].ack({
|
|
4412
4422
|
jsonrpc: e,
|
|
4413
4423
|
state: this._state
|
|
4414
4424
|
})) : (console.error(`InputsUpdate failed no metaframe id: "${n}"`), this.error(`InputsUpdate failed no metaframe id: "${n}"`));
|
|
4415
4425
|
break;
|
|
4416
4426
|
case q.HashParamsUpdate:
|
|
4417
4427
|
if (i) {
|
|
4428
|
+
if (i.url.startsWith("data:"))
|
|
4429
|
+
break;
|
|
4418
4430
|
const c = e.params, l = c.metaframe;
|
|
4419
4431
|
let f = new URL(i.url);
|
|
4420
4432
|
f.hash = c.hash, this._injectedSecrets[l] && Object.entries(this._injectedSecrets[l]).forEach(([m, _]) => {
|
|
@@ -4450,7 +4462,7 @@ class nt extends rr {
|
|
|
4450
4462
|
});
|
|
4451
4463
|
}
|
|
4452
4464
|
const g = new URL(p);
|
|
4453
|
-
this._definition =
|
|
4465
|
+
this._definition = I(this._definition, (m) => {
|
|
4454
4466
|
m.metaframes[l].url = g.href;
|
|
4455
4467
|
}), this._emitDefinitionEvent();
|
|
4456
4468
|
}
|
|
@@ -4458,7 +4470,7 @@ class nt extends rr {
|
|
|
4458
4470
|
default:
|
|
4459
4471
|
this.debug && this.log(`Unknown RPC method: "${s}"`);
|
|
4460
4472
|
}
|
|
4461
|
-
this.listenerCount(
|
|
4473
|
+
this.listenerCount(C.Message) > 0 && this.emit(C.Message, e);
|
|
4462
4474
|
}
|
|
4463
4475
|
}
|
|
4464
4476
|
logInternal(e, s, n) {
|
|
@@ -4468,13 +4480,13 @@ class nt extends rr {
|
|
|
4468
4480
|
}
|
|
4469
4481
|
}
|
|
4470
4482
|
nt.version = Ls;
|
|
4471
|
-
nt.DEFINITION =
|
|
4472
|
-
nt.DEFINITION_UPDATE =
|
|
4473
|
-
nt.ERROR =
|
|
4474
|
-
nt.INPUTS =
|
|
4475
|
-
nt.MESSAGE =
|
|
4476
|
-
nt.OUTPUTS =
|
|
4477
|
-
nt.STATE =
|
|
4483
|
+
nt.DEFINITION = C.Definition;
|
|
4484
|
+
nt.DEFINITION_UPDATE = C.DefinitionUpdate;
|
|
4485
|
+
nt.ERROR = C.Error;
|
|
4486
|
+
nt.INPUTS = C.Inputs;
|
|
4487
|
+
nt.MESSAGE = C.Message;
|
|
4488
|
+
nt.OUTPUTS = C.Outputs;
|
|
4489
|
+
nt.STATE = C.State;
|
|
4478
4490
|
nt.deserializeInputs = Ft;
|
|
4479
4491
|
nt.serializeInputs = _e;
|
|
4480
4492
|
function ds(t) {
|
|
@@ -4557,7 +4569,7 @@ async function yo(t) {
|
|
|
4557
4569
|
throw r.dispose(), new Error(`Failed to set metapage definition: ${b}`);
|
|
4558
4570
|
}
|
|
4559
4571
|
const a = [];
|
|
4560
|
-
n && a.push(r.addListenerReturnDisposer(
|
|
4572
|
+
n && a.push(r.addListenerReturnDisposer(C.Outputs, n));
|
|
4561
4573
|
const u = (O = (P = s == null ? void 0 : s.meta) == null ? void 0 : P.layouts) == null ? void 0 : O["react-grid-layout"], c = u == null ? void 0 : u.layout;
|
|
4562
4574
|
if (!u || !c)
|
|
4563
4575
|
throw new Error("No valid layout found in metapage definition");
|
|
@@ -4702,7 +4714,7 @@ export {
|
|
|
4702
4714
|
ge as MetaframeVersionCurrent,
|
|
4703
4715
|
ys as MetaframeVersionsAll,
|
|
4704
4716
|
nt as Metapage,
|
|
4705
|
-
|
|
4717
|
+
C as MetapageEvents,
|
|
4706
4718
|
Gt as MetapageHashParams,
|
|
4707
4719
|
zr as MetapageIFrameRpcClient,
|
|
4708
4720
|
rr as MetapageShared,
|