wacom 21.1.25 → 21.2.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 CHANGED
@@ -713,224 +713,179 @@ httpService.unlock();
713
713
 
714
714
  ## [Store Service](#store-service)
715
715
 
716
- The `StoreService` manages local storage in a configurable manner. It can set, get, and remove items from storage, with support for asynchronous operations and JSON serialization.
716
+ `StoreService` provides a unified, async-first API for working with storage (localStorage by default or a custom provider via config).
717
+ It supports raw values, safe JSON handling, key prefixing, and optional lifecycle hooks.
717
718
 
718
- ### Properties
719
-
720
- #### `_prefix: string`
721
-
722
- The prefix for storage keys.
719
+ ---
723
720
 
724
- ### Methods
721
+ ### Key features
725
722
 
726
- #### `setPrefix(prefix: string): void`
723
+ - async/await everywhere (no separate `*Async` methods)
724
+ - optional side-effects via `options`
725
+ - automatic JSON corruption handling
726
+ - configurable storage backend
727
+ - prefix support for namespacing
727
728
 
728
- Sets the prefix for storage keys.
729
- **Parameters**:
729
+ ---
730
730
 
731
- - `prefix` (string): The prefix to set.
731
+ ### Prefixing keys
732
732
 
733
- **Example**:
734
-
735
- ```Typescript
736
- storeService.setPrefix('app_');
733
+ ```ts
734
+ storeService.setPrefix("app_");
737
735
  ```
738
736
 
739
- #### `set(key: string, value: string, callback: () => void = () => {}, errCallback: () => void = () => {}): void`
740
-
741
- Sets a value in storage.
737
+ All keys will be stored as `app_<key>` (plus global config prefix if defined).
742
738
 
743
- **Parameters**:
739
+ ---
744
740
 
745
- - `key` (string): The storage key.
746
- - `value` (string): The value to store.
747
- - `callback` (function): The callback to execute on success.
748
- - `errCallback` (function): The callback to execute on error.
741
+ ### set
749
742
 
750
- **Example**:
743
+ Stores a raw string value.
751
744
 
752
- ```Typescript
753
- storeService.set('key', 'value', () => console.log('Success'), () => console.log('Error'));
745
+ ```ts
746
+ await storeService.set("token", "abc123");
754
747
  ```
755
748
 
756
- #### `setAsync(key: string, value: string): Promise<boolean>`
757
-
758
- Sets a value in storage asynchronously.
759
-
760
- **Parameters**:
761
-
762
- - `key` (string): The storage key.
763
- - `value` (string): The value to store.
764
-
765
- **Returns**:
766
-
767
- - `Promise<boolean>`: A promise that resolves to a boolean indicating success.
768
-
769
- **Example**:
749
+ With hooks:
770
750
 
771
- ```Typescript
772
- await storeService.setAsync('key', 'value');
751
+ ```ts
752
+ await storeService.set("token", "abc123", {
753
+ onSuccess: () => console.log("saved"),
754
+ onError: console.error,
755
+ });
773
756
  ```
774
757
 
775
- #### `get(key: string, callback: (value: string) => void = () => {}, errCallback: () => void = () => {}): void`
758
+ **Returns:** `Promise<boolean>`
776
759
 
777
- Gets a value from storage.
778
-
779
- **Parameters**:
760
+ ---
780
761
 
781
- - `key` (string): The storage key.
782
- - `callback` (function): The callback to execute with the retrieved value.
783
- - `errCallback` (function): The callback to execute on error.
762
+ ### get
784
763
 
785
- **Example**:
764
+ Retrieves a raw string value.
786
765
 
787
- ```Typescript
788
- storeService.get('key', value => console.log(value), () => console.log('Error'));
766
+ ```ts
767
+ const token = await storeService.get("token");
789
768
  ```
790
769
 
791
- #### `getAsync(key: string): Promise<string | null>`
792
-
793
- Gets a value from storage asynchronously.
794
-
795
- **Parameters**:
796
-
797
- - `key` (string): The storage key.
798
-
799
- **Returns**:
800
-
801
- - `Promise<string | null>`: A promise that resolves to the retrieved value or `null` if the key is missing.
802
-
803
- **Example**:
770
+ With hooks:
804
771
 
805
- ```Typescript
806
- const value = await storeService.getAsync('key');
772
+ ```ts
773
+ const token = await storeService.get("token", {
774
+ onSuccess: (v) => console.log(v),
775
+ onError: console.error,
776
+ });
807
777
  ```
808
778
 
809
- #### `setJson(key: string, value: any, callback: () => void = () => {}, errCallback: () => void = () => {}): void`
779
+ **Returns:** `Promise<string | null>`
810
780
 
811
- Sets a JSON value in storage.
812
-
813
- **Parameters**:
781
+ ---
814
782
 
815
- - `key` (string): The storage key.
816
- - `value` (any): The value to store.
817
- - `callback` (function): The callback to execute on success.
818
- - `errCallback` (function): The callback to execute on error.
783
+ ### setJson
819
784
 
820
- **Example**:
785
+ Stores a JSON-serializable value.
821
786
 
822
- ```Typescript
823
- storeService.setJson('key', { data: 'value' }, () => console.log('Success'), () => console.log('Error'));
787
+ ```ts
788
+ await storeService.setJson("profile", { name: "Den", role: "dev" });
824
789
  ```
825
790
 
