@joystick.js/cli-canary 0.0.0-canary.606 → 0.0.0-canary.608

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 p 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 E=(()=>{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(typeof process.HMR_CONNECTIONS=="object"&&e?.type){const t=Object.values(process.HMR_CONNECTIONS);for(let n=0;n<t?.length;n+=1){const s=t[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,t={}){const n=g(16),[s,a]=t?.url?.split("?"),o=p.parse(a);process.HMR_CONNECTIONS={...process.HMR_CONNECTIONS||{},[n]:{connection:e,browser_language:o?.browser_language,user_language:o?.user_language,page_component_path:o?.page_component_path}},console.log(process.HMR_CONNECTIONS),Object.keys(process.HMR_CONNECTIONS||{})?.length>0&&process.send({type:"HAS_HMR_CONNECTIONS"}),e.on("message",_=>{JSON.parse(_)?.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{E as default};
1
+ import r from"query-string";import{WebSocketServer as p}from"ws";import l from"../generate_id.js";import a from"./get_translations.js";process.title="joystick_hmr";var C=(()=>{const i=new p({port:parseInt(process.env.PORT,10)+1,path:"/_joystick/hmr"});process.on("message",async o=>{const e=JSON.parse(o);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 t=Object.values(process.HMR_CONNECTIONS);for(let s=0;s<t?.length;s+=1){const n=t[s];if(n?.connection?.send){if(e?.type==="BUILD_ERROR")return n.connection.send(JSON.stringify({type:"BUILD_ERROR"}));if(e?.type==="FILE_CHANGE")return console.log("SENDING...",JSON.stringify({type:"FILE_CHANGE",settings:e?.settings?{global:e?.settings?.global,public:e?.settings?.public}:null,i18n:e?.i18n_change?await a("./.joystick/build",n?.page_component_path,{headers:{"accept-language":n?.browser_language},context:{user:{language:n?.user_language}}}):null,index_html_changed:e?.index_html_change,index_css_changed:e?.index_css_change,index_client_changed:e?.index_client_change})),n.connection.send(JSON.stringify({type:"FILE_CHANGE",settings:e?.settings?{global:e?.settings?.global,public:e?.settings?.public}:null,i18n:e?.i18n_change?await a("./.joystick/build",n?.page_component_path,{headers:{"accept-language":n?.browser_language},context:{user:{language:n?.user_language}}}):null,index_html_changed:e?.index_html_change,index_css_changed:e?.index_css_change,index_client_changed:e?.index_client_change}))}}}}),i.on("connection",function(e,t={}){const s=l(16),[n,_]=t?.url?.split("?"),c=r.parse(_);process.HMR_CONNECTIONS={...process.HMR_CONNECTIONS||{},[s]:{connection:e,browser_language:c?.browser_language,user_language:c?.user_language,page_component_path:c?.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",g=>{JSON.parse(g)?.type==="HMR_UPDATE_COMPLETE"&&process.send({type:"HMR_UPDATE_COMPLETE"})}),e.on("close",()=>{process.HMR_CONNECTIONS[s]&&(delete process.HMR_CONNECTIONS[s],Object.keys(process.HMR_CONNECTIONS||{})?.length===0&&process.send({type:"HAS_NO_HMR_CONNECTIONS"}))})})})();export{C as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/cli-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.606",
4
+ "version": "0.0.0-canary.608",
5
5
  "description": "The CLI for Joystick.",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -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);
@@ -26,6 +31,27 @@ export default (() => {
26
31
  }
27
32
 
28
33
  if (parsed_message?.type === 'FILE_CHANGE') {
34
+ console.log('SENDING...', JSON.stringify({
35
+ type: "FILE_CHANGE",
36
+ settings: parsed_message?.settings ? {
37
+ global: parsed_message?.settings?.global,
38
+ public: parsed_message?.settings?.public,
39
+ } : null,
40
+ i18n: parsed_message?.i18n_change ? await get_translations('./.joystick/build', connection?.page_component_path, {
41
+ headers: {
42
+ 'accept-language': connection?.browser_language,
43
+ },
44
+ context: {
45
+ user: {
46
+ language: connection?.user_language,
47
+ },
48
+ }
49
+ }) : null,
50
+ index_html_changed: parsed_message?.index_html_change,
51
+ index_css_changed: parsed_message?.index_css_change,
52
+ index_client_changed: parsed_message?.index_client_change,
53
+ }));
54
+
29
55
  return connection.connection.send(
30
56
  JSON.stringify({
31
57
  type: "FILE_CHANGE",
@@ -69,7 +95,7 @@ export default (() => {
69
95
  },
70
96
  };
71
97
 
72
- console.log(process.HMR_CONNECTIONS);
98
+ console.log('connection callback', process.HMR_CONNECTIONS);
73
99
 
74
100
  if (Object.keys(process.HMR_CONNECTIONS || {})?.length > 0) {
75
101
  process.send({ type: "HAS_HMR_CONNECTIONS" });