@mercuryworkshop/scramjet-controller 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,466 @@
1
+ var $scramjetControllerInit;
2
+ (() => {
3
+ var __webpack_modules__ = ({
4
+ "./packages/scramjet/packages/rpc/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
+ __webpack_require__.r(__webpack_exports__);
6
+ __webpack_require__.d(__webpack_exports__, {
7
+ RpcHelper: () => (RpcHelper)
8
+ });
9
+ class RpcHelper {
10
+ methods;
11
+ id;
12
+ sendRaw;
13
+ counter = 0;
14
+ promiseCallbacks = new Map();
15
+ constructor(methods, id, sendRaw){
16
+ this.methods = methods;
17
+ this.id = id;
18
+ this.sendRaw = sendRaw;
19
+ }
20
+ recieve(data) {
21
+ if (data === undefined || data === null || typeof data !== "object") return;
22
+ const dt = data[this.id];
23
+ if (dt === undefined || dt === null || typeof dt !== "object") return;
24
+ const type = dt.$type;
25
+ if (type === "response") {
26
+ const token = dt.$token;
27
+ const data = dt.$data;
28
+ const error = dt.$error;
29
+ const cb = this.promiseCallbacks.get(token);
30
+ if (!cb) return;
31
+ this.promiseCallbacks.delete(token);
32
+ if (error !== undefined) {
33
+ cb.reject(new Error(error));
34
+ } else {
35
+ cb.resolve(data);
36
+ }
37
+ } else if (type === "request") {
38
+ const method = dt.$method;
39
+ const args = dt.$args;
40
+ this.methods[method](args).then((r)=>{
41
+ this.sendRaw({
42
+ [this.id]: {
43
+ $type: "response",
44
+ $token: dt.$token,
45
+ $data: r?.[0]
46
+ }
47
+ }, r?.[1]);
48
+ }).catch((err)=>{
49
+ console.error(err);
50
+ this.sendRaw({
51
+ [this.id]: {
52
+ $type: "response",
53
+ $token: dt.$token,
54
+ $error: err?.toString() || "Unknown error"
55
+ }
56
+ }, []);
57
+ });
58
+ }
59
+ }
60
+ call(method, args, transfer = []) {
61
+ let token = this.counter++;
62
+ return new Promise((resolve, reject)=>{
63
+ this.promiseCallbacks.set(token, {
64
+ resolve,
65
+ reject
66
+ });
67
+ this.sendRaw({
68
+ [this.id]: {
69
+ $type: "request",
70
+ $method: method,
71
+ $args: args,
72
+ $token: token
73
+ }
74
+ }, transfer);
75
+ });
76
+ }
77
+ }
78
+
79
+
80
+ },
81
+
82
+ });
83
+ // The module cache
84
+ var __webpack_module_cache__ = {};
85
+
86
+ // The require function
87
+ function __webpack_require__(moduleId) {
88
+
89
+ // Check if module is in cache
90
+ var cachedModule = __webpack_module_cache__[moduleId];
91
+ if (cachedModule !== undefined) {
92
+ return cachedModule.exports;
93
+ }
94
+ // Create a new module (and put it into the cache)
95
+ var module = (__webpack_module_cache__[moduleId] = {
96
+ exports: {}
97
+ });
98
+ // Execute the module function
99
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
100
+
101
+ // Return the exports of the module
102
+ return module.exports;
103
+
104
+ }
105
+
106
+ // webpack/runtime/define_property_getters
107
+ (() => {
108
+ __webpack_require__.d = (exports, definition) => {
109
+ for(var key in definition) {
110
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
111
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
112
+ }
113
+ }
114
+ };
115
+ })();
116
+ // webpack/runtime/has_own_property
117
+ (() => {
118
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
119
+ })();
120
+ // webpack/runtime/make_namespace_object
121
+ (() => {
122
+ // define __esModule on exports
123
+ __webpack_require__.r = (exports) => {
124
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
125
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
126
+ }
127
+ Object.defineProperty(exports, '__esModule', { value: true });
128
+ };
129
+ })();
130
+ var __webpack_exports__ = {};
131
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
132
+ (() => {
133
+ __webpack_require__.r(__webpack_exports__);
134
+ __webpack_require__.d(__webpack_exports__, {
135
+ "default": () => (init)
136
+ });
137
+ /* import */ var _mercuryworkshop_rpc__rspack_import_0 = __webpack_require__("./packages/scramjet/packages/rpc/index.ts");
138
+
139
+ const cookieJar = new $scramjet.CookieJar();
140
+ const defaultConfig = {
141
+ prefix: "/~/sj/",
142
+ virtualWasmPath: "scramjet.wasm.js",
143
+ injectPath: "/controller/controller.inject.js",
144
+ scramjetPath: "/scramjet/scramjet.js",
145
+ wasmPath: "/scramjet/scramjet.wasm.wasm"
146
+ };
147
+ let config;
148
+ async function init(cfg = {}) {
149
+ config = {
150
+ ...defaultConfig,
151
+ ...cfg
152
+ };
153
+ let resp = await fetch(config.wasmPath);
154
+ $scramjet.setWasm(await resp.arrayBuffer());
155
+ return {
156
+ Controller
157
+ };
158
+ }
159
+ const cfg = {
160
+ flags: {
161
+ ...$scramjet.defaultConfig.flags,
162
+ allowFailedIntercepts: true
163
+ },
164
+ maskedfiles: [
165
+ "inject.js",
166
+ "scramjet.wasm.js"
167
+ ]
168
+ };
169
+ const frames = {};
170
+ let wasmPayload = null;
171
+ function makeId() {
172
+ return Math.random().toString(36).substring(2, 10);
173
+ }
174
+ const codecEncode = (url)=>{
175
+ if (!url) return url;
176
+ return encodeURIComponent(url);
177
+ };
178
+ const codecDecode = (url)=>{
179
+ if (!url) return url;
180
+ return decodeURIComponent(url);
181
+ };
182
+ class Controller {
183
+ init;
184
+ id;
185
+ prefix;
186
+ frames = [];
187
+ cookieJar = new $scramjet.CookieJar();
188
+ rpc;
189
+ ready;
190
+ readyResolve;
191
+ transport;
192
+ methods = {
193
+ ready: async ()=>{
194
+ this.readyResolve();
195
+ },
196
+ request: async (data)=>{
197
+ try {
198
+ let path = new URL(data.rawUrl).pathname;
199
+ const frame = this.frames.find((f)=>path.startsWith(f.prefix));
200
+ if (!frame) throw new Error("No frame found for request");
201
+ if (path === frame.prefix + config.virtualWasmPath) {
202
+ if (!wasmPayload) {
203
+ const resp = await fetch(config.wasmPath);
204
+ const buf = await resp.arrayBuffer();
205
+ const b64 = btoa(new Uint8Array(buf).reduce((data, byte)=>(data.push(String.fromCharCode(byte)), data), []).join(""));
206
+ let payload = "";
207
+ payload += "console.warn('WTF'); if ('document' in self && document.currentScript) { document.currentScript.remove(); }\n";
208
+ payload += `self.WASM = '${b64}';`;
209
+ wasmPayload = payload;
210
+ }
211
+ return [
212
+ {
213
+ body: wasmPayload,
214
+ status: 200,
215
+ statusText: "OK",
216
+ headers: {
217
+ "Content-Type": [
218
+ "application/javascript"
219
+ ]
220
+ }
221
+ },
222
+ []
223
+ ];
224
+ }
225
+ let sjheaders = $scramjet.ScramjetHeaders.fromRawHeaders(data.initialHeaders);
226
+ const fetchresponse = await frame.fetchHandler.handleFetch({
227
+ initialHeaders: sjheaders,
228
+ rawClientUrl: data.rawClientUrl ? new URL(data.rawClientUrl) : undefined,
229
+ rawUrl: new URL(data.rawUrl),
230
+ destination: data.destination,
231
+ method: data.method,
232
+ mode: data.mode,
233
+ referrer: data.referrer,
234
+ body: data.body,
235
+ cache: data.cache
236
+ });
237
+ return [
238
+ {
239
+ body: fetchresponse.body,
240
+ status: fetchresponse.status,
241
+ statusText: fetchresponse.statusText,
242
+ headers: fetchresponse.headers.toRawHeaders()
243
+ },
244
+ fetchresponse.body instanceof ReadableStream || fetchresponse.body instanceof ArrayBuffer ? [
245
+ fetchresponse.body
246
+ ] : []
247
+ ];
248
+ } catch (e) {
249
+ console.error("Error in controller request handler:", e);
250
+ throw e;
251
+ }
252
+ },
253
+ initRemoteTransport: async (port)=>{
254
+ const rpc = new _mercuryworkshop_rpc__rspack_import_0.RpcHelper({
255
+ request: async ({ remote, method, body, headers })=>{
256
+ let response = await this.transport.request(new URL(remote), method, body, headers, undefined);
257
+ return [
258
+ response,
259
+ [
260
+ response.body
261
+ ]
262
+ ];
263
+ },
264
+ connect: async ({ url, protocols, requestHeaders, port })=>{
265
+ let resolve;
266
+ let promise = new Promise((res)=>resolve = res);
267
+ const [send, close] = this.transport.connect(new URL(url), protocols, requestHeaders, (protocol)=>{
268
+ resolve({
269
+ result: "success",
270
+ protocol: protocol
271
+ });
272
+ }, (data)=>{
273
+ port.postMessage({
274
+ type: "data",
275
+ data: data
276
+ }, data instanceof ArrayBuffer ? [
277
+ data
278
+ ] : []);
279
+ }, (close, reason)=>{
280
+ port.postMessage({
281
+ type: "close",
282
+ code: close,
283
+ reason: reason
284
+ });
285
+ }, (error)=>{
286
+ resolve({
287
+ result: "failure",
288
+ error: error
289
+ });
290
+ });
291
+ port.onmessageerror = (ev)=>{
292
+ console.error("Transport port messageerror (this should never happen!)", ev);
293
+ };
294
+ port.onmessage = ({ data })=>{
295
+ if (data.type === "data") {
296
+ send(data.data);
297
+ } else if (data.type === "close") {
298
+ close(data.code, data.reason);
299
+ }
300
+ };
301
+ return [
302
+ await promise,
303
+ []
304
+ ];
305
+ }
306
+ }, "transport", (data, transfer)=>port.postMessage(data, transfer));
307
+ port.onmessageerror = (ev)=>{
308
+ console.error("Transport port messageerror (this should never happen!)", ev);
309
+ };
310
+ port.onmessage = (e)=>{
311
+ rpc.recieve(e.data);
312
+ };
313
+ rpc.call("ready", undefined, []);
314
+ },
315
+ sendSetCookie: async ({ url, cookie })=>{}
316
+ };
317
+ constructor(init){
318
+ this.init = init;
319
+ this.transport = init.transport;
320
+ this.id = makeId();
321
+ this.prefix = config.prefix + this.id + "/";
322
+ this.ready = new Promise((resolve)=>{
323
+ this.readyResolve = resolve;
324
+ });
325
+ let channel = new MessageChannel();
326
+ this.rpc = new _mercuryworkshop_rpc__rspack_import_0.RpcHelper(this.methods, "tabchannel-" + this.id, (data, transfer)=>{
327
+ channel.port1.postMessage(data, transfer);
328
+ });
329
+ channel.port1.addEventListener("message", (e)=>{
330
+ this.rpc.recieve(e.data);
331
+ });
332
+ channel.port1.start();
333
+ init.serviceworker.postMessage({
334
+ $controller$init: {
335
+ prefix: config.prefix + this.id,
336
+ id: this.id
337
+ }
338
+ }, [
339
+ channel.port2
340
+ ]);
341
+ }
342
+ createFrame(element) {
343
+ element ??= document.createElement("iframe");
344
+ const frame = new Frame(this, element);
345
+ this.frames.push(frame);
346
+ return frame;
347
+ }
348
+ wait() {
349
+ return this.ready;
350
+ }
351
+ }
352
+ function yieldGetInjectScripts(cookieJar, config, sjconfig, prefix) {
353
+ return function getInjectScripts(meta, handler, script) {
354
+ return [
355
+ script(config.scramjetPath),
356
+ script(config.injectPath),
357
+ script(prefix.href + config.virtualWasmPath),
358
+ script("data:text/javascript;base64," + btoa(`
359
+ document.currentScript.remove();
360
+ $scramjetController.load({
361
+ config: ${JSON.stringify(config)},
362
+ sjconfig: ${JSON.stringify(sjconfig)},
363
+ cookies: ${cookieJar.dump()},
364
+ prefix: new URL("${prefix.href}"),
365
+ yieldGetInjectScripts: ${yieldGetInjectScripts.toString()},
366
+ codecEncode: ${codecEncode.toString()},
367
+ codecDecode: ${codecDecode.toString()},
368
+ })
369
+ `))
370
+ ];
371
+ };
372
+ }
373
+ class Frame {
374
+ controller;
375
+ element;
376
+ fetchHandler;
377
+ id;
378
+ prefix;
379
+ get context() {
380
+ let sjcfg = {
381
+ ...$scramjet.defaultConfig,
382
+ ...cfg
383
+ };
384
+ return {
385
+ cookieJar,
386
+ prefix: new URL(this.prefix, location.href),
387
+ config: sjcfg,
388
+ interface: {
389
+ getInjectScripts: yieldGetInjectScripts(this.controller.cookieJar, config, {
390
+ ...$scramjet.defaultConfig,
391
+ ...cfg
392
+ }, new URL(this.prefix, location.href)),
393
+ getWorkerInjectScripts: (meta, type, script)=>{
394
+ let str = "";
395
+ str += script(config.scramjetPath);
396
+ str += script(this.prefix + config.virtualWasmPath);
397
+ str += `
398
+ (()=>{
399
+ const { ScramjetClient, CookieJar, setWasm } = $scramjet;
400
+
401
+ setWasm(Uint8Array.from(atob(self.WASM), (c) => c.charCodeAt(0)));
402
+ delete self.WASM;
403
+
404
+ const sjconfig = ${JSON.stringify(sjcfg)};
405
+ const prefix = new URL("${this.prefix}", location.href);
406
+
407
+ const context = {
408
+ interface: {
409
+ codecEncode: ${codecEncode.toString()},
410
+ codecDecode: ${codecDecode.toString()},
411
+ },
412
+ prefix,
413
+ config: sjconfig
414
+ };
415
+
416
+ const client = new ScramjetClient(globalThis, {
417
+ context,
418
+ transport: null,
419
+ shouldPassthroughWebsocket: (url) => {
420
+ return url === "wss://anura.pro/";
421
+ }
422
+ });
423
+
424
+ client.hook();
425
+ })();
426
+ `;
427
+ return str;
428
+ },
429
+ codecEncode,
430
+ codecDecode
431
+ }
432
+ };
433
+ }
434
+ constructor(controller, element){
435
+ this.controller = controller;
436
+ this.element = element;
437
+ this.id = makeId();
438
+ this.prefix = this.controller.prefix + this.id + "/";
439
+ this.fetchHandler = new $scramjet.ScramjetFetchHandler({
440
+ crossOriginIsolated: self.crossOriginIsolated,
441
+ context: this.context,
442
+ transport: controller.transport,
443
+ async sendSetCookie (url, cookie) {},
444
+ async fetchBlobUrl (url) {
445
+ return await fetch(url);
446
+ },
447
+ async fetchDataUrl (url) {
448
+ return await fetch(url);
449
+ }
450
+ });
451
+ }
452
+ go(url) {
453
+ const encoded = $scramjet.rewriteUrl(url, this.context, {
454
+ origin: new URL(location.href),
455
+ base: new URL(location.href)
456
+ });
457
+ this.element.src = encoded;
458
+ }
459
+ }
460
+
461
+ })();
462
+
463
+ $scramjetControllerInit = __webpack_exports__;
464
+ })()
465
+ ;
466
+ //# sourceMappingURL=controller.api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.api.js","sources":["webpack://$scramjetControllerInit/./packages/scramjet/packages/rpc/index.ts","webpack://$scramjetControllerInit/webpack/runtime/define_property_getters","webpack://$scramjetControllerInit/webpack/runtime/has_own_property","webpack://$scramjetControllerInit/webpack/runtime/make_namespace_object","webpack://$scramjetControllerInit/./packages/scramjet/packages/controller/src/index.ts"],"sourcesContent":["type Serverbound = {\n\tmethod1: [{ paramA: string; paramB: number }, boolean];\n\tmethod2: [string, number];\n};\n\ntype Clientbound = {\n\tmethod1: [number];\n\tmethod2: [boolean, string];\n};\n\nexport type RpcDescription = {\n\t[method: string]: [args: any, returnType: any] | [args: any] | [];\n};\n\nexport type MethodsDefinition<Description extends RpcDescription> = {\n\t[Method in keyof Description]: (\n\t\t...args: Description[Method] extends [infer A, ...any[]] ? [A] : []\n\t) => Description[Method] extends [any, infer R]\n\t\t? Promise<[R, Transferable[]]>\n\t\t: Promise<void>;\n};\n\nexport class RpcHelper<\n\tLocal extends RpcDescription,\n\tRemote extends RpcDescription,\n> {\n\tcounter: number = 0;\n\tpromiseCallbacks: Map<\n\t\tnumber,\n\t\t{ resolve: (value: any) => void; reject: (reason?: any) => void }\n\t> = new Map();\n\tconstructor(\n\t\tprivate methods: MethodsDefinition<Local>,\n\t\tprivate id: string,\n\t\tprivate sendRaw: (data: any, transfer: Transferable[]) => void\n\t) {}\n\n\trecieve(data: any) {\n\t\tif (data === undefined || data === null || typeof data !== \"object\") return;\n\t\tconst dt = data[this.id];\n\t\tif (dt === undefined || dt === null || typeof dt !== \"object\") return;\n\n\t\tconst type = dt.$type;\n\n\t\tif (type === \"response\") {\n\t\t\tconst token = dt.$token;\n\t\t\tconst data = dt.$data;\n\t\t\tconst error = dt.$error;\n\t\t\tconst cb = this.promiseCallbacks.get(token);\n\t\t\tif (!cb) return;\n\t\t\tthis.promiseCallbacks.delete(token);\n\t\t\tif (error !== undefined) {\n\t\t\t\tcb.reject(new Error(error));\n\t\t\t} else {\n\t\t\t\tcb.resolve(data);\n\t\t\t}\n\t\t} else if (type === \"request\") {\n\t\t\tconst method = dt.$method as keyof Local;\n\t\t\tconst args = dt.$args as Local[typeof method][0];\n\t\t\t(this.methods[method] as any)(args)\n\t\t\t\t.then((r: any) => {\n\t\t\t\t\tthis.sendRaw(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t\t\t$type: \"response\",\n\t\t\t\t\t\t\t\t$token: dt.$token,\n\t\t\t\t\t\t\t\t$data: r?.[0],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tr?.[1]\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t\t.catch((err: any) => {\n\t\t\t\t\tconsole.error(err);\n\t\t\t\t\tthis.sendRaw(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t\t\t$type: \"response\",\n\t\t\t\t\t\t\t\t$token: dt.$token,\n\t\t\t\t\t\t\t\t$error: err?.toString() || \"Unknown error\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[]\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tcall<Method extends keyof Remote>(\n\t\tmethod: Method,\n\t\targs: Remote[Method][0],\n\t\ttransfer: Transferable[] = []\n\t): Promise<Remote[Method][1]> {\n\t\tlet token = this.counter++;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.promiseCallbacks.set(token, { resolve, reject });\n\t\t\tthis.sendRaw(\n\t\t\t\t{\n\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t$type: \"request\",\n\t\t\t\t\t\t$method: method,\n\t\t\t\t\t\t$args: args,\n\t\t\t\t\t\t$token: token,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttransfer\n\t\t\t);\n\t\t});\n\t}\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { type MethodsDefinition, RpcHelper } from \"@mercuryworkshop/rpc\";\nimport type * as ScramjetGlobal from \"@mercuryworkshop/scramjet\";\n\ndeclare const $scramjet: typeof ScramjetGlobal;\n\nimport {\n\ttype TransportToController,\n\ttype Controllerbound,\n\ttype ControllerToTransport,\n\ttype SWbound,\n\ttype WebSocketMessage,\n} from \"./types\";\nimport {\n\tBareCompatibleClient,\n\ttype BareResponse,\n\ttype ProxyTransport,\n} from \"@mercuryworkshop/proxy-transports\";\n\nconst cookieJar = new $scramjet.CookieJar();\n\ntype Config = {\n\twasmPath: string;\n\tinjectPath: string;\n\tscramjetPath: string;\n\tvirtualWasmPath: string;\n\tprefix: string;\n};\n\nconst defaultConfig: Config = {\n\tprefix: \"/~/sj/\",\n\tvirtualWasmPath: \"scramjet.wasm.js\",\n\tinjectPath: \"/controller/controller.inject.js\",\n\tscramjetPath: \"/scramjet/scramjet.js\",\n\twasmPath: \"/scramjet/scramjet.wasm.wasm\",\n};\nlet config: Config;\n\nexport default async function init(cfg: Partial<Config> = {}): Promise<{ Controller: typeof Controller }> {\n\tconfig = { ...defaultConfig, ...cfg };\n\tlet resp = await fetch(config.wasmPath)\n\t\n\t$scramjet.setWasm(await resp.arrayBuffer());\n\n\treturn { Controller };\n}\n\nconst cfg = {\n\tflags: {\n\t\t...$scramjet.defaultConfig.flags,\n\t\tallowFailedIntercepts: true,\n\t},\n\tmaskedfiles: [\"inject.js\", \"scramjet.wasm.js\"],\n};\n\nconst frames: Record<string, Frame> = {};\n\nlet wasmPayload: string | null = null;\n\nfunction makeId(): string {\n\treturn Math.random().toString(36).substring(2, 10);\n}\n\nconst codecEncode = (url: string) => {\n\tif (!url) return url;\n\n\treturn encodeURIComponent(url);\n};\n\nconst codecDecode = (url: string) => {\n\tif (!url) return url;\n\n\treturn decodeURIComponent(url);\n};\n\ntype ControllerInit = {\n\tserviceworker: ServiceWorker;\n\ttransport: ProxyTransport;\n};\n\nclass Controller {\n\tid: string;\n\tprefix: string;\n\tframes: Frame[] = [];\n\tcookieJar = new $scramjet.CookieJar();\n\n\trpc: RpcHelper<Controllerbound, SWbound>;\n\tprivate ready: Promise<void>;\n\tprivate readyResolve!: () => void;\n\n\ttransport: ProxyTransport;\n\n\tprivate methods: MethodsDefinition<Controllerbound> = {\n\t\tready: async () => {\n\t\t\tthis.readyResolve();\n\t\t},\n\t\trequest: async (data) => {\n\t\t\ttry {\n\t\t\t\tlet path = new URL(data.rawUrl).pathname;\n\t\t\t\tconst frame = this.frames.find((f) => path.startsWith(f.prefix));\n\t\t\t\tif (!frame) throw new Error(\"No frame found for request\");\n\n\t\t\t\tif (path === frame.prefix + config.virtualWasmPath) {\n\t\t\t\t\tif (!wasmPayload) {\n\t\t\t\t\t\tconst resp = await fetch(config.wasmPath);\n\t\t\t\t\t\tconst buf = await resp.arrayBuffer();\n\t\t\t\t\t\tconst b64 = btoa(\n\t\t\t\t\t\t\tnew Uint8Array(buf)\n\t\t\t\t\t\t\t\t.reduce(\n\t\t\t\t\t\t\t\t\t(data, byte) => (data.push(String.fromCharCode(byte)), data),\n\t\t\t\t\t\t\t\t\t[] as any\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join(\"\")\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tlet payload = \"\";\n\t\t\t\t\t\tpayload +=\n\t\t\t\t\t\t\t\"console.warn('WTF'); if ('document' in self && document.currentScript) { document.currentScript.remove(); }\\n\";\n\t\t\t\t\t\tpayload += `self.WASM = '${b64}';`;\n\t\t\t\t\t\twasmPayload = payload;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tbody: wasmPayload,\n\t\t\t\t\t\t\tstatus: 200,\n\t\t\t\t\t\t\tstatusText: \"OK\",\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\"Content-Type\": [\"application/javascript\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[],\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\tlet sjheaders = $scramjet.ScramjetHeaders.fromRawHeaders(\n\t\t\t\t\tdata.initialHeaders\n\t\t\t\t);\n\n\t\t\t\tconst fetchresponse = await frame.fetchHandler.handleFetch({\n\t\t\t\t\tinitialHeaders: sjheaders,\n\t\t\t\t\trawClientUrl: data.rawClientUrl\n\t\t\t\t\t\t? new URL(data.rawClientUrl)\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\trawUrl: new URL(data.rawUrl),\n\t\t\t\t\tdestination: data.destination,\n\t\t\t\t\tmethod: data.method,\n\t\t\t\t\tmode: data.mode,\n\t\t\t\t\treferrer: data.referrer,\n\t\t\t\t\tbody: data.body,\n\t\t\t\t\tcache: data.cache,\n\t\t\t\t});\n\n\t\t\t\treturn [\n\t\t\t\t\t{\n\t\t\t\t\t\tbody: fetchresponse.body,\n\t\t\t\t\t\tstatus: fetchresponse.status,\n\t\t\t\t\t\tstatusText: fetchresponse.statusText,\n\t\t\t\t\t\theaders: fetchresponse.headers.toRawHeaders(),\n\t\t\t\t\t},\n\t\t\t\t\tfetchresponse.body instanceof ReadableStream ||\n\t\t\t\t\tfetchresponse.body instanceof ArrayBuffer\n\t\t\t\t\t\t? [fetchresponse.body]\n\t\t\t\t\t\t: [],\n\t\t\t\t];\n\t\t\t} catch (e) {\n\t\t\t\tconsole.error(\"Error in controller request handler:\", e);\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t},\n\t\tinitRemoteTransport: async (port) => {\n\t\t\tconst rpc = new RpcHelper<TransportToController, ControllerToTransport>(\n\t\t\t\t{\n\t\t\t\t\trequest: async ({ remote, method, body, headers }) => {\n\t\t\t\t\t\tlet response = await this.transport.request(\n\t\t\t\t\t\t\tnew URL(remote),\n\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\tbody,\n\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\tundefined\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn [response, [response.body]];\n\t\t\t\t\t},\n\t\t\t\t\tconnect: async ({ url, protocols, requestHeaders, port }) => {\n\t\t\t\t\t\tlet resolve: (arg: TransportToController[\"connect\"][1]) => void;\n\t\t\t\t\t\tlet promise = new Promise<TransportToController[\"connect\"][1]>(\n\t\t\t\t\t\t\t(res) => (resolve = res)\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst [send, close] = this.transport.connect(\n\t\t\t\t\t\t\tnew URL(url),\n\t\t\t\t\t\t\tprotocols,\n\t\t\t\t\t\t\trequestHeaders,\n\t\t\t\t\t\t\t(protocol) => {\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tresult: \"success\",\n\t\t\t\t\t\t\t\t\tprotocol: protocol,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(data) => {\n\t\t\t\t\t\t\t\tport.postMessage(\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\t\t\t\t\tdata: data,\n\t\t\t\t\t\t\t\t\t} as WebSocketMessage,\n\t\t\t\t\t\t\t\t\tdata instanceof ArrayBuffer ? [data] : []\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(close, reason) => {\n\t\t\t\t\t\t\t\tport.postMessage({\n\t\t\t\t\t\t\t\t\ttype: \"close\",\n\t\t\t\t\t\t\t\t\tcode: close,\n\t\t\t\t\t\t\t\t\treason: reason,\n\t\t\t\t\t\t\t\t} as WebSocketMessage);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\tresolve({\n\t\t\t\t\t\t\t\t\tresult: \"failure\",\n\t\t\t\t\t\t\t\t\terror: error,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t\t\tport.onmessageerror = (ev) => {\n\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\"Transport port messageerror (this should never happen!)\",\n\t\t\t\t\t\t\t\tev\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t};\n\t\t\t\t\t\tport.onmessage = ({ data }: { data: WebSocketMessage }) => {\n\t\t\t\t\t\t\tif (data.type === \"data\") {\n\t\t\t\t\t\t\t\tsend(data.data);\n\t\t\t\t\t\t\t} else if (data.type === \"close\") {\n\t\t\t\t\t\t\t\tclose(data.code, data.reason);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\treturn [await promise, []];\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t\"transport\",\n\t\t\t\t(data, transfer) => port.postMessage(data, transfer)\n\t\t\t);\n\t\t\tport.onmessageerror = (ev) => {\n\t\t\t\tconsole.error(\n\t\t\t\t\t\"Transport port messageerror (this should never happen!)\",\n\t\t\t\t\tev\n\t\t\t\t);\n\t\t\t};\n\t\t\tport.onmessage = (e) => {\n\t\t\t\trpc.recieve(e.data);\n\t\t\t};\n\t\t\trpc.call(\"ready\", undefined, []);\n\t\t},\n\t\tsendSetCookie: async ({ url, cookie }) => {},\n\t};\n\n\tconstructor(public init: ControllerInit) {\n\t\tthis.transport = init.transport;\n\t\tthis.id = makeId();\n\t\tthis.prefix = config.prefix + this.id + \"/\";\n\n\t\tthis.ready = new Promise<void>((resolve) => {\n\t\t\tthis.readyResolve = resolve;\n\t\t});\n\n\t\tlet channel = new MessageChannel();\n\t\tthis.rpc = new RpcHelper<Controllerbound, SWbound>(\n\t\t\tthis.methods,\n\t\t\t\"tabchannel-\" + this.id,\n\t\t\t(data, transfer) => {\n\t\t\t\tchannel.port1.postMessage(data, transfer);\n\t\t\t}\n\t\t);\n\t\tchannel.port1.addEventListener(\"message\", (e) => {\n\t\t\tthis.rpc.recieve(e.data);\n\t\t});\n\t\tchannel.port1.start();\n\n\t\tinit.serviceworker.postMessage(\n\t\t\t{\n\t\t\t\t$controller$init: {\n\t\t\t\t\tprefix: config.prefix + this.id,\n\t\t\t\t\tid: this.id,\n\t\t\t\t},\n\t\t\t},\n\t\t\t[channel.port2]\n\t\t);\n\t}\n\n\tcreateFrame(element?: HTMLIFrameElement): Frame {\n\t\telement ??= document.createElement(\"iframe\");\n\t\tconst frame = new Frame(this, element);\n\t\tthis.frames.push(frame);\n\t\treturn frame;\n\t}\n\n\twait(): Promise<void> {\n\t\treturn this.ready;\n\t}\n}\n\nfunction yieldGetInjectScripts(\n\tcookieJar: ScramjetGlobal.CookieJar,\n\tconfig: Config,\n\tsjconfig: ScramjetGlobal.ScramjetConfig,\n\tprefix: URL\n) {\n\treturn function getInjectScripts(meta, handler, script) {\n\t\treturn [\n\t\t\tscript(config.scramjetPath),\n\t\t\tscript(config.injectPath),\n\t\t\tscript(prefix.href + config.virtualWasmPath),\n\t\t\tscript(\n\t\t\t\t\"data:text/javascript;base64,\" +\n\t\t\t\t\tbtoa(`\n\t\t\t\t\tdocument.currentScript.remove();\n\t\t\t\t\t$scramjetController.load({\n\t\t\t\t\t\tconfig: ${JSON.stringify(config)},\n\t\t\t\t\t\tsjconfig: ${JSON.stringify(sjconfig)},\n\t\t\t\t\t\tcookies: ${cookieJar.dump()},\n\t\t\t\t\t\tprefix: new URL(\"${prefix.href}\"),\n\t\t\t\t\t\tyieldGetInjectScripts: ${yieldGetInjectScripts.toString()},\n\t\t\t\t\t\tcodecEncode: ${codecEncode.toString()},\n\t\t\t\t\t\tcodecDecode: ${codecDecode.toString()},\n\t\t\t\t\t})\n\t\t\t\t`)\n\t\t\t),\n\t\t];\n\t};\n}\n\nclass Frame {\n\tfetchHandler: ScramjetGlobal.ScramjetFetchHandler;\n\tid: string;\n\tprefix: string;\n\n\tget context() {\n\t\tlet sjcfg = {\n\t\t\t...$scramjet.defaultConfig,\n\t\t\t...cfg,\n\t\t};\n\t\treturn {\n\t\t\tcookieJar,\n\t\t\tprefix: new URL(this.prefix, location.href),\n\t\t\tconfig: sjcfg,\n\t\t\tinterface: {\n\t\t\t\tgetInjectScripts: yieldGetInjectScripts(\n\t\t\t\t\tthis.controller.cookieJar,\n\t\t\t\t\tconfig,\n\t\t\t\t\t{ ...$scramjet.defaultConfig, ...cfg },\n\t\t\t\t\tnew URL(this.prefix, location.href)\n\t\t\t\t),\n\t\t\t\tgetWorkerInjectScripts: (meta, type, script) => {\n\t\t\t\t\tlet str = \"\";\n\n\t\t\t\t\tstr += script(config.scramjetPath);\n\t\t\t\t\tstr += script(this.prefix + config.virtualWasmPath);\n\t\t\t\t\tstr += `\n\t\t\t\t\t(()=>{\n\t\t\t\t\t\tconst { ScramjetClient, CookieJar, setWasm } = $scramjet;\n\n\t\t\t\t\t\tsetWasm(Uint8Array.from(atob(self.WASM), (c) => c.charCodeAt(0)));\n\t\t\t\t\t\tdelete self.WASM;\n\n\t\t\t\t\t\tconst sjconfig = ${JSON.stringify(sjcfg)};\n\t\t\t\t\t\tconst prefix = new URL(\"${this.prefix}\", location.href);\n\n\t\t\t\t\t\tconst context = {\n\t\t\t\t\t\t\tinterface: {\n\t\t\t\t\t\t\t\tcodecEncode: ${codecEncode.toString()},\n\t\t\t\t\t\t\t\tcodecDecode: ${codecDecode.toString()},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tprefix,\n\t\t\t\t\t\t\tconfig: sjconfig\n\t\t\t\t\t\t};\n\n\t\t\t\t\t\tconst client = new ScramjetClient(globalThis, {\n\t\t\t\t\t\t\tcontext,\n\t\t\t\t\t\t\ttransport: null,\n\t\t\t\t\t\t\tshouldPassthroughWebsocket: (url) => {\n\t\t\t\t\t\t\t\treturn url === \"wss://anura.pro/\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tclient.hook();\n\t\t\t\t\t})();\n\t\t\t\t\t`;\n\n\t\t\t\t\treturn str;\n\t\t\t\t},\n\t\t\t\tcodecEncode,\n\t\t\t\tcodecDecode,\n\t\t\t},\n\t\t};\n\t}\n\n\tconstructor(\n\t\tpublic controller: Controller,\n\t\tpublic element: HTMLIFrameElement\n\t) {\n\t\tthis.id = makeId();\n\t\tthis.prefix = this.controller.prefix + this.id + \"/\";\n\n\t\tthis.fetchHandler = new $scramjet.ScramjetFetchHandler({\n\t\t\tcrossOriginIsolated: self.crossOriginIsolated,\n\t\t\tcontext: this.context,\n\t\t\ttransport: controller.transport,\n\t\t\tasync sendSetCookie(url, cookie) {},\n\t\t\tasync fetchBlobUrl(url) {\n\t\t\t\treturn (await fetch(url)) as BareResponseFetch;\n\t\t\t},\n\t\t\tasync fetchDataUrl(url) {\n\t\t\t\treturn (await fetch(url)) as BareResponseFetch;\n\t\t\t},\n\t\t});\n\t}\n\n\tgo(url: string) {\n\t\tconst encoded = $scramjet.rewriteUrl(url, this.context, {\n\t\t\torigin: new URL(location.href),\n\t\t\tbase: new URL(location.href),\n\t\t});\n\t\tthis.element.src = encoded;\n\t}\n}\n"],"names":["RpcHelper","Map","methods","id","sendRaw","data","undefined","dt","type","token","error","cb","Error","method","args","r","err","console","transfer","Promise","resolve","reject","cookieJar","$scramjet","defaultConfig","config","init","cfg","resp","fetch","Controller","frames","wasmPayload","makeId","Math","codecEncode","url","encodeURIComponent","codecDecode","decodeURIComponent","path","URL","frame","f","buf","b64","btoa","Uint8Array","byte","String","payload","sjheaders","fetchresponse","ReadableStream","ArrayBuffer","e","port","rpc","remote","body","headers","response","protocols","requestHeaders","promise","res","send","close","protocol","reason","ev","cookie","channel","MessageChannel","element","document","Frame","yieldGetInjectScripts","sjconfig","prefix","getInjectScripts","meta","handler","script","JSON","sjcfg","location","str","controller","self","encoded"],"mappings":";;;;;;;;AAsBO,MAAMA;;;;IAIZ,UAAkB,EAAE;IACpB,mBAGI,IAAIC,MAAM;IACd,YACSC,OAAiC,EACjCC,EAAU,EACVC,OAAsD,CAC7D;aAHOF,UAAAA;aACAC,KAAAA;aACAC,UAAAA;IACN;IAEH,QAAQC,IAAS,EAAE;QAClB,IAAIA,SAASC,aAAaD,SAAS,QAAQ,OAAOA,SAAS,UAAU;QACrE,MAAME,KAAKF,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAIE,OAAOD,aAA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,eAAcpD,GAAG,EAAEmC,MAAM,GAAG;YAClC,MAAM,cAAanC,GAAG;gBACrB,OAAQ,MAAMP,MAAMO;YACrB;YACA,MAAM,cAAaA,GAAG;gBACrB,OAAQ,MAAMP,MAAMO;YACrB;QACD;IACD;IAEA,GAAGA,GAAW,EAAE;QACf,MAAMsD,UAAUnE,UAAU,UAAU,CAACa,KAAK,IAAI,CAAC,OAAO,EAAE;YACvD,QAAQ,IAAIK,IAAI6C,SAAS,IAAI;YAC7B,MAAM,IAAI7C,IAAI6C,SAAS,IAAI;QAC5B;QACA,IAAI,CAAC,OAAO,CAAC,GAAG,GAAGI;IACpB;AACD"}
@@ -0,0 +1,297 @@
1
+ var $scramjetControllerInit;
2
+ (() => {
3
+ var __webpack_modules__ = ({
4
+ "./packages/scramjet/packages/rpc/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
+ __webpack_require__.r(__webpack_exports__);
6
+ __webpack_require__.d(__webpack_exports__, {
7
+ RpcHelper: () => (RpcHelper)
8
+ });
9
+ class RpcHelper {
10
+ methods;
11
+ id;
12
+ sendRaw;
13
+ counter = 0;
14
+ promiseCallbacks = new Map();
15
+ constructor(methods, id, sendRaw){
16
+ this.methods = methods;
17
+ this.id = id;
18
+ this.sendRaw = sendRaw;
19
+ }
20
+ recieve(data) {
21
+ if (data === undefined || data === null || typeof data !== "object") return;
22
+ const dt = data[this.id];
23
+ if (dt === undefined || dt === null || typeof dt !== "object") return;
24
+ const type = dt.$type;
25
+ if (type === "response") {
26
+ const token = dt.$token;
27
+ const data = dt.$data;
28
+ const error = dt.$error;
29
+ const cb = this.promiseCallbacks.get(token);
30
+ if (!cb) return;
31
+ this.promiseCallbacks.delete(token);
32
+ if (error !== undefined) {
33
+ cb.reject(new Error(error));
34
+ } else {
35
+ cb.resolve(data);
36
+ }
37
+ } else if (type === "request") {
38
+ const method = dt.$method;
39
+ const args = dt.$args;
40
+ this.methods[method](args).then((r)=>{
41
+ this.sendRaw({
42
+ [this.id]: {
43
+ $type: "response",
44
+ $token: dt.$token,
45
+ $data: r?.[0]
46
+ }
47
+ }, r?.[1]);
48
+ }).catch((err)=>{
49
+ console.error(err);
50
+ this.sendRaw({
51
+ [this.id]: {
52
+ $type: "response",
53
+ $token: dt.$token,
54
+ $error: err?.toString() || "Unknown error"
55
+ }
56
+ }, []);
57
+ });
58
+ }
59
+ }
60
+ call(method, args, transfer = []) {
61
+ let token = this.counter++;
62
+ return new Promise((resolve, reject)=>{
63
+ this.promiseCallbacks.set(token, {
64
+ resolve,
65
+ reject
66
+ });
67
+ this.sendRaw({
68
+ [this.id]: {
69
+ $type: "request",
70
+ $method: method,
71
+ $args: args,
72
+ $token: token
73
+ }
74
+ }, transfer);
75
+ });
76
+ }
77
+ }
78
+
79
+
80
+ },
81
+
82
+ });
83
+ // The module cache
84
+ var __webpack_module_cache__ = {};
85
+
86
+ // The require function
87
+ function __webpack_require__(moduleId) {
88
+
89
+ // Check if module is in cache
90
+ var cachedModule = __webpack_module_cache__[moduleId];
91
+ if (cachedModule !== undefined) {
92
+ return cachedModule.exports;
93
+ }
94
+ // Create a new module (and put it into the cache)
95
+ var module = (__webpack_module_cache__[moduleId] = {
96
+ exports: {}
97
+ });
98
+ // Execute the module function
99
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
100
+
101
+ // Return the exports of the module
102
+ return module.exports;
103
+
104
+ }
105
+
106
+ // webpack/runtime/define_property_getters
107
+ (() => {
108
+ __webpack_require__.d = (exports, definition) => {
109
+ for(var key in definition) {
110
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
111
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
112
+ }
113
+ }
114
+ };
115
+ })();
116
+ // webpack/runtime/has_own_property
117
+ (() => {
118
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
119
+ })();
120
+ // webpack/runtime/make_namespace_object
121
+ (() => {
122
+ // define __esModule on exports
123
+ __webpack_require__.r = (exports) => {
124
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
125
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
126
+ }
127
+ Object.defineProperty(exports, '__esModule', { value: true });
128
+ };
129
+ })();
130
+ var __webpack_exports__ = {};
131
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
132
+ (() => {
133
+ __webpack_require__.r(__webpack_exports__);
134
+ __webpack_require__.d(__webpack_exports__, {
135
+ load: () => (load)
136
+ });
137
+ /* import */ var _mercuryworkshop_rpc__rspack_import_0 = __webpack_require__("./packages/scramjet/packages/rpc/index.ts");
138
+
139
+ const MessagePort_postMessage = MessagePort.prototype.postMessage;
140
+ const postMessage = (port, data, transfer)=>{
141
+ MessagePort_postMessage.call(port, data, transfer);
142
+ };
143
+ class RemoteTransport {
144
+ port;
145
+ readyResolve;
146
+ readyPromise = new Promise((resolve)=>{
147
+ this.readyResolve = resolve;
148
+ });
149
+ ready = false;
150
+ async init() {
151
+ await this.readyPromise;
152
+ this.ready = true;
153
+ }
154
+ rpc;
155
+ constructor(port){
156
+ this.port = port;
157
+ this.rpc = new _mercuryworkshop_rpc__rspack_import_0.RpcHelper({
158
+ ready: async ()=>{
159
+ this.readyResolve();
160
+ }
161
+ }, "transport", (data, transfer)=>{
162
+ postMessage(port, data, transfer);
163
+ });
164
+ port.onmessageerror = (ev)=>{
165
+ console.error("onmessageerror (this should never happen!)", ev);
166
+ };
167
+ port.onmessage = (ev)=>{
168
+ this.rpc.recieve(ev.data);
169
+ };
170
+ port.start();
171
+ }
172
+ connect(url, protocols, requestHeaders, onopen, onmessage, onclose, onerror) {
173
+ const channel = new MessageChannel();
174
+ let port = channel.port1;
175
+ console.warn("connecting");
176
+ this.rpc.call("connect", {
177
+ url: url.href,
178
+ protocols,
179
+ requestHeaders,
180
+ port: channel.port2
181
+ }, [
182
+ channel.port2
183
+ ]).then((response)=>{
184
+ console.log(response);
185
+ if (response.result === "success") {
186
+ onopen(response.protocol, response.extensions);
187
+ } else {
188
+ onerror(response.error);
189
+ }
190
+ });
191
+ port.onmessage = (ev)=>{
192
+ const message = ev.data;
193
+ if (message.type === "data") {
194
+ onmessage(message.data);
195
+ } else if (message.type === "close") {
196
+ onclose(message.code, message.reason);
197
+ }
198
+ };
199
+ port.onmessageerror = (ev)=>{
200
+ console.error("onmessageerror (this should never happen!)", ev);
201
+ onerror("Message error in transport port");
202
+ };
203
+ return [
204
+ (data)=>{
205
+ postMessage(port, {
206
+ type: "data",
207
+ data: data
208
+ }, data instanceof ArrayBuffer ? [
209
+ data
210
+ ] : []);
211
+ },
212
+ (code)=>{
213
+ postMessage(port, {
214
+ type: "close",
215
+ code: code
216
+ });
217
+ }
218
+ ];
219
+ }
220
+ async request(remote, method, body, headers, signal) {
221
+ return await this.rpc.call("request", {
222
+ remote: remote.href,
223
+ method,
224
+ body,
225
+ headers
226
+ });
227
+ }
228
+ meta() {
229
+ return {};
230
+ }
231
+ }
232
+ const sw = navigator.serviceWorker.controller;
233
+ const { SCRAMJETCLIENT, ScramjetClient, CookieJar, setWasm } = $scramjet;
234
+ function load({ config, sjconfig, cookies, prefix, yieldGetInjectScripts, codecEncode, codecDecode }) {
235
+ let client;
236
+ if (SCRAMJETCLIENT in globalThis) {
237
+ client = globalThis[SCRAMJETCLIENT];
238
+ } else {
239
+ setWasm(Uint8Array.from(atob(self.WASM), (c)=>c.charCodeAt(0)));
240
+ delete self.WASM;
241
+ const channel = new MessageChannel();
242
+ const transport = new RemoteTransport(channel.port1);
243
+ sw?.postMessage({
244
+ $sw$initRemoteTransport: {
245
+ port: channel.port2,
246
+ prefix: prefix.href
247
+ }
248
+ }, [
249
+ channel.port2
250
+ ]);
251
+ const cookieJar = new CookieJar();
252
+ cookieJar.load(cookies);
253
+ const context = {
254
+ interface: {
255
+ getInjectScripts: yieldGetInjectScripts(cookieJar, config, sjconfig, prefix),
256
+ codecEncode,
257
+ codecDecode
258
+ },
259
+ prefix,
260
+ cookieJar,
261
+ config: sjconfig
262
+ };
263
+ function createFrameId() {
264
+ return `${Array(8).fill(0).map(()=>Math.floor(Math.random() * 36).toString(36)).join("")}`;
265
+ }
266
+ const frame = globalThis.frameElement;
267
+ if (frame && !frame.name) {
268
+ frame.name = createFrameId();
269
+ }
270
+ client = new ScramjetClient(globalThis, {
271
+ context,
272
+ transport,
273
+ sendSetCookie: async (url, cookie)=>{
274
+ // sw.postMessage({
275
+ // $controller$setCookie: {
276
+ // url,
277
+ // cookie
278
+ // }
279
+ // });
280
+ },
281
+ shouldPassthroughWebsocket: (url)=>{
282
+ return url === "wss://anura.pro/";
283
+ },
284
+ shouldBlockMessageEvent (i) {
285
+ return false;
286
+ }
287
+ });
288
+ client.hook();
289
+ }
290
+ }
291
+
292
+ })();
293
+
294
+ $scramjetControllerInit = __webpack_exports__;
295
+ })()
296
+ ;
297
+ //# sourceMappingURL=controller.inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.inject.js","sources":["webpack://$scramjetControllerInit/./packages/scramjet/packages/rpc/index.ts","webpack://$scramjetControllerInit/webpack/runtime/define_property_getters","webpack://$scramjetControllerInit/webpack/runtime/has_own_property","webpack://$scramjetControllerInit/webpack/runtime/make_namespace_object","webpack://$scramjetControllerInit/./packages/scramjet/packages/controller/src/inject.ts"],"sourcesContent":["type Serverbound = {\n\tmethod1: [{ paramA: string; paramB: number }, boolean];\n\tmethod2: [string, number];\n};\n\ntype Clientbound = {\n\tmethod1: [number];\n\tmethod2: [boolean, string];\n};\n\nexport type RpcDescription = {\n\t[method: string]: [args: any, returnType: any] | [args: any] | [];\n};\n\nexport type MethodsDefinition<Description extends RpcDescription> = {\n\t[Method in keyof Description]: (\n\t\t...args: Description[Method] extends [infer A, ...any[]] ? [A] : []\n\t) => Description[Method] extends [any, infer R]\n\t\t? Promise<[R, Transferable[]]>\n\t\t: Promise<void>;\n};\n\nexport class RpcHelper<\n\tLocal extends RpcDescription,\n\tRemote extends RpcDescription,\n> {\n\tcounter: number = 0;\n\tpromiseCallbacks: Map<\n\t\tnumber,\n\t\t{ resolve: (value: any) => void; reject: (reason?: any) => void }\n\t> = new Map();\n\tconstructor(\n\t\tprivate methods: MethodsDefinition<Local>,\n\t\tprivate id: string,\n\t\tprivate sendRaw: (data: any, transfer: Transferable[]) => void\n\t) {}\n\n\trecieve(data: any) {\n\t\tif (data === undefined || data === null || typeof data !== \"object\") return;\n\t\tconst dt = data[this.id];\n\t\tif (dt === undefined || dt === null || typeof dt !== \"object\") return;\n\n\t\tconst type = dt.$type;\n\n\t\tif (type === \"response\") {\n\t\t\tconst token = dt.$token;\n\t\t\tconst data = dt.$data;\n\t\t\tconst error = dt.$error;\n\t\t\tconst cb = this.promiseCallbacks.get(token);\n\t\t\tif (!cb) return;\n\t\t\tthis.promiseCallbacks.delete(token);\n\t\t\tif (error !== undefined) {\n\t\t\t\tcb.reject(new Error(error));\n\t\t\t} else {\n\t\t\t\tcb.resolve(data);\n\t\t\t}\n\t\t} else if (type === \"request\") {\n\t\t\tconst method = dt.$method as keyof Local;\n\t\t\tconst args = dt.$args as Local[typeof method][0];\n\t\t\t(this.methods[method] as any)(args)\n\t\t\t\t.then((r: any) => {\n\t\t\t\t\tthis.sendRaw(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t\t\t$type: \"response\",\n\t\t\t\t\t\t\t\t$token: dt.$token,\n\t\t\t\t\t\t\t\t$data: r?.[0],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tr?.[1]\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t\t.catch((err: any) => {\n\t\t\t\t\tconsole.error(err);\n\t\t\t\t\tthis.sendRaw(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t\t\t$type: \"response\",\n\t\t\t\t\t\t\t\t$token: dt.$token,\n\t\t\t\t\t\t\t\t$error: err?.toString() || \"Unknown error\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[]\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tcall<Method extends keyof Remote>(\n\t\tmethod: Method,\n\t\targs: Remote[Method][0],\n\t\ttransfer: Transferable[] = []\n\t): Promise<Remote[Method][1]> {\n\t\tlet token = this.counter++;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.promiseCallbacks.set(token, { resolve, reject });\n\t\t\tthis.sendRaw(\n\t\t\t\t{\n\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t$type: \"request\",\n\t\t\t\t\t\t$method: method,\n\t\t\t\t\t\t$args: args,\n\t\t\t\t\t\t$token: token,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttransfer\n\t\t\t);\n\t\t});\n\t}\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import type { CookieJar, ScramjetConfig } from \"@mercuryworkshop/scramjet\";\nimport type * as ScramjetGlobal from \"@mercuryworkshop/scramjet\";\ndeclare const $scramjet: typeof ScramjetGlobal;\n\nimport type {\n\tRawHeaders,\n\tProxyTransport,\n\tTransferrableResponse,\n} from \"@mercuryworkshop/proxy-transports\";\n\nimport { RpcHelper } from \"@mercuryworkshop/rpc\";\nimport type {\n\tControllerToTransport,\n\tTransportToController,\n\tWebSocketData,\n\tWebSocketMessage,\n} from \"./types\";\n\nconst MessagePort_postMessage = MessagePort.prototype.postMessage;\nconst postMessage = (\n\tport: MessagePort,\n\tdata: any,\n\ttransfer?: Transferable[]\n) => {\n\tMessagePort_postMessage.call(port, data, transfer as any);\n};\n\nclass RemoteTransport implements ProxyTransport {\n\tprivate readyResolve!: () => void;\n\tprivate readyPromise: Promise<void> = new Promise((resolve) => {\n\t\tthis.readyResolve = resolve;\n\t});\n\n\tpublic ready = false;\n\tasync init() {\n\t\tawait this.readyPromise;\n\t\tthis.ready = true;\n\t}\n\n\tprivate rpc: RpcHelper<ControllerToTransport, TransportToController>;\n\tconstructor(public port: MessagePort) {\n\t\tthis.rpc = new RpcHelper<ControllerToTransport, TransportToController>(\n\t\t\t{\n\t\t\t\tready: async () => {\n\t\t\t\t\tthis.readyResolve();\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"transport\",\n\t\t\t(data, transfer) => {\n\t\t\t\tpostMessage(port, data, transfer);\n\t\t\t}\n\t\t);\n\t\tport.onmessageerror = (ev) => {\n\t\t\tconsole.error(\"onmessageerror (this should never happen!)\", ev);\n\t\t};\n\t\tport.onmessage = (ev) => {\n\t\t\tthis.rpc.recieve(ev.data);\n\t\t};\n\t\tport.start();\n\t}\n\tconnect(\n\t\turl: URL,\n\t\tprotocols: string[],\n\t\trequestHeaders: RawHeaders,\n\t\tonopen: (protocol: string, extensions: string) => void,\n\t\tonmessage: (data: Blob | ArrayBuffer | string) => void,\n\t\tonclose: (code: number, reason: string) => void,\n\t\tonerror: (error: string) => void\n\t): [\n\t\t(data: Blob | ArrayBuffer | string) => void,\n\t\t(code: number, reason: string) => void,\n\t] {\n\t\tconst channel = new MessageChannel();\n\t\tlet port = channel.port1;\n\t\tconsole.warn(\"connecting\");\n\t\tthis.rpc\n\t\t\t.call(\n\t\t\t\t\"connect\",\n\t\t\t\t{\n\t\t\t\t\turl: url.href,\n\t\t\t\t\tprotocols,\n\t\t\t\t\trequestHeaders,\n\t\t\t\t\tport: channel.port2,\n\t\t\t\t},\n\t\t\t\t[channel.port2]\n\t\t\t)\n\t\t\t.then((response) => {\n\t\t\t\tconsole.log(response);\n\t\t\t\tif (response.result === \"success\") {\n\t\t\t\t\tonopen(response.protocol, response.extensions);\n\t\t\t\t} else {\n\t\t\t\t\tonerror(response.error);\n\t\t\t\t}\n\t\t\t});\n\t\tport.onmessage = (ev) => {\n\t\t\tconst message = ev.data as WebSocketMessage;\n\t\t\tif (message.type === \"data\") {\n\t\t\t\tonmessage(message.data);\n\t\t\t} else if (message.type === \"close\") {\n\t\t\t\tonclose(message.code, message.reason);\n\t\t\t}\n\t\t};\n\t\tport.onmessageerror = (ev) => {\n\t\t\tconsole.error(\"onmessageerror (this should never happen!)\", ev);\n\t\t\tonerror(\"Message error in transport port\");\n\t\t};\n\n\t\treturn [\n\t\t\t(data) => {\n\t\t\t\tpostMessage(\n\t\t\t\t\tport,\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"data\",\n\t\t\t\t\t\tdata: data,\n\t\t\t\t\t},\n\t\t\t\t\tdata instanceof ArrayBuffer ? [data] : []\n\t\t\t\t);\n\t\t\t},\n\t\t\t(code) => {\n\t\t\t\tpostMessage(port, {\n\t\t\t\t\ttype: \"close\",\n\t\t\t\t\tcode: code,\n\t\t\t\t});\n\t\t\t},\n\t\t];\n\t}\n\n\tasync request(\n\t\tremote: URL,\n\t\tmethod: string,\n\t\tbody: BodyInit | null,\n\t\theaders: RawHeaders,\n\t\tsignal: AbortSignal | undefined\n\t): Promise<TransferrableResponse> {\n\t\treturn await this.rpc.call(\"request\", {\n\t\t\tremote: remote.href,\n\t\t\tmethod,\n\t\t\tbody,\n\t\t\theaders,\n\t\t});\n\t}\n\n\tmeta() {\n\t\treturn {};\n\t}\n}\n\nconst sw = navigator.serviceWorker.controller;\nconst { SCRAMJETCLIENT, ScramjetClient, CookieJar, setWasm } = $scramjet;\n\ntype Config = any;\ntype Init = {\n\tconfig: Config;\n\tsjconfig: ScramjetConfig;\n\tcookies: string;\n\tprefix: URL;\n\tyieldGetInjectScripts: (\n\t\tcookieJar: CookieJar,\n\t\tconfig: Config,\n\t\tsjconfig: ScramjetConfig,\n\t\tprefix: URL\n\t) => any;\n\tcodecEncode: (input: string) => string;\n\tcodecDecode: (input: string) => string;\n};\n\nexport function load({\n\tconfig,\n\tsjconfig,\n\tcookies,\n\tprefix,\n\tyieldGetInjectScripts,\n\tcodecEncode,\n\tcodecDecode,\n}: Init) {\n\tlet client;\n\tif (SCRAMJETCLIENT in globalThis) {\n\t\tclient = globalThis[SCRAMJETCLIENT];\n\t} else {\n\t\tsetWasm(Uint8Array.from(atob(self.WASM), (c) => c.charCodeAt(0)));\n\t\tdelete self.WASM;\n\n\t\tconst channel = new MessageChannel();\n\t\tconst transport = new RemoteTransport(channel.port1);\n\t\tsw?.postMessage(\n\t\t\t{\n\t\t\t\t$sw$initRemoteTransport: {\n\t\t\t\t\tport: channel.port2,\n\t\t\t\t\tprefix: prefix.href,\n\t\t\t\t},\n\t\t\t},\n\t\t\t[channel.port2]\n\t\t);\n\n\t\tconst cookieJar = new CookieJar();\n\t\tcookieJar.load(cookies);\n\n\t\tconst context = {\n\t\t\tinterface: {\n\t\t\t\tgetInjectScripts: yieldGetInjectScripts(\n\t\t\t\t\tcookieJar,\n\t\t\t\t\tconfig,\n\t\t\t\t\tsjconfig,\n\t\t\t\t\tprefix\n\t\t\t\t),\n\t\t\t\tcodecEncode,\n\t\t\t\tcodecDecode,\n\t\t\t},\n\t\t\tprefix,\n\t\t\tcookieJar,\n\t\t\tconfig: sjconfig,\n\t\t};\n\t\tfunction createFrameId() {\n\t\t\treturn `${Array(8)\n\t\t\t\t.fill(0)\n\t\t\t\t.map(() => Math.floor(Math.random() * 36).toString(36))\n\t\t\t\t.join(\"\")}`;\n\t\t}\n\n\t\tconst frame = globalThis.frameElement as HTMLIFrameElement | null;\n\t\tif (frame && !frame.name) {\n\t\t\tframe.name = createFrameId();\n\t\t}\n\n\t\tclient = new ScramjetClient(globalThis, {\n\t\t\tcontext,\n\t\t\ttransport,\n\t\t\tsendSetCookie: async (url, cookie) => {\n\t\t\t\t// sw.postMessage({\n\t\t\t\t// \t$controller$setCookie: {\n\t\t\t\t// \t\turl,\n\t\t\t\t// \t\tcookie\n\t\t\t\t// \t}\n\t\t\t\t// });\n\t\t\t},\n\t\t\tshouldPassthroughWebsocket: (url) => {\n\t\t\t\treturn url === \"wss://anura.pro/\";\n\t\t\t},\n\t\t\tshouldBlockMessageEvent(i) {\n\t\t\t\treturn false;\n\t\t\t},\n\t\t});\n\n\t\tclient.hook();\n\t}\n}\n"],"names":["RpcHelper","Map","methods","id","sendRaw","data","undefined","dt","type","token","error","cb","Error","method","args","r","err","console","transfer","Promise","resolve","reject","MessagePort_postMessage","MessagePort","postMessage","port","RemoteTransport","ev","url","protocols","requestHeaders","onopen","onmessage","onclose","onerror","channel","MessageChannel","response","message","ArrayBuffer","code","remote","body","headers","signal","sw","navigator","SCRAMJETCLIENT","ScramjetClient","CookieJar","setWasm","$scramjet","load","config","sjconfig","cookies","prefix","yieldGetInjectScripts","codecEncode","codecDecode","client","globalThis","Uint8Array","atob","self","c","transport","cookieJar","context","createFrameId","Array","Math","frame","cookie","i"],"mappings":";;;;;;;;AAsBO,MAAMA;;;;IAIZ,UAAkB,EAAE;IACpB,mBAGI,IAAIC,MAAM;IACd,YACSC,OAAiC,EACjCC,EAAU,EACVC,OAAsD,CAC7D;aAHOF,UAAAA;aACAC,KAAAA;aACAC,UAAAA;IACN;IAEH,QAAQC,IAAS,EAAE;QAClB,IAAIA,SAASC,aAAaD,SAAS,QAAQ,OAAOA,SAAS,UAAU;QACrE,MAAME,KAAKF,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,IAAIE,OAAOD,aAAaC,OAAO,QAAQ,OAAOA,OAAO,UAAU;QAE/D,MAAMC,OAAOD,GAAG,KAAK;QAErB,IAAIC,SAAS,YAAY;YACxB,MAAMC,QAAQF,GAAG,MAAM;YACvB,MAAMF,OAAOE,GAAG,KAAK;YACrB,MAAMG,QAAQH,GAAG,MAAM;YACvB,MAAMI,KAAK,IAAI,CAAC,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,CAACd,eAAe;IACpC,OAAO;QACNG,QAAQY,WAAW,IAAI,CAACC,KAAKC,KAAK,IAAI,GAAG,CAACC,IAAMA,EAAE,UAAU,CAAC;QAC7D,OAAOD,KAAK,IAAI;QAEhB,MAAM7B,UAAU,IAAIC;QACpB,MAAM8B,YAAY,IAAIxC,gBAAgBS,QAAQ,KAAK;QACnDU,IAAI,YACH;YACC,yBAAyB;gBACxB,MAAMV,QAAQ,KAAK;gBACnB,QAAQqB,OAAO,IAAI;YACpB;QACD,GACA;YAACrB,QAAQ,KAAK;SAAC;QAGhB,MAAMgC,YAAY,IAAIlB;QACtBkB,UAAU,IAAI,CAACZ;QAEf,MAAMa,UAAU;YACf,WAAW;gBACV,kBAAkBX,sBACjBU,WACAd,QACAC,UACAE;gBAEDE;gBACAC;YACD;YACAH;YACAW;YACA,QAAQb;QACT;QACA,SAASe;YACR,OAAO,GAAGC,MAAM,GACd,IAAI,CAAC,GACL,GAAG,CAAC,IAAMC,KAAK,KAAK,CAACA,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,KAClD,IAAI,CAAC,KAAK;QACb;QAEA,MAAMC,QAAQX,WAAW,YAAY;QACrC,IAAIW,SAAS,CAACA,MAAM,IAAI,EAAE;YACzBA,MAAM,IAAI,GAAGH;QACd;QAEAT,SAAS,IAAIZ,eAAea,YAAY;YACvCO;YACAF;YACA,eAAe,OAAOtC,KAAK6C;YAC1B,mBAAmB;YACnB,4BAA4B;YAC5B,SAAS;YACT,WAAW;YACX,KAAK;YACL,MAAM;YACP;YACA,4BAA4B,CAAC7C;gBAC5B,OAAOA,QAAQ;YAChB;YACA,yBAAwB8C,CAAC;gBACxB,OAAO;YACR;QACD;QAEAd,OAAO,IAAI;IACZ;AACD"}
@@ -0,0 +1,265 @@
1
+ var $scramjetControllerInit;
2
+ (() => {
3
+ var __webpack_modules__ = ({
4
+ "./packages/scramjet/packages/rpc/index.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5
+ __webpack_require__.r(__webpack_exports__);
6
+ __webpack_require__.d(__webpack_exports__, {
7
+ RpcHelper: () => (RpcHelper)
8
+ });
9
+ class RpcHelper {
10
+ methods;
11
+ id;
12
+ sendRaw;
13
+ counter = 0;
14
+ promiseCallbacks = new Map();
15
+ constructor(methods, id, sendRaw){
16
+ this.methods = methods;
17
+ this.id = id;
18
+ this.sendRaw = sendRaw;
19
+ }
20
+ recieve(data) {
21
+ if (data === undefined || data === null || typeof data !== "object") return;
22
+ const dt = data[this.id];
23
+ if (dt === undefined || dt === null || typeof dt !== "object") return;
24
+ const type = dt.$type;
25
+ if (type === "response") {
26
+ const token = dt.$token;
27
+ const data = dt.$data;
28
+ const error = dt.$error;
29
+ const cb = this.promiseCallbacks.get(token);
30
+ if (!cb) return;
31
+ this.promiseCallbacks.delete(token);
32
+ if (error !== undefined) {
33
+ cb.reject(new Error(error));
34
+ } else {
35
+ cb.resolve(data);
36
+ }
37
+ } else if (type === "request") {
38
+ const method = dt.$method;
39
+ const args = dt.$args;
40
+ this.methods[method](args).then((r)=>{
41
+ this.sendRaw({
42
+ [this.id]: {
43
+ $type: "response",
44
+ $token: dt.$token,
45
+ $data: r?.[0]
46
+ }
47
+ }, r?.[1]);
48
+ }).catch((err)=>{
49
+ console.error(err);
50
+ this.sendRaw({
51
+ [this.id]: {
52
+ $type: "response",
53
+ $token: dt.$token,
54
+ $error: err?.toString() || "Unknown error"
55
+ }
56
+ }, []);
57
+ });
58
+ }
59
+ }
60
+ call(method, args, transfer = []) {
61
+ let token = this.counter++;
62
+ return new Promise((resolve, reject)=>{
63
+ this.promiseCallbacks.set(token, {
64
+ resolve,
65
+ reject
66
+ });
67
+ this.sendRaw({
68
+ [this.id]: {
69
+ $type: "request",
70
+ $method: method,
71
+ $args: args,
72
+ $token: token
73
+ }
74
+ }, transfer);
75
+ });
76
+ }
77
+ }
78
+
79
+
80
+ },
81
+
82
+ });
83
+ // The module cache
84
+ var __webpack_module_cache__ = {};
85
+
86
+ // The require function
87
+ function __webpack_require__(moduleId) {
88
+
89
+ // Check if module is in cache
90
+ var cachedModule = __webpack_module_cache__[moduleId];
91
+ if (cachedModule !== undefined) {
92
+ return cachedModule.exports;
93
+ }
94
+ // Create a new module (and put it into the cache)
95
+ var module = (__webpack_module_cache__[moduleId] = {
96
+ exports: {}
97
+ });
98
+ // Execute the module function
99
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
100
+
101
+ // Return the exports of the module
102
+ return module.exports;
103
+
104
+ }
105
+
106
+ // webpack/runtime/define_property_getters
107
+ (() => {
108
+ __webpack_require__.d = (exports, definition) => {
109
+ for(var key in definition) {
110
+ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
111
+ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
112
+ }
113
+ }
114
+ };
115
+ })();
116
+ // webpack/runtime/has_own_property
117
+ (() => {
118
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
119
+ })();
120
+ // webpack/runtime/make_namespace_object
121
+ (() => {
122
+ // define __esModule on exports
123
+ __webpack_require__.r = (exports) => {
124
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
125
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
126
+ }
127
+ Object.defineProperty(exports, '__esModule', { value: true });
128
+ };
129
+ })();
130
+ var __webpack_exports__ = {};
131
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
132
+ (() => {
133
+ __webpack_require__.r(__webpack_exports__);
134
+ __webpack_require__.d(__webpack_exports__, {
135
+ route: () => (route),
136
+ shouldRoute: () => (shouldRoute)
137
+ });
138
+ /* import */ var _mercuryworkshop_rpc__rspack_import_0 = __webpack_require__("./packages/scramjet/packages/rpc/index.ts");
139
+
140
+ function makeId() {
141
+ return Math.random().toString(36).substring(2, 10);
142
+ }
143
+ let cookieResolvers = {};
144
+ addEventListener("message", (e)=>{
145
+ if (!e.data) return;
146
+ if (typeof e.data != "object") return;
147
+ if (e.data.$sw$setCookieDone && typeof e.data.$sw$setCookieDone == "object") {
148
+ const done = e.data.$sw$setCookieDone;
149
+ const resolver = cookieResolvers[done.id];
150
+ if (resolver) {
151
+ resolver();
152
+ delete cookieResolvers[done.id];
153
+ }
154
+ }
155
+ if (e.data.$sw$initRemoteTransport && typeof e.data.$sw$initRemoteTransport == "object") {
156
+ const { port, prefix } = e.data.$sw$initRemoteTransport;
157
+ console.error(prefix, tabs);
158
+ const relevantcontroller = tabs.find((tab)=>new URL(prefix).pathname.startsWith(tab.prefix));
159
+ if (!relevantcontroller) {
160
+ console.error("No relevant controller found for transport init");
161
+ return;
162
+ }
163
+ relevantcontroller.rpc.call("initRemoteTransport", port, [
164
+ port
165
+ ]);
166
+ }
167
+ });
168
+ class ControllerReference {
169
+ prefix;
170
+ id;
171
+ rpc;
172
+ constructor(prefix, id, port){
173
+ this.prefix = prefix;
174
+ this.id = id;
175
+ this.rpc = new _mercuryworkshop_rpc__rspack_import_0.RpcHelper({
176
+ sendSetCookie: async ({ url, cookie })=>{
177
+ let clients1 = await self.clients.matchAll();
178
+ let promises = [];
179
+ for (const client of clients1){
180
+ let id = makeId();
181
+ client.postMessage({
182
+ $controller$setCookie: {
183
+ url,
184
+ cookie,
185
+ id
186
+ }
187
+ });
188
+ promises.push(new Promise((resolve)=>{
189
+ cookieResolvers[id] = resolve;
190
+ }));
191
+ }
192
+ await Promise.race([
193
+ new Promise((resolve)=>setTimeout(()=>{
194
+ console.error("timed out waiting for set cookie response (deadlock?)");
195
+ resolve();
196
+ }, 1000)),
197
+ promises
198
+ ]);
199
+ }
200
+ }, "tabchannel-" + id, (data, transfer)=>{
201
+ port.postMessage(data, transfer);
202
+ });
203
+ port.addEventListener("message", (e)=>{
204
+ this.rpc.recieve(e.data);
205
+ });
206
+ port.onmessageerror = console.error;
207
+ this.rpc.call("ready", null);
208
+ }
209
+ }
210
+ const tabs = [];
211
+ addEventListener("message", (e)=>{
212
+ if (!e.data) return;
213
+ if (typeof e.data != "object") return;
214
+ if (!e.data.$controller$init) return;
215
+ if (typeof e.data.$controller$init != "object") return;
216
+ const init = e.data.$controller$init;
217
+ tabs.push(new ControllerReference(init.prefix, init.id, e.ports[0]));
218
+ });
219
+ function shouldRoute(event) {
220
+ const url = new URL(event.request.url);
221
+ const tab = tabs.find((tab)=>url.pathname.startsWith(tab.prefix));
222
+ return tab !== undefined;
223
+ }
224
+ async function route(event) {
225
+ try {
226
+ const url = new URL(event.request.url);
227
+ const tab = tabs.find((tab)=>url.pathname.startsWith(tab.prefix));
228
+ const client = await clients.get(event.clientId);
229
+ const rawheaders = [
230
+ ...event.request.headers
231
+ ];
232
+ const response = await tab.rpc.call("request", {
233
+ rawUrl: event.request.url,
234
+ destination: event.request.destination,
235
+ mode: event.request.mode,
236
+ referrer: event.request.referrer,
237
+ method: event.request.method,
238
+ body: event.request.body,
239
+ cache: event.request.cache,
240
+ forceCrossOriginIsolated: false,
241
+ initialHeaders: rawheaders,
242
+ rawClientUrl: client ? client.url : undefined
243
+ }, event.request.body instanceof ReadableStream || // @ts-expect-error the types for fetchevent are messed up
244
+ event.request.body instanceof ArrayBuffer ? [
245
+ event.request.body
246
+ ] : undefined);
247
+ return new Response(response.body, {
248
+ status: response.status,
249
+ statusText: response.statusText,
250
+ headers: response.headers
251
+ });
252
+ } catch (e) {
253
+ console.error("Service Worker error:", e);
254
+ return new Response("Internal Service Worker Error: " + e.message, {
255
+ status: 500
256
+ });
257
+ }
258
+ }
259
+
260
+ })();
261
+
262
+ $scramjetControllerInit = __webpack_exports__;
263
+ })()
264
+ ;
265
+ //# sourceMappingURL=controller.sw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"controller.sw.js","sources":["webpack://$scramjetControllerInit/./packages/scramjet/packages/rpc/index.ts","webpack://$scramjetControllerInit/webpack/runtime/define_property_getters","webpack://$scramjetControllerInit/webpack/runtime/has_own_property","webpack://$scramjetControllerInit/webpack/runtime/make_namespace_object","webpack://$scramjetControllerInit/./packages/scramjet/packages/controller/src/sw.ts"],"sourcesContent":["type Serverbound = {\n\tmethod1: [{ paramA: string; paramB: number }, boolean];\n\tmethod2: [string, number];\n};\n\ntype Clientbound = {\n\tmethod1: [number];\n\tmethod2: [boolean, string];\n};\n\nexport type RpcDescription = {\n\t[method: string]: [args: any, returnType: any] | [args: any] | [];\n};\n\nexport type MethodsDefinition<Description extends RpcDescription> = {\n\t[Method in keyof Description]: (\n\t\t...args: Description[Method] extends [infer A, ...any[]] ? [A] : []\n\t) => Description[Method] extends [any, infer R]\n\t\t? Promise<[R, Transferable[]]>\n\t\t: Promise<void>;\n};\n\nexport class RpcHelper<\n\tLocal extends RpcDescription,\n\tRemote extends RpcDescription,\n> {\n\tcounter: number = 0;\n\tpromiseCallbacks: Map<\n\t\tnumber,\n\t\t{ resolve: (value: any) => void; reject: (reason?: any) => void }\n\t> = new Map();\n\tconstructor(\n\t\tprivate methods: MethodsDefinition<Local>,\n\t\tprivate id: string,\n\t\tprivate sendRaw: (data: any, transfer: Transferable[]) => void\n\t) {}\n\n\trecieve(data: any) {\n\t\tif (data === undefined || data === null || typeof data !== \"object\") return;\n\t\tconst dt = data[this.id];\n\t\tif (dt === undefined || dt === null || typeof dt !== \"object\") return;\n\n\t\tconst type = dt.$type;\n\n\t\tif (type === \"response\") {\n\t\t\tconst token = dt.$token;\n\t\t\tconst data = dt.$data;\n\t\t\tconst error = dt.$error;\n\t\t\tconst cb = this.promiseCallbacks.get(token);\n\t\t\tif (!cb) return;\n\t\t\tthis.promiseCallbacks.delete(token);\n\t\t\tif (error !== undefined) {\n\t\t\t\tcb.reject(new Error(error));\n\t\t\t} else {\n\t\t\t\tcb.resolve(data);\n\t\t\t}\n\t\t} else if (type === \"request\") {\n\t\t\tconst method = dt.$method as keyof Local;\n\t\t\tconst args = dt.$args as Local[typeof method][0];\n\t\t\t(this.methods[method] as any)(args)\n\t\t\t\t.then((r: any) => {\n\t\t\t\t\tthis.sendRaw(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t\t\t$type: \"response\",\n\t\t\t\t\t\t\t\t$token: dt.$token,\n\t\t\t\t\t\t\t\t$data: r?.[0],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tr?.[1]\n\t\t\t\t\t);\n\t\t\t\t})\n\t\t\t\t.catch((err: any) => {\n\t\t\t\t\tconsole.error(err);\n\t\t\t\t\tthis.sendRaw(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t\t\t$type: \"response\",\n\t\t\t\t\t\t\t\t$token: dt.$token,\n\t\t\t\t\t\t\t\t$error: err?.toString() || \"Unknown error\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t[]\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t}\n\t}\n\n\tcall<Method extends keyof Remote>(\n\t\tmethod: Method,\n\t\targs: Remote[Method][0],\n\t\ttransfer: Transferable[] = []\n\t): Promise<Remote[Method][1]> {\n\t\tlet token = this.counter++;\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis.promiseCallbacks.set(token, { resolve, reject });\n\t\t\tthis.sendRaw(\n\t\t\t\t{\n\t\t\t\t\t[this.id]: {\n\t\t\t\t\t\t$type: \"request\",\n\t\t\t\t\t\t$method: method,\n\t\t\t\t\t\t$args: args,\n\t\t\t\t\t\t$token: token,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\ttransfer\n\t\t\t);\n\t\t});\n\t}\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","declare var clients: Clients;\nimport { RpcHelper } from \"@mercuryworkshop/rpc\";\nimport type { Controllerbound, SWbound } from \"./types\";\nimport type { RawHeaders } from \"@mercuryworkshop/proxy-transports\";\nimport { ScramjetHeaders } from \"@mercuryworkshop/scramjet\";\n\nfunction makeId(): string {\n\treturn Math.random().toString(36).substring(2, 10);\n}\n\nlet cookieResolvers: Record<string, (value: void) => void> = {};\naddEventListener(\"message\", (e) => {\n\tif (!e.data) return;\n\tif (typeof e.data != \"object\") return;\n\tif (e.data.$sw$setCookieDone && typeof e.data.$sw$setCookieDone == \"object\") {\n\t\tconst done = e.data.$sw$setCookieDone;\n\n\t\tconst resolver = cookieResolvers[done.id];\n\t\tif (resolver) {\n\t\t\tresolver();\n\t\t\tdelete cookieResolvers[done.id];\n\t\t}\n\t}\n\n\tif (\n\t\te.data.$sw$initRemoteTransport &&\n\t\ttypeof e.data.$sw$initRemoteTransport == \"object\"\n\t) {\n\t\tconst { port, prefix } = e.data.$sw$initRemoteTransport;\n\n\t\tconsole.error(prefix, tabs);\n\t\tconst relevantcontroller = tabs.find((tab) =>\n\t\t\tnew URL(prefix).pathname.startsWith(tab.prefix)\n\t\t);\n\t\tif (!relevantcontroller) {\n\t\t\tconsole.error(\"No relevant controller found for transport init\");\n\t\t\treturn;\n\t\t}\n\t\trelevantcontroller.rpc.call(\"initRemoteTransport\", port, [port]);\n\t}\n});\n\nclass ControllerReference {\n\trpc: RpcHelper<SWbound, Controllerbound>;\n\n\tconstructor(\n\t\tpublic prefix: string,\n\t\tpublic id: string,\n\t\tport: MessagePort\n\t) {\n\t\tthis.rpc = new RpcHelper(\n\t\t\t{\n\t\t\t\tsendSetCookie: async ({ url, cookie }) => {\n\t\t\t\t\tlet clients = await self.clients.matchAll();\n\t\t\t\t\tlet promises = [];\n\n\t\t\t\t\tfor (const client of clients) {\n\t\t\t\t\t\tlet id = makeId();\n\t\t\t\t\t\tclient.postMessage({\n\t\t\t\t\t\t\t$controller$setCookie: {\n\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\tcookie,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t});\n\t\t\t\t\t\tpromises.push(\n\t\t\t\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\t\t\t\tcookieResolvers[id] = resolve;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait Promise.race([\n\t\t\t\t\t\tnew Promise<void>((resolve) =>\n\t\t\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t\t\t\"timed out waiting for set cookie response (deadlock?)\"\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t}, 1000)\n\t\t\t\t\t\t),\n\t\t\t\t\t\tpromises,\n\t\t\t\t\t]);\n\t\t\t\t},\n\t\t\t},\n\t\t\t\"tabchannel-\" + id,\n\t\t\t(data, transfer) => {\n\t\t\t\tport.postMessage(data, transfer);\n\t\t\t}\n\t\t);\n\t\tport.addEventListener(\"message\", (e) => {\n\t\t\tthis.rpc.recieve(e.data);\n\t\t});\n\t\tport.onmessageerror = console.error;\n\n\t\tthis.rpc.call(\"ready\", null);\n\t}\n}\n\nconst tabs: ControllerReference[] = [];\n\naddEventListener(\"message\", (e) => {\n\tif (!e.data) return;\n\tif (typeof e.data != \"object\") return;\n\tif (!e.data.$controller$init) return;\n\tif (typeof e.data.$controller$init != \"object\") return;\n\tconst init = e.data.$controller$init;\n\n\ttabs.push(new ControllerReference(init.prefix, init.id, e.ports[0]));\n});\n\nexport function shouldRoute(event: FetchEvent): boolean {\n\tconst url = new URL(event.request.url);\n\tconst tab = tabs.find((tab) => url.pathname.startsWith(tab.prefix));\n\treturn tab !== undefined;\n}\n\nexport async function route(event: FetchEvent): Promise<Response> {\n\ttry {\n\t\tconst url = new URL(event.request.url);\n\t\tconst tab = tabs.find((tab) => url.pathname.startsWith(tab.prefix))!;\n\t\tconst client = await clients.get(event.clientId);\n\n\t\tconst rawheaders: RawHeaders = [...event.request.headers];\n\n\t\tconst response = await tab.rpc.call(\n\t\t\t\"request\",\n\t\t\t{\n\t\t\t\trawUrl: event.request.url,\n\t\t\t\tdestination: event.request.destination,\n\t\t\t\tmode: event.request.mode,\n\t\t\t\treferrer: event.request.referrer,\n\t\t\t\tmethod: event.request.method,\n\t\t\t\tbody: event.request.body,\n\t\t\t\tcache: event.request.cache,\n\t\t\t\tforceCrossOriginIsolated: false,\n\t\t\t\tinitialHeaders: rawheaders,\n\t\t\t\trawClientUrl: client ? client.url : undefined,\n\t\t\t},\n\t\t\tevent.request.body instanceof ReadableStream ||\n\t\t\t\t// @ts-expect-error the types for fetchevent are messed up\n\t\t\t\tevent.request.body instanceof ArrayBuffer\n\t\t\t\t? [event.request.body]\n\t\t\t\t: undefined\n\t\t);\n\n\t\treturn new Response(response.body, {\n\t\t\tstatus: response.status,\n\t\t\tstatusText: response.statusText,\n\t\t\theaders: response.headers,\n\t\t});\n\t} catch (e) {\n\t\tconsole.error(\"Service Worker error:\", e);\n\t\treturn new Response(\n\t\t\t\"Internal Service Worker Error: \" + (e as Error).message,\n\t\t\t{\n\t\t\t\tstatus: 500,\n\t\t\t}\n\t\t);\n\t}\n}\n"],"names":["RpcHelper","Map","methods","id","sendRaw","data","undefined","dt","type","token","error","cb","Error","method","args","r","err","console","transfer","Promise","resolve","reject","makeId","Math","cookieResolvers","addEventListener","e","done","resolver","port","prefix","tabs","relevantcontroller","tab","URL","ControllerReference","url","cookie","clients1","self","promises","client","setTimeout","init","shouldRoute","event","route","clients","rawheaders","response","ReadableStream","ArrayBuffer","Response"],"mappings":";;;;;;;;AAsBO,MAAMA;;;;IAIZ,UAAkB,EAAE;IACpB,mBAGI,IAAIC,MAAM;IACd,YACSC,OAAiC,EACjCC,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OAAOA,MAAM,OAAO,CAAC,KAAK;YAC1B,0BAA0B;YAC1B,gBAAgBG;YAChB,cAAcP,SAASA,OAAO,GAAG,GAAGnC;QACrC,GACAuC,MAAM,OAAO,CAAC,IAAI,YAAYK,kBAC7B,0DAA0D;QAC1DL,MAAM,OAAO,CAAC,IAAI,YAAYM,cAC5B;YAACN,MAAM,OAAO,CAAC,IAAI;SAAC,GACpBvC;QAGJ,OAAO,IAAI8C,SAASH,SAAS,IAAI,EAAE;YAClC,QAAQA,SAAS,MAAM;YACvB,YAAYA,SAAS,UAAU;YAC/B,SAASA,SAAS,OAAO;QAC1B;IACD,EAAE,OAAOvB,GAAG;QACXT,QAAQ,KAAK,CAAC,yBAAyBS;QACvC,OAAO,IAAI0B,SACV,oCAAqC1B,EAAY,OAAO,EACxD;YACC,QAAQ;QACT;IAEF;AACD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercuryworkshop/scramjet-controller",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "dependencies": {