@skillbuilder/miniapp-simulator 0.0.0-beta-20261023084421 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -2
- package/dist/sw/miniapp-simulator-service-worker.js +487 -371
- package/dist/sw/miniapp-simulator-service-worker.min.js +1 -1
- package/docs/external-cli-workbench.md +5 -7
- package/docs/npm-integration-verification.md +1 -11
- package/docs/remote-architecture.md +3 -2
- package/docs/worker-runtime.md +62 -0
- package/lib/{client-BZtD2VtP.mjs → client-CO-UjIY3.mjs} +141 -138
- package/lib/index-B5oixYXr.mjs +574 -0
- package/lib/index.js +1152 -1075
- package/lib/remote-client.js +2 -2
- package/lib/types/capabilities/constants.d.ts +1 -0
- package/lib/types/capabilities/csp-snippet.d.ts +2 -0
- package/lib/types/capabilities/security-head-snippet.d.ts +3 -2
- package/lib/types/index.d.ts +8 -1
- package/lib/types/injection/types.d.ts +2 -0
- package/lib/types/remote/protocol.d.ts +7 -2
- package/lib/types/renderer/content-host/iframe-content-host.d.ts +1 -0
- package/lib/types/sw/protocol.d.ts +3 -1
- package/lib/types/sw/served-entry.d.ts +1 -1
- package/lib/types/sw/service-worker-host.d.ts +1 -0
- package/lib/types/sw/worker/globals.d.ts +1 -0
- package/lib/types/sw/worker/mount-store.d.ts +5 -0
- package/lib/types/types/options.d.ts +8 -1
- package/lib/types/workbench/server/index.d.ts +1 -1
- package/lib/types/worker/adapters/csp-policy.d.ts +7 -0
- package/lib/types/worker/adapters/host-lifecycle.d.ts +5 -0
- package/lib/types/worker/adapters/mount-recovery.d.ts +2 -0
- package/lib/types/worker/adapters/package-policy.d.ts +12 -0
- package/lib/types/worker/adapters/page-lifecycle.d.ts +1 -0
- package/lib/types/worker/adapters/protocol.d.ts +49 -0
- package/lib/types/worker/adapters/scripts.d.ts +2 -0
- package/lib/types/worker/adapters/service-worker.d.ts +2 -0
- package/lib/workbench-server.mjs +1 -1
- package/lib/workbench.js +1 -1
- package/package.json +1 -1
- package/lib/index-BW85h7kT.mjs +0 -505
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
const
|
|
1
|
+
import { c as he, r as ye, v as we, o as ve, e as ge } from "./index-B5oixYXr.mjs";
|
|
2
|
+
const K = {
|
|
3
3
|
report() {
|
|
4
4
|
},
|
|
5
5
|
flush() {
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
|
-
function
|
|
9
|
-
if (!t.enabled) return
|
|
8
|
+
function be(t) {
|
|
9
|
+
if (!t.enabled) return K;
|
|
10
10
|
let s;
|
|
11
11
|
try {
|
|
12
12
|
const n = { business_line: t.businessLine };
|
|
13
|
-
s =
|
|
14
|
-
endpoint:
|
|
13
|
+
s = he({
|
|
14
|
+
endpoint: ye(n),
|
|
15
15
|
region: "cn",
|
|
16
16
|
resolveUserId: t.resolveUserId ?? (() => Promise.resolve(""))
|
|
17
17
|
});
|
|
18
18
|
} catch {
|
|
19
|
-
return
|
|
19
|
+
return K;
|
|
20
20
|
}
|
|
21
21
|
return {
|
|
22
22
|
report(n, i = {}) {
|
|
@@ -26,7 +26,7 @@ function ve(t) {
|
|
|
26
26
|
timestamp: Date.now(),
|
|
27
27
|
payload: {
|
|
28
28
|
business_line: t.businessLine,
|
|
29
|
-
sdk_version:
|
|
29
|
+
sdk_version: we,
|
|
30
30
|
renderer: "iframe-service-worker",
|
|
31
31
|
app_id: t.appId,
|
|
32
32
|
session_id: t.sessionId,
|
|
@@ -62,14 +62,14 @@ function I() {
|
|
|
62
62
|
function h(t) {
|
|
63
63
|
return Math.max(0, Math.round(I() - t));
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function te(t, s, n, i = {}) {
|
|
66
66
|
try {
|
|
67
|
-
const a =
|
|
67
|
+
const a = Ie(n);
|
|
68
68
|
if (!a) {
|
|
69
69
|
Object.keys(i).length > 0 && t.report(s, i);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
const { duration: d, ...y } =
|
|
72
|
+
const { duration: d, ...y } = Ee(a);
|
|
73
73
|
t.report(s, {
|
|
74
74
|
result: "success",
|
|
75
75
|
duration: y.network_duration,
|
|
@@ -83,12 +83,12 @@ function ee(t, s, n, i = {}) {
|
|
|
83
83
|
Object.keys(i).length > 0 && t.report(s, i);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function
|
|
86
|
+
function Ie(t) {
|
|
87
87
|
if (typeof performance > "u" || !performance.getEntriesByName) return;
|
|
88
88
|
const s = typeof window > "u" ? t : new URL(t, window.location.href).href, n = performance.getEntriesByName(s, "resource");
|
|
89
89
|
return n[n.length - 1];
|
|
90
90
|
}
|
|
91
|
-
function
|
|
91
|
+
function Ee(t) {
|
|
92
92
|
return {
|
|
93
93
|
network_duration: Math.round(t.duration),
|
|
94
94
|
dns_duration: Math.round(t.domainLookupEnd - t.domainLookupStart),
|
|
@@ -98,44 +98,44 @@ function be(t) {
|
|
|
98
98
|
bytes: t.transferSize
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
|
-
const
|
|
102
|
-
version:
|
|
103
|
-
}, _ =
|
|
104
|
-
function
|
|
101
|
+
const Se = 7, _e = {
|
|
102
|
+
version: Se
|
|
103
|
+
}, _ = _e.version, qe = "miniapp-simulator:connect", Be = "inspectorPauseRuntime", Me = 3e4, Z = 2, Re = 100;
|
|
104
|
+
function ze(t) {
|
|
105
105
|
if (!t.appId.trim()) throw new Error("remote simulator appId is required");
|
|
106
106
|
if (!t.businessLine.trim()) throw new Error("remote simulator businessLine is required");
|
|
107
|
-
const s =
|
|
107
|
+
const s = Ae(t.gateway), n = Ce(t.mount), i = Ne([t.serviceUrl, ...t.fallbackServiceUrls ?? []]), a = document.createElement("iframe");
|
|
108
108
|
a.className = t.className ?? "", a.allow = t.iframeAllow ?? "camera; microphone; autoplay; geolocation", a.referrerPolicy = "no-referrer", a.style.display = "block", a.style.width = "100%", a.style.height = "100%", a.style.border = "0";
|
|
109
|
-
const d = t.timeout ??
|
|
110
|
-
let k = 0, S =
|
|
111
|
-
const
|
|
112
|
-
let F =
|
|
113
|
-
const f =
|
|
109
|
+
const d = t.timeout ?? Me, y = /* @__PURE__ */ new Map(), N = de(t.options), p = new Map(Object.entries(t.hostApi ?? {})), m = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map();
|
|
110
|
+
let k = 0, S = ee(), w, V, D, M, R = !1, U, A = !1, W = "single", g = null, b = !1;
|
|
111
|
+
const O = I();
|
|
112
|
+
let F = O, j = O, H, B;
|
|
113
|
+
const f = be({
|
|
114
114
|
enabled: t.tracker !== !1,
|
|
115
115
|
businessLine: t.businessLine,
|
|
116
116
|
appId: t.appId,
|
|
117
117
|
sessionId: S,
|
|
118
118
|
resolveUserId: () => Promise.resolve(typeof B?.userId == "string" ? B.userId : "")
|
|
119
119
|
});
|
|
120
|
-
let x,
|
|
121
|
-
const
|
|
122
|
-
x = e,
|
|
120
|
+
let x, L;
|
|
121
|
+
const ne = new Promise((e, r) => {
|
|
122
|
+
x = e, L = r;
|
|
123
123
|
});
|
|
124
|
-
let
|
|
124
|
+
let C;
|
|
125
125
|
function T() {
|
|
126
|
-
|
|
126
|
+
C !== void 0 && (window.clearTimeout(C), C = void 0);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
T(),
|
|
128
|
+
function se() {
|
|
129
|
+
T(), C = window.setTimeout(() => {
|
|
130
130
|
const e = new Error(`remote simulator timed out after ${d}ms`);
|
|
131
131
|
b = !0, f.report("client_ready", {
|
|
132
132
|
result: "timeout",
|
|
133
|
-
duration: h(
|
|
134
|
-
}), f.flush(), M(e),
|
|
133
|
+
duration: h(O)
|
|
134
|
+
}), f.flush(), M(e), L(e);
|
|
135
135
|
}, d);
|
|
136
136
|
}
|
|
137
|
-
|
|
138
|
-
function
|
|
137
|
+
pe();
|
|
138
|
+
function ie(e) {
|
|
139
139
|
const r = q.get(e.requestId);
|
|
140
140
|
if (r)
|
|
141
141
|
if (q.delete(e.requestId), window.clearTimeout(r.timer), e.ok)
|
|
@@ -159,7 +159,7 @@ function Be(t) {
|
|
|
159
159
|
}), r.reject(o);
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
async function
|
|
162
|
+
async function ae(e, r) {
|
|
163
163
|
const o = p.get(e.event);
|
|
164
164
|
if (typeof o != "function") {
|
|
165
165
|
r.postMessage({
|
|
@@ -191,7 +191,7 @@ function Be(t) {
|
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
async function
|
|
194
|
+
async function ce(e, r) {
|
|
195
195
|
const o = p.get("request");
|
|
196
196
|
if (typeof o != "function") {
|
|
197
197
|
r.postMessage({
|
|
@@ -205,7 +205,7 @@ function Be(t) {
|
|
|
205
205
|
const l = new AbortController();
|
|
206
206
|
m.set(e.requestId, l);
|
|
207
207
|
try {
|
|
208
|
-
const u = await
|
|
208
|
+
const u = await ge(o, e.options, {
|
|
209
209
|
signal: l.signal,
|
|
210
210
|
onHeaders(v) {
|
|
211
211
|
r.postMessage({
|
|
@@ -245,36 +245,36 @@ function Be(t) {
|
|
|
245
245
|
m.delete(e.requestId);
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
|
-
function
|
|
248
|
+
function ue(e) {
|
|
249
249
|
m.get(e.requestId)?.abort();
|
|
250
250
|
}
|
|
251
|
-
function
|
|
252
|
-
e.event === "inspectorChange" && (A = !!e.payload?.enabled),
|
|
251
|
+
function le(e) {
|
|
252
|
+
e.event === "inspectorChange" && (A = !!e.payload?.enabled), J(e.event, e.payload);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function G(e, r) {
|
|
255
255
|
let o = y.get(e);
|
|
256
256
|
o || (o = /* @__PURE__ */ new Set(), y.set(e, o)), o.add(r);
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function de(e) {
|
|
259
259
|
if (!e) return {};
|
|
260
260
|
const { onRouterChange: r, onScreenShot: o, ...l } = e;
|
|
261
|
-
return r &&
|
|
261
|
+
return r && G(
|
|
262
262
|
"routerChange",
|
|
263
263
|
(u) => r(u)
|
|
264
|
-
), o &&
|
|
264
|
+
), o && G("screenShot", (u) => o(u)), l;
|
|
265
265
|
}
|
|
266
266
|
a.onload = () => {
|
|
267
|
-
g &&
|
|
267
|
+
g && te(f, "runtime_document", g.href, {
|
|
268
268
|
result: "success",
|
|
269
269
|
duration: h(F)
|
|
270
|
-
}),
|
|
270
|
+
}), fe();
|
|
271
271
|
};
|
|
272
|
-
async function
|
|
272
|
+
async function fe() {
|
|
273
273
|
if (R || !g) return;
|
|
274
|
-
const e = w, r = S, o = await
|
|
274
|
+
const e = w, r = S, o = await ke(p);
|
|
275
275
|
if (B = o, R || !g || e !== w) return;
|
|
276
276
|
const l = {
|
|
277
|
-
type:
|
|
277
|
+
type: qe,
|
|
278
278
|
protocolVersion: _,
|
|
279
279
|
sessionId: r,
|
|
280
280
|
appId: t.appId,
|
|
@@ -282,11 +282,11 @@ function Be(t) {
|
|
|
282
282
|
tracker: t.tracker !== !1,
|
|
283
283
|
gateway: s,
|
|
284
284
|
userInfo: o,
|
|
285
|
-
hostApiMethods:
|
|
286
|
-
hostApiStubs:
|
|
287
|
-
options:
|
|
285
|
+
hostApiMethods: X(p),
|
|
286
|
+
hostApiStubs: Q(p),
|
|
287
|
+
options: N
|
|
288
288
|
};
|
|
289
|
-
|
|
289
|
+
j = I(), a.contentWindow?.postMessage(l, g.origin, [e.port2]);
|
|
290
290
|
}
|
|
291
291
|
a.onerror = () => {
|
|
292
292
|
const e = new Error(
|
|
@@ -296,59 +296,59 @@ function Be(t) {
|
|
|
296
296
|
result: "fail",
|
|
297
297
|
duration: h(F),
|
|
298
298
|
message: e.message.slice(0, 512)
|
|
299
|
-
}), f.flush(), M(e), b ?
|
|
299
|
+
}), f.flush(), M(e), b ? J("error", {
|
|
300
300
|
code: "LOAD_FAILED",
|
|
301
301
|
message: e.message,
|
|
302
302
|
url: g?.href,
|
|
303
303
|
cause: e
|
|
304
|
-
}) : (b = !0, T(),
|
|
305
|
-
},
|
|
304
|
+
}) : (b = !0, T(), L(e));
|
|
305
|
+
}, Ue(i, f).then(
|
|
306
306
|
(e) => {
|
|
307
|
-
R || (g = e, F = I(),
|
|
307
|
+
R || (g = e, F = I(), se(), a.src = e.href, n.appendChild(a));
|
|
308
308
|
},
|
|
309
309
|
(e) => {
|
|
310
310
|
const r = e instanceof Error ? e : new Error(String(e));
|
|
311
311
|
b = !0, T(), f.report("client_ready", {
|
|
312
312
|
result: "fail",
|
|
313
|
-
duration: h(
|
|
313
|
+
duration: h(O),
|
|
314
314
|
message: r.message.slice(0, 512)
|
|
315
|
-
}), f.flush(), M(r),
|
|
315
|
+
}), f.flush(), M(r), L(r);
|
|
316
316
|
}
|
|
317
317
|
);
|
|
318
318
|
async function c(e, ...r) {
|
|
319
|
-
return
|
|
319
|
+
return z(`${S}-${++k}`, e, ...r);
|
|
320
320
|
}
|
|
321
|
-
async function
|
|
321
|
+
async function z(e, r, ...o) {
|
|
322
322
|
if (R) throw new Error("remote simulator has been destroyed");
|
|
323
|
-
await
|
|
324
|
-
const l =
|
|
323
|
+
await V;
|
|
324
|
+
const l = Pe(o);
|
|
325
325
|
return new Promise((u, v) => {
|
|
326
|
-
const
|
|
326
|
+
const Y = I(), me = window.setTimeout(() => {
|
|
327
327
|
q.delete(e), f.report("remote_request", {
|
|
328
328
|
type: r,
|
|
329
329
|
request_id: e,
|
|
330
330
|
result: "timeout",
|
|
331
|
-
duration: h(
|
|
331
|
+
duration: h(Y)
|
|
332
332
|
}), v(new Error(`remote simulator ${r} timed out after ${d}ms`));
|
|
333
333
|
}, d);
|
|
334
|
-
q.set(e, { resolve: u, reject: v, timer:
|
|
334
|
+
q.set(e, { resolve: u, reject: v, timer: me, method: r, startedAt: Y }), w.port1.postMessage({ type: "request", requestId: e, method: r, args: o }, l);
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
return {
|
|
338
338
|
iframe: a,
|
|
339
|
-
ready:
|
|
339
|
+
ready: ne,
|
|
340
340
|
load: () => c("load"),
|
|
341
341
|
async loadZip(e, r) {
|
|
342
342
|
const o = `${S}-${++k}`, l = I();
|
|
343
343
|
try {
|
|
344
|
-
const u = await
|
|
344
|
+
const u = await oe(e).arrayBuffer();
|
|
345
345
|
return f.report("package_materialize", {
|
|
346
346
|
request_id: o,
|
|
347
347
|
result: "success",
|
|
348
348
|
duration: h(l),
|
|
349
349
|
bytes: u.byteLength,
|
|
350
350
|
type: "zip"
|
|
351
|
-
}),
|
|
351
|
+
}), z(o, "loadZip", {
|
|
352
352
|
buffer: u,
|
|
353
353
|
options: r
|
|
354
354
|
});
|
|
@@ -358,22 +358,22 @@ function Be(t) {
|
|
|
358
358
|
result: "fail",
|
|
359
359
|
duration: h(l),
|
|
360
360
|
type: "zip",
|
|
361
|
-
message:
|
|
361
|
+
message: $(u).slice(0, 512)
|
|
362
362
|
}), u;
|
|
363
363
|
}
|
|
364
364
|
},
|
|
365
365
|
loadFiles: async (e, r) => {
|
|
366
366
|
const o = `${S}-${++k}`, l = I();
|
|
367
367
|
try {
|
|
368
|
-
const u = await
|
|
368
|
+
const u = await Ve(e);
|
|
369
369
|
return f.report("package_materialize", {
|
|
370
370
|
request_id: o,
|
|
371
371
|
result: "success",
|
|
372
372
|
duration: h(l),
|
|
373
373
|
type: "files",
|
|
374
374
|
count: Object.keys(u).length,
|
|
375
|
-
bytes:
|
|
376
|
-
}),
|
|
375
|
+
bytes: Fe(u)
|
|
376
|
+
}), z(o, "loadFiles", {
|
|
377
377
|
files: u,
|
|
378
378
|
options: r
|
|
379
379
|
});
|
|
@@ -383,7 +383,7 @@ function Be(t) {
|
|
|
383
383
|
result: "fail",
|
|
384
384
|
duration: h(l),
|
|
385
385
|
type: "files",
|
|
386
|
-
message:
|
|
386
|
+
message: $(u).slice(0, 512)
|
|
387
387
|
}), u;
|
|
388
388
|
}
|
|
389
389
|
},
|
|
@@ -437,25 +437,25 @@ function Be(t) {
|
|
|
437
437
|
c("inspector.clear");
|
|
438
438
|
},
|
|
439
439
|
setSelectionMode: (e) => {
|
|
440
|
-
|
|
440
|
+
W = e, c("inspector.setSelectionMode", e);
|
|
441
441
|
},
|
|
442
|
-
getSelectionMode: () =>
|
|
442
|
+
getSelectionMode: () => W,
|
|
443
443
|
getSceneTree: () => c("inspector.getSceneTree"),
|
|
444
444
|
selectByRef: (e) => c("inspector.selectByRef", e)
|
|
445
445
|
},
|
|
446
446
|
hostApi: {
|
|
447
447
|
set(e, r) {
|
|
448
|
-
p.set(e, r),
|
|
448
|
+
p.set(e, r), P();
|
|
449
449
|
},
|
|
450
450
|
registerAll(e) {
|
|
451
451
|
for (const [r, o] of Object.entries(e)) p.set(r, o);
|
|
452
|
-
|
|
452
|
+
P();
|
|
453
453
|
},
|
|
454
454
|
remove(e) {
|
|
455
|
-
p.delete(e),
|
|
455
|
+
p.delete(e), P();
|
|
456
456
|
},
|
|
457
457
|
clear() {
|
|
458
|
-
p.clear(),
|
|
458
|
+
p.clear(), P();
|
|
459
459
|
},
|
|
460
460
|
has: (e) => p.has(e),
|
|
461
461
|
emit: (e, r) => {
|
|
@@ -469,7 +469,7 @@ function Be(t) {
|
|
|
469
469
|
},
|
|
470
470
|
destroy(e) {
|
|
471
471
|
if (!R) {
|
|
472
|
-
R = !0, T(),
|
|
472
|
+
R = !0, U?.(), T(), je(w.port1, S, ++k, e), M(new Error("remote simulator has been destroyed"));
|
|
473
473
|
for (const r of q.values())
|
|
474
474
|
window.clearTimeout(r.timer), r.reject(new Error("remote simulator has been destroyed"));
|
|
475
475
|
q.clear();
|
|
@@ -478,14 +478,15 @@ function Be(t) {
|
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
};
|
|
481
|
-
function
|
|
482
|
-
return c("hostApi.sync",
|
|
481
|
+
function P() {
|
|
482
|
+
return c("hostApi.sync", X(p), Q(p));
|
|
483
483
|
}
|
|
484
|
-
function
|
|
484
|
+
function pe() {
|
|
485
|
+
U?.(), U = void 0;
|
|
485
486
|
for (const r of m.values()) r.abort();
|
|
486
|
-
m.clear(), w && (w.port1.close(), S =
|
|
487
|
-
|
|
488
|
-
}),
|
|
487
|
+
m.clear(), w && (w.port1.close(), S = ee()), k = 0, w = new MessageChannel(), V = new Promise((r, o) => {
|
|
488
|
+
D = r, M = o;
|
|
489
|
+
}), V.catch(() => {
|
|
489
490
|
});
|
|
490
491
|
const e = w;
|
|
491
492
|
e.port1.onmessage = (r) => {
|
|
@@ -498,47 +499,49 @@ function Be(t) {
|
|
|
498
499
|
);
|
|
499
500
|
f.report("runtime_handshake", {
|
|
500
501
|
result: "protocol_mismatch",
|
|
501
|
-
duration: h(
|
|
502
|
+
duration: h(j),
|
|
502
503
|
runtime_version: o.runtimeVersion
|
|
503
|
-
}), f.flush(), M(l), b || (b = !0, T(),
|
|
504
|
+
}), f.flush(), M(l), b || (b = !0, T(), L(l));
|
|
504
505
|
return;
|
|
505
506
|
}
|
|
506
|
-
|
|
507
|
+
H = o.runtimeVersion, U?.(), U = ve(a, (l) => {
|
|
508
|
+
e.port1.postMessage({ type: "worker-visibility", visible: l });
|
|
509
|
+
}), f.report("runtime_handshake", {
|
|
507
510
|
result: "success",
|
|
508
|
-
duration: h(
|
|
509
|
-
runtime_version:
|
|
511
|
+
duration: h(j),
|
|
512
|
+
runtime_version: H
|
|
510
513
|
}), f.report("client_ready", {
|
|
511
514
|
result: "success",
|
|
512
|
-
duration: h(
|
|
513
|
-
runtime_version:
|
|
514
|
-
}),
|
|
515
|
+
duration: h(O),
|
|
516
|
+
runtime_version: H
|
|
517
|
+
}), D(o), b || (b = !0, T(), x(o));
|
|
515
518
|
return;
|
|
516
519
|
}
|
|
517
520
|
if (o?.type === "response") {
|
|
518
|
-
|
|
521
|
+
ie(o);
|
|
519
522
|
return;
|
|
520
523
|
}
|
|
521
524
|
if (o?.type === "host-api-request") {
|
|
522
|
-
|
|
525
|
+
ae(o, e.port1);
|
|
523
526
|
return;
|
|
524
527
|
}
|
|
525
528
|
if (o?.type === "host-request") {
|
|
526
|
-
|
|
529
|
+
ce(o, e.port1);
|
|
527
530
|
return;
|
|
528
531
|
}
|
|
529
532
|
if (o?.type === "host-request-abort") {
|
|
530
|
-
|
|
533
|
+
ue(o);
|
|
531
534
|
return;
|
|
532
535
|
}
|
|
533
|
-
o?.type === "event" &&
|
|
536
|
+
o?.type === "event" && le(o);
|
|
534
537
|
}, e.port1.start();
|
|
535
538
|
}
|
|
536
|
-
function
|
|
539
|
+
function J(e, r) {
|
|
537
540
|
for (const o of [e, "*"])
|
|
538
541
|
for (const l of y.get(o) ?? []) l(r);
|
|
539
542
|
}
|
|
540
543
|
}
|
|
541
|
-
function
|
|
544
|
+
function Ae(t) {
|
|
542
545
|
if (!t) return;
|
|
543
546
|
const s = {};
|
|
544
547
|
for (const [n, i] of Object.entries(t)) {
|
|
@@ -551,7 +554,7 @@ function Me(t) {
|
|
|
551
554
|
} catch {
|
|
552
555
|
throw new Error(`remote simulator gateway.${n} must be an absolute HTTPS URL`);
|
|
553
556
|
}
|
|
554
|
-
if (!
|
|
557
|
+
if (!Te(d))
|
|
555
558
|
throw new Error(
|
|
556
559
|
`remote simulator gateway.${n} must use HTTPS (HTTP is allowed only for loopback development)`
|
|
557
560
|
);
|
|
@@ -563,13 +566,13 @@ function Me(t) {
|
|
|
563
566
|
throw new Error("remote simulator gateway.www is required");
|
|
564
567
|
return s;
|
|
565
568
|
}
|
|
566
|
-
function
|
|
569
|
+
function Te(t) {
|
|
567
570
|
return t.protocol === "https:" ? !0 : t.protocol === "http:" && (t.hostname === "localhost" || t.hostname === "127.0.0.1" || t.hostname === "[::1]");
|
|
568
571
|
}
|
|
569
|
-
function
|
|
572
|
+
function X(t) {
|
|
570
573
|
return [...t].filter(([, s]) => typeof s == "function").map(([s]) => s);
|
|
571
574
|
}
|
|
572
|
-
async function
|
|
575
|
+
async function ke(t) {
|
|
573
576
|
const s = t.get("getUserInfo");
|
|
574
577
|
if (typeof s == "function")
|
|
575
578
|
try {
|
|
@@ -583,7 +586,7 @@ async function Ae(t) {
|
|
|
583
586
|
return;
|
|
584
587
|
}
|
|
585
588
|
}
|
|
586
|
-
function
|
|
589
|
+
function Q(t) {
|
|
587
590
|
return Object.fromEntries(
|
|
588
591
|
[...t].filter((s) => {
|
|
589
592
|
const n = s[1];
|
|
@@ -596,25 +599,25 @@ class E extends Error {
|
|
|
596
599
|
super(s), this.kind = n, this.retryable = i, this.status = a, this.name = "ManifestRequestError";
|
|
597
600
|
}
|
|
598
601
|
}
|
|
599
|
-
async function
|
|
602
|
+
async function Ue(t, s) {
|
|
600
603
|
const n = [], i = new Set(t.map((a) => a.href));
|
|
601
|
-
for (let a = 1; a <=
|
|
604
|
+
for (let a = 1; a <= Z; a += 1) {
|
|
602
605
|
for (const [d, y] of t.entries()) {
|
|
603
606
|
if (a > 1 && !i.has(y.href)) continue;
|
|
604
|
-
const
|
|
607
|
+
const N = I();
|
|
605
608
|
try {
|
|
606
|
-
const p = await
|
|
607
|
-
return
|
|
609
|
+
const p = await Oe(y), m = re(y);
|
|
610
|
+
return te(s, "runtime_manifest", m.href, {
|
|
608
611
|
result: "success",
|
|
609
|
-
duration: h(
|
|
612
|
+
duration: h(N),
|
|
610
613
|
type: d === 0 ? "primary" : "fallback",
|
|
611
614
|
count: a
|
|
612
615
|
}), p;
|
|
613
616
|
} catch (p) {
|
|
614
|
-
const m =
|
|
617
|
+
const m = Le(p);
|
|
615
618
|
s.report("runtime_manifest", {
|
|
616
619
|
result: "fail",
|
|
617
|
-
duration: h(
|
|
620
|
+
duration: h(N),
|
|
618
621
|
type: d === 0 ? "primary" : "fallback",
|
|
619
622
|
count: a,
|
|
620
623
|
...m.status === void 0 ? { error_name: m.kind } : { code: m.status },
|
|
@@ -622,13 +625,13 @@ async function Te(t, s) {
|
|
|
622
625
|
}), n.push(`${y.href} attempt ${a}: ${m.message}`), m.retryable || i.delete(y.href);
|
|
623
626
|
}
|
|
624
627
|
}
|
|
625
|
-
if (a >=
|
|
626
|
-
await
|
|
628
|
+
if (a >= Z || i.size === 0) break;
|
|
629
|
+
await $e();
|
|
627
630
|
}
|
|
628
631
|
throw new Error(`remote simulator services unavailable: ${n.join("; ")}`);
|
|
629
632
|
}
|
|
630
|
-
async function
|
|
631
|
-
const s =
|
|
633
|
+
async function Oe(t) {
|
|
634
|
+
const s = re(t);
|
|
632
635
|
s.searchParams.set("protocolVersion", String(_));
|
|
633
636
|
let n;
|
|
634
637
|
try {
|
|
@@ -639,7 +642,7 @@ async function ke(t) {
|
|
|
639
642
|
});
|
|
640
643
|
} catch (d) {
|
|
641
644
|
throw new E(
|
|
642
|
-
`remote simulator manifest network error: ${
|
|
645
|
+
`remote simulator manifest network error: ${$(d)}`,
|
|
643
646
|
"MANIFEST_NETWORK_ERROR",
|
|
644
647
|
!0
|
|
645
648
|
);
|
|
@@ -656,7 +659,7 @@ async function ke(t) {
|
|
|
656
659
|
i = await n.json();
|
|
657
660
|
} catch (d) {
|
|
658
661
|
throw new E(
|
|
659
|
-
`remote simulator manifest JSON is invalid: ${
|
|
662
|
+
`remote simulator manifest JSON is invalid: ${$(d)}`,
|
|
660
663
|
"MANIFEST_INVALID_JSON",
|
|
661
664
|
!0
|
|
662
665
|
);
|
|
@@ -682,17 +685,17 @@ async function ke(t) {
|
|
|
682
685
|
);
|
|
683
686
|
return a;
|
|
684
687
|
}
|
|
685
|
-
function
|
|
686
|
-
return t instanceof E ? t : new E(
|
|
688
|
+
function Le(t) {
|
|
689
|
+
return t instanceof E ? t : new E($(t), "MANIFEST_UNKNOWN_ERROR", !1);
|
|
687
690
|
}
|
|
688
|
-
function
|
|
689
|
-
return new Promise((t) => window.setTimeout(t,
|
|
691
|
+
function $e() {
|
|
692
|
+
return new Promise((t) => window.setTimeout(t, Re));
|
|
690
693
|
}
|
|
691
|
-
function
|
|
694
|
+
function re(t) {
|
|
692
695
|
const s = t.href.endsWith("/") ? t : new URL(`${t.href}/`), n = new URL("runtime-manifest", s);
|
|
693
696
|
return n.searchParams.set("protocolVersion", String(_)), n;
|
|
694
697
|
}
|
|
695
|
-
function
|
|
698
|
+
function Ne(t) {
|
|
696
699
|
const s = /* @__PURE__ */ new Set(), n = [];
|
|
697
700
|
for (const i of t) {
|
|
698
701
|
const a = new URL(i, window.location.href), d = a.href.endsWith("/") ? a : new URL(`${a.href}/`);
|
|
@@ -700,20 +703,20 @@ function Le(t) {
|
|
|
700
703
|
}
|
|
701
704
|
return n;
|
|
702
705
|
}
|
|
703
|
-
function
|
|
706
|
+
function $(t) {
|
|
704
707
|
return t instanceof Error ? t.message : String(t);
|
|
705
708
|
}
|
|
706
|
-
function
|
|
709
|
+
function Ce(t) {
|
|
707
710
|
const s = typeof t == "string" ? document.querySelector(t) : t;
|
|
708
711
|
if (!s) throw new Error("remote simulator mount element not found");
|
|
709
712
|
return s;
|
|
710
713
|
}
|
|
711
|
-
function
|
|
714
|
+
function oe(t) {
|
|
712
715
|
if (t instanceof Blob) return t;
|
|
713
716
|
const s = t instanceof ArrayBuffer ? t : Uint8Array.from(t).buffer;
|
|
714
717
|
return new Blob([s]);
|
|
715
718
|
}
|
|
716
|
-
function
|
|
719
|
+
function Pe(t) {
|
|
717
720
|
const s = /* @__PURE__ */ new Set(), n = (i) => {
|
|
718
721
|
if (i instanceof ArrayBuffer) {
|
|
719
722
|
s.add(i);
|
|
@@ -733,17 +736,17 @@ function Ne(t) {
|
|
|
733
736
|
};
|
|
734
737
|
return n(t), [...s];
|
|
735
738
|
}
|
|
736
|
-
async function
|
|
739
|
+
async function Ve(t) {
|
|
737
740
|
return Object.fromEntries(
|
|
738
741
|
await Promise.all(
|
|
739
742
|
Object.entries(t).map(async ([s, n]) => [
|
|
740
743
|
s,
|
|
741
|
-
typeof n == "string" ? n : await
|
|
744
|
+
typeof n == "string" ? n : await oe(n).arrayBuffer()
|
|
742
745
|
])
|
|
743
746
|
)
|
|
744
747
|
);
|
|
745
748
|
}
|
|
746
|
-
function
|
|
749
|
+
function Fe(t) {
|
|
747
750
|
try {
|
|
748
751
|
const s = new TextEncoder();
|
|
749
752
|
return Object.values(t).reduce((n, i) => typeof i == "string" ? n + s.encode(i).byteLength : i instanceof ArrayBuffer || ArrayBuffer.isView(i) ? n + i.byteLength : n, 0);
|
|
@@ -751,7 +754,7 @@ function Pe(t) {
|
|
|
751
754
|
return;
|
|
752
755
|
}
|
|
753
756
|
}
|
|
754
|
-
function
|
|
757
|
+
function je(t, s, n, i) {
|
|
755
758
|
try {
|
|
756
759
|
t.postMessage({
|
|
757
760
|
type: "request",
|
|
@@ -762,11 +765,11 @@ function Fe(t, s, n, i) {
|
|
|
762
765
|
} catch {
|
|
763
766
|
}
|
|
764
767
|
}
|
|
765
|
-
function
|
|
768
|
+
function ee() {
|
|
766
769
|
return typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
|
|
767
770
|
}
|
|
768
771
|
export {
|
|
769
|
-
|
|
772
|
+
Be as R,
|
|
770
773
|
_ as a,
|
|
771
|
-
|
|
774
|
+
ze as c
|
|
772
775
|
};
|