@bquery/bquery 1.8.2 → 1.9.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.
Files changed (75) hide show
  1. package/README.md +96 -24
  2. package/dist/{a11y-DVBCy09c.js → a11y-_9X-kt-_.js} +2 -2
  3. package/dist/{a11y-DVBCy09c.js.map → a11y-_9X-kt-_.js.map} +1 -1
  4. package/dist/a11y.es.mjs +1 -1
  5. package/dist/{forms-UcRHsYxC.js → forms-UhAeJEoO.js} +13 -13
  6. package/dist/{forms-UcRHsYxC.js.map → forms-UhAeJEoO.js.map} +1 -1
  7. package/dist/forms.es.mjs +1 -1
  8. package/dist/full.d.ts +4 -4
  9. package/dist/full.d.ts.map +1 -1
  10. package/dist/full.es.mjs +201 -196
  11. package/dist/full.iife.js +20 -20
  12. package/dist/full.iife.js.map +1 -1
  13. package/dist/full.umd.js +20 -20
  14. package/dist/full.umd.js.map +1 -1
  15. package/dist/index.es.mjs +214 -209
  16. package/dist/media/index.d.ts +10 -3
  17. package/dist/media/index.d.ts.map +1 -1
  18. package/dist/media/observers.d.ts +99 -0
  19. package/dist/media/observers.d.ts.map +1 -0
  20. package/dist/media/types.d.ts +125 -0
  21. package/dist/media/types.d.ts.map +1 -1
  22. package/dist/media-D4zLj9t-.js +514 -0
  23. package/dist/media-D4zLj9t-.js.map +1 -0
  24. package/dist/media.es.mjs +12 -9
  25. package/dist/mount-B-JvH6Y0.js +449 -0
  26. package/dist/mount-B-JvH6Y0.js.map +1 -0
  27. package/dist/reactive/index.d.ts +2 -2
  28. package/dist/reactive/index.d.ts.map +1 -1
  29. package/dist/reactive/signal.d.ts +2 -1
  30. package/dist/reactive/signal.d.ts.map +1 -1
  31. package/dist/reactive/watch.d.ts +49 -0
  32. package/dist/reactive/watch.d.ts.map +1 -1
  33. package/dist/reactive-BjpLkclt.js +1184 -0
  34. package/dist/{reactive-DwkhUJfP.js.map → reactive-BjpLkclt.js.map} +1 -1
  35. package/dist/reactive.es.mjs +35 -33
  36. package/dist/{router-CQikC9Ed.js → router-BieVwgci.js} +2 -2
  37. package/dist/{router-CQikC9Ed.js.map → router-BieVwgci.js.map} +1 -1
  38. package/dist/router.es.mjs +1 -1
  39. package/dist/{ssr-_dAcGdzu.js → ssr-CrGSJySz.js} +3 -3
  40. package/dist/{ssr-_dAcGdzu.js.map → ssr-CrGSJySz.js.map} +1 -1
  41. package/dist/ssr.es.mjs +1 -1
  42. package/dist/{store-Cb3gPRve.js → store-CY6sjTW3.js} +2 -2
  43. package/dist/{store-Cb3gPRve.js.map → store-CY6sjTW3.js.map} +1 -1
  44. package/dist/store.es.mjs +1 -1
  45. package/dist/{testing-C5Sjfsna.js → testing-UjAtu9aQ.js} +9 -9
  46. package/dist/{testing-C5Sjfsna.js.map → testing-UjAtu9aQ.js.map} +1 -1
  47. package/dist/testing.es.mjs +1 -1
  48. package/dist/view/directives/aria.d.ts +7 -0
  49. package/dist/view/directives/aria.d.ts.map +1 -0
  50. package/dist/view/directives/error.d.ts +7 -0
  51. package/dist/view/directives/error.d.ts.map +1 -0
  52. package/dist/view/directives/index.d.ts +2 -0
  53. package/dist/view/directives/index.d.ts.map +1 -1
  54. package/dist/view/mount.d.ts.map +1 -1
  55. package/dist/view/process.d.ts +2 -0
  56. package/dist/view/process.d.ts.map +1 -1
  57. package/dist/view.es.mjs +2 -2
  58. package/package.json +5 -5
  59. package/src/full.ts +12 -0
  60. package/src/media/index.ts +20 -2
  61. package/src/media/observers.ts +421 -0
  62. package/src/media/types.ts +136 -0
  63. package/src/reactive/index.ts +3 -0
  64. package/src/reactive/signal.ts +2 -1
  65. package/src/reactive/watch.ts +137 -0
  66. package/src/view/directives/aria.ts +72 -0
  67. package/src/view/directives/error.ts +56 -0
  68. package/src/view/directives/index.ts +2 -0
  69. package/src/view/mount.ts +4 -0
  70. package/src/view/process.ts +6 -0
  71. package/dist/media-i-fB5WxI.js +0 -340
  72. package/dist/media-i-fB5WxI.js.map +0 -1
  73. package/dist/mount-B4Y8bk8Z.js +0 -403
  74. package/dist/mount-B4Y8bk8Z.js.map +0 -1
  75. package/dist/reactive-DwkhUJfP.js +0 -1148
