iobroker.webui 1.25.2 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/io-package.json +14 -14
- package/package.json +14 -14
- package/www/dist/frontend/common/Common.globals.d.ts +1 -1
- package/www/dist/frontend/common/Runtime.d.ts +2 -2
- package/www/dist/frontend/config/IobrokerWebuiSolutionExplorer.js +4 -4
- package/www/dist/frontend/generated/ScriptCommands.json +8 -3
- package/www/dist/frontend/helper/DialogHelper.js +7 -4
- package/www/dist/frontend/runtime/ScreenViewer.js +13 -16
- package/www/dist/frontend/scripting/IobrokerWebuiScriptSystem.js +2 -1
- package/www/index.html +1 -1
- package/www/node_modules/@adobe/css-tools/dist/index.mjs +1 -1
- package/www/node_modules/@iobroker/socket-client/dist/esm/AdminConnection.js +7 -4
- package/www/node_modules/@iobroker/socket-client/dist/esm/Connection.d.ts +82 -2
- package/www/node_modules/@iobroker/socket-client/dist/esm/Connection.js +266 -2
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/BaseCustomWebComponent.d.ts +2 -1
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/BaseCustomWebComponent.js +63 -53
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/Effect.js +2 -0
- package/www/node_modules/@node-projects/base-custom-webcomponent/dist/SignalDecorator.js +16 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/BaseCustomWebComponent.js +795 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/Debounce.js +19 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/DeclaritiveBaseCustomWebcomponent.js +176 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/DomHelper.js +96 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/HotModuleReplacement.js +125 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/LazyLoader.js +52 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/TouchContextMenu.js +20 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/TypedEvent.js +48 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/WeakArray.js +27 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/dist/index.js +9 -0
- package/www/node_modules/@node-projects/propertygrid.webcomponent/node_modules/@node-projects/base-custom-webcomponent/jsr.json +5 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/helper/getBoxQuads.js +14 -15
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/services/ServiceContainer.js +1 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/services/propertiesService/services/NativeElementsPropertiesService.js +37 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/widgets/designerView/designerCanvas.js +2 -0
- package/www/node_modules/@node-projects/web-component-designer/dist/elements/widgets/designerView/extensions/buttons/OptionsContextMenuButton.js +29 -4
- package/www/node_modules/es-module-shims/dist/es-module-shims.js +754 -628
- package/www/node_modules/long/index.js +360 -246
- package/www/node_modules/long/umd/index.js +1585 -1395
- package/www/node_modules/wunderbaum/dist/wunderbaum.css +1 -1
- package/www/node_modules/wunderbaum/dist/wunderbaum.esm.min.js +35 -35
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function debounce(func, wait, immediate = false) {
|
|
2
|
+
var timeout;
|
|
3
|
+
return function executedFunction() {
|
|
4
|
+
//@ts-ignore
|
|
5
|
+
let context = this;
|
|
6
|
+
let args = arguments;
|
|
7
|
+
let later = function () {
|
|
8
|
+
timeout = null;
|
|
9
|
+
if (!immediate)
|
|
10
|
+
func.apply(context, args);
|
|
11
|
+
};
|
|
12
|
+
let callNow = immediate && !timeout;
|
|
13
|
+
clearTimeout(timeout);
|
|
14
|
+
timeout = setTimeout(later, wait);
|
|
15
|
+
if (callNow)
|
|
16
|
+
func.apply(context, args);
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { BaseCustomWebComponentNoAttachedTemplate, css, cssFromString } from "./BaseCustomWebComponent.js";
|
|
2
|
+
import { WeakArray } from "./WeakArray.js";
|
|
3
|
+
function camelToDashCase(text) {
|
|
4
|
+
return text.replace(/([A-Z])/g, (g) => `-${g[0].toLowerCase()}`);
|
|
5
|
+
}
|
|
6
|
+
const instanceMap = new Map();
|
|
7
|
+
class BaseDeclaritiveWebcomponent extends BaseCustomWebComponentNoAttachedTemplate {
|
|
8
|
+
#firstConnect = false;
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
}
|
|
12
|
+
async connectedCallback() {
|
|
13
|
+
if (!this.#firstConnect) {
|
|
14
|
+
this.#firstConnect = true;
|
|
15
|
+
if (window[this.localName].template === undefined) {
|
|
16
|
+
window[this.localName].template = window[this.localName]._definingElement.querySelector('template');
|
|
17
|
+
const styles = window[this.localName]._definingElement.querySelectorAll('style[type=adopted-css]');
|
|
18
|
+
if (styles?.length)
|
|
19
|
+
window[this.localName]._styles = Array.from(styles).map(x => cssFromString(x.textContent));
|
|
20
|
+
}
|
|
21
|
+
//@ts-ignore
|
|
22
|
+
this._rootDocumentFragment = this.constructor.template.content.cloneNode(true);
|
|
23
|
+
//@ts-ignore
|
|
24
|
+
if (this.constructor._styles) {
|
|
25
|
+
//@ts-ignore
|
|
26
|
+
this.shadowRoot.adoptedStyleSheets = this.constructor._styles;
|
|
27
|
+
}
|
|
28
|
+
//@ts-ignore
|
|
29
|
+
if (this.constructor._enableBindings)
|
|
30
|
+
this._bindingsParse(null, true);
|
|
31
|
+
this.shadowRoot.appendChild(this._rootDocumentFragment);
|
|
32
|
+
}
|
|
33
|
+
this._parseAttributesToProperties();
|
|
34
|
+
//@ts-ignore
|
|
35
|
+
if (this.constructor._enableBindings)
|
|
36
|
+
this._bindingsRefresh();
|
|
37
|
+
}
|
|
38
|
+
_reapplyTemplateAfterUpdate() {
|
|
39
|
+
this._bindings = null;
|
|
40
|
+
this.shadowRoot.innerHTML = '';
|
|
41
|
+
this.shadowRoot.adoptedStyleSheets = [];
|
|
42
|
+
//@ts-ignore
|
|
43
|
+
if (this.constructor._styles) {
|
|
44
|
+
//@ts-ignore
|
|
45
|
+
this.shadowRoot.adoptedStyleSheets = this.constructor._styles;
|
|
46
|
+
}
|
|
47
|
+
//@ts-ignore
|
|
48
|
+
this._rootDocumentFragment = this.constructor.template.content.cloneNode(true);
|
|
49
|
+
this.shadowRoot.appendChild(this._rootDocumentFragment);
|
|
50
|
+
//@ts-ignore
|
|
51
|
+
if (this.constructor._enableBindings)
|
|
52
|
+
this._bindingsParse(null, true);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
class DeclaritiveBaseCustomWebcomponent extends BaseCustomWebComponentNoAttachedTemplate {
|
|
56
|
+
static style = css `:host{display:none;}`;
|
|
57
|
+
name;
|
|
58
|
+
enableBindings;
|
|
59
|
+
properties;
|
|
60
|
+
static properties = {
|
|
61
|
+
name: String,
|
|
62
|
+
enableBindings: Boolean,
|
|
63
|
+
properties: String
|
|
64
|
+
};
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
this._parseAttributesToProperties();
|
|
68
|
+
let props = {};
|
|
69
|
+
if (this.properties) {
|
|
70
|
+
if (this.properties[0] === '{') {
|
|
71
|
+
const obj = JSON.parse(this.properties);
|
|
72
|
+
for (let i in obj) {
|
|
73
|
+
if (typeof obj[i] === 'string')
|
|
74
|
+
props[i] = window[obj[i]];
|
|
75
|
+
else {
|
|
76
|
+
props[i] = obj[i];
|
|
77
|
+
props[i].type = obj[i].type ? window[obj[i].type] : String;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
props = this.properties.split(/[\s,;]+/).reduce((a, v) => ({ ...a, [v]: String }), {});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const name = this.name;
|
|
86
|
+
if (window[name]) {
|
|
87
|
+
window[name].template = undefined;
|
|
88
|
+
window[name].properties = props;
|
|
89
|
+
window[name]._propertiesDictionary = null;
|
|
90
|
+
window[name]._enableBindings = this.enableBindings;
|
|
91
|
+
window[name]._definingElement = this;
|
|
92
|
+
window[name]._styles = null;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const instanceArray = new WeakArray();
|
|
96
|
+
instanceMap.set(name, instanceArray);
|
|
97
|
+
window[name] = function () {
|
|
98
|
+
const instance = Reflect.construct(BaseDeclaritiveWebcomponent, [], window[name]);
|
|
99
|
+
instanceArray.add(instance);
|
|
100
|
+
for (let p in props) {
|
|
101
|
+
Object.defineProperty(instance, p, {
|
|
102
|
+
get() {
|
|
103
|
+
return this['_' + p];
|
|
104
|
+
},
|
|
105
|
+
set(newValue) {
|
|
106
|
+
if (this['_' + p] !== newValue) {
|
|
107
|
+
this['_' + p] = newValue;
|
|
108
|
+
if (props[p].reflect) {
|
|
109
|
+
if (props[p].type === Boolean) {
|
|
110
|
+
if (newValue === true)
|
|
111
|
+
this.setAttribute(props[p].attribute ?? camelToDashCase(p), '');
|
|
112
|
+
else
|
|
113
|
+
this.removeAttribute(props[p].attribute ?? camelToDashCase(p));
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
if (props[p].type === Object || props[p].type === Array)
|
|
117
|
+
this.setAttribute(props[p].attribute ?? camelToDashCase(p), JSON.stringify(newValue));
|
|
118
|
+
else
|
|
119
|
+
this.setAttribute(props[p].attribute ?? camelToDashCase(p), newValue);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//@ts-ignore
|
|
123
|
+
if (this.constructor._enableBindings)
|
|
124
|
+
this._bindingsRefresh(p);
|
|
125
|
+
instance.dispatchEvent(new CustomEvent(camelToDashCase(p) + '-changed', { detail: { newValue } }));
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
enumerable: true,
|
|
129
|
+
configurable: true,
|
|
130
|
+
});
|
|
131
|
+
if (props[p].default) {
|
|
132
|
+
instance['_' + p] = props[p].default;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return instance;
|
|
136
|
+
};
|
|
137
|
+
//window[name].style = style;
|
|
138
|
+
window[name].properties = props;
|
|
139
|
+
window[name]._propertiesDictionary = null;
|
|
140
|
+
window[name]._enableBindings = this.enableBindings;
|
|
141
|
+
window[name]._definingElement = this;
|
|
142
|
+
window[name]._styles = null;
|
|
143
|
+
window[name].prototype = Object.create(BaseDeclaritiveWebcomponent.prototype, { constructor: { value: window[name] } });
|
|
144
|
+
if (!customElements.get(name))
|
|
145
|
+
customElements.define(name, window[name]);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
upgradeAllInstances(template) {
|
|
149
|
+
window[this.name].template = template ?? this.querySelector('template');
|
|
150
|
+
const styles = this.querySelectorAll('style[type=adopted-css]');
|
|
151
|
+
if (styles?.length)
|
|
152
|
+
window[this.name]._styles = Array.from(styles).map(x => cssFromString(x.textContent));
|
|
153
|
+
const instanceArray = instanceMap.get(this.name);
|
|
154
|
+
for (const i of instanceArray)
|
|
155
|
+
i._reapplyTemplateAfterUpdate();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
customElements.define("node-projects-dce", DeclaritiveBaseCustomWebcomponent);
|
|
159
|
+
/*
|
|
160
|
+
<node-projects-dce name="simple-dce-demo" properties='{"list":"Array", "list2":"Array", "ctx":{"type":"String","reflect":true}}' enable-bindings >
|
|
161
|
+
<template>
|
|
162
|
+
<style>h1 {color: red}</style>
|
|
163
|
+
<h1>Hello World</h1>
|
|
164
|
+
<div style="border: solid 3px black">Ctx: [[this.ctx]]</div>
|
|
165
|
+
<template repeat:myitem="[[this.list]]">
|
|
166
|
+
<button>[[myitem.toUpperCase()]] - <b>[[myitem.toLowerCase()]]</b> - [[index]]</button>
|
|
167
|
+
<ul>
|
|
168
|
+
<template repeat:myitem2="[[this.list2]]" repeat-index="inneridx">
|
|
169
|
+
<button @click="[[this.ctx = myitem2]]" >[[myitem.toUpperCase()]] - <b>[[myitem2.toLowerCase()]]</b> - [[inneridx * 100]]</button>
|
|
170
|
+
</template>
|
|
171
|
+
</ul>
|
|
172
|
+
</template>
|
|
173
|
+
</template>
|
|
174
|
+
</node-projects-dce>
|
|
175
|
+
<simple-dce-demo list='["aa","bb","cc"]' list2='["hello", "you"]' ctx="TestCtx" style="position:absolute;left:184px;top:-53px;"></simple-dce-demo>
|
|
176
|
+
*/
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export class DomHelper {
|
|
2
|
+
static *getAllChildNodes(element, includeShadowDom = false, ignore) {
|
|
3
|
+
if (!ignore || ignore.indexOf(element) < 0) {
|
|
4
|
+
if (element.children) {
|
|
5
|
+
for (const node of element.children) {
|
|
6
|
+
yield node;
|
|
7
|
+
const childs = DomHelper.getAllChildNodes(node, includeShadowDom, ignore);
|
|
8
|
+
for (const cnode of childs) {
|
|
9
|
+
yield cnode;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
if (includeShadowDom && element.shadowRoot != null) {
|
|
14
|
+
yield element.shadowRoot;
|
|
15
|
+
const childs = DomHelper.getAllChildNodes(element.shadowRoot, includeShadowDom, ignore);
|
|
16
|
+
for (const cnode of childs) {
|
|
17
|
+
yield cnode;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
static removeAllChildnodes(node, selector) {
|
|
24
|
+
if (!selector) {
|
|
25
|
+
for (let c = node.firstChild; c !== null; c = node.firstChild) {
|
|
26
|
+
node.removeChild(c);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
const elements = node.querySelectorAll(selector);
|
|
31
|
+
for (const e of elements) {
|
|
32
|
+
if (e.parentNode == node)
|
|
33
|
+
node.removeChild(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
static nodeIndex(node) {
|
|
38
|
+
let i = 0;
|
|
39
|
+
while ((node = node.previousSibling) != null)
|
|
40
|
+
i++;
|
|
41
|
+
return i;
|
|
42
|
+
}
|
|
43
|
+
static childIndex(node) {
|
|
44
|
+
for (let i = 0; i < node.parentElement.children.length; i++)
|
|
45
|
+
if (node.parentElement.children[i] == node)
|
|
46
|
+
return i;
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
static getHost(node) {
|
|
50
|
+
return node.getRootNode()?.host;
|
|
51
|
+
}
|
|
52
|
+
static nodeIsChildOf(node, parentNode) {
|
|
53
|
+
while (node.parentElement) {
|
|
54
|
+
if (node.parentElement == parentNode)
|
|
55
|
+
return true;
|
|
56
|
+
node = node.parentElement;
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
static findParentNodeOfWithLocalName(element, localName) {
|
|
61
|
+
let el = element;
|
|
62
|
+
while (true) {
|
|
63
|
+
if (el.parentElement != null) {
|
|
64
|
+
el = el.parentElement;
|
|
65
|
+
}
|
|
66
|
+
else if (el.parentNode != null && el.parentNode.host != null) {
|
|
67
|
+
el = el.parentNode.host;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
if (el.localName == localName) {
|
|
73
|
+
return el;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
static findParentNodeOfType(element, type) {
|
|
79
|
+
let el = element;
|
|
80
|
+
while (true) {
|
|
81
|
+
if (el.parentElement != null) {
|
|
82
|
+
el = el.parentElement;
|
|
83
|
+
}
|
|
84
|
+
else if (el.parentNode != null && el.parentNode.host != null) {
|
|
85
|
+
el = el.parentNode.host;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (el instanceof type) {
|
|
91
|
+
return el;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { BaseCustomWebComponentNoAttachedTemplate } from "./BaseCustomWebComponent.js";
|
|
2
|
+
export function getFunctionType(x) {
|
|
3
|
+
return typeof x === 'function'
|
|
4
|
+
? x.prototype
|
|
5
|
+
? Object.getOwnPropertyDescriptor(x, 'prototype').writable
|
|
6
|
+
? 'function'
|
|
7
|
+
: 'class'
|
|
8
|
+
: x.constructor.name === 'AsyncFunction'
|
|
9
|
+
? 'async'
|
|
10
|
+
: 'arrow'
|
|
11
|
+
: '';
|
|
12
|
+
}
|
|
13
|
+
export class HotModuleReplacement {
|
|
14
|
+
static changesFetcher;
|
|
15
|
+
static instances = [];
|
|
16
|
+
static initHMR(fetchChangedFiles) {
|
|
17
|
+
HotModuleReplacement.changesFetcher = fetchChangedFiles;
|
|
18
|
+
BaseCustomWebComponentNoAttachedTemplate.instanceCreatedCallback = (i) => {
|
|
19
|
+
HotModuleReplacement.instances.push(new WeakRef(i));
|
|
20
|
+
};
|
|
21
|
+
HotModuleReplacement.startPolling();
|
|
22
|
+
}
|
|
23
|
+
static startPolling(interval = 100) {
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
HotModuleReplacement.pollForChanges(interval);
|
|
26
|
+
}, interval);
|
|
27
|
+
}
|
|
28
|
+
static async pollForChanges(interval) {
|
|
29
|
+
let changes = await HotModuleReplacement.changesFetcher();
|
|
30
|
+
if (changes != null) {
|
|
31
|
+
for (let file of changes) {
|
|
32
|
+
HotModuleReplacement.assertFileType(file);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setTimeout(() => {
|
|
36
|
+
HotModuleReplacement.pollForChanges(interval);
|
|
37
|
+
}, interval);
|
|
38
|
+
}
|
|
39
|
+
static assertFileType(file) {
|
|
40
|
+
switch (file.trim().toLowerCase().split(".").pop()) {
|
|
41
|
+
case "css":
|
|
42
|
+
console.warn("🔥 Hot reload - css: " + file);
|
|
43
|
+
HotModuleReplacement.reloadCss(file);
|
|
44
|
+
break;
|
|
45
|
+
case "js":
|
|
46
|
+
case "cjs":
|
|
47
|
+
case "mjs":
|
|
48
|
+
console.warn("🔥 Hot reload - js: " + file);
|
|
49
|
+
HotModuleReplacement.reloadJs(file);
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
static async reloadJs(file) {
|
|
56
|
+
let oldModule = await import(file);
|
|
57
|
+
let oldDefine = customElements.define;
|
|
58
|
+
customElements.define = () => null;
|
|
59
|
+
let newModule = await import(file + "?reload=" + new Date().getTime());
|
|
60
|
+
customElements.define = oldDefine;
|
|
61
|
+
for (let nameOfexport in newModule) {
|
|
62
|
+
const classExport = newModule[nameOfexport];
|
|
63
|
+
if (getFunctionType(classExport) == 'class') {
|
|
64
|
+
let i = HotModuleReplacement.instances.length;
|
|
65
|
+
while (i--) {
|
|
66
|
+
let instanceRef = HotModuleReplacement.instances[i];
|
|
67
|
+
let instance = instanceRef.deref();
|
|
68
|
+
if (instance) {
|
|
69
|
+
if (classExport.name == instance.constructor.name) {
|
|
70
|
+
if (instance._hmrCallback)
|
|
71
|
+
instance._hmrCallback(classExport);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
HotModuleReplacement.instances.splice(i, 1);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
for (let nameOfexport in oldModule) {
|
|
81
|
+
const oExport = oldModule[nameOfexport];
|
|
82
|
+
if (getFunctionType(oExport) == 'class') {
|
|
83
|
+
const newExport = newModule[nameOfexport];
|
|
84
|
+
if (newExport) {
|
|
85
|
+
// Gets all attribute-properties of class
|
|
86
|
+
let properties = Object.getOwnPropertyNames(oExport);
|
|
87
|
+
for (let property of properties) {
|
|
88
|
+
if (property == 'prototype' || property == 'name' || property == 'length')
|
|
89
|
+
continue;
|
|
90
|
+
delete oExport[property];
|
|
91
|
+
try {
|
|
92
|
+
oExport[property] = newExport[property];
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
console.error("🔥 Hot reload - error setting property '" + property + "' of '" + oExport.name + "'", err);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
properties = Object.getOwnPropertyNames(oExport.prototype);
|
|
99
|
+
for (let property of properties) {
|
|
100
|
+
if (property == 'prototype' || property == 'name' || property == 'length')
|
|
101
|
+
continue;
|
|
102
|
+
delete oExport[property];
|
|
103
|
+
try {
|
|
104
|
+
oExport.prototype[property] = newExport.prototype[property];
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
console.error("🔥 Hot reload - error setting property '" + property + "' of '" + oExport.name + "'", err);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
// Change the url of the stylesheet to force a reload
|
|
115
|
+
static async reloadCss(file) {
|
|
116
|
+
const newId = new Date().getTime();
|
|
117
|
+
for (let link of document.querySelectorAll(`link[href*="${file}"]`))
|
|
118
|
+
link.href = link.href.split("?")[0] + "?reload=" + newId;
|
|
119
|
+
const oldCssModule = await import(file, { assert: { type: 'css' } });
|
|
120
|
+
const newCssModule = await import(file + "?reload=" + newId, { assert: { type: 'css' } });
|
|
121
|
+
const oldStylesheet = oldCssModule.default;
|
|
122
|
+
const newStylesheet = newCssModule.default;
|
|
123
|
+
oldStylesheet.replace(Array.from(newStylesheet.cssRules).map(rule => rule.cssText).join(''));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export class LazyLoader {
|
|
2
|
+
static LoadJavascript(file) {
|
|
3
|
+
const checkName = '_' + file + '-loaded';
|
|
4
|
+
if (LazyLoader[checkName]) {
|
|
5
|
+
return Promise.resolve(false);
|
|
6
|
+
}
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
const el = document.createElement('script');
|
|
9
|
+
el.src = file;
|
|
10
|
+
el.onload = e => {
|
|
11
|
+
LazyLoader[checkName] = true;
|
|
12
|
+
resolve(true);
|
|
13
|
+
};
|
|
14
|
+
el.onerror = err => {
|
|
15
|
+
reject(err);
|
|
16
|
+
};
|
|
17
|
+
window.document.head.appendChild(el);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
static LoadJavascripts(...files) {
|
|
21
|
+
let p = [];
|
|
22
|
+
for (let f of files) {
|
|
23
|
+
p.push(LazyLoader.LoadJavascript(f));
|
|
24
|
+
}
|
|
25
|
+
return Promise.all(p);
|
|
26
|
+
}
|
|
27
|
+
static LoadText(url) {
|
|
28
|
+
return new Promise(function (resolve, reject) {
|
|
29
|
+
const xhr = new XMLHttpRequest();
|
|
30
|
+
xhr.open('GET', url);
|
|
31
|
+
xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
|
32
|
+
xhr.onload = () => {
|
|
33
|
+
if (xhr.status >= 200 && xhr.status < 300) {
|
|
34
|
+
resolve(xhr.response);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
reject({
|
|
38
|
+
status: xhr.status,
|
|
39
|
+
statusText: xhr.statusText,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
xhr.onerror = () => {
|
|
44
|
+
reject({
|
|
45
|
+
status: xhr.status,
|
|
46
|
+
statusText: xhr.statusText,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
xhr.send();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
let m = new WeakMap();
|
|
2
|
+
export function addTouchFriendlyContextMenu(element, callback) {
|
|
3
|
+
let cb = (e) => {
|
|
4
|
+
let t = setTimeout(() => {
|
|
5
|
+
callback(e);
|
|
6
|
+
}, 500);
|
|
7
|
+
window.addEventListener('touchend', () => {
|
|
8
|
+
clearTimeout(t);
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
element.addEventListener('touchstart', cb);
|
|
12
|
+
element.addEventListener('contextmenu', callback);
|
|
13
|
+
m.set(callback, cb);
|
|
14
|
+
}
|
|
15
|
+
export function removeTouchFriendlyContextMenu(element, callback) {
|
|
16
|
+
let cb = m.get(callback);
|
|
17
|
+
m.delete(callback);
|
|
18
|
+
element.removeEventListener('touchstart', cb);
|
|
19
|
+
element.removeEventListener('contextmenu', cb);
|
|
20
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export class PropertyChangedArgs {
|
|
2
|
+
constructor(newValue, oldValue) {
|
|
3
|
+
this.newValue = newValue;
|
|
4
|
+
this.oldValue = oldValue;
|
|
5
|
+
}
|
|
6
|
+
oldValue;
|
|
7
|
+
newValue;
|
|
8
|
+
}
|
|
9
|
+
export class TypedEvent {
|
|
10
|
+
listeners = [];
|
|
11
|
+
listenersOncer = [];
|
|
12
|
+
listenerSingle = null;
|
|
13
|
+
on = (listener) => {
|
|
14
|
+
this.listeners.push(listener);
|
|
15
|
+
return {
|
|
16
|
+
dispose: () => this.off(listener)
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
single = (listener) => {
|
|
20
|
+
this.listenerSingle = listener;
|
|
21
|
+
return {
|
|
22
|
+
dispose: () => { if (this.listenerSingle === listener)
|
|
23
|
+
this.listenerSingle = null; }
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
once = (listener) => {
|
|
27
|
+
this.listenersOncer.push(listener);
|
|
28
|
+
};
|
|
29
|
+
off = (listener) => {
|
|
30
|
+
let callbackIndex = this.listeners.indexOf(listener);
|
|
31
|
+
if (callbackIndex > -1)
|
|
32
|
+
this.listeners.splice(callbackIndex, 1);
|
|
33
|
+
};
|
|
34
|
+
emit = (event) => {
|
|
35
|
+
this.listeners.forEach((listener) => listener(event));
|
|
36
|
+
if (this.listenersOncer.length > 0) {
|
|
37
|
+
const toCall = this.listenersOncer;
|
|
38
|
+
this.listenersOncer = [];
|
|
39
|
+
toCall.forEach(listener => listener(event));
|
|
40
|
+
}
|
|
41
|
+
if (this.listenerSingle) {
|
|
42
|
+
this.listenerSingle(event);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
pipe = (te) => {
|
|
46
|
+
return this.on((e) => te.emit(e));
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class WeakArray {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.#finalizationRegistry = new FinalizationRegistry((obj) => {
|
|
4
|
+
this.#items.delete(obj);
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
#items = new Set();
|
|
8
|
+
#finalizationRegistry;
|
|
9
|
+
add(obj) {
|
|
10
|
+
const wref = new WeakRef(obj);
|
|
11
|
+
this.#items.add(wref);
|
|
12
|
+
this.#finalizationRegistry.register(obj, wref);
|
|
13
|
+
return wref;
|
|
14
|
+
}
|
|
15
|
+
remove(obj) {
|
|
16
|
+
this.#items.delete(obj);
|
|
17
|
+
}
|
|
18
|
+
*[Symbol.iterator]() {
|
|
19
|
+
for (const o of this.#items) {
|
|
20
|
+
const v = o.deref();
|
|
21
|
+
if (v)
|
|
22
|
+
yield v;
|
|
23
|
+
else
|
|
24
|
+
this.#items.delete(o);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./BaseCustomWebComponent.js";
|
|
2
|
+
export * from "./DomHelper.js";
|
|
3
|
+
export * from "./LazyLoader.js";
|
|
4
|
+
export * from "./TypedEvent.js";
|
|
5
|
+
export * from "./TouchContextMenu.js";
|
|
6
|
+
export * from "./Debounce.js";
|
|
7
|
+
export * from "./DeclaritiveBaseCustomWebcomponent.js";
|
|
8
|
+
export * from "./WeakArray.js";
|
|
9
|
+
//export * from "./HotModuleReplacement.js"
|
package/www/node_modules/@node-projects/web-component-designer/dist/elements/helper/getBoxQuads.js
CHANGED
|
@@ -143,7 +143,7 @@ export function getBoxQuads(node, options) {
|
|
|
143
143
|
return q;
|
|
144
144
|
}
|
|
145
145
|
/** @type {DOMMatrix} */
|
|
146
|
-
let originalElementAndAllParentsMultipliedMatrix = getResultingTransformationBetweenElementAndAllAncestors(node, options?.relativeTo ?? document.body, options
|
|
146
|
+
let originalElementAndAllParentsMultipliedMatrix = getResultingTransformationBetweenElementAndAllAncestors(node, options?.relativeTo ?? document.body, options?.iframes);
|
|
147
147
|
let { width, height } = getElementSize(node, originalElementAndAllParentsMultipliedMatrix);
|
|
148
148
|
let arr = [{ x: 0, y: 0 }, { x: width, y: 0 }, { x: width, y: height }, { x: 0, y: height }];
|
|
149
149
|
/** @type { [DOMPoint, DOMPoint, DOMPoint, DOMPoint] } */
|
|
@@ -234,11 +234,12 @@ export function getElementSize(node, matrix) {
|
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
236
|
* @param {Node} node
|
|
237
|
+
* @param {boolean} includeScroll
|
|
237
238
|
* @param {HTMLIFrameElement[]} iframes
|
|
238
239
|
*/
|
|
239
|
-
function getElementOffsetsInContainer(node, iframes) {
|
|
240
|
+
function getElementOffsetsInContainer(node, includeScroll, iframes) {
|
|
240
241
|
if (node instanceof (node.ownerDocument.defaultView ?? window).HTMLElement) {
|
|
241
|
-
return new DOMPoint(node.offsetLeft - node.scrollLeft, node.offsetTop - node.scrollTop);
|
|
242
|
+
return new DOMPoint(node.offsetLeft - (includeScroll ? node.scrollLeft : 0), node.offsetTop - (includeScroll ? node.scrollTop : 0));
|
|
242
243
|
}
|
|
243
244
|
else if (node instanceof (node.ownerDocument.defaultView ?? window).Text) {
|
|
244
245
|
const range = document.createRange();
|
|
@@ -306,22 +307,20 @@ export function getResultingTransformationBetweenElementAndAllAncestors(node, an
|
|
|
306
307
|
let lastOffsetParent = null;
|
|
307
308
|
while (actualElement != ancestor && actualElement != null) {
|
|
308
309
|
const parentElement = getParentElementIncludingSlots(actualElement, iframes);
|
|
309
|
-
if (
|
|
310
|
-
if (actualElement instanceof (actualElement.ownerDocument.defaultView ?? window).
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
lastOffsetParent = actualElement.offsetParent;
|
|
314
|
-
const mvMat = new DOMMatrix().translate(offsets.x, offsets.y);
|
|
315
|
-
originalElementAndAllParentsMultipliedMatrix = mvMat.multiply(originalElementAndAllParentsMultipliedMatrix);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
const offsets = getElementOffsetsInContainer(actualElement, iframes);
|
|
320
|
-
lastOffsetParent = null;
|
|
310
|
+
if (actualElement instanceof (actualElement.ownerDocument.defaultView ?? window).HTMLElement) {
|
|
311
|
+
if (lastOffsetParent !== actualElement.offsetParent && !(actualElement instanceof (actualElement.ownerDocument.defaultView ?? window).HTMLSlotElement)) {
|
|
312
|
+
const offsets = getElementOffsetsInContainer(actualElement, actualElement !== node, iframes);
|
|
313
|
+
lastOffsetParent = actualElement.offsetParent;
|
|
321
314
|
const mvMat = new DOMMatrix().translate(offsets.x, offsets.y);
|
|
322
315
|
originalElementAndAllParentsMultipliedMatrix = mvMat.multiply(originalElementAndAllParentsMultipliedMatrix);
|
|
323
316
|
}
|
|
324
317
|
}
|
|
318
|
+
else {
|
|
319
|
+
const offsets = getElementOffsetsInContainer(actualElement, actualElement !== node, iframes);
|
|
320
|
+
lastOffsetParent = null;
|
|
321
|
+
const mvMat = new DOMMatrix().translate(offsets.x, offsets.y);
|
|
322
|
+
originalElementAndAllParentsMultipliedMatrix = mvMat.multiply(originalElementAndAllParentsMultipliedMatrix);
|
|
323
|
+
}
|
|
325
324
|
if (parentElement) {
|
|
326
325
|
parentElementMatrix = getElementCombinedTransform(parentElement, iframes);
|
|
327
326
|
if (parentElement != ancestor)
|