fusee-framework 1.9.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 +1 -1
- 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/package.json +1 -1
- package/create-fusee-go/internal/assets/embed/framework/bin/create-fusee.js +0 -199
|
@@ -1,8 +1,66 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export type MutationType = 'direct' | 'patch object' | 'patch function';
|
|
2
|
+
|
|
3
|
+
export const MutationType: {
|
|
4
|
+
readonly DIRECT: 'direct';
|
|
5
|
+
readonly PATCH_OBJECT: 'patch object';
|
|
6
|
+
readonly PATCH_FUNCTION: 'patch function';
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export interface StoreMutation {
|
|
10
|
+
type: MutationType;
|
|
11
|
+
storeId: string;
|
|
12
|
+
payload?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SubscribeOptions {
|
|
16
|
+
flush?: 'pre' | 'post' | 'sync';
|
|
17
|
+
detached?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SubscribeCallback = (mutation: StoreMutation, state: any) => void;
|
|
21
|
+
export type UnsubscribeFunction = () => void;
|
|
22
|
+
|
|
23
|
+
export interface Store<T> {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly type: 'store';
|
|
26
|
+
patch(partial: Partial<{ [K in keyof T]: T[K] extends (...args: any[]) => any ? ReturnType<T[K]> : T[K] }> | ((state: T) => void)): void;
|
|
27
|
+
subscribe(callback: SubscribeCallback, options?: SubscribeOptions): UnsubscribeFunction;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type StoreHook<T> = (() => T & Store<T>) & { $id: string };
|
|
31
|
+
|
|
32
|
+
export function defineStore<T>(id: string, setup: () => T): StoreHook<T>;
|
|
33
|
+
export function resetStore(id: string): void;
|
|
34
|
+
export function clearStores(): void;
|
|
35
|
+
export function registerStorePlugin(plugin: (store: any, id: string) => void): void;
|
|
36
|
+
export function useNestedStore<T>(useStoreFn: StoreHook<T>): T & Store<T>;
|
|
37
|
+
|
|
38
|
+
export type StoreToRefs<T> = {
|
|
39
|
+
[K in keyof T]: T[K] extends (...args: any[]) => infer R ? import('./signal').SignalAccessor<R> : never
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type StoreToState<T> = {
|
|
43
|
+
[K in keyof T]: T[K] extends (...args: any[]) => infer R
|
|
44
|
+
? import('./signal').SignalAccessor<R> extends { readonly: true }
|
|
45
|
+
? never
|
|
46
|
+
: import('./signal').SignalAccessor<R>
|
|
47
|
+
: never
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type StoreToGetters<T> = {
|
|
51
|
+
[K in keyof T]: T[K] extends (...args: any[]) => infer R
|
|
52
|
+
? import('./signal').SignalAccessor<R> extends { readonly: true }
|
|
53
|
+
? import('./signal').SignalAccessor<R>
|
|
54
|
+
: never
|
|
55
|
+
: never
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function storeToRefs<T>(store: T & Store<T>): StoreToRefs<T>;
|
|
59
|
+
export function storeToState<T>(store: T & Store<T>): StoreToState<T>;
|
|
60
|
+
export function storeToGetters<T>(store: T & Store<T>): StoreToGetters<T>;
|
|
61
|
+
|
|
62
|
+
declare global {
|
|
63
|
+
function defineStore<T>(id: string, setup: () => T): import('./store').StoreHook<T>;
|
|
64
|
+
function useNestedStore<T>(useStoreFn: import('./store').StoreHook<T>): T & Store<T>;
|
|
65
|
+
type MutationType = import('./store').MutationType;
|
|
66
|
+
}
|
package/package.json
CHANGED
|
@@ -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();
|