@fluixi/core 1.0.0-alpha.82 → 1.0.0-alpha.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) 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-VNLCQBFQ.mjs +747 -0
  9. package/dist/src/cdn/core.cjs +1279 -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-WMN2AA7E.mjs +66 -0
  14. package/dist/src/index.cjs +1201 -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 +1313 -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-2C2KDDQV.mjs +133 -0
  24. package/dist/src/lib/client/index.cjs +870 -1
  25. package/dist/src/lib/client/index.d.ts +10 -14
  26. package/dist/src/lib/client/index.d.ts.map +1 -1
  27. package/dist/src/lib/client/index.js +36 -21
  28. package/dist/src/lib/client/index.mjs +222 -1
  29. package/dist/src/lib/client/router-X526HSWQ.mjs +548 -0
  30. package/dist/src/lib/context/context.cjs +118 -1
  31. package/dist/src/lib/context/context.d.ts +20 -38
  32. package/dist/src/lib/context/context.d.ts.map +1 -1
  33. package/dist/src/lib/context/context.js +10 -47
  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 +1200 -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 +1313 -1
  44. package/dist/src/lib/env/index.cjs +60 -1
  45. package/dist/src/lib/env/index.d.ts +7 -8
  46. package/dist/src/lib/env/index.d.ts.map +1 -1
  47. package/dist/src/lib/env/index.js +14 -9
  48. package/dist/src/lib/env/index.mjs +39 -1
  49. package/dist/src/lib/i18n/index.cjs +108 -1
  50. package/dist/src/lib/i18n/index.d.ts +31 -10
  51. package/dist/src/lib/i18n/index.d.ts.map +1 -1
  52. package/dist/src/lib/i18n/index.js +31 -10
  53. package/dist/src/lib/i18n/index.mjs +88 -1
  54. package/dist/src/lib/index.cjs +633 -1
  55. package/dist/src/lib/index.d.ts +0 -2
  56. package/dist/src/lib/index.d.ts.map +1 -1
  57. package/dist/src/lib/index.js +5 -11
  58. package/dist/src/lib/index.mjs +721 -1
  59. package/dist/src/lib/isomorphic.cjs +85 -1
  60. package/dist/src/lib/isomorphic.d.ts +41 -8
  61. package/dist/src/lib/isomorphic.d.ts.map +1 -1
  62. package/dist/src/lib/isomorphic.js +38 -5
  63. package/dist/src/lib/isomorphic.mjs +64 -1
  64. package/dist/src/lib/jsx-runtime/index.cjs +21 -1
  65. package/dist/src/lib/jsx-runtime/index.d.ts +1 -1
  66. package/dist/src/lib/jsx-runtime/index.js +1 -11
  67. package/dist/src/lib/jsx-runtime/index.mjs +4 -1
  68. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -1
  69. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -1
  70. package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -8
  71. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +15 -1
  72. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -1
  73. package/dist/src/lib/plugins/fluixi-routes-plugin.js +19 -5
  74. package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -8
  75. package/dist/src/lib/plugins/index.cjs +311 -8
  76. package/dist/src/lib/plugins/index.mjs +279 -8
  77. package/dist/src/lib/plugins/route-codegen.cjs +73 -8
  78. package/dist/src/lib/plugins/route-codegen.d.ts +0 -1
  79. package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -1
  80. package/dist/src/lib/plugins/route-codegen.js +4 -5
  81. package/dist/src/lib/plugins/route-codegen.mjs +52 -8
  82. package/dist/src/lib/plugins/route-scanner.cjs +189 -1
  83. package/dist/src/lib/plugins/route-scanner.d.ts +1 -2
  84. package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -1
  85. package/dist/src/lib/plugins/route-scanner.js +7 -8
  86. package/dist/src/lib/plugins/route-scanner.mjs +158 -1
  87. package/dist/src/lib/plugins/vite.cjs +27 -1
  88. package/dist/src/lib/plugins/vite.mjs +6 -1
  89. package/dist/src/lib/render/await.cjs +38 -1
  90. package/dist/src/lib/render/await.d.ts +18 -0
  91. package/dist/src/lib/render/await.d.ts.map +1 -1
  92. package/dist/src/lib/render/await.js +20 -2
  93. package/dist/src/lib/render/await.mjs +17 -1
  94. package/dist/src/lib/render/component.cjs +221 -1
  95. package/dist/src/lib/render/component.d.ts +3 -44
  96. package/dist/src/lib/render/component.d.ts.map +1 -1
  97. package/dist/src/lib/render/component.js +32 -59
  98. package/dist/src/lib/render/component.mjs +214 -1
  99. package/dist/src/lib/render/deferred.cjs +175 -1
  100. package/dist/src/lib/render/deferred.d.ts.map +1 -1
  101. package/dist/src/lib/render/deferred.js +8 -8
  102. package/dist/src/lib/render/deferred.mjs +158 -1
  103. package/dist/src/lib/render/index.cjs +573 -1
  104. package/dist/src/lib/render/index.d.ts +3 -17
  105. package/dist/src/lib/render/index.d.ts.map +1 -1
  106. package/dist/src/lib/render/index.js +12 -26
  107. package/dist/src/lib/render/index.mjs +590 -1
  108. package/dist/src/lib/render/lazy.cjs +67 -1
  109. package/dist/src/lib/render/lazy.d.ts +22 -1
  110. package/dist/src/lib/render/lazy.d.ts.map +1 -1
  111. package/dist/src/lib/render/lazy.js +47 -8
  112. package/dist/src/lib/render/lazy.mjs +50 -1
  113. package/dist/src/lib/render/suspense.cjs +141 -1
  114. package/dist/src/lib/render/suspense.d.ts +40 -0
  115. package/dist/src/lib/render/suspense.d.ts.map +1 -1
  116. package/dist/src/lib/render/suspense.js +47 -7
  117. package/dist/src/lib/render/suspense.mjs +136 -1
  118. package/dist/src/lib/render/versions.cjs +35 -1
  119. package/dist/src/lib/render/versions.js +6 -6
  120. package/dist/src/lib/render/versions.mjs +14 -1
  121. package/dist/src/lib/router/data.cjs +230 -1
  122. package/dist/src/lib/router/data.d.ts +1 -13
  123. package/dist/src/lib/router/data.d.ts.map +1 -1
  124. package/dist/src/lib/router/data.js +1 -13
  125. package/dist/src/lib/router/data.mjs +214 -1
  126. package/dist/src/lib/router/index.cjs +627 -1
  127. package/dist/src/lib/router/index.d.ts +62 -10
  128. package/dist/src/lib/router/index.d.ts.map +1 -1
  129. package/dist/src/lib/router/index.js +90 -39
  130. package/dist/src/lib/router/index.mjs +639 -1
  131. package/dist/src/lib/server/hydration.cjs +169 -1
  132. package/dist/src/lib/server/hydration.d.ts +15 -55
  133. package/dist/src/lib/server/hydration.d.ts.map +1 -1
  134. package/dist/src/lib/server/hydration.js +23 -62
  135. package/dist/src/lib/server/hydration.mjs +148 -1
  136. package/dist/src/lib/server/index.cjs +401 -11
  137. package/dist/src/lib/server/index.d.ts +30 -6
  138. package/dist/src/lib/server/index.d.ts.map +1 -1
  139. package/dist/src/lib/server/index.js +34 -11
  140. package/dist/src/lib/server/index.mjs +379 -11
  141. package/dist/src/lib/server/reactive.cjs +197 -1
  142. package/dist/src/lib/server/reactive.d.ts +18 -77
  143. package/dist/src/lib/server/reactive.d.ts.map +1 -1
  144. package/dist/src/lib/server/reactive.js +19 -78
  145. package/dist/src/lib/server/reactive.mjs +176 -1
  146. package/dist/src/lib/theme/index.cjs +110 -1
  147. package/dist/src/lib/theme/index.d.ts +19 -4
  148. package/dist/src/lib/theme/index.d.ts.map +1 -1
  149. package/dist/src/lib/theme/index.js +17 -2
  150. package/dist/src/lib/theme/index.mjs +89 -1
  151. package/dist/src/lib/utils/index.cjs +209 -1
  152. package/dist/src/lib/utils/index.d.ts +0 -93
  153. package/dist/src/lib/utils/index.d.ts.map +1 -1
  154. package/dist/src/lib/utils/index.js +0 -93
  155. package/dist/src/lib/utils/index.mjs +188 -1
  156. package/dist/src/routes.cjs +37 -1
  157. package/dist/src/routes.d.ts +1 -1
  158. package/dist/src/routes.js +2 -2
  159. package/dist/src/routes.mjs +17 -1
  160. package/dist/src/server.cjs +400 -11
  161. package/dist/src/server.d.ts +0 -1
  162. package/dist/src/server.d.ts.map +1 -1
  163. package/dist/src/server.js +0 -1
  164. package/dist/src/server.mjs +377 -11
  165. package/dist/src/utils.cjs +21 -1
  166. package/dist/src/utils.d.ts +1 -1
  167. package/dist/src/utils.js +1 -1
  168. package/dist/src/utils.mjs +4 -1
  169. package/dist/src/version.generated.cjs +26 -1
  170. package/dist/src/version.generated.d.ts +1 -1
  171. package/dist/src/version.generated.js +2 -2
  172. package/dist/src/version.generated.mjs +5 -1
  173. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  174. package/package.json +17 -16
  175. package/src/index.ts +2 -14
  176. package/dist/src/cdn/chunk-RN7C7HNS.mjs +0 -1
  177. package/dist/src/cdn/router-QB3W43UQ.mjs +0 -1
  178. package/dist/src/lib/client/chunk-FT22BLCQ.mjs +0 -1
  179. package/dist/src/lib/client/router-IH7JYMRU.mjs +0 -1
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Register this package's version with the DOM runtime, which owns the stamping.
3
3
  *
