create-packer 1.38.2 → 1.39.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.
- package/package.json +4 -5
- package/template/docusaurus/package.json +1 -1
- package/template/{web-app/react-vite/.eslintignore → lib/workspace/.stylelintignore} +2 -0
- package/template/lib/workspace/.stylelintrc +4 -9
- package/template/lib/workspace/eslint.config.mjs +116 -0
- package/template/lib/workspace/package.json +81 -73
- package/template/lib/workspace/packages/react/package.json +41 -41
- package/template/lib/workspace/packages/react/tsconfig.json +3 -8
- package/template/lib/workspace/packages/react/tsconfig.lint.json +21 -0
- package/template/lib/workspace/packages/ts/package.json +29 -29
- package/template/lib/workspace/packages/ts/tsconfig.json +9 -6
- package/template/lib/workspace/packages/ts/tsconfig.lint.json +21 -0
- package/template/nest/package.json +82 -84
- package/template/web-app/react-rsbuild/domain/app/components/app-context.tsx +17 -17
- package/template/web-app/react-rsbuild/domain/router/components/index.ts +2 -0
- package/template/web-app/react-rsbuild/domain/router/components/route-layout.tsx +19 -0
- package/template/web-app/react-rsbuild/domain/router/components/sub-route-outlet.tsx +22 -0
- package/template/web-app/react-rsbuild/domain/router/index.ts +4 -3
- package/template/web-app/react-rsbuild/eslint.config.js +104 -0
- package/template/web-app/react-rsbuild/package.json +78 -79
- package/template/web-app/react-rsbuild/pages/home/index.ts +1 -1
- package/template/web-app/react-rsbuild/pages/home/{home.styled.ts → view.styled.ts} +7 -7
- package/template/web-app/react-rsbuild/pages/home/{home.tsx → view.tsx} +10 -10
- package/template/web-app/{react-vite/shared/tools → react-rsbuild/shared/components}/componentInstance.tsx +80 -80
- package/template/web-app/react-rsbuild/shared/components/index.ts +1 -0
- package/template/web-app/react-rsbuild/shared/service/home.ts +8 -8
- package/template/web-app/react-rsbuild/shared/theme/theme.styled.ts +56 -56
- package/template/web-app/react-rsbuild/shared/tools/index.ts +0 -1
- package/template/web-app/react-vite/domain/router/components/index.ts +2 -0
- package/template/web-app/react-vite/domain/router/components/route-layout.tsx +19 -0
- package/template/web-app/react-vite/domain/router/components/sub-route-outlet.tsx +22 -0
- package/template/web-app/react-vite/domain/router/index.ts +4 -3
- package/template/web-app/react-vite/eslint.config.js +104 -0
- package/template/web-app/react-vite/package.json +79 -79
- package/template/web-app/react-vite/pages/home/index.ts +1 -1
- package/template/web-app/react-vite/pages/home/{home.mock.ts → view.mock.ts} +19 -19
- package/template/web-app/{react-webpack/pages/home/home.styled.ts → react-vite/pages/home/view.styled.ts} +7 -7
- package/template/web-app/react-vite/pages/home/{home.tsx → view.tsx} +10 -10
- package/template/web-app/{react-rsbuild/shared/tools → react-vite/shared/components}/componentInstance.tsx +80 -80
- package/template/web-app/react-vite/shared/components/index.ts +1 -0
- package/template/web-app/react-vite/shared/service/home.ts +10 -10
- package/template/web-app/react-vite/shared/theme/theme.styled.ts +55 -56
- package/template/web-app/react-vite/shared/tools/index.ts +0 -1
- package/template/web-app/react-vite/vite.config.ts +80 -76
- package/template/web-app/react-webpack/domain/router/components/index.ts +2 -0
- package/template/web-app/react-webpack/domain/router/components/route-layout.tsx +19 -0
- package/template/web-app/react-webpack/domain/router/components/sub-route-outlet.tsx +22 -0
- package/template/web-app/react-webpack/domain/router/index.ts +4 -3
- package/template/web-app/react-webpack/eslint.config.js +104 -0
- package/template/web-app/react-webpack/package.json +84 -87
- package/template/web-app/react-webpack/pages/home/index.ts +1 -1
- package/template/web-app/{react-vite/pages/home/home.styled.ts → react-webpack/pages/home/view.styled.ts} +7 -7
- package/template/web-app/react-webpack/pages/home/{home.tsx → view.tsx} +10 -10
- package/template/web-app/react-webpack/shared/{tools → components}/componentInstance.tsx +78 -78
- package/template/web-app/react-webpack/shared/components/index.ts +1 -0
- package/template/web-app/react-webpack/shared/theme/theme.styled.ts +56 -56
- package/template/web-app/react-webpack/shared/tools/index.ts +0 -1
- package/template/web-app/solid/package.json +53 -51
- package/template/web-app/solid/src/pages/home/index.ts +1 -1
- package/template/web-app/solid/src/pages/home/{home.container.tsx → view.tsx} +5 -5
- package/template/web-app/solid/src/pages/notFound/index.ts +1 -1
- package/template/web-app/solid/src/pages/notFound/{notFound.container.tsx → view.tsx} +3 -3
- package/template/web-app/svelte/.prettierrc +21 -14
- package/template/web-app/svelte/.svelte-kit/ambient.d.ts +181 -177
- package/template/web-app/svelte/.svelte-kit/generated/client/app.js +28 -23
- package/template/web-app/svelte/.svelte-kit/generated/client/matchers.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/0.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/1.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/client/nodes/2.js +1 -1
- package/template/web-app/svelte/.svelte-kit/generated/root.js +3 -0
- package/template/web-app/svelte/.svelte-kit/generated/root.svelte +66 -62
- package/template/web-app/svelte/.svelte-kit/generated/server/internal.js +49 -61
- package/template/web-app/svelte/.svelte-kit/non-ambient.d.ts +25 -23
- package/template/web-app/svelte/.svelte-kit/tsconfig.json +49 -32
- package/template/web-app/svelte/.svelte-kit/types/route_meta_data.json +3 -3
- package/template/web-app/svelte/.svelte-kit/types/src/routes/$types.d.ts +22 -35
- package/template/web-app/svelte/eslint.config.js +95 -0
- package/template/web-app/svelte/package.json +55 -55
- package/template/web-app/svelte/src/app.d.ts +13 -12
- package/template/web-app/svelte/src/app.html +2 -2
- package/template/web-app/svelte/src/lib/index.ts +1 -0
- package/template/web-app/svelte/src/routes/+page.svelte +2 -2
- package/template/web-app/svelte/vite.config.ts +59 -55
- package/template/web-app/vue/eslint.config.js +109 -0
- package/template/web-app/vue/package.json +70 -70
- package/template/web-app/vue/pages/home/index.ts +1 -1
- package/template/web-app/vue/pages/home/{home.mock.ts → view.mock.ts} +19 -19
- package/template/web-app/vue/pages/home/{home.vue → view.vue} +16 -16
- package/template/web-app/vue/vite.config.ts +69 -65
- package/template/web-extension/.wxt/eslint-auto-imports.mjs +28 -0
- package/template/web-extension/.wxt/tsconfig.json +28 -25
- package/template/web-extension/.wxt/types/globals.d.ts +15 -15
- package/template/web-extension/.wxt/types/i18n.d.ts +81 -87
- package/template/web-extension/.wxt/types/imports.d.ts +22 -21
- package/template/web-extension/.wxt/types/paths.d.ts +16 -15
- package/template/web-extension/.wxt/wxt.d.ts +7 -6
- package/template/web-extension/entrypoints/content/domain/app/tools/insertApp.tsx +2 -3
- package/template/web-extension/entrypoints/content/index.tsx +10 -12
- package/template/web-extension/entrypoints/popup/main.tsx +14 -14
- package/template/web-extension/entrypoints/popup/{popup.container.tsx → popup.tsx} +3 -3
- package/template/web-extension/eslint.config.js +106 -0
- package/template/web-extension/package.json +84 -86
- package/template/web-extension/shared/content/constant.ts +1 -0
- package/template/web-extension/shared/content/index.ts +2 -1
- package/template/web-extension/shared/content/message.ts +25 -15
- package/template/web-extension/shared/styles/theme.styled.ts +56 -56
- package/template/web-extension/shared/tools/message.ts +70 -80
- package/template/web-extension/tsconfig.json +32 -32
- package/template/web-extension/vite-env.d.ts +20 -19
- package/template/web-extension/wxt.config.ts +43 -50
- package/template/lib/workspace/.eslintrc +0 -111
- package/template/lib/workspace/packages/react/.eslintrc +0 -111
- package/template/lib/workspace/packages/react/.stylelintrc +0 -29
- package/template/web-app/react-rsbuild/.eslintignore +0 -4
- package/template/web-app/react-rsbuild/.eslintrc +0 -111
- package/template/web-app/react-vite/.eslintrc +0 -110
- package/template/web-app/react-webpack/.eslintignore +0 -4
- package/template/web-app/react-webpack/.eslintrc +0 -110
- package/template/web-app/svelte/.eslintignore +0 -13
- package/template/web-app/svelte/.eslintrc +0 -76
- package/template/web-app/vue/.eslintignore +0 -4
- package/template/web-app/vue/.eslintrc +0 -97
- package/template/web-extension/.eslintignore +0 -4
- package/template/web-extension/.eslintrc +0 -110
- /package/template/web-app/solid/src/pages/home/{home.css → view.css} +0 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import eslint from '@eslint/js'
|
|
2
|
+
import globals from 'globals'
|
|
3
|
+
import tseslint from 'typescript-eslint'
|
|
4
|
+
import importPlugin from 'eslint-plugin-import'
|
|
5
|
+
import reactPlugin from 'eslint-plugin-react'
|
|
6
|
+
import reactHooksPlugin from 'eslint-plugin-react-hooks'
|
|
7
|
+
import autoImports from './.wxt/eslint-auto-imports.mjs'
|
|
8
|
+
|
|
9
|
+
const scriptExtensions = ['js', 'jsx', 'mjs', 'cjs', 'ts', 'tsx']
|
|
10
|
+
const files = scriptExtensions.map(ext => `**/*.${ext}`)
|
|
11
|
+
|
|
12
|
+
export default tseslint.config([
|
|
13
|
+
{
|
|
14
|
+
ignores: ['**/node_modules/', '**/dist/', '**/.history/', '**/.vscode/', 'vite.config.ts.*']
|
|
15
|
+
},
|
|
16
|
+
eslint.configs.recommended,
|
|
17
|
+
importPlugin.flatConfigs.recommended,
|
|
18
|
+
tseslint.configs.recommended,
|
|
19
|
+
autoImports,
|
|
20
|
+
{
|
|
21
|
+
plugins: { reactPlugin, reactHooksPlugin },
|
|
22
|
+
files,
|
|
23
|
+
languageOptions: {
|
|
24
|
+
ecmaVersion: 2018,
|
|
25
|
+
sourceType: 'module',
|
|
26
|
+
parserOptions: {
|
|
27
|
+
ecmaFeatures: {
|
|
28
|
+
jsx: true
|
|
29
|
+
},
|
|
30
|
+
useJSXTextNode: true
|
|
31
|
+
},
|
|
32
|
+
globals: {
|
|
33
|
+
...globals.browser,
|
|
34
|
+
...globals.node
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
settings: {
|
|
38
|
+
'import/resolver': {
|
|
39
|
+
typescript: true,
|
|
40
|
+
node: true
|
|
41
|
+
},
|
|
42
|
+
react: {
|
|
43
|
+
version: '18'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
rules: {
|
|
47
|
+
'import/export': 'off',
|
|
48
|
+
'import/namespace': 'off',
|
|
49
|
+
'import/default': 'off',
|
|
50
|
+
'import/no-named-as-default-member': 'off',
|
|
51
|
+
'import/no-named-as-default': 'off',
|
|
52
|
+
'import/order': [
|
|
53
|
+
'error',
|
|
54
|
+
{
|
|
55
|
+
groups: [
|
|
56
|
+
'builtin',
|
|
57
|
+
'external',
|
|
58
|
+
'internal',
|
|
59
|
+
'parent',
|
|
60
|
+
'sibling',
|
|
61
|
+
'index',
|
|
62
|
+
'object',
|
|
63
|
+
'type'
|
|
64
|
+
],
|
|
65
|
+
pathGroups: [
|
|
66
|
+
{ pattern: 'react', group: 'external', position: 'before' },
|
|
67
|
+
{ pattern: 'react-dom/*', group: 'external', position: 'before' },
|
|
68
|
+
{ pattern: 'react-router', group: 'external', position: 'before' },
|
|
69
|
+
{ pattern: 'react-router-dom', group: 'external', position: 'before' }
|
|
70
|
+
],
|
|
71
|
+
pathGroupsExcludedImportTypes: ['react', 'react-router', 'react-router-dom']
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
'no-case-declarations': 'off',
|
|
75
|
+
'@typescript-eslint/no-unused-expressions': 'off',
|
|
76
|
+
'@typescript-eslint/no-empty-object-type': 'off',
|
|
77
|
+
'@typescript-eslint/no-var-requires': 0,
|
|
78
|
+
'@typescript-eslint/explicit-function-return-type': 'off',
|
|
79
|
+
'@typescript-eslint/no-explicit-any': 0,
|
|
80
|
+
'@typescript-eslint/no-non-null-assertion': 'off',
|
|
81
|
+
'@typescript-eslint/no-inferrable-types': [
|
|
82
|
+
'warn',
|
|
83
|
+
{
|
|
84
|
+
ignoreParameters: true
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
'@typescript-eslint/no-unused-vars': [
|
|
88
|
+
'warn',
|
|
89
|
+
{
|
|
90
|
+
argsIgnorePattern: '^_'
|
|
91
|
+
}
|
|
92
|
+
],
|
|
93
|
+
'@typescript-eslint/member-delimiter-style': 0,
|
|
94
|
+
'@typescript-eslint/class-name-casing': 0,
|
|
95
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
96
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
97
|
+
'@typescript-eslint/no-empty-interface': 'off',
|
|
98
|
+
'react/prop-types': 'off',
|
|
99
|
+
'react/no-find-dom-node': 'off',
|
|
100
|
+
'react-hooks/exhaustive-deps': 'off',
|
|
101
|
+
'react/display-name': 'off',
|
|
102
|
+
'react/react-in-jsx-scope': 'off',
|
|
103
|
+
'no-constant-condition': 'off'
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
])
|
|
@@ -1,86 +1,84 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "web-extension",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"prepare": "husky install",
|
|
8
|
-
"dev": "wxt",
|
|
9
|
-
"dev:firefox": "wxt -b firefox",
|
|
10
|
-
"build": "wxt build",
|
|
11
|
-
"build_dev": "wxt build --mode dev",
|
|
12
|
-
"build:firefox": "wxt build -b firefox",
|
|
13
|
-
"build_dev:firefox": "wxt build -b firefox --mode dev",
|
|
14
|
-
"zip": "wxt zip",
|
|
15
|
-
"zip_dev": "wxt zip --mode dev",
|
|
16
|
-
"zip:firefox": "wxt zip -b firefox",
|
|
17
|
-
"zip_dev:firefox": "wxt zip -b firefox --mode dev",
|
|
18
|
-
"postinstall": "wxt prepare",
|
|
19
|
-
"up:vite": "pnpm up vite @vitejs/* -L",
|
|
20
|
-
"format": "prettier --write \"**/*.{ts,js,tsx,jsx,json,css,scss,less}\"",
|
|
21
|
-
"lint": "tsc --noEmit && eslint
|
|
22
|
-
"lint:fix": "eslint
|
|
23
|
-
"cz": "cz",
|
|
24
|
-
"push": "npm run commit && git push",
|
|
25
|
-
"commit": "git add . && npm run cz"
|
|
26
|
-
},
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@tanstack/react-query": "5.51.15",
|
|
29
|
-
"axios": "
|
|
30
|
-
"define-zustand": "3.1.1",
|
|
31
|
-
"immer": "10.0.1",
|
|
32
|
-
"lodash-es": "4.17.21",
|
|
33
|
-
"qs": "6.11.2",
|
|
34
|
-
"react": "18.3.1",
|
|
35
|
-
"react-dom": "18.3.1",
|
|
36
|
-
"styled-components": "6.1.11",
|
|
37
|
-
"zustand": "4.4.1"
|
|
38
|
-
},
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"@commitlint/
|
|
42
|
-
"@commitlint/
|
|
43
|
-
"@
|
|
44
|
-
"@
|
|
45
|
-
"@types/
|
|
46
|
-
"@types/
|
|
47
|
-
"@types/
|
|
48
|
-
"@types/
|
|
49
|
-
"@types/react": "18.3.
|
|
50
|
-
"@
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"eslint": "
|
|
59
|
-
"eslint-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"postcss": "
|
|
66
|
-
"postcss-
|
|
67
|
-
"postcss-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"vite": "
|
|
77
|
-
"
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "web-extension",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"prepare": "husky install",
|
|
8
|
+
"dev": "wxt",
|
|
9
|
+
"dev:firefox": "wxt -b firefox",
|
|
10
|
+
"build": "wxt build",
|
|
11
|
+
"build_dev": "wxt build --mode dev",
|
|
12
|
+
"build:firefox": "wxt build -b firefox",
|
|
13
|
+
"build_dev:firefox": "wxt build -b firefox --mode dev",
|
|
14
|
+
"zip": "wxt zip",
|
|
15
|
+
"zip_dev": "wxt zip --mode dev",
|
|
16
|
+
"zip:firefox": "wxt zip -b firefox",
|
|
17
|
+
"zip_dev:firefox": "wxt zip -b firefox --mode dev",
|
|
18
|
+
"postinstall": "wxt prepare",
|
|
19
|
+
"up:vite": "pnpm up vite @vitejs/* -L",
|
|
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",
|
|
23
|
+
"cz": "cz",
|
|
24
|
+
"push": "npm run commit && git push",
|
|
25
|
+
"commit": "git add . && npm run cz"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@tanstack/react-query": "5.51.15",
|
|
29
|
+
"axios": "1.7.9",
|
|
30
|
+
"define-zustand": "3.1.1",
|
|
31
|
+
"immer": "10.0.1",
|
|
32
|
+
"lodash-es": "4.17.21",
|
|
33
|
+
"qs": "6.11.2",
|
|
34
|
+
"react": "18.3.1",
|
|
35
|
+
"react-dom": "18.3.1",
|
|
36
|
+
"styled-components": "6.1.11",
|
|
37
|
+
"zustand": "4.4.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@commitlint/cli": "17.6.1",
|
|
41
|
+
"@commitlint/config-conventional": "17.6.1",
|
|
42
|
+
"@commitlint/cz-commitlint": "17.5.0",
|
|
43
|
+
"@eslint/js": "9.15.0",
|
|
44
|
+
"@types/chrome": "0.0.254",
|
|
45
|
+
"@types/lodash-es": "4.17.12",
|
|
46
|
+
"@types/node": "18.16.0",
|
|
47
|
+
"@types/qs": "6.9.7",
|
|
48
|
+
"@types/react": "18.3.3",
|
|
49
|
+
"@types/react-dom": "18.3.0",
|
|
50
|
+
"@vitejs/plugin-react": "4.3.4",
|
|
51
|
+
"autoprefixer": "10.4.14",
|
|
52
|
+
"babel-plugin-styled-components": "2.1.4",
|
|
53
|
+
"commitizen": "4.3.0",
|
|
54
|
+
"cssnano": "6.0.0",
|
|
55
|
+
"eslint": "9.17.0",
|
|
56
|
+
"eslint-import-resolver-typescript": "3.7.0",
|
|
57
|
+
"eslint-plugin-import": "2.31.0",
|
|
58
|
+
"eslint-plugin-react": "7.37.2",
|
|
59
|
+
"eslint-plugin-react-hooks": "5.1.0",
|
|
60
|
+
"globals": "15.12.0",
|
|
61
|
+
"husky": "9.1.6",
|
|
62
|
+
"inquirer": "^8.1.2",
|
|
63
|
+
"postcss": "8.4.31",
|
|
64
|
+
"postcss-import": "15.1.0",
|
|
65
|
+
"postcss-nesting": "11.2.2",
|
|
66
|
+
"postcss-scss": "4.0.9",
|
|
67
|
+
"postcss-styled-syntax": "0.6.4",
|
|
68
|
+
"prettier": "3.2.5",
|
|
69
|
+
"rimraf": "5.0.1",
|
|
70
|
+
"sass": "1.63.4",
|
|
71
|
+
"stylelint": "16.10.0",
|
|
72
|
+
"stylelint-config-standard": "36.0.1",
|
|
73
|
+
"typescript": "5.7.2",
|
|
74
|
+
"typescript-eslint": "8.15.0",
|
|
75
|
+
"vite": "6.0.7",
|
|
76
|
+
"vite-plugin-svgr": "4.3.0",
|
|
77
|
+
"wxt": "0.19.25"
|
|
78
|
+
},
|
|
79
|
+
"config": {
|
|
80
|
+
"commitizen": {
|
|
81
|
+
"path": "@commitlint/cz-commitlint"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const CONTENT_MATCHES = ['<all_urls>']
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * as contentMessage from './message'
|
|
1
|
+
export * as contentMessage from './message'
|
|
2
|
+
export * from './constant'
|
|
@@ -1,15 +1,25 @@
|
|
|
1
|
-
import { message } from '@/shared/tools'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { message } from '@/shared/tools'
|
|
2
|
+
import { CONTENT_MATCHES } from './constant'
|
|
3
|
+
|
|
4
|
+
export enum ACTIONS {
|
|
5
|
+
TEST = 'TEST'
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface messageType {
|
|
9
|
+
[ACTIONS.TEST]: object
|
|
10
|
+
}
|
|
11
|
+
export interface responseType {}
|
|
12
|
+
|
|
13
|
+
export const action = message.create<ACTIONS, messageType, responseType>()
|
|
14
|
+
|
|
15
|
+
export function sendToAllContent<A extends ACTIONS>(
|
|
16
|
+
message: message.genMessageType<A, messageType[A]>
|
|
17
|
+
) {
|
|
18
|
+
return action.sendToContent(message, { active: true, url: CONTENT_MATCHES })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function sendToCurrentContent<A extends ACTIONS>(
|
|
22
|
+
message: message.genMessageType<A, messageType[A]>
|
|
23
|
+
) {
|
|
24
|
+
return action.sendToContent(message, { active: true, url: CONTENT_MATCHES })
|
|
25
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { CSSProperties } from 'react'
|
|
2
|
-
|
|
3
|
-
import { isString } from 'lodash-es'
|
|
4
|
-
|
|
5
|
-
export const theme = {
|
|
6
|
-
tools: {
|
|
7
|
-
ellipsis: () => ({
|
|
8
|
-
overflow: 'hidden',
|
|
9
|
-
textOverflow: 'ellipsis',
|
|
10
|
-
whiteSpace: 'nowrap'
|
|
11
|
-
}),
|
|
12
|
-
lineClamp: (n: number) => ({
|
|
13
|
-
'-webkit-line-clamp': `${n}`,
|
|
14
|
-
'-webkit-box-orient': 'vertical',
|
|
15
|
-
overflow: 'hidden',
|
|
16
|
-
display: '-webkit-box'
|
|
17
|
-
}),
|
|
18
|
-
size: (s: string) => ({ width: s, height: s }),
|
|
19
|
-
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
20
|
-
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
21
|
-
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
22
|
-
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
23
|
-
flex: (
|
|
24
|
-
align: CSSProperties['alignItems'],
|
|
25
|
-
justify: CSSProperties['justifyContent'],
|
|
26
|
-
vertical?: boolean
|
|
27
|
-
) => {
|
|
28
|
-
return {
|
|
29
|
-
display: 'flex',
|
|
30
|
-
alignItems: align,
|
|
31
|
-
justifyContent: justify,
|
|
32
|
-
flexDirection: vertical ? 'column' : 'row'
|
|
33
|
-
} satisfies CSSProperties
|
|
34
|
-
},
|
|
35
|
-
/** 数字为元素数量,字符串为对应css的值 */
|
|
36
|
-
grid: {
|
|
37
|
-
grid: (rows: number | string, cols: number | string, gap?: number) => ({
|
|
38
|
-
display: 'grid',
|
|
39
|
-
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
40
|
-
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
41
|
-
gap: gap ? `${gap}px` : void 0
|
|
42
|
-
}),
|
|
43
|
-
rows: (rows: number | string, gap?: number) => ({
|
|
44
|
-
display: 'grid',
|
|
45
|
-
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
46
|
-
rowGap: gap ? `${gap}px` : void 0
|
|
47
|
-
}),
|
|
48
|
-
cols: (cols: number | string, gap?: number) => ({
|
|
49
|
-
display: 'grid',
|
|
50
|
-
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
51
|
-
columnGap: gap ? `${gap}px` : void 0
|
|
52
|
-
})
|
|
53
|
-
} satisfies Record<string,
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export type themeType = typeof theme
|
|
1
|
+
import { CSSProperties } from 'react'
|
|
2
|
+
|
|
3
|
+
import { isString } from 'lodash-es'
|
|
4
|
+
|
|
5
|
+
export const theme = {
|
|
6
|
+
tools: {
|
|
7
|
+
ellipsis: () => ({
|
|
8
|
+
overflow: 'hidden',
|
|
9
|
+
textOverflow: 'ellipsis',
|
|
10
|
+
whiteSpace: 'nowrap'
|
|
11
|
+
}),
|
|
12
|
+
lineClamp: (n: number) => ({
|
|
13
|
+
'-webkit-line-clamp': `${n}`,
|
|
14
|
+
'-webkit-box-orient': 'vertical',
|
|
15
|
+
overflow: 'hidden',
|
|
16
|
+
display: '-webkit-box'
|
|
17
|
+
}),
|
|
18
|
+
size: (s: string) => ({ width: s, height: s }),
|
|
19
|
+
py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
|
|
20
|
+
px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
|
|
21
|
+
my: (s: string) => ({ marginTop: s, marginBottom: s }),
|
|
22
|
+
mx: (s: string) => ({ marginLeft: s, marginRight: s }),
|
|
23
|
+
flex: (
|
|
24
|
+
align: CSSProperties['alignItems'],
|
|
25
|
+
justify: CSSProperties['justifyContent'],
|
|
26
|
+
vertical?: boolean
|
|
27
|
+
) => {
|
|
28
|
+
return {
|
|
29
|
+
display: 'flex',
|
|
30
|
+
alignItems: align,
|
|
31
|
+
justifyContent: justify,
|
|
32
|
+
flexDirection: vertical ? 'column' : 'row'
|
|
33
|
+
} satisfies CSSProperties
|
|
34
|
+
},
|
|
35
|
+
/** 数字为元素数量,字符串为对应css的值 */
|
|
36
|
+
grid: {
|
|
37
|
+
grid: (rows: number | string, cols: number | string, gap?: number) => ({
|
|
38
|
+
display: 'grid',
|
|
39
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
40
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
41
|
+
gap: gap ? `${gap}px` : void 0
|
|
42
|
+
}),
|
|
43
|
+
rows: (rows: number | string, gap?: number) => ({
|
|
44
|
+
display: 'grid',
|
|
45
|
+
gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
|
|
46
|
+
rowGap: gap ? `${gap}px` : void 0
|
|
47
|
+
}),
|
|
48
|
+
cols: (cols: number | string, gap?: number) => ({
|
|
49
|
+
display: 'grid',
|
|
50
|
+
gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
|
|
51
|
+
columnGap: gap ? `${gap}px` : void 0
|
|
52
|
+
})
|
|
53
|
+
} satisfies Record<string, (...args: any) => CSSProperties>
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export type themeType = typeof theme
|
|
@@ -1,80 +1,70 @@
|
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function create<
|
|
75
|
-
Action extends defActionType,
|
|
76
|
-
MessageOps extends messageOpsType<Action>,
|
|
77
|
-
Response extends responseType<Action>
|
|
78
|
-
>() {
|
|
79
|
-
return new MessageConstructor<Action, MessageOps, Response>()
|
|
80
|
-
}
|
|
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
|
+
}
|