epos 1.19.0 → 1.21.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.21.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
@@ -1,3 +1,5 @@
1
+ /// <reference types="chrome"/>
2
+
1
3
  import type * as mobx from 'mobx'
2
4
  import type * as mobxReactLite from 'mobx-react-lite'
3
5
  import type * as react from 'react'
@@ -14,6 +16,10 @@ export type ModelClass = new (...args: any[]) => any
14
16
  export type Model = InstanceType<ModelClass>
15
17
  export type Initial<T extends Obj | Model> = T | (() => T)
16
18
 
19
+ export type StateConfig = {
20
+ allowMissingModels?: boolean | string[]
21
+ }
22
+
17
23
  export type Storage = {
18
24
  /** Get value from the storage. */
19
25
  get<T = unknown>(key: string): Promise<T>
@@ -51,7 +57,7 @@ export interface Epos {
51
57
  /** Emit event locally (calls local listeners only). */
52
58
  emit<T = unknown>(eventName: string, ...args: unknown[]): Promise<T>
53
59
  setSignal(name: string, value?: unknown): void
54
- waitSignal(name: string, timeout?: number): Promise<void>
60
+ waitSignal<T>(name: string, timeout?: number): Promise<T>
55
61
  }
56
62
 
57
63
  // State
@@ -67,6 +73,8 @@ export interface Epos {
67
73
  transaction: (fn: () => void) => void
68
74
  /** Create local state (no sync). */
69
75
  local<T extends Obj = {}>(state?: T): T
76
+ /** Configure state. */
77
+ configure: (config: StateConfig) => void
70
78
  /** Get the list of all state names. */
71
79
  list(filter?: { connected?: boolean }): Promise<{ name: string | null }[]>
72
80
  /** Remove state and all its data. */
@@ -77,6 +85,7 @@ export interface Epos {
77
85
  readonly parent: unique symbol
78
86
  readonly modelInit: unique symbol
79
87
  readonly modelCleanup: unique symbol
88
+ readonly modelStrict: unique symbol
80
89
  readonly modelVersioner: unique symbol
81
90
  }
82
91
  }
@@ -101,14 +110,14 @@ export interface Epos {
101
110
 
102
111
  // Frame
103
112
  frame: {
104
- /** Open frame in the background. */
113
+ /** Open background frame. */
105
114
  open(name: string, url: string, attributes?: Record<string, unknown>): Promise<void>
106
115
  /** Close background frame by its name. */
107
116
  close(name: string): Promise<void>
108
117
  /** Check if background frame with the given name exists. */
109
118
  exists(name: string): Promise<boolean>
110
119
  /** Get list of all open background frames. */
111
- list(): Promise<{ name: string; url: string }[]>
120
+ list(): Promise<{ name: string | null; url: string }[]>
112
121
  }
113
122
 
114
123
  // Static