@wp-playground/storage 0.9.46 → 1.0.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/index.cjs +62 -1
- package/index.js +2813 -233
- package/package.json +7 -6
package/index.js
CHANGED
|
@@ -1,335 +1,2915 @@
|
|
|
1
|
-
import { Semaphore as
|
|
2
|
-
import { Octokit as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Semaphore as Lt, normalizePath as Mt, joinPaths as Ie } from "@php-wasm/util";
|
|
2
|
+
import { Octokit as _e } from "octokit";
|
|
3
|
+
import Ae from "crc-32";
|
|
4
|
+
import Gt from "pako";
|
|
5
|
+
function jr(n) {
|
|
6
|
+
return new _e({
|
|
7
|
+
auth: n
|
|
6
8
|
});
|
|
7
9
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
for (const
|
|
12
|
-
|
|
13
|
-
return
|
|
10
|
+
function Lr(n, r = "") {
|
|
11
|
+
r.length && !r.endsWith("/") && (r += "/");
|
|
12
|
+
const o = {};
|
|
13
|
+
for (const s of n)
|
|
14
|
+
s.path.startsWith(r) && (o[s.path.substring(r.length)] = s.content);
|
|
15
|
+
return o;
|
|
14
16
|
}
|
|
15
|
-
async function
|
|
16
|
-
|
|
17
|
+
async function Fe(n, r, o, s, f, u = {}) {
|
|
18
|
+
u.progress || (u.progress = {
|
|
17
19
|
foundFiles: 0,
|
|
18
20
|
downloadedFiles: 0
|
|
19
21
|
});
|
|
20
|
-
const { onProgress:
|
|
21
|
-
owner:
|
|
22
|
-
repo:
|
|
23
|
-
path:
|
|
24
|
-
ref:
|
|
22
|
+
const { onProgress: h } = u, c = [], w = [], { data: y } = await n.rest.repos.getContent({
|
|
23
|
+
owner: r,
|
|
24
|
+
repo: o,
|
|
25
|
+
path: f,
|
|
26
|
+
ref: s
|
|
25
27
|
});
|
|
26
|
-
if (!Array.isArray(
|
|
28
|
+
if (!Array.isArray(y))
|
|
27
29
|
throw new Error(
|
|
28
|
-
`Expected the list of files to be an array, but got ${typeof
|
|
30
|
+
`Expected the list of files to be an array, but got ${typeof y}`
|
|
29
31
|
);
|
|
30
|
-
for (const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)) :
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
e,
|
|
32
|
+
for (const b of y)
|
|
33
|
+
b.type === "file" ? (++u.progress.foundFiles, h == null || h(u.progress), c.push(
|
|
34
|
+
Se(n, r, o, s, b).then((B) => (++u.progress.downloadedFiles, h == null || h(u.progress), B))
|
|
35
|
+
)) : b.type === "dir" && w.push(
|
|
36
|
+
Fe(
|
|
37
|
+
n,
|
|
37
38
|
r,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
o,
|
|
40
|
+
s,
|
|
41
|
+
b.path,
|
|
42
|
+
u
|
|
41
43
|
)
|
|
42
44
|
);
|
|
43
|
-
const
|
|
44
|
-
(
|
|
45
|
+
const g = await Promise.all(c), m = (await Promise.all(w)).flatMap(
|
|
46
|
+
(b) => b
|
|
45
47
|
);
|
|
46
|
-
return [...
|
|
48
|
+
return [...g, ...m];
|
|
47
49
|
}
|
|
48
|
-
const
|
|
49
|
-
async function
|
|
50
|
-
const
|
|
50
|
+
const Ue = new Lt({ concurrency: 15 });
|
|
51
|
+
async function Se(n, r, o, s, f) {
|
|
52
|
+
const u = await Ue.acquire();
|
|
51
53
|
try {
|
|
52
|
-
const { data:
|
|
53
|
-
owner:
|
|
54
|
-
repo:
|
|
55
|
-
ref:
|
|
56
|
-
path:
|
|
54
|
+
const { data: h } = await n.rest.repos.getContent({
|
|
55
|
+
owner: r,
|
|
56
|
+
repo: o,
|
|
57
|
+
ref: s,
|
|
58
|
+
path: f.path
|
|
57
59
|
});
|
|
58
|
-
if (!("content" in
|
|
59
|
-
throw new Error(`No content found for ${
|
|
60
|
+
if (!("content" in h))
|
|
61
|
+
throw new Error(`No content found for ${f.path}`);
|
|
60
62
|
return {
|
|
61
|
-
name:
|
|
62
|
-
path:
|
|
63
|
-
content:
|
|
63
|
+
name: f.name,
|
|
64
|
+
path: f.path,
|
|
65
|
+
content: ke(h.content)
|
|
64
66
|
};
|
|
65
67
|
} finally {
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
71
|
-
for (let
|
|
72
|
-
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
async function
|
|
76
|
-
var
|
|
77
|
-
const { data:
|
|
78
|
-
owner:
|
|
79
|
-
repo:
|
|
80
|
-
pull_number:
|
|
81
|
-
}),
|
|
82
|
-
owner:
|
|
83
|
-
repo:
|
|
84
|
-
branch:
|
|
85
|
-
workflow_id:
|
|
86
|
-
})).data.workflow_runs[0]) == null ? void 0 :
|
|
87
|
-
owner:
|
|
88
|
-
repo:
|
|
89
|
-
run_id:
|
|
68
|
+
u();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function ke(n) {
|
|
72
|
+
const r = window.atob(n), o = r.length, s = new Uint8Array(o);
|
|
73
|
+
for (let f = 0; f < o; f++)
|
|
74
|
+
s[f] = r.charCodeAt(f);
|
|
75
|
+
return s;
|
|
76
|
+
}
|
|
77
|
+
async function Mr(n, r, o, s, f) {
|
|
78
|
+
var g;
|
|
79
|
+
const { data: u } = await n.rest.pulls.get({
|
|
80
|
+
owner: r,
|
|
81
|
+
repo: o,
|
|
82
|
+
pull_number: s
|
|
83
|
+
}), c = (g = (await n.rest.actions.listWorkflowRuns({
|
|
84
|
+
owner: r,
|
|
85
|
+
repo: o,
|
|
86
|
+
branch: u.head.ref,
|
|
87
|
+
workflow_id: f
|
|
88
|
+
})).data.workflow_runs[0]) == null ? void 0 : g.id, w = await n.rest.actions.listWorkflowRunArtifacts({
|
|
89
|
+
owner: r,
|
|
90
|
+
repo: o,
|
|
91
|
+
run_id: c
|
|
90
92
|
});
|
|
91
|
-
return (await
|
|
92
|
-
owner:
|
|
93
|
-
repo:
|
|
94
|
-
artifact_id:
|
|
93
|
+
return (await n.rest.actions.downloadArtifact({
|
|
94
|
+
owner: r,
|
|
95
|
+
repo: o,
|
|
96
|
+
artifact_id: w.data.artifacts[0].id,
|
|
95
97
|
archive_format: "zip"
|
|
96
98
|
})).data;
|
|
97
99
|
}
|
|
98
|
-
async function
|
|
99
|
-
var
|
|
100
|
-
const { data:
|
|
100
|
+
async function Gr(n, r, o) {
|
|
101
|
+
var u;
|
|
102
|
+
const { data: s, headers: f } = await n.request(
|
|
101
103
|
"GET /repos/{owner}/{repo}",
|
|
102
104
|
{
|
|
103
|
-
owner:
|
|
104
|
-
repo:
|
|
105
|
+
owner: r,
|
|
106
|
+
repo: o
|
|
105
107
|
}
|
|
106
108
|
);
|
|
107
|
-
return !(!
|
|
109
|
+
return !(!f["x-oauth-scopes"] || !((u = s.permissions) != null && u.push));
|
|
108
110
|
}
|
|
109
|
-
async function
|
|
110
|
-
await
|
|
111
|
-
owner:
|
|
112
|
-
repo:
|
|
113
|
-
branch:
|
|
111
|
+
async function Hr(n, r, o, s, f) {
|
|
112
|
+
await n.request("GET /repos/{owner}/{repo}/branches/{branch}", {
|
|
113
|
+
owner: r,
|
|
114
|
+
repo: o,
|
|
115
|
+
branch: s
|
|
114
116
|
}).then(
|
|
115
117
|
() => !0,
|
|
116
118
|
() => !1
|
|
117
|
-
) ? await
|
|
118
|
-
owner:
|
|
119
|
-
repo:
|
|
120
|
-
sha:
|
|
121
|
-
ref: `heads/${
|
|
122
|
-
}) : await
|
|
123
|
-
owner:
|
|
124
|
-
repo:
|
|
125
|
-
sha:
|
|
126
|
-
ref: `refs/heads/${
|
|
119
|
+
) ? await n.request("PATCH /repos/{owner}/{repo}/git/refs/{ref}", {
|
|
120
|
+
owner: r,
|
|
121
|
+
repo: o,
|
|
122
|
+
sha: f,
|
|
123
|
+
ref: `heads/${s}`
|
|
124
|
+
}) : await n.request("POST /repos/{owner}/{repo}/git/refs", {
|
|
125
|
+
owner: r,
|
|
126
|
+
repo: o,
|
|
127
|
+
sha: f,
|
|
128
|
+
ref: `refs/heads/${s}`
|
|
127
129
|
});
|
|
128
130
|
}
|
|
129
|
-
async function
|
|
130
|
-
const
|
|
131
|
-
return (await
|
|
132
|
-
owner:
|
|
133
|
-
repo:
|
|
131
|
+
async function qr(n, r, o) {
|
|
132
|
+
const s = await n.request("GET /user");
|
|
133
|
+
return (await n.request("GET /repos/{owner}/{repo}/forks", {
|
|
134
|
+
owner: r,
|
|
135
|
+
repo: o
|
|
134
136
|
})).data.find(
|
|
135
|
-
(
|
|
136
|
-
) || await
|
|
137
|
-
owner:
|
|
138
|
-
repo:
|
|
139
|
-
}),
|
|
137
|
+
(h) => h.owner && h.owner.login === s.data.login
|
|
138
|
+
) || await n.request("POST /repos/{owner}/{repo}/forks", {
|
|
139
|
+
owner: r,
|
|
140
|
+
repo: o
|
|
141
|
+
}), s.data.login;
|
|
140
142
|
}
|
|
141
|
-
async function
|
|
143
|
+
async function vr(n, r, o, s, f, u) {
|
|
142
144
|
const {
|
|
143
|
-
data: { sha:
|
|
144
|
-
} = await
|
|
145
|
-
owner:
|
|
146
|
-
repo:
|
|
147
|
-
message:
|
|
148
|
-
tree:
|
|
149
|
-
parents: [
|
|
145
|
+
data: { sha: h }
|
|
146
|
+
} = await n.request("POST /repos/{owner}/{repo}/git/commits", {
|
|
147
|
+
owner: r,
|
|
148
|
+
repo: o,
|
|
149
|
+
message: s,
|
|
150
|
+
tree: u,
|
|
151
|
+
parents: [f]
|
|
150
152
|
});
|
|
151
|
-
return
|
|
153
|
+
return h;
|
|
152
154
|
}
|
|
153
|
-
async function
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
e,
|
|
155
|
+
async function zr(n, r, o, s, f) {
|
|
156
|
+
const u = await Te(
|
|
157
|
+
n,
|
|
157
158
|
r,
|
|
158
|
-
|
|
159
|
-
|
|
159
|
+
o,
|
|
160
|
+
s,
|
|
161
|
+
f
|
|
160
162
|
);
|
|
161
|
-
if (
|
|
163
|
+
if (u.length === 0)
|
|
162
164
|
return null;
|
|
163
165
|
const {
|
|
164
|
-
data: { sha:
|
|
165
|
-
} = await
|
|
166
|
-
owner:
|
|
167
|
-
repo:
|
|
168
|
-
base_tree:
|
|
169
|
-
tree:
|
|
166
|
+
data: { sha: h }
|
|
167
|
+
} = await n.request("POST /repos/{owner}/{repo}/git/trees", {
|
|
168
|
+
owner: r,
|
|
169
|
+
repo: o,
|
|
170
|
+
base_tree: s,
|
|
171
|
+
tree: u
|
|
170
172
|
});
|
|
171
|
-
return
|
|
172
|
-
}
|
|
173
|
-
async function
|
|
174
|
-
const
|
|
175
|
-
for (const [
|
|
176
|
-
|
|
177
|
-
for (const [
|
|
178
|
-
|
|
179
|
-
for (const
|
|
180
|
-
|
|
181
|
-
return Promise.all(
|
|
182
|
-
(
|
|
173
|
+
return h;
|
|
174
|
+
}
|
|
175
|
+
async function Te(n, r, o, s, f) {
|
|
176
|
+
const u = [];
|
|
177
|
+
for (const [h, c] of f.create)
|
|
178
|
+
u.push(Ct(n, r, o, h, c));
|
|
179
|
+
for (const [h, c] of f.update)
|
|
180
|
+
u.push(Ct(n, r, o, h, c));
|
|
181
|
+
for (const h of f.delete)
|
|
182
|
+
u.push($e(n, r, o, s, h));
|
|
183
|
+
return Promise.all(u).then(
|
|
184
|
+
(h) => h.filter((c) => !!c)
|
|
183
185
|
);
|
|
184
186
|
}
|
|
185
|
-
const
|
|
186
|
-
async function
|
|
187
|
-
const
|
|
187
|
+
const Ht = new Lt({ concurrency: 10 });
|
|
188
|
+
async function Ct(n, r, o, s, f) {
|
|
189
|
+
const u = await Ht.acquire();
|
|
188
190
|
try {
|
|
189
|
-
if (ArrayBuffer.isView(
|
|
191
|
+
if (ArrayBuffer.isView(f))
|
|
190
192
|
try {
|
|
191
|
-
const
|
|
193
|
+
const h = new TextDecoder("utf-8", {
|
|
192
194
|
fatal: !0
|
|
193
|
-
}).decode(
|
|
195
|
+
}).decode(f);
|
|
194
196
|
return {
|
|
195
|
-
path:
|
|
196
|
-
content:
|
|
197
|
+
path: s,
|
|
198
|
+
content: h,
|
|
197
199
|
mode: "100644"
|
|
198
200
|
};
|
|
199
201
|
} catch {
|
|
200
202
|
const {
|
|
201
|
-
data: { sha:
|
|
202
|
-
} = await
|
|
203
|
-
owner:
|
|
204
|
-
repo:
|
|
203
|
+
data: { sha: c }
|
|
204
|
+
} = await n.rest.git.createBlob({
|
|
205
|
+
owner: r,
|
|
206
|
+
repo: o,
|
|
205
207
|
encoding: "base64",
|
|
206
|
-
content:
|
|
208
|
+
content: Re(f)
|
|
207
209
|
});
|
|
208
210
|
return {
|
|
209
|
-
path:
|
|
210
|
-
sha:
|
|
211
|
+
path: s,
|
|
212
|
+
sha: c,
|
|
211
213
|
mode: "100644"
|
|
212
214
|
};
|
|
213
215
|
}
|
|
214
216
|
else
|
|
215
217
|
return {
|
|
216
|
-
path:
|
|
217
|
-
content:
|
|
218
|
+
path: s,
|
|
219
|
+
content: f,
|
|
218
220
|
mode: "100644"
|
|
219
221
|
};
|
|
220
222
|
} finally {
|
|
221
|
-
|
|
223
|
+
u();
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
|
-
async function
|
|
225
|
-
const
|
|
226
|
+
async function $e(n, r, o, s, f) {
|
|
227
|
+
const u = await Ht.acquire();
|
|
226
228
|
try {
|
|
227
|
-
return await
|
|
228
|
-
owner:
|
|
229
|
-
repo:
|
|
230
|
-
ref:
|
|
231
|
-
path:
|
|
229
|
+
return await n.request("HEAD /repos/{owner}/{repo}/contents/:path", {
|
|
230
|
+
owner: r,
|
|
231
|
+
repo: o,
|
|
232
|
+
ref: s,
|
|
233
|
+
path: f
|
|
232
234
|
}), {
|
|
233
|
-
path:
|
|
235
|
+
path: f,
|
|
234
236
|
mode: "100644",
|
|
235
237
|
sha: null
|
|
236
238
|
};
|
|
237
239
|
} catch {
|
|
238
240
|
return;
|
|
239
241
|
} finally {
|
|
240
|
-
|
|
242
|
+
u();
|
|
241
243
|
}
|
|
242
244
|
}
|
|
243
|
-
function
|
|
244
|
-
const
|
|
245
|
-
for (let
|
|
246
|
-
|
|
247
|
-
return window.btoa(
|
|
245
|
+
function Re(n) {
|
|
246
|
+
const r = [], o = n.byteLength;
|
|
247
|
+
for (let s = 0; s < o; s++)
|
|
248
|
+
r.push(String.fromCharCode(n[s]));
|
|
249
|
+
return window.btoa(r.join(""));
|
|
248
250
|
}
|
|
249
|
-
async function*
|
|
250
|
-
if (
|
|
251
|
-
await
|
|
252
|
-
path:
|
|
253
|
-
read: async () => await
|
|
251
|
+
async function* Wr(n, r, { exceptPaths: o = [] } = {}) {
|
|
252
|
+
if (r = Mt(r), !await n.isDir(r)) {
|
|
253
|
+
await n.fileExists(r) && (yield {
|
|
254
|
+
path: r,
|
|
255
|
+
read: async () => await n.readFileAsBuffer(r)
|
|
254
256
|
});
|
|
255
257
|
return;
|
|
256
258
|
}
|
|
257
|
-
const
|
|
258
|
-
for (;
|
|
259
|
-
const
|
|
260
|
-
if (!
|
|
259
|
+
const s = [r];
|
|
260
|
+
for (; s.length; ) {
|
|
261
|
+
const f = s.pop();
|
|
262
|
+
if (!f)
|
|
261
263
|
return;
|
|
262
|
-
const
|
|
263
|
-
for (const
|
|
264
|
-
const
|
|
265
|
-
|
|
266
|
-
path:
|
|
267
|
-
read: async () => await
|
|
264
|
+
const u = await n.listFiles(f);
|
|
265
|
+
for (const h of u) {
|
|
266
|
+
const c = Ie(f, h);
|
|
267
|
+
o.includes(c.substring(r.length + 1)) || (await n.isDir(c) ? s.push(c) : yield {
|
|
268
|
+
path: c,
|
|
269
|
+
read: async () => await n.readFileAsBuffer(c)
|
|
268
270
|
});
|
|
269
271
|
}
|
|
270
272
|
}
|
|
271
273
|
}
|
|
272
|
-
async function
|
|
273
|
-
const
|
|
274
|
+
async function Yr(n, r) {
|
|
275
|
+
const o = {
|
|
274
276
|
create: /* @__PURE__ */ new Map(),
|
|
275
277
|
update: /* @__PURE__ */ new Map(),
|
|
276
278
|
delete: /* @__PURE__ */ new Set()
|
|
277
|
-
},
|
|
278
|
-
for await (const
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
for (const
|
|
284
|
-
|
|
285
|
-
return
|
|
279
|
+
}, s = /* @__PURE__ */ new Set();
|
|
280
|
+
for await (const f of r) {
|
|
281
|
+
s.add(f.path);
|
|
282
|
+
const u = n.get(f.path), h = await f.read();
|
|
283
|
+
u ? Ce(u, h) || o.update.set(f.path, h) : o.create.set(f.path, h);
|
|
284
|
+
}
|
|
285
|
+
for (const f of n.keys())
|
|
286
|
+
s.has(f) || o.delete.add(f);
|
|
287
|
+
return o;
|
|
286
288
|
}
|
|
287
|
-
function
|
|
288
|
-
return
|
|
289
|
+
function Ce(n, r) {
|
|
290
|
+
return n.length === r.length && n.every((o, s) => o === r[s]);
|
|
289
291
|
}
|
|
290
|
-
async function
|
|
291
|
-
return
|
|
292
|
+
async function Oe(n) {
|
|
293
|
+
return n.type === "local-fs" ? n.handle : Pe(n.path);
|
|
292
294
|
}
|
|
293
|
-
async function
|
|
294
|
-
const
|
|
295
|
-
let
|
|
296
|
-
for (const
|
|
297
|
-
|
|
298
|
-
return
|
|
295
|
+
async function Pe(n) {
|
|
296
|
+
const r = n.split("/").filter((s) => s.length > 0);
|
|
297
|
+
let o = await navigator.storage.getDirectory();
|
|
298
|
+
for (const s of r)
|
|
299
|
+
o = await o.getDirectoryHandle(s, { create: !0 });
|
|
300
|
+
return o;
|
|
299
301
|
}
|
|
300
|
-
async function
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
302
|
+
async function Vr(n) {
|
|
303
|
+
const o = await (await navigator.storage.getDirectory()).resolve(n);
|
|
304
|
+
if (o === null)
|
|
303
305
|
throw new DOMException(
|
|
304
306
|
"Unable to resolve path of OPFS directory handle.",
|
|
305
307
|
"NotFoundError"
|
|
306
308
|
);
|
|
307
|
-
return "/" +
|
|
309
|
+
return "/" + o.join("/");
|
|
308
310
|
}
|
|
309
|
-
async function
|
|
310
|
-
const
|
|
311
|
-
for await (const
|
|
312
|
-
await
|
|
311
|
+
async function Kr(n) {
|
|
312
|
+
const r = await Oe(n);
|
|
313
|
+
for await (const o of r.keys())
|
|
314
|
+
await r.removeEntry(o, {
|
|
313
315
|
recursive: !0
|
|
314
316
|
});
|
|
315
317
|
}
|
|
318
|
+
function De(n) {
|
|
319
|
+
let r = [n];
|
|
320
|
+
return {
|
|
321
|
+
next() {
|
|
322
|
+
return Promise.resolve({ done: r.length === 0, value: r.pop() });
|
|
323
|
+
},
|
|
324
|
+
return() {
|
|
325
|
+
return r = [], {};
|
|
326
|
+
},
|
|
327
|
+
[Symbol.asyncIterator]() {
|
|
328
|
+
return this;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function qt(n) {
|
|
333
|
+
return n[Symbol.asyncIterator] ? n[Symbol.asyncIterator]() : n[Symbol.iterator] ? n[Symbol.iterator]() : n.next ? n : De(n);
|
|
334
|
+
}
|
|
335
|
+
class vt {
|
|
336
|
+
constructor(r) {
|
|
337
|
+
if (typeof Buffer > "u")
|
|
338
|
+
throw new Error("Missing Buffer dependency");
|
|
339
|
+
this.stream = qt(r), this.buffer = null, this.cursor = 0, this.undoCursor = 0, this.started = !1, this._ended = !1, this._discardedBytes = 0;
|
|
340
|
+
}
|
|
341
|
+
eof() {
|
|
342
|
+
return this._ended && this.cursor === this.buffer.length;
|
|
343
|
+
}
|
|
344
|
+
tell() {
|
|
345
|
+
return this._discardedBytes + this.cursor;
|
|
346
|
+
}
|
|
347
|
+
async byte() {
|
|
348
|
+
if (!this.eof() && (this.started || await this._init(), !(this.cursor === this.buffer.length && (await this._loadnext(), this._ended))))
|
|
349
|
+
return this._moveCursor(1), this.buffer[this.undoCursor];
|
|
350
|
+
}
|
|
351
|
+
async chunk() {
|
|
352
|
+
if (!this.eof() && (this.started || await this._init(), !(this.cursor === this.buffer.length && (await this._loadnext(), this._ended))))
|
|
353
|
+
return this._moveCursor(this.buffer.length), this.buffer.slice(this.undoCursor, this.cursor);
|
|
354
|
+
}
|
|
355
|
+
async read(r) {
|
|
356
|
+
if (!this.eof())
|
|
357
|
+
return this.started || await this._init(), this.cursor + r > this.buffer.length && (this._trim(), await this._accumulate(r)), this._moveCursor(r), this.buffer.slice(this.undoCursor, this.cursor);
|
|
358
|
+
}
|
|
359
|
+
async skip(r) {
|
|
360
|
+
this.eof() || (this.started || await this._init(), this.cursor + r > this.buffer.length && (this._trim(), await this._accumulate(r)), this._moveCursor(r));
|
|
361
|
+
}
|
|
362
|
+
async undo() {
|
|
363
|
+
this.cursor = this.undoCursor;
|
|
364
|
+
}
|
|
365
|
+
async _next() {
|
|
366
|
+
this.started = !0;
|
|
367
|
+
let { done: r, value: o } = await this.stream.next();
|
|
368
|
+
return r && (this._ended = !0, !o) ? Buffer.alloc(0) : (o && (o = Buffer.from(o)), o);
|
|
369
|
+
}
|
|
370
|
+
_trim() {
|
|
371
|
+
this.buffer = this.buffer.slice(this.undoCursor), this.cursor -= this.undoCursor, this._discardedBytes += this.undoCursor, this.undoCursor = 0;
|
|
372
|
+
}
|
|
373
|
+
_moveCursor(r) {
|
|
374
|
+
this.undoCursor = this.cursor, this.cursor += r, this.cursor > this.buffer.length && (this.cursor = this.buffer.length);
|
|
375
|
+
}
|
|
376
|
+
async _accumulate(r) {
|
|
377
|
+
if (this._ended)
|
|
378
|
+
return;
|
|
379
|
+
const o = [this.buffer];
|
|
380
|
+
for (; this.cursor + r > Ne(o); ) {
|
|
381
|
+
const s = await this._next();
|
|
382
|
+
if (this._ended)
|
|
383
|
+
break;
|
|
384
|
+
o.push(s);
|
|
385
|
+
}
|
|
386
|
+
this.buffer = Buffer.concat(o);
|
|
387
|
+
}
|
|
388
|
+
async _loadnext() {
|
|
389
|
+
this._discardedBytes += this.buffer.length, this.undoCursor = 0, this.cursor = 0, this.buffer = await this._next();
|
|
390
|
+
}
|
|
391
|
+
async _init() {
|
|
392
|
+
this.buffer = await this._next();
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function Ne(n) {
|
|
396
|
+
return n.reduce((r, o) => r + o.length, 0);
|
|
397
|
+
}
|
|
398
|
+
function je(n, r) {
|
|
399
|
+
const o = r.toString(16);
|
|
400
|
+
return "0".repeat(n - o.length) + o;
|
|
401
|
+
}
|
|
402
|
+
class k {
|
|
403
|
+
static flush() {
|
|
404
|
+
return Buffer.from("0000", "utf8");
|
|
405
|
+
}
|
|
406
|
+
static delim() {
|
|
407
|
+
return Buffer.from("0001", "utf8");
|
|
408
|
+
}
|
|
409
|
+
static encode(r) {
|
|
410
|
+
typeof r == "string" && (r = Buffer.from(r));
|
|
411
|
+
const o = r.length + 4, s = je(4, o);
|
|
412
|
+
return Buffer.concat([Buffer.from(s, "utf8"), r]);
|
|
413
|
+
}
|
|
414
|
+
static streamReader(r) {
|
|
415
|
+
const o = new vt(r);
|
|
416
|
+
return async function() {
|
|
417
|
+
try {
|
|
418
|
+
let f = await o.read(4);
|
|
419
|
+
if (f == null)
|
|
420
|
+
return !0;
|
|
421
|
+
if (f = parseInt(f.toString("utf8"), 16), f === 0 || f === 1)
|
|
422
|
+
return null;
|
|
423
|
+
const u = await o.read(f - 4);
|
|
424
|
+
return u ?? !0;
|
|
425
|
+
} catch (f) {
|
|
426
|
+
return r.error = f, !0;
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
class J extends Error {
|
|
432
|
+
constructor(r) {
|
|
433
|
+
super(r), this.caller = "";
|
|
434
|
+
}
|
|
435
|
+
toJSON() {
|
|
436
|
+
return {
|
|
437
|
+
code: this.code,
|
|
438
|
+
data: this.data,
|
|
439
|
+
caller: this.caller,
|
|
440
|
+
message: this.message,
|
|
441
|
+
stack: this.stack
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
fromJSON(r) {
|
|
445
|
+
const o = new J(r.message);
|
|
446
|
+
return o.code = r.code, o.data = r.data, o.caller = r.caller, o.stack = r.stack, o;
|
|
447
|
+
}
|
|
448
|
+
get isIsomorphicGitError() {
|
|
449
|
+
return !0;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
class _ extends J {
|
|
453
|
+
/**
|
|
454
|
+
* @param {string} message
|
|
455
|
+
*/
|
|
456
|
+
constructor(r) {
|
|
457
|
+
super(
|
|
458
|
+
`An internal error caused this command to fail. Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/issues with this error message: ${r}`
|
|
459
|
+
), this.code = this.name = _.code, this.data = { message: r };
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
_.code = "InternalError";
|
|
463
|
+
class ot extends J {
|
|
464
|
+
/**
|
|
465
|
+
* @param {string} filepath
|
|
466
|
+
*/
|
|
467
|
+
constructor(r) {
|
|
468
|
+
super(`The filepath "${r}" contains unsafe character sequences`), this.code = this.name = ot.code, this.data = { filepath: r };
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
ot.code = "UnsafeFilepathError";
|
|
472
|
+
function zt(n, r) {
|
|
473
|
+
return -(n < r) || +(n > r);
|
|
474
|
+
}
|
|
475
|
+
function Le(n, r) {
|
|
476
|
+
return zt(n.path, r.path);
|
|
477
|
+
}
|
|
478
|
+
function Me(n, r) {
|
|
479
|
+
return zt(Ot(n), Ot(r));
|
|
480
|
+
}
|
|
481
|
+
function Ot(n) {
|
|
482
|
+
return n.mode === "040000" ? n.path + "/" : n.path;
|
|
483
|
+
}
|
|
484
|
+
function Wt(n) {
|
|
485
|
+
switch (n) {
|
|
486
|
+
case "040000":
|
|
487
|
+
return "tree";
|
|
488
|
+
case "100644":
|
|
489
|
+
return "blob";
|
|
490
|
+
case "100755":
|
|
491
|
+
return "blob";
|
|
492
|
+
case "120000":
|
|
493
|
+
return "blob";
|
|
494
|
+
case "160000":
|
|
495
|
+
return "commit";
|
|
496
|
+
}
|
|
497
|
+
throw new _(`Unexpected GitTree entry mode: ${n}`);
|
|
498
|
+
}
|
|
499
|
+
function Ge(n) {
|
|
500
|
+
const r = [];
|
|
501
|
+
let o = 0;
|
|
502
|
+
for (; o < n.length; ) {
|
|
503
|
+
const s = n.indexOf(32, o);
|
|
504
|
+
if (s === -1)
|
|
505
|
+
throw new _(
|
|
506
|
+
`GitTree: Error parsing buffer at byte location ${o}: Could not find the next space character.`
|
|
507
|
+
);
|
|
508
|
+
const f = n.indexOf(0, o);
|
|
509
|
+
if (f === -1)
|
|
510
|
+
throw new _(
|
|
511
|
+
`GitTree: Error parsing buffer at byte location ${o}: Could not find the next null character.`
|
|
512
|
+
);
|
|
513
|
+
let u = n.slice(o, s).toString("utf8");
|
|
514
|
+
u === "40000" && (u = "040000");
|
|
515
|
+
const h = Wt(u), c = n.slice(s + 1, f).toString("utf8");
|
|
516
|
+
if (c.includes("\\") || c.includes("/"))
|
|
517
|
+
throw new ot(c);
|
|
518
|
+
const w = n.slice(f + 1, f + 21).toString("hex");
|
|
519
|
+
o = f + 21, r.push({ mode: u, path: c, oid: w, type: h });
|
|
520
|
+
}
|
|
521
|
+
return r;
|
|
522
|
+
}
|
|
523
|
+
function He(n) {
|
|
524
|
+
if (typeof n == "number" && (n = n.toString(8)), n.match(/^0?4.*/))
|
|
525
|
+
return "040000";
|
|
526
|
+
if (n.match(/^1006.*/))
|
|
527
|
+
return "100644";
|
|
528
|
+
if (n.match(/^1007.*/))
|
|
529
|
+
return "100755";
|
|
530
|
+
if (n.match(/^120.*/))
|
|
531
|
+
return "120000";
|
|
532
|
+
if (n.match(/^160.*/))
|
|
533
|
+
return "160000";
|
|
534
|
+
throw new _(`Could not understand file mode: ${n}`);
|
|
535
|
+
}
|
|
536
|
+
function qe(n) {
|
|
537
|
+
return !n.oid && n.sha && (n.oid = n.sha), n.mode = He(n.mode), n.type || (n.type = Wt(n.mode)), n;
|
|
538
|
+
}
|
|
539
|
+
class bt {
|
|
540
|
+
constructor(r) {
|
|
541
|
+
if (Buffer.isBuffer(r))
|
|
542
|
+
this._entries = Ge(r);
|
|
543
|
+
else if (Array.isArray(r))
|
|
544
|
+
this._entries = r.map(qe);
|
|
545
|
+
else
|
|
546
|
+
throw new _("invalid type passed to GitTree constructor");
|
|
547
|
+
this._entries.sort(Le);
|
|
548
|
+
}
|
|
549
|
+
static from(r) {
|
|
550
|
+
return new bt(r);
|
|
551
|
+
}
|
|
552
|
+
render() {
|
|
553
|
+
return this._entries.map((r) => `${r.mode} ${r.type} ${r.oid} ${r.path}`).join(`
|
|
554
|
+
`);
|
|
555
|
+
}
|
|
556
|
+
toObject() {
|
|
557
|
+
const r = [...this._entries];
|
|
558
|
+
return r.sort(Me), Buffer.concat(
|
|
559
|
+
r.map((o) => {
|
|
560
|
+
const s = Buffer.from(o.mode.replace(/^0/, "")), f = Buffer.from(" "), u = Buffer.from(o.path, "utf8"), h = Buffer.from([0]), c = Buffer.from(o.oid, "hex");
|
|
561
|
+
return Buffer.concat([s, f, u, h, c]);
|
|
562
|
+
})
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* @returns {TreeEntry[]}
|
|
567
|
+
*/
|
|
568
|
+
entries() {
|
|
569
|
+
return this._entries;
|
|
570
|
+
}
|
|
571
|
+
*[Symbol.iterator]() {
|
|
572
|
+
for (const r of this._entries)
|
|
573
|
+
yield r;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function yt({ name: n, email: r, timestamp: o, timezoneOffset: s }) {
|
|
577
|
+
return s = ve(s), `${n} <${r}> ${o} ${s}`;
|
|
578
|
+
}
|
|
579
|
+
function ve(n) {
|
|
580
|
+
const r = ze(We(n));
|
|
581
|
+
n = Math.abs(n);
|
|
582
|
+
const o = Math.floor(n / 60);
|
|
583
|
+
n -= o * 60;
|
|
584
|
+
let s = String(o), f = String(n);
|
|
585
|
+
return s.length < 2 && (s = "0" + s), f.length < 2 && (f = "0" + f), (r === -1 ? "-" : "+") + s + f;
|
|
586
|
+
}
|
|
587
|
+
function ze(n) {
|
|
588
|
+
return Math.sign(n) || (Object.is(n, -0) ? -1 : 1);
|
|
589
|
+
}
|
|
590
|
+
function We(n) {
|
|
591
|
+
return n === 0 ? n : -n;
|
|
592
|
+
}
|
|
593
|
+
function H(n) {
|
|
594
|
+
return n = n.replace(/\r/g, ""), n = n.replace(/^\n+/, ""), n = n.replace(/\n+$/, "") + `
|
|
595
|
+
`, n;
|
|
596
|
+
}
|
|
597
|
+
function it(n) {
|
|
598
|
+
const [, r, o, s, f] = n.match(
|
|
599
|
+
/^(.*) <(.*)> (.*) (.*)$/
|
|
600
|
+
);
|
|
601
|
+
return {
|
|
602
|
+
name: r,
|
|
603
|
+
email: o,
|
|
604
|
+
timestamp: Number(s),
|
|
605
|
+
timezoneOffset: Ye(f)
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
function Ye(n) {
|
|
609
|
+
let [, r, o, s] = n.match(/(\+|-)(\d\d)(\d\d)/);
|
|
610
|
+
return s = (r === "+" ? 1 : -1) * (Number(o) * 60 + Number(s)), Ve(s);
|
|
611
|
+
}
|
|
612
|
+
function Ve(n) {
|
|
613
|
+
return n === 0 ? n : -n;
|
|
614
|
+
}
|
|
615
|
+
class Z {
|
|
616
|
+
constructor(r) {
|
|
617
|
+
if (typeof r == "string")
|
|
618
|
+
this._tag = r;
|
|
619
|
+
else if (Buffer.isBuffer(r))
|
|
620
|
+
this._tag = r.toString("utf8");
|
|
621
|
+
else if (typeof r == "object")
|
|
622
|
+
this._tag = Z.render(r);
|
|
623
|
+
else
|
|
624
|
+
throw new _(
|
|
625
|
+
"invalid type passed to GitAnnotatedTag constructor"
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
static from(r) {
|
|
629
|
+
return new Z(r);
|
|
630
|
+
}
|
|
631
|
+
static render(r) {
|
|
632
|
+
return `object ${r.object}
|
|
633
|
+
type ${r.type}
|
|
634
|
+
tag ${r.tag}
|
|
635
|
+
tagger ${yt(r.tagger)}
|
|
636
|
+
|
|
637
|
+
${r.message}
|
|
638
|
+
${r.gpgsig ? r.gpgsig : ""}`;
|
|
639
|
+
}
|
|
640
|
+
justHeaders() {
|
|
641
|
+
return this._tag.slice(0, this._tag.indexOf(`
|
|
642
|
+
|
|
643
|
+
`));
|
|
644
|
+
}
|
|
645
|
+
message() {
|
|
646
|
+
const r = this.withoutSignature();
|
|
647
|
+
return r.slice(r.indexOf(`
|
|
648
|
+
|
|
649
|
+
`) + 2);
|
|
650
|
+
}
|
|
651
|
+
parse() {
|
|
652
|
+
return Object.assign(this.headers(), {
|
|
653
|
+
message: this.message(),
|
|
654
|
+
gpgsig: this.gpgsig()
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
render() {
|
|
658
|
+
return this._tag;
|
|
659
|
+
}
|
|
660
|
+
headers() {
|
|
661
|
+
const r = this.justHeaders().split(`
|
|
662
|
+
`), o = [];
|
|
663
|
+
for (const f of r)
|
|
664
|
+
f[0] === " " ? o[o.length - 1] += `
|
|
665
|
+
` + f.slice(1) : o.push(f);
|
|
666
|
+
const s = {};
|
|
667
|
+
for (const f of o) {
|
|
668
|
+
const u = f.slice(0, f.indexOf(" ")), h = f.slice(f.indexOf(" ") + 1);
|
|
669
|
+
Array.isArray(s[u]) ? s[u].push(h) : s[u] = h;
|
|
670
|
+
}
|
|
671
|
+
return s.tagger && (s.tagger = it(s.tagger)), s.committer && (s.committer = it(s.committer)), s;
|
|
672
|
+
}
|
|
673
|
+
withoutSignature() {
|
|
674
|
+
const r = H(this._tag);
|
|
675
|
+
return r.indexOf(`
|
|
676
|
+
-----BEGIN PGP SIGNATURE-----`) === -1 ? r : r.slice(0, r.lastIndexOf(`
|
|
677
|
+
-----BEGIN PGP SIGNATURE-----`));
|
|
678
|
+
}
|
|
679
|
+
gpgsig() {
|
|
680
|
+
if (this._tag.indexOf(`
|
|
681
|
+
-----BEGIN PGP SIGNATURE-----`) === -1)
|
|
682
|
+
return;
|
|
683
|
+
const r = this._tag.slice(
|
|
684
|
+
this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),
|
|
685
|
+
this._tag.indexOf("-----END PGP SIGNATURE-----") + 27
|
|
686
|
+
);
|
|
687
|
+
return H(r);
|
|
688
|
+
}
|
|
689
|
+
payload() {
|
|
690
|
+
return this.withoutSignature() + `
|
|
691
|
+
`;
|
|
692
|
+
}
|
|
693
|
+
toObject() {
|
|
694
|
+
return Buffer.from(this._tag, "utf8");
|
|
695
|
+
}
|
|
696
|
+
static async sign(r, o, s) {
|
|
697
|
+
const f = r.payload();
|
|
698
|
+
let { signature: u } = await o({ payload: f, secretKey: s });
|
|
699
|
+
u = H(u);
|
|
700
|
+
const h = f + u;
|
|
701
|
+
return Z.from(h);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
function lt(n) {
|
|
705
|
+
return n.trim().split(`
|
|
706
|
+
`).map((r) => " " + r).join(`
|
|
707
|
+
`) + `
|
|
708
|
+
`;
|
|
709
|
+
}
|
|
710
|
+
function Ke(n) {
|
|
711
|
+
return n.split(`
|
|
712
|
+
`).map((r) => r.replace(/^ /, "")).join(`
|
|
713
|
+
`);
|
|
714
|
+
}
|
|
715
|
+
class O {
|
|
716
|
+
constructor(r) {
|
|
717
|
+
if (typeof r == "string")
|
|
718
|
+
this._commit = r;
|
|
719
|
+
else if (Buffer.isBuffer(r))
|
|
720
|
+
this._commit = r.toString("utf8");
|
|
721
|
+
else if (typeof r == "object")
|
|
722
|
+
this._commit = O.render(r);
|
|
723
|
+
else
|
|
724
|
+
throw new _("invalid type passed to GitCommit constructor");
|
|
725
|
+
}
|
|
726
|
+
static fromPayloadSignature({ payload: r, signature: o }) {
|
|
727
|
+
const s = O.justHeaders(r), f = O.justMessage(r), u = H(
|
|
728
|
+
s + `
|
|
729
|
+
gpgsig` + lt(o) + `
|
|
730
|
+
` + f
|
|
731
|
+
);
|
|
732
|
+
return new O(u);
|
|
733
|
+
}
|
|
734
|
+
static from(r) {
|
|
735
|
+
return new O(r);
|
|
736
|
+
}
|
|
737
|
+
toObject() {
|
|
738
|
+
return Buffer.from(this._commit, "utf8");
|
|
739
|
+
}
|
|
740
|
+
// Todo: allow setting the headers and message
|
|
741
|
+
headers() {
|
|
742
|
+
return this.parseHeaders();
|
|
743
|
+
}
|
|
744
|
+
// Todo: allow setting the headers and message
|
|
745
|
+
message() {
|
|
746
|
+
return O.justMessage(this._commit);
|
|
747
|
+
}
|
|
748
|
+
parse() {
|
|
749
|
+
return Object.assign({ message: this.message() }, this.headers());
|
|
750
|
+
}
|
|
751
|
+
static justMessage(r) {
|
|
752
|
+
return H(r.slice(r.indexOf(`
|
|
753
|
+
|
|
754
|
+
`) + 2));
|
|
755
|
+
}
|
|
756
|
+
static justHeaders(r) {
|
|
757
|
+
return r.slice(0, r.indexOf(`
|
|
758
|
+
|
|
759
|
+
`));
|
|
760
|
+
}
|
|
761
|
+
parseHeaders() {
|
|
762
|
+
const r = O.justHeaders(this._commit).split(`
|
|
763
|
+
`), o = [];
|
|
764
|
+
for (const f of r)
|
|
765
|
+
f[0] === " " ? o[o.length - 1] += `
|
|
766
|
+
` + f.slice(1) : o.push(f);
|
|
767
|
+
const s = {
|
|
768
|
+
parent: []
|
|
769
|
+
};
|
|
770
|
+
for (const f of o) {
|
|
771
|
+
const u = f.slice(0, f.indexOf(" ")), h = f.slice(f.indexOf(" ") + 1);
|
|
772
|
+
Array.isArray(s[u]) ? s[u].push(h) : s[u] = h;
|
|
773
|
+
}
|
|
774
|
+
return s.author && (s.author = it(s.author)), s.committer && (s.committer = it(s.committer)), s;
|
|
775
|
+
}
|
|
776
|
+
static renderHeaders(r) {
|
|
777
|
+
let o = "";
|
|
778
|
+
if (r.tree ? o += `tree ${r.tree}
|
|
779
|
+
` : o += `tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
|
780
|
+
`, r.parent) {
|
|
781
|
+
if (r.parent.length === void 0)
|
|
782
|
+
throw new _("commit 'parent' property should be an array");
|
|
783
|
+
for (const u of r.parent)
|
|
784
|
+
o += `parent ${u}
|
|
785
|
+
`;
|
|
786
|
+
}
|
|
787
|
+
const s = r.author;
|
|
788
|
+
o += `author ${yt(s)}
|
|
789
|
+
`;
|
|
790
|
+
const f = r.committer || r.author;
|
|
791
|
+
return o += `committer ${yt(f)}
|
|
792
|
+
`, r.gpgsig && (o += "gpgsig" + lt(r.gpgsig)), o;
|
|
793
|
+
}
|
|
794
|
+
static render(r) {
|
|
795
|
+
return O.renderHeaders(r) + `
|
|
796
|
+
` + H(r.message);
|
|
797
|
+
}
|
|
798
|
+
render() {
|
|
799
|
+
return this._commit;
|
|
800
|
+
}
|
|
801
|
+
withoutSignature() {
|
|
802
|
+
const r = H(this._commit);
|
|
803
|
+
if (r.indexOf(`
|
|
804
|
+
gpgsig`) === -1)
|
|
805
|
+
return r;
|
|
806
|
+
const o = r.slice(0, r.indexOf(`
|
|
807
|
+
gpgsig`)), s = r.slice(
|
|
808
|
+
r.indexOf(`-----END PGP SIGNATURE-----
|
|
809
|
+
`) + 28
|
|
810
|
+
);
|
|
811
|
+
return H(o + `
|
|
812
|
+
` + s);
|
|
813
|
+
}
|
|
814
|
+
isolateSignature() {
|
|
815
|
+
const r = this._commit.slice(
|
|
816
|
+
this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),
|
|
817
|
+
this._commit.indexOf("-----END PGP SIGNATURE-----") + 27
|
|
818
|
+
);
|
|
819
|
+
return Ke(r);
|
|
820
|
+
}
|
|
821
|
+
static async sign(r, o, s) {
|
|
822
|
+
const f = r.withoutSignature(), u = O.justMessage(r._commit);
|
|
823
|
+
let { signature: h } = await o({ payload: f, secretKey: s });
|
|
824
|
+
h = H(h);
|
|
825
|
+
const w = O.justHeaders(r._commit) + `
|
|
826
|
+
gpgsig` + lt(h) + `
|
|
827
|
+
` + u;
|
|
828
|
+
return O.from(w);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
class Je {
|
|
832
|
+
static wrap({ type: r, object: o }) {
|
|
833
|
+
return Buffer.concat([
|
|
834
|
+
Buffer.from(`${r} ${o.byteLength.toString()}\0`),
|
|
835
|
+
Buffer.from(o)
|
|
836
|
+
]);
|
|
837
|
+
}
|
|
838
|
+
static unwrap(r) {
|
|
839
|
+
const o = r.indexOf(32), s = r.indexOf(0), f = r.slice(0, o).toString("utf8"), u = r.slice(o + 1, s).toString("utf8"), h = r.length - (s + 1);
|
|
840
|
+
if (parseInt(u) !== h)
|
|
841
|
+
throw new _(
|
|
842
|
+
`Length mismatch: expected ${u} bytes but got ${h} instead.`
|
|
843
|
+
);
|
|
844
|
+
return {
|
|
845
|
+
type: f,
|
|
846
|
+
object: Buffer.from(r.slice(s + 1))
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
class z {
|
|
851
|
+
constructor(r) {
|
|
852
|
+
this.buffer = r, this._start = 0;
|
|
853
|
+
}
|
|
854
|
+
eof() {
|
|
855
|
+
return this._start >= this.buffer.length;
|
|
856
|
+
}
|
|
857
|
+
tell() {
|
|
858
|
+
return this._start;
|
|
859
|
+
}
|
|
860
|
+
seek(r) {
|
|
861
|
+
this._start = r;
|
|
862
|
+
}
|
|
863
|
+
slice(r) {
|
|
864
|
+
const o = this.buffer.slice(this._start, this._start + r);
|
|
865
|
+
return this._start += r, o;
|
|
866
|
+
}
|
|
867
|
+
toString(r, o) {
|
|
868
|
+
const s = this.buffer.toString(r, this._start, this._start + o);
|
|
869
|
+
return this._start += o, s;
|
|
870
|
+
}
|
|
871
|
+
write(r, o, s) {
|
|
872
|
+
const f = this.buffer.write(r, this._start, o, s);
|
|
873
|
+
return this._start += o, f;
|
|
874
|
+
}
|
|
875
|
+
copy(r, o, s) {
|
|
876
|
+
const f = r.copy(this.buffer, this._start, o, s);
|
|
877
|
+
return this._start += f, f;
|
|
878
|
+
}
|
|
879
|
+
readUInt8() {
|
|
880
|
+
const r = this.buffer.readUInt8(this._start);
|
|
881
|
+
return this._start += 1, r;
|
|
882
|
+
}
|
|
883
|
+
writeUInt8(r) {
|
|
884
|
+
const o = this.buffer.writeUInt8(r, this._start);
|
|
885
|
+
return this._start += 1, o;
|
|
886
|
+
}
|
|
887
|
+
readUInt16BE() {
|
|
888
|
+
const r = this.buffer.readUInt16BE(this._start);
|
|
889
|
+
return this._start += 2, r;
|
|
890
|
+
}
|
|
891
|
+
writeUInt16BE(r) {
|
|
892
|
+
const o = this.buffer.writeUInt16BE(r, this._start);
|
|
893
|
+
return this._start += 2, o;
|
|
894
|
+
}
|
|
895
|
+
readUInt32BE() {
|
|
896
|
+
const r = this.buffer.readUInt32BE(this._start);
|
|
897
|
+
return this._start += 4, r;
|
|
898
|
+
}
|
|
899
|
+
writeUInt32BE(r) {
|
|
900
|
+
const o = this.buffer.writeUInt32BE(r, this._start);
|
|
901
|
+
return this._start += 4, o;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
function Xe(n, r) {
|
|
905
|
+
const o = new z(n), s = Pt(o);
|
|
906
|
+
if (s !== r.byteLength)
|
|
907
|
+
throw new _(
|
|
908
|
+
`applyDelta expected source buffer to be ${s} bytes but the provided buffer was ${r.length} bytes`
|
|
909
|
+
);
|
|
910
|
+
const f = Pt(o);
|
|
911
|
+
let u;
|
|
912
|
+
const h = Nt(o, r);
|
|
913
|
+
if (h.byteLength === f)
|
|
914
|
+
u = h;
|
|
915
|
+
else {
|
|
916
|
+
u = Buffer.alloc(f);
|
|
917
|
+
const c = new z(u);
|
|
918
|
+
for (c.copy(h); !o.eof(); )
|
|
919
|
+
c.copy(Nt(o, r));
|
|
920
|
+
const w = c.tell();
|
|
921
|
+
if (f !== w)
|
|
922
|
+
throw new _(
|
|
923
|
+
`applyDelta expected target buffer to be ${f} bytes but the resulting buffer was ${w} bytes`
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
return u;
|
|
927
|
+
}
|
|
928
|
+
function Pt(n) {
|
|
929
|
+
let r = 0, o = 0, s = null;
|
|
930
|
+
do
|
|
931
|
+
s = n.readUInt8(), r |= (s & 127) << o, o += 7;
|
|
932
|
+
while (s & 128);
|
|
933
|
+
return r;
|
|
934
|
+
}
|
|
935
|
+
function Dt(n, r, o) {
|
|
936
|
+
let s = 0, f = 0;
|
|
937
|
+
for (; o--; )
|
|
938
|
+
r & 1 && (s |= n.readUInt8() << f), r >>= 1, f += 8;
|
|
939
|
+
return s;
|
|
940
|
+
}
|
|
941
|
+
function Nt(n, r) {
|
|
942
|
+
const o = n.readUInt8(), s = 128, f = 15, u = 112;
|
|
943
|
+
if (o & s) {
|
|
944
|
+
const h = Dt(n, o & f, 4);
|
|
945
|
+
let c = Dt(n, (o & u) >> 4, 3);
|
|
946
|
+
return c === 0 && (c = 65536), r.slice(h, h + c);
|
|
947
|
+
} else
|
|
948
|
+
return n.slice(o);
|
|
949
|
+
}
|
|
950
|
+
async function Ze(n, r) {
|
|
951
|
+
const o = new vt(n);
|
|
952
|
+
let s = await o.read(4);
|
|
953
|
+
if (s = s.toString("utf8"), s !== "PACK")
|
|
954
|
+
throw new _(`Invalid PACK header '${s}'`);
|
|
955
|
+
let f = await o.read(4);
|
|
956
|
+
if (f = f.readUInt32BE(0), f !== 2)
|
|
957
|
+
throw new _(`Invalid packfile version: ${f}`);
|
|
958
|
+
let u = await o.read(4);
|
|
959
|
+
if (u = u.readUInt32BE(0), !(u < 1))
|
|
960
|
+
for (; !o.eof() && u--; ) {
|
|
961
|
+
const h = o.tell(), { type: c, length: w, ofs: y, reference: g } = await Qe(o), m = new Gt.Inflate();
|
|
962
|
+
for (; !m.result; ) {
|
|
963
|
+
const b = await o.chunk();
|
|
964
|
+
if (!b)
|
|
965
|
+
break;
|
|
966
|
+
if (m.push(b, !1), m.err)
|
|
967
|
+
throw new _(`Pako error: ${m.msg}`);
|
|
968
|
+
if (m.result) {
|
|
969
|
+
if (m.result.length !== w)
|
|
970
|
+
throw new _(
|
|
971
|
+
"Inflated object size is different from that stated in packfile."
|
|
972
|
+
);
|
|
973
|
+
await o.undo(), await o.read(b.length - m.strm.avail_in);
|
|
974
|
+
const B = o.tell();
|
|
975
|
+
await r({
|
|
976
|
+
data: m.result,
|
|
977
|
+
type: c,
|
|
978
|
+
num: u,
|
|
979
|
+
offset: h,
|
|
980
|
+
end: B,
|
|
981
|
+
reference: g,
|
|
982
|
+
ofs: y
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
async function Qe(n) {
|
|
989
|
+
let r = await n.byte();
|
|
990
|
+
const o = r >> 4 & 7;
|
|
991
|
+
let s = r & 15;
|
|
992
|
+
if (r & 128) {
|
|
993
|
+
let h = 4;
|
|
994
|
+
do
|
|
995
|
+
r = await n.byte(), s |= (r & 127) << h, h += 7;
|
|
996
|
+
while (r & 128);
|
|
997
|
+
}
|
|
998
|
+
let f, u;
|
|
999
|
+
if (o === 6) {
|
|
1000
|
+
let h = 0;
|
|
1001
|
+
f = 0;
|
|
1002
|
+
const c = [];
|
|
1003
|
+
do
|
|
1004
|
+
r = await n.byte(), f |= (r & 127) << h, h += 7, c.push(r);
|
|
1005
|
+
while (r & 128);
|
|
1006
|
+
u = Buffer.from(c);
|
|
1007
|
+
}
|
|
1008
|
+
return o === 7 && (u = await n.read(20)), { type: o, length: s, ofs: f, reference: u };
|
|
1009
|
+
}
|
|
1010
|
+
let tr = !1;
|
|
1011
|
+
async function er(n) {
|
|
1012
|
+
return tr ? rr(n) : Gt.inflate(n);
|
|
1013
|
+
}
|
|
1014
|
+
async function rr(n) {
|
|
1015
|
+
const r = new DecompressionStream("deflate"), o = new Blob([n]).stream().pipeThrough(r);
|
|
1016
|
+
return new Uint8Array(await new Response(o).arrayBuffer());
|
|
1017
|
+
}
|
|
1018
|
+
function nr(n) {
|
|
1019
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
1020
|
+
}
|
|
1021
|
+
var gt = { exports: {} };
|
|
1022
|
+
typeof Object.create == "function" ? gt.exports = function(r, o) {
|
|
1023
|
+
o && (r.super_ = o, r.prototype = Object.create(o.prototype, {
|
|
1024
|
+
constructor: {
|
|
1025
|
+
value: r,
|
|
1026
|
+
enumerable: !1,
|
|
1027
|
+
writable: !0,
|
|
1028
|
+
configurable: !0
|
|
1029
|
+
}
|
|
1030
|
+
}));
|
|
1031
|
+
} : gt.exports = function(r, o) {
|
|
1032
|
+
if (o) {
|
|
1033
|
+
r.super_ = o;
|
|
1034
|
+
var s = function() {
|
|
1035
|
+
};
|
|
1036
|
+
s.prototype = o.prototype, r.prototype = new s(), r.prototype.constructor = r;
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
var ir = gt.exports, mt = { exports: {} }, q = {}, st = {};
|
|
1040
|
+
st.byteLength = ar;
|
|
1041
|
+
st.toByteArray = fr;
|
|
1042
|
+
st.fromByteArray = lr;
|
|
1043
|
+
var j = [], P = [], or = typeof Uint8Array < "u" ? Uint8Array : Array, pt = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
1044
|
+
for (var K = 0, sr = pt.length; K < sr; ++K)
|
|
1045
|
+
j[K] = pt[K], P[pt.charCodeAt(K)] = K;
|
|
1046
|
+
P["-".charCodeAt(0)] = 62;
|
|
1047
|
+
P["_".charCodeAt(0)] = 63;
|
|
1048
|
+
function Yt(n) {
|
|
1049
|
+
var r = n.length;
|
|
1050
|
+
if (r % 4 > 0)
|
|
1051
|
+
throw new Error("Invalid string. Length must be a multiple of 4");
|
|
1052
|
+
var o = n.indexOf("=");
|
|
1053
|
+
o === -1 && (o = r);
|
|
1054
|
+
var s = o === r ? 0 : 4 - o % 4;
|
|
1055
|
+
return [o, s];
|
|
1056
|
+
}
|
|
1057
|
+
function ar(n) {
|
|
1058
|
+
var r = Yt(n), o = r[0], s = r[1];
|
|
1059
|
+
return (o + s) * 3 / 4 - s;
|
|
1060
|
+
}
|
|
1061
|
+
function cr(n, r, o) {
|
|
1062
|
+
return (r + o) * 3 / 4 - o;
|
|
1063
|
+
}
|
|
1064
|
+
function fr(n) {
|
|
1065
|
+
var r, o = Yt(n), s = o[0], f = o[1], u = new or(cr(n, s, f)), h = 0, c = f > 0 ? s - 4 : s, w;
|
|
1066
|
+
for (w = 0; w < c; w += 4)
|
|
1067
|
+
r = P[n.charCodeAt(w)] << 18 | P[n.charCodeAt(w + 1)] << 12 | P[n.charCodeAt(w + 2)] << 6 | P[n.charCodeAt(w + 3)], u[h++] = r >> 16 & 255, u[h++] = r >> 8 & 255, u[h++] = r & 255;
|
|
1068
|
+
return f === 2 && (r = P[n.charCodeAt(w)] << 2 | P[n.charCodeAt(w + 1)] >> 4, u[h++] = r & 255), f === 1 && (r = P[n.charCodeAt(w)] << 10 | P[n.charCodeAt(w + 1)] << 4 | P[n.charCodeAt(w + 2)] >> 2, u[h++] = r >> 8 & 255, u[h++] = r & 255), u;
|
|
1069
|
+
}
|
|
1070
|
+
function ur(n) {
|
|
1071
|
+
return j[n >> 18 & 63] + j[n >> 12 & 63] + j[n >> 6 & 63] + j[n & 63];
|
|
1072
|
+
}
|
|
1073
|
+
function hr(n, r, o) {
|
|
1074
|
+
for (var s, f = [], u = r; u < o; u += 3)
|
|
1075
|
+
s = (n[u] << 16 & 16711680) + (n[u + 1] << 8 & 65280) + (n[u + 2] & 255), f.push(ur(s));
|
|
1076
|
+
return f.join("");
|
|
1077
|
+
}
|
|
1078
|
+
function lr(n) {
|
|
1079
|
+
for (var r, o = n.length, s = o % 3, f = [], u = 16383, h = 0, c = o - s; h < c; h += u)
|
|
1080
|
+
f.push(hr(n, h, h + u > c ? c : h + u));
|
|
1081
|
+
return s === 1 ? (r = n[o - 1], f.push(
|
|
1082
|
+
j[r >> 2] + j[r << 4 & 63] + "=="
|
|
1083
|
+
)) : s === 2 && (r = (n[o - 2] << 8) + n[o - 1], f.push(
|
|
1084
|
+
j[r >> 10] + j[r >> 4 & 63] + j[r << 2 & 63] + "="
|
|
1085
|
+
)), f.join("");
|
|
1086
|
+
}
|
|
1087
|
+
var xt = {};
|
|
1088
|
+
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
1089
|
+
xt.read = function(n, r, o, s, f) {
|
|
1090
|
+
var u, h, c = f * 8 - s - 1, w = (1 << c) - 1, y = w >> 1, g = -7, m = o ? f - 1 : 0, b = o ? -1 : 1, B = n[r + m];
|
|
1091
|
+
for (m += b, u = B & (1 << -g) - 1, B >>= -g, g += c; g > 0; u = u * 256 + n[r + m], m += b, g -= 8)
|
|
1092
|
+
;
|
|
1093
|
+
for (h = u & (1 << -g) - 1, u >>= -g, g += s; g > 0; h = h * 256 + n[r + m], m += b, g -= 8)
|
|
1094
|
+
;
|
|
1095
|
+
if (u === 0)
|
|
1096
|
+
u = 1 - y;
|
|
1097
|
+
else {
|
|
1098
|
+
if (u === w)
|
|
1099
|
+
return h ? NaN : (B ? -1 : 1) * (1 / 0);
|
|
1100
|
+
h = h + Math.pow(2, s), u = u - y;
|
|
1101
|
+
}
|
|
1102
|
+
return (B ? -1 : 1) * h * Math.pow(2, u - s);
|
|
1103
|
+
};
|
|
1104
|
+
xt.write = function(n, r, o, s, f, u) {
|
|
1105
|
+
var h, c, w, y = u * 8 - f - 1, g = (1 << y) - 1, m = g >> 1, b = f === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, B = s ? 0 : u - 1, T = s ? 1 : -1, L = r < 0 || r === 0 && 1 / r < 0 ? 1 : 0;
|
|
1106
|
+
for (r = Math.abs(r), isNaN(r) || r === 1 / 0 ? (c = isNaN(r) ? 1 : 0, h = g) : (h = Math.floor(Math.log(r) / Math.LN2), r * (w = Math.pow(2, -h)) < 1 && (h--, w *= 2), h + m >= 1 ? r += b / w : r += b * Math.pow(2, 1 - m), r * w >= 2 && (h++, w /= 2), h + m >= g ? (c = 0, h = g) : h + m >= 1 ? (c = (r * w - 1) * Math.pow(2, f), h = h + m) : (c = r * Math.pow(2, m - 1) * Math.pow(2, f), h = 0)); f >= 8; n[o + B] = c & 255, B += T, c /= 256, f -= 8)
|
|
1107
|
+
;
|
|
1108
|
+
for (h = h << f | c, y += f; y > 0; n[o + B] = h & 255, B += T, h /= 256, y -= 8)
|
|
1109
|
+
;
|
|
1110
|
+
n[o + B - T] |= L * 128;
|
|
1111
|
+
};
|
|
1112
|
+
/*!
|
|
1113
|
+
* The buffer module from node.js, for the browser.
|
|
1114
|
+
*
|
|
1115
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
1116
|
+
* @license MIT
|
|
1117
|
+
*/
|
|
1118
|
+
(function(n) {
|
|
1119
|
+
const r = st, o = xt, s = typeof Symbol == "function" && typeof Symbol.for == "function" ? Symbol.for("nodejs.util.inspect.custom") : null;
|
|
1120
|
+
n.Buffer = c, n.SlowBuffer = M, n.INSPECT_MAX_BYTES = 50;
|
|
1121
|
+
const f = 2147483647;
|
|
1122
|
+
n.kMaxLength = f, c.TYPED_ARRAY_SUPPORT = u(), !c.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
|
|
1123
|
+
"This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
|
|
1124
|
+
);
|
|
1125
|
+
function u() {
|
|
1126
|
+
try {
|
|
1127
|
+
const i = new Uint8Array(1), t = { foo: function() {
|
|
1128
|
+
return 42;
|
|
1129
|
+
} };
|
|
1130
|
+
return Object.setPrototypeOf(t, Uint8Array.prototype), Object.setPrototypeOf(i, t), i.foo() === 42;
|
|
1131
|
+
} catch {
|
|
1132
|
+
return !1;
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
Object.defineProperty(c.prototype, "parent", {
|
|
1136
|
+
enumerable: !0,
|
|
1137
|
+
get: function() {
|
|
1138
|
+
if (c.isBuffer(this))
|
|
1139
|
+
return this.buffer;
|
|
1140
|
+
}
|
|
1141
|
+
}), Object.defineProperty(c.prototype, "offset", {
|
|
1142
|
+
enumerable: !0,
|
|
1143
|
+
get: function() {
|
|
1144
|
+
if (c.isBuffer(this))
|
|
1145
|
+
return this.byteOffset;
|
|
1146
|
+
}
|
|
1147
|
+
});
|
|
1148
|
+
function h(i) {
|
|
1149
|
+
if (i > f)
|
|
1150
|
+
throw new RangeError('The value "' + i + '" is invalid for option "size"');
|
|
1151
|
+
const t = new Uint8Array(i);
|
|
1152
|
+
return Object.setPrototypeOf(t, c.prototype), t;
|
|
1153
|
+
}
|
|
1154
|
+
function c(i, t, e) {
|
|
1155
|
+
if (typeof i == "number") {
|
|
1156
|
+
if (typeof t == "string")
|
|
1157
|
+
throw new TypeError(
|
|
1158
|
+
'The "string" argument must be of type string. Received type number'
|
|
1159
|
+
);
|
|
1160
|
+
return m(i);
|
|
1161
|
+
}
|
|
1162
|
+
return w(i, t, e);
|
|
1163
|
+
}
|
|
1164
|
+
c.poolSize = 8192;
|
|
1165
|
+
function w(i, t, e) {
|
|
1166
|
+
if (typeof i == "string")
|
|
1167
|
+
return b(i, t);
|
|
1168
|
+
if (ArrayBuffer.isView(i))
|
|
1169
|
+
return T(i);
|
|
1170
|
+
if (i == null)
|
|
1171
|
+
throw new TypeError(
|
|
1172
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof i
|
|
1173
|
+
);
|
|
1174
|
+
if (N(i, ArrayBuffer) || i && N(i.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (N(i, SharedArrayBuffer) || i && N(i.buffer, SharedArrayBuffer)))
|
|
1175
|
+
return L(i, t, e);
|
|
1176
|
+
if (typeof i == "number")
|
|
1177
|
+
throw new TypeError(
|
|
1178
|
+
'The "value" argument must not be of type number. Received type number'
|
|
1179
|
+
);
|
|
1180
|
+
const a = i.valueOf && i.valueOf();
|
|
1181
|
+
if (a != null && a !== i)
|
|
1182
|
+
return c.from(a, t, e);
|
|
1183
|
+
const l = D(i);
|
|
1184
|
+
if (l)
|
|
1185
|
+
return l;
|
|
1186
|
+
if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof i[Symbol.toPrimitive] == "function")
|
|
1187
|
+
return c.from(i[Symbol.toPrimitive]("string"), t, e);
|
|
1188
|
+
throw new TypeError(
|
|
1189
|
+
"The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof i
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1192
|
+
c.from = function(i, t, e) {
|
|
1193
|
+
return w(i, t, e);
|
|
1194
|
+
}, Object.setPrototypeOf(c.prototype, Uint8Array.prototype), Object.setPrototypeOf(c, Uint8Array);
|
|
1195
|
+
function y(i) {
|
|
1196
|
+
if (typeof i != "number")
|
|
1197
|
+
throw new TypeError('"size" argument must be of type number');
|
|
1198
|
+
if (i < 0)
|
|
1199
|
+
throw new RangeError('The value "' + i + '" is invalid for option "size"');
|
|
1200
|
+
}
|
|
1201
|
+
function g(i, t, e) {
|
|
1202
|
+
return y(i), i <= 0 ? h(i) : t !== void 0 ? typeof e == "string" ? h(i).fill(t, e) : h(i).fill(t) : h(i);
|
|
1203
|
+
}
|
|
1204
|
+
c.alloc = function(i, t, e) {
|
|
1205
|
+
return g(i, t, e);
|
|
1206
|
+
};
|
|
1207
|
+
function m(i) {
|
|
1208
|
+
return y(i), h(i < 0 ? 0 : U(i) | 0);
|
|
1209
|
+
}
|
|
1210
|
+
c.allocUnsafe = function(i) {
|
|
1211
|
+
return m(i);
|
|
1212
|
+
}, c.allocUnsafeSlow = function(i) {
|
|
1213
|
+
return m(i);
|
|
1214
|
+
};
|
|
1215
|
+
function b(i, t) {
|
|
1216
|
+
if ((typeof t != "string" || t === "") && (t = "utf8"), !c.isEncoding(t))
|
|
1217
|
+
throw new TypeError("Unknown encoding: " + t);
|
|
1218
|
+
const e = $(i, t) | 0;
|
|
1219
|
+
let a = h(e);
|
|
1220
|
+
const l = a.write(i, t);
|
|
1221
|
+
return l !== e && (a = a.slice(0, l)), a;
|
|
1222
|
+
}
|
|
1223
|
+
function B(i) {
|
|
1224
|
+
const t = i.length < 0 ? 0 : U(i.length) | 0, e = h(t);
|
|
1225
|
+
for (let a = 0; a < t; a += 1)
|
|
1226
|
+
e[a] = i[a] & 255;
|
|
1227
|
+
return e;
|
|
1228
|
+
}
|
|
1229
|
+
function T(i) {
|
|
1230
|
+
if (N(i, Uint8Array)) {
|
|
1231
|
+
const t = new Uint8Array(i);
|
|
1232
|
+
return L(t.buffer, t.byteOffset, t.byteLength);
|
|
1233
|
+
}
|
|
1234
|
+
return B(i);
|
|
1235
|
+
}
|
|
1236
|
+
function L(i, t, e) {
|
|
1237
|
+
if (t < 0 || i.byteLength < t)
|
|
1238
|
+
throw new RangeError('"offset" is outside of buffer bounds');
|
|
1239
|
+
if (i.byteLength < t + (e || 0))
|
|
1240
|
+
throw new RangeError('"length" is outside of buffer bounds');
|
|
1241
|
+
let a;
|
|
1242
|
+
return t === void 0 && e === void 0 ? a = new Uint8Array(i) : e === void 0 ? a = new Uint8Array(i, t) : a = new Uint8Array(i, t, e), Object.setPrototypeOf(a, c.prototype), a;
|
|
1243
|
+
}
|
|
1244
|
+
function D(i) {
|
|
1245
|
+
if (c.isBuffer(i)) {
|
|
1246
|
+
const t = U(i.length) | 0, e = h(t);
|
|
1247
|
+
return e.length === 0 || i.copy(e, 0, 0, t), e;
|
|
1248
|
+
}
|
|
1249
|
+
if (i.length !== void 0)
|
|
1250
|
+
return typeof i.length != "number" || ht(i.length) ? h(0) : B(i);
|
|
1251
|
+
if (i.type === "Buffer" && Array.isArray(i.data))
|
|
1252
|
+
return B(i.data);
|
|
1253
|
+
}
|
|
1254
|
+
function U(i) {
|
|
1255
|
+
if (i >= f)
|
|
1256
|
+
throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + f.toString(16) + " bytes");
|
|
1257
|
+
return i | 0;
|
|
1258
|
+
}
|
|
1259
|
+
function M(i) {
|
|
1260
|
+
return +i != i && (i = 0), c.alloc(+i);
|
|
1261
|
+
}
|
|
1262
|
+
c.isBuffer = function(t) {
|
|
1263
|
+
return t != null && t._isBuffer === !0 && t !== c.prototype;
|
|
1264
|
+
}, c.compare = function(t, e) {
|
|
1265
|
+
if (N(t, Uint8Array) && (t = c.from(t, t.offset, t.byteLength)), N(e, Uint8Array) && (e = c.from(e, e.offset, e.byteLength)), !c.isBuffer(t) || !c.isBuffer(e))
|
|
1266
|
+
throw new TypeError(
|
|
1267
|
+
'The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array'
|
|
1268
|
+
);
|
|
1269
|
+
if (t === e)
|
|
1270
|
+
return 0;
|
|
1271
|
+
let a = t.length, l = e.length;
|
|
1272
|
+
for (let p = 0, d = Math.min(a, l); p < d; ++p)
|
|
1273
|
+
if (t[p] !== e[p]) {
|
|
1274
|
+
a = t[p], l = e[p];
|
|
1275
|
+
break;
|
|
1276
|
+
}
|
|
1277
|
+
return a < l ? -1 : l < a ? 1 : 0;
|
|
1278
|
+
}, c.isEncoding = function(t) {
|
|
1279
|
+
switch (String(t).toLowerCase()) {
|
|
1280
|
+
case "hex":
|
|
1281
|
+
case "utf8":
|
|
1282
|
+
case "utf-8":
|
|
1283
|
+
case "ascii":
|
|
1284
|
+
case "latin1":
|
|
1285
|
+
case "binary":
|
|
1286
|
+
case "base64":
|
|
1287
|
+
case "ucs2":
|
|
1288
|
+
case "ucs-2":
|
|
1289
|
+
case "utf16le":
|
|
1290
|
+
case "utf-16le":
|
|
1291
|
+
return !0;
|
|
1292
|
+
default:
|
|
1293
|
+
return !1;
|
|
1294
|
+
}
|
|
1295
|
+
}, c.concat = function(t, e) {
|
|
1296
|
+
if (!Array.isArray(t))
|
|
1297
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
1298
|
+
if (t.length === 0)
|
|
1299
|
+
return c.alloc(0);
|
|
1300
|
+
let a;
|
|
1301
|
+
if (e === void 0)
|
|
1302
|
+
for (e = 0, a = 0; a < t.length; ++a)
|
|
1303
|
+
e += t[a].length;
|
|
1304
|
+
const l = c.allocUnsafe(e);
|
|
1305
|
+
let p = 0;
|
|
1306
|
+
for (a = 0; a < t.length; ++a) {
|
|
1307
|
+
let d = t[a];
|
|
1308
|
+
if (N(d, Uint8Array))
|
|
1309
|
+
p + d.length > l.length ? (c.isBuffer(d) || (d = c.from(d)), d.copy(l, p)) : Uint8Array.prototype.set.call(
|
|
1310
|
+
l,
|
|
1311
|
+
d,
|
|
1312
|
+
p
|
|
1313
|
+
);
|
|
1314
|
+
else if (c.isBuffer(d))
|
|
1315
|
+
d.copy(l, p);
|
|
1316
|
+
else
|
|
1317
|
+
throw new TypeError('"list" argument must be an Array of Buffers');
|
|
1318
|
+
p += d.length;
|
|
1319
|
+
}
|
|
1320
|
+
return l;
|
|
1321
|
+
};
|
|
1322
|
+
function $(i, t) {
|
|
1323
|
+
if (c.isBuffer(i))
|
|
1324
|
+
return i.length;
|
|
1325
|
+
if (ArrayBuffer.isView(i) || N(i, ArrayBuffer))
|
|
1326
|
+
return i.byteLength;
|
|
1327
|
+
if (typeof i != "string")
|
|
1328
|
+
throw new TypeError(
|
|
1329
|
+
'The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type ' + typeof i
|
|
1330
|
+
);
|
|
1331
|
+
const e = i.length, a = arguments.length > 2 && arguments[2] === !0;
|
|
1332
|
+
if (!a && e === 0)
|
|
1333
|
+
return 0;
|
|
1334
|
+
let l = !1;
|
|
1335
|
+
for (; ; )
|
|
1336
|
+
switch (t) {
|
|
1337
|
+
case "ascii":
|
|
1338
|
+
case "latin1":
|
|
1339
|
+
case "binary":
|
|
1340
|
+
return e;
|
|
1341
|
+
case "utf8":
|
|
1342
|
+
case "utf-8":
|
|
1343
|
+
return ut(i).length;
|
|
1344
|
+
case "ucs2":
|
|
1345
|
+
case "ucs-2":
|
|
1346
|
+
case "utf16le":
|
|
1347
|
+
case "utf-16le":
|
|
1348
|
+
return e * 2;
|
|
1349
|
+
case "hex":
|
|
1350
|
+
return e >>> 1;
|
|
1351
|
+
case "base64":
|
|
1352
|
+
return Rt(i).length;
|
|
1353
|
+
default:
|
|
1354
|
+
if (l)
|
|
1355
|
+
return a ? -1 : ut(i).length;
|
|
1356
|
+
t = ("" + t).toLowerCase(), l = !0;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
c.byteLength = $;
|
|
1360
|
+
function G(i, t, e) {
|
|
1361
|
+
let a = !1;
|
|
1362
|
+
if ((t === void 0 || t < 0) && (t = 0), t > this.length || ((e === void 0 || e > this.length) && (e = this.length), e <= 0) || (e >>>= 0, t >>>= 0, e <= t))
|
|
1363
|
+
return "";
|
|
1364
|
+
for (i || (i = "utf8"); ; )
|
|
1365
|
+
switch (i) {
|
|
1366
|
+
case "hex":
|
|
1367
|
+
return de(this, t, e);
|
|
1368
|
+
case "utf8":
|
|
1369
|
+
case "utf-8":
|
|
1370
|
+
return It(this, t, e);
|
|
1371
|
+
case "ascii":
|
|
1372
|
+
return le(this, t, e);
|
|
1373
|
+
case "latin1":
|
|
1374
|
+
case "binary":
|
|
1375
|
+
return pe(this, t, e);
|
|
1376
|
+
case "base64":
|
|
1377
|
+
return ue(this, t, e);
|
|
1378
|
+
case "ucs2":
|
|
1379
|
+
case "ucs-2":
|
|
1380
|
+
case "utf16le":
|
|
1381
|
+
case "utf-16le":
|
|
1382
|
+
return we(this, t, e);
|
|
1383
|
+
default:
|
|
1384
|
+
if (a)
|
|
1385
|
+
throw new TypeError("Unknown encoding: " + i);
|
|
1386
|
+
i = (i + "").toLowerCase(), a = !0;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
c.prototype._isBuffer = !0;
|
|
1390
|
+
function R(i, t, e) {
|
|
1391
|
+
const a = i[t];
|
|
1392
|
+
i[t] = i[e], i[e] = a;
|
|
1393
|
+
}
|
|
1394
|
+
c.prototype.swap16 = function() {
|
|
1395
|
+
const t = this.length;
|
|
1396
|
+
if (t % 2 !== 0)
|
|
1397
|
+
throw new RangeError("Buffer size must be a multiple of 16-bits");
|
|
1398
|
+
for (let e = 0; e < t; e += 2)
|
|
1399
|
+
R(this, e, e + 1);
|
|
1400
|
+
return this;
|
|
1401
|
+
}, c.prototype.swap32 = function() {
|
|
1402
|
+
const t = this.length;
|
|
1403
|
+
if (t % 4 !== 0)
|
|
1404
|
+
throw new RangeError("Buffer size must be a multiple of 32-bits");
|
|
1405
|
+
for (let e = 0; e < t; e += 4)
|
|
1406
|
+
R(this, e, e + 3), R(this, e + 1, e + 2);
|
|
1407
|
+
return this;
|
|
1408
|
+
}, c.prototype.swap64 = function() {
|
|
1409
|
+
const t = this.length;
|
|
1410
|
+
if (t % 8 !== 0)
|
|
1411
|
+
throw new RangeError("Buffer size must be a multiple of 64-bits");
|
|
1412
|
+
for (let e = 0; e < t; e += 8)
|
|
1413
|
+
R(this, e, e + 7), R(this, e + 1, e + 6), R(this, e + 2, e + 5), R(this, e + 3, e + 4);
|
|
1414
|
+
return this;
|
|
1415
|
+
}, c.prototype.toString = function() {
|
|
1416
|
+
const t = this.length;
|
|
1417
|
+
return t === 0 ? "" : arguments.length === 0 ? It(this, 0, t) : G.apply(this, arguments);
|
|
1418
|
+
}, c.prototype.toLocaleString = c.prototype.toString, c.prototype.equals = function(t) {
|
|
1419
|
+
if (!c.isBuffer(t))
|
|
1420
|
+
throw new TypeError("Argument must be a Buffer");
|
|
1421
|
+
return this === t ? !0 : c.compare(this, t) === 0;
|
|
1422
|
+
}, c.prototype.inspect = function() {
|
|
1423
|
+
let t = "";
|
|
1424
|
+
const e = n.INSPECT_MAX_BYTES;
|
|
1425
|
+
return t = this.toString("hex", 0, e).replace(/(.{2})/g, "$1 ").trim(), this.length > e && (t += " ... "), "<Buffer " + t + ">";
|
|
1426
|
+
}, s && (c.prototype[s] = c.prototype.inspect), c.prototype.compare = function(t, e, a, l, p) {
|
|
1427
|
+
if (N(t, Uint8Array) && (t = c.from(t, t.offset, t.byteLength)), !c.isBuffer(t))
|
|
1428
|
+
throw new TypeError(
|
|
1429
|
+
'The "target" argument must be one of type Buffer or Uint8Array. Received type ' + typeof t
|
|
1430
|
+
);
|
|
1431
|
+
if (e === void 0 && (e = 0), a === void 0 && (a = t ? t.length : 0), l === void 0 && (l = 0), p === void 0 && (p = this.length), e < 0 || a > t.length || l < 0 || p > this.length)
|
|
1432
|
+
throw new RangeError("out of range index");
|
|
1433
|
+
if (l >= p && e >= a)
|
|
1434
|
+
return 0;
|
|
1435
|
+
if (l >= p)
|
|
1436
|
+
return -1;
|
|
1437
|
+
if (e >= a)
|
|
1438
|
+
return 1;
|
|
1439
|
+
if (e >>>= 0, a >>>= 0, l >>>= 0, p >>>= 0, this === t)
|
|
1440
|
+
return 0;
|
|
1441
|
+
let d = p - l, x = a - e;
|
|
1442
|
+
const A = Math.min(d, x), I = this.slice(l, p), F = t.slice(e, a);
|
|
1443
|
+
for (let E = 0; E < A; ++E)
|
|
1444
|
+
if (I[E] !== F[E]) {
|
|
1445
|
+
d = I[E], x = F[E];
|
|
1446
|
+
break;
|
|
1447
|
+
}
|
|
1448
|
+
return d < x ? -1 : x < d ? 1 : 0;
|
|
1449
|
+
};
|
|
1450
|
+
function Bt(i, t, e, a, l) {
|
|
1451
|
+
if (i.length === 0)
|
|
1452
|
+
return -1;
|
|
1453
|
+
if (typeof e == "string" ? (a = e, e = 0) : e > 2147483647 ? e = 2147483647 : e < -2147483648 && (e = -2147483648), e = +e, ht(e) && (e = l ? 0 : i.length - 1), e < 0 && (e = i.length + e), e >= i.length) {
|
|
1454
|
+
if (l)
|
|
1455
|
+
return -1;
|
|
1456
|
+
e = i.length - 1;
|
|
1457
|
+
} else if (e < 0)
|
|
1458
|
+
if (l)
|
|
1459
|
+
e = 0;
|
|
1460
|
+
else
|
|
1461
|
+
return -1;
|
|
1462
|
+
if (typeof t == "string" && (t = c.from(t, a)), c.isBuffer(t))
|
|
1463
|
+
return t.length === 0 ? -1 : Et(i, t, e, a, l);
|
|
1464
|
+
if (typeof t == "number")
|
|
1465
|
+
return t = t & 255, typeof Uint8Array.prototype.indexOf == "function" ? l ? Uint8Array.prototype.indexOf.call(i, t, e) : Uint8Array.prototype.lastIndexOf.call(i, t, e) : Et(i, [t], e, a, l);
|
|
1466
|
+
throw new TypeError("val must be string, number or Buffer");
|
|
1467
|
+
}
|
|
1468
|
+
function Et(i, t, e, a, l) {
|
|
1469
|
+
let p = 1, d = i.length, x = t.length;
|
|
1470
|
+
if (a !== void 0 && (a = String(a).toLowerCase(), a === "ucs2" || a === "ucs-2" || a === "utf16le" || a === "utf-16le")) {
|
|
1471
|
+
if (i.length < 2 || t.length < 2)
|
|
1472
|
+
return -1;
|
|
1473
|
+
p = 2, d /= 2, x /= 2, e /= 2;
|
|
1474
|
+
}
|
|
1475
|
+
function A(F, E) {
|
|
1476
|
+
return p === 1 ? F[E] : F.readUInt16BE(E * p);
|
|
1477
|
+
}
|
|
1478
|
+
let I;
|
|
1479
|
+
if (l) {
|
|
1480
|
+
let F = -1;
|
|
1481
|
+
for (I = e; I < d; I++)
|
|
1482
|
+
if (A(i, I) === A(t, F === -1 ? 0 : I - F)) {
|
|
1483
|
+
if (F === -1 && (F = I), I - F + 1 === x)
|
|
1484
|
+
return F * p;
|
|
1485
|
+
} else
|
|
1486
|
+
F !== -1 && (I -= I - F), F = -1;
|
|
1487
|
+
} else
|
|
1488
|
+
for (e + x > d && (e = d - x), I = e; I >= 0; I--) {
|
|
1489
|
+
let F = !0;
|
|
1490
|
+
for (let E = 0; E < x; E++)
|
|
1491
|
+
if (A(i, I + E) !== A(t, E)) {
|
|
1492
|
+
F = !1;
|
|
1493
|
+
break;
|
|
1494
|
+
}
|
|
1495
|
+
if (F)
|
|
1496
|
+
return I;
|
|
1497
|
+
}
|
|
1498
|
+
return -1;
|
|
1499
|
+
}
|
|
1500
|
+
c.prototype.includes = function(t, e, a) {
|
|
1501
|
+
return this.indexOf(t, e, a) !== -1;
|
|
1502
|
+
}, c.prototype.indexOf = function(t, e, a) {
|
|
1503
|
+
return Bt(this, t, e, a, !0);
|
|
1504
|
+
}, c.prototype.lastIndexOf = function(t, e, a) {
|
|
1505
|
+
return Bt(this, t, e, a, !1);
|
|
1506
|
+
};
|
|
1507
|
+
function oe(i, t, e, a) {
|
|
1508
|
+
e = Number(e) || 0;
|
|
1509
|
+
const l = i.length - e;
|
|
1510
|
+
a ? (a = Number(a), a > l && (a = l)) : a = l;
|
|
1511
|
+
const p = t.length;
|
|
1512
|
+
a > p / 2 && (a = p / 2);
|
|
1513
|
+
let d;
|
|
1514
|
+
for (d = 0; d < a; ++d) {
|
|
1515
|
+
const x = parseInt(t.substr(d * 2, 2), 16);
|
|
1516
|
+
if (ht(x))
|
|
1517
|
+
return d;
|
|
1518
|
+
i[e + d] = x;
|
|
1519
|
+
}
|
|
1520
|
+
return d;
|
|
1521
|
+
}
|
|
1522
|
+
function se(i, t, e, a) {
|
|
1523
|
+
return nt(ut(t, i.length - e), i, e, a);
|
|
1524
|
+
}
|
|
1525
|
+
function ae(i, t, e, a) {
|
|
1526
|
+
return nt(be(t), i, e, a);
|
|
1527
|
+
}
|
|
1528
|
+
function ce(i, t, e, a) {
|
|
1529
|
+
return nt(Rt(t), i, e, a);
|
|
1530
|
+
}
|
|
1531
|
+
function fe(i, t, e, a) {
|
|
1532
|
+
return nt(xe(t, i.length - e), i, e, a);
|
|
1533
|
+
}
|
|
1534
|
+
c.prototype.write = function(t, e, a, l) {
|
|
1535
|
+
if (e === void 0)
|
|
1536
|
+
l = "utf8", a = this.length, e = 0;
|
|
1537
|
+
else if (a === void 0 && typeof e == "string")
|
|
1538
|
+
l = e, a = this.length, e = 0;
|
|
1539
|
+
else if (isFinite(e))
|
|
1540
|
+
e = e >>> 0, isFinite(a) ? (a = a >>> 0, l === void 0 && (l = "utf8")) : (l = a, a = void 0);
|
|
1541
|
+
else
|
|
1542
|
+
throw new Error(
|
|
1543
|
+
"Buffer.write(string, encoding, offset[, length]) is no longer supported"
|
|
1544
|
+
);
|
|
1545
|
+
const p = this.length - e;
|
|
1546
|
+
if ((a === void 0 || a > p) && (a = p), t.length > 0 && (a < 0 || e < 0) || e > this.length)
|
|
1547
|
+
throw new RangeError("Attempt to write outside buffer bounds");
|
|
1548
|
+
l || (l = "utf8");
|
|
1549
|
+
let d = !1;
|
|
1550
|
+
for (; ; )
|
|
1551
|
+
switch (l) {
|
|
1552
|
+
case "hex":
|
|
1553
|
+
return oe(this, t, e, a);
|
|
1554
|
+
case "utf8":
|
|
1555
|
+
case "utf-8":
|
|
1556
|
+
return se(this, t, e, a);
|
|
1557
|
+
case "ascii":
|
|
1558
|
+
case "latin1":
|
|
1559
|
+
case "binary":
|
|
1560
|
+
return ae(this, t, e, a);
|
|
1561
|
+
case "base64":
|
|
1562
|
+
return ce(this, t, e, a);
|
|
1563
|
+
case "ucs2":
|
|
1564
|
+
case "ucs-2":
|
|
1565
|
+
case "utf16le":
|
|
1566
|
+
case "utf-16le":
|
|
1567
|
+
return fe(this, t, e, a);
|
|
1568
|
+
default:
|
|
1569
|
+
if (d)
|
|
1570
|
+
throw new TypeError("Unknown encoding: " + l);
|
|
1571
|
+
l = ("" + l).toLowerCase(), d = !0;
|
|
1572
|
+
}
|
|
1573
|
+
}, c.prototype.toJSON = function() {
|
|
1574
|
+
return {
|
|
1575
|
+
type: "Buffer",
|
|
1576
|
+
data: Array.prototype.slice.call(this._arr || this, 0)
|
|
1577
|
+
};
|
|
1578
|
+
};
|
|
1579
|
+
function ue(i, t, e) {
|
|
1580
|
+
return t === 0 && e === i.length ? r.fromByteArray(i) : r.fromByteArray(i.slice(t, e));
|
|
1581
|
+
}
|
|
1582
|
+
function It(i, t, e) {
|
|
1583
|
+
e = Math.min(i.length, e);
|
|
1584
|
+
const a = [];
|
|
1585
|
+
let l = t;
|
|
1586
|
+
for (; l < e; ) {
|
|
1587
|
+
const p = i[l];
|
|
1588
|
+
let d = null, x = p > 239 ? 4 : p > 223 ? 3 : p > 191 ? 2 : 1;
|
|
1589
|
+
if (l + x <= e) {
|
|
1590
|
+
let A, I, F, E;
|
|
1591
|
+
switch (x) {
|
|
1592
|
+
case 1:
|
|
1593
|
+
p < 128 && (d = p);
|
|
1594
|
+
break;
|
|
1595
|
+
case 2:
|
|
1596
|
+
A = i[l + 1], (A & 192) === 128 && (E = (p & 31) << 6 | A & 63, E > 127 && (d = E));
|
|
1597
|
+
break;
|
|
1598
|
+
case 3:
|
|
1599
|
+
A = i[l + 1], I = i[l + 2], (A & 192) === 128 && (I & 192) === 128 && (E = (p & 15) << 12 | (A & 63) << 6 | I & 63, E > 2047 && (E < 55296 || E > 57343) && (d = E));
|
|
1600
|
+
break;
|
|
1601
|
+
case 4:
|
|
1602
|
+
A = i[l + 1], I = i[l + 2], F = i[l + 3], (A & 192) === 128 && (I & 192) === 128 && (F & 192) === 128 && (E = (p & 15) << 18 | (A & 63) << 12 | (I & 63) << 6 | F & 63, E > 65535 && E < 1114112 && (d = E));
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
d === null ? (d = 65533, x = 1) : d > 65535 && (d -= 65536, a.push(d >>> 10 & 1023 | 55296), d = 56320 | d & 1023), a.push(d), l += x;
|
|
1606
|
+
}
|
|
1607
|
+
return he(a);
|
|
1608
|
+
}
|
|
1609
|
+
const _t = 4096;
|
|
1610
|
+
function he(i) {
|
|
1611
|
+
const t = i.length;
|
|
1612
|
+
if (t <= _t)
|
|
1613
|
+
return String.fromCharCode.apply(String, i);
|
|
1614
|
+
let e = "", a = 0;
|
|
1615
|
+
for (; a < t; )
|
|
1616
|
+
e += String.fromCharCode.apply(
|
|
1617
|
+
String,
|
|
1618
|
+
i.slice(a, a += _t)
|
|
1619
|
+
);
|
|
1620
|
+
return e;
|
|
1621
|
+
}
|
|
1622
|
+
function le(i, t, e) {
|
|
1623
|
+
let a = "";
|
|
1624
|
+
e = Math.min(i.length, e);
|
|
1625
|
+
for (let l = t; l < e; ++l)
|
|
1626
|
+
a += String.fromCharCode(i[l] & 127);
|
|
1627
|
+
return a;
|
|
1628
|
+
}
|
|
1629
|
+
function pe(i, t, e) {
|
|
1630
|
+
let a = "";
|
|
1631
|
+
e = Math.min(i.length, e);
|
|
1632
|
+
for (let l = t; l < e; ++l)
|
|
1633
|
+
a += String.fromCharCode(i[l]);
|
|
1634
|
+
return a;
|
|
1635
|
+
}
|
|
1636
|
+
function de(i, t, e) {
|
|
1637
|
+
const a = i.length;
|
|
1638
|
+
(!t || t < 0) && (t = 0), (!e || e < 0 || e > a) && (e = a);
|
|
1639
|
+
let l = "";
|
|
1640
|
+
for (let p = t; p < e; ++p)
|
|
1641
|
+
l += Be[i[p]];
|
|
1642
|
+
return l;
|
|
1643
|
+
}
|
|
1644
|
+
function we(i, t, e) {
|
|
1645
|
+
const a = i.slice(t, e);
|
|
1646
|
+
let l = "";
|
|
1647
|
+
for (let p = 0; p < a.length - 1; p += 2)
|
|
1648
|
+
l += String.fromCharCode(a[p] + a[p + 1] * 256);
|
|
1649
|
+
return l;
|
|
1650
|
+
}
|
|
1651
|
+
c.prototype.slice = function(t, e) {
|
|
1652
|
+
const a = this.length;
|
|
1653
|
+
t = ~~t, e = e === void 0 ? a : ~~e, t < 0 ? (t += a, t < 0 && (t = 0)) : t > a && (t = a), e < 0 ? (e += a, e < 0 && (e = 0)) : e > a && (e = a), e < t && (e = t);
|
|
1654
|
+
const l = this.subarray(t, e);
|
|
1655
|
+
return Object.setPrototypeOf(l, c.prototype), l;
|
|
1656
|
+
};
|
|
1657
|
+
function S(i, t, e) {
|
|
1658
|
+
if (i % 1 !== 0 || i < 0)
|
|
1659
|
+
throw new RangeError("offset is not uint");
|
|
1660
|
+
if (i + t > e)
|
|
1661
|
+
throw new RangeError("Trying to access beyond buffer length");
|
|
1662
|
+
}
|
|
1663
|
+
c.prototype.readUintLE = c.prototype.readUIntLE = function(t, e, a) {
|
|
1664
|
+
t = t >>> 0, e = e >>> 0, a || S(t, e, this.length);
|
|
1665
|
+
let l = this[t], p = 1, d = 0;
|
|
1666
|
+
for (; ++d < e && (p *= 256); )
|
|
1667
|
+
l += this[t + d] * p;
|
|
1668
|
+
return l;
|
|
1669
|
+
}, c.prototype.readUintBE = c.prototype.readUIntBE = function(t, e, a) {
|
|
1670
|
+
t = t >>> 0, e = e >>> 0, a || S(t, e, this.length);
|
|
1671
|
+
let l = this[t + --e], p = 1;
|
|
1672
|
+
for (; e > 0 && (p *= 256); )
|
|
1673
|
+
l += this[t + --e] * p;
|
|
1674
|
+
return l;
|
|
1675
|
+
}, c.prototype.readUint8 = c.prototype.readUInt8 = function(t, e) {
|
|
1676
|
+
return t = t >>> 0, e || S(t, 1, this.length), this[t];
|
|
1677
|
+
}, c.prototype.readUint16LE = c.prototype.readUInt16LE = function(t, e) {
|
|
1678
|
+
return t = t >>> 0, e || S(t, 2, this.length), this[t] | this[t + 1] << 8;
|
|
1679
|
+
}, c.prototype.readUint16BE = c.prototype.readUInt16BE = function(t, e) {
|
|
1680
|
+
return t = t >>> 0, e || S(t, 2, this.length), this[t] << 8 | this[t + 1];
|
|
1681
|
+
}, c.prototype.readUint32LE = c.prototype.readUInt32LE = function(t, e) {
|
|
1682
|
+
return t = t >>> 0, e || S(t, 4, this.length), (this[t] | this[t + 1] << 8 | this[t + 2] << 16) + this[t + 3] * 16777216;
|
|
1683
|
+
}, c.prototype.readUint32BE = c.prototype.readUInt32BE = function(t, e) {
|
|
1684
|
+
return t = t >>> 0, e || S(t, 4, this.length), this[t] * 16777216 + (this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3]);
|
|
1685
|
+
}, c.prototype.readBigUInt64LE = v(function(t) {
|
|
1686
|
+
t = t >>> 0, V(t, "offset");
|
|
1687
|
+
const e = this[t], a = this[t + 7];
|
|
1688
|
+
(e === void 0 || a === void 0) && X(t, this.length - 8);
|
|
1689
|
+
const l = e + this[++t] * 2 ** 8 + this[++t] * 2 ** 16 + this[++t] * 2 ** 24, p = this[++t] + this[++t] * 2 ** 8 + this[++t] * 2 ** 16 + a * 2 ** 24;
|
|
1690
|
+
return BigInt(l) + (BigInt(p) << BigInt(32));
|
|
1691
|
+
}), c.prototype.readBigUInt64BE = v(function(t) {
|
|
1692
|
+
t = t >>> 0, V(t, "offset");
|
|
1693
|
+
const e = this[t], a = this[t + 7];
|
|
1694
|
+
(e === void 0 || a === void 0) && X(t, this.length - 8);
|
|
1695
|
+
const l = e * 2 ** 24 + this[++t] * 2 ** 16 + this[++t] * 2 ** 8 + this[++t], p = this[++t] * 2 ** 24 + this[++t] * 2 ** 16 + this[++t] * 2 ** 8 + a;
|
|
1696
|
+
return (BigInt(l) << BigInt(32)) + BigInt(p);
|
|
1697
|
+
}), c.prototype.readIntLE = function(t, e, a) {
|
|
1698
|
+
t = t >>> 0, e = e >>> 0, a || S(t, e, this.length);
|
|
1699
|
+
let l = this[t], p = 1, d = 0;
|
|
1700
|
+
for (; ++d < e && (p *= 256); )
|
|
1701
|
+
l += this[t + d] * p;
|
|
1702
|
+
return p *= 128, l >= p && (l -= Math.pow(2, 8 * e)), l;
|
|
1703
|
+
}, c.prototype.readIntBE = function(t, e, a) {
|
|
1704
|
+
t = t >>> 0, e = e >>> 0, a || S(t, e, this.length);
|
|
1705
|
+
let l = e, p = 1, d = this[t + --l];
|
|
1706
|
+
for (; l > 0 && (p *= 256); )
|
|
1707
|
+
d += this[t + --l] * p;
|
|
1708
|
+
return p *= 128, d >= p && (d -= Math.pow(2, 8 * e)), d;
|
|
1709
|
+
}, c.prototype.readInt8 = function(t, e) {
|
|
1710
|
+
return t = t >>> 0, e || S(t, 1, this.length), this[t] & 128 ? (255 - this[t] + 1) * -1 : this[t];
|
|
1711
|
+
}, c.prototype.readInt16LE = function(t, e) {
|
|
1712
|
+
t = t >>> 0, e || S(t, 2, this.length);
|
|
1713
|
+
const a = this[t] | this[t + 1] << 8;
|
|
1714
|
+
return a & 32768 ? a | 4294901760 : a;
|
|
1715
|
+
}, c.prototype.readInt16BE = function(t, e) {
|
|
1716
|
+
t = t >>> 0, e || S(t, 2, this.length);
|
|
1717
|
+
const a = this[t + 1] | this[t] << 8;
|
|
1718
|
+
return a & 32768 ? a | 4294901760 : a;
|
|
1719
|
+
}, c.prototype.readInt32LE = function(t, e) {
|
|
1720
|
+
return t = t >>> 0, e || S(t, 4, this.length), this[t] | this[t + 1] << 8 | this[t + 2] << 16 | this[t + 3] << 24;
|
|
1721
|
+
}, c.prototype.readInt32BE = function(t, e) {
|
|
1722
|
+
return t = t >>> 0, e || S(t, 4, this.length), this[t] << 24 | this[t + 1] << 16 | this[t + 2] << 8 | this[t + 3];
|
|
1723
|
+
}, c.prototype.readBigInt64LE = v(function(t) {
|
|
1724
|
+
t = t >>> 0, V(t, "offset");
|
|
1725
|
+
const e = this[t], a = this[t + 7];
|
|
1726
|
+
(e === void 0 || a === void 0) && X(t, this.length - 8);
|
|
1727
|
+
const l = this[t + 4] + this[t + 5] * 2 ** 8 + this[t + 6] * 2 ** 16 + (a << 24);
|
|
1728
|
+
return (BigInt(l) << BigInt(32)) + BigInt(e + this[++t] * 2 ** 8 + this[++t] * 2 ** 16 + this[++t] * 2 ** 24);
|
|
1729
|
+
}), c.prototype.readBigInt64BE = v(function(t) {
|
|
1730
|
+
t = t >>> 0, V(t, "offset");
|
|
1731
|
+
const e = this[t], a = this[t + 7];
|
|
1732
|
+
(e === void 0 || a === void 0) && X(t, this.length - 8);
|
|
1733
|
+
const l = (e << 24) + // Overflow
|
|
1734
|
+
this[++t] * 2 ** 16 + this[++t] * 2 ** 8 + this[++t];
|
|
1735
|
+
return (BigInt(l) << BigInt(32)) + BigInt(this[++t] * 2 ** 24 + this[++t] * 2 ** 16 + this[++t] * 2 ** 8 + a);
|
|
1736
|
+
}), c.prototype.readFloatLE = function(t, e) {
|
|
1737
|
+
return t = t >>> 0, e || S(t, 4, this.length), o.read(this, t, !0, 23, 4);
|
|
1738
|
+
}, c.prototype.readFloatBE = function(t, e) {
|
|
1739
|
+
return t = t >>> 0, e || S(t, 4, this.length), o.read(this, t, !1, 23, 4);
|
|
1740
|
+
}, c.prototype.readDoubleLE = function(t, e) {
|
|
1741
|
+
return t = t >>> 0, e || S(t, 8, this.length), o.read(this, t, !0, 52, 8);
|
|
1742
|
+
}, c.prototype.readDoubleBE = function(t, e) {
|
|
1743
|
+
return t = t >>> 0, e || S(t, 8, this.length), o.read(this, t, !1, 52, 8);
|
|
1744
|
+
};
|
|
1745
|
+
function C(i, t, e, a, l, p) {
|
|
1746
|
+
if (!c.isBuffer(i))
|
|
1747
|
+
throw new TypeError('"buffer" argument must be a Buffer instance');
|
|
1748
|
+
if (t > l || t < p)
|
|
1749
|
+
throw new RangeError('"value" argument is out of bounds');
|
|
1750
|
+
if (e + a > i.length)
|
|
1751
|
+
throw new RangeError("Index out of range");
|
|
1752
|
+
}
|
|
1753
|
+
c.prototype.writeUintLE = c.prototype.writeUIntLE = function(t, e, a, l) {
|
|
1754
|
+
if (t = +t, e = e >>> 0, a = a >>> 0, !l) {
|
|
1755
|
+
const x = Math.pow(2, 8 * a) - 1;
|
|
1756
|
+
C(this, t, e, a, x, 0);
|
|
1757
|
+
}
|
|
1758
|
+
let p = 1, d = 0;
|
|
1759
|
+
for (this[e] = t & 255; ++d < a && (p *= 256); )
|
|
1760
|
+
this[e + d] = t / p & 255;
|
|
1761
|
+
return e + a;
|
|
1762
|
+
}, c.prototype.writeUintBE = c.prototype.writeUIntBE = function(t, e, a, l) {
|
|
1763
|
+
if (t = +t, e = e >>> 0, a = a >>> 0, !l) {
|
|
1764
|
+
const x = Math.pow(2, 8 * a) - 1;
|
|
1765
|
+
C(this, t, e, a, x, 0);
|
|
1766
|
+
}
|
|
1767
|
+
let p = a - 1, d = 1;
|
|
1768
|
+
for (this[e + p] = t & 255; --p >= 0 && (d *= 256); )
|
|
1769
|
+
this[e + p] = t / d & 255;
|
|
1770
|
+
return e + a;
|
|
1771
|
+
}, c.prototype.writeUint8 = c.prototype.writeUInt8 = function(t, e, a) {
|
|
1772
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 1, 255, 0), this[e] = t & 255, e + 1;
|
|
1773
|
+
}, c.prototype.writeUint16LE = c.prototype.writeUInt16LE = function(t, e, a) {
|
|
1774
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 2, 65535, 0), this[e] = t & 255, this[e + 1] = t >>> 8, e + 2;
|
|
1775
|
+
}, c.prototype.writeUint16BE = c.prototype.writeUInt16BE = function(t, e, a) {
|
|
1776
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 2, 65535, 0), this[e] = t >>> 8, this[e + 1] = t & 255, e + 2;
|
|
1777
|
+
}, c.prototype.writeUint32LE = c.prototype.writeUInt32LE = function(t, e, a) {
|
|
1778
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 4, 4294967295, 0), this[e + 3] = t >>> 24, this[e + 2] = t >>> 16, this[e + 1] = t >>> 8, this[e] = t & 255, e + 4;
|
|
1779
|
+
}, c.prototype.writeUint32BE = c.prototype.writeUInt32BE = function(t, e, a) {
|
|
1780
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 4, 4294967295, 0), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = t & 255, e + 4;
|
|
1781
|
+
};
|
|
1782
|
+
function At(i, t, e, a, l) {
|
|
1783
|
+
$t(t, a, l, i, e, 7);
|
|
1784
|
+
let p = Number(t & BigInt(4294967295));
|
|
1785
|
+
i[e++] = p, p = p >> 8, i[e++] = p, p = p >> 8, i[e++] = p, p = p >> 8, i[e++] = p;
|
|
1786
|
+
let d = Number(t >> BigInt(32) & BigInt(4294967295));
|
|
1787
|
+
return i[e++] = d, d = d >> 8, i[e++] = d, d = d >> 8, i[e++] = d, d = d >> 8, i[e++] = d, e;
|
|
1788
|
+
}
|
|
1789
|
+
function Ft(i, t, e, a, l) {
|
|
1790
|
+
$t(t, a, l, i, e, 7);
|
|
1791
|
+
let p = Number(t & BigInt(4294967295));
|
|
1792
|
+
i[e + 7] = p, p = p >> 8, i[e + 6] = p, p = p >> 8, i[e + 5] = p, p = p >> 8, i[e + 4] = p;
|
|
1793
|
+
let d = Number(t >> BigInt(32) & BigInt(4294967295));
|
|
1794
|
+
return i[e + 3] = d, d = d >> 8, i[e + 2] = d, d = d >> 8, i[e + 1] = d, d = d >> 8, i[e] = d, e + 8;
|
|
1795
|
+
}
|
|
1796
|
+
c.prototype.writeBigUInt64LE = v(function(t, e = 0) {
|
|
1797
|
+
return At(this, t, e, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1798
|
+
}), c.prototype.writeBigUInt64BE = v(function(t, e = 0) {
|
|
1799
|
+
return Ft(this, t, e, BigInt(0), BigInt("0xffffffffffffffff"));
|
|
1800
|
+
}), c.prototype.writeIntLE = function(t, e, a, l) {
|
|
1801
|
+
if (t = +t, e = e >>> 0, !l) {
|
|
1802
|
+
const A = Math.pow(2, 8 * a - 1);
|
|
1803
|
+
C(this, t, e, a, A - 1, -A);
|
|
1804
|
+
}
|
|
1805
|
+
let p = 0, d = 1, x = 0;
|
|
1806
|
+
for (this[e] = t & 255; ++p < a && (d *= 256); )
|
|
1807
|
+
t < 0 && x === 0 && this[e + p - 1] !== 0 && (x = 1), this[e + p] = (t / d >> 0) - x & 255;
|
|
1808
|
+
return e + a;
|
|
1809
|
+
}, c.prototype.writeIntBE = function(t, e, a, l) {
|
|
1810
|
+
if (t = +t, e = e >>> 0, !l) {
|
|
1811
|
+
const A = Math.pow(2, 8 * a - 1);
|
|
1812
|
+
C(this, t, e, a, A - 1, -A);
|
|
1813
|
+
}
|
|
1814
|
+
let p = a - 1, d = 1, x = 0;
|
|
1815
|
+
for (this[e + p] = t & 255; --p >= 0 && (d *= 256); )
|
|
1816
|
+
t < 0 && x === 0 && this[e + p + 1] !== 0 && (x = 1), this[e + p] = (t / d >> 0) - x & 255;
|
|
1817
|
+
return e + a;
|
|
1818
|
+
}, c.prototype.writeInt8 = function(t, e, a) {
|
|
1819
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 1, 127, -128), t < 0 && (t = 255 + t + 1), this[e] = t & 255, e + 1;
|
|
1820
|
+
}, c.prototype.writeInt16LE = function(t, e, a) {
|
|
1821
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 2, 32767, -32768), this[e] = t & 255, this[e + 1] = t >>> 8, e + 2;
|
|
1822
|
+
}, c.prototype.writeInt16BE = function(t, e, a) {
|
|
1823
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 2, 32767, -32768), this[e] = t >>> 8, this[e + 1] = t & 255, e + 2;
|
|
1824
|
+
}, c.prototype.writeInt32LE = function(t, e, a) {
|
|
1825
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 4, 2147483647, -2147483648), this[e] = t & 255, this[e + 1] = t >>> 8, this[e + 2] = t >>> 16, this[e + 3] = t >>> 24, e + 4;
|
|
1826
|
+
}, c.prototype.writeInt32BE = function(t, e, a) {
|
|
1827
|
+
return t = +t, e = e >>> 0, a || C(this, t, e, 4, 2147483647, -2147483648), t < 0 && (t = 4294967295 + t + 1), this[e] = t >>> 24, this[e + 1] = t >>> 16, this[e + 2] = t >>> 8, this[e + 3] = t & 255, e + 4;
|
|
1828
|
+
}, c.prototype.writeBigInt64LE = v(function(t, e = 0) {
|
|
1829
|
+
return At(this, t, e, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1830
|
+
}), c.prototype.writeBigInt64BE = v(function(t, e = 0) {
|
|
1831
|
+
return Ft(this, t, e, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
|
|
1832
|
+
});
|
|
1833
|
+
function Ut(i, t, e, a, l, p) {
|
|
1834
|
+
if (e + a > i.length)
|
|
1835
|
+
throw new RangeError("Index out of range");
|
|
1836
|
+
if (e < 0)
|
|
1837
|
+
throw new RangeError("Index out of range");
|
|
1838
|
+
}
|
|
1839
|
+
function St(i, t, e, a, l) {
|
|
1840
|
+
return t = +t, e = e >>> 0, l || Ut(i, t, e, 4), o.write(i, t, e, a, 23, 4), e + 4;
|
|
1841
|
+
}
|
|
1842
|
+
c.prototype.writeFloatLE = function(t, e, a) {
|
|
1843
|
+
return St(this, t, e, !0, a);
|
|
1844
|
+
}, c.prototype.writeFloatBE = function(t, e, a) {
|
|
1845
|
+
return St(this, t, e, !1, a);
|
|
1846
|
+
};
|
|
1847
|
+
function kt(i, t, e, a, l) {
|
|
1848
|
+
return t = +t, e = e >>> 0, l || Ut(i, t, e, 8), o.write(i, t, e, a, 52, 8), e + 8;
|
|
1849
|
+
}
|
|
1850
|
+
c.prototype.writeDoubleLE = function(t, e, a) {
|
|
1851
|
+
return kt(this, t, e, !0, a);
|
|
1852
|
+
}, c.prototype.writeDoubleBE = function(t, e, a) {
|
|
1853
|
+
return kt(this, t, e, !1, a);
|
|
1854
|
+
}, c.prototype.copy = function(t, e, a, l) {
|
|
1855
|
+
if (!c.isBuffer(t))
|
|
1856
|
+
throw new TypeError("argument should be a Buffer");
|
|
1857
|
+
if (a || (a = 0), !l && l !== 0 && (l = this.length), e >= t.length && (e = t.length), e || (e = 0), l > 0 && l < a && (l = a), l === a || t.length === 0 || this.length === 0)
|
|
1858
|
+
return 0;
|
|
1859
|
+
if (e < 0)
|
|
1860
|
+
throw new RangeError("targetStart out of bounds");
|
|
1861
|
+
if (a < 0 || a >= this.length)
|
|
1862
|
+
throw new RangeError("Index out of range");
|
|
1863
|
+
if (l < 0)
|
|
1864
|
+
throw new RangeError("sourceEnd out of bounds");
|
|
1865
|
+
l > this.length && (l = this.length), t.length - e < l - a && (l = t.length - e + a);
|
|
1866
|
+
const p = l - a;
|
|
1867
|
+
return this === t && typeof Uint8Array.prototype.copyWithin == "function" ? this.copyWithin(e, a, l) : Uint8Array.prototype.set.call(
|
|
1868
|
+
t,
|
|
1869
|
+
this.subarray(a, l),
|
|
1870
|
+
e
|
|
1871
|
+
), p;
|
|
1872
|
+
}, c.prototype.fill = function(t, e, a, l) {
|
|
1873
|
+
if (typeof t == "string") {
|
|
1874
|
+
if (typeof e == "string" ? (l = e, e = 0, a = this.length) : typeof a == "string" && (l = a, a = this.length), l !== void 0 && typeof l != "string")
|
|
1875
|
+
throw new TypeError("encoding must be a string");
|
|
1876
|
+
if (typeof l == "string" && !c.isEncoding(l))
|
|
1877
|
+
throw new TypeError("Unknown encoding: " + l);
|
|
1878
|
+
if (t.length === 1) {
|
|
1879
|
+
const d = t.charCodeAt(0);
|
|
1880
|
+
(l === "utf8" && d < 128 || l === "latin1") && (t = d);
|
|
1881
|
+
}
|
|
1882
|
+
} else
|
|
1883
|
+
typeof t == "number" ? t = t & 255 : typeof t == "boolean" && (t = Number(t));
|
|
1884
|
+
if (e < 0 || this.length < e || this.length < a)
|
|
1885
|
+
throw new RangeError("Out of range index");
|
|
1886
|
+
if (a <= e)
|
|
1887
|
+
return this;
|
|
1888
|
+
e = e >>> 0, a = a === void 0 ? this.length : a >>> 0, t || (t = 0);
|
|
1889
|
+
let p;
|
|
1890
|
+
if (typeof t == "number")
|
|
1891
|
+
for (p = e; p < a; ++p)
|
|
1892
|
+
this[p] = t;
|
|
1893
|
+
else {
|
|
1894
|
+
const d = c.isBuffer(t) ? t : c.from(t, l), x = d.length;
|
|
1895
|
+
if (x === 0)
|
|
1896
|
+
throw new TypeError('The value "' + t + '" is invalid for argument "value"');
|
|
1897
|
+
for (p = 0; p < a - e; ++p)
|
|
1898
|
+
this[p + e] = d[p % x];
|
|
1899
|
+
}
|
|
1900
|
+
return this;
|
|
1901
|
+
};
|
|
1902
|
+
const Y = {};
|
|
1903
|
+
function ft(i, t, e) {
|
|
1904
|
+
Y[i] = class extends e {
|
|
1905
|
+
constructor() {
|
|
1906
|
+
super(), Object.defineProperty(this, "message", {
|
|
1907
|
+
value: t.apply(this, arguments),
|
|
1908
|
+
writable: !0,
|
|
1909
|
+
configurable: !0
|
|
1910
|
+
}), this.name = `${this.name} [${i}]`, this.stack, delete this.name;
|
|
1911
|
+
}
|
|
1912
|
+
get code() {
|
|
1913
|
+
return i;
|
|
1914
|
+
}
|
|
1915
|
+
set code(l) {
|
|
1916
|
+
Object.defineProperty(this, "code", {
|
|
1917
|
+
configurable: !0,
|
|
1918
|
+
enumerable: !0,
|
|
1919
|
+
value: l,
|
|
1920
|
+
writable: !0
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
toString() {
|
|
1924
|
+
return `${this.name} [${i}]: ${this.message}`;
|
|
1925
|
+
}
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
ft(
|
|
1929
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
1930
|
+
function(i) {
|
|
1931
|
+
return i ? `${i} is outside of buffer bounds` : "Attempt to access memory outside buffer bounds";
|
|
1932
|
+
},
|
|
1933
|
+
RangeError
|
|
1934
|
+
), ft(
|
|
1935
|
+
"ERR_INVALID_ARG_TYPE",
|
|
1936
|
+
function(i, t) {
|
|
1937
|
+
return `The "${i}" argument must be of type number. Received type ${typeof t}`;
|
|
1938
|
+
},
|
|
1939
|
+
TypeError
|
|
1940
|
+
), ft(
|
|
1941
|
+
"ERR_OUT_OF_RANGE",
|
|
1942
|
+
function(i, t, e) {
|
|
1943
|
+
let a = `The value of "${i}" is out of range.`, l = e;
|
|
1944
|
+
return Number.isInteger(e) && Math.abs(e) > 2 ** 32 ? l = Tt(String(e)) : typeof e == "bigint" && (l = String(e), (e > BigInt(2) ** BigInt(32) || e < -(BigInt(2) ** BigInt(32))) && (l = Tt(l)), l += "n"), a += ` It must be ${t}. Received ${l}`, a;
|
|
1945
|
+
},
|
|
1946
|
+
RangeError
|
|
1947
|
+
);
|
|
1948
|
+
function Tt(i) {
|
|
1949
|
+
let t = "", e = i.length;
|
|
1950
|
+
const a = i[0] === "-" ? 1 : 0;
|
|
1951
|
+
for (; e >= a + 4; e -= 3)
|
|
1952
|
+
t = `_${i.slice(e - 3, e)}${t}`;
|
|
1953
|
+
return `${i.slice(0, e)}${t}`;
|
|
1954
|
+
}
|
|
1955
|
+
function ye(i, t, e) {
|
|
1956
|
+
V(t, "offset"), (i[t] === void 0 || i[t + e] === void 0) && X(t, i.length - (e + 1));
|
|
1957
|
+
}
|
|
1958
|
+
function $t(i, t, e, a, l, p) {
|
|
1959
|
+
if (i > e || i < t) {
|
|
1960
|
+
const d = typeof t == "bigint" ? "n" : "";
|
|
1961
|
+
let x;
|
|
1962
|
+
throw p > 3 ? t === 0 || t === BigInt(0) ? x = `>= 0${d} and < 2${d} ** ${(p + 1) * 8}${d}` : x = `>= -(2${d} ** ${(p + 1) * 8 - 1}${d}) and < 2 ** ${(p + 1) * 8 - 1}${d}` : x = `>= ${t}${d} and <= ${e}${d}`, new Y.ERR_OUT_OF_RANGE("value", x, i);
|
|
1963
|
+
}
|
|
1964
|
+
ye(a, l, p);
|
|
1965
|
+
}
|
|
1966
|
+
function V(i, t) {
|
|
1967
|
+
if (typeof i != "number")
|
|
1968
|
+
throw new Y.ERR_INVALID_ARG_TYPE(t, "number", i);
|
|
1969
|
+
}
|
|
1970
|
+
function X(i, t, e) {
|
|
1971
|
+
throw Math.floor(i) !== i ? (V(i, e), new Y.ERR_OUT_OF_RANGE(e || "offset", "an integer", i)) : t < 0 ? new Y.ERR_BUFFER_OUT_OF_BOUNDS() : new Y.ERR_OUT_OF_RANGE(
|
|
1972
|
+
e || "offset",
|
|
1973
|
+
`>= ${e ? 1 : 0} and <= ${t}`,
|
|
1974
|
+
i
|
|
1975
|
+
);
|
|
1976
|
+
}
|
|
1977
|
+
const ge = /[^+/0-9A-Za-z-_]/g;
|
|
1978
|
+
function me(i) {
|
|
1979
|
+
if (i = i.split("=")[0], i = i.trim().replace(ge, ""), i.length < 2)
|
|
1980
|
+
return "";
|
|
1981
|
+
for (; i.length % 4 !== 0; )
|
|
1982
|
+
i = i + "=";
|
|
1983
|
+
return i;
|
|
1984
|
+
}
|
|
1985
|
+
function ut(i, t) {
|
|
1986
|
+
t = t || 1 / 0;
|
|
1987
|
+
let e;
|
|
1988
|
+
const a = i.length;
|
|
1989
|
+
let l = null;
|
|
1990
|
+
const p = [];
|
|
1991
|
+
for (let d = 0; d < a; ++d) {
|
|
1992
|
+
if (e = i.charCodeAt(d), e > 55295 && e < 57344) {
|
|
1993
|
+
if (!l) {
|
|
1994
|
+
if (e > 56319) {
|
|
1995
|
+
(t -= 3) > -1 && p.push(239, 191, 189);
|
|
1996
|
+
continue;
|
|
1997
|
+
} else if (d + 1 === a) {
|
|
1998
|
+
(t -= 3) > -1 && p.push(239, 191, 189);
|
|
1999
|
+
continue;
|
|
2000
|
+
}
|
|
2001
|
+
l = e;
|
|
2002
|
+
continue;
|
|
2003
|
+
}
|
|
2004
|
+
if (e < 56320) {
|
|
2005
|
+
(t -= 3) > -1 && p.push(239, 191, 189), l = e;
|
|
2006
|
+
continue;
|
|
2007
|
+
}
|
|
2008
|
+
e = (l - 55296 << 10 | e - 56320) + 65536;
|
|
2009
|
+
} else
|
|
2010
|
+
l && (t -= 3) > -1 && p.push(239, 191, 189);
|
|
2011
|
+
if (l = null, e < 128) {
|
|
2012
|
+
if ((t -= 1) < 0)
|
|
2013
|
+
break;
|
|
2014
|
+
p.push(e);
|
|
2015
|
+
} else if (e < 2048) {
|
|
2016
|
+
if ((t -= 2) < 0)
|
|
2017
|
+
break;
|
|
2018
|
+
p.push(
|
|
2019
|
+
e >> 6 | 192,
|
|
2020
|
+
e & 63 | 128
|
|
2021
|
+
);
|
|
2022
|
+
} else if (e < 65536) {
|
|
2023
|
+
if ((t -= 3) < 0)
|
|
2024
|
+
break;
|
|
2025
|
+
p.push(
|
|
2026
|
+
e >> 12 | 224,
|
|
2027
|
+
e >> 6 & 63 | 128,
|
|
2028
|
+
e & 63 | 128
|
|
2029
|
+
);
|
|
2030
|
+
} else if (e < 1114112) {
|
|
2031
|
+
if ((t -= 4) < 0)
|
|
2032
|
+
break;
|
|
2033
|
+
p.push(
|
|
2034
|
+
e >> 18 | 240,
|
|
2035
|
+
e >> 12 & 63 | 128,
|
|
2036
|
+
e >> 6 & 63 | 128,
|
|
2037
|
+
e & 63 | 128
|
|
2038
|
+
);
|
|
2039
|
+
} else
|
|
2040
|
+
throw new Error("Invalid code point");
|
|
2041
|
+
}
|
|
2042
|
+
return p;
|
|
2043
|
+
}
|
|
2044
|
+
function be(i) {
|
|
2045
|
+
const t = [];
|
|
2046
|
+
for (let e = 0; e < i.length; ++e)
|
|
2047
|
+
t.push(i.charCodeAt(e) & 255);
|
|
2048
|
+
return t;
|
|
2049
|
+
}
|
|
2050
|
+
function xe(i, t) {
|
|
2051
|
+
let e, a, l;
|
|
2052
|
+
const p = [];
|
|
2053
|
+
for (let d = 0; d < i.length && !((t -= 2) < 0); ++d)
|
|
2054
|
+
e = i.charCodeAt(d), a = e >> 8, l = e % 256, p.push(l), p.push(a);
|
|
2055
|
+
return p;
|
|
2056
|
+
}
|
|
2057
|
+
function Rt(i) {
|
|
2058
|
+
return r.toByteArray(me(i));
|
|
2059
|
+
}
|
|
2060
|
+
function nt(i, t, e, a) {
|
|
2061
|
+
let l;
|
|
2062
|
+
for (l = 0; l < a && !(l + e >= t.length || l >= i.length); ++l)
|
|
2063
|
+
t[l + e] = i[l];
|
|
2064
|
+
return l;
|
|
2065
|
+
}
|
|
2066
|
+
function N(i, t) {
|
|
2067
|
+
return i instanceof t || i != null && i.constructor != null && i.constructor.name != null && i.constructor.name === t.name;
|
|
2068
|
+
}
|
|
2069
|
+
function ht(i) {
|
|
2070
|
+
return i !== i;
|
|
2071
|
+
}
|
|
2072
|
+
const Be = function() {
|
|
2073
|
+
const i = "0123456789abcdef", t = new Array(256);
|
|
2074
|
+
for (let e = 0; e < 16; ++e) {
|
|
2075
|
+
const a = e * 16;
|
|
2076
|
+
for (let l = 0; l < 16; ++l)
|
|
2077
|
+
t[a + l] = i[e] + i[l];
|
|
2078
|
+
}
|
|
2079
|
+
return t;
|
|
2080
|
+
}();
|
|
2081
|
+
function v(i) {
|
|
2082
|
+
return typeof BigInt > "u" ? Ee : i;
|
|
2083
|
+
}
|
|
2084
|
+
function Ee() {
|
|
2085
|
+
throw new Error("BigInt not supported");
|
|
2086
|
+
}
|
|
2087
|
+
})(q);
|
|
2088
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
2089
|
+
(function(n, r) {
|
|
2090
|
+
var o = q, s = o.Buffer;
|
|
2091
|
+
function f(h, c) {
|
|
2092
|
+
for (var w in h)
|
|
2093
|
+
c[w] = h[w];
|
|
2094
|
+
}
|
|
2095
|
+
s.from && s.alloc && s.allocUnsafe && s.allocUnsafeSlow ? n.exports = o : (f(o, r), r.Buffer = u);
|
|
2096
|
+
function u(h, c, w) {
|
|
2097
|
+
return s(h, c, w);
|
|
2098
|
+
}
|
|
2099
|
+
u.prototype = Object.create(s.prototype), f(s, u), u.from = function(h, c, w) {
|
|
2100
|
+
if (typeof h == "number")
|
|
2101
|
+
throw new TypeError("Argument must not be a number");
|
|
2102
|
+
return s(h, c, w);
|
|
2103
|
+
}, u.alloc = function(h, c, w) {
|
|
2104
|
+
if (typeof h != "number")
|
|
2105
|
+
throw new TypeError("Argument must be a number");
|
|
2106
|
+
var y = s(h);
|
|
2107
|
+
return c !== void 0 ? typeof w == "string" ? y.fill(c, w) : y.fill(c) : y.fill(0), y;
|
|
2108
|
+
}, u.allocUnsafe = function(h) {
|
|
2109
|
+
if (typeof h != "number")
|
|
2110
|
+
throw new TypeError("Argument must be a number");
|
|
2111
|
+
return s(h);
|
|
2112
|
+
}, u.allocUnsafeSlow = function(h) {
|
|
2113
|
+
if (typeof h != "number")
|
|
2114
|
+
throw new TypeError("Argument must be a number");
|
|
2115
|
+
return o.SlowBuffer(h);
|
|
2116
|
+
};
|
|
2117
|
+
})(mt, mt.exports);
|
|
2118
|
+
var Vt = mt.exports, Kt = Vt.Buffer;
|
|
2119
|
+
function at(n, r) {
|
|
2120
|
+
this._block = Kt.alloc(n), this._finalSize = r, this._blockSize = n, this._len = 0;
|
|
2121
|
+
}
|
|
2122
|
+
at.prototype.update = function(n, r) {
|
|
2123
|
+
typeof n == "string" && (r = r || "utf8", n = Kt.from(n, r));
|
|
2124
|
+
for (var o = this._block, s = this._blockSize, f = n.length, u = this._len, h = 0; h < f; ) {
|
|
2125
|
+
for (var c = u % s, w = Math.min(f - h, s - c), y = 0; y < w; y++)
|
|
2126
|
+
o[c + y] = n[h + y];
|
|
2127
|
+
u += w, h += w, u % s === 0 && this._update(o);
|
|
2128
|
+
}
|
|
2129
|
+
return this._len += f, this;
|
|
2130
|
+
};
|
|
2131
|
+
at.prototype.digest = function(n) {
|
|
2132
|
+
var r = this._len % this._blockSize;
|
|
2133
|
+
this._block[r] = 128, this._block.fill(0, r + 1), r >= this._finalSize && (this._update(this._block), this._block.fill(0));
|
|
2134
|
+
var o = this._len * 8;
|
|
2135
|
+
if (o <= 4294967295)
|
|
2136
|
+
this._block.writeUInt32BE(o, this._blockSize - 4);
|
|
2137
|
+
else {
|
|
2138
|
+
var s = (o & 4294967295) >>> 0, f = (o - s) / 4294967296;
|
|
2139
|
+
this._block.writeUInt32BE(f, this._blockSize - 8), this._block.writeUInt32BE(s, this._blockSize - 4);
|
|
2140
|
+
}
|
|
2141
|
+
this._update(this._block);
|
|
2142
|
+
var u = this._hash();
|
|
2143
|
+
return n ? u.toString(n) : u;
|
|
2144
|
+
};
|
|
2145
|
+
at.prototype._update = function() {
|
|
2146
|
+
throw new Error("_update must be implemented by subclass");
|
|
2147
|
+
};
|
|
2148
|
+
var pr = at, dr = ir, Jt = pr, wr = Vt.Buffer, yr = [
|
|
2149
|
+
1518500249,
|
|
2150
|
+
1859775393,
|
|
2151
|
+
-1894007588,
|
|
2152
|
+
-899497514
|
|
2153
|
+
], gr = new Array(80);
|
|
2154
|
+
function rt() {
|
|
2155
|
+
this.init(), this._w = gr, Jt.call(this, 64, 56);
|
|
2156
|
+
}
|
|
2157
|
+
dr(rt, Jt);
|
|
2158
|
+
rt.prototype.init = function() {
|
|
2159
|
+
return this._a = 1732584193, this._b = 4023233417, this._c = 2562383102, this._d = 271733878, this._e = 3285377520, this;
|
|
2160
|
+
};
|
|
2161
|
+
function mr(n) {
|
|
2162
|
+
return n << 1 | n >>> 31;
|
|
2163
|
+
}
|
|
2164
|
+
function br(n) {
|
|
2165
|
+
return n << 5 | n >>> 27;
|
|
2166
|
+
}
|
|
2167
|
+
function xr(n) {
|
|
2168
|
+
return n << 30 | n >>> 2;
|
|
2169
|
+
}
|
|
2170
|
+
function Br(n, r, o, s) {
|
|
2171
|
+
return n === 0 ? r & o | ~r & s : n === 2 ? r & o | r & s | o & s : r ^ o ^ s;
|
|
2172
|
+
}
|
|
2173
|
+
rt.prototype._update = function(n) {
|
|
2174
|
+
for (var r = this._w, o = this._a | 0, s = this._b | 0, f = this._c | 0, u = this._d | 0, h = this._e | 0, c = 0; c < 16; ++c)
|
|
2175
|
+
r[c] = n.readInt32BE(c * 4);
|
|
2176
|
+
for (; c < 80; ++c)
|
|
2177
|
+
r[c] = mr(r[c - 3] ^ r[c - 8] ^ r[c - 14] ^ r[c - 16]);
|
|
2178
|
+
for (var w = 0; w < 80; ++w) {
|
|
2179
|
+
var y = ~~(w / 20), g = br(o) + Br(y, s, f, u) + h + r[w] + yr[y] | 0;
|
|
2180
|
+
h = u, u = f, f = xr(s), s = o, o = g;
|
|
2181
|
+
}
|
|
2182
|
+
this._a = o + this._a | 0, this._b = s + this._b | 0, this._c = f + this._c | 0, this._d = u + this._d | 0, this._e = h + this._e | 0;
|
|
2183
|
+
};
|
|
2184
|
+
rt.prototype._hash = function() {
|
|
2185
|
+
var n = wr.allocUnsafe(20);
|
|
2186
|
+
return n.writeInt32BE(this._a | 0, 0), n.writeInt32BE(this._b | 0, 4), n.writeInt32BE(this._c | 0, 8), n.writeInt32BE(this._d | 0, 12), n.writeInt32BE(this._e | 0, 16), n;
|
|
2187
|
+
};
|
|
2188
|
+
var Er = rt;
|
|
2189
|
+
const Ir = /* @__PURE__ */ nr(Er);
|
|
2190
|
+
function _r(n) {
|
|
2191
|
+
let r = "";
|
|
2192
|
+
for (const o of new Uint8Array(n))
|
|
2193
|
+
o < 16 && (r += "0"), r += o.toString(16);
|
|
2194
|
+
return r;
|
|
2195
|
+
}
|
|
2196
|
+
let dt = null;
|
|
2197
|
+
async function jt(n) {
|
|
2198
|
+
return dt === null && (dt = await Fr()), dt ? Xt(n) : Ar(n);
|
|
2199
|
+
}
|
|
2200
|
+
function Ar(n) {
|
|
2201
|
+
return new Ir().update(n).digest("hex");
|
|
2202
|
+
}
|
|
2203
|
+
async function Xt(n) {
|
|
2204
|
+
const r = await crypto.subtle.digest("SHA-1", n);
|
|
2205
|
+
return _r(r);
|
|
2206
|
+
}
|
|
2207
|
+
async function Fr() {
|
|
2208
|
+
try {
|
|
2209
|
+
if (await Xt(new Uint8Array([])) === "da39a3ee5e6b4b0d3255bfef95601890afd80709")
|
|
2210
|
+
return !0;
|
|
2211
|
+
} catch {
|
|
2212
|
+
}
|
|
2213
|
+
return !1;
|
|
2214
|
+
}
|
|
2215
|
+
function Ur(n) {
|
|
2216
|
+
const r = [];
|
|
2217
|
+
let o = 0, s = 0;
|
|
2218
|
+
do {
|
|
2219
|
+
o = n.readUInt8();
|
|
2220
|
+
const f = o & 127;
|
|
2221
|
+
r.push(f), s = o & 128;
|
|
2222
|
+
} while (s);
|
|
2223
|
+
return r.reduce((f, u) => f + 1 << 7 | u, -1);
|
|
2224
|
+
}
|
|
2225
|
+
function Sr(n, r) {
|
|
2226
|
+
let o = r, s = 4, f = null;
|
|
2227
|
+
do
|
|
2228
|
+
f = n.readUInt8(), o |= (f & 127) << s, s += 7;
|
|
2229
|
+
while (f & 128);
|
|
2230
|
+
return o;
|
|
2231
|
+
}
|
|
2232
|
+
class Q {
|
|
2233
|
+
constructor(r) {
|
|
2234
|
+
Object.assign(this, r), this.offsetCache = {};
|
|
2235
|
+
}
|
|
2236
|
+
static async fromIdx({ idx: r, getExternalRefDelta: o }) {
|
|
2237
|
+
const s = new z(r);
|
|
2238
|
+
if (s.slice(4).toString("hex") !== "ff744f63")
|
|
2239
|
+
return;
|
|
2240
|
+
const u = s.readUInt32BE();
|
|
2241
|
+
if (u !== 2)
|
|
2242
|
+
throw new _(
|
|
2243
|
+
`Unable to read version ${u} packfile IDX. (Only version 2 supported)`
|
|
2244
|
+
);
|
|
2245
|
+
if (r.byteLength > 2048 * 1024 * 1024)
|
|
2246
|
+
throw new _(
|
|
2247
|
+
"To keep implementation simple, I haven't implemented the layer 5 feature needed to support packfiles > 2GB in size."
|
|
2248
|
+
);
|
|
2249
|
+
s.seek(s.tell() + 4 * 255);
|
|
2250
|
+
const h = s.readUInt32BE(), c = [];
|
|
2251
|
+
for (let g = 0; g < h; g++) {
|
|
2252
|
+
const m = s.slice(20).toString("hex");
|
|
2253
|
+
c[g] = m;
|
|
2254
|
+
}
|
|
2255
|
+
s.seek(s.tell() + 4 * h);
|
|
2256
|
+
const w = /* @__PURE__ */ new Map();
|
|
2257
|
+
for (let g = 0; g < h; g++)
|
|
2258
|
+
w.set(c[g], s.readUInt32BE());
|
|
2259
|
+
const y = s.slice(20).toString("hex");
|
|
2260
|
+
return new Q({
|
|
2261
|
+
hashes: c,
|
|
2262
|
+
crcs: {},
|
|
2263
|
+
offsets: w,
|
|
2264
|
+
packfileSha: y,
|
|
2265
|
+
getExternalRefDelta: o
|
|
2266
|
+
});
|
|
2267
|
+
}
|
|
2268
|
+
static async fromPack({ pack: r, getExternalRefDelta: o, onProgress: s }) {
|
|
2269
|
+
const f = {
|
|
2270
|
+
1: "commit",
|
|
2271
|
+
2: "tree",
|
|
2272
|
+
3: "blob",
|
|
2273
|
+
4: "tag",
|
|
2274
|
+
6: "ofs-delta",
|
|
2275
|
+
7: "ref-delta"
|
|
2276
|
+
}, u = {}, h = r.slice(-20).toString("hex"), c = [], w = {}, y = /* @__PURE__ */ new Map();
|
|
2277
|
+
let g = null, m = null;
|
|
2278
|
+
await Ze([r], async ({ data: D, type: U, reference: M, offset: $, num: G }) => {
|
|
2279
|
+
g === null && (g = G);
|
|
2280
|
+
const R = Math.floor(
|
|
2281
|
+
(g - G) * 100 / g
|
|
2282
|
+
);
|
|
2283
|
+
R !== m && s && await s({
|
|
2284
|
+
phase: "Receiving objects",
|
|
2285
|
+
loaded: g - G,
|
|
2286
|
+
total: g
|
|
2287
|
+
}), m = R, U = f[U], ["commit", "tree", "blob", "tag"].includes(U) ? u[$] = {
|
|
2288
|
+
type: U,
|
|
2289
|
+
offset: $
|
|
2290
|
+
} : U === "ofs-delta" ? u[$] = {
|
|
2291
|
+
type: U,
|
|
2292
|
+
offset: $
|
|
2293
|
+
} : U === "ref-delta" && (u[$] = {
|
|
2294
|
+
type: U,
|
|
2295
|
+
offset: $
|
|
2296
|
+
});
|
|
2297
|
+
});
|
|
2298
|
+
const b = Object.keys(u).map(Number);
|
|
2299
|
+
for (const [D, U] of b.entries()) {
|
|
2300
|
+
const M = D + 1 === b.length ? r.byteLength - 20 : b[D + 1], $ = u[U], G = Ae.buf(r.slice(U, M)) >>> 0;
|
|
2301
|
+
$.end = M, $.crc = G;
|
|
2302
|
+
}
|
|
2303
|
+
const B = new Q({
|
|
2304
|
+
pack: Promise.resolve(r),
|
|
2305
|
+
packfileSha: h,
|
|
2306
|
+
crcs: w,
|
|
2307
|
+
hashes: c,
|
|
2308
|
+
offsets: y,
|
|
2309
|
+
getExternalRefDelta: o
|
|
2310
|
+
});
|
|
2311
|
+
m = null;
|
|
2312
|
+
let T = 0;
|
|
2313
|
+
const L = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
|
2314
|
+
for (let D in u) {
|
|
2315
|
+
D = Number(D);
|
|
2316
|
+
const U = Math.floor(T * 100 / g);
|
|
2317
|
+
U !== m && s && await s({
|
|
2318
|
+
phase: "Resolving deltas",
|
|
2319
|
+
loaded: T,
|
|
2320
|
+
total: g
|
|
2321
|
+
}), T++, m = U;
|
|
2322
|
+
const M = u[D];
|
|
2323
|
+
if (!M.oid)
|
|
2324
|
+
try {
|
|
2325
|
+
B.readDepth = 0, B.externalReadDepth = 0;
|
|
2326
|
+
const { type: $, object: G } = await B.readSlice({ start: D });
|
|
2327
|
+
L[B.readDepth] += 1;
|
|
2328
|
+
const R = await jt(Je.wrap({ type: $, object: G }));
|
|
2329
|
+
M.oid = R, c.push(R), y.set(R, D), w[R] = M.crc;
|
|
2330
|
+
} catch {
|
|
2331
|
+
continue;
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
return c.sort(), B;
|
|
2335
|
+
}
|
|
2336
|
+
async toBuffer() {
|
|
2337
|
+
const r = [], o = (y, g) => {
|
|
2338
|
+
r.push(Buffer.from(y, g));
|
|
2339
|
+
};
|
|
2340
|
+
o("ff744f63", "hex"), o("00000002", "hex");
|
|
2341
|
+
const s = new z(Buffer.alloc(256 * 4));
|
|
2342
|
+
for (let y = 0; y < 256; y++) {
|
|
2343
|
+
let g = 0;
|
|
2344
|
+
for (const m of this.hashes)
|
|
2345
|
+
parseInt(m.slice(0, 2), 16) <= y && g++;
|
|
2346
|
+
s.writeUInt32BE(g);
|
|
2347
|
+
}
|
|
2348
|
+
r.push(s.buffer);
|
|
2349
|
+
for (const y of this.hashes)
|
|
2350
|
+
o(y, "hex");
|
|
2351
|
+
const f = new z(Buffer.alloc(this.hashes.length * 4));
|
|
2352
|
+
for (const y of this.hashes)
|
|
2353
|
+
f.writeUInt32BE(this.crcs[y]);
|
|
2354
|
+
r.push(f.buffer);
|
|
2355
|
+
const u = new z(Buffer.alloc(this.hashes.length * 4));
|
|
2356
|
+
for (const y of this.hashes)
|
|
2357
|
+
u.writeUInt32BE(this.offsets.get(y));
|
|
2358
|
+
r.push(u.buffer), o(this.packfileSha, "hex");
|
|
2359
|
+
const h = Buffer.concat(r), c = await jt(h), w = Buffer.alloc(20);
|
|
2360
|
+
return w.write(c, "hex"), Buffer.concat([h, w]);
|
|
2361
|
+
}
|
|
2362
|
+
async load({ pack: r }) {
|
|
2363
|
+
this.pack = r;
|
|
2364
|
+
}
|
|
2365
|
+
async unload() {
|
|
2366
|
+
this.pack = null;
|
|
2367
|
+
}
|
|
2368
|
+
async read({ oid: r }) {
|
|
2369
|
+
if (!this.offsets.get(r)) {
|
|
2370
|
+
if (this.getExternalRefDelta)
|
|
2371
|
+
return this.externalReadDepth++, this.getExternalRefDelta(r);
|
|
2372
|
+
throw new _(`Could not read object ${r} from packfile`);
|
|
2373
|
+
}
|
|
2374
|
+
const o = this.offsets.get(r);
|
|
2375
|
+
return this.readSlice({ start: o });
|
|
2376
|
+
}
|
|
2377
|
+
async readSlice({ start: r }) {
|
|
2378
|
+
if (this.offsetCache[r])
|
|
2379
|
+
return Object.assign({}, this.offsetCache[r]);
|
|
2380
|
+
this.readDepth++;
|
|
2381
|
+
const o = {
|
|
2382
|
+
16: "commit",
|
|
2383
|
+
32: "tree",
|
|
2384
|
+
48: "blob",
|
|
2385
|
+
64: "tag",
|
|
2386
|
+
96: "ofs_delta",
|
|
2387
|
+
112: "ref_delta"
|
|
2388
|
+
};
|
|
2389
|
+
if (!this.pack)
|
|
2390
|
+
throw new _(
|
|
2391
|
+
"Tried to read from a GitPackIndex with no packfile loaded into memory"
|
|
2392
|
+
);
|
|
2393
|
+
const s = (await this.pack).slice(r), f = new z(s), u = f.readUInt8(), h = u & 112;
|
|
2394
|
+
let c = o[h];
|
|
2395
|
+
if (c === void 0)
|
|
2396
|
+
throw new _("Unrecognized type: 0b" + h.toString(2));
|
|
2397
|
+
const w = u & 15;
|
|
2398
|
+
let y = w;
|
|
2399
|
+
u & 128 && (y = Sr(f, w));
|
|
2400
|
+
let m = null, b = null;
|
|
2401
|
+
if (c === "ofs_delta") {
|
|
2402
|
+
const T = Ur(f), L = r - T;
|
|
2403
|
+
({ object: m, type: c } = await this.readSlice({ start: L }));
|
|
2404
|
+
}
|
|
2405
|
+
if (c === "ref_delta") {
|
|
2406
|
+
const T = f.slice(20).toString("hex");
|
|
2407
|
+
({ object: m, type: c } = await this.read({ oid: T }));
|
|
2408
|
+
}
|
|
2409
|
+
const B = s.slice(f.tell());
|
|
2410
|
+
if (b = Buffer.from(await er(B)), b.byteLength !== y)
|
|
2411
|
+
throw new _(
|
|
2412
|
+
`Packfile told us object would have length ${y} but it had length ${b.byteLength}`
|
|
2413
|
+
);
|
|
2414
|
+
return m && (b = Buffer.from(Xe(b, m))), this.readDepth > 3 && (this.offsetCache[r] = { type: c, object: b }), { type: c, format: "content", object: b };
|
|
2415
|
+
}
|
|
2416
|
+
}
|
|
2417
|
+
class tt extends J {
|
|
2418
|
+
/**
|
|
2419
|
+
* @param {string} value
|
|
2420
|
+
*/
|
|
2421
|
+
constructor(r) {
|
|
2422
|
+
super(`Expected a 40-char hex object id but saw "${r}".`), this.code = this.name = tt.code, this.data = { value: r };
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
tt.code = "InvalidOidError";
|
|
2426
|
+
class ct extends J {
|
|
2427
|
+
/**
|
|
2428
|
+
* @param {string} oid
|
|
2429
|
+
* @param {'blob'|'commit'|'tag'|'tree'} actual
|
|
2430
|
+
* @param {'blob'|'commit'|'tag'|'tree'} expected
|
|
2431
|
+
* @param {string} [filepath]
|
|
2432
|
+
*/
|
|
2433
|
+
constructor(r, o, s, f) {
|
|
2434
|
+
super(
|
|
2435
|
+
`Object ${r} ${f ? `at ${f}` : ""}was anticipated to be a ${s} but it is a ${o}.`
|
|
2436
|
+
), this.code = this.name = ct.code, this.data = { oid: r, actual: o, expected: s, filepath: f };
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
ct.code = "ObjectTypeError";
|
|
2440
|
+
async function Zt(n, r) {
|
|
2441
|
+
const o = qt(n);
|
|
2442
|
+
for (; ; ) {
|
|
2443
|
+
const { value: s, done: f } = await o.next();
|
|
2444
|
+
if (s && await r(s), f)
|
|
2445
|
+
break;
|
|
2446
|
+
}
|
|
2447
|
+
o.return && o.return();
|
|
2448
|
+
}
|
|
2449
|
+
async function et(n) {
|
|
2450
|
+
let r = 0;
|
|
2451
|
+
const o = [];
|
|
2452
|
+
await Zt(n, (u) => {
|
|
2453
|
+
o.push(u), r += u.byteLength;
|
|
2454
|
+
});
|
|
2455
|
+
const s = new Uint8Array(r);
|
|
2456
|
+
let f = 0;
|
|
2457
|
+
for (const u of o)
|
|
2458
|
+
s.set(u, f), f += u.byteLength;
|
|
2459
|
+
return s;
|
|
2460
|
+
}
|
|
2461
|
+
class wt {
|
|
2462
|
+
constructor() {
|
|
2463
|
+
this._queue = [];
|
|
2464
|
+
}
|
|
2465
|
+
write(r) {
|
|
2466
|
+
if (this._ended)
|
|
2467
|
+
throw Error("You cannot write to a FIFO that has already been ended!");
|
|
2468
|
+
if (this._waiting) {
|
|
2469
|
+
const o = this._waiting;
|
|
2470
|
+
this._waiting = null, o({ value: r });
|
|
2471
|
+
} else
|
|
2472
|
+
this._queue.push(r);
|
|
2473
|
+
}
|
|
2474
|
+
end() {
|
|
2475
|
+
if (this._ended = !0, this._waiting) {
|
|
2476
|
+
const r = this._waiting;
|
|
2477
|
+
this._waiting = null, r({ done: !0 });
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
destroy(r) {
|
|
2481
|
+
this.error = r, this.end();
|
|
2482
|
+
}
|
|
2483
|
+
async next() {
|
|
2484
|
+
if (this._queue.length > 0)
|
|
2485
|
+
return { value: this._queue.shift() };
|
|
2486
|
+
if (this._ended)
|
|
2487
|
+
return { done: !0 };
|
|
2488
|
+
if (this._waiting)
|
|
2489
|
+
throw Error(
|
|
2490
|
+
"You cannot call read until the previous call to read has returned!"
|
|
2491
|
+
);
|
|
2492
|
+
return new Promise((r) => {
|
|
2493
|
+
this._waiting = r;
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2497
|
+
class kr {
|
|
2498
|
+
static demux(r) {
|
|
2499
|
+
const o = k.streamReader(r), s = new wt(), f = new wt(), u = new wt(), h = async function() {
|
|
2500
|
+
const c = await o();
|
|
2501
|
+
if (c === null)
|
|
2502
|
+
return h();
|
|
2503
|
+
if (c === !0) {
|
|
2504
|
+
s.end(), u.end(), r.error ? f.destroy(r.error) : f.end();
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
switch (c[0]) {
|
|
2508
|
+
case 1: {
|
|
2509
|
+
f.write(c.slice(1));
|
|
2510
|
+
break;
|
|
2511
|
+
}
|
|
2512
|
+
case 2: {
|
|
2513
|
+
u.write(c.slice(1));
|
|
2514
|
+
break;
|
|
2515
|
+
}
|
|
2516
|
+
case 3: {
|
|
2517
|
+
const w = c.slice(1);
|
|
2518
|
+
u.write(w), s.end(), u.end(), f.destroy(new Error(w.toString("utf8")));
|
|
2519
|
+
return;
|
|
2520
|
+
}
|
|
2521
|
+
default:
|
|
2522
|
+
s.write(c);
|
|
2523
|
+
}
|
|
2524
|
+
h();
|
|
2525
|
+
};
|
|
2526
|
+
return h(), {
|
|
2527
|
+
packetlines: s,
|
|
2528
|
+
packfile: f,
|
|
2529
|
+
progress: u
|
|
2530
|
+
};
|
|
2531
|
+
}
|
|
2532
|
+
// static mux ({
|
|
2533
|
+
// protocol, // 'side-band' or 'side-band-64k'
|
|
2534
|
+
// packetlines,
|
|
2535
|
+
// packfile,
|
|
2536
|
+
// progress,
|
|
2537
|
+
// error
|
|
2538
|
+
// }) {
|
|
2539
|
+
// const MAX_PACKET_LENGTH = protocol === 'side-band-64k' ? 999 : 65519
|
|
2540
|
+
// let output = new PassThrough()
|
|
2541
|
+
// packetlines.on('data', data => {
|
|
2542
|
+
// if (data === null) {
|
|
2543
|
+
// output.write(GitPktLine.flush())
|
|
2544
|
+
// } else {
|
|
2545
|
+
// output.write(GitPktLine.encode(data))
|
|
2546
|
+
// }
|
|
2547
|
+
// })
|
|
2548
|
+
// let packfileWasEmpty = true
|
|
2549
|
+
// let packfileEnded = false
|
|
2550
|
+
// let progressEnded = false
|
|
2551
|
+
// let errorEnded = false
|
|
2552
|
+
// let goodbye = Buffer.concat([
|
|
2553
|
+
// GitPktLine.encode(Buffer.from('010A', 'hex')),
|
|
2554
|
+
// GitPktLine.flush()
|
|
2555
|
+
// ])
|
|
2556
|
+
// packfile
|
|
2557
|
+
// .on('data', data => {
|
|
2558
|
+
// packfileWasEmpty = false
|
|
2559
|
+
// const buffers = splitBuffer(data, MAX_PACKET_LENGTH)
|
|
2560
|
+
// for (const buffer of buffers) {
|
|
2561
|
+
// output.write(
|
|
2562
|
+
// GitPktLine.encode(Buffer.concat([Buffer.from('01', 'hex'), buffer]))
|
|
2563
|
+
// )
|
|
2564
|
+
// }
|
|
2565
|
+
// })
|
|
2566
|
+
// .on('end', () => {
|
|
2567
|
+
// packfileEnded = true
|
|
2568
|
+
// if (!packfileWasEmpty) output.write(goodbye)
|
|
2569
|
+
// if (progressEnded && errorEnded) output.end()
|
|
2570
|
+
// })
|
|
2571
|
+
// progress
|
|
2572
|
+
// .on('data', data => {
|
|
2573
|
+
// const buffers = splitBuffer(data, MAX_PACKET_LENGTH)
|
|
2574
|
+
// for (const buffer of buffers) {
|
|
2575
|
+
// output.write(
|
|
2576
|
+
// GitPktLine.encode(Buffer.concat([Buffer.from('02', 'hex'), buffer]))
|
|
2577
|
+
// )
|
|
2578
|
+
// }
|
|
2579
|
+
// })
|
|
2580
|
+
// .on('end', () => {
|
|
2581
|
+
// progressEnded = true
|
|
2582
|
+
// if (packfileEnded && errorEnded) output.end()
|
|
2583
|
+
// })
|
|
2584
|
+
// error
|
|
2585
|
+
// .on('data', data => {
|
|
2586
|
+
// const buffers = splitBuffer(data, MAX_PACKET_LENGTH)
|
|
2587
|
+
// for (const buffer of buffers) {
|
|
2588
|
+
// output.write(
|
|
2589
|
+
// GitPktLine.encode(Buffer.concat([Buffer.from('03', 'hex'), buffer]))
|
|
2590
|
+
// )
|
|
2591
|
+
// }
|
|
2592
|
+
// })
|
|
2593
|
+
// .on('end', () => {
|
|
2594
|
+
// errorEnded = true
|
|
2595
|
+
// if (progressEnded && packfileEnded) output.end()
|
|
2596
|
+
// })
|
|
2597
|
+
// return output
|
|
2598
|
+
// }
|
|
2599
|
+
}
|
|
2600
|
+
async function Qt(n) {
|
|
2601
|
+
const { packetlines: r, packfile: o, progress: s } = kr.demux(n), f = [], u = [], h = [];
|
|
2602
|
+
let c = !1, w = !1;
|
|
2603
|
+
return new Promise((y, g) => {
|
|
2604
|
+
Zt(r, (m) => {
|
|
2605
|
+
const b = m.toString("utf8").trim();
|
|
2606
|
+
if (b.startsWith("shallow")) {
|
|
2607
|
+
const B = b.slice(-41).trim();
|
|
2608
|
+
B.length !== 40 && g(new tt(B)), f.push(B);
|
|
2609
|
+
} else if (b.startsWith("unshallow")) {
|
|
2610
|
+
const B = b.slice(-41).trim();
|
|
2611
|
+
B.length !== 40 && g(new tt(B)), u.push(B);
|
|
2612
|
+
} else if (b.startsWith("ACK")) {
|
|
2613
|
+
const [, B, T] = b.split(" ");
|
|
2614
|
+
h.push({ oid: B, status: T }), T || (w = !0);
|
|
2615
|
+
} else
|
|
2616
|
+
b.startsWith("NAK") ? (c = !0, w = !0) : (w = !0, c = !0);
|
|
2617
|
+
w && (n.error ? g(n.error) : y({ shallows: f, unshallows: u, acks: h, nak: c, packfile: o, progress: s }));
|
|
2618
|
+
}).finally(() => {
|
|
2619
|
+
w || (n.error ? g(n.error) : y({ shallows: f, unshallows: u, acks: h, nak: c, packfile: o, progress: s }));
|
|
2620
|
+
});
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
typeof window < "u" && (window.Buffer = q.Buffer);
|
|
2624
|
+
async function Xr(n, r, o) {
|
|
2625
|
+
const f = (await ee(n, r))[r], u = await re(n, f), h = await $r(u, f, o), c = await Rr(
|
|
2626
|
+
n,
|
|
2627
|
+
o.map((y) => h[y].oid)
|
|
2628
|
+
), w = {};
|
|
2629
|
+
return await Promise.all(
|
|
2630
|
+
o.map(async (y) => {
|
|
2631
|
+
w[y] = await ne(
|
|
2632
|
+
c,
|
|
2633
|
+
h[y].oid
|
|
2634
|
+
);
|
|
2635
|
+
})
|
|
2636
|
+
), w;
|
|
2637
|
+
}
|
|
2638
|
+
async function Zr(n, r) {
|
|
2639
|
+
const o = await ee(n, r);
|
|
2640
|
+
if (!(r in o))
|
|
2641
|
+
throw new Error(`Branch ${r} not found`);
|
|
2642
|
+
const s = o[r], f = await re(n, s), u = await Tr(f, s);
|
|
2643
|
+
return u != null && u.object ? te(u) : [];
|
|
2644
|
+
}
|
|
2645
|
+
function te(n) {
|
|
2646
|
+
return n.object.map((r) => {
|
|
2647
|
+
if (r.type === "blob")
|
|
2648
|
+
return {
|
|
2649
|
+
name: r.path,
|
|
2650
|
+
type: "file"
|
|
2651
|
+
};
|
|
2652
|
+
if (r.type === "tree" && r.object)
|
|
2653
|
+
return {
|
|
2654
|
+
name: r.path,
|
|
2655
|
+
type: "folder",
|
|
2656
|
+
children: te(r)
|
|
2657
|
+
};
|
|
2658
|
+
}).filter((r) => !!(r != null && r.name));
|
|
2659
|
+
}
|
|
2660
|
+
async function ee(n, r) {
|
|
2661
|
+
const o = q.Buffer.from(
|
|
2662
|
+
await et([
|
|
2663
|
+
k.encode(`command=ls-refs
|
|
2664
|
+
`),
|
|
2665
|
+
k.encode(`agent=git/2.37.3
|
|
2666
|
+
`),
|
|
2667
|
+
k.encode(`object-format=sha1
|
|
2668
|
+
`),
|
|
2669
|
+
k.delim(),
|
|
2670
|
+
k.encode(`peel
|
|
2671
|
+
`),
|
|
2672
|
+
k.encode(`ref-prefix ${r}
|
|
2673
|
+
`),
|
|
2674
|
+
k.flush()
|
|
2675
|
+
])
|
|
2676
|
+
), s = await fetch(n + "/git-upload-pack", {
|
|
2677
|
+
method: "POST",
|
|
2678
|
+
headers: {
|
|
2679
|
+
Accept: "application/x-git-upload-pack-advertisement",
|
|
2680
|
+
"content-type": "application/x-git-upload-pack-request",
|
|
2681
|
+
"Content-Length": `${o.length}`,
|
|
2682
|
+
"Git-Protocol": "version=2"
|
|
2683
|
+
},
|
|
2684
|
+
body: o
|
|
2685
|
+
}), f = {};
|
|
2686
|
+
for await (const u of Cr(s)) {
|
|
2687
|
+
const h = u.indexOf(" "), c = u.slice(0, h), w = u.slice(h + 1, u.length - 1);
|
|
2688
|
+
f[w] = c;
|
|
2689
|
+
}
|
|
2690
|
+
return f;
|
|
2691
|
+
}
|
|
2692
|
+
async function re(n, r) {
|
|
2693
|
+
const o = q.Buffer.from(
|
|
2694
|
+
await et([
|
|
2695
|
+
k.encode(
|
|
2696
|
+
`want ${r} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3 filter
|
|
2697
|
+
`
|
|
2698
|
+
),
|
|
2699
|
+
k.encode(`filter blob:none
|
|
2700
|
+
`),
|
|
2701
|
+
k.encode(`shallow ${r}
|
|
2702
|
+
`),
|
|
2703
|
+
k.encode(`deepen 1
|
|
2704
|
+
`),
|
|
2705
|
+
k.flush(),
|
|
2706
|
+
k.encode(`done
|
|
2707
|
+
`),
|
|
2708
|
+
k.encode(`done
|
|
2709
|
+
`)
|
|
2710
|
+
])
|
|
2711
|
+
), s = await fetch(n + "/git-upload-pack", {
|
|
2712
|
+
method: "POST",
|
|
2713
|
+
headers: {
|
|
2714
|
+
Accept: "application/x-git-upload-pack-advertisement",
|
|
2715
|
+
"content-type": "application/x-git-upload-pack-request",
|
|
2716
|
+
"Content-Length": `${o.length}`
|
|
2717
|
+
},
|
|
2718
|
+
body: o
|
|
2719
|
+
}), f = ie(s.body), u = await Qt(f), h = q.Buffer.from(await et(u.packfile)), c = await Q.fromPack({
|
|
2720
|
+
pack: h
|
|
2721
|
+
}), w = c.read;
|
|
2722
|
+
return c.read = async function({ oid: y, ...g }) {
|
|
2723
|
+
const m = await w.call(this, { oid: y, ...g });
|
|
2724
|
+
return m.oid = y, m;
|
|
2725
|
+
}, c;
|
|
2726
|
+
}
|
|
2727
|
+
async function Tr(n, r) {
|
|
2728
|
+
const o = await n.read({
|
|
2729
|
+
oid: r
|
|
2730
|
+
});
|
|
2731
|
+
W(o);
|
|
2732
|
+
const s = await n.read({ oid: o.object.tree }), f = [s];
|
|
2733
|
+
for (; f.length > 0; ) {
|
|
2734
|
+
const u = f.pop(), h = await n.read({ oid: u.oid });
|
|
2735
|
+
if (W(h), u.object = h.object, h.type === "tree")
|
|
2736
|
+
for (const c of h.object)
|
|
2737
|
+
c.type === "tree" && f.push(c);
|
|
2738
|
+
}
|
|
2739
|
+
return s;
|
|
2740
|
+
}
|
|
2741
|
+
async function $r(n, r, o) {
|
|
2742
|
+
const s = await n.read({
|
|
2743
|
+
oid: r
|
|
2744
|
+
});
|
|
2745
|
+
W(s);
|
|
2746
|
+
const f = await n.read({ oid: s.object.tree });
|
|
2747
|
+
W(f);
|
|
2748
|
+
const u = {};
|
|
2749
|
+
for (const h of o) {
|
|
2750
|
+
let c = f;
|
|
2751
|
+
const w = h.split("/");
|
|
2752
|
+
for (const y of w) {
|
|
2753
|
+
if (c.type !== "tree")
|
|
2754
|
+
throw new Error(`Path not found in the repo: ${h}`);
|
|
2755
|
+
let g = !1;
|
|
2756
|
+
for (const m of c.object)
|
|
2757
|
+
if (m.path === y) {
|
|
2758
|
+
try {
|
|
2759
|
+
c = await n.read({ oid: m.oid }), W(c);
|
|
2760
|
+
} catch {
|
|
2761
|
+
c = m;
|
|
2762
|
+
}
|
|
2763
|
+
g = !0;
|
|
2764
|
+
break;
|
|
2765
|
+
}
|
|
2766
|
+
if (!g)
|
|
2767
|
+
throw new Error(`Path not found in the repo: ${h}`);
|
|
2768
|
+
}
|
|
2769
|
+
u[h] = c;
|
|
2770
|
+
}
|
|
2771
|
+
return u;
|
|
2772
|
+
}
|
|
2773
|
+
async function Rr(n, r) {
|
|
2774
|
+
const o = q.Buffer.from(
|
|
2775
|
+
await et([
|
|
2776
|
+
...r.map(
|
|
2777
|
+
(c) => k.encode(
|
|
2778
|
+
`want ${c} multi_ack_detailed no-done side-band-64k thin-pack ofs-delta agent=git/2.37.3
|
|
2779
|
+
`
|
|
2780
|
+
)
|
|
2781
|
+
),
|
|
2782
|
+
k.flush(),
|
|
2783
|
+
k.encode(`done
|
|
2784
|
+
`)
|
|
2785
|
+
])
|
|
2786
|
+
), s = await fetch(n + "/git-upload-pack", {
|
|
2787
|
+
method: "POST",
|
|
2788
|
+
headers: {
|
|
2789
|
+
Accept: "application/x-git-upload-pack-advertisement",
|
|
2790
|
+
"content-type": "application/x-git-upload-pack-request",
|
|
2791
|
+
"Content-Length": `${o.length}`
|
|
2792
|
+
},
|
|
2793
|
+
body: o
|
|
2794
|
+
}), f = ie(s.body), u = await Qt(f), h = q.Buffer.from(await et(u.packfile));
|
|
2795
|
+
return await Q.fromPack({
|
|
2796
|
+
pack: h
|
|
2797
|
+
});
|
|
2798
|
+
}
|
|
2799
|
+
async function ne(n, r) {
|
|
2800
|
+
const o = await n.read({ oid: r });
|
|
2801
|
+
if (W(o), o.type === "blob")
|
|
2802
|
+
return o.object;
|
|
2803
|
+
const s = {};
|
|
2804
|
+
for (const { path: f, oid: u, type: h } of o.object)
|
|
2805
|
+
if (h === "blob") {
|
|
2806
|
+
const c = await n.read({ oid: u });
|
|
2807
|
+
W(c), s[f] = c.object;
|
|
2808
|
+
} else
|
|
2809
|
+
h === "tree" && (s[f] = await ne(n, u));
|
|
2810
|
+
return s;
|
|
2811
|
+
}
|
|
2812
|
+
function W(n) {
|
|
2813
|
+
if (n.object instanceof q.Buffer)
|
|
2814
|
+
switch (n.type) {
|
|
2815
|
+
case "commit":
|
|
2816
|
+
n.object = O.from(n.object).parse();
|
|
2817
|
+
break;
|
|
2818
|
+
case "tree":
|
|
2819
|
+
n.object = bt.from(n.object).entries();
|
|
2820
|
+
break;
|
|
2821
|
+
case "blob":
|
|
2822
|
+
n.object = new Uint8Array(n.object), n.format = "content";
|
|
2823
|
+
break;
|
|
2824
|
+
case "tag":
|
|
2825
|
+
n.object = Z.from(n.object).parse();
|
|
2826
|
+
break;
|
|
2827
|
+
default:
|
|
2828
|
+
throw new ct(
|
|
2829
|
+
n.oid,
|
|
2830
|
+
n.type,
|
|
2831
|
+
"blob|commit|tag|tree"
|
|
2832
|
+
);
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
async function* Cr(n) {
|
|
2836
|
+
const r = await n.text();
|
|
2837
|
+
let o = 0;
|
|
2838
|
+
for (; o <= r.length; ) {
|
|
2839
|
+
const s = parseInt(r.substring(o, o + 4), 16);
|
|
2840
|
+
if (s === 0)
|
|
2841
|
+
break;
|
|
2842
|
+
yield r.substring(o + 4, o + s), o += s;
|
|
2843
|
+
}
|
|
2844
|
+
}
|
|
2845
|
+
function ie(n) {
|
|
2846
|
+
if (n[Symbol.asyncIterator])
|
|
2847
|
+
return n;
|
|
2848
|
+
const r = n.getReader();
|
|
2849
|
+
return {
|
|
2850
|
+
next() {
|
|
2851
|
+
return r.read();
|
|
2852
|
+
},
|
|
2853
|
+
return() {
|
|
2854
|
+
return r.releaseLock(), {};
|
|
2855
|
+
},
|
|
2856
|
+
[Symbol.asyncIterator]() {
|
|
2857
|
+
return this;
|
|
2858
|
+
}
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
function Qr(n, r) {
|
|
2862
|
+
r = Mt(r);
|
|
2863
|
+
const o = ["", ".", "/"].includes(r);
|
|
2864
|
+
let s = n;
|
|
2865
|
+
if (o)
|
|
2866
|
+
r = "";
|
|
2867
|
+
else {
|
|
2868
|
+
const h = r.split("/");
|
|
2869
|
+
for (const c of h) {
|
|
2870
|
+
const w = s == null ? void 0 : s.find(
|
|
2871
|
+
(y) => y.name === c
|
|
2872
|
+
);
|
|
2873
|
+
if ((w == null ? void 0 : w.type) === "folder")
|
|
2874
|
+
s = w.children;
|
|
2875
|
+
else
|
|
2876
|
+
return w ? [w.name] : [];
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
const f = [], u = [{ tree: s, path: r }];
|
|
2880
|
+
for (; u.length > 0; ) {
|
|
2881
|
+
const { tree: h, path: c } = u.pop();
|
|
2882
|
+
for (const w of h) {
|
|
2883
|
+
const y = `${c}${c ? "/" : ""}${w.name}`;
|
|
2884
|
+
w.type === "folder" ? u.push({
|
|
2885
|
+
tree: w.children,
|
|
2886
|
+
path: y
|
|
2887
|
+
}) : f.push(y);
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
return f;
|
|
2891
|
+
}
|
|
316
2892
|
export {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
2893
|
+
Yr as changeset,
|
|
2894
|
+
Kr as clearContentsFromMountDevice,
|
|
2895
|
+
jr as createClient,
|
|
2896
|
+
vr as createCommit,
|
|
2897
|
+
Hr as createOrUpdateBranch,
|
|
2898
|
+
zr as createTree,
|
|
2899
|
+
Ct as createTreeNode,
|
|
2900
|
+
Te as createTreeNodes,
|
|
2901
|
+
$e as deleteFile,
|
|
2902
|
+
Oe as directoryHandleFromMountDevice,
|
|
2903
|
+
Vr as directoryHandleToOpfsPath,
|
|
2904
|
+
Lr as filesListToObject,
|
|
2905
|
+
qr as fork,
|
|
2906
|
+
Mr as getArtifact,
|
|
2907
|
+
Fe as getFilesFromDirectory,
|
|
2908
|
+
Wr as iterateFiles,
|
|
2909
|
+
Qr as listDescendantFiles,
|
|
2910
|
+
Zr as listGitFiles,
|
|
2911
|
+
ee as listGitRefs,
|
|
2912
|
+
Gr as mayPush,
|
|
2913
|
+
Pe as opfsPathToDirectoryHandle,
|
|
2914
|
+
Xr as sparseCheckout
|
|
335
2915
|
};
|