@fluixi/core 1.0.0-alpha.83 → 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 (177) 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 +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-X526HSWQ.mjs +548 -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 +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 +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 +627 -1
  125. package/dist/src/lib/router/index.d.ts +62 -10
  126. package/dist/src/lib/router/index.d.ts.map +1 -1
  127. package/dist/src/lib/router/index.js +85 -33
  128. package/dist/src/lib/router/index.mjs +639 -1
  129. package/dist/src/lib/server/hydration.cjs +169 -1
  130. package/dist/src/lib/server/hydration.d.ts +15 -55
  131. package/dist/src/lib/server/hydration.d.ts.map +1 -1
  132. package/dist/src/lib/server/hydration.js +23 -62
  133. package/dist/src/lib/server/hydration.mjs +148 -1
  134. package/dist/src/lib/server/index.cjs +401 -11
  135. package/dist/src/lib/server/index.d.ts +30 -6
  136. package/dist/src/lib/server/index.d.ts.map +1 -1
  137. package/dist/src/lib/server/index.js +34 -11
  138. package/dist/src/lib/server/index.mjs +379 -11
  139. package/dist/src/lib/server/reactive.cjs +197 -1
  140. package/dist/src/lib/server/reactive.d.ts +18 -77
  141. package/dist/src/lib/server/reactive.d.ts.map +1 -1
  142. package/dist/src/lib/server/reactive.js +19 -78
  143. package/dist/src/lib/server/reactive.mjs +176 -1
  144. package/dist/src/lib/theme/index.cjs +110 -1
  145. package/dist/src/lib/theme/index.d.ts +19 -4
  146. package/dist/src/lib/theme/index.d.ts.map +1 -1
  147. package/dist/src/lib/theme/index.js +17 -2
  148. package/dist/src/lib/theme/index.mjs +89 -1
  149. package/dist/src/lib/utils/index.cjs +209 -1
  150. package/dist/src/lib/utils/index.d.ts +0 -93
  151. package/dist/src/lib/utils/index.d.ts.map +1 -1
  152. package/dist/src/lib/utils/index.js +0 -93
  153. package/dist/src/lib/utils/index.mjs +188 -1
  154. package/dist/src/routes.cjs +37 -1
  155. package/dist/src/routes.d.ts +1 -1
  156. package/dist/src/routes.js +2 -2
  157. package/dist/src/routes.mjs +17 -1
  158. package/dist/src/server.cjs +400 -11
  159. package/dist/src/server.d.ts +0 -1
  160. package/dist/src/server.d.ts.map +1 -1
  161. package/dist/src/server.js +0 -1
  162. package/dist/src/server.mjs +377 -11
  163. package/dist/src/utils.cjs +21 -1
  164. package/dist/src/utils.d.ts +1 -1
  165. package/dist/src/utils.js +1 -1
  166. package/dist/src/utils.mjs +4 -1
  167. package/dist/src/version.generated.cjs +26 -1
  168. package/dist/src/version.generated.d.ts +1 -1
  169. package/dist/src/version.generated.js +2 -2
  170. package/dist/src/version.generated.mjs +5 -1
  171. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  172. package/package.json +17 -16
  173. package/src/index.ts +2 -14
  174. package/dist/src/cdn/chunk-55BT3H6E.mjs +0 -1
  175. package/dist/src/cdn/router-5JJZBK4E.mjs +0 -1
  176. package/dist/src/lib/client/chunk-SM4WHBOP.mjs +0 -1
  177. package/dist/src/lib/client/router-IBD4WPQT.mjs +0 -1
@@ -28,7 +28,7 @@ export interface ProviderProps<Child> {
28
28
  children?: Child extends Record<any, any> ? PickChildren<Child> : never;
29
29
  }
30
30
  /**
31
- * Lazy-safe form pass the component's `props` so `children` is read through a
31
+ * Lazy-safe form: pass the component's `props` so `children` is read through a
32
32
  * getter (inside the stamped scope), never materialised early. This is the
33
33
  * recommended way to wrap an <Outlet/>.
34
34
  *
@@ -40,10 +40,25 @@ export declare function createProvider<T>(context: Context<T>, value: T | Access
40
40
  children?: any;
41
41
  }): ComponentChild;
42
42
  /**
43
- * @deprecated Eager form `{ context, value, children }` reads `children` before
43
+ * @deprecated Eager form: `{ context, value, children }` reads `children` before
44
44
  * the context is stamped (see warnEagerProvider). Use `createProvider(context,
45
45
  * value, props)` or `<Context.Provider>` instead.
46
46
  */