4
- * It used to be owned here, and stamped only by core's `render` so an app that reached
5
- * the DOM any other way (`startClient` `hydrate` the dom runtime's `render`) got no
4
+ * It used to be owned here, and stamped only by core's `render`, so an app that reached
5
+ * the DOM any other way (`startClient` -> `hydrate` -> the dom runtime's `render`) got no
6
6
  * version attributes at all. Every SSR app is in that position, including the docs site.
7
7
  *
8
8
  * The stamping therefore moved down to `@fluixi/dom`, which both paths pass through. The
9
- * core version cannot be imported from there core depends on dom, and reversing that is
10
- * a cycle so it is pushed down instead, on import.
9
+ * core version cannot be imported from there: core depends on dom, and reversing that is
10
+ * a cycle, so it is pushed down instead, on import.
11
11
  *
12
12
  * Read from a generated constant rather than `package.json`: bundlers and ESM resolvers
13
13
  * treat a manifest import inconsistently, and it would pull the whole file into the bundle
@@ -16,6 +16,6 @@
16
16
  import { registerCoreVersion } from '@fluixi/dom';
17
17
  import { VERSION as CORE } from '../../version.generated.js';
18
18
  registerCoreVersion(CORE);
19
- // Re-exported so existing importers keep working, and so core's own `render` which does
20
- // not delegate to the dom runtime's `render` can still stamp.
19
+ // Re-exported so existing importers keep working, and so core's own `render`, which does
20
+ // not delegate to the dom runtime's `render`: can still stamp.
21
21
  export { stampVersions, warnOnVersionSkew, versions } from '@fluixi/dom';
@@ -1 +1,14 @@
1
- import{registerCoreVersion as o}from"@fluixi/dom";var r="1.0.0-alpha.82";import{stampVersions as p,warnOnVersionSkew as m,versions as V}from"@fluixi/dom";o(r);export{p as stampVersions,V as versions,m as warnOnVersionSkew};
1
+ // src/lib/render/versions.ts
2
+ import { registerCoreVersion } from "@fluixi/dom";
3
+
4
+ // src/version.generated.ts
5
+ var VERSION = "1.0.0-alpha.84";
6
+
7
+ // src/lib/render/versions.ts
8
+ import { stampVersions, warnOnVersionSkew, versions } from "@fluixi/dom";
9
+ registerCoreVersion(VERSION);
10
+ export {
11
+ stampVersions,
12
+ versions,
13
+ warnOnVersionSkew
14
+ };
@@ -1 +1,230 @@
1
- "use strict";var y=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var n in t)y(e,n,{get:t[n],enumerable:!0})},_=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of R(t))!D.call(e,o)&&o!==n&&y(e,o,{get:()=>t[o],enumerable:!(r=w(t,o))||r.enumerable});return e};var E=e=>_(y({},"__esModule",{value:!0}),e);var J={};H(J,{RouteDataContext:()=>T,RouteDataProvider:()=>L,action:()=>b,cache:()=>M,createAsync:()=>$,revalidate:()=>U,useAction:()=>z,useRouteData:()=>W,useSubmission:()=>j});module.exports=E(J);var c=require("@fluixi/reactive/signal");var k=!1,p=new Map;function x(){return k}function m(e,t){p.set(e,t)}function h(e){return p.get(e)}function O(){p.clear()}function I(){if(typeof window>"u")return;let e=document.getElementById("__FLUIXI_HYDRATION__");e&&e.remove();let t=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,null),n=[],r;for(;r=t.nextNode();){let o=r,i=o.nodeValue||"";(i.startsWith("#")||i.startsWith("/"))&&n.push(o)}n.forEach(o=>o.remove()),O()}typeof window<"u"&&window.addEventListener("load",()=>{setTimeout(I,100)});function v(){return typeof window>"u"}var C=require("@fluixi/dom"),u=require("@fluixi/reactive/signal"),N=require("@fluixi/reactive/signal");function A(e){let t=(0,u.createContext)(e),n=r=>(r.debug,t.Provider({value:r.value,get children(){return r.children},debug:r.debug}));return typeof Symbol<"u"&&Symbol.for&&(n.$$typeof=Symbol.for("react.provider")),n.$$typeof=Symbol.for("react.provider"),{id:t.id,Provider:(0,C.asProvider)(n),defaultValue:e}}function P(e){let t=(0,u.useContext)(e);return t!==void 0?t:e.defaultValue}var d=new Map,a=new Map;function M(e,t){return async(...n)=>{let r=t+":"+JSON.stringify(n);if(x()||typeof window<"u"){let i=h(r);if(i!==void 0)return i}if(d.has(r))return d.get(r);if(a.has(r))return a.get(r);let o=Promise.resolve(e(...n)).then(i=>(d.set(r,i),a.delete(r),v()&&m(r,i),i),i=>{throw a.delete(r),i});return a.set(r,o),o}}var[ee,V]=(0,c.createSignal)(0),F=new Set;function U(e){let t=typeof e=="string"?n=>n.startsWith(e):e;for(let n of d.keys())t(n)&&(d.delete(n),F.add(n));V(n=>n+1)}function $(e,t){let[n]=(0,c.createResource)(t||(()=>!0),e);return n}var g=new Map;function S(e){return g.has(e)||g.set(e,(0,c.createSignal)(void 0)),g.get(e)}function b(e,t){let n=t||e.name||"action",r=async o=>{let[,i]=S(n),l=()=>i(void 0),f=()=>r(o);i({input:o,pending:!0,clear:l,retry:f});try{let s=await e(o);return i({input:o,result:s,pending:!1,clear:l,retry:f}),s}catch(s){throw i({input:o,error:s,pending:!1,clear:l,retry:f}),s}};return r.url=n,r.with=o=>b((...i)=>e(o,...i),t),r}function j(e){let[t]=S(e.url);return t}function z(e){return e}var T=A(),L=T.Provider;function W(){let e=P(T);return typeof e=="function"?e:()=>e}
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/router/data.ts
21
+ var data_exports = {};
22
+ __export(data_exports, {
23
+ RouteDataContext: () => RouteDataContext,
24
+ RouteDataProvider: () => RouteDataProvider,
25
+ action: () => action,
26
+ cache: () => cache,
27
+ createAsync: () => createAsync,
28
+ revalidate: () => revalidate,
29
+ useAction: () => useAction,
30
+ useRouteData: () => useRouteData,
31
+ useSubmission: () => useSubmission
32
+ });
33
+ module.exports = __toCommonJS(data_exports);
34
+ var import_signal3 = require("@fluixi/reactive/signal");
35
+
36
+ // src/lib/server/hydration.ts
37
+ var import_dom = require("@fluixi/dom");
38
+ var hydrating = false;
39
+ var hydrationDataMap = /* @__PURE__ */ new Map();
40
+ function isHydrating() {
41
+ return hydrating;
42
+ }
43
+ function setHydrationData(key, data) {
44
+ hydrationDataMap.set(key, data);
45
+ }
46
+ function getHydrationData(key) {
47
+ return hydrationDataMap.get(key);
48
+ }
49
+ function clearHydrationData() {
50
+ hydrationDataMap.clear();
51
+ }
52
+ function cleanupHydration() {
53
+ if (typeof window === "undefined") {
54
+ return;
55
+ }
56
+ const script = document.getElementById("__FLUIXI_HYDRATION__");
57
+ if (script) {
58
+ script.remove();
59
+ }
60
+ const walker = document.createTreeWalker(
61
+ document.body,
62
+ NodeFilter.SHOW_COMMENT,
63
+ null
64
+ );
65
+ const comments = [];
66
+ let node;
67
+ while (node = walker.nextNode()) {
68
+ const comment = node;
69
+ const text = comment.nodeValue || "";
70
+ if (text.startsWith("#") || text.startsWith("/")) {
71
+ comments.push(comment);
72
+ }
73
+ }
74
+ comments.forEach((comment) => comment.remove());
75
+ clearHydrationData();
76
+ }
77
+ if (typeof window !== "undefined") {
78
+ window.addEventListener("load", () => {
79
+ setTimeout(cleanupHydration, 100);
80
+ });
81
+ }
82
+ function isServerEnvironment() {
83
+ return (0, import_dom.isServer)();
84
+ }
85
+
86
+ // src/lib/context/context.ts
87
+ var import_dom2 = require("@fluixi/dom");
88
+ var import_signal = require("@fluixi/reactive/signal");
89
+ var import_signal2 = require("@fluixi/reactive/signal");
90
+ function createContext(defaultValue, name) {
91
+ const context = (0, import_signal.createContext)(defaultValue, name);
92
+ const Provider = (props) => {
93
+ if (props.debug === true) {
94
+ }
95
+ return context.Provider({
96
+ value: props.value,
97
+ get children() {
98
+ return props.children;
99
+ },
100
+ debug: props.debug
101
+ });
102
+ };
103
+ if (typeof Symbol !== "undefined" && Symbol.for) {
104
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
105
+ }
106
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
107
+ return {
108
+ id: context.id,
109
+ Provider: (0, import_dom2.asProvider)(Provider),
110
+ defaultValue
111
+ };
112
+ }
113
+ function useContext(context) {
114
+ const value = (0, import_signal.useContext)(context);
115
+ return value !== void 0 ? value : context.defaultValue;
116
+ }
117
+
118
+ // src/lib/router/data.ts
119
+ var globalCache = /* @__PURE__ */ new Map();
120
+ var inflightRequests = /* @__PURE__ */ new Map();
121
+ function cache(fn, name) {
122
+ return async (...args) => {
123
+ const key = name + ":" + JSON.stringify(args);
124
+ if (isHydrating() || typeof window !== "undefined") {
125
+ const hydrated = getHydrationData(key);
126
+ if (hydrated !== void 0) {
127
+ return hydrated;
128
+ }
129
+ }
130
+ if (globalCache.has(key)) {
131
+ return globalCache.get(key);
132
+ }
133
+ if (inflightRequests.has(key)) {
134
+ return inflightRequests.get(key);
135
+ }
136
+ const promise = Promise.resolve(fn(...args)).then(
137
+ (val) => {
138
+ globalCache.set(key, val);
139
+ inflightRequests.delete(key);
140
+ if (isServerEnvironment()) {
141
+ setHydrationData(key, val);
142
+ }
143
+ return val;
144
+ },
145
+ (err) => {
146
+ inflightRequests.delete(key);
147
+ throw err;
148
+ }
149
+ );
150
+ inflightRequests.set(key, promise);
151
+ return promise;
152
+ };
153
+ }
154
+ var [revalidationVersion, setRevalidationVersion] = (0, import_signal3.createSignal)(0);
155
+ var revalidationKeys = /* @__PURE__ */ new Set();
156
+ function revalidate(key) {
157
+ const predicate = typeof key === "string" ? (k) => k.startsWith(key) : key;
158
+ for (const k of globalCache.keys()) {
159
+ if (predicate(k)) {
160
+ globalCache.delete(k);
161
+ revalidationKeys.add(k);
162
+ }
163
+ }
164
+ setRevalidationVersion((v) => v + 1);
165
+ }
166
+ function createAsync(fetcher, source) {
167
+ const [data] = (0, import_signal3.createResource)(source || (() => true), fetcher);
168
+ return data;
169
+ }
170
+ var submissionState = /* @__PURE__ */ new Map();
171
+ function getSubmissionSignal(url) {
172
+ if (!submissionState.has(url)) {
173
+ submissionState.set(
174
+ url,
175
+ (0, import_signal3.createSignal)(void 0)
176
+ );
177
+ }
178
+ return submissionState.get(url);
179
+ }
180
+ function action(fn, name) {
181
+ const actionUrl = name || fn.name || "action";
182
+ const submit = async (input) => {
183
+ const [, setSubmission] = getSubmissionSignal(actionUrl);
184
+ const clear = () => setSubmission(void 0);
185
+ const retry = () => submit(input);
186
+ setSubmission({
187
+ input,
188
+ // Approximate type for tracking
189
+ pending: true,
190
+ clear,
191
+ retry
192
+ });
193
+ try {
194
+ const result = await fn(input);
195
+ setSubmission({
196
+ input,
197
+ result,
198
+ pending: false,
199
+ clear,
200
+ retry
201
+ });
202
+ return result;
203
+ } catch (error) {
204
+ setSubmission({
205
+ input,
206
+ error,
207
+ pending: false,
208
+ clear,
209
+ retry
210
+ });
211
+ throw error;
212
+ }
213
+ };
214
+ submit.url = actionUrl;
215
+ submit.with = (args) => action((...a) => fn(args, ...a), name);
216
+ return submit;
217
+ }
218
+ function useSubmission(actionFn) {
219
+ const [submission] = getSubmissionSignal(actionFn.url);
220
+ return submission;
221
+ }
222
+ function useAction(actionFn) {
223
+ return actionFn;
224
+ }
225
+ var RouteDataContext = createContext(void 0, "route-data");
226
+ var RouteDataProvider = RouteDataContext.Provider;
227
+ function useRouteData() {
228
+ const ctx = useContext(RouteDataContext);
229
+ return typeof ctx === "function" ? ctx : () => ctx;
230
+ }
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @fileoverview Data fetching and caching primitives for Fluixi Router
3
2
  * @module @fluixi/core/router/data
