create-visualbuild-app 0.1.0 → 1.0.1

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.
Files changed (44) hide show
  1. package/README.md +919 -58
  2. package/docs/user-guide.md +759 -0
  3. package/package.json +92 -85
  4. package/scripts/create-builder-app.mjs +513 -501
  5. package/scripts/vb-dev.mjs +41 -32
  6. package/scripts/vb-generate.mjs +332 -224
  7. package/templates/default/app/.vercelignore +6 -0
  8. package/templates/default/app/README.md +56 -21
  9. package/templates/default/app/visualbuild/components.json +3 -0
  10. package/templates/default/app/visualbuild/config.d.ts +48 -0
  11. package/templates/default/app/visualbuild.config.ts +38 -0
  12. package/templates/default/builder/README.md +37 -21
  13. package/visual-app-builder/server/parseReactPage.ts +776 -571
  14. package/visual-app-builder/shared/createReactComponentSource.d.mts +2 -0
  15. package/visual-app-builder/shared/createReactComponentSource.mjs +45 -0
  16. package/visual-app-builder/shared/generateReactSource.d.mts +57 -37
  17. package/visual-app-builder/shared/generateReactSource.mjs +608 -443
  18. package/visual-app-builder/shared/npmBuildCommand.d.mts +17 -0
  19. package/visual-app-builder/shared/npmBuildCommand.mjs +26 -0
  20. package/visual-app-builder/shared/syncCustomComponentSource.d.mts +13 -0
  21. package/visual-app-builder/shared/syncCustomComponentSource.mjs +345 -0
  22. package/visual-app-builder/shared/vercelDeployment.d.mts +31 -0
  23. package/visual-app-builder/shared/vercelDeployment.mjs +266 -0
  24. package/visual-app-builder/shared/visualbuildConfig.d.mts +144 -0
  25. package/visual-app-builder/shared/visualbuildConfig.mjs +578 -0
  26. package/visual-app-builder/src/App.tsx +1090 -874
  27. package/visual-app-builder/src/components/Canvas.tsx +1116 -1059
  28. package/visual-app-builder/src/components/CodePanel.tsx +1147 -812
  29. package/visual-app-builder/src/components/ComponentSidebar.tsx +365 -302
  30. package/visual-app-builder/src/components/DeploymentModal.tsx +295 -0
  31. package/visual-app-builder/src/components/PageSwitcher.tsx +133 -133
  32. package/visual-app-builder/src/components/ProjectExplorer.tsx +1054 -1054
  33. package/visual-app-builder/src/components/PropertiesPanel.tsx +792 -692
  34. package/visual-app-builder/src/components/Topbar.tsx +257 -128
  35. package/visual-app-builder/src/data/componentRegistry.tsx +613 -292
  36. package/visual-app-builder/src/data/tailwindClassCatalog.ts +95 -0
  37. package/visual-app-builder/src/index.css +383 -111
  38. package/visual-app-builder/src/stores/useAppStore.ts +2385 -1265
  39. package/visual-app-builder/src/theme.ts +71 -0
  40. package/visual-app-builder/src/types/index.ts +350 -261
  41. package/visual-app-builder/src/utils/codegen.ts +90 -66
  42. package/visual-app-builder/src/utils/deployment.ts +54 -0
  43. package/visual-app-builder/src/utils/projectPersistence.ts +218 -177
  44. package/visual-app-builder/vite.config.ts +1946 -1479
