-
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: improve CSUI overlay repositioning * feat: add cs reload on config change * keep backend code from frontend runtime * chore: default minifier to es2016 for backward compat * fix build broadcast
- Loading branch information
Showing
18 changed files
with
145 additions
and
56 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
19 changes: 0 additions & 19 deletions
19
cli/plasmo/src/features/extension-devtools/build-socket.ts
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum BuildSocketEvent { | ||
BuildReady = "build_ready", | ||
CsChanged = "cs_changed" | ||
} |
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 @@ | ||
import { WebSocket, WebSocketServer } from "ws" | ||
|
||
import { BuildSocketEvent } from "./event" | ||
|
||
export { BuildSocketEvent } | ||
|
||
const createBuildSocket = (hmrPort: number) => { | ||
const wss = new WebSocketServer({ port: hmrPort + 1 }) | ||
|
||
const broadcast = (type: BuildSocketEvent) => { | ||
for (const client of wss.clients) { | ||
if (client.readyState === WebSocket.OPEN) { | ||
client.send(JSON.stringify({ type })) | ||
} | ||
} | ||
} | ||
|
||
return { | ||
broadcast | ||
} | ||
} | ||
|
||
let _buildSocket: Awaited<ReturnType<typeof createBuildSocket>> | ||
|
||
export const getBuildSocket = (hmrPort?: number) => { | ||
if (process.env.NODE_ENV === "production") { | ||
return null | ||
} | ||
|
||
if (!!_buildSocket) { | ||
return _buildSocket | ||
} | ||
|
||
if (!hmrPort) { | ||
throw new Error("HMR port is not provided") | ||
} | ||
|
||
_buildSocket = createBuildSocket(hmrPort) | ||
return _buildSocket | ||
} | ||
|
||
export const buildBroadcast = (type: BuildSocketEvent) => { | ||
if (process.env.NODE_ENV === "production") { | ||
return | ||
} | ||
|
||
const buildSocket = getBuildSocket() | ||
if (buildSocket) { | ||
buildSocket.broadcast(type) | ||
} | ||
} |
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,15 @@ | ||
{ | ||
"name": "@plasmo/framework-shared", | ||
"private": true, | ||
"license": "MIT", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"dependencies": { | ||
"ws": "8.13.0" | ||
}, | ||
"devDependencies": { | ||
"@plasmo/config": "workspace:*", | ||
"@plasmo/utils": "workspace:*" | ||
} | ||
} |
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,5 @@ | ||
{ | ||
"extends": "@plasmo/config/ts/utils", | ||
"include": ["./**/*.ts"], | ||
"exclude": ["node_modules"] | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.