verifi-lib-js 0.0.0-stage → 2.1.2
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 +29 -2
- package/assets/bg/blue.mp4 +0 -0
- package/assets/bg/green.mp4 +0 -0
- package/assets/bg/poster.jpg +0 -0
- package/assets/bg/teal.mp4 +0 -0
- package/assets/fonts/auge-bold.otf +0 -0
- package/assets/fonts/auge-regular.otf +0 -0
- package/assets/fonts/auge-semibold.otf +0 -0
- package/assets/fonts/inter-var.ttf +0 -0
- package/assets/fonts/jetbrains-mono-var.ttf +0 -0
- package/assets/fonts/pacifico.ttf +0 -0
- package/assets/fonts/space-grotesk-var.ttf +0 -0
- package/assets/logos/verifi-lib-js-backup.svg +48 -0
- package/assets/logos/verifi-lib-js.svg +19 -0
- package/assets/site/backup/Pacifico-Regular-95szj24p.ttf +0 -0
- package/assets/site/backup/auge-bold-vywa1g7b.otf +0 -0
- package/assets/site/backup/auge-regular-hz0spgka.otf +0 -0
- package/assets/site/backup/auge-semibold-td2xkdwf.otf +0 -0
- package/assets/site/backup/copium-meme.png +0 -0
- package/assets/site/backup/engine/controller.api.js +1344 -0
- package/assets/site/backup/engine/controller.inject.js +511 -0
- package/assets/site/backup/engine/controller.sw.js +418 -0
- package/assets/site/backup/engine/corridor.js +13215 -0
- package/assets/site/backup/engine/corridor.wasm +0 -0
- package/assets/site/backup/site-backup.css +1 -0
- package/assets/site/backup/site-backup.js +74 -0
- package/assets/site/backup/sw.js +224 -0
- package/assets/site/index.html +113 -0
- package/assets/site/site.css +226 -0
- package/assets/site/site.js +209 -0
- package/index.cjs +104 -0
- package/index.d.ts +16 -0
- package/package.json +30 -4
|
@@ -0,0 +1,1344 @@
|
|
|
1
|
+
var $corridorController;
|
|
2
|
+
(() => {
|
|
3
|
+
var __webpack_modules__ = ({
|
|
4
|
+
"./packages/controller/src/symbols.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
7
|
+
CONTROLLERFRAME: () => (CONTROLLERFRAME)
|
|
8
|
+
});
|
|
9
|
+
const CONTROLLERFRAME = Symbol.for("controller frame handle");
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
},
|
|
13
|
+
"./packages/controller/src/version.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
16
|
+
VERSION: () => (VERSION),
|
|
17
|
+
assertRuntimeCorridorVersion: () => (assertRuntimeCorridorVersion)
|
|
18
|
+
});
|
|
19
|
+
const VERSION = "0.0.14";
|
|
20
|
+
function assertVersionMatch(packageName, expected, actual) {
|
|
21
|
+
if (expected !== actual) {
|
|
22
|
+
throw new Error(`${packageName} version mismatch: this build expects ${expected}, but the loaded runtime is ${actual}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function assertRuntimeCorridorVersion() {
|
|
26
|
+
if (typeof $corridor === "undefined") {
|
|
27
|
+
throw new Error("@mercuryworkshop/corridor is not loaded. Load corridor before the controller.");
|
|
28
|
+
}
|
|
29
|
+
assertVersionMatch("@mercuryworkshop/corridor", "2.0.67-alpha.2", $corridor.versionInfo.version);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
},
|
|
34
|
+
"./packages/rpc/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
35
|
+
__webpack_require__.r(__webpack_exports__);
|
|
36
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
37
|
+
RpcHelper: () => (RpcHelper)
|
|
38
|
+
});
|
|
39
|
+
class RpcHelper {
|
|
40
|
+
methods;
|
|
41
|
+
id;
|
|
42
|
+
sendRaw;
|
|
43
|
+
counter = 0;
|
|
44
|
+
promiseCallbacks = new Map();
|
|
45
|
+
constructor(methods, id, sendRaw){
|
|
46
|
+
this.methods = methods;
|
|
47
|
+
this.id = id;
|
|
48
|
+
this.sendRaw = sendRaw;
|
|
49
|
+
}
|
|
50
|
+
recieve(data) {
|
|
51
|
+
if (data === undefined || data === null || typeof data !== "object") return;
|
|
52
|
+
const dt = data[this.id];
|
|
53
|
+
if (dt === undefined || dt === null || typeof dt !== "object") return;
|
|
54
|
+
const type = dt.$type;
|
|
55
|
+
if (type === "response") {
|
|
56
|
+
const token = dt.$token;
|
|
57
|
+
const data = dt.$data;
|
|
58
|
+
const error = dt.$error;
|
|
59
|
+
const cb = this.promiseCallbacks.get(token);
|
|
60
|
+
if (!cb) return;
|
|
61
|
+
this.promiseCallbacks.delete(token);
|
|
62
|
+
if (error !== undefined) {
|
|
63
|
+
cb.reject(new Error(error));
|
|
64
|
+
} else {
|
|
65
|
+
cb.resolve(data);
|
|
66
|
+
}
|
|
67
|
+
} else if (type === "request") {
|
|
68
|
+
const method = dt.$method;
|
|
69
|
+
const args = dt.$args;
|
|
70
|
+
this.methods[method](args).then((r)=>{
|
|
71
|
+
this.sendRaw({
|
|
72
|
+
[this.id]: {
|
|
73
|
+
$type: "response",
|
|
74
|
+
$token: dt.$token,
|
|
75
|
+
$data: r?.[0]
|
|
76
|
+
}
|
|
77
|
+
}, r?.[1]);
|
|
78
|
+
}).catch((err)=>{
|
|
79
|
+
console.error(err);
|
|
80
|
+
this.sendRaw({
|
|
81
|
+
[this.id]: {
|
|
82
|
+
$type: "response",
|
|
83
|
+
$token: dt.$token,
|
|
84
|
+
$error: err?.toString() || "Unknown error"
|
|
85
|
+
}
|
|
86
|
+
}, []);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
call(method, args, transfer = []) {
|
|
91
|
+
const token = this.counter++;
|
|
92
|
+
return new Promise((resolve, reject)=>{
|
|
93
|
+
this.promiseCallbacks.set(token, {
|
|
94
|
+
resolve,
|
|
95
|
+
reject
|
|
96
|
+
});
|
|
97
|
+
this.sendRaw({
|
|
98
|
+
[this.id]: {
|
|
99
|
+
$type: "request",
|
|
100
|
+
$method: method,
|
|
101
|
+
$args: args,
|
|
102
|
+
$token: token
|
|
103
|
+
}
|
|
104
|
+
}, transfer);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
},
|
|
111
|
+
"./node_modules/.pnpm/@fastify+deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js"(module) {
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
// based on https://github.com/TehShrike/deepmerge
|
|
115
|
+
// MIT License
|
|
116
|
+
// Copyright (c) 2012 - 2022 James Halliday, Josh Duff, and other contributors of deepmerge
|
|
117
|
+
|
|
118
|
+
const JSON_PROTO = Object.getPrototypeOf({})
|
|
119
|
+
|
|
120
|
+
function defaultIsMergeableObjectFactory () {
|
|
121
|
+
return function defaultIsMergeableObject (value) {
|
|
122
|
+
return typeof value === 'object' && value !== null && !(value instanceof RegExp) && !(value instanceof Date)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function deepmergeConstructor (options) {
|
|
127
|
+
function isNotPrototypeKey (value) {
|
|
128
|
+
return (
|
|
129
|
+
value !== 'constructor' &&
|
|
130
|
+
value !== 'prototype' &&
|
|
131
|
+
value !== '__proto__'
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function cloneArray (value) {
|
|
136
|
+
let i = 0
|
|
137
|
+
const il = value.length
|
|
138
|
+
const result = new Array(il)
|
|
139
|
+
for (i; i < il; ++i) {
|
|
140
|
+
result[i] = clone(value[i])
|
|
141
|
+
}
|
|
142
|
+
return result
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function cloneObject (target) {
|
|
146
|
+
const result = {}
|
|
147
|
+
|
|
148
|
+
if (cloneProtoObject && Object.getPrototypeOf(target) !== JSON_PROTO) {
|
|
149
|
+
return cloneProtoObject(target)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const targetKeys = getKeys(target)
|
|
153
|
+
let i, il, key
|
|
154
|
+
for (i = 0, il = targetKeys.length; i < il; ++i) {
|
|
155
|
+
isNotPrototypeKey(key = targetKeys[i]) &&
|
|
156
|
+
(result[key] = clone(target[key]))
|
|
157
|
+
}
|
|
158
|
+
return result
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function concatArrays (target, source) {
|
|
162
|
+
const tl = target.length
|
|
163
|
+
const sl = source.length
|
|
164
|
+
let i = 0
|
|
165
|
+
const result = new Array(tl + sl)
|
|
166
|
+
for (i; i < tl; ++i) {
|
|
167
|
+
result[i] = clone(target[i])
|
|
168
|
+
}
|
|
169
|
+
for (i = 0; i < sl; ++i) {
|
|
170
|
+
result[i + tl] = clone(source[i])
|
|
171
|
+
}
|
|
172
|
+
return result
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const propertyIsEnumerable = Object.prototype.propertyIsEnumerable
|
|
176
|
+
function getSymbolsAndKeys (value) {
|
|
177
|
+
const result = Object.keys(value)
|
|
178
|
+
const keys = Object.getOwnPropertySymbols(value)
|
|
179
|
+
for (let i = 0, il = keys.length; i < il; ++i) {
|
|
180
|
+
propertyIsEnumerable.call(value, keys[i]) && result.push(keys[i])
|
|
181
|
+
}
|
|
182
|
+
return result
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const getKeys = options?.symbols
|
|
186
|
+
? getSymbolsAndKeys
|
|
187
|
+
: Object.keys
|
|
188
|
+
|
|
189
|
+
const cloneProtoObject = typeof options?.cloneProtoObject === 'function'
|
|
190
|
+
? options.cloneProtoObject
|
|
191
|
+
: undefined
|
|
192
|
+
|
|
193
|
+
const isMergeableObject = typeof options?.isMergeableObject === 'function'
|
|
194
|
+
? options.isMergeableObject
|
|
195
|
+
: defaultIsMergeableObjectFactory()
|
|
196
|
+
|
|
197
|
+
const onlyDefinedProperties = options?.onlyDefinedProperties === true
|
|
198
|
+
|
|
199
|
+
function isPrimitive (value) {
|
|
200
|
+
return typeof value !== 'object' || value === null
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const mergeArray = options && typeof options.mergeArray === 'function'
|
|
204
|
+
? options.mergeArray({ clone, deepmerge: _deepmerge, getKeys, isMergeableObject })
|
|
205
|
+
: concatArrays
|
|
206
|
+
|
|
207
|
+
function clone (entry) {
|
|
208
|
+
return isMergeableObject(entry)
|
|
209
|
+
? Array.isArray(entry)
|
|
210
|
+
? cloneArray(entry)
|
|
211
|
+
: cloneObject(entry)
|
|
212
|
+
: entry
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function mergeObject (target, source) {
|
|
216
|
+
const result = {}
|
|
217
|
+
const targetKeys = getKeys(target)
|
|
218
|
+
const sourceKeys = getKeys(source)
|
|
219
|
+
let i, il, key
|
|
220
|
+
for (i = 0, il = targetKeys.length; i < il; ++i) {
|
|
221
|
+
isNotPrototypeKey(key = targetKeys[i]) &&
|
|
222
|
+
(sourceKeys.indexOf(key) === -1) &&
|
|
223
|
+
(result[key] = clone(target[key]))
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
for (i = 0, il = sourceKeys.length; i < il; ++i) {
|
|
227
|
+
if (!isNotPrototypeKey(key = sourceKeys[i])) {
|
|
228
|
+
continue
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (key in target) {
|
|
232
|
+
if (targetKeys.indexOf(key) !== -1) {
|
|
233
|
+
if (cloneProtoObject && isMergeableObject(source[key]) && Object.getPrototypeOf(source[key]) !== JSON_PROTO) {
|
|
234
|
+
result[key] = cloneProtoObject(source[key])
|
|
235
|
+
} else {
|
|
236
|
+
result[key] = _deepmerge(target[key], source[key])
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
if (onlyDefinedProperties && typeof source[key] === 'undefined') {
|
|
241
|
+
continue
|
|
242
|
+
}
|
|
243
|
+
result[key] = clone(source[key])
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return result
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function _deepmerge (target, source) {
|
|
250
|
+
if (onlyDefinedProperties && typeof source === 'undefined') {
|
|
251
|
+
return clone(target)
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const sourceIsArray = Array.isArray(source)
|
|
255
|
+
const targetIsArray = Array.isArray(target)
|
|
256
|
+
|
|
257
|
+
if (isPrimitive(source)) {
|
|
258
|
+
return source
|
|
259
|
+
} else if (!isMergeableObject(target)) {
|
|
260
|
+
return clone(source)
|
|
261
|
+
} else if (sourceIsArray && targetIsArray) {
|
|
262
|
+
return mergeArray(target, source)
|
|
263
|
+
} else if (sourceIsArray !== targetIsArray) {
|
|
264
|
+
return clone(source)
|
|
265
|
+
} else {
|
|
266
|
+
return mergeObject(target, source)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function _deepmergeAll () {
|
|
271
|
+
switch (arguments.length) {
|
|
272
|
+
case 0:
|
|
273
|
+
return {}
|
|
274
|
+
case 1:
|
|
275
|
+
return clone(arguments[0])
|
|
276
|
+
case 2:
|
|
277
|
+
return _deepmerge(arguments[0], arguments[1])
|
|
278
|
+
}
|
|
279
|
+
let result
|
|
280
|
+
for (let i = 0, il = arguments.length; i < il; ++i) {
|
|
281
|
+
result = _deepmerge(result, arguments[i])
|
|
282
|
+
}
|
|
283
|
+
return result
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return options?.all
|
|
287
|
+
? _deepmergeAll
|
|
288
|
+
: _deepmerge
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
module.exports = deepmergeConstructor
|
|
292
|
+
module.exports["default"] = deepmergeConstructor
|
|
293
|
+
module.exports.deepmerge = deepmergeConstructor
|
|
294
|
+
|
|
295
|
+
Object.defineProperty(module.exports, "isMergeableObject", ({
|
|
296
|
+
get: defaultIsMergeableObjectFactory
|
|
297
|
+
}))
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
},
|
|
301
|
+
"./node_modules/.pnpm/@mercuryworkshop+proxy-relays@1.0.2/node_modules/@mercuryworkshop/proxy-relays/dist/index.mjs"(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
302
|
+
__webpack_require__.r(__webpack_exports__);
|
|
303
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
304
|
+
ConduitCompatibleClient: () => (ConduitCompatibleClient),
|
|
305
|
+
ConduitCompatibleWebSocket: () => (ConduitCompatibleWebSocket),
|
|
306
|
+
ConduitResponse: () => (ConduitResponse)
|
|
307
|
+
});
|
|
308
|
+
const WebSocketFields = {
|
|
309
|
+
CLOSED: WebSocket.CLOSED,
|
|
310
|
+
CONNECTING: WebSocket.CONNECTING,
|
|
311
|
+
OPEN: WebSocket.OPEN,
|
|
312
|
+
};
|
|
313
|
+
class ConduitCompatibleWebSocket extends EventTarget {
|
|
314
|
+
transport;
|
|
315
|
+
url;
|
|
316
|
+
readyState = WebSocketFields.CONNECTING;
|
|
317
|
+
extensions = "";
|
|
318
|
+
protocol = "";
|
|
319
|
+
_data;
|
|
320
|
+
_close;
|
|
321
|
+
constructor(remote, protocols, transport, requestHeaders) {
|
|
322
|
+
super();
|
|
323
|
+
this.transport = transport;
|
|
324
|
+
this.url = remote.toString();
|
|
325
|
+
if (!requestHeaders) {
|
|
326
|
+
requestHeaders = [];
|
|
327
|
+
}
|
|
328
|
+
if (!protocols) {
|
|
329
|
+
protocols = [];
|
|
330
|
+
}
|
|
331
|
+
if (typeof protocols === "string") {
|
|
332
|
+
protocols = [protocols];
|
|
333
|
+
}
|
|
334
|
+
const onopen = (protocol, extensions) => {
|
|
335
|
+
this.protocol = protocol;
|
|
336
|
+
this.extensions = extensions;
|
|
337
|
+
this.readyState = WebSocketFields.OPEN;
|
|
338
|
+
const event = new Event("open");
|
|
339
|
+
this.dispatchEvent(event);
|
|
340
|
+
};
|
|
341
|
+
const onmessage = async (payload) => {
|
|
342
|
+
const event = new MessageEvent("message", { data: payload });
|
|
343
|
+
this.dispatchEvent(event);
|
|
344
|
+
};
|
|
345
|
+
const onclose = (code, reason) => {
|
|
346
|
+
this.readyState = WebSocketFields.CLOSED;
|
|
347
|
+
const event = new CloseEvent("close", { code, reason });
|
|
348
|
+
this.dispatchEvent(event);
|
|
349
|
+
};
|
|
350
|
+
const onerror = () => {
|
|
351
|
+
this.readyState = WebSocketFields.CLOSED;
|
|
352
|
+
const event = new Event("error");
|
|
353
|
+
this.dispatchEvent(event);
|
|
354
|
+
};
|
|
355
|
+
(async () => {
|
|
356
|
+
if (!transport.ready) {
|
|
357
|
+
await transport.init();
|
|
358
|
+
}
|
|
359
|
+
const [_data, _close] = transport.connect(new URL(remote), protocols, requestHeaders, onopen, onmessage, onclose, onerror);
|
|
360
|
+
this._data = _data;
|
|
361
|
+
this._close = _close;
|
|
362
|
+
})();
|
|
363
|
+
}
|
|
364
|
+
async send(data) {
|
|
365
|
+
if (!this.transport.ready) {
|
|
366
|
+
await this.transport.init();
|
|
367
|
+
}
|
|
368
|
+
if (this.readyState === WebSocketFields.CONNECTING) {
|
|
369
|
+
throw new DOMException("Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.");
|
|
370
|
+
}
|
|
371
|
+
// we can't check typeof Uint8Array here directly as it may come from another realm
|
|
372
|
+
if (typeof data === "object" && "buffer" in data && data.buffer) {
|
|
373
|
+
let _data = data;
|
|
374
|
+
// this is neccesary in case the buffer is a slice of a larger array
|
|
375
|
+
// in which case you risk edge cases such as sending an entire wasm memory buffer over the websocket
|
|
376
|
+
data = _data.buffer.slice(_data.byteOffset, _data.byteOffset + _data.byteLength);
|
|
377
|
+
}
|
|
378
|
+
this._data(data);
|
|
379
|
+
}
|
|
380
|
+
close(code, reason) {
|
|
381
|
+
this._close(code, reason);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const validChars = "!#$%&'*+-.0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ^_`abcdefghijklmnopqrstuvwxyz|~";
|
|
386
|
+
function validProtocol(protocol) {
|
|
387
|
+
for (let i = 0; i < protocol.length; i++) {
|
|
388
|
+
const char = protocol[i];
|
|
389
|
+
if (!validChars.includes(char)) {
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return true;
|
|
394
|
+
}
|
|
395
|
+
const wsProtocols = ["ws:", "wss:"];
|
|
396
|
+
const statusEmpty = [101, 204, 205, 304];
|
|
397
|
+
const statusRedirect = [301, 302, 303, 307, 308];
|
|
398
|
+
const nativeFetch = fetch;
|
|
399
|
+
function headersObjectToEntries(headers) {
|
|
400
|
+
return [...headers];
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* A Response with additional properties.
|
|
404
|
+
*/
|
|
405
|
+
class ConduitResponse extends Response {
|
|
406
|
+
url;
|
|
407
|
+
rawHeaders;
|
|
408
|
+
redirected = false;
|
|
409
|
+
static fromTransferrableResponse(resp, url) {
|
|
410
|
+
const response = new ConduitResponse(statusEmpty.includes(resp.status) ? undefined : resp.body, {
|
|
411
|
+
headers: new Headers(resp.headers),
|
|
412
|
+
status: resp.status,
|
|
413
|
+
statusText: resp.statusText,
|
|
414
|
+
});
|
|
415
|
+
response.url = url;
|
|
416
|
+
response.redirected =
|
|
417
|
+
resp.status >= 300 &&
|
|
418
|
+
resp.status < 400 &&
|
|
419
|
+
resp.headers["location"] !== undefined;
|
|
420
|
+
response.rawHeaders = resp.headers;
|
|
421
|
+
return response;
|
|
422
|
+
}
|
|
423
|
+
static fromNativeResponse(resp) {
|
|
424
|
+
let body = statusEmpty.includes(resp.status) ? undefined : resp.body;
|
|
425
|
+
const response = new ConduitResponse(body, {
|
|
426
|
+
headers: resp.headers,
|
|
427
|
+
status: resp.status,
|
|
428
|
+
statusText: resp.statusText,
|
|
429
|
+
});
|
|
430
|
+
response.url = resp.url;
|
|
431
|
+
response.rawHeaders = headersObjectToEntries(resp.headers);
|
|
432
|
+
response.redirected = resp.redirected;
|
|
433
|
+
return response;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
const defaultMaxRedirects = 20;
|
|
437
|
+
class ConduitCompatibleClient {
|
|
438
|
+
transport;
|
|
439
|
+
/**
|
|
440
|
+
* Create a ConduitCompatibleClient using the provided transport. Calls to fetch and connect will wait for an implementation to be ready.
|
|
441
|
+
*/
|
|
442
|
+
constructor(transport) {
|
|
443
|
+
this.transport = transport;
|
|
444
|
+
}
|
|
445
|
+
createWebSocket(remote, protocols = [], requestHeaders) {
|
|
446
|
+
try {
|
|
447
|
+
remote = new URL(remote);
|
|
448
|
+
}
|
|
449
|
+
catch (err) {
|
|
450
|
+
throw new DOMException(`Faiiled to construct 'WebSocket': The URL '${remote}' is invalid.`);
|
|
451
|
+
}
|
|
452
|
+
if (!wsProtocols.includes(remote.protocol))
|
|
453
|
+
throw new DOMException(`Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${remote.protocol}' is not allowed.`);
|
|
454
|
+
if (!Array.isArray(protocols))
|
|
455
|
+
protocols = [protocols];
|
|
456
|
+
protocols = protocols.map(String);
|
|
457
|
+
for (const proto of protocols)
|
|
458
|
+
if (!validProtocol(proto))
|
|
459
|
+
throw new DOMException(`Failed to construct 'WebSocket': The subprotocol '${proto}' is invalid.`);
|
|
460
|
+
requestHeaders = requestHeaders || [];
|
|
461
|
+
const socket = new ConduitCompatibleWebSocket(remote, protocols, this.transport, requestHeaders);
|
|
462
|
+
return socket;
|
|
463
|
+
}
|
|
464
|
+
async fetch(url, init) {
|
|
465
|
+
if (!this.transport.ready) {
|
|
466
|
+
await this.transport.init();
|
|
467
|
+
}
|
|
468
|
+
let maxRedirects = init?.maxRedirects || defaultMaxRedirects;
|
|
469
|
+
const body = init?.body;
|
|
470
|
+
const headers = init?.headers || [];
|
|
471
|
+
const method = init?.method || "GET";
|
|
472
|
+
const redirect = init?.redirect || "follow";
|
|
473
|
+
let urlO = new URL(url);
|
|
474
|
+
if (urlO.protocol.startsWith("blob:")) {
|
|
475
|
+
const response = await nativeFetch(urlO);
|
|
476
|
+
return ConduitResponse.fromNativeResponse(response);
|
|
477
|
+
}
|
|
478
|
+
for (let i = 0;; i++) {
|
|
479
|
+
const resp = await this.transport.request(urlO, method, body, headers, undefined);
|
|
480
|
+
const conduitresponse = ConduitResponse.fromTransferrableResponse(resp, urlO.toString());
|
|
481
|
+
if (statusRedirect.includes(conduitresponse.status)) {
|
|
482
|
+
switch (redirect) {
|
|
483
|
+
case "follow": {
|
|
484
|
+
const location = conduitresponse.headers.get("location");
|
|
485
|
+
if (maxRedirects > i && location !== null) {
|
|
486
|
+
urlO = new URL(location, urlO);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
else
|
|
490
|
+
throw new TypeError("Failed to fetch");
|
|
491
|
+
}
|
|
492
|
+
case "error":
|
|
493
|
+
throw new TypeError("Failed to fetch");
|
|
494
|
+
case "manual":
|
|
495
|
+
return conduitresponse;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
return conduitresponse;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
//# sourceMappingURL=index.mjs.map
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
},
|
|
510
|
+
"./packages/core/dist/corridor-external.mjs"(__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
511
|
+
__webpack_require__.r(__webpack_exports__);
|
|
512
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
513
|
+
ConduitResponse: () => (ConduitResponse),
|
|
514
|
+
CookieJar: () => (CookieJar),
|
|
515
|
+
IncrementalHtmlRewriter: () => (IncrementalHtmlRewriter),
|
|
516
|
+
Plugin: () => (Plugin),
|
|
517
|
+
CORRIDORCLIENT: () => (CORRIDORCLIENT),
|
|
518
|
+
CORRIDORCLIENTNAME: () => (CORRIDORCLIENTNAME),
|
|
519
|
+
CorridorClient: () => (CorridorClient),
|
|
520
|
+
CorridorFetchHandler: () => (CorridorFetchHandler),
|
|
521
|
+
CorridorFetchTrackedClient: () => (CorridorFetchTrackedClient),
|
|
522
|
+
CorridorHeaders: () => (CorridorHeaders),
|
|
523
|
+
Tap: () => (Tap),
|
|
524
|
+
createLocationProxy: () => (createLocationProxy),
|
|
525
|
+
defaultConfig: () => (defaultConfig),
|
|
526
|
+
defaultConfigDev: () => (defaultConfigDev),
|
|
527
|
+
flagEnabled: () => (flagEnabled),
|
|
528
|
+
getOwnPropertyDescriptorHandler: () => (getOwnPropertyDescriptorHandler),
|
|
529
|
+
getRewriter: () => (getRewriter),
|
|
530
|
+
getScriptBlockTypeString: () => (getScriptBlockTypeString),
|
|
531
|
+
htmlRules: () => (htmlRules),
|
|
532
|
+
isArchiveMimeType: () => (isArchiveMimeType),
|
|
533
|
+
isAudioOrVideoMimeType: () => (isAudioOrVideoMimeType),
|
|
534
|
+
isFontMimeType: () => (isFontMimeType),
|
|
535
|
+
isHtmlMimeType: () => (isHtmlMimeType),
|
|
536
|
+
isImageMimeType: () => (isImageMimeType),
|
|
537
|
+
isInlineDisplayableMimeType: () => (isInlineDisplayableMimeType),
|
|
538
|
+
isJavascriptMimeType: () => (isJavascriptMimeType),
|
|
539
|
+
isJavascriptMimeTypeEssenceMatch: () => (isJavascriptMimeTypeEssenceMatch),
|
|
540
|
+
isModuleScriptType: () => (isModuleScriptType),
|
|
541
|
+
isScriptType: () => (isScriptType),
|
|
542
|
+
isScriptableMimeType: () => (isScriptableMimeType),
|
|
543
|
+
isXmlMimeType: () => (isXmlMimeType),
|
|
544
|
+
isZipBasedMimeType: () => (isZipBasedMimeType),
|
|
545
|
+
isdedicated: () => (isdedicated),
|
|
546
|
+
isshared: () => (isshared),
|
|
547
|
+
issw: () => (issw),
|
|
548
|
+
iswindow: () => (iswindow),
|
|
549
|
+
isworker: () => (isworker),
|
|
550
|
+
parseMimeType: () => (parseMimeType),
|
|
551
|
+
rewriteBlob: () => (rewriteBlob),
|
|
552
|
+
rewriteCss: () => (rewriteCss),
|
|
553
|
+
rewriteHtml: () => (rewriteHtml),
|
|
554
|
+
rewriteJs: () => (rewriteJs),
|
|
555
|
+
rewriteJsInner: () => (rewriteJsInner),
|
|
556
|
+
rewriteSrcset: () => (rewriteSrcset),
|
|
557
|
+
rewriteUrl: () => (rewriteUrl),
|
|
558
|
+
rewriteWorkers: () => (rewriteWorkers),
|
|
559
|
+
setWasm: () => (setWasm),
|
|
560
|
+
unrewriteBlob: () => (unrewriteBlob),
|
|
561
|
+
unrewriteCss: () => (unrewriteCss),
|
|
562
|
+
unrewriteHtml: () => (unrewriteHtml),
|
|
563
|
+
unrewriteUrl: () => (unrewriteUrl),
|
|
564
|
+
versionInfo: () => (versionInfo)
|
|
565
|
+
});
|
|
566
|
+
// AUTO-GENERATED by ExternalStubPlugin — do not edit.
|
|
567
|
+
// Re-exports of globalThis.$corridor (set by the IIFE bundle).
|
|
568
|
+
const __external = /** @type {any} */ (globalThis).$corridor;
|
|
569
|
+
const {
|
|
570
|
+
ConduitResponse,
|
|
571
|
+
CookieJar,
|
|
572
|
+
IncrementalHtmlRewriter,
|
|
573
|
+
Plugin,
|
|
574
|
+
CORRIDORCLIENT,
|
|
575
|
+
CORRIDORCLIENTNAME,
|
|
576
|
+
CorridorClient,
|
|
577
|
+
CorridorFetchHandler,
|
|
578
|
+
CorridorFetchTrackedClient,
|
|
579
|
+
CorridorHeaders,
|
|
580
|
+
Tap,
|
|
581
|
+
createLocationProxy,
|
|
582
|
+
defaultConfig,
|
|
583
|
+
defaultConfigDev,
|
|
584
|
+
flagEnabled,
|
|
585
|
+
getOwnPropertyDescriptorHandler,
|
|
586
|
+
getRewriter,
|
|
587
|
+
getScriptBlockTypeString,
|
|
588
|
+
htmlRules,
|
|
589
|
+
isArchiveMimeType,
|
|
590
|
+
isAudioOrVideoMimeType,
|
|
591
|
+
isFontMimeType,
|
|
592
|
+
isHtmlMimeType,
|
|
593
|
+
isImageMimeType,
|
|
594
|
+
isInlineDisplayableMimeType,
|
|
595
|
+
isJavascriptMimeType,
|
|
596
|
+
isJavascriptMimeTypeEssenceMatch,
|
|
597
|
+
isModuleScriptType,
|
|
598
|
+
isScriptType,
|
|
599
|
+
isScriptableMimeType,
|
|
600
|
+
isXmlMimeType,
|
|
601
|
+
isZipBasedMimeType,
|
|
602
|
+
isdedicated,
|
|
603
|
+
isshared,
|
|
604
|
+
issw,
|
|
605
|
+
iswindow,
|
|
606
|
+
isworker,
|
|
607
|
+
parseMimeType,
|
|
608
|
+
rewriteBlob,
|
|
609
|
+
rewriteCss,
|
|
610
|
+
rewriteHtml,
|
|
611
|
+
rewriteJs,
|
|
612
|
+
rewriteJsInner,
|
|
613
|
+
rewriteSrcset,
|
|
614
|
+
rewriteUrl,
|
|
615
|
+
rewriteWorkers,
|
|
616
|
+
setWasm,
|
|
617
|
+
unrewriteBlob,
|
|
618
|
+
unrewriteCss,
|
|
619
|
+
unrewriteHtml,
|
|
620
|
+
unrewriteUrl,
|
|
621
|
+
versionInfo,
|
|
622
|
+
} = __external;
|
|
623
|
+
|
|
624
|
+
|
|
625
|
+
},
|
|
626
|
+
|
|
627
|
+
});
|
|
628
|
+
// The module cache
|
|
629
|
+
var __webpack_module_cache__ = {};
|
|
630
|
+
|
|
631
|
+
// The require function
|
|
632
|
+
function __webpack_require__(moduleId) {
|
|
633
|
+
|
|
634
|
+
// Check if module is in cache
|
|
635
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
636
|
+
if (cachedModule !== undefined) {
|
|
637
|
+
return cachedModule.exports;
|
|
638
|
+
}
|
|
639
|
+
// Create a new module (and put it into the cache)
|
|
640
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
641
|
+
exports: {}
|
|
642
|
+
});
|
|
643
|
+
// Execute the module function
|
|
644
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
645
|
+
|
|
646
|
+
// Return the exports of the module
|
|
647
|
+
return module.exports;
|
|
648
|
+
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// webpack/runtime/compat_get_default_export
|
|
652
|
+
(() => {
|
|
653
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
654
|
+
__webpack_require__.n = (module) => {
|
|
655
|
+
var getter = module && module.__esModule ?
|
|
656
|
+
() => (module['default']) :
|
|
657
|
+
() => (module);
|
|
658
|
+
__webpack_require__.d(getter, { a: getter });
|
|
659
|
+
return getter;
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
})();
|
|
663
|
+
// webpack/runtime/define_property_getters
|
|
664
|
+
(() => {
|
|
665
|
+
__webpack_require__.d = (exports, definition) => {
|
|
666
|
+
for(var key in definition) {
|
|
667
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
668
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
};
|
|
672
|
+
})();
|
|
673
|
+
// webpack/runtime/has_own_property
|
|
674
|
+
(() => {
|
|
675
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
676
|
+
})();
|
|
677
|
+
// webpack/runtime/make_namespace_object
|
|
678
|
+
(() => {
|
|
679
|
+
// define __esModule on exports
|
|
680
|
+
__webpack_require__.r = (exports) => {
|
|
681
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
682
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
683
|
+
}
|
|
684
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
685
|
+
};
|
|
686
|
+
})();
|
|
687
|
+
var __webpack_exports__ = {};
|
|
688
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
689
|
+
(() => {
|
|
690
|
+
__webpack_require__.r(__webpack_exports__);
|
|
691
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
692
|
+
Controller: () => (Controller),
|
|
693
|
+
Frame: () => (Frame),
|
|
694
|
+
ManagedPlugin: () => (ManagedPlugin),
|
|
695
|
+
VERSION: () => (/* reexport safe */ _version__rspack_import_5.VERSION),
|
|
696
|
+
assertRuntimeCorridorVersion: () => (/* reexport safe */ _version__rspack_import_5.assertRuntimeCorridorVersion),
|
|
697
|
+
config: () => (config)
|
|
698
|
+
});
|
|
699
|
+
/* import */ var _mercuryworkshop_rpc__rspack_import_0 = __webpack_require__("./packages/rpc/index.ts");
|
|
700
|
+
/* import */ var _mercuryworkshop_proxy_relays__rspack_import_1 = __webpack_require__("./node_modules/.pnpm/@mercuryworkshop+proxy-relays@1.0.2/node_modules/@mercuryworkshop/proxy-relays/dist/index.mjs");
|
|
701
|
+
/* import */ var _fastify_deepmerge__rspack_import_2 = __webpack_require__("./node_modules/.pnpm/@fastify+deepmerge@3.2.1/node_modules/@fastify/deepmerge/index.js");
|
|
702
|
+
/* import */ var _fastify_deepmerge__rspack_import_2_default = /*#__PURE__*/__webpack_require__.n(_fastify_deepmerge__rspack_import_2);
|
|
703
|
+
/* import */ var _mercuryworkshop_corridor__rspack_import_3 = __webpack_require__("./packages/core/dist/corridor-external.mjs");
|
|
704
|
+
/* import */ var _symbols__rspack_import_4 = __webpack_require__("./packages/controller/src/symbols.ts");
|
|
705
|
+
/* import */ var _version__rspack_import_5 = __webpack_require__("./packages/controller/src/version.ts");
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
|
|
714
|
+
const config = {
|
|
715
|
+
prefix: "/~/sj/",
|
|
716
|
+
corridorPath: "/corridor/corridor.js",
|
|
717
|
+
injectPath: "/controller/controller.inject.js",
|
|
718
|
+
wasmPath: "/corridor/corridor.wasm",
|
|
719
|
+
virtualWasmPath: "corridor.wasm.js",
|
|
720
|
+
codec: {
|
|
721
|
+
encode: (url)=>{
|
|
722
|
+
if (!url) return url;
|
|
723
|
+
return encodeURIComponent(url);
|
|
724
|
+
},
|
|
725
|
+
decode: (url)=>{
|
|
726
|
+
if (!url) return url;
|
|
727
|
+
return decodeURIComponent(url);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
const corridorConfig = {
|
|
732
|
+
flags: {
|
|
733
|
+
..._mercuryworkshop_corridor__rspack_import_3.defaultConfig.flags,
|
|
734
|
+
allowFailedIntercepts: true
|
|
735
|
+
},
|
|
736
|
+
maskedfiles: [
|
|
737
|
+
"inject.js",
|
|
738
|
+
"corridor.wasm.js"
|
|
739
|
+
]
|
|
740
|
+
};
|
|
741
|
+
class ManagedPlugin extends _mercuryworkshop_corridor__rspack_import_3.Plugin {
|
|
742
|
+
frame = null;
|
|
743
|
+
dependencies = [];
|
|
744
|
+
constructor(name, dependencies){
|
|
745
|
+
super(name);
|
|
746
|
+
this.dependencies = dependencies;
|
|
747
|
+
}
|
|
748
|
+
install(frame) {
|
|
749
|
+
this.frame = frame;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
const COOKIE_DB_NAME = "__corridor_controller";
|
|
753
|
+
const COOKIE_STORE_NAME = "state";
|
|
754
|
+
const COOKIE_STATE_KEY = "cookies";
|
|
755
|
+
const BROADCASTCHANNEL_NAME = "__corridor_controller_channel";
|
|
756
|
+
let cookieDbPromise = null;
|
|
757
|
+
function parsePersistedCookieState(value) {
|
|
758
|
+
if (typeof value !== "object" || value === null || typeof value.updatedAt !== "number" || !Number.isFinite(value.updatedAt) || typeof value.cookies !== "string") {
|
|
759
|
+
return null;
|
|
760
|
+
}
|
|
761
|
+
return value;
|
|
762
|
+
}
|
|
763
|
+
function requestToPromise(request) {
|
|
764
|
+
return new Promise((resolve, reject)=>{
|
|
765
|
+
request.onsuccess = ()=>resolve(request.result);
|
|
766
|
+
request.onerror = ()=>reject(request.error ?? new Error("IndexedDB request failed"));
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
function transactionToPromise(transaction) {
|
|
770
|
+
return new Promise((resolve, reject)=>{
|
|
771
|
+
transaction.oncomplete = ()=>resolve();
|
|
772
|
+
transaction.onabort = ()=>reject(transaction.error ?? new Error("IndexedDB transaction aborted"));
|
|
773
|
+
transaction.onerror = ()=>reject(transaction.error ?? new Error("IndexedDB transaction failed"));
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function openCookieDatabase() {
|
|
777
|
+
if (cookieDbPromise) {
|
|
778
|
+
return cookieDbPromise;
|
|
779
|
+
}
|
|
780
|
+
cookieDbPromise = new Promise((resolve, reject)=>{
|
|
781
|
+
const request = indexedDB.open(COOKIE_DB_NAME, 1);
|
|
782
|
+
request.onupgradeneeded = ()=>{
|
|
783
|
+
const db = request.result;
|
|
784
|
+
if (!db.objectStoreNames.contains(COOKIE_STORE_NAME)) {
|
|
785
|
+
db.createObjectStore(COOKIE_STORE_NAME);
|
|
786
|
+
}
|
|
787
|
+
};
|
|
788
|
+
request.onsuccess = ()=>resolve(request.result);
|
|
789
|
+
request.onerror = ()=>reject(request.error ?? new Error("Failed to open cookie database"));
|
|
790
|
+
});
|
|
791
|
+
return cookieDbPromise;
|
|
792
|
+
}
|
|
793
|
+
async function readCookieState() {
|
|
794
|
+
try {
|
|
795
|
+
const db = await openCookieDatabase();
|
|
796
|
+
const transaction = db.transaction(COOKIE_STORE_NAME, "readonly");
|
|
797
|
+
const store = transaction.objectStore(COOKIE_STORE_NAME);
|
|
798
|
+
const value = await requestToPromise(store.get(COOKIE_STATE_KEY));
|
|
799
|
+
await transactionToPromise(transaction);
|
|
800
|
+
return parsePersistedCookieState(value);
|
|
801
|
+
} catch (error) {
|
|
802
|
+
console.error("Failed to read persisted controller cookies:", error);
|
|
803
|
+
return null;
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
async function writeCookieState(cookies, currentUpdatedAt) {
|
|
807
|
+
try {
|
|
808
|
+
const db = await openCookieDatabase();
|
|
809
|
+
const transaction = db.transaction(COOKIE_STORE_NAME, "readwrite");
|
|
810
|
+
const store = transaction.objectStore(COOKIE_STORE_NAME);
|
|
811
|
+
const existing = parsePersistedCookieState(await requestToPromise(store.get(COOKIE_STATE_KEY)));
|
|
812
|
+
const updatedAt = Math.max(Date.now(), currentUpdatedAt + 1, (existing?.updatedAt ?? 0) + 1);
|
|
813
|
+
const state = {
|
|
814
|
+
updatedAt,
|
|
815
|
+
cookies
|
|
816
|
+
};
|
|
817
|
+
store.put(state, COOKIE_STATE_KEY);
|
|
818
|
+
await transactionToPromise(transaction);
|
|
819
|
+
return updatedAt;
|
|
820
|
+
} catch (error) {
|
|
821
|
+
console.error("Failed to persist controller cookies:", error);
|
|
822
|
+
return currentUpdatedAt;
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
function makeId() {
|
|
826
|
+
return Math.random().toString(36).substring(2, 10);
|
|
827
|
+
}
|
|
828
|
+
const deepMerge = (0,_fastify_deepmerge__rspack_import_2.deepmerge)();
|
|
829
|
+
class Controller {
|
|
830
|
+
init;
|
|
831
|
+
id;
|
|
832
|
+
config;
|
|
833
|
+
corridorConfig;
|
|
834
|
+
prefix;
|
|
835
|
+
cookieJar = new _mercuryworkshop_corridor__rspack_import_3.CookieJar();
|
|
836
|
+
frames = [];
|
|
837
|
+
serviceWorkerController;
|
|
838
|
+
guardServiceWorkerRevive = true;
|
|
839
|
+
ready;
|
|
840
|
+
readyResolve;
|
|
841
|
+
isReady = false;
|
|
842
|
+
rpc;
|
|
843
|
+
port = null;
|
|
844
|
+
transport;
|
|
845
|
+
cookieUpdatedAt = 0;
|
|
846
|
+
cookieSyncPromise = null;
|
|
847
|
+
cookieSyncDirty = true;
|
|
848
|
+
cookieSyncChannel = new BroadcastChannel(BROADCASTCHANNEL_NAME);
|
|
849
|
+
wasmAlreadyFetched = false;
|
|
850
|
+
wasmPayload = null;
|
|
851
|
+
onTabChannelMessage = (e)=>{
|
|
852
|
+
this.rpc.recieve(e.data);
|
|
853
|
+
};
|
|
854
|
+
onCookieSyncMessage = (event)=>{
|
|
855
|
+
const updatedAt = typeof event.data === "object" && event.data !== null ? event.data.updatedAt : undefined;
|
|
856
|
+
if (typeof updatedAt !== "number" || updatedAt <= this.cookieUpdatedAt) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
this.cookieSyncDirty = true;
|
|
860
|
+
void this.loadSavedCookies();
|
|
861
|
+
};
|
|
862
|
+
async loadCorridorWasm() {
|
|
863
|
+
if (this.wasmAlreadyFetched) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
const resp = await fetch(this.config.wasmPath);
|
|
867
|
+
(0,_mercuryworkshop_corridor__rspack_import_3.setWasm)(await resp.arrayBuffer());
|
|
868
|
+
this.wasmAlreadyFetched = true;
|
|
869
|
+
}
|
|
870
|
+
methods = {
|
|
871
|
+
ready: async ()=>{
|
|
872
|
+
this.readyResolve();
|
|
873
|
+
setTimeout(()=>{
|
|
874
|
+
this.guardServiceWorkerRevive = false;
|
|
875
|
+
}, 5000);
|
|
876
|
+
},
|
|
877
|
+
request: async (data)=>{
|
|
878
|
+
const path = new URL(data.rawUrl).pathname;
|
|
879
|
+
const frame = this.frames.find((f)=>path.startsWith(f.prefix));
|
|
880
|
+
if (!frame) throw new Error("No frame found for request");
|
|
881
|
+
try {
|
|
882
|
+
// doesn't actually *load* every request, but hold up requests until the promise finishes
|
|
883
|
+
await this.loadSavedCookies();
|
|
884
|
+
if (path === frame.prefix + this.config.virtualWasmPath) {
|
|
885
|
+
if (!this.wasmPayload) {
|
|
886
|
+
const resp = await fetch(this.config.wasmPath);
|
|
887
|
+
const buf = await resp.arrayBuffer();
|
|
888
|
+
const b64 = btoa(new Uint8Array(buf).reduce((data, byte)=>(data.push(String.fromCharCode(byte)), data), []).join(""));
|
|
889
|
+
this.wasmPayload = `self.WASM = '${b64}';`;
|
|
890
|
+
}
|
|
891
|
+
return [
|
|
892
|
+
{
|
|
893
|
+
body: this.wasmPayload,
|
|
894
|
+
status: 200,
|
|
895
|
+
statusText: "OK",
|
|
896
|
+
headers: [
|
|
897
|
+
[
|
|
898
|
+
"Content-Type",
|
|
899
|
+
"application/javascript"
|
|
900
|
+
]
|
|
901
|
+
]
|
|
902
|
+
},
|
|
903
|
+
[]
|
|
904
|
+
];
|
|
905
|
+
}
|
|
906
|
+
const sjheaders = _mercuryworkshop_corridor__rspack_import_3.CorridorHeaders.fromRawHeaders(data.initialHeaders);
|
|
907
|
+
const fetchresponse = await frame.fetchHandler.handleFetch({
|
|
908
|
+
initialHeaders: sjheaders,
|
|
909
|
+
rawClientUrl: data.rawClientUrl ? new URL(data.rawClientUrl) : undefined,
|
|
910
|
+
rawUrl: new URL(data.rawUrl),
|
|
911
|
+
rawReferrer: data.rawReferrer,
|
|
912
|
+
rawDestination: data.destination,
|
|
913
|
+
method: data.method,
|
|
914
|
+
mode: data.mode,
|
|
915
|
+
referrer: data.referrer,
|
|
916
|
+
body: data.body,
|
|
917
|
+
cache: data.cache,
|
|
918
|
+
clientId: data.clientId
|
|
919
|
+
});
|
|
920
|
+
return [
|
|
921
|
+
{
|
|
922
|
+
body: fetchresponse.body,
|
|
923
|
+
status: fetchresponse.status,
|
|
924
|
+
statusText: fetchresponse.statusText,
|
|
925
|
+
headers: fetchresponse.headers.toRawHeaders()
|
|
926
|
+
},
|
|
927
|
+
fetchresponse.body instanceof ReadableStream || fetchresponse.body instanceof ArrayBuffer ? [
|
|
928
|
+
fetchresponse.body
|
|
929
|
+
] : []
|
|
930
|
+
];
|
|
931
|
+
} catch (e) {
|
|
932
|
+
const reqcontext = {
|
|
933
|
+
rawrequest: data,
|
|
934
|
+
error: e
|
|
935
|
+
};
|
|
936
|
+
const reqprops = {
|
|
937
|
+
setResponse: undefined,
|
|
938
|
+
suppressError: false
|
|
939
|
+
};
|
|
940
|
+
await _mercuryworkshop_corridor__rspack_import_3.Tap.dispatch(frame.hooks.error.request, reqcontext, reqprops);
|
|
941
|
+
if (!reqprops.suppressError) {
|
|
942
|
+
console.error("Error in controller request handler:", e);
|
|
943
|
+
}
|
|
944
|
+
if (reqprops.setResponse) {
|
|
945
|
+
return [
|
|
946
|
+
reqprops.setResponse,
|
|
947
|
+
[]
|
|
948
|
+
];
|
|
949
|
+
}
|
|
950
|
+
throw e;
|
|
951
|
+
}
|
|
952
|
+
},
|
|
953
|
+
initRemoteTransport: async (port)=>{
|
|
954
|
+
const rpc = new _mercuryworkshop_rpc__rspack_import_0.RpcHelper({
|
|
955
|
+
request: async ({ remote, method, body, headers })=>{
|
|
956
|
+
const response = await this.transport.request(new URL(remote), method, body, headers, undefined);
|
|
957
|
+
return [
|
|
958
|
+
response,
|
|
959
|
+
[
|
|
960
|
+
response.body
|
|
961
|
+
]
|
|
962
|
+
];
|
|
963
|
+
},
|
|
964
|
+
sendSetCookie: async ({ cookies, options })=>{
|
|
965
|
+
await this.loadSavedCookies(true);
|
|
966
|
+
if (options?.clear) {
|
|
967
|
+
this.cookieJar.clear();
|
|
968
|
+
}
|
|
969
|
+
this.applyCookieSyncEntries(cookies);
|
|
970
|
+
await this.persistCookies();
|
|
971
|
+
await this.propagateCookieSync(cookies, options);
|
|
972
|
+
},
|
|
973
|
+
connect: async ({ url, protocols, requestHeaders, port })=>{
|
|
974
|
+
let resolve;
|
|
975
|
+
const promise = new Promise((res)=>resolve = res);
|
|
976
|
+
const [send, close] = this.transport.connect(new URL(url), protocols, requestHeaders, (protocol, extensions)=>{
|
|
977
|
+
resolve({
|
|
978
|
+
result: "success",
|
|
979
|
+
protocol: protocol,
|
|
980
|
+
extensions: extensions
|
|
981
|
+
});
|
|
982
|
+
}, (data)=>{
|
|
983
|
+
port.postMessage({
|
|
984
|
+
type: "data",
|
|
985
|
+
data: data
|
|
986
|
+
}, data instanceof ArrayBuffer ? [
|
|
987
|
+
data
|
|
988
|
+
] : []);
|
|
989
|
+
}, (close, reason)=>{
|
|
990
|
+
port.postMessage({
|
|
991
|
+
type: "close",
|
|
992
|
+
code: close,
|
|
993
|
+
reason: reason
|
|
994
|
+
});
|
|
995
|
+
}, (error)=>{
|
|
996
|
+
resolve({
|
|
997
|
+
result: "failure",
|
|
998
|
+
error: error
|
|
999
|
+
});
|
|
1000
|
+
});
|
|
1001
|
+
port.onmessageerror = (ev)=>{
|
|
1002
|
+
console.error("Transport port messageerror (this should never happen!)", ev);
|
|
1003
|
+
};
|
|
1004
|
+
port.onmessage = ({ data })=>{
|
|
1005
|
+
if (data.type === "data") {
|
|
1006
|
+
send(data.data);
|
|
1007
|
+
} else if (data.type === "close") {
|
|
1008
|
+
close(data.code, data.reason);
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
return [
|
|
1012
|
+
await promise,
|
|
1013
|
+
[]
|
|
1014
|
+
];
|
|
1015
|
+
}
|
|
1016
|
+
}, "transport", (data, transfer)=>port.postMessage(data, transfer));
|
|
1017
|
+
port.onmessageerror = (ev)=>{
|
|
1018
|
+
console.error("Transport port messageerror (this should never happen!)", ev);
|
|
1019
|
+
};
|
|
1020
|
+
port.onmessage = (e)=>{
|
|
1021
|
+
rpc.recieve(e.data);
|
|
1022
|
+
};
|
|
1023
|
+
rpc.call("ready", undefined, []);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
constructor(init){
|
|
1027
|
+
this.init = init;
|
|
1028
|
+
(0,_version__rspack_import_5.assertRuntimeCorridorVersion)();
|
|
1029
|
+
this.id = makeId();
|
|
1030
|
+
this.config = deepMerge(config, init.config || {});
|
|
1031
|
+
this.corridorConfig = deepMerge(corridorConfig, _mercuryworkshop_corridor__rspack_import_3.defaultConfig);
|
|
1032
|
+
this.corridorConfig = deepMerge(this.corridorConfig, init.corridorConfig || {});
|
|
1033
|
+
this.prefix = this.config.prefix + this.id + "/";
|
|
1034
|
+
this.serviceWorkerController = init.serviceworker;
|
|
1035
|
+
this.ready = Promise.all([
|
|
1036
|
+
new Promise((resolve)=>{
|
|
1037
|
+
this.readyResolve = resolve;
|
|
1038
|
+
}),
|
|
1039
|
+
this.loadCorridorWasm(),
|
|
1040
|
+
this.loadSavedCookies(true)
|
|
1041
|
+
]).then(()=>undefined);
|
|
1042
|
+
this.rpc = new _mercuryworkshop_rpc__rspack_import_0.RpcHelper(this.methods, "tabchannel-" + this.id, (data, transfer)=>{
|
|
1043
|
+
if (!this.port) {
|
|
1044
|
+
throw new Error("Port not found");
|
|
1045
|
+
}
|
|
1046
|
+
this.port.postMessage(data, transfer);
|
|
1047
|
+
});
|
|
1048
|
+
this.transport = init.transport;
|
|
1049
|
+
this.cookieSyncChannel.addEventListener("message", this.onCookieSyncMessage);
|
|
1050
|
+
this.setupMessagePort();
|
|
1051
|
+
// copium: a new service worker (a deploy, or the browser restarting
|
|
1052
|
+
// it) takes over with an empty tab registry. Follow whichever worker
|
|
1053
|
+
// controls the page now and register with *that* one — otherwise the
|
|
1054
|
+
// handshake keeps going to the retired worker and every proxied load
|
|
1055
|
+
// fails with "no proxy session for this tab" until a refresh.
|
|
1056
|
+
navigator.serviceWorker.addEventListener("controllerchange", ()=>{
|
|
1057
|
+
if (navigator.serviceWorker.controller) {
|
|
1058
|
+
this.serviceWorkerController = navigator.serviceWorker.controller;
|
|
1059
|
+
this.setupMessagePort();
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
navigator.serviceWorker.addEventListener("message", (e)=>{
|
|
1063
|
+
if (e.data?.$controller$setCookie && typeof e.data.$controller$setCookie === "object") {
|
|
1064
|
+
const payload = e.data.$controller$setCookie;
|
|
1065
|
+
if (payload.options?.clear) {
|
|
1066
|
+
this.cookieJar.clear();
|
|
1067
|
+
}
|
|
1068
|
+
this.applyCookieSyncEntries(payload.cookies);
|
|
1069
|
+
if (typeof payload.id === "string") {
|
|
1070
|
+
this.serviceWorkerController.postMessage({
|
|
1071
|
+
$sw$setCookieDone: {
|
|
1072
|
+
id: payload.id
|
|
1073
|
+
}
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
if (e.data.$controller$swrevive) {
|
|
1079
|
+
// if we just spawned the service worker, it will send this even though it's not actually dead
|
|
1080
|
+
// TODO: pretty jank, fix at some point
|
|
1081
|
+
if (this.guardServiceWorkerRevive) {
|
|
1082
|
+
return;
|
|
1083
|
+
}
|
|
1084
|
+
this.setupMessagePort();
|
|
1085
|
+
}
|
|
1086
|
+
});
|
|
1087
|
+
}
|
|
1088
|
+
setupMessagePort() {
|
|
1089
|
+
if (this.port) {
|
|
1090
|
+
this.port.removeEventListener("message", this.onTabChannelMessage);
|
|
1091
|
+
try {
|
|
1092
|
+
this.port.close();
|
|
1093
|
+
} catch {
|
|
1094
|
+
// ignore
|
|
1095
|
+
}
|
|
1096
|
+
this.port = null;
|
|
1097
|
+
}
|
|
1098
|
+
// copium: always the worker controlling the page right now (see the
|
|
1099
|
+
// controllerchange listener in the constructor).
|
|
1100
|
+
if (navigator.serviceWorker.controller) {
|
|
1101
|
+
this.serviceWorkerController = navigator.serviceWorker.controller;
|
|
1102
|
+
}
|
|
1103
|
+
const channel = new MessageChannel();
|
|
1104
|
+
this.port = channel.port1;
|
|
1105
|
+
this.port.addEventListener("message", this.onTabChannelMessage);
|
|
1106
|
+
this.port.start();
|
|
1107
|
+
this.serviceWorkerController.postMessage({
|
|
1108
|
+
$controller$init: {
|
|
1109
|
+
prefix: this.prefix,
|
|
1110
|
+
id: this.id
|
|
1111
|
+
}
|
|
1112
|
+
}, [
|
|
1113
|
+
channel.port2
|
|
1114
|
+
]);
|
|
1115
|
+
}
|
|
1116
|
+
// TODO: should this be a method on the cookie jar?
|
|
1117
|
+
applyCookieSyncEntries(cookies) {
|
|
1118
|
+
if (!Array.isArray(cookies)) {
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
for (const entry of cookies){
|
|
1122
|
+
if (typeof entry?.url !== "string" || typeof entry.cookie !== "string") {
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
this.cookieJar.setCookies(entry.cookie, new URL(entry.url));
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
async propagateCookieSync(cookies, options = {}) {
|
|
1129
|
+
if (!this.port) {
|
|
1130
|
+
return;
|
|
1131
|
+
}
|
|
1132
|
+
await this.rpc.call("sendSetCookie", {
|
|
1133
|
+
cookies,
|
|
1134
|
+
options
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
async loadSavedCookies(force = false) {
|
|
1138
|
+
if (!force && !this.cookieSyncDirty) {
|
|
1139
|
+
return;
|
|
1140
|
+
}
|
|
1141
|
+
if (this.cookieSyncPromise) {
|
|
1142
|
+
return this.cookieSyncPromise;
|
|
1143
|
+
}
|
|
1144
|
+
this.cookieSyncPromise = (async ()=>{
|
|
1145
|
+
const persisted = await readCookieState();
|
|
1146
|
+
if (persisted && persisted.updatedAt > this.cookieUpdatedAt) {
|
|
1147
|
+
this.cookieJar.load(persisted.cookies);
|
|
1148
|
+
this.cookieUpdatedAt = persisted.updatedAt;
|
|
1149
|
+
}
|
|
1150
|
+
this.cookieSyncDirty = false;
|
|
1151
|
+
})().finally(()=>{
|
|
1152
|
+
this.cookieSyncPromise = null;
|
|
1153
|
+
});
|
|
1154
|
+
return this.cookieSyncPromise;
|
|
1155
|
+
}
|
|
1156
|
+
async persistCookies() {
|
|
1157
|
+
const updatedAt = await writeCookieState(this.cookieJar.dump(), this.cookieUpdatedAt);
|
|
1158
|
+
if (updatedAt <= this.cookieUpdatedAt) {
|
|
1159
|
+
return;
|
|
1160
|
+
}
|
|
1161
|
+
this.cookieUpdatedAt = updatedAt;
|
|
1162
|
+
this.cookieSyncDirty = false;
|
|
1163
|
+
this.cookieSyncChannel.postMessage({
|
|
1164
|
+
updatedAt
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
useTransport(transport) {
|
|
1168
|
+
this.transport = transport;
|
|
1169
|
+
for (const frame of this.frames){
|
|
1170
|
+
frame.controller.transport = transport;
|
|
1171
|
+
frame.fetchHandler.client.transport = transport;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
createFrame(element, options = {}) {
|
|
1175
|
+
if (!this.ready) {
|
|
1176
|
+
throw new Error("Controller is not ready! Try awaiting controller.wait()");
|
|
1177
|
+
}
|
|
1178
|
+
element ??= document.createElement("iframe");
|
|
1179
|
+
const frame = new Frame(this, element, options);
|
|
1180
|
+
this.frames.push(frame);
|
|
1181
|
+
return frame;
|
|
1182
|
+
}
|
|
1183
|
+
async wait() {
|
|
1184
|
+
await this.ready;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
function base64Encode(text) {
|
|
1188
|
+
return btoa(new TextEncoder().encode(text).reduce((data, byte)=>(data.push(String.fromCharCode(byte)), data), []).join(""));
|
|
1189
|
+
}
|
|
1190
|
+
function yieldGetInjectScripts(config, sjconfig, prefix, cookieJar, codecEncode, codecDecode) {
|
|
1191
|
+
const getInjectScripts = (meta, handler, htmlcontext, script)=>{
|
|
1192
|
+
function base64Encode(text) {
|
|
1193
|
+
return btoa(new TextEncoder().encode(text).reduce((data, byte)=>(data.push(String.fromCharCode(byte)), data), []).join(""));
|
|
1194
|
+
}
|
|
1195
|
+
return [
|
|
1196
|
+
script(config.corridorPath),
|
|
1197
|
+
script(prefix.href + config.virtualWasmPath),
|
|
1198
|
+
script(config.injectPath),
|
|
1199
|
+
script("data:text/javascript;charset=utf-8;base64," + base64Encode(`
|
|
1200
|
+
document.querySelectorAll("script[corridor-injected]").forEach(script => script.remove());
|
|
1201
|
+
$corridorController.load({
|
|
1202
|
+
config: ${JSON.stringify(config)},
|
|
1203
|
+
sjconfig: ${JSON.stringify(sjconfig)},
|
|
1204
|
+
prefix: new URL("${prefix.href}"),
|
|
1205
|
+
cookies: ${JSON.stringify(cookieJar.dump())},
|
|
1206
|
+
yieldGetInjectScripts: ${yieldGetInjectScripts.toString()},
|
|
1207
|
+
codecEncode: ${codecEncode.toString()},
|
|
1208
|
+
codecDecode: ${codecDecode.toString()},
|
|
1209
|
+
initHeaders: ${JSON.stringify(htmlcontext.headers ?? [])},
|
|
1210
|
+
history: ${JSON.stringify(htmlcontext.history ?? [])},
|
|
1211
|
+
})
|
|
1212
|
+
`))
|
|
1213
|
+
];
|
|
1214
|
+
};
|
|
1215
|
+
return getInjectScripts;
|
|
1216
|
+
}
|
|
1217
|
+
class Frame {
|
|
1218
|
+
controller;
|
|
1219
|
+
element;
|
|
1220
|
+
options;
|
|
1221
|
+
id;
|
|
1222
|
+
prefix;
|
|
1223
|
+
fetchHandler;
|
|
1224
|
+
hooks;
|
|
1225
|
+
get context() {
|
|
1226
|
+
return {
|
|
1227
|
+
config: this.controller.corridorConfig,
|
|
1228
|
+
prefix: new URL(this.prefix, location.href),
|
|
1229
|
+
cookieJar: this.controller.cookieJar,
|
|
1230
|
+
interface: {
|
|
1231
|
+
getInjectScripts: yieldGetInjectScripts(this.controller.config, this.controller.corridorConfig, new URL(this.prefix, location.href), this.controller.cookieJar, this.controller.config.codec.encode, this.controller.config.codec.decode),
|
|
1232
|
+
getWorkerInjectScripts: (meta, type, script)=>{
|
|
1233
|
+
let str = "";
|
|
1234
|
+
str += script(this.controller.config.corridorPath);
|
|
1235
|
+
str += script(this.prefix + this.controller.config.virtualWasmPath);
|
|
1236
|
+
str += script("data:text/javascript;charset=utf-8;base64," + base64Encode(`
|
|
1237
|
+
(()=>{
|
|
1238
|
+
const { CorridorClient, CookieJar, setWasm } = $corridor;
|
|
1239
|
+
|
|
1240
|
+
setWasm(Uint8Array.from(atob(self.WASM), (c) => c.charCodeAt(0)));
|
|
1241
|
+
delete self.WASM;
|
|
1242
|
+
|
|
1243
|
+
const sjconfig = ${JSON.stringify(this.controller.corridorConfig)};
|
|
1244
|
+
const prefix = new URL("${this.prefix}", location.href);
|
|
1245
|
+
|
|
1246
|
+
const context = {
|
|
1247
|
+
config: sjconfig,
|
|
1248
|
+
prefix,
|
|
1249
|
+
interface: {
|
|
1250
|
+
codecEncode: ${this.controller.config.codec.encode.toString()},
|
|
1251
|
+
codecDecode: ${this.controller.config.codec.decode.toString()},
|
|
1252
|
+
},
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
const client = new CorridorClient(globalThis, {
|
|
1256
|
+
context,
|
|
1257
|
+
transport: null,
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
client.hook();
|
|
1261
|
+
})();
|
|
1262
|
+
`));
|
|
1263
|
+
return str;
|
|
1264
|
+
},
|
|
1265
|
+
codecEncode: this.controller.config.codec.encode,
|
|
1266
|
+
codecDecode: this.controller.config.codec.decode
|
|
1267
|
+
}
|
|
1268
|
+
};
|
|
1269
|
+
}
|
|
1270
|
+
plugins = [];
|
|
1271
|
+
constructor(controller, element, options = {}){
|
|
1272
|
+
this.controller = controller;
|
|
1273
|
+
this.element = element;
|
|
1274
|
+
this.options = options;
|
|
1275
|
+
this.id = makeId();
|
|
1276
|
+
this.prefix = this.controller.prefix + this.id + "/";
|
|
1277
|
+
this.fetchHandler = new _mercuryworkshop_corridor__rspack_import_3.CorridorFetchHandler({
|
|
1278
|
+
crossOriginIsolated: self.crossOriginIsolated,
|
|
1279
|
+
context: this.context,
|
|
1280
|
+
transport: controller.transport,
|
|
1281
|
+
async sendSetCookie (cookies, options) {
|
|
1282
|
+
await controller.persistCookies();
|
|
1283
|
+
await controller.propagateCookieSync(cookies.map(({ url, cookie })=>({
|
|
1284
|
+
url: url.href,
|
|
1285
|
+
cookie
|
|
1286
|
+
})), options);
|
|
1287
|
+
},
|
|
1288
|
+
async fetchBlobUrl (url) {
|
|
1289
|
+
return _mercuryworkshop_proxy_relays__rspack_import_1.ConduitResponse.fromNativeResponse(await fetch(url));
|
|
1290
|
+
},
|
|
1291
|
+
async fetchDataUrl (url) {
|
|
1292
|
+
return _mercuryworkshop_proxy_relays__rspack_import_1.ConduitResponse.fromNativeResponse(await fetch(url));
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
this.hooks = {
|
|
1296
|
+
fetch: this.fetchHandler.hooks.fetch,
|
|
1297
|
+
init: _mercuryworkshop_corridor__rspack_import_3.Tap.create(),
|
|
1298
|
+
error: _mercuryworkshop_corridor__rspack_import_3.Tap.create()
|
|
1299
|
+
};
|
|
1300
|
+
element[_symbols__rspack_import_4.CONTROLLERFRAME] = this;
|
|
1301
|
+
this.plugins = options.plugins ?? [];
|
|
1302
|
+
for (const plugin of this.plugins){
|
|
1303
|
+
for (const dependency of plugin.dependencies){
|
|
1304
|
+
const dependencyPlugin = this.plugins.find((p)=>p.name === dependency);
|
|
1305
|
+
if (!dependencyPlugin) {
|
|
1306
|
+
throw new Error(`Dependency ${dependency} not found for plugin ${plugin.name}`);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
plugin.install(this);
|
|
1310
|
+
}
|
|
1311
|
+
}
|
|
1312
|
+
getPlugin(name) {
|
|
1313
|
+
const plugin = this.plugins.find((p)=>p.name === name);
|
|
1314
|
+
if (!plugin) {
|
|
1315
|
+
throw new Error(`Plugin ${name} not found`);
|
|
1316
|
+
}
|
|
1317
|
+
return plugin;
|
|
1318
|
+
}
|
|
1319
|
+
back() {
|
|
1320
|
+
this.element.contentWindow?.history.back();
|
|
1321
|
+
}
|
|
1322
|
+
forward() {
|
|
1323
|
+
this.element.contentWindow?.history.forward();
|
|
1324
|
+
}
|
|
1325
|
+
reload() {
|
|
1326
|
+
this.element.contentWindow?.location.reload();
|
|
1327
|
+
}
|
|
1328
|
+
go(url) {
|
|
1329
|
+
const encoded = (0,_mercuryworkshop_corridor__rspack_import_3.rewriteUrl)(url, this.context, {
|
|
1330
|
+
//@ts-expect-error
|
|
1331
|
+
origin: new URL(location.href),
|
|
1332
|
+
//@ts-expect-error
|
|
1333
|
+
base: new URL(location.href)
|
|
1334
|
+
});
|
|
1335
|
+
this.element.src = encoded;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
})();
|
|
1340
|
+
|
|
1341
|
+
$corridorController = __webpack_exports__;
|
|
1342
|
+
})()
|
|
1343
|
+
;
|
|
1344
|
+
//# sourceMappingURL=controller.api.js.map
|