@1agh/maude 2.0.4 → 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +39 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/actions/agents.ts +59 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/sync.ts +13 -0
- package/apps/studio/actions/defs/view.ts +59 -3
- package/apps/studio/actions/keymap.gen.ts +35 -0
- package/apps/studio/actions/menu.ts +2 -0
- package/apps/studio/actions/types.ts +3 -1
- package/apps/studio/actions.manifest.json +148 -1
- package/apps/studio/actions.parity.json +31 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -15
- package/apps/studio/api.ts +425 -128
- package/apps/studio/artboard-activity-overlay.tsx +4 -4
- package/apps/studio/artboard-ai-copies.tsx +4 -4
- package/apps/studio/artboard-freeze.ts +108 -0
- package/apps/studio/artboard-live-gate.tsx +636 -0
- package/apps/studio/artboard-live.ts +831 -0
- package/apps/studio/artboard-placeholder.ts +197 -0
- package/apps/studio/artboard-still-raster.ts +485 -0
- package/apps/studio/artboard-still-warmup.ts +221 -0
- package/apps/studio/artboard-still.ts +1188 -0
- package/apps/studio/artboard-webgl.ts +669 -0
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +30 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/bridge/dgn-protocol.ts +35 -0
- package/apps/studio/canvas-build-sandbox.ts +69 -13
- package/apps/studio/canvas-camera.ts +90 -0
- package/apps/studio/canvas-comment-mount.tsx +9 -9
- package/apps/studio/canvas-lib.tsx +289 -44
- package/apps/studio/canvas-pages-view.tsx +465 -0
- package/apps/studio/canvas-pages.ts +305 -0
- package/apps/studio/canvas-rows.ts +62 -0
- package/apps/studio/canvas-shell.tsx +62 -16
- package/apps/studio/canvas-theme-icons.tsx +41 -0
- package/apps/studio/canvas-theme-pill.tsx +15 -6
- package/apps/studio/canvas-theme.ts +12 -11
- package/apps/studio/client/app.jsx +7 -0
- package/apps/studio/client/canvas-url.js +36 -1
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +6 -0
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
- package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
- package/apps/studio/client/hooks/use-project-data.jsx +13 -2
- package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
- package/apps/studio/client/index-loader.ts +41 -21
- package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
- package/apps/studio/client/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +66 -22
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
- package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
- package/apps/studio/client/v2/code/code-consent.js +67 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
- package/apps/studio/client/v2/layers/layers-request.js +49 -0
- package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
- package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
- package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
- package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
- package/apps/studio/client/v2/shell/floating-panels.css +37 -1
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +11 -0
- package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
- package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
- package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
- package/apps/studio/client/v2/shell/pages-pick.js +49 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +56 -0
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +1198 -1198
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +6 -0
- package/apps/studio/ds/board/ds-bar.tsx +21 -3
- package/apps/studio/ds/board/specimen.tsx +16 -2
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +14 -4
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/engine.ts +3 -1
- package/apps/studio/ds/folder-systems.ts +199 -0
- package/apps/studio/ds/pairing-css.ts +2 -1
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +10 -3
- package/apps/studio/editing/ai-point-ring.tsx +4 -4
- package/apps/studio/editing/ai-scope-outline.tsx +4 -4
- package/apps/studio/editing/align-bar.tsx +4 -4
- package/apps/studio/editing/anchor-report.ts +3 -2
- package/apps/studio/editing/artboard-handles.tsx +4 -4
- package/apps/studio/editing/corner-dots.tsx +4 -4
- package/apps/studio/editing/crop-mode.tsx +4 -4
- package/apps/studio/editing/drop-chip.tsx +4 -4
- package/apps/studio/editing/empty-report.ts +3 -2
- package/apps/studio/editing/focus-model.tsx +4 -4
- package/apps/studio/editing/gap-bands.tsx +3 -3
- package/apps/studio/editing/hold-rings.tsx +4 -4
- package/apps/studio/editing/lock-badge.tsx +3 -3
- package/apps/studio/editing/long-page.ts +23 -1
- package/apps/studio/editing/nudge.tsx +2 -2
- package/apps/studio/editing/page-activity.ts +4 -3
- package/apps/studio/editing/paste-bar.tsx +4 -4
- package/apps/studio/editing/pen/overlay.tsx +4 -3
- package/apps/studio/editing/place-freely.tsx +3 -3
- package/apps/studio/editing/reorder-slot.tsx +3 -3
- package/apps/studio/editing/selection.tsx +4 -4
- package/apps/studio/editing/size-ghost.tsx +4 -4
- package/apps/studio/editing/tab-order.tsx +4 -4
- package/apps/studio/editing/text-in-place.tsx +4 -4
- package/apps/studio/editing/undo-preview.tsx +3 -3
- package/apps/studio/equal-spacing-handles.tsx +3 -3
- package/apps/studio/frame-clock.ts +89 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +80 -34
- package/apps/studio/index/ds-usage.ts +4 -1
- package/apps/studio/index-cache.ts +272 -0
- package/apps/studio/inspect-overlay.tsx +4 -3
- package/apps/studio/inspect.ts +7 -2
- package/apps/studio/link-chip-overlay.tsx +4 -3
- package/apps/studio/measure-overlay.tsx +4 -3
- package/apps/studio/present/pointer-dot.tsx +3 -2
- package/apps/studio/present/present-media.ts +6 -2
- package/apps/studio/present/present-stage.tsx +3 -2
- package/apps/studio/preview/preview-camera.tsx +3 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/server.ts +8 -10
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +497 -61
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +405 -163
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +104 -3
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +17 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/use-annotation-resize.tsx +4 -3
- package/apps/studio/use-artboard-drag.tsx +3 -2
- package/apps/studio/use-element-resize.tsx +7 -6
- package/apps/studio/use-grid-track-handles.tsx +5 -4
- package/apps/studio/use-selection-set.tsx +64 -4
- package/apps/studio/use-spacing-handles.tsx +7 -6
- package/apps/studio/video-comp.tsx +75 -39
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +99 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +27 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +164 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// 2.0.7 — the design systems a project has: the configured ones, then the folder-owned ones.
|
|
2
|
+
//
|
|
3
|
+
// A cell's `config.json` never travels on the file plane (file-membership `never`) and is filled in
|
|
4
|
+
// only when the owner's desktop pushes its systems, so a system converted on a desktop can reach the
|
|
5
|
+
// cell as files alone: `system/<ds>/` with its own Design system canvas (`design-system.tsx`). Such a
|
|
6
|
+
// folder owns its canvases (`folderSystemOf`), and it is a system in every list too — `/_api/ds/*`,
|
|
7
|
+
// `/_config` (the Design system panel, the left panel's rows), the usage index — and a `ui/` canvas
|
|
8
|
+
// whose `.meta.json` names it renders with it.
|
|
9
|
+
//
|
|
10
|
+
// One merged list, one order: the configured systems first, exactly as configured, then the folder
|
|
11
|
+
// systems by name. So the default (the configured `defaultDesignSystem`, else the first configured
|
|
12
|
+
// system) never changes while the config lists a system. A name never invents a path: a folder system
|
|
13
|
+
// exists only where `system/<name>/design-system.tsx` is a real file in a real folder; a pin to any
|
|
14
|
+
// other name the config does not list stays at the default.
|
|
15
|
+
//
|
|
16
|
+
// A leaf: node built-ins only, so `context.ts` (loadConfig) can merge with it.
|
|
17
|
+
|
|
18
|
+
import { lstatSync, readdirSync, readFileSync } from 'node:fs';
|
|
19
|
+
import path from 'node:path';
|
|
20
|
+
|
|
21
|
+
/** What a folder name must look like to be a system (the hub door's `designSystems[].name` rule). */
|
|
22
|
+
const FOLDER_NAME = /^[\w .-]{1,64}$/;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The system folder a designRoot-relative path sits in when the config lists no system for it:
|
|
26
|
+
* `system/<ds>/…` whose folder holds its own Design system canvas (`design-system.tsx`). `hasFile`
|
|
27
|
+
* is the caller's reader (the disk, the closure's listing). A name the config already gives another
|
|
28
|
+
* folder is never taken over. One rule for the build (`canvasSystemFor`), the closure
|
|
29
|
+
* (`access/closure.ts`), the tree's map (`api.ts`) and the merged list below.
|
|
30
|
+
*/
|
|
31
|
+
export function folderSystemOf(
|
|
32
|
+
rel: string,
|
|
33
|
+
configured: ReadonlyArray<{ name: string; path: string }>,
|
|
34
|
+
hasFile: (rel: string) => boolean
|
|
35
|
+
): { name: string; path: string } | null {
|
|
36
|
+
const m = /^system\/([^/]+)\//.exec(rel);
|
|
37
|
+
const seg = m?.[1];
|
|
38
|
+
if (!seg || seg.startsWith('_') || seg.startsWith('.') || !FOLDER_NAME.test(seg)) return null;
|
|
39
|
+
const dir = `system/${seg}`;
|
|
40
|
+
if (configured.some((s) => s.path === dir || s.name === seg)) return null;
|
|
41
|
+
return hasFile(`${dir}/design-system.tsx`) ? { name: seg, path: dir } : null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The folder system a canvas's `meta.designSystem` pin names, or null. Only a plain folder name
|
|
46
|
+
* counts (no `/`, never a path), so a pin can reach `system/<name>/` and nothing else.
|
|
47
|
+
*/
|
|
48
|
+
export function pinnedFolderSystem(
|
|
49
|
+
declared: unknown,
|
|
50
|
+
configured: ReadonlyArray<{ name: string; path: string }>,
|
|
51
|
+
hasFile: (rel: string) => boolean
|
|
52
|
+
): { name: string; path: string } | null {
|
|
53
|
+
if (typeof declared !== 'string' || !declared || /[/\\]/.test(declared)) return null;
|
|
54
|
+
const f = folderSystemOf(`system/${declared}/design-system.tsx`, configured, hasFile);
|
|
55
|
+
return f && f.name === declared ? f : null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** A folder system's config entry: its tokens CSS, and its themes + root class guessed from it. */
|
|
59
|
+
export interface FolderSystemEntry {
|
|
60
|
+
name: string;
|
|
61
|
+
path: string;
|
|
62
|
+
tokensCssRel: string;
|
|
63
|
+
themes?: string[];
|
|
64
|
+
themeDefault?: string;
|
|
65
|
+
rootClass?: string;
|
|
66
|
+
/** Not in the config: discovered from its folder. Never written back to config.json. */
|
|
67
|
+
folderOwned: true;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function folderSystemEntry(
|
|
71
|
+
designRoot: string,
|
|
72
|
+
folder: { name: string; path: string }
|
|
73
|
+
): FolderSystemEntry {
|
|
74
|
+
const tokensCssRel = `${folder.path}/colors_and_type.css`;
|
|
75
|
+
let css = '';
|
|
76
|
+
try {
|
|
77
|
+
css = readFileSync(path.join(designRoot, ...tokensCssRel.split('/')), 'utf8');
|
|
78
|
+
} catch {
|
|
79
|
+
/* no tokens yet: the defaults */
|
|
80
|
+
}
|
|
81
|
+
const themes: string[] = [];
|
|
82
|
+
for (const m of css.matchAll(/\[data-theme\s*=\s*["']?([a-z][a-z0-9-]*)["']?\s*\]/gi))
|
|
83
|
+
if (!themes.includes(m[1] as string)) themes.push(m[1] as string);
|
|
84
|
+
const esc = folder.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
85
|
+
const rootClass = new RegExp(`\\.${esc}\\[data-theme`).test(css) ? folder.name : null;
|
|
86
|
+
return {
|
|
87
|
+
name: folder.name,
|
|
88
|
+
path: folder.path,
|
|
89
|
+
tokensCssRel,
|
|
90
|
+
...(themes.length
|
|
91
|
+
? { themes, themeDefault: themes.includes('light') ? 'light' : (themes[0] as string) }
|
|
92
|
+
: {}),
|
|
93
|
+
...(rootClass ? { rootClass } : {}),
|
|
94
|
+
folderOwned: true,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** `rel` (designRoot-relative) is a regular file on disk — a symlink never counts. */
|
|
99
|
+
export function isRealFile(designRoot: string, rel: string): boolean {
|
|
100
|
+
try {
|
|
101
|
+
return lstatSync(path.join(designRoot, ...rel.split('/'))).isFile();
|
|
102
|
+
} catch {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The folder-owned systems on disk under `<designRoot>/system/`, by name. */
|
|
108
|
+
export function folderOwnedSystems(
|
|
109
|
+
designRoot: string,
|
|
110
|
+
configured: ReadonlyArray<{ name: string; path: string }>
|
|
111
|
+
): FolderSystemEntry[] {
|
|
112
|
+
let dirs: string[];
|
|
113
|
+
try {
|
|
114
|
+
dirs = readdirSync(path.join(designRoot, 'system'), { withFileTypes: true })
|
|
115
|
+
.filter((d) => d.isDirectory())
|
|
116
|
+
.map((d) => d.name)
|
|
117
|
+
.sort();
|
|
118
|
+
} catch {
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
const out: FolderSystemEntry[] = [];
|
|
122
|
+
for (const seg of dirs) {
|
|
123
|
+
const f = folderSystemOf(`system/${seg}/design-system.tsx`, configured, (r) =>
|
|
124
|
+
isRealFile(designRoot, r)
|
|
125
|
+
);
|
|
126
|
+
if (f) out.push(folderSystemEntry(designRoot, f));
|
|
127
|
+
}
|
|
128
|
+
return out;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function configuredOf(config: Record<string, unknown>): Array<{ name: string; path: string }> {
|
|
132
|
+
const list = Array.isArray(config.designSystems) ? config.designSystems : [];
|
|
133
|
+
return (list as Array<Record<string, unknown> | null>)
|
|
134
|
+
.filter((e) => !!e && typeof e.name === 'string' && typeof e.path === 'string')
|
|
135
|
+
.map((e) => ({
|
|
136
|
+
name: (e as { name: string }).name,
|
|
137
|
+
path: (e as { path: string }).path.replace(/^\/+|\/+$/g, ''),
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* `config` with its `designSystems` extended by the folder-owned systems on disk (after the
|
|
143
|
+
* configured ones). The same object back when there are none. For READING only: a writer of
|
|
144
|
+
* `config.json` reads the file itself, so a folder system is never persisted into it.
|
|
145
|
+
*/
|
|
146
|
+
export function withFolderSystems<T extends Record<string, unknown>>(
|
|
147
|
+
config: T,
|
|
148
|
+
designRoot: string
|
|
149
|
+
): T {
|
|
150
|
+
const folders = folderOwnedSystems(designRoot, configuredOf(config));
|
|
151
|
+
if (!folders.length) return config;
|
|
152
|
+
const list = Array.isArray(config.designSystems) ? (config.designSystems as unknown[]) : [];
|
|
153
|
+
return { ...config, designSystems: [...list, ...folders] };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The `config.json` entry that adopts folder system `ds`: what the merged list shows for it (name,
|
|
158
|
+
* path, the themes and root class guessed from its tokens), without the `folderOwned` mark — so
|
|
159
|
+
* the system reads the same once it is configured. Null when `ds` is not a folder system here.
|
|
160
|
+
*/
|
|
161
|
+
export function adoptionEntry(
|
|
162
|
+
designRoot: string,
|
|
163
|
+
config: Record<string, unknown>,
|
|
164
|
+
ds: string
|
|
165
|
+
): Record<string, unknown> | null {
|
|
166
|
+
const f = folderOwnedSystems(designRoot, configuredOf(config)).find((s) => s.name === ds);
|
|
167
|
+
if (!f) return null;
|
|
168
|
+
const { folderOwned: _mark, tokensCssRel, ...entry } = f;
|
|
169
|
+
// the tokens CSS is the default one (`<path>/colors_and_type.css`): no key, as a made system has
|
|
170
|
+
return tokensCssRel === `${f.path}/colors_and_type.css` ? entry : { ...entry, tokensCssRel };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A DS write that edits a system's `config.json` entry (default, rename, the schema flag) on a
|
|
175
|
+
* folder-owned system adopts it first: its entry is appended to `config.designSystems` (mutated in
|
|
176
|
+
* place, the caller writes the file as for a configured system). True when it adopted one.
|
|
177
|
+
*/
|
|
178
|
+
export function adoptFolderSystem(
|
|
179
|
+
designRoot: string,
|
|
180
|
+
config: Record<string, unknown>,
|
|
181
|
+
ds: string
|
|
182
|
+
): boolean {
|
|
183
|
+
if (configuredOf(config).some((s) => s.name === ds)) return false;
|
|
184
|
+
const entry = adoptionEntry(designRoot, config, ds);
|
|
185
|
+
if (!entry) return false;
|
|
186
|
+
const list = Array.isArray(config.designSystems) ? (config.designSystems as unknown[]) : [];
|
|
187
|
+
config.designSystems = [...list, entry];
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The files whose change can add, drop or retheme a folder system. */
|
|
192
|
+
export function isFolderSystemFile(rel: unknown): boolean {
|
|
193
|
+
return (
|
|
194
|
+
typeof rel === 'string' &&
|
|
195
|
+
/^system\/[^/]+\/(design-system\.tsx|colors_and_type\.css)$/.test(
|
|
196
|
+
rel.replace(/\\/g, '/').replace(/^\/+/, '')
|
|
197
|
+
)
|
|
198
|
+
);
|
|
199
|
+
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { readFileSync } from 'node:fs';
|
|
23
23
|
import path from 'node:path';
|
|
24
|
+
import { withFolderSystems } from './folder-systems.ts';
|
|
24
25
|
import { type SystemConfig, systemConfigsFrom } from './system.ts';
|
|
25
26
|
|
|
26
27
|
const NAME_RE = /^--[A-Za-z0-9_-]{1,64}$/;
|
|
@@ -113,7 +114,7 @@ export function pairingCssFor(
|
|
|
113
114
|
): string {
|
|
114
115
|
if (!query) return '';
|
|
115
116
|
const tokensRel = query.get('tokens');
|
|
116
|
-
const sys = systemForTokens(config, tokensRel);
|
|
117
|
+
const sys = systemForTokens(withFolderSystems(config, designRoot), tokensRel);
|
|
117
118
|
if (!sys || !tokensRel) return '';
|
|
118
119
|
const rel = canvasRelOf(designRoot, query);
|
|
119
120
|
if (!rel) return '';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// ds/post-build.ts — 2.0.5 (#205): what ds-check --canvas knows about canvases refused AFTER their build.
|
|
2
|
+
//
|
|
3
|
+
// The import walk (access/closure.ts) is static: it names a canvas that imports another canvas. A built module
|
|
4
|
+
// can still be refused at serve time (the inputs gate inlined a file another canvas owns); only the running
|
|
5
|
+
// studio knows, and it reports it on the main origin's `/_index-data` as `canvasRefusedInputs`
|
|
6
|
+
// (access/refused-inputs.ts). `bin/_ds-check-live.mjs` asks that studio — loopback only — and hands the answer
|
|
7
|
+
// here; with no studio ds-check says so and prints the static reasons only.
|
|
8
|
+
|
|
9
|
+
export interface PostBuild {
|
|
10
|
+
/** A studio for this project answered. False = only the import walk was checked. */
|
|
11
|
+
live: boolean;
|
|
12
|
+
/** canvas (design-root-relative, `ui/a.tsx`) → the design-root files its built module was refused for. */
|
|
13
|
+
refused: Map<string, string[]>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const NO_STUDIO: PostBuild = { live: false, refused: new Map() };
|
|
17
|
+
|
|
18
|
+
/** What to print when no studio answered, so a quiet report is not read as "nothing is refused". */
|
|
19
|
+
export const NO_STUDIO_NOTE =
|
|
20
|
+
'note: no studio is running for this project — only the import walk was checked. A canvas refused after its build (it uses a file another canvas owns) shows here while the studio is open.';
|
|
21
|
+
|
|
22
|
+
/** `/_index-data` → the refused files per canvas, keys design-root-relative. Anything else is ignored. */
|
|
23
|
+
export function refusedFromIndex(index: unknown): Map<string, string[]> {
|
|
24
|
+
const out = new Map<string, string[]>();
|
|
25
|
+
if (!index || typeof index !== 'object') return out;
|
|
26
|
+
const rec = index as { designRoot?: unknown; canvasRefusedInputs?: unknown };
|
|
27
|
+
const designRel =
|
|
28
|
+
typeof rec.designRoot === 'string' && rec.designRoot ? rec.designRoot : '.design';
|
|
29
|
+
const raw = rec.canvasRefusedInputs;
|
|
30
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return out;
|
|
31
|
+
for (const [key, list] of Object.entries(raw as Record<string, unknown>)) {
|
|
32
|
+
if (!Array.isArray(list)) continue;
|
|
33
|
+
const names = list.filter((n): n is string => typeof n === 'string' && n !== '');
|
|
34
|
+
if (!names.length) continue;
|
|
35
|
+
out.set(key.startsWith(`${designRel}/`) ? key.slice(designRel.length + 1) : key, names);
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}
|
package/apps/studio/ds/rename.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
|
14
14
|
import path from 'node:path';
|
|
15
15
|
|
|
16
16
|
import { stripSpoofChars } from '../spoof-chars.ts';
|
|
17
|
+
import { adoptFolderSystem, withFolderSystems } from './folder-systems.ts';
|
|
17
18
|
|
|
18
19
|
export const SYSTEM_LABEL_MAX = 64;
|
|
19
20
|
|
|
@@ -64,6 +65,9 @@ export function renameSystem(designRoot: string, ds: string, raw: string | null)
|
|
|
64
65
|
} catch {
|
|
65
66
|
throw new RenameError('ds-config-unreadable', 'The project’s config could not be read.', 500);
|
|
66
67
|
}
|
|
68
|
+
// 2.0.7 — a folder-owned system (not in config.json yet, ds/folder-systems.ts) is adopted first: its entry is
|
|
69
|
+
// appended, then labelled as a configured system is
|
|
70
|
+
const adopted = adoptFolderSystem(designRoot, cfg, ds);
|
|
67
71
|
const systems = (Array.isArray(cfg.designSystems) ? cfg.designSystems : []) as unknown[];
|
|
68
72
|
const entry = systems.find(
|
|
69
73
|
(s): s is Record<string, unknown> =>
|
|
@@ -80,8 +84,11 @@ export function renameSystem(designRoot: string, ds: string, raw: string | null)
|
|
|
80
84
|
);
|
|
81
85
|
if (label !== null) {
|
|
82
86
|
const fold = label.toLowerCase();
|
|
83
|
-
|
|
84
|
-
|
|
87
|
+
// every system the person can see: configured ones and the folder-owned ones not adopted yet
|
|
88
|
+
const shown = (withFolderSystems(cfg, designRoot).designSystems ?? []) as unknown[];
|
|
89
|
+
const clash = shown.some((s) => {
|
|
90
|
+
if (!s || typeof s !== 'object' || s === entry || (s as { name?: unknown }).name === ds)
|
|
91
|
+
return false;
|
|
85
92
|
const o = s as { name?: unknown; label?: unknown };
|
|
86
93
|
return [o.label, o.name].some(
|
|
87
94
|
(v) => typeof v === 'string' && v.trim().toLowerCase() === fold
|
|
@@ -91,7 +98,7 @@ export function renameSystem(designRoot: string, ds: string, raw: string | null)
|
|
|
91
98
|
throw new RenameError('ds-name-taken', 'Another design system already has that name.', 409);
|
|
92
99
|
}
|
|
93
100
|
const previous = typeof entry.label === 'string' ? entry.label : null;
|
|
94
|
-
if (previous === label) return { changed: false, previous, label };
|
|
101
|
+
if (previous === label && !adopted) return { changed: false, previous, label };
|
|
95
102
|
if (label === null) delete entry.label;
|
|
96
103
|
else entry.label = label;
|
|
97
104
|
// keep the file's own indentation and final newline
|
|
@@ -13,6 +13,7 @@ import { createHash } from 'node:crypto';
|
|
|
13
13
|
import { readFileSync } from 'node:fs';
|
|
14
14
|
import { join } from 'node:path';
|
|
15
15
|
import { declaredBy, renderFallbacks } from './fallbacks.ts';
|
|
16
|
+
import { withFolderSystems } from './folder-systems.ts';
|
|
16
17
|
import { pairingCssFor, systemForTokens } from './pairing-css.ts';
|
|
17
18
|
import { loadRegistry } from './registry.ts';
|
|
18
19
|
import { diskFs, loadSystem } from './system.ts';
|
|
@@ -40,7 +41,7 @@ export function fallbacksFor(
|
|
|
40
41
|
config: Record<string, unknown>,
|
|
41
42
|
tokensRel: string | null
|
|
42
43
|
): string {
|
|
43
|
-
const sys = systemForTokens(config, tokensRel);
|
|
44
|
+
const sys = systemForTokens(withFolderSystems(config, designRoot), tokensRel);
|
|
44
45
|
if (!sys) return '';
|
|
45
46
|
const rels = [sys.tokensCssRel, `${sys.path}/preview/_components.css`];
|
|
46
47
|
const digest = `${digestOf(designRoot, rels)}:${JSON.stringify(sys)}`;
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
// was visible (`systemFailed`), and the live tree still hashes to the stage's `beforeTreeHash`. Then:
|
|
5
5
|
// 1. every codemodded canvas that passed the visual gate goes to the kernel as ONE proposal
|
|
6
6
|
// (labelled "Brought <system> up to schema v1") — one Version-history entry, one ⌘Z;
|
|
7
|
-
//
|
|
8
|
-
//
|
|
7
|
+
// — its LANES only (.tsx / .meta.json / .annotations.json); a codemod's other files (a CSS
|
|
8
|
+
// twin) are no document's lane and go with step 2;
|
|
9
|
+
// 2. only once the kernel accepted it, those files and the system files (tokens CSS, tokens.json,
|
|
10
|
+
// config.json's `schema: 1`) are written on Plane B, tmp + rename, and the action's record lands in
|
|
9
11
|
// `_state/ds-upgrade/<ds>/applied/<actionId>.json` with both versions of each file;
|
|
10
12
|
// 3. the throwaway stage folder goes.
|
|
11
13
|
// The undo hook (S10.2's `registerUndoHook`, wired through `registerDsUndoHook`) runs after the
|
|
@@ -69,6 +71,11 @@ export interface ApplyResult {
|
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
const NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
74
|
+
/** The files of a canvas the kernel holds as lanes of its document. */
|
|
75
|
+
export function canvasLanes(canvas: string): Set<string> {
|
|
76
|
+
const base = canvas.replace(/\.tsx$/i, '');
|
|
77
|
+
return new Set([canvas, `${base}.meta.json`, `${base}.annotations.json`]);
|
|
78
|
+
}
|
|
72
79
|
const ID_RE = /^[A-Za-z0-9_-]{1,128}$/;
|
|
73
80
|
const readText = (abs: string) => {
|
|
74
81
|
try {
|
|
@@ -119,14 +126,28 @@ async function applyLocked(inp: ApplyInput): Promise<ApplyResult> {
|
|
|
119
126
|
);
|
|
120
127
|
const pass = new Set(review.updatesCanvases.filter((c) => c.diff === 'pass').map((c) => c.path));
|
|
121
128
|
const after = path.join(stage.dir, 'after', '.design');
|
|
129
|
+
// The kernel takes a canvas's LANES only (its .tsx, .meta.json, .annotations.json): a codemod's
|
|
130
|
+
// other files (the canvas's CSS twin) are no document's lane — a linked hub answers
|
|
131
|
+
// `unknown-canvas`, the local home `invalid`. They ride the file plane with the system files.
|
|
122
132
|
const files: { rel: string; text: string }[] = [];
|
|
133
|
+
const planeFiles: { rel: string; before: string | null; after: string }[] = [];
|
|
134
|
+
const systemRels = new Set(stage.systemFiles.map((f) => f.rel));
|
|
135
|
+
const seen = new Set<string>();
|
|
123
136
|
let updated = 0;
|
|
124
137
|
for (const c of stage.canvases) {
|
|
125
138
|
if (!pass.has(c.path)) continue;
|
|
139
|
+
const lanes = canvasLanes(c.path);
|
|
126
140
|
for (const rel of c.files) {
|
|
127
141
|
const text = readText(path.join(after, rel));
|
|
128
142
|
if (text === null) throw new DsUpgradeError('ds-upgrade-no-stage', `the stage lost ${rel}`);
|
|
129
|
-
|
|
143
|
+
if (seen.has(rel)) continue;
|
|
144
|
+
seen.add(rel);
|
|
145
|
+
if (lanes.has(rel)) files.push({ rel, text });
|
|
146
|
+
else if (!systemRels.has(rel)) {
|
|
147
|
+
const abs = safeAbs(inp.designRoot, rel);
|
|
148
|
+
if (!abs) throw new DsUpgradeError('ds-upgrade-no-stage', `the stage names ${rel}`);
|
|
149
|
+
planeFiles.push({ rel, before: readText(abs), after: text });
|
|
150
|
+
}
|
|
130
151
|
}
|
|
131
152
|
updated++;
|
|
132
153
|
}
|
|
@@ -147,8 +168,9 @@ async function applyLocked(inp: ApplyInput): Promise<ApplyResult> {
|
|
|
147
168
|
);
|
|
148
169
|
actionId = out.actionId ?? null;
|
|
149
170
|
}
|
|
150
|
-
// Plane B, after the kernel accepted:
|
|
151
|
-
|
|
171
|
+
// Plane B, after the kernel accepted: the canvases' other files, the system files, config.json
|
|
172
|
+
// (the schema flag) last
|
|
173
|
+
const ordered = [...planeFiles, ...stage.systemFiles].sort(
|
|
152
174
|
(a, b) => Number(a.rel === 'config.json') - Number(b.rel === 'config.json')
|
|
153
175
|
);
|
|
154
176
|
for (const f of ordered) atomicWrite(path.join(inp.designRoot, f.rel), f.after);
|
|
@@ -44,6 +44,24 @@ export interface UpgradeAsyncOptions {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const out = (code: number, stdout = '', stderr = ''): UpgradeRun => ({ code, stdout, stderr });
|
|
47
|
+
|
|
48
|
+
export const USAGE = `usage: maude design ds-upgrade <ds> <step> [--root <project>]
|
|
49
|
+
|
|
50
|
+
Bring a design system up to the schema (V2-1.13 §5.10). Steps, in order:
|
|
51
|
+
--analyse the check + the mechanical plan, as JSON (read-only)
|
|
52
|
+
--plan-mechanical the plan JSON alone (read-only)
|
|
53
|
+
--validate <plan.json> the invariants on a judged plan (exit 13 = refused, nothing written)
|
|
54
|
+
--stage <plan.json> throwaway before/ + after/ copies; prints the stage, its "stamp" field
|
|
55
|
+
names it in the steps below
|
|
56
|
+
--prove <stamp> two headless studios + the visual gate → review.json
|
|
57
|
+
--apply <stamp> ONE action through the project's open studio (exit 3 = none open)
|
|
58
|
+
--discard <stamp> the throwaway copies and the record go
|
|
59
|
+
--status the live stages and their stamps: staged, being proved, proved
|
|
60
|
+
--cancel <stamp> stops a proof in flight (then --discard)
|
|
61
|
+
|
|
62
|
+
<stamp> is the digits --stage printed (or --status lists); the record folder
|
|
63
|
+
<designRoot>/_state/ds-upgrade/<ds>/<stamp>/ works too.
|
|
64
|
+
`;
|
|
47
65
|
const json = (v: unknown) => `${JSON.stringify(v, null, 2)}\n`;
|
|
48
66
|
const refusal = (e: DsUpgradeError) =>
|
|
49
67
|
out(
|
|
@@ -64,6 +82,7 @@ export function runDsUpgrade(
|
|
|
64
82
|
const names: string[] = [];
|
|
65
83
|
for (let i = 0; i < argv.length; i++) {
|
|
66
84
|
const t = argv[i];
|
|
85
|
+
if (t === '--help' || t === '-h' || t === 'help') return out(EXIT.ok, USAGE);
|
|
67
86
|
if (t === '--root') root = argv[++i] ?? null;
|
|
68
87
|
else if (t === '--analyse' || t === '--plan-mechanical' || t === '--status')
|
|
69
88
|
step = t.slice(2);
|
|
@@ -78,12 +97,13 @@ export function runDsUpgrade(
|
|
|
78
97
|
);
|
|
79
98
|
} else if (t === '--json') {
|
|
80
99
|
/* always JSON */
|
|
81
|
-
} else if (t.startsWith('--'))
|
|
100
|
+
} else if (t.startsWith('--'))
|
|
101
|
+
throw new UsageError(`unknown flag ${t} (maude design ds-upgrade --help)`);
|
|
82
102
|
else names.push(t);
|
|
83
103
|
}
|
|
84
104
|
if (names.length !== 1 || !step)
|
|
85
105
|
throw new UsageError(
|
|
86
|
-
'usage: ds-upgrade <ds> --analyse | --plan-mechanical | --status | --validate|--stage <plan.json> | --prove|--apply|--discard|--cancel <
|
|
106
|
+
'usage: ds-upgrade <ds> --analyse | --plan-mechanical | --status | --validate|--stage <plan.json> | --prove|--apply|--discard|--cancel <stamp> (--help for more)'
|
|
87
107
|
);
|
|
88
108
|
const project = loadProject(root, env);
|
|
89
109
|
const [cfg] = selectSystems(project, names);
|