epos 1.33.0 → 1.34.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 +18 -9
- package/dist/epos.js.map +1 -1
- package/package.json +1 -1
package/dist/epos.d.ts
CHANGED
|
@@ -25,6 +25,11 @@ type Assets = {
|
|
|
25
25
|
};
|
|
26
26
|
type FnArgsOrArr<T> = T extends Fn ? Parameters<T> : Arr;
|
|
27
27
|
type FnResultOrValue<T> = T extends Fn ? ReturnType<T> : T;
|
|
28
|
+
type Project = {
|
|
29
|
+
id: string;
|
|
30
|
+
mode: Mode;
|
|
31
|
+
spec: Spec;
|
|
32
|
+
};
|
|
28
33
|
type ReqInit = {
|
|
29
34
|
body: RequestInit['body'];
|
|
30
35
|
cache: RequestInit['cache'];
|
|
@@ -61,12 +66,12 @@ type Storage = {
|
|
|
61
66
|
get<T = unknown>(key: string): Promise<T | null>;
|
|
62
67
|
/** Set value in the storage. */
|
|
63
68
|
set(key: string, value: unknown): Promise<void>;
|
|
64
|
-
/** Delete
|
|
69
|
+
/** Delete key from the storage. */
|
|
65
70
|
delete(key: string): Promise<void>;
|
|
66
71
|
/** Get all keys from the storage. */
|
|
67
72
|
keys(): Promise<string[]>;
|
|
68
|
-
/**
|
|
69
|
-
|
|
73
|
+
/** Remove the storage. Removes all keys and storage itself. */
|
|
74
|
+
remove(): Promise<void>;
|
|
70
75
|
};
|
|
71
76
|
type Bundle = {
|
|
72
77
|
mode: Mode;
|
|
@@ -105,7 +110,9 @@ interface Epos {
|
|
|
105
110
|
/** Run any state changes in a batch. */
|
|
106
111
|
transaction: (fn: () => void) => void;
|
|
107
112
|
/** Create local state (no sync). */
|
|
108
|
-
local<T extends Obj = {}>(
|
|
113
|
+
local<T extends Obj = {}>(value?: T, opts?: {
|
|
114
|
+
deep: boolean;
|
|
115
|
+
}): T;
|
|
109
116
|
/** Get the list of all state names. */
|
|
110
117
|
list(filter?: {
|
|
111
118
|
connected?: boolean;
|
|
@@ -131,15 +138,15 @@ interface Epos {
|
|
|
131
138
|
<T = unknown>(key: string, value: T): Promise<void>;
|
|
132
139
|
<T = unknown>(name: string, key: string, value: T): Promise<void>;
|
|
133
140
|
};
|
|
134
|
-
/** Delete
|
|
141
|
+
/** Delete key from the storage. */
|
|
135
142
|
delete: {
|
|
136
143
|
(key: string): Promise<void>;
|
|
137
144
|
(name: string, key: string): Promise<void>;
|
|
138
145
|
};
|
|
139
146
|
/** Get all keys from the storage. */
|
|
140
147
|
keys(name?: string): Promise<string[]>;
|
|
141
|
-
/**
|
|
142
|
-
|
|
148
|
+
/** Remove storage. Removes all keys and storage itself. */
|
|
149
|
+
remove(name?: string): Promise<void>;
|
|
143
150
|
/** Get storage API for a specific storage. */
|
|
144
151
|
use(name?: string): Storage;
|
|
145
152
|
/** Get this list of all storages. */
|
|
@@ -193,10 +200,10 @@ interface Epos {
|
|
|
193
200
|
}[];
|
|
194
201
|
};
|
|
195
202
|
env: {
|
|
196
|
-
mode: Mode;
|
|
197
203
|
tabId: number;
|
|
198
204
|
project: {
|
|
199
205
|
id: string;
|
|
206
|
+
mode: Mode;
|
|
200
207
|
spec: Spec;
|
|
201
208
|
};
|
|
202
209
|
isPopup: boolean;
|
|
@@ -218,6 +225,8 @@ interface Epos {
|
|
|
218
225
|
(id: string, bundle: Bundle): Promise<void>;
|
|
219
226
|
};
|
|
220
227
|
remove(name: string): Promise<void>;
|
|
228
|
+
watch(handler: (projects: Project[]) => void): void;
|
|
229
|
+
list(): Promise<Project[]>;
|
|
221
230
|
};
|
|
222
231
|
engine: any;
|
|
223
232
|
}
|
|
@@ -226,4 +235,4 @@ declare global {
|
|
|
226
235
|
}
|
|
227
236
|
declare const _epos: Epos;
|
|
228
237
|
|
|
229
|
-
export { type Arr, type Assets, type Attrs, type Bundle, type Epos, type Fn, type FnArgsOrArr, type FnResultOrValue, type Initial, type Mode, type Model, type ModelClass, type Obj, type ReqInit, type Res, type Sources, type Storage, type Versioner, _epos as default, _epos as epos };
|
|
238
|
+
export { type Arr, type Assets, type Attrs, type Bundle, type Epos, type Fn, type FnArgsOrArr, type FnResultOrValue, type Initial, type Mode, type Model, type ModelClass, type Obj, 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 Versioner = Record<number, (this: any, state: any) => void>\nexport type ModelClass = new (...args: any[]) => any\nexport type Model = InstanceType<ModelClass>\nexport type Initial<T extends Obj | Model> = T | (() => T)\nexport type Attrs = Record<string, string | number>\nexport type Mode = 'development' | 'production'\nexport type Sources = { [path: string]: string }\nexport type Assets = { [path: string]: Blob }\nexport type FnArgsOrArr<T> = T extends Fn ? Parameters<T> : Arr\nexport type FnResultOrValue<T> = T extends Fn ? ReturnType<T> : T\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
|
|
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 Versioner = Record<number, (this: any, state: any) => void>\nexport type ModelClass = new (...args: any[]) => any\nexport type Model = InstanceType<ModelClass>\nexport type Initial<T extends Obj | Model> = T | (() => T)\nexport type Attrs = Record<string, string | number>\nexport type Mode = 'development' | 'production'\nexport type Sources = { [path: string]: string }\nexport type Assets = { [path: string]: Blob }\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 extends Obj | Model = Obj>(initial?: Initial<T>, versioner?: Versioner): Promise<T>\n <T extends Obj | Model = Obj>(name?: string, initial?: Initial<T>, versioner?: Versioner): 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 extends Obj = {}>(value?: T, opts?: { deep: boolean }): 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 to be used by all states. */\n register(models: Record<string, ModelClass>): 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 keys from the storage. */\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":";AAyOA,IAAM,QAAQ;AAEd,IAAO,eAAQ;","names":[]}
|