vue-context-storage 0.1.44 → 0.1.45

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 CHANGED
@@ -769,12 +769,12 @@ The library introspects the Zod schema before validation and wraps non-array val
769
769
 
770
770
  ```typescript
771
771
  const Schema = z.object({
772
- tags: z.string().array().default([]),
773
- ids: z.number().array().default([]),
774
- statuses: z.enum(['active', 'inactive']).array().default([]),
772
+ tags: z.string().array(),
773
+ ids: z.number().array(),
774
+ statuses: z.enum(['active', 'inactive']).array(),
775
775
  filters: z
776
776
  .object({
777
- categories: z.string().array().default([]),
777
+ categories: z.string().array(),
778
778
  })
779
779
  .default({ categories: [] }),
780
780
  })
@@ -782,7 +782,7 @@ const Schema = z.object({
782
782
  // All of these work automatically:
783
783
  // ?tags=vue → { tags: ['vue'], ... }
784
784
  // ?tags=vue&tags=ts → { tags: ['vue', 'ts'], ... }
785
- // (no tags param) → { tags: [], ... }
785
+ // (no tags param) → { tags: [], ... } (falls back to the value in your reactive state)
786
786
  ```
787
787
 
788
788
  Arrays of objects are also handled automatically. They deserialize from indexed query parameters (`?items[0][product]=Apple`) into indexed objects (`{ '0': { product: 'Apple' } }`), and the library converts them back to arrays sorted by numeric key wherever the schema expects `.array()` — coercion is applied recursively inside array elements as well:
