结论:已新增 OPFS host-side 路径模型,覆盖 INI、tool table、parameter、G-code、preview cache 与 session snapshot 存储目标,并让 file-service 和浏览器 smoke 复用该模型;聚合 smoke 验证通过。
61 lines
1.9 KiB
HTML
61 lines
1.9 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>LinuxCNC INI Browser Smoke</title>
|
|
</head>
|
|
<body>
|
|
<pre id="status">running</pre>
|
|
<script type="module">
|
|
import { createLinuxCncIniSdk } from "../../runtime/sdk/src/linuxcnc-ini.js";
|
|
import { loadTextFile, saveTextFile } from "../../runtime/opfs/file-service.js";
|
|
import { machineIniPath } from "../../runtime/opfs/path-model.js";
|
|
|
|
const status = document.getElementById("status");
|
|
|
|
function assertEqual(actual, expected, label) {
|
|
if (actual !== expected) {
|
|
throw new Error(`${label}: expected ${expected}, got ${actual}`);
|
|
}
|
|
}
|
|
|
|
try {
|
|
const ini = await createLinuxCncIniSdk();
|
|
const wasmPath = "/work/browser-smoke.ini";
|
|
const iniText = `[EMC]
|
|
MACHINE = browser-smoke
|
|
|
|
[TRAJ]
|
|
LINEAR_UNITS = mm
|
|
COORDINATES = X Y Z
|
|
|
|
[KINS]
|
|
KINEMATICS = trivkins
|
|
JOINTS = 3
|
|
`;
|
|
|
|
ini.writeTextFile(wasmPath, iniText);
|
|
assertEqual(ini.getString(wasmPath, "EMC", "MACHINE"), "browser-smoke", "machine");
|
|
assertEqual(ini.getString(wasmPath, "TRAJ", "LINEAR_UNITS"), "mm", "units");
|
|
assertEqual(ini.getString(wasmPath, "KINS", "KINEMATICS"), "trivkins", "kinematics");
|
|
assertEqual(ini.getString(wasmPath, "TRAJ", "MISSING"), null, "missing tag");
|
|
|
|
const fields = ini.getFields(wasmPath, {
|
|
machine: { section: "EMC", tag: "MACHINE" },
|
|
joints: { section: "KINS", tag: "JOINTS" },
|
|
});
|
|
assertEqual(fields.machine, "browser-smoke", "field machine");
|
|
assertEqual(fields.joints, "3", "field joints");
|
|
|
|
const opfsPath = machineIniPath("browser-smoke");
|
|
await saveTextFile(opfsPath, iniText);
|
|
assertEqual(await loadTextFile(opfsPath), iniText, "opfs roundtrip");
|
|
|
|
status.textContent = "browser_ini_opfs_smoke=ok";
|
|
} catch (error) {
|
|
status.textContent = `browser_ini_opfs_smoke=fail ${error.stack || error.message}`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|