elements-kit 0.0.15 → 0.0.17
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 +138 -31
- package/dist/attributes-Dtn68R1u.d.mts +94 -0
- package/dist/attributes.d.mts +1 -93
- package/dist/custom-elements.d.mts +74 -0
- package/dist/custom-elements.mjs +100 -0
- package/dist/define-CjbTZ3VG.d.mts +23 -0
- package/dist/{element-ChF24-2z.mjs → element-CGVy_8TW.mjs} +11 -12
- package/dist/for.d.mts +45 -0
- package/dist/for.mjs +136 -0
- package/dist/{index-DUshSQ_6.d.mts → index-DydGTqZU.d.mts} +60 -10
- package/dist/index.d.mts +1 -36
- package/dist/index.mjs +1 -144
- package/dist/infer-BfzRJoCn.d.mts +203 -0
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +1 -1
- package/dist/jsx-runtime/index.d.mts +11 -20
- package/dist/jsx-runtime/index.mjs +2 -2
- package/dist/signals/index.d.mts +2 -2
- package/dist/signals/index.mjs +2 -2
- package/dist/{signals-BHmWX6ox.mjs → signals-J8dK_rA4.mjs} +57 -17
- package/dist/slot-C7GQZe-r.d.mts +104 -0
- package/dist/{slot-Cydy7-0L.mjs → slot-Kb61AcgW.mjs} +21 -2
- package/dist/slot.d.mts +2 -84
- package/dist/slot.mjs +2 -2
- package/dist/{test.BmQO5GaM-ANkhHvbr.mjs → test.BmQO5GaM-DfGStnii.mjs} +1 -1
- package/dist/utilities/_observe.d.mts +11 -0
- package/dist/utilities/_observe.mjs +15 -0
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/active-element.mjs +6 -2
- package/dist/utilities/active-element.test.mjs +1 -1
- package/dist/utilities/async.d.mts +1 -1
- package/dist/utilities/async.mjs +1 -1
- package/dist/utilities/async.test.mjs +2 -2
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/debounced.mjs +1 -1
- package/dist/utilities/debounced.test.mjs +2 -2
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.mjs +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.mjs +7 -34
- package/dist/utilities/element-scroll.test.mjs +2 -2
- package/dist/utilities/environment.d.mts +5 -0
- package/dist/utilities/environment.mjs +5 -0
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-driven.mjs +2 -2
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/event-listener.mjs +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.mjs +1 -1
- package/dist/utilities/focus-within.test.mjs +2 -2
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.mjs +1 -1
- package/dist/utilities/hover.test.mjs +2 -2
- package/dist/utilities/intersection-observer.mjs +4 -6
- package/dist/utilities/intersection-observer.test.mjs +2 -2
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/interval.mjs +1 -1
- package/dist/utilities/interval.test.mjs +2 -2
- package/dist/utilities/location.d.mts +2 -14
- package/dist/utilities/location.mjs +12 -3
- package/dist/utilities/location.test.mjs +5 -5
- package/dist/utilities/long-press.mjs +1 -1
- package/dist/utilities/long-press.test.mjs +2 -2
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.mjs +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 +2 -3
- package/dist/utilities/media-query.mjs +3 -3
- package/dist/utilities/mutation-observer.mjs +4 -7
- package/dist/utilities/mutation-observer.test.mjs +2 -2
- package/dist/utilities/network.d.mts +2 -2
- package/dist/utilities/network.mjs +5 -3
- package/dist/utilities/network.test.mjs +1 -1
- package/dist/utilities/on-click-outside.test.mjs +2 -2
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/orientation.mjs +9 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/previous.mjs +1 -1
- package/dist/utilities/previous.test.mjs +2 -2
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/promise.mjs +1 -1
- package/dist/utilities/promise.test.mjs +2 -2
- package/dist/utilities/resize-observer.mjs +4 -6
- package/dist/utilities/retry.mjs +1 -1
- package/dist/utilities/retry.test.mjs +2 -2
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/routing.mjs +1 -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 +2 -2
- package/dist/utilities/ssr.test.d.mts +1 -0
- package/dist/utilities/ssr.test.mjs +64 -0
- 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.mjs +1 -1
- package/dist/utilities/throttled.test.mjs +2 -2
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.mjs +1 -1
- package/dist/utilities/timeout.test.mjs +2 -2
- package/dist/utilities/window-focus.d.mts +2 -2
- package/dist/utilities/window-focus.mjs +5 -3
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.mjs +10 -5
- package/dist/utilities/window-size.test.mjs +1 -1
- package/package.json +20 -10
- package/dist/lib-JA05lzCN.d.mts +0 -4
- /package/dist/{polyfill-DR5XVnh_.d.mts → polyfill-BVNd6ogU.d.mts} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { on } from "./event-listener.mjs";
|
|
1
|
+
import { fromEvent, sync } from "./event-driven.mjs";
|
|
3
2
|
//#region src/utilities/element-scroll.ts
|
|
4
3
|
/**
|
|
5
4
|
* Returns writable signals for an element's scroll position.
|
|
@@ -9,43 +8,17 @@ import { on } from "./event-listener.mjs";
|
|
|
9
8
|
*/
|
|
10
9
|
function createElementScroll(target) {
|
|
11
10
|
const el = target;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const handler = () => {
|
|
16
|
-
if (skipEvent) {
|
|
17
|
-
skipEvent = false;
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (!el) return;
|
|
21
|
-
x(el.scrollLeft);
|
|
22
|
-
y(el.scrollTop);
|
|
23
|
-
};
|
|
24
|
-
const cleanup = el ? on(el, "scroll", handler, { passive: true }) : () => {};
|
|
25
|
-
const stopX = effect(() => {
|
|
26
|
-
const val = x();
|
|
27
|
-
if (el && el.scrollLeft !== val) {
|
|
28
|
-
skipEvent = true;
|
|
29
|
-
el.scrollLeft = val;
|
|
30
|
-
}
|
|
11
|
+
const scroll = fromEvent(el, "scroll");
|
|
12
|
+
const [x] = sync(scroll, () => el.scrollLeft, (v) => {
|
|
13
|
+
el.scrollLeft = v;
|
|
31
14
|
});
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
if (el && el.scrollTop !== val) {
|
|
35
|
-
skipEvent = true;
|
|
36
|
-
el.scrollTop = val;
|
|
37
|
-
}
|
|
15
|
+
const [y] = sync(scroll, () => el.scrollTop, (v) => {
|
|
16
|
+
el.scrollTop = v;
|
|
38
17
|
});
|
|
39
|
-
const dispose = () => {
|
|
40
|
-
cleanup();
|
|
41
|
-
stopX();
|
|
42
|
-
stopY();
|
|
43
|
-
};
|
|
44
|
-
onCleanup(dispose);
|
|
45
18
|
return {
|
|
46
19
|
x,
|
|
47
20
|
y,
|
|
48
|
-
[Symbol.dispose]:
|
|
21
|
+
[Symbol.dispose]: () => {}
|
|
49
22
|
};
|
|
50
23
|
}
|
|
51
24
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createElementScroll } from "./element-scroll.mjs";
|
|
4
4
|
//#region src/utilities/element-scroll.test.ts
|
|
5
5
|
describe("createElementScroll", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as onCleanup, c as SIGNAL, u as computed, v as signal, y as trigger } from "../signals-J8dK_rA4.mjs";
|
|
2
2
|
//#region src/utilities/event-driven.ts
|
|
3
3
|
/**
|
|
4
4
|
* Returns a `Subscribe` for one or more DOM events on a target.
|
|
@@ -31,7 +31,7 @@ function sync(subscribe, getter, setter) {
|
|
|
31
31
|
setter(v);
|
|
32
32
|
return v;
|
|
33
33
|
}
|
|
34
|
-
Object.defineProperty(proxy,
|
|
34
|
+
Object.defineProperty(proxy, SIGNAL, { value: true });
|
|
35
35
|
return proxy;
|
|
36
36
|
};
|
|
37
37
|
return [factory(), cleanup];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as onCleanup, d as effect } from "../signals-J8dK_rA4.mjs";
|
|
2
2
|
//#region src/utilities/event-listener.ts
|
|
3
3
|
function on(target, type, handler, options) {
|
|
4
4
|
const add = (t) => options !== void 0 ? t.addEventListener(type, handler, options) : t.addEventListener(type, handler);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-ANkhHvbr.mjs";
|
|
1
|
+
import { d as effect, f as effectScope, v as signal } from "../signals-J8dK_rA4.mjs";
|
|
3
2
|
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-DfGStnii.mjs";
|
|
4
4
|
//#region src/utilities/event-listener.test.ts
|
|
5
5
|
afterEach(() => {
|
|
6
6
|
document.body.innerHTML = "";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createFocusWithin } from "./focus-within.mjs";
|
|
4
4
|
//#region src/utilities/focus-within.test.ts
|
|
5
5
|
afterEach(() => {
|
package/dist/utilities/hover.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createHover } from "./hover.mjs";
|
|
4
4
|
//#region src/utilities/hover.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { observe } from "./_observe.mjs";
|
|
2
2
|
//#region src/utilities/intersection-observer.ts
|
|
3
3
|
/**
|
|
4
4
|
* Raw `IntersectionObserver` wrapper with automatic cleanup.
|
|
5
5
|
* Use `createIsInViewport` for the common boolean case.
|
|
6
6
|
*/
|
|
7
7
|
function createIntersectionObserver(target, callback, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onCleanup(cleanup);
|
|
12
|
-
return { [Symbol.dispose]: cleanup };
|
|
8
|
+
return observe(new IntersectionObserver(callback, options), (o) => {
|
|
9
|
+
if (target) o.observe(target);
|
|
10
|
+
});
|
|
13
11
|
}
|
|
14
12
|
//#endregion
|
|
15
13
|
export { createIntersectionObserver };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createIntersectionObserver } from "./intersection-observer.mjs";
|
|
4
4
|
//#region src/utilities/intersection-observer.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as onCleanup, v as signal } from "../signals-J8dK_rA4.mjs";
|
|
2
2
|
//#region src/utilities/interval.ts
|
|
3
3
|
function createInterval(arg1, arg2) {
|
|
4
4
|
const [callback, delay] = resolveArgs(arg1, arg2);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { async } from "./async.mjs";
|
|
4
4
|
import { createInterval } from "./interval.mjs";
|
|
5
5
|
//#region src/utilities/interval.test.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Computed } from "../index-
|
|
1
|
+
import { t as Computed } from "../index-DydGTqZU.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/location.d.ts
|
|
4
4
|
type LocationResult = {
|
|
@@ -7,18 +7,6 @@ type LocationResult = {
|
|
|
7
7
|
pathname: Computed<string>;
|
|
8
8
|
search: Computed<string>;
|
|
9
9
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Returns reactive signals for the four commonly used `location` properties:
|
|
12
|
-
* `hash`, `href`, `pathname`, and `search`.
|
|
13
|
-
*
|
|
14
|
-
* All four share a single event listener set, so creating one `LocationResult`
|
|
15
|
-
* is cheaper than creating four separate signals.
|
|
16
|
-
*
|
|
17
|
-
* **Custom events note:** `pushstate` and `replacestate` are not native DOM
|
|
18
|
-
* events — they must be dispatched by your router or by patching `history`.
|
|
19
|
-
* Back/forward navigation via `popstate` always works without any setup.
|
|
20
|
-
*/
|
|
21
|
-
declare function createLocation(): LocationResult;
|
|
22
10
|
declare const currentLocation: LocationResult;
|
|
23
11
|
//#endregion
|
|
24
|
-
export {
|
|
12
|
+
export { currentLocation };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { _ as
|
|
1
|
+
import { _ as onCleanup, u as computed, v as signal, y as trigger } from "../signals-J8dK_rA4.mjs";
|
|
2
2
|
import { fromEvent } from "./event-driven.mjs";
|
|
3
|
+
import { isBrowser } from "./environment.mjs";
|
|
3
4
|
//#region src/utilities/location.ts
|
|
4
5
|
const EVENTS = [
|
|
5
6
|
"popstate",
|
|
@@ -7,7 +8,7 @@ const EVENTS = [
|
|
|
7
8
|
"replacestate",
|
|
8
9
|
"hashchange"
|
|
9
10
|
];
|
|
10
|
-
const read = (prop) =>
|
|
11
|
+
const read = (prop) => isBrowser ? String(location[prop]) : "";
|
|
11
12
|
/**
|
|
12
13
|
* Returns reactive signals for the four commonly used `location` properties:
|
|
13
14
|
* `hash`, `href`, `pathname`, and `search`.
|
|
@@ -18,8 +19,16 @@ const read = (prop) => typeof location !== "undefined" ? String(location[prop])
|
|
|
18
19
|
* **Custom events note:** `pushstate` and `replacestate` are not native DOM
|
|
19
20
|
* events — they must be dispatched by your router or by patching `history`.
|
|
20
21
|
* Back/forward navigation via `popstate` always works without any setup.
|
|
22
|
+
*
|
|
23
|
+
* Outside a browser, every signal reads the empty string.
|
|
21
24
|
*/
|
|
22
25
|
function createLocation() {
|
|
26
|
+
if (!isBrowser) return {
|
|
27
|
+
hash: computed(() => ""),
|
|
28
|
+
href: computed(() => ""),
|
|
29
|
+
pathname: computed(() => ""),
|
|
30
|
+
search: computed(() => "")
|
|
31
|
+
};
|
|
23
32
|
const tick = signal(void 0);
|
|
24
33
|
onCleanup(fromEvent(window, EVENTS)(() => trigger(tick)));
|
|
25
34
|
const hash = computed(() => {
|
|
@@ -51,4 +60,4 @@ function createLocation() {
|
|
|
51
60
|
}
|
|
52
61
|
const currentLocation = createLocation();
|
|
53
62
|
//#endregion
|
|
54
|
-
export {
|
|
63
|
+
export { currentLocation };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
2
|
-
import {
|
|
1
|
+
import { o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
2
|
+
import { currentLocation } from "./location.mjs";
|
|
3
3
|
//#region src/utilities/location.test.ts
|
|
4
4
|
afterEach(() => {
|
|
5
5
|
location.hash = "";
|
|
@@ -39,16 +39,16 @@ describe("currentLocation (singleton)", () => {
|
|
|
39
39
|
globalExpect(currentLocation.href()).toMatch(/#baz$/);
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
|
-
describe("
|
|
42
|
+
describe("currentLocation (singleton)", () => {
|
|
43
43
|
it("returns independent location signals", () => {
|
|
44
|
-
const loc =
|
|
44
|
+
const loc = currentLocation;
|
|
45
45
|
globalExpect(typeof loc.hash()).toBe("string");
|
|
46
46
|
globalExpect(typeof loc.href()).toBe("string");
|
|
47
47
|
globalExpect(typeof loc.pathname()).toBe("string");
|
|
48
48
|
globalExpect(typeof loc.search()).toBe("string");
|
|
49
49
|
});
|
|
50
50
|
it("all four properties update from a single event", () => {
|
|
51
|
-
const loc =
|
|
51
|
+
const loc = currentLocation;
|
|
52
52
|
history.replaceState(null, "", "/factory-test?q=1#section");
|
|
53
53
|
window.dispatchEvent(new PopStateEvent("popstate"));
|
|
54
54
|
globalExpect(loc.pathname()).toBe("/factory-test");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createLongPress } from "./long-press.mjs";
|
|
4
4
|
//#region src/utilities/long-press.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createMediaDevices } from "./media-devices.mjs";
|
|
4
4
|
//#region src/utilities/media-devices.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createMediaPlayer } from "./media-player.mjs";
|
|
4
4
|
//#region src/utilities/media-player.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as Computed } from "../index-
|
|
1
|
+
import { t as Computed } from "../index-DydGTqZU.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/media-query.d.ts
|
|
4
|
-
declare const isBrowser: boolean;
|
|
5
4
|
/**
|
|
6
5
|
* Creates a signal that tracks a CSS media query.
|
|
7
6
|
*
|
|
@@ -11,4 +10,4 @@ declare const isBrowser: boolean;
|
|
|
11
10
|
*/
|
|
12
11
|
declare function createMediaQuery(query: string, defaultState?: boolean): Computed<boolean>;
|
|
13
12
|
//#endregion
|
|
14
|
-
export { createMediaQuery
|
|
13
|
+
export { createMediaQuery };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as signal } from "../signals-J8dK_rA4.mjs";
|
|
2
2
|
import { fromEvent, sync } from "./event-driven.mjs";
|
|
3
|
+
import { isBrowser } from "./environment.mjs";
|
|
3
4
|
//#region src/utilities/media-query.ts
|
|
4
|
-
const isBrowser = typeof window !== "undefined";
|
|
5
5
|
/**
|
|
6
6
|
* Creates a signal that tracks a CSS media query.
|
|
7
7
|
*
|
|
@@ -16,4 +16,4 @@ function createMediaQuery(query, defaultState) {
|
|
|
16
16
|
return state;
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
|
-
export { createMediaQuery
|
|
19
|
+
export { createMediaQuery };
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { observe } from "./_observe.mjs";
|
|
2
2
|
//#region src/utilities/mutation-observer.ts
|
|
3
3
|
/**
|
|
4
4
|
* Watches `target` for DOM mutations and calls `callback` with each batch of
|
|
5
5
|
* `MutationRecord`s.
|
|
6
6
|
*/
|
|
7
7
|
function createMutationObserver(target, options, callback) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const cleanup = () => observer.disconnect();
|
|
12
|
-
onCleanup(cleanup);
|
|
13
|
-
return { [Symbol.dispose]: cleanup };
|
|
8
|
+
return observe(new MutationObserver((records) => callback(records)), (o) => {
|
|
9
|
+
if (target) o.observe(target, options);
|
|
10
|
+
});
|
|
14
11
|
}
|
|
15
12
|
//#endregion
|
|
16
13
|
export { createMutationObserver };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createMutationObserver } from "./mutation-observer.mjs";
|
|
4
4
|
//#region src/utilities/mutation-observer.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as Computed } from "../index-
|
|
1
|
+
import { t as Computed } from "../index-DydGTqZU.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/network.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Singleton `Computed<boolean>` — `true` when `navigator.onLine` is true.
|
|
6
|
-
* Reacts to `online` / `offline` window events.
|
|
6
|
+
* Reacts to `online` / `offline` window events. Outside a browser, always `true`.
|
|
7
7
|
*/
|
|
8
8
|
declare const online: Computed<boolean>;
|
|
9
9
|
//#endregion
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as signal } from "../signals-J8dK_rA4.mjs";
|
|
2
2
|
import { on } from "./event-listener.mjs";
|
|
3
|
+
import { isBrowser } from "./environment.mjs";
|
|
3
4
|
//#region src/utilities/network.ts
|
|
4
5
|
function createOnline() {
|
|
5
|
-
|
|
6
|
+
if (!isBrowser) return signal(true);
|
|
7
|
+
const value = signal(navigator.onLine);
|
|
6
8
|
const update = () => value(navigator.onLine);
|
|
7
9
|
on(window, "online", update);
|
|
8
10
|
on(window, "offline", update);
|
|
@@ -10,7 +12,7 @@ function createOnline() {
|
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* Singleton `Computed<boolean>` — `true` when `navigator.onLine` is true.
|
|
13
|
-
* Reacts to `online` / `offline` window events.
|
|
15
|
+
* Reacts to `online` / `offline` window events. Outside a browser, always `true`.
|
|
14
16
|
*/
|
|
15
17
|
const online = createOnline();
|
|
16
18
|
//#endregion
|
|
@@ -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-DfGStnii.mjs";
|
|
2
2
|
import { online } from "./network.mjs";
|
|
3
3
|
//#region src/utilities/network.test.ts
|
|
4
4
|
afterEach(() => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, r as afterEach, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { onClickOutside } from "./on-click-outside.mjs";
|
|
4
4
|
//#region src/utilities/on-click-outside.test.ts
|
|
5
5
|
afterEach(() => {
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
import { u as computed } from "../signals-J8dK_rA4.mjs";
|
|
1
2
|
import { fromEvent, sync } from "./event-driven.mjs";
|
|
3
|
+
import { isBrowser } from "./environment.mjs";
|
|
2
4
|
//#region src/utilities/orientation.ts
|
|
3
5
|
/**
|
|
4
|
-
* Returns reactive signals for the screen orientation.
|
|
6
|
+
* Returns reactive signals for the screen orientation. Outside a browser,
|
|
7
|
+
* returns `{ angle: 0, type: "portrait-primary" }` and a no-op disposer.
|
|
5
8
|
*/
|
|
6
9
|
function createOrientation() {
|
|
10
|
+
if (!isBrowser) return {
|
|
11
|
+
angle: computed(() => 0),
|
|
12
|
+
type: computed(() => "portrait-primary"),
|
|
13
|
+
[Symbol.dispose]() {}
|
|
14
|
+
};
|
|
7
15
|
const subscribe = fromEvent(screen.orientation, "change");
|
|
8
16
|
const [angle, stopAngle] = sync(subscribe, () => screen.orientation?.angle ?? 0);
|
|
9
17
|
const [type, stopType] = sync(subscribe, () => screen.orientation?.type ?? "portrait-primary");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { f as effectScope, v as signal } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { createPrevious } from "./previous.mjs";
|
|
4
4
|
//#region src/utilities/previous.test.ts
|
|
5
5
|
describe("createPrevious", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { l as batch, u as computed, v as signal } from "../signals-J8dK_rA4.mjs";
|
|
2
2
|
//#region src/utilities/promise.ts
|
|
3
3
|
/**
|
|
4
4
|
* A `Promise` subclass that exposes its state as reactive signals.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { d as effect } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { ReactivePromise, promise } from "./promise.mjs";
|
|
4
4
|
//#region src/utilities/promise.test.ts
|
|
5
5
|
describe("ReactivePromise", () => {
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { observe } from "./_observe.mjs";
|
|
2
2
|
//#region src/utilities/resize-observer.ts
|
|
3
3
|
/**
|
|
4
4
|
* Raw `ResizeObserver` wrapper with automatic cleanup.
|
|
5
5
|
* Use `createElementRect` for the common case.
|
|
6
6
|
*/
|
|
7
7
|
function createResizeObserver(target, callback) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
onCleanup(cleanup);
|
|
12
|
-
return { [Symbol.dispose]: cleanup };
|
|
8
|
+
return observe(new ResizeObserver(callback), (o) => {
|
|
9
|
+
if (target) o.observe(target);
|
|
10
|
+
});
|
|
13
11
|
}
|
|
14
12
|
//#endregion
|
|
15
13
|
export { createResizeObserver };
|
package/dist/utilities/retry.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as vi, o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-
|
|
1
|
+
import { _ as onCleanup } from "../signals-J8dK_rA4.mjs";
|
|
2
|
+
import { n as vi, o as describe, s as it, t as globalExpect } from "../test.BmQO5GaM-DfGStnii.mjs";
|
|
3
3
|
import { retry } from "./retry.mjs";
|
|
4
4
|
//#region src/utilities/retry.test.ts
|
|
5
5
|
describe("retry", () => {
|