@fluixi/core 1.0.0-alpha.100

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.
Files changed (253) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +334 -0
  3. package/dist/cdn/core.global.js +2 -0
  4. package/dist/cli/generate.cjs +5639 -0
  5. package/dist/cli/generate.d.ts +7 -0
  6. package/dist/cli/generate.d.ts.map +1 -0
  7. package/dist/cli/generate.js +2580 -0
  8. package/dist/cli/generate.mjs +5644 -0
  9. package/dist/cli/index.cjs +5639 -0
  10. package/dist/cli/index.d.ts +7 -0
  11. package/dist/cli/index.d.ts.map +1 -0
  12. package/dist/cli/index.js +2580 -0
  13. package/dist/cli/index.mjs +5644 -0
  14. package/dist/cli/run.cjs +64 -0
  15. package/dist/cli/run.d.ts +3 -0
  16. package/dist/cli/run.d.ts.map +1 -0
  17. package/dist/cli/run.js +62 -0
  18. package/dist/cli/run.mjs +40 -0
  19. package/dist/fluixi.d.ts +5 -0
  20. package/dist/src/cdn/chunk-RKBFEFZP.mjs +987 -0
  21. package/dist/src/cdn/core.cjs +1592 -0
  22. package/dist/src/cdn/core.d.ts +16 -0
  23. package/dist/src/cdn/core.d.ts.map +1 -0
  24. package/dist/src/cdn/core.js +15 -0
  25. package/dist/src/cdn/core.mjs +714 -0
  26. package/dist/src/cdn/router-V2THK27H.mjs +74 -0
  27. package/dist/src/index.cjs +1711 -0
  28. package/dist/src/index.d.ts +4 -0
  29. package/dist/src/index.d.ts.map +1 -0
  30. package/dist/src/index.js +11 -0
  31. package/dist/src/index.mjs +1833 -0
  32. package/dist/src/jsx-dev-runtime.cjs +26 -0
  33. package/dist/src/jsx-dev-runtime.d.ts +2 -0
  34. package/dist/src/jsx-dev-runtime.d.ts.map +1 -0
  35. package/dist/src/jsx-dev-runtime.js +1 -0
  36. package/dist/src/jsx-dev-runtime.mjs +24 -0
  37. package/dist/src/jsx-runtime.cjs +26 -0
  38. package/dist/src/jsx-runtime.d.ts +7 -0
  39. package/dist/src/jsx-runtime.d.ts.map +1 -0
  40. package/dist/src/jsx-runtime.js +8 -0
  41. package/dist/src/jsx-runtime.mjs +24 -0
  42. package/dist/src/lib/client/chunk-FDOPDB6Z.mjs +53 -0
  43. package/dist/src/lib/client/index.cjs +1210 -0
  44. package/dist/src/lib/client/index.d.ts +51 -0
  45. package/dist/src/lib/client/index.d.ts.map +1 -0
  46. package/dist/src/lib/client/index.js +174 -0
  47. package/dist/src/lib/client/index.mjs +293 -0
  48. package/dist/src/lib/client/router-4PTBPZLQ.mjs +891 -0
  49. package/dist/src/lib/context/context.cjs +81 -0
  50. package/dist/src/lib/context/context.d.ts +73 -0
  51. package/dist/src/lib/context/context.d.ts.map +1 -0
  52. package/dist/src/lib/context/context.js +93 -0
  53. package/dist/src/lib/context/context.mjs +64 -0
  54. package/dist/src/lib/context/index.cjs +83 -0
  55. package/dist/src/lib/context/index.d.ts +3 -0
  56. package/dist/src/lib/context/index.d.ts.map +1 -0
  57. package/dist/src/lib/context/index.js +1 -0
  58. package/dist/src/lib/context/index.mjs +64 -0
  59. package/dist/src/lib/control-flow.cjs +35 -0
  60. package/dist/src/lib/control-flow.d.ts +4 -0
  61. package/dist/src/lib/control-flow.d.ts.map +1 -0
  62. package/dist/src/lib/control-flow.js +1 -0
  63. package/dist/src/lib/control-flow.mjs +25 -0
  64. package/dist/src/lib/core.cjs +1710 -0
  65. package/dist/src/lib/core.d.ts +91 -0
  66. package/dist/src/lib/core.d.ts.map +1 -0
  67. package/dist/src/lib/core.js +158 -0
  68. package/dist/src/lib/core.mjs +1833 -0
  69. package/dist/src/lib/env/index.cjs +44 -0
  70. package/dist/src/lib/env/index.d.ts +26 -0
  71. package/dist/src/lib/env/index.d.ts.map +1 -0
  72. package/dist/src/lib/env/index.js +31 -0
  73. package/dist/src/lib/env/index.mjs +23 -0
  74. package/dist/src/lib/i18n/index.cjs +123 -0
  75. package/dist/src/lib/i18n/index.d.ts +110 -0
  76. package/dist/src/lib/i18n/index.d.ts.map +1 -0
  77. package/dist/src/lib/i18n/index.js +164 -0
  78. package/dist/src/lib/i18n/index.mjs +103 -0
  79. package/dist/src/lib/index.cjs +598 -0
  80. package/dist/src/lib/index.d.ts +81 -0
  81. package/dist/src/lib/index.d.ts.map +1 -0
  82. package/dist/src/lib/index.js +130 -0
  83. package/dist/src/lib/index.mjs +688 -0
  84. package/dist/src/lib/isomorphic.cjs +90 -0
  85. package/dist/src/lib/isomorphic.d.ts +114 -0
  86. package/dist/src/lib/isomorphic.d.ts.map +1 -0
  87. package/dist/src/lib/isomorphic.js +132 -0
  88. package/dist/src/lib/isomorphic.mjs +69 -0
  89. package/dist/src/lib/jsx-runtime/index.cjs +21 -0
  90. package/dist/src/lib/jsx-runtime/index.d.ts +13 -0
  91. package/dist/src/lib/jsx-runtime/index.d.ts.map +1 -0
  92. package/dist/src/lib/jsx-runtime/index.js +13 -0
  93. package/dist/src/lib/jsx-runtime/index.mjs +4 -0
  94. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -0
  95. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts +2 -0
  96. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts.map +1 -0
  97. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.js +1 -0
  98. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -0
  99. package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -0
  100. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +35 -0
  101. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -0
  102. package/dist/src/lib/plugins/fluixi-routes-plugin.js +118 -0
  103. package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -0
  104. package/dist/src/lib/plugins/index.cjs +311 -0
  105. package/dist/src/lib/plugins/index.d.ts +6 -0
  106. package/dist/src/lib/plugins/index.d.ts.map +1 -0
  107. package/dist/src/lib/plugins/index.js +7 -0
  108. package/dist/src/lib/plugins/index.mjs +279 -0
  109. package/dist/src/lib/plugins/route-codegen.cjs +73 -0
  110. package/dist/src/lib/plugins/route-codegen.d.ts +12 -0
  111. package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -0
  112. package/dist/src/lib/plugins/route-codegen.js +80 -0
  113. package/dist/src/lib/plugins/route-codegen.mjs +52 -0
  114. package/dist/src/lib/plugins/route-scanner.cjs +189 -0
  115. package/dist/src/lib/plugins/route-scanner.d.ts +38 -0
  116. package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -0
  117. package/dist/src/lib/plugins/route-scanner.js +215 -0
  118. package/dist/src/lib/plugins/route-scanner.mjs +158 -0
  119. package/dist/src/lib/plugins/vite.cjs +27 -0
  120. package/dist/src/lib/plugins/vite.d.ts +3 -0
  121. package/dist/src/lib/plugins/vite.d.ts.map +1 -0
  122. package/dist/src/lib/plugins/vite.js +1 -0
  123. package/dist/src/lib/plugins/vite.mjs +6 -0
  124. package/dist/src/lib/render/await.cjs +38 -0
  125. package/dist/src/lib/render/await.d.ts +26 -0
  126. package/dist/src/lib/render/await.d.ts.map +1 -0
  127. package/dist/src/lib/render/await.js +45 -0
  128. package/dist/src/lib/render/await.mjs +17 -0
  129. package/dist/src/lib/render/component.cjs +221 -0
  130. package/dist/src/lib/render/component.d.ts +296 -0
  131. package/dist/src/lib/render/component.d.ts.map +1 -0
  132. package/dist/src/lib/render/component.js +514 -0
  133. package/dist/src/lib/render/component.mjs +214 -0
  134. package/dist/src/lib/render/deferred.cjs +175 -0
  135. package/dist/src/lib/render/deferred.d.ts +36 -0
  136. package/dist/src/lib/render/deferred.d.ts.map +1 -0
  137. package/dist/src/lib/render/deferred.js +141 -0
  138. package/dist/src/lib/render/deferred.mjs +158 -0
  139. package/dist/src/lib/render/index.cjs +573 -0
  140. package/dist/src/lib/render/index.d.ts +98 -0
  141. package/dist/src/lib/render/index.d.ts.map +1 -0
  142. package/dist/src/lib/render/index.js +180 -0
  143. package/dist/src/lib/render/index.mjs +590 -0
  144. package/dist/src/lib/render/lazy.cjs +67 -0
  145. package/dist/src/lib/render/lazy.d.ts +49 -0
  146. package/dist/src/lib/render/lazy.d.ts.map +1 -0
  147. package/dist/src/lib/render/lazy.js +105 -0
  148. package/dist/src/lib/render/lazy.mjs +50 -0
  149. package/dist/src/lib/render/suspense.cjs +141 -0
  150. package/dist/src/lib/render/suspense.d.ts +65 -0
  151. package/dist/src/lib/render/suspense.d.ts.map +1 -0
  152. package/dist/src/lib/render/suspense.js +196 -0
  153. package/dist/src/lib/render/suspense.mjs +136 -0
  154. package/dist/src/lib/render/versions.cjs +35 -0
  155. package/dist/src/lib/render/versions.d.ts +2 -0
  156. package/dist/src/lib/render/versions.d.ts.map +1 -0
  157. package/dist/src/lib/render/versions.js +21 -0
  158. package/dist/src/lib/render/versions.mjs +14 -0
  159. package/dist/src/lib/router/data.cjs +228 -0
  160. package/dist/src/lib/router/data.d.ts +142 -0
  161. package/dist/src/lib/router/data.d.ts.map +1 -0
  162. package/dist/src/lib/router/data.js +258 -0
  163. package/dist/src/lib/router/data.mjs +214 -0
  164. package/dist/src/lib/router/index.cjs +921 -0
  165. package/dist/src/lib/router/index.d.ts +274 -0
  166. package/dist/src/lib/router/index.d.ts.map +1 -0
  167. package/dist/src/lib/router/index.js +904 -0
  168. package/dist/src/lib/router/index.mjs +938 -0
  169. package/dist/src/lib/router/scroll.cjs +79 -0
  170. package/dist/src/lib/router/scroll.d.ts +19 -0
  171. package/dist/src/lib/router/scroll.d.ts.map +1 -0
  172. package/dist/src/lib/router/scroll.js +68 -0
  173. package/dist/src/lib/router/scroll.mjs +58 -0
  174. package/dist/src/lib/router/transition.cjs +75 -0
  175. package/dist/src/lib/router/transition.d.ts +81 -0
  176. package/dist/src/lib/router/transition.d.ts.map +1 -0
  177. package/dist/src/lib/router/transition.js +136 -0
  178. package/dist/src/lib/router/transition.mjs +54 -0
  179. package/dist/src/lib/server/hydration.cjs +169 -0
  180. package/dist/src/lib/server/hydration.d.ts +198 -0
  181. package/dist/src/lib/server/hydration.d.ts.map +1 -0
  182. package/dist/src/lib/server/hydration.js +345 -0
  183. package/dist/src/lib/server/hydration.mjs +148 -0
  184. package/dist/src/lib/server/index.cjs +406 -0
  185. package/dist/src/lib/server/index.d.ts +115 -0
  186. package/dist/src/lib/server/index.d.ts.map +1 -0
  187. package/dist/src/lib/server/index.js +164 -0
  188. package/dist/src/lib/server/index.mjs +384 -0
  189. package/dist/src/lib/server/reactive.cjs +197 -0
  190. package/dist/src/lib/server/reactive.d.ts +239 -0
  191. package/dist/src/lib/server/reactive.d.ts.map +1 -0
  192. package/dist/src/lib/server/reactive.js +413 -0
  193. package/dist/src/lib/server/reactive.mjs +176 -0
  194. package/dist/src/lib/storage/cache.cjs +51 -0
  195. package/dist/src/lib/storage/cache.d.ts +18 -0
  196. package/dist/src/lib/storage/cache.d.ts.map +1 -0
  197. package/dist/src/lib/storage/cache.js +42 -0
  198. package/dist/src/lib/storage/cache.mjs +30 -0
  199. package/dist/src/lib/storage/index.cjs +246 -0
  200. package/dist/src/lib/storage/index.d.ts +83 -0
  201. package/dist/src/lib/storage/index.d.ts.map +1 -0
  202. package/dist/src/lib/storage/index.js +179 -0
  203. package/dist/src/lib/storage/index.mjs +231 -0
  204. package/dist/src/lib/storage/persisted.cjs +91 -0
  205. package/dist/src/lib/storage/persisted.d.ts +53 -0
  206. package/dist/src/lib/storage/persisted.d.ts.map +1 -0
  207. package/dist/src/lib/storage/persisted.js +75 -0
  208. package/dist/src/lib/storage/persisted.mjs +70 -0
  209. package/dist/src/lib/theme/color-scheme.cjs +281 -0
  210. package/dist/src/lib/theme/color-scheme.d.ts +61 -0
  211. package/dist/src/lib/theme/color-scheme.d.ts.map +1 -0
  212. package/dist/src/lib/theme/color-scheme.js +120 -0
  213. package/dist/src/lib/theme/color-scheme.mjs +265 -0
  214. package/dist/src/lib/theme/index.cjs +267 -0
  215. package/dist/src/lib/theme/index.d.ts +78 -0
  216. package/dist/src/lib/theme/index.d.ts.map +1 -0
  217. package/dist/src/lib/theme/index.js +135 -0
  218. package/dist/src/lib/theme/index.mjs +251 -0
  219. package/dist/src/lib/theme/provider.cjs +346 -0
  220. package/dist/src/lib/theme/provider.d.ts +34 -0
  221. package/dist/src/lib/theme/provider.d.ts.map +1 -0
  222. package/dist/src/lib/theme/provider.js +60 -0
  223. package/dist/src/lib/theme/provider.mjs +332 -0
  224. package/dist/src/lib/utils/index.cjs +209 -0
  225. package/dist/src/lib/utils/index.d.ts +286 -0
  226. package/dist/src/lib/utils/index.d.ts.map +1 -0
  227. package/dist/src/lib/utils/index.js +434 -0
  228. package/dist/src/lib/utils/index.mjs +188 -0
  229. package/dist/src/routes.cjs +37 -0
  230. package/dist/src/routes.d.ts +22 -0
  231. package/dist/src/routes.d.ts.map +1 -0
  232. package/dist/src/routes.js +20 -0
  233. package/dist/src/routes.mjs +17 -0
  234. package/dist/src/server.cjs +405 -0
  235. package/dist/src/server.d.ts +63 -0
  236. package/dist/src/server.d.ts.map +1 -0
  237. package/dist/src/server.js +62 -0
  238. package/dist/src/server.mjs +382 -0
  239. package/dist/src/utils.cjs +21 -0
  240. package/dist/src/utils.d.ts +10 -0
  241. package/dist/src/utils.d.ts.map +1 -0
  242. package/dist/src/utils.js +9 -0
  243. package/dist/src/utils.mjs +4 -0
  244. package/dist/src/version.generated.cjs +26 -0
  245. package/dist/src/version.generated.d.ts +3 -0
  246. package/dist/src/version.generated.d.ts.map +1 -0
  247. package/dist/src/version.generated.js +3 -0
  248. package/dist/src/version.generated.mjs +5 -0
  249. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  250. package/package.json +164 -0
  251. package/src/index.ts +19 -0
  252. package/types/fluixi.d.ts +5 -0
  253. package/types/vinxi.d.ts +50 -0
