调整
This commit is contained in:
parent
177594b638
commit
d15e9171f7
@ -40,6 +40,7 @@
|
||||
"@rspack/cli": "^1.0.14",
|
||||
"@rspack/core": "^1.0.14",
|
||||
"@types/chrome": "^0.0.279",
|
||||
"@types/node": "^22.10.2",
|
||||
"@types/pako": "^2.0.3",
|
||||
"@types/react": "^18.2.48",
|
||||
"@types/react-dom": "^18.2.18",
|
||||
|
@ -1,9 +1,9 @@
|
||||
export type ApiFunction = (params: any, con: chrome.runtime.Port | chrome.runtime.MessageSender) => any;
|
||||
|
||||
export class Server {
|
||||
apiFunctionMap: Map<string, ApiFunction> = new Map();
|
||||
private apiFunctionMap: Map<string, ApiFunction> = new Map();
|
||||
|
||||
constructor() {
|
||||
constructor(private env: string) {
|
||||
chrome.runtime.onConnect.addListener((port) => {
|
||||
port.onMessage.addListener((msg: { action: string }) => {
|
||||
this.connectHandle(msg.action, msg, port);
|
||||
|
207
pnpm-lock.yaml
generated
207
pnpm-lock.yaml
generated
@ -75,6 +75,9 @@ importers:
|
||||
'@types/chrome':
|
||||
specifier: ^0.0.279
|
||||
version: 0.0.279
|
||||
'@types/node':
|
||||
specifier: ^22.10.2
|
||||
version: 22.10.2
|
||||
'@types/pako':
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3
|
||||
@ -92,7 +95,7 @@ importers:
|
||||
version: 0.65.0-beta.2(postcss@8.4.49)
|
||||
'@vitest/coverage-v8':
|
||||
specifier: 2.1.4
|
||||
version: 2.1.4(vitest@2.1.4(@types/node@22.8.1)(jsdom@25.0.1)(terser@5.36.0))
|
||||
version: 2.1.4(vitest@2.1.4(@types/node@22.10.2)(jsdom@25.0.1)(terser@5.36.0))
|
||||
autoprefixer:
|
||||
specifier: ^10.4.20
|
||||
version: 10.4.20(postcss@8.4.49)
|
||||
@ -125,7 +128,7 @@ importers:
|
||||
version: 3.3.3
|
||||
ts-node:
|
||||
specifier: ^10.9.2
|
||||
version: 10.9.2(@types/node@22.8.1)(typescript@5.6.3)
|
||||
version: 10.9.2(@types/node@22.10.2)(typescript@5.6.3)
|
||||
typescript:
|
||||
specifier: ^5.6.3
|
||||
version: 5.6.3
|
||||
@ -134,10 +137,10 @@ importers:
|
||||
version: 8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.6.3)
|
||||
unocss:
|
||||
specifier: 0.65.0-beta.2
|
||||
version: 0.65.0-beta.2(@unocss/webpack@0.65.0-beta.2(rollup@4.24.4)(webpack@5.96.1(esbuild@0.23.1)))(postcss@8.4.49)(rollup@4.24.4)(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
version: 0.65.0-beta.2(@unocss/webpack@0.65.0-beta.2(rollup@4.24.4)(webpack@5.96.1(esbuild@0.23.1)))(postcss@8.4.49)(rollup@4.24.4)(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
vitest:
|
||||
specifier: ^2.1.4
|
||||
version: 2.1.4(@types/node@22.8.1)(jsdom@25.0.1)(terser@5.36.0)
|
||||
version: 2.1.4(@types/node@22.10.2)(jsdom@25.0.1)(terser@5.36.0)
|
||||
|
||||
packages/message:
|
||||
dependencies:
|
||||
@ -1025,6 +1028,9 @@ packages:
|
||||
'@types/node-forge@1.3.11':
|
||||
resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==}
|
||||
|
||||
'@types/node@22.10.2':
|
||||
resolution: {integrity: sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==}
|
||||
|
||||
'@types/node@22.8.1':
|
||||
resolution: {integrity: sha512-k6Gi8Yyo8EtrNtkHXutUu2corfDf9su95VYVP10aGYMMROM6SAItZi0w1XszA6RtWTHSVp5OeFof37w0IEqCQg==}
|
||||
|
||||
@ -3477,6 +3483,9 @@ packages:
|
||||
undici-types@6.19.8:
|
||||
resolution: {integrity: sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==}
|
||||
|
||||
undici-types@6.20.0:
|
||||
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
|
||||
|
||||
unocss@0.65.0-beta.2:
|
||||
resolution: {integrity: sha512-iBuELniWmyGEws8F3rCWTQ8bO0sft8yEgYZsny0fHB+rvty6zW67qvSNd7KTj6LiT37zU/FWSWZKRYzCWrq9kA==}
|
||||
engines: {node: '>=14'}
|
||||
@ -4419,11 +4428,11 @@ snapshots:
|
||||
'@types/body-parser@1.19.5':
|
||||
dependencies:
|
||||
'@types/connect': 3.4.38
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/bonjour@3.5.13':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/chrome@0.0.279':
|
||||
dependencies:
|
||||
@ -4433,11 +4442,11 @@ snapshots:
|
||||
'@types/connect-history-api-fallback@1.5.4':
|
||||
dependencies:
|
||||
'@types/express-serve-static-core': 5.0.1
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/connect@3.4.38':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/eslint-scope@3.7.7':
|
||||
dependencies:
|
||||
@ -4455,14 +4464,14 @@ snapshots:
|
||||
|
||||
'@types/express-serve-static-core@4.19.6':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
'@types/qs': 6.9.16
|
||||
'@types/range-parser': 1.2.7
|
||||
'@types/send': 0.17.4
|
||||
|
||||
'@types/express-serve-static-core@5.0.1':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
'@types/qs': 6.9.16
|
||||
'@types/range-parser': 1.2.7
|
||||
'@types/send': 0.17.4
|
||||
@ -4486,7 +4495,7 @@ snapshots:
|
||||
|
||||
'@types/http-proxy@1.17.15':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/json-schema@7.0.15': {}
|
||||
|
||||
@ -4496,7 +4505,11 @@ snapshots:
|
||||
|
||||
'@types/node-forge@1.3.11':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/node@22.10.2':
|
||||
dependencies:
|
||||
undici-types: 6.20.0
|
||||
|
||||
'@types/node@22.8.1':
|
||||
dependencies:
|
||||
@ -4528,7 +4541,7 @@ snapshots:
|
||||
'@types/send@0.17.4':
|
||||
dependencies:
|
||||
'@types/mime': 1.3.5
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/serve-index@1.9.4':
|
||||
dependencies:
|
||||
@ -4537,18 +4550,18 @@ snapshots:
|
||||
'@types/serve-static@1.15.7':
|
||||
dependencies:
|
||||
'@types/http-errors': 2.0.4
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
'@types/send': 0.17.4
|
||||
|
||||
'@types/sockjs@0.3.36':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@types/use-sync-external-store@0.0.3': {}
|
||||
|
||||
'@types/ws@8.5.12':
|
||||
dependencies:
|
||||
'@types/node': 22.8.1
|
||||
'@types/node': 22.10.2
|
||||
|
||||
'@typescript-eslint/eslint-plugin@8.11.0(@typescript-eslint/parser@8.11.0(eslint@9.13.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.13.0(jiti@1.21.6))(typescript@5.6.3)':
|
||||
dependencies:
|
||||
@ -4685,13 +4698,13 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.11.0
|
||||
eslint-visitor-keys: 3.4.3
|
||||
|
||||
'@unocss/astro@0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))':
|
||||
'@unocss/astro@0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))':
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.0-beta.2
|
||||
'@unocss/reset': 0.65.0-beta.2
|
||||
'@unocss/vite': 0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
'@unocss/vite': 0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
optionalDependencies:
|
||||
vite: 5.4.10(@types/node@22.8.1)(terser@5.36.0)
|
||||
vite: 5.4.10(@types/node@22.10.2)(terser@5.36.0)
|
||||
transitivePeerDependencies:
|
||||
- rollup
|
||||
- supports-color
|
||||
@ -4820,7 +4833,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@unocss/core': 0.65.0-beta.2
|
||||
|
||||
'@unocss/vite@0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))':
|
||||
'@unocss/vite@0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))':
|
||||
dependencies:
|
||||
'@ampproject/remapping': 2.3.0
|
||||
'@rollup/pluginutils': 5.1.3(rollup@4.24.4)
|
||||
@ -4830,7 +4843,7 @@ snapshots:
|
||||
chokidar: 3.6.0
|
||||
magic-string: 0.30.12
|
||||
tinyglobby: 0.2.10
|
||||
vite: 5.4.10(@types/node@22.8.1)(terser@5.36.0)
|
||||
vite: 5.4.10(@types/node@22.10.2)(terser@5.36.0)
|
||||
transitivePeerDependencies:
|
||||
- rollup
|
||||
- supports-color
|
||||
@ -4853,7 +4866,7 @@ snapshots:
|
||||
- supports-color
|
||||
optional: true
|
||||
|
||||
'@vitest/coverage-v8@2.1.4(vitest@2.1.4(@types/node@22.8.1)(jsdom@25.0.1)(terser@5.36.0))':
|
||||
'@vitest/coverage-v8@2.1.4(vitest@2.1.4(@types/node@22.10.2)(jsdom@25.0.1)(terser@5.36.0))':
|
||||
dependencies:
|
||||
'@ampproject/remapping': 2.3.0
|
||||
'@bcoe/v8-coverage': 0.2.3
|
||||
@ -4867,7 +4880,7 @@ snapshots:
|
||||
std-env: 3.7.0
|
||||
test-exclude: 7.0.1
|
||||
tinyrainbow: 1.2.0
|
||||
vitest: 2.1.4(@types/node@22.8.1)(jsdom@25.0.1)(terser@5.36.0)
|
||||
vitest: 2.1.4(@types/node@22.10.2)(jsdom@25.0.1)(terser@5.36.0)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@ -4878,13 +4891,13 @@ snapshots:
|
||||
chai: 5.1.2
|
||||
tinyrainbow: 1.2.0
|
||||
|
||||
'@vitest/mocker@2.1.4(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))':
|
||||
'@vitest/mocker@2.1.4(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))':
|
||||
dependencies:
|
||||
'@vitest/spy': 2.1.4
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.12
|
||||
optionalDependencies:
|
||||
vite: 5.4.10(@types/node@22.8.1)(terser@5.36.0)
|
||||
vite: 5.4.10(@types/node@22.10.2)(terser@5.36.0)
|
||||
|
||||
'@vitest/mocker@2.1.4(vite@5.4.10(@types/node@22.8.1))':
|
||||
dependencies:
|
||||
@ -7420,6 +7433,24 @@ snapshots:
|
||||
dependencies:
|
||||
typescript: 5.6.3
|
||||
|
||||
ts-node@10.9.2(@types/node@22.10.2)(typescript@5.6.3):
|
||||
dependencies:
|
||||
'@cspotcode/source-map-support': 0.8.1
|
||||
'@tsconfig/node10': 1.0.11
|
||||
'@tsconfig/node12': 1.0.11
|
||||
'@tsconfig/node14': 1.0.3
|
||||
'@tsconfig/node16': 1.0.4
|
||||
'@types/node': 22.10.2
|
||||
acorn: 8.13.0
|
||||
acorn-walk: 8.3.4
|
||||
arg: 4.1.3
|
||||
create-require: 1.1.1
|
||||
diff: 4.0.2
|
||||
make-error: 1.3.6
|
||||
typescript: 5.6.3
|
||||
v8-compile-cache-lib: 3.0.1
|
||||
yn: 3.1.1
|
||||
|
||||
ts-node@10.9.2(@types/node@22.8.1)(typescript@5.6.3):
|
||||
dependencies:
|
||||
'@cspotcode/source-map-support': 0.8.1
|
||||
@ -7531,9 +7562,11 @@ snapshots:
|
||||
|
||||
undici-types@6.19.8: {}
|
||||
|
||||
unocss@0.65.0-beta.2(@unocss/webpack@0.65.0-beta.2(rollup@4.24.4)(webpack@5.96.1(esbuild@0.23.1)))(postcss@8.4.49)(rollup@4.24.4)(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3)):
|
||||
undici-types@6.20.0: {}
|
||||
|
||||
unocss@0.65.0-beta.2(@unocss/webpack@0.65.0-beta.2(rollup@4.24.4)(webpack@5.96.1(esbuild@0.23.1)))(postcss@8.4.49)(rollup@4.24.4)(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3)):
|
||||
dependencies:
|
||||
'@unocss/astro': 0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
'@unocss/astro': 0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
'@unocss/cli': 0.65.0-beta.2(rollup@4.24.4)
|
||||
'@unocss/core': 0.65.0-beta.2
|
||||
'@unocss/postcss': 0.65.0-beta.2(postcss@8.4.49)
|
||||
@ -7549,10 +7582,10 @@ snapshots:
|
||||
'@unocss/transformer-compile-class': 0.65.0-beta.2
|
||||
'@unocss/transformer-directives': 0.65.0-beta.2
|
||||
'@unocss/transformer-variant-group': 0.65.0-beta.2
|
||||
'@unocss/vite': 0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
'@unocss/vite': 0.65.0-beta.2(rollup@4.24.4)(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))(vue@3.5.13(typescript@5.6.3))
|
||||
optionalDependencies:
|
||||
'@unocss/webpack': 0.65.0-beta.2(rollup@4.24.4)(webpack@5.96.1(esbuild@0.23.1))
|
||||
vite: 5.4.10(@types/node@22.8.1)(terser@5.36.0)
|
||||
vite: 5.4.10(@types/node@22.10.2)(terser@5.36.0)
|
||||
transitivePeerDependencies:
|
||||
- postcss
|
||||
- rollup
|
||||
@ -7608,6 +7641,23 @@ snapshots:
|
||||
|
||||
vary@1.1.2: {}
|
||||
|
||||
vite-node@2.1.4(@types/node@22.10.2)(terser@5.36.0):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
debug: 4.3.7
|
||||
pathe: 1.1.2
|
||||
vite: 5.4.10(@types/node@22.10.2)(terser@5.36.0)
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- less
|
||||
- lightningcss
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
|
||||
vite-node@2.1.4(@types/node@22.8.1):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
@ -7625,22 +7675,15 @@ snapshots:
|
||||
- supports-color
|
||||
- terser
|
||||
|
||||
vite-node@2.1.4(@types/node@22.8.1)(terser@5.36.0):
|
||||
vite@5.4.10(@types/node@22.10.2)(terser@5.36.0):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
debug: 4.3.7
|
||||
pathe: 1.1.2
|
||||
vite: 5.4.10(@types/node@22.8.1)(terser@5.36.0)
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- less
|
||||
- lightningcss
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
esbuild: 0.21.5
|
||||
postcss: 8.4.49
|
||||
rollup: 4.24.4
|
||||
optionalDependencies:
|
||||
'@types/node': 22.10.2
|
||||
fsevents: 2.3.3
|
||||
terser: 5.36.0
|
||||
|
||||
vite@5.4.10(@types/node@22.8.1):
|
||||
dependencies:
|
||||
@ -7651,15 +7694,41 @@ snapshots:
|
||||
'@types/node': 22.8.1
|
||||
fsevents: 2.3.3
|
||||
|
||||
vite@5.4.10(@types/node@22.8.1)(terser@5.36.0):
|
||||
vitest@2.1.4(@types/node@22.10.2)(jsdom@25.0.1)(terser@5.36.0):
|
||||
dependencies:
|
||||
esbuild: 0.21.5
|
||||
postcss: 8.4.49
|
||||
rollup: 4.24.4
|
||||
'@vitest/expect': 2.1.4
|
||||
'@vitest/mocker': 2.1.4(vite@5.4.10(@types/node@22.10.2)(terser@5.36.0))
|
||||
'@vitest/pretty-format': 2.1.4
|
||||
'@vitest/runner': 2.1.4
|
||||
'@vitest/snapshot': 2.1.4
|
||||
'@vitest/spy': 2.1.4
|
||||
'@vitest/utils': 2.1.4
|
||||
chai: 5.1.2
|
||||
debug: 4.3.7
|
||||
expect-type: 1.1.0
|
||||
magic-string: 0.30.12
|
||||
pathe: 1.1.2
|
||||
std-env: 3.7.0
|
||||
tinybench: 2.9.0
|
||||
tinyexec: 0.3.1
|
||||
tinypool: 1.0.1
|
||||
tinyrainbow: 1.2.0
|
||||
vite: 5.4.10(@types/node@22.10.2)(terser@5.36.0)
|
||||
vite-node: 2.1.4(@types/node@22.10.2)(terser@5.36.0)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@types/node': 22.8.1
|
||||
fsevents: 2.3.3
|
||||
terser: 5.36.0
|
||||
'@types/node': 22.10.2
|
||||
jsdom: 25.0.1
|
||||
transitivePeerDependencies:
|
||||
- less
|
||||
- lightningcss
|
||||
- msw
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
|
||||
vitest@2.1.4(@types/node@22.8.1):
|
||||
dependencies:
|
||||
@ -7696,42 +7765,6 @@ snapshots:
|
||||
- supports-color
|
||||
- terser
|
||||
|
||||
vitest@2.1.4(@types/node@22.8.1)(jsdom@25.0.1)(terser@5.36.0):
|
||||
dependencies:
|
||||
'@vitest/expect': 2.1.4
|
||||
'@vitest/mocker': 2.1.4(vite@5.4.10(@types/node@22.8.1)(terser@5.36.0))
|
||||
'@vitest/pretty-format': 2.1.4
|
||||
'@vitest/runner': 2.1.4
|
||||
'@vitest/snapshot': 2.1.4
|
||||
'@vitest/spy': 2.1.4
|
||||
'@vitest/utils': 2.1.4
|
||||
chai: 5.1.2
|
||||
debug: 4.3.7
|
||||
expect-type: 1.1.0
|
||||
magic-string: 0.30.12
|
||||
pathe: 1.1.2
|
||||
std-env: 3.7.0
|
||||
tinybench: 2.9.0
|
||||
tinyexec: 0.3.1
|
||||
tinypool: 1.0.1
|
||||
tinyrainbow: 1.2.0
|
||||
vite: 5.4.10(@types/node@22.8.1)(terser@5.36.0)
|
||||
vite-node: 2.1.4(@types/node@22.8.1)(terser@5.36.0)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@types/node': 22.8.1
|
||||
jsdom: 25.0.1
|
||||
transitivePeerDependencies:
|
||||
- less
|
||||
- lightningcss
|
||||
- msw
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
|
||||
void-elements@3.1.0: {}
|
||||
|
||||
vue-flow-layout@0.1.1(vue@3.5.13(typescript@5.6.3)):
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Server } from "@Packages/message/server";
|
||||
|
||||
// offscreen环境的管理器
|
||||
export class Manager {
|
||||
private api: Server = new Server();
|
||||
export class OffscreenManager {
|
||||
private api: Server = new Server("offscreen");
|
||||
|
||||
initManager() {
|
||||
// 监听消息
|
@ -120,7 +120,7 @@ export default class ServiceWorkerManager {
|
||||
});
|
||||
}
|
||||
|
||||
private api: Server = new Server();
|
||||
private api: Server = new Server("service_worker");
|
||||
|
||||
private mq: MessageQueue = new MessageQueue();
|
||||
|
||||
@ -133,6 +133,7 @@ export default class ServiceWorkerManager {
|
||||
initManager() {
|
||||
// 监听消息
|
||||
this.api.on("getInstallInfo", this.getInstallInfo);
|
||||
this.api.on("messageQueue", this.mq.handler());
|
||||
|
||||
this.listenerScriptInstall();
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
import { Connect, Server } from "@Packages/message";
|
||||
import { ExtServer } from "@Packages/message/extension";
|
||||
import { WindowServer } from "@Packages/message/window";
|
||||
import migrate from "./app/migrate";
|
||||
import LoggerCore from "./app/logger/core";
|
||||
import DBWriter from "./app/logger/db_writer";
|
||||
import { LoggerDAO } from "./app/repo/logger";
|
||||
import { OffscreenManager } from "./app/service/offscreen";
|
||||
|
||||
function main() {
|
||||
// 初始化数据库
|
||||
@ -16,23 +14,10 @@ function main() {
|
||||
labels: { env: "offscreen" },
|
||||
});
|
||||
loggerCore.logger().debug("offscreen start");
|
||||
// 与sandbox建立连接
|
||||
const server = new Server(new WindowServer(window));
|
||||
server.on("connection", (con) => {
|
||||
const wrapCon = new Connect(con);
|
||||
wrapCon.on("forward", (data, resp) => {
|
||||
console.log(data);
|
||||
});
|
||||
});
|
||||
// 监听扩展消息
|
||||
const extServer = new Server(new ExtServer());
|
||||
extServer.on("connection", (con) => {
|
||||
const wrapCon = new Connect(con);
|
||||
wrapCon.on("recv", (data, resp) => {
|
||||
console.log(data);
|
||||
resp("service_wwww");
|
||||
});
|
||||
});
|
||||
|
||||
// 初始化管理器
|
||||
const manager = new OffscreenManager();
|
||||
manager.initManager();
|
||||
}
|
||||
|
||||
main();
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Avatar, Button, Grid, Message, Space, Switch, Tag, Tooltip, Typography } from "@arco-design/web-react";
|
||||
import CodeEditor from "../components/CodeEditor";
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Metadata, Script, SCRIPT_STATUS_DISABLE, SCRIPT_STATUS_ENABLE } from "@App/app/repo/scripts";
|
||||
import { Subscribe } from "@App/app/repo/subscribe";
|
||||
import { i18nDescription, i18nName } from "@App/locales/locales";
|
||||
@ -72,6 +72,14 @@ function App() {
|
||||
},
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const url = new URL(window.location.href);
|
||||
const uuid = url.searchParams.get("uuid");
|
||||
if (!uuid) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="h-full">
|
||||
<div className="h-full">
|
||||
|
@ -1,468 +0,0 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import {
|
||||
Avatar,
|
||||
Button,
|
||||
Grid,
|
||||
Message,
|
||||
Space,
|
||||
Switch,
|
||||
Tag,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@arco-design/web-react";
|
||||
import ScriptController from "@App/app/service/script/controller";
|
||||
import {
|
||||
prepareScriptByCode,
|
||||
prepareSubscribeByCode,
|
||||
ScriptInfo,
|
||||
} from "@App/pkg/utils/script";
|
||||
import {
|
||||
Metadata,
|
||||
Script,
|
||||
SCRIPT_STATUS_DISABLE,
|
||||
SCRIPT_STATUS_ENABLE,
|
||||
} from "@App/app/repo/scripts";
|
||||
import { nextTime } from "@App/pkg/utils/utils";
|
||||
import IoC from "@App/app/ioc";
|
||||
import { Subscribe, SUBSCRIBE_STATUS_ENABLE } from "@App/app/repo/subscribe";
|
||||
import SubscribeController from "@App/app/service/subscribe/controller";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { i18nDescription, i18nName } from "@App/locales/locales";
|
||||
import CodeEditor from "../components/CodeEditor";
|
||||
|
||||
type Permission = { label: string; color?: string; value: string[] }[];
|
||||
|
||||
const closeWindow = () => {
|
||||
window.close();
|
||||
};
|
||||
|
||||
export default function Description() {
|
||||
const [permission, setPermission] = useState<Permission>([]);
|
||||
const [metadata, setMetadata] = useState<Metadata>({});
|
||||
// 脚本信息包括脚本代码、下载url,但是不包括解析代码后得到的metadata,通过background的缓存获取
|
||||
const [info, setInfo] = useState<ScriptInfo>();
|
||||
// 对脚本详细的描述
|
||||
const [description, setDescription] = useState<any>();
|
||||
// 是系统检测到脚本更新时打开的窗口会有一个倒计时
|
||||
const [countdown, setCountdown] = useState<number>(-1);
|
||||
// 是否为更新
|
||||
const [isUpdate, setIsUpdate] = useState<boolean>(false);
|
||||
// 脚本信息
|
||||
const [upsertScript, setUpsertScript] = useState<Script | Subscribe>();
|
||||
// 更新的情况下会有老版本的脚本信息
|
||||
const [oldScript, setOldScript] = useState<Script | Subscribe>();
|
||||
// 脚本开启状态
|
||||
const [enable, setEnable] = useState<boolean>(false);
|
||||
const scriptCtrl = IoC.instance(ScriptController) as ScriptController;
|
||||
const subscribeCtrl = IoC.instance(
|
||||
SubscribeController
|
||||
) as SubscribeController;
|
||||
const [isSub, setIsSub] = useState<boolean>(false);
|
||||
// 按钮文案
|
||||
const [btnText, setBtnText] = useState<string>();
|
||||
const { t } = useTranslation();
|
||||
|
||||
// 不推荐的内容标签与描述
|
||||
const antifeatures: {
|
||||
[key: string]: { color: string; title: string; description: string };
|
||||
} = {
|
||||
"referral-link": {
|
||||
color: "purple",
|
||||
title: t("antifeature_referral_link_title"),
|
||||
description: t("antifeature_referral_link_description"),
|
||||
},
|
||||
ads: {
|
||||
color: "orange",
|
||||
title: t("antifeature_ads_title"),
|
||||
description: t("antifeature_ads_description"),
|
||||
},
|
||||
payment: {
|
||||
color: "magenta",
|
||||
title: t("antifeature_payment_title"),
|
||||
description: t("antifeature_payment_description"),
|
||||
},
|
||||
miner: {
|
||||
color: "orangered",
|
||||
title: t("antifeature_miner_title"),
|
||||
description: t("antifeature_miner_description"),
|
||||
},
|
||||
membership: {
|
||||
color: "blue",
|
||||
title: t("antifeature_membership_title"),
|
||||
description: t("antifeature_membership_description"),
|
||||
},
|
||||
tracking: {
|
||||
color: "pinkpurple",
|
||||
title: t("antifeature_tracking_title"),
|
||||
description: t("antifeature_tracking_description"),
|
||||
},
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (isSub) {
|
||||
setBtnText(isUpdate ? t("update_subscribe")! : t("install_subscribe")!);
|
||||
} else {
|
||||
setBtnText(isUpdate ? t("update_script")! : t("install_script")!);
|
||||
}
|
||||
}, [isSub, isUpdate]);
|
||||
useEffect(() => {
|
||||
if (countdown === -1) {
|
||||
return;
|
||||
}
|
||||
setTimeout(() => {
|
||||
setCountdown((time) => {
|
||||
if (time > 0) {
|
||||
return time - 1;
|
||||
}
|
||||
if (time === 0) {
|
||||
closeWindow();
|
||||
}
|
||||
return time;
|
||||
});
|
||||
}, 1000);
|
||||
}, [countdown]);
|
||||
|
||||
const url = new URL(window.location.href);
|
||||
const uuid = url.searchParams.get("uuid");
|
||||
if (!uuid) {
|
||||
return <p>{t("invalid_link")}</p>;
|
||||
}
|
||||
useEffect(() => {
|
||||
scriptCtrl.fetchScriptInfo(uuid).then(async (resp: ScriptInfo) => {
|
||||
if (!resp) {
|
||||
return;
|
||||
}
|
||||
let prepare:
|
||||
| { script: Script; oldScript?: Script }
|
||||
| { subscribe: Subscribe; oldSubscribe?: Subscribe };
|
||||
let action: Script | Subscribe;
|
||||
if (resp.isSubscribe) {
|
||||
setIsSub(true);
|
||||
prepare = await prepareSubscribeByCode(resp.code, resp.url);
|
||||
action = prepare.subscribe;
|
||||
setOldScript(prepare.oldSubscribe);
|
||||
delete prepare.oldSubscribe;
|
||||
} else {
|
||||
if (resp.isUpdate) {
|
||||
prepare = await prepareScriptByCode(resp.code, resp.url, resp.uuid);
|
||||
} else {
|
||||
prepare = await prepareScriptByCode(resp.code, resp.url);
|
||||
}
|
||||
action = prepare.script;
|
||||
setOldScript(prepare.oldScript);
|
||||
delete prepare.oldScript;
|
||||
}
|
||||
setEnable(action.status === SUBSCRIBE_STATUS_ENABLE);
|
||||
if (resp.source === "system") {
|
||||
setCountdown(60);
|
||||
}
|
||||
const meta = action.metadata;
|
||||
if (!meta) {
|
||||
return;
|
||||
}
|
||||
const perm: Permission = [];
|
||||
if (resp.isSubscribe) {
|
||||
perm.push({
|
||||
label: t("subscribe_install_label"),
|
||||
color: "#ff0000",
|
||||
value: meta.scripturl,
|
||||
});
|
||||
}
|
||||
if (meta.match) {
|
||||
perm.push({ label: t("script_runs_in"), value: meta.match });
|
||||
}
|
||||
if (meta.connect) {
|
||||
perm.push({
|
||||
label: t("script_has_full_access_to"),
|
||||
color: "#F9925A",
|
||||
value: meta.connect,
|
||||
});
|
||||
}
|
||||
if (meta.require) {
|
||||
perm.push({ label: t("script_requires"), value: meta.require });
|
||||
}
|
||||
setUpsertScript(action);
|
||||
if (action.id !== 0) {
|
||||
setIsUpdate(true);
|
||||
}
|
||||
setPermission(perm);
|
||||
setMetadata(meta);
|
||||
setInfo(resp);
|
||||
const desList = [];
|
||||
let isCookie = false;
|
||||
metadata.grant?.forEach((val) => {
|
||||
if (val === "GM_cookie") {
|
||||
isCookie = true;
|
||||
}
|
||||
});
|
||||
if (isCookie) {
|
||||
desList.push(
|
||||
<Typography.Text type="error" key="cookie">
|
||||
{t("cookie_warning")}
|
||||
</Typography.Text>
|
||||
);
|
||||
}
|
||||
if (meta.crontab) {
|
||||
desList.push(
|
||||
<Typography.Text key="crontab">
|
||||
{t("scheduled_script_description_1")}
|
||||
</Typography.Text>
|
||||
);
|
||||
desList.push(
|
||||
<Typography.Text key="cronta-nexttime">
|
||||
{t("scheduled_script_description_2", {
|
||||
expression: meta.crontab[0],
|
||||
time: nextTime(meta.crontab[0]),
|
||||
})}
|
||||
</Typography.Text>
|
||||
);
|
||||
} else if (meta.background) {
|
||||
desList.push(
|
||||
<Typography.Text key="background">
|
||||
{t("background_script_description")}
|
||||
</Typography.Text>
|
||||
);
|
||||
}
|
||||
if (desList.length) {
|
||||
setDescription(<div>{desList.map((item) => item)}</div>);
|
||||
}
|
||||
// 修改网页显示title
|
||||
document.title = `${
|
||||
action.id === 0 ? t("install_script") : t("update_script")
|
||||
} - ${meta.name} - ScriptCat`;
|
||||
});
|
||||
}, []);
|
||||
return (
|
||||
<div className="h-full">
|
||||
<Grid.Row gutter={8}>
|
||||
<Grid.Col flex={1} className="flex-col p-8px">
|
||||
<Space direction="vertical">
|
||||
<div>
|
||||
{upsertScript?.metadata.icon && (
|
||||
<Avatar size={32} shape="square" style={{ marginRight: "8px" }}>
|
||||
<img
|
||||
src={upsertScript.metadata.icon[0]}
|
||||
alt={upsertScript?.name}
|
||||
/>
|
||||
</Avatar>
|
||||
)}
|
||||
<Typography.Text bold className="text-size-lg">
|
||||
{upsertScript && i18nName(upsertScript)}
|
||||
<Tooltip
|
||||
content={
|
||||
isSub
|
||||
? t("subscribe_source_tooltip")
|
||||
: t("script_status_tooltip")
|
||||
}
|
||||
>
|
||||
<Switch
|
||||
style={{ marginLeft: "8px" }}
|
||||
checked={enable}
|
||||
onChange={(checked) => {
|
||||
setUpsertScript((script) => {
|
||||
if (!script) {
|
||||
return script;
|
||||
}
|
||||
script.status = checked
|
||||
? SCRIPT_STATUS_ENABLE
|
||||
: SCRIPT_STATUS_DISABLE;
|
||||
setEnable(checked);
|
||||
return script;
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<div>
|
||||
<Typography.Text bold>
|
||||
{upsertScript && i18nDescription(upsertScript)}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<div>
|
||||
<Typography.Text bold>
|
||||
{t("author")}: {metadata.author}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<div>
|
||||
<Typography.Text
|
||||
bold
|
||||
style={{
|
||||
overflowWrap: "break-word",
|
||||
wordBreak: "break-all",
|
||||
maxHeight: "70px",
|
||||
display: "block",
|
||||
overflowY: "auto",
|
||||
}}
|
||||
>
|
||||
{t("source")}: {info?.url}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
<div className="text-end">
|
||||
<Space>
|
||||
<Button
|
||||
type="primary"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
if (!upsertScript) {
|
||||
Message.error(t("script_info_load_failed")!);
|
||||
return;
|
||||
}
|
||||
if (isSub) {
|
||||
subscribeCtrl
|
||||
.upsert(upsertScript as Subscribe)
|
||||
.then(() => {
|
||||
Message.success(t("subscribe_success")!);
|
||||
setBtnText(t("subscribe_success")!);
|
||||
setTimeout(() => {
|
||||
closeWindow();
|
||||
}, 200);
|
||||
})
|
||||
.catch((e) => {
|
||||
Message.error(`${t("subscribe_failed")}: ${e}`);
|
||||
});
|
||||
return;
|
||||
}
|
||||
scriptCtrl
|
||||
.upsert(upsertScript as Script)
|
||||
.then(() => {
|
||||
if (isUpdate) {
|
||||
Message.success(t("install.update_success")!);
|
||||
setBtnText(t("install.update_success")!);
|
||||
} else {
|
||||
Message.success(t("install_success")!);
|
||||
setBtnText(t("install_success")!);
|
||||
}
|
||||
setTimeout(() => {
|
||||
closeWindow();
|
||||
}, 200);
|
||||
})
|
||||
.catch((e) => {
|
||||
Message.error(`${t("install_failed")}: ${e}`);
|
||||
});
|
||||
}}
|
||||
>
|
||||
{btnText}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
status="danger"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
if (countdown === -1) {
|
||||
closeWindow();
|
||||
} else {
|
||||
setCountdown(-1);
|
||||
}
|
||||
}}
|
||||
>
|
||||
{countdown === -1
|
||||
? t("close")
|
||||
: `${t("stop")} (${countdown})`}
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</Space>
|
||||
</Grid.Col>
|
||||
<Grid.Col flex={1} className="p-8px">
|
||||
<Space direction="vertical">
|
||||
<div>
|
||||
<Space>
|
||||
{oldScript && (
|
||||
<Tooltip
|
||||
content={`${t("current_version")}: v${
|
||||
oldScript.metadata.version[0]
|
||||
}`}
|
||||
>
|
||||
<Tag bordered>{oldScript.metadata.version[0]}</Tag>
|
||||
</Tooltip>
|
||||
)}
|
||||
{metadata.version && (
|
||||
<Tooltip
|
||||
color="red"
|
||||
content={`${t("update_version")}: v${metadata.version[0]}`}
|
||||
>
|
||||
<Tag bordered color="red">
|
||||
{metadata.version[0]}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
)}
|
||||
{(metadata.background || metadata.crontab) && (
|
||||
<Tooltip color="green" content={t("background_script_tag")}>
|
||||
<Tag bordered color="green">
|
||||
{t("background_script")}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
)}
|
||||
{metadata.crontab && (
|
||||
<Tooltip color="green" content={t("scheduled_script_tag")}>
|
||||
<Tag bordered color="green">
|
||||
{t("scheduled_script")}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
)}
|
||||
{metadata.antifeature &&
|
||||
metadata.antifeature.map((antifeature) => {
|
||||
const item = antifeature.split(" ")[0];
|
||||
return (
|
||||
antifeatures[item] && (
|
||||
<Tooltip
|
||||
color={antifeatures[item].color}
|
||||
content={antifeatures[item].description}
|
||||
>
|
||||
<Tag bordered color={antifeatures[item].color}>
|
||||
{antifeatures[item].title}
|
||||
</Tag>
|
||||
</Tooltip>
|
||||
)
|
||||
);
|
||||
})}
|
||||
</Space>
|
||||
</div>
|
||||
{description && description}
|
||||
<div>
|
||||
<Typography.Text type="error">
|
||||
{t("install_from_legitimate_sources_warning")}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
</Space>
|
||||
</Grid.Col>
|
||||
<Grid.Col span={24}>
|
||||
<Grid.Row>
|
||||
{permission.map((item) => (
|
||||
<Grid.Col
|
||||
key={item.label}
|
||||
span={8}
|
||||
style={{
|
||||
maxHeight: "200px",
|
||||
overflowY: "auto",
|
||||
overflowX: "auto",
|
||||
boxSizing: "border-box",
|
||||
}}
|
||||
className="p-8px"
|
||||
>
|
||||
<Typography.Text bold color={item.color}>
|
||||
{item.label}
|
||||
</Typography.Text>
|
||||
{item.value.map((v) => (
|
||||
<div key={v}>
|
||||
<Typography.Text
|
||||
style={{ wordBreak: "unset", color: item.color }}
|
||||
>
|
||||
{v}
|
||||
</Typography.Text>
|
||||
</div>
|
||||
))}
|
||||
</Grid.Col>
|
||||
))}
|
||||
</Grid.Row>
|
||||
</Grid.Col>
|
||||
</Grid.Row>
|
||||
<CodeEditor
|
||||
id="show-code"
|
||||
code={upsertScript?.code || undefined}
|
||||
diffCode={oldScript?.code || ""}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -1,11 +1,3 @@
|
||||
import { Connect } from "@Packages/message";
|
||||
import { windowConnect } from "@Packages/message/window";
|
||||
|
||||
function main() {
|
||||
const client = new Connect(windowConnect(window, window.parent));
|
||||
client.emit("recv", "123", (resp: string) => {
|
||||
console.log("sandbox", resp);
|
||||
});
|
||||
}
|
||||
function main() {}
|
||||
|
||||
main();
|
||||
|
Loading…
x
Reference in New Issue
Block a user