epos 1.4.2 → 1.5.1

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.
Files changed (35) hide show
  1. package/dist/epos/epos.d.ts +72 -0
  2. package/dist/epos/epos.js +3 -0
  3. package/dist/manifest/manifest.d.ts +6 -0
  4. package/dist/manifest/manifest.js +4 -0
  5. package/dist/plugin/lib/lib-mobx-react-lite.d.ts +1 -0
  6. package/dist/plugin/lib/lib-mobx-react-lite.js +1 -0
  7. package/dist/plugin/lib/lib-mobx.d.ts +6 -0
  8. package/dist/plugin/lib/lib-mobx.js +1 -0
  9. package/dist/plugin/lib/lib-react-dom-client.d.ts +3 -0
  10. package/dist/plugin/lib/lib-react-dom-client.js +2 -0
  11. package/dist/plugin/lib/lib-react-dom.d.ts +3 -0
  12. package/dist/plugin/lib/lib-react-dom.js +2 -0
  13. package/dist/plugin/lib/lib-react-jsx-runtime.d.ts +3 -0
  14. package/dist/plugin/lib/lib-react-jsx-runtime.js +2 -0
  15. package/dist/plugin/lib/lib-react.d.ts +11 -0
  16. package/dist/plugin/lib/lib-react.js +2 -0
  17. package/dist/plugin/plugin-esbuild.d.ts +3 -0
  18. package/dist/plugin/plugin-esbuild.js +27 -0
  19. package/dist/plugin/plugin-vite.d.ts +3 -0
  20. package/dist/plugin/plugin-vite.js +29 -0
  21. package/epos.schema.json +92 -0
  22. package/package.json +28 -22
  23. package/eslint.config.js +0 -19
  24. package/prettier.config.mjs +0 -7
  25. package/src/bridge/bridge-mobx-react.js +0 -35
  26. package/src/bridge/bridge-mobx.js +0 -141
  27. package/src/bridge/bridge-react-dom-client.js +0 -5
  28. package/src/bridge/bridge-react-dom.js +0 -35
  29. package/src/bridge/bridge-react-jsx-runtime.js +0 -5
  30. package/src/bridge/bridge-react.js +0 -85
  31. package/src/kit/kit-bin.js +0 -8
  32. package/src/kit/kit-server.js +0 -176
  33. package/src/plugin/plugin-esbuild.js +0 -37
  34. package/src/plugin/plugin-vite.js +0 -40
  35. package/src/types/types.d.ts +0 -61
