@rien7/design-surface 0.1.1 → 0.1.3

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.
@@ -7,14 +7,7 @@ const runtimeBase = fs.existsSync(new URL('../dist/cli/init.mjs', import.meta.ur
7
7
  ? '../dist'
8
8
  : '../src'
9
9
 
10
- const { initDesignSurface } = await import(`${runtimeBase}/cli/init.mjs`)
11
- const { proposeToken } = await import(`${runtimeBase}/cli/propose.mjs`)
12
- const { replyReviewItem, updateReviewItemStatus } = await import(`${runtimeBase}/cli/reviewOps.mjs`)
13
- const { buildAgentPrompt, isCopyableReviewItem, isUnreviewedProposal } = await import(
14
- `${runtimeBase}/shared/prompt.mjs`
15
- )
16
- const { extractTokensFromCss } = await import(`${runtimeBase}/tokens/extract.mjs`)
17
- const { runTokenPipeline } = await import(`${runtimeBase}/tokens/pipeline.mjs`)
10
+ const loadModule = (relPath) => import(`${runtimeBase}/${relPath}`)
18
11
 
19
12
  const root = process.cwd()
20
13
  const designRoot = path.join(root, 'design')
@@ -99,6 +92,7 @@ if (command === 'init') {
99
92
  if (cssFormat !== undefined && cssFormat !== 'theme' && cssFormat !== 'root') {
100
93
  fail(`invalid --css-format "${cssFormat}". Expected "theme" or "root".`)
101
94
  }
95
+ const { initDesignSurface } = await loadModule('cli/init.mjs')
102
96
  const { results, viteSnippet, agentGuideSnippet } = await initDesignSurface({
103
97
  root,
104
98
  cssFormat,
@@ -121,6 +115,7 @@ if (command === 'tokens') {
121
115
  const sub = arg
122
116
  if (sub === 'build' || sub === 'check') {
123
117
  try {
118
+ const { runTokenPipeline } = await loadModule('tokens/pipeline.mjs')
124
119
  const check = sub === 'check'
125
120
  const { counts, warnings, contrast, unsupported } = await runTokenPipeline({ root, check })
126
121
  console.log(
@@ -145,6 +140,7 @@ if (command === 'tokens') {
145
140
  const dryRun = rest.includes('--dry-run')
146
141
  const files = rest.filter((item) => item !== '--dry-run')
147
142
  try {
143
+ const { extractTokensFromCss } = await loadModule('tokens/extract.mjs')
148
144
  const result = await extractTokensFromCss({ root, files, dryRun })
149
145
  console.log(
150
146
  `${dryRun ? '[dry-run] ' : ''}Scanned ${result.scannedFiles.length} CSS file(s): ${result.addedPrimitives.length} primitive, ${result.addedSemantics.length} semantic, ${result.skippedExisting.length} existing skipped`,
@@ -177,6 +173,7 @@ if (command === 'propose') {
177
173
  fail(`unknown propose target: ${arg ?? '(missing)'} (expected "token")`)
178
174
  }
179
175
  try {
176
+ const { proposeToken } = await loadModule('cli/propose.mjs')
180
177
  const { item, reviewPath } = proposeToken({ root, argv: process.argv.slice(4) })
181
178
  const rel = path.relative(root, reviewPath).split(path.sep).join('/')
182
179
  console.log(
@@ -190,6 +187,7 @@ if (command === 'propose') {
190
187
 
191
188
  if (command === 'reply') {
192
189
  try {
190
+ const { replyReviewItem } = await loadModule('cli/reviewOps.mjs')
193
191
  const { item } = replyReviewItem({ root, argv: process.argv.slice(3) })
194
192
  console.log(`Replied to ${item.id} (${item.status})`)
195
193
  process.exit(0)
@@ -200,6 +198,7 @@ if (command === 'reply') {
200
198
 
201
199
  if (command === 'status') {
202
200
  try {
201
+ const { updateReviewItemStatus } = await loadModule('cli/reviewOps.mjs')
203
202
  const { item } = updateReviewItemStatus({ root, argv: process.argv.slice(3) })
204
203
  console.log(`Updated ${item.id} -> ${item.status}`)
205
204
  process.exit(0)
@@ -209,6 +208,7 @@ if (command === 'status') {
209
208
  }
210
209
 
211
210
  if (command === 'list') {
211
+ const { isUnreviewedProposal } = await loadModule('shared/prompt.mjs')
212
212
  const files = reviewFiles()
213
213
  if (!files.length) {
214
214
  console.log('No review ledgers.')
@@ -249,6 +249,9 @@ if (command === 'clear') {
249
249
  }
250
250
 
251
251
  if (command === 'prompt') {
252
+ const { buildAgentPrompt, isCopyableReviewItem, isUnreviewedProposal } = await loadModule(
253
+ 'shared/prompt.mjs',
254
+ )
252
255
  if (!arg) fail('prompt requires a design id')
253
256
  const file = path.join(designRoot, arg, 'review.json')
254
257
  const review = readJson(file)
@@ -1,4 +1,4 @@
1
- import { parseSync } from 'oxc-parser'
1
+ import { parse } from '@babel/parser'
2
2
 
3
3
  import { createLineIndex } from './types.mjs'
4
4
 
@@ -7,12 +7,31 @@ export function parseSourceAst(file, content, ctx) {
7
7
  const existing = cache?.get(file)
8
8
  if (existing && existing.content === content) return existing
9
9
 
10
- const result = parseSync(file, content)
10
+ const isTs = /\.(?:tsx?|mts|cts)$/i.test(file)
11
+ const isJsx = /\.(?:tsx|jsx|js|mjs|cjs)$/i.test(file)
12
+ const plugins = ['estree', 'decorators-legacy']
13
+ if (isTs) plugins.push('typescript')
14
+ if (isJsx) plugins.push('jsx')
15
+
16
+ let program = { type: 'Program', body: [] }
17
+ let errors = []
18
+ try {
19
+ const ast = parse(content, {
20
+ sourceType: 'unambiguous',
21
+ errorRecovery: true,
22
+ plugins,
23
+ })
24
+ program = ast.program
25
+ errors = ast.errors ?? []
26
+ } catch (error) {
27
+ errors = [error]
28
+ }
29
+
11
30
  const locationAt = createLineIndex(content)
12
31
  const entry = {
13
32
  content,
14
- program: result.program,
15
- errors: result.errors ?? [],
33
+ program,
34
+ errors,
16
35
  locationAt,
17
36
  }
18
37
  cache?.set(file, entry)
@@ -30,7 +49,9 @@ export function walkAst(node, visitor, parent = null) {
30
49
  if (stop === false) return
31
50
  }
32
51
  for (const [key, value] of Object.entries(node)) {
33
- if (key === 'type' || key === 'start' || key === 'end' || key === 'loc') continue
52
+ if (key === 'type' || key === 'start' || key === 'end' || key === 'loc' || key === 'extra' || key === 'comments') {
53
+ continue
54
+ }
34
55
  if (value && typeof value === 'object') {
35
56
  walkAst(value, visitor, node)
36
57
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rien7/design-surface",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "A TSX-native design surface: preview real components, tune tokens, and hand structured changes to a coding agent.",
6
6
  "license": "MIT",
@@ -77,10 +77,10 @@
77
77
  "vite": "^8.0.0"
78
78
  },
79
79
  "dependencies": {
80
+ "@babel/parser": "^8.1.3",
80
81
  "@base-ui/react": "^1.9.0",
81
82
  "@hugeicons/core-free-icons": "^4.4.0",
82
83
  "@hugeicons/react": "^1.1.10",
83
- "oxc-parser": "^0.160.0",
84
84
  "postcss": "^8.5.33",
85
85
  "postcss-value-parser": "^4.2.0",
86
86
  "tinyglobby": "^0.2.17"
@@ -139,6 +139,15 @@ type PageBoardProps = {
139
139
 
140
140
  The board renders `renderFrame(frame)` for each state. The system renders the frame chrome, iframe, loading/error states, selection and comments.
141
141
 
142
+ ## Exploring directions (side-by-side comparison)
143
+
144
+ When requirements or visual direction are still open, **show 2–3 concrete directions side by side on one `PageBoard`** instead of describing alternatives in prose:
145
+
146
+ - Put each direction in its own frame on the same page (`direction-a`, `direction-b`, `direction-c`) with identical viewport sizes so visual density, hierarchy, and token usage are directly comparable.
147
+ - Use editor-level `PageBoard` annotations (short title + 1–2 line trade-off caption above or below each `renderFrame(frame)`) to explain what each option optimizes for — annotations stay outside the iframes so they never pollute inspection or comments.
148
+ - Build every direction from real `src/` components and declared tokens (or `propose token` with fallback if a direction introduces a new semantic role).
149
+ - Once the human picks a direction (via comment or chat), keep the winning implementation in `src/`, remove the discarded direction frames, and expand the remaining page into concrete interaction states (`default`, `loading`, `empty`, `error`).
150
+
142
151
  ## Free layout (`FreeCanvas` & `FreeItem`)
143
152
 
144
153
  Use `FreeCanvas` and `FreeItem` from `@rien7/design-surface/runtime` when a frame has free-positioned elements that can be Alt-dragged or adjusted numerically in the Inspector: