@camstack/addon-pipeline 1.2.74 → 1.2.75
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/dist/{addon-utils-CQs-AjTJ.js → addon-utils-a_36HH_N.js} +4 -4
- package/dist/audio-analyzer/index.js +5 -6
- package/dist/audio-analyzer/index.mjs +3 -3
- package/dist/detection-pipeline/index.js +9 -10
- package/dist/detection-pipeline/index.mjs +5 -5
- package/dist/{dist-CgJ8MRAy.js → dist-6ZJCV0jY.js} +1900 -27
- package/dist/{dist-CKY0efl3.mjs → dist-T_8jMw7d.mjs} +1865 -27
- package/dist/{event-loop-stall-monitor-Dx-zXcNg.js → event-loop-stall-monitor-Cjof8vA1.js} +1 -1
- package/dist/{event-loop-stall-monitor-CIapFIez.mjs → event-loop-stall-monitor-XeGmL4xr.mjs} +1 -1
- package/dist/lazy-sharp-6oymT_yf.mjs +341 -0
- package/dist/lazy-sharp-DvwPafeP.js +360 -0
- package/dist/motion-wasm/index.js +3 -3
- package/dist/motion-wasm/index.mjs +3 -3
- package/dist/pipeline-runner/index.js +6 -7
- package/dist/pipeline-runner/index.mjs +4 -4
- package/dist/recorder/index.js +138 -32
- package/dist/recorder/index.mjs +137 -30
- package/dist/session-decode/decode-worker-child.js +311 -126
- package/dist/session-decode/decode-worker-child.mjs +311 -123
- package/dist/stream-broker/_stub.js +94 -94
- package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-DVJ4gKkk.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-H2OTmgR6.mjs} +2 -2
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-RYTOS6B-.mjs +26 -0
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-DfsLsn2e.mjs +26 -0
- package/dist/stream-broker/{hostInit-5SFdfUyc.mjs → hostInit-4XDN_Nt0.mjs} +2 -2
- package/dist/stream-broker/index.js +12 -13
- package/dist/stream-broker/index.mjs +3 -3
- package/dist/stream-broker/remoteEntry.js +1 -1
- package/dist/{worker-protocol-D44DCkcs.js → worker-protocol-B0cbTXyw.js} +1 -1
- package/dist/{worker-protocol-BzAQPUR-.mjs → worker-protocol-SqED7Y9i.mjs} +1 -1
- package/package.json +1 -1
- package/dist/chunk-emK7D4bc.js +0 -35
- package/dist/lazy-sharp-B-mb8uWx.mjs +0 -20
- package/dist/lazy-sharp-CcYuXtsa.js +0 -25
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-C_plRUtD.mjs +0 -26
- package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CExO0piw.mjs +0 -26
- package/dist/{addon-utils-CZ2xo67g.mjs → addon-utils-A2S9D7pu.mjs} +2 -2
package/dist/{event-loop-stall-monitor-CIapFIez.mjs → event-loop-stall-monitor-XeGmL4xr.mjs}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as COCO_TO_MACRO, i as COCO_80_LABELS, r as AUDIO_MACRO_LABELS, z as hfModelUrl } from "./dist-
|
|
1
|
+
import { a as COCO_TO_MACRO, i as COCO_80_LABELS, r as AUDIO_MACRO_LABELS, z as hfModelUrl } from "./dist-T_8jMw7d.mjs";
|
|
2
2
|
import { PerformanceObserver } from "node:perf_hooks";
|
|
3
3
|
//#region src/detection-pipeline/registry/model-catalogs.ts
|
|
4
4
|
var HF_REPO = "camstack/camstack-models";
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import * as path$1 from "node:path";
|
|
4
|
+
//#region src/shared/host-external-import.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolving a HOST-EXTERNAL package (`sharp`, `node-av`, …) from a process that
|
|
7
|
+
* does NOT have the framework ESM resolver hook registered.
|
|
8
|
+
*
|
|
9
|
+
* ## The problem this exists for
|
|
10
|
+
*
|
|
11
|
+
* An addon bundle leaves the packages in `HOST_EXTERNAL_SPECIFIERS`
|
|
12
|
+
* (`@camstack/system` → `kernel/host-externals.ts`) unbundled and expects the
|
|
13
|
+
* HOST to provide them. What provides them is a module-customization hook
|
|
14
|
+
* (`framework-resolver-hook.mjs`) that `registerFrameworkResolver` installs in
|
|
15
|
+
* the **addon-runner process**, re-anchoring those bare specifiers at
|
|
16
|
+
* `<frameworkDir>/node_modules`.
|
|
17
|
+
*
|
|
18
|
+
* A worker started with a plain `child_process.fork` — the session decode
|
|
19
|
+
* worker (`session-decode/fork-decode-worker.ts`) is the one in this package —
|
|
20
|
+
* does NOT inherit that hook. In it, `import('sharp')` and `import('node-av')`
|
|
21
|
+
* throw `Cannot find package 'X' imported from /data/addons/@camstack/…`,
|
|
22
|
+
* because the addon directory has no `node_modules` to walk up into.
|
|
23
|
+
*
|
|
24
|
+
* ## Why an explicit path and not the hook
|
|
25
|
+
*
|
|
26
|
+
* Registering the framework resolver in the child was considered and rejected:
|
|
27
|
+
*
|
|
28
|
+
* - it would need the child to reach INTO another package's build output
|
|
29
|
+
* (`<frameworkDir>/node_modules/@camstack/system/dist/…/framework-resolver-hook.mjs`)
|
|
30
|
+
* plus an `--import` shim, i.e. a hard coupling to a layout nothing checks;
|
|
31
|
+
* - a registered hook makes **every** `import()` in that process re-enter the
|
|
32
|
+
* loader and block the main thread on `Atomics.wait` until the hooks worker
|
|
33
|
+
* answers — the exact cost `shared/lazy-sharp.ts` was written to remove from
|
|
34
|
+
* the frame path. Paying it per decode worker to load two modules is the
|
|
35
|
+
* wrong trade;
|
|
36
|
+
* - the explicit-path fallback is already the shipped answer for `node-av` in
|
|
37
|
+
* this same worker, and had been for months. A second mechanism for `sharp`
|
|
38
|
+
* would mean two ways to fail.
|
|
39
|
+
*
|
|
40
|
+
* So: try the bare specifier (works on the hub, where the fork inherits the
|
|
41
|
+
* hook, and in dev, where workspace symlinks resolve), then resolve the package
|
|
42
|
+
* explicitly out of the module roots an agent is known to lay out.
|
|
43
|
+
*
|
|
44
|
+
* ## The anchors, in order
|
|
45
|
+
*
|
|
46
|
+
* - **DOCKER / single-copy node** — the framework overlay
|
|
47
|
+
* `CAMSTACK_FRAMEWORK_DIR` (`<frameworkDir>/node_modules/<pkg>`). The
|
|
48
|
+
* launcher points this at the ACTIVE closure in data-root mode and forked
|
|
49
|
+
* children inherit it (`server/backend/src/launcher.ts`).
|
|
50
|
+
* - **ELECTRON agent** — the app bundle beside `CAMSTACK_BUNDLED_ADDONS_DIR`
|
|
51
|
+
* (`<resources>/addons`): `<resources>/node_modules/<pkg>` and the
|
|
52
|
+
* `app.asar.unpacked` mirror.
|
|
53
|
+
* - **the process cwd** — always tried last, and it is NOT redundant:
|
|
54
|
+
* `CAMSTACK_FRAMEWORK_DIR` is only exported on some boots (the Docker
|
|
55
|
+
* entrypoint sets it in its fallback branch; the launcher only in data-root
|
|
56
|
+
* mode), while the launcher ALWAYS extends `NODE_PATH` with the framework and
|
|
57
|
+
* hub `node_modules`. A CJS-style resolution honours `NODE_PATH`; an ESM
|
|
58
|
+
* `import()` of a bare specifier does not. This is the same escape hatch
|
|
59
|
+
* `stream-broker/webrtc/session.ts` uses to find the framework's `werift`.
|
|
60
|
+
*
|
|
61
|
+
* An anchor that cannot resolve the specifier is skipped, so an empty result
|
|
62
|
+
* leaves the bare specifier as the only path, exactly as before.
|
|
63
|
+
*
|
|
64
|
+
* Resolution goes through `createRequire(...).resolve(specifier)` rather than a
|
|
65
|
+
* hardcoded relative entry (`dist/index.js`, …): that honours the package's own
|
|
66
|
+
* `exports`/`main`, so it keeps working across a dependency's file-layout
|
|
67
|
+
* changes, handles SUBPATH specifiers (`node-av/constants`) with no mapping
|
|
68
|
+
* table, and consults `NODE_PATH`. It also verifies the file exists, which is
|
|
69
|
+
* what the previous `fs.existsSync` check did by hand.
|
|
70
|
+
*/
|
|
71
|
+
/**
|
|
72
|
+
* The anchor filename resolution walks up from. It never has to EXIST —
|
|
73
|
+
* `createRequire` only needs a path to anchor at — but naming it after camstack
|
|
74
|
+
* keeps a stack trace readable if one ever escapes.
|
|
75
|
+
*/
|
|
76
|
+
var ANCHOR_FILE = "__camstack_host_external_anchor__.cjs";
|
|
77
|
+
/** Node error codes that mean "the module is not there", not "it failed to load". */
|
|
78
|
+
var RESOLUTION_ERROR_CODES = [
|
|
79
|
+
"ERR_MODULE_NOT_FOUND",
|
|
80
|
+
"MODULE_NOT_FOUND",
|
|
81
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
82
|
+
"ERR_UNSUPPORTED_DIR_IMPORT"
|
|
83
|
+
];
|
|
84
|
+
/** `err.code` when the error carries a string one. No cast: `in` narrows. */
|
|
85
|
+
function errorCode(err) {
|
|
86
|
+
if (typeof err !== "object" || err === null) return null;
|
|
87
|
+
if (!("code" in err)) return null;
|
|
88
|
+
const code = err.code;
|
|
89
|
+
return typeof code === "string" ? code : null;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* True when `err` says the module could not be FOUND (as opposed to found and
|
|
93
|
+
* failed to load — a broken native binary, a throwing top level).
|
|
94
|
+
*
|
|
95
|
+
* The distinction is load-bearing for callers that memoize failure: a
|
|
96
|
+
* resolution failure is deterministic for the life of the process (the env and
|
|
97
|
+
* the framework layout do not change under a running worker), so retrying it
|
|
98
|
+
* per frame can only re-pay the loader round-trip and re-log. A LOAD failure
|
|
99
|
+
* can plausibly be a deploy blip and stays retryable.
|
|
100
|
+
*
|
|
101
|
+
* The message check is a belt for the same braces: Node has moved these codes
|
|
102
|
+
* before, and a miss here degrades to "retry forever", which is the bug.
|
|
103
|
+
*/
|
|
104
|
+
function isModuleResolutionError(err) {
|
|
105
|
+
const code = errorCode(err);
|
|
106
|
+
if (code !== null && RESOLUTION_ERROR_CODES.includes(code)) return true;
|
|
107
|
+
if (!(err instanceof Error)) return false;
|
|
108
|
+
return err.message.includes("Cannot find package") || err.message.includes("Cannot find module");
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The files a resolution is anchored at, in the order they are tried. Each is a
|
|
112
|
+
* path INSIDE a candidate `node_modules` (so `<dir>/node_modules/<pkg>` is on
|
|
113
|
+
* the walk), except the cwd anchor, which walks up from the cwd itself.
|
|
114
|
+
*
|
|
115
|
+
* The anchor files never have to exist — `createRequire` only needs a path.
|
|
116
|
+
*/
|
|
117
|
+
function hostExternalAnchors(env, cwd) {
|
|
118
|
+
const anchors = [];
|
|
119
|
+
const frameworkDir = env["CAMSTACK_FRAMEWORK_DIR"];
|
|
120
|
+
if (frameworkDir !== void 0 && frameworkDir.length > 0) anchors.push(path$1.join(frameworkDir, "node_modules", ANCHOR_FILE));
|
|
121
|
+
const bundledAddons = env["CAMSTACK_BUNDLED_ADDONS_DIR"];
|
|
122
|
+
if (bundledAddons !== void 0 && bundledAddons.length > 0) {
|
|
123
|
+
const resourcesRoot = path$1.dirname(bundledAddons);
|
|
124
|
+
anchors.push(path$1.join(resourcesRoot, "node_modules", ANCHOR_FILE));
|
|
125
|
+
anchors.push(path$1.join(resourcesRoot, "app.asar.unpacked", "node_modules", ANCHOR_FILE));
|
|
126
|
+
}
|
|
127
|
+
anchors.push(path$1.join(cwd, ANCHOR_FILE));
|
|
128
|
+
return anchors;
|
|
129
|
+
}
|
|
130
|
+
/** `createRequire(anchor).resolve(specifier)`, or `null` when it is not there. */
|
|
131
|
+
function resolveFromAnchor(anchorPath, specifier) {
|
|
132
|
+
try {
|
|
133
|
+
return createRequire(anchorPath).resolve(specifier);
|
|
134
|
+
} catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Importable `file:` URLs for `specifier`, in the order a caller should try them
|
|
140
|
+
* after the bare specifier has already failed. Deduplicated (two anchors
|
|
141
|
+
* routinely resolve to the SAME file — a NODE_PATH hit, or a symlink), and empty
|
|
142
|
+
* when nothing resolves it, which leaves the bare specifier the only path.
|
|
143
|
+
*/
|
|
144
|
+
function hostExternalEntryUrls(specifier, options = {}) {
|
|
145
|
+
const env = options.env ?? process.env;
|
|
146
|
+
const cwd = options.cwd ?? process.cwd();
|
|
147
|
+
const resolveEntry = options.resolve ?? resolveFromAnchor;
|
|
148
|
+
const urls = [];
|
|
149
|
+
for (const anchor of hostExternalAnchors(env, cwd)) {
|
|
150
|
+
const entry = resolveEntry(anchor, specifier);
|
|
151
|
+
if (entry === null || entry.length === 0) continue;
|
|
152
|
+
const url = pathToFileURL(entry).href;
|
|
153
|
+
if (!urls.includes(url)) urls.push(url);
|
|
154
|
+
}
|
|
155
|
+
return urls;
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
//#region src/shared/lazy-sharp.ts
|
|
159
|
+
/**
|
|
160
|
+
* lazy-sharp — resolve `sharp` ONCE, not once per frame, and give up ONCE when
|
|
161
|
+
* it cannot be resolved at all.
|
|
162
|
+
*
|
|
163
|
+
* ## What this fixes (2026-08-02)
|
|
164
|
+
*
|
|
165
|
+
* `await import('sharp')` sat directly in the frame path, in a spot whose own
|
|
166
|
+
* comment reads "This is the production hot path (camera frames from broker)",
|
|
167
|
+
* and in six other places along the same path. At ~13 fps per camera across the
|
|
168
|
+
* fleet that is thousands of dynamic imports a minute.
|
|
169
|
+
*
|
|
170
|
+
* Node caches the MODULE after the first import, so this looks free. It is not:
|
|
171
|
+
* the addon runner registers module-customization hooks (the framework
|
|
172
|
+
* resolver), and with hooks registered every `import()` re-enters the loader and
|
|
173
|
+
* resolves the specifier through the hooks worker — **synchronously**. A CPU
|
|
174
|
+
* profile of the live detection runner caught it exactly:
|
|
175
|
+
*
|
|
176
|
+
* makeSyncRequest@hooks:631
|
|
177
|
+
* resolveSync@hooks:860
|
|
178
|
+
* #resolveAndMaybeBlockOnLoaderThread@loader:715
|
|
179
|
+
* …
|
|
180
|
+
* import@loader:626
|
|
181
|
+
* runPipeline@index.js:5565
|
|
182
|
+
*
|
|
183
|
+
* `#resolveAndMaybeBlockOnLoaderThread` is the name of the problem:
|
|
184
|
+
* `makeSyncRequest` blocks the MAIN THREAD on `Atomics.wait` until the hooks
|
|
185
|
+
* worker answers. That is a synchronous block on the frame path, which is the
|
|
186
|
+
* shape the 22-88s event-loop freezes had.
|
|
187
|
+
*
|
|
188
|
+
* ## What it fixes a second time (2026-08-14)
|
|
189
|
+
*
|
|
190
|
+
* A memo that CLEARS on failure re-pays that entire cost on every call once the
|
|
191
|
+
* module genuinely is not there. The subject-tile tier hit exactly that: in the
|
|
192
|
+
* decode worker (a plain `child_process.fork`, no resolver hook) `import('sharp')`
|
|
193
|
+
* cannot resolve, and because the memo was dropped on failure, every subject of
|
|
194
|
+
* every frame re-entered the loader and logged a WARN — 3 800 WARN/min
|
|
195
|
+
* cluster-wide, with a synchronous loader round-trip on the frame path behind
|
|
196
|
+
* each one, and not one tile ever cut.
|
|
197
|
+
*
|
|
198
|
+
* So this module now does two more things:
|
|
199
|
+
*
|
|
200
|
+
* 1. **Falls back to an explicit path.** Same mechanism `node-av` has used in
|
|
201
|
+
* the same worker for months, extracted into
|
|
202
|
+
* `shared/host-external-import.ts` — read its docblock for the layouts and
|
|
203
|
+
* for why the framework resolver is NOT registered in the child instead.
|
|
204
|
+
* 2. **Distinguishes the two failure kinds.**
|
|
205
|
+
* - **Resolution** failure (nothing, anywhere, resolves `sharp`): the answer
|
|
206
|
+
* cannot change while this process lives, so it is memoized as a sticky
|
|
207
|
+
* {@link SharpUnavailableError}. Later calls reject IMMEDIATELY, with no
|
|
208
|
+
* loader re-entry, and exactly ONE warning is emitted for the process
|
|
209
|
+
* naming every candidate tried and the cause.
|
|
210
|
+
* - **Load** failure (found, but the native binary or the module body threw):
|
|
211
|
+
* the memo is cleared, so a later call retries. A partially-installed
|
|
212
|
+
* native dep during a deploy must not poison the encoder for the whole
|
|
213
|
+
* process lifetime — that would turn a blip into a camera that never
|
|
214
|
+
* produces media again. This is the original behaviour, kept on purpose,
|
|
215
|
+
* and it is safe to keep only because it is now the NARROW case.
|
|
216
|
+
*
|
|
217
|
+
* ## Why a memo and not a static import
|
|
218
|
+
*
|
|
219
|
+
* `sharp` is a heavy native module. The dynamic import was deliberate — nodes
|
|
220
|
+
* that never encode a frame should not pay to load it, and a node whose native
|
|
221
|
+
* build is missing must fail at first use rather than at boot. Both properties
|
|
222
|
+
* survive: the module is still loaded on FIRST use, and a failure still surfaces
|
|
223
|
+
* at that call. Only the repeat resolutions are removed.
|
|
224
|
+
*
|
|
225
|
+
* The promise itself is cached (not just the resolved value), so N concurrent
|
|
226
|
+
* first-callers share one import instead of racing into N.
|
|
227
|
+
*/
|
|
228
|
+
/** The bare specifier. Also the first entry of a failure's candidate list. */
|
|
229
|
+
var SHARP_SPECIFIER = "sharp";
|
|
230
|
+
/**
|
|
231
|
+
* `sharp` cannot be resolved in this process, and nothing about that can change
|
|
232
|
+
* while it runs. Carries the candidates tried so the log answers "where did you
|
|
233
|
+
* look" without a second round of diagnosis.
|
|
234
|
+
*/
|
|
235
|
+
var SharpUnavailableError = class extends Error {
|
|
236
|
+
attempts;
|
|
237
|
+
constructor(attempts, cause) {
|
|
238
|
+
super(`sharp could not be resolved in this process — tried ${attempts.join(", ")}; cause: ${describeError(cause)}`, { cause });
|
|
239
|
+
this.name = "SharpUnavailableError";
|
|
240
|
+
this.attempts = attempts;
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
function describeError(err) {
|
|
244
|
+
return err instanceof Error ? err.message : String(err);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The bare specifier stays a LITERAL `import('sharp')` so the bundler keeps
|
|
248
|
+
* treating it as the declared external it is; only the fallback candidates go
|
|
249
|
+
* through a variable specifier (typed `any` by TS, so the declared return type
|
|
250
|
+
* applies without a cast — the same shape `importNodeAv` uses).
|
|
251
|
+
*/
|
|
252
|
+
async function importSharpModule(specifier) {
|
|
253
|
+
if (specifier === SHARP_SPECIFIER) return import("sharp");
|
|
254
|
+
return await import(specifier);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Build a loader. Exported for tests; production uses the module-level
|
|
258
|
+
* {@link getSharp}, which is one of these.
|
|
259
|
+
*/
|
|
260
|
+
function createSharpLoader(deps = {}) {
|
|
261
|
+
const importModule = deps.importModule ?? importSharpModule;
|
|
262
|
+
const fallbackUrls = deps.fallbackUrls ?? (() => hostExternalEntryUrls(SHARP_SPECIFIER));
|
|
263
|
+
const warn = deps.warn;
|
|
264
|
+
let pending = null;
|
|
265
|
+
let unavailable = null;
|
|
266
|
+
let warned = false;
|
|
267
|
+
/** Bare first, then each fallback candidate, in order. */
|
|
268
|
+
const attempt = async () => {
|
|
269
|
+
const attempts = [SHARP_SPECIFIER];
|
|
270
|
+
let lastError;
|
|
271
|
+
try {
|
|
272
|
+
return (await importModule(SHARP_SPECIFIER)).default;
|
|
273
|
+
} catch (bareError) {
|
|
274
|
+
if (!isModuleResolutionError(bareError)) {
|
|
275
|
+
pending = null;
|
|
276
|
+
throw bareError;
|
|
277
|
+
}
|
|
278
|
+
lastError = bareError;
|
|
279
|
+
}
|
|
280
|
+
for (const url of fallbackUrls()) {
|
|
281
|
+
attempts.push(url);
|
|
282
|
+
try {
|
|
283
|
+
return (await importModule(url)).default;
|
|
284
|
+
} catch (candidateError) {
|
|
285
|
+
if (!isModuleResolutionError(candidateError)) {
|
|
286
|
+
pending = null;
|
|
287
|
+
throw candidateError;
|
|
288
|
+
}
|
|
289
|
+
lastError = candidateError;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const failure = new SharpUnavailableError(attempts, lastError);
|
|
293
|
+
unavailable = failure;
|
|
294
|
+
pending = null;
|
|
295
|
+
if (!warned) {
|
|
296
|
+
warned = true;
|
|
297
|
+
if (warn) warn(failure.message);
|
|
298
|
+
else process.stderr.write(`${failure.message}\n`);
|
|
299
|
+
}
|
|
300
|
+
throw failure;
|
|
301
|
+
};
|
|
302
|
+
return {
|
|
303
|
+
load: () => {
|
|
304
|
+
if (unavailable !== null) return Promise.reject(unavailable);
|
|
305
|
+
if (pending === null) pending = attempt();
|
|
306
|
+
return pending;
|
|
307
|
+
},
|
|
308
|
+
reset: () => {
|
|
309
|
+
pending = null;
|
|
310
|
+
unavailable = null;
|
|
311
|
+
warned = false;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/** Where the process-wide loader's single diagnostic goes. */
|
|
316
|
+
var warnSink = null;
|
|
317
|
+
/**
|
|
318
|
+
* Route the one-off "sharp is unavailable" diagnostic somewhere it will be seen.
|
|
319
|
+
* Without a sink it goes to stderr, which the decode worker's parent inherits
|
|
320
|
+
* but does NOT forward to the scoped logger — so the worker installs one at
|
|
321
|
+
* boot (`decode-worker-child.ts`) to get the line into `addons.getLogs` with its
|
|
322
|
+
* `[dev:<id>]` prefix.
|
|
323
|
+
*/
|
|
324
|
+
function setSharpWarnSink(sink) {
|
|
325
|
+
warnSink = sink;
|
|
326
|
+
}
|
|
327
|
+
var defaultLoader = createSharpLoader({ warn: (message) => {
|
|
328
|
+
if (warnSink) warnSink(message);
|
|
329
|
+
else process.stderr.write(`${message}\n`);
|
|
330
|
+
} });
|
|
331
|
+
/**
|
|
332
|
+
* The `sharp` factory, resolved once per process.
|
|
333
|
+
*
|
|
334
|
+
* Rejects with {@link SharpUnavailableError} — immediately, and without touching
|
|
335
|
+
* the module loader — once resolution has been proven impossible here.
|
|
336
|
+
*/
|
|
337
|
+
function getSharp() {
|
|
338
|
+
return defaultLoader.load();
|
|
339
|
+
}
|
|
340
|
+
//#endregion
|
|
341
|
+
export { setSharpWarnSink as n, hostExternalEntryUrls as r, getSharp as t };
|