epos 1.33.0 → 1.35.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 +29 -19
- package/dist/epos.js.map +1 -1
- package/package.json +3 -3
package/dist/epos.d.ts
CHANGED
|
@@ -9,13 +9,13 @@ import * as yjs from 'yjs';
|
|
|
9
9
|
import { Chrome } from './chrome.d.js';
|
|
10
10
|
|
|
11
11
|
type Fn<T = any> = (...args: any[]) => T;
|
|
12
|
+
type Cls<T = any> = new (...args: any[]) => T;
|
|
12
13
|
type Obj = Record<string, unknown>;
|
|
13
14
|
type Arr = unknown[];
|
|
14
|
-
type
|
|
15
|
-
type
|
|
16
|
-
type
|
|
17
|
-
type
|
|
18
|
-
type Attrs = Record<string, string | number>;
|
|
15
|
+
type Model<T> = T extends object ? Exclude<T, Obj | Arr | Fn> : never;
|
|
16
|
+
type ObjModel<T> = T extends Obj ? T : Model<T>;
|
|
17
|
+
type ObjArrModel<T> = T extends Obj | Arr ? T : Model<T>;
|
|
18
|
+
type Versioner<T> = Record<number, (this: T, state: T) => void>;
|
|
19
19
|
type Mode = 'development' | 'production';
|
|
20
20
|
type Sources = {
|
|
21
21
|
[path: string]: string;
|
|
@@ -23,8 +23,14 @@ type Sources = {
|
|
|
23
23
|
type Assets = {
|
|
24
24
|
[path: string]: Blob;
|
|
25
25
|
};
|
|
26
|
+
type Attrs = Record<string, string | number>;
|
|
26
27
|
type FnArgsOrArr<T> = T extends Fn ? Parameters<T> : Arr;
|
|
27
28
|
type FnResultOrValue<T> = T extends Fn ? ReturnType<T> : T;
|
|
29
|
+
type Project = {
|
|
30
|
+
id: string;
|
|
31
|
+
mode: Mode;
|
|
32
|
+
spec: Spec;
|
|
33
|
+
};
|
|
28
34
|
type ReqInit = {
|
|
29
35
|
body: RequestInit['body'];
|
|
30
36
|
cache: RequestInit['cache'];
|
|
@@ -61,12 +67,12 @@ type Storage = {
|
|
|
61
67
|
get<T = unknown>(key: string): Promise<T | null>;
|
|
62
68
|
/** Set value in the storage. */
|
|
63
69
|
set(key: string, value: unknown): Promise<void>;
|
|
64
|
-
/** Delete
|
|
70
|
+
/** Delete key from the storage. */
|
|
65
71
|
delete(key: string): Promise<void>;
|
|
66
72
|
/** Get all keys from the storage. */
|
|
67
73
|
keys(): Promise<string[]>;
|
|
68
|
-
/**
|
|
69
|
-
|
|
74
|
+
/** Remove the storage. Removes all keys and storage itself. */
|
|
75
|
+
remove(): Promise<void>;
|
|
70
76
|
};
|
|
71
77
|
type Bundle = {
|
|
72
78
|
mode: Mode;
|
|
@@ -97,15 +103,17 @@ interface Epos {
|
|
|
97
103
|
state: {
|
|
98
104
|
/** Connect state. */
|
|
99
105
|
connect: {
|
|
100
|
-
<T
|
|
101
|
-
<T
|
|
106
|
+
<T = Obj>(initial?: ObjModel<T>, versioner?: Versioner<T>): Promise<T>;
|
|
107
|
+
<T = Obj>(initial?: () => ObjModel<T>, versioner?: Versioner<T>): Promise<T>;
|
|
108
|
+
<T = Obj>(name?: string, initial?: ObjModel<T>, versioner?: Versioner<T>): Promise<T>;
|
|
109
|
+
<T = Obj>(name?: string, initial?: () => ObjModel<T>, versioner?: Versioner<T>): Promise<T>;
|
|
102
110
|
};
|
|
103
111
|
/** Disconnect state. */
|
|
104
112
|
disconnect(name?: string): void;
|
|
105
113
|
/** Run any state changes in a batch. */
|
|
106
114
|
transaction: (fn: () => void) => void;
|
|
107
115
|
/** Create local state (no sync). */
|
|
108
|
-
local<T
|
|
116
|
+
local<T = Obj>(state?: ObjArrModel<T>): T;
|
|
109
117
|
/** Get the list of all state names. */
|
|
110
118
|
list(filter?: {
|
|
111
119
|
connected?: boolean;
|
|
@@ -114,8 +122,8 @@ interface Epos {
|
|
|
114
122
|
}[]>;
|
|
115
123
|
/** Remove state and all its data. */
|
|
116
124
|
remove(name?: string): Promise<void>;
|
|
117
|
-
/** Register models
|
|
118
|
-
register(models: Record<string,
|
|
125
|
+
/** Register models that can be used by all states. */
|
|
126
|
+
register(models: Record<string, Cls>): void;
|
|
119
127
|
PARENT: symbol;
|
|
120
128
|
ATTACH: symbol;
|
|
121
129
|
DETACH: symbol;
|
|
@@ -131,15 +139,15 @@ interface Epos {
|
|
|
131
139
|
<T = unknown>(key: string, value: T): Promise<void>;
|
|
132
140
|
<T = unknown>(name: string, key: string, value: T): Promise<void>;
|
|
133
141
|
};
|
|
134
|
-
/** Delete
|
|
142
|
+
/** Delete key from the storage. */
|
|
135
143
|
delete: {
|
|
136
144
|
(key: string): Promise<void>;
|
|
137
145
|
(name: string, key: string): Promise<void>;
|
|
138
146
|
};
|
|
139
|
-
/** Get all keys
|
|
147
|
+
/** Get all storage keys. */
|
|
140
148
|
keys(name?: string): Promise<string[]>;
|
|
141
|
-
/**
|
|
142
|
-
|
|
149
|
+
/** Remove storage. Removes all keys and storage itself. */
|
|
150
|
+
remove(name?: string): Promise<void>;
|
|
143
151
|
/** Get storage API for a specific storage. */
|
|
144
152
|
use(name?: string): Storage;
|
|
145
153
|
/** Get this list of all storages. */
|
|
@@ -193,10 +201,10 @@ interface Epos {
|
|
|
193
201
|
}[];
|
|
194
202
|
};
|
|
195
203
|
env: {
|
|
196
|
-
mode: Mode;
|
|
197
204
|
tabId: number;
|
|
198
205
|
project: {
|
|
199
206
|
id: string;
|
|
207
|
+
mode: Mode;
|
|
200
208
|
spec: Spec;
|
|
201
209
|
};
|
|
202
210
|
isPopup: boolean;
|
|
@@ -218,6 +226,8 @@ interface Epos {
|
|
|
218
226
|
(id: string, bundle: Bundle): Promise<void>;
|
|
219
227
|
};
|
|
220
228
|
remove(name: string): Promise<void>;
|
|
229
|
+
watch(handler: (projects: Project[]) => void): void;
|
|
230
|
+
list(): Promise<Project[]>;
|
|
221
231
|
};
|
|
222
232
|
engine: any;
|
|
223
233
|
}
|
|
@@ -226,4 +236,4 @@ declare global {
|
|
|
226
236
|
}
|
|
227
237
|
declare const _epos: Epos;
|
|
228
238
|
|
|
229
|
-
export { type Arr, type Assets, type Attrs, type Bundle, type Epos, type Fn, type FnArgsOrArr, type FnResultOrValue, type
|
|
239
|
+
export { type Arr, type Assets, type Attrs, type Bundle, type Cls, type Epos, type Fn, type FnArgsOrArr, type FnResultOrValue, type Mode, type Model, type Obj, type ObjArrModel, type ObjModel, type Project, type ReqInit, type Res, type Sources, type Storage, type Versioner, _epos as default, _epos as epos };
|
package/dist/epos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/epos.ts"],"sourcesContent":["import { Spec } from 'epos-spec'\nimport type * as mobx from 'mobx'\nimport type * as mobxReactLite from 'mobx-react-lite'\nimport type * as react from 'react'\nimport type * as reactDom from 'react-dom'\nimport type * as reactDomClient from 'react-dom/client'\nimport type * as reactJsxRuntime from 'react/jsx-runtime'\nimport type * as yjs from 'yjs'\nimport type { Chrome } from './chrome.ts'\n\nexport type Fn<T = any> = (...args: any[]) => T\nexport type Obj = Record<string, unknown>\nexport type Arr = unknown[]\nexport type
|
|
1
|
+
{"version":3,"sources":["../src/epos.ts"],"sourcesContent":["import { Spec } from 'epos-spec'\nimport type * as mobx from 'mobx'\nimport type * as mobxReactLite from 'mobx-react-lite'\nimport type * as react from 'react'\nimport type * as reactDom from 'react-dom'\nimport type * as reactDomClient from 'react-dom/client'\nimport type * as reactJsxRuntime from 'react/jsx-runtime'\nimport type * as yjs from 'yjs'\nimport type { Chrome } from './chrome.ts'\n\nexport type Fn<T = any> = (...args: any[]) => T\nexport type Cls<T = any> = new (...args: any[]) => T\nexport type Obj = Record<string, unknown>\nexport type Arr = unknown[]\nexport type Model<T> = T extends object ? Exclude<T, Obj | Arr | Fn> : never\nexport type ObjModel<T> = T extends Obj ? T : Model<T>\nexport type ObjArrModel<T> = T extends Obj | Arr ? T : Model<T>\nexport type Versioner<T> = Record<number, (this: T, state: T) => void>\nexport type Mode = 'development' | 'production'\nexport type Sources = { [path: string]: string }\nexport type Assets = { [path: string]: Blob }\nexport type Attrs = Record<string, string | number>\nexport type FnArgsOrArr<T> = T extends Fn ? Parameters<T> : Arr\nexport type FnResultOrValue<T> = T extends Fn ? ReturnType<T> : T\nexport type Project = { id: string; mode: Mode; spec: Spec }\n\nexport type ReqInit = {\n body: RequestInit['body']\n cache: RequestInit['cache']\n credentials: RequestInit['credentials']\n headers: RequestInit['headers']\n integrity: RequestInit['integrity']\n keepalive: RequestInit['keepalive']\n method: RequestInit['method']\n mode: RequestInit['mode']\n priority: RequestInit['priority']\n redirect: RequestInit['redirect']\n referrer: RequestInit['referrer']\n referrerPolicy: RequestInit['referrerPolicy']\n}\n\nexport type Res = {\n ok: Response['ok']\n url: Response['url']\n type: Response['type']\n status: Response['status']\n statusText: Response['statusText']\n redirected: Response['redirected']\n text: Response['text']\n json: Response['json']\n blob: Response['blob']\n headers: {\n get: Response['headers']['get']\n has: Response['headers']['has']\n /** Get all header keys. */\n keys: () => string[]\n }\n}\n\nexport type Storage = {\n /** Get value from the storage. */\n get<T = unknown>(key: string): Promise<T | null>\n /** Set value in the storage. */\n set(key: string, value: unknown): Promise<void>\n /** Delete key from the storage. */\n delete(key: string): Promise<void>\n /** Get all keys from the storage. */\n keys(): Promise<string[]>\n /** Remove the storage. Removes all keys and storage itself. */\n remove(): Promise<void>\n}\n\nexport type Bundle = {\n mode: Mode\n spec: Spec\n sources: Sources\n assets: Assets\n}\n\nexport interface Epos {\n // General\n fetch: (url: string | URL, init?: ReqInit) => Promise<Res>\n browser: Chrome\n render(node: react.ReactNode, container?: reactDomClient.Container): void\n component<T>(Component: react.FC<T>): typeof Component\n element: HTMLDivElement\n\n // Bus\n bus: {\n /** Listen for an event. */\n on<T extends Fn>(name: string, callback: T, thisArg?: unknown): void\n /** Remove event listener. */\n off<T extends Fn>(name: string, callback?: T): void\n /** Listen for an event once. */\n once<T extends Fn>(name: string, callback: T, thisArg?: unknown): void\n /** Send an event to all remote listeners (local listeners are ignored). */\n send<T = unknown>(name: string, ...args: FnArgsOrArr<T>): Promise<FnResultOrValue<T> | null>\n /** Emit event locally (calls local listeners only). */\n emit<T = unknown>(name: string, ...args: FnArgsOrArr<T>): Promise<FnResultOrValue<T> | null>\n setSignal(name: string, value?: unknown): void\n waitSignal<T = unknown>(name: string, timeout?: number): Promise<T | null>\n }\n\n // State\n state: {\n /** Connect state. */\n connect: {\n <T = Obj>(initial?: ObjModel<T>, versioner?: Versioner<T>): Promise<T>\n <T = Obj>(initial?: () => ObjModel<T>, versioner?: Versioner<T>): Promise<T>\n <T = Obj>(name?: string, initial?: ObjModel<T>, versioner?: Versioner<T>): Promise<T>\n <T = Obj>(name?: string, initial?: () => ObjModel<T>, versioner?: Versioner<T>): Promise<T>\n }\n /** Disconnect state. */\n disconnect(name?: string): void\n /** Run any state changes in a batch. */\n transaction: (fn: () => void) => void\n /** Create local state (no sync). */\n local<T = Obj>(state?: ObjArrModel<T>): T\n /** Get the list of all state names. */\n list(filter?: { connected?: boolean }): Promise<{ name: string | null }[]>\n /** Remove state and all its data. */\n remove(name?: string): Promise<void>\n /** Register models that can be used by all states. */\n register(models: Record<string, Cls>): void\n PARENT: symbol\n ATTACH: symbol\n DETACH: symbol\n }\n\n // Storage\n storage: {\n /** Get value from the storage. */\n get: {\n <T = unknown>(key: string): Promise<T | null>\n <T = unknown>(name: string, key: string): Promise<T | null>\n }\n /** Set value in the storage. */\n set: {\n <T = unknown>(key: string, value: T): Promise<void>\n <T = unknown>(name: string, key: string, value: T): Promise<void>\n }\n /** Delete key from the storage. */\n delete: {\n (key: string): Promise<void>\n (name: string, key: string): Promise<void>\n }\n /** Get all storage keys. */\n keys(name?: string): Promise<string[]>\n /** Remove storage. Removes all keys and storage itself. */\n remove(name?: string): Promise<void>\n /** Get storage API for a specific storage. */\n use(name?: string): Storage\n /** Get this list of all storages. */\n list(): Promise<{ name: string | null }[]>\n }\n\n // Frame\n frame: {\n /** Open background frame. */\n open: {\n (url: string): Promise<void>\n (url: string, attrs: Attrs): Promise<void>\n (name: string, url: string): Promise<void>\n (name: string, url: string, attrs: Attrs): Promise<void>\n }\n /** Close background frame. */\n close(name?: string): Promise<void>\n /** Check if background frame with the given name exists. */\n exists(name?: string): Promise<boolean>\n /** Get list of all open background frames. */\n list(): Promise<{ name: string | null; url: string }[]>\n }\n\n // Asset\n asset: {\n /** Load specified asset to memory. Load all assets if no path is provided. */\n load: {\n /** Load all assets. */\n (): Promise<void>\n /** Load asset by path. */\n (path: string): Promise<void>\n }\n /** Unload either all assets from the memory or a specific asset by its path. */\n unload: {\n /** Unload all assets. */\n (): void\n /** Unload asset by path. */\n (path: string): void\n }\n /** Get asset URL. The asset must be loaded first via `epos.asset.load`. */\n url(path: string): string\n /** Get asset as Blob. */\n get(path: string): Promise<Blob | null>\n /** Get list of all available assets. */\n list(filter?: { loaded?: boolean }): { path: string; loaded: boolean }[]\n }\n\n // Env\n env: {\n tabId: number\n project: { id: string; mode: Mode; spec: Spec }\n isPopup: boolean\n isSidePanel: boolean\n isBackground: boolean\n }\n\n // Libs\n libs: {\n mobx: typeof mobx\n mobxReactLite: typeof mobxReactLite\n react: typeof react\n reactDom: typeof reactDom\n reactDomClient: typeof reactDomClient\n reactJsxRuntime: typeof reactJsxRuntime\n yjs: typeof yjs\n }\n\n // Installer\n installer: {\n install: {\n (id: string, url: string, mode?: Mode): Promise<void>\n (id: string, bundle: Bundle): Promise<void>\n }\n remove(name: string): Promise<void>\n watch(handler: (projects: Project[]) => void): void\n list(): Promise<Project[]>\n }\n\n // Engine\n engine: any\n}\n\ndeclare global {\n var epos: Epos\n}\n\nconst _epos = epos\nexport { _epos as epos }\nexport default _epos\n"],"mappings":";AA4OA,IAAM,QAAQ;AAEd,IAAO,eAAQ;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "epos",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "imkost",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"@types/chrome": "^0.1.32",
|
|
25
25
|
"@types/react": "^19.2.7",
|
|
26
26
|
"@types/react-dom": "^19.2.3",
|
|
27
|
-
"epos-spec": "^1.
|
|
27
|
+
"epos-spec": "^1.5.0",
|
|
28
28
|
"mobx": "^6.15.0",
|
|
29
29
|
"mobx-react-lite": "^4.1.1",
|
|
30
30
|
"portfinder": "^1.0.38",
|
|
31
31
|
"react": "^19.2.3",
|
|
32
|
-
"ws": "^8.
|
|
32
|
+
"ws": "^8.19.0",
|
|
33
33
|
"yjs": "^13.6.29"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|