@schukai/monster 1.14.0 → 1.15.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +38 -0
- package/README.md +5 -5
- package/dist/modules/constants.js +2 -2
- package/dist/modules/constraints/abstract.js +2 -2
- package/dist/modules/constraints/abstractoperator.js +2 -2
- package/dist/modules/constraints/andoperator.js +2 -2
- package/dist/modules/constraints/invalid.js +2 -2
- package/dist/modules/constraints/isarray.js +2 -2
- package/dist/modules/constraints/isobject.js +2 -2
- package/dist/modules/constraints/namespace.js +1 -1
- package/dist/modules/constraints/oroperator.js +2 -2
- package/dist/modules/constraints/valid.js +2 -2
- package/dist/modules/data/buildmap.js +2 -2
- package/dist/modules/data/diff.js +2 -2
- package/dist/modules/data/extend.js +2 -2
- package/dist/modules/data/namespace.js +1 -1
- package/dist/modules/data/pathfinder.js +2 -2
- package/dist/modules/data/pipe.js +2 -2
- package/dist/modules/data/transformer.js +2 -2
- package/dist/modules/dom/assembler.js +2 -2
- package/dist/modules/dom/attributes.js +2 -2
- package/dist/modules/dom/constants.js +1 -1
- package/dist/modules/dom/customcontrol.js +2 -2
- package/dist/modules/dom/customelement.js +2 -2
- package/dist/modules/dom/events.js +2 -2
- package/dist/modules/dom/locale.js +2 -2
- package/dist/modules/dom/namespace.js +1 -1
- package/dist/modules/dom/template.js +2 -2
- package/dist/modules/dom/theme.js +2 -2
- package/dist/modules/dom/updater.js +2 -2
- package/dist/modules/dom/util.js +2 -2
- package/dist/modules/i18n/locale.js +2 -2
- package/dist/modules/i18n/namespace.js +1 -1
- package/dist/modules/i18n/provider.js +2 -2
- package/dist/modules/i18n/providers/fetch.js +2 -2
- package/dist/modules/i18n/providers/namespace.js +1 -1
- package/dist/modules/i18n/translations.js +2 -2
- package/dist/modules/logging/handler/console.js +2 -2
- package/dist/modules/logging/handler/namespace.js +1 -1
- package/dist/modules/logging/handler.js +2 -2
- package/dist/modules/logging/logentry.js +2 -2
- package/dist/modules/logging/logger.js +2 -2
- package/dist/modules/logging/namespace.js +1 -1
- package/dist/modules/math/namespace.js +1 -1
- package/dist/modules/math/random.js +2 -2
- package/dist/modules/monster.js +2 -2
- package/dist/modules/namespace.js +2 -2
- package/dist/modules/text/formatter.js +2 -2
- package/dist/modules/text/namespace.js +1 -1
- package/dist/modules/types/base.js +2 -2
- package/dist/modules/types/basewithoptions.js +2 -2
- package/dist/modules/types/global.js +2 -2
- package/dist/modules/types/id.js +2 -2
- package/dist/modules/types/is.js +2 -2
- package/dist/modules/types/namespace.js +1 -1
- package/dist/modules/types/observer.js +2 -2
- package/dist/modules/types/observerlist.js +2 -2
- package/dist/modules/types/proxyobserver.js +2 -2
- package/dist/modules/types/queue.js +2 -2
- package/dist/modules/types/randomid.js +2 -2
- package/dist/modules/types/stack.js +2 -2
- package/dist/modules/types/tokenlist.js +2 -2
- package/dist/modules/types/typeof.js +2 -2
- package/dist/modules/types/uniquequeue.js +2 -2
- package/dist/modules/types/validate.js +2 -2
- package/dist/modules/types/version.js +2 -2
- package/dist/modules/util/clone.js +2 -2
- package/dist/modules/util/comparator.js +2 -2
- package/dist/modules/util/freeze.js +2 -2
- package/dist/modules/util/namespace.js +1 -1
- package/dist/monster.dev.js +8263 -7501
- package/dist/monster.dev.js.map +1 -1
- package/dist/monster.js +2 -9
- package/package.json +1 -1
- package/source/constants.js +6 -5
- package/source/constraints/abstract.js +2 -2
- package/source/constraints/abstractoperator.js +4 -4
- package/source/constraints/andoperator.js +8 -8
- package/source/constraints/invalid.js +6 -6
- package/source/constraints/isarray.js +7 -7
- package/source/constraints/isobject.js +7 -7
- package/source/constraints/namespace.js +2 -2
- package/source/constraints/oroperator.js +8 -8
- package/source/constraints/valid.js +7 -7
- package/source/data/buildmap.js +15 -15
- package/source/data/diff.js +9 -9
- package/source/data/extend.js +55 -13
- package/source/data/namespace.js +2 -2
- package/source/data/pathfinder.js +13 -14
- package/source/data/pipe.js +8 -8
- package/source/data/transformer.js +10 -11
- package/source/dom/assembler.js +7 -7
- package/source/dom/attributes.js +27 -28
- package/source/dom/constants.js +1 -2
- package/source/dom/customcontrol.js +90 -128
- package/source/dom/customelement.js +166 -71
- package/source/dom/events.js +9 -9
- package/source/dom/locale.js +5 -5
- package/source/dom/namespace.js +2 -2
- package/source/dom/template.js +30 -19
- package/source/dom/theme.js +8 -9
- package/source/dom/updater.js +43 -26
- package/source/dom/util.js +11 -11
- package/source/i18n/locale.js +7 -7
- package/source/i18n/namespace.js +1 -1
- package/source/i18n/provider.js +6 -6
- package/source/i18n/providers/fetch.js +10 -10
- package/source/i18n/translations.js +5 -5
- package/source/logging/handler/console.js +5 -5
- package/source/logging/handler/namespace.js +1 -1
- package/source/logging/handler.js +8 -8
- package/source/logging/logentry.js +5 -5
- package/source/logging/logger.js +5 -5
- package/source/logging/namespace.js +2 -2
- package/source/math/namespace.js +2 -2
- package/source/math/random.js +5 -5
- package/source/monster.js +48 -44
- package/source/namespace.js +2 -2
- package/source/text/formatter.js +6 -7
- package/source/text/namespace.js +1 -1
- package/source/types/base.js +4 -5
- package/source/types/basewithoptions.js +10 -9
- package/source/types/global.js +7 -7
- package/source/types/id.js +7 -7
- package/source/types/is.js +22 -22
- package/source/types/namespace.js +2 -2
- package/source/types/observer.js +7 -7
- package/source/types/observerlist.js +4 -4
- package/source/types/proxyobserver.js +32 -26
- package/source/types/queue.js +13 -7
- package/source/types/randomid.js +6 -6
- package/source/types/stack.js +11 -4
- package/source/types/tokenlist.js +9 -9
- package/source/types/typeof.js +5 -5
- package/source/types/uniquequeue.js +14 -7
- package/source/types/validate.js +27 -27
- package/source/types/version.js +9 -9
- package/source/util/clone.js +6 -6
- package/source/util/comparator.js +7 -7
- package/source/util/freeze.js +7 -7
- package/source/util/namespace.js +2 -2
- package/test/cases/data/extend.js +66 -13
- package/test/cases/dom/customcontrol.js +17 -3
- package/test/cases/dom/customelement.js +65 -7
- package/test/cases/dom/template.js +40 -1
- package/test/cases/monster.js +1 -1
- package/test/cases/types/proxyobserver.js +9 -0
- package/test/web/monster-dev.html +3 -3
- package/test/web/monster.html +2 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +3 -3
package/source/dom/events.js
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {validateInstance, validateString} from "../types/validate.js";
|
8
8
|
import {findClosestByAttribute} from "./attributes.js";
|
9
9
|
import {getDocument} from "./util.js";
|
10
10
|
|
@@ -13,7 +13,7 @@ import {getDocument} from "./util.js";
|
|
13
13
|
*
|
14
14
|
* ```
|
15
15
|
* <script type="module">
|
16
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
16
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/events.js';
|
17
17
|
* console.log(new Monster.DOM.fireEvent())
|
18
18
|
* </script>
|
19
19
|
* ```
|
@@ -22,7 +22,7 @@ import {getDocument} from "./util.js";
|
|
22
22
|
*
|
23
23
|
* ```
|
24
24
|
* <script type="module">
|
25
|
-
* import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
25
|
+
* import {fireEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/events.js';
|
26
26
|
* console.log(fireEvent())
|
27
27
|
* </script>
|
28
28
|
* ```
|
@@ -64,14 +64,14 @@ function fireEvent(element, type) {
|
|
64
64
|
}
|
65
65
|
|
66
66
|
/**
|
67
|
-
* This function gets the path `Event.composedPath()` from an event and tries to find the next element
|
67
|
+
* This function gets the path `Event.composedPath()` from an event and tries to find the next element
|
68
68
|
* up the tree `element.closest()` with the attribute and value. If no value is specified, only the attribute is searched.
|
69
69
|
*
|
70
70
|
* You can call the function via the monster namespace `new Monster.DOM.findTargetElementFromEvent()`.
|
71
71
|
*
|
72
72
|
* ```
|
73
73
|
* <script type="module">
|
74
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
74
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/events.js';
|
75
75
|
* console.log(new Monster.DOM.findTargetElementFromEvent())
|
76
76
|
* </script>
|
77
77
|
* ```
|
@@ -80,11 +80,11 @@ function fireEvent(element, type) {
|
|
80
80
|
*
|
81
81
|
* ```
|
82
82
|
* <script type="module">
|
83
|
-
* import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
83
|
+
* import {findTargetElementFromEvent} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/events.js';
|
84
84
|
* console.log(findTargetElementFromEvent())
|
85
85
|
* </script>
|
86
86
|
* ```
|
87
|
-
*
|
87
|
+
*
|
88
88
|
* @since 1.14.0
|
89
89
|
* @param {Event} event
|
90
90
|
* @param {string} attributeName
|
@@ -113,5 +113,5 @@ function findTargetElementFromEvent(event, attributeName, attributeValue) {
|
|
113
113
|
}
|
114
114
|
|
115
115
|
|
116
|
-
|
116
|
+
assignToNamespace('Monster.DOM', findTargetElementFromEvent, fireEvent);
|
117
117
|
export {Monster, findTargetElementFromEvent, fireEvent}
|
package/source/dom/locale.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
import {parseLocale} from "../i18n/locale.js";
|
3
4
|
/**
|
4
5
|
* @author schukai GmbH
|
5
6
|
*/
|
6
|
-
|
7
|
-
import {Monster, parseLocale} from "../i18n/locale.js";
|
7
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
8
8
|
import {getDocument} from "./util.js";
|
9
9
|
|
10
10
|
/**
|
@@ -20,7 +20,7 @@ const DEFAULT_LANGUAGE = 'en';
|
|
20
20
|
*
|
21
21
|
* ```
|
22
22
|
* <script type="module">
|
23
|
-
* import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
23
|
+
* import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/locale.js';
|
24
24
|
* console.log(new Monster.DOM.getLocaleOfDocument())
|
25
25
|
* </script>
|
26
26
|
* ```
|
@@ -29,7 +29,7 @@ const DEFAULT_LANGUAGE = 'en';
|
|
29
29
|
*
|
30
30
|
* ```
|
31
31
|
* <script type="module">
|
32
|
-
* import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
32
|
+
* import {getLocaleOfDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/locale.js';
|
33
33
|
* console.log(new getLocaleOfDocument())
|
34
34
|
* </script>
|
35
35
|
* ```
|
@@ -55,5 +55,5 @@ function getLocaleOfDocument() {
|
|
55
55
|
return parseLocale(DEFAULT_LANGUAGE);
|
56
56
|
}
|
57
57
|
|
58
|
-
|
58
|
+
assignToNamespace('Monster.DOM', getLocaleOfDocument);
|
59
59
|
export {Monster, getLocaleOfDocument}
|
package/source/dom/namespace.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
/**
|
4
4
|
* In this namespace you will find classes and methods for handling the DOM.
|
5
|
-
*
|
5
|
+
*
|
6
6
|
* @namespace Monster/DOM
|
7
7
|
* @author schukai GmbH
|
8
8
|
*/
|
@@ -11,4 +11,4 @@
|
|
11
11
|
* @private
|
12
12
|
* @type {string}
|
13
13
|
*/
|
14
|
-
const namespace="Monster.DOM";
|
14
|
+
const namespace = "Monster.DOM";
|
package/source/dom/template.js
CHANGED
@@ -3,11 +3,10 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
8
|
-
import {validateString} from "../types/validate.js";
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {Base} from '../types/base.js';
|
9
8
|
import {getGlobalFunction, getGlobalObject} from '../types/global.js';
|
10
|
-
import {validateInstance} from "../types/validate.js";
|
9
|
+
import {validateInstance, validateString} from "../types/validate.js";
|
11
10
|
import {getDocumentTheme} from "./theme.js";
|
12
11
|
|
13
12
|
/**
|
@@ -15,7 +14,7 @@ import {getDocumentTheme} from "./theme.js";
|
|
15
14
|
*
|
16
15
|
* ```
|
17
16
|
* <script type="module">
|
18
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
17
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/template.js';
|
19
18
|
* console.log(new Monster.DOM.Template())
|
20
19
|
* </script>
|
21
20
|
* ```
|
@@ -24,7 +23,7 @@ import {getDocumentTheme} from "./theme.js";
|
|
24
23
|
*
|
25
24
|
* ```
|
26
25
|
* <script type="module">
|
27
|
-
* import {Template} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
26
|
+
* import {Template} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/template.js';
|
28
27
|
* console.log(new Template())
|
29
28
|
* </script>
|
30
29
|
* ```
|
@@ -74,7 +73,7 @@ class Template extends Base {
|
|
74
73
|
*
|
75
74
|
* ```
|
76
75
|
* <script type="module">
|
77
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
76
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/template.js';
|
78
77
|
* console.log(Monster.DOM.findDocumentTemplate())
|
79
78
|
* </script>
|
80
79
|
* ```
|
@@ -83,13 +82,13 @@ class Template extends Base {
|
|
83
82
|
*
|
84
83
|
* ```
|
85
84
|
* <script type="module">
|
86
|
-
* import {findTemplate} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
85
|
+
* import {findTemplate} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/template.js';
|
87
86
|
* console.log(findDocumentTemplate())
|
88
87
|
* </script>
|
89
88
|
* ```
|
90
89
|
*
|
91
90
|
* @param {string} id
|
92
|
-
* @param {Node}
|
91
|
+
* @param {Node} currentNode
|
93
92
|
* @return {Template}
|
94
93
|
* @since 1.7.0
|
95
94
|
* @copyright schukai GmbH
|
@@ -97,29 +96,41 @@ class Template extends Base {
|
|
97
96
|
* @throws {Error} template id not found.
|
98
97
|
* @throws {TypeError} value is not a string
|
99
98
|
*/
|
100
|
-
function findDocumentTemplate(id,
|
99
|
+
function findDocumentTemplate(id, currentNode) {
|
101
100
|
validateString(id);
|
102
|
-
|
103
|
-
if (!(
|
104
|
-
|
101
|
+
|
102
|
+
if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
|
103
|
+
|
104
|
+
if (currentNode instanceof Node) {
|
105
|
+
currentNode = currentNode.getRootNode();
|
106
|
+
|
107
|
+
if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
|
108
|
+
currentNode = currentNode.ownerDocument;
|
109
|
+
}
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
if (!(currentNode instanceof Document || currentNode instanceof DocumentFragment)) {
|
114
|
+
currentNode = getGlobalObject('document');
|
115
|
+
}
|
105
116
|
}
|
106
|
-
|
117
|
+
|
107
118
|
const HTMLTemplateElement = getGlobalFunction('HTMLTemplateElement');
|
108
119
|
|
109
120
|
let theme = getDocumentTheme()
|
110
121
|
let themedID = id + '-' + theme.getName();
|
111
122
|
|
112
|
-
let template =
|
123
|
+
let template = currentNode.getElementById(themedID);
|
113
124
|
if (template instanceof HTMLTemplateElement) {
|
114
125
|
return new Template(template);
|
115
126
|
}
|
116
127
|
|
117
|
-
template =
|
128
|
+
template = currentNode.getElementById(id);
|
118
129
|
if (template instanceof HTMLTemplateElement) {
|
119
130
|
return new Template(template);
|
120
131
|
}
|
121
|
-
|
122
|
-
if(
|
132
|
+
|
133
|
+
if (currentNode !== getGlobalObject('document')) {
|
123
134
|
return findDocumentTemplate(id)
|
124
135
|
}
|
125
136
|
|
@@ -127,7 +138,7 @@ function findDocumentTemplate(id, root) {
|
|
127
138
|
}
|
128
139
|
|
129
140
|
|
130
|
-
|
141
|
+
assignToNamespace('Monster.DOM', Template, findDocumentTemplate);
|
131
142
|
export {Monster, Template, findDocumentTemplate}
|
132
143
|
|
133
144
|
|
package/source/dom/theme.js
CHANGED
@@ -3,20 +3,19 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
8
|
-
import {validateString} from "../types/validate.js";
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {Base} from '../types/base.js';
|
9
8
|
import {getGlobalObject} from '../types/global.js';
|
9
|
+
import {validateString} from "../types/validate.js";
|
10
10
|
import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.js";
|
11
11
|
|
12
12
|
|
13
|
-
|
14
13
|
/**
|
15
14
|
* You can call the method via the monster namespace `new Monster.DOM.Theme()`.
|
16
15
|
*
|
17
16
|
* ```
|
18
17
|
* <script type="module">
|
19
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
18
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/theme.js';
|
20
19
|
* console.log(new Monster.DOM.Theme())
|
21
20
|
* </script>
|
22
21
|
* ```
|
@@ -25,14 +24,14 @@ import {ATTRIBUTE_THEME_NAME, DEFAULT_THEME} from "./constants.js";
|
|
25
24
|
*
|
26
25
|
* ```
|
27
26
|
* <script type="module">
|
28
|
-
* import {Theme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
27
|
+
* import {Theme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/theme.js';
|
29
28
|
* console.log(new Theme())
|
30
29
|
* </script>
|
31
30
|
* ```
|
32
|
-
*
|
31
|
+
*
|
33
32
|
* @example
|
34
33
|
*
|
35
|
-
* import {getDocumentTheme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
34
|
+
* import {getDocumentTheme} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/theme.js';
|
36
35
|
*
|
37
36
|
* const theme = getDocumentTheme();
|
38
37
|
* console.log(theme.getName());
|
@@ -96,5 +95,5 @@ function getDocumentTheme() {
|
|
96
95
|
|
97
96
|
}
|
98
97
|
|
99
|
-
|
98
|
+
assignToNamespace('Monster.DOM', Theme, getDocumentTheme);
|
100
99
|
export {Monster, Theme, getDocumentTheme}
|
package/source/dom/updater.js
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
+
import {Diff} from "../data/diff.js";
|
3
4
|
import {Pathfinder} from "../data/pathfinder.js";
|
4
5
|
import {Pipe} from "../data/pipe.js";
|
5
|
-
import {Base, Monster} from "../types/base.js";
|
6
|
-
import {isInstance, isArray} from "../types/is.js";
|
7
|
-
import {Observer} from "../types/observer.js";
|
8
|
-
import {ProxyObserver} from "../types/proxyobserver.js";
|
9
|
-
import {validateInstance, validateArray} from "../types/validate.js";
|
10
|
-
import {clone} from "../util/clone.js";
|
11
|
-
import {Diff} from "../data/diff.js";
|
12
6
|
import {
|
13
|
-
ATTRIBUTE_UPDATER_REPLACE,
|
14
7
|
ATTRIBUTE_UPDATER_ATTRIBUTES,
|
8
|
+
ATTRIBUTE_UPDATER_BIND,
|
15
9
|
ATTRIBUTE_UPDATER_INSERT,
|
16
|
-
ATTRIBUTE_UPDATER_REMOVE,
|
17
10
|
ATTRIBUTE_UPDATER_INSERT_REFERENCE,
|
18
|
-
|
11
|
+
ATTRIBUTE_UPDATER_REMOVE,
|
12
|
+
ATTRIBUTE_UPDATER_REPLACE
|
19
13
|
} from "../dom/constants.js";
|
20
|
-
import {findDocumentTemplate} from "./template.js";
|
21
|
-
import {getDocument} from "./util.js";
|
22
|
-
|
23
14
|
/**
|
24
15
|
* @author schukai GmbH
|
25
16
|
*/
|
17
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
18
|
+
import {Base} from "../types/base.js";
|
19
|
+
import {isArray, isInstance, isIterable} from "../types/is.js";
|
20
|
+
import {Observer} from "../types/observer.js";
|
21
|
+
import {ProxyObserver} from "../types/proxyobserver.js";
|
22
|
+
import {validateArray, validateInstance} from "../types/validate.js";
|
23
|
+
import {clone} from "../util/clone.js";
|
24
|
+
import {findDocumentTemplate} from "./template.js";
|
25
|
+
import {getDocument} from "./util.js";
|
26
26
|
|
27
27
|
|
28
28
|
/**
|
@@ -34,7 +34,7 @@ import {getDocument} from "./util.js";
|
|
34
34
|
*
|
35
35
|
* ```
|
36
36
|
* <script type="module">
|
37
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
37
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/updater.js';
|
38
38
|
* console.log(new Monster.DOM.Updater())
|
39
39
|
* </script>
|
40
40
|
* ```
|
@@ -43,14 +43,14 @@ import {getDocument} from "./util.js";
|
|
43
43
|
*
|
44
44
|
* ```
|
45
45
|
* <script type="module">
|
46
|
-
* import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
46
|
+
* import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/updater.js';
|
47
47
|
* console.log(new Updater())
|
48
48
|
* </script>
|
49
49
|
* ```
|
50
50
|
*
|
51
51
|
* @example
|
52
52
|
*
|
53
|
-
* import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
53
|
+
* import {Updater} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/updater.js';
|
54
54
|
*
|
55
55
|
* // First we prepare the html document.
|
56
56
|
* // This is done here via script, but can also be inserted into the document as pure html.
|
@@ -102,6 +102,7 @@ class Updater extends Base {
|
|
102
102
|
this.element = validateInstance(element, HTMLElement);
|
103
103
|
|
104
104
|
if (subject === undefined) subject = {}
|
105
|
+
let a = subject;
|
105
106
|
if (!isInstance(subject, ProxyObserver)) {
|
106
107
|
subject = new ProxyObserver(subject);
|
107
108
|
}
|
@@ -114,7 +115,9 @@ class Updater extends Base {
|
|
114
115
|
* @type {object}
|
115
116
|
*/
|
116
117
|
this.subject = subject.attachObserver(new Observer(() => {
|
118
|
+
|
117
119
|
const s = this.subject.getRealSubject();
|
120
|
+
|
118
121
|
const diff = Diff(this.last, s)
|
119
122
|
this.last = clone(s);
|
120
123
|
|
@@ -174,6 +177,26 @@ class Updater extends Base {
|
|
174
177
|
|
175
178
|
}
|
176
179
|
|
180
|
+
// /**
|
181
|
+
// *
|
182
|
+
// * @param {string} path
|
183
|
+
// * @param {*} value
|
184
|
+
// * @param {boolean} notifyAnyway
|
185
|
+
// * @return {Updater}
|
186
|
+
// * @since 1.15.0
|
187
|
+
// */
|
188
|
+
// setVia(path, value, notifyAnyway) {
|
189
|
+
// if(isBoolean(notifyAnyway)&¬ifyAnyway===true) {
|
190
|
+
// // the key __init__has no further meaning and is only
|
191
|
+
// // used to create the diff for empty objects.
|
192
|
+
// new Pathfinder(this.last).setVia(path, {'__init__': true});
|
193
|
+
//
|
194
|
+
// }
|
195
|
+
//
|
196
|
+
// new Pathfinder(this.subject.getSubject()).setVia(path, value);
|
197
|
+
// return this;
|
198
|
+
// }
|
199
|
+
|
177
200
|
/**
|
178
201
|
* Let the magic begin
|
179
202
|
*
|
@@ -318,10 +341,9 @@ function getControlEventHandler() {
|
|
318
341
|
|
319
342
|
|
320
343
|
// values from customelements
|
321
|
-
} else if ((element?.constructor?.prototype && !!Object.getOwnPropertyDescriptor(element.constructor.prototype, 'value')?.['get'])|| element.hasOwnProperty('value')) {
|
344
|
+
} else if ((element?.constructor?.prototype && !!Object.getOwnPropertyDescriptor(element.constructor.prototype, 'value')?.['get']) || element.hasOwnProperty('value')) {
|
322
345
|
value = element?.['value'];
|
323
346
|
} else {
|
324
|
-
console.log(element);
|
325
347
|
throw new Error("unsupported object");
|
326
348
|
}
|
327
349
|
|
@@ -416,7 +438,7 @@ function insertElement(change) {
|
|
416
438
|
insertPoint = containerElement.lastChild;
|
417
439
|
}
|
418
440
|
|
419
|
-
if (!
|
441
|
+
if (!isIterable(value)) {
|
420
442
|
throw new Error('the value is not iterable');
|
421
443
|
}
|
422
444
|
|
@@ -470,12 +492,7 @@ function insertElement(change) {
|
|
470
492
|
*/
|
471
493
|
function appendNewDocumentFragment(container, key, ref, path) {
|
472
494
|
|
473
|
-
let
|
474
|
-
if (!rootNode) {
|
475
|
-
rootNode = getDocument();
|
476
|
-
}
|
477
|
-
|
478
|
-
let template = findDocumentTemplate(key, rootNode);
|
495
|
+
let template = findDocumentTemplate(key, container);
|
479
496
|
|
480
497
|
let nodes = template.createDocumentFragment();
|
481
498
|
for (const [, node] of Object.entries(nodes.childNodes)) {
|
@@ -728,5 +745,5 @@ function handleInputControlAttributeUpdate(element, name, value) {
|
|
728
745
|
|
729
746
|
}
|
730
747
|
|
731
|
-
|
748
|
+
assignToNamespace('Monster.DOM', Updater);
|
732
749
|
export {Monster, Updater}
|
package/source/dom/util.js
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {getGlobal} from "../types/global.js";
|
8
8
|
import {validateString} from "../types/validate.js";
|
9
9
|
|
10
10
|
|
@@ -13,7 +13,7 @@ import {validateString} from "../types/validate.js";
|
|
13
13
|
*
|
14
14
|
* ```
|
15
15
|
* <script type="module">
|
16
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
16
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/util.js';
|
17
17
|
* console.log(Monster.DOM.getDocument())
|
18
18
|
* </script>
|
19
19
|
* ```
|
@@ -22,7 +22,7 @@ import {validateString} from "../types/validate.js";
|
|
22
22
|
*
|
23
23
|
* ```
|
24
24
|
* <script type="module">
|
25
|
-
* import {getDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
25
|
+
* import {getDocument} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/util.js';
|
26
26
|
* console.log(getDocument())
|
27
27
|
* </script>
|
28
28
|
* ```
|
@@ -62,7 +62,7 @@ import {validateString} from "../types/validate.js";
|
|
62
62
|
*/
|
63
63
|
function getDocument() {
|
64
64
|
let document = getGlobal()?.['document'];
|
65
|
-
if (typeof document !== 'object') {
|
65
|
+
if (typeof document !== 'object') {
|
66
66
|
throw new Error("not supported environment")
|
67
67
|
}
|
68
68
|
|
@@ -74,7 +74,7 @@ function getDocument() {
|
|
74
74
|
*
|
75
75
|
* ```
|
76
76
|
* <script type="module">
|
77
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
77
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/util.js';
|
78
78
|
* console.log(Monster.DOM.getWindow())
|
79
79
|
* </script>
|
80
80
|
* ```
|
@@ -83,7 +83,7 @@ function getDocument() {
|
|
83
83
|
*
|
84
84
|
* ```
|
85
85
|
* <script type="module">
|
86
|
-
* import {getWindow} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
86
|
+
* import {getWindow} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/util.js';
|
87
87
|
* console.log(getWindow(null))
|
88
88
|
* </script>
|
89
89
|
* ```
|
@@ -140,7 +140,7 @@ function getWindow() {
|
|
140
140
|
*
|
141
141
|
* ```
|
142
142
|
* <script type="module">
|
143
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
143
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/util.js';
|
144
144
|
* console.log(Monster.DOM.getDocumentFragmentFromString())
|
145
145
|
* </script>
|
146
146
|
* ```
|
@@ -149,7 +149,7 @@ function getWindow() {
|
|
149
149
|
*
|
150
150
|
* ```
|
151
151
|
* <script type="module">
|
152
|
-
* import {getDocumentFragmentFromString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
152
|
+
* import {getDocumentFragmentFromString} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/dom/util.js';
|
153
153
|
* console.log(getDocumentFragmentFromString('<div></div>'))
|
154
154
|
* </script>
|
155
155
|
* ```
|
@@ -194,10 +194,10 @@ function getDocumentFragmentFromString(html) {
|
|
194
194
|
const document = getDocument();
|
195
195
|
const template = document.createElement('template');
|
196
196
|
template.innerHTML = html;
|
197
|
-
|
197
|
+
|
198
198
|
return template.content;
|
199
199
|
}
|
200
200
|
|
201
201
|
|
202
|
-
|
202
|
+
assignToNamespace('Monster.DOM', getWindow, getDocument, getDocumentFragmentFromString);
|
203
203
|
export {Monster, getWindow, getDocument, getDocumentFragmentFromString}
|
package/source/i18n/locale.js
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {Base} from "../types/base.js";
|
8
8
|
import {validateString} from "../types/validate.js";
|
9
9
|
import {clone} from "../util/clone.js";
|
10
10
|
|
@@ -23,7 +23,7 @@ const localeStringSymbol = Symbol('localeString');
|
|
23
23
|
*
|
24
24
|
* ```
|
25
25
|
* <script type="module">
|
26
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
26
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/i18n/locale.js';
|
27
27
|
* console.log(new Monster.I18n.Locale())
|
28
28
|
* </script>
|
29
29
|
* ```
|
@@ -32,7 +32,7 @@ const localeStringSymbol = Symbol('localeString');
|
|
32
32
|
*
|
33
33
|
* ```
|
34
34
|
* <script type="module">
|
35
|
-
* import {Locale} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
35
|
+
* import {Locale} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/i18n/locale.js';
|
36
36
|
* console.log(new Locale())
|
37
37
|
* </script>
|
38
38
|
* ```
|
@@ -189,7 +189,7 @@ class Locale extends Base {
|
|
189
189
|
*
|
190
190
|
* ```
|
191
191
|
* <script type="module">
|
192
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
192
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/i18n/locale.js';
|
193
193
|
* console.log(new Monster.I18n.createLocale())
|
194
194
|
* </script>
|
195
195
|
* ```
|
@@ -198,7 +198,7 @@ class Locale extends Base {
|
|
198
198
|
*
|
199
199
|
* ```
|
200
200
|
* <script type="module">
|
201
|
-
* import {createLocale} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
201
|
+
* import {createLocale} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/i18n/locale.js';
|
202
202
|
* console.log(createLocale())
|
203
203
|
* </script>
|
204
204
|
* ```
|
@@ -318,5 +318,5 @@ function parseLocale(locale) {
|
|
318
318
|
}
|
319
319
|
|
320
320
|
|
321
|
-
|
321
|
+
assignToNamespace('Monster.I18n', Locale, parseLocale);
|
322
322
|
export {Monster, Locale, parseLocale}
|
package/source/i18n/namespace.js
CHANGED
package/source/i18n/provider.js
CHANGED
@@ -3,19 +3,19 @@
|
|
3
3
|
/**
|
4
4
|
* @author schukai GmbH
|
5
5
|
*/
|
6
|
-
|
7
|
-
import {
|
6
|
+
import {assignToNamespace, Monster} from '../namespace.js';
|
7
|
+
import {BaseWithOptions} from "../types/basewithoptions.js";
|
8
8
|
import {Locale} from "./locale.js"
|
9
9
|
import {Translations} from "./translations.js"
|
10
10
|
|
11
11
|
/**
|
12
12
|
* A provider makes a translation object available.
|
13
|
-
*
|
13
|
+
*
|
14
14
|
* You can call the method via the monster namespace `new Monster.I18n.Provider()`.
|
15
15
|
*
|
16
16
|
* ```
|
17
17
|
* <script type="module">
|
18
|
-
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
18
|
+
* import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/i18n/provider.js';
|
19
19
|
* console.log(new Monster.I18n.Provider())
|
20
20
|
* </script>
|
21
21
|
* ```
|
@@ -24,7 +24,7 @@ import {Translations} from "./translations.js"
|
|
24
24
|
*
|
25
25
|
* ```
|
26
26
|
* <script type="module">
|
27
|
-
* import {Provider} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.
|
27
|
+
* import {Provider} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.15.3/dist/modules/i18n/provider.js';
|
28
28
|
* console.log(new Provider())
|
29
29
|
* </script>
|
30
30
|
* ```
|
@@ -54,5 +54,5 @@ class Provider extends BaseWithOptions {
|
|
54
54
|
}
|
55
55
|
|
56
56
|
|
57
|
-
|
57
|
+
assignToNamespace('Monster.I18n', Provider);
|
58
58
|
export {Monster, Provider}
|