sibujs 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -119
- package/dist/browser.cjs +288 -80
- package/dist/browser.d.cts +19 -9
- package/dist/browser.d.ts +19 -9
- package/dist/browser.js +6 -6
- package/dist/build.cjs +1019 -313
- package/dist/build.d.cts +1 -1
- package/dist/build.d.ts +1 -1
- package/dist/build.js +15 -13
- package/dist/cdn.global.js +17 -16
- package/dist/chunk-2RA7SHDA.js +65 -0
- package/dist/chunk-2UPRY23K.js +80 -0
- package/dist/chunk-3JHCYHWN.js +125 -0
- package/dist/{chunk-ZWKZCBO6.js → chunk-3LR7GLWQ.js} +154 -33
- package/dist/{chunk-3AIRKM3B.js → chunk-3NSGB5JN.js} +115 -34
- package/dist/{chunk-3ARAQO7B.js → chunk-52YJLLRO.js} +29 -6
- package/dist/chunk-54EDRCEF.js +93 -0
- package/dist/chunk-7JDB7I65.js +1327 -0
- package/dist/{chunk-WZSPOOER.js → chunk-CC65Y57T.js} +8 -5
- package/dist/{chunk-23VV7YD3.js → chunk-DFPFITST.js} +25 -30
- package/dist/{chunk-WR5D4EGH.js → chunk-GTBNNBJ6.js} +14 -2
- package/dist/chunk-HB24TBAF.js +121 -0
- package/dist/{chunk-CZUGLNJS.js → chunk-ITX6OO3F.js} +3 -3
- package/dist/{chunk-JAKHTMQU.js → chunk-JA6667UN.js} +206 -46
- package/dist/{chunk-77L6NL3X.js → chunk-JXMMDLBY.js} +306 -183
- package/dist/{chunk-3X2YG6YM.js → chunk-JYD2PWXH.js} +59 -28
- package/dist/{chunk-F3FA4F32.js → chunk-KLRMB5ZS.js} +135 -79
- package/dist/{chunk-5X6PP2UK.js → chunk-LMLD24FC.js} +2 -2
- package/dist/{chunk-M4NLBH4I.js → chunk-LYTCUZ7H.js} +3 -2
- package/dist/{chunk-TSOKIX5Z.js → chunk-MIUAXB7K.js} +126 -74
- package/dist/{chunk-QWZG56ET.js → chunk-ND2664SF.js} +558 -190
- package/dist/{chunk-JCI5M6U6.js → chunk-O2MNQFLP.js} +261 -79
- package/dist/{chunk-EWFVA3TJ.js → chunk-R73P76YZ.js} +1 -1
- package/dist/{chunk-2BYQDGN3.js → chunk-SAHNHTFC.js} +234 -63
- package/dist/chunk-UCS6AMJ7.js +79 -0
- package/dist/{chunk-ZD6OAMTH.js → chunk-VLPPXTYG.js} +90 -35
- package/dist/{chunk-OUZZEE4S.js → chunk-WOMYAHHI.js} +17 -11
- package/dist/{contracts-xo5ckdRP.d.cts → contracts-ey_Qh8ef.d.cts} +7 -8
- package/dist/{contracts-xo5ckdRP.d.ts → contracts-ey_Qh8ef.d.ts} +7 -8
- package/dist/{customElement-D2DJp_xn.d.cts → customElement-CPfIrbvg.d.cts} +18 -9
- package/dist/{customElement-D2DJp_xn.d.ts → customElement-CPfIrbvg.d.ts} +18 -9
- package/dist/data.cjs +452 -100
- package/dist/data.d.cts +20 -2
- package/dist/data.d.ts +20 -2
- package/dist/data.js +11 -9
- package/dist/devtools.cjs +535 -247
- package/dist/devtools.d.cts +1 -1
- package/dist/devtools.d.ts +1 -1
- package/dist/devtools.js +34 -30
- package/dist/ecosystem.cjs +499 -143
- package/dist/ecosystem.d.cts +13 -11
- package/dist/ecosystem.d.ts +13 -11
- package/dist/ecosystem.js +12 -11
- package/dist/extras.cjs +3639 -1629
- package/dist/extras.d.cts +11 -11
- package/dist/extras.d.ts +11 -11
- package/dist/extras.js +58 -45
- package/dist/index.cjs +1023 -313
- package/dist/index.d.cts +128 -55
- package/dist/index.d.ts +128 -55
- package/dist/index.js +28 -16
- package/dist/{introspect-BumjnBKr.d.cts → introspect-BWNjNw64.d.cts} +22 -2
- package/dist/{introspect-CZrlcaYy.d.ts → introspect-cY2pg9pW.d.ts} +22 -2
- package/dist/motion.cjs +90 -36
- package/dist/motion.d.cts +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +4 -4
- package/dist/patterns.cjs +414 -81
- package/dist/patterns.d.cts +53 -20
- package/dist/patterns.d.ts +53 -20
- package/dist/patterns.js +7 -7
- package/dist/performance.cjs +364 -108
- package/dist/performance.d.cts +29 -17
- package/dist/performance.d.ts +29 -17
- package/dist/performance.js +13 -6
- package/dist/plugin-D30wlGW5.d.cts +71 -0
- package/dist/plugin-D30wlGW5.d.ts +71 -0
- package/dist/plugins.cjs +652 -271
- package/dist/plugins.d.cts +13 -6
- package/dist/plugins.d.ts +13 -6
- package/dist/plugins.js +116 -50
- package/dist/{ssr-Do_SiVoL.d.cts → ssr-CrVNy6Pa.d.cts} +9 -15
- package/dist/{ssr-Do_SiVoL.d.ts → ssr-CrVNy6Pa.d.ts} +9 -15
- package/dist/{ssr-4PBXAOO3.js → ssr-FXD2PPMC.js} +4 -3
- package/dist/ssr.cjs +648 -219
- package/dist/ssr.d.cts +27 -7
- package/dist/ssr.d.ts +27 -7
- package/dist/ssr.js +12 -11
- package/dist/{tagFactory-DaJ0YWX6.d.ts → tagFactory-S17H2qxu.d.cts} +9 -1
- package/dist/{tagFactory-DaJ0YWX6.d.cts → tagFactory-S17H2qxu.d.ts} +9 -1
- package/dist/testing.cjs +252 -63
- package/dist/testing.d.cts +17 -4
- package/dist/testing.d.ts +17 -4
- package/dist/testing.js +100 -44
- package/dist/ui.cjs +576 -168
- package/dist/ui.d.cts +13 -16
- package/dist/ui.d.ts +13 -16
- package/dist/ui.js +20 -17
- package/dist/widgets.cjs +1001 -93
- package/dist/widgets.d.cts +104 -2
- package/dist/widgets.d.ts +104 -2
- package/dist/widgets.js +9 -7
- package/package.json +8 -2
- package/dist/chunk-32DY64NT.js +0 -282
- package/dist/chunk-3CRQALYP.js +0 -877
- package/dist/chunk-4EI4AG32.js +0 -482
- package/dist/chunk-4MYMUBRS.js +0 -21
- package/dist/chunk-6HLLIF3K.js +0 -398
- package/dist/chunk-6LSNVCS2.js +0 -937
- package/dist/chunk-6SA3QQES.js +0 -61
- package/dist/chunk-7BF6TK55.js +0 -1097
- package/dist/chunk-7TQKR4PP.js +0 -294
- package/dist/chunk-7V26P53V.js +0 -712
- package/dist/chunk-AZ3ISID5.js +0 -298
- package/dist/chunk-B7SWRFUT.js +0 -332
- package/dist/chunk-BGN5ZMP4.js +0 -26
- package/dist/chunk-BTU3TJDS.js +0 -365
- package/dist/chunk-BW3WT46K.js +0 -937
- package/dist/chunk-C6KFWOFV.js +0 -616
- package/dist/chunk-CHF5OHIA.js +0 -61
- package/dist/chunk-CHJ27IGK.js +0 -26
- package/dist/chunk-CMBFNA7L.js +0 -27
- package/dist/chunk-DAHRH4ON.js +0 -331
- package/dist/chunk-DKOHBI74.js +0 -924
- package/dist/chunk-DTCOOBMX.js +0 -725
- package/dist/chunk-EBGIRKQY.js +0 -616
- package/dist/chunk-EUZND3CB.js +0 -27
- package/dist/chunk-EVCZO745.js +0 -365
- package/dist/chunk-FGOEVHY3.js +0 -60
- package/dist/chunk-G3BOQPVO.js +0 -365
- package/dist/chunk-GCOK2LC3.js +0 -282
- package/dist/chunk-HGMJFBC7.js +0 -654
- package/dist/chunk-K5ZUMYVS.js +0 -89
- package/dist/chunk-KQPDEVVS.js +0 -398
- package/dist/chunk-L6JRBDNS.js +0 -60
- package/dist/chunk-LA6KQEDU.js +0 -712
- package/dist/chunk-MDVXJWFN.js +0 -304
- package/dist/chunk-MEZVEBPN.js +0 -2008
- package/dist/chunk-MK4ERFYL.js +0 -2249
- package/dist/chunk-MLKGABMK.js +0 -9
- package/dist/chunk-MQ5GOYPH.js +0 -2249
- package/dist/chunk-N6IZB6KJ.js +0 -567
- package/dist/chunk-NEKUBFPT.js +0 -60
- package/dist/chunk-NHUC2QWH.js +0 -282
- package/dist/chunk-NMRUZALC.js +0 -1097
- package/dist/chunk-NYVAC6P5.js +0 -37
- package/dist/chunk-OF7UZIVB.js +0 -725
- package/dist/chunk-P6W3STU4.js +0 -2249
- package/dist/chunk-PBHF5WKN.js +0 -616
- package/dist/chunk-PTQJDMRT.js +0 -146
- package/dist/chunk-PZEGYCF5.js +0 -61
- package/dist/chunk-QBMDLBU2.js +0 -975
- package/dist/chunk-RQGQSLQK.js +0 -725
- package/dist/chunk-SDLZDHKP.js +0 -107
- package/dist/chunk-TNQWPPE6.js +0 -37
- package/dist/chunk-UHNL42EF.js +0 -2730
- package/dist/chunk-UNXCEF6S.js +0 -21
- package/dist/chunk-V2XTI523.js +0 -347
- package/dist/chunk-VAU366PN.js +0 -2241
- package/dist/chunk-VMVDTCXB.js +0 -712
- package/dist/chunk-VRW3FULF.js +0 -725
- package/dist/chunk-WADYRCO2.js +0 -304
- package/dist/chunk-WILQZRO4.js +0 -282
- package/dist/chunk-WUHJISPP.js +0 -298
- package/dist/chunk-XYU6TZOW.js +0 -182
- package/dist/chunk-Y6GP4QGG.js +0 -276
- package/dist/chunk-YECR7UIA.js +0 -347
- package/dist/chunk-YUTWTI4B.js +0 -654
- package/dist/chunk-Z65KYU7I.js +0 -26
- package/dist/chunk-Z6POF5YC.js +0 -975
- package/dist/chunk-ZBJP6WFL.js +0 -482
- package/dist/contracts-DDrwxvJ-.d.cts +0 -245
- package/dist/contracts-DDrwxvJ-.d.ts +0 -245
- package/dist/contracts-DOrhwbke.d.cts +0 -245
- package/dist/contracts-DOrhwbke.d.ts +0 -245
- package/dist/customElement-BKQfbSZQ.d.cts +0 -262
- package/dist/customElement-BKQfbSZQ.d.ts +0 -262
- package/dist/customElement-yz8uyk-0.d.cts +0 -308
- package/dist/customElement-yz8uyk-0.d.ts +0 -308
- package/dist/introspect-Cb0zgpi2.d.cts +0 -477
- package/dist/introspect-Y2xNXGSf.d.ts +0 -477
- package/dist/plugin-Bek4RhJY.d.cts +0 -43
- package/dist/plugin-Bek4RhJY.d.ts +0 -43
- package/dist/ssr-3RXHP5ES.js +0 -38
- package/dist/ssr-6GIMY5MX.js +0 -38
- package/dist/ssr-BA6sxxUd.d.cts +0 -135
- package/dist/ssr-BA6sxxUd.d.ts +0 -135
- package/dist/ssr-WKUPVSSK.js +0 -36
- package/dist/tagFactory-Dl8QCLga.d.cts +0 -23
- package/dist/tagFactory-Dl8QCLga.d.ts +0 -23
package/dist/chunk-4EI4AG32.js
DELETED
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
effect
|
|
3
|
-
} from "./chunk-PZEGYCF5.js";
|
|
4
|
-
import {
|
|
5
|
-
batch,
|
|
6
|
-
signal
|
|
7
|
-
} from "./chunk-YECR7UIA.js";
|
|
8
|
-
|
|
9
|
-
// src/browser/media.ts
|
|
10
|
-
function media(query) {
|
|
11
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
12
|
-
const [matches2] = signal(false);
|
|
13
|
-
return { matches: matches2, dispose: () => {
|
|
14
|
-
} };
|
|
15
|
-
}
|
|
16
|
-
const mql = window.matchMedia(query);
|
|
17
|
-
const [matches, setMatches] = signal(mql.matches);
|
|
18
|
-
const handler = (event) => {
|
|
19
|
-
setMatches(event.matches);
|
|
20
|
-
};
|
|
21
|
-
mql.addEventListener("change", handler);
|
|
22
|
-
function dispose() {
|
|
23
|
-
mql.removeEventListener("change", handler);
|
|
24
|
-
}
|
|
25
|
-
return { matches, dispose };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// src/browser/resize.ts
|
|
29
|
-
function resolveTarget(target) {
|
|
30
|
-
return typeof target === "function" ? target : () => target.current;
|
|
31
|
-
}
|
|
32
|
-
function resize(target) {
|
|
33
|
-
const [width, setWidth] = signal(0);
|
|
34
|
-
const [height, setHeight] = signal(0);
|
|
35
|
-
let observer = null;
|
|
36
|
-
if (typeof window === "undefined" || typeof ResizeObserver === "undefined") {
|
|
37
|
-
return { width, height, dispose: () => {
|
|
38
|
-
} };
|
|
39
|
-
}
|
|
40
|
-
const getter = resolveTarget(target);
|
|
41
|
-
const cleanup = effect(() => {
|
|
42
|
-
const el = getter();
|
|
43
|
-
if (observer) {
|
|
44
|
-
observer.disconnect();
|
|
45
|
-
observer = null;
|
|
46
|
-
}
|
|
47
|
-
if (!el) return;
|
|
48
|
-
observer = new ResizeObserver((entries) => {
|
|
49
|
-
const entry = entries[0];
|
|
50
|
-
if (entry) {
|
|
51
|
-
batch(() => {
|
|
52
|
-
setWidth(entry.contentRect.width);
|
|
53
|
-
setHeight(entry.contentRect.height);
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
observer.observe(el);
|
|
58
|
-
});
|
|
59
|
-
function dispose() {
|
|
60
|
-
cleanup();
|
|
61
|
-
if (observer) {
|
|
62
|
-
observer.disconnect();
|
|
63
|
-
observer = null;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return { width, height, dispose };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// src/browser/scroll.ts
|
|
70
|
-
function scroll(target) {
|
|
71
|
-
const [x, setX] = signal(0);
|
|
72
|
-
const [y, setY] = signal(0);
|
|
73
|
-
const [isScrolling, setIsScrolling] = signal(false);
|
|
74
|
-
let scrollTimer = null;
|
|
75
|
-
if (typeof window === "undefined") {
|
|
76
|
-
return { x, y, isScrolling, dispose: () => {
|
|
77
|
-
} };
|
|
78
|
-
}
|
|
79
|
-
const handler = () => {
|
|
80
|
-
const el = target ? target() : null;
|
|
81
|
-
batch(() => {
|
|
82
|
-
if (el) {
|
|
83
|
-
setX(el.scrollLeft);
|
|
84
|
-
setY(el.scrollTop);
|
|
85
|
-
} else {
|
|
86
|
-
setX(window.scrollX ?? window.pageXOffset ?? 0);
|
|
87
|
-
setY(window.scrollY ?? window.pageYOffset ?? 0);
|
|
88
|
-
}
|
|
89
|
-
setIsScrolling(true);
|
|
90
|
-
});
|
|
91
|
-
if (scrollTimer !== null) clearTimeout(scrollTimer);
|
|
92
|
-
scrollTimer = setTimeout(() => {
|
|
93
|
-
setIsScrolling(false);
|
|
94
|
-
scrollTimer = null;
|
|
95
|
-
}, 150);
|
|
96
|
-
};
|
|
97
|
-
const scrollTarget = target ? target() : null;
|
|
98
|
-
const eventTarget = scrollTarget || window;
|
|
99
|
-
eventTarget.addEventListener("scroll", handler, { passive: true });
|
|
100
|
-
function dispose() {
|
|
101
|
-
eventTarget.removeEventListener("scroll", handler);
|
|
102
|
-
if (scrollTimer !== null) {
|
|
103
|
-
clearTimeout(scrollTimer);
|
|
104
|
-
scrollTimer = null;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return { x, y, isScrolling, dispose };
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// src/browser/online.ts
|
|
111
|
-
function online() {
|
|
112
|
-
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
113
|
-
const [online3] = signal(true);
|
|
114
|
-
return { online: online3, dispose: () => {
|
|
115
|
-
} };
|
|
116
|
-
}
|
|
117
|
-
const [online2, setOnline] = signal(navigator.onLine);
|
|
118
|
-
const onOnline = () => setOnline(true);
|
|
119
|
-
const onOffline = () => setOnline(false);
|
|
120
|
-
window.addEventListener("online", onOnline);
|
|
121
|
-
window.addEventListener("offline", onOffline);
|
|
122
|
-
function dispose() {
|
|
123
|
-
window.removeEventListener("online", onOnline);
|
|
124
|
-
window.removeEventListener("offline", onOffline);
|
|
125
|
-
}
|
|
126
|
-
return { online: online2, dispose };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// src/browser/geo.ts
|
|
130
|
-
function geo(options) {
|
|
131
|
-
const [latitude, setLatitude] = signal(null);
|
|
132
|
-
const [longitude, setLongitude] = signal(null);
|
|
133
|
-
const [accuracy, setAccuracy] = signal(null);
|
|
134
|
-
const [error, setError] = signal(null);
|
|
135
|
-
let watchId = null;
|
|
136
|
-
if (typeof navigator !== "undefined" && navigator.geolocation) {
|
|
137
|
-
watchId = navigator.geolocation.watchPosition(
|
|
138
|
-
(position) => {
|
|
139
|
-
batch(() => {
|
|
140
|
-
setLatitude(position.coords.latitude);
|
|
141
|
-
setLongitude(position.coords.longitude);
|
|
142
|
-
setAccuracy(position.coords.accuracy);
|
|
143
|
-
setError(null);
|
|
144
|
-
});
|
|
145
|
-
},
|
|
146
|
-
(err) => {
|
|
147
|
-
setError(err);
|
|
148
|
-
},
|
|
149
|
-
options
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
function dispose() {
|
|
153
|
-
if (watchId !== null && typeof navigator !== "undefined" && navigator.geolocation) {
|
|
154
|
-
navigator.geolocation.clearWatch(watchId);
|
|
155
|
-
watchId = null;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return { latitude, longitude, accuracy, error, dispose };
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// src/browser/battery.ts
|
|
162
|
-
function battery() {
|
|
163
|
-
const [level, setLevel] = signal(null);
|
|
164
|
-
const [charging, setCharging] = signal(null);
|
|
165
|
-
const [chargingTime, setChargingTime] = signal(null);
|
|
166
|
-
const [dischargingTime, setDischargingTime] = signal(null);
|
|
167
|
-
const [supported, setSupported] = signal(false);
|
|
168
|
-
let battery2 = null;
|
|
169
|
-
let onLevelChange = null;
|
|
170
|
-
let onChargingChange = null;
|
|
171
|
-
let onChargingTimeChange = null;
|
|
172
|
-
let onDischargingTimeChange = null;
|
|
173
|
-
let disposed = false;
|
|
174
|
-
if (typeof navigator !== "undefined" && "getBattery" in navigator) {
|
|
175
|
-
setSupported(true);
|
|
176
|
-
navigator.getBattery().then((bm) => {
|
|
177
|
-
if (disposed) return;
|
|
178
|
-
battery2 = bm;
|
|
179
|
-
batch(() => {
|
|
180
|
-
setLevel(bm.level);
|
|
181
|
-
setCharging(bm.charging);
|
|
182
|
-
setChargingTime(bm.chargingTime);
|
|
183
|
-
setDischargingTime(bm.dischargingTime);
|
|
184
|
-
});
|
|
185
|
-
onLevelChange = () => setLevel(bm.level);
|
|
186
|
-
onChargingChange = () => setCharging(bm.charging);
|
|
187
|
-
onChargingTimeChange = () => setChargingTime(bm.chargingTime);
|
|
188
|
-
onDischargingTimeChange = () => setDischargingTime(bm.dischargingTime);
|
|
189
|
-
bm.addEventListener("levelchange", onLevelChange);
|
|
190
|
-
bm.addEventListener("chargingchange", onChargingChange);
|
|
191
|
-
bm.addEventListener("chargingtimechange", onChargingTimeChange);
|
|
192
|
-
bm.addEventListener("dischargingtimechange", onDischargingTimeChange);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
function dispose() {
|
|
196
|
-
disposed = true;
|
|
197
|
-
if (battery2) {
|
|
198
|
-
if (onLevelChange) battery2.removeEventListener("levelchange", onLevelChange);
|
|
199
|
-
if (onChargingChange) battery2.removeEventListener("chargingchange", onChargingChange);
|
|
200
|
-
if (onChargingTimeChange) battery2.removeEventListener("chargingtimechange", onChargingTimeChange);
|
|
201
|
-
if (onDischargingTimeChange) battery2.removeEventListener("dischargingtimechange", onDischargingTimeChange);
|
|
202
|
-
battery2 = null;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return { level, charging, chargingTime, dischargingTime, supported, dispose };
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// src/browser/idle.ts
|
|
209
|
-
var ACTIVITY_EVENTS = ["mousemove", "mousedown", "keydown", "touchstart", "scroll"];
|
|
210
|
-
function idle(timeout = 6e4) {
|
|
211
|
-
const [idle2, setIdle] = signal(false);
|
|
212
|
-
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
213
|
-
return { idle: idle2, dispose: () => {
|
|
214
|
-
} };
|
|
215
|
-
}
|
|
216
|
-
let timer = null;
|
|
217
|
-
function resetTimer() {
|
|
218
|
-
setIdle(false);
|
|
219
|
-
if (timer !== null) clearTimeout(timer);
|
|
220
|
-
timer = setTimeout(() => {
|
|
221
|
-
setIdle(true);
|
|
222
|
-
}, timeout);
|
|
223
|
-
}
|
|
224
|
-
for (const event of ACTIVITY_EVENTS) {
|
|
225
|
-
document.addEventListener(event, resetTimer, { passive: true });
|
|
226
|
-
}
|
|
227
|
-
resetTimer();
|
|
228
|
-
function dispose() {
|
|
229
|
-
if (timer !== null) {
|
|
230
|
-
clearTimeout(timer);
|
|
231
|
-
timer = null;
|
|
232
|
-
}
|
|
233
|
-
for (const event of ACTIVITY_EVENTS) {
|
|
234
|
-
document.removeEventListener(event, resetTimer);
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return { idle: idle2, dispose };
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
// src/browser/permissions.ts
|
|
241
|
-
function permissions(name) {
|
|
242
|
-
const [state, setState] = signal("prompt");
|
|
243
|
-
let permissionStatus = null;
|
|
244
|
-
let onChange = null;
|
|
245
|
-
let disposed = false;
|
|
246
|
-
if (typeof navigator === "undefined" || !navigator.permissions) {
|
|
247
|
-
setState("unsupported");
|
|
248
|
-
return { state, dispose: () => {
|
|
249
|
-
} };
|
|
250
|
-
}
|
|
251
|
-
navigator.permissions.query({ name }).then((status) => {
|
|
252
|
-
if (disposed) return;
|
|
253
|
-
permissionStatus = status;
|
|
254
|
-
setState(status.state);
|
|
255
|
-
onChange = () => {
|
|
256
|
-
setState(status.state);
|
|
257
|
-
};
|
|
258
|
-
status.addEventListener("change", onChange);
|
|
259
|
-
}).catch(() => {
|
|
260
|
-
setState("unsupported");
|
|
261
|
-
});
|
|
262
|
-
function dispose() {
|
|
263
|
-
disposed = true;
|
|
264
|
-
if (permissionStatus && onChange) {
|
|
265
|
-
permissionStatus.removeEventListener("change", onChange);
|
|
266
|
-
permissionStatus = null;
|
|
267
|
-
onChange = null;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return { state, dispose };
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// src/browser/clipboard.ts
|
|
274
|
-
function clipboard() {
|
|
275
|
-
const [text, setText] = signal("");
|
|
276
|
-
const [copied, setCopied] = signal(false);
|
|
277
|
-
let copiedTimer = null;
|
|
278
|
-
async function copy(value) {
|
|
279
|
-
if (typeof navigator === "undefined" || !navigator.clipboard) {
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
await navigator.clipboard.writeText(value);
|
|
283
|
-
setText(value);
|
|
284
|
-
setCopied(true);
|
|
285
|
-
if (copiedTimer !== null) clearTimeout(copiedTimer);
|
|
286
|
-
copiedTimer = setTimeout(() => {
|
|
287
|
-
setCopied(false);
|
|
288
|
-
copiedTimer = null;
|
|
289
|
-
}, 2e3);
|
|
290
|
-
}
|
|
291
|
-
function dispose() {
|
|
292
|
-
if (copiedTimer !== null) {
|
|
293
|
-
clearTimeout(copiedTimer);
|
|
294
|
-
copiedTimer = null;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return { text, copy, copied, dispose };
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// src/browser/dragDrop.ts
|
|
301
|
-
function resolveTarget2(target) {
|
|
302
|
-
return typeof target === "function" ? target : () => target.current;
|
|
303
|
-
}
|
|
304
|
-
function draggable(element, data) {
|
|
305
|
-
const [isDragging, setIsDragging] = signal(false);
|
|
306
|
-
if (typeof window === "undefined") {
|
|
307
|
-
return { isDragging, dispose: () => {
|
|
308
|
-
} };
|
|
309
|
-
}
|
|
310
|
-
let currentEl = null;
|
|
311
|
-
let onDragStart = null;
|
|
312
|
-
let onDragEnd = null;
|
|
313
|
-
const getter = resolveTarget2(element);
|
|
314
|
-
const cleanup = effect(() => {
|
|
315
|
-
if (currentEl && onDragStart && onDragEnd) {
|
|
316
|
-
currentEl.removeEventListener("dragstart", onDragStart);
|
|
317
|
-
currentEl.removeEventListener("dragend", onDragEnd);
|
|
318
|
-
}
|
|
319
|
-
const el = getter();
|
|
320
|
-
currentEl = el;
|
|
321
|
-
if (!el) return;
|
|
322
|
-
el.draggable = true;
|
|
323
|
-
onDragStart = (e) => {
|
|
324
|
-
setIsDragging(true);
|
|
325
|
-
if (e.dataTransfer && data !== void 0) {
|
|
326
|
-
e.dataTransfer.setData("application/json", JSON.stringify(data));
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
onDragEnd = () => {
|
|
330
|
-
setIsDragging(false);
|
|
331
|
-
};
|
|
332
|
-
el.addEventListener("dragstart", onDragStart);
|
|
333
|
-
el.addEventListener("dragend", onDragEnd);
|
|
334
|
-
});
|
|
335
|
-
function dispose() {
|
|
336
|
-
cleanup();
|
|
337
|
-
if (currentEl && onDragStart && onDragEnd) {
|
|
338
|
-
currentEl.removeEventListener("dragstart", onDragStart);
|
|
339
|
-
currentEl.removeEventListener("dragend", onDragEnd);
|
|
340
|
-
currentEl = null;
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
return { isDragging, dispose };
|
|
344
|
-
}
|
|
345
|
-
function dropZone(element, options) {
|
|
346
|
-
const [isOver, setIsOver] = signal(false);
|
|
347
|
-
if (typeof window === "undefined") {
|
|
348
|
-
return { isOver, dispose: () => {
|
|
349
|
-
} };
|
|
350
|
-
}
|
|
351
|
-
let currentEl = null;
|
|
352
|
-
let onDragOver = null;
|
|
353
|
-
let onDragEnter = null;
|
|
354
|
-
let onDragLeave = null;
|
|
355
|
-
let onDrop = null;
|
|
356
|
-
const getter = resolveTarget2(element);
|
|
357
|
-
const cleanup = effect(() => {
|
|
358
|
-
if (currentEl && onDragOver && onDragEnter && onDragLeave && onDrop) {
|
|
359
|
-
currentEl.removeEventListener("dragover", onDragOver);
|
|
360
|
-
currentEl.removeEventListener("dragenter", onDragEnter);
|
|
361
|
-
currentEl.removeEventListener("dragleave", onDragLeave);
|
|
362
|
-
currentEl.removeEventListener("drop", onDrop);
|
|
363
|
-
}
|
|
364
|
-
const el = getter();
|
|
365
|
-
currentEl = el;
|
|
366
|
-
if (!el) return;
|
|
367
|
-
onDragOver = (e) => {
|
|
368
|
-
e.preventDefault();
|
|
369
|
-
};
|
|
370
|
-
onDragEnter = (e) => {
|
|
371
|
-
e.preventDefault();
|
|
372
|
-
setIsOver(true);
|
|
373
|
-
};
|
|
374
|
-
onDragLeave = () => {
|
|
375
|
-
setIsOver(false);
|
|
376
|
-
};
|
|
377
|
-
onDrop = (e) => {
|
|
378
|
-
e.preventDefault();
|
|
379
|
-
setIsOver(false);
|
|
380
|
-
let transferData = null;
|
|
381
|
-
if (e.dataTransfer) {
|
|
382
|
-
const raw = e.dataTransfer.getData("application/json");
|
|
383
|
-
if (raw) {
|
|
384
|
-
try {
|
|
385
|
-
transferData = JSON.parse(raw);
|
|
386
|
-
} catch {
|
|
387
|
-
transferData = raw;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
options.onDrop(transferData, e);
|
|
392
|
-
};
|
|
393
|
-
el.addEventListener("dragover", onDragOver);
|
|
394
|
-
el.addEventListener("dragenter", onDragEnter);
|
|
395
|
-
el.addEventListener("dragleave", onDragLeave);
|
|
396
|
-
el.addEventListener("drop", onDrop);
|
|
397
|
-
});
|
|
398
|
-
function dispose() {
|
|
399
|
-
cleanup();
|
|
400
|
-
if (currentEl && onDragOver && onDragEnter && onDragLeave && onDrop) {
|
|
401
|
-
currentEl.removeEventListener("dragover", onDragOver);
|
|
402
|
-
currentEl.removeEventListener("dragenter", onDragEnter);
|
|
403
|
-
currentEl.removeEventListener("dragleave", onDragLeave);
|
|
404
|
-
currentEl.removeEventListener("drop", onDrop);
|
|
405
|
-
currentEl = null;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
return { isOver, dispose };
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// src/browser/title.ts
|
|
412
|
-
function title(value) {
|
|
413
|
-
if (typeof document === "undefined") {
|
|
414
|
-
return () => {
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
const previousTitle = document.title;
|
|
418
|
-
if (typeof value === "function") {
|
|
419
|
-
const cleanup = effect(() => {
|
|
420
|
-
document.title = value();
|
|
421
|
-
});
|
|
422
|
-
return () => {
|
|
423
|
-
cleanup();
|
|
424
|
-
document.title = previousTitle;
|
|
425
|
-
};
|
|
426
|
-
}
|
|
427
|
-
document.title = value;
|
|
428
|
-
return () => {
|
|
429
|
-
document.title = previousTitle;
|
|
430
|
-
};
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// src/browser/colorScheme.ts
|
|
434
|
-
function colorScheme() {
|
|
435
|
-
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
436
|
-
const [scheme2] = signal("light");
|
|
437
|
-
return { scheme: scheme2, dispose: () => {
|
|
438
|
-
} };
|
|
439
|
-
}
|
|
440
|
-
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
441
|
-
const [scheme, setScheme] = signal(mql.matches ? "dark" : "light");
|
|
442
|
-
const handler = (event) => {
|
|
443
|
-
setScheme(event.matches ? "dark" : "light");
|
|
444
|
-
};
|
|
445
|
-
mql.addEventListener("change", handler);
|
|
446
|
-
function dispose() {
|
|
447
|
-
mql.removeEventListener("change", handler);
|
|
448
|
-
}
|
|
449
|
-
return { scheme, dispose };
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// src/browser/format.ts
|
|
453
|
-
function formatNumber(value, options) {
|
|
454
|
-
const { locale, ...formatOptions } = options ?? {};
|
|
455
|
-
return new Intl.NumberFormat(locale, formatOptions).format(value);
|
|
456
|
-
}
|
|
457
|
-
function formatCurrency(value, currency, options) {
|
|
458
|
-
const { locale, ...formatOptions } = options ?? {};
|
|
459
|
-
return new Intl.NumberFormat(locale, {
|
|
460
|
-
style: "currency",
|
|
461
|
-
currency,
|
|
462
|
-
...formatOptions
|
|
463
|
-
}).format(value);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
export {
|
|
467
|
-
media,
|
|
468
|
-
resize,
|
|
469
|
-
scroll,
|
|
470
|
-
online,
|
|
471
|
-
geo,
|
|
472
|
-
battery,
|
|
473
|
-
idle,
|
|
474
|
-
permissions,
|
|
475
|
-
clipboard,
|
|
476
|
-
draggable,
|
|
477
|
-
dropZone,
|
|
478
|
-
title,
|
|
479
|
-
colorScheme,
|
|
480
|
-
formatNumber,
|
|
481
|
-
formatCurrency
|
|
482
|
-
};
|
package/dist/chunk-4MYMUBRS.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// src/core/dev.ts
|
|
2
|
-
function isDev() {
|
|
3
|
-
return typeof globalThis.__SIBU_DEV__ !== "undefined" ? !!globalThis.__SIBU_DEV__ : typeof __SIBU_DEV__ !== "undefined" ? __SIBU_DEV__ : true;
|
|
4
|
-
}
|
|
5
|
-
var _isDev = isDev();
|
|
6
|
-
function devAssert(condition, message) {
|
|
7
|
-
if (_isDev && !condition) {
|
|
8
|
-
throw new Error(`[Sibu] ${message}`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
function devWarn(message) {
|
|
12
|
-
if (_isDev) {
|
|
13
|
-
console.warn(`[Sibu] ${message}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export {
|
|
18
|
-
isDev,
|
|
19
|
-
devAssert,
|
|
20
|
-
devWarn
|
|
21
|
-
};
|