@fluixi/core 1.0.0-alpha.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +334 -0
  3. package/dist/cdn/core.global.js +2 -0
  4. package/dist/cli/generate.cjs +5639 -0
  5. package/dist/cli/generate.d.ts +7 -0
  6. package/dist/cli/generate.d.ts.map +1 -0
  7. package/dist/cli/generate.js +2580 -0
  8. package/dist/cli/generate.mjs +5644 -0
  9. package/dist/cli/index.cjs +5639 -0
  10. package/dist/cli/index.d.ts +7 -0
  11. package/dist/cli/index.d.ts.map +1 -0
  12. package/dist/cli/index.js +2580 -0
  13. package/dist/cli/index.mjs +5644 -0
  14. package/dist/cli/run.cjs +64 -0
  15. package/dist/cli/run.d.ts +3 -0
  16. package/dist/cli/run.d.ts.map +1 -0
  17. package/dist/cli/run.js +62 -0
  18. package/dist/cli/run.mjs +40 -0
  19. package/dist/fluixi.d.ts +5 -0
  20. package/dist/src/cdn/chunk-RKBFEFZP.mjs +987 -0
  21. package/dist/src/cdn/core.cjs +1592 -0
  22. package/dist/src/cdn/core.d.ts +16 -0
  23. package/dist/src/cdn/core.d.ts.map +1 -0
  24. package/dist/src/cdn/core.js +15 -0
  25. package/dist/src/cdn/core.mjs +714 -0
  26. package/dist/src/cdn/router-V2THK27H.mjs +74 -0
  27. package/dist/src/index.cjs +1711 -0
  28. package/dist/src/index.d.ts +4 -0
  29. package/dist/src/index.d.ts.map +1 -0
  30. package/dist/src/index.js +11 -0
  31. package/dist/src/index.mjs +1833 -0
  32. package/dist/src/jsx-dev-runtime.cjs +26 -0
  33. package/dist/src/jsx-dev-runtime.d.ts +2 -0
  34. package/dist/src/jsx-dev-runtime.d.ts.map +1 -0
  35. package/dist/src/jsx-dev-runtime.js +1 -0
  36. package/dist/src/jsx-dev-runtime.mjs +24 -0
  37. package/dist/src/jsx-runtime.cjs +26 -0
  38. package/dist/src/jsx-runtime.d.ts +7 -0
  39. package/dist/src/jsx-runtime.d.ts.map +1 -0
  40. package/dist/src/jsx-runtime.js +8 -0
  41. package/dist/src/jsx-runtime.mjs +24 -0
  42. package/dist/src/lib/client/chunk-FDOPDB6Z.mjs +53 -0
  43. package/dist/src/lib/client/index.cjs +1210 -0
  44. package/dist/src/lib/client/index.d.ts +51 -0
  45. package/dist/src/lib/client/index.d.ts.map +1 -0
  46. package/dist/src/lib/client/index.js +174 -0
  47. package/dist/src/lib/client/index.mjs +293 -0
  48. package/dist/src/lib/client/router-4PTBPZLQ.mjs +891 -0
  49. package/dist/src/lib/context/context.cjs +81 -0
  50. package/dist/src/lib/context/context.d.ts +73 -0
  51. package/dist/src/lib/context/context.d.ts.map +1 -0
  52. package/dist/src/lib/context/context.js +93 -0
  53. package/dist/src/lib/context/context.mjs +64 -0
  54. package/dist/src/lib/context/index.cjs +83 -0
  55. package/dist/src/lib/context/index.d.ts +3 -0
  56. package/dist/src/lib/context/index.d.ts.map +1 -0
  57. package/dist/src/lib/context/index.js +1 -0
  58. package/dist/src/lib/context/index.mjs +64 -0
  59. package/dist/src/lib/control-flow.cjs +35 -0
  60. package/dist/src/lib/control-flow.d.ts +4 -0
  61. package/dist/src/lib/control-flow.d.ts.map +1 -0
  62. package/dist/src/lib/control-flow.js +1 -0
  63. package/dist/src/lib/control-flow.mjs +25 -0
  64. package/dist/src/lib/core.cjs +1710 -0
  65. package/dist/src/lib/core.d.ts +91 -0
  66. package/dist/src/lib/core.d.ts.map +1 -0
  67. package/dist/src/lib/core.js +158 -0
  68. package/dist/src/lib/core.mjs +1833 -0
  69. package/dist/src/lib/env/index.cjs +44 -0
  70. package/dist/src/lib/env/index.d.ts +26 -0
  71. package/dist/src/lib/env/index.d.ts.map +1 -0
  72. package/dist/src/lib/env/index.js +31 -0
  73. package/dist/src/lib/env/index.mjs +23 -0
  74. package/dist/src/lib/i18n/index.cjs +123 -0
  75. package/dist/src/lib/i18n/index.d.ts +110 -0
  76. package/dist/src/lib/i18n/index.d.ts.map +1 -0
  77. package/dist/src/lib/i18n/index.js +164 -0
  78. package/dist/src/lib/i18n/index.mjs +103 -0
  79. package/dist/src/lib/index.cjs +598 -0
  80. package/dist/src/lib/index.d.ts +81 -0
  81. package/dist/src/lib/index.d.ts.map +1 -0
  82. package/dist/src/lib/index.js +130 -0
  83. package/dist/src/lib/index.mjs +688 -0
  84. package/dist/src/lib/isomorphic.cjs +90 -0
  85. package/dist/src/lib/isomorphic.d.ts +114 -0
  86. package/dist/src/lib/isomorphic.d.ts.map +1 -0
  87. package/dist/src/lib/isomorphic.js +132 -0
  88. package/dist/src/lib/isomorphic.mjs +69 -0
  89. package/dist/src/lib/jsx-runtime/index.cjs +21 -0
  90. package/dist/src/lib/jsx-runtime/index.d.ts +13 -0
  91. package/dist/src/lib/jsx-runtime/index.d.ts.map +1 -0
  92. package/dist/src/lib/jsx-runtime/index.js +13 -0
  93. package/dist/src/lib/jsx-runtime/index.mjs +4 -0
  94. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +21 -0
  95. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts +2 -0
  96. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts.map +1 -0
  97. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.js +1 -0
  98. package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +4 -0
  99. package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +302 -0
  100. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +35 -0
  101. package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -0
  102. package/dist/src/lib/plugins/fluixi-routes-plugin.js +118 -0
  103. package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +271 -0
  104. package/dist/src/lib/plugins/index.cjs +311 -0
  105. package/dist/src/lib/plugins/index.d.ts +6 -0
  106. package/dist/src/lib/plugins/index.d.ts.map +1 -0
  107. package/dist/src/lib/plugins/index.js +7 -0
  108. package/dist/src/lib/plugins/index.mjs +279 -0
  109. package/dist/src/lib/plugins/route-codegen.cjs +73 -0
  110. package/dist/src/lib/plugins/route-codegen.d.ts +12 -0
  111. package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -0
  112. package/dist/src/lib/plugins/route-codegen.js +80 -0
  113. package/dist/src/lib/plugins/route-codegen.mjs +52 -0
  114. package/dist/src/lib/plugins/route-scanner.cjs +189 -0
  115. package/dist/src/lib/plugins/route-scanner.d.ts +38 -0
  116. package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -0
  117. package/dist/src/lib/plugins/route-scanner.js +215 -0
  118. package/dist/src/lib/plugins/route-scanner.mjs +158 -0
  119. package/dist/src/lib/plugins/vite.cjs +27 -0
  120. package/dist/src/lib/plugins/vite.d.ts +3 -0
  121. package/dist/src/lib/plugins/vite.d.ts.map +1 -0
  122. package/dist/src/lib/plugins/vite.js +1 -0
  123. package/dist/src/lib/plugins/vite.mjs +6 -0
  124. package/dist/src/lib/render/await.cjs +38 -0
  125. package/dist/src/lib/render/await.d.ts +26 -0
  126. package/dist/src/lib/render/await.d.ts.map +1 -0
  127. package/dist/src/lib/render/await.js +45 -0
  128. package/dist/src/lib/render/await.mjs +17 -0
  129. package/dist/src/lib/render/component.cjs +221 -0
  130. package/dist/src/lib/render/component.d.ts +296 -0
  131. package/dist/src/lib/render/component.d.ts.map +1 -0
  132. package/dist/src/lib/render/component.js +514 -0
  133. package/dist/src/lib/render/component.mjs +214 -0
  134. package/dist/src/lib/render/deferred.cjs +175 -0
  135. package/dist/src/lib/render/deferred.d.ts +36 -0
  136. package/dist/src/lib/render/deferred.d.ts.map +1 -0
  137. package/dist/src/lib/render/deferred.js +141 -0
  138. package/dist/src/lib/render/deferred.mjs +158 -0
  139. package/dist/src/lib/render/index.cjs +573 -0
  140. package/dist/src/lib/render/index.d.ts +98 -0
  141. package/dist/src/lib/render/index.d.ts.map +1 -0
  142. package/dist/src/lib/render/index.js +180 -0
  143. package/dist/src/lib/render/index.mjs +590 -0
  144. package/dist/src/lib/render/lazy.cjs +67 -0
  145. package/dist/src/lib/render/lazy.d.ts +49 -0
  146. package/dist/src/lib/render/lazy.d.ts.map +1 -0
  147. package/dist/src/lib/render/lazy.js +105 -0
  148. package/dist/src/lib/render/lazy.mjs +50 -0
  149. package/dist/src/lib/render/suspense.cjs +141 -0
  150. package/dist/src/lib/render/suspense.d.ts +65 -0
  151. package/dist/src/lib/render/suspense.d.ts.map +1 -0
  152. package/dist/src/lib/render/suspense.js +196 -0
  153. package/dist/src/lib/render/suspense.mjs +136 -0
  154. package/dist/src/lib/render/versions.cjs +35 -0
  155. package/dist/src/lib/render/versions.d.ts +2 -0
  156. package/dist/src/lib/render/versions.d.ts.map +1 -0
  157. package/dist/src/lib/render/versions.js +21 -0
  158. package/dist/src/lib/render/versions.mjs +14 -0
  159. package/dist/src/lib/router/data.cjs +228 -0
  160. package/dist/src/lib/router/data.d.ts +142 -0
  161. package/dist/src/lib/router/data.d.ts.map +1 -0
  162. package/dist/src/lib/router/data.js +258 -0
  163. package/dist/src/lib/router/data.mjs +214 -0
  164. package/dist/src/lib/router/index.cjs +921 -0
  165. package/dist/src/lib/router/index.d.ts +274 -0
  166. package/dist/src/lib/router/index.d.ts.map +1 -0
  167. package/dist/src/lib/router/index.js +904 -0
  168. package/dist/src/lib/router/index.mjs +938 -0
  169. package/dist/src/lib/router/scroll.cjs +79 -0
  170. package/dist/src/lib/router/scroll.d.ts +19 -0
  171. package/dist/src/lib/router/scroll.d.ts.map +1 -0
  172. package/dist/src/lib/router/scroll.js +68 -0
  173. package/dist/src/lib/router/scroll.mjs +58 -0
  174. package/dist/src/lib/router/transition.cjs +75 -0
  175. package/dist/src/lib/router/transition.d.ts +81 -0
  176. package/dist/src/lib/router/transition.d.ts.map +1 -0
  177. package/dist/src/lib/router/transition.js +136 -0
  178. package/dist/src/lib/router/transition.mjs +54 -0
  179. package/dist/src/lib/server/hydration.cjs +169 -0
  180. package/dist/src/lib/server/hydration.d.ts +198 -0
  181. package/dist/src/lib/server/hydration.d.ts.map +1 -0
  182. package/dist/src/lib/server/hydration.js +345 -0
  183. package/dist/src/lib/server/hydration.mjs +148 -0
  184. package/dist/src/lib/server/index.cjs +406 -0
  185. package/dist/src/lib/server/index.d.ts +115 -0
  186. package/dist/src/lib/server/index.d.ts.map +1 -0
  187. package/dist/src/lib/server/index.js +164 -0
  188. package/dist/src/lib/server/index.mjs +384 -0
  189. package/dist/src/lib/server/reactive.cjs +197 -0
  190. package/dist/src/lib/server/reactive.d.ts +239 -0
  191. package/dist/src/lib/server/reactive.d.ts.map +1 -0
  192. package/dist/src/lib/server/reactive.js +413 -0
  193. package/dist/src/lib/server/reactive.mjs +176 -0
  194. package/dist/src/lib/storage/cache.cjs +51 -0
  195. package/dist/src/lib/storage/cache.d.ts +18 -0
  196. package/dist/src/lib/storage/cache.d.ts.map +1 -0
  197. package/dist/src/lib/storage/cache.js +42 -0
  198. package/dist/src/lib/storage/cache.mjs +30 -0
  199. package/dist/src/lib/storage/index.cjs +246 -0
  200. package/dist/src/lib/storage/index.d.ts +83 -0
  201. package/dist/src/lib/storage/index.d.ts.map +1 -0
  202. package/dist/src/lib/storage/index.js +179 -0
  203. package/dist/src/lib/storage/index.mjs +231 -0
  204. package/dist/src/lib/storage/persisted.cjs +91 -0
  205. package/dist/src/lib/storage/persisted.d.ts +53 -0
  206. package/dist/src/lib/storage/persisted.d.ts.map +1 -0
  207. package/dist/src/lib/storage/persisted.js +75 -0
  208. package/dist/src/lib/storage/persisted.mjs +70 -0
  209. package/dist/src/lib/theme/color-scheme.cjs +281 -0
  210. package/dist/src/lib/theme/color-scheme.d.ts +61 -0
  211. package/dist/src/lib/theme/color-scheme.d.ts.map +1 -0
  212. package/dist/src/lib/theme/color-scheme.js +120 -0
  213. package/dist/src/lib/theme/color-scheme.mjs +265 -0
  214. package/dist/src/lib/theme/index.cjs +267 -0
  215. package/dist/src/lib/theme/index.d.ts +78 -0
  216. package/dist/src/lib/theme/index.d.ts.map +1 -0
  217. package/dist/src/lib/theme/index.js +135 -0
  218. package/dist/src/lib/theme/index.mjs +251 -0
  219. package/dist/src/lib/theme/provider.cjs +346 -0
  220. package/dist/src/lib/theme/provider.d.ts +34 -0
  221. package/dist/src/lib/theme/provider.d.ts.map +1 -0
  222. package/dist/src/lib/theme/provider.js +60 -0
  223. package/dist/src/lib/theme/provider.mjs +332 -0
  224. package/dist/src/lib/utils/index.cjs +209 -0
  225. package/dist/src/lib/utils/index.d.ts +286 -0
  226. package/dist/src/lib/utils/index.d.ts.map +1 -0
  227. package/dist/src/lib/utils/index.js +434 -0
  228. package/dist/src/lib/utils/index.mjs +188 -0
  229. package/dist/src/routes.cjs +37 -0
  230. package/dist/src/routes.d.ts +22 -0
  231. package/dist/src/routes.d.ts.map +1 -0
  232. package/dist/src/routes.js +20 -0
  233. package/dist/src/routes.mjs +17 -0
  234. package/dist/src/server.cjs +405 -0
  235. package/dist/src/server.d.ts +63 -0
  236. package/dist/src/server.d.ts.map +1 -0
  237. package/dist/src/server.js +62 -0
  238. package/dist/src/server.mjs +382 -0
  239. package/dist/src/utils.cjs +21 -0
  240. package/dist/src/utils.d.ts +10 -0
  241. package/dist/src/utils.d.ts.map +1 -0
  242. package/dist/src/utils.js +9 -0
  243. package/dist/src/utils.mjs +4 -0
  244. package/dist/src/version.generated.cjs +26 -0
  245. package/dist/src/version.generated.d.ts +3 -0
  246. package/dist/src/version.generated.d.ts.map +1 -0
  247. package/dist/src/version.generated.js +3 -0
  248. package/dist/src/version.generated.mjs +5 -0
  249. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  250. package/package.json +164 -0
  251. package/src/index.ts +19 -0
  252. package/types/fluixi.d.ts +5 -0
  253. package/types/vinxi.d.ts +50 -0
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/render/component.ts
21
+ var component_exports = {};
22
+ __export(component_exports, {
23
+ $component: () => $component,
24
+ DEV: () => DEV,
25
+ batch: () => import_signal.batch,
26
+ createComponent: () => createComponent,
27
+ createEffect: () => import_signal.createEffect,
28
+ createMemo: () => import_signal.createMemo,
29
+ devOnly: () => devOnly,
30
+ ensureIntegration: () => ensureIntegration,
31
+ getContextOwner: () => getContextOwner,
32
+ getOwner: () => import_signal.getOwner,
33
+ getSharedConfig: () => getSharedConfig,
34
+ hasLifecycleContext: () => hasLifecycleContext,
35
+ isDev: () => isDev,
36
+ onCleanup: () => import_signal.onCleanup,
37
+ onMount: () => onMount,
38
+ onUnmount: () => onUnmount,
39
+ runWithOwner: () => import_signal.runWithOwner,
40
+ setOwner: () => setOwner,
41
+ useCallback: () => useCallback,
42
+ useEffect: () => useEffect,
43
+ useEventListener: () => useEventListener,
44
+ useMemo: () => useMemo,
45
+ useReducer: () => useReducer,
46
+ useRef: () => useRef
47
+ });
48
+ module.exports = __toCommonJS(component_exports);
49
+ var import_dom = require("@fluixi/dom");
50
+ var import_dom2 = require("@fluixi/dom");
51
+ var import_signal = require("@fluixi/reactive/signal");
52
+ var sharedConfig = {
53
+ context: null,
54
+ owner: null
55
+ };
56
+ function getSharedConfig() {
57
+ return sharedConfig;
58
+ }
59
+ function setOwner(owner) {
60
+ sharedConfig.owner = owner;
61
+ sharedConfig.context = owner;
62
+ }
63
+ function getContextOwner() {
64
+ return sharedConfig.context || sharedConfig.owner;
65
+ }
66
+ var DEV = typeof process !== "undefined" && false;
67
+ var _LIFECYCLE = /* @__PURE__ */ Symbol.for("fluixi-lifecycle");
68
+ function getOwnerLifecycle() {
69
+ const owner = (0, import_signal.getOwner)();
70
+ if (!owner) return null;
71
+ if (!owner[_LIFECYCLE]) {
72
+ const lc = { mounts: [], effects: [], scheduled: false };
73
+ owner[_LIFECYCLE] = lc;
74
+ }
75
+ return owner[_LIFECYCLE];
76
+ }
77
+ function scheduleLifecycleFlush(lc) {
78
+ if (lc.scheduled) return;
79
+ if ((0, import_dom.isServer)()) {
80
+ lc.mounts = [];
81
+ lc.effects = [];
82
+ return;
83
+ }
84
+ lc.scheduled = true;
85
+ const owner = (0, import_signal.getOwner)();
86
+ queueMicrotask(() => {
87
+ if ((0, import_signal.isOwnerDisposed)(owner)) {
88
+ lc.mounts = [];
89
+ lc.effects = [];
90
+ return;
91
+ }
92
+ (0, import_signal.runWithOwner)(owner, () => {
93
+ for (const cb of lc.mounts) {
94
+ try {
95
+ const cleanup = cb();
96
+ if (typeof cleanup === "function") {
97
+ (0, import_signal.onCleanup)(cleanup);
98
+ }
99
+ } catch (e) {
100
+ console.error("Error in onMount callback:", e);
101
+ }
102
+ }
103
+ for (const cb of lc.effects) {
104
+ let cleanup;
105
+ (0, import_signal.createEffect)(() => {
106
+ if (cleanup) cleanup();
107
+ cleanup = cb();
108
+ });
109
+ (0, import_signal.onCleanup)(() => {
110
+ if (cleanup) cleanup();
111
+ });
112
+ }
113
+ lc.mounts = [];
114
+ lc.effects = [];
115
+ });
116
+ });
117
+ }
118
+ function ensureIntegration(_from) {
119
+ }
120
+ function createComponent(Comp, props) {
121
+ return (0, import_dom2.createComponent)(Comp, props);
122
+ }
123
+ function $component(value, props) {
124
+ const component = typeof value === "function" ? (0, import_signal.untrack)(() => value(props)) : value;
125
+ const nameable = component != null && (typeof component === "function" || typeof component === "object");
126
+ if (nameable) {
127
+ try {
128
+ component["$name"] = value.name;
129
+ } catch {
130
+ }
131
+ }
132
+ if (nameable && !(0, import_signal.isSignal)(component)) {
133
+ return (0, import_dom2.asComponent)(component);
134
+ }
135
+ return component;
136
+ }
137
+ function onMount(fn, reactive = true) {
138
+ if ((0, import_dom.isServer)()) return;
139
+ const lc = getOwnerLifecycle();
140
+ if (lc) {
141
+ if (!reactive) {
142
+ if (!lc.scheduled) {
143
+ fn();
144
+ }
145
+ return;
146
+ }
147
+ lc.mounts.push(fn);
148
+ scheduleLifecycleFlush(lc);
149
+ } else {
150
+ if (!reactive) {
151
+ fn();
152
+ return;
153
+ }
154
+ (0, import_signal.createEffect)(() => {
155
+ const cleanup = (0, import_signal.untrack)(fn);
156
+ if (typeof cleanup === "function") {
157
+ (0, import_signal.onCleanup)(cleanup);
158
+ }
159
+ });
160
+ }
161
+ }
162
+ function onUnmount(fn) {
163
+ (0, import_signal.onCleanup)(fn);
164
+ }
165
+ function useEffect(callback) {
166
+ const lc = getOwnerLifecycle();
167
+ if (lc) {
168
+ lc.effects.push(callback);
169
+ scheduleLifecycleFlush(lc);
170
+ } else {
171
+ let cleanup;
172
+ (0, import_signal.createEffect)(() => {
173
+ if (cleanup) cleanup();
174
+ cleanup = callback();
175
+ });
176
+ (0, import_signal.onCleanup)(() => {
177
+ if (cleanup) cleanup();
178
+ });
179
+ }
180
+ }
181
+ function useMemo(fn) {
182
+ return (0, import_signal.createMemo)(fn);
183
+ }
184
+ function useRef(initialValue) {
185
+ const ref = { current: initialValue };
186
+ (0, import_signal.onCleanup)(() => {
187
+ ref.current = null;
188
+ });
189
+ return ref;
190
+ }
191
+ function useReducer(reducer, initialState) {
192
+ const [state, setState] = (0, import_signal.createSignal)(initialState);
193
+ const dispatch = (action) => {
194
+ setState(reducer(state(), action));
195
+ };
196
+ return [state, dispatch];
197
+ }
198
+ function useEventListener(target, event, handler, options) {
199
+ useEffect(() => {
200
+ const element = target && "current" in target ? target.current : target;
201
+ if (!element) return;
202
+ element.addEventListener(event, handler, options);
203
+ return () => {
204
+ element.removeEventListener(event, handler, options);
205
+ };
206
+ });
207
+ }
208
+ function useCallback(callback) {
209
+ return callback;
210
+ }
211
+ function hasLifecycleContext() {
212
+ return (0, import_signal.getOwner)() !== null;
213
+ }
214
+ function isDev() {
215
+ return DEV;
216
+ }
217
+ function devOnly(fn) {
218
+ if (DEV) {
219
+ fn();
220
+ }
221
+ }
@@ -0,0 +1,296 @@
1
+ /**
2
+ * Component creation for Fluixi. Component-creation logic only: context lives in
3
+ * the reactive system, rendering in render/index.ts, and SSR in server/.
4
+ */
5
+ import { CreateComponentReturnType } from '@fluixi/dom';
6
+ import { onCleanup, getOwner, createEffect, createMemo, batch, runWithOwner } from '@fluixi/reactive/signal';
7
+ type Owner = any;
8
+ interface SharedConfig {
9
+ context: Owner | null;
10
+ owner: Owner | null;
11
+ }
12
+ /**
13
+ * Get shared reactive config
14
+ * Used for maintaining reactive context across components
15
+ * @internal
16
+ */
17
+ export declare function getSharedConfig(): SharedConfig;
18
+ /**
19
+ * Set current owner in shared config
20
+ * @internal
21
+ */
22
+ export declare function setOwner(owner: Owner | null): void;
23
+ /**
24
+ * Get current owner from shared config
25
+ * @internal
26
+ */
27
+ export declare function getContextOwner(): Owner | null;
28
+ /**
29
+ * Development mode flag
30
+ */
31
+ export declare const DEV: boolean;
32
+ export type LifecycleCallback = {
33
+ mounted?: boolean;
34
+ (): void | (() => void);
35
+ };
36
+ /**
37
+ * Ref object type
38
+ */
39
+ export interface RefObject<T> {
40
+ current: T;
41
+ }
42
+ /**
43
+ * The runtime creates components itself now, so nothing has to be registered for
44
+ * it to work and this does nothing. It stays because callers exist, and because
45
+ * `registerCreateComponent` is still the way to install a different component
46
+ * model: pass your own implementation there and the runtime uses it instead.
47
+ *
48
+ * Do not register a function that calls the runtime's own `createComponent`: it
49
+ * consults the slot first, so that recurses.
50
+ */
51
+ export declare function ensureIntegration(_from?: string): void;
52
+ /**
53
+ * Create and execute a component once. Opens an Owner, runs the component untracked,
54
+ * captures its output, keeps children lazy, propagates context (via sharedConfig), and
55
+ * attaches cleanup. Components execute once and never re-execute.
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const MyComponent = (props: { name: string }) => {
60
+ * return html`<div>Hello ${props.name}</div>`;
61
+ * };
62
+ *
63
+ * const result = createComponent(MyComponent, { name: 'World' });
64
+ * ```
65
+ */
66
+ export declare function createComponent<T extends (props?: any) => any, U = any>(Comp: T, props?: U): CreateComponentReturnType<T, U>;
67
+ export declare function $component<T extends (props?: any) => any, U = any>(value: T, props?: U): CreateComponentReturnType<T, U>;
68
+ /**
69
+ * Register a callback to run when component mounts
70
+ *
71
+ * SolidJS-aligned: uses createEffect to schedule the callback.
72
+ * The effect runs once after the reactive graph is established,
73
+ * tied to the current Owner for automatic cleanup.
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const MyComponent = () => {
78
+ * onMount(() => {
79
+ * console.log('Component mounted');
80
+ * return () => console.log('Cleanup');
81
+ * });
82
+ *
83
+ * return html`<div>Content</div>`;
84
+ * };
85
+ * ```
86
+ */
87
+ export declare function onMount(fn: LifecycleCallback, reactive?: boolean): void;
88
+ /**
89
+ * Register a callback to run when component unmounts
90
+ *
91
+ * SolidJS-aligned: directly delegates to onCleanup which registers
92
+ * with the current reactive Owner for automatic disposal.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * const MyComponent = () => {
97
+ * onUnmount(() => {
98
+ * console.log('Component is unmounting');
99
+ * });
100
+ *
101
+ * return html`<div>Content</div>`;
102
+ * };
103
+ * ```
104
+ */
105
+ export declare function onUnmount(fn: () => void): void;
106
+ /**
107
+ * Register a cleanup function
108
+ *
109
+ * Component constructs reactive graph including cleanup
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const MyComponent = () => {
114
+ * const timer = setInterval(() => console.log('tick'), 1000);
115
+ *
116
+ * onCleanup(() => clearInterval(timer));
117
+ *
118
+ * return html`<div>Timer running</div>`;
119
+ * };
120
+ * ```
121
+ */
122
+ export { onCleanup };
123
+ /**
124
+ * Create a reactive effect
125
+ *
126
+ * Effects run when their dependencies change
127
+ * On server, effects run once
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const MyComponent = () => {
132
+ * const [count, setCount] = createSignal(0);
133
+ *
134
+ * useEffect(() => {
135
+ * console.log('Count changed:', count());
136
+ * });
137
+ *
138
+ * return html`<button @click=${() => setCount(count() + 1)}>Click</button>`;
139
+ * };
140
+ * ```
141
+ */
142
+ export declare function useEffect(callback: () => void | (() => void)): void;
143
+ /**
144
+ * Create a memoized computed value
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * const MyComponent = () => {
149
+ * const [count, setCount] = createSignal(0);
150
+ * const doubled = useMemo(() => count() * 2);
151
+ *
152
+ * return html`<div>Doubled: ${doubled()}</div>`;
153
+ * };
154
+ * ```
155
+ */
156
+ export declare function useMemo<T>(fn: () => T): () => T;
157
+ /**
158
+ * Create a ref object
159
+ *
160
+ * Refs persist across component re-renders (though components only run once)
161
+ * Useful for storing DOM references and mutable values
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * const MyComponent = () => {
166
+ * const inputRef = useRef<HTMLInputElement>(null);
167
+ *
168
+ * onMount(() => {
169
+ * inputRef.current?.focus();
170
+ * });
171
+ *
172
+ * return html`<input ref=${inputRef} />`;
173
+ * };
174
+ * ```
175
+ */
176
+ export declare function useRef<T>(initialValue: T): RefObject<T>;
177
+ /**
178
+ * Create a reducer for state management
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * type Action = { type: 'increment' } | { type: 'decrement' };
183
+ *
184
+ * const MyComponent = () => {
185
+ * const [state, dispatch] = useReducer(
186
+ * (state: number, action: Action) => {
187
+ * switch (action.type) {
188
+ * case 'increment': return state + 1;
189
+ * case 'decrement': return state - 1;
190
+ * }
191
+ * },
192
+ * 0
193
+ * );
194
+ *
195
+ * return html`
196
+ * <button @click=${() => dispatch({ type: 'increment' })}>
197
+ * Count: ${state()}
198
+ * </button>
199
+ * `;
200
+ * };
201
+ * ```
202
+ */
203
+ export declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [() => S, (action: A) => void];
204
+ /**
205
+ * Attach an event listener with automatic cleanup
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * const MyComponent = () => {
210
+ * const divRef = useRef<HTMLDivElement>(null);
211
+ *
212
+ * useEventListener(divRef, 'click', (e) => {
213
+ * console.log('Div clicked', e);
214
+ * });
215
+ *
216
+ * useEventListener(window, 'resize', () => {
217
+ * console.log('Window resized');
218
+ * });
219
+ *
220
+ * return html`<div ref=${divRef}>Click me</div>`;
221
+ * };
222
+ * ```
223
+ */
224
+ export declare function useEventListener<K extends keyof WindowEventMap>(target: EventTarget | RefObject<EventTarget | null> | Window | Document, event: K, handler: (event: WindowEventMap[K]) => void, options?: AddEventListenerOptions): void;
225
+ /**
226
+ * Create a callback function (memoization optimization)
227
+ *
228
+ * In Fluixi, components only run once, so this is mostly for
229
+ * API compatibility and explicit intent
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * const MyComponent = () => {
234
+ * const handleClick = useCallback(() => {
235
+ * console.log('Clicked');
236
+ * });
237
+ *
238
+ * return html`<button @click=${handleClick}>Click</button>`;
239
+ * };
240
+ * ```
241
+ */
242
+ export declare function useCallback<T extends (...args: any[]) => any>(callback: T): T;
243
+ /**
244
+ * Batch update helper
245
+ * Re-exported for convenience
246
+ */
247
+ export { batch };
248
+ /**
249
+ * Create a memo
250
+ * Re-exported for convenience
251
+ */
252
+ export { createMemo };
253
+ /**
254
+ * Create an effect
255
+ * Re-exported for convenience
256
+ */
257
+ export { createEffect };
258
+ /**
259
+ * Get current reactive owner
260
+ * Re-exported for convenience
261
+ */
262
+ export { getOwner };
263
+ /**
264
+ * Run with specific owner
265
+ * Re-exported for convenience
266
+ */
267
+ export { runWithOwner };
268
+ /**
269
+ * Helper to check if we're in a component context
270
+ * @internal
271
+ */
272
+ export declare function hasLifecycleContext(): boolean;
273
+ /**
274
+ * Check if in development mode
275
+ *
276
+ * @example
277
+ * ```typescript
278
+ * if (isDev()) {
279
+ * console.log('Running in development mode');
280
+ * }
281
+ * ```
282
+ */
283
+ export declare function isDev(): boolean;
284
+ /**
285
+ * Development-only code execution
286
+ *
287
+ * @example
288
+ * ```typescript
289
+ * devOnly(() => {
290
+ * console.log('This only runs in development');
291
+ * });
292
+ * ```
293
+ */
294
+ export declare function devOnly(fn: () => void): void;
295
+ export type { Component, ComponentProps } from "@fluixi/dom";
296
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/lib/render/component.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAIL,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EAGV,KAAK,EAEL,YAAY,EASb,MAAM,yBAAyB,CAAC;AAKjC,KAAK,KAAK,GAAG,GAAG,CAAC;AAMjB,UAAU,YAAY;IACpB,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAOD;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAE9C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,IAAI,CAGlD;AAED;;;GAGG;AACH,wBAAgB,eAAe,IAAI,KAAK,GAAG,IAAI,CAE9C;AAMD;;GAEG;AACH,eAAO,MAAM,GAAG,SAC2D,CAAC;AAM5E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC;CACZ;AAoGD;;;;;;;;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