Guard browser OPFS custom session filename constants

This commit is contained in:
2026-06-13 23:55:22 +08:00
parent 33ae88bc21
commit 2e3f242b90
2 changed files with 111 additions and 48 deletions

View File

@@ -2409,3 +2409,60 @@ browser/OPFS boundary guard不改变 LinuxCNC-owned interpreter、INI、tool
```bash ```bash
git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d
``` ```
四十一、2026-06-13 继续执行记录browser OPFS custom session filename constants guard
1. 本批目标。
继续 staged path guard inventory 第三十六轮,收敛 browser OPFS smoke 中 custom
session 的 repeated filename literals。
2. 已完成改动。
- INI-derived custom session block 新增局部 constants
`iniFileMachineId`、`iniFileParameterFilename`、`iniFileToolTableFilename`
- explicit override custom session block 新增局部 constants
`iniOverrideMachineId`、`explicitParameterFilename`、`explicitToolTableFilename`
- machine text、custom OPFS write、runtime input、session staging、save staging 均改为
复用对应局部 constants
- 常量只保留在 browser smoke 对应测试 block 内,避免扩大抽象范围;
- 未修改 OPFS bridge behavior、file-service、path-model、SDK planner、interpreter 或
LinuxCNC-owned runtime semantics。
涉及文件:
```text
wasm-port/tests/browser/interp_smoke.html
```
3. 已完成验证。
```bash
git diff --check
SKIP_INI_BUILD=1 SKIP_INTERP_BUILD=1 wasm-port/tests/browser/verify_interp_browser.sh
wasm-port/tools/verify_vendor_sync.sh
wasm-port/tools/verify_no_standalone_cnc_semantics.sh
SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_interp_wasm.sh
SKIP_INTERP_BUILD=1 wasm-port/tests/wasm/node/verify_sim_configs_inventory_wasm.sh
wasm-port/tests/host/verify_host_smokes.sh
```
提交建议:
```text
Guard browser OPFS custom session filename constants
```
4. 下一步工作建议。
继续 staged path guard inventory 第三十七轮,优先扫描 browser OPFS smoke 中 custom
session 的 INI WASM path (`/work/browser-ini-file-session.ini` 与
`/work/browser-ini-override-session.ini`) 是否值得同样局部常量化;仍只加 browser/OPFS
boundary guard不改变 LinuxCNC-owned interpreter、INI、tool、parameter 或 runtime
semantics。
下一轮第一条命令仍保持:
```bash
git status --short && git log -5 --oneline && tail -n 120 text7.txt && awk '/^[一二三四五六七八九十百]+、/ {print}' text7.txt | sort | uniq -d
```

View File

