@bquery/bquery 1.4.0 → 1.5.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 (127) hide show
  1. package/README.md +139 -120
  2. package/dist/component/component.d.ts.map +1 -1
  3. package/dist/component/index.d.ts +2 -0
  4. package/dist/component/index.d.ts.map +1 -1
  5. package/dist/component/library.d.ts +34 -0
  6. package/dist/component/library.d.ts.map +1 -0
  7. package/dist/component/types.d.ts +10 -6
  8. package/dist/component/types.d.ts.map +1 -1
  9. package/dist/component-CY5MVoYN.js +531 -0
  10. package/dist/component-CY5MVoYN.js.map +1 -0
  11. package/dist/component.es.mjs +6 -184
  12. package/dist/config-DRmZZno3.js +40 -0
  13. package/dist/config-DRmZZno3.js.map +1 -0
  14. package/dist/core-CK2Mfpf4.js +648 -0
  15. package/dist/core-CK2Mfpf4.js.map +1 -0
  16. package/dist/core-DPdbItcq.js +112 -0
  17. package/dist/core-DPdbItcq.js.map +1 -0
  18. package/dist/core.es.mjs +45 -1261
  19. package/dist/full.d.ts +6 -6
  20. package/dist/full.d.ts.map +1 -1
  21. package/dist/full.es.mjs +98 -92
  22. package/dist/full.iife.js +173 -3
  23. package/dist/full.iife.js.map +1 -1
  24. package/dist/full.umd.js +173 -3
  25. package/dist/full.umd.js.map +1 -1
  26. package/dist/index.es.mjs +143 -139
  27. package/dist/motion/transition.d.ts +1 -1
  28. package/dist/motion/transition.d.ts.map +1 -1
  29. package/dist/motion/types.d.ts +11 -1
  30. package/dist/motion/types.d.ts.map +1 -1
  31. package/dist/motion-C5DRdPnO.js +415 -0
  32. package/dist/motion-C5DRdPnO.js.map +1 -0
  33. package/dist/motion.es.mjs +25 -361
  34. package/dist/object-qGpWr6-J.js +38 -0
  35. package/dist/object-qGpWr6-J.js.map +1 -0
  36. package/dist/platform/announcer.d.ts +59 -0
  37. package/dist/platform/announcer.d.ts.map +1 -0
  38. package/dist/platform/config.d.ts +92 -0
  39. package/dist/platform/config.d.ts.map +1 -0
  40. package/dist/platform/cookies.d.ts +45 -0
  41. package/dist/platform/cookies.d.ts.map +1 -0
  42. package/dist/platform/index.d.ts +8 -0
  43. package/dist/platform/index.d.ts.map +1 -1
  44. package/dist/platform/meta.d.ts +62 -0
  45. package/dist/platform/meta.d.ts.map +1 -0
  46. package/dist/platform-B7JhGBc7.js +361 -0
  47. package/dist/platform-B7JhGBc7.js.map +1 -0
  48. package/dist/platform.es.mjs +11 -248
  49. package/dist/reactive/async-data.d.ts +114 -0
  50. package/dist/reactive/async-data.d.ts.map +1 -0
  51. package/dist/reactive/index.d.ts +2 -2
  52. package/dist/reactive/index.d.ts.map +1 -1
  53. package/dist/reactive/signal.d.ts +2 -0
  54. package/dist/reactive/signal.d.ts.map +1 -1
  55. package/dist/reactive-BDya-ia8.js +253 -0
  56. package/dist/reactive-BDya-ia8.js.map +1 -0
  57. package/dist/reactive.es.mjs +18 -34
  58. package/dist/router-CijiICxt.js +188 -0
  59. package/dist/router-CijiICxt.js.map +1 -0
  60. package/dist/router.es.mjs +11 -200
  61. package/dist/sanitize-jyJ2ryE2.js +302 -0
  62. package/dist/sanitize-jyJ2ryE2.js.map +1 -0
  63. package/dist/security/constants.d.ts.map +1 -1
  64. package/dist/security.es.mjs +10 -56
  65. package/dist/store-CPK9E62U.js +262 -0
  66. package/dist/store-CPK9E62U.js.map +1 -0
  67. package/dist/store.es.mjs +12 -25
  68. package/dist/view-Cdi0g-qo.js +396 -0
  69. package/dist/view-Cdi0g-qo.js.map +1 -0
  70. package/dist/view.es.mjs +10 -430
  71. package/package.json +15 -11
  72. package/src/component/component.ts +319 -289
  73. package/src/component/index.ts +42 -40
  74. package/src/component/library.ts +504 -0
  75. package/src/component/types.ts +91 -85
  76. package/src/core/collection.ts +628 -628
  77. package/src/core/element.ts +774 -774
  78. package/src/core/index.ts +48 -48
  79. package/src/core/utils/function.ts +151 -151
  80. package/src/full.ts +223 -187
  81. package/src/motion/animate.ts +113 -113
  82. package/src/motion/flip.ts +176 -176
  83. package/src/motion/scroll.ts +57 -57
  84. package/src/motion/spring.ts +150 -150
  85. package/src/motion/timeline.ts +246 -246
  86. package/src/motion/transition.ts +53 -7
  87. package/src/motion/types.ts +208 -198
  88. package/src/platform/announcer.ts +208 -0
  89. package/src/platform/config.ts +163 -0
  90. package/src/platform/cookies.ts +165 -0
  91. package/src/platform/index.ts +39 -18
  92. package/src/platform/meta.ts +168 -0
  93. package/src/platform/storage.ts +215 -215
  94. package/src/reactive/async-data.ts +486 -0
  95. package/src/reactive/core.ts +114 -114
  96. package/src/reactive/effect.ts +54 -54
  97. package/src/reactive/index.ts +37 -23
  98. package/src/reactive/internals.ts +122 -122
  99. package/src/reactive/signal.ts +29 -20
  100. package/src/security/constants.ts +211 -209
  101. package/src/security/sanitize-core.ts +364 -364
  102. package/src/view/evaluate.ts +290 -290
  103. package/dist/batch-x7b2eZST.js +0 -13
  104. package/dist/batch-x7b2eZST.js.map +0 -1
  105. package/dist/component.es.mjs.map +0 -1
  106. package/dist/core-BhpuvPhy.js +0 -170
  107. package/dist/core-BhpuvPhy.js.map +0 -1
  108. package/dist/core.es.mjs.map +0 -1
  109. package/dist/full.es.mjs.map +0 -1
  110. package/dist/index.es.mjs.map +0 -1
  111. package/dist/motion.es.mjs.map +0 -1
  112. package/dist/persisted-DHoi3uEs.js +0 -278
  113. package/dist/persisted-DHoi3uEs.js.map +0 -1
  114. package/dist/platform.es.mjs.map +0 -1
  115. package/dist/reactive.es.mjs.map +0 -1
  116. package/dist/router.es.mjs.map +0 -1
  117. package/dist/sanitize-Cxvxa-DX.js +0 -283
  118. package/dist/sanitize-Cxvxa-DX.js.map +0 -1
  119. package/dist/security.es.mjs.map +0 -1
  120. package/dist/store.es.mjs.map +0 -1
  121. package/dist/type-guards-BdKlYYlS.js +0 -32
  122. package/dist/type-guards-BdKlYYlS.js.map +0 -1
  123. package/dist/untrack-DNnnqdlR.js +0 -6
  124. package/dist/untrack-DNnnqdlR.js.map +0 -1
  125. package/dist/view.es.mjs.map +0 -1
  126. package/dist/watch-DXXv3iAI.js +0 -58
  127. package/dist/watch-DXXv3iAI.js.map +0 -1