@@ -0,0 +1,759 @@
1
+ # VisualBuild v1 User Guide
2
+
3
+ VisualBuild is a local visual editor for React and Tailwind applications. It
4
+ lets you build pages with drag and drop while keeping ordinary `.jsx` and
5
+ `.tsx` source files that can be opened in any code editor, committed to Git,
6
+ built with Vite, and deployed without a VisualBuild runtime.
7
+
8
+ This guide covers installation, the generated workspace, visual editing, page
9
+ and component registration, the code workspace, source ownership, supported
10
+ two-way synchronization, configuration, deployment, limits, recovery, and the
11
+ planned direction after v1.
12
+
13
+ ## Contents
14
+
15
+ 1. [Requirements](#requirements)
16
+ 2. [Create a project](#create-a-project)
17
+ 3. [Understand the generated workspace](#understand-the-generated-workspace)
18
+ 4. [Start the app and editor](#start-the-app-and-editor)
19
+ 5. [Understand the interface](#understand-the-interface)
20
+ 6. [Build and edit a page](#build-and-edit-a-page)
21
+ 7. [Create and register pages](#create-and-register-pages)
22
+ 8. [Use built-in elements](#use-built-in-elements)
23
+ 9. [Create and register custom components](#create-and-register-custom-components)
24
+ 10. [Use the code panel and larger editor](#use-the-code-panel-and-larger-editor)
25
+ 11. [Understand source ownership and synchronization](#understand-source-ownership-and-synchronization)
26
+ 12. [Reverse-sync support and limits](#reverse-sync-support-and-limits)
27
+ 13. [Configure VisualBuild](#configure-visualbuild)
28
+ 14. [Use editor themes and responsive previews](#use-editor-themes-and-responsive-previews)
29
+ 15. [Deploy to Vercel](#deploy-to-vercel)
30
+ 16. [Generate and build without the editor](#generate-and-build-without-the-editor)
31
+ 17. [Upcoming versions](#upcoming-versions)
32
+ 18. [Recover from errors and conflicts](#recover-from-errors-and-conflicts)
33
+ 19. [Troubleshooting](#troubleshooting)
34
+
35
+ ## Requirements
36
+
37
+ - Node.js and npm.
38
+ - A terminal. The examples use PowerShell and `npm.cmd` on Windows. On macOS
39
+ or Linux, use `npm` in the same commands.
40
+ - A modern browser.
41
+ - A Vercel account and access token only if you want one-click deployment.
42
+
43
+ The examples use `my-app` as the application folder. Replace it with the name
44
+ you supplied to the create command.
45
+
46
+ ## Create a project
47
+
48
+ Create a named project from the public package:
49
+
50
+ ```powershell
51
+ npm create visualbuild-app@latest my-app
52
+ ```
53
+
54
+ The equivalent `npx` command is:
55
+
56
+ ```powershell
57
+ npx create-visualbuild-app@latest my-app
58
+ ```
59
+
60
+ If you omit the name, VisualBuild creates `my-app`:
61
+
62
+ ```powershell
63
+ npm create visualbuild-app@latest
64
+ ```
65
+
66
+ Maintainers testing an unpublished local checkout can run this from an empty
67
+ folder:
68
+
69
+ ```powershell
70
+ npm.cmd --prefix "D:\path\to\builder-app" run create-visualbuild-app -- my-app
71
+ ```
72
+
73
+ The command creates two sibling projects. It does not install dependencies.
74
+
75
+ ## Understand the generated workspace
76
+
77
+ ```text
78
+ workspace/
79
+ my-app/ deployable React application
80
+ src/ application source
81
+ visualbuild/ schema, registry, and ownership metadata
82
+ pages.json visual page schema
83
+ components.json registered custom components and prop metadata
84
+ generated-files.json files managed by the generator
85
+ visualbuild.config.ts typed project configuration
86
+ package.json application dependencies only
87
+ visual-builder/ optional local editor and generator
88
+ visual-app-builder/ VisualBuild interface and local API
89
+ scripts/ editor and generation commands
90
+ package.json editor-only dependencies
91
+ my-app-README.md workspace-specific quick start
92
+ VISUALBUILD-GUIDE.md a copy of this complete guide
93
+ ```
94
+
95
+ The separation is a production boundary, not only an organizational choice:
96
+
97
+ | Location | Owner and purpose | Deploy it? |
98
+ | --- | --- | --- |
99
+ | `my-app/src` | Real React application source | Yes |
100
+ | `my-app/visualbuild` | VisualBuild schema, registry, and generation metadata | No runtime requirement |
101
+ | `my-app/visualbuild.config.ts` | Local editor/generator configuration | No runtime requirement |
102
+ | `visual-builder` | Visual editor, watcher, generator, and editor-only dependencies | No |
103
+
104
+ The app does not install drag-and-drop, editor state, or generator packages.
105
+ It remains runnable after the sibling `visual-builder` directory is removed.
106
+
107
+ ## Start the app and editor
108
+
109
+ Open the first terminal in the workspace root, then install and run the
110
+ application:
111
+
112
+ ```powershell
113
+ cd my-app
114
+ npm.cmd install
115
+ npm.cmd run dev
116
+ ```
117
+
118
+ Open a separate second terminal in the workspace root, then install and run
119
+ the visual editor:
120
+
121
+ ```powershell
122
+ cd visual-builder
123
+ npm.cmd install
124
+ npm.cmd run visual-builder
125
+ ```
126
+
127
+ If the second terminal opens inside `my-app` instead of the workspace root,
128
+ use this path to reach the sibling editor:
129
+
130
+ ```powershell
131
+ cd ..\visual-builder
132
+ ```
133
+
134
+ Do not run both development processes sequentially in one occupied terminal.
135
+ Use two terminals so the app and VisualBuild can remain running together. If
136
+ you stop the app and reuse its terminal, then `cd ..\visual-builder` is the
137
+ correct command because that terminal is still inside `my-app`.
138
+
139
+ The app normally uses Vite's development URL. VisualBuild opens at:
140
+
141
+ ```text
142
+ http://127.0.0.1:7371
143
+ ```
144
+
145
+ Keep the builder terminal open while editing. It runs the file watcher,
146
+ generation API, reverse-sync importer, and optional deployment service.
147
+
148
+ ## Understand the interface
149
+
150
+ ### Top bar
151
+
152
+ - **Preview** hides editor panels and displays the active page as the user
153
+ will see it.
154
+ - **Code** opens or closes the right Code panel.
155
+ - The palette button changes the editor theme only.
156
+ - **Save** writes the visual schema and regenerates managed source.
157
+ - **Deploy** builds the developer-owned app and publishes its static output to
158
+ Vercel.
159
+
160
+ ### Left panel
161
+
162
+ - **Files** is the project explorer. Create, select, rename, move, and delete
163
+ files or folders here.
164
+ - **Elements** contains global elements, registered custom components,
165
+ reusable page blocks, and HTML primitives grouped by category.
166
+ - Collapse the panel with its arrow when more canvas space is needed.
167
+
168
+ ### Canvas and page bar
169
+
170
+ - Drag elements from the Elements panel onto insertion zones.
171
+ - Click an element to add it to the selected container. If no valid container
172
+ is selected, drag it to the desired insertion zone.
173
+ - Select a canvas node to show its controls and Properties.
174
+ - Drag selected nodes to reorder or nest them in compatible containers.
175
+ - Use **Mobile**, **Tablet**, and **Desktop** above the canvas to test the
176
+ configured responsive widths.
177
+ - Use the page bar along the bottom to switch pages, add a page, or delete a
178
+ page when more than one exists.
179
+
180
+ ### Right panel
181
+
182
+ - **Properties** edits the selected node's text, ID, component fields,
183
+ Tailwind classes, arrays, booleans, select values, and supported additional
184
+ attributes.
185
+ - Selecting the page root exposes **Page root tag**, allowing `div`, `main`,
186
+ `section`, `article`, `header`, `footer`, `nav`, `aside`, or `form`.
187
+ - Registered custom components expose their managed component root tag, ID,
188
+ Tailwind classes, additional attributes, and configured prop fields.
189
+ - **Code** shows generated views and the editable source file associated with
190
+ the current selection.
191
+ - Collapse the panel with its arrow when more canvas space is needed.
192
+
193
+ ## Build and edit a page
194
+
195
+ 1. Open **Elements**.
196
+ 2. Drag a reusable page block, such as Hero, Grid, or Pricing, onto the canvas.
197
+ 3. Select the block or one of its nested elements.
198
+ 4. Open **Properties** and edit its text, values, ID, or Tailwind classes.
199
+ 5. Drag primitives such as `h2`, `p`, `button`, `section`, or `div` into a
200
+ compatible insertion zone.
201
+ 6. Reorder a node with its drag handle or move it upward with the canvas
202
+ control.
203
+ 7. Select the page root to change its semantic root tag and root classes.
204
+ 8. Switch between Mobile, Tablet, and Desktop.
205
+ 9. Click **Preview** to inspect the page without editor chrome.
206
+ 10. Click **Save** to persist the schema and generated React source.
207
+
208
+ Tailwind changes are stored as ordinary `className` strings. The class editor
209
+ offers suggestions as you type; variants such as `sm:`, `hover:`, and `focus:`
210
+ remain part of the generated source. Editor themes never modify these classes.
211
+
212
+ ## Create and register pages
213
+
214
+ VisualBuild supports two page workflows.
215
+
216
+ ### Create a managed page from the page bar
217
+
218
+ 1. Click **+ Add page** at the bottom of the editor.
219
+ 2. Enter a unique page name.
220
+ 3. Enter a unique route such as `/about`.
221
+ 4. Click **Add**.
222
+
223
+ VisualBuild creates a page schema entry and a generated file under the
224
+ configured `pagesDir`, normally `src/pages`. The new page becomes active and
225
+ is managed from the canvas.
226
+
227
+ ### Register an existing React file as a page
228
+
229
+ 1. Create or select a `.jsx` or `.tsx` file inside the configured `sourceDir`.
230
+ 2. Ensure it exports a React component whose returned JSX follows the
231
+ [supported static contract](#reverse-sync-support-and-limits).
232
+ 3. Select the file in **Files**. The Code panel switches to **File**.
233
+ 4. Click **Register**.
234
+ 5. Choose **Page** in **Register as**.
235
+ 6. Enter the page name and route.
236
+ 7. Click **Register page**.
237
+
238
+ VisualBuild parses the returned static JSX into the page registry, adds the
239
+ page to `visualbuild/pages.json`, and treats the source as a managed page from
240
+ that point onward. Duplicate names and routes are rejected.
241
+
242
+ ### Page files in the project explorer
243
+
244
+ - Renaming or moving a managed page file through VisualBuild updates its
245
+ `sourcePath`, imports, schema, and selected File view together.
246
+ - External moves are detected and reconciled when VisualBuild can identify
247
+ the matching file.
248
+ - Deleting a managed page file unregisters that page. VisualBuild restores the
249
+ file if it is the only registered page, because a project must retain at
250
+ least one page.
251
+
252
+ ## Use built-in elements
253
+
254
+ The Elements panel contains three main levels:
255
+
256
+ - **Global**: Navbar and Footer. These belong to the shared app layout and
257
+ appear across pages.
258
+ - **Page Blocks**: Hero, Card, Button, Grid, Testimonials, Pricing, Form,
259
+ Image, Features, Gallery, FAQ, Contact Form, and Login Form.
260
+ - **Primitives**: semantic, layout, text, media, form, table, and interactive
261
+ HTML elements used for detailed composition.
262
+
263
+ Every built-in page block expands to an editable primitive tree. You can
264
+ select nested elements, change their properties, add compatible children,
265
+ reorder them, preview them, and generate normal React source.
266
+
267
+ ## Create and register custom components
268
+
269
+ ### Create the source file
270
+
271
+ Create a `.jsx` or `.tsx` file inside the app's `src` directory. Files created
272
+ from VisualBuild receive filename-derived component boilerplate automatically.
273
+ For example, `src/components/First.tsx` starts as a valid default-exported
274
+ component.
275
+
276
+ A component can contain authored static JSX and an optional `children` slot:
277
+
278
+ ```tsx
279
+ import type { ReactNode } from 'react'
280
+
281
+ export default function First({ children }: { children?: ReactNode }) {
282
+ return (
283
+ <section className="w-full rounded-lg p-6">
284
+ <h2 className="text-2xl font-bold">First component</h2>
285
+ {children}
286
+ </section>
287
+ )
288
+ }
289
+ ```
290
+
291
+ ### Register the component
292
+
293
+ 1. Select the file in **Files**.
294
+ 2. Click **Register** in the Code panel.
295
+ 3. Choose **Component** in **Register as**.
296
+ 4. Confirm the detected export.
297
+ 5. Click **Register component**.
298
+
299
+ VisualBuild records the registration in `visualbuild/components.json`. The
300
+ component appears immediately under **Elements > Custom**. Default and named
301
+ exports are supported when they can be detected from the source.
302
+
303
+ Do not add registrations to `visualbuild.config.ts`. The project registry file
304
+ is the single registration source used by the editor.
305
+
306
+ ### Edit and use the registered component
307
+
308
+ - Drag or click the component from **Elements > Custom** to add it to a page.
309
+ - Select the component to edit its root tag, ID, Tailwind classes, additional
310
+ JSON attributes, and registered prop schema.
311
+ - Static JSX authored in the component file appears on the canvas and is
312
+ selectable.
313
+ - Elements dragged into the custom component become part of the reusable
314
+ component definition and are written into its source on Save.
315
+ - Selecting the component or one of its definition-owned children opens the
316
+ component source in the File tab.
317
+
318
+ VisualBuild treats these canvas edits as definition edits. If the component is
319
+ used on multiple pages, the updated definition applies everywhere. Generated
320
+ pages import the local source directly and render a self-closing reference such
321
+ as `<First />`; they do not copy the component's internal JSX into every page.
322
+
323
+ Registration supplies root tag, ID, Tailwind class, and additional-attribute
324
+ fields. Advanced prop metadata lives in that component's `props` object in
325
+ `visualbuild/components.json`. Supported field types are `string`, `text`,
326
+ `number`, `boolean`, `color`, `select`, `array`, and `attributes`. A custom
327
+ field affects runtime output only when the React component accepts and uses
328
+ the corresponding prop.
329
+
330
+ ## Use the code panel and larger editor
331
+
332
+ The Code panel has several views:
333
+
334
+ | View | Purpose | Editable here? |
335
+ | --- | --- | --- |
336
+ | **Page** | Generated source preview for the active page | No |
337
+ | **App** | Generated application entry/router preview | No |
338
+ | **Layout** | Generated shared Navbar/Footer layout preview | No |
339
+ | **JSON** | Current visual schema preview | No |
340
+ | **File** | Exact selected project file | Yes |
341
+
342
+ Generated views are useful for understanding and copying output. Use **File**
343
+ when you want to change actual source.
344
+
345
+ Selection follows source ownership:
346
+
347
+ - Selecting a normal page node opens the active managed page file.
348
+ - Selecting a registered custom component or its internal node opens that
349
+ custom component file.
350
+ - Selecting a file from **Files** opens that exact file.
351
+
352
+ The File tab shows `*` when it has unsaved text. Use **Save file** or
353
+ `Ctrl+S`. The top-bar **Save** is different: it saves canvas/schema state and
354
+ regenerates managed files.
355
+
356
+ Click **Open editor** for the full-screen code workspace. It contains a larger
357
+ editable File view and a live project explorer, which is more practical for
358
+ long components and page files. Close it with the `x` button to return to the
359
+ canvas without losing unsaved File text.
360
+
361
+ Text files up to 2 MB are editable. Binary files, symbolic links, files outside
362
+ the app root, and oversized files are protected from browser editing.
363
+
364
+ ## Understand source ownership and synchronization
365
+
366
+ VisualBuild is bidirectional only across documented, safe boundaries.
367
+
368
+ | Change | Result |
369
+ | --- | --- |
370
+ | Canvas/Properties change, then top-bar **Save** | Writes `pages.json`, regenerates managed pages/App/layout, and synchronizes definition-owned custom component JSX |
371
+ | Managed page source changes in File, VS Code, or another editor | Static returned JSX is parsed into the schema and canvas |
372
+ | Registered custom component source changes | Its static preview, root defaults, and definition tree refresh on the canvas |
373
+ | Generic project file changes | The project explorer and File view refresh; the file is not converted into canvas nodes |
374
+ | Managed page file is renamed or moved | Schema `sourcePath` and generated imports are updated |
375
+ | Managed page file is deleted | The page is unregistered, except the only remaining page is restored |
376
+
377
+ ### Ownership rules
378
+
379
+ - `visualbuild/pages.json` is the safe visual schema boundary.
380
+ - Files listed in `visualbuild/generated-files.json` are generator-managed.
381
+ - Managed page files can be edited visually or through the supported static
382
+ source importer. A later canvas Save can regenerate them.
383
+ - Registered custom component files remain local React source, but canvas
384
+ edits to their managed root and definition tree intentionally update those
385
+ files.
386
+ - Unregistered components and ordinary project files are developer-owned and
387
+ are never rewritten merely because they exist under `src`.
388
+ - Set `generator.emitApp` or `generator.emitLayout` to `false` when you want to
389
+ retain developer ownership of those outputs.
390
+
391
+ Commit application source, `visualbuild.config.ts`, and the `visualbuild`
392
+ metadata to Git so schema and source changes can be reviewed and recovered.
393
+
394
+ ## Reverse-sync support and limits
395
+
396
+ Reverse sync is intentionally a static JSX importer, not a JavaScript runtime
397
+ or a full React compiler.
398
+
399
+ ### Supported
400
+
401
+ - `.jsx` and `.tsx` managed page files inside the configured source directory.
402
+ - Function and arrow components with a discoverable returned JSX element or
403
+ fragment.
404
+ - Standard supported HTML tags and registered PascalCase custom components.
405
+ - Recursive static element trees and fragments.
406
+ - Static text.
407
+ - Boolean attributes and static string, number, boolean, `null`, negative
408
+ number, and expression-free template literal values.
409
+ - `className`, ID, supported component props, and supported plain attributes.
410
+ - The special `{children}` slot used by registered custom component previews.
411
+
412
+ ### Not supported for source-to-canvas import
413
+
414
+ - Unknown or unregistered custom component tags.
415
+ - Member-expression or namespaced tags such as `<UI.Card>`.
416
+ - Spread attributes such as `<div {...props}>`.
417
+ - Runtime JSX expressions such as `{items.map(...)}`, `{condition && ...}`,
418
+ ternaries, function calls, state-dependent values, or fetched data.
419
+ - Arbitrary hook behavior, event-handler logic, render props, portals, or
420
+ runtime component factories as visual nodes.
421
+ - Dynamically computed attribute values.
422
+
423
+ Unsupported source is not partially imported. VisualBuild displays **Reverse
424
+ sync paused**, keeps the last valid schema, and leaves the edited source file
425
+ untouched. This prevents a best-effort import from silently deleting code.
426
+
427
+ You can still keep complex React in developer-owned files. Register only the
428
+ static components that should participate in the visual canvas, or disable a
429
+ generated output and own it entirely in code.
430
+
431
+ ## Configure VisualBuild
432
+
433
+ Each app contains a typed `visualbuild.config.ts`. Every field is optional.
434
+ Restart the builder after changing paths because its file watchers are created
435
+ at startup.
436
+
437
+ ```ts
438
+ import type { VisualBuildConfig } from './visualbuild/config'
439
+
440
+ export default {
441
+ paths: {
442
+ sourceDir: 'src',
443
+ pagesDir: 'src/pages',
444
+ layoutsDir: 'src/layouts',
445
+ appFile: 'src/App.tsx',
446
+ schemaFile: 'visualbuild/pages.json',
447
+ componentRegistryFile: 'visualbuild/components.json',
448
+ generatedManifestFile: 'visualbuild/generated-files.json',
449
+ },
450
+ editor: {
451
+ theme: 'default',
452
+ defaultViewport: 'desktop',
453
+ responsiveWidths: {
454
+ mobile: 390,
455
+ tablet: 768,
456
+ desktop: 'fluid',
457
+ },
458
+ panels: {
459
+ leftOpen: true,
460
+ leftTab: 'elements',
461
+ rightOpen: true,
462
+ rightTab: 'properties',
463
+ codeView: 'page',
464
+ },
465
+ },
466
+ generator: {
467
+ emitApp: true,
468
+ emitLayout: true,
469
+ cleanStaleFiles: true,
470
+ },
471
+ deployment: {
472
+ provider: 'vercel',
473
+ outputDirectory: 'dist',
474
+ projectName: 'my-app',
475
+ // teamId: 'team_abc123',
476
+ },
477
+ } satisfies VisualBuildConfig
478
+ ```
479
+
480
+ ### Configuration reference
481
+
482
+ - `paths.sourceDir`: application source boundary.
483
+ - `paths.pagesDir`: default generated page directory.
484
+ - `paths.layoutsDir`: generated shared layout directory.
485
+ - `paths.appFile`: generated app/router path.
486
+ - `paths.schemaFile`: page schema path.
487
+ - `paths.componentRegistryFile`: custom component registry path.
488
+ - `paths.generatedManifestFile`: generated-file ownership manifest.
489
+ - `editor.theme`: `default`, `codex-dark`, `vs-light`, `vs-dark`, or `system`.
490
+ - `editor.defaultViewport`: `mobile`, `tablet`, or `desktop`.
491
+ - `editor.responsiveWidths`: widths from 240 through 4096; desktop may be
492
+ `fluid`.
493
+ - `editor.panels`: initial open tabs and initial Code view.
494
+ - `generator.emitApp`: whether VisualBuild owns and emits the App file.
495
+ - `generator.emitLayout`: whether VisualBuild owns and emits the shared layout.
496
+ - `generator.cleanStaleFiles`: whether obsolete managed files are removed.
497
+ - `deployment.outputDirectory`: application build output to upload.
498
+ - `deployment.projectName`: stable lowercase Vercel project name.
499
+ - `deployment.teamId`: optional Vercel team identifier beginning with `team_`.
500
+
501
+ Paths must stay inside the app. Page, layout, and App paths must remain inside
502
+ `sourceDir`. Invalid values stop builder startup with a focused configuration
503
+ error instead of falling back silently.
504
+
505
+ ## Use editor themes and responsive previews
506
+
507
+ The palette menu offers:
508
+
509
+ - VisualBuild Default
510
+ - Codex Dark
511
+ - VS Code Light
512
+ - VS Code Dark
513
+ - System
514
+
515
+ The selected theme is stored per project and restored after refresh. The
516
+ configuration theme is the initial fallback until the user selects one.
517
+ Editor theme variables are scoped to editor chrome; they never recolor the
518
+ canvas, generated source, preview, or deployed application.
519
+
520
+ Mobile, Tablet, and Desktop use `editor.responsiveWidths`. They change the
521
+ canvas viewport, not the application's generated Tailwind classes.
522
+
523
+ ## Deploy to Vercel
524
+
525
+ VisualBuild performs a production deployment of the developer-owned app. It
526
+ saves and generates source, runs `npm run build` locally, creates a digest
527
+ manifest from the configured static output directory, uploads those files,
528
+ creates a production Vercel deployment, and waits until Vercel reports
529
+ `READY`.
530
+
531
+ ### Configure credentials
532
+
533
+ Create a Vercel access token. Set it only in the terminal that starts the
534
+ builder:
535
+
536
+ ```powershell
537
+ cd visual-builder
538
+ $env:VERCEL_TOKEN = 'your-token'
539
+ npm.cmd run visual-builder
540
+ ```
541
+
542
+ For a team-owned project, optionally set:
543
+
544
+ ```powershell
545
+ $env:VERCEL_TEAM_ID = 'team_abc123'
546
+ ```
547
+
548
+ You can also enter the Team ID in the deployment dialog. The access token is
549
+ never accepted in project configuration, browser storage, or the dialog.
550
+
551
+ On macOS or Linux:
552
+
553
+ ```bash
554
+ cd visual-builder
555
+ VERCEL_TOKEN='your-token' npm run visual-builder
556
+ ```
557
+
558
+ ### Deploy
559
+
560
+ 1. Open VisualBuild.
561
+ 2. Click **Deploy**.
562
+ 3. Review the lowercase Vercel project name.
563
+ 4. Leave Team ID blank for a personal account, or provide the owning team ID.
564
+ 5. Click **Deploy production**.
565
+ 6. Wait for `READY` and open the returned production URL.
566
+
567
+ Only the configured static output, normally `dist`, is uploaded. VisualBuild
568
+ rejects builder, metadata, config, dependency, Git, symlink, and other
569
+ builder-only paths at the deployment boundary. A virtual SPA fallback is added
570
+ to the deployment without modifying application source.
571
+
572
+ The following never enter the production upload:
573
+
574
+ - `visual-builder`
575
+ - `visual-app-builder`
576
+ - `visualbuild`
577
+ - `visualbuild.config.*`
578
+ - `node_modules`
579
+ - `.git`
580
+ - `.vercel`
581
+ - the Vercel access token
582
+
583
+ ## Generate and build without the editor
584
+
585
+ Generate managed source from the schema without opening the browser:
586
+
587
+ ```powershell
588
+ cd visual-builder
589
+ npm.cmd run vb:generate
590
+ ```
591
+
592
+ Build the deployable application independently:
593
+
594
+ ```powershell
595
+ cd ..\my-app
596
+ npm.cmd run build
597
+ ```
598
+
599
+ This independence is the quickest way to verify the production boundary: the
600
+ app build must succeed using only the app package and its dependencies.
601
+
602
+ ## Upcoming versions
603
+
604
+ The features in this section are planned roadmap items, not capabilities in
605
+ the current v1 release. Their final scope and release order may change as the
606
+ implementation is validated.
607
+
608
+ ### v1.1: application package installation interface
609
+
610
+ VisualBuild will add an editor interface for finding, installing, updating,
611
+ and removing npm packages used by the developer-owned application. Package
612
+ operations will target the application workspace and its `package.json`; they
613
+ will not add editor-only packages to the production application.
614
+
615
+ This is different from installing the `create-visualbuild-app` CLI itself and
616
+ from publishing VisualBuild to npm. It is package management for the React
617
+ application being built. This interface is a new addition to the current
618
+ roadmap; the locked PRD's original v1.1 item was Vercel deployment, which is
619
+ already available in the current v1 implementation.
620
+
621
+ ### v2: generated-application state management setup
622
+
623
+ VisualBuild will offer setup flows for application state management with
624
+ Zustand and Redux. The generated stores, providers, hooks, and configuration
625
+ will belong to the developer's application and remain usable without a
626
+ VisualBuild runtime.
627
+
628
+ VisualBuild already uses Zustand internally for editor state. That internal
629
+ implementation is separate from the planned v2 feature, which configures
630
+ state management in the generated application. Redux support and this
631
+ generated-application setup flow are additions to the current roadmap rather
632
+ than features specified by the locked PRD.
633
+
634
+ ### v2: AI help
635
+
636
+ VisualBuild will introduce contextual AI help for building and understanding
637
+ the project. The v2 scope is assistance inside the existing visual-and-code
638
+ workflow, such as explaining errors, suggesting edits, and helping configure
639
+ components. AI changes must remain reviewable and must produce ordinary
640
+ developer-owned project files.
641
+
642
+ The PRD also describes a later, broader AI-native phase: natural-language page
643
+ generation, AI-assisted layout generation, and generation through the project
644
+ schema. That full generation workflow remains a later roadmap item rather
645
+ than part of the initial v2 AI-help scope.
646
+
647
+ ### Additional PRD roadmap items
648
+
649
+ The longer-term PRD also identifies these directions:
650
+
651
+ - data and authentication integration, including protected routes;
652
+ - a component marketplace and publishing developer components;
653
+ - team collaboration through shared project state;
654
+ - full natural-language-to-project generation and AI layout suggestions;
655
+ - multi-framework output such as Vue, Svelte, and Solid; and
656
+ - a VisualBuild experience integrated into VS Code.
657
+
658
+ Some PRD milestones have already been delivered earlier than originally
659
+ planned in this repository, including Vercel deployment, local custom component
660
+ registration, drag and drop, editor themes, and limited reverse sync. They are
661
+ documented as current v1 features elsewhere in this guide and are therefore
662
+ not repeated as upcoming work.
663
+
664
+ ## Recover from errors and conflicts
665
+
666
+ ### Reverse sync paused
667
+
668
+ The edited managed source contains unsupported or invalid JSX. The file is not
669
+ overwritten and the last valid schema remains active.
670
+
671
+ 1. Read the notice for the unsupported tag or attribute.
672
+ 2. Fix the file so its returned JSX matches the static contract, or move the
673
+ dynamic behavior to a developer-owned component.
674
+ 3. Save the file again and wait for **Source synced**.
675
+
676
+ ### Source changed while the canvas has unsaved edits
677
+
678
+ VisualBuild does not choose a winner automatically.
679
+
680
+ - Click **Load source changes** to discard unsaved canvas state and import the
681
+ source version.
682
+ - Dismiss the notice to keep working from the canvas state. A later top-bar
683
+ Save regenerates managed source from that canvas/schema state.
684
+
685
+ ### File changed while the File editor has unsaved text
686
+
687
+ VisualBuild preserves the browser text and displays **Reload disk**.
688
+
689
+ - Click **Reload disk** to discard browser edits and load the external file.
690
+ - Keep editing and use **Save file** to make the browser version the file
691
+ version.
692
+
693
+ ### Generation failed during Save
694
+
695
+ Schema writes are transactional. VisualBuild restores the previous
696
+ `pages.json` and regenerates the last valid managed source. Read the diagnostic,
697
+ fix the duplicate route, invalid schema, or reported source issue, and save
698
+ again.
699
+
700
+ ### Rename or move failed
701
+
702
+ Managed file moves update filesystem paths, schema paths, and imports as one
703
+ operation. If persistence or generation fails, VisualBuild rolls the move back.
704
+ Refresh the project tree, resolve the reported conflict, and retry.
705
+
706
+ ### Deployment failed
707
+
708
+ The deployment dialog shows whether failure occurred during local generation,
709
+ the app build, file upload, deployment creation, or Vercel processing. The
710
+ last successful production deployment stays live.
711
+
712
+ Check:
713
+
714
+ 1. The builder was started after `VERCEL_TOKEN` was set.
715
+ 2. App dependencies are installed.
716
+ 3. `npm run build` succeeds in the app directory.
717
+ 4. `deployment.outputDirectory` matches the build output.
718
+ 5. Project name is lowercase and valid.
719
+ 6. Team ID and token belong to the same Vercel scope.
720
+
721
+ ## Troubleshooting
722
+
723
+ ### Deploy is disabled
724
+
725
+ Stop the builder, set `VERCEL_TOKEN` in that same terminal, and restart it.
726
+
727
+ ### A newly created test app does not contain recent local changes
728
+
729
+ Scaffolds copy the current editor into `visual-builder`. An existing scaffold
730
+ does not update when the framework repository changes. Create a fresh scaffold
731
+ when validating unpublished framework changes.
732
+
733
+ ### A custom component is not in Elements
734
+
735
+ - Confirm the file is `.jsx` or `.tsx` under `sourceDir`.
736
+ - Confirm it has a detectable default or named React component export.
737
+ - Select the file and use **Register > Component**.
738
+ - Check `visualbuild/components.json` for the saved registration.
739
+
740
+ ### A custom component's source content is not visible on the canvas
741
+
742
+ Keep the returned JSX static and supported. Runtime expressions are not
743
+ rendered as visual nodes. An optional `{children}` position is recognized as
744
+ the drop location for definition-owned children.
745
+
746
+ ### Page source does not update the canvas
747
+
748
+ Confirm the file is registered as a page, then check the reverse-sync notice.
749
+ Unregistered generic files refresh in the File editor but are not imported
750
+ into the page schema.
751
+
752
+ ### File edits and canvas edits appear to disagree
753
+
754
+ Check which Save action you used:
755
+
756
+ - **Save file** writes the File editor buffer.
757
+ - Top-bar **Save** writes canvas/schema state and regenerates managed files.
758
+
759
+ Use the conflict notice to choose which side should become authoritative.