create-visualbuild-app 0.1.0 → 1.0.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.
Files changed (44) hide show
  1. package/README.md +306 -123
  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
package/README.md CHANGED
@@ -1,123 +1,306 @@
1
- # VisualBuild
2
-
3
- VisualBuild is a visual development framework for building React applications
4
- with drag and drop while retaining normal, editable source code.
5
-
6
- The visual editor writes the project schema, the generator writes real React
7
- files, and supported static JSX/TSX edits can sync back into the canvas.
8
-
9
- ## Public CLI
10
-
11
- The canonical npm package is `create-visualbuild-app`.
12
-
13
- After the first public release, create a named project with either command:
14
-
15
- ```bash
16
- npm create visualbuild-app@latest my-blog
17
- ```
18
-
19
- ```bash
20
- npx create-visualbuild-app@latest my-blog
21
- ```
22
-
23
- Omitting the name creates `my-app`:
24
-
25
- ```bash
26
- npm create visualbuild-app@latest
27
- ```
28
-
29
- The public package has not been published yet. Maintainers can exercise the
30
- same CLI from this repository:
31
-
32
- ```powershell
33
- npm.cmd run create-visualbuild-app -- my-blog
34
- ```
35
-
36
- The previous local script remains available as a compatibility alias:
37
-
38
- ```powershell
39
- npm.cmd run create-builder-app -- my-blog
40
- ```
41
-
42
- ## Scaffold Output
43
-
44
- VisualBuild deliberately separates the deployable application from the editor:
45
-
46
- ```text
47
- workspace/
48
- my-blog/ # developer-owned React application
49
- visual-builder/ # visual editor, generator, and file watcher
50
- my-blog-README.md # generated setup instructions
51
- ```
52
-
53
- The React app does not install editor-only packages such as dnd-kit or Zustand.
54
- It can be built, deployed, or retained after deleting `visual-builder/`.
55
-
56
- ## Run A Generated Project
57
-
58
- Install and start the React application:
59
-
60
- ```powershell
61
- cd my-blog
62
- npm install
63
- npm.cmd run dev
64
- ```
65
-
66
- In another terminal, install and start the visual editor:
67
-
68
- ```powershell
69
- cd visual-builder
70
- npm install
71
- npm.cmd run visual-builder
72
- ```
73
-
74
- Changes saved in the editor update `my-blog/visualbuild/pages.json` and the
75
- generated React source. Supported static source edits are watched and reflected
76
- back into the canvas.
77
-
78
- ## Architecture
79
-
80
- ```text
81
- Visual Editor
82
- |
83
- v
84
- visualbuild/pages.json
85
- |
86
- v
87
- Babel AST Generator
88
- |
89
- v
90
- React Project
91
- ```
92
-
93
- `visualbuild/pages.json` remains the safe schema boundary. Reverse sync accepts
94
- documented static JSX/TSX structures; unsupported dynamic React code is left
95
- untouched and produces an editor diagnostic.
96
-
97
- ## Development
98
-
99
- ```powershell
100
- npm install
101
- npm.cmd run visual-builder
102
- ```
103
-
104
- Useful checks:
105
-
106
- ```powershell
107
- npm.cmd run lint
108
- npm.cmd run build
109
- npm.cmd run test:week3
110
- npm.cmd pack --dry-run
111
- ```
112
-
113
- ## Status
114
-
115
- Current version: `0.1.0`
116
-
117
- Week 3 is in progress. The stable published template, CLI identity, and
118
- generator diagnostics are complete. The remaining release work is publishing
119
- to npm and validating clean public-registry scaffolds.
120
-
121
- ## License
122
-
123
- UNLICENSED
1
+ # VisualBuild
2
+
3
+ VisualBuild is a visual development framework for building React applications
4
+ with drag and drop while retaining normal, editable source code.
5
+
6
+ The visual editor writes the project schema, the generator writes real React
7
+ files, and supported static JSX/TSX edits can sync back into the canvas.
8
+
9
+ ## Complete User Guide
10
+
11
+ Read the [VisualBuild v1 User Guide](docs/user-guide.md) for the complete,
12
+ self-contained workflow. It covers installation, folder separation, the
13
+ interface, visual editing, page and component registration, the full-screen
14
+ code workspace, source ownership, supported two-way sync, configuration,
15
+ themes, Vercel deployment, limits, troubleshooting, and error recovery.
16
+
17
+ Every new scaffold also includes this guide as `VISUALBUILD-GUIDE.md` beside
18
+ the generated app and editor folders, so the documentation remains available
19
+ without returning to the framework repository.
20
+
21
+ ## Public CLI
22
+
23
+ The canonical npm package is `create-visualbuild-app`.
24
+
25
+ Create a named project with either command:
26
+
27
+ ```bash
28
+ npm create visualbuild-app@latest my-app
29
+ ```
30
+
31
+ ```bash
32
+ npx create-visualbuild-app@latest my-app
33
+ ```
34
+
35
+ Omitting the name creates `my-app`:
36
+
37
+ ```bash
38
+ npm create visualbuild-app@latest
39
+ ```
40
+
41
+ Version `0.1.0` is published on npm. Maintainers can also exercise the same CLI
42
+ from this repository:
43
+
44
+ ```powershell
45
+ npm.cmd run create-visualbuild-app -- my-app
46
+ ```
47
+
48
+ The previous local script remains available as a compatibility alias:
49
+
50
+ ```powershell
51
+ npm.cmd run create-builder-app -- my-app
52
+ ```
53
+
54
+ ## Scaffold Output
55
+
56
+ VisualBuild deliberately separates the deployable application from the editor:
57
+
58
+ ```text
59
+ workspace/
60
+ my-app/ # developer-owned React application
61
+ visual-builder/ # visual editor, generator, and file watcher
62
+ my-app-README.md # generated setup instructions
63
+ ```
64
+
65
+ The React app does not install editor-only packages such as dnd-kit or Zustand.
66
+ It can be built, deployed, or retained after deleting `visual-builder/`.
67
+
68
+ ## Run A Generated Project
69
+
70
+ Install and start the React application:
71
+
72
+ ```powershell
73
+ cd my-app
74
+ npm install
75
+ npm.cmd run dev
76
+ ```
77
+
78
+ In another terminal, install and start the visual editor:
79
+
80
+ ```powershell
81
+ cd visual-builder
82
+ npm install
83
+ npm.cmd run visual-builder
84
+ ```
85
+
86
+ Changes saved in the editor update `my-app/visualbuild/pages.json` and the
87
+ generated React source. Supported static source edits are watched and reflected
88
+ back into the canvas.
89
+
90
+ ## Configure A Project
91
+
92
+ Each generated app includes a typed `visualbuild.config.ts`. All fields are
93
+ optional; omitted values keep the standard `src`, desktop, dark-editor, and
94
+ generation behavior.
95
+
96
+ ```ts
97
+ import type { VisualBuildConfig } from './visualbuild/config'
98
+
99
+ export default {
100
+ paths: {
101
+ sourceDir: 'src',
102
+ pagesDir: 'src/pages',
103
+ layoutsDir: 'src/layouts',
104
+ appFile: 'src/App.tsx',
105
+ schemaFile: 'visualbuild/pages.json',
106
+ componentRegistryFile: 'visualbuild/components.json',
107
+ generatedManifestFile: 'visualbuild/generated-files.json',
108
+ },
109
+ editor: {
110
+ theme: 'default',
111
+ defaultViewport: 'desktop',
112
+ responsiveWidths: {
113
+ mobile: 390,
114
+ tablet: 768,
115
+ desktop: 'fluid',
116
+ },
117
+ panels: {
118
+ leftOpen: true,
119
+ leftTab: 'elements',
120
+ rightOpen: true,
121
+ rightTab: 'properties',
122
+ codeView: 'page',
123
+ },
124
+ },
125
+ generator: {
126
+ emitApp: true,
127
+ emitLayout: true,
128
+ cleanStaleFiles: true,
129
+ },
130
+ deployment: {
131
+ provider: 'vercel',
132
+ outputDirectory: 'dist',
133
+ },
134
+ } satisfies VisualBuildConfig
135
+ ```
136
+
137
+ Paths are normalized project-relative paths and cannot escape the app folder.
138
+ Page, layout, and App locations must remain inside `sourceDir`. Responsive
139
+ widths accept values from 240 through 4096 pixels; desktop also accepts
140
+ `'fluid'`. Generator switches can retain a developer-owned App or layout and
141
+ can disable stale managed-file cleanup. Restart the visual-builder process
142
+ after changing project paths so its file watchers use the new locations.
143
+
144
+ ## Deploy To Vercel
145
+
146
+ VisualBuild can publish the developer-owned app directly from the editor. The
147
+ deployment pipeline saves and regenerates source, runs the app's production
148
+ build locally, and uploads only the configured static output directory. It
149
+ never uploads `visual-builder`, `visual-app-builder`, `visualbuild`,
150
+ `node_modules`, the VisualBuild config, or the Vercel access token.
151
+
152
+ Create a Vercel access token, then set it only in the terminal that starts the
153
+ visual builder:
154
+
155
+ ```powershell
156
+ $env:VERCEL_TOKEN = 'your-token'
157
+ npm.cmd run visual-builder
158
+ ```
159
+
160
+ For a team-owned project, optionally set `$env:VERCEL_TEAM_ID = 'team_...'` or
161
+ enter the Team ID in the deployment dialog. Click **Deploy** in the top bar,
162
+ review the Vercel project name, and choose **Deploy production**. VisualBuild
163
+ waits for Vercel to report `READY`, then displays the production URL.
164
+
165
+ Configure a non-standard Vite output directory or stable Vercel project name
166
+ in `visualbuild.config.ts`:
167
+
168
+ ```ts
169
+ deployment: {
170
+ provider: 'vercel',
171
+ outputDirectory: 'dist',
172
+ projectName: 'my-app',
173
+ teamId: 'team_abc123', // optional
174
+ }
175
+ ```
176
+
177
+ The access token is intentionally not supported in project configuration or
178
+ browser storage. If deployment fails, the dialog shows the Vercel or local
179
+ build error and leaves the last successful production deployment untouched.
180
+
181
+ ## Editor Themes
182
+
183
+ Use the palette control in the VisualBuild top bar to switch between:
184
+
185
+ - VisualBuild Default
186
+ - Codex Dark
187
+ - VS Code Light
188
+ - VS Code Dark
189
+ - System
190
+
191
+ The selected theme is saved per project and restored after refresh or editor
192
+ restart. `editor.theme` in `visualbuild.config.ts` supplies the initial choice
193
+ until the user selects a theme. The legacy values `dark` and `light` remain
194
+ supported and map to VisualBuild Default and VS Code Light.
195
+
196
+ Theme styles are scoped to editor chrome. The canvas, preview, generated React
197
+ source, and deployable application keep their own Tailwind styling and are not
198
+ recolored by the editor theme.
199
+
200
+ ## Register Local Components
201
+
202
+ Create a `.jsx` or `.tsx` component inside the deployable app's `src` folder,
203
+ then register it from the editor:
204
+
205
+ New `.jsx` and `.tsx` files created through the VisualBuild project explorer
206
+ are automatically initialized with a valid default-export component named from
207
+ the file. The starter uses a simple `<div>` root with an editable heading, so it
208
+ is immediately ready for custom-component registration. Root attributes are
209
+ written into that element from the Properties panel. Other file extensions
210
+ remain empty.
211
+
212
+ 1. Select the source file in **Files**.
213
+ 2. Click **Register** in the Code panel.
214
+ 3. Choose **Component** from the **Register as** dropdown.
215
+ 4. Click **Register component**.
216
+
217
+ VisualBuild detects the default or named component export, stores the
218
+ registration in `visualbuild/components.json`, and immediately adds it under
219
+ **Elements → Custom**.
220
+
221
+ Registered components expose ID, Tailwind classes, and additional JSON
222
+ attributes in the Properties panel. They also expose their managed component
223
+ root tag and accept nested canvas elements. Static JSX authored inside the
224
+ component is selectable on the canvas. Elements dragged inside the component
225
+ become part of the component definition and are written into the registered
226
+ source file on Save. Pages reference the reusable definition with a
227
+ self-closing component tag such as `<First />`; they do not duplicate the
228
+ component's internal JSX. Generated pages import components directly from
229
+ their local source files, so the deployed app has no VisualBuild runtime
230
+ dependency.
231
+
232
+ Custom component root-property edits update the registered implementation, such
233
+ as `src/components/First.tsx`, and therefore apply to every use of that
234
+ component. Nested element edits have the same definition-wide behavior. File
235
+ mode follows source ownership: selecting any node inside a registered custom
236
+ component opens that component's source; selecting a page element opens the
237
+ active managed page source; and selecting a project-tree file opens that exact
238
+ file. Unsaved root, property, and child-tree changes immediately update the
239
+ matching page or custom-component File buffer unless the developer has started
240
+ typing there.
241
+
242
+ ## Architecture
243
+
244
+ ```text
245
+ Visual Editor
246
+ |
247
+ v
248
+ visualbuild/pages.json
249
+ |
250
+ v
251
+ Babel AST Generator
252
+ |
253
+ v
254
+ React Project
255
+ ```
256
+
257
+ `visualbuild/pages.json` remains the safe schema boundary. Reverse sync accepts
258
+ documented static JSX/TSX structures; unsupported dynamic React code is left
259
+ untouched and produces an editor diagnostic.
260
+
261
+ The Code panel's Page, App, Layout, and JSON tabs are generated, read-only
262
+ previews. The File tab edits the exact selected project file. Click **Open
263
+ editor** to use the larger full-screen code workspace with its own project
264
+ explorer and Save file controls. Top-bar **Save** persists canvas/schema state;
265
+ **Save file** writes the source editor buffer.
266
+
267
+ Managed page source can update the canvas when its returned JSX is static.
268
+ Registered custom component source refreshes its canvas definition. Runtime
269
+ expressions, spread props, member-expression tags, and arbitrary React behavior
270
+ are intentionally outside the importer boundary. See the
271
+ [reverse-sync contract and recovery guide](docs/user-guide.md#reverse-sync-support-and-limits)
272
+ before editing generated pages directly.
273
+
274
+ ## Development
275
+
276
+ ```powershell
277
+ npm install
278
+ npm.cmd run visual-builder
279
+ ```
280
+
281
+ Useful checks:
282
+
283
+ ```powershell
284
+ npm.cmd run lint
285
+ npm.cmd run build
286
+ npm.cmd run test:week3
287
+ npm.cmd run test:custom-components
288
+ npm.cmd run test:config
289
+ npm.cmd run test:deployment
290
+ npm.cmd pack --dry-run
291
+ ```
292
+
293
+ ## Status
294
+
295
+ Current version: `0.1.0`
296
+
297
+ Week 3 is complete. Version `0.1.0` is published as
298
+ `create-visualbuild-app`, and both public CLI forms have been validated from
299
+ clean workspaces with explicit and default project names.
300
+
301
+ Week 4 covers component expansion, custom component registration, editor
302
+ themes, configuration, deployment, and v1 release-candidate validation.
303
+
304
+ ## License
305
+
306
+ UNLICENSED