@@ -0,0 +1,590 @@
1
+ // src/lib/render/index.ts
2
+ import { isServer as isServer3 } from "@fluixi/dom";
3
+ import { createRoot as createRoot2 } from "@fluixi/reactive/signal";
4
+
5
+ // src/lib/render/versions.ts
6
+ import { registerCoreVersion } from "@fluixi/dom";
7
+
8
+ // src/version.generated.ts
9
+ var VERSION = "1.0.0-alpha.100";
10
+
11
+ // src/lib/render/versions.ts
12
+ import { stampVersions, warnOnVersionSkew, versions } from "@fluixi/dom";
13
+ registerCoreVersion(VERSION);
14
+
15
+ // src/lib/render/index.ts
16
+ import {
17
+ isDOMNode,
18
+ delegateEvents,
19
+ insert
20
+ } from "@fluixi/dom";
21
+
22
+ // src/lib/render/component.ts
23
+ import { isServer } from "@fluixi/dom";
24
+ import {
25
+ createComponent as domCreateComponent,
26
+ asComponent
27
+ } from "@fluixi/dom";
28
+ import {
29
+ untrack,
30
+ onCleanup,
31
+ getOwner,
32
+ createEffect,
33
+ createMemo,
34
+ createSignal,
35
+ isSignal,
36
+ batch,
37
+ runWithOwner,
38
+ isOwnerDisposed
39
+ } from "@fluixi/reactive/signal";
40
+ var sharedConfig = {
41
+ context: null,
42
+ owner: null
43
+ };
44
+ function getSharedConfig() {
45
+ return sharedConfig;
46
+ }
47
+ var DEV = typeof process !== "undefined" && false;
48
+ var _LIFECYCLE = /* @__PURE__ */ Symbol.for("fluixi-lifecycle");
49
+ function getOwnerLifecycle() {
50
+ const owner = getOwner();
51
+ if (!owner) return null;
52
+ if (!owner[_LIFECYCLE]) {
53
+ const lc = { mounts: [], effects: [], scheduled: false };
54
+ owner[_LIFECYCLE] = lc;
55
+ }
56
+ return owner[_LIFECYCLE];
57
+ }
58
+ function scheduleLifecycleFlush(lc) {
59
+ if (lc.scheduled) return;
60
+ if (isServer()) {
61
+ lc.mounts = [];
62
+ lc.effects = [];
63
+ return;
64
+ }
65
+ lc.scheduled = true;
66
+ const owner = getOwner();
67
+ queueMicrotask(() => {
68
+ if (isOwnerDisposed(owner)) {
69
+ lc.mounts = [];
70
+ lc.effects = [];
71
+ return;
72
+ }
73
+ runWithOwner(owner, () => {
74
+ for (const cb of lc.mounts) {
75
+ try {
76
+ const cleanup = cb();
77
+ if (typeof cleanup === "function") {
78
+ onCleanup(cleanup);
79
+ }
80
+ } catch (e) {
81
+ console.error("Error in onMount callback:", e);
82
+ }
83
+ }
84
+ for (const cb of lc.effects) {
85
+ let cleanup;
86
+ createEffect(() => {
87
+ if (cleanup) cleanup();
88
+ cleanup = cb();
89
+ });
90
+ onCleanup(() => {
91
+ if (cleanup) cleanup();
92
+ });
93
+ }
94
+ lc.mounts = [];
95
+ lc.effects = [];
96
+ });
97
+ });
98
+ }
99
+ function createComponent(Comp, props) {
100
+ return domCreateComponent(Comp, props);
101
+ }
102
+ function $component(value, props) {
103
+ const component = typeof value === "function" ? untrack(() => value(props)) : value;
104
+ const nameable = component != null && (typeof component === "function" || typeof component === "object");
105
+ if (nameable) {
106
+ try {
107
+ component["$name"] = value.name;
108
+ } catch {
109
+ }
110
+ }
111
+ if (nameable && !isSignal(component)) {
112
+ return asComponent(component);
113
+ }
114
+ return component;
115
+ }
116
+ function onMount(fn, reactive = true) {
117
+ if (isServer()) return;
118
+ const lc = getOwnerLifecycle();
119
+ if (lc) {
120
+ if (!reactive) {
121
+ if (!lc.scheduled) {
122
+ fn();
123
+ }
124
+ return;
125
+ }
126
+ lc.mounts.push(fn);
127
+ scheduleLifecycleFlush(lc);
128
+ } else {
129
+ if (!reactive) {
130
+ fn();
131
+ return;
132
+ }
133
+ createEffect(() => {
134
+ const cleanup = untrack(fn);
135
+ if (typeof cleanup === "function") {
136
+ onCleanup(cleanup);
137
+ }
138
+ });
139
+ }
140
+ }
141
+ function onUnmount(fn) {
142
+ onCleanup(fn);
143
+ }
144
+ function useEffect(callback) {
145
+ const lc = getOwnerLifecycle();
146
+ if (lc) {
147
+ lc.effects.push(callback);
148
+ scheduleLifecycleFlush(lc);
149
+ } else {
150
+ let cleanup;
151
+ createEffect(() => {
152
+ if (cleanup) cleanup();
153
+ cleanup = callback();
154
+ });
155
+ onCleanup(() => {
156
+ if (cleanup) cleanup();
157
+ });
158
+ }
159
+ }
160
+ function useMemo(fn) {
161
+ return createMemo(fn);
162
+ }
163
+ function useRef(initialValue) {
164
+ const ref = { current: initialValue };
165
+ onCleanup(() => {
166
+ ref.current = null;
167
+ });
168
+ return ref;
169
+ }
170
+ function useReducer(reducer, initialState) {
171
+ const [state, setState] = createSignal(initialState);
172
+ const dispatch = (action) => {
173
+ setState(reducer(state(), action));
174
+ };
175
+ return [state, dispatch];
176
+ }
177
+ function useEventListener(target, event, handler, options) {
178
+ useEffect(() => {
179
+ const element = target && "current" in target ? target.current : target;
180
+ if (!element) return;
181
+ element.addEventListener(event, handler, options);
182
+ return () => {
183
+ element.removeEventListener(event, handler, options);
184
+ };
185
+ });
186
+ }
187
+ function useCallback(callback) {
188
+ return callback;
189
+ }
190
+ function isDev() {
191
+ return DEV;
192
+ }
193
+ function devOnly(fn) {
194
+ if (DEV) {
195
+ fn();
196
+ }
197
+ }
198
+
199
+ // src/lib/render/suspense.ts
200
+ import {
201
+ createSignal as createSignal2,
202
+ createMemo as createMemo2,
203
+ createEffect as createEffect2,
204
+ createRenderEffect as createRenderEffect2,
205
+ isSignal as isSignal2,
206
+ readChildren,
207
+ useContext as useContext2,
208
+ createContext as createContext2,
209
+ createSuspenseBoundary,
210
+ provideSuspense
211
+ } from "@fluixi/reactive/signal";
212
+ import {
213
+ asSuspense,
214
+ isComponent,
215
+ createComponent as createComponent2,
216
+ runWithoutHydration
217
+ } from "@fluixi/dom";
218
+ function isNode(value) {
219
+ if (typeof window === "undefined") return false;
220
+ if (typeof Node === "function" && value instanceof Node) return true;
221
+ return !!(value && typeof value === "object" && typeof value.nodeType === "number");
222
+ }
223
+ function isLitResult(value) {
224
+ if (!value || typeof value !== "object") return false;
225
+ return !!(typeof value["_$litType$"] !== "undefined" || typeof value["_$litDirective$"] !== "undefined" || Array.isArray(value.strings) && Array.isArray(value.values));
226
+ }
227
+ function isPromise(value) {
228
+ return !!(value && typeof value === "object" && typeof value.then === "function" || value instanceof Promise);
229
+ }
230
+ function isJSXElement(value) {
231
+ return !!(value && typeof value === "object" && "type" in value && "props" in value);
232
+ }
233
+ var SuspenseListContext = createContext2(void 0, "suspense-list");
234
+ function Suspense(props) {
235
+ return createComponent2(SuspenseImpl, props);
236
+ }
237
+ function SuspenseImpl(props) {
238
+ const boundary = createSuspenseBoundary();
239
+ const listCtx = useContext2(SuspenseListContext);
240
+ const listState = listCtx ? listCtx.register(boundary.inFallback) : void 0;
241
+ function instantiateOnce(val) {
242
+ if (val == null || typeof val === "boolean") return null;
243
+ if (typeof val === "function" && isComponent(val) && !isSignal2(val)) return val();
244
+ return val;
245
+ }
246
+ const fallback = runWithoutHydration(() => instantiateOnce(props.fallback ?? null));
247
+ const children = provideSuspense(boundary, () => readChildren(() => props.children));
248
+ const track = (value, depth) => {
249
+ if (depth > 8) return;
250
+ if (Array.isArray(value)) {
251
+ for (const x of value) track(x, depth + 1);
252
+ } else if (typeof value === "function" && isSignal2(value)) {
253
+ track(value(), depth + 1);
254
+ }
255
+ };
256
+ provideSuspense(boundary, () => {
257
+ createRenderEffect2(() => track(children, 0));
258
+ });
259
+ const [resolved, setResolved] = createSignal2(void 0);
260
+ const childIsPromise = isPromise(children);
261
+ if (childIsPromise) {
262
+ boundary.increment();
263
+ children.then(
264
+ (v) => {
265
+ setResolved(() => v);
266
+ boundary.decrement();
267
+ },
268
+ () => boundary.decrement()
269
+ );
270
+ }
271
+ return createMemo2(() => {
272
+ const showFallback = listState ? listState.showFallback() : boundary.inFallback();
273
+ if (showFallback) return fallback;
274
+ if (childIsPromise) return resolved();
275
+ return children;
276
+ });
277
+ }
278
+ function SuspenseList(props) {
279
+ return createComponent2(SuspenseListImpl, props);
280
+ }
281
+ function SuspenseListImpl(props) {
282
+ const { revealOrder = "together", tail } = props;
283
+ const registrations = [];
284
+ function coordinateReveal() {
285
+ if (revealOrder === "together") {
286
+ const allResolved = registrations.every((r) => !r.inFallback());
287
+ registrations.forEach((r) => {
288
+ r.setShowContent(allResolved);
289
+ r.setShowFallback(!allResolved);
290
+ });
291
+ } else {
292
+ const items = revealOrder === "backwards" ? [...registrations].reverse() : registrations;
293
+ let blocked = false;
294
+ for (const r of items) {
295
+ if (blocked || r.inFallback()) {
296
+ blocked = true;
297
+ r.setShowContent(false);
298
+ r.setShowFallback(tail !== "hidden");
299
+ } else {
300
+ r.setShowContent(true);
301
+ r.setShowFallback(false);
302
+ }
303
+ }
304
+ }
305
+ }
306
+ const coordinator = {
307
+ register: (inFallback) => {
308
+ const [showContent, setShowContent] = createSignal2(true);
309
+ const [showFallback, setShowFallback] = createSignal2(false);
310
+ registrations.push({ inFallback, setShowContent, setShowFallback });
311
+ createEffect2(() => {
312
+ inFallback();
313
+ coordinateReveal();
314
+ });
315
+ return { showContent, showFallback };
316
+ }
317
+ };
318
+ return SuspenseListContext.Provider({
319
+ value: coordinator,
320
+ children: props.children
321
+ });
322
+ }
323
+ asSuspense(Suspense);
324
+ Object.defineProperty(Suspense, "__suspense", { value: true, enumerable: true });
325
+
326
+ // src/lib/render/lazy.ts
327
+ import { createComponent as createComponent3 } from "@fluixi/dom";
328
+ import {
329
+ untrack as untrack2,
330
+ createMemo as createMemo3,
331
+ createResource as createResource2
332
+ } from "@fluixi/reactive/signal";
333
+ function fromChunk(value) {
334
+ if (value != null && (typeof value === "object" || typeof value === "function")) {
335
+ try {
336
+ value["$lazy"] = true;
337
+ } catch {
338
+ }
339
+ }
340
+ return value;
341
+ }
342
+ function lazy(loader, options) {
343
+ let resolved;
344
+ let promise;
345
+ let component;
346
+ function load() {
347
+ if (!promise) {
348
+ promise = loader().then((mod) => resolved = mod.default);
349
+ }
350
+ return promise;
351
+ }
352
+ if (options?.preload) load();
353
+ const LazyWrapper = ((props) => {
354
+ if (resolved) {
355
+ const C = resolved;
356
+ return fromChunk(untrack2(() => C(props)));
357
+ }
358
+ if (!component) {
359
+ const [resource] = createResource2(() => load(), { transport: false });
360
+ component = resource;
361
+ if (resource.error) throw resource.error;
362
+ }
363
+ return createMemo3(() => {
364
+ const C = component();
365
+ return C ? fromChunk(createComponent3(C, props)) : void 0;
366
+ });
367
+ });
368
+ LazyWrapper.preload = () => load().then(() => void 0);
369
+ LazyWrapper.$lazy = true;
370
+ LazyWrapper.loader = loader;
371
+ return LazyWrapper;
372
+ }
373
+
374
+ // src/lib/render/deferred.ts
375
+ import { isServer as isServer2 } from "@fluixi/dom";
376
+ import { createMemo as createMemo4, createSignal as createSignal3 } from "@fluixi/reactive/signal";
377
+ import { observeIntersection } from "@fluixi/dom/utils";
378
+ function deferred(loader, options) {
379
+ const exportName = options.export ?? "default";
380
+ const Lazy = lazy(
381
+ () => loader().then((mod) => {
382
+ const component = mod[exportName];
383
+ if (typeof component !== "function") {
384
+ throw new Error(
385
+ `deferred(): module has no '${exportName}' export (got ${typeof component}).`
386
+ );
387
+ }
388
+ return { default: component };
389
+ }),
390
+ { fallback: options.fallback }
391
+ );
392
+ function Deferred(props) {
393
+ if (options.strategy.kind === "never") return isServer2() ? Lazy(props) : null;
394
+ if (isServer2() || options.strategy.kind === "eager") return Lazy(props);
395
+ const [ready, setReady] = createSignal3(false);
396
+ const start = () => {
397
+ void Lazy.preload().then(() => setReady(true));
398
+ };
399
+ const anchor = options.strategy.kind === "visible" ? createAnchor() : void 0;
400
+ schedule(options.strategy, start, anchor);
401
+ return createMemo4(() => ready() ? Lazy(props) : anchor ?? options.fallback ?? null, void 0, {
402
+ name: "deferred"
403
+ });
404
+ }
405
+ Deferred.preload = Lazy.preload;
406
+ return Deferred;
407
+ }
408
+ function createAnchor() {
409
+ const el = document.createElement("span");
410
+ el.setAttribute("data-fx-load", "visible");
411
+ el.style.display = "block";
412
+ return el;
413
+ }
414
+ function schedule(strategy, start, anchor) {
415
+ let fired = false;
416
+ const once = () => {
417
+ if (fired) return;
418
+ fired = true;
419
+ start();
420
+ };
421
+ switch (strategy.kind) {
422
+ case "idle": {
423
+ const ric = globalThis.requestIdleCallback;
424
+ if (ric) ric(once);
425
+ else setTimeout(once, 1);
426
+ return;
427
+ }
428
+ case "visible": {
429
+ if (!anchor || typeof IntersectionObserver === "undefined") {
430
+ once();
431
+ return;
432
+ }
433
+ const stop = observeIntersection(
434
+ anchor,
435
+ (isIntersecting) => {
436
+ if (!isIntersecting) return;
437
+ stop();
438
+ once();
439
+ },
440
+ { rootMargin: strategy.rootMargin ?? "0px" }
441
+ );
442
+ return;
443
+ }
444
+ case "interaction": {
445
+ const handler = () => {
446
+ for (const event of strategy.events) {
447
+ document.removeEventListener(event, handler, true);
448
+ }
449
+ once();
450
+ };
451
+ for (const event of strategy.events) {
452
+ document.addEventListener(event, handler, { capture: true, passive: true });
453
+ }
454
+ return;
455
+ }
456
+ case "media": {
457
+ if (typeof matchMedia === "undefined") {
458
+ once();
459
+ return;
460
+ }
461
+ const query = matchMedia(strategy.query);
462
+ if (query.matches) {
463
+ once();
464
+ return;
465
+ }
466
+ const onChange = (e) => {
467
+ if (!e.matches) return;
468
+ query.removeEventListener("change", onChange);
469
+ once();
470
+ };
471
+ query.addEventListener("change", onChange);
472
+ return;
473
+ }
474
+ /* c8 ignore next 3 */
475
+ default:
476
+ once();
477
+ }
478
+ }
479
+
480
+ // src/lib/render/await.ts
481
+ import { createResource as createResource3 } from "@fluixi/reactive/signal";
482
+ function Await(props) {
483
+ const fetcher = () => {
484
+ const v = props.value;
485
+ return typeof v === "function" ? v() : v;
486
+ };
487
+ const [data] = createResource3(fetcher);
488
+ return () => {
489
+ if (data.loading) return props.fallback;
490
+ const child = props.children;
491
+ return typeof child === "function" ? child(data()) : child;
492
+ };
493
+ }
494
+
495
+ // src/lib/render/index.ts
496
+ function render(code, container, options = {}) {
497
+ delegateEvents(["click", "input", "change", "submit"]);
498
+ if (isServer3()) {
499
+ throw new Error(
500
+ "render() is for client-side only. Use renderToString() on server."
501
+ );
502
+ }
503
+ if (!container) {
504
+ throw new Error("Container element is required");
505
+ }
506
+ let disposer;
507
+ createRoot2((dispose) => {
508
+ disposer = dispose;
509
+ const result = typeof code === "function" ? code() : code;
510
+ container.textContent = "";
511
+ stampVersions(container);
512
+ warnOnVersionSkew();
513
+ insert(container, () => result);
514
+ });
515
+ return () => {
516
+ if (disposer) {
517
+ disposer();
518
+ disposer = void 0;
519
+ }
520
+ };
521
+ }
522
+ function isLitTemplateResult(value) {
523
+ return value && typeof value === "object" && (value["_$litType$"] !== void 0 || value["_$litDirective$"] !== void 0);
524
+ }
525
+ function portal(code, target, options = {}) {
526
+ const container = document.createElement("div");
527
+ container.setAttribute("data-portal", "true");
528
+ target.appendChild(container);
529
+ const dispose = render(code, container, options);
530
+ return () => {
531
+ dispose();
532
+ if (target.contains(container)) {
533
+ target.removeChild(container);
534
+ }
535
+ };
536
+ }
537
+ function isRenderable(value) {
538
+ if (value == null) return true;
539
+ if (typeof value === "function") return true;
540
+ if (isDOMNode(value)) return true;
541
+ if (isLitTemplateResult(value)) return true;
542
+ if (Array.isArray(value)) return true;
543
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
544
+ return true;
545
+ }
546
+ return false;
547
+ }
548
+ function initDelegation() {
549
+ if (isServer3()) return;
550
+ delegateEvents(["click", "input", "change", "submit"]);
551
+ }
552
+ function cleanupDelegation() {
553
+ if (isServer3()) return;
554
+ }
555
+ export {
556
+ $component,
557
+ Await,
558
+ DEV,
559
+ Suspense,
560
+ SuspenseList,
561
+ batch,
562
+ cleanupDelegation,
563
+ createComponent,
564
+ createEffect,
565
+ createMemo,
566
+ deferred,
567
+ devOnly,
568
+ getOwner,
569
+ getSharedConfig,
570
+ initDelegation,
571
+ isDev,
572
+ isJSXElement,
573
+ isLitResult,
574
+ isNode,
575
+ isPromise,
576
+ isRenderable,
577
+ lazy,
578
+ onCleanup,
579
+ onMount,
580
+ onUnmount,
581
+ portal,
582
+ render,
583
+ runWithOwner,
584
+ useCallback,
585
+ useEffect,
586
+ useEventListener,
587
+ useMemo,
588
+ useReducer,
589
+ useRef
590
+ };
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/render/lazy.ts
21
+ var lazy_exports = {};
22
+ __export(lazy_exports, {
23
+ lazy: () => lazy
24
+ });
25
+ module.exports = __toCommonJS(lazy_exports);
26
+ var import_dom = require("@fluixi/dom");
27
+ var import_signal = require("@fluixi/reactive/signal");
28
+ function fromChunk(value) {
29
+ if (value != null && (typeof value === "object" || typeof value === "function")) {
30
+ try {
31
+ value["$lazy"] = true;
32
+ } catch {
33
+ }
34
+ }
35
+ return value;
36
+ }
37
+ function lazy(loader, options) {
38
+ let resolved;
39
+ let promise;
40
+ let component;
41
+ function load() {
42
+ if (!promise) {
43
+ promise = loader().then((mod) => resolved = mod.default);
44
+ }
45
+ return promise;
46
+ }
47
+ if (options?.preload) load();
48
+ const LazyWrapper = ((props) => {
49
+ if (resolved) {
50
+ const C = resolved;
51
+ return fromChunk((0, import_signal.untrack)(() => C(props)));
52
+ }
53
+ if (!component) {
54
+ const [resource] = (0, import_signal.createResource)(() => load(), { transport: false });
55
+ component = resource;
56
+ if (resource.error) throw resource.error;
57
+ }
58
+ return (0, import_signal.createMemo)(() => {
59
+ const C = component();
60
+ return C ? fromChunk((0, import_dom.createComponent)(C, props)) : void 0;
61
+ });
62
+ });
63
+ LazyWrapper.preload = () => load().then(() => void 0);
64
+ LazyWrapper.$lazy = true;
65
+ LazyWrapper.loader = loader;
66
+ return LazyWrapper;
67
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Lazy-load a component module.
3
+ *
4
+ * SolidJS-aligned pattern:
5
+ * 1. `comp` signal is shared across all instances of this lazy component (module-level).
6
+ * 2. `createResource` at the component level registers the load promise with the
7
+ * nearest Suspense boundary (trackPromise / resource.loading).
8
+ * 3. A pure `createMemo` reads `comp()`: undefined while loading (Suspense shows
9
+ * fallback), the rendered component once loaded.
10
+ * 4. `preload()` is exposed so routes / link hover handlers can start the download
11
+ * before the component is rendered.
12
+ */
13
+ import { Component, ComponentProps } from '@fluixi/dom';
14
+ export type LazyComponent<P = ComponentProps> = () => Promise<{
15
+ default: Component<P>;
16
+ }>;
17
+ export interface LazyOptions {
18
+ /** Show this while the module is loading */
19
+ fallback?: any;
20
+ /** If true, start loading immediately when lazy() is called */
21
+ preload?: boolean;
22
+ }
23
+ /**
24
+ * Defer a component to its own chunk, loaded the first time it renders.
25
+ *
26
+ * `loader` is a dynamic import, and its `default` export is the component. The returned
27
+ * function stands in for it and carries `preload()`, which starts the import without
28
+ * rendering anything. File routing uses that: `startClient` preloads the matched route
29
+ * before hydrating.
30
+ *
31
+ * Preloading is what keeps hydration intact. If the module has already resolved by the
32
+ * time this renders, the component renders synchronously on the first pass, so it adopts
33
+ * the server's DOM in place. On a cold client navigation it goes through a resource
34
+ * instead, suspends, and a `Suspense` boundary above it shows the fallback.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const Settings = lazy(() => import('./Settings.js'));
39
+ *
40
+ * // somewhere that knows the route is next
41
+ * void Settings.preload();
42
+ * ```
43
+ */
44
+ export declare function lazy<T extends (...args: any[]) => any>(loader: () => Promise<{
45
+ default: T;
46
+ }>, options?: LazyOptions): T & {
47
+ preload: () => Promise<void>;
48
+ };
49
+ //# sourceMappingURL=lazy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../../../src/lib/render/lazy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAmB,MAAM,aAAa,CAAC;AAUzE,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,cAAc,IAAI,MAAM,OAAO,CAAC;IAC5D,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CACvB,CAAC,CAAC;AAEH,MAAM,WAAW,WAAW;IAC1B,4CAA4C;IAC5C,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,+DAA+D;IAC/D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAmBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACpD,MAAM,EAAE,MAAM,OAAO,CAAC;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC,EACrC,OAAO,CAAC,EAAE,WAAW,GACpB,CAAC,GAAG;IAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CA2DtC"}