forked from liriliri/chii
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
113 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ elements.patch | |
network.patch | ||
application.patch | ||
sources.patch | ||
embedded.patch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: redhoodsu <[email protected]> | ||
Date: Sun, 17 Jul 2022 12:28:39 +0800 | ||
Subject: embedded | ||
|
||
|
||
diff --git a/front_end/core/sdk/Connections.ts b/front_end/core/sdk/Connections.ts | ||
index cfa1ca58f1d45d5034731cae037e91364be9de6e..619ae8cc56e2274a3fbd9b159a669333c37ba9f2 100644 | ||
--- a/front_end/core/sdk/Connections.ts | ||
+++ b/front_end/core/sdk/Connections.ts | ||
@@ -75,6 +75,29 @@ export class MainConnection implements ProtocolClient.InspectorBackend.Connectio | ||
} | ||
} | ||
|
||
+export class EmbeddedConnection implements ProtocolClient.InspectorBackend.Connection { | ||
+ onMessage: ((arg0: Object) => void) | null; | ||
+ constructor() { | ||
+ this.onMessage = null; | ||
+ window.addEventListener('message', event => { | ||
+ if (this.onMessage) { | ||
+ this.onMessage(event.data); | ||
+ } | ||
+ }) | ||
+ } | ||
+ setOnMessage(onMessage: (arg0: (Object|string)) => void): void { | ||
+ this.onMessage = onMessage; | ||
+ } | ||
+ sendRawMessage(message: string): void { | ||
+ window.parent.postMessage(message); | ||
+ } | ||
+ setOnDisconnect(onDisconnect: (arg0: string) => void): void { | ||
+ } | ||
+ disconnect(): Promise<void> { | ||
+ return Promise.resolve(); | ||
+ } | ||
+} | ||
+ | ||
export class WebSocketConnection implements ProtocolClient.InspectorBackend.Connection { | ||
#socket: WebSocket|null; | ||
onMessage: ((arg0: (Object|string)) => void)|null; | ||
@@ -280,6 +303,10 @@ export async function initMainConnection( | ||
function createMainConnection(websocketConnectionLost: () => void): ProtocolClient.InspectorBackend.Connection { | ||
const wsParam = Root.Runtime.Runtime.queryParam('ws'); | ||
const wssParam = Root.Runtime.Runtime.queryParam('wss'); | ||
+ const embeddedParam = Root.Runtime.Runtime.queryParam('embedded'); | ||
+ if (embeddedParam === 'true') { | ||
+ return new EmbeddedConnection() | ||
+ } | ||
if (wsParam || wssParam) { | ||
const ws = wsParam ? `ws://${wsParam}` : `wss://${wssParam}`; | ||
return new WebSocketConnection(ws, websocketConnectionLost); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters