neo.mjs 10.0.0-beta.4 → 10.0.0-beta.5

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.
Files changed (46) hide show
  1. package/.github/RELEASE_NOTES/v10.0.0-beta.4.md +2 -2
  2. package/ServiceWorker.mjs +2 -2
  3. package/apps/portal/index.html +1 -1
  4. package/apps/portal/view/home/FooterContainer.mjs +1 -1
  5. package/examples/button/effect/MainContainer.mjs +207 -0
  6. package/examples/button/effect/app.mjs +6 -0
  7. package/examples/button/effect/index.html +11 -0
  8. package/examples/button/effect/neo-config.json +6 -0
  9. package/learn/guides/datahandling/StateProviders.md +1 -0
  10. package/learn/guides/fundamentals/DeclarativeVDOMWithEffects.md +166 -0
  11. package/learn/tree.json +1 -0
  12. package/package.json +2 -2
  13. package/src/DefaultConfig.mjs +2 -2
  14. package/src/Neo.mjs +226 -78
  15. package/src/button/Effect.mjs +435 -0
  16. package/src/collection/Base.mjs +7 -2
  17. package/src/component/Base.mjs +67 -46
  18. package/src/container/Base.mjs +28 -24
  19. package/src/core/Base.mjs +138 -19
  20. package/src/core/Config.mjs +123 -32
  21. package/src/core/Effect.mjs +127 -0
  22. package/src/core/EffectBatchManager.mjs +68 -0
  23. package/src/core/EffectManager.mjs +38 -0
  24. package/src/grid/Container.mjs +8 -4
  25. package/src/grid/column/Component.mjs +1 -1
  26. package/src/state/Provider.mjs +343 -452
  27. package/src/state/createHierarchicalDataProxy.mjs +124 -0
  28. package/src/tab/header/EffectButton.mjs +75 -0
  29. package/src/vdom/Helper.mjs +9 -10
  30. package/src/vdom/VNode.mjs +1 -1
  31. package/src/worker/App.mjs +0 -5
  32. package/test/siesta/siesta.js +32 -0
  33. package/test/siesta/tests/CollectionBase.mjs +10 -10
  34. package/test/siesta/tests/VdomHelper.mjs +22 -59
  35. package/test/siesta/tests/config/AfterSetConfig.mjs +100 -0
  36. package/test/siesta/tests/{ReactiveConfigs.mjs → config/Basic.mjs} +58 -21
  37. package/test/siesta/tests/config/CircularDependencies.mjs +166 -0
  38. package/test/siesta/tests/config/CustomFunctions.mjs +69 -0
  39. package/test/siesta/tests/config/Hierarchy.mjs +94 -0
  40. package/test/siesta/tests/config/MemoryLeak.mjs +92 -0
  41. package/test/siesta/tests/config/MultiLevelHierarchy.mjs +85 -0
  42. package/test/siesta/tests/core/Effect.mjs +131 -0
  43. package/test/siesta/tests/core/EffectBatching.mjs +322 -0
  44. package/test/siesta/tests/neo/MixinStaticConfig.mjs +138 -0
  45. package/test/siesta/tests/state/Provider.mjs +537 -0
  46. package/test/siesta/tests/state/createHierarchicalDataProxy.mjs +217 -0
@@ -13,8 +13,8 @@ The centerpiece of this release is the new reactive config system, internally na
13
13
  // In ComponentA
14
14
  const componentB = Neo.get('b');
15
15
 
