@metapages/metapage 0.13.8 → 0.13.10-alpha1
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.mjs +2157 -0
- package/dist/index.mjs.map +1 -0
- package/dist/metapage/Metaframe.d.ts +2 -2
- package/dist/metapage/Metaframe.d.ts.map +1 -1
- package/dist/metapage/MetapageIFrameRpcClient.d.ts +5 -5
- package/dist/metapage/MetapageIFrameRpcClient.d.ts.map +1 -1
- package/dist/metapage/data.d.ts.map +1 -1
- package/package.json +13 -15
- package/src/metapage/Metaframe.ts +30 -21
- package/src/metapage/MetapageIFrameRpcClient.ts +46 -30
- package/src/metapage/data.ts +12 -14
- package/src/metapage/types/definitions.d.ts +0 -1
- package/dist/browser/metaframe/index.js +0 -31
- package/dist/browser/metaframe/index.js.map +0 -1
- package/dist/browser/metapage/index.js +0 -37
- package/dist/browser/metapage/index.js.map +0 -1
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/metapage/Constants.js +0 -7
- package/dist/metapage/Constants.js.map +0 -1
- package/dist/metapage/Metaframe.js +0 -346
- package/dist/metapage/Metaframe.js.map +0 -1
- package/dist/metapage/Metapage.js +0 -797
- package/dist/metapage/Metapage.js.map +0 -1
- package/dist/metapage/MetapageIFrameRpcClient.js +0 -363
- package/dist/metapage/MetapageIFrameRpcClient.js.map +0 -1
- package/dist/metapage/MetapageTools.js +0 -273
- package/dist/metapage/MetapageTools.js.map +0 -1
- package/dist/metapage/Shared.js +0 -32
- package/dist/metapage/Shared.js.map +0 -1
- package/dist/metapage/data.js +0 -112
- package/dist/metapage/data.js.map +0 -1
- package/dist/metapage/errors/MissingMetaframeJson.js +0 -7
- package/dist/metapage/errors/MissingMetaframeJson.js.map +0 -1
- package/dist/metapage/errors/RootMetapageError.js +0 -7
- package/dist/metapage/errors/RootMetapageError.js.map +0 -1
- package/dist/metapage/jsonrpc2.js +0 -25
- package/dist/metapage/jsonrpc2.js.map +0 -1
- package/dist/metapage/v0_0_1/all.js +0 -16
- package/dist/metapage/v0_0_1/all.js.map +0 -1
- package/dist/metapage/v0_1_0/all.js +0 -16
- package/dist/metapage/v0_1_0/all.js.map +0 -1
- package/dist/metapage/v0_2/all.js +0 -3
- package/dist/metapage/v0_2/all.js.map +0 -1
- package/dist/metapage/v0_3/JsonRpcMethods.js +0 -20
- package/dist/metapage/v0_3/JsonRpcMethods.js.map +0 -1
- package/dist/metapage/v0_3/all.js +0 -2
- package/dist/metapage/v0_3/all.js.map +0 -1
- package/dist/metapage/v0_4/core.js +0 -2
- package/dist/metapage/v0_4/core.js.map +0 -1
- package/dist/metapage/v0_4/events.js +0 -12
- package/dist/metapage/v0_4/events.js.map +0 -1
- package/dist/metapage/v0_4/index.js +0 -7
- package/dist/metapage/v0_4/index.js.map +0 -1
- package/dist/metapage/v0_4/jsonrpc.js +0 -20
- package/dist/metapage/v0_4/jsonrpc.js.map +0 -1
- package/dist/metapage/v0_4/metaframe.js +0 -2
- package/dist/metapage/v0_4/metaframe.js.map +0 -1
- package/dist/metapage/v0_4/metapage.js +0 -2
- package/dist/metapage/v0_4/metapage.js.map +0 -1
- package/dist/metapage/v0_4/versions.js +0 -17
- package/dist/metapage/v0_4/versions.js.map +0 -1
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2157 @@
|
|
|
1
|
+
function bt(o) {
|
|
2
|
+
throw new Error('Could not dynamically require "' + o + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
3
|
+
}
|
|
4
|
+
var Xt = { exports: {} };
|
|
5
|
+
(function(o, t) {
|
|
6
|
+
(function(n) {
|
|
7
|
+
o.exports = n();
|
|
8
|
+
})(function() {
|
|
9
|
+
return function n(a, d, m) {
|
|
10
|
+
function b(S, A) {
|
|
11
|
+
if (!d[S]) {
|
|
12
|
+
if (!a[S]) {
|
|
13
|
+
var P = typeof bt == "function" && bt;
|
|
14
|
+
if (!A && P)
|
|
15
|
+
return P(S, !0);
|
|
16
|
+
if (I)
|
|
17
|
+
return I(S, !0);
|
|
18
|
+
throw new Error("Cannot find module '" + S + "'");
|
|
19
|
+
}
|
|
20
|
+
A = d[S] = { exports: {} }, a[S][0].call(A.exports, function(T) {
|
|
21
|
+
var V = a[S][1][T];
|
|
22
|
+
return b(V || T);
|
|
23
|
+
}, A, A.exports, n, a, d, m);
|
|
24
|
+
}
|
|
25
|
+
return d[S].exports;
|
|
26
|
+
}
|
|
27
|
+
for (var I = typeof bt == "function" && bt, M = 0; M < m.length; M++)
|
|
28
|
+
b(m[M]);
|
|
29
|
+
return b;
|
|
30
|
+
}({ 1: [function(n, a, d) {
|
|
31
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
32
|
+
var y = n("crypto");
|
|
33
|
+
function C(l, g) {
|
|
34
|
+
g = L(l, g);
|
|
35
|
+
var s;
|
|
36
|
+
return (s = g.algorithm !== "passthrough" ? y.createHash(g.algorithm) : new B()).write === void 0 && (s.write = s.update, s.end = s.update), O(g, s).dispatch(l), s.update || s.end(""), s.digest ? s.digest(g.encoding === "buffer" ? void 0 : g.encoding) : (l = s.read(), g.encoding !== "buffer" ? l.toString(g.encoding) : l);
|
|
37
|
+
}
|
|
38
|
+
(d = a.exports = C).sha1 = function(l) {
|
|
39
|
+
return C(l);
|
|
40
|
+
}, d.keys = function(l) {
|
|
41
|
+
return C(l, { excludeValues: !0, algorithm: "sha1", encoding: "hex" });
|
|
42
|
+
}, d.MD5 = function(l) {
|
|
43
|
+
return C(l, { algorithm: "md5", encoding: "hex" });
|
|
44
|
+
}, d.keysMD5 = function(l) {
|
|
45
|
+
return C(l, { algorithm: "md5", encoding: "hex", excludeValues: !0 });
|
|
46
|
+
};
|
|
47
|
+
var h = y.getHashes ? y.getHashes().slice() : ["sha1", "md5"], E = (h.push("passthrough"), ["buffer", "hex", "binary", "base64"]);
|
|
48
|
+
function L(l, g) {
|
|
49
|
+
var s = {};
|
|
50
|
+
if (s.algorithm = (g = g || {}).algorithm || "sha1", s.encoding = g.encoding || "hex", s.excludeValues = !!g.excludeValues, s.algorithm = s.algorithm.toLowerCase(), s.encoding = s.encoding.toLowerCase(), s.ignoreUnknown = g.ignoreUnknown === !0, s.respectType = g.respectType !== !1, s.respectFunctionNames = g.respectFunctionNames !== !1, s.respectFunctionProperties = g.respectFunctionProperties !== !1, s.unorderedArrays = g.unorderedArrays === !0, s.unorderedSets = g.unorderedSets !== !1, s.unorderedObjects = g.unorderedObjects !== !1, s.replacer = g.replacer || void 0, s.excludeKeys = g.excludeKeys || void 0, l === void 0)
|
|
51
|
+
throw new Error("Object argument required.");
|
|
52
|
+
for (var u = 0; u < h.length; ++u)
|
|
53
|
+
h[u].toLowerCase() === s.algorithm.toLowerCase() && (s.algorithm = h[u]);
|
|
54
|
+
if (h.indexOf(s.algorithm) === -1)
|
|
55
|
+
throw new Error('Algorithm "' + s.algorithm + '" not supported. supported values: ' + h.join(", "));
|
|
56
|
+
if (E.indexOf(s.encoding) === -1 && s.algorithm !== "passthrough")
|
|
57
|
+
throw new Error('Encoding "' + s.encoding + '" not supported. supported values: ' + E.join(", "));
|
|
58
|
+
return s;
|
|
59
|
+
}
|
|
60
|
+
function _(l) {
|
|
61
|
+
if (typeof l == "function")
|
|
62
|
+
return /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i.exec(Function.prototype.toString.call(l)) != null;
|
|
63
|
+
}
|
|
64
|
+
function O(l, g, s) {
|
|
65
|
+
s = s || [];
|
|
66
|
+
function u(i) {
|
|
67
|
+
return g.update ? g.update(i, "utf8") : g.write(i, "utf8");
|
|
68
|
+
}
|
|
69
|
+
return { dispatch: function(i) {
|
|
70
|
+
return this["_" + ((i = l.replacer ? l.replacer(i) : i) === null ? "null" : typeof i)](i);
|
|
71
|
+
}, _object: function(i) {
|
|
72
|
+
var c, p = Object.prototype.toString.call(i), j = /\[object (.*)\]/i.exec(p);
|
|
73
|
+
if (j = (j = j ? j[1] : "unknown:[" + p + "]").toLowerCase(), 0 <= (p = s.indexOf(i)))
|
|
74
|
+
return this.dispatch("[CIRCULAR:" + p + "]");
|
|
75
|
+
if (s.push(i), I !== void 0 && I.isBuffer && I.isBuffer(i))
|
|
76
|
+
return u("buffer:"), u(i);
|
|
77
|
+
if (j === "object" || j === "function" || j === "asyncfunction")
|
|
78
|
+
return p = Object.keys(i), l.unorderedObjects && (p = p.sort()), l.respectType === !1 || _(i) || p.splice(0, 0, "prototype", "__proto__", "constructor"), l.excludeKeys && (p = p.filter(function(R) {
|
|
79
|
+
return !l.excludeKeys(R);
|
|
80
|
+
})), u("object:" + p.length + ":"), c = this, p.forEach(function(R) {
|
|
81
|
+
c.dispatch(R), u(":"), l.excludeValues || c.dispatch(i[R]), u(",");
|
|
82
|
+
});
|
|
83
|
+
if (!this["_" + j]) {
|
|
84
|
+
if (l.ignoreUnknown)
|
|
85
|
+
return u("[" + j + "]");
|
|
86
|
+
throw new Error('Unknown object type "' + j + '"');
|
|
87
|
+
}
|
|
88
|
+
this["_" + j](i);
|
|
89
|
+
}, _array: function(i, R) {
|
|
90
|
+
R = R !== void 0 ? R : l.unorderedArrays !== !1;
|
|
91
|
+
var p = this;
|
|
92
|
+
if (u("array:" + i.length + ":"), !R || i.length <= 1)
|
|
93
|
+
return i.forEach(function(x) {
|
|
94
|
+
return p.dispatch(x);
|
|
95
|
+
});
|
|
96
|
+
var j = [], R = i.map(function(x) {
|
|
97
|
+
var D = new B(), z = s.slice();
|
|
98
|
+
return O(l, D, z).dispatch(x), j = j.concat(z.slice(s.length)), D.read().toString();
|
|
99
|
+
});
|
|
100
|
+
return s = s.concat(j), R.sort(), this._array(R, !1);
|
|
101
|
+
}, _date: function(i) {
|
|
102
|
+
return u("date:" + i.toJSON());
|
|
103
|
+
}, _symbol: function(i) {
|
|
104
|
+
return u("symbol:" + i.toString());
|
|
105
|
+
}, _error: function(i) {
|
|
106
|
+
return u("error:" + i.toString());
|
|
107
|
+
}, _boolean: function(i) {
|
|
108
|
+
return u("bool:" + i.toString());
|
|
109
|
+
}, _string: function(i) {
|
|
110
|
+
u("string:" + i.length + ":"), u(i.toString());
|
|
111
|
+
}, _function: function(i) {
|
|
112
|
+
u("fn:"), _(i) ? this.dispatch("[native]") : this.dispatch(i.toString()), l.respectFunctionNames !== !1 && this.dispatch("function-name:" + String(i.name)), l.respectFunctionProperties && this._object(i);
|
|
113
|
+
}, _number: function(i) {
|
|
114
|
+
return u("number:" + i.toString());
|
|
115
|
+
}, _xml: function(i) {
|
|
116
|
+
return u("xml:" + i.toString());
|
|
117
|
+
}, _null: function() {
|
|
118
|
+
return u("Null");
|
|
119
|
+
}, _undefined: function() {
|
|
120
|
+
return u("Undefined");
|
|
121
|
+
}, _regexp: function(i) {
|
|
122
|
+
return u("regex:" + i.toString());
|
|
123
|
+
}, _uint8array: function(i) {
|
|
124
|
+
return u("uint8array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
125
|
+
}, _uint8clampedarray: function(i) {
|
|
126
|
+
return u("uint8clampedarray:"), this.dispatch(Array.prototype.slice.call(i));
|
|
127
|
+
}, _int8array: function(i) {
|
|
128
|
+
return u("int8array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
129
|
+
}, _uint16array: function(i) {
|
|
130
|
+
return u("uint16array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
131
|
+
}, _int16array: function(i) {
|
|
132
|
+
return u("int16array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
133
|
+
}, _uint32array: function(i) {
|
|
134
|
+
return u("uint32array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
135
|
+
}, _int32array: function(i) {
|
|
136
|
+
return u("int32array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
137
|
+
}, _float32array: function(i) {
|
|
138
|
+
return u("float32array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
139
|
+
}, _float64array: function(i) {
|
|
140
|
+
return u("float64array:"), this.dispatch(Array.prototype.slice.call(i));
|
|
141
|
+
}, _arraybuffer: function(i) {
|
|
142
|
+
return u("arraybuffer:"), this.dispatch(new Uint8Array(i));
|
|
143
|
+
}, _url: function(i) {
|
|
144
|
+
return u("url:" + i.toString());
|
|
145
|
+
}, _map: function(i) {
|
|
146
|
+
return u("map:"), i = Array.from(i), this._array(i, l.unorderedSets !== !1);
|
|
147
|
+
}, _set: function(i) {
|
|
148
|
+
return u("set:"), i = Array.from(i), this._array(i, l.unorderedSets !== !1);
|
|
149
|
+
}, _file: function(i) {
|
|
150
|
+
return u("file:"), this.dispatch([i.name, i.size, i.type, i.lastModfied]);
|
|
151
|
+
}, _blob: function() {
|
|
152
|
+
if (l.ignoreUnknown)
|
|
153
|
+
return u("[blob]");
|
|
154
|
+
throw Error(`Hashing Blob objects is currently not supported
|
|
155
|
+
(see https://github.com/puleos/object-hash/issues/26)
|
|
156
|
+
Use "options.replacer" or "options.ignoreUnknown"
|
|
157
|
+
`);
|
|
158
|
+
}, _domwindow: function() {
|
|
159
|
+
return u("domwindow");
|
|
160
|
+
}, _bigint: function(i) {
|
|
161
|
+
return u("bigint:" + i.toString());
|
|
162
|
+
}, _process: function() {
|
|
163
|
+
return u("process");
|
|
164
|
+
}, _timer: function() {
|
|
165
|
+
return u("timer");
|
|
166
|
+
}, _pipe: function() {
|
|
167
|
+
return u("pipe");
|
|
168
|
+
}, _tcp: function() {
|
|
169
|
+
return u("tcp");
|
|
170
|
+
}, _udp: function() {
|
|
171
|
+
return u("udp");
|
|
172
|
+
}, _tty: function() {
|
|
173
|
+
return u("tty");
|
|
174
|
+
}, _statwatcher: function() {
|
|
175
|
+
return u("statwatcher");
|
|
176
|
+
}, _securecontext: function() {
|
|
177
|
+
return u("securecontext");
|
|
178
|
+
}, _connection: function() {
|
|
179
|
+
return u("connection");
|
|
180
|
+
}, _zlib: function() {
|
|
181
|
+
return u("zlib");
|
|
182
|
+
}, _context: function() {
|
|
183
|
+
return u("context");
|
|
184
|
+
}, _nodescript: function() {
|
|
185
|
+
return u("nodescript");
|
|
186
|
+
}, _httpparser: function() {
|
|
187
|
+
return u("httpparser");
|
|
188
|
+
}, _dataview: function() {
|
|
189
|
+
return u("dataview");
|
|
190
|
+
}, _signal: function() {
|
|
191
|
+
return u("signal");
|
|
192
|
+
}, _fsevent: function() {
|
|
193
|
+
return u("fsevent");
|
|
194
|
+
}, _tlswrap: function() {
|
|
195
|
+
return u("tlswrap");
|
|
196
|
+
} };
|
|
197
|
+
}
|
|
198
|
+
function B() {
|
|
199
|
+
return { buf: "", write: function(l) {
|
|
200
|
+
this.buf += l;
|
|
201
|
+
}, end: function(l) {
|
|
202
|
+
this.buf += l;
|
|
203
|
+
}, read: function() {
|
|
204
|
+
return this.buf;
|
|
205
|
+
} };
|
|
206
|
+
}
|
|
207
|
+
d.writeToStream = function(l, g, s) {
|
|
208
|
+
return s === void 0 && (s = g, g = {}), O(g = L(l, g), s).dispatch(l);
|
|
209
|
+
};
|
|
210
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/fake_9a5aa49d.js", "/");
|
|
211
|
+
}, { buffer: 3, crypto: 5, lYpoI2: 11 }], 2: [function(n, a, d) {
|
|
212
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
213
|
+
(function(y) {
|
|
214
|
+
var C = typeof Uint8Array < "u" ? Uint8Array : Array, h = "+".charCodeAt(0), E = "/".charCodeAt(0), L = "0".charCodeAt(0), _ = "a".charCodeAt(0), O = "A".charCodeAt(0), B = "-".charCodeAt(0), l = "_".charCodeAt(0);
|
|
215
|
+
function g(s) {
|
|
216
|
+
return s = s.charCodeAt(0), s === h || s === B ? 62 : s === E || s === l ? 63 : s < L ? -1 : s < L + 10 ? s - L + 26 + 26 : s < O + 26 ? s - O : s < _ + 26 ? s - _ + 26 : void 0;
|
|
217
|
+
}
|
|
218
|
+
y.toByteArray = function(s) {
|
|
219
|
+
var u, i;
|
|
220
|
+
if (0 < s.length % 4)
|
|
221
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
222
|
+
var c = s.length, c = s.charAt(c - 2) === "=" ? 2 : s.charAt(c - 1) === "=" ? 1 : 0, p = new C(3 * s.length / 4 - c), j = 0 < c ? s.length - 4 : s.length, R = 0;
|
|
223
|
+
function x(D) {
|
|
224
|
+
p[R++] = D;
|
|
225
|
+
}
|
|
226
|
+
for (u = 0; u < j; u += 4, 0)
|
|
227
|
+
x((16711680 & (i = g(s.charAt(u)) << 18 | g(s.charAt(u + 1)) << 12 | g(s.charAt(u + 2)) << 6 | g(s.charAt(u + 3)))) >> 16), x((65280 & i) >> 8), x(255 & i);
|
|
228
|
+
return c == 2 ? x(255 & (i = g(s.charAt(u)) << 2 | g(s.charAt(u + 1)) >> 4)) : c == 1 && (x((i = g(s.charAt(u)) << 10 | g(s.charAt(u + 1)) << 4 | g(s.charAt(u + 2)) >> 2) >> 8 & 255), x(255 & i)), p;
|
|
229
|
+
}, y.fromByteArray = function(s) {
|
|
230
|
+
var u, i, c, p, j = s.length % 3, R = "";
|
|
231
|
+
function x(D) {
|
|
232
|
+
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(D);
|
|
233
|
+
}
|
|
234
|
+
for (u = 0, c = s.length - j; u < c; u += 3)
|
|
235
|
+
i = (s[u] << 16) + (s[u + 1] << 8) + s[u + 2], R += x((p = i) >> 18 & 63) + x(p >> 12 & 63) + x(p >> 6 & 63) + x(63 & p);
|
|
236
|
+
switch (j) {
|
|
237
|
+
case 1:
|
|
238
|
+
R = (R += x((i = s[s.length - 1]) >> 2)) + x(i << 4 & 63) + "==";
|
|
239
|
+
break;
|
|
240
|
+
case 2:
|
|
241
|
+
R = (R = (R += x((i = (s[s.length - 2] << 8) + s[s.length - 1]) >> 10)) + x(i >> 4 & 63)) + x(i << 2 & 63) + "=";
|
|
242
|
+
}
|
|
243
|
+
return R;
|
|
244
|
+
};
|
|
245
|
+
})(d === void 0 ? this.base64js = {} : d);
|
|
246
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/base64-js/lib/b64.js", "/node_modules/gulp-browserify/node_modules/base64-js/lib");
|
|
247
|
+
}, { buffer: 3, lYpoI2: 11 }], 3: [function(n, a, d) {
|
|
248
|
+
(function(m, b, h, M, S, A, P, T, V) {
|
|
249
|
+
var y = n("base64-js"), C = n("ieee754");
|
|
250
|
+
function h(e, r, f) {
|
|
251
|
+
if (!(this instanceof h))
|
|
252
|
+
return new h(e, r, f);
|
|
253
|
+
var v, w, k, $, J = typeof e;
|
|
254
|
+
if (r === "base64" && J == "string")
|
|
255
|
+
for (e = ($ = e).trim ? $.trim() : $.replace(/^\s+|\s+$/g, ""); e.length % 4 != 0; )
|
|
256
|
+
e += "=";
|
|
257
|
+
if (J == "number")
|
|
258
|
+
v = K(e);
|
|
259
|
+
else if (J == "string")
|
|
260
|
+
v = h.byteLength(e, r);
|
|
261
|
+
else {
|
|
262
|
+
if (J != "object")
|
|
263
|
+
throw new Error("First argument needs to be a number, array or string.");
|
|
264
|
+
v = K(e.length);
|
|
265
|
+
}
|
|
266
|
+
if (h._useTypedArrays ? w = h._augment(new Uint8Array(v)) : ((w = this).length = v, w._isBuffer = !0), h._useTypedArrays && typeof e.byteLength == "number")
|
|
267
|
+
w._set(e);
|
|
268
|
+
else if (q($ = e) || h.isBuffer($) || $ && typeof $ == "object" && typeof $.length == "number")
|
|
269
|
+
for (k = 0; k < v; k++)
|
|
270
|
+
h.isBuffer(e) ? w[k] = e.readUInt8(k) : w[k] = e[k];
|
|
271
|
+
else if (J == "string")
|
|
272
|
+
w.write(e, 0, r);
|
|
273
|
+
else if (J == "number" && !h._useTypedArrays && !f)
|
|
274
|
+
for (k = 0; k < v; k++)
|
|
275
|
+
w[k] = 0;
|
|
276
|
+
return w;
|
|
277
|
+
}
|
|
278
|
+
function E(e, r, f, v) {
|
|
279
|
+
return h._charsWritten = yt(function(w) {
|
|
280
|
+
for (var k = [], $ = 0; $ < w.length; $++)
|
|
281
|
+
k.push(255 & w.charCodeAt($));
|
|
282
|
+
return k;
|
|
283
|
+
}(r), e, f, v);
|
|
284
|
+
}
|
|
285
|
+
function L(e, r, f, v) {
|
|
286
|
+
return h._charsWritten = yt(function(w) {
|
|
287
|
+
for (var k, $, J = [], Y = 0; Y < w.length; Y++)
|
|
288
|
+
$ = w.charCodeAt(Y), k = $ >> 8, $ = $ % 256, J.push($), J.push(k);
|
|
289
|
+
return J;
|
|
290
|
+
}(r), e, f, v);
|
|
291
|
+
}
|
|
292
|
+
function _(e, r, f) {
|
|
293
|
+
var v = "";
|
|
294
|
+
f = Math.min(e.length, f);
|
|
295
|
+
for (var w = r; w < f; w++)
|
|
296
|
+
v += String.fromCharCode(e[w]);
|
|
297
|
+
return v;
|
|
298
|
+
}
|
|
299
|
+
function O(e, r, f, k) {
|
|
300
|
+
k || (U(typeof f == "boolean", "missing or invalid endian"), U(r != null, "missing offset"), U(r + 1 < e.length, "Trying to read beyond buffer length"));
|
|
301
|
+
var w, k = e.length;
|
|
302
|
+
if (!(k <= r))
|
|
303
|
+
return f ? (w = e[r], r + 1 < k && (w |= e[r + 1] << 8)) : (w = e[r] << 8, r + 1 < k && (w |= e[r + 1])), w;
|
|
304
|
+
}
|
|
305
|
+
function B(e, r, f, k) {
|
|
306
|
+
k || (U(typeof f == "boolean", "missing or invalid endian"), U(r != null, "missing offset"), U(r + 3 < e.length, "Trying to read beyond buffer length"));
|
|
307
|
+
var w, k = e.length;
|
|
308
|
+
if (!(k <= r))
|
|
309
|
+
return f ? (r + 2 < k && (w = e[r + 2] << 16), r + 1 < k && (w |= e[r + 1] << 8), w |= e[r], r + 3 < k && (w += e[r + 3] << 24 >>> 0)) : (r + 1 < k && (w = e[r + 1] << 16), r + 2 < k && (w |= e[r + 2] << 8), r + 3 < k && (w |= e[r + 3]), w += e[r] << 24 >>> 0), w;
|
|
310
|
+
}
|
|
311
|
+
function l(e, r, f, v) {
|
|
312
|
+
if (v || (U(typeof f == "boolean", "missing or invalid endian"), U(r != null, "missing offset"), U(r + 1 < e.length, "Trying to read beyond buffer length")), !(e.length <= r))
|
|
313
|
+
return v = O(e, r, f, !0), 32768 & v ? -1 * (65535 - v + 1) : v;
|
|
314
|
+
}
|
|
315
|
+
function g(e, r, f, v) {
|
|
316
|
+
if (v || (U(typeof f == "boolean", "missing or invalid endian"), U(r != null, "missing offset"), U(r + 3 < e.length, "Trying to read beyond buffer length")), !(e.length <= r))
|
|
317
|
+
return v = B(e, r, f, !0), 2147483648 & v ? -1 * (4294967295 - v + 1) : v;
|
|
318
|
+
}
|
|
319
|
+
function s(e, r, f, v) {
|
|
320
|
+
return v || (U(typeof f == "boolean", "missing or invalid endian"), U(r + 3 < e.length, "Trying to read beyond buffer length")), C.read(e, r, f, 23, 4);
|
|
321
|
+
}
|
|
322
|
+
function u(e, r, f, v) {
|
|
323
|
+
return v || (U(typeof f == "boolean", "missing or invalid endian"), U(r + 7 < e.length, "Trying to read beyond buffer length")), C.read(e, r, f, 52, 8);
|
|
324
|
+
}
|
|
325
|
+
function i(e, r, f, v, w) {
|
|
326
|
+
if (w || (U(r != null, "missing value"), U(typeof v == "boolean", "missing or invalid endian"), U(f != null, "missing offset"), U(f + 1 < e.length, "trying to write beyond buffer length"), At(r, 65535)), w = e.length, !(w <= f))
|
|
327
|
+
for (var k = 0, $ = Math.min(w - f, 2); k < $; k++)
|
|
328
|
+
e[f + k] = (r & 255 << 8 * (v ? k : 1 - k)) >>> 8 * (v ? k : 1 - k);
|
|
329
|
+
}
|
|
330
|
+
function c(e, r, f, v, w) {
|
|
331
|
+
if (w || (U(r != null, "missing value"), U(typeof v == "boolean", "missing or invalid endian"), U(f != null, "missing offset"), U(f + 3 < e.length, "trying to write beyond buffer length"), At(r, 4294967295)), w = e.length, !(w <= f))
|
|
332
|
+
for (var k = 0, $ = Math.min(w - f, 4); k < $; k++)
|
|
333
|
+
e[f + k] = r >>> 8 * (v ? k : 3 - k) & 255;
|
|
334
|
+
}
|
|
335
|
+
function p(e, r, f, v, w) {
|
|
336
|
+
w || (U(r != null, "missing value"), U(typeof v == "boolean", "missing or invalid endian"), U(f != null, "missing offset"), U(f + 1 < e.length, "Trying to write beyond buffer length"), Lt(r, 32767, -32768)), e.length <= f || i(e, 0 <= r ? r : 65535 + r + 1, f, v, w);
|
|
337
|
+
}
|
|
338
|
+
function j(e, r, f, v, w) {
|
|
339
|
+
w || (U(r != null, "missing value"), U(typeof v == "boolean", "missing or invalid endian"), U(f != null, "missing offset"), U(f + 3 < e.length, "Trying to write beyond buffer length"), Lt(r, 2147483647, -2147483648)), e.length <= f || c(e, 0 <= r ? r : 4294967295 + r + 1, f, v, w);
|
|
340
|
+
}
|
|
341
|
+
function R(e, r, f, v, w) {
|
|
342
|
+
w || (U(r != null, "missing value"), U(typeof v == "boolean", "missing or invalid endian"), U(f != null, "missing offset"), U(f + 3 < e.length, "Trying to write beyond buffer length"), Nt(r, 34028234663852886e22, -34028234663852886e22)), e.length <= f || C.write(e, r, f, v, 23, 4);
|
|
343
|
+
}
|
|
344
|
+
function x(e, r, f, v, w) {
|
|
345
|
+
w || (U(r != null, "missing value"), U(typeof v == "boolean", "missing or invalid endian"), U(f != null, "missing offset"), U(f + 7 < e.length, "Trying to write beyond buffer length"), Nt(r, 17976931348623157e292, -17976931348623157e292)), e.length <= f || C.write(e, r, f, v, 52, 8);
|
|
346
|
+
}
|
|
347
|
+
d.Buffer = h, d.SlowBuffer = h, d.INSPECT_MAX_BYTES = 50, h.poolSize = 8192, h._useTypedArrays = function() {
|
|
348
|
+
try {
|
|
349
|
+
var e = new ArrayBuffer(0), r = new Uint8Array(e);
|
|
350
|
+
return r.foo = function() {
|
|
351
|
+
return 42;
|
|
352
|
+
}, r.foo() === 42 && typeof r.subarray == "function";
|
|
353
|
+
} catch {
|
|
354
|
+
return !1;
|
|
355
|
+
}
|
|
356
|
+
}(), h.isEncoding = function(e) {
|
|
357
|
+
switch (String(e).toLowerCase()) {
|
|
358
|
+
case "hex":
|
|
359
|
+
case "utf8":
|
|
360
|
+
case "utf-8":
|
|
361
|
+
case "ascii":
|
|
362
|
+
case "binary":
|
|
363
|
+
case "base64":
|
|
364
|
+
case "raw":
|
|
365
|
+
case "ucs2":
|
|
366
|
+
case "ucs-2":
|
|
367
|
+
case "utf16le":
|
|
368
|
+
case "utf-16le":
|
|
369
|
+
return !0;
|
|
370
|
+
default:
|
|
371
|
+
return !1;
|
|
372
|
+
}
|
|
373
|
+
}, h.isBuffer = function(e) {
|
|
374
|
+
return !(e == null || !e._isBuffer);
|
|
375
|
+
}, h.byteLength = function(e, r) {
|
|
376
|
+
var f;
|
|
377
|
+
switch (e += "", r || "utf8") {
|
|
378
|
+
case "hex":
|
|
379
|
+
f = e.length / 2;
|
|
380
|
+
break;
|
|
381
|
+
case "utf8":
|
|
382
|
+
case "utf-8":
|
|
383
|
+
f = ot(e).length;
|
|
384
|
+
break;
|
|
385
|
+
case "ascii":
|
|
386
|
+
case "binary":
|
|
387
|
+
case "raw":
|
|
388
|
+
f = e.length;
|
|
389
|
+
break;
|
|
390
|
+
case "base64":
|
|
391
|
+
f = xt(e).length;
|
|
392
|
+
break;
|
|
393
|
+
case "ucs2":
|
|
394
|
+
case "ucs-2":
|
|
395
|
+
case "utf16le":
|
|
396
|
+
case "utf-16le":
|
|
397
|
+
f = 2 * e.length;
|
|
398
|
+
break;
|
|
399
|
+
default:
|
|
400
|
+
throw new Error("Unknown encoding");
|
|
401
|
+
}
|
|
402
|
+
return f;
|
|
403
|
+
}, h.concat = function(e, r) {
|
|
404
|
+
if (U(q(e), `Usage: Buffer.concat(list, [totalLength])
|
|
405
|
+
list should be an Array.`), e.length === 0)
|
|
406
|
+
return new h(0);
|
|
407
|
+
if (e.length === 1)
|
|
408
|
+
return e[0];
|
|
409
|
+
if (typeof r != "number")
|
|
410
|
+
for (w = r = 0; w < e.length; w++)
|
|
411
|
+
r += e[w].length;
|
|
412
|
+
for (var f = new h(r), v = 0, w = 0; w < e.length; w++) {
|
|
413
|
+
var k = e[w];
|
|
414
|
+
k.copy(f, v), v += k.length;
|
|
415
|
+
}
|
|
416
|
+
return f;
|
|
417
|
+
}, h.prototype.write = function(e, r, f, v) {
|
|
418
|
+
isFinite(r) ? isFinite(f) || (v = f, f = void 0) : (Y = v, v = r, r = f, f = Y), r = Number(r) || 0;
|
|
419
|
+
var w, k, $, J, Y = this.length - r;
|
|
420
|
+
switch ((!f || Y < (f = Number(f))) && (f = Y), v = String(v || "utf8").toLowerCase()) {
|
|
421
|
+
case "hex":
|
|
422
|
+
w = function(et, Q, Z, H) {
|
|
423
|
+
Z = Number(Z) || 0;
|
|
424
|
+
var W = et.length - Z;
|
|
425
|
+
(!H || W < (H = Number(H))) && (H = W), U((W = Q.length) % 2 == 0, "Invalid hex string"), W / 2 < H && (H = W / 2);
|
|
426
|
+
for (var ht = 0; ht < H; ht++) {
|
|
427
|
+
var Vt = parseInt(Q.substr(2 * ht, 2), 16);
|
|
428
|
+
U(!isNaN(Vt), "Invalid hex string"), et[Z + ht] = Vt;
|
|
429
|
+
}
|
|
430
|
+
return h._charsWritten = 2 * ht, ht;
|
|
431
|
+
}(this, e, r, f);
|
|
432
|
+
break;
|
|
433
|
+
case "utf8":
|
|
434
|
+
case "utf-8":
|
|
435
|
+
k = this, $ = r, J = f, w = h._charsWritten = yt(ot(e), k, $, J);
|
|
436
|
+
break;
|
|
437
|
+
case "ascii":
|
|
438
|
+
case "binary":
|
|
439
|
+
w = E(this, e, r, f);
|
|
440
|
+
break;
|
|
441
|
+
case "base64":
|
|
442
|
+
k = this, $ = r, J = f, w = h._charsWritten = yt(xt(e), k, $, J);
|
|
443
|
+
break;
|
|
444
|
+
case "ucs2":
|
|
445
|
+
case "ucs-2":
|
|
446
|
+
case "utf16le":
|
|
447
|
+
case "utf-16le":
|
|
448
|
+
w = L(this, e, r, f);
|
|
449
|
+
break;
|
|
450
|
+
default:
|
|
451
|
+
throw new Error("Unknown encoding");
|
|
452
|
+
}
|
|
453
|
+
return w;
|
|
454
|
+
}, h.prototype.toString = function(e, r, f) {
|
|
455
|
+
var v, w, k, $, J = this;
|
|
456
|
+
if (e = String(e || "utf8").toLowerCase(), r = Number(r) || 0, (f = f !== void 0 ? Number(f) : J.length) === r)
|
|
457
|
+
return "";
|
|
458
|
+
switch (e) {
|
|
459
|
+
case "hex":
|
|
460
|
+
v = function(Y, et, Q) {
|
|
461
|
+
var Z = Y.length;
|
|
462
|
+
(!et || et < 0) && (et = 0), (!Q || Q < 0 || Z < Q) && (Q = Z);
|
|
463
|
+
for (var H = "", W = et; W < Q; W++)
|
|
464
|
+
H += F(Y[W]);
|
|
465
|
+
return H;
|
|
466
|
+
}(J, r, f);
|
|
467
|
+
break;
|
|
468
|
+
case "utf8":
|
|
469
|
+
case "utf-8":
|
|
470
|
+
v = function(Y, et, Q) {
|
|
471
|
+
var Z = "", H = "";
|
|
472
|
+
Q = Math.min(Y.length, Q);
|
|
473
|
+
for (var W = et; W < Q; W++)
|
|
474
|
+
Y[W] <= 127 ? (Z += Tt(H) + String.fromCharCode(Y[W]), H = "") : H += "%" + Y[W].toString(16);
|
|
475
|
+
return Z + Tt(H);
|
|
476
|
+
}(J, r, f);
|
|
477
|
+
break;
|
|
478
|
+
case "ascii":
|
|
479
|
+
case "binary":
|
|
480
|
+
v = _(J, r, f);
|
|
481
|
+
break;
|
|
482
|
+
case "base64":
|
|
483
|
+
w = J, $ = f, v = (k = r) === 0 && $ === w.length ? y.fromByteArray(w) : y.fromByteArray(w.slice(k, $));
|
|
484
|
+
break;
|
|
485
|
+
case "ucs2":
|
|
486
|
+
case "ucs-2":
|
|
487
|
+
case "utf16le":
|
|
488
|
+
case "utf-16le":
|
|
489
|
+
v = function(Y, et, Q) {
|
|
490
|
+
for (var Z = Y.slice(et, Q), H = "", W = 0; W < Z.length; W += 2)
|
|
491
|
+
H += String.fromCharCode(Z[W] + 256 * Z[W + 1]);
|
|
492
|
+
return H;
|
|
493
|
+
}(J, r, f);
|
|
494
|
+
break;
|
|
495
|
+
default:
|
|
496
|
+
throw new Error("Unknown encoding");
|
|
497
|
+
}
|
|
498
|
+
return v;
|
|
499
|
+
}, h.prototype.toJSON = function() {
|
|
500
|
+
return { type: "Buffer", data: Array.prototype.slice.call(this._arr || this, 0) };
|
|
501
|
+
}, h.prototype.copy = function(e, r, f, v) {
|
|
502
|
+
if (r = r || 0, (v = v || v === 0 ? v : this.length) !== (f = f || 0) && e.length !== 0 && this.length !== 0) {
|
|
503
|
+
U(f <= v, "sourceEnd < sourceStart"), U(0 <= r && r < e.length, "targetStart out of bounds"), U(0 <= f && f < this.length, "sourceStart out of bounds"), U(0 <= v && v <= this.length, "sourceEnd out of bounds"), v > this.length && (v = this.length);
|
|
504
|
+
var w = (v = e.length - r < v - f ? e.length - r + f : v) - f;
|
|
505
|
+
if (w < 100 || !h._useTypedArrays)
|
|
506
|
+
for (var k = 0; k < w; k++)
|
|
507
|
+
e[k + r] = this[k + f];
|
|
508
|
+
else
|
|
509
|
+
e._set(this.subarray(f, f + w), r);
|
|
510
|
+
}
|
|
511
|
+
}, h.prototype.slice = function(e, r) {
|
|
512
|
+
var f = this.length;
|
|
513
|
+
if (e = z(e, f, 0), r = z(r, f, f), h._useTypedArrays)
|
|
514
|
+
return h._augment(this.subarray(e, r));
|
|
515
|
+
for (var v = r - e, w = new h(v, void 0, !0), k = 0; k < v; k++)
|
|
516
|
+
w[k] = this[k + e];
|
|
517
|
+
return w;
|
|
518
|
+
}, h.prototype.get = function(e) {
|
|
519
|
+
return console.log(".get() is deprecated. Access using array indexes instead."), this.readUInt8(e);
|
|
520
|
+
}, h.prototype.set = function(e, r) {
|
|
521
|
+
return console.log(".set() is deprecated. Access using array indexes instead."), this.writeUInt8(e, r);
|
|
522
|
+
}, h.prototype.readUInt8 = function(e, r) {
|
|
523
|
+
if (r || (U(e != null, "missing offset"), U(e < this.length, "Trying to read beyond buffer length")), !(e >= this.length))
|
|
524
|
+
return this[e];
|
|
525
|
+
}, h.prototype.readUInt16LE = function(e, r) {
|
|
526
|
+
return O(this, e, !0, r);
|
|
527
|
+
}, h.prototype.readUInt16BE = function(e, r) {
|
|
528
|
+
return O(this, e, !1, r);
|
|
529
|
+
}, h.prototype.readUInt32LE = function(e, r) {
|
|
530
|
+
return B(this, e, !0, r);
|
|
531
|
+
}, h.prototype.readUInt32BE = function(e, r) {
|
|
532
|
+
return B(this, e, !1, r);
|
|
533
|
+
}, h.prototype.readInt8 = function(e, r) {
|
|
534
|
+
if (r || (U(e != null, "missing offset"), U(e < this.length, "Trying to read beyond buffer length")), !(e >= this.length))
|
|
535
|
+
return 128 & this[e] ? -1 * (255 - this[e] + 1) : this[e];
|
|
536
|
+
}, h.prototype.readInt16LE = function(e, r) {
|
|
537
|
+
return l(this, e, !0, r);
|
|
538
|
+
}, h.prototype.readInt16BE = function(e, r) {
|
|
539
|
+
return l(this, e, !1, r);
|
|
540
|
+
}, h.prototype.readInt32LE = function(e, r) {
|
|
541
|
+
return g(this, e, !0, r);
|
|
542
|
+
}, h.prototype.readInt32BE = function(e, r) {
|
|
543
|
+
return g(this, e, !1, r);
|
|
544
|
+
}, h.prototype.readFloatLE = function(e, r) {
|
|
545
|
+
return s(this, e, !0, r);
|
|
546
|
+
}, h.prototype.readFloatBE = function(e, r) {
|
|
547
|
+
return s(this, e, !1, r);
|
|
548
|
+
}, h.prototype.readDoubleLE = function(e, r) {
|
|
549
|
+
return u(this, e, !0, r);
|
|
550
|
+
}, h.prototype.readDoubleBE = function(e, r) {
|
|
551
|
+
return u(this, e, !1, r);
|
|
552
|
+
}, h.prototype.writeUInt8 = function(e, r, f) {
|
|
553
|
+
f || (U(e != null, "missing value"), U(r != null, "missing offset"), U(r < this.length, "trying to write beyond buffer length"), At(e, 255)), r >= this.length || (this[r] = e);
|
|
554
|
+
}, h.prototype.writeUInt16LE = function(e, r, f) {
|
|
555
|
+
i(this, e, r, !0, f);
|
|
556
|
+
}, h.prototype.writeUInt16BE = function(e, r, f) {
|
|
557
|
+
i(this, e, r, !1, f);
|
|
558
|
+
}, h.prototype.writeUInt32LE = function(e, r, f) {
|
|
559
|
+
c(this, e, r, !0, f);
|
|
560
|
+
}, h.prototype.writeUInt32BE = function(e, r, f) {
|
|
561
|
+
c(this, e, r, !1, f);
|
|
562
|
+
}, h.prototype.writeInt8 = function(e, r, f) {
|
|
563
|
+
f || (U(e != null, "missing value"), U(r != null, "missing offset"), U(r < this.length, "Trying to write beyond buffer length"), Lt(e, 127, -128)), r >= this.length || (0 <= e ? this.writeUInt8(e, r, f) : this.writeUInt8(255 + e + 1, r, f));
|
|
564
|
+
}, h.prototype.writeInt16LE = function(e, r, f) {
|
|
565
|
+
p(this, e, r, !0, f);
|
|
566
|
+
}, h.prototype.writeInt16BE = function(e, r, f) {
|
|
567
|
+
p(this, e, r, !1, f);
|
|
568
|
+
}, h.prototype.writeInt32LE = function(e, r, f) {
|
|
569
|
+
j(this, e, r, !0, f);
|
|
570
|
+
}, h.prototype.writeInt32BE = function(e, r, f) {
|
|
571
|
+
j(this, e, r, !1, f);
|
|
572
|
+
}, h.prototype.writeFloatLE = function(e, r, f) {
|
|
573
|
+
R(this, e, r, !0, f);
|
|
574
|
+
}, h.prototype.writeFloatBE = function(e, r, f) {
|
|
575
|
+
R(this, e, r, !1, f);
|
|
576
|
+
}, h.prototype.writeDoubleLE = function(e, r, f) {
|
|
577
|
+
x(this, e, r, !0, f);
|
|
578
|
+
}, h.prototype.writeDoubleBE = function(e, r, f) {
|
|
579
|
+
x(this, e, r, !1, f);
|
|
580
|
+
}, h.prototype.fill = function(e, r, f) {
|
|
581
|
+
if (r = r || 0, f = f || this.length, U(typeof (e = typeof (e = e || 0) == "string" ? e.charCodeAt(0) : e) == "number" && !isNaN(e), "value is not a number"), U(r <= f, "end < start"), f !== r && this.length !== 0) {
|
|
582
|
+
U(0 <= r && r < this.length, "start out of bounds"), U(0 <= f && f <= this.length, "end out of bounds");
|
|
583
|
+
for (var v = r; v < f; v++)
|
|
584
|
+
this[v] = e;
|
|
585
|
+
}
|
|
586
|
+
}, h.prototype.inspect = function() {
|
|
587
|
+
for (var e = [], r = this.length, f = 0; f < r; f++)
|
|
588
|
+
if (e[f] = F(this[f]), f === d.INSPECT_MAX_BYTES) {
|
|
589
|
+
e[f + 1] = "...";
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
return "<Buffer " + e.join(" ") + ">";
|
|
593
|
+
}, h.prototype.toArrayBuffer = function() {
|
|
594
|
+
if (typeof Uint8Array > "u")
|
|
595
|
+
throw new Error("Buffer.toArrayBuffer not supported in this browser");
|
|
596
|
+
if (h._useTypedArrays)
|
|
597
|
+
return new h(this).buffer;
|
|
598
|
+
for (var e = new Uint8Array(this.length), r = 0, f = e.length; r < f; r += 1)
|
|
599
|
+
e[r] = this[r];
|
|
600
|
+
return e.buffer;
|
|
601
|
+
};
|
|
602
|
+
var D = h.prototype;
|
|
603
|
+
function z(e, r, f) {
|
|
604
|
+
return typeof e != "number" ? f : r <= (e = ~~e) ? r : 0 <= e || 0 <= (e += r) ? e : 0;
|
|
605
|
+
}
|
|
606
|
+
function K(e) {
|
|
607
|
+
return (e = ~~Math.ceil(+e)) < 0 ? 0 : e;
|
|
608
|
+
}
|
|
609
|
+
function q(e) {
|
|
610
|
+
return (Array.isArray || function(r) {
|
|
611
|
+
return Object.prototype.toString.call(r) === "[object Array]";
|
|
612
|
+
})(e);
|
|
613
|
+
}
|
|
614
|
+
function F(e) {
|
|
615
|
+
return e < 16 ? "0" + e.toString(16) : e.toString(16);
|
|
616
|
+
}
|
|
617
|
+
function ot(e) {
|
|
618
|
+
for (var r = [], f = 0; f < e.length; f++) {
|
|
619
|
+
var v = e.charCodeAt(f);
|
|
620
|
+
if (v <= 127)
|
|
621
|
+
r.push(e.charCodeAt(f));
|
|
622
|
+
else
|
|
623
|
+
for (var w = f, k = (55296 <= v && v <= 57343 && f++, encodeURIComponent(e.slice(w, f + 1)).substr(1).split("%")), $ = 0; $ < k.length; $++)
|
|
624
|
+
r.push(parseInt(k[$], 16));
|
|
625
|
+
}
|
|
626
|
+
return r;
|
|
627
|
+
}
|
|
628
|
+
function xt(e) {
|
|
629
|
+
return y.toByteArray(e);
|
|
630
|
+
}
|
|
631
|
+
function yt(e, r, f, v) {
|
|
632
|
+
for (var w = 0; w < v && !(w + f >= r.length || w >= e.length); w++)
|
|
633
|
+
r[w + f] = e[w];
|
|
634
|
+
return w;
|
|
635
|
+
}
|
|
636
|
+
function Tt(e) {
|
|
637
|
+
try {
|
|
638
|
+
return decodeURIComponent(e);
|
|
639
|
+
} catch {
|
|
640
|
+
return String.fromCharCode(65533);
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
function At(e, r) {
|
|
644
|
+
U(typeof e == "number", "cannot write a non-number as a number"), U(0 <= e, "specified a negative value for writing an unsigned value"), U(e <= r, "value is larger than maximum value for type"), U(Math.floor(e) === e, "value has a fractional component");
|
|
645
|
+
}
|
|
646
|
+
function Lt(e, r, f) {
|
|
647
|
+
U(typeof e == "number", "cannot write a non-number as a number"), U(e <= r, "value larger than maximum allowed value"), U(f <= e, "value smaller than minimum allowed value"), U(Math.floor(e) === e, "value has a fractional component");
|
|
648
|
+
}
|
|
649
|
+
function Nt(e, r, f) {
|
|
650
|
+
U(typeof e == "number", "cannot write a non-number as a number"), U(e <= r, "value larger than maximum allowed value"), U(f <= e, "value smaller than minimum allowed value");
|
|
651
|
+
}
|
|
652
|
+
function U(e, r) {
|
|
653
|
+
if (!e)
|
|
654
|
+
throw new Error(r || "Failed assertion");
|
|
655
|
+
}
|
|
656
|
+
h._augment = function(e) {
|
|
657
|
+
return e._isBuffer = !0, e._get = e.get, e._set = e.set, e.get = D.get, e.set = D.set, e.write = D.write, e.toString = D.toString, e.toLocaleString = D.toString, e.toJSON = D.toJSON, e.copy = D.copy, e.slice = D.slice, e.readUInt8 = D.readUInt8, e.readUInt16LE = D.readUInt16LE, e.readUInt16BE = D.readUInt16BE, e.readUInt32LE = D.readUInt32LE, e.readUInt32BE = D.readUInt32BE, e.readInt8 = D.readInt8, e.readInt16LE = D.readInt16LE, e.readInt16BE = D.readInt16BE, e.readInt32LE = D.readInt32LE, e.readInt32BE = D.readInt32BE, e.readFloatLE = D.readFloatLE, e.readFloatBE = D.readFloatBE, e.readDoubleLE = D.readDoubleLE, e.readDoubleBE = D.readDoubleBE, e.writeUInt8 = D.writeUInt8, e.writeUInt16LE = D.writeUInt16LE, e.writeUInt16BE = D.writeUInt16BE, e.writeUInt32LE = D.writeUInt32LE, e.writeUInt32BE = D.writeUInt32BE, e.writeInt8 = D.writeInt8, e.writeInt16LE = D.writeInt16LE, e.writeInt16BE = D.writeInt16BE, e.writeInt32LE = D.writeInt32LE, e.writeInt32BE = D.writeInt32BE, e.writeFloatLE = D.writeFloatLE, e.writeFloatBE = D.writeFloatBE, e.writeDoubleLE = D.writeDoubleLE, e.writeDoubleBE = D.writeDoubleBE, e.fill = D.fill, e.inspect = D.inspect, e.toArrayBuffer = D.toArrayBuffer, e;
|
|
658
|
+
};
|
|
659
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/buffer/index.js", "/node_modules/gulp-browserify/node_modules/buffer");
|
|
660
|
+
}, { "base64-js": 2, buffer: 3, ieee754: 10, lYpoI2: 11 }], 4: [function(n, a, d) {
|
|
661
|
+
(function(m, b, y, M, S, A, P, T, V) {
|
|
662
|
+
var y = n("buffer").Buffer, C = 4, h = new y(C);
|
|
663
|
+
h.fill(0), a.exports = { hash: function(E, L, _, O) {
|
|
664
|
+
for (var B = L(function(i, c) {
|
|
665
|
+
i.length % C != 0 && (p = i.length + (C - i.length % C), i = y.concat([i, h], p));
|
|
666
|
+
for (var p, j = [], R = c ? i.readInt32BE : i.readInt32LE, x = 0; x < i.length; x += C)
|
|
667
|
+
j.push(R.call(i, x));
|
|
668
|
+
return j;
|
|
669
|
+
}(E = y.isBuffer(E) ? E : new y(E), O), 8 * E.length), L = O, l = new y(_), g = L ? l.writeInt32BE : l.writeInt32LE, s = 0; s < B.length; s++)
|
|
670
|
+
g.call(l, B[s], 4 * s, !0);
|
|
671
|
+
return l;
|
|
672
|
+
} };
|
|
673
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/helpers.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
674
|
+
}, { buffer: 3, lYpoI2: 11 }], 5: [function(n, a, d) {
|
|
675
|
+
(function(m, b, y, M, S, A, P, T, V) {
|
|
676
|
+
var y = n("buffer").Buffer, C = n("./sha"), h = n("./sha256"), E = n("./rng"), L = { sha1: C, sha256: h, md5: n("./md5") }, _ = 64, O = new y(_);
|
|
677
|
+
function B(i, c) {
|
|
678
|
+
var p = L[i = i || "sha1"], j = [];
|
|
679
|
+
return p || l("algorithm:", i, "is not yet supported"), { update: function(R) {
|
|
680
|
+
return y.isBuffer(R) || (R = new y(R)), j.push(R), R.length, this;
|
|
681
|
+
}, digest: function(R) {
|
|
682
|
+
var x = y.concat(j), x = c ? function(D, z, K) {
|
|
683
|
+
y.isBuffer(z) || (z = new y(z)), y.isBuffer(K) || (K = new y(K)), z.length > _ ? z = D(z) : z.length < _ && (z = y.concat([z, O], _));
|
|
684
|
+
for (var q = new y(_), F = new y(_), ot = 0; ot < _; ot++)
|
|
685
|
+
q[ot] = 54 ^ z[ot], F[ot] = 92 ^ z[ot];
|
|
686
|
+
return K = D(y.concat([q, K])), D(y.concat([F, K]));
|
|
687
|
+
}(p, c, x) : p(x);
|
|
688
|
+
return j = null, R ? x.toString(R) : x;
|
|
689
|
+
} };
|
|
690
|
+
}
|
|
691
|
+
function l() {
|
|
692
|
+
var i = [].slice.call(arguments).join(" ");
|
|
693
|
+
throw new Error([i, "we accept pull requests", "http://github.com/dominictarr/crypto-browserify"].join(`
|
|
694
|
+
`));
|
|
695
|
+
}
|
|
696
|
+
O.fill(0), d.createHash = function(i) {
|
|
697
|
+
return B(i);
|
|
698
|
+
}, d.createHmac = B, d.randomBytes = function(i, c) {
|
|
699
|
+
if (!c || !c.call)
|
|
700
|
+
return new y(E(i));
|
|
701
|
+
try {
|
|
702
|
+
c.call(this, void 0, new y(E(i)));
|
|
703
|
+
} catch (p) {
|
|
704
|
+
c(p);
|
|
705
|
+
}
|
|
706
|
+
};
|
|
707
|
+
var g, s = ["createCredentials", "createCipher", "createCipheriv", "createDecipher", "createDecipheriv", "createSign", "createVerify", "createDiffieHellman", "pbkdf2"], u = function(i) {
|
|
708
|
+
d[i] = function() {
|
|
709
|
+
l("sorry,", i, "is not implemented yet");
|
|
710
|
+
};
|
|
711
|
+
};
|
|
712
|
+
for (g in s)
|
|
713
|
+
u(s[g]);
|
|
714
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/index.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
715
|
+
}, { "./md5": 6, "./rng": 7, "./sha": 8, "./sha256": 9, buffer: 3, lYpoI2: 11 }], 6: [function(n, a, d) {
|
|
716
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
717
|
+
var y = n("./helpers");
|
|
718
|
+
function C(l, g) {
|
|
719
|
+
l[g >> 5] |= 128 << g % 32, l[14 + (g + 64 >>> 9 << 4)] = g;
|
|
720
|
+
for (var s = 1732584193, u = -271733879, i = -1732584194, c = 271733878, p = 0; p < l.length; p += 16) {
|
|
721
|
+
var j = s, R = u, x = i, D = c, s = E(s, u, i, c, l[p + 0], 7, -680876936), c = E(c, s, u, i, l[p + 1], 12, -389564586), i = E(i, c, s, u, l[p + 2], 17, 606105819), u = E(u, i, c, s, l[p + 3], 22, -1044525330);
|
|
722
|
+
s = E(s, u, i, c, l[p + 4], 7, -176418897), c = E(c, s, u, i, l[p + 5], 12, 1200080426), i = E(i, c, s, u, l[p + 6], 17, -1473231341), u = E(u, i, c, s, l[p + 7], 22, -45705983), s = E(s, u, i, c, l[p + 8], 7, 1770035416), c = E(c, s, u, i, l[p + 9], 12, -1958414417), i = E(i, c, s, u, l[p + 10], 17, -42063), u = E(u, i, c, s, l[p + 11], 22, -1990404162), s = E(s, u, i, c, l[p + 12], 7, 1804603682), c = E(c, s, u, i, l[p + 13], 12, -40341101), i = E(i, c, s, u, l[p + 14], 17, -1502002290), s = L(s, u = E(u, i, c, s, l[p + 15], 22, 1236535329), i, c, l[p + 1], 5, -165796510), c = L(c, s, u, i, l[p + 6], 9, -1069501632), i = L(i, c, s, u, l[p + 11], 14, 643717713), u = L(u, i, c, s, l[p + 0], 20, -373897302), s = L(s, u, i, c, l[p + 5], 5, -701558691), c = L(c, s, u, i, l[p + 10], 9, 38016083), i = L(i, c, s, u, l[p + 15], 14, -660478335), u = L(u, i, c, s, l[p + 4], 20, -405537848), s = L(s, u, i, c, l[p + 9], 5, 568446438), c = L(c, s, u, i, l[p + 14], 9, -1019803690), i = L(i, c, s, u, l[p + 3], 14, -187363961), u = L(u, i, c, s, l[p + 8], 20, 1163531501), s = L(s, u, i, c, l[p + 13], 5, -1444681467), c = L(c, s, u, i, l[p + 2], 9, -51403784), i = L(i, c, s, u, l[p + 7], 14, 1735328473), s = _(s, u = L(u, i, c, s, l[p + 12], 20, -1926607734), i, c, l[p + 5], 4, -378558), c = _(c, s, u, i, l[p + 8], 11, -2022574463), i = _(i, c, s, u, l[p + 11], 16, 1839030562), u = _(u, i, c, s, l[p + 14], 23, -35309556), s = _(s, u, i, c, l[p + 1], 4, -1530992060), c = _(c, s, u, i, l[p + 4], 11, 1272893353), i = _(i, c, s, u, l[p + 7], 16, -155497632), u = _(u, i, c, s, l[p + 10], 23, -1094730640), s = _(s, u, i, c, l[p + 13], 4, 681279174), c = _(c, s, u, i, l[p + 0], 11, -358537222), i = _(i, c, s, u, l[p + 3], 16, -722521979), u = _(u, i, c, s, l[p + 6], 23, 76029189), s = _(s, u, i, c, l[p + 9], 4, -640364487), c = _(c, s, u, i, l[p + 12], 11, -421815835), i = _(i, c, s, u, l[p + 15], 16, 530742520), s = O(s, u = _(u, i, c, s, l[p + 2], 23, -995338651), i, c, l[p + 0], 6, -198630844), c = O(c, s, u, i, l[p + 7], 10, 1126891415), i = O(i, c, s, u, l[p + 14], 15, -1416354905), u = O(u, i, c, s, l[p + 5], 21, -57434055), s = O(s, u, i, c, l[p + 12], 6, 1700485571), c = O(c, s, u, i, l[p + 3], 10, -1894986606), i = O(i, c, s, u, l[p + 10], 15, -1051523), u = O(u, i, c, s, l[p + 1], 21, -2054922799), s = O(s, u, i, c, l[p + 8], 6, 1873313359), c = O(c, s, u, i, l[p + 15], 10, -30611744), i = O(i, c, s, u, l[p + 6], 15, -1560198380), u = O(u, i, c, s, l[p + 13], 21, 1309151649), s = O(s, u, i, c, l[p + 4], 6, -145523070), c = O(c, s, u, i, l[p + 11], 10, -1120210379), i = O(i, c, s, u, l[p + 2], 15, 718787259), u = O(u, i, c, s, l[p + 9], 21, -343485551), s = B(s, j), u = B(u, R), i = B(i, x), c = B(c, D);
|
|
723
|
+
}
|
|
724
|
+
return Array(s, u, i, c);
|
|
725
|
+
}
|
|
726
|
+
function h(l, g, s, u, i, c) {
|
|
727
|
+
return B((g = B(B(g, l), B(u, c))) << i | g >>> 32 - i, s);
|
|
728
|
+
}
|
|
729
|
+
function E(l, g, s, u, i, c, p) {
|
|
730
|
+
return h(g & s | ~g & u, l, g, i, c, p);
|
|
731
|
+
}
|
|
732
|
+
function L(l, g, s, u, i, c, p) {
|
|
733
|
+
return h(g & u | s & ~u, l, g, i, c, p);
|
|
734
|
+
}
|
|
735
|
+
function _(l, g, s, u, i, c, p) {
|
|
736
|
+
return h(g ^ s ^ u, l, g, i, c, p);
|
|
737
|
+
}
|
|
738
|
+
function O(l, g, s, u, i, c, p) {
|
|
739
|
+
return h(s ^ (g | ~u), l, g, i, c, p);
|
|
740
|
+
}
|
|
741
|
+
function B(l, g) {
|
|
742
|
+
var s = (65535 & l) + (65535 & g);
|
|
743
|
+
return (l >> 16) + (g >> 16) + (s >> 16) << 16 | 65535 & s;
|
|
744
|
+
}
|
|
745
|
+
a.exports = function(l) {
|
|
746
|
+
return y.hash(l, C, 16);
|
|
747
|
+
};
|
|
748
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/md5.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
749
|
+
}, { "./helpers": 4, buffer: 3, lYpoI2: 11 }], 7: [function(n, a, d) {
|
|
750
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
751
|
+
a.exports = function(y) {
|
|
752
|
+
for (var C, h = new Array(y), E = 0; E < y; E++)
|
|
753
|
+
!(3 & E) && (C = 4294967296 * Math.random()), h[E] = C >>> ((3 & E) << 3) & 255;
|
|
754
|
+
return h;
|
|
755
|
+
};
|
|
756
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/rng.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
757
|
+
}, { buffer: 3, lYpoI2: 11 }], 8: [function(n, a, d) {
|
|
758
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
759
|
+
var y = n("./helpers");
|
|
760
|
+
function C(L, _) {
|
|
761
|
+
L[_ >> 5] |= 128 << 24 - _ % 32, L[15 + (_ + 64 >> 9 << 4)] = _;
|
|
762
|
+
for (var O, B, l, g = Array(80), s = 1732584193, u = -271733879, i = -1732584194, c = 271733878, p = -1009589776, j = 0; j < L.length; j += 16) {
|
|
763
|
+
for (var R = s, x = u, D = i, z = c, K = p, q = 0; q < 80; q++) {
|
|
764
|
+
g[q] = q < 16 ? L[j + q] : E(g[q - 3] ^ g[q - 8] ^ g[q - 14] ^ g[q - 16], 1);
|
|
765
|
+
var F = h(h(E(s, 5), (F = u, B = i, l = c, (O = q) < 20 ? F & B | ~F & l : !(O < 40) && O < 60 ? F & B | F & l | B & l : F ^ B ^ l)), h(h(p, g[q]), (O = q) < 20 ? 1518500249 : O < 40 ? 1859775393 : O < 60 ? -1894007588 : -899497514)), p = c, c = i, i = E(u, 30), u = s, s = F;
|
|
766
|
+
}
|
|
767
|
+
s = h(s, R), u = h(u, x), i = h(i, D), c = h(c, z), p = h(p, K);
|
|
768
|
+
}
|
|
769
|
+
return Array(s, u, i, c, p);
|
|
770
|
+
}
|
|
771
|
+
function h(L, _) {
|
|
772
|
+
var O = (65535 & L) + (65535 & _);
|
|
773
|
+
return (L >> 16) + (_ >> 16) + (O >> 16) << 16 | 65535 & O;
|
|
774
|
+
}
|
|
775
|
+
function E(L, _) {
|
|
776
|
+
return L << _ | L >>> 32 - _;
|
|
777
|
+
}
|
|
778
|
+
a.exports = function(L) {
|
|
779
|
+
return y.hash(L, C, 20, !0);
|
|
780
|
+
};
|
|
781
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/sha.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
782
|
+
}, { "./helpers": 4, buffer: 3, lYpoI2: 11 }], 9: [function(n, a, d) {
|
|
783
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
784
|
+
function y(_, O) {
|
|
785
|
+
var B = (65535 & _) + (65535 & O);
|
|
786
|
+
return (_ >> 16) + (O >> 16) + (B >> 16) << 16 | 65535 & B;
|
|
787
|
+
}
|
|
788
|
+
function C(_, O) {
|
|
789
|
+
var B, l = new Array(1116352408, 1899447441, 3049323471, 3921009573, 961987163, 1508970993, 2453635748, 2870763221, 3624381080, 310598401, 607225278, 1426881987, 1925078388, 2162078206, 2614888103, 3248222580, 3835390401, 4022224774, 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, 2554220882, 2821834349, 2952996808, 3210313671, 3336571891, 3584528711, 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, 1695183700, 1986661051, 2177026350, 2456956037, 2730485921, 2820302411, 3259730800, 3345764771, 3516065817, 3600352804, 4094571909, 275423344, 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, 1537002063, 1747873779, 1955562222, 2024104815, 2227730452, 2361852424, 2428436474, 2756734187, 3204031479, 3329325298), g = new Array(1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225), s = new Array(64);
|
|
790
|
+
_[O >> 5] |= 128 << 24 - O % 32, _[15 + (O + 64 >> 9 << 4)] = O;
|
|
791
|
+
for (var u, i, c = 0; c < _.length; c += 16) {
|
|
792
|
+
for (var p = g[0], j = g[1], R = g[2], x = g[3], D = g[4], z = g[5], K = g[6], q = g[7], F = 0; F < 64; F++)
|
|
793
|
+
s[F] = F < 16 ? _[F + c] : y(y(y((i = s[F - 2], E(i, 17) ^ E(i, 19) ^ L(i, 10)), s[F - 7]), (i = s[F - 15], E(i, 7) ^ E(i, 18) ^ L(i, 3))), s[F - 16]), B = y(y(y(y(q, E(i = D, 6) ^ E(i, 11) ^ E(i, 25)), D & z ^ ~D & K), l[F]), s[F]), u = y(E(u = p, 2) ^ E(u, 13) ^ E(u, 22), p & j ^ p & R ^ j & R), q = K, K = z, z = D, D = y(x, B), x = R, R = j, j = p, p = y(B, u);
|
|
794
|
+
g[0] = y(p, g[0]), g[1] = y(j, g[1]), g[2] = y(R, g[2]), g[3] = y(x, g[3]), g[4] = y(D, g[4]), g[5] = y(z, g[5]), g[6] = y(K, g[6]), g[7] = y(q, g[7]);
|
|
795
|
+
}
|
|
796
|
+
return g;
|
|
797
|
+
}
|
|
798
|
+
var h = n("./helpers"), E = function(_, O) {
|
|
799
|
+
return _ >>> O | _ << 32 - O;
|
|
800
|
+
}, L = function(_, O) {
|
|
801
|
+
return _ >>> O;
|
|
802
|
+
};
|
|
803
|
+
a.exports = function(_) {
|
|
804
|
+
return h.hash(_, C, 32, !0);
|
|
805
|
+
};
|
|
806
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/crypto-browserify/sha256.js", "/node_modules/gulp-browserify/node_modules/crypto-browserify");
|
|
807
|
+
}, { "./helpers": 4, buffer: 3, lYpoI2: 11 }], 10: [function(n, a, d) {
|
|
808
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
809
|
+
d.read = function(y, C, h, E, c) {
|
|
810
|
+
var _, O, B = 8 * c - E - 1, l = (1 << B) - 1, g = l >> 1, s = -7, u = h ? c - 1 : 0, i = h ? -1 : 1, c = y[C + u];
|
|
811
|
+
for (u += i, _ = c & (1 << -s) - 1, c >>= -s, s += B; 0 < s; _ = 256 * _ + y[C + u], u += i, s -= 8)
|
|
812
|
+
;
|
|
813
|
+
for (O = _ & (1 << -s) - 1, _ >>= -s, s += E; 0 < s; O = 256 * O + y[C + u], u += i, s -= 8)
|
|
814
|
+
;
|
|
815
|
+
if (_ === 0)
|
|
816
|
+
_ = 1 - g;
|
|
817
|
+
else {
|
|
818
|
+
if (_ === l)
|
|
819
|
+
return O ? NaN : 1 / 0 * (c ? -1 : 1);
|
|
820
|
+
O += Math.pow(2, E), _ -= g;
|
|
821
|
+
}
|
|
822
|
+
return (c ? -1 : 1) * O * Math.pow(2, _ - E);
|
|
823
|
+
}, d.write = function(y, C, h, E, L, p) {
|
|
824
|
+
var O, B, l = 8 * p - L - 1, g = (1 << l) - 1, s = g >> 1, u = L === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, i = E ? 0 : p - 1, c = E ? 1 : -1, p = C < 0 || C === 0 && 1 / C < 0 ? 1 : 0;
|
|
825
|
+
for (C = Math.abs(C), isNaN(C) || C === 1 / 0 ? (B = isNaN(C) ? 1 : 0, O = g) : (O = Math.floor(Math.log(C) / Math.LN2), C * (E = Math.pow(2, -O)) < 1 && (O--, E *= 2), 2 <= (C += 1 <= O + s ? u / E : u * Math.pow(2, 1 - s)) * E && (O++, E /= 2), g <= O + s ? (B = 0, O = g) : 1 <= O + s ? (B = (C * E - 1) * Math.pow(2, L), O += s) : (B = C * Math.pow(2, s - 1) * Math.pow(2, L), O = 0)); 8 <= L; y[h + i] = 255 & B, i += c, B /= 256, L -= 8)
|
|
826
|
+
;
|
|
827
|
+
for (O = O << L | B, l += L; 0 < l; y[h + i] = 255 & O, i += c, O /= 256, l -= 8)
|
|
828
|
+
;
|
|
829
|
+
y[h + i - c] |= 128 * p;
|
|
830
|
+
};
|
|
831
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/ieee754/index.js", "/node_modules/gulp-browserify/node_modules/ieee754");
|
|
832
|
+
}, { buffer: 3, lYpoI2: 11 }], 11: [function(n, a, d) {
|
|
833
|
+
(function(m, b, I, M, S, A, P, T, V) {
|
|
834
|
+
var y, C, h;
|
|
835
|
+
function E() {
|
|
836
|
+
}
|
|
837
|
+
(m = a.exports = {}).nextTick = (C = typeof window < "u" && window.setImmediate, h = typeof window < "u" && window.postMessage && window.addEventListener, C ? function(L) {
|
|
838
|
+
return window.setImmediate(L);
|
|
839
|
+
} : h ? (y = [], window.addEventListener("message", function(L) {
|
|
840
|
+
var _ = L.source;
|
|
841
|
+
_ !== window && _ !== null || L.data !== "process-tick" || (L.stopPropagation(), 0 < y.length && y.shift()());
|
|
842
|
+
}, !0), function(L) {
|
|
843
|
+
y.push(L), window.postMessage("process-tick", "*");
|
|
844
|
+
}) : function(L) {
|
|
845
|
+
setTimeout(L, 0);
|
|
846
|
+
}), m.title = "browser", m.browser = !0, m.env = {}, m.argv = [], m.on = E, m.addListener = E, m.once = E, m.off = E, m.removeListener = E, m.removeAllListeners = E, m.emit = E, m.binding = function(L) {
|
|
847
|
+
throw new Error("process.binding is not supported");
|
|
848
|
+
}, m.cwd = function() {
|
|
849
|
+
return "/";
|
|
850
|
+
}, m.chdir = function(L) {
|
|
851
|
+
throw new Error("process.chdir is not supported");
|
|
852
|
+
};
|
|
853
|
+
}).call(this, n("lYpoI2"), typeof self < "u" ? self : typeof window < "u" ? window : {}, n("buffer").Buffer, arguments[3], arguments[4], arguments[5], arguments[6], "/node_modules/gulp-browserify/node_modules/process/browser.js", "/node_modules/gulp-browserify/node_modules/process");
|
|
854
|
+
}, { buffer: 3, lYpoI2: 11 }] }, {}, [1])(1);
|
|
855
|
+
});
|
|
856
|
+
})(Xt);
|
|
857
|
+
var $t = Xt.exports, it;
|
|
858
|
+
(function(o) {
|
|
859
|
+
o.V0_3 = "0.3", o.V0_4 = "0.4", o.V0_5 = "0.5", o.V0_6 = "0.6";
|
|
860
|
+
})(it || (it = {}));
|
|
861
|
+
var st;
|
|
862
|
+
(function(o) {
|
|
863
|
+
o.V0_2 = "0.2", o.V0_3 = "0.3";
|
|
864
|
+
})(st || (st = {}));
|
|
865
|
+
const Ft = Object.keys(it), Le = it.V0_6, zt = Object.keys(st), pt = st.V0_3;
|
|
866
|
+
var N;
|
|
867
|
+
(function(o) {
|
|
868
|
+
o.Inputs = "inputs", o.Outputs = "outputs", o.State = "state", o.Definition = "definition", o.DefinitionUpdateRequest = "definitionupdaterequest", o.Error = "error", o.UrlHashUpdate = "urlhashupdate", o.Message = "Message";
|
|
869
|
+
})(N || (N = {}));
|
|
870
|
+
var X;
|
|
871
|
+
(function(o) {
|
|
872
|
+
o.InputsUpdate = "InputsUpdate", o.OutputsUpdate = "OutputsUpdate", o.SetupIframeClientRequest = "SetupIframeClientRequest", o.SetupIframeServerResponseAck = "SetupIframeServerResponseAck", o.PluginRequest = "SetupIframeServerPluginRequestResponseAck", o.HashParamsUpdate = "HashParamsUpdate";
|
|
873
|
+
})(X || (X = {}));
|
|
874
|
+
var at;
|
|
875
|
+
(function(o) {
|
|
876
|
+
o.InputsUpdate = "InputsUpdate", o.MessageAck = "MessageAck", o.SetupIframeServerResponse = "SetupIframeServerResponse";
|
|
877
|
+
})(at || (at = {}));
|
|
878
|
+
var kt;
|
|
879
|
+
(function(o) {
|
|
880
|
+
o.State = "metapage/state";
|
|
881
|
+
})(kt || (kt = {}));
|
|
882
|
+
const rt = "metapage/definition", ft = "metapage/state", Qt = zt[zt.length - 1], ae = Ft[Ft.length - 1];
|
|
883
|
+
function Ot(o, t) {
|
|
884
|
+
const n = Et(o), a = Et(t), d = n.pop(), m = a.pop(), b = Pt(n, a);
|
|
885
|
+
return b !== 0 ? b : d && m ? Pt(d.split("."), m.split(".")) : d || m ? d ? -1 : 1 : 0;
|
|
886
|
+
}
|
|
887
|
+
const ue = (o) => typeof o == "string" && /^[v\d]/.test(o) && Zt.test(o), lt = (o, t, n) => {
|
|
888
|
+
le(n);
|
|
889
|
+
const a = Ot(o, t);
|
|
890
|
+
return te[n].includes(a);
|
|
891
|
+
}, fe = (o, t) => {
|
|
892
|
+
const n = t.match(/^([<>=~^]+)/), a = n ? n[1] : "=";
|
|
893
|
+
if (a !== "^" && a !== "~")
|
|
894
|
+
return lt(o, t, a);
|
|
895
|
+
const [d, m, b] = Et(o), [I, M, S] = Et(t);
|
|
896
|
+
return It(d, I) !== 0 ? !1 : a === "^" ? Pt([m, b], [M, S]) >= 0 : It(m, M) !== 0 ? !1 : It(b, S) >= 0;
|
|
897
|
+
};
|
|
898
|
+
Ot.validate = ue;
|
|
899
|
+
Ot.compare = lt;
|
|
900
|
+
Ot.satisfies = fe;
|
|
901
|
+
const Zt = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i, Et = (o) => {
|
|
902
|
+
if (typeof o != "string")
|
|
903
|
+
throw new TypeError("Invalid argument expected string");
|
|
904
|
+
const t = o.match(Zt);
|
|
905
|
+
if (!t)
|
|
906
|
+
throw new Error(`Invalid argument not valid semver ('${o}' received)`);
|
|
907
|
+
return t.shift(), t;
|
|
908
|
+
}, qt = (o) => o === "*" || o === "x" || o === "X", Jt = (o) => {
|
|
909
|
+
const t = parseInt(o, 10);
|
|
910
|
+
return isNaN(t) ? o : t;
|
|
911
|
+
}, he = (o, t) => typeof o != typeof t ? [String(o), String(t)] : [o, t], It = (o, t) => {
|
|
912
|
+
if (qt(o) || qt(t))
|
|
913
|
+
return 0;
|
|
914
|
+
const [n, a] = he(Jt(o), Jt(t));
|
|
915
|
+
return n > a ? 1 : n < a ? -1 : 0;
|
|
916
|
+
}, Pt = (o, t) => {
|
|
917
|
+
for (let n = 0; n < Math.max(o.length, t.length); n++) {
|
|
918
|
+
const a = It(o[n] || 0, t[n] || 0);
|
|
919
|
+
if (a !== 0)
|
|
920
|
+
return a;
|
|
921
|
+
}
|
|
922
|
+
return 0;
|
|
923
|
+
}, te = {
|
|
924
|
+
">": [1],
|
|
925
|
+
">=": [0, 1],
|
|
926
|
+
"=": [0],
|
|
927
|
+
"<=": [-1, 0],
|
|
928
|
+
"<": [-1]
|
|
929
|
+
}, Wt = Object.keys(te), le = (o) => {
|
|
930
|
+
if (typeof o != "string")
|
|
931
|
+
throw new TypeError(
|
|
932
|
+
`Invalid operator type, expected string but got ${typeof o}`
|
|
933
|
+
);
|
|
934
|
+
if (Wt.indexOf(o) === -1)
|
|
935
|
+
throw new Error(
|
|
936
|
+
`Invalid operator, expected one of ${Wt.join("|")}`
|
|
937
|
+
);
|
|
938
|
+
};
|
|
939
|
+
var ee = { exports: {} };
|
|
940
|
+
(function(o) {
|
|
941
|
+
var t = Object.prototype.hasOwnProperty, n = "~";
|
|
942
|
+
function a() {
|
|
943
|
+
}
|
|
944
|
+
Object.create && (a.prototype = /* @__PURE__ */ Object.create(null), new a().__proto__ || (n = !1));
|
|
945
|
+
function d(M, S, A) {
|
|
946
|
+
this.fn = M, this.context = S, this.once = A || !1;
|
|
947
|
+
}
|
|
948
|
+
function m(M, S, A, P, T) {
|
|
949
|
+
if (typeof A != "function")
|
|
950
|
+
throw new TypeError("The listener must be a function");
|
|
951
|
+
var V = new d(A, P || M, T), y = n ? n + S : S;
|
|
952
|
+
return M._events[y] ? M._events[y].fn ? M._events[y] = [M._events[y], V] : M._events[y].push(V) : (M._events[y] = V, M._eventsCount++), M;
|
|
953
|
+
}
|
|
954
|
+
function b(M, S) {
|
|
955
|
+
--M._eventsCount === 0 ? M._events = new a() : delete M._events[S];
|
|
956
|
+
}
|
|
957
|
+
function I() {
|
|
958
|
+
this._events = new a(), this._eventsCount = 0;
|
|
959
|
+
}
|
|
960
|
+
I.prototype.eventNames = function() {
|
|
961
|
+
var S = [], A, P;
|
|
962
|
+
if (this._eventsCount === 0)
|
|
963
|
+
return S;
|
|
964
|
+
for (P in A = this._events)
|
|
965
|
+
t.call(A, P) && S.push(n ? P.slice(1) : P);
|
|
966
|
+
return Object.getOwnPropertySymbols ? S.concat(Object.getOwnPropertySymbols(A)) : S;
|
|
967
|
+
}, I.prototype.listeners = function(S) {
|
|
968
|
+
var A = n ? n + S : S, P = this._events[A];
|
|
969
|
+
if (!P)
|
|
970
|
+
return [];
|
|
971
|
+
if (P.fn)
|
|
972
|
+
return [P.fn];
|
|
973
|
+
for (var T = 0, V = P.length, y = new Array(V); T < V; T++)
|
|
974
|
+
y[T] = P[T].fn;
|
|
975
|
+
return y;
|
|
976
|
+
}, I.prototype.listenerCount = function(S) {
|
|
977
|
+
var A = n ? n + S : S, P = this._events[A];
|
|
978
|
+
return P ? P.fn ? 1 : P.length : 0;
|
|
979
|
+
}, I.prototype.emit = function(S, A, P, T, V, y) {
|
|
980
|
+
var C = n ? n + S : S;
|
|
981
|
+
if (!this._events[C])
|
|
982
|
+
return !1;
|
|
983
|
+
var h = this._events[C], E = arguments.length, L, _;
|
|
984
|
+
if (h.fn) {
|
|
985
|
+
switch (h.once && this.removeListener(S, h.fn, void 0, !0), E) {
|
|
986
|
+
case 1:
|
|
987
|
+
return h.fn.call(h.context), !0;
|
|
988
|
+
case 2:
|
|
989
|
+
return h.fn.call(h.context, A), !0;
|
|
990
|
+
case 3:
|
|
991
|
+
return h.fn.call(h.context, A, P), !0;
|
|
992
|
+
case 4:
|
|
993
|
+
return h.fn.call(h.context, A, P, T), !0;
|
|
994
|
+
case 5:
|
|
995
|
+
return h.fn.call(h.context, A, P, T, V), !0;
|
|
996
|
+
case 6:
|
|
997
|
+
return h.fn.call(h.context, A, P, T, V, y), !0;
|
|
998
|
+
}
|
|
999
|
+
for (_ = 1, L = new Array(E - 1); _ < E; _++)
|
|
1000
|
+
L[_ - 1] = arguments[_];
|
|
1001
|
+
h.fn.apply(h.context, L);
|
|
1002
|
+
} else {
|
|
1003
|
+
var O = h.length, B;
|
|
1004
|
+
for (_ = 0; _ < O; _++)
|
|
1005
|
+
switch (h[_].once && this.removeListener(S, h[_].fn, void 0, !0), E) {
|
|
1006
|
+
case 1:
|
|
1007
|
+
h[_].fn.call(h[_].context);
|
|
1008
|
+
break;
|
|
1009
|
+
case 2:
|
|
1010
|
+
h[_].fn.call(h[_].context, A);
|
|
1011
|
+
break;
|
|
1012
|
+
case 3:
|
|
1013
|
+
h[_].fn.call(h[_].context, A, P);
|
|
1014
|
+
break;
|
|
1015
|
+
case 4:
|
|
1016
|
+
h[_].fn.call(h[_].context, A, P, T);
|
|
1017
|
+
break;
|
|
1018
|
+
default:
|
|
1019
|
+
if (!L)
|
|
1020
|
+
for (B = 1, L = new Array(E - 1); B < E; B++)
|
|
1021
|
+
L[B - 1] = arguments[B];
|
|
1022
|
+
h[_].fn.apply(h[_].context, L);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
return !0;
|
|
1026
|
+
}, I.prototype.on = function(S, A, P) {
|
|
1027
|
+
return m(this, S, A, P, !1);
|
|
1028
|
+
}, I.prototype.once = function(S, A, P) {
|
|
1029
|
+
return m(this, S, A, P, !0);
|
|
1030
|
+
}, I.prototype.removeListener = function(S, A, P, T) {
|
|
1031
|
+
var V = n ? n + S : S;
|
|
1032
|
+
if (!this._events[V])
|
|
1033
|
+
return this;
|
|
1034
|
+
if (!A)
|
|
1035
|
+
return b(this, V), this;
|
|
1036
|
+
var y = this._events[V];
|
|
1037
|
+
if (y.fn)
|
|
1038
|
+
y.fn === A && (!T || y.once) && (!P || y.context === P) && b(this, V);
|
|
1039
|
+
else {
|
|
1040
|
+
for (var C = 0, h = [], E = y.length; C < E; C++)
|
|
1041
|
+
(y[C].fn !== A || T && !y[C].once || P && y[C].context !== P) && h.push(y[C]);
|
|
1042
|
+
h.length ? this._events[V] = h.length === 1 ? h[0] : h : b(this, V);
|
|
1043
|
+
}
|
|
1044
|
+
return this;
|
|
1045
|
+
}, I.prototype.removeAllListeners = function(S) {
|
|
1046
|
+
var A;
|
|
1047
|
+
return S ? (A = n ? n + S : S, this._events[A] && b(this, A)) : (this._events = new a(), this._eventsCount = 0), this;
|
|
1048
|
+
}, I.prototype.off = I.prototype.removeListener, I.prototype.addListener = I.prototype.on, I.prefixed = n, I.EventEmitter = I, o.exports = I;
|
|
1049
|
+
})(ee);
|
|
1050
|
+
var Dt = ee.exports, mt;
|
|
1051
|
+
(function(o) {
|
|
1052
|
+
o.mp_debug = "mp_debug";
|
|
1053
|
+
})(mt || (mt = {}));
|
|
1054
|
+
const ce = () => {
|
|
1055
|
+
try {
|
|
1056
|
+
return window !== window.top;
|
|
1057
|
+
} catch {
|
|
1058
|
+
return !1;
|
|
1059
|
+
}
|
|
1060
|
+
}, ne = {
|
|
1061
|
+
version: pt,
|
|
1062
|
+
metaframes: {}
|
|
1063
|
+
};
|
|
1064
|
+
class de extends Dt.EventEmitter {
|
|
1065
|
+
constructor() {
|
|
1066
|
+
super(), this._definition = ne, this.getDefinition = this.getDefinition.bind(this);
|
|
1067
|
+
}
|
|
1068
|
+
error(t) {
|
|
1069
|
+
throw "Subclass should implement";
|
|
1070
|
+
}
|
|
1071
|
+
getDefinition() {
|
|
1072
|
+
return this._definition;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
const ie = (o) => {
|
|
1076
|
+
if (o === null)
|
|
1077
|
+
throw "Metapage definition cannot be null";
|
|
1078
|
+
if (typeof o == "string")
|
|
1079
|
+
try {
|
|
1080
|
+
o = JSON.parse(o);
|
|
1081
|
+
} catch {
|
|
1082
|
+
throw `Cannot parse into JSON:
|
|
1083
|
+
${o}`;
|
|
1084
|
+
}
|
|
1085
|
+
if (!o.version)
|
|
1086
|
+
throw 'Missing "version" key in metapage definition';
|
|
1087
|
+
let t;
|
|
1088
|
+
switch (re(o.version)) {
|
|
1089
|
+
case st.V0_2: {
|
|
1090
|
+
t = ie(me(o));
|
|
1091
|
+
break;
|
|
1092
|
+
}
|
|
1093
|
+
case st.V0_3: {
|
|
1094
|
+
t = o;
|
|
1095
|
+
break;
|
|
1096
|
+
}
|
|
1097
|
+
default:
|
|
1098
|
+
console.warn(`Metapage definition version=${o.version} but we only know up to version ${pt}. Assuming the definition is compatible, but it's the future!`), t = o;
|
|
1099
|
+
break;
|
|
1100
|
+
}
|
|
1101
|
+
return t;
|
|
1102
|
+
}, se = (o, t) => {
|
|
1103
|
+
if (o)
|
|
1104
|
+
switch (o.version) {
|
|
1105
|
+
case void 0:
|
|
1106
|
+
case it.V0_3:
|
|
1107
|
+
case it.V0_4:
|
|
1108
|
+
return se(pe(o));
|
|
1109
|
+
case it.V0_5:
|
|
1110
|
+
return ge(o);
|
|
1111
|
+
case it.V0_6:
|
|
1112
|
+
return o;
|
|
1113
|
+
default:
|
|
1114
|
+
if (t && t.errorIfUnknownVersion)
|
|
1115
|
+
throw `Unsupported metaframe version. Please upgrade to a new version: npm i @metapages/metapage@latest
|
|
1116
|
+
${JSON.stringify(o)}
|
|
1117
|
+
${window.location.href}`;
|
|
1118
|
+
return console.error(`Unsupported metaframe version. Not throwing an error because you might not be able to upgrade. Please upgrade to a new version: npm i @metapages/metapage@latest
|
|
1119
|
+
${JSON.stringify(o)}
|
|
1120
|
+
${window.location.href}`), o;
|
|
1121
|
+
}
|
|
1122
|
+
}, pe = (o) => {
|
|
1123
|
+
const { version: t, inputs: n, outputs: a, allow: d, metadata: m, ...b } = o, I = m, { title: M, author: S, image: A, descriptionUrl: P, keywords: T, iconUrl: V, ...y } = I, C = {
|
|
1124
|
+
name: M,
|
|
1125
|
+
author: S,
|
|
1126
|
+
description: P,
|
|
1127
|
+
image: A,
|
|
1128
|
+
tags: T,
|
|
1129
|
+
...y
|
|
1130
|
+
};
|
|
1131
|
+
return {
|
|
1132
|
+
version: it.V0_5,
|
|
1133
|
+
inputs: n,
|
|
1134
|
+
outputs: a,
|
|
1135
|
+
allow: d,
|
|
1136
|
+
metadata: C,
|
|
1137
|
+
...b
|
|
1138
|
+
};
|
|
1139
|
+
}, ge = (o) => {
|
|
1140
|
+
const { metadata: t, ...n } = o, a = {
|
|
1141
|
+
...n,
|
|
1142
|
+
version: it.V0_6
|
|
1143
|
+
};
|
|
1144
|
+
if (t) {
|
|
1145
|
+
const { edit: d, ...m } = t, b = { ...m };
|
|
1146
|
+
if (a.metadata = b, d && !(b && b.operations && b.operations.edit))
|
|
1147
|
+
switch (b.operations || (b.operations = {}), d.type) {
|
|
1148
|
+
case "metapage":
|
|
1149
|
+
const I = d.value, M = {
|
|
1150
|
+
type: "metapage",
|
|
1151
|
+
metapage: I.definition,
|
|
1152
|
+
metaframe: I.key || "edit"
|
|
1153
|
+
};
|
|
1154
|
+
b.operations.edit = M;
|
|
1155
|
+
break;
|
|
1156
|
+
case "metaframe":
|
|
1157
|
+
const S = d.value, A = {
|
|
1158
|
+
type: "url",
|
|
1159
|
+
url: S.url,
|
|
1160
|
+
params: S.params ? S.params.map((P) => ({
|
|
1161
|
+
to: P.to,
|
|
1162
|
+
from: P.from,
|
|
1163
|
+
toType: P.toType === "path" ? void 0 : P.toType
|
|
1164
|
+
})) : void 0
|
|
1165
|
+
};
|
|
1166
|
+
b.operations.edit = A;
|
|
1167
|
+
break;
|
|
1168
|
+
default:
|
|
1169
|
+
throw `Unsupported edit type: ${d.type} in metadata for metaframe ${JSON.stringify(t)}`;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return a;
|
|
1173
|
+
}, me = (o) => (o.version = st.V0_3, o), St = (o, t) => {
|
|
1174
|
+
if (!t)
|
|
1175
|
+
return !1;
|
|
1176
|
+
let n = !1;
|
|
1177
|
+
return Object.keys(t).forEach((a) => {
|
|
1178
|
+
n = !0, t[a] === void 0 ? delete o[a] : o[a] = t[a];
|
|
1179
|
+
}), n;
|
|
1180
|
+
}, re = (o) => {
|
|
1181
|
+
if (o === "latest")
|
|
1182
|
+
return pt;
|
|
1183
|
+
if (lt(o, "0.2", "<"))
|
|
1184
|
+
throw `Unknown version: ${o}`;
|
|
1185
|
+
return lt(o, "0.2", ">=") && lt(o, st.V0_3, "<") ? st.V0_2 : lt(o, "0.3", ">=") ? st.V0_3 : (console.log(`Could not match version=${o} to any known version, assuming ${pt}`), pt);
|
|
1186
|
+
}, Ue = (o) => window.location.search ? new URLSearchParams(window.location.search).get(o) : null, ke = () => new URLSearchParams(window.location.search).has(mt.mp_debug), Ct = () => {
|
|
1187
|
+
const o = new URLSearchParams(window.location.search).get(mt.mp_debug);
|
|
1188
|
+
return o === "true" || o === "1";
|
|
1189
|
+
}, ye = (o) => o.filter((n) => new URLSearchParams(window.location.search).has(n)).length > 0, Pe = (o = 8) => Bt(o), be = (o = 8) => Bt(o), Ce = (o = 8) => Bt(o), Yt = "abcdefghijklmnopqrstuvwxyz0123456789", Bt = (o = 8) => {
|
|
1190
|
+
for (var t = "", n = Yt.length, a = 0; a < o; a++)
|
|
1191
|
+
t += Yt.charAt(Math.floor(Math.random() * n));
|
|
1192
|
+
return t;
|
|
1193
|
+
}, Rt = (o, t, n) => {
|
|
1194
|
+
t = t || "000", t && t.trim() == "" && (t = void 0);
|
|
1195
|
+
let a;
|
|
1196
|
+
if (typeof o == "string" ? a = o : typeof o == "number" ? a = o + "" : a = JSON.stringify(o, null, " "), t && t.trim() != "") {
|
|
1197
|
+
var d = `color: #${t}`;
|
|
1198
|
+
n && (d = `${d}; background: #${n}`), a = `%c${a}`, window.console.log(a, d);
|
|
1199
|
+
} else
|
|
1200
|
+
window.console.log(a);
|
|
1201
|
+
}, oe = (o) => we(_e(o)), _e = (o) => {
|
|
1202
|
+
var t = 0;
|
|
1203
|
+
for (let n = 0; n < o.length; n++)
|
|
1204
|
+
t = o.charCodeAt(n) + ((t << 5) - t);
|
|
1205
|
+
return t;
|
|
1206
|
+
}, we = (o) => {
|
|
1207
|
+
var t = (o & 16777215).toString(16).toUpperCase();
|
|
1208
|
+
return "00000".substring(0, 6 - t.length) + t;
|
|
1209
|
+
}, Ut = () => document.readyState == "complete" || document.readyState == "interactive", jt = async () => Ut() ? Promise.resolve() : new Promise((o) => {
|
|
1210
|
+
if (Ut()) {
|
|
1211
|
+
o();
|
|
1212
|
+
return;
|
|
1213
|
+
}
|
|
1214
|
+
let t = !1;
|
|
1215
|
+
window.addEventListener("load", () => {
|
|
1216
|
+
t || (t = !0, o());
|
|
1217
|
+
}), setTimeout(() => {
|
|
1218
|
+
!t && Ut() && (t = !0, o());
|
|
1219
|
+
}, 200);
|
|
1220
|
+
});
|
|
1221
|
+
var ct = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", dt = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
1222
|
+
for (var _t = 0; _t < ct.length; _t++)
|
|
1223
|
+
dt[ct.charCodeAt(_t)] = _t;
|
|
1224
|
+
var wt = function(o) {
|
|
1225
|
+
var t = new Uint8Array(o), n, a = t.length, d = "";
|
|
1226
|
+
for (n = 0; n < a; n += 3)
|
|
1227
|
+
d += ct[t[n] >> 2], d += ct[(t[n] & 3) << 4 | t[n + 1] >> 4], d += ct[(t[n + 1] & 15) << 2 | t[n + 2] >> 6], d += ct[t[n + 2] & 63];
|
|
1228
|
+
return a % 3 === 2 ? d = d.substring(0, d.length - 1) + "=" : a % 3 === 1 && (d = d.substring(0, d.length - 2) + "=="), d;
|
|
1229
|
+
}, vt = function(o) {
|
|
1230
|
+
var t = o.length * 0.75, n = o.length, a, d = 0, m, b, I, M;
|
|
1231
|
+
o[o.length - 1] === "=" && (t--, o[o.length - 2] === "=" && t--);
|
|
1232
|
+
var S = new ArrayBuffer(t), A = new Uint8Array(S);
|
|
1233
|
+
for (a = 0; a < n; a += 4)
|
|
1234
|
+
m = dt[o.charCodeAt(a)], b = dt[o.charCodeAt(a + 1)], I = dt[o.charCodeAt(a + 2)], M = dt[o.charCodeAt(a + 3)], A[d++] = m << 2 | b >> 4, A[d++] = (b & 15) << 4 | I >> 2, A[d++] = (I & 3) << 6 | M & 63;
|
|
1235
|
+
return S;
|
|
1236
|
+
};
|
|
1237
|
+
const Mt = async (o) => {
|
|
1238
|
+
for (const t of Object.keys(o)) {
|
|
1239
|
+
const n = await ve(o[t]);
|
|
1240
|
+
o[t] = n;
|
|
1241
|
+
}
|
|
1242
|
+
return o;
|
|
1243
|
+
}, gt = async (o) => {
|
|
1244
|
+
for (const t of Object.keys(o)) {
|
|
1245
|
+
const n = await Ie(o[t]);
|
|
1246
|
+
o[t] = n;
|
|
1247
|
+
}
|
|
1248
|
+
return o;
|
|
1249
|
+
}, ve = async (o) => {
|
|
1250
|
+
if (o instanceof Int8Array || o instanceof Uint8Array || o instanceof Uint8ClampedArray || o instanceof Int16Array || o instanceof Uint16Array || o instanceof Int32Array || o instanceof Uint32Array || o instanceof Float32Array || o instanceof Float64Array) {
|
|
1251
|
+
const t = o, n = {
|
|
1252
|
+
_s: !0,
|
|
1253
|
+
_c: o.constructor.name,
|
|
1254
|
+
value: wt(t.buffer),
|
|
1255
|
+
byteLength: t.byteLength,
|
|
1256
|
+
byteOffset: t.byteOffset,
|
|
1257
|
+
size: t.byteLength
|
|
1258
|
+
};
|
|
1259
|
+
return Promise.resolve(n);
|
|
1260
|
+
} else if (o instanceof File) {
|
|
1261
|
+
const t = o, n = await t.arrayBuffer();
|
|
1262
|
+
return {
|
|
1263
|
+
_s: !0,
|
|
1264
|
+
_c: File.name,
|
|
1265
|
+
value: wt(n),
|
|
1266
|
+
name: t.name,
|
|
1267
|
+
fileType: t.type,
|
|
1268
|
+
lastModified: t.lastModified,
|
|
1269
|
+
size: n.byteLength
|
|
1270
|
+
};
|
|
1271
|
+
} else if (o instanceof Blob) {
|
|
1272
|
+
const t = o, n = await t.arrayBuffer();
|
|
1273
|
+
return {
|
|
1274
|
+
_s: !0,
|
|
1275
|
+
_c: Blob.name,
|
|
1276
|
+
value: wt(n),
|
|
1277
|
+
fileType: t.type,
|
|
1278
|
+
size: n.byteLength
|
|
1279
|
+
};
|
|
1280
|
+
} else if (o instanceof ArrayBuffer) {
|
|
1281
|
+
const t = o, n = {
|
|
1282
|
+
_s: !0,
|
|
1283
|
+
_c: ArrayBuffer.name,
|
|
1284
|
+
value: wt(t),
|
|
1285
|
+
size: t.byteLength
|
|
1286
|
+
};
|
|
1287
|
+
return Promise.resolve(n);
|
|
1288
|
+
}
|
|
1289
|
+
return Promise.resolve(o);
|
|
1290
|
+
}, Ie = (o) => {
|
|
1291
|
+
if (!(o && typeof o == "object" && o._s === !0))
|
|
1292
|
+
return o;
|
|
1293
|
+
const t = o, n = t._c;
|
|
1294
|
+
if (n === Blob.name) {
|
|
1295
|
+
const b = o;
|
|
1296
|
+
return new Blob([vt(t.value)], {
|
|
1297
|
+
type: b.fileType
|
|
1298
|
+
});
|
|
1299
|
+
} else if (n === File.name) {
|
|
1300
|
+
const b = o;
|
|
1301
|
+
return new File([vt(t.value)], b.name, {
|
|
1302
|
+
type: b.fileType,
|
|
1303
|
+
lastModified: b.lastModified
|
|
1304
|
+
});
|
|
1305
|
+
} else if (n === ArrayBuffer.name)
|
|
1306
|
+
return vt(t.value);
|
|
1307
|
+
const a = o, d = vt(a.value), m = a._c;
|
|
1308
|
+
try {
|
|
1309
|
+
return new globalThis[m](d);
|
|
1310
|
+
} catch {
|
|
1311
|
+
}
|
|
1312
|
+
return o;
|
|
1313
|
+
};
|
|
1314
|
+
class Ht extends Dt.EventEmitter {
|
|
1315
|
+
constructor(t, n, a, d, m, b = !1) {
|
|
1316
|
+
if (super(), this.inputs = {}, this.outputs = {}, this._disposables = [], this._rpcListeners = [], this._loaded = !1, this._onLoaded = [], this._sendInputsAfterRegistration = !1, this._plugin = !1, this._cachedEventInputsUpdate = {
|
|
1317
|
+
iframeId: void 0,
|
|
1318
|
+
inputs: void 0
|
|
1319
|
+
}, this._cachedEventOutputsUpdate = {
|
|
1320
|
+
iframeId: null,
|
|
1321
|
+
inputs: null
|
|
1322
|
+
}, !n.startsWith("http")) {
|
|
1323
|
+
for (; n.startsWith("/"); )
|
|
1324
|
+
n = n.substring(1);
|
|
1325
|
+
n = window.location.protocol + "//" + window.location.hostname + (window.location.port && window.location.port != "" ? ":" + window.location.port : "") + "/" + n;
|
|
1326
|
+
}
|
|
1327
|
+
this.url = n, this._metapage = t;
|
|
1328
|
+
var I = new URL(this.url);
|
|
1329
|
+
b && I.searchParams.set(mt.mp_debug, "true"), this.url = I.href, this.id = a, this._debug = b, this._parentId = d, this._color = oe(this.id), this._consoleBackgroundColor = m, this._iframe = document.createElement("iframe"), this._iframe.name = this.id;
|
|
1330
|
+
const M = this;
|
|
1331
|
+
this.iframe = new Promise((S) => {
|
|
1332
|
+
jt().then(async () => {
|
|
1333
|
+
if (M._iframe) {
|
|
1334
|
+
const A = await M.getDefinition();
|
|
1335
|
+
if (!M._iframe)
|
|
1336
|
+
return;
|
|
1337
|
+
A && A.allow && (M._iframe.allow = A.allow), M._iframe.src = this.url, S(M._iframe);
|
|
1338
|
+
}
|
|
1339
|
+
});
|
|
1340
|
+
}), this.ack = this.ack.bind(this), this.dispose = this.dispose.bind(this), this.getDefinition = this.getDefinition.bind(this), this.getDefinitionUrl = this.getDefinitionUrl.bind(this), this.setPlugin = this.setPlugin.bind(this), this.hasPermissionsDefinition = this.hasPermissionsDefinition.bind(this), this.hasPermissionsState = this.hasPermissionsState.bind(this), this.log = this.log.bind(this), this.logInternal = this.logInternal.bind(this), this.onInput = this.onInput.bind(this), this.onInputs = this.onInputs.bind(this), this.onOutput = this.onOutput.bind(this), this.onOutputs = this.onOutputs.bind(this), this.register = this.register.bind(this), this.registered = this.registered.bind(this), this.sendInputs = this.sendInputs.bind(this), this.sendOrBufferPostMessage = this.sendOrBufferPostMessage.bind(this), this.sendRpc = this.sendRpc.bind(this), this.sendRpcInternal = this.sendRpcInternal.bind(this), this.setInput = this.setInput.bind(this), this.setInputs = this.setInputs.bind(this), this.setMetapage = this.setMetapage.bind(this), this.setOutput = this.setOutput.bind(this), this.setOutputs = this.setOutputs.bind(this), this.setPlugin = this.setPlugin.bind(this), this.addListenerReturnDisposer = this.addListenerReturnDisposer.bind(this), this.isDisposed = this.isDisposed.bind(this);
|
|
1341
|
+
}
|
|
1342
|
+
addListenerReturnDisposer(t, n) {
|
|
1343
|
+
return super.addListener(t, n), () => {
|
|
1344
|
+
super.removeListener(t, n);
|
|
1345
|
+
};
|
|
1346
|
+
}
|
|
1347
|
+
setPlugin() {
|
|
1348
|
+
if (this._loaded)
|
|
1349
|
+
throw "Cannot setPlugin after MetapageIFrameRpcClient already loaded";
|
|
1350
|
+
return this._plugin = !0, this;
|
|
1351
|
+
}
|
|
1352
|
+
setMetapage(t) {
|
|
1353
|
+
return this._metapage = t, this;
|
|
1354
|
+
}
|
|
1355
|
+
hasPermissionsState() {
|
|
1356
|
+
return this._definition !== void 0 && this._definition.inputs !== void 0 && this._definition.inputs[ft] !== void 0;
|
|
1357
|
+
}
|
|
1358
|
+
hasPermissionsDefinition() {
|
|
1359
|
+
return this._definition !== void 0 && this._definition.inputs !== void 0 && this._definition.inputs[rt] !== void 0;
|
|
1360
|
+
}
|
|
1361
|
+
getDefinitionUrl() {
|
|
1362
|
+
var t = new URL(this.url);
|
|
1363
|
+
return t.pathname = t.pathname + (t.pathname.endsWith("/") ? "metaframe.json" : "/metaframe.json"), t.href;
|
|
1364
|
+
}
|
|
1365
|
+
async getDefinition() {
|
|
1366
|
+
if (this._definition)
|
|
1367
|
+
return this._definition;
|
|
1368
|
+
var t = this.getDefinitionUrl();
|
|
1369
|
+
try {
|
|
1370
|
+
const n = await window.fetch(t);
|
|
1371
|
+
if (n.ok) {
|
|
1372
|
+
const a = await n.json(), d = se(a);
|
|
1373
|
+
return this._definition = d, this._definition;
|
|
1374
|
+
} else
|
|
1375
|
+
this.emit(N.Error, `Failed to fetch: ${t}
|
|
1376
|
+
Status: ${n.status}
|
|
1377
|
+
Status text: ${n.statusText}`);
|
|
1378
|
+
} catch (n) {
|
|
1379
|
+
this.emit(N.Error, `Failed to fetch or convert: ${t}
|
|
1380
|
+
Error: ${n}`);
|
|
1381
|
+
}
|
|
1382
|
+
}
|
|
1383
|
+
setInput(t, n) {
|
|
1384
|
+
console.assert(!!t);
|
|
1385
|
+
var a = {};
|
|
1386
|
+
a[t] = n, this.setInputs(a);
|
|
1387
|
+
}
|
|
1388
|
+
setInputs(t) {
|
|
1389
|
+
if (this.log({ m: "MetapageIFrameRpcClient", inputs: t }), !St(this.inputs, t))
|
|
1390
|
+
return this;
|
|
1391
|
+
if (this._loaded || (this._sendInputsAfterRegistration = !0), this._iframe.parentNode && this._loaded && this.sendInputs(t), this.emit(N.Inputs, this.inputs), this._metapage.listenerCount(N.Inputs) > 0) {
|
|
1392
|
+
var n = {};
|
|
1393
|
+
n[this.id] = t, this._metapage.emit(N.Inputs, n);
|
|
1394
|
+
}
|
|
1395
|
+
return this;
|
|
1396
|
+
}
|
|
1397
|
+
setOutput(t, n) {
|
|
1398
|
+
console.assert(!!t);
|
|
1399
|
+
var a = {};
|
|
1400
|
+
a[t] = n, this.setOutputs(a);
|
|
1401
|
+
}
|
|
1402
|
+
setOutputs(t) {
|
|
1403
|
+
if (St(this.outputs, t) && (this.emit(N.Outputs, t), this._metapage.listenerCount(N.Outputs) > 0)) {
|
|
1404
|
+
var n = {};
|
|
1405
|
+
n[this.id] = this.outputs, this._metapage.emit(N.Outputs, n);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
onInputs(t) {
|
|
1409
|
+
return this.addListenerReturnDisposer(N.Inputs, t);
|
|
1410
|
+
}
|
|
1411
|
+
onInput(t, n) {
|
|
1412
|
+
var a = function(d) {
|
|
1413
|
+
d.hasOwnProperty(t) && n(d[t]);
|
|
1414
|
+
};
|
|
1415
|
+
return this.addListenerReturnDisposer(N.Inputs, a);
|
|
1416
|
+
}
|
|
1417
|
+
onOutputs(t) {
|
|
1418
|
+
return this.addListenerReturnDisposer(N.Outputs, t);
|
|
1419
|
+
}
|
|
1420
|
+
onOutput(t, n) {
|
|
1421
|
+
var a = function(d) {
|
|
1422
|
+
d.hasOwnProperty(t) && n(d[t]);
|
|
1423
|
+
};
|
|
1424
|
+
return this.addListenerReturnDisposer(N.Outputs, a);
|
|
1425
|
+
}
|
|
1426
|
+
isDisposed() {
|
|
1427
|
+
return this.inputs === void 0;
|
|
1428
|
+
}
|
|
1429
|
+
dispose() {
|
|
1430
|
+
for (super.removeAllListeners(); this._disposables && this._disposables.length > 0; ) {
|
|
1431
|
+
const t = this._disposables.pop();
|
|
1432
|
+
t && t();
|
|
1433
|
+
}
|
|
1434
|
+
this._rpcListeners = void 0, this.inputs = void 0, this.outputs = void 0, this._iframe && this._iframe.parentNode && this._iframe.parentNode.removeChild(this._iframe), this._iframe = void 0, this._bufferMessages = void 0, this._bufferTimeout && (window.clearInterval(this._bufferTimeout), this._bufferTimeout = void 0), this._metapage = void 0;
|
|
1435
|
+
}
|
|
1436
|
+
register() {
|
|
1437
|
+
var t = {
|
|
1438
|
+
iframeId: this.id,
|
|
1439
|
+
parentId: this._parentId,
|
|
1440
|
+
plugin: this._plugin,
|
|
1441
|
+
state: {
|
|
1442
|
+
inputs: this.inputs
|
|
1443
|
+
},
|
|
1444
|
+
version: Qt
|
|
1445
|
+
};
|
|
1446
|
+
this.sendRpcInternal(at.SetupIframeServerResponse, t);
|
|
1447
|
+
}
|
|
1448
|
+
registered(t) {
|
|
1449
|
+
if (this.log({ m: "MetapageIFrameRpcClient.registered", inputs: this.inputs }), !this._loaded) {
|
|
1450
|
+
if (!t)
|
|
1451
|
+
throw "Cannot register without a version";
|
|
1452
|
+
for (this.version = t, this._loaded = !0; this._onLoaded && this._onLoaded.length > 0; )
|
|
1453
|
+
this._onLoaded.pop()();
|
|
1454
|
+
this._sendInputsAfterRegistration && this.sendInputs(this.inputs);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
async sendInputs(t) {
|
|
1458
|
+
t = await Mt(t), this.sendRpc(at.InputsUpdate, {
|
|
1459
|
+
inputs: t,
|
|
1460
|
+
parentId: this._parentId
|
|
1461
|
+
});
|
|
1462
|
+
}
|
|
1463
|
+
sendRpc(t, n) {
|
|
1464
|
+
if (this?._iframe?.parentNode && this._loaded)
|
|
1465
|
+
this.sendRpcInternal(t, n);
|
|
1466
|
+
else {
|
|
1467
|
+
this?._metapage?.error("sending rpc later");
|
|
1468
|
+
const a = this;
|
|
1469
|
+
this?._onLoaded.push(() => {
|
|
1470
|
+
a.sendRpcInternal(t, n);
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
ack(t) {
|
|
1475
|
+
if (this.log("⚒ ⚒ ⚒ calling ack"), this._debug) {
|
|
1476
|
+
this.log("⚒ ⚒ ⚒ sending ack from client to frame");
|
|
1477
|
+
var n = {
|
|
1478
|
+
message: t
|
|
1479
|
+
};
|
|
1480
|
+
this.sendRpc(at.MessageAck, n);
|
|
1481
|
+
} else
|
|
1482
|
+
this.log("⚒ ⚒ ⚒ NOT sending ack from client to frame since not debug mode");
|
|
1483
|
+
}
|
|
1484
|
+
log(t) {
|
|
1485
|
+
this._debug && this.logInternal(t);
|
|
1486
|
+
}
|
|
1487
|
+
logInternal(t) {
|
|
1488
|
+
let n;
|
|
1489
|
+
typeof t == "string" ? n = t : typeof t == "string" ? n = t + "" : n = JSON.stringify(t), Rt(`Metapage[${this._parentId}] Metaframe[${this.id}] ${n}`, this._color, this._consoleBackgroundColor);
|
|
1490
|
+
}
|
|
1491
|
+
sendRpcInternal(t, n) {
|
|
1492
|
+
const a = {
|
|
1493
|
+
id: "_",
|
|
1494
|
+
iframeId: this.id,
|
|
1495
|
+
jsonrpc: "2.0",
|
|
1496
|
+
method: t,
|
|
1497
|
+
params: n,
|
|
1498
|
+
parentId: this._parentId
|
|
1499
|
+
};
|
|
1500
|
+
this._iframe ? this.sendOrBufferPostMessage(a) : this._metapage ? this._metapage.error(`Cannot send to child iframe messageJSON=${JSON.stringify(a).substring(0, 200)}`) : console.error(`Cannot send to child iframe messageJSON=${JSON.stringify(a).substring(0, 200)}`);
|
|
1501
|
+
}
|
|
1502
|
+
sendOrBufferPostMessage(t) {
|
|
1503
|
+
if (this._iframe && this._iframe.contentWindow)
|
|
1504
|
+
this._iframe.contentWindow.postMessage(t, this.url);
|
|
1505
|
+
else if (this._bufferMessages)
|
|
1506
|
+
this._bufferMessages.push(t);
|
|
1507
|
+
else {
|
|
1508
|
+
this._bufferMessages = [t];
|
|
1509
|
+
const n = this;
|
|
1510
|
+
this._bufferTimeout = window.setInterval(function() {
|
|
1511
|
+
n._iframe && n._iframe.contentWindow && (n._bufferMessages.forEach((a) => n._iframe.contentWindow.postMessage(a, n.url)), window.clearInterval(n._bufferTimeout), n._bufferTimeout = void 0, n._bufferMessages = void 0);
|
|
1512
|
+
}, 0);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
var Gt;
|
|
1517
|
+
(function(o) {
|
|
1518
|
+
o.all = "all", o.delta = "delta";
|
|
1519
|
+
})(Gt || (Gt = {}));
|
|
1520
|
+
const Kt = () => ({
|
|
1521
|
+
metaframes: {
|
|
1522
|
+
inputs: {},
|
|
1523
|
+
outputs: {}
|
|
1524
|
+
},
|
|
1525
|
+
plugins: {
|
|
1526
|
+
inputs: {},
|
|
1527
|
+
outputs: {}
|
|
1528
|
+
}
|
|
1529
|
+
}), De = (o) => re(o), Ee = (o, t) => !t || t === "*" || o === t ? !0 : t.endsWith("*") ? o.startsWith(t.slice(0, -1)) : t.startsWith("*") ? o.endsWith(t.slice(1)) : !1, Se = "bcbcbc";
|
|
1530
|
+
class tt extends de {
|
|
1531
|
+
constructor(t) {
|
|
1532
|
+
super(), this._state = Kt(), this._metaframes = {}, this._plugins = {}, this._pluginOrder = [], this.debug = Ct(), this._internalReceivedMessageCounter = 0, this._cachedInputLookupMap = {}, this._inputMap = {}, this._id = t && t.id ? t.id : be(), this._consoleBackgroundColor = t && t.color ? t.color : Se, this.addPipe = this.addPipe.bind(this), this.dispose = this.dispose.bind(this), this.addMetaframe = this.addMetaframe.bind(this), this.addPlugin = this.addPlugin.bind(this), this.getInputsFromOutput = this.getInputsFromOutput.bind(this), this.getMetaframe = this.getMetaframe.bind(this), this.getMetaframeIds = this.getMetaframeIds.bind(this), this.getMetaframeOrPlugin = this.getMetaframeOrPlugin.bind(this), this.getMetaframes = this.getMetaframes.bind(this), this.getPlugin = this.getPlugin.bind(this), this.getPluginIds = this.getPluginIds.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.pluginIds = this.pluginIds.bind(this), this.plugins = this.plugins.bind(this), this.removeAll = this.removeAll.bind(this), this.removeMetaframe = this.removeMetaframe.bind(this), this.removePlugin = this.removePlugin.bind(this), this.setDebugFromUrlParams = this.setDebugFromUrlParams.bind(this), this.setDefinition = this.setDefinition.bind(this), this.setInput = this.setInput.bind(this), this.setInputs = this.setInputs.bind(this), this.setInputStateOnly = this.setInputStateOnly.bind(this), this.setMetaframeClientInputAndSentClientEvent = this.setMetaframeClientInputAndSentClientEvent.bind(this), this.setOutputStateOnly = this.setOutputStateOnly.bind(this), this.setState = this.setState.bind(this), this.isDisposed = this.isDisposed.bind(this), this.updatePluginsWithDefinition = this.updatePluginsWithDefinition.bind(this), this._emitDefinitionEvent = this._emitDefinitionEvent.bind(this), jt().then(() => {
|
|
1533
|
+
this.isDisposed() || (window.addEventListener("message", this.onMessage), this.log("Initialized"));
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
static from(t, n) {
|
|
1537
|
+
if (t == null)
|
|
1538
|
+
throw "Metapage definition cannot be null";
|
|
1539
|
+
if (typeof t == "string")
|
|
1540
|
+
try {
|
|
1541
|
+
t = JSON.parse(t);
|
|
1542
|
+
} catch {
|
|
1543
|
+
throw "Cannot parse into JSON:\n${metaPageDef}";
|
|
1544
|
+
}
|
|
1545
|
+
var a = new tt();
|
|
1546
|
+
return a.setDefinition(t);
|
|
1547
|
+
}
|
|
1548
|
+
isDisposed() {
|
|
1549
|
+
return this._metaframes === void 0;
|
|
1550
|
+
}
|
|
1551
|
+
addListenerReturnDisposer(t, n) {
|
|
1552
|
+
return super.addListener(t, n), () => {
|
|
1553
|
+
super.removeListener(t, n);
|
|
1554
|
+
};
|
|
1555
|
+
}
|
|
1556
|
+
setDebugFromUrlParams() {
|
|
1557
|
+
return this.debug = ye(["MP_DEBUG", "DEBUG", "debug", "mp_debug"]), this;
|
|
1558
|
+
}
|
|
1559
|
+
getState() {
|
|
1560
|
+
return this._state;
|
|
1561
|
+
}
|
|
1562
|
+
setState(t) {
|
|
1563
|
+
this._state = t, this.getMetaframeIds().forEach((n) => {
|
|
1564
|
+
this.getMetaframe(n).setInputs(this._state.metaframes.inputs[n]), this.getMetaframe(n).setOutputs(this._state.metaframes.outputs[n]);
|
|
1565
|
+
}), this.getPluginIds().forEach((n) => {
|
|
1566
|
+
this.getPlugin(n).setInputs(this._state.plugins.inputs[n]), this.getPlugin(n).setOutputs(this._state.plugins.outputs[n]);
|
|
1567
|
+
}), this.emit(N.State, this._state);
|
|
1568
|
+
}
|
|
1569
|
+
getStateMetaframes() {
|
|
1570
|
+
return this._state.metaframes;
|
|
1571
|
+
}
|
|
1572
|
+
getDefinition() {
|
|
1573
|
+
return this._definition;
|
|
1574
|
+
}
|
|
1575
|
+
setDefinition(t, n) {
|
|
1576
|
+
if (!t.version)
|
|
1577
|
+
throw "Metapage definition must have a version";
|
|
1578
|
+
const a = ie(t);
|
|
1579
|
+
a.metaframes && Object.keys(a.metaframes).forEach((m) => {
|
|
1580
|
+
if (a.plugins && a.plugins.includes(m))
|
|
1581
|
+
throw this.emitErrorMessage(`Plugin with url=${m} matches metaframe. Metaframe ids and plugin urls are not allowed to collide`), `Plugin with url=${m} matches metaframe. Metaframe ids and plugin urls are not allowed to collide`;
|
|
1582
|
+
var b = a.metaframes[m];
|
|
1583
|
+
if (typeof b != "object")
|
|
1584
|
+
throw this.emitErrorMessage(`Metaframe "${m}" is not an object`), `Metaframe "${m}" is not an object`;
|
|
1585
|
+
if (!b.url)
|
|
1586
|
+
throw this.emitErrorMessage(`Metaframe "${m}" missing field: url`), `Metaframe "${m}" missing field: url`;
|
|
1587
|
+
});
|
|
1588
|
+
const d = this._definition;
|
|
1589
|
+
return this._definition = a, Object.keys(this._metaframes).forEach((m) => {
|
|
1590
|
+
(!a.metaframes || !a.metaframes[m]) && this.removeMetaframe(m);
|
|
1591
|
+
}), Object.keys(this._plugins).forEach((m) => {
|
|
1592
|
+
a.plugins && !a.plugins.includes(m) && this.removePlugin(m);
|
|
1593
|
+
}), this._pluginOrder = a.plugins ? a.plugins : [], n && (this._state = n), a.metaframes && Object.keys(a.metaframes).forEach((m) => {
|
|
1594
|
+
if (!this._metaframes.hasOwnProperty(m)) {
|
|
1595
|
+
const b = a.metaframes[m];
|
|
1596
|
+
this.addMetaframe(m, b);
|
|
1597
|
+
}
|
|
1598
|
+
}), a.plugins && a.plugins.forEach((m) => {
|
|
1599
|
+
this._plugins.hasOwnProperty(m) || this.addPlugin(m);
|
|
1600
|
+
}), d !== ne && window.setTimeout(() => {
|
|
1601
|
+
!this.isDisposed() && a === this._definition && (this._emitDefinitionEvent(), n && this.emit(N.State, this._state));
|
|
1602
|
+
}, 0), this;
|
|
1603
|
+
}
|
|
1604
|
+
_emitDefinitionEvent() {
|
|
1605
|
+
const t = {
|
|
1606
|
+
definition: this._definition,
|
|
1607
|
+
metaframes: this._metaframes,
|
|
1608
|
+
plugins: this._plugins
|
|
1609
|
+
};
|
|
1610
|
+
this.emit(N.Definition, t);
|
|
1611
|
+
}
|
|
1612
|
+
addPipe(t, n) {
|
|
1613
|
+
this._inputMap[t] || (this._inputMap[t] = []), this._inputMap[t].push(n);
|
|
1614
|
+
}
|
|
1615
|
+
removeMetaframe(t) {
|
|
1616
|
+
this._metaframes[t] && (this._metaframes[t].dispose(), delete this._metaframes[t], delete this._state.metaframes.inputs[t], delete this._state.metaframes.outputs[t], delete this._inputMap[t], Object.keys(this._inputMap).forEach((n) => {
|
|
1617
|
+
const a = this._inputMap[n];
|
|
1618
|
+
let d = 0;
|
|
1619
|
+
for (; d <= a.length; )
|
|
1620
|
+
a[d] && a[d].metaframe === t ? a.splice(d, 1) : d++;
|
|
1621
|
+
}), this._cachedInputLookupMap = {});
|
|
1622
|
+
}
|
|
1623
|
+
removePlugin(t) {
|
|
1624
|
+
this._plugins[t] && (this._plugins[t].dispose(), delete this._plugins[t], delete this._state.plugins.inputs[t], delete this._state.plugins.outputs[t]);
|
|
1625
|
+
}
|
|
1626
|
+
removeAll() {
|
|
1627
|
+
Object.keys(this._metaframes).forEach((t) => this._metaframes[t].dispose()), Object.keys(this._plugins).forEach((t) => this._plugins[t].dispose()), this._metaframes = {}, this._plugins = {}, this._state = Kt(), this._inputMap = {}, this._cachedInputLookupMap = {};
|
|
1628
|
+
}
|
|
1629
|
+
metaframes() {
|
|
1630
|
+
return this.getMetaframes();
|
|
1631
|
+
}
|
|
1632
|
+
metaframeIds() {
|
|
1633
|
+
return this.getMetaframeIds();
|
|
1634
|
+
}
|
|
1635
|
+
getMetaframeIds() {
|
|
1636
|
+
return Object.keys(this._metaframes);
|
|
1637
|
+
}
|
|
1638
|
+
getMetaframes() {
|
|
1639
|
+
return Object.assign({}, this._metaframes);
|
|
1640
|
+
}
|
|
1641
|
+
plugins() {
|
|
1642
|
+
return Object.assign({}, this._plugins);
|
|
1643
|
+
}
|
|
1644
|
+
pluginIds() {
|
|
1645
|
+
return this.getPluginIds();
|
|
1646
|
+
}
|
|
1647
|
+
getPluginIds() {
|
|
1648
|
+
return this._pluginOrder.slice(0);
|
|
1649
|
+
}
|
|
1650
|
+
getMetaframe(t) {
|
|
1651
|
+
return this._metaframes[t];
|
|
1652
|
+
}
|
|
1653
|
+
getPlugin(t) {
|
|
1654
|
+
return this._plugins[t];
|
|
1655
|
+
}
|
|
1656
|
+
addMetaframe(t, n) {
|
|
1657
|
+
if (!t)
|
|
1658
|
+
throw "addMetaframe missing metaframeId";
|
|
1659
|
+
if (!n)
|
|
1660
|
+
throw "addMetaframe missing definition";
|
|
1661
|
+
if (this._metaframes[t])
|
|
1662
|
+
throw this.emitErrorMessage(`Existing metaframe for id=${t}`), `Existing metaframe for id=${t}`;
|
|
1663
|
+
if (!n.url)
|
|
1664
|
+
throw this.emitErrorMessage(`Metaframe definition missing url id=${t}`), `Metaframe definition missing url id=${t}`;
|
|
1665
|
+
var a = new Ht(this, n.url, t, this._id, this._consoleBackgroundColor, this.debug).setMetapage(this);
|
|
1666
|
+
return this._metaframes[t] = a, a.addListener(N.Error, (d) => {
|
|
1667
|
+
this.emit(N.Error, {
|
|
1668
|
+
metaframeId: a.id,
|
|
1669
|
+
metaframeUrl: a.url,
|
|
1670
|
+
error: d
|
|
1671
|
+
});
|
|
1672
|
+
}), n.inputs && n.inputs.forEach((d) => this.addPipe(t, d)), a.setInputs(this._state.metaframes.inputs[t]), a;
|
|
1673
|
+
}
|
|
1674
|
+
addPlugin(t) {
|
|
1675
|
+
if (!t)
|
|
1676
|
+
throw "Plugin missing url";
|
|
1677
|
+
const n = new Ht(this, t, t, this._id, this._consoleBackgroundColor, this.debug).setInputs(this._state.plugins.inputs[t]).setMetapage(this).setPlugin();
|
|
1678
|
+
return Oe(this, n), this._plugins[t] = n, n;
|
|
1679
|
+
}
|
|
1680
|
+
dispose() {
|
|
1681
|
+
this.log("disposing"), super.removeAllListeners(), window.removeEventListener("message", this.onMessage), this._metaframes && Object.keys(this._metaframes).forEach((t) => this._metaframes[t].dispose()), this._plugins && Object.keys(this._plugins).forEach((t) => this._plugins[t].dispose()), this._id = void 0, this._metaframes = void 0, this._plugins = void 0, this._state = void 0, this._cachedInputLookupMap = void 0, this._inputMap = void 0;
|
|
1682
|
+
}
|
|
1683
|
+
log(t, n, a) {
|
|
1684
|
+
this.debug && this.logInternal(t, n, a);
|
|
1685
|
+
}
|
|
1686
|
+
error(t) {
|
|
1687
|
+
this.logInternal(t, "f00", this._consoleBackgroundColor), this.emitErrorMessage(`${t}`);
|
|
1688
|
+
}
|
|
1689
|
+
emitErrorMessage(t) {
|
|
1690
|
+
this.emit(N.Error, t);
|
|
1691
|
+
}
|
|
1692
|
+
getInputsFromOutput(t, n) {
|
|
1693
|
+
if (this._cachedInputLookupMap[t] || (this._cachedInputLookupMap[t] = {}), !this._cachedInputLookupMap[t][n]) {
|
|
1694
|
+
var a = [];
|
|
1695
|
+
this._cachedInputLookupMap[t][n] = a, Object.keys(this._inputMap).forEach((d) => {
|
|
1696
|
+
d !== t && this._inputMap[d].forEach((m) => {
|
|
1697
|
+
if (m.metaframe == t && Ee(n, m.source)) {
|
|
1698
|
+
var b = m.target;
|
|
1699
|
+
(!m.target || m.target.startsWith("*") || m.target === "") && (b = n), a.push({ metaframe: d, pipe: b });
|
|
1700
|
+
}
|
|
1701
|
+
});
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
return this._cachedInputLookupMap[t][n];
|
|
1705
|
+
}
|
|
1706
|
+
isValidJSONRpcMessage(t) {
|
|
1707
|
+
if (t.jsonrpc !== "2.0")
|
|
1708
|
+
return !1;
|
|
1709
|
+
switch (t.method) {
|
|
1710
|
+
case X.SetupIframeClientRequest:
|
|
1711
|
+
return !0;
|
|
1712
|
+
default:
|
|
1713
|
+
var a = t.iframeId;
|
|
1714
|
+
return !(a && !(t.parentId === this._id && (this._metaframes[a] || this._plugins[a])));
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
setInput(t, n, a) {
|
|
1718
|
+
this.setInputStateOnly(t, n, a), this.setMetaframeClientInputAndSentClientEvent(t, n, a), this.emit(N.State, this._state), this.emit(N.Inputs, this._state);
|
|
1719
|
+
}
|
|
1720
|
+
setMetaframeClientInputAndSentClientEvent(t, n, a) {
|
|
1721
|
+
if (typeof t == "object") {
|
|
1722
|
+
if (n || a)
|
|
1723
|
+
throw "bad arguments, see API docs";
|
|
1724
|
+
const d = t;
|
|
1725
|
+
Object.keys(d).forEach((m) => {
|
|
1726
|
+
var b = m, I = d[b];
|
|
1727
|
+
if (typeof I != "object")
|
|
1728
|
+
throw "bad arguments, see API docs";
|
|
1729
|
+
var M = this._metaframes[b];
|
|
1730
|
+
M ? M.setInputs(I) : this.error("No iframe id=$metaframeId");
|
|
1731
|
+
});
|
|
1732
|
+
} else if (typeof t == "string") {
|
|
1733
|
+
const d = this._metaframes[t];
|
|
1734
|
+
if (d == null && this.error(`No iframe id=${t}`), typeof n == "string")
|
|
1735
|
+
d.setInput(n, a);
|
|
1736
|
+
else if (typeof n == "object")
|
|
1737
|
+
d.setInputs(n);
|
|
1738
|
+
else
|
|
1739
|
+
throw "bad arguments, see API docs";
|
|
1740
|
+
} else
|
|
1741
|
+
throw "bad arguments, see API docs";
|
|
1742
|
+
}
|
|
1743
|
+
setInputs(t, n, a) {
|
|
1744
|
+
this.setInput(t, n, a);
|
|
1745
|
+
}
|
|
1746
|
+
setOutputStateOnly(t, n, a) {
|
|
1747
|
+
this._setStateOnly(!1, t, n, a);
|
|
1748
|
+
}
|
|
1749
|
+
setInputStateOnly(t, n, a) {
|
|
1750
|
+
this._setStateOnly(!0, t, n, a);
|
|
1751
|
+
}
|
|
1752
|
+
_setStateOnly(t, n, a, d) {
|
|
1753
|
+
if (typeof n == "object") {
|
|
1754
|
+
if (a || d)
|
|
1755
|
+
throw "If first argument is an object, subsequent args should be undefined";
|
|
1756
|
+
const m = n;
|
|
1757
|
+
Object.keys(m).forEach((b) => {
|
|
1758
|
+
var I = m[b];
|
|
1759
|
+
if (typeof I != "object")
|
|
1760
|
+
throw "Object values must be objects";
|
|
1761
|
+
const M = this._metaframes.hasOwnProperty(b);
|
|
1762
|
+
if (!M && !this._plugins.hasOwnProperty(b))
|
|
1763
|
+
throw "No metaframe or plugin: ${metaframeId}";
|
|
1764
|
+
const S = M ? t ? this._state.metaframes.inputs : this._state.metaframes.outputs : t ? this._state.plugins.inputs : this._state.plugins.outputs;
|
|
1765
|
+
S[b] = S[b] ? S[b] : {}, Object.keys(I).forEach((A) => {
|
|
1766
|
+
I[A] === void 0 ? delete S[b][A] : S[b][A] = I[A];
|
|
1767
|
+
});
|
|
1768
|
+
});
|
|
1769
|
+
} else if (typeof n == "string") {
|
|
1770
|
+
const m = n, b = this._metaframes.hasOwnProperty(m);
|
|
1771
|
+
if (!b && !this._plugins.hasOwnProperty(m))
|
|
1772
|
+
throw `No metaframe or plugin: ${m}`;
|
|
1773
|
+
const I = b ? t ? this._state.metaframes.inputs : this._state.metaframes.outputs : t ? this._state.plugins.inputs : this._state.plugins.outputs;
|
|
1774
|
+
if (typeof a == "string") {
|
|
1775
|
+
I[m] = I[m] ? I[m] : {};
|
|
1776
|
+
const M = a;
|
|
1777
|
+
d === void 0 ? delete I[m][M] : I[m][M] = d;
|
|
1778
|
+
} else if (typeof a == "object") {
|
|
1779
|
+
I[m] = I[m] ? I[m] : {};
|
|
1780
|
+
const M = a;
|
|
1781
|
+
Object.keys(M).forEach((S) => {
|
|
1782
|
+
M[S] === void 0 ? delete I[m][S] : I[m][S] = M[S];
|
|
1783
|
+
});
|
|
1784
|
+
} else
|
|
1785
|
+
throw "Second argument must be a string or an object";
|
|
1786
|
+
} else
|
|
1787
|
+
throw "First argument must be a string or an object";
|
|
1788
|
+
}
|
|
1789
|
+
getMetaframeOrPlugin(t) {
|
|
1790
|
+
var n = this._metaframes[t];
|
|
1791
|
+
return n || (n = this._plugins[t]), n;
|
|
1792
|
+
}
|
|
1793
|
+
onMessage(t) {
|
|
1794
|
+
if (typeof t.data == "object") {
|
|
1795
|
+
const b = t.data;
|
|
1796
|
+
if (!this.isValidJSONRpcMessage(b))
|
|
1797
|
+
return;
|
|
1798
|
+
var n = b.method;
|
|
1799
|
+
const I = b.iframeId;
|
|
1800
|
+
if (!I)
|
|
1801
|
+
return;
|
|
1802
|
+
const M = this.getMetaframeOrPlugin(I), S = this._plugins[I];
|
|
1803
|
+
switch (b._messageCount = ++this._internalReceivedMessageCounter, this.debug && this.log(`processing ${JSON.stringify(b, null, " ").substr(0, 500)}`), n) {
|
|
1804
|
+
case X.SetupIframeClientRequest:
|
|
1805
|
+
M && M.register();
|
|
1806
|
+
break;
|
|
1807
|
+
case X.SetupIframeServerResponseAck:
|
|
1808
|
+
if (M) {
|
|
1809
|
+
const P = b.params;
|
|
1810
|
+
M.registered(P.version);
|
|
1811
|
+
}
|
|
1812
|
+
break;
|
|
1813
|
+
case X.OutputsUpdate:
|
|
1814
|
+
const A = b.params;
|
|
1815
|
+
if (this._metaframes[I]) {
|
|
1816
|
+
var a = this._metaframes[I];
|
|
1817
|
+
this.setOutputStateOnly(I, A), a.setOutputs(A), this.emit(N.State, this._state);
|
|
1818
|
+
var d = !1;
|
|
1819
|
+
const P = Object.keys(A), T = {};
|
|
1820
|
+
P.forEach((V, y) => {
|
|
1821
|
+
const C = this.getInputsFromOutput(I, V);
|
|
1822
|
+
C.length > 0 && C.forEach((h) => {
|
|
1823
|
+
T[h.metaframe] || (T[h.metaframe] = {}), T[h.metaframe][h.pipe] = A[V], this.setInputStateOnly(h.metaframe, h.pipe, A[V]), d = !0;
|
|
1824
|
+
});
|
|
1825
|
+
}), Object.keys(T).forEach((V) => {
|
|
1826
|
+
this._metaframes[V].setInputs(T[V]);
|
|
1827
|
+
}), d && this.emit(N.State, this._state), this.debug && a.ack({ jsonrpc: b, state: this._state });
|
|
1828
|
+
} else if (this._plugins[I]) {
|
|
1829
|
+
const P = !A[ft] && !A[rt];
|
|
1830
|
+
P && this.setOutputStateOnly(I, A), this._plugins[I].setOutputs(A), P && this.emit(N.State, this._state), this.debug && this._plugins[I].ack({
|
|
1831
|
+
jsonrpc: b,
|
|
1832
|
+
state: this._state
|
|
1833
|
+
});
|
|
1834
|
+
} else
|
|
1835
|
+
this.error("missing metaframe/plugin=$metaframeId");
|
|
1836
|
+
break;
|
|
1837
|
+
case X.InputsUpdate:
|
|
1838
|
+
var m = b.params;
|
|
1839
|
+
if (this.debug && this.log(`inputs ${JSON.stringify(m)} from ${I}`), this._metaframes[I])
|
|
1840
|
+
this.setInputStateOnly(I, m), this._metaframes[I].setInputs(m), this.emit(N.State, this._state), this.debug && this._metaframes[I].ack({
|
|
1841
|
+
jsonrpc: b,
|
|
1842
|
+
state: this._state
|
|
1843
|
+
});
|
|
1844
|
+
else if (this._plugins[I]) {
|
|
1845
|
+
const P = !m[ft] && !m[rt];
|
|
1846
|
+
P && this.setInputStateOnly(I, m), this._plugins[I].setInputs(m), P && this.emit(N.State, this._state), this.debug && this._plugins[I].ack({
|
|
1847
|
+
jsonrpc: b,
|
|
1848
|
+
state: this._state
|
|
1849
|
+
});
|
|
1850
|
+
} else
|
|
1851
|
+
console.error(`InputsUpdate failed no metaframe or plugin id: "${I}"`), this.error(`InputsUpdate failed no metaframe or plugin id: "${I}"`);
|
|
1852
|
+
break;
|
|
1853
|
+
case X.PluginRequest:
|
|
1854
|
+
S && M && M.hasPermissionsState() && (M.setInput(ft, this._state), this.debug && M.ack({ jsonrpc: b, state: this._state }));
|
|
1855
|
+
break;
|
|
1856
|
+
case X.HashParamsUpdate:
|
|
1857
|
+
if (!S && M) {
|
|
1858
|
+
const P = b.params, T = new URL(M.url);
|
|
1859
|
+
T.hash = P.hash, M.url = T.href, this._definition.metaframes[P.metaframe].url = T.href, this._emitDefinitionEvent();
|
|
1860
|
+
}
|
|
1861
|
+
break;
|
|
1862
|
+
default:
|
|
1863
|
+
this.debug && this.log(`Unknown RPC method: "${n}"`);
|
|
1864
|
+
}
|
|
1865
|
+
this.emit(N.Message, b);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
updatePluginsWithDefinition() {
|
|
1869
|
+
this.getDefinition(), Object.values(this._plugins).forEach((t) => {
|
|
1870
|
+
t.hasPermissionsDefinition() && Me(t);
|
|
1871
|
+
});
|
|
1872
|
+
}
|
|
1873
|
+
logInternal(t, n, a) {
|
|
1874
|
+
a = a || this._consoleBackgroundColor;
|
|
1875
|
+
let d;
|
|
1876
|
+
typeof t == "string" ? d = t : typeof t == "number" ? d = t + "" : d = JSON.stringify(t), d = this._id ? `Metapage[${this._id}] ${d}` : d, Rt(d, n, a);
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
tt.version = Qt;
|
|
1880
|
+
tt.DEFINITION = N.Definition;
|
|
1881
|
+
tt.DEFINITION_UPDATE_REQUEST = N.DefinitionUpdateRequest;
|
|
1882
|
+
tt.ERROR = N.Error;
|
|
1883
|
+
tt.INPUTS = N.Inputs;
|
|
1884
|
+
tt.MESSAGE = N.Message;
|
|
1885
|
+
tt.OUTPUTS = N.Outputs;
|
|
1886
|
+
tt.STATE = N.State;
|
|
1887
|
+
tt.deserializeInputs = gt;
|
|
1888
|
+
tt.serializeInputs = Mt;
|
|
1889
|
+
const Oe = async (o, t) => {
|
|
1890
|
+
try {
|
|
1891
|
+
const d = await t.getDefinition();
|
|
1892
|
+
if (!d)
|
|
1893
|
+
throw `${t.url}`;
|
|
1894
|
+
if (t.isDisposed())
|
|
1895
|
+
return;
|
|
1896
|
+
if (t.hasPermissionsDefinition()) {
|
|
1897
|
+
var n = o.addListenerReturnDisposer(N.Definition, (m) => {
|
|
1898
|
+
t.setInput(rt, m.definition);
|
|
1899
|
+
});
|
|
1900
|
+
t._disposables.push(n);
|
|
1901
|
+
var a = o.getDefinition();
|
|
1902
|
+
if (a && (t.setInput(rt, a), d.outputs)) {
|
|
1903
|
+
var n = t.onOutput(rt, (b) => {
|
|
1904
|
+
$t.sha1(b) !== $t.sha1(a) && o.emit(N.DefinitionUpdateRequest, b);
|
|
1905
|
+
});
|
|
1906
|
+
t._disposables.push(n);
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
if (t.hasPermissionsState() && d.outputs) {
|
|
1910
|
+
var n = t.onOutput(ft, (b) => {
|
|
1911
|
+
o.setState(b);
|
|
1912
|
+
});
|
|
1913
|
+
t._disposables.push(n);
|
|
1914
|
+
}
|
|
1915
|
+
} catch (d) {
|
|
1916
|
+
console.error(d), o.emit(N.Error, `Failed to get plugin definition from "${t.getDefinitionUrl()}", error=${d}`);
|
|
1917
|
+
}
|
|
1918
|
+
}, Me = (o) => {
|
|
1919
|
+
const t = o._metapage.getDefinition();
|
|
1920
|
+
o.setInput(rt, t);
|
|
1921
|
+
};
|
|
1922
|
+
var ut;
|
|
1923
|
+
(function(o) {
|
|
1924
|
+
o.WaitingForPageLoad = "WaitingForPageLoad", o.SentSetupIframeClientRequest = "SentSetupIframeClientRequest", o.Ready = "Ready";
|
|
1925
|
+
})(ut || (ut = {}));
|
|
1926
|
+
var G;
|
|
1927
|
+
(function(o) {
|
|
1928
|
+
o.Connected = "connected", o.Error = "error", o.Input = "input", o.Inputs = "inputs", o.Message = "message";
|
|
1929
|
+
})(G || (G = {}));
|
|
1930
|
+
class nt extends Dt.EventEmitter {
|
|
1931
|
+
constructor(t) {
|
|
1932
|
+
if (super(), this._inputPipeValues = {}, this._outputPipeValues = {}, this._state = ut.WaitingForPageLoad, this._messageSendCount = 0, this.debug = Ct(), this.isInputOutputBlobSerialization = !0, this.id = window.name, this.debug = Ct(), this._isIframe = ce(), this.addListener = this.addListener.bind(this), this.dispose = this.dispose.bind(this), this.error = this.error.bind(this), this.getInput = this.getInput.bind(this), this.getInputs = this.getInputs.bind(this), this.log = this.log.bind(this), this.logInternal = this.logInternal.bind(this), this.onInput = this.onInput.bind(this), this.onInputs = this.onInputs.bind(this), this.onMessage = this.onMessage.bind(this), this.sendRpc = this.sendRpc.bind(this), this.setInput = this.setInput.bind(this), this.setInputs = this.setInputs.bind(this), this.setInternalInputsAndNotify = this.setInternalInputsAndNotify.bind(this), this.setOutput = this.setOutput.bind(this), this.setOutputs = this.setOutputs.bind(this), this.warn = this.warn.bind(this), this._resolveSetupIframeServerResponse = this._resolveSetupIframeServerResponse.bind(this), this.addListenerReturnDisposer = this.addListenerReturnDisposer.bind(this), this.connected = this.connected.bind(this), this.disableNotifyOnHashUrlChange = this.disableNotifyOnHashUrlChange.bind(this), this._onHashUrlChange = this._onHashUrlChange.bind(this), !this._isIframe) {
|
|
1933
|
+
this.log("Not an iframe, metaframe code disabled");
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
const n = this;
|
|
1937
|
+
jt().then(() => {
|
|
1938
|
+
this.log("pageLoaded"), window.addEventListener("message", this.onMessage), n.sendRpc(X.SetupIframeClientRequest, {
|
|
1939
|
+
version: nt.version
|
|
1940
|
+
}), n._state = ut.SentSetupIframeClientRequest;
|
|
1941
|
+
}), t && t.disableHashChangeEvent || window.addEventListener("hashchange", this._onHashUrlChange);
|
|
1942
|
+
}
|
|
1943
|
+
_resolveSetupIframeServerResponse(t) {
|
|
1944
|
+
if (this._state === ut.WaitingForPageLoad)
|
|
1945
|
+
throw "Got message but page has not finished loading, we should never get in this state";
|
|
1946
|
+
(async () => this._parentId ? this.log("Got JsonRpcMethods.SetupIframeServerResponse but already resolved") : (this._parentVersion = t.version, this.color = oe(this.id), this._parentId = t.parentId, this.log(`metapage[${this._parentId}](v${this._parentVersion ? this._parentVersion : "unknown"}) registered`), t.state && t.state.inputs && (this.isInputOutputBlobSerialization ? this._inputPipeValues = await gt(t.state.inputs) : this._inputPipeValues = t.state.inputs), this._state = ut.Ready, this.sendRpc(X.SetupIframeServerResponseAck, {
|
|
1947
|
+
version: nt.version
|
|
1948
|
+
}), this._inputPipeValues && Object.keys(this._inputPipeValues).length > 0 && (this.emit(G.Inputs, this._inputPipeValues), Object.keys(this._inputPipeValues).forEach((n) => this.emit(G.Input, n, this._inputPipeValues[n]))), this.emit(G.Inputs, this._inputPipeValues), t.plugin && (this.plugin = new Ae(this)), this.emit(G.Connected)))();
|
|
1949
|
+
}
|
|
1950
|
+
async connected() {
|
|
1951
|
+
if (this._state !== ut.Ready)
|
|
1952
|
+
return new Promise((t, n) => {
|
|
1953
|
+
let a;
|
|
1954
|
+
a = this.addListenerReturnDisposer(G.Connected, () => {
|
|
1955
|
+
t(), a();
|
|
1956
|
+
});
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
addListenerReturnDisposer(t, n) {
|
|
1960
|
+
return super.addListener(t, n), () => {
|
|
1961
|
+
super.removeListener(t, n);
|
|
1962
|
+
};
|
|
1963
|
+
}
|
|
1964
|
+
log(t, n, a) {
|
|
1965
|
+
this.debug && this.logInternal(t, n || this.color);
|
|
1966
|
+
}
|
|
1967
|
+
warn(t) {
|
|
1968
|
+
this.debug && this.logInternal(t, "000", this.color);
|
|
1969
|
+
}
|
|
1970
|
+
error(t) {
|
|
1971
|
+
this.logInternal(t, this.color, "f00");
|
|
1972
|
+
}
|
|
1973
|
+
logInternal(t, n, a) {
|
|
1974
|
+
let d;
|
|
1975
|
+
typeof t == "string" ? d = t : typeof t == "number" ? d = t + "" : d = JSON.stringify(t), n = n && n + "", d = (this.id ? `Metaframe[${this.id}] ` : "") + `${d}`, Rt(d, n, a);
|
|
1976
|
+
}
|
|
1977
|
+
dispose() {
|
|
1978
|
+
super.removeAllListeners(), window.removeEventListener("message", this.onMessage), this.disableNotifyOnHashUrlChange(), this._inputPipeValues = void 0, this._outputPipeValues = void 0;
|
|
1979
|
+
}
|
|
1980
|
+
addListener(t, n) {
|
|
1981
|
+
return super.addListener(t, n), t === G.Inputs && window.setTimeout(() => {
|
|
1982
|
+
this._inputPipeValues && n(this._inputPipeValues);
|
|
1983
|
+
}, 0), this;
|
|
1984
|
+
}
|
|
1985
|
+
onInput(t, n) {
|
|
1986
|
+
return this.addListenerReturnDisposer(G.Input, (a, d) => {
|
|
1987
|
+
t === a && n(d);
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
onInputs(t) {
|
|
1991
|
+
return this.addListenerReturnDisposer(G.Inputs, t);
|
|
1992
|
+
}
|
|
1993
|
+
setInput(t, n) {
|
|
1994
|
+
var a = {};
|
|
1995
|
+
a[t] = n, this.setInputs(a);
|
|
1996
|
+
}
|
|
1997
|
+
async setInputs(t) {
|
|
1998
|
+
this.isInputOutputBlobSerialization && (t = await gt(t)), this.sendRpc(X.InputsUpdate, t);
|
|
1999
|
+
}
|
|
2000
|
+
async setInternalInputsAndNotify(t) {
|
|
2001
|
+
this.isInputOutputBlobSerialization && (t = await gt(t)), St(this._inputPipeValues, t) && (Object.keys(t).forEach((n) => this.emit(G.Input, n, t[n])), this.emit(G.Inputs, t));
|
|
2002
|
+
}
|
|
2003
|
+
getInput(t) {
|
|
2004
|
+
return console.assert(!!t), this._inputPipeValues[t];
|
|
2005
|
+
}
|
|
2006
|
+
getInputs() {
|
|
2007
|
+
return this._inputPipeValues;
|
|
2008
|
+
}
|
|
2009
|
+
setOutput(t, n) {
|
|
2010
|
+
console.assert(!!t);
|
|
2011
|
+
var a = {};
|
|
2012
|
+
a[t] = n, this.setOutputs(a);
|
|
2013
|
+
}
|
|
2014
|
+
async setOutputs(t) {
|
|
2015
|
+
this.isInputOutputBlobSerialization && (t = await Mt(t)), St(this._outputPipeValues, t) && this.sendRpc(X.OutputsUpdate, t);
|
|
2016
|
+
}
|
|
2017
|
+
disableNotifyOnHashUrlChange() {
|
|
2018
|
+
window.removeEventListener("hashchange", this._onHashUrlChange);
|
|
2019
|
+
}
|
|
2020
|
+
_onHashUrlChange(t) {
|
|
2021
|
+
const n = {
|
|
2022
|
+
hash: window.location.hash,
|
|
2023
|
+
metaframe: this.id
|
|
2024
|
+
};
|
|
2025
|
+
this.sendRpc(X.HashParamsUpdate, n);
|
|
2026
|
+
}
|
|
2027
|
+
sendRpc(t, n) {
|
|
2028
|
+
if (this._isIframe) {
|
|
2029
|
+
const a = {
|
|
2030
|
+
jsonrpc: "2.0",
|
|
2031
|
+
id: ++this._messageSendCount,
|
|
2032
|
+
method: t,
|
|
2033
|
+
params: n,
|
|
2034
|
+
iframeId: this.id,
|
|
2035
|
+
parentId: this._parentId
|
|
2036
|
+
};
|
|
2037
|
+
window.parent && window.parent.postMessage(a, "*");
|
|
2038
|
+
} else
|
|
2039
|
+
this.log("Cannot send JSON-RPC window message: there is no window.parent which means we are not an iframe");
|
|
2040
|
+
}
|
|
2041
|
+
onMessage(t) {
|
|
2042
|
+
if (typeof t.data == "object") {
|
|
2043
|
+
let a = t.data;
|
|
2044
|
+
if (a.jsonrpc === "2.0") {
|
|
2045
|
+
var n = a.method;
|
|
2046
|
+
if (!(n == at.SetupIframeServerResponse || a.parentId == this._parentId && a.iframeId == this.id)) {
|
|
2047
|
+
this.log(`window.message: received message but jsonrpc.parentId=${a.parentId} _parentId=${this._parentId} jsonrpc.iframeId=${a.iframeId} id=${this.id}`);
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
switch (n) {
|
|
2051
|
+
case at.SetupIframeServerResponse:
|
|
2052
|
+
this._resolveSetupIframeServerResponse(a.params);
|
|
2053
|
+
break;
|
|
2054
|
+
case at.InputsUpdate:
|
|
2055
|
+
if (this._state !== ut.Ready)
|
|
2056
|
+
throw "Got InputsUpdate but metaframe is not MetaframeLoadingState.Ready";
|
|
2057
|
+
this.setInternalInputsAndNotify(a.params.inputs);
|
|
2058
|
+
break;
|
|
2059
|
+
case at.MessageAck:
|
|
2060
|
+
this.debug && this.log(`ACK: ${JSON.stringify(a)}`);
|
|
2061
|
+
break;
|
|
2062
|
+
default:
|
|
2063
|
+
this.debug && this.log(`window.message: unknown JSON-RPC method: ${JSON.stringify(a)}`);
|
|
2064
|
+
break;
|
|
2065
|
+
}
|
|
2066
|
+
this.emit(G.Message, a);
|
|
2067
|
+
}
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2070
|
+
}
|
|
2071
|
+
nt.version = ae;
|
|
2072
|
+
nt.ERROR = G.Error;
|
|
2073
|
+
nt.CONNECTED = G.Connected;
|
|
2074
|
+
nt.INPUT = G.Input;
|
|
2075
|
+
nt.INPUTS = G.Inputs;
|
|
2076
|
+
nt.MESSAGE = G.Message;
|
|
2077
|
+
nt.deserializeInputs = gt;
|
|
2078
|
+
nt.serializeInputs = Mt;
|
|
2079
|
+
class Ae {
|
|
2080
|
+
constructor(t) {
|
|
2081
|
+
this._metaframe = t, this.requestState = this.requestState.bind(this), this.onState = this.onState.bind(this), this.getState = this.getState.bind(this), this.setState = this.setState.bind(this), this.onDefinition = this.onDefinition.bind(this), this.getDefinition = this.getDefinition.bind(this), this.setDefinition = this.setDefinition.bind(this);
|
|
2082
|
+
}
|
|
2083
|
+
requestState() {
|
|
2084
|
+
var t = {
|
|
2085
|
+
method: kt.State
|
|
2086
|
+
};
|
|
2087
|
+
this._metaframe.sendRpc(X.PluginRequest, t);
|
|
2088
|
+
}
|
|
2089
|
+
onState(t) {
|
|
2090
|
+
const n = this._metaframe.onInput(ft, t);
|
|
2091
|
+
return this.getState() && t(this.getState()), n;
|
|
2092
|
+
}
|
|
2093
|
+
getState() {
|
|
2094
|
+
return this._metaframe.getInput(ft);
|
|
2095
|
+
}
|
|
2096
|
+
setState(t) {
|
|
2097
|
+
this._metaframe.setOutput(ft, t);
|
|
2098
|
+
}
|
|
2099
|
+
onDefinition(t) {
|
|
2100
|
+
var n = this._metaframe.onInput(rt, t);
|
|
2101
|
+
return this.getDefinition() && t(this.getDefinition()), n;
|
|
2102
|
+
}
|
|
2103
|
+
setDefinition(t) {
|
|
2104
|
+
this._metaframe.setOutput(rt, t);
|
|
2105
|
+
}
|
|
2106
|
+
getDefinition() {
|
|
2107
|
+
return this._metaframe.getInput(rt);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
export {
|
|
2111
|
+
kt as ApiPayloadPluginRequestMethod,
|
|
2112
|
+
ne as INITIAL_NULL_METAPAGE_DEFINITION,
|
|
2113
|
+
X as JsonRpcMethodsFromChild,
|
|
2114
|
+
at as JsonRpcMethodsFromParent,
|
|
2115
|
+
nt as Metaframe,
|
|
2116
|
+
G as MetaframeEvents,
|
|
2117
|
+
ut as MetaframeLoadingState,
|
|
2118
|
+
Ae as MetaframePlugin,
|
|
2119
|
+
Le as MetaframeVersionCurrent,
|
|
2120
|
+
Ft as MetaframeVersionsAll,
|
|
2121
|
+
tt as Metapage,
|
|
2122
|
+
Gt as MetapageEventStateType,
|
|
2123
|
+
N as MetapageEvents,
|
|
2124
|
+
mt as MetapageHashParams,
|
|
2125
|
+
Ht as MetapageIFrameRpcClient,
|
|
2126
|
+
de as MetapageShared,
|
|
2127
|
+
pt as MetapageVersionCurrent,
|
|
2128
|
+
zt as MetapageVersionsAll,
|
|
2129
|
+
it as VersionsMetaframe,
|
|
2130
|
+
st as VersionsMetapage,
|
|
2131
|
+
se as convertMetaframeJsonToCurrentVersion,
|
|
2132
|
+
ie as convertMetapageDefinitionToCurrentVersion,
|
|
2133
|
+
gt as deserializeInputs,
|
|
2134
|
+
ye as existsAnyUrlParam,
|
|
2135
|
+
Bt as generateId,
|
|
2136
|
+
Pe as generateMetaframeId,
|
|
2137
|
+
be as generateMetapageId,
|
|
2138
|
+
Ce as generateNonce,
|
|
2139
|
+
De as getLibraryVersionMatching,
|
|
2140
|
+
re as getMatchingVersion,
|
|
2141
|
+
Ue as getUrlParam,
|
|
2142
|
+
ke as getUrlParamDebug,
|
|
2143
|
+
_e as hashCode,
|
|
2144
|
+
we as intToRGB,
|
|
2145
|
+
Ct as isDebugFromUrlsParams,
|
|
2146
|
+
ce as isIframe,
|
|
2147
|
+
Ut as isPageLoaded,
|
|
2148
|
+
Rt as log,
|
|
2149
|
+
Ee as matchPipe,
|
|
2150
|
+
St as merge,
|
|
2151
|
+
jt as pageLoaded,
|
|
2152
|
+
Ie as possiblyDeserializeDatarefToValue,
|
|
2153
|
+
ve as possiblySerializeValueToDataref,
|
|
2154
|
+
Mt as serializeInputs,
|
|
2155
|
+
oe as stringToRgb
|
|
2156
|
+
};
|
|
2157
|
+
//# sourceMappingURL=index.mjs.map
|