@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,413 @@
1
+ /**
2
+ * @module @fluixi/core/server/reactive
3
+ *
4
+ * Maps reactive primitives for server-side execution
5
+ * Following SolidJS pattern of server-specific reactive behavior
6
+ *
7
+ * Server mode:
8
+ * - Signals read-only snapshot
9
+ * - Effects run once
10
+ * - No scheduling
11
+ * - No subscriptions
12
+ */
13
+ // ============================================================================
14
+ // SERVER SIGNAL
15
+ // ============================================================================
16
+ /**
17
+ * Server createSignal - Returns snapshot value
18
+ *
19
+ * Signals read-only snapshot on server
20
+ * No reactivity, no tracking, just initial value
21
+ *
22
+ * @example
23
+ * ```typescript
24
+ * // On server, this returns a static snapshot
25
+ * const [count, setCount] = createSignal(0);
26
+ * console.log(count()); // 0
27
+ * setCount(1); // Updates value but triggers no effects
28
+ * console.log(count()); // 1
29
+ * ```
30
+ */
31
+ export function createSignal(value, options) {
32
+ // Server: Simple read/write, no reactivity
33
+ let current = value;
34
+ const read = (() => current);
35
+ const write = (newValue) => {
36
+ if (typeof newValue === 'function') {
37
+ current = newValue(current);
38
+ }
39
+ else {
40
+ current = newValue;
41
+ }
42
+ return current;
43
+ };
44
+ return [read, write];
45
+ }
46
+ // ============================================================================
47
+ // SERVER EFFECT
48
+ // ============================================================================
49
+ /**
50
+ * Server createEffect - Runs once, no tracking
51
+ *
52
+ * Effects run once on server, no scheduling
53
+ * Execute immediately and return no-op disposer
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * // On server, runs once immediately
58
+ * createEffect(() => {
59
+ * console.log('This runs once');
60
+ * });
61
+ * ```
62
+ */
63
+ export function createEffect(fn, value, options) {
64
+ // Server: Run once, no tracking, no scheduling
65
+ try {
66
+ fn(value);
67
+ }
68
+ catch (error) {
69
+ console.error('[Fluixi Server] Effect error:', error);
70
+ }
71
+ // Return no-op disposer
72
+ return { dispose: () => { } };
73
+ }
74
+ // ============================================================================
75
+ // SERVER MEMO
76
+ // ============================================================================
77
+ /**
78
+ * Server createMemo - Compute once, return static accessor
79
+ *
80
+ * No tracking on server, single evaluation
81
+ * Memoizes value at creation time
82
+ *
83
+ * @example
84
+ * ```typescript
85
+ * const [count] = createSignal(5);
86
+ * const doubled = createMemo(() => count() * 2);
87
+ * console.log(doubled()); // 10 (computed once)
88
+ * ```
89
+ */
90
+ export function createMemo(fn, value, options) {
91
+ // Server: Compute once, no reactivity
92
+ const computed = fn(value);
93
+ return (() => computed);
94
+ }
95
+ // ============================================================================
96
+ // SERVER ROOT
97
+ // ============================================================================
98
+ /**
99
+ * Server createRoot - Creates owner but no reactive tracking
100
+ *
101
+ * Owners exist on server for tree structure
102
+ * Needed for context and cleanup, but no reactive tracking
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * const result = createRoot((dispose) => {
107
+ * // Server: Executes once, maintains owner tree
108
+ * return <App />;
109
+ * });
110
+ * ```
111
+ */
112
+ export function createRoot(fn) {
113
+ // Server: Execute function with no-op disposer
114
+ // Owner tree maintained for context/cleanup
115
+ const cleanups = [];
116
+ const dispose = () => {
117
+ cleanups.forEach((cleanup) => {
118
+ try {
119
+ cleanup();
120
+ }
121
+ catch (error) {
122
+ console.error('[Fluixi Server] Cleanup error:', error);
123
+ }
124
+ });
125
+ cleanups.length = 0;
126
+ };
127
+ try {
128
+ return fn(dispose);
129
+ }
130
+ catch (error) {
131
+ dispose();
132
+ throw error;
133
+ }
134
+ }
135
+ // ============================================================================
136
+ // SERVER BATCH
137
+ // ============================================================================
138
+ /**
139
+ * Server batch - Execute immediately, no batching
140
+ *
141
+ * No scheduling on server
142
+ * Just runs the function synchronously
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * batch(() => {
147
+ * setCount(1);
148
+ * setName('Alice');
149
+ * }); // Executes immediately
150
+ * ```
151
+ */
152
+ export function batch(fn) {
153
+ // Server: No batching needed, just run
154
+ return fn();
155
+ }
156
+ // ============================================================================
157
+ // SERVER UNTRACK
158
+ // ============================================================================
159
+ /**
160
+ * Server untrack - Execute function (already untracked)
161
+ *
162
+ * No tracking on server anyway
163
+ * This is a no-op but exists for API compatibility
164
+ *
165
+ * @example
166
+ * ```typescript
167
+ * untrack(() => {
168
+ * return signal(); // Not tracked (but nothing is on server)
169
+ * });
170
+ * ```
171
+ */
172
+ export function untrack(fn) {
173
+ // Server: Already untracked, just run
174
+ return fn();
175
+ }
176
+ // ============================================================================
177
+ // SERVER CLEANUP
178
+ // ============================================================================
179
+ let currentCleanups = null;
180
+ /**
181
+ * Server onCleanup - Register cleanup function
182
+ *
183
+ * Cleanup still needed for SSR resource management
184
+ * Stores cleanup for execution when root disposes
185
+ *
186
+ * @example
187
+ * ```typescript
188
+ * createRoot((dispose) => {
189
+ * onCleanup(() => {
190
+ * console.log('Cleanup on dispose');
191
+ * });
192
+ * return result;
193
+ * });
194
+ * ```
195
+ */
196
+ export function onCleanup(fn) {
197
+ if (currentCleanups) {
198
+ currentCleanups.push(fn);
199
+ }
200
+ }
201
+ // ============================================================================
202
+ // SERVER OWNER
203
+ // ============================================================================
204
+ let currentOwner = null;
205
+ /**
206
+ * Server getOwner - Get current reactive owner
207
+ *
208
+ * Owner tree maintained on server for context
209
+ */
210
+ export function getOwner() {
211
+ return currentOwner;
212
+ }
213
+ /**
214
+ * Server runWithOwner - Run function with specific owner
215
+ *
216
+ * Owner switching for proper context nesting
217
+ */
218
+ export function runWithOwner(owner, fn) {
219
+ const prev = currentOwner;
220
+ currentOwner = owner;
221
+ try {
222
+ return fn();
223
+ }
224
+ finally {
225
+ currentOwner = prev;
226
+ }
227
+ }
228
+ // ============================================================================
229
+ // SERVER CONTEXT
230
+ // ============================================================================
231
+ const contextMap = new Map();
232
+ /**
233
+ * Server createContext - Create context with default value
234
+ *
235
+ * Context lookup-based, no subscriptions on server
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * const ThemeContext = createContext('light');
240
+ * ```
241
+ */
242
+ export function createContext(defaultValue) {
243
+ const id = Symbol('context');
244
+ const Provider = (props) => {
245
+ // Server: Store value in context map
246
+ const prevValue = contextMap.get(id);
247
+ contextMap.set(id, props.value);
248
+ try {
249
+ return props.children;
250
+ }
251
+ finally {
252
+ // Restore previous value
253
+ if (prevValue !== undefined) {
254
+ contextMap.set(id, prevValue);
255
+ }
256
+ else {
257
+ contextMap.delete(id);
258
+ }
259
+ }
260
+ };
261
+ return {
262
+ id,
263
+ Provider,
264
+ defaultValue: defaultValue,
265
+ };
266
+ }
267
+ /**
268
+ * Server useContext - Retrieve context value
269
+ *
270
+ * No subscriptions on server, just lookup
271
+ *
272
+ * @example
273
+ * ```typescript
274
+ * const theme = useContext(ThemeContext);
275
+ * ```
276
+ */
277
+ export function useContext(context) {
278
+ // Server: Simple lookup, no subscription
279
+ const value = contextMap.get(context.id);
280
+ return value !== undefined ? value : context.defaultValue;
281
+ }
282
+ // ============================================================================
283
+ // SERVER COMPUTED
284
+ // ============================================================================
285
+ /**
286
+ * Server createComputed - Alias for createEffect
287
+ *
288
+ * On server, computed values run once like effects
289
+ */
290
+ export function createComputed(fn) {
291
+ return createEffect(fn);
292
+ }
293
+ // ============================================================================
294
+ // SERVER RENDER EFFECT
295
+ // ============================================================================
296
+ /**
297
+ * Server createRenderEffect - Runs once for SSR rendering
298
+ */
299
+ export function createRenderEffect(fn) {
300
+ return createEffect(fn);
301
+ }
302
+ // ============================================================================
303
+ // SERVER DEFERRED
304
+ // ============================================================================
305
+ /**
306
+ * Server createDeferred - No deferring on server
307
+ */
308
+ export function createDeferred(fn) {
309
+ return createMemo(fn);
310
+ }
311
+ // ============================================================================
312
+ // SERVER SELECTOR
313
+ // ============================================================================
314
+ /**
315
+ * Server createSelector - Returns static equality check
316
+ */
317
+ // ENVIRONMENT
318
+ /**
319
+ * The server stand-in for `createSelector`.
320
+ *
321
+ * On the client a selector is a fine-grained membership test that only notifies the two
322
+ * keys whose match changed. A server render produces one pass and has no subscriptions to
323
+ * be fine-grained about, so this reads the source once and compares.
324
+ */
325
+ export function createSelector(source) {
326
+ const value = source();
327
+ return (key) => key === value;
328
+ }
329
+ // ============================================================================
330
+ // SERVER RESOURCE
331
+ // ============================================================================
332
+ /**
333
+ * Server createResource - Stub for resource creation
334
+ */
335
+ export function createResource(source, fetcher, options) {
336
+ return [
337
+ () => undefined,
338
+ {
339
+ mutate: (v) => v,
340
+ refetch: () => { },
341
+ },
342
+ ];
343
+ }
344
+ /**
345
+ * Server createStore: plain object wrapper, no reactivity.
346
+ * Mirrors the client API so shared code compiles on both sides.
347
+ */
348
+ export function createStore(init) {
349
+ const state = { ...init };
350
+ function setStore(keyOrPatch, value) {
351
+ if (typeof keyOrPatch === 'object' &&
352
+ keyOrPatch !== null &&
353
+ !Array.isArray(keyOrPatch)) {
354
+ for (const k of Object.keys(keyOrPatch)) {
355
+ const v = keyOrPatch[k];
356
+ state[k] = typeof v === 'function' ? v(state[k]) : v;
357
+ }
358
+ }
359
+ else {
360
+ state[keyOrPatch] =
361
+ typeof value === 'function' ? value(state[keyOrPatch]) : value;
362
+ }
363
+ }
364
+ return [state, setStore];
365
+ }
366
+ // ============================================================================
367
+ // SERVER TRANSITION
368
+ // ============================================================================
369
+ /**
370
+ * Server startTransition - Execute immediately
371
+ */
372
+ export function startTransition(fn) {
373
+ fn();
374
+ }
375
+ // ============================================================================
376
+ // ENVIRONMENT
377
+ // ============================================================================
378
+ // ENVIRONMENT
379
+ // ============================================================================
380
+ /**
381
+ * Check if running on server
382
+ */
383
+ export const isServer = true;
384
+ /**
385
+ * Check if running on client
386
+ */
387
+ export const isClient = false;
388
+ // ============================================================================
389
+ // COMPATIBILITY
390
+ // ============================================================================
391
+ /**
392
+ * Server sharedConfig - Empty config object for compatibility
393
+ */
394
+ export const sharedConfig = {
395
+ context: null,
396
+ owner: null,
397
+ };
398
+ /**
399
+ * Set current reactive owner (for internal use)
400
+ * @internal
401
+ */
402
+ export function setOwner(owner) {
403
+ currentOwner = owner;
404
+ sharedConfig.owner = owner;
405
+ sharedConfig.context = owner;
406
+ }
407
+ /**
408
+ * Get shared config (for compatibility)
409
+ * @internal
410
+ */
411
+ export function getSharedConfig() {
412
+ return sharedConfig;
413
+ }
@@ -0,0 +1,176 @@
1
+ // src/lib/server/reactive.ts
2
+ function createSignal(value, options) {
3
+ let current = value;
4
+ const read = (() => current);
5
+ const write = (newValue) => {
6
+ if (typeof newValue === "function") {
7
+ current = newValue(current);
8
+ } else {
9
+ current = newValue;
10
+ }
11
+ return current;
12
+ };
13
+ return [read, write];
14
+ }
15
+ function createEffect(fn, value, options) {
16
+ try {
17
+ fn(value);
18
+ } catch (error) {
19
+ console.error("[Fluixi Server] Effect error:", error);
20
+ }
21
+ return { dispose: () => {
22
+ } };
23
+ }
24
+ function createMemo(fn, value, options) {
25
+ const computed = fn(value);
26
+ return (() => computed);
27
+ }
28
+ function createRoot(fn) {
29
+ const cleanups = [];
30
+ const dispose = () => {
31
+ cleanups.forEach((cleanup) => {
32
+ try {
33
+ cleanup();
34
+ } catch (error) {
35
+ console.error("[Fluixi Server] Cleanup error:", error);
36
+ }
37
+ });
38
+ cleanups.length = 0;
39
+ };
40
+ try {
41
+ return fn(dispose);
42
+ } catch (error) {
43
+ dispose();
44
+ throw error;
45
+ }
46
+ }
47
+ function batch(fn) {
48
+ return fn();
49
+ }
50
+ function untrack(fn) {
51
+ return fn();
52
+ }
53
+ var currentCleanups = null;
54
+ function onCleanup(fn) {
55
+ if (currentCleanups) {
56
+ currentCleanups.push(fn);
57
+ }
58
+ }
59
+ var currentOwner = null;
60
+ function getOwner() {
61
+ return currentOwner;
62
+ }
63
+ function runWithOwner(owner, fn) {
64
+ const prev = currentOwner;
65
+ currentOwner = owner;
66
+ try {
67
+ return fn();
68
+ } finally {
69
+ currentOwner = prev;
70
+ }
71
+ }
72
+ var contextMap = /* @__PURE__ */ new Map();
73
+ function createContext(defaultValue) {
74
+ const id = /* @__PURE__ */ Symbol("context");
75
+ const Provider = (props) => {
76
+ const prevValue = contextMap.get(id);
77
+ contextMap.set(id, props.value);
78
+ try {
79
+ return props.children;
80
+ } finally {
81
+ if (prevValue !== void 0) {
82
+ contextMap.set(id, prevValue);
83
+ } else {
84
+ contextMap.delete(id);
85
+ }
86
+ }
87
+ };
88
+ return {
89
+ id,
90
+ Provider,
91
+ defaultValue
92
+ };
93
+ }
94
+ function useContext(context) {
95
+ const value = contextMap.get(context.id);
96
+ return value !== void 0 ? value : context.defaultValue;
97
+ }
98
+ function createComputed(fn) {
99
+ return createEffect(fn);
100
+ }
101
+ function createRenderEffect(fn) {
102
+ return createEffect(fn);
103
+ }
104
+ function createDeferred(fn) {
105
+ return createMemo(fn);
106
+ }
107
+ function createSelector(source) {
108
+ const value = source();
109
+ return (key) => key === value;
110
+ }
111
+ function createResource(source, fetcher, options) {
112
+ return [
113
+ () => void 0,
114
+ {
115
+ mutate: (v) => v,
116
+ refetch: () => {
117
+ }
118
+ }
119
+ ];
120
+ }
121
+ function createStore(init) {
122
+ const state = { ...init };
123
+ function setStore(keyOrPatch, value) {
124
+ if (typeof keyOrPatch === "object" && keyOrPatch !== null && !Array.isArray(keyOrPatch)) {
125
+ for (const k of Object.keys(keyOrPatch)) {
126
+ const v = keyOrPatch[k];
127
+ state[k] = typeof v === "function" ? v(state[k]) : v;
128
+ }
129
+ } else {
130
+ state[keyOrPatch] = typeof value === "function" ? value(state[keyOrPatch]) : value;
131
+ }
132
+ }
133
+ return [state, setStore];
134
+ }
135
+ function startTransition(fn) {
136
+ fn();
137
+ }
138
+ var isServer = true;
139
+ var isClient = false;
140
+ var sharedConfig = {
141
+ context: null,
142
+ owner: null
143
+ };
144
+ function setOwner(owner) {
145
+ currentOwner = owner;
146
+ sharedConfig.owner = owner;
147
+ sharedConfig.context = owner;
148
+ }
149
+ function getSharedConfig() {
150
+ return sharedConfig;
151
+ }
152
+ export {
153
+ batch,
154
+ createComputed,
155
+ createContext,
156
+ createDeferred,
157
+ createEffect,
158
+ createMemo,
159
+ createRenderEffect,
160
+ createResource,
161
+ createRoot,
162
+ createSelector,
163
+ createSignal,
164
+ createStore,
165
+ getOwner,
166
+ getSharedConfig,
167
+ isClient,
168
+ isServer,
169
+ onCleanup,
170
+ runWithOwner,
171
+ setOwner,
172
+ sharedConfig,
173
+ startTransition,
174
+ untrack,
175
+ useContext
176
+ };
@@ -0,0 +1,51 @@
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/storage/cache.ts
21
+ var cache_exports = {};
22
+ __export(cache_exports, {
23
+ storageCache: () => storageCache
24
+ });
25
+ module.exports = __toCommonJS(cache_exports);
26
+ function storageCache(storage, options = {}) {
27
+ const inflight = /* @__PURE__ */ new Map();
28
+ return {
29
+ get(key) {
30
+ try {
31
+ const entry = storage.getEntry(key);
32
+ return entry ? { value: entry.value, timestamp: entry.createdAt } : void 0;
33
+ } catch {
34
+ return void 0;
35
+ }
36
+ },
37
+ set(key, entry) {
38
+ try {
39
+ storage.set(key, entry.value, options.ttl !== void 0 ? { ttl: options.ttl } : void 0);
40
+ } catch {
41
+ }
42
+ },
43
+ delete: (key) => storage.remove(key),
44
+ keys: () => storage.keys(),
45
+ clear() {
46
+ storage.clear();
47
+ inflight.clear();
48
+ },
49
+ inflight
50
+ };
51
+ }
@@ -0,0 +1,18 @@
1
+ import type { ResourceCache } from '@fluixi/reactive/cached-resource';
2
+ import type { TypedStorage } from '@fluixi/storage';
3
+ /**
4
+ * A `cachedResource` cache kept in a storage, so fetched data outlives the page: session
5
+ * storage for the tab, local storage across visits. Values pass through the storage's
6
+ * serializer, so they must be plain data. In-flight fetches stay in memory.
7
+ *
8
+ * Give it its own namespace, since `clearCachedResources()` clears that storage, and a `ttl`
9
+ * so entries do not pile up after the resource that wrote them is gone.
10
+ *
11
+ * @example
12
+ * const cache = storageCache(useStorage({ scope: 'session', namespace: 'cache' }), { ttl: 10 * 60_000 });
13
+ * const orgs = cachedResource(() => api.get('/orgs'), { name: 'orgs', ttl: 60_000, cache });
14
+ */
15
+ export declare function storageCache(storage: TypedStorage<any>, options?: {
16
+ ttl?: number;
17
+ }): ResourceCache;
18
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../../src/lib/storage/cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,EAAE,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,aAAa,CA2BtG"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * A `cachedResource` cache kept in a storage, so fetched data outlives the page: session
3
+ * storage for the tab, local storage across visits. Values pass through the storage's
4
+ * serializer, so they must be plain data. In-flight fetches stay in memory.
5
+ *
6
+ * Give it its own namespace, since `clearCachedResources()` clears that storage, and a `ttl`
7
+ * so entries do not pile up after the resource that wrote them is gone.
8
+ *
9
+ * @example
10
+ * const cache = storageCache(useStorage({ scope: 'session', namespace: 'cache' }), { ttl: 10 * 60_000 });
11
+ * const orgs = cachedResource(() => api.get('/orgs'), { name: 'orgs', ttl: 60_000, cache });
12
+ */
13
+ export function storageCache(storage, options = {}) {
14
+ const inflight = new Map();
15
+ return {
16
+ get(key) {
17
+ try {
18
+ const entry = storage.getEntry(key);
19
+ return entry ? { value: entry.value, timestamp: entry.createdAt } : undefined;
20
+ }
21
+ catch {
22
+ // Unreadable or blocked: a miss, and the resource fetches.
23
+ return undefined;
24
+ }
25
+ },
26
+ set(key, entry) {
27
+ try {
28
+ storage.set(key, entry.value, options.ttl !== undefined ? { ttl: options.ttl } : undefined);
29
+ }
30
+ catch {
31
+ /* quota, or a value the serializer refuses: kept for this page only by the fetch itself */
32
+ }
33
+ },
34
+ delete: (key) => storage.remove(key),
35
+ keys: () => storage.keys(),
36
+ clear() {
37
+ storage.clear();
38
+ inflight.clear();
39
+ },
40
+ inflight,
41
+ };
42
+ }