refactor(console-web): centralize page lifecycle and UI composition
Declare navigation, page metadata, lazy loaders, and keep-alive policy in one registry. Retain primary iframe pages until a continuous inactive TTL expires and expose typed show, hide, and unload events through the Page SDK. Move business-aware components out of the UI primitive directory, migrate views and Host dialogs to variant primitives and local Tailwind classes, and remove the global component style layer. Keep native dialogs inside the overlay flex context so they remain centered. Cover iframe expiration, lifecycle dispatch, UI dependency direction, and global style ownership with focused tests.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile, readdir } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
|
||||
const uiDirectory = new URL("../src/components/ui/", import.meta.url);
|
||||
const appStylesheet = new URL("../src/styles/app.css", import.meta.url);
|
||||
|
||||
test("UI primitives do not depend on page, Host or domain modules", async () => {
|
||||
const files = (await readdir(uiDirectory)).filter(
|
||||
(name) => name.endsWith(".ts") || name.endsWith(".tsx"),
|
||||
);
|
||||
|
||||
for (const file of files) {
|
||||
const source = await readFile(new URL(file, uiDirectory), "utf8");
|
||||
const imports = [...source.matchAll(/from\s+["']([^"']+)["']/g)].map((match) => match[1]);
|
||||
|
||||
for (const specifier of imports) {
|
||||
assert.doesNotMatch(
|
||||
specifier,
|
||||
/(?:^|\/)(?:feedback|host|layout|pages|sdk|services)(?:\/|$)|\/lib\/(?:api|model|view-state)$/,
|
||||
`${file} must remain business-independent: ${specifier}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("global stylesheet does not own component variants", async () => {
|
||||
const source = await readFile(appStylesheet, "utf8");
|
||||
|
||||
assert.doesNotMatch(
|
||||
source,
|
||||
/@layer\s+components/,
|
||||
"component classes and variants belong beside their Solid components",
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user