@doracli/type 0.0.6 → 0.0.8

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2020-2029 zhangzhiguo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2029 zhangzhiguo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -3,5 +3,6 @@
3
3
  ## Usage
4
4
 
5
5
  ```
6
+ dora type
6
7
 
7
8
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doracli/type",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "package by webpack",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
@@ -22,5 +22,5 @@
22
22
  "g:test": "vitest run",
23
23
  "build": "drr build"
24
24
  },
25
- "gitHead": "b387668fa2986c56f245bc53bcb7072fd53b62e1"
25
+ "gitHead": "f0bd0475ac70c3c95336633ffdab4a4ec9794ca7"
26
26
  }
@@ -0,0 +1,440 @@
1
+ /**
2
+ * Chrome Manifest V3 配置的主类型。
3
+ *
4
+ * 说明:
5
+ * - 这里只是一个“较完整”的示例类型,字段尽量覆盖常用/官方字段,但不保证绝对齐全。
6
+ * - 所有字段都是可选的,方便你按需组合使用。
7
+ * - 如果你只做 MV3,建议将 manifest_version 限制为 3。
8
+ */
9
+ export interface TDoraConfigBrowserExtension {
10
+ /**
11
+ * Manifest 版本,目前推荐使用 3。
12
+ */
13
+ manifest_version?: 3;
14
+
15
+ /**
16
+ * 扩展名称(必填字段,但这里为了方便使用写成可选)。
17
+ */
18
+ name?: string;
19
+
20
+ /**
21
+ * 扩展描述。
22
+ */
23
+ description?: string;
24
+
25
+ /**
26
+ * 扩展版本号,语义化版本字符串。
27
+ */
28
+ version?: string;
29
+
30
+ /**
31
+ * 版本名称,通常用于显示给用户的完整版本信息。
32
+ */
33
+ version_name?: string;
34
+
35
+ /**
36
+ * 默认语言,使用 BCP-47 语言标签(如 "en"、"zh_CN")。
37
+ */
38
+ default_locale?: string;
39
+
40
+ /**
41
+ * 扩展图标配置,不同尺寸的图标路径。
42
+ */
43
+ icons?: Partial<
44
+ Record<'16' | '19' | '32' | '38' | '48' | '64' | '128', string>
45
+ >;
46
+
47
+ /**
48
+ * 浏览器工具栏按钮(统一 action)。
49
+ */
50
+ action?: TAction;
51
+
52
+ /**
53
+ * 仅浏览器按钮(与 action 互斥,用于早期/兼容场景)。
54
+ */
55
+ browser_action?: TAction;
56
+
57
+ /**
58
+ * 页面(标签页)中的内容脚本配置。
59
+ */
60
+ content_scripts?: TContentScript[];
61
+
62
+ /**
63
+ * 背景脚本配置(MV3 下为 service_worker)。
64
+ */
65
+ background?: TBackground;
66
+
67
+ /**
68
+ * 选项页面(设置页)配置。
69
+ */
70
+ options_ui?: TOptionsUI;
71
+
72
+ /**
73
+ * 侧边栏(Side Panel)配置。
74
+ * Chrome MV3 中用于声明默认侧边栏页面。
75
+ */
76
+ side_panel?: TSidePanel;
77
+
78
+ /**
79
+ * 新标签页(chrome://newtab)替换配置。
80
+ */
81
+ chrome_url_overrides?: {
82
+ newtab?: string;
83
+ bookmarks?: string;
84
+ history?: string;
85
+ };
86
+
87
+ /**
88
+ * 权限列表(普通权限)。
89
+ */
90
+ permissions?: TPermission[];
91
+
92
+ /**
93
+ * 可选权限(用户按需授权)。
94
+ */
95
+ optional_permissions?: TPermission[];
96
+
97
+ /**
98
+ * 主机权限(匹配 URL 模式)。
99
+ * 例如:"https://*//*"、"*://example.com/*"
100
+ */
101
+ host_permissions?: string[];
102
+
103
+ /**
104
+ * 可选主机权限。
105
+ */
106
+ optional_host_permissions?: string[];
107
+
108
+ /**
109
+ * 扩展在各个浏览器的兼容性信息。
110
+ */
111
+ browser_specific_settings?: {
112
+ gecko?: {
113
+ id?: string;
114
+ strict_min_version?: string;
115
+ strict_max_version?: string;
116
+ update_url?: string;
117
+ };
118
+ gecko_android?: {
119
+ id?: string;
120
+ strict_min_version?: string;
121
+ strict_max_version?: string;
122
+ update_url?: string;
123
+ };
124
+ edge?: {
125
+ browser_action_next_to_addressbar?: boolean;
126
+ };
127
+ };
128
+
129
+ /**
130
+ * 声明可在 declarativeNetRequest 等规则表中使用的资源。
131
+ */
132
+ declarative_net_request?: {
133
+ rule_resources?: Array<{
134
+ id: string;
135
+ enabled?: boolean;
136
+ path: string;
137
+ }>;
138
+ };
139
+
140
+ /**
141
+ * web_accessible_resources 声明。
142
+ * 注意:MV3 要使用对象数组形式。
143
+ */
144
+ web_accessible_resources?: Array<{
145
+ /**
146
+ * 可以被网页访问的资源路径(相对于扩展根目录)。
147
+ */
148
+ resources: string[];
149
+ /**
150
+ * 允许访问这些资源的 URL 匹配。
151
+ */
152
+ matches?: string[];
153
+ /**
154
+ * 运行时条件,例如 "manifest"。
155
+ */
156
+ extension_ids?: string[];
157
+ }>;
158
+
159
+ /**
160
+ * 命令(快捷键)配置。
161
+ */
162
+ commands?: Record<string, TCommand>;
163
+
164
+ /**
165
+ * 右键菜单、下载、标签页等 API 所需的声明式配置(一般通过 permissions 控制,这里不单独细分)。
166
+ */
167
+
168
+ /**
169
+ * 各种页面(popup、tab 等)中使用的 CSS 文件(不是内容脚本)。
170
+ * 只在部分场景中用到。
171
+ */
172
+ chrome_settings_overrides?: {
173
+ homepage?: string;
174
+ search_provider?: {
175
+ name: string;
176
+ keyword?: string;
177
+ favicon_url?: string;
178
+ search_url: string;
179
+ encoding?: string;
180
+ suggest_url?: string;
181
+ instant_url?: string;
182
+ image_url?: string;
183
+ search_url_post_params?: string;
184
+ suggest_url_post_params?: string;
185
+ instant_url_post_params?: string;
186
+ image_url_post_params?: string;
187
+ alternate_urls?: string[];
188
+ is_default?: boolean;
189
+ };
190
+ startup_pages?: string[];
191
+ };
192
+
193
+ /**
194
+ * omnibox 关键字(地址栏关键字)。
195
+ */
196
+ omnibox?: {
197
+ keyword: string;
198
+ };
199
+
200
+ /**
201
+ * 声明需要在剪贴板、文件系统等特殊能力。
202
+ * 实际上主要还是由 permissions 控制,这里只是保留结构位。
203
+ */
204
+
205
+ /**
206
+ * devtools 页面配置。
207
+ */
208
+ devtools_page?: string;
209
+
210
+ /**
211
+ * 远程调试页面(少用)。
212
+ */
213
+ devtools_page_experimental?: string;
214
+
215
+ /**
216
+ * 默认搜索引擎设置(一般通过 chrome_settings_overrides.search_provider 管理)。
217
+ */
218
+
219
+ /**
220
+ * 实验性字段、平台特定字段等可以统一放在扩展字段中,避免类型限制太死。
221
+ */
222
+ [key: string]: unknown;
223
+ }
224
+
225
+ /**
226
+ * 工具栏按钮 / 浏览器按钮 的统一类型。
227
+ */
228
+ export interface TAction {
229
+ /**
230
+ * 按钮图标,可以设置不同尺寸。
231
+ */
232
+ default_icon?: Partial<
233
+ Record<'16' | '19' | '32' | '38' | '48' | '64' | '128', string>
234
+ >;
235
+
236
+ /**
237
+ * 按钮悬浮提示文本。
238
+ */
239
+ default_title?: string;
240
+
241
+ /**
242
+ * 点击按钮时弹出的页面(HTML)。
243
+ */
244
+ default_popup?: string;
245
+
246
+ /**
247
+ * 图标上显示的默认徽标文字。
248
+ */
249
+ default_badge_text?: string;
250
+ }
251
+
252
+ /**
253
+ * 内容脚本(注入到网页中的 JS/CSS)。
254
+ */
255
+ export interface TContentScript {
256
+ /**
257
+ * 匹配的网页 URL 模式。
258
+ * 例如:"https://*//*"、"*://*.example.com/*"
259
+ */
260
+ matches?: string[];
261
+
262
+ /**
263
+ * 排除的网页 URL 模式。
264
+ */
265
+ exclude_matches?: string[];
266
+
267
+ /**
268
+ * 只在这些页面中注入(更细粒度)。
269
+ */
270
+ include_globs?: string[];
271
+
272
+ /**
273
+ * 排除这些页面(更细粒度)。
274
+ */
275
+ exclude_globs?: string[];
276
+
277
+ /**
278
+ * 要注入的 JS 文件列表。
279
+ */
280
+ js?: string[];
281
+
282
+ /**
283
+ * 要注入的 CSS 文件列表。
284
+ */
285
+ css?: string[];
286
+
287
+ /**
288
+ * 在页面生命周期的哪个阶段注入脚本。
289
+ * - "document_start":DOM 创建前
290
+ * - "document_end":DOM 加载完成后
291
+ * - "document_idle":页面空闲时(默认)
292
+ */
293
+ run_at?: 'document_start' | 'document_end' | 'document_idle';
294
+
295
+ /**
296
+ * 是否在所有 frame 中注入(包括 iframe)。
297
+ */
298
+ all_frames?: boolean;
299
+
300
+ /**
301
+ * 是否仅在顶级 frame 中注入。
302
+ */
303
+ match_about_blank?: boolean;
304
+
305
+ /**
306
+ * 是否隔离世界。
307
+ */
308
+ world?: 'ISOLATED' | 'CONTENT_SCRIPTS' | 'MAIN';
309
+ }
310
+
311
+ /**
312
+ * 背景脚本配置(MV3 下使用 service_worker)。
313
+ */
314
+ export interface TBackground {
315
+ /**
316
+ * 背景 service worker 文件路径。
317
+ */
318
+ service_worker?: string;
319
+
320
+ /**
321
+ * 是否在页面关闭后仍尽快保持活跃(Chrome 部分版本支持)。
322
+ */
323
+ type?: 'module';
324
+ }
325
+
326
+ /**
327
+ * 选项页(设置页面)配置。
328
+ */
329
+ export interface TOptionsUI {
330
+ /**
331
+ * 选项页 HTML 路径。
332
+ */
333
+ page?: string;
334
+
335
+ /**
336
+ * 是否以独立标签页形式打开。
337
+ */
338
+ open_in_tab?: boolean;
339
+
340
+ /**
341
+ * 是否使用 Chrome 提供的 IFrame 外壳(旧字段,通常不需要)。
342
+ */
343
+ chrome_style?: boolean;
344
+ }
345
+
346
+ /**
347
+ * 侧边栏(Side Panel)配置。
348
+ */
349
+ export interface TSidePanel {
350
+ /**
351
+ * 默认侧边栏页面 HTML 路径。
352
+ */
353
+ default_path?: string;
354
+ }
355
+
356
+ /**
357
+ * 命令配置(快捷键)。
358
+ */
359
+ export interface TCommand {
360
+ /**
361
+ * 用户可自定义的推荐快捷键。
362
+ * 示例:"Ctrl+Shift+Y"
363
+ */
364
+ suggested_key?: {
365
+ default?: string;
366
+ mac?: string;
367
+ linux?: string;
368
+ chromeos?: string;
369
+ windows?: string;
370
+ };
371
+
372
+ /**
373
+ * 命令描述,会在快捷键设置页面中显示。
374
+ */
375
+ description?: string;
376
+
377
+ /**
378
+ * 是否是全局快捷键(即使没有浏览器窗口也能触发)。
379
+ */
380
+ global?: boolean;
381
+ }
382
+
383
+ /**
384
+ * MV3 常见权限类型。
385
+ * 如果有用到文档中未列出的权限,可以自行补充 string 类型。
386
+ */
387
+ export type TPermission =
388
+ | 'activeTab'
389
+ | 'alarms'
390
+ | 'background'
391
+ | 'bookmarks'
392
+ | 'browsingData'
393
+ | 'clipboardRead'
394
+ | 'clipboardWrite'
395
+ | 'contentSettings'
396
+ | 'contextMenus'
397
+ | 'cookies'
398
+ | 'debugger'
399
+ | 'declarativeContent'
400
+ | 'declarativeNetRequest'
401
+ | 'declarativeNetRequestFeedback'
402
+ | 'declarativeNetRequestWithHostAccess'
403
+ | 'desktopCapture'
404
+ | 'downloads'
405
+ | 'downloads.open'
406
+ | 'favicon'
407
+ | 'fileBrowserHandler'
408
+ | 'fileSystemProvider'
409
+ | 'gcm'
410
+ | 'history'
411
+ | 'identity'
412
+ | 'idle'
413
+ | 'management'
414
+ | 'nativeMessaging'
415
+ | 'notifications'
416
+ | 'pageCapture'
417
+ | 'privacy'
418
+ | 'proxy'
419
+ | 'scripting'
420
+ | 'search'
421
+ | 'sessions'
422
+ | 'sidePanel'
423
+ | 'storage'
424
+ | 'system.cpu'
425
+ | 'system.display'
426
+ | 'system.memory'
427
+ | 'system.storage'
428
+ | 'tabCapture'
429
+ | 'tabGroups'
430
+ | 'tabs'
431
+ | 'topSites'
432
+ | 'tts'
433
+ | 'ttsEngine'
434
+ | 'unlimitedStorage'
435
+ | 'vpnProvider'
436
+ | 'wallpaper'
437
+ | 'webNavigation'
438
+ | 'webRequest'
439
+ | 'webRequestBlocking'
440
+ | (string & {});
@@ -1,4 +1,5 @@
1
1
  import type { PartialRecursive } from './common';
2
+ import type { TDoraConfigBrowserExtension } from './dora-config-browser-extension';
2
3
  import type { TDoraConfigCommon } from './dora-config-common';
3
4
  import type { TDoraConfigDts } from './dora-config-dts';
4
5
  import type { TDoraConfigEsbuild } from './dora-config-esbuild';
@@ -15,6 +16,7 @@ export type TDoraConfig = TDoraConfigCommon & {
15
16
  esbuildConfig?: TDoraConfigEsbuild;
16
17
  serviceConfig?: Partial<TDoraConfigService>;
17
18
  dtsConfig?: TDoraConfigDts;
19
+ browserExtensionConfig?: TDoraConfigBrowserExtension;
18
20
  };
19
21
 
20
22
  export type TDoraConfigDefine =
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './cdn-type';
2
2
  export * from './dora-config';
3
+ export * from './dora-config-browser-extension';
3
4
  export * from './dora-config-common';
4
5
  export * from './dora-config-multiple';
5
6
  export * from './dora-config-rollup';