@@ -0,0 +1,72 @@
1
+ import type * as Mobx from 'mobx';
2
+ import type * as MobxReactLite from 'mobx-react-lite';
3
+ import type * as React from 'react';
4
+ import type * as ReactDom from 'react-dom';
5
+ import type * as ReactDomClient from 'react-dom/client';
6
+ import type * as ReactJsxRuntime from 'react/jsx-runtime';
7
+ type Fn = (...args: unknown[]) => unknown;
8
+ export type Epos = {
9
+ on(name: string, callback: Fn, thisValue?: unknown): void;
10
+ off(name: string, callback?: Fn): void;
11
+ once(name: string, callback: Fn, thisValue?: unknown): void;
12
+ send(name: string, ...args: unknown[]): Promise<unknown>;
13
+ call(name: string, ...args: unknown[]): Promise<unknown>;
14
+ connect(): void;
15
+ disconnect(): void;
16
+ transaction(): void;
17
+ autorun(): void;
18
+ reaction(): void;
19
+ root: HTMLElement;
20
+ shadow: ShadowRoot;
21
+ component(): void;
22
+ render(): void;
23
+ portal(): void;
24
+ useState(): void;
25
+ useAutorun(): void;
26
+ useReaction(): void;
27
+ fetch(): void;
28
+ browser(): void;
29
+ storage: {
30
+ get(): void;
31
+ set(): void;
32
+ delete(): void;
33
+ keys(): void;
34
+ clear(): void;
35
+ connect(): void;
36
+ };
37
+ assets: {
38
+ use(): void;
39
+ useUrl(): void;
40
+ get(): void;
41
+ getUrl(): void;
42
+ load(): void;
43
+ offload(): void;
44
+ list(): void;
45
+ };
46
+ env: {
47
+ name: string;
48
+ tabId: number;
49
+ is: {
50
+ tab: boolean;
51
+ hub: boolean;
52
+ web: boolean;
53
+ view: boolean;
54
+ popup: boolean;
55
+ panel: boolean;
56
+ background: boolean;
57
+ foreground: boolean;
58
+ };
59
+ };
60
+ mobx: typeof Mobx;
61
+ mobxReactLite: typeof MobxReactLite;
62
+ react: typeof React;
63
+ reactDom: typeof ReactDom;
64
+ reactDomClient: typeof ReactDomClient;
65
+ reactJsxRuntime: typeof ReactJsxRuntime;
66
+ };
67
+ declare global {
68
+ var epos: Epos;
69
+ }
70
+ declare const _epos: Epos;
71
+ export { _epos as epos };
72
+ export default _epos;
@@ -0,0 +1,3 @@
1
+ const _epos = epos;
2
+ export { _epos as epos };
3
+ export default _epos;
@@ -0,0 +1,6 @@
1
+ export type Manifest = {
2
+ name: string;
3
+ [key: string]: any;
4
+ };
5
+ export declare function defineManifest(manifest: Manifest): Manifest;
6
+ export default defineManifest;
@@ -0,0 +1,4 @@
1
+ export function defineManifest(manifest) {
2
+ return manifest;
3
+ }
4
+ export default defineManifest;
@@ -0,0 +1 @@
1
+ export declare const enableStaticRendering: typeof import("mobx-react-lite").enableStaticRendering, isUsingStaticRendering: typeof import("mobx-react-lite").isUsingStaticRendering, observer: typeof import("mobx-react-lite").observer, Observer: typeof import("mobx-react-lite").Observer, observerBatching: typeof import("mobx-react-lite").observerBatching, useAsObservableSource: typeof import("mobx-react-lite").useAsObservableSource, useLocalObservable: typeof import("mobx-react-lite").useLocalObservable, useLocalStore: typeof import("mobx-react-lite").useLocalStore, useObserver: typeof import("mobx-react-lite").useObserver, useStaticRendering: typeof import("mobx-react-lite").useStaticRendering;
@@ -0,0 +1 @@
1
+ export const { enableStaticRendering, isUsingStaticRendering, observer, Observer, observerBatching, useAsObservableSource, useLocalObservable, useLocalStore, useObserver, useStaticRendering, } = epos.mobxReactLite;
@@ -0,0 +1,6 @@
1
+ export declare const _allowStateChanges: typeof import("mobx")._allowStateChanges, _allowStateChangesInsideComputed: typeof import("mobx").runInAction, _allowStateReadsEnd: typeof import("mobx")._allowStateReadsEnd, _allowStateReadsStart: typeof import("mobx")._allowStateReadsStart, _autoAction: import("mobx").IActionFactory, _endAction: typeof import("mobx")._endAction, _getAdministration: typeof import("mobx")._getAdministration, _getGlobalState: typeof import("mobx")._getGlobalState, _interceptReads: typeof import("mobx")._interceptReads, _isComputingDerivation: typeof import("mobx")._isComputingDerivation, _resetGlobalState: typeof import("mobx")._resetGlobalState, _startAction: typeof import("mobx")._startAction, $mobx: symbol, action: import("mobx").IActionFactory, autorun: typeof import("mobx").autorun, comparer: {
2
+ identity: (a: any, b: any) => boolean;
3
+ structural: (a: any, b: any) => boolean;
4
+ default: (a: any, b: any) => boolean;
5
+ shallow: (a: any, b: any) => boolean;
6
+ }, computed: import("mobx").IComputedFactory, configure: typeof import("mobx").configure, createAtom: typeof import("mobx").createAtom, defineProperty: typeof import("mobx").defineProperty, entries: typeof import("mobx").entries, extendObservable: typeof import("mobx").extendObservable, FlowCancellationError: typeof import("mobx").FlowCancellationError, flowResult: typeof import("mobx").flowResult, get: typeof import("mobx").get, getAtom: typeof import("mobx").getAtom, getDebugName: typeof import("mobx").getDebugName, getDependencyTree: typeof import("mobx").getDependencyTree, getObserverTree: typeof import("mobx").getObserverTree, has: typeof import("mobx").has, intercept: typeof import("mobx").intercept, isAction: typeof import("mobx").isAction, isBoxedObservable: (x: any) => x is import("mobx").IObservableValue<any>, isComputed: typeof import("mobx").isComputed, isComputedProp: typeof import("mobx").isComputedProp, isFlow: typeof import("mobx").isFlow, isFlowCancellationError: typeof import("mobx").isFlowCancellationError, isObservable: typeof import("mobx").isObservable, isObservableArray: typeof import("mobx").isObservableArray, isObservableMap: (thing: any) => thing is import("mobx").ObservableMap<any, any>, isObservableObject: typeof import("mobx").isObservableObject, isObservableProp: typeof import("mobx").isObservableProp, isObservableSet: (thing: any) => thing is import("mobx").ObservableSet<any>, keys: typeof import("mobx").keys, makeAutoObservable: typeof import("mobx").makeAutoObservable, makeObservable: typeof import("mobx").makeObservable, observable: import("mobx").IObservableFactory, ObservableMap: typeof import("mobx").ObservableMap, ObservableSet: typeof import("mobx").ObservableSet, observe: typeof import("mobx").observe, onBecomeObserved: typeof import("mobx").onBecomeObserved, onBecomeUnobserved: typeof import("mobx").onBecomeUnobserved, onReactionError: typeof import("mobx").onReactionError, override: import("mobx/dist/internal").Annotation & PropertyDecorator & import("mobx/dist/types/decorator_fills").ClassMethodDecorator, ownKeys: typeof import("mobx").ownKeys, reaction: typeof import("mobx").reaction, Reaction: typeof import("mobx").Reaction, remove: typeof import("mobx").remove, runInAction: typeof import("mobx").runInAction, set: typeof import("mobx").set, spy: typeof import("mobx").spy, toJS: typeof import("mobx").toJS, trace: typeof import("mobx").trace, transaction: typeof import("mobx").transaction, untracked: typeof import("mobx").untracked, values: typeof import("mobx").values, when: typeof import("mobx").when;
@@ -0,0 +1 @@
1
+ export const { _allowStateChanges, _allowStateChangesInsideComputed, _allowStateReadsEnd, _allowStateReadsStart, _autoAction, _endAction, _getAdministration, _getGlobalState, _interceptReads, _isComputingDerivation, _resetGlobalState, _startAction, $mobx, action, autorun, comparer, computed, configure, createAtom, defineProperty, entries, extendObservable, FlowCancellationError, flowResult, get, getAtom, getDebugName, getDependencyTree, getObserverTree, has, intercept, isAction, isBoxedObservable, isComputed, isComputedProp, isFlow, isFlowCancellationError, isObservable, isObservableArray, isObservableMap, isObservableObject, isObservableProp, isObservableSet, keys, makeAutoObservable, makeObservable, observable, ObservableMap, ObservableSet, observe, onBecomeObserved, onBecomeUnobserved, onReactionError, override, ownKeys, reaction, Reaction, remove, runInAction, set, spy, toJS, trace, transaction, untracked, values, when, } = epos.mobx;
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ export declare const createRoot: any, hydrateRoot: any;
@@ -0,0 +1,2 @@
1
+ export default epos.reactDOMClient;
2
+ export const { createRoot, hydrateRoot } = epos.reactDOMClient;
@@ -0,0 +1,3 @@
1
+ declare const _default: any;
2
+ export default _default;
3
+ export declare const createPortal: any, flushSync: any, preconnect: any, prefetchDNS: any, preinit: any, preinitModule: any, preload: any, preloadModule: any, requestFormReset: any, unstable_batchedUpdates: any, useFormState: any, useFormStatus: any, version: any;
@@ -0,0 +1,2 @@
1
+ export default epos.reactDOM;
2
+ export const { createPortal, flushSync, preconnect, prefetchDNS, preinit, preinitModule, preload, preloadModule, requestFormReset, unstable_batchedUpdates, useFormState, useFormStatus, version, } = epos.reactDOM;
@@ -0,0 +1,3 @@
1
+ declare const _default: typeof import("react/jsx-runtime");
2
+ export default _default;
3
+ export declare const Fragment: import("react").ExoticComponent<import("react").FragmentProps>, jsx: typeof import("react/jsx-runtime").jsx, jsxs: typeof import("react/jsx-runtime").jsxs;
@@ -0,0 +1,2 @@
1
+ export default epos.reactJsxRuntime;
2
+ export const { Fragment, jsx, jsxs } = epos.reactJsxRuntime;
@@ -0,0 +1,11 @@
1
+ declare const _default: typeof import("react");
2
+ export default _default;
3
+ export declare const act: typeof import("react").act, cache: typeof import("react").cache, Children: {
4
+ map<T, C>(children: C | readonly C[], fn: (child: C, index: number) => T): C extends null | undefined ? C : Array<Exclude<T, boolean | null | undefined>>;
5
+ forEach<C>(children: C | readonly C[], fn: (child: C, index: number) => void): void;
6
+ count(children: any): number;
7
+ only<C>(children: C): C extends any[] ? never : C;
8
+ toArray(children: import("react").ReactNode | import("react").ReactNode[]): Array<Exclude<import("react").ReactNode, boolean | null | undefined>>;
9
+ }, cloneElement: typeof import("react").cloneElement, Component: typeof import("react").Component, createContext: typeof import("react").createContext, createElement: typeof import("react").createElement, createRef: typeof import("react").createRef, forwardRef: typeof import("react").forwardRef, Fragment: import("react").ExoticComponent<import("react").FragmentProps>, isValidElement: typeof import("react").isValidElement, lazy: typeof import("react").lazy, memo: typeof import("react").memo, Profiler: import("react").ExoticComponent<import("react").ProfilerProps>, PureComponent: typeof import("react").PureComponent, startTransition: typeof import("react").startTransition, StrictMode: import("react").ExoticComponent<{
10
+ children?: import("react").ReactNode | undefined;
11
+ }>, Suspense: import("react").ExoticComponent<import("react").SuspenseProps>, use: typeof import("react").use, useActionState: typeof import("react").useActionState, useCallback: typeof import("react").useCallback, useContext: typeof import("react").useContext, useDebugValue: typeof import("react").useDebugValue, useDeferredValue: typeof import("react").useDeferredValue, useEffect: typeof import("react").useEffect, useId: typeof import("react").useId, useImperativeHandle: typeof import("react").useImperativeHandle, useInsertionEffect: typeof import("react").useInsertionEffect, useLayoutEffect: typeof import("react").useLayoutEffect, useMemo: typeof import("react").useMemo, useOptimistic: typeof import("react").useOptimistic, useReducer: typeof import("react").useReducer, useRef: typeof import("react").useRef, useState: typeof import("react").useState, useSyncExternalStore: typeof import("react").useSyncExternalStore, useTransition: typeof import("react").useTransition, version: string;
@@ -0,0 +1,2 @@
1
+ export default epos.react;
2
+ export const { act, cache, Children, cloneElement, Component, createContext, createElement, createRef, forwardRef, Fragment, isValidElement, lazy, memo, Profiler, PureComponent, startTransition, StrictMode, Suspense, use, useActionState, useCallback, useContext, useDebugValue, useDeferredValue, useEffect, useId, useImperativeHandle, useInsertionEffect, useLayoutEffect, useMemo, useOptimistic, useReducer, useRef, useState, useSyncExternalStore, useTransition, version, } = epos.react;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'esbuild';
2
+ export declare function epos(): Plugin;
3
+ export default epos;
@@ -0,0 +1,27 @@
1
+ import path from 'path';
2
+ export function epos() {
3
+ return {
4
+ name: 'epos',
5
+ setup(build) {
6
+ build.onResolve({ filter: /^react$/ }, () => ({
7
+ path: path.resolve(import.meta.dirname, './lib/lib-react.js'),
8
+ }));
9
+ build.onResolve({ filter: /^react\/jsx-runtime$/ }, () => ({
10
+ path: path.resolve(import.meta.dirname, './lib/lib-react-jsx-runtime.js'),
11
+ }));
12
+ build.onResolve({ filter: /^react-dom$/ }, () => ({
13
+ path: path.resolve(import.meta.dirname, './lib/lib-react-dom.js'),
14
+ }));
15
+ build.onResolve({ filter: /^react-dom\/client$/ }, () => ({
16
+ path: path.resolve(import.meta.dirname, './lib/lib-react-dom-client.js'),
17
+ }));
18
+ build.onResolve({ filter: /^mobx$/ }, () => ({
19
+ path: path.resolve(import.meta.dirname, './lib/lib-mobx.js'),
20
+ }));
21
+ build.onResolve({ filter: /^mobx-react$/ }, () => ({
22
+ path: path.resolve(import.meta.dirname, './lib/lib-mobx-react.js'),
23
+ }));
24
+ },
25
+ };
26
+ }
27
+ export default epos;
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function epos(): Plugin;
3
+ export default epos;
@@ -0,0 +1,29 @@
1
+ import path from 'path';
2
+ export function epos() {
3
+ return {
4
+ name: 'epos',
5
+ enforce: 'pre',
6
+ resolveId(source) {
7
+ if (source === 'react') {
8
+ return path.resolve(import.meta.dirname, './lib-react.js');
9
+ }
10
+ if (source === 'react/jsx-runtime') {
11
+ return path.resolve(import.meta.dirname, './lib-react-jsx-runtime.js');
12
+ }
13
+ if (source === 'react-dom') {
14
+ return path.resolve(import.meta.dirname, './lib-react-dom.js');
15
+ }
16
+ if (source === 'react-dom/client') {
17
+ return path.resolve(import.meta.dirname, './lib-react-dom-client.js');
18
+ }
19
+ if (source === 'mobx') {
20
+ return path.resolve(import.meta.dirname, './lib-mobx.js');
21
+ }
22
+ if (source === 'mobx-react') {
23
+ return path.resolve(import.meta.dirname, './lib-mobx-react.js');
24
+ }
25
+ return null;
26
+ },
27
+ };
28
+ }
29
+ export default epos;
@@ -0,0 +1,92 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Epos Manifest Schema",
4
+ "type": "object",
5
+ "properties": {
6
+ "$schema": { "type": "string" },
7
+ "name": { "$ref": "#/definitions/Name" },
8
+ "action": { "$ref": "#/definitions/Action" },
9
+ "popup": { "$ref": "#/definitions/Popup" },
10
+ "assets": { "$ref": "#/definitions/Assets" },
11
+ "bundles": { "$ref": "#/definitions/Bundles" },
12
+ "run": { "$ref": "#/definitions/Run" },
13
+ "src": { "$ref": "#/definitions/Src" },
14
+ "mode": { "$ref": "#/definitions/Mode" }
15
+ },
16
+ "required": ["name"],
17
+ "additionalProperties": false,
18
+
19
+ "definitions": {
20
+ "Name": {
21
+ "type": "string",
22
+ "minLength": 2,
23
+ "maxLength": 50,
24
+ "pattern": "^[a-z0-9\\-]+$"
25
+ },
26
+
27
+ "Action": {
28
+ "oneOf": [{ "type": "null" }, { "type": "string" }]
29
+ },
30
+
31
+ "Popup": {
32
+ "type": "object",
33
+ "properties": {
34
+ "width": { "type": "number", "minimum": 150, "maximum": 800, "default": 400 },
35
+ "height": { "type": "number", "minimum": 150, "maximum": 600, "default": 600 }
36
+ },
37
+ "additionalProperties": false
38
+ },
39
+
40
+ "Assets": {
41
+ "type": "array",
42
+ "items": { "$ref": "#/definitions/Asset" }
43
+ },
44
+
45
+ "Asset": {
46
+ "type": "string"
47
+ },
48
+
49
+ "Bundles": {
50
+ "type": "array",
51
+ "items": { "$ref": "#/definitions/Bundle" }
52
+ },
53
+
54
+ "Bundle": {
55
+ "type": "object",
56
+ "properties": {
57
+ "run": { "$ref": "#/definitions/Run" },
58
+ "src": { "$ref": "#/definitions/Src" },
59
+ "mode": { "$ref": "#/definitions/Mode" }
60
+ },
61
+ "additionalProperties": false
62
+ },
63
+
64
+ "Run": {
65
+ "oneOf": [
66
+ { "$ref": "#/definitions/RunItem" },
67
+ { "type": "array", "items": { "$ref": "#/definitions/RunItem" } }
68
+ ]
69
+ },
70
+
71
+ "RunItem": {
72
+ "type": "string"
73
+ },
74
+
75
+ "Src": {
76
+ "oneOf": [
77
+ { "$ref": "#/definitions/SrcItem" },
78
+ { "type": "array", "items": { "$ref": "#/definitions/SrcItem" } }
79
+ ]
80
+ },
81
+
82
+ "SrcItem": {
83
+ "type": "string",
84
+ "pattern": "^.*\\.(css|js|[^.]+)$"
85
+ },
86
+
87
+ "Mode": {
88
+ "type": "string",
89
+ "enum": ["normal", "shadow", "lite"]
90
+ }
91
+ }
92
+ }
package/package.json CHANGED
@@ -1,38 +1,44 @@
1
1
  {
2
2
  "name": "epos",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
+ "type": "module",
4
5
  "author": "imkost",
5
6
  "description": "",
6
7
  "keywords": [],
7
8
  "license": "MIT",
8
- "type": "module",
9
9
  "scripts": {
10
- "dev": "node ./src/kit/kit-bin.js",
10
+ "dev": "rimraf dist; tsc --watch",
11
+ "build": "rimraf dist; tsc",
11
12
  "lint": "eslint ./src",
12
- "release": "npm publish --loglevel=error"
13
- },
14
- "bin": {
15
- "epos": "src/kit/kit-bin.js"
13
+ "release": "npm version patch && npm publish"
16
14
  },
17
15
  "exports": {
18
16
  ".": {
19
- "types": "./src/types/types.d.ts"
17
+ "import": "./dist/epos/epos.js"
20
18
  },
21
- "./plugin-vite": "./src/plugin-vite.js",
22
- "./plugin-esbuild": "./src/plugin-esbuild.js"
23
- },
24
- "dependencies": {
25
- "chokidar": "^4.0.3",
26
- "glob": "^11.0.1",
27
- "ignore": "^7.0.3",
28
- "js-yaml": "^4.1.0",
29
- "mime": "^4.0.6",
30
- "prettier": "^3.4.2",
31
- "ws": "^8.18.0"
19
+ "./vite": {
20
+ "import": "./dist/plugin/plugin-vite.js"
21
+ },
22
+ "./esbuild": {
23
+ "import": "./dist/plugin/plugin-esbuild.js"
24
+ },
25
+ "./manifest": {
26
+ "import": "./dist/manifest/manifest.js"
27
+ }
32
28
  },
29
+ "files": [
30
+ "dist",
31
+ "epos.schema.json"
32
+ ],
33
33
  "devDependencies": {
34
- "@eslint/js": "^9.18.0",
35
- "eslint": "^9.18.0",
36
- "globals": "^15.14.0"
34
+ "@types/chrome": "^0.1.1",
35
+ "@types/react": "^19.1.8",
36
+ "@types/react-dom": "^19.1.6",
37
+ "esbuild": "^0.25.8",
38
+ "mobx": "^6.13.7",
39
+ "mobx-react-lite": "^4.1.0",
40
+ "react": "^19.1.0",
41
+ "rimraf": "^6.0.1",
42
+ "vite": "^7.0.6"
37
43
  }
38
44
  }
