@bquery/bquery 1.2.0 → 1.4.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 (309) hide show
  1. package/README.md +127 -27
  2. package/dist/batch-x7b2eZST.js +13 -0
  3. package/dist/batch-x7b2eZST.js.map +1 -0
  4. package/dist/component/component.d.ts +69 -0
  5. package/dist/component/component.d.ts.map +1 -0
  6. package/dist/component/html.d.ts +35 -0
  7. package/dist/component/html.d.ts.map +1 -0
  8. package/dist/component/index.d.ts +3 -126
  9. package/dist/component/index.d.ts.map +1 -1
  10. package/dist/component/props.d.ts +18 -0
  11. package/dist/component/props.d.ts.map +1 -0
  12. package/dist/component/types.d.ts +77 -0
  13. package/dist/component/types.d.ts.map +1 -0
  14. package/dist/component.es.mjs +90 -59
  15. package/dist/component.es.mjs.map +1 -1
  16. package/dist/core/collection.d.ts +55 -3
  17. package/dist/core/collection.d.ts.map +1 -1
  18. package/dist/core/dom.d.ts +6 -0
  19. package/dist/core/dom.d.ts.map +1 -0
  20. package/dist/core/element.d.ts +31 -4
  21. package/dist/core/element.d.ts.map +1 -1
  22. package/dist/core/index.d.ts +2 -0
  23. package/dist/core/index.d.ts.map +1 -1
  24. package/dist/core/utils/array.d.ts +74 -0
  25. package/dist/core/utils/array.d.ts.map +1 -0
  26. package/dist/core/utils/function.d.ts +87 -0
  27. package/dist/core/utils/function.d.ts.map +1 -0
  28. package/dist/core/utils/index.d.ts +70 -0
  29. package/dist/core/utils/index.d.ts.map +1 -0
  30. package/dist/core/utils/misc.d.ts +63 -0
  31. package/dist/core/utils/misc.d.ts.map +1 -0
  32. package/dist/core/utils/number.d.ts +65 -0
  33. package/dist/core/utils/number.d.ts.map +1 -0
  34. package/dist/core/utils/object.d.ts +133 -0
  35. package/dist/core/utils/object.d.ts.map +1 -0
  36. package/dist/core/utils/string.d.ts +80 -0
  37. package/dist/core/utils/string.d.ts.map +1 -0
  38. package/dist/core/utils/type-guards.d.ts +79 -0
  39. package/dist/core/utils/type-guards.d.ts.map +1 -0
  40. package/dist/core-BhpuvPhy.js +170 -0
  41. package/dist/core-BhpuvPhy.js.map +1 -0
  42. package/dist/core.es.mjs +495 -489
  43. package/dist/core.es.mjs.map +1 -1
  44. package/dist/full.d.ts +2 -2
  45. package/dist/full.d.ts.map +1 -1
  46. package/dist/full.es.mjs +87 -64
  47. package/dist/full.es.mjs.map +1 -1
  48. package/dist/full.iife.js +2 -2
  49. package/dist/full.iife.js.map +1 -1
  50. package/dist/full.umd.js +2 -2
  51. package/dist/full.umd.js.map +1 -1
  52. package/dist/index.es.mjs +138 -68
  53. package/dist/index.es.mjs.map +1 -1
  54. package/dist/motion/animate.d.ts +25 -0
  55. package/dist/motion/animate.d.ts.map +1 -0
  56. package/dist/motion/easing.d.ts +30 -0
  57. package/dist/motion/easing.d.ts.map +1 -0
  58. package/dist/motion/flip.d.ts +55 -0
  59. package/dist/motion/flip.d.ts.map +1 -0
  60. package/dist/motion/index.d.ts +11 -138
  61. package/dist/motion/index.d.ts.map +1 -1
  62. package/dist/motion/keyframes.d.ts +21 -0
  63. package/dist/motion/keyframes.d.ts.map +1 -0
  64. package/dist/motion/reduced-motion.d.ts +12 -0
  65. package/dist/motion/reduced-motion.d.ts.map +1 -0
  66. package/dist/motion/scroll.d.ts +15 -0
  67. package/dist/motion/scroll.d.ts.map +1 -0
  68. package/dist/motion/spring.d.ts +42 -0
  69. package/dist/motion/spring.d.ts.map +1 -0
  70. package/dist/motion/stagger.d.ts +22 -0
  71. package/dist/motion/stagger.d.ts.map +1 -0
  72. package/dist/motion/timeline.d.ts +21 -0
  73. package/dist/motion/timeline.d.ts.map +1 -0
  74. package/dist/motion/transition.d.ts +22 -0
  75. package/dist/motion/transition.d.ts.map +1 -0
  76. package/dist/motion/types.d.ts +182 -0
  77. package/dist/motion/types.d.ts.map +1 -0
  78. package/dist/motion.es.mjs +320 -61
  79. package/dist/motion.es.mjs.map +1 -1
  80. package/dist/persisted-DHoi3uEs.js +278 -0
  81. package/dist/persisted-DHoi3uEs.js.map +1 -0
  82. package/dist/platform/storage.d.ts.map +1 -1
  83. package/dist/platform.es.mjs +12 -7
  84. package/dist/platform.es.mjs.map +1 -1
  85. package/dist/reactive/batch.d.ts +13 -0
  86. package/dist/reactive/batch.d.ts.map +1 -0
  87. package/dist/reactive/computed.d.ts +50 -0
  88. package/dist/reactive/computed.d.ts.map +1 -0
  89. package/dist/reactive/core.d.ts +72 -0
  90. package/dist/reactive/core.d.ts.map +1 -0
  91. package/dist/reactive/effect.d.ts +15 -0
  92. package/dist/reactive/effect.d.ts.map +1 -0
  93. package/dist/reactive/index.d.ts +2 -2
  94. package/dist/reactive/index.d.ts.map +1 -1
  95. package/dist/reactive/internals.d.ts +42 -0
  96. package/dist/reactive/internals.d.ts.map +1 -0
  97. package/dist/reactive/linked.d.ts +36 -0
  98. package/dist/reactive/linked.d.ts.map +1 -0
  99. package/dist/reactive/persisted.d.ts +14 -0
  100. package/dist/reactive/persisted.d.ts.map +1 -0
  101. package/dist/reactive/readonly.d.ts +26 -0
  102. package/dist/reactive/readonly.d.ts.map +1 -0
  103. package/dist/reactive/signal.d.ts +13 -312
  104. package/dist/reactive/signal.d.ts.map +1 -1
  105. package/dist/reactive/type-guards.d.ts +20 -0
  106. package/dist/reactive/type-guards.d.ts.map +1 -0
  107. package/dist/reactive/untrack.d.ts +29 -0
  108. package/dist/reactive/untrack.d.ts.map +1 -0
  109. package/dist/reactive/watch.d.ts +42 -0
  110. package/dist/reactive/watch.d.ts.map +1 -0
  111. package/dist/reactive.es.mjs +30 -163
  112. package/dist/reactive.es.mjs.map +1 -1
  113. package/dist/router/index.d.ts +6 -252
  114. package/dist/router/index.d.ts.map +1 -1
  115. package/dist/router/links.d.ts +44 -0
  116. package/dist/router/links.d.ts.map +1 -0
  117. package/dist/router/match.d.ts +20 -0
  118. package/dist/router/match.d.ts.map +1 -0
  119. package/dist/router/navigation.d.ts +45 -0
  120. package/dist/router/navigation.d.ts.map +1 -0
  121. package/dist/router/query.d.ts +16 -0
  122. package/dist/router/query.d.ts.map +1 -0
  123. package/dist/router/router.d.ts +34 -0
  124. package/dist/router/router.d.ts.map +1 -0
  125. package/dist/router/state.d.ts +27 -0
  126. package/dist/router/state.d.ts.map +1 -0
  127. package/dist/router/types.d.ts +88 -0
  128. package/dist/router/types.d.ts.map +1 -0
  129. package/dist/router/utils.d.ts +65 -0
  130. package/dist/router/utils.d.ts.map +1 -0
  131. package/dist/router.es.mjs +168 -132
  132. package/dist/router.es.mjs.map +1 -1
  133. package/dist/sanitize-Cxvxa-DX.js +283 -0
  134. package/dist/sanitize-Cxvxa-DX.js.map +1 -0
  135. package/dist/security/constants.d.ts +42 -0
  136. package/dist/security/constants.d.ts.map +1 -0
  137. package/dist/security/csp.d.ts +24 -0
  138. package/dist/security/csp.d.ts.map +1 -0
  139. package/dist/security/index.d.ts +4 -2
  140. package/dist/security/index.d.ts.map +1 -1
  141. package/dist/security/sanitize-core.d.ts +13 -0
  142. package/dist/security/sanitize-core.d.ts.map +1 -0
  143. package/dist/security/sanitize.d.ts +5 -57
  144. package/dist/security/sanitize.d.ts.map +1 -1
  145. package/dist/security/trusted-types.d.ts +25 -0
  146. package/dist/security/trusted-types.d.ts.map +1 -0
  147. package/dist/security/types.d.ts +36 -0
  148. package/dist/security/types.d.ts.map +1 -0
  149. package/dist/security.es.mjs +50 -277
  150. package/dist/security.es.mjs.map +1 -1
  151. package/dist/store/create-store.d.ts +15 -0
  152. package/dist/store/create-store.d.ts.map +1 -0
  153. package/dist/store/define-store.d.ts +28 -0
  154. package/dist/store/define-store.d.ts.map +1 -0
  155. package/dist/store/devtools.d.ts +22 -0
  156. package/dist/store/devtools.d.ts.map +1 -0
  157. package/dist/store/index.d.ts +10 -286
  158. package/dist/store/index.d.ts.map +1 -1
  159. package/dist/store/mapping.d.ts +28 -0
  160. package/dist/store/mapping.d.ts.map +1 -0
  161. package/dist/store/persisted.d.ts +13 -0
  162. package/dist/store/persisted.d.ts.map +1 -0
  163. package/dist/store/plugins.d.ts +13 -0
  164. package/dist/store/plugins.d.ts.map +1 -0
  165. package/dist/store/registry.d.ts +28 -0
  166. package/dist/store/registry.d.ts.map +1 -0
  167. package/dist/store/types.d.ts +71 -0
  168. package/dist/store/types.d.ts.map +1 -0
  169. package/dist/store/utils.d.ts +28 -0
  170. package/dist/store/utils.d.ts.map +1 -0
  171. package/dist/store/watch.d.ts +23 -0
  172. package/dist/store/watch.d.ts.map +1 -0
  173. package/dist/store.es.mjs +22 -224
  174. package/dist/store.es.mjs.map +1 -1
  175. package/dist/type-guards-BdKlYYlS.js +32 -0
  176. package/dist/type-guards-BdKlYYlS.js.map +1 -0
  177. package/dist/untrack-DNnnqdlR.js +6 -0
  178. package/dist/untrack-DNnnqdlR.js.map +1 -0
  179. package/dist/view/directives/bind.d.ts +7 -0
  180. package/dist/view/directives/bind.d.ts.map +1 -0
  181. package/dist/view/directives/class.d.ts +8 -0
  182. package/dist/view/directives/class.d.ts.map +1 -0
  183. package/dist/view/directives/for.d.ts +23 -0
  184. package/dist/view/directives/for.d.ts.map +1 -0
  185. package/dist/view/directives/html.d.ts +7 -0
  186. package/dist/view/directives/html.d.ts.map +1 -0
  187. package/dist/view/directives/if.d.ts +7 -0
  188. package/dist/view/directives/if.d.ts.map +1 -0
  189. package/dist/view/directives/index.d.ts +12 -0
  190. package/dist/view/directives/index.d.ts.map +1 -0
  191. package/dist/view/directives/model.d.ts +7 -0
  192. package/dist/view/directives/model.d.ts.map +1 -0
  193. package/dist/view/directives/on.d.ts +7 -0
  194. package/dist/view/directives/on.d.ts.map +1 -0
  195. package/dist/view/directives/ref.d.ts +7 -0
  196. package/dist/view/directives/ref.d.ts.map +1 -0
  197. package/dist/view/directives/show.d.ts +7 -0
  198. package/dist/view/directives/show.d.ts.map +1 -0
  199. package/dist/view/directives/style.d.ts +7 -0
  200. package/dist/view/directives/style.d.ts.map +1 -0
  201. package/dist/view/directives/text.d.ts +7 -0
  202. package/dist/view/directives/text.d.ts.map +1 -0
  203. package/dist/view/evaluate.d.ts +43 -0
  204. package/dist/view/evaluate.d.ts.map +1 -0
  205. package/dist/view/index.d.ts +3 -93
  206. package/dist/view/index.d.ts.map +1 -1
  207. package/dist/view/mount.d.ts +69 -0
  208. package/dist/view/mount.d.ts.map +1 -0
  209. package/dist/view/process.d.ts +26 -0
  210. package/dist/view/process.d.ts.map +1 -0
  211. package/dist/view/types.d.ts +36 -0
  212. package/dist/view/types.d.ts.map +1 -0
  213. package/dist/view.es.mjs +358 -251
  214. package/dist/view.es.mjs.map +1 -1
  215. package/dist/watch-DXXv3iAI.js +58 -0
  216. package/dist/watch-DXXv3iAI.js.map +1 -0
  217. package/package.json +14 -14
  218. package/src/component/component.ts +289 -0
  219. package/src/component/html.ts +53 -0
  220. package/src/component/index.ts +40 -414
  221. package/src/component/props.ts +116 -0
  222. package/src/component/types.ts +85 -0
  223. package/src/core/collection.ts +181 -7
  224. package/src/core/dom.ts +38 -0
  225. package/src/core/element.ts +59 -25
  226. package/src/core/index.ts +48 -4
  227. package/src/core/utils/array.ts +102 -0
  228. package/src/core/utils/function.ts +151 -0
  229. package/src/core/utils/index.ts +83 -0
  230. package/src/core/utils/misc.ts +82 -0
  231. package/src/core/utils/number.ts +78 -0
  232. package/src/core/utils/object.ts +206 -0
  233. package/src/core/utils/string.ts +112 -0
  234. package/src/core/utils/type-guards.ts +112 -0
  235. package/src/full.ts +187 -150
  236. package/src/index.ts +36 -36
  237. package/src/motion/animate.ts +113 -0
  238. package/src/motion/easing.ts +40 -0
  239. package/src/motion/flip.ts +176 -0
  240. package/src/motion/index.ts +41 -358
  241. package/src/motion/keyframes.ts +46 -0
  242. package/src/motion/reduced-motion.ts +17 -0
  243. package/src/motion/scroll.ts +57 -0
  244. package/src/motion/spring.ts +150 -0
  245. package/src/motion/stagger.ts +43 -0
  246. package/src/motion/timeline.ts +246 -0
  247. package/src/motion/transition.ts +51 -0
  248. package/src/motion/types.ts +198 -0
  249. package/src/platform/storage.ts +215 -208
  250. package/src/reactive/batch.ts +22 -0
  251. package/src/reactive/computed.ts +92 -0
  252. package/src/reactive/core.ts +114 -0
  253. package/src/reactive/effect.ts +54 -0
  254. package/src/reactive/index.ts +23 -22
  255. package/src/reactive/internals.ts +122 -0
  256. package/src/reactive/linked.ts +56 -0
  257. package/src/reactive/persisted.ts +74 -0
  258. package/src/reactive/readonly.ts +35 -0
  259. package/src/reactive/signal.ts +20 -520
  260. package/src/reactive/type-guards.ts +22 -0
  261. package/src/reactive/untrack.ts +31 -0
  262. package/src/reactive/watch.ts +73 -0
  263. package/src/router/index.ts +41 -718
  264. package/src/router/links.ts +130 -0
  265. package/src/router/match.ts +106 -0
  266. package/src/router/navigation.ts +71 -0
  267. package/src/router/query.ts +35 -0
  268. package/src/router/router.ts +211 -0
  269. package/src/router/state.ts +46 -0
  270. package/src/router/types.ts +93 -0
  271. package/src/router/utils.ts +116 -0
  272. package/src/security/constants.ts +209 -0
  273. package/src/security/csp.ts +77 -0
  274. package/src/security/index.ts +4 -12
  275. package/src/security/sanitize-core.ts +364 -0
  276. package/src/security/sanitize.ts +66 -625
  277. package/src/security/trusted-types.ts +69 -0
  278. package/src/security/types.ts +40 -0
  279. package/src/store/create-store.ts +329 -0
  280. package/src/store/define-store.ts +48 -0
  281. package/src/store/devtools.ts +45 -0
  282. package/src/store/index.ts +22 -848
  283. package/src/store/mapping.ts +73 -0
  284. package/src/store/persisted.ts +61 -0
  285. package/src/store/plugins.ts +32 -0
  286. package/src/store/registry.ts +51 -0
  287. package/src/store/types.ts +94 -0
  288. package/src/store/utils.ts +141 -0
  289. package/src/store/watch.ts +52 -0
  290. package/src/view/directives/bind.ts +23 -0
  291. package/src/view/directives/class.ts +70 -0
  292. package/src/view/directives/for.ts +275 -0
  293. package/src/view/directives/html.ts +19 -0
  294. package/src/view/directives/if.ts +30 -0
  295. package/src/view/directives/index.ts +11 -0
  296. package/src/view/directives/model.ts +56 -0
  297. package/src/view/directives/on.ts +41 -0
  298. package/src/view/directives/ref.ts +41 -0
  299. package/src/view/directives/show.ts +26 -0
  300. package/src/view/directives/style.ts +47 -0
  301. package/src/view/directives/text.ts +15 -0
  302. package/src/view/evaluate.ts +290 -0
  303. package/src/view/index.ts +112 -1041
  304. package/src/view/mount.ts +200 -0
  305. package/src/view/process.ts +92 -0
  306. package/src/view/types.ts +44 -0
  307. package/dist/core/utils.d.ts +0 -313
  308. package/dist/core/utils.d.ts.map +0 -1
  309. package/src/core/utils.ts +0 -444