@@ -1,250 +1,13 @@
1
- class h {
2
- constructor(e) {
3
- this.bucketName = e, this.dbPromise = null, this.storeName = "blobs";
4
- }
5
- openDB() {
6
- if (this.dbPromise) return this.dbPromise;
7
- const e = `bquery-bucket-${this.bucketName}`;
8
- return this.dbPromise = new Promise((t, s) => {
9
- const n = indexedDB.open(e, 1);
10
- n.onupgradeneeded = () => {
11
- const i = n.result;
12
- i.objectStoreNames.contains(this.storeName) || i.createObjectStore(this.storeName);
13
- }, n.onsuccess = () => t(n.result), n.onerror = () => s(n.error);
14
- }), this.dbPromise;
15
- }
16
- async withStore(e, t) {
17
- const s = await this.openDB();
18
- return new Promise((n, i) => {
19
- const a = s.transaction(this.storeName, e).objectStore(this.storeName), o = t(a);
20
- o.onsuccess = () => n(o.result), o.onerror = () => i(o.error);
21
- });
22
- }
23
- async put(e, t) {
24
- await this.withStore("readwrite", (s) => s.put(t, e));
25
- }
26
- async get(e) {
27
- return await this.withStore("readonly", (s) => s.get(e)) ?? null;
28
- }
29
- async remove(e) {
30
- await this.withStore("readwrite", (t) => t.delete(e));
31
- }
32
- async keys() {
33
- return (await this.withStore("readonly", (t) => t.getAllKeys())).map((t) => String(t));
34
- }
35
- }
36
- const y = {
37
- /**
38
- * Open or create a storage bucket.
39
- * @param name - Bucket name
40
- * @returns Bucket instance for blob operations
41
- */
42
- async open(r) {
43
- return new h(r);
44
- }
45
- };
46
- class d {
47
- constructor(e) {
48
- this.cache = e;
49
- }
50
- async add(e) {
51
- await this.cache.add(e);
52
- }
53
- async addAll(e) {
54
- await this.cache.addAll(e);
55
- }
56
- async put(e, t) {
57
- await this.cache.put(e, t);
58
- }
59
- async match(e) {
60
- return this.cache.match(e);
61
- }
62
- async remove(e) {
63
- return this.cache.delete(e);
64
- }
65
- async keys() {
66
- return (await this.cache.keys()).map((t) => t.url);
67
- }
68
- }
69
- const m = {
70
- /**
71
- * Check if Cache Storage API is supported.
72
- * @returns True if caches API is available
73
- */
74
- isSupported() {
75
- return "caches" in window;
76
- },
77
- /**
78
- * Open or create a named cache.
79
- * @param name - Cache name
80
- * @returns CacheHandle for cache operations
81
- */
82
- async open(r) {
83
- if (!this.isSupported())
84
- throw new Error("bQuery: Cache Storage API not supported");
85
- const e = await caches.open(r);
86
- return new d(e);
87
- },
88
- /**
89
- * Delete a named cache.
90
- * @param name - Cache name to delete
91
- * @returns True if the cache was deleted
92
- */
93
- async delete(r) {
94
- return this.isSupported() ? caches.delete(r) : !1;
95
- },
96
- /**
97
- * List all cache names.
98
- * @returns Array of cache names
99
- */
100
- async keys() {
101
- return this.isSupported() ? caches.keys() : [];
102
- }
103
- }, S = {
104
- /**
105
- * Check if notifications are supported.
106
- * @returns True if Notification API is available
107
- */
108
- isSupported() {
109
- return "Notification" in window;
110
- },
111
- /**
112
- * Get current permission status.
113
- * @returns Current permission state
114
- */
115
- getPermission() {
116
- return this.isSupported() ? Notification.permission : "denied";
117
- },
118
- /**
119
- * Request notification permission from the user.
120
- * @returns Promise resolving to the permission result
121
- */
122
- async requestPermission() {
123
- return this.isSupported() ? Notification.permission === "granted" ? "granted" : Notification.permission === "denied" ? "denied" : Notification.requestPermission() : "denied";
124
- },
125
- /**
126
- * Send a notification.
127
- * Requires 'granted' permission.
128
- * @param title - Notification title
129
- * @param options - Optional notification settings
130
- * @returns The Notification instance or null if not permitted
131
- */
132
- send(r, e) {
133
- return this.isSupported() ? Notification.permission !== "granted" ? (console.warn("bQuery: Notification permission not granted"), null) : new Notification(r, e) : (console.warn("bQuery: Notifications not supported in this browser"), null);
134
- }
135
- };
136
- class c {
137
- constructor(e) {
138
- this.storage = e;
139
- }
140
- async get(e) {
141
- const t = this.storage.getItem(e);
142
- if (t === null) return null;
143
- try {
144
- return JSON.parse(t);
145
- } catch {
146
- return t;
147
- }
148
- }
149
- async set(e, t) {
150
- const s = typeof t == "string" ? t : JSON.stringify(t);
151
- this.storage.setItem(e, s);
152
- }
153
- async remove(e) {
154
- this.storage.removeItem(e);
155
- }
156
- async clear() {
157
- this.storage.clear();
158
- }
159
- async keys() {
160
- const e = [];
161
- for (let t = 0; t < this.storage.length; t++) {
162
- const s = this.storage.key(t);
163
- s !== null && e.push(s);
164
- }
165
- return e;
166
- }
167
- }
168
- class l extends c {
169
- constructor() {
170
- super(localStorage);
171
- }
172
- }
173
- class p extends c {
174
- constructor() {
175
- super(sessionStorage);
176
- }
177
- }
178
- class w {
179
- constructor(e) {
180
- this.options = e, this.dbPromise = null;
181
- }
182
- /**
183
- * Opens or creates the IndexedDB database.
184
- */
185
- openDB() {
186
- return this.dbPromise ? this.dbPromise : (this.dbPromise = new Promise((e, t) => {
187
- const s = indexedDB.open(this.options.name, this.options.version ?? 1);
188
- s.onupgradeneeded = () => {
189
- const n = s.result;
190
- n.objectStoreNames.contains(this.options.store) || n.createObjectStore(this.options.store);
191
- }, s.onsuccess = () => e(s.result), s.onerror = () => t(s.error);
192
- }), this.dbPromise);
193
- }
194
- /**
195
- * Executes a transaction on the object store.
196
- */
197
- async withStore(e, t) {
198
- const s = await this.openDB();
199
- return new Promise((n, i) => {
200
- const a = s.transaction(this.options.store, e).objectStore(this.options.store), o = t(a);
201
- o.onsuccess = () => n(o.result), o.onerror = () => i(o.error);
202
- });
203
- }
204
- async get(e) {
205
- return await this.withStore("readonly", (s) => s.get(e)) ?? null;
206
- }
207
- async set(e, t) {
208
- await this.withStore("readwrite", (s) => s.put(t, e));
209
- }
210
- async remove(e) {
211
- await this.withStore("readwrite", (t) => t.delete(e));
212
- }
213
- async clear() {
214
- await this.withStore("readwrite", (e) => e.clear());
215
- }
216
- async keys() {
217
- return (await this.withStore("readonly", (t) => t.getAllKeys())).map((t) => String(t));
218
- }
219
- }
220
- const g = {
221
- /**
222
- * Create a localStorage adapter.
223
- * @returns StorageAdapter wrapping localStorage
224
- */
225
- local() {
226
- return new l();
227
- },
228
- /**
229
- * Create a sessionStorage adapter.
230
- * @returns StorageAdapter wrapping sessionStorage
231
- */
232
- session() {
233
- return new p();
234
- },
235
- /**
236
- * Create an IndexedDB adapter with key-value interface.
237
- * @param options - Database and store configuration
238
- * @returns StorageAdapter wrapping IndexedDB
239
- */
240
- indexedDB(r) {
241
- return new w(r);
242
- }
243
- };
1
+ import { n as a, t as s } from "./config-DRmZZno3.js";
2
+ import { a as i, i as n, n as t, o as r, r as f, s as u, t as c } from "./platform-B7JhGBc7.js";
244
3
  export {
245
- y as buckets,
246
- m as cache,
247
- S as notifications,
248
- g as storage
4
+ u as buckets,
5
+ r as cache,
6
+ s as defineBqueryConfig,
7
+ t as definePageMeta,
8
+ a as getBqueryConfig,
9
+ n as notifications,
10
+ c as storage,
11
+ f as useAnnouncer,
12
+ i as useCookie
249
13
  };
