@joystick.js/cli-canary 0.0.0-canary.610 → 0.0.0-canary.611
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 i}from"ws";import N from"../generate_id.js";import g 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(
|
|
1
|
+
import _ from"query-string";import{WebSocketServer as i}from"ws";import N from"../generate_id.js";import g 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);console.log("LENGTH",o?.length);for(let n=0;n<o?.length;n+=1){console.log("SEND TO",o[n],n);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 g("./.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=N(16),[s,a]=o?.url?.split("?"),t=_.parse(a);console.log("ADD CONNECTION",n),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],console.log("DELETE CONNECTION",n),Object.keys(process.HMR_CONNECTIONS||{})?.length===0&&process.send({type:"HAS_NO_HMR_CONNECTIONS"}))})})})();export{u as default};
|
package/package.json
CHANGED
|
@@ -22,10 +22,13 @@ export default (() => {
|
|
|
22
22
|
|
|
23
23
|
if (typeof process.HMR_CONNECTIONS === "object" && !!parsed_message?.type) {
|
|
24
24
|
const connections = Object.values(process.HMR_CONNECTIONS);
|
|
25
|
+
|
|
26
|
+
console.log('LENGTH', connections?.length);
|
|
27
|
+
|
|
25
28
|
for (let i = 0; i < connections?.length; i += 1) {
|
|
29
|
+
console.log('SEND TO', connections[i], i);
|
|
26
30
|
const connection = connections[i];
|
|
27
31
|
|
|
28
|
-
console.log('SEND TO', connection);
|
|
29
32
|
|
|
30
33
|
if (connection?.connection?.send) {
|
|
31
34
|
if (parsed_message?.type === 'BUILD_ERROR') {
|