@aventusjs/cli 0.0.23 → 0.0.25
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.
- package/lib/Aventus@I18n.package.avt +1 -1
- package/lib/Aventus@Main.package.avt +28 -28
- package/lib/Aventus@Sharp.package.avt +718 -718
- package/lib/Aventus@UI.package.avt +61 -61
- package/out/RealServer.js +90 -14
- package/out/cli.js +1 -1
- package/package.json +1 -1
|
@@ -56,7 +56,7 @@ const I18n: Aventus.I18nClass;
|
|
|
56
56
|
}
|
|
57
57
|
//#endregion js def //
|
|
58
58
|
//#region js src //
|
|
59
|
-
{"namespace":"Aventus","available":[{"code":"(() => {\r\n if(!Object.hasOwn(window, \"t\")) {\r\n\r\n Object.defineProperty(window, \"t\", {\r\n get() {return Aventus.I18n.t;}\r\n });\r\n\r\n Object.defineProperty(window, \"tDyn\", {\r\n get() {return Aventus.I18n.t;}\r\n });\r\n\r\n Aventus.WebComponent.prototype.t = function(key, params = {}) {\r\n const i18n = Aventus.I18n;\r\n const localeKey = this.$type.replace(/\\./g, '°') + \"°\" + key;\r\n if(i18n.hasKey(localeKey)) {\r\n return i18n.t(localeKey, params);\r\n }\r\n return i18n.t(key, params);\r\n }\r\n Aventus.WebComponent.prototype.tDyn = function(key, params = {}) {\r\n const i18n = Aventus.I18n;\r\n const localeKey = this.$type.replace(/\\./g, '°') + \"°\" + key;\r\n if(i18n.hasKey(localeKey)) {\r\n return i18n.t(localeKey, params);\r\n }\r\n return i18n.t(key, params);\r\n }\r\n\t}\r\n\r\n})();\r\n\r\n","dependencies":[],"fullName":"!staticClass_3c20413907f4e649ec4f2bf2e7857aa9","required":true,"noNamespace":"before","type":0,"isExported":false,"convertibleName":""},{"code":"let I18nClass=class I18nClass {\n constructor() { this.t = this.t.bind(this); }\n currentLocale = \"en-GB\";\n availableLocales = [];\n fallback = \"en-GB\";\n langMutex = new Aventus.ActionGuard();\n onLocaleChange = new Aventus.Callback();\n watcher = Aventus.Watcher.get({\n locale: {}\n });\n get locale() {\n return this.watcher['locale'];\n }\n set locale(value) {\n this.watcher['locale'] = value;\n }\n files = [];\n waitingFiles = [];\n __translations = {};\n async setLocale(lang) {\n if (!this.availableLocales.includes(lang)) {\n throw `The locale ${lang} can't be found inside the locales : ${this.availableLocales.join(\", \")}`;\n }\n let oldLocale = this.currentLocale;\n this.currentLocale = lang;\n localStorage.setItem(\"AventusI18nLang\", lang);\n if (!this.__translations[lang]) {\n await this.langMutex.run([\"\"], async () => {\n const proms = [];\n for (let file of this.files) {\n let uri = file.replace(/\\$locale/g, lang);\n proms.push(Aventus.ResourceLoader.load(uri));\n }\n const results = await Promise.all(proms);\n let items = {};\n for (let result of results) {\n try {\n this.merge(items, JSON.parse(result));\n }\n catch (e) {\n console.error(e);\n }\n }\n this.__translations[lang] = items;\n });\n }\n this.locale = this.__translations[lang];\n this.onLocaleChange.trigger(oldLocale, lang);\n }\n getLocale() {\n return this.currentLocale;\n }\n merge(from, to) {\n for (let key in to) {\n let val = to[key];\n if (typeof val == 'object') {\n let temp = {};\n this.merge(temp, val);\n from[key] = temp;\n }\n else {\n from[key] = val;\n }\n }\n }\n registerLocales(locales) {\n for (let locale of locales) {\n if (!this.availableLocales.includes(locale)) {\n this.availableLocales.push(locale);\n }\n }\n }\n registerFallback(fallback) {\n if (!this.availableLocales.includes(fallback)) {\n throw `The fallback ${fallback} can't be found inside the locales : ${this.availableLocales.join(\", \")}`;\n }\n this.fallback = fallback;\n const userLang = localStorage.getItem(\"AventusI18nLang\") ?? navigator.language;\n if (this.availableLocales.includes(userLang)) {\n this.currentLocale = userLang;\n return;\n }\n let prefix = userLang.split(\"-\")[0];\n if (this.availableLocales.includes(prefix)) {\n this.currentLocale = prefix;\n return;\n }\n this.currentLocale = this.fallback;\n this.onLocaleChange.trigger(this.currentLocale, this.currentLocale);\n }\n registerFileTimeout = 0;\n registerFile(file, options) {\n if (this.files.includes(file))\n return;\n this.waitingFiles.push(file);\n options = options ?? {};\n if (options.load === false)\n return;\n if (options.delay === false) {\n this.loadFileDelay();\n return;\n }\n clearTimeout(this.registerFileTimeout);\n this.registerFileTimeout = setTimeout(() => {\n this.loadFileDelay();\n }, 200);\n }\n async loadFileDelay() {\n await this.langMutex.run([\"\"], async () => {\n const lang = this.currentLocale;\n const proms = [];\n for (let file of this.waitingFiles) {\n let uri = file.replace(/\\$locale/g, lang).toLowerCase();\n proms.push(Aventus.ResourceLoader.load(uri));\n }\n const results = await Promise.all(proms);\n let items = this.locale;\n for (let result of results) {\n try {\n this.merge(items, JSON.parse(result));\n }\n catch (e) {\n console.error(e);\n }\n }\n for (let file of this.waitingFiles) {\n this.files.push(file);\n }\n this.__translations[lang] = items;\n this.waitingFiles = [];\n });\n }\n init() {\n return this.loadFileDelay();\n }\n hasKey(key) {\n return this.locale[key] !== undefined;\n }\n t(key, params = {}) {\n let translation = this.locale[key];\n if (translation === undefined) {\n translation = key;\n }\n for (let key in params) {\n let regex = new RegExp(\"(?<!\\\\\\\\)\\\\{ *\" + key + \" *\\\\}\", \"g\");\n translation = translation.replace(regex, params[key]);\n }\n return translation;\n }\n}\nI18nClass.Namespace=`Aventus`;\
|
|
59
|
+
{"namespace":"Aventus","available":[{"code":"(() => {\r\n if(!Object.hasOwn(window, \"t\")) {\r\n\r\n Object.defineProperty(window, \"t\", {\r\n get() {return Aventus.I18n.t;}\r\n });\r\n\r\n Object.defineProperty(window, \"tDyn\", {\r\n get() {return Aventus.I18n.t;}\r\n });\r\n\r\n Aventus.WebComponent.prototype.t = function(key, params = {}) {\r\n const i18n = Aventus.I18n;\r\n const localeKey = this.$type.replace(/\\./g, '°') + \"°\" + key;\r\n if(i18n.hasKey(localeKey)) {\r\n return i18n.t(localeKey, params);\r\n }\r\n return i18n.t(key, params);\r\n }\r\n Aventus.WebComponent.prototype.tDyn = function(key, params = {}) {\r\n const i18n = Aventus.I18n;\r\n const localeKey = this.$type.replace(/\\./g, '°') + \"°\" + key;\r\n if(i18n.hasKey(localeKey)) {\r\n return i18n.t(localeKey, params);\r\n }\r\n return i18n.t(key, params);\r\n }\r\n\t}\r\n\r\n})();\r\n\r\n","dependencies":[],"fullName":"!staticClass_3c20413907f4e649ec4f2bf2e7857aa9","required":true,"noNamespace":"before","type":0,"isExported":false,"convertibleName":""},{"code":"let I18nClass=class I18nClass {\n constructor() { this.t = this.t.bind(this); }\n currentLocale = \"en-GB\";\n availableLocales = [];\n fallback = \"en-GB\";\n langMutex = new Aventus.ActionGuard();\n onLocaleChange = new Aventus.Callback();\n watcher = Aventus.Watcher.get({\n locale: {}\n });\n get locale() {\n return this.watcher['locale'];\n }\n set locale(value) {\n this.watcher['locale'] = value;\n }\n files = [];\n waitingFiles = [];\n __translations = {};\n async setLocale(lang) {\n if (!this.availableLocales.includes(lang)) {\n throw `The locale ${lang} can't be found inside the locales : ${this.availableLocales.join(\", \")}`;\n }\n let oldLocale = this.currentLocale;\n this.currentLocale = lang;\n localStorage.setItem(\"AventusI18nLang\", lang);\n if (!this.__translations[lang]) {\n await this.langMutex.run([\"\"], async () => {\n const proms = [];\n for (let file of this.files) {\n let uri = file.replace(/\\$locale/g, lang);\n proms.push(Aventus.ResourceLoader.load(uri));\n }\n const results = await Promise.all(proms);\n let items = {};\n for (let result of results) {\n try {\n this.merge(items, JSON.parse(result));\n }\n catch (e) {\n console.error(e);\n }\n }\n this.__translations[lang] = items;\n });\n }\n this.locale = this.__translations[lang];\n this.onLocaleChange.trigger(oldLocale, lang);\n }\n getLocale() {\n return this.currentLocale;\n }\n merge(from, to) {\n for (let key in to) {\n let val = to[key];\n if (typeof val == 'object') {\n let temp = {};\n this.merge(temp, val);\n from[key] = temp;\n }\n else {\n from[key] = val;\n }\n }\n }\n registerLocales(locales) {\n for (let locale of locales) {\n if (!this.availableLocales.includes(locale)) {\n this.availableLocales.push(locale);\n }\n }\n }\n registerFallback(fallback) {\n if (!this.availableLocales.includes(fallback)) {\n throw `The fallback ${fallback} can't be found inside the locales : ${this.availableLocales.join(\", \")}`;\n }\n this.fallback = fallback;\n const userLang = localStorage.getItem(\"AventusI18nLang\") ?? navigator.language;\n if (this.availableLocales.includes(userLang)) {\n this.currentLocale = userLang;\n return;\n }\n let prefix = userLang.split(\"-\")[0];\n if (this.availableLocales.includes(prefix)) {\n this.currentLocale = prefix;\n return;\n }\n this.currentLocale = this.fallback;\n this.onLocaleChange.trigger(this.currentLocale, this.currentLocale);\n }\n registerFileTimeout = 0;\n registerFile(file, options) {\n if (this.files.includes(file))\n return;\n this.waitingFiles.push(file);\n options = options ?? {};\n if (options.load === false)\n return;\n if (options.delay === false) {\n this.loadFileDelay();\n return;\n }\n clearTimeout(this.registerFileTimeout);\n this.registerFileTimeout = setTimeout(() => {\n this.loadFileDelay();\n }, 200);\n }\n async loadFileDelay() {\n await this.langMutex.run([\"\"], async () => {\n const lang = this.currentLocale;\n const proms = [];\n for (let file of this.waitingFiles) {\n let uri = file.replace(/\\$locale/g, lang).toLowerCase();\n proms.push(Aventus.ResourceLoader.load(uri));\n }\n const results = await Promise.all(proms);\n let items = this.locale;\n for (let result of results) {\n try {\n this.merge(items, JSON.parse(result));\n }\n catch (e) {\n console.error(e);\n }\n }\n for (let file of this.waitingFiles) {\n this.files.push(file);\n }\n this.__translations[lang] = items;\n this.waitingFiles = [];\n });\n }\n init() {\n return this.loadFileDelay();\n }\n hasKey(key) {\n return this.locale[key] !== undefined;\n }\n t(key, params = {}) {\n let translation = this.locale[key];\n if (translation === undefined) {\n translation = key;\n }\n for (let key in params) {\n let regex = new RegExp(\"(?<!\\\\\\\\)\\\\{ *\" + key + \" *\\\\}\", \"g\");\n translation = translation.replace(regex, params[key]);\n }\n return translation;\n }\n}\nI18nClass.Namespace=`Aventus`;\n__as1(_, 'I18nClass', I18nClass);\n","dependencies":[{"fullName":"Dependencies","isStrong":false},{"fullName":"Aventus.WebComponent","isStrong":false},{"fullName":"Aventus.ActionGuard","isStrong":false},{"fullName":"Aventus.Callback","isStrong":false},{"fullName":"Aventus.Watcher","isStrong":false},{"fullName":"BindThis","isStrong":false}],"fullName":"Aventus.I18nClass","required":false,"type":1,"isExported":true,"convertibleName":""},{"code":"let I18n= Aventus.Instance.get(I18nClass);\n__as1(_, 'I18n', I18n);\n","dependencies":[{"fullName":"Aventus.I18nClass","isStrong":true},{"fullName":"Aventus.Instance","isStrong":true}],"fullName":"Aventus.I18n","required":false,"type":5,"isExported":true,"convertibleName":""}],"existing":[]}
|
|
60
60
|
//#endregion js src //
|
|
61
61
|
//#region css def //
|
|
62
62
|
{}
|