seitu 0.10.11 → 0.12.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/dist/core/subscription.d.ts +2 -2
- package/dist/react/hooks.d.ts +1 -0
- package/dist/react.js +6 -6
- package/dist/vue/composables.d.ts +1 -0
- package/dist/vue.js +10 -10
- package/dist/web/web-storage-value.d.ts +2 -2
- package/dist/web/web-storage.d.ts +2 -2
- package/dist/web.js +13 -1
- package/package.json +3 -3
|
@@ -23,8 +23,8 @@ export interface Readable<T> {
|
|
|
23
23
|
export interface Writable<T, P = T> {
|
|
24
24
|
set: (value: T | ((prev: P) => T)) => any;
|
|
25
25
|
}
|
|
26
|
-
export interface
|
|
27
|
-
|
|
26
|
+
export interface Clearable {
|
|
27
|
+
clear: () => void;
|
|
28
28
|
}
|
|
29
29
|
export declare function createReadableSubscription<T>(get: () => T, subscribe: (callback: () => any, options?: SubscribeOptions) => () => void, notify: () => void): Readable<T> & Subscribable<T>;
|
|
30
30
|
export declare function createSubscription(options?: {
|
package/dist/react/hooks.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import * as React from 'react';
|
|
|
3
3
|
export interface UseSubscriptionOptions<S extends Subscribable<any> & Readable<any>, R = S['~']['output']> {
|
|
4
4
|
selector?: (value: S['~']['output']) => R;
|
|
5
5
|
deps?: React.DependencyList;
|
|
6
|
+
isEqual?: (prev: R, next: R) => boolean;
|
|
6
7
|
}
|
|
7
8
|
/**
|
|
8
9
|
* Use this hook to subscribe to a reactive value. Accepts a subscription object
|
package/dist/react.js
CHANGED
|
@@ -2,13 +2,13 @@ import { deepEqual as e } from "fast-equals";
|
|
|
2
2
|
import * as t from "react";
|
|
3
3
|
//#region src/react/hooks.ts
|
|
4
4
|
function n(n, r) {
|
|
5
|
-
let { selector: i, deps: a = [] } = r ?? {},
|
|
6
|
-
(
|
|
7
|
-
let
|
|
8
|
-
let
|
|
9
|
-
return
|
|
5
|
+
let { selector: i, deps: a = [], isEqual: o = e } = r ?? {}, s = typeof n == "function", c = s ? n : () => n, l = t.useMemo(() => c(), s ? a : [n, ...a]), u = t.useRef(void 0), d = t.useRef(l), f = t.useRef(i), p = t.useRef(o);
|
|
6
|
+
(d.current !== l || f.current !== i) && (d.current = l, f.current = i, u.current = void 0), p.current = o;
|
|
7
|
+
let m = t.useCallback(() => {
|
|
8
|
+
let e = f.current, t = e ? e(d.current.get()) : d.current.get(), n = u.current;
|
|
9
|
+
return n !== void 0 && p.current(n, t) ? n : (u.current = t, t);
|
|
10
10
|
}, []);
|
|
11
|
-
return t.useSyncExternalStore(
|
|
11
|
+
return t.useSyncExternalStore(l.subscribe, m, m);
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
//#region src/react/components.tsx
|
|
@@ -2,6 +2,7 @@ import type { MaybeRefOrGetter, ShallowRef } from 'vue';
|
|
|
2
2
|
import type { Readable, Subscribable } from '../core/index';
|
|
3
3
|
export interface UseSubscriptionOptions<S extends Subscribable<any> & Readable<any>, R = S['~']['output']> {
|
|
4
4
|
selector?: (value: S['~']['output']) => R;
|
|
5
|
+
isEqual?: (prev: R, next: R) => boolean;
|
|
5
6
|
}
|
|
6
7
|
/**
|
|
7
8
|
* Use this composable to subscribe to a reactive value. Accepts a subscription object
|
package/dist/vue.js
CHANGED
|
@@ -2,21 +2,21 @@ import { deepEqual as e } from "fast-equals";
|
|
|
2
2
|
import { computed as t, onWatcherCleanup as n, readonly as r, shallowRef as i, toValue as a, watch as o } from "vue";
|
|
3
3
|
//#region src/vue/composables.ts
|
|
4
4
|
function s(s, c) {
|
|
5
|
-
let { selector: l } = c ?? {};
|
|
6
|
-
function
|
|
5
|
+
let { selector: l, isEqual: u = e } = c ?? {};
|
|
6
|
+
function d(e) {
|
|
7
7
|
return l ? l(e.get()) : e.get();
|
|
8
8
|
}
|
|
9
|
-
let
|
|
10
|
-
return o(
|
|
11
|
-
|
|
12
|
-
let
|
|
13
|
-
let
|
|
14
|
-
|
|
9
|
+
let f = t(() => a(s)), p = i(d(f.value));
|
|
10
|
+
return o(f, (e) => {
|
|
11
|
+
p.value = d(e);
|
|
12
|
+
let t = e.subscribe(() => {
|
|
13
|
+
let t = d(e);
|
|
14
|
+
u(p.value, t) || (p.value = t);
|
|
15
15
|
});
|
|
16
16
|
n(() => {
|
|
17
|
-
|
|
17
|
+
t();
|
|
18
18
|
});
|
|
19
|
-
}, { immediate: !0 }), r(
|
|
19
|
+
}, { immediate: !0 }), r(p);
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
22
|
export { s as useSubscription };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Clearable, Readable, Subscribable, Writable } from '../core/index';
|
|
3
3
|
import type { ValidationSchemaErrorProps, ValidationSchemaObjectErrorProps } from '../validate';
|
|
4
4
|
import type { WebStorage } from './web-storage';
|
|
5
|
-
export interface WebStorageValue<V> extends Subscribable<V>, Readable<V>, Writable<V>,
|
|
5
|
+
export interface WebStorageValue<V> extends Subscribable<V>, Readable<V>, Writable<V>, Clearable {
|
|
6
6
|
}
|
|
7
7
|
export interface WebStorageValueOptionsWithStorage<Storage extends WebStorage<any>, K extends keyof Storage['~']['output']> {
|
|
8
8
|
storage: Storage;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type { Readable, Subscribable, Writable } from '../core/index';
|
|
2
|
+
import type { Clearable, Readable, Subscribable, Writable } from '../core/index';
|
|
3
3
|
import type { Simplify } from '../utils';
|
|
4
4
|
import type { ValidationSchemaObjectErrorProps } from '../validate';
|
|
5
5
|
export type WebStorageInput = Record<string, StandardSchemaV1<unknown, unknown>>;
|
|
@@ -13,7 +13,7 @@ export interface WebStorageOptions<S extends WebStorageInput> {
|
|
|
13
13
|
keyTransform?: (key: keyof S) => string;
|
|
14
14
|
onValidationError?: (props: ValidationSchemaObjectErrorProps<WebStorageOutput<S>>) => void | StandardSchemaV1.InferOutput<S[keyof S]>;
|
|
15
15
|
}
|
|
16
|
-
export interface WebStorage<O extends Record<string, unknown>> extends Subscribable<O>, Readable<O>, Writable<Partial<O>, O
|
|
16
|
+
export interface WebStorage<O extends Record<string, unknown>> extends Subscribable<O>, Readable<O>, Writable<Partial<O>, O>, Clearable {
|
|
17
17
|
'~': {
|
|
18
18
|
getDefaultValue: <K extends keyof O>(key: K) => O[K];
|
|
19
19
|
type: 'localStorage' | 'sessionStorage';
|
package/dist/web.js
CHANGED
|
@@ -111,6 +111,18 @@ function c(n) {
|
|
|
111
111
|
}));
|
|
112
112
|
}), l = void 0;
|
|
113
113
|
},
|
|
114
|
+
clear: () => {
|
|
115
|
+
if (typeof window > "u") return;
|
|
116
|
+
let e = window[n.type];
|
|
117
|
+
for (let t of s) {
|
|
118
|
+
let r = String(n.keyTransform ? n.keyTransform(t) : t);
|
|
119
|
+
e.removeItem(r), window.dispatchEvent(new StorageEvent("storage", {
|
|
120
|
+
key: r,
|
|
121
|
+
newValue: null
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
l = void 0;
|
|
125
|
+
},
|
|
114
126
|
"~": {
|
|
115
127
|
...d["~"],
|
|
116
128
|
getDefaultValue: (e) => i[e],
|
|
@@ -158,7 +170,7 @@ function l(i) {
|
|
|
158
170
|
newValue: r
|
|
159
171
|
})), l = void 0;
|
|
160
172
|
},
|
|
161
|
-
|
|
173
|
+
clear: () => {
|
|
162
174
|
typeof window > "u" || (window[a].removeItem(i.key), l = void 0);
|
|
163
175
|
}
|
|
164
176
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "seitu",
|
|
3
3
|
"displayName": "Seitu",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.12.0",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "Valerii Strilets",
|
|
8
8
|
"license": "MIT",
|
|
@@ -82,10 +82,10 @@
|
|
|
82
82
|
"react-dom": "^19.2.4",
|
|
83
83
|
"type-fest": "^5.5.0",
|
|
84
84
|
"typescript": "^6.0.2",
|
|
85
|
-
"vite": "^8.0.
|
|
85
|
+
"vite": "^8.0.4",
|
|
86
86
|
"vite-plugin-dts": "^4.5.4",
|
|
87
87
|
"vitest": "^4.1.2",
|
|
88
|
-
"vue": "^3.5.
|
|
88
|
+
"vue": "^3.5.32",
|
|
89
89
|
"zod": "^4.3.6"
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|