codenotch-react 1.0.58 → 1.0.60
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
|
-
{"version":3,"file":"Auml.d.ts","sourceRoot":"","sources":["../../src/components/Auml.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,0EAA0E,CAAC;
|
|
1
|
+
{"version":3,"file":"Auml.d.ts","sourceRoot":"","sources":["../../src/components/Auml.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,eAAe,EAAE,MAAM,0EAA0E,CAAC;AAU3G,UAAU,UAAU;IAChB,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,UAAU;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;CAC7B;AAED,qBAAa,IAAK,SAAQ,KAAK,CAAC,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IAE7D,kBAAkB,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;gBAEnC,KAAK,EAAE,UAAU;IAY7B,iBAAiB;IAmCjB,oBAAoB;IAQpB,QAAQ,CAAC,CAAC,EAAE,eAAe;IAO3B,OAAO;IAYP,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS;IAclC,cAAc;;;IAMd,wBAAwB,IAAI,MAAM,GAAG,IAAI;IAmCzC,2BAA2B,CAAC,kBAAkB,EAAE,MAAM,GAAG,MAAM;IAO/D,QAAQ,CAAC,EAAE,EAAE,MAAM;IAmBnB,QAAQ,CAAC,KAAK,EAAE,MAAM;IAsBtB,MAAM;IAoDA,mBAAmB;CAoC5B"}
|
package/dist/components/Auml.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.Auml = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const SpaRenderWithBrowserRouter_1 = require("@echino/echino.ui.framework/components/SpaBuilder/SpaRender/SpaRenderWithBrowserRouter");
|
|
9
|
+
const I18nUtils_1 = __importDefault(require("../utils/I18nUtils"));
|
|
9
10
|
class Auml extends react_1.default.Component {
|
|
10
11
|
constructor(props) {
|
|
11
12
|
super(props);
|
|
@@ -13,6 +14,10 @@ class Auml extends react_1.default.Component {
|
|
|
13
14
|
loaded: false,
|
|
14
15
|
inspectorEnabled: false
|
|
15
16
|
};
|
|
17
|
+
if (typeof user === 'undefined') {
|
|
18
|
+
let globalObject = typeof window !== 'undefined' ? window : globalThis;
|
|
19
|
+
globalObject['user'] = null; // Make sure user is defined
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
componentDidMount() {
|
|
18
23
|
try {
|
|
@@ -20,7 +25,7 @@ class Auml extends react_1.default.Component {
|
|
|
20
25
|
if (this._refreshTokenTimer) {
|
|
21
26
|
clearTimeout(this._refreshTokenTimer);
|
|
22
27
|
}
|
|
23
|
-
if (
|
|
28
|
+
if (user === null) {
|
|
24
29
|
console.log("No user found, will not refresh the token");
|
|
25
30
|
return;
|
|
26
31
|
}
|
|
@@ -150,8 +155,15 @@ export interface UserInfo {
|
|
|
150
155
|
aumlManifest = appManifestObj.auml;
|
|
151
156
|
}
|
|
152
157
|
catch { }
|
|
158
|
+
let auml = this.props.value;
|
|
159
|
+
try {
|
|
160
|
+
auml = I18nUtils_1.default.compileAuml(auml);
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
console.error("Error compiling AUML with i18n variables: " + err);
|
|
164
|
+
}
|
|
153
165
|
return react_1.default.createElement("div", { className: "app" },
|
|
154
|
-
react_1.default.createElement(SpaRenderWithBrowserRouter_1.SpaRenderWithBrowserRouter, { appDescription:
|
|
166
|
+
react_1.default.createElement(SpaRenderWithBrowserRouter_1.SpaRenderWithBrowserRouter, { appDescription: auml, tenant: tenant, serviceName: serviceName, packageVersions: packageVersions, user: user, languages: languages, onProgress: (s) => this.progress(s), input: inputs, theme: theme, manifest: aumlManifest, inspectorEnabled: this.state.inspectorEnabled, children: [] }),
|
|
155
167
|
!this.state.loaded &&
|
|
156
168
|
react_1.default.createElement("div", { className: `app-loading ${this.getMode(theme)}` },
|
|
157
169
|
this.getLogo(),
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAIjD,QAAA,MAAM,GAAG,EAAE,aAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEpF,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,UAAU,MAAM,yBAAyB,CAAC;AAIjD,QAAA,MAAM,GAAG,EAAE,aAAkB,CAAC;AAM9B;;;;GAIG;AACH,iBAAS,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,IAAI,CAqErC;AAED,iBAAS,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,MAAM,CAoCjD;AAED;;;GAGG;AACH,iBAAS,YAAY,IAAI,aAAa,CAkLrC;AAED,OAAO,EACH,GAAG,EACH,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,IAAI,EACJ,UAAU,EACb,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,38 +34,46 @@ function init(envVariables) {
|
|
|
34
34
|
// i18n.fr.somekey=some value
|
|
35
35
|
let i18nLanguages = new Set();
|
|
36
36
|
Object.keys(envVariables).forEach((key) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Parse like json
|
|
46
|
-
try {
|
|
47
|
-
keyValue = JSON.parse(keyValue);
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.warn(`Codenotch environment variable ${key} is not a valid JSON string. Using raw value.`);
|
|
51
|
-
}
|
|
37
|
+
try {
|
|
38
|
+
if (key.startsWith('GLOBAL.')) {
|
|
39
|
+
// Global variable, we set it directly on the window object
|
|
40
|
+
let globalKey = key.substring('GLOBAL.'.length);
|
|
41
|
+
let globalObject = typeof window !== 'undefined' ? window : globalThis;
|
|
42
|
+
globalObject[globalKey] = JSON.parse(envVariables[key]);
|
|
43
|
+
console.log(`Codenotch global variable ${globalKey} set!`);
|
|
44
|
+
return;
|
|
52
45
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
46
|
+
else if (key.startsWith("i18n.")) {
|
|
47
|
+
// Special case
|
|
48
|
+
let parts = key.split("."); // i18n.someKey.fr
|
|
49
|
+
let language = parts[parts.length - 1]; // fr
|
|
50
|
+
let keyName = parts.slice(1, parts.length - 1).join("."); // someKey
|
|
51
|
+
i18nLanguages.add(language);
|
|
52
|
+
let value = `${envVariables[key]}`.trim();
|
|
53
|
+
if (value.startsWith('"') && value.endsWith('"')) {
|
|
54
|
+
// Parse like json
|
|
55
|
+
value = JSON.parse(value);
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
|
|
57
|
+
env.i18n = env.i18n ?? {};
|
|
58
|
+
env.i18n[language] = env.i18n[language] ?? {};
|
|
59
|
+
env.i18n[language][keyName] = value;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
env[key] = envVariables[key];
|
|
63
|
+
if (['appManifest', 'projectManifest'].includes(key)) {
|
|
64
|
+
// Must be Json
|
|
65
|
+
try {
|
|
66
|
+
env[key] = JSON.parse(envVariables[key]);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
console.warn(`Codenotch environment variable ${key} is not a valid JSON string. Using raw value.`);
|
|
70
|
+
}
|
|
66
71
|
}
|
|
72
|
+
console.log(`Codenotch environment variable ${key} set to ${env[key]}`);
|
|
67
73
|
}
|
|
68
|
-
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
console.error(`Error processing Codenotch environment variable ${key}:`, error);
|
|
69
77
|
}
|
|
70
78
|
});
|
|
71
79
|
if (env.language === undefined) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18nUtils.d.ts","sourceRoot":"","sources":["../../src/utils/I18nUtils.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,CAAC,QAAQ,OAAO,SAAS;WAErB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAO/C,OAAO,CAAC,MAAM,CAAC,UAAU;CAqB5B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __1 = require("..");
|
|
4
|
+
class I18nUtils {
|
|
5
|
+
static compileAuml(auml) {
|
|
6
|
+
auml = this.injectI18n(auml);
|
|
7
|
+
return auml;
|
|
8
|
+
}
|
|
9
|
+
static injectI18n(auml) {
|
|
10
|
+
let i18n = (0, __1.useCodenotch)().env.i18n ?? {};
|
|
11
|
+
if (Object.keys(i18n).length === 0) {
|
|
12
|
+
// No i18n variables, return original auml
|
|
13
|
+
return auml;
|
|
14
|
+
}
|
|
15
|
+
// Obtain the root tag of the file
|
|
16
|
+
let match = auml.match(/<([^!\r\n\t\f\v> ]+)/);
|
|
17
|
+
if (!match) {
|
|
18
|
+
return auml;
|
|
19
|
+
}
|
|
20
|
+
let rootTag = match[1];
|
|
21
|
+
auml = auml.replace(`</${rootTag}>`, `<${rootTag}.I18n><![CDATA[${JSON.stringify(i18n)}]]></${rootTag}.I18n></${rootTag}>`);
|
|
22
|
+
return auml;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = I18nUtils;
|