推进 INI 面板 shell handoff mount workflow helper
This commit is contained in:
@@ -32,6 +32,7 @@ import {
|
||||
createIniPanelShellSessionHandoffPackageMountState,
|
||||
createIniPanelShellSessionHandoffMountDomContract,
|
||||
createIniPanelShellSessionHandoffMountDomReadiness,
|
||||
mountIniPanelShellSessionHandoff,
|
||||
renderIniPanelShellSessionHandoffMountState,
|
||||
createIniPanelShellSessionHandoffPackageReport,
|
||||
createIniPanelShellSessionHandoffPackageRenderState,
|
||||
@@ -235,6 +236,10 @@ row dataset keys, and render-result fields before rendering into shell-owned
|
||||
DOM. Use `createIniPanelShellSessionHandoffMountDomReadiness()` or
|
||||
`linuxCncIniPanelLaunchApi.getShellSessionHandoffMountDomReadiness()` to check
|
||||
that the required document and nodes exist before calling the renderer. Use
|
||||
`mountIniPanelShellSessionHandoff()` or
|
||||
`linuxCncIniPanelLaunchApi.mountShellSessionHandoff()` when an outer shell
|
||||
needs one browser-side workflow result containing the contract, DOM readiness,
|
||||
mount render-state, renderer result, and any mount error as data. Use
|
||||
`renderIniPanelShellSessionHandoffMountState()` or
|
||||
`linuxCncIniPanelLaunchApi.renderShellSessionHandoffMountState()` when an outer
|
||||
shell needs the shared read-only DOM renderer for those rows. The launch page
|
||||
@@ -244,9 +249,9 @@ the control page.
|
||||
The browser workflow smoke
|
||||
`tests/browser/ini_panel_shell_integration_workflow_smoke.html` verifies the
|
||||
same external shell handoff: read integration manifest, pass readiness gate,
|
||||
open the control page target, render waiting and ready mount-state into an
|
||||
external shell-owned `[data-external-shell-mount]` DOM region, then read
|
||||
readonly machine-session status.
|
||||
open the control page target, mount waiting and ready mount-state into an
|
||||
external shell-owned `[data-external-shell-mount]` DOM region through the shared
|
||||
mount workflow, then read readonly machine-session status.
|
||||
|
||||
The control-page refresh workflow lives in
|
||||
`runtime/ui/ini-panel/control-page-refresh-workflow.js`. Use
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
isSupportedIniPanelLaunchApiManifest,
|
||||
createIniPanelShellSessionHandoffMountDomContract,
|
||||
createIniPanelShellSessionHandoffMountDomReadiness,
|
||||
mountIniPanelShellSessionHandoff,
|
||||
renderIniPanelShellSessionHandoffMountState,
|
||||
} from "./ui-shell.js";
|
||||
|
||||
@@ -191,6 +192,12 @@
|
||||
renderShellSessionHandoffMountState: (renderState, options) => (
|
||||
renderIniPanelShellSessionHandoffMountState(renderState, options ?? { documentRef: document })
|
||||
),
|
||||
mountShellSessionHandoff: (options) => (
|
||||
mountIniPanelShellSessionHandoff(options ?? {
|
||||
renderState: shellViewModel.shellSessionHandoffPackageMountRenderState,
|
||||
documentRef: document,
|
||||
})
|
||||
),
|
||||
isSupportedShellSessionHandoffPackage: shellViewModel.isSupportedShellSessionHandoffPackage,
|
||||
getLauncherLinks: () => shellViewModel.launcherLinks,
|
||||
getControlPageApiMethods: () => shellViewModel.controlPage.browserApiMethods,
|
||||
|
||||
@@ -146,6 +146,7 @@ export function createIniPanelLaunchApiManifest(entries = getVisibleIniPanelEntr
|
||||
"getShellSessionHandoffMountDomContract",
|
||||
"getShellSessionHandoffMountDomReadiness",
|
||||
"renderShellSessionHandoffMountState",
|
||||
"mountShellSessionHandoff",
|
||||
"isSupportedShellSessionHandoffPackage",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
@@ -1195,6 +1196,73 @@ export function renderIniPanelShellSessionHandoffMountState(
|
||||
};
|
||||
}
|
||||
|
||||
export function mountIniPanelShellSessionHandoff({
|
||||
renderState = createIniPanelShellSessionHandoffPackageMountRenderState(),
|
||||
rowDatasetPrefix = "handoffMount",
|
||||
contract = createIniPanelShellSessionHandoffMountDomContract({ rowDatasetPrefix }),
|
||||
documentRef = globalThis.document,
|
||||
mountNode = documentRef?.querySelector?.(contract.selectors.mount),
|
||||
statusNode = documentRef?.querySelector?.(contract.selectors.status),
|
||||
rowsNode = documentRef?.querySelector?.(contract.selectors.rows),
|
||||
} = {}) {
|
||||
const domReadiness = createIniPanelShellSessionHandoffMountDomReadiness({
|
||||
contract,
|
||||
documentRef,
|
||||
mountNode,
|
||||
statusNode,
|
||||
rowsNode,
|
||||
});
|
||||
if (!domReadiness.ready) {
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-mount-workflow",
|
||||
workflowVersion: 1,
|
||||
phase: "blocked",
|
||||
ready: false,
|
||||
statusLine: `Blocked: ${domReadiness.missing.join(", ")}`,
|
||||
contract,
|
||||
domReadiness,
|
||||
renderState,
|
||||
renderResult: null,
|
||||
error: null,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const renderResult = renderIniPanelShellSessionHandoffMountState(renderState, {
|
||||
contract,
|
||||
documentRef,
|
||||
mountNode,
|
||||
statusNode,
|
||||
rowsNode,
|
||||
});
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-mount-workflow",
|
||||
workflowVersion: 1,
|
||||
phase: renderState?.ready ? "ready" : "blocked",
|
||||
ready: renderState?.ready === true,
|
||||
statusLine: renderResult.statusLine,
|
||||
contract,
|
||||
domReadiness,
|
||||
renderState,
|
||||
renderResult,
|
||||
error: null,
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
apiName: "ini-panel-shell-session-handoff-mount-workflow",
|
||||
workflowVersion: 1,
|
||||
phase: "blocked",
|
||||
ready: false,
|
||||
statusLine: `Blocked: ${error?.message ?? "mount workflow error"}`,
|
||||
contract,
|
||||
domReadiness,
|
||||
renderState,
|
||||
renderResult: null,
|
||||
error: error?.message ?? String(error),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries()) {
|
||||
const shellIntegrationManifest = createIniPanelShellIntegrationManifest(entries);
|
||||
const shellIntegrationReadiness = createIniPanelShellIntegrationReadiness(shellIntegrationManifest);
|
||||
@@ -1312,6 +1380,7 @@ export function createIniPanelShellViewModel(entries = getVisibleIniPanelEntries
|
||||
createShellSessionHandoffMountDomContract: createIniPanelShellSessionHandoffMountDomContract,
|
||||
createShellSessionHandoffMountDomReadiness: createIniPanelShellSessionHandoffMountDomReadiness,
|
||||
renderShellSessionHandoffMountState: renderIniPanelShellSessionHandoffMountState,
|
||||
mountShellSessionHandoff: mountIniPanelShellSessionHandoff,
|
||||
isSupportedShellSessionHandoffPackage: isSupportedIniPanelShellSessionHandoffPackage,
|
||||
controlPage: {
|
||||
browserApiSchema: createControlPageBrowserApiSchema(),
|
||||
|
||||
@@ -88,6 +88,7 @@ TOOL_TABLE = browser-shell-tool.tbl
|
||||
!launchApi?.getShellSessionHandoffMountDomContract ||
|
||||
!launchApi?.getShellSessionHandoffMountDomReadiness ||
|
||||
!launchApi?.renderShellSessionHandoffMountState ||
|
||||
!launchApi?.mountShellSessionHandoff ||
|
||||
!launchApi?.isSupportedShellSessionHandoffPackage
|
||||
) {
|
||||
throw new Error("launch API namespace did not expose shell integration helpers");
|
||||
@@ -123,15 +124,16 @@ TOOL_TABLE = browser-shell-tool.tbl
|
||||
contract: externalMountDomContract,
|
||||
documentRef: document,
|
||||
});
|
||||
const waitingMountRenderResult = launchApi.renderShellSessionHandoffMountState(
|
||||
handoffPackageMountRenderState,
|
||||
{
|
||||
contract: externalMountDomContract,
|
||||
documentRef: document,
|
||||
},
|
||||
);
|
||||
const waitingMountWorkflow = launchApi.mountShellSessionHandoff({
|
||||
renderState: handoffPackageMountRenderState,
|
||||
contract: externalMountDomContract,
|
||||
documentRef: document,
|
||||
});
|
||||
const waitingMountRenderResult = waitingMountWorkflow.renderResult;
|
||||
assertEqual(externalMountDomContract.rowDatasetPrefix, "externalMount", "external shell mount DOM contract prefix");
|
||||
assertEqual(externalMountDomReadiness.ready, true, "external shell mount DOM readiness");
|
||||
assertEqual(waitingMountWorkflow.phase, "blocked", "external shell waiting mount workflow phase");
|
||||
assertEqual(waitingMountWorkflow.domReadiness.ready, true, "external shell waiting mount workflow DOM readiness");
|
||||
assertEqual(handoffSummarySchema.summaryVersion, 1, "shell handoff summary schema version");
|
||||
assertEqual(
|
||||
launchApi.isSupportedShellSessionHandoffSummary(handoffSummary),
|
||||
@@ -290,18 +292,18 @@ TOOL_TABLE = browser-shell-tool.tbl
|
||||
);
|
||||
const readyMountDisplay = launchApi.getShellSessionHandoffPackageMountDisplayViewModel(readyMountState);
|
||||
const readyMountRenderState = launchApi.getShellSessionHandoffPackageMountRenderState(readyMountState);
|
||||
const readyMountRenderResult = launchApi.renderShellSessionHandoffMountState(
|
||||
readyMountRenderState,
|
||||
{
|
||||
contract: externalMountDomContract,
|
||||
documentRef: document,
|
||||
},
|
||||
);
|
||||
const readyMountWorkflow = launchApi.mountShellSessionHandoff({
|
||||
renderState: readyMountRenderState,
|
||||
contract: externalMountDomContract,
|
||||
documentRef: document,
|
||||
});
|
||||
const readyMountRenderResult = readyMountWorkflow.renderResult;
|
||||
assertEqual(readyMountState.ready, true, "shell handoff package mount-state readiness");
|
||||
assertEqual(readyMountState.sessionLoadState.phase, "ready", "shell handoff package mount-state ready session");
|
||||
assertEqual(readyMountDisplay.detailText, "No blocking reasons", "shell handoff package ready mount display");
|
||||
assertEqual(readyMountRenderState.statusLine, "Ready: No blocking reasons", "shell handoff package ready mount render-state");
|
||||
assertEqual(readyMountRenderResult.rendered, true, "external shell ready mount render result");
|
||||
assertEqual(readyMountWorkflow.phase, "ready", "external shell ready mount workflow phase");
|
||||
assertEqual(readyMountRenderResult.dataset.handoffReady, "true", "external shell ready mount render dataset");
|
||||
assertEqual(
|
||||
document.querySelector("[data-external-shell-mount-status]").textContent,
|
||||
|
||||
@@ -29,6 +29,7 @@ import {
|
||||
createIniPanelShellSessionHandoffPackageMountState,
|
||||
createIniPanelShellSessionHandoffMountDomContract,
|
||||
createIniPanelShellSessionHandoffMountDomReadiness,
|
||||
mountIniPanelShellSessionHandoff,
|
||||
renderIniPanelShellSessionHandoffMountState,
|
||||
createIniPanelShellSessionHandoffPackageReport,
|
||||
createIniPanelShellSessionHandoffPackageRenderState,
|
||||
@@ -97,6 +98,7 @@ const requiredShellExports = [
|
||||
"createIniPanelShellSessionHandoffPackageMountState",
|
||||
"createIniPanelShellSessionHandoffMountDomContract",
|
||||
"createIniPanelShellSessionHandoffMountDomReadiness",
|
||||
"mountIniPanelShellSessionHandoff",
|
||||
"renderIniPanelShellSessionHandoffMountState",
|
||||
"createIniPanelShellSessionHandoffPackageReport",
|
||||
"createIniPanelShellSessionHandoffPackageRenderState",
|
||||
@@ -291,6 +293,10 @@ assert.equal(
|
||||
createIniPanelShellSessionHandoffMountDomReadiness({ documentRef: null }).ready,
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
mountIniPanelShellSessionHandoff({ documentRef: null }).phase,
|
||||
"blocked",
|
||||
);
|
||||
assert.equal(isSupportedIniPanelShellSessionHandoffPackage(createIniPanelShellViewModel().shellSessionHandoffPackage), true);
|
||||
assert.equal(isSupportedIniPanelShellIntegrationManifest(createIniPanelShellViewModel().shellIntegrationManifest), true);
|
||||
assert.deepEqual(createIniPanelShellViewModel().launchApiSchema, createIniPanelLaunchApiSchema());
|
||||
@@ -450,6 +456,7 @@ assert.match(docText, /\brenderIniPanelShellSessionHandoffMountState\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.renderShellSessionHandoffMountState\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getShellSessionHandoffMountDomContract\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getShellSessionHandoffMountDomReadiness\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.mountShellSessionHandoff\b/);
|
||||
assert.match(docText, /\blinuxCncIniPanelLaunchApi\.getControlPageApiMethods\b/);
|
||||
assert.match(docText, /\bini_panel_shell_integration_workflow_smoke\.html\b/);
|
||||
assert.match(browserIniPanelText, /\bini_panel_shell_integration_workflow_smoke\.html\b/);
|
||||
@@ -468,6 +475,7 @@ assert.match(shellIntegrationWorkflowSmokeText, /\bgetShellSessionHandoffPackage
|
||||
assert.match(shellIntegrationWorkflowSmokeText, /\bgetShellSessionHandoffPackageMountRenderState\b/);
|
||||
assert.match(shellIntegrationWorkflowSmokeText, /\bgetShellSessionHandoffMountDomContract\b/);
|
||||
assert.match(shellIntegrationWorkflowSmokeText, /\bgetShellSessionHandoffMountDomReadiness\b/);
|
||||
assert.match(shellIntegrationWorkflowSmokeText, /\bmountShellSessionHandoff\b/);
|
||||
assert.match(shellIntegrationWorkflowSmokeText, /\brenderShellSessionHandoffMountState\b/);
|
||||
assert.match(shellIntegrationWorkflowSmokeText, /\bdata-external-shell-mount\b/);
|
||||
assert.match(shellIntegrationWorkflowSmokeText, /\bdata-external-mount-value\b/);
|
||||
|
||||
@@ -66,6 +66,7 @@ assert.deepEqual(manifest, {
|
||||
"getShellSessionHandoffMountDomContract",
|
||||
"getShellSessionHandoffMountDomReadiness",
|
||||
"renderShellSessionHandoffMountState",
|
||||
"mountShellSessionHandoff",
|
||||
"isSupportedShellSessionHandoffPackage",
|
||||
"getLauncherLinks",
|
||||
"getControlPageApiMethods",
|
||||
@@ -187,6 +188,7 @@ assert.match(launchText, /\bgetShellSessionHandoffPackageMountRenderState\b/);
|
||||
assert.match(launchText, /\bgetShellSessionHandoffMountDomContract\b/);
|
||||
assert.match(launchText, /\bgetShellSessionHandoffMountDomReadiness\b/);
|
||||
assert.match(launchText, /\brenderShellSessionHandoffMountState\b/);
|
||||
assert.match(launchText, /\bmountShellSessionHandoff\b/);
|
||||
assert.match(launchText, /\bisSupportedShellSessionHandoffPackage\b/);
|
||||
assert.match(launchText, /\bdata-handoff-mount\b/);
|
||||
assert.match(launchText, /\bdata-handoff-mount-status\b/);
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
createIniPanelShellSessionHandoffPackageMountState,
|
||||
createIniPanelShellSessionHandoffMountDomContract,
|
||||
createIniPanelShellSessionHandoffMountDomReadiness,
|
||||
mountIniPanelShellSessionHandoff,
|
||||
createIniPanelShellSessionHandoffPackageReport,
|
||||
createIniPanelShellSessionHandoffPackageRenderState,
|
||||
createIniPanelShellSessionHandoffPackageSchema,
|
||||
@@ -151,7 +152,7 @@ assert.deepEqual(readiness, {
|
||||
counts: {
|
||||
pages: 2,
|
||||
launcherLinks: 2,
|
||||
launchMethods: 29,
|
||||
launchMethods: 30,
|
||||
controlPageMethods: 11,
|
||||
persistenceCapabilities: 3,
|
||||
},
|
||||
@@ -213,7 +214,7 @@ assert.deepEqual(handoffSummary, {
|
||||
counts: {
|
||||
pages: 2,
|
||||
launcherLinks: 2,
|
||||
launchMethods: 29,
|
||||
launchMethods: 30,
|
||||
controlPageMethods: 11,
|
||||
persistenceCapabilities: 3,
|
||||
},
|
||||
@@ -701,6 +702,10 @@ assert.deepEqual(createIniPanelShellSessionHandoffMountDomReadiness({ documentRe
|
||||
},
|
||||
contract: handoffMountDomContract,
|
||||
});
|
||||
assert.equal(
|
||||
mountIniPanelShellSessionHandoff({ documentRef: null }).statusLine,
|
||||
"Blocked: document, mount, status, rows",
|
||||
);
|
||||
assert.deepEqual(
|
||||
createIniPanelShellSessionHandoffPackageMountState({
|
||||
handoffPackage,
|
||||
@@ -1112,7 +1117,7 @@ assert.deepEqual(createIniPanelShellIntegrationReadiness(blockedManifest), {
|
||||
counts: {
|
||||
pages: 2,
|
||||
launcherLinks: 2,
|
||||
launchMethods: 29,
|
||||
launchMethods: 30,
|
||||
controlPageMethods: 11,
|
||||
persistenceCapabilities: 3,
|
||||
},
|
||||
@@ -1283,6 +1288,7 @@ assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPack
|
||||
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageMountState\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffMountDomContract\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffMountDomReadiness\b/);
|
||||
assert.match(shellText, /\bexport function mountIniPanelShellSessionHandoff\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageReport\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageRenderState\b/);
|
||||
assert.match(shellText, /\bexport function createIniPanelShellSessionHandoffPackageSchema\b/);
|
||||
@@ -1310,6 +1316,7 @@ assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageMountRenderStat
|
||||
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageMountState\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellSessionHandoffMountDomContract\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellSessionHandoffMountDomReadiness\b/);
|
||||
assert.match(docText, /\bmountIniPanelShellSessionHandoff\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageReport\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageRenderState\b/);
|
||||
assert.match(docText, /\bcreateIniPanelShellSessionHandoffPackageSchema\b/);
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
createIniPanelShellSessionHandoffPackageMountState,
|
||||
createIniPanelShellSessionHandoffMountDomContract,
|
||||
createIniPanelShellSessionHandoffMountDomReadiness,
|
||||
mountIniPanelShellSessionHandoff,
|
||||
renderIniPanelShellSessionHandoffMountState,
|
||||
createIniPanelShellSessionHandoffPackageReport,
|
||||
createIniPanelShellSessionHandoffPackageRenderState,
|
||||
@@ -98,6 +99,7 @@ assert.equal(typeof createIniPanelShellSessionHandoffPackageMountRenderState, "f
|
||||
assert.equal(typeof createIniPanelShellSessionHandoffPackageMountState, "function");
|
||||
assert.equal(typeof createIniPanelShellSessionHandoffMountDomContract, "function");
|
||||
assert.equal(typeof createIniPanelShellSessionHandoffMountDomReadiness, "function");
|
||||
assert.equal(typeof mountIniPanelShellSessionHandoff, "function");
|
||||
assert.equal(typeof renderIniPanelShellSessionHandoffMountState, "function");
|
||||
assert.equal(typeof createIniPanelShellSessionHandoffPackageReport, "function");
|
||||
assert.equal(typeof createIniPanelShellSessionHandoffPackageRenderState, "function");
|
||||
@@ -699,6 +701,7 @@ assert.equal(
|
||||
shellViewModel.renderShellSessionHandoffMountState,
|
||||
renderIniPanelShellSessionHandoffMountState,
|
||||
);
|
||||
assert.equal(shellViewModel.mountShellSessionHandoff, mountIniPanelShellSessionHandoff);
|
||||
assert.equal(shellViewModel.createShellSessionHandoffPackageReport, createIniPanelShellSessionHandoffPackageReport);
|
||||
assert.equal(shellViewModel.createShellSessionHandoffPackageSchema, createIniPanelShellSessionHandoffPackageSchema);
|
||||
assert.equal(shellViewModel.isSupportedShellSessionHandoffPackage, isSupportedIniPanelShellSessionHandoffPackage);
|
||||
@@ -822,6 +825,29 @@ assert.deepEqual(
|
||||
);
|
||||
assert.equal(mountRowsNode.children[7].dataset.handoffMountValue, "session-load-state");
|
||||
assert.equal(mountRowsNode.children[7].dataset.handoffMountStatus, "blocked");
|
||||
const mountWorkflowResult = mountIniPanelShellSessionHandoff({
|
||||
renderState: shellViewModel.shellSessionHandoffPackageMountRenderState,
|
||||
documentRef: mountDocument,
|
||||
mountNode,
|
||||
statusNode: mountStatusNode,
|
||||
rowsNode: mountRowsNode,
|
||||
});
|
||||
assert.equal(mountWorkflowResult.apiName, "ini-panel-shell-session-handoff-mount-workflow");
|
||||
assert.equal(mountWorkflowResult.workflowVersion, 1);
|
||||
assert.equal(mountWorkflowResult.phase, "blocked");
|
||||
assert.equal(mountWorkflowResult.ready, false);
|
||||
assert.equal(mountWorkflowResult.domReadiness.ready, true);
|
||||
assert.equal(mountWorkflowResult.renderResult.rendered, true);
|
||||
assert.equal(mountWorkflowResult.renderResult.rowCount, 5);
|
||||
assert.equal(mountWorkflowResult.error, null);
|
||||
assert.deepEqual(
|
||||
mountIniPanelShellSessionHandoff({ documentRef: mountDocument }).renderResult,
|
||||
null,
|
||||
);
|
||||
assert.deepEqual(
|
||||
mountIniPanelShellSessionHandoff({ documentRef: mountDocument }).domReadiness.missing,
|
||||
["mount", "status", "rows"],
|
||||
);
|
||||
const externalContract = createIniPanelShellSessionHandoffMountDomContract({
|
||||
rowDatasetPrefix: "externalMount",
|
||||
selectors: {
|
||||
|
||||
Reference in New Issue
Block a user