@fluixi/core 1.0.0-alpha.83 → 1.0.0-alpha.85

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 (182) hide show
  1. package/dist/cdn/core.global.js +2 -1
  2. package/dist/cli/generate.cjs +4117 -292
  3. package/dist/cli/generate.mjs +4122 -292
  4. package/dist/cli/index.cjs +4117 -292
  5. package/dist/cli/index.mjs +4122 -292
  6. package/dist/cli/run.cjs +63 -1
  7. package/dist/cli/run.mjs +39 -1
  8. package/dist/src/cdn/chunk-MDJLC3PE.mjs +830 -0
  9. package/dist/src/cdn/core.cjs +1365 -1
  10. package/dist/src/cdn/core.d.ts +3 -3
  11. package/dist/src/cdn/core.js +3 -3
  12. package/dist/src/cdn/core.mjs +642 -1
  13. package/dist/src/cdn/router-JYFZP3EZ.mjs +70 -0
  14. package/dist/src/index.cjs +1280 -1
  15. package/dist/src/index.d.ts.map +1 -1
  16. package/dist/src/index.js +1 -11
  17. package/dist/src/index.mjs +1393 -1
  18. package/dist/src/jsx-dev-runtime.cjs +26 -1
  19. package/dist/src/jsx-dev-runtime.mjs +24 -1
  20. package/dist/src/jsx-runtime.cjs +26 -1
  21. package/dist/src/jsx-runtime.js +0 -9
  22. package/dist/src/jsx-runtime.mjs +24 -1
  23. package/dist/src/lib/client/chunk-7IUN2FLI.mjs +133 -0
  24. package/dist/src/lib/client/index.cjs +956 -1
  25. package/dist/src/lib/client/index.d.ts +17 -6
  26. package/dist/src/lib/client/index.d.ts.map +1 -1
  27. package/dist/src/lib/client/index.js +26 -19
  28. package/dist/src/lib/client/index.mjs +222 -1
  29. package/dist/src/lib/client/router-NOFEMOEH.mjs +631 -0
  30. package/dist/src/lib/context/context.cjs +118 -1
  31. package/dist/src/lib/context/context.d.ts +19 -37
  32. package/dist/src/lib/context/context.d.ts.map +1 -1
  33. package/dist/src/lib/context/context.js +8 -45
  34. package/dist/src/lib/context/context.mjs +99 -1
  35. package/dist/src/lib/context/index.cjs +120 -1
  36. package/dist/src/lib/context/index.mjs +99 -1
  37. package/dist/src/lib/control-flow.cjs +35 -1
  38. package/dist/src/lib/control-flow.mjs +25 -1
  39. package/dist/src/lib/core.cjs +1279 -1
  40. package/dist/src/lib/core.d.ts +0 -2
  41. package/dist/src/lib/core.d.ts.map +1 -1
  42. package/dist/src/lib/core.js +14 -48
  43. package/dist/src/lib/core.mjs +1393 -1
  44. package/dist/src/lib/env/index.cjs +60 -1
  45. package/dist/src/lib/env/index.d.ts +5 -5
  46. package/dist/src/lib/env/index.js +5 -5
  47. package/dist/src/lib/env/index.mjs +39 -1
  48. package/dist/src/lib/i18n/index.cjs +108 -1
  49. package/dist/src/lib/i18n/index.d.ts +31 -10
  50. package/dist/src/lib/i18n/index.d.ts.map +1 -1
  51. package/dist/src/lib/i18n/index.js +31 -10
  52. package/dist/src/lib/i18n/index.mjs +88 -1
  53. package/dist/src/lib/index.cjs +633 -1
  54. package/dist/src/lib/index.d.ts +0 -2
  55. package/dist/src/lib/index.d.ts.map +1 -1
  56. package/dist/src/lib/index.js +5 -11
  57. package/dist/src/lib/index.mjs +721 -1
  58. package/dist/src/lib/isomorphic.cjs +85 -1
  59. package/dist/src/lib/isomorphic.d.ts +41 -8
  60. package/dist/src/lib/isomorphic.d.ts.map +1 -1
  61. package/dist/src/lib/isomorphic.js +38 -5
  62. package/dist/src/lib/isomorphic.mjs +64 -1
  63. package/dist/src/lib/jsx-runtime/index.cjs +21 -1
  64. package/dist/src/lib/jsx-runtime/index.d.ts +1 -1
  65. package/dist/src/lib/jsx-runtime/index.js +1 -11
  66. package/dist/src/lib/jsx-runtime/index.mjs +4 -1
  67. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -1
  68. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -1
  69. package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -8
  70. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +15 -1
  71. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -1
  72. package/dist/src/lib/plugins/fluixi-routes-plugin.js +19 -5
  73. package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -8
  74. package/dist/src/lib/plugins/index.cjs +311 -8
  75. package/dist/src/lib/plugins/index.mjs +279 -8
  76. package/dist/src/lib/plugins/route-codegen.cjs +73 -8
  77. package/dist/src/lib/plugins/route-codegen.d.ts +0 -1
  78. package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -1
  79. package/dist/src/lib/plugins/route-codegen.js +4 -5
  80. package/dist/src/lib/plugins/route-codegen.mjs +52 -8
  81. package/dist/src/lib/plugins/route-scanner.cjs +189 -1
  82. package/dist/src/lib/plugins/route-scanner.d.ts +1 -2
  83. package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -1
  84. package/dist/src/lib/plugins/route-scanner.js +7 -8
  85. package/dist/src/lib/plugins/route-scanner.mjs +158 -1
  86. package/dist/src/lib/plugins/vite.cjs +27 -1
  87. package/dist/src/lib/plugins/vite.mjs +6 -1
  88. package/dist/src/lib/render/await.cjs +38 -1
  89. package/dist/src/lib/render/await.d.ts +18 -0
  90. package/dist/src/lib/render/await.d.ts.map +1 -1
  91. package/dist/src/lib/render/await.js +20 -2
  92. package/dist/src/lib/render/await.mjs +17 -1
  93. package/dist/src/lib/render/component.cjs +221 -1
  94. package/dist/src/lib/render/component.d.ts +3 -44
  95. package/dist/src/lib/render/component.d.ts.map +1 -1
  96. package/dist/src/lib/render/component.js +23 -55
  97. package/dist/src/lib/render/component.mjs +214 -1
  98. package/dist/src/lib/render/deferred.cjs +175 -1
  99. package/dist/src/lib/render/deferred.js +5 -5
  100. package/dist/src/lib/render/deferred.mjs +158 -1
  101. package/dist/src/lib/render/index.cjs +573 -1
  102. package/dist/src/lib/render/index.d.ts +3 -17
  103. package/dist/src/lib/render/index.d.ts.map +1 -1
  104. package/dist/src/lib/render/index.js +8 -22
  105. package/dist/src/lib/render/index.mjs +590 -1
  106. package/dist/src/lib/render/lazy.cjs +67 -1
  107. package/dist/src/lib/render/lazy.d.ts +22 -1
  108. package/dist/src/lib/render/lazy.d.ts.map +1 -1
  109. package/dist/src/lib/render/lazy.js +26 -5
  110. package/dist/src/lib/render/lazy.mjs +50 -1
  111. package/dist/src/lib/render/suspense.cjs +141 -1
  112. package/dist/src/lib/render/suspense.d.ts +40 -0
  113. package/dist/src/lib/render/suspense.d.ts.map +1 -1
  114. package/dist/src/lib/render/suspense.js +46 -6
  115. package/dist/src/lib/render/suspense.mjs +136 -1
  116. package/dist/src/lib/render/versions.cjs +35 -1
  117. package/dist/src/lib/render/versions.js +6 -6
  118. package/dist/src/lib/render/versions.mjs +14 -1
  119. package/dist/src/lib/router/data.cjs +230 -1
  120. package/dist/src/lib/router/data.d.ts +1 -13
  121. package/dist/src/lib/router/data.d.ts.map +1 -1
  122. package/dist/src/lib/router/data.js +0 -12
  123. package/dist/src/lib/router/data.mjs +214 -1
  124. package/dist/src/lib/router/index.cjs +709 -1
  125. package/dist/src/lib/router/index.d.ts +78 -23
  126. package/dist/src/lib/router/index.d.ts.map +1 -1
  127. package/dist/src/lib/router/index.js +161 -37
  128. package/dist/src/lib/router/index.mjs +722 -1
  129. package/dist/src/lib/router/transition.cjs +75 -0
  130. package/dist/src/lib/router/transition.d.ts +81 -0
  131. package/dist/src/lib/router/transition.d.ts.map +1 -0
  132. package/dist/src/lib/router/transition.js +136 -0
  133. package/dist/src/lib/router/transition.mjs +54 -0
  134. package/dist/src/lib/server/hydration.cjs +169 -1
  135. package/dist/src/lib/server/hydration.d.ts +15 -55
  136. package/dist/src/lib/server/hydration.d.ts.map +1 -1
  137. package/dist/src/lib/server/hydration.js +23 -62
  138. package/dist/src/lib/server/hydration.mjs +148 -1
  139. package/dist/src/lib/server/index.cjs +401 -11
  140. package/dist/src/lib/server/index.d.ts +30 -6
  141. package/dist/src/lib/server/index.d.ts.map +1 -1
  142. package/dist/src/lib/server/index.js +34 -11
  143. package/dist/src/lib/server/index.mjs +379 -11
  144. package/dist/src/lib/server/reactive.cjs +197 -1
  145. package/dist/src/lib/server/reactive.d.ts +18 -77
  146. package/dist/src/lib/server/reactive.d.ts.map +1 -1
  147. package/dist/src/lib/server/reactive.js +19 -78
  148. package/dist/src/lib/server/reactive.mjs +176 -1
  149. package/dist/src/lib/theme/index.cjs +110 -1
  150. package/dist/src/lib/theme/index.d.ts +19 -4
  151. package/dist/src/lib/theme/index.d.ts.map +1 -1
  152. package/dist/src/lib/theme/index.js +17 -2
  153. package/dist/src/lib/theme/index.mjs +89 -1
  154. package/dist/src/lib/utils/index.cjs +209 -1
  155. package/dist/src/lib/utils/index.d.ts +0 -93
  156. package/dist/src/lib/utils/index.d.ts.map +1 -1
  157. package/dist/src/lib/utils/index.js +0 -93
  158. package/dist/src/lib/utils/index.mjs +188 -1
  159. package/dist/src/routes.cjs +37 -1
  160. package/dist/src/routes.d.ts +1 -1
  161. package/dist/src/routes.js +2 -2
  162. package/dist/src/routes.mjs +17 -1
  163. package/dist/src/server.cjs +400 -11
  164. package/dist/src/server.d.ts +0 -1
  165. package/dist/src/server.d.ts.map +1 -1
  166. package/dist/src/server.js +0 -1
  167. package/dist/src/server.mjs +377 -11
  168. package/dist/src/utils.cjs +21 -1
  169. package/dist/src/utils.d.ts +1 -1
  170. package/dist/src/utils.js +1 -1
  171. package/dist/src/utils.mjs +4 -1
  172. package/dist/src/version.generated.cjs +26 -1
  173. package/dist/src/version.generated.d.ts +1 -1
  174. package/dist/src/version.generated.js +2 -2
  175. package/dist/src/version.generated.mjs +5 -1
  176. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  177. package/package.json +17 -16
  178. package/src/index.ts +2 -14
  179. package/dist/src/cdn/chunk-55BT3H6E.mjs +0 -1
  180. package/dist/src/cdn/router-5JJZBK4E.mjs +0 -1
  181. package/dist/src/lib/client/chunk-SM4WHBOP.mjs +0 -1
  182. package/dist/src/lib/client/router-IBD4WPQT.mjs +0 -1
