You've already forked bilibili-subtitle
fix
This commit is contained in:
@@ -28,7 +28,6 @@
|
|||||||
"less": "^4.1.3",
|
"less": "^4.1.3",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"pako": "^2.1.0",
|
"pako": "^2.1.0",
|
||||||
"postmessage-promise": "^3.2.1",
|
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@@ -53,9 +53,6 @@ importers:
|
|||||||
pako:
|
pako:
|
||||||
specifier: ^2.1.0
|
specifier: ^2.1.0
|
||||||
version: 2.1.0
|
version: 2.1.0
|
||||||
postmessage-promise:
|
|
||||||
specifier: ^3.2.1
|
|
||||||
version: 3.2.1
|
|
||||||
qs:
|
qs:
|
||||||
specifier: ^6.11.0
|
specifier: ^6.11.0
|
||||||
version: 6.11.0
|
version: 6.11.0
|
||||||
@@ -2008,9 +2005,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-h+pbPsyhlYj6N2ozBmHhHrs9DzGmbaarbLvWipMRO7RLS+v4onj26MPFXA5OBYFxyqYhUJK456SwDcY9H2/zsA==}
|
resolution: {integrity: sha512-h+pbPsyhlYj6N2ozBmHhHrs9DzGmbaarbLvWipMRO7RLS+v4onj26MPFXA5OBYFxyqYhUJK456SwDcY9H2/zsA==}
|
||||||
engines: {node: ^10 || ^12 || >=14}
|
engines: {node: ^10 || ^12 || >=14}
|
||||||
|
|
||||||
postmessage-promise@3.2.1:
|
|
||||||
resolution: {integrity: sha512-cSs5eg+DvBQIdIQK9Cimd1wB2eb85xlzJXkJwm6jYNcTlsiwTFXvdyF/69JFozX6vIkdYz2Jv31W+BvSKQXNVg==}
|
|
||||||
|
|
||||||
prelude-ls@1.2.1:
|
prelude-ls@1.2.1:
|
||||||
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
|
||||||
engines: {node: '>= 0.8.0'}
|
engines: {node: '>= 0.8.0'}
|
||||||
@@ -4668,10 +4662,6 @@ snapshots:
|
|||||||
picocolors: 1.0.0
|
picocolors: 1.0.0
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
|
|
||||||
postmessage-promise@3.2.1:
|
|
||||||
dependencies:
|
|
||||||
'@babel/runtime': 7.19.0
|
|
||||||
|
|
||||||
prelude-ls@1.2.1: {}
|
prelude-ls@1.2.1: {}
|
||||||
|
|
||||||
prop-types@15.8.1:
|
prop-types@15.8.1:
|
||||||
|
@@ -71,7 +71,7 @@ class ExtensionMessage {
|
|||||||
const id = crypto.randomUUID()
|
const id = crypto.randomUUID()
|
||||||
const name = port.name
|
const name = port.name
|
||||||
const portMessageHandler = new Layer1Protocol<MessageData, MessageResult>(async (value: MessageData) => {
|
const portMessageHandler = new Layer1Protocol<MessageData, MessageResult>(async (value: MessageData) => {
|
||||||
// 初始化
|
// 初始化消息
|
||||||
if (value.method === '_init') {
|
if (value.method === '_init') {
|
||||||
const type = value.params.type
|
const type = value.params.type
|
||||||
let tabId = value.params.tabId
|
let tabId = value.params.tabId
|
||||||
@@ -95,6 +95,7 @@ class ExtensionMessage {
|
|||||||
} as MessageResult
|
} as MessageResult
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 处理消息
|
||||||
return handler(value, portContext)
|
return handler(value, portContext)
|
||||||
}, port)
|
}, port)
|
||||||
const portContext: PortContext = {id, name, port, portMessageHandler, ready: false}
|
const portContext: PortContext = {id, name, port, portMessageHandler, ready: false}
|
||||||
|
@@ -8,15 +8,11 @@ class InjectMessage {
|
|||||||
methods?: {
|
methods?: {
|
||||||
[key: string]: (params: any, context: MethodContext) => Promise<any>
|
[key: string]: (params: any, context: MethodContext) => Promise<any>
|
||||||
}
|
}
|
||||||
// postMessageToApp?: (method: string, payload: PostMessagePayload) => Promise<PostMessageResponse>
|
|
||||||
|
|
||||||
debug = (...args: any[]) => {
|
debug = (...args: any[]) => {
|
||||||
console.debug('[Inject Messaging]', ...args)
|
console.debug('[Inject Messaging]', ...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param sendResponse No matter what is returned, this method will definitely be called.
|
|
||||||
*/
|
|
||||||
messageHandler = async (event: MessageData): Promise<MessageResult> => {
|
messageHandler = async (event: MessageData): Promise<MessageResult> => {
|
||||||
this.debug(`${event.from} => `, JSON.stringify(event))
|
this.debug(`${event.from} => `, JSON.stringify(event))
|
||||||
|
|
||||||
|
@@ -30,13 +30,6 @@ class Layer1Protocol<L1Req = any, L1Res = any> {
|
|||||||
this.handler = handler
|
this.handler = handler
|
||||||
}
|
}
|
||||||
|
|
||||||
// init(type: 'inject' | 'app', tabId?: number) {
|
|
||||||
// this.port.postMessage({
|
|
||||||
// type,
|
|
||||||
// tabId,
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
|
|
||||||
startListen() {
|
startListen() {
|
||||||
// 持久监听 port.onMessage
|
// 持久监听 port.onMessage
|
||||||
this.port.onMessage.addListener((msg: ReqMsg<L1Req, L1Res>) => {
|
this.port.onMessage.addListener((msg: ReqMsg<L1Req, L1Res>) => {
|
||||||
|
Reference in New Issue
Block a user