@schukai/monster 3.104.0 → 3.105.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
 
4
4
 
5
+ ## [3.105.0] - 2025-02-05
6
+
7
+ ### Add Features
8
+
9
+ - new internal Translation
10
+
11
+
12
+
13
+ ## [3.104.1] - 2025-02-04
14
+
15
+ ### Bug Fixes
16
+
17
+ - remove debug information and reset save button to state-button
18
+
19
+
20
+
5
21
  ## [3.104.0] - 2025-02-04
6
22
 
7
23
  ### Add Features
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.104.0"}
1
+ {"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.105.0"}
@@ -32,7 +32,7 @@ import { Datasource } from "./datasource.mjs";
32
32
  import { Rest as RestDatasource } from "./datasource/rest.mjs";
33
33
  import { BadgeStyleSheet } from "../stylesheet/badge.mjs";
34
34
  import { SaveButtonStyleSheet } from "./stylesheet/save-button.mjs";
35
- import "../form/message-state-button.mjs";
35
+ import "../form/state-button.mjs";
36
36
 
37
37
  import {
38
38
  handleDataSourceChanges,
@@ -315,13 +315,12 @@ function getTranslations() {
315
315
  * @throws {Error} the selector must match exactly one element
316
316
  */
317
317
  function initControlReferences() {
318
-
319
318
  if (!this.shadowRoot) {
320
319
  throw new Error("no shadow-root is defined");
321
320
  }
322
321
 
323
322
  this[stateButtonElementSymbol] = this.shadowRoot.querySelector(
324
- "[data-monster-role=save-button]",
323
+ "[data-monster-role=state-button]",
325
324
  );
326
325
 
327
326
  this[badgeElementSymbol] = this.shadowRoot.querySelector(
@@ -334,9 +333,9 @@ function initControlReferences() {
334
333
  changed: new State(
335
334
  "changed",
336
335
  '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-arrow-up" viewBox="0 0 16 16">' +
337
- '<path fill-rule="evenodd" d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708z"/>' +
338
- '<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"/>' +
339
- "</svg>",
336
+ '<path fill-rule="evenodd" d="M7.646 5.146a.5.5 0 0 1 .708 0l2 2a.5.5 0 0 1-.708.708L8.5 6.707V10.5a.5.5 0 0 1-1 0V6.707L6.354 7.854a.5.5 0 1 1-.708-.708z"/>' +
337
+ '<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383m.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"/>' +
338
+ "</svg>",
340
339
  ),
341
340
  };
342
341
 
@@ -347,9 +346,6 @@ function initControlReferences() {
347
346
  "labels.button",
348
347
  this.getOption("labels.button"),
349
348
  );
350
-
351
- console.log(this[stateButtonElementSymbol])
352
-
353
349
  });
354
350
  }
355
351
 
@@ -401,16 +397,14 @@ function updateOptionsFromArguments(options) {
401
397
  function getTemplate() {
402
398
  // language=HTML
403
399
  return `
404
- <div data-monster-role="control" part="control"
405
- data-monster-attributes="disabled path:disabled | if:true">
406
- <monster-message-state-button part="button"
407
- data-monster-role="save-button"
408
- ></monster-message-state-button>
409
- <div data-monster-attributes="disabled path:disabled | if:true, class path:classes.badge"
410
- data-monster-role="badge"
411
- data-monster-replace="path:changes"></div>
412
- </div>
413
- `;
400
+ <div data-monster-role="control" part="control"
401
+ data-monster-attributes="disabled path:disabled | if:true">
402
+ <monster-state-button data-monster-role="state-button">save</monster-state-button>
403
+ <div data-monster-attributes="disabled path:disabled | if:true, class path:classes.badge"
404
+ data-monster-role="badge"
405
+ data-monster-replace="path:changes"></div>
406
+ </div>
407
+ `;
414
408
  }
415
409
 
416
- registerCustomElement(SaveButton);
410
+ registerCustomElement(SaveButton);
@@ -69,9 +69,6 @@ class MessageStateButton extends Popper {
69
69
  * @throws {TypeError} value is not an instance
70
70
  */
71
71
  setState(state, timeout) {
72
-
73
- console.log(this[buttonElementSymbol]);
74
-
75
72
  return this[buttonElementSymbol].setState(state, timeout);
76
73
  }
77
74
 
@@ -19,6 +19,7 @@ import { Server } from "../server.mjs";
19
19
  import { WriteError } from "./restapi/writeerror.mjs";
20
20
  import { DataFetchError } from "./restapi/data-fetch-error.mjs";
21
21
  import { clone } from "../../../util/clone.mjs";
22
+ import {getInternalLocalizationMessage} from "../../../i18n/internal.mjs";
22
23
 
23
24
  export { RestAPI };
24
25
 
@@ -224,7 +225,9 @@ function fetchData(init, key, callback) {
224
225
 
225
226
  if (acceptedStatus.indexOf(resp.status) === -1) {
226
227
  throw new DataFetchError(
227
- `the response does not contain an accepted status (actual: ${resp.status}).`,
228
+ getInternalLocalizationMessage(
229
+ `i18n{the-response-does-not-contain-an-accepted-status::status=${resp.status}}`
230
+ ),
228
231
  response,
229
232
  );
230
233
  }
@@ -244,7 +247,9 @@ function fetchData(init, key, callback) {
244
247
  }
245
248
 
246
249
  throw new DataFetchError(
247
- `the response does not contain a valid json (actual: ${body}).`,
250
+ getInternalLocalizationMessage(
251
+ `i18n{the-response-does-not-contain-a-valid-json::actual=${body}}`
252
+ ),
248
253
  response,
249
254
  );
250
255
  }
@@ -39,6 +39,8 @@ class Formatter extends TextFormatter {
39
39
  * Default values for the markers are `${` and `}`
40
40
  *
41
41
  * @param {object} object
42
+ * @param {Translations} translation
43
+ * @param {object} [options]
42
44
  * @throws {TypeError} value is not a object
43
45
  */
44
46
  constructor(object, translation, options) {
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Copyright © schukai GmbH and all contributing authors, {{copyRightYear}}. All rights reserved.
3
+ * Node module: @schukai/monster
4
+ *
5
+ * This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
6
+ * The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
7
+ *
8
+ * For those who do not wish to adhere to the AGPLv3, a commercial license is available.
9
+ * Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
10
+ * For more information about purchasing a commercial license, please contact schukai GmbH.
11
+ *
12
+ * SPDX-License-Identifier: AGPL-3.0
13
+ */
14
+
15
+ import {Formatter} from "./formatter.mjs";
16
+ import {getLocaleOfDocument} from "../dom/locale.mjs";
17
+ import {Translations} from "./translations.mjs";
18
+
19
+ export {getInternalLocalizationMessage};
20
+
21
+ let internalTranslations = null;
22
+ getInternalTranslations();
23
+
24
+
25
+ function getInternalTranslations() {
26
+
27
+ if (internalTranslations) {
28
+ return internalTranslations;
29
+ }
30
+
31
+ let locale = "en";
32
+ try {
33
+ let locale = getLocaleOfDocument();
34
+ } catch (error) {
35
+ }
36
+
37
+ let messages = {};
38
+
39
+ switch (locale.language) {
40
+ case "de":
41
+ messages = {
42
+ "the-response-does-not-contain-an-accepted-status": `Der Server hat die Anfrage nicht akzeptiert (Status \${status}).`,
43
+ "the-response-does-not-contain-a-valid-json": `Die Antwort des Servers ist kein gültiges JSON (actual=\${actual}).`,
44
+ };
45
+ break;
46
+ case "es":
47
+ messages = {
48
+ "the-response-does-not-contain-an-accepted-status": `El servidor no ha aceptado la solicitud (Estado \${status}).`,
49
+ "the-response-does-not-contain-a-valid-json": `La respuesta del servidor no es un JSON válido (actual=\${actual}).`,
50
+ };
51
+ break;
52
+ case "zh":
53
+ messages = {
54
+ "the-response-does-not-contain-an-accepted-status": `服务器未接受请求(状态 \${status})。`,
55
+ "the-response-does-not-contain-a-valid-json": `服务器响应不是有效的JSON(实际=\${actual})。`,
56
+ };
57
+ break;
58
+ case "fr":
59
+ messages = {
60
+ "the-response-does-not-contain-an-accepted-status": `Le serveur n'a pas accepté la demande (Statut \${status}).`,
61
+ "the-response-does-not-contain-a-valid-json": `La réponse du serveur n'est pas un JSON valide (actuel=\${actual}).`,
62
+ };
63
+ break;
64
+ case "it":
65
+ messages = {
66
+ "the-response-does-not-contain-an-accepted-status": `Il server non ha accettato la richiesta (Stato \${status}).`,
67
+ "the-response-does-not-contain-a-valid-json": `La risposta del server non è un JSON valido (attuale=\${actual}).`,
68
+ };
69
+ break;
70
+ case "nl":
71
+ messages = {
72
+ "the-response-does-not-contain-an-accepted-status": `De server heeft het verzoek niet geaccepteerd (Status \${status}).`,
73
+ "the-response-does-not-contain-a-valid-json": `De serverrespons is geen geldige JSON (actueel=\${actual}).`,
74
+ };
75
+ break;
76
+ case "sv":
77
+ messages = {
78
+ "the-response-does-not-contain-an-accepted-status": `Servern accepterade inte begäran (Status \${status}).`,
79
+ "the-response-does-not-contain-a-valid-json": `Serverns svar är inte en giltig JSON (faktisk=\${actual}).`,
80
+ };
81
+ break;
82
+ case "pl":
83
+ messages = {
84
+ "the-response-does-not-contain-an-accepted-status": `Serwer nie zaakceptował żądania (Status \${status}).`,
85
+ "the-response-does-not-contain-a-valid-json": `Odpowiedź serwera nie jest prawidłowym JSON-em (aktualne=\${actual}).`,
86
+ };
87
+ break;
88
+ case "da":
89
+ messages = {
90
+ "the-response-does-not-contain-an-accepted-status": `Serveren accepterede ikke forespørgslen (Status \${status}).`,
91
+ "the-response-does-not-contain-a-valid-json": `Serverens svar er ikke en gyldig JSON (aktuel=\${actual}).`,
92
+ };
93
+ break;
94
+ case "fi":
95
+ messages = {
96
+ "the-response-does-not-contain-an-accepted-status": `Palvelin ei hyväksynyt pyyntöä (Tila \${status}).`,
97
+ "the-response-does-not-contain-a-valid-json": `Palvelimen vastaus ei ole kelvollinen JSON (todellinen=\${actual}).`,
98
+ };
99
+ break;
100
+ case "no":
101
+ messages = {
102
+ "the-response-does-not-contain-an-accepted-status": `Serveren aksepterte ikke forespørselen (Status \${status}).`,
103
+ "the-response-does-not-contain-a-valid-json": `Serverens respons er ikke en gyldig JSON (faktisk=\${actual}).`,
104
+ };
105
+ break;
106
+ case "cs":
107
+ messages = {
108
+ "the-response-does-not-contain-an-accepted-status": `Server nepřijal požadavek (Stav \${status}).`,
109
+ "the-response-does-not-contain-a-valid-json": `Odpověď serveru není platný JSON (skutečný=\${actual}).`,
110
+ };
111
+ break;
112
+ default: // English
113
+ messages = {
114
+ "the-response-does-not-contain-an-accepted-status": `The server did not accept the request (Status \${status}).`,
115
+ "the-response-does-not-contain-a-valid-json": `The server response is not a valid JSON (actual=\${actual}).`,
116
+ };
117
+ }
118
+
119
+
120
+ const translation = new Translations(locale);
121
+ translation.assignTranslations(messages);
122
+
123
+ internalTranslations = translation;
124
+
125
+ return translation
126
+ }
127
+
128
+
129
+ /**
130
+ * Returns the internal localization message.
131
+ * @param message
132
+ * @returns {string}
133
+ */
134
+
135
+ function getInternalLocalizationMessage(message) {
136
+ const formatter = new Formatter({}, getInternalTranslations());
137
+ return formatter.format(message);
138
+
139
+ }
@@ -12,6 +12,35 @@
12
12
  * SPDX-License-Identifier: AGPL-3.0
