reflected 0.2.4 → 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.
Files changed (162) hide show
  1. package/dist/async-CM1iXZPW.js +44 -0
  2. package/dist/async-OLiknCrf.js +41 -0
  3. package/dist/async.js +856 -1
  4. package/dist/broadcast-B4sl9DBp.js +24 -0
  5. package/dist/broadcast-eR5_7TCY.js +15 -0
  6. package/dist/broadcast.js +850 -1
  7. package/dist/ffi/async-0Q0H4a_N.js +41 -0
  8. package/dist/ffi/async-CbwemiL2.js +41 -0
  9. package/dist/ffi/async-D6Zj6i_Q.js +44 -0
  10. package/dist/ffi/async-DLrN8K6M.js +44 -0
  11. package/dist/ffi/broadcast-CKNplfox.js +15 -0
  12. package/dist/ffi/broadcast-CbbtYobq.js +25 -0
  13. package/dist/ffi/broadcast-DIucqhL0.js +25 -0
  14. package/dist/ffi/broadcast-uydYnG6E.js +15 -0
  15. package/dist/ffi/global-DzpOeFX2.js +14 -0
  16. package/dist/ffi/global-LTfnrHcF.js +11 -0
  17. package/dist/ffi/i32-Cw-Rqr5y.js +13 -0
  18. package/dist/ffi/main.js +650 -1
  19. package/dist/ffi/message-2Dqj3uZ3.js +15 -0
  20. package/dist/ffi/message-Co0Oew7f.js +25 -0
  21. package/dist/ffi/message-Cxjrx_su.js +25 -0
  22. package/dist/ffi/message-mK0eTb54.js +15 -0
  23. package/dist/ffi/sender-B7Xmjz4q.js +194 -0
  24. package/dist/ffi/sender-C0gu9RzR.js +194 -0
  25. package/dist/ffi/shared-5Nhc4gvB.js +175 -0
  26. package/dist/ffi/shared-B3KmQkGh.js +425 -0
  27. package/dist/ffi/shared-CjWXp6-D.js +171 -0
  28. package/dist/ffi/shared-Czh3AlGt.js +53 -0
  29. package/dist/ffi/shared-DZdgWBc6.js +53 -0
  30. package/dist/ffi/shared-array-buffer-BQgQXQvC.js +28 -0
  31. package/dist/ffi/shared-ddawRQD0.js +425 -0
  32. package/dist/ffi/views-C3SJnvMr.js +48 -0
  33. package/dist/ffi/views-DBBYng9N.js +52 -0
  34. package/dist/ffi/worker.js +616 -1
  35. package/dist/ffi/xhr-Be-3qHQb.js +101 -0
  36. package/dist/ffi/xhr-CKhf21P8.js +41 -0
  37. package/dist/ffi/xhr-CRJGE1xP.js +41 -0
  38. package/dist/ffi/xhr-DSsSGsb-.js +101 -0
  39. package/dist/i32-UV5fM9Tw.js +12 -0
  40. package/dist/index.js +57 -1
  41. package/dist/message-D_SM4ST4.js +24 -0
  42. package/dist/message-vCWcUEmt.js +15 -0
  43. package/dist/message.js +843 -1
  44. package/dist/proxy/main/async-8J3q5T6q.js +41 -0
  45. package/dist/proxy/main/async-Di4MuQWe.js +44 -0
  46. package/dist/proxy/main/broadcast-CR8vlkKk.js +24 -0
  47. package/dist/proxy/main/broadcast-LNW6nFVD.js +15 -0
  48. package/dist/proxy/main/channel-NcnPEVL4.js +110 -0
  49. package/dist/proxy/main/i32-UV5fM9Tw.js +12 -0
  50. package/dist/proxy/main/message-j-4BYSZ4.js +24 -0
  51. package/dist/proxy/main/message-uirwoNUQ.js +15 -0
  52. package/dist/proxy/main/proxy.js +106 -1
  53. package/dist/proxy/main/sender-Dkjjbv2Y.js +194 -0
  54. package/dist/proxy/main/shared-C3U1MNPd.js +53 -0
  55. package/dist/proxy/main/shared-CV7CPYuP.js +43 -0
  56. package/dist/proxy/main/shared-DdPca9Ke.js +431 -0
  57. package/dist/proxy/main/shared-array-buffer-BQgQXQvC.js +28 -0
  58. package/dist/proxy/main/xhr-BUjEbkCh.js +100 -0
  59. package/dist/proxy/main/xhr-WnkM0dVo.js +41 -0
  60. package/dist/proxy/worker/async-CZJaURwO.js +41 -0
  61. package/dist/proxy/worker/async-DaSAye0a.js +44 -0
  62. package/dist/proxy/worker/broadcast-DRVfswix.js +24 -0
  63. package/dist/proxy/worker/broadcast-fWsZlH8v.js +15 -0
  64. package/dist/proxy/worker/channel-NcnPEVL4.js +110 -0
  65. package/dist/proxy/worker/i32-UV5fM9Tw.js +12 -0
  66. package/dist/proxy/worker/message-Bots8UXM.js +15 -0
  67. package/dist/proxy/worker/message-sej0J6k5.js +24 -0
  68. package/dist/proxy/worker/proxy.js +79 -1
  69. package/dist/proxy/worker/sender-D5Lm-DmC.js +194 -0
  70. package/dist/proxy/worker/shared-CgOGpfKJ.js +431 -0
  71. package/dist/proxy/worker/shared-Cn1K0k8G.js +53 -0
  72. package/dist/proxy/worker/shared-DR7YYduq.js +41 -0
  73. package/dist/proxy/worker/shared-array-buffer-BQgQXQvC.js +28 -0
  74. package/dist/proxy/worker/xhr-CQDzS28h.js +100 -0
  75. package/dist/proxy/worker/xhr-DAgmljtu.js +41 -0
  76. package/dist/sender-BSx3lj4w.js +193 -0
  77. package/dist/shared-Ccm1cPah.js +125 -0
  78. package/dist/shared-DVDPRDN_.js +53 -0
  79. package/dist/shared-L0wiAfqu.js +431 -0
  80. package/dist/shared-array-buffer-BQgQXQvC.js +28 -0
  81. package/dist/sw.js +155 -1
  82. package/dist/with-resolvers-DsO_nhbc.js +24 -0
  83. package/dist/xhr-BZOjL92j.js +100 -0
  84. package/dist/xhr-Crh-419R.js +41 -0
  85. package/dist/xhr.js +909 -1
  86. package/package.json +1 -1
  87. package/reflected.tar.gz +0 -0
  88. package/dist/async-C2eqvaGm.js +0 -1
  89. package/dist/async-s2VCmNNG.js +0 -1
  90. package/dist/broadcast-CArZGSOF.js +0 -1
  91. package/dist/broadcast-f7NecPmf.js +0 -1
  92. package/dist/ffi/async-B_TI4xaG.js +0 -1
  93. package/dist/ffi/async-BeKYhv9s.js +0 -1
  94. package/dist/ffi/async-Dl9wCRDA.js +0 -1
  95. package/dist/ffi/async-F0rxZjV9.js +0 -1
  96. package/dist/ffi/broadcast-CBUwPa0e.js +0 -1
  97. package/dist/ffi/broadcast-Ce_cOurt.js +0 -1
  98. package/dist/ffi/broadcast-D0jZEoUb.js +0 -1
  99. package/dist/ffi/broadcast-D7p6b88J.js +0 -1
  100. package/dist/ffi/global-B3nXXiRL.js +0 -1
  101. package/dist/ffi/global-Bs8RLRoX.js +0 -1
  102. package/dist/ffi/i32-BkNtpHwD.js +0 -1
  103. package/dist/ffi/message-BdbPt0y5.js +0 -1
  104. package/dist/ffi/message-DNbm1E-6.js +0 -1
  105. package/dist/ffi/message-DW2TgKPr.js +0 -1
  106. package/dist/ffi/message-TyU9xCIl.js +0 -1
  107. package/dist/ffi/sender-C5EHIpuL.js +0 -1
  108. package/dist/ffi/sender-DBFDKow4.js +0 -1
  109. package/dist/ffi/shared-BfrghvHB.js +0 -1
  110. package/dist/ffi/shared-C2XCOXcu.js +0 -1
  111. package/dist/ffi/shared-Cs1s8cy4.js +0 -1
  112. package/dist/ffi/shared-DsgUjYDJ.js +0 -1
  113. package/dist/ffi/shared-DwSbyGXy.js +0 -1
  114. package/dist/ffi/shared-DyOzpRO0.js +0 -1
  115. package/dist/ffi/shared-array-buffer-cwdMr2mc.js +0 -1
  116. package/dist/ffi/views-CdOIrBQR.js +0 -1
  117. package/dist/ffi/views-Cr2pQ4B-.js +0 -1
  118. package/dist/ffi/xhr-BkOoxiJZ.js +0 -1
  119. package/dist/ffi/xhr-C598zZcp.js +0 -1
  120. package/dist/ffi/xhr-CasCWs_z.js +0 -1
  121. package/dist/ffi/xhr-DHyu_Jz0.js +0 -1
  122. package/dist/i32-C78nBJH2.js +0 -1
  123. package/dist/message-RcKwy8Ib.js +0 -1
  124. package/dist/message-l7W12V0c.js +0 -1
  125. package/dist/proxy/main/async-Bc0QcTaC.js +0 -1
  126. package/dist/proxy/main/async-CyZdYOvJ.js +0 -1
  127. package/dist/proxy/main/broadcast-BX9FmxMK.js +0 -1
  128. package/dist/proxy/main/broadcast-DXhTouQy.js +0 -1
  129. package/dist/proxy/main/channel-DQBWE7_E.js +0 -1
  130. package/dist/proxy/main/i32-C78nBJH2.js +0 -1
  131. package/dist/proxy/main/message-CbPHeJAY.js +0 -1
  132. package/dist/proxy/main/message-DxRlOVN7.js +0 -1
  133. package/dist/proxy/main/sender-CNwZwCuI.js +0 -1
  134. package/dist/proxy/main/shared-BoatDt-V.js +0 -1
  135. package/dist/proxy/main/shared-FMegJ6yb.js +0 -1
  136. package/dist/proxy/main/shared-array-buffer-cwdMr2mc.js +0 -1
  137. package/dist/proxy/main/shared-z_jGYqUa.js +0 -1
  138. package/dist/proxy/main/xhr-BaBkekSn.js +0 -1
  139. package/dist/proxy/main/xhr-Fg-l74MV.js +0 -1
  140. package/dist/proxy/worker/async-Do59YjcF.js +0 -1
  141. package/dist/proxy/worker/async-fqI-s7gn.js +0 -1
  142. package/dist/proxy/worker/broadcast-Bdt9gmj_.js +0 -1
  143. package/dist/proxy/worker/broadcast-D7rjohJL.js +0 -1
  144. package/dist/proxy/worker/channel-DQBWE7_E.js +0 -1
  145. package/dist/proxy/worker/i32-C78nBJH2.js +0 -1
  146. package/dist/proxy/worker/message-BvU2dKHz.js +0 -1
  147. package/dist/proxy/worker/message-DhtuceT9.js +0 -1
  148. package/dist/proxy/worker/sender-CWhM7QKB.js +0 -1
  149. package/dist/proxy/worker/shared-DDIlHBz4.js +0 -1
  150. package/dist/proxy/worker/shared-NtUlwI0Z.js +0 -1
  151. package/dist/proxy/worker/shared-QrUiXPgc.js +0 -1
  152. package/dist/proxy/worker/shared-array-buffer-cwdMr2mc.js +0 -1
  153. package/dist/proxy/worker/xhr-CK-Z6L0B.js +0 -1
  154. package/dist/proxy/worker/xhr-JKtROQ3y.js +0 -1
  155. package/dist/sender-D7tfUn3T.js +0 -1
  156. package/dist/shared-BCEcO4-0.js +0 -1
  157. package/dist/shared-BWvJKuCK.js +0 -1
  158. package/dist/shared-BhhIigP4.js +0 -1
  159. package/dist/shared-array-buffer-cwdMr2mc.js +0 -1
  160. package/dist/with-resolvers-CHEvl4oe.js +0 -1
  161. package/dist/xhr-Bd0lMv0-.js +0 -1
  162. package/dist/xhr-DaixJn9d.js +0 -1