@@ -6,7 +6,9 @@ import type { Computed } from './computed';
6
6
  import type { Signal } from './core';
7
7
  import type { CleanupFn } from './internals';
8
8
 
9
+ import { debounce, throttle } from '../core/utils/function';
9
10
  import { effect } from './effect';
11
+ import { getCurrentScope, onScopeDispose } from './scope';
10
12
 
11
13
  /**
12
14
  * Options for the watch function.
@@ -71,3 +73,138 @@ export const watch = <T>(
71
73
  }
72
74
  });
73
75
  };
76
+
77
+ /**
78
+ * Watches a signal or computed value and debounces callback delivery.
79
+ * Rapid changes are collapsed into a single callback using the latest value
80
+ * and the first old value observed within the debounce window.
81
+ *
82
+ * @template T - The type of the watched value
83
+ * @param source - The signal or computed to watch
84
+ * @param callback - Function called with the debounced (newValue, oldValue)
85
+ * @param delayMs - Debounce delay in milliseconds
86
+ * @param options - Watch options
87
+ * @returns A cleanup function to stop watching and cancel pending callbacks
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const query = signal('');
92
+ * const stop = watchDebounce(query, (newQuery) => {
93
+ * console.log('Search for', newQuery);
94
+ * }, 250);
95
+ *
96
+ * query.value = 'b';
97
+ * query.value = 'bq';
98
+ * query.value = 'bqu'; // Only this value is delivered after 250ms
99
+ *
100
+ * stop();
101
+ * ```
102
+ */
103
+ export const watchDebounce = <T>(
104
+ source: Signal<T> | Computed<T>,
105
+ callback: (newValue: T, oldValue: T | undefined) => void,
106
+ delayMs: number,
107
+ options: WatchOptions<T> = {}
108
+ ): CleanupFn => {
109
+ const { immediate = false, equals = Object.is } = options;
110
+ const normalizedDelayMs = Number.isFinite(delayMs) ? Math.max(0, delayMs) : 0;
111
+ let hasPending = false;
112
+ let pendingNewValue!: T;
113
+ let pendingOldValue: T | undefined;
114
+ const cancelPending = (): void => {
115
+ notify.cancel();
116
+ hasPending = false;
117
+ pendingOldValue = undefined;
118
+ };
119
+
120
+ const notify = debounce(() => {
121
+ if (!hasPending) {
122
+ return;
123
+ }
124
+
125
+ try {
126
+ callback(pendingNewValue, pendingOldValue);
127
+ } catch (error) {
128
+ console.error('bQuery reactive: Error in watchDebounce callback', error);
129
+ }
130
+ hasPending = false;
131
+ pendingOldValue = undefined;
132
+ }, normalizedDelayMs);
133
+
134
+ if (immediate) {
135
+ callback(source.peek(), undefined);
136
+ }
137
+
138
+ const cleanup = watch(
139
+ source,
140
+ (newValue, oldValue) => {
141
+ if (!hasPending) {
142
+ pendingOldValue = oldValue;
143
+ }
144
+
145
+ pendingNewValue = newValue;
146
+ hasPending = true;
147
+ notify();
148
+ },
149
+ { equals }
150
+ );
151
+
152
+ if (getCurrentScope()) {
153
+ onScopeDispose(cancelPending);
154
+ }
155
+
156
+ return () => {
157
+ cleanup();
158
+ cancelPending();
159
+ };
160
+ };
161
+
162
+ /**
163
+ * Watches a signal or computed value and throttles callback delivery.
164
+ * Changes are delivered at most once per interval.
165
+ *
166
+ * @template T - The type of the watched value
167
+ * @param source - The signal or computed to watch
168
+ * @param callback - Function called with throttled (newValue, oldValue) updates
169
+ * @param intervalMs - Minimum interval between callback runs in milliseconds
170
+ * @param options - Watch options
171
+ * @returns A cleanup function to stop watching and reset the throttle window
172
+ *
173
+ * @example
174
+ * ```ts
175
+ * const scrollY = signal(0);
176
+ * const stop = watchThrottle(scrollY, (nextY) => {
177
+ * console.log('Scroll position', nextY);
178
+ * }, 100);
179
+ *
180
+ * stop();
181
+ * ```
182
+ */
183
+ export const watchThrottle = <T>(
184
+ source: Signal<T> | Computed<T>,
185
+ callback: (newValue: T, oldValue: T | undefined) => void,
186
+ intervalMs: number,
187
+ options: WatchOptions<T> = {}
188
+ ): CleanupFn => {
189
+ const { immediate = false, equals = Object.is } = options;
190
+ const normalizedIntervalMs = Number.isFinite(intervalMs) ? Math.max(0, intervalMs) : 0;
191
+ const notify = throttle(
192
+ (newValue: T, oldValue: T | undefined) => {
193
+ callback(newValue, oldValue);
194
+ },
195
+ normalizedIntervalMs
196
+ );
197
+
198
+ if (immediate) {
199
+ notify(source.peek(), undefined);
200
+ }
201
+
202
+ const cleanup = watch(source, (newValue, oldValue) => {
203
+ notify(newValue, oldValue);
204
+ }, { equals });
205
+
206
+ return () => {
207
+ cleanup();
208
+ notify.cancel();
209
+ };
210
+ };
@@ -0,0 +1,72 @@
1
+ import { effect } from '../../reactive/index';
2
+ import { isPrototypePollutionKey } from '../../core/utils/object';
3
+ import { evaluate, parseObjectExpression } from '../evaluate';
4
+ import type { DirectiveHandler } from '../types';
5
+
6
+ const toKebabCase = (value: string): string => value.replace(/([A-Z])/g, '-$1').toLowerCase();
7
+
8
+ const normalizeAriaAttribute = (name: string): string => {
9
+ const trimmed = name.trim();
10
+ const lower = trimmed.toLowerCase();
11
+
12
+ if (lower.startsWith('aria-')) {
13
+ return lower;
14
+ }
15
+
16
+ const withoutPrefix = /^aria[A-Z]/.test(trimmed) ? trimmed.slice(4) : trimmed;
17
+ return `aria-${toKebabCase(withoutPrefix).replace(/^-/, '')}`;
18
+ };
19
+
20
+ const shouldRemoveAttribute = (value: unknown): boolean => value == null || value === '';
21
+
22
+ /**
23
+ * Handles bq-aria directive - reactive ARIA attribute binding.
24
+ * @internal
25
+ */
26
+ export const handleAria: DirectiveHandler = (el, expression, context, cleanups) => {
27
+ let appliedAttributes: Set<string> = new Set();
28
+
29
+ const cleanup = effect(() => {
30
+ const newAttributes = new Set<string>();
31
+ const ariaValues = Object.create(null) as Record<string, unknown>;
32
+
33
+ if (expression.trimStart().startsWith('{')) {
34
+ const ariaMap = parseObjectExpression(expression);
35
+ for (const [attrName, valueExpr] of Object.entries(ariaMap)) {
36
+ ariaValues[attrName] = evaluate(valueExpr, context);
37
+ }
38
+ } else {
39
+ const result = evaluate<Record<string, unknown>>(expression, context);
40
+ if (result && typeof result === 'object' && !Array.isArray(result)) {
41
+ for (const [attrName, value] of Object.entries(result)) {
42
+ if (isPrototypePollutionKey(attrName)) {
43
+ continue;
44
+ }
45
+
46
+ ariaValues[attrName] = value;
47
+ }
48
+ }
49
+ }
50
+
51
+ for (const [attrName, value] of Object.entries(ariaValues)) {
52
+ const normalizedName = normalizeAriaAttribute(attrName);
53
+ if (shouldRemoveAttribute(value)) {
54
+ el.removeAttribute(normalizedName);
55
+ continue;
56
+ }
57
+
58
+ el.setAttribute(normalizedName, value === true ? 'true' : String(value));
59
+ newAttributes.add(normalizedName);
60
+ }
61
+
62
+ for (const attrName of appliedAttributes) {
63
+ if (!newAttributes.has(attrName)) {
64
+ el.removeAttribute(attrName);
65
+ }
66
+ }
67
+
68
+ appliedAttributes = newAttributes;
69
+ });
70
+
71
+ cleanups.push(cleanup);
72
+ };
@@ -0,0 +1,56 @@
1
+ import { effect, isComputed, isSignal } from '../../reactive/index';
2
+ import { evaluate } from '../evaluate';
3
+ import type { DirectiveHandler } from '../types';
4
+
5
+ type ErrorSource = unknown;
6
+
7
+ const getErrorMessage = (source: ErrorSource): string => {
8
+ if (isSignal(source) || isComputed(source)) {
9
+ return String(source.value ?? '');
10
+ }
11
+
12
+ if (source && typeof source === 'object' && 'error' in source) {
13
+ const errorValue = source.error;
14
+ if (isSignal(errorValue) || isComputed(errorValue)) {
15
+ return String(errorValue.value ?? '');
16
+ }
17
+ return String(errorValue ?? '');
18
+ }
19
+
20
+ return String(source ?? '');
21
+ };
22
+
23
+ /**
24
+ * Handles bq-error directive - renders error messages and toggles visibility.
25
+ * @internal
26
+ */
27
+ export const handleError: DirectiveHandler = (el, expression, context, cleanups) => {
28
+ const htmlEl = el as HTMLElement;
29
+ const shouldManageAriaHidden = !htmlEl.hasAttribute('aria-hidden');
30
+
31
+ if (!htmlEl.hasAttribute('role')) {
32
+ htmlEl.setAttribute('role', 'alert');
33
+ }
34
+
35
+ if (!htmlEl.hasAttribute('aria-live')) {
36
+ htmlEl.setAttribute('aria-live', 'assertive');
37
+ }
38
+
39
+ const cleanup = effect(() => {
40
+ const source = evaluate(expression, context);
41
+ const message = getErrorMessage(source).trim();
42
+ const hasMessage = message.length > 0;
43
+
44
+ htmlEl.textContent = message;
45
+ htmlEl.hidden = !hasMessage;
46
+ if (shouldManageAriaHidden) {
47
+ if (hasMessage) {
48
+ htmlEl.removeAttribute('aria-hidden');
49
+ } else {
50
+ htmlEl.setAttribute('aria-hidden', 'true');
51
+ }
52
+ }
53
+ });
54
+
55
+ cleanups.push(cleanup);
56
+ };
@@ -1,5 +1,7 @@
1
+ export { handleAria } from './aria';
1
2
  export { handleBind } from './bind';
