@joystick.js/node-canary 0.0.0-canary.459 → 0.0.0-canary.460

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"./get_platform_safe_path.js";const a=async(t="")=>(await import(t))?.default;var f=a;export{f as default};
1
+ import"./get_platform_safe_path.js";const e=async(t="")=>(await(process.platform==="win32"?import(`file://${t}`):import(t)))?.default;var f=e;export{f as default};
@@ -1 +1 @@
1
- import o from"fs";import p from"./dynamic_import.js";import"./get_platform_safe_path.js";import h from"../app/settings/load.js";import u from"./path_exists.js";import d from"./types.js";const l=h(),m=async(t="",n="",r="")=>{const a=await p(`${n}/i18n/${t}?v=${new Date().getTime()}`);if(console.log({language_file:a}),a&&d.is_object(a)){const e=a[r];return e||a}return{}},$=(t="",n=[],r="")=>{let a=[];t&&a.push(t);const s=n?.filter(e=>!e?.includes("*"));return a.push(...s),(l?.config?.i18n?.defaultLanguage||l?.config?.i18n?.default_language)&&a.push(l?.config?.i18n?.defaultLanguage||l?.config?.i18n?.default_language),a?.flatMap(e=>{const i=[e];return e?.length===2&&i.push(`${e.substring(0,2)}-`),e?.length>2&&(i.push(`${e?.split("-")[0]}`),i.push(`${e?.split("-")[0]}-`)),i})?.map(e=>e[e.length-1]==="-"?new RegExp(r?`^${r}_${e}[A-Z]+.js`:`^${e}[A-Z]+.js`,"g"):new RegExp(r?`^${r}_${e}.js`:`^${e}.js`,"g"))},w=(t="")=>t.split(",")?.map(r=>r.split(";")[0]),b=async(t={})=>{const n=t?.is_email?`${t?.joystick_build_path}i18n/email`:`${t?.joystick_build_path}i18n`;console.log({language_files_path:await u(n),file_list:o.readdirSync(n)});const r=await u(n)&&o.readdirSync(n)||[],a=t?.is_email?[]:w(t?.req?.headers["accept-language"]),s=$(t?.req?.context?.user?.language,a,t?.email_template_name);console.log({language_files_path:n,language_files:r,language_preferences:s});let e=null;for(let c=0;c<s.length;c+=1){const g=s[c],f=r.find(_=>!!_.match(g));if(f){e=f;break}}return(e?await m(e,t?.joystick_build_path,t?.render_component_path):null)||{}};var E=b;export{E as default};
1
+ import g from"fs";import p from"./dynamic_import.js";import"./get_platform_safe_path.js";import _ from"../app/settings/load.js";import h from"./path_exists.js";import d from"./types.js";const c=_(),m=async(t="",n="",a="")=>{const r=await p(`${n}/i18n/${t}?v=${new Date().getTime()}`);if(console.log({language_file:r}),r&&d.is_object(r)){const e=r[a];return e||r}return{}},$=(t="",n=[],a="")=>{let r=[];t&&r.push(t);const i=n?.filter(e=>!e?.includes("*"));return r.push(...i),(c?.config?.i18n?.defaultLanguage||c?.config?.i18n?.default_language)&&r.push(c?.config?.i18n?.defaultLanguage||c?.config?.i18n?.default_language),r?.flatMap(e=>{const s=[e];return e?.length===2&&s.push(`${e.substring(0,2)}-`),e?.length>2&&(s.push(`${e?.split("-")[0]}`),s.push(`${e?.split("-")[0]}-`)),s})?.map(e=>e[e.length-1]==="-"?new RegExp(a?`^${a}_${e}[A-Z]+.js`:`^${e}[A-Z]+.js`,"g"):new RegExp(a?`^${a}_${e}.js`:`^${e}.js`,"g"))},w=(t="")=>t.split(",")?.map(a=>a.split(";")[0]),b=async(t={})=>{const n=t?.is_email?`${t?.joystick_build_path}i18n/email`:`${t?.joystick_build_path}i18n`,a=await h(n)&&g.readdirSync(n)||[],r=t?.is_email?[]:w(t?.req?.headers["accept-language"]),i=$(t?.req?.context?.user?.language,r,t?.email_template_name);let e=null;for(let l=0;l<i.length;l+=1){const u=i[l],f=a.find(o=>!!o.match(u));if(f){e=f;break}}return(e?await m(e,t?.joystick_build_path,t?.render_component_path):null)||{}};var E=b;export{E as default};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.459",
4
+ "version": "0.0.0-canary.460",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  import get_platform_safe_path from "./get_platform_safe_path.js";
2
2
 
3
- const dynamic_import = async (path = '') => {
4
- const file = await import(path);
3
+ const dynamic_import = async (path = '') => {
4
+ const file = await import(process.platform === 'win32' ? `file://${path}` : path);
5
5
  return file?.default;
6
6
  };
7
7
 
@@ -78,8 +78,6 @@ const get_translations = async (get_translations_options = {}) => {
78
78
  `${get_translations_options?.joystick_build_path}i18n/email` :
79
79
  `${get_translations_options?.joystick_build_path}i18n`;
80
80
 
81
- console.log({ language_files_path: await path_exists(language_files_path), file_list: fs.readdirSync(language_files_path) });
82
-
83
81
  const language_files = (await path_exists(language_files_path) && fs.readdirSync(language_files_path)) || [];
84
82
  const browser_languages = get_translations_options?.is_email ? [] : parse_browser_languages(get_translations_options?.req?.headers['accept-language']);
85
83
  const language_preferences = get_language_preference_regexes(
@@ -88,7 +86,6 @@ const get_translations = async (get_translations_options = {}) => {
88
86
  get_translations_options?.email_template_name
89
87
  );
90
88
 
91
- console.log({ language_files_path, language_files, language_preferences });
92
89
  let matching_file = null;
93
90
 
94
91
  for (let i = 0; i < language_preferences.length; i += 1) {