@fictjs/runtime 0.0.2
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 +17 -0
- package/dist/index.cjs +4224 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1572 -0
- package/dist/index.d.ts +1572 -0
- package/dist/index.dev.js +4240 -0
- package/dist/index.dev.js.map +1 -0
- package/dist/index.js +4133 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs +44 -0
- package/dist/jsx-dev-runtime.cjs.map +1 -0
- package/dist/jsx-dev-runtime.js +14 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.cjs +44 -0
- package/dist/jsx-runtime.cjs.map +1 -0
- package/dist/jsx-runtime.js +14 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/slim.cjs +3384 -0
- package/dist/slim.cjs.map +1 -0
- package/dist/slim.d.cts +475 -0
- package/dist/slim.d.ts +475 -0
- package/dist/slim.js +3335 -0
- package/dist/slim.js.map +1 -0
- package/package.json +68 -0
- package/src/binding.ts +2127 -0
- package/src/constants.ts +456 -0
- package/src/cycle-guard.ts +134 -0
- package/src/devtools.ts +17 -0
- package/src/dom.ts +683 -0
- package/src/effect.ts +83 -0
- package/src/error-boundary.ts +118 -0
- package/src/hooks.ts +72 -0
- package/src/index.ts +184 -0
- package/src/jsx-dev-runtime.ts +2 -0
- package/src/jsx-runtime.ts +2 -0
- package/src/jsx.ts +786 -0
- package/src/lifecycle.ts +273 -0
- package/src/list-helpers.ts +619 -0
- package/src/memo.ts +14 -0
- package/src/node-ops.ts +185 -0
- package/src/props.ts +212 -0
- package/src/reconcile.ts +151 -0
- package/src/ref.ts +25 -0
- package/src/scheduler.ts +12 -0
- package/src/signal.ts +1278 -0
- package/src/slim.ts +68 -0
- package/src/store.ts +210 -0
- package/src/suspense.ts +187 -0
- package/src/transition.ts +128 -0
- package/src/types.ts +172 -0
- package/src/versioned-signal.ts +58 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1572 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signal accessor - function to get/set signal value
|
|
3
|
+
*/
|
|
4
|
+
interface SignalAccessor<T> {
|
|
5
|
+
(): T;
|
|
6
|
+
(value: T): void;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Computed accessor - function to get computed value
|
|
10
|
+
*/
|
|
11
|
+
type ComputedAccessor<T> = () => T;
|
|
12
|
+
/**
|
|
13
|
+
* Create a reactive signal
|
|
14
|
+
* @param initialValue - The initial value
|
|
15
|
+
* @returns A signal accessor function
|
|
16
|
+
*/
|
|
17
|
+
declare function signal<T>(initialValue: T): SignalAccessor<T>;
|
|
18
|
+
declare const $state: <T>(value: T) => T;
|
|
19
|
+
/**
|
|
20
|
+
* Create a selector signal that efficiently updates only when the selected key matches.
|
|
21
|
+
* Useful for large lists where only one item is selected.
|
|
22
|
+
*
|
|
23
|
+
* @param source - The source signal returning the current key
|
|
24
|
+
* @param equalityFn - Optional equality function
|
|
25
|
+
* @returns A selector function that takes a key and returns a boolean signal accessor
|
|
26
|
+
*/
|
|
27
|
+
declare function createSelector<T>(source: () => T, equalityFn?: (a: T, b: T) => boolean): (key: T) => boolean;
|
|
28
|
+
|
|
29
|
+
type Store<T> = T;
|
|
30
|
+
/**
|
|
31
|
+
* Create a Store: a reactive proxy that allows fine-grained access and mutation.
|
|
32
|
+
*
|
|
33
|
+
* @param initialValue - The initial state object
|
|
34
|
+
* @returns [store, setStore]
|
|
35
|
+
*/
|
|
36
|
+
declare function createStore<T extends object>(initialValue: T): [Store<T>, (fn: (state: T) => void | T) => void];
|
|
37
|
+
|
|
38
|
+
type Memo<T> = () => T;
|
|
39
|
+
declare function createMemo<T>(fn: () => T): Memo<T>;
|
|
40
|
+
declare const $memo: typeof createMemo;
|
|
41
|
+
|
|
42
|
+
/** Any DOM node that can be rendered */
|
|
43
|
+
type DOMElement = Node;
|
|
44
|
+
/** Cleanup function type */
|
|
45
|
+
type Cleanup = () => void;
|
|
46
|
+
/** Fict Virtual Node - represents a component or element in the virtual tree */
|
|
47
|
+
interface FictVNode {
|
|
48
|
+
/** Element type: tag name, Fragment symbol, or component function */
|
|
49
|
+
type: string | symbol | ((props: Record<string, unknown>) => FictNode);
|
|
50
|
+
/** Props passed to the element/component */
|
|
51
|
+
props: Record<string, unknown> | null;
|
|
52
|
+
/** Optional key for list rendering optimization */
|
|
53
|
+
key?: string | undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Fict Node - represents any renderable value
|
|
57
|
+
* This type covers all possible values that can appear in JSX
|
|
58
|
+
*/
|
|
59
|
+
type FictNode = FictVNode | FictNode[] | Node | string | number | boolean | null | undefined;
|
|
60
|
+
/** Props that all components receive */
|
|
61
|
+
interface BaseProps {
|
|
62
|
+
/** Optional key for list rendering */
|
|
63
|
+
key?: string | number;
|
|
64
|
+
/** Optional children */
|
|
65
|
+
children?: FictNode | FictNode[];
|
|
66
|
+
}
|
|
67
|
+
/** A Fict component function */
|
|
68
|
+
type Component<P extends Record<string, unknown> = Record<string, unknown>> = (props: P & BaseProps) => FictNode;
|
|
69
|
+
/** Props with children */
|
|
70
|
+
type PropsWithChildren<P = unknown> = P & {
|
|
71
|
+
children?: FictNode | FictNode[];
|
|
72
|
+
};
|
|
73
|
+
interface ErrorInfo {
|
|
74
|
+
source: 'render' | 'effect' | 'event' | 'renderChild' | 'cleanup';
|
|
75
|
+
componentName?: string;
|
|
76
|
+
eventName?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Event handler type for type-safe event handling */
|
|
79
|
+
type EventHandler<E extends Event = Event> = (event: E) => void;
|
|
80
|
+
/** Ref callback type */
|
|
81
|
+
type RefCallback<T extends HTMLElement = HTMLElement> = (element: T) => void;
|
|
82
|
+
/** Ref object type (for future use with createRef) */
|
|
83
|
+
interface RefObject<T extends HTMLElement = HTMLElement> {
|
|
84
|
+
current: T | null;
|
|
85
|
+
}
|
|
86
|
+
/** Ref type that can be either callback or object */
|
|
87
|
+
type Ref<T extends HTMLElement = HTMLElement> = RefCallback<T> | RefObject<T>;
|
|
88
|
+
/** CSS style value - can be string or number (number becomes px) */
|
|
89
|
+
type StyleValue = string | number;
|
|
90
|
+
/** CSS style object */
|
|
91
|
+
type CSSStyleObject = {
|
|
92
|
+
[K in keyof CSSStyleDeclaration]?: StyleValue;
|
|
93
|
+
} & Record<string, StyleValue>;
|
|
94
|
+
/** Style prop type - can be string or object */
|
|
95
|
+
type StyleProp = string | CSSStyleObject | null | undefined;
|
|
96
|
+
/** Class object for conditional classes */
|
|
97
|
+
type ClassObject = Record<string, boolean | undefined | null>;
|
|
98
|
+
/** Class prop type - can be string or object */
|
|
99
|
+
type ClassProp = string | ClassObject | null | undefined;
|
|
100
|
+
interface SuspenseToken {
|
|
101
|
+
then: Promise<unknown>['then'];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
type Effect = () => void | Cleanup;
|
|
105
|
+
declare function createEffect(fn: Effect): () => void;
|
|
106
|
+
declare const $effect: typeof createEffect;
|
|
107
|
+
declare function createRenderEffect(fn: Effect): () => void;
|
|
108
|
+
|
|
109
|
+
interface HookContext {
|
|
110
|
+
slots: unknown[];
|
|
111
|
+
cursor: number;
|
|
112
|
+
}
|
|
113
|
+
declare function __fictUseContext(): HookContext;
|
|
114
|
+
declare function __fictPushContext(): HookContext;
|
|
115
|
+
declare function __fictPopContext(): void;
|
|
116
|
+
declare function __fictResetContext(): void;
|
|
117
|
+
declare function __fictUseSignal<T>(ctx: HookContext, initial: T, slot?: number): SignalAccessor<T>;
|
|
118
|
+
declare function __fictUseMemo<T>(ctx: HookContext, fn: () => T, slot?: number): ComputedAccessor<T>;
|
|
119
|
+
declare function __fictUseEffect(ctx: HookContext, fn: () => void, slot?: number): void;
|
|
120
|
+
declare function __fictRender<T>(ctx: HookContext, fn: () => T): T;
|
|
121
|
+
|
|
122
|
+
interface VersionedSignalOptions<T> {
|
|
123
|
+
equals?: (prev: T, next: T) => boolean;
|
|
124
|
+
}
|
|
125
|
+
interface VersionedSignal<T> {
|
|
126
|
+
/** Reactive read that tracks both the value and version counter */
|
|
127
|
+
read: () => T;
|
|
128
|
+
/** Write a new value, forcing a version bump when value is equal */
|
|
129
|
+
write: (next: T) => void;
|
|
130
|
+
/** Force a version bump without changing the value */
|
|
131
|
+
force: () => void;
|
|
132
|
+
/** Read the current version without creating a dependency */
|
|
133
|
+
peekVersion: () => number;
|
|
134
|
+
/** Read the current value without tracking */
|
|
135
|
+
peekValue: () => T;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Create a signal wrapper that forces subscribers to update when the same reference is written.
|
|
139
|
+
*
|
|
140
|
+
* Useful for compiler-generated keyed list items where updates may reuse the same object reference.
|
|
141
|
+
*/
|
|
142
|
+
declare function createVersionedSignal<T>(initialValue: T, options?: VersionedSignalOptions<T>): VersionedSignal<T>;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
* Marks a zero-arg getter so props proxy can lazily evaluate it.
|
|
147
|
+
* Users normally never call this directly; the compiler injects it.
|
|
148
|
+
*/
|
|
149
|
+
declare function __fictProp<T>(getter: () => T): () => T;
|
|
150
|
+
declare function createPropsProxy<T extends Record<string, unknown>>(props: T): T;
|
|
151
|
+
/**
|
|
152
|
+
* Create a rest-like props object while preserving prop getters.
|
|
153
|
+
* Excludes the specified keys from the returned object.
|
|
154
|
+
*/
|
|
155
|
+
declare function __fictPropsRest<T extends Record<string, unknown>>(props: T, exclude: (string | number | symbol)[]): Record<string, unknown>;
|
|
156
|
+
/**
|
|
157
|
+
* Merge multiple props-like objects while preserving lazy getters.
|
|
158
|
+
* Later sources override earlier ones.
|
|
159
|
+
*
|
|
160
|
+
* Uses lazy lookup strategy - properties are only accessed when read,
|
|
161
|
+
* avoiding upfront iteration of all keys.
|
|
162
|
+
*/
|
|
163
|
+
type MergeSource<T extends Record<string, unknown>> = T | (() => T);
|
|
164
|
+
declare function mergeProps<T extends Record<string, unknown>>(...sources: (MergeSource<T> | null | undefined)[]): Record<string, unknown>;
|
|
165
|
+
type PropGetter<T> = (() => T) & {
|
|
166
|
+
__fictProp: true;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Memoize a prop getter to cache expensive computations.
|
|
170
|
+
* Use when prop expressions involve heavy calculations.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```tsx
|
|
174
|
+
* // Without useProp - recomputes on every access
|
|
175
|
+
* <Child data={expensiveComputation(list, filter)} />
|
|
176
|
+
*
|
|
177
|
+
* // With useProp - cached until dependencies change, auto-unwrapped by props proxy
|
|
178
|
+
* const memoizedData = useProp(() => expensiveComputation(list, filter))
|
|
179
|
+
* <Child data={memoizedData} />
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
declare function useProp<T>(getter: () => T): PropGetter<T>;
|
|
183
|
+
|
|
184
|
+
type LifecycleFn = () => void | Cleanup;
|
|
185
|
+
interface RootContext {
|
|
186
|
+
parent?: RootContext | undefined;
|
|
187
|
+
onMountCallbacks?: LifecycleFn[];
|
|
188
|
+
cleanups: Cleanup[];
|
|
189
|
+
destroyCallbacks: Cleanup[];
|
|
190
|
+
errorHandlers?: ErrorHandler[];
|
|
191
|
+
suspenseHandlers?: SuspenseHandler[];
|
|
192
|
+
}
|
|
193
|
+
type ErrorHandler = (err: unknown, info?: ErrorInfo) => boolean | void;
|
|
194
|
+
type SuspenseHandler = (token: SuspenseToken | PromiseLike<unknown>) => boolean | void;
|
|
195
|
+
declare function onMount(fn: LifecycleFn): void;
|
|
196
|
+
declare function onDestroy(fn: LifecycleFn): void;
|
|
197
|
+
declare function onCleanup(fn: Cleanup): void;
|
|
198
|
+
declare function createRoot<T>(fn: () => T): {
|
|
199
|
+
dispose: () => void;
|
|
200
|
+
value: T;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Create a ref object for DOM element references.
|
|
205
|
+
*
|
|
206
|
+
* @returns A ref object with a `current` property initialized to `null`
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```tsx
|
|
210
|
+
* import { createRef } from 'fict'
|
|
211
|
+
*
|
|
212
|
+
* function Component() {
|
|
213
|
+
* const inputRef = createRef<HTMLInputElement>()
|
|
214
|
+
*
|
|
215
|
+
* $effect(() => {
|
|
216
|
+
* inputRef.current?.focus()
|
|
217
|
+
* })
|
|
218
|
+
*
|
|
219
|
+
* return <input ref={inputRef} />
|
|
220
|
+
* }
|
|
221
|
+
* ```
|
|
222
|
+
*/
|
|
223
|
+
declare function createRef<T extends HTMLElement = HTMLElement>(): RefObject<T>;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Execute a function with low-priority scheduling.
|
|
227
|
+
* Updates triggered inside the callback will be processed after any high-priority updates.
|
|
228
|
+
* This keeps the UI responsive during expensive operations.
|
|
229
|
+
*
|
|
230
|
+
* @param fn - The function to execute in transition context
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```tsx
|
|
234
|
+
* const handleInput = (e) => {
|
|
235
|
+
* query = e.target.value // High priority: immediate
|
|
236
|
+
* startTransition(() => {
|
|
237
|
+
* // Low priority: processed after high priority updates
|
|
238
|
+
* filteredItems = allItems.filter(x => x.includes(query))
|
|
239
|
+
* })
|
|
240
|
+
* }
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
declare function startTransition(fn: () => void): void;
|
|
244
|
+
/**
|
|
245
|
+
* React-style useTransition hook.
|
|
246
|
+
* Returns a pending signal and a startTransition function.
|
|
247
|
+
*
|
|
248
|
+
* @returns A tuple of [isPending accessor, startTransition function]
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```tsx
|
|
252
|
+
* function SearchComponent() {
|
|
253
|
+
* let query = $state('')
|
|
254
|
+
* const [isPending, start] = useTransition()
|
|
255
|
+
*
|
|
256
|
+
* const handleChange = (e) => {
|
|
257
|
+
* query = e.target.value
|
|
258
|
+
* start(() => {
|
|
259
|
+
* // Expensive filtering happens in low priority
|
|
260
|
+
* filteredResults = expensiveFilter(allData, query)
|
|
261
|
+
* })
|
|
262
|
+
* }
|
|
263
|
+
*
|
|
264
|
+
* return (
|
|
265
|
+
* <>
|
|
266
|
+
* <input value={query} onInput={handleChange} />
|
|
267
|
+
* {isPending() && <Spinner />}
|
|
268
|
+
* <Results items={filteredResults} />
|
|
269
|
+
* </>
|
|
270
|
+
* )
|
|
271
|
+
* }
|
|
272
|
+
* ```
|
|
273
|
+
*/
|
|
274
|
+
declare function useTransition(): [() => boolean, (fn: () => void) => void];
|
|
275
|
+
/**
|
|
276
|
+
* Creates a deferred version of a value that updates with low priority.
|
|
277
|
+
* The returned accessor will lag behind the source value during rapid updates,
|
|
278
|
+
* allowing high-priority work to complete first.
|
|
279
|
+
*
|
|
280
|
+
* @param getValue - Accessor function that returns the source value
|
|
281
|
+
* @returns Accessor function that returns the deferred value
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* ```tsx
|
|
285
|
+
* function SearchResults({ query }) {
|
|
286
|
+
* const deferredQuery = useDeferredValue(() => query)
|
|
287
|
+
*
|
|
288
|
+
* // deferredQuery lags behind query during rapid typing
|
|
289
|
+
* const results = expensiveSearch(deferredQuery())
|
|
290
|
+
*
|
|
291
|
+
* return <ResultList items={results} />
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
declare function useDeferredValue<T>(getValue: () => T): () => T;
|
|
296
|
+
|
|
297
|
+
declare function batch<T>(fn: () => T): T;
|
|
298
|
+
declare function untrack<T>(fn: () => T): T;
|
|
299
|
+
|
|
300
|
+
interface CycleProtectionOptions {
|
|
301
|
+
maxFlushCyclesPerMicrotask?: number;
|
|
302
|
+
maxEffectRunsPerFlush?: number;
|
|
303
|
+
windowSize?: number;
|
|
304
|
+
highUsageRatio?: number;
|
|
305
|
+
maxRootReentrantDepth?: number;
|
|
306
|
+
enableWindowWarning?: boolean;
|
|
307
|
+
devMode?: boolean;
|
|
308
|
+
}
|
|
309
|
+
declare function setCycleProtectionOptions(opts: CycleProtectionOptions): void;
|
|
310
|
+
|
|
311
|
+
declare const Fragment: unique symbol;
|
|
312
|
+
declare namespace JSX {
|
|
313
|
+
type Element = FictNode;
|
|
314
|
+
interface IntrinsicElements {
|
|
315
|
+
html: HTMLAttributes<HTMLHtmlElement>;
|
|
316
|
+
head: HTMLAttributes<HTMLHeadElement>;
|
|
317
|
+
body: HTMLAttributes<HTMLBodyElement>;
|
|
318
|
+
title: HTMLAttributes<HTMLTitleElement>;
|
|
319
|
+
meta: MetaHTMLAttributes<HTMLMetaElement>;
|
|
320
|
+
link: LinkHTMLAttributes<HTMLLinkElement>;
|
|
321
|
+
style: StyleHTMLAttributes<HTMLStyleElement>;
|
|
322
|
+
script: ScriptHTMLAttributes<HTMLScriptElement>;
|
|
323
|
+
noscript: HTMLAttributes<HTMLElement>;
|
|
324
|
+
div: HTMLAttributes<HTMLDivElement>;
|
|
325
|
+
span: HTMLAttributes<HTMLSpanElement>;
|
|
326
|
+
main: HTMLAttributes<HTMLElement>;
|
|
327
|
+
header: HTMLAttributes<HTMLElement>;
|
|
328
|
+
footer: HTMLAttributes<HTMLElement>;
|
|
329
|
+
section: HTMLAttributes<HTMLElement>;
|
|
330
|
+
article: HTMLAttributes<HTMLElement>;
|
|
331
|
+
aside: HTMLAttributes<HTMLElement>;
|
|
332
|
+
nav: HTMLAttributes<HTMLElement>;
|
|
333
|
+
address: HTMLAttributes<HTMLElement>;
|
|
334
|
+
h1: HTMLAttributes<HTMLHeadingElement>;
|
|
335
|
+
h2: HTMLAttributes<HTMLHeadingElement>;
|
|
336
|
+
h3: HTMLAttributes<HTMLHeadingElement>;
|
|
337
|
+
h4: HTMLAttributes<HTMLHeadingElement>;
|
|
338
|
+
h5: HTMLAttributes<HTMLHeadingElement>;
|
|
339
|
+
h6: HTMLAttributes<HTMLHeadingElement>;
|
|
340
|
+
hgroup: HTMLAttributes<HTMLElement>;
|
|
341
|
+
p: HTMLAttributes<HTMLParagraphElement>;
|
|
342
|
+
blockquote: BlockquoteHTMLAttributes<HTMLQuoteElement>;
|
|
343
|
+
pre: HTMLAttributes<HTMLPreElement>;
|
|
344
|
+
figure: HTMLAttributes<HTMLElement>;
|
|
345
|
+
figcaption: HTMLAttributes<HTMLElement>;
|
|
346
|
+
hr: HTMLAttributes<HTMLHRElement>;
|
|
347
|
+
br: HTMLAttributes<HTMLBRElement>;
|
|
348
|
+
wbr: HTMLAttributes<HTMLElement>;
|
|
349
|
+
a: AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
350
|
+
abbr: HTMLAttributes<HTMLElement>;
|
|
351
|
+
b: HTMLAttributes<HTMLElement>;
|
|
352
|
+
bdi: HTMLAttributes<HTMLElement>;
|
|
353
|
+
bdo: HTMLAttributes<HTMLElement>;
|
|
354
|
+
cite: HTMLAttributes<HTMLElement>;
|
|
355
|
+
code: HTMLAttributes<HTMLElement>;
|
|
356
|
+
data: DataHTMLAttributes<HTMLDataElement>;
|
|
357
|
+
dfn: HTMLAttributes<HTMLElement>;
|
|
358
|
+
em: HTMLAttributes<HTMLElement>;
|
|
359
|
+
i: HTMLAttributes<HTMLElement>;
|
|
360
|
+
kbd: HTMLAttributes<HTMLElement>;
|
|
361
|
+
mark: HTMLAttributes<HTMLElement>;
|
|
362
|
+
q: QuoteHTMLAttributes<HTMLQuoteElement>;
|
|
363
|
+
rp: HTMLAttributes<HTMLElement>;
|
|
364
|
+
rt: HTMLAttributes<HTMLElement>;
|
|
365
|
+
ruby: HTMLAttributes<HTMLElement>;
|
|
366
|
+
s: HTMLAttributes<HTMLElement>;
|
|
367
|
+
samp: HTMLAttributes<HTMLElement>;
|
|
368
|
+
small: HTMLAttributes<HTMLElement>;
|
|
369
|
+
strong: HTMLAttributes<HTMLElement>;
|
|
370
|
+
sub: HTMLAttributes<HTMLElement>;
|
|
371
|
+
sup: HTMLAttributes<HTMLElement>;
|
|
372
|
+
time: TimeHTMLAttributes<HTMLTimeElement>;
|
|
373
|
+
u: HTMLAttributes<HTMLElement>;
|
|
374
|
+
var: HTMLAttributes<HTMLElement>;
|
|
375
|
+
ul: HTMLAttributes<HTMLUListElement>;
|
|
376
|
+
ol: OlHTMLAttributes<HTMLOListElement>;
|
|
377
|
+
li: LiHTMLAttributes<HTMLLIElement>;
|
|
378
|
+
dl: HTMLAttributes<HTMLDListElement>;
|
|
379
|
+
dt: HTMLAttributes<HTMLElement>;
|
|
380
|
+
dd: HTMLAttributes<HTMLElement>;
|
|
381
|
+
menu: HTMLAttributes<HTMLMenuElement>;
|
|
382
|
+
table: TableHTMLAttributes<HTMLTableElement>;
|
|
383
|
+
caption: HTMLAttributes<HTMLTableCaptionElement>;
|
|
384
|
+
colgroup: ColgroupHTMLAttributes<HTMLTableColElement>;
|
|
385
|
+
col: ColHTMLAttributes<HTMLTableColElement>;
|
|
386
|
+
thead: HTMLAttributes<HTMLTableSectionElement>;
|
|
387
|
+
tbody: HTMLAttributes<HTMLTableSectionElement>;
|
|
388
|
+
tfoot: HTMLAttributes<HTMLTableSectionElement>;
|
|
389
|
+
tr: HTMLAttributes<HTMLTableRowElement>;
|
|
390
|
+
th: ThHTMLAttributes<HTMLTableCellElement>;
|
|
391
|
+
td: TdHTMLAttributes<HTMLTableCellElement>;
|
|
392
|
+
form: FormHTMLAttributes<HTMLFormElement>;
|
|
393
|
+
fieldset: FieldsetHTMLAttributes<HTMLFieldSetElement>;
|
|
394
|
+
legend: HTMLAttributes<HTMLLegendElement>;
|
|
395
|
+
label: LabelHTMLAttributes<HTMLLabelElement>;
|
|
396
|
+
input: InputHTMLAttributes<HTMLInputElement>;
|
|
397
|
+
button: ButtonHTMLAttributes<HTMLButtonElement>;
|
|
398
|
+
select: SelectHTMLAttributes<HTMLSelectElement>;
|
|
399
|
+
datalist: HTMLAttributes<HTMLDataListElement>;
|
|
400
|
+
optgroup: OptgroupHTMLAttributes<HTMLOptGroupElement>;
|
|
401
|
+
option: OptionHTMLAttributes<HTMLOptionElement>;
|
|
402
|
+
textarea: TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
403
|
+
output: OutputHTMLAttributes<HTMLOutputElement>;
|
|
404
|
+
progress: ProgressHTMLAttributes<HTMLProgressElement>;
|
|
405
|
+
meter: MeterHTMLAttributes<HTMLMeterElement>;
|
|
406
|
+
details: DetailsHTMLAttributes<HTMLDetailsElement>;
|
|
407
|
+
summary: HTMLAttributes<HTMLElement>;
|
|
408
|
+
dialog: DialogHTMLAttributes<HTMLDialogElement>;
|
|
409
|
+
img: ImgHTMLAttributes<HTMLImageElement>;
|
|
410
|
+
picture: HTMLAttributes<HTMLPictureElement>;
|
|
411
|
+
source: SourceHTMLAttributes<HTMLSourceElement>;
|
|
412
|
+
audio: AudioVideoHTMLAttributes<HTMLAudioElement>;
|
|
413
|
+
video: AudioVideoHTMLAttributes<HTMLVideoElement>;
|
|
414
|
+
track: TrackHTMLAttributes<HTMLTrackElement>;
|
|
415
|
+
map: MapHTMLAttributes<HTMLMapElement>;
|
|
416
|
+
area: AreaHTMLAttributes<HTMLAreaElement>;
|
|
417
|
+
iframe: IframeHTMLAttributes<HTMLIFrameElement>;
|
|
418
|
+
embed: EmbedHTMLAttributes<HTMLEmbedElement>;
|
|
419
|
+
object: ObjectHTMLAttributes<HTMLObjectElement>;
|
|
420
|
+
param: ParamHTMLAttributes<HTMLParamElement>;
|
|
421
|
+
canvas: CanvasHTMLAttributes<HTMLCanvasElement>;
|
|
422
|
+
svg: SVGAttributes<SVGSVGElement>;
|
|
423
|
+
path: SVGAttributes<SVGPathElement>;
|
|
424
|
+
circle: SVGAttributes<SVGCircleElement>;
|
|
425
|
+
rect: SVGAttributes<SVGRectElement>;
|
|
426
|
+
line: SVGAttributes<SVGLineElement>;
|
|
427
|
+
polyline: SVGAttributes<SVGPolylineElement>;
|
|
428
|
+
polygon: SVGAttributes<SVGPolygonElement>;
|
|
429
|
+
ellipse: SVGAttributes<SVGEllipseElement>;
|
|
430
|
+
g: SVGAttributes<SVGGElement>;
|
|
431
|
+
defs: SVGAttributes<SVGDefsElement>;
|
|
432
|
+
use: SVGAttributes<SVGUseElement>;
|
|
433
|
+
text: SVGAttributes<SVGTextElement>;
|
|
434
|
+
tspan: SVGAttributes<SVGTSpanElement>;
|
|
435
|
+
template: HTMLAttributes<HTMLTemplateElement>;
|
|
436
|
+
slot: SlotHTMLAttributes<HTMLSlotElement>;
|
|
437
|
+
portal: HTMLAttributes<HTMLElement>;
|
|
438
|
+
}
|
|
439
|
+
interface ElementChildrenAttribute {
|
|
440
|
+
children: unknown;
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
interface HTMLAttributes<T> {
|
|
444
|
+
children?: FictNode | FictNode[];
|
|
445
|
+
key?: string | number;
|
|
446
|
+
id?: string;
|
|
447
|
+
class?: string;
|
|
448
|
+
style?: string | Record<string, string | number>;
|
|
449
|
+
title?: string;
|
|
450
|
+
lang?: string;
|
|
451
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
452
|
+
hidden?: boolean | 'hidden' | 'until-found';
|
|
453
|
+
tabIndex?: number;
|
|
454
|
+
draggable?: boolean | 'true' | 'false';
|
|
455
|
+
contentEditable?: boolean | 'true' | 'false' | 'inherit';
|
|
456
|
+
spellCheck?: boolean | 'true' | 'false';
|
|
457
|
+
translate?: 'yes' | 'no';
|
|
458
|
+
inert?: boolean;
|
|
459
|
+
popover?: 'auto' | 'manual';
|
|
460
|
+
autofocus?: boolean;
|
|
461
|
+
slot?: string;
|
|
462
|
+
accessKey?: string;
|
|
463
|
+
onClick?: (e: MouseEvent) => void;
|
|
464
|
+
onDblClick?: (e: MouseEvent) => void;
|
|
465
|
+
onMouseDown?: (e: MouseEvent) => void;
|
|
466
|
+
onMouseUp?: (e: MouseEvent) => void;
|
|
467
|
+
onMouseMove?: (e: MouseEvent) => void;
|
|
468
|
+
onMouseEnter?: (e: MouseEvent) => void;
|
|
469
|
+
onMouseLeave?: (e: MouseEvent) => void;
|
|
470
|
+
onMouseOver?: (e: MouseEvent) => void;
|
|
471
|
+
onMouseOut?: (e: MouseEvent) => void;
|
|
472
|
+
onContextMenu?: (e: MouseEvent) => void;
|
|
473
|
+
onInput?: (e: InputEvent) => void;
|
|
474
|
+
onChange?: (e: Event) => void;
|
|
475
|
+
onSubmit?: (e: SubmitEvent) => void;
|
|
476
|
+
onReset?: (e: Event) => void;
|
|
477
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
478
|
+
onKeyUp?: (e: KeyboardEvent) => void;
|
|
479
|
+
onKeyPress?: (e: KeyboardEvent) => void;
|
|
480
|
+
onFocus?: (e: FocusEvent) => void;
|
|
481
|
+
onBlur?: (e: FocusEvent) => void;
|
|
482
|
+
onScroll?: (e: Event) => void;
|
|
483
|
+
onWheel?: (e: WheelEvent) => void;
|
|
484
|
+
onLoad?: (e: Event) => void;
|
|
485
|
+
onError?: (e: Event) => void;
|
|
486
|
+
onDrag?: (e: DragEvent) => void;
|
|
487
|
+
onDragStart?: (e: DragEvent) => void;
|
|
488
|
+
onDragEnd?: (e: DragEvent) => void;
|
|
489
|
+
onDragEnter?: (e: DragEvent) => void;
|
|
490
|
+
onDragLeave?: (e: DragEvent) => void;
|
|
491
|
+
onDragOver?: (e: DragEvent) => void;
|
|
492
|
+
onDrop?: (e: DragEvent) => void;
|
|
493
|
+
onTouchStart?: (e: TouchEvent) => void;
|
|
494
|
+
onTouchMove?: (e: TouchEvent) => void;
|
|
495
|
+
onTouchEnd?: (e: TouchEvent) => void;
|
|
496
|
+
onTouchCancel?: (e: TouchEvent) => void;
|
|
497
|
+
onAnimationStart?: (e: AnimationEvent) => void;
|
|
498
|
+
onAnimationEnd?: (e: AnimationEvent) => void;
|
|
499
|
+
onAnimationIteration?: (e: AnimationEvent) => void;
|
|
500
|
+
onTransitionEnd?: (e: TransitionEvent) => void;
|
|
501
|
+
onPointerDown?: (e: PointerEvent) => void;
|
|
502
|
+
onPointerUp?: (e: PointerEvent) => void;
|
|
503
|
+
onPointerMove?: (e: PointerEvent) => void;
|
|
504
|
+
onPointerEnter?: (e: PointerEvent) => void;
|
|
505
|
+
onPointerLeave?: (e: PointerEvent) => void;
|
|
506
|
+
onPointerOver?: (e: PointerEvent) => void;
|
|
507
|
+
onPointerOut?: (e: PointerEvent) => void;
|
|
508
|
+
onPointerCancel?: (e: PointerEvent) => void;
|
|
509
|
+
ref?: ((el: T | null) => void) | {
|
|
510
|
+
current: T | null;
|
|
511
|
+
};
|
|
512
|
+
role?: string;
|
|
513
|
+
'aria-hidden'?: boolean | 'true' | 'false';
|
|
514
|
+
'aria-label'?: string;
|
|
515
|
+
'aria-labelledby'?: string;
|
|
516
|
+
'aria-describedby'?: string;
|
|
517
|
+
'aria-live'?: 'off' | 'polite' | 'assertive';
|
|
518
|
+
'aria-atomic'?: boolean | 'true' | 'false';
|
|
519
|
+
'aria-busy'?: boolean | 'true' | 'false';
|
|
520
|
+
'aria-current'?: boolean | 'true' | 'false' | 'page' | 'step' | 'location' | 'date' | 'time';
|
|
521
|
+
'aria-disabled'?: boolean | 'true' | 'false';
|
|
522
|
+
'aria-expanded'?: boolean | 'true' | 'false';
|
|
523
|
+
'aria-haspopup'?: boolean | 'true' | 'false' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog';
|
|
524
|
+
'aria-pressed'?: boolean | 'true' | 'false' | 'mixed';
|
|
525
|
+
'aria-selected'?: boolean | 'true' | 'false';
|
|
526
|
+
'aria-checked'?: boolean | 'true' | 'false' | 'mixed';
|
|
527
|
+
'aria-controls'?: string;
|
|
528
|
+
'aria-owns'?: string;
|
|
529
|
+
'aria-activedescendant'?: string;
|
|
530
|
+
'aria-valuemin'?: number;
|
|
531
|
+
'aria-valuemax'?: number;
|
|
532
|
+
'aria-valuenow'?: number;
|
|
533
|
+
'aria-valuetext'?: string;
|
|
534
|
+
'aria-orientation'?: 'horizontal' | 'vertical';
|
|
535
|
+
'aria-readonly'?: boolean | 'true' | 'false';
|
|
536
|
+
'aria-required'?: boolean | 'true' | 'false';
|
|
537
|
+
'aria-invalid'?: boolean | 'true' | 'false' | 'grammar' | 'spelling';
|
|
538
|
+
'aria-errormessage'?: string;
|
|
539
|
+
'aria-modal'?: boolean | 'true' | 'false';
|
|
540
|
+
'aria-placeholder'?: string;
|
|
541
|
+
'aria-sort'?: 'none' | 'ascending' | 'descending' | 'other';
|
|
542
|
+
'aria-colcount'?: number;
|
|
543
|
+
'aria-colindex'?: number;
|
|
544
|
+
'aria-colspan'?: number;
|
|
545
|
+
'aria-rowcount'?: number;
|
|
546
|
+
'aria-rowindex'?: number;
|
|
547
|
+
'aria-rowspan'?: number;
|
|
548
|
+
'aria-setsize'?: number;
|
|
549
|
+
'aria-posinset'?: number;
|
|
550
|
+
'aria-level'?: number;
|
|
551
|
+
'aria-multiselectable'?: boolean | 'true' | 'false';
|
|
552
|
+
'aria-autocomplete'?: 'none' | 'inline' | 'list' | 'both';
|
|
553
|
+
'aria-details'?: string;
|
|
554
|
+
'aria-keyshortcuts'?: string;
|
|
555
|
+
'aria-roledescription'?: string;
|
|
556
|
+
[key: `data-${string}`]: string | number | boolean | undefined;
|
|
557
|
+
}
|
|
558
|
+
interface AnchorHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
559
|
+
href?: string;
|
|
560
|
+
target?: '_self' | '_blank' | '_parent' | '_top' | string;
|
|
561
|
+
rel?: string;
|
|
562
|
+
download?: boolean | string;
|
|
563
|
+
hreflang?: string;
|
|
564
|
+
type?: string;
|
|
565
|
+
referrerPolicy?: ReferrerPolicy;
|
|
566
|
+
ping?: string;
|
|
567
|
+
}
|
|
568
|
+
interface ButtonHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
569
|
+
type?: 'button' | 'submit' | 'reset';
|
|
570
|
+
disabled?: boolean;
|
|
571
|
+
name?: string;
|
|
572
|
+
value?: string;
|
|
573
|
+
form?: string;
|
|
574
|
+
formAction?: string;
|
|
575
|
+
formEncType?: string;
|
|
576
|
+
formMethod?: string;
|
|
577
|
+
formNoValidate?: boolean;
|
|
578
|
+
formTarget?: string;
|
|
579
|
+
popovertarget?: string;
|
|
580
|
+
popovertargetaction?: 'show' | 'hide' | 'toggle';
|
|
581
|
+
}
|
|
582
|
+
interface InputHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
583
|
+
type?: string;
|
|
584
|
+
value?: string | number | readonly string[];
|
|
585
|
+
defaultValue?: string | number | readonly string[];
|
|
586
|
+
checked?: boolean;
|
|
587
|
+
defaultChecked?: boolean;
|
|
588
|
+
disabled?: boolean;
|
|
589
|
+
placeholder?: string;
|
|
590
|
+
name?: string;
|
|
591
|
+
form?: string;
|
|
592
|
+
required?: boolean;
|
|
593
|
+
readonly?: boolean;
|
|
594
|
+
multiple?: boolean;
|
|
595
|
+
min?: number | string;
|
|
596
|
+
max?: number | string;
|
|
597
|
+
minLength?: number;
|
|
598
|
+
maxLength?: number;
|
|
599
|
+
step?: number | string;
|
|
600
|
+
pattern?: string;
|
|
601
|
+
size?: number;
|
|
602
|
+
accept?: string;
|
|
603
|
+
capture?: boolean | 'user' | 'environment';
|
|
604
|
+
list?: string;
|
|
605
|
+
autoComplete?: string;
|
|
606
|
+
autoCapitalize?: string;
|
|
607
|
+
inputMode?: 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
|
|
608
|
+
enterKeyHint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
609
|
+
height?: number | string;
|
|
610
|
+
width?: number | string;
|
|
611
|
+
alt?: string;
|
|
612
|
+
src?: string;
|
|
613
|
+
formAction?: string;
|
|
614
|
+
formEncType?: string;
|
|
615
|
+
formMethod?: string;
|
|
616
|
+
formNoValidate?: boolean;
|
|
617
|
+
formTarget?: string;
|
|
618
|
+
}
|
|
619
|
+
interface FormHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
620
|
+
action?: string;
|
|
621
|
+
method?: 'get' | 'post' | 'dialog';
|
|
622
|
+
encType?: string;
|
|
623
|
+
target?: string;
|
|
624
|
+
name?: string;
|
|
625
|
+
noValidate?: boolean;
|
|
626
|
+
autoComplete?: 'on' | 'off';
|
|
627
|
+
acceptCharset?: string;
|
|
628
|
+
}
|
|
629
|
+
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
630
|
+
src?: string;
|
|
631
|
+
alt?: string;
|
|
632
|
+
width?: number | string;
|
|
633
|
+
height?: number | string;
|
|
634
|
+
srcSet?: string;
|
|
635
|
+
sizes?: string;
|
|
636
|
+
loading?: 'eager' | 'lazy';
|
|
637
|
+
decoding?: 'async' | 'auto' | 'sync';
|
|
638
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
639
|
+
referrerPolicy?: ReferrerPolicy;
|
|
640
|
+
useMap?: string;
|
|
641
|
+
isMap?: boolean;
|
|
642
|
+
fetchPriority?: 'auto' | 'high' | 'low';
|
|
643
|
+
}
|
|
644
|
+
interface TextareaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
645
|
+
value?: string | number;
|
|
646
|
+
defaultValue?: string;
|
|
647
|
+
disabled?: boolean;
|
|
648
|
+
placeholder?: string;
|
|
649
|
+
name?: string;
|
|
650
|
+
form?: string;
|
|
651
|
+
required?: boolean;
|
|
652
|
+
readonly?: boolean;
|
|
653
|
+
rows?: number;
|
|
654
|
+
cols?: number;
|
|
655
|
+
minLength?: number;
|
|
656
|
+
maxLength?: number;
|
|
657
|
+
wrap?: 'hard' | 'soft' | 'off';
|
|
658
|
+
autoComplete?: string;
|
|
659
|
+
}
|
|
660
|
+
interface SelectHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
661
|
+
value?: string | number | readonly string[];
|
|
662
|
+
defaultValue?: string | number | readonly string[];
|
|
663
|
+
disabled?: boolean;
|
|
664
|
+
name?: string;
|
|
665
|
+
form?: string;
|
|
666
|
+
required?: boolean;
|
|
667
|
+
multiple?: boolean;
|
|
668
|
+
size?: number;
|
|
669
|
+
autoComplete?: string;
|
|
670
|
+
}
|
|
671
|
+
interface OptionHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
672
|
+
value?: string | number;
|
|
673
|
+
disabled?: boolean;
|
|
674
|
+
selected?: boolean;
|
|
675
|
+
label?: string;
|
|
676
|
+
}
|
|
677
|
+
interface OptgroupHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
678
|
+
disabled?: boolean;
|
|
679
|
+
label?: string;
|
|
680
|
+
}
|
|
681
|
+
interface LabelHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
682
|
+
for?: string;
|
|
683
|
+
htmlFor?: string;
|
|
684
|
+
form?: string;
|
|
685
|
+
}
|
|
686
|
+
interface FieldsetHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
687
|
+
disabled?: boolean;
|
|
688
|
+
name?: string;
|
|
689
|
+
form?: string;
|
|
690
|
+
}
|
|
691
|
+
interface OutputHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
692
|
+
for?: string;
|
|
693
|
+
htmlFor?: string;
|
|
694
|
+
form?: string;
|
|
695
|
+
name?: string;
|
|
696
|
+
}
|
|
697
|
+
interface ProgressHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
698
|
+
value?: number | string;
|
|
699
|
+
max?: number | string;
|
|
700
|
+
}
|
|
701
|
+
interface MeterHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
702
|
+
value?: number | string;
|
|
703
|
+
min?: number | string;
|
|
704
|
+
max?: number | string;
|
|
705
|
+
low?: number | string;
|
|
706
|
+
high?: number | string;
|
|
707
|
+
optimum?: number | string;
|
|
708
|
+
}
|
|
709
|
+
interface TableHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
710
|
+
cellPadding?: number | string;
|
|
711
|
+
cellSpacing?: number | string;
|
|
712
|
+
border?: number | string;
|
|
713
|
+
}
|
|
714
|
+
interface ThHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
715
|
+
colSpan?: number;
|
|
716
|
+
rowSpan?: number;
|
|
717
|
+
scope?: 'row' | 'col' | 'rowgroup' | 'colgroup';
|
|
718
|
+
abbr?: string;
|
|
719
|
+
headers?: string;
|
|
720
|
+
}
|
|
721
|
+
interface TdHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
722
|
+
colSpan?: number;
|
|
723
|
+
rowSpan?: number;
|
|
724
|
+
headers?: string;
|
|
725
|
+
}
|
|
726
|
+
interface ColHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
727
|
+
span?: number;
|
|
728
|
+
}
|
|
729
|
+
interface ColgroupHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
730
|
+
span?: number;
|
|
731
|
+
}
|
|
732
|
+
interface OlHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
733
|
+
start?: number;
|
|
734
|
+
reversed?: boolean;
|
|
735
|
+
type?: '1' | 'a' | 'A' | 'i' | 'I';
|
|
736
|
+
}
|
|
737
|
+
interface LiHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
738
|
+
value?: number;
|
|
739
|
+
}
|
|
740
|
+
interface AudioVideoHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
741
|
+
src?: string;
|
|
742
|
+
controls?: boolean;
|
|
743
|
+
autoPlay?: boolean;
|
|
744
|
+
loop?: boolean;
|
|
745
|
+
muted?: boolean;
|
|
746
|
+
preload?: 'none' | 'metadata' | 'auto';
|
|
747
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
748
|
+
poster?: string;
|
|
749
|
+
width?: number | string;
|
|
750
|
+
height?: number | string;
|
|
751
|
+
playsInline?: boolean;
|
|
752
|
+
disableRemotePlayback?: boolean;
|
|
753
|
+
onPlay?: (e: Event) => void;
|
|
754
|
+
onPause?: (e: Event) => void;
|
|
755
|
+
onEnded?: (e: Event) => void;
|
|
756
|
+
onTimeUpdate?: (e: Event) => void;
|
|
757
|
+
onVolumeChange?: (e: Event) => void;
|
|
758
|
+
onSeeking?: (e: Event) => void;
|
|
759
|
+
onSeeked?: (e: Event) => void;
|
|
760
|
+
onLoadedData?: (e: Event) => void;
|
|
761
|
+
onLoadedMetadata?: (e: Event) => void;
|
|
762
|
+
onCanPlay?: (e: Event) => void;
|
|
763
|
+
onCanPlayThrough?: (e: Event) => void;
|
|
764
|
+
onWaiting?: (e: Event) => void;
|
|
765
|
+
onPlaying?: (e: Event) => void;
|
|
766
|
+
onProgress?: (e: Event) => void;
|
|
767
|
+
onDurationChange?: (e: Event) => void;
|
|
768
|
+
onRateChange?: (e: Event) => void;
|
|
769
|
+
onStalled?: (e: Event) => void;
|
|
770
|
+
onSuspend?: (e: Event) => void;
|
|
771
|
+
onEmptied?: (e: Event) => void;
|
|
772
|
+
}
|
|
773
|
+
interface SourceHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
774
|
+
src?: string;
|
|
775
|
+
srcSet?: string;
|
|
776
|
+
sizes?: string;
|
|
777
|
+
type?: string;
|
|
778
|
+
media?: string;
|
|
779
|
+
width?: number | string;
|
|
780
|
+
height?: number | string;
|
|
781
|
+
}
|
|
782
|
+
interface TrackHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
783
|
+
src?: string;
|
|
784
|
+
srcLang?: string;
|
|
785
|
+
label?: string;
|
|
786
|
+
kind?: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
787
|
+
default?: boolean;
|
|
788
|
+
}
|
|
789
|
+
interface IframeHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
790
|
+
src?: string;
|
|
791
|
+
srcDoc?: string;
|
|
792
|
+
name?: string;
|
|
793
|
+
width?: number | string;
|
|
794
|
+
height?: number | string;
|
|
795
|
+
allow?: string;
|
|
796
|
+
allowFullScreen?: boolean;
|
|
797
|
+
sandbox?: string;
|
|
798
|
+
loading?: 'eager' | 'lazy';
|
|
799
|
+
referrerPolicy?: ReferrerPolicy;
|
|
800
|
+
}
|
|
801
|
+
interface EmbedHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
802
|
+
src?: string;
|
|
803
|
+
type?: string;
|
|
804
|
+
width?: number | string;
|
|
805
|
+
height?: number | string;
|
|
806
|
+
}
|
|
807
|
+
interface ObjectHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
808
|
+
data?: string;
|
|
809
|
+
type?: string;
|
|
810
|
+
name?: string;
|
|
811
|
+
width?: number | string;
|
|
812
|
+
height?: number | string;
|
|
813
|
+
form?: string;
|
|
814
|
+
useMap?: string;
|
|
815
|
+
}
|
|
816
|
+
interface ParamHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
817
|
+
name?: string;
|
|
818
|
+
value?: string;
|
|
819
|
+
}
|
|
820
|
+
interface CanvasHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
821
|
+
width?: number | string;
|
|
822
|
+
height?: number | string;
|
|
823
|
+
}
|
|
824
|
+
interface MapHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
825
|
+
name?: string;
|
|
826
|
+
}
|
|
827
|
+
interface AreaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
828
|
+
alt?: string;
|
|
829
|
+
coords?: string;
|
|
830
|
+
href?: string;
|
|
831
|
+
hreflang?: string;
|
|
832
|
+
download?: boolean | string;
|
|
833
|
+
rel?: string;
|
|
834
|
+
shape?: 'rect' | 'circle' | 'poly' | 'default';
|
|
835
|
+
target?: string;
|
|
836
|
+
referrerPolicy?: ReferrerPolicy;
|
|
837
|
+
ping?: string;
|
|
838
|
+
}
|
|
839
|
+
interface DetailsHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
840
|
+
open?: boolean;
|
|
841
|
+
onToggle?: (e: Event) => void;
|
|
842
|
+
}
|
|
843
|
+
interface DialogHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
844
|
+
open?: boolean;
|
|
845
|
+
onClose?: (e: Event) => void;
|
|
846
|
+
onCancel?: (e: Event) => void;
|
|
847
|
+
}
|
|
848
|
+
interface BlockquoteHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
849
|
+
cite?: string;
|
|
850
|
+
}
|
|
851
|
+
interface QuoteHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
852
|
+
cite?: string;
|
|
853
|
+
}
|
|
854
|
+
interface TimeHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
855
|
+
dateTime?: string;
|
|
856
|
+
}
|
|
857
|
+
interface DataHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
858
|
+
value?: string;
|
|
859
|
+
}
|
|
860
|
+
interface MetaHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
861
|
+
name?: string;
|
|
862
|
+
content?: string;
|
|
863
|
+
httpEquiv?: string;
|
|
864
|
+
charSet?: string;
|
|
865
|
+
property?: string;
|
|
866
|
+
}
|
|
867
|
+
interface LinkHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
868
|
+
href?: string;
|
|
869
|
+
rel?: string;
|
|
870
|
+
type?: string;
|
|
871
|
+
media?: string;
|
|
872
|
+
as?: string;
|
|
873
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
874
|
+
referrerPolicy?: ReferrerPolicy;
|
|
875
|
+
sizes?: string;
|
|
876
|
+
hreflang?: string;
|
|
877
|
+
integrity?: string;
|
|
878
|
+
fetchPriority?: 'auto' | 'high' | 'low';
|
|
879
|
+
disabled?: boolean;
|
|
880
|
+
}
|
|
881
|
+
interface StyleHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
882
|
+
media?: string;
|
|
883
|
+
nonce?: string;
|
|
884
|
+
blocking?: string;
|
|
885
|
+
}
|
|
886
|
+
interface ScriptHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
887
|
+
src?: string;
|
|
888
|
+
type?: string;
|
|
889
|
+
async?: boolean;
|
|
890
|
+
defer?: boolean;
|
|
891
|
+
crossOrigin?: 'anonymous' | 'use-credentials';
|
|
892
|
+
integrity?: string;
|
|
893
|
+
noModule?: boolean;
|
|
894
|
+
nonce?: string;
|
|
895
|
+
referrerPolicy?: ReferrerPolicy;
|
|
896
|
+
fetchPriority?: 'auto' | 'high' | 'low';
|
|
897
|
+
blocking?: string;
|
|
898
|
+
}
|
|
899
|
+
interface SlotHTMLAttributes<T> extends HTMLAttributes<T> {
|
|
900
|
+
name?: string;
|
|
901
|
+
onSlotchange?: (e: Event) => void;
|
|
902
|
+
}
|
|
903
|
+
interface SVGAttributes<T> extends HTMLAttributes<T> {
|
|
904
|
+
viewBox?: string;
|
|
905
|
+
xmlns?: string;
|
|
906
|
+
xmlnsXlink?: string;
|
|
907
|
+
fill?: string;
|
|
908
|
+
stroke?: string;
|
|
909
|
+
strokeWidth?: string | number;
|
|
910
|
+
strokeLinecap?: 'butt' | 'round' | 'square';
|
|
911
|
+
strokeLinejoin?: 'miter' | 'round' | 'bevel';
|
|
912
|
+
strokeDasharray?: string;
|
|
913
|
+
strokeDashoffset?: string | number;
|
|
914
|
+
strokeOpacity?: string | number;
|
|
915
|
+
fillOpacity?: string | number;
|
|
916
|
+
opacity?: string | number;
|
|
917
|
+
transform?: string;
|
|
918
|
+
transformOrigin?: string;
|
|
919
|
+
clipPath?: string;
|
|
920
|
+
mask?: string;
|
|
921
|
+
filter?: string;
|
|
922
|
+
d?: string;
|
|
923
|
+
cx?: string | number;
|
|
924
|
+
cy?: string | number;
|
|
925
|
+
r?: string | number;
|
|
926
|
+
rx?: string | number;
|
|
927
|
+
ry?: string | number;
|
|
928
|
+
x?: string | number;
|
|
929
|
+
y?: string | number;
|
|
930
|
+
x1?: string | number;
|
|
931
|
+
y1?: string | number;
|
|
932
|
+
x2?: string | number;
|
|
933
|
+
y2?: string | number;
|
|
934
|
+
width?: string | number;
|
|
935
|
+
height?: string | number;
|
|
936
|
+
points?: string;
|
|
937
|
+
pathLength?: string | number;
|
|
938
|
+
textAnchor?: 'start' | 'middle' | 'end';
|
|
939
|
+
dominantBaseline?: string;
|
|
940
|
+
dx?: string | number;
|
|
941
|
+
dy?: string | number;
|
|
942
|
+
fontSize?: string | number;
|
|
943
|
+
fontFamily?: string;
|
|
944
|
+
fontWeight?: string | number;
|
|
945
|
+
href?: string;
|
|
946
|
+
xlinkHref?: string;
|
|
947
|
+
gradientUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
|
|
948
|
+
gradientTransform?: string;
|
|
949
|
+
spreadMethod?: 'pad' | 'reflect' | 'repeat';
|
|
950
|
+
offset?: string | number;
|
|
951
|
+
stopColor?: string;
|
|
952
|
+
stopOpacity?: string | number;
|
|
953
|
+
clipPathUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
|
|
954
|
+
maskUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
|
|
955
|
+
maskContentUnits?: 'userSpaceOnUse' | 'objectBoundingBox';
|
|
956
|
+
preserveAspectRatio?: string;
|
|
957
|
+
markerStart?: string;
|
|
958
|
+
markerMid?: string;
|
|
959
|
+
markerEnd?: string;
|
|
960
|
+
vectorEffect?: string;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Fict Reactive DOM Binding System
|
|
965
|
+
*
|
|
966
|
+
* This module provides the core mechanisms for reactive DOM updates.
|
|
967
|
+
* It bridges the gap between Fict's reactive system (signals, effects)
|
|
968
|
+
* and the DOM, enabling fine-grained updates without a virtual DOM.
|
|
969
|
+
*
|
|
970
|
+
* Design Philosophy:
|
|
971
|
+
* - Values wrapped in functions `() => T` are treated as reactive
|
|
972
|
+
* - Static values are applied once without tracking
|
|
973
|
+
* - The compiler transforms JSX expressions to use these primitives
|
|
974
|
+
*/
|
|
975
|
+
|
|
976
|
+
/** A reactive value that can be either static or a getter function */
|
|
977
|
+
type MaybeReactive<T> = T | (() => T);
|
|
978
|
+
/** Internal type for createElement function reference */
|
|
979
|
+
type CreateElementFn = (node: FictNode) => Node;
|
|
980
|
+
/** Handle returned by conditional/list bindings for cleanup */
|
|
981
|
+
interface BindingHandle {
|
|
982
|
+
/** Marker node(s) used for positioning */
|
|
983
|
+
marker: Comment | DocumentFragment;
|
|
984
|
+
/** Flush pending content - call after markers are inserted into DOM */
|
|
985
|
+
flush?: () => void;
|
|
986
|
+
/** Dispose function to clean up the binding */
|
|
987
|
+
dispose: Cleanup;
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
990
|
+
* Check if a value is reactive (a getter function)
|
|
991
|
+
* Note: Event handlers (functions that take arguments) are NOT reactive values
|
|
992
|
+
*/
|
|
993
|
+
declare function isReactive(value: unknown): value is () => unknown;
|
|
994
|
+
/**
|
|
995
|
+
* Unwrap a potentially reactive value to get the actual value
|
|
996
|
+
*/
|
|
997
|
+
declare function unwrap<T>(value: MaybeReactive<T>): T;
|
|
998
|
+
/**
|
|
999
|
+
* Unwrap a primitive proxy value to get the raw primitive value.
|
|
1000
|
+
* This is primarily useful for advanced scenarios where you need the actual
|
|
1001
|
+
* primitive type (e.g., for typeof checks or strict equality comparisons).
|
|
1002
|
+
*
|
|
1003
|
+
* @param value - A potentially proxied primitive value
|
|
1004
|
+
* @returns The raw primitive value
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```ts
|
|
1008
|
+
* createList(
|
|
1009
|
+
* () => [1, 2, 3],
|
|
1010
|
+
* (item) => {
|
|
1011
|
+
* const raw = unwrapPrimitive(item)
|
|
1012
|
+
* typeof raw === 'number' // true
|
|
1013
|
+
* raw === 1 // true (for first item)
|
|
1014
|
+
* },
|
|
1015
|
+
* item => item
|
|
1016
|
+
* )
|
|
1017
|
+
* ```
|
|
1018
|
+
*/
|
|
1019
|
+
declare function unwrapPrimitive<T>(value: T): T;
|
|
1020
|
+
/**
|
|
1021
|
+
* Create a text node that reactively updates when the value changes.
|
|
1022
|
+
*
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```ts
|
|
1025
|
+
* // Static text
|
|
1026
|
+
* createTextBinding("Hello")
|
|
1027
|
+
*
|
|
1028
|
+
* // Reactive text (compiler output)
|
|
1029
|
+
* createTextBinding(() => $count())
|
|
1030
|
+
* ```
|
|
1031
|
+
*/
|
|
1032
|
+
declare function createTextBinding(value: MaybeReactive<unknown>): Text;
|
|
1033
|
+
/**
|
|
1034
|
+
* Bind a reactive value to an existing text node.
|
|
1035
|
+
* This is a convenience function for binding to existing DOM nodes.
|
|
1036
|
+
*/
|
|
1037
|
+
declare function bindText(textNode: Text, getValue: () => unknown): Cleanup;
|
|
1038
|
+
/** Attribute setter function type */
|
|
1039
|
+
type AttributeSetter = (el: HTMLElement, key: string, value: unknown) => void;
|
|
1040
|
+
/**
|
|
1041
|
+
* Create a reactive attribute binding on an element.
|
|
1042
|
+
*
|
|
1043
|
+
* @example
|
|
1044
|
+
* ```ts
|
|
1045
|
+
* // Static attribute
|
|
1046
|
+
* createAttributeBinding(button, 'disabled', false, setAttribute)
|
|
1047
|
+
*
|
|
1048
|
+
* // Reactive attribute (compiler output)
|
|
1049
|
+
* createAttributeBinding(button, 'disabled', () => !$isValid(), setAttribute)
|
|
1050
|
+
* ```
|
|
1051
|
+
*/
|
|
1052
|
+
declare function createAttributeBinding(el: HTMLElement, key: string, value: MaybeReactive<unknown>, setter: AttributeSetter): void;
|
|
1053
|
+
/**
|
|
1054
|
+
* Bind a reactive value to an element's attribute.
|
|
1055
|
+
*/
|
|
1056
|
+
declare function bindAttribute(el: HTMLElement, key: string, getValue: () => unknown): Cleanup;
|
|
1057
|
+
/**
|
|
1058
|
+
* Bind a reactive value to an element's property.
|
|
1059
|
+
*/
|
|
1060
|
+
declare function bindProperty(el: HTMLElement, key: string, getValue: () => unknown): Cleanup;
|
|
1061
|
+
/**
|
|
1062
|
+
* Apply styles to an element, supporting reactive style objects/strings.
|
|
1063
|
+
*/
|
|
1064
|
+
declare function createStyleBinding(el: HTMLElement, value: MaybeReactive<string | Record<string, string | number> | null | undefined>): void;
|
|
1065
|
+
/**
|
|
1066
|
+
* Bind a reactive style value to an existing element.
|
|
1067
|
+
*/
|
|
1068
|
+
declare function bindStyle(el: HTMLElement, getValue: () => string | Record<string, string | number> | null | undefined): Cleanup;
|
|
1069
|
+
/**
|
|
1070
|
+
* Apply class to an element, supporting reactive class values.
|
|
1071
|
+
*/
|
|
1072
|
+
declare function createClassBinding(el: HTMLElement, value: MaybeReactive<string | Record<string, boolean> | null | undefined>): void;
|
|
1073
|
+
/**
|
|
1074
|
+
* Bind a reactive class value to an existing element.
|
|
1075
|
+
*/
|
|
1076
|
+
declare function bindClass(el: HTMLElement, getValue: () => string | Record<string, boolean> | null | undefined): Cleanup;
|
|
1077
|
+
/**
|
|
1078
|
+
* Exported classList function for direct use (compatible with dom-expressions)
|
|
1079
|
+
*/
|
|
1080
|
+
declare function classList(node: HTMLElement, value: Record<string, boolean> | null | undefined, prev?: Record<string, boolean>): Record<string, boolean>;
|
|
1081
|
+
/**
|
|
1082
|
+
* Insert reactive content into a parent element.
|
|
1083
|
+
* This is a simpler API than createChildBinding for basic cases.
|
|
1084
|
+
*
|
|
1085
|
+
* @param parent - The parent element to insert into
|
|
1086
|
+
* @param getValue - Function that returns the value to render
|
|
1087
|
+
* @param markerOrCreateElement - Optional marker node to insert before, or createElementFn
|
|
1088
|
+
* @param createElementFn - Optional function to create DOM elements (when marker is provided)
|
|
1089
|
+
*/
|
|
1090
|
+
declare function insert(parent: HTMLElement | DocumentFragment, getValue: () => FictNode, markerOrCreateElement?: Node | CreateElementFn, createElementFn?: CreateElementFn): Cleanup;
|
|
1091
|
+
/**
|
|
1092
|
+
* Create a reactive child binding that updates when the child value changes.
|
|
1093
|
+
* This is used for dynamic expressions like `{show && <Modal />}` or `{items.map(...)}`.
|
|
1094
|
+
*
|
|
1095
|
+
* @example
|
|
1096
|
+
* ```ts
|
|
1097
|
+
* // Reactive child (compiler output for {count})
|
|
1098
|
+
* createChildBinding(parent, () => $count(), createElement)
|
|
1099
|
+
*
|
|
1100
|
+
* // Reactive conditional (compiler output for {show && <Modal />})
|
|
1101
|
+
* createChildBinding(parent, () => $show() && jsx(Modal, {}), createElement)
|
|
1102
|
+
* ```
|
|
1103
|
+
*/
|
|
1104
|
+
declare function createChildBinding(parent: HTMLElement | DocumentFragment, getValue: () => FictNode, createElementFn: CreateElementFn): BindingHandle;
|
|
1105
|
+
declare global {
|
|
1106
|
+
interface HTMLElement {
|
|
1107
|
+
_$host?: HTMLElement;
|
|
1108
|
+
[key: `$$${string}`]: EventListener | [EventListener, unknown] | undefined;
|
|
1109
|
+
[key: `$$${string}Data`]: unknown;
|
|
1110
|
+
}
|
|
1111
|
+
interface Document extends Record<string, unknown> {
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Initialize event delegation for a set of event names.
|
|
1116
|
+
* Events will be handled at the document level and dispatched to the appropriate handlers.
|
|
1117
|
+
*
|
|
1118
|
+
* @param eventNames - Array of event names to delegate
|
|
1119
|
+
* @param doc - The document to attach handlers to (default: window.document)
|
|
1120
|
+
*
|
|
1121
|
+
* @example
|
|
1122
|
+
* ```ts
|
|
1123
|
+
* // Called automatically by the compiler for delegated events
|
|
1124
|
+
* delegateEvents(['click', 'input', 'keydown'])
|
|
1125
|
+
* ```
|
|
1126
|
+
*/
|
|
1127
|
+
declare function delegateEvents(eventNames: string[], doc?: Document): void;
|
|
1128
|
+
/**
|
|
1129
|
+
* Clear all delegated event handlers from a document.
|
|
1130
|
+
*
|
|
1131
|
+
* @param doc - The document to clear handlers from (default: window.document)
|
|
1132
|
+
*/
|
|
1133
|
+
declare function clearDelegatedEvents(doc?: Document): void;
|
|
1134
|
+
/**
|
|
1135
|
+
* Add an event listener to an element.
|
|
1136
|
+
* If the event is in DelegatedEvents, it uses event delegation for better performance.
|
|
1137
|
+
*
|
|
1138
|
+
* @param node - The element to add the listener to
|
|
1139
|
+
* @param name - The event name (lowercase)
|
|
1140
|
+
* @param handler - The event handler or [handler, data] tuple
|
|
1141
|
+
* @param delegate - Whether to use delegation (auto-detected based on event name)
|
|
1142
|
+
*/
|
|
1143
|
+
declare function addEventListener(node: HTMLElement, name: string, handler: EventListener | [EventListener, unknown] | null | undefined, delegate?: boolean): void;
|
|
1144
|
+
/**
|
|
1145
|
+
* Bind an event listener to an element.
|
|
1146
|
+
* Uses event delegation for better performance when applicable.
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```ts
|
|
1150
|
+
* // Static event
|
|
1151
|
+
* bindEvent(button, 'click', handleClick)
|
|
1152
|
+
*
|
|
1153
|
+
* // Reactive event (compiler output)
|
|
1154
|
+
* bindEvent(button, 'click', () => $handler())
|
|
1155
|
+
*
|
|
1156
|
+
* // With modifiers
|
|
1157
|
+
* bindEvent(button, 'click', handler, { capture: true, passive: true, once: true })
|
|
1158
|
+
* ```
|
|
1159
|
+
*/
|
|
1160
|
+
declare function bindEvent(el: HTMLElement, eventName: string, handler: EventListenerOrEventListenerObject | null | undefined, options?: boolean | AddEventListenerOptions): Cleanup;
|
|
1161
|
+
/**
|
|
1162
|
+
* Bind a ref to an element.
|
|
1163
|
+
* Supports both callback refs and ref objects.
|
|
1164
|
+
*
|
|
1165
|
+
* @param el - The element to bind the ref to
|
|
1166
|
+
* @param ref - Either a callback function, a ref object, or a reactive getter
|
|
1167
|
+
* @returns Cleanup function
|
|
1168
|
+
*
|
|
1169
|
+
* @example
|
|
1170
|
+
* ```ts
|
|
1171
|
+
* // Callback ref
|
|
1172
|
+
* bindRef(el, (element) => { store.input = element })
|
|
1173
|
+
*
|
|
1174
|
+
* // Ref object
|
|
1175
|
+
* const inputRef = createRef()
|
|
1176
|
+
* bindRef(el, inputRef)
|
|
1177
|
+
*
|
|
1178
|
+
* // Reactive ref (compiler output)
|
|
1179
|
+
* bindRef(el, () => props.ref)
|
|
1180
|
+
* ```
|
|
1181
|
+
*/
|
|
1182
|
+
declare function bindRef(el: HTMLElement, ref: unknown): Cleanup;
|
|
1183
|
+
/**
|
|
1184
|
+
* Apply spread props to an element with reactive updates.
|
|
1185
|
+
* This handles dynamic spread like `<div {...props}>`.
|
|
1186
|
+
*
|
|
1187
|
+
* @param node - The element to apply props to
|
|
1188
|
+
* @param props - The props object (may have reactive getters)
|
|
1189
|
+
* @param isSVG - Whether this is an SVG element
|
|
1190
|
+
* @param skipChildren - Whether to skip children handling
|
|
1191
|
+
* @returns The previous props for tracking changes
|
|
1192
|
+
*
|
|
1193
|
+
* @example
|
|
1194
|
+
* ```ts
|
|
1195
|
+
* // Compiler output for <div {...props} />
|
|
1196
|
+
* spread(el, props, false, false)
|
|
1197
|
+
* ```
|
|
1198
|
+
*/
|
|
1199
|
+
declare function spread(node: HTMLElement, props?: Record<string, unknown>, isSVG?: boolean, skipChildren?: boolean): Record<string, unknown>;
|
|
1200
|
+
/**
|
|
1201
|
+
* Assign props to a node, tracking previous values for efficient updates.
|
|
1202
|
+
* This is the core prop assignment logic used by spread.
|
|
1203
|
+
*
|
|
1204
|
+
* @param node - The element to assign props to
|
|
1205
|
+
* @param props - New props object
|
|
1206
|
+
* @param isSVG - Whether this is an SVG element
|
|
1207
|
+
* @param skipChildren - Whether to skip children handling
|
|
1208
|
+
* @param prevProps - Previous props for comparison
|
|
1209
|
+
* @param skipRef - Whether to skip ref handling
|
|
1210
|
+
*/
|
|
1211
|
+
declare function assign(node: HTMLElement, props: Record<string, unknown>, isSVG?: boolean, skipChildren?: boolean, prevProps?: Record<string, unknown>, skipRef?: boolean): void;
|
|
1212
|
+
/**
|
|
1213
|
+
* Create a conditional rendering binding.
|
|
1214
|
+
* Efficiently renders one of two branches based on a condition.
|
|
1215
|
+
*
|
|
1216
|
+
* This is an optimized version for `{condition ? <A /> : <B />}` patterns
|
|
1217
|
+
* where both branches are known statically.
|
|
1218
|
+
*
|
|
1219
|
+
* @example
|
|
1220
|
+
* ```ts
|
|
1221
|
+
* // Compiler output for {show ? <A /> : <B />}
|
|
1222
|
+
* createConditional(
|
|
1223
|
+
* () => $show(),
|
|
1224
|
+
* () => jsx(A, {}),
|
|
1225
|
+
* () => jsx(B, {}),
|
|
1226
|
+
* createElement
|
|
1227
|
+
* )
|
|
1228
|
+
* ```
|
|
1229
|
+
*/
|
|
1230
|
+
declare function createConditional(condition: () => boolean, renderTrue: () => FictNode, createElementFn: CreateElementFn, renderFalse?: () => FictNode): BindingHandle;
|
|
1231
|
+
/** Key extractor function type */
|
|
1232
|
+
type KeyFn<T> = (item: T, index: number) => string | number;
|
|
1233
|
+
/**
|
|
1234
|
+
* Create a reactive list rendering binding with optional keying.
|
|
1235
|
+
*/
|
|
1236
|
+
declare function createList<T>(items: () => T[], renderItem: (item: T, index: number) => FictNode, createElementFn: CreateElementFn, getKey?: KeyFn<T>): BindingHandle;
|
|
1237
|
+
/**
|
|
1238
|
+
* Create a show/hide binding that uses CSS display instead of DOM manipulation.
|
|
1239
|
+
* More efficient than conditional when the content is expensive to create.
|
|
1240
|
+
*
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```ts
|
|
1243
|
+
* createShow(container, () => $visible())
|
|
1244
|
+
* ```
|
|
1245
|
+
*/
|
|
1246
|
+
declare function createShow(el: HTMLElement, condition: () => boolean, displayValue?: string): void;
|
|
1247
|
+
/**
|
|
1248
|
+
* Create a portal that renders content into a different DOM container.
|
|
1249
|
+
*
|
|
1250
|
+
* @example
|
|
1251
|
+
* ```ts
|
|
1252
|
+
* createPortal(
|
|
1253
|
+
* document.body,
|
|
1254
|
+
* () => jsx(Modal, { children: 'Hello' }),
|
|
1255
|
+
* createElement
|
|
1256
|
+
* )
|
|
1257
|
+
* ```
|
|
1258
|
+
*/
|
|
1259
|
+
declare function createPortal(container: HTMLElement, render: () => FictNode, createElementFn: CreateElementFn): BindingHandle;
|
|
1260
|
+
|
|
1261
|
+
/**
|
|
1262
|
+
* Fict DOM Rendering System
|
|
1263
|
+
*
|
|
1264
|
+
* This module provides DOM rendering capabilities with reactive bindings.
|
|
1265
|
+
* It transforms JSX virtual nodes into actual DOM elements, automatically
|
|
1266
|
+
* setting up reactive updates for dynamic values.
|
|
1267
|
+
*
|
|
1268
|
+
* Key Features:
|
|
1269
|
+
* - Reactive text content: `{count}` updates when count changes
|
|
1270
|
+
* - Reactive attributes: `disabled={!isValid}` updates reactively
|
|
1271
|
+
* - Reactive children: `{show && <Modal />}` handles conditionals
|
|
1272
|
+
* - List rendering: `{items.map(...)}` with efficient keyed updates
|
|
1273
|
+
*/
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Render a Fict view into a container element.
|
|
1277
|
+
*
|
|
1278
|
+
* @param view - A function that returns the view to render
|
|
1279
|
+
* @param container - The DOM container to render into
|
|
1280
|
+
* @returns A teardown function to unmount the view
|
|
1281
|
+
*
|
|
1282
|
+
* @example
|
|
1283
|
+
* ```ts
|
|
1284
|
+
* const unmount = render(() => <App />, document.getElementById('root')!)
|
|
1285
|
+
* // Later: unmount()
|
|
1286
|
+
* ```
|
|
1287
|
+
*/
|
|
1288
|
+
declare function render(view: () => FictNode, container: HTMLElement): () => void;
|
|
1289
|
+
/**
|
|
1290
|
+
* Create a DOM element from a Fict node.
|
|
1291
|
+
* This is the main entry point for converting virtual nodes to real DOM.
|
|
1292
|
+
*
|
|
1293
|
+
* Supports:
|
|
1294
|
+
* - Native DOM nodes (passed through)
|
|
1295
|
+
* - Null/undefined/false (empty text node)
|
|
1296
|
+
* - Arrays (DocumentFragment)
|
|
1297
|
+
* - Strings/numbers (text nodes)
|
|
1298
|
+
* - Booleans (empty text node)
|
|
1299
|
+
* - VNodes (components or HTML elements)
|
|
1300
|
+
* - Reactive values (functions returning any of the above)
|
|
1301
|
+
*/
|
|
1302
|
+
declare function createElement(node: FictNode): DOMElement;
|
|
1303
|
+
/**
|
|
1304
|
+
* Create a template cloning factory from an HTML string.
|
|
1305
|
+
* Used by the compiler for efficient DOM generation.
|
|
1306
|
+
*
|
|
1307
|
+
* @param html - The HTML string to create a template from
|
|
1308
|
+
* @param isImportNode - Use importNode for elements like img/iframe
|
|
1309
|
+
* @param isSVG - Whether the template is SVG content
|
|
1310
|
+
* @param isMathML - Whether the template is MathML content
|
|
1311
|
+
*/
|
|
1312
|
+
declare function template(html: string, isImportNode?: boolean, isSVG?: boolean, isMathML?: boolean): () => Node;
|
|
1313
|
+
|
|
1314
|
+
interface ErrorBoundaryProps extends BaseProps {
|
|
1315
|
+
fallback: FictNode | ((err: unknown) => FictNode);
|
|
1316
|
+
onError?: (err: unknown) => void;
|
|
1317
|
+
resetKeys?: unknown | (() => unknown);
|
|
1318
|
+
}
|
|
1319
|
+
declare function ErrorBoundary(props: ErrorBoundaryProps): FictNode;
|
|
1320
|
+
|
|
1321
|
+
interface SuspenseProps extends BaseProps {
|
|
1322
|
+
fallback: FictNode | ((err?: unknown) => FictNode);
|
|
1323
|
+
onResolve?: () => void;
|
|
1324
|
+
onReject?: (err: unknown) => void;
|
|
1325
|
+
resetKeys?: unknown | (() => unknown);
|
|
1326
|
+
}
|
|
1327
|
+
interface SuspenseHandle {
|
|
1328
|
+
token: SuspenseToken;
|
|
1329
|
+
resolve: () => void;
|
|
1330
|
+
reject: (err: unknown) => void;
|
|
1331
|
+
}
|
|
1332
|
+
declare function createSuspenseToken(): SuspenseHandle;
|
|
1333
|
+
declare function Suspense(props: SuspenseProps): FictNode;
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* Fict DOM Constants
|
|
1337
|
+
*
|
|
1338
|
+
* Property constants and configurations for DOM attribute handling.
|
|
1339
|
+
* Borrowed from dom-expressions for comprehensive DOM support.
|
|
1340
|
+
*/
|
|
1341
|
+
declare const BooleanAttributes: Set<string>;
|
|
1342
|
+
/**
|
|
1343
|
+
* Properties that should be set via DOM property (not attribute)
|
|
1344
|
+
* Includes camelCase versions of boolean attributes
|
|
1345
|
+
*/
|
|
1346
|
+
declare const Properties: Set<string>;
|
|
1347
|
+
/**
|
|
1348
|
+
* Properties that represent children/content
|
|
1349
|
+
*/
|
|
1350
|
+
declare const ChildProperties: Set<string>;
|
|
1351
|
+
/**
|
|
1352
|
+
* React compatibility aliases (className -> class)
|
|
1353
|
+
*/
|
|
1354
|
+
declare const Aliases: Record<string, string>;
|
|
1355
|
+
/**
|
|
1356
|
+
* Get the property alias for a given attribute and tag name
|
|
1357
|
+
*/
|
|
1358
|
+
declare function getPropAlias(prop: string, tagName: string): string | undefined;
|
|
1359
|
+
/**
|
|
1360
|
+
* Events that should use event delegation for performance
|
|
1361
|
+
* These events bubble and are commonly used across many elements
|
|
1362
|
+
*/
|
|
1363
|
+
declare const DelegatedEvents: Set<string>;
|
|
1364
|
+
/**
|
|
1365
|
+
* SVG element names (excluding common ones that overlap with HTML)
|
|
1366
|
+
*/
|
|
1367
|
+
declare const SVGElements: Set<string>;
|
|
1368
|
+
/**
|
|
1369
|
+
* SVG attribute namespaces
|
|
1370
|
+
*/
|
|
1371
|
+
declare const SVGNamespace: Record<string, string>;
|
|
1372
|
+
/**
|
|
1373
|
+
* CSS properties that don't need a unit (like 'px')
|
|
1374
|
+
*/
|
|
1375
|
+
declare const UnitlessStyles: Set<string>;
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Fict DOM Reconciliation
|
|
1379
|
+
*
|
|
1380
|
+
* Efficient array reconciliation algorithm based on udomdiff.
|
|
1381
|
+
* https://github.com/WebReflection/udomdiff
|
|
1382
|
+
*
|
|
1383
|
+
* This algorithm uses a 5-step strategy:
|
|
1384
|
+
* 1. Common prefix - skip matching nodes at start
|
|
1385
|
+
* 2. Common suffix - skip matching nodes at end
|
|
1386
|
+
* 3. Append - insert remaining new nodes
|
|
1387
|
+
* 4. Remove - remove remaining old nodes
|
|
1388
|
+
* 5. Swap/Map fallback - handle complex rearrangements
|
|
1389
|
+
*
|
|
1390
|
+
* Most real-world updates (95%+) use fast paths without building a Map.
|
|
1391
|
+
*/
|
|
1392
|
+
/**
|
|
1393
|
+
* Reconcile two arrays of DOM nodes, efficiently updating the DOM.
|
|
1394
|
+
*
|
|
1395
|
+
* @param parentNode - The parent element containing the nodes
|
|
1396
|
+
* @param a - The old array of nodes (currently in DOM)
|
|
1397
|
+
* @param b - The new array of nodes (target state)
|
|
1398
|
+
*
|
|
1399
|
+
* @example
|
|
1400
|
+
* ```ts
|
|
1401
|
+
* const oldNodes = [node1, node2, node3]
|
|
1402
|
+
* const newNodes = [node1, node4, node3] // node2 replaced with node4
|
|
1403
|
+
* reconcileArrays(parent, oldNodes, newNodes)
|
|
1404
|
+
* ```
|
|
1405
|
+
*/
|
|
1406
|
+
declare function reconcileArrays(parentNode: ParentNode, a: Node[], b: Node[]): void;
|
|
1407
|
+
|
|
1408
|
+
interface FictDevtoolsHook {
|
|
1409
|
+
registerSignal: (id: number, value: unknown) => void;
|
|
1410
|
+
updateSignal: (id: number, value: unknown) => void;
|
|
1411
|
+
registerEffect: (id: number) => void;
|
|
1412
|
+
effectRun: (id: number) => void;
|
|
1413
|
+
cycleDetected?: (payload: {
|
|
1414
|
+
reason: string;
|
|
1415
|
+
detail?: Record<string, unknown>;
|
|
1416
|
+
}) => void;
|
|
1417
|
+
}
|
|
1418
|
+
declare function getDevtoolsHook(): FictDevtoolsHook | undefined;
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* Low-level DOM node helpers shared across runtime modules.
|
|
1422
|
+
* Keep this file dependency-free to avoid module cycles.
|
|
1423
|
+
*/
|
|
1424
|
+
/**
|
|
1425
|
+
* Convert a value to a flat array of DOM nodes.
|
|
1426
|
+
* Defensively handles proxies and non-DOM values.
|
|
1427
|
+
*/
|
|
1428
|
+
declare function toNodeArray(node: Node | Node[] | unknown): Node[];
|
|
1429
|
+
/**
|
|
1430
|
+
* Insert nodes before an anchor node, preserving order.
|
|
1431
|
+
* Uses DocumentFragment for batch insertion when inserting multiple nodes.
|
|
1432
|
+
*/
|
|
1433
|
+
declare function insertNodesBefore(parent: ParentNode & Node, nodes: Node[], anchor: Node | null): void;
|
|
1434
|
+
/**
|
|
1435
|
+
* Remove an array of nodes from the DOM.
|
|
1436
|
+
*/
|
|
1437
|
+
declare function removeNodes(nodes: Node[]): void;
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* List Helpers for Compiler-Generated Fine-Grained Updates
|
|
1441
|
+
*
|
|
1442
|
+
* These helpers are used by the compiler to generate efficient keyed list rendering.
|
|
1443
|
+
* They provide low-level primitives for DOM node manipulation without rebuilding.
|
|
1444
|
+
*/
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* A keyed block represents a single item in a list with its associated DOM nodes and state
|
|
1448
|
+
*/
|
|
1449
|
+
interface KeyedBlock<T = unknown> {
|
|
1450
|
+
/** Unique key for this block */
|
|
1451
|
+
key: string | number;
|
|
1452
|
+
/** DOM nodes belonging to this block */
|
|
1453
|
+
nodes: Node[];
|
|
1454
|
+
/** Root context for lifecycle management */
|
|
1455
|
+
root: RootContext;
|
|
1456
|
+
/** Signal containing the current item value */
|
|
1457
|
+
item: SignalAccessor<T>;
|
|
1458
|
+
/** Signal containing the current index */
|
|
1459
|
+
index: SignalAccessor<number>;
|
|
1460
|
+
/** Last raw item value assigned to this block */
|
|
1461
|
+
rawItem: T;
|
|
1462
|
+
/** Last raw index value assigned to this block */
|
|
1463
|
+
rawIndex: number;
|
|
1464
|
+
}
|
|
1465
|
+
/**
|
|
1466
|
+
* Container for managing keyed list blocks
|
|
1467
|
+
*/
|
|
1468
|
+
interface KeyedListContainer<T = unknown> {
|
|
1469
|
+
/** Start marker comment node */
|
|
1470
|
+
startMarker: Comment;
|
|
1471
|
+
/** End marker comment node */
|
|
1472
|
+
endMarker: Comment;
|
|
1473
|
+
/** Map of key to block */
|
|
1474
|
+
blocks: Map<string | number, KeyedBlock<T>>;
|
|
1475
|
+
/** Scratch map reused for the next render */
|
|
1476
|
+
nextBlocks: Map<string | number, KeyedBlock<T>>;
|
|
1477
|
+
/** Current nodes in DOM order (including markers) */
|
|
1478
|
+
currentNodes: Node[];
|
|
1479
|
+
/** Next-frame node buffer to avoid reallocations */
|
|
1480
|
+
nextNodes: Node[];
|
|
1481
|
+
/** Ordered blocks in current DOM order */
|
|
1482
|
+
orderedBlocks: KeyedBlock<T>[];
|
|
1483
|
+
/** Next-frame ordered block buffer to avoid reallocations */
|
|
1484
|
+
nextOrderedBlocks: KeyedBlock<T>[];
|
|
1485
|
+
/** Track position of keys in the ordered buffer to handle duplicates */
|
|
1486
|
+
orderedIndexByKey: Map<string | number, number>;
|
|
1487
|
+
/** Cleanup function */
|
|
1488
|
+
dispose: () => void;
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Binding handle returned by createKeyedList for compiler-generated code
|
|
1492
|
+
*/
|
|
1493
|
+
interface KeyedListBinding {
|
|
1494
|
+
/** Document fragment placeholder inserted by the compiler/runtime */
|
|
1495
|
+
marker: DocumentFragment;
|
|
1496
|
+
/** Start marker comment node */
|
|
1497
|
+
startMarker: Comment;
|
|
1498
|
+
/** End marker comment node */
|
|
1499
|
+
endMarker: Comment;
|
|
1500
|
+
/** Flush pending items - call after markers are inserted into DOM */
|
|
1501
|
+
flush?: () => void;
|
|
1502
|
+
/** Cleanup function */
|
|
1503
|
+
dispose: () => void;
|
|
1504
|
+
}
|
|
1505
|
+
type FineGrainedRenderItem<T> = (itemSig: SignalAccessor<T>, indexSig: SignalAccessor<number>, key: string | number) => Node[];
|
|
1506
|
+
/**
|
|
1507
|
+
* A block identified by start/end comment markers.
|
|
1508
|
+
*/
|
|
1509
|
+
interface MarkerBlock {
|
|
1510
|
+
start: Comment;
|
|
1511
|
+
end: Comment;
|
|
1512
|
+
root?: RootContext;
|
|
1513
|
+
}
|
|
1514
|
+
/**
|
|
1515
|
+
* Move nodes to a position before the anchor node.
|
|
1516
|
+
* This is optimized to avoid unnecessary DOM operations.
|
|
1517
|
+
*
|
|
1518
|
+
* @param parent - Parent node to move nodes within
|
|
1519
|
+
* @param nodes - Array of nodes to move
|
|
1520
|
+
* @param anchor - Node to insert before (or null for end)
|
|
1521
|
+
*/
|
|
1522
|
+
declare function moveNodesBefore(parent: Node, nodes: Node[], anchor: Node | null): void;
|
|
1523
|
+
/**
|
|
1524
|
+
* Remove an array of nodes from the DOM
|
|
1525
|
+
*
|
|
1526
|
+
* @param nodes - Array of nodes to remove
|
|
1527
|
+
*/
|
|
1528
|
+
/**
|
|
1529
|
+
* Move an entire marker-delimited block (including markers) before the anchor.
|
|
1530
|
+
*/
|
|
1531
|
+
declare function moveMarkerBlock(parent: Node, block: MarkerBlock, anchor: Node | null): void;
|
|
1532
|
+
/**
|
|
1533
|
+
* Destroy a marker-delimited block, removing nodes and destroying the associated root.
|
|
1534
|
+
*/
|
|
1535
|
+
declare function destroyMarkerBlock(block: MarkerBlock): void;
|
|
1536
|
+
/**
|
|
1537
|
+
* Create a container for managing a keyed list.
|
|
1538
|
+
* This sets up the marker nodes and provides cleanup.
|
|
1539
|
+
*
|
|
1540
|
+
* @returns Container object with markers, blocks map, and dispose function
|
|
1541
|
+
*/
|
|
1542
|
+
declare function createKeyedListContainer<T = unknown>(): KeyedListContainer<T>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Create a new keyed block with the given render function
|
|
1545
|
+
*
|
|
1546
|
+
* @param key - Unique key for this block
|
|
1547
|
+
* @param item - Initial item value
|
|
1548
|
+
* @param index - Initial index
|
|
1549
|
+
* @param render - Function that creates the DOM nodes and sets up bindings
|
|
1550
|
+
* @returns New KeyedBlock
|
|
1551
|
+
*/
|
|
1552
|
+
declare function createKeyedBlock<T>(key: string | number, item: T, index: number, render: (item: SignalAccessor<T>, index: SignalAccessor<number>, key: string | number) => Node[], needsIndex?: boolean): KeyedBlock<T>;
|
|
1553
|
+
/**
|
|
1554
|
+
* Find the first node after the start marker (for getting current anchor)
|
|
1555
|
+
*/
|
|
1556
|
+
declare function getFirstNodeAfter(marker: Comment): Node | null;
|
|
1557
|
+
/**
|
|
1558
|
+
* Check if a node is between two markers
|
|
1559
|
+
*/
|
|
1560
|
+
declare function isNodeBetweenMarkers(node: Node, startMarker: Comment, endMarker: Comment): boolean;
|
|
1561
|
+
/**
|
|
1562
|
+
* Create a keyed list binding with automatic diffing and DOM updates.
|
|
1563
|
+
* This is used by compiler-generated code for efficient list rendering.
|
|
1564
|
+
*
|
|
1565
|
+
* @param getItems - Function that returns the current array of items
|
|
1566
|
+
* @param keyFn - Function to extract unique key from each item
|
|
1567
|
+
* @param renderItem - Function that creates DOM nodes for each item
|
|
1568
|
+
* @returns Binding handle with markers and dispose function
|
|
1569
|
+
*/
|
|
1570
|
+
declare function createKeyedList<T>(getItems: () => T[], keyFn: (item: T, index: number) => string | number, renderItem: FineGrainedRenderItem<T>, needsIndex?: boolean): KeyedListBinding;
|
|
1571
|
+
|
|
1572
|
+
export { $effect, $memo, $state, Aliases, type AttributeSetter, type BaseProps, type BindingHandle, BooleanAttributes, ChildProperties, type ClassProp, type Cleanup, type Component, type CreateElementFn, type DOMElement, DelegatedEvents, type Effect, ErrorBoundary, type ErrorInfo, type EventHandler, type FictDevtoolsHook, type FictNode, type FictVNode, Fragment, JSX, type KeyFn, type KeyedBlock, type KeyedListBinding, type KeyedListContainer, type MarkerBlock, type MaybeReactive, type Memo, Properties, type PropsWithChildren, type Ref, type RefCallback, type RefObject, SVGElements, SVGNamespace, type SignalAccessor as Signal, type Store, type StyleProp, Suspense, type SuspenseToken, UnitlessStyles, type VersionedSignal, type VersionedSignalOptions, __fictPopContext, __fictProp, __fictPropsRest, __fictPushContext, __fictRender, __fictResetContext, __fictUseContext, __fictUseEffect, __fictUseMemo, __fictUseSignal, addEventListener, assign, batch, bindAttribute, bindClass, bindEvent, bindProperty, bindRef, bindStyle, bindText, classList, clearDelegatedEvents, createAttributeBinding, createChildBinding, createClassBinding, createConditional, createEffect, createElement, createKeyedBlock, createKeyedList, createKeyedListContainer, createList, createMemo, createPortal, createPropsProxy, createRef, createRenderEffect, createRoot, createSelector, createShow, signal as createSignal, createStore, createStyleBinding, createSuspenseToken, createTextBinding, createVersionedSignal, delegateEvents, destroyMarkerBlock, getDevtoolsHook, getFirstNodeAfter, getPropAlias, insert, insertNodesBefore, isNodeBetweenMarkers, isReactive, mergeProps, moveMarkerBlock, moveNodesBefore, onCleanup, onDestroy, onMount, __fictProp as prop, reconcileArrays, removeNodes, render, setCycleProtectionOptions, spread, startTransition, template, toNodeArray, untrack, unwrap, unwrapPrimitive, useDeferredValue, useProp, useTransition };
|