@veryfront/ext-content-mdx 0.1.1119 → 0.1.1122
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 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/deno.js +1 -1
- package/esm/src/config/defaults.d.ts +39 -0
- package/esm/src/config/defaults.d.ts.map +1 -0
- package/esm/src/config/defaults.js +65 -0
- package/esm/src/errors/error-registry/agent.d.ts +18 -0
- package/esm/src/errors/error-registry/agent.d.ts.map +1 -0
- package/esm/src/errors/error-registry/agent.js +60 -0
- package/esm/src/errors/error-registry/boundary.d.ts +16 -0
- package/esm/src/errors/error-registry/boundary.d.ts.map +1 -0
- package/esm/src/errors/error-registry/boundary.js +52 -0
- package/esm/src/errors/error-registry/build.d.ts +20 -0
- package/esm/src/errors/error-registry/build.d.ts.map +1 -0
- package/esm/src/errors/error-registry/build.js +68 -0
- package/esm/src/errors/error-registry/config.d.ts +31 -0
- package/esm/src/errors/error-registry/config.d.ts.map +1 -0
- package/esm/src/errors/error-registry/config.js +97 -0
- package/esm/src/errors/error-registry/deploy.d.ts +12 -0
- package/esm/src/errors/error-registry/deploy.d.ts.map +1 -0
- package/esm/src/errors/error-registry/deploy.js +36 -0
- package/esm/src/errors/error-registry/dev.d.ts +14 -0
- package/esm/src/errors/error-registry/dev.d.ts.map +1 -0
- package/esm/src/errors/error-registry/dev.js +44 -0
- package/esm/src/errors/error-registry/general.d.ts +29 -0
- package/esm/src/errors/error-registry/general.d.ts.map +1 -0
- package/esm/src/errors/error-registry/general.js +92 -0
- package/esm/src/errors/error-registry/module.d.ts +16 -0
- package/esm/src/errors/error-registry/module.d.ts.map +1 -0
- package/esm/src/errors/error-registry/module.js +52 -0
- package/esm/src/errors/error-registry/route.d.ts +16 -0
- package/esm/src/errors/error-registry/route.d.ts.map +1 -0
- package/esm/src/errors/error-registry/route.js +52 -0
- package/esm/src/errors/error-registry/runtime.d.ts +27 -0
- package/esm/src/errors/error-registry/runtime.d.ts.map +1 -0
- package/esm/src/errors/error-registry/runtime.js +87 -0
- package/esm/src/errors/error-registry/server.d.ts +39 -0
- package/esm/src/errors/error-registry/server.d.ts.map +1 -0
- package/esm/src/errors/error-registry/server.js +129 -0
- package/esm/src/errors/error-registry-helpers.d.ts +6 -0
- package/esm/src/errors/error-registry-helpers.d.ts.map +1 -0
- package/esm/src/errors/error-registry-helpers.js +9 -0
- package/esm/src/errors/error-registry.d.ts +120 -0
- package/esm/src/errors/error-registry.d.ts.map +1 -0
- package/esm/src/errors/error-registry.js +60 -0
- package/esm/src/errors/types.d.ts +84 -0
- package/esm/src/errors/types.d.ts.map +1 -0
- package/esm/src/errors/types.js +69 -0
- package/esm/src/errors/veryfront-error.d.ts +149 -0
- package/esm/src/errors/veryfront-error.d.ts.map +1 -0
- package/esm/src/errors/veryfront-error.js +61 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts +13 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.d.ts.map +1 -0
- package/esm/src/modules/react-loader/ssr-module-loader/concurrency/semaphore.js +55 -0
- package/esm/src/observability/tracing/api-shim.d.ts +191 -0
- package/esm/src/observability/tracing/api-shim.d.ts.map +1 -0
- package/esm/src/observability/tracing/api-shim.js +281 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts +63 -0
- package/esm/src/observability/tracing/otlp-setup.d.ts.map +1 -0
- package/esm/src/observability/tracing/otlp-setup.js +219 -0
- package/esm/src/observability/tracing/telemetry-env.d.ts +3 -0
- package/esm/src/observability/tracing/telemetry-env.d.ts.map +1 -0
- package/esm/src/observability/tracing/telemetry-env.js +10 -0
- package/esm/src/platform/adapters/base.d.ts +209 -0
- package/esm/src/platform/adapters/base.d.ts.map +1 -0
- package/esm/src/platform/adapters/base.js +15 -0
- package/esm/src/platform/compat/constants.d.ts +13 -0
- package/esm/src/platform/compat/constants.d.ts.map +1 -0
- package/esm/src/platform/compat/constants.js +12 -0
- package/esm/src/platform/compat/dynamic-import.d.ts +11 -0
- package/esm/src/platform/compat/dynamic-import.d.ts.map +1 -0
- package/esm/src/platform/compat/dynamic-import.js +10 -0
- package/esm/src/platform/compat/fs.d.ts +76 -0
- package/esm/src/platform/compat/fs.d.ts.map +1 -0
- package/esm/src/platform/compat/fs.js +336 -0
- package/esm/src/platform/compat/process/command.d.ts +33 -0
- package/esm/src/platform/compat/process/command.d.ts.map +1 -0
- package/esm/src/platform/compat/process/command.js +206 -0
- package/esm/src/platform/compat/process.d.ts +5 -0
- package/esm/src/platform/compat/process.d.ts.map +1 -0
- package/esm/src/platform/compat/process.js +4 -0
- package/esm/src/transforms/import-rewriter/url-builder.d.ts +70 -0
- package/esm/src/transforms/import-rewriter/url-builder.d.ts.map +1 -0
- package/esm/src/transforms/import-rewriter/url-builder.js +152 -0
- package/esm/src/transforms/mdx/compiler/import-rewriter.d.ts.map +1 -1
- package/esm/src/transforms/mdx/compiler/import-rewriter.js +2 -1
- package/esm/src/utils/base64url.d.ts +7 -0
- package/esm/src/utils/base64url.d.ts.map +1 -0
- package/esm/src/utils/base64url.js +39 -0
- package/esm/src/utils/bundle-manifest.d.ts +63 -0
- package/esm/src/utils/bundle-manifest.d.ts.map +1 -0
- package/esm/src/utils/bundle-manifest.js +96 -0
- package/esm/src/utils/constants/buffers.d.ts +24 -0
- package/esm/src/utils/constants/buffers.d.ts.map +1 -0
- package/esm/src/utils/constants/buffers.js +23 -0
- package/esm/src/utils/constants/build.d.ts +8 -0
- package/esm/src/utils/constants/build.d.ts.map +1 -0
- package/esm/src/utils/constants/build.js +7 -0
- package/esm/src/utils/constants/cache.d.ts +74 -0
- package/esm/src/utils/constants/cache.d.ts.map +1 -0
- package/esm/src/utils/constants/cache.js +133 -0
- package/esm/src/utils/constants/cdn.d.ts +29 -0
- package/esm/src/utils/constants/cdn.d.ts.map +1 -0
- package/esm/src/utils/constants/cdn.js +58 -0
- package/esm/src/utils/constants/crypto.d.ts +10 -0
- package/esm/src/utils/constants/crypto.d.ts.map +1 -0
- package/esm/src/utils/constants/crypto.js +9 -0
- package/esm/src/utils/constants/env.d.ts +16 -0
- package/esm/src/utils/constants/env.d.ts.map +1 -0
- package/esm/src/utils/constants/env.js +20 -0
- package/esm/src/utils/constants/hash.d.ts +5 -0
- package/esm/src/utils/constants/hash.d.ts.map +1 -0
- package/esm/src/utils/constants/hash.js +4 -0
- package/esm/src/utils/constants/hmr.d.ts +24 -0
- package/esm/src/utils/constants/hmr.d.ts.map +1 -0
- package/esm/src/utils/constants/hmr.js +26 -0
- package/esm/src/utils/constants/html.d.ts +13 -0
- package/esm/src/utils/constants/html.d.ts.map +1 -0
- package/esm/src/utils/constants/html.js +12 -0
- package/esm/src/utils/constants/http.d.ts +77 -0
- package/esm/src/utils/constants/http.d.ts.map +1 -0
- package/esm/src/utils/constants/http.js +76 -0
- package/esm/src/utils/constants/index.d.ts +23 -0
- package/esm/src/utils/constants/index.d.ts.map +1 -0
- package/esm/src/utils/constants/index.js +22 -0
- package/esm/src/utils/constants/limits.d.ts +27 -0
- package/esm/src/utils/constants/limits.d.ts.map +1 -0
- package/esm/src/utils/constants/limits.js +26 -0
- package/esm/src/utils/constants/metrics.d.ts +10 -0
- package/esm/src/utils/constants/metrics.d.ts.map +1 -0
- package/esm/src/utils/constants/metrics.js +34 -0
- package/esm/src/utils/constants/network.d.ts +23 -0
- package/esm/src/utils/constants/network.d.ts.map +1 -0
- package/esm/src/utils/constants/network.js +27 -0
- package/esm/src/utils/constants/priorities.d.ts +31 -0
- package/esm/src/utils/constants/priorities.d.ts.map +1 -0
- package/esm/src/utils/constants/priorities.js +30 -0
- package/esm/src/utils/constants/retry.d.ts +14 -0
- package/esm/src/utils/constants/retry.d.ts.map +1 -0
- package/esm/src/utils/constants/retry.js +13 -0
- package/esm/src/utils/constants/server.d.ts +107 -0
- package/esm/src/utils/constants/server.d.ts.map +1 -0
- package/esm/src/utils/constants/server.js +120 -0
- package/esm/src/utils/feature-flags.d.ts +7 -0
- package/esm/src/utils/feature-flags.d.ts.map +1 -0
- package/esm/src/utils/feature-flags.js +8 -0
- package/esm/src/utils/hash-utils.d.ts +22 -0
- package/esm/src/utils/hash-utils.d.ts.map +1 -0
- package/esm/src/utils/hash-utils.js +48 -0
- package/esm/src/utils/import-lockfile.d.ts +52 -0
- package/esm/src/utils/import-lockfile.d.ts.map +1 -0
- package/esm/src/utils/import-lockfile.js +187 -0
- package/esm/src/utils/index.d.ts +30 -0
- package/esm/src/utils/index.d.ts.map +1 -0
- package/esm/src/utils/index.js +29 -0
- package/esm/src/utils/logger/components.d.ts +73 -0
- package/esm/src/utils/logger/components.d.ts.map +1 -0
- package/esm/src/utils/logger/components.js +81 -0
- package/esm/src/utils/logger/index.d.ts +10 -0
- package/esm/src/utils/logger/index.d.ts.map +1 -0
- package/esm/src/utils/logger/index.js +9 -0
- package/esm/src/utils/logger/request-context.d.ts +27 -0
- package/esm/src/utils/logger/request-context.d.ts.map +1 -0
- package/esm/src/utils/logger/request-context.js +28 -0
- package/esm/src/utils/memoize.d.ts +19 -0
- package/esm/src/utils/memoize.d.ts.map +1 -0
- package/esm/src/utils/memoize.js +72 -0
- package/esm/src/utils/parallel.d.ts +21 -0
- package/esm/src/utils/parallel.d.ts.map +1 -0
- package/esm/src/utils/parallel.js +51 -0
- package/esm/src/utils/path-utils.d.ts +34 -0
- package/esm/src/utils/path-utils.d.ts.map +1 -0
- package/esm/src/utils/path-utils.js +138 -0
- package/esm/src/utils/perf-timer.d.ts +11 -0
- package/esm/src/utils/perf-timer.d.ts.map +1 -0
- package/esm/src/utils/perf-timer.js +114 -0
- package/esm/src/utils/platform.d.ts +9 -0
- package/esm/src/utils/platform.d.ts.map +1 -0
- package/esm/src/utils/platform.js +11 -0
- package/esm/src/utils/runtime-guards.d.ts +29 -0
- package/esm/src/utils/runtime-guards.d.ts.map +1 -0
- package/esm/src/utils/runtime-guards.js +23 -0
- package/esm/src/utils/sleep.d.ts +2 -0
- package/esm/src/utils/sleep.d.ts.map +1 -0
- package/esm/src/utils/sleep.js +19 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**************************
|
|
2
|
+
* OpenTelemetry OTLP Setup
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper that delegates to the `ext-observability-opentelemetry` extension via the
|
|
5
|
+
* `TracingExporter` contract. When the extension is not installed, all span
|
|
6
|
+
* operations silently no-op.
|
|
7
|
+
*
|
|
8
|
+
* Reads configuration from environment variables:
|
|
9
|
+
* - OTEL_TRACES_ENABLED: "true" to enable tracing
|
|
10
|
+
* - OTEL_SERVICE_NAME: Service name for traces
|
|
11
|
+
* - OTEL_EXPORTER_OTLP_ENDPOINT: OTLP endpoint
|
|
12
|
+
* - OTEL_EXPORTER_OTLP_HEADERS: Auth headers
|
|
13
|
+
**************************/
|
|
14
|
+
import { isTruthyEnvValue } from "../../utils/constants/env.js";
|
|
15
|
+
import { serverLogger } from "../../utils/logger/logger.js";
|
|
16
|
+
import { context as shimContext, defaultTextMapGetter, defaultTextMapSetter, getTracer, getTracerProviderRevision, propagation as shimPropagation, SpanKind, SpanStatusCode, trace as shimTrace, } from "./api-shim.js";
|
|
17
|
+
import { getHostTelemetryEnv } from "./telemetry-env.js";
|
|
18
|
+
const logger = serverLogger.component("otel");
|
|
19
|
+
function parseHeaders(headerString) {
|
|
20
|
+
if (!headerString)
|
|
21
|
+
return {};
|
|
22
|
+
if (headerString.startsWith("Basic "))
|
|
23
|
+
return { Authorization: headerString };
|
|
24
|
+
if (headerString.startsWith("Authorization=")) {
|
|
25
|
+
return { Authorization: headerString.substring("Authorization=".length) };
|
|
26
|
+
}
|
|
27
|
+
const headers = {};
|
|
28
|
+
for (const part of headerString.split(",")) {
|
|
29
|
+
const [key, ...valueParts] = part.split("=");
|
|
30
|
+
if (!key || valueParts.length === 0)
|
|
31
|
+
continue;
|
|
32
|
+
headers[key.trim()] = valueParts.join("=").trim();
|
|
33
|
+
}
|
|
34
|
+
return headers;
|
|
35
|
+
}
|
|
36
|
+
function getConfig() {
|
|
37
|
+
// Span helpers can run during module initialization and test setup, before
|
|
38
|
+
// bootstrap has loaded .env files. Read tracing env directly here so no-op
|
|
39
|
+
// spans do not force early EnvironmentConfig initialization.
|
|
40
|
+
return {
|
|
41
|
+
enabled: isTruthyEnvValue(getHostTelemetryEnv("VERYFRONT_OTEL")) ||
|
|
42
|
+
isTruthyEnvValue(getHostTelemetryEnv("OTEL_TRACES_ENABLED")),
|
|
43
|
+
serviceName: getHostTelemetryEnv("OTEL_SERVICE_NAME") || "veryfront",
|
|
44
|
+
endpoint: getHostTelemetryEnv("OTEL_EXPORTER_OTLP_ENDPOINT") || "",
|
|
45
|
+
headers: parseHeaders(getHostTelemetryEnv("OTEL_EXPORTER_OTLP_HEADERS")),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
let cachedTracingRuntime;
|
|
49
|
+
function getTracingRuntime() {
|
|
50
|
+
const providerRevision = getTracerProviderRevision();
|
|
51
|
+
if (!cachedTracingRuntime || cachedTracingRuntime.providerRevision !== providerRevision) {
|
|
52
|
+
const config = getConfig();
|
|
53
|
+
cachedTracingRuntime = {
|
|
54
|
+
providerRevision,
|
|
55
|
+
config,
|
|
56
|
+
tracer: getTracer(config.serviceName),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return cachedTracingRuntime;
|
|
60
|
+
}
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
// Legacy initialise / shutdown (now delegated to bootstrap.ts + ext)
|
|
63
|
+
// ---------------------------------------------------------------------------
|
|
64
|
+
let initialized = false;
|
|
65
|
+
/** Initialize OTLP tracing export. */
|
|
66
|
+
export async function initializeOTLP() {
|
|
67
|
+
if (initialized) {
|
|
68
|
+
logger.debug("Already initialized");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// Actual provider setup is handled by ext-observability-opentelemetry via bootstrap.
|
|
72
|
+
// This is kept for backward compatibility.
|
|
73
|
+
initialized = true;
|
|
74
|
+
logger.debug("OTLP setup delegated to ext-observability-opentelemetry extension");
|
|
75
|
+
}
|
|
76
|
+
/** Shut down OTLP tracing export. */
|
|
77
|
+
export async function shutdownOTLP() {
|
|
78
|
+
// Actual shutdown is handled by the extension loader teardown.
|
|
79
|
+
logger.debug("OTLP shutdown delegated to ext-observability-opentelemetry extension");
|
|
80
|
+
}
|
|
81
|
+
/** Check whether OTLP export is enabled. */
|
|
82
|
+
export function isOTLPEnabled() {
|
|
83
|
+
return initialized;
|
|
84
|
+
}
|
|
85
|
+
/** Initialize OTLP tracing with explicit API adapters. */
|
|
86
|
+
export async function initializeOTLPWithApis() {
|
|
87
|
+
await initializeOTLP();
|
|
88
|
+
}
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Span helpers — delegate to shim (which delegates to SDK if wired)
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
function setSpanErrorStatus(span, error) {
|
|
93
|
+
span.setStatus({
|
|
94
|
+
code: SpanStatusCode.ERROR,
|
|
95
|
+
message: error instanceof Error ? error.message : String(error),
|
|
96
|
+
});
|
|
97
|
+
if (error instanceof Error)
|
|
98
|
+
span.recordException(error);
|
|
99
|
+
}
|
|
100
|
+
/** Applies span. */
|
|
101
|
+
export async function withSpan(name, fn, attributes, options) {
|
|
102
|
+
const { tracer } = getTracingRuntime();
|
|
103
|
+
const parentContext = shimContext.active();
|
|
104
|
+
const span = tracer.startSpan(name, { kind: options?.kind ?? SpanKind.INTERNAL, attributes }, parentContext);
|
|
105
|
+
const spanContext = shimTrace.setSpan(parentContext, span);
|
|
106
|
+
try {
|
|
107
|
+
const result = await shimContext.with(spanContext, () => fn(span));
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
setSpanErrorStatus(span, error);
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
span.end();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/** Applies span sync. */
|
|
119
|
+
export function withSpanSync(name, fn, attributes, options) {
|
|
120
|
+
const { tracer } = getTracingRuntime();
|
|
121
|
+
const parentContext = shimContext.active();
|
|
122
|
+
const span = tracer.startSpan(name, { kind: options?.kind ?? SpanKind.INTERNAL, attributes }, parentContext);
|
|
123
|
+
try {
|
|
124
|
+
const result = fn();
|
|
125
|
+
span.setStatus({ code: SpanStatusCode.OK });
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
setSpanErrorStatus(span, error);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
finally {
|
|
133
|
+
span.end();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** Context for extract. */
|
|
137
|
+
export function extractContext(headers) {
|
|
138
|
+
const carrier = {};
|
|
139
|
+
for (const [k, v] of headers)
|
|
140
|
+
carrier[k.toLowerCase()] = v;
|
|
141
|
+
return shimPropagation.extract(shimContext.active(), carrier, defaultTextMapGetter);
|
|
142
|
+
}
|
|
143
|
+
/** Context for inject. */
|
|
144
|
+
export function injectContext(headers) {
|
|
145
|
+
const carrier = {};
|
|
146
|
+
shimPropagation.inject(shimContext.active(), carrier, defaultTextMapSetter);
|
|
147
|
+
for (const [k, v] of Object.entries(carrier))
|
|
148
|
+
headers.set(k, v);
|
|
149
|
+
}
|
|
150
|
+
/** Starts server span. */
|
|
151
|
+
export function startServerSpan(method, path, parentContext) {
|
|
152
|
+
const { tracer } = getTracingRuntime();
|
|
153
|
+
const ctx = (parentContext || shimContext.active());
|
|
154
|
+
const span = tracer.startSpan(`${method} ${path}`, { kind: SpanKind.SERVER }, ctx);
|
|
155
|
+
span.setAttribute("http.method", method);
|
|
156
|
+
span.setAttribute("http.target", path);
|
|
157
|
+
return { span, context: shimTrace.setSpan(ctx, span) };
|
|
158
|
+
}
|
|
159
|
+
/** End an active server tracing span. */
|
|
160
|
+
export function endServerSpan(span, statusCode, error) {
|
|
161
|
+
if (!span)
|
|
162
|
+
return;
|
|
163
|
+
const otelSpan = span;
|
|
164
|
+
otelSpan.setAttribute("http.status_code", statusCode);
|
|
165
|
+
if (error) {
|
|
166
|
+
setSpanErrorStatus(otelSpan, error);
|
|
167
|
+
otelSpan.end();
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (statusCode >= 400) {
|
|
171
|
+
otelSpan.setStatus({ code: SpanStatusCode.ERROR });
|
|
172
|
+
otelSpan.end();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
otelSpan.setStatus({ code: SpanStatusCode.OK });
|
|
176
|
+
otelSpan.end();
|
|
177
|
+
}
|
|
178
|
+
/** Sets span attributes. */
|
|
179
|
+
export function setSpanAttributes(span, attributes) {
|
|
180
|
+
if (!span)
|
|
181
|
+
return;
|
|
182
|
+
const otelSpan = span;
|
|
183
|
+
for (const [key, value] of Object.entries(attributes))
|
|
184
|
+
otelSpan.setAttribute(key, value);
|
|
185
|
+
}
|
|
186
|
+
/** Adds an event to a span. */
|
|
187
|
+
export function addSpanEvent(span, name, attributes) {
|
|
188
|
+
if (!span)
|
|
189
|
+
return;
|
|
190
|
+
const otelSpan = span;
|
|
191
|
+
otelSpan.addEvent(name, attributes);
|
|
192
|
+
}
|
|
193
|
+
/** Sets active span attributes. */
|
|
194
|
+
export function setActiveSpanAttributes(attributes) {
|
|
195
|
+
const span = shimTrace.getActiveSpan?.();
|
|
196
|
+
if (!span)
|
|
197
|
+
return;
|
|
198
|
+
for (const [key, value] of Object.entries(attributes))
|
|
199
|
+
span.setAttribute(key, value);
|
|
200
|
+
}
|
|
201
|
+
/** Marks the active span as failed. */
|
|
202
|
+
export function setActiveSpanErrorStatus(error) {
|
|
203
|
+
const span = shimTrace.getActiveSpan?.();
|
|
204
|
+
if (!span)
|
|
205
|
+
return;
|
|
206
|
+
setSpanErrorStatus(span, error);
|
|
207
|
+
}
|
|
208
|
+
/** Context for with. */
|
|
209
|
+
export async function withContext(spanContext, fn) {
|
|
210
|
+
return shimContext.with(spanContext, fn);
|
|
211
|
+
}
|
|
212
|
+
/** Context for get trace. */
|
|
213
|
+
export function getTraceContext() {
|
|
214
|
+
const span = shimTrace.getActiveSpan?.();
|
|
215
|
+
if (!span)
|
|
216
|
+
return {};
|
|
217
|
+
const ctx = span.spanContext();
|
|
218
|
+
return { traceId: ctx.traceId, spanId: ctx.spanId };
|
|
219
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telemetry-env.d.ts","sourceRoot":"","sources":["../../../../src/src/observability/tracing/telemetry-env.ts"],"names":[],"mappings":"AAMA,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEnE;AAED,wBAAgB,sCAAsC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAE3E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getHostEnv } from "../../platform/compat/process.js";
|
|
2
|
+
const RESERVED_SHARED_RUNTIME_TELEMETRY_ENV_KEYS = new Set([
|
|
3
|
+
"VERYFRONT_OTEL",
|
|
4
|
+
]);
|
|
5
|
+
export function getHostTelemetryEnv(key) {
|
|
6
|
+
return getHostEnv(key);
|
|
7
|
+
}
|
|
8
|
+
export function isReservedSharedRuntimeTelemetryEnvKey(key) {
|
|
9
|
+
return key.startsWith("OTEL_") || RESERVED_SHARED_RUNTIME_TELEMETRY_ENV_KEYS.has(key);
|
|
10
|
+
}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/***********************
|
|
2
|
+
* Runtime identifier for platform-specific code paths
|
|
3
|
+
***********************/
|
|
4
|
+
export type RuntimeId = "deno" | "node" | "bun" | "cloudflare" | "memory";
|
|
5
|
+
/**
|
|
6
|
+
* Core runtime adapter interface
|
|
7
|
+
*
|
|
8
|
+
* Provides a unified abstraction over runtime-specific APIs (Deno, Node.js, Bun, Cloudflare Workers).
|
|
9
|
+
* All platform-specific code should go through this adapter to ensure cross-platform compatibility.
|
|
10
|
+
*/
|
|
11
|
+
export interface RuntimeAdapter {
|
|
12
|
+
/** Unique identifier for this runtime */
|
|
13
|
+
readonly id: RuntimeId;
|
|
14
|
+
/** Human-readable name for logging */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/** Runtime capabilities for feature detection */
|
|
17
|
+
readonly capabilities: RuntimeCapabilities;
|
|
18
|
+
/** Filesystem operations */
|
|
19
|
+
fs: FileSystemAdapter;
|
|
20
|
+
/** Environment variable access */
|
|
21
|
+
env: EnvironmentAdapter;
|
|
22
|
+
/** HTTP server operations */
|
|
23
|
+
server: ServerAdapter;
|
|
24
|
+
serve(handler: (request: Request) => Promise<Response> | Response, options: ServeOptions): Promise<Server>;
|
|
25
|
+
/** Shell operations (sync fs for CLI) */
|
|
26
|
+
shell?: ShellAdapter;
|
|
27
|
+
/** Key-value store (Cloudflare KV, Deno KV) */
|
|
28
|
+
kv?: KVStoreAdapter;
|
|
29
|
+
/** File watcher (not available on Workers) */
|
|
30
|
+
watcher?: FileWatcherAdapter;
|
|
31
|
+
/** Initialize the adapter (called once before first use) */
|
|
32
|
+
initialize?(): Promise<void>;
|
|
33
|
+
/** Clean shutdown (close connections, etc.) */
|
|
34
|
+
shutdown?(): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Runtime capabilities for feature detection
|
|
38
|
+
*/
|
|
39
|
+
export interface RuntimeCapabilities {
|
|
40
|
+
/** Native TypeScript support without compilation */
|
|
41
|
+
typescript: boolean;
|
|
42
|
+
/** Native JSX/TSX support */
|
|
43
|
+
jsx: boolean;
|
|
44
|
+
/** HTTP/2 server support */
|
|
45
|
+
http2: boolean;
|
|
46
|
+
/** WebSocket support */
|
|
47
|
+
websocket: boolean;
|
|
48
|
+
/** Web Workers / Worker threads support */
|
|
49
|
+
workers: boolean;
|
|
50
|
+
/** File system watching */
|
|
51
|
+
fileWatching: boolean;
|
|
52
|
+
/** Shell command execution */
|
|
53
|
+
shell: boolean;
|
|
54
|
+
/** Key-value store available */
|
|
55
|
+
kvStore: boolean;
|
|
56
|
+
/** Writable filesystem (false for Workers without KV) */
|
|
57
|
+
writableFs: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface WebSocketUpgradeOptions {
|
|
60
|
+
protocol?: string;
|
|
61
|
+
headers?: Headers | Record<string, string>;
|
|
62
|
+
idleTimeout?: number;
|
|
63
|
+
}
|
|
64
|
+
export interface ServerAdapter {
|
|
65
|
+
upgradeWebSocket(request: Request, options?: WebSocketUpgradeOptions): WebSocketUpgrade;
|
|
66
|
+
}
|
|
67
|
+
export interface WebSocketConnection {
|
|
68
|
+
readonly readyState: number;
|
|
69
|
+
send(data: string | ArrayBuffer): void;
|
|
70
|
+
close(code?: number, reason?: string): void;
|
|
71
|
+
addEventListener(type: string, listener: EventListener, options?: AddEventListenerOptions): void;
|
|
72
|
+
removeEventListener(type: string, listener: EventListener): void;
|
|
73
|
+
}
|
|
74
|
+
declare const WEBSOCKET_UPGRADE_RESPONSE_KIND = "websocket-upgrade";
|
|
75
|
+
export interface WebSocketUpgradeResponse {
|
|
76
|
+
readonly kind: typeof WEBSOCKET_UPGRADE_RESPONSE_KIND;
|
|
77
|
+
readonly status: 101;
|
|
78
|
+
readonly statusText: string;
|
|
79
|
+
readonly headers: Headers;
|
|
80
|
+
readonly body: null;
|
|
81
|
+
}
|
|
82
|
+
export interface WebSocketUpgrade {
|
|
83
|
+
socket: WebSocketConnection;
|
|
84
|
+
response: Response | WebSocketUpgradeResponse;
|
|
85
|
+
}
|
|
86
|
+
export declare function createWebSocketUpgradeResponse(input?: {
|
|
87
|
+
headers?: HeadersInit;
|
|
88
|
+
statusText?: string;
|
|
89
|
+
}): WebSocketUpgradeResponse;
|
|
90
|
+
export declare function isWebSocketUpgradeResponse(value: unknown): value is WebSocketUpgradeResponse;
|
|
91
|
+
export interface ServeOptions {
|
|
92
|
+
port?: number;
|
|
93
|
+
hostname?: string;
|
|
94
|
+
signal?: AbortSignal;
|
|
95
|
+
onListen?: (params: {
|
|
96
|
+
hostname: string;
|
|
97
|
+
port: number;
|
|
98
|
+
}) => void;
|
|
99
|
+
}
|
|
100
|
+
export interface Server {
|
|
101
|
+
stop(): Promise<void>;
|
|
102
|
+
addr: {
|
|
103
|
+
hostname: string;
|
|
104
|
+
port: number;
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export interface FileSystemAdapter {
|
|
108
|
+
readFile(path: string): Promise<string>;
|
|
109
|
+
/** Read raw bytes when binary-safe access is required */
|
|
110
|
+
readFileBytes?(path: string): Promise<Uint8Array>;
|
|
111
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
112
|
+
exists(path: string): Promise<boolean>;
|
|
113
|
+
readDir(path: string): AsyncIterable<DirEntry>;
|
|
114
|
+
stat(path: string): Promise<FileInfo>;
|
|
115
|
+
/**
|
|
116
|
+
* Stat a path WITHOUT following a terminal symlink (lstat semantics).
|
|
117
|
+
* Unlike stat(), which follows symlinks and therefore always reports
|
|
118
|
+
* isSymlink:false for a link, this reports isSymlink:true for the link
|
|
119
|
+
* itself. Used by path validation to detect symlink escapes. Optional:
|
|
120
|
+
* virtual/remote filesystems that have no OS-level symlinks may omit it.
|
|
121
|
+
*/
|
|
122
|
+
lstat?(path: string): Promise<FileInfo>;
|
|
123
|
+
/**
|
|
124
|
+
* Resolve a path to its canonical physical form, following all symlinks.
|
|
125
|
+
* Used by path validation to check containment against the real target so a
|
|
126
|
+
* symlink whose target escapes the base directory can be rejected. Throws if
|
|
127
|
+
* the path does not exist. Optional: virtual/remote filesystems that have no
|
|
128
|
+
* OS-level symlinks may omit it.
|
|
129
|
+
*/
|
|
130
|
+
realPath?(path: string): Promise<string>;
|
|
131
|
+
mkdir(path: string, options?: {
|
|
132
|
+
recursive?: boolean;
|
|
133
|
+
}): Promise<void>;
|
|
134
|
+
remove(path: string, options?: {
|
|
135
|
+
recursive?: boolean;
|
|
136
|
+
}): Promise<void>;
|
|
137
|
+
makeTempDir(prefix: string): Promise<string>;
|
|
138
|
+
watch(paths: string | string[], options?: WatchOptions): FileWatcher;
|
|
139
|
+
/** Resolve a file path with extension fallback (e.g., pages/test → pages/test.mdx) */
|
|
140
|
+
resolveFile?(basePath: string, options?: ResolveFileOptions): Promise<string | null>;
|
|
141
|
+
/** Refresh remote source snapshots when a preview render detects stale cached content. */
|
|
142
|
+
refreshSourceSnapshot?(reason?: string): Promise<void>;
|
|
143
|
+
}
|
|
144
|
+
export interface ResolveFileOptions {
|
|
145
|
+
allowPagesPrefix?: boolean;
|
|
146
|
+
}
|
|
147
|
+
export interface DirEntry {
|
|
148
|
+
name: string;
|
|
149
|
+
isFile: boolean;
|
|
150
|
+
isDirectory: boolean;
|
|
151
|
+
isSymlink: boolean;
|
|
152
|
+
}
|
|
153
|
+
export interface FileInfo {
|
|
154
|
+
size: number;
|
|
155
|
+
isFile: boolean;
|
|
156
|
+
isDirectory: boolean;
|
|
157
|
+
isSymlink: boolean;
|
|
158
|
+
mtime: Date | null;
|
|
159
|
+
}
|
|
160
|
+
export interface EnvironmentAdapter {
|
|
161
|
+
get(key: string): string | undefined;
|
|
162
|
+
set(key: string, value: string): void;
|
|
163
|
+
toObject(): Record<string, string>;
|
|
164
|
+
}
|
|
165
|
+
export interface WatchOptions {
|
|
166
|
+
recursive?: boolean;
|
|
167
|
+
signal?: AbortSignal;
|
|
168
|
+
}
|
|
169
|
+
export type FileChangeKind = "create" | "modify" | "delete" | "any";
|
|
170
|
+
export interface FileChangeEvent {
|
|
171
|
+
kind: FileChangeKind;
|
|
172
|
+
paths: string[];
|
|
173
|
+
}
|
|
174
|
+
export interface FileWatcher extends AsyncIterable<FileChangeEvent> {
|
|
175
|
+
close(): void;
|
|
176
|
+
/**
|
|
177
|
+
* Resolves once the watcher's internal loop has fully stopped, including
|
|
178
|
+
* any in-flight filesystem operations. close() only signals shutdown;
|
|
179
|
+
* await this to guarantee no pending async ops remain (e.g. before test
|
|
180
|
+
* sanitizer checks or process exit).
|
|
181
|
+
*/
|
|
182
|
+
done?: Promise<void>;
|
|
183
|
+
}
|
|
184
|
+
export interface ShellAdapter {
|
|
185
|
+
statSync(path: string): {
|
|
186
|
+
isFile: boolean;
|
|
187
|
+
isDirectory: boolean;
|
|
188
|
+
};
|
|
189
|
+
readFileSync(path: string): string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Key-value store adapter for Cloudflare KV, Deno KV, etc.
|
|
193
|
+
*/
|
|
194
|
+
export interface KVStoreAdapter {
|
|
195
|
+
get(key: string): Promise<string | null>;
|
|
196
|
+
set(key: string, value: string, options?: {
|
|
197
|
+
expirationTtl?: number;
|
|
198
|
+
}): Promise<void>;
|
|
199
|
+
delete(key: string): Promise<void>;
|
|
200
|
+
list(prefix?: string): AsyncIterable<string>;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* File watcher adapter for development mode
|
|
204
|
+
*/
|
|
205
|
+
export interface FileWatcherAdapter {
|
|
206
|
+
watch(paths: string | string[], options?: WatchOptions): FileWatcher;
|
|
207
|
+
}
|
|
208
|
+
export {};
|
|
209
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/adapters/base.ts"],"names":[],"mappings":"AAAA;;yBAEyB;AACzB,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,GAAG,QAAQ,CAAC;AAE1E;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IAEvB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,iDAAiD;IACjD,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAE3C,4BAA4B;IAC5B,EAAE,EAAE,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CKET_UPGRADE_RESPONSE_KIND = "websocket-upgrade";
|
|
2
|
+
export function createWebSocketUpgradeResponse(input = {}) {
|
|
3
|
+
return {
|
|
4
|
+
kind: WEBSOCKET_UPGRADE_RESPONSE_KIND,
|
|
5
|
+
status: 101,
|
|
6
|
+
statusText: input.statusText ?? "Switching Protocols",
|
|
7
|
+
headers: new Headers(input.headers),
|
|
8
|
+
body: null,
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export function isWebSocketUpgradeResponse(value) {
|
|
12
|
+
return typeof value === "object" && value !== null &&
|
|
13
|
+
value.kind === WEBSOCKET_UPGRADE_RESPONSE_KIND &&
|
|
14
|
+
value.status === 101;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-level constants that don't depend on configuration.
|
|
3
|
+
* These are simple values used by HTTP servers and adapters.
|
|
4
|
+
*
|
|
5
|
+
* Note: config/defaults.ts re-exports DEFAULT_PORT for higher layers.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_PORT = 3000;
|
|
8
|
+
export declare const LOCALHOST: {
|
|
9
|
+
readonly IPV4: "127.0.0.1";
|
|
10
|
+
readonly IPV6: "::1";
|
|
11
|
+
readonly HOSTNAME: "localhost";
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/constants.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,YAAY,OAAO,CAAC;AAEjC,eAAO,MAAM,SAAS;;;;CAIZ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-level constants that don't depend on configuration.
|
|
3
|
+
* These are simple values used by HTTP servers and adapters.
|
|
4
|
+
*
|
|
5
|
+
* Note: config/defaults.ts re-exports DEFAULT_PORT for higher layers.
|
|
6
|
+
*/
|
|
7
|
+
export const DEFAULT_PORT = 3000;
|
|
8
|
+
export const LOCALHOST = {
|
|
9
|
+
IPV4: "127.0.0.1",
|
|
10
|
+
IPV6: "::1",
|
|
11
|
+
HOSTNAME: "localhost",
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opaque dynamic import helper.
|
|
3
|
+
*
|
|
4
|
+
* Uses `new Function` to hide the `import()` call from static analysis
|
|
5
|
+
* by bundlers and `deno compile`, preventing them from tracing into
|
|
6
|
+
* the imported specifier.
|
|
7
|
+
*
|
|
8
|
+
* @module platform/compat
|
|
9
|
+
*/
|
|
10
|
+
export declare const dynamicImport: <T = unknown>(specifier: string) => Promise<T>;
|
|
11
|
+
//# sourceMappingURL=dynamic-import.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-import.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/dynamic-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,eAAO,MAAM,aAAa,EAA4D,CACpF,CAAC,GAAG,OAAO,EAEX,SAAS,EAAE,MAAM,KACd,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opaque dynamic import helper.
|
|
3
|
+
*
|
|
4
|
+
* Uses `new Function` to hide the `import()` call from static analysis
|
|
5
|
+
* by bundlers and `deno compile`, preventing them from tracing into
|
|
6
|
+
* the imported specifier.
|
|
7
|
+
*
|
|
8
|
+
* @module platform/compat
|
|
9
|
+
*/
|
|
10
|
+
export const dynamicImport = new Function("specifier", "return import(specifier)");
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { FileInfo } from "../adapters/base.js";
|
|
2
|
+
/** Public API contract for file system. */
|
|
3
|
+
export interface FileSystem {
|
|
4
|
+
readTextFile(path: string): Promise<string>;
|
|
5
|
+
readFile(path: string): Promise<Uint8Array>;
|
|
6
|
+
writeTextFile(path: string, data: string): Promise<void>;
|
|
7
|
+
writeFile(path: string, data: Uint8Array): Promise<void>;
|
|
8
|
+
exists(path: string): Promise<boolean>;
|
|
9
|
+
stat(path: string): Promise<FileInfo>;
|
|
10
|
+
lstat?(path: string): Promise<FileInfo>;
|
|
11
|
+
mkdir(path: string, options?: {
|
|
12
|
+
recursive?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
readDir(path: string): AsyncIterable<{
|
|
15
|
+
name: string;
|
|
16
|
+
isFile: boolean;
|
|
17
|
+
isDirectory: boolean;
|
|
18
|
+
isSymlink?: boolean;
|
|
19
|
+
}>;
|
|
20
|
+
remove(path: string, options?: {
|
|
21
|
+
recursive?: boolean;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
makeTempDir(options?: {
|
|
24
|
+
prefix?: string;
|
|
25
|
+
}): Promise<string>;
|
|
26
|
+
chmod(path: string, mode: number): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/** Create file system. */
|
|
29
|
+
export declare function createFileSystem(): FileSystem;
|
|
30
|
+
/** Read a file as text. */
|
|
31
|
+
export declare function readTextFile(path: string): Promise<string>;
|
|
32
|
+
/** Read a file as bytes. */
|
|
33
|
+
export declare function readFile(path: string): Promise<Uint8Array>;
|
|
34
|
+
/** Write text to a file. */
|
|
35
|
+
export declare function writeTextFile(path: string, data: string): Promise<void>;
|
|
36
|
+
/** Write bytes to a file. */
|
|
37
|
+
export declare function writeFile(path: string, data: Uint8Array): Promise<void>;
|
|
38
|
+
/** Check whether a path exists. */
|
|
39
|
+
export declare function exists(path: string): Promise<boolean>;
|
|
40
|
+
/** Read file metadata. */
|
|
41
|
+
export declare function stat(path: string): Promise<FileInfo>;
|
|
42
|
+
/** Read file metadata without following a terminal symbolic link. */
|
|
43
|
+
export declare function lstat(path: string): Promise<FileInfo>;
|
|
44
|
+
/** Create a directory. */
|
|
45
|
+
export declare function mkdir(path: string, options?: {
|
|
46
|
+
recursive?: boolean;
|
|
47
|
+
}): Promise<void>;
|
|
48
|
+
/** Remove a file or directory. */
|
|
49
|
+
export declare function remove(path: string, options?: {
|
|
50
|
+
recursive?: boolean;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
/** Read directory entries. */
|
|
53
|
+
export declare function readDir(path: string): AsyncIterable<{
|
|
54
|
+
name: string;
|
|
55
|
+
isFile: boolean;
|
|
56
|
+
isDirectory: boolean;
|
|
57
|
+
isSymlink?: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
/** Create temp dir. */
|
|
60
|
+
export declare function makeTempDir(options?: {
|
|
61
|
+
prefix?: string;
|
|
62
|
+
}): Promise<string>;
|
|
63
|
+
/** Change file permissions. */
|
|
64
|
+
export declare function chmod(path: string, mode: number): Promise<void>;
|
|
65
|
+
export declare function symlink(target: string, path: string): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a path to its canonical absolute form, following symlinks.
|
|
68
|
+
* Throws if the path does not exist. Useful for containment checks where a
|
|
69
|
+
* symlink could otherwise escape an intended directory.
|
|
70
|
+
*/
|
|
71
|
+
export declare function realPath(path: string): Promise<string>;
|
|
72
|
+
/** Error shape for is not found. */
|
|
73
|
+
export declare function isNotFoundError(error: unknown, seen?: Set<unknown>): boolean;
|
|
74
|
+
/** Error shape for is already exists. */
|
|
75
|
+
export declare function isAlreadyExistsError(error: unknown): boolean;
|
|
76
|
+
//# sourceMappingURL=fs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../../src/src/platform/compat/fs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAgBpD,2CAA2C;AAC3C,MAAM,WAAW,UAAU;IACzB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OA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