2
3
  export { handleClass } from './class';
4
+ export { handleError } from './error';
3
5
  export { createForHandler } from './for';
4
6
  export { handleHtml } from './html';
5
7
  export { handleIf } from './if';
package/src/view/mount.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import type { CleanupFn } from '../reactive/index';
2
2
  import {
3
3
  createForHandler,
4
+ handleAria,
4
5
  handleBind,
5
6
  handleClass,
7
+ handleError,
6
8
  handleHtml,
7
9
  handleIf,
8
10
  handleModel,
@@ -80,6 +82,8 @@ export const mount = (
80
82
 
81
83
  const handlers: DirectiveHandlers = {
82
84
  text: handleText,
85
+ error: handleError,
86
+ aria: handleAria,
83
87
  html: handleHtml(sanitize),
84
88
  if: handleIf,
85
89
  show: handleShow,
@@ -5,6 +5,8 @@ import type { BindingContext, DirectiveHandler } from './types';
5
5
 
6
6
  export type DirectiveHandlers = {
7
7
  text: DirectiveHandler;
8
+ error: DirectiveHandler;
9
+ aria: DirectiveHandler;
8
10
  html: DirectiveHandler;
9
11
  if: DirectiveHandler;
10
12
  show: DirectiveHandler;
@@ -46,6 +48,10 @@ export const processElement = (
46
48
  // Handle other directives
47
49
  if (directive === 'text') {
48
50
  handlers.text(el, value, context, cleanups);
51
+ } else if (directive === 'error') {
52
+ handlers.error(el, value, context, cleanups);
53
+ } else if (directive === 'aria') {
54
+ handlers.aria(el, value, context, cleanups);
49
55
  } else if (directive === 'html') {
50
56
  handlers.html(el, value, context, cleanups);
51
57
  } else if (directive === 'if') {
@@ -1,340 +0,0 @@
1
- import { n as s } from "./core-DdtZHzsS.js";
2
- import { m as u } from "./reactive-DwkhUJfP.js";
3
- var A = (t) => {
4
- const a = s(!1);
5
- let i;
6
- if (typeof window < "u" && typeof window.matchMedia == "function") try {
7
- const e = window.matchMedia(t);
8
- a.value = e.matches;
9
- const d = (l) => {
10
- a.value = l.matches;
11
- };
12
- if (typeof e.addEventListener == "function")
13
- e.addEventListener("change", d), i = () => {
14
- e.removeEventListener("change", d);
15
- };
16
- else if (typeof e.addListener == "function") {
17
- const l = e;
18
- l.addListener(d), i = () => {
19
- l.removeListener(d);
20
- };
21
- }
22
- } catch {
23
- }
24
- const r = u(a);
25
- let n = !1;
26
- return Object.defineProperty(r, "destroy", {
27
- enumerable: !1,
28
- configurable: !0,
29
- value() {
30
- n || (n = !0, i?.(), a.dispose());
31
- }
32
- }), r;
33
- }, P = (t) => {
34
- const a = {}, i = [];
35
- for (const e of Object.keys(t)) {
36
- const d = t[e], l = s(!1);
37
- let f;
38
- if (typeof window < "u" && typeof window.matchMedia == "function") try {
39
- const c = window.matchMedia(`(min-width: ${d}px)`);
40
- l.value = c.matches;
41
- const o = (p) => {
42
- l.value = p.matches;
43
- };
44
- if (typeof c.addEventListener == "function")
45
- c.addEventListener("change", o), f = () => {
46
- c.removeEventListener("change", o);
47
- };
48
- else {
49
- const p = c;
50
- typeof p.addListener == "function" && (p.addListener(o), f = () => {
51
- p.removeListener?.(o);
52
- });
53
- }
54
- } catch {
55
- }
56
- const v = u(l);
57
- let g = !1;
58
- Object.defineProperty(v, "destroy", {
59
- enumerable: !1,
60
- configurable: !0,
61
- value() {
62
- g || (g = !0, f?.(), l.dispose());
63
- }
64
- }), i.push(v.destroy), a[e] = v;
65
- }
66
- let r = !1;
67
- const n = Object.defineProperty(a, "destroyAll", {
68
- enumerable: !1,
69
- configurable: !0,
70
- value() {
71
- r || (r = !0, i.forEach((e) => {
72
- e();
73
- }));
74
- }
75
- });
76
- return Object.prototype.hasOwnProperty.call(a, "destroy") || Object.defineProperty(n, "destroy", {
77
- enumerable: !1,
78
- configurable: !0,
79
- value: n.destroyAll
80
- }), n;
81
- }, y = (t, a) => a >= t ? "portrait" : "landscape", x = () => {
82
- const t = s({
83
- width: typeof window < "u" ? window.innerWidth : 0,
84
- height: typeof window < "u" ? window.innerHeight : 0,
85
- orientation: typeof window < "u" ? y(window.innerWidth, window.innerHeight) : "portrait"
86
- });
87
- let a;
88
- if (typeof window < "u") {
89
- const n = () => {
90
- t.value = {
91
- width: window.innerWidth,
92
- height: window.innerHeight,
93
- orientation: y(window.innerWidth, window.innerHeight)
94
- };
95
- };
96
- window.addEventListener("resize", n), a = () => {
97
- window.removeEventListener("resize", n);
98
- };
99
- }
100
- const i = u(t);
101
- let r = !1;
102
- return Object.defineProperty(i, "destroy", {
103
- enumerable: !1,
104
- configurable: !0,
105
- value: () => {
106
- r || (r = !0, a?.(), t.dispose());
107
- }
108
- }), i;
109
- }, h = () => {
110
- const t = typeof navigator < "u" && navigator.onLine !== void 0 ? navigator.onLine : !0, a = (typeof navigator < "u" ? navigator : void 0)?.connection;
111
- return {
112
- online: t,
113
- effectiveType: a?.effectiveType ?? "unknown",
114
- downlink: a?.downlink ?? 0,
115
- rtt: a?.rtt ?? 0
116
- };
117
- }, I = () => {
118
- const t = s(h());
119
- let a;
120
- if (typeof window < "u") {
121
- const n = () => {
122
- t.value = h();
123
- };
124
- window.addEventListener("online", n), window.addEventListener("offline", n);
125
- const e = typeof navigator < "u" ? navigator : void 0;
126
- e?.connection && typeof e.connection.addEventListener == "function" && e.connection.addEventListener("change", n), a = () => {
127
- window.removeEventListener("online", n), window.removeEventListener("offline", n), e?.connection && typeof e.connection.removeEventListener == "function" && e.connection.removeEventListener("change", n);
128
- };
129
- }
130
- const i = u(t);
131
- let r = !1;
132
- return Object.defineProperty(i, "destroy", {
133
- value() {
134
- r || (r = !0, a?.(), t.dispose());
135
- },
136
- enumerable: !1,
137
- configurable: !0
138
- }), i;
139
- }, E = {
140
- supported: !1,
141
- charging: !1,
142
- chargingTime: 0,
143
- dischargingTime: 0,
144
- level: 1
145
- }, j = () => {
146
- const t = s({ ...E });
147
- let a, i = !1;
148
- typeof navigator < "u" && "getBattery" in navigator && typeof navigator.getBattery == "function" && navigator.getBattery().then((n) => {
149
- if (i) return;
150
- const e = () => {
151
- t.value = {
152
- supported: !0,
153
- charging: n.charging,
154
- chargingTime: n.chargingTime,
155
- dischargingTime: n.dischargingTime,
156
- level: n.level
157
- };
158
- };
159
- e(), n.addEventListener("chargingchange", e), n.addEventListener("chargingtimechange", e), n.addEventListener("dischargingtimechange", e), n.addEventListener("levelchange", e), a = () => {
160
- n.removeEventListener("chargingchange", e), n.removeEventListener("chargingtimechange", e), n.removeEventListener("dischargingtimechange", e), n.removeEventListener("levelchange", e);
161
- };
162
- }).catch(() => {
163
- });
164
- const r = u(t);
165
- return Object.defineProperty(r, "destroy", {
166
- enumerable: !1,
167
- configurable: !0,
168
- value() {
169
- i || (i = !0, a?.(), t.dispose());
170
- }
171
- }), r;
172
- }, w = {
173
- supported: !1,
174
- loading: !1,
175
- latitude: null,
176
- longitude: null,
177
- accuracy: null,
178
- altitude: null,
179
- altitudeAccuracy: null,
180
- heading: null,
181
- speed: null,
182
- timestamp: null,
183
- error: null
184
- }, R = (t = {}) => {
185
- const { enableHighAccuracy: a = !1, maximumAge: i = 0, timeout: r = 1 / 0, watch: n = !1 } = t, e = s({ ...w });
186
- let d;
187
- if (typeof navigator < "u" && "geolocation" in navigator) {
188
- e.value = {
189
- ...w,
190
- supported: !0,
191
- loading: !0
192
- };
193
- const v = {
194
- enableHighAccuracy: a,
195
- maximumAge: i,
196
- timeout: r === 1 / 0 ? void 0 : r
197
- }, g = (o) => {
198
- e.value = {
199
- supported: !0,
200
- loading: !1,
201
- latitude: o.coords.latitude,
202
- longitude: o.coords.longitude,
203
- accuracy: o.coords.accuracy,
204
- altitude: o.coords.altitude,
205
- altitudeAccuracy: o.coords.altitudeAccuracy,
206
- heading: o.coords.heading,
207
- speed: o.coords.speed,
208
- timestamp: o.timestamp,
209
- error: null
210
- };
211
- }, c = (o) => {
212
- e.value = {
213
- ...e.value,
214
- loading: !1,
215
- error: o.message
216
- };
217
- };
218
- if (n) {
219
- const o = navigator.geolocation.watchPosition(g, c, v);
220
- d = () => {
221
- navigator.geolocation.clearWatch(o);
222
- };
223
- } else navigator.geolocation.getCurrentPosition(g, c, v);
224
- }
225
- const l = u(e);
226
- let f = !1;
227
- return Object.defineProperty(l, "destroy", {
228
- enumerable: !1,
229
- configurable: !0,
230
- value() {
231
- f || (f = !0, d?.(), e.dispose());
232
- }
233
- }), l;
234
- }, L = {
235
- acceleration: {
236
- x: null,
237
- y: null,
238
- z: null
239
- },
240
- accelerationIncludingGravity: {
241
- x: null,
242
- y: null,
243
- z: null
244
- },
245
- rotationRate: {
246
- alpha: null,
247
- beta: null,
248
- gamma: null
249
- },
250
- interval: 0
251
- }, b = {
252
- alpha: null,
253
- beta: null,
254
- gamma: null,
255
- absolute: !1
256
- }, _ = () => {
257
- const t = s({ ...L });
258
- let a;
259
- if (typeof window < "u") {
260
- const n = (e) => {
261
- t.value = {
262
- acceleration: {
263
- x: e.acceleration?.x ?? null,
264
- y: e.acceleration?.y ?? null,
265
- z: e.acceleration?.z ?? null
266
- },
267
- accelerationIncludingGravity: {
268
- x: e.accelerationIncludingGravity?.x ?? null,
269
- y: e.accelerationIncludingGravity?.y ?? null,
270
- z: e.accelerationIncludingGravity?.z ?? null
271
- },
272
- rotationRate: {
273
- alpha: e.rotationRate?.alpha ?? null,
274
- beta: e.rotationRate?.beta ?? null,
275
- gamma: e.rotationRate?.gamma ?? null
276
- },
277
- interval: e.interval ?? 0
278
- };
279
- };
280
- window.addEventListener("devicemotion", n), a = () => {
281
- window.removeEventListener("devicemotion", n);
282
- };
283
- }
284
- const i = u(t);
285
- let r = !1;
286
- return Object.defineProperty(i, "destroy", {
287
- enumerable: !1,
288
- configurable: !0,
289
- value() {
290
- r || (r = !0, a?.(), t.dispose());
291
- }
292
- }), i;
293
- }, k = () => {
294
- const t = s({ ...b });
295
- let a;
296
- if (typeof window < "u") {
297
- const n = (e) => {
298
- t.value = {
299
- alpha: e.alpha ?? null,
300
- beta: e.beta ?? null,
301
- gamma: e.gamma ?? null,
302
- absolute: e.absolute ?? !1
303
- };
304
- };
305
- window.addEventListener("deviceorientation", n), a = () => {
306
- window.removeEventListener("deviceorientation", n);
307
- };
308
- }
309
- const i = u(t);
310
- let r = !1;
311
- return Object.defineProperty(i, "destroy", {
312
- enumerable: !1,
313
- configurable: !0,
314
- value() {
315
- r || (r = !0, a?.(), t.dispose());
316
- }
317
- }), i;
318
- }, m = "bQuery media: Clipboard API is unavailable. Use a secure context (HTTPS or localhost) and ensure clipboard permissions or user-activation requirements are met.", z = {
319
- read: async () => {
320
- if (typeof navigator > "u" || !navigator.clipboard || typeof navigator.clipboard.readText != "function") throw new Error(m);
321
- return navigator.clipboard.readText();
322
- },
323
- write: async (t) => {
324
- if (typeof navigator > "u" || !navigator.clipboard || typeof navigator.clipboard.writeText != "function") throw new Error(m);
325
- return navigator.clipboard.writeText(t);
326
- }
327
- };
328
- export {
329
- j as a,
330
- P as c,
331
- R as i,
332
- A as l,
333
- _ as n,
334
- I as o,
335
- k as r,
336
- x as s,
337
- z as t
338
- };
339
-
340
- //# sourceMappingURL=media-i-fB5WxI.js.map