epos 1.39.0 → 1.40.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.
@@ -0,0 +1,103 @@
1
+ import 'chrome';
2
+ export type Browser = {
3
+ action: Action;
4
+ extension: Extension;
5
+ i18n: I18n;
6
+ management: Management;
7
+ permissions: Permissions;
8
+ runtime: Runtime;
9
+ windows: Windows;
10
+ alarms: Alarms;
11
+ declarativeNetRequest: DeclarativeNetRequest;
12
+ tabs: Tabs;
13
+ webNavigation: WebNavigation;
14
+ browsingData: BrowsingData;
15
+ contextMenus: ContextMenus;
16
+ cookies: Cookies;
17
+ downloads: Downloads;
18
+ notifications: Notifications;
19
+ sidePanel: SidePanel;
20
+ storage: Storage;
21
+ };
22
+ export type Alarms = typeof chrome.alarms;
23
+ export type Cookies = typeof chrome.cookies;
24
+ export type WebNavigation = typeof chrome.webNavigation;
25
+ export type Windows = typeof chrome.windows;
26
+ export type Action = Omit<typeof chrome.action, 'openPopup'>;
27
+ export type Extension = Omit<typeof chrome.extension, 'getBackgroundPage' | 'getExtensionTabs' | 'getURL' | 'getViews' | 'lastError' | 'onRequest' | 'onRequestExternal' | 'sendRequest'>;
28
+ export type I18n = Omit<typeof chrome.i18n, 'getMessage'>;
29
+ export type Management = Omit<typeof chrome.management, 'createAppShortcut' | 'generateAppForLink' | 'get' | 'getAll' | 'getPermissionWarningsById' | 'installReplacementWebApp' | 'launchApp' | 'onDisabled' | 'onEnabled' | 'onInstalled' | 'onUninstalled' | 'setEnabled' | 'setLaunchType' | 'uninstall'>;
30
+ export type Permissions = Omit<typeof chrome.permissions, 'contains' | 'getAll' | 'remove' | 'request' | 'addHostAccessRequest' | 'onAdded' | 'onRemoved' | 'removeHostAccessRequest'> & {
31
+ contains: (query: PermissionQuery) => Promise<boolean>;
32
+ getAll: () => Promise<{
33
+ origins: string[];
34
+ permissions: Permission[];
35
+ }>;
36
+ remove: (query: PermissionQuery) => Promise<boolean>;
37
+ request: (query: PermissionQuery) => Promise<boolean>;
38
+ };
39
+ export type PermissionQuery = {
40
+ origins?: string[];
41
+ permissions?: chrome.runtime.ManifestPermission[];
42
+ };
43
+ export type Permission = RequiredPermission | OptionalPermission;
44
+ export type RequiredPermission = 'alarms' | 'declarativeNetRequest' | 'offscreen' | 'scripting' | 'tabs' | 'unlimitedStorage' | 'webNavigation';
45
+ export type OptionalPermission = 'background' | 'browsingData' | 'contextMenus' | 'cookies' | 'downloads' | 'notifications' | 'sidePanel' | 'storage';
46
+ export type Runtime = Omit<typeof chrome.runtime, 'getBackgroundPage' | 'onBrowserUpdateAvailable' | 'connect' | 'connectNative' | 'getPackageDirectoryEntry' | 'lastError' | 'onConnect' | 'onConnectExternal' | 'onConnectNative' | 'onInstalled' | 'OnInstalledReason' | 'onMessage' | 'onMessageExternal' | 'onRestartRequired' | 'OnRestartRequiredReason' | 'onStartup' | 'onSuspend' | 'onSuspendCanceled' | 'onUserScriptConnect' | 'onUserScriptMessage' | 'openOptionsPage' | 'restart' | 'restartAfterDelay' | 'sendMessage' | 'sendNativeMessage'>;
47
+ export type DeclarativeNetRequest = Omit<typeof chrome.declarativeNetRequest, 'updateDynamicRules' | 'updateSessionRules' | 'getAvailableStaticRuleCount' | 'getDisabledRuleIds' | 'getEnabledRulesets' | 'getMatchedRules' | 'onRuleMatchedDebug' | 'setExtensionActionOptions' | 'testMatchOutcome' | 'updateEnabledRulesets' | 'updateStaticRules'> & {
48
+ /**
49
+ * Modifies the current set of dynamic rules for the extension. The rules with IDs listed in `options.removeRuleIds` are first removed, and then the rules given in `options.addRules` are added. Notes:
50
+ *
51
+ * - In `epos`, `addRules` cannot have IDs, instead IDs will be assigned automatically and returned in the result.
52
+ * - This update happens as a single atomic operation: either all specified rules are added and removed, or an error is returned.
53
+ * - These rules are persisted across browser sessions and across extension updates.
54
+ * - Static rules specified as part of the extension package can not be removed using this function.
55
+ * - {@link MAX_NUMBER_OF_DYNAMIC_RULES} is the maximum number of dynamic rules an extension can add. The number of [unsafe rules](https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#safe_rules) must not exceed {@link MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES}.
56
+ *
57
+ * Can return its result via Promise in Manifest V3 or later since Chrome 91.
58
+ *
59
+ * @return An array of IDs of the rules that were added.
60
+ */
61
+ updateDynamicRules: (options: UpdateRuleOptions) => Promise<number[]>;
62
+ /**
63
+ * Modifies the current set of dynamic rules for the extension. The rules with IDs listed in `options.removeRuleIds` are first removed, and then the rules given in `options.addRules` are added. Notes:
64
+ *
65
+ * Can return its result via Promise in Manifest V3 or later since Chrome 91.
66
+ *
67
+ * - In `epos`, `addRules` cannot have IDs, instead IDs will be assigned automatically and returned in the result.
68
+ * - This update happens as a single atomic operation: either all specified rules are added and removed, or an error is returned.
69
+ * - These rules are persisted across browser sessions and across extension updates.
70
+ * - Static rules specified as part of the extension package can not be removed using this function.
71
+ * - {@link MAX_NUMBER_OF_DYNAMIC_RULES} is the maximum number of dynamic rules an extension can add. The number of [unsafe rules](https://developer.chrome.com/docs/extensions/reference/declarativeNetRequest/#safe_rules) must not exceed {@link MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES}.
72
+ *
73
+ * Can return its result via Promise in Manifest V3 or later since Chrome 91.
74
+ *
75
+ * @return An array of IDs of the rules that were added.
76
+ */
77
+ updateSessionRules: (options: UpdateRuleOptions) => Promise<number[]>;
78
+ };
79
+ export type UpdateRuleOptions = {
80
+ /** Rules to add. */
81
+ addRules?: Omit<chrome.declarativeNetRequest.Rule, 'id'>[] | undefined;
82
+ /** IDs of the rules to remove. Any invalid IDs will be ignored. */
83
+ removeRuleIds?: number[] | undefined;
84
+ };
85
+ export type Tabs = Omit<typeof chrome.tabs, 'executeScript' | 'getAllInWindow' | 'getSelected' | 'insertCSS' | 'onActiveChanged' | 'onHighlightChanged' | 'onSelectionChanged' | 'sendRequest' | 'connect' | 'sendMessage' | 'getCurrent'>;
86
+ export type BrowsingData = Omit<typeof chrome.browsingData, 'removePasswords' | 'removePluginData'>;
87
+ export type ContextMenus = Omit<typeof chrome.contextMenus, 'create'> & {
88
+ /**
89
+ * Creates a new context menu item.
90
+ * @return The ID of the newly created item.
91
+ */
92
+ create: (createProperties: chrome.contextMenus.CreateProperties) => Promise<string>;
93
+ };
94
+ export type Downloads = Omit<typeof chrome.downloads, 'setShelfEnabled' | 'open' | 'setUiOptions'>;
95
+ export type Notifications = Omit<typeof chrome.notifications, 'onShowSettings' | 'getPermissionLevel' | 'onPermissionLevelChanged'>;
96
+ export type SidePanel = Omit<typeof chrome.sidePanel, 'close' | 'open' | 'setOptions' | 'setPanelBehavior'> & {
97
+ onClosed: chrome.events.Event<() => void>;
98
+ };
99
+ export type Storage = Omit<typeof chrome.storage, 'local' | 'session' | 'sync' | 'managed'> & {
100
+ local: Omit<typeof chrome.storage.local, 'setAccessLevel'>;
101
+ session: Omit<typeof chrome.storage.session, 'setAccessLevel'>;
102
+ sync: Omit<typeof chrome.storage.sync, 'MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE' | 'setAccessLevel'>;
103
+ };
@@ -0,0 +1,2 @@
1
+ import 'chrome';
2
+ //# sourceMappingURL=epos-browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"epos-browser.js","sourceRoot":"","sources":["../src/epos-browser.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,CAAA"}
package/dist/epos.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- /// <reference types="chrome" preserve="true" />
2
- import { type Spec } from 'epos-spec';
1
+ import type { Spec } from 'epos-spec';
3
2
  import type * as mobx from 'mobx';
