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.
- package/README.md +919 -58
- package/docs/user-guide.md +759 -0
- package/package.json +92 -85
- package/scripts/create-builder-app.mjs +513 -501
- package/scripts/vb-dev.mjs +41 -32
- package/scripts/vb-generate.mjs +332 -224
- package/templates/default/app/.vercelignore +6 -0
- package/templates/default/app/README.md +56 -21
- package/templates/default/app/visualbuild/components.json +3 -0
- package/templates/default/app/visualbuild/config.d.ts +48 -0
- package/templates/default/app/visualbuild.config.ts +38 -0
- package/templates/default/builder/README.md +37 -21
- package/visual-app-builder/server/parseReactPage.ts +776 -571
- package/visual-app-builder/shared/createReactComponentSource.d.mts +2 -0
- package/visual-app-builder/shared/createReactComponentSource.mjs +45 -0
- package/visual-app-builder/shared/generateReactSource.d.mts +57 -37
- package/visual-app-builder/shared/generateReactSource.mjs +608 -443
- package/visual-app-builder/shared/npmBuildCommand.d.mts +17 -0
- package/visual-app-builder/shared/npmBuildCommand.mjs +26 -0
- package/visual-app-builder/shared/syncCustomComponentSource.d.mts +13 -0
- package/visual-app-builder/shared/syncCustomComponentSource.mjs +345 -0
- package/visual-app-builder/shared/vercelDeployment.d.mts +31 -0
- package/visual-app-builder/shared/vercelDeployment.mjs +266 -0
- package/visual-app-builder/shared/visualbuildConfig.d.mts +144 -0
- package/visual-app-builder/shared/visualbuildConfig.mjs +578 -0
- package/visual-app-builder/src/App.tsx +1090 -874
- package/visual-app-builder/src/components/Canvas.tsx +1116 -1059
- package/visual-app-builder/src/components/CodePanel.tsx +1147 -812
- package/visual-app-builder/src/components/ComponentSidebar.tsx +365 -302
- package/visual-app-builder/src/components/DeploymentModal.tsx +295 -0
- package/visual-app-builder/src/components/PageSwitcher.tsx +133 -133
- package/visual-app-builder/src/components/ProjectExplorer.tsx +1054 -1054
- package/visual-app-builder/src/components/PropertiesPanel.tsx +792 -692
- package/visual-app-builder/src/components/Topbar.tsx +257 -128
- package/visual-app-builder/src/data/componentRegistry.tsx +613 -292
- package/visual-app-builder/src/data/tailwindClassCatalog.ts +95 -0
- package/visual-app-builder/src/index.css +383 -111
- package/visual-app-builder/src/stores/useAppStore.ts +2385 -1265
- package/visual-app-builder/src/theme.ts +71 -0
- package/visual-app-builder/src/types/index.ts +350 -261
- package/visual-app-builder/src/utils/codegen.ts +90 -66
- package/visual-app-builder/src/utils/deployment.ts +54 -0
- package/visual-app-builder/src/utils/projectPersistence.ts +218 -177
- package/visual-app-builder/vite.config.ts +1946 -1479
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export function toReactComponentName(fileName) {
|
|
2
|
+
const baseName = String(fileName)
|
|
3
|
+
.replace(/\.(jsx|tsx)$/i, '')
|
|
4
|
+
.trim()
|
|
5
|
+
const name = baseName
|
|
6
|
+
.split(/[^A-Za-z0-9]+/)
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
9
|
+
.join('')
|
|
10
|
+
const candidate = name || 'Component'
|
|
11
|
+
|
|
12
|
+
return /^[A-Za-z_$]/.test(candidate)
|
|
13
|
+
? candidate
|
|
14
|
+
: `Component${candidate}`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function createReactComponentSource(fileName) {
|
|
18
|
+
const extension = String(fileName).split('.').pop()?.toLowerCase()
|
|
19
|
+
|
|
20
|
+
if (extension !== 'jsx' && extension !== 'tsx') {
|
|
21
|
+
return ''
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const componentName = toReactComponentName(fileName)
|
|
25
|
+
|
|
26
|
+
if (extension === 'tsx') {
|
|
27
|
+
return `export default function ${componentName}() {
|
|
28
|
+
return (
|
|
29
|
+
<div>
|
|
30
|
+
<h1>${componentName}</h1>
|
|
31
|
+
</div>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return `export default function ${componentName}() {
|
|
38
|
+
return (
|
|
39
|
+
<div>
|
|
40
|
+
<h1>${componentName}</h1>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
`
|
|
45
|
+
}
|
|
@@ -1,37 +1,57 @@
|
|
|
1
|
-
export interface SourceVisualNode {
|
|
2
|
-
id?: string
|
|
3
|
-
type: string
|
|
4
|
-
props?: Record<string, unknown>
|
|
5
|
-
children?: SourceVisualNode[]
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
export
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export function
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
): string
|
|
32
|
-
export function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
1
|
+
export interface SourceVisualNode {
|
|
2
|
+
id?: string
|
|
3
|
+
type: string
|
|
4
|
+
props?: Record<string, unknown>
|
|
5
|
+
children?: SourceVisualNode[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface SourceCustomComponent {
|
|
9
|
+
name: string
|
|
10
|
+
importPath: string
|
|
11
|
+
exportName: 'default' | string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface SourcePage {
|
|
15
|
+
id?: string
|
|
16
|
+
name: string
|
|
17
|
+
route: string
|
|
18
|
+
sourcePath?: string
|
|
19
|
+
root?: SourceVisualNode
|
|
20
|
+
components?: SourceVisualNode[]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface SourceAppShell {
|
|
24
|
+
header: SourceVisualNode | null
|
|
25
|
+
footer: SourceVisualNode | null
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function generatePageSource(
|
|
29
|
+
page: SourcePage,
|
|
30
|
+
customComponents?: SourceCustomComponent[]
|
|
31
|
+
): string
|
|
32
|
+
export function generateAppSource(
|
|
33
|
+
pages: SourcePage[],
|
|
34
|
+
appShell?: SourceAppShell,
|
|
35
|
+
options?: {
|
|
36
|
+
appFile?: string
|
|
37
|
+
layoutFile?: string
|
|
38
|
+
emitLayout?: boolean
|
|
39
|
+
}
|
|
40
|
+
): string
|
|
41
|
+
export function generateLayoutSource(
|
|
42
|
+
appShell: SourceAppShell,
|
|
43
|
+
customComponents?: SourceCustomComponent[],
|
|
44
|
+
options?: {
|
|
45
|
+
layoutFile?: string
|
|
46
|
+
}
|
|
47
|
+
): string
|
|
48
|
+
export function generateNodeSource(
|
|
49
|
+
node: SourceVisualNode,
|
|
50
|
+
indent?: string
|
|
51
|
+
): string
|
|
52
|
+
export function toPageComponentName(name: string): string
|
|
53
|
+
export function getPageSourcePath(
|
|
54
|
+
page: Pick<SourcePage, 'name' | 'sourcePath'>
|
|
55
|
+
): string
|
|
56
|
+
export function createPageSourcePath(name: string, pagesDir?: string): string
|
|
57
|
+
export function normalizeProjectPath(value: string): string
|