@resourcexjs/registry 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/README.md +10 -10
- package/dist/index.d.ts +93 -120
- package/dist/index.js +2166 -402
- package/dist/index.js.map +14 -12
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -3878,7 +3878,7 @@ var require_deflate2 = __commonJS((exports) => {
|
|
|
3878
3878
|
options.raw = true;
|
|
3879
3879
|
return deflate(input, options);
|
|
3880
3880
|
}
|
|
3881
|
-
function
|
|
3881
|
+
function gzip4(input, options) {
|
|
3882
3882
|
options = options || {};
|
|
3883
3883
|
options.gzip = true;
|
|
3884
3884
|
return deflate(input, options);
|
|
@@ -3886,7 +3886,7 @@ var require_deflate2 = __commonJS((exports) => {
|
|
|
3886
3886
|
exports.Deflate = Deflate;
|
|
3887
3887
|
exports.deflate = deflate;
|
|
3888
3888
|
exports.deflateRaw = deflateRaw;
|
|
3889
|
-
exports.gzip =
|
|
3889
|
+
exports.gzip = gzip4;
|
|
3890
3890
|
});
|
|
3891
3891
|
|
|
3892
3892
|
// ../../node_modules/.bun/pako@1.0.11/node_modules/pako/lib/zlib/inffast.js
|
|
@@ -5919,7 +5919,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
5919
5919
|
function makeArray(subject) {
|
|
5920
5920
|
return Array.isArray(subject) ? subject : [subject];
|
|
5921
5921
|
}
|
|
5922
|
-
var
|
|
5922
|
+
var EMPTY4 = "";
|
|
5923
5923
|
var SPACE = " ";
|
|
5924
5924
|
var ESCAPE = "\\";
|
|
5925
5925
|
var REGEX_TEST_BLANK_LINE = /^\s+$/;
|
|
@@ -5937,7 +5937,7 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
5937
5937
|
var define2 = (object, key, value) => Object.defineProperty(object, key, { value });
|
|
5938
5938
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
5939
5939
|
var RETURN_FALSE = () => false;
|
|
5940
|
-
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match :
|
|
5940
|
+
var sanitizeRange = (range) => range.replace(REGEX_REGEXP_RANGE, (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY4);
|
|
5941
5941
|
var cleanRangeBackSlash = (slashes) => {
|
|
5942
5942
|
const { length } = slashes;
|
|
5943
5943
|
return slashes.slice(0, length - length % 2);
|
|
@@ -5945,11 +5945,11 @@ var require_ignore = __commonJS((exports, module) => {
|
|
|
5945
5945
|
var REPLACERS = [
|
|
5946
5946
|
[
|
|
5947
5947
|
/^\uFEFF/,
|
|
5948
|
-
() =>
|
|
5948
|
+
() => EMPTY4
|
|
5949
5949
|
],
|
|
5950
5950
|
[
|
|
5951
5951
|
/((?:\\\\)*?)(\\?\s+)$/,
|
|
5952
|
-
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE :
|
|
5952
|
+
(_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY4)
|
|
5953
5953
|
],
|
|
5954
5954
|
[
|
|
5955
5955
|
/(\\+?)\s/g,
|
|
@@ -6948,17 +6948,17 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
6948
6948
|
const length = Math.ceil((62 + bpath.length + 1) / 8) * 8;
|
|
6949
6949
|
const written = Buffer.alloc(length);
|
|
6950
6950
|
const writer = new BufferCursor(written);
|
|
6951
|
-
const
|
|
6952
|
-
writer.writeUInt32BE(
|
|
6953
|
-
writer.writeUInt32BE(
|
|
6954
|
-
writer.writeUInt32BE(
|
|
6955
|
-
writer.writeUInt32BE(
|
|
6956
|
-
writer.writeUInt32BE(
|
|
6957
|
-
writer.writeUInt32BE(
|
|
6958
|
-
writer.writeUInt32BE(
|
|
6959
|
-
writer.writeUInt32BE(
|
|
6960
|
-
writer.writeUInt32BE(
|
|
6961
|
-
writer.writeUInt32BE(
|
|
6951
|
+
const stat3 = normalizeStats(entry);
|
|
6952
|
+
writer.writeUInt32BE(stat3.ctimeSeconds);
|
|
6953
|
+
writer.writeUInt32BE(stat3.ctimeNanoseconds);
|
|
6954
|
+
writer.writeUInt32BE(stat3.mtimeSeconds);
|
|
6955
|
+
writer.writeUInt32BE(stat3.mtimeNanoseconds);
|
|
6956
|
+
writer.writeUInt32BE(stat3.dev);
|
|
6957
|
+
writer.writeUInt32BE(stat3.ino);
|
|
6958
|
+
writer.writeUInt32BE(stat3.mode);
|
|
6959
|
+
writer.writeUInt32BE(stat3.uid);
|
|
6960
|
+
writer.writeUInt32BE(stat3.gid);
|
|
6961
|
+
writer.writeUInt32BE(stat3.size);
|
|
6962
6962
|
writer.write(entry.oid, 20, "hex");
|
|
6963
6963
|
writer.writeUInt16BE(renderCacheEntryFlags(entry));
|
|
6964
6964
|
writer.write(entry.path, bpath.length, "utf8");
|
|
@@ -7003,13 +7003,13 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
7003
7003
|
};
|
|
7004
7004
|
}
|
|
7005
7005
|
async function updateCachedIndexFile(fs, filepath, cache) {
|
|
7006
|
-
const [
|
|
7006
|
+
const [stat3, rawIndexFile] = await Promise.all([
|
|
7007
7007
|
fs.lstat(filepath),
|
|
7008
7008
|
fs.read(filepath)
|
|
7009
7009
|
]);
|
|
7010
7010
|
const index2 = await GitIndex.from(rawIndexFile);
|
|
7011
7011
|
cache.map.set(filepath, index2);
|
|
7012
|
-
cache.stats.set(filepath,
|
|
7012
|
+
cache.stats.set(filepath, stat3);
|
|
7013
7013
|
}
|
|
7014
7014
|
async function isIndexStale(fs, filepath, cache) {
|
|
7015
7015
|
const savedStats = cache.stats.get(filepath);
|
|
@@ -7476,7 +7476,7 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
7476
7476
|
path += "/";
|
|
7477
7477
|
return isAbsolute ? `/${path}` : path;
|
|
7478
7478
|
}
|
|
7479
|
-
function
|
|
7479
|
+
function join4(...args) {
|
|
7480
7480
|
if (args.length === 0)
|
|
7481
7481
|
return ".";
|
|
7482
7482
|
let joined;
|
|
@@ -7831,7 +7831,7 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
7831
7831
|
}
|
|
7832
7832
|
}
|
|
7833
7833
|
for (const [key, value] of actualRefsToWrite) {
|
|
7834
|
-
await acquireLock(key, async () => fs.write(
|
|
7834
|
+
await acquireLock(key, async () => fs.write(join4(gitdir, key), `${value.trim()}
|
|
7835
7835
|
`, "utf8"));
|
|
7836
7836
|
}
|
|
7837
7837
|
return { pruned };
|
|
@@ -7840,18 +7840,18 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
7840
7840
|
if (!value.match(/[0-9a-f]{40}/)) {
|
|
7841
7841
|
throw new InvalidOidError(value);
|
|
7842
7842
|
}
|
|
7843
|
-
await acquireLock(ref, async () => fs.write(
|
|
7843
|
+
await acquireLock(ref, async () => fs.write(join4(gitdir, ref), `${value.trim()}
|
|
7844
7844
|
`, "utf8"));
|
|
7845
7845
|
}
|
|
7846
7846
|
static async writeSymbolicRef({ fs, gitdir, ref, value }) {
|
|
7847
|
-
await acquireLock(ref, async () => fs.write(
|
|
7847
|
+
await acquireLock(ref, async () => fs.write(join4(gitdir, ref), "ref: " + `${value.trim()}
|
|
7848
7848
|
`, "utf8"));
|
|
7849
7849
|
}
|
|
7850
7850
|
static async deleteRef({ fs, gitdir, ref }) {
|
|
7851
7851
|
return GitRefManager.deleteRefs({ fs, gitdir, refs: [ref] });
|
|
7852
7852
|
}
|
|
7853
7853
|
static async deleteRefs({ fs, gitdir, refs }) {
|
|
7854
|
-
await Promise.all(refs.map((ref) => fs.rm(
|
|
7854
|
+
await Promise.all(refs.map((ref) => fs.rm(join4(gitdir, ref))));
|
|
7855
7855
|
let text = await acquireLock("packed-refs", async () => fs.read(`${gitdir}/packed-refs`, { encoding: "utf8" }));
|
|
7856
7856
|
const packed = GitPackedRefs.from(text);
|
|
7857
7857
|
const beforeSize = packed.refs.size;
|
|
@@ -8771,7 +8771,7 @@ Please file a bug report at https://github.com/isomorphic-git/isomorphic-git/iss
|
|
|
8771
8771
|
format = "content",
|
|
8772
8772
|
getExternalRefDelta
|
|
8773
8773
|
}) {
|
|
8774
|
-
let list = await fs.readdir(
|
|
8774
|
+
let list = await fs.readdir(join4(gitdir, "objects/pack"));
|
|
8775
8775
|
list = list.filter((x) => x.endsWith(".idx"));
|
|
8776
8776
|
for (const filename of list) {
|
|
8777
8777
|
const indexFile = `${gitdir}/objects/pack/${filename}`;
|
|
@@ -9512,9 +9512,9 @@ gpgsig`));
|
|
|
9512
9512
|
}
|
|
9513
9513
|
const tree = GitTree.from(object);
|
|
9514
9514
|
for (const entry2 of tree) {
|
|
9515
|
-
map.set(
|
|
9515
|
+
map.set(join4(filepath, entry2.path), entry2);
|
|
9516
9516
|
}
|
|
9517
|
-
return tree.entries().map((entry2) =>
|
|
9517
|
+
return tree.entries().map((entry2) => join4(filepath, entry2.path));
|
|
9518
9518
|
}
|
|
9519
9519
|
async type(entry) {
|
|
9520
9520
|
if (entry._type === false) {
|
|
@@ -9605,10 +9605,10 @@ gpgsig`));
|
|
|
9605
9605
|
async readdir(entry) {
|
|
9606
9606
|
const filepath = entry._fullpath;
|
|
9607
9607
|
const { fs, dir } = this;
|
|
9608
|
-
const names = await fs.readdir(
|
|
9608
|
+
const names = await fs.readdir(join4(dir, filepath));
|
|
9609
9609
|
if (names === null)
|
|
9610
9610
|
return null;
|
|
9611
|
-
return names.map((name) =>
|
|
9611
|
+
return names.map((name) => join4(filepath, name));
|
|
9612
9612
|
}
|
|
9613
9613
|
async type(entry) {
|
|
9614
9614
|
if (entry._type === false) {
|
|
@@ -9625,21 +9625,21 @@ gpgsig`));
|
|
|
9625
9625
|
async stat(entry) {
|
|
9626
9626
|
if (entry._stat === false) {
|
|
9627
9627
|
const { fs, dir } = this;
|
|
9628
|
-
let
|
|
9629
|
-
if (!
|
|
9628
|
+
let stat3 = await fs.lstat(`${dir}/${entry._fullpath}`);
|
|
9629
|
+
if (!stat3) {
|
|
9630
9630
|
throw new Error(`ENOENT: no such file or directory, lstat '${entry._fullpath}'`);
|
|
9631
9631
|
}
|
|
9632
|
-
let type =
|
|
9633
|
-
if (type === "blob" && !
|
|
9632
|
+
let type = stat3.isDirectory() ? "tree" : "blob";
|
|
9633
|
+
if (type === "blob" && !stat3.isFile() && !stat3.isSymbolicLink()) {
|
|
9634
9634
|
type = "special";
|
|
9635
9635
|
}
|
|
9636
9636
|
entry._type = type;
|
|
9637
|
-
|
|
9638
|
-
entry._mode =
|
|
9639
|
-
if (
|
|
9640
|
-
|
|
9637
|
+
stat3 = normalizeStats(stat3);
|
|
9638
|
+
entry._mode = stat3.mode;
|
|
9639
|
+
if (stat3.size === -1 && entry._actualSize) {
|
|
9640
|
+
stat3.size = entry._actualSize;
|
|
9641
9641
|
}
|
|
9642
|
-
entry._stat =
|
|
9642
|
+
entry._stat = stat3;
|
|
9643
9643
|
}
|
|
9644
9644
|
return entry._stat;
|
|
9645
9645
|
}
|
|
@@ -9821,11 +9821,11 @@ gpgsig`));
|
|
|
9821
9821
|
await fs.rm(filepath);
|
|
9822
9822
|
} else if (entries.length) {
|
|
9823
9823
|
await Promise.all(entries.map((entry) => {
|
|
9824
|
-
const subpath =
|
|
9825
|
-
return fs.lstat(subpath).then((
|
|
9826
|
-
if (!
|
|
9824
|
+
const subpath = join4(filepath, entry);
|
|
9825
|
+
return fs.lstat(subpath).then((stat3) => {
|
|
9826
|
+
if (!stat3)
|
|
9827
9827
|
return;
|
|
9828
|
-
return
|
|
9828
|
+
return stat3.isDirectory() ? rmRecursive(fs, subpath) : fs.rm(subpath);
|
|
9829
9829
|
});
|
|
9830
9830
|
})).then(() => fs.rmdir(filepath));
|
|
9831
9831
|
} else {
|
|
@@ -10043,7 +10043,7 @@ gpgsig`));
|
|
|
10043
10043
|
return dotgit;
|
|
10044
10044
|
} else if (dotgitStat.isFile()) {
|
|
10045
10045
|
return fsp._readFile(dotgit, "utf8").then((contents) => contents.trimRight().substr(8)).then((submoduleGitdir) => {
|
|
10046
|
-
const gitdir =
|
|
10046
|
+
const gitdir = join4(dirname2(dotgit), submoduleGitdir);
|
|
10047
10047
|
return gitdir;
|
|
10048
10048
|
});
|
|
10049
10049
|
} else {
|
|
@@ -10068,7 +10068,7 @@ gpgsig`));
|
|
|
10068
10068
|
async function abortMerge({
|
|
10069
10069
|
fs: _fs,
|
|
10070
10070
|
dir,
|
|
10071
|
-
gitdir =
|
|
10071
|
+
gitdir = join4(dir, ".git"),
|
|
10072
10072
|
commit: commit2 = "HEAD",
|
|
10073
10073
|
cache = {}
|
|
10074
10074
|
}) {
|
|
@@ -10137,19 +10137,19 @@ gpgsig`));
|
|
|
10137
10137
|
}
|
|
10138
10138
|
|
|
10139
10139
|
class GitIgnoreManager {
|
|
10140
|
-
static async isIgnored({ fs, dir, gitdir =
|
|
10140
|
+
static async isIgnored({ fs, dir, gitdir = join4(dir, ".git"), filepath }) {
|
|
10141
10141
|
if (basename(filepath) === ".git")
|
|
10142
10142
|
return true;
|
|
10143
10143
|
if (filepath === ".")
|
|
10144
10144
|
return false;
|
|
10145
10145
|
let excludes = "";
|
|
10146
|
-
const excludesFile =
|
|
10146
|
+
const excludesFile = join4(gitdir, "info", "exclude");
|
|
10147
10147
|
if (await fs.exists(excludesFile)) {
|
|
10148
10148
|
excludes = await fs.read(excludesFile, "utf8");
|
|
10149
10149
|
}
|
|
10150
10150
|
const pairs = [
|
|
10151
10151
|
{
|
|
10152
|
-
gitignore:
|
|
10152
|
+
gitignore: join4(dir, ".gitignore"),
|
|
10153
10153
|
filepath
|
|
10154
10154
|
}
|
|
10155
10155
|
];
|
|
@@ -10158,7 +10158,7 @@ gpgsig`));
|
|
|
10158
10158
|
const folder = pieces.slice(0, i).join("/");
|
|
10159
10159
|
const file = pieces.slice(i).join("/");
|
|
10160
10160
|
pairs.push({
|
|
10161
|
-
gitignore:
|
|
10161
|
+
gitignore: join4(dir, folder, ".gitignore"),
|
|
10162
10162
|
filepath: file
|
|
10163
10163
|
});
|
|
10164
10164
|
}
|
|
@@ -10247,7 +10247,7 @@ gpgsig`));
|
|
|
10247
10247
|
async function add({
|
|
10248
10248
|
fs: _fs,
|
|
10249
10249
|
dir,
|
|
10250
|
-
gitdir =
|
|
10250
|
+
gitdir = join4(dir, ".git"),
|
|
10251
10251
|
filepath,
|
|
10252
10252
|
cache = {},
|
|
10253
10253
|
force = false,
|
|
@@ -10301,17 +10301,17 @@ gpgsig`));
|
|
|
10301
10301
|
if (ignored)
|
|
10302
10302
|
return;
|
|
10303
10303
|
}
|
|
10304
|
-
const stats = await fs.lstat(
|
|
10304
|
+
const stats = await fs.lstat(join4(dir, currentFilepath));
|
|
10305
10305
|
if (!stats)
|
|
10306
10306
|
throw new NotFoundError(currentFilepath);
|
|
10307
10307
|
if (stats.isDirectory()) {
|
|
10308
|
-
const children = await fs.readdir(
|
|
10308
|
+
const children = await fs.readdir(join4(dir, currentFilepath));
|
|
10309
10309
|
if (parallel) {
|
|
10310
10310
|
const promises2 = children.map((child) => addToIndex({
|
|
10311
10311
|
dir,
|
|
10312
10312
|
gitdir,
|
|
10313
10313
|
fs,
|
|
10314
|
-
filepath: [
|
|
10314
|
+
filepath: [join4(currentFilepath, child)],
|
|
10315
10315
|
index: index2,
|
|
10316
10316
|
force,
|
|
10317
10317
|
parallel,
|
|
@@ -10324,7 +10324,7 @@ gpgsig`));
|
|
|
10324
10324
|
dir,
|
|
10325
10325
|
gitdir,
|
|
10326
10326
|
fs,
|
|
10327
|
-
filepath: [
|
|
10327
|
+
filepath: [join4(currentFilepath, child)],
|
|
10328
10328
|
index: index2,
|
|
10329
10329
|
force,
|
|
10330
10330
|
parallel,
|
|
@@ -10333,7 +10333,7 @@ gpgsig`));
|
|
|
10333
10333
|
}
|
|
10334
10334
|
}
|
|
10335
10335
|
} else {
|
|
10336
|
-
const object = stats.isSymbolicLink() ? await fs.readlink(
|
|
10336
|
+
const object = stats.isSymbolicLink() ? await fs.readlink(join4(dir, currentFilepath)).then(posixifyPathBuffer) : await fs.read(join4(dir, currentFilepath), { autocrlf });
|
|
10337
10337
|
if (object === null)
|
|
10338
10338
|
throw new NotFoundError(currentFilepath);
|
|
10339
10339
|
const oid = await _writeObject({ fs, gitdir, type: "blob", object });
|
|
@@ -10729,7 +10729,7 @@ gpgsig`));
|
|
|
10729
10729
|
fs: _fs,
|
|
10730
10730
|
onSign,
|
|
10731
10731
|
dir,
|
|
10732
|
-
gitdir =
|
|
10732
|
+
gitdir = join4(dir, ".git"),
|
|
10733
10733
|
ref = "refs/notes/commits",
|
|
10734
10734
|
oid,
|
|
10735
10735
|
note,
|
|
@@ -10804,7 +10804,7 @@ gpgsig`));
|
|
|
10804
10804
|
async function addRemote({
|
|
10805
10805
|
fs,
|
|
10806
10806
|
dir,
|
|
10807
|
-
gitdir =
|
|
10807
|
+
gitdir = join4(dir, ".git"),
|
|
10808
10808
|
remote,
|
|
10809
10809
|
url,
|
|
10810
10810
|
force = false
|
|
@@ -10874,7 +10874,7 @@ gpgsig`));
|
|
|
10874
10874
|
fs: _fs,
|
|
10875
10875
|
onSign,
|
|
10876
10876
|
dir,
|
|
10877
|
-
gitdir =
|
|
10877
|
+
gitdir = join4(dir, ".git"),
|
|
10878
10878
|
ref,
|
|
10879
10879
|
tagger: _tagger,
|
|
10880
10880
|
message = ref,
|
|
@@ -10955,7 +10955,7 @@ gpgsig`));
|
|
|
10955
10955
|
async function branch({
|
|
10956
10956
|
fs,
|
|
10957
10957
|
dir,
|
|
10958
|
-
gitdir =
|
|
10958
|
+
gitdir = join4(dir, ".git"),
|
|
10959
10959
|
ref,
|
|
10960
10960
|
object,
|
|
10961
10961
|
checkout: checkout2 = false,
|
|
@@ -11526,7 +11526,7 @@ gpgsig`));
|
|
|
11526
11526
|
onProgress,
|
|
11527
11527
|
onPostCheckout,
|
|
11528
11528
|
dir,
|
|
11529
|
-
gitdir =
|
|
11529
|
+
gitdir = join4(dir, ".git"),
|
|
11530
11530
|
remote = "origin",
|
|
11531
11531
|
ref: _ref,
|
|
11532
11532
|
filepaths,
|
|
@@ -11939,7 +11939,7 @@ gpgsig`));
|
|
|
11939
11939
|
static async read({ fs, gitdir }) {
|
|
11940
11940
|
if (lock$2 === null)
|
|
11941
11941
|
lock$2 = new AsyncLock;
|
|
11942
|
-
const filepath =
|
|
11942
|
+
const filepath = join4(gitdir, "shallow");
|
|
11943
11943
|
const oids = new Set;
|
|
11944
11944
|
await lock$2.acquire(filepath, async function() {
|
|
11945
11945
|
const text = await fs.read(filepath, { encoding: "utf8" });
|
|
@@ -11955,7 +11955,7 @@ gpgsig`));
|
|
|
11955
11955
|
static async write({ fs, gitdir, oids }) {
|
|
11956
11956
|
if (lock$2 === null)
|
|
11957
11957
|
lock$2 = new AsyncLock;
|
|
11958
|
-
const filepath =
|
|
11958
|
+
const filepath = join4(gitdir, "shallow");
|
|
11959
11959
|
if (oids.size > 0) {
|
|
11960
11960
|
const text = [...oids].join(`
|
|
11961
11961
|
`) + `
|
|
@@ -11983,7 +11983,7 @@ gpgsig`));
|
|
|
11983
11983
|
oid,
|
|
11984
11984
|
getExternalRefDelta
|
|
11985
11985
|
}) {
|
|
11986
|
-
let list = await fs.readdir(
|
|
11986
|
+
let list = await fs.readdir(join4(gitdir, "objects/pack"));
|
|
11987
11987
|
list = list.filter((x) => x.endsWith(".idx"));
|
|
11988
11988
|
for (const filename of list) {
|
|
11989
11989
|
const indexFile = `${gitdir}/objects/pack/${filename}`;
|
|
@@ -12272,7 +12272,7 @@ gpgsig`));
|
|
|
12272
12272
|
depth = null,
|
|
12273
12273
|
since = null,
|
|
12274
12274
|
exclude = [],
|
|
12275
|
-
relative = false,
|
|
12275
|
+
relative: relative2 = false,
|
|
12276
12276
|
tags = false,
|
|
12277
12277
|
singleBranch = false,
|
|
12278
12278
|
headers = {},
|
|
@@ -12320,7 +12320,7 @@ gpgsig`));
|
|
|
12320
12320
|
if (exclude.length > 0 && !remoteHTTP.capabilities.has("deepen-not")) {
|
|
12321
12321
|
throw new RemoteCapabilityError("deepen-not", "exclude");
|
|
12322
12322
|
}
|
|
12323
|
-
if (
|
|
12323
|
+
if (relative2 === true && !remoteHTTP.capabilities.has("deepen-relative")) {
|
|
12324
12324
|
throw new RemoteCapabilityError("deepen-relative", "relative");
|
|
12325
12325
|
}
|
|
12326
12326
|
const { oid, fullref } = GitRefManager.resolveAgainstMap({
|
|
@@ -12340,7 +12340,7 @@ gpgsig`));
|
|
|
12340
12340
|
"ofs-delta",
|
|
12341
12341
|
`agent=${pkg.agent}`
|
|
12342
12342
|
]);
|
|
12343
|
-
if (
|
|
12343
|
+
if (relative2)
|
|
12344
12344
|
capabilities.push("deepen-relative");
|
|
12345
12345
|
const wants = singleBranch ? [oid] : remoteRefs.values();
|
|
12346
12346
|
const haveRefs = singleBranch ? [ref] : await GitRefManager.listRefs({
|
|
@@ -12499,7 +12499,7 @@ gpgsig`));
|
|
|
12499
12499
|
}
|
|
12500
12500
|
if (packfileSha !== "" && !emptyPackfile(packfile)) {
|
|
12501
12501
|
res.packfile = `objects/pack/pack-${packfileSha}.pack`;
|
|
12502
|
-
const fullpath =
|
|
12502
|
+
const fullpath = join4(gitdir, res.packfile);
|
|
12503
12503
|
await fs.write(fullpath, packfile);
|
|
12504
12504
|
const getExternalRefDelta = (oid2) => _readObject({ fs, cache, gitdir, oid: oid2 });
|
|
12505
12505
|
const idx = await GitPackIndex.fromPack({
|
|
@@ -12515,7 +12515,7 @@ gpgsig`));
|
|
|
12515
12515
|
fs,
|
|
12516
12516
|
bare = false,
|
|
12517
12517
|
dir,
|
|
12518
|
-
gitdir = bare ? dir :
|
|
12518
|
+
gitdir = bare ? dir : join4(dir, ".git"),
|
|
12519
12519
|
defaultBranch = "master"
|
|
12520
12520
|
}) {
|
|
12521
12521
|
if (await fs.exists(gitdir + "/config"))
|
|
@@ -12562,7 +12562,7 @@ gpgsig`));
|
|
|
12562
12562
|
depth,
|
|
12563
12563
|
since,
|
|
12564
12564
|
exclude,
|
|
12565
|
-
relative,
|
|
12565
|
+
relative: relative2,
|
|
12566
12566
|
singleBranch,
|
|
12567
12567
|
noCheckout,
|
|
12568
12568
|
noTags,
|
|
@@ -12594,7 +12594,7 @@ gpgsig`));
|
|
|
12594
12594
|
depth,
|
|
12595
12595
|
since,
|
|
12596
12596
|
exclude,
|
|
12597
|
-
relative,
|
|
12597
|
+
relative: relative2,
|
|
12598
12598
|
singleBranch,
|
|
12599
12599
|
headers,
|
|
12600
12600
|
tags: !noTags
|
|
@@ -12633,7 +12633,7 @@ gpgsig`));
|
|
|
12633
12633
|
onAuthFailure,
|
|
12634
12634
|
onPostCheckout,
|
|
12635
12635
|
dir,
|
|
12636
|
-
gitdir =
|
|
12636
|
+
gitdir = join4(dir, ".git"),
|
|
12637
12637
|
url,
|
|
12638
12638
|
corsProxy = undefined,
|
|
12639
12639
|
ref = undefined,
|
|
@@ -12641,7 +12641,7 @@ gpgsig`));
|
|
|
12641
12641
|
depth = undefined,
|
|
12642
12642
|
since = undefined,
|
|
12643
12643
|
exclude = [],
|
|
12644
|
-
relative = false,
|
|
12644
|
+
relative: relative2 = false,
|
|
12645
12645
|
singleBranch = false,
|
|
12646
12646
|
noCheckout = false,
|
|
12647
12647
|
noTags = false,
|
|
@@ -12679,7 +12679,7 @@ gpgsig`));
|
|
|
12679
12679
|
depth,
|
|
12680
12680
|
since,
|
|
12681
12681
|
exclude,
|
|
12682
|
-
relative,
|
|
12682
|
+
relative: relative2,
|
|
12683
12683
|
singleBranch,
|
|
12684
12684
|
noCheckout,
|
|
12685
12685
|
noTags,
|
|
@@ -12696,7 +12696,7 @@ gpgsig`));
|
|
|
12696
12696
|
fs: _fs,
|
|
12697
12697
|
onSign,
|
|
12698
12698
|
dir,
|
|
12699
|
-
gitdir =
|
|
12699
|
+
gitdir = join4(dir, ".git"),
|
|
12700
12700
|
message,
|
|
12701
12701
|
author,
|
|
12702
12702
|
committer,
|
|
@@ -12743,7 +12743,7 @@ gpgsig`));
|
|
|
12743
12743
|
async function currentBranch({
|
|
12744
12744
|
fs,
|
|
12745
12745
|
dir,
|
|
12746
|
-
gitdir =
|
|
12746
|
+
gitdir = join4(dir, ".git"),
|
|
12747
12747
|
fullname = false,
|
|
12748
12748
|
test = false
|
|
12749
12749
|
}) {
|
|
@@ -12784,7 +12784,7 @@ gpgsig`));
|
|
|
12784
12784
|
async function deleteBranch({
|
|
12785
12785
|
fs,
|
|
12786
12786
|
dir,
|
|
12787
|
-
gitdir =
|
|
12787
|
+
gitdir = join4(dir, ".git"),
|
|
12788
12788
|
ref
|
|
12789
12789
|
}) {
|
|
12790
12790
|
try {
|
|
@@ -12802,7 +12802,7 @@ gpgsig`));
|
|
|
12802
12802
|
throw err;
|
|
12803
12803
|
}
|
|
12804
12804
|
}
|
|
12805
|
-
async function deleteRef({ fs, dir, gitdir =
|
|
12805
|
+
async function deleteRef({ fs, dir, gitdir = join4(dir, ".git"), ref }) {
|
|
12806
12806
|
try {
|
|
12807
12807
|
assertParameter("fs", fs);
|
|
12808
12808
|
assertParameter("ref", ref);
|
|
@@ -12822,7 +12822,7 @@ gpgsig`));
|
|
|
12822
12822
|
async function deleteRemote({
|
|
12823
12823
|
fs,
|
|
12824
12824
|
dir,
|
|
12825
|
-
gitdir =
|
|
12825
|
+
gitdir = join4(dir, ".git"),
|
|
12826
12826
|
remote
|
|
12827
12827
|
}) {
|
|
12828
12828
|
try {
|
|
@@ -12844,7 +12844,7 @@ gpgsig`));
|
|
|
12844
12844
|
ref = ref.startsWith("refs/tags/") ? ref : `refs/tags/${ref}`;
|
|
12845
12845
|
await GitRefManager.deleteRef({ fs, gitdir, ref });
|
|
12846
12846
|
}
|
|
12847
|
-
async function deleteTag({ fs, dir, gitdir =
|
|
12847
|
+
async function deleteTag({ fs, dir, gitdir = join4(dir, ".git"), ref }) {
|
|
12848
12848
|
try {
|
|
12849
12849
|
assertParameter("fs", fs);
|
|
12850
12850
|
assertParameter("ref", ref);
|
|
@@ -12873,7 +12873,7 @@ gpgsig`));
|
|
|
12873
12873
|
getExternalRefDelta
|
|
12874
12874
|
}) {
|
|
12875
12875
|
const results = [];
|
|
12876
|
-
let list = await fs.readdir(
|
|
12876
|
+
let list = await fs.readdir(join4(gitdir, "objects/pack"));
|
|
12877
12877
|
list = list.filter((x) => x.endsWith(".idx"));
|
|
12878
12878
|
for (const filename of list) {
|
|
12879
12879
|
const indexFile = `${gitdir}/objects/pack/${filename}`;
|
|
@@ -12918,7 +12918,7 @@ gpgsig`));
|
|
|
12918
12918
|
async function expandOid({
|
|
12919
12919
|
fs,
|
|
12920
12920
|
dir,
|
|
12921
|
-
gitdir =
|
|
12921
|
+
gitdir = join4(dir, ".git"),
|
|
12922
12922
|
oid,
|
|
12923
12923
|
cache = {}
|
|
12924
12924
|
}) {
|
|
@@ -12939,7 +12939,7 @@ gpgsig`));
|
|
|
12939
12939
|
throw err;
|
|
12940
12940
|
}
|
|
12941
12941
|
}
|
|
12942
|
-
async function expandRef({ fs, dir, gitdir =
|
|
12942
|
+
async function expandRef({ fs, dir, gitdir = join4(dir, ".git"), ref }) {
|
|
12943
12943
|
try {
|
|
12944
12944
|
assertParameter("fs", fs);
|
|
12945
12945
|
assertParameter("gitdir", gitdir);
|
|
@@ -13026,7 +13026,7 @@ gpgsig`));
|
|
|
13026
13026
|
fs,
|
|
13027
13027
|
cache,
|
|
13028
13028
|
dir,
|
|
13029
|
-
gitdir =
|
|
13029
|
+
gitdir = join4(dir, ".git"),
|
|
13030
13030
|
index: index2,
|
|
13031
13031
|
ourOid,
|
|
13032
13032
|
baseOid,
|
|
@@ -13496,7 +13496,7 @@ gpgsig`));
|
|
|
13496
13496
|
onAuthSuccess,
|
|
13497
13497
|
onAuthFailure,
|
|
13498
13498
|
dir,
|
|
13499
|
-
gitdir =
|
|
13499
|
+
gitdir = join4(dir, ".git"),
|
|
13500
13500
|
ref,
|
|
13501
13501
|
url,
|
|
13502
13502
|
remote,
|
|
@@ -13554,7 +13554,7 @@ gpgsig`));
|
|
|
13554
13554
|
onAuthSuccess,
|
|
13555
13555
|
onAuthFailure,
|
|
13556
13556
|
dir,
|
|
13557
|
-
gitdir =
|
|
13557
|
+
gitdir = join4(dir, ".git"),
|
|
13558
13558
|
ref,
|
|
13559
13559
|
remote,
|
|
13560
13560
|
remoteRef,
|
|
@@ -13563,7 +13563,7 @@ gpgsig`));
|
|
|
13563
13563
|
depth = null,
|
|
13564
13564
|
since = null,
|
|
13565
13565
|
exclude = [],
|
|
13566
|
-
relative = false,
|
|
13566
|
+
relative: relative2 = false,
|
|
13567
13567
|
tags = false,
|
|
13568
13568
|
singleBranch = false,
|
|
13569
13569
|
headers = {},
|
|
@@ -13595,7 +13595,7 @@ gpgsig`));
|
|
|
13595
13595
|
depth,
|
|
13596
13596
|
since,
|
|
13597
13597
|
exclude,
|
|
13598
|
-
relative,
|
|
13598
|
+
relative: relative2,
|
|
13599
13599
|
tags,
|
|
13600
13600
|
singleBranch,
|
|
13601
13601
|
headers,
|
|
@@ -13610,7 +13610,7 @@ gpgsig`));
|
|
|
13610
13610
|
async function findMergeBase({
|
|
13611
13611
|
fs,
|
|
13612
13612
|
dir,
|
|
13613
|
-
gitdir =
|
|
13613
|
+
gitdir = join4(dir, ".git"),
|
|
13614
13614
|
oids,
|
|
13615
13615
|
cache = {}
|
|
13616
13616
|
}) {
|
|
@@ -13632,7 +13632,7 @@ gpgsig`));
|
|
|
13632
13632
|
}
|
|
13633
13633
|
}
|
|
13634
13634
|
async function _findRoot({ fs, filepath }) {
|
|
13635
|
-
if (await fs.exists(
|
|
13635
|
+
if (await fs.exists(join4(filepath, ".git"))) {
|
|
13636
13636
|
return filepath;
|
|
13637
13637
|
} else {
|
|
13638
13638
|
const parent = dirname2(filepath);
|
|
@@ -13652,7 +13652,7 @@ gpgsig`));
|
|
|
13652
13652
|
throw err;
|
|
13653
13653
|
}
|
|
13654
13654
|
}
|
|
13655
|
-
async function getConfig({ fs, dir, gitdir =
|
|
13655
|
+
async function getConfig({ fs, dir, gitdir = join4(dir, ".git"), path }) {
|
|
13656
13656
|
try {
|
|
13657
13657
|
assertParameter("fs", fs);
|
|
13658
13658
|
assertParameter("gitdir", gitdir);
|
|
@@ -13676,7 +13676,7 @@ gpgsig`));
|
|
|
13676
13676
|
async function getConfigAll({
|
|
13677
13677
|
fs,
|
|
13678
13678
|
dir,
|
|
13679
|
-
gitdir =
|
|
13679
|
+
gitdir = join4(dir, ".git"),
|
|
13680
13680
|
path
|
|
13681
13681
|
}) {
|
|
13682
13682
|
try {
|
|
@@ -13870,7 +13870,7 @@ gpgsig`));
|
|
|
13870
13870
|
filepath
|
|
13871
13871
|
}) {
|
|
13872
13872
|
try {
|
|
13873
|
-
filepath =
|
|
13873
|
+
filepath = join4(dir, filepath);
|
|
13874
13874
|
const pack = await fs.read(filepath);
|
|
13875
13875
|
const getExternalRefDelta = (oid) => _readObject({ fs, cache, gitdir, oid });
|
|
13876
13876
|
const idx = await GitPackIndex.fromPack({
|
|
@@ -13891,7 +13891,7 @@ gpgsig`));
|
|
|
13891
13891
|
fs,
|
|
13892
13892
|
onProgress,
|
|
13893
13893
|
dir,
|
|
13894
|
-
gitdir =
|
|
13894
|
+
gitdir = join4(dir, ".git"),
|
|
13895
13895
|
filepath,
|
|
13896
13896
|
cache = {}
|
|
13897
13897
|
}) {
|
|
@@ -13919,7 +13919,7 @@ gpgsig`));
|
|
|
13919
13919
|
fs,
|
|
13920
13920
|
bare = false,
|
|
13921
13921
|
dir,
|
|
13922
|
-
gitdir = bare ? dir :
|
|
13922
|
+
gitdir = bare ? dir : join4(dir, ".git"),
|
|
13923
13923
|
defaultBranch = "master"
|
|
13924
13924
|
}) {
|
|
13925
13925
|
try {
|
|
@@ -13995,7 +13995,7 @@ gpgsig`));
|
|
|
13995
13995
|
async function isDescendent({
|
|
13996
13996
|
fs,
|
|
13997
13997
|
dir,
|
|
13998
|
-
gitdir =
|
|
13998
|
+
gitdir = join4(dir, ".git"),
|
|
13999
13999
|
oid,
|
|
14000
14000
|
ancestor,
|
|
14001
14001
|
depth = -1,
|
|
@@ -14024,7 +14024,7 @@ gpgsig`));
|
|
|
14024
14024
|
async function isIgnored({
|
|
14025
14025
|
fs,
|
|
14026
14026
|
dir,
|
|
14027
|
-
gitdir =
|
|
14027
|
+
gitdir = join4(dir, ".git"),
|
|
14028
14028
|
filepath
|
|
14029
14029
|
}) {
|
|
14030
14030
|
try {
|
|
@@ -14048,7 +14048,7 @@ gpgsig`));
|
|
|
14048
14048
|
async function listBranches({
|
|
14049
14049
|
fs,
|
|
14050
14050
|
dir,
|
|
14051
|
-
gitdir =
|
|
14051
|
+
gitdir = join4(dir, ".git"),
|
|
14052
14052
|
remote
|
|
14053
14053
|
}) {
|
|
14054
14054
|
try {
|
|
@@ -14102,17 +14102,17 @@ gpgsig`));
|
|
|
14102
14102
|
gitdir,
|
|
14103
14103
|
oid: entry.oid,
|
|
14104
14104
|
filenames,
|
|
14105
|
-
prefix:
|
|
14105
|
+
prefix: join4(prefix, entry.path)
|
|
14106
14106
|
});
|
|
14107
14107
|
} else {
|
|
14108
|
-
filenames.push(
|
|
14108
|
+
filenames.push(join4(prefix, entry.path));
|
|
14109
14109
|
}
|
|
14110
14110
|
}
|
|
14111
14111
|
}
|
|
14112
14112
|
async function listFiles({
|
|
14113
14113
|
fs,
|
|
14114
14114
|
dir,
|
|
14115
|
-
gitdir =
|
|
14115
|
+
gitdir = join4(dir, ".git"),
|
|
14116
14116
|
ref,
|
|
14117
14117
|
cache = {}
|
|
14118
14118
|
}) {
|
|
@@ -14156,7 +14156,7 @@ gpgsig`));
|
|
|
14156
14156
|
async function listNotes({
|
|
14157
14157
|
fs,
|
|
14158
14158
|
dir,
|
|
14159
|
-
gitdir =
|
|
14159
|
+
gitdir = join4(dir, ".git"),
|
|
14160
14160
|
ref = "refs/notes/commits",
|
|
14161
14161
|
cache = {}
|
|
14162
14162
|
}) {
|
|
@@ -14180,7 +14180,7 @@ gpgsig`));
|
|
|
14180
14180
|
async function listRefs({
|
|
14181
14181
|
fs,
|
|
14182
14182
|
dir,
|
|
14183
|
-
gitdir =
|
|
14183
|
+
gitdir = join4(dir, ".git"),
|
|
14184
14184
|
filepath
|
|
14185
14185
|
}) {
|
|
14186
14186
|
try {
|
|
@@ -14203,7 +14203,7 @@ gpgsig`));
|
|
|
14203
14203
|
}));
|
|
14204
14204
|
return remotes;
|
|
14205
14205
|
}
|
|
14206
|
-
async function listRemotes({ fs, dir, gitdir =
|
|
14206
|
+
async function listRemotes({ fs, dir, gitdir = join4(dir, ".git") }) {
|
|
14207
14207
|
try {
|
|
14208
14208
|
assertParameter("fs", fs);
|
|
14209
14209
|
assertParameter("gitdir", gitdir);
|
|
@@ -14308,7 +14308,7 @@ gpgsig`));
|
|
|
14308
14308
|
throw err;
|
|
14309
14309
|
}
|
|
14310
14310
|
}
|
|
14311
|
-
async function listTags({ fs, dir, gitdir =
|
|
14311
|
+
async function listTags({ fs, dir, gitdir = join4(dir, ".git") }) {
|
|
14312
14312
|
try {
|
|
14313
14313
|
assertParameter("fs", fs);
|
|
14314
14314
|
assertParameter("gitdir", gitdir);
|
|
@@ -14364,7 +14364,7 @@ gpgsig`));
|
|
|
14364
14364
|
const walks = tree.entries().map(function(entry) {
|
|
14365
14365
|
let result;
|
|
14366
14366
|
if (entry.oid === fileId) {
|
|
14367
|
-
result =
|
|
14367
|
+
result = join4(parentPath, entry.path);
|
|
14368
14368
|
filepaths.push(result);
|
|
14369
14369
|
} else if (entry.type === "tree") {
|
|
14370
14370
|
result = _readObject({
|
|
@@ -14381,7 +14381,7 @@ gpgsig`));
|
|
|
14381
14381
|
fileId,
|
|
14382
14382
|
oid,
|
|
14383
14383
|
filepaths,
|
|
14384
|
-
parentPath:
|
|
14384
|
+
parentPath: join4(parentPath, entry.path)
|
|
14385
14385
|
});
|
|
14386
14386
|
});
|
|
14387
14387
|
}
|
|
@@ -14516,7 +14516,7 @@ gpgsig`));
|
|
|
14516
14516
|
async function log({
|
|
14517
14517
|
fs,
|
|
14518
14518
|
dir,
|
|
14519
|
-
gitdir =
|
|
14519
|
+
gitdir = join4(dir, ".git"),
|
|
14520
14520
|
filepath,
|
|
14521
14521
|
ref = "HEAD",
|
|
14522
14522
|
depth,
|
|
@@ -14551,7 +14551,7 @@ gpgsig`));
|
|
|
14551
14551
|
fs: _fs,
|
|
14552
14552
|
onSign,
|
|
14553
14553
|
dir,
|
|
14554
|
-
gitdir =
|
|
14554
|
+
gitdir = join4(dir, ".git"),
|
|
14555
14555
|
ours,
|
|
14556
14556
|
theirs,
|
|
14557
14557
|
fastForward: fastForward2 = true,
|
|
@@ -14628,7 +14628,7 @@ gpgsig`));
|
|
|
14628
14628
|
fs,
|
|
14629
14629
|
cache,
|
|
14630
14630
|
dir,
|
|
14631
|
-
gitdir =
|
|
14631
|
+
gitdir = join4(dir, ".git"),
|
|
14632
14632
|
oids
|
|
14633
14633
|
}) {
|
|
14634
14634
|
const hash = new Hash;
|
|
@@ -14671,7 +14671,7 @@ gpgsig`));
|
|
|
14671
14671
|
const packfileSha = packfile.slice(-20).toString("hex");
|
|
14672
14672
|
const filename = `pack-${packfileSha}.pack`;
|
|
14673
14673
|
if (write) {
|
|
14674
|
-
await fs.write(
|
|
14674
|
+
await fs.write(join4(gitdir, `objects/pack/${filename}`), packfile);
|
|
14675
14675
|
return { filename };
|
|
14676
14676
|
}
|
|
14677
14677
|
return {
|
|
@@ -14682,7 +14682,7 @@ gpgsig`));
|
|
|
14682
14682
|
async function packObjects({
|
|
14683
14683
|
fs,
|
|
14684
14684
|
dir,
|
|
14685
|
-
gitdir =
|
|
14685
|
+
gitdir = join4(dir, ".git"),
|
|
14686
14686
|
oids,
|
|
14687
14687
|
write = false,
|
|
14688
14688
|
cache = {}
|
|
@@ -14714,7 +14714,7 @@ gpgsig`));
|
|
|
14714
14714
|
onAuthSuccess,
|
|
14715
14715
|
onAuthFailure,
|
|
14716
14716
|
dir,
|
|
14717
|
-
gitdir =
|
|
14717
|
+
gitdir = join4(dir, ".git"),
|
|
14718
14718
|
ref,
|
|
14719
14719
|
url,
|
|
14720
14720
|
remote,
|
|
@@ -14786,7 +14786,7 @@ gpgsig`));
|
|
|
14786
14786
|
fs,
|
|
14787
14787
|
cache,
|
|
14788
14788
|
dir,
|
|
14789
|
-
gitdir =
|
|
14789
|
+
gitdir = join4(dir, ".git"),
|
|
14790
14790
|
start,
|
|
14791
14791
|
finish
|
|
14792
14792
|
}) {
|
|
@@ -14833,7 +14833,7 @@ gpgsig`));
|
|
|
14833
14833
|
fs,
|
|
14834
14834
|
cache,
|
|
14835
14835
|
dir,
|
|
14836
|
-
gitdir =
|
|
14836
|
+
gitdir = join4(dir, ".git"),
|
|
14837
14837
|
oids
|
|
14838
14838
|
}) {
|
|
14839
14839
|
const visited = new Set;
|
|
@@ -15126,7 +15126,7 @@ gpgsig`));
|
|
|
15126
15126
|
onAuthFailure,
|
|
15127
15127
|
onPrePush,
|
|
15128
15128
|
dir,
|
|
15129
|
-
gitdir =
|
|
15129
|
+
gitdir = join4(dir, ".git"),
|
|
15130
15130
|
ref,
|
|
15131
15131
|
remoteRef,
|
|
15132
15132
|
remote = "origin",
|
|
@@ -15200,7 +15200,7 @@ gpgsig`));
|
|
|
15200
15200
|
async function readBlob({
|
|
15201
15201
|
fs,
|
|
15202
15202
|
dir,
|
|
15203
|
-
gitdir =
|
|
15203
|
+
gitdir = join4(dir, ".git"),
|
|
15204
15204
|
oid,
|
|
15205
15205
|
filepath,
|
|
15206
15206
|
cache = {}
|
|
@@ -15226,7 +15226,7 @@ gpgsig`));
|
|
|
15226
15226
|
async function readCommit({
|
|
15227
15227
|
fs,
|
|
15228
15228
|
dir,
|
|
15229
|
-
gitdir =
|
|
15229
|
+
gitdir = join4(dir, ".git"),
|
|
15230
15230
|
oid,
|
|
15231
15231
|
cache = {}
|
|
15232
15232
|
}) {
|
|
@@ -15267,7 +15267,7 @@ gpgsig`));
|
|
|
15267
15267
|
async function readNote({
|
|
15268
15268
|
fs,
|
|
15269
15269
|
dir,
|
|
15270
|
-
gitdir =
|
|
15270
|
+
gitdir = join4(dir, ".git"),
|
|
15271
15271
|
ref = "refs/notes/commits",
|
|
15272
15272
|
oid,
|
|
15273
15273
|
cache = {}
|
|
@@ -15294,7 +15294,7 @@ gpgsig`));
|
|
|
15294
15294
|
async function readObject({
|
|
15295
15295
|
fs: _fs,
|
|
15296
15296
|
dir,
|
|
15297
|
-
gitdir =
|
|
15297
|
+
gitdir = join4(dir, ".git"),
|
|
15298
15298
|
oid,
|
|
15299
15299
|
format = "parsed",
|
|
15300
15300
|
filepath = undefined,
|
|
@@ -15379,7 +15379,7 @@ gpgsig`));
|
|
|
15379
15379
|
async function readTag({
|
|
15380
15380
|
fs,
|
|
15381
15381
|
dir,
|
|
15382
|
-
gitdir =
|
|
15382
|
+
gitdir = join4(dir, ".git"),
|
|
15383
15383
|
oid,
|
|
15384
15384
|
cache = {}
|
|
15385
15385
|
}) {
|
|
@@ -15403,7 +15403,7 @@ gpgsig`));
|
|
|
15403
15403
|
async function readTree({
|
|
15404
15404
|
fs,
|
|
15405
15405
|
dir,
|
|
15406
|
-
gitdir =
|
|
15406
|
+
gitdir = join4(dir, ".git"),
|
|
15407
15407
|
oid,
|
|
15408
15408
|
filepath = undefined,
|
|
15409
15409
|
cache = {}
|
|
@@ -15429,7 +15429,7 @@ gpgsig`));
|
|
|
15429
15429
|
async function remove({
|
|
15430
15430
|
fs: _fs,
|
|
15431
15431
|
dir,
|
|
15432
|
-
gitdir =
|
|
15432
|
+
gitdir = join4(dir, ".git"),
|
|
15433
15433
|
filepath,
|
|
15434
15434
|
cache = {}
|
|
15435
15435
|
}) {
|
|
@@ -15499,7 +15499,7 @@ gpgsig`));
|
|
|
15499
15499
|
fs: _fs,
|
|
15500
15500
|
onSign,
|
|
15501
15501
|
dir,
|
|
15502
|
-
gitdir =
|
|
15502
|
+
gitdir = join4(dir, ".git"),
|
|
15503
15503
|
ref = "refs/notes/commits",
|
|
15504
15504
|
oid,
|
|
15505
15505
|
author: _author,
|
|
@@ -15589,7 +15589,7 @@ gpgsig`));
|
|
|
15589
15589
|
async function renameBranch({
|
|
15590
15590
|
fs,
|
|
15591
15591
|
dir,
|
|
15592
|
-
gitdir =
|
|
15592
|
+
gitdir = join4(dir, ".git"),
|
|
15593
15593
|
ref,
|
|
15594
15594
|
oldref,
|
|
15595
15595
|
checkout: checkout2 = false
|
|
@@ -15619,7 +15619,7 @@ gpgsig`));
|
|
|
15619
15619
|
async function resetIndex({
|
|
15620
15620
|
fs: _fs,
|
|
15621
15621
|
dir,
|
|
15622
|
-
gitdir =
|
|
15622
|
+
gitdir = join4(dir, ".git"),
|
|
15623
15623
|
filepath,
|
|
15624
15624
|
ref,
|
|
15625
15625
|
cache = {}
|
|
@@ -15666,7 +15666,7 @@ gpgsig`));
|
|
|
15666
15666
|
gid: 0,
|
|
15667
15667
|
size: 0
|
|
15668
15668
|
};
|
|
15669
|
-
const object = dir && await fs.read(
|
|
15669
|
+
const object = dir && await fs.read(join4(dir, filepath));
|
|
15670
15670
|
if (object) {
|
|
15671
15671
|
workdirOid = await hashObject$1({
|
|
15672
15672
|
gitdir: updatedGitdir,
|
|
@@ -15674,7 +15674,7 @@ gpgsig`));
|
|
|
15674
15674
|
object
|
|
15675
15675
|
});
|
|
15676
15676
|
if (oid === workdirOid) {
|
|
15677
|
-
stats = await fs.lstat(
|
|
15677
|
+
stats = await fs.lstat(join4(dir, filepath));
|
|
15678
15678
|
}
|
|
15679
15679
|
}
|
|
15680
15680
|
await GitIndexManager.acquire({ fs, gitdir: updatedGitdir, cache }, async function(index2) {
|
|
@@ -15691,7 +15691,7 @@ gpgsig`));
|
|
|
15691
15691
|
async function resolveRef({
|
|
15692
15692
|
fs,
|
|
15693
15693
|
dir,
|
|
15694
|
-
gitdir =
|
|
15694
|
+
gitdir = join4(dir, ".git"),
|
|
15695
15695
|
ref,
|
|
15696
15696
|
depth
|
|
15697
15697
|
}) {
|
|
@@ -15716,7 +15716,7 @@ gpgsig`));
|
|
|
15716
15716
|
async function setConfig({
|
|
15717
15717
|
fs: _fs,
|
|
15718
15718
|
dir,
|
|
15719
|
-
gitdir =
|
|
15719
|
+
gitdir = join4(dir, ".git"),
|
|
15720
15720
|
path,
|
|
15721
15721
|
value,
|
|
15722
15722
|
append = false
|
|
@@ -15785,7 +15785,7 @@ gpgsig`));
|
|
|
15785
15785
|
return lock$3.acquire(ref, callback);
|
|
15786
15786
|
}
|
|
15787
15787
|
async function checkAndWriteBlob(fs, gitdir, dir, filepath, oid = null) {
|
|
15788
|
-
const currentFilepath =
|
|
15788
|
+
const currentFilepath = join4(dir, filepath);
|
|
15789
15789
|
const stats = await fs.lstat(currentFilepath);
|
|
15790
15790
|
if (!stats)
|
|
15791
15791
|
throw new NotFoundError(currentFilepath);
|
|
@@ -15948,7 +15948,7 @@ gpgsig`));
|
|
|
15948
15948
|
stageUpdated.push({
|
|
15949
15949
|
filepath,
|
|
15950
15950
|
oid,
|
|
15951
|
-
stats: await fs.lstat(
|
|
15951
|
+
stats: await fs.lstat(join4(dir, filepath))
|
|
15952
15952
|
});
|
|
15953
15953
|
return {
|
|
15954
15954
|
method: "write",
|
|
@@ -15961,7 +15961,7 @@ gpgsig`));
|
|
|
15961
15961
|
});
|
|
15962
15962
|
await acquireLock$1({ fs, gitdir, dirRemoved, ops }, async () => {
|
|
15963
15963
|
for (const op of ops) {
|
|
15964
|
-
const currentFilepath =
|
|
15964
|
+
const currentFilepath = join4(dir, op.filepath);
|
|
15965
15965
|
switch (op.method) {
|
|
15966
15966
|
case "rmdir":
|
|
15967
15967
|
await fs.rmdir(currentFilepath);
|
|
@@ -15997,7 +15997,7 @@ gpgsig`));
|
|
|
15997
15997
|
}
|
|
15998
15998
|
|
|
15999
15999
|
class GitStashManager {
|
|
16000
|
-
constructor({ fs, dir, gitdir =
|
|
16000
|
+
constructor({ fs, dir, gitdir = join4(dir, ".git") }) {
|
|
16001
16001
|
Object.assign(this, {
|
|
16002
16002
|
fs,
|
|
16003
16003
|
dir,
|
|
@@ -16012,10 +16012,10 @@ gpgsig`));
|
|
|
16012
16012
|
return "logs/refs/stash";
|
|
16013
16013
|
}
|
|
16014
16014
|
get refStashPath() {
|
|
16015
|
-
return
|
|
16015
|
+
return join4(this.gitdir, GitStashManager.refStash);
|
|
16016
16016
|
}
|
|
16017
16017
|
get refLogsStashPath() {
|
|
16018
|
-
return
|
|
16018
|
+
return join4(this.gitdir, GitStashManager.refLogsStash);
|
|
16019
16019
|
}
|
|
16020
16020
|
async getAuthor() {
|
|
16021
16021
|
if (!this._author) {
|
|
@@ -16260,7 +16260,7 @@ gpgsig`));
|
|
|
16260
16260
|
async function stash({
|
|
16261
16261
|
fs,
|
|
16262
16262
|
dir,
|
|
16263
|
-
gitdir =
|
|
16263
|
+
gitdir = join4(dir, ".git"),
|
|
16264
16264
|
op = "push",
|
|
16265
16265
|
message = "",
|
|
16266
16266
|
refIdx = 0
|
|
@@ -16283,7 +16283,7 @@ gpgsig`));
|
|
|
16283
16283
|
const _fs = new FileSystem(fs);
|
|
16284
16284
|
const updatedGitdir = await discoverGitdir({ fsp: _fs, dotgit: gitdir });
|
|
16285
16285
|
const folders = ["refs", "logs", "logs/refs"];
|
|
16286
|
-
folders.map((f) =>
|
|
16286
|
+
folders.map((f) => join4(updatedGitdir, f)).forEach(async (folder) => {
|
|
16287
16287
|
if (!await _fs.exists(folder)) {
|
|
16288
16288
|
await _fs.mkdir(folder);
|
|
16289
16289
|
}
|
|
@@ -16310,7 +16310,7 @@ gpgsig`));
|
|
|
16310
16310
|
async function status({
|
|
16311
16311
|
fs: _fs,
|
|
16312
16312
|
dir,
|
|
16313
|
-
gitdir =
|
|
16313
|
+
gitdir = join4(dir, ".git"),
|
|
16314
16314
|
filepath,
|
|
16315
16315
|
cache = {}
|
|
16316
16316
|
}) {
|
|
@@ -16344,7 +16344,7 @@ gpgsig`));
|
|
|
16344
16344
|
}
|
|
16345
16345
|
return null;
|
|
16346
16346
|
});
|
|
16347
|
-
const stats = await fs.lstat(
|
|
16347
|
+
const stats = await fs.lstat(join4(dir, filepath));
|
|
16348
16348
|
const H = treeOid !== null;
|
|
16349
16349
|
const I = indexEntry !== null;
|
|
16350
16350
|
const W = stats !== null;
|
|
@@ -16352,7 +16352,7 @@ gpgsig`));
|
|
|
16352
16352
|
if (I && !compareStats(indexEntry, stats)) {
|
|
16353
16353
|
return indexEntry.oid;
|
|
16354
16354
|
} else {
|
|
16355
|
-
const object = await fs.read(
|
|
16355
|
+
const object = await fs.read(join4(dir, filepath));
|
|
16356
16356
|
const workdirOid = await hashObject$1({
|
|
16357
16357
|
gitdir: updatedGitdir,
|
|
16358
16358
|
type: "blob",
|
|
@@ -16445,7 +16445,7 @@ gpgsig`));
|
|
|
16445
16445
|
async function statusMatrix({
|
|
16446
16446
|
fs: _fs,
|
|
16447
16447
|
dir,
|
|
16448
|
-
gitdir =
|
|
16448
|
+
gitdir = join4(dir, ".git"),
|
|
16449
16449
|
ref = "HEAD",
|
|
16450
16450
|
filepaths = ["."],
|
|
16451
16451
|
filter,
|
|
@@ -16522,7 +16522,7 @@ gpgsig`));
|
|
|
16522
16522
|
async function tag({
|
|
16523
16523
|
fs: _fs,
|
|
16524
16524
|
dir,
|
|
16525
|
-
gitdir =
|
|
16525
|
+
gitdir = join4(dir, ".git"),
|
|
16526
16526
|
ref,
|
|
16527
16527
|
object,
|
|
16528
16528
|
force = false
|
|
@@ -16554,7 +16554,7 @@ gpgsig`));
|
|
|
16554
16554
|
async function updateIndex$1({
|
|
16555
16555
|
fs: _fs,
|
|
16556
16556
|
dir,
|
|
16557
|
-
gitdir =
|
|
16557
|
+
gitdir = join4(dir, ".git"),
|
|
16558
16558
|
cache = {},
|
|
16559
16559
|
filepath,
|
|
16560
16560
|
oid,
|
|
@@ -16572,7 +16572,7 @@ gpgsig`));
|
|
|
16572
16572
|
if (remove2) {
|
|
16573
16573
|
return await GitIndexManager.acquire({ fs, gitdir: updatedGitdir, cache }, async function(index2) {
|
|
16574
16574
|
if (!force) {
|
|
16575
|
-
const fileStats2 = await fs.lstat(
|
|
16575
|
+
const fileStats2 = await fs.lstat(join4(dir, filepath));
|
|
16576
16576
|
if (fileStats2) {
|
|
16577
16577
|
if (fileStats2.isDirectory()) {
|
|
16578
16578
|
throw new InvalidFilepathError("directory");
|
|
@@ -16589,7 +16589,7 @@ gpgsig`));
|
|
|
16589
16589
|
}
|
|
16590
16590
|
let fileStats;
|
|
16591
16591
|
if (!oid) {
|
|
16592
|
-
fileStats = await fs.lstat(
|
|
16592
|
+
fileStats = await fs.lstat(join4(dir, filepath));
|
|
16593
16593
|
if (!fileStats) {
|
|
16594
16594
|
throw new NotFoundError(`file at "${filepath}" on disk and "remove" not set`);
|
|
16595
16595
|
}
|
|
@@ -16604,7 +16604,7 @@ gpgsig`));
|
|
|
16604
16604
|
let stats;
|
|
16605
16605
|
if (!oid) {
|
|
16606
16606
|
stats = fileStats;
|
|
16607
|
-
const object = stats.isSymbolicLink() ? await fs.readlink(
|
|
16607
|
+
const object = stats.isSymbolicLink() ? await fs.readlink(join4(dir, filepath)) : await fs.read(join4(dir, filepath));
|
|
16608
16608
|
oid = await _writeObject({
|
|
16609
16609
|
fs,
|
|
16610
16610
|
gitdir: updatedGitdir,
|
|
@@ -16647,7 +16647,7 @@ gpgsig`));
|
|
|
16647
16647
|
async function walk({
|
|
16648
16648
|
fs,
|
|
16649
16649
|
dir,
|
|
16650
|
-
gitdir =
|
|
16650
|
+
gitdir = join4(dir, ".git"),
|
|
16651
16651
|
trees,
|
|
16652
16652
|
map,
|
|
16653
16653
|
reduce,
|
|
@@ -16675,7 +16675,7 @@ gpgsig`));
|
|
|
16675
16675
|
throw err;
|
|
16676
16676
|
}
|
|
16677
16677
|
}
|
|
16678
|
-
async function writeBlob({ fs, dir, gitdir =
|
|
16678
|
+
async function writeBlob({ fs, dir, gitdir = join4(dir, ".git"), blob }) {
|
|
16679
16679
|
try {
|
|
16680
16680
|
assertParameter("fs", fs);
|
|
16681
16681
|
assertParameter("gitdir", gitdir);
|
|
@@ -16697,7 +16697,7 @@ gpgsig`));
|
|
|
16697
16697
|
async function writeCommit({
|
|
16698
16698
|
fs,
|
|
16699
16699
|
dir,
|
|
16700
|
-
gitdir =
|
|
16700
|
+
gitdir = join4(dir, ".git"),
|
|
16701
16701
|
commit: commit2
|
|
16702
16702
|
}) {
|
|
16703
16703
|
try {
|
|
@@ -16719,7 +16719,7 @@ gpgsig`));
|
|
|
16719
16719
|
async function writeObject({
|
|
16720
16720
|
fs: _fs,
|
|
16721
16721
|
dir,
|
|
16722
|
-
gitdir =
|
|
16722
|
+
gitdir = join4(dir, ".git"),
|
|
16723
16723
|
type,
|
|
16724
16724
|
object,
|
|
16725
16725
|
format = "parsed",
|
|
@@ -16765,7 +16765,7 @@ gpgsig`));
|
|
|
16765
16765
|
async function writeRef({
|
|
16766
16766
|
fs: _fs,
|
|
16767
16767
|
dir,
|
|
16768
|
-
gitdir =
|
|
16768
|
+
gitdir = join4(dir, ".git"),
|
|
16769
16769
|
ref,
|
|
16770
16770
|
value,
|
|
16771
16771
|
force = false,
|
|
@@ -16820,7 +16820,7 @@ gpgsig`));
|
|
|
16820
16820
|
});
|
|
16821
16821
|
return oid;
|
|
16822
16822
|
}
|
|
16823
|
-
async function writeTag({ fs, dir, gitdir =
|
|
16823
|
+
async function writeTag({ fs, dir, gitdir = join4(dir, ".git"), tag: tag2 }) {
|
|
16824
16824
|
try {
|
|
16825
16825
|
assertParameter("fs", fs);
|
|
16826
16826
|
assertParameter("gitdir", gitdir);
|
|
@@ -16837,7 +16837,7 @@ gpgsig`));
|
|
|
16837
16837
|
throw err;
|
|
16838
16838
|
}
|
|
16839
16839
|
}
|
|
16840
|
-
async function writeTree({ fs, dir, gitdir =
|
|
16840
|
+
async function writeTree({ fs, dir, gitdir = join4(dir, ".git"), tree }) {
|
|
16841
16841
|
try {
|
|
16842
16842
|
assertParameter("fs", fs);
|
|
16843
16843
|
assertParameter("gitdir", gitdir);
|
|
@@ -20342,13 +20342,13 @@ var require_readable = __commonJS((exports, module) => {
|
|
|
20342
20342
|
return state[kPaused] === true || state.flowing === false;
|
|
20343
20343
|
};
|
|
20344
20344
|
Readable.prototype.setEncoding = function(enc) {
|
|
20345
|
-
const
|
|
20346
|
-
this._readableState.decoder =
|
|
20345
|
+
const decoder4 = new StringDecoder(enc);
|
|
20346
|
+
this._readableState.decoder = decoder4;
|
|
20347
20347
|
this._readableState.encoding = this._readableState.decoder.encoding;
|
|
20348
20348
|
const buffer = this._readableState.buffer;
|
|
20349
20349
|
let content = "";
|
|
20350
20350
|
for (const data of buffer) {
|
|
20351
|
-
content +=
|
|
20351
|
+
content += decoder4.write(data);
|
|
20352
20352
|
}
|
|
20353
20353
|
buffer.clear();
|
|
20354
20354
|
if (content !== "")
|
|
@@ -23447,13 +23447,6 @@ var require_ours = __commonJS((exports, module) => {
|
|
|
23447
23447
|
module.exports.default = module.exports;
|
|
23448
23448
|
});
|
|
23449
23449
|
|
|
23450
|
-
// src/types.ts
|
|
23451
|
-
function isRemoteConfig(config) {
|
|
23452
|
-
return config !== undefined && "endpoint" in config;
|
|
23453
|
-
}
|
|
23454
|
-
function isGitConfig(config) {
|
|
23455
|
-
return config !== undefined && "type" in config && config.type === "git";
|
|
23456
|
-
}
|
|
23457
23450
|
// ../core/dist/index.js
|
|
23458
23451
|
import { gzip, gunzip } from "node:zlib";
|
|
23459
23452
|
import { promisify } from "node:util";
|
|
@@ -23614,7 +23607,8 @@ class RegistryError extends ResourceXError {
|
|
|
23614
23607
|
}
|
|
23615
23608
|
// src/LocalRegistry.ts
|
|
23616
23609
|
import { homedir } from "node:os";
|
|
23617
|
-
import { join as
|
|
23610
|
+
import { join as join3, resolve as resolvePath } from "node:path";
|
|
23611
|
+
import { symlink, lstat, readlink } from "node:fs/promises";
|
|
23618
23612
|
|
|
23619
23613
|
// ../type/dist/index.js
|
|
23620
23614
|
import { gzip as gzip2, gunzip as gunzip2 } from "node:zlib";
|
|
@@ -24678,9 +24672,81 @@ async function unpackTar(archive, options = {}) {
|
|
|
24678
24672
|
var gzipAsync2 = promisify2(gzip2);
|
|
24679
24673
|
var gunzipAsync2 = promisify2(gunzip2);
|
|
24680
24674
|
|
|
24681
|
-
class
|
|
24675
|
+
class RXPImpl {
|
|
24676
|
+
_files;
|
|
24677
|
+
_pathsCache = null;
|
|
24678
|
+
_treeCache = null;
|
|
24679
|
+
constructor(files) {
|
|
24680
|
+
this._files = files;
|
|
24681
|
+
}
|
|
24682
|
+
paths() {
|
|
24683
|
+
if (this._pathsCache) {
|
|
24684
|
+
return this._pathsCache;
|
|
24685
|
+
}
|
|
24686
|
+
this._pathsCache = Array.from(this._files.keys()).sort();
|
|
24687
|
+
return this._pathsCache;
|
|
24688
|
+
}
|
|
24689
|
+
tree() {
|
|
24690
|
+
if (this._treeCache) {
|
|
24691
|
+
return this._treeCache;
|
|
24692
|
+
}
|
|
24693
|
+
const root = new Map;
|
|
24694
|
+
for (const path of this._files.keys()) {
|
|
24695
|
+
const parts = path.split("/");
|
|
24696
|
+
let currentLevel = root;
|
|
24697
|
+
for (let i = 0;i < parts.length; i++) {
|
|
24698
|
+
const part = parts[i];
|
|
24699
|
+
const isFile = i === parts.length - 1;
|
|
24700
|
+
if (!currentLevel.has(part)) {
|
|
24701
|
+
const treeNode2 = {
|
|
24702
|
+
node: {
|
|
24703
|
+
name: part,
|
|
24704
|
+
type: isFile ? "file" : "directory",
|
|
24705
|
+
children: isFile ? undefined : []
|
|
24706
|
+
},
|
|
24707
|
+
children: new Map
|
|
24708
|
+
};
|
|
24709
|
+
currentLevel.set(part, treeNode2);
|
|
24710
|
+
}
|
|
24711
|
+
const treeNode = currentLevel.get(part);
|
|
24712
|
+
if (!isFile) {
|
|
24713
|
+
currentLevel = treeNode.children;
|
|
24714
|
+
}
|
|
24715
|
+
}
|
|
24716
|
+
}
|
|
24717
|
+
const convertToPathNodes = (level) => {
|
|
24718
|
+
return Array.from(level.values()).map((treeNode) => {
|
|
24719
|
+
if (treeNode.node.type === "directory" && treeNode.children.size > 0) {
|
|
24720
|
+
treeNode.node.children = convertToPathNodes(treeNode.children);
|
|
24721
|
+
}
|
|
24722
|
+
return treeNode.node;
|
|
24723
|
+
});
|
|
24724
|
+
};
|
|
24725
|
+
this._treeCache = convertToPathNodes(root);
|
|
24726
|
+
return this._treeCache;
|
|
24727
|
+
}
|
|
24728
|
+
async file(path) {
|
|
24729
|
+
const content = this._files.get(path);
|
|
24730
|
+
if (!content) {
|
|
24731
|
+
throw new ContentError(`file not found: ${path}`);
|
|
24732
|
+
}
|
|
24733
|
+
return content;
|
|
24734
|
+
}
|
|
24735
|
+
async files() {
|
|
24736
|
+
return new Map(this._files);
|
|
24737
|
+
}
|
|
24738
|
+
async pack() {
|
|
24739
|
+
const filesRecord = {};
|
|
24740
|
+
for (const [path, content] of this._files) {
|
|
24741
|
+
filesRecord[path] = content;
|
|
24742
|
+
}
|
|
24743
|
+
return createRXA(filesRecord);
|
|
24744
|
+
}
|
|
24745
|
+
}
|
|
24746
|
+
|
|
24747
|
+
class RXAImpl {
|
|
24682
24748
|
_buffer;
|
|
24683
|
-
|
|
24749
|
+
_rxpCache = null;
|
|
24684
24750
|
constructor(buffer) {
|
|
24685
24751
|
this._buffer = buffer;
|
|
24686
24752
|
}
|
|
@@ -24696,17 +24762,9 @@ class RXCImpl {
|
|
|
24696
24762
|
async buffer() {
|
|
24697
24763
|
return this._buffer;
|
|
24698
24764
|
}
|
|
24699
|
-
async
|
|
24700
|
-
|
|
24701
|
-
|
|
24702
|
-
if (!content) {
|
|
24703
|
-
throw new ContentError(`file not found: ${path}`);
|
|
24704
|
-
}
|
|
24705
|
-
return content;
|
|
24706
|
-
}
|
|
24707
|
-
async files() {
|
|
24708
|
-
if (this._filesCache) {
|
|
24709
|
-
return this._filesCache;
|
|
24765
|
+
async extract() {
|
|
24766
|
+
if (this._rxpCache) {
|
|
24767
|
+
return this._rxpCache;
|
|
24710
24768
|
}
|
|
24711
24769
|
const tarBuffer = await gunzipAsync2(this._buffer);
|
|
24712
24770
|
const entries = await unpackTar(tarBuffer);
|
|
@@ -24716,16 +24774,16 @@ class RXCImpl {
|
|
|
24716
24774
|
filesMap.set(entry.header.name, Buffer.from(entry.data));
|
|
24717
24775
|
}
|
|
24718
24776
|
}
|
|
24719
|
-
this.
|
|
24720
|
-
return
|
|
24777
|
+
this._rxpCache = new RXPImpl(filesMap);
|
|
24778
|
+
return this._rxpCache;
|
|
24721
24779
|
}
|
|
24722
24780
|
}
|
|
24723
|
-
function
|
|
24724
|
-
return "
|
|
24781
|
+
function isBufferInput(input) {
|
|
24782
|
+
return "buffer" in input && Buffer.isBuffer(input.buffer);
|
|
24725
24783
|
}
|
|
24726
|
-
async function
|
|
24727
|
-
if (
|
|
24728
|
-
return new
|
|
24784
|
+
async function createRXA(input) {
|
|
24785
|
+
if (isBufferInput(input)) {
|
|
24786
|
+
return new RXAImpl(input.buffer);
|
|
24729
24787
|
}
|
|
24730
24788
|
const entries = Object.entries(input).map(([name, content]) => {
|
|
24731
24789
|
const body = typeof content === "string" ? content : content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
@@ -24737,7 +24795,7 @@ async function createRXC(input) {
|
|
|
24737
24795
|
});
|
|
24738
24796
|
const tarBuffer = await packTar(entries);
|
|
24739
24797
|
const gzipBuffer = await gzipAsync2(Buffer.from(tarBuffer));
|
|
24740
|
-
return new
|
|
24798
|
+
return new RXAImpl(gzipBuffer);
|
|
24741
24799
|
}
|
|
24742
24800
|
|
|
24743
24801
|
class ResourceTypeError extends ResourceXError2 {
|
|
@@ -24748,13 +24806,13 @@ class ResourceTypeError extends ResourceXError2 {
|
|
|
24748
24806
|
}
|
|
24749
24807
|
var textSerializer = {
|
|
24750
24808
|
async serialize(rxr) {
|
|
24751
|
-
return rxr.
|
|
24809
|
+
return rxr.archive.buffer();
|
|
24752
24810
|
},
|
|
24753
24811
|
async deserialize(data, manifest) {
|
|
24754
24812
|
return {
|
|
24755
24813
|
locator: parseRXL2(manifest.toLocator()),
|
|
24756
24814
|
manifest,
|
|
24757
|
-
|
|
24815
|
+
archive: await createRXA({ buffer: data })
|
|
24758
24816
|
};
|
|
24759
24817
|
}
|
|
24760
24818
|
};
|
|
@@ -24765,7 +24823,8 @@ var textResolver = {
|
|
|
24765
24823
|
resource: rxr,
|
|
24766
24824
|
schema: undefined,
|
|
24767
24825
|
execute: async () => {
|
|
24768
|
-
const
|
|
24826
|
+
const pkg = await rxr.archive.extract();
|
|
24827
|
+
const buffer = await pkg.file("content");
|
|
24769
24828
|
return buffer.toString("utf-8");
|
|
24770
24829
|
}
|
|
24771
24830
|
};
|
|
@@ -24780,13 +24839,13 @@ var textType = {
|
|
|
24780
24839
|
};
|
|
24781
24840
|
var jsonSerializer = {
|
|
24782
24841
|
async serialize(rxr) {
|
|
24783
|
-
return rxr.
|
|
24842
|
+
return rxr.archive.buffer();
|
|
24784
24843
|
},
|
|
24785
24844
|
async deserialize(data, manifest) {
|
|
24786
24845
|
return {
|
|
24787
24846
|
locator: parseRXL2(manifest.toLocator()),
|
|
24788
24847
|
manifest,
|
|
24789
|
-
|
|
24848
|
+
archive: await createRXA({ buffer: data })
|
|
24790
24849
|
};
|
|
24791
24850
|
}
|
|
24792
24851
|
};
|
|
@@ -24797,7 +24856,8 @@ var jsonResolver = {
|
|
|
24797
24856
|
resource: rxr,
|
|
24798
24857
|
schema: undefined,
|
|
24799
24858
|
execute: async () => {
|
|
24800
|
-
const
|
|
24859
|
+
const pkg = await rxr.archive.extract();
|
|
24860
|
+
const buffer = await pkg.file("content");
|
|
24801
24861
|
return JSON.parse(buffer.toString("utf-8"));
|
|
24802
24862
|
}
|
|
24803
24863
|
};
|
|
@@ -24812,13 +24872,13 @@ var jsonType = {
|
|
|
24812
24872
|
};
|
|
24813
24873
|
var binarySerializer = {
|
|
24814
24874
|
async serialize(rxr) {
|
|
24815
|
-
return rxr.
|
|
24875
|
+
return rxr.archive.buffer();
|
|
24816
24876
|
},
|
|
24817
24877
|
async deserialize(data, manifest) {
|
|
24818
24878
|
return {
|
|
24819
24879
|
locator: parseRXL2(manifest.toLocator()),
|
|
24820
24880
|
manifest,
|
|
24821
|
-
|
|
24881
|
+
archive: await createRXA({ buffer: data })
|
|
24822
24882
|
};
|
|
24823
24883
|
}
|
|
24824
24884
|
};
|
|
@@ -24829,7 +24889,8 @@ var binaryResolver = {
|
|
|
24829
24889
|
resource: rxr,
|
|
24830
24890
|
schema: undefined,
|
|
24831
24891
|
execute: async () => {
|
|
24832
|
-
|
|
24892
|
+
const pkg = await rxr.archive.extract();
|
|
24893
|
+
return pkg.file("content");
|
|
24833
24894
|
}
|
|
24834
24895
|
};
|
|
24835
24896
|
}
|
|
@@ -25433,154 +25494,1526 @@ function createARP(config) {
|
|
|
25433
25494
|
return new ARP(config);
|
|
25434
25495
|
}
|
|
25435
25496
|
|
|
25436
|
-
//
|
|
25437
|
-
|
|
25497
|
+
// ../loader/dist/index.js
|
|
25498
|
+
import { join as join2, relative } from "node:path";
|
|
25499
|
+
import { stat as stat2, readFile as readFile2, readdir as readdir2 } from "node:fs/promises";
|
|
25500
|
+
import { gzip as gzip3, gunzip as gunzip3 } from "node:zlib";
|
|
25501
|
+
import { promisify as promisify3 } from "node:util";
|
|
25438
25502
|
|
|
25439
|
-
class
|
|
25440
|
-
|
|
25441
|
-
|
|
25442
|
-
|
|
25443
|
-
constructor(config) {
|
|
25444
|
-
this.basePath = config?.path ?? DEFAULT_PATH;
|
|
25445
|
-
this.typeHandler = TypeHandlerChain.create();
|
|
25446
|
-
this.arp = createARP();
|
|
25447
|
-
if (config?.types) {
|
|
25448
|
-
for (const type of config.types) {
|
|
25449
|
-
this.typeHandler.register(type);
|
|
25450
|
-
}
|
|
25451
|
-
}
|
|
25503
|
+
class ResourceXError3 extends Error {
|
|
25504
|
+
constructor(message, options) {
|
|
25505
|
+
super(message, options);
|
|
25506
|
+
this.name = "ResourceXError";
|
|
25452
25507
|
}
|
|
25453
|
-
|
|
25454
|
-
|
|
25508
|
+
}
|
|
25509
|
+
|
|
25510
|
+
class ManifestError2 extends ResourceXError3 {
|
|
25511
|
+
constructor(message) {
|
|
25512
|
+
super(message);
|
|
25513
|
+
this.name = "ManifestError";
|
|
25455
25514
|
}
|
|
25456
|
-
|
|
25457
|
-
|
|
25515
|
+
}
|
|
25516
|
+
|
|
25517
|
+
class ContentError2 extends ResourceXError3 {
|
|
25518
|
+
constructor(message) {
|
|
25519
|
+
super(message);
|
|
25520
|
+
this.name = "ContentError";
|
|
25458
25521
|
}
|
|
25459
|
-
|
|
25460
|
-
|
|
25461
|
-
|
|
25462
|
-
|
|
25463
|
-
|
|
25464
|
-
|
|
25465
|
-
|
|
25466
|
-
|
|
25467
|
-
|
|
25468
|
-
|
|
25469
|
-
|
|
25522
|
+
}
|
|
25523
|
+
|
|
25524
|
+
class RXLImpl3 {
|
|
25525
|
+
domain;
|
|
25526
|
+
path;
|
|
25527
|
+
name;
|
|
25528
|
+
type;
|
|
25529
|
+
version;
|
|
25530
|
+
constructor(parts) {
|
|
25531
|
+
this.domain = parts.domain;
|
|
25532
|
+
this.path = parts.path;
|
|
25533
|
+
this.name = parts.name;
|
|
25534
|
+
this.type = parts.type;
|
|
25535
|
+
this.version = parts.version;
|
|
25536
|
+
}
|
|
25537
|
+
toString() {
|
|
25538
|
+
let result = "";
|
|
25539
|
+
if (this.domain) {
|
|
25540
|
+
result += this.domain + "/";
|
|
25541
|
+
if (this.path) {
|
|
25542
|
+
result += this.path + "/";
|
|
25470
25543
|
}
|
|
25471
|
-
return join2(path, resourceName, version);
|
|
25472
25544
|
}
|
|
25473
|
-
|
|
25474
|
-
|
|
25475
|
-
|
|
25476
|
-
return !rxl.domain || rxl.domain === "localhost";
|
|
25477
|
-
}
|
|
25478
|
-
async existsAt(resourcePath) {
|
|
25479
|
-
const manifestPath = join2(resourcePath, "manifest.json");
|
|
25480
|
-
const arl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
25481
|
-
return arl.exists();
|
|
25482
|
-
}
|
|
25483
|
-
async findArea(locator) {
|
|
25484
|
-
const localPath = this.buildPath(locator, "local");
|
|
25485
|
-
if (await this.existsAt(localPath)) {
|
|
25486
|
-
return "local";
|
|
25545
|
+
result += this.name;
|
|
25546
|
+
if (this.type) {
|
|
25547
|
+
result += "." + this.type;
|
|
25487
25548
|
}
|
|
25488
|
-
|
|
25489
|
-
|
|
25490
|
-
return "cache";
|
|
25549
|
+
if (this.version) {
|
|
25550
|
+
result += "@" + this.version;
|
|
25491
25551
|
}
|
|
25492
|
-
return
|
|
25552
|
+
return result;
|
|
25493
25553
|
}
|
|
25494
|
-
|
|
25495
|
-
|
|
25496
|
-
|
|
25497
|
-
|
|
25498
|
-
|
|
25499
|
-
|
|
25500
|
-
|
|
25501
|
-
|
|
25502
|
-
|
|
25503
|
-
|
|
25504
|
-
|
|
25505
|
-
|
|
25554
|
+
}
|
|
25555
|
+
function isDomain3(str) {
|
|
25556
|
+
if (str === "localhost")
|
|
25557
|
+
return true;
|
|
25558
|
+
return str.includes(".");
|
|
25559
|
+
}
|
|
25560
|
+
function parseRXL3(locator) {
|
|
25561
|
+
let remaining = locator;
|
|
25562
|
+
let version;
|
|
25563
|
+
let type;
|
|
25564
|
+
let domain;
|
|
25565
|
+
let path;
|
|
25566
|
+
let name;
|
|
25567
|
+
const atIndex = remaining.indexOf("@");
|
|
25568
|
+
if (atIndex !== -1) {
|
|
25569
|
+
version = remaining.slice(atIndex + 1);
|
|
25570
|
+
remaining = remaining.slice(0, atIndex);
|
|
25506
25571
|
}
|
|
25507
|
-
|
|
25508
|
-
|
|
25572
|
+
const segments = remaining.split("/");
|
|
25573
|
+
if (segments.length > 1 && isDomain3(segments[0])) {
|
|
25574
|
+
domain = segments[0];
|
|
25575
|
+
const lastSegment = segments[segments.length - 1];
|
|
25576
|
+
if (segments.length > 2) {
|
|
25577
|
+
path = segments.slice(1, -1).join("/");
|
|
25578
|
+
}
|
|
25579
|
+
remaining = lastSegment;
|
|
25580
|
+
} else {
|
|
25581
|
+
remaining = segments.join("/");
|
|
25509
25582
|
}
|
|
25510
|
-
|
|
25511
|
-
|
|
25583
|
+
const dotIndex = remaining.lastIndexOf(".");
|
|
25584
|
+
if (dotIndex !== -1) {
|
|
25585
|
+
type = remaining.slice(dotIndex + 1);
|
|
25586
|
+
name = remaining.slice(0, dotIndex);
|
|
25587
|
+
} else {
|
|
25588
|
+
name = remaining;
|
|
25512
25589
|
}
|
|
25513
|
-
|
|
25514
|
-
|
|
25515
|
-
|
|
25516
|
-
|
|
25517
|
-
|
|
25518
|
-
|
|
25519
|
-
|
|
25520
|
-
|
|
25521
|
-
|
|
25522
|
-
|
|
25523
|
-
|
|
25524
|
-
|
|
25525
|
-
|
|
25590
|
+
return new RXLImpl3({ domain, path, name, type, version });
|
|
25591
|
+
}
|
|
25592
|
+
|
|
25593
|
+
class RXMImpl2 {
|
|
25594
|
+
domain;
|
|
25595
|
+
path;
|
|
25596
|
+
name;
|
|
25597
|
+
type;
|
|
25598
|
+
version;
|
|
25599
|
+
constructor(data) {
|
|
25600
|
+
this.domain = data.domain;
|
|
25601
|
+
this.path = data.path;
|
|
25602
|
+
this.name = data.name;
|
|
25603
|
+
this.type = data.type;
|
|
25604
|
+
this.version = data.version;
|
|
25526
25605
|
}
|
|
25527
|
-
|
|
25528
|
-
|
|
25529
|
-
if (
|
|
25530
|
-
|
|
25606
|
+
toLocator() {
|
|
25607
|
+
let result = this.domain + "/";
|
|
25608
|
+
if (this.path) {
|
|
25609
|
+
result += this.path + "/";
|
|
25531
25610
|
}
|
|
25532
|
-
|
|
25533
|
-
|
|
25611
|
+
result += this.name;
|
|
25612
|
+
result += "." + this.type;
|
|
25613
|
+
result += "@" + this.version;
|
|
25614
|
+
return result;
|
|
25534
25615
|
}
|
|
25535
|
-
|
|
25536
|
-
const
|
|
25537
|
-
|
|
25616
|
+
toJSON() {
|
|
25617
|
+
const json = {
|
|
25618
|
+
domain: this.domain,
|
|
25619
|
+
name: this.name,
|
|
25620
|
+
type: this.type,
|
|
25621
|
+
version: this.version
|
|
25622
|
+
};
|
|
25623
|
+
if (this.path !== undefined) {
|
|
25624
|
+
json.path = this.path;
|
|
25625
|
+
}
|
|
25626
|
+
return json;
|
|
25538
25627
|
}
|
|
25539
|
-
|
|
25540
|
-
|
|
25541
|
-
|
|
25628
|
+
}
|
|
25629
|
+
function createRXM2(data) {
|
|
25630
|
+
if (!data.domain) {
|
|
25631
|
+
throw new ManifestError2("domain is required");
|
|
25542
25632
|
}
|
|
25543
|
-
|
|
25544
|
-
|
|
25545
|
-
if (isLocal) {
|
|
25546
|
-
const localPath = this.buildPath(locator, "local");
|
|
25547
|
-
if (await this.existsAt(localPath)) {
|
|
25548
|
-
const arl = this.arp.parse(this.toArpUrl(localPath));
|
|
25549
|
-
await arl.delete();
|
|
25550
|
-
}
|
|
25551
|
-
} else {
|
|
25552
|
-
const cachePath = this.buildPath(locator, "cache");
|
|
25553
|
-
if (await this.existsAt(cachePath)) {
|
|
25554
|
-
const arl = this.arp.parse(this.toArpUrl(cachePath));
|
|
25555
|
-
await arl.delete();
|
|
25556
|
-
}
|
|
25557
|
-
}
|
|
25633
|
+
if (!data.name) {
|
|
25634
|
+
throw new ManifestError2("name is required");
|
|
25558
25635
|
}
|
|
25559
|
-
|
|
25560
|
-
|
|
25561
|
-
|
|
25562
|
-
|
|
25563
|
-
|
|
25564
|
-
|
|
25565
|
-
|
|
25566
|
-
|
|
25567
|
-
|
|
25568
|
-
|
|
25569
|
-
|
|
25570
|
-
|
|
25571
|
-
|
|
25572
|
-
|
|
25573
|
-
|
|
25574
|
-
|
|
25575
|
-
|
|
25576
|
-
|
|
25577
|
-
|
|
25578
|
-
|
|
25579
|
-
|
|
25580
|
-
|
|
25581
|
-
|
|
25582
|
-
|
|
25583
|
-
|
|
25636
|
+
if (!data.type) {
|
|
25637
|
+
throw new ManifestError2("type is required");
|
|
25638
|
+
}
|
|
25639
|
+
if (!data.version) {
|
|
25640
|
+
throw new ManifestError2("version is required");
|
|
25641
|
+
}
|
|
25642
|
+
return new RXMImpl2({
|
|
25643
|
+
domain: data.domain,
|
|
25644
|
+
path: data.path,
|
|
25645
|
+
name: data.name,
|
|
25646
|
+
type: data.type,
|
|
25647
|
+
version: data.version
|
|
25648
|
+
});
|
|
25649
|
+
}
|
|
25650
|
+
var BLOCK_SIZE3 = 512;
|
|
25651
|
+
var BLOCK_SIZE_MASK2 = 511;
|
|
25652
|
+
var DEFAULT_FILE_MODE2 = 420;
|
|
25653
|
+
var DEFAULT_DIR_MODE2 = 493;
|
|
25654
|
+
var USTAR_NAME_OFFSET2 = 0;
|
|
25655
|
+
var USTAR_NAME_SIZE2 = 100;
|
|
25656
|
+
var USTAR_MODE_OFFSET2 = 100;
|
|
25657
|
+
var USTAR_MODE_SIZE2 = 8;
|
|
25658
|
+
var USTAR_UID_OFFSET2 = 108;
|
|
25659
|
+
var USTAR_UID_SIZE2 = 8;
|
|
25660
|
+
var USTAR_GID_OFFSET2 = 116;
|
|
25661
|
+
var USTAR_GID_SIZE2 = 8;
|
|
25662
|
+
var USTAR_SIZE_OFFSET2 = 124;
|
|
25663
|
+
var USTAR_SIZE_SIZE2 = 12;
|
|
25664
|
+
var USTAR_MTIME_OFFSET2 = 136;
|
|
25665
|
+
var USTAR_MTIME_SIZE2 = 12;
|
|
25666
|
+
var USTAR_CHECKSUM_OFFSET2 = 148;
|
|
25667
|
+
var USTAR_CHECKSUM_SIZE2 = 8;
|
|
25668
|
+
var USTAR_TYPEFLAG_OFFSET2 = 156;
|
|
25669
|
+
var USTAR_TYPEFLAG_SIZE2 = 1;
|
|
25670
|
+
var USTAR_LINKNAME_OFFSET2 = 157;
|
|
25671
|
+
var USTAR_LINKNAME_SIZE2 = 100;
|
|
25672
|
+
var USTAR_MAGIC_OFFSET2 = 257;
|
|
25673
|
+
var USTAR_MAGIC_SIZE2 = 6;
|
|
25674
|
+
var USTAR_VERSION_OFFSET2 = 263;
|
|
25675
|
+
var USTAR_VERSION_SIZE2 = 2;
|
|
25676
|
+
var USTAR_UNAME_OFFSET2 = 265;
|
|
25677
|
+
var USTAR_UNAME_SIZE2 = 32;
|
|
25678
|
+
var USTAR_GNAME_OFFSET2 = 297;
|
|
25679
|
+
var USTAR_GNAME_SIZE2 = 32;
|
|
25680
|
+
var USTAR_PREFIX_OFFSET2 = 345;
|
|
25681
|
+
var USTAR_PREFIX_SIZE2 = 155;
|
|
25682
|
+
var USTAR_VERSION2 = "00";
|
|
25683
|
+
var USTAR_MAX_UID_GID2 = 2097151;
|
|
25684
|
+
var USTAR_MAX_SIZE2 = 8589934591;
|
|
25685
|
+
var FILE2 = "file";
|
|
25686
|
+
var LINK2 = "link";
|
|
25687
|
+
var SYMLINK2 = "symlink";
|
|
25688
|
+
var DIRECTORY2 = "directory";
|
|
25689
|
+
var TYPEFLAG2 = {
|
|
25690
|
+
file: "0",
|
|
25691
|
+
link: "1",
|
|
25692
|
+
symlink: "2",
|
|
25693
|
+
"character-device": "3",
|
|
25694
|
+
"block-device": "4",
|
|
25695
|
+
directory: "5",
|
|
25696
|
+
fifo: "6",
|
|
25697
|
+
"pax-header": "x",
|
|
25698
|
+
"pax-global-header": "g",
|
|
25699
|
+
"gnu-long-name": "L",
|
|
25700
|
+
"gnu-long-link-name": "K"
|
|
25701
|
+
};
|
|
25702
|
+
var FLAGTYPE2 = {
|
|
25703
|
+
"0": FILE2,
|
|
25704
|
+
"1": LINK2,
|
|
25705
|
+
"2": SYMLINK2,
|
|
25706
|
+
"3": "character-device",
|
|
25707
|
+
"4": "block-device",
|
|
25708
|
+
"5": DIRECTORY2,
|
|
25709
|
+
"6": "fifo",
|
|
25710
|
+
x: "pax-header",
|
|
25711
|
+
g: "pax-global-header",
|
|
25712
|
+
L: "gnu-long-name",
|
|
25713
|
+
K: "gnu-long-link-name"
|
|
25714
|
+
};
|
|
25715
|
+
var ZERO_BLOCK3 = new Uint8Array(BLOCK_SIZE3);
|
|
25716
|
+
var EMPTY3 = new Uint8Array(0);
|
|
25717
|
+
var encoder3 = new TextEncoder;
|
|
25718
|
+
var decoder3 = new TextDecoder;
|
|
25719
|
+
function writeString2(view, offset, size, value) {
|
|
25720
|
+
if (value)
|
|
25721
|
+
encoder3.encodeInto(value, view.subarray(offset, offset + size));
|
|
25722
|
+
}
|
|
25723
|
+
function writeOctal2(view, offset, size, value) {
|
|
25724
|
+
if (value === undefined)
|
|
25725
|
+
return;
|
|
25726
|
+
const octalString = value.toString(8).padStart(size - 1, "0");
|
|
25727
|
+
encoder3.encodeInto(octalString, view.subarray(offset, offset + size - 1));
|
|
25728
|
+
}
|
|
25729
|
+
function readString2(view, offset, size) {
|
|
25730
|
+
const end = view.indexOf(0, offset);
|
|
25731
|
+
const sliceEnd = end === -1 || end > offset + size ? offset + size : end;
|
|
25732
|
+
return decoder3.decode(view.subarray(offset, sliceEnd));
|
|
25733
|
+
}
|
|
25734
|
+
function readOctal2(view, offset, size) {
|
|
25735
|
+
let value = 0;
|
|
25736
|
+
const end = offset + size;
|
|
25737
|
+
for (let i = offset;i < end; i++) {
|
|
25738
|
+
const charCode = view[i];
|
|
25739
|
+
if (charCode === 0)
|
|
25740
|
+
break;
|
|
25741
|
+
if (charCode === 32)
|
|
25742
|
+
continue;
|
|
25743
|
+
value = value * 8 + (charCode - 48);
|
|
25744
|
+
}
|
|
25745
|
+
return value;
|
|
25746
|
+
}
|
|
25747
|
+
function readNumeric2(view, offset, size) {
|
|
25748
|
+
if (view[offset] & 128) {
|
|
25749
|
+
let result = 0;
|
|
25750
|
+
result = view[offset] & 127;
|
|
25751
|
+
for (let i = 1;i < size; i++)
|
|
25752
|
+
result = result * 256 + view[offset + i];
|
|
25753
|
+
if (!Number.isSafeInteger(result))
|
|
25754
|
+
throw new Error("TAR number too large");
|
|
25755
|
+
return result;
|
|
25756
|
+
}
|
|
25757
|
+
return readOctal2(view, offset, size);
|
|
25758
|
+
}
|
|
25759
|
+
var isBodyless2 = (header) => header.type === DIRECTORY2 || header.type === SYMLINK2 || header.type === LINK2;
|
|
25760
|
+
async function normalizeBody2(body) {
|
|
25761
|
+
if (body === null || body === undefined)
|
|
25762
|
+
return EMPTY3;
|
|
25763
|
+
if (body instanceof Uint8Array)
|
|
25764
|
+
return body;
|
|
25765
|
+
if (typeof body === "string")
|
|
25766
|
+
return encoder3.encode(body);
|
|
25767
|
+
if (body instanceof ArrayBuffer)
|
|
25768
|
+
return new Uint8Array(body);
|
|
25769
|
+
if (body instanceof Blob)
|
|
25770
|
+
return new Uint8Array(await body.arrayBuffer());
|
|
25771
|
+
throw new TypeError("Unsupported content type for entry body.");
|
|
25772
|
+
}
|
|
25773
|
+
function transformHeader2(header, options) {
|
|
25774
|
+
const { strip, filter, map } = options;
|
|
25775
|
+
if (!strip && !filter && !map)
|
|
25776
|
+
return header;
|
|
25777
|
+
const h = { ...header };
|
|
25778
|
+
if (strip && strip > 0) {
|
|
25779
|
+
const components = h.name.split("/").filter(Boolean);
|
|
25780
|
+
if (strip >= components.length)
|
|
25781
|
+
return null;
|
|
25782
|
+
const newName = components.slice(strip).join("/");
|
|
25783
|
+
h.name = h.type === DIRECTORY2 && !newName.endsWith("/") ? `${newName}/` : newName;
|
|
25784
|
+
if (h.linkname?.startsWith("/")) {
|
|
25785
|
+
const linkComponents = h.linkname.split("/").filter(Boolean);
|
|
25786
|
+
h.linkname = strip >= linkComponents.length ? "/" : `/${linkComponents.slice(strip).join("/")}`;
|
|
25787
|
+
}
|
|
25788
|
+
}
|
|
25789
|
+
if (filter?.(h) === false)
|
|
25790
|
+
return null;
|
|
25791
|
+
const result = map ? map(h) : h;
|
|
25792
|
+
if (result && (!result.name || !result.name.trim() || result.name === "." || result.name === "/"))
|
|
25793
|
+
return null;
|
|
25794
|
+
return result;
|
|
25795
|
+
}
|
|
25796
|
+
var CHECKSUM_SPACE2 = 32;
|
|
25797
|
+
var ASCII_ZERO2 = 48;
|
|
25798
|
+
function validateChecksum2(block) {
|
|
25799
|
+
const stored = readOctal2(block, USTAR_CHECKSUM_OFFSET2, USTAR_CHECKSUM_SIZE2);
|
|
25800
|
+
let sum = 0;
|
|
25801
|
+
for (let i = 0;i < block.length; i++)
|
|
25802
|
+
if (i >= USTAR_CHECKSUM_OFFSET2 && i < USTAR_CHECKSUM_OFFSET2 + USTAR_CHECKSUM_SIZE2)
|
|
25803
|
+
sum += CHECKSUM_SPACE2;
|
|
25804
|
+
else
|
|
25805
|
+
sum += block[i];
|
|
25806
|
+
return stored === sum;
|
|
25807
|
+
}
|
|
25808
|
+
function writeChecksum2(block) {
|
|
25809
|
+
block.fill(CHECKSUM_SPACE2, USTAR_CHECKSUM_OFFSET2, USTAR_CHECKSUM_OFFSET2 + USTAR_CHECKSUM_SIZE2);
|
|
25810
|
+
let checksum = 0;
|
|
25811
|
+
for (const byte of block)
|
|
25812
|
+
checksum += byte;
|
|
25813
|
+
for (let i = USTAR_CHECKSUM_OFFSET2 + 6 - 1;i >= USTAR_CHECKSUM_OFFSET2; i--) {
|
|
25814
|
+
block[i] = (checksum & 7) + ASCII_ZERO2;
|
|
25815
|
+
checksum >>= 3;
|
|
25816
|
+
}
|
|
25817
|
+
block[USTAR_CHECKSUM_OFFSET2 + 6] = 0;
|
|
25818
|
+
block[USTAR_CHECKSUM_OFFSET2 + 7] = CHECKSUM_SPACE2;
|
|
25819
|
+
}
|
|
25820
|
+
function generatePax2(header) {
|
|
25821
|
+
const paxRecords = {};
|
|
25822
|
+
if (header.name.length > USTAR_NAME_SIZE2) {
|
|
25823
|
+
if (findUstarSplit2(header.name) === null)
|
|
25824
|
+
paxRecords.path = header.name;
|
|
25825
|
+
}
|
|
25826
|
+
if (header.linkname && header.linkname.length > USTAR_NAME_SIZE2)
|
|
25827
|
+
paxRecords.linkpath = header.linkname;
|
|
25828
|
+
if (header.uname && header.uname.length > USTAR_UNAME_SIZE2)
|
|
25829
|
+
paxRecords.uname = header.uname;
|
|
25830
|
+
if (header.gname && header.gname.length > USTAR_GNAME_SIZE2)
|
|
25831
|
+
paxRecords.gname = header.gname;
|
|
25832
|
+
if (header.uid != null && header.uid > USTAR_MAX_UID_GID2)
|
|
25833
|
+
paxRecords.uid = String(header.uid);
|
|
25834
|
+
if (header.gid != null && header.gid > USTAR_MAX_UID_GID2)
|
|
25835
|
+
paxRecords.gid = String(header.gid);
|
|
25836
|
+
if (header.size != null && header.size > USTAR_MAX_SIZE2)
|
|
25837
|
+
paxRecords.size = String(header.size);
|
|
25838
|
+
if (header.pax)
|
|
25839
|
+
Object.assign(paxRecords, header.pax);
|
|
25840
|
+
const paxEntries = Object.entries(paxRecords);
|
|
25841
|
+
if (paxEntries.length === 0)
|
|
25842
|
+
return null;
|
|
25843
|
+
const paxBody = encoder3.encode(paxEntries.map(([key, value]) => {
|
|
25844
|
+
const record = `${key}=${value}
|
|
25845
|
+
`;
|
|
25846
|
+
const partLength = encoder3.encode(record).length + 1;
|
|
25847
|
+
let totalLength = partLength + String(partLength).length;
|
|
25848
|
+
totalLength = partLength + String(totalLength).length;
|
|
25849
|
+
return `${totalLength} ${record}`;
|
|
25850
|
+
}).join(""));
|
|
25851
|
+
return {
|
|
25852
|
+
paxHeader: createTarHeader2({
|
|
25853
|
+
name: decoder3.decode(encoder3.encode(`PaxHeader/${header.name}`).slice(0, 100)),
|
|
25854
|
+
size: paxBody.length,
|
|
25855
|
+
type: "pax-header",
|
|
25856
|
+
mode: 420,
|
|
25857
|
+
mtime: header.mtime,
|
|
25858
|
+
uname: header.uname,
|
|
25859
|
+
gname: header.gname,
|
|
25860
|
+
uid: header.uid,
|
|
25861
|
+
gid: header.gid
|
|
25862
|
+
}),
|
|
25863
|
+
paxBody
|
|
25864
|
+
};
|
|
25865
|
+
}
|
|
25866
|
+
function findUstarSplit2(path) {
|
|
25867
|
+
if (path.length <= USTAR_NAME_SIZE2)
|
|
25868
|
+
return null;
|
|
25869
|
+
const minSlashIndex = path.length - USTAR_NAME_SIZE2 - 1;
|
|
25870
|
+
const slashIndex = path.lastIndexOf("/", USTAR_PREFIX_SIZE2);
|
|
25871
|
+
if (slashIndex > 0 && slashIndex >= minSlashIndex)
|
|
25872
|
+
return {
|
|
25873
|
+
prefix: path.slice(0, slashIndex),
|
|
25874
|
+
name: path.slice(slashIndex + 1)
|
|
25875
|
+
};
|
|
25876
|
+
return null;
|
|
25877
|
+
}
|
|
25878
|
+
function createTarHeader2(header) {
|
|
25879
|
+
const view = new Uint8Array(BLOCK_SIZE3);
|
|
25880
|
+
const size = isBodyless2(header) ? 0 : header.size ?? 0;
|
|
25881
|
+
let name = header.name;
|
|
25882
|
+
let prefix = "";
|
|
25883
|
+
if (!header.pax?.path) {
|
|
25884
|
+
const split = findUstarSplit2(name);
|
|
25885
|
+
if (split) {
|
|
25886
|
+
name = split.name;
|
|
25887
|
+
prefix = split.prefix;
|
|
25888
|
+
}
|
|
25889
|
+
}
|
|
25890
|
+
writeString2(view, USTAR_NAME_OFFSET2, USTAR_NAME_SIZE2, name);
|
|
25891
|
+
writeOctal2(view, USTAR_MODE_OFFSET2, USTAR_MODE_SIZE2, header.mode ?? (header.type === DIRECTORY2 ? DEFAULT_DIR_MODE2 : DEFAULT_FILE_MODE2));
|
|
25892
|
+
writeOctal2(view, USTAR_UID_OFFSET2, USTAR_UID_SIZE2, header.uid ?? 0);
|
|
25893
|
+
writeOctal2(view, USTAR_GID_OFFSET2, USTAR_GID_SIZE2, header.gid ?? 0);
|
|
25894
|
+
writeOctal2(view, USTAR_SIZE_OFFSET2, USTAR_SIZE_SIZE2, size);
|
|
25895
|
+
writeOctal2(view, USTAR_MTIME_OFFSET2, USTAR_MTIME_SIZE2, Math.floor((header.mtime?.getTime() ?? Date.now()) / 1000));
|
|
25896
|
+
writeString2(view, USTAR_TYPEFLAG_OFFSET2, USTAR_TYPEFLAG_SIZE2, TYPEFLAG2[header.type ?? FILE2]);
|
|
25897
|
+
writeString2(view, USTAR_LINKNAME_OFFSET2, USTAR_LINKNAME_SIZE2, header.linkname);
|
|
25898
|
+
writeString2(view, USTAR_MAGIC_OFFSET2, USTAR_MAGIC_SIZE2, "ustar\x00");
|
|
25899
|
+
writeString2(view, USTAR_VERSION_OFFSET2, USTAR_VERSION_SIZE2, USTAR_VERSION2);
|
|
25900
|
+
writeString2(view, USTAR_UNAME_OFFSET2, USTAR_UNAME_SIZE2, header.uname);
|
|
25901
|
+
writeString2(view, USTAR_GNAME_OFFSET2, USTAR_GNAME_SIZE2, header.gname);
|
|
25902
|
+
writeString2(view, USTAR_PREFIX_OFFSET2, USTAR_PREFIX_SIZE2, prefix);
|
|
25903
|
+
writeChecksum2(view);
|
|
25904
|
+
return view;
|
|
25905
|
+
}
|
|
25906
|
+
function parseUstarHeader2(block, strict) {
|
|
25907
|
+
if (strict && !validateChecksum2(block))
|
|
25908
|
+
throw new Error("Invalid tar header checksum.");
|
|
25909
|
+
const typeflag = readString2(block, USTAR_TYPEFLAG_OFFSET2, USTAR_TYPEFLAG_SIZE2);
|
|
25910
|
+
const header = {
|
|
25911
|
+
name: readString2(block, USTAR_NAME_OFFSET2, USTAR_NAME_SIZE2),
|
|
25912
|
+
mode: readOctal2(block, USTAR_MODE_OFFSET2, USTAR_MODE_SIZE2),
|
|
25913
|
+
uid: readNumeric2(block, USTAR_UID_OFFSET2, USTAR_UID_SIZE2),
|
|
25914
|
+
gid: readNumeric2(block, USTAR_GID_OFFSET2, USTAR_GID_SIZE2),
|
|
25915
|
+
size: readNumeric2(block, USTAR_SIZE_OFFSET2, USTAR_SIZE_SIZE2),
|
|
25916
|
+
mtime: /* @__PURE__ */ new Date(readNumeric2(block, USTAR_MTIME_OFFSET2, USTAR_MTIME_SIZE2) * 1000),
|
|
25917
|
+
type: FLAGTYPE2[typeflag] || FILE2,
|
|
25918
|
+
linkname: readString2(block, USTAR_LINKNAME_OFFSET2, USTAR_LINKNAME_SIZE2)
|
|
25919
|
+
};
|
|
25920
|
+
const magic = readString2(block, USTAR_MAGIC_OFFSET2, USTAR_MAGIC_SIZE2);
|
|
25921
|
+
if (magic.trim() === "ustar") {
|
|
25922
|
+
header.uname = readString2(block, USTAR_UNAME_OFFSET2, USTAR_UNAME_SIZE2);
|
|
25923
|
+
header.gname = readString2(block, USTAR_GNAME_OFFSET2, USTAR_GNAME_SIZE2);
|
|
25924
|
+
}
|
|
25925
|
+
if (magic === "ustar")
|
|
25926
|
+
header.prefix = readString2(block, USTAR_PREFIX_OFFSET2, USTAR_PREFIX_SIZE2);
|
|
25927
|
+
return header;
|
|
25928
|
+
}
|
|
25929
|
+
var PAX_MAPPING2 = {
|
|
25930
|
+
path: ["name", (v) => v],
|
|
25931
|
+
linkpath: ["linkname", (v) => v],
|
|
25932
|
+
size: ["size", (v) => parseInt(v, 10)],
|
|
25933
|
+
mtime: ["mtime", parseFloat],
|
|
25934
|
+
uid: ["uid", (v) => parseInt(v, 10)],
|
|
25935
|
+
gid: ["gid", (v) => parseInt(v, 10)],
|
|
25936
|
+
uname: ["uname", (v) => v],
|
|
25937
|
+
gname: ["gname", (v) => v]
|
|
25938
|
+
};
|
|
25939
|
+
function parsePax2(buffer) {
|
|
25940
|
+
const decoder$1 = new TextDecoder("utf-8");
|
|
25941
|
+
const overrides = {};
|
|
25942
|
+
const pax = {};
|
|
25943
|
+
let offset = 0;
|
|
25944
|
+
while (offset < buffer.length) {
|
|
25945
|
+
const spaceIndex = buffer.indexOf(32, offset);
|
|
25946
|
+
if (spaceIndex === -1)
|
|
25947
|
+
break;
|
|
25948
|
+
const length = parseInt(decoder$1.decode(buffer.subarray(offset, spaceIndex)), 10);
|
|
25949
|
+
if (Number.isNaN(length) || length === 0)
|
|
25950
|
+
break;
|
|
25951
|
+
const recordEnd = offset + length;
|
|
25952
|
+
const [key, value] = decoder$1.decode(buffer.subarray(spaceIndex + 1, recordEnd - 1)).split("=", 2);
|
|
25953
|
+
if (key && value !== undefined) {
|
|
25954
|
+
pax[key] = value;
|
|
25955
|
+
const mapping = PAX_MAPPING2[key];
|
|
25956
|
+
if (mapping) {
|
|
25957
|
+
const [targetKey, parser] = mapping;
|
|
25958
|
+
const parsedValue = parser(value);
|
|
25959
|
+
if (typeof parsedValue === "string" || !Number.isNaN(parsedValue))
|
|
25960
|
+
overrides[targetKey] = parsedValue;
|
|
25961
|
+
}
|
|
25962
|
+
}
|
|
25963
|
+
offset = recordEnd;
|
|
25964
|
+
}
|
|
25965
|
+
if (Object.keys(pax).length > 0)
|
|
25966
|
+
overrides.pax = pax;
|
|
25967
|
+
return overrides;
|
|
25968
|
+
}
|
|
25969
|
+
function applyOverrides2(header, overrides) {
|
|
25970
|
+
if (overrides.name !== undefined)
|
|
25971
|
+
header.name = overrides.name;
|
|
25972
|
+
if (overrides.linkname !== undefined)
|
|
25973
|
+
header.linkname = overrides.linkname;
|
|
25974
|
+
if (overrides.size !== undefined)
|
|
25975
|
+
header.size = overrides.size;
|
|
25976
|
+
if (overrides.mtime !== undefined)
|
|
25977
|
+
header.mtime = /* @__PURE__ */ new Date(overrides.mtime * 1000);
|
|
25978
|
+
if (overrides.uid !== undefined)
|
|
25979
|
+
header.uid = overrides.uid;
|
|
25980
|
+
if (overrides.gid !== undefined)
|
|
25981
|
+
header.gid = overrides.gid;
|
|
25982
|
+
if (overrides.uname !== undefined)
|
|
25983
|
+
header.uname = overrides.uname;
|
|
25984
|
+
if (overrides.gname !== undefined)
|
|
25985
|
+
header.gname = overrides.gname;
|
|
25986
|
+
if (overrides.pax)
|
|
25987
|
+
header.pax = Object.assign({}, header.pax ?? {}, overrides.pax);
|
|
25988
|
+
}
|
|
25989
|
+
function getMetaParser2(type) {
|
|
25990
|
+
switch (type) {
|
|
25991
|
+
case "pax-global-header":
|
|
25992
|
+
case "pax-header":
|
|
25993
|
+
return parsePax2;
|
|
25994
|
+
case "gnu-long-name":
|
|
25995
|
+
return (data) => ({ name: readString2(data, 0, data.length) });
|
|
25996
|
+
case "gnu-long-link-name":
|
|
25997
|
+
return (data) => ({ linkname: readString2(data, 0, data.length) });
|
|
25998
|
+
default:
|
|
25999
|
+
return;
|
|
26000
|
+
}
|
|
26001
|
+
}
|
|
26002
|
+
function getHeaderBlocks2(header) {
|
|
26003
|
+
const base = createTarHeader2(header);
|
|
26004
|
+
const pax = generatePax2(header);
|
|
26005
|
+
if (!pax)
|
|
26006
|
+
return [base];
|
|
26007
|
+
const paxPadding = -pax.paxBody.length & BLOCK_SIZE_MASK2;
|
|
26008
|
+
const paddingBlocks = paxPadding > 0 ? [ZERO_BLOCK3.subarray(0, paxPadding)] : [];
|
|
26009
|
+
return [
|
|
26010
|
+
pax.paxHeader,
|
|
26011
|
+
pax.paxBody,
|
|
26012
|
+
...paddingBlocks,
|
|
26013
|
+
base
|
|
26014
|
+
];
|
|
26015
|
+
}
|
|
26016
|
+
var EOF_BUFFER3 = new Uint8Array(BLOCK_SIZE3 * 2);
|
|
26017
|
+
function createTarPacker3(onData, onError, onFinalize) {
|
|
26018
|
+
let currentHeader = null;
|
|
26019
|
+
let bytesWritten = 0;
|
|
26020
|
+
let finalized = false;
|
|
26021
|
+
return {
|
|
26022
|
+
add(header) {
|
|
26023
|
+
if (finalized) {
|
|
26024
|
+
const error = /* @__PURE__ */ new Error("No new tar entries after finalize.");
|
|
26025
|
+
onError(error);
|
|
26026
|
+
throw error;
|
|
26027
|
+
}
|
|
26028
|
+
if (currentHeader !== null) {
|
|
26029
|
+
const error = /* @__PURE__ */ new Error("Previous entry must be completed before adding a new one");
|
|
26030
|
+
onError(error);
|
|
26031
|
+
throw error;
|
|
26032
|
+
}
|
|
26033
|
+
try {
|
|
26034
|
+
const size = isBodyless2(header) ? 0 : header.size ?? 0;
|
|
26035
|
+
const headerBlocks = getHeaderBlocks2({
|
|
26036
|
+
...header,
|
|
26037
|
+
size
|
|
26038
|
+
});
|
|
26039
|
+
for (const block of headerBlocks)
|
|
26040
|
+
onData(block);
|
|
26041
|
+
currentHeader = {
|
|
26042
|
+
...header,
|
|
26043
|
+
size
|
|
26044
|
+
};
|
|
26045
|
+
bytesWritten = 0;
|
|
26046
|
+
} catch (error) {
|
|
26047
|
+
onError(error);
|
|
26048
|
+
}
|
|
26049
|
+
},
|
|
26050
|
+
write(chunk) {
|
|
26051
|
+
if (!currentHeader) {
|
|
26052
|
+
const error = /* @__PURE__ */ new Error("No active tar entry.");
|
|
26053
|
+
onError(error);
|
|
26054
|
+
throw error;
|
|
26055
|
+
}
|
|
26056
|
+
if (finalized) {
|
|
26057
|
+
const error = /* @__PURE__ */ new Error("Cannot write data after finalize.");
|
|
26058
|
+
onError(error);
|
|
26059
|
+
throw error;
|
|
26060
|
+
}
|
|
26061
|
+
const newTotal = bytesWritten + chunk.length;
|
|
26062
|
+
if (newTotal > currentHeader.size) {
|
|
26063
|
+
const error = /* @__PURE__ */ new Error(`"${currentHeader.name}" exceeds given size of ${currentHeader.size} bytes.`);
|
|
26064
|
+
onError(error);
|
|
26065
|
+
throw error;
|
|
26066
|
+
}
|
|
26067
|
+
try {
|
|
26068
|
+
bytesWritten = newTotal;
|
|
26069
|
+
onData(chunk);
|
|
26070
|
+
} catch (error) {
|
|
26071
|
+
onError(error);
|
|
26072
|
+
}
|
|
26073
|
+
},
|
|
26074
|
+
endEntry() {
|
|
26075
|
+
if (!currentHeader) {
|
|
26076
|
+
const error = /* @__PURE__ */ new Error("No active entry to end.");
|
|
26077
|
+
onError(error);
|
|
26078
|
+
throw error;
|
|
26079
|
+
}
|
|
26080
|
+
if (finalized) {
|
|
26081
|
+
const error = /* @__PURE__ */ new Error("Cannot end entry after finalize.");
|
|
26082
|
+
onError(error);
|
|
26083
|
+
throw error;
|
|
26084
|
+
}
|
|
26085
|
+
try {
|
|
26086
|
+
if (bytesWritten !== currentHeader.size) {
|
|
26087
|
+
const error = /* @__PURE__ */ new Error(`Size mismatch for "${currentHeader.name}".`);
|
|
26088
|
+
onError(error);
|
|
26089
|
+
throw error;
|
|
26090
|
+
}
|
|
26091
|
+
const paddingSize = -currentHeader.size & BLOCK_SIZE_MASK2;
|
|
26092
|
+
if (paddingSize > 0)
|
|
26093
|
+
onData(new Uint8Array(paddingSize));
|
|
26094
|
+
currentHeader = null;
|
|
26095
|
+
bytesWritten = 0;
|
|
26096
|
+
} catch (error) {
|
|
26097
|
+
onError(error);
|
|
26098
|
+
throw error;
|
|
26099
|
+
}
|
|
26100
|
+
},
|
|
26101
|
+
finalize() {
|
|
26102
|
+
if (finalized) {
|
|
26103
|
+
const error = /* @__PURE__ */ new Error("Archive has already been finalized");
|
|
26104
|
+
onError(error);
|
|
26105
|
+
throw error;
|
|
26106
|
+
}
|
|
26107
|
+
if (currentHeader !== null) {
|
|
26108
|
+
const error = /* @__PURE__ */ new Error("Cannot finalize while an entry is still active");
|
|
26109
|
+
onError(error);
|
|
26110
|
+
throw error;
|
|
26111
|
+
}
|
|
26112
|
+
try {
|
|
26113
|
+
onData(EOF_BUFFER3);
|
|
26114
|
+
finalized = true;
|
|
26115
|
+
if (onFinalize)
|
|
26116
|
+
onFinalize();
|
|
26117
|
+
} catch (error) {
|
|
26118
|
+
onError(error);
|
|
26119
|
+
}
|
|
26120
|
+
}
|
|
26121
|
+
};
|
|
26122
|
+
}
|
|
26123
|
+
var INITIAL_CAPACITY2 = 256;
|
|
26124
|
+
function createChunkQueue2() {
|
|
26125
|
+
let chunks = new Array(INITIAL_CAPACITY2);
|
|
26126
|
+
let capacityMask = chunks.length - 1;
|
|
26127
|
+
let head = 0;
|
|
26128
|
+
let tail = 0;
|
|
26129
|
+
let totalAvailable = 0;
|
|
26130
|
+
const consumeFromHead = (count) => {
|
|
26131
|
+
const chunk = chunks[head];
|
|
26132
|
+
if (count === chunk.length) {
|
|
26133
|
+
chunks[head] = EMPTY3;
|
|
26134
|
+
head = head + 1 & capacityMask;
|
|
26135
|
+
} else
|
|
26136
|
+
chunks[head] = chunk.subarray(count);
|
|
26137
|
+
totalAvailable -= count;
|
|
26138
|
+
if (totalAvailable === 0 && chunks.length > INITIAL_CAPACITY2) {
|
|
26139
|
+
chunks = new Array(INITIAL_CAPACITY2);
|
|
26140
|
+
capacityMask = INITIAL_CAPACITY2 - 1;
|
|
26141
|
+
head = 0;
|
|
26142
|
+
tail = 0;
|
|
26143
|
+
}
|
|
26144
|
+
};
|
|
26145
|
+
function pull(bytes, callback) {
|
|
26146
|
+
if (callback) {
|
|
26147
|
+
let fed = 0;
|
|
26148
|
+
let remaining$1 = Math.min(bytes, totalAvailable);
|
|
26149
|
+
while (remaining$1 > 0) {
|
|
26150
|
+
const chunk = chunks[head];
|
|
26151
|
+
const toFeed = Math.min(remaining$1, chunk.length);
|
|
26152
|
+
const segment = toFeed === chunk.length ? chunk : chunk.subarray(0, toFeed);
|
|
26153
|
+
consumeFromHead(toFeed);
|
|
26154
|
+
remaining$1 -= toFeed;
|
|
26155
|
+
fed += toFeed;
|
|
26156
|
+
if (!callback(segment))
|
|
26157
|
+
break;
|
|
26158
|
+
}
|
|
26159
|
+
return fed;
|
|
26160
|
+
}
|
|
26161
|
+
if (totalAvailable < bytes)
|
|
26162
|
+
return null;
|
|
26163
|
+
if (bytes === 0)
|
|
26164
|
+
return EMPTY3;
|
|
26165
|
+
const firstChunk = chunks[head];
|
|
26166
|
+
if (firstChunk.length >= bytes) {
|
|
26167
|
+
const view = firstChunk.length === bytes ? firstChunk : firstChunk.subarray(0, bytes);
|
|
26168
|
+
consumeFromHead(bytes);
|
|
26169
|
+
return view;
|
|
26170
|
+
}
|
|
26171
|
+
const result = new Uint8Array(bytes);
|
|
26172
|
+
let copied = 0;
|
|
26173
|
+
let remaining = bytes;
|
|
26174
|
+
while (remaining > 0) {
|
|
26175
|
+
const chunk = chunks[head];
|
|
26176
|
+
const toCopy = Math.min(remaining, chunk.length);
|
|
26177
|
+
result.set(toCopy === chunk.length ? chunk : chunk.subarray(0, toCopy), copied);
|
|
26178
|
+
copied += toCopy;
|
|
26179
|
+
remaining -= toCopy;
|
|
26180
|
+
consumeFromHead(toCopy);
|
|
26181
|
+
}
|
|
26182
|
+
return result;
|
|
26183
|
+
}
|
|
26184
|
+
return {
|
|
26185
|
+
push: (chunk) => {
|
|
26186
|
+
if (chunk.length === 0)
|
|
26187
|
+
return;
|
|
26188
|
+
let nextTail = tail + 1 & capacityMask;
|
|
26189
|
+
if (nextTail === head) {
|
|
26190
|
+
const oldLen = chunks.length;
|
|
26191
|
+
const newLen = oldLen * 2;
|
|
26192
|
+
const newChunks = new Array(newLen);
|
|
26193
|
+
const count = tail - head + oldLen & oldLen - 1;
|
|
26194
|
+
if (head < tail)
|
|
26195
|
+
for (let i = 0;i < count; i++)
|
|
26196
|
+
newChunks[i] = chunks[head + i];
|
|
26197
|
+
else if (count > 0) {
|
|
26198
|
+
const firstPart = oldLen - head;
|
|
26199
|
+
for (let i = 0;i < firstPart; i++)
|
|
26200
|
+
newChunks[i] = chunks[head + i];
|
|
26201
|
+
for (let i = 0;i < tail; i++)
|
|
26202
|
+
newChunks[firstPart + i] = chunks[i];
|
|
26203
|
+
}
|
|
26204
|
+
chunks = newChunks;
|
|
26205
|
+
capacityMask = newLen - 1;
|
|
26206
|
+
head = 0;
|
|
26207
|
+
tail = count;
|
|
26208
|
+
nextTail = tail + 1 & capacityMask;
|
|
26209
|
+
}
|
|
26210
|
+
chunks[tail] = chunk;
|
|
26211
|
+
tail = nextTail;
|
|
26212
|
+
totalAvailable += chunk.length;
|
|
26213
|
+
},
|
|
26214
|
+
available: () => totalAvailable,
|
|
26215
|
+
peek: (bytes) => {
|
|
26216
|
+
if (totalAvailable < bytes)
|
|
26217
|
+
return null;
|
|
26218
|
+
if (bytes === 0)
|
|
26219
|
+
return EMPTY3;
|
|
26220
|
+
const firstChunk = chunks[head];
|
|
26221
|
+
if (firstChunk.length >= bytes)
|
|
26222
|
+
return firstChunk.length === bytes ? firstChunk : firstChunk.subarray(0, bytes);
|
|
26223
|
+
const result = new Uint8Array(bytes);
|
|
26224
|
+
let copied = 0;
|
|
26225
|
+
let index = head;
|
|
26226
|
+
while (copied < bytes) {
|
|
26227
|
+
const chunk = chunks[index];
|
|
26228
|
+
const toCopy = Math.min(bytes - copied, chunk.length);
|
|
26229
|
+
if (toCopy === chunk.length)
|
|
26230
|
+
result.set(chunk, copied);
|
|
26231
|
+
else
|
|
26232
|
+
result.set(chunk.subarray(0, toCopy), copied);
|
|
26233
|
+
copied += toCopy;
|
|
26234
|
+
index = index + 1 & capacityMask;
|
|
26235
|
+
}
|
|
26236
|
+
return result;
|
|
26237
|
+
},
|
|
26238
|
+
discard: (bytes) => {
|
|
26239
|
+
if (bytes > totalAvailable)
|
|
26240
|
+
throw new Error("Too many bytes consumed");
|
|
26241
|
+
if (bytes === 0)
|
|
26242
|
+
return;
|
|
26243
|
+
let remaining = bytes;
|
|
26244
|
+
while (remaining > 0) {
|
|
26245
|
+
const chunk = chunks[head];
|
|
26246
|
+
const toConsume = Math.min(remaining, chunk.length);
|
|
26247
|
+
consumeFromHead(toConsume);
|
|
26248
|
+
remaining -= toConsume;
|
|
26249
|
+
}
|
|
26250
|
+
},
|
|
26251
|
+
pull
|
|
26252
|
+
};
|
|
26253
|
+
}
|
|
26254
|
+
var STATE_HEADER2 = 0;
|
|
26255
|
+
var STATE_BODY2 = 1;
|
|
26256
|
+
var truncateErr2 = /* @__PURE__ */ new Error("Tar archive is truncated.");
|
|
26257
|
+
function createUnpacker2(options = {}) {
|
|
26258
|
+
const strict = options.strict ?? false;
|
|
26259
|
+
const { available, peek, push, discard, pull } = createChunkQueue2();
|
|
26260
|
+
let state = STATE_HEADER2;
|
|
26261
|
+
let ended = false;
|
|
26262
|
+
let done = false;
|
|
26263
|
+
let eof = false;
|
|
26264
|
+
let currentEntry = null;
|
|
26265
|
+
const paxGlobals = {};
|
|
26266
|
+
let nextEntryOverrides = {};
|
|
26267
|
+
const unpacker = {
|
|
26268
|
+
isEntryActive: () => state === STATE_BODY2,
|
|
26269
|
+
isBodyComplete: () => !currentEntry || currentEntry.remaining === 0,
|
|
26270
|
+
write(chunk) {
|
|
26271
|
+
if (ended)
|
|
26272
|
+
throw new Error("Archive already ended.");
|
|
26273
|
+
push(chunk);
|
|
26274
|
+
},
|
|
26275
|
+
end() {
|
|
26276
|
+
ended = true;
|
|
26277
|
+
},
|
|
26278
|
+
readHeader() {
|
|
26279
|
+
if (state !== STATE_HEADER2)
|
|
26280
|
+
throw new Error("Cannot read header while an entry is active");
|
|
26281
|
+
if (done)
|
|
26282
|
+
return;
|
|
26283
|
+
while (!done) {
|
|
26284
|
+
if (available() < BLOCK_SIZE3) {
|
|
26285
|
+
if (ended) {
|
|
26286
|
+
if (available() > 0 && strict)
|
|
26287
|
+
throw truncateErr2;
|
|
26288
|
+
done = true;
|
|
26289
|
+
return;
|
|
26290
|
+
}
|
|
26291
|
+
return null;
|
|
26292
|
+
}
|
|
26293
|
+
const headerBlock = peek(BLOCK_SIZE3);
|
|
26294
|
+
if (isZeroBlock2(headerBlock)) {
|
|
26295
|
+
if (available() < BLOCK_SIZE3 * 2) {
|
|
26296
|
+
if (ended) {
|
|
26297
|
+
if (strict)
|
|
26298
|
+
throw truncateErr2;
|
|
26299
|
+
done = true;
|
|
26300
|
+
return;
|
|
26301
|
+
}
|
|
26302
|
+
return null;
|
|
26303
|
+
}
|
|
26304
|
+
if (isZeroBlock2(peek(BLOCK_SIZE3 * 2).subarray(BLOCK_SIZE3))) {
|
|
26305
|
+
discard(BLOCK_SIZE3 * 2);
|
|
26306
|
+
done = true;
|
|
26307
|
+
eof = true;
|
|
26308
|
+
return;
|
|
26309
|
+
}
|
|
26310
|
+
if (strict)
|
|
26311
|
+
throw new Error("Invalid tar header.");
|
|
26312
|
+
discard(BLOCK_SIZE3);
|
|
26313
|
+
continue;
|
|
26314
|
+
}
|
|
26315
|
+
let internalHeader;
|
|
26316
|
+
try {
|
|
26317
|
+
internalHeader = parseUstarHeader2(headerBlock, strict);
|
|
26318
|
+
} catch (err) {
|
|
26319
|
+
if (strict)
|
|
26320
|
+
throw err;
|
|
26321
|
+
discard(BLOCK_SIZE3);
|
|
26322
|
+
continue;
|
|
26323
|
+
}
|
|
26324
|
+
const metaParser = getMetaParser2(internalHeader.type);
|
|
26325
|
+
if (metaParser) {
|
|
26326
|
+
const paddedSize = internalHeader.size + BLOCK_SIZE_MASK2 & ~BLOCK_SIZE_MASK2;
|
|
26327
|
+
if (available() < BLOCK_SIZE3 + paddedSize) {
|
|
26328
|
+
if (ended && strict)
|
|
26329
|
+
throw truncateErr2;
|
|
26330
|
+
return null;
|
|
26331
|
+
}
|
|
26332
|
+
discard(BLOCK_SIZE3);
|
|
26333
|
+
const overrides = metaParser(pull(paddedSize).subarray(0, internalHeader.size));
|
|
26334
|
+
const target = internalHeader.type === "pax-global-header" ? paxGlobals : nextEntryOverrides;
|
|
26335
|
+
for (const key in overrides)
|
|
26336
|
+
target[key] = overrides[key];
|
|
26337
|
+
continue;
|
|
26338
|
+
}
|
|
26339
|
+
discard(BLOCK_SIZE3);
|
|
26340
|
+
const header = internalHeader;
|
|
26341
|
+
if (internalHeader.prefix)
|
|
26342
|
+
header.name = `${internalHeader.prefix}/${header.name}`;
|
|
26343
|
+
applyOverrides2(header, paxGlobals);
|
|
26344
|
+
applyOverrides2(header, nextEntryOverrides);
|
|
26345
|
+
nextEntryOverrides = {};
|
|
26346
|
+
currentEntry = {
|
|
26347
|
+
header,
|
|
26348
|
+
remaining: header.size,
|
|
26349
|
+
padding: -header.size & BLOCK_SIZE_MASK2
|
|
26350
|
+
};
|
|
26351
|
+
state = STATE_BODY2;
|
|
26352
|
+
return header;
|
|
26353
|
+
}
|
|
26354
|
+
},
|
|
26355
|
+
streamBody(callback) {
|
|
26356
|
+
if (state !== STATE_BODY2 || !currentEntry || currentEntry.remaining === 0)
|
|
26357
|
+
return 0;
|
|
26358
|
+
const bytesToFeed = Math.min(currentEntry.remaining, available());
|
|
26359
|
+
if (bytesToFeed === 0)
|
|
26360
|
+
return 0;
|
|
26361
|
+
const fed = pull(bytesToFeed, callback);
|
|
26362
|
+
currentEntry.remaining -= fed;
|
|
26363
|
+
return fed;
|
|
26364
|
+
},
|
|
26365
|
+
skipPadding() {
|
|
26366
|
+
if (state !== STATE_BODY2 || !currentEntry)
|
|
26367
|
+
return true;
|
|
26368
|
+
if (currentEntry.remaining > 0)
|
|
26369
|
+
throw new Error("Body not fully consumed");
|
|
26370
|
+
if (available() < currentEntry.padding)
|
|
26371
|
+
return false;
|
|
26372
|
+
discard(currentEntry.padding);
|
|
26373
|
+
currentEntry = null;
|
|
26374
|
+
state = STATE_HEADER2;
|
|
26375
|
+
return true;
|
|
26376
|
+
},
|
|
26377
|
+
skipEntry() {
|
|
26378
|
+
if (state !== STATE_BODY2 || !currentEntry)
|
|
26379
|
+
return true;
|
|
26380
|
+
const toDiscard = Math.min(currentEntry.remaining, available());
|
|
26381
|
+
if (toDiscard > 0) {
|
|
26382
|
+
discard(toDiscard);
|
|
26383
|
+
currentEntry.remaining -= toDiscard;
|
|
26384
|
+
}
|
|
26385
|
+
if (currentEntry.remaining > 0)
|
|
26386
|
+
return false;
|
|
26387
|
+
return unpacker.skipPadding();
|
|
26388
|
+
},
|
|
26389
|
+
validateEOF() {
|
|
26390
|
+
if (strict) {
|
|
26391
|
+
if (!eof)
|
|
26392
|
+
throw truncateErr2;
|
|
26393
|
+
if (available() > 0) {
|
|
26394
|
+
if (pull(available()).some((byte) => byte !== 0))
|
|
26395
|
+
throw new Error("Invalid EOF.");
|
|
26396
|
+
}
|
|
26397
|
+
}
|
|
26398
|
+
}
|
|
26399
|
+
};
|
|
26400
|
+
return unpacker;
|
|
26401
|
+
}
|
|
26402
|
+
function isZeroBlock2(block) {
|
|
26403
|
+
if (block.byteOffset % 8 === 0) {
|
|
26404
|
+
const view = new BigUint64Array(block.buffer, block.byteOffset, block.length / 8);
|
|
26405
|
+
for (let i = 0;i < view.length; i++)
|
|
26406
|
+
if (view[i] !== 0n)
|
|
26407
|
+
return false;
|
|
26408
|
+
return true;
|
|
26409
|
+
}
|
|
26410
|
+
for (let i = 0;i < block.length; i++)
|
|
26411
|
+
if (block[i] !== 0)
|
|
26412
|
+
return false;
|
|
26413
|
+
return true;
|
|
26414
|
+
}
|
|
26415
|
+
function createTarPacker22() {
|
|
26416
|
+
let streamController;
|
|
26417
|
+
let packer;
|
|
26418
|
+
return {
|
|
26419
|
+
readable: new ReadableStream({ start(controller) {
|
|
26420
|
+
streamController = controller;
|
|
26421
|
+
packer = createTarPacker3(controller.enqueue.bind(controller), controller.error.bind(controller), controller.close.bind(controller));
|
|
26422
|
+
} }),
|
|
26423
|
+
controller: {
|
|
26424
|
+
add(header) {
|
|
26425
|
+
const bodyless = isBodyless2(header);
|
|
26426
|
+
const h = { ...header };
|
|
26427
|
+
if (bodyless)
|
|
26428
|
+
h.size = 0;
|
|
26429
|
+
packer.add(h);
|
|
26430
|
+
if (bodyless)
|
|
26431
|
+
packer.endEntry();
|
|
26432
|
+
return new WritableStream({
|
|
26433
|
+
write(chunk) {
|
|
26434
|
+
packer.write(chunk);
|
|
26435
|
+
},
|
|
26436
|
+
close() {
|
|
26437
|
+
if (!bodyless)
|
|
26438
|
+
packer.endEntry();
|
|
26439
|
+
},
|
|
26440
|
+
abort(reason) {
|
|
26441
|
+
streamController.error(reason);
|
|
26442
|
+
}
|
|
26443
|
+
});
|
|
26444
|
+
},
|
|
26445
|
+
finalize() {
|
|
26446
|
+
packer.finalize();
|
|
26447
|
+
},
|
|
26448
|
+
error(err) {
|
|
26449
|
+
streamController.error(err);
|
|
26450
|
+
}
|
|
26451
|
+
}
|
|
26452
|
+
};
|
|
26453
|
+
}
|
|
26454
|
+
async function streamToBuffer2(stream) {
|
|
26455
|
+
const chunks = [];
|
|
26456
|
+
const reader = stream.getReader();
|
|
26457
|
+
let totalLength = 0;
|
|
26458
|
+
try {
|
|
26459
|
+
while (true) {
|
|
26460
|
+
const { done, value } = await reader.read();
|
|
26461
|
+
if (done)
|
|
26462
|
+
break;
|
|
26463
|
+
chunks.push(value);
|
|
26464
|
+
totalLength += value.length;
|
|
26465
|
+
}
|
|
26466
|
+
const result = new Uint8Array(totalLength);
|
|
26467
|
+
let offset = 0;
|
|
26468
|
+
for (const chunk of chunks) {
|
|
26469
|
+
result.set(chunk, offset);
|
|
26470
|
+
offset += chunk.length;
|
|
26471
|
+
}
|
|
26472
|
+
return result;
|
|
26473
|
+
} finally {
|
|
26474
|
+
reader.releaseLock();
|
|
26475
|
+
}
|
|
26476
|
+
}
|
|
26477
|
+
var drain2 = (stream) => stream.pipeTo(new WritableStream);
|
|
26478
|
+
function createTarDecoder2(options = {}) {
|
|
26479
|
+
const unpacker = createUnpacker2(options);
|
|
26480
|
+
let bodyController = null;
|
|
26481
|
+
let pumping = false;
|
|
26482
|
+
const pump = (controller) => {
|
|
26483
|
+
if (pumping)
|
|
26484
|
+
return;
|
|
26485
|
+
pumping = true;
|
|
26486
|
+
try {
|
|
26487
|
+
while (true)
|
|
26488
|
+
if (unpacker.isEntryActive()) {
|
|
26489
|
+
if (bodyController) {
|
|
26490
|
+
if (unpacker.streamBody((c) => (bodyController.enqueue(c), true)) === 0 && !unpacker.isBodyComplete())
|
|
26491
|
+
break;
|
|
26492
|
+
} else if (!unpacker.skipEntry())
|
|
26493
|
+
break;
|
|
26494
|
+
if (unpacker.isBodyComplete()) {
|
|
26495
|
+
try {
|
|
26496
|
+
bodyController?.close();
|
|
26497
|
+
} catch {}
|
|
26498
|
+
bodyController = null;
|
|
26499
|
+
if (!unpacker.skipPadding())
|
|
26500
|
+
break;
|
|
26501
|
+
}
|
|
26502
|
+
} else {
|
|
26503
|
+
const header = unpacker.readHeader();
|
|
26504
|
+
if (header === null || header === undefined)
|
|
26505
|
+
break;
|
|
26506
|
+
controller.enqueue({
|
|
26507
|
+
header,
|
|
26508
|
+
body: new ReadableStream({
|
|
26509
|
+
start(c) {
|
|
26510
|
+
if (header.size === 0)
|
|
26511
|
+
c.close();
|
|
26512
|
+
else
|
|
26513
|
+
bodyController = c;
|
|
26514
|
+
},
|
|
26515
|
+
pull: () => pump(controller),
|
|
26516
|
+
cancel() {
|
|
26517
|
+
bodyController = null;
|
|
26518
|
+
pump(controller);
|
|
26519
|
+
}
|
|
26520
|
+
})
|
|
26521
|
+
});
|
|
26522
|
+
}
|
|
26523
|
+
} catch (error) {
|
|
26524
|
+
try {
|
|
26525
|
+
bodyController?.error(error);
|
|
26526
|
+
} catch {}
|
|
26527
|
+
bodyController = null;
|
|
26528
|
+
throw error;
|
|
26529
|
+
} finally {
|
|
26530
|
+
pumping = false;
|
|
26531
|
+
}
|
|
26532
|
+
};
|
|
26533
|
+
return new TransformStream({
|
|
26534
|
+
transform(chunk, controller) {
|
|
26535
|
+
try {
|
|
26536
|
+
unpacker.write(chunk);
|
|
26537
|
+
pump(controller);
|
|
26538
|
+
} catch (error) {
|
|
26539
|
+
try {
|
|
26540
|
+
bodyController?.error(error);
|
|
26541
|
+
} catch {}
|
|
26542
|
+
throw error;
|
|
26543
|
+
}
|
|
26544
|
+
},
|
|
26545
|
+
flush(controller) {
|
|
26546
|
+
try {
|
|
26547
|
+
unpacker.end();
|
|
26548
|
+
pump(controller);
|
|
26549
|
+
unpacker.validateEOF();
|
|
26550
|
+
if (unpacker.isEntryActive() && !unpacker.isBodyComplete())
|
|
26551
|
+
try {
|
|
26552
|
+
bodyController?.close();
|
|
26553
|
+
} catch {}
|
|
26554
|
+
} catch (error) {
|
|
26555
|
+
try {
|
|
26556
|
+
bodyController?.error(error);
|
|
26557
|
+
} catch {}
|
|
26558
|
+
throw error;
|
|
26559
|
+
}
|
|
26560
|
+
}
|
|
26561
|
+
}, undefined, { highWaterMark: 1 });
|
|
26562
|
+
}
|
|
26563
|
+
async function packTar2(entries) {
|
|
26564
|
+
const { readable, controller } = createTarPacker22();
|
|
26565
|
+
await (async () => {
|
|
26566
|
+
for (const entry of entries) {
|
|
26567
|
+
const entryStream = controller.add(entry.header);
|
|
26568
|
+
const body = "body" in entry ? entry.body : entry.data;
|
|
26569
|
+
if (!body) {
|
|
26570
|
+
await entryStream.close();
|
|
26571
|
+
continue;
|
|
26572
|
+
}
|
|
26573
|
+
if (body instanceof ReadableStream)
|
|
26574
|
+
await body.pipeTo(entryStream);
|
|
26575
|
+
else if (body instanceof Blob)
|
|
26576
|
+
await body.stream().pipeTo(entryStream);
|
|
26577
|
+
else
|
|
26578
|
+
try {
|
|
26579
|
+
const chunk = await normalizeBody2(body);
|
|
26580
|
+
if (chunk.length > 0) {
|
|
26581
|
+
const writer = entryStream.getWriter();
|
|
26582
|
+
await writer.write(chunk);
|
|
26583
|
+
await writer.close();
|
|
26584
|
+
} else
|
|
26585
|
+
await entryStream.close();
|
|
26586
|
+
} catch {
|
|
26587
|
+
throw new TypeError(`Unsupported content type for entry "${entry.header.name}".`);
|
|
26588
|
+
}
|
|
26589
|
+
}
|
|
26590
|
+
})().then(() => controller.finalize()).catch((err) => controller.error(err));
|
|
26591
|
+
return new Uint8Array(await streamToBuffer2(readable));
|
|
26592
|
+
}
|
|
26593
|
+
async function unpackTar2(archive, options = {}) {
|
|
26594
|
+
const sourceStream = archive instanceof ReadableStream ? archive : new ReadableStream({ start(controller) {
|
|
26595
|
+
controller.enqueue(archive instanceof Uint8Array ? archive : new Uint8Array(archive));
|
|
26596
|
+
controller.close();
|
|
26597
|
+
} });
|
|
26598
|
+
const results = [];
|
|
26599
|
+
const entryStream = sourceStream.pipeThrough(createTarDecoder2(options));
|
|
26600
|
+
for await (const entry of entryStream) {
|
|
26601
|
+
let processedHeader;
|
|
26602
|
+
try {
|
|
26603
|
+
processedHeader = transformHeader2(entry.header, options);
|
|
26604
|
+
} catch (error) {
|
|
26605
|
+
await entry.body.cancel();
|
|
26606
|
+
throw error;
|
|
26607
|
+
}
|
|
26608
|
+
if (processedHeader === null) {
|
|
26609
|
+
await drain2(entry.body);
|
|
26610
|
+
continue;
|
|
26611
|
+
}
|
|
26612
|
+
if (isBodyless2(processedHeader)) {
|
|
26613
|
+
await drain2(entry.body);
|
|
26614
|
+
results.push({ header: processedHeader });
|
|
26615
|
+
} else
|
|
26616
|
+
results.push({
|
|
26617
|
+
header: processedHeader,
|
|
26618
|
+
data: await streamToBuffer2(entry.body)
|
|
26619
|
+
});
|
|
26620
|
+
}
|
|
26621
|
+
return results;
|
|
26622
|
+
}
|
|
26623
|
+
var gzipAsync3 = promisify3(gzip3);
|
|
26624
|
+
var gunzipAsync3 = promisify3(gunzip3);
|
|
26625
|
+
|
|
26626
|
+
class RXPImpl2 {
|
|
26627
|
+
_files;
|
|
26628
|
+
_pathsCache = null;
|
|
26629
|
+
_treeCache = null;
|
|
26630
|
+
constructor(files) {
|
|
26631
|
+
this._files = files;
|
|
26632
|
+
}
|
|
26633
|
+
paths() {
|
|
26634
|
+
if (this._pathsCache) {
|
|
26635
|
+
return this._pathsCache;
|
|
26636
|
+
}
|
|
26637
|
+
this._pathsCache = Array.from(this._files.keys()).sort();
|
|
26638
|
+
return this._pathsCache;
|
|
26639
|
+
}
|
|
26640
|
+
tree() {
|
|
26641
|
+
if (this._treeCache) {
|
|
26642
|
+
return this._treeCache;
|
|
26643
|
+
}
|
|
26644
|
+
const root = new Map;
|
|
26645
|
+
for (const path of this._files.keys()) {
|
|
26646
|
+
const parts = path.split("/");
|
|
26647
|
+
let currentLevel = root;
|
|
26648
|
+
for (let i = 0;i < parts.length; i++) {
|
|
26649
|
+
const part = parts[i];
|
|
26650
|
+
const isFile = i === parts.length - 1;
|
|
26651
|
+
if (!currentLevel.has(part)) {
|
|
26652
|
+
const treeNode2 = {
|
|
26653
|
+
node: {
|
|
26654
|
+
name: part,
|
|
26655
|
+
type: isFile ? "file" : "directory",
|
|
26656
|
+
children: isFile ? undefined : []
|
|
26657
|
+
},
|
|
26658
|
+
children: new Map
|
|
26659
|
+
};
|
|
26660
|
+
currentLevel.set(part, treeNode2);
|
|
26661
|
+
}
|
|
26662
|
+
const treeNode = currentLevel.get(part);
|
|
26663
|
+
if (!isFile) {
|
|
26664
|
+
currentLevel = treeNode.children;
|
|
26665
|
+
}
|
|
26666
|
+
}
|
|
26667
|
+
}
|
|
26668
|
+
const convertToPathNodes = (level) => {
|
|
26669
|
+
return Array.from(level.values()).map((treeNode) => {
|
|
26670
|
+
if (treeNode.node.type === "directory" && treeNode.children.size > 0) {
|
|
26671
|
+
treeNode.node.children = convertToPathNodes(treeNode.children);
|
|
26672
|
+
}
|
|
26673
|
+
return treeNode.node;
|
|
26674
|
+
});
|
|
26675
|
+
};
|
|
26676
|
+
this._treeCache = convertToPathNodes(root);
|
|
26677
|
+
return this._treeCache;
|
|
26678
|
+
}
|
|
26679
|
+
async file(path) {
|
|
26680
|
+
const content = this._files.get(path);
|
|
26681
|
+
if (!content) {
|
|
26682
|
+
throw new ContentError2(`file not found: ${path}`);
|
|
26683
|
+
}
|
|
26684
|
+
return content;
|
|
26685
|
+
}
|
|
26686
|
+
async files() {
|
|
26687
|
+
return new Map(this._files);
|
|
26688
|
+
}
|
|
26689
|
+
async pack() {
|
|
26690
|
+
const filesRecord = {};
|
|
26691
|
+
for (const [path, content] of this._files) {
|
|
26692
|
+
filesRecord[path] = content;
|
|
26693
|
+
}
|
|
26694
|
+
return createRXA2(filesRecord);
|
|
26695
|
+
}
|
|
26696
|
+
}
|
|
26697
|
+
|
|
26698
|
+
class RXAImpl2 {
|
|
26699
|
+
_buffer;
|
|
26700
|
+
_rxpCache = null;
|
|
26701
|
+
constructor(buffer) {
|
|
26702
|
+
this._buffer = buffer;
|
|
26703
|
+
}
|
|
26704
|
+
get stream() {
|
|
26705
|
+
const buffer = this._buffer;
|
|
26706
|
+
return new ReadableStream({
|
|
26707
|
+
start(controller) {
|
|
26708
|
+
controller.enqueue(new Uint8Array(buffer));
|
|
26709
|
+
controller.close();
|
|
26710
|
+
}
|
|
26711
|
+
});
|
|
26712
|
+
}
|
|
26713
|
+
async buffer() {
|
|
26714
|
+
return this._buffer;
|
|
26715
|
+
}
|
|
26716
|
+
async extract() {
|
|
26717
|
+
if (this._rxpCache) {
|
|
26718
|
+
return this._rxpCache;
|
|
26719
|
+
}
|
|
26720
|
+
const tarBuffer = await gunzipAsync3(this._buffer);
|
|
26721
|
+
const entries = await unpackTar2(tarBuffer);
|
|
26722
|
+
const filesMap = new Map;
|
|
26723
|
+
for (const entry of entries) {
|
|
26724
|
+
if ((entry.header.type === "file" || entry.header.type === undefined) && entry.data) {
|
|
26725
|
+
filesMap.set(entry.header.name, Buffer.from(entry.data));
|
|
26726
|
+
}
|
|
26727
|
+
}
|
|
26728
|
+
this._rxpCache = new RXPImpl2(filesMap);
|
|
26729
|
+
return this._rxpCache;
|
|
26730
|
+
}
|
|
26731
|
+
}
|
|
26732
|
+
function isBufferInput2(input) {
|
|
26733
|
+
return "buffer" in input && Buffer.isBuffer(input.buffer);
|
|
26734
|
+
}
|
|
26735
|
+
async function createRXA2(input) {
|
|
26736
|
+
if (isBufferInput2(input)) {
|
|
26737
|
+
return new RXAImpl2(input.buffer);
|
|
26738
|
+
}
|
|
26739
|
+
const entries = Object.entries(input).map(([name, content]) => {
|
|
26740
|
+
const body = typeof content === "string" ? content : content instanceof Uint8Array ? content : new Uint8Array(content);
|
|
26741
|
+
const size = typeof content === "string" ? Buffer.byteLength(content) : content.length;
|
|
26742
|
+
return {
|
|
26743
|
+
header: { name, size, type: "file" },
|
|
26744
|
+
body
|
|
26745
|
+
};
|
|
26746
|
+
});
|
|
26747
|
+
const tarBuffer = await packTar2(entries);
|
|
26748
|
+
const gzipBuffer = await gzipAsync3(Buffer.from(tarBuffer));
|
|
26749
|
+
return new RXAImpl2(gzipBuffer);
|
|
26750
|
+
}
|
|
26751
|
+
|
|
26752
|
+
class FolderLoader {
|
|
26753
|
+
async canLoad(source) {
|
|
26754
|
+
try {
|
|
26755
|
+
const stats = await stat2(source);
|
|
26756
|
+
if (!stats.isDirectory()) {
|
|
26757
|
+
return false;
|
|
26758
|
+
}
|
|
26759
|
+
const manifestPath = join2(source, "resource.json");
|
|
26760
|
+
const manifestStats = await stat2(manifestPath);
|
|
26761
|
+
return manifestStats.isFile();
|
|
26762
|
+
} catch {
|
|
26763
|
+
return false;
|
|
26764
|
+
}
|
|
26765
|
+
}
|
|
26766
|
+
async load(folderPath) {
|
|
26767
|
+
const manifestPath = join2(folderPath, "resource.json");
|
|
26768
|
+
let manifestJson;
|
|
26769
|
+
try {
|
|
26770
|
+
manifestJson = await readFile2(manifestPath, "utf-8");
|
|
26771
|
+
} catch (error) {
|
|
26772
|
+
throw new ResourceXError3(`Failed to read resource.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
26773
|
+
}
|
|
26774
|
+
let manifestData;
|
|
26775
|
+
try {
|
|
26776
|
+
manifestData = JSON.parse(manifestJson);
|
|
26777
|
+
} catch (error) {
|
|
26778
|
+
throw new ResourceXError3(`Invalid JSON in resource.json: ${error instanceof Error ? error.message : String(error)}`);
|
|
26779
|
+
}
|
|
26780
|
+
if (!manifestData.name) {
|
|
26781
|
+
throw new ResourceXError3("Invalid resource.json: missing required field 'name'");
|
|
26782
|
+
}
|
|
26783
|
+
if (!manifestData.type) {
|
|
26784
|
+
throw new ResourceXError3("Invalid resource.json: missing required field 'type'");
|
|
26785
|
+
}
|
|
26786
|
+
if (!manifestData.version) {
|
|
26787
|
+
throw new ResourceXError3("Invalid resource.json: missing required field 'version'");
|
|
26788
|
+
}
|
|
26789
|
+
const manifest = createRXM2({
|
|
26790
|
+
domain: manifestData.domain ?? "localhost",
|
|
26791
|
+
path: manifestData.path,
|
|
26792
|
+
name: manifestData.name,
|
|
26793
|
+
type: manifestData.type,
|
|
26794
|
+
version: manifestData.version
|
|
26795
|
+
});
|
|
26796
|
+
const files = await this.readFolderFiles(folderPath);
|
|
26797
|
+
if (Object.keys(files).length === 0) {
|
|
26798
|
+
throw new ResourceXError3("No content files found in resource folder");
|
|
26799
|
+
}
|
|
26800
|
+
const archive = await createRXA2(files);
|
|
26801
|
+
const locator = parseRXL3(manifest.toLocator());
|
|
26802
|
+
return {
|
|
26803
|
+
locator,
|
|
26804
|
+
manifest,
|
|
26805
|
+
archive
|
|
26806
|
+
};
|
|
26807
|
+
}
|
|
26808
|
+
async readFolderFiles(folderPath, basePath = folderPath) {
|
|
26809
|
+
const files = {};
|
|
26810
|
+
const entries = await readdir2(folderPath, { withFileTypes: true });
|
|
26811
|
+
for (const entry of entries) {
|
|
26812
|
+
const fullPath = join2(folderPath, entry.name);
|
|
26813
|
+
const relativePath = relative(basePath, fullPath);
|
|
26814
|
+
if (relativePath === "resource.json") {
|
|
26815
|
+
continue;
|
|
26816
|
+
}
|
|
26817
|
+
if (entry.isFile()) {
|
|
26818
|
+
files[relativePath] = await readFile2(fullPath);
|
|
26819
|
+
} else if (entry.isDirectory()) {
|
|
26820
|
+
const subFiles = await this.readFolderFiles(fullPath, basePath);
|
|
26821
|
+
Object.assign(files, subFiles);
|
|
26822
|
+
}
|
|
26823
|
+
}
|
|
26824
|
+
return files;
|
|
26825
|
+
}
|
|
26826
|
+
}
|
|
26827
|
+
async function loadResource(source, config) {
|
|
26828
|
+
const loader = config?.loader ?? new FolderLoader;
|
|
26829
|
+
const canLoad = await loader.canLoad(source);
|
|
26830
|
+
if (!canLoad) {
|
|
26831
|
+
throw new ResourceXError3(`Cannot load resource from: ${source}`);
|
|
26832
|
+
}
|
|
26833
|
+
return loader.load(source);
|
|
26834
|
+
}
|
|
26835
|
+
|
|
26836
|
+
// src/LocalRegistry.ts
|
|
26837
|
+
var DEFAULT_PATH = `${homedir()}/.resourcex`;
|
|
26838
|
+
|
|
26839
|
+
class LocalRegistry {
|
|
26840
|
+
basePath;
|
|
26841
|
+
typeHandler;
|
|
26842
|
+
arp;
|
|
26843
|
+
constructor(config) {
|
|
26844
|
+
this.basePath = config?.path ?? DEFAULT_PATH;
|
|
26845
|
+
this.typeHandler = TypeHandlerChain.create();
|
|
26846
|
+
this.arp = createARP();
|
|
26847
|
+
if (config?.types) {
|
|
26848
|
+
for (const type of config.types) {
|
|
26849
|
+
this.typeHandler.register(type);
|
|
26850
|
+
}
|
|
26851
|
+
}
|
|
26852
|
+
}
|
|
26853
|
+
supportType(type) {
|
|
26854
|
+
this.typeHandler.register(type);
|
|
26855
|
+
}
|
|
26856
|
+
toArpUrl(filePath) {
|
|
26857
|
+
return `arp:binary:file://${filePath}`;
|
|
26858
|
+
}
|
|
26859
|
+
buildPath(locator, area) {
|
|
26860
|
+
const rxl = typeof locator === "string" ? parseRXL(locator) : locator;
|
|
26861
|
+
const resourceName = rxl.type ? `${rxl.name}.${rxl.type}` : rxl.name;
|
|
26862
|
+
const version = rxl.version ?? "latest";
|
|
26863
|
+
if (area === "local") {
|
|
26864
|
+
return join3(this.basePath, "local", resourceName, version);
|
|
26865
|
+
} else {
|
|
26866
|
+
const domain = rxl.domain ?? "localhost";
|
|
26867
|
+
let path = join3(this.basePath, "cache", domain);
|
|
26868
|
+
if (rxl.path) {
|
|
26869
|
+
path = join3(path, rxl.path);
|
|
26870
|
+
}
|
|
26871
|
+
return join3(path, resourceName, version);
|
|
26872
|
+
}
|
|
26873
|
+
}
|
|
26874
|
+
isLocalOnlyLocator(locator) {
|
|
26875
|
+
const rxl = typeof locator === "string" ? parseRXL(locator) : locator;
|
|
26876
|
+
return !rxl.domain || rxl.domain === "localhost";
|
|
26877
|
+
}
|
|
26878
|
+
async existsAt(resourcePath) {
|
|
26879
|
+
const manifestPath = join3(resourcePath, "manifest.json");
|
|
26880
|
+
const arl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
26881
|
+
return arl.exists();
|
|
26882
|
+
}
|
|
26883
|
+
async findArea(locator) {
|
|
26884
|
+
const localPath = this.buildPath(locator, "local");
|
|
26885
|
+
if (await this.existsAt(localPath)) {
|
|
26886
|
+
return "local";
|
|
26887
|
+
}
|
|
26888
|
+
const cachePath = this.buildPath(locator, "cache");
|
|
26889
|
+
if (await this.existsAt(cachePath)) {
|
|
26890
|
+
return "cache";
|
|
26891
|
+
}
|
|
26892
|
+
return null;
|
|
26893
|
+
}
|
|
26894
|
+
async isSymlink(path) {
|
|
26895
|
+
try {
|
|
26896
|
+
const stats = await lstat(path);
|
|
26897
|
+
return stats.isSymbolicLink();
|
|
26898
|
+
} catch {
|
|
26899
|
+
return false;
|
|
26900
|
+
}
|
|
26901
|
+
}
|
|
26902
|
+
async loadFrom(resourcePath) {
|
|
26903
|
+
if (await this.isSymlink(resourcePath)) {
|
|
26904
|
+
const targetPath = await readlink(resourcePath);
|
|
26905
|
+
return loadResource(targetPath);
|
|
26906
|
+
}
|
|
26907
|
+
const manifestPath = join3(resourcePath, "manifest.json");
|
|
26908
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
26909
|
+
const manifestResource = await manifestArl.resolve();
|
|
26910
|
+
const manifestContent = manifestResource.content.toString("utf-8");
|
|
26911
|
+
const manifestData = JSON.parse(manifestContent);
|
|
26912
|
+
const manifest = createRXM(manifestData);
|
|
26913
|
+
const contentPath = join3(resourcePath, "archive.tar.gz");
|
|
26914
|
+
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
26915
|
+
const contentResource = await contentArl.resolve();
|
|
26916
|
+
const data = contentResource.content;
|
|
26917
|
+
return this.typeHandler.deserialize(data, manifest);
|
|
26918
|
+
}
|
|
26919
|
+
async link(path) {
|
|
26920
|
+
const rxr = await loadResource(path);
|
|
26921
|
+
const locator = rxr.manifest.toLocator();
|
|
26922
|
+
const resourcePath = this.buildPath(locator, "local");
|
|
26923
|
+
try {
|
|
26924
|
+
const arl = this.arp.parse(this.toArpUrl(resourcePath));
|
|
26925
|
+
if (await arl.exists()) {
|
|
26926
|
+
await arl.delete();
|
|
26927
|
+
}
|
|
26928
|
+
} catch {}
|
|
26929
|
+
const parentPath = join3(resourcePath, "..");
|
|
26930
|
+
const parentArl = this.arp.parse(this.toArpUrl(parentPath));
|
|
26931
|
+
await parentArl.mkdir();
|
|
26932
|
+
const absolutePath = resolvePath(path);
|
|
26933
|
+
await symlink(absolutePath, resourcePath);
|
|
26934
|
+
}
|
|
26935
|
+
async add(source) {
|
|
26936
|
+
const resource = typeof source === "string" ? await loadResource(source) : source;
|
|
26937
|
+
const locator = resource.manifest.toLocator();
|
|
26938
|
+
const resourcePath = this.buildPath(locator, "local");
|
|
26939
|
+
if (await this.isSymlink(resourcePath)) {
|
|
26940
|
+
const arl = this.arp.parse(this.toArpUrl(resourcePath));
|
|
26941
|
+
await arl.delete();
|
|
26942
|
+
}
|
|
26943
|
+
const dirArl = this.arp.parse(this.toArpUrl(resourcePath));
|
|
26944
|
+
await dirArl.mkdir();
|
|
26945
|
+
const manifestPath = join3(resourcePath, "manifest.json");
|
|
26946
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
26947
|
+
const manifestContent = Buffer.from(JSON.stringify(resource.manifest.toJSON(), null, 2), "utf-8");
|
|
26948
|
+
await manifestArl.deposit(manifestContent);
|
|
26949
|
+
const contentPath = join3(resourcePath, "archive.tar.gz");
|
|
26950
|
+
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
26951
|
+
const serialized = await this.typeHandler.serialize(resource);
|
|
26952
|
+
await contentArl.deposit(serialized);
|
|
26953
|
+
}
|
|
26954
|
+
async pull(_locator, _options) {
|
|
26955
|
+
throw new RegistryError("Pull not implemented yet - see issue #018");
|
|
26956
|
+
}
|
|
26957
|
+
async publish(_source, _options) {
|
|
26958
|
+
throw new RegistryError("Publish not implemented yet - see issue #018");
|
|
26959
|
+
}
|
|
26960
|
+
async get(locator) {
|
|
26961
|
+
const area = await this.findArea(locator);
|
|
26962
|
+
if (!area) {
|
|
26963
|
+
throw new RegistryError(`Resource not found: ${locator}`);
|
|
26964
|
+
}
|
|
26965
|
+
const resourcePath = this.buildPath(locator, area);
|
|
26966
|
+
return this.loadFrom(resourcePath);
|
|
26967
|
+
}
|
|
26968
|
+
async resolve(locator) {
|
|
26969
|
+
const rxr = await this.get(locator);
|
|
26970
|
+
return this.typeHandler.resolve(rxr);
|
|
26971
|
+
}
|
|
26972
|
+
async exists(locator) {
|
|
26973
|
+
const area = await this.findArea(locator);
|
|
26974
|
+
return area !== null;
|
|
26975
|
+
}
|
|
26976
|
+
async delete(locator) {
|
|
26977
|
+
const isLocal = this.isLocalOnlyLocator(locator);
|
|
26978
|
+
if (isLocal) {
|
|
26979
|
+
const localPath = this.buildPath(locator, "local");
|
|
26980
|
+
if (await this.existsAt(localPath)) {
|
|
26981
|
+
const arl = this.arp.parse(this.toArpUrl(localPath));
|
|
26982
|
+
await arl.delete();
|
|
26983
|
+
}
|
|
26984
|
+
} else {
|
|
26985
|
+
const cachePath = this.buildPath(locator, "cache");
|
|
26986
|
+
if (await this.existsAt(cachePath)) {
|
|
26987
|
+
const arl = this.arp.parse(this.toArpUrl(cachePath));
|
|
26988
|
+
await arl.delete();
|
|
26989
|
+
}
|
|
26990
|
+
}
|
|
26991
|
+
}
|
|
26992
|
+
async search(options) {
|
|
26993
|
+
const { query, limit, offset = 0 } = options ?? {};
|
|
26994
|
+
const locators = [];
|
|
26995
|
+
const localDir = join3(this.basePath, "local");
|
|
26996
|
+
try {
|
|
26997
|
+
const localArl = this.arp.parse(this.toArpUrl(localDir));
|
|
26998
|
+
const localEntries = await localArl.list({ recursive: true, pattern: "*.json" });
|
|
26999
|
+
for (const entry of localEntries) {
|
|
27000
|
+
if (!entry.endsWith("manifest.json"))
|
|
27001
|
+
continue;
|
|
27002
|
+
const rxl = this.parseLocalEntry(entry);
|
|
27003
|
+
if (rxl)
|
|
27004
|
+
locators.push(rxl);
|
|
27005
|
+
}
|
|
27006
|
+
} catch {}
|
|
27007
|
+
const cacheDir = join3(this.basePath, "cache");
|
|
27008
|
+
try {
|
|
27009
|
+
const cacheArl = this.arp.parse(this.toArpUrl(cacheDir));
|
|
27010
|
+
const cacheEntries = await cacheArl.list({ recursive: true, pattern: "*.json" });
|
|
27011
|
+
for (const entry of cacheEntries) {
|
|
27012
|
+
if (!entry.endsWith("manifest.json"))
|
|
27013
|
+
continue;
|
|
27014
|
+
const rxl = this.parseCacheEntry(entry);
|
|
27015
|
+
if (rxl)
|
|
27016
|
+
locators.push(rxl);
|
|
25584
27017
|
}
|
|
25585
27018
|
} catch {}
|
|
25586
27019
|
let filtered = locators;
|
|
@@ -25657,6 +27090,12 @@ class LocalRegistry {
|
|
|
25657
27090
|
}
|
|
25658
27091
|
// src/RemoteRegistry.ts
|
|
25659
27092
|
class RemoteRegistry {
|
|
27093
|
+
static canHandle(url) {
|
|
27094
|
+
return url.startsWith("https://") || url.startsWith("http://");
|
|
27095
|
+
}
|
|
27096
|
+
static create(config) {
|
|
27097
|
+
return new RemoteRegistry({ endpoint: config.url });
|
|
27098
|
+
}
|
|
25660
27099
|
endpoint;
|
|
25661
27100
|
typeHandler;
|
|
25662
27101
|
constructor(config) {
|
|
@@ -25666,15 +27105,18 @@ class RemoteRegistry {
|
|
|
25666
27105
|
supportType(type) {
|
|
25667
27106
|
this.typeHandler.register(type);
|
|
25668
27107
|
}
|
|
27108
|
+
async link(_path) {
|
|
27109
|
+
throw new RegistryError("Cannot link to remote registry - use local registry for linking");
|
|
27110
|
+
}
|
|
27111
|
+
async add(_source) {
|
|
27112
|
+
throw new RegistryError("Cannot add to remote registry - use local registry for adding");
|
|
27113
|
+
}
|
|
25669
27114
|
async pull(_locator, _options) {
|
|
25670
27115
|
throw new RegistryError("Cannot pull to remote registry - use local registry for pulling");
|
|
25671
27116
|
}
|
|
25672
|
-
async publish(
|
|
27117
|
+
async publish(_source, _options) {
|
|
25673
27118
|
throw new RegistryError("Remote registry publish not implemented yet");
|
|
25674
27119
|
}
|
|
25675
|
-
async link(_resource) {
|
|
25676
|
-
throw new RegistryError("Cannot link to remote registry - use local registry for linking");
|
|
25677
|
-
}
|
|
25678
27120
|
async get(locator) {
|
|
25679
27121
|
const manifestUrl = `${this.endpoint}/resource?locator=${encodeURIComponent(locator)}`;
|
|
25680
27122
|
const manifestResponse = await fetch(manifestUrl);
|
|
@@ -25749,10 +27191,24 @@ async function discoverRegistry(domain) {
|
|
|
25749
27191
|
throw new RegistryError(`Failed to discover registry for ${domain}: ${error.message}`);
|
|
25750
27192
|
}
|
|
25751
27193
|
}
|
|
27194
|
+
// src/types.ts
|
|
27195
|
+
function isUrlConfig(config) {
|
|
27196
|
+
return config !== undefined && "url" in config && !("type" in config) && !("endpoint" in config);
|
|
27197
|
+
}
|
|
27198
|
+
function isRemoteConfig(config) {
|
|
27199
|
+
return config !== undefined && "endpoint" in config;
|
|
27200
|
+
}
|
|
27201
|
+
function isGitConfig(config) {
|
|
27202
|
+
return config !== undefined && "type" in config && config.type === "git";
|
|
27203
|
+
}
|
|
27204
|
+
function isGitHubConfig(config) {
|
|
27205
|
+
return config !== undefined && "type" in config && config.type === "github";
|
|
27206
|
+
}
|
|
27207
|
+
|
|
25752
27208
|
// src/GitRegistry.ts
|
|
25753
27209
|
var import_isomorphic_git = __toESM(require_isomorphic_git(), 1);
|
|
25754
27210
|
import { homedir as homedir2 } from "node:os";
|
|
25755
|
-
import { join as
|
|
27211
|
+
import { join as join4 } from "node:path";
|
|
25756
27212
|
import fs from "node:fs";
|
|
25757
27213
|
|
|
25758
27214
|
// ../../node_modules/.bun/isomorphic-git@1.36.1/node_modules/isomorphic-git/http/node/index.js
|
|
@@ -25912,6 +27368,71 @@ async function request({
|
|
|
25912
27368
|
var index = { request };
|
|
25913
27369
|
var node_default = index;
|
|
25914
27370
|
|
|
27371
|
+
// src/middleware/RegistryMiddleware.ts
|
|
27372
|
+
class RegistryMiddleware {
|
|
27373
|
+
inner;
|
|
27374
|
+
constructor(inner) {
|
|
27375
|
+
this.inner = inner;
|
|
27376
|
+
}
|
|
27377
|
+
supportType(type) {
|
|
27378
|
+
this.inner.supportType(type);
|
|
27379
|
+
}
|
|
27380
|
+
link(path) {
|
|
27381
|
+
return this.inner.link(path);
|
|
27382
|
+
}
|
|
27383
|
+
add(source) {
|
|
27384
|
+
return this.inner.add(source);
|
|
27385
|
+
}
|
|
27386
|
+
pull(locator, options) {
|
|
27387
|
+
return this.inner.pull(locator, options);
|
|
27388
|
+
}
|
|
27389
|
+
publish(source, options) {
|
|
27390
|
+
return this.inner.publish(source, options);
|
|
27391
|
+
}
|
|
27392
|
+
get(locator) {
|
|
27393
|
+
return this.inner.get(locator);
|
|
27394
|
+
}
|
|
27395
|
+
resolve(locator) {
|
|
27396
|
+
return this.inner.resolve(locator);
|
|
27397
|
+
}
|
|
27398
|
+
exists(locator) {
|
|
27399
|
+
return this.inner.exists(locator);
|
|
27400
|
+
}
|
|
27401
|
+
delete(locator) {
|
|
27402
|
+
return this.inner.delete(locator);
|
|
27403
|
+
}
|
|
27404
|
+
search(options) {
|
|
27405
|
+
return this.inner.search(options);
|
|
27406
|
+
}
|
|
27407
|
+
}
|
|
27408
|
+
|
|
27409
|
+
// src/middleware/DomainValidation.ts
|
|
27410
|
+
class DomainValidation extends RegistryMiddleware {
|
|
27411
|
+
trustedDomain;
|
|
27412
|
+
constructor(inner, trustedDomain) {
|
|
27413
|
+
super(inner);
|
|
27414
|
+
this.trustedDomain = trustedDomain;
|
|
27415
|
+
}
|
|
27416
|
+
validateDomain(rxr) {
|
|
27417
|
+
if (rxr.manifest.domain !== this.trustedDomain) {
|
|
27418
|
+
throw new RegistryError(`Untrusted domain: resource claims "${rxr.manifest.domain}" but registry only trusts "${this.trustedDomain}"`);
|
|
27419
|
+
}
|
|
27420
|
+
}
|
|
27421
|
+
async get(locator) {
|
|
27422
|
+
const rxr = await this.inner.get(locator);
|
|
27423
|
+
this.validateDomain(rxr);
|
|
27424
|
+
return rxr;
|
|
27425
|
+
}
|
|
27426
|
+
async resolve(locator) {
|
|
27427
|
+
const rxr = await this.inner.get(locator);
|
|
27428
|
+
this.validateDomain(rxr);
|
|
27429
|
+
return this.inner.resolve(locator);
|
|
27430
|
+
}
|
|
27431
|
+
}
|
|
27432
|
+
function withDomainValidation(registry, trustedDomain) {
|
|
27433
|
+
return new DomainValidation(registry, trustedDomain);
|
|
27434
|
+
}
|
|
27435
|
+
|
|
25915
27436
|
// src/GitRegistry.ts
|
|
25916
27437
|
var DEFAULT_GIT_CACHE = `${homedir2()}/.resourcex/.git-cache`;
|
|
25917
27438
|
var MAX_RETRIES = 2;
|
|
@@ -25920,6 +27441,19 @@ function isLocalPath(url) {
|
|
|
25920
27441
|
}
|
|
25921
27442
|
|
|
25922
27443
|
class GitRegistry {
|
|
27444
|
+
static canHandle(url) {
|
|
27445
|
+
return url.startsWith("git@") || url.endsWith(".git");
|
|
27446
|
+
}
|
|
27447
|
+
static create(config) {
|
|
27448
|
+
const registry = new GitRegistry({
|
|
27449
|
+
type: "git",
|
|
27450
|
+
url: config.url,
|
|
27451
|
+
ref: config.ref,
|
|
27452
|
+
basePath: config.basePath,
|
|
27453
|
+
domain: config.domain
|
|
27454
|
+
});
|
|
27455
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
27456
|
+
}
|
|
25923
27457
|
url;
|
|
25924
27458
|
ref;
|
|
25925
27459
|
basePath;
|
|
@@ -25945,7 +27479,7 @@ class GitRegistry {
|
|
|
25945
27479
|
normalized = normalized.slice(0, -4);
|
|
25946
27480
|
}
|
|
25947
27481
|
const dirName = normalized.replace(/\//g, "-");
|
|
25948
|
-
return
|
|
27482
|
+
return join4(DEFAULT_GIT_CACHE, dirName);
|
|
25949
27483
|
}
|
|
25950
27484
|
supportType(type) {
|
|
25951
27485
|
this.typeHandler.register(type);
|
|
@@ -25954,7 +27488,7 @@ class GitRegistry {
|
|
|
25954
27488
|
return `arp:binary:file://${filePath}`;
|
|
25955
27489
|
}
|
|
25956
27490
|
async ensureCloned() {
|
|
25957
|
-
const gitDir =
|
|
27491
|
+
const gitDir = join4(this.cacheDir, ".git");
|
|
25958
27492
|
const gitArl = this.arp.parse(this.toArpUrl(gitDir));
|
|
25959
27493
|
if (this.isLocal) {
|
|
25960
27494
|
if (!await gitArl.exists()) {
|
|
@@ -26033,17 +27567,17 @@ class GitRegistry {
|
|
|
26033
27567
|
const rxl = parseRXL(locator);
|
|
26034
27568
|
const domain = rxl.domain ?? "localhost";
|
|
26035
27569
|
const version = rxl.version ?? "latest";
|
|
26036
|
-
let path =
|
|
27570
|
+
let path = join4(this.cacheDir, this.basePath, domain);
|
|
26037
27571
|
if (rxl.path) {
|
|
26038
|
-
path =
|
|
27572
|
+
path = join4(path, rxl.path);
|
|
26039
27573
|
}
|
|
26040
27574
|
const resourceName = rxl.type ? `${rxl.name}.${rxl.type}` : rxl.name;
|
|
26041
|
-
return
|
|
27575
|
+
return join4(path, resourceName, version);
|
|
26042
27576
|
}
|
|
26043
27577
|
async get(locator) {
|
|
26044
27578
|
await this.ensureCloned();
|
|
26045
27579
|
const resourcePath = this.buildResourcePath(locator);
|
|
26046
|
-
const manifestPath =
|
|
27580
|
+
const manifestPath = join4(resourcePath, "manifest.json");
|
|
26047
27581
|
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
26048
27582
|
if (!await manifestArl.exists()) {
|
|
26049
27583
|
throw new RegistryError(`Resource not found: ${locator}`);
|
|
@@ -26052,7 +27586,7 @@ class GitRegistry {
|
|
|
26052
27586
|
const manifestContent = manifestResource.content.toString("utf-8");
|
|
26053
27587
|
const manifestData = JSON.parse(manifestContent);
|
|
26054
27588
|
const manifest = createRXM(manifestData);
|
|
26055
|
-
const contentPath =
|
|
27589
|
+
const contentPath = join4(resourcePath, "archive.tar.gz");
|
|
26056
27590
|
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
26057
27591
|
const contentResource = await contentArl.resolve();
|
|
26058
27592
|
const data = contentResource.content;
|
|
@@ -26066,7 +27600,7 @@ class GitRegistry {
|
|
|
26066
27600
|
try {
|
|
26067
27601
|
await this.ensureCloned();
|
|
26068
27602
|
const resourcePath = this.buildResourcePath(locator);
|
|
26069
|
-
const manifestPath =
|
|
27603
|
+
const manifestPath = join4(resourcePath, "manifest.json");
|
|
26070
27604
|
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
26071
27605
|
return await manifestArl.exists();
|
|
26072
27606
|
} catch {
|
|
@@ -26077,7 +27611,7 @@ class GitRegistry {
|
|
|
26077
27611
|
await this.ensureCloned();
|
|
26078
27612
|
const { query, limit, offset = 0 } = options ?? {};
|
|
26079
27613
|
const locators = [];
|
|
26080
|
-
const baseDir =
|
|
27614
|
+
const baseDir = join4(this.cacheDir, this.basePath);
|
|
26081
27615
|
try {
|
|
26082
27616
|
const baseArl = this.arp.parse(this.toArpUrl(baseDir));
|
|
26083
27617
|
const entries = await baseArl.list({ recursive: true, pattern: "*.json" });
|
|
@@ -26137,119 +27671,349 @@ class GitRegistry {
|
|
|
26137
27671
|
return null;
|
|
26138
27672
|
}
|
|
26139
27673
|
}
|
|
27674
|
+
async link(_path) {
|
|
27675
|
+
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.link()");
|
|
27676
|
+
}
|
|
27677
|
+
async add(_source) {
|
|
27678
|
+
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.add()");
|
|
27679
|
+
}
|
|
26140
27680
|
async pull(_locator, _options) {
|
|
26141
27681
|
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.pull()");
|
|
26142
27682
|
}
|
|
26143
|
-
async publish(
|
|
27683
|
+
async publish(_source, _options) {
|
|
26144
27684
|
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.publish()");
|
|
26145
27685
|
}
|
|
26146
|
-
async link(_resource) {
|
|
26147
|
-
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.link()");
|
|
26148
|
-
}
|
|
26149
27686
|
async delete(_locator) {
|
|
26150
27687
|
throw new RegistryError("GitRegistry is read-only - use LocalRegistry.delete()");
|
|
26151
27688
|
}
|
|
26152
27689
|
}
|
|
26153
|
-
|
|
26154
|
-
|
|
26155
|
-
|
|
26156
|
-
|
|
26157
|
-
|
|
27690
|
+
|
|
27691
|
+
// src/GitHubRegistry.ts
|
|
27692
|
+
import { homedir as homedir3 } from "node:os";
|
|
27693
|
+
import { join as join5 } from "node:path";
|
|
27694
|
+
import { gunzipSync } from "node:zlib";
|
|
27695
|
+
var DEFAULT_GITHUB_CACHE = `${homedir3()}/.resourcex/.github-cache`;
|
|
27696
|
+
function parseGitHubUrl(url) {
|
|
27697
|
+
if (!url.startsWith("https://github.com/")) {
|
|
27698
|
+
throw new RegistryError(`Invalid GitHub URL: ${url}. Expected format: https://github.com/owner/repo`);
|
|
27699
|
+
}
|
|
27700
|
+
const path = url.slice("https://github.com/".length);
|
|
27701
|
+
const parts = path.split("/");
|
|
27702
|
+
if (parts.length < 2) {
|
|
27703
|
+
throw new RegistryError(`Invalid GitHub URL: ${url}. Expected format: https://github.com/owner/repo`);
|
|
27704
|
+
}
|
|
27705
|
+
const owner = parts[0];
|
|
27706
|
+
const repo = parts[1];
|
|
27707
|
+
let branch = "main";
|
|
27708
|
+
if (parts.length >= 4 && parts[2] === "tree") {
|
|
27709
|
+
branch = parts[3];
|
|
27710
|
+
}
|
|
27711
|
+
return { owner, repo, branch };
|
|
27712
|
+
}
|
|
27713
|
+
function isGitHubUrl(url) {
|
|
27714
|
+
return url.startsWith("https://github.com/");
|
|
27715
|
+
}
|
|
27716
|
+
|
|
27717
|
+
class GitHubRegistry {
|
|
27718
|
+
static canHandle(url) {
|
|
27719
|
+
return isGitHubUrl(url);
|
|
27720
|
+
}
|
|
27721
|
+
static create(config) {
|
|
27722
|
+
const registry = new GitHubRegistry({
|
|
27723
|
+
url: config.url,
|
|
27724
|
+
ref: config.ref,
|
|
27725
|
+
basePath: config.basePath
|
|
27726
|
+
});
|
|
27727
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
27728
|
+
}
|
|
27729
|
+
url;
|
|
27730
|
+
owner;
|
|
27731
|
+
repo;
|
|
27732
|
+
ref;
|
|
27733
|
+
basePath;
|
|
27734
|
+
cacheDir;
|
|
27735
|
+
typeHandler;
|
|
27736
|
+
arp;
|
|
27737
|
+
tarballDownloaded = false;
|
|
27738
|
+
constructor(config) {
|
|
27739
|
+
this.url = config.url;
|
|
27740
|
+
const parsed = parseGitHubUrl(config.url);
|
|
27741
|
+
this.owner = parsed.owner;
|
|
27742
|
+
this.repo = parsed.repo;
|
|
27743
|
+
this.ref = config.ref ?? parsed.branch;
|
|
27744
|
+
this.basePath = config.basePath ?? ".resourcex";
|
|
27745
|
+
this.typeHandler = TypeHandlerChain.create();
|
|
27746
|
+
this.arp = createARP();
|
|
27747
|
+
this.cacheDir = this.buildCacheDir();
|
|
27748
|
+
}
|
|
27749
|
+
buildCacheDir() {
|
|
27750
|
+
const dirName = `github.com-${this.owner}-${this.repo}`;
|
|
27751
|
+
return join5(DEFAULT_GITHUB_CACHE, dirName);
|
|
26158
27752
|
}
|
|
26159
27753
|
supportType(type) {
|
|
26160
|
-
this.
|
|
27754
|
+
this.typeHandler.register(type);
|
|
26161
27755
|
}
|
|
26162
|
-
|
|
26163
|
-
return
|
|
27756
|
+
toArpUrl(filePath) {
|
|
27757
|
+
return `arp:binary:file://${filePath}`;
|
|
26164
27758
|
}
|
|
26165
|
-
|
|
26166
|
-
return this.
|
|
27759
|
+
getTarballUrl() {
|
|
27760
|
+
return `https://github.com/${this.owner}/${this.repo}/archive/refs/heads/${this.ref}.tar.gz`;
|
|
26167
27761
|
}
|
|
26168
|
-
|
|
26169
|
-
|
|
27762
|
+
async ensureDownloaded() {
|
|
27763
|
+
if (this.tarballDownloaded) {
|
|
27764
|
+
return;
|
|
27765
|
+
}
|
|
27766
|
+
const tarballUrl = this.getTarballUrl();
|
|
27767
|
+
const response = await fetch(tarballUrl, {
|
|
27768
|
+
headers: {
|
|
27769
|
+
"User-Agent": "ResourceX/1.0"
|
|
27770
|
+
}
|
|
27771
|
+
});
|
|
27772
|
+
if (!response.ok) {
|
|
27773
|
+
throw new RegistryError(`Failed to download tarball from ${tarballUrl}: ${response.status} ${response.statusText}`);
|
|
27774
|
+
}
|
|
27775
|
+
const tarballBuffer = Buffer.from(await response.arrayBuffer());
|
|
27776
|
+
await this.extractTarball(tarballBuffer);
|
|
27777
|
+
this.tarballDownloaded = true;
|
|
27778
|
+
}
|
|
27779
|
+
async extractTarball(tarballBuffer) {
|
|
27780
|
+
const tarBuffer = gunzipSync(tarballBuffer);
|
|
27781
|
+
const files = this.parseTar(tarBuffer);
|
|
27782
|
+
const cacheArl = this.arp.parse(this.toArpUrl(this.cacheDir));
|
|
27783
|
+
await cacheArl.mkdir();
|
|
27784
|
+
for (const [path, content] of files) {
|
|
27785
|
+
const parts = path.split("/");
|
|
27786
|
+
if (parts.length < 2)
|
|
27787
|
+
continue;
|
|
27788
|
+
const relativePath = parts.slice(1).join("/");
|
|
27789
|
+
if (!relativePath)
|
|
27790
|
+
continue;
|
|
27791
|
+
const fullPath = join5(this.cacheDir, relativePath);
|
|
27792
|
+
const parentDir = fullPath.substring(0, fullPath.lastIndexOf("/"));
|
|
27793
|
+
if (parentDir) {
|
|
27794
|
+
const parentArl = this.arp.parse(this.toArpUrl(parentDir));
|
|
27795
|
+
await parentArl.mkdir();
|
|
27796
|
+
}
|
|
27797
|
+
const fileArl = this.arp.parse(this.toArpUrl(fullPath));
|
|
27798
|
+
await fileArl.deposit(content);
|
|
27799
|
+
}
|
|
26170
27800
|
}
|
|
26171
|
-
|
|
26172
|
-
|
|
27801
|
+
parseTar(tarBuffer) {
|
|
27802
|
+
const files = new Map;
|
|
27803
|
+
let offset = 0;
|
|
27804
|
+
while (offset < tarBuffer.length) {
|
|
27805
|
+
const header = tarBuffer.subarray(offset, offset + 512);
|
|
27806
|
+
if (header[0] === 0) {
|
|
27807
|
+
break;
|
|
27808
|
+
}
|
|
27809
|
+
let filename = "";
|
|
27810
|
+
for (let i = 0;i < 100 && header[i] !== 0; i++) {
|
|
27811
|
+
filename += String.fromCharCode(header[i]);
|
|
27812
|
+
}
|
|
27813
|
+
let prefix = "";
|
|
27814
|
+
for (let i = 345;i < 500 && header[i] !== 0; i++) {
|
|
27815
|
+
prefix += String.fromCharCode(header[i]);
|
|
27816
|
+
}
|
|
27817
|
+
if (prefix) {
|
|
27818
|
+
filename = prefix + "/" + filename;
|
|
27819
|
+
}
|
|
27820
|
+
let sizeStr = "";
|
|
27821
|
+
for (let i = 124;i < 136 && header[i] !== 0 && header[i] !== 32; i++) {
|
|
27822
|
+
sizeStr += String.fromCharCode(header[i]);
|
|
27823
|
+
}
|
|
27824
|
+
const size = parseInt(sizeStr, 8) || 0;
|
|
27825
|
+
const typeFlag = header[156];
|
|
27826
|
+
offset += 512;
|
|
27827
|
+
if (typeFlag === 48 || typeFlag === 0) {
|
|
27828
|
+
if (size > 0) {
|
|
27829
|
+
const content = tarBuffer.subarray(offset, offset + size);
|
|
27830
|
+
files.set(filename, Buffer.from(content));
|
|
27831
|
+
}
|
|
27832
|
+
}
|
|
27833
|
+
offset += Math.ceil(size / 512) * 512;
|
|
27834
|
+
}
|
|
27835
|
+
return files;
|
|
26173
27836
|
}
|
|
26174
|
-
|
|
26175
|
-
|
|
27837
|
+
buildResourcePath(locator) {
|
|
27838
|
+
const rxl = parseRXL(locator);
|
|
27839
|
+
const domain = rxl.domain ?? "localhost";
|
|
27840
|
+
const version = rxl.version ?? "latest";
|
|
27841
|
+
let path = join5(this.cacheDir, this.basePath, domain);
|
|
27842
|
+
if (rxl.path) {
|
|
27843
|
+
path = join5(path, rxl.path);
|
|
27844
|
+
}
|
|
27845
|
+
const resourceName = rxl.type ? `${rxl.name}.${rxl.type}` : rxl.name;
|
|
27846
|
+
return join5(path, resourceName, version);
|
|
26176
27847
|
}
|
|
26177
|
-
|
|
26178
|
-
|
|
27848
|
+
async get(locator) {
|
|
27849
|
+
await this.ensureDownloaded();
|
|
27850
|
+
const resourcePath = this.buildResourcePath(locator);
|
|
27851
|
+
const manifestPath = join5(resourcePath, "manifest.json");
|
|
27852
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
27853
|
+
if (!await manifestArl.exists()) {
|
|
27854
|
+
throw new RegistryError(`Resource not found: ${locator}`);
|
|
27855
|
+
}
|
|
27856
|
+
const manifestResource = await manifestArl.resolve();
|
|
27857
|
+
const manifestContent = manifestResource.content.toString("utf-8");
|
|
27858
|
+
const manifestData = JSON.parse(manifestContent);
|
|
27859
|
+
const manifest = createRXM(manifestData);
|
|
27860
|
+
const contentPath = join5(resourcePath, "archive.tar.gz");
|
|
27861
|
+
const contentArl = this.arp.parse(this.toArpUrl(contentPath));
|
|
27862
|
+
const contentResource = await contentArl.resolve();
|
|
27863
|
+
const data = contentResource.content;
|
|
27864
|
+
return this.typeHandler.deserialize(data, manifest);
|
|
26179
27865
|
}
|
|
26180
|
-
|
|
26181
|
-
|
|
27866
|
+
async resolve(locator) {
|
|
27867
|
+
const rxr = await this.get(locator);
|
|
27868
|
+
return this.typeHandler.resolve(rxr);
|
|
26182
27869
|
}
|
|
26183
|
-
|
|
26184
|
-
|
|
27870
|
+
async exists(locator) {
|
|
27871
|
+
try {
|
|
27872
|
+
await this.ensureDownloaded();
|
|
27873
|
+
const resourcePath = this.buildResourcePath(locator);
|
|
27874
|
+
const manifestPath = join5(resourcePath, "manifest.json");
|
|
27875
|
+
const manifestArl = this.arp.parse(this.toArpUrl(manifestPath));
|
|
27876
|
+
return await manifestArl.exists();
|
|
27877
|
+
} catch {
|
|
27878
|
+
return false;
|
|
27879
|
+
}
|
|
26185
27880
|
}
|
|
26186
|
-
|
|
26187
|
-
|
|
26188
|
-
|
|
26189
|
-
|
|
26190
|
-
|
|
26191
|
-
|
|
26192
|
-
|
|
26193
|
-
|
|
27881
|
+
async search(options) {
|
|
27882
|
+
await this.ensureDownloaded();
|
|
27883
|
+
const { query, limit, offset = 0 } = options ?? {};
|
|
27884
|
+
const locators = [];
|
|
27885
|
+
const baseDir = join5(this.cacheDir, this.basePath);
|
|
27886
|
+
try {
|
|
27887
|
+
const baseArl = this.arp.parse(this.toArpUrl(baseDir));
|
|
27888
|
+
const entries = await baseArl.list({ recursive: true, pattern: "*.json" });
|
|
27889
|
+
for (const entry of entries) {
|
|
27890
|
+
if (!entry.endsWith("manifest.json"))
|
|
27891
|
+
continue;
|
|
27892
|
+
const rxl = this.parseEntryToRXL(entry);
|
|
27893
|
+
if (rxl)
|
|
27894
|
+
locators.push(rxl);
|
|
27895
|
+
}
|
|
27896
|
+
} catch {
|
|
27897
|
+
return [];
|
|
27898
|
+
}
|
|
27899
|
+
let filtered = locators;
|
|
27900
|
+
if (query) {
|
|
27901
|
+
const lowerQuery = query.toLowerCase();
|
|
27902
|
+
filtered = locators.filter((rxl) => {
|
|
27903
|
+
const searchText = `${rxl.domain ?? ""} ${rxl.path ?? ""} ${rxl.name} ${rxl.type ?? ""}`.toLowerCase();
|
|
27904
|
+
return searchText.includes(lowerQuery);
|
|
27905
|
+
});
|
|
27906
|
+
}
|
|
27907
|
+
let result = filtered.slice(offset);
|
|
27908
|
+
if (limit !== undefined) {
|
|
27909
|
+
result = result.slice(0, limit);
|
|
27910
|
+
}
|
|
27911
|
+
return result;
|
|
26194
27912
|
}
|
|
26195
|
-
|
|
26196
|
-
|
|
26197
|
-
|
|
27913
|
+
parseEntryToRXL(entry) {
|
|
27914
|
+
const dirPath = entry.replace(/[/\\]manifest\.json$/, "");
|
|
27915
|
+
const parts = dirPath.split(/[/\\]/);
|
|
27916
|
+
if (parts.length < 3)
|
|
27917
|
+
return null;
|
|
27918
|
+
const version = parts.pop();
|
|
27919
|
+
const nameTypePart = parts.pop();
|
|
27920
|
+
const domain = parts.shift();
|
|
27921
|
+
const path = parts.length > 0 ? parts.join("/") : undefined;
|
|
27922
|
+
const dotIndex = nameTypePart.lastIndexOf(".");
|
|
27923
|
+
let name;
|
|
27924
|
+
let type;
|
|
27925
|
+
if (dotIndex !== -1) {
|
|
27926
|
+
name = nameTypePart.substring(0, dotIndex);
|
|
27927
|
+
type = nameTypePart.substring(dotIndex + 1);
|
|
27928
|
+
} else {
|
|
27929
|
+
name = nameTypePart;
|
|
27930
|
+
type = undefined;
|
|
27931
|
+
}
|
|
27932
|
+
let locatorStr = domain;
|
|
27933
|
+
if (path)
|
|
27934
|
+
locatorStr += `/${path}`;
|
|
27935
|
+
locatorStr += `/${name}`;
|
|
27936
|
+
if (type)
|
|
27937
|
+
locatorStr += `.${type}`;
|
|
27938
|
+
locatorStr += `@${version}`;
|
|
27939
|
+
try {
|
|
27940
|
+
return parseRXL(locatorStr);
|
|
27941
|
+
} catch {
|
|
27942
|
+
return null;
|
|
26198
27943
|
}
|
|
26199
27944
|
}
|
|
26200
|
-
async
|
|
26201
|
-
|
|
26202
|
-
this.validateDomain(rxr);
|
|
26203
|
-
return rxr;
|
|
27945
|
+
async link(_path) {
|
|
27946
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.link()");
|
|
26204
27947
|
}
|
|
26205
|
-
async
|
|
26206
|
-
|
|
26207
|
-
|
|
26208
|
-
|
|
27948
|
+
async add(_source) {
|
|
27949
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.add()");
|
|
27950
|
+
}
|
|
27951
|
+
async pull(_locator, _options) {
|
|
27952
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.pull()");
|
|
27953
|
+
}
|
|
27954
|
+
async publish(_source, _options) {
|
|
27955
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.publish()");
|
|
27956
|
+
}
|
|
27957
|
+
async delete(_locator) {
|
|
27958
|
+
throw new RegistryError("GitHubRegistry is read-only - use LocalRegistry.delete()");
|
|
26209
27959
|
}
|
|
26210
|
-
}
|
|
26211
|
-
function withDomainValidation(registry, trustedDomain) {
|
|
26212
|
-
return new DomainValidation(registry, trustedDomain);
|
|
26213
27960
|
}
|
|
26214
27961
|
|
|
26215
27962
|
// src/createRegistry.ts
|
|
26216
|
-
|
|
27963
|
+
var URL_HANDLERS = [
|
|
27964
|
+
GitHubRegistry,
|
|
27965
|
+
GitRegistry,
|
|
27966
|
+
RemoteRegistry
|
|
27967
|
+
];
|
|
27968
|
+
function isRemoteUrl(url) {
|
|
26217
27969
|
return url.startsWith("git@") || url.startsWith("https://") || url.startsWith("http://");
|
|
26218
27970
|
}
|
|
26219
27971
|
function createRegistry(config) {
|
|
26220
27972
|
if (isRemoteConfig(config)) {
|
|
26221
27973
|
return new RemoteRegistry(config);
|
|
26222
27974
|
}
|
|
27975
|
+
if (isGitHubConfig(config)) {
|
|
27976
|
+
const registry = new GitHubRegistry(config);
|
|
27977
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
27978
|
+
}
|
|
26223
27979
|
if (isGitConfig(config)) {
|
|
26224
|
-
if (
|
|
27980
|
+
if (isRemoteUrl(config.url) && !config.domain) {
|
|
26225
27981
|
throw new RegistryError(`Remote git registry requires a trusted domain.
|
|
26226
27982
|
|
|
26227
|
-
` + `
|
|
26228
|
-
` + `
|
|
26229
|
-
` + `2. Explicitly set domain: createRegistry({ type: "git", url: "...", domain: "your-domain.com" })
|
|
26230
|
-
|
|
26231
|
-
` + `This ensures resources from untrusted sources cannot impersonate your domain.`);
|
|
27983
|
+
` + `Use discoverRegistry() or explicitly set domain:
|
|
27984
|
+
` + `createRegistry({ type: "git", url: "...", domain: "your-domain.com" })`);
|
|
26232
27985
|
}
|
|
26233
|
-
const
|
|
26234
|
-
|
|
26235
|
-
|
|
26236
|
-
|
|
26237
|
-
return
|
|
27986
|
+
const registry = new GitRegistry(config);
|
|
27987
|
+
return config.domain ? withDomainValidation(registry, config.domain) : registry;
|
|
27988
|
+
}
|
|
27989
|
+
if (isUrlConfig(config)) {
|
|
27990
|
+
return createFromUrl(config);
|
|
26238
27991
|
}
|
|
26239
27992
|
return new LocalRegistry(config);
|
|
26240
27993
|
}
|
|
27994
|
+
function createFromUrl(config) {
|
|
27995
|
+
const { url, domain } = config;
|
|
27996
|
+
if (isRemoteUrl(url) && !domain) {
|
|
27997
|
+
throw new RegistryError(`Remote registry URL requires a trusted domain.
|
|
27998
|
+
|
|
27999
|
+
` + `Use discoverRegistry() or explicitly set domain:
|
|
28000
|
+
` + `createRegistry({ url: "...", domain: "your-domain.com" })`);
|
|
28001
|
+
}
|
|
28002
|
+
for (const Handler of URL_HANDLERS) {
|
|
28003
|
+
if (Handler.canHandle(url)) {
|
|
28004
|
+
return Handler.create(config);
|
|
28005
|
+
}
|
|
28006
|
+
}
|
|
28007
|
+
throw new RegistryError(`No handler found for URL: ${url}`);
|
|
28008
|
+
}
|
|
26241
28009
|
export {
|
|
26242
28010
|
withDomainValidation,
|
|
26243
|
-
isRemoteConfig,
|
|
26244
|
-
isGitConfig,
|
|
26245
28011
|
discoverRegistry,
|
|
26246
28012
|
createRegistry,
|
|
26247
|
-
RemoteRegistry,
|
|
26248
28013
|
RegistryMiddleware,
|
|
26249
28014
|
RegistryError,
|
|
26250
28015
|
LocalRegistry,
|
|
26251
|
-
GitRegistry,
|
|
26252
28016
|
DomainValidation
|
|
26253
28017
|
};
|
|
26254
28018
|
|
|
26255
|
-
//# debugId=
|
|
28019
|
+
//# debugId=4521F4F0C842396664756E2164756E21
|