seitu 0.10.5 → 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.
Files changed (29) hide show
  1. package/dist/{core-DSqQS36s.js → core-CIQELdxV.js} +8 -15
  2. package/dist/core.js +1 -1
  3. package/dist/{core → src/core}/schema-store.d.ts +9 -12
  4. package/dist/{validate.d.ts → src/validate.d.ts} +2 -6
  5. package/dist/{web → src/web}/web-storage-value.d.ts +2 -2
  6. package/dist/{web → src/web}/web-storage.d.ts +10 -5
  7. package/dist/web.js +1 -1
  8. package/package.json +2 -2
  9. /package/dist/{core → src/core}/computed.d.ts +0 -0
  10. /package/dist/{core → src/core}/debounce-fn.d.ts +0 -0
  11. /package/dist/{core → src/core}/debounce.d.ts +0 -0
  12. /package/dist/{core → src/core}/index.d.ts +0 -0
  13. /package/dist/{core → src/core}/store.d.ts +0 -0
  14. /package/dist/{core → src/core}/subscription.d.ts +0 -0
  15. /package/dist/{core → src/core}/throttle-fn.d.ts +0 -0
  16. /package/dist/{core → src/core}/throttle.d.ts +0 -0
  17. /package/dist/{react → src/react}/components.d.ts +0 -0
  18. /package/dist/{react → src/react}/hooks.d.ts +0 -0
  19. /package/dist/{react → src/react}/index.d.ts +0 -0
  20. /package/dist/{utils → src/utils}/index.d.ts +0 -0
  21. /package/dist/{utils → src/utils}/validation.d.ts +0 -0
  22. /package/dist/{utils.d.ts → src/utils.d.ts} +0 -0
  23. /package/dist/{vue → src/vue}/composables.d.ts +0 -0
  24. /package/dist/{vue → src/vue}/index.d.ts +0 -0
  25. /package/dist/{vue → src/vue}/test-utils.d.ts +0 -0
  26. /package/dist/{web → src/web}/index.d.ts +0 -0
  27. /package/dist/{web → src/web}/is-online.d.ts +0 -0
  28. /package/dist/{web → src/web}/media-query.d.ts +0 -0
  29. /package/dist/{web → src/web}/scroll-state.d.ts +0 -0
@@ -86,30 +86,23 @@ function o(e, t, n) {
86
86
  //#endregion
87
87
  //#region src/core/schema-store.ts
88
88
  function s(n) {
89
- let r = c(n.defaultValue), { subscribe: i, notify: a } = t(), s = { ...n.defaultValue }, l = () => {
90
- let e = r.get(), t = {
91
- ...s,
92
- ...e
93
- };
94
- return o(n.schema, t, {
95
- defaultValue: s,
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,
96
93
  label: "createSchemaStore",
97
94
  onError: n.onValidationError ? (e, t) => n.onValidationError({
98
95
  issues: [...e],
99
96
  value: t,
100
- defaultValue: s
97
+ defaultValue: n.defaultValue
101
98
  }) : void 0
102
99
  });
103
- }, u = e(l, i, a);
100
+ };
104
101
  return {
105
- ...u,
102
+ ...e(s, i, a),
106
103
  set: (e) => {
107
- let t = typeof e == "function" ? e(l()) : e;
104
+ let t = typeof e == "function" ? e(s()) : e;
108
105
  r.set(t), a();
109
- },
110
- "~": {
111
- ...u["~"],
112
- getDefaultValue: (e) => s[e]
113
106
  }
114
107
  };
115
108
  }
package/dist/core.js CHANGED
@@ -1,2 +1,2 @@
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-DSqQS36s.js";
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
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 };
@@ -1,21 +1,18 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
- import type { ValidationSchemaErrorProps } from '../validate';
2
+ import type { ValidationSchemaErrorProps, ValidationSchemaOutput } from '../validate';
3
3
  import type { Readable, Subscribable, Writable } from './index';
