@aventusjs/cli 0.0.12 → 0.0.14
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 +61 -0
- package/lib/Aventus@Main.package.avt +2500 -0
- package/lib/Aventus@Php.package.avt +455 -0
- package/lib/Aventus@Sharp.package.avt +851 -0
- package/lib/Aventus@UI.package.avt +1249 -0
- package/lib/emmet/aventus.json +7 -0
- package/lib/templateScript/AventusTemplate.d.ts +118 -0
- package/lib/templateScript/AventusTemplate.ts +420 -0
- package/out/705.RealServer.js +27 -0
- package/out/RealInteraction.js +1 -1
- package/out/RealServer.js +225 -158
- package/out/cli.js +1 -1
- package/package.json +1 -1
- package/out/940.RealServer.js +0 -27
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Aventus@I18n:1.0.0
|
|
2
|
+
// npm:@aventusjs/i18n
|
|
3
|
+
//#region js def //
|
|
4
|
+
declare global {
|
|
5
|
+
|
|
6
|
+
namespace Aventus{
|
|
7
|
+
@Dependances([{ type: WebComponent, strong: true }])
|
|
8
|
+
class I18nClass {
|
|
9
|
+
|
|
10
|
+
private currentLocale;
|
|
11
|
+
protected langMutex: Aventus.ActionGuard;
|
|
12
|
+
private watcher;
|
|
13
|
+
protected get locale(): any;
|
|
14
|
+
protected set locale(value: any);
|
|
15
|
+
protected files: string[];
|
|
16
|
+
protected waitingFiles: string[];
|
|
17
|
+
protected __translations: {
|
|
18
|
+
[lang: string]: {};
|
|
19
|
+
};
|
|
20
|
+
setLocale(lang: string): Promise<void>;
|
|
21
|
+
getLocale(): string;
|
|
22
|
+
private merge;
|
|
23
|
+
private registerFileTimeout;
|
|
24
|
+
registerFile(file: string): void;
|
|
25
|
+
protected loadFileDelay(): Promise<void>;
|
|
26
|
+
hasKey(key: string): boolean;
|
|
27
|
+
@BindThis()
|
|
28
|
+
t(key: string, params?: {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
}): string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const I18n: I18nClass;
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function t(key: keyof Aventus.AventusI18n, params: { [key: string]: string; } = {}): string;
|
|
38
|
+
declare namespace Aventus {
|
|
39
|
+
interface WebComponent extends HTMLElement {
|
|
40
|
+
t: (key: keyof Aventus.AventusI18n, params: { [key: string]: string; } = {}) => string;
|
|
41
|
+
}
|
|
42
|
+
interface AventusI18n {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
//#endregion js def //
|
|
47
|
+
//#region js src //
|
|
48
|
+
{"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 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\t}\r\n\r\n})();\r\n\r\n","dependances":[],"fullName":"!staticClass_0b3f4490a9fdc9f8a16a5a5008491950","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 langMutex = new Aventus.ActionGuard();\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 this.currentLocale = 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 }\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 registerFileTimeout = 0;\n registerFile(file) {\n if (this.files.includes(file))\n return;\n this.waitingFiles.push(file);\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 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`;\r\n__as1(_, 'I18nClass', I18nClass);\r\n","dependances":[{"fullName":"Dependances","isStrong":false},{"fullName":"Aventus.WebComponent","isStrong":false},{"fullName":"Aventus.ActionGuard","isStrong":false},{"fullName":"Aventus.Watcher","isStrong":false},{"fullName":"Promise","isStrong":false},{"fullName":"Aventus.ResourceLoader","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);\r\n","dependances":[{"fullName":"Aventus.I18nClass","isStrong":true},{"fullName":"Aventus.Instance","isStrong":true}],"fullName":"Aventus.I18n","required":false,"type":5,"isExported":true,"convertibleName":""}],"existing":[]}
|
|
49
|
+
//#endregion js src //
|
|
50
|
+
//#region css def //
|
|
51
|
+
{}
|
|
52
|
+
//#endregion css def //
|
|
53
|
+
//#region css //
|
|
54
|
+
{}
|
|
55
|
+
//#endregion css //
|
|
56
|
+
//#region html //
|
|
57
|
+
{}
|
|
58
|
+
//#endregion html //
|
|
59
|
+
//#region dependances //
|
|
60
|
+
{}
|
|
61
|
+
//#endregion dependances //
|