4
3
  import type * as mobxReactLite from 'mobx-react-lite';
5
4
  import type * as react from 'react';
@@ -7,6 +6,7 @@ import type * as reactDom from 'react-dom';
7
6
  import type * as reactDomClient from 'react-dom/client';
8
7
  import type * as reactJsxRuntime from 'react/jsx-runtime';
9
8
  import type * as yjs from 'yjs';
9
+ import type { Browser } from './epos-browser.js';
10
10
  export type Fn = (...args: any[]) => unknown;
11
11
  export type Cls = new (...args: any[]) => unknown;
12
12
  export type Obj = Record<PropertyKey, unknown>;
@@ -20,8 +20,9 @@ export type Root<T> = Initial<T> & {
20
20
  };
21
21
  export type Initial<T> = T extends Obj ? T : Instance<T>;
22
22
  export type Versioner<T> = Record<number, (this: Root<T>, state: Root<T>) => void>;
23
- export type { Spec };
23
+ export type { Browser, Spec };
24
24
  export type Mode = 'development' | 'production';
25
+ export type Manifest = chrome.runtime.ManifestV3;
25
26
  export type Sources = {
26
27
  [path: string]: string;
27
28
  };
@@ -46,8 +47,19 @@ export type ProjectBase = {
46
47
  mode: Mode;
47
48
  enabled: boolean;
48
49
  spec: Spec;
50
+ manifest: Manifest;
49
51
  };