250
- //# sourceMappingURL=platform.es.mjs.map
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Async data and fetch composables built on bQuery signals.
3
+ *
4
+ * @module bquery/reactive
5
+ */
6
+ import { type BqueryFetchParseAs } from '../platform/config';
7
+ import { Signal } from './core';
8
+ /** Allowed status values for async composables. */
9
+ export type AsyncDataStatus = 'idle' | 'pending' | 'success' | 'error';
10
+ /** Reactive source types that can trigger refreshes. */
11
+ export type AsyncWatchSource = (() => unknown) | {
12
+ value: unknown;
13
+ };
14
+ /** Options shared by async composables. */
15
+ export interface UseAsyncDataOptions<TResult, TData = TResult> {
16
+ /** Run the handler immediately (default: true). */
17
+ immediate?: boolean;
18
+ /** Default data value before the first successful execution. */
19
+ defaultValue?: TData;
20
+ /** Optional reactive sources that trigger refreshes when they change. */
21
+ watch?: AsyncWatchSource[];
22
+ /** Transform the resolved value before storing it. */
23
+ transform?: (value: TResult) => TData;
24
+ /** Called after a successful execution. */
25
+ onSuccess?: (value: TData) => void;
26
+ /** Called after a failed execution. */
27
+ onError?: (error: Error) => void;
28
+ }
29
+ /** Return value of useAsyncData() and useFetch(). */
30
+ export interface AsyncDataState<TData> {
31
+ /** Reactive data signal. */
32
+ data: Signal<TData | undefined>;
33
+ /** Last error encountered by the composable. */
34
+ error: Signal<Error | null>;
35
+ /** Current lifecycle status. */
36
+ status: Signal<AsyncDataStatus>;
37
+ /** Computed boolean that mirrors `status === 'pending'`. */
38
+ pending: {
39
+ readonly value: boolean;
40
+ peek(): boolean;
41
+ };
42
+ /** Execute the handler manually. Returns the cached data value when called after dispose(). */
43
+ execute: () => Promise<TData | undefined>;
44
+ /** Alias for execute(). */
45
+ refresh: () => Promise<TData | undefined>;
46
+ /** Clear data, error, and status back to the initial state. */
47
+ clear: () => void;
48
+ /** Dispose reactive watchers and prevent future executions. */
49
+ dispose: () => void;
50
+ }
51
+ /** Options for useFetch(). */
52
+ export interface UseFetchOptions<TResponse = unknown, TData = TResponse> extends UseAsyncDataOptions<TResponse, TData>, Omit<RequestInit, 'body' | 'headers'> {
53
+ /** Base URL prepended to relative URLs. */
54
+ baseUrl?: string;
55
+ /** Query parameters appended to the request URL. */
56
+ query?: Record<string, unknown>;
57
+ /** Request headers. */
58
+ headers?: HeadersInit;
59
+ /** Request body, including plain objects for JSON requests. */
60
+ body?: BodyInit | Record<string, unknown> | unknown[] | null;
61
+ /** Override the parser used for the response body. */
62
+ parseAs?: BqueryFetchParseAs;
63
+ /** Custom fetch implementation for testing or adapters. */
64
+ fetcher?: typeof fetch;
65
+ }
66
+ /** Input accepted by useFetch(). */
67
+ export type FetchInput = string | URL | Request | (() => string | URL | Request);
68
+ /**
69
+ * Create a reactive wrapper around an async resolver.
70
+ *
71
+ * @template TResult - Raw result type returned by the handler
72
+ * @template TData - Stored data type after optional transformation
73
+ * @param handler - Async function to execute
74
+ * @param options - Execution, transform, and refresh options
75
+ * @returns Reactive data state with execute(), refresh(), and clear()
76
+ *
77
+ * @example
78
+ * ```ts
79
+ * const user = useAsyncData(() => fetch('/api/user').then((res) => res.json()));
80
+ * ```
81
+ */
82
+ export declare const useAsyncData: <TResult, TData = TResult>(handler: () => Promise<TResult>, options?: UseAsyncDataOptions<TResult, TData>) => AsyncDataState<TData>;
83
+ /**
84
+ * Reactive fetch composable using the browser Fetch API.
85
+ *
86
+ * @template TResponse - Raw parsed response type
87
+ * @template TData - Stored response type after optional transformation
88
+ * @param input - Request URL, Request object, or lazy input factory
89
+ * @param options - Request and reactive state options
90
+ * @returns Reactive fetch state with execute(), refresh(), and clear()
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * const users = useFetch<{ id: number; name: string }[]>('/api/users');
95
+ * ```
96
+ */
97
+ export declare const useFetch: <TResponse = unknown, TData = TResponse>(input: FetchInput, options?: UseFetchOptions<TResponse, TData>) => AsyncDataState<TData>;
98
+ /**
99
+ * Create a preconfigured useFetch() helper.
100
+ *
101
+ * @param defaults - Default request options merged into every useFetch() call
102
+ * @returns A useFetch-compatible function with merged defaults
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const useApiFetch = createUseFetch({ baseUrl: 'https://api.example.com' });
107
+ * const profile = useApiFetch('/profile');
108
+ * ```
109
+ */
110
+ /** Overload for factories without a configured transform, preserving per-call `TResponse -> TData` inference. */
111
+ export declare function createUseFetch<TDefaultResponse = unknown>(defaults?: UseFetchOptions<TDefaultResponse, TDefaultResponse>): <TResponse = TDefaultResponse, TData = TResponse>(input: FetchInput, options?: UseFetchOptions<TResponse, TData>) => AsyncDataState<TData>;
112
+ /** Overload for factories with a configured transform, preserving the transformed factory data type by default. */
113
+ export declare function createUseFetch<TDefaultResponse = unknown, TDefaultData = TDefaultResponse>(defaults: UseFetchOptions<TDefaultResponse, TDefaultData>): <TResponse = TDefaultResponse, TData = TDefaultData>(input: FetchInput, options?: UseFetchOptions<TResponse, TData>) => AsyncDataState<TData>;
114
+ //# sourceMappingURL=async-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-data.d.ts","sourceRoot":"","sources":["../../src/reactive/async-data.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAmB,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAG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KAAK,GAAG,SAAS,EAC7D,OAAO,UAAU,EACjB,UAAS,eAAe,CAAC,SAAS,EAAE,KAAK,CAAM,KAC9C,cAAc,CAAC,KAAK,CAuEtB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,gBAAgB,GAAG,OAAO,EACvD,QAAQ,CAAC,EAAE,eAAe,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,GAC7D,CAAC,SAAS,GAAG,gBAAgB,EAAE,KAAK,GAAG,SAAS,EACjD,KAAK,EAAE,UAAU,EACjB,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,KACxC,cAAc,CAAC,KAAK,CAAC,CAAC;AAE3B,mHAAmH;AACnH,wBAAgB,cAAc,CAAC,gBAAgB,GAAG,OAAO,EAAE,YAAY,GAAG,gBAAgB,EACxF,QAAQ,EAAE,eAAe,CAAC,gBAAgB,EAAE,YAAY,CAAC,GACxD,CAAC,SAAS,GAAG,gBAAgB,EAAE,KAAK,GAAG,YAAY,EACpD,KAAK,EAAE,UAAU,EACjB,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,EAAE,KAAK,CAAC,KACxC,cAAc,CAAC,KAAK,CAAC,CAAC"}
@@ -3,6 +3,6 @@
3
3
  *
