@fkn/lib 0.9.20 → 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 (75) hide show
  1. package/account.cjs +1 -1
  2. package/account.js +24 -17
  3. package/{api-CyWF0RUj.d.ts → api-B0qRPCcX.d.ts} +8 -0
  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-CQVtRvcI.d.ts → cloud-BTpJn4jy.d.ts} +2 -2
  20. package/{cloud-C_1Dt_tR.js → cloud-BlR1He17.js} +77 -74
  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-jRuNpBs3.js → extension-BI2NxGtC.js} +2 -2
  32. package/{extension-B3nD2u7c.cjs → extension-rFQQpEqJ.cjs} +1 -1
  33. package/extension.cjs +1 -1
  34. package/extension.js +1 -1
  35. package/fs/promises.cjs +1 -1
  36. package/fs/promises.js +1 -1
  37. package/fs-BUcpl9k4.cjs +1 -0
  38. package/fs-bpb3Ysdd.js +347 -0
  39. package/fs.cjs +1 -1
  40. package/fs.js +1 -1
  41. package/http.cjs +1 -1
  42. package/http.d.ts +1 -1
  43. package/http.js +1 -1
  44. package/index.cjs +1 -1
  45. package/index.d.ts +9 -15
  46. package/index.js +86 -33
  47. package/net-C2fIMWFr.cjs +1 -0
  48. package/{net-ByL9yG7X.d.ts → net-CnYxw_sB.d.ts} +3 -1
  49. package/{net-BbmQeMpt.js → net-Ct8ywVAk.js} +52 -41
  50. package/net.cjs +1 -1
  51. package/net.d.ts +1 -1
  52. package/net.js +1 -1
  53. package/node-fs-BZCQUmeE.js +404 -0
  54. package/node-fs-DZPGCYWg.cjs +1 -0
  55. package/opfs.cjs +1 -1
  56. package/opfs.js +1 -1
  57. package/package.json +1 -1
  58. package/packages.cjs +1 -1
  59. package/packages.js +165 -149
  60. package/proxy--aljNHvG.js +69 -0
  61. package/{proxy-RU8sbq68.d.ts → proxy-CuXtzxSQ.d.ts} +1 -1
  62. package/proxy-oHfEx1cn.cjs +1 -0
  63. package/{storage-C8hBot2f.js → storage-C1nW5Tvh.js} +1 -1
  64. package/{storage-BW-jDLUL.cjs → storage-rXHvV2FU.cjs} +1 -1
  65. package/api-DQ-V4Lls.js +0 -220
  66. package/api-kHMHDGar.cjs +0 -3
  67. package/cloud-C8jfO0iJ.cjs +0 -1
  68. package/dgram-D2Or5f2e.cjs +0 -1
  69. package/fs-BW5mVMmu.js +0 -340
  70. package/fs-DJm0bhjg.cjs +0 -1
  71. package/net-COzDDBnS.cjs +0 -1
  72. package/node-fs-BMR2yCEt.cjs +0 -1
  73. package/node-fs-DKfokOlh.js +0 -401
  74. package/proxy-B0gNjT8-.cjs +0 -1
  75. package/proxy-BpqvCJmA.js +0 -43
@@ -1,40 +1,41 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
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 { r as s, t as c } from "./api-DQ-V4Lls.js";
4
- import { t as l } from "./proxy-BpqvCJmA.js";
5
- import { t as u } from "./dns.js";
6
- import { t as d } from "./cloud/fs.js";
7
- import { s as f } from "./net-BbmQeMpt.js";
8
- import { i as p } from "./dgram-DlGl_ho1.js";
9
- import { t as m } from "./http.js";
10
- import { expose as h } from "osra";
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";
11
12
  //#region node_modules/@mfkn/web-extension/lib/lib/locator-permissions.js
12
- var g = {
13
+ var _ = {
13
14
  scope: "frame.fetchRead",
14
15
  category: "network",
15
16
  severity: 3,
16
17
  unsafe: !0,
17
18
  title: "Read your account data on this site",
18
19
  description: "Lets the app read pages and data from this site as you, using the session in the frame."
19
- }, _ = {
20
+ }, v = {
20
21
  scope: "frame.fetchWrite",
21
22
  category: "network",
22
23
  severity: 3,
23
24
  unsafe: !0,
24
25
  title: "Change your account data on this site",
25
26
  description: "Lets the app send changes to this site as you, using the session in the frame."
26
- }, v = /* @__PURE__ */ new Set([
27
+ }, y = /* @__PURE__ */ new Set([
27
28
  "GET",
28
29
  "HEAD",
29
30
  "OPTIONS"
30
- ]), y = (e, t) => v.has((t?.method ?? "GET").toUpperCase()) ? g : _, b = (e) => {
31
+ ]), b = (e, t) => y.has((t?.method ?? "GET").toUpperCase()) ? _ : v, x = (e) => {
31
32
  let t = [];
32
33
  for (let n of e) {
33
34
  let e = n.trim().toLowerCase();
34
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));
35
36
  }
