Guard browser OPFS session wasm path group helper

This commit is contained in:
2026-06-14 01:30:13 +08:00
parent 9757d196d1
commit 6a9f1c99df
2 changed files with 71 additions and 28 deletions

View File

@@ -4580,6 +4580,14 @@
return { ini, parameters, toolTable };
}
function opfsBrowserSessionWasmPaths(prefix) {
return opfsSessionWasmPaths(
`/work/${prefix}-machine.ini`,
`/work/${prefix}-linuxcnc.var`,
`/work/${prefix}-tool.tbl`,
);
}
function opfsCustomSessionPaths(machineId, parameterFilename, toolTableFilename, iniWasmPath) {
return {
opfs: {
@@ -9172,9 +9180,7 @@
);
const browserInterpMachineId = "browser-interp";
const browserInterpIniWasmPath = "/work/browser-machine.ini";
const browserInterpParameterWasmPath = "/work/browser-linuxcnc.var";
const browserInterpToolTableWasmPath = "/work/browser-tool.tbl";
const browserInterpWasmPaths = opfsBrowserSessionWasmPaths("browser");
const browserInterpTextPaths = await saveMachineTextFiles(browserInterpMachineId, {
ini: `[EMC]\nMACHINE = ${browserInterpMachineId}\n`,
toolTable: "T2 P7 Z3.125 D1.5 I12 J34 Q4 ;browser finish tool\n",
@@ -9197,9 +9203,9 @@
interp,
browserInterpMachineId,
{
iniWasmPath: browserInterpIniWasmPath,
parameterWasmPath: browserInterpParameterWasmPath,
toolTableWasmPath: browserInterpToolTableWasmPath,
iniWasmPath: browserInterpWasmPaths.ini,
parameterWasmPath: browserInterpWasmPaths.parameters,
toolTableWasmPath: browserInterpWasmPaths.toolTable,
},
);
assertOpfsSessionStaging(
@@ -9207,11 +9213,7 @@
loadedSession,
browserInterpMachineId,
{
wasm: opfsSessionWasmPaths(
browserInterpIniWasmPath,
browserInterpParameterWasmPath,
browserInterpToolTableWasmPath,
),
wasm: browserInterpWasmPaths,
},
);
verifyOpfsLoadResult(
@@ -9251,14 +9253,14 @@
5221: 9.87,
5399: 66.6,
},
{ wasmPath: browserInterpParameterWasmPath },
{ wasmPath: browserInterpWasmPaths.parameters },
);
assertOpfsSavedParameterStaging(
"opfs_save_parameters_staging",
savedParameters,
browserInterpMachineId,
OPFS_DEFAULT_PARAMETER_FILENAME,
browserInterpParameterWasmPath,
browserInterpWasmPaths.parameters,
);
verifyOpfsSaveResult(
"opfs_save_parameters",
@@ -9297,14 +9299,14 @@
const savedToolTable = await saveMachineToolTableToOpfs(
interp,
browserInterpMachineId,
{ wasmPath: browserInterpToolTableWasmPath },
{ wasmPath: browserInterpWasmPaths.toolTable },
);
assertOpfsSavedToolTableStaging(
"opfs_save_tool_table_staging",
savedToolTable,
browserInterpMachineId,
OPFS_DEFAULT_TOOL_TABLE_FILENAME,
browserInterpToolTableWasmPath,
browserInterpWasmPaths.toolTable,
);
verifyOpfsSaveResult(
"opfs_save_tool_table",
@@ -9332,9 +9334,7 @@
);
const browserRandomMachineId = "browser-random-toolchanger";
const browserRandomIniWasmPath = "/work/browser-random-machine.ini";
const browserRandomParameterWasmPath = "/work/browser-random-linuxcnc.var";
const browserRandomToolTableWasmPath = "/work/browser-random-tool.tbl";
const browserRandomWasmPaths = opfsBrowserSessionWasmPaths("browser-random");
const browserRandomTextPaths = await saveMachineTextFiles(browserRandomMachineId, {
ini: [
"[EMC]",
@@ -9368,9 +9368,9 @@
browserRandomMachineId,
{
iniSdk: ini,
iniWasmPath: browserRandomIniWasmPath,
parameterWasmPath: browserRandomParameterWasmPath,
toolTableWasmPath: browserRandomToolTableWasmPath,
iniWasmPath: browserRandomWasmPaths.ini,
parameterWasmPath: browserRandomWasmPaths.parameters,
toolTableWasmPath: browserRandomWasmPaths.toolTable,
},
);
assertOpfsSessionStaging(
@@ -9378,11 +9378,7 @@
loadedRandomSession,
browserRandomMachineId,
{
wasm: opfsSessionWasmPaths(
browserRandomIniWasmPath,
browserRandomParameterWasmPath,
browserRandomToolTableWasmPath,
),
wasm: browserRandomWasmPaths,
},
);
verifyOpfsLoadResult(
@@ -9407,14 +9403,14 @@
const savedRandomToolTable = await saveMachineToolTableToOpfs(
interp,
browserRandomMachineId,
{ wasmPath: browserRandomToolTableWasmPath },
{ wasmPath: browserRandomWasmPaths.toolTable },
);
assertOpfsSavedToolTableStaging(
"opfs_save_random_tool_table_staging",
savedRandomToolTable,
browserRandomMachineId,
OPFS_DEFAULT_TOOL_TABLE_FILENAME,
browserRandomToolTableWasmPath,
browserRandomWasmPaths.toolTable,
);
verifyOpfsSaveResult(
"opfs_save_random_tool_table",