@joystick.js/cli-canary 0.0.0-canary.603 → 0.0.0-canary.605

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 g}from"ws";import l from"../generate_id.js";import N from"./get_translations.js";process.title="joystick_hmr";var R=(()=>{const a=new g({port:parseInt(process.env.PORT,10)+1,path:"/_joystick/hmr"});process.on("message",async r=>{const e=JSON.parse(r);if(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(console.log({parsed_message:e}),e?.type==="BUILD_ERROR")return console.log("SEND BUILD ERROR"),n.connection.send(JSON.stringify({type:"BUILD_ERROR"}));if(e?.type==="FILE_CHANGE")return console.log("SEND FILE 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 N("./.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}))}}}}),a.on("connection",function(e,t={}){const s=l(16),[n,i]=t?.url?.split("?"),o=_.parse(i);process.HMR_CONNECTIONS={...process.HMR_CONNECTIONS||{},[s]:{connection:e,browser_language:o?.browser_language,user_language:o?.user_language,page_component_path:o?.page_component_path,watchlist:[]}},Object.keys(process.HMR_CONNECTIONS||{})?.length>0&&process.send({type:"HAS_HMR_CONNECTIONS"}),e.on("message",p=>{const c=JSON.parse(p);c?.type==="HMR_UPDATE_COMPLETE"&&process.send({type:"HMR_UPDATE_COMPLETE"}),c?.type==="HMR_WATCHLIST"&&process.HMR_CONNECTIONS[s]?.watchlist?.push(...c?.tags||[])}),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{R as default};
1
+ import _ from"query-string";import{WebSocketServer as g}from"ws";import N from"../generate_id.js";import l from"./get_translations.js";process.title="joystick_hmr";var h=(()=>{const a=new g({port:parseInt(process.env.PORT,10)+1,path:"/_joystick/hmr"});process.on("message",async r=>{const e=JSON.parse(r);if(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 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 l("./.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}))}}}}),a.on("connection",function(e,t={}){const s=N(16),[n,i]=t?.url?.split("?"),o=_.parse(i);process.HMR_CONNECTIONS={...process.HMR_CONNECTIONS||{},[s]:{connection:e,browser_language:o?.browser_language,user_language:o?.user_language,page_component_path:o?.page_component_path,watchlist:[]}},Object.keys(process.HMR_CONNECTIONS||{})?.length>0&&process.send({type:"HAS_HMR_CONNECTIONS"}),e.on("message",p=>{const c=JSON.parse(p);c?.type==="HMR_UPDATE_COMPLETE"&&process.send({type:"HMR_UPDATE_COMPLETE"}),c?.type==="HMR_WATCHLIST"&&process.HMR_CONNECTIONS[s]?.watchlist?.push(...c?.tags||[])}),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{h as default};
@@ -1 +1 @@
1
- import d from"chokidar";import f from"fs";import{dirname as h}from"path";import m from"../../build/build_files.js";import y from"../../debounce.js";import _ from"./get_after_run_tasks.js";import g from"./get_file_codependencies.js";import o from"../../build/get_file_operation.js";import k from"../../build/get_path_platform.js";import v from"../../types.js";import w from"./watch_paths.js";const{mkdir:l,copyFile:R,rm:p}=f.promises,n=async(e={},i={})=>{const r=process.initial_build_complete?await g(e?.path):[];if(i?.is_build_file&&await m({files:[{path:e?.path,platform:k(e?.path)}]}).catch((t=[])=>{if(!process.initial_build_complete&&t?.length>0&&process.exit(0),process.initial_build_complete&&t?.length>0)throw process.app_server_process.send(JSON.stringify({type:"BUILD_ERROR",paths:t.filter(({success:a})=>!a)})),process.hmr_server_process.send(JSON.stringify({type:"BUILD_ERROR"})),new Error("BUILD_ERROR")}),r?.length>0)for(let t=0;t<r?.length;t+=1){const a=r[t];return n({path:a},i)}return Promise.resolve()},b=async(e={})=>{switch(e?.operation){case"add_directory":return l(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return n(e,{is_build_file:!0});case"copy_file":return await l(h(`.joystick/build/${e?.path}`),{recursive:!0}),await R(e?.path,`.joystick/build/${e?.path}`),n(e,{is_build_file:!1});case"delete_directory":return p(`.joystick/build/${e?.path}`,{recursive:!0});case"delete_file":return await p(`.joystick/build/${e?.path}`,{recursive:!0}),n(e,{is_build_file:!1});default:return!0}},D=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:o(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),B=(e={})=>({operation:o(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?_(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>{switch(e?.event){case"add_file":return B(e);case"change_file":return E(e);case"delete_file":return $(e);case"add_directory":return O(e);case"delete_directory":return D(e)}},L=async(e=[],i={})=>{try{const r=new Set([]);for(let t=0;t<e?.length;t+=1){const a=e[t],s=I(a);if(await b(s),s?.after_run_tasks)for(let c=0;c<s?.after_run_tasks?.length;c+=1){const u=s?.after_run_tasks[c];r.add(u)}}setTimeout(async()=>{const t=Array.from(r);for(let a=0;a<t?.length;a+=1){const s=t[a];v.is_function(i[s])&&await i[s](e)}},300)}catch{}},S=(e="")=>{switch(e){case"add":return"add_file";case"change":return"change_file";case"unlink":return"delete_file";case"addDir":return"add_directory";case"unlinkDir":return"delete_directory"}},U=(e={})=>{const i=d.watch(w.map(({path:t})=>t),{ignored:".joystick"});let r=[];process.initial_build_complete=!1,i.on("error",t=>console.error(t)),i.on("all",(t,a)=>{r.push({event:S(t),path:a}),y(async()=>{await L(r,e),process.initial_build_complete=!0,r=[]},100)})};var H=U;export{H as default};
1
+ import f from"chokidar";import h from"fs";import{dirname as m}from"path";import y from"../../build/build_files.js";import g from"../../debounce.js";import s from"./get_after_run_tasks.js";import k from"./get_file_codependencies.js";import l from"../../build/get_file_operation.js";import v from"../../build/get_path_platform.js";import w from"../../types.js";import R from"./watch_paths.js";const{mkdir:p,copyFile:b,rm:d}=h.promises,c=async(e={},i={})=>{const a=process.initial_build_complete?await k(e?.path):[];if(i?.is_build_file&&await y({files:[{path:e?.path,platform:v(e?.path)}]}).catch((t=[])=>{if(!process.initial_build_complete&&t?.length>0&&process.exit(0),process.initial_build_complete&&t?.length>0)throw process.app_server_process.send(JSON.stringify({type:"BUILD_ERROR",paths:t.filter(({success:r})=>!r)})),process.hmr_server_process.send(JSON.stringify({type:"BUILD_ERROR"})),new Error("BUILD_ERROR")}),a?.length>0)for(let t=0;t<a?.length;t+=1){const r=a[t];return c({path:r},i)}return Promise.resolve()},D=async(e={})=>{switch(e?.operation){case"add_directory":return p(`.joystick/build/${e?.path}`,{recursive:!0});case"build_file":return c(e,{is_build_file:!0});case"copy_file":return await p(m(`.joystick/build/${e?.path}`),{recursive:!0}),await b(e?.path,`.joystick/build/${e?.path}`),c(e,{is_build_file:!1});case"delete_directory":return d(`.joystick/build/${e?.path}`,{recursive:!0});case"delete_file":return await d(`.joystick/build/${e?.path}`,{recursive:!0}),c(e,{is_build_file:!1});default:return!0}},O=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),$=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),E=(e={})=>({operation:e?.event,path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),B=(e={})=>({operation:l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),I=(e={})=>({operation:l(e?.path),path:e?.path,after_run_tasks:process.initial_build_complete?s(e?.path):["start_app_server","start_hmr_server"]}),L=(e={})=>{switch(e?.event){case"add_file":return I(e);case"change_file":return B(e);case"delete_file":return E(e);case"add_directory":return $(e);case"delete_directory":return O(e)}},S=async(e=[],i={})=>{try{const a=new Set([]);for(let r=0;r<e?.length;r+=1){const _=e[r],n=L(_);if(await D(n),n?.after_run_tasks)for(let o=0;o<n?.after_run_tasks?.length;o+=1){const u=n?.after_run_tasks[o];a.add(u)}}const t=Array.from(a);for(let r=0;r<t?.length;r+=1){const _=t[r];w.is_function(i[_])&&await i[_](e)}}catch{}},U=(e="")=>{switch(e){case"add":return"add_file";case"change":return"change_file";case"unlink":return"delete_file";case"addDir":return"add_directory";case"unlinkDir":return"delete_directory"}},x=(e={})=>{const i=f.watch(R.map(({path:t})=>t),{ignored:".joystick"});let a=[];process.initial_build_complete=!1,i.on("error",t=>console.error(t)),i.on("all",(t,r)=>{a.push({event:U(t),path:r}),g(async()=>{await S(a,e),process.initial_build_complete=!0,a=[]},100)})};var M=x;export{M as default};
@@ -1 +1 @@
1
- import e from"./get_platform_safe_path.js";var o=[e("api/"),e("cronJobs/"),e("cron_jobs/"),e("fixtures/"),e("lib/node"),e("queues/"),e("routes/"),e("tests/"),e("uploaders/"),e("websockets/"),"index.server.js"];export{o as default};
1
+ import e from"./get_platform_safe_path.js";var o=[e("api/"),e("cronJobs/"),e("cron_jobs/"),e("fixtures/"),e("indexes/"),e("lib/node"),e("queues/"),e("routes/"),e("tests/"),e("uploaders/"),e("websockets/"),"index.server.js"];export{o as default};
@@ -1 +1 @@
1
- import t from"../../build/copy_paths.js";const a=[{path:"api"},{path:"cronJobs"},{path:"cron_jobs"},{path:"email"},{path:"fixtures"},{path:"lib"},{path:"queues"},{path:"routes"},{path:"ui"},{path:"uploaders"},{path:"websockets"},{path:"index.client.js"},{path:"index.server.js"},...t];var h=a;export{h as default};
1
+ import t from"../../build/copy_paths.js";const a=[{path:"api"},{path:"cronJobs"},{path:"cron_jobs"},{path:"email"},{path:"fixtures"},{path:"indexes"},{path:"lib"},{path:"queues"},{path:"routes"},{path:"ui"},{path:"uploaders"},{path:"websockets"},{path:"index.client.js"},{path:"index.server.js"},...t];var e=a;export{e 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.603",
4
+ "version": "0.0.0-canary.605",
5
5
  "description": "The CLI for Joystick.",
6
6
  "main": "dist/index.js",
7
7
  "bin": {
@@ -21,15 +21,11 @@ export default (() => {
21
21
  const connection = connections[i];
22
22
 
23
23
  if (connection?.connection?.send) {
24
- console.log({ parsed_message });
25
-
26
24
  if (parsed_message?.type === 'BUILD_ERROR') {
27
- console.log('SEND BUILD ERROR');
28
25
  return connection.connection.send(JSON.stringify({ type: 'BUILD_ERROR' }));
29
26
  }
30
27
 
31
28
  if (parsed_message?.type === 'FILE_CHANGE') {
32
- console.log('SEND FILE CHANGE');
33
29
  return connection.connection.send(
34
30
  JSON.stringify({
35
31
  type: "FILE_CHANGE",
@@ -149,17 +149,15 @@ const process_file_watcher_jobs = async (jobs = [], after_run_functions = {}) =>
149
149
  }
150
150
  }
151
151
 
152
- setTimeout(async () => {
153
- const tasks_to_run = Array.from(after_run_tasks);
152
+ const tasks_to_run = Array.from(after_run_tasks);
154
153
 
155
- for (let i = 0; i < tasks_to_run?.length; i += 1) {
156
- const after_run_task = tasks_to_run[i];
154
+ for (let i = 0; i < tasks_to_run?.length; i += 1) {
155
+ const after_run_task = tasks_to_run[i];
157
156
 
158
- if (types.is_function(after_run_functions[after_run_task])) {
159
- await after_run_functions[after_run_task](jobs);
160
- }
157
+ if (types.is_function(after_run_functions[after_run_task])) {
158
+ await after_run_functions[after_run_task](jobs);
161
159
  }
162
- }, 300);
160
+ }
163
161
  } catch(error) {
164
162
  // NOTE: Dead catch as we just want to avoid after_run_tasks from running. Actual
165
163
  // errors are handled as part of run_job() (e.g., build errors are handled as a part
@@ -5,6 +5,7 @@ export default [
5
5
  get_platform_safe_path("cronJobs/"),
6
6
  get_platform_safe_path("cron_jobs/"),
7
7
  get_platform_safe_path("fixtures/"),
8
+ get_platform_safe_path("indexes/"),
8
9
  get_platform_safe_path("lib/node"),
9
10
  get_platform_safe_path("queues/"),
10
11
  get_platform_safe_path("routes/"),
@@ -6,6 +6,7 @@ const watch_paths = [
6
6
  { path: "cron_jobs" },
7
7
  { path: "email" },
8
8
  { path: "fixtures" },
9
+ { path: "indexes" },
9
10
  { path: "lib" },
10
11
  { path: "queues" },
11
12
  { path: "routes" },