50
- export type Project<T = {}> = ProjectBase & (T extends {
52
+ export type ProjectFull = ProjectBase & {
53
+ sources: Sources;
54
+ assets: Assets;
55
+ };
56
+ export type ProjectWithSources = ProjectBase & {
57
+ sources: Sources;
58
+ };
59
+ export type ProjectWithAssets = ProjectBase & {
60
+ assets: Assets;
61
+ };
62
+ export type Project<T extends ProjectQuery = {}> = ProjectBase & (T extends {
51
63
  sources: true;
52
64
  } ? {
53
65
  sources: Sources;
@@ -77,22 +89,29 @@ export type Res = {
77
89
  status: Response['status'];
78
90
  statusText: Response['statusText'];
79
91
  redirected: Response['redirected'];
92
+ headers: Response['headers'];
80
93
  text: Response['text'];
81
94
  json: Response['json'];
82
95
  blob: Response['blob'];
83
- headers: {
84
- get: Response['headers']['get'];
85
- has: Response['headers']['has'];
86
- /** Get all header keys. */
87
- keys: () => string[];
88
- };
89
96
  };
90
97
  export interface Epos {
91
98
  fetch: (url: string | URL, init?: ReqInit) => Promise<Res>;
92
- browser: typeof chrome;
99
+ browser: Browser;
93
100
  render(node: react.ReactNode, container?: reactDomClient.Container): void;
94
101
  component<T>(Component: react.FC<T>): react.FC<T>;
95
102
  container: HTMLDivElement;
103
+ env: {
104
+ /** `tabId` is `-1` for iframes, including `<background>` iframe. */
105
+ tabId: -1 | number;
106
+ project: {
107
+ id: string;
108
+ mode: Mode;
109
+ spec: Spec;
110
+ };
111
+ isPopup: boolean;
112
+ isSidePanel: boolean;
113
+ isBackground: boolean;
114
+ };
96
115
  bus: {
97
116
  /** Register event listener. */
98
117
  on<T extends Fn>(name: string, callback: T, thisArg?: unknown): void;
@@ -211,16 +230,18 @@ export interface Epos {
211
230
  loaded: boolean;
212
231
  }[];
213
232
  };
214
- env: {
215
- tabId: number;
216
- project: {
217
- id: string;
218
- mode: Mode;
219
- spec: Spec;
220
- };
221
- isPopup: boolean;
222
- isSidePanel: boolean;
223
- isBackground: boolean;
233
+ projects: {
234
+ get<T extends ProjectQuery>(id: string, query?: T): Promise<Project<T> | null>;
235
+ has(id: string): Promise<boolean>;
236
+ list<T extends ProjectQuery>(query?: T): Promise<Project<T>[]>;
237
+ watch(listener: () => void): void;
238
+ fetch(url: string): Promise<Bundle>;
239
+ create<T extends string>(params: Bundle & Partial<{
240
+ id: T;
241
+ } & ProjectSettings>): Promise<T>;
242
+ update(id: string, updates: Partial<Bundle & ProjectSettings>): Promise<void>;
243
+ remove(id: string): Promise<void>;
244
+ export(id: string, mode?: Mode): Promise<Record<string, Blob>>;
224
245
  };
225
246
  libs: {
226
247
  mobx: typeof mobx;
@@ -231,19 +252,6 @@ export interface Epos {
231
252
  reactJsxRuntime: typeof reactJsxRuntime;
232
253
  yjs: typeof yjs;
233
254
  };
234
- projects: {
235
- create<T extends string>(params: {
236
- id?: T;
237
- } & Partial<ProjectSettings> & Bundle): Promise<T>;
238
- update(id: string, updates: Partial<ProjectSettings & Bundle>): Promise<void>;
239
- remove(id: string): Promise<void>;
240
- has(id: string): Promise<boolean>;
241
- get<T extends ProjectQuery>(id: string, query?: T): Promise<Project<T> | null>;
242
- list<T extends ProjectQuery>(query?: T): Promise<Project<T>[]>;
243
- watch(listener: () => void): void;
244
- fetch(url: string): Promise<Bundle>;
245
- };
246
- engine: any;
247
255
  }
248
256
  declare global {
249
257
  var epos: Epos;
package/dist/epos.js CHANGED
@@ -1,5 +1,3 @@
1
- /// <reference types="chrome" preserve="true" />
2
- import {} from 'epos-spec';
3
1
  const _epos = epos;
4
2
  export { _epos as epos };
5
3
  export default epos;
package/dist/epos.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"epos.js","sourceRoot":"","sources":["../src/epos.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,OAAO,EAAa,MAAM,WAAW,CAAA;AA4OrC,MAAM,KAAK,GAAG,IAAI,CAAA;AAClB,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,CAAA;AAExB,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"epos.js","sourceRoot":"","sources":["../src/epos.ts"],"names":[],"mappings":"AAkOA,MAAM,KAAK,GAAG,IAAI,CAAA;AAClB,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,CAAA;AAExB,eAAe,IAAI,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "epos",
3
- "version": "1.39.0",
3
+ "version": "1.40.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "imkost",
@@ -9,22 +9,22 @@
9
9
  "scripts": {
10
10
  "dev": "rimraf dist && tsgo --watch",
11
11
  "build": "rimraf dist && tsgo",
12
- "lint": "tsgo --noEmit",
13
- "release": "sh -c 'npm version ${1:-minor} && npm run build && npm publish' --"
12
+ "lint": "tsgo --build --noEmit"
14
13
  },
15
14
  "exports": {
16
15
  ".": "./dist/epos.js",
17
- "./vite": "./dist/epos-vite.js"
16
+ "./vite": "./dist/epos-vite.js",
17
+ "./browser": "./dist/epos-browser.js"
18
18
  },
19
19
  "files": [
20
20
  "dist"
21
21
  ],
22
22
  "dependencies": {
23
23
  "@parcel/watcher": "^2.5.4",
24
- "@types/chrome": "^0.1.33",
25
- "@types/react": "^19.2.8",
24
+ "@types/chrome": "^0.1.36",
25
+ "@types/react": "^19.2.9",
26
26
  "@types/react-dom": "^19.2.3",
27
- "epos-spec": "^1.6.0",
27
+ "epos-spec": "^1.8.1",
28
28
  "mobx": "^6.15.0",
29
29
  "mobx-react-lite": "^4.1.1",
30
30
  "portfinder": "^1.0.38",
@@ -33,9 +33,9 @@
33
33
  "yjs": "^13.6.29"
34
34
  },
35
35
  "devDependencies": {
36
- "vite": "^7.3.1"
36
+ "vite": "npm:rolldown-vite@^7.3.1"
37
37
  },
38
38
  "peerDependencies": {
39
- "vite": "^7.3.0"
39
+ "vite": "npm:rolldown-vite@^7.3.1"
40
40
  }
41
41
  }