epos 1.19.0 → 1.20.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/epos.d.ts CHANGED
@@ -13,6 +13,9 @@ type ClassName = string | null | boolean | undefined | ClassName[];
13
13
  type ModelClass = new (...args: any[]) => any;
14
14
  type Model = InstanceType<ModelClass>;
15
15
  type Initial<T extends Obj | Model> = T | (() => T);
16
+ type StateConfig = {
17
+ allowMissingModels?: boolean | string[];
18
+ };
16
19
  type Storage = {
17
20
  /** Get value from the storage. */
18
21
  get<T = unknown>(key: string): Promise<T>;
@@ -46,7 +49,7 @@ interface Epos {
46
49
  /** Emit event locally (calls local listeners only). */
47
50
  emit<T = unknown>(eventName: string, ...args: unknown[]): Promise<T>;
48
51
  setSignal(name: string, value?: unknown): void;
49
- waitSignal(name: string, timeout?: number): Promise<void>;
52
+ waitSignal<T>(name: string, timeout?: number): Promise<T>;
50
53
  };
51
54
  state: {
52
55
  /** Connect state. */
@@ -60,6 +63,8 @@ interface Epos {
60
63
  transaction: (fn: () => void) => void;
61
64
  /** Create local state (no sync). */
62
65
  local<T extends Obj = {}>(state?: T): T;
66
+ /** Configure state. */
67
+ configure: (config: StateConfig) => void;
63
68
  /** Get the list of all state names. */
64
69
  list(filter?: {
65
70
  connected?: boolean;
@@ -74,6 +79,7 @@ interface Epos {
74
79
  readonly parent: unique symbol;
75
80
  readonly modelInit: unique symbol;
76
81
  readonly modelCleanup: unique symbol;
82
+ readonly modelStrict: unique symbol;
77
83
  readonly modelVersioner: unique symbol;
78
84
  };
79
85
  };
@@ -96,7 +102,7 @@ interface Epos {
96
102
  }[]>;
97
103
  };
98
104
  frame: {
99
- /** Open frame in the background. */
105
+ /** Open background frame. */
100
106
  open(name: string, url: string, attributes?: Record<string, unknown>): Promise<void>;
101
107
  /** Close background frame by its name. */
102
108
  close(name: string): Promise<void>;
@@ -104,7 +110,7 @@ interface Epos {
104
110
  exists(name: string): Promise<boolean>;
105
111
  /** Get list of all open background frames. */
106
112
  list(): Promise<{
107
- name: string;
113
+ name: string | null;
108
114
  url: string;
109
115
  }[]>;
110
116
  };
@@ -155,4 +161,4 @@ declare global {
155
161
  declare const _epos: Epos;
156
162
  var epos$1 = epos;
157
163
 
158
- export { type ClassName, type Epos, type Fn, type Initial, type Model, type ModelClass, type Obj, type Storage, type Versioner, epos$1 as default, _epos as epos };
164
+ export { type ClassName, type Epos, type Fn, type Initial, type Model, type ModelClass, type Obj, type StateConfig, type Storage, type Versioner, epos$1 as default, _epos as epos };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epos",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "imkost",
@@ -29,9 +29,9 @@
29
29
  "dist"
30
30
  ],
31
31
  "dependencies": {
32
- "@types/chrome": "^0.1.21",
33
- "@types/react": "^19.2.0",
34
- "@types/react-dom": "^19.2.0",
32
+ "@types/chrome": "^0.1.22",
33
+ "@types/react": "^19.2.2",
34
+ "@types/react-dom": "^19.2.1",
35
35
  "mobx": "^6.15.0",
36
36
  "mobx-react-lite": "^4.1.1",
37
37
  "react": "^19.2.0",
package/src/epos.ts CHANGED
@@ -14,6 +14,10 @@ export type ModelClass = new (...args: any[]) => any
14
14
  export type Model = InstanceType<ModelClass>
15
15
  export type Initial<T extends Obj | Model> = T | (() => T)
16
16
 
17
+ export type StateConfig = {
18
+ allowMissingModels?: boolean | string[]
19
+ }
20
+
17
21
  export type Storage = {
18
22
  /** Get value from the storage. */
19
23
  get<T = unknown>(key: string): Promise<T>
@@ -51,7 +55,7 @@ export interface Epos {
51
55
  /** Emit event locally (calls local listeners only). */
52
56
  emit<T = unknown>(eventName: string, ...args: unknown[]): Promise<T>
53
57
  setSignal(name: string, value?: unknown): void
54
- waitSignal(name: string, timeout?: number): Promise<void>
58
+ waitSignal<T>(name: string, timeout?: number): Promise<T>
55
59
  }
56
60
 
57
61
  // State
@@ -67,6 +71,8 @@ export interface Epos {
67
71
  transaction: (fn: () => void) => void
68
72
  /** Create local state (no sync). */
69
73
  local<T extends Obj = {}>(state?: T): T
74
+ /** Configure state. */
75
+ configure: (config: StateConfig) => void
70
76
  /** Get the list of all state names. */
71
77
  list(filter?: { connected?: boolean }): Promise<{ name: string | null }[]>
72
78
  /** Remove state and all its data. */
@@ -77,6 +83,7 @@ export interface Epos {
77
83
  readonly parent: unique symbol
78
84
  readonly modelInit: unique symbol
79
85
  readonly modelCleanup: unique symbol
86
+ readonly modelStrict: unique symbol
80
87
  readonly modelVersioner: unique symbol
81
88
  }
82
89
  }
@@ -101,14 +108,14 @@ export interface Epos {
101
108
 
102
109
  // Frame
103
110
  frame: {
104
- /** Open frame in the background. */
111
+ /** Open background frame. */
105
112
  open(name: string, url: string, attributes?: Record<string, unknown>): Promise<void>
106
113
  /** Close background frame by its name. */
107
114
  close(name: string): Promise<void>
108
115
  /** Check if background frame with the given name exists. */
109
116
  exists(name: string): Promise<boolean>
110
117
  /** Get list of all open background frames. */
111
- list(): Promise<{ name: string; url: string }[]>
118
+ list(): Promise<{ name: string | null; url: string }[]>
112
119
  }
113
120
 
114
121
  // Static