@fkn/lib 0.9.19 → 0.9.21

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 (86) hide show
  1. package/account.cjs +1 -1
  2. package/account.js +24 -17
  3. package/{api-DnO1DsJC.d.ts → api-B0qRPCcX.d.ts} +36 -37
  4. package/api-BqRjtWm_.js +311 -0
  5. package/api-CKO3Hw-O.cjs +3 -0
  6. package/busy-Bp1E3JPT.js +24 -0
  7. package/busy-Dv8wzE5M.cjs +1 -0
  8. package/cloud/dgram.cjs +1 -1
  9. package/cloud/dgram.js +1 -1
  10. package/cloud/fetch.cjs +1 -1
  11. package/cloud/fetch.d.ts +1 -1
  12. package/cloud/fetch.js +1 -1
  13. package/cloud/fs.cjs +1 -1
  14. package/cloud/fs.js +2 -2
  15. package/cloud/net.cjs +1 -1
  16. package/cloud/net.d.ts +1 -1
  17. package/cloud/net.js +1 -1
  18. package/cloud-BCQTex58.cjs +1 -0
  19. package/{cloud-uE4g-WqI.d.ts → cloud-BTpJn4jy.d.ts} +3 -3
  20. package/cloud-BlR1He17.js +212 -0
  21. package/cloud.cjs +1 -1
  22. package/cloud.d.ts +3 -3
  23. package/cloud.js +4 -4
  24. package/dgram-9hn582qO.cjs +1 -0
  25. package/{dgram-DlGl_ho1.js → dgram-TB03kqMr.js} +55 -49
  26. package/dgram.cjs +1 -1
  27. package/dgram.d.ts +2 -1
  28. package/dgram.js +1 -1
  29. package/dns.cjs +1 -1
  30. package/dns.js +1 -1
  31. package/extension-BI2NxGtC.js +78 -0
  32. package/{extension-CN9oFZ0Q.d.ts → extension-CMPZjuaV.d.ts} +1 -1
  33. package/extension-rFQQpEqJ.cjs +1 -0
  34. package/extension.cjs +1 -1
  35. package/extension.d.ts +2 -2
  36. package/extension.js +3 -3
  37. package/fs/promises.cjs +1 -1
  38. package/fs/promises.js +1 -1
  39. package/fs-BUcpl9k4.cjs +1 -0
  40. package/fs-bpb3Ysdd.js +347 -0
  41. package/fs.cjs +1 -1
  42. package/fs.js +1 -1
  43. package/http.cjs +1 -1
  44. package/http.d.ts +1 -1
  45. package/http.js +1 -1
  46. package/{index-DLaonjpx.d.ts → index-DY8WjklJ.d.ts} +82 -0
  47. package/index.cjs +1 -1
  48. package/index.d.ts +12 -18
  49. package/index.js +92 -39
  50. package/lib-DbiVHPXE.cjs +53 -0
  51. package/{lib-CegQxwDI.js → lib-k3lstfa4.js} +178 -131
  52. package/net-C2fIMWFr.cjs +1 -0
  53. package/{net-l7JVHsIR.d.ts → net-CnYxw_sB.d.ts} +3 -1
  54. package/{net-BbmQeMpt.js → net-Ct8ywVAk.js} +52 -41
  55. package/net.cjs +1 -1
  56. package/net.d.ts +1 -1
  57. package/net.js +1 -1
  58. package/node-fs-BZCQUmeE.js +404 -0
  59. package/node-fs-DZPGCYWg.cjs +1 -0
  60. package/opfs.cjs +1 -1
  61. package/opfs.js +1 -1
  62. package/package.json +1 -1
  63. package/{packages-vX-1yfRK.d.ts → packages-Cn8S-Hkn.d.ts} +20 -20
  64. package/packages.cjs +1 -1
  65. package/packages.d.ts +1 -1
  66. package/packages.js +165 -149
  67. package/proxy--aljNHvG.js +69 -0
  68. package/{proxy-7ib45Uo-.d.ts → proxy-CuXtzxSQ.d.ts} +1 -1
  69. package/proxy-oHfEx1cn.cjs +1 -0
  70. package/{storage-C8hBot2f.js → storage-C1nW5Tvh.js} +1 -1
  71. package/{storage-BW-jDLUL.cjs → storage-rXHvV2FU.cjs} +1 -1
  72. package/api-DQ-V4Lls.js +0 -220
  73. package/api-kHMHDGar.cjs +0 -3
  74. package/cloud-BQoppUw4.cjs +0 -1
  75. package/cloud-C8CeqUht.js +0 -130
  76. package/dgram-D2Or5f2e.cjs +0 -1
  77. package/extension-4BM5hKrn.cjs +0 -1
  78. package/extension-DVO10P3i.js +0 -78
  79. package/fs-BW5mVMmu.js +0 -340
  80. package/fs-DJm0bhjg.cjs +0 -1
  81. package/lib-ulyxIbTr.cjs +0 -53
  82. package/net-COzDDBnS.cjs +0 -1
  83. package/node-fs-BMR2yCEt.cjs +0 -1
  84. package/node-fs-DKfokOlh.js +0 -401
  85. package/proxy-B0gNjT8-.cjs +0 -1
  86. package/proxy-BpqvCJmA.js +0 -43
