@fluixi/core 1.0.0-alpha.82 → 1.0.0-alpha.84
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/cdn/core.global.js +2 -1
- package/dist/cli/generate.cjs +4117 -292
- package/dist/cli/generate.mjs +4122 -292
- package/dist/cli/index.cjs +4117 -292
- package/dist/cli/index.mjs +4122 -292
- package/dist/cli/run.cjs +63 -1
- package/dist/cli/run.mjs +39 -1
- package/dist/src/cdn/chunk-VNLCQBFQ.mjs +747 -0
- package/dist/src/cdn/core.cjs +1279 -1
- package/dist/src/cdn/core.d.ts +3 -3
- package/dist/src/cdn/core.js +3 -3
- package/dist/src/cdn/core.mjs +642 -1
- package/dist/src/cdn/router-WMN2AA7E.mjs +66 -0
- package/dist/src/index.cjs +1201 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -11
- package/dist/src/index.mjs +1313 -1
- package/dist/src/jsx-dev-runtime.cjs +26 -1
- package/dist/src/jsx-dev-runtime.mjs +24 -1
- package/dist/src/jsx-runtime.cjs +26 -1
- package/dist/src/jsx-runtime.js +0 -9
- package/dist/src/jsx-runtime.mjs +24 -1
- package/dist/src/lib/client/chunk-2C2KDDQV.mjs +133 -0
- package/dist/src/lib/client/index.cjs +870 -1
- package/dist/src/lib/client/index.d.ts +10 -14
- package/dist/src/lib/client/index.d.ts.map +1 -1
- package/dist/src/lib/client/index.js +36 -21
- package/dist/src/lib/client/index.mjs +222 -1
- package/dist/src/lib/client/router-X526HSWQ.mjs +548 -0
- package/dist/src/lib/context/context.cjs +118 -1
- package/dist/src/lib/context/context.d.ts +20 -38
- package/dist/src/lib/context/context.d.ts.map +1 -1
- package/dist/src/lib/context/context.js +10 -47
- package/dist/src/lib/context/context.mjs +99 -1
- package/dist/src/lib/context/index.cjs +120 -1
- package/dist/src/lib/context/index.mjs +99 -1
- package/dist/src/lib/control-flow.cjs +35 -1
- package/dist/src/lib/control-flow.mjs +25 -1
- package/dist/src/lib/core.cjs +1200 -1
- package/dist/src/lib/core.d.ts +0 -2
- package/dist/src/lib/core.d.ts.map +1 -1
- package/dist/src/lib/core.js +14 -48
- package/dist/src/lib/core.mjs +1313 -1
- package/dist/src/lib/env/index.cjs +60 -1
- package/dist/src/lib/env/index.d.ts +7 -8
- package/dist/src/lib/env/index.d.ts.map +1 -1
- package/dist/src/lib/env/index.js +14 -9
- package/dist/src/lib/env/index.mjs +39 -1
- package/dist/src/lib/i18n/index.cjs +108 -1
- package/dist/src/lib/i18n/index.d.ts +31 -10
- package/dist/src/lib/i18n/index.d.ts.map +1 -1
- package/dist/src/lib/i18n/index.js +31 -10
- package/dist/src/lib/i18n/index.mjs +88 -1
- package/dist/src/lib/index.cjs +633 -1
- package/dist/src/lib/index.d.ts +0 -2
- package/dist/src/lib/index.d.ts.map +1 -1
- package/dist/src/lib/index.js +5 -11
- package/dist/src/lib/index.mjs +721 -1
- package/dist/src/lib/isomorphic.cjs +85 -1
- package/dist/src/lib/isomorphic.d.ts +41 -8
- package/dist/src/lib/isomorphic.d.ts.map +1 -1
- package/dist/src/lib/isomorphic.js +38 -5
- package/dist/src/lib/isomorphic.mjs +64 -1
- package/dist/src/lib/jsx-runtime/index.cjs +21 -1
- package/dist/src/lib/jsx-runtime/index.d.ts +1 -1
- package/dist/src/lib/jsx-runtime/index.js +1 -11
- package/dist/src/lib/jsx-runtime/index.mjs +4 -1
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -1
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -1
- package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -8
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +15 -1
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -1
- package/dist/src/lib/plugins/fluixi-routes-plugin.js +19 -5
- package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -8
- package/dist/src/lib/plugins/index.cjs +311 -8
- package/dist/src/lib/plugins/index.mjs +279 -8
- package/dist/src/lib/plugins/route-codegen.cjs +73 -8
- package/dist/src/lib/plugins/route-codegen.d.ts +0 -1
- package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -1
- package/dist/src/lib/plugins/route-codegen.js +4 -5
- package/dist/src/lib/plugins/route-codegen.mjs +52 -8
- package/dist/src/lib/plugins/route-scanner.cjs +189 -1
- package/dist/src/lib/plugins/route-scanner.d.ts +1 -2
- package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -1
- package/dist/src/lib/plugins/route-scanner.js +7 -8
- package/dist/src/lib/plugins/route-scanner.mjs +158 -1
- package/dist/src/lib/plugins/vite.cjs +27 -1
- package/dist/src/lib/plugins/vite.mjs +6 -1
- package/dist/src/lib/render/await.cjs +38 -1
- package/dist/src/lib/render/await.d.ts +18 -0
- package/dist/src/lib/render/await.d.ts.map +1 -1
- package/dist/src/lib/render/await.js +20 -2
- package/dist/src/lib/render/await.mjs +17 -1
- package/dist/src/lib/render/component.cjs +221 -1
- package/dist/src/lib/render/component.d.ts +3 -44
- package/dist/src/lib/render/component.d.ts.map +1 -1
- package/dist/src/lib/render/component.js +32 -59
- package/dist/src/lib/render/component.mjs +214 -1
- package/dist/src/lib/render/deferred.cjs +175 -1
- package/dist/src/lib/render/deferred.d.ts.map +1 -1
- package/dist/src/lib/render/deferred.js +8 -8
- package/dist/src/lib/render/deferred.mjs +158 -1
- package/dist/src/lib/render/index.cjs +573 -1
- package/dist/src/lib/render/index.d.ts +3 -17
- package/dist/src/lib/render/index.d.ts.map +1 -1
- package/dist/src/lib/render/index.js +12 -26
- package/dist/src/lib/render/index.mjs +590 -1
- package/dist/src/lib/render/lazy.cjs +67 -1
- package/dist/src/lib/render/lazy.d.ts +22 -1
- package/dist/src/lib/render/lazy.d.ts.map +1 -1
- package/dist/src/lib/render/lazy.js +47 -8
- package/dist/src/lib/render/lazy.mjs +50 -1
- package/dist/src/lib/render/suspense.cjs +141 -1
- package/dist/src/lib/render/suspense.d.ts +40 -0
- package/dist/src/lib/render/suspense.d.ts.map +1 -1
- package/dist/src/lib/render/suspense.js +47 -7
- package/dist/src/lib/render/suspense.mjs +136 -1
- package/dist/src/lib/render/versions.cjs +35 -1
- package/dist/src/lib/render/versions.js +6 -6
- package/dist/src/lib/render/versions.mjs +14 -1
- package/dist/src/lib/router/data.cjs +230 -1
- package/dist/src/lib/router/data.d.ts +1 -13
- package/dist/src/lib/router/data.d.ts.map +1 -1
- package/dist/src/lib/router/data.js +1 -13
- package/dist/src/lib/router/data.mjs +214 -1
- package/dist/src/lib/router/index.cjs +627 -1
- package/dist/src/lib/router/index.d.ts +62 -10
- package/dist/src/lib/router/index.d.ts.map +1 -1
- package/dist/src/lib/router/index.js +90 -39
- package/dist/src/lib/router/index.mjs +639 -1
- package/dist/src/lib/server/hydration.cjs +169 -1
- package/dist/src/lib/server/hydration.d.ts +15 -55
- package/dist/src/lib/server/hydration.d.ts.map +1 -1
- package/dist/src/lib/server/hydration.js +23 -62
- package/dist/src/lib/server/hydration.mjs +148 -1
- package/dist/src/lib/server/index.cjs +401 -11
- package/dist/src/lib/server/index.d.ts +30 -6
- package/dist/src/lib/server/index.d.ts.map +1 -1
- package/dist/src/lib/server/index.js +34 -11
- package/dist/src/lib/server/index.mjs +379 -11
- package/dist/src/lib/server/reactive.cjs +197 -1
- package/dist/src/lib/server/reactive.d.ts +18 -77
- package/dist/src/lib/server/reactive.d.ts.map +1 -1
- package/dist/src/lib/server/reactive.js +19 -78
- package/dist/src/lib/server/reactive.mjs +176 -1
- package/dist/src/lib/theme/index.cjs +110 -1
- package/dist/src/lib/theme/index.d.ts +19 -4
- package/dist/src/lib/theme/index.d.ts.map +1 -1
- package/dist/src/lib/theme/index.js +17 -2
- package/dist/src/lib/theme/index.mjs +89 -1
- package/dist/src/lib/utils/index.cjs +209 -1
- package/dist/src/lib/utils/index.d.ts +0 -93
- package/dist/src/lib/utils/index.d.ts.map +1 -1
- package/dist/src/lib/utils/index.js +0 -93
- package/dist/src/lib/utils/index.mjs +188 -1
- package/dist/src/routes.cjs +37 -1
- package/dist/src/routes.d.ts +1 -1
- package/dist/src/routes.js +2 -2
- package/dist/src/routes.mjs +17 -1
- package/dist/src/server.cjs +400 -11
- package/dist/src/server.d.ts +0 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +0 -1
- package/dist/src/server.mjs +377 -11
- package/dist/src/utils.cjs +21 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.js +1 -1
- package/dist/src/utils.mjs +4 -1
- package/dist/src/version.generated.cjs +26 -1
- package/dist/src/version.generated.d.ts +1 -1
- package/dist/src/version.generated.js +2 -2
- package/dist/src/version.generated.mjs +5 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/index.ts +2 -14
- package/dist/src/cdn/chunk-RN7C7HNS.mjs +0 -1
- package/dist/src/cdn/router-QB3W43UQ.mjs +0 -1
- package/dist/src/lib/client/chunk-FT22BLCQ.mjs +0 -1
- package/dist/src/lib/client/router-IH7JYMRU.mjs +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Client-Side Rendering Entry Point for Fluixi
|
|
3
2
|
* @module @fluixi/core/client
|
|
4
3
|
*
|
|
5
4
|
* Implements client-side mounting and hydration logic using @fluixi/dom runtime.
|
|
@@ -9,9 +8,6 @@ import '../render/versions.js';
|
|
|
9
8
|
/**
|
|
10
9
|
* Mount application to DOM (Client-side Rendering)
|
|
11
10
|
*
|
|
12
|
-
* @param App Root component function
|
|
13
|
-
* @param container DOM element to mount into
|
|
14
|
-
*
|
|
15
11
|
* @example
|
|
16
12
|
* ```typescript
|
|
17
13
|
* import { mount } from '@fluixi/core/client';
|
|
@@ -28,27 +24,27 @@ export interface StartClientOptions {
|
|
|
28
24
|
/** Force hydration mode. Default: auto-detect from __FLUIXI_HYDRATION__ marker */
|
|
29
25
|
hydrate?: boolean;
|
|
30
26
|
/**
|
|
31
|
-
* The app's route tree (the same array passed to <Router routes={
|
|
27
|
+
* The app's route tree (the same array passed to <Router routes={...}/>). When provided,
|
|
32
28
|
* the lazy chunk(s) for the route matching the current URL are downloaded and awaited
|
|
33
|
-
*
|
|
29
|
+
* before hydration, so each lazy file-route resolves synchronously and adopts the server
|
|
34
30
|
* DOM in place (no fallback, no duplicate). Passing this also enables auto-hydration of a
|
|
35
31
|
* server-rendered (non-empty) root, giving flash-free hydration with zero extra config.
|
|
36
32
|
*/
|
|
37
33
|
routes?: any[];
|
|
38
34
|
}
|
|
39
35
|
/**
|
|
40
|
-
*
|
|
36
|
+
* Mount or hydrate an app in the browser.
|
|
37
|
+
*
|
|
38
|
+
* Hydration is detected from the marker the server render leaves behind, so the same
|
|
39
|
+
* call works for a server-rendered page and a plain SPA. Pass `hydrate` to force it.
|
|
41
40
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
41
|
+
* Pass `routes` for a file-routed app. The chunks for the route matching the current URL
|
|
42
|
+
* are downloaded and awaited before hydrating, which is what lets each lazy route resolve
|
|
43
|
+
* synchronously and adopt the server's DOM rather than building a second copy beside it.
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
46
|
* ```ts
|
|
47
|
-
*
|
|
48
|
-
* import { startClient } from '@fluixi/core/client';
|
|
49
|
-
* import App from './app';
|
|
50
|
-
*
|
|
51
|
-
* startClient(App);
|
|
47
|
+
* await startClient(App, { root: '#app', routes });
|
|
52
48
|
* ```
|
|
53
49
|
*/
|
|
54
50
|
export declare function startClient(App: (props?: any) => any, options?: StartClientOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/client/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/client/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,uBAAuB,CAAC;AAgB/B;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,QAOlE;AAED,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,WAAW,kBAAkB;IACjC,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC5B,kFAAkF;IAClF,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;CAChB;AAoBD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,WAAW,CAC/B,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,GAAG,KAAK,GAAG,EACzB,OAAO,GAAE,kBAAuB,iBAgEjC"}
|
|
@@ -1,32 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @fileoverview Client-Side Rendering Entry Point for Fluixi
|
|
3
2
|
* @module @fluixi/core/client
|
|
4
3
|
*
|
|
5
4
|
* Implements client-side mounting and hydration logic using @fluixi/dom runtime.
|
|
6
5
|
* Supports both JSX and Lit HTML.
|
|
7
6
|
*/
|
|
8
|
-
// import {
|
|
9
|
-
// cleanupHydration,
|
|
10
|
-
// deserializeHydrationData,
|
|
11
|
-
// } from '../server/hydration.js';
|
|
12
7
|
import { render as domRender, hydrate as domHydrate, } from '@fluixi/dom';
|
|
13
8
|
// Registers core's version with the DOM runtime, which does the stamping. This entry is a
|
|
14
|
-
// separate subpath, so it does not otherwise load core's render
|
|
9
|
+
// separate subpath, so it does not otherwise load core's render, and without this the
|
|
15
10
|
// hydrate path stamped `fx-dom`/`fx-reactive` but never `fluixi`.
|
|
16
11
|
import '../render/versions.js';
|
|
17
12
|
import { deserializeHydrationData, setHydrating, cleanupHydration, } from '../server/hydration.js';
|
|
18
13
|
import { render } from '../render/index.js';
|
|
14
|
+
import { createComponent } from '../render/component.js';
|
|
15
|
+
import { createMemo } from '@fluixi/reactive/signal';
|
|
19
16
|
import { createHead, setActiveHead, mountHead, stripHeadMarker } from '@fluixi/head';
|
|
20
17
|
// Connect the reactive system (signals, effects, batch) to the DOM runtime.
|
|
21
18
|
// Without this, createRenderEffect in @fluixi/dom is a one-shot call that never
|
|
22
|
-
// re-runs when signals change
|
|
19
|
+
// re-runs when signals change: breaking all JSX reactive updates.
|
|
23
20
|
// ensureIntegration();
|
|
24
21
|
/**
|
|
25
22
|
* Mount application to DOM (Client-side Rendering)
|
|
26
23
|
*
|
|
27
|
-
* @param App Root component function
|
|
28
|
-
* @param container DOM element to mount into
|
|
29
|
-
*
|
|
30
24
|
* @example
|
|
31
25
|
* ```typescript
|
|
32
26
|
* import { mount } from '@fluixi/core/client';
|
|
@@ -58,6 +52,23 @@ export { hydrate } from '@fluixi/dom';
|
|
|
58
52
|
* startClient(App);
|
|
59
53
|
* ```
|
|
60
54
|
*/
|
|
55
|
+
/** The root, entered the way the compiler enters every other component. */
|
|
56
|
+
const rootOf = (App) => createMemo(() => createComponent(App));
|
|
57
|
+
/**
|
|
58
|
+
* Mount or hydrate an app in the browser.
|
|
59
|
+
*
|
|
60
|
+
* Hydration is detected from the marker the server render leaves behind, so the same
|
|
61
|
+
* call works for a server-rendered page and a plain SPA. Pass `hydrate` to force it.
|
|
62
|
+
*
|
|
63
|
+
* Pass `routes` for a file-routed app. The chunks for the route matching the current URL
|
|
64
|
+
* are downloaded and awaited before hydrating, which is what lets each lazy route resolve
|
|
65
|
+
* synchronously and adopt the server's DOM rather than building a second copy beside it.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* await startClient(App, { root: '#app', routes });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
61
72
|
export async function startClient(App, options = {}) {
|
|
62
73
|
const container = typeof options.root === 'string'
|
|
63
74
|
? document.querySelector(options.root)
|
|
@@ -66,27 +77,27 @@ export async function startClient(App, options = {}) {
|
|
|
66
77
|
throw new Error(`[Fluixi] Mount container not found: ${options.root ?? '#app'}`);
|
|
67
78
|
}
|
|
68
79
|
// Hydrate when explicitly requested (`{ hydrate: true }`), when the server emits the
|
|
69
|
-
// `__FLUIXI_HYDRATION__` marker, or
|
|
80
|
+
// `__FLUIXI_HYDRATION__` marker, or, with a route tree in hand, when the mount root already
|
|
70
81
|
// holds server-rendered content. A non-empty root means SSR/SSG ran, so reuse that DOM instead
|
|
71
82
|
// of clearing and re-rendering (which flashes). Auto-hydration is gated on `routes` because
|
|
72
83
|
// hydrating an app with async lazy file-routes is only safe once those chunks are preloaded
|
|
73
|
-
// (below)
|
|
74
|
-
// client-only app mounts into an empty `<div id="root">` (firstElementChild null)
|
|
84
|
+
// (below): without the route tree we can't preload, so we fall back to the render() path. A
|
|
85
|
+
// client-only app mounts into an empty `<div id="root">` (firstElementChild null) -> client render.
|
|
75
86
|
const hasServerDom = !!document.getElementById('__FLUIXI_HYDRATION__') ||
|
|
76
87
|
(!!options.routes && container.firstElementChild != null);
|
|
77
88
|
const shouldHydrate = options.hydrate ?? hasServerDom;
|
|
78
|
-
// Active head registry for this document
|
|
89
|
+
// Active head registry for this document: seo()/useHead() during the app render register here;
|
|
79
90
|
// mountHead reconciles it into <head> after mount (reusing server tags by key) and keeps it live.
|
|
80
91
|
const head = createHead();
|
|
81
92
|
setActiveHead(head);
|
|
82
|
-
// Drop a stray `<!--fh
|
|
93
|
+
// Drop a stray `<!--fh:...-->` head-transport comment if the server left one in the mount root
|
|
83
94
|
// (streaming / custom servers that don't lift it into <head>). It would otherwise be the cursor's
|
|
84
|
-
// first node and strand hydration
|
|
95
|
+
// first node and strand hydration: rebuilding the whole tree as a duplicate. Harmless no-op when
|
|
85
96
|
// the server already extracted it (the supported adapter/prerender/dev paths do).
|
|
86
97
|
stripHeadMarker(container);
|
|
87
98
|
if (shouldHydrate) {
|
|
88
99
|
// Preload the lazy chunk(s) for the current route so they resolve synchronously during the
|
|
89
|
-
// hydration render
|
|
100
|
+
// hydration render, the lazy boundary then adopts the server DOM in place instead of
|
|
90
101
|
// resolving a tick later and rebuilding a duplicate. Dynamic import keeps the router out of
|
|
91
102
|
// client-only bundles that never pass `routes`.
|
|
92
103
|
if (options.routes && options.routes.length) {
|
|
@@ -95,9 +106,13 @@ export async function startClient(App, options = {}) {
|
|
|
95
106
|
}
|
|
96
107
|
deserializeHydrationData();
|
|
97
108
|
setHydrating(true);
|
|
98
|
-
|
|
109
|
+
// A memo around createComponent, which is what compiled JSX emits for every other
|
|
110
|
+
// component. Called directly, the root is the one component the runtime never hears
|
|
111
|
+
// about: nothing holds its return value, so no node is made and a graph of the
|
|
112
|
+
// application starts at whatever the root happened to render.
|
|
113
|
+
domHydrate(rootOf(App), container);
|
|
99
114
|
// Handlers are now wired (delegated $$listeners attach during the hydration
|
|
100
|
-
// render)
|
|
115
|
+
// render): replay any events the user fired before hydration.
|
|
101
116
|
replayEvents();
|
|
102
117
|
setTimeout(() => {
|
|
103
118
|
setHydrating(false);
|
|
@@ -105,14 +120,14 @@ export async function startClient(App, options = {}) {
|
|
|
105
120
|
}, 100);
|
|
106
121
|
}
|
|
107
122
|
else {
|
|
108
|
-
render((
|
|
123
|
+
render(rootOf(App), container);
|
|
109
124
|
}
|
|
110
125
|
mountHead(head);
|
|
111
126
|
}
|
|
112
127
|
/**
|
|
113
128
|
* Replay events captured before hydration by the server's eventCaptureScript
|
|
114
129
|
* (window.__FX_REPLAY__). Hydration REUSES the server DOM, so each recorded target
|
|
115
|
-
* is still live
|
|
130
|
+
* is still live: re-dispatch a synthetic event on it so the app's delegated
|
|
116
131
|
* handlers fire. Discrete events only (click/input/change/submit/keydown). No-op
|
|
117
132
|
* when the capture script wasn't emitted (no queue).
|
|
118
133
|
*/
|
|
@@ -1 +1,222 @@
|
|
|
1
|
-
|
|
1
|
+
/*! @fluixi/core v1.0.0-alpha.84 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
|
|
2
|
+
import {
|
|
3
|
+
cleanupHydration,
|
|
4
|
+
deserializeHydrationData,
|
|
5
|
+
setHydrating
|
|
6
|
+
} from "./chunk-2C2KDDQV.mjs";
|
|
7
|
+
|
|
8
|
+
// src/lib/client/index.ts
|
|
9
|
+
import {
|
|
10
|
+
render as domRender,
|
|
11
|
+
hydrate as domHydrate
|
|
12
|
+
} from "@fluixi/dom";
|
|
13
|
+
|
|
14
|
+
// src/lib/render/versions.ts
|
|
15
|
+
import { registerCoreVersion } from "@fluixi/dom";
|
|
16
|
+
|
|
17
|
+
// src/version.generated.ts
|
|
18
|
+
var VERSION = "1.0.0-alpha.84";
|
|
19
|
+
|
|
20
|
+
// src/lib/render/versions.ts
|
|
21
|
+
import { stampVersions, warnOnVersionSkew, versions } from "@fluixi/dom";
|
|
22
|
+
registerCoreVersion(VERSION);
|
|
23
|
+
|
|
24
|
+
// src/lib/render/index.ts
|
|
25
|
+
import { isServer as isServer3 } from "@fluixi/dom";
|
|
26
|
+
import { createRoot as createRoot2 } from "@fluixi/reactive/signal";
|
|
27
|
+
import {
|
|
28
|
+
isDOMNode,
|
|
29
|
+
delegateEvents,
|
|
30
|
+
insert
|
|
31
|
+
} from "@fluixi/dom";
|
|
32
|
+
|
|
33
|
+
// src/lib/render/component.ts
|
|
34
|
+
import { isServer } from "@fluixi/dom";
|
|
35
|
+
import {
|
|
36
|
+
createComponent as domCreateComponent,
|
|
37
|
+
asComponent
|
|
38
|
+
} from "@fluixi/dom";
|
|
39
|
+
import {
|
|
40
|
+
untrack,
|
|
41
|
+
onCleanup,
|
|
42
|
+
getOwner,
|
|
43
|
+
createEffect,
|
|
44
|
+
createMemo,
|
|
45
|
+
createSignal,
|
|
46
|
+
isSignal,
|
|
47
|
+
batch,
|
|
48
|
+
runWithOwner,
|
|
49
|
+
isOwnerDisposed
|
|
50
|
+
} from "@fluixi/reactive/signal";
|
|
51
|
+
function createComponent(Comp, props) {
|
|
52
|
+
return domCreateComponent(Comp, props);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/lib/render/suspense.ts
|
|
56
|
+
import {
|
|
57
|
+
createSignal as createSignal2,
|
|
58
|
+
createMemo as createMemo2,
|
|
59
|
+
createEffect as createEffect2,
|
|
60
|
+
createRenderEffect as createRenderEffect2,
|
|
61
|
+
isSignal as isSignal2,
|
|
62
|
+
readChildren,
|
|
63
|
+
useContext as useContext2,
|
|
64
|
+
createContext as createContext2,
|
|
65
|
+
createSuspenseBoundary,
|
|
66
|
+
provideSuspense
|
|
67
|
+
} from "@fluixi/reactive/signal";
|
|
68
|
+
import {
|
|
69
|
+
asSuspense,
|
|
70
|
+
isComponent,
|
|
71
|
+
createComponent as createComponent2,
|
|
72
|
+
runWithoutHydration
|
|
73
|
+
} from "@fluixi/dom";
|
|
74
|
+
function isPromise(value) {
|
|
75
|
+
return !!(value && typeof value === "object" && typeof value.then === "function" || value instanceof Promise);
|
|
76
|
+
}
|
|
77
|
+
var SuspenseListContext = createContext2(void 0, "suspense-list");
|
|
78
|
+
function Suspense(props) {
|
|
79
|
+
return createComponent2(SuspenseImpl, props);
|
|
80
|
+
}
|
|
81
|
+
function SuspenseImpl(props) {
|
|
82
|
+
const boundary = createSuspenseBoundary();
|
|
83
|
+
const listCtx = useContext2(SuspenseListContext);
|
|
84
|
+
const listState = listCtx ? listCtx.register(boundary.inFallback) : void 0;
|
|
85
|
+
function instantiateOnce(val) {
|
|
86
|
+
if (val == null || typeof val === "boolean") return null;
|
|
87
|
+
if (typeof val === "function" && isComponent(val) && !isSignal2(val)) return val();
|
|
88
|
+
return val;
|
|
89
|
+
}
|
|
90
|
+
const fallback = runWithoutHydration(() => instantiateOnce(props.fallback ?? null));
|
|
91
|
+
const children = provideSuspense(boundary, () => readChildren(() => props.children));
|
|
92
|
+
const track = (value, depth) => {
|
|
93
|
+
if (depth > 8) return;
|
|
94
|
+
if (Array.isArray(value)) {
|
|
95
|
+
for (const x of value) track(x, depth + 1);
|
|
96
|
+
} else if (typeof value === "function" && isSignal2(value)) {
|
|
97
|
+
track(value(), depth + 1);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
provideSuspense(boundary, () => {
|
|
101
|
+
createRenderEffect2(() => track(children, 0));
|
|
102
|
+
});
|
|
103
|
+
const [resolved, setResolved] = createSignal2(void 0);
|
|
104
|
+
const childIsPromise = isPromise(children);
|
|
105
|
+
if (childIsPromise) {
|
|
106
|
+
boundary.increment();
|
|
107
|
+
children.then(
|
|
108
|
+
(v) => {
|
|
109
|
+
setResolved(() => v);
|
|
110
|
+
boundary.decrement();
|
|
111
|
+
},
|
|
112
|
+
() => boundary.decrement()
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
return createMemo2(() => {
|
|
116
|
+
const showFallback = listState ? listState.showFallback() : boundary.inFallback();
|
|
117
|
+
if (showFallback) return fallback;
|
|
118
|
+
if (childIsPromise) return resolved();
|
|
119
|
+
return children;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
asSuspense(Suspense);
|
|
123
|
+
Object.defineProperty(Suspense, "__suspense", { value: true, enumerable: true });
|
|
124
|
+
|
|
125
|
+
// src/lib/render/deferred.ts
|
|
126
|
+
import { isServer as isServer2 } from "@fluixi/dom";
|
|
127
|
+
import { createMemo as createMemo3, createSignal as createSignal3 } from "@fluixi/reactive/signal";
|
|
128
|
+
import { observeIntersection } from "@fluixi/dom/utils";
|
|
129
|
+
|
|
130
|
+
// src/lib/render/await.ts
|
|
131
|
+
import { createResource as createResource2 } from "@fluixi/reactive/signal";
|
|
132
|
+
|
|
133
|
+
// src/lib/render/index.ts
|
|
134
|
+
function render(code, container, options = {}) {
|
|
135
|
+
delegateEvents(["click", "input", "change", "submit"]);
|
|
136
|
+
if (isServer3()) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
"render() is for client-side only. Use renderToString() on server."
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
if (!container) {
|
|
142
|
+
throw new Error("Container element is required");
|
|
143
|
+
}
|
|
144
|
+
let disposer;
|
|
145
|
+
createRoot2((dispose) => {
|
|
146
|
+
disposer = dispose;
|
|
147
|
+
const result = typeof code === "function" ? code() : code;
|
|
148
|
+
container.textContent = "";
|
|
149
|
+
stampVersions(container);
|
|
150
|
+
warnOnVersionSkew();
|
|
151
|
+
insert(container, () => result);
|
|
152
|
+
});
|
|
153
|
+
return () => {
|
|
154
|
+
if (disposer) {
|
|
155
|
+
disposer();
|
|
156
|
+
disposer = void 0;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// src/lib/client/index.ts
|
|
162
|
+
import { createMemo as createMemo4 } from "@fluixi/reactive/signal";
|
|
163
|
+
import { createHead, setActiveHead, mountHead, stripHeadMarker } from "@fluixi/head";
|
|
164
|
+
import { hydrate } from "@fluixi/dom";
|
|
165
|
+
function mount(App, container) {
|
|
166
|
+
if (!container) {
|
|
167
|
+
throw new Error("Container element not found for mount()");
|
|
168
|
+
}
|
|
169
|
+
domRender(() => App(), container);
|
|
170
|
+
}
|
|
171
|
+
var rootOf = (App) => createMemo4(() => createComponent(App));
|
|
172
|
+
async function startClient(App, options = {}) {
|
|
173
|
+
const container = typeof options.root === "string" ? document.querySelector(options.root) : options.root ?? document.querySelector("#app");
|
|
174
|
+
if (!container) {
|
|
175
|
+
throw new Error(
|
|
176
|
+
`[Fluixi] Mount container not found: ${options.root ?? "#app"}`
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
const hasServerDom = !!document.getElementById("__FLUIXI_HYDRATION__") || !!options.routes && container.firstElementChild != null;
|
|
180
|
+
const shouldHydrate = options.hydrate ?? hasServerDom;
|
|
181
|
+
const head = createHead();
|
|
182
|
+
setActiveHead(head);
|
|
183
|
+
stripHeadMarker(container);
|
|
184
|
+
if (shouldHydrate) {
|
|
185
|
+
if (options.routes && options.routes.length) {
|
|
186
|
+
const { preloadRoutes } = await import("./router-X526HSWQ.mjs");
|
|
187
|
+
await preloadRoutes(options.routes, window.location.pathname);
|
|
188
|
+
}
|
|
189
|
+
deserializeHydrationData();
|
|
190
|
+
setHydrating(true);
|
|
191
|
+
domHydrate(rootOf(App), container);
|
|
192
|
+
replayEvents();
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
setHydrating(false);
|
|
195
|
+
cleanupHydration();
|
|
196
|
+
}, 100);
|
|
197
|
+
} else {
|
|
198
|
+
render(rootOf(App), container);
|
|
199
|
+
}
|
|
200
|
+
mountHead(head);
|
|
201
|
+
}
|
|
202
|
+
function replayEvents() {
|
|
203
|
+
if (typeof window === "undefined") return;
|
|
204
|
+
const w = window;
|
|
205
|
+
if (typeof w.__FX_REPLAY_STOP__ === "function") w.__FX_REPLAY_STOP__();
|
|
206
|
+
const queue = w.__FX_REPLAY__;
|
|
207
|
+
w.__FX_REPLAY__ = void 0;
|
|
208
|
+
w.__FX_REPLAY_STOP__ = void 0;
|
|
209
|
+
if (!Array.isArray(queue) || queue.length === 0) return;
|
|
210
|
+
for (const rec of queue) {
|
|
211
|
+
const target = rec && rec.target;
|
|
212
|
+
if (!target || target.isConnected === false || typeof target.dispatchEvent !== "function") continue;
|
|
213
|
+
const type = rec.type;
|
|
214
|
+
const ev = type === "click" ? new MouseEvent(type, { bubbles: true, cancelable: true }) : new Event(type, { bubbles: true, cancelable: true });
|
|
215
|
+
target.dispatchEvent(ev);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
export {
|
|
219
|
+
hydrate,
|
|
220
|
+
mount,
|
|
221
|
+
startClient
|
|
222
|
+
};
|