resourcexjs 2.1.1 → 2.3.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/dist/arp.d.ts +4 -2
- package/dist/arp.js +2166 -402
- package/dist/arp.js.map +5 -5
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2404 -447
- package/dist/index.js.map +7 -7
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1134,9 +1134,81 @@ async function unpackTar(archive, options = {}) {
|
|
|
1134
1134
|
var gzipAsync = promisify(gzip);
|
|
1135
1135
|
var gunzipAsync = promisify(gunzip);
|
|
1136
1136
|
|
|
1137
|
-
class
|
|
1137
|
+
class RXPImpl {
|
|
1138
|
+
_files;
|
|
1139
|
+
_pathsCache = null;
|
|
1140
|
+
_treeCache = null;
|
|
1141
|
+
constructor(files) {
|
|
1142
|
+
this._files = files;
|
|
1143
|
+
}
|
|
1144
|
+
paths() {
|
|
1145
|
+
if (this._pathsCache) {
|
|
1146
|
+
return this._pathsCache;
|
|
1147
|
+
}
|
|
1148
|
+
this._pathsCache = Array.from(this._files.keys()).sort();
|
|
1149
|
+
return this._pathsCache;
|
|
1150
|
+
}
|
|
1151
|
+
tree() {
|
|
1152
|
+
if (this._treeCache) {
|
|
1153
|
+
return this._treeCache;
|
|
1154
|
+
}
|
|
1155
|
+
const root = new Map;
|
|
1156
|
+
for (const path of this._files.keys()) {
|
|
1157
|
+
const parts = path.split("/");
|
|
1158
|
+
let currentLevel = root;
|
|
1159
|
+
for (let i = 0;i < parts.length; i++) {
|
|
1160
|
+
const part = parts[i];
|
|
1161
|
+
const isFile = i === parts.length - 1;
|
|
1162
|
+
if (!currentLevel.has(part)) {
|
|
1163
|
+
const treeNode2 = {
|
|
1164
|
+
node: {
|
|
1165
|
+
name: part,
|
|
1166
|
+
type: isFile ? "file" : "directory",
|
|
1167
|
+
children: isFile ? undefined : []
|
|
1168
|
+
},
|
|
1169
|
+
children: new Map
|
|
1170
|
+
};
|
|
1171
|
+
currentLevel.set(part, treeNode2);
|
|
1172
|
+
}
|
|
1173
|
+
const treeNode = currentLevel.get(part);
|
|
1174
|
+
if (!isFile) {
|
|
1175
|
+
currentLevel = treeNode.children;
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
const convertToPathNodes = (level) => {
|
|
1180
|
+
return Array.from(level.values()).map((treeNode) => {
|
|
1181
|
+
if (treeNode.node.type === "directory" && treeNode.children.size > 0) {
|
|
1182
|
+
treeNode.node.children = convertToPathNodes(treeNode.children);
|
|
1183
|
+
}
|
|
1184
|
+
return treeNode.node;
|
|
1185
|
+
});
|
|
1186
|
+
};
|
|
1187
|
+
this._treeCache = convertToPathNodes(root);
|
|
1188
|
+
return this._treeCache;
|
|
1189
|
+
}
|
|
1190
|
+
async file(path) {
|
|
1191
|
+
const content = this._files.get(path);
|
|
1192
|
+
if (!content) {
|
|
1193
|
+
throw new ContentError(`file not found: ${path}`);
|
|
1194
|
+
}
|
|
1195
|
+
return content;
|
|
1196
|
+
}
|
|
1197
|
+
async files() {
|
|
1198
|
+
return new Map(this._files);
|
|
1199
|
+
}
|
|
1200
|
+
async pack() {
|
|
1201
|
+
const filesRecord = {};
|
|
1202
|
+
for (const [path, content] of this._files) {
|
|
1203
|
+
filesRecord[path] = content;
|
|
1204
|
+
}
|
|
1205
|
+
return createRXA(filesRecord);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
class RXAImpl {
|
|
1138
1210
|
_buffer;
|
|
1139
|
-
|
|
1211
|
+
_rxpCache = null;
|
|
1140
1212
|
constructor(buffer) {
|
|
1141
1213
|
this._buffer = buffer;
|
|
1142
1214
|
}
|
|
@@ -1152,17 +1224,9 @@ class RXCImpl {
|
|
|
1152
1224
|
async buffer() {
|
|
1153
1225
|
return this._buffer;
|
|
1154
1226
|
}
|
|
1155
|
-
async
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
if (!content) {
|
|
1159
|
-
throw new ContentError(`file not found: ${path}`);
|
|
1160
|
-
}
|
|
1161
|
-
return content;
|
|
1162
|
-
}
|
|
1163
|
-
async files() {
|
|
1164
|
-
if (this._filesCache) {
|
|
1165
|
-
return this._filesCache;
|
|
1227
|
+
async extract() {
|
|
1228
|
+
if (this._rxpCache) {
|
|
1229
|
+
return this._rxpCache;
|
|
1166
1230
|
}
|
|
1167
1231
|
const tarBuffer = await gunzipAsync(this._buffer);
|
|
1168
1232
|
const entries = await unpackTar(tarBuffer);
|
|
@@ -1172,16 +1236,16 @@ class RXCImpl {
|
|
|
1172
1236
|
filesMap.set(entry.header.name, Buffer.from(entry.data));
|
|
1173
1237
|
}
|
|
1174
1238
|
}
|
|
1175
|
-
this.
|
|
1176
|
-
return
|
|
1239
|
+
this._rxpCache = new RXPImpl(filesMap);
|
|
1240
|
+
return this._rxpCache;
|
|
1177
1241
|
}
|
|
1178
1242
|
}
|
|
1179
|
-
function
|
|
1180
|
-
return "
|
|
1243
|
+
function isBufferInput(input) {
|
|
1244
|
+
return "buffer" in input && Buffer.isBuffer(input.buffer);
|
|
1181
1245
|
}
|
|
1182
|
-
async function
|
|
1183
|
-
if (
|
|
1184
|
-
return new
|
|
1246
|
+
async function createRXA(input) {
|
|
1247
|
+
if (isBufferInput(input)) {
|
|
1248
|
+
return new RXAImpl(input.buffer);
|
|
1185
1249
|
}
|
|
1186
1250
|
const entries = Object.entries(input).map(([name, content]) => {
|
|
1187
1251
|
const body = typeof content === "string" ? content : content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
@@ -1193,7 +1257,7 @@ async function createRXC(input) {
|
|
|
1193
1257
|
});
|
|
1194
1258
|
const tarBuffer = await packTar(entries);
|
|
1195
1259
|
const gzipBuffer = await gzipAsync(Buffer.from(tarBuffer));
|
|
1196
|
-
return new
|
|
1260
|
+
return new RXAImpl(gzipBuffer);
|
|
1197
1261
|
}
|
|
1198
1262
|
// ../type/dist/index.js
|
|
1199
1263
|
import { gzip as gzip2, gunzip as gunzip2 } from "node:zlib";
|
|
@@ -2257,9 +2321,81 @@ async function unpackTar2(archive, options = {}) {
|
|
|
2257
2321
|
var gzipAsync2 = promisify2(gzip2);
|
|
2258
2322
|
var gunzipAsync2 = promisify2(gunzip2);
|
|
2259
2323
|
|
|
2260
|
-
class
|
|
2324
|
+
class RXPImpl2 {
|
|
2325
|
+
_files;
|
|
2326
|
+
_pathsCache = null;
|
|
2327
|
+
_treeCache = null;
|
|
2328
|
+
constructor(files) {
|
|
2329
|
+
this._files = files;
|
|
2330
|
+
}
|
|
2331
|
+
paths() {
|
|
2332
|
+
if (this._pathsCache) {
|
|
2333
|
+
return this._pathsCache;
|
|
2334
|
+
}
|
|
2335
|
+
this._pathsCache = Array.from(this._files.keys()).sort();
|
|
2336
|
+
return this._pathsCache;
|
|
2337
|
+
}
|
|
2338
|
+
tree() {
|
|
2339
|
+
if (this._treeCache) {
|
|
2340
|
+
return this._treeCache;
|
|
2341
|
+
}
|
|
2342
|
+
const root = new Map;
|
|
2343
|
+
for (const path of this._files.keys()) {
|
|
2344
|
+
const parts = path.split("/");
|
|
2345
|
+
let currentLevel = root;
|
|
2346
|
+
for (let i = 0;i < parts.length; i++) {
|
|
2347
|
+
const part = parts[i];
|
|
2348
|
+
const isFile = i === parts.length - 1;
|
|
2349
|
+
if (!currentLevel.has(part)) {
|
|
2350
|
+
const treeNode2 = {
|
|
2351
|
+
node: {
|
|
2352
|
+
name: part,
|
|
2353
|
+
type: isFile ? "file" : "directory",
|
|
2354
|
+
children: isFile ? undefined : []
|
|
2355
|
+
},
|
|
2356
|
+
children: new Map
|
|
2357
|
+
};
|
|
2358
|
+
currentLevel.set(part, treeNode2);
|
|
2359
|
+
}
|
|
2360
|
+
const treeNode = currentLevel.get(part);
|
|
2361
|
+
if (!isFile) {
|
|
2362
|
+
currentLevel = treeNode.children;
|
|
2363
|
+
}
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
const convertToPathNodes = (level) => {
|
|
2367
|
+
return Array.from(level.values()).map((treeNode) => {
|
|
2368
|
+
if (treeNode.node.type === "directory" && treeNode.children.size > 0) {
|
|
2369
|
+
treeNode.node.children = convertToPathNodes(treeNode.children);
|
|
2370
|
+
}
|
|
2371
|
+
return treeNode.node;
|
|
2372
|
+
});
|
|
2373
|
+
};
|
|
2374
|
+
this._treeCache = convertToPathNodes(root);
|
|
2375
|
+
return this._treeCache;
|
|
2376
|
+
}
|
|
2377
|
+
async file(path) {
|
|
2378
|
+
const content = this._files.get(path);
|
|
2379
|
+
if (!content) {
|
|
2380
|
+
throw new ContentError2(`file not found: ${path}`);
|
|
2381
|
+
}
|
|
2382
|
+
return content;
|
|
2383
|
+
}
|
|
2384
|
+
async files() {
|
|
2385
|
+
return new Map(this._files);
|
|
2386
|
+
}
|
|
2387
|
+
async pack() {
|
|
2388
|
+
const filesRecord = {};
|
|
2389
|
+
for (const [path, content] of this._files) {
|
|
2390
|
+
filesRecord[path] = content;
|
|
2391
|
+
}
|
|
2392
|
+
return createRXA2(filesRecord);
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
class RXAImpl2 {
|
|
2261
2397
|
_buffer;
|
|
2262
|
-
|
|
2398
|
+
_rxpCache = null;
|
|
2263
2399
|
constructor(buffer) {
|
|
2264
2400
|
this._buffer = buffer;
|
|
2265
2401
|
}
|
|
@@ -2275,17 +2411,9 @@ class RXCImpl2 {
|
|
|
2275
2411
|
async buffer() {
|
|
2276
2412
|
return this._buffer;
|
|
2277
2413
|
}
|
|
2278
|
-
async
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
if (!content) {
|
|
2282
|
-
throw new ContentError2(`file not found: ${path}`);
|
|
2283
|
-
}
|
|
2284
|
-
return content;
|
|
2285
|
-
}
|
|
2286
|
-
async files() {
|
|
2287
|
-
if (this._filesCache) {
|
|
2288
|
-
return this._filesCache;
|
|
2414
|
+
async extract() {
|
|
2415
|
+
if (this._rxpCache) {
|
|
2416
|
+
return this._rxpCache;
|
|
2289
2417
|
}
|
|
2290
2418
|
const tarBuffer = await gunzipAsync2(this._buffer);
|
|
2291
2419
|
const entries = await unpackTar2(tarBuffer);
|
|
@@ -2295,16 +2423,16 @@ class RXCImpl2 {
|
|
|
2295
2423
|
filesMap.set(entry.header.name, Buffer.from(entry.data));
|
|
2296
2424
|
}
|
|
2297
2425
|
}
|
|
2298
|
-
this.
|
|
2299
|
-
return
|
|
2426
|
+
this._rxpCache = new RXPImpl2(filesMap);
|
|
2427
|
+
return this._rxpCache;
|
|
2300
2428
|
}
|
|
2301
2429
|
}
|
|
2302
|
-
function
|
|
2303
|
-
return "
|
|
2430
|
+
function isBufferInput2(input) {
|
|
2431
|
+
return "buffer" in input && Buffer.isBuffer(input.buffer);
|
|
2304
2432
|
}
|
|
2305
|
-
async function
|
|
2306
|
-
if (
|
|
2307
|
-
return new
|
|
2433
|
+
async function createRXA2(input) {
|
|
2434
|
+
if (isBufferInput2(input)) {
|
|
2435
|
+
return new RXAImpl2(input.buffer);
|
|
2308
2436
|
}
|
|
2309
2437
|
const entries = Object.entries(input).map(([name, content]) => {
|
|
2310
2438
|
const body = typeof content === "string" ? content : content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
@@ -2316,7 +2444,7 @@ async function createRXC2(input) {
|
|
|
2316
2444
|
});
|
|
2317
2445
|
const tarBuffer = await packTar2(entries);
|
|
2318
2446
|
const gzipBuffer = await gzipAsync2(Buffer.from(tarBuffer));
|
|
2319
|
-
return new
|
|
2447
|
+
return new RXAImpl2(gzipBuffer);
|
|
2320
2448
|
}
|
|
2321
2449
|
|
|
2322
2450
|
class ResourceTypeError extends ResourceXError2 {
|
|
@@ -2327,13 +2455,13 @@ class ResourceTypeError extends ResourceXError2 {
|
|
|
2327
2455
|
}
|
|
2328
2456
|
var textSerializer = {
|
|
2329
2457
|
async serialize(rxr) {
|
|
2330
|
-
return rxr.
|
|
2458
|
+
return rxr.archive.buffer();
|
|
2331
2459
|
},
|
|
2332
2460
|
async deserialize(data, manifest) {
|
|
2333
2461
|
return {
|
|
2334
2462
|
locator: parseRXL2(manifest.toLocator()),
|
|
2335
2463
|
manifest,
|
|
2336
|
-
|
|
2464
|
+
archive: await createRXA2({ buffer: data })
|
|
2337
2465
|
};
|
|
2338
2466
|
}
|
|
2339
2467
|
};
|
|
@@ -2344,7 +2472,8 @@ var textResolver = {
|
|
|
2344
2472
|
resource: rxr,
|
|
2345
2473
|
schema: undefined,
|
|
2346
2474
|
execute: async () => {
|
|
2347
|
-
const
|
|
2475
|
+
const pkg = await rxr.archive.extract();
|
|
2476
|
+
const buffer = await pkg.file("content");
|
|
2348
2477
|
return buffer.toString("utf-8");
|
|
2349
2478
|
}
|
|
2350
2479
|
};
|
|
@@ -2359,13 +2488,13 @@ var textType = {
|
|
|
2359
2488
|
};
|
|
2360
2489
|
var jsonSerializer = {
|
|
2361
2490
|
async serialize(rxr) {
|
|
2362
|
-
return rxr.
|
|
2491
|
+
return rxr.archive.buffer();
|
|
2363
2492
|
},
|
|
2364
2493
|
async deserialize(data, manifest) {
|
|
2365
2494
|
return {
|
|
2366
2495
|
locator: parseRXL2(manifest.toLocator()),
|
|
2367
2496
|
manifest,
|
|
2368
|
-
|
|
2497
|
+
archive: await createRXA2({ buffer: data })
|
|
2369
2498
|
};
|
|
2370
2499
|
}
|
|
2371
2500
|
};
|
|
@@ -2376,7 +2505,8 @@ var jsonResolver = {
|
|
|
2376
2505
|
resource: rxr,
|
|
2377
2506
|
schema: undefined,
|
|
2378
2507
|
execute: async () => {
|
|
2379
|
-
const
|
|
2508
|
+
const pkg = await rxr.archive.extract();
|
|
2509
|
+
const buffer = await pkg.file("content");
|
|
2380
2510
|
return JSON.parse(buffer.toString("utf-8"));
|
|
2381
2511
|
}
|
|
2382
2512
|
};
|
|
@@ -2391,13 +2521,13 @@ var jsonType = {
|
|
|
2391
2521
|
};
|
|
2392
2522
|
var binarySerializer = {
|
|
2393
2523
|
async serialize(rxr) {
|
|
2394
|
-
return rxr.
|
|
2524
|
+
return rxr.archive.buffer();
|
|
2395
2525
|
},
|
|
2396
2526
|
async deserialize(data, manifest) {
|
|
2397
2527
|
return {
|
|
2398
2528
|
locator: parseRXL2(manifest.toLocator()),
|
|
2399
2529
|
manifest,
|
|
2400
|
-
|
|
2530
|
+
archive: await createRXA2({ buffer: data })
|
|
2401
2531
|
};
|
|
2402
2532
|
}
|
|
2403
2533
|
};
|
|
@@ -2408,7 +2538,8 @@ var binaryResolver = {
|
|
|
2408
2538
|
resource: rxr,
|
|
2409
2539
|
schema: undefined,
|
|
2410
2540
|
execute: async () => {
|
|
2411
|
-
|
|
2541
|
+
const pkg = await rxr.archive.extract();
|
|
2542
|
+
return pkg.file("content");
|
|
2412
2543
|
}
|
|
2413
2544
|
};
|
|
2414
2545
|
}
|
|
@@ -2499,14 +2630,22 @@ import { createRequire } from "node:module";
|
|
|
2499
2630
|
import { gzip as gzip3, gunzip as gunzip3 } from "node:zlib";
|
|
2500
2631
|
import { promisify as promisify3 } from "node:util";
|
|
2501
2632
|
import { homedir } from "node:os";
|
|
2502
|
-
import { join as
|
|
2633
|
+
import { join as join3, resolve as resolvePath } from "node:path";
|
|
2634
|
+
import { symlink, lstat, readlink } from "node:fs/promises";
|
|
2503
2635
|
import { gzip as gzip22, gunzip as gunzip22 } from "node:zlib";
|
|
2504
2636
|
import { promisify as promisify22 } from "node:util";
|
|
2505
2637
|
import { readFile, writeFile, readdir, mkdir, rm, access, stat } from "node:fs/promises";
|
|
2506
2638
|
import { resolve, dirname, join } from "node:path";
|
|
2639
|
+
import { join as join2, relative } from "node:path";
|
|
2640
|
+
import { stat as stat2, readFile as readFile2, readdir as readdir2 } from "node:fs/promises";
|
|
2641
|
+
import { gzip as gzip32, gunzip as gunzip32 } from "node:zlib";
|
|
2642
|
+
import { promisify as promisify32 } from "node:util";
|
|
2507
2643
|
import { homedir as homedir2 } from "node:os";
|
|
2508
|
-
import { join as
|
|
2644
|
+
import { join as join4 } from "node:path";
|
|
2509
2645
|
import fs from "node:fs";
|
|
2646
|
+
import { homedir as homedir3 } from "node:os";
|
|
2647
|
+
import { join as join5 } from "node:path";
|
|
2648
|
+
import { gunzipSync } from "node:zlib";
|
|
2510
2649
|
var __create = Object.create;
|
|
2511
2650
|
var __getProtoOf = Object.getPrototypeOf;
|
|
2512
2651
|
var __defProp = Object.defineProperty;
|
|
@@ -6254,7 +6393,7 @@ var require_deflate2 = __commonJS((exports) => {
|
|
|
6254
6393
|
options.raw = true;
|
|
6255
6394
|
return deflate(input, options);
|
|
6256
6395
|
}
|
|
6257
|
-
function
|
|
6396
|
+
function gzip4(input, options) {
|
|
6258
6397
|
options = options || {};
|
|
6259
6398
|
options.gzip = true;
|
|
6260
6399
|
return deflate(input, options);
|
|
@@ -6262,7 +6401,7 @@ var require_deflate2 = __commonJS((exports) => {
|
|
|
6262
6401
|
exports.Deflate = Deflate;
|
|
6263
6402
|
exports.deflate = deflate;
|
|
6264
6403
|
exports.deflateRaw = deflateRaw;
|
|
6265
|
-
exports.gzip =
|
|
6404
|
+
exports.gzip = gzip4;
|
|
6266
6405
|
});
|
|
6267
6406
|
var require_inffast = __commonJS((exports, module) => {
|
|
6268
6407
|
var BAD = 30;
|
|
@@ -8277,7 +8416,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8277
8416
|
function makeArray(subject) {
|
|
8278
8417
|
return Array.isArray(subject) ? subject : [subject];
|
|
8279
8418
|
}
|
|
8280
|
-
var
|
|
8419
|
+
var EMPTY4 = "";
|
|
8281
8420
|
var SPACE = " ";
|
|
8282
8421
|
var ESCAPE = "\\";
|
|
8283
8422
|
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
@@ -8295,7 +8434,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8295
8434
|
var define2 = (object, key, value) => Object.defineProperty(object, key, { value });
|
|
8296
8435
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
8297
8436
|
var RETURN_FALSE = () => false;
|
|
8298
|
-
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match :
|
|
8437
|
+
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY4);
|
|
8299
8438
|
var cleanRangeBackSlash = (slashes) => {
|
|
8300
8439
|
const { length } = slashes;
|
|
8301
8440
|
return slashes.slice(0, length - length % 2);
|
|
@@ -8303,11 +8442,11 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
8303
8442
|
var REPLACERS = [
|
|
8304
8443
|
[
|
|
8305
8444
|
/^\uFEFF/,
|
|
8306
|
-
() =>
|
|
8445
|
+
() => EMPTY4
|
|
8307
8446
|
],
|
|
8308
8447
|
[
|
|
8309
8448
|
/((?:\\\\)*?)(\\?\s+)$/,
|
|
8310
|
-
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE :
|
|
8449
|
+
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY4)
|
|
8311
8450
|
],
|
|
8312
8451
|
[
|
|
8313
8452
|
/(\\+?)\s/g,
|
|
@@ -9298,17 +9437,17 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
9298
9437
|
const length = Math.ceil((62 + bpath.length + 1) / 8) * 8;
|
|
9299
9438
|
const written = Buffer.alloc(length);
|
|
9300
9439
|
const writer = new BufferCursor(written);
|
|
9301
|
-
const
|
|
9302
|
-
writer.writeUInt32BE(
|
|
9303
|
-
writer.writeUInt32BE(
|
|
9304
|
-
writer.writeUInt32BE(
|
|
9305
|
-
writer.writeUInt32BE(
|
|
9306
|
-
writer.writeUInt32BE(
|
|
9307
|
-
writer.writeUInt32BE(
|
|
9308
|
-
writer.writeUInt32BE(
|
|
9309
|
-
writer.writeUInt32BE(
|
|
9310
|
-
writer.writeUInt32BE(
|
|
9311
|
-
writer.writeUInt32BE(
|
|
9440
|
+
const stat3 = normalizeStats(entry);
|
|
9441
|
+
writer.writeUInt32BE(stat3.ctimeSeconds);
|
|
9442
|
+
writer.writeUInt32BE(stat3.ctimeNanoseconds);
|
|
9443
|
+
writer.writeUInt32BE(stat3.mtimeSeconds);
|
|
9444
|
+
writer.writeUInt32BE(stat3.mtimeNanoseconds);
|
|
9445
|
+
writer.writeUInt32BE(stat3.dev);
|
|
9446
|
+
writer.writeUInt32BE(stat3.ino);
|
|
9447
|
+
writer.writeUInt32BE(stat3.mode);
|
|
9448
|
+
writer.writeUInt32BE(stat3.uid);
|
|
9449
|
+
writer.writeUInt32BE(stat3.gid);
|
|
9450
|
+
writer.writeUInt32BE(stat3.size);
|
|
9312
9451
|
writer.write(entry.oid, 20, "hex");
|
|
9313
9452
|
writer.writeUInt16BE(renderCacheEntryFlags(entry));
|
|
9314
9453
|
writer.write(entry.path, bpath.length, "utf8");
|
|
@@ -9353,13 +9492,13 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
9353
9492
|
};
|
|
9354
9493
|
}
|
|
9355
9494
|
async function updateCachedIndexFile(fs2, filepath, cache) {
|
|
9356
|
-
const [
|
|
9495
|
+
const [stat3, rawIndexFile] = await Promise.all([
|
|
9357
9496
|
fs2.lstat(filepath),
|
|
9358
9497
|
fs2.read(filepath)
|
|
9359
9498
|
]);
|
|
9360
9499
|
const index2 = await GitIndex.from(rawIndexFile);
|
|
9361
9500
|
cache.map.set(filepath, index2);
|
|
9362
|
-
cache.stats.set(filepath,
|
|
9501
|
+
cache.stats.set(filepath, stat3);
|
|
9363
9502
|
}
|
|
9364
9503
|
async function isIndexStale(fs2, filepath, cache) {
|
|
9365
9504
|
const savedStats = cache.stats.get(filepath);
|
|
@@ -9826,7 +9965,7 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
9826
9965
|
path += "/";
|
|
9827
9966
|
return isAbsolute ? `/${path}` : path;
|
|
9828
9967
|
}
|
|
9829
|
-
function
|
|
9968
|
+
function join42(...args) {
|
|
9830
9969
|
if (args.length === 0)
|
|
9831
9970
|
return ".";
|
|
9832
9971
|
let joined;
|
|
@@ -10181,7 +10320,7 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
10181
10320
|
}
|
|
10182
10321
|
}
|
|
10183
10322
|
for (const [key, value] of actualRefsToWrite) {
|
|
10184
|
-
await acquireLock(key, async () => fs2.write(
|
|
10323
|
+
await acquireLock(key, async () => fs2.write(join42(gitdir, key), `${value.trim()}
|
|
10185
10324
|
`, "utf8"));
|
|
10186
10325
|
}
|
|
10187
10326
|
return { pruned };
|
|
@@ -10190,18 +10329,18 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
10190
10329
|
if (!value.match(/[0-9a-f]{40}/)) {
|
|
10191
10330
|
throw new InvalidOidError(value);
|
|
10192
10331
|
}
|
|
10193
|
-
await acquireLock(ref, async () => fs2.write(
|
|
10332
|
+
await acquireLock(ref, async () => fs2.write(join42(gitdir, ref), `${value.trim()}
|
|
10194
10333
|
`, "utf8"));
|
|
10195
10334
|
}
|
|
10196
10335
|
static async writeSymbolicRef({ fs: fs2, gitdir, ref, value }) {
|
|
10197
|
-
await acquireLock(ref, async () => fs2.write(
|
|
10336
|
+
await acquireLock(ref, async () => fs2.write(join42(gitdir, ref), "ref: " + `${value.trim()}
|
|
10198
10337
|
`, "utf8"));
|
|
10199
10338
|
}
|
|
10200
10339
|
static async deleteRef({ fs: fs2, gitdir, ref }) {
|
|
10201
10340
|
return GitRefManager.deleteRefs({ fs: fs2, gitdir, refs: [ref] });
|
|
10202
10341
|
}
|
|
10203
10342
|
static async deleteRefs({ fs: fs2, gitdir, refs }) {
|
|
10204
|
-
await Promise.all(refs.map((ref) => fs2.rm(
|
|
10343
|
+
await Promise.all(refs.map((ref) => fs2.rm(join42(gitdir, ref))));
|
|
10205
10344
|
let text = await acquireLock("packed-refs", async () => fs2.read(`${gitdir}/packed-refs`, { encoding: "utf8" }));
|
|
10206
10345
|
const packed = GitPackedRefs.from(text);
|
|
10207
10346
|
const beforeSize = packed.refs.size;
|
|
@@ -11121,7 +11260,7 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
11121
11260
|
format = "content",
|
|
11122
11261
|
getExternalRefDelta
|
|
11123
11262
|
}) {
|
|
11124
|
-
let list = await fs2.readdir(
|
|
11263
|
+
let list = await fs2.readdir(join42(gitdir, "objects/pack"));
|
|
11125
11264
|
list = list.filter((x) => x.endsWith(".idx"));
|
|
11126
11265
|
for (const filename of list) {
|
|
11127
11266
|
const indexFile = `${gitdir}/objects/pack/${filename}`;
|
|
@@ -11862,9 +12001,9 @@ gpgsig`));
|
|
|
11862
12001
|
}
|
|
11863
12002
|
const tree = GitTree.from(object);
|
|
11864
12003
|
for (const entry2 of tree) {
|
|
11865
|
-
map.set(
|
|
12004
|
+
map.set(join42(filepath, entry2.path), entry2);
|
|
11866
12005
|
}
|
|
11867
|
-
return tree.entries().map((entry2) =>
|
|
12006
|
+
return tree.entries().map((entry2) => join42(filepath, entry2.path));
|
|
11868
12007
|
}
|
|
11869
12008
|
async type(entry) {
|
|
11870
12009
|
if (entry._type === false) {
|
|
@@ -11955,10 +12094,10 @@ gpgsig`));
|
|
|
11955
12094
|
async readdir(entry) {
|
|
11956
12095
|
const filepath = entry._fullpath;
|
|
11957
12096
|
const { fs: fs2, dir } = this;
|
|
11958
|
-
const names = await fs2.readdir(
|
|
12097
|
+
const names = await fs2.readdir(join42(dir, filepath));
|
|
11959
12098
|
if (names === null)
|
|
11960
12099
|
return null;
|
|
11961
|
-
return names.map((name) =>
|
|
12100
|
+
return names.map((name) => join42(filepath, name));
|
|
11962
12101
|
}
|
|
11963
12102
|
async type(entry) {
|
|
11964
12103
|
if (entry._type === false) {
|
|
@@ -11975,21 +12114,21 @@ gpgsig`));
|
|
|
11975
12114
|
async stat(entry) {
|
|
11976
12115
|
if (entry._stat === false) {
|
|
11977
12116
|
const { fs: fs2, dir } = this;
|
|
11978
|
-
let
|
|
11979
|
-
if (!
|
|
12117
|
+
let stat3 = await fs2.lstat(`${dir}/${entry._fullpath}`);
|
|
12118
|
+
if (!stat3) {
|
|
11980
12119
|
throw new Error(`ENOENT: no such file or directory, lstat '${entry._fullpath}'`);
|
|
11981
12120
|
}
|
|
11982
|
-
let type =
|
|
11983
|
-
if (type === "blob" && !
|
|
12121
|
+
let type = stat3.isDirectory() ? "tree" : "blob";
|
|
12122
|
+
if (type === "blob" && !stat3.isFile() && !stat3.isSymbolicLink()) {
|
|
11984
12123
|
type = "special";
|
|
11985
12124
|
}
|
|
11986
12125
|
entry._type = type;
|
|
11987
|
-
|
|
11988
|
-
entry._mode =
|
|
11989
|
-
if (
|
|
11990
|
-
|
|
12126
|
+
stat3 = normalizeStats(stat3);
|
|
12127
|
+
entry._mode = stat3.mode;
|
|
12128
|
+
if (stat3.size === -1 && entry._actualSize) {
|
|
12129
|
+
stat3.size = entry._actualSize;
|
|
11991
12130
|
}
|
|
11992
|
-
entry._stat =
|
|
12131
|
+
entry._stat = stat3;
|
|
11993
12132
|
}
|
|
11994
12133
|
return entry._stat;
|
|
11995
12134
|
}
|
|
@@ -12171,11 +12310,11 @@ gpgsig`));
|
|
|
12171
12310
|
await fs2.rm(filepath);
|
|
12172
12311
|
} else if (entries.length) {
|
|
12173
12312
|
await Promise.all(entries.map((entry) => {
|
|
12174
|
-
const subpath =
|
|
12175
|
-
return fs2.lstat(subpath).then((
|
|
12176
|
-
if (!
|
|
12313
|
+
const subpath = join42(filepath, entry);
|
|
12314
|
+
return fs2.lstat(subpath).then((stat3) => {
|
|
12315
|
+
if (!stat3)
|
|
12177
12316
|
return;
|
|
12178
|
-
return
|
|
12317
|
+
return stat3.isDirectory() ? rmRecursive(fs2, subpath) : fs2.rm(subpath);
|
|
12179
12318
|
});
|
|
12180
12319
|
})).then(() => fs2.rmdir(filepath));
|
|
12181
12320
|
} else {
|
|
@@ -12393,7 +12532,7 @@ gpgsig`));
|
|
|
12393
12532
|
return dotgit;
|
|
12394
12533
|
} else if (dotgitStat.isFile()) {
|
|
12395
12534
|
return fsp._readFile(dotgit, "utf8").then((contents) => contents.trimRight().substr(8)).then((submoduleGitdir) => {
|
|
12396
|
-
const gitdir =
|
|
12535
|
+
const gitdir = join42(dirname2(dotgit), submoduleGitdir);
|
|
12397
12536
|
return gitdir;
|
|
12398
12537
|
});
|
|
12399
12538
|
} else {
|
|
@@ -12418,7 +12557,7 @@ gpgsig`));
|
|
|
12418
12557
|
async function abortMerge({
|
|
12419
12558
|
fs: _fs,
|
|
12420
12559
|
dir,
|
|
12421
|
-
gitdir =
|
|
12560
|
+
gitdir = join42(dir, ".git"),
|
|
12422
12561
|
commit: commit2 = "HEAD",
|
|
12423
12562
|
cache = {}
|
|
12424
12563
|
}) {
|
|
@@ -12487,19 +12626,19 @@ gpgsig`));
|
|
|
12487
12626
|
}
|
|
12488
12627
|
|
|
12489
12628
|
class GitIgnoreManager {
|
|
12490
|
-
static async isIgnored({ fs: fs2, dir, gitdir =
|
|
12629
|
+
static async isIgnored({ fs: fs2, dir, gitdir = join42(dir, ".git"), filepath }) {
|
|
12491
12630
|
if (basename(filepath) === ".git")
|
|
12492
12631
|
return true;
|
|
12493
12632
|
if (filepath === ".")
|
|
12494
12633
|
return false;
|
|
12495
12634
|
let excludes = "";
|
|
12496
|
-
const excludesFile =
|
|
12635
|
+
const excludesFile = join42(gitdir, "info", "exclude");
|
|
12497
12636
|
if (await fs2.exists(excludesFile)) {
|
|
12498
12637
|
excludes = await fs2.read(excludesFile, "utf8");
|
|
12499
12638
|
}
|
|
12500
12639
|
const pairs = [
|
|
12501
12640
|
{
|
|
12502
|
-
gitignore:
|
|
12641
|
+
gitignore: join42(dir, ".gitignore"),
|
|
12503
12642
|
filepath
|
|
12504
12643
|
}
|
|
12505
12644
|
];
|
|
@@ -12508,7 +12647,7 @@ gpgsig`));
|
|
|
12508
12647
|
const folder = pieces.slice(0, i).join("/");
|
|
12509
12648
|
const file = pieces.slice(i).join("/");
|
|
12510
12649
|
pairs.push({
|
|
12511
|
-
gitignore:
|
|
12650
|
+
gitignore: join42(dir, folder, ".gitignore"),
|
|
12512
12651
|
filepath: file
|
|
12513
12652
|
});
|
|
12514
12653
|
}
|
|
@@ -12597,7 +12736,7 @@ gpgsig`));
|
|
|
12597
12736
|
async function add({
|
|
12598
12737
|
fs: _fs,
|
|
12599
12738
|
dir,
|
|
12600
|
-
gitdir =
|
|
12739
|
+
gitdir = join42(dir, ".git"),
|
|
12601
12740
|
filepath,
|
|
12602
12741
|
cache = {},
|
|
12603
12742
|
force = false,
|
|
@@ -12651,17 +12790,17 @@ gpgsig`));
|
|
|
12651
12790
|
if (ignored)
|
|
12652
12791
|
return;
|
|
12653
12792
|
}
|
|
12654
|
-
const stats = await fs2.lstat(
|
|
12793
|
+
const stats = await fs2.lstat(join42(dir, currentFilepath));
|
|
12655
12794
|
if (!stats)
|
|
12656
12795
|
throw new NotFoundError(currentFilepath);
|
|
12657
12796
|
if (stats.isDirectory()) {
|
|
12658
|
-
const children = await fs2.readdir(
|
|
12797
|
+
const children = await fs2.readdir(join42(dir, currentFilepath));
|
|
12659
12798
|
if (parallel) {
|
|
12660
12799
|
const promises2 = children.map((child) => addToIndex({
|
|
12661
12800
|
dir,
|
|
12662
12801
|
gitdir,
|
|
12663
12802
|
fs: fs2,
|
|
12664
|
-
filepath: [
|
|
12803
|
+
filepath: [join42(currentFilepath, child)],
|
|
12665
12804
|
index: index2,
|
|
12666
12805
|
force,
|
|
12667
12806
|
parallel,
|
|
@@ -12674,7 +12813,7 @@ gpgsig`));
|
|
|
12674
12813
|
dir,
|
|
12675
12814
|
gitdir,
|
|
12676
12815
|
fs: fs2,
|
|
12677
|
-
filepath: [
|
|
12816
|
+
filepath: [join42(currentFilepath, child)],
|
|
12678
12817
|
index: index2,
|
|
12679
12818
|
force,
|
|
12680
12819
|
parallel,
|
|
@@ -12683,7 +12822,7 @@ gpgsig`));
|
|
|
12683
12822
|
}
|
|
12684
12823
|
}
|
|
12685
12824
|
} else {
|
|
12686
|
-
const object = stats.isSymbolicLink() ? await fs2.readlink(
|
|
12825
|
+
const object = stats.isSymbolicLink() ? await fs2.readlink(join42(dir, currentFilepath)).then(posixifyPathBuffer) : await fs2.read(join42(dir, currentFilepath), { autocrlf });
|
|
12687
12826
|
if (object === null)
|
|
12688
12827
|
throw new NotFoundError(currentFilepath);
|
|
12689
12828
|
const oid = await _writeObject({ fs: fs2, gitdir, type: "blob", object });
|
|
@@ -13079,7 +13218,7 @@ gpgsig`));
|
|
|
13079
13218
|
fs: _fs,
|
|
13080
13219
|
onSign,
|
|
13081
13220
|
dir,
|
|
13082
|
-
gitdir =
|
|
13221
|
+
gitdir = join42(dir, ".git"),
|
|
13083
13222
|
ref = "refs/notes/commits",
|
|
13084
13223
|
oid,
|
|
13085
13224
|
note,
|
|
@@ -13154,7 +13293,7 @@ gpgsig`));
|
|
|
13154
13293
|
async function addRemote({
|
|
13155
13294
|
fs: fs2,
|
|
13156
13295
|
dir,
|
|
13157
|
-
gitdir =
|
|
13296
|
+
gitdir = join42(dir, ".git"),
|
|
13158
13297
|
remote,
|
|
13159
13298
|
url,
|
|
13160
13299
|
force = false
|
|
@@ -13224,7 +13363,7 @@ gpgsig`));
|
|
|
13224
13363
|
fs: _fs,
|
|
13225
13364
|
onSign,
|
|
13226
13365
|
dir,
|
|
13227
|
-
gitdir =
|
|
13366
|
+
gitdir = join42(dir, ".git"),
|
|
13228
13367
|
ref,
|
|
13229
13368
|
tagger: _tagger,
|
|
13230
13369
|
message = ref,
|
|
@@ -13305,7 +13444,7 @@ gpgsig`));
|
|
|
13305
13444
|
async function branch({
|
|
13306
13445
|
fs: fs2,
|
|
13307
13446
|
dir,
|
|
13308
|
-
gitdir =
|
|
13447
|
+
gitdir = join42(dir, ".git"),
|
|
13309
13448
|
ref,
|
|
13310
13449
|
object,
|
|
13311
13450
|
checkout: checkout2 = false,
|
|
@@ -13876,7 +14015,7 @@ gpgsig`));
|
|
|
13876
14015
|
onProgress,
|
|
13877
14016
|
onPostCheckout,
|
|
13878
14017
|
dir,
|
|
13879
|
-
gitdir =
|
|
14018
|
+
gitdir = join42(dir, ".git"),
|
|
13880
14019
|
remote = "origin",
|
|
13881
14020
|
ref: _ref,
|
|
13882
14021
|
filepaths,
|
|
@@ -14289,7 +14428,7 @@ gpgsig`));
|
|
|
14289
14428
|
static async read({ fs: fs2, gitdir }) {
|
|
14290
14429
|
if (lock$2 === null)
|
|
14291
14430
|
lock$2 = new AsyncLock;
|
|
14292
|
-
const filepath =
|
|
14431
|
+
const filepath = join42(gitdir, "shallow");
|
|
14293
14432
|
const oids = new Set;
|
|
14294
14433
|
await lock$2.acquire(filepath, async function() {
|
|
14295
14434
|
const text = await fs2.read(filepath, { encoding: "utf8" });
|
|
@@ -14305,7 +14444,7 @@ gpgsig`));
|
|
|
14305
14444
|
static async write({ fs: fs2, gitdir, oids }) {
|
|
14306
14445
|
if (lock$2 === null)
|
|
14307
14446
|
lock$2 = new AsyncLock;
|
|
14308
|
-
const filepath =
|
|
14447
|
+
const filepath = join42(gitdir, "shallow");
|
|
14309
14448
|
if (oids.size > 0) {
|
|
14310
14449
|
const text = [...oids].join(`
|
|
14311
14450
|
`) + `
|
|
@@ -14333,7 +14472,7 @@ gpgsig`));
|
|
|
14333
14472
|
oid,
|
|
14334
14473
|
getExternalRefDelta
|
|
14335
14474
|
}) {
|
|
14336
|
-
let list = await fs2.readdir(
|
|
14475
|
+
let list = await fs2.readdir(join42(gitdir, "objects/pack"));
|
|
14337
14476
|
list = list.filter((x) => x.endsWith(".idx"));
|
|
14338
14477
|
for (const filename of list) {
|
|
14339
14478
|
const indexFile = `${gitdir}/objects/pack/${filename}`;
|
|
@@ -14622,7 +14761,7 @@ gpgsig`));
|
|
|
14622
14761
|
depth = null,
|
|
14623
14762
|
since = null,
|
|
14624
14763
|
exclude = [],
|
|
14625
|
-
relative = false,
|
|
14764
|
+
relative: relative2 = false,
|
|
14626
14765
|
tags = false,
|
|
14627
14766
|
singleBranch = false,
|
|
14628
14767
|
headers = {},
|
|
@@ -14670,7 +14809,7 @@ gpgsig`));
|
|
|
14670
14809
|
if (exclude.length > 0 && !remoteHTTP.capabilities.has("deepen-not")) {
|
|
14671
14810
|
throw new RemoteCapabilityError("deepen-not", "exclude");
|
|
14672
14811
|
}
|
|
14673
|
-
if (
|
|
14812
|
+
if (relative2 === true && !remoteHTTP.capabilities.has("deepen-relative")) {
|
|
14674
14813
|
throw new RemoteCapabilityError("deepen-relative", "relative");
|
|
14675
14814
|
}
|
|
14676
14815
|
const { oid, fullref } = GitRefManager.resolveAgainstMap({
|
|
@@ -14690,7 +14829,7 @@ gpgsig`));
|
|
|
14690
14829
|
"ofs-delta",
|
|
14691
14830
|
`agent=${pkg.agent}`
|
|
14692
14831
|
]);
|
|
14693
|
-
if (
|
|
14832
|
+
if (relative2)
|
|
14694
14833
|
capabilities.push("deepen-relative");
|
|
14695
14834
|
const wants = singleBranch ? [oid] : remoteRefs.values();
|
|
14696
14835
|
const haveRefs = singleBranch ? [ref] : await GitRefManager.listRefs({
|
|
@@ -14849,7 +14988,7 @@ gpgsig`));
|
|
|
14849
14988
|
}
|
|
14850
14989
|
if (packfileSha !== "" && !emptyPackfile(packfile)) {
|
|
14851
14990
|
res.packfile = `objects/pack/pack-${packfileSha}.pack`;
|
|
14852
|
-
const fullpath =
|
|
14991
|
+
const fullpath = join42(gitdir, res.packfile);
|
|
14853
14992
|
await fs2.write(fullpath, packfile);
|
|
14854
14993
|
const getExternalRefDelta = (oid2) => _readObject({ fs: fs2, cache, gitdir, oid: oid2 });
|
|
14855
14994
|
const idx = await GitPackIndex.fromPack({
|
|
@@ -14865,7 +15004,7 @@ gpgsig`));
|
|
|
14865
15004
|
fs: fs2,
|
|
14866
15005
|
bare = false,
|
|
14867
15006
|
dir,
|
|
14868
|
-
gitdir = bare ? dir :
|
|
15007
|
+
gitdir = bare ? dir : join42(dir, ".git"),
|
|
14869
15008
|
defaultBranch = "master"
|
|
14870
15009
|
}) {
|
|
14871
15010
|
if (await fs2.exists(gitdir + "/config"))
|
|
@@ -14912,7 +15051,7 @@ gpgsig`));
|
|
|
14912
15051
|
depth,
|
|
14913
15052
|
since,
|
|
14914
15053
|
exclude,
|
|
14915
|
-
relative,
|
|
15054
|
+
relative: relative2,
|
|
14916
15055
|
singleBranch,
|
|
14917
15056
|
noCheckout,
|
|
14918
15057
|
noTags,
|
|
@@ -14944,7 +15083,7 @@ gpgsig`));
|
|
|
14944
15083
|
depth,
|
|
14945
15084
|
since,
|
|
14946
15085
|
exclude,
|
|
14947
|
-
relative,
|
|
15086
|
+
relative: relative2,
|
|
14948
15087
|
singleBranch,
|
|
14949
15088
|
headers,
|
|
14950
15089
|
tags: !noTags
|
|
@@ -14983,7 +15122,7 @@ gpgsig`));
|
|
|
14983
15122
|
onAuthFailure,
|
|
14984
15123
|
onPostCheckout,
|
|
14985
15124
|
dir,
|
|
14986
|
-
gitdir =
|
|
15125
|
+
gitdir = join42(dir, ".git"),
|
|
14987
15126
|
url,
|
|
14988
15127
|
corsProxy = undefined,
|
|
14989
15128
|
ref = undefined,
|
|
@@ -14991,7 +15130,7 @@ gpgsig`));
|
|
|
14991
15130
|
depth = undefined,
|
|
14992
15131
|
since = undefined,
|
|
14993
15132
|
exclude = [],
|
|
14994
|
-
relative = false,
|
|
15133
|
+
relative: relative2 = false,
|
|
14995
15134
|
singleBranch = false,
|
|
14996
15135
|
noCheckout = false,
|
|
14997
15136
|
noTags = false,
|
|
@@ -15029,7 +15168,7 @@ gpgsig`));
|
|
|
15029
15168
|
depth,
|
|
15030
15169
|
since,
|
|
15031
15170
|
exclude,
|
|
15032
|
-
relative,
|
|
15171
|
+
relative: relative2,
|
|
15033
15172
|
singleBranch,
|
|
15034
15173
|
noCheckout,
|
|
15035
15174
|
noTags,
|
|
@@ -15046,7 +15185,7 @@ gpgsig`));
|
|
|
15046
15185
|
fs: _fs,
|
|
15047
15186
|
onSign,
|
|
15048
15187
|
dir,
|
|
15049
|
-
gitdir =
|
|
15188
|
+
gitdir = join42(dir, ".git"),
|
|
15050
15189
|
message,
|
|
15051
15190
|
author,
|
|
15052
15191
|
committer,
|
|
@@ -15093,7 +15232,7 @@ gpgsig`));
|
|
|
15093
15232
|
async function currentBranch({
|
|
15094
15233
|
fs: fs2,
|
|
15095
15234
|
dir,
|
|
15096
|
-
gitdir =
|
|
15235
|
+
gitdir = join42(dir, ".git"),
|
|
15097
15236
|
fullname = false,
|
|
15098
15237
|
test = false
|
|
15099
15238
|
}) {
|
|
@@ -15134,7 +15273,7 @@ gpgsig`));
|
|
|
15134
15273
|
async function deleteBranch({
|
|
15135
15274
|
fs: fs2,
|
|
15136
15275
|
dir,
|
|
15137
|
-
gitdir =
|
|
15276
|
+
gitdir = join42(dir, ".git"),
|
|
15138
15277
|
ref
|
|
15139
15278
|
}) {
|
|
15140
15279
|
try {
|
|
@@ -15152,7 +15291,7 @@ gpgsig`));
|
|
|
15152
15291
|
throw err;
|
|
15153
15292
|
}
|
|
15154
15293
|
}
|
|
15155
|
-
async function deleteRef({ fs: fs2, dir, gitdir =
|
|
15294
|
+
async function deleteRef({ fs: fs2, dir, gitdir = join42(dir, ".git"), ref }) {
|
|
15156
15295
|
try {
|
|
15157
15296
|
assertParameter("fs", fs2);
|
|
15158
15297
|
assertParameter("ref", ref);
|
|
@@ -15172,7 +15311,7 @@ gpgsig`));
|
|
|
15172
15311
|
async function deleteRemote({
|
|
15173
15312
|
fs: fs2,
|
|
15174
15313
|
dir,
|
|
15175
|
-
gitdir =
|
|
15314
|
+
gitdir = join42(dir, ".git"),
|
|
15176
15315
|
remote
|
|
15177
15316
|
}) {
|
|
15178
15317
|
try {
|
|
@@ -15194,7 +15333,7 @@ gpgsig`));
|
|
|
15194
15333
|
ref = ref.startsWith("refs/tags/") ? ref : `refs/tags/${ref}`;
|
|
15195
15334
|
await GitRefManager.deleteRef({ fs: fs2, gitdir, ref });
|
|
15196
15335
|
}
|
|
15197
|
-
async function deleteTag({ fs: fs2, dir, gitdir =
|
|
15336
|
+
async function deleteTag({ fs: fs2, dir, gitdir = join42(dir, ".git"), ref }) {
|
|
15198
15337
|
try {
|
|
15199
15338
|
assertParameter("fs", fs2);
|
|
15200
15339
|
assertParameter("ref", ref);
|
|
@@ -15223,7 +15362,7 @@ gpgsig`));
|
|
|
15223
15362
|
getExternalRefDelta
|
|
15224
15363
|
}) {
|
|
15225
15364
|
const results = [];
|
|
15226
|
-
let list = await fs2.readdir(
|
|
15365
|
+
let list = await fs2.readdir(join42(gitdir, "objects/pack"));
|
|
15227
15366
|
list = list.filter((x) => x.endsWith(".idx"));
|
|
15228
15367
|
for (const filename of list) {
|
|
15229
15368
|
const indexFile = `${gitdir}/objects/pack/${filename}`;
|
|
@@ -15268,7 +15407,7 @@ gpgsig`));
|
|
|
15268
15407
|
async function expandOid({
|
|
15269
15408
|
fs: fs2,
|
|
15270
15409
|
dir,
|
|
15271
|
-
gitdir =
|
|
15410
|
+
gitdir = join42(dir, ".git"),
|
|
15272
15411
|
oid,
|
|
15273
15412
|
cache = {}
|
|
15274
15413
|
}) {
|
|
@@ -15289,7 +15428,7 @@ gpgsig`));
|
|
|
15289
15428
|
throw err;
|
|
15290
15429
|
}
|
|
15291
15430
|
}
|
|
15292
|
-
async function expandRef({ fs: fs2, dir, gitdir =
|
|
15431
|
+
async function expandRef({ fs: fs2, dir, gitdir = join42(dir, ".git"), ref }) {
|
|
15293
15432
|
try {
|
|
15294
15433
|
assertParameter("fs", fs2);
|
|
15295
15434
|
assertParameter("gitdir", gitdir);
|
|
@@ -15376,7 +15515,7 @@ gpgsig`));
|
|
|
15376
15515
|
fs: fs2,
|
|
15377
15516
|
cache,
|
|
15378
15517
|
dir,
|
|
15379
|
-
gitdir =
|
|
15518
|
+
gitdir = join42(dir, ".git"),
|
|
15380
15519
|
index: index2,
|
|
15381
15520
|
ourOid,
|
|
15382
15521
|
baseOid,
|
|
@@ -15846,7 +15985,7 @@ gpgsig`));
|
|
|
15846
15985
|
onAuthSuccess,
|
|
15847
15986
|
onAuthFailure,
|
|
15848
15987
|
dir,
|
|
15849
|
-
gitdir =
|
|
15988
|
+
gitdir = join42(dir, ".git"),
|
|
15850
15989
|
ref,
|
|
15851
15990
|
url,
|
|
15852
15991
|
remote,
|
|
@@ -15904,7 +16043,7 @@ gpgsig`));
|
|
|
15904
16043
|
onAuthSuccess,
|
|
15905
16044
|
onAuthFailure,
|
|
15906
16045
|
dir,
|
|
15907
|
-
gitdir =
|
|
16046
|
+
gitdir = join42(dir, ".git"),
|
|
15908
16047
|
ref,
|
|
15909
16048
|
remote,
|
|
15910
16049
|
remoteRef,
|
|
@@ -15913,7 +16052,7 @@ gpgsig`));
|
|
|
15913
16052
|
depth = null,
|
|
15914
16053
|
since = null,
|
|
15915
16054
|
exclude = [],
|
|
15916
|
-
relative = false,
|
|
16055
|
+
relative: relative2 = false,
|
|
15917
16056
|
tags = false,
|
|
15918
16057
|
singleBranch = false,
|
|
15919
16058
|
headers = {},
|
|
@@ -15945,7 +16084,7 @@ gpgsig`));
|
|
|
15945
16084
|
depth,
|
|
15946
16085
|
since,
|
|
15947
16086
|
exclude,
|
|
15948
|
-
relative,
|
|
16087
|
+
relative: relative2,
|
|
15949
16088
|
tags,
|
|
15950
16089
|
singleBranch,
|
|
15951
16090
|
headers,
|
|
@@ -15960,7 +16099,7 @@ gpgsig`));
|
|
|
15960
16099
|
async function findMergeBase({
|
|
15961
16100
|
fs: fs2,
|
|
15962
16101
|
dir,
|
|
15963
|
-
gitdir =
|
|
16102
|
+
gitdir = join42(dir, ".git"),
|
|
15964
16103
|
oids,
|
|
15965
16104
|
cache = {}
|
|
15966
16105
|
}) {
|
|
@@ -15982,7 +16121,7 @@ gpgsig`));
|
|
|
15982
16121
|
}
|
|
15983
16122
|
}
|
|
15984
16123
|
async function _findRoot({ fs: fs2, filepath }) {
|
|
15985
|
-
if (await fs2.exists(
|
|
16124
|
+
if (await fs2.exists(join42(filepath, ".git"))) {
|
|
15986
16125
|
return filepath;
|
|
15987
16126
|
} else {
|
|
15988
16127
|
const parent = dirname2(filepath);
|
|
@@ -16002,7 +16141,7 @@ gpgsig`));
|
|
|
16002
16141
|
throw err;
|
|
16003
16142
|
}
|
|
16004
16143
|
}
|
|
16005
|
-
async function getConfig({ fs: fs2, dir, gitdir =
|
|
16144
|
+
async function getConfig({ fs: fs2, dir, gitdir = join42(dir, ".git"), path }) {
|
|
16006
16145
|
try {
|
|
16007
16146
|
assertParameter("fs", fs2);
|
|
16008
16147
|
assertParameter("gitdir", gitdir);
|
|
@@ -16026,7 +16165,7 @@ gpgsig`));
|
|
|
16026
16165
|
async function getConfigAll({
|
|
16027
16166
|
fs: fs2,
|
|
16028
16167
|
dir,
|
|
16029
|
-
gitdir =
|
|
16168
|
+
gitdir = join42(dir, ".git"),
|
|
16030
16169
|
path
|
|
16031
16170
|
}) {
|
|
16032
16171
|
try {
|
|
@@ -16220,7 +16359,7 @@ gpgsig`));
|
|
|
16220
16359
|
filepath
|
|
16221
16360
|
}) {
|
|
16222
16361
|
try {
|
|
16223
|
-
filepath =
|
|
16362
|
+
filepath = join42(dir, filepath);
|
|
16224
16363
|
const pack = await fs2.read(filepath);
|
|
16225
16364
|
const getExternalRefDelta = (oid) => _readObject({ fs: fs2, cache, gitdir, oid });
|
|
16226
16365
|
const idx = await GitPackIndex.fromPack({
|
|
@@ -16241,7 +16380,7 @@ gpgsig`));
|
|
|
16241
16380
|
fs: fs2,
|
|
16242
16381
|
onProgress,
|
|
16243
16382
|
dir,
|
|
16244
|
-
gitdir =
|
|
16383
|
+
gitdir = join42(dir, ".git"),
|
|
16245
16384
|
filepath,
|
|
16246
16385
|
cache = {}
|
|
16247
16386
|
}) {
|
|
@@ -16269,7 +16408,7 @@ gpgsig`));
|
|
|
16269
16408
|
fs: fs2,
|
|
16270
16409
|
bare = false,
|
|
16271
16410
|
dir,
|
|
16272
|
-
gitdir = bare ? dir :
|
|
16411
|
+
gitdir = bare ? dir : join42(dir, ".git"),
|
|
16273
16412
|
defaultBranch = "master"
|
|
16274
16413
|
}) {
|
|
16275
16414
|
try {
|
|
@@ -16345,7 +16484,7 @@ gpgsig`));
|
|
|
16345
16484
|
async function isDescendent({
|
|
16346
16485
|
fs: fs2,
|
|
16347
16486
|
dir,
|
|
16348
|
-
gitdir =
|
|
16487
|
+
gitdir = join42(dir, ".git"),
|
|
16349
16488
|
oid,
|
|
16350
16489
|
ancestor,
|
|
16351
16490
|
depth = -1,
|
|
@@ -16374,7 +16513,7 @@ gpgsig`));
|
|
|
16374
16513
|
async function isIgnored({
|
|
16375
16514
|
fs: fs2,
|
|
16376
16515
|
dir,
|
|
16377
|
-
gitdir =
|
|
16516
|
+
gitdir = join42(dir, ".git"),
|
|
16378
16517
|
filepath
|
|
16379
16518
|
}) {
|
|
16380
16519
|
try {
|
|
@@ -16398,7 +16537,7 @@ gpgsig`));
|
|
|
16398
16537
|
async function listBranches({
|
|
16399
16538
|
fs: fs2,
|
|
16400
16539
|
dir,
|
|
16401
|
-
gitdir =
|
|
16540
|
+
gitdir = join42(dir, ".git"),
|
|
16402
16541
|
remote
|
|
16403
16542
|
}) {
|
|
16404
16543
|
try {
|
|
@@ -16452,17 +16591,17 @@ gpgsig`));
|
|
|
16452
16591
|
gitdir,
|
|
16453
16592
|
oid: entry.oid,
|
|
16454
16593
|
filenames,
|
|
16455
|
-
prefix:
|
|
16594
|
+
prefix: join42(prefix, entry.path)
|
|
16456
16595
|
});
|
|
16457
16596
|
} else {
|
|
16458
|
-
filenames.push(
|
|
16597
|
+
filenames.push(join42(prefix, entry.path));
|
|
16459
16598
|
}
|
|
16460
16599
|
}
|
|
16461
16600
|
}
|
|
16462
16601
|
async function listFiles({
|
|
16463
16602
|
fs: fs2,
|
|
16464
16603
|
dir,
|
|
16465
|
-
gitdir =
|
|
16604
|
+
gitdir = join42(dir, ".git"),
|
|
16466
16605
|
ref,
|
|
16467
16606
|
cache = {}
|
|
16468
16607
|
}) {
|
|
@@ -16506,7 +16645,7 @@ gpgsig`));
|
|
|
16506
16645
|
async function listNotes({
|
|
16507
16646
|
fs: fs2,
|
|
16508
16647
|
dir,
|
|
16509
|
-
gitdir =
|
|
16648
|
+
gitdir = join42(dir, ".git"),
|
|
16510
16649
|
ref = "refs/notes/commits",
|
|
16511
16650
|
cache = {}
|
|
16512
16651
|
}) {
|
|
@@ -16530,7 +16669,7 @@ gpgsig`));
|
|
|
16530
16669
|
async function listRefs({
|
|
16531
16670
|
fs: fs2,
|
|
16532
16671
|
dir,
|
|
16533
|
-
gitdir =
|
|
16672
|
+
gitdir = join42(dir, ".git"),
|
|
16534
16673
|
filepath
|
|
16535
16674
|
}) {
|
|
16536
16675
|
try {
|
|
@@ -16553,7 +16692,7 @@ gpgsig`));
|
|
|
16553
16692
|
}));
|
|
16554
16693
|
return remotes;
|
|
16555
16694
|
}
|
|
16556
|
-
async function listRemotes({ fs: fs2, dir, gitdir =
|
|
16695
|
+
async function listRemotes({ fs: fs2, dir, gitdir = join42(dir, ".git") }) {
|
|
16557
16696
|
try {
|
|
16558
16697
|
assertParameter("fs", fs2);
|
|
16559
16698
|
assertParameter("gitdir", gitdir);
|
|
@@ -16658,7 +16797,7 @@ gpgsig`));
|
|
|
16658
16797
|
throw err;
|
|
16659
16798
|
}
|
|
16660
16799
|
}
|
|
16661
|
-
async function listTags({ fs: fs2, dir, gitdir =
|
|
16800
|
+
async function listTags({ fs: fs2, dir, gitdir = join42(dir, ".git") }) {
|
|
16662
16801
|
try {
|
|
16663
16802
|
assertParameter("fs", fs2);
|
|
16664
16803
|
assertParameter("gitdir", gitdir);
|
|
@@ -16714,7 +16853,7 @@ gpgsig`));
|
|
|
16714
16853
|
const walks = tree.entries().map(function(entry) {
|
|
16715
16854
|
let result;
|
|
16716
16855
|
if (entry.oid === fileId) {
|
|
16717
|
-
result =
|
|
16856
|
+
result = join42(parentPath, entry.path);
|
|
16718
16857
|
filepaths.push(result);
|
|
16719
16858
|
} else if (entry.type === "tree") {
|
|
16720
16859
|
result = _readObject({
|
|
@@ -16731,7 +16870,7 @@ gpgsig`));
|
|
|
16731
16870
|
fileId,
|
|
16732
16871
|
oid,
|
|
16733
16872
|
filepaths,
|
|
16734
|
-
parentPath:
|
|
16873
|
+
parentPath: join42(parentPath, entry.path)
|
|
16735
16874
|
});
|
|
16736
16875
|
});
|
|
16737
16876
|
}
|
|
@@ -16866,7 +17005,7 @@ gpgsig`));
|
|
|
16866
17005
|
async function log({
|
|
16867
17006
|
fs: fs2,
|
|
16868
17007
|
dir,
|
|
16869
|
-
gitdir =
|
|
17008
|
+
gitdir = join42(dir, ".git"),
|
|
16870
17009
|
filepath,
|
|
16871
17010
|
ref = "HEAD",
|
|
16872
17011
|
depth,
|
|
@@ -16901,7 +17040,7 @@ gpgsig`));
|
|
|
16901
17040
|
fs: _fs,
|
|
16902
17041
|
onSign,
|
|
16903
17042
|
dir,
|
|
16904
|
-
gitdir =
|
|
17043
|
+
gitdir = join42(dir, ".git"),
|
|
16905
17044
|
ours,
|
|
16906
17045
|
theirs,
|
|
16907
17046
|
fastForward: fastForward2 = true,
|
|
@@ -16978,7 +17117,7 @@ gpgsig`));
|
|
|
16978
17117
|
fs: fs2,
|
|
16979
17118
|
cache,
|
|
16980
17119
|
dir,
|
|
16981
|
-
gitdir =
|
|
17120
|
+
gitdir = join42(dir, ".git"),
|
|
16982
17121
|
oids
|
|
16983
17122
|
}) {
|
|
16984
17123
|
const hash = new Hash;
|
|
@@ -17021,7 +17160,7 @@ gpgsig`));
|
|
|
17021
17160
|
const packfileSha = packfile.slice(-20).toString("hex");
|
|
17022
17161
|
const filename = `pack-${packfileSha}.pack`;
|
|
17023
17162
|
if (write) {
|
|
17024
|
-
await fs2.write(
|
|
17163
|
+
await fs2.write(join42(gitdir, `objects/pack/${filename}`), packfile);
|
|
17025
17164
|
return { filename };
|
|
17026
17165
|
}
|
|
17027
17166
|
return {
|
|
@@ -17032,7 +17171,7 @@ gpgsig`));
|
|
|
17032
17171
|
async function packObjects({
|
|
17033
17172
|
fs: fs2,
|
|
17034
17173
|
dir,
|
|
17035
|
-
gitdir =
|
|
17174
|
+
gitdir = join42(dir, ".git"),
|
|
17036
17175
|
oids,
|
|
17037
17176
|
write = false,
|
|
17038
17177
|
cache = {}
|
|
@@ -17064,7 +17203,7 @@ gpgsig`));
|
|
|
17064
17203
|
onAuthSuccess,
|
|
17065
17204
|
onAuthFailure,
|
|
17066
17205
|
dir,
|
|
17067
|
-
gitdir =
|
|
17206
|
+
gitdir = join42(dir, ".git"),
|
|
17068
17207
|
ref,
|
|
17069
17208
|
url,
|
|
17070
17209
|
remote,
|
|
@@ -17136,7 +17275,7 @@ gpgsig`));
|
|
|
17136
17275
|
fs: fs2,
|
|
17137
17276
|
cache,
|
|
17138
17277
|
dir,
|
|
17139
|
-
gitdir =
|
|
17278
|
+
gitdir = join42(dir, ".git"),
|
|
17140
17279
|
start,
|
|
17141
17280
|
finish
|
|
17142
17281
|
}) {
|
|
@@ -17183,7 +17322,7 @@ gpgsig`));
|
|
|
17183
17322
|
fs: fs2,
|
|
17184
17323
|
cache,
|
|
17185
17324
|
dir,
|
|
17186
|
-
gitdir =
|
|
17325
|
+
gitdir = join42(dir, ".git"),
|
|
17187
17326
|
oids
|
|
17188
17327
|
}) {
|
|
17189
17328
|
const visited = new Set;
|
|
@@ -17476,7 +17615,7 @@ gpgsig`));
|
|
|
17476
17615
|
onAuthFailure,
|
|
17477
17616
|
onPrePush,
|
|
17478
17617
|
dir,
|
|
17479
|
-
gitdir =
|
|
17618
|
+
gitdir = join42(dir, ".git"),
|
|
17480
17619
|
ref,
|
|
17481
17620
|
remoteRef,
|
|
17482
17621
|
remote = "origin",
|
|
@@ -17550,7 +17689,7 @@ gpgsig`));
|
|
|
17550
17689
|
async function readBlob({
|
|
17551
17690
|
fs: fs2,
|
|
17552
17691
|
dir,
|
|
17553
|
-
gitdir =
|
|
17692
|
+
gitdir = join42(dir, ".git"),
|
|
17554
17693
|
oid,
|
|
17555
17694
|
filepath,
|
|
17556
17695
|
cache = {}
|
|
@@ -17576,7 +17715,7 @@ gpgsig`));
|
|
|
17576
17715
|
async function readCommit({
|
|
17577
17716
|
fs: fs2,
|
|
17578
17717
|
dir,
|
|
17579
|
-
gitdir =
|
|
17718
|
+
gitdir = join42(dir, ".git"),
|
|
17580
17719
|
oid,
|
|
17581
17720
|
cache = {}
|
|
17582
17721
|
}) {
|
|
@@ -17617,7 +17756,7 @@ gpgsig`));
|
|
|
17617
17756
|
async function readNote({
|
|
17618
17757
|
fs: fs2,
|
|
17619
17758
|
dir,
|
|
17620
|
-
gitdir =
|
|
17759
|
+
gitdir = join42(dir, ".git"),
|
|
17621
17760
|
ref = "refs/notes/commits",
|
|
17622
17761
|
oid,
|
|
17623
17762
|
cache = {}
|
|
@@ -17644,7 +17783,7 @@ gpgsig`));
|
|
|
17644
17783
|
async function readObject({
|
|
17645
17784
|
fs: _fs,
|
|
17646
17785
|
dir,
|
|
17647
|
-
gitdir =
|
|
17786
|
+
gitdir = join42(dir, ".git"),
|
|
17648
17787
|
oid,
|
|
17649
17788
|
format = "parsed",
|
|
17650
17789
|
filepath = undefined,
|
|
@@ -17729,7 +17868,7 @@ gpgsig`));
|
|
|
17729
17868
|
async function readTag({
|
|
17730
17869
|
fs: fs2,
|
|
17731
17870
|
dir,
|
|
17732
|
-
gitdir =
|
|
17871
|
+
gitdir = join42(dir, ".git"),
|
|
17733
17872
|
oid,
|
|
17734
17873
|
cache = {}
|
|
17735
17874
|
}) {
|
|
@@ -17753,7 +17892,7 @@ gpgsig`));
|
|
|
17753
17892
|
async function readTree({
|
|
17754
17893
|
fs: fs2,
|
|
17755
17894
|
dir,
|
|
17756
|
-
gitdir =
|
|
17895
|
+
gitdir = join42(dir, ".git"),
|
|
17757
17896
|
oid,
|
|
17758
17897
|
filepath = undefined,
|
|
17759
17898
|
cache = {}
|
|
@@ -17779,7 +17918,7 @@ gpgsig`));
|
|
|
17779
17918
|
async function remove({
|
|
17780
17919
|
fs: _fs,
|
|
17781
17920
|
dir,
|
|
17782
|
-
gitdir =
|
|
17921
|
+
gitdir = join42(dir, ".git"),
|
|
17783
17922
|
filepath,
|
|
17784
17923
|
cache = {}
|
|
17785
17924
|
}) {
|
|
@@ -17849,7 +17988,7 @@ gpgsig`));
|
|
|
17849
17988
|
fs: _fs,
|
|
17850
17989
|
onSign,
|
|
17851
17990
|
dir,
|
|
17852
|
-
gitdir =
|
|
17991
|
+
gitdir = join42(dir, ".git"),
|
|
17853
17992
|
ref = "refs/notes/commits",
|
|
17854
17993
|
oid,
|
|
17855
17994
|
author: _author,
|
|
@@ -17939,7 +18078,7 @@ gpgsig`));
|
|
|
17939
18078
|
async function renameBranch({
|
|
17940
18079
|
fs: fs2,
|
|
17941
18080
|
dir,
|
|
17942
|
-
gitdir =
|
|
18081
|
+
gitdir = join42(dir, ".git"),
|
|
17943
18082
|
ref,
|
|
17944
18083
|
oldref,
|
|
17945
18084
|
checkout: checkout2 = false
|
|
@@ -17969,7 +18108,7 @@ gpgsig`));
|
|
|
17969
18108
|
async function resetIndex({
|
|
17970
18109
|
fs: _fs,
|
|
17971
18110
|
dir,
|
|
17972
|
-
gitdir =
|
|
18111
|
+
gitdir = join42(dir, ".git"),
|
|
17973
18112
|
filepath,
|
|
17974
18113
|
ref,
|
|
17975
18114
|
cache = {}
|
|
@@ -18016,7 +18155,7 @@ gpgsig`));
|
|
|
18016
18155
|
gid: 0,
|
|
18017
18156
|
size: 0
|
|
18018
18157
|
};
|
|
18019
|
-
const object = dir && await fs2.read(
|
|
18158
|
+
const object = dir && await fs2.read(join42(dir, filepath));
|
|
18020
18159
|
if (object) {
|
|
18021
18160
|
workdirOid = await hashObject$1({
|
|
18022
18161
|
gitdir: updatedGitdir,
|
|
@@ -18024,7 +18163,7 @@ gpgsig`));
|
|
|
18024
18163
|
object
|
|
18025
18164
|
});
|
|
18026
18165
|
if (oid === workdirOid) {
|
|
18027
|
-
stats = await fs2.lstat(
|
|
18166
|
+
stats = await fs2.lstat(join42(dir, filepath));
|
|
18028
18167
|
}
|
|
18029
18168
|
}
|
|
18030
18169
|
await GitIndexManager.acquire({ fs: fs2, gitdir: updatedGitdir, cache }, async function(index2) {
|
|
@@ -18041,7 +18180,7 @@ gpgsig`));
|
|
|
18041
18180
|
async function resolveRef({
|
|
18042
18181
|
fs: fs2,
|
|
18043
18182
|
dir,
|
|
18044
|
-
gitdir =
|
|
18183
|
+
gitdir = join42(dir, ".git"),
|
|
18045
18184
|
ref,
|
|
18046
18185
|
depth
|
|
18047
18186
|
}) {
|
|
@@ -18066,7 +18205,7 @@ gpgsig`));
|
|
|
18066
18205
|
async function setConfig({
|
|
18067
18206
|
fs: _fs,
|
|
18068
18207
|
dir,
|
|
18069
|
-
gitdir =
|
|
18208
|
+
gitdir = join42(dir, ".git"),
|
|
18070
18209
|
path,
|
|
18071
18210
|
value,
|
|
18072
18211
|
append = false
|
|
@@ -18135,7 +18274,7 @@ gpgsig`));
|
|
|
18135
18274
|
return lock$3.acquire(ref, callback);
|
|
18136
18275
|
}
|
|
18137
18276
|
async function checkAndWriteBlob(fs2, gitdir, dir, filepath, oid = null) {
|
|
18138
|
-
const currentFilepath =
|
|
18277
|
+
const currentFilepath = join42(dir, filepath);
|
|
18139
18278
|
const stats = await fs2.lstat(currentFilepath);
|
|
18140
18279
|
if (!stats)
|
|
18141
18280
|
throw new NotFoundError(currentFilepath);
|
|
@@ -18298,7 +18437,7 @@ gpgsig`));
|
|
|
18298
18437
|
stageUpdated.push({
|
|
18299
18438
|
filepath,
|
|
18300
18439
|
oid,
|
|
18301
|
-
stats: await fs2.lstat(
|
|
18440
|
+
stats: await fs2.lstat(join42(dir, filepath))
|
|
18302
18441
|
});
|
|
18303
18442
|
return {
|
|
18304
18443
|
method: "write",
|
|
@@ -18311,7 +18450,7 @@ gpgsig`));
|
|
|
18311
18450
|
});
|
|
18312
18451
|
await acquireLock$1({ fs: fs2, gitdir, dirRemoved, ops }, async () => {
|
|
18313
18452
|
for (const op of ops) {
|
|
18314
|
-
const currentFilepath =
|
|
18453
|
+
const currentFilepath = join42(dir, op.filepath);
|
|
18315
18454
|
switch (op.method) {
|
|
18316
18455
|
case "rmdir":
|
|
18317
18456
|
await fs2.rmdir(currentFilepath);
|
|
@@ -18347,7 +18486,7 @@ gpgsig`));
|
|
|
18347
18486
|
}
|
|
18348
18487
|
|
|
18349
18488
|
class GitStashManager {
|
|
18350
|
-
constructor({ fs: fs2, dir, gitdir =
|
|
18489
|
+
constructor({ fs: fs2, dir, gitdir = join42(dir, ".git") }) {
|
|
18351
18490
|
Object.assign(this, {
|
|
18352
18491
|
fs: fs2,
|
|
18353
18492
|
dir,
|
|
@@ -18362,10 +18501,10 @@ gpgsig`));
|
|
|
18362
18501
|
return "logs/refs/stash";
|
|
18363
18502
|
}
|
|
18364
18503
|
get refStashPath() {
|
|
18365
|
-
return
|
|
18504
|
+
return join42(this.gitdir, GitStashManager.refStash);
|
|
18366
18505
|
}
|
|
18367
18506
|
get refLogsStashPath() {
|
|
18368
|
-
return
|
|
18507
|
+
return join42(this.gitdir, GitStashManager.refLogsStash);
|
|
18369
18508
|
}
|
|
18370
18509
|
async getAuthor() {
|
|
18371
18510
|
if (!this._author) {
|
|
@@ -18610,7 +18749,7 @@ gpgsig`));
|
|
|
18610
18749
|
async function stash({
|
|
18611
18750
|
fs: fs2,
|
|
18612
18751
|
dir,
|
|
18613
|
-
gitdir =
|
|
18752
|
+
gitdir = join42(dir, ".git"),
|
|
18614
18753
|
op = "push",
|
|
18615
18754
|
message = "",
|
|
18616
18755
|
refIdx = 0
|
|
@@ -18633,7 +18772,7 @@ gpgsig`));
|
|
|
18633
18772
|
const _fs = new FileSystem(fs2);
|
|
18634
18773
|
const updatedGitdir = await discoverGitdir({ fsp: _fs, dotgit: gitdir });
|
|
18635
18774
|
const folders = ["refs", "logs", "logs/refs"];
|
|
18636
|
-
folders.map((f) =>
|
|
18775
|
+
folders.map((f) => join42(updatedGitdir, f)).forEach(async (folder) => {
|
|
18637
18776
|
if (!await _fs.exists(folder)) {
|
|
18638
18777
|
await _fs.mkdir(folder);
|
|
18639
18778
|
}
|
|
@@ -18660,7 +18799,7 @@ gpgsig`));
|
|
|
18660
18799
|
async function status({
|
|
18661
18800
|
fs: _fs,
|
|
18662
18801
|
dir,
|
|
18663
|
-
gitdir =
|
|
18802
|
+
gitdir = join42(dir, ".git"),
|
|
18664
18803
|
filepath,
|
|
18665
18804
|
cache = {}
|
|
18666
18805
|
}) {
|
|
@@ -18694,7 +18833,7 @@ gpgsig`));
|
|
|
18694
18833
|
}
|
|
18695
18834
|
return null;
|
|
18696
18835
|
});
|
|
18697
|
-
const stats = await fs2.lstat(
|
|
18836
|
+
const stats = await fs2.lstat(join42(dir, filepath));
|
|
18698
18837
|
const H = treeOid !== null;
|
|
18699
18838
|
const I = indexEntry !== null;
|
|
18700
18839
|
const W = stats !== null;
|
|
@@ -18702,7 +18841,7 @@ gpgsig`));
|
|
|
18702
18841
|
if (I && !compareStats(indexEntry, stats)) {
|
|
18703
18842
|
return indexEntry.oid;
|
|
18704
18843
|
} else {
|
|
18705
|
-
const object = await fs2.read(
|
|
18844
|
+
const object = await fs2.read(join42(dir, filepath));
|
|
18706
18845
|
const workdirOid = await hashObject$1({
|
|
18707
18846
|
gitdir: updatedGitdir,
|
|
18708
18847
|
type: "blob",
|
|
@@ -18795,7 +18934,7 @@ gpgsig`));
|
|
|
18795
18934
|
async function statusMatrix({
|
|
18796
18935
|
fs: _fs,
|
|
18797
18936
|
dir,
|
|
18798
|
-
gitdir =
|
|
18937
|
+
gitdir = join42(dir, ".git"),
|
|
18799
18938
|
ref = "HEAD",
|
|
18800
18939
|
filepaths = ["."],
|
|
18801
18940
|
filter,
|
|
@@ -18872,7 +19011,7 @@ gpgsig`));
|
|
|
18872
19011
|
async function tag({
|
|
18873
19012
|
fs: _fs,
|
|
18874
19013
|
dir,
|
|
18875
|
-
gitdir =
|
|
19014
|
+
gitdir = join42(dir, ".git"),
|
|
18876
19015
|
ref,
|
|
18877
19016
|
object,
|
|
18878
19017
|
force = false
|
|
@@ -18904,7 +19043,7 @@ gpgsig`));
|
|
|
18904
19043
|
async function updateIndex$1({
|
|
18905
19044
|
fs: _fs,
|
|
18906
19045
|
dir,
|
|
18907
|
-
gitdir =
|
|
19046
|
+
gitdir = join42(dir, ".git"),
|
|
18908
19047
|
cache = {},
|
|
18909
19048
|
filepath,
|
|
18910
19049
|
oid,
|
|
@@ -18922,7 +19061,7 @@ gpgsig`));
|
|
|
18922
19061
|
if (remove2) {
|
|
18923
19062
|
return await GitIndexManager.acquire({ fs: fs2, gitdir: updatedGitdir, cache }, async function(index2) {
|
|
18924
19063
|
if (!force) {
|
|
18925
|
-
const fileStats2 = await fs2.lstat(
|
|
19064
|
+
const fileStats2 = await fs2.lstat(join42(dir, filepath));
|
|
18926
19065
|
if (fileStats2) {
|
|
18927
19066
|
if (fileStats2.isDirectory()) {
|
|
18928
19067
|
throw new InvalidFilepathError("directory");
|
|
@@ -18939,7 +19078,7 @@ gpgsig`));
|
|
|
18939
19078
|
}
|
|
18940
19079
|
let fileStats;
|
|
18941
19080
|
if (!oid) {
|
|
18942
|
-
fileStats = await fs2.lstat(
|
|
19081
|
+
fileStats = await fs2.lstat(join42(dir, filepath));
|
|
18943
19082
|
if (!fileStats) {
|
|
18944
19083
|
throw new NotFoundError(`file at "${filepath}" on disk and "remove" not set`);
|
|
18945
19084
|
}
|
|
@@ -18954,7 +19093,7 @@ gpgsig`));
|
|
|
18954
19093
|
let stats;
|
|
18955
19094
|
if (!oid) {
|
|
18956
19095
|
stats = fileStats;
|
|
18957
|
-
const object = stats.isSymbolicLink() ? await fs2.readlink(
|
|
19096
|
+
const object = stats.isSymbolicLink() ? await fs2.readlink(join42(dir, filepath)) : await fs2.read(join42(dir, filepath));
|
|
18958
19097
|
oid = await _writeObject({
|
|
18959
19098
|
fs: fs2,
|
|
18960
19099
|
gitdir: updatedGitdir,
|
|
@@ -18997,7 +19136,7 @@ gpgsig`));
|
|
|
18997
19136
|
async function walk({
|
|
18998
19137
|
fs: fs2,
|
|
18999
19138
|
dir,
|
|
19000
|
-
gitdir =
|
|
19139
|
+
gitdir = join42(dir, ".git"),
|
|
19001
19140
|
trees,
|
|
19002
19141
|
map,
|
|
19003
19142
|
reduce,
|
|
@@ -19025,7 +19164,7 @@ gpgsig`));
|
|
|
19025
19164
|
throw err;
|
|
19026
19165
|
}
|
|
19027
19166
|
}
|
|
19028
|
-
async function writeBlob({ fs: fs2, dir, gitdir =
|
|
19167
|
+
async function writeBlob({ fs: fs2, dir, gitdir = join42(dir, ".git"), blob }) {
|
|
19029
19168
|
try {
|
|
19030
19169
|
assertParameter("fs", fs2);
|
|
19031
19170
|
assertParameter("gitdir", gitdir);
|
|
@@ -19047,7 +19186,7 @@ gpgsig`));
|
|
|
19047
19186
|
async function writeCommit({
|
|
19048
19187
|
fs: fs2,
|
|
19049
19188
|
dir,
|
|
19050
|
-
gitdir =
|
|
19189
|
+
gitdir = join42(dir, ".git"),
|
|
19051
19190
|
commit: commit2
|
|
19052
19191
|
}) {
|
|
19053
19192
|
try {
|
|
@@ -19069,7 +19208,7 @@ gpgsig`));
|
|
|
19069
19208
|
async function writeObject({
|
|
19070
19209
|
fs: _fs,
|
|
19071
19210
|
dir,
|
|
19072
|
-
gitdir =
|
|
19211
|
+
gitdir = join42(dir, ".git"),
|
|
19073
19212
|
type,
|
|
19074
19213
|
object,
|
|
19075
19214
|
format = "parsed",
|
|
@@ -19115,7 +19254,7 @@ gpgsig`));
|
|
|
19115
19254
|
async function writeRef({
|
|
19116
19255
|
fs: _fs,
|
|
19117
19256
|
dir,
|
|
19118
|
-
gitdir =
|
|
19257
|
+
gitdir = join42(dir, ".git"),
|
|
19119
19258
|
ref,
|
|
19120
19259
|
value,
|
|
19121
19260
|
force = false,
|
|
@@ -19170,7 +19309,7 @@ gpgsig`));
|
|
|
19170
19309
|
});
|
|
19171
19310
|
return oid;
|
|
19172
19311
|
}
|
|
19173
|
-
async function writeTag({ fs: fs2, dir, gitdir =
|
|
19312
|
+
async function writeTag({ fs: fs2, dir, gitdir = join42(dir, ".git"), tag: tag2 }) {
|
|
19174
19313
|
try {
|
|
19175
19314
|
assertParameter("fs", fs2);
|
|
19176
19315
|
assertParameter("gitdir", gitdir);
|
|
@@ -19187,7 +19326,7 @@ gpgsig`));
|
|
|
19187
19326
|
throw err;
|
|
19188
19327
|
}
|
|
19189
19328
|
}
|
|
19190
|
-
async function writeTree({ fs: fs2, dir, gitdir =
|
|
19329
|
+
async function writeTree({ fs: fs2, dir, gitdir = join42(dir, ".git"), tree }) {
|
|
19191
19330
|
try {
|
|
19192
19331
|
assertParameter("fs", fs2);
|
|
19193
19332
|
assertParameter("gitdir", gitdir);
|
|
@@ -22645,13 +22784,13 @@ var require_readable = __commonJS((exports, module) => {
|
|
|
22645
22784
|
return state[kPaused] === true || state.flowing === false;
|
|
22646
22785
|
};
|
|
22647
22786
|
Readable.prototype.setEncoding = function(enc) {
|
|
22648
|
-
const
|
|
22649
|
-
this._readableState.decoder =
|
|
22787
|
+
const decoder4 = new StringDecoder(enc);
|
|
22788
|
+
this._readableState.decoder = decoder4;
|
|
22650
22789
|
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
22651
22790
|
const buffer = this._readableState.buffer;
|
|
22652
22791
|
let content = "";
|
|
22653
22792
|
for (const data of buffer) {
|
|
22654
|
-
content +=
|
|
22793
|
+
content += decoder4.write(data);
|
|
22655
22794
|
}
|
|
22656
22795
|
buffer.clear();
|
|
22657
22796
|
if (content !== "")
|
|
@@ -25727,12 +25866,6 @@ var require_ours = __commonJS((exports, module) => {
|
|
|
25727
25866
|
}
|
|
25728
25867
|
module.exports.default = module.exports;
|
|
25729
25868
|
});
|
|
25730
|
-
function isRemoteConfig(config) {
|
|
25731
|
-
return config !== undefined && "endpoint" in config;
|
|
25732
|
-
}
|
|
25733
|
-
function isGitConfig(config) {
|
|
25734
|
-
return config !== undefined && "type" in config && config.type === "git";
|
|
25735
|
-
}
|
|
25736
25869
|
|
|
25737
25870
|
class ResourceXError3 extends Error {
|
|
25738
25871
|
constructor(message, options) {
|
|
@@ -26948,9 +27081,81 @@ async function unpackTar3(archive, options = {}) {
|
|
|
26948
27081
|
var gzipAsync22 = promisify22(gzip22);
|
|
26949
27082
|
var gunzipAsync22 = promisify22(gunzip22);
|
|
26950
27083
|
|
|
26951
|
-
class
|
|
27084
|
+
class RXPImpl3 {
|
|
27085
|
+
_files;
|
|
27086
|
+
_pathsCache = null;
|
|
27087
|
+
_treeCache = null;
|
|
27088
|
+
constructor(files) {
|
|
27089
|
+
this._files = files;
|
|
27090
|
+
}
|
|
27091
|
+
paths() {
|
|
27092
|
+
if (this._pathsCache) {
|
|
27093
|
+
return this._pathsCache;
|
|
27094
|
+
}
|
|
27095
|
+
this._pathsCache = Array.from(this._files.keys()).sort();
|
|
27096
|
+
return this._pathsCache;
|
|
27097
|
+
}
|
|
27098
|
+
tree() {
|
|
27099
|
+
if (this._treeCache) {
|
|
27100
|
+
return this._treeCache;
|
|
27101
|
+
}
|
|
27102
|
+
const root = new Map;
|
|
27103
|
+
for (const path of this._files.keys()) {
|
|
27104
|
+
const parts = path.split("/");
|
|
27105
|
+
let currentLevel = root;
|
|
27106
|
+
for (let i = 0;i < parts.length; i++) {
|
|
27107
|
+
const part = parts[i];
|
|
27108
|
+
const isFile = i === parts.length - 1;
|
|
27109
|
+
if (!currentLevel.has(part)) {
|
|
27110
|
+
const treeNode2 = {
|
|
27111
|
+
node: {
|
|
27112
|
+
name: part,
|
|
27113
|
+
type: isFile ? "file" : "directory",
|
|
27114
|
+
children: isFile ? undefined : []
|
|
27115
|
+
},
|
|
27116
|
+
children: new Map
|
|
27117
|
+
};
|
|
27118
|
+
currentLevel.set(part, treeNode2);
|
|
27119
|
+
}
|
|
27120
|
+
const treeNode = currentLevel.get(part);
|
|
27121
|
+
if (!isFile) {
|
|
27122
|
+
currentLevel = treeNode.children;
|
|
27123
|
+
}
|
|
27124
|
+
}
|
|
27125
|
+
}
|
|
27126
|
+
const convertToPathNodes = (level) => {
|
|
27127
|
+
return Array.from(level.values()).map((treeNode) => {
|
|
27128
|
+
if (treeNode.node.type === "directory" && treeNode.children.size > 0) {
|
|
27129
|
+
treeNode.node.children = convertToPathNodes(treeNode.children);
|
|
27130
|
+
}
|
|
27131
|
+
return treeNode.node;
|
|
27132
|
+
});
|
|
27133
|
+
};
|
|
27134
|
+
this._treeCache = convertToPathNodes(root);
|
|
27135
|
+
return this._treeCache;
|
|
27136
|
+
}
|
|
27137
|
+
async file(path) {
|
|
27138
|
+
const content = this._files.get(path);
|
|
27139
|
+
if (!content) {
|
|
27140
|
+
throw new ContentError3(`file not found: ${path}`);
|
|
27141
|
+
}
|
|
27142
|
+
return content;
|
|
27143
|
+
}
|
|
27144
|
+
async files() {
|
|
27145
|
+
return new Map(this._files);
|
|
27146
|
+
}
|
|
27147
|
+
async pack() {
|
|
27148
|
+
const filesRecord = {};
|
|
27149
|
+
for (const [path, content] of this._files) {
|
|
27150
|
+
filesRecord[path] = content;
|
|
27151
|
+
}
|
|
27152
|
+
return createRXA3(filesRecord);
|
|
27153
|
+
}
|
|
27154
|
+
}
|
|
27155
|
+
|
|
27156
|
+
class RXAImpl3 {
|
|
26952
27157
|
_buffer;
|
|
26953
|
-
|
|
27158
|
+
_rxpCache = null;
|
|
26954
27159
|
constructor(buffer) {
|
|
26955
27160
|
this._buffer = buffer;
|
|
26956
27161
|
}
|
|
@@ -26966,17 +27171,9 @@ class RXCImpl3 {
|
|
|
26966
27171
|
async buffer() {
|
|
26967
27172
|
return this._buffer;
|
|
26968
27173
|
}
|
|
26969
|
-
async
|
|
26970
|
-
|
|
26971
|
-
|
|
26972
|
-
if (!content) {
|
|
26973
|
-
throw new ContentError3(`file not found: ${path}`);
|
|
26974
|
-
}
|
|
26975
|
-
return content;
|
|
26976
|
-
}
|
|
26977
|
-
async files() {
|
|
26978
|
-
if (this._filesCache) {
|
|
26979
|
-
return this._filesCache;
|
|
27174
|
+
async extract() {
|
|
27175
|
+
if (this._rxpCache) {
|
|
27176
|
+
return this._rxpCache;
|
|
26980
27177
|
}
|
|
26981
27178
|
const tarBuffer = await gunzipAsync22(this._buffer);
|
|
26982
27179
|
const entries = await unpackTar3(tarBuffer);
|
|
@@ -26986,16 +27183,16 @@ class RXCImpl3 {
|
|
|
26986
27183
|
filesMap.set(entry.header.name, Buffer.from(entry.data));
|
|
26987
27184
|
}
|
|
26988
27185
|
}
|
|
26989
|
-
this.
|
|
26990
|
-
return
|
|
27186
|
+
this._rxpCache = new RXPImpl3(filesMap);
|
|
27187
|
+
return this._rxpCache;
|
|
26991
27188
|
}
|
|
26992
27189
|
}
|
|
26993
|
-
function
|
|
26994
|
-
return "
|
|
27190
|
+
function isBufferInput3(input) {
|
|
27191
|
+
return "buffer" in input && Buffer.isBuffer(input.buffer);
|
|
26995
27192
|
}
|
|
26996
|
-
async function
|
|
26997
|
-
if (
|
|
26998
|
-
return new
|
|
27193
|
+
async function createRXA3(input) {
|
|
27194
|
+
if (isBufferInput3(input)) {
|
|
27195
|
+
return new RXAImpl3(input.buffer);
|
|
26999
27196
|
}
|
|
27000
27197
|
const entries = Object.entries(input).map(([name, content]) => {
|
|
27001
27198
|
const body = typeof content === "string" ? content : content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
@@ -27007,7 +27204,7 @@ async function createRXC3(input) {
|
|
|
27007
27204
|
});
|
|
27008
27205
|
const tarBuffer = await packTar3(entries);
|
|
27009
27206
|
const gzipBuffer = await gzipAsync22(Buffer.from(tarBuffer));
|
|
27010
|
-
return new
|
|
27207
|
+
return new RXAImpl3(gzipBuffer);
|
|
27011
27208
|
}
|
|
27012
27209
|
|
|
27013
27210
|
class ResourceTypeError2 extends ResourceXError22 {
|
|
@@ -27018,13 +27215,13 @@ class ResourceTypeError2 extends ResourceXError22 {
|
|
|
27018
27215
|
}
|
|
27019
27216
|
var textSerializer2 = {
|
|
27020
27217
|
async serialize(rxr) {
|
|
27021
|
-
return rxr.
|
|
27218
|
+
return rxr.archive.buffer();
|
|
27022
27219
|
},
|
|
27023
27220
|
async deserialize(data, manifest) {
|
|
27024
27221
|
return {
|
|
27025
27222
|
locator: parseRXL22(manifest.toLocator()),
|
|
27026
27223
|
manifest,
|
|
27027
|
-
|
|
27224
|
+
archive: await createRXA3({ buffer: data })
|
|
27028
27225
|
};
|
|
27029
27226
|
}
|
|
27030
27227
|
};
|
|
@@ -27035,7 +27232,8 @@ var textResolver2 = {
|
|
|
27035
27232
|
resource: rxr,
|
|
27036
27233
|
schema: undefined,
|
|
27037
27234
|
execute: async () => {
|
|
27038
|
-
const
|
|
27235
|
+
const pkg = await rxr.archive.extract();
|
|
27236
|
+
const buffer = await pkg.file("content");
|
|
27039
27237
|
return buffer.toString("utf-8");
|
|
27040
27238
|
}
|
|
27041
27239
|
};
|
|
@@ -27050,13 +27248,13 @@ var textType2 = {
|
|
|
27050
27248
|
};
|
|
27051
27249
|
var jsonSerializer2 = {
|
|
27052
27250
|
async serialize(rxr) {
|
|
27053
|
-
return rxr.
|
|
27251
|
+
return rxr.archive.buffer();
|
|
27054
27252
|
},
|
|
27055
27253
|
async deserialize(data, manifest) {
|
|
27056
27254
|
return {
|
|
27057
27255
|
locator: parseRXL22(manifest.toLocator()),
|
|
27058
27256
|
manifest,
|
|
27059
|
-
|
|
27257
|
+
archive: await createRXA3({ buffer: data })
|
|
27060
27258
|
};
|
|
27061
27259
|
}
|
|
27062
27260
|
};
|
|
@@ -27067,7 +27265,8 @@ var jsonResolver2 = {
|
|
|
27067
27265
|
resource: rxr,
|
|
27068
27266
|
schema: undefined,
|
|
27069
27267
|
execute: async () => {
|
|
27070
|
-
const
|
|
27268
|
+
const pkg = await rxr.archive.extract();
|
|
27269
|
+
const buffer = await pkg.file("content");
|
|
27071
27270
|
return JSON.parse(buffer.toString("utf-8"));
|
|
27072
27271
|
}
|
|
27073
27272
|
};
|
|
@@ -27082,13 +27281,13 @@ var jsonType2 = {
|
|
|
27082
27281
|
};
|
|
27083
27282
|
var binarySerializer2 = {
|
|
27084
27283
|
async serialize(rxr) {
|
|
27085
|
-
return rxr.
|
|
27284
|
+
return rxr.archive.buffer();
|
|
27086
27285
|
},
|
|
27087
27286
|
async deserialize(data, manifest) {
|
|
27088
27287
|
return {
|
|
27089
27288
|
locator: parseRXL22(manifest.toLocator()),
|
|
27090
27289
|
manifest,
|
|
27091
|
-
|
|
27290
|
+
archive: await createRXA3({ buffer: data })
|
|
27092
27291
|
};
|
|
27093
27292
|
}
|
|
27094
27293
|
};
|
|
@@ -27099,7 +27298,8 @@ var binaryResolver2 = {
|
|
|
27099
27298
|
resource: rxr,
|
|
27100
27299
|
schema: undefined,
|
|
27101
27300
|
execute: async () => {
|
|
27102
|
-
|
|
27301
|
+
const pkg = await rxr.archive.extract();
|
|
27302
|
+
return pkg.file("content");
|
|
27103
27303
|
}
|
|
27104
27304
|
};
|
|
27105
27305
|
}
|
|
@@ -27698,107 +27898,1473 @@ class ARP {
|
|
|
27698
27898
|
function createARP(config) {
|
|
27699
27899
|
return new ARP(config);
|
|
27700
27900
|
}
|
|
27701
|
-
var DEFAULT_PATH = `${homedir()}/.resourcex`;
|
|
27702
27901
|
|
|
27703
|
-
class
|
|
27704
|
-
|
|
27705
|
-
|
|
27706
|
-
|
|
27707
|
-
constructor(config) {
|
|
27708
|
-
this.basePath = config?.path ?? DEFAULT_PATH;
|
|
27709
|
-
this.typeHandler = TypeHandlerChain2.create();
|
|
27710
|
-
this.arp = createARP();
|
|
27711
|
-
if (config?.types) {
|
|
27712
|
-
for (const type of config.types) {
|
|
27713
|
-
this.typeHandler.register(type);
|
|
27714
|
-
}
|
|
27715
|
-
}
|
|
27902
|
+
class ResourceXError32 extends Error {
|
|
27903
|
+
constructor(message, options) {
|
|
27904
|
+
super(message, options);
|
|
27905
|
+
this.name = "ResourceXError";
|
|
27716
27906
|
}
|
|
27717
|
-
|
|
27718
|
-
|
|
27907
|
+
}
|
|
27908
|
+
|
|
27909
|
+
class ManifestError22 extends ResourceXError32 {
|
|
27910
|
+
constructor(message) {
|
|
27911
|
+
super(message);
|
|
27912
|
+
this.name = "ManifestError";
|
|
27719
27913
|
}
|
|
27720
|
-
|
|
27721
|
-
|
|
27914
|
+
}
|
|
27915
|
+
|
|
27916
|
+
class ContentError22 extends ResourceXError32 {
|
|
27917
|
+
constructor(message) {
|
|
27918
|
+
super(message);
|
|
27919
|
+
this.name = "ContentError";
|
|
27722
27920
|
}
|
|
27723
|
-
|
|
27724
|
-
|
|
27725
|
-
|
|
27726
|
-
|
|
27727
|
-
|
|
27728
|
-
|
|
27729
|
-
|
|
27730
|
-
|
|
27731
|
-
|
|
27732
|
-
|
|
27733
|
-
|
|
27921
|
+
}
|
|
27922
|
+
|
|
27923
|
+
class RXLImpl32 {
|
|
27924
|
+
domain;
|
|
27925
|
+
path;
|
|
27926
|
+
name;
|
|
27927
|
+
type;
|
|
27928
|
+
version;
|
|
27929
|
+
constructor(parts) {
|
|
27930
|
+
this.domain = parts.domain;
|
|
27931
|
+
this.path = parts.path;
|
|
27932
|
+
this.name = parts.name;
|
|
27933
|
+
this.type = parts.type;
|
|
27934
|
+
this.version = parts.version;
|
|
27935
|
+
}
|
|
27936
|
+
toString() {
|
|
27937
|
+
let result = "";
|
|
27938
|
+
if (this.domain) {
|
|
27939
|
+
result += this.domain + "/";
|
|
27940
|
+
if (this.path) {
|
|
27941
|
+
result += this.path + "/";
|
|
27734
27942
|
}
|
|
27735
|
-
return join2(path, resourceName, version);
|
|
27736
27943
|
}
|
|
27737
|
-
|
|
27738
|
-
|
|
27739
|
-
|
|
27740
|
-
return !rxl.domain || rxl.domain === "localhost";
|
|
27741
|
-
}
|
|
27742
|
-
async existsAt(resourcePath) {
|
|
27743
|
-
const manifestPath = join2(resourcePath, "manifest.json");
|
|
27744
|
-
const arl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
27745
|
-
return arl.exists();
|
|
27746
|
-
}
|
|
27747
|
-
async findArea(locator) {
|
|
27748
|
-
const localPath = this.buildPath(locator, "local");
|
|
27749
|
-
if (await this.existsAt(localPath)) {
|
|
27750
|
-
return "local";
|
|
27944
|
+
result += this.name;
|
|
27945
|
+
if (this.type) {
|
|
27946
|
+
result += "." + this.type;
|
|
27751
27947
|
}
|
|
27752
|
-
|
|
27753
|
-
|
|
27754
|
-
return "cache";
|
|
27948
|
+
if (this.version) {
|
|
27949
|
+
result += "@" + this.version;
|
|
27755
27950
|
}
|
|
27756
|
-
return
|
|
27951
|
+
return result;
|
|
27757
27952
|
}
|
|
27758
|
-
|
|
27759
|
-
|
|
27760
|
-
|
|
27761
|
-
|
|
27762
|
-
|
|
27763
|
-
|
|
27764
|
-
|
|
27765
|
-
|
|
27766
|
-
|
|
27767
|
-
|
|
27768
|
-
|
|
27769
|
-
|
|
27953
|
+
}
|
|
27954
|
+
function isDomain32(str) {
|
|
27955
|
+
if (str === "localhost")
|
|
27956
|
+
return true;
|
|
27957
|
+
return str.includes(".");
|
|
27958
|
+
}
|
|
27959
|
+
function parseRXL32(locator) {
|
|
27960
|
+
let remaining = locator;
|
|
27961
|
+
let version;
|
|
27962
|
+
let type;
|
|
27963
|
+
let domain;
|
|
27964
|
+
let path;
|
|
27965
|
+
let name;
|
|
27966
|
+
const atIndex = remaining.indexOf("@");
|
|
27967
|
+
if (atIndex !== -1) {
|
|
27968
|
+
version = remaining.slice(atIndex + 1);
|
|
27969
|
+
remaining = remaining.slice(0, atIndex);
|
|
27770
27970
|
}
|
|
27771
|
-
|
|
27772
|
-
|
|
27971
|
+
const segments = remaining.split("/");
|
|
27972
|
+
if (segments.length > 1 && isDomain32(segments[0])) {
|
|
27973
|
+
domain = segments[0];
|
|
27974
|
+
const lastSegment = segments[segments.length - 1];
|
|
27975
|
+
if (segments.length > 2) {
|
|
27976
|
+
path = segments.slice(1, -1).join("/");
|
|
27977
|
+
}
|
|
27978
|
+
remaining = lastSegment;
|
|
27979
|
+
} else {
|
|
27980
|
+
remaining = segments.join("/");
|
|
27773
27981
|
}
|
|
27774
|
-
|
|
27775
|
-
|
|
27982
|
+
const dotIndex = remaining.lastIndexOf(".");
|
|
27983
|
+
if (dotIndex !== -1) {
|
|
27984
|
+
type = remaining.slice(dotIndex + 1);
|
|
27985
|
+
name = remaining.slice(0, dotIndex);
|
|
27986
|
+
} else {
|
|
27987
|
+
name = remaining;
|
|
27776
27988
|
}
|
|
27777
|
-
|
|
27778
|
-
|
|
27779
|
-
|
|
27780
|
-
|
|
27781
|
-
|
|
27782
|
-
|
|
27783
|
-
|
|
27784
|
-
|
|
27785
|
-
|
|
27786
|
-
|
|
27787
|
-
|
|
27788
|
-
|
|
27789
|
-
|
|
27989
|
+
return new RXLImpl32({ domain, path, name, type, version });
|
|
27990
|
+
}
|
|
27991
|
+
|
|
27992
|
+
class RXMImpl22 {
|
|
27993
|
+
domain;
|
|
27994
|
+
path;
|
|
27995
|
+
name;
|
|
27996
|
+
type;
|
|
27997
|
+
version;
|
|
27998
|
+
constructor(data) {
|
|
27999
|
+
this.domain = data.domain;
|
|
28000
|
+
this.path = data.path;
|
|
28001
|
+
this.name = data.name;
|
|
28002
|
+
this.type = data.type;
|
|
28003
|
+
this.version = data.version;
|
|
27790
28004
|
}
|
|
27791
|
-
|
|
27792
|
-
|
|
27793
|
-
if (
|
|
27794
|
-
|
|
28005
|
+
toLocator() {
|
|
28006
|
+
let result = this.domain + "/";
|
|
28007
|
+
if (this.path) {
|
|
28008
|
+
result += this.path + "/";
|
|
27795
28009
|
}
|
|
27796
|
-
|
|
27797
|
-
|
|
28010
|
+
result += this.name;
|
|
28011
|
+
result += "." + this.type;
|
|
28012
|
+
result += "@" + this.version;
|
|
28013
|
+
return result;
|
|
27798
28014
|
}
|
|
27799
|
-
|
|
27800
|
-
const
|
|
27801
|
-
|
|
28015
|
+
toJSON() {
|
|
28016
|
+
const json = {
|
|
28017
|
+
domain: this.domain,
|
|
28018
|
+
name: this.name,
|
|
28019
|
+
type: this.type,
|
|
28020
|
+
version: this.version
|
|
28021
|
+
};
|
|
28022
|
+
if (this.path !== undefined) {
|
|
28023
|
+
json.path = this.path;
|
|
28024
|
+
}
|
|
28025
|
+
return json;
|
|
28026
|
+
}
|
|
28027
|
+
}
|
|
28028
|
+
function createRXM22(data) {
|
|
28029
|
+
if (!data.domain) {
|
|
28030
|
+
throw new ManifestError22("domain is required");
|
|
28031
|
+
}
|
|
28032
|
+
if (!data.name) {
|
|
28033
|
+
throw new ManifestError22("name is required");
|
|
28034
|
+
}
|
|
28035
|
+
if (!data.type) {
|
|
28036
|
+
throw new ManifestError22("type is required");
|
|
28037
|
+
}
|
|
28038
|
+
if (!data.version) {
|
|
28039
|
+
throw new ManifestError22("version is required");
|
|
28040
|
+
}
|
|
28041
|
+
return new RXMImpl22({
|
|
28042
|
+
domain: data.domain,
|
|
28043
|
+
path: data.path,
|
|
28044
|
+
name: data.name,
|
|
28045
|
+
type: data.type,
|
|
28046
|
+
version: data.version
|
|
28047
|
+
});
|
|
28048
|
+
}
|
|
28049
|
+
var BLOCK_SIZE32 = 512;
|
|
28050
|
+
var BLOCK_SIZE_MASK22 = 511;
|
|
28051
|
+
var DEFAULT_FILE_MODE22 = 420;
|
|
28052
|
+
var DEFAULT_DIR_MODE22 = 493;
|
|
28053
|
+
var USTAR_NAME_OFFSET22 = 0;
|
|
28054
|
+
var USTAR_NAME_SIZE22 = 100;
|
|
28055
|
+
var USTAR_MODE_OFFSET22 = 100;
|
|
28056
|
+
var USTAR_MODE_SIZE22 = 8;
|
|
28057
|
+
var USTAR_UID_OFFSET22 = 108;
|
|
28058
|
+
var USTAR_UID_SIZE22 = 8;
|
|
28059
|
+
var USTAR_GID_OFFSET22 = 116;
|
|
28060
|
+
var USTAR_GID_SIZE22 = 8;
|
|
28061
|
+
var USTAR_SIZE_OFFSET22 = 124;
|
|
28062
|
+
var USTAR_SIZE_SIZE22 = 12;
|
|
28063
|
+
var USTAR_MTIME_OFFSET22 = 136;
|
|
28064
|
+
var USTAR_MTIME_SIZE22 = 12;
|
|
28065
|
+
var USTAR_CHECKSUM_OFFSET22 = 148;
|
|
28066
|
+
var USTAR_CHECKSUM_SIZE22 = 8;
|
|
28067
|
+
var USTAR_TYPEFLAG_OFFSET22 = 156;
|
|
28068
|
+
var USTAR_TYPEFLAG_SIZE22 = 1;
|
|
28069
|
+
var USTAR_LINKNAME_OFFSET22 = 157;
|
|
28070
|
+
var USTAR_LINKNAME_SIZE22 = 100;
|
|
28071
|
+
var USTAR_MAGIC_OFFSET22 = 257;
|
|
28072
|
+
var USTAR_MAGIC_SIZE22 = 6;
|
|
28073
|
+
var USTAR_VERSION_OFFSET22 = 263;
|
|
28074
|
+
var USTAR_VERSION_SIZE22 = 2;
|
|
28075
|
+
var USTAR_UNAME_OFFSET22 = 265;
|
|
28076
|
+
var USTAR_UNAME_SIZE22 = 32;
|
|
28077
|
+
var USTAR_GNAME_OFFSET22 = 297;
|
|
28078
|
+
var USTAR_GNAME_SIZE22 = 32;
|
|
28079
|
+
var USTAR_PREFIX_OFFSET22 = 345;
|
|
28080
|
+
var USTAR_PREFIX_SIZE22 = 155;
|
|
28081
|
+
var USTAR_VERSION22 = "00";
|
|
28082
|
+
var USTAR_MAX_UID_GID22 = 2097151;
|
|
28083
|
+
var USTAR_MAX_SIZE22 = 8589934591;
|
|
28084
|
+
var FILE22 = "file";
|
|
28085
|
+
var LINK22 = "link";
|
|
28086
|
+
var SYMLINK22 = "symlink";
|
|
28087
|
+
var DIRECTORY22 = "directory";
|
|
28088
|
+
var TYPEFLAG22 = {
|
|
28089
|
+
file: "0",
|
|
28090
|
+
link: "1",
|
|
28091
|
+
symlink: "2",
|
|
28092
|
+
"character-device": "3",
|
|
28093
|
+
"block-device": "4",
|
|
28094
|
+
directory: "5",
|
|
28095
|
+
fifo: "6",
|
|
28096
|
+
"pax-header": "x",
|
|
28097
|
+
"pax-global-header": "g",
|
|
28098
|
+
"gnu-long-name": "L",
|
|
28099
|
+
"gnu-long-link-name": "K"
|
|
28100
|
+
};
|
|
28101
|
+
var FLAGTYPE22 = {
|
|
28102
|
+
"0": FILE22,
|
|
28103
|
+
"1": LINK22,
|
|
28104
|
+
"2": SYMLINK22,
|
|
28105
|
+
"3": "character-device",
|
|
28106
|
+
"4": "block-device",
|
|
28107
|
+
"5": DIRECTORY22,
|
|
28108
|
+
"6": "fifo",
|
|
28109
|
+
x: "pax-header",
|
|
28110
|
+
g: "pax-global-header",
|
|
28111
|
+
L: "gnu-long-name",
|
|
28112
|
+
K: "gnu-long-link-name"
|
|
28113
|
+
};
|
|
28114
|
+
var ZERO_BLOCK32 = new Uint8Array(BLOCK_SIZE32);
|
|
28115
|
+
var EMPTY32 = new Uint8Array(0);
|
|
28116
|
+
var encoder32 = new TextEncoder;
|
|
28117
|
+
var decoder32 = new TextDecoder;
|
|
28118
|
+
function writeString22(view, offset, size, value) {
|
|
28119
|
+
if (value)
|
|
28120
|
+
encoder32.encodeInto(value, view.subarray(offset, offset + size));
|
|
28121
|
+
}
|
|
28122
|
+
function writeOctal22(view, offset, size, value) {
|
|
28123
|
+
if (value === undefined)
|
|
28124
|
+
return;
|
|
28125
|
+
const octalString = value.toString(8).padStart(size - 1, "0");
|
|
28126
|
+
encoder32.encodeInto(octalString, view.subarray(offset, offset + size - 1));
|
|
28127
|
+
}
|
|
28128
|
+
function readString22(view, offset, size) {
|
|
28129
|
+
const end = view.indexOf(0, offset);
|
|
28130
|
+
const sliceEnd = end === -1 || end > offset + size ? offset + size : end;
|
|
28131
|
+
return decoder32.decode(view.subarray(offset, sliceEnd));
|
|
28132
|
+
}
|
|
28133
|
+
function readOctal22(view, offset, size) {
|
|
28134
|
+
let value = 0;
|
|
28135
|
+
const end = offset + size;
|
|
28136
|
+
for (let i = offset;i < end; i++) {
|
|
28137
|
+
const charCode = view[i];
|
|
28138
|
+
if (charCode === 0)
|
|
28139
|
+
break;
|
|
28140
|
+
if (charCode === 32)
|
|
28141
|
+
continue;
|
|
28142
|
+
value = value * 8 + (charCode - 48);
|
|
28143
|
+
}
|
|
28144
|
+
return value;
|
|
28145
|
+
}
|
|
28146
|
+
function readNumeric22(view, offset, size) {
|
|
28147
|
+
if (view[offset] & 128) {
|
|
28148
|
+
let result = 0;
|
|
28149
|
+
result = view[offset] & 127;
|
|
28150
|
+
for (let i = 1;i < size; i++)
|
|
28151
|
+
result = result * 256 + view[offset + i];
|
|
28152
|
+
if (!Number.isSafeInteger(result))
|
|
28153
|
+
throw new Error("TAR number too large");
|
|
28154
|
+
return result;
|
|
28155
|
+
}
|
|
28156
|
+
return readOctal22(view, offset, size);
|
|
28157
|
+
}
|
|
28158
|
+
var isBodyless22 = (header) => header.type === DIRECTORY22 || header.type === SYMLINK22 || header.type === LINK22;
|
|
28159
|
+
async function normalizeBody22(body) {
|
|
28160
|
+
if (body === null || body === undefined)
|
|
28161
|
+
return EMPTY32;
|
|
28162
|
+
if (body instanceof Uint8Array)
|
|
28163
|
+
return body;
|
|
28164
|
+
if (typeof body === "string")
|
|
28165
|
+
return encoder32.encode(body);
|
|
28166
|
+
if (body instanceof ArrayBuffer)
|
|
28167
|
+
return new Uint8Array(body);
|
|
28168
|
+
if (body instanceof Blob)
|
|
28169
|
+
return new Uint8Array(await body.arrayBuffer());
|
|
28170
|
+
throw new TypeError("Unsupported content type for entry body.");
|
|
28171
|
+
}
|
|
28172
|
+
function transformHeader22(header, options) {
|
|
28173
|
+
const { strip, filter, map } = options;
|
|
28174
|
+
if (!strip && !filter && !map)
|
|
28175
|
+
return header;
|
|
28176
|
+
const h = { ...header };
|
|
28177
|
+
if (strip && strip > 0) {
|
|
28178
|
+
const components = h.name.split("/").filter(Boolean);
|
|
28179
|
+
if (strip >= components.length)
|
|
28180
|
+
return null;
|
|
28181
|
+
const newName = components.slice(strip).join("/");
|
|
28182
|
+
h.name = h.type === DIRECTORY22 && !newName.endsWith("/") ? `${newName}/` : newName;
|
|
28183
|
+
if (h.linkname?.startsWith("/")) {
|
|
28184
|
+
const linkComponents = h.linkname.split("/").filter(Boolean);
|
|
28185
|
+
h.linkname = strip >= linkComponents.length ? "/" : `/${linkComponents.slice(strip).join("/")}`;
|
|
28186
|
+
}
|
|
28187
|
+
}
|
|
28188
|
+
if (filter?.(h) === false)
|
|
28189
|
+
return null;
|
|
28190
|
+
const result = map ? map(h) : h;
|
|
28191
|
+
if (result && (!result.name || !result.name.trim() || result.name === "." || result.name === "/"))
|
|
28192
|
+
return null;
|
|
28193
|
+
return result;
|
|
28194
|
+
}
|
|
28195
|
+
var CHECKSUM_SPACE22 = 32;
|
|
28196
|
+
var ASCII_ZERO22 = 48;
|
|
28197
|
+
function validateChecksum22(block) {
|
|
28198
|
+
const stored = readOctal22(block, USTAR_CHECKSUM_OFFSET22, USTAR_CHECKSUM_SIZE22);
|
|
28199
|
+
let sum = 0;
|
|
28200
|
+
for (let i = 0;i < block.length; i++)
|
|
28201
|
+
if (i >= USTAR_CHECKSUM_OFFSET22 && i < USTAR_CHECKSUM_OFFSET22 + USTAR_CHECKSUM_SIZE22)
|
|
28202
|
+
sum += CHECKSUM_SPACE22;
|
|
28203
|
+
else
|
|
28204
|
+
sum += block[i];
|
|
28205
|
+
return stored === sum;
|
|
28206
|
+
}
|
|
28207
|
+
function writeChecksum22(block) {
|
|
28208
|
+
block.fill(CHECKSUM_SPACE22, USTAR_CHECKSUM_OFFSET22, USTAR_CHECKSUM_OFFSET22 + USTAR_CHECKSUM_SIZE22);
|
|
28209
|
+
let checksum = 0;
|
|
28210
|
+
for (const byte of block)
|
|
28211
|
+
checksum += byte;
|
|
28212
|
+
for (let i = USTAR_CHECKSUM_OFFSET22 + 6 - 1;i >= USTAR_CHECKSUM_OFFSET22; i--) {
|
|
28213
|
+
block[i] = (checksum & 7) + ASCII_ZERO22;
|
|
28214
|
+
checksum >>= 3;
|
|
28215
|
+
}
|
|
28216
|
+
block[USTAR_CHECKSUM_OFFSET22 + 6] = 0;
|
|
28217
|
+
block[USTAR_CHECKSUM_OFFSET22 + 7] = CHECKSUM_SPACE22;
|
|
28218
|
+
}
|
|
28219
|
+
function generatePax22(header) {
|
|
28220
|
+
const paxRecords = {};
|
|
28221
|
+
if (header.name.length > USTAR_NAME_SIZE22) {
|
|
28222
|
+
if (findUstarSplit22(header.name) === null)
|
|
28223
|
+
paxRecords.path = header.name;
|
|
28224
|
+
}
|
|
28225
|
+
if (header.linkname && header.linkname.length > USTAR_NAME_SIZE22)
|
|
28226
|
+
paxRecords.linkpath = header.linkname;
|
|
28227
|
+
if (header.uname && header.uname.length > USTAR_UNAME_SIZE22)
|
|
28228
|
+
paxRecords.uname = header.uname;
|
|
28229
|
+
if (header.gname && header.gname.length > USTAR_GNAME_SIZE22)
|
|
28230
|
+
paxRecords.gname = header.gname;
|
|
28231
|
+
if (header.uid != null && header.uid > USTAR_MAX_UID_GID22)
|
|
28232
|
+
paxRecords.uid = String(header.uid);
|
|
28233
|
+
if (header.gid != null && header.gid > USTAR_MAX_UID_GID22)
|
|
28234
|
+
paxRecords.gid = String(header.gid);
|
|
28235
|
+
if (header.size != null && header.size > USTAR_MAX_SIZE22)
|
|
28236
|
+
paxRecords.size = String(header.size);
|
|
28237
|
+
if (header.pax)
|
|
28238
|
+
Object.assign(paxRecords, header.pax);
|
|
28239
|
+
const paxEntries = Object.entries(paxRecords);
|
|
28240
|
+
if (paxEntries.length === 0)
|
|
28241
|
+
return null;
|
|
28242
|
+
const paxBody = encoder32.encode(paxEntries.map(([key, value]) => {
|
|
28243
|
+
const record = `${key}=${value}
|
|
28244
|
+
`;
|
|
28245
|
+
const partLength = encoder32.encode(record).length + 1;
|
|
28246
|
+
let totalLength = partLength + String(partLength).length;
|
|
28247
|
+
totalLength = partLength + String(totalLength).length;
|
|
28248
|
+
return `${totalLength} ${record}`;
|
|
28249
|
+
}).join(""));
|
|
28250
|
+
return {
|
|
28251
|
+
paxHeader: createTarHeader22({
|
|
28252
|
+
name: decoder32.decode(encoder32.encode(`PaxHeader/${header.name}`).slice(0, 100)),
|
|
28253
|
+
size: paxBody.length,
|
|
28254
|
+
type: "pax-header",
|
|
28255
|
+
mode: 420,
|
|
28256
|
+
mtime: header.mtime,
|
|
28257
|
+
uname: header.uname,
|
|
28258
|
+
gname: header.gname,
|
|
28259
|
+
uid: header.uid,
|
|
28260
|
+
gid: header.gid
|
|
28261
|
+
}),
|
|
28262
|
+
paxBody
|
|
28263
|
+
};
|
|
28264
|
+
}
|
|
28265
|
+
function findUstarSplit22(path) {
|
|
28266
|
+
if (path.length <= USTAR_NAME_SIZE22)
|
|
28267
|
+
return null;
|
|
28268
|
+
const minSlashIndex = path.length - USTAR_NAME_SIZE22 - 1;
|
|
28269
|
+
const slashIndex = path.lastIndexOf("/", USTAR_PREFIX_SIZE22);
|
|
28270
|
+
if (slashIndex > 0 && slashIndex >= minSlashIndex)
|
|
28271
|
+
return {
|
|
28272
|
+
prefix: path.slice(0, slashIndex),
|
|
28273
|
+
name: path.slice(slashIndex + 1)
|
|
28274
|
+
};
|
|
28275
|
+
return null;
|
|
28276
|
+
}
|
|
28277
|
+
function createTarHeader22(header) {
|
|
28278
|
+
const view = new Uint8Array(BLOCK_SIZE32);
|
|
28279
|
+
const size = isBodyless22(header) ? 0 : header.size ?? 0;
|
|
28280
|
+
let name = header.name;
|
|
28281
|
+
let prefix = "";
|
|
28282
|
+
if (!header.pax?.path) {
|
|
28283
|
+
const split = findUstarSplit22(name);
|
|
28284
|
+
if (split) {
|
|
28285
|
+
name = split.name;
|
|
28286
|
+
prefix = split.prefix;
|
|
28287
|
+
}
|
|
28288
|
+
}
|
|
28289
|
+
writeString22(view, USTAR_NAME_OFFSET22, USTAR_NAME_SIZE22, name);
|
|
28290
|
+
writeOctal22(view, USTAR_MODE_OFFSET22, USTAR_MODE_SIZE22, header.mode ?? (header.type === DIRECTORY22 ? DEFAULT_DIR_MODE22 : DEFAULT_FILE_MODE22));
|
|
28291
|
+
writeOctal22(view, USTAR_UID_OFFSET22, USTAR_UID_SIZE22, header.uid ?? 0);
|
|
28292
|
+
writeOctal22(view, USTAR_GID_OFFSET22, USTAR_GID_SIZE22, header.gid ?? 0);
|
|
28293
|
+
writeOctal22(view, USTAR_SIZE_OFFSET22, USTAR_SIZE_SIZE22, size);
|
|
28294
|
+
writeOctal22(view, USTAR_MTIME_OFFSET22, USTAR_MTIME_SIZE22, Math.floor((header.mtime?.getTime() ?? Date.now()) / 1000));
|
|
28295
|
+
writeString22(view, USTAR_TYPEFLAG_OFFSET22, USTAR_TYPEFLAG_SIZE22, TYPEFLAG22[header.type ?? FILE22]);
|
|
28296
|
+
writeString22(view, USTAR_LINKNAME_OFFSET22, USTAR_LINKNAME_SIZE22, header.linkname);
|
|
28297
|
+
writeString22(view, USTAR_MAGIC_OFFSET22, USTAR_MAGIC_SIZE22, "ustar\x00");
|
|
28298
|
+
writeString22(view, USTAR_VERSION_OFFSET22, USTAR_VERSION_SIZE22, USTAR_VERSION22);
|
|
28299
|
+
writeString22(view, USTAR_UNAME_OFFSET22, USTAR_UNAME_SIZE22, header.uname);
|
|
28300
|
+
writeString22(view, USTAR_GNAME_OFFSET22, USTAR_GNAME_SIZE22, header.gname);
|
|
28301
|
+
writeString22(view, USTAR_PREFIX_OFFSET22, USTAR_PREFIX_SIZE22, prefix);
|
|
28302
|
+
writeChecksum22(view);
|
|
28303
|
+
return view;
|
|
28304
|
+
}
|
|
28305
|
+
function parseUstarHeader22(block, strict) {
|
|
28306
|
+
if (strict && !validateChecksum22(block))
|
|
28307
|
+
throw new Error("Invalid tar header checksum.");
|
|
28308
|
+
const typeflag = readString22(block, USTAR_TYPEFLAG_OFFSET22, USTAR_TYPEFLAG_SIZE22);
|
|
28309
|
+
const header = {
|
|
28310
|
+
name: readString22(block, USTAR_NAME_OFFSET22, USTAR_NAME_SIZE22),
|
|
28311
|
+
mode: readOctal22(block, USTAR_MODE_OFFSET22, USTAR_MODE_SIZE22),
|
|
28312
|
+
uid: readNumeric22(block, USTAR_UID_OFFSET22, USTAR_UID_SIZE22),
|
|
28313
|
+
gid: readNumeric22(block, USTAR_GID_OFFSET22, USTAR_GID_SIZE22),
|
|
28314
|
+
size: readNumeric22(block, USTAR_SIZE_OFFSET22, USTAR_SIZE_SIZE22),
|
|
28315
|
+
mtime: /* @__PURE__ */ new Date(readNumeric22(block, USTAR_MTIME_OFFSET22, USTAR_MTIME_SIZE22) * 1000),
|
|
28316
|
+
type: FLAGTYPE22[typeflag] || FILE22,
|
|
28317
|
+
linkname: readString22(block, USTAR_LINKNAME_OFFSET22, USTAR_LINKNAME_SIZE22)
|
|
28318
|
+
};
|
|
28319
|
+
const magic = readString22(block, USTAR_MAGIC_OFFSET22, USTAR_MAGIC_SIZE22);
|
|
28320
|
+
if (magic.trim() === "ustar") {
|
|
28321
|
+
header.uname = readString22(block, USTAR_UNAME_OFFSET22, USTAR_UNAME_SIZE22);
|
|
28322
|
+
header.gname = readString22(block, USTAR_GNAME_OFFSET22, USTAR_GNAME_SIZE22);
|
|
28323
|
+
}
|
|
28324
|
+
if (magic === "ustar")
|
|
28325
|
+
header.prefix = readString22(block, USTAR_PREFIX_OFFSET22, USTAR_PREFIX_SIZE22);
|
|
28326
|
+
return header;
|
|
28327
|
+
}
|
|
28328
|
+
var PAX_MAPPING22 = {
|
|
28329
|
+
path: ["name", (v) => v],
|
|
28330
|
+
linkpath: ["linkname", (v) => v],
|
|
28331
|
+
size: ["size", (v) => parseInt(v, 10)],
|
|
28332
|
+
mtime: ["mtime", parseFloat],
|
|
28333
|
+
uid: ["uid", (v) => parseInt(v, 10)],
|
|
28334
|
+
gid: ["gid", (v) => parseInt(v, 10)],
|
|
28335
|
+
uname: ["uname", (v) => v],
|
|
28336
|
+
gname: ["gname", (v) => v]
|
|
28337
|
+
};
|
|
28338
|
+
function parsePax22(buffer) {
|
|
28339
|
+
const decoder$1 = new TextDecoder("utf-8");
|
|
28340
|
+
const overrides = {};
|
|
28341
|
+
const pax = {};
|
|
28342
|
+
let offset = 0;
|
|
28343
|
+
while (offset < buffer.length) {
|
|
28344
|
+
const spaceIndex = buffer.indexOf(32, offset);
|
|
28345
|
+
if (spaceIndex === -1)
|
|
28346
|
+
break;
|
|
28347
|
+
const length = parseInt(decoder$1.decode(buffer.subarray(offset, spaceIndex)), 10);
|
|
28348
|
+
if (Number.isNaN(length) || length === 0)
|
|
28349
|
+
break;
|
|
28350
|
+
const recordEnd = offset + length;
|
|
28351
|
+
const [key, value] = decoder$1.decode(buffer.subarray(spaceIndex + 1, recordEnd - 1)).split("=", 2);
|
|
28352
|
+
if (key && value !== undefined) {
|
|
28353
|
+
pax[key] = value;
|
|
28354
|
+
const mapping = PAX_MAPPING22[key];
|
|
28355
|
+
if (mapping) {
|
|
28356
|
+
const [targetKey, parser] = mapping;
|
|
28357
|
+
const parsedValue = parser(value);
|
|
28358
|
+
if (typeof parsedValue === "string" || !Number.isNaN(parsedValue))
|
|
28359
|
+
overrides[targetKey] = parsedValue;
|
|
28360
|
+
}
|
|
28361
|
+
}
|
|
28362
|
+
offset = recordEnd;
|
|
28363
|
+
}
|
|
28364
|
+
if (Object.keys(pax).length > 0)
|
|
28365
|
+
overrides.pax = pax;
|
|
28366
|
+
return overrides;
|
|
28367
|
+
}
|
|
28368
|
+
function applyOverrides22(header, overrides) {
|
|
28369
|
+
if (overrides.name !== undefined)
|
|
28370
|
+
header.name = overrides.name;
|
|
28371
|
+
if (overrides.linkname !== undefined)
|
|
28372
|
+
header.linkname = overrides.linkname;
|
|
28373
|
+
if (overrides.size !== undefined)
|
|
28374
|
+
header.size = overrides.size;
|
|
28375
|
+
if (overrides.mtime !== undefined)
|
|
28376
|
+
header.mtime = /* @__PURE__ */ new Date(overrides.mtime * 1000);
|
|
28377
|
+
if (overrides.uid !== undefined)
|
|
28378
|
+
header.uid = overrides.uid;
|
|
28379
|
+
if (overrides.gid !== undefined)
|
|
28380
|
+
header.gid = overrides.gid;
|
|
28381
|
+
if (overrides.uname !== undefined)
|
|
28382
|
+
header.uname = overrides.uname;
|
|
28383
|
+
if (overrides.gname !== undefined)
|
|
28384
|
+
header.gname = overrides.gname;
|
|
28385
|
+
if (overrides.pax)
|
|
28386
|
+
header.pax = Object.assign({}, header.pax ?? {}, overrides.pax);
|
|
28387
|
+
}
|
|
28388
|
+
function getMetaParser22(type) {
|
|
28389
|
+
switch (type) {
|
|
28390
|
+
case "pax-global-header":
|
|
28391
|
+
case "pax-header":
|
|
28392
|
+
return parsePax22;
|
|
28393
|
+
case "gnu-long-name":
|
|
28394
|
+
return (data) => ({ name: readString22(data, 0, data.length) });
|
|
28395
|
+
case "gnu-long-link-name":
|
|
28396
|
+
return (data) => ({ linkname: readString22(data, 0, data.length) });
|
|
28397
|
+
default:
|
|
28398
|
+
return;
|
|
28399
|
+
}
|
|
28400
|
+
}
|
|
28401
|
+
function getHeaderBlocks22(header) {
|
|
28402
|
+
const base = createTarHeader22(header);
|
|
28403
|
+
const pax = generatePax22(header);
|
|
28404
|
+
if (!pax)
|
|
28405
|
+
return [base];
|
|
28406
|
+
const paxPadding = -pax.paxBody.length & BLOCK_SIZE_MASK22;
|
|
28407
|
+
const paddingBlocks = paxPadding > 0 ? [ZERO_BLOCK32.subarray(0, paxPadding)] : [];
|
|
28408
|
+
return [
|
|
28409
|
+
pax.paxHeader,
|
|
28410
|
+
pax.paxBody,
|
|
28411
|
+
...paddingBlocks,
|
|
28412
|
+
base
|
|
28413
|
+
];
|
|
28414
|
+
}
|
|
28415
|
+
var EOF_BUFFER32 = new Uint8Array(BLOCK_SIZE32 * 2);
|
|
28416
|
+
function createTarPacker32(onData, onError, onFinalize) {
|
|
28417
|
+
let currentHeader = null;
|
|
28418
|
+
let bytesWritten = 0;
|
|
28419
|
+
let finalized = false;
|
|
28420
|
+
return {
|
|
28421
|
+
add(header) {
|
|
28422
|
+
if (finalized) {
|
|
28423
|
+
const error = /* @__PURE__ */ new Error("No new tar entries after finalize.");
|
|
28424
|
+
onError(error);
|
|
28425
|
+
throw error;
|
|
28426
|
+
}
|
|
28427
|
+
if (currentHeader !== null) {
|
|
28428
|
+
const error = /* @__PURE__ */ new Error("Previous entry must be completed before adding a new one");
|
|
28429
|
+
onError(error);
|
|
28430
|
+
throw error;
|
|
28431
|
+
}
|
|
28432
|
+
try {
|
|
28433
|
+
const size = isBodyless22(header) ? 0 : header.size ?? 0;
|
|
28434
|
+
const headerBlocks = getHeaderBlocks22({
|
|
28435
|
+
...header,
|
|
28436
|
+
size
|
|
28437
|
+
});
|
|
28438
|
+
for (const block of headerBlocks)
|
|
28439
|
+
onData(block);
|
|
28440
|
+
currentHeader = {
|
|
28441
|
+
...header,
|
|
28442
|
+
size
|
|
28443
|
+
};
|
|
28444
|
+
bytesWritten = 0;
|
|
28445
|
+
} catch (error) {
|
|
28446
|
+
onError(error);
|
|
28447
|
+
}
|
|
28448
|
+
},
|
|
28449
|
+
write(chunk) {
|
|
28450
|
+
if (!currentHeader) {
|
|
28451
|
+
const error = /* @__PURE__ */ new Error("No active tar entry.");
|
|
28452
|
+
onError(error);
|
|
28453
|
+
throw error;
|
|
28454
|
+
}
|
|
28455
|
+
if (finalized) {
|
|
28456
|
+
const error = /* @__PURE__ */ new Error("Cannot write data after finalize.");
|
|
28457
|
+
onError(error);
|
|
28458
|
+
throw error;
|
|
28459
|
+
}
|
|
28460
|
+
const newTotal = bytesWritten + chunk.length;
|
|
28461
|
+
if (newTotal > currentHeader.size) {
|
|
28462
|
+
const error = /* @__PURE__ */ new Error(`"${currentHeader.name}" exceeds given size of ${currentHeader.size} bytes.`);
|
|
28463
|
+
onError(error);
|
|
28464
|
+
throw error;
|
|
28465
|
+
}
|
|
28466
|
+
try {
|
|
28467
|
+
bytesWritten = newTotal;
|
|
28468
|
+
onData(chunk);
|
|
28469
|
+
} catch (error) {
|
|
28470
|
+
onError(error);
|
|
28471
|
+
}
|
|
28472
|
+
},
|
|
28473
|
+
endEntry() {
|
|
28474
|
+
if (!currentHeader) {
|
|
28475
|
+
const error = /* @__PURE__ */ new Error("No active entry to end.");
|
|
28476
|
+
onError(error);
|
|
28477
|
+
throw error;
|
|
28478
|
+
}
|
|
28479
|
+
if (finalized) {
|
|
28480
|
+
const error = /* @__PURE__ */ new Error("Cannot end entry after finalize.");
|
|
28481
|
+
onError(error);
|
|
28482
|
+
throw error;
|
|
28483
|
+
}
|
|
28484
|
+
try {
|
|
28485
|
+
if (bytesWritten !== currentHeader.size) {
|
|
28486
|
+
const error = /* @__PURE__ */ new Error(`Size mismatch for "${currentHeader.name}".`);
|
|
28487
|
+
onError(error);
|
|
28488
|
+
throw error;
|
|
28489
|
+
}
|
|
28490
|
+
const paddingSize = -currentHeader.size & BLOCK_SIZE_MASK22;
|
|
28491
|
+
if (paddingSize > 0)
|
|
28492
|
+
onData(new Uint8Array(paddingSize));
|
|
28493
|
+
currentHeader = null;
|
|
28494
|
+
bytesWritten = 0;
|
|
28495
|
+
} catch (error) {
|
|
28496
|
+
onError(error);
|
|
28497
|
+
throw error;
|
|
28498
|
+
}
|
|
28499
|
+
},
|
|
28500
|
+
finalize() {
|
|
28501
|
+
if (finalized) {
|
|
28502
|
+
const error = /* @__PURE__ */ new Error("Archive has already been finalized");
|
|
28503
|
+
onError(error);
|
|
28504
|
+
throw error;
|
|
28505
|
+
}
|
|
28506
|
+
if (currentHeader !== null) {
|
|
28507
|
+
const error = /* @__PURE__ */ new Error("Cannot finalize while an entry is still active");
|
|
28508
|
+
onError(error);
|
|
28509
|
+
throw error;
|
|
28510
|
+
}
|
|
28511
|
+
try {
|
|
28512
|
+
onData(EOF_BUFFER32);
|
|
28513
|
+
finalized = true;
|
|
28514
|
+
if (onFinalize)
|
|
28515
|
+
onFinalize();
|
|
28516
|
+
} catch (error) {
|
|
28517
|
+
onError(error);
|
|
28518
|
+
}
|
|
28519
|
+
}
|
|
28520
|
+
};
|
|
28521
|
+
}
|
|
28522
|
+
var INITIAL_CAPACITY22 = 256;
|
|
28523
|
+
function createChunkQueue22() {
|
|
28524
|
+
let chunks = new Array(INITIAL_CAPACITY22);
|
|
28525
|
+
let capacityMask = chunks.length - 1;
|
|
28526
|
+
let head = 0;
|
|
28527
|
+
let tail = 0;
|
|
28528
|
+
let totalAvailable = 0;
|
|
28529
|
+
const consumeFromHead = (count) => {
|
|
28530
|
+
const chunk = chunks[head];
|
|
28531
|
+
if (count === chunk.length) {
|
|
28532
|
+
chunks[head] = EMPTY32;
|
|
28533
|
+
head = head + 1 & capacityMask;
|
|
28534
|
+
} else
|
|
28535
|
+
chunks[head] = chunk.subarray(count);
|
|
28536
|
+
totalAvailable -= count;
|
|
28537
|
+
if (totalAvailable === 0 && chunks.length > INITIAL_CAPACITY22) {
|
|
28538
|
+
chunks = new Array(INITIAL_CAPACITY22);
|
|
28539
|
+
capacityMask = INITIAL_CAPACITY22 - 1;
|
|
28540
|
+
head = 0;
|
|
28541
|
+
tail = 0;
|
|
28542
|
+
}
|
|
28543
|
+
};
|
|
28544
|
+
function pull(bytes, callback) {
|
|
28545
|
+
if (callback) {
|
|
28546
|
+
let fed = 0;
|
|
28547
|
+
let remaining$1 = Math.min(bytes, totalAvailable);
|
|
28548
|
+
while (remaining$1 > 0) {
|
|
28549
|
+
const chunk = chunks[head];
|
|
28550
|
+
const toFeed = Math.min(remaining$1, chunk.length);
|
|
28551
|
+
const segment = toFeed === chunk.length ? chunk : chunk.subarray(0, toFeed);
|
|
28552
|
+
consumeFromHead(toFeed);
|
|
28553
|
+
remaining$1 -= toFeed;
|
|
28554
|
+
fed += toFeed;
|
|
28555
|
+
if (!callback(segment))
|
|
28556
|
+
break;
|
|
28557
|
+
}
|
|
28558
|
+
return fed;
|
|
28559
|
+
}
|
|
28560
|
+
if (totalAvailable < bytes)
|
|
28561
|
+
return null;
|
|
28562
|
+
if (bytes === 0)
|
|
28563
|
+
return EMPTY32;
|
|
28564
|
+
const firstChunk = chunks[head];
|
|
28565
|
+
if (firstChunk.length >= bytes) {
|
|
28566
|
+
const view = firstChunk.length === bytes ? firstChunk : firstChunk.subarray(0, bytes);
|
|
28567
|
+
consumeFromHead(bytes);
|
|
28568
|
+
return view;
|
|
28569
|
+
}
|
|
28570
|
+
const result = new Uint8Array(bytes);
|
|
28571
|
+
let copied = 0;
|
|
28572
|
+
let remaining = bytes;
|
|
28573
|
+
while (remaining > 0) {
|
|
28574
|
+
const chunk = chunks[head];
|
|
28575
|
+
const toCopy = Math.min(remaining, chunk.length);
|
|
28576
|
+
result.set(toCopy === chunk.length ? chunk : chunk.subarray(0, toCopy), copied);
|
|
28577
|
+
copied += toCopy;
|
|
28578
|
+
remaining -= toCopy;
|
|
28579
|
+
consumeFromHead(toCopy);
|
|
28580
|
+
}
|
|
28581
|
+
return result;
|
|
28582
|
+
}
|
|
28583
|
+
return {
|
|
28584
|
+
push: (chunk) => {
|
|
28585
|
+
if (chunk.length === 0)
|
|
28586
|
+
return;
|
|
28587
|
+
let nextTail = tail + 1 & capacityMask;
|
|
28588
|
+
if (nextTail === head) {
|
|
28589
|
+
const oldLen = chunks.length;
|
|
28590
|
+
const newLen = oldLen * 2;
|
|
28591
|
+
const newChunks = new Array(newLen);
|
|
28592
|
+
const count = tail - head + oldLen & oldLen - 1;
|
|
28593
|
+
if (head < tail)
|
|
28594
|
+
for (let i = 0;i < count; i++)
|
|
28595
|
+
newChunks[i] = chunks[head + i];
|
|
28596
|
+
else if (count > 0) {
|
|
28597
|
+
const firstPart = oldLen - head;
|
|
28598
|
+
for (let i = 0;i < firstPart; i++)
|
|
28599
|
+
newChunks[i] = chunks[head + i];
|
|
28600
|
+
for (let i = 0;i < tail; i++)
|
|
28601
|
+
newChunks[firstPart + i] = chunks[i];
|
|
28602
|
+
}
|
|
28603
|
+
chunks = newChunks;
|
|
28604
|
+
capacityMask = newLen - 1;
|
|
28605
|
+
head = 0;
|
|
28606
|
+
tail = count;
|
|
28607
|
+
nextTail = tail + 1 & capacityMask;
|
|
28608
|
+
}
|
|
28609
|
+
chunks[tail] = chunk;
|
|
28610
|
+
tail = nextTail;
|
|
28611
|
+
totalAvailable += chunk.length;
|
|
28612
|
+
},
|
|
28613
|
+
available: () => totalAvailable,
|
|
28614
|
+
peek: (bytes) => {
|
|
28615
|
+
if (totalAvailable < bytes)
|
|
28616
|
+
return null;
|
|
28617
|
+
if (bytes === 0)
|
|
28618
|
+
return EMPTY32;
|
|
28619
|
+
const firstChunk = chunks[head];
|
|
28620
|
+
if (firstChunk.length >= bytes)
|
|
28621
|
+
return firstChunk.length === bytes ? firstChunk : firstChunk.subarray(0, bytes);
|
|
28622
|
+
const result = new Uint8Array(bytes);
|
|
28623
|
+
let copied = 0;
|
|
28624
|
+
let index = head;
|
|
28625
|
+
while (copied < bytes) {
|
|
28626
|
+
const chunk = chunks[index];
|
|
28627
|
+
const toCopy = Math.min(bytes - copied, chunk.length);
|
|
28628
|
+
if (toCopy === chunk.length)
|
|
28629
|
+
result.set(chunk, copied);
|
|
28630
|
+
else
|
|
28631
|
+
result.set(chunk.subarray(0, toCopy), copied);
|
|
28632
|
+
copied += toCopy;
|
|
28633
|
+
index = index + 1 & capacityMask;
|
|
28634
|
+
}
|
|
28635
|
+
return result;
|
|
28636
|
+
},
|
|
28637
|
+
discard: (bytes) => {
|
|
28638
|
+
if (bytes > totalAvailable)
|
|
28639
|
+
throw new Error("Too many bytes consumed");
|
|
28640
|
+
if (bytes === 0)
|
|
28641
|
+
return;
|
|
28642
|
+
let remaining = bytes;
|
|
28643
|
+
while (remaining > 0) {
|
|
28644
|
+
const chunk = chunks[head];
|
|
28645
|
+
const toConsume = Math.min(remaining, chunk.length);
|
|
28646
|
+
consumeFromHead(toConsume);
|
|
28647
|
+
remaining -= toConsume;
|
|
28648
|
+
}
|
|
28649
|
+
},
|
|
28650
|
+
pull
|
|
28651
|
+
};
|
|
28652
|
+
}
|
|
28653
|
+
var STATE_HEADER22 = 0;
|
|
28654
|
+
var STATE_BODY22 = 1;
|
|
28655
|
+
var truncateErr22 = /* @__PURE__ */ new Error("Tar archive is truncated.");
|
|
28656
|
+
function createUnpacker22(options = {}) {
|
|
28657
|
+
const strict = options.strict ?? false;
|
|
28658
|
+
const { available, peek, push, discard, pull } = createChunkQueue22();
|
|
28659
|
+
let state = STATE_HEADER22;
|
|
28660
|
+
let ended = false;
|
|
28661
|
+
let done = false;
|
|
28662
|
+
let eof = false;
|
|
28663
|
+
let currentEntry = null;
|
|
28664
|
+
const paxGlobals = {};
|
|
28665
|
+
let nextEntryOverrides = {};
|
|
28666
|
+
const unpacker = {
|
|
28667
|
+
isEntryActive: () => state === STATE_BODY22,
|
|
28668
|
+
isBodyComplete: () => !currentEntry || currentEntry.remaining === 0,
|
|
28669
|
+
write(chunk) {
|
|
28670
|
+
if (ended)
|
|
28671
|
+
throw new Error("Archive already ended.");
|
|
28672
|
+
push(chunk);
|
|
28673
|
+
},
|
|
28674
|
+
end() {
|
|
28675
|
+
ended = true;
|
|
28676
|
+
},
|
|
28677
|
+
readHeader() {
|
|
28678
|
+
if (state !== STATE_HEADER22)
|
|
28679
|
+
throw new Error("Cannot read header while an entry is active");
|
|
28680
|
+
if (done)
|
|
28681
|
+
return;
|
|
28682
|
+
while (!done) {
|
|
28683
|
+
if (available() < BLOCK_SIZE32) {
|
|
28684
|
+
if (ended) {
|
|
28685
|
+
if (available() > 0 && strict)
|
|
28686
|
+
throw truncateErr22;
|
|
28687
|
+
done = true;
|
|
28688
|
+
return;
|
|
28689
|
+
}
|
|
28690
|
+
return null;
|
|
28691
|
+
}
|
|
28692
|
+
const headerBlock = peek(BLOCK_SIZE32);
|
|
28693
|
+
if (isZeroBlock22(headerBlock)) {
|
|
28694
|
+
if (available() < BLOCK_SIZE32 * 2) {
|
|
28695
|
+
if (ended) {
|
|
28696
|
+
if (strict)
|
|
28697
|
+
throw truncateErr22;
|
|
28698
|
+
done = true;
|
|
28699
|
+
return;
|
|
28700
|
+
}
|
|
28701
|
+
return null;
|
|
28702
|
+
}
|
|
28703
|
+
if (isZeroBlock22(peek(BLOCK_SIZE32 * 2).subarray(BLOCK_SIZE32))) {
|
|
28704
|
+
discard(BLOCK_SIZE32 * 2);
|
|
28705
|
+
done = true;
|
|
28706
|
+
eof = true;
|
|
28707
|
+
return;
|
|
28708
|
+
}
|
|
28709
|
+
if (strict)
|
|
28710
|
+
throw new Error("Invalid tar header.");
|
|
28711
|
+
discard(BLOCK_SIZE32);
|
|
28712
|
+
continue;
|
|
28713
|
+
}
|
|
28714
|
+
let internalHeader;
|
|
28715
|
+
try {
|
|
28716
|
+
internalHeader = parseUstarHeader22(headerBlock, strict);
|
|
28717
|
+
} catch (err) {
|
|
28718
|
+
if (strict)
|
|
28719
|
+
throw err;
|
|
28720
|
+
discard(BLOCK_SIZE32);
|
|
28721
|
+
continue;
|
|
28722
|
+
}
|
|
28723
|
+
const metaParser = getMetaParser22(internalHeader.type);
|
|
28724
|
+
if (metaParser) {
|
|
28725
|
+
const paddedSize = internalHeader.size + BLOCK_SIZE_MASK22 & ~BLOCK_SIZE_MASK22;
|
|
28726
|
+
if (available() < BLOCK_SIZE32 + paddedSize) {
|
|
28727
|
+
if (ended && strict)
|
|
28728
|
+
throw truncateErr22;
|
|
28729
|
+
return null;
|
|
28730
|
+
}
|
|
28731
|
+
discard(BLOCK_SIZE32);
|
|
28732
|
+
const overrides = metaParser(pull(paddedSize).subarray(0, internalHeader.size));
|
|
28733
|
+
const target = internalHeader.type === "pax-global-header" ? paxGlobals : nextEntryOverrides;
|
|
28734
|
+
for (const key in overrides)
|
|
28735
|
+
target[key] = overrides[key];
|
|
28736
|
+
continue;
|
|
28737
|
+
}
|
|
28738
|
+
discard(BLOCK_SIZE32);
|
|
28739
|
+
const header = internalHeader;
|
|
28740
|
+
if (internalHeader.prefix)
|
|
28741
|
+
header.name = `${internalHeader.prefix}/${header.name}`;
|
|
28742
|
+
applyOverrides22(header, paxGlobals);
|
|
28743
|
+
applyOverrides22(header, nextEntryOverrides);
|
|
28744
|
+
nextEntryOverrides = {};
|
|
28745
|
+
currentEntry = {
|
|
28746
|
+
header,
|
|
28747
|
+
remaining: header.size,
|
|
28748
|
+
padding: -header.size & BLOCK_SIZE_MASK22
|
|
28749
|
+
};
|
|
28750
|
+
state = STATE_BODY22;
|
|
28751
|
+
return header;
|
|
28752
|
+
}
|
|
28753
|
+
},
|
|
28754
|
+
streamBody(callback) {
|
|
28755
|
+
if (state !== STATE_BODY22 || !currentEntry || currentEntry.remaining === 0)
|
|
28756
|
+
return 0;
|
|
28757
|
+
const bytesToFeed = Math.min(currentEntry.remaining, available());
|
|
28758
|
+
if (bytesToFeed === 0)
|
|
28759
|
+
return 0;
|
|
28760
|
+
const fed = pull(bytesToFeed, callback);
|
|
28761
|
+
currentEntry.remaining -= fed;
|
|
28762
|
+
return fed;
|
|
28763
|
+
},
|
|
28764
|
+
skipPadding() {
|
|
28765
|
+
if (state !== STATE_BODY22 || !currentEntry)
|
|
28766
|
+
return true;
|
|
28767
|
+
if (currentEntry.remaining > 0)
|
|
28768
|
+
throw new Error("Body not fully consumed");
|
|
28769
|
+
if (available() < currentEntry.padding)
|
|
28770
|
+
return false;
|
|
28771
|
+
discard(currentEntry.padding);
|
|
28772
|
+
currentEntry = null;
|
|
28773
|
+
state = STATE_HEADER22;
|
|
28774
|
+
return true;
|
|
28775
|
+
},
|
|
28776
|
+
skipEntry() {
|
|
28777
|
+
if (state !== STATE_BODY22 || !currentEntry)
|
|
28778
|
+
return true;
|
|
28779
|
+
const toDiscard = Math.min(currentEntry.remaining, available());
|
|
28780
|
+
if (toDiscard > 0) {
|
|
28781
|
+
discard(toDiscard);
|
|
28782
|
+
currentEntry.remaining -= toDiscard;
|
|
28783
|
+
}
|
|
28784
|
+
if (currentEntry.remaining > 0)
|
|
28785
|
+
return false;
|
|
28786
|
+
return unpacker.skipPadding();
|
|
28787
|
+
},
|
|
28788
|
+
validateEOF() {
|
|
28789
|
+
if (strict) {
|
|
28790
|
+
if (!eof)
|
|
28791
|
+
throw truncateErr22;
|
|
28792
|
+
if (available() > 0) {
|
|
28793
|
+
if (pull(available()).some((byte) => byte !== 0))
|
|
28794
|
+
throw new Error("Invalid EOF.");
|
|
28795
|
+
}
|
|
28796
|
+
}
|
|
28797
|
+
}
|
|
28798
|
+
};
|
|
28799
|
+
return unpacker;
|
|
28800
|
+
}
|
|
28801
|
+
function isZeroBlock22(block) {
|
|
28802
|
+
if (block.byteOffset % 8 === 0) {
|
|
28803
|
+
const view = new BigUint64Array(block.buffer, block.byteOffset, block.length / 8);
|
|
28804
|
+
for (let i = 0;i < view.length; i++)
|
|
28805
|
+
if (view[i] !== 0n)
|
|
28806
|
+
return false;
|
|
28807
|
+
return true;
|
|
28808
|
+
}
|
|
28809
|
+
for (let i = 0;i < block.length; i++)
|
|
28810
|
+
if (block[i] !== 0)
|
|
28811
|
+
return false;
|
|
28812
|
+
return true;
|
|
28813
|
+
}
|
|
28814
|
+
function createTarPacker222() {
|
|
28815
|
+
let streamController;
|
|
28816
|
+
let packer;
|
|
28817
|
+
return {
|
|
28818
|
+
readable: new ReadableStream({ start(controller) {
|
|
28819
|
+
streamController = controller;
|
|
28820
|
+
packer = createTarPacker32(controller.enqueue.bind(controller), controller.error.bind(controller), controller.close.bind(controller));
|
|
28821
|
+
} }),
|
|
28822
|
+
controller: {
|
|
28823
|
+
add(header) {
|
|
28824
|
+
const bodyless = isBodyless22(header);
|
|
28825
|
+
const h = { ...header };
|
|
28826
|
+
if (bodyless)
|
|
28827
|
+
h.size = 0;
|
|
28828
|
+
packer.add(h);
|
|
28829
|
+
if (bodyless)
|
|
28830
|
+
packer.endEntry();
|
|
28831
|
+
return new WritableStream({
|
|
28832
|
+
write(chunk) {
|
|
28833
|
+
packer.write(chunk);
|
|
28834
|
+
},
|
|
28835
|
+
close() {
|
|
28836
|
+
if (!bodyless)
|
|
28837
|
+
packer.endEntry();
|
|
28838
|
+
},
|
|
28839
|
+
abort(reason) {
|
|
28840
|
+
streamController.error(reason);
|
|
28841
|
+
}
|
|
28842
|
+
});
|
|
28843
|
+
},
|
|
28844
|
+
finalize() {
|
|
28845
|
+
packer.finalize();
|
|
28846
|
+
},
|
|
28847
|
+
error(err) {
|
|
28848
|
+
streamController.error(err);
|
|
28849
|
+
}
|
|
28850
|
+
}
|
|
28851
|
+
};
|
|
28852
|
+
}
|
|
28853
|
+
async function streamToBuffer22(stream) {
|
|
28854
|
+
const chunks = [];
|
|
28855
|
+
const reader = stream.getReader();
|
|
28856
|
+
let totalLength = 0;
|
|
28857
|
+
try {
|
|
28858
|
+
while (true) {
|
|
28859
|
+
const { done, value } = await reader.read();
|
|
28860
|
+
if (done)
|
|
28861
|
+
break;
|
|
28862
|
+
chunks.push(value);
|
|
28863
|
+
totalLength += value.length;
|
|
28864
|
+
}
|
|
28865
|
+
const result = new Uint8Array(totalLength);
|
|
28866
|
+
let offset = 0;
|
|
28867
|
+
for (const chunk of chunks) {
|
|
28868
|
+
result.set(chunk, offset);
|
|
28869
|
+
offset += chunk.length;
|
|
28870
|
+
}
|
|
28871
|
+
return result;
|
|
28872
|
+
} finally {
|
|
28873
|
+
reader.releaseLock();
|
|
28874
|
+
}
|
|
28875
|
+
}
|
|
28876
|
+
var drain22 = (stream) => stream.pipeTo(new WritableStream);
|
|
28877
|
+
function createTarDecoder22(options = {}) {
|
|
28878
|
+
const unpacker = createUnpacker22(options);
|
|
28879
|
+
let bodyController = null;
|
|
28880
|
+
let pumping = false;
|
|
28881
|
+
const pump = (controller) => {
|
|
28882
|
+
if (pumping)
|
|
28883
|
+
return;
|
|
28884
|
+
pumping = true;
|
|
28885
|
+
try {
|
|
28886
|
+
while (true)
|
|
28887
|
+
if (unpacker.isEntryActive()) {
|
|
28888
|
+
if (bodyController) {
|
|
28889
|
+
if (unpacker.streamBody((c) => (bodyController.enqueue(c), true)) === 0 && !unpacker.isBodyComplete())
|
|
28890
|
+
break;
|
|
28891
|
+
} else if (!unpacker.skipEntry())
|
|
28892
|
+
break;
|
|
28893
|
+
if (unpacker.isBodyComplete()) {
|
|
28894
|
+
try {
|
|
28895
|
+
bodyController?.close();
|
|
28896
|
+
} catch {}
|
|
28897
|
+
bodyController = null;
|
|
28898
|
+
if (!unpacker.skipPadding())
|
|
28899
|
+
break;
|
|
28900
|
+
}
|
|
28901
|
+
} else {
|
|
28902
|
+
const header = unpacker.readHeader();
|
|
28903
|
+
if (header === null || header === undefined)
|
|
28904
|
+
break;
|
|
28905
|
+
controller.enqueue({
|
|
28906
|
+
header,
|
|
28907
|
+
body: new ReadableStream({
|
|
28908
|
+
start(c) {
|
|
28909
|
+
if (header.size === 0)
|
|
28910
|
+
c.close();
|
|
28911
|
+
else
|
|
28912
|
+
bodyController = c;
|
|
28913
|
+
},
|
|
28914
|
+
pull: () => pump(controller),
|
|
28915
|
+
cancel() {
|
|
28916
|
+
bodyController = null;
|
|
28917
|
+
pump(controller);
|
|
28918
|
+
}
|
|
28919
|
+
})
|
|
28920
|
+
});
|
|
28921
|
+
}
|
|
28922
|
+
} catch (error) {
|
|
28923
|
+
try {
|
|
28924
|
+
bodyController?.error(error);
|
|
28925
|
+
} catch {}
|
|
28926
|
+
bodyController = null;
|
|
28927
|
+
throw error;
|
|
28928
|
+
} finally {
|
|
28929
|
+
pumping = false;
|
|
28930
|
+
}
|
|
28931
|
+
};
|
|
28932
|
+
return new TransformStream({
|
|
28933
|
+
transform(chunk, controller) {
|
|
28934
|
+
try {
|
|
28935
|
+
unpacker.write(chunk);
|
|
28936
|
+
pump(controller);
|
|
28937
|
+
} catch (error) {
|
|
28938
|
+
try {
|
|
28939
|
+
bodyController?.error(error);
|
|
28940
|
+
} catch {}
|
|
28941
|
+
throw error;
|
|
28942
|
+
}
|
|
28943
|
+
},
|
|
28944
|
+
flush(controller) {
|
|
28945
|
+
try {
|
|
28946
|
+
unpacker.end();
|
|
28947
|
+
pump(controller);
|
|
28948
|
+
unpacker.validateEOF();
|
|
28949
|
+
if (unpacker.isEntryActive() && !unpacker.isBodyComplete())
|
|
28950
|
+
try {
|
|
28951
|
+
bodyController?.close();
|
|
28952
|
+
} catch {}
|
|
28953
|
+
} catch (error) {
|
|
28954
|
+
try {
|
|
28955
|
+
bodyController?.error(error);
|
|
28956
|
+
} catch {}
|
|
28957
|
+
throw error;
|
|
28958
|
+
}
|
|
28959
|
+
}
|
|
28960
|
+
}, undefined, { highWaterMark: 1 });
|
|
28961
|
+
}
|
|
28962
|
+
async function packTar22(entries) {
|
|
28963
|
+
const { readable, controller } = createTarPacker222();
|
|
28964
|
+
await (async () => {
|
|
28965
|
+
for (const entry of entries) {
|
|
28966
|
+
const entryStream = controller.add(entry.header);
|
|
28967
|
+
const body = "body" in entry ? entry.body : entry.data;
|
|
28968
|
+
if (!body) {
|
|
28969
|
+
await entryStream.close();
|
|
28970
|
+
continue;
|
|
28971
|
+
}
|
|
28972
|
+
if (body instanceof ReadableStream)
|
|
28973
|
+
await body.pipeTo(entryStream);
|
|
28974
|
+
else if (body instanceof Blob)
|
|
28975
|
+
await body.stream().pipeTo(entryStream);
|
|
28976
|
+
else
|
|
28977
|
+
try {
|
|
28978
|
+
const chunk = await normalizeBody22(body);
|
|
28979
|
+
if (chunk.length > 0) {
|
|
28980
|
+
const writer = entryStream.getWriter();
|
|
28981
|
+
await writer.write(chunk);
|
|
28982
|
+
await writer.close();
|
|
28983
|
+
} else
|
|
28984
|
+
await entryStream.close();
|
|
28985
|
+
} catch {
|
|
28986
|
+
throw new TypeError(`Unsupported content type for entry "${entry.header.name}".`);
|
|
28987
|
+
}
|
|
28988
|
+
}
|
|
28989
|
+
})().then(() => controller.finalize()).catch((err) => controller.error(err));
|
|
28990
|
+
return new Uint8Array(await streamToBuffer22(readable));
|
|
28991
|
+
}
|
|
28992
|
+
async function unpackTar22(archive, options = {}) {
|
|
28993
|
+
const sourceStream = archive instanceof ReadableStream ? archive : new ReadableStream({ start(controller) {
|
|
28994
|
+
controller.enqueue(archive instanceof Uint8Array ? archive : new Uint8Array(archive));
|
|
28995
|
+
controller.close();
|
|
28996
|
+
} });
|
|
28997
|
+
const results = [];
|
|
28998
|
+
const entryStream = sourceStream.pipeThrough(createTarDecoder22(options));
|
|
28999
|
+
for await (const entry of entryStream) {
|
|
29000
|
+
let processedHeader;
|
|
29001
|
+
try {
|
|
29002
|
+
processedHeader = transformHeader22(entry.header, options);
|
|
29003
|
+
} catch (error) {
|
|
29004
|
+
await entry.body.cancel();
|
|
29005
|
+
throw error;
|
|
29006
|
+
}
|
|
29007
|
+
if (processedHeader === null) {
|
|
29008
|
+
await drain22(entry.body);
|
|
29009
|
+
continue;
|
|
29010
|
+
}
|
|
29011
|
+
if (isBodyless22(processedHeader)) {
|
|
29012
|
+
await drain22(entry.body);
|
|
29013
|
+
results.push({ header: processedHeader });
|
|
29014
|
+
} else
|
|
29015
|
+
results.push({
|
|
29016
|
+
header: processedHeader,
|
|
29017
|
+
data: await streamToBuffer22(entry.body)
|
|
29018
|
+
});
|
|
29019
|
+
}
|
|
29020
|
+
return results;
|
|
29021
|
+
}
|
|
29022
|
+
var gzipAsync32 = promisify32(gzip32);
|
|
29023
|
+
var gunzipAsync32 = promisify32(gunzip32);
|
|
29024
|
+
|
|
29025
|
+
class RXPImpl22 {
|
|
29026
|
+
_files;
|
|
29027
|
+
_pathsCache = null;
|
|
29028
|
+
_treeCache = null;
|
|
29029
|
+
constructor(files) {
|
|
29030
|
+
this._files = files;
|
|
29031
|
+
}
|
|
29032
|
+
paths() {
|
|
29033
|
+
if (this._pathsCache) {
|
|
29034
|
+
return this._pathsCache;
|
|
29035
|
+
}
|
|
29036
|
+
this._pathsCache = Array.from(this._files.keys()).sort();
|
|
29037
|
+
return this._pathsCache;
|
|
29038
|
+
}
|
|
29039
|
+
tree() {
|
|
29040
|
+
if (this._treeCache) {
|
|
29041
|
+
return this._treeCache;
|
|
29042
|
+
}
|
|
29043
|
+
const root = new Map;
|
|
29044
|
+
for (const path of this._files.keys()) {
|
|
29045
|
+
const parts = path.split("/");
|
|
29046
|
+
let currentLevel = root;
|
|
29047
|
+
for (let i = 0;i < parts.length; i++) {
|
|
29048
|
+
const part = parts[i];
|
|
29049
|
+
const isFile = i === parts.length - 1;
|
|
29050
|
+
if (!currentLevel.has(part)) {
|
|
29051
|
+
const treeNode2 = {
|
|
29052
|
+
node: {
|
|
29053
|
+
name: part,
|
|
29054
|
+
type: isFile ? "file" : "directory",
|
|
29055
|
+
children: isFile ? undefined : []
|
|
29056
|
+
},
|
|
29057
|
+
children: new Map
|
|
29058
|
+
};
|
|
29059
|
+
currentLevel.set(part, treeNode2);
|
|
29060
|
+
}
|
|
29061
|
+
const treeNode = currentLevel.get(part);
|
|
29062
|
+
if (!isFile) {
|
|
29063
|
+
currentLevel = treeNode.children;
|
|
29064
|
+
}
|
|
29065
|
+
}
|
|
29066
|
+
}
|
|
29067
|
+
const convertToPathNodes = (level) => {
|
|
29068
|
+
return Array.from(level.values()).map((treeNode) => {
|
|
29069
|
+
if (treeNode.node.type === "directory" && treeNode.children.size > 0) {
|
|
29070
|
+
treeNode.node.children = convertToPathNodes(treeNode.children);
|
|
29071
|
+
}
|
|
29072
|
+
return treeNode.node;
|
|
29073
|
+
});
|
|
29074
|
+
};
|
|
29075
|
+
this._treeCache = convertToPathNodes(root);
|
|
29076
|
+
return this._treeCache;
|
|
29077
|
+
}
|
|
29078
|
+
async file(path) {
|
|
29079
|
+
const content = this._files.get(path);
|
|
29080
|
+
if (!content) {
|
|
29081
|
+
throw new ContentError22(`file not found: ${path}`);
|
|
29082
|
+
}
|
|
29083
|
+
return content;
|
|
29084
|
+
}
|
|
29085
|
+
async files() {
|
|
29086
|
+
return new Map(this._files);
|
|
29087
|
+
}
|
|
29088
|
+
async pack() {
|
|
29089
|
+
const filesRecord = {};
|
|
29090
|
+
for (const [path, content] of this._files) {
|
|
29091
|
+
filesRecord[path] = content;
|
|
29092
|
+
}
|
|
29093
|
+
return createRXA22(filesRecord);
|
|
29094
|
+
}
|
|
29095
|
+
}
|
|
29096
|
+
|
|
29097
|
+
class RXAImpl22 {
|
|
29098
|
+
_buffer;
|
|
29099
|
+
_rxpCache = null;
|
|
29100
|
+
constructor(buffer) {
|
|
29101
|
+
this._buffer = buffer;
|
|
29102
|
+
}
|
|
29103
|
+
get stream() {
|
|
29104
|
+
const buffer = this._buffer;
|
|
29105
|
+
return new ReadableStream({
|
|
29106
|
+
start(controller) {
|
|
29107
|
+
controller.enqueue(new Uint8Array(buffer));
|
|
29108
|
+
controller.close();
|
|
29109
|
+
}
|
|
29110
|
+
});
|
|
29111
|
+
}
|
|
29112
|
+
async buffer() {
|
|
29113
|
+
return this._buffer;
|
|
29114
|
+
}
|
|
29115
|
+
async extract() {
|
|
29116
|
+
if (this._rxpCache) {
|
|
29117
|
+
return this._rxpCache;
|
|
29118
|
+
}
|
|
29119
|
+
const tarBuffer = await gunzipAsync32(this._buffer);
|
|
29120
|
+
const entries = await unpackTar22(tarBuffer);
|
|
29121
|
+
const filesMap = new Map;
|
|
29122
|
+
for (const entry of entries) {
|
|
29123
|
+
if ((entry.header.type === "file" || entry.header.type === undefined) && entry.data) {
|
|
29124
|
+
filesMap.set(entry.header.name, Buffer.from(entry.data));
|
|
29125
|
+
}
|
|
29126
|
+
}
|
|
29127
|
+
this._rxpCache = new RXPImpl22(filesMap);
|
|
29128
|
+
return this._rxpCache;
|
|
29129
|
+
}
|
|
29130
|
+
}
|
|
29131
|
+
function isBufferInput22(input) {
|
|
29132
|
+
return "buffer" in input && Buffer.isBuffer(input.buffer);
|
|
29133
|
+
}
|
|
29134
|
+
async function createRXA22(input) {
|
|
29135
|
+
if (isBufferInput22(input)) {
|
|
29136
|
+
return new RXAImpl22(input.buffer);
|
|
29137
|
+
}
|
|
29138
|
+
const entries = Object.entries(input).map(([name, content]) => {
|
|
29139
|
+
const body = typeof content === "string" ? content : content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
29140
|
+
const size = typeof content === "string" ? Buffer.byteLength(content) : content.length;
|
|
29141
|
+
return {
|
|
29142
|
+
header: { name, size, type: "file" },
|
|
29143
|
+
body
|
|
29144
|
+
};
|
|
29145
|
+
});
|
|
29146
|
+
const tarBuffer = await packTar22(entries);
|
|
29147
|
+
const gzipBuffer = await gzipAsync32(Buffer.from(tarBuffer));
|
|
29148
|
+
return new RXAImpl22(gzipBuffer);
|
|
29149
|
+
}
|
|
29150
|
+
|
|
29151
|
+
class FolderLoader {
|
|
29152
|
+
async canLoad(source) {
|
|
29153
|
+
try {
|
|
29154
|
+
const stats = await stat2(source);
|
|
29155
|
+
if (!stats.isDirectory()) {
|
|
29156
|
+
return false;
|
|
29157
|
+
}
|
|
29158
|
+
const manifestPath = join2(source, "resource.json");
|
|
29159
|
+
const manifestStats = await stat2(manifestPath);
|
|
29160
|
+
return manifestStats.isFile();
|
|
29161
|
+
} catch {
|
|
29162
|
+
return false;
|
|
29163
|
+
}
|
|
29164
|
+
}
|
|
29165
|
+
async load(folderPath) {
|
|
29166
|
+
const manifestPath = join2(folderPath, "resource.json");
|
|
29167
|
+
let manifestJson;
|
|
29168
|
+
try {
|
|
29169
|
+
manifestJson = await readFile2(manifestPath, "utf-8");
|
|
29170
|
+
} catch (error) {
|
|
29171
|
+
throw new ResourceXError32(`Failed to read resource.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
29172
|
+
}
|
|
29173
|
+
let manifestData;
|
|
29174
|
+
try {
|
|
29175
|
+
manifestData = JSON.parse(manifestJson);
|
|
29176
|
+
} catch (error) {
|
|
29177
|
+
throw new ResourceXError32(`Invalid JSON in resource.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
29178
|
+
}
|
|
29179
|
+
if (!manifestData.name) {
|
|
29180
|
+
throw new ResourceXError32("Invalid resource.json: missing required field 'name'");
|
|
29181
|
+
}
|
|
29182
|
+
if (!manifestData.type) {
|
|
29183
|
+
throw new ResourceXError32("Invalid resource.json: missing required field 'type'");
|
|
29184
|
+
}
|
|
29185
|
+
if (!manifestData.version) {
|
|
29186
|
+
throw new ResourceXError32("Invalid resource.json: missing required field 'version'");
|
|
29187
|
+
}
|
|
29188
|
+
const manifest = createRXM22({
|
|
29189
|
+
domain: manifestData.domain ?? "localhost",
|
|
29190
|
+
path: manifestData.path,
|
|
29191
|
+
name: manifestData.name,
|
|
29192
|
+
type: manifestData.type,
|
|
29193
|
+
version: manifestData.version
|
|
29194
|
+
});
|
|
29195
|
+
const files = await this.readFolderFiles(folderPath);
|
|
29196
|
+
if (Object.keys(files).length === 0) {
|
|
29197
|
+
throw new ResourceXError32("No content files found in resource folder");
|
|
29198
|
+
}
|
|
29199
|
+
const archive = await createRXA22(files);
|
|
29200
|
+
const locator = parseRXL32(manifest.toLocator());
|
|
29201
|
+
return {
|
|
29202
|
+
locator,
|
|
29203
|
+
manifest,
|
|
29204
|
+
archive
|
|
29205
|
+
};
|
|
29206
|
+
}
|
|
29207
|
+
async readFolderFiles(folderPath, basePath = folderPath) {
|
|
29208
|
+
const files = {};
|
|
29209
|
+
const entries = await readdir2(folderPath, { withFileTypes: true });
|
|
29210
|
+
for (const entry of entries) {
|
|
29211
|
+
const fullPath = join2(folderPath, entry.name);
|
|
29212
|
+
const relativePath = relative(basePath, fullPath);
|
|
29213
|
+
if (relativePath === "resource.json") {
|
|
29214
|
+
continue;
|
|
29215
|
+
}
|
|
29216
|
+
if (entry.isFile()) {
|
|
29217
|
+
files[relativePath] = await readFile2(fullPath);
|
|
29218
|
+
} else if (entry.isDirectory()) {
|
|
29219
|
+
const subFiles = await this.readFolderFiles(fullPath, basePath);
|
|
29220
|
+
Object.assign(files, subFiles);
|
|
29221
|
+
}
|
|
29222
|
+
}
|
|
29223
|
+
return files;
|
|
29224
|
+
}
|
|
29225
|
+
}
|
|
29226
|
+
async function loadResource(source, config) {
|
|
29227
|
+
const loader = config?.loader ?? new FolderLoader;
|
|
29228
|
+
const canLoad = await loader.canLoad(source);
|
|
29229
|
+
if (!canLoad) {
|
|
29230
|
+
throw new ResourceXError32(`Cannot load resource from: ${source}`);
|
|
29231
|
+
}
|
|
29232
|
+
return loader.load(source);
|
|
29233
|
+
}
|
|
29234
|
+
var DEFAULT_PATH = `${homedir()}/.resourcex`;
|
|
29235
|
+
|
|
29236
|
+
class LocalRegistry {
|
|
29237
|
+
basePath;
|
|
29238
|
+
typeHandler;
|
|
29239
|
+
arp;
|
|
29240
|
+
constructor(config) {
|
|
29241
|
+
this.basePath = config?.path ?? DEFAULT_PATH;
|
|
29242
|
+
this.typeHandler = TypeHandlerChain2.create();
|
|
29243
|
+
this.arp = createARP();
|
|
29244
|
+
if (config?.types) {
|
|
29245
|
+
for (const type of config.types) {
|
|
29246
|
+
this.typeHandler.register(type);
|
|
29247
|
+
}
|
|
29248
|
+
}
|
|
29249
|
+
}
|
|
29250
|
+
supportType(type) {
|
|
29251
|
+
this.typeHandler.register(type);
|
|
29252
|
+
}
|
|
29253
|
+
toArpUrl(filePath) {
|
|
29254
|
+
return `arp:binary:file://${filePath}`;
|
|
29255
|
+
}
|
|
29256
|
+
buildPath(locator, area) {
|
|
29257
|
+
const rxl = typeof locator === "string" ? parseRXL3(locator) : locator;
|
|
29258
|
+
const resourceName = rxl.type ? `${rxl.name}.${rxl.type}` : rxl.name;
|
|
29259
|
+
const version = rxl.version ?? "latest";
|
|
29260
|
+
if (area === "local") {
|
|
29261
|
+
return join3(this.basePath, "local", resourceName, version);
|
|
29262
|
+
} else {
|
|
29263
|
+
const domain = rxl.domain ?? "localhost";
|
|
29264
|
+
let path = join3(this.basePath, "cache", domain);
|
|
29265
|
+
if (rxl.path) {
|
|
29266
|
+
path = join3(path, rxl.path);
|
|
29267
|
+
}
|
|
29268
|
+
return join3(path, resourceName, version);
|
|
29269
|
+
}
|
|
29270
|
+
}
|
|
29271
|
+
isLocalOnlyLocator(locator) {
|
|
29272
|
+
const rxl = typeof locator === "string" ? parseRXL3(locator) : locator;
|
|
29273
|
+
return !rxl.domain || rxl.domain === "localhost";
|
|
29274
|
+
}
|
|
29275
|
+
async existsAt(resourcePath) {
|
|
29276
|
+
const manifestPath = join3(resourcePath, "manifest.json");
|
|
29277
|
+
const arl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
29278
|
+
return arl.exists();
|
|
29279
|
+
}
|
|
29280
|
+
async findArea(locator) {
|
|
29281
|
+
const localPath = this.buildPath(locator, "local");
|
|
29282
|
+
if (await this.existsAt(localPath)) {
|
|
29283
|
+
return "local";
|
|
29284
|
+
}
|
|
29285
|
+
const cachePath = this.buildPath(locator, "cache");
|
|
29286
|
+
if (await this.existsAt(cachePath)) {
|
|
29287
|
+
return "cache";
|
|
29288
|
+
}
|
|
29289
|
+
return null;
|
|
29290
|
+
}
|
|
29291
|
+
async isSymlink(path) {
|
|
29292
|
+
try {
|
|
29293
|
+
const stats = await lstat(path);
|
|
29294
|
+
return stats.isSymbolicLink();
|
|
29295
|
+
} catch {
|
|
29296
|
+
return false;
|
|
29297
|
+
}
|
|
29298
|
+
}
|
|
29299
|
+
async loadFrom(resourcePath) {
|
|
29300
|
+
if (await this.isSymlink(resourcePath)) {
|
|
29301
|
+
const targetPath = await readlink(resourcePath);
|
|
29302
|
+
return loadResource(targetPath);
|
|
29303
|
+
}
|
|
29304
|
+
const manifestPath = join3(resourcePath, "manifest.json");
|
|
29305
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
29306
|
+
const manifestResource = await manifestArl.resolve();
|
|
29307
|
+
const manifestContent = manifestResource.content.toString("utf-8");
|
|
29308
|
+
const manifestData = JSON.parse(manifestContent);
|
|
29309
|
+
const manifest = createRXM2(manifestData);
|
|
29310
|
+
const contentPath = join3(resourcePath, "archive.tar.gz");
|
|
29311
|
+
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
29312
|
+
const contentResource = await contentArl.resolve();
|
|
29313
|
+
const data = contentResource.content;
|
|
29314
|
+
return this.typeHandler.deserialize(data, manifest);
|
|
29315
|
+
}
|
|
29316
|
+
async link(path) {
|
|
29317
|
+
const rxr = await loadResource(path);
|
|
29318
|
+
const locator = rxr.manifest.toLocator();
|
|
29319
|
+
const resourcePath = this.buildPath(locator, "local");
|
|
29320
|
+
try {
|
|
29321
|
+
const arl = this.arp.parse(this.toArpUrl(resourcePath));
|
|
29322
|
+
if (await arl.exists()) {
|
|
29323
|
+
await arl.delete();
|
|
29324
|
+
}
|
|
29325
|
+
} catch {}
|
|
29326
|
+
const parentPath = join3(resourcePath, "..");
|
|
29327
|
+
const parentArl = this.arp.parse(this.toArpUrl(parentPath));
|
|
29328
|
+
await parentArl.mkdir();
|
|
29329
|
+
const absolutePath = resolvePath(path);
|
|
29330
|
+
await symlink(absolutePath, resourcePath);
|
|
29331
|
+
}
|
|
29332
|
+
async add(source) {
|
|
29333
|
+
const resource = typeof source === "string" ? await loadResource(source) : source;
|
|
29334
|
+
const locator = resource.manifest.toLocator();
|
|
29335
|
+
const resourcePath = this.buildPath(locator, "local");
|
|
29336
|
+
if (await this.isSymlink(resourcePath)) {
|
|
29337
|
+
const arl = this.arp.parse(this.toArpUrl(resourcePath));
|
|
29338
|
+
await arl.delete();
|
|
29339
|
+
}
|
|
29340
|
+
const dirArl = this.arp.parse(this.toArpUrl(resourcePath));
|
|
29341
|
+
await dirArl.mkdir();
|
|
29342
|
+
const manifestPath = join3(resourcePath, "manifest.json");
|
|
29343
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
29344
|
+
const manifestContent = Buffer.from(JSON.stringify(resource.manifest.toJSON(), null, 2), "utf-8");
|
|
29345
|
+
await manifestArl.deposit(manifestContent);
|
|
29346
|
+
const contentPath = join3(resourcePath, "archive.tar.gz");
|
|
29347
|
+
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
29348
|
+
const serialized = await this.typeHandler.serialize(resource);
|
|
29349
|
+
await contentArl.deposit(serialized);
|
|
29350
|
+
}
|
|
29351
|
+
async pull(_locator, _options) {
|
|
29352
|
+
throw new RegistryError("Pull not implemented yet - see issue #018");
|
|
29353
|
+
}
|
|
29354
|
+
async publish(_source, _options) {
|
|
29355
|
+
throw new RegistryError("Publish not implemented yet - see issue #018");
|
|
29356
|
+
}
|
|
29357
|
+
async get(locator) {
|
|
29358
|
+
const area = await this.findArea(locator);
|
|
29359
|
+
if (!area) {
|
|
29360
|
+
throw new RegistryError(`Resource not found: ${locator}`);
|
|
29361
|
+
}
|
|
29362
|
+
const resourcePath = this.buildPath(locator, area);
|
|
29363
|
+
return this.loadFrom(resourcePath);
|
|
29364
|
+
}
|
|
29365
|
+
async resolve(locator) {
|
|
29366
|
+
const rxr = await this.get(locator);
|
|
29367
|
+
return this.typeHandler.resolve(rxr);
|
|
27802
29368
|
}
|
|
27803
29369
|
async exists(locator) {
|
|
27804
29370
|
const area = await this.findArea(locator);
|
|
@@ -27823,7 +29389,7 @@ class LocalRegistry {
|
|
|
27823
29389
|
async search(options) {
|
|
27824
29390
|
const { query, limit, offset = 0 } = options ?? {};
|
|
27825
29391
|
const locators = [];
|
|
27826
|
-
const localDir =
|
|
29392
|
+
const localDir = join3(this.basePath, "local");
|
|
27827
29393
|
try {
|
|
27828
29394
|
const localArl = this.arp.parse(this.toArpUrl(localDir));
|
|
27829
29395
|
const localEntries = await localArl.list({ recursive: true, pattern: "*.json" });
|
|
@@ -27835,7 +29401,7 @@ class LocalRegistry {
|
|
|
27835
29401
|
locators.push(rxl);
|
|
27836
29402
|
}
|
|
27837
29403
|
} catch {}
|
|
27838
|
-
const cacheDir =
|
|
29404
|
+
const cacheDir = join3(this.basePath, "cache");
|
|
27839
29405
|
try {
|
|
27840
29406
|
const cacheArl = this.arp.parse(this.toArpUrl(cacheDir));
|
|
27841
29407
|
const cacheEntries = await cacheArl.list({ recursive: true, pattern: "*.json" });
|
|
@@ -27921,6 +29487,12 @@ class LocalRegistry {
|
|
|
27921
29487
|
}
|
|
27922
29488
|
|
|
27923
29489
|
class RemoteRegistry {
|
|
29490
|
+
static canHandle(url) {
|
|
29491
|
+
return url.startsWith("https://") || url.startsWith("http://");
|
|
29492
|
+
}
|
|
29493
|
+
static create(config) {
|
|
29494
|
+
return new RemoteRegistry({ endpoint: config.url });
|
|
29495
|
+
}
|
|
27924
29496
|
endpoint;
|
|
27925
29497
|
typeHandler;
|
|
27926
29498
|
constructor(config) {
|
|
@@ -27930,15 +29502,18 @@ class RemoteRegistry {
|
|
|
27930
29502
|
supportType(type) {
|
|
27931
29503
|
this.typeHandler.register(type);
|
|
27932
29504
|
}
|
|
29505
|
+
async link(_path) {
|
|
29506
|
+
throw new RegistryError("Cannot link to remote registry - use local registry for linking");
|
|
29507
|
+
}
|
|
29508
|
+
async add(_source) {
|
|
29509
|
+
throw new RegistryError("Cannot add to remote registry - use local registry for adding");
|
|
29510
|
+
}
|
|
27933
29511
|
async pull(_locator, _options) {
|
|
27934
29512
|
throw new RegistryError("Cannot pull to remote registry - use local registry for pulling");
|
|
27935
29513
|
}
|
|
27936
|
-
async publish(
|
|
29514
|
+
async publish(_source, _options) {
|
|
27937
29515
|
throw new RegistryError("Remote registry publish not implemented yet");
|
|
27938
29516
|
}
|
|
27939
|
-
async link(_resource) {
|
|
27940
|
-
throw new RegistryError("Cannot link to remote registry - use local registry for linking");
|
|
27941
|
-
}
|
|
27942
29517
|
async get(locator) {
|
|
27943
29518
|
const manifestUrl = `${this.endpoint}/resource?locator=${encodeURIComponent(locator)}`;
|
|
27944
29519
|
const manifestResponse = await fetch(manifestUrl);
|
|
@@ -28013,6 +29588,18 @@ async function discoverRegistry(domain) {
|
|
|
28013
29588
|
throw new RegistryError(`Failed to discover registry for ${domain}: ${error.message}`);
|
|
28014
29589
|
}
|
|
28015
29590
|
}
|
|
29591
|
+
function isUrlConfig(config) {
|
|
29592
|
+
return config !== undefined && "url" in config && !("type" in config) && !("endpoint" in config);
|
|
29593
|
+
}
|
|
29594
|
+
function isRemoteConfig(config) {
|
|
29595
|
+
return config !== undefined && "endpoint" in config;
|
|
29596
|
+
}
|
|
29597
|
+
function isGitConfig(config) {
|
|
29598
|
+
return config !== undefined && "type" in config && config.type === "git";
|
|
29599
|
+
}
|
|
29600
|
+
function isGitHubConfig(config) {
|
|
29601
|
+
return config !== undefined && "type" in config && config.type === "github";
|
|
29602
|
+
}
|
|
28016
29603
|
var import_isomorphic_git = __toESM(require_isomorphic_git(), 1);
|
|
28017
29604
|
var import_simple_get = __toESM(require_simple_get(), 1);
|
|
28018
29605
|
function fromValue(value) {
|
|
@@ -28167,8 +29754,71 @@ async function request({
|
|
|
28167
29754
|
});
|
|
28168
29755
|
});
|
|
28169
29756
|
}
|
|
28170
|
-
var index = { request };
|
|
28171
|
-
var node_default = index;
|
|
29757
|
+
var index = { request };
|
|
29758
|
+
var node_default = index;
|
|
29759
|
+
|
|
29760
|
+
class RegistryMiddleware {
|
|
29761
|
+
inner;
|
|
29762
|
+
constructor(inner) {
|
|
29763
|
+
this.inner = inner;
|
|
29764
|
+
}
|
|
29765
|
+
supportType(type) {
|
|
29766
|
+
this.inner.supportType(type);
|
|
29767
|
+
}
|
|
29768
|
+
link(path) {
|
|
29769
|
+
return this.inner.link(path);
|
|
29770
|
+
}
|
|
29771
|
+
add(source) {
|
|
29772
|
+
return this.inner.add(source);
|
|
29773
|
+
}
|
|
29774
|
+
pull(locator, options) {
|
|
29775
|
+
return this.inner.pull(locator, options);
|
|
29776
|
+
}
|
|
29777
|
+
publish(source, options) {
|
|
29778
|
+
return this.inner.publish(source, options);
|
|
29779
|
+
}
|
|
29780
|
+
get(locator) {
|
|
29781
|
+
return this.inner.get(locator);
|
|
29782
|
+
}
|
|
29783
|
+
resolve(locator) {
|
|
29784
|
+
return this.inner.resolve(locator);
|
|
29785
|
+
}
|
|
29786
|
+
exists(locator) {
|
|
29787
|
+
return this.inner.exists(locator);
|
|
29788
|
+
}
|
|
29789
|
+
delete(locator) {
|
|
29790
|
+
return this.inner.delete(locator);
|
|
29791
|
+
}
|
|
29792
|
+
search(options) {
|
|
29793
|
+
return this.inner.search(options);
|
|
29794
|
+
}
|
|
29795
|
+
}
|
|
29796
|
+
|
|
29797
|
+
class DomainValidation extends RegistryMiddleware {
|
|
29798
|
+
trustedDomain;
|
|
29799
|
+
constructor(inner, trustedDomain) {
|
|
29800
|
+
super(inner);
|
|
29801
|
+
this.trustedDomain = trustedDomain;
|
|
29802
|
+
}
|
|
29803
|
+
validateDomain(rxr) {
|
|
29804
|
+
if (rxr.manifest.domain !== this.trustedDomain) {
|
|
29805
|
+
throw new RegistryError(`Untrusted domain: resource claims "${rxr.manifest.domain}" but registry only trusts "${this.trustedDomain}"`);
|
|
29806
|
+
}
|
|
29807
|
+
}
|
|
29808
|
+
async get(locator) {
|
|
29809
|
+
const rxr = await this.inner.get(locator);
|
|
29810
|
+
this.validateDomain(rxr);
|
|
29811
|
+
return rxr;
|
|
29812
|
+
}
|
|
29813
|
+
async resolve(locator) {
|
|
29814
|
+
const rxr = await this.inner.get(locator);
|
|
29815
|
+
this.validateDomain(rxr);
|
|
29816
|
+
return this.inner.resolve(locator);
|
|
29817
|
+
}
|
|
29818
|
+
}
|
|
29819
|
+
function withDomainValidation(registry, trustedDomain) {
|
|
29820
|
+
return new DomainValidation(registry, trustedDomain);
|
|
29821
|
+
}
|
|
28172
29822
|
var DEFAULT_GIT_CACHE = `${homedir2()}/.resourcex/.git-cache`;
|
|
28173
29823
|
var MAX_RETRIES = 2;
|
|
28174
29824
|
function isLocalPath(url) {
|
|
@@ -28176,6 +29826,19 @@ function isLocalPath(url) {
|
|
|
28176
29826
|
}
|
|
28177
29827
|
|
|
28178
29828
|
class GitRegistry {
|
|
29829
|
+
static canHandle(url) {
|
|
29830
|
+
return url.startsWith("git@") || url.endsWith(".git");
|
|
29831
|
+
}
|
|
29832
|
+
static create(config) {
|
|
29833
|
+
const registry = new GitRegistry({
|
|
29834
|
+
type: "git",
|
|
29835
|
+
url: config.url,
|
|
29836
|
+
ref: config.ref,
|
|
29837
|
+
basePath: config.basePath,
|
|
29838
|
+
domain: config.domain
|
|
29839
|
+
});
|
|
29840
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
29841
|
+
}
|
|
28179
29842
|
url;
|
|
28180
29843
|
ref;
|
|
28181
29844
|
basePath;
|
|
@@ -28201,7 +29864,7 @@ class GitRegistry {
|
|
|
28201
29864
|
normalized = normalized.slice(0, -4);
|
|
28202
29865
|
}
|
|
28203
29866
|
const dirName = normalized.replace(/\//g, "-");
|
|
28204
|
-
return
|
|
29867
|
+
return join4(DEFAULT_GIT_CACHE, dirName);
|
|
28205
29868
|
}
|
|
28206
29869
|
supportType(type) {
|
|
28207
29870
|
this.typeHandler.register(type);
|
|
@@ -28210,7 +29873,7 @@ class GitRegistry {
|
|
|
28210
29873
|
return `arp:binary:file://${filePath}`;
|
|
28211
29874
|
}
|
|
28212
29875
|
async ensureCloned() {
|
|
28213
|
-
const gitDir =
|
|
29876
|
+
const gitDir = join4(this.cacheDir, ".git");
|
|
28214
29877
|
const gitArl = this.arp.parse(this.toArpUrl(gitDir));
|
|
28215
29878
|
if (this.isLocal) {
|
|
28216
29879
|
if (!await gitArl.exists()) {
|
|
@@ -28289,17 +29952,17 @@ class GitRegistry {
|
|
|
28289
29952
|
const rxl = parseRXL3(locator);
|
|
28290
29953
|
const domain = rxl.domain ?? "localhost";
|
|
28291
29954
|
const version = rxl.version ?? "latest";
|
|
28292
|
-
let path =
|
|
29955
|
+
let path = join4(this.cacheDir, this.basePath, domain);
|
|
28293
29956
|
if (rxl.path) {
|
|
28294
|
-
path =
|
|
29957
|
+
path = join4(path, rxl.path);
|
|
28295
29958
|
}
|
|
28296
29959
|
const resourceName = rxl.type ? `${rxl.name}.${rxl.type}` : rxl.name;
|
|
28297
|
-
return
|
|
29960
|
+
return join4(path, resourceName, version);
|
|
28298
29961
|
}
|
|
28299
29962
|
async get(locator) {
|
|
28300
29963
|
await this.ensureCloned();
|
|
28301
29964
|
const resourcePath = this.buildResourcePath(locator);
|
|
28302
|
-
const manifestPath =
|
|
29965
|
+
const manifestPath = join4(resourcePath, "manifest.json");
|
|
28303
29966
|
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
28304
29967
|
if (!await manifestArl.exists()) {
|
|
28305
29968
|
throw new RegistryError(`Resource not found: ${locator}`);
|
|
@@ -28308,7 +29971,7 @@ class GitRegistry {
|
|
|
28308
29971
|
const manifestContent = manifestResource.content.toString("utf-8");
|
|
28309
29972
|
const manifestData = JSON.parse(manifestContent);
|
|
28310
29973
|
const manifest = createRXM2(manifestData);
|
|
28311
|
-
const contentPath =
|
|
29974
|
+
const contentPath = join4(resourcePath, "archive.tar.gz");
|
|
28312
29975
|
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
28313
29976
|
const contentResource = await contentArl.resolve();
|
|
28314
29977
|
const data = contentResource.content;
|
|
@@ -28322,7 +29985,7 @@ class GitRegistry {
|
|
|
28322
29985
|
try {
|
|
28323
29986
|
await this.ensureCloned();
|
|
28324
29987
|
const resourcePath = this.buildResourcePath(locator);
|
|
28325
|
-
const manifestPath =
|
|
29988
|
+
const manifestPath = join4(resourcePath, "manifest.json");
|
|
28326
29989
|
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
28327
29990
|
return await manifestArl.exists();
|
|
28328
29991
|
} catch {
|
|
@@ -28333,7 +29996,7 @@ class GitRegistry {
|
|
|
28333
29996
|
await this.ensureCloned();
|
|
28334
29997
|
const { query, limit, offset = 0 } = options ?? {};
|
|
28335
29998
|
const locators = [];
|
|
28336
|
-
const baseDir =
|
|
29999
|
+
const baseDir = join4(this.cacheDir, this.basePath);
|
|
28337
30000
|
try {
|
|
28338
30001
|
const baseArl = this.arp.parse(this.toArpUrl(baseDir));
|
|
28339
30002
|
const entries = await baseArl.list({ recursive: true, pattern: "*.json" });
|
|
@@ -28393,107 +30056,337 @@ class GitRegistry {
|
|
|
28393
30056
|
return null;
|
|
28394
30057
|
}
|
|
28395
30058
|
}
|
|
30059
|
+
async link(_path) {
|
|
30060
|
+
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.link()");
|
|
30061
|
+
}
|
|
30062
|
+
async add(_source) {
|
|
30063
|
+
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.add()");
|
|
30064
|
+
}
|
|
28396
30065
|
async pull(_locator, _options) {
|
|
28397
30066
|
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.pull()");
|
|
28398
30067
|
}
|
|
28399
|
-
async publish(
|
|
30068
|
+
async publish(_source, _options) {
|
|
28400
30069
|
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.publish()");
|
|
28401
30070
|
}
|
|
28402
|
-
async link(_resource) {
|
|
28403
|
-
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.link()");
|
|
28404
|
-
}
|
|
28405
30071
|
async delete(_locator) {
|
|
28406
30072
|
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.delete()");
|
|
28407
30073
|
}
|
|
28408
30074
|
}
|
|
30075
|
+
var DEFAULT_GITHUB_CACHE = `${homedir3()}/.resourcex/.github-cache`;
|
|
30076
|
+
function parseGitHubUrl(url) {
|
|
30077
|
+
if (!url.startsWith("https://github.com/")) {
|
|
30078
|
+
throw new RegistryError(`Invalid GitHub URL: ${url}. Expected format: https://github.com/owner/repo`);
|
|
30079
|
+
}
|
|
30080
|
+
const path = url.slice("https://github.com/".length);
|
|
30081
|
+
const parts = path.split("/");
|
|
30082
|
+
if (parts.length < 2) {
|
|
30083
|
+
throw new RegistryError(`Invalid GitHub URL: ${url}. Expected format: https://github.com/owner/repo`);
|
|
30084
|
+
}
|
|
30085
|
+
const owner = parts[0];
|
|
30086
|
+
const repo = parts[1];
|
|
30087
|
+
let branch = "main";
|
|
30088
|
+
if (parts.length >= 4 && parts[2] === "tree") {
|
|
30089
|
+
branch = parts[3];
|
|
30090
|
+
}
|
|
30091
|
+
return { owner, repo, branch };
|
|
30092
|
+
}
|
|
30093
|
+
function isGitHubUrl(url) {
|
|
30094
|
+
return url.startsWith("https://github.com/");
|
|
30095
|
+
}
|
|
28409
30096
|
|
|
28410
|
-
class
|
|
28411
|
-
|
|
28412
|
-
|
|
28413
|
-
|
|
30097
|
+
class GitHubRegistry {
|
|
30098
|
+
static canHandle(url) {
|
|
30099
|
+
return isGitHubUrl(url);
|
|
30100
|
+
}
|
|
30101
|
+
static create(config) {
|
|
30102
|
+
const registry = new GitHubRegistry({
|
|
30103
|
+
url: config.url,
|
|
30104
|
+
ref: config.ref,
|
|
30105
|
+
basePath: config.basePath
|
|
30106
|
+
});
|
|
30107
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
30108
|
+
}
|
|
30109
|
+
url;
|
|
30110
|
+
owner;
|
|
30111
|
+
repo;
|
|
30112
|
+
ref;
|
|
30113
|
+
basePath;
|
|
30114
|
+
cacheDir;
|
|
30115
|
+
typeHandler;
|
|
30116
|
+
arp;
|
|
30117
|
+
tarballDownloaded = false;
|
|
30118
|
+
constructor(config) {
|
|
30119
|
+
this.url = config.url;
|
|
30120
|
+
const parsed = parseGitHubUrl(config.url);
|
|
30121
|
+
this.owner = parsed.owner;
|
|
30122
|
+
this.repo = parsed.repo;
|
|
30123
|
+
this.ref = config.ref ?? parsed.branch;
|
|
30124
|
+
this.basePath = config.basePath ?? ".resourcex";
|
|
30125
|
+
this.typeHandler = TypeHandlerChain2.create();
|
|
30126
|
+
this.arp = createARP();
|
|
30127
|
+
this.cacheDir = this.buildCacheDir();
|
|
30128
|
+
}
|
|
30129
|
+
buildCacheDir() {
|
|
30130
|
+
const dirName = `github.com-${this.owner}-${this.repo}`;
|
|
30131
|
+
return join5(DEFAULT_GITHUB_CACHE, dirName);
|
|
28414
30132
|
}
|
|
28415
30133
|
supportType(type) {
|
|
28416
|
-
this.
|
|
30134
|
+
this.typeHandler.register(type);
|
|
28417
30135
|
}
|
|
28418
|
-
|
|
28419
|
-
return
|
|
30136
|
+
toArpUrl(filePath) {
|
|
30137
|
+
return `arp:binary:file://${filePath}`;
|
|
28420
30138
|
}
|
|
28421
|
-
|
|
28422
|
-
return this.
|
|
30139
|
+
getTarballUrl() {
|
|
30140
|
+
return `https://github.com/${this.owner}/${this.repo}/archive/refs/heads/${this.ref}.tar.gz`;
|
|
28423
30141
|
}
|
|
28424
|
-
|
|
28425
|
-
|
|
30142
|
+
async ensureDownloaded() {
|
|
30143
|
+
if (this.tarballDownloaded) {
|
|
30144
|
+
return;
|
|
30145
|
+
}
|
|
30146
|
+
const tarballUrl = this.getTarballUrl();
|
|
30147
|
+
const response = await fetch(tarballUrl, {
|
|
30148
|
+
headers: {
|
|
30149
|
+
"User-Agent": "ResourceX/1.0"
|
|
30150
|
+
}
|
|
30151
|
+
});
|
|
30152
|
+
if (!response.ok) {
|
|
30153
|
+
throw new RegistryError(`Failed to download tarball from ${tarballUrl}: ${response.status} ${response.statusText}`);
|
|
30154
|
+
}
|
|
30155
|
+
const tarballBuffer = Buffer.from(await response.arrayBuffer());
|
|
30156
|
+
await this.extractTarball(tarballBuffer);
|
|
30157
|
+
this.tarballDownloaded = true;
|
|
30158
|
+
}
|
|
30159
|
+
async extractTarball(tarballBuffer) {
|
|
30160
|
+
const tarBuffer = gunzipSync(tarballBuffer);
|
|
30161
|
+
const files = this.parseTar(tarBuffer);
|
|
30162
|
+
const cacheArl = this.arp.parse(this.toArpUrl(this.cacheDir));
|
|
30163
|
+
await cacheArl.mkdir();
|
|
30164
|
+
for (const [path, content] of files) {
|
|
30165
|
+
const parts = path.split("/");
|
|
30166
|
+
if (parts.length < 2)
|
|
30167
|
+
continue;
|
|
30168
|
+
const relativePath = parts.slice(1).join("/");
|
|
30169
|
+
if (!relativePath)
|
|
30170
|
+
continue;
|
|
30171
|
+
const fullPath = join5(this.cacheDir, relativePath);
|
|
30172
|
+
const parentDir = fullPath.substring(0, fullPath.lastIndexOf("/"));
|
|
30173
|
+
if (parentDir) {
|
|
30174
|
+
const parentArl = this.arp.parse(this.toArpUrl(parentDir));
|
|
30175
|
+
await parentArl.mkdir();
|
|
30176
|
+
}
|
|
30177
|
+
const fileArl = this.arp.parse(this.toArpUrl(fullPath));
|
|
30178
|
+
await fileArl.deposit(content);
|
|
30179
|
+
}
|
|
28426
30180
|
}
|
|
28427
|
-
|
|
28428
|
-
|
|
30181
|
+
parseTar(tarBuffer) {
|
|
30182
|
+
const files = new Map;
|
|
30183
|
+
let offset = 0;
|
|
30184
|
+
while (offset < tarBuffer.length) {
|
|
30185
|
+
const header = tarBuffer.subarray(offset, offset + 512);
|
|
30186
|
+
if (header[0] === 0) {
|
|
30187
|
+
break;
|
|
30188
|
+
}
|
|
30189
|
+
let filename = "";
|
|
30190
|
+
for (let i = 0;i < 100 && header[i] !== 0; i++) {
|
|
30191
|
+
filename += String.fromCharCode(header[i]);
|
|
30192
|
+
}
|
|
30193
|
+
let prefix = "";
|
|
30194
|
+
for (let i = 345;i < 500 && header[i] !== 0; i++) {
|
|
30195
|
+
prefix += String.fromCharCode(header[i]);
|
|
30196
|
+
}
|
|
30197
|
+
if (prefix) {
|
|
30198
|
+
filename = prefix + "/" + filename;
|
|
30199
|
+
}
|
|
30200
|
+
let sizeStr = "";
|
|
30201
|
+
for (let i = 124;i < 136 && header[i] !== 0 && header[i] !== 32; i++) {
|
|
30202
|
+
sizeStr += String.fromCharCode(header[i]);
|
|
30203
|
+
}
|
|
30204
|
+
const size = parseInt(sizeStr, 8) || 0;
|
|
30205
|
+
const typeFlag = header[156];
|
|
30206
|
+
offset += 512;
|
|
30207
|
+
if (typeFlag === 48 || typeFlag === 0) {
|
|
30208
|
+
if (size > 0) {
|
|
30209
|
+
const content = tarBuffer.subarray(offset, offset + size);
|
|
30210
|
+
files.set(filename, Buffer.from(content));
|
|
30211
|
+
}
|
|
30212
|
+
}
|
|
30213
|
+
offset += Math.ceil(size / 512) * 512;
|
|
30214
|
+
}
|
|
30215
|
+
return files;
|
|
28429
30216
|
}
|
|
28430
|
-
|
|
28431
|
-
|
|
30217
|
+
buildResourcePath(locator) {
|
|
30218
|
+
const rxl = parseRXL3(locator);
|
|
30219
|
+
const domain = rxl.domain ?? "localhost";
|
|
30220
|
+
const version = rxl.version ?? "latest";
|
|
30221
|
+
let path = join5(this.cacheDir, this.basePath, domain);
|
|
30222
|
+
if (rxl.path) {
|
|
30223
|
+
path = join5(path, rxl.path);
|
|
30224
|
+
}
|
|
30225
|
+
const resourceName = rxl.type ? `${rxl.name}.${rxl.type}` : rxl.name;
|
|
30226
|
+
return join5(path, resourceName, version);
|
|
28432
30227
|
}
|
|
28433
|
-
|
|
28434
|
-
|
|
30228
|
+
async get(locator) {
|
|
30229
|
+
await this.ensureDownloaded();
|
|
30230
|
+
const resourcePath = this.buildResourcePath(locator);
|
|
30231
|
+
const manifestPath = join5(resourcePath, "manifest.json");
|
|
30232
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
30233
|
+
if (!await manifestArl.exists()) {
|
|
30234
|
+
throw new RegistryError(`Resource not found: ${locator}`);
|
|
30235
|
+
}
|
|
30236
|
+
const manifestResource = await manifestArl.resolve();
|
|
30237
|
+
const manifestContent = manifestResource.content.toString("utf-8");
|
|
30238
|
+
const manifestData = JSON.parse(manifestContent);
|
|
30239
|
+
const manifest = createRXM2(manifestData);
|
|
30240
|
+
const contentPath = join5(resourcePath, "archive.tar.gz");
|
|
30241
|
+
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
30242
|
+
const contentResource = await contentArl.resolve();
|
|
30243
|
+
const data = contentResource.content;
|
|
30244
|
+
return this.typeHandler.deserialize(data, manifest);
|
|
28435
30245
|
}
|
|
28436
|
-
|
|
28437
|
-
|
|
30246
|
+
async resolve(locator) {
|
|
30247
|
+
const rxr = await this.get(locator);
|
|
30248
|
+
return this.typeHandler.resolve(rxr);
|
|
28438
30249
|
}
|
|
28439
|
-
|
|
28440
|
-
|
|
30250
|
+
async exists(locator) {
|
|
30251
|
+
try {
|
|
30252
|
+
await this.ensureDownloaded();
|
|
30253
|
+
const resourcePath = this.buildResourcePath(locator);
|
|
30254
|
+
const manifestPath = join5(resourcePath, "manifest.json");
|
|
30255
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
30256
|
+
return await manifestArl.exists();
|
|
30257
|
+
} catch {
|
|
30258
|
+
return false;
|
|
30259
|
+
}
|
|
28441
30260
|
}
|
|
28442
|
-
|
|
28443
|
-
|
|
28444
|
-
|
|
28445
|
-
|
|
28446
|
-
|
|
28447
|
-
|
|
28448
|
-
|
|
30261
|
+
async search(options) {
|
|
30262
|
+
await this.ensureDownloaded();
|
|
30263
|
+
const { query, limit, offset = 0 } = options ?? {};
|
|
30264
|
+
const locators = [];
|
|
30265
|
+
const baseDir = join5(this.cacheDir, this.basePath);
|
|
30266
|
+
try {
|
|
30267
|
+
const baseArl = this.arp.parse(this.toArpUrl(baseDir));
|
|
30268
|
+
const entries = await baseArl.list({ recursive: true, pattern: "*.json" });
|
|
30269
|
+
for (const entry of entries) {
|
|
30270
|
+
if (!entry.endsWith("manifest.json"))
|
|
30271
|
+
continue;
|
|
30272
|
+
const rxl = this.parseEntryToRXL(entry);
|
|
30273
|
+
if (rxl)
|
|
30274
|
+
locators.push(rxl);
|
|
30275
|
+
}
|
|
30276
|
+
} catch {
|
|
30277
|
+
return [];
|
|
30278
|
+
}
|
|
30279
|
+
let filtered = locators;
|
|
30280
|
+
if (query) {
|
|
30281
|
+
const lowerQuery = query.toLowerCase();
|
|
30282
|
+
filtered = locators.filter((rxl) => {
|
|
30283
|
+
const searchText = `${rxl.domain ?? ""} ${rxl.path ?? ""} ${rxl.name} ${rxl.type ?? ""}`.toLowerCase();
|
|
30284
|
+
return searchText.includes(lowerQuery);
|
|
30285
|
+
});
|
|
30286
|
+
}
|
|
30287
|
+
let result = filtered.slice(offset);
|
|
30288
|
+
if (limit !== undefined) {
|
|
30289
|
+
result = result.slice(0, limit);
|
|
30290
|
+
}
|
|
30291
|
+
return result;
|
|
28449
30292
|
}
|
|
28450
|
-
|
|
28451
|
-
|
|
28452
|
-
|
|
30293
|
+
parseEntryToRXL(entry) {
|
|
30294
|
+
const dirPath = entry.replace(/[/\\]manifest\.json$/, "");
|
|
30295
|
+
const parts = dirPath.split(/[/\\]/);
|
|
30296
|
+
if (parts.length < 3)
|
|
30297
|
+
return null;
|
|
30298
|
+
const version = parts.pop();
|
|
30299
|
+
const nameTypePart = parts.pop();
|
|
30300
|
+
const domain = parts.shift();
|
|
30301
|
+
const path = parts.length > 0 ? parts.join("/") : undefined;
|
|
30302
|
+
const dotIndex = nameTypePart.lastIndexOf(".");
|
|
30303
|
+
let name;
|
|
30304
|
+
let type;
|
|
30305
|
+
if (dotIndex !== -1) {
|
|
30306
|
+
name = nameTypePart.substring(0, dotIndex);
|
|
30307
|
+
type = nameTypePart.substring(dotIndex + 1);
|
|
30308
|
+
} else {
|
|
30309
|
+
name = nameTypePart;
|
|
30310
|
+
type = undefined;
|
|
30311
|
+
}
|
|
30312
|
+
let locatorStr = domain;
|
|
30313
|
+
if (path)
|
|
30314
|
+
locatorStr += `/${path}`;
|
|
30315
|
+
locatorStr += `/${name}`;
|
|
30316
|
+
if (type)
|
|
30317
|
+
locatorStr += `.${type}`;
|
|
30318
|
+
locatorStr += `@${version}`;
|
|
30319
|
+
try {
|
|
30320
|
+
return parseRXL3(locatorStr);
|
|
30321
|
+
} catch {
|
|
30322
|
+
return null;
|
|
28453
30323
|
}
|
|
28454
30324
|
}
|
|
28455
|
-
async
|
|
28456
|
-
|
|
28457
|
-
this.validateDomain(rxr);
|
|
28458
|
-
return rxr;
|
|
30325
|
+
async link(_path) {
|
|
30326
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.link()");
|
|
28459
30327
|
}
|
|
28460
|
-
async
|
|
28461
|
-
|
|
28462
|
-
|
|
28463
|
-
|
|
30328
|
+
async add(_source) {
|
|
30329
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.add()");
|
|
30330
|
+
}
|
|
30331
|
+
async pull(_locator, _options) {
|
|
30332
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.pull()");
|
|
30333
|
+
}
|
|
30334
|
+
async publish(_source, _options) {
|
|
30335
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.publish()");
|
|
30336
|
+
}
|
|
30337
|
+
async delete(_locator) {
|
|
30338
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.delete()");
|
|
28464
30339
|
}
|
|
28465
30340
|
}
|
|
28466
|
-
|
|
28467
|
-
|
|
28468
|
-
|
|
28469
|
-
|
|
30341
|
+
var URL_HANDLERS = [
|
|
30342
|
+
GitHubRegistry,
|
|
30343
|
+
GitRegistry,
|
|
30344
|
+
RemoteRegistry
|
|
30345
|
+
];
|
|
30346
|
+
function isRemoteUrl(url) {
|
|
28470
30347
|
return url.startsWith("git@") || url.startsWith("https://") || url.startsWith("http://");
|
|
28471
30348
|
}
|
|
28472
30349
|
function createRegistry(config) {
|
|
28473
30350
|
if (isRemoteConfig(config)) {
|
|
28474
30351
|
return new RemoteRegistry(config);
|
|
28475
30352
|
}
|
|
30353
|
+
if (isGitHubConfig(config)) {
|
|
30354
|
+
const registry = new GitHubRegistry(config);
|
|
30355
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
30356
|
+
}
|
|
28476
30357
|
if (isGitConfig(config)) {
|
|
28477
|
-
if (
|
|
30358
|
+
if (isRemoteUrl(config.url) && !config.domain) {
|
|
28478
30359
|
throw new RegistryError(`Remote git registry requires a trusted domain.
|
|
28479
30360
|
|
|
28480
|
-
` + `
|
|
28481
|
-
` + `
|
|
28482
|
-
` + `2. Explicitly set domain: createRegistry({ type: "git", url: "...", domain: "your-domain.com" })
|
|
28483
|
-
|
|
28484
|
-
` + `This ensures resources from untrusted sources cannot impersonate your domain.`);
|
|
28485
|
-
}
|
|
28486
|
-
const gitRegistry = new GitRegistry(config);
|
|
28487
|
-
if (config.domain) {
|
|
28488
|
-
return withDomainValidation(gitRegistry, config.domain);
|
|
30361
|
+
` + `Use discoverRegistry() or explicitly set domain:
|
|
30362
|
+
` + `createRegistry({ type: "git", url: "...", domain: "your-domain.com" })`);
|
|
28489
30363
|
}
|
|
28490
|
-
|
|
30364
|
+
const registry = new GitRegistry(config);
|
|
30365
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
30366
|
+
}
|
|
30367
|
+
if (isUrlConfig(config)) {
|
|
30368
|
+
return createFromUrl(config);
|
|
28491
30369
|
}
|
|
28492
30370
|
return new LocalRegistry(config);
|
|
28493
30371
|
}
|
|
30372
|
+
function createFromUrl(config) {
|
|
30373
|
+
const { url, domain } = config;
|
|
30374
|
+
if (isRemoteUrl(url) && !domain) {
|
|
30375
|
+
throw new RegistryError(`Remote registry URL requires a trusted domain.
|
|
30376
|
+
|
|
30377
|
+
` + `Use discoverRegistry() or explicitly set domain:
|
|
30378
|
+
` + `createRegistry({ url: "...", domain: "your-domain.com" })`);
|
|
30379
|
+
}
|
|
30380
|
+
for (const Handler of URL_HANDLERS) {
|
|
30381
|
+
if (Handler.canHandle(url)) {
|
|
30382
|
+
return Handler.create(config);
|
|
30383
|
+
}
|
|
30384
|
+
}
|
|
30385
|
+
throw new RegistryError(`No handler found for URL: ${url}`);
|
|
30386
|
+
}
|
|
28494
30387
|
// ../loader/dist/index.js
|
|
28495
|
-
import { join as
|
|
28496
|
-
import { stat as
|
|
30388
|
+
import { join as join6, relative as relative2 } from "node:path";
|
|
30389
|
+
import { stat as stat3, readFile as readFile3, readdir as readdir3 } from "node:fs/promises";
|
|
28497
30390
|
import { gzip as gzip4, gunzip as gunzip4 } from "node:zlib";
|
|
28498
30391
|
import { promisify as promisify4 } from "node:util";
|
|
28499
30392
|
|
|
@@ -29620,9 +31513,81 @@ async function unpackTar4(archive, options = {}) {
|
|
|
29620
31513
|
var gzipAsync4 = promisify4(gzip4);
|
|
29621
31514
|
var gunzipAsync4 = promisify4(gunzip4);
|
|
29622
31515
|
|
|
29623
|
-
class
|
|
31516
|
+
class RXPImpl4 {
|
|
31517
|
+
_files;
|
|
31518
|
+
_pathsCache = null;
|
|
31519
|
+
_treeCache = null;
|
|
31520
|
+
constructor(files) {
|
|
31521
|
+
this._files = files;
|
|
31522
|
+
}
|
|
31523
|
+
paths() {
|
|
31524
|
+
if (this._pathsCache) {
|
|
31525
|
+
return this._pathsCache;
|
|
31526
|
+
}
|
|
31527
|
+
this._pathsCache = Array.from(this._files.keys()).sort();
|
|
31528
|
+
return this._pathsCache;
|
|
31529
|
+
}
|
|
31530
|
+
tree() {
|
|
31531
|
+
if (this._treeCache) {
|
|
31532
|
+
return this._treeCache;
|
|
31533
|
+
}
|
|
31534
|
+
const root = new Map;
|
|
31535
|
+
for (const path of this._files.keys()) {
|
|
31536
|
+
const parts = path.split("/");
|
|
31537
|
+
let currentLevel = root;
|
|
31538
|
+
for (let i = 0;i < parts.length; i++) {
|
|
31539
|
+
const part = parts[i];
|
|
31540
|
+
const isFile = i === parts.length - 1;
|
|
31541
|
+
if (!currentLevel.has(part)) {
|
|
31542
|
+
const treeNode2 = {
|
|
31543
|
+
node: {
|
|
31544
|
+
name: part,
|
|
31545
|
+
type: isFile ? "file" : "directory",
|
|
31546
|
+
children: isFile ? undefined : []
|
|
31547
|
+
},
|
|
31548
|
+
children: new Map
|
|
31549
|
+
};
|
|
31550
|
+
currentLevel.set(part, treeNode2);
|
|
31551
|
+
}
|
|
31552
|
+
const treeNode = currentLevel.get(part);
|
|
31553
|
+
if (!isFile) {
|
|
31554
|
+
currentLevel = treeNode.children;
|
|
31555
|
+
}
|
|
31556
|
+
}
|
|
31557
|
+
}
|
|
31558
|
+
const convertToPathNodes = (level) => {
|
|
31559
|
+
return Array.from(level.values()).map((treeNode) => {
|
|
31560
|
+
if (treeNode.node.type === "directory" && treeNode.children.size > 0) {
|
|
31561
|
+
treeNode.node.children = convertToPathNodes(treeNode.children);
|
|
31562
|
+
}
|
|
31563
|
+
return treeNode.node;
|
|
31564
|
+
});
|
|
31565
|
+
};
|
|
31566
|
+
this._treeCache = convertToPathNodes(root);
|
|
31567
|
+
return this._treeCache;
|
|
31568
|
+
}
|
|
31569
|
+
async file(path) {
|
|
31570
|
+
const content = this._files.get(path);
|
|
31571
|
+
if (!content) {
|
|
31572
|
+
throw new ContentError4(`file not found: ${path}`);
|
|
31573
|
+
}
|
|
31574
|
+
return content;
|
|
31575
|
+
}
|
|
31576
|
+
async files() {
|
|
31577
|
+
return new Map(this._files);
|
|
31578
|
+
}
|
|
31579
|
+
async pack() {
|
|
31580
|
+
const filesRecord = {};
|
|
31581
|
+
for (const [path, content] of this._files) {
|
|
31582
|
+
filesRecord[path] = content;
|
|
31583
|
+
}
|
|
31584
|
+
return createRXA4(filesRecord);
|
|
31585
|
+
}
|
|
31586
|
+
}
|
|
31587
|
+
|
|
31588
|
+
class RXAImpl4 {
|
|
29624
31589
|
_buffer;
|
|
29625
|
-
|
|
31590
|
+
_rxpCache = null;
|
|
29626
31591
|
constructor(buffer) {
|
|
29627
31592
|
this._buffer = buffer;
|
|
29628
31593
|
}
|
|
@@ -29638,17 +31603,9 @@ class RXCImpl4 {
|
|
|
29638
31603
|
async buffer() {
|
|
29639
31604
|
return this._buffer;
|
|
29640
31605
|
}
|
|
29641
|
-
async
|
|
29642
|
-
|
|
29643
|
-
|
|
29644
|
-
if (!content) {
|
|
29645
|
-
throw new ContentError4(`file not found: ${path}`);
|
|
29646
|
-
}
|
|
29647
|
-
return content;
|
|
29648
|
-
}
|
|
29649
|
-
async files() {
|
|
29650
|
-
if (this._filesCache) {
|
|
29651
|
-
return this._filesCache;
|
|
31606
|
+
async extract() {
|
|
31607
|
+
if (this._rxpCache) {
|
|
31608
|
+
return this._rxpCache;
|
|
29652
31609
|
}
|
|
29653
31610
|
const tarBuffer = await gunzipAsync4(this._buffer);
|
|
29654
31611
|
const entries = await unpackTar4(tarBuffer);
|
|
@@ -29658,16 +31615,16 @@ class RXCImpl4 {
|
|
|
29658
31615
|
filesMap.set(entry.header.name, Buffer.from(entry.data));
|
|
29659
31616
|
}
|
|
29660
31617
|
}
|
|
29661
|
-
this.
|
|
29662
|
-
return
|
|
31618
|
+
this._rxpCache = new RXPImpl4(filesMap);
|
|
31619
|
+
return this._rxpCache;
|
|
29663
31620
|
}
|
|
29664
31621
|
}
|
|
29665
|
-
function
|
|
29666
|
-
return "
|
|
31622
|
+
function isBufferInput4(input) {
|
|
31623
|
+
return "buffer" in input && Buffer.isBuffer(input.buffer);
|
|
29667
31624
|
}
|
|
29668
|
-
async function
|
|
29669
|
-
if (
|
|
29670
|
-
return new
|
|
31625
|
+
async function createRXA4(input) {
|
|
31626
|
+
if (isBufferInput4(input)) {
|
|
31627
|
+
return new RXAImpl4(input.buffer);
|
|
29671
31628
|
}
|
|
29672
31629
|
const entries = Object.entries(input).map(([name, content]) => {
|
|
29673
31630
|
const body = typeof content === "string" ? content : content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
@@ -29679,28 +31636,28 @@ async function createRXC4(input) {
|
|
|
29679
31636
|
});
|
|
29680
31637
|
const tarBuffer = await packTar4(entries);
|
|
29681
31638
|
const gzipBuffer = await gzipAsync4(Buffer.from(tarBuffer));
|
|
29682
|
-
return new
|
|
31639
|
+
return new RXAImpl4(gzipBuffer);
|
|
29683
31640
|
}
|
|
29684
31641
|
|
|
29685
|
-
class
|
|
31642
|
+
class FolderLoader2 {
|
|
29686
31643
|
async canLoad(source) {
|
|
29687
31644
|
try {
|
|
29688
|
-
const stats = await
|
|
31645
|
+
const stats = await stat3(source);
|
|
29689
31646
|
if (!stats.isDirectory()) {
|
|
29690
31647
|
return false;
|
|
29691
31648
|
}
|
|
29692
|
-
const manifestPath =
|
|
29693
|
-
const manifestStats = await
|
|
31649
|
+
const manifestPath = join6(source, "resource.json");
|
|
31650
|
+
const manifestStats = await stat3(manifestPath);
|
|
29694
31651
|
return manifestStats.isFile();
|
|
29695
31652
|
} catch {
|
|
29696
31653
|
return false;
|
|
29697
31654
|
}
|
|
29698
31655
|
}
|
|
29699
31656
|
async load(folderPath) {
|
|
29700
|
-
const manifestPath =
|
|
31657
|
+
const manifestPath = join6(folderPath, "resource.json");
|
|
29701
31658
|
let manifestJson;
|
|
29702
31659
|
try {
|
|
29703
|
-
manifestJson = await
|
|
31660
|
+
manifestJson = await readFile3(manifestPath, "utf-8");
|
|
29704
31661
|
} catch (error) {
|
|
29705
31662
|
throw new ResourceXError4(`Failed to read resource.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
29706
31663
|
}
|
|
@@ -29730,25 +31687,25 @@ class FolderLoader {
|
|
|
29730
31687
|
if (Object.keys(files).length === 0) {
|
|
29731
31688
|
throw new ResourceXError4("No content files found in resource folder");
|
|
29732
31689
|
}
|
|
29733
|
-
const
|
|
31690
|
+
const archive = await createRXA4(files);
|
|
29734
31691
|
const locator = parseRXL4(manifest.toLocator());
|
|
29735
31692
|
return {
|
|
29736
31693
|
locator,
|
|
29737
31694
|
manifest,
|
|
29738
|
-
|
|
31695
|
+
archive
|
|
29739
31696
|
};
|
|
29740
31697
|
}
|
|
29741
31698
|
async readFolderFiles(folderPath, basePath = folderPath) {
|
|
29742
31699
|
const files = {};
|
|
29743
|
-
const entries = await
|
|
31700
|
+
const entries = await readdir3(folderPath, { withFileTypes: true });
|
|
29744
31701
|
for (const entry of entries) {
|
|
29745
|
-
const fullPath =
|
|
29746
|
-
const relativePath =
|
|
31702
|
+
const fullPath = join6(folderPath, entry.name);
|
|
31703
|
+
const relativePath = relative2(basePath, fullPath);
|
|
29747
31704
|
if (relativePath === "resource.json") {
|
|
29748
31705
|
continue;
|
|
29749
31706
|
}
|
|
29750
31707
|
if (entry.isFile()) {
|
|
29751
|
-
files[relativePath] = await
|
|
31708
|
+
files[relativePath] = await readFile3(fullPath);
|
|
29752
31709
|
} else if (entry.isDirectory()) {
|
|
29753
31710
|
const subFiles = await this.readFolderFiles(fullPath, basePath);
|
|
29754
31711
|
Object.assign(files, subFiles);
|
|
@@ -29757,8 +31714,8 @@ class FolderLoader {
|
|
|
29757
31714
|
return files;
|
|
29758
31715
|
}
|
|
29759
31716
|
}
|
|
29760
|
-
async function
|
|
29761
|
-
const loader = config?.loader ?? new
|
|
31717
|
+
async function loadResource2(source, config) {
|
|
31718
|
+
const loader = config?.loader ?? new FolderLoader2;
|
|
29762
31719
|
const canLoad = await loader.canLoad(source);
|
|
29763
31720
|
if (!canLoad) {
|
|
29764
31721
|
throw new ResourceXError4(`Cannot load resource from: ${source}`);
|
|
@@ -29767,17 +31724,17 @@ async function loadResource(source, config) {
|
|
|
29767
31724
|
}
|
|
29768
31725
|
|
|
29769
31726
|
// src/index.ts
|
|
29770
|
-
var VERSION = "2.
|
|
31727
|
+
var VERSION = "2.3.0";
|
|
29771
31728
|
export {
|
|
29772
31729
|
withDomainValidation,
|
|
29773
31730
|
textType,
|
|
29774
31731
|
parseRXL,
|
|
29775
|
-
loadResource,
|
|
31732
|
+
loadResource2 as loadResource,
|
|
29776
31733
|
jsonType,
|
|
29777
31734
|
discoverRegistry,
|
|
29778
31735
|
createRegistry,
|
|
29779
31736
|
createRXM,
|
|
29780
|
-
|
|
31737
|
+
createRXA,
|
|
29781
31738
|
builtinTypes,
|
|
29782
31739
|
binaryType,
|
|
29783
31740
|
VERSION,
|
|
@@ -29789,9 +31746,9 @@ export {
|
|
|
29789
31746
|
ManifestError,
|
|
29790
31747
|
LocatorError,
|
|
29791
31748
|
LocalRegistry,
|
|
29792
|
-
FolderLoader,
|
|
31749
|
+
FolderLoader2 as FolderLoader,
|
|
29793
31750
|
DomainValidation,
|
|
29794
31751
|
ContentError
|
|
29795
31752
|
};
|
|
29796
31753
|
|
|
29797
|
-
//# debugId=
|
|
31754
|
+
//# debugId=F895E8556A6AA7E764756E2164756E21
|