@@ -1,8 +1,8 @@
1
- import { t as cloudFetch } from "./proxy-7ib45Uo-.js";
2
- import { d as Frame, u as AttachFrameOptions } from "./index-DLaonjpx.js";
1
+ import { t as cloudFetch } from "./proxy-CuXtzxSQ.js";
2
+ import { d as Frame, u as AttachFrameOptions } from "./index-DY8WjklJ.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
4
  import { n as fs_d_exports } from "./fs-CUmugp10.js";
5
- import { s as net_d_exports } from "./net-l7JVHsIR.js";
5
+ import { s as net_d_exports } from "./net-CnYxw_sB.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
 
@@ -0,0 +1,212 @@
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { R as t, _ as n, a as r, f as i, m as a, s as o } from "./lib-k3lstfa4.js";
3
+ import { o as s, r as c } from "./api-BqRjtWm_.js";
4
+ import { t as l } from "./busy-Bp1E3JPT.js";
5
+ import { t as u } from "./proxy--aljNHvG.js";
6
+ import { t as d } from "./dns.js";
7
+ import { t as f } from "./cloud/fs.js";
8
+ import { s as p } from "./net-Ct8ywVAk.js";
9
+ import { i as m } from "./dgram-TB03kqMr.js";
10
+ import { t as h } from "./http.js";
11
+ import { expose as g } from "osra";
12
+ //#region node_modules/@mfkn/web-extension/lib/lib/locator-permissions.js
13
+ var _ = {
14
+ scope: "frame.fetchRead",
15
+ category: "network",
16
+ severity: 3,
17
+ unsafe: !0,
18
+ title: "Read your account data on this site",
19
+ description: "Lets the app read pages and data from this site as you, using the session in the frame."
20
+ }, v = {
21
+ scope: "frame.fetchWrite",
22
+ category: "network",
23
+ severity: 3,
24
+ unsafe: !0,
25
+ title: "Change your account data on this site",
26
+ description: "Lets the app send changes to this site as you, using the session in the frame."
27
+ }, y = /* @__PURE__ */ new Set([
28
+ "GET",
29
+ "HEAD",
30
+ "OPTIONS"
31
+ ]), b = (e, t) => y.has((t?.method ?? "GET").toUpperCase()) ? _ : v, x = (e) => {
32
+ let t = [];
33
+ for (let n of e) {
34
+ let e = n.trim().toLowerCase();
35
+ !e || e.length > 253 || /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/.test(e) && (t.includes(e) || t.push(e));
36
+ }
37
+ return t;
38
+ }, S = (e, t) => {
39
+ if (!e.session) return {
40
+ kind: "refuse",
41
+ reason: "frame.fetch on the cloud backend needs its own session: attach with syncCookies: false"
42
+ };
43
+ if (typeof t != "string") return {
44
+ kind: "refuse",
45
+ reason: "frame.fetch: url must be a string"
46
+ };
47
+ let n;
48
+ try {
49
+ n = new URL(t);
50
+ } catch {
51
+ return {
52
+ kind: "refuse",
53
+ reason: "frame.fetch on the cloud backend needs an absolute url"
54
+ };
55
+ }
56
+ if (n.protocol !== "https:" && n.protocol !== "http:") return {
57
+ kind: "refuse",
58
+ reason: "frame.fetch: only http(s) urls are supported"
59
+ };
60
+ if (!(e.declaredHosts.includes(n.hostname) || e.approvedOrigins.has(n.origin))) return {
61
+ kind: "refuse",
62
+ reason: "frame.fetch: the target is outside the origins this attachment declared"
63
+ };
64
+ let r = e.declaredHosts.length ? e.declaredHosts : [n.hostname];
65
+ return {
66
+ kind: "consent",
67
+ targetHost: n.hostname,
68
+ promptHosts: r
69
+ };
70
+ }, C = (e) => e, w = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", T = 2e4, E = 65e3, D = 3e4, O = 5e3, k = /* @__PURE__ */ new Set([]), A = () => "https://fkn.app", j = (e) => !e || e === "about:blank", M = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, N = ({ target: e, session: t, domains: n }) => {
71
+ let r = new URL("/attach-frame", A());
72
+ return e && r.searchParams.set("url", e), t && r.searchParams.set("session", t), n.length && r.searchParams.set("domains", n.join(",")), r.href;
73
+ }, P = (e, t, n) => {
74
+ let r, i = new Promise((e, i) => {
75
+ r = setTimeout(() => i(Error(n)), t);
76
+ });
77
+ return Promise.race([e, i]).finally(() => clearTimeout(r));
78
+ }, F = (e, t) => {
79
+ let n = () => {
80
+ a(), t();
81
+ }, r = e.parentNode, i = new MutationObserver(() => {
82
+ (!e.isConnected || e.parentNode !== r) && (a(), t());
83
+ }), a = () => {
84
+ window.removeEventListener("pagehide", n), i.disconnect();
85
+ };
86
+ window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
87
+ }, I = () => Object.assign(/* @__PURE__ */ Error("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), { name: a }), L = (e, t) => {
88
+ let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
89
+ return [...new Set(n)].join("; ");
90
+ }, R = [
91
+ 300,
92
+ 1200,
93
+ 4e3
94
+ ], z = (e) => {
95
+ let t = () => {
96
+ if (!e.isConnected) return;
97
+ let t = e.style.height, n = e.getBoundingClientRect();
98
+ n.height && (e.style.height = `${n.height - 1}px`, setTimeout(() => {
99
+ e.style.height = t;
100
+ }, 50));
101
+ };
102
+ t();
103
+ for (let e of R) setTimeout(t, e);
104
+ }, B = (e) => {
105
+ let t = e.getAttribute("sandbox");
106
+ if (t === null) return;
107
+ let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
108
+ if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
109
+ }, V = async ({ iframe: e, domains: a = [], syncCookies: s = !0, lockdown: u = !1 }) => {
110
+ if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
111
+ if (u) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
112
+ if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
113
+ B(e);
114
+ let d = e.getAttribute("src") ?? "", f = (() => {
115
+ if (j(d)) return null;
116
+ try {
117
+ return new URL(e.src || d, location.href);
118
+ } catch {
119
+ throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${d}`);
120
+ }
121
+ })();
122
+ if (f) {
123
+ let e = new URL("/attach-frame", A());
124
+ if (f.origin === e.origin && f.pathname === e.pathname) throw Error("cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe");
125
+ }
126
+ let p = f?.href ?? "";
127
+ p && o(p);
128
+ let m = p, h = M(s), _ = x(a), v = /* @__PURE__ */ new Set();
129
+ try {
130
+ v.add(new URL(p).origin);
131
+ } catch {}
132
+ let y = new AbortController(), R = e.referrerPolicy, V = e.allow;
133
+ if (e.referrerPolicy = "origin", e.allow = L(w, e.allow), e.src = N({
134
+ target: p,
135
+ session: h,
136
+ domains: _
137
+ }), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
138
+ try {
139
+ let a = await P(g({}, {
140
+ key: "fkn-attach-frame",
141
+ origin: A(),
142
+ transport: {
143
+ receive: window,
144
+ emit: e.contentWindow
145
+ },
146
+ unregisterSignal: y.signal,
147
+ revivableModules: C(t)
148
+ }), T, "cloud.attachFrame: timed out connecting to the render proxy page");
149
+ await P(a.ready(), E, "cloud.attachFrame: the render proxy never became ready"), p && z(e), F(e, () => y.abort());
150
+ let o = l("attached frame");
151
+ y.signal.aborted ? o() : y.signal.addEventListener("abort", o, { once: !0 });
152
+ let s = e.contentWindow, u = () => {
153
+ if (!(!y.signal.aborted && e.isConnected && e.contentWindow === s)) throw y.abort(), I();
154
+ };
155
+ return r({
156
+ executor: {
157
+ execute: (e, t, n) => k.has(t) ? Promise.reject(i(t, "cloud")) : (u(), a.executeLocator(e, t, n)),
158
+ highlight: async () => {}
159
+ },
160
+ gate: async (e) => {
161
+ if (e.operation !== "fetch") return;
162
+ let t = S({
163
+ session: h,
164
+ declaredHosts: _,
165
+ approvedOrigins: v
166
+ }, e.args[0]);
167
+ if (t.kind === "refuse") throw n(t.reason, "fetch");
168
+ if (!await (await c).frameConsent.ensure({
169
+ scope: b(e.args[0], e.args[1]).scope,
170
+ hosts: t.promptHosts
171
+ })) throw n("frame.fetch: the user did not grant this", "fetch");
172
+ },
173
+ goto: async (t, n = {}) => {
174
+ let r = new URL(t, location.href).href;
175
+ u();
176
+ let { timeoutMs: i } = n;
177
+ await P(a.goto(r, n), (i ?? D) + O, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded"), m = r;
178
+ try {
179
+ v.add(new URL(r).origin);
180
+ } catch {}
181
+ z(e);
182
+ },
183
+ url: () => m
184
+ });
185
+ } catch (t) {
186
+ throw y.abort(), e.referrerPolicy = R, e.allow = V, e.src = p || "about:blank", t;
187
+ }
188
+ }, H = () => typeof window < "u" && !0, U = async () => {
189
+ let e = await c.then((e) => e.cloud.quota());
190
+ return {
191
+ premium: e.premium,
192
+ overQuota: e.overQuota,
193
+ throttled: e.overQuota && !e.premium,
194
+ usedBytes: e.usedBytes,
195
+ limitBytes: e.limitBytes,
196
+ remainingBytes: e.remaining,
197
+ bytesPerSecond: e.bytesPerSecond,
198
+ bitsPerSecond: e.bytesPerSecond * 8
199
+ };
200
+ }, W = /* @__PURE__ */ e({
201
+ attachFrame: () => V,
202
+ available: () => G,
203
+ dgram: () => m,
204
+ dns: () => d,
205
+ fetch: () => u,
206
+ fs: () => f,
207
+ http: () => h,
208
+ net: () => p,
209
+ quota: () => U
210
+ }), G = () => s;
211
+ //#endregion
212
+ export { H as a, V as i, W as n, U as r, G as t };
package/cloud.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-B0gNjT8-.cjs"),t=require("./cloud-BQoppUw4.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net-COzDDBnS.cjs"),a=require("./dgram-D2Or5f2e.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.s}}),exports.quota=t.r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-oHfEx1cn.cjs"),t=require("./cloud-BCQTex58.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net-C2fIMWFr.cjs"),a=require("./dgram-9hn582qO.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.s}}),exports.quota=t.r;
package/cloud.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { t as cloudFetch } from "./proxy-7ib45Uo-.js";
2
- import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-uE4g-WqI.js";
1
+ import { t as cloudFetch } from "./proxy-CuXtzxSQ.js";
2
+ import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-BTpJn4jy.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
4
  import { n as fs_d_exports } from "./fs-CUmugp10.js";
5
- import { s as net_d_exports } from "./net-l7JVHsIR.js";
5
+ import { s as net_d_exports } from "./net-CnYxw_sB.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
  export { type QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
package/cloud.js CHANGED
@@ -1,8 +1,8 @@
1
- import { t as e } from "./proxy-BpqvCJmA.js";
2
- import { i as t, r as n, t as r } from "./cloud-C8CeqUht.js";
1
+ import { t as e } from "./proxy--aljNHvG.js";
2
+ import { i as t, r as n, t as r } from "./cloud-BlR1He17.js";
3
3
  import { t as i } from "./dns.js";
4
4
  import { t as a } from "./cloud/fs.js";
5
- import { s as o } from "./net-BbmQeMpt.js";
6
- import { i as s } from "./dgram-DlGl_ho1.js";
5
+ import { s as o } from "./net-Ct8ywVAk.js";
6
+ import { i as s } from "./dgram-TB03kqMr.js";
7
7
  import { t as c } from "./http.js";
8
8
  export { t as attachFrame, r as available, s as dgram, i as dns, e as fetch, a as fs, c as http, o as net, n as quota };
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-CKO3Hw-O.cjs"),n=require("./busy-Dv8wzE5M.cjs"),r=require("./utils-QfNXtEhb.cjs");let i=require("buffer"),a=require("events"),o=require("ip-address");var s=e.t({Socket:()=>c,createSocket:()=>m,default:()=>h}),c=class extends a.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_busyRelease;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=new Map;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}_dataPortAcks=!1;_dataPortConsumedBytes=0;_dataPortAckedBytes=0;_ackDataPortBatch(e){if(!this._dataPortAcks||!this._dataPort||(this._dataPortConsumedBytes+=e,this._dataPortAckedBytes!==0&&this._dataPortConsumedBytes-this._dataPortAckedBytes<524288))return;this._dataPortAckedBytes=this._dataPortConsumedBytes;let t={type:r.n,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){this._destroyed||(this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0,this.listenerCount(`error`)>0&&this.emit(`error`,Error(e||`WebVPN session closed`)),this.emit(`close`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,r,a=0;for(;a+4<=e.byteLength;){let o=t.getUint32(a);a+=4;let s=a+o;if(s>e.byteLength)break;let c=a+4,l=t.getUint8(c);c+=1;let u,d,p;if(l===2){if(!this._remoteAddress){a=s;continue}u=this._remoteAddress.address,d=this._remoteAddress.family,p=this._remoteAddress.port}else{let n=new Uint8Array(e,c,l===0?4:16);l===0?(d=`IPv4`,u=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(d=`IPv6`,u=f(n)),c+=n.byteLength,p=t.getUint16(c),c+=2}let m=t.getUint32(c);c+=4;try{this.emit(`message`,i.Buffer.from(e.slice(c,c+m)),{address:u,family:d,port:p,size:m})}catch(e){n||(n=!0,r=e)}a=s}if(n)throw r}_peerTail(e,t){if(e===void 0||t===void 0)return l;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=o.Address4.isValid(e)?d(e):p(e),a=new Uint8Array(1+i.byteLength+2);return a[0]=i.byteLength===4?0:1,a.set(i,1),new DataView(a.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,a),a}_portSend(e,t,n){let r=this._peerTail(t,n),i=new Uint8Array(8+r.byteLength+4+e.byteLength),a=new DataView(i.buffer);a.setUint32(0,i.byteLength-4),a.setUint32(4,this._socketId),i.set(r,8),a.setUint32(8+r.byteLength,e.byteLength),i.set(e,12+r.byteLength),this._sendQueue.push(i),this._sendQueueBytes+=i.byteLength,!this._sendFlushScheduled&&(this._sendFlushScheduled=!0,queueMicrotask(()=>{this._sendFlushScheduled=!1;let e=this._sendQueue,t=this._sendQueueBytes;if(this._sendQueue=[],this._sendQueueBytes=0,!e.length||!this._dataPort)return;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;this._dataPort.postMessage(n.buffer,[n.buffer])}))}addMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let n=r.o(...e),i=this._type===`udp6`?`::`:`0.0.0.0`,a=this.__webvpn_udp_socket_init__(t.r.then(e=>e.cloud.webvpn.udpSocket({type:this._type,address:n.address??i,port:n.port,dataPort:!0})));return n.callback&&a.then(e=>{e&&n.callback.call(this)}),this}__webvpn_udp_socket_init__(e,t){return t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort}),this._busyRelease??=n.t(`udp socket`),this._webVPNUdpSocketPromise=e.then(e=>{if(e.dataPort)this._socketId=e.socketId,this._dataPort=e.dataPort,this._dataPortAcks=e.dataPortAcks===!0,this._dataPort.onmessage=e=>{try{this._onDataPortBatch(e.data)}finally{this._ackDataPortBatch(e.data.byteLength)}};else{let t=e.dataReadableStream.getReader();(async()=>{for(;;){let{value:e,done:n}=await t.read();if(n)return;this.emit(`message`,i.Buffer.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size})}})().catch(e=>this._onTransportClosed(e instanceof Error?e.message:void 0))}return e.closed?.then(e=>this._onTransportClosed(e?.reason)).catch(()=>{}),this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`listening`)}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=this._destroyed;this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0;try{await t.close()}finally{try{e&&e()}finally{n||this.emit(`close`)}}}).catch(()=>{}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0,o=await t.connect({remotePort:n,remoteAddress:i});this._connectedLocally=o?.local===!0,this._remoteAddress=o?.address?{address:o.address,family:o.family,port:o.port}:{address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},this._connectGeneration+=1,a&&a()}).catch(e=>{this.emit(`error`,e)})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);let e=this._remoteAddress,t=this._connectedLocally,n=this._connectGeneration;this._remoteAddress=void 0,this._connectedLocally=void 0,this._webVPNUdpSocketPromise.then(e=>e?.disconnect?.()).catch(r=>{this._connectGeneration===n&&(this._remoteAddress=e,this._connectedLocally=t),this.emit(`error`,r)})}dropMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=r.s(...e),n=u(t.message),i=n;if(t.hasRange){let{offset:e,length:r}=t;if(!Number.isInteger(e)||e<0||e>n.byteLength)throw Object.assign(RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(r)||r<0||r>n.byteLength-e)throw Object.assign(RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});i=n.subarray(e,e+r)}let a=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let n=t.callback,r=t.address??a,s=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(s||o.Address4.isValid(r)||o.Address6.isValid(r))){this._portSend(i,s?void 0:r,s?void 0:t.port),n?.call(this,null,i.byteLength);return}e.send({port:t.port,address:r,message:i.byteOffset===0&&i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}).then(()=>n?.call(this,null,i.byteLength),e=>n?n.call(this,e,0):this.emit(`error`,e))})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},l=new Uint8Array([2]),u=e=>{if(typeof e==`string`)return r.l.encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e)){let t=e.map(u),n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}return new Uint8Array(e)},d=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},f=e=>{let t=[];for(let n=0;n<16;n+=2)t.push(e[n]<<8|e[n+1]);let n=-1,r=1;for(let e=0;e<8;){if(t[e]!==0){e++;continue}let i=e;for(;i<8&&t[i]===0;)i++;i-e>r&&(n=e,r=i-e),e=i}return n===-1?t.map(e=>e.toString(16)).join(`:`):`${t.slice(0,n).map(e=>e.toString(16)).join(`:`)}::${t.slice(n+r).map(e=>e.toString(16)).join(`:`)}`},p=e=>{let t=new o.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},m=(e,t)=>{let n=new c(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},h={Socket:c,createSocket:m};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
@@ -1,21 +1,23 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { t } from "./api-DQ-V4Lls.js";
3
- import { l as n, n as r, o as i, s as a } from "./utils-DVlbuXmW.js";
4
- import { Buffer as o } from "buffer";
5
- import { EventEmitter as s } from "events";
6
- import { Address4 as c, Address6 as l } from "ip-address";
2
+ import { r as t } from "./api-BqRjtWm_.js";
3
+ import { t as n } from "./busy-Bp1E3JPT.js";
4
+ import { l as r, n as i, o as a, s as o } from "./utils-DVlbuXmW.js";
5
+ import { Buffer as s } from "buffer";
6
+ import { EventEmitter as c } from "events";
7
+ import { Address4 as l, Address6 as u } from "ip-address";
7
8
  //#region src/lib/webvpn/dgram.ts
8
- var u = /* @__PURE__ */ e({
9
- Socket: () => d,
10
- createSocket: () => _,
11
- default: () => v
12
- }), d = class extends s {
9
+ var d = /* @__PURE__ */ e({
10
+ Socket: () => f,
11
+ createSocket: () => v,
12
+ default: () => y
13
+ }), f = class extends c {
13
14
  _type;
14
15
  _localAddress;
15
16
  _remoteAddress;
16
17
  _connectedLocally;
17
18
  _connectGeneration = 0;
18
19
  _destroyed = !1;
20
+ _busyRelease;
19
21
  _webVPNUdpSocketPromise;
20
22
  _dataPort;
21
23
  _socketId;
@@ -52,38 +54,38 @@ var u = /* @__PURE__ */ e({
52
54
  if (!this._dataPortAcks || !this._dataPort || (this._dataPortConsumedBytes += e, this._dataPortAckedBytes !== 0 && this._dataPortConsumedBytes - this._dataPortAckedBytes < 524288)) return;
53
55
  this._dataPortAckedBytes = this._dataPortConsumedBytes;
54
56
  let t = {
55
- type: r,
57
+ type: i,
56
58
  consumedBytes: this._dataPortConsumedBytes
57
59
  };
58
60
  this._dataPort.postMessage(t);
59
61
  }
60
62
  _onTransportClosed(e) {
61
- this._destroyed || (this._destroyed = !0, this._dataPort?.close(), this._dataPort = void 0, this.listenerCount("error") > 0 && this.emit("error", Error(e || "WebVPN session closed")), this.emit("close"));
63
+ this._destroyed || (this._destroyed = !0, this._busyRelease?.(), this._dataPort?.close(), this._dataPort = void 0, this.listenerCount("error") > 0 && this.emit("error", Error(e || "WebVPN session closed")), this.emit("close"));
62
64
  }
63
65
  _onDataPortBatch(e) {
64
66
  let t = new DataView(e), n = !1, r, i = 0;
65
67
  for (; i + 4 <= e.byteLength;) {
66
68
  let a = t.getUint32(i);
67
69
  i += 4;
68
- let s = i + a;
69
- if (s > e.byteLength) break;
70
+ let o = i + a;
71
+ if (o > e.byteLength) break;
70
72
  let c = i + 4, l = t.getUint8(c);
71
73
  c += 1;
72
74
  let u, d, f;
73
75
  if (l === 2) {
74
76
  if (!this._remoteAddress) {
75
- i = s;
77
+ i = o;
76
78
  continue;
77
79
  }
78
80
  u = this._remoteAddress.address, d = this._remoteAddress.family, f = this._remoteAddress.port;
79
81
  } else {
80
82
  let n = new Uint8Array(e, c, l === 0 ? 4 : 16);
81
- l === 0 ? (d = "IPv4", u = `${n[0]}.${n[1]}.${n[2]}.${n[3]}`) : (d = "IPv6", u = h(n)), c += n.byteLength, f = t.getUint16(c), c += 2;
83
+ l === 0 ? (d = "IPv4", u = `${n[0]}.${n[1]}.${n[2]}.${n[3]}`) : (d = "IPv6", u = g(n)), c += n.byteLength, f = t.getUint16(c), c += 2;
82
84
  }
83
85
  let p = t.getUint32(c);
84
86
  c += 4;
85
87
  try {
86
- this.emit("message", o.from(e.slice(c, c + p)), {
88
+ this.emit("message", s.from(e.slice(c, c + p)), {
87
89
  address: u,
88
90
  family: d,
89
91
  port: f,
@@ -92,15 +94,15 @@ var u = /* @__PURE__ */ e({
92
94
  } catch (e) {
93
95
  n || (n = !0, r = e);
94
96
  }
95
- i = s;
97
+ i = o;
96
98
  }
97
99
  if (n) throw r;
98
100
  }
99
101
  _peerTail(e, t) {
100
- if (e === void 0 || t === void 0) return f;
102
+ if (e === void 0 || t === void 0) return p;
101
103
  let n = `${e}|${t}`, r = this._peerTailCache.get(n);
102
104
  if (r) return r;
103
- let i = c.isValid(e) ? m(e) : g(e), a = new Uint8Array(1 + i.byteLength + 2);
105
+ let i = l.isValid(e) ? h(e) : _(e), a = new Uint8Array(1 + i.byteLength + 2);
104
106
  return a[0] = i.byteLength === 4 ? 0 : 1, a.set(i, 1), new DataView(a.buffer).setUint16(1 + i.byteLength, t), this._peerTailCache.size >= 4096 && this._peerTailCache.clear(), this._peerTailCache.set(n, a), a;
105
107
  }
106
108
  _portSend(e, t, n) {
@@ -115,8 +117,8 @@ var u = /* @__PURE__ */ e({
115
117
  }));
116
118
  }
117
119
  addMembership(e, t) {
118
- if (c.isValid(e)) {
119
- let n = m(e), r = t && c.isValid(t) ? m(t) : new Uint8Array([
120
+ if (l.isValid(e)) {
121
+ let n = h(e), r = t && l.isValid(t) ? h(t) : new Uint8Array([
120
122
  0,
121
123
  0,
122
124
  0,
@@ -127,8 +129,8 @@ var u = /* @__PURE__ */ e({
127
129
  group: n,
128
130
  interface: r
129
131
  });
130
- } else if (l.isValid(e)) {
131
- let t = g(e);
132
+ } else if (u.isValid(e)) {
133
+ let t = _(e);
132
134
  this._setUdpOption({
133
135
  type: 7,
134
136
  group: t,
@@ -141,13 +143,13 @@ var u = /* @__PURE__ */ e({
141
143
  return this._localAddress;
142
144
  }
143
145
  bind(...e) {
144
- let n = i(...e), r = this._type === "udp6" ? "::" : "0.0.0.0", a = this.__webvpn_udp_socket_init__(t.then((e) => e.cloud.webvpn.udpSocket({
146
+ let n = a(...e), r = this._type === "udp6" ? "::" : "0.0.0.0", i = this.__webvpn_udp_socket_init__(t.then((e) => e.cloud.webvpn.udpSocket({
145
147
  type: this._type,
146
148
  address: n.address ?? r,
147
149
  port: n.port,
148
150
  dataPort: !0
149
151
  })));
150
- return n.callback && a.then((e) => {
152
+ return n.callback && i.then((e) => {
151
153
  e && n.callback.call(this);
152
154
  }), this;
153
155
  }
@@ -156,7 +158,7 @@ var u = /* @__PURE__ */ e({
156
158
  address: t.localAddress,
157
159
  family: t.localFamily,
158
160
  port: t.localPort
159
- }), this._webVPNUdpSocketPromise = e.then((e) => {
161
+ }), this._busyRelease ??= n("udp socket"), this._webVPNUdpSocketPromise = e.then((e) => {
160
162
  if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPortAcks = e.dataPortAcks === !0, this._dataPort.onmessage = (e) => {
161
163
  try {
162
164
  this._onDataPortBatch(e.data);
@@ -170,7 +172,7 @@ var u = /* @__PURE__ */ e({
170
172
  for (;;) {
171
173
  let { value: e, done: n } = await t.read();
172
174
  if (n) return;
173
- this.emit("message", o.from(e.data), {
175
+ this.emit("message", s.from(e.data), {
174
176
  address: e.address,
175
177
  family: e.family,
176
178
  port: e.port,
@@ -187,7 +189,11 @@ var u = /* @__PURE__ */ e({
187
189
  }).catch((e) => {
188
190
  this.emit("error", e);
189
191
  }), this._webVPNUdpSocketPromise.then((e) => {
190
- e && this.emit("listening");
192
+ if (!e) {
193
+ this._busyRelease?.();
194
+ return;
195
+ }
196
+ this.emit("listening");
191
197
  }), this._webVPNUdpSocketPromise;
192
198
  }
193
199
  close(e) {
@@ -195,7 +201,7 @@ var u = /* @__PURE__ */ e({
195
201
  return this._webVPNUdpSocketPromise.then(async (t) => {
196
202
  if (!t) throw Error("Socket not bound");
197
203
  let n = this._destroyed;
198
- this._destroyed = !0, this._dataPort?.close(), this._dataPort = void 0;
204
+ this._destroyed = !0, this._busyRelease?.(), this._dataPort?.close(), this._dataPort = void 0;
199
205
  try {
200
206
  await t.close();
201
207
  } finally {
@@ -237,8 +243,8 @@ var u = /* @__PURE__ */ e({
237
243
  });
238
244
  }
239
245
  dropMembership(e, t) {
240
- if (c.isValid(e)) {
241
- let n = m(e), r = t && c.isValid(t) ? m(t) : new Uint8Array([
246
+ if (l.isValid(e)) {
247
+ let n = h(e), r = t && l.isValid(t) ? h(t) : new Uint8Array([
242
248
  0,
243
249
  0,
244
250
  0,
@@ -249,8 +255,8 @@ var u = /* @__PURE__ */ e({
249
255
  group: n,
250
256
  interface: r
251
257
  });
252
- } else if (l.isValid(e)) {
253
- let t = g(e);
258
+ } else if (u.isValid(e)) {
259
+ let t = _(e);
254
260
  this._setUdpOption({
255
261
  type: 8,
256
262
  group: t,
@@ -283,7 +289,7 @@ var u = /* @__PURE__ */ e({
283
289
  }
284
290
  send(...e) {
285
291
  this._webVPNUdpSocketPromise || this.bind();
286
- let t = a(...e), n = p(t.message), r = n;
292
+ let t = o(...e), n = m(t.message), r = n;
287
293
  if (t.hasRange) {
288
294
  let { offset: e, length: i } = t;
289
295
  if (!Number.isInteger(e) || e < 0 || e > n.byteLength) throw Object.assign(/* @__PURE__ */ RangeError("\"offset\" is outside of buffer bounds"), { code: "ERR_BUFFER_OUT_OF_BOUNDS" });
@@ -295,7 +301,7 @@ var u = /* @__PURE__ */ e({
295
301
  this._webVPNUdpSocketPromise.then((e) => {
296
302
  if (!e) throw Error("Socket not bound");
297
303
  let n = t.callback, a = t.address ?? i, o = this._remoteAddress !== void 0 && t.address === void 0;
298
- if (this._dataPort && (o || c.isValid(a) || l.isValid(a))) {
304
+ if (this._dataPort && (o || l.isValid(a) || u.isValid(a))) {
299
305
  this._portSend(r, o ? void 0 : a, o ? void 0 : t.port), n?.call(this, null, r.byteLength);
300
306
  return;
301
307
  }
@@ -356,21 +362,21 @@ var u = /* @__PURE__ */ e({
356
362
  this.close(e);
357
363
  });
358
364
  }
359
- }, f = new Uint8Array([2]), p = (e) => {
360
- if (typeof e == "string") return n.encode(e);
365
+ }, p = new Uint8Array([2]), m = (e) => {
366
+ if (typeof e == "string") return r.encode(e);
361
367
  if (e instanceof Uint8Array) return e;
362
368
  if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
363
369
  if (Array.isArray(e)) {
364
- let t = e.map(p), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
370
+ let t = e.map(m), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
365
371
  for (let e of t) n.set(e, r), r += e.byteLength;
366
372
  return n;
367
373
  }
368
374
  return new Uint8Array(e);
369
- }, m = (e) => {
375
+ }, h = (e) => {
370
376
  let t = e.split(".").map((e) => parseInt(e, 10));
371
377
  if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
372
378
  return new Uint8Array(t);
373
- }, h = (e) => {
379
+ }, g = (e) => {
374
380
  let t = [];
375
381
  for (let n = 0; n < 16; n += 2) t.push(e[n] << 8 | e[n + 1]);
376
382
  let n = -1, r = 1;
@@ -384,16 +390,16 @@ var u = /* @__PURE__ */ e({
384
390
  i - e > r && (n = e, r = i - e), e = i;
385
391
  }
386
392
  return n === -1 ? t.map((e) => e.toString(16)).join(":") : `${t.slice(0, n).map((e) => e.toString(16)).join(":")}::${t.slice(n + r).map((e) => e.toString(16)).join(":")}`;
387
- }, g = (e) => {
388
- let t = new l(e).getBitsBase16(0, 128).match(/.{2}/g);
393
+ }, _ = (e) => {
394
+ let t = new u(e).getBitsBase16(0, 128).match(/.{2}/g);
389
395
  if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
390
396
  return new Uint8Array(t.map((e) => parseInt(e, 16)));
391
- }, _ = (e, t) => {
392
- let n = new d(typeof e == "string" ? { type: e } : e);
397
+ }, v = (e, t) => {
398
+ let n = new f(typeof e == "string" ? { type: e } : e);
393
399
  return t && n.on("message", t), n;
394
- }, v = {
395
- Socket: d,
396
- createSocket: _
400
+ }, y = {
401
+ Socket: f,
402
+ createSocket: v
397
403
  };
398
404
  //#endregion
399
- export { u as i, _ as n, v as r, d as t };
405
+ export { d as i, v as n, y as r, f as t };
package/dgram.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-D2Or5f2e.cjs");exports.Socket=e.t,exports.createSocket=e.n,exports.default=e.r;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-9hn582qO.cjs");exports.Socket=e.t,exports.createSocket=e.n,exports.default=e.r;
package/dgram.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as UdpSocketOption, t as Resolvers } from "./api-DnO1DsJC.js";
1
+ import { n as UdpSocketOption, t as Resolvers } from "./api-B0qRPCcX.js";
2
2
  import { Buffer } from "buffer";
3
3
  import { AddressInfo } from "net";
4
4
  import { EventEmitter } from "events";
@@ -30,6 +30,7 @@ declare class Socket extends EventEmitter implements Socket$2 {
30
30
  _connectedLocally?: boolean;
31
31
  _connectGeneration: number;
32
32
  _destroyed: boolean;
33
+ _busyRelease?: () => void;
33
34
  _webVPNUdpSocketPromise?: Promise<Awaited<ReturnType<WebVpnUdpSocket>> | undefined>;
34
35
  _dataPort?: MessagePort;
35
36
  _socketId?: number;
package/dgram.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as e, r as t, t as n } from "./dgram-DlGl_ho1.js";
1
+ import { n as e, r as t, t as n } from "./dgram-TB03kqMr.js";
2
2
  export { n as Socket, e as createSocket, t as default };
package/dns.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-kHMHDGar.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.t.then(t=>t.cloud.dns.lookup(e,n));exports.lookup=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-CKO3Hw-O.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.r.then(t=>t.cloud.dns.lookup(e,n));exports.lookup=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
package/dns.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { t } from "./api-DQ-V4Lls.js";
2
+ import { r as t } from "./api-BqRjtWm_.js";
3
3
  //#region src/lib/dns.ts
4
4
  var n = /* @__PURE__ */ e({ lookup: () => r }), r = (e, n) => t.then((t) => t.cloud.dns.lookup(e, n));
5
5
  //#endregion
@@ -0,0 +1,78 @@
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, U as _, V as v, a as y, b, c as x, d as S, g as C, h as w, i as T, j as E, k as D, l as O, m as k, n as A, o as j, p as M, r as N, s as P, t as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./lib-k3lstfa4.js";
3
+ import { r as H } from "./api-BqRjtWm_.js";
4
+ import { n as U, t as W } from "./proxy--aljNHvG.js";
5
+ import { available as G, fetch as K } from "./desktop.js";
6
+ //#region src/lib/extension-prompt.ts
7
+ var q = async (e) => {
8
+ if (typeof window > "u") return !1;
9
+ if (o()) return !0;
10
+ let t = await H, n = null, r = new Promise((e) => {
11
+ n = () => {
12
+ o() && e(!0);
13
+ }, p.addEventListener("statuschange", n);
14
+ }), i = t.installPrompt.show(e).then(() => !1), a = await Promise.race([r, i]);
15
+ return n && p.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
16
+ }, J = null;
17
+ c(() => (J ||= q().then(() => void 0).finally(() => {
18
+ J = null;
19
+ }), J));
20
+ //#endregion
21
+ //#region src/lib/auto.ts
22
+ var Y = () => typeof document < "u" && o(), X = async (e, t) => {
23
+ if (U(e), t?.credentials === "include") {
24
+ if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
25
+ return R(e, t);
26
+ }
27
+ return Y() ? R(e, {
28
+ ...t,
29
+ credentials: "omit"
30
+ }) : G() ? K(e, t) : W(e, t);
31
+ }, Z = /* @__PURE__ */ e({
32
+ ATTACH_FRAME_EVENT_KEY: () => A,
33
+ FORGEABLE_HEADERS: () => t,
34
+ LOCATOR_DENIED: () => w,
35
+ LOCATOR_ERROR: () => C,
36
+ LOCATOR_UNSUPPORTED: () => k,
37
+ assertAttachableFrameUrl: () => P,
38
+ assertFetchableUrl: () => r,
39
+ assertForgeableHeaders: () => E,
40
+ assertLockdownApplicable: () => x,
41
+ assertOneCookieIdentity: () => u,
42
+ attachFrame: () => N,
43
+ attachFramePermission: () => T,
44
+ available: () => Y,
45
+ box: () => V,
46
+ cookies: () => z,
47
+ createFrame: () => y,
48
+ createVideoElementHandle: () => n,
49
+ events: () => p,
50
+ extension: () => p,
51
+ fetch: () => R,
52
+ fetchCredentialedPermission: () => g,
53
+ fetchLocalPermission: () => a,
54
+ fetchPermission: () => i,
55
+ gotoPermission: () => j,
56
+ handleRevivableModules: () => m,
57
+ hasForgedCookie: () => d,
58
+ isBlockedFetchUrl: () => f,
59
+ isBlockedFrameUrl: () => O,
60
+ isExtensionExposed: () => o,
61
+ isLocalNetworkUrl: () => D,
62
+ isLocatorDenied: () => M,
63
+ isLocatorUnsupported: () => I,
64
+ isTerminalError: () => S,
65
+ isType: () => v,
66
+ modifyRequestHeadersPermission: () => L,
67
+ permissions: () => F,
68
+ promptInstall: () => q,
69
+ readCookiePermission: () => h,
70
+ removeRequestHeaderRule: () => B,
71
+ revive: () => s,
72
+ setMissingExtensionHandler: () => c,
73
+ setRequestHeaderRule: () => b,
74
+ type: () => _,
75
+ waitForExtensionExposure: () => l
76
+ });
77
+ //#endregion
78
+ export { q as i, X as n, Y as r, Z as t };