@fluixi/core 1.0.0-alpha.53
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.
- package/LICENSE +21 -0
- package/README.md +611 -0
- package/dist/cdn/core.global.js +3 -0
- package/dist/cli/generate.cjs +1814 -0
- package/dist/cli/generate.d.ts +7 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/cli/generate.js +2580 -0
- package/dist/cli/generate.mjs +1814 -0
- package/dist/cli/index.cjs +1814 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +2580 -0
- package/dist/cli/index.mjs +1814 -0
- package/dist/cli/run.cjs +2 -0
- package/dist/cli/run.d.ts +3 -0
- package/dist/cli/run.d.ts.map +1 -0
- package/dist/cli/run.js +62 -0
- package/dist/cli/run.mjs +2 -0
- package/dist/fluixi.d.ts +5 -0
- package/dist/src/cdn/chunk-PFM5O5UE.mjs +1 -0
- package/dist/src/cdn/core.cjs +1 -0
- package/dist/src/cdn/core.d.ts +16 -0
- package/dist/src/cdn/core.d.ts.map +1 -0
- package/dist/src/cdn/core.js +15 -0
- package/dist/src/cdn/core.mjs +1 -0
- package/dist/src/cdn/router-next-WNWCFVC2.mjs +1 -0
- package/dist/src/index.cjs +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +26 -0
- package/dist/src/index.mjs +1 -0
- package/dist/src/jsx-dev-runtime.cjs +1 -0
- package/dist/src/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/jsx-dev-runtime.js +1 -0
- package/dist/src/jsx-dev-runtime.mjs +1 -0
- package/dist/src/jsx-runtime.cjs +1 -0
- package/dist/src/jsx-runtime.d.ts +7 -0
- package/dist/src/jsx-runtime.d.ts.map +1 -0
- package/dist/src/jsx-runtime.js +17 -0
- package/dist/src/jsx-runtime.mjs +1 -0
- package/dist/src/lib/client/chunk-D3VTWVNJ.mjs +1 -0
- package/dist/src/lib/client/index.cjs +1 -0
- package/dist/src/lib/client/index.d.ts +54 -0
- package/dist/src/lib/client/index.d.ts.map +1 -0
- package/dist/src/lib/client/index.js +142 -0
- package/dist/src/lib/client/index.mjs +1 -0
- package/dist/src/lib/client/router-next-UYIYMRJL.mjs +1 -0
- package/dist/src/lib/context/context.cjs +1 -0
- package/dist/src/lib/context/context.d.ts +337 -0
- package/dist/src/lib/context/context.d.ts.map +1 -0
- package/dist/src/lib/context/context.js +462 -0
- package/dist/src/lib/context/context.mjs +1 -0
- package/dist/src/lib/context/index.cjs +1 -0
- package/dist/src/lib/context/index.d.ts +3 -0
- package/dist/src/lib/context/index.d.ts.map +1 -0
- package/dist/src/lib/context/index.js +5 -0
- package/dist/src/lib/context/index.mjs +1 -0
- package/dist/src/lib/control-flow.cjs +1 -0
- package/dist/src/lib/control-flow.d.ts +4 -0
- package/dist/src/lib/control-flow.d.ts.map +1 -0
- package/dist/src/lib/control-flow.js +1 -0
- package/dist/src/lib/control-flow.mjs +1 -0
- package/dist/src/lib/core.cjs +1 -0
- package/dist/src/lib/core.d.ts +90 -0
- package/dist/src/lib/core.d.ts.map +1 -0
- package/dist/src/lib/core.js +181 -0
- package/dist/src/lib/core.mjs +1 -0
- package/dist/src/lib/directives/lit.cjs +1 -0
- package/dist/src/lib/directives/lit.d.ts +2 -0
- package/dist/src/lib/directives/lit.d.ts.map +1 -0
- package/dist/src/lib/directives/lit.js +31 -0
- package/dist/src/lib/directives/lit.mjs +0 -0
- package/dist/src/lib/env/index.cjs +1 -0
- package/dist/src/lib/env/index.d.ts +39 -0
- package/dist/src/lib/env/index.d.ts.map +1 -0
- package/dist/src/lib/env/index.js +50 -0
- package/dist/src/lib/env/index.mjs +1 -0
- package/dist/src/lib/i18n/index.cjs +1 -0
- package/dist/src/lib/i18n/index.d.ts +79 -0
- package/dist/src/lib/i18n/index.d.ts.map +1 -0
- package/dist/src/lib/i18n/index.js +127 -0
- package/dist/src/lib/i18n/index.mjs +1 -0
- package/dist/src/lib/index.cjs +1 -0
- package/dist/src/lib/index.d.ts +83 -0
- package/dist/src/lib/index.d.ts.map +1 -0
- package/dist/src/lib/index.js +147 -0
- package/dist/src/lib/index.mjs +1 -0
- package/dist/src/lib/isomorphic.cjs +1 -0
- package/dist/src/lib/isomorphic.d.ts +69 -0
- package/dist/src/lib/isomorphic.d.ts.map +1 -0
- package/dist/src/lib/isomorphic.js +92 -0
- package/dist/src/lib/isomorphic.mjs +1 -0
- package/dist/src/lib/jsx-runtime/index.cjs +1 -0
- package/dist/src/lib/jsx-runtime/index.d.ts +13 -0
- package/dist/src/lib/jsx-runtime/index.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/index.js +23 -0
- package/dist/src/lib/jsx-runtime/index.mjs +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.cjs +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts +2 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.js +1 -0
- package/dist/src/lib/jsx-runtime/jsx-dev-runtime.mjs +1 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.cjs +13 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts +21 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.d.ts.map +1 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.js +102 -0
- package/dist/src/lib/plugins/fluixi-routes-plugin.mjs +13 -0
- package/dist/src/lib/plugins/index.cjs +13 -0
- package/dist/src/lib/plugins/index.d.ts +4 -0
- package/dist/src/lib/plugins/index.d.ts.map +1 -0
- package/dist/src/lib/plugins/index.js +3 -0
- package/dist/src/lib/plugins/index.mjs +13 -0
- package/dist/src/lib/plugins/route-codegen.cjs +8 -0
- package/dist/src/lib/plugins/route-codegen.d.ts +13 -0
- package/dist/src/lib/plugins/route-codegen.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-codegen.js +81 -0
- package/dist/src/lib/plugins/route-codegen.mjs +8 -0
- package/dist/src/lib/plugins/route-scanner.cjs +1 -0
- package/dist/src/lib/plugins/route-scanner.d.ts +39 -0
- package/dist/src/lib/plugins/route-scanner.d.ts.map +1 -0
- package/dist/src/lib/plugins/route-scanner.js +216 -0
- package/dist/src/lib/plugins/route-scanner.mjs +1 -0
- package/dist/src/lib/plugins/vite.cjs +1 -0
- package/dist/src/lib/plugins/vite.d.ts +3 -0
- package/dist/src/lib/plugins/vite.d.ts.map +1 -0
- package/dist/src/lib/plugins/vite.js +1 -0
- package/dist/src/lib/plugins/vite.mjs +1 -0
- package/dist/src/lib/render/component.cjs +1 -0
- package/dist/src/lib/render/component.d.ts +328 -0
- package/dist/src/lib/render/component.d.ts.map +1 -0
- package/dist/src/lib/render/component.js +520 -0
- package/dist/src/lib/render/component.mjs +1 -0
- package/dist/src/lib/render/index.cjs +1 -0
- package/dist/src/lib/render/index.d.ts +113 -0
- package/dist/src/lib/render/index.d.ts.map +1 -0
- package/dist/src/lib/render/index.js +201 -0
- package/dist/src/lib/render/index.mjs +1 -0
- package/dist/src/lib/render/lazy.cjs +1 -0
- package/dist/src/lib/render/lazy.d.ts +28 -0
- package/dist/src/lib/render/lazy.d.ts.map +1 -0
- package/dist/src/lib/render/lazy.js +62 -0
- package/dist/src/lib/render/lazy.mjs +1 -0
- package/dist/src/lib/render/suspense.cjs +1 -0
- package/dist/src/lib/render/suspense.d.ts +25 -0
- package/dist/src/lib/render/suspense.d.ts.map +1 -0
- package/dist/src/lib/render/suspense.js +139 -0
- package/dist/src/lib/render/suspense.mjs +1 -0
- package/dist/src/lib/router-next/data.cjs +1 -0
- package/dist/src/lib/router-next/data.d.ts +101 -0
- package/dist/src/lib/router-next/data.d.ts.map +1 -0
- package/dist/src/lib/router-next/data.js +179 -0
- package/dist/src/lib/router-next/data.mjs +1 -0
- package/dist/src/lib/router-next/index.cjs +1 -0
- package/dist/src/lib/router-next/index.d.ts +156 -0
- package/dist/src/lib/router-next/index.d.ts.map +1 -0
- package/dist/src/lib/router-next/index.js +464 -0
- package/dist/src/lib/router-next/index.mjs +1 -0
- package/dist/src/lib/server/hydration.cjs +1 -0
- package/dist/src/lib/server/hydration.d.ts +238 -0
- package/dist/src/lib/server/hydration.d.ts.map +1 -0
- package/dist/src/lib/server/hydration.js +384 -0
- package/dist/src/lib/server/hydration.mjs +1 -0
- package/dist/src/lib/server/index.cjs +16 -0
- package/dist/src/lib/server/index.d.ts +91 -0
- package/dist/src/lib/server/index.d.ts.map +1 -0
- package/dist/src/lib/server/index.js +141 -0
- package/dist/src/lib/server/index.mjs +16 -0
- package/dist/src/lib/server/reactive.cjs +1 -0
- package/dist/src/lib/server/reactive.d.ts +298 -0
- package/dist/src/lib/server/reactive.d.ts.map +1 -0
- package/dist/src/lib/server/reactive.js +472 -0
- package/dist/src/lib/server/reactive.mjs +1 -0
- package/dist/src/lib/theme/index.cjs +1 -0
- package/dist/src/lib/theme/index.d.ts +51 -0
- package/dist/src/lib/theme/index.d.ts.map +1 -0
- package/dist/src/lib/theme/index.js +79 -0
- package/dist/src/lib/theme/index.mjs +1 -0
- package/dist/src/lib/utils/index.cjs +1 -0
- package/dist/src/lib/utils/index.d.ts +379 -0
- package/dist/src/lib/utils/index.d.ts.map +1 -0
- package/dist/src/lib/utils/index.js +527 -0
- package/dist/src/lib/utils/index.mjs +1 -0
- package/dist/src/rx.cjs +1 -0
- package/dist/src/rx.d.ts +2 -0
- package/dist/src/rx.d.ts.map +1 -0
- package/dist/src/rx.js +101 -0
- package/dist/src/rx.mjs +0 -0
- package/dist/src/server.cjs +16 -0
- package/dist/src/server.d.ts +64 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +63 -0
- package/dist/src/server.mjs +16 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +128 -0
- package/src/index.ts +31 -0
- package/types/fluixi.d.ts +5 -0
- package/types/vinxi.d.ts +50 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
// /**
|
|
2
|
+
// * @fileoverview Context API for Fluixi that wraps @fluixi/reactive context for Lit templates
|
|
3
|
+
// * @module @fluixi/core/context/context
|
|
4
|
+
// */
|
|
5
|
+
import { asProvider } from '@fluixi/dom';
|
|
6
|
+
import { createContext as createReactiveContext, useContext as useReactiveContext } from '@fluixi/reactive/signal';
|
|
7
|
+
import { readChildren, } from '@fluixi/reactive/signal';
|
|
8
|
+
import { ensureIntegration } from '../render/component.js';
|
|
9
|
+
ensureIntegration('index');
|
|
10
|
+
/**
|
|
11
|
+
* Provider component that supplies a context value to its descendants
|
|
12
|
+
*
|
|
13
|
+
* This wraps @fluixi/reactive's Provider for use with Lit templates.
|
|
14
|
+
*
|
|
15
|
+
* @template T - Type of the context value
|
|
16
|
+
* @param {ContextProvider<T>} props - Component props
|
|
17
|
+
* @returns {TemplateResult} Rendered children with context
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { createContext, Provider } from '@fluixi/core/context';
|
|
22
|
+
* import { createSignal } from '@fluixi/reactive';
|
|
23
|
+
* import { html } from 'lit';
|
|
24
|
+
*
|
|
25
|
+
* const ThemeContext = createContext({ primaryColor: '#007bff' });
|
|
26
|
+
*
|
|
27
|
+
* class App extends FluixiElement {
|
|
28
|
+
* private [theme, setTheme] = createSignal({ primaryColor: '#28a745' });
|
|
29
|
+
*
|
|
30
|
+
* view() {
|
|
31
|
+
* return html`
|
|
32
|
+
* ${Provider({
|
|
33
|
+
* context: ThemeContext,
|
|
34
|
+
* value: this.theme(),
|
|
35
|
+
* children: html`
|
|
36
|
+
* <div>
|
|
37
|
+
* <themed-button></themed-button>
|
|
38
|
+
* <themed-text></themed-text>
|
|
39
|
+
* </div>
|
|
40
|
+
* `
|
|
41
|
+
* })}
|
|
42
|
+
* `;
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Nested providers
|
|
50
|
+
* const UserContext = createContext<User | null>(null);
|
|
51
|
+
* const PermissionsContext = createContext<string[]>([]);
|
|
52
|
+
*
|
|
53
|
+
* class App extends FluixiElement {
|
|
54
|
+
* private [user, setUser] = createSignal<User | null>(null);
|
|
55
|
+
* private [permissions, setPermissions] = createSignal<string[]>(['read']);
|
|
56
|
+
*
|
|
57
|
+
* view() {
|
|
58
|
+
* return html`
|
|
59
|
+
* ${Provider({
|
|
60
|
+
* context: UserContext,
|
|
61
|
+
* value: this.user(),
|
|
62
|
+
* children: Provider({
|
|
63
|
+
* context: PermissionsContext,
|
|
64
|
+
* value: this.permissions(),
|
|
65
|
+
* children: html`<app-dashboard></app-dashboard>`
|
|
66
|
+
* })
|
|
67
|
+
* })}
|
|
68
|
+
* `;
|
|
69
|
+
* }
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
let _warnedEagerProvider = false;
|
|
74
|
+
function warnEagerProvider() {
|
|
75
|
+
if (_warnedEagerProvider)
|
|
76
|
+
return;
|
|
77
|
+
_warnedEagerProvider = true;
|
|
78
|
+
if (typeof process !== 'undefined' && process.env?.NODE_ENV === 'production')
|
|
79
|
+
return;
|
|
80
|
+
console.warn('[fluixi] createProvider({ context, value, children }) reads `children` eagerly: ' +
|
|
81
|
+
'the object literal materialises `children` BEFORE the context is stamped, so a ' +
|
|
82
|
+
'routed <Outlet/> that has siblings inside the provider renders detached and its ' +
|
|
83
|
+
'descendants see no context under SSR. Use the lazy form instead:\n' +
|
|
84
|
+
' createProvider(Context, value, props) // children stays a getter\n' +
|
|
85
|
+
' // or JSX: <Context.Provider value={…}>{props.children}</Context.Provider>');
|
|
86
|
+
}
|
|
87
|
+
export function createProvider(a, value, childProps) {
|
|
88
|
+
// Distinguish the two overloads: a Context (from createContext) exposes `.Provider`,
|
|
89
|
+
// whereas the deprecated form's first arg is the props object (which has `.context`).
|
|
90
|
+
const isLazyForm = !!a?.Provider;
|
|
91
|
+
const context = (isLazyForm ? a : a.context);
|
|
92
|
+
const rawValue = isLazyForm ? value : a.value;
|
|
93
|
+
const debug = isLazyForm ? false : (a.debug ?? false);
|
|
94
|
+
if (!isLazyForm)
|
|
95
|
+
warnEagerProvider();
|
|
96
|
+
// Resolve value if it's an accessor
|
|
97
|
+
const resolvedValue = typeof rawValue === 'function' ? rawValue() : rawValue;
|
|
98
|
+
// Always read children through a getter so they render INSIDE the stamped scope.
|
|
99
|
+
// For the lazy form `childProps.children` is still a getter here (untouched); for
|
|
100
|
+
// the eager form the caller already materialised it, so this can only mitigate,
|
|
101
|
+
// not fully fix — hence the deprecation warning above.
|
|
102
|
+
const sourceProps = isLazyForm ? childProps : a;
|
|
103
|
+
return context.Provider({
|
|
104
|
+
value: resolvedValue,
|
|
105
|
+
get children() { return sourceProps?.children; },
|
|
106
|
+
debug,
|
|
107
|
+
});
|
|
108
|
+
// // Wrap children in the reactive provider
|
|
109
|
+
// return html`${ReactiveProvider({
|
|
110
|
+
// value: resolvedValue,
|
|
111
|
+
// children: resolveChildren(children),
|
|
112
|
+
// //<!--Array.isArray(children) ? html`${children}` : children,-->
|
|
113
|
+
// } as any)}`;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Creates a context with a provider component
|
|
117
|
+
*
|
|
118
|
+
* Returns both the context and a convenience component that combines
|
|
119
|
+
* context creation with the provider.
|
|
120
|
+
*
|
|
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
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* import { createContextWithProvider } from '@fluixi/core/context';
|
|
128
|
+
* import { createSignal } from '@fluixi/reactive';
|
|
129
|
+
* import { html } from 'lit';
|
|
130
|
+
*
|
|
131
|
+
* const [ThemeContext, ThemeProvider] = createContextWithProvider({
|
|
132
|
+
* primaryColor: '#007bff'
|
|
133
|
+
* });
|
|
134
|
+
*
|
|
135
|
+
* class App extends FluixiElement {
|
|
136
|
+
* private [theme] = createSignal({ primaryColor: '#28a745' });
|
|
137
|
+
*
|
|
138
|
+
* view() {
|
|
139
|
+
* return html`
|
|
140
|
+
* ${ThemeProvider({
|
|
141
|
+
* value: this.theme(),
|
|
142
|
+
* children: html`<div><themed-button></themed-button></div>`
|
|
143
|
+
* })}
|
|
144
|
+
* `;
|
|
145
|
+
* }
|
|
146
|
+
* }
|
|
147
|
+
*
|
|
148
|
+
* class ThemedButton extends FluixiElement {
|
|
149
|
+
* view() {
|
|
150
|
+
* const theme = useContext(ThemeContext);
|
|
151
|
+
* return html`<button style="color: ${theme.primaryColor}">Click</button>`;
|
|
152
|
+
* }
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export function createContextWithProvider(defaultValue) {
|
|
157
|
+
const context = createContext(defaultValue);
|
|
158
|
+
const provider = (props) => {
|
|
159
|
+
// Lazy-safe form so children (which may contain an <Outlet/>) render inside
|
|
160
|
+
// the stamped scope.
|
|
161
|
+
return createProvider(context, props.value, props);
|
|
162
|
+
};
|
|
163
|
+
return [context, provider];
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates multiple context providers in a nested structure
|
|
167
|
+
*
|
|
168
|
+
* Utility function to avoid deeply nested Provider components.
|
|
169
|
+
*
|
|
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
|
+
* @example
|
|
175
|
+
* ```typescript
|
|
176
|
+
* import { composeProviders, createContext } from '@fluixi/core/context';
|
|
177
|
+
* import { createSignal } from '@fluixi/reactive';
|
|
178
|
+
* import { html } from 'lit';
|
|
179
|
+
*
|
|
180
|
+
* const ThemeContext = createContext({ dark: false });
|
|
181
|
+
* const UserContext = createContext<User | null>(null);
|
|
182
|
+
* const LocaleContext = createContext('en');
|
|
183
|
+
*
|
|
184
|
+
* class App extends FluixiElement {
|
|
185
|
+
* private [theme] = createSignal({ dark: true });
|
|
186
|
+
* private [user] = createSignal<User | null>({ id: 1, name: 'Alice' });
|
|
187
|
+
* private [locale] = createSignal('fr');
|
|
188
|
+
*
|
|
189
|
+
* view() {
|
|
190
|
+
* return composeProviders(
|
|
191
|
+
* [
|
|
192
|
+
* [ThemeContext, this.theme()],
|
|
193
|
+
* [UserContext, this.user()],
|
|
194
|
+
* [LocaleContext, this.locale()]
|
|
195
|
+
* ],
|
|
196
|
+
* html`<app-dashboard></app-dashboard>`
|
|
197
|
+
* );
|
|
198
|
+
* }
|
|
199
|
+
* }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
export function composeProviders(contexts, children) {
|
|
203
|
+
if (contexts.length === 0) {
|
|
204
|
+
return readChildren(() => children);
|
|
205
|
+
}
|
|
206
|
+
const [context, value] = contexts[0];
|
|
207
|
+
const remaining = contexts.slice(1);
|
|
208
|
+
// Lazy-safe form: defer the nested children behind a getter so each provider
|
|
209
|
+
// stamps its context before the inner providers/children render.
|
|
210
|
+
return createProvider(context, value, {
|
|
211
|
+
get children() { return composeProviders(remaining, children); },
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Creates a context consumer component
|
|
216
|
+
*
|
|
217
|
+
* Alternative to useContext hook, useful for rendering props patterns.
|
|
218
|
+
*
|
|
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
|
+
* @example
|
|
224
|
+
* ```typescript
|
|
225
|
+
* import { createContext, createConsumer } from '@fluixi/core/context';
|
|
226
|
+
* import { html } from 'lit';
|
|
227
|
+
*
|
|
228
|
+
* const ThemeContext = createContext({ primaryColor: '#007bff' });
|
|
229
|
+
* const ThemeConsumer = createConsumer(ThemeContext);
|
|
230
|
+
*
|
|
231
|
+
* class MyComponent extends FluixiElement {
|
|
232
|
+
* view() {
|
|
233
|
+
* return html`
|
|
234
|
+
* ${ThemeConsumer({
|
|
235
|
+
* children: (theme) => html`
|
|
236
|
+
* <div style="color: ${theme.primaryColor}">
|
|
237
|
+
* Themed content
|
|
238
|
+
* </div>
|
|
239
|
+
* `
|
|
240
|
+
* })}
|
|
241
|
+
* `;
|
|
242
|
+
* }
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
export function createConsumer(context) {
|
|
247
|
+
return (props) => {
|
|
248
|
+
const value = useContext(context);
|
|
249
|
+
return props.children(value);
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Hook to provide and consume a context in one component
|
|
254
|
+
*
|
|
255
|
+
* Useful for creating context-based stores or services.
|
|
256
|
+
*
|
|
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
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* import { createContext, useProvide, Provider } from '@fluixi/core/context';
|
|
265
|
+
* import { createSignal } from '@fluixi/reactive';
|
|
266
|
+
* import { html } from 'lit';
|
|
267
|
+
*
|
|
268
|
+
* interface Counter {
|
|
269
|
+
* count: number;
|
|
270
|
+
* increment: () => void;
|
|
271
|
+
* }
|
|
272
|
+
*
|
|
273
|
+
* const CounterContext = createContext<Counter>({
|
|
274
|
+
* count: 0,
|
|
275
|
+
* increment: () => {}
|
|
276
|
+
* });
|
|
277
|
+
*
|
|
278
|
+
* class CounterProvider extends FluixiElement {
|
|
279
|
+
* view() {
|
|
280
|
+
* const counter = useProvide(CounterContext, () => {
|
|
281
|
+
* const [count, setCount] = createSignal(0);
|
|
282
|
+
* return {
|
|
283
|
+
* count: count(),
|
|
284
|
+
* increment: () => setCount(count() + 1)
|
|
285
|
+
* };
|
|
286
|
+
* });
|
|
287
|
+
*
|
|
288
|
+
* return html`
|
|
289
|
+
* ${Provider({
|
|
290
|
+
* context: CounterContext,
|
|
291
|
+
* value: counter,
|
|
292
|
+
* children: html`<slot></slot>`
|
|
293
|
+
* })}
|
|
294
|
+
* `;
|
|
295
|
+
* }
|
|
296
|
+
* }
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
export function useProvide(context, factory) {
|
|
300
|
+
// Check if already provided
|
|
301
|
+
const existing = useContext(context);
|
|
302
|
+
// If we got the default value, create new instance
|
|
303
|
+
if (existing === context.defaultValue) {
|
|
304
|
+
return factory();
|
|
305
|
+
}
|
|
306
|
+
return existing;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Creates a scoped context that only exists within a specific component tree
|
|
310
|
+
*
|
|
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
|
+
* @example
|
|
316
|
+
* ```typescript
|
|
317
|
+
* import { createContext } from '@fluixi/core/context';
|
|
318
|
+
*
|
|
319
|
+
* // This context won't leak to parent or sibling components
|
|
320
|
+
* const LocalContext = createContext({ data: 'local' });
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
// export function createContext<T>(defaultValue: T): Context<T> {
|
|
324
|
+
// // Create a unique symbol-based context for scoping
|
|
325
|
+
// return createContext(defaultValue);
|
|
326
|
+
// }
|
|
327
|
+
//
|
|
328
|
+
//
|
|
329
|
+
// ============================================================================
|
|
330
|
+
// CONTEXT HELPERS
|
|
331
|
+
// ============================================================================
|
|
332
|
+
/**
|
|
333
|
+
* Create a context for sharing state across component tree
|
|
334
|
+
*
|
|
335
|
+
* Section 9: Context is lookup-based, works on server and client
|
|
336
|
+
* Supports nested contexts and complex values
|
|
337
|
+
*
|
|
338
|
+
* @template T - Context value type
|
|
339
|
+
* @param {T} defaultValue - Default value
|
|
340
|
+
* @returns {Context<T>} Context object with Provider
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```typescript
|
|
344
|
+
* // Simple context
|
|
345
|
+
* const ThemeContext = createContext('light');
|
|
346
|
+
*
|
|
347
|
+
* // Complex context with object
|
|
348
|
+
* const AppContext = createContext({
|
|
349
|
+
* theme: 'light',
|
|
350
|
+
* toggleTheme: () => {}
|
|
351
|
+
* });
|
|
352
|
+
*
|
|
353
|
+
* // Usage in JSX
|
|
354
|
+
* <ThemeContext.Provider value="dark">
|
|
355
|
+
* <Child />
|
|
356
|
+
* </ThemeContext.Provider>
|
|
357
|
+
*
|
|
358
|
+
* // Usage in Lit-html
|
|
359
|
+
* html`
|
|
360
|
+
* <${ThemeContext.Provider} value=${{ theme: 'dark', toggleTheme }}>
|
|
361
|
+
* <${Child} />
|
|
362
|
+
* </${ThemeContext.Provider}>
|
|
363
|
+
* `
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
/**
|
|
367
|
+
* Creates a scoped context that only exists within a specific component tree
|
|
368
|
+
*
|
|
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
|
+
* @example
|
|
374
|
+
* ```typescript
|
|
375
|
+
* import { createContext } from '@fluixi/core';
|
|
376
|
+
*
|
|
377
|
+
* // This context won't leak to parent or sibling components
|
|
378
|
+
* const LocalContext = createContext({ data: 'local' });
|
|
379
|
+
* ```
|
|
380
|
+
* @example
|
|
381
|
+
* ```typescript
|
|
382
|
+
* // Simple context
|
|
383
|
+
* const ThemeContext = createContext('light');
|
|
384
|
+
*
|
|
385
|
+
* // Complex context with object
|
|
386
|
+
* const AppContext = createContext({
|
|
387
|
+
* theme: 'light',
|
|
388
|
+
* toggleTheme: () => {}
|
|
389
|
+
* });
|
|
390
|
+
*
|
|
391
|
+
* // Usage in JSX
|
|
392
|
+
* <ThemeContext.Provider value="dark">
|
|
393
|
+
* <Child />
|
|
394
|
+
* </ThemeContext.Provider>
|
|
395
|
+
*
|
|
396
|
+
* // Usage in Lit-html
|
|
397
|
+
* html`
|
|
398
|
+
* <${ThemeContext.Provider} value=${{ theme: 'dark', toggleTheme }}>
|
|
399
|
+
* <${Child} />
|
|
400
|
+
* </${ThemeContext.Provider}>
|
|
401
|
+
* `
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
export function createContext(defaultValue) {
|
|
405
|
+
const context = createReactiveContext(defaultValue);
|
|
406
|
+
// Wrap Provider to work with both JSX and Lit-html
|
|
407
|
+
const Provider = (props) => {
|
|
408
|
+
if (props.debug === true) {
|
|
409
|
+
}
|
|
410
|
+
// Pass children LAZILY (a getter). The reactive Provider reads children inside
|
|
411
|
+
// its render effect, AFTER stamping the context on the owner. Reading
|
|
412
|
+
// props.children here (e.g. `children: props.children`) evaluates the imperative
|
|
413
|
+
// `get children()` getter eagerly, so the children — and any <Outlet/> in them —
|
|
414
|
+
// render before the context is available.
|
|
415
|
+
return context.Provider({
|
|
416
|
+
value: props.value,
|
|
417
|
+
get children() {
|
|
418
|
+
return props.children;
|
|
419
|
+
},
|
|
420
|
+
debug: props.debug,
|
|
421
|
+
});
|
|
422
|
+
};
|
|
423
|
+
// For JSX: Provider.$$typeof support
|
|
424
|
+
if (typeof Symbol !== 'undefined' && Symbol.for) {
|
|
425
|
+
Provider.$$typeof = Symbol.for('react.provider');
|
|
426
|
+
}
|
|
427
|
+
Provider.$$typeof = Symbol.for('react.provider');
|
|
428
|
+
return {
|
|
429
|
+
id: context.id,
|
|
430
|
+
Provider: asProvider(Provider),
|
|
431
|
+
defaultValue: defaultValue,
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Use context value from nearest Provider
|
|
436
|
+
*
|
|
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
|
|
442
|
+
*
|
|
443
|
+
* @example
|
|
444
|
+
* ```typescript
|
|
445
|
+
* const Child = () => {
|
|
446
|
+
* const theme = useContext(ThemeContext);
|
|
447
|
+
* const { theme: currentTheme, toggleTheme } = useContext(AppContext);
|
|
448
|
+
*
|
|
449
|
+
* return html`
|
|
450
|
+
* <div>
|
|
451
|
+
* <p>Theme: ${currentTheme}</p>
|
|
452
|
+
* <button @click=${toggleTheme}>Toggle</button>
|
|
453
|
+
* </div>
|
|
454
|
+
* `;
|
|
455
|
+
* };
|
|
456
|
+
* ```
|
|
457
|
+
*/
|
|
458
|
+
export function useContext(context) {
|
|
459
|
+
// Use reactive context lookup — walks up Owner chain
|
|
460
|
+
const value = useReactiveContext(context);
|
|
461
|
+
return value !== undefined ? value : context.defaultValue;
|
|
462
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{asProvider as m}from"@fluixi/dom";import{createContext as h,useContext as g}from"@fluixi/reactive/signal";import{readChildren as b}from"@fluixi/reactive/signal";import{registerCreateComponent as p,asComponent as v}from"@fluixi/dom";import{untrack as x,onCleanup as L,getOwner as A,createEffect as k,createMemo as U,createSignal as V,isSignal as y,batch as j,runWithOwner as _}from"@fluixi/reactive/signal";function c(e){p(T)}function T(e,n){return C(e,n)}function C(e,n){let t=typeof e=="function"?x(()=>e(n)):e;if(t!=null&&(typeof t=="function"||typeof t=="object")&&!y(t)){try{t.$name=e.name}catch{}return v(t)}return t}c("index");var a=!1;function P(){a||(a=!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 s(e,n,t){let o=!!e?.Provider,r=o?e:e.context,i=o?n:e.value,d=o?!1:e.debug??!1;o||P();let l=typeof i=="function"?i():i,f=o?t:e;return r.Provider({value:l,get children(){return f?.children},debug:d})}function H(e){let n=S(e);return[n,o=>s(n,o.value,o)]}function E(e,n){if(e.length===0)return b(()=>n);let[t,o]=e[0],r=e.slice(1);return s(t,o,{get children(){return E(r,n)}})}function Q(e){return n=>{let t=u(e);return n.children(t)}}function Z(e,n){let t=u(e);return t===e.defaultValue?n():t}function S(e){let n=h(e),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:m(t),defaultValue:e}}function u(e){let n=g(e);return n!==void 0?n:e.defaultValue}export{E as composeProviders,Q as createConsumer,S as createContext,H as createContextWithProvider,s as createProvider,u as useContext,Z as useProvide};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var l=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var O=Object.prototype.hasOwnProperty;var w=(e,n)=>{for(var t in n)l(e,t,{get:n[t],enumerable:!0})},R=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of S(n))!O.call(e,i)&&i!==t&&l(e,i,{get:()=>n[i],enumerable:!(o=E(n,i))||o.enumerable});return e};var L=e=>R(l({},"__esModule",{value:!0}),e);var V={};w(V,{composeProviders:()=>f,createConsumer:()=>m,createContext:()=>p,createContextWithProvider:()=>T,createProvider:()=>s,useContext:()=>u,useProvide:()=>h});module.exports=L(V);var y=require("@fluixi/dom"),a=require("@fluixi/reactive/signal"),C=require("@fluixi/reactive/signal");var c=require("@fluixi/dom"),r=require("@fluixi/reactive/signal");function v(e){(0,c.registerCreateComponent)(A)}function A(e,n){return k(e,n)}function k(e,n){let t=typeof e=="function"?(0,r.untrack)(()=>e(n)):e;if(t!=null&&(typeof t=="function"||typeof t=="object")&&!(0,r.isSignal)(t)){try{t.$name=e.name}catch{}return(0,c.asComponent)(t)}return t}v("index");var x=!1;function U(){x||(x=!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 s(e,n,t){let o=!!e?.Provider,i=o?e:e.context,d=o?n:e.value,g=o?!1:e.debug??!1;o||U();let P=typeof d=="function"?d():d,b=o?t:e;return i.Provider({value:P,get children(){return b?.children},debug:g})}function T(e){let n=p(e);return[n,o=>s(n,o.value,o)]}function f(e,n){if(e.length===0)return(0,C.readChildren)(()=>n);let[t,o]=e[0],i=e.slice(1);return s(t,o,{get children(){return f(i,n)}})}function m(e){return n=>{let t=u(e);return n.children(t)}}function h(e,n){let t=u(e);return t===e.defaultValue?n():t}function p(e){let n=(0,a.createContext)(e),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:(0,y.asProvider)(t),defaultValue:e}}function u(e){let n=(0,a.useContext)(e);return n!==void 0?n:e.defaultValue}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/context/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,gBAAgB,EAChB,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{asProvider as g}from"@fluixi/dom";import{createContext as P,useContext as b}from"@fluixi/reactive/signal";import{readChildren as E}from"@fluixi/reactive/signal";import{registerCreateComponent as x,asComponent as y}from"@fluixi/dom";import{untrack as C,onCleanup as U,getOwner as V,createEffect as j,createMemo as M,createSignal as _,isSignal as T,batch as D,runWithOwner as $}from"@fluixi/reactive/signal";function s(e){x(m)}function m(e,n){return h(e,n)}function h(e,n){let t=typeof e=="function"?C(()=>e(n)):e;if(t!=null&&(typeof t=="function"||typeof t=="object")&&!T(t)){try{t.$name=e.name}catch{}return y(t)}return t}s("index");var u=!1;function S(){u||(u=!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 c(e,n,t){let o=!!e?.Provider,r=o?e:e.context,i=o?n:e.value,f=o?!1:e.debug??!1;o||S();let p=typeof i=="function"?i():i,v=o?t:e;return r.Provider({value:p,get children(){return v?.children},debug:f})}function O(e){let n=l(e);return[n,o=>c(n,o.value,o)]}function d(e,n){if(e.length===0)return E(()=>n);let[t,o]=e[0],r=e.slice(1);return c(t,o,{get children(){return d(r,n)}})}function w(e){return n=>{let t=a(e);return n.children(t)}}function R(e,n){let t=a(e);return t===e.defaultValue?n():t}function l(e){let n=P(e),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:g(t),defaultValue:e}}function a(e){let n=b(e);return n!==void 0?n:e.defaultValue}export{d as composeProviders,w as createConsumer,l as createContext,O as createContextWithProvider,c as createProvider,a as useContext,R as useProvide};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var h=Object.prototype.hasOwnProperty;var n=(p,r)=>{for(var t in r)y(p,t,{get:r[t],enumerable:!0})},S=(p,r,t,P)=>{if(r&&typeof r=="object"||typeof r=="function")for(let e of a(r))!h.call(p,e)&&e!==t&&y(p,e,{get:()=>r[e],enumerable:!(P=s(r,e))||P.enumerable});return p};var c=p=>S(y({},"__esModule",{value:!0}),p);var d={};n(d,{Dynamic:()=>o.Dynamic,ErrorBoundary:()=>o.ErrorBoundary,For:()=>o.For,Index:()=>o.Index,Match:()=>o.Match,Portal:()=>o.Portal,Show:()=>o.Show,Switch:()=>o.Switch});module.exports=c(d);var o=require("@fluixi/dom");
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ShowProps as _ShowProps } from '@fluixi/dom';
|
|
2
|
+
export type ShowProps<T> = _ShowProps<T, JSX.Element>;
|
|
3
|
+
export { Show, For, Index, Switch, Match, Dynamic, ErrorBoundary, Portal, type ForProps, type ForPropsKeyed, type ForPropsUnkeyed, type IndexProps, type SwitchProps, type MatchProps, type MatchNode, type DynamicProps, type ErrorBoundaryProps, type PortalProps, } from '@fluixi/dom';
|
|
4
|
+
//# sourceMappingURL=control-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-flow.d.ts","sourceRoot":"","sources":["../../../src/lib/control-flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,IAAI,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,UAAU,CAAC,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;AACtD,OAAO,EACL,IAAI,EACJ,GAAG,EACH,KAAK,EACL,MAAM,EACN,KAAK,EACL,OAAO,EACP,aAAa,EACb,MAAM,EACN,KAAK,QAAQ,EACb,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,WAAW,GACjB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Show, For, Index, Switch, Match, Dynamic, ErrorBoundary, Portal, } from '@fluixi/dom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Show as p,For as e,Index as t,Switch as y,Match as P,Dynamic as s,ErrorBoundary as a,Portal as h}from"@fluixi/dom";export{s as Dynamic,a as ErrorBoundary,e as For,t as Index,P as Match,h as Portal,p as Show,y as Switch};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Be=Object.create;var z=Object.defineProperty;var qe=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ye=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var n in t)z(e,n,{get:t[n],enumerable:!0})},U=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xe(t))!Ge.call(e,o)&&o!==n&&z(e,o,{get:()=>t[o],enumerable:!(r=qe(t,o))||r.enumerable});return e},m=(e,t,n)=>(U(e,t,"default"),n&&U(n,t,"default")),Ze=(e,t,n)=>(n=e!=null?Be(Ye(e)):{},U(t||!e||!e.__esModule?z(n,"default",{value:e,enumerable:!0}):n,e)),et=e=>U(z({},"__esModule",{value:!0}),e);var y={};Qe(y,{$component:()=>J,Dynamic:()=>C.Dynamic,ErrorBoundary:()=>C.ErrorBoundary,FRAMEWORK_NAME:()=>We,For:()=>C.For,Index:()=>C.Index,Island:()=>b.Island,Link:()=>ee,Match:()=>C.Match,Portal:()=>C.Portal,Router:()=>Q,Show:()=>C.Show,Store:()=>A.Store,Suspense:()=>j,SuspenseList:()=>le,Switch:()=>C.Switch,VERSION:()=>ze,addClass:()=>s.addClass,appendChildren:()=>s.appendChildren,batch:()=>a.batch,classMap:()=>b.classMap,cleanupDelegation:()=>Ee,clientOnly:()=>Ve,closest:()=>s.closest,composeProviders:()=>ye,createComponent:()=>D,createComputed:()=>a.createComputed,createConsumer:()=>Fe,createContext:()=>k,createContextWithProvider:()=>Ie,createDebounce:()=>K.createDebounce,createDeferred:()=>a.createDeferred,createEffect:()=>a.createEffect,createIsomorphicState:()=>me,createIsomorphicStore:()=>$e,createMemo:()=>a.createMemo,createMemoryStorage:()=>xe,createProvider:()=>Y,createRenderEffect:()=>a.createRenderEffect,createResource:()=>a.createResource,createRoot:()=>a.createRoot,createSelector:()=>K.createSelector,createSignal:()=>a.createSignal,createStore:()=>A.createStore,createTheme:()=>Ke,default:()=>Pt,delegate:()=>s.delegate,domCreateElement:()=>s.createElement,env:()=>V,getAttribute:()=>s.getAttribute,getOffset:()=>s.getOffset,getOwner:()=>a.getOwner,getStyle:()=>s.getStyle,hasClass:()=>s.hasClass,hydrateIslands:()=>b.hydrateIslands,initDelegation:()=>ke,isClient:()=>he,isJSXElement:()=>de,isLitResult:()=>ue,isNode:()=>ce,isRenderable:()=>Oe,isServer:()=>ge,isVisible:()=>s.isVisible,lazy:()=>q,mergeProps:()=>b.mergeProps,observeIntersection:()=>s.observeIntersection,observeResize:()=>s.observeResize,onCleanup:()=>a.onCleanup,onMount:()=>N,onUnmount:()=>_,portal:()=>Ae,query:()=>s.query,queryAll:()=>s.queryAll,read:()=>F.readSignal,reduce:()=>F.reduceSignal,removeAttribute:()=>s.removeAttribute,removeChildren:()=>s.removeChildren,removeClass:()=>s.removeClass,render:()=>pe,runWithOwner:()=>a.runWithOwner,scrollIntoView:()=>s.scrollIntoView,setAttribute:()=>s.setAttribute,setOwner:()=>a.setOwner,setStyles:()=>s.setStyles,splitProps:()=>b.splitProps,storage:()=>$,styleMap:()=>b.styleMap,toggleClass:()=>s.toggleClass,untrack:()=>a.untrack,untrackStore:()=>A.untrackStore,unwrap:()=>A.unwrap,useCallback:()=>ae,useContext:()=>E,useEffect:()=>B,useEventListener:()=>ie,useLocation:()=>Ue,useMemo:()=>re,useNavigate:()=>Z,useParams:()=>He,useProvide:()=>Ne,useReducer:()=>se,useRef:()=>oe,useRouter:()=>L,waitForElement:()=>s.waitForElement});module.exports=et(y);var a=require("@fluixi/reactive/signal"),K=require("@fluixi/reactive/signal"),F=require("@fluixi/reactive/operators");var Re=require("@fluixi/reactive/signal"),P=require("@fluixi/dom");var W=require("@fluixi/dom"),d=require("@fluixi/reactive/signal");var ne=Symbol.for("fluixi-lifecycle");function be(){let e=(0,d.getOwner)();if(!e)return null;if(!e[ne]){let t={mounts:[],effects:[],scheduled:!1};e[ne]=t}return e[ne]}function Se(e){if(e.scheduled)return;e.scheduled=!0;let t=(0,d.getOwner)();queueMicrotask(()=>{(0,d.runWithOwner)(t,()=>{for(let n of e.mounts)try{let r=n();typeof r=="function"&&(0,d.onCleanup)(r)}catch(r){console.error("Error in onMount callback:",r)}for(let n of e.effects){let r;(0,d.createEffect)(()=>{r&&r(),r=n()}),(0,d.onCleanup)(()=>{r&&r()})}e.mounts=[],e.effects=[]})})}function M(e){(0,W.registerCreateComponent)(D)}function D(e,t){return J(e,t)}function J(e,t){let n=typeof e=="function"?(0,d.untrack)(()=>e(t)):e;if(n!=null&&(typeof n=="function"||typeof n=="object")&&!(0,d.isSignal)(n)){try{n.$name=e.name}catch{}return(0,W.asComponent)(n)}return n}function N(e,t=!0){let n=be();if(n){if(!t){n.scheduled||e();return}n.mounts.push(e),Se(n)}else{if(!t){e();return}(0,d.createEffect)(()=>{let r=(0,d.untrack)(e);typeof r=="function"&&(0,d.onCleanup)(r)})}}function _(e){(0,d.onCleanup)(e)}function B(e){let t=be();if(t)t.effects.push(e),Se(t);else{let n;(0,d.createEffect)(()=>{n&&n(),n=e()}),(0,d.onCleanup)(()=>{n&&n()})}}function re(e){return(0,d.createMemo)(e)}function oe(e){let t={current:e};return(0,d.onCleanup)(()=>{t.current=null}),t}function se(e,t){let[n,r]=(0,d.createSignal)(t);return[n,c=>{r(e(n(),c))}]}function ie(e,t,n,r){B(()=>{let o=e&&"current"in e?e.current:e;if(o)return o.addEventListener(t,n,r),()=>{o.removeEventListener(t,n,r)}})}function ae(e){return e}var g=require("@fluixi/reactive/signal"),S=require("@fluixi/dom");function ce(e){return typeof window>"u"?!1:typeof Node=="function"&&e instanceof Node?!0:!!(e&&typeof e=="object"&&typeof e.nodeType=="number")}function ue(e){return!e||typeof e!="object"?!1:!!(typeof e._$litType$<"u"||typeof e._$litDirective$<"u"||Array.isArray(e.strings)&&Array.isArray(e.values))}function Pe(e){return!!(e&&typeof e=="object"&&typeof e.then=="function"||e instanceof Promise)}function de(e){return!!(e&&typeof e=="object"&&"type"in e&&"props"in e)}var we=(0,g.createContext)();function j(e){return(0,S.createComponent)(tt,e)}function tt(e){let t=(0,g.createSuspenseBoundary)(),n=(0,g.useContext)(we),r=n?n.register(t.inFallback):void 0;function o(f){return f==null||typeof f=="boolean"?null:typeof f=="function"&&(0,S.isComponent)(f)&&!(0,g.isSignal)(f)?f():f}let c=(0,S.runWithoutHydration)(()=>o(e.fallback??null)),i=(0,g.provideSuspense)(t,()=>e.children);(0,g.provideSuspense)(t,()=>{(0,g.createRenderEffect)(()=>{let f=i;if(Array.isArray(f))for(let x of f)typeof x=="function"&&(0,g.isSignal)(x)&&x();else typeof f=="function"&&(0,g.isSignal)(f)&&f()})});let[l,u]=(0,g.createSignal)(void 0),T=Pe(i);return T&&(t.increment(),i.then(f=>{u(()=>f),t.decrement()},()=>t.decrement())),(0,g.createMemo)(()=>(r?r.showFallback():t.inFallback())?c:T?l():i)}function le(e){return(0,S.createComponent)(nt,e)}function nt(e){let{revealOrder:t="together",tail:n}=e,r=[];function o(){if(t==="together"){let i=r.every(l=>!l.inFallback());r.forEach(l=>{l.setShowContent(i),l.setShowFallback(!i)})}else{let i=t==="backwards"?[...r].reverse():r,l=!1;for(let u of i)l||u.inFallback()?(l=!0,u.setShowContent(!1),u.setShowFallback(n!=="hidden")):(u.setShowContent(!0),u.setShowFallback(!1))}}let c={register:i=>{let[l,u]=(0,g.createSignal)(!0),[T,f]=(0,g.createSignal)(!1);return r.push({inFallback:i,setShowContent:u,setShowFallback:f}),(0,g.createEffect)(()=>{i(),o()}),{showContent:l,showFallback:T}}};return we.Provider({value:c,children:e.children})}(0,S.asSuspense)(j);Object.defineProperty(j,"__suspense",{value:!0,enumerable:!0});var O=require("@fluixi/reactive/signal");function q(e,t){let n,r,o;function c(){return r||(r=e().then(l=>n=l.default)),r}t?.preload&&c();let i=(l=>{if(n){let u=n;return(0,O.untrack)(()=>u(l))}if(!o){let[u]=(0,O.createResource)(()=>c());if(o=u,u.error)throw u.error}return(0,O.createMemo)(()=>{let u=o();return u?(0,O.untrack)(()=>u(l)):void 0},void 0,{name:"lazy"})});return i.preload=()=>c().then(()=>{}),i.$lazy=!0,i.loader=e,i}typeof window<"u"&&import("lit").then(e=>(0,P.registerLitRender)(e.render));var fe=typeof window>"u";function pe(e,t,n={}){if(M("render"),(0,P.delegateEvents)(["click","input","change","submit"]),fe)throw new Error("render() is for client-side only. Use renderToString() on server.");if(!t)throw new Error("Container element is required");let r;return(0,Re.createRoot)(o=>{r=o;let c=typeof e=="function"?e():e;t.textContent="",t.setAttribute("fluixi-js","v1"),(0,P.insert)(t,()=>c)}),()=>{r&&(r(),r=void 0)}}function rt(e){return e&&typeof e=="object"&&(e._$litType$!==void 0||e._$litDirective$!==void 0)}function Ae(e,t,n={}){let r=document.createElement("div");r.setAttribute("data-portal","true"),t.appendChild(r);let o=pe(e,r,n);return()=>{o(),t.contains(r)&&t.removeChild(r)}}function Oe(e){return!!(e==null||typeof e=="function"||(0,P.isDOMNode)(e)||rt(e)||Array.isArray(e)||typeof e=="string"||typeof e=="number"||typeof e=="boolean")}function ke(){fe||(0,P.delegateEvents)(["click","input","change","submit"])}function Ee(){}var Me=require("@fluixi/dom"),X=require("@fluixi/reactive/signal"),De=require("@fluixi/reactive/signal");M("index");var Le=!1;function ot(){Le||(Le=!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 Y(e,t,n){let r=!!e?.Provider,o=r?e:e.context,c=r?t:e.value,i=r?!1:e.debug??!1;r||ot();let l=typeof c=="function"?c():c,u=r?n:e;return o.Provider({value:l,get children(){return u?.children},debug:i})}function Ie(e){let t=k(e);return[t,r=>Y(t,r.value,r)]}function ye(e,t){if(e.length===0)return(0,De.readChildren)(()=>t);let[n,r]=e[0],o=e.slice(1);return Y(n,r,{get children(){return ye(o,t)}})}function Fe(e){return t=>{let n=E(e);return t.children(n)}}function Ne(e,t){let n=E(e);return n===e.defaultValue?t():n}function k(e){let t=(0,X.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,Me.asProvider)(n),defaultValue:e}}function E(e){let t=(0,X.useContext)(e);return t!==void 0?t:e.defaultValue}var G=require("@fluixi/reactive/signal"),_e=require("@fluixi/dom"),st="__fluixi_iso_states__",it="__iso:";function at(){return globalThis[st]??=new Map}function je(e){if(typeof window>"u")return;let t=(0,_e.getServerData)();return t?t[it+e]:void 0}function me(e,t){let n=je(e),r=n!==void 0?n:typeof window<"u"&&t.client?t.client():t.fallback,[o,c]=(0,G.createSignal)(r);return at().set(e,{server:t.server,set:c}),{value:o,set:c,key:e}}function $e(e,t){let n=je(e)!==void 0,r=me(e,{server:t.server,fallback:t.fallback}),o=()=>r.value()??t.fallback,c=x=>{if(!(!t.persist||typeof localStorage>"u"))try{localStorage.setItem(t.persist,JSON.stringify(x))}catch{}},i=x=>{r.set(x),c(x)},l=(x,H)=>{i({...o(),[x]:H})},u={};for(let x of Object.keys(t.fallback))u[x]=(0,G.createMemo)(()=>o()[x]);let T=null;return{value:o,fields:u,set:i,setField:l,ensureInit:()=>n||!t.client?Promise.resolve():(T||(T=Promise.resolve(t.client()).then(x=>{i(x)}).catch(x=>{throw T=null,x})),T),key:e}}var ge=typeof document>"u",he=!ge;function xe(){let e=new Map;return{getItem:t=>e.has(t)?e.get(t):null,setItem:(t,n)=>{e.set(t,String(n))},removeItem:t=>{e.delete(t)},clear:()=>e.clear(),key:t=>Array.from(e.keys())[t]??null,get length(){return e.size}}}var $=typeof localStorage<"u"?localStorage:xe(),V={get window(){return typeof window<"u"?window:void 0},get document(){return typeof document<"u"?document:void 0}};function Ve(e,t){return he?e():t}var Te=require("@fluixi/reactive/signal");function ct(e){return e?e===!0?{dark:"dark",light:"light"}:e:null}function Ke(e){let t=e.storageKey??"theme",n=e.attribute??"data-theme",r=ct(e.system),o=()=>{let v=$.getItem(t);return v&&e.themes.includes(v)?v:r&&V.window?.matchMedia?.("(prefers-color-scheme: dark)")?.matches?r.dark:r?r.light:e.default},[c,i]=(0,Te.createSignal)(o()),[l,u]=(0,Te.createSignal)(!1),T=v=>{V.document?.documentElement.setAttribute(n,v);try{$.setItem(t,v)}catch{}},f=v=>{if(!e.themes.includes(v))return;let Je=c();i(()=>v),T(v),e.onChange?.(v,Je),e.load&&(u(!0),e.onLoading?.(v),Promise.resolve(e.load(v)).finally(()=>{u(!1),e.onLoaded?.(v)}))};return{value:c,isLoading:l,set:f,toggle:()=>{let v=e.themes.indexOf(c());f(e.themes[(v+1)%e.themes.length])},init:()=>T(c()),headScript:()=>`<script>(function(){try{var c=${JSON.stringify({k:t,a:n,d:e.default,sys:r})},t=localStorage.getItem(c.k);if(!t&&c.sys)t=matchMedia('(prefers-color-scheme: dark)').matches?c.sys.dark:c.sys.light;if(!t)t=c.d;document.documentElement.setAttribute(c.a,t);}catch(e){}})();<\/script>`}}m(y,require("@fluixi/utils"),module.exports);var p=require("@fluixi/reactive/signal"),h=require("@fluixi/dom"),R=require("@fluixi/reactive/signal"),pt=require("@fluixi/utils/object"),yt=require("@fluixi/utils/compare"),I=require("@fluixi/router"),te=require("@fluixi/router");var ve=require("@fluixi/reactive/signal");var ut=new Map;function dt(){ut.clear()}function lt(){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,c=o.nodeValue||"";(c.startsWith("#")||c.startsWith("/"))&&n.push(o)}n.forEach(o=>o.remove()),dt()}typeof window<"u"&&window.addEventListener("load",()=>{setTimeout(lt,100)});var[yn,mn]=(0,ve.createSignal)(0);var ft=k(),gn=ft.Provider;var St=require("@fluixi/reactive/signal"),Ce=(0,R.createContext)(),mt=(0,R.createContext)(),gt=(0,R.createContext)(),ht=(0,R.createContext)();function xt(e,t,n){let r,o=e.route.data;if(typeof o=="function"){let f=!1;(0,p.onCleanup)(()=>{f=!0});let x=(0,p.getOwner)(),[H]=(0,p.createResource)(()=>o({params:n.params,location:n.location},x,()=>f));r=H}let c=()=>ht.Provider({value:r,get children(){return gt.Provider({value:e.params,get children(){return mt.Provider({value:{depth:t,...n},get children(){return(0,h.createComponent)(e.component,{})}})}})}});if(!r)return c();let i=r,l=()=>i.loading,[u,T]=(0,p.createSignal)((0,p.untrack)(()=>!l()));return(0,p.createEffect)(()=>T(!l())),(0,p.createMemo)(()=>u()?c():null)}function Tt(e){let t=e.depth+1,[n,r]=(0,p.createSignal)((0,p.untrack)(()=>e.matched()[t]?.component));return(0,p.createEffect)(()=>{let o=e.matched()[t]?.component;r(()=>o)}),(0,p.createMemo)(()=>{if(!n())return e.notFound?e.notFound():null;let c=(0,p.untrack)(()=>e.matched())[t];return xt(c,t,{matched:e.matched,params:e.params,location:e.location})})}function vt(e){return e==null?Ct():typeof e=="function"?(0,h.createComponent)(e,{}):e}function Ct(){let e=(0,h.createNativeElement)("div");(0,h.setAttribute)(e,"class","fx-not-found"),(0,h.setAttribute)(e,"role","main"),(0,h.setAttribute)(e,"style","min-height:60vh;display:grid;place-content:center;gap:.25rem;text-align:center;font-family:system-ui,-apple-system,sans-serif");let t=(0,h.createNativeElement)("h1");(0,h.setAttribute)(t,"style","margin:0;font-size:2.5rem;font-weight:700"),(0,h.insert)(t,"404");let n=(0,h.createNativeElement)("p");return(0,h.setAttribute)(n,"style","margin:0;opacity:.7"),(0,h.insert)(n,"This page could not be found."),e.appendChild(t),e.appendChild(n),e}function Q(e){let t=e.history??(0,I.createBrowserHistory)(),n=(0,I.createRouter)({routes:e.routes,base:e.base,history:t}),[r,o]=(0,p.createSignal)(n.state()),c=n.subscribe(o);(0,p.onCleanup)(()=>{c(),n.destroy()});let i=(0,p.createMemo)(()=>(r().match?.matched??[]).filter(f=>f.component)),l={router:n,location:(0,p.createMemo)(()=>r().location),params:(0,p.createMemo)(()=>r().match?.params??{})},u={depth:-1,matched:i,params:l.params,location:l.location,notFound:()=>vt(e.notFound)},T;return Ce.Provider({value:l,get children(){return T??=Tt(u)}})}var bt={router:{navigate:()=>{}},location:()=>({pathname:"",search:"",hash:"",query:{}}),params:()=>({})};function L(){let e=(0,R.useContext)(Ce);if(e)return e;if(typeof window>"u")return bt;throw new Error("[router-next] useRouter must be used within <Router>")}function He(){let e=L().params;return(0,p.createMemo)(()=>e(),{},{equals:(t,n)=>JSON.stringify(t)===JSON.stringify(n)})}function Ue(){let{location:e}=L();return new Proxy({},{get:(t,n)=>e()[n],has:(t,n)=>n in e(),ownKeys:()=>Reflect.ownKeys(e()),getOwnPropertyDescriptor:(t,n)=>Object.getOwnPropertyDescriptor(e(),n)})}function Z(){let{router:e}=L();return(t,n)=>e.navigate(t,n)}var w=e=>typeof e=="function"?e():e;function ee(e){let t=(0,R.useContext)(Ce),n=typeof document>"u",r=()=>t?.router.navigate(w(e.href)??"",{replace:w(e.replace)}),o=(0,h.createNativeElement)("a");if((0,h.setAttribute)(o,"href",w(e.href)??""),e.slot&&(0,h.setAttribute)(o,"slot",w(e.slot)),typeof o.addEventListener=="function")o.addEventListener("click",i=>{i.metaKey||i.ctrlKey||i.shiftKey||i.altKey||(i.preventDefault(),r())});else{let i=w(e.className??e.class)??"";i&&(0,h.setAttribute)(o,"class",i)}typeof o.addEventListener=="function"&&(0,p.createEffect)(()=>{let i=w(e.href)??"";o.setAttribute("href",i);let l=w(e.className??e.class)??"",u=w(e.activeClass)??"",T=w(e.active)??t?.location().pathname===i;o.className=[l,T?u:""].filter(Boolean).join(" ")});let c=e.children;return c!=null&&(0,h.insert)(o,c),o}var s=require("@fluixi/dom"),b=require("@fluixi/dom");var C=require("@fluixi/dom");var A=require("@fluixi/reactive/store"),ze="0.0.1",We="Fluixi";var Pt={createComponent:D,onMount:N,onUnmount:_,createEffect:a.createEffect,createMemo:a.createMemo,createSignal:a.createSignal,createContext:k,createRoot:a.createRoot,createDeferred:a.createDeferred,createComputed:a.createComputed,createRenderEffect:a.createRenderEffect,createSelector:K.createSelector,onCleanup:a.onCleanup,getOwner:a.getOwner,runWithOwner:a.runWithOwner,batch:a.batch,untrack:a.untrack,useContext:E,setOwner:a.setOwner,Router:Q,Link:ee,useRouter:L,useNavigate:Z,read:F.readSignal,reduce:F.reduceSignal,VERSION:ze,FRAMEWORK_NAME:We};M("fluixi element main");
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Fluixi - A reactive framework for lit-html inspired by SolidJS
|
|
3
|
+
* @module @fluixi/core
|
|
4
|
+
* @version 0.0.1
|
|
5
|
+
*
|
|
6
|
+
* Fluixi is a modern reactive framework that combines the power of lit-html
|
|
7
|
+
* with fine-grained reactivity from @fluixi/reactive, inspired by SolidJS's design.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { createSignal, render, html } from '@fluixi/core';
|
|
12
|
+
*
|
|
13
|
+
* const Counter = () => {
|
|
14
|
+
* const [count, setCount] = createSignal(0);
|
|
15
|
+
*
|
|
16
|
+
* return html`
|
|
17
|
+
* <div>
|
|
18
|
+
* <p>Count: ${count()}</p>
|
|
19
|
+
* <button @click=${() => setCount(count() + 1)}>Increment</button>
|
|
20
|
+
* </div>
|
|
21
|
+
* `;
|
|
22
|
+
* };
|
|
23
|
+
*
|
|
24
|
+
* render(Counter, document.getElementById('app')!);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
import { createEffect, createMemo, createSignal, createResource, createRoot, createComputed, createRenderEffect, onCleanup, getOwner, runWithOwner, batch, untrack, createDeferred, setOwner } from '@fluixi/reactive/signal';
|
|
28
|
+
import { createDebounce, createSelector } from '@fluixi/reactive/signal';
|
|
29
|
+
import { readSignal as read, reduceSignal as reduce } from '@fluixi/reactive/operators';
|
|
30
|
+
import { createComponent, onMount, onUnmount } from './render/index.js';
|
|
31
|
+
import { createContext, useContext } from './context/index.js';
|
|
32
|
+
export * from './context/index.js';
|
|
33
|
+
export { createIsomorphicState, createIsomorphicStore, type IsomorphicState, type IsomorphicOptions, type IsomorphicStore, type IsomorphicStoreOptions, } from './isomorphic.js';
|
|
34
|
+
export { isServer, isClient, storage, createMemoryStorage, env, clientOnly, } from './env/index.js';
|
|
35
|
+
export { createTheme, type Theme, type ThemeOptions } from './theme/index.js';
|
|
36
|
+
export * from '@fluixi/utils';
|
|
37
|
+
import { Link, Router, useNavigate, useRouter } from './router-next/index.js';
|
|
38
|
+
export { query, queryAll, closest, addClass, removeClass, toggleClass, hasClass, setAttribute, getAttribute, removeAttribute, setStyles, getStyle, createElement as domCreateElement, removeChildren, appendChildren, isVisible, scrollIntoView, getOffset, delegate, waitForElement, observeIntersection, observeResize, } from '@fluixi/dom';
|
|
39
|
+
export { classMap, styleMap, Island, hydrateIslands, type IslandProps, type IslandRegistry, mergeProps, splitProps, type ComponentFn, type ComponentChild, type ComponentOrElement, type FxComponent, type FxC, type FxParentProps, type FxParent, type FxVoidProps, type FxVoid, type FxFlowProps, type FxFlow, } from '@fluixi/dom';
|
|
40
|
+
export * from "./control-flow.js";
|
|
41
|
+
export { createStore, untrackStore, unwrap, Store } from '@fluixi/reactive/store';
|
|
42
|
+
export type { Accessor, Setter, Signal, SignalOptions, MemoOptions, Resource, } from '@fluixi/reactive/signal';
|
|
43
|
+
export type { ReadSignal } from '@fluixi/reactive/operators';
|
|
44
|
+
export { render, portal, isRenderable, initDelegation, cleanupDelegation, createComponent, onMount, onUnmount, useEffect, useRef, useReducer, useMemo, useEventListener, useCallback, lazy, Suspense, SuspenseList, isNode, isLitResult, isJSXElement, $component, type RenderOptions, type SuspenseProps, type SuspenseListProps, type LazyOptions, type Component, type ComponentProps, type LifecycleCallback, type LazyComponent, type RefObject, } from './render/index.js';
|
|
45
|
+
export type { $ShowProps, $MatchProps, $SwitchProps, $ForProps, $IndexProps, $PortalProps, $DynamicProps, $DynamicSwitchProps, } from '@fluixi/lit';
|
|
46
|
+
export { Router, Link, useRouter, useLocation, useNavigate, useParams, } from './router-next/index.js';
|
|
47
|
+
export type { RouterLocation as Location, RouteDefinition, NavigateOptions, } from './router-next/index.js';
|
|
48
|
+
/**
|
|
49
|
+
* Framework version
|
|
50
|
+
*/
|
|
51
|
+
export declare const VERSION = "0.0.1";
|
|
52
|
+
/**
|
|
53
|
+
* Framework name
|
|
54
|
+
*/
|
|
55
|
+
export declare const FRAMEWORK_NAME = "Fluixi";
|
|
56
|
+
export { createEffect, createMemo, createSignal, createResource, createContext, createRoot, createDeferred, createDebounce, createComputed, createRenderEffect, createSelector, onCleanup, getOwner, runWithOwner, batch, untrack, useContext, setOwner, read, reduce, };
|
|
57
|
+
/**
|
|
58
|
+
* Default export - commonly used functions
|
|
59
|
+
*/
|
|
60
|
+
declare const _default: {
|
|
61
|
+
createComponent: typeof createComponent;
|
|
62
|
+
onMount: typeof onMount;
|
|
63
|
+
onUnmount: typeof onUnmount;
|
|
64
|
+
createEffect: typeof createEffect;
|
|
65
|
+
createMemo: typeof createMemo;
|
|
66
|
+
createSignal: typeof createSignal;
|
|
67
|
+
createContext: typeof createContext;
|
|
68
|
+
createRoot: typeof createRoot;
|
|
69
|
+
createDeferred: typeof createDeferred;
|
|
70
|
+
createComputed: typeof createComputed;
|
|
71
|
+
createRenderEffect: typeof createRenderEffect;
|
|
72
|
+
createSelector: typeof createSelector;
|
|
73
|
+
onCleanup: typeof onCleanup;
|
|
74
|
+
getOwner: typeof getOwner;
|
|
75
|
+
runWithOwner: typeof runWithOwner;
|
|
76
|
+
batch: typeof batch;
|
|
77
|
+
untrack: typeof untrack;
|
|
78
|
+
useContext: typeof useContext;
|
|
79
|
+
setOwner: typeof setOwner;
|
|
80
|
+
Router: typeof Router;
|
|
81
|
+
Link: typeof Link;
|
|
82
|
+
useRouter: typeof useRouter;
|
|
83
|
+
useNavigate: typeof useNavigate;
|
|
84
|
+
read: typeof read;
|
|
85
|
+
reduce: typeof reduce;
|
|
86
|
+
VERSION: string;
|
|
87
|
+
FRAMEWORK_NAME: string;
|
|
88
|
+
};
|
|
89
|
+
export default _default;
|
|
90
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../src/lib/core.ts"],"names":[],"mappings":"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"}
|