@vertz/ui 0.2.0
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/README.md +1138 -0
- package/dist/css/public.d.ts +157 -0
- package/dist/css/public.js +18 -0
- package/dist/form/public.d.ts +111 -0
- package/dist/form/public.js +11 -0
- package/dist/index.d.ts +700 -0
- package/dist/index.js +261 -0
- package/dist/internals.d.ts +414 -0
- package/dist/internals.js +268 -0
- package/dist/jsx-runtime/index.d.ts +40 -0
- package/dist/jsx-runtime/index.js +50 -0
- package/dist/query/public.d.ts +58 -0
- package/dist/query/public.js +7 -0
- package/dist/router/public.d.ts +214 -0
- package/dist/router/public.js +21 -0
- package/dist/shared/chunk-bp3v6s9j.js +62 -0
- package/dist/shared/chunk-d8h2eh8d.js +141 -0
- package/dist/shared/chunk-f1ynwam4.js +872 -0
- package/dist/shared/chunk-j8vzvne3.js +153 -0
- package/dist/shared/chunk-pgymxpn1.js +308 -0
- package/dist/shared/chunk-tsdpgmks.js +98 -0
- package/dist/shared/chunk-xd9d7q5p.js +115 -0
- package/dist/shared/chunk-zbbvx05f.js +202 -0
- package/dist/test/index.d.ts +268 -0
- package/dist/test/index.js +236 -0
- package/package.json +76 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import {
|
|
2
|
+
eagerStrategy,
|
|
3
|
+
hydrate,
|
|
4
|
+
idleStrategy,
|
|
5
|
+
interactionStrategy,
|
|
6
|
+
lazyStrategy,
|
|
7
|
+
mediaStrategy,
|
|
8
|
+
visibleStrategy
|
|
9
|
+
} from "./shared/chunk-d8h2eh8d.js";
|
|
10
|
+
import {
|
|
11
|
+
createLink,
|
|
12
|
+
createOutlet,
|
|
13
|
+
parseSearchParams,
|
|
14
|
+
useSearchParams
|
|
15
|
+
} from "./shared/chunk-bp3v6s9j.js";
|
|
16
|
+
import {
|
|
17
|
+
createRouter
|
|
18
|
+
} from "./shared/chunk-xd9d7q5p.js";
|
|
19
|
+
import {
|
|
20
|
+
defineRoutes
|
|
21
|
+
} from "./shared/chunk-j8vzvne3.js";
|
|
22
|
+
import {
|
|
23
|
+
form,
|
|
24
|
+
formDataToObject,
|
|
25
|
+
validate
|
|
26
|
+
} from "./shared/chunk-tsdpgmks.js";
|
|
27
|
+
import {
|
|
28
|
+
query
|
|
29
|
+
} from "./shared/chunk-zbbvx05f.js";
|
|
30
|
+
import {
|
|
31
|
+
DisposalScopeError,
|
|
32
|
+
_tryOnCleanup,
|
|
33
|
+
batch,
|
|
34
|
+
computed,
|
|
35
|
+
createContext,
|
|
36
|
+
effect,
|
|
37
|
+
onCleanup,
|
|
38
|
+
popScope,
|
|
39
|
+
pushScope,
|
|
40
|
+
runCleanups,
|
|
41
|
+
signal,
|
|
42
|
+
untrack,
|
|
43
|
+
useContext
|
|
44
|
+
} from "./shared/chunk-pgymxpn1.js";
|
|
45
|
+
import {
|
|
46
|
+
ThemeProvider,
|
|
47
|
+
compileTheme,
|
|
48
|
+
css,
|
|
49
|
+
defineTheme,
|
|
50
|
+
globalCss,
|
|
51
|
+
s,
|
|
52
|
+
variants
|
|
53
|
+
} from "./shared/chunk-f1ynwam4.js";
|
|
54
|
+
|
|
55
|
+
// src/component/children.ts
|
|
56
|
+
function resolveChildren(value) {
|
|
57
|
+
if (value == null) {
|
|
58
|
+
return [];
|
|
59
|
+
}
|
|
60
|
+
if (typeof value === "string") {
|
|
61
|
+
return [document.createTextNode(value)];
|
|
62
|
+
}
|
|
63
|
+
if (typeof value === "number") {
|
|
64
|
+
return [document.createTextNode(String(value))];
|
|
65
|
+
}
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
const result = [];
|
|
68
|
+
for (const child of value) {
|
|
69
|
+
const resolved = resolveChildren(child);
|
|
70
|
+
for (const node of resolved) {
|
|
71
|
+
result.push(node);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
return [value];
|
|
77
|
+
}
|
|
78
|
+
function children(accessor) {
|
|
79
|
+
return () => resolveChildren(accessor());
|
|
80
|
+
}
|
|
81
|
+
// src/component/error-boundary-context.ts
|
|
82
|
+
var handlerStack = [];
|
|
83
|
+
function pushErrorHandler(handler) {
|
|
84
|
+
handlerStack.push(handler);
|
|
85
|
+
}
|
|
86
|
+
function popErrorHandler() {
|
|
87
|
+
handlerStack.pop();
|
|
88
|
+
}
|
|
89
|
+
function getCurrentErrorHandler() {
|
|
90
|
+
if (handlerStack.length === 0) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
return handlerStack[handlerStack.length - 1];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/component/error-boundary.ts
|
|
97
|
+
function toError(value) {
|
|
98
|
+
if (value instanceof Error) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
return new Error(String(value));
|
|
102
|
+
}
|
|
103
|
+
function ErrorBoundary(props) {
|
|
104
|
+
function handleAsyncError(error, placeholder) {
|
|
105
|
+
const fallbackNode = props.fallback(error, retry);
|
|
106
|
+
function retry() {
|
|
107
|
+
try {
|
|
108
|
+
const retryResult = props.children();
|
|
109
|
+
if (fallbackNode.parentNode) {
|
|
110
|
+
fallbackNode.parentNode.replaceChild(retryResult, fallbackNode);
|
|
111
|
+
}
|
|
112
|
+
} catch (_retryThrown) {}
|
|
113
|
+
}
|
|
114
|
+
if (placeholder.parentNode) {
|
|
115
|
+
placeholder.parentNode.replaceChild(fallbackNode, placeholder);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
pushErrorHandler(handleAsyncError);
|
|
120
|
+
const result = props.children();
|
|
121
|
+
popErrorHandler();
|
|
122
|
+
return result;
|
|
123
|
+
} catch (thrown) {
|
|
124
|
+
let retry = function() {
|
|
125
|
+
try {
|
|
126
|
+
const retryResult = props.children();
|
|
127
|
+
if (fallbackNode.parentNode) {
|
|
128
|
+
fallbackNode.parentNode.replaceChild(retryResult, fallbackNode);
|
|
129
|
+
}
|
|
130
|
+
} catch (_retryThrown) {}
|
|
131
|
+
};
|
|
132
|
+
popErrorHandler();
|
|
133
|
+
const error = toError(thrown);
|
|
134
|
+
const fallbackNode = props.fallback(error, retry);
|
|
135
|
+
return fallbackNode;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
// src/component/lifecycle.ts
|
|
139
|
+
function onMount(callback) {
|
|
140
|
+
const scope = pushScope();
|
|
141
|
+
try {
|
|
142
|
+
untrack(callback);
|
|
143
|
+
} finally {
|
|
144
|
+
popScope();
|
|
145
|
+
if (scope.length > 0) {
|
|
146
|
+
_tryOnCleanup(() => runCleanups(scope));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function watch(dep, callback) {
|
|
151
|
+
let innerCleanups = null;
|
|
152
|
+
const dispose = effect(() => {
|
|
153
|
+
if (innerCleanups) {
|
|
154
|
+
runCleanups(innerCleanups);
|
|
155
|
+
}
|
|
156
|
+
const value = dep();
|
|
157
|
+
innerCleanups = pushScope();
|
|
158
|
+
try {
|
|
159
|
+
untrack(() => callback(value));
|
|
160
|
+
} finally {
|
|
161
|
+
popScope();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
_tryOnCleanup(() => {
|
|
165
|
+
if (innerCleanups) {
|
|
166
|
+
runCleanups(innerCleanups);
|
|
167
|
+
}
|
|
168
|
+
dispose();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// src/component/refs.ts
|
|
172
|
+
function ref() {
|
|
173
|
+
return { current: undefined };
|
|
174
|
+
}
|
|
175
|
+
// src/component/suspense.ts
|
|
176
|
+
function isPromise(value) {
|
|
177
|
+
return value != null && typeof value === "object" && typeof value.then === "function";
|
|
178
|
+
}
|
|
179
|
+
function toError2(value) {
|
|
180
|
+
if (value instanceof Error) {
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
return new Error(String(value));
|
|
184
|
+
}
|
|
185
|
+
function propagateError(error, placeholder, errorHandler) {
|
|
186
|
+
if (errorHandler) {
|
|
187
|
+
errorHandler(error, placeholder);
|
|
188
|
+
} else {
|
|
189
|
+
queueMicrotask(() => {
|
|
190
|
+
throw error;
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function Suspense(props) {
|
|
195
|
+
const errorHandler = getCurrentErrorHandler();
|
|
196
|
+
try {
|
|
197
|
+
return props.children();
|
|
198
|
+
} catch (thrown) {
|
|
199
|
+
if (!isPromise(thrown)) {
|
|
200
|
+
throw thrown;
|
|
201
|
+
}
|
|
202
|
+
const placeholder = props.fallback();
|
|
203
|
+
thrown.then(() => {
|
|
204
|
+
try {
|
|
205
|
+
const resolved = props.children();
|
|
206
|
+
if (placeholder.parentNode) {
|
|
207
|
+
placeholder.parentNode.replaceChild(resolved, placeholder);
|
|
208
|
+
}
|
|
209
|
+
} catch (retryError) {
|
|
210
|
+
if (!isPromise(retryError)) {
|
|
211
|
+
propagateError(toError2(retryError), placeholder, errorHandler);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}).catch((error) => {
|
|
215
|
+
propagateError(toError2(error), placeholder, errorHandler);
|
|
216
|
+
});
|
|
217
|
+
return placeholder;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export {
|
|
221
|
+
watch,
|
|
222
|
+
visibleStrategy,
|
|
223
|
+
variants,
|
|
224
|
+
validate,
|
|
225
|
+
useSearchParams,
|
|
226
|
+
useContext,
|
|
227
|
+
untrack,
|
|
228
|
+
signal,
|
|
229
|
+
s,
|
|
230
|
+
resolveChildren,
|
|
231
|
+
ref,
|
|
232
|
+
query,
|
|
233
|
+
parseSearchParams,
|
|
234
|
+
onMount,
|
|
235
|
+
onCleanup,
|
|
236
|
+
mediaStrategy,
|
|
237
|
+
lazyStrategy,
|
|
238
|
+
interactionStrategy,
|
|
239
|
+
idleStrategy,
|
|
240
|
+
hydrate,
|
|
241
|
+
globalCss,
|
|
242
|
+
formDataToObject,
|
|
243
|
+
form,
|
|
244
|
+
effect,
|
|
245
|
+
eagerStrategy,
|
|
246
|
+
defineTheme,
|
|
247
|
+
defineRoutes,
|
|
248
|
+
css,
|
|
249
|
+
createRouter,
|
|
250
|
+
createOutlet,
|
|
251
|
+
createLink,
|
|
252
|
+
createContext,
|
|
253
|
+
computed,
|
|
254
|
+
compileTheme,
|
|
255
|
+
children,
|
|
256
|
+
batch,
|
|
257
|
+
ThemeProvider,
|
|
258
|
+
Suspense,
|
|
259
|
+
ErrorBoundary,
|
|
260
|
+
DisposalScopeError
|
|
261
|
+
};
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
/** Color tokens: a map of color names to their raw/contextual values. */
|
|
2
|
+
type ColorTokens = Record<string, Record<string, string>>;
|
|
3
|
+
/** Spacing tokens: a flat map of names to CSS values. */
|
|
4
|
+
type SpacingTokens = Record<string, string>;
|
|
5
|
+
/** The structured theme object returned by defineTheme(). */
|
|
6
|
+
interface Theme {
|
|
7
|
+
/** Color design tokens. */
|
|
8
|
+
colors: ColorTokens;
|
|
9
|
+
/** Spacing scale tokens. */
|
|
10
|
+
spacing?: SpacingTokens;
|
|
11
|
+
}
|
|
12
|
+
/** Output of compileTheme(). */
|
|
13
|
+
interface CompiledTheme {
|
|
14
|
+
/** The generated CSS string with :root and [data-theme] blocks. */
|
|
15
|
+
css: string;
|
|
16
|
+
/** Flat list of token dot-paths (e.g., 'primary.500', 'background'). */
|
|
17
|
+
tokens: string[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compile a theme into CSS custom properties.
|
|
21
|
+
*
|
|
22
|
+
* Generates:
|
|
23
|
+
* - `:root { ... }` block with default/raw token values
|
|
24
|
+
* - `[data-theme="dark"] { ... }` block with dark overrides (if any)
|
|
25
|
+
*
|
|
26
|
+
* @param theme - A theme object from defineTheme().
|
|
27
|
+
* @returns Compiled CSS and token list.
|
|
28
|
+
*/
|
|
29
|
+
declare function compileTheme(theme: Theme): CompiledTheme;
|
|
30
|
+
/**
|
|
31
|
+
* Shared CSS token lookup tables.
|
|
32
|
+
*
|
|
33
|
+
* This is the single source of truth for all CSS token resolution data.
|
|
34
|
+
* These tables are consumed by:
|
|
35
|
+
* 1. packages/ui/src/css/token-resolver.ts (runtime)
|
|
36
|
+
* 2. packages/ui-compiler/src/transformers/css-transformer.ts (compiler)
|
|
37
|
+
* 3. packages/ui-compiler/src/css-extraction/extractor.ts (extraction)
|
|
38
|
+
*
|
|
39
|
+
* DO NOT duplicate these tables elsewhere. If you need a new token,
|
|
40
|
+
* add it here and all consumers will pick it up automatically.
|
|
41
|
+
*/
|
|
42
|
+
interface PropertyMapping {
|
|
43
|
+
/** CSS property name(s). If multiple, all get the same value. */
|
|
44
|
+
properties: string[];
|
|
45
|
+
/** Value resolver type. */
|
|
46
|
+
valueType: "spacing" | "color" | "radius" | "shadow" | "size" | "display" | "alignment" | "font-size" | "font-weight" | "line-height" | "ring" | "content" | "raw";
|
|
47
|
+
}
|
|
48
|
+
declare const PROPERTY_MAP: Record<string, PropertyMapping>;
|
|
49
|
+
/** A single CSS property-value pair. */
|
|
50
|
+
interface CSSDeclarationEntry {
|
|
51
|
+
property: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}
|
|
54
|
+
/** Keyword map -- single keywords that resolve to one or more declarations. */
|
|
55
|
+
declare const KEYWORD_MAP: Record<string, CSSDeclarationEntry[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Display-only keyword map. Used by the compiler for quick display keyword
|
|
58
|
+
* lookup without processing the full KEYWORD_MAP.
|
|
59
|
+
*/
|
|
60
|
+
declare const DISPLAY_MAP: Record<string, string>;
|
|
61
|
+
/** Spacing scale: number -> rem. 1=0.25rem, 2=0.5rem, 4=1rem, 8=2rem, etc. */
|
|
62
|
+
declare const SPACING_SCALE: Record<string, string>;
|
|
63
|
+
/** Border radius scale. */
|
|
64
|
+
declare const RADIUS_SCALE: Record<string, string>;
|
|
65
|
+
/** Shadow scale. */
|
|
66
|
+
declare const SHADOW_SCALE: Record<string, string>;
|
|
67
|
+
/** Font size scale. */
|
|
68
|
+
declare const FONT_SIZE_SCALE: Record<string, string>;
|
|
69
|
+
/** Font weight scale. */
|
|
70
|
+
declare const FONT_WEIGHT_SCALE: Record<string, string>;
|
|
71
|
+
/** Line height scale. */
|
|
72
|
+
declare const LINE_HEIGHT_SCALE: Record<string, string>;
|
|
73
|
+
/** Alignment value map. */
|
|
74
|
+
declare const ALIGNMENT_MAP: Record<string, string>;
|
|
75
|
+
/** Size keywords for width/height. */
|
|
76
|
+
declare const SIZE_KEYWORDS: Record<string, string>;
|
|
77
|
+
/** Height-axis property shorthands that should use vh units. */
|
|
78
|
+
declare const HEIGHT_AXIS_PROPERTIES: ReadonlySet<string>;
|
|
79
|
+
/** Known color token namespaces -- values that resolve to CSS custom properties. */
|
|
80
|
+
declare const COLOR_NAMESPACES: ReadonlySet<string>;
|
|
81
|
+
/** CSS color keywords that pass through without token resolution. */
|
|
82
|
+
declare const CSS_COLOR_KEYWORDS: ReadonlySet<string>;
|
|
83
|
+
/** Content keywords. */
|
|
84
|
+
declare const CONTENT_MAP: Record<string, string>;
|
|
85
|
+
/** Supported pseudo-state prefixes. */
|
|
86
|
+
declare const PSEUDO_PREFIXES: ReadonlySet<string>;
|
|
87
|
+
/** Map pseudo shorthand names to CSS pseudo-selectors. */
|
|
88
|
+
declare const PSEUDO_MAP: Record<string, string>;
|
|
89
|
+
/**
|
|
90
|
+
* A reactive signal that holds a value and notifies subscribers on change.
|
|
91
|
+
*/
|
|
92
|
+
interface Signal<T> {
|
|
93
|
+
/** Get the current value and subscribe to changes (when inside a tracking context). */
|
|
94
|
+
get value(): T;
|
|
95
|
+
/** Set the current value and notify subscribers if changed. */
|
|
96
|
+
set value(newValue: T);
|
|
97
|
+
/** Read the current value without subscribing (no tracking). */
|
|
98
|
+
peek(): T;
|
|
99
|
+
/** Manually notify all subscribers (useful after mutating the value in place). */
|
|
100
|
+
notify(): void;
|
|
101
|
+
}
|
|
102
|
+
/** Dispose function returned by effect(). */
|
|
103
|
+
type DisposeFn = () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Create a reactive attribute binding.
|
|
106
|
+
* When the value returned by `fn` changes, the attribute is updated.
|
|
107
|
+
* If fn returns null or undefined, the attribute is removed.
|
|
108
|
+
*
|
|
109
|
+
* Compiler output target for reactive attribute expressions.
|
|
110
|
+
* Returns a dispose function to stop the reactive binding.
|
|
111
|
+
*/
|
|
112
|
+
declare function __attr(el: HTMLElement, name: string, fn: () => string | null | undefined): DisposeFn;
|
|
113
|
+
/**
|
|
114
|
+
* Reactive display toggle.
|
|
115
|
+
* When fn() returns false, the element is hidden (display: none).
|
|
116
|
+
* When fn() returns true, the element is shown (display restored).
|
|
117
|
+
*
|
|
118
|
+
* Compiler output target for v-show / conditional display directives.
|
|
119
|
+
* Returns a dispose function to stop the reactive binding.
|
|
120
|
+
*/
|
|
121
|
+
declare function __show(el: HTMLElement, fn: () => boolean): DisposeFn;
|
|
122
|
+
/**
|
|
123
|
+
* Reactive class binding.
|
|
124
|
+
* Each key in the classMap is a class name; the value function determines
|
|
125
|
+
* whether that class is present.
|
|
126
|
+
*
|
|
127
|
+
* Compiler output target for reactive class expressions.
|
|
128
|
+
* Returns a dispose function to stop all reactive bindings.
|
|
129
|
+
*/
|
|
130
|
+
declare function __classList(el: HTMLElement, classMap: Record<string, () => boolean>): DisposeFn;
|
|
131
|
+
/** A Node that also carries a dispose function for cleanup. */
|
|
132
|
+
interface DisposableNode extends Node {
|
|
133
|
+
dispose: DisposeFn;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Reactive conditional rendering.
|
|
137
|
+
* When condFn() is true, renders trueFn(); otherwise renders falseFn().
|
|
138
|
+
* Manages DOM insertion and cleanup automatically.
|
|
139
|
+
*
|
|
140
|
+
* Compiler output target for ternary expressions and if/else in JSX.
|
|
141
|
+
*
|
|
142
|
+
* Returns a Node (DocumentFragment) with a `dispose` property attached.
|
|
143
|
+
*/
|
|
144
|
+
declare function __conditional(condFn: () => boolean, trueFn: () => Node | null, falseFn: () => Node | null): DisposableNode;
|
|
145
|
+
/** A Text node that also carries a dispose function for cleanup. */
|
|
146
|
+
interface DisposableText extends Text {
|
|
147
|
+
dispose: DisposeFn;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Create a reactive text node whose content updates automatically
|
|
151
|
+
* when the reactive dependencies of `fn` change.
|
|
152
|
+
*
|
|
153
|
+
* This is a compiler output target — the compiler generates calls
|
|
154
|
+
* to __text when it encounters reactive text interpolation in JSX.
|
|
155
|
+
*
|
|
156
|
+
* Returns a Text node with a `dispose` property for cleanup.
|
|
157
|
+
*/
|
|
158
|
+
declare function __text(fn: () => string): DisposableText;
|
|
159
|
+
/**
|
|
160
|
+
* Create a reactive child node that updates when dependencies change.
|
|
161
|
+
* Unlike __text(), this handles both Node values (appended directly)
|
|
162
|
+
* and primitives (converted to text nodes).
|
|
163
|
+
*
|
|
164
|
+
* This prevents HTMLElements from being stringified to "[object HTMLElement]"
|
|
165
|
+
* when used as JSX expression children like {someElement}.
|
|
166
|
+
*
|
|
167
|
+
* Returns a wrapper element with `display: contents` and a `dispose` property.
|
|
168
|
+
*/
|
|
169
|
+
declare function __child(fn: () => Node | string | number | boolean | null | undefined): HTMLElement & {
|
|
170
|
+
dispose: DisposeFn;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Insert a static (non-reactive) child value into a parent node.
|
|
174
|
+
* This is used for static JSX expression children to avoid the performance
|
|
175
|
+
* overhead of effect() when reactivity isn't needed.
|
|
176
|
+
*
|
|
177
|
+
* Handles Node values (appended directly), primitives (converted to text),
|
|
178
|
+
* and nullish/boolean values (skipped).
|
|
179
|
+
*/
|
|
180
|
+
declare function __insert(parent: Node, value: Node | string | number | boolean | null | undefined): void;
|
|
181
|
+
/**
|
|
182
|
+
* Create a DOM element with optional static properties.
|
|
183
|
+
*
|
|
184
|
+
* This is a compiler output target — the compiler generates calls
|
|
185
|
+
* to __element for each JSX element.
|
|
186
|
+
*/
|
|
187
|
+
declare function __element(tag: string, props?: Record<string, string>): HTMLElement;
|
|
188
|
+
/**
|
|
189
|
+
* Bind an event handler to an element.
|
|
190
|
+
* Returns a cleanup function to remove the listener.
|
|
191
|
+
*
|
|
192
|
+
* Compiler output target for event bindings (onClick, onInput, etc.).
|
|
193
|
+
*/
|
|
194
|
+
declare function __on(el: HTMLElement, event: string, handler: EventListener): () => void;
|
|
195
|
+
/**
|
|
196
|
+
* Insert a node into a container before a reference node.
|
|
197
|
+
* If reference is null, appends to the end.
|
|
198
|
+
*/
|
|
199
|
+
declare function insertBefore(container: Node, node: Node, reference: Node | null): void;
|
|
200
|
+
/**
|
|
201
|
+
* Remove a node from its parent.
|
|
202
|
+
*/
|
|
203
|
+
declare function removeNode(node: Node): void;
|
|
204
|
+
/**
|
|
205
|
+
* Clear all children from a container.
|
|
206
|
+
*/
|
|
207
|
+
declare function clearChildren(container: Node): void;
|
|
208
|
+
/**
|
|
209
|
+
* Keyed list reconciliation.
|
|
210
|
+
* Efficiently updates a container's children when the items signal changes.
|
|
211
|
+
* Reuses existing DOM nodes based on key identity — no virtual DOM.
|
|
212
|
+
*
|
|
213
|
+
* Compiler output target for .map() / for-each expressions in JSX.
|
|
214
|
+
*
|
|
215
|
+
* @param container - The parent DOM element
|
|
216
|
+
* @param items - A signal or getter function containing the array of items.
|
|
217
|
+
* The compiler generates `() => signal.value` as a getter; the runtime
|
|
218
|
+
* also accepts a raw Signal for direct use in tests.
|
|
219
|
+
* @param keyFn - Extracts a unique key from each item
|
|
220
|
+
* @param renderFn - Creates a DOM node for an item (called once per key)
|
|
221
|
+
* @returns A dispose function to stop the reactive list reconciliation
|
|
222
|
+
*/
|
|
223
|
+
declare function __list<T>(container: HTMLElement, items: Signal<T[]> | (() => T[]), keyFn: (item: T) => string | number, renderFn: (item: T) => Node): DisposeFn;
|
|
224
|
+
/** A function returning a dynamic import of a component module. */
|
|
225
|
+
type ComponentLoader = () => Promise<{
|
|
226
|
+
default: ComponentFunction;
|
|
227
|
+
}>;
|
|
228
|
+
/** A component function that takes props and an element to mount into. */
|
|
229
|
+
type ComponentFunction = (props: Record<string, unknown>, el: Element) => void;
|
|
230
|
+
/** Maps component IDs to their dynamic import loaders. */
|
|
231
|
+
type ComponentRegistry = Record<string, ComponentLoader>;
|
|
232
|
+
/**
|
|
233
|
+
* Resolves a component ID to its module's default export.
|
|
234
|
+
*
|
|
235
|
+
* Throws if the component ID is not found in the registry.
|
|
236
|
+
*/
|
|
237
|
+
declare function resolveComponent(registry: ComponentRegistry, componentId: string): Promise<ComponentFunction>;
|
|
238
|
+
/**
|
|
239
|
+
* Reads serialized props from a `<script type="application/json">` tag
|
|
240
|
+
* within the hydration boundary element.
|
|
241
|
+
*/
|
|
242
|
+
declare function deserializeProps(container: Element): Record<string, unknown>;
|
|
243
|
+
/**
|
|
244
|
+
* Interface for cache stores used by query().
|
|
245
|
+
* Consumers can provide custom implementations (e.g. LRU, persistent storage).
|
|
246
|
+
*/
|
|
247
|
+
interface CacheStore<T = unknown> {
|
|
248
|
+
get(key: string): T | undefined;
|
|
249
|
+
set(key: string, value: T): void;
|
|
250
|
+
delete(key: string): void;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Default in-memory cache backed by a Map.
|
|
254
|
+
*/
|
|
255
|
+
declare class MemoryCache<T = unknown> implements CacheStore<T> {
|
|
256
|
+
private _store;
|
|
257
|
+
get(key: string): T | undefined;
|
|
258
|
+
set(key: string, value: T): void;
|
|
259
|
+
delete(key: string): void;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Derive a cache key from a thunk function.
|
|
263
|
+
*
|
|
264
|
+
* Uses the string representation of the function as a simple fingerprint.
|
|
265
|
+
* For deterministic keys in production, prefer passing an explicit `key` option.
|
|
266
|
+
*/
|
|
267
|
+
declare function deriveKey(thunk: () => unknown): string;
|
|
268
|
+
/**
|
|
269
|
+
* Template literal type utility that extracts route parameter names from a path pattern.
|
|
270
|
+
*
|
|
271
|
+
* Examples:
|
|
272
|
+
* - `'/users/:id'` -> `{ id: string }`
|
|
273
|
+
* - `'/users/:id/posts/:postId'` -> `{ id: string; postId: string }`
|
|
274
|
+
* - `'/files/*'` -> `{ '*': string }`
|
|
275
|
+
* - `'/users'` -> `Record<string, never>`
|
|
276
|
+
*/
|
|
277
|
+
/** Extract param names from a single segment. */
|
|
278
|
+
type ExtractSegmentParam<S extends string> = S extends `:${infer Param}` ? Param : never;
|
|
279
|
+
/** Recursively extract params from path segments separated by '/'. */
|
|
280
|
+
type ExtractParamsFromSegments<T extends string> = T extends `${infer Segment}/${infer Rest}` ? ExtractSegmentParam<Segment> | ExtractParamsFromSegments<Rest> : ExtractSegmentParam<T>;
|
|
281
|
+
/** Check if a path contains a wildcard '*' at the end. */
|
|
282
|
+
type HasWildcard<T extends string> = T extends `${string}*` ? true : false;
|
|
283
|
+
/** Remove trailing wildcard for param extraction. */
|
|
284
|
+
type WithoutWildcard<T extends string> = T extends `${infer Before}*` ? Before : T;
|
|
285
|
+
/**
|
|
286
|
+
* Extract typed params from a route path pattern.
|
|
287
|
+
* `:param` segments become `{ param: string }`.
|
|
288
|
+
* A trailing `*` becomes `{ '*': string }`.
|
|
289
|
+
*/
|
|
290
|
+
type ExtractParams<T extends string> = [ExtractParamsFromSegments<WithoutWildcard<T>>] extends [never] ? HasWildcard<T> extends true ? {
|
|
291
|
+
"*": string;
|
|
292
|
+
} : Record<string, never> : HasWildcard<T> extends true ? { [K in ExtractParamsFromSegments<WithoutWildcard<T>>] : string } & {
|
|
293
|
+
"*": string;
|
|
294
|
+
} : { [K in ExtractParamsFromSegments<WithoutWildcard<T>>] : string };
|
|
295
|
+
/** Simple schema interface for search param parsing. */
|
|
296
|
+
interface SearchParamSchema<T> {
|
|
297
|
+
parse(data: unknown): T;
|
|
298
|
+
}
|
|
299
|
+
/** A route configuration for a single path. */
|
|
300
|
+
interface RouteConfig<
|
|
301
|
+
TPath extends string = string,
|
|
302
|
+
TLoaderData = unknown,
|
|
303
|
+
TSearch = unknown
|
|
304
|
+
> {
|
|
305
|
+
/** Component factory (lazy for code splitting). */
|
|
306
|
+
component: () => Node | Promise<{
|
|
307
|
+
default: () => Node;
|
|
308
|
+
}>;
|
|
309
|
+
/** Optional loader that runs before render. */
|
|
310
|
+
loader?: (ctx: {
|
|
311
|
+
params: ExtractParams<TPath>;
|
|
312
|
+
signal: AbortSignal;
|
|
313
|
+
}) => Promise<TLoaderData> | TLoaderData;
|
|
314
|
+
/** Optional error component rendered when loader throws. */
|
|
315
|
+
errorComponent?: (error: Error) => Node;
|
|
316
|
+
/** Optional search params schema for validation/coercion. */
|
|
317
|
+
searchParams?: SearchParamSchema<TSearch>;
|
|
318
|
+
/** Nested child routes. */
|
|
319
|
+
children?: RouteDefinitionMap;
|
|
320
|
+
}
|
|
321
|
+
/** A map of path patterns to route configs (user input format). */
|
|
322
|
+
interface RouteDefinitionMap {
|
|
323
|
+
[pattern: string]: RouteConfig;
|
|
324
|
+
}
|
|
325
|
+
/** Internal compiled route. */
|
|
326
|
+
interface CompiledRoute {
|
|
327
|
+
/** The original path pattern. */
|
|
328
|
+
pattern: string;
|
|
329
|
+
/** The route config. */
|
|
330
|
+
component: RouteConfig["component"];
|
|
331
|
+
loader?: (ctx: {
|
|
332
|
+
params: Record<string, string>;
|
|
333
|
+
signal: AbortSignal;
|
|
334
|
+
}) => Promise<unknown> | unknown;
|
|
335
|
+
errorComponent?: RouteConfig["errorComponent"];
|
|
336
|
+
searchParams?: RouteConfig["searchParams"];
|
|
337
|
+
/** Compiled children. */
|
|
338
|
+
children?: CompiledRoute[];
|
|
339
|
+
}
|
|
340
|
+
/** A single matched route entry in the matched chain. */
|
|
341
|
+
interface MatchedRoute {
|
|
342
|
+
route: CompiledRoute;
|
|
343
|
+
params: Record<string, string>;
|
|
344
|
+
}
|
|
345
|
+
/** Result of matching a URL against the route tree. */
|
|
346
|
+
interface RouteMatch {
|
|
347
|
+
/** All params extracted from the full URL path. */
|
|
348
|
+
params: Record<string, string>;
|
|
349
|
+
/** The leaf route config that matched. */
|
|
350
|
+
route: CompiledRoute;
|
|
351
|
+
/** The chain of matched routes from root to leaf (for nested layouts). */
|
|
352
|
+
matched: MatchedRoute[];
|
|
353
|
+
/** URLSearchParams from the URL. */
|
|
354
|
+
searchParams: URLSearchParams;
|
|
355
|
+
/** Parsed/coerced search params if schema is defined. */
|
|
356
|
+
search: Record<string, unknown>;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Match a URL path against a list of compiled routes.
|
|
360
|
+
* Supports nested route matching for layouts.
|
|
361
|
+
*
|
|
362
|
+
* @param routes - Compiled route list
|
|
363
|
+
* @param url - URL path (may include query string)
|
|
364
|
+
* @returns RouteMatch or null if no route matches
|
|
365
|
+
*/
|
|
366
|
+
declare function matchRoute(routes: CompiledRoute[], url: string): RouteMatch | null;
|
|
367
|
+
/**
|
|
368
|
+
* Execute all loaders for matched routes in parallel.
|
|
369
|
+
*
|
|
370
|
+
* Each loader receives `{ params, signal }` with the full merged params
|
|
371
|
+
* from all matched routes and an AbortSignal for cancellation.
|
|
372
|
+
* Routes without loaders produce `undefined` in the results array.
|
|
373
|
+
*
|
|
374
|
+
* @param matched - The chain of matched routes (parent to leaf)
|
|
375
|
+
* @param params - Merged params from all matched routes
|
|
376
|
+
* @param signal - AbortSignal to pass to loaders for cancellation
|
|
377
|
+
* @returns Array of loader results (one per matched route)
|
|
378
|
+
*/
|
|
379
|
+
declare function executeLoaders(matched: MatchedRoute[], params: Record<string, string>, signal?: AbortSignal): Promise<unknown[]>;
|
|
380
|
+
/**
|
|
381
|
+
* Route path matching with `:param` and `*` wildcard support.
|
|
382
|
+
*/
|
|
383
|
+
/** Result of a successful route match. */
|
|
384
|
+
interface MatchResult {
|
|
385
|
+
/** Extracted parameters from the path. */
|
|
386
|
+
params: Record<string, string>;
|
|
387
|
+
/** The matched portion of the URL path. */
|
|
388
|
+
path: string;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Match a URL path against a route pattern.
|
|
392
|
+
*
|
|
393
|
+
* - Static segments must match exactly.
|
|
394
|
+
* - `:param` segments capture a single non-empty path segment.
|
|
395
|
+
* - `*` at the end captures all remaining segments (including empty).
|
|
396
|
+
*
|
|
397
|
+
* Returns a MatchResult on success, or null if the path does not match.
|
|
398
|
+
*/
|
|
399
|
+
declare function matchPath(pattern: string, path: string): MatchResult | null;
|
|
400
|
+
/**
|
|
401
|
+
* Push a new cleanup scope. All onCleanup calls within this scope
|
|
402
|
+
* will be collected and returned when the scope is popped.
|
|
403
|
+
*/
|
|
404
|
+
declare function pushScope(): DisposeFn[];
|
|
405
|
+
/**
|
|
406
|
+
* Pop the current cleanup scope.
|
|
407
|
+
*/
|
|
408
|
+
declare function popScope(): void;
|
|
409
|
+
/**
|
|
410
|
+
* Run all collected cleanup functions in LIFO (reverse) order and clear the list.
|
|
411
|
+
* Reverse order matches try/finally semantics — last registered, first cleaned up.
|
|
412
|
+
*/
|
|
413
|
+
declare function runCleanups(cleanups: DisposeFn[]): void;
|
|
414
|
+
export { runCleanups, resolveComponent, removeNode, pushScope, popScope, matchRoute, matchPath, insertBefore, executeLoaders, deserializeProps, deriveKey, compileTheme, clearChildren, __text, __show, __on, __list, __insert, __element, __conditional, __classList, __child, __attr, SPACING_SCALE, SIZE_KEYWORDS, SHADOW_SCALE, RADIUS_SCALE, PropertyMapping, PSEUDO_PREFIXES, PSEUDO_MAP, PROPERTY_MAP, MemoryCache, MatchResult, LINE_HEIGHT_SCALE, KEYWORD_MAP, HEIGHT_AXIS_PROPERTIES, FONT_WEIGHT_SCALE, FONT_SIZE_SCALE, DISPLAY_MAP, CSS_COLOR_KEYWORDS, CSSDeclarationEntry, CONTENT_MAP, COLOR_NAMESPACES, ALIGNMENT_MAP };
|