@erclx/canon 5.53.0 → 5.54.0
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/CHANGELOG.md +10 -0
- package/README.md +10 -9
- package/claude/.claude-plugin/plugin.json +1 -1
- package/claude/skills/canon-cli/SKILL.md +5 -5
- package/claude/skills/design-identity/REQUIREMENT.md +2 -2
- package/claude/skills/design-identity/SKILL.md +6 -6
- package/claude/skills/design-record/REQUIREMENT.md +2 -2
- package/claude/skills/design-record/SKILL.md +4 -4
- package/claude/skills/design-record/references/folder.md +1 -1
- package/claude/skills/design-taste/REQUIREMENT.md +1 -1
- package/claude/skills/draw-figure/REQUIREMENT.md +1 -1
- package/claude/skills/draw-figure/SKILL.md +1 -1
- package/claude/skills/pick-by-eye/REQUIREMENT.md +4 -4
- package/claude/skills/pick-by-eye/SKILL.md +34 -41
- package/claude/skills/pick-by-eye/references/board.md +42 -0
- package/claude/skills/pick-by-eye/references/live-arms.md +3 -3
- package/claude/skills/plan-groundwork/SKILL.md +1 -1
- package/claude/skills/teach-craft/REQUIREMENT.md +1 -1
- package/claude/skills/teach-craft/SKILL.md +32 -1
- package/claude/skills/teach-craft/references/adopted.md +113 -0
- package/claude/skills/teach-craft/references/lesson-craft.md +10 -2
- package/claude/skills/teach-craft/references/pedagogy.md +29 -2
- package/docs/agents/install-and-sync.md +0 -8
- package/docs/target/migrations.md +8 -3
- package/docs/target/projects.md +1 -1
- package/docs/workflow/skill-map.md +0 -1
- package/docs/workflow/visual-design-workflow.md +1 -4
- package/governance/detect.toml +1 -6
- package/governance/renames.toml +0 -1
- package/package.json +2 -5
- package/src/claude/cases/misc.ts +0 -5
- package/src/claude/skills-audit.ts +1 -0
- package/src/cli/help.ts +0 -3
- package/src/cli.ts +0 -2
- package/src/commands/design.ts +16 -315
- package/src/commands/sync.ts +4 -5
- package/src/design/regen.ts +5 -32
- package/src/design/render.ts +1 -1
- package/src/design/tokens.ts +3 -2
- package/src/gate/stages.ts +4 -10
- package/src/gov/audit.ts +1 -6
- package/src/markdown/scope.ts +2 -4
- package/src/shipped/references.ts +1 -2
- package/src/sync/check.ts +4 -29
- package/src/sync/stamp.ts +6 -6
- package/src/sync/target.ts +1 -4
- package/tooling/claude/reference.md +1 -1
- package/tooling/claude/seeds/canon/DESIGN.md +1 -1
- package/claude/skills/canvas-board/REQUIREMENT.md +0 -35
- package/claude/skills/canvas-board/SKILL.md +0 -143
- package/claude/skills/canvas-board/references/canvas.md +0 -170
- package/governance/rules/ui/canvas.md +0 -13
- package/src/canvas/address.ts +0 -227
- package/src/canvas/arrange.ts +0 -66
- package/src/canvas/capture.ts +0 -391
- package/src/canvas/client/app.tsx +0 -188
- package/src/canvas/client/inspector/align-grid.tsx +0 -162
- package/src/canvas/client/inspector/color-field.tsx +0 -398
- package/src/canvas/client/inspector/color-inputs.tsx +0 -139
- package/src/canvas/client/inspector/color-picker.tsx +0 -668
- package/src/canvas/client/inspector/color-space.ts +0 -240
- package/src/canvas/client/inspector/field.tsx +0 -263
- package/src/canvas/client/inspector/fields.css +0 -763
- package/src/canvas/client/inspector/section.tsx +0 -27
- package/src/canvas/client/inspector/size-field.tsx +0 -69
- package/src/canvas/client/inspector/token-select.tsx +0 -109
- package/src/canvas/client/inspector/values.ts +0 -297
- package/src/canvas/client/inspector.tsx +0 -692
- package/src/canvas/client/keys.ts +0 -71
- package/src/canvas/client/layers.tsx +0 -118
- package/src/canvas/client/main.tsx +0 -71
- package/src/canvas/client/pages-panel.tsx +0 -212
- package/src/canvas/client/panel-handle.tsx +0 -90
- package/src/canvas/client/selection.tsx +0 -199
- package/src/canvas/client/shell.css +0 -762
- package/src/canvas/client/state.ts +0 -792
- package/src/canvas/client/surface.tsx +0 -803
- package/src/canvas/client/theme-panel.tsx +0 -55
- package/src/canvas/client/tools.tsx +0 -153
- package/src/canvas/content.ts +0 -781
- package/src/canvas/edit.ts +0 -575
- package/src/canvas/editing.ts +0 -203
- package/src/canvas/fit.ts +0 -238
- package/src/canvas/global.d.ts +0 -15
- package/src/canvas/history.ts +0 -116
- package/src/canvas/index.html +0 -20
- package/src/canvas/server.ts +0 -766
- package/src/canvas/tokens.ts +0 -221
- package/src/commands/canvas.ts +0 -1097
- package/src/design/adapter.ts +0 -59
- package/src/design/base.css +0 -203
- package/src/design/brand-favicon.ts +0 -18
- package/src/design/neutral.ts +0 -127
- package/src/design/project-fonts.ts +0 -392
package/src/canvas/tokens.ts
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
2
|
-
import { join } from 'node:path'
|
|
3
|
-
import { DESIGN_INSTALL_DIR, DESIGN_PROJECT_SUBDIR } from '@/design/adapter'
|
|
4
|
-
import { buildDesignCss, fontFaceBlock } from '@/design/css'
|
|
5
|
-
import {
|
|
6
|
-
FONT_FACES,
|
|
7
|
-
HAND_DRAWN_FONT_FACES,
|
|
8
|
-
type FontFace,
|
|
9
|
-
} from '@/design/fonts'
|
|
10
|
-
import {
|
|
11
|
-
type DroppedFace,
|
|
12
|
-
inlineProjectFaces,
|
|
13
|
-
projectSheets,
|
|
14
|
-
} from '@/design/project-fonts'
|
|
15
|
-
import { isOwnCheckout } from '@/roots/project'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The stylesheet injected into every frame, so a frame drawn with
|
|
19
|
-
* `var(--color-*)` shows the project's own values. Parsing a `DESIGN.md` into
|
|
20
|
-
* custom properties is left out, since no such mapping exists, and a frame can
|
|
21
|
-
* always link a stylesheet of its own.
|
|
22
|
-
*/
|
|
23
|
-
export type FrameTokens =
|
|
24
|
-
| { readonly source: 'toolkit'; readonly css: string }
|
|
25
|
-
| {
|
|
26
|
-
readonly source: 'installed'
|
|
27
|
-
readonly css: string
|
|
28
|
-
/** Relative to the root, in the order the stylesheet concatenates them. */
|
|
29
|
-
readonly files: readonly string[]
|
|
30
|
-
/** Project faces left out of the sheet, present only when one was. */
|
|
31
|
-
readonly dropped?: readonly DroppedFace[]
|
|
32
|
-
}
|
|
33
|
-
| { readonly source: 'none'; readonly css: string; readonly notice: string }
|
|
34
|
-
|
|
35
|
-
export interface TokenOptions {
|
|
36
|
-
/** Overrides the checkout test, which reads this package's own name. */
|
|
37
|
-
readonly isOwnCheckout?: boolean
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const BASE_FILE = 'base.css'
|
|
41
|
-
|
|
42
|
-
const NONE_NOTICE = `No token stylesheet, so frames render unstyled. Run canon design install to add ${join(DESIGN_INSTALL_DIR, BASE_FILE)}, put overrides under ${join(DESIGN_INSTALL_DIR, DESIGN_PROJECT_SUBDIR)}/, or link a stylesheet from the frame.`
|
|
43
|
-
|
|
44
|
-
export type TokenKind =
|
|
45
|
-
| 'color'
|
|
46
|
-
| 'spacing'
|
|
47
|
-
| 'radius'
|
|
48
|
-
| 'font-family'
|
|
49
|
-
| 'font-size'
|
|
50
|
-
| 'other'
|
|
51
|
-
|
|
52
|
-
export interface Token {
|
|
53
|
-
readonly name: string
|
|
54
|
-
readonly value: string
|
|
55
|
-
/** The literal a `var()` value ends at, where the sheet defines it. */
|
|
56
|
-
readonly resolved?: string
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface TokenGroup {
|
|
60
|
-
readonly kind: TokenKind
|
|
61
|
-
readonly tokens: readonly Token[]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const KIND_ORDER: readonly TokenKind[] = [
|
|
65
|
-
'color',
|
|
66
|
-
'spacing',
|
|
67
|
-
'radius',
|
|
68
|
-
'font-family',
|
|
69
|
-
'font-size',
|
|
70
|
-
'other',
|
|
71
|
-
]
|
|
72
|
-
|
|
73
|
-
/** By the naming the toolkit's module and most token sheets share. */
|
|
74
|
-
function kindOf(name: string): TokenKind {
|
|
75
|
-
if (name.startsWith('--color-')) return 'color'
|
|
76
|
-
if (/^--(space|spacing)-/.test(name)) return 'spacing'
|
|
77
|
-
if (name.startsWith('--radius-')) return 'radius'
|
|
78
|
-
if (/-family$|^--font-family-/.test(name)) return 'font-family'
|
|
79
|
-
if (/-size$|^--font-size-|^--text-/.test(name)) return 'font-size'
|
|
80
|
-
return 'other'
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const DECLARATION = /(--[A-Za-z0-9_-]+)\s*:\s*([^;}]*)/g
|
|
84
|
-
|
|
85
|
-
const REFERENCE = /^var\(\s*(--[A-Za-z0-9_-]+)\s*(?:,[^)]*)?\)$/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* The custom properties a token sheet defines, grouped by kind. A property
|
|
89
|
-
* defined twice keeps its first value, which is the dark theme's in this
|
|
90
|
-
* toolkit's module and the base's in an installed sheet. Empty groups drop.
|
|
91
|
-
*/
|
|
92
|
-
export function tokenGroups(css: string): TokenGroup[] {
|
|
93
|
-
const values = new Map<string, string>()
|
|
94
|
-
for (const [, name, value] of css
|
|
95
|
-
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
96
|
-
.matchAll(DECLARATION)) {
|
|
97
|
-
if (name && value !== undefined && !values.has(name)) {
|
|
98
|
-
values.set(name, value.trim())
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const resolve = (value: string, seen: Set<string>): string | undefined => {
|
|
103
|
-
const reference = value.match(REFERENCE)?.[1]
|
|
104
|
-
if (!reference) return value
|
|
105
|
-
const next = values.get(reference)
|
|
106
|
-
if (next === undefined || seen.has(reference)) return undefined
|
|
107
|
-
return resolve(next, new Set([...seen, reference]))
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const grouped = new Map<TokenKind, Token[]>()
|
|
111
|
-
for (const [name, value] of values) {
|
|
112
|
-
const resolved = REFERENCE.test(value)
|
|
113
|
-
? resolve(value, new Set([name]))
|
|
114
|
-
: undefined
|
|
115
|
-
const token =
|
|
116
|
-
resolved === undefined ? { name, value } : { name, value, resolved }
|
|
117
|
-
const kind = kindOf(name)
|
|
118
|
-
grouped.set(kind, [...(grouped.get(kind) ?? []), token])
|
|
119
|
-
}
|
|
120
|
-
return KIND_ORDER.flatMap((kind) => {
|
|
121
|
-
const tokens = grouped.get(kind)
|
|
122
|
-
return tokens ? [{ kind, tokens }] : []
|
|
123
|
-
})
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* The families a served sheet declares a face for, so a caller reads what the
|
|
128
|
-
* frames carry from the same sheet the server builds rather than from a list
|
|
129
|
-
* of its own.
|
|
130
|
-
*/
|
|
131
|
-
export function servedFamilies(css: string): Set<string> {
|
|
132
|
-
const families = new Set<string>()
|
|
133
|
-
for (const [, family] of css.matchAll(
|
|
134
|
-
/@font-face\s*{[^}]*?font-family:\s*["']?([^"';}]+)/g,
|
|
135
|
-
)) {
|
|
136
|
-
if (family) families.add(family.trim())
|
|
137
|
-
}
|
|
138
|
-
return families
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** The installed files in cascade order: the base first, then each override. */
|
|
142
|
-
function installedFiles(root: string): string[] {
|
|
143
|
-
const base = join(DESIGN_INSTALL_DIR, BASE_FILE)
|
|
144
|
-
return [
|
|
145
|
-
...(existsSync(join(root, base)) ? [base] : []),
|
|
146
|
-
...projectSheets(root),
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The vendored faces no project rule already declares, so a frame naming
|
|
152
|
-
* `Geist Variable` renders the same face in the capture and in any browser
|
|
153
|
-
* whether or not a sheet names it, and a project face of the same family wins
|
|
154
|
-
* outright.
|
|
155
|
-
*/
|
|
156
|
-
function toolkitFaces(declared: ReadonlySet<string>): FontFace[] {
|
|
157
|
-
return [...FONT_FACES, ...HAND_DRAWN_FONT_FACES].filter(
|
|
158
|
-
(face) => !declared.has(face.family),
|
|
159
|
-
)
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* A project sheet with its local `url()`s inlined, since a frame is served
|
|
164
|
-
* from the content folder and cannot reach a path under `.claude/design/`.
|
|
165
|
-
*/
|
|
166
|
-
function installedSheets(root: string, files: readonly string[]) {
|
|
167
|
-
const projectDir = join(DESIGN_INSTALL_DIR, DESIGN_PROJECT_SUBDIR)
|
|
168
|
-
const dropped: DroppedFace[] = []
|
|
169
|
-
const declared = new Set<string>()
|
|
170
|
-
const css = files
|
|
171
|
-
.map((file) => {
|
|
172
|
-
const raw = readFileSync(join(root, file), 'utf8')
|
|
173
|
-
if (!file.startsWith(projectDir)) return `/* ${file} */\n${raw}`
|
|
174
|
-
const inlined = inlineProjectFaces(root, file, raw)
|
|
175
|
-
dropped.push(...inlined.dropped)
|
|
176
|
-
for (const family of inlined.declared) declared.add(family)
|
|
177
|
-
return `/* ${file} */\n${inlined.css}`
|
|
178
|
-
})
|
|
179
|
-
.join('\n')
|
|
180
|
-
return { css, dropped, declared }
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* The toolkit's own module where the root is this checkout, else the installed
|
|
185
|
-
* base plus its project overrides, else nothing with a notice naming where
|
|
186
|
-
* tokens would come from.
|
|
187
|
-
*/
|
|
188
|
-
export function resolveFrameTokens(
|
|
189
|
-
root: string,
|
|
190
|
-
options: TokenOptions = {},
|
|
191
|
-
): FrameTokens {
|
|
192
|
-
if (options.isOwnCheckout ?? isOwnCheckout(root)) {
|
|
193
|
-
/*
|
|
194
|
-
* Faces embedded, since the type tokens name `Geist Variable` and a
|
|
195
|
-
* machine with only static Geist installed renders every frame in the
|
|
196
|
-
* fallback.
|
|
197
|
-
*/
|
|
198
|
-
return {
|
|
199
|
-
source: 'toolkit',
|
|
200
|
-
css: buildDesignCss(undefined, { embedFonts: true }),
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const files = installedFiles(root)
|
|
205
|
-
if (files.length > 0) {
|
|
206
|
-
const { css, dropped, declared } = installedSheets(root, files)
|
|
207
|
-
const faces = toolkitFaces(declared)
|
|
208
|
-
return {
|
|
209
|
-
source: 'installed',
|
|
210
|
-
css: faces.length > 0 ? `${fontFaceBlock(faces)}\n${css}` : css,
|
|
211
|
-
files,
|
|
212
|
-
...(dropped.length > 0 && { dropped }),
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
return {
|
|
217
|
-
source: 'none',
|
|
218
|
-
css: fontFaceBlock(toolkitFaces(new Set())),
|
|
219
|
-
notice: NONE_NOTICE,
|
|
220
|
-
}
|
|
221
|
-
}
|