import type { TSciChart } from "../../types/TSciChart"; /** * The wasm modules this build knows how to load. `data` ships in v6; `charting` and `charting3d` * are named here because the loader is shared infrastructure and the union is the contract - the * artifacts arrive in Phases 2 and 3. */ export type TSciChartModuleName = "data" | "charting" | "charting3d"; /** * Wasm filenames a `locateFile` hook must always resolve by name relative to wherever the core * was found, and must NEVER rewrite via the wasmUrl/wasmNoSimdUrl/wasm64Url/NO_SIMD substitutions * those hooks otherwise apply to any ".wasm" path - a rewrite there silently hands back the wrong * binary. A name list, not a prefix test, so a customer file that happens to start "scichart-" is * never caught by it. * * The ABI anchor was here until the NEEDED strip: it was load-time linked, so emscripten asked for * it through `locateFile` at startup. `strip-dylink-needed.js` now empties each core's `dylink.0` * NEEDED list right after the link, so the anchor is a build input that is never fetched, never * served and never shipped - and must not appear in this list, which exists to describe the * artifacts a page really does request. * * The single exported source of truth: `getLocateFile` (`SciChartSurfaceBase.ts`) and the test * harness's own `locateFile` (`tests/sciChartInit2DTest.ts`) both import this rather than each * keeping their own literal copy, so Phase 2/3 add a module name here once, not in two files that * can silently diverge. */ export declare const NEVER_REWRITTEN_WASM: Set; /** * The wasm build variant a core (and therefore every module it loads) was built as. "simd" is the * default and carries NO filename suffix - `scichart-data.wasm` - matching the core's own naming * (`scichart.wasm` / `scichart-nosimd.wasm` / `scichart-64.wasm`). */ export type TWasmVariant = "simd" | "nosimd" | "64"; /** The one place a module artifact's filename is constructed - URL resolution AND error text. */ export declare const moduleFileName: (moduleName: TSciChartModuleName, variant: TWasmVariant) => string; export declare const isNeverRewrittenWasm: (path: string) => boolean; /** * Is this bundle the INTERNAL static (monolithic) build shape? The modular shape is the v6 * default: a consumer bundle that defines nothing gets the modular path, and this returns false. * * Reads the build-time flag `process.env.SCICHART_STATIC`, which only INTERNAL harnesses ever * define - the static/equivalence visual-test client via a webpack `DefinePlugin` *textual* * substitution, and the static unit suite as a real env var under Node. The static build is not * shipped to consumers; there is no runtime switch. * * THE TRY/CATCH IS LOAD-BEARING AND MUST NOT BE "SIMPLIFIED" TO A `typeof process` GUARD. There are * exactly two situations, and the two obvious spellings each break one of them: * * 1. **Internal static app** - `DefinePlugin` replaces the expression `process.env.SCICHART_STATIC` * with the literal `true` before this code ever runs, so no `process` reference survives and the * `catch` is unreachable. A `typeof process !== "undefined" &&` guard would break THIS case: * webpack does not define `process` itself, so `typeof process` is `"undefined"` on a real * browser page and the guard would evaluate to `false` *regardless of the substituted literal* - * silently sending the static client down the modular path. The same guard shipped once (on this * flag's predecessor, SCICHART_MODULAR) and silently disabled module loading; do not reintroduce it. * 2. **Consumer (modular, default) app** - nothing defines the key, so the expression survives into * the bundle as a live read of a global that webpack 5 does not polyfill. Reading it throws * `ReferenceError: process is not defined`, which the `catch` turns into "not static" - the * right answer, and the answer EVERY consumer bundle must get. Leaving the read unguarded would * throw inside `createMaster`/`createSingleInternal` for every chart of either dimension (it did * exactly that in SciChartDemo on the predecessor flag). `process.env.NODE_ENV` (used ~15 times * elsewhere in this library) does not have the problem, because webpack's `optimization.nodeEnv` * defines that ONE key automatically. * * `constants/app.ts` protects its own `process.env?.TEST_ENV` read with a `typeof process` guard, * which is correct THERE - that flag is only ever a real environment variable read in Node, never a * substituted literal - and is exactly why the guard looks safe here and is not. * * Not memoised at module scope on purpose: with the substitution in place this is a constant-folded * `return !!true`, and evaluating it lazily keeps the tests able to set the env var per-case in Node. */ export declare const isStaticBuild: () => boolean; /** * @deprecated The modular shape is the v6 default and `SCICHART_MODULAR` is no longer read. * Kept as an inverted alias of {@link isStaticBuild} for any internal caller not yet migrated. */ export declare const isModularBuild: () => boolean; /** * The registration-mechanism version the core was built against. Must match every module's * declared `abi`. Mirrors SCRTModuleRegistry.h's `SCRT_ADDON_ABI2_VERSION`. * * NOT derived from the header - this is a hand-maintained literal, unlike the native side of the * same check: `stampModuleSection.js --from-header` reads `SCRT_ADDON_ABI2_VERSION` straight out * of the header when it stamps a module, so a module's own declared `abi` can never drift from * the header. This constant has no equivalent mechanism (nothing in TypeScript can read a C++ * `#define`, and the core exposes no runtime query for its own registration-ABI version - only * `scrt_query_category`, which is per-category, not this). If `SCRT_ADDON_ABI2_VERSION` ever * changes, THIS LINE MUST BE UPDATED BY HAND IN THE SAME CHANGE, or validateModuleBytes compares * every module's (correctly-derived) stamp against a stale number here - which fails in the wrong * direction: a real mismatch would read as a false "matches" if both sides drifted together, or a * false rejection of a genuinely-fine module if only this side is stale. Residual risk - flagged * for whoever next bumps SCRT_ADDON_ABI2_VERSION, and for design review to decide whether a build- * time codegen step (mirroring --from-header) is worth adding. */ export declare const SCRT_MODULE_ABI_VERSION = 1; /** What the `scrt.module` custom section carries. Stamped at build time by * SciChart.Native/Web/WasmBuildScripts/stampModuleSection.js. */ type TModuleStamp = { module: TSciChartModuleName; abi: number; category: string; categoryVersion: number; /** Build variant ("simd" | "nosimd" | "64"). Absent on modules stamped before variant parity * (Task A6) - treated as "simd", the only variant that existed then. */ variant?: string; }; /** * Validates module bytes before emscripten sees them, because emscripten's own failures are not * debuggable from their messages: a truncated fetch, a version-skewed module and a core with too * narrow an export table all surface as errors naming neither the module nor the symbol * (`asyncLoad` calls `onerror()` with no argument at all). Everything this function rejects, it * rejects with the module name, the resolved URL and the fix. */ export declare const validateModuleBytes: (bytes: Uint8Array, moduleName: string, url: string, expectedVariant: TWasmVariant) => TModuleStamp; /** * Resolves a module's URL. Deliberately NOT routed through getLocateFile: that hook applies the * SIMD / wasmUrl rewrites, which are about the core binary and would rewrite a module filename * into the core's URL. `modulesUrl` lets a self-hoster put modules somewhere other than beside * the core; without it they resolve relative to the configured wasmUrl's directory, and failing * that relative to the page - which is what a default npm install wants. */ export declare const resolveModuleUrl: (moduleName: TSciChartModuleName, sciChartConfig: { wasmUrl?: string; modulesUrl?: string; }, variant: TWasmVariant) => string; /** * Loads a native wasm module into this wasm context, if it is not already loaded. * * Idempotent and race-safe: a second call while the first is in flight returns the SAME promise * OBJECT, not merely an equivalent one, so two surfaces created together neither double-fetch nor - * much worse - dlopen twice, which would double-register every embind type in the module. * * Deliberately NOT declared `async`, even though every call site just `await`s it: an `async` * function always wraps its result in a FRESH promise per call, even when the body itself * `return`s an existing one - so two concurrent callers would observe two DIFFERENT (if * equivalent) promise objects, silently breaking the guarantee this doc comment has claimed since * this function was written (Task 8's own test caught the gap - `expect(p1).to.equal(p2)` failed * against the `async` version, with the registry proving the DEDUPE was still functionally correct * regardless: the identity guarantee and the functional guarantee are two different things, and * only one of them held). Returning the SAME `Promise` reference (`load`, below) to every * caller while the load is in flight is what makes both checks actually true. * * In the static (monolithic) build there is nothing to load: the types are already present, so * this resolves immediately. Callers therefore never need to know which build shape they are on. */ export declare const ensureModule: (wasmContext: TSciChart, moduleName: TSciChartModuleName) => Promise; /** Which modules are loaded into this wasm context. */ export declare const getLoadedModules: (wasmContext: TSciChart) => TSciChartModuleName[]; /** * Throws a named, actionable error if `apiName` needs a module that has not been loaded. * * Detection is by probing for the symbol rather than by asking which build shape this is, which * makes it correct in both without a build-time flag: in the static build the symbol is always * there, and in the modular build it appears exactly when the module is dlopen'd. * * Deliberately a throw and not a fallback. Today's crossfilter path warns once and renders * unfiltered when it meets an unsupported resampler variant; that pattern is NOT extended here, * because a chart that silently renders unfiltered data is a wrong answer that looks correct. */ export declare const requireModule: (wasmContext: TSciChart, moduleName: TSciChartModuleName, probeSymbol: string, apiName: string) => void; export {};