spana-test 0.5.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 +126 -246
- package/README.md +2 -2
- package/dist/agent/index.d.ts +2 -2
- package/dist/agent/index.js +5 -5
- package/dist/{storybook-CxaP3YDz.d.ts → app-D_UyZBsl.d.ts} +213 -10
- package/dist/{chunk-WSA5QPTA.js → chunk-2IXXEXTL.js} +2 -2
- package/dist/{chunk-3YE2POGD.js → chunk-3SH5JQF7.js} +143 -3
- package/dist/chunk-3SH5JQF7.js.map +1 -0
- package/dist/chunk-54ASKII6.js +183 -0
- package/dist/chunk-54ASKII6.js.map +1 -0
- package/dist/{chunk-LRGT342X.js → chunk-6B5Y75V4.js} +1633 -533
- package/dist/chunk-6B5Y75V4.js.map +1 -0
- package/dist/{chunk-SQL3YRR5.js → chunk-JYFPZRCN.js} +21 -3
- package/dist/chunk-JYFPZRCN.js.map +1 -0
- package/dist/{chunk-UJQ7PID5.js → chunk-KNSAHEXI.js} +78 -3
- package/dist/chunk-KNSAHEXI.js.map +1 -0
- package/dist/{chunk-3TRMQCUT.js → chunk-PLE7RFQE.js} +31 -2
- package/dist/chunk-PLE7RFQE.js.map +1 -0
- package/dist/{chunk-H3RWZCID.js → chunk-RURZVMZ7.js} +104 -3
- package/dist/chunk-RURZVMZ7.js.map +1 -0
- package/dist/{chunk-XENRC3YO.js → chunk-T3EBOYLS.js} +751 -59
- package/dist/chunk-T3EBOYLS.js.map +1 -0
- package/dist/{chunk-PJKIXVSO.js → chunk-T5CROOR7.js} +898 -238
- package/dist/chunk-T5CROOR7.js.map +1 -0
- package/dist/{chunk-5245YBLL.js → chunk-Y2RZNOKU.js} +2 -2
- package/dist/cli.js +11 -11
- package/dist/cli.js.map +1 -1
- package/dist/config-loader-NIDQGP3K.js +9 -0
- package/dist/{doctor-command-WB3O2H64.js → doctor-command-WPEVZEZ4.js} +3 -3
- package/dist/{filters-Q3ALKWZ5.js → filters-MQG2RMPX.js} +4 -2
- package/dist/flow-g6AICPAl.d.ts +95 -0
- 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 +436 -21
- package/dist/index.js +328 -7
- package/dist/index.js.map +1 -1
- package/dist/{runner-6HK62Q7B.js → runner-TF4OKPYP.js} +2 -2
- package/dist/{screenshot-compare-3QRHHSFZ.js → screenshot-compare-POTXVUTL.js} +21 -1
- package/dist/screenshot-compare-POTXVUTL.js.map +1 -0
- package/dist/{server-PRM7BVVD.js → server-EBPYK3VE.js} +5 -5
- package/dist/{server-QWJJB3WG.js → server-IGLBFEU7.js} +2 -2
- package/dist/{session-2E6OK6BH.js → session-QRWH3SPW.js} +4 -4
- package/dist/{session-Ddem-Q5n.d.ts → session-cJ_tZjCL.d.ts} +22 -1
- package/dist/{studio-command-O3NN5BCG.js → studio-command-FLA5HKRK.js} +2 -2
- package/dist/{test-command-FYOZ6QAE.js → test-command-P5W7UD52.js} +24 -10
- package/dist/test-command-P5W7UD52.js.map +1 -0
- package/dist/{validator-HZ2A3NEI.js → validator-BLOLIHUY.js} +3 -3
- package/package.json +3 -2
- package/dist/chunk-3TRMQCUT.js.map +0 -1
- package/dist/chunk-3YE2POGD.js.map +0 -1
- package/dist/chunk-H3RWZCID.js.map +0 -1
- package/dist/chunk-LRGT342X.js.map +0 -1
- package/dist/chunk-PJKIXVSO.js.map +0 -1
- package/dist/chunk-SQL3YRR5.js.map +0 -1
- package/dist/chunk-UJQ7PID5.js.map +0 -1
- package/dist/chunk-XENRC3YO.js.map +0 -1
- package/dist/config-loader-XGDDJGVY.js +0 -9
- package/dist/flow-CyRC-tTc.d.ts +0 -176
- package/dist/html-F3X3XPSX.js.map +0 -1
- package/dist/screenshot-compare-3QRHHSFZ.js.map +0 -1
- package/dist/test-command-FYOZ6QAE.js.map +0 -1
- /package/dist/{chunk-WSA5QPTA.js.map → chunk-2IXXEXTL.js.map} +0 -0
- /package/dist/{chunk-5245YBLL.js.map → chunk-Y2RZNOKU.js.map} +0 -0
- /package/dist/{config-loader-XGDDJGVY.js.map → config-loader-NIDQGP3K.js.map} +0 -0
- /package/dist/{doctor-command-WB3O2H64.js.map → doctor-command-WPEVZEZ4.js.map} +0 -0
- /package/dist/{filters-Q3ALKWZ5.js.map → filters-MQG2RMPX.js.map} +0 -0
- /package/dist/{runner-6HK62Q7B.js.map → runner-TF4OKPYP.js.map} +0 -0
- /package/dist/{server-PRM7BVVD.js.map → server-EBPYK3VE.js.map} +0 -0
- /package/dist/{server-QWJJB3WG.js.map → server-IGLBFEU7.js.map} +0 -0
- /package/dist/{session-2E6OK6BH.js.map → session-QRWH3SPW.js.map} +0 -0
- /package/dist/{studio-command-O3NN5BCG.js.map → studio-command-FLA5HKRK.js.map} +0 -0
- /package/dist/{validator-HZ2A3NEI.js.map → validator-BLOLIHUY.js.map} +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// src/core/native-accel.ts
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import { dirname, resolve } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var loadAttempted = false;
|
|
7
|
+
var cachedLib = null;
|
|
8
|
+
function libFileName() {
|
|
9
|
+
if (process.platform === "darwin") return "libspana_native.dylib";
|
|
10
|
+
if (process.platform === "win32") return "spana_native.dll";
|
|
11
|
+
return "libspana_native.so";
|
|
12
|
+
}
|
|
13
|
+
function findNativeLibraryPath() {
|
|
14
|
+
const envOverride = process.env["SPANA_NATIVE_LIB"];
|
|
15
|
+
if (envOverride && existsSync(envOverride)) return envOverride;
|
|
16
|
+
const file = libFileName();
|
|
17
|
+
const platformArch = `${process.platform}-${process.arch}`;
|
|
18
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const candidates = [
|
|
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
|
|
24
|
+
resolve(here, "../../native", file),
|
|
25
|
+
resolve(here, "../native", file),
|
|
26
|
+
// Monorepo cargo release / debug output
|
|
27
|
+
resolve(here, "../../../spana-native/target/release", file),
|
|
28
|
+
resolve(here, "../../../../packages/spana-native/target/release", file),
|
|
29
|
+
resolve(process.cwd(), "packages/spana-native/target/release", file)
|
|
30
|
+
];
|
|
31
|
+
for (const candidate of candidates) {
|
|
32
|
+
if (existsSync(candidate)) return candidate;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
function loadNativeAccelerator() {
|
|
37
|
+
if (loadAttempted) return cachedLib;
|
|
38
|
+
loadAttempted = true;
|
|
39
|
+
if (process.env["SPANA_DISABLE_NATIVE"] === "1") {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
if (typeof globalThis["Bun"] === "undefined") {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const libPath = findNativeLibraryPath();
|
|
46
|
+
if (!libPath) return null;
|
|
47
|
+
try {
|
|
48
|
+
const req = createRequire(import.meta.url);
|
|
49
|
+
const ffiModuleName = ["bun", "ffi"].join(":");
|
|
50
|
+
const ffi = req(ffiModuleName);
|
|
51
|
+
const lib = ffi.dlopen(libPath, {
|
|
52
|
+
spana_compare_png: {
|
|
53
|
+
args: [
|
|
54
|
+
ffi.FFIType.ptr,
|
|
55
|
+
ffi.FFIType.u64,
|
|
56
|
+
ffi.FFIType.ptr,
|
|
57
|
+
ffi.FFIType.u64,
|
|
58
|
+
ffi.FFIType.f64,
|
|
59
|
+
ffi.FFIType.f64,
|
|
60
|
+
ffi.FFIType.i32,
|
|
61
|
+
ffi.FFIType.ptr
|
|
62
|
+
],
|
|
63
|
+
returns: ffi.FFIType.void
|
|
64
|
+
},
|
|
65
|
+
spana_tokenize_xml: {
|
|
66
|
+
args: [ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr, ffi.FFIType.u64, ffi.FFIType.ptr],
|
|
67
|
+
returns: ffi.FFIType.i32
|
|
68
|
+
},
|
|
69
|
+
spana_free_buffer: {
|
|
70
|
+
args: [ffi.FFIType.ptr, ffi.FFIType.u64],
|
|
71
|
+
returns: ffi.FFIType.void
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const { spana_compare_png, spana_tokenize_xml, spana_free_buffer } = lib.symbols;
|
|
75
|
+
const resultScratch = new ArrayBuffer(40);
|
|
76
|
+
const resultView = new DataView(resultScratch);
|
|
77
|
+
const resultBytes = new Uint8Array(resultScratch);
|
|
78
|
+
const bufScratch = new ArrayBuffer(16);
|
|
79
|
+
const bufView = new DataView(bufScratch);
|
|
80
|
+
const bufBytes = new Uint8Array(bufScratch);
|
|
81
|
+
const textEncoder = new TextEncoder();
|
|
82
|
+
const textDecoder = new TextDecoder();
|
|
83
|
+
cachedLib = {
|
|
84
|
+
libraryPath: libPath,
|
|
85
|
+
comparePng: (expected, actual, threshold, maxDiffRatio, layoutTolerant) => {
|
|
86
|
+
const expArr = expected instanceof Uint8Array ? expected : new Uint8Array(expected);
|
|
87
|
+
const actArr = actual instanceof Uint8Array ? actual : new Uint8Array(actual);
|
|
88
|
+
if (expArr.byteLength === 0 || actArr.byteLength === 0) return null;
|
|
89
|
+
spana_compare_png(
|
|
90
|
+
ffi.ptr(expArr),
|
|
91
|
+
expArr.byteLength,
|
|
92
|
+
ffi.ptr(actArr),
|
|
93
|
+
actArr.byteLength,
|
|
94
|
+
threshold,
|
|
95
|
+
maxDiffRatio,
|
|
96
|
+
layoutTolerant ? 1 : 0,
|
|
97
|
+
ffi.ptr(resultBytes)
|
|
98
|
+
);
|
|
99
|
+
const matched = resultView.getInt32(0, true);
|
|
100
|
+
if (matched < 0) return null;
|
|
101
|
+
const sizeMismatch = resultView.getInt32(4, true) !== 0;
|
|
102
|
+
const diffPixelCount = resultView.getUint32(8, true);
|
|
103
|
+
const diffPixelRatio = resultView.getFloat64(16, true);
|
|
104
|
+
const diffPtr = Number(resultView.getBigUint64(24, true));
|
|
105
|
+
const diffLen = Number(resultView.getBigUint64(32, true));
|
|
106
|
+
let diffImage;
|
|
107
|
+
if (diffPtr !== 0 && diffLen > 0) {
|
|
108
|
+
try {
|
|
109
|
+
const view = new Uint8Array(ffi.toArrayBuffer(diffPtr, 0, diffLen));
|
|
110
|
+
diffImage = Buffer.from(view);
|
|
111
|
+
} finally {
|
|
112
|
+
spana_free_buffer(diffPtr, diffLen);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
match: matched === 1,
|
|
117
|
+
sizeMismatch,
|
|
118
|
+
diffPixelCount,
|
|
119
|
+
diffPixelRatio,
|
|
120
|
+
...diffImage ? { diffImage } : {}
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
tokenizeXml: (xml, wrapperTag) => {
|
|
124
|
+
const xmlBytes = textEncoder.encode(xml);
|
|
125
|
+
if (xmlBytes.byteLength === 0) return [];
|
|
126
|
+
const wrapBytes = textEncoder.encode(wrapperTag);
|
|
127
|
+
const rc = spana_tokenize_xml(
|
|
128
|
+
ffi.ptr(xmlBytes),
|
|
129
|
+
xmlBytes.byteLength,
|
|
130
|
+
wrapBytes.byteLength > 0 ? ffi.ptr(wrapBytes) : 0,
|
|
131
|
+
wrapBytes.byteLength,
|
|
132
|
+
ffi.ptr(bufBytes)
|
|
133
|
+
);
|
|
134
|
+
if (rc !== 0) return null;
|
|
135
|
+
const outPtr = Number(bufView.getBigUint64(0, true));
|
|
136
|
+
const outLen = Number(bufView.getBigUint64(8, true));
|
|
137
|
+
if (outPtr === 0 || outLen === 0) return [];
|
|
138
|
+
try {
|
|
139
|
+
const slice = new Uint8Array(ffi.toArrayBuffer(outPtr, 0, outLen));
|
|
140
|
+
const jsonStr = textDecoder.decode(slice);
|
|
141
|
+
return JSON.parse(jsonStr);
|
|
142
|
+
} finally {
|
|
143
|
+
spana_free_buffer(outPtr, outLen);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return cachedLib;
|
|
148
|
+
} catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function isNativeAcceleratorActive() {
|
|
153
|
+
return loadNativeAccelerator() !== null;
|
|
154
|
+
}
|
|
155
|
+
function getNativeAcceleratorPath() {
|
|
156
|
+
return loadNativeAccelerator()?.libraryPath ?? null;
|
|
157
|
+
}
|
|
158
|
+
function comparePngNative(expected, actual, threshold, maxDiffRatio, layoutTolerant) {
|
|
159
|
+
const lib = loadNativeAccelerator();
|
|
160
|
+
if (!lib) return null;
|
|
161
|
+
try {
|
|
162
|
+
return lib.comparePng(expected, actual, threshold, maxDiffRatio, layoutTolerant);
|
|
163
|
+
} catch {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function tokenizeXmlNative(xml, wrapperTag) {
|
|
168
|
+
const lib = loadNativeAccelerator();
|
|
169
|
+
if (!lib) return null;
|
|
170
|
+
try {
|
|
171
|
+
return lib.tokenizeXml(xml, wrapperTag);
|
|
172
|
+
} catch {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
isNativeAcceleratorActive,
|
|
179
|
+
getNativeAcceleratorPath,
|
|
180
|
+
comparePngNative,
|
|
181
|
+
tokenizeXmlNative
|
|
182
|
+
};
|
|
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;AAC7B,MAAI,QAAQ,aAAa,SAAU,QAAO;AAC1C,MAAI,QAAQ,aAAa,QAAS,QAAO;AACzC,SAAO;AACT;AAEA,SAAS,wBAAuC;AAC9C,QAAM,cAAc,QAAQ,IAAI,kBAAkB;AAClD,MAAI,eAAe,WAAW,WAAW,EAAG,QAAO;AAEnD,QAAM,OAAO,YAAY;A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