enigmatic 0.30.0 → 0.31.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/package.json +1 -1
- package/public/client.js +17 -7
- package/public/index2.html +3 -0
package/package.json
CHANGED
package/public/client.js
CHANGED
|
@@ -25,10 +25,14 @@ const customProxy = new Proxy(window.custom, {
|
|
|
25
25
|
if (typeof value === 'function' || (value && typeof value.render === 'function')) {
|
|
26
26
|
setTimeout(() => {
|
|
27
27
|
$$(prop).forEach(async el => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
try {
|
|
29
|
+
if (typeof value === 'function') {
|
|
30
|
+
el.innerHTML = await value();
|
|
31
|
+
} else if (value && typeof value.render === 'function') {
|
|
32
|
+
el.innerHTML = value.render();
|
|
33
|
+
}
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error('Custom element error:', e);
|
|
32
36
|
}
|
|
33
37
|
});
|
|
34
38
|
}, 0);
|
|
@@ -39,7 +43,8 @@ const customProxy = new Proxy(window.custom, {
|
|
|
39
43
|
Object.defineProperty(window, 'custom', {
|
|
40
44
|
get: () => customProxy,
|
|
41
45
|
set: (val) => {
|
|
42
|
-
Object.
|
|
46
|
+
Object.keys(val || {}).forEach(key => customProxy[key] = val[key]);
|
|
47
|
+
window.initCustomElements();
|
|
43
48
|
},
|
|
44
49
|
configurable: true
|
|
45
50
|
});
|
|
@@ -119,9 +124,14 @@ window.logout = function() {
|
|
|
119
124
|
window.location.href = `${window.api_url}/logout`
|
|
120
125
|
}
|
|
121
126
|
|
|
122
|
-
// Auto-initialize on load
|
|
127
|
+
// Auto-initialize on load and watch for new elements
|
|
123
128
|
if (document.readyState === 'loading') {
|
|
124
|
-
document.addEventListener('DOMContentLoaded',
|
|
129
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
130
|
+
window.initCustomElements();
|
|
131
|
+
// Watch for new custom elements added to DOM
|
|
132
|
+
new MutationObserver(() => window.initCustomElements()).observe(document.body, { childList: true, subtree: true });
|
|
133
|
+
});
|
|
125
134
|
} else {
|
|
126
135
|
window.initCustomElements();
|
|
136
|
+
new MutationObserver(() => window.initCustomElements()).observe(document.body, { childList: true, subtree: true });
|
|
127
137
|
}
|