36
37
  return t;
37
- }, x = (e, t) => {
38
+ }, S = (e, t) => {
38
39
  if (!e.session) return {
39
40
  kind: "refuse",
40
41
  reason: "frame.fetch on the cloud backend needs its own session: attach with syncCookies: false"
@@ -66,15 +67,15 @@ var g = {
66
67
  targetHost: n.hostname,
67
68
  promptHosts: r
68
69
  };
69
- }, S = (e) => e, C = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", w = 2e4, T = 65e3, E = 3e4, D = 5e3, O = /* @__PURE__ */ new Set([]), k = () => "https://fkn.app", A = (e) => !e || e === "about:blank", j = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, M = ({ target: e, session: t, domains: n }) => {
70
- let r = new URL("/attach-frame", k());
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());
71
72
  return e && r.searchParams.set("url", e), t && r.searchParams.set("session", t), n.length && r.searchParams.set("domains", n.join(",")), r.href;
72
- }, N = (e, t, n) => {
73
+ }, P = (e, t, n) => {
73
74
  let r, i = new Promise((e, i) => {
74
75
  r = setTimeout(() => i(Error(n)), t);
75
76
  });
76
77
  return Promise.race([e, i]).finally(() => clearTimeout(r));
77
- }, P = (e, t) => {
78
+ }, F = (e, t) => {
78
79
  let n = () => {
79
80
  a(), t();
80
81
  }, r = e.parentNode, i = new MutationObserver(() => {
@@ -83,14 +84,14 @@ var g = {
83
84
  window.removeEventListener("pagehide", n), i.disconnect();
84
85
  };
85
86
  window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
86
- }, F = () => Object.assign(/* @__PURE__ */ Error("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), { name: a }), I = (e, 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) => {
87
88
  let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
88
89
  return [...new Set(n)].join("; ");
89
- }, L = [
90
+ }, R = [
90
91
  300,
91
92
  1200,
92
93
  4e3
93
- ], R = (e) => {
94
+ ], z = (e) => {
94
95
  let t = () => {
95
96
  if (!e.isConnected) return;
96
97
  let t = e.style.height, n = e.getBoundingClientRect();
@@ -99,90 +100,92 @@ var g = {
99
100
  }, 50));
100
101
  };
101
102
  t();
102
- for (let e of L) setTimeout(t, e);
103
- }, z = (e) => {
103
+ for (let e of R) setTimeout(t, e);
104
+ }, B = (e) => {
104
105
  let t = e.getAttribute("sandbox");
105
106
  if (t === null) return;
106
107
  let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
107
108
  if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
108
- }, B = async ({ iframe: e, domains: a = [], syncCookies: s = !0, lockdown: l = !1 }) => {
109
+ }, V = async ({ iframe: e, domains: a = [], syncCookies: s = !0, lockdown: u = !1 }) => {
109
110
  if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
110
- if (l) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
111
+ if (u) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
111
112
  if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
112
- z(e);
113
- let u = e.getAttribute("src") ?? "", d = (() => {
114
- if (A(u)) return null;
113
+ B(e);
114
+ let d = e.getAttribute("src") ?? "", f = (() => {
115
+ if (j(d)) return null;
115
116
  try {
116
- return new URL(e.src || u, location.href);
117
+ return new URL(e.src || d, location.href);
117
118
  } catch {
118
- throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${u}`);
119
+ throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${d}`);
119
120
  }
120
121
  })();
121
- if (d) {
122
- let e = new URL("/attach-frame", k());
123
- if (d.origin === e.origin && d.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");
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");
124
125
  }
125
- let f = d?.href ?? "";
126
- f && o(f);
127
- let p = f, m = j(s), g = b(a), _ = /* @__PURE__ */ new Set();
126
+ let p = f?.href ?? "";
127
+ p && o(p);
128
+ let m = p, h = M(s), _ = x(a), v = /* @__PURE__ */ new Set();
128
129
  try {
129
- _.add(new URL(f).origin);
130
+ v.add(new URL(p).origin);
130
131
  } catch {}
131
- let v = new AbortController(), L = e.referrerPolicy, B = e.allow;
132
- if (e.referrerPolicy = "origin", e.allow = I(C, e.allow), e.src = M({
133
- target: f,
134
- session: m,
135
- domains: g
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: _
136
137
  }), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
137
138
  try {
138
- let a = await N(h({}, {
139
+ let a = await P(g({}, {
139
140
  key: "fkn-attach-frame",
140
- origin: k(),
141
+ origin: A(),
141
142
  transport: {
142
143
  receive: window,
143
144
  emit: e.contentWindow
144
145
  },
145
- unregisterSignal: v.signal,
146
- revivableModules: S(t)
147
- }), w, "cloud.attachFrame: timed out connecting to the render proxy page");
148
- await N(a.ready(), T, "cloud.attachFrame: the render proxy never became ready"), f && R(e), P(e, () => v.abort());
149
- let o = e.contentWindow, s = () => {
150
- if (!(!v.signal.aborted && e.isConnected && e.contentWindow === o)) throw v.abort(), F();
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();
151
154
  };
152
155
  return r({
153
156
  executor: {
154
- execute: (e, t, n) => O.has(t) ? Promise.reject(i(t, "cloud")) : (s(), a.executeLocator(e, t, n)),
157
+ execute: (e, t, n) => k.has(t) ? Promise.reject(i(t, "cloud")) : (u(), a.executeLocator(e, t, n)),
155
158
  highlight: async () => {}
156
159
  },
157
160
  gate: async (e) => {
158
161
  if (e.operation !== "fetch") return;
159
- let t = x({
160
- session: m,
161
- declaredHosts: g,
162
- approvedOrigins: _
162
+ let t = S({
163
+ session: h,
164
+ declaredHosts: _,
165
+ approvedOrigins: v
163
166
  }, e.args[0]);
164
167
  if (t.kind === "refuse") throw n(t.reason, "fetch");
165
168
  if (!await (await c).frameConsent.ensure({
166
- scope: y(e.args[0], e.args[1]).scope,
169
+ scope: b(e.args[0], e.args[1]).scope,
167
170
  hosts: t.promptHosts
168
171
  })) throw n("frame.fetch: the user did not grant this", "fetch");
169
172
  },
170
173
  goto: async (t, n = {}) => {
171
174
  let r = new URL(t, location.href).href;
172
- s();
175
+ u();
173
176
  let { timeoutMs: i } = n;
174
- await N(a.goto(r, n), (i ?? E) + D, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded"), p = r;
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;
175
178
  try {
176
- _.add(new URL(r).origin);
179
+ v.add(new URL(r).origin);
177
180
  } catch {}
178
- R(e);
181
+ z(e);
179
182
  },
180
- url: () => p
183
+ url: () => m
181
184
  });
182
185
  } catch (t) {
183
- throw v.abort(), e.referrerPolicy = L, e.allow = B, e.src = f || "about:blank", t;
186
+ throw y.abort(), e.referrerPolicy = R, e.allow = V, e.src = p || "about:blank", t;
184
187
  }
185
- }, V = () => typeof window < "u" && !0, H = async () => {
188
+ }, H = () => typeof window < "u" && !0, U = async () => {
186
189
  let e = await c.then((e) => e.cloud.quota());
187
190
  return {
188
191
  premium: e.premium,
@@ -194,16 +197,16 @@ var g = {
194
197
  bytesPerSecond: e.bytesPerSecond,
195
198
  bitsPerSecond: e.bytesPerSecond * 8
196
199
  };
197
- }, U = /* @__PURE__ */ e({
198
- attachFrame: () => B,
199
- available: () => W,
200
- dgram: () => p,
201
- dns: () => u,
202
- fetch: () => l,
203
- fs: () => d,
204
- http: () => m,
205
- net: () => f,
206
- quota: () => H
207
- }), W = () => s;
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;
208
211
  //#endregion
209
- export { V as a, B as i, U as n, H as r, W as t };
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-C8jfO0iJ.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-RU8sbq68.js";
2
- import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-CQVtRvcI.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-ByL9yG7X.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-C_1Dt_tR.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-CyWF0RUj.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
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
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 { t as H } from "./api-DQ-V4Lls.js";
4
- import { n as U, t as W } from "./proxy-BpqvCJmA.js";
3
+ import { r as H } from "./api-BqRjtWm_.js";
4
+ import { n as U, t as W } from "./proxy--aljNHvG.js";
5
5
  import { available as G, fetch as K } from "./desktop.js";
6
6
  //#region src/lib/extension-prompt.ts
7
7
  var q = async (e) => {