elements-kit 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/dist/await.d.mts +53 -0
- package/dist/await.mjs +70 -0
- package/dist/custom-elements.d.mts +1 -1
- package/dist/{element-xQwq4ulc.mjs → element-D3om9yA6.mjs} +71 -4
- package/dist/for.d.mts +20 -26
- package/dist/for.mjs +29 -4
- package/dist/fragment-ROPRBJQd.mjs +61 -0
- package/dist/hydrate/index.d.mts +41 -0
- package/dist/hydrate/index.mjs +2 -0
- package/dist/hydrate-6Qx4n4Su.mjs +380 -0
- package/dist/integrations/astro-client.d.mts +17 -0
- package/dist/integrations/astro-client.mjs +23 -0
- package/dist/integrations/astro-server.d.mts +15 -0
- package/dist/integrations/astro-server.mjs +39 -0
- package/dist/integrations/astro-slots.d.mts +12 -0
- package/dist/integrations/astro-slots.mjs +30 -0
- package/dist/integrations/astro.d.mts +46 -0
- package/dist/integrations/astro.mjs +64 -0
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +2 -2
- package/dist/jsx-runtime/index.d.mts +1 -1
- package/dist/jsx-runtime/index.mjs +2 -20
- package/dist/{lib-Dkc7cV5F.mjs → lib-DYypKhxk.mjs} +63 -5
- package/dist/render.mjs +1 -1
- package/dist/{scope-CnEvL9Nd.mjs → scope-zbEG299F.mjs} +1 -1
- package/dist/server/index.d.mts +43 -0
- package/dist/server/index.mjs +2 -0
- package/dist/server-iFSng50i.mjs +385 -0
- package/dist/signals/index.d.mts +2 -2
- package/dist/signals/index.mjs +5 -3
- package/dist/{slot-B8y0aEoz.d.mts → slot-BFWXeFRl.d.mts} +6 -0
- package/dist/{slot-Cne__au7.mjs → slot-Dvf30O0B.mjs} +12 -1
- package/dist/slot.d.mts +1 -1
- package/dist/slot.mjs +1 -1
- package/dist/{infer-B7T5hi_D.d.mts → types-ncUK9rki.d.mts} +140 -141
- package/dist/ui/overlay/index.mjs +1 -1
- package/dist/utilities/_observe.mjs +1 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/active-element.mjs +1 -1
- package/dist/utilities/async.d.mts +19 -2
- package/dist/utilities/async.mjs +49 -2
- package/dist/utilities/context.mjs +1 -1
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/debounced.mjs +1 -1
- package/dist/utilities/dom-lifecycle.bench.mjs +3255 -1
- package/dist/utilities/dom-lifecycle.mjs +1 -1
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.mjs +1 -1
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-driven.mjs +1 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/event-listener.mjs +1 -1
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/focus-within.mjs +1 -1
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.mjs +1 -1
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/interval.mjs +1 -1
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/location.mjs +1 -1
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.mjs +1 -1
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/media-query.mjs +1 -1
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/network.mjs +1 -1
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/orientation.mjs +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/previous.mjs +1 -1
- package/dist/utilities/promise.d.mts +19 -2
- package/dist/utilities/promise.mjs +33 -3
- package/dist/utilities/retry.mjs +1 -1
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/routing.mjs +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/throttled.mjs +1 -1
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.mjs +1 -1
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-focus.mjs +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.mjs +1 -1
- package/package.json +16 -1
- package/dist/benchmark.CX_oY03V-CSLAXL5f.mjs +0 -5145
- package/dist/magic-string.es-CXefOmkB.mjs +0 -1011
- package/dist/test.BmQO5GaM-Ddz9cDxc.mjs +0 -8266
- package/dist/utilities/active-element.test.d.mts +0 -1
- package/dist/utilities/active-element.test.mjs +0 -25
- package/dist/utilities/async.test.d.mts +0 -1
- package/dist/utilities/async.test.mjs +0 -275
- package/dist/utilities/context.test.d.mts +0 -1
- package/dist/utilities/context.test.mjs +0 -171
- package/dist/utilities/debounced.test.d.mts +0 -1
- package/dist/utilities/debounced.test.mjs +0 -68
- package/dist/utilities/dom-lifecycle.test.d.mts +0 -1
- package/dist/utilities/dom-lifecycle.test.mjs +0 -228
- package/dist/utilities/element-rect.test.d.mts +0 -1
- package/dist/utilities/element-rect.test.mjs +0 -101
- package/dist/utilities/element-scroll.test.d.mts +0 -1
- package/dist/utilities/element-scroll.test.mjs +0 -27
- package/dist/utilities/event-listener.test.d.mts +0 -1
- package/dist/utilities/event-listener.test.mjs +0 -60
- package/dist/utilities/focus-within.test.d.mts +0 -1
- package/dist/utilities/focus-within.test.mjs +0 -51
- package/dist/utilities/form-object.test.d.mts +0 -1
- package/dist/utilities/form-object.test.mjs +0 -408
- package/dist/utilities/hover.test.d.mts +0 -1
- package/dist/utilities/hover.test.mjs +0 -54
- package/dist/utilities/intersection-observer.test.d.mts +0 -1
- package/dist/utilities/intersection-observer.test.mjs +0 -46
- package/dist/utilities/interval.test.d.mts +0 -1
- package/dist/utilities/interval.test.mjs +0 -115
- package/dist/utilities/location.test.d.mts +0 -1
- package/dist/utilities/location.test.mjs +0 -61
- package/dist/utilities/long-press.test.d.mts +0 -1
- package/dist/utilities/long-press.test.mjs +0 -54
- package/dist/utilities/media-devices.test.d.mts +0 -1
- package/dist/utilities/media-devices.test.mjs +0 -44
- package/dist/utilities/media-player.test.d.mts +0 -1
- package/dist/utilities/media-player.test.mjs +0 -102
- package/dist/utilities/mutation-observer.test.d.mts +0 -1
- package/dist/utilities/mutation-observer.test.mjs +0 -48
- package/dist/utilities/network.test.d.mts +0 -1
- package/dist/utilities/network.test.mjs +0 -30
- package/dist/utilities/on-click-outside.test.d.mts +0 -1
- package/dist/utilities/on-click-outside.test.mjs +0 -45
- package/dist/utilities/previous.test.d.mts +0 -1
- package/dist/utilities/previous.test.mjs +0 -90
- package/dist/utilities/promise.test.d.mts +0 -1
- package/dist/utilities/promise.test.mjs +0 -158
- package/dist/utilities/retry.test.d.mts +0 -1
- package/dist/utilities/retry.test.mjs +0 -85
- package/dist/utilities/routing.test.d.mts +0 -1
- package/dist/utilities/routing.test.mjs +0 -129
- package/dist/utilities/search-params.test.d.mts +0 -1
- package/dist/utilities/search-params.test.mjs +0 -37
- package/dist/utilities/ssr.test.d.mts +0 -1
- package/dist/utilities/ssr.test.mjs +0 -65
- package/dist/utilities/storage.test.d.mts +0 -1
- package/dist/utilities/storage.test.mjs +0 -139
- package/dist/utilities/throttled.test.d.mts +0 -1
- package/dist/utilities/throttled.test.mjs +0 -58
- package/dist/utilities/timeout.test.d.mts +0 -1
- package/dist/utilities/timeout.test.mjs +0 -121
- package/dist/utilities/window-size.test.d.mts +0 -1
- package/dist/utilities/window-size.test.mjs +0 -43
- /package/dist/{custom-elements-D5CgfNKc.d.mts → custom-elements-DK5VUcWA.d.mts} +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-3r7Diua4.mjs";
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
2
|
+
import { n as Slot, r as PrimitiveNodeType, t as SLOTS } from "./slot-BFWXeFRl.mjs";
|
|
3
|
+
import { t as CustomElementRegistry } from "./custom-elements-DK5VUcWA.mjs";
|
|
4
4
|
import { JSX } from "dom-expressions/src/jsx-h";
|
|
5
5
|
|
|
6
6
|
//#region src/jsx-runtime/element.d.ts
|
|
7
|
-
declare function createElement(type: string | Component,
|
|
8
|
-
ref,
|
|
9
|
-
...props
|
|
10
|
-
}?: JSX$1.IntrinsicAttributes & Record<string, unknown>): JSX$1.Element;
|
|
7
|
+
declare function createElement(type: string | Component, allProps?: JSX$1.IntrinsicAttributes & Record<string, unknown>): JSX$1.Element;
|
|
11
8
|
//#endregion
|
|
12
9
|
//#region src/signals/lib.d.ts
|
|
13
10
|
declare const SIGNAL: unique symbol;
|
|
@@ -111,6 +108,19 @@ declare function computed<T>(getter: (previousValue?: T) => T): () => T;
|
|
|
111
108
|
* stop(); // final cleanup: abort the last fetch
|
|
112
109
|
* ```
|
|
113
110
|
*/
|
|
111
|
+
/**
|
|
112
|
+
* @internal Method key for settling a reactive async wrapper from a
|
|
113
|
+
* serialized server snapshot (hydration seeding). Lives here so
|
|
114
|
+
* `utilities/promise`, `utilities/async` and `hydrate` can share it without
|
|
115
|
+
* a utility-to-utility dependency.
|
|
116
|
+
*/
|
|
117
|
+
declare const SEED: unique symbol;
|
|
118
|
+
/**
|
|
119
|
+
* @internal Method key for the hydrate claim protocol: the claim walk hands
|
|
120
|
+
* each async wrapper its ek-data record (or undefined). The wrapper decides —
|
|
121
|
+
* seed and discard any deferred run, or execute the deferred run now.
|
|
122
|
+
*/
|
|
123
|
+
declare const CLAIM: unique symbol;
|
|
114
124
|
declare function effect(fn: () => void): () => void;
|
|
115
125
|
/**
|
|
116
126
|
* Creates an ownership scope that groups reactive effects so they can all be
|
|
@@ -333,142 +343,8 @@ type MaybeReactive<T> = T | Computed<T>;
|
|
|
333
343
|
* ```
|
|
334
344
|
*/
|
|
335
345
|
declare function resolve<T>(value: MaybeReactive<T>): T;
|
|
336
|
-
/**
|
|
337
|
-
* Turn a reactive-props object into a bag of per-key getters. Callers may
|
|
338
|
-
* pass values or reactive sources (`signal`, `computed`); reading
|
|
339
|
-
* `props.name()` inside an effect or JSX getter subscribes to whatever
|
|
340
|
-
* drives it. Static values become stable thunks, signals and computed pass
|
|
341
|
-
* through unchanged — so identity is preserved (`props.name === props.name`).
|
|
342
|
-
*
|
|
343
|
-
* The JSX runtime auto-applies this to function-component props — call
|
|
344
|
-
* directly only for non-JSX call sites or nested prop bags.
|
|
345
|
-
*
|
|
346
|
-
* @example
|
|
347
|
-
* ```ts
|
|
348
|
-
* import { resolveProps } from "elements-kit/signals";
|
|
349
|
-
* import { signal } from "elements-kit/signals";
|
|
350
|
-
*
|
|
351
|
-
* const count = signal(0);
|
|
352
|
-
* const props = resolveProps({ count, label: "n" });
|
|
353
|
-
* props.count(); // 0 — subscribes to count
|
|
354
|
-
* props.label(); // "n"
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
346
|
declare function resolveProps<P extends object>(raw: { [K in keyof P]: MaybeReactive<P[K]> }): ReactiveProps<P>;
|
|
358
347
|
//#endregion
|
|
359
|
-
//#region src/jsx-runtime/fragment.d.ts
|
|
360
|
-
/**
|
|
361
|
-
* Used by the JSX transform for `<>...</>` fragments.
|
|
362
|
-
*
|
|
363
|
-
* Each child is routed through `mountChild`, which handles Nodes, strings,
|
|
364
|
-
* numbers, arrays, and reactive getters — matching the behavior of any other
|
|
365
|
-
* JSX container. `mountChild` also wires each child's cleanup via its own
|
|
366
|
-
* `effectScope`, which links to the enclosing `effectScope` created by
|
|
367
|
-
* `createElement(Fragment, ...)` for disposal propagation.
|
|
368
|
-
*/
|
|
369
|
-
declare function Fragment(props: {
|
|
370
|
-
children?: () => Child;
|
|
371
|
-
}): DocumentFragment;
|
|
372
|
-
//#endregion
|
|
373
|
-
//#region src/jsx-runtime/index.d.ts
|
|
374
|
-
/**
|
|
375
|
-
* Maps slot names to `Child` content.
|
|
376
|
-
* Use this to type `slot:name` JSX props on a custom component.
|
|
377
|
-
*
|
|
378
|
-
* @example
|
|
379
|
-
* ```tsx
|
|
380
|
-
* function Card(props: { title: string } & SlotProps<"header" | "footer">) { … }
|
|
381
|
-
* // caller: <Card title="…" slot:header={<h1>…</h1>} slot:footer={<p>…</p>} />
|
|
382
|
-
* ```
|
|
383
|
-
*/
|
|
384
|
-
type SlotProps<K extends string> = { [P in K as `slot:${P}`]?: Child };
|
|
385
|
-
/**
|
|
386
|
-
* Get the full JSX prop types for a given tag name, including reactive
|
|
387
|
-
* attributes, events, and all our namespace extensions.
|
|
388
|
-
*
|
|
389
|
-
* @example
|
|
390
|
-
* ```ts
|
|
391
|
-
* type InputProps = Attrs<"input">; // typed props for <input>
|
|
392
|
-
* type DivProps = Attrs<"div">; // typed props for <div>
|
|
393
|
-
* ```
|
|
394
|
-
*/
|
|
395
|
-
type Attrs<K extends keyof JSX$1.IntrinsicElements> = JSX$1.IntrinsicElements[K];
|
|
396
|
-
/**
|
|
397
|
-
* Namespaced JSX props added by elements-kit on top of dom-expressions.
|
|
398
|
-
* All four are tag-aware via the element type `E`.
|
|
399
|
-
*
|
|
400
|
-
* - `ref` — callback invoked with the mounted element, typed as the concrete
|
|
401
|
-
* element class for intrinsics and registered custom elements.
|
|
402
|
-
* - `class:foo` — open string + `MaybeReactive<boolean>`. Class names are
|
|
403
|
-
* user-defined CSS so the key stays open (no autocomplete possible).
|
|
404
|
-
* - `style:cssProp` — keys mapped from `DomJSX.CSSProperties` (csstype's
|
|
405
|
-
* hyphenated property names) for autocomplete; value typed per-property.
|
|
406
|
-
* - `prop:K` — inferred from `keyof E`. On `<div>` exposes
|
|
407
|
-
* `prop:className`, `prop:id`, etc. (from `HTMLDivElement`); on a
|
|
408
|
-
* registered custom element exposes its public fields too.
|
|
409
|
-
*
|
|
410
|
-
* `slot:foo` is NOT here — it's emitted per-element via `SlotsOf<C>` only
|
|
411
|
-
* for elements that declare `[SLOTS]`. Plain HTML intrinsics don't accept
|
|
412
|
-
* slot props (the runtime ignores them).
|
|
413
|
-
*/
|
|
414
|
-
type CssStyleKey = Extract<keyof JSX.CSSProperties, string> extends infer K ? K extends `-${string}` ? never : K : never;
|
|
415
|
-
type StyleNamespace = { [K in CssStyleKey as `style:${K}`]?: MaybeReactive<JSX.CSSProperties[K] | null> };
|
|
416
|
-
type PropNamespace<E> = { [K in keyof E as K extends string ? `prop:${K}` : never]?: MaybeReactive<E[K]> };
|
|
417
|
-
type JsxNamespaces<E extends Element = Element> = {
|
|
418
|
-
ref?: (el: E) => void;
|
|
419
|
-
[cls: `class:${string}`]: MaybeReactive<boolean>;
|
|
420
|
-
} & StyleNamespace & PropNamespace<E>;
|
|
421
|
-
type XlinkAttrs = {
|
|
422
|
-
"xlink:href"?: MaybeReactive<string | undefined>;
|
|
423
|
-
"xlink:title"?: MaybeReactive<string | undefined>;
|
|
424
|
-
"xlink:show"?: MaybeReactive<"new" | "replace" | "embed" | "other" | "none" | undefined>;
|
|
425
|
-
"xlink:role"?: MaybeReactive<string | undefined>;
|
|
426
|
-
"xlink:type"?: MaybeReactive<"simple" | "extended" | "locator" | "arc" | "resource" | "title" | undefined>;
|
|
427
|
-
"xlink:arcrole"?: MaybeReactive<string | undefined>;
|
|
428
|
-
"xlink:actuate"?: MaybeReactive<"onLoad" | "onRequest" | "other" | "none" | undefined>;
|
|
429
|
-
};
|
|
430
|
-
type XmlAttrs = {
|
|
431
|
-
"xml:lang"?: MaybeReactive<string | undefined>;
|
|
432
|
-
"xml:space"?: MaybeReactive<"default" | "preserve" | undefined>;
|
|
433
|
-
"xml:base"?: MaybeReactive<string | undefined>;
|
|
434
|
-
};
|
|
435
|
-
type SvgNamespaceAttrs = XlinkAttrs & XmlAttrs;
|
|
436
|
-
type JsxNamespaceKeys = "ref" | `class:${string}` | `style:${string}` | `prop:${string}`;
|
|
437
|
-
type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
|
|
438
|
-
type IntrinsicElementOf<T> = T extends {
|
|
439
|
-
ref?: infer R | undefined;
|
|
440
|
-
} ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element;
|
|
441
|
-
declare namespace JSX$1 {
|
|
442
|
-
export type Element = globalThis.Element | globalThis.DocumentFragment | null;
|
|
443
|
-
export type ElementType = Child | Component;
|
|
444
|
-
export interface ElementChildrenAttribute {
|
|
445
|
-
children: {};
|
|
446
|
-
}
|
|
447
|
-
export interface IntrinsicAttributes {
|
|
448
|
-
ref?: (el: Element) => void;
|
|
449
|
-
}
|
|
450
|
-
export type LibraryManagedAttributes<C, P> = ResolveProps<C, P>;
|
|
451
|
-
type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends infer C extends AnyElementCtor ? WithJsxNamespaces<MaybeReactiveProps<ElementProps<C>>, InstanceType<C>> : never };
|
|
452
|
-
export type IntrinsicElements = { [K in keyof JSX.IntrinsicElements]: WithJsxNamespaces<JSX.IntrinsicElements[K], IntrinsicElementOf<JSX.IntrinsicElements[K]>> & (IntrinsicElementOf<JSX.IntrinsicElements[K]> extends SVGElement ? SvgNamespaceAttrs : {}) } & RegisteredElements;
|
|
453
|
-
export {};
|
|
454
|
-
}
|
|
455
|
-
//#endregion
|
|
456
|
-
//#region src/jsx-runtime/types.d.ts
|
|
457
|
-
/** An instance created by a component class — must expose `render()`. */
|
|
458
|
-
interface ComponentInstance {
|
|
459
|
-
render(): JSX$1.Element;
|
|
460
|
-
}
|
|
461
|
-
/** A class whose constructor returns a ComponentInstance. */
|
|
462
|
-
type ComponentClass<P extends Record<PropertyKey, unknown> = any> = new (props: P) => ComponentInstance;
|
|
463
|
-
type ComponentFn<P extends Record<PropertyKey, unknown> = any> = (props: ReactiveProps<P>) => JSX$1.Element;
|
|
464
|
-
/** Anything valid as the first arg to `createElement` / a JSX tag target. */
|
|
465
|
-
type Component = NonNullable<JSX$1.Element> | ComponentClass | ComponentFn;
|
|
466
|
-
/** A resolved runtime node — what `applyProps` / `applyChildren` operate on. */
|
|
467
|
-
type PropsTarget = NonNullable<JSX$1.Element> | ComponentInstance;
|
|
468
|
-
/** Anything that can appear as a JSX child. */
|
|
469
|
-
type Child = PrimitiveNodeType | JSX$1.Element | AnyFn | Child[];
|
|
470
|
-
type AnyFn = (...args: any[]) => Child;
|
|
471
|
-
//#endregion
|
|
472
348
|
//#region src/jsx-runtime/infer.d.ts
|
|
473
349
|
type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
|
|
474
350
|
type Inst<C> = C extends (abstract new (...args: any[]) => infer I) ? I : never;
|
|
@@ -681,4 +557,127 @@ type ComponentProps<C extends ComponentClass<any>> = C extends ComponentClass<in
|
|
|
681
557
|
*/
|
|
682
558
|
type Props<C> = (C extends (abstract new (...args: any[]) => infer I) ? MaybeReactiveProps<InstanceProps<I>> : C extends ((props: infer P, ...rest: any[]) => any) ? P extends object ? MaybeReactiveProps<RawProps<P>> : {} : MaybeReactiveProps<InstanceProps<C>>) & SlotsOf<C>;
|
|
683
559
|
//#endregion
|
|
684
|
-
|
|
560
|
+
//#region src/jsx-runtime/fragment.d.ts
|
|
561
|
+
/**
|
|
562
|
+
* Used by the JSX transform for `<>...</>` fragments.
|
|
563
|
+
*
|
|
564
|
+
* Each child is routed through `mountChild`, which handles Nodes, strings,
|
|
565
|
+
* numbers, arrays, and reactive getters — matching the behavior of any other
|
|
566
|
+
* JSX container. `mountChild` also wires each child's cleanup via its own
|
|
567
|
+
* `effectScope`, which links to the enclosing `effectScope` created by
|
|
568
|
+
* `createElement(Fragment, ...)` for disposal propagation.
|
|
569
|
+
*
|
|
570
|
+
* **Raw HTML mode** — `<Fragment html>{markup}</Fragment>`: the child is a
|
|
571
|
+
* `MaybeReactive<string>` rendered as markup inside a Slot region (comment
|
|
572
|
+
* markers), so the server renderer and the hydration claim pass share the
|
|
573
|
+
* region boundary. Reactive sources re-render the region on change. This is
|
|
574
|
+
* the library's only raw-HTML sink: the string is NOT escaped — sanitize
|
|
575
|
+
* untrusted input at the call site. `<script>` tags never execute.
|
|
576
|
+
*/
|
|
577
|
+
declare function Fragment(props: Props<{
|
|
578
|
+
children: Child;
|
|
579
|
+
}> | {
|
|
580
|
+
html: true;
|
|
581
|
+
children: MaybeReactive<string>;
|
|
582
|
+
}): DocumentFragment;
|
|
583
|
+
//#endregion
|
|
584
|
+
//#region src/jsx-runtime/index.d.ts
|
|
585
|
+
/**
|
|
586
|
+
* Maps slot names to `Child` content.
|
|
587
|
+
* Use this to type `slot:name` JSX props on a custom component.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```tsx
|
|
591
|
+
* function Card(props: { title: string } & SlotProps<"header" | "footer">) { … }
|
|
592
|
+
* // caller: <Card title="…" slot:header={<h1>…</h1>} slot:footer={<p>…</p>} />
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
type SlotProps<K extends string> = { [P in K as `slot:${P}`]?: Child };
|
|
596
|
+
/**
|
|
597
|
+
* Get the full JSX prop types for a given tag name, including reactive
|
|
598
|
+
* attributes, events, and all our namespace extensions.
|
|
599
|
+
*
|
|
600
|
+
* @example
|
|
601
|
+
* ```ts
|
|
602
|
+
* type InputProps = Attrs<"input">; // typed props for <input>
|
|
603
|
+
* type DivProps = Attrs<"div">; // typed props for <div>
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
type Attrs<K extends keyof JSX$1.IntrinsicElements> = JSX$1.IntrinsicElements[K];
|
|
607
|
+
/**
|
|
608
|
+
* Namespaced JSX props added by elements-kit on top of dom-expressions.
|
|
609
|
+
* All four are tag-aware via the element type `E`.
|
|
610
|
+
*
|
|
611
|
+
* - `ref` — callback invoked with the mounted element, typed as the concrete
|
|
612
|
+
* element class for intrinsics and registered custom elements.
|
|
613
|
+
* - `class:foo` — open string + `MaybeReactive<boolean>`. Class names are
|
|
614
|
+
* user-defined CSS so the key stays open (no autocomplete possible).
|
|
615
|
+
* - `style:cssProp` — keys mapped from `DomJSX.CSSProperties` (csstype's
|
|
616
|
+
* hyphenated property names) for autocomplete; value typed per-property.
|
|
617
|
+
* - `prop:K` — inferred from `keyof E`. On `<div>` exposes
|
|
618
|
+
* `prop:className`, `prop:id`, etc. (from `HTMLDivElement`); on a
|
|
619
|
+
* registered custom element exposes its public fields too.
|
|
620
|
+
*
|
|
621
|
+
* `slot:foo` is NOT here — it's emitted per-element via `SlotsOf<C>` only
|
|
622
|
+
* for elements that declare `[SLOTS]`. Plain HTML intrinsics don't accept
|
|
623
|
+
* slot props (the runtime ignores them).
|
|
624
|
+
*/
|
|
625
|
+
type CssStyleKey = Extract<keyof JSX.CSSProperties, string> extends infer K ? K extends `-${string}` ? never : K : never;
|
|
626
|
+
type StyleNamespace = { [K in CssStyleKey as `style:${K}`]?: MaybeReactive<JSX.CSSProperties[K] | null> };
|
|
627
|
+
type PropNamespace<E> = { [K in keyof E as K extends string ? `prop:${K}` : never]?: MaybeReactive<E[K]> };
|
|
628
|
+
type JsxNamespaces<E extends Element = Element> = {
|
|
629
|
+
ref?: (el: E) => void;
|
|
630
|
+
[cls: `class:${string}`]: MaybeReactive<boolean>;
|
|
631
|
+
} & StyleNamespace & PropNamespace<E>;
|
|
632
|
+
type XlinkAttrs = {
|
|
633
|
+
"xlink:href"?: MaybeReactive<string | undefined>;
|
|
634
|
+
"xlink:title"?: MaybeReactive<string | undefined>;
|
|
635
|
+
"xlink:show"?: MaybeReactive<"new" | "replace" | "embed" | "other" | "none" | undefined>;
|
|
636
|
+
"xlink:role"?: MaybeReactive<string | undefined>;
|
|
637
|
+
"xlink:type"?: MaybeReactive<"simple" | "extended" | "locator" | "arc" | "resource" | "title" | undefined>;
|
|
638
|
+
"xlink:arcrole"?: MaybeReactive<string | undefined>;
|
|
639
|
+
"xlink:actuate"?: MaybeReactive<"onLoad" | "onRequest" | "other" | "none" | undefined>;
|
|
640
|
+
};
|
|
641
|
+
type XmlAttrs = {
|
|
642
|
+
"xml:lang"?: MaybeReactive<string | undefined>;
|
|
643
|
+
"xml:space"?: MaybeReactive<"default" | "preserve" | undefined>;
|
|
644
|
+
"xml:base"?: MaybeReactive<string | undefined>;
|
|
645
|
+
};
|
|
646
|
+
type SvgNamespaceAttrs = XlinkAttrs & XmlAttrs;
|
|
647
|
+
type JsxNamespaceKeys = "ref" | `class:${string}` | `style:${string}` | `prop:${string}`;
|
|
648
|
+
type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
|
|
649
|
+
type IntrinsicElementOf<T> = T extends {
|
|
650
|
+
ref?: infer R | undefined;
|
|
651
|
+
} ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element;
|
|
652
|
+
declare namespace JSX$1 {
|
|
653
|
+
export type Element = globalThis.Element | globalThis.DocumentFragment | null;
|
|
654
|
+
export type ElementType = Child | Component;
|
|
655
|
+
export interface ElementChildrenAttribute {
|
|
656
|
+
children: {};
|
|
657
|
+
}
|
|
658
|
+
export interface IntrinsicAttributes {
|
|
659
|
+
ref?: (el: Element) => void;
|
|
660
|
+
}
|
|
661
|
+
export type LibraryManagedAttributes<C, P> = ResolveProps<C, P>;
|
|
662
|
+
type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends infer C extends AnyElementCtor ? WithJsxNamespaces<MaybeReactiveProps<ElementProps<C>>, InstanceType<C>> : never };
|
|
663
|
+
export type IntrinsicElements = { [K in keyof JSX.IntrinsicElements]: WithJsxNamespaces<JSX.IntrinsicElements[K], IntrinsicElementOf<JSX.IntrinsicElements[K]>> & (IntrinsicElementOf<JSX.IntrinsicElements[K]> extends SVGElement ? SvgNamespaceAttrs : {}) } & RegisteredElements;
|
|
664
|
+
export {};
|
|
665
|
+
}
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/jsx-runtime/types.d.ts
|
|
668
|
+
/** An instance created by a component class — must expose `render()`. */
|
|
669
|
+
interface ComponentInstance {
|
|
670
|
+
render(): JSX$1.Element;
|
|
671
|
+
}
|
|
672
|
+
/** A class whose constructor returns a ComponentInstance. */
|
|
673
|
+
type ComponentClass<P extends Record<PropertyKey, unknown> = any> = new (props: P) => ComponentInstance;
|
|
674
|
+
type ComponentFn<P extends Record<PropertyKey, unknown> = any> = (props: ReactiveProps<P>) => JSX$1.Element;
|
|
675
|
+
/** Anything valid as the first arg to `createElement` / a JSX tag target. */
|
|
676
|
+
type Component = NonNullable<JSX$1.Element> | ComponentClass | ComponentFn;
|
|
677
|
+
/** A resolved runtime node — what `applyProps` / `applyChildren` operate on. */
|
|
678
|
+
type PropsTarget = NonNullable<JSX$1.Element> | ComponentInstance;
|
|
679
|
+
/** Anything that can appear as a JSX child. */
|
|
680
|
+
type Child = PrimitiveNodeType | JSX$1.Element | AnyFn | Child[];
|
|
681
|
+
type AnyFn = (...args: any[]) => Child;
|
|
682
|
+
//#endregion
|
|
683
|
+
export { EFFECT_SCOPE as A, isSignal as B, isReactive as C, CLAIM as D, resolveProps as E, effect as F, createElement as G, signal as H, effectScope as I, isComputed as L, SIGNAL as M, batch as N, COMPUTED as O, computed as P, isEffect as R, Updater as S, resolve as T, trigger as U, onCleanup as V, untracked as W, Require as _, ComponentInstance as a, MaybeReactive as b, JSX$1 as c, ComponentProps as d, ElementProps as f, ReactiveProps as g, RawProps as h, ComponentFn as i, SEED as j, EFFECT as k, SlotProps as l, Props as m, Component as n, PropsTarget as o, MaybeReactiveProps as p, ComponentClass as r, Attrs as s, Child as t, Fragment as u, ResolveProps as v, reactive as w, Signal as x, Computed as y, isEffectScope as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as onCleanup, u as effect } from "../../lib-DYypKhxk.mjs";
|
|
2
2
|
import "../../signals/index.mjs";
|
|
3
3
|
import { createElementRect } from "../../utilities/element-rect.mjs";
|
|
4
4
|
//#region src/ui/overlay/constrain.ts
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { b as MaybeReactive } from "../
|
|
1
|
+
import { D as CLAIM, b as MaybeReactive, j as SEED } from "../types-ncUK9rki.mjs";
|
|
2
2
|
import { ComputedPromise } from "./promise.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utilities/async.d.ts
|
|
5
|
+
/** @internal Hydrate cleanup: execute deferred runs no claim resolved. */
|
|
6
|
+
declare function flushDeferredAsyncRuns(): void;
|
|
5
7
|
/** Shape of the async function driven by {@link Async} / {@link async}. */
|
|
6
8
|
type Fn<TInput, TOutput> = (input: TInput) => Promise<TOutput>;
|
|
7
9
|
/**
|
|
@@ -43,6 +45,19 @@ declare class Async<TInput = undefined, TOutput = unknown> {
|
|
|
43
45
|
then<TResult1 = TOutput, TResult2 = never>(onfulfilled?: ((value: TOutput | undefined) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
44
46
|
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<TOutput | undefined | TResult>;
|
|
45
47
|
finally(onfinally?: (() => void) | null): Promise<TOutput | undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* @internal Hydration seeding — delegates to the current operation's
|
|
50
|
+
* `ReactivePromise`. See `ReactivePromise[SEED]`.
|
|
51
|
+
*/
|
|
52
|
+
[SEED](value: unknown): void;
|
|
53
|
+
/**
|
|
54
|
+
* @internal Hydrate claim protocol. A server record seeds the state and
|
|
55
|
+
* discards any deferred run — the fetcher never executes. No record means
|
|
56
|
+
* the deferred run executes now.
|
|
57
|
+
*/
|
|
58
|
+
[CLAIM](record: {
|
|
59
|
+
value: unknown;
|
|
60
|
+
} | undefined): void;
|
|
46
61
|
constructor(fn: MaybeReactive<Fn<TInput, TOutput>>);
|
|
47
62
|
/**
|
|
48
63
|
* Runs the async function once with the given input, stopping any currently active
|
|
@@ -59,6 +74,8 @@ declare class Async<TInput = undefined, TOutput = unknown> {
|
|
|
59
74
|
*/
|
|
60
75
|
start(...args: TInput extends undefined ? [] : [input: TInput]): this;
|
|
61
76
|
}
|
|
77
|
+
/** @internal Cross-instance-safe `Async` detection. */
|
|
78
|
+
declare function isAsyncLike(value: unknown): value is Async<never, unknown>;
|
|
62
79
|
/**
|
|
63
80
|
* Create an {@link Async} that is also callable as a signal: invoking it
|
|
64
81
|
* (with no args) reads the current `result`, so it drops into any reactive
|
|
@@ -78,4 +95,4 @@ declare class Async<TInput = undefined, TOutput = unknown> {
|
|
|
78
95
|
*/
|
|
79
96
|
declare function async<TInput = any, TOutput = undefined>(fn: MaybeReactive<(input: TInput) => Promise<TOutput>>): Async<TInput, TOutput> & ((...args: any[]) => TOutput | undefined);
|
|
80
97
|
//#endregion
|
|
81
|
-
export { Async, Fn, async };
|
|
98
|
+
export { Async, Fn, async, flushDeferredAsyncRuns, isAsyncLike };
|
package/dist/utilities/async.mjs
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as untracked, b as shouldDeferAsyncRuns, f as effectsInert, n as CLAIM, o as SEED, u as effect, x as signal } from "../lib-DYypKhxk.mjs";
|
|
2
2
|
import { resolve } from "../signals/index.mjs";
|
|
3
3
|
import { promise } from "./promise.mjs";
|
|
4
4
|
//#region src/utilities/async.ts
|
|
5
|
+
const deferredRuns = /* @__PURE__ */ new Map();
|
|
6
|
+
/** @internal Hydrate cleanup: execute deferred runs no claim resolved. */
|
|
7
|
+
function flushDeferredAsyncRuns() {
|
|
8
|
+
const runs = [...deferredRuns.values()];
|
|
9
|
+
deferredRuns.clear();
|
|
10
|
+
for (const run of runs) run();
|
|
11
|
+
}
|
|
5
12
|
/**
|
|
6
13
|
* Reactive wrapper around an async function. Exposes the current run as
|
|
7
14
|
* reactive signals (`state`, `value`, `reason`, `result`, `pending`) and
|
|
@@ -65,6 +72,28 @@ var Async = class {
|
|
|
65
72
|
finally(onfinally) {
|
|
66
73
|
return this.raw.finally(onfinally);
|
|
67
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* @internal Hydration seeding — delegates to the current operation's
|
|
77
|
+
* `ReactivePromise`. See `ReactivePromise[SEED]`.
|
|
78
|
+
*/
|
|
79
|
+
[SEED](value) {
|
|
80
|
+
const seed = this.raw[SEED];
|
|
81
|
+
seed?.(value);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @internal Hydrate claim protocol. A server record seeds the state and
|
|
85
|
+
* discards any deferred run — the fetcher never executes. No record means
|
|
86
|
+
* the deferred run executes now.
|
|
87
|
+
*/
|
|
88
|
+
[CLAIM](record) {
|
|
89
|
+
const pendingRun = deferredRuns.get(this);
|
|
90
|
+
deferredRuns.delete(this);
|
|
91
|
+
if (record) {
|
|
92
|
+
if (untracked(() => this.state) === "pending") this[SEED](record.value);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
pendingRun?.();
|
|
96
|
+
}
|
|
68
97
|
constructor(fn) {
|
|
69
98
|
this.#fn(resolve(fn));
|
|
70
99
|
}
|
|
@@ -79,6 +108,14 @@ var Async = class {
|
|
|
79
108
|
* and register cleanup effects.
|
|
80
109
|
*/
|
|
81
110
|
run(...args) {
|
|
111
|
+
if (shouldDeferAsyncRuns()) {
|
|
112
|
+
deferredRuns.set(this, () => this.run(...args));
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
if (effectsInert()) {
|
|
116
|
+
untracked(() => this.#execute(...args));
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
82
119
|
this.stop();
|
|
83
120
|
this.#cleanup = effect(() => {
|
|
84
121
|
untracked(() => this.#execute(...args));
|
|
@@ -107,6 +144,13 @@ var Async = class {
|
|
|
107
144
|
return this;
|
|
108
145
|
}
|
|
109
146
|
};
|
|
147
|
+
const ASYNC_BRAND = Symbol.for("elements-kit.async");
|
|
148
|
+
Object.defineProperty(Async.prototype, ASYNC_BRAND, { value: true });
|
|
149
|
+
/** @internal Cross-instance-safe `Async` detection. */
|
|
150
|
+
function isAsyncLike(value) {
|
|
151
|
+
if (value instanceof Async) return true;
|
|
152
|
+
return value != null && (typeof value === "object" || typeof value === "function") && value[ASYNC_BRAND] === true;
|
|
153
|
+
}
|
|
110
154
|
const ASYNC_KEYS = new Set([
|
|
111
155
|
"then",
|
|
112
156
|
"catch",
|
|
@@ -121,6 +165,9 @@ const ASYNC_KEYS = new Set([
|
|
|
121
165
|
"run",
|
|
122
166
|
"fn",
|
|
123
167
|
"raw",
|
|
168
|
+
SEED,
|
|
169
|
+
CLAIM,
|
|
170
|
+
ASYNC_BRAND,
|
|
124
171
|
Symbol.dispose
|
|
125
172
|
]);
|
|
126
173
|
/**
|
|
@@ -160,4 +207,4 @@ function async(fn) {
|
|
|
160
207
|
});
|
|
161
208
|
}
|
|
162
209
|
//#endregion
|
|
163
|
-
export { Async, async };
|
|
210
|
+
export { Async, async, flushDeferredAsyncRuns, isAsyncLike };
|