4
4
  * @module bquery/reactive
5
5
  */
6
- export { Computed, Signal, batch, computed, effect, isComputed, isSignal, linkedSignal, persistedSignal, readonly, signal, untrack, watch, } from './signal';
7
- export type { CleanupFn, LinkedSignal, Observer, ReadonlySignal } from './signal';
6
+ export { Computed, Signal, batch, computed, createUseFetch, effect, isComputed, isSignal, linkedSignal, persistedSignal, readonly, signal, useAsyncData, useFetch, untrack, watch, } from './signal';
7
+ export type { AsyncDataState, AsyncDataStatus, AsyncWatchSource, CleanupFn, FetchInput, LinkedSignal, Observer, ReadonlySignal, UseAsyncDataOptions, UseFetchOptions, } from './signal';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reactive/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,MAAM,EACN,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,MAAM,EACN,OAAO,EACP,KAAK,GACN,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/reactive/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,QAAQ,EACR,MAAM,EACN,KAAK,EACL,QAAQ,EACR,cAAc,EACd,MAAM,EACN,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,KAAK,GACN,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,eAAe,GAChB,MAAM,UAAU,CAAC"}
@@ -4,6 +4,7 @@
4
4
  * @module bquery/reactive
5
5
  */
6
6
  export { batch } from './batch';