4
- export interface SchemaStore<O extends Record<string, unknown>> extends Subscribable<O>, Readable<O>, Writable<O> {
5
- '~': {
6
- getDefaultValue: <K extends keyof O>(key: K) => O[K];
7
- } & Subscribable<O>['~'];
4
+ export interface SchemaStore<O> extends Subscribable<O>, Readable<O>, Writable<O, O> {
8
5
  }
9
- export interface SchemaStoreOptions<O extends Record<string, unknown>> {
10
- schema: StandardSchemaV1<unknown, O>;
11
- defaultValue: O;
6
+ export interface SchemaStoreOptions<S extends StandardSchemaV1<unknown>> {
7
+ schema: S;
8
+ defaultValue: ValidationSchemaOutput<S>;
12
9
  /**
13
10
  * Handle validation errors.
14
11
  *
15
12
  * If returns a value, it will be validated and used as the store value.
16
13
  * If returns undefined, the default value will be returned.
17
14
  */
18
- onValidationError?: (props: ValidationSchemaErrorProps<O>) => void | O;
15
+ onValidationError?: (props: ValidationSchemaErrorProps<ValidationSchemaOutput<S>>) => void | ValidationSchemaOutput<S>;
19
16
  }
20
17
  /**
21
18
  * Creates a reactive schema store: state is validated on read, supports partial `set`, and
@@ -23,7 +20,7 @@ export interface SchemaStoreOptions<O extends Record<string, unknown>> {
23
20
  *
24
21
  * @example
25
22
  * ```ts twoslash
26
- * import { createSchemaStore, createSchemaStoreMemoryProvider } from 'seitu'
23
+ * import { createSchemaStore } from 'seitu'
27
24
  * import * as z from 'zod'
28
25
  *
29
26
  * const store = createSchemaStore({
@@ -31,8 +28,8 @@ export interface SchemaStoreOptions<O extends Record<string, unknown>> {
31
28
  * defaultValue: { count: 0, name: '' },
32
29
  * })
33
30
  * store.get()
34
- * store.set({ count: 1 })
31
+ * store.set({ count: 1, name: 'alice' })
35
32
  * store.subscribe(console.log)
36
33
  * ```
37
34
  */
38
- export declare function createSchemaStore<O extends Record<string, unknown>>(options: SchemaStoreOptions<O>): SchemaStore<O>;
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
- import type { Simplify } from './utils';
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 ValidationSchemasErrorProps<O extends Record<string, unknown>> {
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, ValidationSchemasErrorProps } from '../validate';
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: ValidationSchemasErrorProps<Storage['~']['output']>) => void;
10
+ onValidationError?: (props: ValidationSchemaObjectErrorProps<Storage['~']['output']>) => void;
11
11
  }
12
12
  export interface WebStorageValueOptionsWithSchema<S extends StandardSchemaV1<unknown>> {
13
13
  type: 'localStorage' | 'sessionStorage';
@@ -1,12 +1,17 @@
1
1
  import type { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import type { Readable, Subscribable, Writable } from '../core/index';
3
- import type { ValidationObjectSchemas, ValidationObjectSchemasOutput, ValidationSchemasErrorProps } from '../validate';
4
- export interface WebStorageOptions<S extends ValidationObjectSchemas> {
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> {
5
10
  schemas: S;
6
- defaultValues: ValidationObjectSchemasOutput<S>;
11
+ defaultValues: WebStorageOutput<S>;
7
12
  type: 'localStorage' | 'sessionStorage';
8
13
  keyTransform?: (key: keyof S) => string;
9
- onValidationError?: (props: ValidationSchemasErrorProps<ValidationObjectSchemasOutput<S>>) => void | StandardSchemaV1.InferOutput<S[keyof S]>;
14
+ onValidationError?: (props: ValidationSchemaObjectErrorProps<WebStorageOutput<S>>) => void | StandardSchemaV1.InferOutput<S[keyof S]>;
10
15
  }
11
16
  export interface WebStorage<O extends Record<string, unknown>> extends Subscribable<O>, Readable<O>, Writable<Partial<O>, O> {
12
17
  '~': {
@@ -62,4 +67,4 @@ export interface WebStorage<O extends Record<string, unknown>> extends Subscriba
62
67
  * }
63
68
  * ```
64
69
  */
65
- export declare function createWebStorage<S extends ValidationObjectSchemas>(options: WebStorageOptions<S>): WebStorage<ValidationObjectSchemasOutput<S>>;
70
+ export declare function createWebStorage<S extends WebStorageInput>(options: WebStorageOptions<S>): WebStorage<WebStorageOutput<S>>;
package/dist/web.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, d as t, o as n, u as r } from "./core-DSqQS36s.js";
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
4
  let { subscribe: e, notify: n } = t({ onFirstSubscribe: () => (typeof window < "u" && (window.addEventListener("online", n), window.addEventListener("offline", n)), () => {
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",
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": "^5.9.3",
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",
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