epos 1.22.0 → 1.25.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.
@@ -0,0 +1,10 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ declare class EposVite {
4
+ private libs;
5
+ get plugin(): Plugin;
6
+ private onResolveId;
7
+ }
8
+ declare function epos(): Plugin<any>;
9
+
10
+ export { EposVite, epos as default, epos };
@@ -0,0 +1,31 @@
1
+ // src/epos-vite.ts
2
+ import { resolve } from "path";
3
+ var EposVite = class {
4
+ libs = {
5
+ "react": resolve(import.meta.dirname, "./libs/libs-react.js"),
6
+ "react/jsx-runtime": resolve(import.meta.dirname, "./libs/libs-react-jsx-runtime.js"),
7
+ "react-dom": resolve(import.meta.dirname, "./libs/libs-react-dom.js"),
8
+ "react-dom/client": resolve(import.meta.dirname, "./libs/libs-react-dom-client.js"),
9
+ "mobx": resolve(import.meta.dirname, "./libs/libs-mobx.js"),
10
+ "mobx-react-lite": resolve(import.meta.dirname, "./libs/libs-mobx-react-lite.js")
11
+ };
12
+ get plugin() {
13
+ return {
14
+ name: "epos",
15
+ enforce: "pre",
16
+ resolveId: this.onResolveId
17
+ };
18
+ }
19
+ onResolveId = (source) => {
20
+ return this.libs[source] ?? null;
21
+ };
22
+ };
23
+ function epos() {
24
+ return new EposVite().plugin;
25
+ }
26
+ var epos_vite_default = epos;
27
+ export {
28
+ EposVite,
29
+ epos_vite_default as default,
30
+ epos
31
+ };
package/dist/epos.d.ts CHANGED
@@ -16,6 +16,36 @@ type Initial<T extends Obj | Model> = T | (() => T);
16
16
  type StateConfig = {
17
17
  allowMissingModels?: boolean | string[];
18
18
  };
