@joystick.js/cli-canary 0.0.0-canary.605 → 0.0.0-canary.607
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import _ from"query-string";import{WebSocketServer as
|
|
1
|
+
import _ from"query-string";import{WebSocketServer as i}from"ws";import g from"../generate_id.js";import N from"./get_translations.js";process.title="joystick_hmr";var u=(()=>{const r=new i({port:parseInt(process.env.PORT,10)+1,path:"/_joystick/hmr"});process.on("message",async c=>{const e=JSON.parse(c);if(console.log("message callback",{connections:process.HMR_CONNECTIONS,connections_type:typeof process.HMR_CONNECTIONS,parsed_message:e}),typeof process.HMR_CONNECTIONS=="object"&&e?.type){const o=Object.values(process.HMR_CONNECTIONS);for(let n=0;n<o?.length;n+=1){const s=o[n];if(s?.connection?.send){if(e?.type==="BUILD_ERROR")return s.connection.send(JSON.stringify({type:"BUILD_ERROR"}));if(e?.type==="FILE_CHANGE")return s.connection.send(JSON.stringify({type:"FILE_CHANGE",settings:e?.settings?{global:e?.settings?.global,public:e?.settings?.public}:null,i18n:e?.i18n_change?await N("./.joystick/build",s?.page_component_path,{headers:{"accept-language":s?.browser_language},context:{user:{language:s?.user_language}}}):null,index_html_changed:e?.index_html_change,index_css_changed:e?.index_css_change,index_client_changed:e?.index_client_change}))}}}}),r.on("connection",function(e,o={}){const n=g(16),[s,a]=o?.url?.split("?"),t=_.parse(a);process.HMR_CONNECTIONS={...process.HMR_CONNECTIONS||{},[n]:{connection:e,browser_language:t?.browser_language,user_language:t?.user_language,page_component_path:t?.page_component_path}},console.log("connection callback",process.HMR_CONNECTIONS),Object.keys(process.HMR_CONNECTIONS||{})?.length>0&&process.send({type:"HAS_HMR_CONNECTIONS"}),e.on("message",p=>{JSON.parse(p)?.type==="HMR_UPDATE_COMPLETE"&&process.send({type:"HMR_UPDATE_COMPLETE"})}),e.on("close",()=>{process.HMR_CONNECTIONS[n]&&(delete process.HMR_CONNECTIONS[n],Object.keys(process.HMR_CONNECTIONS||{})?.length===0&&process.send({type:"HAS_NO_HMR_CONNECTIONS"}))})})})();export{u as default};
|
package/package.json
CHANGED
|
@@ -14,6 +14,11 @@ export default (() => {
|
|
|
14
14
|
process.on("message", async (message) => {
|
|
15
15
|
const parsed_message = JSON.parse(message);
|
|
16
16
|
|
|
17
|
+
console.log('message callback', {
|
|
18
|
+
connections: process.HMR_CONNECTIONS,
|
|
19
|
+
connections_type: typeof process.HMR_CONNECTIONS,
|
|
20
|
+
parsed_message,
|
|
21
|
+
});
|
|
17
22
|
|
|
18
23
|
if (typeof process.HMR_CONNECTIONS === "object" && !!parsed_message?.type) {
|
|
19
24
|
const connections = Object.values(process.HMR_CONNECTIONS);
|
|
@@ -66,10 +71,11 @@ export default (() => {
|
|
|
66
71
|
browser_language: connection_params?.browser_language,
|
|
67
72
|
user_language: connection_params?.user_language,
|
|
68
73
|
page_component_path: connection_params?.page_component_path,
|
|
69
|
-
watchlist: [],
|
|
70
74
|
},
|
|
71
75
|
};
|
|
72
76
|
|
|
77
|
+
console.log('connection callback', process.HMR_CONNECTIONS);
|
|
78
|
+
|
|
73
79
|
if (Object.keys(process.HMR_CONNECTIONS || {})?.length > 0) {
|
|
74
80
|
process.send({ type: "HAS_HMR_CONNECTIONS" });
|
|
75
81
|
}
|
|
@@ -80,12 +86,6 @@ export default (() => {
|
|
|
80
86
|
if (parsed_message?.type === "HMR_UPDATE_COMPLETE") {
|
|
81
87
|
process.send({ type: "HMR_UPDATE_COMPLETE" });
|
|
82
88
|
}
|
|
83
|
-
|
|
84
|
-
if (parsed_message?.type === "HMR_WATCHLIST") {
|
|
85
|
-
process.HMR_CONNECTIONS[connection_id]?.watchlist?.push(
|
|
86
|
-
...(parsed_message?.tags || [])
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
websocket_connection.on("close", () => {
|