spana-test 0.6.0 → 0.7.0
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/.agents/skills/spana-testing/SKILL.md +19 -15
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +3 -3
- package/dist/{app-DcLXtpv4.d.ts → app-D_UyZBsl.d.ts} +9 -2
- package/dist/{chunk-S4JVAHBR.js → chunk-2IXXEXTL.js} +2 -2
- package/dist/{chunk-4K3FZTSV.js → chunk-54ASKII6.js} +6 -2
- package/dist/chunk-54ASKII6.js.map +1 -0
- package/dist/{chunk-KEUZLBQS.js → chunk-6B5Y75V4.js} +544 -79
- package/dist/chunk-6B5Y75V4.js.map +1 -0
- package/dist/{chunk-KBRLIQRA.js → chunk-JYFPZRCN.js} +6 -3
- package/dist/chunk-JYFPZRCN.js.map +1 -0
- package/dist/{chunk-WBBMEAHU.js → chunk-KNSAHEXI.js} +3 -3
- package/dist/{chunk-C4E4XULT.js → chunk-RURZVMZ7.js} +3 -3
- package/dist/{chunk-LCV673G3.js → chunk-T3EBOYLS.js} +154 -26
- package/dist/chunk-T3EBOYLS.js.map +1 -0
- package/dist/{chunk-PWUJT5HE.js → chunk-T5CROOR7.js} +3 -3
- package/dist/cli.js +8 -8
- package/dist/config-loader-NIDQGP3K.js +9 -0
- package/dist/{doctor-command-WEHFANT7.js → doctor-command-WPEVZEZ4.js} +3 -3
- package/dist/{flow-C2JQ7gUu.d.ts → flow-g6AICPAl.d.ts} +1 -1
- package/dist/gherkin/steps.d.ts +2 -2
- package/dist/{html-F3X3XPSX.js → html-IKCTZH2U.js} +194 -3
- package/dist/html-IKCTZH2U.js.map +1 -0
- package/dist/index.d.ts +228 -7
- package/dist/index.js +161 -7
- package/dist/index.js.map +1 -1
- package/dist/{screenshot-compare-5NINZVOK.js → screenshot-compare-POTXVUTL.js} +2 -2
- package/dist/{server-OANRDAHN.js → server-EBPYK3VE.js} +4 -4
- package/dist/{server-3MGZNK67.js → server-IGLBFEU7.js} +2 -2
- package/dist/{session-Q3QYHT4Q.js → session-QRWH3SPW.js} +4 -4
- package/dist/{session-Daq0mE_a.d.ts → session-cJ_tZjCL.d.ts} +1 -1
- package/dist/{studio-command-RJYLJT4I.js → studio-command-FLA5HKRK.js} +2 -2
- package/dist/{test-command-ALH5ZQY5.js → test-command-P5W7UD52.js} +7 -7
- package/package.json +2 -1
- package/dist/chunk-4K3FZTSV.js.map +0 -1
- package/dist/chunk-KBRLIQRA.js.map +0 -1
- package/dist/chunk-KEUZLBQS.js.map +0 -1
- package/dist/chunk-LCV673G3.js.map +0 -1
- package/dist/config-loader-J4Z2PMUQ.js +0 -9
- package/dist/html-F3X3XPSX.js.map +0 -1
- /package/dist/{chunk-S4JVAHBR.js.map → chunk-2IXXEXTL.js.map} +0 -0
- /package/dist/{chunk-WBBMEAHU.js.map → chunk-KNSAHEXI.js.map} +0 -0
- /package/dist/{chunk-C4E4XULT.js.map → chunk-RURZVMZ7.js.map} +0 -0
- /package/dist/{chunk-PWUJT5HE.js.map → chunk-T5CROOR7.js.map} +0 -0
- /package/dist/{config-loader-J4Z2PMUQ.js.map → config-loader-NIDQGP3K.js.map} +0 -0
- /package/dist/{doctor-command-WEHFANT7.js.map → doctor-command-WPEVZEZ4.js.map} +0 -0
- /package/dist/{screenshot-compare-5NINZVOK.js.map → screenshot-compare-POTXVUTL.js.map} +0 -0
- /package/dist/{server-OANRDAHN.js.map → server-EBPYK3VE.js.map} +0 -0
- /package/dist/{server-3MGZNK67.js.map → server-IGLBFEU7.js.map} +0 -0
- /package/dist/{session-Q3QYHT4Q.js.map → session-QRWH3SPW.js.map} +0 -0
- /package/dist/{studio-command-RJYLJT4I.js.map → studio-command-FLA5HKRK.js.map} +0 -0
- /package/dist/{test-command-ALH5ZQY5.js.map → test-command-P5W7UD52.js.map} +0 -0
|
@@ -12,16 +12,18 @@ Full online docs & LLM reference: `https://spana.antonwester.se/llms-full.txt`
|
|
|
12
12
|
|
|
13
13
|
When connected to `spana mcp` (`npx spana mcp` / `bunx spana mcp`), drive live sessions directly at sub-5 ms tool latency instead of shelling out repeatedly:
|
|
14
14
|
|
|
15
|
-
| MCP Tool
|
|
16
|
-
|
|
|
17
|
-
| `spana_session_start`
|
|
18
|
-
| `spana_observe`
|
|
19
|
-
| `spana_tap` / `spana_input_text` / `spana_press_key` | Execute verified pointer/keyboard actions (2–4 ms
|
|
20
|
-
| `spana_assert_visible` / `spana_assert_text`
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
15
|
+
| MCP Tool | Purpose |
|
|
16
|
+
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
|
|
17
|
+
| `spana_session_start` | Start a live session (`web`, `android`, `ios`, `electron`, `electrobun`) |
|
|
18
|
+
| `spana_observe` | Compact interactive element tree (~273 tokens avg) with `testID` & bounds |
|
|
19
|
+
| `spana_tap` / `spana_fill` / `spana_input_text` / `spana_press_key` | Execute verified pointer/keyboard actions (1-RTT atomic `spana_fill` + 2–4 ms tap) |
|
|
20
|
+
| `spana_assert_visible` / `spana_assert_text` | Run real auto-waiting assertions (~1 ms on web) |
|
|
21
|
+
| `spana_assert_accessible` | Run live `axe-core` WCAG accessibility audit on the current screen |
|
|
22
|
+
| `spana_assert_screenshot` | Run Rust-accelerated visual regression diff against saved baselines |
|
|
23
|
+
| `spana_diagnostics` | Fetch browser console logs & uncaught JS errors (~0.8 ms) |
|
|
24
|
+
| `spana_screenshot` | Capture PNG screenshot when visual inspection is needed |
|
|
25
|
+
| `spana_export_flow` | Export the verified action trace as a deterministic `.flow.ts` file |
|
|
26
|
+
| `spana_run_flow` / `spana_session_stop` | Execute existing `.flow.ts` files and cleanly tear down |
|
|
25
27
|
|
|
26
28
|
---
|
|
27
29
|
|
|
@@ -171,10 +173,12 @@ export default defineConfig({
|
|
|
171
173
|
|
|
172
174
|
---
|
|
173
175
|
|
|
174
|
-
## Failure Investigation
|
|
176
|
+
## Failure Investigation & Fixing Application Bugs
|
|
175
177
|
|
|
176
|
-
When a flow fails,
|
|
178
|
+
When a flow fails, decide first whether the bug is in the **test** or in the **application under test** — never paper over real app bugs with `sleep()` or loosened assertions:
|
|
177
179
|
|
|
178
|
-
1.
|
|
179
|
-
2.
|
|
180
|
-
3.
|
|
180
|
+
1. **Inspect `failure-bundle.json` and `report.html` playback** in `.spana/artifacts/` (or `spana-output/`): check the visual timeline frames + click-ripple position, failed step, nearby selectors, inline `consoleLogs`, and uncaught `jsErrors`.
|
|
181
|
+
2. **Fix missing `data-testid` / `testID` in the app** when an interactive control has no stable selector (`spana_observe` shows unlabelled buttons/inputs) — add `data-testid` to the component rather than relying on fragile text/coordinate selectors.
|
|
182
|
+
3. **Fix hydration / overlay races in the app** when taps wait on obscured overlays or fire before client state boots — set `window.__SPANA_APP_READY__ = true` once hydration/auth settles (Spana automatically awaits it) and guard async tab/filter fetches with `AbortController` or a request sequence counter so stale responses cannot overwrite newer UI state.
|
|
183
|
+
4. **Fix accessibility violations in the app** when `spana_assert_accessible` / `toPassAccessibilityAudit()` reports WCAG failures — repair missing `aria-label`s, `<label htmlFor>`, button semantics, and color contrast in the component source rather than excluding rules.
|
|
184
|
+
5. **Eliminate flaky test setup** — use `app.fill()` (atomic 1-RTT clear+type), `definePersona()` / `PersonaAuthCache` / `createApiFixture()` instead of repeated UI login, `execution.web.engine: "auto"` (Direct CDP with automatic OOPIF iframe support), `artifacts.video: "retain-on-failure"` + `artifacts.playback: true` for visual debugging, and always run `spana validate` before `spana test`.
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { C as ConnectOptions, D as Direction, S as Session, a as SuggestedSelector, c as connect } from '../session-
|
|
2
|
-
import '../app-
|
|
1
|
+
export { C as ConnectOptions, D as Direction, S as Session, a as SuggestedSelector, c as connect } from '../session-cJ_tZjCL.js';
|
|
2
|
+
import '../app-D_UyZBsl.js';
|
|
3
3
|
import 'effect';
|
|
4
4
|
|
|
5
5
|
interface ValidationError {
|
package/dist/agent/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import "../chunk-PLE7RFQE.js";
|
|
|
5
5
|
import {
|
|
6
6
|
Session,
|
|
7
7
|
connect
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-KNSAHEXI.js";
|
|
9
9
|
import "../chunk-HCG4CJKR.js";
|
|
10
|
-
import "../chunk-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-T5CROOR7.js";
|
|
11
|
+
import "../chunk-T3EBOYLS.js";
|
|
12
12
|
import "../chunk-HYSTRWYN.js";
|
|
13
13
|
import "../chunk-DTNK54C2.js";
|
|
14
14
|
import "../chunk-S5JNNDXS.js";
|
|
@@ -559,8 +559,9 @@ interface ElectrobunAppConfig {
|
|
|
559
559
|
bridge?: BridgeConfig;
|
|
560
560
|
}
|
|
561
561
|
type BrowserName = "chromium" | "firefox" | "webkit";
|
|
562
|
-
type WebBrowserEngine = "playwright" | "cdp" | "lightpanda";
|
|
562
|
+
type WebBrowserEngine = "auto" | "playwright" | "cdp" | "lightpanda";
|
|
563
563
|
type WebResourceBlockType = "image" | "font" | "media" | "stylesheet";
|
|
564
|
+
type VideoRecordingMode = "off" | "on" | "retain-on-failure";
|
|
564
565
|
type StorybookValue = string | number | boolean | null;
|
|
565
566
|
interface StorybookConfig {
|
|
566
567
|
/** Optional dedicated Storybook URL (falls back to apps.web.url when omitted) */
|
|
@@ -688,6 +689,10 @@ interface ArtifactConfig {
|
|
|
688
689
|
consoleLogs?: boolean;
|
|
689
690
|
jsErrors?: boolean;
|
|
690
691
|
har?: boolean;
|
|
692
|
+
/** Video / screencast recording mode: "off" (default), "on", or "retain-on-failure". */
|
|
693
|
+
video?: VideoRecordingMode;
|
|
694
|
+
/** Embed interactive step-by-step visual playback timeline inside report.html (auto-enabled when video !== "off"). */
|
|
695
|
+
playback?: boolean;
|
|
691
696
|
}
|
|
692
697
|
interface HookContext {
|
|
693
698
|
app: unknown;
|
|
@@ -723,6 +728,8 @@ interface ProvConfig {
|
|
|
723
728
|
retryDelay?: number;
|
|
724
729
|
/** Max workers per platform when using --parallel. */
|
|
725
730
|
workers?: number;
|
|
731
|
+
/** Max in-process workers before automatically sharding across multiple OS processes (default: 8). */
|
|
732
|
+
maxWorkersPerProcess?: number;
|
|
726
733
|
/** Default tap mode when a DOM channel resolves an element: "native" (real touch, default) or "dom" (fast synthetic click). */
|
|
727
734
|
tapMode?: TapMode;
|
|
728
735
|
/** Pin device locale across targets so system UI sheet labels stay deterministic. */
|
|
@@ -905,4 +912,4 @@ interface PromiseApp<T extends string = string, R extends string = string> {
|
|
|
905
912
|
switchToNativeApp(): Promise<void>;
|
|
906
913
|
}
|
|
907
914
|
|
|
908
|
-
export {
|
|
915
|
+
export { type WebResourceBlockType as $, type AppiumExecutionConfig as A, type BrowserRouteMatcher as B, type DeviceStateConfig as C, DriverError as D, type ExtendedSelector as E, type DismissKeyboardOptions as F, type DomChannelKind as G, type DomRect as H, type ElectronAppConfig as I, type RelativeSelector as J, type ScrollUntilVisibleOptions as K, type LaunchOptions as L, type StorybookConfig as M, type StorybookOpenOptions as N, type StorybookValue as O, type Platform as P, type TouchAction as Q, type RawDriverService as R, type Selector as S, type TapMode as T, type TouchSequence as U, type VirtualAuthenticatorOptions as V, type VideoRecordingMode as W, type VirtualCredential as X, type WarmDaemonConfig as Y, type WebBrowserEngine as Z, type WebExecutionConfig as _, type DomElementMatch as a, buildDomFillScript as a0, buildDomWaitForHiddenScript as a1, buildDomWaitForMatchScript as a2, buildDomWaitForSelectorScript as a3, defineConfig as a4, isSystemUISelector as a5, isTestIDSelector as a6, systemUI as a7, type WaitOptions as a8, type ProvConfig as b, type DomChannel as c, type DomTargetInfo as d, type DomWaitForSelectorOptions as e, type DomWaitForHiddenOptions as f, type DomWaitForMatchOptions as g, type DomWaitForMatchResult as h, type DomFillOptions as i, type DomIdleOptions as j, type DomStorageEntries as k, type DomClearStorageOptions as l, type BrowserMockResponse as m, type BrowserConsoleLog as n, type BrowserJSError as o, type BrowserName as p, type ElectrobunAppConfig as q, type ElectrobunRenderer as r, type AppConfig as s, type PromiseApp as t, type ArtifactConfig as u, type BackUntilVisibleOptions as v, type BridgeConfig as w, type BrowserHAR as x, type BrowserNetworkConditions as y, DeviceInfo as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
formatConfigValidationError,
|
|
3
3
|
validateConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-JYFPZRCN.js";
|
|
5
5
|
|
|
6
6
|
// src/cli/config-loader.ts
|
|
7
7
|
import { existsSync } from "fs";
|
|
@@ -123,4 +123,4 @@ ${formatConfigValidationError(error)}`,
|
|
|
123
123
|
export {
|
|
124
124
|
loadConfig
|
|
125
125
|
};
|
|
126
|
-
//# sourceMappingURL=chunk-
|
|
126
|
+
//# sourceMappingURL=chunk-2IXXEXTL.js.map
|
|
@@ -14,9 +14,13 @@ function findNativeLibraryPath() {
|
|
|
14
14
|
const envOverride = process.env["SPANA_NATIVE_LIB"];
|
|
15
15
|
if (envOverride && existsSync(envOverride)) return envOverride;
|
|
16
16
|
const file = libFileName();
|
|
17
|
+
const platformArch = `${process.platform}-${process.arch}`;
|
|
17
18
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
18
19
|
const candidates = [
|
|
19
|
-
//
|
|
20
|
+
// Prebuilt platform-arch binaries bundled in npm package (packages/spana/native/<platform>-<arch>/)
|
|
21
|
+
resolve(here, "../../native", platformArch, file),
|
|
22
|
+
resolve(here, "../native", platformArch, file),
|
|
23
|
+
// Flat bundled path
|
|
20
24
|
resolve(here, "../../native", file),
|
|
21
25
|
resolve(here, "../native", file),
|
|
22
26
|
// Monorepo cargo release / debug output
|
|
@@ -176,4 +180,4 @@ export {
|
|
|
176
180
|
comparePngNative,
|
|
177
181
|
tokenizeXmlNative
|
|
178
182
|
};
|
|
179
|
-
//# sourceMappingURL=chunk-
|
|
183
|
+
//# sourceMappingURL=chunk-54ASKII6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/native-accel.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport interface NativePngCompareResult {\n match: boolean;\n sizeMismatch: boolean;\n diffPixelCount: number;\n diffPixelRatio: number;\n diffImage?: Buffer;\n}\n\nexport interface NativeXmlRawNode {\n tagName: string;\n attrs: Record<string, string>;\n children: NativeXmlRawNode[];\n}\n\ninterface LoadedNativeLib {\n comparePng: (\n expected: Buffer | Uint8Array,\n actual: Buffer | Uint8Array,\n threshold: number,\n maxDiffRatio: number,\n layoutTolerant: boolean,\n ) => NativePngCompareResult | null;\n tokenizeXml: (xml: string, wrapperTag: string) => NativeXmlRawNode[] | null;\n libraryPath: string;\n}\n\nlet loadAttempted = false;\nlet cachedLib: LoadedNativeLib | null = null;\n\nfunction libFileName(): string {\n if (process.platform === \"darwin\") return \"libspana_native.dylib\";\n if (process.platform === \"win32\") return \"spana_native.dll\";\n return \"libspana_native.so\";\n}\n\nfunction findNativeLibraryPath(): string | null {\n const envOverride = process.env[\"SPANA_NATIVE_LIB\"];\n if (envOverride && existsSync(envOverride)) return envOverride;\n\n const file = libFileName();\n const platformArch = `${process.platform}-${process.arch}`;\n const here = dirname(fileURLToPath(import.meta.url));\n const candidates = [\n // Prebuilt platform-arch binaries bundled in npm package (packages/spana/native/<platform>-<arch>/)\n resolve(here, \"../../native\", platformArch, file),\n resolve(here, \"../native\", platformArch, file),\n // Flat bundled path\n resolve(here, \"../../native\", file),\n resolve(here, \"../native\", file),\n // Monorepo cargo release / debug output\n resolve(here, \"../../../spana-native/target/release\", file),\n resolve(here, \"../../../../packages/spana-native/target/release\", file),\n resolve(process.cwd(), \"packages/spana-native/target/release\", file),\n ];\n\n for (const candidate of candidates) {\n if (existsSync(candidate)) return candidate;\n }\n return null;\n}\n\nfunction loadNativeAccelerator(): LoadedNativeLib | null {\n if (loadAttempted) return cachedLib;\n loadAttempted = true;\n\n if (process.env[\"SPANA_DISABLE_NATIVE\"] === \"1\") {\n return null;\n }\n\n // Uses Bun's zero-overhead native FFI when running under Bun; Node.js falls back cleanly to JS\n if (typeof (globalThis as Record<string, unknown>)[\"Bun\"] === \"undefined\") {\n return null;\n }\n\n const libPath = findNativeLibraryPath();\n if (!libPath) return null;\n\n try {\n // Dynamic createRequire so bundlers targeting Node never fail on `bun:ffi`\n const req = createRequire(import.meta.url);\n const ffiModuleName = [\"bun\", \"ffi\"].join(\":\");\n const ffi = req(ffiModuleName) as {\n dlopen: (path: string, symbols: Record<string, unknown>) => { symbols: Record<string, any> };\n FFIType: Record<string, string>;\n ptr: (buf: Uint8Array) => number;\n toArrayBuffer: (p: number, offset: number, length: number) => ArrayBuffer;\n };\n\n const lib = ffi.dlopen(libPath, {\n spana_compare_png: {\n args: [\n ffi.FFIType.ptr,\n ffi.FFIType.u64,\n ffi.FFIType.ptr,\n ffi.FFIType.u64,\n ffi.FFIType.f64,\n ffi.FFIType.f64,\n ffi.FFIType.i32,\n ffi.FFIType.ptr,\n ],\n returns: ffi.FFIType.void,\n },\n spana_tokenize_xml: {\n args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr],\n returns: ffi.FFIType.i32,\n },\n spana_free_buffer: {\n args: [ffi.FFIType.ptr, ffi.FFIType.u64],\n returns: ffi.FFIType.void,\n },\n });\n\n const { spana_compare_png, spana_tokenize_xml, spana_free_buffer } = lib.symbols;\n\n // Struct layout of NativeCompareResult (repr(C) on 64-bit):\n // offset 0: matched (i32)\n // offset 4: size_mismatch (i32)\n // offset 8: diff_pixel_count (u32)\n // offset 12: [4 bytes padding]\n // offset 16: diff_pixel_ratio (f64)\n // offset 24: diff_png_ptr (*mut u8 / u64)\n // offset 32: diff_png_len (usize / u64)\n // Total = 40 bytes\n const resultScratch = new ArrayBuffer(40);\n const resultView = new DataView(resultScratch);\n const resultBytes = new Uint8Array(resultScratch);\n\n // Struct layout of NativeBuffer (repr(C) on 64-bit):\n // offset 0: ptr (*mut u8 / u64)\n // offset 8: len (usize / u64)\n const bufScratch = new ArrayBuffer(16);\n const bufView = new DataView(bufScratch);\n const bufBytes = new Uint8Array(bufScratch);\n\n const textEncoder = new TextEncoder();\n const textDecoder = new TextDecoder();\n\n cachedLib = {\n libraryPath: libPath,\n\n comparePng: (expected, actual, threshold, maxDiffRatio, layoutTolerant) => {\n const expArr = expected instanceof Uint8Array ? expected : new Uint8Array(expected);\n const actArr = actual instanceof Uint8Array ? actual : new Uint8Array(actual);\n if (expArr.byteLength === 0 || actArr.byteLength === 0) return null;\n\n spana_compare_png(\n ffi.ptr(expArr),\n expArr.byteLength,\n ffi.ptr(actArr),\n actArr.byteLength,\n threshold,\n maxDiffRatio,\n layoutTolerant ? 1 : 0,\n ffi.ptr(resultBytes),\n );\n\n const matched = resultView.getInt32(0, true);\n if (matched < 0) return null;\n const sizeMismatch = resultView.getInt32(4, true) !== 0;\n const diffPixelCount = resultView.getUint32(8, true);\n const diffPixelRatio = resultView.getFloat64(16, true);\n const diffPtr = Number(resultView.getBigUint64(24, true));\n const diffLen = Number(resultView.getBigUint64(32, true));\n\n let diffImage: Buffer | undefined;\n if (diffPtr !== 0 && diffLen > 0) {\n try {\n const view = new Uint8Array(ffi.toArrayBuffer(diffPtr, 0, diffLen));\n diffImage = Buffer.from(view);\n } finally {\n spana_free_buffer(diffPtr, diffLen);\n }\n }\n\n return {\n match: matched === 1,\n sizeMismatch,\n diffPixelCount,\n diffPixelRatio,\n ...(diffImage ? { diffImage } : {}),\n };\n },\n\n tokenizeXml: (xml, wrapperTag) => {\n const xmlBytes = textEncoder.encode(xml);\n if (xmlBytes.byteLength === 0) return [];\n const wrapBytes = textEncoder.encode(wrapperTag);\n const rc = spana_tokenize_xml(\n ffi.ptr(xmlBytes),\n xmlBytes.byteLength,\n wrapBytes.byteLength > 0 ? ffi.ptr(wrapBytes) : 0,\n wrapBytes.byteLength,\n ffi.ptr(bufBytes),\n );\n if (rc !== 0) return null;\n\n const outPtr = Number(bufView.getBigUint64(0, true));\n const outLen = Number(bufView.getBigUint64(8, true));\n if (outPtr === 0 || outLen === 0) return [];\n\n try {\n const slice = new Uint8Array(ffi.toArrayBuffer(outPtr, 0, outLen));\n const jsonStr = textDecoder.decode(slice);\n return JSON.parse(jsonStr) as NativeXmlRawNode[];\n } finally {\n spana_free_buffer(outPtr, outLen);\n }\n },\n };\n\n return cachedLib;\n } catch {\n return null;\n }\n}\n\n/** Check whether Spana's native Rust accelerator (`libspana_native`) is loaded and active. */\nexport function isNativeAcceleratorActive(): boolean {\n return loadNativeAccelerator() !== null;\n}\n\n/** Return the loaded native Rust library path, or `null` when running in pure-JS fallback mode. */\nexport function getNativeAcceleratorPath(): string | null {\n return loadNativeAccelerator()?.libraryPath ?? null;\n}\n\n/** Accelerated Rust PNG diff (returns `null` if unavailable so caller falls back cleanly to JS). */\nexport function comparePngNative(\n expected: Buffer | Uint8Array,\n actual: Buffer | Uint8Array,\n threshold: number,\n maxDiffRatio: number,\n layoutTolerant: boolean,\n): NativePngCompareResult | null {\n const lib = loadNativeAccelerator();\n if (!lib) return null;\n try {\n return lib.comparePng(expected, actual, threshold, maxDiffRatio, layoutTolerant);\n } catch {\n return null;\n }\n}\n\n/** Accelerated Rust XML hierarchy tokenizer (returns `null` if unavailable so caller falls back to JS). */\nexport function tokenizeXmlNative(xml: string, wrapperTag: string): NativeXmlRawNode[] | null {\n const lib = loadNativeAccelerator();\n if (!lib) return null;\n try {\n return lib.tokenizeXml(xml, wrapperTag);\n } catch {\n return null;\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAC9B,SAAS,SAAS,eAAe;AACjC,SAAS,qBAAqB;AA4B9B,IAAI,gBAAgB;AACpB,IAAI,YAAoC;AAExC,SAAS,cAAsB;AA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