47
+ /**
48
+ * Provide a context value to a subtree, without writing the `Provider` tag.
49
+ *
50
+ * Takes either a `Context` from `createContext` or a provider component, so it works for
51
+ * both shapes the context API hands back. `value` may be an accessor, in which case
52
+ * descendants see it change.
53
+ *
54
+ * Reach for the `Provider` tag in markup; this is for providing a value from code, such as
55
+ * a wrapper that supplies context around children it was handed.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * createProvider(ThemeContext, 'dark', { children: () => renderPage() });
60
+ * ```
61
+ */
47
62
  export declare function createProvider<T, S = Children>(props: ContextProvider<T, S>): ComponentChild;
48
63
  /**
49
64
  * Creates a context with a provider component
@@ -51,10 +66,6 @@ export declare function createProvider<T, S = Children>(props: ContextProvider<T
51
66
  * Returns both the context and a convenience component that combines
52
67
  * context creation with the provider.
53
68
  *
54
- * @template T - Type of the context value
55
- * @param {T} defaultValue - Default value for the context
56
- * @returns {[Context<T>, (props: { value: T | Accessor<T>; children: TemplateResult | TemplateResult[] }) => TemplateResult]} Context and provider component
57
- *
58
69
  * @example
59
70
  * ```typescript
60
71
  * import { createContextWithProvider } from '@fluixi/core/context';
@@ -92,10 +103,6 @@ export declare function createContextWithProvider<T, U>(defaultValue: T): [Conte
92
103
  *
93
104
  * Utility function to avoid deeply nested Provider components.
94
105
  *
95
- * @param {Array<[Context<any>, any]>} contexts - Array of [context, value] tuples
96
- * @param {TemplateResult | TemplateResult[]} children - Children to render
97
- * @returns {TemplateResult} Nested providers with children
98
- *
99
106
  * @example
100
107
  * ```typescript
101
108
  * import { composeProviders, createContext } from '@fluixi/core/context';
@@ -130,10 +137,6 @@ export declare function composeProviders(contexts: Array<[Context<any>, any]>, c
130
137
  *
131
138
  * Alternative to useContext hook, useful for rendering props patterns.
132
139
  *
133
- * @template T - Type of the context value
134
- * @param {Context<T>} context - Context to consume
135
- * @returns {(props: { children: (value: T) => TemplateResult }) => TemplateResult} Consumer component
136
- *
137
140
  * @example
138
141
  * ```typescript
139
142
  * import { createContext, createConsumer } from '@fluixi/core/context';
@@ -165,11 +168,6 @@ export declare function createConsumer<T>(context: Context<T>): (props: {
165
168
  *
166
169
  * Useful for creating context-based stores or services.
167
170
  *
168
- * @template T - Type of the context value
169
- * @param {Context<T>} context - Context to use
170
- * @param {() => T} factory - Factory function to create the context value
171
- * @returns {T} Context value
172
- *
173
171
  * @example
174
172
  * ```typescript
175
173
  * import { createContext, useProvide, Provider } from '@fluixi/core/context';
@@ -211,10 +209,6 @@ export declare function useProvide<T>(context: Context<T>, factory: () => T): T;
211
209
  /**
212
210
  * Creates a scoped context that only exists within a specific component tree
213
211
  *
214
- * @template T - Type of the context value
215
- * @param {T} defaultValue - Default value for the context
216
- * @returns {Context<T>} Scoped context object
217
- *
218
212
  * @example
219
213
  * ```typescript
220
214
  * import { createContext } from '@fluixi/core/context';
@@ -226,13 +220,9 @@ export declare function useProvide<T>(context: Context<T>, factory: () => T): T;
226
220
  /**
227
221
  * Create a context for sharing state across component tree
228
222
  *
229
- * Section 9: Context is lookup-based, works on server and client
223
+ * Context is lookup-based, works on server and client
230
224
  * Supports nested contexts and complex values
231
225
  *
232
- * @template T - Context value type
233
- * @param {T} defaultValue - Default value
234
- * @returns {Context<T>} Context object with Provider
235
- *
236
226
  * @example
237
227
  * ```typescript
238
228
  * // Simple context
@@ -260,10 +250,6 @@ export declare function useProvide<T>(context: Context<T>, factory: () => T): T;
260
250
  /**
261
251
  * Creates a scoped context that only exists within a specific component tree
262
252
  *
263
- * @template T - Type of the context value
264
- * @param {T} defaultValue - Default value for the context
265
- * @returns {Context<T>} Scoped context object
266
- *
267
253
  * @example
268
254
  * ```typescript
269
255
  * import { createContext } from '@fluixi/core';
@@ -307,11 +293,7 @@ export declare function createContext<T>(defaultValue?: T, name?: string): {
307
293
  /**
308
294
  * Use context value from nearest Provider
309
295
  *
310
- * Section 9: Lookup-based, no subscriptions on server
311
- *
312
- * @template T - Context value type
313
- * @param {Context} context - Context to use
314
- * @returns {T} Context value
296
+ * Lookup-based, no subscriptions on server
315
297
  *
316
298
  * @example
317
299
  * ```typescript
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/lib/context/context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAc,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9E,OAAO,EACL,QAAQ,EACR,OAAO,EAER,MAAM,yBAAyB,CAAC;AA6GjC,KAAK,CAAC,GAAG,SAAS,GAAG,SAAS,EAAE,CAAC;AAEjC,UAAU,QAAQ;IAChB,IAAI,CAAC,CAAC;IACN,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACrB;AAOD,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,UAAU,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,KAAK,GAAG,KAAK,CAAC;AAC/G,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC;IACnC;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAEpB;;OAEG;IACH,KAAK,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAEvB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,KAAK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,CAAC,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,GAAG,CAAC;IACxE,YAAY,EAAE,CAAC,CAAC;CACjB,CAgCA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,CAAC,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG,CAAC,CAIJ;AAYD,YAAY,EAAE,OAAO,EAAE,CAAC"}
@@ -10,10 +10,6 @@ import { readChildren, } from '@fluixi/reactive/signal';
10
10
  *
11
11
  * This wraps @fluixi/reactive's Provider for use with Lit templates.
12
12
  *
13
- * @template T - Type of the context value
14
- * @param {ContextProvider<T>} props - Component props
15
- * @returns {TemplateResult} Rendered children with context
16
- *
17
13
  * @example
18
14
  * ```typescript
19
15
  * import { createContext, Provider } from '@fluixi/core/context';
@@ -80,9 +76,9 @@ function warnEagerProvider() {
80
76
  'routed <Outlet/> that has siblings inside the provider renders detached and its ' +
81
77
  'descendants see no context under SSR. Use the lazy form instead:\n' +
82
78
  ' createProvider(Context, value, props) // children stays a getter\n' +
83
- ' // or JSX: <Context.Provider value={}>{props.children}</Context.Provider>');
79
+ ' // or JSX: <Context.Provider value={...}>{props.children}</Context.Provider>');
84
80
  }
85
- // Returns the Provider's rendered output, not a component it was annotated
81
+ // Returns the Provider's rendered output, not a component, it was annotated
86
82
  // `Component<T>`, which made `<MyProvider>` fail as a JSX element.
87
83
  export function createProvider(a, value, childProps) {
88
84
  // Distinguish the two overloads: a Context (from createContext) exposes `.Provider`,
@@ -98,7 +94,7 @@ export function createProvider(a, value, childProps) {
98
94
  // Always read children through a getter so they render INSIDE the stamped scope.
99
95
  // For the lazy form `childProps.children` is still a getter here (untouched); for
100
96
  // the eager form the caller already materialised it, so this can only mitigate,
101
- // not fully fix hence the deprecation warning above.
97
+ // not fully fix: hence the deprecation warning above.
102
98
  const sourceProps = isLazyForm ? childProps : a;
103
99
  return context.Provider({
104
100
  value: resolvedValue,
@@ -118,10 +114,6 @@ export function createProvider(a, value, childProps) {
118
114
  * Returns both the context and a convenience component that combines
119
115
  * context creation with the provider.
120
116
  *
121
- * @template T - Type of the context value
122
- * @param {T} defaultValue - Default value for the context
123
- * @returns {[Context<T>, (props: { value: T | Accessor<T>; children: TemplateResult | TemplateResult[] }) => TemplateResult]} Context and provider component
124
- *
125
117
  * @example
126
118
  * ```typescript
127
119
  * import { createContextWithProvider } from '@fluixi/core/context';
@@ -167,10 +159,6 @@ export function createContextWithProvider(defaultValue) {
167
159
  *
168
160
  * Utility function to avoid deeply nested Provider components.
169
161
  *
170
- * @param {Array<[Context<any>, any]>} contexts - Array of [context, value] tuples
171
- * @param {TemplateResult | TemplateResult[]} children - Children to render
172
- * @returns {TemplateResult} Nested providers with children
173
- *
174
162
  * @example
175
163
  * ```typescript
176
164
  * import { composeProviders, createContext } from '@fluixi/core/context';
@@ -216,10 +204,6 @@ export function composeProviders(contexts, children) {
216
204
  *
217
205
  * Alternative to useContext hook, useful for rendering props patterns.
218
206
  *
219
- * @template T - Type of the context value
220
- * @param {Context<T>} context - Context to consume
221
- * @returns {(props: { children: (value: T) => TemplateResult }) => TemplateResult} Consumer component
222
- *
223
207
  * @example
224
208
  * ```typescript
225
209
  * import { createContext, createConsumer } from '@fluixi/core/context';
@@ -254,11 +238,6 @@ export function createConsumer(context) {
254
238
  *
255
239
  * Useful for creating context-based stores or services.
256
240
  *
257
- * @template T - Type of the context value
258
- * @param {Context<T>} context - Context to use
259
- * @param {() => T} factory - Factory function to create the context value
260
- * @returns {T} Context value
261
- *
262
241
  * @example
263
242
  * ```typescript
264
243
  * import { createContext, useProvide, Provider } from '@fluixi/core/context';
@@ -308,10 +287,6 @@ export function useProvide(context, factory) {
308
287
  /**
309
288
  * Creates a scoped context that only exists within a specific component tree
310
289
  *
311
- * @template T - Type of the context value
312
- * @param {T} defaultValue - Default value for the context
313
- * @returns {Context<T>} Scoped context object
314
- *
315
290
  * @example
316
291
  * ```typescript
317
292
  * import { createContext } from '@fluixi/core/context';
@@ -332,13 +307,9 @@ export function useProvide(context, factory) {
332
307
  /**
333
308
  * Create a context for sharing state across component tree
334
309
  *
335
- * Section 9: Context is lookup-based, works on server and client
310
+ * Context is lookup-based, works on server and client
336
311
  * Supports nested contexts and complex values
337
312
  *
338
- * @template T - Context value type
339
- * @param {T} defaultValue - Default value
340
- * @returns {Context<T>} Context object with Provider
341
- *
342
313
  * @example
343
314
  * ```typescript
344
315
  * // Simple context
@@ -366,10 +337,6 @@ export function useProvide(context, factory) {
366
337
  /**
367
338
  * Creates a scoped context that only exists within a specific component tree
368
339
  *
369
- * @template T - Type of the context value
370
- * @param {T} defaultValue - Default value for the context
371
- * @returns {Context<T>} Scoped context object
372
- *
373
340
  * @example
374
341
  * ```typescript
375
342
  * import { createContext } from '@fluixi/core';
@@ -408,9 +375,9 @@ export function createContext(defaultValue, name) {
408
375
  if (props.debug === true) {
409
376
  }
410
377
  // Pass children LAZILY (a getter). The reactive Provider reads children inside
411
- // its render effect, AFTER stamping the context on the owner. Reading
378
+ // its render effect, after stamping the context on the owner. Reading
412
379
  // props.children here (e.g. `children: props.children`) evaluates the imperative
413
- // `get children()` getter eagerly, so the children and any <Outlet/> in them
380
+ // `get children()` getter eagerly, so the children, and any <Outlet/> in them,
414
381
  // render before the context is available.
415
382
  return context.Provider({
416
383
  value: props.value,
@@ -434,11 +401,7 @@ export function createContext(defaultValue, name) {
434
401
  /**
435
402
  * Use context value from nearest Provider
436
403
  *
437
- * Section 9: Lookup-based, no subscriptions on server
438
- *
439
- * @template T - Context value type
440
- * @param {Context} context - Context to use
441
- * @returns {T} Context value
404
+ * Lookup-based, no subscriptions on server
442
405
  *
443
406
  * @example
444
407
  * ```typescript
@@ -456,7 +419,7 @@ export function createContext(defaultValue, name) {
456
419
  * ```
457
420
  */