19
+ type ReqInit = {
20
+ body: RequestInit['body'];
21
+ cache: RequestInit['cache'];
22
+ credentials: RequestInit['credentials'];
23
+ headers: RequestInit['headers'];
24
+ integrity: RequestInit['integrity'];
25
+ keepalive: RequestInit['keepalive'];
26
+ method: RequestInit['method'];
27
+ mode: RequestInit['mode'];
28
+ priority: RequestInit['priority'];
29
+ redirect: RequestInit['redirect'];
30
+ referrer: RequestInit['referrer'];
31
+ referrerPolicy: RequestInit['referrerPolicy'];
32
+ };
33
+ type Res = {
34
+ ok: Response['ok'];
35
+ url: Response['url'];
36
+ type: Response['type'];
37
+ status: Response['status'];
38
+ statusText: Response['statusText'];
39
+ redirected: Response['redirected'];
40
+ text: Response['text'];
41
+ json: Response['json'];
42
+ blob: Response['blob'];
43
+ headers: {
44
+ get: Response['headers']['get'];
45
+ has: Response['headers']['has'];
46
+ keys: () => string[];
47
+ };
48
+ };
19
49
  type Storage = {
20
50
  /** Get value from the storage. */
21
51
  get<T = unknown>(key: string): Promise<T>;
@@ -29,14 +59,11 @@ type Storage = {
29
59
  clear(): Promise<void>;
30
60
  };
31
61
  interface Epos {
32
- fetch: typeof window.fetch;
62
+ fetch: (url: string | URL, init?: ReqInit) => Promise<Res>;
33
63
  browser: typeof chrome;
34
64
  element: HTMLDivElement;
35
65
  render(node: react.ReactNode, container?: reactDomClient.Container): void;
36
- component: {
37
- <P>(Component: react.FC<P>): typeof Component;
38
- <P>(name: string, Component: react.FC<P>): typeof Component;
39
- };
66
+ component<T>(Component: react.FC<T>): typeof Component;
40
67
  bus: {
41
68
  /** Listen for an event. */
42
69
  on(eventName: string, callback: Fn, thisValue?: unknown): void;
@@ -114,18 +141,24 @@ interface Epos {
114
141
  url: string;
115
142
  }[]>;
116
143
  };
117
- static: {
118
- /** Get static file URL. The file must be loaded first via `epos.static.load`. */
144
+ assets: {
145
+ /** Get asset URL. The asset must be loaded first via `epos.assets.load`. */
119
146
  url(path: string): string;
120
- /** Load static file by path. */
121
- load(path: string): Promise<Blob>;
122
- /** Load all static files. */
123
- loadAll(): Promise<Blob[]>;
124
- /** Unload static file from memory. */
125
- unload(path: string): void;
126
- /** Unload all static files from memory. */
127
- unloadAll(): void;
128
- /** Get list of all available static files. */
147
+ /** Load either all assets or a specific asset by its path. */
148
+ load: {
149
+ /** Load all assets. */
150
+ (): Promise<void>;
151
+ /** Load asset by path. */
152
+ (path: string): Promise<Blob>;
153
+ };
154
+ /** Unload either all assets from memory or a specific asset by its path. */
155
+ unload: {
156
+ /** Unload all assets from memory. */
157
+ (): void;
158
+ /** Unload asset by path. */
159
+ (path: string): void;
160
+ };
161
+ /** Get list of all available asset files. */
129
162
  list(filter?: {
130
163
  loaded?: boolean;
131
164
  }): {
@@ -159,6 +192,5 @@ declare global {
159
192
  }
160
193
  }
161
194
  declare const _epos: Epos;
162
- var epos$1 = epos;
163
195
 
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 };
196
+ export { type ClassName, type Epos, type Fn, type Initial, type Model, type ModelClass, type Obj, type ReqInit, type Res, type StateConfig, type Storage, type Versioner, _epos as default, _epos as epos };
package/dist/epos.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/epos.ts
2
2
  var _epos = epos;
3
- var epos_default = epos;
3
+ var epos_default = _epos;
4
4
  export {
5
5
  epos_default as default,
6
6
  _epos as epos
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epos",
3
- "version": "1.22.0",
3
+ "version": "1.25.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "imkost",
@@ -19,9 +19,12 @@
19
19
  "types": "./dist/epos.d.ts"
20
20
  },
21
21
  "./vite": {
22
- "source": "./src/vite.ts",
23
- "import": "./dist/vite.js",
24
- "types": "./dist/vite.d.ts"
22
+ "source": "./src/epos-vite.ts",
23
+ "import": "./dist/epos-vite.js",
24
+ "types": "./dist/epos-vite.d.ts"
25
+ },
26
+ "./vite/ts": {
27
+ "import": "./src/epos-vite.ts"
25
28
  }
26
29
  },
27
30
  "files": [
@@ -29,18 +32,21 @@
29
32
  "dist"
30
33
  ],
31
34
  "dependencies": {
32
- "@types/chrome": "^0.1.22",
35
+ "@parcel/watcher": "^2.5.1",
36
+ "@types/chrome": "^0.1.24",
33
37
  "@types/react": "^19.2.2",
34
- "@types/react-dom": "^19.2.1",
38
+ "@types/react-dom": "^19.2.2",
35
39
  "mobx": "^6.15.0",
36
40
  "mobx-react-lite": "^4.1.1",
41
+ "portfinder": "^1.0.38",
37
42
  "react": "^19.2.0",
43
+ "ws": "^8.18.3",
38
44
  "yjs": "^13.6.27"
39
45
  },
40
46
  "devDependencies": {
41
- "vite": "^7.1.9"
47
+ "vite": "^7.1.12"
42
48
  },
43
49
  "peerDependencies": {
44
- "vite": "^7.1.4"
50
+ "vite": "^7.1.9"
45
51
  }
46
52
  }
@@ -0,0 +1,31 @@
1
+ import { resolve } from 'node:path'
2
+ import type { Plugin } from 'vite'
3
+
4
+ export class EposVite {
5
+ private libs: Record<string, string> = {
6
+ 'react': resolve(import.meta.dirname, './libs/libs-react.js'),
7
+ 'react/jsx-runtime': resolve(import.meta.dirname, './libs/libs-react-jsx-runtime.js'),
8
+ 'react-dom': resolve(import.meta.dirname, './libs/libs-react-dom.js'),
9
+ 'react-dom/client': resolve(import.meta.dirname, './libs/libs-react-dom-client.js'),
10
+ 'mobx': resolve(import.meta.dirname, './libs/libs-mobx.js'),
11
+ 'mobx-react-lite': resolve(import.meta.dirname, './libs/libs-mobx-react-lite.js'),
12
+ }
13
+
14
+ get plugin(): Plugin {
15
+ return {
16
+ name: 'epos',
17
+ enforce: 'pre',
18
+ resolveId: this.onResolveId,
19
+ }
20
+ }
21
+
22
+ private onResolveId = (source: string) => {
23
+ return this.libs[source] ?? null
24
+ }
25
+ }
26
+
27
+ export function epos() {
28
+ return new EposVite().plugin
29
+ }
30
+
31
+ export default epos
package/src/epos.ts CHANGED
@@ -1,5 +1,3 @@
1
- import './chrome-types.d.ts'
2
-
3
1
  import type * as mobx from 'mobx'
4
2
  import type * as mobxReactLite from 'mobx-react-lite'
5
3
  import type * as react from 'react'
@@ -7,6 +5,7 @@ import type * as reactDom from 'react-dom'
7
5
  import type * as reactDomClient from 'react-dom/client'
8
6
  import type * as reactJsxRuntime from 'react/jsx-runtime'
9
7
  import type * as yjs from 'yjs'
8
+ import './chrome-types.d.ts'
10
9
 
11
10
  export type Fn<T = any> = (...args: any[]) => T
12
11
  export type Obj = Record<string, unknown>
@@ -20,6 +19,38 @@ export type StateConfig = {
20
19
  allowMissingModels?: boolean | string[]
21
20
  }
22
21
 
22
+ export type ReqInit = {
23
+ body: RequestInit['body']
24
+ cache: RequestInit['cache']
25
+ credentials: RequestInit['credentials']
26
+ headers: RequestInit['headers']
27
+ integrity: RequestInit['integrity']
28
+ keepalive: RequestInit['keepalive']
29
+ method: RequestInit['method']
30
+ mode: RequestInit['mode']
31
+ priority: RequestInit['priority']
32
+ redirect: RequestInit['redirect']
33
+ referrer: RequestInit['referrer']
34
+ referrerPolicy: RequestInit['referrerPolicy']
35
+ }
36
+
37
+ export type Res = {
38
+ ok: Response['ok']
39
+ url: Response['url']
40
+ type: Response['type']
41
+ status: Response['status']
42
+ statusText: Response['statusText']
43
+ redirected: Response['redirected']
44
+ text: Response['text']
45
+ json: Response['json']
46
+ blob: Response['blob']
47
+ headers: {
48
+ get: Response['headers']['get']
49
+ has: Response['headers']['has']
50
+ keys: () => string[]
51
+ }
52
+ }
53
+
23
54
  export type Storage = {
24
55
  /** Get value from the storage. */
25
56
  get<T = unknown>(key: string): Promise<T>
@@ -35,14 +66,11 @@ export type Storage = {
35
66
 
36
67
  export interface Epos {
37
68
  // General
38
- fetch: typeof window.fetch
69
+ fetch: (url: string | URL, init?: ReqInit) => Promise<Res>
39
70
  browser: typeof chrome
40
71
  element: HTMLDivElement
41
72
  render(node: react.ReactNode, container?: reactDomClient.Container): void
42
- component: {
43
- <P>(Component: react.FC<P>): typeof Component
44
- <P>(name: string, Component: react.FC<P>): typeof Component
45
- }
73
+ component<T>(Component: react.FC<T>): typeof Component
46
74
 
47
75
  // Bus
48
76
  bus: {
@@ -120,19 +148,25 @@ export interface Epos {
120
148
  list(): Promise<{ name: string | null; url: string }[]>
121
149
  }
122
150
 
123
- // Static
124
- static: {
125
- /** Get static file URL. The file must be loaded first via `epos.static.load`. */
151
+ // Assets
152
+ assets: {
153
+ /** Get asset URL. The asset must be loaded first via `epos.assets.load`. */
126
154
  url(path: string): string
127
- /** Load static file by path. */
128
- load(path: string): Promise<Blob>
129
- /** Load all static files. */
130
- loadAll(): Promise<Blob[]>
131
- /** Unload static file from memory. */
132
- unload(path: string): void
133
- /** Unload all static files from memory. */
134
- unloadAll(): void
135
- /** Get list of all available static files. */
155
+ /** Load either all assets or a specific asset by its path. */
156
+ load: {
157
+ /** Load all assets. */
158
+ (): Promise<void>
159
+ /** Load asset by path. */
160
+ (path: string): Promise<Blob>
161
+ }
162
+ /** Unload either all assets from memory or a specific asset by its path. */
163
+ unload: {
164
+ /** Unload all assets from memory. */
165
+ (): void
166
+ /** Unload asset by path. */
167
+ (path: string): void
168
+ }
169
+ /** Get list of all available asset files. */
136
170
  list(filter?: { loaded?: boolean }): { path: string; loaded: boolean }[]
137
171
  }
138
172
 
@@ -169,4 +203,4 @@ declare global {
169
203
 
170
204
  const _epos = epos
171
205
  export { _epos as epos }
172
- export default epos
206
+ export default _epos
package/dist/vite.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Plugin } from 'vite';
2
-
3
- declare function epos(): Plugin;
4
-
5
- export { epos as default, epos };
package/dist/vite.js DELETED
@@ -1,22 +0,0 @@
1
- // src/vite.ts
2
- import { resolve } from "path";
3
- var libs = {
4
- "react": resolve(import.meta.dirname, "./libs/libs-react.js"),
5
- "react/jsx-runtime": resolve(import.meta.dirname, "./libs/libs-react-jsx-runtime.js"),
6
- "react-dom": resolve(import.meta.dirname, "./libs/libs-react-dom.js"),
7
- "react-dom/client": resolve(import.meta.dirname, "./libs/libs-react-dom-client.js"),
8
- "mobx": resolve(import.meta.dirname, "./libs/libs-mobx.js"),
9
- "mobx-react-lite": resolve(import.meta.dirname, "./libs/libs-mobx-react-lite.js")
10
- };
11
- function epos() {
12
- return {
13
- name: "epos",
14
- enforce: "pre",
15
- resolveId: (source) => libs[source] ?? null
16
- };
17
- }
18
- var vite_default = epos;
19
- export {
20
- vite_default as default,
21
- epos
22
- };
package/src/vite.ts DELETED
@@ -1,21 +0,0 @@
1
- import { resolve } from 'node:path'
2
- import type { Plugin } from 'vite'
3
-
4
- const libs: Record<string, string> = {
5
- 'react': resolve(import.meta.dirname, './libs/libs-react.js'),
6
- 'react/jsx-runtime': resolve(import.meta.dirname, './libs/libs-react-jsx-runtime.js'),
7
- 'react-dom': resolve(import.meta.dirname, './libs/libs-react-dom.js'),
8
- 'react-dom/client': resolve(import.meta.dirname, './libs/libs-react-dom-client.js'),
9
- 'mobx': resolve(import.meta.dirname, './libs/libs-mobx.js'),
10
- 'mobx-react-lite': resolve(import.meta.dirname, './libs/libs-mobx-react-lite.js'),
11
- }
12
-
13
- export function epos(): Plugin {
14
- return {
15
- name: 'epos',
16
- enforce: 'pre',
17
- resolveId: source => libs[source] ?? null,
18
- }
19
- }
20
-
21
- export default epos