@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
|
@@ -510,6 +510,12 @@
|
|
|
510
510
|
var(--maude-hud-shadow-md),
|
|
511
511
|
inset 0 0 0 1px var(--maude-hud-accent);
|
|
512
512
|
}
|
|
513
|
+
.ds-bar-b--ic {
|
|
514
|
+
display: grid;
|
|
515
|
+
place-items: center;
|
|
516
|
+
padding-inline: 7px;
|
|
517
|
+
}
|
|
518
|
+
|
|
513
519
|
.ds-bar-b:disabled {
|
|
514
520
|
opacity: 0.4;
|
|
515
521
|
cursor: default;
|
|
@@ -6,10 +6,15 @@
|
|
|
6
6
|
// system's tokens and never CSS system colours: it is Maude's bar over the user's design, so a locked or
|
|
7
7
|
// garish brand must not restyle it, and it follows the APP theme (a `Canvas` bar was white in the dark app).
|
|
8
8
|
// 13 `DsBar`: island · 24 px `system` glyph tile · name · `.seg` Light | Dark · Review… as the primary button.
|
|
9
|
+
// 2.0.7 polish (decision `v2-207-pages-on-ds-canvas`): Canvas | Pages and, in Pages, ‹ n / N › after Light | Dark —
|
|
10
|
+
// the switch every ordinary canvas has on its pill (canvas-pages-view.tsx), which this canvas does not draw.
|
|
9
11
|
|
|
12
|
+
import type { ReactNode } from 'react';
|
|
10
13
|
import { createPortal } from 'react-dom';
|
|
11
14
|
import { DsIcon } from '../../canvas-ds-icons.tsx';
|
|
15
|
+
import { CanvasPagesSwitch } from '../../canvas-pages-view.tsx';
|
|
12
16
|
import { setCanvasTheme } from '../../canvas-theme.ts';
|
|
17
|
+
import { THEME_WORD, ThemeIcon } from '../../canvas-theme-icons.tsx';
|
|
13
18
|
import { isEmbedCanvas } from '../../read-only-mode.ts';
|
|
14
19
|
import { useBoardMode, useBoardModel } from './state.ts';
|
|
15
20
|
import type { BoardMode, BoardModel } from './types.ts';
|
|
@@ -26,11 +31,14 @@ export function DsBarView({
|
|
|
26
31
|
mode,
|
|
27
32
|
onMode,
|
|
28
33
|
onReview,
|
|
34
|
+
pages = null,
|
|
29
35
|
}: {
|
|
30
36
|
model: BoardModel;
|
|
31
37
|
mode: BoardMode;
|
|
32
38
|
onMode: (m: BoardMode) => void;
|
|
33
39
|
onReview?: () => void;
|
|
40
|
+
/** Canvas | Pages (the connected bar passes `CanvasPagesSwitch variant="ds"`) */
|
|
41
|
+
pages?: ReactNode;
|
|
34
42
|
}) {
|
|
35
43
|
const linked = !!model.library;
|
|
36
44
|
// a linked library takes no edits here: nothing waits, so there is nothing to Review…
|
|
@@ -47,16 +55,20 @@ export function DsBarView({
|
|
|
47
55
|
<button
|
|
48
56
|
key={m}
|
|
49
57
|
type="button"
|
|
50
|
-
className="ds-bar-b k-seg-b"
|
|
58
|
+
className="ds-bar-b ds-bar-b--ic k-seg-b"
|
|
51
59
|
data-testid={`ds-bar-mode-${m}`}
|
|
52
60
|
aria-pressed={mode === m}
|
|
61
|
+
aria-label={THEME_WORD[m]}
|
|
53
62
|
disabled={m === 'dark' && !hasDark}
|
|
63
|
+
// 2.0.7 — icons only, like the canvas pill; the name (or what's missing) is the tooltip
|
|
64
|
+
title={m === 'dark' && !hasDark ? 'This design system has no Dark' : THEME_WORD[m]}
|
|
54
65
|
onClick={() => onMode(m)}
|
|
55
66
|
>
|
|
56
|
-
{m
|
|
67
|
+
<ThemeIcon mode={m} />
|
|
57
68
|
</button>
|
|
58
69
|
))}
|
|
59
70
|
</fieldset>
|
|
71
|
+
{pages}
|
|
60
72
|
{linked ? (
|
|
61
73
|
<>
|
|
62
74
|
<span className="ds-bar-sep" />
|
|
@@ -101,7 +113,13 @@ export function DsBar({ onReview, portal = true }: { onReview?: () => void; port
|
|
|
101
113
|
// an embed (the reach view's Patterns frame, DDR-247) shows the design alone: the bar is Maude's chrome
|
|
102
114
|
if (!model || isEmbedCanvas()) return null;
|
|
103
115
|
const bar = (
|
|
104
|
-
<DsBarView
|
|
116
|
+
<DsBarView
|
|
117
|
+
model={model}
|
|
118
|
+
mode={mode}
|
|
119
|
+
onMode={(m) => setCanvasTheme(m)}
|
|
120
|
+
onReview={ask}
|
|
121
|
+
pages={<CanvasPagesSwitch variant="ds" />}
|
|
122
|
+
/>
|
|
105
123
|
);
|
|
106
124
|
return portal && typeof document !== 'undefined' ? createPortal(bar, document.body) : bar;
|
|
107
125
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// `Section`). Without them the system's `.<root>[data-theme]` token blocks never matched this wrapper, so a
|
|
11
11
|
// specimen page stayed in Light while the seven sections switched.
|
|
12
12
|
|
|
13
|
-
import { DSRoot } from '@maude/canvas-lib';
|
|
13
|
+
import { DSRoot, useArtboardSeen } from '@maude/canvas-lib';
|
|
14
14
|
import { Component, type ComponentType, type ReactNode } from 'react';
|
|
15
15
|
import { getSpecimen, useBoardMode, useBoardModel } from './state.ts';
|
|
16
16
|
import { themeFor } from './types.ts';
|
|
@@ -43,10 +43,24 @@ function Missing({ src, why }: { src: string; why: string }) {
|
|
|
43
43
|
export function Specimen({ src, mode: modeProp }: { src: string; mode?: 'light' | 'dark' }) {
|
|
44
44
|
const model = useBoardModel();
|
|
45
45
|
const stored = useBoardMode();
|
|
46
|
+
// 2.0.5 — a specimen page mounts once its artboard first comes near the viewport (a board of 58 built
|
|
47
|
+
// every page at open). The artboard keeps its size meanwhile; captures and exports mount all of them.
|
|
48
|
+
const seen = useArtboardSeen();
|
|
49
|
+
const mode = modeProp ?? stored;
|
|
50
|
+
// 2.0.7 — the pending page carries the system's root class and theme like the page itself: without them its
|
|
51
|
+
// `var(--bg-1)` fell back to the `Canvas` system colour, which in a dark scheme is a black box.
|
|
52
|
+
if (!seen)
|
|
53
|
+
return (
|
|
54
|
+
<DSRoot
|
|
55
|
+
theme={model ? themeFor(model, mode) : undefined}
|
|
56
|
+
className={`ds-board ds-specimen ds-specimen-pending${model?.rootClass ? ` ${model.rootClass}` : ''}${mode === 'dark' ? ' ds-dark' : ''}`}
|
|
57
|
+
data-ds-specimen={src}
|
|
58
|
+
aria-hidden="true"
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
46
61
|
const mod = getSpecimen(src) as { default?: ComponentType } | ComponentType | undefined;
|
|
47
62
|
const Comp = (typeof mod === 'function' ? mod : mod?.default) as ComponentType | undefined;
|
|
48
63
|
if (!Comp) return <Missing src={src} why="is not loaded" />;
|
|
49
|
-
const mode = modeProp ?? stored;
|
|
50
64
|
return (
|
|
51
65
|
<DSRoot
|
|
52
66
|
theme={model ? themeFor(model, mode) : undefined}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { readFileSync } from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
|
-
import { ROW_GAP } from '../../canvas-rows.ts';
|
|
7
|
+
import { MAX_ROW_COLUMNS, ROW_GAP } from '../../canvas-rows.ts';
|
|
8
8
|
import { DEV_SERVER_ROOT } from '../../paths.ts';
|
|
9
9
|
import { SECTIONS, type SectionKind } from './types.ts';
|
|
10
10
|
|
|
@@ -22,9 +22,9 @@ export interface OwnSpecimenArtboard {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
|
-
* Own artboards sit below the seven sections at a showcase's size (V2-1.6 §5.2's example):
|
|
26
|
-
*
|
|
27
|
-
* row `rowGap` below the last. A specimen page grows past `h` (the artboard hugs its content, 1 500–4 750
|
|
25
|
+
* Own artboards sit below the seven sections at a showcase's size (V2-1.6 §5.2's example): each
|
|
26
|
+
* section starts a row, in the order the artboards come (convert-map.ts gives them in section order),
|
|
27
|
+
* wraps after `MAX_ROW_COLUMNS` pages (2.0.7 fix #6), and each row sits `rowGap` below the last. A specimen page grows past `h` (the artboard hugs its content, 1 500–4 750
|
|
28
28
|
* px measured live on this repo's two systems, 2026-10-31), and the height is only known once the page
|
|
29
29
|
* is on screen — so the generator writes the COMPACT pitch (`h + ROW_GAP`) and the open canvas re-pitches
|
|
30
30
|
* the rows from the measured heights (`canvas-rows.ts` `flowRows`, r3-ds-rows): a row is as tall as its
|
|
@@ -33,22 +33,42 @@ export interface OwnSpecimenArtboard {
|
|
|
33
33
|
*/
|
|
34
34
|
export const OWN_ARTBOARD = { w: 1440, h: 900, y: 1860, gap: 48, rowGap: ROW_GAP } as const;
|
|
35
35
|
|
|
36
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* The design-px box of each own artboard: each section starts a row, in first-seen order, and wraps
|
|
38
|
+
* onto the next row after `MAX_ROW_COLUMNS` pages (2.0.7 fix #6 — one row per section made StudyFi's
|
|
39
|
+
* 29 component pages a 43 000 px row and the canvas fitted at 2 %).
|
|
40
|
+
*/
|
|
37
41
|
function ownLayout(own: readonly OwnSpecimenArtboard[]) {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
if (!
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
const sections: Array<string | undefined> = [];
|
|
43
|
+
const bySection = new Map<string | undefined, OwnSpecimenArtboard[]>();
|
|
44
|
+
for (const o of own) {
|
|
45
|
+
if (!bySection.has(o.section)) {
|
|
46
|
+
sections.push(o.section);
|
|
47
|
+
bySection.set(o.section, []);
|
|
48
|
+
}
|
|
49
|
+
bySection.get(o.section)?.push(o);
|
|
50
|
+
}
|
|
51
|
+
const place = new Map<string, { x: number; y: number }>();
|
|
52
|
+
let row = 0;
|
|
53
|
+
for (const s of sections) {
|
|
54
|
+
const pages = bySection.get(s) ?? [];
|
|
55
|
+
pages.forEach((o, i) => {
|
|
56
|
+
const col = i % MAX_ROW_COLUMNS;
|
|
57
|
+
place.set(o.id, {
|
|
58
|
+
x: col * (OWN_ARTBOARD.w + OWN_ARTBOARD.gap),
|
|
59
|
+
y:
|
|
60
|
+
OWN_ARTBOARD.y +
|
|
61
|
+
(row + Math.floor(i / MAX_ROW_COLUMNS)) * (OWN_ARTBOARD.h + OWN_ARTBOARD.rowGap),
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
row += Math.ceil(pages.length / MAX_ROW_COLUMNS);
|
|
65
|
+
}
|
|
66
|
+
return own.map((o) => ({
|
|
67
|
+
id: o.id,
|
|
68
|
+
...(place.get(o.id) as { x: number; y: number }),
|
|
69
|
+
w: OWN_ARTBOARD.w,
|
|
70
|
+
h: OWN_ARTBOARD.h,
|
|
71
|
+
}));
|
|
52
72
|
}
|
|
53
73
|
|
|
54
74
|
/**
|
|
@@ -3,7 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
import { readdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
5
5
|
import { join, relative, resolve } from 'node:path';
|
|
6
|
+
import { canvasImportsReport } from '../access/closure.ts';
|
|
7
|
+
import { closureConfigFor } from '../access/known-canvases.ts';
|
|
8
|
+
import { diskProjectReader } from '../access/request.ts';
|
|
6
9
|
import { claimWritesSync } from '../bin/_write-claim.mjs';
|
|
10
|
+
import { canvasImportsLines } from '../client/v2/code/canvas-imports-words.js';
|
|
7
11
|
import {
|
|
8
12
|
type CanvasContext,
|
|
9
13
|
type CanvasReport,
|
|
@@ -15,6 +19,7 @@ import {
|
|
|
15
19
|
} from './canvas-check.ts';
|
|
16
20
|
import { checkSystem, type SystemReport } from './check.ts';
|
|
17
21
|
import type { DsCheckArgs, Project, RunResult } from './cli.ts';
|
|
22
|
+
import { NO_STUDIO_NOTE, type PostBuild } from './post-build.ts';
|
|
18
23
|
import { indexRegistry, loadRegistry } from './registry.ts';
|
|
19
24
|
import { diskFs, loadSystem, type SystemModel } from './system.ts';
|
|
20
25
|
|
|
@@ -196,7 +201,8 @@ export function runCanvasModes(
|
|
|
196
201
|
project: Project,
|
|
197
202
|
systemsSelected: SystemReport[] | null,
|
|
198
203
|
t0: number,
|
|
199
|
-
hookInput: string | null
|
|
204
|
+
hookInput: string | null,
|
|
205
|
+
post: PostBuild | null = null
|
|
200
206
|
): RunResult {
|
|
201
207
|
const ctx = canvasContext(project);
|
|
202
208
|
if (args.cheatsheet) {
|
|
@@ -326,6 +332,8 @@ export function runCanvasModes(
|
|
|
326
332
|
registry: 1,
|
|
327
333
|
durationMs: Math.round(performance.now() - t0),
|
|
328
334
|
systems: systemsSelected ?? [],
|
|
335
|
+
studio: post?.live ?? null,
|
|
336
|
+
refusedInputs: Object.fromEntries(post?.refused ?? []),
|
|
329
337
|
canvases: reports.map((r) => ({ ...r, findings: r.findings.map(({ span: _s, ...f }) => f) })),
|
|
330
338
|
...(args.fix ? { fixed, dryRun: args.dryRun } : {}),
|
|
331
339
|
};
|
|
@@ -338,9 +346,57 @@ export function runCanvasModes(
|
|
|
338
346
|
? `${args.dryRun ? 'would fix' : 'fixed'}: ${fixed.map((f) => `${f.file} (${f.edits})`).join(', ')}`
|
|
339
347
|
: 'nothing to fix'
|
|
340
348
|
);
|
|
341
|
-
|
|
349
|
+
const why = refusedWhy(project, reports, post);
|
|
350
|
+
for (const r of reports) {
|
|
351
|
+
lines.push(...(args.quiet ? [`${r.path}: ${r.state}`] : summarize(r)));
|
|
352
|
+
for (const line of why.get(r.path) ?? []) lines.push(` ✗ ${line}`);
|
|
353
|
+
}
|
|
342
354
|
if (!reports.length) lines.push('no canvas matched');
|
|
355
|
+
else if (post && !post.live) lines.push(NO_STUDIO_NOTE);
|
|
343
356
|
return { code, stdout: `${lines.join('\n')}\n`, stderr: '' };
|
|
344
357
|
}
|
|
345
358
|
|
|
359
|
+
/**
|
|
360
|
+
* 2.0.5 (#205) — why a canvas renders nothing in its frame, in the shell card's words
|
|
361
|
+
* (client/v2/code/canvas-imports-words.js): (1) its import walk reaches another canvas's code (the studio
|
|
362
|
+
* refuses its module, access/closure.ts `walkImports`; judged with the closure config the studio uses), and
|
|
363
|
+
* (2) — only a running studio knows — its BUILT module was refused for a file another canvas owns (`post`,
|
|
364
|
+
* read from `/_index-data` by bin/_ds-check-live.mjs).
|
|
365
|
+
*/
|
|
366
|
+
function refusedWhy(
|
|
367
|
+
project: Project,
|
|
368
|
+
reports: CanvasReport[],
|
|
369
|
+
post: PostBuild | null
|
|
370
|
+
): Map<string, string[]> {
|
|
371
|
+
const out = new Map<string, string[]>();
|
|
372
|
+
if (!reports.length) return out;
|
|
373
|
+
let walked = new Map<string, string[]>();
|
|
374
|
+
try {
|
|
375
|
+
const reader = diskProjectReader(project.designRoot, () => 'ds-check');
|
|
376
|
+
const cfg = closureConfigFor({
|
|
377
|
+
cfg: project.config as { linkedHub?: { url?: string } | null },
|
|
378
|
+
paths: { designRoot: project.designRoot },
|
|
379
|
+
});
|
|
380
|
+
walked = canvasImportsReport(
|
|
381
|
+
reader,
|
|
382
|
+
reports.map((r) => r.path),
|
|
383
|
+
cfg
|
|
384
|
+
);
|
|
385
|
+
} catch {
|
|
386
|
+
/* the walk is a courtesy here: the report stands without it */
|
|
387
|
+
}
|
|
388
|
+
const dir =
|
|
389
|
+
typeof project.config.newComponentDir === 'string' ? project.config.newComponentDir : '';
|
|
390
|
+
for (const r of reports) {
|
|
391
|
+
const imports = walked.get(r.path) ?? [];
|
|
392
|
+
const built = post?.refused.get(r.path) ?? [];
|
|
393
|
+
if (!imports.length && !built.length) continue;
|
|
394
|
+
out.set(
|
|
395
|
+
r.path,
|
|
396
|
+
canvasImportsLines(imports, dir, built).filter((l): l is string => typeof l === 'string')
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
return out;
|
|
400
|
+
}
|
|
401
|
+
|
|
346
402
|
export { relative, resolve };
|
package/apps/studio/ds/check.ts
CHANGED
|
@@ -209,6 +209,31 @@ export function checkSystem(model: SystemModel, idx: RegistryIndex): SystemRepor
|
|
|
209
209
|
if (themeGaps.length) reasons.add('theme-gap');
|
|
210
210
|
if (cfg.themes.length === 1) reasons.add('single-theme');
|
|
211
211
|
|
|
212
|
+
// fix/ds-convert-hooks-cli #10 — a colour role declared ONLY on `:root` as `var(--x)`: a custom
|
|
213
|
+
// property's var() is resolved where it is declared, so a nested `[data-theme='light']` island
|
|
214
|
+
// inherits the value `:root` resolved (the dark one) even when it redefines `--x`. A warning
|
|
215
|
+
// note (no level change: theme-gap / single-theme already carry one), with the fix.
|
|
216
|
+
const rootOnly: string[] = [];
|
|
217
|
+
for (const r of required) {
|
|
218
|
+
if (!r.perTheme) continue;
|
|
219
|
+
const ds = model.byName.get(r.name) ?? [];
|
|
220
|
+
if (!ds.length) continue;
|
|
221
|
+
const onlyRoot = ds.every((d) =>
|
|
222
|
+
(model.rules[d.rule]?.selector ?? '')
|
|
223
|
+
.replace(/\/\*[\s\S]*?\*\//g, ' ')
|
|
224
|
+
.split(',')
|
|
225
|
+
.every((s) => s.trim() === ':root')
|
|
226
|
+
);
|
|
227
|
+
if (onlyRoot && ds.some((d) => /\bvar\(/.test(d.value))) rootOnly.push(r.name);
|
|
228
|
+
}
|
|
229
|
+
const rootOnlyNote = rootOnly.length
|
|
230
|
+
? {
|
|
231
|
+
id: 'root-only-roles',
|
|
232
|
+
name: rootOnly.join(' '),
|
|
233
|
+
detail: `declared only on :root as var(…), so a nested [data-theme] island inherits the value :root resolved, not its own theme's. Declare them in each theme's rule too (e.g. \`.ds[data-theme="light"], [data-theme="light"] { ${rootOnly[0]}: var(…); }\`), so every island resolves var() against its own theme.`,
|
|
234
|
+
}
|
|
235
|
+
: null;
|
|
236
|
+
|
|
212
237
|
// ── Value types + unresolved refs ──────────────────────────────────────────
|
|
213
238
|
const typeErrors: TypeError_[] = [];
|
|
214
239
|
const unresolvedRefs: { name: string; ref: string }[] = [];
|
|
@@ -256,7 +281,7 @@ export function checkSystem(model: SystemModel, idx: RegistryIndex): SystemRepor
|
|
|
256
281
|
collisions.push({ id: 'type-mismatch', name: e.name, detect: 'type' });
|
|
257
282
|
}
|
|
258
283
|
if (typeErrors.length) reasons.add('type-collision');
|
|
259
|
-
const notes: SystemReport['notes'] = [];
|
|
284
|
+
const notes: SystemReport['notes'] = rootOnlyNote ? [rootOnlyNote] : [];
|
|
260
285
|
for (const row of reg.collisions) {
|
|
261
286
|
if (row.detect === 'type') continue;
|
|
262
287
|
let hit: string | null = null;
|
package/apps/studio/ds/cli.ts
CHANGED
|
@@ -6,6 +6,8 @@ import { join, resolve } from 'node:path';
|
|
|
6
6
|
import { runCanvasModes } from './canvas-cli.ts';
|
|
7
7
|
import { checkSystem, type SystemReport } from './check.ts';
|
|
8
8
|
import { emitTokensJson } from './emit.ts';
|
|
9
|
+
import { withFolderSystems } from './folder-systems.ts';
|
|
10
|
+
import type { PostBuild } from './post-build.ts';
|
|
9
11
|
import { indexRegistry, loadRegistry } from './registry.ts';
|
|
10
12
|
import {
|
|
11
13
|
diskFs,
|
|
@@ -134,7 +136,12 @@ export function loadProject(
|
|
|
134
136
|
const cfgPath = join(designRoot, 'config.json');
|
|
135
137
|
if (!existsSync(cfgPath)) throw new UsageError(`no .design/config.json under ${root}`);
|
|
136
138
|
const config = JSON.parse(readFileSync(cfgPath, 'utf8')) as Record<string, unknown>;
|
|
137
|
-
return {
|
|
139
|
+
return {
|
|
140
|
+
root,
|
|
141
|
+
designRoot,
|
|
142
|
+
config,
|
|
143
|
+
systems: systemConfigsFrom(withFolderSystems(config, designRoot)),
|
|
144
|
+
};
|
|
138
145
|
}
|
|
139
146
|
|
|
140
147
|
export function selectSystems(project: Project, names: string[]): SystemConfig[] {
|
|
@@ -261,7 +268,9 @@ function humanSystem(r: SystemReport): string {
|
|
|
261
268
|
` C7: ${r.c7.families} accent famil${r.c7.families === 1 ? 'y' : 'ies'} vs ${r.c7.strategy} → ${r.c7.pass ? 'pass' : 'FAIL'}`
|
|
262
269
|
);
|
|
263
270
|
for (const n of r.notes)
|
|
264
|
-
lines.push(
|
|
271
|
+
lines.push(
|
|
272
|
+
` ${n.id === 'root-only-roles' ? 'warning' : 'note'}: ${n.id}${n.name ? ` (${n.name})` : ''} — ${n.detail}`
|
|
273
|
+
);
|
|
265
274
|
return lines.join('\n');
|
|
266
275
|
}
|
|
267
276
|
|
|
@@ -274,7 +283,8 @@ export interface RunResult {
|
|
|
274
283
|
export function runDsCheck(
|
|
275
284
|
argv: string[],
|
|
276
285
|
env: Record<string, string | undefined> = process.env,
|
|
277
|
-
hookInput: string | null = null
|
|
286
|
+
hookInput: string | null = null,
|
|
287
|
+
post: PostBuild | null = null
|
|
278
288
|
): RunResult {
|
|
279
289
|
const t0 = performance.now();
|
|
280
290
|
let args: DsCheckArgs;
|
|
@@ -300,7 +310,7 @@ export function runDsCheck(
|
|
|
300
310
|
if (args.emit) throw new UsageError('--emit is a system flag; run it without canvas flags');
|
|
301
311
|
// `<ds> --canvases`: the system result rides along (its code wins when non-zero)
|
|
302
312
|
const sys = args.allCanvases && args.systems.length ? systemReports(project, systems) : null;
|
|
303
|
-
return runCanvasModes(args, project, sys, t0, hookInput);
|
|
313
|
+
return runCanvasModes(args, project, sys, t0, hookInput, post);
|
|
304
314
|
}
|
|
305
315
|
let emitted: { written: string[]; refused: string[] } | null = null;
|
|
306
316
|
if (args.emit) {
|
|
@@ -13,6 +13,7 @@ import path from 'node:path';
|
|
|
13
13
|
|
|
14
14
|
import { RECIPES } from '../edit-ops/insert-component.ts';
|
|
15
15
|
import { canvasSystemFor } from './ds-resolver.ts';
|
|
16
|
+
import { withFolderSystems } from './folder-systems.ts';
|
|
16
17
|
import { readHead } from './head.ts';
|
|
17
18
|
import { type SystemConfig, systemConfigsFrom } from './system.ts';
|
|
18
19
|
|
|
@@ -76,7 +77,7 @@ function readJson(abs: string): Record<string, unknown> | null {
|
|
|
76
77
|
export function systemForPicker(designRoot: string, canvasAbs: string | null): SystemConfig | null {
|
|
77
78
|
if (canvasAbs) return canvasSystemFor(designRoot, canvasAbs);
|
|
78
79
|
const config = readJson(path.join(designRoot, 'config.json')) ?? {};
|
|
79
|
-
const systems = systemConfigsFrom(config);
|
|
80
|
+
const systems = systemConfigsFrom(withFolderSystems(config, designRoot));
|
|
80
81
|
const def = typeof config.defaultDesignSystem === 'string' ? config.defaultDesignSystem : null;
|
|
81
82
|
return systems.find((s) => s.name === def) ?? systems[0] ?? null;
|
|
82
83
|
}
|
|
@@ -170,6 +170,39 @@ function readText(abs: string): string | null {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
/** The Design system canvas's own files (canvas, sidecar, board), moved from `dsAbs` into `trashAbs`. */
|
|
174
|
+
function moveDsCanvasFiles(dsAbs: string, trashAbs: string): string[] {
|
|
175
|
+
const moved: string[] = [];
|
|
176
|
+
for (const f of [DS_CANVAS, DS_META, DS_ANNOTATIONS]) {
|
|
177
|
+
const from = path.join(dsAbs, f);
|
|
178
|
+
if (!existsSync(from)) continue;
|
|
179
|
+
mkdirSync(trashAbs, { recursive: true });
|
|
180
|
+
renameSync(from, path.join(trashAbs, f));
|
|
181
|
+
moved.push(f);
|
|
182
|
+
}
|
|
183
|
+
return moved;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* fix/ds-convert-hooks-cli #8 — a Design system canvas left over by a system that is a FOLDER (no
|
|
188
|
+
* head.json: a Restore that sync brought back, a copy) goes to the Trash the way Restore puts one
|
|
189
|
+
* there: `_trash/ds-convert/<ds>-<stamp>/`. `null` when the system is converted — then the canvas IS
|
|
190
|
+
* the system, and Restore (`ds convert <ds> --restore`) is the way back.
|
|
191
|
+
*/
|
|
192
|
+
export function trashFolderDsCanvas(
|
|
193
|
+
designRoot: string,
|
|
194
|
+
dsRel: string,
|
|
195
|
+
now = Date.now()
|
|
196
|
+
): { trash: string; moved: string[] } | null {
|
|
197
|
+
const a = path.join(designRoot, ...dsRel.split('/'));
|
|
198
|
+
if (readHead(a).state !== 'absent') return null;
|
|
199
|
+
const name = path.basename(a);
|
|
200
|
+
let trash = `${RESTORE_TRASH_REL}/${name}-${stampOf(now)}`;
|
|
201
|
+
for (let n = 2; existsSync(path.join(designRoot, trash)); n++)
|
|
202
|
+
trash = `${RESTORE_TRASH_REL}/${name}-${stampOf(now)}-${n}`;
|
|
203
|
+
return { trash, moved: moveDsCanvasFiles(a, path.join(designRoot, trash)) };
|
|
204
|
+
}
|
|
205
|
+
|
|
173
206
|
const stampOf = (ms: number) =>
|
|
174
207
|
new Date(ms)
|
|
175
208
|
.toISOString()
|
|
@@ -580,12 +613,7 @@ export function createDsConvert(engine: DsEngine) {
|
|
|
580
613
|
const moved = moveHeadAside(a, { head: h.doc.head, base: h.doc.base }, trashAbs);
|
|
581
614
|
if (tokens !== null && tokens !== model.tokensJson)
|
|
582
615
|
atomicWrite(path.join(a, TOKENS_JSON_KEY), tokens);
|
|
583
|
-
|
|
584
|
-
const from = path.join(a, f);
|
|
585
|
-
if (!existsSync(from)) continue;
|
|
586
|
-
renameSync(from, path.join(trashAbs, f));
|
|
587
|
-
moved.push(f);
|
|
588
|
-
}
|
|
616
|
+
moved.push(...moveDsCanvasFiles(a, trashAbs));
|
|
589
617
|
return {
|
|
590
618
|
action: 'restore',
|
|
591
619
|
rev: null,
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import { readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
|
+
import { adoptFolderSystem } from './folder-systems.ts';
|
|
13
|
+
|
|
12
14
|
/** Same shape as the engine's refusals (`code` + `status`), so the route answers it the same way. */
|
|
13
15
|
class DefaultError extends Error {
|
|
14
16
|
constructor(
|
|
@@ -39,6 +41,9 @@ export function setDefaultSystem(designRoot: string, ds: string): DefaultResult
|
|
|
39
41
|
} catch {
|
|
40
42
|
throw new DefaultError('ds-config-unreadable', 'The project’s config could not be read.', 500);
|
|
41
43
|
}
|
|
44
|
+
// 2.0.7 — a folder-owned system (not in config.json yet, ds/folder-systems.ts) is adopted first: its entry is
|
|
45
|
+
// appended, then the default is set as for a configured system
|
|
46
|
+
const adopted = adoptFolderSystem(designRoot, cfg, ds);
|
|
42
47
|
const systems = Array.isArray(cfg.designSystems) ? (cfg.designSystems as unknown[]) : [];
|
|
43
48
|
const names = systems.map((s) =>
|
|
44
49
|
s && typeof s === 'object' ? (s as { name?: unknown }).name : null
|
|
@@ -46,7 +51,7 @@ export function setDefaultSystem(designRoot: string, ds: string): DefaultResult
|
|
|
46
51
|
if (!names.includes(ds))
|
|
47
52
|
throw new DefaultError('ds-unknown-system', `no design system named ${ds.slice(0, 64)}`, 404);
|
|
48
53
|
const previous = typeof cfg.defaultDesignSystem === 'string' ? cfg.defaultDesignSystem : null;
|
|
49
|
-
if (previous === ds) return { changed: false, previous, default: ds };
|
|
54
|
+
if (previous === ds && !adopted) return { changed: false, previous, default: ds };
|
|
50
55
|
cfg.defaultDesignSystem = ds;
|
|
51
56
|
// keep the file's own indentation and final newline
|
|
52
57
|
const indent = /^\{\n( +|\t)"/.exec(text)?.[1] ?? ' ';
|
|
@@ -14,6 +14,12 @@ import path from 'node:path';
|
|
|
14
14
|
import type { BunPlugin } from 'bun';
|
|
15
15
|
import { DEV_SERVER_ROOT } from '../paths.ts';
|
|
16
16
|
import { boardDeps, buildBoardModel } from './board/build-model.ts';
|
|
17
|
+
import {
|
|
18
|
+
folderOwnedSystems,
|
|
19
|
+
folderSystemEntry,
|
|
20
|
+
folderSystemOf,
|
|
21
|
+
pinnedFolderSystem,
|
|
22
|
+
} from './folder-systems.ts';
|
|
17
23
|
import { type SystemConfig, systemConfigsFrom } from './system.ts';
|
|
18
24
|
|
|
19
25
|
export const DS_SPECIFIER = '@maude/ds';
|
|
@@ -84,19 +90,52 @@ function readJson(abs: string): Record<string, unknown> | null {
|
|
|
84
90
|
|
|
85
91
|
const metaPathFor = (canvasAbs: string) => canvasAbs.replace(/\.tsx$/, '.meta.json');
|
|
86
92
|
|
|
87
|
-
|
|
93
|
+
// the one rule, re-exported for the callers that import it from here
|
|
94
|
+
export { folderSystemOf };
|
|
95
|
+
|
|
96
|
+
/** The `SystemConfig` of a folder-owned system: its themes and root class read from its tokens. */
|
|
97
|
+
function folderSystemConfig(
|
|
98
|
+
designRoot: string,
|
|
99
|
+
config: Record<string, unknown>,
|
|
100
|
+
folder: { name: string; path: string }
|
|
101
|
+
): SystemConfig {
|
|
102
|
+
const [sys] = systemConfigsFrom({
|
|
103
|
+
...config,
|
|
104
|
+
designSystems: [folderSystemEntry(designRoot, folder)],
|
|
105
|
+
});
|
|
106
|
+
return sys as SystemConfig;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* The design system a canvas renders under, or null when the project has none. Owner by path →
|
|
111
|
+
* 2.0.7 owner by its own folder → `meta.designSystem` (a configured system, else a folder system
|
|
112
|
+
* of exactly that name) → `defaultDesignSystem` → the first system of the merged list (the first
|
|
113
|
+
* configured one whenever the config lists any). A pin to a name with no system stays at the
|
|
114
|
+
* default: a name never invents a path.
|
|
115
|
+
*/
|
|
88
116
|
export function canvasSystemFor(designRoot: string, canvasAbs: string): SystemConfig | null {
|
|
89
|
-
const
|
|
90
|
-
|
|
117
|
+
const config = readJson(path.join(designRoot, 'config.json')) ?? {};
|
|
118
|
+
const systems = systemConfigsFrom(config);
|
|
91
119
|
const rel = path.relative(designRoot, canvasAbs).split(path.sep).join('/');
|
|
92
120
|
const owner = systems.find((s) => rel.startsWith(`${s.path}/`));
|
|
93
121
|
if (owner) return owner;
|
|
94
|
-
const
|
|
95
|
-
const
|
|
122
|
+
const hasFile = (r: string) => existsSync(path.join(designRoot, ...r.split('/')));
|
|
123
|
+
const folder = folderSystemOf(rel, systems, hasFile);
|
|
124
|
+
if (folder) return folderSystemConfig(designRoot, config, folder);
|
|
125
|
+
const named = (name: unknown): SystemConfig | null => {
|
|
126
|
+
if (typeof name !== 'string' || !name) return null;
|
|
127
|
+
const configured = systems.find((s) => s.name === name);
|
|
128
|
+
if (configured) return configured;
|
|
129
|
+
const pinned = pinnedFolderSystem(name, systems, hasFile);
|
|
130
|
+
return pinned ? folderSystemConfig(designRoot, config, pinned) : null;
|
|
131
|
+
};
|
|
132
|
+
const byMeta = named(readJson(metaPathFor(canvasAbs))?.designSystem);
|
|
96
133
|
if (byMeta) return byMeta;
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
134
|
+
const byDefault = named(config.defaultDesignSystem);
|
|
135
|
+
if (byDefault) return byDefault;
|
|
136
|
+
if (systems.length) return systems[0] as SystemConfig;
|
|
137
|
+
const [first] = folderOwnedSystems(designRoot, systems);
|
|
138
|
+
return first ? folderSystemConfig(designRoot, config, first) : null;
|
|
100
139
|
}
|
|
101
140
|
|
|
102
141
|
const overridePath = (designRoot: string, sys: SystemConfig) =>
|
|
@@ -194,6 +233,17 @@ export function dsResolver(designRoot: string, canvasAbs: string): BunPlugin {
|
|
|
194
233
|
export function dsDepsFor(source: string, canvasAbs: string, designRoot: string): string[] {
|
|
195
234
|
if (!usesDs(source)) return [];
|
|
196
235
|
const deps = [metaPathFor(canvasAbs), path.join(designRoot, 'config.json')];
|
|
236
|
+
// 2.0.7 — a pin to a system the config does not list resolves once its folder's Design system
|
|
237
|
+
// canvas arrives (a cell gets it as files), so that file appearing is a change too
|
|
238
|
+
const declared = readJson(metaPathFor(canvasAbs))?.designSystem;
|
|
239
|
+
if (
|
|
240
|
+
typeof declared === 'string' &&
|
|
241
|
+
/^[^/\\._][^/\\]*$/.test(declared) &&
|
|
242
|
+
!systemConfigsFrom(readJson(path.join(designRoot, 'config.json')) ?? {}).some(
|
|
243
|
+
(s) => s.name === declared
|
|
244
|
+
)
|
|
245
|
+
)
|
|
246
|
+
deps.push(path.join(designRoot, 'system', declared, 'design-system.tsx'));
|
|
197
247
|
const sys = canvasSystemFor(designRoot, canvasAbs);
|
|
198
248
|
if (sys && importsDs(source)) deps.push(overridePath(designRoot, sys));
|
|
199
249
|
if (sys && importsDsBoard(source)) {
|
|
@@ -20,6 +20,7 @@ import path from 'node:path';
|
|
|
20
20
|
import { LOCAL_OWNER } from '../access/request.ts';
|
|
21
21
|
import { createDsUsage } from '../index/ds-usage.ts';
|
|
22
22
|
import { type DsOp, type DsOpAnswer, runDsOp } from '../routes/ds.ts';
|
|
23
|
+
import { recordPendingDelete } from '../sync/pending-deletes.ts';
|
|
23
24
|
import { createDsEngine } from './engine.ts';
|
|
24
25
|
import type { By } from './head.ts';
|
|
25
26
|
|
|
@@ -556,6 +557,18 @@ export async function execDsPlan(
|
|
|
556
557
|
usage,
|
|
557
558
|
access: LOCAL_OWNER,
|
|
558
559
|
by,
|
|
560
|
+
// #7 — no studio, no bus: a deletion (Restore trashing the Design system canvas) is written
|
|
561
|
+
// down for the next sync boot to tell the project (sync/pending-deletes.ts).
|
|
562
|
+
emit: (event, payload) => {
|
|
563
|
+
const p = payload as { action?: unknown; slug?: unknown; rel?: unknown } | null;
|
|
564
|
+
if (
|
|
565
|
+
event === 'canvas-list-update' &&
|
|
566
|
+
p?.action === 'removed' &&
|
|
567
|
+
typeof p.slug === 'string' &&
|
|
568
|
+
typeof p.rel === 'string'
|
|
569
|
+
)
|
|
570
|
+
recordPendingDelete(designRoot, { slug: p.slug, rel: p.rel });
|
|
571
|
+
},
|
|
559
572
|
});
|
|
560
573
|
} finally {
|
|
561
574
|
usage?.stop();
|
package/apps/studio/ds/engine.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { atomicWrite } from '../sync/atomic-write.ts';
|
|
|
38
38
|
import { modesOf } from './board/types.ts';
|
|
39
39
|
import { followedDark } from './contrast.ts';
|
|
40
40
|
import { canvasSystemFor } from './ds-resolver.ts';
|
|
41
|
+
import { withFolderSystems } from './folder-systems.ts';
|
|
41
42
|
import {
|
|
42
43
|
type ComponentEdit,
|
|
43
44
|
emitTokensJson,
|
|
@@ -419,8 +420,9 @@ export function createDsEngine(opts: EngineOptions) {
|
|
|
419
420
|
return readJsonObj(path.join(designRoot, 'config.json')) ?? {};
|
|
420
421
|
}
|
|
421
422
|
|
|
423
|
+
// 2.0.7 — the configured systems, then the folder-owned ones (ds/folder-systems.ts)
|
|
422
424
|
function systems(): SystemConfig[] {
|
|
423
|
-
return systemConfigsFrom(config());
|
|
425
|
+
return systemConfigsFrom(withFolderSystems(config(), designRoot));
|
|
424
426
|
}
|
|
425
427
|
|
|
426
428
|
function system(ds: string): SystemConfig {
|