seitu 0.10.4 → 0.10.6
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-BFAZmVJI.js → core-CIQELdxV.js} +18 -27
- package/dist/core.js +2 -2
- package/dist/src/core/schema-store.d.ts +35 -0
- package/dist/{validate.d.ts → src/validate.d.ts} +2 -6
- package/dist/{web → src/web}/web-storage-value.d.ts +2 -2
- package/dist/{web → src/web}/web-storage.d.ts +14 -7
- package/dist/web.js +41 -41
- package/package.json +2 -2
- package/dist/core/schema-store.d.ts +0 -57
- /package/dist/{core → src/core}/computed.d.ts +0 -0
- /package/dist/{core → src/core}/debounce-fn.d.ts +0 -0
- /package/dist/{core → src/core}/debounce.d.ts +0 -0
- /package/dist/{core → src/core}/index.d.ts +0 -0
- /package/dist/{core → src/core}/store.d.ts +0 -0
- /package/dist/{core → src/core}/subscription.d.ts +0 -0
- /package/dist/{core → src/core}/throttle-fn.d.ts +0 -0
- /package/dist/{core → src/core}/throttle.d.ts +0 -0
- /package/dist/{react → src/react}/components.d.ts +0 -0
- /package/dist/{react → src/react}/hooks.d.ts +0 -0
- /package/dist/{react → src/react}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/index.d.ts +0 -0
- /package/dist/{utils → src/utils}/validation.d.ts +0 -0
- /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
- /package/dist/{vue → src/vue}/composables.d.ts +0 -0
- /package/dist/{vue → src/vue}/index.d.ts +0 -0
- /package/dist/{vue → src/vue}/test-utils.d.ts +0 -0
- /package/dist/{web → src/web}/index.d.ts +0 -0
- /package/dist/{web → src/web}/is-online.d.ts +0 -0
- /package/dist/{web → src/web}/media-query.d.ts +0 -0
- /package/dist/{web → src/web}/scroll-state.d.ts +0 -0
|
@@ -86,38 +86,29 @@ function o(e, t, n) {
|
|
|
86
86
|
//#endregion
|
|
87
87
|
//#region src/core/schema-store.ts
|
|
88
88
|
function s(n) {
|
|
89
|
-
let { subscribe:
|
|
90
|
-
let e =
|
|
91
|
-
|
|
92
|
-
defaultValue:
|
|
93
|
-
label:
|
|
89
|
+
let r = c(n.defaultValue), { subscribe: i, notify: a } = t(), s = () => {
|
|
90
|
+
let e = r.get();
|
|
91
|
+
return o(n.schema, e, {
|
|
92
|
+
defaultValue: n.defaultValue,
|
|
93
|
+
label: "createSchemaStore",
|
|
94
|
+
onError: n.onValidationError ? (e, t) => n.onValidationError({
|
|
95
|
+
issues: [...e],
|
|
96
|
+
value: t,
|
|
97
|
+
defaultValue: n.defaultValue
|
|
98
|
+
}) : void 0
|
|
94
99
|
});
|
|
95
|
-
return e;
|
|
96
|
-
}, u = e(l, r, i);
|
|
97
|
-
return {
|
|
98
|
-
...u,
|
|
99
|
-
set: (e) => {
|
|
100
|
-
let t = typeof e == "function" ? e(l()) : e;
|
|
101
|
-
s.set(t), i();
|
|
102
|
-
},
|
|
103
|
-
"~": {
|
|
104
|
-
...u["~"],
|
|
105
|
-
getDefaultValue: (e) => a[e]
|
|
106
|
-
}
|
|
107
100
|
};
|
|
108
|
-
}
|
|
109
|
-
function c() {
|
|
110
|
-
let e = l({});
|
|
111
101
|
return {
|
|
112
|
-
|
|
113
|
-
set: (
|
|
114
|
-
e
|
|
102
|
+
...e(s, i, a),
|
|
103
|
+
set: (e) => {
|
|
104
|
+
let t = typeof e == "function" ? e(s()) : e;
|
|
105
|
+
r.set(t), a();
|
|
115
106
|
}
|
|
116
107
|
};
|
|
117
108
|
}
|
|
118
109
|
//#endregion
|
|
119
110
|
//#region src/core/store.ts
|
|
120
|
-
function
|
|
111
|
+
function c(n) {
|
|
121
112
|
let r = n, { subscribe: i, notify: a } = t();
|
|
122
113
|
return {
|
|
123
114
|
...e(() => r, i, a),
|
|
@@ -129,7 +120,7 @@ function l(n) {
|
|
|
129
120
|
}
|
|
130
121
|
//#endregion
|
|
131
122
|
//#region src/core/throttle.ts
|
|
132
|
-
function
|
|
123
|
+
function l(n, r) {
|
|
133
124
|
let i = n.get(), a, o = !1, { subscribe: s, notify: c } = t({ onFirstSubscribe() {
|
|
134
125
|
let e = n.subscribe(() => {
|
|
135
126
|
if (a) {
|
|
@@ -148,7 +139,7 @@ function u(n, r) {
|
|
|
148
139
|
}
|
|
149
140
|
//#endregion
|
|
150
141
|
//#region src/core/throttle-fn.ts
|
|
151
|
-
function
|
|
142
|
+
function u(n, r) {
|
|
152
143
|
let i, a, o, { subscribe: s, notify: c } = t();
|
|
153
144
|
return Object.assign((...e) => {
|
|
154
145
|
if (a) {
|
|
@@ -164,4 +155,4 @@ function d(n, r) {
|
|
|
164
155
|
}, e(() => i, s, c));
|
|
165
156
|
}
|
|
166
157
|
//#endregion
|
|
167
|
-
export {
|
|
158
|
+
export { o as a, r as c, t as d, s as i, n as l, l as n, a as o, c as r, i as s, u as t, e as u };
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { c as e, d as t, i as n, l as r, n as i, r as a, s as o, t as s, u as c } from "./core-CIQELdxV.js";
|
|
2
|
+
export { r as createComputed, e as createDebounce, o as createDebounceFn, c as createReadableSubscription, n as createSchemaStore, a as createStore, t as createSubscription, i as createThrottle, s as createThrottleFn };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import type { ValidationSchemaErrorProps, ValidationSchemaOutput } from '../validate';
|
|
3
|
+
import type { Readable, Subscribable, Writable } from './index';
|
|
4
|
+
export interface SchemaStore<O> extends Subscribable<O>, Readable<O>, Writable<O, O> {
|
|
5
|
+
}
|
|
6
|
+
export interface SchemaStoreOptions<S extends StandardSchemaV1<unknown>> {
|
|
7
|
+
schema: S;
|
|
8
|
+
defaultValue: ValidationSchemaOutput<S>;
|
|
9
|
+
/**
|
|
10
|
+
* Handle validation errors.
|
|
11
|
+
*
|
|
12
|
+
* If returns a value, it will be validated and used as the store value.
|
|
13
|
+
* If returns undefined, the default value will be returned.
|
|
14
|
+
*/
|
|
15
|
+
onValidationError?: (props: ValidationSchemaErrorProps<ValidationSchemaOutput<S>>) => void | ValidationSchemaOutput<S>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Creates a reactive schema store: state is validated on read, supports partial `set`, and
|
|
19
|
+
* falls back to default values when validation fails.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts twoslash
|
|
23
|
+
* import { createSchemaStore } from 'seitu'
|
|
24
|
+
* import * as z from 'zod'
|
|
25
|
+
*
|
|
26
|
+
* const store = createSchemaStore({
|
|
27
|
+
* schema: z.object({ count: z.number(), name: z.string() }),
|
|
28
|
+
* defaultValue: { count: 0, name: '' },
|
|
29
|
+
* })
|
|
30
|
+
* store.get()
|
|
31
|
+
* store.set({ count: 1, name: 'alice' })
|
|
32
|
+
* store.subscribe(console.log)
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function createSchemaStore<S extends StandardSchemaV1<unknown>>(options: SchemaStoreOptions<S>): SchemaStore<ValidationSchemaOutput<S>>;
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
|
|
3
|
-
export type ValidationObjectSchemas = Record<string, StandardSchemaV1<unknown, unknown>>;
|
|
4
|
-
export type ValidationObjectSchemasOutput<S extends ValidationObjectSchemas> = Simplify<{
|
|
5
|
-
[K in keyof S]: StandardSchemaV1.InferOutput<S[K]>;
|
|
6
|
-
}>;
|
|
2
|
+
export type ValidationSchemaOutput<S extends StandardSchemaV1<unknown>> = StandardSchemaV1.InferOutput<S>;
|
|
7
3
|
export interface ValidationSchemaErrorProps<O> {
|
|
8
4
|
defaultValue: O;
|
|
9
5
|
issues: StandardSchemaV1.Issue[];
|
|
10
6
|
value: unknown;
|
|
11
7
|
}
|
|
12
|
-
export interface
|
|
8
|
+
export interface ValidationSchemaObjectErrorProps<O extends Record<string, unknown>> {
|
|
13
9
|
defaultValue: O[keyof O];
|
|
14
10
|
issues: StandardSchemaV1.Issue[];
|
|
15
11
|
value: unknown;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
import type { Readable, Removable, Subscribable, Writable } from '../core/index';
|
|
3
|
-
import type { ValidationSchemaErrorProps,
|
|
3
|
+
import type { ValidationSchemaErrorProps, ValidationSchemaObjectErrorProps } from '../validate';
|
|
4
4
|
import type { WebStorage } from './web-storage';
|
|
5
5
|
export interface WebStorageValue<V> extends Subscribable<V>, Readable<V>, Writable<V>, Removable {
|
|
6
6
|
}
|
|
7
7
|
export interface WebStorageValueOptionsWithStorage<Storage extends WebStorage<any>, K extends keyof Storage['~']['output']> {
|
|
8
8
|
storage: Storage;
|
|
9
9
|
key: K;
|
|
10
|
-
onValidationError?: (props:
|
|
10
|
+
onValidationError?: (props: ValidationSchemaObjectErrorProps<Storage['~']['output']>) => void;
|
|
11
11
|
}
|
|
12
12
|
export interface WebStorageValueOptionsWithSchema<S extends StandardSchemaV1<unknown>> {
|
|
13
13
|
type: 'localStorage' | 'sessionStorage';
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
|
|
2
|
+
import type { Readable, Subscribable, Writable } from '../core/index';
|
|
3
|
+
import type { Simplify } from '../utils';
|
|
4
|
+
import type { ValidationSchemaObjectErrorProps } from '../validate';
|
|
5
|
+
export type WebStorageInput = Record<string, StandardSchemaV1<unknown, unknown>>;
|
|
6
|
+
export type WebStorageOutput<S extends WebStorageInput> = Simplify<{
|
|
7
|
+
[K in keyof S]: StandardSchemaV1.InferOutput<S[K]>;
|
|
8
|
+
}>;
|
|
9
|
+
export interface WebStorageOptions<S extends WebStorageInput> {
|
|
10
|
+
schemas: S;
|
|
11
|
+
defaultValues: WebStorageOutput<S>;
|
|
5
12
|
type: 'localStorage' | 'sessionStorage';
|
|
6
13
|
keyTransform?: (key: keyof S) => string;
|
|
7
|
-
onValidationError?: (props:
|
|
14
|
+
onValidationError?: (props: ValidationSchemaObjectErrorProps<WebStorageOutput<S>>) => void | StandardSchemaV1.InferOutput<S[keyof S]>;
|
|
8
15
|
}
|
|
9
|
-
export interface WebStorage<O extends Record<string, unknown>> extends
|
|
16
|
+
export interface WebStorage<O extends Record<string, unknown>> extends Subscribable<O>, Readable<O>, Writable<Partial<O>, O> {
|
|
10
17
|
'~': {
|
|
11
18
|
getDefaultValue: <K extends keyof O>(key: K) => O[K];
|
|
12
19
|
type: 'localStorage' | 'sessionStorage';
|
|
13
|
-
} &
|
|
20
|
+
} & Subscribable<O>['~'];
|
|
14
21
|
}
|
|
15
22
|
/**
|
|
16
23
|
* Creates a reactive handle for a localStorage or sessionStorage instance.
|
|
@@ -60,4 +67,4 @@ export interface WebStorage<O extends Record<string, unknown>> extends SchemaSto
|
|
|
60
67
|
* }
|
|
61
68
|
* ```
|
|
62
69
|
*/
|
|
63
|
-
export declare function createWebStorage<S extends
|
|
70
|
+
export declare function createWebStorage<S extends WebStorageInput>(options: WebStorageOptions<S>): WebStorage<WebStorageOutput<S>>;
|
package/dist/web.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as e, d as t, o as n, u as r } from "./core-CIQELdxV.js";
|
|
2
2
|
//#region src/web/is-online.ts
|
|
3
3
|
function i() {
|
|
4
|
-
let { subscribe:
|
|
5
|
-
typeof window < "u" && (window.removeEventListener("online",
|
|
4
|
+
let { subscribe: e, notify: n } = t({ onFirstSubscribe: () => (typeof window < "u" && (window.addEventListener("online", n), window.addEventListener("offline", n)), () => {
|
|
5
|
+
typeof window < "u" && (window.removeEventListener("online", n), window.removeEventListener("offline", n));
|
|
6
6
|
}) });
|
|
7
|
-
return
|
|
7
|
+
return r(() => typeof navigator > "u" ? !0 : navigator.onLine, e, n);
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
//#region src/web/media-query.ts
|
|
11
|
-
function a(
|
|
12
|
-
let
|
|
13
|
-
|
|
11
|
+
function a(e) {
|
|
12
|
+
let n = typeof window > "u" ? null : window.matchMedia(e.query), { subscribe: i, notify: a } = t({ onFirstSubscribe: () => (n?.addEventListener("change", a), () => {
|
|
13
|
+
n?.removeEventListener("change", a);
|
|
14
14
|
}) });
|
|
15
|
-
return
|
|
15
|
+
return r(() => n?.matches ?? e.defaultMatches ?? !1, i, a);
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/web/scroll-state.ts
|
|
@@ -66,7 +66,7 @@ function s(e) {
|
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
68
|
//#region src/web/web-storage.ts
|
|
69
|
-
function c(
|
|
69
|
+
function c(n) {
|
|
70
70
|
let i = !1, { subscribe: a, notify: o } = t({ onFirstSubscribe: () => {
|
|
71
71
|
let e = () => {
|
|
72
72
|
i || o();
|
|
@@ -74,40 +74,40 @@ function c(r) {
|
|
|
74
74
|
return typeof window < "u" && window.addEventListener("storage", e), () => {
|
|
75
75
|
typeof window < "u" && window.removeEventListener("storage", e);
|
|
76
76
|
};
|
|
77
|
-
} }), s = { ...
|
|
78
|
-
if (typeof window > "u") return
|
|
79
|
-
let
|
|
80
|
-
for (let n of c) {
|
|
81
|
-
let a = String(r.keyTransform ? r.keyTransform(n) : n), o = e.getItem(a);
|
|
82
|
-
i[n] = o, t && l.get(n) !== o && (t = !1);
|
|
83
|
-
}
|
|
84
|
-
if (t) return u;
|
|
85
|
-
let a = { ...r.defaultValues };
|
|
77
|
+
} }), s = { ...n.defaultValues }, c = Object.keys(n.defaultValues), l = /* @__PURE__ */ new Map(), u, d = () => {
|
|
78
|
+
if (typeof window > "u") return n.defaultValues;
|
|
79
|
+
let t = window[n.type], r = u !== void 0, i = {};
|
|
86
80
|
for (let e of c) {
|
|
87
|
-
let
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
81
|
+
let a = String(n.keyTransform ? n.keyTransform(e) : e), o = t.getItem(a);
|
|
82
|
+
i[e] = o, r && l.get(e) !== o && (r = !1);
|
|
83
|
+
}
|
|
84
|
+
if (r) return u;
|
|
85
|
+
let a = { ...n.defaultValues };
|
|
86
|
+
for (let t of c) {
|
|
87
|
+
let r = i[t];
|
|
88
|
+
r === null ? a[t] = n.defaultValues[t] : a[t] = e(n.schemas[t], r, {
|
|
89
|
+
defaultValue: n.defaultValues[t],
|
|
90
|
+
label: `createWebStorage:${String(t)}`,
|
|
91
|
+
onError: n.onValidationError ? (e, r) => n.onValidationError({
|
|
92
|
+
issues: [...e],
|
|
93
|
+
key: t,
|
|
94
|
+
value: r,
|
|
95
|
+
defaultValue: n.defaultValues[t]
|
|
96
96
|
}) : void 0
|
|
97
|
-
}), l.set(String(
|
|
97
|
+
}), l.set(String(t), i[String(t)]);
|
|
98
98
|
}
|
|
99
99
|
return u = a, a;
|
|
100
|
-
}, f =
|
|
100
|
+
}, f = r(d, a, o);
|
|
101
101
|
return {
|
|
102
102
|
...f,
|
|
103
103
|
set: (e) => {
|
|
104
104
|
let t = typeof e == "function" ? e(d()) : e;
|
|
105
105
|
if (typeof window > "u") return;
|
|
106
|
-
let
|
|
106
|
+
let r = window[n.type];
|
|
107
107
|
i = !0, Object.entries(t).forEach(([e, t]) => {
|
|
108
108
|
let i = typeof t == "string" ? t : JSON.stringify(t);
|
|
109
|
-
|
|
110
|
-
key:
|
|
109
|
+
r.setItem(n.keyTransform ? n.keyTransform(e) : e, i), window.dispatchEvent(new StorageEvent("storage", {
|
|
110
|
+
key: n.keyTransform ? n.keyTransform(e) : e,
|
|
111
111
|
newValue: i
|
|
112
112
|
}));
|
|
113
113
|
}), i = !1, u = void 0, o();
|
|
@@ -115,7 +115,7 @@ function c(r) {
|
|
|
115
115
|
"~": {
|
|
116
116
|
...f["~"],
|
|
117
117
|
getDefaultValue: (e) => s[e],
|
|
118
|
-
type:
|
|
118
|
+
type: n.type
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
}
|
|
@@ -132,12 +132,12 @@ function u(i) {
|
|
|
132
132
|
};
|
|
133
133
|
} }), d = l, f, p = () => {
|
|
134
134
|
if (typeof window > "u") return s;
|
|
135
|
-
let
|
|
136
|
-
if (d !== l &&
|
|
137
|
-
if (d =
|
|
138
|
-
let
|
|
135
|
+
let t = window[a].getItem(i.key);
|
|
136
|
+
if (d !== l && t === d) return f;
|
|
137
|
+
if (d = t, t === null) return f = s, f;
|
|
138
|
+
let r = n(t);
|
|
139
139
|
try {
|
|
140
|
-
return "schema" in i ? (f =
|
|
140
|
+
return "schema" in i ? (f = e(i.schema, t, {
|
|
141
141
|
defaultValue: s,
|
|
142
142
|
label: `createWebStorageValue:${i.key}`,
|
|
143
143
|
onError: i.onValidationError ? (e, t) => i.onValidationError({
|
|
@@ -145,13 +145,13 @@ function u(i) {
|
|
|
145
145
|
issues: [...e],
|
|
146
146
|
value: t
|
|
147
147
|
}) : void 0
|
|
148
|
-
}), f) : (f =
|
|
148
|
+
}), f) : (f = r, f);
|
|
149
149
|
} catch {
|
|
150
|
-
return f = s !== void 0 && typeof s != "string" ? s :
|
|
150
|
+
return f = s !== void 0 && typeof s != "string" ? s : r, f;
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
153
|
return {
|
|
154
|
-
...
|
|
154
|
+
...r(p, c, u),
|
|
155
155
|
set: (e) => {
|
|
156
156
|
if (typeof window > "u") return;
|
|
157
157
|
let t = window[a], n = typeof e == "function" ? e(p()) : e;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "seitu",
|
|
3
3
|
"displayName": "Seitu",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.10.
|
|
5
|
+
"version": "0.10.6",
|
|
6
6
|
"private": false,
|
|
7
7
|
"author": "Valerii Strilets",
|
|
8
8
|
"license": "MIT",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"happy-dom": "^20.8.9",
|
|
82
82
|
"react-dom": "^19.2.4",
|
|
83
83
|
"type-fest": "^5.5.0",
|
|
84
|
-
"typescript": "^
|
|
84
|
+
"typescript": "^6.0.2",
|
|
85
85
|
"vite": "^8.0.3",
|
|
86
86
|
"vite-plugin-dts": "^4.5.4",
|
|
87
87
|
"vitest": "^4.1.2",
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
-
import type { ValidationObjectSchemas, ValidationObjectSchemasOutput } from '../validate';
|
|
3
|
-
import type { Readable, Subscribable, Writable } from './index';
|
|
4
|
-
export interface SchemaStore<O extends Record<string, unknown>> extends Subscribable<O>, Readable<O>, Writable<Partial<O>, O> {
|
|
5
|
-
'~': {
|
|
6
|
-
getDefaultValue: <K extends keyof O>(key: K) => O[K];
|
|
7
|
-
} & Subscribable<O>['~'];
|
|
8
|
-
}
|
|
9
|
-
export interface SchemaStoreOptions<S extends Record<string, StandardSchemaV1>> {
|
|
10
|
-
schemas: S;
|
|
11
|
-
defaultValues: ValidationObjectSchemasOutput<S>;
|
|
12
|
-
/**
|
|
13
|
-
* The provider to use for the schema store. If not provided, the schema store will
|
|
14
|
-
* use an in-memory provider.
|
|
15
|
-
*/
|
|
16
|
-
provider?: SchemaStoreProvider<S>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Creates a reactive schema store: state is validated on read, supports partial `set`, and
|
|
20
|
-
* falls back to default values when validation fails.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts twoslash
|
|
24
|
-
* import { createSchemaStore, createSchemaStoreMemoryProvider } from 'seitu'
|
|
25
|
-
* import * as z from 'zod'
|
|
26
|
-
*
|
|
27
|
-
* const store = createSchemaStore({
|
|
28
|
-
* schemas: { count: z.number(), name: z.string() },
|
|
29
|
-
* defaultValues: { count: 0, name: '' },
|
|
30
|
-
* })
|
|
31
|
-
* store.get()
|
|
32
|
-
* store.set({ count: 1 })
|
|
33
|
-
* store.subscribe(console.log)
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function createSchemaStore<S extends Record<string, StandardSchemaV1>>(options: SchemaStoreOptions<S>): SchemaStore<ValidationObjectSchemasOutput<S>>;
|
|
37
|
-
export interface SchemaStoreProvider<S extends ValidationObjectSchemas> {
|
|
38
|
-
get: () => ValidationObjectSchemasOutput<S>;
|
|
39
|
-
set: (value: Partial<ValidationObjectSchemasOutput<S>>) => void;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Creates an in-memory provider for a schema store. Use as the state backing when you don't
|
|
43
|
-
* need persistence (e.g. for testing or ephemeral UI state).
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```ts twoslash
|
|
47
|
-
* import { createSchemaStore, createSchemaStoreMemoryProvider } from 'seitu'
|
|
48
|
-
* import * as z from 'zod'
|
|
49
|
-
*
|
|
50
|
-
* const store = createSchemaStore({
|
|
51
|
-
* schemas: { count: z.number(), name: z.string() },
|
|
52
|
-
* defaultValues: { count: 0, name: '' },
|
|
53
|
-
* provider: createSchemaStoreMemoryProvider(),
|
|
54
|
-
* })
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare function createSchemaStoreMemoryProvider<S extends ValidationObjectSchemas>(): SchemaStoreProvider<S>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|