@@ -9395,27 +9395,30 @@
].join("\n"), ].join("\n"),
); );
const browserIniFileTextPaths = await saveMachineTextFiles("browser-ini-file-session", { const iniFileMachineId = "browser-ini-file-session";
const iniFileParameterFilename = "browser-custom.var";
const iniFileToolTableFilename = "browser-custom-tool.tbl";
const browserIniFileTextPaths = await saveMachineTextFiles(iniFileMachineId, {
ini: [ ini: [
"[EMC]", "[EMC]",
"MACHINE = browser-ini-file-session", `MACHINE = ${iniFileMachineId}`,
"", "",
"[RS274NGC]", "[RS274NGC]",
"PARAMETER_FILE = browser-custom.var", `PARAMETER_FILE = ${iniFileParameterFilename}`,
"", "",
"[EMCIO]", "[EMCIO]",
"TOOL_TABLE = browser-custom-tool.tbl", `TOOL_TABLE = ${iniFileToolTableFilename}`,
"", "",
].join("\n"), ].join("\n"),
}); });
assertMachineTextStorePaths( assertMachineTextStorePaths(
"opfs_save_ini_named_machine_text_files_staging", "opfs_save_ini_named_machine_text_files_staging",
browserIniFileTextPaths, browserIniFileTextPaths,
"browser-ini-file-session", iniFileMachineId,
); );
await writeOpfsMachineFile( await writeOpfsMachineFile(
"browser-ini-file-session", iniFileMachineId,
"browser-custom.var", iniFileParameterFilename,
[ [
"5161 31.25", "5161 31.25",
"5162 62.5", "5162 62.5",
@@ -9426,28 +9429,28 @@
].join("\n"), ].join("\n"),
); );
await writeOpfsMachineFile( await writeOpfsMachineFile(
"browser-ini-file-session", iniFileMachineId,
"browser-custom-tool.tbl", iniFileToolTableFilename,
"T8 P8 Z4.5 D0.5 ;browser custom tool\n", "T8 P8 Z4.5 D0.5 ;browser custom tool\n",
); );
const loadedIniFileSession = await loadMachineSessionFromOpfs( const loadedIniFileSession = await loadMachineSessionFromOpfs(
interp, interp,
"browser-ini-file-session", iniFileMachineId,
{ {
iniSdk: ini, iniSdk: ini,
iniWasmPath: "/work/browser-ini-file-session.ini", iniWasmPath: "/work/browser-ini-file-session.ini",
parameterWasmPath: opfsCustomSessionWasmPath("browser-custom.var"), parameterWasmPath: opfsCustomSessionWasmPath(iniFileParameterFilename),
toolTableWasmPath: opfsCustomSessionWasmPath("browser-custom-tool.tbl"), toolTableWasmPath: opfsCustomSessionWasmPath(iniFileToolTableFilename),
}, },
); );
assertOpfsSessionStaging( assertOpfsSessionStaging(
"opfs_load_ini_named_session_staging", "opfs_load_ini_named_session_staging",
loadedIniFileSession, loadedIniFileSession,
"browser-ini-file-session", iniFileMachineId,
opfsCustomSessionPaths( opfsCustomSessionPaths(
"browser-ini-file-session", iniFileMachineId,
"browser-custom.var", iniFileParameterFilename,
"browser-custom-tool.tbl", iniFileToolTableFilename,
"/work/browser-ini-file-session.ini", "/work/browser-ini-file-session.ini",
), ),
); );
@@ -9464,7 +9467,7 @@
); );
const savedIniNamedParameters = await saveMachineParametersToOpfs( const savedIniNamedParameters = await saveMachineParametersToOpfs(
interp, interp,
"browser-ini-file-session", iniFileMachineId,
{ {
5161: 33.75, 5161: 33.75,
5162: 67.5, 5162: 67.5,
@@ -9480,9 +9483,9 @@
assertOpfsSavedParameterStaging( assertOpfsSavedParameterStaging(
"opfs_save_ini_named_parameters_staging", "opfs_save_ini_named_parameters_staging",
savedIniNamedParameters, savedIniNamedParameters,
"browser-ini-file-session", iniFileMachineId,
"browser-custom.var", iniFileParameterFilename,
opfsCustomSessionWasmPath("browser-custom.var"), opfsCustomSessionWasmPath(iniFileParameterFilename),
); );
verifyExpectedOutput( verifyExpectedOutput(
"opfs_save_ini_named_parameter_file", "opfs_save_ini_named_parameter_file",
@@ -9529,7 +9532,7 @@
); );
const savedIniNamedToolTable = await saveMachineToolTableToOpfs( const savedIniNamedToolTable = await saveMachineToolTableToOpfs(
interp, interp,
"browser-ini-file-session", iniFileMachineId,
{ {
opfsPath: loadedIniFileSession.toolTable.opfsPath, opfsPath: loadedIniFileSession.toolTable.opfsPath,
wasmPath: loadedIniFileSession.toolTable.wasmPath, wasmPath: loadedIniFileSession.toolTable.wasmPath,
@@ -9538,9 +9541,9 @@
assertOpfsSavedToolTableStaging( assertOpfsSavedToolTableStaging(
"opfs_save_ini_named_tool_table_staging", "opfs_save_ini_named_tool_table_staging",
savedIniNamedToolTable, savedIniNamedToolTable,
"browser-ini-file-session", iniFileMachineId,
"browser-custom-tool.tbl", iniFileToolTableFilename,
opfsCustomSessionWasmPath("browser-custom-tool.tbl"), opfsCustomSessionWasmPath(iniFileToolTableFilename),
); );
verifyExpectedOutput( verifyExpectedOutput(
"opfs_save_ini_named_tool_table", "opfs_save_ini_named_tool_table",
@@ -9563,10 +9566,13 @@
].join("\n"), ].join("\n"),
); );
const browserIniOverrideTextPaths = await saveMachineTextFiles("browser-ini-override-session", { const iniOverrideMachineId = "browser-ini-override-session";
const explicitParameterFilename = "browser-explicit.var";
const explicitToolTableFilename = "browser-explicit-tool.tbl";
const browserIniOverrideTextPaths = await saveMachineTextFiles(iniOverrideMachineId, {
ini: [ ini: [
"[EMC]", "[EMC]",
"MACHINE = browser-ini-override-session", `MACHINE = ${iniOverrideMachineId}`,
"", "",
"[RS274NGC]", "[RS274NGC]",
"PARAMETER_FILE = browser-ignored.var", "PARAMETER_FILE = browser-ignored.var",
@@ -9579,11 +9585,11 @@
assertMachineTextStorePaths( assertMachineTextStorePaths(
"opfs_save_ini_override_machine_text_files_staging", "opfs_save_ini_override_machine_text_files_staging",
browserIniOverrideTextPaths, browserIniOverrideTextPaths,
"browser-ini-override-session", iniOverrideMachineId,
); );
await writeOpfsMachineFile( await writeOpfsMachineFile(
"browser-ini-override-session", iniOverrideMachineId,
"browser-explicit.var", explicitParameterFilename,
[ [
"5161 41.25", "5161 41.25",
"5162 82.5", "5162 82.5",
@@ -9594,30 +9600,30 @@
].join("\n"), ].join("\n"),
); );
await writeOpfsMachineFile( await writeOpfsMachineFile(
"browser-ini-override-session", iniOverrideMachineId,
"browser-explicit-tool.tbl", explicitToolTableFilename,
"T9 P9 Z5.5 D0.625 ;browser explicit tool\n", "T9 P9 Z5.5 D0.625 ;browser explicit tool\n",
); );
const loadedIniOverrideSession = await loadMachineSessionFromOpfs( const loadedIniOverrideSession = await loadMachineSessionFromOpfs(
interp, interp,
"browser-ini-override-session", iniOverrideMachineId,
{ {
iniSdk: ini, iniSdk: ini,
iniWasmPath: "/work/browser-ini-override-session.ini", iniWasmPath: "/work/browser-ini-override-session.ini",
parameterFilename: "browser-explicit.var", parameterFilename: explicitParameterFilename,
parameterWasmPath: opfsCustomSessionWasmPath("browser-explicit.var"), parameterWasmPath: opfsCustomSessionWasmPath(explicitParameterFilename),
toolTableFilename: "browser-explicit-tool.tbl", toolTableFilename: explicitToolTableFilename,
toolTableWasmPath: opfsCustomSessionWasmPath("browser-explicit-tool.tbl"), toolTableWasmPath: opfsCustomSessionWasmPath(explicitToolTableFilename),
}, },
); );
assertOpfsSessionStaging( assertOpfsSessionStaging(
"opfs_load_explicit_session_staging", "opfs_load_explicit_session_staging",
loadedIniOverrideSession, loadedIniOverrideSession,
"browser-ini-override-session", iniOverrideMachineId,
opfsCustomSessionPaths( opfsCustomSessionPaths(
"browser-ini-override-session", iniOverrideMachineId,
"browser-explicit.var", explicitParameterFilename,
"browser-explicit-tool.tbl", explicitToolTableFilename,
"/work/browser-ini-override-session.ini", "/work/browser-ini-override-session.ini",
), ),
); );
@@ -9646,7 +9652,7 @@
); );
const savedExplicitParameters = await saveMachineParametersToOpfs( const savedExplicitParameters = await saveMachineParametersToOpfs(
interp, interp,
"browser-ini-override-session", iniOverrideMachineId,
{ {
5161: 51.25, 5161: 51.25,
5162: 102.5, 5162: 102.5,
@@ -9662,9 +9668,9 @@
assertOpfsSavedParameterStaging( assertOpfsSavedParameterStaging(
"opfs_save_explicit_parameters_staging", "opfs_save_explicit_parameters_staging",
savedExplicitParameters, savedExplicitParameters,
"browser-ini-override-session", iniOverrideMachineId,
"browser-explicit.var", explicitParameterFilename,
opfsCustomSessionWasmPath("browser-explicit.var"), opfsCustomSessionWasmPath(explicitParameterFilename),
); );
verifyExpectedOutput( verifyExpectedOutput(
"opfs_save_explicit_parameter_file", "opfs_save_explicit_parameter_file",
@@ -9699,7 +9705,7 @@
); );
const savedExplicitToolTable = await saveMachineToolTableToOpfs( const savedExplicitToolTable = await saveMachineToolTableToOpfs(
interp, interp,
"browser-ini-override-session", iniOverrideMachineId,
{ {
opfsPath: loadedIniOverrideSession.toolTable.opfsPath, opfsPath: loadedIniOverrideSession.toolTable.opfsPath,
wasmPath: loadedIniOverrideSession.toolTable.wasmPath, wasmPath: loadedIniOverrideSession.toolTable.wasmPath,
@@ -9708,9 +9714,9 @@
assertOpfsSavedToolTableStaging( assertOpfsSavedToolTableStaging(
"opfs_save_explicit_tool_table_staging", "opfs_save_explicit_tool_table_staging",
savedExplicitToolTable, savedExplicitToolTable,
"browser-ini-override-session", iniOverrideMachineId,
"browser-explicit-tool.tbl", explicitToolTableFilename,
opfsCustomSessionWasmPath("browser-explicit-tool.tbl"), opfsCustomSessionWasmPath(explicitToolTableFilename),
); );
verifyExpectedOutput( verifyExpectedOutput(
"opfs_save_explicit_tool_table", "opfs_save_explicit_tool_table",