epos 1.18.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>;
@@ -45,6 +48,8 @@ interface Epos {
45
48
  send<T = unknown>(eventName: string, ...args: unknown[]): Promise<T>;
46
49
  /** Emit event locally (calls local listeners only). */
47
50
  emit<T = unknown>(eventName: string, ...args: unknown[]): Promise<T>;
51
+ setSignal(name: string, value?: unknown): void;
52
+ waitSignal<T>(name: string, timeout?: number): Promise<T>;
48
53
  };
49
54
  state: {
50
55
  /** Connect state. */
@@ -58,6 +63,8 @@ interface Epos {
58
63
  transaction: (fn: () => void) => void;
59
64
  /** Create local state (no sync). */
60
65
  local<T extends Obj = {}>(state?: T): T;
66
+ /** Configure state. */
67
+ configure: (config: StateConfig) => void;
61
68
  /** Get the list of all state names. */
62
69
  list(filter?: {
63
70
  connected?: boolean;
@@ -72,6 +79,7 @@ interface Epos {
72
79
  readonly parent: unique symbol;
73
80
  readonly modelInit: unique symbol;
74
81
  readonly modelCleanup: unique symbol;
82
+ readonly modelStrict: unique symbol;
75
83
  readonly modelVersioner: unique symbol;
76
84
  };
77
85
  };
@@ -94,7 +102,7 @@ interface Epos {
94
102
  }[]>;
95
103
  };
96
104
  frame: {
97
- /** Open frame in the background. */
105
+ /** Open background frame. */
98
106
  open(name: string, url: string, attributes?: Record<string, unknown>): Promise<void>;
99
107
  /** Close background frame by its name. */
100
108
  close(name: string): Promise<void>;
@@ -102,7 +110,7 @@ interface Epos {
102
110
  exists(name: string): Promise<boolean>;
103
111
  /** Get list of all open background frames. */
104
112
  list(): Promise<{
105
- name: string;
113
+ name: string | null;
106
114
  url: string;
107
115
  }[]>;
108
116
  };
@@ -153,4 +161,4 @@ declare global {
153
161
  declare const _epos: Epos;
154
162
  var epos$1 = epos;
155
163
 
156
- 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.18.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>
@@ -50,6 +54,8 @@ export interface Epos {
50
54
  send<T = unknown>(eventName: string, ...args: unknown[]): Promise<T>
51
55
  /** Emit event locally (calls local listeners only). */
52
56
  emit<T = unknown>(eventName: string, ...args: unknown[]): Promise<T>
57
+ setSignal(name: string, value?: unknown): void
58
+ waitSignal<T>(name: string, timeout?: number): Promise<T>
53
59
  }
54
60
 
55
61
  // State
@@ -65,6 +71,8 @@ export interface Epos {
65
71
  transaction: (fn: () => void) => void
66
72
  /** Create local state (no sync). */
67
73
  local<T extends Obj = {}>(state?: T): T
74
+ /** Configure state. */
75
+ configure: (config: StateConfig) => void
68
76
  /** Get the list of all state names. */
69
77
  list(filter?: { connected?: boolean }): Promise<{ name: string | null }[]>
70
78
  /** Remove state and all its data. */
@@ -75,6 +83,7 @@ export interface Epos {
75
83
  readonly parent: unique symbol
76
84
  readonly modelInit: unique symbol
77
85
  readonly modelCleanup: unique symbol
86
+ readonly modelStrict: unique symbol
78
87
  readonly modelVersioner: unique symbol
79
88
  }
80
89
  }
@@ -99,14 +108,14 @@ export interface Epos {
99
108
 
100
109
  // Frame
101
110
  frame: {
102
- /** Open frame in the background. */
111
+ /** Open background frame. */
103
112
  open(name: string, url: string, attributes?: Record<string, unknown>): Promise<void>
104
113
  /** Close background frame by its name. */
105
114
  close(name: string): Promise<void>
106
115
  /** Check if background frame with the given name exists. */
107
116
  exists(name: string): Promise<boolean>
108
117
  /** Get list of all open background frames. */
109
- list(): Promise<{ name: string; url: string }[]>
118
+ list(): Promise<{ name: string | null; url: string }[]>
110
119
  }
111
120
 
112
121
  // Static