@@ -1 +1,37 @@
1
- "use strict";var n=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var d=(e,i)=>{for(var o in i)n(e,o,{get:i[o],enumerable:!0})},s=(e,i,o,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let t of l(i))!f.call(e,t)&&t!==o&&n(e,t,{get:()=>i[t],enumerable:!(r=u(i,t))||r.enumerable});return e};var a=e=>s(n({},"__esModule",{value:!0}),e);var p={};d(p,{routes:()=>g});module.exports=a(p);function x(){throw new Error("[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, so there is no route tree. Add the plugin to your Vite config — or, in a @fluixi/start app, build with `fluixi build`/`fluixi dev` rather than calling vite directly.")}var g=new Proxy([],{get:(e,i)=>i==="then"?void 0:x()});
1
+ /*! @fluixi/core v1.0.0-alpha.85 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/routes.ts
22
+ var routes_exports = {};
23
+ __export(routes_exports, {
24
+ routes: () => routes
25
+ });
26
+ module.exports = __toCommonJS(routes_exports);
27
+ function missingPlugin() {
28
+ throw new Error(
29
+ "[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, so there is no route tree. Add the plugin to your Vite config, or, in a @fluixi/start app, build with `fluixi build`/`fluixi dev` rather than calling vite directly."
30
+ );
31
+ }
32
+ var routes = new Proxy([], {
33
+ get: (target, key) => (
34
+ // `then` is probed by any `await`; answering undefined keeps this from looking thenable.
35
+ key === "then" ? void 0 : missingPlugin()
36
+ )
37
+ });
@@ -12,7 +12,7 @@
12
12
  * It exists as a real module so the types come from this package rather than from an
13
13
  * ambient `declare module` the plugin writes into your `src/`. That generated file could
14
14
  * drift, raised a gitignore question, and left `virtual:fluixi-routes` invisible to
15
- * anything not running the Vite plugin plain `tsc`, an editor, a test runner.
15
+ * anything not running the Vite plugin: plain `tsc`, an editor, a test runner.
16
16
  *
17
17
  * `virtual:fluixi-routes` still resolves, so existing apps keep working.
18
18
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Reaching this code means the plugin did not replace the module.
3
3
  *
4
- * The alternative exporting an empty array is worse than it looks: the app builds, the
4
+ * The alternative, exporting an empty array, is worse than it looks: the app builds, the
5
5
  * router mounts, and every route 404s with nothing to explain why. A virtual specifier at
6
6
  * least failed loudly when the plugin was missing, and giving that up for better types
7
7
  * should not also give up the error. TypeScript never evaluates this, so type-checking is
@@ -9,7 +9,7 @@
9
9
  */
