@veryfront/ext-content-mdx 0.1.1186 → 0.1.1189
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/esm/_dnt.polyfills.d.ts +6 -6
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/deno.d.ts +18 -0
- package/esm/deno.js +30 -9
- package/esm/src/config/defaults.d.ts +31 -24
- package/esm/src/config/defaults.d.ts.map +1 -1
- package/esm/src/config/defaults.js +25 -18
- package/esm/src/errors/diagnostic-policy.d.ts +35 -0
- package/esm/src/errors/diagnostic-policy.d.ts.map +1 -0
- package/esm/src/errors/diagnostic-policy.js +100 -0
- package/esm/src/errors/error-registry/boundary.d.ts +2 -0
- package/esm/src/errors/error-registry/boundary.d.ts.map +1 -1
- package/esm/src/errors/error-registry/boundary.js +8 -0
- package/esm/src/errors/error-registry/config.d.ts.map +1 -1
- package/esm/src/errors/error-registry/config.js +3 -3
- package/esm/src/errors/error-registry/deploy.js +1 -1
- package/esm/src/errors/error-registry/server.d.ts +2 -0
- package/esm/src/errors/error-registry/server.d.ts.map +1 -1
- package/esm/src/errors/error-registry/server.js +8 -0
- package/esm/src/errors/error-registry-helpers.d.ts +11 -2
- package/esm/src/errors/error-registry-helpers.d.ts.map +1 -1
- package/esm/src/errors/error-registry-helpers.js +70 -1
- package/esm/src/errors/error-registry.d.ts +85 -73
- package/esm/src/errors/error-registry.d.ts.map +1 -1
- package/esm/src/errors/error-registry.js +2 -14
- package/esm/src/errors/types.d.ts +44 -5
- package/esm/src/errors/types.d.ts.map +1 -1
- package/esm/src/errors/types.js +148 -24
- package/esm/src/errors/veryfront-error.d.ts +25 -2
- package/esm/src/errors/veryfront-error.d.ts.map +1 -1
- package/esm/src/errors/veryfront-error.js +638 -28
- package/esm/src/observability/limits.d.ts +20 -0
- package/esm/src/observability/limits.d.ts.map +1 -0
- package/esm/src/observability/limits.js +19 -0
- package/esm/src/observability/telemetry-error.d.ts +22 -0
- package/esm/src/observability/telemetry-error.d.ts.map +1 -0
- package/esm/src/observability/telemetry-error.js +377 -0
- package/esm/src/observability/tracing/api-shim.d.ts +39 -0
- package/esm/src/observability/tracing/api-shim.d.ts.map +1 -1
- package/esm/src/observability/tracing/api-shim.js +196 -69
- package/esm/src/observability/tracing/context-callback.d.ts +14 -0
- package/esm/src/observability/tracing/context-callback.d.ts.map +1 -0
- package/esm/src/observability/tracing/context-callback.js +111 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -1
- package/esm/src/observability/tracing/otlp-setup.js +190 -46
- package/esm/src/platform/adapters/base.d.ts +51 -7
- package/esm/src/platform/adapters/base.d.ts.map +1 -1
- package/esm/src/platform/adapters/base.js +4 -2
- package/esm/src/platform/adapters/bounded-file-read.d.ts +9 -0
- package/esm/src/platform/adapters/bounded-file-read.d.ts.map +1 -1
- package/esm/src/platform/adapters/bounded-file-read.js +11 -5
- package/esm/src/platform/adapters/file-snapshot-error.d.ts +2 -0
- package/esm/src/platform/adapters/file-snapshot-error.d.ts.map +1 -1
- package/esm/src/platform/adapters/file-snapshot-error.js +2 -0
- package/esm/src/platform/adapters/file-system-capabilities.d.ts +74 -0
- package/esm/src/platform/adapters/file-system-capabilities.d.ts.map +1 -0
- package/esm/src/platform/adapters/file-system-capabilities.js +508 -0
- package/esm/src/platform/adapters/native-file-system-provenance.d.ts +6 -0
- package/esm/src/platform/adapters/native-file-system-provenance.d.ts.map +1 -0
- package/esm/src/platform/adapters/native-file-system-provenance.js +15 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.d.ts +45 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/deno/filesystem-adapter.js +291 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts +71 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/node-filesystem-adapter.js +471 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.d.ts +16 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/shared-watcher.js +140 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.d.ts +2 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/temp-dir.js +10 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.d.ts +5 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.d.ts.map +1 -0
- package/esm/src/platform/adapters/runtime/shared/watcher-queue.js +75 -0
- package/esm/src/platform/compat/abort-signal.d.ts +20 -0
- package/esm/src/platform/compat/abort-signal.d.ts.map +1 -0
- package/esm/src/platform/compat/abort-signal.js +64 -0
- package/esm/src/platform/compat/constants.d.ts +2 -2
- package/esm/src/platform/compat/constants.d.ts.map +1 -1
- package/esm/src/platform/compat/constants.js +2 -2
- package/esm/src/platform/compat/error-introspection.d.ts +37 -0
- package/esm/src/platform/compat/error-introspection.d.ts.map +1 -0
- package/esm/src/platform/compat/error-introspection.js +258 -0
- package/esm/src/platform/compat/fs.d.ts +29 -8
- package/esm/src/platform/compat/fs.d.ts.map +1 -1
- package/esm/src/platform/compat/fs.js +123 -57
- package/esm/src/platform/compat/native-brand-checks.d.ts +14 -0
- package/esm/src/platform/compat/native-brand-checks.d.ts.map +1 -0
- package/esm/src/platform/compat/native-brand-checks.js +68 -0
- package/esm/src/platform/compat/not-found-error.d.ts +8 -3
- package/esm/src/platform/compat/not-found-error.d.ts.map +1 -1
- package/esm/src/platform/compat/not-found-error.js +164 -31
- package/esm/src/platform/compat/path/security.d.ts.map +1 -1
- package/esm/src/platform/compat/path/security.js +3 -5
- package/esm/src/platform/compat/process/command.d.ts +24 -1
- package/esm/src/platform/compat/process/command.d.ts.map +1 -1
- package/esm/src/platform/compat/process/command.js +393 -78
- package/esm/src/platform/compat/process/env.d.ts +11 -0
- package/esm/src/platform/compat/process/env.d.ts.map +1 -1
- package/esm/src/platform/compat/process/env.js +28 -38
- package/esm/src/platform/compat/process/global-error.d.ts +19 -0
- package/esm/src/platform/compat/process/global-error.d.ts.map +1 -0
- package/esm/src/platform/compat/process/global-error.js +57 -0
- package/esm/src/platform/compat/process/lifecycle.d.ts +10 -3
- package/esm/src/platform/compat/process/lifecycle.d.ts.map +1 -1
- package/esm/src/platform/compat/process/lifecycle.js +74 -23
- package/esm/src/platform/compat/process/project-env-contract.d.ts +19 -0
- package/esm/src/platform/compat/process/project-env-contract.d.ts.map +1 -0
- package/esm/src/platform/compat/process/project-env-contract.js +19 -0
- package/esm/src/platform/compat/runtime.d.ts +14 -5
- package/esm/src/platform/compat/runtime.d.ts.map +1 -1
- package/esm/src/platform/compat/runtime.js +34 -9
- package/esm/src/platform/compat/std/front-matter-yaml.d.ts +12 -0
- package/esm/src/platform/compat/std/front-matter-yaml.d.ts.map +1 -1
- package/esm/src/platform/compat/std/front-matter-yaml.js +35 -3
- package/esm/src/platform/compat/temp-directory-prefix.d.ts +8 -0
- package/esm/src/platform/compat/temp-directory-prefix.d.ts.map +1 -0
- package/esm/src/platform/compat/temp-directory-prefix.js +15 -0
- package/esm/src/utils/abort.d.ts +10 -0
- package/esm/src/utils/abort.d.ts.map +1 -0
- package/esm/src/utils/abort.js +35 -0
- package/esm/src/utils/constants/build.d.ts +3 -0
- package/esm/src/utils/constants/build.d.ts.map +1 -1
- package/esm/src/utils/constants/build.js +5 -1
- package/esm/src/utils/constants/cache.d.ts +21 -0
- package/esm/src/utils/constants/cache.d.ts.map +1 -1
- package/esm/src/utils/constants/cache.js +101 -39
- package/esm/src/utils/constants/css.d.ts +20 -0
- package/esm/src/utils/constants/css.d.ts.map +1 -0
- package/esm/src/utils/constants/css.js +19 -0
- package/esm/src/utils/constants/limits.d.ts +4 -0
- package/esm/src/utils/constants/limits.d.ts.map +1 -1
- package/esm/src/utils/constants/limits.js +4 -0
- package/esm/src/utils/constants/project-identity.d.ts +5 -0
- package/esm/src/utils/constants/project-identity.d.ts.map +1 -0
- package/esm/src/utils/constants/project-identity.js +4 -0
- package/esm/src/utils/constants/retry.d.ts +18 -0
- package/esm/src/utils/constants/retry.d.ts.map +1 -1
- package/esm/src/utils/constants/retry.js +18 -0
- package/esm/src/utils/constants/security.d.ts +4 -0
- package/esm/src/utils/constants/security.d.ts.map +1 -1
- package/esm/src/utils/constants/security.js +4 -0
- package/esm/src/utils/index.d.ts +3 -1
- package/esm/src/utils/index.d.ts.map +1 -1
- package/esm/src/utils/index.js +3 -1
- package/esm/src/utils/logger/core.d.ts +5 -0
- package/esm/src/utils/logger/core.d.ts.map +1 -1
- package/esm/src/utils/logger/core.js +67 -2
- package/esm/src/utils/logger/redact.d.ts +36 -13
- package/esm/src/utils/logger/redact.d.ts.map +1 -1
- package/esm/src/utils/logger/redact.js +573 -83
- package/esm/src/utils/parallel.d.ts.map +1 -1
- package/esm/src/utils/parallel.js +11 -1
- package/esm/src/utils/project-identity.d.ts +11 -0
- package/esm/src/utils/project-identity.d.ts.map +1 -0
- package/esm/src/utils/project-identity.js +69 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +3 -3
- package/esm/src/platform/adapters/runtime/shared/native-file-capabilities.d.ts +0 -33
- package/esm/src/platform/adapters/runtime/shared/native-file-capabilities.d.ts.map +0 -1
- package/esm/src/platform/adapters/runtime/shared/native-file-capabilities.js +0 -205
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../src/src/utils/parallel.ts"],"names":[],"mappings":"AAAA;;;;;;;iCAOiC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,oEAAoE,CAAC;AAY/F,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"parallel.d.ts","sourceRoot":"","sources":["../../../src/src/utils/parallel.ts"],"names":[],"mappings":"AAAA;;;;;;;iCAOiC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,oEAAoE,CAAC;AAY/F,KAAK,eAAe,GAAG;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAyBF,wBAAwB;AACxB,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,KAAK,EAAE,CAAC,EAAE,EACV,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1C,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,CAAC,EAAE,CAAC,CA4Bd;AAED,wBAAgB,WAAW,CAAC,CAAC,SAAS,SAAS,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EACvE,GAAG,EAAE,CAAC,EACN,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,CAMxD"}
|
|
@@ -15,6 +15,16 @@ const ACQUIRE_TIMEOUT_MS = 30_000;
|
|
|
15
15
|
// so a queue cap would reject items in large batches instead of letting
|
|
16
16
|
// them progress under the concurrency limit with timeout-based backpressure.
|
|
17
17
|
const apiSemaphore = new Semaphore(DEFAULT_CONCURRENCY);
|
|
18
|
+
function resolveParallelSemaphore(options) {
|
|
19
|
+
if (options.semaphore !== undefined)
|
|
20
|
+
return options.semaphore;
|
|
21
|
+
if (options.concurrency === undefined)
|
|
22
|
+
return apiSemaphore;
|
|
23
|
+
if (!Number.isSafeInteger(options.concurrency) || options.concurrency < 1) {
|
|
24
|
+
throw new RangeError("parallel concurrency must be a positive safe integer");
|
|
25
|
+
}
|
|
26
|
+
return new Semaphore(options.concurrency);
|
|
27
|
+
}
|
|
18
28
|
async function acquireOrThrow(semaphore, timeoutMs, label) {
|
|
19
29
|
const acquired = await semaphore.tryAcquire(timeoutMs);
|
|
20
30
|
if (acquired)
|
|
@@ -28,7 +38,7 @@ export function parallelMap(items, fn, options = {}) {
|
|
|
28
38
|
return withSpan("utils.parallelMap", async () => {
|
|
29
39
|
if (items.length === 0)
|
|
30
40
|
return [];
|
|
31
|
-
const semaphore = options
|
|
41
|
+
const semaphore = resolveParallelSemaphore(options);
|
|
32
42
|
const timeoutMs = options.timeoutMs ?? ACQUIRE_TIMEOUT_MS;
|
|
33
43
|
const results = new Array(items.length);
|
|
34
44
|
await Promise.all(items.map(async (item, index) => {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MAX_OPAQUE_ID_CODE_UNITS, MAX_PROJECT_SLUG_CODE_UNITS } from "./constants/project-identity.js";
|
|
2
|
+
/** Whether a string contains a Unicode Cc control code point. */
|
|
3
|
+
export declare function hasProjectIdentityControlCharacters(value: string): boolean;
|
|
4
|
+
/** Normalize optional whitespace surrounding an upstream project slug. */
|
|
5
|
+
export declare function normalizeProjectSlug(value: string): string;
|
|
6
|
+
/** Whether a value is a bounded, exact opaque identifier. */
|
|
7
|
+
export declare function isCanonicalOpaqueProjectIdentifier(value: unknown): value is string;
|
|
8
|
+
/** Whether a normalized value is a canonical hosted project slug. */
|
|
9
|
+
export declare function isCanonicalProjectSlug(value: string): boolean;
|
|
10
|
+
export { MAX_OPAQUE_ID_CODE_UNITS, MAX_PROJECT_SLUG_CODE_UNITS };
|
|
11
|
+
//# sourceMappingURL=project-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-identity.d.ts","sourceRoot":"","sources":["../../../src/src/utils/project-identity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC5B,MAAM,iCAAiC,CAAC;AAiCzC,iEAAiE;AACjE,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQ1E;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,6DAA6D;AAC7D,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CASlF;AAED,qEAAqE;AACrE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAiB7D;AAED,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MAX_OPAQUE_ID_CODE_UNITS, MAX_PROJECT_SLUG_CODE_UNITS, } from "./constants/project-identity.js";
|
|
2
|
+
const ReflectApply = Reflect.apply;
|
|
3
|
+
const StringPrototypeCharCodeAt = String.prototype.charCodeAt;
|
|
4
|
+
const StringPrototypeTrim = String.prototype.trim;
|
|
5
|
+
function charCodeAt(value, index) {
|
|
6
|
+
return ReflectApply(StringPrototypeCharCodeAt, value, [index]);
|
|
7
|
+
}
|
|
8
|
+
function isAsciiLetterOrDigit(code) {
|
|
9
|
+
return ((code >= 0x30 && code <= 0x39) ||
|
|
10
|
+
(code >= 0x41 && code <= 0x5a) ||
|
|
11
|
+
(code >= 0x61 && code <= 0x7a));
|
|
12
|
+
}
|
|
13
|
+
function isWellFormedUtf16(value) {
|
|
14
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
15
|
+
const code = charCodeAt(value, index);
|
|
16
|
+
if (code >= 0xd800 && code <= 0xdbff) {
|
|
17
|
+
if (index + 1 >= value.length)
|
|
18
|
+
return false;
|
|
19
|
+
const low = charCodeAt(value, index + 1);
|
|
20
|
+
if (low < 0xdc00 || low > 0xdfff)
|
|
21
|
+
return false;
|
|
22
|
+
index += 1;
|
|
23
|
+
}
|
|
24
|
+
else if (code >= 0xdc00 && code <= 0xdfff) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
/** Whether a string contains a Unicode Cc control code point. */
|
|
31
|
+
export function hasProjectIdentityControlCharacters(value) {
|
|
32
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
33
|
+
const code = charCodeAt(value, index);
|
|
34
|
+
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/** Normalize optional whitespace surrounding an upstream project slug. */
|
|
41
|
+
export function normalizeProjectSlug(value) {
|
|
42
|
+
return ReflectApply(StringPrototypeTrim, value, []);
|
|
43
|
+
}
|
|
44
|
+
/** Whether a value is a bounded, exact opaque identifier. */
|
|
45
|
+
export function isCanonicalOpaqueProjectIdentifier(value) {
|
|
46
|
+
return (typeof value === "string" &&
|
|
47
|
+
value.length > 0 &&
|
|
48
|
+
value.length <= MAX_OPAQUE_ID_CODE_UNITS &&
|
|
49
|
+
isWellFormedUtf16(value) &&
|
|
50
|
+
value === normalizeProjectSlug(value) &&
|
|
51
|
+
!hasProjectIdentityControlCharacters(value));
|
|
52
|
+
}
|
|
53
|
+
/** Whether a normalized value is a canonical hosted project slug. */
|
|
54
|
+
export function isCanonicalProjectSlug(value) {
|
|
55
|
+
if (value.length === 0 ||
|
|
56
|
+
value.length > MAX_PROJECT_SLUG_CODE_UNITS ||
|
|
57
|
+
!isAsciiLetterOrDigit(charCodeAt(value, 0)) ||
|
|
58
|
+
!isAsciiLetterOrDigit(charCodeAt(value, value.length - 1))) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
for (let index = 1; index < value.length - 1; index += 1) {
|
|
62
|
+
const code = charCodeAt(value, index);
|
|
63
|
+
if (!isAsciiLetterOrDigit(code) && code !== 0x2d) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
export { MAX_OPAQUE_ID_CODE_UNITS, MAX_PROJECT_SLUG_CODE_UNITS };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veryfront/ext-content-mdx",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1189",
|
|
4
4
|
"description": "Veryfront first-party extension package for ext-content-mdx",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"veryfront",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"scripts": {},
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=22.3.0"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"vfile": "6.0.3"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
|
-
"veryfront": "^0.1.
|
|
70
|
+
"veryfront": "^0.1.1189"
|
|
71
71
|
},
|
|
72
72
|
"type": "module",
|
|
73
73
|
"types": "./esm/extensions/ext-content-mdx/src/index.d.ts",
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
interface SnapshotStat {
|
|
2
|
-
readonly dev: bigint;
|
|
3
|
-
readonly ino: bigint;
|
|
4
|
-
readonly size: bigint;
|
|
5
|
-
readonly mtimeNs: bigint;
|
|
6
|
-
readonly ctimeNs: bigint;
|
|
7
|
-
isFile(): boolean;
|
|
8
|
-
isSymbolicLink(): boolean;
|
|
9
|
-
}
|
|
10
|
-
interface SnapshotHandle {
|
|
11
|
-
stat(): Promise<SnapshotStat>;
|
|
12
|
-
read(buffer: Uint8Array, offset: number, length: number, position: number): Promise<{
|
|
13
|
-
bytesRead: number;
|
|
14
|
-
}>;
|
|
15
|
-
writeFile(content: Uint8Array): Promise<void>;
|
|
16
|
-
close(): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export interface NativeSnapshotOperations {
|
|
19
|
-
realpath(path: string): Promise<string>;
|
|
20
|
-
lstat(path: string): Promise<SnapshotStat>;
|
|
21
|
-
open(path: string, flags: number | string): Promise<SnapshotHandle>;
|
|
22
|
-
}
|
|
23
|
-
/** Whether the runtime can enforce a no-follow native snapshot open. */
|
|
24
|
-
export declare function supportsNativeFileSnapshots(platform?: "posix" | "windows"): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Read one verified regular-file generation without following a terminal link.
|
|
27
|
-
* Identity and generation are checked before and after the bounded positional read.
|
|
28
|
-
*/
|
|
29
|
-
export declare function readNodeFileSnapshotWithinLimit(path: string, containmentRoot: string, byteLimit: number, operations?: NativeSnapshotOperations): Promise<Uint8Array>;
|
|
30
|
-
/** Create a new file without replacement and join handle cleanup. */
|
|
31
|
-
export declare function createNodeFileBytesExclusive(path: string, content: Uint8Array, operations?: NativeSnapshotOperations): Promise<void>;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=native-file-capabilities.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"native-file-capabilities.d.ts","sourceRoot":"","sources":["../../../../../../src/src/platform/adapters/runtime/shared/native-file-capabilities.ts"],"names":[],"mappings":"AAIA,UAAU,YAAY;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,MAAM,IAAI,OAAO,CAAC;IAClB,cAAc,IAAI,OAAO,CAAC;CAC3B;AAED,UAAU,cAAc;IACtB,IAAI,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9B,IAAI,CACF,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,SAAS,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACrE;AAED,wEAAwE;AACxE,wBAAgB,2BAA2B,CACzC,QAAQ,GAAE,OAAO,GAAG,SAA2D,GAC9E,OAAO,CAET;AAkFD;;;GAGG;AACH,wBAAsB,+BAA+B,CACnD,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,UAAU,CAAC,EAAE,wBAAwB,GACpC,OAAO,CAAC,UAAU,CAAC,CAsHrB;AAED,qEAAqE;AACrE,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,UAAU,EACnB,UAAU,CAAC,EAAE,wBAAwB,GACpC,OAAO,CAAC,IAAI,CAAC,CAYf"}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { isAbsolute, relative, resolve, sep } from "../../../compat/path/index.js";
|
|
2
|
-
import { runtimeUsesWindowsPaths } from "../../../compat/path/portable.js";
|
|
3
|
-
import { FileSnapshotChangedError } from "../../file-snapshot-error.js";
|
|
4
|
-
/** Whether the runtime can enforce a no-follow native snapshot open. */
|
|
5
|
-
export function supportsNativeFileSnapshots(platform = runtimeUsesWindowsPaths() ? "windows" : "posix") {
|
|
6
|
-
return platform === "posix";
|
|
7
|
-
}
|
|
8
|
-
function toSnapshotStat(stats) {
|
|
9
|
-
return {
|
|
10
|
-
dev: stats.dev,
|
|
11
|
-
ino: stats.ino,
|
|
12
|
-
size: stats.size,
|
|
13
|
-
mtimeNs: stats.mtimeNs,
|
|
14
|
-
ctimeNs: stats.ctimeNs,
|
|
15
|
-
isFile: () => stats.isFile(),
|
|
16
|
-
isSymbolicLink: () => stats.isSymbolicLink(),
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
async function defaultOperations() {
|
|
20
|
-
const fs = await import("node:fs/promises");
|
|
21
|
-
return {
|
|
22
|
-
realpath: (path) => fs.realpath(path),
|
|
23
|
-
async lstat(path) {
|
|
24
|
-
return toSnapshotStat(await fs.lstat(path, { bigint: true }));
|
|
25
|
-
},
|
|
26
|
-
async open(path, flags) {
|
|
27
|
-
const handle = await fs.open(path, flags);
|
|
28
|
-
return {
|
|
29
|
-
async stat() {
|
|
30
|
-
return toSnapshotStat(await handle.stat({ bigint: true }));
|
|
31
|
-
},
|
|
32
|
-
read: (buffer, offset, length, position) => handle.read(buffer, offset, length, position),
|
|
33
|
-
writeFile: (content) => handle.writeFile(content),
|
|
34
|
-
close: () => handle.close(),
|
|
35
|
-
};
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function requireByteLimit(value) {
|
|
40
|
-
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
41
|
-
throw new RangeError("Snapshot byte limit must be a positive safe integer");
|
|
42
|
-
}
|
|
43
|
-
return value;
|
|
44
|
-
}
|
|
45
|
-
function isContainedPath(path, root) {
|
|
46
|
-
const relation = relative(root, path);
|
|
47
|
-
return relation === "" ||
|
|
48
|
-
(relation !== ".." && !relation.startsWith(`..${sep}`) && !isAbsolute(relation));
|
|
49
|
-
}
|
|
50
|
-
function sameIdentity(left, right) {
|
|
51
|
-
return left.dev === right.dev && left.ino === right.ino;
|
|
52
|
-
}
|
|
53
|
-
function sameGeneration(left, right) {
|
|
54
|
-
return sameIdentity(left, right) && left.size === right.size &&
|
|
55
|
-
left.mtimeNs === right.mtimeNs && left.ctimeNs === right.ctimeNs;
|
|
56
|
-
}
|
|
57
|
-
function changed(message, cause) {
|
|
58
|
-
const error = new FileSnapshotChangedError(message);
|
|
59
|
-
if (cause !== undefined)
|
|
60
|
-
Object.defineProperty(error, "cause", { value: cause });
|
|
61
|
-
return error;
|
|
62
|
-
}
|
|
63
|
-
async function closeSnapshotHandle(handle, primaryFailure, failed) {
|
|
64
|
-
try {
|
|
65
|
-
await handle.close();
|
|
66
|
-
}
|
|
67
|
-
catch (cleanupFailure) {
|
|
68
|
-
if (failed) {
|
|
69
|
-
throw new AggregateError([primaryFailure, cleanupFailure], "Filesystem snapshot read and handle cleanup both failed");
|
|
70
|
-
}
|
|
71
|
-
throw cleanupFailure;
|
|
72
|
-
}
|
|
73
|
-
if (failed)
|
|
74
|
-
throw primaryFailure;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Read one verified regular-file generation without following a terminal link.
|
|
78
|
-
* Identity and generation are checked before and after the bounded positional read.
|
|
79
|
-
*/
|
|
80
|
-
export async function readNodeFileSnapshotWithinLimit(path, containmentRoot, byteLimit, operations) {
|
|
81
|
-
const admittedLimit = requireByteLimit(byteLimit);
|
|
82
|
-
const lexicalRoot = resolve(containmentRoot);
|
|
83
|
-
const candidate = resolve(path);
|
|
84
|
-
const fsOperations = operations ?? await defaultOperations();
|
|
85
|
-
const { constants } = await import("node:fs");
|
|
86
|
-
if (!Number.isSafeInteger(constants.O_NOFOLLOW) || constants.O_NOFOLLOW === 0) {
|
|
87
|
-
throw new TypeError("This runtime cannot guarantee no-follow snapshot opens");
|
|
88
|
-
}
|
|
89
|
-
const canonicalRoot = await fsOperations.realpath(lexicalRoot);
|
|
90
|
-
if (!isContainedPath(candidate, lexicalRoot) &&
|
|
91
|
-
!isContainedPath(candidate, canonicalRoot)) {
|
|
92
|
-
throw new TypeError("Snapshot path must be contained by the requested root");
|
|
93
|
-
}
|
|
94
|
-
const pathnameBefore = await fsOperations.lstat(candidate);
|
|
95
|
-
if (pathnameBefore.isSymbolicLink()) {
|
|
96
|
-
throw new TypeError("Snapshot path must not be a symbolic link");
|
|
97
|
-
}
|
|
98
|
-
if (!pathnameBefore.isFile()) {
|
|
99
|
-
throw new TypeError("Snapshot path must identify a regular file");
|
|
100
|
-
}
|
|
101
|
-
let handle;
|
|
102
|
-
try {
|
|
103
|
-
handle = await fsOperations.open(candidate, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
104
|
-
}
|
|
105
|
-
catch (cause) {
|
|
106
|
-
throw changed("File identity became uncertain while opening the snapshot", cause);
|
|
107
|
-
}
|
|
108
|
-
let failed = false;
|
|
109
|
-
let primaryFailure;
|
|
110
|
-
let result;
|
|
111
|
-
try {
|
|
112
|
-
let handleBefore;
|
|
113
|
-
try {
|
|
114
|
-
handleBefore = await handle.stat();
|
|
115
|
-
}
|
|
116
|
-
catch (cause) {
|
|
117
|
-
throw changed("Opened file identity could not be verified", cause);
|
|
118
|
-
}
|
|
119
|
-
if (!handleBefore.isFile() || !sameGeneration(pathnameBefore, handleBefore)) {
|
|
120
|
-
throw changed("File identity changed while opening the snapshot");
|
|
121
|
-
}
|
|
122
|
-
let canonicalTarget;
|
|
123
|
-
let pathnameOpened;
|
|
124
|
-
try {
|
|
125
|
-
[canonicalTarget, pathnameOpened] = await Promise.all([
|
|
126
|
-
fsOperations.realpath(candidate),
|
|
127
|
-
fsOperations.lstat(candidate),
|
|
128
|
-
]);
|
|
129
|
-
}
|
|
130
|
-
catch (cause) {
|
|
131
|
-
throw changed("File target became uncertain while opening the snapshot", cause);
|
|
132
|
-
}
|
|
133
|
-
if (pathnameOpened.isSymbolicLink() || !pathnameOpened.isFile() ||
|
|
134
|
-
!sameGeneration(handleBefore, pathnameOpened)) {
|
|
135
|
-
throw changed("File identity changed while opening the snapshot");
|
|
136
|
-
}
|
|
137
|
-
if (!isContainedPath(canonicalTarget, canonicalRoot)) {
|
|
138
|
-
throw new TypeError("Snapshot target must be contained by the canonical root");
|
|
139
|
-
}
|
|
140
|
-
if (handleBefore.size < 0n) {
|
|
141
|
-
throw changed("File size became uncertain while opening the snapshot");
|
|
142
|
-
}
|
|
143
|
-
if (handleBefore.size > BigInt(admittedLimit)) {
|
|
144
|
-
throw new RangeError(`File exceeds byte limit of ${admittedLimit} bytes`);
|
|
145
|
-
}
|
|
146
|
-
const size = Number(handleBefore.size);
|
|
147
|
-
let bytes;
|
|
148
|
-
try {
|
|
149
|
-
bytes = new Uint8Array(size);
|
|
150
|
-
}
|
|
151
|
-
catch (cause) {
|
|
152
|
-
throw new Error("Unable to allocate the admitted snapshot buffer", { cause });
|
|
153
|
-
}
|
|
154
|
-
let offset = 0;
|
|
155
|
-
while (offset < size) {
|
|
156
|
-
const { bytesRead } = await handle.read(bytes, offset, size - offset, offset);
|
|
157
|
-
if (!Number.isSafeInteger(bytesRead) || bytesRead <= 0 || bytesRead > size - offset) {
|
|
158
|
-
throw changed("File size changed while reading the snapshot");
|
|
159
|
-
}
|
|
160
|
-
offset += bytesRead;
|
|
161
|
-
}
|
|
162
|
-
let handleAfter;
|
|
163
|
-
let pathnameAfter;
|
|
164
|
-
let canonicalTargetAfter;
|
|
165
|
-
try {
|
|
166
|
-
[handleAfter, pathnameAfter, canonicalTargetAfter] = await Promise.all([
|
|
167
|
-
handle.stat(),
|
|
168
|
-
fsOperations.lstat(candidate),
|
|
169
|
-
fsOperations.realpath(candidate),
|
|
170
|
-
]);
|
|
171
|
-
}
|
|
172
|
-
catch (cause) {
|
|
173
|
-
throw changed("File identity became uncertain after reading the snapshot", cause);
|
|
174
|
-
}
|
|
175
|
-
if (pathnameAfter.isSymbolicLink() || !pathnameAfter.isFile() ||
|
|
176
|
-
!sameGeneration(handleBefore, handleAfter) ||
|
|
177
|
-
!sameGeneration(handleBefore, pathnameAfter) ||
|
|
178
|
-
canonicalTargetAfter !== canonicalTarget ||
|
|
179
|
-
!isContainedPath(canonicalTargetAfter, canonicalRoot)) {
|
|
180
|
-
throw changed("File snapshot changed during the read");
|
|
181
|
-
}
|
|
182
|
-
result = bytes;
|
|
183
|
-
}
|
|
184
|
-
catch (error) {
|
|
185
|
-
failed = true;
|
|
186
|
-
primaryFailure = error;
|
|
187
|
-
}
|
|
188
|
-
await closeSnapshotHandle(handle, primaryFailure, failed);
|
|
189
|
-
return result;
|
|
190
|
-
}
|
|
191
|
-
/** Create a new file without replacement and join handle cleanup. */
|
|
192
|
-
export async function createNodeFileBytesExclusive(path, content, operations) {
|
|
193
|
-
const fsOperations = operations ?? await defaultOperations();
|
|
194
|
-
const handle = await fsOperations.open(path, "wx");
|
|
195
|
-
let failed = false;
|
|
196
|
-
let primaryFailure;
|
|
197
|
-
try {
|
|
198
|
-
await handle.writeFile(content);
|
|
199
|
-
}
|
|
200
|
-
catch (error) {
|
|
201
|
-
failed = true;
|
|
202
|
-
primaryFailure = error;
|
|
203
|
-
}
|
|
204
|
-
await closeSnapshotHandle(handle, primaryFailure, failed);
|
|
205
|
-
}
|