@schukai/monster 3.80.1 → 3.80.2
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 +11 -0
- package/package.json +1 -1
- package/source/components/layout/collapse.mjs +4 -4
- package/source/components/style/space.pcss +1 -1
- package/source/data/datasource/server/restapi/data-fetch-error.mjs +0 -1
- package/source/dom/customcontrol.mjs +0 -25
- package/source/dom/customelement.mjs +0 -8
- package/source/i18n/formatter.mjs +0 -2
- package/source/i18n/locale.mjs +0 -2
- package/source/i18n/provider.mjs +0 -2
- package/source/i18n/translations.mjs +0 -1
- package/source/logging/handler/console.mjs +0 -1
- package/source/logging/handler.mjs +0 -1
- package/source/logging/logger.mjs +2 -11
- package/source/net/webconnect/message.mjs +0 -1
- package/source/types/basewithoptions.mjs +1 -2
- package/source/types/noderecursiveiterator.mjs +1 -5
- package/source/types/observablequeue.mjs +0 -4
- package/source/types/observer.mjs +0 -3
- package/source/types/observerlist.mjs +0 -2
- package/source/types/queue.mjs +0 -1
- package/source/util/processing/callback.mjs +56 -0
- package/source/util/processing.mjs +2 -40
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
## [3.80.2] - 2024-10-07
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- wrong css property [#250](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/250)
|
|
10
|
+
### Documentation
|
|
11
|
+
|
|
12
|
+
- some optimisations
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
5
16
|
## [3.80.1] - 2024-10-06
|
|
6
17
|
|
|
7
18
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.11","@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.80.
|
|
1
|
+
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.11","@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.80.2"}
|
|
@@ -201,8 +201,8 @@ class Collapse extends CustomElement {
|
|
|
201
201
|
/**
|
|
202
202
|
* Open the collapse
|
|
203
203
|
* @returns {Collapse}
|
|
204
|
-
* @fires
|
|
205
|
-
* @fires
|
|
204
|
+
* @fires monster-collapse-before-open
|
|
205
|
+
* @fires monster-collapse-open
|
|
206
206
|
*/
|
|
207
207
|
open() {
|
|
208
208
|
let node;
|
|
@@ -245,8 +245,8 @@ class Collapse extends CustomElement {
|
|
|
245
245
|
/**
|
|
246
246
|
* Close the collapse
|
|
247
247
|
* @returns {Collapse}
|
|
248
|
-
* @fires
|
|
249
|
-
* @fires
|
|
248
|
+
* @fires monster-collapse-before-close
|
|
249
|
+
* @fires monster-collapse-closed
|
|
250
250
|
*/
|
|
251
251
|
close() {
|
|
252
252
|
if (!this[detailsElementSymbol].classList.contains("active")) {
|
|
@@ -32,8 +32,6 @@ const attachedInternalSymbol = Symbol("attachedInternal");
|
|
|
32
32
|
* After defining a `CustomElement`, the `registerCustomElement` method must be called with the new class name. Only then
|
|
33
33
|
* will the tag defined via the `getTag` method be made known to the DOM.
|
|
34
34
|
*
|
|
35
|
-
* <img src="./images/custom-control.png">
|
|
36
|
-
*
|
|
37
35
|
* This control uses `attachInternals()` to integrate the control into a form. If the target environment does not support
|
|
38
36
|
* this method, the [polyfill](https://www.npmjs.com/package/element-internals-polyfill) can be used.
|
|
39
37
|
*
|
|
@@ -48,18 +46,9 @@ const attachedInternalSymbol = Symbol("attachedInternal");
|
|
|
48
46
|
*
|
|
49
47
|
* Read the HTML specification for Custom Element Reactions: {@link https://html.spec.whatwg.org/dev/custom-elements.html#custom-element-reactions|Custom Element Reactions}.
|
|
50
48
|
*
|
|
51
|
-
* @startuml custom-control.png
|
|
52
|
-
* skinparam monochrome true
|
|
53
|
-
* skinparam shadowing false
|
|
54
|
-
* HTMLElement <|-- CustomElement
|
|
55
|
-
* CustomElement <|-- CustomControl
|
|
56
|
-
* @enduml
|
|
57
49
|
* @summary A base class for custom controls based on CustomElement.
|
|
58
|
-
* @copyright schukai GmbH
|
|
59
50
|
* @license AGPLv3
|
|
60
51
|
* @since 1.14.0
|
|
61
|
-
* @memberOf Monster.DOM
|
|
62
|
-
* @extends Monster.DOM.CustomElement
|
|
63
52
|
*/
|
|
64
53
|
class CustomControl extends CustomElement {
|
|
65
54
|
/**
|
|
@@ -74,7 +63,6 @@ class CustomControl extends CustomElement {
|
|
|
74
63
|
*
|
|
75
64
|
* @inheritdoc
|
|
76
65
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
77
|
-
* @since 1.7.0
|
|
78
66
|
*/
|
|
79
67
|
constructor() {
|
|
80
68
|
super();
|
|
@@ -117,14 +105,12 @@ class CustomControl extends CustomElement {
|
|
|
117
105
|
*
|
|
118
106
|
* @see [attachInternals()]{@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/attachInternals}
|
|
119
107
|
* @see [Custom Elements Face Example]{@link https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements-face-example}
|
|
120
|
-
* @since 1.14.0
|
|
121
108
|
* @return {boolean}
|
|
122
109
|
*/
|
|
123
110
|
static formAssociated = true;
|
|
124
111
|
|
|
125
112
|
/**
|
|
126
113
|
* @inheritdoc
|
|
127
|
-
* @since 1.14.0
|
|
128
114
|
**/
|
|
129
115
|
get defaults() {
|
|
130
116
|
return extend({}, super.defaults);
|
|
@@ -135,7 +121,6 @@ class CustomControl extends CustomElement {
|
|
|
135
121
|
*
|
|
136
122
|
* This is a method of [internal API](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals), which is a part of the web standard for custom elements.
|
|
137
123
|
*
|
|
138
|
-
* @since 1.14.0
|
|
139
124
|
* @throws {Error} the value getter must be overwritten by the derived class
|
|
140
125
|
*/
|
|
141
126
|
get value() {
|
|
@@ -148,7 +133,6 @@ class CustomControl extends CustomElement {
|
|
|
148
133
|
* This is a method of [internal API](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals), which is a part of the web standard for custom elements.
|
|
149
134
|
*
|
|
150
135
|
* @param {*} value The value to set.
|
|
151
|
-
* @since 1.14.0
|
|
152
136
|
* @throws {Error} the value setter must be overwritten by the derived class
|
|
153
137
|
*/
|
|
154
138
|
set value(value) {
|
|
@@ -159,7 +143,6 @@ class CustomControl extends CustomElement {
|
|
|
159
143
|
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
|
|
160
144
|
*
|
|
161
145
|
* @return {NodeList}
|
|
162
|
-
* @since 1.14.0
|
|
163
146
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/labels}
|
|
164
147
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
165
148
|
*/
|
|
@@ -201,7 +184,6 @@ class CustomControl extends CustomElement {
|
|
|
201
184
|
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
|
|
202
185
|
*
|
|
203
186
|
* @return {string}
|
|
204
|
-
* @since 1.14.0
|
|
205
187
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/validationMessage
|
|
206
188
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
207
189
|
*/
|
|
@@ -213,7 +195,6 @@ class CustomControl extends CustomElement {
|
|
|
213
195
|
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
|
|
214
196
|
*
|
|
215
197
|
* @return {boolean}
|
|
216
|
-
* @since 1.14.0
|
|
217
198
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/willValidate
|
|
218
199
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
219
200
|
*/
|
|
@@ -225,7 +206,6 @@ class CustomControl extends CustomElement {
|
|
|
225
206
|
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
|
|
226
207
|
*
|
|
227
208
|
* @return {boolean}
|
|
228
|
-
* @since 1.14.0
|
|
229
209
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/states
|
|
230
210
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
231
211
|
*/
|
|
@@ -237,7 +217,6 @@ class CustomControl extends CustomElement {
|
|
|
237
217
|
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
|
|
238
218
|
*
|
|
239
219
|
* @return {HTMLFontElement|null}
|
|
240
|
-
* @since 1.14.0
|
|
241
220
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/form
|
|
242
221
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
243
222
|
*/
|
|
@@ -259,7 +238,6 @@ class CustomControl extends CustomElement {
|
|
|
259
238
|
*
|
|
260
239
|
* @param {File|string|FormData} value
|
|
261
240
|
* @param {File|string|FormData} state
|
|
262
|
-
* @since 1.14.0
|
|
263
241
|
* @return {undefined}
|
|
264
242
|
* @throws {DOMException} NotSupportedError
|
|
265
243
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
@@ -275,7 +253,6 @@ class CustomControl extends CustomElement {
|
|
|
275
253
|
* @param {string|undefined} message
|
|
276
254
|
* @param {HTMLElement} anchor
|
|
277
255
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/setValidity
|
|
278
|
-
* @since 1.14.0
|
|
279
256
|
* @return {undefined}
|
|
280
257
|
* @throws {DOMException} NotSupportedError
|
|
281
258
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
@@ -288,7 +265,6 @@ class CustomControl extends CustomElement {
|
|
|
288
265
|
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
|
|
289
266
|
*
|
|
290
267
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/checkValidity
|
|
291
|
-
* @since 1.14.0
|
|
292
268
|
* @return {boolean}
|
|
293
269
|
* @throws {DOMException} NotSupportedError
|
|
294
270
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
@@ -301,7 +277,6 @@ class CustomControl extends CustomElement {
|
|
|
301
277
|
* This is a method of [internal api](https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals)
|
|
302
278
|
*
|
|
303
279
|
* @return {boolean}
|
|
304
|
-
* @since 1.14.0
|
|
305
280
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/ElementInternals/reportValidity
|
|
306
281
|
* @throws {Error} the ElementInternals is not supported and a polyfill is necessary
|
|
307
282
|
* @throws {DOMException} NotSupportedError
|
|
@@ -170,10 +170,6 @@ const scriptHostElementSymbol = Symbol("scriptHostElement");
|
|
|
170
170
|
*
|
|
171
171
|
* You can create an instance of the object via the `document.createElement()` function.
|
|
172
172
|
*
|
|
173
|
-
* ## Interaction
|
|
174
|
-
*
|
|
175
|
-
* <img src="./images/customelement-sequencediagram.png">
|
|
176
|
-
*
|
|
177
173
|
* ## Styling
|
|
178
174
|
*
|
|
179
175
|
* To display custom elements optimally, the `:defined` pseudo-class can be used. To prevent custom elements from being displayed and flickering until the control is registered,
|
|
@@ -234,12 +230,9 @@ const scriptHostElementSymbol = Symbol("scriptHostElement");
|
|
|
234
230
|
* More information about Custom Elements can be found in the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements).
|
|
235
231
|
* And in the [HTML Standard](https://html.spec.whatwg.org/multipage/custom-elements.html#custom-elements) or in the [WHATWG Wiki](https://wiki.whatwg.org/wiki/Custom_Elements).
|
|
236
232
|
*
|
|
237
|
-
* @externalExample ../../example/dom/theme.mjs
|
|
238
233
|
* @license AGPLv3
|
|
239
234
|
* @since 1.7.0
|
|
240
235
|
* @copyright schukai GmbH
|
|
241
|
-
* @memberOf Monster.DOM
|
|
242
|
-
* @extends external:HTMLElement
|
|
243
236
|
* @summary A base class for HTML5 custom controls.
|
|
244
237
|
*/
|
|
245
238
|
class CustomElement extends HTMLElement {
|
|
@@ -250,7 +243,6 @@ class CustomElement extends HTMLElement {
|
|
|
250
243
|
* IMPORTANT: CustomControls instances are not created via the constructor, but either via a tag in the HTML or via <code>document.createElement()</code>.
|
|
251
244
|
*
|
|
252
245
|
* @throws {Error} the options attribute does not contain a valid json definition.
|
|
253
|
-
* @since 1.7.0
|
|
254
246
|
*/
|
|
255
247
|
constructor() {
|
|
256
248
|
super();
|
|
@@ -30,11 +30,9 @@ const internalTranslationSymbol = Symbol("internalTranslation");
|
|
|
30
30
|
/**
|
|
31
31
|
* The Formatter extends the Text.Formatter with the possibility to replace the key by a translation.
|
|
32
32
|
*
|
|
33
|
-
* @externalExample ../../example/i18n/formatter.mjs
|
|
34
33
|
* @license AGPLv3
|
|
35
34
|
* @since 1.26.0
|
|
36
35
|
* @copyright schukai GmbH
|
|
37
|
-
* @memberOf Monster.I18n
|
|
38
36
|
*/
|
|
39
37
|
class Formatter extends TextFormatter {
|
|
40
38
|
/**
|
package/source/i18n/locale.mjs
CHANGED
|
@@ -20,14 +20,12 @@ import { clone } from "../util/clone.mjs";
|
|
|
20
20
|
export { Locale, parseLocale };
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
* @memberOf Monster.I18n
|
|
24
23
|
* @type {symbol}
|
|
25
24
|
*/
|
|
26
25
|
const propertiesSymbol = Symbol("properties");
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
28
|
* @type {symbol}
|
|
30
|
-
* @memberOf Monster.I18n
|
|
31
29
|
*/
|
|
32
30
|
const localeStringSymbol = Symbol("localeString");
|
|
33
31
|
|
package/source/i18n/provider.mjs
CHANGED
|
@@ -26,7 +26,6 @@ import { Translations } from "./translations.mjs";
|
|
|
26
26
|
export { Provider, translationsLinkSymbol };
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @memberOf Monster.I18n
|
|
30
29
|
* @type {symbol}
|
|
31
30
|
* @license AGPLv3
|
|
32
31
|
* @since 3.9.0
|
|
@@ -42,7 +41,6 @@ const translationsLinkSymbol = Symbol.for(
|
|
|
42
41
|
* @license AGPLv3
|
|
43
42
|
* @since 1.13.0
|
|
44
43
|
* @copyright schukai GmbH
|
|
45
|
-
* @memberOf Monster.I18n
|
|
46
44
|
* @see {@link https://datatracker.ietf.org/doc/html/rfc3066}
|
|
47
45
|
*/
|
|
48
46
|
class Provider extends BaseWithOptions {
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
import { Handler } from "
|
|
16
|
-
import { LogEntry } from "
|
|
15
|
+
import { Handler } from "./handler.mjs";
|
|
16
|
+
import { LogEntry } from "./logentry.mjs";
|
|
17
17
|
|
|
18
18
|
import { Base } from "../types/base.mjs";
|
|
19
19
|
import {
|
|
@@ -27,49 +27,41 @@ export { Logger, ALL, TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF };
|
|
|
27
27
|
/**
|
|
28
28
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
29
29
|
* @type {number}
|
|
30
|
-
* @memberOf Monster.Logging
|
|
31
30
|
*/
|
|
32
31
|
const ALL = 255;
|
|
33
32
|
/**
|
|
34
33
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
35
34
|
* @type {number}
|
|
36
|
-
* @memberOf Monster.Logging
|
|
37
35
|
*/
|
|
38
36
|
const TRACE = 64;
|
|
39
37
|
/**
|
|
40
38
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
41
39
|
* @type {number}
|
|
42
|
-
* @memberOf Monster.Logging
|
|
43
40
|
*/
|
|
44
41
|
const DEBUG = 32;
|
|
45
42
|
/**
|
|
46
43
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
47
44
|
* @type {number}
|
|
48
|
-
* @memberOf Monster.Logging
|
|
49
45
|
*/
|
|
50
46
|
const INFO = 16;
|
|
51
47
|
/**
|
|
52
48
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
53
49
|
* @type {number}
|
|
54
|
-
* @memberOf Monster.Logging
|
|
55
50
|
*/
|
|
56
51
|
const WARN = 8;
|
|
57
52
|
/**
|
|
58
53
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
59
54
|
* @type {number}
|
|
60
|
-
* @memberOf Monster.Logging
|
|
61
55
|
*/
|
|
62
56
|
const ERROR = 4;
|
|
63
57
|
/**
|
|
64
58
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
65
59
|
* @type {number}
|
|
66
|
-
* @memberOf Monster.Logging
|
|
67
60
|
*/
|
|
68
61
|
const FATAL = 2;
|
|
69
62
|
/**
|
|
70
63
|
* ALL > TRACE > DEBUG > INFO > WARN > ERROR > FATAL > OFF
|
|
71
64
|
* @type {number}
|
|
72
|
-
* @memberOf Monster.Logging
|
|
73
65
|
*/
|
|
74
66
|
const OFF = 0;
|
|
75
67
|
|
|
@@ -79,7 +71,6 @@ const OFF = 0;
|
|
|
79
71
|
* @license AGPLv3
|
|
80
72
|
* @since 1.5.0
|
|
81
73
|
* @copyright schukai GmbH
|
|
82
|
-
* @memberOf Monster.Logging
|
|
83
74
|
*/
|
|
84
75
|
class Logger extends Base {
|
|
85
76
|
/**
|
|
@@ -32,8 +32,7 @@ export { BaseWithOptions };
|
|
|
32
32
|
* @license AGPLv3
|
|
33
33
|
* @since 1.13.0
|
|
34
34
|
* @copyright schukai GmbH
|
|
35
|
-
* @
|
|
36
|
-
* @deprecated since 3.15.0 use {@link Monster.Types.Base} with {@link Monster.Types.equipWithInternal} instead.
|
|
35
|
+
* @deprecated since 3.15.0 use `BaseWithOptions` instead of `BaseWithOptions`
|
|
37
36
|
*/
|
|
38
37
|
class BaseWithOptions extends Base {
|
|
39
38
|
/**
|
|
@@ -31,11 +31,7 @@ const isNodeListSymbol = Symbol("isNodeList");
|
|
|
31
31
|
/**
|
|
32
32
|
* Represents a recursive iterator for traversing nodes in a DOM tree.
|
|
33
33
|
*
|
|
34
|
-
* @externalExample ../../example/types/noderecursiveiterator.mjs
|
|
35
|
-
* @license AGPLv3
|
|
36
34
|
* @since 1.26.0
|
|
37
|
-
* @copyright schukai GmbH
|
|
38
|
-
* @memberOf Monster.Types
|
|
39
35
|
* @summary An iterator to run recursively through a tree of nodes
|
|
40
36
|
* @extends Base
|
|
41
37
|
*/
|
|
@@ -91,7 +87,7 @@ class NodeRecursiveIterator extends Base {
|
|
|
91
87
|
|
|
92
88
|
/**
|
|
93
89
|
* @param {function} callback
|
|
94
|
-
* @return {
|
|
90
|
+
* @return {NodeRecursiveIterator}
|
|
95
91
|
*/
|
|
96
92
|
forEach(callback) {
|
|
97
93
|
for (const node of this) {
|
|
@@ -23,11 +23,8 @@ export { ObservableQueue };
|
|
|
23
23
|
*
|
|
24
24
|
* `Queue.add()` and `Queue.clear()` notify all observers.
|
|
25
25
|
*
|
|
26
|
-
* @externalExample ../../example/types/queue.mjs
|
|
27
|
-
* @license AGPLv3
|
|
28
26
|
* @since 3.3.0
|
|
29
27
|
* @copyright schukai GmbH
|
|
30
|
-
* @memberOf Monster.Types
|
|
31
28
|
* @summary An observable Queue (Fifo)
|
|
32
29
|
*/
|
|
33
30
|
class ObservableQueue extends Queue {
|
|
@@ -44,7 +41,6 @@ class ObservableQueue extends Queue {
|
|
|
44
41
|
/**
|
|
45
42
|
* This method is called by the `instanceof` operator.
|
|
46
43
|
* @returns {symbol}
|
|
47
|
-
* @since 2.1.0
|
|
48
44
|
*/
|
|
49
45
|
static get [instanceSymbol]() {
|
|
50
46
|
return Symbol.for("@schukai/monster/types/observablequeue");
|
|
@@ -53,11 +53,8 @@ export { Observer };
|
|
|
53
53
|
*
|
|
54
54
|
* The callback function must have as many parameters as arguments are given.
|
|
55
55
|
*
|
|
56
|
-
* @externalExample ../../example/types/observer.mjs
|
|
57
56
|
* @license AGPLv3
|
|
58
57
|
* @since 1.0.0
|
|
59
|
-
* @copyright schukai GmbH
|
|
60
|
-
* @memberOf Monster.Types
|
|
61
58
|
*/
|
|
62
59
|
class Observer extends Base {
|
|
63
60
|
/**
|
package/source/types/queue.mjs
CHANGED
|
@@ -0,0 +1,56 @@
|
|
|
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 { internalSymbol } from "../../constants.mjs";
|
|
16
|
+
import { getGlobalFunction } from "../../types/global.mjs";
|
|
17
|
+
import { validateFunction, validateInteger } from "../../types/validate.mjs";
|
|
18
|
+
|
|
19
|
+
export { Callback };
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
class Callback {
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
* @param {function} callback
|
|
28
|
+
* @param {int|undefined} time
|
|
29
|
+
* @throws {TypeError} value is not a function
|
|
30
|
+
* @throws {TypeError} value is not an integer
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
constructor(callback, time) {
|
|
34
|
+
this[internalSymbol] = {
|
|
35
|
+
callback: validateFunction(callback),
|
|
36
|
+
time: validateInteger(time ?? 0),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @private
|
|
42
|
+
* @param {*} data
|
|
43
|
+
* @return {Promise}
|
|
44
|
+
*/
|
|
45
|
+
run(data) {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
getGlobalFunction("setTimeout")(() => {
|
|
48
|
+
try {
|
|
49
|
+
resolve(this[internalSymbol].callback(data));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
reject(e);
|
|
52
|
+
}
|
|
53
|
+
}, this[internalSymbol].time);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -14,52 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
import { internalSymbol } from "../constants.mjs";
|
|
16
16
|
import { Base } from "../types/base.mjs";
|
|
17
|
-
import { getGlobalFunction } from "../types/global.mjs";
|
|
18
17
|
import { isFunction, isInteger } from "../types/is.mjs";
|
|
19
18
|
import { Queue } from "../types/queue.mjs";
|
|
20
|
-
import {
|
|
19
|
+
import { Callback } from "./processing/callback.mjs";
|
|
21
20
|
|
|
22
21
|
export { Processing };
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
class Callback {
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {function} callback
|
|
31
|
-
* @param {int|undefined} time
|
|
32
|
-
* @throws {TypeError} value is not a function
|
|
33
|
-
* @throws {TypeError} value is not an integer
|
|
34
|
-
* @private
|
|
35
|
-
*/
|
|
36
|
-
constructor(callback, time) {
|
|
37
|
-
this[internalSymbol] = {
|
|
38
|
-
callback: validateFunction(callback),
|
|
39
|
-
time: validateInteger(time ?? 0),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* @private
|
|
45
|
-
* @param {*} data
|
|
46
|
-
* @return {Promise}
|
|
47
|
-
*/
|
|
48
|
-
run(data) {
|
|
49
|
-
return new Promise((resolve, reject) => {
|
|
50
|
-
getGlobalFunction("setTimeout")(() => {
|
|
51
|
-
try {
|
|
52
|
-
resolve(this[internalSymbol].callback(data));
|
|
53
|
-
} catch (e) {
|
|
54
|
-
reject(e);
|
|
55
|
-
}
|
|
56
|
-
}, this[internalSymbol].time);
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* This class allows to execute several functions in order.
|
|
24
|
+
* This class allows executing several functions in order.
|
|
63
25
|
*
|
|
64
26
|
* Functions and timeouts can be passed. If a timeout is passed, it applies to all further functions.
|
|
65
27
|
* In the example
|