@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
|
@@ -60,47 +60,34 @@ export function getHostEnv(key) {
|
|
|
60
60
|
return runtimeProcess.env[key];
|
|
61
61
|
return undefined;
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
63
|
+
let _trustedProjectEnvSnapshot = null;
|
|
64
|
+
/**
|
|
65
|
+
* Register the server-owned project environment snapshot bridge.
|
|
66
|
+
*
|
|
67
|
+
* Kept out of the public process barrel so project code cannot replace the
|
|
68
|
+
* callback through a supported package export. Re-registering a different
|
|
69
|
+
* function is rejected rather than silently widening an isolation boundary.
|
|
70
|
+
*/
|
|
71
|
+
export function registerTrustedProjectEnvSnapshot(getter) {
|
|
72
|
+
if (_trustedProjectEnvSnapshot && _trustedProjectEnvSnapshot !== getter) {
|
|
73
|
+
throw new Error("Project environment snapshot bridge is already registered");
|
|
78
74
|
}
|
|
79
|
-
|
|
75
|
+
_trustedProjectEnvSnapshot = getter;
|
|
80
76
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (mod) {
|
|
85
|
-
_isProjectEnvActive = mod;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return _isProjectEnvActive();
|
|
77
|
+
/** Return the active server-owned project env snapshot, if registered. */
|
|
78
|
+
export function getTrustedProjectEnvSnapshot() {
|
|
79
|
+
return _trustedProjectEnvSnapshot?.();
|
|
92
80
|
}
|
|
93
81
|
/** Read an environment variable from the active project scope. */
|
|
94
82
|
export function getEnv(key) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return undefined;
|
|
83
|
+
const projectEnv = getTrustedProjectEnvSnapshot();
|
|
84
|
+
if (projectEnv !== undefined) {
|
|
85
|
+
// The registered snapshot is authoritative even when the requested key is
|
|
86
|
+
// absent. Falling through here would expose host process configuration to
|
|
87
|
+
// a remote project. Never discover this boundary through replaceable
|
|
88
|
+
// globalThis hooks.
|
|
89
|
+
return projectEnv[key];
|
|
90
|
+
}
|
|
104
91
|
return getHostEnv(key);
|
|
105
92
|
}
|
|
106
93
|
const DEFAULT_ENV_TRUE_VALUES = ["1", "true", "yes"];
|
|
@@ -119,8 +106,11 @@ export function getEnvNumber(key, fallback) {
|
|
|
119
106
|
const value = getEnvString(key);
|
|
120
107
|
if (value === undefined)
|
|
121
108
|
return fallback;
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
109
|
+
const normalized = value.trim();
|
|
110
|
+
if (!/^[+-]?\d+$/.test(normalized))
|
|
111
|
+
return fallback ?? Number.NaN;
|
|
112
|
+
const parsed = Number(normalized);
|
|
113
|
+
if (!Number.isSafeInteger(parsed))
|
|
124
114
|
return fallback ?? Number.NaN;
|
|
125
115
|
return parsed;
|
|
126
116
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type GlobalErrorType = "uncaughtException" | "unhandledRejection";
|
|
2
|
+
export type GlobalErrorHandler = (error: Error, type: GlobalErrorType) => boolean | void;
|
|
3
|
+
type HandlerFailureReporter = (error: Error, type: GlobalErrorType) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Convert an arbitrary thrown value without invoking object conversion hooks.
|
|
6
|
+
*
|
|
7
|
+
* Rejected promises and manual event dispatch can carry any JavaScript value.
|
|
8
|
+
* Calling String(value) is unsafe here because a hostile toString or
|
|
9
|
+
* Symbol.toPrimitive implementation can throw while the runtime is already
|
|
10
|
+
* handling a global failure.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeGlobalError(value: unknown): Error;
|
|
13
|
+
/**
|
|
14
|
+
* Invoke a global error callback while preserving the runtime's fatal default
|
|
15
|
+
* when the callback itself fails.
|
|
16
|
+
*/
|
|
17
|
+
export declare function invokeGlobalErrorHandler(handler: GlobalErrorHandler, error: Error, type: GlobalErrorType, reportFailure?: HandlerFailureReporter): boolean;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=global-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-error.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/global-error.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;AAEzE,MAAM,MAAM,kBAAkB,GAAG,CAC/B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,eAAe,KAClB,OAAO,GAAG,IAAI,CAAC;AAEpB,KAAK,sBAAsB,GAAG,CAC5B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,eAAe,KAClB,IAAI,CAAC;AAIV;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAgB1D;AAwBD;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,eAAe,EACrB,aAAa,GAAE,sBAA6C,GAC3D,OAAO,CAOT"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const NON_ERROR_VALUE_MESSAGE = "A non-Error object was thrown";
|
|
2
|
+
/**
|
|
3
|
+
* Convert an arbitrary thrown value without invoking object conversion hooks.
|
|
4
|
+
*
|
|
5
|
+
* Rejected promises and manual event dispatch can carry any JavaScript value.
|
|
6
|
+
* Calling String(value) is unsafe here because a hostile toString or
|
|
7
|
+
* Symbol.toPrimitive implementation can throw while the runtime is already
|
|
8
|
+
* handling a global failure.
|
|
9
|
+
*/
|
|
10
|
+
export function normalizeGlobalError(value) {
|
|
11
|
+
if (value instanceof Error)
|
|
12
|
+
return value;
|
|
13
|
+
if (value === null)
|
|
14
|
+
return new Error("null");
|
|
15
|
+
switch (typeof value) {
|
|
16
|
+
case "string":
|
|
17
|
+
return new Error(value);
|
|
18
|
+
case "number":
|
|
19
|
+
case "boolean":
|
|
20
|
+
case "bigint":
|
|
21
|
+
case "symbol":
|
|
22
|
+
case "undefined":
|
|
23
|
+
return new Error(String(value));
|
|
24
|
+
default:
|
|
25
|
+
return new Error(NON_ERROR_VALUE_MESSAGE);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function reportHandlerFailure(error, type) {
|
|
29
|
+
let message = "Unknown handler failure";
|
|
30
|
+
try {
|
|
31
|
+
if (typeof error.message === "string" && error.message) {
|
|
32
|
+
message = error.message;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Error.message can be replaced with a throwing accessor.
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
console.error(`Global error handler threw while processing ${type}: ${message}`);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
// A replaced console implementation must not recurse into global handling.
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Invoke a global error callback while preserving the runtime's fatal default
|
|
47
|
+
* when the callback itself fails.
|
|
48
|
+
*/
|
|
49
|
+
export function invokeGlobalErrorHandler(handler, error, type, reportFailure = reportHandlerFailure) {
|
|
50
|
+
try {
|
|
51
|
+
return handler(error, type) === true;
|
|
52
|
+
}
|
|
53
|
+
catch (handlerError) {
|
|
54
|
+
reportFailure(normalizeGlobalError(handlerError), type);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as dntShim from "../../../../_dnt.shims.js";
|
|
2
|
+
import { type GlobalErrorHandler } from "./global-error.js";
|
|
2
3
|
/** Get command-line arguments (cross-runtime: Deno.args or process.argv). */
|
|
3
4
|
export declare function getArgs(): string[];
|
|
4
5
|
/** Exit the process with an optional code (cross-runtime: Deno.exit or process.exit). */
|
|
@@ -39,9 +40,15 @@ export declare function getRuntimeVersion(): string;
|
|
|
39
40
|
*/
|
|
40
41
|
export declare function getOsType(): string;
|
|
41
42
|
/**
|
|
42
|
-
* Register a
|
|
43
|
+
* Register a SIGINT or SIGTERM handler for graceful shutdown.
|
|
44
|
+
*
|
|
45
|
+
* If registration fails after a runtime partially installs the handler, this
|
|
46
|
+
* function removes that exact registration. When removal also fails, both
|
|
47
|
+
* failures are exposed in registration-first order through an AggregateError.
|
|
48
|
+
*
|
|
49
|
+
* @returns An idempotent disposer for the exact signal and handler pair.
|
|
43
50
|
*/
|
|
44
|
-
export declare function onSignal(signal: "SIGINT" | "SIGTERM", handler: () => void): void;
|
|
51
|
+
export declare function onSignal(signal: "SIGINT" | "SIGTERM", handler: () => void): () => void;
|
|
45
52
|
/**
|
|
46
53
|
* Register global error handlers for uncaught exceptions and unhandled promise rejections.
|
|
47
54
|
* These handlers prevent the process from crashing due to application code errors.
|
|
@@ -51,7 +58,7 @@ export declare function onSignal(signal: "SIGINT" | "SIGTERM", handler: () => vo
|
|
|
51
58
|
*
|
|
52
59
|
* @param onError - Callback invoked with the error. Return true to prevent process exit.
|
|
53
60
|
*/
|
|
54
|
-
export declare function onGlobalError(onError:
|
|
61
|
+
export declare function onGlobalError(onError: GlobalErrorHandler): void;
|
|
55
62
|
/**
|
|
56
63
|
* Unreference a timer to prevent it from keeping the process alive
|
|
57
64
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,2BAA2B,CAAC;AAErD,OAAO,EACL,KAAK,kBAAkB,EAGxB,MAAM,mBAAmB,CAAC;AAG3B,6EAA6E;AAC7E,wBAAgB,OAAO,IAAI,MAAM,EAAE,CAKlC;AAED,yFAAyF;AACzF,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAKzC;AAED,4CAA4C;AAC5C,wBAAgB,GAAG,IAAI,MAAM,CAK5B;AAED,wBAAgB,KAAK,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAW7C;AAED,wBAAgB,GAAG,IAAI,MAAM,CAK5B;AAED,wBAAgB,WAAW,IAAI;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAaA;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAKvC;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAKrC;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAqBnE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,MAAM,CASlC;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,QAAQ,GAAG,SAAS,EAC5B,OAAO,EAAE,MAAM,IAAI,GAClB,MAAM,IAAI,CA+CZ;AAgBD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,kBAAkB,GAC1B,IAAI,CAgDN;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAahF;AAED;;GAEG;AACH,wBAAgB,QAAQ,IAAI,MAAM,CAKjC;AAED;;;GAGG;AACH,wBAAgB,MAAM,IAAI,MAAM,CAW/B;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI;IAAE,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAAG,IAAI,CAWpE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAexE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1D;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAuBjD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as dntShim from "../../../../_dnt.shims.js";
|
|
2
2
|
import { getDenoRuntime, isBun as IS_BUN, isDeno as IS_DENO } from "../runtime.js";
|
|
3
|
+
import { invokeGlobalErrorHandler, normalizeGlobalError, } from "./global-error.js";
|
|
3
4
|
import { runtimeProcess } from "./runtime-process.js";
|
|
4
5
|
/** Get command-line arguments (cross-runtime: Deno.args or process.argv). */
|
|
5
6
|
export function getArgs() {
|
|
@@ -137,16 +138,75 @@ export function getOsType() {
|
|
|
137
138
|
return "unknown";
|
|
138
139
|
}
|
|
139
140
|
/**
|
|
140
|
-
* Register a
|
|
141
|
+
* Register a SIGINT or SIGTERM handler for graceful shutdown.
|
|
142
|
+
*
|
|
143
|
+
* If registration fails after a runtime partially installs the handler, this
|
|
144
|
+
* function removes that exact registration. When removal also fails, both
|
|
145
|
+
* failures are exposed in registration-first order through an AggregateError.
|
|
146
|
+
*
|
|
147
|
+
* @returns An idempotent disposer for the exact signal and handler pair.
|
|
141
148
|
*/
|
|
142
149
|
export function onSignal(signal, handler) {
|
|
143
150
|
const deno = IS_DENO ? getDenoRuntime() : undefined;
|
|
144
151
|
if (deno) {
|
|
145
|
-
|
|
146
|
-
|
|
152
|
+
try {
|
|
153
|
+
deno.addSignalListener(signal, handler);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
// Older Deno builds can retain the callback before native binding fails.
|
|
157
|
+
try {
|
|
158
|
+
deno.removeSignalListener(signal, handler);
|
|
159
|
+
}
|
|
160
|
+
catch (cleanupError) {
|
|
161
|
+
throw new AggregateError([error, cleanupError], `Failed to register and roll back ${signal} handler`);
|
|
162
|
+
}
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
return createIdempotentDisposer(() => {
|
|
166
|
+
deno.removeSignalListener(signal, handler);
|
|
167
|
+
});
|
|
147
168
|
}
|
|
148
|
-
if (runtimeProcess)
|
|
149
|
-
runtimeProcess
|
|
169
|
+
if (runtimeProcess) {
|
|
170
|
+
const process = runtimeProcess;
|
|
171
|
+
const remove = () => {
|
|
172
|
+
if (typeof process.off === "function") {
|
|
173
|
+
process.off(signal, handler);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
process.removeListener(signal, handler);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
try {
|
|
180
|
+
process.on(signal, handler);
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
// A runtime hook can throw after installing the listener.
|
|
184
|
+
try {
|
|
185
|
+
remove();
|
|
186
|
+
}
|
|
187
|
+
catch (cleanupError) {
|
|
188
|
+
throw new AggregateError([error, cleanupError], `Failed to register and roll back ${signal} handler`);
|
|
189
|
+
}
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
return createIdempotentDisposer(remove);
|
|
193
|
+
}
|
|
194
|
+
return () => { };
|
|
195
|
+
}
|
|
196
|
+
function createIdempotentDisposer(dispose) {
|
|
197
|
+
let active = true;
|
|
198
|
+
return () => {
|
|
199
|
+
if (!active)
|
|
200
|
+
return;
|
|
201
|
+
active = false;
|
|
202
|
+
try {
|
|
203
|
+
dispose();
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
active = true;
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
};
|
|
150
210
|
}
|
|
151
211
|
/**
|
|
152
212
|
* Register global error handlers for uncaught exceptions and unhandled promise rejections.
|
|
@@ -161,14 +221,16 @@ export function onGlobalError(onError) {
|
|
|
161
221
|
if (IS_DENO) {
|
|
162
222
|
// Intentionally permanent: process-level handlers must persist for the entire runtime
|
|
163
223
|
globalThis.addEventListener("error", (event) => {
|
|
164
|
-
const error =
|
|
165
|
-
if (onError
|
|
224
|
+
const error = normalizeGlobalError(event.error);
|
|
225
|
+
if (invokeGlobalErrorHandler(onError, error, "uncaughtException")) {
|
|
166
226
|
event.preventDefault();
|
|
227
|
+
}
|
|
167
228
|
});
|
|
168
229
|
globalThis.addEventListener("unhandledrejection", (event) => {
|
|
169
|
-
const error =
|
|
170
|
-
if (onError
|
|
230
|
+
const error = normalizeGlobalError(event.reason);
|
|
231
|
+
if (invokeGlobalErrorHandler(onError, error, "unhandledRejection")) {
|
|
171
232
|
event.preventDefault();
|
|
233
|
+
}
|
|
172
234
|
});
|
|
173
235
|
return;
|
|
174
236
|
}
|
|
@@ -176,17 +238,7 @@ export function onGlobalError(onError) {
|
|
|
176
238
|
return;
|
|
177
239
|
const process = runtimeProcess;
|
|
178
240
|
const handleNodeGlobalError = (error, type) => {
|
|
179
|
-
|
|
180
|
-
try {
|
|
181
|
-
shouldPreventExit = onError(error, type) === true;
|
|
182
|
-
}
|
|
183
|
-
catch (handlerError) {
|
|
184
|
-
const handlerException = handlerError instanceof Error
|
|
185
|
-
? handlerError
|
|
186
|
-
: new Error(String(handlerError));
|
|
187
|
-
console.error("Global error handler threw while processing", type, handlerException);
|
|
188
|
-
}
|
|
189
|
-
if (shouldPreventExit)
|
|
241
|
+
if (invokeGlobalErrorHandler(onError, error, type))
|
|
190
242
|
return;
|
|
191
243
|
// Node/Bun suppress default fatal behavior when a listener is registered.
|
|
192
244
|
// If the callback did not explicitly handle the error, exit to preserve
|
|
@@ -194,11 +246,10 @@ export function onGlobalError(onError) {
|
|
|
194
246
|
process.exit(1);
|
|
195
247
|
};
|
|
196
248
|
runtimeProcess.on("uncaughtException", (error) => {
|
|
197
|
-
handleNodeGlobalError(error, "uncaughtException");
|
|
249
|
+
handleNodeGlobalError(normalizeGlobalError(error), "uncaughtException");
|
|
198
250
|
});
|
|
199
251
|
runtimeProcess.on("unhandledRejection", (reason) => {
|
|
200
|
-
|
|
201
|
-
handleNodeGlobalError(error, "unhandledRejection");
|
|
252
|
+
handleNodeGlobalError(normalizeGlobalError(reason), "unhandledRejection");
|
|
202
253
|
});
|
|
203
254
|
}
|
|
204
255
|
/**
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level project environment contract shared by server admission and
|
|
3
|
+
* routing worker boundaries.
|
|
4
|
+
*
|
|
5
|
+
* Keep this module free of runtime and server dependencies so higher layers
|
|
6
|
+
* can share one immutable contract without reversing dependency direction.
|
|
7
|
+
*
|
|
8
|
+
* @module platform/compat/process/project-env-contract
|
|
9
|
+
*/
|
|
10
|
+
/** Immutable project environment admitted to runtime and worker boundaries. */
|
|
11
|
+
export type ProjectEnvSnapshot = Readonly<Record<string, string>>;
|
|
12
|
+
/** Fixed resource limits for every project environment admission boundary. */
|
|
13
|
+
export declare const PROJECT_ENV_SNAPSHOT_LIMITS: Readonly<{
|
|
14
|
+
maxEntries: 128;
|
|
15
|
+
maxKeyChars: 1024;
|
|
16
|
+
maxValueChars: number;
|
|
17
|
+
maxUtf8Bytes: number;
|
|
18
|
+
}>;
|
|
19
|
+
//# sourceMappingURL=project-env-contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-env-contract.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/process/project-env-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE,8EAA8E;AAC9E,eAAO,MAAM,2BAA2B;;;;;EAOtC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level project environment contract shared by server admission and
|
|
3
|
+
* routing worker boundaries.
|
|
4
|
+
*
|
|
5
|
+
* Keep this module free of runtime and server dependencies so higher layers
|
|
6
|
+
* can share one immutable contract without reversing dependency direction.
|
|
7
|
+
*
|
|
8
|
+
* @module platform/compat/process/project-env-contract
|
|
9
|
+
*/
|
|
10
|
+
const objectFreeze = Object.freeze;
|
|
11
|
+
/** Fixed resource limits for every project environment admission boundary. */
|
|
12
|
+
export const PROJECT_ENV_SNAPSHOT_LIMITS = objectFreeze({
|
|
13
|
+
// The API returns at most 100 tenant entries. Runtime-owned scoped values
|
|
14
|
+
// may be added afterward without exceeding this boundary.
|
|
15
|
+
maxEntries: 128,
|
|
16
|
+
maxKeyChars: 1_024,
|
|
17
|
+
maxValueChars: 1024 * 1024,
|
|
18
|
+
maxUtf8Bytes: 1024 * 1024,
|
|
19
|
+
});
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
export type RuntimeKind = "bun" | "cloudflare" | "deno" | "node" | "unknown";
|
|
3
|
+
/** @internal Exported so overlapping host signals can be regression-tested. */
|
|
4
|
+
export declare function classifyRuntimeSignals(signals: {
|
|
5
|
+
bun: boolean;
|
|
6
|
+
cloudflare: boolean;
|
|
7
|
+
deno: boolean;
|
|
8
|
+
node: boolean;
|
|
9
|
+
}): RuntimeKind;
|
|
2
10
|
export declare function getDenoRuntime(): typeof dntShim.Deno | undefined;
|
|
3
11
|
/**
|
|
4
12
|
* Check if an executable path is a compiled Deno binary.
|
|
@@ -6,11 +14,14 @@ export declare function getDenoRuntime(): typeof dntShim.Deno | undefined;
|
|
|
6
14
|
* @internal Exported for testing only.
|
|
7
15
|
*/
|
|
8
16
|
export declare function testDenoCompiledDetection(execPath: string, standalone?: boolean): boolean;
|
|
9
|
-
|
|
17
|
+
export declare const runtimeKind: RuntimeKind;
|
|
18
|
+
/** True if running in Bun runtime (Bun also exposes process.versions.node). */
|
|
10
19
|
export declare const isBun: boolean;
|
|
11
|
-
/** True if running in
|
|
20
|
+
/** True if running in Cloudflare Workers, including nodejs_compat workers. */
|
|
21
|
+
export declare const isCloudflare: boolean;
|
|
22
|
+
/** True if running in Node.js rather than a more specific compatible host. */
|
|
12
23
|
export declare const isNode: boolean;
|
|
13
|
-
/** True if running in real Deno runtime
|
|
24
|
+
/** True if running in the real Deno runtime rather than a dnt shim. */
|
|
14
25
|
export declare const isDeno: boolean;
|
|
15
26
|
/**
|
|
16
27
|
* True if running in a compiled Deno binary.
|
|
@@ -18,8 +29,6 @@ export declare const isDeno: boolean;
|
|
|
18
29
|
* This is evaluated once at module load time.
|
|
19
30
|
*/
|
|
20
31
|
export declare const isDenoCompiled: boolean;
|
|
21
|
-
/** True if running in Cloudflare Workers runtime */
|
|
22
|
-
export declare const isCloudflare: boolean;
|
|
23
32
|
/**
|
|
24
33
|
* Detect if running in Node.js (vs Deno) at call time.
|
|
25
34
|
* Use this function instead of the constant when runtime detection needs to happen
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AAMlD,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAE7E,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,OAAO,EAAE;IAC9C,GAAG,EAAE,OAAO,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;CACf,GAAG,WAAW,CAQd;AAWD,wBAAgB,cAAc,IAAI,OAAO,OAAO,CAAC,IAAI,GAAG,SAAS,CAWhE;AAMD;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,OAAO,GAAG,OAAO,CAQzF;AAuBD,eAAO,MAAM,WAAW,EAAE,WAKxB,CAAC;AAEH,+EAA+E;AAC/E,eAAO,MAAM,KAAK,EAAE,OAA+B,CAAC;AAEpD,8EAA8E;AAC9E,eAAO,MAAM,YAAY,EAAE,OAAsC,CAAC;AAElE,8EAA8E;AAC9E,eAAO,MAAM,MAAM,EAAE,OAAgC,CAAC;AAEtD,uEAAuE;AACvE,eAAO,MAAM,MAAM,EAAE,OAAgC,CAAC;AAEtD;;;;GAIG;AACH,eAAO,MAAM,cAAc,EAAE,OAA0C,CAAC;AAExE;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAOvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAK7C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
/** @internal Exported so overlapping host signals can be regression-tested. */
|
|
3
|
+
export function classifyRuntimeSignals(signals) {
|
|
4
|
+
// Bun exposes Node compatibility globals. Cloudflare Workers can do the same
|
|
5
|
+
// when nodejs_compat is enabled, so the more specific host signals must win.
|
|
6
|
+
if (signals.bun)
|
|
7
|
+
return "bun";
|
|
8
|
+
if (signals.cloudflare)
|
|
9
|
+
return "cloudflare";
|
|
10
|
+
if (signals.node)
|
|
11
|
+
return "node";
|
|
12
|
+
if (signals.deno)
|
|
13
|
+
return "deno";
|
|
14
|
+
return "unknown";
|
|
15
|
+
}
|
|
2
16
|
function hasNodeProcess() {
|
|
3
17
|
const global = dntShim.dntGlobalThis;
|
|
4
18
|
return global.process?.versions?.node != null && !global.process?.versions?.deno;
|
|
@@ -51,27 +65,38 @@ function isDenoCompiledBinary() {
|
|
|
51
65
|
function hasCloudflareGlobals() {
|
|
52
66
|
return "caches" in dntShim.dntGlobalThis && "WebSocketPair" in dntShim.dntGlobalThis;
|
|
53
67
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
export const runtimeKind = classifyRuntimeSignals({
|
|
69
|
+
bun: hasBunGlobal(),
|
|
70
|
+
cloudflare: hasCloudflareGlobals(),
|
|
71
|
+
deno: hasRealDeno(),
|
|
72
|
+
node: hasNodeProcess(),
|
|
73
|
+
});
|
|
74
|
+
/** True if running in Bun runtime (Bun also exposes process.versions.node). */
|
|
75
|
+
export const isBun = runtimeKind === "bun";
|
|
76
|
+
/** True if running in Cloudflare Workers, including nodejs_compat workers. */
|
|
77
|
+
export const isCloudflare = runtimeKind === "cloudflare";
|
|
78
|
+
/** True if running in Node.js rather than a more specific compatible host. */
|
|
79
|
+
export const isNode = runtimeKind === "node";
|
|
80
|
+
/** True if running in the real Deno runtime rather than a dnt shim. */
|
|
81
|
+
export const isDeno = runtimeKind === "deno";
|
|
60
82
|
/**
|
|
61
83
|
* True if running in a compiled Deno binary.
|
|
62
84
|
* Compiled binaries cannot dynamically import HTTP URLs - they must use local file:// paths.
|
|
63
85
|
* This is evaluated once at module load time.
|
|
64
86
|
*/
|
|
65
87
|
export const isDenoCompiled = isDeno && isDenoCompiledBinary();
|
|
66
|
-
/** True if running in Cloudflare Workers runtime */
|
|
67
|
-
export const isCloudflare = hasCloudflareGlobals();
|
|
68
88
|
/**
|
|
69
89
|
* Detect if running in Node.js (vs Deno) at call time.
|
|
70
90
|
* Use this function instead of the constant when runtime detection needs to happen
|
|
71
91
|
* at call time (e.g., when bundled with esbuild's __esm lazy initialization pattern).
|
|
72
92
|
*/
|
|
73
93
|
export function isNodeRuntime() {
|
|
74
|
-
return
|
|
94
|
+
return classifyRuntimeSignals({
|
|
95
|
+
bun: hasBunGlobal(),
|
|
96
|
+
cloudflare: hasCloudflareGlobals(),
|
|
97
|
+
deno: false,
|
|
98
|
+
node: hasNodeProcess(),
|
|
99
|
+
}) === "node";
|
|
75
100
|
}
|
|
76
101
|
/**
|
|
77
102
|
* Detect if code is executing in a server environment (SSR).
|
|
@@ -8,6 +8,18 @@ export interface Extract<T> {
|
|
|
8
8
|
body: string;
|
|
9
9
|
frontMatter: string;
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Extracts YAML front matter with the compatibility behavior used by existing
|
|
13
|
+
* framework consumers. Scalar roots become an empty attribute object while
|
|
14
|
+
* object-like roots, including sequences, are returned unchanged.
|
|
15
|
+
*/
|
|
11
16
|
export declare function extract<T = Record<string, unknown>>(text: string): Extract<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts YAML front matter and requires its root to be a plain mapping.
|
|
19
|
+
*
|
|
20
|
+
* Use this at trust boundaries where silently coercing a scalar or sequence
|
|
21
|
+
* would hide malformed metadata.
|
|
22
|
+
*/
|
|
23
|
+
export declare function extractMapping(text: string): Extract<Record<string, unknown>>;
|
|
12
24
|
export declare function test(text: string): boolean;
|
|
13
25
|
//# sourceMappingURL=front-matter-yaml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"front-matter-yaml.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/std/front-matter-yaml.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"front-matter-yaml.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/std/front-matter-yaml.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,KAAK,EAAE,CAAC,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAuBD;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAQ7E;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkBlC;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE1C"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { parse } from "../../../../deps/jsr.io/@std/yaml/1.1.0/parse.js";
|
|
7
7
|
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)(?:\r?\n)?---(?:\r?\n|$)([\s\S]*)$/;
|
|
8
|
-
|
|
8
|
+
function extractUnknown(text) {
|
|
9
9
|
const match = text.match(FRONTMATTER_RE);
|
|
10
10
|
if (!match) {
|
|
11
11
|
return {
|
|
@@ -16,13 +16,45 @@ export function extract(text) {
|
|
|
16
16
|
}
|
|
17
17
|
const frontMatter = match[1] ?? "";
|
|
18
18
|
const parsed = frontMatter.trim() ? parse(frontMatter) : {};
|
|
19
|
-
const attrs = (parsed && typeof parsed === "object" ? parsed : {});
|
|
20
19
|
return {
|
|
21
|
-
attrs,
|
|
20
|
+
attrs: parsed,
|
|
22
21
|
body: match[2] ?? "",
|
|
23
22
|
frontMatter,
|
|
24
23
|
};
|
|
25
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Extracts YAML front matter with the compatibility behavior used by existing
|
|
27
|
+
* framework consumers. Scalar roots become an empty attribute object while
|
|
28
|
+
* object-like roots, including sequences, are returned unchanged.
|
|
29
|
+
*/
|
|
30
|
+
export function extract(text) {
|
|
31
|
+
const extracted = extractUnknown(text);
|
|
32
|
+
return {
|
|
33
|
+
...extracted,
|
|
34
|
+
attrs: (extracted.attrs && typeof extracted.attrs === "object" ? extracted.attrs : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extracts YAML front matter and requires its root to be a plain mapping.
|
|
39
|
+
*
|
|
40
|
+
* Use this at trust boundaries where silently coercing a scalar or sequence
|
|
41
|
+
* would hide malformed metadata.
|
|
42
|
+
*/
|
|
43
|
+
export function extractMapping(text) {
|
|
44
|
+
const extracted = extractUnknown(text);
|
|
45
|
+
const parsed = extracted.attrs;
|
|
46
|
+
if (!parsed ||
|
|
47
|
+
typeof parsed !== "object" ||
|
|
48
|
+
Array.isArray(parsed) ||
|
|
49
|
+
(Reflect.getPrototypeOf(parsed) !== Object.prototype &&
|
|
50
|
+
Reflect.getPrototypeOf(parsed) !== null)) {
|
|
51
|
+
throw new TypeError("YAML front matter must be a mapping");
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
...extracted,
|
|
55
|
+
attrs: parsed,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
26
58
|
export function test(text) {
|
|
27
59
|
return /^---\r?\n/.test(text);
|
|
28
60
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate a prefix before combining it with an operating-system temp root.
|
|
3
|
+
*
|
|
4
|
+
* Prefixes are file-name fragments, not paths. Rejecting separators and null
|
|
5
|
+
* bytes keeps every runtime adapter beneath its selected temp root.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateTempDirectoryPrefix(prefix: unknown): string;
|
|
8
|
+
//# sourceMappingURL=temp-directory-prefix.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"temp-directory-prefix.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/temp-directory-prefix.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAUnE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate a prefix before combining it with an operating-system temp root.
|
|
3
|
+
*
|
|
4
|
+
* Prefixes are file-name fragments, not paths. Rejecting separators and null
|
|
5
|
+
* bytes keeps every runtime adapter beneath its selected temp root.
|
|
6
|
+
*/
|
|
7
|
+
export function validateTempDirectoryPrefix(prefix) {
|
|
8
|
+
if (typeof prefix !== "string") {
|
|
9
|
+
throw new TypeError("Temporary directory prefix must be a string");
|
|
10
|
+
}
|
|
11
|
+
if (prefix.includes("/") || prefix.includes("\\") || prefix.includes("\0")) {
|
|
12
|
+
throw new TypeError("Temporary directory prefix must not contain path separators or null bytes");
|
|
13
|
+
}
|
|
14
|
+
return prefix;
|
|
15
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Convert an arbitrary abort reason into the framework's stable Error shape. */
|
|
2
|
+
export declare function createAbortError(reason?: unknown): Error;
|
|
3
|
+
/** Throw the normalized abort reason when a signal has already been aborted. */
|
|
4
|
+
export declare function throwIfAborted(abortSignal?: AbortSignal): void;
|
|
5
|
+
/**
|
|
6
|
+
* Await a value while allowing cancellation to win even when the producer
|
|
7
|
+
* ignores its signal.
|
|
8
|
+
*/
|
|
9
|
+
export declare function awaitAbortable<T>(value: T | PromiseLike<T>, abortSignal?: AbortSignal): Promise<T>;
|
|
10
|
+
//# sourceMappingURL=abort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../../src/src/utils/abort.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,KAAK,CASxD;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAI9D;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EACzB,WAAW,CAAC,EAAE,WAAW,GACxB,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
|