package/eslint.config.js DELETED
@@ -1,19 +0,0 @@
1
- import globals from 'globals'
2
- import pluginJs from '@eslint/js'
3
-
4
- /** @type {import('eslint').Linter.Config[]} */
5
- export default [
6
- { languageOptions: { globals: globals.browser } },
7
- pluginJs.configs.recommended,
8
- {
9
- languageOptions: {
10
- globals: {
11
- Self: false,
12
- process: false,
13
- },
14
- },
15
- rules: {
16
- 'no-unused-labels': 0,
17
- },
18
- },
19
- ]
@@ -1,7 +0,0 @@
1
- export default {
2
- semi: false,
3
- singleQuote: true,
4
- arrowParens: 'avoid',
5
- quoteProps: 'preserve',
6
- printWidth: 87,
7
- }
@@ -1,35 +0,0 @@
1
- const {
2
- MobXProviderContext,
3
- Observer,
4
- PropTypes,
5
- Provider,
6
- disposeOnUnmount,
7
- enableStaticRendering,
8
- inject,
9
- isUsingStaticRendering,
10
- observer,
11
- observerBatching,
12
- useAsObservableSource,
13
- useLocalObservable,
14
- useLocalStore,
15
- useObserver,
16
- useStaticRendering,
17
- } = Self.mobxReact
18
-
19
- export {
20
- MobXProviderContext,
21
- Observer,
22
- PropTypes,
23
- Provider,
24
- disposeOnUnmount,
25
- enableStaticRendering,
26
- inject,
27
- isUsingStaticRendering,
28
- observer,
29
- observerBatching,
30
- useAsObservableSource,
31
- useLocalObservable,
32
- useLocalStore,
33
- useObserver,
34
- useStaticRendering,
35
- }
@@ -1,141 +0,0 @@
1
- const {
2
- $mobx,
3
- FlowCancellationError,
4
- ObservableMap,
5
- ObservableSet,
6
- Reaction,
7
- _allowStateChanges,
8
- _allowStateChangesInsideComputed,
9
- _allowStateReadsEnd,
10
- _allowStateReadsStart,
11
- _autoAction,
12
- _endAction,
13
- _getAdministration,
14
- _getGlobalState,
15
- _interceptReads,
16
- _isComputingDerivation,
17
- _resetGlobalState,
18
- _startAction,
19
- action,
20
- autorun,
21
- comparer,
22
- computed,
23
- configure,
24
- createAtom,
25
- defineProperty,
26
- entries,
27
- extendObservable,
28
- flow,
29
- flowResult,
30
- get,
31
- getAtom,
32
- getDebugName,
33
- getDependencyTree,
34
- getObserverTree,
35
- has,
36
- intercept,
37
- isAction,
38
- isBoxedObservable,
39
- isComputed,
40
- isComputedProp,
41
- isFlow,
42
- isFlowCancellationError,
43
- isObservable,
44
- isObservableArray,
45
- isObservableMap,
46
- isObservableObject,
47
- isObservableProp,
48
- isObservableSet,
49
- keys,
50
- makeAutoObservable,
51
- makeObservable,
52
- observable,
53
- observe,
54
- onBecomeObserved,
55
- onBecomeUnobserved,
56
- onReactionError,
57
- override,
58
- ownKeys,
59
- reaction,
60
- remove,
61
- runInAction,
62
- set,
63
- spy,
64
- toJS,
65
- trace,
66
- transaction,
67
- untracked,
68
- values,
69
- when,
70
- } = Self.mobx
71
-
72
- export {
73
- $mobx,
74
- FlowCancellationError,
75
- ObservableMap,
76
- ObservableSet,
77
- Reaction,
78
- _allowStateChanges,
79
- _allowStateChangesInsideComputed,
80
- _allowStateReadsEnd,
81
- _allowStateReadsStart,
82
- _autoAction,
83
- _endAction,
84
- _getAdministration,
85
- _getGlobalState,
86
- _interceptReads,
87
- _isComputingDerivation,
88
- _resetGlobalState,
89
- _startAction,
90
- action,
91
- autorun,
92
- comparer,
93
- computed,
94
- configure,
95
- createAtom,
96
- defineProperty,
97
- entries,
98
- extendObservable,
99
- flow,
100
- flowResult,
101
- get,
102
- getAtom,
103
- getDebugName,
104
- getDependencyTree,
105
- getObserverTree,
106
- has,
107
- intercept,
108
- isAction,
109
- isBoxedObservable,
110
- isComputed,
111
- isComputedProp,
112
- isFlow,
113
- isFlowCancellationError,
114
- isObservable,
115
- isObservableArray,
116
- isObservableMap,
117
- isObservableObject,
118
- isObservableProp,
119
- isObservableSet,
120
- keys,
121
- makeAutoObservable,
122
- makeObservable,
123
- observable,
124
- observe,
125
- onBecomeObserved,
126
- onBecomeUnobserved,
127
- onReactionError,
128
- override,
129
- ownKeys,
130
- reaction,
131
- remove,
132
- runInAction,
133
- set,
134
- spy,
135
- toJS,
136
- trace,
137
- transaction,
138
- untracked,
139
- values,
140
- when,
141
- }
@@ -1,5 +0,0 @@
1
- const reactDomClient = Self.reactDomClient
2
- const { createRoot, hydrateRoot, version } = reactDomClient
3
-
4
- export default reactDomClient
5
- export { createRoot, hydrateRoot, version }
@@ -1,35 +0,0 @@
1
- const reactDom = Self.reactDom
2
- const {
3
- __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
4
- createPortal,
5
- flushSync,
6
- preconnect,
7
- prefetchDNS,
8
- preinit,
9
- preinitModule,
10
- preload,
11
- preloadModule,
12
- requestFormReset,
13
- unstable_batchedUpdates,
14
- useFormState,
15
- useFormStatus,
16
- version,
17
- } = reactDom
18
-
19
- export default reactDom
20
- export {
21
- __DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
22
- createPortal,
23
- flushSync,
24
- preconnect,
25
- prefetchDNS,
26
- preinit,
27
- preinitModule,
28
- preload,
29
- preloadModule,
30
- requestFormReset,
31
- unstable_batchedUpdates,
32
- useFormState,
33
- useFormStatus,
34
- version,
35
- }
@@ -1,5 +0,0 @@
1
- const reactJsxRuntime = Self.reactJsxRuntime
2
- const { Fragment, jsx, jsxs } = reactJsxRuntime
3
-
4
- export default reactJsxRuntime
5
- export { Fragment, jsx, jsxs }
@@ -1,85 +0,0 @@
1
- const react = Self.react
2
- const {
3
- Children,
4
- Component,
5
- Fragment,
6
- Profiler,
7
- PureComponent,
8
- StrictMode,
9
- Suspense,
10
- __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
11
- act,
12
- cache,
13
- cloneElement,
14
- createContext,
15
- createElement,
16
- createRef,
17
- forwardRef,
18
- isValidElement,
19
- lazy,
20
- memo,
21
- startTransition,
22
- unstable_useCacheRefresh,
23
- use,
24
- useActionState,
25
- useCallback,
26
- useContext,
27
- useDebugValue,
28
- useDeferredValue,
29
- useEffect,
30
- useId,
31
- useImperativeHandle,
32
- useInsertionEffect,
33
- useLayoutEffect,
34
- useMemo,
35
- useOptimistic,
36
- useReducer,
37
- useRef,
38
- useState,
39
- useSyncExternalStore,
40
- useTransition,
41
- version,
42
- } = react
43
-
44
- export default react
45
- export {
46
- Children,
47
- Component,
48
- Fragment,
49
- Profiler,
50
- PureComponent,
51
- StrictMode,
52
- Suspense,
53
- __CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
54
- act,
55
- cache,
56
- cloneElement,
57
- createContext,
58
- createElement,
59
- createRef,
60
- forwardRef,
61
- isValidElement,
62
- lazy,
63
- memo,
64
- startTransition,
65
- unstable_useCacheRefresh,
66
- use,
67
- useActionState,
68
- useCallback,
69
- useContext,
70
- useDebugValue,
71
- useDeferredValue,
72
- useEffect,
73
- useId,
74
- useImperativeHandle,
75
- useInsertionEffect,
76
- useLayoutEffect,
77
- useMemo,
78
- useOptimistic,
79
- useReducer,
80
- useRef,
81
- useState,
82
- useSyncExternalStore,
83
- useTransition,
84
- version,
85
- }
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import $server from './kit-server.js'
4
-
5
- run: (async () => {
6
- const dir = process.argv[2] || process.cwd()
7
- await $server.init(dir)
8
- })()
@@ -1,176 +0,0 @@
1
- import $fs from 'node:fs/promises'
2
- import $path from 'path'
3
- import $http from 'node:http'
4
- import $mime from 'mime'
5
- import $yaml from 'js-yaml'
6
- import $chokidar from 'chokidar'
7
- import * as $ws from 'ws'
8
-
9
- const $server = {
10
- async init(dir) {
11
- this._dir = dir
12
- this._port = 4322
13
- this._maxFiles = 10_000
14
-
15
- this._wss = null
16
- this._server = null
17
- this._pkgs = {} // { [path]: { name, dir, watcher } }
18
-
19
- await this._initServer()
20
- await this._initWebSocket()
21
- await this._startWatcher()
22
-
23
- console.log('🟢 ready')
24
- },
25
-
26
- async _initServer() {
27
- const ready = Promise.withResolvers()
28
-
29
- this._server = $http.createServer(async (req, res) => {
30
- try {
31
- const { data, type } = await this._handleRequest(req)
32
- res.writeHead(200, { 'Content-Type': type })
33
- res.end(data)
34
- } catch (e) {
35
- if (e === 404) {
36
- res.writeHead(404, { 'Content-Type': 'text/plain' })
37
- res.end('404: File Not Found')
38
- } else {
39
- console.error(e)
40
- res.writeHead(500, { 'Content-Type': 'text/plain' })
41
- res.end('500: Internal Server Error')
42
- }
43
- }
44
- })
45
-
46
- this._server.listen(this._port, () => {
47
- ready.resolve()
48
- })
49
-
50
- this._server.on('error', e => {
51
- if (e.code === 'EADDRINUSE') {
52
- console.log(`🔴 port ${this._port} is already in use`)
53
- process.exit()
54
- }
55
- ready.reject(e)
56
- })
57
-
58
- await ready.promise
59
- },
60
-
61
- async _initWebSocket() {
62
- this._wss = new $ws.WebSocketServer({ server: this._server })
63
- },
64
-
65
- async _startWatcher() {
66
- const ready = Promise.withResolvers()
67
- const watcher = $chokidar.watch(this._dir, { ignored: this._ignored })
68
-
69
- // initial scan
70
- let done = false
71
- let files = 0
72
- watcher.on('add', async () => {
73
- if (done) return
74
- files += 1
75
- if (files < this._maxFiles) return
76
- console.log(`🔴 too many files in ${this._dir}`)
77
- console.log('ℹ️ select directory with fewer files')
78
- process.exit()
79
- })
80
- watcher.on('ready', () => {
81
- done = false
82
- ready.resolve()
83
- })
84
-
85
- // watch manifest files
86
- const variants = new Set(['epos.json', 'epos.yaml', 'epos.yml'])
87
- watcher.on('all', async (event, path) => {
88
- const isManifest = variants.has($path.basename(path))
89
- if (!isManifest) return
90
-
91
- // manifest removed? -> stop pkg watcher
92
- if (event === 'unlink') {
93
- if (!this._pkgs[path]) return
94
- this._pkgs[path].watcher.close()
95
- delete this._pkgs[path]
96
- return
97
- }
98
-
99
- // read manifest
100
- let name = null
101
- let manifest = null
102
- try {
103
- const isJson = path.endsWith('.json')
104
- const content = await $fs.readFile(path, 'utf-8')
105
- manifest = isJson ? JSON.parse(content) : $yaml.load(content)
106
- name = manifest.name
107
- } catch {}
108
-
109
- // invalid manifest? -> stop pkg watcher
110
- if (!name) {
111
- if (!this._pkgs[path]) return
112
- this._pkgs[path].watcher.close()
113
- delete this._pkgs[path]
114
- return
115
- }
116
-
117
- // create pkg watcher
118
- const dir = $path.dirname(path)
119
- const pkgWatcher = this._createPkgWatcher(name, dir)
120
- this._pkgs[path] = { name, dir, watcher: pkgWatcher }
121
- })
122
-
123
- await ready.promise
124
- },
125
-
126
- _createPkgWatcher(name, dir) {
127
- const watcher = $chokidar.watch(dir, { ignored: this._ignored })
128
-
129
- // broadcast all changes
130
- watcher.on('all', (event, path) => {
131
- const data = JSON.stringify({ name, path: $path.relative(dir, path) })
132
- for (const client of this._wss.clients) {
133
- if (client.readyState !== 1) continue
134
- client.send(data)
135
- }
136
- })
137
-
138
- return watcher
139
- },
140
-
141
- async _handleRequest(req) {
142
- // /<pkgName>/some/path/to/file.jsx
143
- const [pkgName, ...filePath] = req.url.split('/').slice(1)
144
-
145
- // pkg not found? -> 404
146
- const pkg = Object.values(this._pkgs).find(p => p.name === pkgName)
147
- if (!pkg) throw 404
148
-
149
- // file not found? -> 404
150
- const path = $path.join(pkg.dir, ...filePath)
151
- const exists = await this._fileExists(path)
152
- if (!exists) throw 404
153
-
154
- // respond file
155
- const data = await $fs.readFile(path)
156
- const type = $mime.getType(path) || 'application/octet-stream'
157
- return { data, type }
158
- },
159
-
160
- async _fileExists(path) {
161
- try {
162
- await $fs.access(path, $fs.constants.F_OK)
163
- return true
164
- } catch {
165
- return false
166
- }
167
- },
168
-
169
- _ignored(path) {
170
- if (path.includes('node_modules')) return true
171
- if ($path.basename(path).startsWith('.')) return true
172
- return false
173
- },
174
- }
175
-
176
- export default $server
@@ -1,37 +0,0 @@
1
- import $path from 'path'
2
- const dirname = import.meta.dirname
3
-
4
- export default {
5
- name: 'epos-plugin/esbuild',
6
- setup(build) {
7
- // react
8
- build.onResolve({ filter: /^react$/ }, () => ({
9
- path: $path.resolve(dirname, '../bridge/bridge-react.js'),
10
- }))
11
-
12
- // react/jsx-runtime
13
- build.onResolve({ filter: /^react\/jsx-runtime$/ }, () => ({
14
- path: $path.resolve(dirname, '../bridge/bridge-react-jsx-runtime.js'),
15
- }))
16
-
17
- // react-dom
18
- build.onResolve({ filter: /^react-dom$/ }, () => ({
19
- path: $path.resolve(dirname, '../bridge/bridge-react-dom.js'),
20
- }))
21
-
22
- // react-dom/client
23
- build.onResolve({ filter: /^react-dom\/client$/ }, () => ({
24
- path: $path.resolve(dirname, '../bridge/bridge-react-dom-client.js'),
25
- }))
26
-
27
- // mobx
28
- build.onResolve({ filter: /^mobx$/ }, () => ({
29
- path: $path.resolve(dirname, '../bridge/bridge-mobx.js'),
30
- }))
31
-
32
- // mobx-react
33
- build.onResolve({ filter: /^mobx-react$/ }, () => ({
34
- path: $path.resolve(dirname, '../bridge/bridge-mobx-react.js'),
35
- }))
36
- },
37
- }
@@ -1,40 +0,0 @@
1
- import $path from 'path'
2
- const dirname = import.meta.dirname
3
-
4
- export default {
5
- name: 'epos-plugin/vite',
6
- enforce: 'pre',
7
- resolveId(source) {
8
- // react
9
- if (source === 'react') {
10
- return $path.resolve(dirname, '../bridge/bridge-react.js')
11
- }
12
-
13
- // react/jsx-runtime
14
- if (source === 'react/jsx-runtime') {
15
- return $path.resolve(dirname, '../bridge/bridge-react-jsx-runtime.js')
16
- }
17
-
18
- // react-dom
19
- if (source === 'react-dom') {
20
- return $path.resolve(dirname, '../bridge/bridge-react-dom.js')
21
- }
22
-
23
- // react-dom/client
24
- if (source === 'react-dom/client') {
25
- return $path.resolve(dirname, '../bridge/bridge-react-dom-client.js')
26
- }
27
-
28
- // mobx
29
- if (source === 'mobx') {
30
- return $path.resolve(dirname, '../bridge/bridge-mobx.js')
31
- }
32
-
33
- // mobx-react
34
- if (source === 'mobx-react') {
35
- return $path.resolve(dirname, '../bridge/bridge-mobx-react.js')
36
- }
37
-
38
- return null
39
- },
40
- }
@@ -1,61 +0,0 @@
1
- declare var self: EposSelf
2
- declare var Self: EposSelf
3
-
4
- interface EposSelf {
5
- name: string
6
- state: Record<string, any>
7
- tabId: number
8
- browser: Record<string, any>
9
- root: HTMLElement
10
- shadow: ShadowRoot
11
-
12
- on: (event: string, callback: (...args: any[]) => any) => void
13
- off: (event: string, callback?: (...args: any[]) => any) => void
14
- send: (event: string, ...args: any[]) => Promise<any>
15
- call: (event: string, ...args: any[]) => Promise<any>
16
- use: (pkgName: string) => any
17
- fetch: (url: string, opts?: object) => Promise<object>
18
- render: (what: any, container?: HTMLElement | ShadowRoot) => void
19
- portal: (vnode: object, container: HTMLElement | ShadowRoot) => void
20
-
21
- unit<T extends Record<string, unknown> & { create?: (...args: any[]) => any }>(
22
- name: string,
23
- schema: T,
24
- ): T['create'] extends (...args: infer P) => any ? (...args: P) => T : () => T
25
-
26
- is: {
27
- tab: boolean
28
- popup: boolean
29
- sidePanel: boolean
30
- background: boolean
31
- }
32
-
33
- component: {
34
- (render: Function): any
35
- (name: string, render: Function): any
36
- (schema: Record<string, any>): any
37
- (name: string, schema: Record<string, any>): any
38
- }
39
-
40
- storage: {
41
- get(key: string): Promise<any>
42
- set(key: string, value: any): Promise<void>
43
- keys(): Promise<string[]>
44
- remove(key: string): Promise<void>
45
- clear(): Promise<void>
46
- connect(name: string): Omit<EposSelf['storage'], 'connect'>
47
- }
48
-
49
- files: {
50
- get: (name: string) => Promise<Blob>
51
- url: (name: string) => Promise<string>
52
- text: (name: string) => Promise<string>
53
- }
54
-
55
- react: object
56
- reactJsxRuntime: object
57
- reactDom: object
58
- reactDomClient: object
59
- mobx: object
60
- mobxReact: object
61
- }