10
10
  function missingPlugin() {
11
11
  throw new Error("[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, " +
12
- 'so there is no route tree. Add the plugin to your Vite config or, in a @fluixi/start ' +
12
+ 'so there is no route tree. Add the plugin to your Vite config, or, in a @fluixi/start ' +
13
13
  'app, build with `fluixi build`/`fluixi dev` rather than calling vite directly.');
14
14
  }
15
15
  /** Routes discovered under the configured routes directory (default `src/routes`). */
@@ -1 +1,17 @@
1
- function e(){throw new Error("[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, so there is no route tree. Add the plugin to your Vite config or, in a @fluixi/start app, build with `fluixi build`/`fluixi dev` rather than calling vite directly.")}var o=new Proxy([],{get:(t,i)=>i==="then"?void 0:e()});export{o as routes};
1
+ /*! @fluixi/core v1.0.0-alpha.85 | (c) 2026 Ibrahima Touré and Fluixi contributors | MIT */
2
+
3
+ // src/routes.ts
4
+ function missingPlugin() {
5
+ throw new Error(
6
+ "[fluixi] '@fluixi/core/routes' was imported but fluixiRoutesPlugin did not replace it, so there is no route tree. Add the plugin to your Vite config, or, in a @fluixi/start app, build with `fluixi build`/`fluixi dev` rather than calling vite directly."
7
+ );
8
+ }
9
+ var routes = new Proxy([], {
10
+ get: (target, key) => (
11
+ // `then` is probed by any `await`; answering undefined keeps this from looking thenable.
12
+ key === "then" ? void 0 : missingPlugin()
13
+ )
14
+ });
15
+ export {
16
+ routes
17
+ };
@@ -1,16 +1,405 @@
1
- "use strict";var T=Object.defineProperty;var st=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var ut=Object.prototype.hasOwnProperty;var dt=(t,e)=>{for(var n in e)T(t,n,{get:e[n],enumerable:!0})},lt=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ct(e))!ut.call(t,o)&&o!==n&&T(t,o,{get:()=>e[o],enumerable:!(r=st(e,o))||r.enumerable});return t};var pt=t=>lt(T({},"__esModule",{value:!0}),t);var St={};dt(St,{batch:()=>I,cleanupHydration:()=>m,clearHydrationData:()=>g,clearHydrationDataKey:()=>H,createComputed:()=>P,createContext:()=>U,createDeferred:()=>X,createEffect:()=>f,createHtmlDocument:()=>tt,createHydratableResource:()=>k,createMemo:()=>S,createRenderEffect:()=>V,createResource:()=>J,createRoot:()=>F,createSelector:()=>B,createSignal:()=>K,deserializeHydrationData:()=>b,getHydrationData:()=>d,getOwner:()=>W,getSSRContext:()=>ft,hasHydrationData:()=>R,hydrationMarker:()=>O,hydrationMarkerEnd:()=>A,hydrationMarkerStart:()=>E,isClient:()=>nt,isClientEnvironment:()=>M,isClientReactive:()=>Q,isHydrating:()=>x,isServer:()=>et,isServerEnvironment:()=>j,isServerReactive:()=>G,onCleanup:()=>z,onClient:()=>gt,onServer:()=>xt,renderToPage:()=>Z,renderToStream:()=>rt,renderToString:()=>h,runWithOwner:()=>L,serializeHydrationData:()=>l,setHydrating:()=>D,setHydrationData:()=>u,setSSRContext:()=>yt,startServer:()=>mt,startTransition:()=>q,untrack:()=>N,useContext:()=>Y,useHydrationData:()=>_,withSSRContext:()=>Tt});module.exports=pt(St);var C=!1,a=new Map;function x(){return C}function D(t){C=t}function u(t,e){a.set(t,e)}function d(t){return a.get(t)}function R(t){return a.has(t)}function g(){a.clear()}function H(t){a.delete(t)}function l(){if(a.size===0)return"";let t=Object.fromEntries(a);return`<script type="application/json" id="__FLUIXI_HYDRATION__">${JSON.stringify(t)}<\/script>`}function b(){if(typeof window>"u")return!1;let t=document.getElementById("__FLUIXI_HYDRATION__");if(!t||t.getAttribute("type")!=="application/json")return!1;try{let e=t.textContent||"{}",n=JSON.parse(e);for(let[r,o]of Object.entries(n))a.set(r,o);return!0}catch(e){return console.error("Failed to deserialize hydration data:",e),!1}}function O(t){return`<!--#${t}-->`}function E(t){return`<!--#${t}-->`}function A(t){return`<!--/${t}-->`}function k(t,e){return async()=>{if(x()||typeof window<"u"){let r=d(t);if(r!==void 0)return r}let n=await e();return typeof window>"u"&&u(t,n),n}}function _(t,e){let n=d(t);if(n!==void 0)return n;let r=typeof e=="function"?e():e;return typeof window>"u"&&u(t,r),r}function m(){if(typeof window>"u")return;let t=document.getElementById("__FLUIXI_HYDRATION__");t&&t.remove();let e=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,null),n=[],r;for(;r=e.nextNode();){let o=r,i=o.nodeValue||"";(i.startsWith("#")||i.startsWith("/"))&&n.push(o)}n.forEach(o=>o.remove()),g()}typeof window<"u"&&window.addEventListener("load",()=>{setTimeout(m,100)});function j(){return typeof window>"u"}function M(){return typeof window<"u"}var v=require("@fluixi/server");function K(t,e){let n=t;return[(()=>n),i=>(typeof i=="function"?n=i(n):n=i,n)]}function f(t,e,n){try{t(e)}catch(r){console.error("[Fluixi Server] Effect error:",r)}return{dispose:()=>{}}}function S(t,e,n){let r=t(e);return(()=>r)}function F(t){let e=[],n=()=>{e.forEach(r=>{try{r()}catch(o){console.error("[Fluixi Server] Cleanup error:",o)}}),e.length=0};try{return t(n)}catch(r){throw n(),r}}function I(t){return t()}function N(t){return t()}var $=null;function z(t){$&&$.push(t)}var p=null;function W(){return p}function L(t,e){let n=p;p=t;try{return e()}finally{p=n}}var s=new Map;function U(t){let e=Symbol("context");return{id:e,Provider:r=>{let o=s.get(e);s.set(e,r.value);try{return r.children}finally{o!==void 0?s.set(e,o):s.delete(e)}},defaultValue:t}}function Y(t){let e=s.get(t.id);return e!==void 0?e:t.defaultValue}function P(t){return f(t)}function V(t){return f(t)}function X(t){return S(t)}function B(t){let e=t();return n=>n===e}function J(t,e,n){return[()=>{},{mutate:r=>r,refetch:()=>{}}]}function q(t){t()}var G=!0,Q=!1;var c=null;function ft(){return c}function yt(t){c=t}function Tt(t,e){let n=c;c=t;try{return e()}finally{c=n}}async function Z(t,e={}){let n=await h(t);return tt(n,e)}function tt(t,e={}){let{title:n="Fluixi App",lang:r="en",stylesheets:o=[],scripts:i=[],head:ot="",bodyAttributes:w=""}=e,it=o.map(y=>`<link rel="stylesheet" href="${y}">`).join(`
2
- `),at=i.map(y=>`<script type="module" src="${y}"><\/script>`).join(`
3
- `);return`<!DOCTYPE html>
4
- <html lang="${r}">
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/server.ts
21
+ var server_exports = {};
22
+ __export(server_exports, {
23
+ batch: () => batch,
24
+ cleanupHydration: () => cleanupHydration,
25
+ clearHydrationData: () => clearHydrationData,
26
+ clearHydrationDataKey: () => clearHydrationDataKey,
27
+ createComputed: () => createComputed,
28
+ createContext: () => createContext,
29
+ createDeferred: () => createDeferred,
30
+ createEffect: () => createEffect,
31
+ createHtmlDocument: () => createHtmlDocument,
32
+ createHydratableResource: () => createHydratableResource,
33
+ createMemo: () => createMemo,
34
+ createRenderEffect: () => createRenderEffect,
35
+ createResource: () => createResource,
36
+ createRoot: () => createRoot,
37
+ createSelector: () => createSelector,
38
+ createSignal: () => createSignal,
39
+ deserializeHydrationData: () => deserializeHydrationData,
40
+ getHydrationData: () => getHydrationData,
41
+ getOwner: () => getOwner,
42
+ getSSRContext: () => getSSRContext,
43
+ hasHydrationData: () => hasHydrationData,
44
+ hydrationMarker: () => hydrationMarker,
45
+ hydrationMarkerEnd: () => hydrationMarkerEnd,
46
+ hydrationMarkerStart: () => hydrationMarkerStart,
47
+ isClient: () => isClient2,
48
+ isClientEnvironment: () => isClientEnvironment,
49
+ isClientReactive: () => isClient,
50
+ isHydrating: () => isHydrating,
51
+ isServer: () => import_dom2.isServer,
52
+ isServerEnvironment: () => isServerEnvironment,
53
+ isServerReactive: () => isServer,
54
+ onCleanup: () => onCleanup,
55
+ onClient: () => onClient,
56
+ onServer: () => onServer,
57
+ renderToPage: () => renderToPage,
58
+ renderToStream: () => renderToStream,
59
+ renderToString: () => renderToString,
60
+ runWithOwner: () => runWithOwner,
61
+ serializeHydrationData: () => serializeHydrationData,
62
+ setHydrating: () => setHydrating,
63
+ setHydrationData: () => setHydrationData,
64
+ setSSRContext: () => setSSRContext,
65
+ startServer: () => startServer,
66
+ startTransition: () => startTransition,
67
+ untrack: () => untrack,
68
+ useContext: () => useContext,
69
+ useHydrationData: () => useHydrationData,
70
+ withSSRContext: () => withSSRContext
71
+ });
72
+ module.exports = __toCommonJS(server_exports);
73
+
74
+ // src/lib/server/hydration.ts
75
+ var import_dom = require("@fluixi/dom");
76
+ var hydrating = false;
77
+ var hydrationDataMap = /* @__PURE__ */ new Map();
78
+ function isHydrating() {
79
+ return hydrating;
80
+ }
81
+ function setHydrating(state) {
82
+ hydrating = state;
83
+ }
84
+ function setHydrationData(key, data) {
85
+ hydrationDataMap.set(key, data);
86
+ }
87
+ function getHydrationData(key) {
88
+ return hydrationDataMap.get(key);
89
+ }
90
+ function hasHydrationData(key) {
91
+ return hydrationDataMap.has(key);
92
+ }
93
+ function clearHydrationData() {
94
+ hydrationDataMap.clear();
95
+ }
96
+ function clearHydrationDataKey(key) {
97
+ hydrationDataMap.delete(key);
98
+ }
99
+ function serializeHydrationData() {
100
+ if (hydrationDataMap.size === 0) {
101
+ return "";
102
+ }
103
+ const data = Object.fromEntries(hydrationDataMap);
104
+ const json = JSON.stringify(data);
105
+ return `<script type="application/json" id="__FLUIXI_HYDRATION__">${json}<\/script>`;
106
+ }
107
+ function deserializeHydrationData() {
108
+ if (typeof window === "undefined") {
109
+ return false;
110
+ }
111
+ const script = document.getElementById("__FLUIXI_HYDRATION__");
112
+ if (!script || script.getAttribute("type") !== "application/json") {
113
+ return false;
114
+ }
115
+ try {
116
+ const json = script.textContent || "{}";
117
+ const data = JSON.parse(json);
118
+ for (const [key, value] of Object.entries(data)) {
119
+ hydrationDataMap.set(key, value);
120
+ }
121
+ return true;
122
+ } catch (error) {
123
+ console.error("Failed to deserialize hydration data:", error);
124
+ return false;
125
+ }
126
+ }
127
+ function hydrationMarker(id) {
128
+ return `<!--#${id}-->`;
129
+ }
130
+ function hydrationMarkerStart(id) {
131
+ return `<!--#${id}-->`;
132
+ }
133
+ function hydrationMarkerEnd(id) {
134
+ return `<!--/${id}-->`;
135
+ }
136
+ function createHydratableResource(key, fetcher) {
137
+ return async () => {
138
+ if (isHydrating() || typeof window !== "undefined") {
139
+ const cached = getHydrationData(key);
140
+ if (cached !== void 0) {
141
+ return cached;
142
+ }
143
+ }
144
+ const data = await fetcher();
145
+ if (typeof window === "undefined") {
146
+ setHydrationData(key, data);
147
+ }
148
+ return data;
149
+ };
150
+ }
151
+ function useHydrationData(key, value) {
152
+ const hydrationData = getHydrationData(key);
153
+ if (hydrationData !== void 0) {
154
+ return hydrationData;
155
+ }
156
+ const computedValue = typeof value === "function" ? value() : value;
157
+ if (typeof window === "undefined") {
158
+ setHydrationData(key, computedValue);
159
+ }
160
+ return computedValue;
161
+ }
162
+ function cleanupHydration() {
163
+ if (typeof window === "undefined") {
164
+ return;
165
+ }
166
+ const script = document.getElementById("__FLUIXI_HYDRATION__");
167
+ if (script) {
168
+ script.remove();
169
+ }
170
+ const walker = document.createTreeWalker(
171
+ document.body,
172
+ NodeFilter.SHOW_COMMENT,
173
+ null
174
+ );
175
+ const comments = [];
176
+ let node;
177
+ while (node = walker.nextNode()) {
178
+ const comment = node;
179
+ const text = comment.nodeValue || "";
180
+ if (text.startsWith("#") || text.startsWith("/")) {
181
+ comments.push(comment);
182
+ }
183
+ }
184
+ comments.forEach((comment) => comment.remove());
185
+ clearHydrationData();
186
+ }
187
+ if (typeof window !== "undefined") {
188
+ window.addEventListener("load", () => {
189
+ setTimeout(cleanupHydration, 100);
190
+ });
191
+ }
192
+ function isServerEnvironment() {
193
+ return (0, import_dom.isServer)();
194
+ }
195
+ function isClientEnvironment() {
196
+ return !(0, import_dom.isServer)();
197
+ }
198
+
199
+ // src/lib/server/index.ts
200
+ var import_server = require("@fluixi/server");
201
+ var import_dom2 = require("@fluixi/dom");
202
+
203
+ // src/lib/server/reactive.ts
204
+ function createSignal(value, options) {
205
+ let current = value;
206
+ const read = (() => current);
207
+ const write = (newValue) => {
208
+ if (typeof newValue === "function") {
209
+ current = newValue(current);
210
+ } else {
211
+ current = newValue;
212
+ }
213
+ return current;
214
+ };
215
+ return [read, write];
216
+ }
217
+ function createEffect(fn, value, options) {
218
+ try {
219
+ fn(value);
220
+ } catch (error) {
221
+ console.error("[Fluixi Server] Effect error:", error);
222
+ }
223
+ return { dispose: () => {
224
+ } };
225
+ }
226
+ function createMemo(fn, value, options) {
227
+ const computed = fn(value);
228
+ return (() => computed);
229
+ }
230
+ function createRoot(fn) {
231
+ const cleanups = [];
232
+ const dispose = () => {
233
+ cleanups.forEach((cleanup) => {
234
+ try {
235
+ cleanup();
236
+ } catch (error) {
237
+ console.error("[Fluixi Server] Cleanup error:", error);
238
+ }
239
+ });
240
+ cleanups.length = 0;
241
+ };
242
+ try {
243
+ return fn(dispose);
244
+ } catch (error) {
245
+ dispose();
246
+ throw error;
247
+ }
248
+ }
249
+ function batch(fn) {
250
+ return fn();
251
+ }
252
+ function untrack(fn) {
253
+ return fn();
254
+ }
255
+ var currentCleanups = null;
256
+ function onCleanup(fn) {
257
+ if (currentCleanups) {
258
+ currentCleanups.push(fn);
259
+ }
260
+ }
261
+ var currentOwner = null;
262
+ function getOwner() {
263
+ return currentOwner;
264
+ }
265
+ function runWithOwner(owner, fn) {
266
+ const prev = currentOwner;
267
+ currentOwner = owner;
268
+ try {
269
+ return fn();
270
+ } finally {
271
+ currentOwner = prev;
272
+ }
273
+ }
274
+ var contextMap = /* @__PURE__ */ new Map();
275
+ function createContext(defaultValue) {
276
+ const id = /* @__PURE__ */ Symbol("context");
277
+ const Provider = (props) => {
278
+ const prevValue = contextMap.get(id);
279
+ contextMap.set(id, props.value);
280
+ try {
281
+ return props.children;
282
+ } finally {
283
+ if (prevValue !== void 0) {
284
+ contextMap.set(id, prevValue);
285
+ } else {
286
+ contextMap.delete(id);
287
+ }
288
+ }
289
+ };
290
+ return {
291
+ id,
292
+ Provider,
293
+ defaultValue
294
+ };
295
+ }
296
+ function useContext(context) {
297
+ const value = contextMap.get(context.id);
298
+ return value !== void 0 ? value : context.defaultValue;
299
+ }
300
+ function createComputed(fn) {
301
+ return createEffect(fn);
302
+ }
303
+ function createRenderEffect(fn) {
304
+ return createEffect(fn);
305
+ }
306
+ function createDeferred(fn) {
307
+ return createMemo(fn);
308
+ }
309
+ function createSelector(source) {
310
+ const value = source();
311
+ return (key) => key === value;
312
+ }
313
+ function createResource(source, fetcher, options) {
314
+ return [
315
+ () => void 0,
316
+ {
317
+ mutate: (v) => v,
318
+ refetch: () => {
319
+ }
320
+ }
321
+ ];
322
+ }
323
+ function startTransition(fn) {
324
+ fn();
325
+ }
326
+ var isServer = true;
327
+ var isClient = false;
328
+
329
+ // src/lib/server/index.ts
330
+ var import_dom3 = require("@fluixi/dom");
331
+ var currentSSRContext = null;
332
+ function getSSRContext() {
333
+ return currentSSRContext;
334
+ }
335
+ function setSSRContext(context) {
336
+ currentSSRContext = context;
337
+ }
338
+ function withSSRContext(context, fn) {
339
+ const prev = currentSSRContext;
340
+ currentSSRContext = context;
341
+ try {
342
+ return fn();
343
+ } finally {
344
+ currentSSRContext = prev;
345
+ }
346
+ }
347
+ async function renderToPage(code, options = {}) {
348
+ const content = await renderToString(code);
349
+ return createHtmlDocument(content, options);
350
+ }
351
+ function createHtmlDocument(content, options = {}) {
352
+ const {
353
+ title = "Fluixi App",
354
+ lang = "en",
355
+ stylesheets = [],
356
+ scripts = [],
357
+ head = "",
358
+ bodyAttributes = ""
359
+ } = options;
360
+ const styleTags = stylesheets.map((href) => `<link rel="stylesheet" href="${href}">`).join("\n ");
361
+ const scriptTags = scripts.map((src) => `<script type="module" src="${src}"><\/script>`).join("\n ");
362
+ return `<!DOCTYPE html>
363
+ <html lang="${lang}">
5
364
  <head>
6
365
  <meta charset="UTF-8">
7
366
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
- <title>${n}</title>
9
- ${it}
10
- ${ot}
367
+ <title>${title}</title>
368
+ ${styleTags}
369
+ ${head}
11
370
  </head>
12
- <body${w?" "+w:""}>
13
- ${t}
14
- ${at}
371
+ <body${bodyAttributes ? " " + bodyAttributes : ""}>
372
+ ${content}
373
+ ${scriptTags}
15
374
  </body>
16
- </html>`}function et(){return typeof window>"u"}function nt(){return typeof window<"u"}function xt(t,e){return et()?t():e}function gt(t,e){return nt()?t():e}async function h(t){let e=await(0,v.renderToString)(t),n=l();return e+n}async function rt(t){let e=await(0,v.renderToString)(t),n=l();return e+n}function mt(t){return{render:e=>h(()=>t({url:e})),stream:e=>rt(()=>t({url:e})),page:(e,n)=>Z(()=>t({url:e}),n)}}
375
+ </html>`;
376
+ }
377
+ function isClient2() {
378
+ return !(0, import_dom3.isServer)();
379
+ }
380
+ function onServer(fn, fallback) {
381
+ return (0, import_dom3.isServer)() ? fn() : fallback;
382
+ }
383
+ function onClient(fn, fallback) {
384
+ return !(0, import_dom3.isServer)() ? fn() : fallback;
385
+ }
386
+ async function renderToString(code) {
387
+ const html = await (0, import_server.renderToString)(code);
388
+ const script = serializeHydrationData();
389
+ return html + script;
390
+ }
391
+ async function renderToStream(code) {
392
+ const html = await (0, import_server.renderToString)(code);
393
+ const script = serializeHydrationData();
394
+ return html + script;
395
+ }
396
+ function startServer(App) {
397
+ return {
398
+ /** Render the app to a full HTML string (includes hydration data) */
399
+ render: (url) => renderToString(() => App({ url })),
400
+ /** Render the app to a streamable HTML string (includes hydration data) */
401
+ stream: (url) => renderToStream(() => App({ url })),
402
+ /** Render the app to a complete HTML page document */
403
+ page: (url, opts) => renderToPage(() => App({ url }), opts)
404
+ };
405
+ }
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @fileoverview Server exports for Fluixi
3
2
  * @module @fluixi/core/server
4
3
  *
5
4
  * This module provides server-side rendering and hydration utilities.
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,cAAc,uBAAuB,CAAC"}
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @fileoverview Server exports for Fluixi
3
2
  * @module @fluixi/core/server
4
3
  *
5
4
  * This module provides server-side rendering and hydration utilities.