@moldea.ai/cli 13.0.4 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -9
- package/dist/chunks/{composition-DfXcSF44.js → composition-D1OYuZ5d.js} +1 -1
- package/dist/chunks/{composition-DxVb23Ru.js → composition-_3bygS_a.js} +21 -23
- package/dist/chunks/composition-_3bygS_a.js.map +1 -0
- package/dist/chunks/{core-composition-D3haS6M3.js → core-composition-BKcJ--NX.js} +2 -2
- package/dist/chunks/{core-composition-D3haS6M3.js.map → core-composition-BKcJ--NX.js.map} +1 -1
- package/dist/moldea.js +7 -12
- package/dist/moldea.js.map +1 -1
- package/dist/portable/LICENSES.md +506 -0
- package/dist/portable/SHA256SUMS +17 -0
- package/dist/portable/analysis-worker.mjs +193 -0
- package/dist/portable/chunk-131f8005.mjs +115 -0
- package/dist/portable/chunk-2ba7e89e.mjs +26 -0
- package/dist/portable/chunk-459da9cf.mjs +4138 -0
- package/dist/portable/chunk-728df961.mjs +544 -0
- package/dist/portable/chunk-8d6114d2.mjs +588 -0
- package/dist/portable/chunk-90403e67.mjs +2 -0
- package/dist/portable/chunk-94b5ac22.mjs +59 -0
- package/dist/portable/chunk-a5514957.mjs +5870 -0
- package/dist/portable/chunk-b98ca669.mjs +2 -0
- package/dist/portable/chunk-c13db66a.mjs +380 -0
- package/dist/portable/chunk-d5af3eda.mjs +2926 -0
- package/dist/portable/chunk-ec3f49d3.mjs +367 -0
- package/dist/portable/chunk-fcbcf4e3.mjs +147458 -0
- package/dist/portable/moldea.mjs +3529 -0
- package/dist/portable/node-runner.mjs +146 -0
- package/package.json +3 -3
- package/dist/chunks/composition-DxVb23Ru.js.map +0 -1
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
import { f as Exception, u as isObjectValid } from "./chunk-728df961.mjs";
|
|
2
|
+
//#region ../repository/dist/chunks/links-DPog2q0N.js
|
|
3
|
+
var SOURCE_ERROR_MESSAGES = {
|
|
4
|
+
ABORTED: "The repository operation was aborted.",
|
|
5
|
+
ACCESS_DENIED: "Access to the repository source was denied.",
|
|
6
|
+
ENTRY_NOT_DIRECTORY: "The requested repository entry is not a directory.",
|
|
7
|
+
ENTRY_NOT_FILE: "The requested repository entry is not a file.",
|
|
8
|
+
ENTRY_NOT_FOUND: "The requested repository entry was not found.",
|
|
9
|
+
ENTRY_NOT_LINK: "The requested repository entry is not a symlink.",
|
|
10
|
+
INVALID_PAGE_REQUEST: "The repository page request is invalid.",
|
|
11
|
+
INVALID_SOURCE_DATA: "The repository source returned invalid data.",
|
|
12
|
+
PROVIDER_INCOMPLETE: "The repository provider cannot expose a complete result.",
|
|
13
|
+
RESOURCE_LIMIT_EXCEEDED: "A named repository resource limit was exceeded.",
|
|
14
|
+
SNAPSHOT_CHANGED: "The repository snapshot changed during the operation.",
|
|
15
|
+
SOURCE_UNAVAILABLE: "The repository source is unavailable."
|
|
16
|
+
};
|
|
17
|
+
var RepositoryPathException = class extends Exception {
|
|
18
|
+
code;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
super("The repository path is invalid.", {
|
|
21
|
+
code: "INVALID_REPOSITORY_PATH",
|
|
22
|
+
cause: options?.cause
|
|
23
|
+
});
|
|
24
|
+
this.code = "INVALID_REPOSITORY_PATH";
|
|
25
|
+
this.name = "RepositoryPathException";
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var RepositorySourceException = class extends Exception {
|
|
29
|
+
code;
|
|
30
|
+
operation;
|
|
31
|
+
path;
|
|
32
|
+
resource;
|
|
33
|
+
retryable;
|
|
34
|
+
constructor(options) {
|
|
35
|
+
super(SOURCE_ERROR_MESSAGES[options.code], {
|
|
36
|
+
code: options.code,
|
|
37
|
+
cause: options.cause
|
|
38
|
+
});
|
|
39
|
+
this.code = options.code;
|
|
40
|
+
this.name = "RepositorySourceException";
|
|
41
|
+
this.operation = options.operation;
|
|
42
|
+
this.path = options.path;
|
|
43
|
+
this.resource = options.resource ?? null;
|
|
44
|
+
this.retryable = options.retryable;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var SHA256_INITIAL_STATE = [
|
|
48
|
+
1779033703,
|
|
49
|
+
3144134277,
|
|
50
|
+
1013904242,
|
|
51
|
+
2773480762,
|
|
52
|
+
1359893119,
|
|
53
|
+
2600822924,
|
|
54
|
+
528734635,
|
|
55
|
+
1541459225
|
|
56
|
+
];
|
|
57
|
+
var SHA256_ROUND_CONSTANTS = [
|
|
58
|
+
1116352408,
|
|
59
|
+
1899447441,
|
|
60
|
+
3049323471,
|
|
61
|
+
3921009573,
|
|
62
|
+
961987163,
|
|
63
|
+
1508970993,
|
|
64
|
+
2453635748,
|
|
65
|
+
2870763221,
|
|
66
|
+
3624381080,
|
|
67
|
+
310598401,
|
|
68
|
+
607225278,
|
|
69
|
+
1426881987,
|
|
70
|
+
1925078388,
|
|
71
|
+
2162078206,
|
|
72
|
+
2614888103,
|
|
73
|
+
3248222580,
|
|
74
|
+
3835390401,
|
|
75
|
+
4022224774,
|
|
76
|
+
264347078,
|
|
77
|
+
604807628,
|
|
78
|
+
770255983,
|
|
79
|
+
1249150122,
|
|
80
|
+
1555081692,
|
|
81
|
+
1996064986,
|
|
82
|
+
2554220882,
|
|
83
|
+
2821834349,
|
|
84
|
+
2952996808,
|
|
85
|
+
3210313671,
|
|
86
|
+
3336571891,
|
|
87
|
+
3584528711,
|
|
88
|
+
113926993,
|
|
89
|
+
338241895,
|
|
90
|
+
666307205,
|
|
91
|
+
773529912,
|
|
92
|
+
1294757372,
|
|
93
|
+
1396182291,
|
|
94
|
+
1695183700,
|
|
95
|
+
1986661051,
|
|
96
|
+
2177026350,
|
|
97
|
+
2456956037,
|
|
98
|
+
2730485921,
|
|
99
|
+
2820302411,
|
|
100
|
+
3259730800,
|
|
101
|
+
3345764771,
|
|
102
|
+
3516065817,
|
|
103
|
+
3600352804,
|
|
104
|
+
4094571909,
|
|
105
|
+
275423344,
|
|
106
|
+
430227734,
|
|
107
|
+
506948616,
|
|
108
|
+
659060556,
|
|
109
|
+
883997877,
|
|
110
|
+
958139571,
|
|
111
|
+
1322822218,
|
|
112
|
+
1537002063,
|
|
113
|
+
1747873779,
|
|
114
|
+
1955562222,
|
|
115
|
+
2024104815,
|
|
116
|
+
2227730452,
|
|
117
|
+
2361852424,
|
|
118
|
+
2428436474,
|
|
119
|
+
2756734187,
|
|
120
|
+
3204031479,
|
|
121
|
+
3329325298
|
|
122
|
+
];
|
|
123
|
+
var rotateRight = (value, shift) => value >>> shift | value << 32 - shift;
|
|
124
|
+
var processSha256Block = (state, input, offset, schedule) => {
|
|
125
|
+
for (let index = 0; index < 16; index += 1) {
|
|
126
|
+
const wordOffset = offset + index * 4;
|
|
127
|
+
schedule[index] = (input[wordOffset] ?? 0) << 24 | (input[wordOffset + 1] ?? 0) << 16 | (input[wordOffset + 2] ?? 0) << 8 | (input[wordOffset + 3] ?? 0);
|
|
128
|
+
}
|
|
129
|
+
for (let index = 16; index < 64; index += 1) {
|
|
130
|
+
const first = schedule[index - 15] ?? 0;
|
|
131
|
+
const second = schedule[index - 2] ?? 0;
|
|
132
|
+
const firstSigma = rotateRight(first, 7) ^ rotateRight(first, 18) ^ first >>> 3;
|
|
133
|
+
const secondSigma = rotateRight(second, 17) ^ rotateRight(second, 19) ^ second >>> 10;
|
|
134
|
+
schedule[index] = (schedule[index - 16] ?? 0) + firstSigma + (schedule[index - 7] ?? 0) + secondSigma >>> 0;
|
|
135
|
+
}
|
|
136
|
+
let a = state[0] ?? 0;
|
|
137
|
+
let b = state[1] ?? 0;
|
|
138
|
+
let c = state[2] ?? 0;
|
|
139
|
+
let d = state[3] ?? 0;
|
|
140
|
+
let e = state[4] ?? 0;
|
|
141
|
+
let f = state[5] ?? 0;
|
|
142
|
+
let g = state[6] ?? 0;
|
|
143
|
+
let h = state[7] ?? 0;
|
|
144
|
+
for (let index = 0; index < 64; index += 1) {
|
|
145
|
+
const sumOne = rotateRight(e, 6) ^ rotateRight(e, 11) ^ rotateRight(e, 25);
|
|
146
|
+
const choice = e & f ^ ~e & g;
|
|
147
|
+
const temporaryOne = h + sumOne + choice + (SHA256_ROUND_CONSTANTS[index] ?? 0) + (schedule[index] ?? 0) >>> 0;
|
|
148
|
+
const temporaryTwo = (rotateRight(a, 2) ^ rotateRight(a, 13) ^ rotateRight(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
149
|
+
h = g;
|
|
150
|
+
g = f;
|
|
151
|
+
f = e;
|
|
152
|
+
e = d + temporaryOne >>> 0;
|
|
153
|
+
d = c;
|
|
154
|
+
c = b;
|
|
155
|
+
b = a;
|
|
156
|
+
a = temporaryOne + temporaryTwo >>> 0;
|
|
157
|
+
}
|
|
158
|
+
state[0] = (state[0] ?? 0) + a >>> 0;
|
|
159
|
+
state[1] = (state[1] ?? 0) + b >>> 0;
|
|
160
|
+
state[2] = (state[2] ?? 0) + c >>> 0;
|
|
161
|
+
state[3] = (state[3] ?? 0) + d >>> 0;
|
|
162
|
+
state[4] = (state[4] ?? 0) + e >>> 0;
|
|
163
|
+
state[5] = (state[5] ?? 0) + f >>> 0;
|
|
164
|
+
state[6] = (state[6] ?? 0) + g >>> 0;
|
|
165
|
+
state[7] = (state[7] ?? 0) + h >>> 0;
|
|
166
|
+
};
|
|
167
|
+
var sha256 = (parts) => {
|
|
168
|
+
const state = [...SHA256_INITIAL_STATE];
|
|
169
|
+
const schedule = new Uint32Array(64);
|
|
170
|
+
const pending = new Uint8Array(64);
|
|
171
|
+
let pendingLength = 0;
|
|
172
|
+
let totalByteLength = 0n;
|
|
173
|
+
const update = (input) => {
|
|
174
|
+
totalByteLength += BigInt(input.byteLength);
|
|
175
|
+
let offset = 0;
|
|
176
|
+
if (pendingLength > 0) {
|
|
177
|
+
const copied = Math.min(64 - pendingLength, input.byteLength);
|
|
178
|
+
pending.set(input.subarray(0, copied), pendingLength);
|
|
179
|
+
pendingLength += copied;
|
|
180
|
+
offset = copied;
|
|
181
|
+
if (pendingLength === 64) {
|
|
182
|
+
processSha256Block(state, pending, 0, schedule);
|
|
183
|
+
pendingLength = 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
while (offset + 64 <= input.byteLength) {
|
|
187
|
+
processSha256Block(state, input, offset, schedule);
|
|
188
|
+
offset += 64;
|
|
189
|
+
}
|
|
190
|
+
if (offset < input.byteLength) {
|
|
191
|
+
pending.set(input.subarray(offset), 0);
|
|
192
|
+
pendingLength = input.byteLength - offset;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
for (const part of parts) {
|
|
196
|
+
const length = BigInt(part.byteLength);
|
|
197
|
+
const lengthPrefix = new Uint8Array(8);
|
|
198
|
+
const lengthView = new DataView(lengthPrefix.buffer);
|
|
199
|
+
lengthView.setUint32(0, Number(length >> 32n), false);
|
|
200
|
+
lengthView.setUint32(4, Number(length & 4294967295n), false);
|
|
201
|
+
update(lengthPrefix);
|
|
202
|
+
update(part);
|
|
203
|
+
}
|
|
204
|
+
const finalLength = pendingLength < 56 ? 64 : 128;
|
|
205
|
+
const finalBlocks = new Uint8Array(finalLength);
|
|
206
|
+
finalBlocks.set(pending.subarray(0, pendingLength));
|
|
207
|
+
finalBlocks[pendingLength] = 128;
|
|
208
|
+
const bitLength = totalByteLength * 8n;
|
|
209
|
+
const finalView = new DataView(finalBlocks.buffer);
|
|
210
|
+
finalView.setUint32(finalLength - 8, Number(bitLength >> 32n), false);
|
|
211
|
+
finalView.setUint32(finalLength - 4, Number(bitLength & 4294967295n), false);
|
|
212
|
+
for (let offset = 0; offset < finalLength; offset += 64) processSha256Block(state, finalBlocks, offset, schedule);
|
|
213
|
+
const digest = new Uint8Array(32);
|
|
214
|
+
const digestView = new DataView(digest.buffer);
|
|
215
|
+
state.forEach((word, index) => digestView.setUint32(index * 4, word, false));
|
|
216
|
+
return digest;
|
|
217
|
+
};
|
|
218
|
+
var createRepositoryIdentity = (parts) => {
|
|
219
|
+
const digest = sha256(parts);
|
|
220
|
+
return `sha256:${Array.from(digest, (byte) => byte.toString(16).padStart(2, "0")).join("")}`;
|
|
221
|
+
};
|
|
222
|
+
var encoder = new TextEncoder();
|
|
223
|
+
var ENVELOPE_KEYS = new Set([
|
|
224
|
+
"checksum",
|
|
225
|
+
"payload",
|
|
226
|
+
"version"
|
|
227
|
+
]);
|
|
228
|
+
var createRepositoryCursor = (payload) => {
|
|
229
|
+
const serializedPayload = JSON.stringify(payload);
|
|
230
|
+
return JSON.stringify({
|
|
231
|
+
checksum: createRepositoryIdentity([encoder.encode(serializedPayload)]),
|
|
232
|
+
payload: serializedPayload,
|
|
233
|
+
version: 1
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
var decodeRepositoryCursor = (cursor) => {
|
|
237
|
+
const envelope = JSON.parse(cursor);
|
|
238
|
+
if (!isObjectValid(envelope, true) || Reflect.ownKeys(envelope).some((key) => typeof key !== "string" || !ENVELOPE_KEYS.has(key)) || envelope["version"] !== 1 || typeof envelope["payload"] !== "string" || typeof envelope["checksum"] !== "string" || envelope["checksum"] !== createRepositoryIdentity([encoder.encode(envelope["payload"])])) throw new TypeError("The repository cursor is invalid.");
|
|
239
|
+
return JSON.parse(envelope["payload"]);
|
|
240
|
+
};
|
|
241
|
+
var parsePositivePageInteger = (value, operation, path) => {
|
|
242
|
+
if (!Number.isSafeInteger(value) || value <= 0) throw new RepositorySourceException({
|
|
243
|
+
code: "INVALID_PAGE_REQUEST",
|
|
244
|
+
operation,
|
|
245
|
+
path,
|
|
246
|
+
retryable: false
|
|
247
|
+
});
|
|
248
|
+
return value;
|
|
249
|
+
};
|
|
250
|
+
var WINDOWS_DRIVE_PREFIX_PATTERN = /^\/[A-Za-z]:/u;
|
|
251
|
+
var hasASCIIControlCharacter = (value) => {
|
|
252
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
253
|
+
const codeUnit = value.charCodeAt(index);
|
|
254
|
+
if (codeUnit <= 31 || codeUnit === 127) return true;
|
|
255
|
+
}
|
|
256
|
+
return false;
|
|
257
|
+
};
|
|
258
|
+
var isRepositoryPath = (value) => {
|
|
259
|
+
if (typeof value !== "string" || !value.isWellFormed()) return false;
|
|
260
|
+
if (value === "/") return true;
|
|
261
|
+
if (!value.startsWith("/") || value.startsWith("//") || value.endsWith("/") || value.includes("\\") || hasASCIIControlCharacter(value) || WINDOWS_DRIVE_PREFIX_PATTERN.test(value)) return false;
|
|
262
|
+
return value.slice(1).split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
263
|
+
};
|
|
264
|
+
var parseRepositoryPath = (value) => {
|
|
265
|
+
if (!isRepositoryPath(value)) throw new RepositoryPathException();
|
|
266
|
+
return value;
|
|
267
|
+
};
|
|
268
|
+
var compareRepositoryPaths = (left, right) => {
|
|
269
|
+
const leftSegments = left.split("/");
|
|
270
|
+
const rightSegments = right.split("/");
|
|
271
|
+
const sharedLength = Math.min(leftSegments.length, rightSegments.length);
|
|
272
|
+
for (let index = 0; index < sharedLength; index += 1) {
|
|
273
|
+
const leftSegment = leftSegments[index] ?? "";
|
|
274
|
+
const rightSegment = rightSegments[index] ?? "";
|
|
275
|
+
if (leftSegment < rightSegment) return -1;
|
|
276
|
+
if (leftSegment > rightSegment) return 1;
|
|
277
|
+
}
|
|
278
|
+
return leftSegments.length - rightSegments.length;
|
|
279
|
+
};
|
|
280
|
+
var REPOSITORY_ROOT = parseRepositoryPath("/");
|
|
281
|
+
var COMPARISON_CURSOR_KEYS = new Set([
|
|
282
|
+
"baseCursor",
|
|
283
|
+
"baseSnapshotId",
|
|
284
|
+
"candidateCursor",
|
|
285
|
+
"candidateSnapshotId",
|
|
286
|
+
"pendingFile"
|
|
287
|
+
]);
|
|
288
|
+
var PENDING_FILE_CURSOR_KEYS = new Set(["offset", "path"]);
|
|
289
|
+
var throwIfAborted = (signal) => {
|
|
290
|
+
if (signal?.aborted) throw new RepositorySourceException({
|
|
291
|
+
cause: signal.reason,
|
|
292
|
+
code: "ABORTED",
|
|
293
|
+
operation: "list-changes-page",
|
|
294
|
+
path: null,
|
|
295
|
+
retryable: false
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
var invalidComparisonCursor = (cause) => {
|
|
299
|
+
return new RepositorySourceException({
|
|
300
|
+
cause,
|
|
301
|
+
code: "INVALID_PAGE_REQUEST",
|
|
302
|
+
operation: "list-changes-page",
|
|
303
|
+
path: null,
|
|
304
|
+
retryable: false
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
var parseComparisonCursor = (cursor, baseSnapshotId, candidateSnapshotId) => {
|
|
308
|
+
if (cursor === void 0) return {
|
|
309
|
+
baseCursor: null,
|
|
310
|
+
baseSnapshotId,
|
|
311
|
+
candidateCursor: null,
|
|
312
|
+
candidateSnapshotId,
|
|
313
|
+
pendingFile: null
|
|
314
|
+
};
|
|
315
|
+
try {
|
|
316
|
+
const parsed = decodeRepositoryCursor(cursor);
|
|
317
|
+
if (typeof parsed !== "object" || parsed === null || Reflect.ownKeys(parsed).some((key) => typeof key !== "string" || !COMPARISON_CURSOR_KEYS.has(key)) || parsed.baseSnapshotId !== baseSnapshotId || parsed.candidateSnapshotId !== candidateSnapshotId || typeof parsed.baseCursor !== "string" && parsed.baseCursor !== null || typeof parsed.candidateCursor !== "string" && parsed.candidateCursor !== null || parsed.pendingFile !== null && (typeof parsed.pendingFile !== "object" || Reflect.ownKeys(parsed.pendingFile).some((key) => typeof key !== "string" || !PENDING_FILE_CURSOR_KEYS.has(key)) || typeof parsed.pendingFile.path !== "string" || !Number.isSafeInteger(parsed.pendingFile.offset) || parsed.pendingFile.offset < 0)) throw new Error("invalid comparison cursor");
|
|
318
|
+
return parsed;
|
|
319
|
+
} catch (cause) {
|
|
320
|
+
throw invalidComparisonCursor(cause);
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
var invalidSourceData = (path, cause) => {
|
|
324
|
+
throw new RepositorySourceException({
|
|
325
|
+
cause,
|
|
326
|
+
code: "INVALID_SOURCE_DATA",
|
|
327
|
+
operation: "list-changes-page",
|
|
328
|
+
path,
|
|
329
|
+
retryable: false
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
var getNextEntry = async (reader, cursor, signal) => {
|
|
333
|
+
if (cursor === "") return null;
|
|
334
|
+
const page = await reader.listEntriesPage({
|
|
335
|
+
...cursor === null ? {} : { cursor },
|
|
336
|
+
maxEntries: 1,
|
|
337
|
+
prefix: REPOSITORY_ROOT,
|
|
338
|
+
...signal === void 0 ? {} : { signal }
|
|
339
|
+
});
|
|
340
|
+
if (page.snapshot.id !== reader.snapshot.id || page.entries.length > 1) throw invalidComparisonCursor();
|
|
341
|
+
const entry = page.entries[0];
|
|
342
|
+
if (entry === void 0) {
|
|
343
|
+
if (!page.isComplete || page.nextCursor !== null) throw invalidComparisonCursor();
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
if (!page.isComplete && page.nextCursor === null) throw invalidComparisonCursor();
|
|
347
|
+
return {
|
|
348
|
+
cursorAfter: page.nextCursor ?? "",
|
|
349
|
+
entry
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
var classifySharedEntryMetadata = (baseEntry, candidateEntry, canCompareContentIdentities) => {
|
|
353
|
+
if (baseEntry.type !== candidateEntry.type) return {
|
|
354
|
+
baseEntry,
|
|
355
|
+
candidateEntry,
|
|
356
|
+
kind: "type-changed",
|
|
357
|
+
path: baseEntry.path
|
|
358
|
+
};
|
|
359
|
+
if (baseEntry.type !== "file") return null;
|
|
360
|
+
if (baseEntry.byteLength !== null && candidateEntry.byteLength !== null && baseEntry.byteLength !== candidateEntry.byteLength) return {
|
|
361
|
+
baseEntry,
|
|
362
|
+
candidateEntry,
|
|
363
|
+
kind: "modified",
|
|
364
|
+
path: baseEntry.path
|
|
365
|
+
};
|
|
366
|
+
if (canCompareContentIdentities && baseEntry.contentIdentity !== null && candidateEntry.contentIdentity !== null && baseEntry.contentIdentity === candidateEntry.contentIdentity) return null;
|
|
367
|
+
if (baseEntry.byteLength === 0 && candidateEntry.byteLength === 0) return null;
|
|
368
|
+
};
|
|
369
|
+
var validateFilePage = (page, entry, expectedSnapshotId, expectedOffset, maxBytes) => {
|
|
370
|
+
const nextOffset = expectedOffset + page.bytes.byteLength;
|
|
371
|
+
if (!(page.bytes instanceof Uint8Array) || page.bytes.byteLength > maxBytes || page.offset !== expectedOffset || page.snapshot.id !== expectedSnapshotId || !Number.isSafeInteger(page.totalBytes) || page.totalBytes < expectedOffset || nextOffset > page.totalBytes || entry.byteLength !== null && page.totalBytes !== entry.byteLength || page.isComplete !== (nextOffset === page.totalBytes) || page.nextOffset !== (page.isComplete ? null : nextOffset) || !page.isComplete && page.bytes.byteLength === 0) invalidSourceData(entry.path);
|
|
372
|
+
};
|
|
373
|
+
var compareFileRange = async (base, candidate, baseEntry, candidateEntry, offset, maxBytesRead, signal) => {
|
|
374
|
+
const maxBaseBytes = Math.floor(maxBytesRead / 2);
|
|
375
|
+
if (maxBaseBytes < 1) return {
|
|
376
|
+
bytesRead: 0,
|
|
377
|
+
isComplete: false,
|
|
378
|
+
isEqual: true,
|
|
379
|
+
nextOffset: offset
|
|
380
|
+
};
|
|
381
|
+
const basePage = await base.readFilePage(baseEntry.path, {
|
|
382
|
+
maxBytes: maxBaseBytes,
|
|
383
|
+
offset,
|
|
384
|
+
...signal === void 0 ? {} : { signal }
|
|
385
|
+
});
|
|
386
|
+
validateFilePage(basePage, baseEntry, base.snapshot.id, offset, maxBaseBytes);
|
|
387
|
+
let bytesRead = basePage.bytes.byteLength;
|
|
388
|
+
let candidateOffset = offset;
|
|
389
|
+
let comparedBytes = 0;
|
|
390
|
+
let candidateTotalBytes = null;
|
|
391
|
+
const candidateTargetBytes = Math.max(basePage.bytes.byteLength, 1);
|
|
392
|
+
while (comparedBytes < candidateTargetBytes) {
|
|
393
|
+
const remainingTargetBytes = candidateTargetBytes - comparedBytes;
|
|
394
|
+
const candidatePage = await candidate.readFilePage(candidateEntry.path, {
|
|
395
|
+
maxBytes: remainingTargetBytes,
|
|
396
|
+
offset: candidateOffset,
|
|
397
|
+
...signal === void 0 ? {} : { signal }
|
|
398
|
+
});
|
|
399
|
+
validateFilePage(candidatePage, candidateEntry, candidate.snapshot.id, candidateOffset, remainingTargetBytes);
|
|
400
|
+
candidateTotalBytes = candidatePage.totalBytes;
|
|
401
|
+
bytesRead += candidatePage.bytes.byteLength;
|
|
402
|
+
if (basePage.totalBytes !== candidatePage.totalBytes) return {
|
|
403
|
+
bytesRead,
|
|
404
|
+
isComplete: true,
|
|
405
|
+
isEqual: false,
|
|
406
|
+
nextOffset: offset
|
|
407
|
+
};
|
|
408
|
+
for (let index = 0; index < candidatePage.bytes.byteLength; index += 1) if (basePage.bytes[comparedBytes + index] !== candidatePage.bytes[index]) return {
|
|
409
|
+
bytesRead,
|
|
410
|
+
isComplete: true,
|
|
411
|
+
isEqual: false,
|
|
412
|
+
nextOffset: offset
|
|
413
|
+
};
|
|
414
|
+
comparedBytes += candidatePage.bytes.byteLength;
|
|
415
|
+
candidateOffset += candidatePage.bytes.byteLength;
|
|
416
|
+
if (candidatePage.isComplete) break;
|
|
417
|
+
}
|
|
418
|
+
if (candidateTotalBytes === null) invalidSourceData(candidateEntry.path);
|
|
419
|
+
const nextOffset = offset + basePage.bytes.byteLength;
|
|
420
|
+
const isComplete = nextOffset === basePage.totalBytes && nextOffset === candidateTotalBytes;
|
|
421
|
+
return {
|
|
422
|
+
bytesRead,
|
|
423
|
+
isComplete,
|
|
424
|
+
isEqual: true,
|
|
425
|
+
nextOffset
|
|
426
|
+
};
|
|
427
|
+
};
|
|
428
|
+
var RepositoryComparison = class {
|
|
429
|
+
baseSnapshot;
|
|
430
|
+
candidateSnapshot;
|
|
431
|
+
#base;
|
|
432
|
+
#candidate;
|
|
433
|
+
constructor(base, candidate) {
|
|
434
|
+
this.#base = base;
|
|
435
|
+
this.#candidate = candidate;
|
|
436
|
+
this.baseSnapshot = base.snapshot;
|
|
437
|
+
this.candidateSnapshot = candidate.snapshot;
|
|
438
|
+
}
|
|
439
|
+
async listChangesPage(options) {
|
|
440
|
+
const maxChanges = parsePositivePageInteger(options.maxChanges, "list-changes-page", null);
|
|
441
|
+
const maxEntriesVisited = parsePositivePageInteger(options.maxEntriesVisited, "list-changes-page", null);
|
|
442
|
+
const maxBytesRead = parsePositivePageInteger(options.maxBytesRead, "list-changes-page", null);
|
|
443
|
+
if (maxBytesRead < 2) throw invalidComparisonCursor();
|
|
444
|
+
throwIfAborted(options.signal);
|
|
445
|
+
const cursor = parseComparisonCursor(options.cursor, this.baseSnapshot.id, this.candidateSnapshot.id);
|
|
446
|
+
let baseCursor = cursor.baseCursor;
|
|
447
|
+
let candidateCursor = cursor.candidateCursor;
|
|
448
|
+
let pendingFile = cursor.pendingFile;
|
|
449
|
+
const changes = [];
|
|
450
|
+
let bytesRead = 0;
|
|
451
|
+
let entriesVisited = 0;
|
|
452
|
+
let baseNext;
|
|
453
|
+
let candidateNext;
|
|
454
|
+
while (entriesVisited < maxEntriesVisited && changes.length < maxChanges) {
|
|
455
|
+
throwIfAborted(options.signal);
|
|
456
|
+
[baseNext, candidateNext] = await Promise.all([baseNext === void 0 ? getNextEntry(this.#base, baseCursor, options.signal) : Promise.resolve(baseNext), candidateNext === void 0 ? getNextEntry(this.#candidate, candidateCursor, options.signal) : Promise.resolve(candidateNext)]);
|
|
457
|
+
if (baseNext === null) baseCursor = "";
|
|
458
|
+
if (candidateNext === null) candidateCursor = "";
|
|
459
|
+
if (baseNext === null && candidateNext === null) break;
|
|
460
|
+
const baseEntry = baseNext?.entry;
|
|
461
|
+
const candidateEntry = candidateNext?.entry;
|
|
462
|
+
if (pendingFile !== null && (baseEntry?.path !== pendingFile.path || candidateEntry?.path !== pendingFile.path)) throw invalidComparisonCursor();
|
|
463
|
+
if (candidateEntry === void 0 || baseEntry !== void 0 && compareRepositoryPaths(baseEntry.path, candidateEntry.path) < 0) {
|
|
464
|
+
changes.push({
|
|
465
|
+
baseEntry: baseEntry ?? null,
|
|
466
|
+
candidateEntry: null,
|
|
467
|
+
kind: "deleted",
|
|
468
|
+
path: baseEntry?.path ?? REPOSITORY_ROOT
|
|
469
|
+
});
|
|
470
|
+
baseCursor = baseNext?.cursorAfter ?? "";
|
|
471
|
+
baseNext = void 0;
|
|
472
|
+
} else if (baseEntry === void 0 || compareRepositoryPaths(candidateEntry.path, baseEntry.path) < 0) {
|
|
473
|
+
changes.push({
|
|
474
|
+
baseEntry: null,
|
|
475
|
+
candidateEntry,
|
|
476
|
+
kind: "added",
|
|
477
|
+
path: candidateEntry.path
|
|
478
|
+
});
|
|
479
|
+
candidateCursor = candidateNext?.cursorAfter ?? "";
|
|
480
|
+
candidateNext = void 0;
|
|
481
|
+
} else {
|
|
482
|
+
const change = classifySharedEntryMetadata(baseEntry, candidateEntry, this.baseSnapshot.sourceKind === this.candidateSnapshot.sourceKind);
|
|
483
|
+
if (change !== void 0) {
|
|
484
|
+
if (change !== null) changes.push(change);
|
|
485
|
+
baseCursor = baseNext?.cursorAfter ?? "";
|
|
486
|
+
candidateCursor = candidateNext?.cursorAfter ?? "";
|
|
487
|
+
baseNext = void 0;
|
|
488
|
+
candidateNext = void 0;
|
|
489
|
+
pendingFile = null;
|
|
490
|
+
} else if (maxBytesRead - bytesRead < 2) break;
|
|
491
|
+
else {
|
|
492
|
+
const comparison = await compareFileRange(this.#base, this.#candidate, baseEntry, candidateEntry, pendingFile?.offset ?? 0, maxBytesRead - bytesRead, options.signal);
|
|
493
|
+
bytesRead += comparison.bytesRead;
|
|
494
|
+
if (!comparison.isEqual) changes.push({
|
|
495
|
+
baseEntry,
|
|
496
|
+
candidateEntry,
|
|
497
|
+
kind: "modified",
|
|
498
|
+
path: baseEntry.path
|
|
499
|
+
});
|
|
500
|
+
if (comparison.isComplete) {
|
|
501
|
+
baseCursor = baseNext?.cursorAfter ?? "";
|
|
502
|
+
candidateCursor = candidateNext?.cursorAfter ?? "";
|
|
503
|
+
baseNext = void 0;
|
|
504
|
+
candidateNext = void 0;
|
|
505
|
+
pendingFile = null;
|
|
506
|
+
} else pendingFile = {
|
|
507
|
+
offset: comparison.nextOffset,
|
|
508
|
+
path: baseEntry.path
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
entriesVisited += 1;
|
|
513
|
+
if (pendingFile !== null) break;
|
|
514
|
+
}
|
|
515
|
+
const isComplete = baseCursor === "" && candidateCursor === "" && pendingFile === null;
|
|
516
|
+
const nextCursor = isComplete ? null : createRepositoryCursor({
|
|
517
|
+
baseCursor,
|
|
518
|
+
baseSnapshotId: this.baseSnapshot.id,
|
|
519
|
+
candidateCursor,
|
|
520
|
+
candidateSnapshotId: this.candidateSnapshot.id,
|
|
521
|
+
pendingFile
|
|
522
|
+
});
|
|
523
|
+
return {
|
|
524
|
+
baseSnapshot: this.baseSnapshot,
|
|
525
|
+
bytesRead,
|
|
526
|
+
candidateSnapshot: this.candidateSnapshot,
|
|
527
|
+
changes,
|
|
528
|
+
entriesVisited,
|
|
529
|
+
isComplete,
|
|
530
|
+
nextCursor
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
var createRepositoryComparison = async (base, candidate, options) => {
|
|
535
|
+
if (options?.signal?.aborted) throw new RepositorySourceException({
|
|
536
|
+
cause: options.signal.reason,
|
|
537
|
+
code: "ABORTED",
|
|
538
|
+
operation: "create-comparison",
|
|
539
|
+
path: null,
|
|
540
|
+
retryable: false
|
|
541
|
+
});
|
|
542
|
+
await Promise.resolve();
|
|
543
|
+
return new RepositoryComparison(base, candidate);
|
|
544
|
+
};
|
|
545
|
+
var REPOSITORY_LINK_TEXT_MAX_BYTES = 4096;
|
|
546
|
+
var DRIVE_PREFIX_PATTERN = /^[A-Za-z]:/u;
|
|
547
|
+
var resolveLinkText = (linkPath, text) => {
|
|
548
|
+
if (text === null || text === "") return { kind: "unsupported" };
|
|
549
|
+
if (text.startsWith("/") || DRIVE_PREFIX_PATTERN.test(text)) return { kind: "outside" };
|
|
550
|
+
const segments = text.split("/");
|
|
551
|
+
if (segments.at(-1) === "") return { kind: "unsupported" };
|
|
552
|
+
const namedSegments = segments.filter((segment) => segment !== "" && segment !== ".");
|
|
553
|
+
const directorySegments = linkPath.split("/").slice(1, -1);
|
|
554
|
+
let segmentIndex = 0;
|
|
555
|
+
while (namedSegments[segmentIndex] === "..") {
|
|
556
|
+
if (directorySegments.length === 0) return { kind: "outside" };
|
|
557
|
+
directorySegments.pop();
|
|
558
|
+
segmentIndex += 1;
|
|
559
|
+
}
|
|
560
|
+
const remainingSegments = namedSegments.slice(segmentIndex);
|
|
561
|
+
if (remainingSegments.includes("..")) return { kind: "unsupported" };
|
|
562
|
+
const candidate = `/${[...directorySegments, ...remainingSegments].join("/")}`;
|
|
563
|
+
return isRepositoryPath(candidate) ? {
|
|
564
|
+
kind: "path",
|
|
565
|
+
path: candidate
|
|
566
|
+
} : { kind: "unsupported" };
|
|
567
|
+
};
|
|
568
|
+
var resolveRepositoryLink = async (source, path, options) => {
|
|
569
|
+
const visitedPaths = new Set();
|
|
570
|
+
let currentPath = parseRepositoryPath(path);
|
|
571
|
+
for (let followedLinks = 0;; followedLinks += 1) {
|
|
572
|
+
if (visitedPaths.has(currentPath)) return { state: "loop" };
|
|
573
|
+
visitedPaths.add(currentPath);
|
|
574
|
+
const entry = await source.getEntry(currentPath, options);
|
|
575
|
+
if (entry === null) return { state: "missing" };
|
|
576
|
+
if (entry.type === "file") return {
|
|
577
|
+
state: "file",
|
|
578
|
+
targetPath: currentPath
|
|
579
|
+
};
|
|
580
|
+
if (entry.type !== "symlink") return { state: "not-file" };
|
|
581
|
+
if (followedLinks === 32) return { state: "loop" };
|
|
582
|
+
const step = resolveLinkText(currentPath, await source.readLinkText(currentPath, options));
|
|
583
|
+
if (step.kind !== "path") return { state: step.kind };
|
|
584
|
+
currentPath = step.path;
|
|
585
|
+
}
|
|
586
|
+
};
|
|
587
|
+
//#endregion
|
|
588
|
+
export { compareRepositoryPaths as a, isRepositoryPath as c, RepositorySourceException as i, parseRepositoryPath as l, REPOSITORY_ROOT as n, createRepositoryComparison as o, RepositoryPathException as r, createRepositoryIdentity as s, REPOSITORY_LINK_TEXT_MAX_BYTES as t, resolveRepositoryLink as u };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { a as createInspectionProcessFailure, c as encodeInspectionMessage, r as NODE_INSPECTION_TERMINATION_GRACE_MS } from "./chunk-ec3f49d3.mjs";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
//#region ../core/dist/chunks/lifecycle-z05THc0s.js
|
|
4
|
+
var createInspectionSender = (send) => {
|
|
5
|
+
let queued = 0;
|
|
6
|
+
let tail = Promise.resolve();
|
|
7
|
+
return async (message) => {
|
|
8
|
+
if (queued >= 4) throw createInspectionProcessFailure();
|
|
9
|
+
queued++;
|
|
10
|
+
const operation = tail.then(() => new Promise((resolve, reject) => {
|
|
11
|
+
try {
|
|
12
|
+
send(encodeInspectionMessage(message), (error) => {
|
|
13
|
+
if (error !== null) reject(createInspectionProcessFailure(error));
|
|
14
|
+
else resolve();
|
|
15
|
+
});
|
|
16
|
+
} catch (cause) {
|
|
17
|
+
reject(cause instanceof Error ? cause : createInspectionProcessFailure(cause));
|
|
18
|
+
}
|
|
19
|
+
}));
|
|
20
|
+
tail = operation.catch(() => {});
|
|
21
|
+
try {
|
|
22
|
+
await operation;
|
|
23
|
+
} finally {
|
|
24
|
+
queued--;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
var createInspectionEnvironment = () => {
|
|
29
|
+
const names = new Set([
|
|
30
|
+
"systemroot",
|
|
31
|
+
"windir",
|
|
32
|
+
"temp",
|
|
33
|
+
"tmp",
|
|
34
|
+
"tmpdir"
|
|
35
|
+
]);
|
|
36
|
+
return Object.fromEntries(Object.entries(process.env).filter(([name]) => names.has(name.toLowerCase())));
|
|
37
|
+
};
|
|
38
|
+
var superviseInspectionChild = (child, requestStop) => {
|
|
39
|
+
let hasClosed = false;
|
|
40
|
+
let forceTimer;
|
|
41
|
+
return {
|
|
42
|
+
closed: new Promise((resolve) => {
|
|
43
|
+
child.once("close", () => {
|
|
44
|
+
hasClosed = true;
|
|
45
|
+
clearTimeout(forceTimer);
|
|
46
|
+
resolve();
|
|
47
|
+
});
|
|
48
|
+
}),
|
|
49
|
+
terminate: () => {
|
|
50
|
+
if (hasClosed || forceTimer !== void 0) return;
|
|
51
|
+
forceTimer = setTimeout(() => {
|
|
52
|
+
if (!hasClosed) child.kill("SIGKILL");
|
|
53
|
+
}, NODE_INSPECTION_TERMINATION_GRACE_MS);
|
|
54
|
+
requestStop();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { createInspectionSender as n, superviseInspectionChild as r, createInspectionEnvironment as t };
|