fusee-framework 1.8.0 → 1.9.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 +64 -3
- package/app/benchmark/vite.config.js +23 -0
- package/auto-imports.d.ts +4 -0
- package/bin/create-fusee-linux +0 -0
- package/bin/create-fusee-mac-arm64 +0 -0
- package/bin/create-fusee-mac-intel +0 -0
- package/bin/create-fusee-win.exe +0 -0
- package/bin/create-fusee.exe +0 -0
- package/create-fusee-go/internal/assets/embed/framework/auto-import-preset.js +15 -9
- package/create-fusee-go/internal/assets/embed/framework/core/async-context.js +27 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/ast.js +167 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/errors-list.js +47 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/errors.js +107 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/generator.js +363 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/lexer.js +347 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/main-compiler.js +115 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/parser.js +414 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/plugins/actions-plugin.js +263 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/plugins/compiler-plugin.d.ts +5 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/plugins/compiler-plugin.js +45 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/plugins/file-router-plugin.js +301 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/plugins/router-plugin.js +196 -0
- package/create-fusee-go/internal/assets/embed/framework/core/compiler/transformer.js +398 -0
- package/create-fusee-go/internal/assets/embed/framework/core/component.js +61 -23
- package/create-fusee-go/internal/assets/embed/framework/core/di.js +187 -0
- package/create-fusee-go/internal/assets/embed/framework/core/directives.js +40 -96
- package/create-fusee-go/internal/assets/embed/framework/core/evaluator.js +1 -1
- package/create-fusee-go/internal/assets/embed/framework/core/h.js +430 -0
- package/create-fusee-go/internal/assets/embed/framework/core/hydration.js +83 -0
- package/create-fusee-go/internal/assets/embed/framework/core/reconcile.js +151 -0
- package/create-fusee-go/internal/assets/embed/framework/core/signal.js +269 -0
- package/create-fusee-go/internal/assets/embed/framework/core/store.js +322 -81
- package/create-fusee-go/internal/assets/embed/framework/index.js +5 -3
- package/create-fusee-go/internal/assets/embed/framework/router/file-router.js +1 -1
- package/create-fusee-go/internal/assets/embed/framework/router/router.js +113 -21
- package/create-fusee-go/internal/assets/embed/framework/server/actions.js +173 -0
- package/create-fusee-go/internal/assets/embed/framework/server/actions.server.js +88 -0
- package/create-fusee-go/internal/assets/embed/framework/server/index.js +18 -0
- package/create-fusee-go/internal/assets/embed/framework/types/actions.d.ts +50 -0
- package/create-fusee-go/internal/assets/embed/framework/types/actions.server.d.ts +36 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/ast.d.ts +166 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/errors-codes.d.ts +23 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/errors.d.ts +43 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/generator.d.ts +8 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/h.d.ts +46 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/lexer.d.ts +27 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/main-compiler.d.ts +60 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/parser.d.ts +4 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/plugins/actions.d.ts +30 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/plugins/compiler-plugin.d.ts +5 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/plugins/file-router-plugins.d.ts +32 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/plugins/router-plugin.d.ts +24 -0
- package/create-fusee-go/internal/assets/embed/framework/types/compiler/transformer.d.ts +28 -0
- package/create-fusee-go/internal/assets/embed/framework/types/component.d.ts +89 -88
- package/create-fusee-go/internal/assets/embed/framework/types/di.d.ts +43 -0
- package/create-fusee-go/internal/assets/embed/framework/types/hydration.d.ts +30 -0
- package/create-fusee-go/internal/assets/embed/framework/types/index.d.ts +38 -22
- package/create-fusee-go/internal/assets/embed/framework/types/reconcile.d.ts +7 -0
- package/create-fusee-go/internal/assets/embed/framework/types/router.d.ts +11 -1
- package/create-fusee-go/internal/assets/embed/framework/types/server.d.ts +11 -0
- package/create-fusee-go/internal/assets/embed/framework/types/signal.d.ts +142 -79
- package/create-fusee-go/internal/assets/embed/framework/types/store.d.ts +66 -8
- package/framework/auto-import-preset.js +3 -1
- package/framework/core/async-context.js +27 -0
- package/framework/core/compiler/ast.js +167 -0
- package/framework/core/compiler/errors-list.js +47 -0
- package/framework/core/compiler/errors.js +107 -0
- package/framework/core/compiler/generator.js +363 -0
- package/framework/core/compiler/lexer.js +347 -0
- package/framework/core/compiler/main-compiler.js +115 -0
- package/framework/core/compiler/parser.js +414 -0
- package/framework/core/compiler/plugins/actions-plugin.js +263 -0
- package/framework/core/compiler/plugins/compiler-plugin.d.ts +5 -0
- package/framework/core/compiler/plugins/compiler-plugin.js +45 -0
- package/framework/core/compiler/plugins/file-router-plugin.js +301 -0
- package/framework/core/compiler/plugins/router-plugin.js +196 -0
- package/framework/core/compiler/transformer.js +398 -0
- package/framework/core/component.js +34 -10
- package/framework/core/evaluator.js +1 -1
- package/framework/core/h.js +430 -0
- package/framework/core/hydration.js +83 -0
- package/framework/core/signal.js +17 -15
- package/framework/server/actions.js +173 -0
- package/framework/server/actions.server.js +88 -0
- package/framework/server/index.js +18 -0
- package/framework/types/actions.d.ts +50 -0
- package/framework/types/actions.server.d.ts +36 -0
- package/framework/types/compiler/ast.d.ts +166 -0
- package/framework/types/compiler/errors-codes.d.ts +23 -0
- package/framework/types/compiler/errors.d.ts +43 -0
- package/framework/types/compiler/generator.d.ts +8 -0
- package/framework/types/compiler/h.d.ts +46 -0
- package/framework/types/compiler/lexer.d.ts +27 -0
- package/framework/types/compiler/main-compiler.d.ts +60 -0
- package/framework/types/compiler/parser.d.ts +4 -0
- package/framework/types/compiler/plugins/actions.d.ts +30 -0
- package/framework/types/compiler/plugins/compiler-plugin.d.ts +5 -0
- package/framework/types/compiler/plugins/file-router-plugins.d.ts +32 -0
- package/framework/types/compiler/plugins/router-plugin.d.ts +24 -0
- package/framework/types/compiler/transformer.d.ts +28 -0
- package/framework/types/hydration.d.ts +30 -0
- package/framework/types/index.d.ts +6 -0
- package/framework/types/server.d.ts +11 -0
- package/framework/types/signal.d.ts +2 -7
- package/ghid_go_fusee_integrat_go1_26.txt +276 -0
- package/ghid_rust_fusee_rust_1_95_0.txt +1118 -0
- package/package.json +44 -36
- package/vite.config.js +65 -53
- package/create-fusee-go/internal/assets/embed/framework/bin/create-fusee.js +0 -199
package/package.json
CHANGED
|
@@ -1,36 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "fusee-framework",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Fusée - Signals-first JS Framework | Peak Performance",
|
|
5
|
-
"main": "framework/index.js",
|
|
6
|
-
"types": "framework/types/index.d.ts",
|
|
7
|
-
"bin": {
|
|
8
|
-
"fusee": "./bin/index.js",
|
|
9
|
-
"create-fusee": "./bin/index.js",
|
|
10
|
-
"create-fusee-app": "./bin/index.js"
|
|
11
|
-
},
|
|
12
|
-
"type": "module",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"dev": "vite",
|
|
15
|
-
"build": "vite build",
|
|
16
|
-
"preview": "vite preview",
|
|
17
|
-
"test": "vitest run"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [],
|
|
20
|
-
"author": "",
|
|
21
|
-
"license": "MIT",
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/SebiSomu/fusee.git"
|
|
25
|
-
},
|
|
26
|
-
"publishConfig": {
|
|
27
|
-
"registry": "https://registry.npmjs.org/"
|
|
28
|
-
},
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "fusee-framework",
|
|
3
|
+
"version": "1.9.1",
|
|
4
|
+
"description": "Fusée - Signals-first JS Framework | Peak Performance",
|
|
5
|
+
"main": "framework/index.js",
|
|
6
|
+
"types": "framework/types/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"fusee": "./bin/index.js",
|
|
9
|
+
"create-fusee": "./bin/index.js",
|
|
10
|
+
"create-fusee-app": "./bin/index.js"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"dev": "vite",
|
|
15
|
+
"build": "vite build",
|
|
16
|
+
"preview": "vite preview",
|
|
17
|
+
"test": "vitest run"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [],
|
|
20
|
+
"author": "",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/SebiSomu/fusee.git"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"registry": "https://registry.npmjs.org/"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"fast-glob": "^3.3.3",
|
|
31
|
+
"jsdom": "^29.0.2",
|
|
32
|
+
"typescript": "^6.0.2",
|
|
33
|
+
"unplugin-auto-import": "^21.0.0",
|
|
34
|
+
"vite": "^5.0.0",
|
|
35
|
+
"vitest": "^4.1.4"
|
|
36
|
+
},
|
|
37
|
+
"exports": {
|
|
38
|
+
".": "./framework/index.js",
|
|
39
|
+
"./server": "./framework/server/index.js"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"benchmark": "^2.1.4"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/vite.config.js
CHANGED
|
@@ -1,53 +1,65 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import path from 'path'
|
|
3
|
-
import AutoImport from 'unplugin-auto-import/vite'
|
|
4
|
-
import { FuseePreset } from './framework/auto-import-preset.js'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import AutoImport from 'unplugin-auto-import/vite'
|
|
4
|
+
import { FuseePreset } from './framework/auto-import-preset.js'
|
|
5
|
+
import { fuseeCompilerPlugin } from './framework/core/compiler/plugins/compiler-plugin.js'
|
|
6
|
+
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
root: '.',
|
|
9
|
+
plugins: [
|
|
10
|
+
fuseeCompilerPlugin(),
|
|
11
|
+
AutoImport({
|
|
12
|
+
imports: [FuseePreset],
|
|
13
|
+
dts: true,
|
|
14
|
+
})
|
|
15
|
+
],
|
|
16
|
+
|
|
17
|
+
resolve: {
|
|
18
|
+
alias: {
|
|
19
|
+
'fusee-framework': path.resolve(__dirname, './framework'),
|
|
20
|
+
'@app': path.resolve(__dirname, './app'),
|
|
21
|
+
'@shared/config': path.resolve(__dirname, '../shared-config/index.ts')
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
optimizeDeps: {
|
|
26
|
+
exclude: ['fusee-framework']
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
server: {
|
|
30
|
+
port: 3000,
|
|
31
|
+
open: true,
|
|
32
|
+
hmr: true,
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
build: {
|
|
36
|
+
outDir: 'dist',
|
|
37
|
+
emptyOutDir: true,
|
|
38
|
+
|
|
39
|
+
rollupOptions: {
|
|
40
|
+
input: {
|
|
41
|
+
main: path.resolve(__dirname, 'index.html'),
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
test: {
|
|
47
|
+
environment: 'jsdom',
|
|
48
|
+
globals: true,
|
|
49
|
+
exclude: [
|
|
50
|
+
'node_modules/**',
|
|
51
|
+
'bench-node-1/**',
|
|
52
|
+
'create-fusee-go/**',
|
|
53
|
+
'dist/**'
|
|
54
|
+
],
|
|
55
|
+
typecheck: {
|
|
56
|
+
enabled: true,
|
|
57
|
+
include: ['framework/**/*.test-d.ts'],
|
|
58
|
+
},
|
|
59
|
+
resolve: {
|
|
60
|
+
alias: {
|
|
61
|
+
'fusee/actions.server': path.resolve('./framework/server/actions.js')
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
})
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import readline from 'readline';
|
|
5
|
-
import { fileURLToPath } from 'url';
|
|
6
|
-
|
|
7
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
8
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
10
|
-
// Find the package root
|
|
11
|
-
let pkgRoot = __dirname;
|
|
12
|
-
while (pkgRoot !== path.dirname(pkgRoot) && !fs.existsSync(path.join(pkgRoot, 'package.json'))) {
|
|
13
|
-
pkgRoot = path.dirname(pkgRoot);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const sourceFramework = fs.existsSync(path.join(pkgRoot, 'framework'))
|
|
17
|
-
? path.join(pkgRoot, 'framework')
|
|
18
|
-
: pkgRoot;
|
|
19
|
-
|
|
20
|
-
const projectName = process.argv[2] || 'my-fusee-app';
|
|
21
|
-
const projectPath = path.isAbsolute(projectName) ? projectName : path.join(process.cwd(), projectName);
|
|
22
|
-
|
|
23
|
-
async function scaffold() {
|
|
24
|
-
console.log(`\n🚀 Welcome to Fusée Framework Scaffolder!`);
|
|
25
|
-
const choice = await new Promise(resolve => {
|
|
26
|
-
rl.question('🧬 Select language template [JavaScript (js) / TypeScript (ts)] (default: js): ', (answer) => {
|
|
27
|
-
resolve(answer.toLowerCase() === 'ts' ? 'ts' : 'js');
|
|
28
|
-
});
|
|
29
|
-
}); rl.close();
|
|
30
|
-
|
|
31
|
-
console.log(`\n🚀 Scaffolding a new project in: ${projectPath}...`);
|
|
32
|
-
|
|
33
|
-
function copyDir(src, dest, skipTypes = false) {
|
|
34
|
-
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
|
35
|
-
fs.readdirSync(src).forEach(item => {
|
|
36
|
-
if (skipTypes && (item === 'types' || item.endsWith('.d.ts'))) return;
|
|
37
|
-
if (item === 'bin' || item === 'node_modules' || item === '.git' || item === 'dist') return;
|
|
38
|
-
|
|
39
|
-
const s = path.join(src, item);
|
|
40
|
-
const d = path.join(dest, item);
|
|
41
|
-
if (fs.lstatSync(s).isDirectory()) copyDir(s, d, skipTypes);
|
|
42
|
-
else fs.copyFileSync(s, d);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const coreFolders = ['app', 'app/components', 'app/routes'];
|
|
47
|
-
coreFolders.forEach(f => {
|
|
48
|
-
const dir = path.join(projectPath, f);
|
|
49
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
console.log('📦 Injecting Fusée Core Engine...');
|
|
53
|
-
copyDir(sourceFramework, path.join(projectPath, 'framework'), choice === 'js');
|
|
54
|
-
|
|
55
|
-
const ext = choice === 'ts' ? 'ts' : 'js';
|
|
56
|
-
|
|
57
|
-
// 1. package.json
|
|
58
|
-
const packageJson = {
|
|
59
|
-
name: projectName === '.' ? 'fusee-project' : projectName,
|
|
60
|
-
version: '1.0.0',
|
|
61
|
-
type: 'module',
|
|
62
|
-
scripts: { "dev": "vite", "build": "vite build" },
|
|
63
|
-
devDependencies: {
|
|
64
|
-
"vite": "^5.0.0",
|
|
65
|
-
"unplugin-auto-import": "^0.17.0"
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
if (choice === 'ts') packageJson.devDependencies["typescript"] = "^5.0.0";
|
|
69
|
-
fs.writeFileSync(path.join(projectPath, 'package.json'), JSON.stringify(packageJson, null, 2));
|
|
70
|
-
|
|
71
|
-
// 2. vite.config.js
|
|
72
|
-
const viteConfig = `import { defineConfig } from 'vite';
|
|
73
|
-
import path from 'path';
|
|
74
|
-
import AutoImport from 'unplugin-auto-import/vite';
|
|
75
|
-
import { FuseePreset } from './framework/auto-import-preset.js';
|
|
76
|
-
|
|
77
|
-
export default defineConfig({
|
|
78
|
-
resolve: {
|
|
79
|
-
alias: {
|
|
80
|
-
'fusee-framework': path.resolve(__dirname, './framework')
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
plugins: [
|
|
84
|
-
AutoImport({
|
|
85
|
-
imports: [FuseePreset],
|
|
86
|
-
dts: true // Generates auto-imports.d.ts
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
});`;
|
|
90
|
-
fs.writeFileSync(path.join(projectPath, 'vite.config.js'), viteConfig);
|
|
91
|
-
|
|
92
|
-
// 3. tsconfig.json (if TS)
|
|
93
|
-
if (choice === 'ts') {
|
|
94
|
-
const tsConfig = {
|
|
95
|
-
compilerOptions: {
|
|
96
|
-
"target": "ESNext",
|
|
97
|
-
"module": "ESNext",
|
|
98
|
-
"moduleResolution": "bundler",
|
|
99
|
-
"strict": true,
|
|
100
|
-
"esModuleInterop": true,
|
|
101
|
-
"skipLibCheck": true,
|
|
102
|
-
"paths": {
|
|
103
|
-
"fusee-framework": ["./framework/types/index.d.ts"]
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
"include": ["app/**/*", "framework/**/*", "auto-imports.d.ts"]
|
|
107
|
-
};
|
|
108
|
-
fs.writeFileSync(path.join(projectPath, 'tsconfig.json'), JSON.stringify(tsConfig, null, 2));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// 4. index.html
|
|
112
|
-
const indexHtml = `<!DOCTYPE html>
|
|
113
|
-
<html>
|
|
114
|
-
<head>
|
|
115
|
-
<meta charset="UTF-8">
|
|
116
|
-
<title>Fusée App</title>
|
|
117
|
-
<style>
|
|
118
|
-
body { background: #050505; color: white; font-family: system-ui; margin: 0; }
|
|
119
|
-
#app { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; }
|
|
120
|
-
.hero { text-align: center; margin-bottom: 2rem; }
|
|
121
|
-
h1 { color: #ff3333; font-size: 3rem; margin: 0; }
|
|
122
|
-
</style>
|
|
123
|
-
</head>
|
|
124
|
-
<body>
|
|
125
|
-
<div id="app">
|
|
126
|
-
<div class="hero">
|
|
127
|
-
<h1>Fusée 🚀</h1>
|
|
128
|
-
<p style="opacity: 0.6;">Modern Reactive Framework</p>
|
|
129
|
-
</div>
|
|
130
|
-
{{ Counter }}
|
|
131
|
-
</div>
|
|
132
|
-
<script type="module" src="/app/main.${ext}"></script>
|
|
133
|
-
</body>
|
|
134
|
-
</html>`;
|
|
135
|
-
fs.writeFileSync(path.join(projectPath, 'index.html'), indexHtml);
|
|
136
|
-
|
|
137
|
-
// 5. Counter component
|
|
138
|
-
const btnStyle = "background:#ff3333; color:white; border:none; width:50px; height:50px; border-radius:15px; cursor:pointer; font-size:1.5rem; transition: 0.2s;";
|
|
139
|
-
const counterContent = choice === 'ts'
|
|
140
|
-
? `interface CounterResult {
|
|
141
|
-
count: Signal<number>
|
|
142
|
-
inc: () => void
|
|
143
|
-
dec: () => void
|
|
144
|
-
template: string
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export const Counter = defineComponent({
|
|
148
|
-
setup(): CounterResult {
|
|
149
|
-
const count = signal<number>(0);
|
|
150
|
-
return {
|
|
151
|
-
count,
|
|
152
|
-
inc: () => count(count() + 1),
|
|
153
|
-
dec: () => count(count() - 1),
|
|
154
|
-
template: \`
|
|
155
|
-
<div style="display:flex; align-items:center; gap:2rem; background:#111; padding:2rem; border-radius:20px; border:1px solid #222;">
|
|
156
|
-
<button @click="dec" style="${btnStyle}">-</button>
|
|
157
|
-
<span style="font-size:3rem; font-weight:bold; min-width:60px; text-align:center;">{{ count }}</span>
|
|
158
|
-
<button @click="inc" style="${btnStyle}">+</button>
|
|
159
|
-
</div>
|
|
160
|
-
\`
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
|
-
});`
|
|
164
|
-
: `export const Counter = defineComponent({
|
|
165
|
-
setup() {
|
|
166
|
-
const count = signal(0);
|
|
167
|
-
return {
|
|
168
|
-
count,
|
|
169
|
-
inc: () => count(count() + 1),
|
|
170
|
-
dec: () => count(count() - 1),
|
|
171
|
-
template: \`
|
|
172
|
-
<div style="display:flex; align-items:center; gap:2rem; background:#111; padding:2rem; border-radius:20px; border:1px solid #222;">
|
|
173
|
-
<button @click="dec" style="${btnStyle}">-</button>
|
|
174
|
-
<span style="font-size:3rem; font-weight:bold; min-width:60px; text-align:center;">{{ count }}</span>
|
|
175
|
-
<button @click="inc" style="${btnStyle}">+</button>
|
|
176
|
-
</div>
|
|
177
|
-
\`
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
});`;
|
|
181
|
-
fs.writeFileSync(path.join(projectPath, `app/components/Counter.${ext}`), counterContent);
|
|
182
|
-
|
|
183
|
-
// 6. main.js
|
|
184
|
-
const mainContent = `import { Counter } from './components/Counter';
|
|
185
|
-
|
|
186
|
-
const root = document.getElementById('app');
|
|
187
|
-
if (root) {
|
|
188
|
-
// mountTemplate is now auto-imported via Fusée!
|
|
189
|
-
mountTemplate(root.innerHTML, root, {}, { Counter });
|
|
190
|
-
}
|
|
191
|
-
`;
|
|
192
|
-
fs.writeFileSync(path.join(projectPath, `app/main.${ext}`), mainContent);
|
|
193
|
-
|
|
194
|
-
console.log(`\n✅ Fusée Project Ready!`);
|
|
195
|
-
const instructions = projectName === '.' ? 'npm install && npm run dev' : `cd ${projectName} && npm install && npm run dev`;
|
|
196
|
-
console.log(`👉 Run: ${instructions}\n`);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
scaffold();
|