13
13
  */
14
14
 
15
+ /**
16
+ * Curretnly from Monster supported languages.
17
+ * @type {string[]}
18
+ */
19
+ export const currentSupportedLanguages = [
20
+ "en", // English
21
+ "de", // German
22
+ "es", // Spanish
23
+ "zh", // Mandarin
24
+ "hi", // Hindi
25
+ "bn", // Bengali
26
+ "pt", // Portuguese
27
+ "ru", // Russian
28
+ "ja", // Japanese
29
+ "pa", // Western Punjabi
30
+ "mr", // Marathi
31
+ "fr", // French
32
+ "it", // Italian
33
+ "nl", // Dutch
34
+ "sv", // Swedish
35
+ "pl", // Polish
36
+ "da", // Danish
37
+ "fi", // Finnish
38
+ "no", // Norwegian
39
+ "cs" // Czech
40
+ ];
41
+
42
+
43
+
15
44
  export const languages = {
16
45
  en: "English",
17
46
  "en-GB": "English (United Kingdom)",
@@ -13,12 +13,12 @@
13
13
  */
14
14
 
15
15
  import {
16
- validateFunction,
17
- validateObject,
18
- validateString,
16
+ validateFunction,
17
+ validateObject,
18
+ validateString,
19
19
  } from "./validate.mjs";
20
20
 
21
- export { getGlobal, getGlobalObject, getGlobalFunction };
21
+ export {getGlobal, getGlobalObject, getGlobalFunction};
22
22
 
23
23
  /**
24
24
  * @type {object}
@@ -31,39 +31,40 @@ let globalReference;
31
31
  * @throws {Error} unsupported environment.
32
32
  */
33
33
  (function () {
34
- if (typeof globalThis === "object") {
35
- globalReference = globalThis;
36
- return;
37
- }
34
+ if (typeof globalThis === "object") {
35
+ globalReference = globalThis;
36
+ return;
37
+ }
38
38
 
39
- if (typeof self !== "undefined") {
40
- globalReference = self;
41
- return;
42
- } else if (typeof window !== "undefined") {
43
- globalReference = window;
44
- return;
45
- }
39
+ if (typeof self !== "undefined") {
40
+ globalReference = self;
41
+ return;
42
+ } else if (typeof window !== "undefined") {
43
+ globalReference = window;
44
+ return;
45
+ }
46
46
 
47
- Object.defineProperty(Object.prototype, "__monster__", {
48
- get: function () {
49
- return this;
50
- },
51
- configurable: true,
52
- });
47
+ Object.defineProperty(Object.prototype, "__monster__", {
48
+ get: function () {
49
+ return this;
50
+ },
51
+ configurable: true,
52
+ });
53
53
 
54
- if (typeof __monster__ === "object") {
55
- __monster__.globalThis = __monster__;
56
- delete Object.prototype.__monster__;
54
+ if (typeof __monster__ === "object") {
55
+ __monster__.globalThis = __monster__;
56
+ delete Object.prototype.__monster__;
57
57
 
58
- globalReference = globalThis;
59
- return;
60
- }
58
+ globalReference = globalThis;
59
+ return;
60
+ }
61
61
 
62
- try {
63
- globalReference = Function("return this")();
64
- } catch (e) {}
62
+ try {
63
+ globalReference = Function("return this")();
64
+ } catch (e) {
65
+ }
65
66
 
66
- throw new Error("unsupported environment.");
67
+ throw new Error("unsupported environment.");
67
68
  })();
68
69
 
69
70
  /**
@@ -76,7 +77,7 @@ let globalReference;
76
77
  * @return {object} globalThis
77
78
  */
78
79
  function getGlobal() {
79
- return globalReference;
80
+ return globalReference;
80
81
  }
81
82
 
82
83
  /**
@@ -111,12 +112,12 @@ function getGlobal() {
111
112
  * @throws {TypeError} value is not a string
112
113
  */
113
114
  function getGlobalObject(name) {
114
- validateString(name);
115
- const o = globalReference?.[name];
116
- if (typeof o === "undefined")
117
- throw new Error(`the object ${name} is not defined`);
118
- validateObject(o);
119
- return o;
115
+ validateString(name);
116
+ const o = globalReference?.[name];
117
+ if (typeof o === "undefined")
118
+ throw new Error(`the object ${name} is not defined`);
119
+ validateObject(o);
120
+ return o;
120
121
  }
121
122
 
122
123
  /**
@@ -149,10 +150,11 @@ function getGlobalObject(name) {
149
150
  * @throws {TypeError} value is not a string
150
151
  */
151
152
  function getGlobalFunction(name) {
152
- validateString(name);
153
- const f = globalReference?.[name];
154
- if (typeof f === "undefined")
155
- throw new Error(`the function ${name} is not defined`);
156
- validateFunction(f);
157
- return f;
153
+ validateString(name);
154
+ const f = globalReference?.[name];
155
+ if (typeof f === "undefined") {
156
+ throw new Error(`the function ${name} is not defined`);
157
+ }
158
+ validateFunction(f);
159
+ return f;
158
160
  }
@@ -156,7 +156,7 @@ function getMonsterVersion() {
156
156
  }
157
157
 
158
158
  /** don't touch, replaced by make with package.json version */
159
- monsterVersion = new Version("3.102.6");
159
+ monsterVersion = new Version("3.104.1");
160
160
 
161
161
  return monsterVersion;
162
162
  }
@@ -7,7 +7,7 @@ describe('Monster', function () {
7
7
  let monsterVersion
8
8
 
9
9
  /** don´t touch, replaced by make with package.json version */
10
- monsterVersion = new Version("3.102.6")
10
+ monsterVersion = new Version("3.104.1")
11
11
 
12
12
  let m = getMonsterVersion();
13
13
 
@@ -9,8 +9,8 @@
9
9
  </head>
10
10
  <body>
11
11
  <div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
12
- <h1 style='margin-bottom: 0.1em;'>Monster 3.102.6</h1>
13
- <div id="lastupdate" style='font-size:0.7em'>last update So 2. Feb 23:18:18 CET 2025</div>
12
+ <h1 style='margin-bottom: 0.1em;'>Monster 3.104.1</h1>
13
+ <div id="lastupdate" style='font-size:0.7em'>last update Mi 5. Feb 19:28:33 CET 2025</div>
14
14
  </div>
15
15
  <div id="mocha-errors"
16
16
  style="color: red;font-weight: bold;display: flex;align-items: center;justify-content: center;flex-direction: column;margin:20px;"></div>