elements-kit 0.22.0 → 0.23.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/LICENSE +201 -21
- package/README.md +30 -13
- package/dist/await.d.mts +1 -1
- package/dist/await.mjs +4 -6
- package/dist/children-BbHF-Dew.d.mts +253 -0
- package/dist/{element-Di0PYFX1.mjs → element-w3nDE2S5.mjs} +2 -2
- package/dist/environment-Fg46vL6e.d.mts +19 -0
- package/dist/for.d.mts +1 -1
- package/dist/for.mjs +1 -1
- package/dist/{fragment-Bvs1sGu1.mjs → fragment-DEhI5x0f.mjs} +2 -3
- package/dist/hydrate/index.mjs +1 -1
- package/dist/{hydrate-CHomBRY9.mjs → hydrate-CrVzu88K.mjs} +5 -5
- package/dist/index-BR8XVkck.d.mts +392 -0
- package/dist/integrations/astro-client.mjs +2 -2
- package/dist/integrations/astro-server.mjs +3 -4
- package/dist/integrations/astro-slots.mjs +2 -2
- package/dist/integrations/react.d.mts +1 -1
- package/dist/jsx-runtime/index.d.mts +3 -2
- package/dist/jsx-runtime/index.mjs +2 -2
- package/dist/server/index.mjs +1 -1
- package/dist/{server-CTkyXTV6.mjs → server-D7ffi7b_.mjs} +4 -4
- package/dist/signals/index.d.mts +2 -2
- package/dist/signals/index.mjs +30 -20
- package/dist/ui/otp-input/index.d.mts +5 -4
- package/dist/ui/otp-input/index.mjs +5 -5
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/async.d.mts +2 -2
- package/dist/utilities/async.mjs +13 -5
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/environment.d.mts +2 -7
- package/dist/utilities/environment.mjs +13 -1
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/package.json +1 -1
- package/dist/children-s3nFjpLA.d.mts +0 -581
- /package/dist/{polyfill-BVNd6ogU.d.mts → polyfill-C-CxgMqq.d.mts} +0 -0
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-DILeh3-s.mjs";
|
|
2
|
-
import { i as PropertiesOf, n as CustomElementRegistry, r as EventsOf } from "./custom-elements-CdpilMDu.mjs";
|
|
3
|
-
import * as CSS from "csstype";
|
|
4
|
-
import { JSX } from "dom-expressions/src/jsx";
|
|
5
|
-
|
|
6
|
-
//#region src/signals/lib.d.ts
|
|
7
|
-
declare const SIGNAL: unique symbol;
|
|
8
|
-
declare const COMPUTED: unique symbol;
|
|
9
|
-
declare const EFFECT: unique symbol;
|
|
10
|
-
declare const EFFECT_SCOPE: unique symbol;
|
|
11
|
-
/**
|
|
12
|
-
* Returns `true` if `fn` is a signal handle created by {@link signal}.
|
|
13
|
-
*
|
|
14
|
-
* Relies on the SIGNAL symbol.
|
|
15
|
-
*/
|
|
16
|
-
declare function isSignal(fn: unknown): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Returns `true` if `fn` is a computed handle created by {@link computed}.
|
|
19
|
-
*
|
|
20
|
-
* Relies on the COMPUTED symbol.
|
|
21
|
-
*/
|
|
22
|
-
declare function isComputed(fn: unknown): boolean;
|
|
23
|
-
/**
|
|
24
|
-
* Returns `true` if `fn` is an effect cleanup handle created by {@link effect}.
|
|
25
|
-
*
|
|
26
|
-
* Relies on the EFFECT symbol.
|
|
27
|
-
*/
|
|
28
|
-
declare function isEffect(fn: unknown): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Returns `true` if `fn` is an effectScope cleanup handle created by
|
|
31
|
-
* {@link effectScope}.
|
|
32
|
-
*
|
|
33
|
-
* Relies on `Function.name` matching the internal `effectScopeOper` function name.
|
|
34
|
-
*/
|
|
35
|
-
declare function isEffectScope(fn: () => void): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Creates a mutable reactive signal.
|
|
38
|
-
*
|
|
39
|
-
* - **Read**: call with no arguments → returns the current value and
|
|
40
|
-
* subscribes the active tracking context.
|
|
41
|
-
* - **Write**: call with a value → updates the signal and schedules
|
|
42
|
-
* downstream effects if the value changed.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* const count = signal(0);
|
|
47
|
-
* count(); // → 0 (read)
|
|
48
|
-
* count(1); // write – effects depending on count will re-run
|
|
49
|
-
* count(); // → 1
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
declare function signal<T>(): Updater<T> & Computed<T>;
|
|
53
|
-
declare function signal<T>(initialValue: T): Updater<T> & Computed<T>;
|
|
54
|
-
/**
|
|
55
|
-
* Creates a lazily-evaluated computed value.
|
|
56
|
-
*
|
|
57
|
-
* The `getter` is only called when the computed value is read **and** one of
|
|
58
|
-
* its dependencies has changed since the last evaluation. If nothing has
|
|
59
|
-
* changed the cached `value` is returned without re-running `getter`.
|
|
60
|
-
*
|
|
61
|
-
* Computed values are read-only; they cannot be set directly.
|
|
62
|
-
*
|
|
63
|
-
* @param getter - Pure function deriving a value from other reactive sources.
|
|
64
|
-
* Receives the previous value as an optional optimisation hint.
|
|
65
|
-
*
|
|
66
|
-
* @example
|
|
67
|
-
* ```ts
|
|
68
|
-
* const a = signal(1);
|
|
69
|
-
* const b = signal(2);
|
|
70
|
-
* const sum = computed(() => a() + b());
|
|
71
|
-
*
|
|
72
|
-
* sum(); // → 3
|
|
73
|
-
* a(10);
|
|
74
|
-
* sum(); // → 12 (re-evaluated lazily)
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
declare function computed<T>(getter: (previousValue?: T) => T): () => T;
|
|
78
|
-
/**
|
|
79
|
-
* Creates a reactive side-effect that runs immediately and re-runs whenever
|
|
80
|
-
* any signal or computed it read during its last execution changes.
|
|
81
|
-
*
|
|
82
|
-
* Use {@link onCleanup} inside `fn` to register teardown logic that runs
|
|
83
|
-
* before each re-execution and on final disposal.
|
|
84
|
-
*
|
|
85
|
-
* If `effect` is called inside an `effectScope` or another `effect`, the
|
|
86
|
-
* new effect is automatically owned by the outer scope and will be disposed
|
|
87
|
-
* when the scope is disposed.
|
|
88
|
-
*
|
|
89
|
-
* @param fn - The side-effect body. Reactive reads inside this function
|
|
90
|
-
* establish dependency links.
|
|
91
|
-
* @returns A disposal function. Call it to stop the effect and run any
|
|
92
|
-
* registered cleanup.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* const url = signal('/api/data');
|
|
97
|
-
*
|
|
98
|
-
* const stop = effect(() => {
|
|
99
|
-
* const controller = new AbortController();
|
|
100
|
-
* fetch(url(), { signal: controller.signal });
|
|
101
|
-
* onCleanup(() => controller.abort());
|
|
102
|
-
* });
|
|
103
|
-
*
|
|
104
|
-
* url('/api/other'); // previous fetch is aborted, new one starts
|
|
105
|
-
* stop(); // final cleanup: abort the last fetch
|
|
106
|
-
* ```
|
|
107
|
-
*/
|
|
108
|
-
/**
|
|
109
|
-
* @internal Method key for settling a reactive async wrapper from a
|
|
110
|
-
* serialized server snapshot (hydration seeding). Lives here so
|
|
111
|
-
* `utilities/promise`, `utilities/async` and `hydrate` can share it without
|
|
112
|
-
* a utility-to-utility dependency.
|
|
113
|
-
*/
|
|
114
|
-
declare const SEED: unique symbol;
|
|
115
|
-
/**
|
|
116
|
-
* @internal Method key for the hydrate claim protocol: the claim walk hands
|
|
117
|
-
* each async wrapper its ek-data record (or undefined). The wrapper decides —
|
|
118
|
-
* seed and discard any deferred run, or execute the deferred run now.
|
|
119
|
-
*/
|
|
120
|
-
declare const CLAIM: unique symbol;
|
|
121
|
-
declare function effect(fn: () => void): () => void;
|
|
122
|
-
/**
|
|
123
|
-
* Creates an ownership scope that groups reactive effects so they can all be
|
|
124
|
-
* disposed at once.
|
|
125
|
-
*
|
|
126
|
-
* Effects and nested scopes created inside `fn` are linked to this scope.
|
|
127
|
-
* When the returned disposal function is called, all owned effects are stopped
|
|
128
|
-
* in cascade – triggering their registered {@link onCleanup} callbacks – and
|
|
129
|
-
* the scope itself is removed from any parent scope that owns it.
|
|
130
|
-
*
|
|
131
|
-
* @param fn - Synchronous setup function. Create effects and nested scopes
|
|
132
|
-
* here.
|
|
133
|
-
* @returns A disposal function that tears down all owned effects and the scope
|
|
134
|
-
* itself.
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* ```ts
|
|
138
|
-
* const stopAll = effectScope(() => {
|
|
139
|
-
* effect(() => console.log('a:', a()));
|
|
140
|
-
* effect(() => console.log('b:', b()));
|
|
141
|
-
* });
|
|
142
|
-
*
|
|
143
|
-
* stopAll(); // both effects stopped simultaneously
|
|
144
|
-
* ```
|
|
145
|
-
*/
|
|
146
|
-
declare function effectScope(fn: () => void): () => void;
|
|
147
|
-
/**
|
|
148
|
-
* Registers a cleanup callback for the currently executing effect or scope.
|
|
149
|
-
*
|
|
150
|
-
* The callback will be called:
|
|
151
|
-
* 1. **Before the next re-run** of the enclosing effect (so resources from
|
|
152
|
-
* the previous run are released before the new run sets them up again).
|
|
153
|
-
* 2. **On final disposal** of the effect, whether triggered explicitly by
|
|
154
|
-
* calling the effect's cleanup handle or implicitly by an owning
|
|
155
|
-
* `effectScope` being disposed.
|
|
156
|
-
*
|
|
157
|
-
* Calling `onCleanup` outside of a tracking context (no active effect) is a
|
|
158
|
-
* no-op; it does **not** throw.
|
|
159
|
-
*
|
|
160
|
-
* Only one cleanup function per effect run is supported. Calling `onCleanup`
|
|
161
|
-
* multiple times within the same run overwrites the previous registration.
|
|
162
|
-
*
|
|
163
|
-
* @param fn - The teardown callback.
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* ```ts
|
|
167
|
-
* effect(() => {
|
|
168
|
-
* const id = setInterval(() => tick(), 1000);
|
|
169
|
-
* onCleanup(() => clearInterval(id));
|
|
170
|
-
* });
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* @example Composable helper – no prop-drilling needed:
|
|
174
|
-
* ```ts
|
|
175
|
-
* function useEventListener(target: EventTarget, type: string, handler: EventListener) {
|
|
176
|
-
* target.addEventListener(type, handler);
|
|
177
|
-
* onCleanup(() => target.removeEventListener(type, handler));
|
|
178
|
-
* }
|
|
179
|
-
*
|
|
180
|
-
* effect(() => {
|
|
181
|
-
* useEventListener(window, 'resize', onResize);
|
|
182
|
-
* });
|
|
183
|
-
* ```
|
|
184
|
-
*/
|
|
185
|
-
declare function onCleanup(fn: () => void): void;
|
|
186
|
-
/**
|
|
187
|
-
* Runs `fn` as a single atomic update: all signal writes inside `fn` are
|
|
188
|
-
* collected and effects are flushed only once after `fn` returns, rather than
|
|
189
|
-
* after each individual write.
|
|
190
|
-
*
|
|
191
|
-
* Batches can be nested; the flush only occurs when the outermost batch
|
|
192
|
-
* completes.
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* ```ts
|
|
196
|
-
* batch(() => {
|
|
197
|
-
* x(1);
|
|
198
|
-
* y(2);
|
|
199
|
-
* z(3);
|
|
200
|
-
* }); // effects that depend on x, y, or z run once here
|
|
201
|
-
* ```
|
|
202
|
-
*/
|
|
203
|
-
declare function batch(fn: () => void): void;
|
|
204
|
-
/**
|
|
205
|
-
* Executes `fn` in a non-tracking context: any signals read inside `fn` do
|
|
206
|
-
* **not** create dependency links on the currently active subscriber.
|
|
207
|
-
*
|
|
208
|
-
* Useful when you need to read a signal's current value without subscribing to
|
|
209
|
-
* future changes.
|
|
210
|
-
*
|
|
211
|
-
* @returns The value returned by `fn`.
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```ts
|
|
215
|
-
* const logCount = effect(() => {
|
|
216
|
-
* console.log('triggered by a:', a());
|
|
217
|
-
* // read b without subscribing – effect won't re-run when b changes
|
|
218
|
-
* console.log('current b:', untracked(b));
|
|
219
|
-
* });
|
|
220
|
-
* ```
|
|
221
|
-
*/
|
|
222
|
-
declare function untracked<T>(fn: Computed<T>): T;
|
|
223
|
-
/**
|
|
224
|
-
* Manually triggers all subscribers of every signal read inside `fn`.
|
|
225
|
-
*
|
|
226
|
-
* Unlike writing to a signal, `trigger` does not change the signal's value; it
|
|
227
|
-
* only forces downstream effects and computeds to re-evaluate.
|
|
228
|
-
*
|
|
229
|
-
* @param fn - Function whose reactive reads identify the signals to trigger.
|
|
230
|
-
*
|
|
231
|
-
* @example
|
|
232
|
-
* ```ts
|
|
233
|
-
* const items = signal([1, 2, 3]);
|
|
234
|
-
*
|
|
235
|
-
* // Mutate in place (referential equality won't detect the change):
|
|
236
|
-
* items().push(4);
|
|
237
|
-
* trigger(items); // manually notify subscribers
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
declare function trigger<T = void>(fn: Computed<T>): void;
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region src/signals/index.d.ts
|
|
243
|
-
/**
|
|
244
|
-
* Type-guard: `true` when `value` is a reactive source (`signal` or `computed`),
|
|
245
|
-
* `false` when it is a plain value.
|
|
246
|
-
*
|
|
247
|
-
* Use this when you accept {@link MaybeReactive} and need to branch on whether
|
|
248
|
-
* the caller passed a live source or a static value.
|
|
249
|
-
*
|
|
250
|
-
* @example
|
|
251
|
-
* ```ts
|
|
252
|
-
* import { signal, isReactive } from "elements-kit/signals";
|
|
253
|
-
*
|
|
254
|
-
* const a: MaybeReactive<number> = 5;
|
|
255
|
-
* const b: MaybeReactive<number> = signal(0);
|
|
256
|
-
* const c: () => number = () => 5;
|
|
257
|
-
*
|
|
258
|
-
* isReactive(a); // false
|
|
259
|
-
* isReactive(b); // true
|
|
260
|
-
* isReactive(c); // false
|
|
261
|
-
* ```
|
|
262
|
-
*/
|
|
263
|
-
declare function isReactive<T>(value: MaybeReactive<T>): value is () => T;
|
|
264
|
-
/** Writer half of a {@link Signal}: `sig(next)` assigns a new value. */
|
|
265
|
-
type Updater<T> = (value: T) => void;
|
|
266
|
-
/** Zero-arg getter that subscribes the current tracking scope on call. */
|
|
267
|
-
type Computed<T> = () => T;
|
|
268
|
-
/**
|
|
269
|
-
* A reactive read/write cell — callable as both a getter (no args) and a
|
|
270
|
-
* setter (one arg).
|
|
271
|
-
*
|
|
272
|
-
* @example
|
|
273
|
-
* ```ts
|
|
274
|
-
* import { signal } from "elements-kit/signals";
|
|
275
|
-
*
|
|
276
|
-
* const count: Signal<number> = signal(0);
|
|
277
|
-
* count(); // read → 0 (subscribes the active scope)
|
|
278
|
-
* count(5); // write → notifies subscribers
|
|
279
|
-
* ```
|
|
280
|
-
*/
|
|
281
|
-
type Signal<T> = Updater<T> & Computed<T>;
|
|
282
|
-
/**
|
|
283
|
-
* A decorator that makes a class field reactive by automatically wrapping its value in a signal.
|
|
284
|
-
*
|
|
285
|
-
* The field behaves like a normal property (get/set) but reactivity is tracked under the hood.
|
|
286
|
-
* Any reads will subscribe to the signal and any writes will trigger updates.
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
* ```ts
|
|
290
|
-
* class Counter {
|
|
291
|
-
* \@reactive() count: number = 0;
|
|
292
|
-
* }
|
|
293
|
-
*
|
|
294
|
-
* const counter = new Counter();
|
|
295
|
-
* counter.count++; // Triggers reactivity
|
|
296
|
-
* console.log(counter.count); // Subscribes to changes
|
|
297
|
-
* ```
|
|
298
|
-
*
|
|
299
|
-
* @remarks
|
|
300
|
-
* Equivalent to manually creating a private signal and getter/setter:
|
|
301
|
-
* ```ts
|
|
302
|
-
* class Counter {
|
|
303
|
-
* #count = signal(0);
|
|
304
|
-
* get count() { return this.#count(); }
|
|
305
|
-
* set count(value) { this.#count(value); }
|
|
306
|
-
* }
|
|
307
|
-
* ```
|
|
308
|
-
*/
|
|
309
|
-
declare function reactive<This extends object, Value>(source?: (self: This) => Signal<Value>): (_target: unknown, context: ClassFieldDecoratorContext<This, Value>) => (this: This, initialValue: Value) => Value;
|
|
310
|
-
/**
|
|
311
|
-
* A value that may be static or reactive. Accepts a plain `T` or a
|
|
312
|
-
* zero-arg getter (`() => T`) — typically a `signal` or `computed`.
|
|
313
|
-
*
|
|
314
|
-
* Used across the library anywhere a prop or attribute may be bound to
|
|
315
|
-
* reactive state. Resolve with {@link resolve}, detect with {@link isReactive}.
|
|
316
|
-
*
|
|
317
|
-
* @template T — the value type.
|
|
318
|
-
*
|
|
319
|
-
* @example
|
|
320
|
-
* ```ts
|
|
321
|
-
* import { signal, computed } from "elements-kit/signals";
|
|
322
|
-
*
|
|
323
|
-
* const count = signal(0);
|
|
324
|
-
* const double = computed(() => count() * 2);
|
|
325
|
-
*
|
|
326
|
-
* const a: MaybeReactive<number> = 5; // static
|
|
327
|
-
* const b: MaybeReactive<number> = count; // signal (getter)
|
|
328
|
-
* const c: MaybeReactive<number> = double; // computed (getter)
|
|
329
|
-
* ```
|
|
330
|
-
*/
|
|
331
|
-
type MaybeReactive<T> = T | Computed<T>;
|
|
332
|
-
/**
|
|
333
|
-
* Resolve a {@link MaybeReactive} to its current value. Calls the getter
|
|
334
|
-
* when reactive; returns the value as-is when static.
|
|
335
|
-
*
|
|
336
|
-
* @example
|
|
337
|
-
* ```ts
|
|
338
|
-
* resolve(5); // 5
|
|
339
|
-
* resolve(() => count()); // current count value
|
|
340
|
-
* ```
|
|
341
|
-
*/
|
|
342
|
-
declare function resolve<T>(value: MaybeReactive<T>): T;
|
|
343
|
-
declare function resolveProps<P extends object>(raw: { [K in keyof P]: MaybeReactive<P[K]> }): Props<P>;
|
|
344
|
-
//#endregion
|
|
345
|
-
//#region src/jsx-runtime/infer.d.ts
|
|
346
|
-
/**
|
|
347
|
-
* Promote keys `K` of `P` to required; leave the rest unchanged.
|
|
348
|
-
*
|
|
349
|
-
* @template P — the prop object type.
|
|
350
|
-
* @template K — the keys to make required.
|
|
351
|
-
*
|
|
352
|
-
* @example
|
|
353
|
-
* ```ts
|
|
354
|
-
* type Optional = { a?: number; b?: string; c?: boolean };
|
|
355
|
-
* type AB = Require<Optional, "a" | "b">;
|
|
356
|
-
* // { a: number; b: string; c?: boolean }
|
|
357
|
-
* ```
|
|
358
|
-
*/
|
|
359
|
-
type Require<P, K extends keyof P> = { [X in K]-?: P[X] } & Omit<P, K>;
|
|
360
|
-
declare const RAW_PROPS: unique symbol;
|
|
361
|
-
type Props<P> = { readonly [K in keyof P]: Computed<P[K]> } & {
|
|
362
|
-
readonly [RAW_PROPS]?: P;
|
|
363
|
-
};
|
|
364
|
-
/** Recover the raw prop shape `P` from a `Props<P>`. */
|
|
365
|
-
type RawProps<R> = R extends {
|
|
366
|
-
readonly [RAW_PROPS]?: infer P;
|
|
367
|
-
} ? P : R;
|
|
368
|
-
/**
|
|
369
|
-
* Caller-facing wrap: each key accepts a plain value OR a reactive getter.
|
|
370
|
-
* The JSX checker applies it automatically to component props; name it
|
|
371
|
-
* directly when typing a call-site shape by hand (e.g. a class component's
|
|
372
|
-
* constructor param, like `For`'s). Function-typed props are wrapped too
|
|
373
|
-
* (`Computed<F>` is zero-arg, so TS still picks the handler signature by
|
|
374
|
-
* arity for inline arrows). `Signal<F>` must never be added explicitly — its
|
|
375
|
-
* one-arg `Updater` half would collapse inline arrow params to implicit any.
|
|
376
|
-
*/
|
|
377
|
-
type MaybeReactiveProps<P> = { [K in keyof P]: undefined extends P[K] ? MaybeReactive<Exclude<P[K], undefined>> | undefined : MaybeReactive<P[K]> };
|
|
378
|
-
/**
|
|
379
|
-
* @internal Call-site prop resolution for `JSX.LibraryManagedAttributes`:
|
|
380
|
-
* - empty param (instance-field classes, no ctor) → wrap `PropsOf<C>`
|
|
381
|
-
* - branded `Props<P>` param (function components) → wrap the raw `P`
|
|
382
|
-
* - non-empty constructor param → pass through (preserves `For<T>` inference)
|
|
383
|
-
*
|
|
384
|
-
* Emptiness is checked FIRST: `{}` structurally matches the optional brand
|
|
385
|
-
* (`{} extends { [RAW_PROPS]?: infer Raw }` with `Raw = unknown`), which
|
|
386
|
-
* would silently type every no-ctor class as `MaybeReactiveProps<unknown>`
|
|
387
|
-
* (= `{}`, accepting anything). A real `Props<P>` is never empty — its
|
|
388
|
-
* `keyof` always contains the brand symbol.
|
|
389
|
-
*/
|
|
390
|
-
type ResolveProps<C, P, NN = NonNullable<P>> = [keyof NN] extends [never] ? C extends JSX$1.ElementType | JSX$1.ElementClass ? MaybeReactiveProps<PropsOf<C>> : {} : NN extends {
|
|
391
|
-
readonly [RAW_PROPS]?: infer Raw;
|
|
392
|
-
} ? MaybeReactiveProps<Raw> : NN;
|
|
393
|
-
type PropKeysOf<C> = keyof PropertiesOf<C> & string;
|
|
394
|
-
type AttrMap<C> = C extends {
|
|
395
|
-
[ATTRIBUTES]: infer M;
|
|
396
|
-
} ? M : {};
|
|
397
|
-
type HandlerValue<H> = H extends AttrChangeHandler<any> ? string | null : H;
|
|
398
|
-
type AttrsOf<C> = AttrMap<C> extends infer M ? M extends Record<string, unknown> ? string extends keyof M ? {} : { [K in Exclude<keyof M & string, PropKeysOf<C>>]?: HandlerValue<M[K]> } : {} : {};
|
|
399
|
-
type PropNamespacedOf<C> = { [K in PropKeysOf<C> as `prop:${K}`]?: NonNullable<PropertiesOf<C>[K]> };
|
|
400
|
-
type JsxEventsOf<C> = { [K in keyof EventsOf<C> & string as `on:${K}`]?: (ev: EventsOf<C>[K]) => void };
|
|
401
|
-
type ChildrenOf<C> = C extends {
|
|
402
|
-
children: never;
|
|
403
|
-
} ? {} : {
|
|
404
|
-
children?: Children;
|
|
405
|
-
};
|
|
406
|
-
type BaseDOMAttrs = JSX.DOMAttributes<HTMLElement>;
|
|
407
|
-
/**
|
|
408
|
-
* Full JSX prop type for a custom-element class (extends `HTMLElement`).
|
|
409
|
-
*
|
|
410
|
-
* Composes every surface the element can receive from JSX:
|
|
411
|
-
* - **Attributes** — keys from `static [ATTRIBUTES]` (typed `MaybeReactive<string | null>`).
|
|
412
|
-
* Keys also present on the instance are dropped here so the flat key carries the property type.
|
|
413
|
-
* - **Flat properties** — public instance fields, wrapped in `MaybeReactive`.
|
|
414
|
-
* - **`prop:*`** — explicit property assignment for every field.
|
|
415
|
-
* - **Events** — keys from `declare static events: { ... }` produce
|
|
416
|
-
* `on:${K}` typed handlers (the only event syntax the runtime attaches).
|
|
417
|
-
* - **Children** — `children?: Child` unless `static children: never`.
|
|
418
|
-
* - **DOM attrs** — the standard dom-expressions surface (`class`, `style`, `ref`, …).
|
|
419
|
-
*
|
|
420
|
-
* @template C — the custom-element class (constructor type).
|
|
421
|
-
*
|
|
422
|
-
* @example
|
|
423
|
-
* ```ts
|
|
424
|
-
* \@attributes
|
|
425
|
-
* class XRange extends HTMLElement {
|
|
426
|
-
* static [ATTRIBUTES]: Attributes<XRange> = { min(v) { this.min = +v! } };
|
|
427
|
-
* declare static events: { commit: CustomEvent<number> };
|
|
428
|
-
* #slot = new Slot();
|
|
429
|
-
* get label() { return this.#slot.get(); }
|
|
430
|
-
* set label(value: Node) { this.#slot.set(value) }
|
|
431
|
-
* \@reactive() min = 0;
|
|
432
|
-
* }
|
|
433
|
-
*
|
|
434
|
-
* type Props = ElementProps<typeof XRange>;
|
|
435
|
-
* // {
|
|
436
|
-
* // min?: MaybeReactive<number>;
|
|
437
|
-
* // "prop:min"?: number;
|
|
438
|
-
* // "on:commit"?: (e: CustomEvent<number>) => void;
|
|
439
|
-
* // label?: Node
|
|
440
|
-
* // children?: Node;
|
|
441
|
-
* // // …plus ref, class, class:*, style, style:*, standard DOM events
|
|
442
|
-
* // }
|
|
443
|
-
* ```
|
|
444
|
-
*
|
|
445
|
-
* @see {@link PropsOf} for class-components / function components (no attr/event synthesis).
|
|
446
|
-
*/
|
|
447
|
-
type ElementProps<C extends AnyElementCtor> = BaseDOMAttrs & AttrsOf<C> & PropertiesOf<C> & PropNamespacedOf<C> & JsxEventsOf<C> & ChildrenOf<C>;
|
|
448
|
-
/**
|
|
449
|
-
* Props for any component — class or function.
|
|
450
|
-
*
|
|
451
|
-
* The combination of the two specialised helpers:
|
|
452
|
-
* - **Custom-element constructor** (`typeof Cls`, `Cls extends HTMLElement`)
|
|
453
|
-
* → `ElementProps<Cls>` — the full JSX surface (attrs, `prop:*`, `on:*`,children).
|
|
454
|
-
* - **Everything else** (function component, class component ctor or
|
|
455
|
-
* instance) → `ComponentProps<T>` — the raw prop shape.
|
|
456
|
-
*
|
|
457
|
-
* @template T — constructor, function, or instance.
|
|
458
|
-
*
|
|
459
|
-
* @example
|
|
460
|
-
* ```ts
|
|
461
|
-
* // 1. Class instance (lets a generic flow)
|
|
462
|
-
* class For<T> { each: T[] = []; render() { return null } }
|
|
463
|
-
* type ForProps<T> = PropsOf<For<T>>;
|
|
464
|
-
* // ↑ { each?: T[] }
|
|
465
|
-
*
|
|
466
|
-
* // 2. Function component
|
|
467
|
-
* const Greeting = (_p: { name: string; excited?: boolean }) => null;
|
|
468
|
-
* type GreetingProps = PropsOf<typeof Greeting>;
|
|
469
|
-
* // ↑ { name: string; excited?: boolean }
|
|
470
|
-
*
|
|
471
|
-
* // 3. Class constructor
|
|
472
|
-
* class Counter { count = 0; render() { return null } }
|
|
473
|
-
* type CounterProps = PropsOf<typeof Counter>;
|
|
474
|
-
* // ↑ { count?: number }
|
|
475
|
-
* ```
|
|
476
|
-
*/
|
|
477
|
-
type PropsOf<T extends JSX$1.ElementType | JSX$1.ElementClass | AnyElementCtor> = T extends AnyElementCtor ? ElementProps<T> : T extends JSX$1.ElementType | JSX$1.ElementClass ? ComponentProps<T> : never;
|
|
478
|
-
/**
|
|
479
|
-
* Raw props of a function or class COMPONENT (not a custom element):
|
|
480
|
-
* function components use the first parameter (`RawProps` unwraps a branded
|
|
481
|
-
* `Props<P>`); classes use their public instance fields. The custom-element half of `PropsOf` is `ElementProps`.
|
|
482
|
-
*/
|
|
483
|
-
type ComponentProps<T extends JSX$1.ElementType | JSX$1.ElementClass> = T extends ((props: infer P, ...rest: any[]) => any) ? P extends object ? RawProps<P> : {} : PropertiesOf<T>;
|
|
484
|
-
type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
|
|
485
|
-
//#endregion
|
|
486
|
-
//#region src/jsx-runtime/element.d.ts
|
|
487
|
-
type UnsupportedDomKeys = "ref" | "children" | "classList" | "$ServerOnly" | keyof JSX.CustomEventHandlersCamelCase<any> | keyof JSX.CustomEventHandlersLowerCase<any> | keyof JSX.DirectiveAttributes | keyof JSX.DirectiveFunctionAttributes<any> | keyof JSX.AttrAttributes | keyof JSX.BoolAttributes | keyof JSX.OnCaptureAttributes<any>;
|
|
488
|
-
type DOMIntrinsicElements = { [K in keyof JSX.IntrinsicElements]: Omit<JSX.IntrinsicElements[K], UnsupportedDomKeys> };
|
|
489
|
-
type DOMElements = { [K in keyof JSX.IntrinsicElements]: JSX.IntrinsicElements[K] extends {
|
|
490
|
-
ref?: infer R | undefined;
|
|
491
|
-
} ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element };
|
|
492
|
-
declare function createElement(type: JSX$1.ElementType, allProps?: {
|
|
493
|
-
ref?: (el: Element) => void;
|
|
494
|
-
} & Record<string, unknown>): JSX$1.Element | null;
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region src/jsx-runtime/fragment.d.ts
|
|
497
|
-
/**
|
|
498
|
-
* Used by the JSX transform for `<>...</>` fragments.
|
|
499
|
-
*
|
|
500
|
-
* Each child is routed through `mountChild`, which handles Nodes, strings,
|
|
501
|
-
* numbers, arrays, and reactive getters — matching the behavior of any other
|
|
502
|
-
* JSX container. `mountChild` also wires each child's cleanup via its own
|
|
503
|
-
* `effectScope`, which links to the enclosing `effectScope` created by
|
|
504
|
-
* `createElement(Fragment, ...)` for disposal propagation.
|
|
505
|
-
*
|
|
506
|
-
* **Raw HTML mode** — `<Fragment html>{markup}</Fragment>`: the child is a
|
|
507
|
-
* `MaybeReactive<string>` rendered as markup inside a Slot region (comment
|
|
508
|
-
* markers), so the server renderer and the hydration claim pass share the
|
|
509
|
-
* region boundary. Reactive sources re-render the region on change. This is
|
|
510
|
-
* the library's only raw-HTML sink: the string is NOT escaped — sanitize
|
|
511
|
-
* untrusted input at the call site. `<script>` tags never execute.
|
|
512
|
-
*/
|
|
513
|
-
declare function Fragment(props: Props<{
|
|
514
|
-
children?: Children;
|
|
515
|
-
}> | {
|
|
516
|
-
html: true;
|
|
517
|
-
children: MaybeReactive<string>;
|
|
518
|
-
}): DocumentFragment;
|
|
519
|
-
//#endregion
|
|
520
|
-
//#region src/jsx-runtime/index.d.ts
|
|
521
|
-
declare namespace JSX$1 {
|
|
522
|
-
export type Element = globalThis.Element | globalThis.DocumentFragment;
|
|
523
|
-
export type ElementClass = {
|
|
524
|
-
render(): JSX$1.Element | null;
|
|
525
|
-
};
|
|
526
|
-
export type ElementType = string | JSX$1.Element | (new (props: any) => JSX$1.ElementClass) | ((props: any) => JSX$1.Element | null);
|
|
527
|
-
export interface ElementChildrenAttribute {
|
|
528
|
-
children: {};
|
|
529
|
-
}
|
|
530
|
-
export interface IntrinsicAttributes {}
|
|
531
|
-
export type LibraryManagedAttributes<C, P> = ResolveProps<C, P>;
|
|
532
|
-
type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends infer C extends AnyElementCtor ? MaybeReactiveProps<WithJsxNamespaces<Omit<ElementProps<C>, "children" | "ref">, InstanceType<C>>> & {
|
|
533
|
-
ref?: (el: InstanceType<C>) => void;
|
|
534
|
-
children?: Children;
|
|
535
|
-
} : never };
|
|
536
|
-
export type IntrinsicElements = { [K in keyof DOMIntrinsicElements]: MaybeReactiveProps<WithJsxNamespaces<DOMIntrinsicElements[K], DOMElements[K]>> & {
|
|
537
|
-
ref?: (el: DOMElements[K]) => void;
|
|
538
|
-
children?: Children;
|
|
539
|
-
} & (DOMElements[K] extends SVGElement ? SvgNamespaceAttrs : {}) } & RegisteredElements;
|
|
540
|
-
export {};
|
|
541
|
-
}
|
|
542
|
-
/** A class whose constructor returns a ComponentInstance. */
|
|
543
|
-
type ComponentClass<P extends Record<PropertyKey, unknown> = any> = new (props: P) => JSX$1.ElementClass;
|
|
544
|
-
type ComponentFn<P extends Record<PropertyKey, unknown> = any> = (props: Props<P>) => JSX$1.Element | null;
|
|
545
|
-
//#endregion
|
|
546
|
-
//#region src/jsx-runtime/properties.d.ts
|
|
547
|
-
interface CSSProperties extends CSS.PropertiesHyphen {
|
|
548
|
-
[key: `-${string}`]: string | number | undefined;
|
|
549
|
-
}
|
|
550
|
-
type CssStyleKey = Extract<keyof CSSProperties, string> extends infer K ? K extends `-${string}` ? never : K : never;
|
|
551
|
-
type StyleNamespace = { [K in CssStyleKey as `style:${K}`]?: CSSProperties[K] | null };
|
|
552
|
-
type PropNamespace<E> = { [K in keyof E as K extends string ? `prop:${K}` : never]?: E[K] };
|
|
553
|
-
type XlinkAttrs = {
|
|
554
|
-
"xlink:href"?: string | undefined;
|
|
555
|
-
"xlink:title"?: string | undefined;
|
|
556
|
-
"xlink:show"?: "new" | "replace" | "embed" | "other" | "none" | undefined;
|
|
557
|
-
"xlink:role"?: string | undefined;
|
|
558
|
-
"xlink:type"?: "simple" | "extended" | "locator" | "arc" | "resource" | "title" | undefined;
|
|
559
|
-
"xlink:arcrole"?: string | undefined;
|
|
560
|
-
"xlink:actuate"?: "onLoad" | "onRequest" | "other" | "none" | undefined;
|
|
561
|
-
};
|
|
562
|
-
type ClassNamespace = { [K in `class:${string}`]?: boolean };
|
|
563
|
-
type XmlAttrs = {
|
|
564
|
-
"xml:lang"?: string | undefined;
|
|
565
|
-
"xml:space"?: "default" | "preserve" | undefined;
|
|
566
|
-
"xml:base"?: string | undefined;
|
|
567
|
-
};
|
|
568
|
-
type SvgNamespaceAttrs = XlinkAttrs & XmlAttrs;
|
|
569
|
-
interface StyleAttrObject extends CSS.Properties {}
|
|
570
|
-
type JsxNamespaces<E extends Element = Element> = (E extends ElementCSSInlineStyle ? {
|
|
571
|
-
style?: string | StyleAttrObject;
|
|
572
|
-
} & StyleNamespace : {}) & PropNamespace<Omit<E, "children">> & ClassNamespace;
|
|
573
|
-
type JsxNamespaceKeys = "style" | `class:${string}` | `style:${string}` | `prop:${string}`;
|
|
574
|
-
type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
|
|
575
|
-
//#endregion
|
|
576
|
-
//#region src/jsx-runtime/children.d.ts
|
|
577
|
-
type PrimitiveNodeType = Node | string | boolean | number | bigint | symbol | Date | RegExp | null | undefined;
|
|
578
|
-
type AnyFn = (...args: any[]) => Children;
|
|
579
|
-
type Children = PrimitiveNodeType | AnyFn | Element | DocumentFragment | Children[];
|
|
580
|
-
//#endregion
|
|
581
|
-
export { isComputed as A, EFFECT_SCOPE as C, computed as D, batch as E, signal as F, trigger as I, untracked as L, isEffectScope as M, isSignal as N, effect as O, onCleanup as P, EFFECT as S, SIGNAL as T, reactive as _, Fragment as a, CLAIM as b, Props as c, Require as d, Computed as f, isReactive as g, Updater as h, JSX$1 as i, isEffect as j, effectScope as k, PropsOf as l, Signal as m, ComponentClass as n, createElement as o, MaybeReactive as p, ComponentFn as r, MaybeReactiveProps as s, Children as t, RawProps as u, resolve as v, SEED as w, COMPUTED as x, resolveProps as y };
|
|
File without changes
|