@joystick.js/cli-canary 0.0.0-canary.611 → 0.0.0-canary.612

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);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};
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 u=(()=>{const a=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];s?.connection?.send&&(e?.type==="BUILD_ERROR"&&s.connection.send(JSON.stringify({type:"BUILD_ERROR"})),e?.type==="FILE_CHANGE"&&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})))}}}),a.on("connection",function(e,t={}){const n=g(16),[s,r]=t?.url?.split("?"),o=p.parse(r);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}},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{u 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.611",
4
+ "version": "0.0.0-canary.612",
5
5
  "description": "The CLI for Joystick.",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -14,29 +14,19 @@ 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
- });
22
-
23
17
  if (typeof process.HMR_CONNECTIONS === "object" && !!parsed_message?.type) {
24
18
  const connections = Object.values(process.HMR_CONNECTIONS);
25
19
 
26
- console.log('LENGTH', connections?.length);
27
-
28
20
  for (let i = 0; i < connections?.length; i += 1) {
29
- console.log('SEND TO', connections[i], i);
30
21
  const connection = connections[i];
31
22
 
32
-
33
23
  if (connection?.connection?.send) {
34
24
  if (parsed_message?.type === 'BUILD_ERROR') {
35
- return connection.connection.send(JSON.stringify({ type: 'BUILD_ERROR' }));
25
+ connection.connection.send(JSON.stringify({ type: 'BUILD_ERROR' }));
36
26
  }
37
27
 
38
28
  if (parsed_message?.type === 'FILE_CHANGE') {
39
- return connection.connection.send(
29
+ connection.connection.send(
40
30
  JSON.stringify({
41
31
  type: "FILE_CHANGE",
42
32
  settings: parsed_message?.settings ? {
@@ -69,8 +59,6 @@ export default (() => {
69
59
  const [_path, params] = connection_request?.url?.split("?");
70
60
  const connection_params = queryString.parse(params);
71
61
 
72
- console.log('ADD CONNECTION', connection_id);
73
-
74
62
  process.HMR_CONNECTIONS = {
75
63
  ...(process.HMR_CONNECTIONS || {}),
76
64
  [connection_id]: {
@@ -81,8 +69,6 @@ export default (() => {
81
69
  },
82
70
  };
83
71
 
84
- console.log('connection callback', process.HMR_CONNECTIONS);
85
-
86
72
  if (Object.keys(process.HMR_CONNECTIONS || {})?.length > 0) {
87
73
  process.send({ type: "HAS_HMR_CONNECTIONS" });
88
74
  }
@@ -99,8 +85,6 @@ export default (() => {
99
85
  if (process.HMR_CONNECTIONS[connection_id]) {
100
86
  delete process.HMR_CONNECTIONS[connection_id];
101
87
 
102
- console.log('DELETE CONNECTION', connection_id);
103
-
104
88
  if (Object.keys(process.HMR_CONNECTIONS || {})?.length === 0) {
105
89
  process.send({ type: "HAS_NO_HMR_CONNECTIONS" });
106
90
  }