@@ -461,6 +461,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
461461 'REX-N: the predicate set is pinned BY NAME, never by count': 3,
462462 'REX-U: unit pins on the operand grammar and the FROM-side reader': 24,
463463 'REX-L: the compiler is loaded only when a marker names the category': 6,
464+ 'WS (#26220): ui workspace packages, `.tsx` modules, aliases and shims': 11,
464465 'G6: a changeset that was ALREADY breaking at base is inherited': 1,
465466 'R15: a changeset RENAMED AND turned breaking in the same commit': 5,
466467 'G10: a PURE rename of an ALREADY-breaking stock changeset': 3,
@@ -493,7 +494,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
493494
494495// DELETING an entry silences that battery's floor exactly as effectively as
495496// zeroing it, so the roster's own size is pinned too.
496- const SELF_TEST_BATTERY_FLOOR = 55 ;
497+ const SELF_TEST_BATTERY_FLOOR = 56 ;
497498
498499// The key an assertion is filed under when no battery is open. It is not a
499500// declared battery, so it reds by the same set difference rather than silently
@@ -7607,6 +7608,108 @@ function selfTest() {
76077608 'REX-L5: a scan with the reader loaded, or with no such marker, never asks for it');
76087609 }
76097610
7611+ // ---- WS (#26220): a ui workspace package, read through the workspace file --
7612+ //
7613+ // The gate's package globs are the rev's own `pnpm-workspace.yaml`, so an
7614+ // `@object-ui/*` package under `ui/packages/*` has a manifest here like any
7615+ // other. And its export reader compiles `.tsx`: the ui entries re-export from
7616+ // `.tsx` modules -- directly, through an alias, and through a `.ts` shim -- and
7617+ // without the `jsx` option every such module failed to resolve (TS6142), so
7618+ // predicate 2 could not locate a single declaration behind one.
7619+ battery('WS (#26220): ui workspace packages, `.tsx` modules, aliases and shims');
7620+ {
7621+ const UI_PKG = '@object-ui/app-shell';
7622+ const UI_DIR = 'ui/packages/app-shell';
7623+ const uiPath = (rel) => `${UI_DIR}/${rel}`;
7624+ const UI_PKGS = {
7625+ '@objectstack/spec': { dir: 'packages/spec', private: false },
7626+ '@objectstack/platform-objects': { dir: 'packages/platform-objects', private: false },
7627+ '@object-ui/console': { dir: 'ui/apps/console', private: true },
7628+ };
7629+ const UI_INDEX_HEAD = "export { AppShell } from './AppShell.js';\n";
7630+ const UI_BASE_FILES = {
7631+ [uiPath('package.json')]: JSON.stringify({
7632+ name: UI_PKG, version: '1.0.0', types: 'dist/index.d.ts',
7633+ exports: { '.': { types: './dist/index.d.ts', import: './dist/index.mjs' } },
7634+ }),
7635+ [uiPath('src/index.ts')]:
7636+ `${UI_INDEX_HEAD}` +
7637+ "export { useExpressionContext } from './providers/ExpressionProvider.js';\n" +
7638+ "export { PageShell as MetadataPageShell } from './views/PageShell.js';\n" +
7639+ "export type { RecentItemInput } from './hooks/useRecentItems.js';\n",
7640+ [uiPath('src/AppShell.tsx')]: 'export const AppShell = () => <div className="shell" />;\n',
7641+ [uiPath('src/providers/ExpressionProvider.tsx')]:
7642+ 'export function useExpressionContext() {\n return <span>{1}</span>;\n}\n',
7643+ [uiPath('src/views/PageShell.tsx')]: 'export function PageShell() {\n return <main />;\n}\n',
7644+ [uiPath('src/hooks/useRecentItems.ts')]:
7645+ "export { useRecentItems, type RecentItemInput } from '../context/RecentItemsProvider.js';\n",
7646+ [uiPath('src/context/RecentItemsProvider.tsx')]:
7647+ 'export interface RecentItemInput { id: string }\nexport function useRecentItems() {\n return <ul />;\n}\n',
7648+ 'packages/platform-objects/src/audit/sys-email-template.object.ts':
7649+ "export const SysEmailTemplate = { name: 'sys_email_template' };\n",
7650+ };
7651+ const UI_OPERANDS = ['useExpressionContext', 'MetadataPageShell', 'RecentItemInput'];
7652+ const UI_CS = CS({
7653+ bumps: [[UI_PKG, 'patch']],
7654+ body:
7655+ 'refactor(app-shell)!: retire three root-entry exports\n\n**BREAKING**: retired exports.\n\n' +
7656+ UI_OPERANDS.map((o) => `- FROM \`${o}\` TO nothing: delete the import.`).join('\n') +
7657+ `\n\n<!-- adr-0087: not-required (runtime-export-retired${UI_OPERANDS.map((o) => ` ${UI_PKG}#${o}`).join(',')}) ` +
7658+ 'the retired names are runtime exports; the compiler reports each at its importer, and no stored shape moves -->\n',
7659+ });
7660+ const UI_FIXTURE = (over = {}) => ({
7661+ pkgs: UI_PKGS,
7662+ baseFiles: UI_BASE_FILES,
7663+ files: { [uiPath('src/index.ts')]: UI_INDEX_HEAD, '.changeset/x.md': UI_CS },
7664+ ...over,
7665+ });
7666+
7667+ const wsG1 = run(mk(UI_FIXTURE()));
7668+ green('WS-G1 a `ui/packages/*` package retires a `.tsx` export, an alias of one and a type behind a `.ts` shim', wsG1);
7669+ const detail = wsG1.judged[0]?.detail ?? '';
7670+ assert(
7671+ /useExpressionContext \(export, ui\/packages\/app-shell\/src\/providers\/ExpressionProvider\.tsx\)/.test(detail) &&
7672+ /MetadataPageShell \(export, ui\/packages\/app-shell\/src\/views\/PageShell\.tsx\)/.test(detail) &&
7673+ /RecentItemInput \(export, ui\/packages\/app-shell\/src\/context\/RecentItemsProvider\.tsx\)/.test(detail),
7674+ 'WS-G1b: predicate 2 must locate each declaration where the compiler resolves it -- the `.tsx` module, ' +
7675+ `the ALIASED declaration, and the module BEHIND the shim. Got: ${detail}`,
7676+ );
7677+
7678+ // The membership comes from the workspace file and nowhere else: the same tree
7679+ // with the `ui/packages/*` glob dropped has no manifest named the package.
7680+ red('WS-R1 a package whose directory no workspace glob names has no workspace manifest', run(mk(UI_FIXTURE({
7681+ workspace: WORKSPACE_YAML.replace(' - ui/packages/*\n', ''),
7682+ }))), [/no workspace manifest at [0-9a-f]{12} is named `@object-ui\/app-shell`/]);
7683+
7684+ let thrown = null;
7685+ try { run(mk(UI_FIXTURE({ workspace: null }))); } catch (e) { thrown = e; }
7686+ assert(thrown instanceof WorkspaceEnumerationError && /pnpm-workspace\.yaml at [0-9a-f]{12} is missing/.test(thrown.message),
7687+ `WS-R2: a rev with no workspace file is REFUSED, never read as an empty workspace (got ${thrown?.message ?? 'no throw'})`);
7688+
7689+ green('WS-G2 `unpublished` on a private `ui/apps/*` package', run(mk({
7690+ pkgs: UI_PKGS,
7691+ files: {
7692+ '.changeset/x.md': CS({
7693+ bumps: [['@object-ui/console', 'major']],
7694+ body: '**BREAKING** x\n\n<!-- adr-0087: not-required (unpublished) the console app is private and publishes to no registry -->\n',
7695+ }),
7696+ },
7697+ })));
7698+
7699+ const GLOBS = ['packages/*', 'ui', 'ui/packages/*'];
7700+ assert(isWorkspaceManifest('ui/packages/app-shell/package.json', GLOBS), 'WS-U1: `<dir>/*` names a directory directly under `<dir>`');
7701+ assert(isWorkspaceManifest('ui/package.json', GLOBS), 'WS-U2: a bare `<dir>` glob names that directory itself');
7702+ assert(!isWorkspaceManifest('ui/packages/app-shell/test/fixture/package.json', GLOBS),
7703+ 'WS-U3: a manifest nested below a member is not a member -- a fixture package.json cannot shadow a real one');
7704+ assert(!isWorkspaceManifest('ui/node_modules/x/package.json', ['ui/*']) && !isWorkspaceManifest('ui/.cache/package.json', ['ui/*']),
7705+ 'WS-U4: `node_modules` and dot-directories are never members (the enumerator\'s rule)');
7706+ let rich = null;
7707+ const richDir = mk({ files: {}, workspace: 'packages:\n - packages/**\n' }).dir;
7708+ try { workspaceGlobsAt('HEAD', richDir); } catch (e) { rich = e; }
7709+ assert(rich instanceof WorkspaceEnumerationError && /richer than/.test(rich.message),
7710+ `WS-U5: a glob richer than \`<dir>\` / \`<dir>/*\` is refused, never matched against nothing (got ${rich?.message ?? 'no throw'})`);
7711+ }
7712+
76107713 // ---- G6: a changeset that was ALREADY breaking at base is inherited -------
76117714 battery('G6: a changeset that was ALREADY breaking at base is inherited');
76127715 {
0 commit comments