elements-kit 0.3.1 → 0.3.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/dist/{benchmark.CX_oY03V-COK1VBpH.mjs → benchmark.CX_oY03V-CsUg-gW0.mjs} +2 -2
- package/dist/custom-elements-D5CgfNKc.d.mts +55 -0
- package/dist/custom-elements.d.mts +1 -1
- package/dist/custom-elements.mjs +6 -4
- package/dist/for.d.mts +1 -1
- package/dist/{infer-BUUWMoG9.d.mts → infer-LDn1TquI.d.mts} +45 -33
- package/dist/integrations/react.d.mts +1 -1
- package/dist/jsx-runtime/index.d.mts +1 -1
- package/dist/signals/index.d.mts +1 -1
- package/dist/{test.BmQO5GaM-C8YqghE0.mjs → test.BmQO5GaM-ZC2MPXQb.mjs} +4 -4
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/active-element.test.mjs +2 -2
- package/dist/utilities/async.d.mts +7 -1
- package/dist/utilities/async.mjs +6 -0
- package/dist/utilities/async.test.mjs +2 -2
- package/dist/utilities/context.test.mjs +2 -2
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/debounced.test.mjs +2 -2
- package/dist/utilities/dom-lifecycle.bench.mjs +1 -1
- package/dist/utilities/dom-lifecycle.d.mts +19 -21
- package/dist/utilities/dom-lifecycle.mjs +16 -13
- package/dist/utilities/dom-lifecycle.test.mjs +2 -2
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.test.mjs +2 -2
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/element-scroll.test.mjs +2 -2
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/event-listener.test.mjs +2 -2
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/focus-within.test.mjs +2 -2
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.test.mjs +2 -2
- package/dist/utilities/intersection-observer.d.mts +17 -0
- package/dist/utilities/intersection-observer.mjs +17 -0
- package/dist/utilities/intersection-observer.test.mjs +2 -2
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/interval.test.mjs +2 -2
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/location.test.mjs +2 -2
- package/dist/utilities/long-press.test.mjs +2 -2
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.test.mjs +2 -2
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-player.test.mjs +2 -2
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/mutation-observer.test.mjs +2 -2
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/network.test.mjs +2 -2
- package/dist/utilities/on-click-outside.test.mjs +2 -2
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/previous.test.mjs +2 -2
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/promise.test.mjs +2 -2
- package/dist/utilities/retry.test.mjs +2 -2
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/routing.test.mjs +2 -2
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/search-params.test.mjs +2 -2
- package/dist/utilities/ssr.test.mjs +2 -2
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/storage.test.mjs +2 -2
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/throttled.test.mjs +2 -2
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.test.mjs +2 -2
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.test.mjs +2 -2
- package/package.json +1 -1
- package/dist/custom-elements-CBuenqVD.d.mts +0 -41
|
@@ -5106,7 +5106,7 @@ function manageArtifactAttachment(attachment) {
|
|
|
5106
5106
|
if (attachment.body != null) attachment.bodyEncoding ??= "base64";
|
|
5107
5107
|
}
|
|
5108
5108
|
//#endregion
|
|
5109
|
-
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.
|
|
5109
|
+
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.9_vite@8.0.8_@types+node@25.5.2_esbuild@0.27.7_/node_modules/vitest/dist/chunks/utils.BX5Fg8C4.js
|
|
5110
5110
|
const NAME_WORKER_STATE = "__vitest_worker__";
|
|
5111
5111
|
function getWorkerState() {
|
|
5112
5112
|
const workerState = globalThis[NAME_WORKER_STATE];
|
|
@@ -5146,7 +5146,7 @@ async function waitForImportsToResolve() {
|
|
|
5146
5146
|
await waitForImportsToResolve();
|
|
5147
5147
|
}
|
|
5148
5148
|
//#endregion
|
|
5149
|
-
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.
|
|
5149
|
+
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.9_vite@8.0.8_@types+node@25.5.2_esbuild@0.27.7_/node_modules/vitest/dist/chunks/benchmark.CX_oY03V.js
|
|
5150
5150
|
const benchFns = /* @__PURE__ */ new WeakMap();
|
|
5151
5151
|
const benchOptsMap = /* @__PURE__ */ new WeakMap();
|
|
5152
5152
|
const bench = createBenchmark(function(name, fn = noop, options = {}) {
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/custom-elements.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Registry of custom-element tags to their constructors.
|
|
4
|
+
* Users augment this interface to add typed JSX support for their elements.
|
|
5
|
+
*
|
|
6
|
+
* The interface lives in the global `ElementsKit` namespace so augmentations
|
|
7
|
+
* propagate cleanly through type-bundle chunk splits — augmenting a module
|
|
8
|
+
* subpath would not always merge with internal references inside the JSX
|
|
9
|
+
* namespace's `IntrinsicElements`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* declare global {
|
|
14
|
+
* namespace ElementsKit {
|
|
15
|
+
* interface CustomElementRegistry {
|
|
16
|
+
* "x-range": typeof XRange;
|
|
17
|
+
* }
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare global {
|
|
23
|
+
namespace ElementsKit {
|
|
24
|
+
interface CustomElementRegistry {}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
type CustomElementRegistry = ElementsKit.CustomElementRegistry;
|
|
28
|
+
type AnyCtor = CustomElementConstructor;
|
|
29
|
+
/**
|
|
30
|
+
* Register a custom element with the browser and return its class.
|
|
31
|
+
* Pair with an augmentation of `ElementsKit.CustomElementRegistry` to get typed JSX.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* import { defineElement } from "elements-kit/custom-elements";
|
|
36
|
+
*
|
|
37
|
+
* class XCounter extends HTMLElement {}
|
|
38
|
+
*
|
|
39
|
+
* defineElement("x-counter", XCounter);
|
|
40
|
+
*
|
|
41
|
+
* declare global {
|
|
42
|
+
* namespace ElementsKit {
|
|
43
|
+
* interface CustomElementRegistry {
|
|
44
|
+
* "x-counter": typeof XCounter;
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* // JSX now gets typed props + typed ref
|
|
50
|
+
* // <x-counter />
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
declare function defineElement<Tag extends `${string}-${string}`, C extends AnyCtor>(tag: Tag, cls: C, options?: ElementDefinitionOptions): C;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { defineElement as n, CustomElementRegistry as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as defineElement, t as CustomElementRegistry } from "./custom-elements-
|
|
1
|
+
import { n as defineElement, t as CustomElementRegistry } from "./custom-elements-D5CgfNKc.mjs";
|
|
2
2
|
export { CustomElementRegistry, defineElement };
|
package/dist/custom-elements.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/custom-elements.ts
|
|
2
2
|
/**
|
|
3
3
|
* Register a custom element with the browser and return its class.
|
|
4
|
-
* Pair with
|
|
4
|
+
* Pair with an augmentation of `ElementsKit.CustomElementRegistry` to get typed JSX.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```tsx
|
|
@@ -11,9 +11,11 @@
|
|
|
11
11
|
*
|
|
12
12
|
* defineElement("x-counter", XCounter);
|
|
13
13
|
*
|
|
14
|
-
* declare
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* declare global {
|
|
15
|
+
* namespace ElementsKit {
|
|
16
|
+
* interface CustomElementRegistry {
|
|
17
|
+
* "x-counter": typeof XCounter;
|
|
18
|
+
* }
|
|
17
19
|
* }
|
|
18
20
|
* }
|
|
19
21
|
*
|
package/dist/for.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-3r7Diua4.mjs";
|
|
2
|
-
import { t as CustomElementRegistry } from "./custom-elements-
|
|
2
|
+
import { t as CustomElementRegistry } from "./custom-elements-D5CgfNKc.mjs";
|
|
3
3
|
import { a as PrimitiveNodeType, i as Slots, n as Slot, t as SLOTS } from "./slot-CfafCBOW.mjs";
|
|
4
4
|
import { JSX } from "dom-expressions/src/jsx-h";
|
|
5
5
|
|
|
@@ -395,24 +395,34 @@ type SlotProps<K extends string> = { [P in K as `slot:${P}`]?: Child };
|
|
|
395
395
|
type Attrs<K extends keyof JSX$1.IntrinsicElements> = JSX$1.IntrinsicElements[K];
|
|
396
396
|
/**
|
|
397
397
|
* Namespaced JSX props added by elements-kit on top of dom-expressions.
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
* - `
|
|
401
|
-
*
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
*
|
|
406
|
-
* - `prop:
|
|
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).
|
|
407
413
|
*/
|
|
408
|
-
type
|
|
409
|
-
|
|
410
|
-
|
|
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;
|
|
411
419
|
[cls: `class:${string}`]: MaybeReactive<boolean>;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
type
|
|
420
|
+
} & StyleNamespace & PropNamespace<E>;
|
|
421
|
+
type JsxNamespaceKeys = "ref" | `class:${string}` | `style:${string}` | `prop:${string}`;
|
|
422
|
+
type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
|
|
423
|
+
type IntrinsicElementOf<T> = T extends {
|
|
424
|
+
ref?: infer R | undefined;
|
|
425
|
+
} ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element;
|
|
416
426
|
declare namespace JSX$1 {
|
|
417
427
|
export type Element = globalThis.Element | globalThis.DocumentFragment | null;
|
|
418
428
|
export type ElementType = Child | Component;
|
|
@@ -423,10 +433,8 @@ declare namespace JSX$1 {
|
|
|
423
433
|
ref?: (el: Element) => void;
|
|
424
434
|
}
|
|
425
435
|
export type LibraryManagedAttributes<C, P> = ResolveProps<C, P>;
|
|
426
|
-
type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends AnyElementCtor ? MaybeReactiveProps<ElementProps<CustomElementRegistry[K]>> : never };
|
|
427
|
-
export type IntrinsicElements = { [K in keyof JSX.IntrinsicElements]: WithJsxNamespaces<JSX.IntrinsicElements[K]
|
|
428
|
-
/** Unregistered custom elements (`x-foo`, `my-component`, …) — loose fallback. */[customElement: `${string}-${string}`]: WithJsxNamespaces<JSX.DOMAttributes<HTMLElement>> & Record<string, unknown>;
|
|
429
|
-
};
|
|
436
|
+
type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends AnyElementCtor ? WithJsxNamespaces<MaybeReactiveProps<ElementProps<CustomElementRegistry[K]>>, InstanceType<CustomElementRegistry[K]>> : never };
|
|
437
|
+
export type IntrinsicElements = { [K in keyof JSX.IntrinsicElements]: WithJsxNamespaces<JSX.IntrinsicElements[K], IntrinsicElementOf<JSX.IntrinsicElements[K]>> } & RegisteredElements;
|
|
430
438
|
export {};
|
|
431
439
|
}
|
|
432
440
|
//#endregion
|
|
@@ -466,7 +474,7 @@ type PropValueFor<V> = V extends Slot ? Child : V;
|
|
|
466
474
|
* the DOM surface is excluded; for plain classes, all own keys are kept.
|
|
467
475
|
* `Slot`-typed fields are mapped to `Child` (see {@link PropValueFor}).
|
|
468
476
|
*/
|
|
469
|
-
type
|
|
477
|
+
type InstanceProps<I> = { [K in PublicPropKeys<I> & string]?: PropValueFor<I[K]> };
|
|
470
478
|
/**
|
|
471
479
|
* Promote keys `K` of `P` to required; leave the rest unchanged.
|
|
472
480
|
*
|
|
@@ -482,11 +490,14 @@ type PropsOfInstance<I> = { [K in PublicPropKeys<I> & string]?: PropValueFor<I[K
|
|
|
482
490
|
*/
|
|
483
491
|
type Require<P, K extends keyof P> = { [X in K]-?: P[X] } & Omit<P, K>;
|
|
484
492
|
/**
|
|
485
|
-
* Wrap every prop in {@link MaybeReactive} so callers may pass
|
|
486
|
-
* plain value or a reactive getter. Function-typed props (event
|
|
487
|
-
* render callbacks) are
|
|
488
|
-
*
|
|
489
|
-
*
|
|
493
|
+
* Wrap every non-function prop in {@link MaybeReactive} so callers may pass
|
|
494
|
+
* either a plain value or a reactive getter. Function-typed props (event
|
|
495
|
+
* handlers, render callbacks) are left as-is so inline arrow callbacks get
|
|
496
|
+
* proper contextual typing for their parameters — wrapping them in
|
|
497
|
+
* `MaybeReactive<F> = F | (() => F)` produces two callable alternatives and
|
|
498
|
+
* TS falls back to implicit-any on the callback's params. Optionality is
|
|
499
|
+
* preserved at the key level — the `| undefined` stays at the prop, not
|
|
500
|
+
* inside the reactive.
|
|
490
501
|
*
|
|
491
502
|
* @template P — source prop object type.
|
|
492
503
|
*
|
|
@@ -497,14 +508,15 @@ type Require<P, K extends keyof P> = { [X in K]-?: P[X] } & Omit<P, K>;
|
|
|
497
508
|
* // {
|
|
498
509
|
* // count: MaybeReactive<number>;
|
|
499
510
|
* // label?: MaybeReactive<string>;
|
|
500
|
-
* // onClick:
|
|
511
|
+
* // onClick: (e: Event) => void;
|
|
501
512
|
* // }
|
|
502
513
|
* ```
|
|
503
514
|
*
|
|
504
515
|
* @see {@link MaybeReactive}
|
|
505
516
|
* @see {@link Props}
|
|
506
517
|
*/
|
|
507
|
-
type MaybeReactiveProps<P> = { [K in keyof P]: undefined extends P[K] ?
|
|
518
|
+
type MaybeReactiveProps<P> = { [K in keyof P]: undefined extends P[K] ? MaybeReactiveOrFn<Exclude<P[K], undefined>> | undefined : MaybeReactiveOrFn<P[K]> };
|
|
519
|
+
type MaybeReactiveOrFn<T> = Extract<T, (...args: any[]) => any> extends never ? MaybeReactive<T> : T;
|
|
508
520
|
declare const RAW_PROPS: unique symbol;
|
|
509
521
|
type ReactiveProps<P> = { readonly [K in keyof P]: Computed<P[K]> } & {
|
|
510
522
|
readonly [RAW_PROPS]?: P;
|
|
@@ -526,7 +538,7 @@ type RawProps<R> = R extends {
|
|
|
526
538
|
type ResolveProps<C, P, NN = NonNullable<P>> = NN extends {
|
|
527
539
|
readonly [RAW_PROPS]?: infer Raw;
|
|
528
540
|
} ? MaybeReactiveProps<Raw> : [keyof NN] extends [never] ? Props<C> : NN;
|
|
529
|
-
type InstancePropsOf<C> = Inst<C> extends infer I ?
|
|
541
|
+
type InstancePropsOf<C> = Inst<C> extends infer I ? InstanceProps<I> : {};
|
|
530
542
|
type PropKeysOf<C> = keyof InstancePropsOf<C> & string;
|
|
531
543
|
type AttrMap<C> = C extends {
|
|
532
544
|
[ATTRIBUTES]: infer M;
|
|
@@ -620,9 +632,9 @@ type ComponentProps<C extends ComponentClass<any>> = C extends ComponentClass<in
|
|
|
620
632
|
* prop in {@link MaybeReactive} so callers may pass values or reactive getters.
|
|
621
633
|
*
|
|
622
634
|
* Branches by input shape:
|
|
623
|
-
* - **Class constructor** (`typeof Cls`) → uses `
|
|
635
|
+
* - **Class constructor** (`typeof Cls`) → uses `InstanceProps<InstanceType<Cls>>`.
|
|
624
636
|
* - **Function component** (`(props: P) => ...`) → uses the first parameter.
|
|
625
|
-
* - **Class instance** (`Cls<T>`) → uses `
|
|
637
|
+
* - **Class instance** (`Cls<T>`) → uses `InstanceProps<Cls<T>>` (useful when
|
|
626
638
|
* generics need to flow through — see the `For` example below).
|
|
627
639
|
*
|
|
628
640
|
* Does **not** synthesize `on:*`, `slot:*`, or attribute surface. For custom
|
|
@@ -652,6 +664,6 @@ type ComponentProps<C extends ComponentClass<any>> = C extends ComponentClass<in
|
|
|
652
664
|
* @see {@link ComponentProps} — constructor-param-based class components.
|
|
653
665
|
* @see {@link MaybeReactiveProps}
|
|
654
666
|
*/
|
|
655
|
-
type Props<C> = (C extends (abstract new (...args: any[]) => infer I) ? MaybeReactiveProps<
|
|
667
|
+
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>;
|
|
656
668
|
//#endregion
|
|
657
669
|
export { SIGNAL as A, signal as B, isReactive as C, COMPUTED as D, resolveProps as E, isComputed as F, untracked as H, isEffect as I, isEffectScope as L, computed as M, effect as N, EFFECT as O, effectScope as P, isSignal as R, Updater as S, resolve as T, createElement as U, trigger as V, SlotProps as _, RawProps as a, MaybeReactive as b, ResolveProps as c, ComponentClass as d, ComponentFn as f, JSX$1 as g, Attrs as h, Props as i, batch as j, EFFECT_SCOPE as k, Child as l, PropsTarget as m, ElementProps as n, ReactiveProps as o, ComponentInstance as p, MaybeReactiveProps as r, Require as s, ComponentProps as t, Component as u, Fragment as v, reactive as w, Signal as x, Computed as y, onCleanup as z };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { U as createElement, _ as SlotProps, a as RawProps, b as MaybeReactive, c as ResolveProps, d as ComponentClass, f as ComponentFn, g as JSX, h as Attrs, i as Props, l as Child, m as PropsTarget, n as ElementProps, o as ReactiveProps, p as ComponentInstance, r as MaybeReactiveProps, s as Require, t as ComponentProps, u as Component, v as Fragment } from "../infer-
|
|
1
|
+
import { U as createElement, _ as SlotProps, a as RawProps, b as MaybeReactive, c as ResolveProps, d as ComponentClass, f as ComponentFn, g as JSX, h as Attrs, i as Props, l as Child, m as PropsTarget, n as ElementProps, o as ReactiveProps, p as ComponentInstance, r as MaybeReactiveProps, s as Require, t as ComponentProps, u as Component, v as Fragment } from "../infer-LDn1TquI.mjs";
|
|
2
2
|
export { Attrs, Child, Component, ComponentClass, ComponentFn, ComponentInstance, ComponentProps, ElementProps, Fragment, JSX, MaybeReactive, MaybeReactiveProps, Props, PropsTarget, RawProps, ReactiveProps, Require, ResolveProps, SlotProps, createElement as h, createElement as jsx, createElement as jsxDEV, createElement as jsxs };
|
package/dist/signals/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as SIGNAL, B as signal, C as isReactive, D as COMPUTED, E as resolveProps, F as isComputed, H as untracked, I as isEffect, L as isEffectScope, M as computed, N as effect, O as EFFECT, P as effectScope, R as isSignal, S as Updater, T as resolve, V as trigger, b as MaybeReactive, j as batch, k as EFFECT_SCOPE, w as reactive, x as Signal, y as Computed, z as onCleanup } from "../infer-
|
|
1
|
+
import { A as SIGNAL, B as signal, C as isReactive, D as COMPUTED, E as resolveProps, F as isComputed, H as untracked, I as isEffect, L as isEffectScope, M as computed, N as effect, O as EFFECT, P as effectScope, R as isSignal, S as Updater, T as resolve, V as trigger, b as MaybeReactive, j as batch, k as EFFECT_SCOPE, w as reactive, x as Signal, y as Computed, z as onCleanup } from "../infer-LDn1TquI.mjs";
|
|
2
2
|
export { COMPUTED, Computed, EFFECT, EFFECT_SCOPE, MaybeReactive, SIGNAL, Signal, Updater, batch, computed, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, onCleanup, reactive, resolve, resolveProps, signal, trigger, untracked };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as plugins, C as getCallLastIndex, D as ordinal, E as noop, O as stringify, S as createSimpleStackTrace, T as isObject, _ as getSafeTimers, a as waitForImportsToResolve, b as printDiffOrStringify, d as getNames, g as delay, h as parseSingleStack, i as resetModules, j as y, k as format, m as parseErrorStacktrace, n as getWorkerState, r as isChildProcess, u as getCurrentTest, v as processError, w as getType, x as assertTypes, y as diff } from "./benchmark.CX_oY03V-
|
|
1
|
+
import { A as plugins, C as getCallLastIndex, D as ordinal, E as noop, O as stringify, S as createSimpleStackTrace, T as isObject, _ as getSafeTimers, a as waitForImportsToResolve, b as printDiffOrStringify, d as getNames, g as delay, h as parseSingleStack, i as resetModules, j as y, k as format, m as parseErrorStacktrace, n as getWorkerState, r as isChildProcess, u as getCurrentTest, v as processError, w as getType, x as assertTypes, y as diff } from "./benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
2
|
//#region node_modules/.pnpm/@vitest+spy@4.1.3/node_modules/@vitest/spy/dist/index.js
|
|
3
3
|
function isMockFunction(fn) {
|
|
4
4
|
return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
|
|
@@ -4735,10 +4735,10 @@ function offsetToLineNumber(source, offset) {
|
|
|
4735
4735
|
return line + 1;
|
|
4736
4736
|
}
|
|
4737
4737
|
//#endregion
|
|
4738
|
-
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.
|
|
4738
|
+
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.9_vite@8.0.8_@types+node@25.5.2_esbuild@0.27.7_/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js
|
|
4739
4739
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
4740
4740
|
//#endregion
|
|
4741
|
-
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.
|
|
4741
|
+
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.9_vite@8.0.8_@types+node@25.5.2_esbuild@0.27.7_/node_modules/vitest/dist/chunks/rpc.MzXet3jl.js
|
|
4742
4742
|
const RealDate = Date;
|
|
4743
4743
|
let now = null;
|
|
4744
4744
|
var MockDate = class MockDate extends RealDate {
|
|
@@ -5506,7 +5506,7 @@ var SnapshotClient = class {
|
|
|
5506
5506
|
}
|
|
5507
5507
|
};
|
|
5508
5508
|
//#endregion
|
|
5509
|
-
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.
|
|
5509
|
+
//#region node_modules/.pnpm/vitest@4.1.3_@types+node@25.5.2_happy-dom@20.8.9_vite@8.0.8_@types+node@25.5.2_esbuild@0.27.7_/node_modules/vitest/dist/chunks/test.BmQO5GaM.js
|
|
5510
5510
|
var fakeTimersSrc = {};
|
|
5511
5511
|
var global$1;
|
|
5512
5512
|
var hasRequiredGlobal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as it, l as describe } from "../benchmark.CX_oY03V-
|
|
2
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
3
3
|
import { activeElement } from "./active-element.mjs";
|
|
4
4
|
//#region src/utilities/active-element.test.ts
|
|
5
5
|
describe("activeElement (singleton)", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as MaybeReactive } from "../infer-
|
|
1
|
+
import { b as MaybeReactive } from "../infer-LDn1TquI.mjs";
|
|
2
2
|
import { ComputedPromise } from "./promise.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utilities/async.d.ts
|
|
@@ -9,6 +9,12 @@ type Fn<TInput, TOutput> = (input: TInput) => Promise<TOutput>;
|
|
|
9
9
|
* reactive signals (`state`, `value`, `reason`, `result`, `pending`) and
|
|
10
10
|
* lets you `run`/`start`/`stop` the underlying task imperatively.
|
|
11
11
|
*
|
|
12
|
+
* Trigger choice: `start()` tracks the body and re-runs when its parameter
|
|
13
|
+
* signals change — right for "fetch X whenever `id` changes". `run()` is
|
|
14
|
+
* one-shot and untracked — right for externally-driven loads (intersection,
|
|
15
|
+
* click, form submit), especially when the body writes to the same signals
|
|
16
|
+
* it reads (`start()` would cascade).
|
|
17
|
+
*
|
|
12
18
|
* Prefer the {@link async} factory — it returns an `Async` that is also
|
|
13
19
|
* callable as a signal (`op()` === `op.result`), which is what most call
|
|
14
20
|
* sites want. Use this class directly only when you need the object form.
|
package/dist/utilities/async.mjs
CHANGED
|
@@ -7,6 +7,12 @@ import { promise } from "./promise.mjs";
|
|
|
7
7
|
* reactive signals (`state`, `value`, `reason`, `result`, `pending`) and
|
|
8
8
|
* lets you `run`/`start`/`stop` the underlying task imperatively.
|
|
9
9
|
*
|
|
10
|
+
* Trigger choice: `start()` tracks the body and re-runs when its parameter
|
|
11
|
+
* signals change — right for "fetch X whenever `id` changes". `run()` is
|
|
12
|
+
* one-shot and untracked — right for externally-driven loads (intersection,
|
|
13
|
+
* click, form submit), especially when the body writes to the same signals
|
|
14
|
+
* it reads (`start()` would cascade).
|
|
15
|
+
*
|
|
10
16
|
* Prefer the {@link async} factory — it returns an `Async` that is also
|
|
11
17
|
* callable as a signal (`op()` === `op.result`), which is what most call
|
|
12
18
|
* sites want. Use this class directly only when you need the object form.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { m as signal, p as onCleanup, s as effect } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { Async, async } from "./async.mjs";
|
|
6
6
|
import { createInterval } from "./interval.mjs";
|
|
7
7
|
//#region src/utilities/async.test.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope, m as signal, s as effect } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { getContext, setContext } from "./context.mjs";
|
|
6
6
|
//#region src/utilities/context.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope, m as signal } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { c as beforeEach, f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { c as beforeEach, f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createDebounced } from "./debounced.mjs";
|
|
6
6
|
//#region src/utilities/debounced.test.ts
|
|
7
7
|
beforeEach(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { l as describe, t as bench } from "../benchmark.CX_oY03V-
|
|
1
|
+
import { l as describe, t as bench } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
2
|
//#region src/utilities/dom-lifecycle.bench.ts
|
|
3
3
|
describe("dom-lifecycle — registration cost", () => {
|
|
4
4
|
bench("register 100 entries on already-connected elements", () => {
|
|
@@ -34,19 +34,9 @@ type AdoptedCallback = (oldDocument: Document, newDocument: Document) => void;
|
|
|
34
34
|
* place the lifecycle element where those selectors don't reach if needed.)
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* onConnect={(el) => el.parentElement?.classList.add("ready")}
|
|
41
|
-
* onDisconnect={(el) => {
|
|
42
|
-
* // el.parentElement is null here per spec — stash from onConnect if needed
|
|
43
|
-
* }}
|
|
44
|
-
* />
|
|
45
|
-
* </div>
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* Wrap children — read the wrapped subtree via `firstElementChild`:
|
|
37
|
+
* Canonical form — wrap the subtree the lifecycle owns. `onConnect` runs
|
|
38
|
+
* inside an `effectScope` tied to the wrapped subtree, so observers, context
|
|
39
|
+
* lookups, and `onCleanup` registrations clean up on disconnect.
|
|
50
40
|
* ```tsx
|
|
51
41
|
* <section>
|
|
52
42
|
* <dom-lifecycle onConnect={(el) => measure(el.firstElementChild)}>
|
|
@@ -55,6 +45,19 @@ type AdoptedCallback = (oldDocument: Document, newDocument: Document) => void;
|
|
|
55
45
|
* </dom-lifecycle>
|
|
56
46
|
* </section>
|
|
57
47
|
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* Sibling form — fallback for cases where the host element is already
|
|
51
|
+
* present for layout reasons and you only need lifecycle on the surrounding
|
|
52
|
+
* element. Read `self.parentElement` for the host; capture it in `onConnect`
|
|
53
|
+
* if you need it on disconnect (the spec nulls it before `onDisconnect`).
|
|
54
|
+
* ```tsx
|
|
55
|
+
* <div>
|
|
56
|
+
* <dom-lifecycle
|
|
57
|
+
* onConnect={(el) => el.parentElement?.classList.add("ready")}
|
|
58
|
+
* />
|
|
59
|
+
* </div>
|
|
60
|
+
* ```
|
|
58
61
|
*/
|
|
59
62
|
declare class DomLifecycleElement extends HTMLElement {
|
|
60
63
|
#private;
|
|
@@ -72,14 +75,9 @@ declare class DomLifecycleElement extends HTMLElement {
|
|
|
72
75
|
adoptedCallback(oldDocument: Document, newDocument: Document): void;
|
|
73
76
|
}
|
|
74
77
|
declare global {
|
|
75
|
-
namespace
|
|
76
|
-
interface
|
|
77
|
-
"dom-lifecycle":
|
|
78
|
-
onConnect?: LifecycleCallback;
|
|
79
|
-
onDisconnect?: LifecycleCallback;
|
|
80
|
-
onMove?: LifecycleCallback;
|
|
81
|
-
onAdopted?: AdoptedCallback;
|
|
82
|
-
};
|
|
78
|
+
namespace ElementsKit {
|
|
79
|
+
interface CustomElementRegistry {
|
|
80
|
+
"dom-lifecycle": typeof DomLifecycleElement;
|
|
83
81
|
}
|
|
84
82
|
}
|
|
85
83
|
}
|
|
@@ -35,19 +35,9 @@ import { isBrowser } from "./environment.mjs";
|
|
|
35
35
|
* place the lifecycle element where those selectors don't reach if needed.)
|
|
36
36
|
*
|
|
37
37
|
* @example
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* onConnect={(el) => el.parentElement?.classList.add("ready")}
|
|
42
|
-
* onDisconnect={(el) => {
|
|
43
|
-
* // el.parentElement is null here per spec — stash from onConnect if needed
|
|
44
|
-
* }}
|
|
45
|
-
* />
|
|
46
|
-
* </div>
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* Wrap children — read the wrapped subtree via `firstElementChild`:
|
|
38
|
+
* Canonical form — wrap the subtree the lifecycle owns. `onConnect` runs
|
|
39
|
+
* inside an `effectScope` tied to the wrapped subtree, so observers, context
|
|
40
|
+
* lookups, and `onCleanup` registrations clean up on disconnect.
|
|
51
41
|
* ```tsx
|
|
52
42
|
* <section>
|
|
53
43
|
* <dom-lifecycle onConnect={(el) => measure(el.firstElementChild)}>
|
|
@@ -56,6 +46,19 @@ import { isBrowser } from "./environment.mjs";
|
|
|
56
46
|
* </dom-lifecycle>
|
|
57
47
|
* </section>
|
|
58
48
|
* ```
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* Sibling form — fallback for cases where the host element is already
|
|
52
|
+
* present for layout reasons and you only need lifecycle on the surrounding
|
|
53
|
+
* element. Read `self.parentElement` for the host; capture it in `onConnect`
|
|
54
|
+
* if you need it on disconnect (the spec nulls it before `onDisconnect`).
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <div>
|
|
57
|
+
* <dom-lifecycle
|
|
58
|
+
* onConnect={(el) => el.parentElement?.classList.add("ready")}
|
|
59
|
+
* />
|
|
60
|
+
* </div>
|
|
61
|
+
* ```
|
|
59
62
|
*/
|
|
60
63
|
var DomLifecycleElement = class extends HTMLElement {
|
|
61
64
|
#onConnect = null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
2
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
3
3
|
import { DomLifecycleElement } from "./dom-lifecycle.mjs";
|
|
4
4
|
//#region src/utilities/dom-lifecycle.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createElementRect } from "./element-rect.mjs";
|
|
6
6
|
//#region src/utilities/element-rect.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createElementScroll } from "./element-scroll.mjs";
|
|
6
6
|
//#region src/utilities/element-scroll.test.ts
|
|
7
7
|
describe("createElementScroll", () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as effectScope, m as signal, s as effect } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
3
|
import { on } from "./event-listener.mjs";
|
|
4
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
5
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
4
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
5
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
6
6
|
//#region src/utilities/event-listener.test.ts
|
|
7
7
|
afterEach(() => {
|
|
8
8
|
document.body.innerHTML = "";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createFocusWithin } from "./focus-within.mjs";
|
|
6
6
|
//#region src/utilities/focus-within.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createHover } from "./hover.mjs";
|
|
6
6
|
//#region src/utilities/hover.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Raw `IntersectionObserver` wrapper with automatic cleanup.
|
|
4
4
|
* Use `createIsInViewport` for the common boolean case.
|
|
5
|
+
*
|
|
6
|
+
* The platform default is `root: null`, which observes intersections with
|
|
7
|
+
* the **viewport** — not with `target`'s nearest scrollable ancestor. For a
|
|
8
|
+
* sentinel inside an in-page scroll container, pass `root: containerEl`
|
|
9
|
+
* explicitly; otherwise the sentinel reads as "intersecting" the viewport
|
|
10
|
+
* and fires immediately and repeatedly.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* // In-page scroll container — pass `root` so intersection is computed
|
|
15
|
+
* // against the container's scrollport, not the viewport.
|
|
16
|
+
* createIntersectionObserver(
|
|
17
|
+
* sentinelEl,
|
|
18
|
+
* ([entry]) => { if (entry.isIntersecting) loadMore.run(); },
|
|
19
|
+
* { root: containerEl, rootMargin: "100px" },
|
|
20
|
+
* );
|
|
21
|
+
* ```
|
|
5
22
|
*/
|
|
6
23
|
declare function createIntersectionObserver(target: Element, callback: IntersectionObserverCallback, options?: IntersectionObserverInit): Disposable;
|
|
7
24
|
//#endregion
|
|
@@ -3,6 +3,23 @@ import { observe } from "./_observe.mjs";
|
|
|
3
3
|
/**
|
|
4
4
|
* Raw `IntersectionObserver` wrapper with automatic cleanup.
|
|
5
5
|
* Use `createIsInViewport` for the common boolean case.
|
|
6
|
+
*
|
|
7
|
+
* The platform default is `root: null`, which observes intersections with
|
|
8
|
+
* the **viewport** — not with `target`'s nearest scrollable ancestor. For a
|
|
9
|
+
* sentinel inside an in-page scroll container, pass `root: containerEl`
|
|
10
|
+
* explicitly; otherwise the sentinel reads as "intersecting" the viewport
|
|
11
|
+
* and fires immediately and repeatedly.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* // In-page scroll container — pass `root` so intersection is computed
|
|
16
|
+
* // against the container's scrollport, not the viewport.
|
|
17
|
+
* createIntersectionObserver(
|
|
18
|
+
* sentinelEl,
|
|
19
|
+
* ([entry]) => { if (entry.isIntersecting) loadMore.run(); },
|
|
20
|
+
* { root: containerEl, rootMargin: "100px" },
|
|
21
|
+
* );
|
|
22
|
+
* ```
|
|
6
23
|
*/
|
|
7
24
|
function createIntersectionObserver(target, callback, options) {
|
|
8
25
|
return observe(new IntersectionObserver(callback, options), (o) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createIntersectionObserver } from "./intersection-observer.mjs";
|
|
6
6
|
//#region src/utilities/intersection-observer.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { async } from "./async.mjs";
|
|
6
6
|
import { createInterval } from "./interval.mjs";
|
|
7
7
|
//#region src/utilities/interval.test.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
2
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
3
3
|
import { currentLocation } from "./location.mjs";
|
|
4
4
|
//#region src/utilities/location.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createLongPress } from "./long-press.mjs";
|
|
6
6
|
//#region src/utilities/long-press.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createMediaDevices } from "./media-devices.mjs";
|
|
6
6
|
//#region src/utilities/media-devices.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createMediaPlayer } from "./media-player.mjs";
|
|
6
6
|
//#region src/utilities/media-player.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createMutationObserver } from "./mutation-observer.mjs";
|
|
6
6
|
//#region src/utilities/mutation-observer.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
2
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
3
3
|
import { online } from "./network.mjs";
|
|
4
4
|
//#region src/utilities/network.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { onClickOutside } from "./on-click-outside.mjs";
|
|
6
6
|
//#region src/utilities/on-click-outside.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope, m as signal } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createPrevious } from "./previous.mjs";
|
|
6
6
|
//#region src/utilities/previous.test.ts
|
|
7
7
|
describe("createPrevious", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { s as effect } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { ReactivePromise, promise } from "./promise.mjs";
|
|
6
6
|
//#region src/utilities/promise.test.ts
|
|
7
7
|
describe("ReactivePromise", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { p as onCleanup } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { retry } from "./retry.mjs";
|
|
6
6
|
//#region src/utilities/retry.test.ts
|
|
7
7
|
describe("retry", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as it, l as describe, o as afterEach, s as beforeAll } from "../benchmark.CX_oY03V-
|
|
2
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as it, l as describe, o as afterEach, s as beforeAll } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
3
3
|
import { isLocalNavigationEvent, match, matches, navigate, patchHistory } from "./routing.mjs";
|
|
4
4
|
//#region src/utilities/routing.test.ts
|
|
5
5
|
beforeAll(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createSearchParam } from "./search-params.mjs";
|
|
6
6
|
//#region src/utilities/search-params.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { p as test } from "../benchmark.CX_oY03V-
|
|
2
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { p as test } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
3
3
|
//#region src/utilities/ssr.test.ts
|
|
4
4
|
// @vitest-environment node
|
|
5
5
|
test.each([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createLocalStorage, createSessionStorage } from "./storage.mjs";
|
|
6
6
|
//#region src/utilities/storage.test.ts
|
|
7
7
|
describe("createLocalStorage", () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope, m as signal } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { c as beforeEach, f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { c as beforeEach, f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createThrottled } from "./throttled.mjs";
|
|
6
6
|
//#region src/utilities/throttled.test.ts
|
|
7
7
|
beforeEach(() => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as effectScope } from "../lib-CVfOddra.mjs";
|
|
2
2
|
import "../signals/index.mjs";
|
|
3
|
-
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-
|
|
4
|
-
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-
|
|
3
|
+
import { f as it, l as describe, o as afterEach } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
4
|
+
import { n as vi, t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
5
5
|
import { createTimeout } from "./timeout.mjs";
|
|
6
6
|
//#region src/utilities/timeout.test.ts
|
|
7
7
|
afterEach(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as it, l as describe } from "../benchmark.CX_oY03V-
|
|
2
|
-
import { t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as it, l as describe } from "../benchmark.CX_oY03V-CsUg-gW0.mjs";
|
|
2
|
+
import { t as globalExpect } from "../test.BmQO5GaM-ZC2MPXQb.mjs";
|
|
3
3
|
import { windowSize } from "./window-size.mjs";
|
|
4
4
|
//#region src/utilities/window-size.test.ts
|
|
5
5
|
describe("windowSize (singleton)", () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elements-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2",
|
|
5
5
|
"description": "A lightweight reactive UI library that transforms native HTMLElements into reactive components with signals. Ideal for framework-agnostic applications and web components.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"webcomponents",
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/custom-elements.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Registry of custom-element tags to their constructors.
|
|
4
|
-
* Users augment this interface to add typed JSX support for their elements:
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* declare module "elements-kit/custom-elements" {
|
|
9
|
-
* interface CustomElementRegistry {
|
|
10
|
-
* "x-range": typeof XRange;
|
|
11
|
-
* }
|
|
12
|
-
* }
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
interface CustomElementRegistry {}
|
|
16
|
-
type AnyCtor = CustomElementConstructor;
|
|
17
|
-
/**
|
|
18
|
-
* Register a custom element with the browser and return its class.
|
|
19
|
-
* Pair with a module augmentation of `CustomElementRegistry` to get typed JSX.
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```tsx
|
|
23
|
-
* import { defineElement } from "elements-kit/custom-elements";
|
|
24
|
-
*
|
|
25
|
-
* class XCounter extends HTMLElement {}
|
|
26
|
-
*
|
|
27
|
-
* defineElement("x-counter", XCounter);
|
|
28
|
-
*
|
|
29
|
-
* declare module "elements-kit/custom-elements" {
|
|
30
|
-
* interface CustomElementRegistry {
|
|
31
|
-
* "x-counter": typeof XCounter;
|
|
32
|
-
* }
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* // JSX now gets typed props + typed ref
|
|
36
|
-
* // <x-counter />
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function defineElement<Tag extends `${string}-${string}`, C extends AnyCtor>(tag: Tag, cls: C, options?: ElementDefinitionOptions): C;
|
|
40
|
-
//#endregion
|
|
41
|
-
export { defineElement as n, CustomElementRegistry as t };
|