create-packer 1.43.6 → 1.43.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/package.json +1 -1
- package/template/web-app/react-rsbuild/index.html +1 -0
- package/template/web-app/react-vite/index.html +1 -0
- package/template/web-app/vue/index.html +1 -0
- package/template/web-app/vue-rsbuild/index.html +1 -0
- package/template/web-extension/.wxt/eslint-auto-imports.mjs +28 -28
- package/template/web-extension/.wxt/tsconfig.json +27 -27
- package/template/web-extension/.wxt/types/globals.d.ts +15 -15
- package/template/web-extension/.wxt/types/i18n.d.ts +81 -81
- package/template/web-extension/.wxt/types/imports.d.ts +22 -22
- package/template/web-extension/.wxt/types/paths.d.ts +16 -16
- package/template/web-extension/.wxt/wxt.d.ts +7 -7
- package/template/web-extension/entrypoints/background/index.ts +7 -1
- package/template/web-extension/entrypoints/content/index.tsx +1 -1
- package/template/web-extension/eslint.config.js +1 -2
- package/template/web-extension/package.json +6 -5
- package/template/web-extension/shared/background/message.ts +4 -8
- package/template/web-extension/shared/content/message.ts +18 -15
- package/template/web-extension/shared/popup/message.ts +4 -9
- package/template/web-extension/shared/styles/global.styled.ts +1 -0
- package/template/web-extension/shared/tools/index.ts +0 -1
- package/template/web-extension/tsconfig.node.json +1 -1
- package/template/web-extension/vite-env.d.ts +1 -0
- package/template/web-extension/shared/tools/message.ts +0 -70
package/package.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const globals = {
|
|
2
|
-
"ContentScriptContext": true,
|
|
3
|
-
"InvalidMatchPattern": true,
|
|
4
|
-
"MatchPattern": true,
|
|
5
|
-
"MigrationError": true,
|
|
6
|
-
"browser": true,
|
|
7
|
-
"createIframeUi": true,
|
|
8
|
-
"createIntegratedUi": true,
|
|
9
|
-
"createShadowRootUi": true,
|
|
10
|
-
"defineAppConfig": true,
|
|
11
|
-
"defineBackground": true,
|
|
12
|
-
"defineConfig": true,
|
|
13
|
-
"defineContentScript": true,
|
|
14
|
-
"defineUnlistedScript": true,
|
|
15
|
-
"defineWxtPlugin": true,
|
|
16
|
-
"fakeBrowser": true,
|
|
17
|
-
"injectScript": true,
|
|
18
|
-
"storage": true,
|
|
19
|
-
"useAppConfig": true
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
name: "wxt/auto-imports",
|
|
24
|
-
languageOptions: {
|
|
25
|
-
globals,
|
|
26
|
-
sourceType: "module",
|
|
27
|
-
},
|
|
28
|
-
};
|
|
1
|
+
const globals = {
|
|
2
|
+
"ContentScriptContext": true,
|
|
3
|
+
"InvalidMatchPattern": true,
|
|
4
|
+
"MatchPattern": true,
|
|
5
|
+
"MigrationError": true,
|
|
6
|
+
"browser": true,
|
|
7
|
+
"createIframeUi": true,
|
|
8
|
+
"createIntegratedUi": true,
|
|
9
|
+
"createShadowRootUi": true,
|
|
10
|
+
"defineAppConfig": true,
|
|
11
|
+
"defineBackground": true,
|
|
12
|
+
"defineConfig": true,
|
|
13
|
+
"defineContentScript": true,
|
|
14
|
+
"defineUnlistedScript": true,
|
|
15
|
+
"defineWxtPlugin": true,
|
|
16
|
+
"fakeBrowser": true,
|
|
17
|
+
"injectScript": true,
|
|
18
|
+
"storage": true,
|
|
19
|
+
"useAppConfig": true
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
name: "wxt/auto-imports",
|
|
24
|
+
languageOptions: {
|
|
25
|
+
globals,
|
|
26
|
+
sourceType: "module",
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "Bundler",
|
|
6
|
-
"noEmit": true,
|
|
7
|
-
"esModuleInterop": true,
|
|
8
|
-
"forceConsistentCasingInFileNames": true,
|
|
9
|
-
"resolveJsonModule": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"paths": {
|
|
13
|
-
"@": [".."],
|
|
14
|
-
"@/*": ["../*"],
|
|
15
|
-
"~": [".."],
|
|
16
|
-
"~/*": ["../*"],
|
|
17
|
-
"@@": [".."],
|
|
18
|
-
"@@/*": ["../*"],
|
|
19
|
-
"~~": [".."],
|
|
20
|
-
"~~/*": ["../*"]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"include": [
|
|
24
|
-
"../**/*",
|
|
25
|
-
"./wxt.d.ts"
|
|
26
|
-
],
|
|
27
|
-
"exclude": ["../dist"]
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "Bundler",
|
|
6
|
+
"noEmit": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"forceConsistentCasingInFileNames": true,
|
|
9
|
+
"resolveJsonModule": true,
|
|
10
|
+
"strict": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"paths": {
|
|
13
|
+
"@": [".."],
|
|
14
|
+
"@/*": ["../*"],
|
|
15
|
+
"~": [".."],
|
|
16
|
+
"~/*": ["../*"],
|
|
17
|
+
"@@": [".."],
|
|
18
|
+
"@@/*": ["../*"],
|
|
19
|
+
"~~": [".."],
|
|
20
|
+
"~~/*": ["../*"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"include": [
|
|
24
|
+
"../**/*",
|
|
25
|
+
"./wxt.d.ts"
|
|
26
|
+
],
|
|
27
|
+
"exclude": ["../dist"]
|
|
28
28
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
// Generated by wxt
|
|
2
|
-
interface ImportMetaEnv {
|
|
3
|
-
readonly MANIFEST_VERSION: 2 | 3;
|
|
4
|
-
readonly BROWSER: string;
|
|
5
|
-
readonly CHROME: boolean;
|
|
6
|
-
readonly FIREFOX: boolean;
|
|
7
|
-
readonly SAFARI: boolean;
|
|
8
|
-
readonly EDGE: boolean;
|
|
9
|
-
readonly OPERA: boolean;
|
|
10
|
-
readonly COMMAND: "build" | "serve";
|
|
11
|
-
readonly ENTRYPOINT: string;
|
|
12
|
-
}
|
|
13
|
-
interface ImportMeta {
|
|
14
|
-
readonly env: ImportMetaEnv
|
|
15
|
-
}
|
|
1
|
+
// Generated by wxt
|
|
2
|
+
interface ImportMetaEnv {
|
|
3
|
+
readonly MANIFEST_VERSION: 2 | 3;
|
|
4
|
+
readonly BROWSER: string;
|
|
5
|
+
readonly CHROME: boolean;
|
|
6
|
+
readonly FIREFOX: boolean;
|
|
7
|
+
readonly SAFARI: boolean;
|
|
8
|
+
readonly EDGE: boolean;
|
|
9
|
+
readonly OPERA: boolean;
|
|
10
|
+
readonly COMMAND: "build" | "serve";
|
|
11
|
+
readonly ENTRYPOINT: string;
|
|
12
|
+
}
|
|
13
|
+
interface ImportMeta {
|
|
14
|
+
readonly env: ImportMetaEnv
|
|
15
|
+
}
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
// Generated by wxt
|
|
2
|
-
import "wxt/browser";
|
|
3
|
-
|
|
4
|
-
declare module "wxt/browser" {
|
|
5
|
-
/**
|
|
6
|
-
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
|
|
7
|
-
*/
|
|
8
|
-
interface GetMessageOptions {
|
|
9
|
-
/**
|
|
10
|
-
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
|
|
11
|
-
*/
|
|
12
|
-
escapeLt?: boolean
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface WxtI18n extends I18n.Static {
|
|
16
|
-
/**
|
|
17
|
-
* The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.
|
|
18
|
-
* Note: You can't use this message in a manifest file.
|
|
19
|
-
*
|
|
20
|
-
* "<browser.runtime.id>"
|
|
21
|
-
*/
|
|
22
|
-
getMessage(
|
|
23
|
-
messageName: "@@extension_id",
|
|
24
|
-
substitutions?: string | string[],
|
|
25
|
-
options?: GetMessageOptions,
|
|
26
|
-
): string;
|
|
27
|
-
/**
|
|
28
|
-
* "<browser.i18n.getUiLocale()>"
|
|
29
|
-
*/
|
|
30
|
-
getMessage(
|
|
31
|
-
messageName: "@@ui_locale",
|
|
32
|
-
substitutions?: string | string[],
|
|
33
|
-
options?: GetMessageOptions,
|
|
34
|
-
): string;
|
|
35
|
-
/**
|
|
36
|
-
* The text direction for the current locale, either "ltr" for left-to-right languages such as English or "rtl" for right-to-left languages such as Japanese.
|
|
37
|
-
*
|
|
38
|
-
* "<ltr|rtl>"
|
|
39
|
-
*/
|
|
40
|
-
getMessage(
|
|
41
|
-
messageName: "@@bidi_dir",
|
|
42
|
-
substitutions?: string | string[],
|
|
43
|
-
options?: GetMessageOptions,
|
|
44
|
-
): string;
|
|
45
|
-
/**
|
|
46
|
-
* If the @@bidi_dir is "ltr", then this is "rtl"; otherwise, it's "ltr".
|
|
47
|
-
*
|
|
48
|
-
* "<rtl|ltr>"
|
|
49
|
-
*/
|
|
50
|
-
getMessage(
|
|
51
|
-
messageName: "@@bidi_reversed_dir",
|
|
52
|
-
substitutions?: string | string[],
|
|
53
|
-
options?: GetMessageOptions,
|
|
54
|
-
): string;
|
|
55
|
-
/**
|
|
56
|
-
* If the @@bidi_dir is "ltr", then this is "left"; otherwise, it's "right".
|
|
57
|
-
*
|
|
58
|
-
* "<left|right>"
|
|
59
|
-
*/
|
|
60
|
-
getMessage(
|
|
61
|
-
messageName: "@@bidi_start_edge",
|
|
62
|
-
substitutions?: string | string[],
|
|
63
|
-
options?: GetMessageOptions,
|
|
64
|
-
): string;
|
|
65
|
-
/**
|
|
66
|
-
* If the @@bidi_dir is "ltr", then this is "right"; otherwise, it's "left".
|
|
67
|
-
*
|
|
68
|
-
* "<right|left>"
|
|
69
|
-
*/
|
|
70
|
-
getMessage(
|
|
71
|
-
messageName: "@@bidi_end_edge",
|
|
72
|
-
substitutions?: string | string[],
|
|
73
|
-
options?: GetMessageOptions,
|
|
74
|
-
): string;
|
|
75
|
-
getMessage(
|
|
76
|
-
messageName: "@@extension_id" | "@@ui_locale" | "@@bidi_dir" | "@@bidi_reversed_dir" | "@@bidi_start_edge" | "@@bidi_end_edge",
|
|
77
|
-
substitutions?: string | string[],
|
|
78
|
-
options?: GetMessageOptions,
|
|
79
|
-
): string;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
1
|
+
// Generated by wxt
|
|
2
|
+
import "wxt/browser";
|
|
3
|
+
|
|
4
|
+
declare module "wxt/browser" {
|
|
5
|
+
/**
|
|
6
|
+
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
|
|
7
|
+
*/
|
|
8
|
+
interface GetMessageOptions {
|
|
9
|
+
/**
|
|
10
|
+
* See https://developer.chrome.com/docs/extensions/reference/i18n/#method-getMessage
|
|
11
|
+
*/
|
|
12
|
+
escapeLt?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface WxtI18n extends I18n.Static {
|
|
16
|
+
/**
|
|
17
|
+
* The extension or app ID; you might use this string to construct URLs for resources inside the extension. Even unlocalized extensions can use this message.
|
|
18
|
+
* Note: You can't use this message in a manifest file.
|
|
19
|
+
*
|
|
20
|
+
* "<browser.runtime.id>"
|
|
21
|
+
*/
|
|
22
|
+
getMessage(
|
|
23
|
+
messageName: "@@extension_id",
|
|
24
|
+
substitutions?: string | string[],
|
|
25
|
+
options?: GetMessageOptions,
|
|
26
|
+
): string;
|
|
27
|
+
/**
|
|
28
|
+
* "<browser.i18n.getUiLocale()>"
|
|
29
|
+
*/
|
|
30
|
+
getMessage(
|
|
31
|
+
messageName: "@@ui_locale",
|
|
32
|
+
substitutions?: string | string[],
|
|
33
|
+
options?: GetMessageOptions,
|
|
34
|
+
): string;
|
|
35
|
+
/**
|
|
36
|
+
* The text direction for the current locale, either "ltr" for left-to-right languages such as English or "rtl" for right-to-left languages such as Japanese.
|
|
37
|
+
*
|
|
38
|
+
* "<ltr|rtl>"
|
|
39
|
+
*/
|
|
40
|
+
getMessage(
|
|
41
|
+
messageName: "@@bidi_dir",
|
|
42
|
+
substitutions?: string | string[],
|
|
43
|
+
options?: GetMessageOptions,
|
|
44
|
+
): string;
|
|
45
|
+
/**
|
|
46
|
+
* If the @@bidi_dir is "ltr", then this is "rtl"; otherwise, it's "ltr".
|
|
47
|
+
*
|
|
48
|
+
* "<rtl|ltr>"
|
|
49
|
+
*/
|
|
50
|
+
getMessage(
|
|
51
|
+
messageName: "@@bidi_reversed_dir",
|
|
52
|
+
substitutions?: string | string[],
|
|
53
|
+
options?: GetMessageOptions,
|
|
54
|
+
): string;
|
|
55
|
+
/**
|
|
56
|
+
* If the @@bidi_dir is "ltr", then this is "left"; otherwise, it's "right".
|
|
57
|
+
*
|
|
58
|
+
* "<left|right>"
|
|
59
|
+
*/
|
|
60
|
+
getMessage(
|
|
61
|
+
messageName: "@@bidi_start_edge",
|
|
62
|
+
substitutions?: string | string[],
|
|
63
|
+
options?: GetMessageOptions,
|
|
64
|
+
): string;
|
|
65
|
+
/**
|
|
66
|
+
* If the @@bidi_dir is "ltr", then this is "right"; otherwise, it's "left".
|
|
67
|
+
*
|
|
68
|
+
* "<right|left>"
|
|
69
|
+
*/
|
|
70
|
+
getMessage(
|
|
71
|
+
messageName: "@@bidi_end_edge",
|
|
72
|
+
substitutions?: string | string[],
|
|
73
|
+
options?: GetMessageOptions,
|
|
74
|
+
): string;
|
|
75
|
+
getMessage(
|
|
76
|
+
messageName: "@@extension_id" | "@@ui_locale" | "@@bidi_dir" | "@@bidi_reversed_dir" | "@@bidi_start_edge" | "@@bidi_end_edge",
|
|
77
|
+
substitutions?: string | string[],
|
|
78
|
+
options?: GetMessageOptions,
|
|
79
|
+
): string;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
// Generated by wxt
|
|
2
|
-
export {}
|
|
3
|
-
declare global {
|
|
4
|
-
const ContentScriptContext: typeof import('wxt/client')['ContentScriptContext']
|
|
5
|
-
const InvalidMatchPattern: typeof import('wxt/sandbox')['InvalidMatchPattern']
|
|
6
|
-
const MatchPattern: typeof import('wxt/sandbox')['MatchPattern']
|
|
7
|
-
const MigrationError: typeof import('wxt/storage')['MigrationError']
|
|
8
|
-
const browser: typeof import('wxt/browser/chrome')['browser']
|
|
9
|
-
const createIframeUi: typeof import('wxt/client')['createIframeUi']
|
|
10
|
-
const createIntegratedUi: typeof import('wxt/client')['createIntegratedUi']
|
|
11
|
-
const createShadowRootUi: typeof import('wxt/client')['createShadowRootUi']
|
|
12
|
-
const defineAppConfig: typeof import('wxt/sandbox')['defineAppConfig']
|
|
13
|
-
const defineBackground: typeof import('wxt/sandbox')['defineBackground']
|
|
14
|
-
const defineConfig: typeof import('wxt')['defineConfig']
|
|
15
|
-
const defineContentScript: typeof import('wxt/sandbox')['defineContentScript']
|
|
16
|
-
const defineUnlistedScript: typeof import('wxt/sandbox')['defineUnlistedScript']
|
|
17
|
-
const defineWxtPlugin: typeof import('wxt/sandbox')['defineWxtPlugin']
|
|
18
|
-
const fakeBrowser: typeof import('wxt/testing')['fakeBrowser']
|
|
19
|
-
const injectScript: typeof import('wxt/client')['injectScript']
|
|
20
|
-
const storage: typeof import('wxt/storage')['storage']
|
|
21
|
-
const useAppConfig: typeof import('wxt/client')['useAppConfig']
|
|
22
|
-
}
|
|
1
|
+
// Generated by wxt
|
|
2
|
+
export {}
|
|
3
|
+
declare global {
|
|
4
|
+
const ContentScriptContext: typeof import('wxt/client')['ContentScriptContext']
|
|
5
|
+
const InvalidMatchPattern: typeof import('wxt/sandbox')['InvalidMatchPattern']
|
|
6
|
+
const MatchPattern: typeof import('wxt/sandbox')['MatchPattern']
|
|
7
|
+
const MigrationError: typeof import('wxt/storage')['MigrationError']
|
|
8
|
+
const browser: typeof import('wxt/browser/chrome')['browser']
|
|
9
|
+
const createIframeUi: typeof import('wxt/client')['createIframeUi']
|
|
10
|
+
const createIntegratedUi: typeof import('wxt/client')['createIntegratedUi']
|
|
11
|
+
const createShadowRootUi: typeof import('wxt/client')['createShadowRootUi']
|
|
12
|
+
const defineAppConfig: typeof import('wxt/sandbox')['defineAppConfig']
|
|
13
|
+
const defineBackground: typeof import('wxt/sandbox')['defineBackground']
|
|
14
|
+
const defineConfig: typeof import('wxt')['defineConfig']
|
|
15
|
+
const defineContentScript: typeof import('wxt/sandbox')['defineContentScript']
|
|
16
|
+
const defineUnlistedScript: typeof import('wxt/sandbox')['defineUnlistedScript']
|
|
17
|
+
const defineWxtPlugin: typeof import('wxt/sandbox')['defineWxtPlugin']
|
|
18
|
+
const fakeBrowser: typeof import('wxt/testing')['fakeBrowser']
|
|
19
|
+
const injectScript: typeof import('wxt/client')['injectScript']
|
|
20
|
+
const storage: typeof import('wxt/storage')['storage']
|
|
21
|
+
const useAppConfig: typeof import('wxt/client')['useAppConfig']
|
|
22
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// Generated by wxt
|
|
2
|
-
import "wxt/browser";
|
|
3
|
-
|
|
4
|
-
declare module "wxt/browser" {
|
|
5
|
-
export type PublicPath =
|
|
6
|
-
| "/"
|
|
7
|
-
| "/background.js"
|
|
8
|
-
| "/content-scripts/content.js"
|
|
9
|
-
| "/popup.html"
|
|
10
|
-
| "/vite.svg"
|
|
11
|
-
type HtmlPublicPath = Extract<PublicPath, `${string}.html`>
|
|
12
|
-
export interface WxtRuntime {
|
|
13
|
-
getURL(path: PublicPath): string;
|
|
14
|
-
getURL(path: `${HtmlPublicPath}${string}`): string;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
// Generated by wxt
|
|
2
|
+
import "wxt/browser";
|
|
3
|
+
|
|
4
|
+
declare module "wxt/browser" {
|
|
5
|
+
export type PublicPath =
|
|
6
|
+
| "/"
|
|
7
|
+
| "/background.js"
|
|
8
|
+
| "/content-scripts/content.js"
|
|
9
|
+
| "/popup.html"
|
|
10
|
+
| "/vite.svg"
|
|
11
|
+
type HtmlPublicPath = Extract<PublicPath, `${string}.html`>
|
|
12
|
+
export interface WxtRuntime {
|
|
13
|
+
getURL(path: PublicPath): string;
|
|
14
|
+
getURL(path: `${HtmlPublicPath}${string}`): string;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
// Generated by wxt
|
|
2
|
-
/// <reference types="wxt/vite-builder-env" />
|
|
3
|
-
/// <reference
|
|
4
|
-
/// <reference
|
|
5
|
-
/// <reference
|
|
6
|
-
/// <reference types="@types/chrome" />
|
|
7
|
-
/// <reference
|
|
1
|
+
// Generated by wxt
|
|
2
|
+
/// <reference types="wxt/vite-builder-env" />
|
|
3
|
+
/// <reference path="./types/paths.d.ts" />
|
|
4
|
+
/// <reference path="./types/i18n.d.ts" />
|
|
5
|
+
/// <reference path="./types/globals.d.ts" />
|
|
6
|
+
/// <reference types="@types/chrome" />
|
|
7
|
+
/// <reference path="./types/imports.d.ts" />
|
|
@@ -4,7 +4,6 @@ import tseslint from 'typescript-eslint'
|
|
|
4
4
|
import importPlugin from 'eslint-plugin-import'
|
|
5
5
|
import reactPlugin from 'eslint-plugin-react'
|
|
6
6
|
import reactHooksPlugin from 'eslint-plugin-react-hooks'
|
|
7
|
-
import autoImports from './.wxt/eslint-auto-imports.mjs'
|
|
8
7
|
|
|
9
8
|
const scriptExtensions = ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx']
|
|
10
9
|
const files = scriptExtensions.map(ext => `**/*.${ext}`)
|
|
@@ -16,7 +15,6 @@ export default tseslint.config([
|
|
|
16
15
|
eslint.configs.recommended,
|
|
17
16
|
importPlugin.flatConfigs.recommended,
|
|
18
17
|
tseslint.configs.recommended,
|
|
19
|
-
autoImports,
|
|
20
18
|
{
|
|
21
19
|
plugins: { reactPlugin, reactHooksPlugin },
|
|
22
20
|
files,
|
|
@@ -95,6 +93,7 @@ export default tseslint.config([
|
|
|
95
93
|
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
96
94
|
'@typescript-eslint/ban-ts-comment': 'off',
|
|
97
95
|
'@typescript-eslint/no-empty-interface': 'off',
|
|
96
|
+
'@typescript-eslint/triple-slash-reference': 'off',
|
|
98
97
|
'react/prop-types': 'off',
|
|
99
98
|
'react/no-find-dom-node': 'off',
|
|
100
99
|
'react-hooks/exhaustive-deps': 'off',
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
"postinstall": "wxt prepare",
|
|
19
19
|
"up:vite": "pnpm up vite @vitejs/* -L",
|
|
20
20
|
"format": "prettier --write \"**/*.{ts,js,tsx,jsx,json,css,scss,less}\"",
|
|
21
|
-
"lint": "tsc --noEmit && eslint && stylelint **/*.{css,scss,less}",
|
|
22
|
-
"lint:fix": "eslint --fix && stylelint **/*.{css,scss,less} --fix",
|
|
21
|
+
"lint": "tsc --noEmit && eslint **/*.{tsx,ts} && stylelint **/*.{css,scss,less,ts,tsx}",
|
|
22
|
+
"lint:fix": "eslint **/*.{tsx,ts} --fix && stylelint **/*.{css,scss,less,ts,tsx} --fix",
|
|
23
23
|
"cz": "cz",
|
|
24
24
|
"push": "npm run commit && git push",
|
|
25
25
|
"commit": "git add . && npm run cz"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@tanstack/react-query": "5.51.15",
|
|
29
|
+
"@webext-core/messaging": "2.2.0",
|
|
29
30
|
"axios": "1.7.9",
|
|
30
31
|
"define-zustand": "3.2.1",
|
|
31
32
|
"immer": "10.0.1",
|
|
@@ -72,10 +73,10 @@
|
|
|
72
73
|
"stylelint": "16.10.0",
|
|
73
74
|
"stylelint-config-standard": "36.0.1",
|
|
74
75
|
"typescript": "5.8.2",
|
|
75
|
-
"typescript-eslint": "8.
|
|
76
|
-
"vite": "6.
|
|
76
|
+
"typescript-eslint": "8.28.0",
|
|
77
|
+
"vite": "6.2.3",
|
|
77
78
|
"vite-plugin-svgr": "4.3.0",
|
|
78
|
-
"wxt": "0.19.
|
|
79
|
+
"wxt": "0.19.29"
|
|
79
80
|
},
|
|
80
81
|
"config": {
|
|
81
82
|
"commitizen": {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export enum ACTIONS {
|
|
3
|
-
TEST = 'TEST'
|
|
4
|
-
}
|
|
1
|
+
import { defineExtensionMessaging } from '@webext-core/messaging'
|
|
5
2
|
|
|
6
|
-
export
|
|
7
|
-
|
|
3
|
+
export type messageType = {
|
|
4
|
+
test: () => Promise<string>
|
|
8
5
|
}
|
|
9
|
-
export interface responseType {}
|
|
10
6
|
|
|
11
|
-
export const
|
|
7
|
+
export const { sendMessage, onMessage } = defineExtensionMessaging<messageType>()
|
|
@@ -1,25 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineExtensionMessaging } from '@webext-core/messaging'
|
|
2
2
|
import { CONTENT_MATCHES } from './constant'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
4
|
+
export type messageType = {
|
|
5
|
+
test: () => Promise<string>
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
[ACTIONS.TEST]: object
|
|
10
|
-
}
|
|
11
|
-
export interface responseType {}
|
|
12
|
-
|
|
13
|
-
export const action = message.create<ACTIONS, messageType, responseType>()
|
|
8
|
+
export const { sendMessage, onMessage } = defineExtensionMessaging<messageType>()
|
|
14
9
|
|
|
15
|
-
export function sendToAllContent<A extends
|
|
16
|
-
|
|
10
|
+
export async function sendToAllContent<A extends keyof messageType>(
|
|
11
|
+
action: A,
|
|
12
|
+
data?: Parameters<messageType[A]>[0]
|
|
17
13
|
) {
|
|
18
|
-
|
|
14
|
+
const tabs = await chrome.tabs.query({ url: CONTENT_MATCHES })
|
|
15
|
+
return await Promise.all(
|
|
16
|
+
tabs.map(tab => {
|
|
17
|
+
return sendMessage(action, data as never, { tabId: tab.id! })
|
|
18
|
+
})
|
|
19
|
+
)
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export function sendToCurrentContent<A extends
|
|
22
|
-
|
|
22
|
+
export async function sendToCurrentContent<A extends keyof messageType>(
|
|
23
|
+
action: A,
|
|
24
|
+
data?: Parameters<messageType[A]>[0]
|
|
23
25
|
) {
|
|
24
|
-
|
|
26
|
+
const tabs = await chrome.tabs.query({ active: true, url: CONTENT_MATCHES })
|
|
27
|
+
return await sendMessage(action, data as never, { tabId: tabs[0].id! })
|
|
25
28
|
}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineExtensionMessaging } from '@webext-core/messaging'
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
3
|
+
export type messageType = {
|
|
4
|
+
test: () => Promise<string>
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export
|
|
8
|
-
[ACTIONS.TEST]: object
|
|
9
|
-
}
|
|
10
|
-
export interface responseType {}
|
|
11
|
-
|
|
12
|
-
export const action = message.create<ACTIONS, messageType, responseType>()
|
|
7
|
+
export const { sendMessage, onMessage } = defineExtensionMessaging<messageType>()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as message from './message'
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { map, unset } from 'lodash-es'
|
|
2
|
-
|
|
3
|
-
export type defActionType = string
|
|
4
|
-
export type messageOpsType<Action extends defActionType> = Record<Action, object>
|
|
5
|
-
export type genMessageType<
|
|
6
|
-
Action extends defActionType,
|
|
7
|
-
MessageOps extends messageOpsType<Action>[Action]
|
|
8
|
-
> = { action: Action } & MessageOps
|
|
9
|
-
export type responseType<Action extends defActionType> = { [key in Action]?: any }
|
|
10
|
-
export type actionHandlerType<Message, Response> = (
|
|
11
|
-
message: Message,
|
|
12
|
-
sender: chrome.runtime.MessageSender,
|
|
13
|
-
callback: (response?: Response) => void
|
|
14
|
-
) => any
|
|
15
|
-
class MessageConstructor<
|
|
16
|
-
Action extends defActionType,
|
|
17
|
-
MessageConfig extends messageOpsType<Action>,
|
|
18
|
-
Response extends responseType<Action>
|
|
19
|
-
> {
|
|
20
|
-
action: {
|
|
21
|
-
[key: string]: actionHandlerType<
|
|
22
|
-
genMessageType<Action, MessageConfig[Action]>,
|
|
23
|
-
Response[Action]
|
|
24
|
-
>
|
|
25
|
-
}
|
|
26
|
-
constructor() {
|
|
27
|
-
this.action = {}
|
|
28
|
-
}
|
|
29
|
-
initListener() {
|
|
30
|
-
chrome.runtime.onMessage.addListener((message, sender, callback) => {
|
|
31
|
-
this.action[message.action]?.(message, sender, callback)
|
|
32
|
-
return true
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
addListener<A extends Action>(
|
|
36
|
-
action: A,
|
|
37
|
-
callback: actionHandlerType<genMessageType<A, MessageConfig[A]>, Response[A]>
|
|
38
|
-
) {
|
|
39
|
-
this.action[action] = callback
|
|
40
|
-
}
|
|
41
|
-
removeListener(action: Action) {
|
|
42
|
-
unset(this.action, action)
|
|
43
|
-
}
|
|
44
|
-
async send<A extends Action>(message: genMessageType<A, MessageConfig[A]>) {
|
|
45
|
-
return new Promise<Response[A]>(resolve => {
|
|
46
|
-
chrome.runtime.sendMessage(message, response => resolve(response))
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
async sendToContent<A extends Action>(
|
|
50
|
-
message: genMessageType<A, MessageConfig[A]>,
|
|
51
|
-
tabConfig: chrome.tabs.QueryInfo
|
|
52
|
-
) {
|
|
53
|
-
const tabs = await chrome.tabs.query(tabConfig)
|
|
54
|
-
return await Promise.all(
|
|
55
|
-
map(tabs, tab => {
|
|
56
|
-
return new Promise<Response[A]>(resolve => {
|
|
57
|
-
chrome.tabs.sendMessage(tab.id!, message, response => resolve(response))
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function create<
|
|
65
|
-
Action extends defActionType,
|
|
66
|
-
MessageOps extends messageOpsType<Action>,
|
|
67
|
-
Response extends responseType<Action>
|
|
68
|
-
>() {
|
|
69
|
-
return new MessageConstructor<Action, MessageOps, Response>()
|
|
70
|
-
}
|