reflected 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/async-CM1iXZPW.js +44 -0
- package/dist/async-OLiknCrf.js +41 -0
- package/dist/async.js +856 -1
- package/dist/broadcast-B4sl9DBp.js +24 -0
- package/dist/broadcast-eR5_7TCY.js +15 -0
- package/dist/broadcast.js +850 -1
- package/dist/ffi/async-0Q0H4a_N.js +41 -0
- package/dist/ffi/async-CbwemiL2.js +41 -0
- package/dist/ffi/async-D6Zj6i_Q.js +44 -0
- package/dist/ffi/async-DLrN8K6M.js +44 -0
- package/dist/ffi/broadcast-CKNplfox.js +15 -0
- package/dist/ffi/broadcast-CbbtYobq.js +25 -0
- package/dist/ffi/broadcast-DIucqhL0.js +25 -0
- package/dist/ffi/broadcast-uydYnG6E.js +15 -0
- package/dist/ffi/global-DzpOeFX2.js +14 -0
- package/dist/ffi/global-LTfnrHcF.js +11 -0
- package/dist/ffi/i32-Cw-Rqr5y.js +13 -0
- package/dist/ffi/main.js +650 -1
- package/dist/ffi/message-2Dqj3uZ3.js +15 -0
- package/dist/ffi/message-Co0Oew7f.js +25 -0
- package/dist/ffi/message-Cxjrx_su.js +25 -0
- package/dist/ffi/message-mK0eTb54.js +15 -0
- package/dist/ffi/sender-B7Xmjz4q.js +194 -0
- package/dist/ffi/sender-C0gu9RzR.js +194 -0
- package/dist/ffi/shared-5Nhc4gvB.js +175 -0
- package/dist/ffi/shared-B3KmQkGh.js +425 -0
- package/dist/ffi/shared-CjWXp6-D.js +171 -0
- package/dist/ffi/shared-Czh3AlGt.js +53 -0
- package/dist/ffi/shared-DZdgWBc6.js +53 -0
- package/dist/ffi/shared-array-buffer-BQgQXQvC.js +28 -0
- package/dist/ffi/shared-ddawRQD0.js +425 -0
- package/dist/ffi/views-C3SJnvMr.js +48 -0
- package/dist/ffi/views-DBBYng9N.js +52 -0
- package/dist/ffi/worker.js +616 -1
- package/dist/ffi/xhr-Be-3qHQb.js +101 -0
- package/dist/ffi/xhr-CKhf21P8.js +41 -0
- package/dist/ffi/xhr-CRJGE1xP.js +41 -0
- package/dist/ffi/xhr-DSsSGsb-.js +101 -0
- package/dist/i32-UV5fM9Tw.js +12 -0
- package/dist/index.js +57 -1
- package/dist/message-D_SM4ST4.js +24 -0
- package/dist/message-vCWcUEmt.js +15 -0
- package/dist/message.js +843 -1
- package/dist/proxy/main/async-8J3q5T6q.js +41 -0
- package/dist/proxy/main/async-Di4MuQWe.js +44 -0
- package/dist/proxy/main/broadcast-CR8vlkKk.js +24 -0
- package/dist/proxy/main/broadcast-LNW6nFVD.js +15 -0
- package/dist/proxy/main/channel-NcnPEVL4.js +110 -0
- package/dist/proxy/main/i32-UV5fM9Tw.js +12 -0
- package/dist/proxy/main/message-j-4BYSZ4.js +24 -0
- package/dist/proxy/main/message-uirwoNUQ.js +15 -0
- package/dist/proxy/main/proxy.js +106 -1
- package/dist/proxy/main/sender-Dkjjbv2Y.js +194 -0
- package/dist/proxy/main/shared-C3U1MNPd.js +53 -0
- package/dist/proxy/main/shared-CV7CPYuP.js +43 -0
- package/dist/proxy/main/shared-DdPca9Ke.js +431 -0
- package/dist/proxy/main/shared-array-buffer-BQgQXQvC.js +28 -0
- package/dist/proxy/main/xhr-BUjEbkCh.js +100 -0
- package/dist/proxy/main/xhr-WnkM0dVo.js +41 -0
- package/dist/proxy/worker/async-CZJaURwO.js +41 -0
- package/dist/proxy/worker/async-DaSAye0a.js +44 -0
- package/dist/proxy/worker/broadcast-DRVfswix.js +24 -0
- package/dist/proxy/worker/broadcast-fWsZlH8v.js +15 -0
- package/dist/proxy/worker/channel-NcnPEVL4.js +110 -0
- package/dist/proxy/worker/i32-UV5fM9Tw.js +12 -0
- package/dist/proxy/worker/message-Bots8UXM.js +15 -0
- package/dist/proxy/worker/message-sej0J6k5.js +24 -0
- package/dist/proxy/worker/proxy.js +79 -1
- package/dist/proxy/worker/sender-D5Lm-DmC.js +194 -0
- package/dist/proxy/worker/shared-CgOGpfKJ.js +431 -0
- package/dist/proxy/worker/shared-Cn1K0k8G.js +53 -0
- package/dist/proxy/worker/shared-DR7YYduq.js +41 -0
- package/dist/proxy/worker/shared-array-buffer-BQgQXQvC.js +28 -0
- package/dist/proxy/worker/xhr-CQDzS28h.js +100 -0
- package/dist/proxy/worker/xhr-DAgmljtu.js +41 -0
- package/dist/sender-BSx3lj4w.js +193 -0
- package/dist/shared-Ccm1cPah.js +125 -0
- package/dist/shared-DVDPRDN_.js +53 -0
- package/dist/shared-L0wiAfqu.js +431 -0
- package/dist/shared-array-buffer-BQgQXQvC.js +28 -0
- package/dist/sw.js +155 -1
- package/dist/with-resolvers-DsO_nhbc.js +24 -0
- package/dist/xhr-BZOjL92j.js +100 -0
- package/dist/xhr-Crh-419R.js +41 -0
- package/dist/xhr.js +909 -1
- package/package.json +1 -1
- package/reflected.tar.gz +0 -0
- package/dist/async-C2eqvaGm.js +0 -1
- package/dist/async-s2VCmNNG.js +0 -1
- package/dist/broadcast-CArZGSOF.js +0 -1
- package/dist/broadcast-f7NecPmf.js +0 -1
- package/dist/ffi/async-B_TI4xaG.js +0 -1
- package/dist/ffi/async-BeKYhv9s.js +0 -1
- package/dist/ffi/async-Dl9wCRDA.js +0 -1
- package/dist/ffi/async-F0rxZjV9.js +0 -1
- package/dist/ffi/broadcast-CBUwPa0e.js +0 -1
- package/dist/ffi/broadcast-Ce_cOurt.js +0 -1
- package/dist/ffi/broadcast-D0jZEoUb.js +0 -1
- package/dist/ffi/broadcast-D7p6b88J.js +0 -1
- package/dist/ffi/global-B3nXXiRL.js +0 -1
- package/dist/ffi/global-Bs8RLRoX.js +0 -1
- package/dist/ffi/i32-BkNtpHwD.js +0 -1
- package/dist/ffi/message-BdbPt0y5.js +0 -1
- package/dist/ffi/message-DNbm1E-6.js +0 -1
- package/dist/ffi/message-DW2TgKPr.js +0 -1
- package/dist/ffi/message-TyU9xCIl.js +0 -1
- package/dist/ffi/sender-C5EHIpuL.js +0 -1
- package/dist/ffi/sender-DBFDKow4.js +0 -1
- package/dist/ffi/shared-BfrghvHB.js +0 -1
- package/dist/ffi/shared-C2XCOXcu.js +0 -1
- package/dist/ffi/shared-Cs1s8cy4.js +0 -1
- package/dist/ffi/shared-DsgUjYDJ.js +0 -1
- package/dist/ffi/shared-DwSbyGXy.js +0 -1
- package/dist/ffi/shared-DyOzpRO0.js +0 -1
- package/dist/ffi/shared-array-buffer-cwdMr2mc.js +0 -1
- package/dist/ffi/views-CdOIrBQR.js +0 -1
- package/dist/ffi/views-Cr2pQ4B-.js +0 -1
- package/dist/ffi/xhr-BkOoxiJZ.js +0 -1
- package/dist/ffi/xhr-C598zZcp.js +0 -1
- package/dist/ffi/xhr-CasCWs_z.js +0 -1
- package/dist/ffi/xhr-DHyu_Jz0.js +0 -1
- package/dist/i32-C78nBJH2.js +0 -1
- package/dist/message-RcKwy8Ib.js +0 -1
- package/dist/message-l7W12V0c.js +0 -1
- package/dist/proxy/main/async-Bc0QcTaC.js +0 -1
- package/dist/proxy/main/async-CyZdYOvJ.js +0 -1
- package/dist/proxy/main/broadcast-BX9FmxMK.js +0 -1
- package/dist/proxy/main/broadcast-DXhTouQy.js +0 -1
- package/dist/proxy/main/channel-DQBWE7_E.js +0 -1
- package/dist/proxy/main/i32-C78nBJH2.js +0 -1
- package/dist/proxy/main/message-CbPHeJAY.js +0 -1
- package/dist/proxy/main/message-DxRlOVN7.js +0 -1
- package/dist/proxy/main/sender-CNwZwCuI.js +0 -1
- package/dist/proxy/main/shared-BoatDt-V.js +0 -1
- package/dist/proxy/main/shared-FMegJ6yb.js +0 -1
- package/dist/proxy/main/shared-array-buffer-cwdMr2mc.js +0 -1
- package/dist/proxy/main/shared-z_jGYqUa.js +0 -1
- package/dist/proxy/main/xhr-BaBkekSn.js +0 -1
- package/dist/proxy/main/xhr-Fg-l74MV.js +0 -1
- package/dist/proxy/worker/async-Do59YjcF.js +0 -1
- package/dist/proxy/worker/async-fqI-s7gn.js +0 -1
- package/dist/proxy/worker/broadcast-Bdt9gmj_.js +0 -1
- package/dist/proxy/worker/broadcast-D7rjohJL.js +0 -1
- package/dist/proxy/worker/channel-DQBWE7_E.js +0 -1
- package/dist/proxy/worker/i32-C78nBJH2.js +0 -1
- package/dist/proxy/worker/message-BvU2dKHz.js +0 -1
- package/dist/proxy/worker/message-DhtuceT9.js +0 -1
- package/dist/proxy/worker/sender-CWhM7QKB.js +0 -1
- package/dist/proxy/worker/shared-DDIlHBz4.js +0 -1
- package/dist/proxy/worker/shared-NtUlwI0Z.js +0 -1
- package/dist/proxy/worker/shared-QrUiXPgc.js +0 -1
- package/dist/proxy/worker/shared-array-buffer-cwdMr2mc.js +0 -1
- package/dist/proxy/worker/xhr-CK-Z6L0B.js +0 -1
- package/dist/proxy/worker/xhr-JKtROQ3y.js +0 -1
- package/dist/sender-D7tfUn3T.js +0 -1
- package/dist/shared-BCEcO4-0.js +0 -1
- package/dist/shared-BWvJKuCK.js +0 -1
- package/dist/shared-BhhIigP4.js +0 -1
- package/dist/shared-array-buffer-cwdMr2mc.js +0 -1
- package/dist/with-resolvers-CHEvl4oe.js +0 -1
- package/dist/xhr-Bd0lMv0-.js +0 -1
- package/dist/xhr-DaixJn9d.js +0 -1
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { w as withResolvers } from './with-resolvers-DsO_nhbc.js';
|
|
2
|
+
import { W as Worker$1, S as SAB } from './async-CM1iXZPW.js';
|
|
3
|
+
import { v as randomUUID, b as byteOffset, t as SHARED_CHANNEL } from './shared-Ccm1cPah.js';
|
|
4
|
+
import { S as Sender, h as handler, u as url, p as post } from './shared-L0wiAfqu.js';
|
|
5
|
+
import './shared-array-buffer-BQgQXQvC.js';
|
|
6
|
+
import './i32-UV5fM9Tw.js';
|
|
7
|
+
|
|
8
|
+
const CHANNEL = 'xhr';
|
|
9
|
+
|
|
10
|
+
const channels = new Map;
|
|
11
|
+
|
|
12
|
+
const sharedBC = new BroadcastChannel(SHARED_CHANNEL);
|
|
13
|
+
sharedBC.addEventListener('message', async ({ data: [op, details] }) => {
|
|
14
|
+
if (op === 'request') {
|
|
15
|
+
const [uid, [id, channel]] = details;
|
|
16
|
+
const responses = channels.get(channel);
|
|
17
|
+
if (responses) {
|
|
18
|
+
const promise = responses.get(id);
|
|
19
|
+
responses.delete(id);
|
|
20
|
+
sharedBC.postMessage(['response', [uid, await promise]]);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const { promise: sw, resolve } = withResolvers();
|
|
26
|
+
let init = true;
|
|
27
|
+
|
|
28
|
+
const activate = (swc, options) => {
|
|
29
|
+
let w, c = true, { url } = options;
|
|
30
|
+
swc.getRegistration(url)
|
|
31
|
+
.then(r => (r ?? swc.register(url, options)))
|
|
32
|
+
.then(function ready(r) {
|
|
33
|
+
const { controller } = swc;
|
|
34
|
+
c = c && !!controller;
|
|
35
|
+
w = (r.installing || r.waiting || r.active);
|
|
36
|
+
if (!w) return activate(swc, options);
|
|
37
|
+
if (w.state === 'activated') {
|
|
38
|
+
if (c) {
|
|
39
|
+
// allow ServiceWorker swap on different URL
|
|
40
|
+
if (controller.scriptURL === url)
|
|
41
|
+
return resolve();
|
|
42
|
+
r.unregister();
|
|
43
|
+
}
|
|
44
|
+
location.reload();
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
w.addEventListener('statechange', () => ready(r), { once: true });
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
class Worker extends Sender {
|
|
53
|
+
#channel;
|
|
54
|
+
constructor(scriptURL, options, resolve) {
|
|
55
|
+
if (init) {
|
|
56
|
+
init = false;
|
|
57
|
+
let { serviceWorker } = options;
|
|
58
|
+
if (!serviceWorker) {
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
return new Worker$1(scriptURL, options, resolve);
|
|
61
|
+
}
|
|
62
|
+
if (typeof serviceWorker === 'string') serviceWorker = { url: serviceWorker };
|
|
63
|
+
serviceWorker.url = new URL(serviceWorker.url, location.href).href;
|
|
64
|
+
activate(navigator.serviceWorker, serviceWorker);
|
|
65
|
+
}
|
|
66
|
+
const channel = randomUUID();
|
|
67
|
+
const bc = new BroadcastChannel(channel);
|
|
68
|
+
const sab = SAB(options);
|
|
69
|
+
const responses = new Map;
|
|
70
|
+
const i32a = new Int32Array(sab);
|
|
71
|
+
const handle = handler(sab, options, false);
|
|
72
|
+
channels.set(channel, responses);
|
|
73
|
+
bc.addEventListener('message', async ({ data: [id, payload] }) => {
|
|
74
|
+
const { promise, resolve } = withResolvers();
|
|
75
|
+
responses.set(id, promise);
|
|
76
|
+
await handle({ data: payload });
|
|
77
|
+
resolve(new Uint8Array(sab, byteOffset, i32a[1]));
|
|
78
|
+
});
|
|
79
|
+
super(...url(scriptURL, CHANNEL, options));
|
|
80
|
+
super.addEventListener('message', () => resolve(this), { once: true });
|
|
81
|
+
super.postMessage(post(sab, options).concat(channel));
|
|
82
|
+
this.#channel = channel;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
terminate() {
|
|
86
|
+
channels.delete(this.#channel);
|
|
87
|
+
super.terminate();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
get channel() {
|
|
91
|
+
return CHANNEL;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
var xhr = (scriptURL, options) => {
|
|
95
|
+
const { promise, resolve } = withResolvers();
|
|
96
|
+
const worker = new Worker(scriptURL, options, resolve);
|
|
97
|
+
return worker instanceof Worker$1 ? promise : sw.then(() => promise);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export { xhr as default };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { w as withResolvers } from './with-resolvers-DsO_nhbc.js';
|
|
2
|
+
import { s as sender, d as decoder } from './sender-BSx3lj4w.js';
|
|
3
|
+
import { i as i32 } from './i32-UV5fM9Tw.js';
|
|
4
|
+
import './shared-Ccm1cPah.js';
|
|
5
|
+
|
|
6
|
+
const { parse, stringify } = JSON;
|
|
7
|
+
|
|
8
|
+
const { promise, resolve } = withResolvers();
|
|
9
|
+
|
|
10
|
+
addEventListener(
|
|
11
|
+
'message',
|
|
12
|
+
({ data: [_, main, channel] }) => resolve([main, channel]),
|
|
13
|
+
{ once: true }
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
const channel = 'xhr';
|
|
17
|
+
|
|
18
|
+
const handle = (channel, options) => {
|
|
19
|
+
const bc = new BroadcastChannel(channel);
|
|
20
|
+
const next = i32();
|
|
21
|
+
const decode = (options.decoder ?? decoder)({ byteOffset: 0 });
|
|
22
|
+
const { serviceWorker } = options;
|
|
23
|
+
return (payload, ...rest) => {
|
|
24
|
+
const id = next();
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
bc.postMessage([id, payload], ...rest);
|
|
27
|
+
const xhr = new XMLHttpRequest;
|
|
28
|
+
xhr.open('POST', serviceWorker, false);
|
|
29
|
+
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
30
|
+
xhr.send(stringify([id, channel]));
|
|
31
|
+
const { length, buffer } = new Uint8Array(parse(xhr.responseText));
|
|
32
|
+
return options.onsync(length ? decode(length, buffer) : void 0);
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var xhr = options => promise.then(([main, channel]) => {
|
|
37
|
+
postMessage(1);
|
|
38
|
+
return handle(channel, sender({ ...main, ...options }));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export { channel, xhr as default };
|