16
- // Subscribe to changes in componentB's 'items' config
17
- this.cleanup = componentB.getConfig('items').subscribe((newValue, oldValue) => {
16
+ // Subscribe to changes in componentB's 'text' config
17
+ this.cleanup = componentB.getConfig('text').subscribe((newValue, oldValue) => {
18
18
  this.someOtherProperty = newValue; // Reactively update
19
19
  });
20
20
 
package/ServiceWorker.mjs CHANGED
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='10.0.0-beta.4'
23
+ * @member {String} version='10.0.0-beta.5'
24
24
  */
25
- version: '10.0.0-beta.4'
25
+ version: '10.0.0-beta.5'
26
26
  }
27
27
 
28
28
  /**
@@ -16,7 +16,7 @@
16
16
  "@type": "Organization",
17
17
  "name": "Neo.mjs"
18
18
  },
19
- "datePublished": "2025-07-04",
19
+ "datePublished": "2025-07-09",
20
20
  "publisher": {
21
21
  "@type": "Organization",
22
22
  "name": "Neo.mjs"
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- text : 'v10.0.0-beta.4'
110
+ text : 'v10.0.0-beta.5'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -0,0 +1,207 @@
1
+ import CheckBox from '../../../src/form/field/CheckBox.mjs';
2
+ import ComboBox from '../../../src/form/field/ComboBox.mjs';
3
+ import ConfigurationViewport from '../../ConfigurationViewport.mjs';
4
+ import EffectButton from '../../../src/button/Effect.mjs';
5
+ import NumberField from '../../../src/form/field/Number.mjs';
6
+ import Radio from '../../../src/form/field/Radio.mjs';
7
+ import TextField from '../../../src/form/field/Text.mjs';
8
+
9
+ /**
10
+ * @class Neo.examples.button.effect.MainContainer
11
+ * @extends Neo.examples.ConfigurationViewport
12
+ */
13
+ class MainContainer extends ConfigurationViewport {
14
+ static config = {
15
+ className : 'Neo.examples.button.effect.MainContainer',
16
+ configItemLabelWidth: 160,
17
+ configItemWidth : 280,
18
+ layout : {ntype: 'hbox', align: 'stretch'}
19
+ }
20
+
21
+ createConfigurationComponents() {
22
+ let me = this;
23
+
24
+ return [{
25
+ module : Radio,
26
+ checked : me.exampleComponent.badgePosition === 'bottom-left',
27
+ hideValueLabel: false,
28
+ labelText : 'badgePosition',
29
+ listeners : {change: me.onRadioChange.bind(me, 'badgePosition', 'bottom-left')},
30
+ name : 'badgePosition',
31
+ valueLabelText: 'bottom-left'
32
+ }, {
33
+ module : Radio,
34
+ checked : me.exampleComponent.badgePosition === 'bottom-right',
35
+ hideValueLabel: false,
36
+ labelText : '',
37
+ listeners : {change: me.onRadioChange.bind(me, 'badgePosition', 'bottom-right')},
38
+ name : 'badgePosition',
39
+ valueLabelText: 'bottom-right'
40
+ }, {
41
+ module : Radio,
42
+ checked : me.exampleComponent.badgePosition === 'top-left',
43
+ hideValueLabel: false,
44
+ labelText : '',
45
+ listeners : {change: me.onRadioChange.bind(me, 'badgePosition', 'top-left')},
46
+ name : 'badgePosition',
47
+ valueLabelText: 'top-left'
48
+ }, {
49
+ module : Radio,
50
+ checked : me.exampleComponent.badgePosition === 'top-right',
51
+ hideValueLabel: false,
52
+ labelText : '',
53
+ listeners : {change: me.onRadioChange.bind(me, 'badgePosition', 'top-right')},
54
+ name : 'badgePosition',
55
+ valueLabelText: 'top-right'
56
+ }, {
57
+ module : TextField,
58
+ labelText : 'badgeText',
59
+ listeners : {change: me.onConfigChange.bind(me, 'badgeText')},
60
+ style : {marginTop: '10px'},
61
+ value : me.exampleComponent.badgeText
62
+ }, {
63
+ module : CheckBox,
64
+ checked : me.exampleComponent.disabled,
65
+ labelText: 'disabled',
66
+ listeners: {change: me.onConfigChange.bind(me, 'disabled')},
67
+ style : {marginTop: '10px'}
68
+ }, {
69
+ module : NumberField,
70
+ clearable : true,
71
+ labelText : 'height',
72
+ listeners : {change: me.onConfigChange.bind(me, 'height')},
73
+ maxValue : 300,
74
+ minValue : 30,
75
+ stepSize : 5,
76
+ style : {marginTop: '10px'},
77
+ value : me.exampleComponent.height
78
+ }, {
79
+ module : TextField, // todo: selectField with options
80
+ labelText : 'iconCls',
81
+ listeners : {change: me.onConfigChange.bind(me, 'iconCls')},
82
+ value : me.exampleComponent.iconCls
83
+ }, {
84
+ module : TextField, // todo: colorPickerField
85
+ clearable : true,
86
+ labelText : 'iconColor',
87
+ listeners : {change: me.onConfigChange.bind(me, 'iconColor')},
88
+ value : me.exampleComponent.iconColor
89
+ }, {
90
+ module : Radio,
91
+ checked : me.exampleComponent.iconPosition === 'top',
92
+ hideValueLabel: false,
93
+ labelText : 'iconPosition',
94
+ listeners : {change: me.onRadioChange.bind(me, 'iconPosition', 'top')},
95
+ name : 'iconPosition',
96
+ style : {marginTop: '10px'},
97
+ valueLabelText: 'top'
98
+ }, {
99
+ module : Radio,
100
+ checked : me.exampleComponent.iconPosition === 'right',
101
+ hideValueLabel: false,
102
+ labelText : '',
103
+ listeners : {change: me.onRadioChange.bind(me, 'iconPosition', 'right')},
104
+ name : 'iconPosition',
105
+ valueLabelText: 'right'
106
+ }, {
107
+ module : Radio,
108
+ checked : me.exampleComponent.iconPosition === 'bottom',
109
+ hideValueLabel: false,
110
+ labelText : '',
111
+ listeners : {change: me.onRadioChange.bind(me, 'iconPosition', 'bottom')},
112
+ name : 'iconPosition',
113
+ valueLabelText: 'bottom'
114
+ }, {
115
+ module : Radio,
116
+ checked : me.exampleComponent.iconPosition === 'left',
117
+ hideValueLabel: false,
118
+ labelText : '',
119
+ listeners : {change: me.onRadioChange.bind(me, 'iconPosition', 'left')},
120
+ name : 'iconPosition',
121
+ valueLabelText: 'left'
122
+ }, {
123
+ module : NumberField,
124
+ clearable : true,
125
+ labelText : 'rippleEffectDuration',
126
+ listeners : {change: me.onConfigChange.bind(me, 'rippleEffectDuration')},
127
+ maxValue : 5000,
128
+ minValue : 100,
129
+ stepSize : 100,
130
+ style : {marginTop: '10px'},
131
+ value : me.exampleComponent.rippleEffectDuration
132
+ }, {
133
+ module : TextField,
134
+ clearable : true,
135
+ labelText : 'text',
136
+ listeners : {change: me.onConfigChange.bind(me, 'text')},
137
+ style : {marginTop: '10px'},
138
+ value : me.exampleComponent.text
139
+ }, {
140
+ module : TextField,
141
+ clearable : true,
142
+ labelText : 'tooltip',
143
+ listeners : {change: me.onConfigChange.bind(me, 'tooltip')},
144
+ style : {marginTop: '10px'},
145
+ value : me.exampleComponent.tooltip
146
+ }, {
147
+ module : ComboBox,
148
+ forceSelection: true,
149
+ labelText : 'ui',
150
+ listeners : {change: me.onConfigRecordChange.bind(me, 'ui')},
151
+ style : {marginTop: '10px'},
152
+ value : me.exampleComponent.ui,
153
+
154
+ store: {
155
+ data: [
156
+ {id: 'primary', name: 'primary'},
157
+ {id: 'secondary', name: 'secondary'},
158
+ {id: 'tertiary', name: 'tertiary'}
159
+ ]
160
+ }
161
+ }, {
162
+ module : CheckBox,
163
+ checked : me.exampleComponent.useRippleEffect,
164
+ labelText: 'useRippleEffect',
165
+ listeners: {change: me.onConfigChange.bind(me, 'useRippleEffect')},
166
+ style : {marginTop: '10px'}
167
+ }, {
168
+ module : NumberField,
169
+ clearable : true,
170
+ labelText : 'width',
171
+ listeners : {change: me.onConfigChange.bind(me, 'width')},
172
+ maxValue : 300,
173
+ minValue : 100,
174
+ stepSize : 5,
175
+ style : {marginTop: '10px'},
176
+ value : me.exampleComponent.width
177
+ }];
178
+ }
179
+
180
+ /**
181
+ * @returns {Neo.component.Base}
182
+ */
183
+ createExampleComponent() {
184
+ return Neo.create({
185
+ module : EffectButton,
186
+ badgeText: 'Badge',
187
+ flex : 'none',
188
+ handler : data => console.log('button click =>', data.component.id),
189
+ height : 50,
190
+ iconCls : 'fa fa-home',
191
+ style : {marginBottom: '1500px', marginTop: '500px'},
192
+ text : 'Hello World',
193
+ ui : 'primary',
194
+ width : 150
195
+ })
196
+ }
197
+
198
+ /**
199
+ * @param {String} config
200
+ * @param {Object} opts
201
+ */
202
+ onConfigRecordChange(config, opts) {
203
+ this.exampleComponent[config] = opts.value['id']
204
+ }
205
+ }
206
+
207
+ export default Neo.setupClass(MainContainer);
@@ -0,0 +1,6 @@
1
+ import MainContainer from './MainContainer.mjs';
2
+
3
+ export const onStart = () => Neo.app({
4
+ mainView: MainContainer,
5
+ name : 'Neo.examples.button.effect'
6
+ });
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE HTML>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <meta charset="UTF-8">
6
+ <title>Neo EffectButton</title>
7
+ </head>
8
+ <body>
9
+ <script src="../../../src/MicroLoader.mjs" type="module"></script>
10
+ </body>
11
+ </html>
@@ -0,0 +1,6 @@
1
+ {
2
+ "appPath" : "examples/button/effect/app.mjs",
3
+ "basePath" : "../../../",
4
+ "environment": "development",
5
+ "mainPath" : "./Main.mjs"
6
+ }
@@ -321,6 +321,7 @@ class MainContainerController extends Controller {
321
321
  animateTargetId: me.getReference('edit-user-button').id,
322
322
  appName : me.component.appName,
323
323
  closeAction : 'hide',
324
+ modal : true,
324
325
 
325
326
  stateProvider: {
326
327
  parent: me.getStateProvider()
@@ -0,0 +1,166 @@
1
+ ### A New Approach: Declarative VDOM with Effects
2
+
3
+ Neo.mjs v10 introduces a powerful new declarative pattern for defining a component's internal Virtual DOM (VDOM), serving as an alternative to the traditional imperative hook-based system. This approach, which leverages the new `Neo.core.Effect` class, allows developers to define a component's entire VDOM structure in a single, reactive function, similar to the `render()` method in React.
4
+
5
+ This guide will walk you through the new pattern, compare it to the classic approach, and explain when to use each.
6
+
7
+ ### The Classic Pattern: Imperative Hooks
8
+
9
+ Let's look at the traditional way a component like `Neo.button.Base` defines and updates its VDOM.
10
+
11
+ **1. Initial VDOM Structure:**
12
+ The base structure is defined in the `_vdom` config.
13
+
14
+ ```javascript readonly
15
+ // Neo.button.Base
16
+ class Button extends Component {
17
+ static config = {
18
+ _vdom: {
19
+ tag: 'button', type: 'button', cn: [
20
+ {tag: 'span', cls: ['neo-button-glyph']},
21
+ {tag: 'span', cls: ['neo-button-text']},
22
+ // ... and so on
23
+ ]
24
+ }
25
+ }
26
+ }
27
+ ```
28
+
29
+ **2. Imperative Updates:**
30
+ To make the component reactive, developers must implement specific `afterSet` hooks for each config that affects the UI. The logic is imperative and fragmented.
31
+
32
+ ```javascript readonly
33
+ // Neo.button.Base - internal framework code
34
+ afterSetIconCls(value, oldValue) {
35
+ let {iconNode} = this;
36
+ // Imperative: Manually add/remove classes
37
+ NeoArray.remove(iconNode.cls, oldValue);
38
+ NeoArray.add(iconNode.cls, value);
39
+ this.update();
40
+ }
41
+
42
+ afterSetText(value, oldValue) {
43
+ let {textNode} = this;
44
+ // Imperative: Manually set properties
45
+ textNode.removeDom = !value;
46
+ textNode.text = value;
47
+ this.update();
48
+ }
49
+
50
+ afterSetPressed(value, oldValue) {
51
+ // Imperative: Manually toggle a class
52
+ NeoArray.toggle(this.cls, 'pressed', value);
53
+ this.update();
54
+ }
55
+ ```
56
+
57
+ **Pros:**
58
+ * **Performance:** Updates are surgical and extremely fast. Only the code for the changed property is executed.
59
+
60
+ **Cons:**
61
+ * **High Cognitive Load:** To understand the component's full rendering logic, a developer must find and read multiple, separate methods.
62
+ * **Error-Prone:** Forgetting to implement a hook for a new config is a common source of bugs.
63
+
64
+ ### The New Pattern: Declarative VDOM with `Effect`
65
+
66
+ The new `EffectButton` PoC demonstrates a more modern, declarative approach.
67
+
68
+ **1. A Single, Reactive Render Function:**
69
+ Instead of fragmented hooks, the entire VDOM is generated within a `Neo.core.Effect`. This effect automatically tracks its dependencies (like `this.text` or `this.pressed`) and re-runs whenever they change.
70
+
71
+ ```javascript readonly
72
+ // button.Effect - The "Template Method"
73
+ createVdomEffect() {
74
+ return new Effect({fn: () => {
75
+ // The effect's only job is to get the config and trigger an update.
76
+ this._vdom = this.getVdomConfig();
77
+ this.update();
78
+ }});
79
+ }
80
+
81
+ // The main VDOM builder
82
+ getVdomConfig() {
83
+ return {
84
+ tag: this.pressed ? 'a' : 'button', // Declarative logic
85
+ cls: this.getVdomCls(),
86
+ cn: this.getVdomChildren()
87
+ // ... and so on
88
+ };
89
+ }
90
+ ```
91
+
92
+ **2. Centralized Logic:**
93
+ All VDOM logic is co-located, making it easy to read and understand at a glance.
94
+
95
+ ```javascript readonly
96
+ // button.Effect - Centralized class and child generation
97
+ getVdomCls() {
98
+ let vdomCls = [...this.baseCls, ...this.cls];
99
+ // Declarative: Describe what the classes should be based on state
100
+ NeoArray.toggle(vdomCls, 'no-text', !this.text);
101
+ NeoArray.toggle(vdomCls, 'pressed', this.pressed);
102
+ vdomCls.push('icon-' + this.iconPosition);
103
+ return vdomCls;
104
+ }
105
+
106
+ getVdomChildren() {
107
+ return [
108
+ // Declarative: Describe the children based on state
109
+ {tag: 'span', cls: ['neo-button-glyph', ...this._iconCls || []], removeDom: !this.iconCls},
110
+ {tag: 'span', cls: ['neo-button-text'], removeDom: !this.text, text: this.text},
111
+ // ... and so on
112
+ ];
113
+ }
114
+ ```
115
+
116
+ ### The Power of Inheritance
117
+
118
+ A key challenge with a single render function is extensibility. The new pattern solves this by using a "Template Method" design. The main effect calls smaller, overridable builder methods.
119
+
120
+ This allows a subclass like `tab.header.EffectButton` to easily extend the VDOM without duplicating code.
121
+
122
+ ```javascript readonly
123
+ // tab.header.EffectButton
124
+ class EffectTabButton extends EffectButton {
125
+ // Override to add the indicator child node
126
+ getVdomChildren() {
127
+ // Get the standard button children from the parent class
128
+ let children = super.getVdomChildren();
129
+
130
+ // Add the new indicator node
131
+ children.push({
132
+ cls: ['neo-tab-button-indicator'],
133
+ removeDom: !this.useActiveTabIndicator
134
+ });
135
+
136
+ return children;
137
+ }
138
+
139
+ // Override to add accessibility attributes
140
+ getVdomConfig() {
141
+ let vdomConfig = super.getVdomConfig();
142
+ vdomConfig.role = this.role;
143
+ if (this.pressed) {
144
+ vdomConfig['aria-selected'] = true;
145
+ }
146
+ return vdomConfig;
147
+ }
148
+ }
149
+ ```
150
+
151
+ ### When to Use Each Pattern: A Hybrid Approach
152
+
153
+ Neo.mjs v10 does not force you to choose one pattern over the other. Instead, it empowers you to use the right tool for the job.
154
+
155
+ **Use the Declarative `Effect` Pattern when (Recommended Default):**
156
+ * Building most of your application components.
157
+ * You value developer experience, readability, and maintainability.
158
+ * The component's VDOM structure can be expressed as a pure function of its state.
159
+
160
+ **Use the Imperative `afterSet` Pattern when:**
161
+ * You are building a highly complex, performance-critical component (e.g., a virtualized data grid or a canvas-based chart).
162
+ * You need to perform surgical, hand-tuned VDOM manipulations for maximum performance, bypassing a full recalculation.
163
+
164
+ ### Conclusion
165
+
166
+ The new declarative VDOM pattern is a major leap forward for component development in Neo.mjs. It provides a more modern, readable, and robust way to build components, while the classic imperative pattern remains a powerful tool for fine-grained performance optimization. By understanding both, you can build sophisticated, high-performance applications with an exceptional developer experience.
package/learn/tree.json CHANGED
@@ -26,6 +26,7 @@
26
26
  {"name": "Application Bootstrap", "parentId": "guides/fundamentals", "id": "guides/fundamentals/ApplicationBootstrap"},
27
27
  {"name": "Instance Lifecycle", "parentId": "guides/fundamentals", "id": "guides/fundamentals/InstanceLifecycle"},
28
28
  {"name": "Declarative Component Trees VS Imperative Vdom", "parentId": "guides/fundamentals", "id": "guides/fundamentals/DeclarativeComponentTreesVsImperativeVdom"},
29
+ {"name": "Declarative VDOM with Effects", "parentId": "guides/fundamentals", "id": "guides/fundamentals/DeclarativeVDOMWithEffects"},
29
30
  {"name": "Config System Deep Dive", "parentId": "guides/fundamentals", "id": "guides/fundamentals/ConfigSystemDeepDive"},
30
31
  {"name": "Extending Neo Classes", "parentId": "guides/fundamentals", "id": "guides/fundamentals/ExtendingNeoClasses"},
31
32
  {"name": "Main Thread Addons: Interacting with the Browser", "parentId": "guides/fundamentals", "id": "guides/fundamentals/MainThreadAddons"},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "neo.mjs",
3
- "version" : "10.0.0-beta.4",
3
+ "version" : "10.0.0-beta.5",
4
4
  "description" : "Neo.mjs: The multi-threaded UI framework for building ultra-fast, desktop-like web applications with uncompromised responsiveness, inherent security, and a transpilation-free dev mode.",
5
5
  "type" : "module",
6
6
  "repository" : {
@@ -96,7 +96,7 @@
96
96
  "siesta-lite" : "5.5.2",
97
97
  "terser" : "^5.43.1",
98
98
  "url" : "^0.11.4",
99
- "webpack" : "^5.99.9",
99
+ "webpack" : "^5.100.0",
100
100
  "webpack-cli" : "^6.0.1",
101
101
  "webpack-dev-server" : "^5.2.2",
102
102
  "webpack-hook-plugin" : "^1.0.7",
@@ -289,12 +289,12 @@ const DefaultConfig = {
289
289
  useVdomWorker: true,
290
290
  /**
291
291
  * buildScripts/injectPackageVersion.mjs will update this value
292
- * @default '10.0.0-beta.4'
292
+ * @default '10.0.0-beta.5'
293
293
  * @memberOf! module:Neo
294
294
  * @name config.version
295
295
  * @type String
296
296
  */
297
- version: '10.0.0-beta.4'
297
+ version: '10.0.0-beta.5'
298
298
  };
299
299
 
300
300
  Object.assign(DefaultConfig, {