elements-kit 0.0.18 → 0.0.20
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 +65 -118
- package/dist/{attributes-Dtn68R1u.d.mts → attributes-DILeh3-s.d.mts} +42 -9
- package/dist/attributes.d.mts +1 -1
- package/dist/attributes.mjs +32 -0
- package/dist/{define-CjbTZ3VG.d.mts → custom-elements-D5_NMNyD.d.mts} +20 -2
- package/dist/custom-elements.d.mts +2 -74
- package/dist/custom-elements.mjs +15 -86
- package/dist/{element-CGVy_8TW.mjs → element-w1GCIMVp.mjs} +33 -21
- package/dist/for.d.mts +31 -2
- package/dist/for.mjs +18 -2
- package/dist/infer-DuFY-y2b.d.mts +657 -0
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +6 -4
- package/dist/jsx-runtime/index.d.mts +2 -73
- package/dist/jsx-runtime/index.mjs +8 -14
- package/dist/{signals-J8dK_rA4.mjs → lib-D6duEs38.mjs} +1 -105
- package/dist/render.d.mts +21 -0
- package/dist/render.mjs +32 -0
- package/dist/scope-DM2gzOkb.mjs +45 -0
- package/dist/signals/index.d.mts +1 -1
- package/dist/signals/index.mjs +134 -1
- package/dist/{slot-Kb61AcgW.mjs → slot-CKtUoy2X.mjs} +0 -1
- package/dist/{slot-C7GQZe-r.d.mts → slot-D5iBUSAm.d.mts} +18 -1
- package/dist/slot.d.mts +1 -1
- package/dist/slot.mjs +1 -1
- package/dist/{test.BmQO5GaM-DfGStnii.mjs → test.BmQO5GaM-BeO5pvCo.mjs} +1 -1
- package/dist/utilities/_observe.mjs +2 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/active-element.mjs +2 -1
- package/dist/utilities/active-element.test.mjs +1 -1
- package/dist/utilities/async.d.mts +39 -1
- package/dist/utilities/async.mjs +39 -1
- package/dist/utilities/async.test.mjs +3 -2
- package/dist/utilities/debounced.d.mts +12 -1
- package/dist/utilities/debounced.mjs +13 -1
- package/dist/utilities/debounced.test.mjs +3 -2
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.mjs +2 -1
- package/dist/utilities/element-rect.test.mjs +3 -2
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/element-scroll.test.mjs +3 -2
- package/dist/utilities/environment.d.mts +2 -0
- package/dist/utilities/environment.mjs +2 -0
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-driven.mjs +2 -1
- package/dist/utilities/event-listener.d.mts +12 -1
- package/dist/utilities/event-listener.mjs +2 -1
- package/dist/utilities/event-listener.test.mjs +3 -2
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/focus-within.mjs +2 -1
- package/dist/utilities/focus-within.test.mjs +3 -2
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.mjs +2 -1
- package/dist/utilities/hover.test.mjs +3 -2
- package/dist/utilities/intersection-observer.test.mjs +3 -2
- package/dist/utilities/interval.d.mts +14 -1
- package/dist/utilities/interval.mjs +2 -1
- package/dist/utilities/interval.test.mjs +3 -2
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/location.mjs +2 -1
- package/dist/utilities/location.test.mjs +1 -1
- package/dist/utilities/long-press.test.mjs +3 -2
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.mjs +2 -1
- package/dist/utilities/media-devices.test.mjs +3 -2
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-player.test.mjs +3 -2
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/media-query.mjs +2 -1
- package/dist/utilities/mutation-observer.test.mjs +3 -2
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/network.mjs +2 -1
- package/dist/utilities/network.test.mjs +1 -1
- package/dist/utilities/on-click-outside.test.mjs +3 -2
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/orientation.mjs +2 -1
- package/dist/utilities/previous.d.mts +13 -1
- package/dist/utilities/previous.mjs +14 -1
- package/dist/utilities/previous.test.mjs +3 -2
- package/dist/utilities/promise.d.mts +7 -1
- package/dist/utilities/promise.mjs +2 -1
- package/dist/utilities/promise.test.mjs +3 -2
- package/dist/utilities/retry.d.mts +15 -0
- package/dist/utilities/retry.mjs +17 -1
- package/dist/utilities/retry.test.mjs +3 -2
- package/dist/utilities/routing.d.mts +12 -1
- package/dist/utilities/routing.mjs +13 -1
- package/dist/utilities/routing.test.mjs +1 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/search-params.test.mjs +3 -2
- package/dist/utilities/ssr.test.mjs +1 -1
- package/dist/utilities/storage.d.mts +18 -1
- package/dist/utilities/storage.mjs +17 -0
- package/dist/utilities/storage.test.mjs +3 -2
- package/dist/utilities/throttled.d.mts +12 -1
- package/dist/utilities/throttled.mjs +13 -1
- package/dist/utilities/throttled.test.mjs +3 -2
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.mjs +2 -1
- package/dist/utilities/timeout.test.mjs +3 -2
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-focus.mjs +2 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.mjs +2 -1
- package/dist/utilities/window-size.test.mjs +1 -1
- package/package.json +1 -1
- package/dist/index-DydGTqZU.d.mts +0 -315
- package/dist/infer-BfzRJoCn.d.mts +0 -203
- package/dist/polyfill-BVNd6ogU.d.mts +0 -9
- /package/dist/{magic-string.es-i62WTP6J.mjs → magic-string.es-cTgJnTCj.mjs} +0 -0
package/dist/utilities/async.mjs
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as untracked, m as signal, s as effect } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import { resolve } from "../signals/index.mjs";
|
|
2
3
|
import { promise } from "./promise.mjs";
|
|
3
4
|
//#region src/utilities/async.ts
|
|
5
|
+
/**
|
|
6
|
+
* Reactive wrapper around an async function. Exposes the current run as
|
|
7
|
+
* reactive signals (`state`, `value`, `reason`, `result`, `pending`) and
|
|
8
|
+
* lets you `run`/`start`/`stop` the underlying task imperatively.
|
|
9
|
+
*
|
|
10
|
+
* Prefer the {@link async} factory — it returns an `Async` that is also
|
|
11
|
+
* callable as a signal (`op()` === `op.result`), which is what most call
|
|
12
|
+
* sites want. Use this class directly only when you need the object form.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { Async } from "elements-kit/utilities/async";
|
|
17
|
+
*
|
|
18
|
+
* const loader = new Async<string, User>(fetchUser);
|
|
19
|
+
* loader.run("alice");
|
|
20
|
+
* effect(() => {
|
|
21
|
+
* if (loader.state === "fulfilled") console.log(loader.value);
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
4
25
|
var Async = class {
|
|
5
26
|
#fn = signal(async () => Promise.resolve(void 0));
|
|
6
27
|
#cleanup = () => {};
|
|
@@ -96,6 +117,23 @@ const ASYNC_KEYS = new Set([
|
|
|
96
117
|
"raw",
|
|
97
118
|
Symbol.dispose
|
|
98
119
|
]);
|
|
120
|
+
/**
|
|
121
|
+
* Create an {@link Async} that is also callable as a signal: invoking it
|
|
122
|
+
* (with no args) reads the current `result`, so it drops into any reactive
|
|
123
|
+
* context that expects a zero-arg getter.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* import { async } from "elements-kit/utilities/async";
|
|
128
|
+
*
|
|
129
|
+
* const load = async((id: string) => fetch(`/u/${id}`).then(r => r.json()));
|
|
130
|
+
* load.run("alice");
|
|
131
|
+
*
|
|
132
|
+
* // Read as a signal — subscribes to result changes
|
|
133
|
+
* effect(() => console.log(load()));
|
|
134
|
+
* await load; // Await the current run — works like a normal promise
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
99
137
|
function async(fn) {
|
|
100
138
|
const inst = new Async(fn);
|
|
101
139
|
const signal = () => inst.result;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { m as signal, p as onCleanup, s as effect } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { Async, async } from "./async.mjs";
|
|
4
5
|
import { createInterval } from "./interval.mjs";
|
|
5
6
|
//#region src/utilities/async.test.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as Computed } from "../infer-DuFY-y2b.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/debounced.d.ts
|
|
4
4
|
/**
|
|
@@ -6,6 +6,17 @@ import { t as Computed } from "../index-DydGTqZU.mjs";
|
|
|
6
6
|
* milliseconds of silence (i.e. no new values from `getter`).
|
|
7
7
|
*
|
|
8
8
|
* The initial value is read synchronously, so the computed is never undefined.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { signal } from "elements-kit/signals";
|
|
13
|
+
* import { createDebounced } from "elements-kit/utilities/debounced";
|
|
14
|
+
*
|
|
15
|
+
* const query = signal("");
|
|
16
|
+
* const debounced = createDebounced(query, 300);
|
|
17
|
+
*
|
|
18
|
+
* effect(() => fetch(`/search?q=${debounced()}`));
|
|
19
|
+
* ```
|
|
9
20
|
*/
|
|
10
21
|
declare function createDebounced<T>(getter: () => T, delay: number | (() => number)): Computed<T>;
|
|
11
22
|
//#endregion
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as signal, s as effect } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
import { createTimeout } from "./timeout.mjs";
|
|
3
4
|
//#region src/utilities/debounced.ts
|
|
4
5
|
/**
|
|
@@ -6,6 +7,17 @@ import { createTimeout } from "./timeout.mjs";
|
|
|
6
7
|
* milliseconds of silence (i.e. no new values from `getter`).
|
|
7
8
|
*
|
|
8
9
|
* The initial value is read synchronously, so the computed is never undefined.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { signal } from "elements-kit/signals";
|
|
14
|
+
* import { createDebounced } from "elements-kit/utilities/debounced";
|
|
15
|
+
*
|
|
16
|
+
* const query = signal("");
|
|
17
|
+
* const debounced = createDebounced(query, 300);
|
|
18
|
+
*
|
|
19
|
+
* effect(() => fetch(`/search?q=${debounced()}`));
|
|
20
|
+
* ```
|
|
9
21
|
*/
|
|
10
22
|
function createDebounced(getter, delay) {
|
|
11
23
|
const s = signal(getter());
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope, m as signal } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { a as beforeEach, n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createDebounced } from "./debounced.mjs";
|
|
4
5
|
//#region src/utilities/debounced.test.ts
|
|
5
6
|
beforeEach(() => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createElementRect } from "./element-rect.mjs";
|
|
4
5
|
//#region src/utilities/element-rect.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createElementScroll } from "./element-scroll.mjs";
|
|
4
5
|
//#region src/utilities/element-scroll.test.ts
|
|
5
6
|
describe("createElementScroll", () => {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
//#region src/utilities/environment.d.ts
|
|
2
|
+
/** `true` when running in a browser (both `window` and `document` exist). */
|
|
2
3
|
declare const isBrowser: boolean;
|
|
4
|
+
/** A shared `Disposable` whose `Symbol.dispose` is a no-op — useful as a safe default. */
|
|
3
5
|
declare const noopDisposable: Disposable;
|
|
4
6
|
//#endregion
|
|
5
7
|
export { isBrowser, noopDisposable };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
//#region src/utilities/environment.ts
|
|
2
|
+
/** `true` when running in a browser (both `window` and `document` exist). */
|
|
2
3
|
const isBrowser = typeof window !== "undefined" && typeof document !== "undefined";
|
|
4
|
+
/** A shared `Disposable` whose `Symbol.dispose` is a no-op — useful as a safe default. */
|
|
3
5
|
const noopDisposable = { [Symbol.dispose]() {} };
|
|
4
6
|
//#endregion
|
|
5
7
|
export { isBrowser, noopDisposable };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as trigger, i as SIGNAL, m as signal, o as computed, p as onCleanup } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
//#region src/utilities/event-driven.ts
|
|
3
4
|
/**
|
|
4
5
|
* Returns a `Subscribe` for one or more DOM events on a target.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as Computed } from "../infer-DuFY-y2b.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/event-listener.d.ts
|
|
4
4
|
/**
|
|
@@ -7,6 +7,17 @@ import { t as Computed } from "../index-DydGTqZU.mjs";
|
|
|
7
7
|
* When called inside an `effect` or `effectScope` the listener is removed
|
|
8
8
|
* when the scope is disposed. When the target is a reactive getter the
|
|
9
9
|
* listener is re-registered whenever the target changes.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { on } from "elements-kit/utilities/event-listener";
|
|
14
|
+
*
|
|
15
|
+
* // Static target — listener removed when the enclosing scope ends
|
|
16
|
+
* on(window, "resize", () => console.log(window.innerWidth));
|
|
17
|
+
*
|
|
18
|
+
* // Reactive target — listener follows the current element
|
|
19
|
+
* on(activeElement, "focus", () => console.log("focused"));
|
|
20
|
+
* ```
|
|
10
21
|
*/
|
|
11
22
|
declare function on<K extends keyof HTMLElementEventMap>(target: HTMLElement | Computed<HTMLElement | null>, type: K, handler: (e: HTMLElementEventMap[K]) => void, options?: AddEventListenerOptions): () => void;
|
|
12
23
|
declare function on<K extends keyof DocumentEventMap>(target: Document | Computed<Document | null>, type: K, handler: (e: DocumentEventMap[K]) => void, options?: AddEventListenerOptions): () => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { p as onCleanup, s as effect } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
//#region src/utilities/event-listener.ts
|
|
3
4
|
function on(target, type, handler, options) {
|
|
4
5
|
const add = (t) => options !== void 0 ? t.addEventListener(type, handler, options) : t.addEventListener(type, handler);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as effectScope, m as signal, s as effect } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
import { on } from "./event-listener.mjs";
|
|
3
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
4
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
4
5
|
//#region src/utilities/event-listener.test.ts
|
|
5
6
|
afterEach(() => {
|
|
6
7
|
document.body.innerHTML = "";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createFocusWithin } from "./focus-within.mjs";
|
|
4
5
|
//#region src/utilities/focus-within.test.ts
|
|
5
6
|
afterEach(() => {
|
package/dist/utilities/hover.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createHover } from "./hover.mjs";
|
|
4
5
|
//#region src/utilities/hover.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createIntersectionObserver } from "./intersection-observer.mjs";
|
|
4
5
|
//#region src/utilities/intersection-observer.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as Computed } from "../infer-DuFY-y2b.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/interval.d.ts
|
|
4
4
|
type IntervalResult = {
|
|
@@ -12,6 +12,19 @@ type Fn = () => void;
|
|
|
12
12
|
type Delay = number | (() => number);
|
|
13
13
|
/**
|
|
14
14
|
* Pausable `setInterval` wrapper. Starts running immediately on creation.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { createInterval } from "elements-kit/utilities/interval";
|
|
19
|
+
*
|
|
20
|
+
* // Reactive clock — updates a signal every second
|
|
21
|
+
* const { timestamp, stop } = createInterval(1000);
|
|
22
|
+
* effect(() => console.log(new Date(timestamp())));
|
|
23
|
+
*
|
|
24
|
+
* // With a callback
|
|
25
|
+
* const beat = createInterval(() => beatCount(beatCount() + 1), 500);
|
|
26
|
+
* beat.stop();
|
|
27
|
+
* ```
|
|
15
28
|
*/
|
|
16
29
|
declare function createInterval(delay: Delay): IntervalResult;
|
|
17
30
|
declare function createInterval(callback: Fn, delay: Delay): IntervalResult;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as signal, p as onCleanup } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
//#region src/utilities/interval.ts
|
|
3
4
|
function createInterval(arg1, arg2) {
|
|
4
5
|
const [callback, delay] = resolveArgs(arg1, arg2);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { async } from "./async.mjs";
|
|
4
5
|
import { createInterval } from "./interval.mjs";
|
|
5
6
|
//#region src/utilities/interval.test.ts
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as trigger, m as signal, o as computed, p as onCleanup } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
import { fromEvent } from "./event-driven.mjs";
|
|
3
4
|
import { isBrowser } from "./environment.mjs";
|
|
4
5
|
//#region src/utilities/location.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
2
2
|
import { currentLocation } from "./location.mjs";
|
|
3
3
|
//#region src/utilities/location.test.ts
|
|
4
4
|
afterEach(() => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createLongPress } from "./long-press.mjs";
|
|
4
5
|
//#region src/utilities/long-press.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createMediaDevices } from "./media-devices.mjs";
|
|
4
5
|
//#region src/utilities/media-devices.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createMediaPlayer } from "./media-player.mjs";
|
|
4
5
|
//#region src/utilities/media-player.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as signal } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
import { fromEvent, sync } from "./event-driven.mjs";
|
|
3
4
|
import { isBrowser } from "./environment.mjs";
|
|
4
5
|
//#region src/utilities/media-query.ts
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createMutationObserver } from "./mutation-observer.mjs";
|
|
4
5
|
//#region src/utilities/mutation-observer.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as signal } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
import { on } from "./event-listener.mjs";
|
|
3
4
|
import { isBrowser } from "./environment.mjs";
|
|
4
5
|
//#region src/utilities/network.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
2
2
|
import { online } from "./network.mjs";
|
|
3
3
|
//#region src/utilities/network.test.ts
|
|
4
4
|
afterEach(() => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { onClickOutside } from "./on-click-outside.mjs";
|
|
4
5
|
//#region src/utilities/on-click-outside.test.ts
|
|
5
6
|
afterEach(() => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { o as computed } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
import { fromEvent, sync } from "./event-driven.mjs";
|
|
3
4
|
import { isBrowser } from "./environment.mjs";
|
|
4
5
|
//#region src/utilities/orientation.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as Computed } from "../infer-DuFY-y2b.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/previous.d.ts
|
|
4
4
|
/**
|
|
@@ -6,6 +6,18 @@ import { t as Computed } from "../index-DydGTqZU.mjs";
|
|
|
6
6
|
* Starts as `undefined` until the source changes for the first time.
|
|
7
7
|
*
|
|
8
8
|
* When `ignore` is provided, the previous value only updates when the ignore check fails.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { signal } from "elements-kit/signals";
|
|
13
|
+
* import { createPrevious } from "elements-kit/utilities/previous";
|
|
14
|
+
*
|
|
15
|
+
* const count = signal(0);
|
|
16
|
+
* const prev = createPrevious(count);
|
|
17
|
+
*
|
|
18
|
+
* count(1); prev(); // 0
|
|
19
|
+
* count(2); prev(); // 1
|
|
20
|
+
* ```
|
|
9
21
|
*/
|
|
10
22
|
declare function createPrevious<T>(source: Computed<T>, ignore?: (a: T, b: T) => boolean): Computed<T | undefined>;
|
|
11
23
|
//#endregion
|
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as signal, s as effect } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
//#region src/utilities/previous.ts
|
|
3
4
|
/**
|
|
4
5
|
* Returns a `Computed` that always holds the *previous* value of `source`.
|
|
5
6
|
* Starts as `undefined` until the source changes for the first time.
|
|
6
7
|
*
|
|
7
8
|
* When `ignore` is provided, the previous value only updates when the ignore check fails.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { signal } from "elements-kit/signals";
|
|
13
|
+
* import { createPrevious } from "elements-kit/utilities/previous";
|
|
14
|
+
*
|
|
15
|
+
* const count = signal(0);
|
|
16
|
+
* const prev = createPrevious(count);
|
|
17
|
+
*
|
|
18
|
+
* count(1); prev(); // 0
|
|
19
|
+
* count(2); prev(); // 1
|
|
20
|
+
* ```
|
|
8
21
|
*/
|
|
9
22
|
function createPrevious(source, ignore) {
|
|
10
23
|
const prev = signal(void 0);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { c as effectScope, m as signal } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { createPrevious } from "./previous.mjs";
|
|
4
5
|
//#region src/utilities/previous.test.ts
|
|
5
6
|
describe("createPrevious", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as Computed } from "../infer-DuFY-y2b.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/promise.d.ts
|
|
4
4
|
/**
|
|
@@ -28,6 +28,12 @@ declare class ReactivePromise<T, E = unknown> extends Promise<T> {
|
|
|
28
28
|
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void);
|
|
29
29
|
static from<T, E = unknown>(p: Promise<T>): ReactivePromise<T, E>;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* A {@link ReactivePromise} that is also callable as a `Computed<T | E | undefined>`.
|
|
33
|
+
*
|
|
34
|
+
* Invoking it (`p()`) reads the current `.result` — so it drops into any
|
|
35
|
+
* reactive context that expects a zero-arg getter.
|
|
36
|
+
*/
|
|
31
37
|
type ComputedPromise<T, E = unknown> = ReactivePromise<T, E> & Computed<T | E | undefined>;
|
|
32
38
|
type Executor<T, E = unknown> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: E) => void) => void;
|
|
33
39
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as batch, m as signal, o as computed } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
2
3
|
//#region src/utilities/promise.ts
|
|
3
4
|
/**
|
|
4
5
|
* A `Promise` subclass that exposes its state as reactive signals.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { s as effect } from "../lib-D6duEs38.mjs";
|
|
2
|
+
import "../signals/index.mjs";
|
|
3
|
+
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-BeO5pvCo.mjs";
|
|
3
4
|
import { ReactivePromise, promise } from "./promise.mjs";
|
|
4
5
|
//#region src/utilities/promise.test.ts
|
|
5
6
|
describe("ReactivePromise", () => {
|