@bquery/bquery 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +586 -546
- package/dist/component/component.d.ts +13 -5
- package/dist/component/component.d.ts.map +1 -1
- package/dist/component/html.d.ts +40 -3
- package/dist/component/html.d.ts.map +1 -1
- package/dist/component/index.d.ts +2 -2
- package/dist/component/index.d.ts.map +1 -1
- package/dist/component/library.d.ts.map +1 -1
- package/dist/component/types.d.ts +131 -16
- package/dist/component/types.d.ts.map +1 -1
- package/dist/component-BEQgt5hl.js +600 -0
- package/dist/component-BEQgt5hl.js.map +1 -0
- package/dist/component.es.mjs +7 -6
- package/dist/config-DRmZZno3.js.map +1 -1
- package/dist/core-BGQJVw0-.js +35 -0
- package/dist/core-BGQJVw0-.js.map +1 -0
- package/dist/{core-CK2Mfpf4.js → core-CCEabVHl.js} +2 -2
- package/dist/{core-CK2Mfpf4.js.map → core-CCEabVHl.js.map} +1 -1
- package/dist/core.es.mjs +1 -1
- package/dist/effect-AFRW_Plg.js +84 -0
- package/dist/effect-AFRW_Plg.js.map +1 -0
- package/dist/full.d.ts +4 -4
- package/dist/full.d.ts.map +1 -1
- package/dist/full.es.mjs +98 -94
- package/dist/full.iife.js +14 -14
- package/dist/full.iife.js.map +1 -1
- package/dist/full.umd.js +14 -14
- package/dist/full.umd.js.map +1 -1
- package/dist/index.es.mjs +143 -139
- package/dist/{motion-C5DRdPnO.js → motion-D9TcHxOF.js} +1 -1
- package/dist/{motion-C5DRdPnO.js.map → motion-D9TcHxOF.js.map} +1 -1
- package/dist/motion.es.mjs +1 -1
- package/dist/{platform-B7JhGBc7.js → platform-Dr9b6fsq.js} +21 -20
- package/dist/platform-Dr9b6fsq.js.map +1 -0
- package/dist/platform.es.mjs +1 -1
- package/dist/{reactive-BDya-ia8.js → reactive-DSkct0dO.js} +51 -50
- package/dist/reactive-DSkct0dO.js.map +1 -0
- package/dist/reactive.es.mjs +19 -17
- package/dist/{router-CijiICxt.js → router-CbDhl8rS.js} +3 -3
- package/dist/{router-CijiICxt.js.map → router-CbDhl8rS.js.map} +1 -1
- package/dist/router.es.mjs +1 -1
- package/dist/{sanitize-jyJ2ryE2.js → sanitize-Bs2dkMby.js} +94 -83
- package/dist/sanitize-Bs2dkMby.js.map +1 -0
- package/dist/security/index.d.ts +4 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/sanitize.d.ts +4 -1
- package/dist/security/sanitize.d.ts.map +1 -1
- package/dist/security/trusted-html.d.ts +53 -0
- package/dist/security/trusted-html.d.ts.map +1 -0
- package/dist/security.es.mjs +10 -9
- package/dist/store/define-store.d.ts +1 -1
- package/dist/store/define-store.d.ts.map +1 -1
- package/dist/store/mapping.d.ts +1 -1
- package/dist/store/mapping.d.ts.map +1 -1
- package/dist/store/persisted.d.ts +1 -1
- package/dist/store/persisted.d.ts.map +1 -1
- package/dist/store/types.d.ts +2 -2
- package/dist/store/types.d.ts.map +1 -1
- package/dist/store/watch.d.ts +1 -1
- package/dist/store/watch.d.ts.map +1 -1
- package/dist/{store-CPK9E62U.js → store-BwDvI45q.js} +49 -48
- package/dist/{store-CPK9E62U.js.map → store-BwDvI45q.js.map} +1 -1
- package/dist/store.es.mjs +1 -1
- package/dist/storybook/index.d.ts +37 -0
- package/dist/storybook/index.d.ts.map +1 -0
- package/dist/storybook.es.mjs +151 -0
- package/dist/storybook.es.mjs.map +1 -0
- package/dist/untrack-B0rVscTc.js +7 -0
- package/dist/untrack-B0rVscTc.js.map +1 -0
- package/dist/{view-Cdi0g-qo.js → view-C70lA3vf.js} +29 -28
- package/dist/{view-Cdi0g-qo.js.map → view-C70lA3vf.js.map} +1 -1
- package/dist/view.es.mjs +9 -8
- package/package.json +141 -136
- package/src/component/component.ts +259 -54
- package/src/component/html.ts +153 -53
- package/src/component/index.ts +10 -2
- package/src/component/library.ts +42 -28
- package/src/component/types.ts +184 -19
- package/src/full.ts +8 -2
- package/src/motion/transition.ts +97 -97
- package/src/motion/types.ts +208 -208
- package/src/platform/announcer.ts +208 -208
- package/src/platform/config.ts +163 -163
- package/src/platform/cookies.ts +165 -165
- package/src/platform/index.ts +39 -39
- package/src/platform/meta.ts +168 -168
- package/src/reactive/async-data.ts +486 -486
- package/src/reactive/index.ts +37 -37
- package/src/reactive/signal.ts +29 -29
- package/src/security/constants.ts +211 -211
- package/src/security/index.ts +17 -10
- package/src/security/sanitize.ts +70 -66
- package/src/security/trusted-html.ts +71 -0
- package/src/store/define-store.ts +49 -48
- package/src/store/mapping.ts +74 -73
- package/src/store/persisted.ts +62 -61
- package/src/store/types.ts +92 -94
- package/src/store/watch.ts +53 -52
- package/src/storybook/index.ts +479 -0
- package/dist/component-CY5MVoYN.js +0 -531
- package/dist/component-CY5MVoYN.js.map +0 -1
- package/dist/core-DPdbItcq.js +0 -112
- package/dist/core-DPdbItcq.js.map +0 -1
- package/dist/platform-B7JhGBc7.js.map +0 -1
- package/dist/reactive-BDya-ia8.js.map +0 -1
- package/dist/sanitize-jyJ2ryE2.js.map +0 -1
package/src/store/types.ts
CHANGED
|
@@ -1,94 +1,92 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Store types for bQuery's state module.
|
|
3
|
-
* @module bquery/store
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Store state factory function.
|
|
8
|
-
*/
|
|
9
|
-
export type StateFactory<S> = () => S;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Getter definition - derives computed values from state.
|
|
13
|
-
*/
|
|
14
|
-
export type Getters<S, G> = {
|
|
15
|
-
[K in keyof G]: (state: S, getters: G) => G[K];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Action definition - methods that can modify state.
|
|
20
|
-
* The `this` context includes state, getters, and other actions.
|
|
21
|
-
*/
|
|
22
|
-
export type Actions<S, G, A> = {
|
|
23
|
-
[K in keyof A]: A[K]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
$
|
|
70
|
-
/**
|
|
71
|
-
$
|
|
72
|
-
/**
|
|
73
|
-
$
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
*
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
$
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
options: StoreDefinition<any, any, any>;
|
|
94
|
-
}) => Partial<S> | void;
|
|
1
|
+
/**
|
|
2
|
+
* Store types for bQuery's state module.
|
|
3
|
+
* @module bquery/store
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Store state factory function.
|
|
8
|
+
*/
|
|
9
|
+
export type StateFactory<S> = () => S;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Getter definition - derives computed values from state.
|
|
13
|
+
*/
|
|
14
|
+
export type Getters<S, G> = {
|
|
15
|
+
[K in keyof G]: (state: S, getters: G) => G[K];
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Action definition - methods that can modify state.
|
|
20
|
+
* The `this` context includes state, getters, and other actions.
|
|
21
|
+
*/
|
|
22
|
+
export type Actions<S, G, A> = {
|
|
23
|
+
[K in keyof A]: A[K];
|
|
24
|
+
} & ThisType<S & G & A>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Store definition for createStore.
|
|
28
|
+
*/
|
|
29
|
+
export type StoreDefinition<
|
|
30
|
+
S extends Record<string, unknown> = Record<string, unknown>,
|
|
31
|
+
G extends Record<string, unknown> = Record<string, unknown>,
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
A extends Record<string, (...args: any[]) => any> = Record<string, never>,
|
|
34
|
+
> = {
|
|
35
|
+
/** Unique store identifier for devtools */
|
|
36
|
+
id: string;
|
|
37
|
+
/** State factory function */
|
|
38
|
+
state: StateFactory<S>;
|
|
39
|
+
/** Computed getters */
|
|
40
|
+
getters?: Getters<S, G>;
|
|
41
|
+
/** Action methods */
|
|
42
|
+
actions?: Actions<S, G, A>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Store subscriber callback.
|
|
47
|
+
*/
|
|
48
|
+
export type StoreSubscriber<S> = (state: S) => void;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Patch payload for store updates.
|
|
52
|
+
*/
|
|
53
|
+
export type StorePatch<S> = Partial<S> | ((state: S) => void);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The returned store instance with state, getters, and actions merged.
|
|
57
|
+
*/
|
|
58
|
+
export type Store<
|
|
59
|
+
S extends Record<string, unknown>,
|
|
60
|
+
G extends Record<string, unknown>,
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
62
|
+
A extends Record<string, (...args: any[]) => any>,
|
|
63
|
+
> = S &
|
|
64
|
+
G &
|
|
65
|
+
A & {
|
|
66
|
+
/** Store identifier */
|
|
67
|
+
$id: string;
|
|
68
|
+
/** Reset state to initial values */
|
|
69
|
+
$reset: () => void;
|
|
70
|
+
/** Subscribe to state changes */
|
|
71
|
+
$subscribe: (callback: StoreSubscriber<S>) => () => void;
|
|
72
|
+
/** Patch multiple state properties at once (shallow) */
|
|
73
|
+
$patch: (partial: StorePatch<S>) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Patch with deep reactivity support.
|
|
76
|
+
* Unlike $patch, this method deep-clones nested objects before mutation,
|
|
77
|
+
* ensuring that all changes trigger reactive updates.
|
|
78
|
+
*/
|
|
79
|
+
$patchDeep: (partial: StorePatch<S>) => void;
|
|
80
|
+
/** Get raw state object (non-reactive snapshot) */
|
|
81
|
+
$state: S;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Plugin that can extend store functionality.
|
|
86
|
+
*/
|
|
87
|
+
export type StorePlugin<S = unknown> = (context: {
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
+
store: Store<any, any, any>;
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
91
|
+
options: StoreDefinition<any, any, any>;
|
|
92
|
+
}) => Partial<S> | void;
|
package/src/store/watch.ts
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Store watch helpers.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type { Store } from './types';
|
|
6
|
-
import { deepEqual } from './utils';
|
|
7
|
-
|
|
8
|
-
export type WatchStoreOptions<T> = {
|
|
9
|
-
/** Call the callback immediately with the current value. */
|
|
10
|
-
immediate?: boolean;
|
|
11
|
-
/** Use deep comparison when determining changes. */
|
|
12
|
-
deep?: boolean;
|
|
13
|
-
/** Custom equality check for selected values. */
|
|
14
|
-
equals?: (a: T, b: T) => boolean;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Watch a selected slice of store state.
|
|
19
|
-
*
|
|
20
|
-
* @param store - The store instance
|
|
21
|
-
* @param selector - Function to select the watched value
|
|
22
|
-
* @param callback - Called when the selected value changes
|
|
23
|
-
* @param options - Watch options
|
|
24
|
-
* @returns Unsubscribe function
|
|
25
|
-
*/
|
|
26
|
-
export const watchStore = <
|
|
27
|
-
S extends Record<string, unknown>,
|
|
28
|
-
G extends Record<string, unknown>,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Store watch helpers.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Store } from './types';
|
|
6
|
+
import { deepEqual } from './utils';
|
|
7
|
+
|
|
8
|
+
export type WatchStoreOptions<T> = {
|
|
9
|
+
/** Call the callback immediately with the current value. */
|
|
10
|
+
immediate?: boolean;
|
|
11
|
+
/** Use deep comparison when determining changes. */
|
|
12
|
+
deep?: boolean;
|
|
13
|
+
/** Custom equality check for selected values. */
|
|
14
|
+
equals?: (a: T, b: T) => boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Watch a selected slice of store state.
|
|
19
|
+
*
|
|
20
|
+
* @param store - The store instance
|
|
21
|
+
* @param selector - Function to select the watched value
|
|
22
|
+
* @param callback - Called when the selected value changes
|
|
23
|
+
* @param options - Watch options
|
|
24
|
+
* @returns Unsubscribe function
|
|
25
|
+
*/
|
|
26
|
+
export const watchStore = <
|
|
27
|
+
S extends Record<string, unknown>,
|
|
28
|
+
G extends Record<string, unknown>,
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- actions may declare specific parameter types
|
|
30
|
+
A extends Record<string, (...args: any[]) => any>,
|
|
31
|
+
T,
|
|
32
|
+
>(
|
|
33
|
+
store: Store<S, G, A>,
|
|
34
|
+
selector: (state: S) => T,
|
|
35
|
+
callback: (value: T, previous: T | undefined) => void,
|
|
36
|
+
options: WatchStoreOptions<T> = {}
|
|
37
|
+
): (() => void) => {
|
|
38
|
+
const equals = options.equals ?? (options.deep ? deepEqual : Object.is);
|
|
39
|
+
let previous = selector(store.$state);
|
|
40
|
+
|
|
41
|
+
if (options.immediate) {
|
|
42
|
+
callback(previous, undefined);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return store.$subscribe((state) => {
|
|
46
|
+
const current = selector(state);
|
|
47
|
+
if (!equals(current, previous)) {
|
|
48
|
+
const prev = previous;
|
|
49
|
+
previous = current;
|
|
50
|
+
callback(current, prev);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
};
|