@@ -0,0 +1,101 @@
1
+ import { w as withResolvers, x as randomUUID, s as byteOffset, S as SHARED_CHANNEL } from './shared-5Nhc4gvB.js';
2
+ import { W as Worker$1, S as SAB } from './async-D6Zj6i_Q.js';
3
+ import { S as Sender, h as handler, u as url, p as post } from './shared-ddawRQD0.js';
4
+ import './shared-array-buffer-BQgQXQvC.js';
5
+ import './i32-Cw-Rqr5y.js';
6
+ import './views-C3SJnvMr.js';
7
+ import './global-LTfnrHcF.js';
8
+
9
+ const CHANNEL = 'xhr';
10
+
11
+ const channels = new Map;
12
+
13
+ const sharedBC = new BroadcastChannel(SHARED_CHANNEL);
14
+ sharedBC.addEventListener('message', async ({ data: [op, details] }) => {
15
+ if (op === 'request') {
16
+ const [uid, [id, channel]] = details;
17
+ const responses = channels.get(channel);
18
+ if (responses) {
19
+ const promise = responses.get(id);
20
+ responses.delete(id);
21
+ sharedBC.postMessage(['response', [uid, await promise]]);
22
+ }
23
+ }
24
+ });
25
+
26
+ const { promise: sw, resolve } = withResolvers();
27
+ let init = true;
28
+
29
+ const activate = (swc, options) => {
30
+ let w, c = true, { url } = options;
31
+ swc.getRegistration(url)
32
+ .then(r => (r ?? swc.register(url, options)))
33
+ .then(function ready(r) {
34
+ const { controller } = swc;
35
+ c = c && !!controller;
36
+ w = (r.installing || r.waiting || r.active);
37
+ if (!w) return activate(swc, options);
38
+ if (w.state === 'activated') {
39
+ if (c) {
40
+ // allow ServiceWorker swap on different URL
41
+ if (controller.scriptURL === url)
42
+ return resolve();
43
+ r.unregister();
44
+ }
45
+ location.reload();
46
+ }
47
+ else {
48
+ w.addEventListener('statechange', () => ready(r), { once: true });
49
+ }
50
+ });
51
+ };
52
+
53
+ class Worker extends Sender {
54
+ #channel;
55
+ constructor(scriptURL, options, resolve) {
56
+ if (init) {
57
+ init = false;
58
+ let { serviceWorker } = options;
59
+ if (!serviceWorker) {
60
+ // @ts-ignore
61
+ return new Worker$1(scriptURL, options, resolve);
62
+ }
63
+ if (typeof serviceWorker === 'string') serviceWorker = { url: serviceWorker };
64
+ serviceWorker.url = new URL(serviceWorker.url, location.href).href;
65
+ activate(navigator.serviceWorker, serviceWorker);
66
+ }
67
+ const channel = randomUUID();
68
+ const bc = new BroadcastChannel(channel);
69
+ const sab = SAB(options);
70
+ const responses = new Map;
71
+ const i32a = new Int32Array(sab);
72
+ const handle = handler(sab, options, false);
73
+ channels.set(channel, responses);
74
+ bc.addEventListener('message', async ({ data: [id, payload] }) => {
75
+ const { promise, resolve } = withResolvers();
76
+ responses.set(id, promise);
77
+ await handle({ data: payload });
78
+ resolve(new Uint8Array(sab, byteOffset, i32a[1]));
79
+ });
80
+ super(...url(scriptURL, CHANNEL, options));
81
+ super.addEventListener('message', () => resolve(this), { once: true });
82
+ super.postMessage(post(sab, options).concat(channel));
83
+ this.#channel = channel;
84
+ }
85
+
86
+ terminate() {
87
+ channels.delete(this.#channel);
88
+ super.terminate();
89
+ }
90
+
91
+ get channel() {
92
+ return CHANNEL;
93
+ }
94
+ }
95
+ var xhr = (scriptURL, options) => {
96
+ const { promise, resolve } = withResolvers();
97
+ const worker = new Worker(scriptURL, options, resolve);
98
+ return worker instanceof Worker$1 ? promise : sw.then(() => promise);
99
+ };
100
+
101
+ export { xhr as default };
@@ -0,0 +1,41 @@
1
+ import { w as withResolvers } from './shared-5Nhc4gvB.js';
2
+ import { s as sender, d as decoder } from './sender-B7Xmjz4q.js';
3
+ import { i as i32 } from './i32-Cw-Rqr5y.js';
4
+ import './views-C3SJnvMr.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 };
@@ -0,0 +1,41 @@
1
+ import { w as withResolvers } from './shared-CjWXp6-D.js';
2
+ import { s as sender, d as decoder } from './sender-C0gu9RzR.js';
3
+ import { i as i32 } from './i32-Cw-Rqr5y.js';
4
+ import './views-DBBYng9N.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 };
@@ -0,0 +1,101 @@
1
+ import { w as withResolvers, v as randomUUID, r as byteOffset, S as SHARED_CHANNEL } from './shared-CjWXp6-D.js';
2
+ import { W as Worker$1, S as SAB } from './async-DLrN8K6M.js';
3
+ import { S as Sender, h as handler, u as url, p as post } from './shared-B3KmQkGh.js';
4
+ import './shared-array-buffer-BQgQXQvC.js';
5
+ import './i32-Cw-Rqr5y.js';
6
+ import './views-DBBYng9N.js';
7
+ import './global-DzpOeFX2.js';
8
+
9
+ const CHANNEL = 'xhr';
10
+
11
+ const channels = new Map;
12
+
13
+ const sharedBC = new BroadcastChannel(SHARED_CHANNEL);
14
+ sharedBC.addEventListener('message', async ({ data: [op, details] }) => {
15
+ if (op === 'request') {
16
+ const [uid, [id, channel]] = details;
17
+ const responses = channels.get(channel);
18
+ if (responses) {
19
+ const promise = responses.get(id);
20
+ responses.delete(id);
21
+ sharedBC.postMessage(['response', [uid, await promise]]);
22
+ }
23
+ }
24
+ });
25
+
26
+ const { promise: sw, resolve } = withResolvers();
27
+ let init = true;
28
+
29
+ const activate = (swc, options) => {
30
+ let w, c = true, { url } = options;
31
+ swc.getRegistration(url)
32
+ .then(r => (r ?? swc.register(url, options)))
33
+ .then(function ready(r) {
34
+ const { controller } = swc;
35
+ c = c && !!controller;
36
+ w = (r.installing || r.waiting || r.active);
37
+ if (!w) return activate(swc, options);
38
+ if (w.state === 'activated') {
39
+ if (c) {
40
+ // allow ServiceWorker swap on different URL
41
+ if (controller.scriptURL === url)
42
+ return resolve();
43
+ r.unregister();
44
+ }
45
+ location.reload();
46
+ }
47
+ else {
48
+ w.addEventListener('statechange', () => ready(r), { once: true });
49
+ }
50
+ });
51
+ };
52
+
53
+ class Worker extends Sender {
54
+ #channel;
55
+ constructor(scriptURL, options, resolve) {
56
+ if (init) {
57
+ init = false;
58
+ let { serviceWorker } = options;
59
+ if (!serviceWorker) {
60
+ // @ts-ignore
61
+ return new Worker$1(scriptURL, options, resolve);
62
+ }
63
+ if (typeof serviceWorker === 'string') serviceWorker = { url: serviceWorker };
64
+ serviceWorker.url = new URL(serviceWorker.url, location.href).href;
65
+ activate(navigator.serviceWorker, serviceWorker);
66
+ }
67
+ const channel = randomUUID();
68
+ const bc = new BroadcastChannel(channel);
69
+ const sab = SAB(options);
70
+ const responses = new Map;
71
+ const i32a = new Int32Array(sab);
72
+ const handle = handler(sab, options, false);
73
+ channels.set(channel, responses);
74
+ bc.addEventListener('message', async ({ data: [id, payload] }) => {
75
+ const { promise, resolve } = withResolvers();
76
+ responses.set(id, promise);
77
+ await handle({ data: payload });
78
+ resolve(new Uint8Array(sab, byteOffset, i32a[1]));
79
+ });
80
+ super(...url(scriptURL, CHANNEL, options));
81
+ super.addEventListener('message', () => resolve(this), { once: true });
82
+ super.postMessage(post(sab, options).concat(channel));
83
+ this.#channel = channel;
84
+ }
85
+
86
+ terminate() {
87
+ channels.delete(this.#channel);
88
+ super.terminate();
89
+ }
90
+
91
+ get channel() {
92
+ return CHANNEL;
93
+ }
94
+ }
95
+ var xhr = (scriptURL, options) => {
96
+ const { promise, resolve } = withResolvers();
97
+ const worker = new Worker(scriptURL, options, resolve);
98
+ return worker instanceof Worker$1 ? promise : sw.then(() => promise);
99
+ };
100
+
101
+ export { xhr as default };
@@ -0,0 +1,12 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @param {number} [start]
5
+ * @returns {() => number}
6
+ */
7
+ var i32 = start => {
8
+ const i32 = new Int32Array(1);
9
+ return () => i32[0]++;
10
+ };
11
+
12
+ export { i32 as i };
package/dist/index.js CHANGED
@@ -1 +1,57 @@
1
- import{w as a}from"./with-resolvers-CHEvl4oe.js";import{n as s}from"./shared-array-buffer-cwdMr2mc.js";let t,e;if("importScripts"in globalThis){let s;const{promise:r,resolve:o}=a(),i=new URL(location).searchParams.get("reflected");t=i,s="message"===i?import("./message-RcKwy8Ib.js"):"broadcast"===i?import("./broadcast-CArZGSOF.js"):"xhr"===i?import("./xhr-Bd0lMv0-.js"):import("./async-C2eqvaGm.js"),e=async a=>{const{data:t,ports:e}=await r,{default:o}=await s,i=new Event("message");return i.data=t,i.ports=e,dispatchEvent(i),o(a)},addEventListener("message",o,{once:!0})}else s?"InstallTrigger"in globalThis?(t="broadcast",e=(await import("./broadcast-f7NecPmf.js")).default):(t="message",e=(await import("./message-l7W12V0c.js")).default):navigator.serviceWorker?(t="xhr",e=(await import("./xhr-DaixJn9d.js")).default):(t="async",e=(await import("./async-s2VCmNNG.js").then(function(a){return a.a})).default);var r=e;export{t as channel,r as default};
1
+ import { w as withResolvers } from './with-resolvers-DsO_nhbc.js';
2
+ import { n as native } from './shared-array-buffer-BQgQXQvC.js';
3
+
4
+ /** @typedef {import('./main/shared.js').Options} MainOptions */
5
+ /** @typedef {import('./worker/shared.js').Options} WorkerOptions */
6
+
7
+ /** @type {string} */
8
+ let channel;
9
+
10
+ /** @type {Function} */
11
+ let module$1;
12
+
13
+ if ('importScripts' in globalThis) {
14
+ let get;
15
+ const { promise, resolve } = withResolvers();
16
+ // @ts-ignore
17
+ const reflected = new URL(location).searchParams.get('reflected');
18
+ channel = reflected;
19
+ if (reflected === 'message') get = import(/* webpackIgnore: true */'./message-vCWcUEmt.js');
20
+ else if (reflected === 'broadcast') get = import(/* webpackIgnore: true */'./broadcast-eR5_7TCY.js');
21
+ else if (reflected === 'xhr') get = import(/* webpackIgnore: true */'./xhr-Crh-419R.js');
22
+ else get = import(/* webpackIgnore: true */'./async-OLiknCrf.js');
23
+ module$1 = async options => {
24
+ const { data, ports } = await promise;
25
+ const { default: reflect } = await get;
26
+ const event = new Event('message');
27
+ // @ts-ignore
28
+ event.data = data;
29
+ // @ts-ignore
30
+ event.ports = ports;
31
+ dispatchEvent(event);
32
+ return reflect(options);
33
+ };
34
+ addEventListener('message', resolve, { once: true });
35
+ }
36
+ else if (native) {
37
+ if ('InstallTrigger' in globalThis) {
38
+ channel = 'broadcast';
39
+ module$1 = (await import(/* webpackIgnore: true */'./broadcast-B4sl9DBp.js')).default;
40
+ }
41
+ else {
42
+ channel = 'message';
43
+ module$1 = (await import(/* webpackIgnore: true */'./message-D_SM4ST4.js')).default;
44
+ }
45
+ }
46
+ else if (navigator.serviceWorker) {
47
+ channel = 'xhr';
48
+ module$1 = (await import(/* webpackIgnore: true */'./xhr-BZOjL92j.js')).default;
49
+ }
50
+ else {
51
+ channel = 'async';
52
+ module$1 = (await import(/* webpackIgnore: true */'./async-CM1iXZPW.js').then(function (n) { return n.a; })).default;
53
+ }
54
+
55
+ var module_default = module$1;
56
+
57
+ export { channel, module_default as default };
@@ -0,0 +1,24 @@
1
+ import { b as bootstrap, S as Sender, a as SAB, h as handler, u as url, p as post } from './shared-L0wiAfqu.js';
2
+ import './with-resolvers-DsO_nhbc.js';
3
+ import './i32-UV5fM9Tw.js';
4
+ import './shared-Ccm1cPah.js';
5
+
6
+ const CHANNEL = 'message';
7
+
8
+ var message = bootstrap(class Worker extends Sender {
9
+ constructor(scriptURL, options, resolve) {
10
+ const { port1, port2 } = new MessageChannel;
11
+ const sab = SAB(options);
12
+ port1.addEventListener(CHANNEL, handler(sab, options, true));
13
+ port1.start();
14
+ super(...url(scriptURL, CHANNEL, options));
15
+ super.addEventListener(CHANNEL, () => resolve(this), { once: true });
16
+ super.postMessage(post(sab, options), [port2]);
17
+ }
18
+
19
+ get channel() {
20
+ return CHANNEL;
21
+ }
22
+ });
23
+
24
+ export { message as default };
@@ -0,0 +1,15 @@
1
+ import { w as withResolvers } from './with-resolvers-DsO_nhbc.js';
2
+ import { h as handler } from './shared-DVDPRDN_.js';
3
+ import './sender-BSx3lj4w.js';
4
+ import './shared-Ccm1cPah.js';
5
+
6
+ const { promise, resolve } = withResolvers();
7
+
8
+ const channel = 'message';
9
+
10
+ var message = handler(
11
+ promise,
12
+ ({ data: [sab, main], ports: [channel] }) => resolve([sab, main, channel])
13
+ );
14
+
15
+ export { channel, message as default };