@@ -1,288 +1,12 @@
1
1
  /**
2
- * Minimal state management built on signals.
3
- *
4
- * This module provides a lightweight store pattern inspired by Pinia/Vuex
5
- * but built entirely on bQuery's reactive primitives. Features include:
6
- * - Signal-based reactive state
7
- * - Computed getters
8
- * - Actions with async support
9
- * - Devtools hooks for debugging
10
- * - Plugin system for extensions
11
- *
12
- * @module bquery/store
13
- *
14
- * @example
15
- * ```ts
16
- * import { createStore } from 'bquery/store';
17
- * import { effect } from 'bquery/reactive';
18
- *
19
- * const counterStore = createStore({
20
- * id: 'counter',
21
- * state: () => ({ count: 0 }),
22
- * getters: {
23
- * doubled: (state) => state.count * 2,
24
- * isPositive: (state) => state.count > 0,
25
- * },
26
- * actions: {
27
- * increment() {
28
- * this.count++;
29
- * },
30
- * async fetchAndSet(url: string) {
31
- * const response = await fetch(url);
32
- * const data = await response.json();
33
- * this.count = data.count;
34
- * },
35
- * },
36
- * });
37
- *
38
- * effect(() => {
39
- * console.log('Count:', counterStore.count);
40
- * console.log('Doubled:', counterStore.doubled);
41
- * });
42
- *
43
- * counterStore.increment();
44
- * ```
45
- */
46
- /**
47
- * Store state factory function.
48
- */
49
- export type StateFactory<S> = () => S;
50
- /**
51
- * Getter definition - derives computed values from state.
52
- */
53
- export type Getters<S, G> = {
54
- [K in keyof G]: (state: S, getters: G) => G[K];
55
- };
56
- /**
57
- * Action definition - methods that can modify state.
58
- */
59
- export type Actions<S, A> = {
60
- [K in keyof A]: A[K] extends (...args: infer P) => infer R ? (this: S & A, ...args: P) => R : never;
61
- };
62
- /**
63
- * Store definition for createStore.
64
- */
65
- export type StoreDefinition<S extends Record<string, unknown> = Record<string, unknown>, G extends Record<string, unknown> = Record<string, unknown>, A extends Record<string, (...args: any[]) => any> = Record<string, never>> = {
66
- /** Unique store identifier for devtools */
67
- id: string;
68
- /** State factory function */
69
- state: StateFactory<S>;
70
- /** Computed getters */
71
- getters?: Getters<S, G>;
72
- /** Action methods */
73
- actions?: A;
74
- };
75
- /**
76
- * The returned store instance with state, getters, and actions merged.
77
- */
78
- export type Store<S extends Record<string, unknown>, G extends Record<string, unknown>, A extends Record<string, (...args: any[]) => any>> = S & G & A & {
79
- /** Store identifier */
80
- $id: string;
81
- /** Reset state to initial values */
82
- $reset: () => void;
83
- /** Subscribe to state changes */
84
- $subscribe: (callback: (state: S) => void) => () => void;
85
- /** Patch multiple state properties at once (shallow) */
86
- $patch: (partial: Partial<S> | ((state: S) => void)) => void;
87
- /**
88
- * Patch with deep reactivity support.
89
- * Unlike $patch, this method deep-clones nested objects before mutation,
90
- * ensuring that all changes trigger reactive updates.
91
- */
92
- $patchDeep: (partial: Partial<S> | ((state: S) => void)) => void;
93
- /** Get raw state object (non-reactive snapshot) */
94
- $state: S;
95
- };
96
- /**
97
- * Plugin that can extend store functionality.
98
- */
99
- export type StorePlugin<S = unknown> = (context: {
100
- store: Store<any, any, any>;
101
- options: StoreDefinition<any, any, any>;
102
- }) => Partial<S> | void;
103
- /** @internal Devtools hook */
104
- declare global {
105
- interface Window {
106
- __BQUERY_DEVTOOLS__?: {
107
- stores: Map<string, unknown>;
108
- onStoreCreated?: (id: string, store: unknown) => void;
109
- onStateChange?: (id: string, state: unknown) => void;
110
- };
111
- }
112
- }
113
- /**
114
- * Creates a reactive store with state, getters, and actions.
115
- *
116
- * @template S - State type
117
- * @template G - Getters type
118
- * @template A - Actions type
119
- * @param definition - Store definition
120
- * @returns The reactive store instance
121
- *
122
- * @example
123
- * ```ts
124
- * import { createStore } from 'bquery/store';
125
- *
126
- * // Simple counter store
127
- * const useCounter = createStore({
128
- * id: 'counter',
129
- * state: () => ({ count: 0, step: 1 }),
130
- * getters: {
131
- * doubled: (state) => state.count * 2,
132
- * next: (state) => state.count + state.step,
133
- * },
134
- * actions: {
135
- * increment() {
136
- * this.count += this.step;
137
- * },
138
- * decrement() {
139
- * this.count -= this.step;
140
- * },
141
- * setStep(newStep: number) {
142
- * this.step = newStep;
143
- * },
144
- * async loadFromServer() {
145
- * const res = await fetch('/api/counter');
146
- * const data = await res.json();
147
- * this.count = data.count;
148
- * },
149
- * },
150
- * });
151
- *
152
- * // Use the store
153
- * useCounter.increment();
154
- * console.log(useCounter.count); // 1
155
- * console.log(useCounter.doubled); // 2
156
- * ```
157
- */
158
- export declare const createStore: <S extends Record<string, unknown>, G extends Record<string, unknown> = Record<string, never>, A extends Record<string, (...args: any[]) => any> = Record<string, never>>(definition: StoreDefinition<S, G, A>) => Store<S, G, A>;
159
- /**
160
- * Retrieves an existing store by its ID.
161
- *
162
- * @param id - The store identifier
163
- * @returns The store instance or undefined if not found
164
- *
165
- * @example
166
- * ```ts
167
- * import { getStore } from 'bquery/store';
168
- *
169
- * const counter = getStore('counter');
170
- * if (counter) {
171
- * counter.increment();
172
- * }
173
- * ```
174
- */
175
- export declare const getStore: <T = unknown>(id: string) => T | undefined;
176
- /**
177
- * Lists all registered store IDs.
178
- *
179
- * @returns Array of store IDs
180
- *
181
- * @example
182
- * ```ts
183
- * import { listStores } from 'bquery/store';
184
- *
185
- * console.log('Active stores:', listStores());
186
- * ```
187
- */
188
- export declare const listStores: () => string[];
189
- /**
190
- * Removes a store from the registry.
191
- *
192
- * @param id - The store identifier
193
- *
194
- * @example
195
- * ```ts
196
- * import { destroyStore } from 'bquery/store';
197
- *
198
- * destroyStore('counter');
199
- * ```
200
- */
201
- export declare const destroyStore: (id: string) => void;
202
- /**
203
- * Registers a plugin that extends all stores.
204
- *
205
- * @param plugin - The plugin function
206
- *
207
- * @example
208
- * ```ts
209
- * import { registerPlugin } from 'bquery/store';
210
- *
211
- * // Add localStorage persistence
212
- * registerPlugin(({ store, options }) => {
213
- * const key = `bquery-store-${options.id}`;
214
- *
215
- * // Load saved state
216
- * const saved = localStorage.getItem(key);
217
- * if (saved) {
218
- * store.$patch(JSON.parse(saved));
219
- * }
220
- *
221
- * // Save on changes
222
- * store.$subscribe((state) => {
223
- * localStorage.setItem(key, JSON.stringify(state));
224
- * });
225
- * });
226
- * ```
227
- */
228
- export declare const registerPlugin: (plugin: StorePlugin) => void;
229
- /**
230
- * Creates a store with automatic persistence to localStorage.
231
- *
232
- * @param definition - Store definition
233
- * @param storageKey - Optional custom storage key
234
- * @returns The reactive store instance
235
- *
236
- * @example
237
- * ```ts
238
- * import { createPersistedStore } from 'bquery/store';
239
- *
240
- * const settings = createPersistedStore({
241
- * id: 'settings',
242
- * state: () => ({
243
- * theme: 'dark',
244
- * language: 'en',
245
- * }),
246
- * });
247
- *
248
- * // State is automatically saved/loaded from localStorage
249
- * settings.theme = 'light';
250
- * ```
251
- */
252
- export declare const createPersistedStore: <S extends Record<string, unknown>, G extends Record<string, unknown> = Record<string, never>, A extends Record<string, (...args: unknown[]) => unknown> = Record<string, never>>(definition: StoreDefinition<S, G, A>, storageKey?: string) => Store<S, G, A>;
253
- /**
254
- * Maps store state properties to a reactive object for use in components.
255
- *
256
- * @param store - The store instance
257
- * @param keys - State keys to map
258
- * @returns Object with mapped properties
259
- *
260
- * @example
261
- * ```ts
262
- * import { mapState } from 'bquery/store';
263
- *
264
- * const counter = useCounter();
265
- * const { count, step } = mapState(counter, ['count', 'step']);
266
- * ```
267
- */
268
- export declare const mapState: <S extends Record<string, unknown>, K extends keyof S>(store: S, keys: K[]) => Pick<S, K>;
269
- /**
270
- * Maps store actions to an object for easier destructuring.
271
- *
272
- * @param store - The store instance
273
- * @param keys - Action keys to map
274
- * @returns Object with mapped actions
275
- *
276
- * @example
277
- * ```ts
278
- * import { mapActions } from 'bquery/store';
279
- *
280
- * const counter = useCounter();
281
- * const { increment, decrement } = mapActions(counter, ['increment', 'decrement']);
282
- *
283
- * // Use directly
284
- * increment();
285
- * ```
286
- */
287
- export declare const mapActions: <A extends Record<string, (...args: unknown[]) => unknown>, K extends keyof A>(store: A, keys: K[]) => Pick<A, K>;
2
+ * Store module exports.
3
+ */
4
+ export type { Actions, Getters, StateFactory, Store, StoreDefinition, StorePatch, StorePlugin, StoreSubscriber, } from './types';
5
+ export { createStore } from './create-store';
6
+ export { defineStore } from './define-store';
7
+ export { mapActions, mapGetters, mapState } from './mapping';
8
+ export { createPersistedStore } from './persisted';
9
+ export { registerPlugin } from './plugins';
10
+ export { destroyStore, getStore, listStores } from './registry';
11
+ export { watchStore } from './watch';
288
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAQH;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GACtD,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAC9B,KAAK;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,CACzB,CAAC,SAAS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,MAAM,UAAU,GACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,EACzD,CAAC,SAAS,MAAM,CAAC,EAEjB,OAAO,CAAC,EACR,MAAM,CAAC,EAAE,KACR,IAAI,CAAC,CAAC,EAAE,CAAC,CASX,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,KAAK,EACL,eAAe,EACf,UAAU,EACV,WAAW,EACX,eAAe,GAChB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Mapping helpers for store state and actions.
3
+ */
4
+ /**
5
+ * Maps store state properties to a reactive object for use in components.
6
+ *
7
+ * @param store - The store instance
8
+ * @param keys - State keys to map
9
+ * @returns Object with mapped properties
10
+ */
11
+ export declare const mapState: <S extends Record<string, unknown>, K extends keyof S>(store: S, keys: K[]) => Pick<S, K>;
12
+ /**
13
+ * Maps store getters to a reactive object for use in components.
14
+ *
15
+ * @param store - The store instance
16
+ * @param keys - Getter keys to map
17
+ * @returns Object with mapped getters
18
+ */
19
+ export declare const mapGetters: <G extends Record<string, unknown>, K extends keyof G>(store: G, keys: K[]) => Pick<G, K>;
20
+ /**
21
+ * Maps store actions to an object for easier destructuring.
22
+ *
23
+ * @param store - The store instance
24
+ * @param keys - Action keys to map
25
+ * @returns Object with mapped actions
26
+ */
27
+ export declare const mapActions: <A extends Record<string, (...args: unknown[]) => unknown>, K extends keyof A>(store: A, keys: K[]) => Pick<A, K>;
28
+ //# sourceMappingURL=mapping.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mapping.d.ts","sourceRoot":"","sources":["../../src/store/mapping.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAC3E,OAAO,CAAC,EACR,MAAM,CAAC,EAAE,KACR,IAAI,CAAC,CAAC,EAAE,CAAC,CAWX,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,EAC7E,OAAO,CAAC,EACR,MAAM,CAAC,EAAE,KACR,IAAI,CAAC,CAAC,EAAE,CAAC,CAWX,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,GACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,EACzD,CAAC,SAAS,MAAM,CAAC,EAEjB,OAAO,CAAC,EACR,MAAM,CAAC,EAAE,KACR,IAAI,CAAC,CAAC,EAAE,CAAC,CASX,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Store persistence helpers.
3
+ */
4
+ import type { Store, StoreDefinition } from './types';
5
+ /**
6
+ * Creates a store with automatic persistence to localStorage.
7
+ *
8
+ * @param definition - Store definition
9
+ * @param storageKey - Optional custom storage key
10
+ * @returns The reactive store instance
11
+ */
12
+ export declare const createPersistedStore: <S extends Record<string, unknown>, G extends Record<string, unknown> = Record<string, never>, A extends Record<string, (...args: unknown[]) => unknown> = Record<string, never>>(definition: StoreDefinition<S, G, A>, storageKey?: string) => Store<S, G, A>;
13
+ //# sourceMappingURL=persisted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persisted.d.ts","sourceRoot":"","sources":["../../src/store/persisted.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEtD;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,GAC/B,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACzD,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAEjF,YAAY,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACpC,aAAa,MAAM,KAClB,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAuCf,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Store plugins API.
3
+ */
4
+ import type { Store, StoreDefinition, StorePlugin } from './types';
5
+ /**
6
+ * Registers a plugin that extends all stores.
7
+ *
8
+ * @param plugin - The plugin function
9
+ */
10
+ export declare const registerPlugin: (plugin: StorePlugin) => void;
11
+ /** @internal */
12
+ export declare const applyPlugins: (store: Store<any, any, any>, options: StoreDefinition<any, any, any>) => void;
13
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/store/plugins.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAKnE;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,WAAW,KAAG,IAEpD,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,YAAY,GAEvB,OAAO,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAE3B,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KACtC,IAOF,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Store registry utilities.
3
+ */
4
+ import type { Store } from './types';
5
+ /** @internal */
6
+ export declare const hasStore: (id: string) => boolean;
7
+ /** @internal */
8
+ export declare const registerStore: (id: string, store: Store<any, any, any>) => void;
9
+ /**
10
+ * Retrieves an existing store by its ID.
11
+ *
12
+ * @param id - The store identifier
13
+ * @returns The store instance or undefined if not found
14
+ */
15
+ export declare const getStore: <T = unknown>(id: string) => T | undefined;
16
+ /**
17
+ * Lists all registered store IDs.
18
+ *
19
+ * @returns Array of store IDs
20
+ */
21
+ export declare const listStores: () => string[];
22
+ /**
23
+ * Removes a store from the registry.
24
+ *
25
+ * @param id - The store identifier
26
+ */
27
+ export declare const destroyStore: (id: string) => void;
28
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/store/registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMrC,gBAAgB;AAChB,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,KAAG,OAAgC,CAAC;AAEvE,gBAAgB;AAChB,eAAO,MAAM,aAAa,GACxB,IAAI,MAAM,EAEV,OAAO,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAC1B,IAEF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,GAAG,OAAO,EAAE,IAAI,MAAM,KAAG,CAAC,GAAG,SAEtD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,QAAO,MAAM,EAEnC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,KAAG,IAGzC,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Store types for bQuery's state module.
3
+ * @module bquery/store
4
+ */
5
+ /**
6
+ * Store state factory function.
7
+ */
8
+ export type StateFactory<S> = () => S;
9
+ /**
10
+ * Getter definition - derives computed values from state.
11
+ */
12
+ export type Getters<S, G> = {
13
+ [K in keyof G]: (state: S, getters: G) => G[K];
14
+ };
15
+ /**
16
+ * Action definition - methods that can modify state.
17
+ * The `this` context includes state, getters, and other actions.
18
+ */
19
+ export type Actions<S, G, A> = {
20
+ [K in keyof A]: A[K] extends (...args: infer P) => infer R ? (this: S & G & A, ...args: P) => R : never;
21
+ };
22
+ /**
23
+ * Store definition for createStore.
24
+ */
25
+ export type StoreDefinition<S extends Record<string, unknown> = Record<string, unknown>, G extends Record<string, unknown> = Record<string, unknown>, A extends Record<string, (...args: any[]) => any> = Record<string, never>> = {
26
+ /** Unique store identifier for devtools */
27
+ id: string;
28
+ /** State factory function */
29
+ state: StateFactory<S>;
30
+ /** Computed getters */
31
+ getters?: Getters<S, G>;
32
+ /** Action methods */
33
+ actions?: Actions<S, G, A>;
34
+ };
35
+ /**
36
+ * Store subscriber callback.
37
+ */
38
+ export type StoreSubscriber<S> = (state: S) => void;
39
+ /**
40
+ * Patch payload for store updates.
41
+ */
42
+ export type StorePatch<S> = Partial<S> | ((state: S) => void);
43
+ /**
44
+ * The returned store instance with state, getters, and actions merged.
45
+ */
46
+ export type Store<S extends Record<string, unknown>, G extends Record<string, unknown>, A extends Record<string, (...args: any[]) => any>> = S & G & A & {
47
+ /** Store identifier */
48
+ $id: string;
49
+ /** Reset state to initial values */
50
+ $reset: () => void;
51
+ /** Subscribe to state changes */
52
+ $subscribe: (callback: StoreSubscriber<S>) => () => void;
53
+ /** Patch multiple state properties at once (shallow) */
54
+ $patch: (partial: StorePatch<S>) => void;
55
+ /**
56
+ * Patch with deep reactivity support.
57
+ * Unlike $patch, this method deep-clones nested objects before mutation,
58
+ * ensuring that all changes trigger reactive updates.
59
+ */
60
+ $patchDeep: (partial: StorePatch<S>) => void;
61
+ /** Get raw state object (non-reactive snapshot) */
62
+ $state: S;
63
+ };
64
+ /**
65
+ * Plugin that can extend store functionality.
66
+ */
67
+ export type StorePlugin<S = unknown> = (context: {
68
+ store: Store<any, any, any>;
69
+ options: StoreDefinition<any, any, any>;
70
+ }) => Partial<S> | void;
71
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/store/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI;KACzB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI;KAC5B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GACtD,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAClC,KAAK;CACV,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,CACzB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO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AAC,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC;IACzD,wDAAwD;IACxD,MAAM,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACzC;;;;OAIG;IACH,UAAU,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC7C,mDAAmD;IACnD,MAAM,EAAE,CAAC,CAAC;CACX,CAAC;AAEJ;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,OAAO,EAAE;IAE/C,KAAK,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAE5B,OAAO,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;CACzC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Internal utilities for the store module.
3
+ * @internal
4
+ */
5
+ /**
6
+ * Check if a value is a plain object (not array, null, Date, etc.).
7
+ * @internal
8
+ */
9
+ export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
10
+ /**
11
+ * Deep clones an object. Used for deep reactivity support.
12
+ * @internal
13
+ */
14
+ export declare const deepClone: <T>(obj: T) => T;
15
+ /**
16
+ * Compares two values for deep equality.
17
+ * @internal
18
+ */
19
+ export declare const deepEqual: (a: unknown, b: unknown) => boolean;
20
+ /**
21
+ * Detects if nested objects were mutated but the reference stayed the same.
22
+ * Returns the keys where nested mutations were detected.
23
+ * @internal
24
+ */
25
+ export declare const detectNestedMutations: <S extends Record<string, unknown>>(before: S, after: S, signalValues: Map<keyof S, unknown>) => Array<keyof S>;
26
+ /** @internal Flag to enable/disable development warnings */
27
+ export declare const isDev: boolean;
28
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/store/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAI7E,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,KAAK,CAAC,KAAG,CA0BrC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,EAAE,GAAG,OAAO,KAAG,OA+ClD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrE,QAAQ,CAAC,EACT,OAAO,CAAC,EACR,cAAc,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,KAClC,KAAK,CAAC,MAAM,CAAC,CAoBf,CAAC;AAEF,4DAA4D;AAC5D,eAAO,MAAM,KAAK,SAQd,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Store watch helpers.
3
+ */
4
+ import type { Store } from './types';
5
+ export type WatchStoreOptions<T> = {
6
+ /** Call the callback immediately with the current value. */
7
+ immediate?: boolean;
8
+ /** Use deep comparison when determining changes. */
9
+ deep?: boolean;
10
+ /** Custom equality check for selected values. */
11
+ equals?: (a: T, b: T) => boolean;
12
+ };
13
+ /**
14
+ * Watch a selected slice of store state.
15
+ *
16
+ * @param store - The store instance
17
+ * @param selector - Function to select the watched value
18
+ * @param callback - Called when the selected value changes
19
+ * @param options - Watch options
20
+ * @returns Unsubscribe function
21
+ */
22
+ export declare const watchStore: <S extends Record<string, unknown>, G extends Record<string, unknown>, A extends Record<string, (...args: unknown[]) => unknown>, T>(store: Store<S, G, A>, selector: (state: S) => T, callback: (value: T, previous: T | undefined) => void, options?: WatchStoreOptions<T>) => (() => void);
23
+ //# sourceMappingURL=watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../src/store/watch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAGrC,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;IACjC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oDAAoD;IACpD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,iDAAiD;IACjD,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC;CAClC,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,UAAU,GACrB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,EACzD,CAAC,EAED,OAAO,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACrB,UAAU,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EACzB,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,SAAS,KAAK,IAAI,EACrD,UAAS,iBAAiB,CAAC,CAAC,CAAM,KACjC,CAAC,MAAM,IAAI,CAgBb,CAAC"}