826
- #### `setJsonAsync(key: string, value: any): Promise<boolean>`
827
-
828
- Sets a JSON value in storage asynchronously.
829
-
830
- **Parameters**:
831
-
832
- - `key` (string): The storage key.
833
- - `value` (any): The value to store.
791
+ With hooks:
834
792
 
835
- **Returns**:
836
-
837
- - `Promise<boolean>`: A promise that resolves to a boolean indicating success.
838
-
839
- **Example**:
840
-
841
- ```Typescript
842
- await storeService.setJsonAsync('key', { data: 'value' });
793
+ ```ts
794
+ await storeService.setJson("profile", user, {
795
+ onSuccess: () => console.log("saved"),
796
+ onError: console.error,
797
+ });
843
798
  ```
844
799
 
845
- #### `getJson(key: string, callback: (value: any) => void = () => {}, errCallback: () => void = () => {}): void`
800
+ **Returns:** `Promise<boolean>`
846
801
 
847
- Gets a JSON value from storage.
802
+ ---
848
803
 
849
- **Parameters**:
804
+ ### getJson
850
805
 
851
- - `key` (string): The storage key.
852
- - `callback` (function): The callback to execute with the retrieved value.
853
- - `errCallback` (function): The callback to execute on error.
806
+ Retrieves a JSON value safely.
854
807
 
855
- **Example**:
808
+ - empty or missing → `null` (or `defaultValue`)
809
+ - corrupted JSON → auto-cleared (by default)
856
810
 
857
- ```Typescript
858
- storeService.getJson('key', value => console.log(value), () => console.log('Error'));
811
+ ```ts
812
+ const profile = await storeService.getJson<User>("profile");
859
813
  ```
860
814
 
861
- #### `getJsonAsync<T = any>(key: string): Promise<T | null>`
862
-
863
- Gets a JSON value from storage asynchronously.
815
+ With defaults and error handling:
864
816
 
865
- **Parameters**:
866
-
867
- - `key` (string): The storage key.
868
-
869
- **Returns**:
870
-
871
- - `Promise<T | null>`: A promise that resolves to the retrieved value.
872
-
873
- **Example**:
874
-
875
- ```Typescript
876
- const value = await storeService.getJsonAsync('key');
817
+ ```ts
818
+ const profile = await storeService.getJson<User>("profile", {
819
+ defaultValue: {},
820
+ onError: console.warn,
821
+ });
877
822
  ```
878
823
 
879
- #### `remove(key: string, callback?: () => void, errCallback?: () => void): Promise<boolean>`
824
+ Disable auto-clean:
880
825
 
881
- Removes a value from storage.
882
-
883
- **Parameters**:
826
+ ```ts
827
+ await storeService.getJson("profile", {
828
+ clearOnError: false,
829
+ });
830
+ ```
884
831
 
885
- - `key` (string): The storage key.
886
- - `callback` (function): The callback to execute on success.
887
- - `errCallback` (function): The callback to execute on error.
832
+ **Returns:** `Promise<T | null>`
888
833
 
889
- **Returns**:
834
+ ---
890
835
 
891
- - `Promise<boolean>`: A promise that resolves to a boolean indicating success.
836
+ ### remove
892
837
 
893
- **Example**:
838
+ Removes a single key.
894
839
 
895
- ```Typescript
896
- await storeService.remove('key', () => console.log('Success'), () => console.log('Error'));
840
+ ```ts
841
+ await storeService.remove("token");
897
842
  ```
898
843
 
899
- #### `clear(callback?: () => void, errCallback?: () => void): Promise<boolean>`
844
+ With hooks:
900
845
 
901
- Clears all values from storage.
902
-
903
- **Parameters**:
846
+ ```ts
847
+ await storeService.remove("token", {
848
+ onSuccess: () => console.log("removed"),
849
+ onError: console.error,
850
+ });
851
+ ```
904
852
 
905
- - `callback` (function): The callback to execute on success.
906
- - `errCallback` (function): The callback to execute on error.
853
+ **Returns:** `Promise<boolean>`
907
854
 
908
- **Returns**:
855
+ ---
909
856
 
910
- - `Promise<boolean>`: A promise that resolves to a boolean indicating success.
857
+ ### clear
911
858
 
912
- **Example**:
859
+ Clears all stored values.
913
860
 
914
- ```Typescript
915
- await storeService.clear(() => console.log('Success'), () => console.log('Error'));
861
+ ```ts
862
+ await storeService.clear();
916
863
  ```
917
864
 
918
- #### `applyPrefix(key: string): string`
919
-
920
- Applies the configured prefix to a storage key.
865
+ With hooks:
921
866
 
922
- **Parameters**:
867
+ ```ts
868
+ await storeService.clear({
869
+ onSuccess: () => console.log("cleared"),
870
+ onError: console.error,
871
+ });
872
+ ```
923
873
 
924
- - `key` (string): The storage key.
874
+ **Returns:** `Promise<boolean>`
925
875
 
926
- **Returns**:
876
+ ---
927
877
 
928
- - `string`: The prefixed storage key.
878
+ ### Options object
929
879
 
930
- **Example**:
880
+ All methods accept an optional `options` parameter:
931
881
 
932
- ```Typescript
933
- const prefixedKey = storeService.applyPrefix('key');
882
+ ```ts
883
+ interface StoreOptions<T = unknown> {
884
+ onSuccess?: (value?: T | null) => void;
885
+ onError?: (err: unknown) => void;
886
+ defaultValue?: T; // getJson only
887
+ clearOnError?: boolean; // getJson only (default: true)
888
+ }
934
889
  ```
935
890
 
936
891
  ## [Meta Service](#meta-service)