4
3
  */
5
4
  import { type Accessor, Resource } from '@fluixi/reactive/signal';
@@ -24,30 +23,19 @@ export interface Submission<T, Args extends any[]> {
24
23
  * - Deduplication
25
24
  * - Hydration (Server -> Client)
26
25
  * - Revalidation
27
- *
28
- * @param fn Async function to cache
29
- * @param name Unique name for the cache key
30
26
  */
31
27
  export declare function cache<T, Args extends any[]>(fn: (...args: Args) => Promise<T> | T, name: string): (...args: Args) => Promise<T>;
32
28
  /**
33
29
  * Revalidate a cache key. Clears the memory cache and triggers
34
30
  * reactive invalidation so resources using createAsync re-fetch.
35
- *
36
- * @param key Key prefix string or predicate function to match cache keys
37
31
  */
38
32
  export declare function revalidate(key: string | ((key: string) => boolean)): void;
39
33
  /**
40
34
  * Create an async resource from a promise or cache function
41
- *
42
- * @param fetcher Function that returns a promise
43
- * @param source Dependency signal (optional)
44
35
  */
45
36
  export declare function createAsync<T, S extends any = true>(fetcher: (source: S) => Promise<T> | T, source?: () => S): Resource<S>;
46
37
  /**
47
38
  * Create a server action
48
- *
49
- * @param fn Function to execute (server-side)
50
- * @param name Action name
51
39
  */
52
40
  export declare function action<T, Args extends any[]>(fn: (...args: Args) => Promise<T> | T, name?: string): Action<T, Args>;
53
41
  /**
@@ -60,7 +48,7 @@ export declare function useSubmission<T, Args extends any[]>(actionFn: Action<T,
60
48
  export declare function useAction<T, Args extends any[]>(actionFn: Action<T, Args>): (...args: Args) => Promise<T>;
61
49
  export interface RouteDataArgs {
62
50
  /**
63
- * Route params either a reactive signal accessor (when called from the
51
+ * Route params, either a reactive signal accessor (when called from the
64
52
  * router's createRoot during layout creation) or a plain snapshot object
65
53
  * (legacy / manual usage). Always normalise with:
66
54
  * `const getParams = typeof args.params === 'function' ? args.params : () => args.params;`
@@ -1 +1 @@
1
- {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/lib/router/data.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAGL,KAAK,QAAQ,EAEb,QAAQ,EACT,MAAM,yBAAyB,CAAC;AAejC,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,IAAI,SAAS,GAAG,EAAE,IAAI,CAC3C,GAAG,IAAI,EAAE,IAAI,KACV,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,C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pC,CAAC,MAAM;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClD;AAED,MAAM,MAAM,aAAa,GAAG,CAC1B,IAAI,EAAE,aAAa,EACnB,KAAK,CAAC,EAAE,GAAG,EACX,WAAW,CAAC,EAAE,MAAM,OAAO,KACxB,GAAG,CAAC;AAET,eAAO,MAAM,gBAAgB;;;;;;;;CAA8C,CAAC;AAE5E,eAAO,MAAM,iBAAiB;;;;SAA4B,CAAC;AAE3D;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,KAAK,MAAM,CAAC,GAAG,SAAS,CAGrD"}
@@ -1,5 +1,4 @@
1
1
  /**
2
- * @fileoverview Data fetching and caching primitives for Fluixi Router
3
2
  * @module @fluixi/core/router/data
4
3
  */
5
4
  import { createResource, createSignal } from '@fluixi/reactive/signal';
@@ -17,9 +16,6 @@ const inflightRequests = new Map();
17
16
  * - Deduplication
18
17
  * - Hydration (Server -> Client)
19
18
  * - Revalidation
20
- *
21
- * @param fn Async function to cache
22
- * @param name Unique name for the cache key
23
19
  */
24
20
  export function cache(fn, name) {
25
21
  return async (...args) => {
@@ -65,8 +61,6 @@ const revalidationKeys = new Set();
65
61
  /**
66
62
  * Revalidate a cache key. Clears the memory cache and triggers
67
63
  * reactive invalidation so resources using createAsync re-fetch.
68
- *
69
- * @param key Key prefix string or predicate function to match cache keys
70
64
  */
71
65
  export function revalidate(key) {
72
66
  const predicate = typeof key === 'string' ? (k) => k.startsWith(key) : key;
@@ -84,9 +78,6 @@ export function revalidate(key) {
84
78
  // ============================================================================
85
79
  /**
86
80
  * Create an async resource from a promise or cache function
87
- *
88
- * @param fetcher Function that returns a promise
89
- * @param source Dependency signal (optional)
90
81
  */
91
82
  export function createAsync(fetcher, source) {
92
83
  const [data] = createResource(source || (() => true), fetcher);
@@ -105,9 +96,6 @@ function getSubmissionSignal(url) {
105
96
  }
106
97
  /**
107
98
  * Create a server action
108
- *
109
- * @param fn Function to execute (server-side)
110
- * @param name Action name
111
99
  */
112
100
  export function action(fn, name) {
113
101
  const actionUrl = name || fn.name || 'action';
@@ -163,7 +151,7 @@ export function useSubmission(actionFn) {
163
151
  export function useAction(actionFn) {
164
152
  return actionFn;
165
153
  }
166
- export const RouteDataContext = createContext();
154
+ export const RouteDataContext = createContext(undefined, 'route-data');
167
155
  export const RouteDataProvider = RouteDataContext.Provider;
168
156
  /**
169
157
  * Access the data returned by the nearest ancestor route's `routeData` export.
@@ -1 +1,214 @@
1
- import{createResource as D,createSignal as h}from"@fluixi/reactive/signal";var A=!1,l=new Map;function y(){return A}function p(e,r){l.set(e,r)}function g(e){return l.get(e)}function P(){l.clear()}function S(){if(typeof window>"u")return;let e=document.getElementById("__FLUIXI_HYDRATION__");e&&e.remove();let r=document.createTreeWalker(document.body,NodeFilter.SHOW_COMMENT,null),n=[],t;for(;t=r.nextNode();){let i=t,o=i.nodeValue||"";(o.startsWith("#")||o.startsWith("/"))&&n.push(i)}n.forEach(i=>i.remove()),P()}typeof window<"u"&&window.addEventListener("load",()=>{setTimeout(S,100)});function T(){return typeof window>"u"}import{asProvider as b}from"@fluixi/dom";import{createContext as w,useContext as R}from"@fluixi/reactive/signal";import{readChildren as F}from"@fluixi/reactive/signal";function x(e){let r=w(e),n=t=>(t.debug,r.Provider({value:t.value,get children(){return t.children},debug:t.debug}));return typeof Symbol<"u"&&Symbol.for&&(n.$$typeof=Symbol.for("react.provider")),n.$$typeof=Symbol.for("react.provider"),{id:r.id,Provider:b(n),defaultValue:e}}function m(e){let r=R(e);return r!==void 0?r:e.defaultValue}var d=new Map,a=new Map;function W(e,r){return async(...n)=>{let t=r+":"+JSON.stringify(n);if(y()||typeof window<"u"){let o=g(t);if(o!==void 0)return o}if(d.has(t))return d.get(t);if(a.has(t))return a.get(t);let i=Promise.resolve(e(...n)).then(o=>(d.set(t,o),a.delete(t),T()&&p(t,o),o),o=>{throw a.delete(t),o});return a.set(t,i),i}}var[J,H]=h(0),_=new Set;function X(e){let r=typeof e=="string"?n=>n.startsWith(e):e;for(let n of d.keys())r(n)&&(d.delete(n),_.add(n));H(n=>n+1)}function B(e,r){let[n]=D(r||(()=>!0),e);return n}var f=new Map;function v(e){return f.has(e)||f.set(e,h(void 0)),f.get(e)}function E(e,r){let n=r||e.name||"action",t=async i=>{let[,o]=v(n),c=()=>o(void 0),u=()=>t(i);o({input:i,pending:!0,clear:c,retry:u});try{let s=await e(i);return o({input:i,result:s,pending:!1,clear:c,retry:u}),s}catch(s){throw o({input:i,error:s,pending:!1,clear:c,retry:u}),s}};return t.url=n,t.with=i=>E((...o)=>e(i,...o),r),t}function Y(e){let[r]=v(e.url);return r}function K(e){return e}var C=x(),q=C.Provider;function G(){let e=m(C);return typeof e=="function"?e:()=>e}export{C as RouteDataContext,q as RouteDataProvider,E as action,W as cache,B as createAsync,X as revalidate,K as useAction,G as useRouteData,Y as useSubmission};
1
+ // src/lib/router/data.ts
2
+ import {
3
+ createResource,
4
+ createSignal
5
+ } from "@fluixi/reactive/signal";
6
+
7
+ // src/lib/server/hydration.ts
8
+ import { isServer as domIsServer } from "@fluixi/dom";
9
+ var hydrating = false;
10
+ var hydrationDataMap = /* @__PURE__ */ new Map();
11
+ function isHydrating() {
12
+ return hydrating;
13
+ }
14
+ function setHydrationData(key, data) {
15
+ hydrationDataMap.set(key, data);
16
+ }
17
+ function getHydrationData(key) {
18
+ return hydrationDataMap.get(key);
19
+ }
20
+ function clearHydrationData() {
21
+ hydrationDataMap.clear();
22
+ }
23
+ function cleanupHydration() {
24
+ if (typeof window === "undefined") {
25
+ return;
26
+ }
27
+ const script = document.getElementById("__FLUIXI_HYDRATION__");
28
+ if (script) {
29
+ script.remove();
30
+ }
31
+ const walker = document.createTreeWalker(
32
+ document.body,
33
+ NodeFilter.SHOW_COMMENT,
34
+ null
35
+ );
36
+ const comments = [];
37
+ let node;
38
+ while (node = walker.nextNode()) {
39
+ const comment = node;
40
+ const text = comment.nodeValue || "";
41
+ if (text.startsWith("#") || text.startsWith("/")) {
42
+ comments.push(comment);
43
+ }
44
+ }
45
+ comments.forEach((comment) => comment.remove());
46
+ clearHydrationData();
47
+ }
48
+ if (typeof window !== "undefined") {
49
+ window.addEventListener("load", () => {
50
+ setTimeout(cleanupHydration, 100);
51
+ });
52
+ }
53
+ function isServerEnvironment() {
54
+ return domIsServer();
55
+ }
56
+
57
+ // src/lib/context/context.ts
58
+ import { asProvider } from "@fluixi/dom";
59
+ import { createContext as createReactiveContext, useContext as useReactiveContext } from "@fluixi/reactive/signal";
60
+ import {
61
+ readChildren
62
+ } from "@fluixi/reactive/signal";
63
+ function createContext(defaultValue, name) {
64
+ const context = createReactiveContext(defaultValue, name);
65
+ const Provider = (props) => {
66
+ if (props.debug === true) {
67
+ }
68
+ return context.Provider({
69
+ value: props.value,
70
+ get children() {
71
+ return props.children;
72
+ },
73
+ debug: props.debug
74
+ });
75
+ };
76
+ if (typeof Symbol !== "undefined" && Symbol.for) {
77
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
78
+ }
79
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
80
+ return {
81
+ id: context.id,
82
+ Provider: asProvider(Provider),
83
+ defaultValue
84
+ };
85
+ }
86
+ function useContext(context) {
87
+ const value = useReactiveContext(context);
88
+ return value !== void 0 ? value : context.defaultValue;
89
+ }
90
+
91
+ // src/lib/router/data.ts
92
+ var globalCache = /* @__PURE__ */ new Map();
93
+ var inflightRequests = /* @__PURE__ */ new Map();
94
+ function cache(fn, name) {
95
+ return async (...args) => {
96
+ const key = name + ":" + JSON.stringify(args);
97
+ if (isHydrating() || typeof window !== "undefined") {
98
+ const hydrated = getHydrationData(key);
99
+ if (hydrated !== void 0) {
100
+ return hydrated;
101
+ }
102
+ }
103
+ if (globalCache.has(key)) {
104
+ return globalCache.get(key);
105
+ }
106
+ if (inflightRequests.has(key)) {
107
+ return inflightRequests.get(key);
108
+ }
109
+ const promise = Promise.resolve(fn(...args)).then(
110
+ (val) => {
111
+ globalCache.set(key, val);
112
+ inflightRequests.delete(key);
113
+ if (isServerEnvironment()) {
114
+ setHydrationData(key, val);
115
+ }
116
+ return val;
117
+ },
118
+ (err) => {
119
+ inflightRequests.delete(key);
120
+ throw err;
121
+ }
122
+ );
123
+ inflightRequests.set(key, promise);
124
+ return promise;
125
+ };
126
+ }
127
+ var [revalidationVersion, setRevalidationVersion] = createSignal(0);
128
+ var revalidationKeys = /* @__PURE__ */ new Set();
129
+ function revalidate(key) {
130
+ const predicate = typeof key === "string" ? (k) => k.startsWith(key) : key;
131
+ for (const k of globalCache.keys()) {
132
+ if (predicate(k)) {
133
+ globalCache.delete(k);
134
+ revalidationKeys.add(k);
135
+ }
136
+ }
137
+ setRevalidationVersion((v) => v + 1);
138
+ }
139
+ function createAsync(fetcher, source) {
140
+ const [data] = createResource(source || (() => true), fetcher);
141
+ return data;
142
+ }
143
+ var submissionState = /* @__PURE__ */ new Map();
144
+ function getSubmissionSignal(url) {
145
+ if (!submissionState.has(url)) {
146
+ submissionState.set(
147
+ url,
148
+ createSignal(void 0)
149
+ );
150
+ }
151
+ return submissionState.get(url);
152
+ }
153
+ function action(fn, name) {
154
+ const actionUrl = name || fn.name || "action";
155
+ const submit = async (input) => {
156
+ const [, setSubmission] = getSubmissionSignal(actionUrl);
157
+ const clear = () => setSubmission(void 0);
158
+ const retry = () => submit(input);
159
+ setSubmission({
160
+ input,
161
+ // Approximate type for tracking
162
+ pending: true,
163
+ clear,
164
+ retry
165
+ });
166
+ try {
167
+ const result = await fn(input);
168
+ setSubmission({
169
+ input,
170
+ result,
171
+ pending: false,
172
+ clear,
173
+ retry
174
+ });
175
+ return result;
176
+ } catch (error) {
177
+ setSubmission({
178
+ input,
179
+ error,
180
+ pending: false,
181
+ clear,
182
+ retry
183
+ });
184
+ throw error;
185
+ }
186
+ };
187
+ submit.url = actionUrl;
188
+ submit.with = (args) => action((...a) => fn(args, ...a), name);
189
+ return submit;
190
+ }
191
+ function useSubmission(actionFn) {
192
+ const [submission] = getSubmissionSignal(actionFn.url);
193
+ return submission;
194
+ }
195
+ function useAction(actionFn) {
196
+ return actionFn;
197
+ }
198
+ var RouteDataContext = createContext(void 0, "route-data");
199
+ var RouteDataProvider = RouteDataContext.Provider;
200
+ function useRouteData() {
201
+ const ctx = useContext(RouteDataContext);
202
+ return typeof ctx === "function" ? ctx : () => ctx;
203
+ }
204
+ export {
205
+ RouteDataContext,
206
+ RouteDataProvider,
207
+ action,
208
+ cache,
209
+ createAsync,
210
+ revalidate,
211
+ useAction,
212
+ useRouteData,
213
+ useSubmission
214
+ };