@webkrafters/react-observable-context 4.1.0-alpha.2 → 4.1.0-alpha.3

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.
@@ -3,7 +3,7 @@ export type Listener<T extends import("../../../types").State> = import("../../.
3
3
  export type State = import("../../../types").State;
4
4
  export type StoreInternal<T extends import("../../../types").State> = import("../../../types").StoreInternal<T>;
5
5
  declare function useStateManager<T extends import("../../../types").State>(initStateValue: T): {
6
- select: (clientId: string, ...propertyPaths?: string[]) => {
6
+ select: (clientId: string, ...propertyPaths?: import("../../../types").PropertyPathTokens) => {
7
7
  [propertyPaths: string]: Readonly<any>;
8
8
  };
9
9
  state: T;
@@ -12,10 +12,10 @@ export type State = import("../../../types").State;
12
12
  export type MutableRefObject<T> = import('react').MutableRefObject<T>;
13
13
  import _setState from "../../set-state";
14
14
  declare function useStore<T extends import("../../../types").State>(prehooks: Prehooks<T>, value: T, storage?: IStorage<T>): {
15
- getState: (clientId: string, ...propertyPaths?: string[]) => {
15
+ getState: (clientId: string, ...propertyPaths?: import("../../../types").PropertyPathTokens) => {
16
16
  [propertyPaths: string]: Readonly<any>;
17
17
  };
18
- resetState: (propertyPaths?: string[]) => void;
18
+ resetState: (propertyPaths?: any[]) => void;
19
19
  setState: (changes: import("../../../types").UpdatePayload<import("../../../types").PartialState<T>>) => void;
20
20
  subscribe: (listener: import("../../../types").Listener<T>) => VoidFunction;
21
21
  unlinkCache: (clientId: string) => void;
@@ -70,7 +70,7 @@ export type SelectorMap<T extends import("../types").State> = {
70
70
  export type StoreInternal<T extends import("../types").State> = import("../types").StoreInternal<T>;
71
71
  export type PartialStore<T extends import("../types").State> = {
72
72
  data?: import("../types").Data;
73
- resetState?: (propertyPaths?: string[]) => void;
73
+ resetState?: (propertyPaths?: any[]) => void;
74
74
  setState?: (changes: import("../types").UpdatePayload<import("../types").PartialState<T>>) => void;
75
75
  };
76
76
  export type Store<T extends import("../types").State> = import("../types").Store<T>;
@@ -1,7 +1,7 @@
1
1
  export default setState;
2
2
  export type TagKey = import("./tag-functions").TagKey;
3
- export type HasArrayRoot<K extends KeyTypes = string> = HasRoot<K, Array<any>>;
4
- export type HasObjectRoot<K extends KeyTypes = string> = K extends number ? {
3
+ export type HasArrayRoot<K extends import("../../types").KeyType = string> = HasRoot<K, Array<any>>;
4
+ export type HasObjectRoot<K extends import("../../types").KeyType = string> = K extends number ? {
5
5
  [rootKey: number]: {
6
6
  [x: string]: any;
7
7
  };
@@ -16,14 +16,14 @@ export type HasObjectRoot<K extends KeyTypes = string> = K extends number ? {
16
16
  [x: string]: any;
17
17
  };
18
18
  };
19
- export type HasRoot<K extends KeyTypes = string, T> = K extends number ? {
19
+ export type HasRoot<K extends import("../../types").KeyType = string, T> = K extends number ? {
20
20
  [rootKey: number]: T;
21
21
  } | [T] : K extends string ? {
22
22
  [rootKey: string]: T;
23
23
  } : {
24
24
  [rootKey: symbol]: T;
25
25
  };
26
- export type KeyTypes = number | string | symbol;
26
+ export type KeyType = import("../../types").KeyType;
27
27
  export type Listener<T extends import("../../types").State> = import("../../types").Listener<T>;
28
28
  export type UpdatePayload<T> = import("../../types").UpdatePayload<T>;
29
29
  export type PartialState<T extends import("../../types").State> = import("../../types").PartialState<T>;
@@ -1,4 +1,4 @@
1
- export function $clear(state: T, stateKey: K, stats: Stats, changes: (import("../../../types").ClearCommand | import("../../../types").BaseType)[] | (T & { [K_1 in K]: import("../../../types").ClearCommand & {
1
+ export function $clear(state: T, stateKey: K, stats: Stats, changes: (import("../../../types").BaseType | import("../../../types").ClearCommand)[] | (T & { [K_1 in K]: import("../../../types").ClearCommand & {
2
2
  [x: string]: any;
3
3
  }; })): void;
4
4
  export const $delete: TagFunction<T, K, import("../../../types").DeleteCommand<T[K]>>;
@@ -290,7 +290,7 @@ exports["default"] = _default;
290
290
  var isClosedTag = function () {
291
291
  var NO_PARAM_TAGS = _defineProperty({}, _constants.CLEAR_TAG, null);
292
292
  return function (tag) {
293
- return tag in NO_PARAM_TAGS;
293
+ return tag in NO_PARAM_TAGS && !Array.isArray(tag);
294
294
  };
295
295
  }();
296
296
  exports.isClosedTag = isClosedTag;
package/dist/types.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  declare const _default: any;
2
2
  export default _default;
3
+ export type BaseType = any[] | {
4
+ [x: string]: any;
5
+ } | Scalar;
3
6
  export type Data = {
4
7
  [selectorKey: string]: Readonly<any>;
5
8
  };
@@ -33,14 +36,29 @@ export type PropertyInfo<T extends any[] | State> = {
33
36
  source: T;
34
37
  value: any;
35
38
  };
39
+ export type PropertyPath<T extends State> = keyof T | KeyType | KeyType[];
40
+ export type PropertyPathTokens = Array<KeyType>;
41
+ export type Scalar = boolean | KeyType;
42
+ export type KeyType = number | string | symbol;
43
+ export type SelectorMap<T extends State> = {
44
+ [dataPropKey: string]: PropertyPath<T>;
45
+ [dataPropKey: number]: PropertyPath<T>;
46
+ [dataPropKey: symbol]: PropertyPath<T>;
47
+ } & {
48
+ [dataPropKey: string]: "@@STATE" | ["@@STATE"];
49
+ [dataPropKey: number]: "@@STATE" | ["@@STATE"];
50
+ [dataPropKey: symbol]: "@@STATE" | ["@@STATE"];
51
+ };
36
52
  export type State = {
37
53
  [x: string]: any;
54
+ [x: number]: any;
55
+ [x: symbol]: any;
38
56
  };
39
57
  export type StoreInternal<T extends State> = {
40
- resetState: (propertyPaths?: string[]) => void;
58
+ resetState: (propertyPaths?: any[]) => void;
41
59
  setState: (changes: UpdatePayload<PartialState<T>>) => void;
42
60
  } & {
43
- getState: (clientId: string, ...propertyPaths?: string[]) => {
61
+ getState: (clientId: string, ...propertyPaths?: PropertyPathTokens) => {
44
62
  [propertyPaths: string]: Readonly<any>;
45
63
  };
46
64
  subscribe: (listener: Listener<T>) => Unsubscribe;
@@ -48,7 +66,7 @@ export type StoreInternal<T extends State> = {
48
66
  };
49
67
  export type Store<T extends State> = {
50
68
  data: Data;
51
- resetState: (propertyPaths?: string[]) => void;
69
+ resetState: (propertyPaths?: PropertyPath[]) => void;
52
70
  setState: (changes: UpdatePayload<PartialState<T>>) => void;
53
71
  };
54
72
  export type UpdateStats = {
@@ -84,7 +102,4 @@ export type PUSH_TAG = typeof import("./constants").PUSH_TAG;
84
102
  export type REPLACE_TAG = typeof import("./constants").REPLACE_TAG;
85
103
  export type SET_TAG = typeof import("./constants").SET_TAG;
86
104
  export type SPLICE_TAG = typeof import("./constants").SPLICE_TAG;
87
- export type Unsubscribe = VoidFunction;
88
- export type BaseType = string | number | boolean | symbol | any[] | {
89
- [x: string]: any;
90
- };
105
+ export type Unsubscribe = VoidFunction;
package/package.json CHANGED
@@ -133,5 +133,5 @@
133
133
  "test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
134
134
  },
135
135
  "types": "dist/main/index.d.ts",
136
- "version": "4.1.0-alpha.2"
136
+ "version": "4.1.0-alpha.3"
137
137
  }