@liteforge/runtime 0.2.3 → 0.4.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.
- package/dist/app.d.ts +18 -23
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +105 -89
- package/dist/app.js.map +1 -1
- package/dist/component.d.ts +6 -0
- package/dist/component.d.ts.map +1 -1
- package/dist/component.js +22 -0
- package/dist/component.js.map +1 -1
- package/dist/control-flow.d.ts +10 -5
- package/dist/control-flow.d.ts.map +1 -1
- package/dist/control-flow.js +142 -65
- package/dist/control-flow.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin-registry.d.ts +9 -0
- package/dist/plugin-registry.d.ts.map +1 -0
- package/dist/plugin-registry.js +18 -0
- package/dist/plugin-registry.js.map +1 -0
- package/dist/types.d.ts +74 -29
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/app.d.ts
CHANGED
|
@@ -3,36 +3,31 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Central app bootstrap: mounts root component, initializes stores,
|
|
5
5
|
* sets up context, router, plugins, and debug utilities.
|
|
6
|
+
*
|
|
7
|
+
* Returns an AppBuilder that supports chained .use(plugin).mount().
|
|
8
|
+
* The AppBuilder is also a Thenable, so `await createApp(...)` works
|
|
9
|
+
* without an explicit .mount() call (backward compat).
|
|
6
10
|
*/
|
|
7
|
-
import type { AppConfig,
|
|
11
|
+
import type { AppConfig, AppBuilder } from './types.js';
|
|
8
12
|
/**
|
|
9
13
|
* Create and bootstrap a LiteForge application.
|
|
10
14
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* 4. Initializes stores (calls initialize() if present)
|
|
16
|
-
* 5. Starts the router (if present)
|
|
17
|
-
* 6. Mounts the root component
|
|
18
|
-
* 7. Runs plugin afterMount hooks
|
|
19
|
-
* 8. Sets up debug utilities (if debug mode)
|
|
20
|
-
* 9. Calls onReady callback
|
|
21
|
-
*
|
|
22
|
-
* @param config - Application configuration
|
|
23
|
-
* @returns Promise resolving to the app instance
|
|
15
|
+
* Returns an AppBuilder with:
|
|
16
|
+
* - `.use(plugin)` — register a new-style LiteForgePlugin (chainable)
|
|
17
|
+
* - `.mount()` — async, performs full bootstrap
|
|
18
|
+
* - `.then()` — Thenable for `await createApp(...)` backward compat
|
|
24
19
|
*
|
|
25
20
|
* @example
|
|
26
21
|
* ```ts
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* });
|
|
22
|
+
* // New pattern:
|
|
23
|
+
* const app = await createApp({ root: App, target: '#app' })
|
|
24
|
+
* .use(routerPlugin(options))
|
|
25
|
+
* .use(modalPlugin())
|
|
26
|
+
* .mount();
|
|
27
|
+
*
|
|
28
|
+
* // Old pattern (still works):
|
|
29
|
+
* const app = await createApp({ root: App, target: '#app', plugins: [devtoolsPlugin()] });
|
|
35
30
|
* ```
|
|
36
31
|
*/
|
|
37
|
-
export declare function createApp(config: AppConfig):
|
|
32
|
+
export declare function createApp(config: AppConfig): AppBuilder;
|
|
38
33
|
//# sourceMappingURL=app.d.ts.map
|
package/dist/app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,SAAS,EAET,UAAU,EAKX,MAAM,YAAY,CAAC;AAuBpB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAsCvD"}
|
package/dist/app.js
CHANGED
|
@@ -3,50 +3,77 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Central app bootstrap: mounts root component, initializes stores,
|
|
5
5
|
* sets up context, router, plugins, and debug utilities.
|
|
6
|
+
*
|
|
7
|
+
* Returns an AppBuilder that supports chained .use(plugin).mount().
|
|
8
|
+
* The AppBuilder is also a Thenable, so `await createApp(...)` works
|
|
9
|
+
* without an explicit .mount() call (backward compat).
|
|
6
10
|
*/
|
|
7
11
|
import { initAppContext, clearContext, use } from './context.js';
|
|
8
12
|
import { isComponentFactory } from './component.js';
|
|
9
13
|
import { getHMRHandler } from './hmr.js';
|
|
14
|
+
import { createPluginContext } from './plugin-registry.js';
|
|
10
15
|
// ============================================================================
|
|
11
|
-
// createApp
|
|
16
|
+
// createApp — returns AppBuilder
|
|
12
17
|
// ============================================================================
|
|
13
18
|
/**
|
|
14
19
|
* Create and bootstrap a LiteForge application.
|
|
15
20
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* 4. Initializes stores (calls initialize() if present)
|
|
21
|
-
* 5. Starts the router (if present)
|
|
22
|
-
* 6. Mounts the root component
|
|
23
|
-
* 7. Runs plugin afterMount hooks
|
|
24
|
-
* 8. Sets up debug utilities (if debug mode)
|
|
25
|
-
* 9. Calls onReady callback
|
|
26
|
-
*
|
|
27
|
-
* @param config - Application configuration
|
|
28
|
-
* @returns Promise resolving to the app instance
|
|
21
|
+
* Returns an AppBuilder with:
|
|
22
|
+
* - `.use(plugin)` — register a new-style LiteForgePlugin (chainable)
|
|
23
|
+
* - `.mount()` — async, performs full bootstrap
|
|
24
|
+
* - `.then()` — Thenable for `await createApp(...)` backward compat
|
|
29
25
|
*
|
|
30
26
|
* @example
|
|
31
27
|
* ```ts
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* });
|
|
28
|
+
* // New pattern:
|
|
29
|
+
* const app = await createApp({ root: App, target: '#app' })
|
|
30
|
+
* .use(routerPlugin(options))
|
|
31
|
+
* .use(modalPlugin())
|
|
32
|
+
* .mount();
|
|
33
|
+
*
|
|
34
|
+
* // Old pattern (still works):
|
|
35
|
+
* const app = await createApp({ root: App, target: '#app', plugins: [devtoolsPlugin()] });
|
|
40
36
|
* ```
|
|
41
37
|
*/
|
|
42
|
-
export
|
|
38
|
+
export function createApp(config) {
|
|
39
|
+
const newStylePlugins = [];
|
|
40
|
+
let mountCalled = false;
|
|
41
|
+
const builder = {
|
|
42
|
+
use(plugin) {
|
|
43
|
+
if (mountCalled) {
|
|
44
|
+
throw new Error(`[LiteForge] Cannot call .use() after .mount() — plugin "${plugin.name}" added too late.`);
|
|
45
|
+
}
|
|
46
|
+
newStylePlugins.push(plugin);
|
|
47
|
+
return builder;
|
|
48
|
+
},
|
|
49
|
+
mount() {
|
|
50
|
+
if (mountCalled) {
|
|
51
|
+
throw new Error('[LiteForge] .mount() has already been called.');
|
|
52
|
+
}
|
|
53
|
+
mountCalled = true;
|
|
54
|
+
return installAndMount(config, newStylePlugins);
|
|
55
|
+
},
|
|
56
|
+
then(onfulfilled, onrejected) {
|
|
57
|
+
return builder.mount().then(onfulfilled, onrejected);
|
|
58
|
+
},
|
|
59
|
+
catch(onrejected) {
|
|
60
|
+
return builder.mount().catch(onrejected);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
return builder;
|
|
64
|
+
}
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// installAndMount — the full bootstrap logic
|
|
67
|
+
// ============================================================================
|
|
68
|
+
async function installAndMount(config, newStylePlugins) {
|
|
43
69
|
let rootInstance = null;
|
|
44
70
|
let rootNode = null;
|
|
45
71
|
let targetElement = null;
|
|
46
72
|
let isMounted = false;
|
|
47
73
|
const appContext = {};
|
|
48
74
|
const storesMap = {};
|
|
49
|
-
|
|
75
|
+
const pluginCleanups = [];
|
|
76
|
+
// Determine debug mode
|
|
50
77
|
const isDebug = config.debug ??
|
|
51
78
|
(typeof globalThis !== 'undefined' &&
|
|
52
79
|
globalThis.__DEV__ === true);
|
|
@@ -72,39 +99,55 @@ export async function createApp(config) {
|
|
|
72
99
|
}
|
|
73
100
|
// 2b. Router
|
|
74
101
|
if (config.router) {
|
|
75
|
-
appContext
|
|
102
|
+
appContext['router'] = config.router;
|
|
76
103
|
}
|
|
77
|
-
// 2c. Stores
|
|
104
|
+
// 2c. Stores
|
|
78
105
|
if (config.stores) {
|
|
79
106
|
for (const store of config.stores) {
|
|
80
107
|
storesMap[store.$name] = store;
|
|
81
108
|
appContext[`store:${store.$name}`] = store;
|
|
82
|
-
// Also register directly by name for convenience
|
|
83
109
|
appContext[store.$name] = store;
|
|
84
110
|
}
|
|
85
111
|
}
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
112
|
+
// ========================================
|
|
113
|
+
// 3. Duplicate-check all plugin names BEFORE any install()
|
|
114
|
+
// ========================================
|
|
115
|
+
const seenNames = new Set();
|
|
116
|
+
for (const plugin of newStylePlugins) {
|
|
117
|
+
if (seenNames.has(plugin.name)) {
|
|
118
|
+
throw new Error(`[LiteForge] Duplicate plugin name: "${plugin.name}". Each plugin must have a unique name.`);
|
|
92
119
|
}
|
|
120
|
+
seenNames.add(plugin.name);
|
|
93
121
|
}
|
|
94
122
|
// ========================================
|
|
95
|
-
//
|
|
123
|
+
// 4. LiteForgePlugin install()
|
|
124
|
+
// On failure: run collected cleanups in reverse, then re-throw.
|
|
96
125
|
// ========================================
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
126
|
+
const pluginCtx = createPluginContext(targetElement, appContext);
|
|
127
|
+
for (const plugin of newStylePlugins) {
|
|
128
|
+
try {
|
|
129
|
+
const cleanup = plugin.install(pluginCtx);
|
|
130
|
+
if (typeof cleanup === 'function') {
|
|
131
|
+
pluginCleanups.push(cleanup);
|
|
101
132
|
}
|
|
102
133
|
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
// Run cleanups for already-installed plugins in reverse
|
|
136
|
+
for (let i = pluginCleanups.length - 1; i >= 0; i--) {
|
|
137
|
+
try {
|
|
138
|
+
pluginCleanups[i]();
|
|
139
|
+
}
|
|
140
|
+
catch { /* ignore cleanup errors */ }
|
|
141
|
+
}
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
103
144
|
}
|
|
104
|
-
//
|
|
145
|
+
// ========================================
|
|
146
|
+
// 6. Initialize app-level context
|
|
147
|
+
// ========================================
|
|
105
148
|
initAppContext(appContext);
|
|
106
149
|
// ========================================
|
|
107
|
-
//
|
|
150
|
+
// 7. Initialize stores
|
|
108
151
|
// ========================================
|
|
109
152
|
if (config.stores) {
|
|
110
153
|
for (const store of config.stores) {
|
|
@@ -117,48 +160,39 @@ export async function createApp(config) {
|
|
|
117
160
|
}
|
|
118
161
|
}
|
|
119
162
|
// ========================================
|
|
120
|
-
//
|
|
163
|
+
// 8. Start router
|
|
121
164
|
// ========================================
|
|
122
|
-
if (config.router &&
|
|
165
|
+
if (config.router &&
|
|
166
|
+
'start' in config.router &&
|
|
167
|
+
typeof config.router.start === 'function') {
|
|
123
168
|
if (isDebug) {
|
|
124
169
|
console.log('[LiteForge] Starting router...');
|
|
125
170
|
}
|
|
126
171
|
await config.router.start();
|
|
127
172
|
}
|
|
128
173
|
// ========================================
|
|
129
|
-
//
|
|
174
|
+
// 9. Mount root component
|
|
130
175
|
// ========================================
|
|
131
176
|
const rootConfig = config.root;
|
|
132
177
|
if (isComponentFactory(rootConfig)) {
|
|
133
|
-
// It's a ComponentFactory from createComponent()
|
|
134
178
|
rootInstance = rootConfig({});
|
|
135
179
|
rootInstance.mount(targetElement);
|
|
136
180
|
}
|
|
137
181
|
else {
|
|
138
|
-
// It's a simple render function () => Node
|
|
139
182
|
rootNode = rootConfig();
|
|
140
183
|
targetElement.appendChild(rootNode);
|
|
141
184
|
}
|
|
142
185
|
isMounted = true;
|
|
143
186
|
// ========================================
|
|
144
|
-
//
|
|
187
|
+
// 10. Build app instance
|
|
145
188
|
// ========================================
|
|
146
|
-
// Create app instance first so plugins can use it
|
|
147
|
-
// Note: We build the object conditionally to satisfy exactOptionalPropertyTypes
|
|
148
189
|
const app = Object.assign({
|
|
149
190
|
unmount,
|
|
150
191
|
use: createAppUse(appContext),
|
|
151
192
|
stores: storesMap,
|
|
152
193
|
}, config.router ? { router: config.router } : {});
|
|
153
|
-
if (config.plugins) {
|
|
154
|
-
for (const plugin of config.plugins) {
|
|
155
|
-
if (plugin.afterMount) {
|
|
156
|
-
await plugin.afterMount(app);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
194
|
// ========================================
|
|
161
|
-
//
|
|
195
|
+
// 11. Debug utilities
|
|
162
196
|
// ========================================
|
|
163
197
|
if (isDebug && typeof window !== 'undefined') {
|
|
164
198
|
const debugUtils = {
|
|
@@ -189,14 +223,12 @@ export async function createApp(config) {
|
|
|
189
223
|
console.log('='.repeat(50));
|
|
190
224
|
}
|
|
191
225
|
// ========================================
|
|
192
|
-
//
|
|
226
|
+
// 12b. HMR support
|
|
193
227
|
// ========================================
|
|
194
228
|
const hmrHandler = getHMRHandler();
|
|
195
229
|
if (hmrHandler) {
|
|
196
230
|
hmrHandler.fullRerender = () => {
|
|
197
231
|
console.log('[LiteForge HMR] 🔄 Full app re-render (stores + router preserved)');
|
|
198
|
-
// Set cooldown immediately to block any HMR updates triggered by
|
|
199
|
-
// module re-evaluation during the synchronous remount cycle
|
|
200
232
|
if (typeof window !== 'undefined') {
|
|
201
233
|
if (window.__LITEFORGE_HMR_COOLDOWN__ !== undefined) {
|
|
202
234
|
clearTimeout(window.__LITEFORGE_HMR_COOLDOWN__);
|
|
@@ -205,10 +237,8 @@ export async function createApp(config) {
|
|
|
205
237
|
delete window.__LITEFORGE_HMR_COOLDOWN__;
|
|
206
238
|
}, 200);
|
|
207
239
|
}
|
|
208
|
-
// Preserve scroll position across the re-render
|
|
209
240
|
const scrollX = window.scrollX;
|
|
210
241
|
const scrollY = window.scrollY;
|
|
211
|
-
// Unmount current root
|
|
212
242
|
if (rootInstance) {
|
|
213
243
|
rootInstance.unmount();
|
|
214
244
|
rootInstance = null;
|
|
@@ -217,8 +247,6 @@ export async function createApp(config) {
|
|
|
217
247
|
rootNode.parentNode.removeChild(rootNode);
|
|
218
248
|
rootNode = null;
|
|
219
249
|
}
|
|
220
|
-
// Re-mount root component — all factories read latest definitions
|
|
221
|
-
// from the component registry (updated by createComponent on re-eval)
|
|
222
250
|
if (targetElement) {
|
|
223
251
|
if (isComponentFactory(config.root)) {
|
|
224
252
|
rootInstance = config.root({});
|
|
@@ -229,12 +257,11 @@ export async function createApp(config) {
|
|
|
229
257
|
targetElement.appendChild(rootNode);
|
|
230
258
|
}
|
|
231
259
|
}
|
|
232
|
-
// Restore scroll after DOM settles
|
|
233
260
|
requestAnimationFrame(() => { window.scrollTo(scrollX, scrollY); });
|
|
234
261
|
};
|
|
235
262
|
}
|
|
236
263
|
// ========================================
|
|
237
|
-
//
|
|
264
|
+
// 13. onReady callback
|
|
238
265
|
// ========================================
|
|
239
266
|
if (config.onReady) {
|
|
240
267
|
config.onReady(app);
|
|
@@ -242,70 +269,59 @@ export async function createApp(config) {
|
|
|
242
269
|
return app;
|
|
243
270
|
}
|
|
244
271
|
catch (error) {
|
|
245
|
-
// Handle bootstrap errors
|
|
246
272
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
247
273
|
if (config.onError) {
|
|
248
274
|
config.onError(err);
|
|
249
275
|
}
|
|
250
|
-
// Re-throw so the promise rejects
|
|
251
276
|
throw err;
|
|
252
277
|
}
|
|
253
|
-
//
|
|
278
|
+
// ============================================================================
|
|
254
279
|
// Internal Functions
|
|
255
|
-
//
|
|
280
|
+
// ============================================================================
|
|
256
281
|
function unmount() {
|
|
257
282
|
if (!isMounted)
|
|
258
283
|
return;
|
|
259
|
-
// Plugin
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
const appForPlugin = Object.assign({
|
|
264
|
-
unmount,
|
|
265
|
-
use: createAppUse(appContext),
|
|
266
|
-
stores: storesMap,
|
|
267
|
-
}, config.router ? { router: config.router } : {});
|
|
268
|
-
plugin.beforeUnmount(appForPlugin);
|
|
269
|
-
}
|
|
284
|
+
// Plugin cleanups in REVERSE order
|
|
285
|
+
for (let i = pluginCleanups.length - 1; i >= 0; i--) {
|
|
286
|
+
try {
|
|
287
|
+
pluginCleanups[i]();
|
|
270
288
|
}
|
|
289
|
+
catch { /* ignore cleanup errors */ }
|
|
271
290
|
}
|
|
272
291
|
// Unmount root component
|
|
273
292
|
if (rootInstance) {
|
|
274
293
|
rootInstance.unmount();
|
|
275
294
|
rootInstance = null;
|
|
276
295
|
}
|
|
277
|
-
// Remove simple render function node
|
|
278
296
|
if (rootNode && rootNode.parentNode) {
|
|
279
297
|
rootNode.parentNode.removeChild(rootNode);
|
|
280
298
|
rootNode = null;
|
|
281
299
|
}
|
|
282
|
-
// Clear target element
|
|
283
300
|
if (targetElement) {
|
|
284
301
|
targetElement.innerHTML = '';
|
|
285
302
|
}
|
|
286
303
|
// Stop router
|
|
287
|
-
if (config.router &&
|
|
304
|
+
if (config.router &&
|
|
305
|
+
'stop' in config.router &&
|
|
306
|
+
typeof config.router.stop === 'function') {
|
|
288
307
|
config.router.stop();
|
|
289
308
|
}
|
|
290
309
|
// Remove debug utilities from window
|
|
291
310
|
if (typeof window !== 'undefined' && '$lf' in window) {
|
|
292
311
|
delete window.$lf;
|
|
293
312
|
}
|
|
294
|
-
// Clear context
|
|
295
313
|
clearContext();
|
|
296
314
|
isMounted = false;
|
|
297
315
|
}
|
|
298
316
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
*/
|
|
317
|
+
// ============================================================================
|
|
318
|
+
// Helpers
|
|
319
|
+
// ============================================================================
|
|
303
320
|
function createAppUse(appContext) {
|
|
304
321
|
return function appUse(key) {
|
|
305
322
|
if (key in appContext) {
|
|
306
323
|
return appContext[key];
|
|
307
324
|
}
|
|
308
|
-
// Fall back to global use() which checks the context stack
|
|
309
325
|
return use(key);
|
|
310
326
|
};
|
|
311
327
|
}
|
package/dist/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAYH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAc3D,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,SAAS,CAAC,MAAiB;IACzC,MAAM,eAAe,GAAsB,EAAE,CAAC;IAC9C,IAAI,WAAW,GAAG,KAAK,CAAC;IAExB,MAAM,OAAO,GAAe;QAC1B,GAAG,CAAC,MAAuB;YACzB,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CACb,2DAA2D,MAAM,CAAC,IAAI,mBAAmB,CAC1F,CAAC;YACJ,CAAC;YACD,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,KAAK;YACH,IAAI,WAAW,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;YACnE,CAAC;YACD,WAAW,GAAG,IAAI,CAAC;YACnB,OAAO,eAAe,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;QAClD,CAAC;QAED,I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A6C,CAAC,GAAG,CAAC;QAC5D,CAAC;QAED,YAAY,EAAE,CAAC;QACf,SAAS,GAAG,KAAK,CAAC;IACpB,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,SAAS,YAAY,CAAC,UAAmC;IACvD,OAAO,SAAS,MAAM,CAAc,GAAW;QAC7C,IAAI,GAAG,IAAI,UAAU,EAAE,CAAC;YACtB,OAAO,UAAU,CAAC,GAAG,CAAM,CAAC;QAC9B,CAAC;QACD,OAAO,GAAG,CAAI,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/component.d.ts
CHANGED
|
@@ -18,6 +18,12 @@
|
|
|
18
18
|
* from the registry at call-time, picking up the new component/mounted/etc. fns
|
|
19
19
|
*/
|
|
20
20
|
import type { ComponentDefinition, ComponentFactory, PropDefinition, InputPropsFromSchema, Simplify } from './types.js';
|
|
21
|
+
/**
|
|
22
|
+
* Register a cleanup function to run when the current component is destroyed.
|
|
23
|
+
* Must be called synchronously during `setup()`.
|
|
24
|
+
* Outside of setup(), this is a no-op.
|
|
25
|
+
*/
|
|
26
|
+
export declare function onSetupCleanup(fn: () => void): void;
|
|
21
27
|
/**
|
|
22
28
|
* Create a component factory from a component definition.
|
|
23
29
|
*
|
package/dist/component.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAEhB,cAAc,EACd,oBAAoB,EACpB,QAAQ,EACT,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAEhB,cAAc,E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,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAKrG"}
|
package/dist/component.js
CHANGED
|
@@ -22,6 +22,16 @@ import { use, withContext } from './context.js';
|
|
|
22
22
|
import { registerComponent, getLatestDefinition } from './hmr.js';
|
|
23
23
|
// Track parent component for debug hierarchy
|
|
24
24
|
let currentParentComponentId;
|
|
25
|
+
// Setup-scope cleanup registry — populated during setup(), drained on unmount()
|
|
26
|
+
let currentSetupCleanups = null;
|
|
27
|
+
/**
|
|
28
|
+
* Register a cleanup function to run when the current component is destroyed.
|
|
29
|
+
* Must be called synchronously during `setup()`.
|
|
30
|
+
* Outside of setup(), this is a no-op.
|
|
31
|
+
*/
|
|
32
|
+
export function onSetupCleanup(fn) {
|
|
33
|
+
currentSetupCleanups?.push(fn);
|
|
34
|
+
}
|
|
25
35
|
// Check if we're in development mode
|
|
26
36
|
const isDev = typeof import.meta !== 'undefined' && import.meta.env?.DEV === true;
|
|
27
37
|
// ============================================================================
|
|
@@ -76,6 +86,7 @@ function createComponentInstance(definition, inputProps) {
|
|
|
76
86
|
let setupResult;
|
|
77
87
|
let loadedData;
|
|
78
88
|
let mountedCleanup;
|
|
89
|
+
const setupCleanups = [];
|
|
79
90
|
const hasProvide = Boolean(definition.provide);
|
|
80
91
|
let provideContext;
|
|
81
92
|
// currentDefinition is the frozen import binding. In dev mode with an hmrId
|
|
@@ -88,7 +99,10 @@ function createComponentInstance(definition, inputProps) {
|
|
|
88
99
|
// Phase 1: Setup (synchronous)
|
|
89
100
|
// ========================================
|
|
90
101
|
if (currentDefinition.setup) {
|
|
102
|
+
const prevCleanups = currentSetupCleanups;
|
|
103
|
+
currentSetupCleanups = setupCleanups;
|
|
91
104
|
setupResult = currentDefinition.setup({ props, use });
|
|
105
|
+
currentSetupCleanups = prevCleanups;
|
|
92
106
|
}
|
|
93
107
|
// ========================================
|
|
94
108
|
// Lifecycle Methods
|
|
@@ -139,6 +153,14 @@ function createComponentInstance(definition, inputProps) {
|
|
|
139
153
|
if (currentDefinition.destroyed) {
|
|
140
154
|
currentDefinition.destroyed({ props, setup: setupResult });
|
|
141
155
|
}
|
|
156
|
+
// Run setup-scope cleanups (registered via onSetupCleanup during setup())
|
|
157
|
+
for (let i = setupCleanups.length - 1; i >= 0; i--) {
|
|
158
|
+
try {
|
|
159
|
+
setupCleanups[i]();
|
|
160
|
+
}
|
|
161
|
+
catch { /* ignore */ }
|
|
162
|
+
}
|
|
163
|
+
setupCleanups.length = 0;
|
|
142
164
|
// Run mounted cleanup
|
|
143
165
|
if (mountedCleanup) {
|
|
144
166
|
mountedCleanup();
|
package/dist/component.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAElE,6CAA6C;AAC7C,IAAI,wBAA4C,CAAC;AAEjD,qCAAqC;AACrC,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;AAElF,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E,IAAW,cAOV;AAPD,WAAW,cAAc;IACvB,yDAAO,CAAA;IACP,yDAAO,CAAA;IACP,uDAAM,CAAA;IACN,qDAAK,CAAA;IACL,yDAAO,CAAA;IACP,6DAAS,CAAA;AACX,CAAC,EAPU,cAAc,KAAd,cAAc,QAOxB;AAsDD,iBAAiB;AACjB,MAAM,UAAU,eAAe,CAI7B,UAAwC;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AC,IAAI,CAAC,kBAAkB,GAAG,cAAc,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,QAAa,CAAC;AACvB,CAAC;AAED,+EAA+E;AAC/E,iDAAiD;AACjD,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,OAAO,KAAK,KAAK,UAAU;QAC1B,KAAmD,CAAC,qBAAqB,KAAK,IAAI,CACpF,CAAC;AACJ,CAAC"}
|
package/dist/control-flow.d.ts
CHANGED
|
@@ -16,8 +16,9 @@ export interface ShowConfig<T = unknown> {
|
|
|
16
16
|
}
|
|
17
17
|
export declare function Show<T>(config: ShowConfig<T>): Node;
|
|
18
18
|
/**
|
|
19
|
-
* Config for For component
|
|
20
|
-
*
|
|
19
|
+
* Config for For component.
|
|
20
|
+
* children receives plain values — the Vite plugin transforms item.x to () => item().x
|
|
21
|
+
* at compile time. Internally, For still uses signal-backed getters for performance.
|
|
21
22
|
*/
|
|
22
23
|
export interface ForConfig<T> {
|
|
23
24
|
each: (() => ReadonlyArray<T>) | (() => T[]) | ReadonlyArray<T> | T[];
|
|
@@ -28,17 +29,21 @@ export interface ForConfig<T> {
|
|
|
28
29
|
/**
|
|
29
30
|
* Render a list of items with keyed reconciliation.
|
|
30
31
|
*
|
|
32
|
+
* When items reorder, DOM nodes are moved (not destroyed/recreated).
|
|
33
|
+
* When item data changes, the item signal is updated and reactive bindings auto-update.
|
|
34
|
+
*
|
|
31
35
|
* @typeParam T - The item type, inferred from the `each` array
|
|
32
36
|
*
|
|
33
37
|
* @example
|
|
34
38
|
* ```ts
|
|
35
39
|
* For({
|
|
36
40
|
* each: () => users(),
|
|
37
|
-
* key:
|
|
41
|
+
* key: (user) => user.id,
|
|
38
42
|
* children: (user, index) => {
|
|
39
|
-
*
|
|
43
|
+
* // user() and index() are getters - read them inside reactive contexts
|
|
44
|
+
* return <div>{() => `${index()}: ${user().name}`}</div>;
|
|
40
45
|
* },
|
|
41
|
-
* fallback: () =>
|
|
46
|
+
* fallback: () => <div>No users</div>,
|
|
42
47
|
* })
|
|
43
48
|
* ```
|
|
44
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-flow.d.ts","sourceRoot":"","sources":["../src/control-flow.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAqB,gBAAgB,EAA4B,cAAc,EAAE,MAAM,YAAY,CAAC;AAsChH;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAC3C;AA6BD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CA0EnD;
|
|
1
|
+
{"version":3,"file":"control-flow.d.ts","sourceRoot":"","sources":["../src/control-flow.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAqB,gBAAgB,EAA4B,cAAc,EAAE,MAAM,YAAY,CAAC;AAsChH;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,GAAG,OAAO;IACrC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;CAC3C;AA6BD,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CA0EnD;AASD;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,IAAI,EA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