@fkn/lib 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{api-BYUraih6.d.ts → api-CI4d96Ty.d.ts} +156 -24
- package/{background-B_VgpARk.cjs → background-Bu7dBd_Z.cjs} +1 -1
- package/{background-BVBbBOmL.js → background-DLnt6fYS.js} +5 -5
- package/cloud/dgram.cjs +1 -1
- package/cloud/dgram.js +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.d.ts +2 -2
- package/cloud/fs.js +18 -15
- package/cloud/net.cjs +1 -1
- package/cloud/net.d.ts +1 -1
- package/cloud/net.js +3 -3
- package/{cloud-gklfa4ZN.d.ts → cloud-BxPdeAuj.d.ts} +4 -4
- package/cloud-DevROE3T.cjs +1 -0
- package/{cloud-BFyf2uC7.js → cloud-Pibu_mY3.js} +32 -18
- package/cloud.cjs +1 -1
- package/cloud.d.ts +3 -3
- package/cloud.js +4 -4
- package/desktop.d.ts +6 -0
- package/{dgram-wtjARbt0.js → dgram-CKRbKVzG.js} +140 -86
- package/dgram-DcvdNkg6.cjs +1 -0
- package/dgram.cjs +1 -1
- package/dgram.d.ts +16 -1
- package/dgram.js +1 -1
- package/{extension-CPj10qwa.js → extension-4ib5y95s.js} +1 -1
- package/{extension-D-NUXxzF.cjs → extension-DVHdBvOz.cjs} +1 -1
- package/extension.cjs +1 -1
- package/extension.js +2 -2
- package/fs/promises.cjs +1 -1
- package/fs/promises.js +1 -1
- package/{fs-D6nNf1mR.js → fs-7E0-tE2x.js} +11 -11
- package/{fs-K7ROdxDx.d.ts → fs-BEfsbriO.d.ts} +14 -2
- package/{fs-BfmfMBiw.cjs → fs-BN4hkppN.cjs} +1 -1
- package/fs.cjs +1 -1
- package/fs.js +1 -1
- package/http.cjs +1 -1
- package/http.d.ts +1 -1
- package/http.js +1 -1
- package/index.cjs +1 -1
- package/index.d.ts +3 -3
- package/index.js +6 -6
- package/{net-DKMWPXb_.js → net-BFYMbE4N.js} +49 -26
- package/net-BPpdNdpy.cjs +1 -0
- package/{net-BDW1AVX1.d.ts → net-Cx8lDWau.d.ts} +13 -4
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +3 -3
- package/package.json +1 -1
- package/{packages-D36R2vBv.d.ts → packages-CErlrrLB.d.ts} +2 -2
- package/packages.d.ts +2 -2
- package/{proxy-C8SG1Beo.js → proxy-Cusnx9Ex.js} +1 -1
- package/{proxy-bPaU3-Cz.cjs → proxy-Du95zAKk.cjs} +1 -1
- package/storage-DMETg6sP.js +30 -0
- package/storage-ezLkqmQR.cjs +1 -0
- package/{utils-DPtyxGQu.js → utils-DVlbuXmW.js} +6 -4
- package/utils-QfNXtEhb.cjs +1 -0
- package/cloud-5o7yJHeX.cjs +0 -1
- package/dgram-CE43gJq9.cjs +0 -1
- package/net-CpuAhaQC.cjs +0 -1
- package/storage-OkwsFLN1.cjs +0 -1
- package/storage-TmeyhZGt.js +0 -19
- package/utils-CoimMjf9.cjs +0 -1
package/cloud.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-Du95zAKk.cjs"),t=require("./cloud-DevROE3T.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net-BPpdNdpy.cjs"),a=require("./dgram-DcvdNkg6.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,7 +1,7 @@
|
|
|
1
|
-
import { a as attachFrame, i as quota, o as cloudFetch, r as QuotaStatus, t as available } from "./cloud-
|
|
1
|
+
import { a as attachFrame, i as quota, o as cloudFetch, r as QuotaStatus, t as available } from "./cloud-BxPdeAuj.js";
|
|
2
2
|
import { t as dns_d_exports } from "./dns.js";
|
|
3
|
-
import { n as fs_d_exports } from "./fs-
|
|
4
|
-
import { s as net_d_exports } from "./net-
|
|
3
|
+
import { n as fs_d_exports } from "./fs-BEfsbriO.js";
|
|
4
|
+
import { s as net_d_exports } from "./net-Cx8lDWau.js";
|
|
5
5
|
import { t as dgram_d_exports } from "./dgram.js";
|
|
6
6
|
import { t as http_d_exports } from "./http.js";
|
|
7
7
|
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-
|
|
2
|
-
import { i as t, r as n, t as r } from "./cloud-
|
|
1
|
+
import { t as e } from "./proxy-Cusnx9Ex.js";
|
|
2
|
+
import { i as t, r as n, t as r } from "./cloud-Pibu_mY3.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-
|
|
6
|
-
import { i as s } from "./dgram-
|
|
5
|
+
import { s as o } from "./net-BFYMbE4N.js";
|
|
6
|
+
import { i as s } from "./dgram-CKRbKVzG.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 };
|
package/desktop.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
declare namespace desktop_d_exports {
|
|
2
2
|
export { available, dgram, dns, fetch, fs, net };
|
|
3
3
|
}
|
|
4
|
+
/** Typed placeholder for the planned desktop backend. Always false in this release. */
|
|
4
5
|
declare const available: () => boolean;
|
|
6
|
+
/** Planned desktop fetch backend. Throws in this release. */
|
|
5
7
|
declare const fetch: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
8
|
+
/** Planned desktop DNS backend. Every method throws in this release. */
|
|
6
9
|
declare const dns: {
|
|
7
10
|
lookup: (..._args: unknown[]) => never;
|
|
8
11
|
};
|
|
12
|
+
/** Planned desktop TCP backend. Every method throws in this release. */
|
|
9
13
|
declare const net: {
|
|
10
14
|
connect: (..._args: unknown[]) => never;
|
|
11
15
|
createConnection: (..._args: unknown[]) => never;
|
|
12
16
|
createServer: (..._args: unknown[]) => never;
|
|
13
17
|
};
|
|
18
|
+
/** Planned desktop UDP backend. Every method throws in this release. */
|
|
14
19
|
declare const dgram: {
|
|
15
20
|
createSocket: (..._args: unknown[]) => never;
|
|
16
21
|
};
|
|
22
|
+
/** Planned desktop storage backend. available() resolves false; storage operations throw. */
|
|
17
23
|
declare const fs: {
|
|
18
24
|
available: () => Promise<boolean>;
|
|
19
25
|
readFile: (..._args: unknown[]) => never;
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-DF993M8W.js";
|
|
2
2
|
import { t } from "./api--bnCFd4w.js";
|
|
3
|
-
import {
|
|
4
|
-
import { Buffer as
|
|
5
|
-
import { EventEmitter as
|
|
6
|
-
import { Address4 as
|
|
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";
|
|
7
7
|
//#region src/lib/webvpn/dgram.ts
|
|
8
|
-
var
|
|
9
|
-
Socket: () =>
|
|
10
|
-
createSocket: () =>
|
|
11
|
-
default: () =>
|
|
12
|
-
}),
|
|
8
|
+
var u = /* @__PURE__ */ e({
|
|
9
|
+
Socket: () => d,
|
|
10
|
+
createSocket: () => _,
|
|
11
|
+
default: () => v
|
|
12
|
+
}), d = class extends s {
|
|
13
13
|
_type;
|
|
14
14
|
_localAddress;
|
|
15
15
|
_remoteAddress;
|
|
16
|
+
_connectedLocally;
|
|
17
|
+
_connectGeneration = 0;
|
|
18
|
+
_destroyed = !1;
|
|
16
19
|
_webVPNUdpSocketPromise;
|
|
17
20
|
_dataPort;
|
|
18
21
|
_socketId;
|
|
@@ -42,40 +45,62 @@ var l = /* @__PURE__ */ e({
|
|
|
42
45
|
}
|
|
43
46
|
});
|
|
44
47
|
}
|
|
48
|
+
_dataPortAcks = !1;
|
|
49
|
+
_dataPortConsumedBytes = 0;
|
|
50
|
+
_dataPortAckedBytes = 0;
|
|
51
|
+
_ackDataPortBatch(e) {
|
|
52
|
+
if (!this._dataPortAcks || !this._dataPort || (this._dataPortConsumedBytes += e, this._dataPortAckedBytes !== 0 && this._dataPortConsumedBytes - this._dataPortAckedBytes < 524288)) return;
|
|
53
|
+
this._dataPortAckedBytes = this._dataPortConsumedBytes;
|
|
54
|
+
let t = {
|
|
55
|
+
type: r,
|
|
56
|
+
consumedBytes: this._dataPortConsumedBytes
|
|
57
|
+
};
|
|
58
|
+
this._dataPort.postMessage(t);
|
|
59
|
+
}
|
|
60
|
+
_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"));
|
|
62
|
+
}
|
|
45
63
|
_onDataPortBatch(e) {
|
|
46
|
-
let t = new DataView(e), n = 0;
|
|
47
|
-
for (;
|
|
48
|
-
let
|
|
49
|
-
|
|
50
|
-
let
|
|
51
|
-
if (
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
if (
|
|
64
|
+
let t = new DataView(e), n = !1, r, i = 0;
|
|
65
|
+
for (; i + 4 <= e.byteLength;) {
|
|
66
|
+
let a = t.getUint32(i);
|
|
67
|
+
i += 4;
|
|
68
|
+
let s = i + a;
|
|
69
|
+
if (s > e.byteLength) break;
|
|
70
|
+
let c = i + 4, l = t.getUint8(c);
|
|
71
|
+
c += 1;
|
|
72
|
+
let u, d, f;
|
|
73
|
+
if (l === 2) {
|
|
56
74
|
if (!this._remoteAddress) {
|
|
57
|
-
|
|
75
|
+
i = s;
|
|
58
76
|
continue;
|
|
59
77
|
}
|
|
60
|
-
|
|
78
|
+
u = this._remoteAddress.address, d = this._remoteAddress.family, f = this._remoteAddress.port;
|
|
61
79
|
} else {
|
|
62
|
-
let n = new Uint8Array(e,
|
|
63
|
-
|
|
80
|
+
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;
|
|
82
|
+
}
|
|
83
|
+
let p = t.getUint32(c);
|
|
84
|
+
c += 4;
|
|
85
|
+
try {
|
|
86
|
+
this.emit("message", o.from(e.slice(c, c + p)), {
|
|
87
|
+
address: u,
|
|
88
|
+
family: d,
|
|
89
|
+
port: f,
|
|
90
|
+
size: p
|
|
91
|
+
});
|
|
92
|
+
} catch (e) {
|
|
93
|
+
n || (n = !0, r = e);
|
|
64
94
|
}
|
|
65
|
-
|
|
66
|
-
o += 4, this.emit("message", a.from(e.slice(o, o + d)), {
|
|
67
|
-
address: c,
|
|
68
|
-
family: l,
|
|
69
|
-
port: u,
|
|
70
|
-
size: d
|
|
71
|
-
}), n = i;
|
|
95
|
+
i = s;
|
|
72
96
|
}
|
|
97
|
+
if (n) throw r;
|
|
73
98
|
}
|
|
74
99
|
_peerTail(e, t) {
|
|
75
|
-
if (e === void 0 || t === void 0) return
|
|
100
|
+
if (e === void 0 || t === void 0) return f;
|
|
76
101
|
let n = `${e}|${t}`, r = this._peerTailCache.get(n);
|
|
77
102
|
if (r) return r;
|
|
78
|
-
let i =
|
|
103
|
+
let i = c.isValid(e) ? m(e) : g(e), a = new Uint8Array(1 + i.byteLength + 2);
|
|
79
104
|
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;
|
|
80
105
|
}
|
|
81
106
|
_portSend(e, t, n) {
|
|
@@ -90,8 +115,8 @@ var l = /* @__PURE__ */ e({
|
|
|
90
115
|
}));
|
|
91
116
|
}
|
|
92
117
|
addMembership(e, t) {
|
|
93
|
-
if (
|
|
94
|
-
let n =
|
|
118
|
+
if (c.isValid(e)) {
|
|
119
|
+
let n = m(e), r = t && c.isValid(t) ? m(t) : new Uint8Array([
|
|
95
120
|
0,
|
|
96
121
|
0,
|
|
97
122
|
0,
|
|
@@ -102,8 +127,8 @@ var l = /* @__PURE__ */ e({
|
|
|
102
127
|
group: n,
|
|
103
128
|
interface: r
|
|
104
129
|
});
|
|
105
|
-
} else if (
|
|
106
|
-
let t =
|
|
130
|
+
} else if (l.isValid(e)) {
|
|
131
|
+
let t = g(e);
|
|
107
132
|
this._setUdpOption({
|
|
108
133
|
type: 7,
|
|
109
134
|
group: t,
|
|
@@ -116,27 +141,36 @@ var l = /* @__PURE__ */ e({
|
|
|
116
141
|
return this._localAddress;
|
|
117
142
|
}
|
|
118
143
|
bind(...e) {
|
|
119
|
-
let n =
|
|
144
|
+
let n = i(...e), r = this._type === "udp6" ? "::" : "0.0.0.0";
|
|
120
145
|
return this._webVPNUdpSocketPromise = t.then((e) => e.cloud.webvpn.udpSocket({
|
|
121
146
|
type: this._type,
|
|
122
|
-
address: n.address ??
|
|
147
|
+
address: n.address ?? r,
|
|
123
148
|
port: n.port,
|
|
124
149
|
dataPort: !0
|
|
125
150
|
})).then((e) => {
|
|
126
|
-
if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPort.onmessage = (e) =>
|
|
151
|
+
if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPortAcks = e.dataPortAcks === !0, this._dataPort.onmessage = (e) => {
|
|
152
|
+
try {
|
|
153
|
+
this._onDataPortBatch(e.data);
|
|
154
|
+
} finally {
|
|
155
|
+
this._ackDataPortBatch(e.data.byteLength);
|
|
156
|
+
}
|
|
157
|
+
};
|
|
127
158
|
else {
|
|
128
|
-
let t = e.dataReadableStream.getReader()
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
159
|
+
let t = e.dataReadableStream.getReader();
|
|
160
|
+
(async () => {
|
|
161
|
+
for (;;) {
|
|
162
|
+
let { value: e, done: n } = await t.read();
|
|
163
|
+
if (n) return;
|
|
164
|
+
this.emit("message", o.from(e.data), {
|
|
165
|
+
address: e.address,
|
|
166
|
+
family: e.family,
|
|
167
|
+
port: e.port,
|
|
168
|
+
size: e.size
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
})().catch((e) => this._onTransportClosed(e instanceof Error ? e.message : void 0));
|
|
138
172
|
}
|
|
139
|
-
return this._localAddress = {
|
|
173
|
+
return e.closed?.then((e) => this._onTransportClosed(e?.reason)).catch(() => {}), this._localAddress = {
|
|
140
174
|
address: e.localAddress,
|
|
141
175
|
family: e.localFamily,
|
|
142
176
|
port: e.localPort
|
|
@@ -153,38 +187,51 @@ var l = /* @__PURE__ */ e({
|
|
|
153
187
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
154
188
|
return this._webVPNUdpSocketPromise.then(async (t) => {
|
|
155
189
|
if (!t) throw Error("Socket not bound");
|
|
156
|
-
|
|
157
|
-
|
|
190
|
+
let n = this._destroyed;
|
|
191
|
+
this._destroyed = !0, this._dataPort?.close(), this._dataPort = void 0;
|
|
192
|
+
try {
|
|
193
|
+
await t.close();
|
|
194
|
+
} finally {
|
|
195
|
+
try {
|
|
196
|
+
e && e();
|
|
197
|
+
} finally {
|
|
198
|
+
n || this.emit("close");
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}).catch(() => {}), this;
|
|
158
202
|
}
|
|
159
203
|
connect(...e) {
|
|
160
204
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
161
205
|
this._webVPNUdpSocketPromise.then(async (t) => {
|
|
162
206
|
if (!t) throw Error("Socket not bound");
|
|
163
|
-
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
|
|
164
|
-
await t.connect({
|
|
207
|
+
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({
|
|
165
208
|
remotePort: n,
|
|
166
209
|
remoteAddress: i
|
|
167
|
-
})
|
|
210
|
+
});
|
|
211
|
+
this._connectedLocally = o?.local === !0, this._remoteAddress = o?.address ? {
|
|
212
|
+
address: o.address,
|
|
213
|
+
family: o.family,
|
|
214
|
+
port: o.port
|
|
215
|
+
} : {
|
|
168
216
|
address: i,
|
|
169
217
|
family: this._type === "udp6" ? "IPv6" : "IPv4",
|
|
170
218
|
port: n
|
|
171
|
-
}, a && a();
|
|
219
|
+
}, this._connectGeneration += 1, a && a();
|
|
220
|
+
}).catch((e) => {
|
|
221
|
+
this.emit("error", e);
|
|
172
222
|
});
|
|
173
223
|
}
|
|
174
224
|
disconnect() {
|
|
175
225
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
176
226
|
if (!this._remoteAddress) throw Error("ERR_SOCKET_DGRAM_NOT_CONNECTED");
|
|
177
|
-
this._remoteAddress =
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
remotePort: 0,
|
|
181
|
-
remoteAddress: this._type === "udp4" ? "0.0.0.0" : "::"
|
|
182
|
-
});
|
|
227
|
+
let e = this._remoteAddress, t = this._connectedLocally, n = this._connectGeneration;
|
|
228
|
+
this._remoteAddress = void 0, this._connectedLocally = void 0, this._webVPNUdpSocketPromise.then((e) => e?.disconnect?.()).catch((r) => {
|
|
229
|
+
this._connectGeneration === n && (this._remoteAddress = e, this._connectedLocally = t), this.emit("error", r);
|
|
183
230
|
});
|
|
184
231
|
}
|
|
185
232
|
dropMembership(e, t) {
|
|
186
|
-
if (
|
|
187
|
-
let n =
|
|
233
|
+
if (c.isValid(e)) {
|
|
234
|
+
let n = m(e), r = t && c.isValid(t) ? m(t) : new Uint8Array([
|
|
188
235
|
0,
|
|
189
236
|
0,
|
|
190
237
|
0,
|
|
@@ -195,8 +242,8 @@ var l = /* @__PURE__ */ e({
|
|
|
195
242
|
group: n,
|
|
196
243
|
interface: r
|
|
197
244
|
});
|
|
198
|
-
} else if (
|
|
199
|
-
let t =
|
|
245
|
+
} else if (l.isValid(e)) {
|
|
246
|
+
let t = g(e);
|
|
200
247
|
this._setUdpOption({
|
|
201
248
|
type: 8,
|
|
202
249
|
group: t,
|
|
@@ -229,20 +276,27 @@ var l = /* @__PURE__ */ e({
|
|
|
229
276
|
}
|
|
230
277
|
send(...e) {
|
|
231
278
|
this._webVPNUdpSocketPromise || this.bind();
|
|
232
|
-
let t =
|
|
279
|
+
let t = a(...e), n = p(t.message), r = n;
|
|
280
|
+
if (t.hasRange) {
|
|
281
|
+
let { offset: e, length: i } = t;
|
|
282
|
+
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" });
|
|
283
|
+
if (!Number.isInteger(i) || i < 0 || i > n.byteLength - e) throw Object.assign(/* @__PURE__ */ RangeError("\"length\" is outside of buffer bounds"), { code: "ERR_BUFFER_OUT_OF_BOUNDS" });
|
|
284
|
+
r = n.subarray(e, e + i);
|
|
285
|
+
}
|
|
286
|
+
let i = this._type === "udp6" ? "::1" : "127.0.0.1";
|
|
233
287
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
234
288
|
this._webVPNUdpSocketPromise.then((e) => {
|
|
235
289
|
if (!e) throw Error("Socket not bound");
|
|
236
|
-
let n =
|
|
237
|
-
if (this._dataPort && (o ||
|
|
238
|
-
this._portSend(
|
|
290
|
+
let n = t.callback, a = t.address ?? i, o = this._remoteAddress !== void 0 && t.address === void 0;
|
|
291
|
+
if (this._dataPort && (o || c.isValid(a) || l.isValid(a))) {
|
|
292
|
+
this._portSend(r, o ? void 0 : a, o ? void 0 : t.port), n?.call(this, null, r.byteLength);
|
|
239
293
|
return;
|
|
240
294
|
}
|
|
241
295
|
e.send({
|
|
242
|
-
|
|
296
|
+
port: t.port,
|
|
243
297
|
address: a,
|
|
244
|
-
message:
|
|
245
|
-
}).then(() =>
|
|
298
|
+
message: r.byteOffset === 0 && r.byteLength === r.buffer.byteLength ? r.buffer : r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength)
|
|
299
|
+
}).then(() => n?.call(this, null, r.byteLength), (e) => n ? n.call(this, e, 0) : this.emit("error", e));
|
|
246
300
|
});
|
|
247
301
|
}
|
|
248
302
|
setBroadcast(e) {
|
|
@@ -295,21 +349,21 @@ var l = /* @__PURE__ */ e({
|
|
|
295
349
|
this.close(e);
|
|
296
350
|
});
|
|
297
351
|
}
|
|
298
|
-
},
|
|
299
|
-
if (typeof e == "string") return
|
|
352
|
+
}, f = new Uint8Array([2]), p = (e) => {
|
|
353
|
+
if (typeof e == "string") return n.encode(e);
|
|
300
354
|
if (e instanceof Uint8Array) return e;
|
|
301
355
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
302
356
|
if (Array.isArray(e)) {
|
|
303
|
-
let t = e.map(
|
|
357
|
+
let t = e.map(p), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
|
|
304
358
|
for (let e of t) n.set(e, r), r += e.byteLength;
|
|
305
359
|
return n;
|
|
306
360
|
}
|
|
307
361
|
return new Uint8Array(e);
|
|
308
|
-
},
|
|
362
|
+
}, m = (e) => {
|
|
309
363
|
let t = e.split(".").map((e) => parseInt(e, 10));
|
|
310
364
|
if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
|
|
311
365
|
return new Uint8Array(t);
|
|
312
|
-
},
|
|
366
|
+
}, h = (e) => {
|
|
313
367
|
let t = [];
|
|
314
368
|
for (let n = 0; n < 16; n += 2) t.push(e[n] << 8 | e[n + 1]);
|
|
315
369
|
let n = -1, r = 1;
|
|
@@ -323,16 +377,16 @@ var l = /* @__PURE__ */ e({
|
|
|
323
377
|
i - e > r && (n = e, r = i - e), e = i;
|
|
324
378
|
}
|
|
325
379
|
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(":")}`;
|
|
326
|
-
},
|
|
327
|
-
let t = new
|
|
380
|
+
}, g = (e) => {
|
|
381
|
+
let t = new l(e).getBitsBase16(0, 128).match(/.{2}/g);
|
|
328
382
|
if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
|
|
329
383
|
return new Uint8Array(t.map((e) => parseInt(e, 16)));
|
|
330
|
-
},
|
|
331
|
-
let n = new
|
|
384
|
+
}, _ = (e, t) => {
|
|
385
|
+
let n = new d(typeof e == "string" ? { type: e } : e);
|
|
332
386
|
return t && n.on("message", t), n;
|
|
333
|
-
},
|
|
334
|
-
Socket:
|
|
335
|
-
createSocket:
|
|
387
|
+
}, v = {
|
|
388
|
+
Socket: d,
|
|
389
|
+
createSocket: _
|
|
336
390
|
};
|
|
337
391
|
//#endregion
|
|
338
|
-
export {
|
|
392
|
+
export { u as i, _ as n, v as r, d as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./api-DD5v1qP9.cjs"),n=require("./utils-QfNXtEhb.cjs");let r=require("buffer"),i=require("events"),a=require("ip-address");var o=e.n({Socket:()=>s,createSocket:()=>p,default:()=>m}),s=class extends i.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_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}_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:n.n,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){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`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,i,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,f,p;if(l===2){if(!this._remoteAddress){a=s;continue}u=this._remoteAddress.address,f=this._remoteAddress.family,p=this._remoteAddress.port}else{let n=new Uint8Array(e,c,l===0?4:16);l===0?(f=`IPv4`,u=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(f=`IPv6`,u=d(n)),c+=n.byteLength,p=t.getUint16(c),c+=2}let m=t.getUint32(c);c+=4;try{this.emit(`message`,r.Buffer.from(e.slice(c,c+m)),{address:u,family:f,port:p,size:m})}catch(e){n||(n=!0,i=e)}a=s}if(n)throw i}_peerTail(e,t){if(e===void 0||t===void 0)return c;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=a.Address4.isValid(e)?u(e):f(e),o=new Uint8Array(1+i.byteLength+2);return o[0]=i.byteLength===4?0:1,o.set(i,1),new DataView(o.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,o),o}_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(a.Address4.isValid(e)){let n=u(e),r=t&&a.Address4.isValid(t)?u(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(a.Address6.isValid(e)){let t=f(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 i=n.o(...e),a=this._type===`udp6`?`::`:`0.0.0.0`;return this._webVPNUdpSocketPromise=t.t.then(e=>e.cloud.webvpn.udpSocket({type:this._type,address:i.address??a,port:i.port,dataPort:!0})).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`,r.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=>{e&&this.emit(`listening`)}),i.callback&&this._webVPNUdpSocketPromise.then(e=>{e&&i.callback.call(this)}),this}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._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(a.Address4.isValid(e)){let n=u(e),r=t&&a.Address4.isValid(t)?u(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(a.Address6.isValid(e)){let t=f(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=n.s(...e),r=l(t.message),i=r;if(t.hasRange){let{offset:e,length:n}=t;if(!Number.isInteger(e)||e<0||e>r.byteLength)throw Object.assign(RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(n)||n<0||n>r.byteLength-e)throw Object.assign(RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});i=r.subarray(e,e+n)}let o=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??o,s=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(s||a.Address4.isValid(r)||a.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)})}},c=new Uint8Array([2]),l=e=>{if(typeof e==`string`)return n.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(l),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)},u=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)},d=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(`:`)}`},f=e=>{let t=new a.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)))},p=(e,t)=>{let n=new s(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},m={Socket:s,createSocket:p};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
package/dgram.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-DcvdNkg6.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-
|
|
1
|
+
import { n as UdpSocketOption, t as Resolvers } from "./api-CI4d96Ty.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { AddressInfo } from "net";
|
|
4
4
|
import { EventEmitter } from "events";
|
|
@@ -27,6 +27,9 @@ declare class Socket extends EventEmitter implements Socket$2 {
|
|
|
27
27
|
family: string;
|
|
28
28
|
port: number;
|
|
29
29
|
};
|
|
30
|
+
_connectedLocally?: boolean;
|
|
31
|
+
_connectGeneration: number;
|
|
32
|
+
_destroyed: boolean;
|
|
30
33
|
_webVPNUdpSocketPromise?: Promise<Awaited<ReturnType<WebVpnUdpSocket>> | undefined>;
|
|
31
34
|
_dataPort?: MessagePort;
|
|
32
35
|
_socketId?: number;
|
|
@@ -43,6 +46,11 @@ declare class Socket extends EventEmitter implements Socket$2 {
|
|
|
43
46
|
_lastMulticastTtl: number;
|
|
44
47
|
_lastMulticastLoopback: boolean;
|
|
45
48
|
_setUdpOption(option: UdpSocketOption): void;
|
|
49
|
+
_dataPortAcks: boolean;
|
|
50
|
+
_dataPortConsumedBytes: number;
|
|
51
|
+
_dataPortAckedBytes: number;
|
|
52
|
+
_ackDataPortBatch(batchBytes: number): void;
|
|
53
|
+
_onTransportClosed(reason?: string): void;
|
|
46
54
|
_onDataPortBatch(buffer: ArrayBuffer): void;
|
|
47
55
|
_peerTail(address: string | undefined, port: number | undefined): Uint8Array;
|
|
48
56
|
_portSend(message: Uint8Array, address: string | undefined, port: number | undefined): void;
|
|
@@ -59,8 +67,11 @@ declare class Socket extends EventEmitter implements Socket$2 {
|
|
|
59
67
|
dropMembership(multicastAddress: string, multicastInterface?: string | undefined): void;
|
|
60
68
|
getRecvBufferSize(): number;
|
|
61
69
|
getSendBufferSize(): number;
|
|
70
|
+
/** Queue measurements are not exposed by the browser transport. Always returns 0. */
|
|
62
71
|
getSendQueueSize(): number;
|
|
72
|
+
/** Queue measurements are not exposed by the browser transport. Always returns 0. */
|
|
63
73
|
getSendQueueCount(): number;
|
|
74
|
+
/** No-op in a browser, which has no Node process-liveness handle. */
|
|
64
75
|
ref(): this;
|
|
65
76
|
remoteAddress(): AddressInfo;
|
|
66
77
|
send(msg: string | readonly any[] | Uint8Array, port?: number | undefined, address?: string | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
@@ -71,14 +82,18 @@ declare class Socket extends EventEmitter implements Socket$2 {
|
|
|
71
82
|
send(msg: string | Uint8Array, offset: number, length: number, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
72
83
|
send(msg: unknown, offset?: unknown, length?: unknown, port?: unknown, address?: unknown, callback?: unknown): void;
|
|
73
84
|
setBroadcast(flag: boolean): void;
|
|
85
|
+
/** No-op. The browser transport does not expose an interface index or address. */
|
|
74
86
|
setMulticastInterface(multicastInterface: string): void;
|
|
75
87
|
setMulticastLoopback(flag: boolean): boolean;
|
|
76
88
|
setMulticastTTL(ttl: number): number;
|
|
77
89
|
setRecvBufferSize(size: number): void;
|
|
78
90
|
setSendBufferSize(size: number): void;
|
|
79
91
|
setTTL(ttl: number): number;
|
|
92
|
+
/** No-op in a browser, which has no Node process-liveness handle. */
|
|
80
93
|
unref(): this;
|
|
94
|
+
/** Not implemented by the browser transport. This method currently does nothing. */
|
|
81
95
|
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string | undefined): void;
|
|
96
|
+
/** Not implemented by the browser transport. This method currently does nothing. */
|
|
82
97
|
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string | undefined): void;
|
|
83
98
|
[Symbol.asyncDispose](): Promise<void>;
|
|
84
99
|
}
|
package/dgram.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./dgram-
|
|
1
|
+
import { n as e, r as t, t as n } from "./dgram-CKRbKVzG.js";
|
|
2
2
|
export { n as Socket, e as createSocket, t as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-DF993M8W.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, V as _, a as v, c as y, d as b, i as x, j as S, k as C, l as w, n as T, o as E, r as D, s as O, t as k, u as A, w as j, x as M, z as N } from "./proxy-
|
|
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, V as _, a as v, c as y, d as b, i as x, j as S, k as C, l as w, n as T, o as E, r as D, s as O, t as k, u as A, w as j, x as M, z as N } from "./proxy-Cusnx9Ex.js";
|
|
3
3
|
import { t as P } from "./api--bnCFd4w.js";
|
|
4
4
|
import { available as F, fetch as I } from "./desktop.js";
|
|
5
5
|
//#region src/lib/extension-prompt.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./proxy-
|
|
1
|
+
const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./proxy-Du95zAKk.cjs"),n=require("./api-DD5v1qP9.cjs"),r=require("./desktop.cjs");var i=async e=>{if(typeof window>`u`)return!1;if(t.P())return!0;let r=await n.t,i=null,a=new Promise(e=>{i=()=>{t.P()&&e(!0)},t.N.addEventListener(`statuschange`,i)}),o=r.installPrompt.show(e).then(()=>!1),s=await Promise.race([a,o]);return i&&t.N.removeEventListener(`statuschange`,i),await r.installPrompt.hide().catch(()=>{}),s},a=null;t.F(()=>(a||=i().then(()=>void 0).finally(()=>{a=null}),a));var o=()=>typeof document<`u`&&t.P(),s=async(e,n)=>{if(t.n(e),n?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return t.D(e,n)}return o()?t.D(e,{...n,credentials:`omit`}):r.available()?r.fetch(e,n):t.t(e,n)},c=e.n({ATTACH_FRAME_EVENT_KEY:()=>t.i,assertAttachableFrameUrl:()=>t.l,assertFetchableUrl:()=>t.E,assertLockdownApplicable:()=>t.u,attachFrame:()=>t.a,attachFramePermission:()=>t.o,available:()=>o,box:()=>t.R,cookies:()=>t.w,createFrame:()=>t.s,createVideoElementHandle:()=>t.z,events:()=>t.N,extension:()=>t.N,fetch:()=>t.D,fetchCredentialedPermission:()=>t.O,fetchLocalPermission:()=>t.k,fetchPermission:()=>t.A,gotoPermission:()=>t.c,handleRevivableModules:()=>t.L,isBlockedFetchUrl:()=>t.j,isBlockedFrameUrl:()=>t.d,isExtensionExposed:()=>t.P,isLocalNetworkUrl:()=>t.M,isType:()=>t.B,modifyRequestHeadersPermission:()=>t.x,permissions:()=>t.r,promptInstall:()=>i,readCookiePermission:()=>t.T,removeRequestHeaderRule:()=>t.S,revive:()=>t.V,setMissingExtensionHandler:()=>t.F,setRequestHeaderRule:()=>t.C,type:()=>t.H,waitForExtensionExposure:()=>t.I});Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
package/extension.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-Du95zAKk.cjs"),t=require("./extension-DVHdBvOz.cjs");exports.ATTACH_FRAME_EVENT_KEY=e.i,exports.assertAttachableFrameUrl=e.l,exports.assertFetchableUrl=e.E,exports.assertLockdownApplicable=e.u,exports.attachFrame=e.a,exports.attachFramePermission=e.o,exports.available=t.r,exports.box=e.R,exports.cookies=e.w,exports.createFrame=e.s,exports.createVideoElementHandle=e.z,exports.events=e.N,exports.extension=e.N,exports.fetch=e.D,exports.fetchCredentialedPermission=e.O,exports.fetchLocalPermission=e.k,exports.fetchPermission=e.A,exports.gotoPermission=e.c,exports.handleRevivableModules=e.L,exports.isBlockedFetchUrl=e.j,exports.isBlockedFrameUrl=e.d,exports.isExtensionExposed=e.P,exports.isLocalNetworkUrl=e.M,exports.isType=e.B,exports.modifyRequestHeadersPermission=e.x,exports.permissions=e.r,exports.promptInstall=t.i,exports.readCookiePermission=e.T,exports.removeRequestHeaderRule=e.S,exports.revive=e.V,exports.setMissingExtensionHandler=e.F,exports.setRequestHeaderRule=e.C,exports.type=e.H,exports.waitForExtensionExposure=e.I;
|
package/extension.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, V as g, a as _, c as v, d as y, i as b, j as x, k as S, l as C, o as w, r as T, s as E, u as D, w as O, x as k, z as A } from "./proxy-
|
|
2
|
-
import { i as j, r as M } from "./extension-
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, V as g, a as _, c as v, d as y, i as b, j as x, k as S, l as C, o as w, r as T, s as E, u as D, w as O, x as k, z as A } from "./proxy-Cusnx9Ex.js";
|
|
2
|
+
import { i as j, r as M } from "./extension-4ib5y95s.js";
|
|
3
3
|
export { b as ATTACH_FRAME_EVENT_KEY, C as assertAttachableFrameUrl, i as assertFetchableUrl, D as assertLockdownApplicable, _ as attachFrame, w as attachFramePermission, M as available, p as box, O as cookies, E as createFrame, A as createVideoElementHandle, u as events, u as extension, r as fetch, d as fetchCredentialedPermission, S as fetchLocalPermission, e as fetchPermission, v as gotoPermission, c as handleRevivableModules, x as isBlockedFetchUrl, y as isBlockedFrameUrl, f as isExtensionExposed, l as isLocalNetworkUrl, t as isType, k as modifyRequestHeadersPermission, T as permissions, j as promptInstall, h as readCookiePermission, m as removeRequestHeaderRule, g as revive, a as setMissingExtensionHandler, n as setRequestHeaderRule, o as type, s as waitForExtensionExposure };
|
package/fs/promises.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../fs-BN4hkppN.cjs");var{readFile:t,writeFile:n,appendFile:r,unlink:i,rename:a,readdir:o,mkdir:s,rm:c,rmdir:l,stat:u,lstat:d,access:f}=e.p,p=e.p;exports.access=f,exports.appendFile=r,exports.default=p,exports.lstat=d,exports.mkdir=s,exports.readFile=t,exports.readdir=o,exports.rename=a,exports.rm=c,exports.rmdir=l,exports.stat=u,exports.unlink=i,exports.writeFile=n;
|
package/fs/promises.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as e } from "../fs-
|
|
1
|
+
import { p as e } from "../fs-7E0-tE2x.js";
|
|
2
2
|
//#region src/lib/fs/promises.ts
|
|
3
3
|
var { readFile: t, writeFile: n, appendFile: r, unlink: i, rename: a, readdir: o, mkdir: s, rm: c, rmdir: l, stat: u, lstat: d, access: f } = e, p = e;
|
|
4
4
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as e } from "./rolldown-runtime-DF993M8W.js";
|
|
2
2
|
import { t } from "./node-fs-Dbf93qP7.js";
|
|
3
|
-
import {
|
|
3
|
+
import { i as n, n as r, o as i, s as a, u as o } from "./storage-DMETg6sP.js";
|
|
4
4
|
import { a as s, i as c, n as l, o as u, t as d } from "./opfs-7_GmzQ93.js";
|
|
5
5
|
//#region src/lib/fs/hybrid.ts
|
|
6
6
|
var f = /* @__PURE__ */ e({
|
|
@@ -10,39 +10,39 @@ var f = /* @__PURE__ */ e({
|
|
|
10
10
|
readFile: () => v,
|
|
11
11
|
remove: () => b,
|
|
12
12
|
writeFile: () => y
|
|
13
|
-
}), p, m = async () => await (p ??= d().catch(() => !1)) ? !0 : (p = void 0, !1), h = () =>
|
|
14
|
-
let [e, t] = await Promise.all([m().then((e) => e ? l() : []).catch(() => []), h().then((e) => e ?
|
|
13
|
+
}), p, m = async () => await (p ??= d().catch(() => !1)) ? !0 : (p = void 0, !1), h = () => r().catch(() => !1), g = async () => await m() || await h(), _ = async () => {
|
|
14
|
+
let [e, t] = await Promise.all([m().then((e) => e ? l() : []).catch(() => []), h().then((e) => e ? n() : []).catch(() => [])]), r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
15
15
|
let t = Date.parse(e.updatedAt ?? "");
|
|
16
16
|
return Number.isFinite(t) ? t : 0;
|
|
17
17
|
}, a = (e) => {
|
|
18
|
-
let t =
|
|
19
|
-
(!t ||
|
|
18
|
+
let t = r.get(e.path);
|
|
19
|
+
(!t || i(e) >= i(t)) && r.set(e.path, e);
|
|
20
20
|
};
|
|
21
21
|
for (let t of e) a(t);
|
|
22
22
|
for (let e of t) a(e);
|
|
23
|
-
return [...
|
|
23
|
+
return [...r.values()];
|
|
24
24
|
}, v = async (e) => {
|
|
25
25
|
if (await m()) try {
|
|
26
26
|
return await c(e);
|
|
27
27
|
} catch (e) {
|
|
28
28
|
if (e?.name !== "NotFoundError") throw e;
|
|
29
29
|
}
|
|
30
|
-
let t = await
|
|
30
|
+
let t = await i(e);
|
|
31
31
|
return await m() && u(e, t).catch(() => {}), t;
|
|
32
32
|
}, y = async (e, t, n) => {
|
|
33
33
|
let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
34
34
|
if (await m()) {
|
|
35
|
-
await u(e, r, n), await h() &&
|
|
35
|
+
await u(e, r, n), await h() && o(e, r, n).catch((e) => console.warn("fs: cloud replicate failed", e));
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
if (await h()) return
|
|
38
|
+
if (await h()) return o(e, r, n);
|
|
39
39
|
throw Error("fs: no storage backend available");
|
|
40
40
|
}, b = async (e) => {
|
|
41
41
|
let t = [];
|
|
42
|
-
if (await m() && t.push(s(e).catch(() => {})), await h() && t.push(
|
|
42
|
+
if (await m() && t.push(s(e).catch(() => {})), await h() && t.push(a(e).catch(() => {})), !t.length) throw Error("fs: no storage backend available");
|
|
43
43
|
await Promise.all(t);
|
|
44
44
|
}, x = async (e) => {
|
|
45
|
-
let t = await
|
|
45
|
+
let t = await i(e);
|
|
46
46
|
return await m() && await u(e, t), t;
|
|
47
47
|
}, S = /* @__PURE__ */ e({
|
|
48
48
|
appendFile: () => z,
|