推进 INI 面板 launch 暴露 control-page API 清单
This commit is contained in:
@@ -8,7 +8,9 @@
|
||||
<pre id="status">running</pre>
|
||||
<script type="module">
|
||||
import {
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellViewModel,
|
||||
getIniPanelEntryByHref,
|
||||
getVisibleIniPanelEntries,
|
||||
} from "../../runtime/ui/ini-panel/ui-shell.js";
|
||||
@@ -44,8 +46,17 @@
|
||||
"Open read-only control view",
|
||||
"launch manifest control entry",
|
||||
);
|
||||
assertEqual(
|
||||
createIniPanelShellViewModel().controlPage.browserApiMethods.join(","),
|
||||
createControlPageBrowserApiMethods().join(","),
|
||||
"launch shell control-page browser API methods",
|
||||
);
|
||||
|
||||
const launchDoc = await loadLaunchFrame();
|
||||
const launchApi = launchDoc.defaultView.linuxCncIniPanelLaunchApi;
|
||||
if (!launchApi?.getLauncherLinks || !launchApi?.getControlPageApiMethods) {
|
||||
throw new Error("launch API namespace did not expose shell helpers");
|
||||
}
|
||||
assertEqual(
|
||||
launchDoc.querySelector('a[href="./index.html"]').textContent,
|
||||
"Open edit and run panel",
|
||||
@@ -56,6 +67,16 @@
|
||||
"Open read-only control view",
|
||||
"launch panel control link",
|
||||
);
|
||||
assertEqual(
|
||||
launchApi.getLauncherLinks().length,
|
||||
2,
|
||||
"launch API launcher link count",
|
||||
);
|
||||
assertEqual(
|
||||
launchApi.getControlPageApiMethods().join(","),
|
||||
createControlPageBrowserApiMethods().join(","),
|
||||
"launch API control-page browser methods",
|
||||
);
|
||||
status.textContent = "browser_ini_launch_smoke=ok";
|
||||
console.log("browser_ini_launch_smoke=ok");
|
||||
} catch (error) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
INI_PANEL_ENTRIES,
|
||||
controlPageStatusText,
|
||||
createControlPageSessionLoadState,
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellViewModel,
|
||||
@@ -23,6 +24,7 @@ const root = resolve(__dirname, "../../..");
|
||||
const docText = readFileSync(resolve(root, "docs/panel-entry.md"), "utf8");
|
||||
const shellText = readFileSync(resolve(root, "runtime/ui/ini-panel/ui-shell.js"), "utf8");
|
||||
const controlPageText = readFileSync(resolve(root, "runtime/ui/ini-panel/control-page.js"), "utf8");
|
||||
const launchText = readFileSync(resolve(root, "runtime/ui/ini-panel/launch.html"), "utf8");
|
||||
const refreshWorkflowText = readFileSync(
|
||||
resolve(root, "runtime/ui/ini-panel/control-page-refresh-workflow.js"),
|
||||
"utf8",
|
||||
@@ -35,6 +37,7 @@ const sessionWorkflowText = readFileSync(
|
||||
const requiredShellExports = [
|
||||
"INI_PANEL_ENTRIES",
|
||||
"controlPageStatusText",
|
||||
"createControlPageBrowserApiMethods",
|
||||
"createControlPageSessionLoadState",
|
||||
"createIniPanelLauncherLinkViewModel",
|
||||
"createIniPanelShellControlPageContract",
|
||||
@@ -97,6 +100,10 @@ assert.deepEqual(
|
||||
createIniPanelShellViewModel().controlPage.contract,
|
||||
createIniPanelShellControlPageContract(),
|
||||
);
|
||||
assert.deepEqual(
|
||||
createIniPanelShellViewModel().controlPage.browserApiMethods,
|
||||
createControlPageBrowserApiMethods(),
|
||||
);
|
||||
assert.equal(controlPageStatusText({ lastAction: "run-gcode", runStatus: "ok", error: null }), "run-gcode | ok | -");
|
||||
assert.deepEqual(createControlPageSessionLoadState({ phase: "waiting-panel" }), {
|
||||
phase: "waiting-panel",
|
||||
@@ -120,14 +127,17 @@ assert.deepEqual(
|
||||
assert.equal(createIniPanelShellViewModel().controlPage.readStatus, readMachineSessionReadonlyStatus);
|
||||
assert.equal(createIniPanelShellViewModel().controlPage.refresh, refreshMachineSessionControlPage);
|
||||
assert.equal(typeof createIniPanelShellViewModel().controlPage.renderView, "function");
|
||||
assert.match(controlPageText, /\bexport function createControlPageBrowserApiMethods\b/);
|
||||
assert.match(shellText, /\bexport function createControlPageBrowserApiMethods\b/);
|
||||
assert.match(controlPageText, /\bgetControlPageApiMethods\b/);
|
||||
assert.match(launchText, /\blinuxCncIniPanelLaunchApi\b/);
|
||||
assert.match(launchText, /\bgetControlPageApiMethods\b/);
|
||||
assert.match(controlPageText, /\bgetControlPageContract\b/);
|
||||
assert.match(controlPageText, /\breadControlPageStatus\b/);
|
||||
assert.match(controlPageText, /\bcreateIniPanelShellControlPageContract\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageApiMethods\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.getControlPageContract\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelControlPageApi\.readControlPageStatus\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
|
||||
|
||||
for (const entry of INI_PANEL_ENTRIES) {
|
||||
const escapedHref = entry.href.replace(".", "\\.");
|
||||
|
||||
@@ -4,6 +4,7 @@ import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
import {
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellViewModel,
|
||||
createMachineSessionControlPageController,
|
||||
@@ -55,6 +56,7 @@ assert.deepEqual(contract, {
|
||||
|
||||
const shellViewModel = createIniPanelShellViewModel();
|
||||
assert.deepEqual(Object.keys(shellViewModel.controlPage), [
|
||||
"browserApiMethods",
|
||||
"contract",
|
||||
"createController",
|
||||
"loadSessionState",
|
||||
@@ -63,6 +65,7 @@ assert.deepEqual(Object.keys(shellViewModel.controlPage), [
|
||||
"refresh",
|
||||
"renderView",
|
||||
]);
|
||||
assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods());
|
||||
assert.deepEqual(shellViewModel.controlPage.contract, contract);
|
||||
assert.deepEqual(shellViewModel.controlPage.readonlyStatusApiManifest, manifest);
|
||||
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
|
||||
@@ -81,6 +84,7 @@ for (const fieldName of contract.readonlyStatusApiStatusFields) {
|
||||
}
|
||||
|
||||
assert.match(shellText, /\bexport function createIniPanelShellControlPageContract\b/);
|
||||
assert.match(shellText, /\bexport function createControlPageBrowserApiMethods\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellControlPageContract\b/);
|
||||
assert.match(docText, /\bcontrolPage\.contract\b/);
|
||||
assert.doesNotMatch(shellText, /\bparseGcode\b|\bcanonicalEvents\b|\btoolTable\b|\bplanner\b/);
|
||||
|
||||
@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
|
||||
import {
|
||||
INI_PANEL_ENTRIES,
|
||||
controlPageStatusText,
|
||||
createControlPageBrowserApiMethods,
|
||||
createIniPanelLauncherLinkViewModel,
|
||||
createIniPanelShellControlPageContract,
|
||||
createIniPanelShellViewModel,
|
||||
@@ -44,6 +45,7 @@ assert.equal(getIniPanelEntryByHref("./index.html")?.id, "edit-run");
|
||||
assert.equal(typeof createMachineSessionControlPageController, "function");
|
||||
assert.equal(typeof createMachineSessionReadonlyStatus, "function");
|
||||
assert.equal(typeof createMachineSessionReadonlyStatusApiManifest, "function");
|
||||
assert.equal(typeof createControlPageBrowserApiMethods, "function");
|
||||
assert.equal(typeof createIniPanelShellControlPageContract, "function");
|
||||
assert.equal(typeof loadMachineSessionForControlPageWorkflow, "function");
|
||||
assert.equal(typeof readMachineSessionReadonlyStatus, "function");
|
||||
@@ -85,6 +87,7 @@ assert.deepEqual(shellViewModel.pages, [
|
||||
},
|
||||
]);
|
||||
assert.deepEqual(shellViewModel.launcherLinks, createIniPanelLauncherLinkViewModel());
|
||||
assert.deepEqual(shellViewModel.controlPage.browserApiMethods, createControlPageBrowserApiMethods());
|
||||
assert.equal(shellViewModel.controlPage.createController, createMachineSessionControlPageController);
|
||||
assert.deepEqual(shellViewModel.controlPage.contract, createIniPanelShellControlPageContract());
|
||||
assert.equal(shellViewModel.controlPage.loadSessionState, loadMachineSessionForControlPageWorkflow);
|
||||
|
||||
Reference in New Issue
Block a user