@@ -803,7 +803,7 @@ const Schema = z.object({
803
803
 
804
804
  #### Boolean Coercion
805
805
 
806
- The query handler serializes booleans as `'1'`/`'0'` strings in URL parameters (e.g. `?active=1`). Standard `z.boolean()` cannot be used because `Boolean('0')` is `true` in JavaScript. The library automatically converts `'1'` → `true` and `'0'` → `false` when the schema expects a boolean field. **No special helpers are needed** — plain `z.boolean()` works out of the box:
806
+ The query handler serializes booleans as `'1'`/`'0'` strings in URL parameters (e.g. `?active=1`). Standard `z.coerce.boolean()` cannot be used because `Boolean('0')` is `true` in JavaScript. The library automatically converts `'1'` → `true` and `'0'` → `false` when the schema expects a boolean field. **No special helpers are needed** — plain `z.boolean()` works out of the box:
807
807
 
808
808
  ```typescript
809
809
  const Schema = z.object({
@@ -817,13 +817,13 @@ const Schema = z.object({
817
817
 
818
818
  #### Number Coercion
819
819
 
820
- URL query parameters are always strings (`?page=5` → `'5'`), so plain `z.number()` would reject them with `"expected number, received string"`. The library automatically converts numeric strings to numbers wherever the schema expects a number — including inside nested objects and `z.array(z.number())`. **`z` is not required** — plain `z.number()` works out of the box:
820
+ URL query parameters are always strings (`?page=5` → `'5'`), so plain `z.number()` would reject them with `"expected number, received string"`. The library automatically converts numeric strings to numbers wherever the schema expects a number — including inside nested objects and `z.array(z.number())`. **`z.coerce` is not required** — plain `z.number()` works out of the box:
821
821
 
822
822
  ```typescript
823
823
  const Schema = z.object({
824
824
  page: z.number().default(1),
825
825
  score: z.number().nullable(),
826
- ids: z.array(z.number()).default([]),
826
+ ids: z.array(z.number()),
827
827
  })
828
828
 
829
829
  // ?page=5 → { page: 5, ... }
@@ -833,7 +833,7 @@ const Schema = z.object({
833
833
 
834
834
  Coercion is conservative: a non-numeric string (`?page=abc`) or an empty value is **not** forced to a number (`Number('')` would be `0`). Instead the schema validation fails and the field falls back to its initial data, so missing/garbage input never silently becomes `0`. `null` is preserved for `.nullable()` fields.
835
835
 
836
- > `z.number()` still works and remains useful when you want Zod's own coercion semantics (e.g. coercing booleans or accepting empty strings as `0`).
836
+ > `z.coerce.number()` still works and remains useful when you want Zod's own coercion semantics (e.g. coercing booleans or accepting empty strings as `0`).
837
837
 
838
838
  ### `createEmptyZodObject(schema, options?)`
839
839
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import * as vue0 from "vue";
1
+ import * as vue9 from "vue";
2
2
  import { ComputedRef, InjectionKey, MaybeRefOrGetter, Plugin, PropType, UnwrapNestedRefs } from "vue";
3
3
  import { LocationQuery, LocationQueryValue } from "vue-router";
4
4
  import { ZodObject, ZodRawShape, z } from "zod";
5
5
 
6
6
  //#region src/components/ContextStorageActivator.vue.d.ts
7
7
  declare const _default$1: typeof __VLS_export$4;
8
- declare const __VLS_export$4: vue0.DefineComponent<{}, () => vue0.VNode<vue0.RendererNode, vue0.RendererElement, {
8
+ declare const __VLS_export$4: vue9.DefineComponent<{}, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
9
9
  [key: string]: any;
10
- }>, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
10
+ }>, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
11
11
  //#endregion
12
12
  //#region src/handlers/types.d.ts
13
13
  interface HandlerSchema<T> {
@@ -66,7 +66,7 @@ interface ContextStorageHandler<T, O> {
66
66
  //#endregion
67
67
  //#region src/components/ContextStorageCollection.vue.d.ts
68
68
  declare const _default$2: typeof __VLS_export$3;
69
- declare const __VLS_export$3: vue0.DefineComponent<vue0.ExtractPropTypes<{
69
+ declare const __VLS_export$3: vue9.DefineComponent<vue9.ExtractPropTypes<{
70
70
  handlers: {
71
71
  type: PropType<ContextStorageHandlerFactory[]>;
72
72
  default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
@@ -82,9 +82,9 @@ declare const __VLS_export$3: vue0.DefineComponent<vue0.ExtractPropTypes<{
82
82
  type: PropType<ContextStorageHandlerFactory[]>;
83
83
  default: undefined;
84
84
  };
85
- }>, () => vue0.VNode<vue0.RendererNode, vue0.RendererElement, {
85
+ }>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
86
86
  [key: string]: any;
87
- }>[] | undefined, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<vue0.ExtractPropTypes<{
87
+ }>[] | undefined, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
88
88
  handlers: {
89
89
  type: PropType<ContextStorageHandlerFactory[]>;
90
90
  default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
@@ -103,27 +103,27 @@ declare const __VLS_export$3: vue0.DefineComponent<vue0.ExtractPropTypes<{
103
103
  }>> & Readonly<{}>, {
104
104
  handlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
105
105
  additionalHandlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
106
- }, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
106
+ }, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
107
107
  //#endregion
108
108
  //#region src/components/ContextStorageProvider.vue.d.ts
109
109
  declare const _default$4: typeof __VLS_export$2;
110
- declare const __VLS_export$2: vue0.DefineComponent<vue0.ExtractPropTypes<{
110
+ declare const __VLS_export$2: vue9.DefineComponent<vue9.ExtractPropTypes<{
111
111
  itemKey: {
112
112
  type: StringConstructor;
113
113
  required: true;
114
114
  };
115
- }>, () => vue0.VNode<vue0.RendererNode, vue0.RendererElement, {
115
+ }>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
116
116
  [key: string]: any;
117
- }>[] | undefined, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<vue0.ExtractPropTypes<{
117
+ }>[] | undefined, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
118
118
  itemKey: {
119
119
  type: StringConstructor;
120
120
  required: true;
121
121
  };
122
- }>> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
122
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
123
123
  //#endregion
124
124
  //#region src/components/ContextStorage.vue.d.ts
125
125
  declare const _default: typeof __VLS_export$1;
126
- declare const __VLS_export$1: vue0.DefineComponent<vue0.ExtractPropTypes<{
126
+ declare const __VLS_export$1: vue9.DefineComponent<vue9.ExtractPropTypes<{
127
127
  handlers: {
128
128
  type: PropType<ContextStorageHandlerFactory[]>;
129
129
  default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
@@ -139,9 +139,9 @@ declare const __VLS_export$1: vue0.DefineComponent<vue0.ExtractPropTypes<{
139
139
  type: PropType<ContextStorageHandlerFactory[]>;
140
140
  default: undefined;
141
141
  };
142
- }>, () => vue0.VNode<vue0.RendererNode, vue0.RendererElement, {
142
+ }>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
143
143
  [key: string]: any;
144
- }>[] | undefined, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<vue0.ExtractPropTypes<{
144
+ }>[] | undefined, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
145
145
  handlers: {
146
146
  type: PropType<ContextStorageHandlerFactory[]>;
147
147
  default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
@@ -160,7 +160,7 @@ declare const __VLS_export$1: vue0.DefineComponent<vue0.ExtractPropTypes<{
160
160
  }>> & Readonly<{}>, {
161
161
  handlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
162
162
  additionalHandlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
163
- }, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
163
+ }, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
164
164
  //#endregion
165
165
  //#region src/prefix.d.ts
166
166
  /**
@@ -182,19 +182,19 @@ declare const contextStoragePrefixSegmentsInjectKey: InjectionKey<MaybeRefOrGett
182
182
  //#endregion
183
183
  //#region src/components/ContextStoragePrefix.vue.d.ts
184
184
  declare const _default$3: typeof __VLS_export;
185
- declare const __VLS_export: vue0.DefineComponent<vue0.ExtractPropTypes<{
185
+ declare const __VLS_export: vue9.DefineComponent<vue9.ExtractPropTypes<{
186
186
  name: {
187
187
  type: PropType<ContextStoragePrefixSegment>;
188
188
  required: true;
189
189
  };
190
- }>, () => vue0.VNode<vue0.RendererNode, vue0.RendererElement, {
190
+ }>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
191
191
  [key: string]: any;
192
- }>, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<vue0.ExtractPropTypes<{
192
+ }>, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
193
193
  name: {
194
194
  type: PropType<ContextStoragePrefixSegment>;
195
195
  required: true;
196
196
  };
197
- }>> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
197
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
198
198
  //#endregion
199
199
  //#region src/plugin.d.ts
200
200
  declare const VueContextStoragePlugin: Plugin;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vue-context-storage",
3
3
  "type": "module",
4
- "version": "0.1.44",
4
+ "version": "0.1.45",
5
5
  "description": "Vue 3 reactive state management — sync state with the URL query, localStorage, and sessionStorage",
6
6
  "author": "",
7
7
  "license": "MIT",