458
421
  export function useContext(context) {
459
- // Use reactive context lookup walks up Owner chain
422
+ // Use reactive context lookup: walks up Owner chain
460
423
  const value = useReactiveContext(context);
461
424
  return value !== undefined ? value : context.defaultValue;
462
425
  }
@@ -1 +1,99 @@
1
- import{asProvider as C}from"@fluixi/dom";import{createContext as v,useContext as p}from"@fluixi/reactive/signal";import{readChildren as x}from"@fluixi/reactive/signal";var d=!1;function T(){d||(d=!0,!(typeof process<"u")&&console.warn("[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={…}>{props.children}</Context.Provider>"))}function a(e,r,n){let t=!!e?.Provider,o=t?e:e.context,i=t?r:e.value,c=t?!1:e.debug??!1;t||T();let l=typeof i=="function"?i():i,u=t?n:e;return o.Provider({value:l,get children(){return u?.children},debug:c})}function S(e){let r=f(e);return[r,t=>a(r,t.value,t)]}function h(e,r){if(e.length===0)return x(()=>r);let[n,t]=e[0],o=e.slice(1);return a(n,t,{get children(){return h(o,r)}})}function A(e){return r=>{let n=s(e);return r.children(n)}}function R(e,r){let n=s(e);return n===e.defaultValue?r():n}function f(e,r){let n=v(e,r),t=o=>(o.debug,n.Provider({value:o.value,get children(){return o.children},debug:o.debug}));return typeof Symbol<"u"&&Symbol.for&&(t.$$typeof=Symbol.for("react.provider")),t.$$typeof=Symbol.for("react.provider"),{id:n.id,Provider:C(t),defaultValue:e}}function s(e){let r=p(e);return r!==void 0?r:e.defaultValue}export{h as composeProviders,A as createConsumer,f as createContext,S as createContextWithProvider,a as createProvider,s as useContext,R as useProvide};
1
+ // src/lib/context/context.ts
2
+ import { asProvider } from "@fluixi/dom";
3
+ import { createContext as createReactiveContext, useContext as useReactiveContext } from "@fluixi/reactive/signal";
4
+ import {
5
+ readChildren
6
+ } from "@fluixi/reactive/signal";
7
+ var _warnedEagerProvider = false;
8
+ function warnEagerProvider() {
9
+ if (_warnedEagerProvider) return;
10
+ _warnedEagerProvider = true;
11
+ if (typeof process !== "undefined" && true) return;
12
+ console.warn(
13
+ "[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={...}>{props.children}</Context.Provider>"
14
+ );
15
+ }
16
+ function createProvider(a, value, childProps) {
17
+ const isLazyForm = !!a?.Provider;
18
+ const context = isLazyForm ? a : a.context;
19
+ const rawValue = isLazyForm ? value : a.value;
20
+ const debug = isLazyForm ? false : a.debug ?? false;
21
+ if (!isLazyForm) warnEagerProvider();
22
+ const resolvedValue = typeof rawValue === "function" ? rawValue() : rawValue;
23
+ const sourceProps = isLazyForm ? childProps : a;
24
+ return context.Provider({
25
+ value: resolvedValue,
26
+ get children() {
27
+ return sourceProps?.children;
28
+ },
29
+ debug
30
+ });
31
+ }
32
+ function createContextWithProvider(defaultValue) {
33
+ const context = createContext(defaultValue);
34
+ const provider = (props) => {
35
+ return createProvider(context, props.value, props);
36
+ };
37
+ return [context, provider];
38
+ }
39
+ function composeProviders(contexts, children) {
40
+ if (contexts.length === 0) {
41
+ return readChildren(() => children);
42
+ }
43
+ const [context, value] = contexts[0];
44
+ const remaining = contexts.slice(1);
45
+ return createProvider(context, value, {
46
+ get children() {
47
+ return composeProviders(remaining, children);
48
+ }
49
+ });
50
+ }
51
+ function createConsumer(context) {
52
+ return (props) => {
53
+ const value = useContext(context);
54
+ return props.children(value);
55
+ };
56
+ }
57
+ function useProvide(context, factory) {
58
+ const existing = useContext(context);
59
+ if (existing === context.defaultValue) {
60
+ return factory();
61
+ }
62
+ return existing;
63
+ }
64
+ function createContext(defaultValue, name) {
65
+ const context = createReactiveContext(defaultValue, name);
66
+ const Provider = (props) => {
67
+ if (props.debug === true) {
68
+ }
69
+ return context.Provider({
70
+ value: props.value,
71
+ get children() {
72
+ return props.children;
73
+ },
74
+ debug: props.debug
75
+ });
76
+ };
77
+ if (typeof Symbol !== "undefined" && Symbol.for) {
78
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
79
+ }
80
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
81
+ return {
82
+ id: context.id,
83
+ Provider: asProvider(Provider),
84
+ defaultValue
85
+ };
86
+ }
87
+ function useContext(context) {
88
+ const value = useReactiveContext(context);
89
+ return value !== void 0 ? value : context.defaultValue;
90
+ }
91
+ export {
92
+ composeProviders,
93
+ createConsumer,
94
+ createContext,
95
+ createContextWithProvider,
96
+ createProvider,
97
+ useContext,
98
+ useProvide
99
+ };
@@ -1 +1,120 @@
1
- "use strict";var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var S=(e,r)=>{for(var t in r)c(e,t,{get:r[t],enumerable:!0})},A=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of g(r))!b.call(e,o)&&o!==t&&c(e,o,{get:()=>r[o],enumerable:!(n=m(r,o))||n.enumerable});return e};var R=e=>A(c({},"__esModule",{value:!0}),e);var k={};S(k,{composeProviders:()=>l,createConsumer:()=>T,createContext:()=>u,createContextWithProvider:()=>x,createProvider:()=>d,useContext:()=>a,useProvide:()=>f});module.exports=R(k);var v=require("@fluixi/dom"),i=require("@fluixi/reactive/signal"),p=require("@fluixi/reactive/signal"),C=!1;function V(){C||(C=!0,!(typeof process<"u")&&console.warn("[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={…}>{props.children}</Context.Provider>"))}function d(e,r,t){let n=!!e?.Provider,o=n?e:e.context,s=n?r:e.value,h=n?!1:e.debug??!1;n||V();let y=typeof s=="function"?s():s,P=n?t:e;return o.Provider({value:y,get children(){return P?.children},debug:h})}function x(e){let r=u(e);return[r,n=>d(r,n.value,n)]}function l(e,r){if(e.length===0)return(0,p.readChildren)(()=>r);let[t,n]=e[0],o=e.slice(1);return d(t,n,{get children(){return l(o,r)}})}function T(e){return r=>{let t=a(e);return r.children(t)}}function f(e,r){let t=a(e);return t===e.defaultValue?r():t}function u(e,r){let t=(0,i.createContext)(e,r),n=o=>(o.debug,t.Provider({value:o.value,get children(){return o.children},debug:o.debug}));return typeof Symbol<"u"&&Symbol.for&&(n.$$typeof=Symbol.for("react.provider")),n.$$typeof=Symbol.for("react.provider"),{id:t.id,Provider:(0,v.asProvider)(n),defaultValue:e}}function a(e){let r=(0,i.useContext)(e);return r!==void 0?r:e.defaultValue}
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/context/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ composeProviders: () => composeProviders,
24
+ createConsumer: () => createConsumer,
25
+ createContext: () => createContext,
26
+ createContextWithProvider: () => createContextWithProvider,
27
+ createProvider: () => createProvider,
28
+ useContext: () => useContext,
29
+ useProvide: () => useProvide
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+
33
+ // src/lib/context/context.ts
34
+ var import_dom = require("@fluixi/dom");
35
+ var import_signal = require("@fluixi/reactive/signal");
36
+ var import_signal2 = require("@fluixi/reactive/signal");
37
+ var _warnedEagerProvider = false;
38
+ function warnEagerProvider() {
39
+ if (_warnedEagerProvider) return;
40
+ _warnedEagerProvider = true;
41
+ if (typeof process !== "undefined" && true) return;
42
+ console.warn(
43
+ "[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={...}>{props.children}</Context.Provider>"
44
+ );
45
+ }
46
+ function createProvider(a, value, childProps) {
47
+ const isLazyForm = !!a?.Provider;
48
+ const context = isLazyForm ? a : a.context;
49
+ const rawValue = isLazyForm ? value : a.value;
50
+ const debug = isLazyForm ? false : a.debug ?? false;
51
+ if (!isLazyForm) warnEagerProvider();
52
+ const resolvedValue = typeof rawValue === "function" ? rawValue() : rawValue;
53
+ const sourceProps = isLazyForm ? childProps : a;
54
+ return context.Provider({
55
+ value: resolvedValue,
56
+ get children() {
57
+ return sourceProps?.children;
58
+ },
59
+ debug
60
+ });
61
+ }
62
+ function createContextWithProvider(defaultValue) {
63
+ const context = createContext(defaultValue);
64
+ const provider = (props) => {
65
+ return createProvider(context, props.value, props);
66
+ };
67
+ return [context, provider];
68
+ }
69
+ function composeProviders(contexts, children) {
70
+ if (contexts.length === 0) {
71
+ return (0, import_signal2.readChildren)(() => children);
72
+ }
73
+ const [context, value] = contexts[0];
74
+ const remaining = contexts.slice(1);
75
+ return createProvider(context, value, {
76
+ get children() {
77
+ return composeProviders(remaining, children);
78
+ }
79
+ });
80
+ }
81
+ function createConsumer(context) {
82
+ return (props) => {
83
+ const value = useContext(context);
84
+ return props.children(value);
85
+ };
86
+ }
87
+ function useProvide(context, factory) {
88
+ const existing = useContext(context);
89
+ if (existing === context.defaultValue) {
90
+ return factory();
91
+ }
92
+ return existing;
93
+ }
94
+ function createContext(defaultValue, name) {
95
+ const context = (0, import_signal.createContext)(defaultValue, name);
96
+ const Provider = (props) => {
97
+ if (props.debug === true) {
98
+ }
99
+ return context.Provider({
100
+ value: props.value,
101
+ get children() {
102
+ return props.children;
103
+ },
104
+ debug: props.debug
105
+ });
106
+ };
107
+ if (typeof Symbol !== "undefined" && Symbol.for) {
108
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
109
+ }
110
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
111
+ return {
112
+ id: context.id,
113
+ Provider: (0, import_dom.asProvider)(Provider),
114
+ defaultValue
115
+ };
116
+ }
117
+ function useContext(context) {
118
+ const value = (0, import_signal.useContext)(context);
119
+ return value !== void 0 ? value : context.defaultValue;
120
+ }
@@ -1 +1,99 @@
1
- import{asProvider as p}from"@fluixi/dom";import{createContext as x,useContext as T}from"@fluixi/reactive/signal";import{readChildren as f}from"@fluixi/reactive/signal";var s=!1;function h(){s||(s=!0,!(typeof process<"u")&&console.warn("[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={…}>{props.children}</Context.Provider>"))}function d(e,r,n){let t=!!e?.Provider,o=t?e:e.context,i=t?r:e.value,u=t?!1:e.debug??!1;t||h();let C=typeof i=="function"?i():i,v=t?n:e;return o.Provider({value:C,get children(){return v?.children},debug:u})}function y(e){let r=l(e);return[r,t=>d(r,t.value,t)]}function c(e,r){if(e.length===0)return f(()=>r);let[n,t]=e[0],o=e.slice(1);return d(n,t,{get children(){return c(o,r)}})}function P(e){return r=>{let n=a(e);return r.children(n)}}function m(e,r){let n=a(e);return n===e.defaultValue?r():n}function l(e,r){let n=x(e,r),t=o=>(o.debug,n.Provider({value:o.value,get children(){return o.children},debug:o.debug}));return typeof Symbol<"u"&&Symbol.for&&(t.$$typeof=Symbol.for("react.provider")),t.$$typeof=Symbol.for("react.provider"),{id:n.id,Provider:p(t),defaultValue:e}}function a(e){let r=T(e);return r!==void 0?r:e.defaultValue}export{c as composeProviders,P as createConsumer,l as createContext,y as createContextWithProvider,d as createProvider,a as useContext,m as useProvide};
1
+ // src/lib/context/context.ts
2
+ import { asProvider } from "@fluixi/dom";
3
+ import { createContext as createReactiveContext, useContext as useReactiveContext } from "@fluixi/reactive/signal";
4
+ import {
5
+ readChildren
6
+ } from "@fluixi/reactive/signal";
7
+ var _warnedEagerProvider = false;
8
+ function warnEagerProvider() {
9
+ if (_warnedEagerProvider) return;
10
+ _warnedEagerProvider = true;
11
+ if (typeof process !== "undefined" && true) return;
12
+ console.warn(
13
+ "[fluixi] createProvider({ context, value, children }) reads `children` eagerly: the object literal materialises `children` BEFORE the context is stamped, so a routed <Outlet/> that has siblings inside the provider renders detached and its descendants see no context under SSR. Use the lazy form instead:\n createProvider(Context, value, props) // children stays a getter\n // or JSX: <Context.Provider value={...}>{props.children}</Context.Provider>"
14
+ );
15
+ }
16
+ function createProvider(a, value, childProps) {
17
+ const isLazyForm = !!a?.Provider;
18
+ const context = isLazyForm ? a : a.context;
19
+ const rawValue = isLazyForm ? value : a.value;
20
+ const debug = isLazyForm ? false : a.debug ?? false;
21
+ if (!isLazyForm) warnEagerProvider();
22
+ const resolvedValue = typeof rawValue === "function" ? rawValue() : rawValue;
23
+ const sourceProps = isLazyForm ? childProps : a;
24
+ return context.Provider({
25
+ value: resolvedValue,
26
+ get children() {
27
+ return sourceProps?.children;
28
+ },
29
+ debug
30
+ });
31
+ }
32
+ function createContextWithProvider(defaultValue) {
33
+ const context = createContext(defaultValue);
34
+ const provider = (props) => {
35
+ return createProvider(context, props.value, props);
36
+ };
37
+ return [context, provider];
38
+ }
39
+ function composeProviders(contexts, children) {
40
+ if (contexts.length === 0) {
41
+ return readChildren(() => children);
42
+ }
43
+ const [context, value] = contexts[0];
44
+ const remaining = contexts.slice(1);
45
+ return createProvider(context, value, {
46
+ get children() {
47
+ return composeProviders(remaining, children);
48
+ }
49
+ });
50
+ }
51
+ function createConsumer(context) {
52
+ return (props) => {
53
+ const value = useContext(context);
54
+ return props.children(value);
55
+ };
56
+ }
57
+ function useProvide(context, factory) {
58
+ const existing = useContext(context);
59
+ if (existing === context.defaultValue) {
60
+ return factory();
61
+ }
62
+ return existing;
63
+ }
64
+ function createContext(defaultValue, name) {
65
+ const context = createReactiveContext(defaultValue, name);
66
+ const Provider = (props) => {
67
+ if (props.debug === true) {
68
+ }
69
+ return context.Provider({
70
+ value: props.value,
71
+ get children() {
72
+ return props.children;
73
+ },
74
+ debug: props.debug
75
+ });
76
+ };
77
+ if (typeof Symbol !== "undefined" && Symbol.for) {
78
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
79
+ }
80
+ Provider.$$typeof = /* @__PURE__ */ Symbol.for("react.provider");
81
+ return {
82
+ id: context.id,
83
+ Provider: asProvider(Provider),
84
+ defaultValue
85
+ };
86
+ }
87
+ function useContext(context) {
88
+ const value = useReactiveContext(context);
89
+ return value !== void 0 ? value : context.defaultValue;
90
+ }
91
+ export {
92
+ composeProviders,
93
+ createConsumer,
94
+ createContext,
95
+ createContextWithProvider,
96
+ createProvider,
97
+ useContext,
98
+ useProvide
99
+ };
@@ -1 +1,35 @@
1
- "use strict";var y=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var n=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var h=(p,r)=>{for(var t in r)y(p,t,{get:r[t],enumerable:!0})},S=(p,r,t,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of n(r))!a.call(p,e)&&e!==t&&y(p,e,{get:()=>r[e],enumerable:!(s=P(r,e))||s.enumerable});return p};var c=p=>S(y({},"__esModule",{value:!0}),p);var d={};h(d,{ClientOnly:()=>o.ClientOnly,Dynamic:()=>o.Dynamic,ErrorBoundary:()=>o.ErrorBoundary,For:()=>o.For,Index:()=>o.Index,Match:()=>o.Match,NoSsr:()=>o.NoSsr,Portal:()=>o.Portal,Show:()=>o.Show,Switch:()=>o.Switch});module.exports=c(d);var o=require("@fluixi/dom");
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/control-flow.ts
21
+ var control_flow_exports = {};
22
+ __export(control_flow_exports, {
23
+ ClientOnly: () => import_dom.ClientOnly,
24
+ Dynamic: () => import_dom.Dynamic,
25
+ ErrorBoundary: () => import_dom.ErrorBoundary,
26
+ For: () => import_dom.For,
27
+ Index: () => import_dom.Index,
28
+ Match: () => import_dom.Match,
29
+ NoSsr: () => import_dom.NoSsr,
30
+ Portal: () => import_dom.Portal,
31
+ Show: () => import_dom.Show,
32
+ Switch: () => import_dom.Switch
33
+ });
34
+ module.exports = __toCommonJS(control_flow_exports);
35
+ var import_dom = require("@fluixi/dom");