7
+ export { createUseFetch, useAsyncData, useFetch } from './async-data';
7
8
  export { Computed, computed } from './computed';
8
9
  export { Signal, signal } from './core';
9
10
  export { effect } from './effect';
@@ -14,6 +15,7 @@ export { isComputed, isSignal } from './type-guards';
14
15
  export { untrack } from './untrack';
15
16
  export { watch } from './watch';
16
17
  export type { CleanupFn, Observer } from './internals';
18
+ export type { AsyncDataState, AsyncDataStatus, AsyncWatchSource, FetchInput, UseAsyncDataOptions, UseFetchOptions, } from './async-data';
17
19
  export type { LinkedSignal } from './linked';
18
20
  export type { ReadonlySignal } from './readonly';
19
21
  //# sourceMappingURL=signal.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/reactive/signal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/reactive/signal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvD,YAAY,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,mBAAmB,EACnB,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,253 @@
1
+ import { i as q } from "./object-qGpWr6-J.js";
2
+ import { a as b, c as D, d as O, i as U, l as B, n as v, o as I, r as g, s as V, t as x, u as S } from "./core-DPdbItcq.js";
3
+ import { n as _ } from "./config-DRmZZno3.js";
4
+ var K = (e) => {
5
+ U();
6
+ try {
7
+ e();
8
+ } finally {
9
+ I();
10
+ }
11
+ }, k = class {
12
+ constructor(e) {
13
+ this.compute = e, this.dirty = !0, this.subscribers = /* @__PURE__ */ new Set(), this.markDirty = () => {
14
+ this.dirty = !0;
15
+ const t = Array.from(this.subscribers);
16
+ for (const a of t) B(a);
17
+ };
18
+ }
19
+ get value() {
20
+ const e = V();
21
+ return e && (this.subscribers.add(e), D(e, this)), this.dirty && (this.dirty = !1, b(this.markDirty), this.cachedValue = S(this.markDirty, this.compute)), this.cachedValue;
22
+ }
23
+ peek() {
24
+ return this.dirty && (this.dirty = !1, b(this.markDirty), this.cachedValue = S(this.markDirty, this.compute)), this.cachedValue;
25
+ }
26
+ unsubscribe(e) {
27
+ this.subscribers.delete(e);
28
+ }
29
+ }, R = (e) => new k(e), p = (e) => O(e), A = (e) => {
30
+ if (e instanceof Error) return e;
31
+ if (typeof e == "string") return new Error(e);
32
+ try {
33
+ return new Error(JSON.stringify(e));
34
+ } catch {
35
+ return new Error(String(e));
36
+ }
37
+ }, L = (e) => typeof e == "function" ? e() : e.value, E = (...e) => {
38
+ const t = new Headers();
39
+ for (const a of e)
40
+ a && new Headers(a).forEach((r, n) => {
41
+ t.set(n, r);
42
+ });
43
+ return t;
44
+ }, C = (e) => typeof e == "string" || e instanceof Blob || e instanceof FormData || e instanceof URLSearchParams || typeof ArrayBuffer < "u" && e instanceof ArrayBuffer || typeof ReadableStream < "u" && e instanceof ReadableStream ? !0 : typeof e == "object" && e !== null && ArrayBuffer.isView(e), M = (e, t) => e == null || C(e) ? e : (t.has("content-type") || t.set("content-type", "application/json"), JSON.stringify(e)), j = (e) => typeof e == "function" ? e() : e, P = (e, t) => {
45
+ for (const [a, r] of Object.entries(t))
46
+ if (r != null) {
47
+ if (Array.isArray(r)) {
48
+ for (const n of r) n != null && e.searchParams.append(a, String(n));
49
+ continue;
50
+ }
51
+ e.searchParams.set(a, String(r));
52
+ }
53
+ }, T = (e, t) => {
54
+ const a = typeof window < "u" && /^https?:/i.test(window.location.href) ? window.location.href : "http://localhost", r = t ? new URL(t, a).toString() : a;
55
+ return e instanceof URL ? new URL(e.toString(), r) : new URL(e, r);
56
+ }, $ = async (e, t) => {
57
+ if (t === "response") return e;
58
+ if (t === "text") return await e.text();
59
+ if (t === "blob") return await e.blob();
60
+ if (t === "arrayBuffer") return await e.arrayBuffer();
61
+ if (t === "formData") return await e.formData();
62
+ const a = await e.text();
63
+ if (a)
64
+ try {
65
+ return JSON.parse(a);
66
+ } catch (r) {
67
+ const n = e.url ? ` for ${e.url}` : "";
68
+ throw new Error(`Failed to parse JSON response${n} (status ${e.status}): ${r instanceof Error ? r.message : String(r)}`);
69
+ }
70
+ }, w = (e) => {
71
+ const t = e?.trim();
72
+ return t ? t.toUpperCase() : void 0;
73
+ }, z = (e, t, a) => {
74
+ const r = t instanceof Request ? w(t.method) : void 0;
75
+ return e ?? r ?? (a ? "POST" : void 0);
76
+ }, J = (e, t, a) => e || (t instanceof Request ? void 0 : a), N = (e) => {
77
+ const t = w(e.method);
78
+ let a;
79
+ if (t !== "GET" && t !== "HEAD" && !e.bodyUsed) try {
80
+ a = e.clone().body ?? void 0;
81
+ } catch {
82
+ a = void 0;
83
+ }
84
+ return {
85
+ method: t,
86
+ headers: e.headers,
87
+ body: a,
88
+ cache: e.cache,
89
+ credentials: e.credentials,
90
+ integrity: e.integrity,
91
+ keepalive: e.keepalive,
92
+ mode: e.mode,
93
+ redirect: e.redirect,
94
+ referrer: e.referrer,
95
+ referrerPolicy: e.referrerPolicy,
96
+ signal: e.signal
97
+ };
98
+ }, F = (e, t = {}) => {
99
+ const a = t.immediate ?? !0, r = v(t.defaultValue), n = v(null), s = v("idle"), i = R(() => s.value === "pending");
100
+ let c = 0, f = !1, y = () => {
101
+ };
102
+ const h = () => {
103
+ c += 1, r.value = t.defaultValue, n.value = null, s.value = "idle";
104
+ }, m = () => {
105
+ f || (f = !0, c += 1, y());
106
+ }, d = async () => {
107
+ if (f) return r.peek();
108
+ const o = ++c;
109
+ s.value = "pending", n.value = null;
110
+ try {
111
+ const l = await e(), u = t.transform ? t.transform(l) : l;
112
+ return f || o !== c ? r.peek() : (r.value = u, s.value = "success", t.onSuccess?.(u), u);
113
+ } catch (l) {
114
+ const u = A(l);
115
+ return f || o !== c || (n.value = u, s.value = "error", t.onError?.(u)), r.peek();
116
+ }
117
+ };
118
+ if (t.watch?.length) {
119
+ let o = !1;
120
+ y = g(() => {
121
+ for (const l of t.watch ?? []) L(l);
122
+ if (!o) {
123
+ o = !0, a && p(() => d());
124
+ return;
125
+ }
126
+ p(() => d());
127
+ });
128
+ } else a && d();
129
+ return {
130
+ data: r,
131
+ error: n,
132
+ status: s,
133
+ pending: i,
134
+ execute: d,
135
+ refresh: d,
136
+ clear: h,
137
+ dispose: m
138
+ };
139
+ }, H = (e, t = {}) => {
140
+ const a = _().fetch, r = t.parseAs ?? a?.parseAs ?? "json", n = t.fetcher ?? fetch;
141
+ return F(async () => {
142
+ const s = j(e), i = typeof s == "string" || s instanceof URL ? T(s, t.baseUrl ?? a?.baseUrl) : s instanceof Request && t.query ? new URL(s.url) : null;
143
+ i && t.query && P(i, t.query);
144
+ const c = E(a?.headers, s instanceof Request ? s.headers : void 0, t.headers), f = t.body != null, y = w(t.method), h = z(y, s, f), m = h === "GET" || h === "HEAD" ? h : null;
145
+ if (f && m) throw new Error(`Cannot send a request body with ${m} requests`);
146
+ const d = J(y, s, h), o = {
147
+ ...t,
148
+ method: d,
149
+ headers: c,
150
+ body: M(t.body, c)
151
+ };
152
+ delete o.baseUrl, delete o.query, delete o.parseAs, delete o.fetcher, delete o.defaultValue, delete o.immediate, delete o.watch, delete o.transform, delete o.onSuccess, delete o.onError;
153
+ let l = i ?? s;
154
+ s instanceof Request && i && i.toString() !== s.url && (l = new Request(i.toString(), N(s)));
155
+ const u = await n(l, o);
156
+ if (!u.ok) throw Object.assign(/* @__PURE__ */ new Error(`Request failed with status ${u.status}`), {
157
+ response: u,
158
+ status: u.status,
159
+ statusText: u.statusText
160
+ });
161
+ return $(u, r);
162
+ }, t);
163
+ };
164
+ function X(e = {}) {
165
+ return (t, a = {}) => {
166
+ const r = e, n = q({}, r.query ?? {}, a.query ?? {});
167
+ return H(t, {
168
+ ...r,
169
+ ...a,
170
+ headers: E(r.headers, a.headers),
171
+ query: Object.keys(n).length > 0 ? n : void 0
172
+ });
173
+ };
174
+ }
175
+ var Y = (e, t) => {
176
+ const a = R(e);
177
+ return {
178
+ get value() {
179
+ return a.value;
180
+ },
181
+ set value(r) {
182
+ t(r);
183
+ },
184
+ peek() {
185
+ return a.peek();
186
+ }
187
+ };
188
+ }, Z = (e, t) => {
189
+ let a = !1, r = null;
190
+ try {
191
+ if (r = globalThis.localStorage, r) {
192
+ const i = `__bquery_test_${Math.random().toString(36).slice(2, 9)}__`, c = "__test__";
193
+ try {
194
+ r.setItem(i, c), r.getItem(i), a = !0;
195
+ } finally {
196
+ try {
197
+ r.removeItem(i);
198
+ } catch {
199
+ }
200
+ }
201
+ }
202
+ } catch {
203
+ a = !1;
204
+ }
205
+ let n = t;
206
+ if (a && r) try {
207
+ const i = r.getItem(e);
208
+ i !== null && (n = JSON.parse(i));
209
+ } catch {
210
+ }
211
+ const s = v(n);
212
+ return a && r && g(() => {
213
+ try {
214
+ r.setItem(e, JSON.stringify(s.value));
215
+ } catch {
216
+ }
217
+ }), s;
218
+ }, ee = (e) => ({
219
+ get value() {
220
+ return e.value;
221
+ },
222
+ peek() {
223
+ return e.peek();
224
+ }
225
+ }), te = (e) => e instanceof x, re = (e) => e instanceof k, ae = (e, t, a = {}) => {
226
+ const { immediate: r = !1, equals: n = Object.is } = a;
227
+ let s, i = !0;
228
+ return g(() => {
229
+ const c = e.value;
230
+ if (i) {
231
+ i = !1, s = c, r && t(c, void 0);
232
+ return;
233
+ }
234
+ n(c, s) || (t(c, s), s = c);
235
+ });
236
+ };
237
+ export {
238
+ Z as a,
239
+ F as c,
240
+ k as d,
241
+ R as f,
242
+ ee as i,
243
+ H as l,
244
+ re as n,
245
+ Y as o,
246
+ K as p,
247
+ te as r,
248
+ X as s,
249
+ ae as t,
250
+ p as u
251
+ };
252
+
253
+ //# sourceMappingURL=reactive-BDya-ia8.js.map