@appkit/dek-plugin 0.12.0 → 0.14.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/index.es.js CHANGED
@@ -439,11 +439,14 @@ function usePluginState(api2, key, defaultValue) {
439
439
  }
440
440
  return [
441
441
  value,
442
- (newValue) => {
443
- if (typeof newValue === "object") {
444
- newValue = JSON.stringify(newValue);
442
+ (newValueOrFn) => {
443
+ if (typeof newValueOrFn === "function") {
444
+ newValueOrFn = newValueOrFn(value);
445
445
  }
446
- setState(integrationKey, key, newValue);
446
+ if (typeof newValueOrFn === "object") {
447
+ newValueOrFn = JSON.stringify(newValueOrFn);
448
+ }
449
+ setState(integrationKey, key, newValueOrFn);
447
450
  }
448
451
  ];
449
452
  }
package/dist/index.umd.js CHANGED
@@ -442,11 +442,14 @@ var __publicField = (obj, key, value) => {
442
442
  }
443
443
  return [
444
444
  value,
445
- (newValue) => {
446
- if (typeof newValue === "object") {
447
- newValue = JSON.stringify(newValue);
445
+ (newValueOrFn) => {
446
+ if (typeof newValueOrFn === "function") {
447
+ newValueOrFn = newValueOrFn(value);
448
448
  }
449
- setState(integrationKey, key, newValue);
449
+ if (typeof newValueOrFn === "object") {
450
+ newValueOrFn = JSON.stringify(newValueOrFn);
451
+ }
452
+ setState(integrationKey, key, newValueOrFn);
450
453
  }
451
454
  ];
452
455
  }
@@ -1,10 +1,11 @@
1
1
  import { DekApi } from '../api';
2
2
  import { DekApiStateType } from '../state';
3
- export type ApiSetStateAction = (value: DekApiStateType) => void;
4
- declare function usePluginState(api: DekApi, key: string): [DekApiStateType | undefined, ApiSetStateAction];
5
- declare function usePluginState(api: DekApi, key: string, defaultValue: string): [string, ApiSetStateAction];
6
- declare function usePluginState(api: DekApi, key: string, defaultValue: number): [number, ApiSetStateAction];
7
- declare function usePluginState(api: DekApi, key: string, defaultValue: boolean): [boolean, ApiSetStateAction];
8
- declare function usePluginState(api: DekApi, key: string, defaultValue: Array<any>): [Array<any>, ApiSetStateAction];
9
- declare function usePluginState(api: DekApi, key: string, defaultValue: Record<string, any>): [Record<string, any>, ApiSetStateAction];
3
+ export type DekApiStateSetFunc = (value: DekApiStateType) => DekApiStateType;
4
+ export type DekApiStateSetter = (newValueOrFn: DekApiStateType | DekApiStateSetFunc) => void;
5
+ declare function usePluginState(api: DekApi, key: string): [DekApiStateType | undefined, DekApiStateSetter];
6
+ declare function usePluginState(api: DekApi, key: string, defaultValue: string): [string, DekApiStateSetter];
7
+ declare function usePluginState(api: DekApi, key: string, defaultValue: number): [number, DekApiStateSetter];
8
+ declare function usePluginState(api: DekApi, key: string, defaultValue: boolean): [boolean, DekApiStateSetter];
9
+ declare function usePluginState(api: DekApi, key: string, defaultValue: Array<any>): [Array<any>, DekApiStateSetter];
10
+ declare function usePluginState(api: DekApi, key: string, defaultValue: Record<string, any>): [Record<string, any>, DekApiStateSetter];
10
11
  export default usePluginState;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appkit/dek-plugin",
3
3
  "private": false,
4
- "version": "0.12.0",
4
+ "version": "0.14.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",