neo.mjs 5.15.0 → 5.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/ServiceWorker.mjs +2 -2
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/component/Base.mjs +92 -106
- package/src/core/Base.mjs +1 -1
package/apps/ServiceWorker.mjs
CHANGED
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -245,12 +245,12 @@ const DefaultConfig = {
|
|
245
245
|
useVdomWorker: true,
|
246
246
|
/**
|
247
247
|
* buildScripts/injectPackageVersion.mjs will update this value
|
248
|
-
* @default '5.15.
|
248
|
+
* @default '5.15.2'
|
249
249
|
* @memberOf! module:Neo
|
250
250
|
* @name config.version
|
251
251
|
* @type String
|
252
252
|
*/
|
253
|
-
version: '5.15.
|
253
|
+
version: '5.15.2'
|
254
254
|
};
|
255
255
|
|
256
256
|
Object.assign(DefaultConfig, {
|
package/src/component/Base.mjs
CHANGED
@@ -709,45 +709,7 @@ class Base extends CoreBase {
|
|
709
709
|
* @protected
|
710
710
|
*/
|
711
711
|
afterSetVdom(value, oldValue) {
|
712
|
-
|
713
|
-
app = Neo.apps[me.appName],
|
714
|
-
vdom = value,
|
715
|
-
listenerId;
|
716
|
-
|
717
|
-
// It is important to keep the vdom tree stable to ensure that containers do not lose the references to their
|
718
|
-
// child vdom trees. The if case should not happen, but in case it does, keeping the reference and merging
|
719
|
-
// the content over seems to be the best strategy
|
720
|
-
if (me._vdom !== vdom) {
|
721
|
-
Logger.warn('vdom got replaced for: ' + me.id + '. Copying the content into the reference holder object');
|
722
|
-
|
723
|
-
Object.keys(me._vdom).forEach(key => {
|
724
|
-
delete me._vdom[key]
|
725
|
-
});
|
726
|
-
|
727
|
-
vdom = Object.assign(me._vdom, vdom)
|
728
|
-
}
|
729
|
-
|
730
|
-
if (!me.needsParentUpdate()) {
|
731
|
-
if (me.silentVdomUpdate) {
|
732
|
-
me.needsVdomUpdate = true
|
733
|
-
} else {
|
734
|
-
if (!me.mounted && me.isConstructed && !me.hasRenderingListener && app?.rendering === true) {
|
735
|
-
me.hasRenderingListener = true;
|
736
|
-
|
737
|
-
listenerId = app.on('mounted', () => {
|
738
|
-
app.un('mounted', listenerId);
|
739
|
-
|
740
|
-
setTimeout(() => {
|
741
|
-
me.vnode && me.updateVdom(me.vdom, me.vnode)
|
742
|
-
}, 50)
|
743
|
-
});
|
744
|
-
} else if (me.mounted && me.vnode && !me.isParentVdomUpdating()) {
|
745
|
-
me.updateVdom(vdom, me.vnode)
|
746
|
-
}
|
747
|
-
}
|
748
|
-
}
|
749
|
-
|
750
|
-
me.hasUnmountedVdomChanges = !me.mounted && me.hasBeenMounted
|
712
|
+
this.updateVdom(value)
|
751
713
|
}
|
752
714
|
|
753
715
|
/**
|
@@ -1107,6 +1069,55 @@ class Base extends CoreBase {
|
|
1107
1069
|
return ComponentManager.down(this, config, returnFirstMatch)
|
1108
1070
|
}
|
1109
1071
|
|
1072
|
+
/**
|
1073
|
+
* Internal method to send update requests to the vdom worker
|
1074
|
+
* @param {Object} vdom
|
1075
|
+
* @param {Neo.vdom.VNode} vnode
|
1076
|
+
* @param {function} [resolve] used by promiseVdomUpdate()
|
1077
|
+
* @param {function} [reject] used by promiseVdomUpdate()
|
1078
|
+
* @private
|
1079
|
+
*/
|
1080
|
+
#executeVdomUpdate(vdom, vnode, resolve, reject) {
|
1081
|
+
let me = this,
|
1082
|
+
opts = {vdom, vnode},
|
1083
|
+
deltas;
|
1084
|
+
|
1085
|
+
me.isVdomUpdating = true;
|
1086
|
+
|
1087
|
+
// we can not set the config directly => it could already be false,
|
1088
|
+
// and we still want to pass it further into subtrees
|
1089
|
+
me._needsVdomUpdate = false;
|
1090
|
+
me.afterSetNeedsVdomUpdate?.(false, true)
|
1091
|
+
|
1092
|
+
if (Neo.currentWorker.isSharedWorker) {
|
1093
|
+
opts.appName = me.appName
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
Neo.vdom.Helper.update(opts).catch(err => {
|
1097
|
+
console.log('Error attempting to update component dom', err, me);
|
1098
|
+
me.isVdomUpdating = false;
|
1099
|
+
|
1100
|
+
reject?.()
|
1101
|
+
}).then(data => {
|
1102
|
+
// checking if the component got destroyed before the update cycle is done
|
1103
|
+
if (me.id) {
|
1104
|
+
// console.log('Component vnode updated', data);
|
1105
|
+
me.vnode = data.vnode;
|
1106
|
+
me.isVdomUpdating = false;
|
1107
|
+
|
1108
|
+
deltas = data.deltas;
|
1109
|
+
|
1110
|
+
if (!Neo.config.useVdomWorker && deltas.length > 0) {
|
1111
|
+
Neo.applyDeltas(me.appName, deltas).then(() => {
|
1112
|
+
me.resolveVdomUpdate(resolve)
|
1113
|
+
})
|
1114
|
+
} else {
|
1115
|
+
me.resolveVdomUpdate(resolve)
|
1116
|
+
}
|
1117
|
+
}
|
1118
|
+
})
|
1119
|
+
}
|
1120
|
+
|
1110
1121
|
/**
|
1111
1122
|
* Calls focus() on the top level DOM node of this component or on a given node via id
|
1112
1123
|
* @param {String} id=this.id
|
@@ -1397,6 +1408,7 @@ class Base extends CoreBase {
|
|
1397
1408
|
console.warn('vdom parent update conflict with:', parent, 'for:', me)
|
1398
1409
|
}
|
1399
1410
|
|
1411
|
+
console.log('add cache', me.id);
|
1400
1412
|
NeoArray.add(parent.childUpdateCache, me.id);
|
1401
1413
|
return true
|
1402
1414
|
} else {
|
@@ -1597,34 +1609,8 @@ class Base extends CoreBase {
|
|
1597
1609
|
* @returns {Promise<any>}
|
1598
1610
|
*/
|
1599
1611
|
promiseVdomUpdate(vdom=this.vdom, vnode=this.vnode) {
|
1600
|
-
let me = this,
|
1601
|
-
_vdom = me.vdom;
|
1602
|
-
|
1603
|
-
// todo: updateVdom() should handle this
|
1604
|
-
// It is important to keep the vdom tree stable to ensure that containers do not lose the references to their
|
1605
|
-
// child vdom trees. The if case should not happen, but in case it does, keeping the reference and merging
|
1606
|
-
// the content over seems to be the best strategy
|
1607
|
-
if (_vdom !== vdom) {
|
1608
|
-
Logger.warn('vdom got replaced for: ' + me.id + '. Copying the content into the reference holder object');
|
1609
|
-
|
1610
|
-
Object.keys(_vdom).forEach(key => {
|
1611
|
-
delete _vdom[key];
|
1612
|
-
});
|
1613
|
-
|
1614
|
-
vdom = Object.assign(me._vdom, vdom)
|
1615
|
-
}
|
1616
|
-
|
1617
|
-
if (me.silentVdomUpdate) {
|
1618
|
-
return Promise.resolve()
|
1619
|
-
}
|
1620
|
-
|
1621
1612
|
return new Promise((resolve, reject) => {
|
1622
|
-
|
1623
|
-
me.updateVdom(vdom, vnode, resolve, reject)
|
1624
|
-
} else {
|
1625
|
-
me.update();
|
1626
|
-
resolve()
|
1627
|
-
}
|
1613
|
+
this.updateVdom(vdom, vnode, resolve, reject)
|
1628
1614
|
})
|
1629
1615
|
}
|
1630
1616
|
|
@@ -1975,11 +1961,12 @@ class Base extends CoreBase {
|
|
1975
1961
|
updateStyle(value, oldValue, id=this.id) {
|
1976
1962
|
let me = this,
|
1977
1963
|
delta = Style.compareStyles(value, oldValue),
|
1978
|
-
|
1979
|
-
vnode = me.vnode && VNodeUtil.findChildVnode(me.vnode, id),
|
1980
|
-
opts, vnodeStyle;
|
1964
|
+
opts, vdom, vnode, vnodeStyle;
|
1981
1965
|
|
1982
1966
|
if (delta) {
|
1967
|
+
vdom = VDomUtil.findVdomChild(me.vdom, id);
|
1968
|
+
vnode = me.vnode && VNodeUtil.findChildVnode(me.vnode, id);
|
1969
|
+
|
1983
1970
|
if (!me.hasUnmountedVdomChanges) {
|
1984
1971
|
me.hasUnmountedVdomChanges = !me.mounted && me.hasBeenMounted
|
1985
1972
|
}
|
@@ -2018,55 +2005,54 @@ class Base extends CoreBase {
|
|
2018
2005
|
|
2019
2006
|
/**
|
2020
2007
|
* Gets called after the vdom config gets changed in case the component is already mounted (delta updates).
|
2021
|
-
* @param {Object} vdom
|
2022
|
-
* @param {Neo.vdom.VNode} vnode
|
2008
|
+
* @param {Object} vdom=this.vdom
|
2009
|
+
* @param {Neo.vdom.VNode} vnode=this.vnode
|
2023
2010
|
* @param {function} [resolve] used by promiseVdomUpdate()
|
2024
2011
|
* @param {function} [reject] used by promiseVdomUpdate()
|
2025
2012
|
* @protected
|
2026
2013
|
*/
|
2027
|
-
updateVdom(vdom, vnode, resolve, reject) {
|
2028
|
-
let me
|
2029
|
-
|
2014
|
+
updateVdom(vdom=this.vdom, vnode=this.vnode, resolve, reject) {
|
2015
|
+
let me = this,
|
2016
|
+
app = Neo.apps[me.appName],
|
2017
|
+
listenerId;
|
2030
2018
|
|
2031
|
-
//
|
2032
|
-
//
|
2019
|
+
// It is important to keep the vdom tree stable to ensure that containers do not lose the references to their
|
2020
|
+
// child vdom trees. The if case should not happen, but in case it does, keeping the reference and merging
|
2021
|
+
// the content over seems to be the best strategy
|
2022
|
+
if (me._vdom !== vdom) {
|
2023
|
+
Logger.warn('vdom got replaced for: ' + me.id + '. Copying the content into the reference holder object');
|
2033
2024
|
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
me.isVdomUpdating = true;
|
2038
|
-
me.needsVdomUpdate = false;
|
2025
|
+
Object.keys(me._vdom).forEach(key => {
|
2026
|
+
delete me._vdom[key]
|
2027
|
+
});
|
2039
2028
|
|
2040
|
-
|
2029
|
+
vdom = Object.assign(me._vdom, vdom)
|
2030
|
+
}
|
2041
2031
|
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2032
|
+
if (me.silentVdomUpdate) {
|
2033
|
+
me.needsVdomUpdate = true;
|
2034
|
+
resolve?.()
|
2035
|
+
} else {
|
2036
|
+
if (!me.mounted && me.isConstructed && !me.hasRenderingListener && app?.rendering === true) {
|
2037
|
+
me.hasRenderingListener = true;
|
2045
2038
|
|
2046
|
-
|
2047
|
-
|
2048
|
-
me.isVdomUpdating = false;
|
2039
|
+
listenerId = app.on('mounted', () => {
|
2040
|
+
app.un('mounted', listenerId);
|
2049
2041
|
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
me
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
if (!Neo.config.useVdomWorker && deltas.length > 0) {
|
2061
|
-
Neo.applyDeltas(me.appName, deltas).then(() => {
|
2062
|
-
me.resolveVdomUpdate(resolve)
|
2063
|
-
})
|
2064
|
-
} else {
|
2065
|
-
me.resolveVdomUpdate(resolve)
|
2066
|
-
}
|
2042
|
+
me.timeout(50).then(() => {
|
2043
|
+
me.vnode && me.updateVdom(me.vdom, me.vnode, resolve, reject)
|
2044
|
+
})
|
2045
|
+
})
|
2046
|
+
} else {
|
2047
|
+
if (me.mounted && vnode && !me.needsParentUpdate() && !me.isParentVdomUpdating()) {
|
2048
|
+
me.#executeVdomUpdate(vdom, vnode, resolve, reject)
|
2049
|
+
} else {
|
2050
|
+
resolve?.()
|
2067
2051
|
}
|
2068
|
-
}
|
2052
|
+
}
|
2069
2053
|
}
|
2054
|
+
|
2055
|
+
me.hasUnmountedVdomChanges = !me.mounted && me.hasBeenMounted
|
2070
2056
|
}
|
2071
2057
|
}
|
2072
2058
|
|
package/src/core/Base.mjs
CHANGED
@@ -382,7 +382,7 @@ class Base {
|
|
382
382
|
}
|
383
383
|
|
384
384
|
items.forEach(item => {
|
385
|
-
Object.entries(item).forEach(([key, value]) => {
|
385
|
+
item && Object.entries(item).forEach(([key, value]) => {
|
386
386
|
if (Array.isArray(value)) {
|
387
387
|
me.parseItemConfigs(value);
|
388
388
|
} else if (typeof value === 'string' && value.startsWith('@config:')) {
|