@schukai/monster 1.31.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG +11 -0
- package/README.md +55 -58
- package/example/constraints/andoperator.mjs +17 -0
- package/example/constraints/invalid.mjs +6 -0
- package/example/constraints/isarray.mjs +11 -0
- package/example/constraints/isobject.mjs +12 -0
- package/example/constraints/oroperator.mjs +15 -0
- package/example/constraints/valid.mjs +6 -0
- package/example/data/buildmap.mjs +67 -0
- package/example/data/datasource.mjs +7 -0
- package/example/data/diff.mjs +39 -0
- package/example/data/pathfinder-1.mjs +23 -0
- package/example/data/pathfinder-2.mjs +19 -0
- package/example/data/pipe.mjs +14 -0
- package/example/data/storage/restapi.mjs +11 -0
- package/example/data/transformer.mjs +9 -0
- package/example/dom/customelement.mjs +13 -0
- package/example/dom/theme.mjs +5 -0
- package/example/dom/updater.mjs +23 -0
- package/example/i18n/formatter.mjs +10 -0
- package/example/i18n/providers/fetch.mjs +5 -0
- package/example/i18n/translations.mjs +20 -0
- package/example/types/basewithoptions.mjs +10 -0
- package/example/types/is-1.mjs +5 -0
- package/example/types/is-10.mjs +6 -0
- package/example/types/is-2.mjs +4 -0
- package/example/types/is-3.mjs +4 -0
- package/example/types/is-4.mjs +5 -0
- package/example/types/is-5.mjs +4 -0
- package/example/types/is-6.mjs +4 -0
- package/example/types/is-7.mjs +4 -0
- package/example/types/is-8.mjs +4 -0
- package/example/types/is-9.mjs +6 -0
- package/example/types/noderecursiveiterator.mjs +32 -0
- package/example/types/observer.mjs +9 -0
- package/example/types/proxyobserver.mjs +25 -0
- package/example/types/queue.mjs +20 -0
- package/example/types/tokenlist-1.mjs +4 -0
- package/example/types/tokenlist-2.mjs +7 -0
- package/example/types/tokenlist-3.mjs +5 -0
- package/example/types/tokenlist-4.mjs +5 -0
- package/example/types/tokenlist-5.mjs +5 -0
- package/example/types/typeof.mjs +9 -0
- package/example/types/version-1.mjs +6 -0
- package/example/types/version-2.mjs +3 -0
- package/example/util/comparator.mjs +10 -0
- package/example/util/deadmansswitch.mjs +9 -0
- package/example/util/processing.mjs +17 -0
- package/package.json +6 -60
- package/source/{constants.js → constants.mjs} +7 -10
- package/source/constraints/{abstract.js → abstract.mjs} +8 -9
- package/source/constraints/{abstractoperator.js → abstractoperator.mjs} +11 -8
- package/source/constraints/andoperator.mjs +38 -0
- package/source/constraints/invalid.mjs +38 -0
- package/source/constraints/isarray.mjs +41 -0
- package/source/constraints/isobject.mjs +41 -0
- package/source/constraints/{namespace.js → namespace.mjs} +3 -8
- package/source/constraints/{oroperator.js → oroperator.mjs} +10 -42
- package/source/constraints/valid.mjs +38 -0
- package/source/data/{buildmap.js → buildmap.mjs} +18 -104
- package/source/data/{buildtree.js → buildtree.mjs} +11 -31
- package/source/data/datasource/{namespace.js → namespace.mjs} +1 -9
- package/source/data/datasource/restapi/namespace.mjs +8 -0
- package/source/data/datasource/restapi/{writeerror.js → writeerror.mjs} +8 -9
- package/source/data/datasource/{restapi.js → restapi.mjs} +15 -45
- package/source/data/datasource/storage/localstorage.mjs +45 -0
- package/source/data/datasource/storage/{namespace.js → namespace.mjs} +1 -9
- package/source/data/datasource/storage/sessionstorage.mjs +45 -0
- package/source/data/datasource/{storage.js → storage.mjs} +12 -35
- package/source/data/{datasource.js → datasource.mjs} +17 -45
- package/source/data/{diff.js → diff.mjs} +10 -69
- package/source/data/{extend.js → extend.mjs} +10 -28
- package/source/data/{namespace.js → namespace.mjs} +2 -8
- package/source/data/{pathfinder.js → pathfinder.mjs} +18 -77
- package/source/data/{pipe.js → pipe.mjs} +14 -46
- package/source/data/{transformer.js → transformer.mjs} +18 -43
- package/source/dom/{assembler.js → assembler.mjs} +12 -28
- package/source/dom/{attributes.js → attributes.mjs} +42 -253
- package/source/dom/{constants.js → constants.mjs} +110 -61
- package/source/dom/{customcontrol.js → customcontrol.mjs} +10 -17
- package/source/dom/{customelement.js → customelement.mjs} +28 -52
- package/source/dom/{events.js → events.mjs} +15 -64
- package/source/dom/{focusmanager.js → focusmanager.mjs} +13 -34
- package/source/dom/{locale.js → locale.mjs} +11 -26
- package/source/dom/{namespace.js → namespace.mjs} +1 -8
- package/source/dom/{ready.js → ready.mjs} +12 -30
- package/source/dom/resource/{data.js → data.mjs} +11 -31
- package/source/dom/resource/link/namespace.mjs +10 -0
- package/source/dom/resource/link/stylesheet.mjs +35 -0
- package/source/dom/resource/{link.js → link.mjs} +9 -29
- package/source/dom/resource/namespace.mjs +8 -0
- package/source/dom/resource/{script.js → script.mjs} +9 -29
- package/source/dom/{resource.js → resource.mjs} +19 -39
- package/source/dom/{resourcemanager.js → resourcemanager.mjs} +17 -35
- package/source/dom/{template.js → template.mjs} +18 -43
- package/source/dom/{theme.js → theme.mjs} +14 -36
- package/source/dom/{updater.js → updater.mjs} +34 -68
- package/source/dom/{util.js → util.mjs} +17 -66
- package/source/dom/worker/{factory.js → factory.mjs} +13 -34
- package/source/dom/worker/namespace.mjs +8 -0
- package/source/i18n/{formatter.js → formatter.mjs} +14 -45
- package/source/i18n/{locale.js → locale.mjs} +15 -30
- package/source/i18n/{namespace.js → namespace.mjs} +1 -9
- package/source/i18n/provider.mjs +40 -0
- package/source/i18n/providers/{fetch.js → fetch.mjs} +18 -43
- package/source/i18n/providers/namespace.mjs +8 -0
- package/source/i18n/{translations.js → translations.mjs} +12 -52
- package/source/logging/handler/console.mjs +50 -0
- package/source/logging/handler/namespace.mjs +6 -0
- package/source/logging/{handler.js → handler.mjs} +13 -30
- package/source/logging/logentry.mjs +51 -0
- package/source/logging/{logger.js → logger.mjs} +12 -28
- package/source/logging/{namespace.js → namespace.mjs} +1 -9
- package/source/math/{namespace.js → namespace.mjs} +1 -9
- package/source/math/{random.js → random.mjs} +8 -34
- package/source/monster.mjs +114 -0
- package/source/text/{formatter.js → formatter.mjs} +17 -33
- package/source/text/{namespace.js → namespace.mjs} +1 -9
- package/source/types/base.mjs +31 -0
- package/source/types/{basewithoptions.js → basewithoptions.mjs} +17 -46
- package/source/types/{binary.js → binary.mjs} +10 -42
- package/source/types/{dataurl.js → dataurl.mjs} +12 -46
- package/source/types/{global.js → global.mjs} +20 -12
- package/source/types/{id.js → id.mjs} +10 -27
- package/source/types/is.mjs +225 -0
- package/source/types/{mediatype.js → mediatype.mjs} +13 -29
- package/source/types/{namespace.js → namespace.mjs} +1 -8
- package/source/types/{node.js → node.mjs} +11 -28
- package/source/types/{nodelist.js → nodelist.mjs} +17 -32
- package/source/types/{noderecursiveiterator.js → noderecursiveiterator.mjs} +14 -65
- package/source/types/{observer.js → observer.mjs} +15 -42
- package/source/types/{observerlist.js → observerlist.mjs} +12 -29
- package/source/types/{proxyobserver.js → proxyobserver.mjs} +19 -62
- package/source/types/{queue.js → queue.mjs} +10 -47
- package/source/types/randomid.mjs +45 -0
- package/source/types/regex.mjs +27 -0
- package/source/types/{stack.js → stack.mjs} +8 -24
- package/source/types/{tokenlist.js → tokenlist.mjs} +20 -64
- package/source/types/typeof.mjs +37 -0
- package/source/types/{uniquequeue.js → uniquequeue.mjs} +11 -27
- package/source/types/{uuid.js → uuid.mjs} +15 -33
- package/source/types/{validate.js → validate.mjs} +38 -155
- package/source/types/{version.js → version.mjs} +19 -62
- package/source/util/{clone.js → clone.mjs} +10 -28
- package/source/util/{comparator.js → comparator.mjs} +13 -43
- package/source/util/{deadmansswitch.js → deadmansswitch.mjs} +15 -40
- package/source/util/freeze.mjs +39 -0
- package/source/util/{namespace.js → namespace.mjs} +1 -9
- package/source/util/{processing.js → processing.mjs} +13 -51
- package/source/util/{trimspaces.js → trimspaces.mjs} +14 -21
- package/test/cases/constraint/{andoperator.js → andoperator.mjs} +3 -3
- package/test/cases/constraint/{invalid.js → invalid.mjs} +1 -1
- package/test/cases/constraint/{isarray.js → isarray.mjs} +1 -1
- package/test/cases/constraint/{isobject.js → isobject.mjs} +1 -1
- package/test/cases/constraint/{oroperator.js → oroperator.mjs} +3 -3
- package/test/cases/constraint/{valid.js → valid.mjs} +1 -1
- package/test/cases/data/{buildmap.js → buildmap.mjs} +1 -1
- package/test/cases/data/{buildtree.js → buildtree.mjs} +2 -2
- package/test/cases/data/datasource/{restapi.js → restapi.mjs} +5 -5
- package/test/cases/data/datasource/storage/{localstorage.js → localstorage.mjs} +5 -5
- package/test/cases/data/datasource/storage/{sessionstorage.js → sessionstorage.mjs} +5 -5
- package/test/cases/data/{datasource.js → datasource.mjs} +1 -1
- package/test/cases/data/{diff.js → diff.mjs} +2 -2
- package/test/cases/data/{extend.js → extend.mjs} +1 -1
- package/test/cases/data/{pathfinder.js → pathfinder.mjs} +1 -1
- package/test/cases/data/{pipe.js → pipe.mjs} +19 -5
- package/test/cases/data/{transformer.js → transformer.mjs} +14 -10
- package/test/cases/dom/{assembler.js → assembler.mjs} +2 -2
- package/test/cases/dom/{attributes.js → attributes.mjs} +2 -2
- package/test/cases/dom/{customcontrol.js → customcontrol.mjs} +6 -6
- package/test/cases/dom/{customelement.js → customelement.mjs} +6 -6
- package/test/cases/dom/{events.js → events.mjs} +2 -2
- package/test/cases/dom/{focusmanager.js → focusmanager.mjs} +3 -3
- package/test/cases/dom/{locale.js → locale.mjs} +2 -2
- package/test/cases/dom/{ready.js → ready.mjs} +2 -2
- package/test/cases/dom/resource/{data.js → data.mjs} +9 -9
- package/test/cases/dom/resource/link/{stylesheet.js → stylesheet.mjs} +6 -6
- package/test/cases/dom/resource/{link.js → link.mjs} +6 -6
- package/test/cases/dom/resource/{script.js → script.mjs} +6 -6
- package/test/cases/dom/{resourcemanager.js → resourcemanager.mjs} +6 -6
- package/test/cases/dom/{template.js → template.mjs} +3 -3
- package/test/cases/dom/{theme.js → theme.mjs} +3 -3
- package/test/cases/dom/{updater.js → updater.mjs} +6 -6
- package/test/cases/dom/{util.js → util.mjs} +2 -2
- package/test/cases/dom/worker/{factory.js → factory.mjs} +4 -4
- package/test/cases/i18n/{formatter.js → formatter.mjs} +2 -2
- package/test/cases/i18n/{locale.js → locale.mjs} +1 -1
- package/test/cases/i18n/{provider.js → provider.mjs} +1 -1
- package/test/cases/i18n/providers/{fetch.js → fetch.mjs} +3 -3
- package/test/cases/i18n/{translations.js → translations.mjs} +2 -2
- package/test/cases/logging/handler/{console.js → console.mjs} +3 -3
- package/test/cases/logging/{handler.js → handler.mjs} +3 -3
- package/test/cases/logging/{logentry.js → logentry.mjs} +1 -1
- package/test/cases/logging/{logger.js → logger.mjs} +1 -1
- package/test/cases/math/random.mjs +101 -0
- package/test/cases/monster.mjs +20 -0
- package/test/cases/text/{formatter.js → formatter.mjs} +1 -1
- package/test/cases/types/{base.js → base.mjs} +1 -1
- package/test/cases/types/{basewithoptions.js → basewithoptions.mjs} +1 -1
- package/test/cases/types/{binary.js → binary.mjs} +1 -1
- package/test/cases/types/{dataurl.js → dataurl.mjs} +1 -1
- package/test/cases/types/{global.js → global.mjs} +1 -1
- package/test/cases/types/{id.js → id.mjs} +17 -6
- package/test/cases/types/{is.js → is.mjs} +20 -8
- package/test/cases/types/{mediatype.js → mediatype.mjs} +1 -1
- package/test/cases/types/{node.js → node.mjs} +3 -3
- package/test/cases/types/{nodelist.js → nodelist.mjs} +2 -2
- package/test/cases/types/{noderecursiveiterator.js → noderecursiveiterator.mjs} +3 -3
- package/test/cases/types/{observer.js → observer.mjs} +1 -1
- package/test/cases/types/{observerlist.js → observerlist.mjs} +2 -2
- package/test/cases/types/{proxyobserver.js → proxyobserver.mjs} +4 -4
- package/test/cases/types/{queue.js → queue.mjs} +1 -1
- package/test/cases/types/randomid.mjs +39 -0
- package/test/cases/types/regex.mjs +46 -0
- package/test/cases/types/{stack.js → stack.mjs} +1 -1
- package/test/cases/types/{tokenlist.js → tokenlist.mjs} +1 -1
- package/test/cases/types/{typeof.js → typeof.mjs} +3 -4
- package/test/cases/types/{uniquequeue.js → uniquequeue.mjs} +1 -1
- package/test/cases/types/{uuid.js → uuid.mjs} +30 -10
- package/test/cases/types/{validate.js → validate.mjs} +3 -4
- package/test/cases/types/{version.js → version.mjs} +1 -2
- package/test/cases/util/{clone.js → clone.mjs} +1 -1
- package/test/cases/util/{comparator.js → comparator.mjs} +1 -1
- package/test/cases/util/{deadmansswitch.js → deadmansswitch.mjs} +1 -1
- package/test/cases/util/{freeze.js → freeze.mjs} +1 -1
- package/test/cases/util/{processing.js → processing.mjs} +1 -1
- package/test/cases/util/{trimspaces.js → trimspaces.mjs} +1 -1
- package/test/util/{chai-dom.js → chai-dom.mjs} +0 -0
- package/test/util/{cleanupdom.js → cleanupdom.mjs} +0 -0
- package/test/util/{jsdom.js → jsdom.mjs} +2 -2
- package/test/util/{localstorage.js → localstorage.mjs} +0 -0
- package/test/web/import.js +77 -78
- package/test/web/prepare.js +0 -8
- package/test/web/test.html +5 -4
- package/test/web/tests.js +25731 -587
- package/dist/modules/constants.js +0 -2
- package/dist/modules/constraints/abstract.js +0 -2
- package/dist/modules/constraints/abstractoperator.js +0 -2
- package/dist/modules/constraints/andoperator.js +0 -2
- package/dist/modules/constraints/invalid.js +0 -2
- package/dist/modules/constraints/isarray.js +0 -2
- package/dist/modules/constraints/isobject.js +0 -2
- package/dist/modules/constraints/namespace.js +0 -2
- package/dist/modules/constraints/oroperator.js +0 -2
- package/dist/modules/constraints/valid.js +0 -2
- package/dist/modules/data/buildmap.js +0 -2
- package/dist/modules/data/buildtree.js +0 -2
- package/dist/modules/data/datasource/namespace.js +0 -2
- package/dist/modules/data/datasource/restapi/writeerror.js +0 -2
- package/dist/modules/data/datasource/restapi.js +0 -2
- package/dist/modules/data/datasource/storage/localstorage.js +0 -2
- package/dist/modules/data/datasource/storage/namespace.js +0 -2
- package/dist/modules/data/datasource/storage/sessionstorage.js +0 -2
- package/dist/modules/data/datasource/storage.js +0 -2
- package/dist/modules/data/datasource.js +0 -2
- package/dist/modules/data/diff.js +0 -2
- package/dist/modules/data/extend.js +0 -2
- package/dist/modules/data/namespace.js +0 -2
- package/dist/modules/data/pathfinder.js +0 -2
- package/dist/modules/data/pipe.js +0 -2
- package/dist/modules/data/transformer.js +0 -2
- package/dist/modules/dom/assembler.js +0 -2
- package/dist/modules/dom/attributes.js +0 -2
- package/dist/modules/dom/constants.js +0 -2
- package/dist/modules/dom/customcontrol.js +0 -2
- package/dist/modules/dom/customelement.js +0 -2
- package/dist/modules/dom/events.js +0 -2
- package/dist/modules/dom/focusmanager.js +0 -2
- package/dist/modules/dom/locale.js +0 -2
- package/dist/modules/dom/namespace.js +0 -2
- package/dist/modules/dom/ready.js +0 -2
- package/dist/modules/dom/resource/data.js +0 -2
- package/dist/modules/dom/resource/link/stylesheet.js +0 -2
- package/dist/modules/dom/resource/link.js +0 -2
- package/dist/modules/dom/resource/script.js +0 -2
- package/dist/modules/dom/resource.js +0 -2
- package/dist/modules/dom/resourcemanager.js +0 -2
- package/dist/modules/dom/template.js +0 -2
- package/dist/modules/dom/theme.js +0 -2
- package/dist/modules/dom/updater.js +0 -2
- package/dist/modules/dom/util.js +0 -2
- package/dist/modules/dom/worker/factory.js +0 -2
- package/dist/modules/i18n/formatter.js +0 -2
- package/dist/modules/i18n/locale.js +0 -2
- package/dist/modules/i18n/namespace.js +0 -2
- package/dist/modules/i18n/provider.js +0 -2
- package/dist/modules/i18n/providers/fetch.js +0 -2
- package/dist/modules/i18n/providers/namespace.js +0 -2
- package/dist/modules/i18n/translations.js +0 -2
- package/dist/modules/logging/handler/console.js +0 -2
- package/dist/modules/logging/handler/namespace.js +0 -2
- package/dist/modules/logging/handler.js +0 -2
- package/dist/modules/logging/logentry.js +0 -2
- package/dist/modules/logging/logger.js +0 -2
- package/dist/modules/logging/namespace.js +0 -2
- package/dist/modules/math/namespace.js +0 -2
- package/dist/modules/math/random.js +0 -2
- package/dist/modules/monster.js +0 -2
- package/dist/modules/namespace.js +0 -2
- package/dist/modules/text/formatter.js +0 -2
- package/dist/modules/text/namespace.js +0 -2
- package/dist/modules/types/base.js +0 -2
- package/dist/modules/types/basewithoptions.js +0 -2
- package/dist/modules/types/binary.js +0 -2
- package/dist/modules/types/dataurl.js +0 -2
- package/dist/modules/types/global.js +0 -2
- package/dist/modules/types/id.js +0 -2
- package/dist/modules/types/is.js +0 -2
- package/dist/modules/types/mediatype.js +0 -2
- package/dist/modules/types/namespace.js +0 -2
- package/dist/modules/types/node.js +0 -2
- package/dist/modules/types/nodelist.js +0 -2
- package/dist/modules/types/noderecursiveiterator.js +0 -2
- package/dist/modules/types/observer.js +0 -2
- package/dist/modules/types/observerlist.js +0 -2
- package/dist/modules/types/proxyobserver.js +0 -2
- package/dist/modules/types/queue.js +0 -2
- package/dist/modules/types/randomid.js +0 -2
- package/dist/modules/types/regex.js +0 -2
- package/dist/modules/types/stack.js +0 -2
- package/dist/modules/types/tokenlist.js +0 -2
- package/dist/modules/types/typeof.js +0 -2
- package/dist/modules/types/uniquequeue.js +0 -2
- package/dist/modules/types/uuid.js +0 -2
- package/dist/modules/types/validate.js +0 -2
- package/dist/modules/types/version.js +0 -2
- package/dist/modules/util/clone.js +0 -2
- package/dist/modules/util/comparator.js +0 -2
- package/dist/modules/util/deadmansswitch.js +0 -2
- package/dist/modules/util/freeze.js +0 -2
- package/dist/modules/util/namespace.js +0 -2
- package/dist/modules/util/processing.js +0 -2
- package/dist/modules/util/trimspaces.js +0 -2
- package/dist/monster.dev.js +0 -15490
- package/dist/monster.dev.js.map +0 -1
- package/dist/monster.js +0 -2
- package/source/constraints/andoperator.js +0 -71
- package/source/constraints/invalid.js +0 -63
- package/source/constraints/isarray.js +0 -71
- package/source/constraints/isobject.js +0 -72
- package/source/constraints/valid.js +0 -63
- package/source/data/datasource/storage/localstorage.js +0 -64
- package/source/data/datasource/storage/sessionstorage.js +0 -61
- package/source/dom/resource/link/stylesheet.js +0 -54
- package/source/i18n/provider.js +0 -58
- package/source/i18n/providers/namespace.js +0 -16
- package/source/logging/handler/console.js +0 -66
- package/source/logging/handler/namespace.js +0 -14
- package/source/logging/logentry.js +0 -68
- package/source/monster.js +0 -80
- package/source/namespace.js +0 -171
- package/source/types/base.js +0 -50
- package/source/types/is.js +0 -429
- package/source/types/package.d.ts +0 -1
- package/source/types/randomid.js +0 -60
- package/source/types/regex.js +0 -49
- package/source/types/typeof.js +0 -63
- package/source/util/freeze.js +0 -57
- package/test/cases/math/random.js +0 -82
- package/test/cases/monster.js +0 -23
- package/test/cases/namespace.js +0 -93
- package/test/cases/types/randomid.js +0 -24
- package/test/cases/types/regex.js +0 -32
- package/test/web/monster-dev.html +0 -22
- package/test/web/monster.html +0 -21
package/CHANGELOG
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [2.0.0] - 2022-08-08
|
6
|
+
|
7
|
+
- New structure in the repo
|
8
|
+
- Remove namespace functionality
|
9
|
+
- Switching the tests to esbuild
|
10
|
+
- Actualization of the documentation template
|
11
|
+
- New URL of the documentation
|
12
|
+
- Bug fix typeOf (constructor name was recognized wrong)
|
13
|
+
- Removal of the built version of the library
|
14
|
+
- Switching from js to mjs
|
15
|
+
|
5
16
|
## [1.31.0] - 2022-02-07
|
6
17
|
|
7
18
|
## Added
|
package/README.md
CHANGED
@@ -1,88 +1,86 @@
|
|
1
1
|
# Monster
|
2
2
|
|
3
|
-
Monster is
|
4
|
-
|
5
|
-
everything.
|
3
|
+
Monster is perfectly suited for the creation of beautiful and fast
|
4
|
+
user interfaces and websites.
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
CSS and Javascript in a meaningful way.
|
6
|
+
Monster relies on proven concepts mixed with many new JavaScript concepts such as
|
7
|
+
classes, WeakRef, WeakMaps, proxies or the MutationObserver interface, just to name a few.
|
10
8
|
|
11
|
-
Monster
|
12
|
-
user interfaces and websites. The basis is formed by core functions that
|
13
|
-
can be supplemented by necessary classes and objects.
|
9
|
+
Monster integrates easily into your existing websites without taking over everything.
|
14
10
|
|
15
|
-
|
11
|
+
It is not the goal of Monster to pull in an entirely new abstraction
|
12
|
+
with its own language, but to combine the existing techniques of HTML,
|
13
|
+
CSS and JavaScript in a meaningful way.
|
14
|
+
|
15
|
+
One design target is to reach the shiny sun with as little JavaScript as possible.
|
16
16
|
|
17
17
|
Monster was built with ES6 modules and uses [import](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Statements/import)
|
18
18
|
and [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export).
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
For some functions, you need additional [polyfills](#polyfill).
|
21
|
+
|
22
|
+
## Documentation
|
22
23
|
|
23
|
-
|
24
|
+
To check out docs and examples, visit [monsterjs.org/en/doc/monster/](https://monsterjs.org/en/doc/monster/).
|
24
25
|
|
25
26
|
## Installation
|
26
27
|
|
27
|
-
`npm install @schukai/monster`
|
28
|
+
`npm install @schukai/monster`, `yarn install @schukai/monster` or `pnpm install @schukai/monster`
|
28
29
|
|
29
|
-
##
|
30
|
+
## Usage
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
<html>
|
34
|
-
<head>
|
35
|
-
<title>HTML, CSS and JavaScript demo</title>
|
36
|
-
</head>
|
37
|
-
|
38
|
-
<body>
|
39
|
-
<p>Hello Monster <span id="version"></span>!</p>
|
40
|
-
<script type="module">
|
41
|
-
import {
|
42
|
-
Monster
|
43
|
-
} from 'https://unpkg.com/@schukai/monster@1.31.0/dist/modules/monster.js';
|
44
|
-
let id = document.getElementById('version');
|
45
|
-
id.innerHTML = Monster.getVersion();
|
46
|
-
</script>
|
47
|
-
</body>
|
48
|
-
</html>
|
49
|
-
```
|
32
|
+
A simple example of the use of functionality from Monster. We create a small file `index.mjs`.
|
33
|
+
The `m` in `.mjs` stands for module. In the example we want to make substitutions in a string.
|
50
34
|
|
51
|
-
|
35
|
+
```js
|
36
|
+
import {Formatter} from '@schukai/monster/source/text/formatter.mjs';
|
37
|
+
const text = '${mykey${subkey}}';
|
38
|
+
let obj = {
|
39
|
+
mykey2: "1",
|
40
|
+
subkey: "2"
|
41
|
+
};
|
52
42
|
|
43
|
+
new Formatter(obj).format(text);
|
44
|
+
// ↦ 1
|
53
45
|
```
|
54
|
-
<script type="module" src="https://unpkg.com/@schukai/monster@1.31.0/dist/modules/monster.js"></script>
|
55
|
-
<script nomodule src="https://unpkg.com/@schukai/monster@1.31.0/dist/monster.js"></script>
|
56
|
-
```
|
57
|
-
### Polyfill
|
58
46
|
|
59
|
-
|
60
|
-
|
61
|
-
However, many functions can be mapped via [polyfill.io](https://polyfill.io/) and thus the compatibility can be increased.
|
47
|
+
To integrate this function into a website it is recommended to use a bundler like [esbuild](https://esbuild.github.io/).
|
62
48
|
|
49
|
+
```sh
|
50
|
+
esbuild index.mjs --outfile dist.js
|
63
51
|
```
|
64
|
-
|
65
|
-
|
66
|
-
|
52
|
+
|
53
|
+
We can now integrate that into our website.
|
54
|
+
|
55
|
+
```html
|
56
|
+
<!DOCTYPE html>
|
57
|
+
<html lang="en">
|
58
|
+
<head>
|
59
|
+
<meta charset="UTF-8">
|
60
|
+
<title>Monster</title>
|
61
|
+
<script src="dist.js"></script>
|
62
|
+
</head>
|
63
|
+
<body>
|
67
64
|
```
|
68
65
|
|
69
|
-
|
66
|
+
Voila!
|
70
67
|
|
71
|
-
if the global name Monster, is already used by another component, the following variable can be used to adapt the name of the component.
|
72
68
|
|
73
|
-
|
74
|
-
__MonsterRootName__="MyMonster"
|
75
|
-
```
|
69
|
+
### Polyfill
|
76
70
|
|
77
|
-
|
71
|
+
We do try to work around some browser bugs, but on the whole we don't use polyfills and feature detection.
|
78
72
|
|
79
|
-
|
73
|
+
However, many functions can be mapped via [polyfill.io](https://polyfill.io/) and thus the compatibility can be increased.
|
80
74
|
|
81
|
-
|
75
|
+
```
|
76
|
+
<script id="polyfill" src="https://polyfill.io/v3/polyfill.min.js?features=Array.from,Array.isArray,Array.prototype.entries,Array.prototype.fill,Array.prototype.forEach,Array.prototype.indexOf,Array.prototype.keys,Array.prototype.lastIndexOf,Array.prototype.map,Array.prototype.reduce,Array.prototype.sort,ArrayBuffer,atob,DataView,document,DocumentFragment,Element,Event,globalThis,HTMLDocument,HTMLTemplateElement,JSON,Map,Math.log2,Number.isInteger,Object.assign,Object.defineProperty,Object.entries,Object.getOwnPropertyDescriptor,Object.getPrototypeOf,Object.keys,Promise,Reflect,Reflect.defineProperty,Reflect.get,Reflect.getOwnPropertyDescriptor,Reflect.setPrototypeOf,Set,String.prototype.endsWith,String.prototype.matchAll,String.prototype.padStart,String.prototype.startsWith,String.prototype.trim,Symbol,Symbol.iterator,WeakMap,WeakSet"
|
77
|
+
crossorigin="anonymous"
|
78
|
+
referrerpolicy="no-referrer"></script>
|
79
|
+
```
|
82
80
|
|
83
81
|
## Questions
|
84
82
|
|
85
|
-
For questions and commercial support please contact [schukai GmbH](https://www.schukai.com/).
|
83
|
+
For questions and commercial support, please contact [schukai GmbH](https://www.schukai.com/).
|
86
84
|
The issue list of this repo is exclusively for bug reports and feature requests.
|
87
85
|
|
88
86
|
## Issues
|
@@ -92,14 +90,13 @@ issue. Issues not conforming to the guidelines may be closed immediately.
|
|
92
90
|
|
93
91
|
## License
|
94
92
|
|
95
|
-
Copyright ©
|
93
|
+
Copyright © 2022 schukai GmbH
|
96
94
|
|
97
95
|
[AGPL](https://www.gnu.org/licenses/agpl-3.0.de.html)
|
98
96
|
|
99
|
-
|
97
|
+
You can also purchase a commercial license.
|
100
98
|
|
101
99
|
## Changelog
|
102
100
|
|
103
101
|
Detailed changes for each release are documented in
|
104
|
-
the [CHANGELOG](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/blob/master/
|
105
|
-
|
102
|
+
the [CHANGELOG](https://gitlab.schukai.com/oss/libraries/javascript/monster/-/blob/master/application/CHANGELOG).
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import {Valid} from '@schukai/monster/source/constraints/valid.mjs';
|
2
|
+
import {Invalid} from '@schukai/monster/source/constraints/invalid.mjs';
|
3
|
+
import {AndOperator} from '@schukai/monster/source/constraints/andoperator.mjs';
|
4
|
+
|
5
|
+
new AndOperator(
|
6
|
+
new Valid(), new Valid()).isValid()
|
7
|
+
.then(() => console.log(true))
|
8
|
+
.catch(() => console.log(false));
|
9
|
+
// ↦ true
|
10
|
+
|
11
|
+
new AndOperator(
|
12
|
+
new Invalid(), new Valid()).isValid()
|
13
|
+
.then(() => console.log(true))
|
14
|
+
.catch(() => console.log(false));
|
15
|
+
// ↦ false
|
16
|
+
|
17
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import {Valid} from '@schukai/monster/source/constraints/valid.mjs';
|
2
|
+
import {Invalid} from '@schukai/monster/source/constraints/invalid.mjs';
|
3
|
+
import {OrOperator} from '@schukai/monster/source/constraints/oroperator.mjs';
|
4
|
+
|
5
|
+
new OrOperator(
|
6
|
+
new Valid(), new Invalid()).isValid()
|
7
|
+
.then(() => console.log(true))
|
8
|
+
.catch(() => console.log(false));
|
9
|
+
// ↦ true
|
10
|
+
|
11
|
+
new OrOperator(
|
12
|
+
new Invalid(), new Invalid()).isValid()
|
13
|
+
.then(() => console.log(true))
|
14
|
+
.catch(() => console.log(false));
|
15
|
+
// ↦ false
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import {buildMap} from '@schukai/monster/source/data/buildmap.mjs';
|
2
|
+
// a typical data structure as reported by an api
|
3
|
+
|
4
|
+
let map;
|
5
|
+
let obj = {
|
6
|
+
"data": [
|
7
|
+
{
|
8
|
+
"id": 10,
|
9
|
+
"name": "Cassandra",
|
10
|
+
"address": {
|
11
|
+
"street": "493-4105 Vulputate Street",
|
12
|
+
"city": "Saumur",
|
13
|
+
"zip": "52628"
|
14
|
+
}
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"id": 20,
|
18
|
+
"name": "Holly",
|
19
|
+
"address": {
|
20
|
+
"street": "1762 Eget Rd.",
|
21
|
+
"city": "Schwalbach",
|
22
|
+
"zip": "952340"
|
23
|
+
}
|
24
|
+
},
|
25
|
+
{
|
26
|
+
"id": 30,
|
27
|
+
"name": "Guy",
|
28
|
+
"address": {
|
29
|
+
"street": "957-388 Sollicitudin Avenue",
|
30
|
+
"city": "Panchià",
|
31
|
+
"zip": "420729"
|
32
|
+
}
|
33
|
+
}
|
34
|
+
]
|
35
|
+
};
|
36
|
+
|
37
|
+
// The function is passed this data structure and with the help of the selector `'data.*'` the data to be considered are selected.
|
38
|
+
// The key is given by a simple definition `'id'` and the value is given by a template `'${name} (${address.zip} ${address.city})'`.
|
39
|
+
map = buildMap(obj, 'data.*', '${name} (${address.zip} ${address.city})', 'id');
|
40
|
+
console.log(map);
|
41
|
+
|
42
|
+
// ↦ Map(3) {
|
43
|
+
// '10' => 'Cassandra (52628 Saumur)',
|
44
|
+
// '20' => 'Holly (952340 Schwalbach)',
|
45
|
+
// '30' => 'Guy (420729 Panchià)'
|
46
|
+
// }
|
47
|
+
|
48
|
+
// If no key is specified, the key from the selection, here the array index, is taken.
|
49
|
+
map = buildMap(obj, 'data.*', '${name} (${address.zip} ${address.city})');
|
50
|
+
console.log(map);
|
51
|
+
|
52
|
+
// ↦ Map(3) {
|
53
|
+
// '0' => 'Cassandra (52628 Saumur)',
|
54
|
+
// '1' => 'Holly (952340 Schwalbach)',
|
55
|
+
// '2' => 'Guy (420729 Panchià)'
|
56
|
+
// }
|
57
|
+
|
58
|
+
// a filter (function(value, key) {}) can be specified to accept only defined entries.
|
59
|
+
map = buildMap(obj, 'data.*', '${name} (${address.zip} ${address.city})', 'id', function (value, key) {
|
60
|
+
return (value['id'] >= 20) ? true : false
|
61
|
+
});
|
62
|
+
console.log(map);
|
63
|
+
|
64
|
+
// ↦ Map(2) {
|
65
|
+
// 20 => 'Holly (952340 Schwalbach)',
|
66
|
+
// 30 => 'Guy (420729 Panchià)'
|
67
|
+
// }
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import {Diff} from '@schukai/monster/source/data/diff.mjs';
|
2
|
+
|
3
|
+
// given are two objects x and y.
|
4
|
+
|
5
|
+
let x = {
|
6
|
+
a: 1,
|
7
|
+
b: "Hello!"
|
8
|
+
}
|
9
|
+
|
10
|
+
let y = {
|
11
|
+
a: 2,
|
12
|
+
c: true
|
13
|
+
}
|
14
|
+
|
15
|
+
// These two objects can be compared with each other.
|
16
|
+
|
17
|
+
console.log(Diff(x, y));
|
18
|
+
|
19
|
+
// the result is then the following
|
20
|
+
|
21
|
+
//
|
22
|
+
// [
|
23
|
+
// {
|
24
|
+
// operator: 'update',
|
25
|
+
// path: [ 'a' ],
|
26
|
+
// first: { value: 1, type: 'number' },
|
27
|
+
// second: { value: 2, type: 'number' }
|
28
|
+
// },
|
29
|
+
// {
|
30
|
+
// operator: 'delete',
|
31
|
+
// path: [ 'b' ],
|
32
|
+
// first: { value: 'Hello!', type: 'string' }
|
33
|
+
// },
|
34
|
+
// {
|
35
|
+
// operator: 'add',
|
36
|
+
// path: [ 'c' ],
|
37
|
+
// second: { value: true, type: 'boolean' }
|
38
|
+
// }
|
39
|
+
// ]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import {Pathfinder} from '@schukai/monster/source/data/pathfinder.mjs';
|
2
|
+
|
3
|
+
let value = new Pathfinder({
|
4
|
+
a: {
|
5
|
+
b: {
|
6
|
+
f: [
|
7
|
+
{
|
8
|
+
g: false,
|
9
|
+
}
|
10
|
+
],
|
11
|
+
}
|
12
|
+
}
|
13
|
+
}).getVia("a.b.f.0.g");
|
14
|
+
|
15
|
+
console.log(value);
|
16
|
+
// ↦ false
|
17
|
+
|
18
|
+
try {
|
19
|
+
new Pathfinder({}).getVia("a.b.f.0.g");
|
20
|
+
} catch (e) {
|
21
|
+
console.log(e.toString());
|
22
|
+
// ↦ Error: the journey is not at its end (b.f.0.g)
|
23
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import {Pathfinder} from '@schukai/monster/source/data/pathfinder.mjs';
|
2
|
+
|
3
|
+
let p = new Pathfinder({
|
4
|
+
a: {
|
5
|
+
x: [
|
6
|
+
{c: 1}, {c: 2}
|
7
|
+
],
|
8
|
+
y: true
|
9
|
+
},
|
10
|
+
b: {
|
11
|
+
x: [
|
12
|
+
{c: 1, d: false}, {c: 2}
|
13
|
+
],
|
14
|
+
y: true
|
15
|
+
},
|
16
|
+
});
|
17
|
+
|
18
|
+
let r = p.getVia("*.x.*.c");
|
19
|
+
console.log(r);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import {RestAPI} from '@schukai/monster/source/data/datasource/restapi.mjs';
|
2
|
+
|
3
|
+
const ds = new RestAPI({
|
4
|
+
url: 'https://httpbin.org/get'
|
5
|
+
}, {
|
6
|
+
url: 'https://httpbin.org/post'
|
7
|
+
});
|
8
|
+
|
9
|
+
ds.set({flag: true})
|
10
|
+
ds.write().then(() => console.log('done'));
|
11
|
+
ds.read().then(() => console.log('done'));
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// In the example the user can use his own template by creating a template in the DOM with the ID `my-custom-element`.
|
2
|
+
// You can also specify a theme (for example `mytheme`), then it will search for the ID `my-custom-element-mytheme` and
|
3
|
+
// if not available for the ID `my-custom-element`.
|
4
|
+
|
5
|
+
class MyCustomElement extends CustomElement {
|
6
|
+
|
7
|
+
static getTag() {
|
8
|
+
return "my-custom-element"
|
9
|
+
}
|
10
|
+
|
11
|
+
}
|
12
|
+
|
13
|
+
// ↦ <my-custom-element></my-custom-element>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import {Updater} from '@schukai/monster/source/dom/updater.mjs';
|
2
|
+
|
3
|
+
// First we prepare the html document.
|
4
|
+
// This is done here via script, but can also be inserted into the document as pure html.
|
5
|
+
// To do this, simply insert the tag <h1 data-monster-replace="path:headline"></h1>.
|
6
|
+
const body = document.querySelector('body');
|
7
|
+
const headline = document.createElement('h1');
|
8
|
+
headline.setAttribute('data-monster-replace', 'path:headline')
|
9
|
+
body.appendChild(headline);
|
10
|
+
|
11
|
+
// the data structure
|
12
|
+
let obj = {
|
13
|
+
headline: "Hello World",
|
14
|
+
};
|
15
|
+
|
16
|
+
// Now comes the real magic. we pass the updater the parent HTMLElement
|
17
|
+
// and the desired data structure.
|
18
|
+
const updater = new Updater(body, obj);
|
19
|
+
updater.run();
|
20
|
+
|
21
|
+
// Now you can change the data structure and the HTML will follow these changes.
|
22
|
+
const subject = updater.getSubject();
|
23
|
+
subject['headline'] = "Hello World!"
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import {Formatter} from '@schukai/monster/source/i18n/formatter.mjs';
|
2
|
+
import {Translations} from '@schukai/monster/source/i18n/translations.mjs';
|
3
|
+
|
4
|
+
const translations = new Translations('en')
|
5
|
+
.assignTranslations({
|
6
|
+
thekey: "${animal} has eaten the ${food}!"
|
7
|
+
});
|
8
|
+
|
9
|
+
new Formatter({}, translations).format("thekey:animal=dog::food=cake")
|
10
|
+
// ↦ dog has eaten the cake!
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import {Translations} from '@schukai/monster/source/i18n/translations.mjs';
|
2
|
+
import {parseLocale} from '@schukai/monster/source/i18n/locale.mjs';
|
3
|
+
|
4
|
+
const translation = new Translations(parseLocale('en-GB'));
|
5
|
+
|
6
|
+
translation.assignTranslations({
|
7
|
+
text1: "click",
|
8
|
+
text2: {
|
9
|
+
'one': 'click once',
|
10
|
+
'other': 'click n times'
|
11
|
+
}
|
12
|
+
});
|
13
|
+
|
14
|
+
console.log(translation.getText('text1'));
|
15
|
+
// ↦ click
|
16
|
+
|
17
|
+
console.log(translation.getPluralRuleText('text2', 1));
|
18
|
+
// -> click once
|
19
|
+
console.log(translation.getPluralRuleText('text2', 2));
|
20
|
+
// -> click n times
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import {Node} from '@schukai/monster/source/types/node.mjs';
|
2
|
+
import {NodeRecursiveIterator} from '@schukai/monster/source/types/noderecursiveiterator.mjs';
|
3
|
+
|
4
|
+
const node = new Node('1')
|
5
|
+
|
6
|
+
// 1
|
7
|
+
// 2
|
8
|
+
// ├ 2.1
|
9
|
+
// ├ 2.2
|
10
|
+
// └ 2.3
|
11
|
+
// 3
|
12
|
+
// 4
|
13
|
+
// ├ 4.1
|
14
|
+
// └ 4.2
|
15
|
+
node.appendChild(
|
16
|
+
(new Node('2'))
|
17
|
+
.appendChild(new Node('2.1'))
|
18
|
+
.appendChild(new Node('2.2'))
|
19
|
+
.appendChild(new Node('2.3')))
|
20
|
+
.appendChild(new Node('3'))
|
21
|
+
.appendChild(new Node('4')
|
22
|
+
.appendChild(new Node('4.1'))
|
23
|
+
.appendChild(new Node('4.2')));
|
24
|
+
|
25
|
+
const iterator = new NodeRecursiveIterator(node);
|
26
|
+
|
27
|
+
const result = [];
|
28
|
+
for (const n of iterator) {
|
29
|
+
result.push(n.value);
|
30
|
+
}
|
31
|
+
|
32
|
+
// ↦ ['1', '2', '2.1', '2.2', '2.3', '3', '4', '4.1', '4.2']
|