@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,215 +1,215 @@
1
- /**
2
- * Unified storage adapters for web platform storage APIs.
3
- * Provides a consistent, promise-based interface with predictable errors.
4
- */
5
-
6
- /**
7
- * Common interface for all storage adapters.
8
- * All methods return promises for a unified async API.
9
- */
10
- export interface StorageAdapter {
11
- /**
12
- * Retrieve a value by key.
13
- * @param key - The storage key
14
- * @returns The stored value or null if not found
15
- */
16
- get<T>(key: string): Promise<T | null>;
17
-
18
- /**
19
- * Store a value by key.
20
- * @param key - The storage key
21
- * @param value - The value to store
22
- */
23
- set<T>(key: string, value: T): Promise<void>;
24
-
25
- /**
26
- * Remove a value by key.
27
- * @param key - The storage key
28
- */
29
- remove(key: string): Promise<void>;
30
-
31
- /**
32
- * Clear all stored values.
33
- */
34
- clear(): Promise<void>;
35
-
36
- /**
37
- * Get all storage keys.
38
- * @returns Array of all keys
39
- */
40
- keys(): Promise<string[]>;
41
- }
42
-
43
- /**
44
- * Abstract base class for web storage adapters (localStorage/sessionStorage).
45
- * Implements DRY principle by sharing common logic.
46
- */
47
- abstract class WebStorageAdapter implements StorageAdapter {
48
- constructor(protected readonly storage: Storage) {}
49
-
50
- async get<T>(key: string): Promise<T | null> {
51
- const raw = this.storage.getItem(key);
52
- if (raw === null) return null;
53
- try {
54
- return JSON.parse(raw) as T;
55
- } catch {
56
- return raw as unknown as T;
57
- }
58
- }
59
-
60
- async set<T>(key: string, value: T): Promise<void> {
61
- const serialized = typeof value === 'string' ? value : JSON.stringify(value);
62
- this.storage.setItem(key, serialized);
63
- }
64
-
65
- async remove(key: string): Promise<void> {
66
- this.storage.removeItem(key);
67
- }
68
-
69
- async clear(): Promise<void> {
70
- this.storage.clear();
71
- }
72
-
73
- async keys(): Promise<string[]> {
74
- const result: string[] = [];
75
- for (let i = 0; i < this.storage.length; i++) {
76
- const key = this.storage.key(i);
77
- if (key !== null) {
78
- result.push(key);
79
- }
80
- }
81
- return result;
82
- }
83
- }
84
-
85
- /**
86
- * localStorage adapter with async interface.
87
- */
88
- class LocalStorageAdapter extends WebStorageAdapter {
89
- constructor() {
90
- super(localStorage);
91
- }
92
- }
93
-
94
- /**
95
- * sessionStorage adapter with async interface.
96
- */
97
- class SessionStorageAdapter extends WebStorageAdapter {
98
- constructor() {
99
- super(sessionStorage);
100
- }
101
- }
102
-
103
- /**
104
- * IndexedDB configuration options.
105
- */
106
- export interface IndexedDBOptions {
107
- /** Database name */
108
- name: string;
109
- /** Object store name */
110
- store: string;
111
- /** Database version (optional) */
112
- version?: number;
113
- }
114
-
115
- /**
116
- * IndexedDB key-value adapter.
117
- * Wraps IndexedDB with a simple key-value interface.
118
- */
119
- class IndexedDBAdapter implements StorageAdapter {
120
- private dbPromise: Promise<IDBDatabase> | null = null;
121
-
122
- constructor(private readonly options: IndexedDBOptions) {}
123
-
124
- /**
125
- * Opens or creates the IndexedDB database.
126
- */
127
- private openDB(): Promise<IDBDatabase> {
128
- if (this.dbPromise) return this.dbPromise;
129
-
130
- this.dbPromise = new Promise((resolve, reject) => {
131
- const request = indexedDB.open(this.options.name, this.options.version ?? 1);
132
-
133
- request.onupgradeneeded = () => {
134
- const db = request.result;
135
- if (!db.objectStoreNames.contains(this.options.store)) {
136
- db.createObjectStore(this.options.store);
137
- }
138
- };
139
-
140
- request.onsuccess = () => resolve(request.result);
141
- request.onerror = () => reject(request.error);
142
- });
143
-
144
- return this.dbPromise;
145
- }
146
-
147
- /**
148
- * Executes a transaction on the object store.
149
- */
150
- private async withStore<T>(
151
- mode: IDBTransactionMode,
152
- operation: (store: IDBObjectStore) => IDBRequest<T>
153
- ): Promise<T> {
154
- const db = await this.openDB();
155
- return new Promise((resolve, reject) => {
156
- const tx = db.transaction(this.options.store, mode);
157
- const store = tx.objectStore(this.options.store);
158
- const request = operation(store);
159
- request.onsuccess = () => resolve(request.result);
160
- request.onerror = () => reject(request.error);
161
- });
162
- }
163
-
164
- async get<T>(key: string): Promise<T | null> {
165
- const result = await this.withStore<T | undefined>('readonly', (store) => store.get(key));
166
- return result ?? null;
167
- }
168
-
169
- async set<T>(key: string, value: T): Promise<void> {
170
- await this.withStore('readwrite', (store) => store.put(value, key));
171
- }
172
-
173
- async remove(key: string): Promise<void> {
174
- await this.withStore('readwrite', (store) => store.delete(key));
175
- }
176
-
177
- async clear(): Promise<void> {
178
- await this.withStore('readwrite', (store) => store.clear());
179
- }
180
-
181
- async keys(): Promise<string[]> {
182
- const result = await this.withStore<IDBValidKey[]>('readonly', (store) => store.getAllKeys());
183
- return result.map((key) => String(key));
184
- }
185
- }
186
-
187
- /**
188
- * Storage factory providing access to different storage adapters.
189
- */
190
- export const storage = {
191
- /**
192
- * Create a localStorage adapter.
193
- * @returns StorageAdapter wrapping localStorage
194
- */
195
- local(): StorageAdapter {
196
- return new LocalStorageAdapter();
197
- },
198
-
199
- /**
200
- * Create a sessionStorage adapter.
201
- * @returns StorageAdapter wrapping sessionStorage
202
- */
203
- session(): StorageAdapter {
204
- return new SessionStorageAdapter();
205
- },
206
-
207
- /**
208
- * Create an IndexedDB adapter with key-value interface.
209
- * @param options - Database and store configuration
210
- * @returns StorageAdapter wrapping IndexedDB
211
- */
212
- indexedDB(options: IndexedDBOptions): StorageAdapter {
213
- return new IndexedDBAdapter(options);
214
- },
215
- };
1
+ /**
2
+ * Unified storage adapters for web platform storage APIs.
3
+ * Provides a consistent, promise-based interface with predictable errors.
4
+ */
5
+
6
+ /**
7
+ * Common interface for all storage adapters.
8
+ * All methods return promises for a unified async API.
9
+ */
10
+ export interface StorageAdapter {
11
+ /**
12
+ * Retrieve a value by key.
13
+ * @param key - The storage key
14
+ * @returns The stored value or null if not found
15
+ */
16
+ get<T>(key: string): Promise<T | null>;
17
+
18
+ /**
19
+ * Store a value by key.
20
+ * @param key - The storage key
21
+ * @param value - The value to store
22
+ */
23
+ set<T>(key: string, value: T): Promise<void>;
24
+
25
+ /**
26
+ * Remove a value by key.
27
+ * @param key - The storage key
28
+ */
29
+ remove(key: string): Promise<void>;
30
+
31
+ /**
32
+ * Clear all stored values.
33
+ */
34
+ clear(): Promise<void>;
35
+
36
+ /**
37
+ * Get all storage keys.
38
+ * @returns Array of all keys
39
+ */
40
+ keys(): Promise<string[]>;
41
+ }
42
+
43
+ /**
44
+ * Abstract base class for web storage adapters (localStorage/sessionStorage).
45
+ * Implements DRY principle by sharing common logic.
46
+ */
47
+ abstract class WebStorageAdapter implements StorageAdapter {
48
+ constructor(protected readonly storage: Storage) {}
49
+
50
+ async get<T>(key: string): Promise<T | null> {
51
+ const raw = this.storage.getItem(key);
52
+ if (raw === null) return null;
53
+ try {
54
+ return JSON.parse(raw) as T;
55
+ } catch {
56
+ return raw as unknown as T;
57
+ }
58
+ }
59
+
60
+ async set<T>(key: string, value: T): Promise<void> {
61
+ const serialized = typeof value === 'string' ? value : JSON.stringify(value);
62
+ this.storage.setItem(key, serialized);
63
+ }
64
+
65
+ async remove(key: string): Promise<void> {
66
+ this.storage.removeItem(key);
67
+ }
68
+
69
+ async clear(): Promise<void> {
70
+ this.storage.clear();
71
+ }
72
+
73
+ async keys(): Promise<string[]> {
74
+ const result: string[] = [];
75
+ for (let i = 0; i < this.storage.length; i++) {
76
+ const key = this.storage.key(i);
77
+ if (key !== null) {
78
+ result.push(key);
79
+ }
80
+ }
81
+ return result;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * localStorage adapter with async interface.
87
+ */
88
+ class LocalStorageAdapter extends WebStorageAdapter {
89
+ constructor() {
90
+ super(localStorage);
91
+ }
92
+ }
93
+
94
+ /**
95
+ * sessionStorage adapter with async interface.
96
+ */
97
+ class SessionStorageAdapter extends WebStorageAdapter {
98
+ constructor() {
99
+ super(sessionStorage);
100
+ }
101
+ }
102
+
103
+ /**
104
+ * IndexedDB configuration options.
105
+ */
106
+ export interface IndexedDBOptions {
107
+ /** Database name */
108
+ name: string;
109
+ /** Object store name */
110
+ store: string;
111
+ /** Database version (optional) */
112
+ version?: number;
113
+ }
114
+
115
+ /**
116
+ * IndexedDB key-value adapter.
117
+ * Wraps IndexedDB with a simple key-value interface.
118
+ */
119
+ class IndexedDBAdapter implements StorageAdapter {
120
+ private dbPromise: Promise<IDBDatabase> | null = null;
121
+
122
+ constructor(private readonly options: IndexedDBOptions) {}
123
+
124
+ /**
125
+ * Opens or creates the IndexedDB database.
126
+ */
127
+ private openDB(): Promise<IDBDatabase> {
128
+ if (this.dbPromise) return this.dbPromise;
129
+
130
+ this.dbPromise = new Promise((resolve, reject) => {
131
+ const request = indexedDB.open(this.options.name, this.options.version ?? 1);
132
+
133
+ request.onupgradeneeded = () => {
134
+ const db = request.result;
135
+ if (!db.objectStoreNames.contains(this.options.store)) {
136
+ db.createObjectStore(this.options.store);
137
+ }
138
+ };
139
+
140
+ request.onsuccess = () => resolve(request.result);
141
+ request.onerror = () => reject(request.error);
142
+ });
143
+
144
+ return this.dbPromise;
145
+ }
146
+
147
+ /**
148
+ * Executes a transaction on the object store.
149
+ */
150
+ private async withStore<T>(
151
+ mode: IDBTransactionMode,
152
+ operation: (store: IDBObjectStore) => IDBRequest<T>
153
+ ): Promise<T> {
154
+ const db = await this.openDB();
155
+ return new Promise((resolve, reject) => {
156
+ const tx = db.transaction(this.options.store, mode);
157
+ const store = tx.objectStore(this.options.store);
158
+ const request = operation(store);
159
+ request.onsuccess = () => resolve(request.result);
160
+ request.onerror = () => reject(request.error);
161
+ });
162
+ }
163
+
164
+ async get<T>(key: string): Promise<T | null> {
165
+ const result = await this.withStore<T | undefined>('readonly', (store) => store.get(key));
166
+ return result ?? null;
167
+ }
168
+
169
+ async set<T>(key: string, value: T): Promise<void> {
170
+ await this.withStore('readwrite', (store) => store.put(value, key));
171
+ }
172
+
173
+ async remove(key: string): Promise<void> {
174
+ await this.withStore('readwrite', (store) => store.delete(key));
175
+ }
176
+
177
+ async clear(): Promise<void> {
178
+ await this.withStore('readwrite', (store) => store.clear());
179
+ }
180
+
181
+ async keys(): Promise<string[]> {
182
+ const result = await this.withStore<IDBValidKey[]>('readonly', (store) => store.getAllKeys());
183
+ return result.map((key) => String(key));
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Storage factory providing access to different storage adapters.
189
+ */
190
+ export const storage = {
191
+ /**
192
+ * Create a localStorage adapter.
193
+ * @returns StorageAdapter wrapping localStorage
194
+ */
195
+ local(): StorageAdapter {
196
+ return new LocalStorageAdapter();
197
+ },
198
+
199
+ /**
200
+ * Create a sessionStorage adapter.
201
+ * @returns StorageAdapter wrapping sessionStorage
202
+ */
203
+ session(): StorageAdapter {
204
+ return new SessionStorageAdapter();
205
+ },
206
+
207
+ /**
208
+ * Create an IndexedDB adapter with key-value interface.
209
+ * @param options - Database and store configuration
210
+ * @returns StorageAdapter wrapping IndexedDB
211
+ */
212
+ indexedDB(options: IndexedDBOptions): StorageAdapter {
213
+ return new IndexedDBAdapter(options);
214
+ },
215
+ };