neo.mjs 10.0.0-alpha.5 → 10.0.0-beta.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.
Files changed (188) hide show
  1. package/ServiceWorker.mjs +2 -2
  2. package/apps/colors/view/GridContainer.mjs +1 -1
  3. package/apps/covid/view/AttributionComponent.mjs +1 -1
  4. package/apps/covid/view/HeaderContainer.mjs +6 -6
  5. package/apps/covid/view/MainContainerController.mjs +5 -5
  6. package/apps/covid/view/TableContainerController.mjs +1 -1
  7. package/apps/covid/view/country/Gallery.mjs +13 -13
  8. package/apps/covid/view/country/Helix.mjs +13 -13
  9. package/apps/covid/view/country/HistoricalDataTable.mjs +1 -1
  10. package/apps/email/view/Viewport.mjs +2 -2
  11. package/apps/form/view/SideNavList.mjs +1 -1
  12. package/apps/portal/index.html +1 -1
  13. package/apps/portal/resources/data/examples_devmode.json +26 -27
  14. package/apps/portal/resources/data/examples_dist_dev.json +26 -27
  15. package/apps/portal/resources/data/examples_dist_esm.json +25 -26
  16. package/apps/portal/resources/data/examples_dist_prod.json +26 -27
  17. package/apps/portal/view/HeaderToolbar.mjs +3 -3
  18. package/apps/portal/view/about/Container.mjs +2 -2
  19. package/apps/portal/view/about/MemberContainer.mjs +3 -3
  20. package/apps/portal/view/blog/List.mjs +7 -7
  21. package/apps/portal/view/examples/List.mjs +4 -4
  22. package/apps/portal/view/home/ContentBox.mjs +2 -2
  23. package/apps/portal/view/home/FeatureSection.mjs +3 -3
  24. package/apps/portal/view/home/FooterContainer.mjs +7 -7
  25. package/apps/portal/view/home/parts/AfterMath.mjs +3 -3
  26. package/apps/portal/view/home/parts/MainNeo.mjs +3 -3
  27. package/apps/portal/view/home/parts/References.mjs +6 -6
  28. package/apps/portal/view/learn/ContentComponent.mjs +102 -111
  29. package/apps/portal/view/learn/PageSectionsContainer.mjs +1 -1
  30. package/apps/portal/view/learn/PageSectionsList.mjs +2 -2
  31. package/apps/portal/view/services/Component.mjs +16 -16
  32. package/apps/realworld/view/FooterComponent.mjs +1 -1
  33. package/apps/realworld/view/HeaderComponent.mjs +8 -8
  34. package/apps/realworld/view/HomeComponent.mjs +6 -6
  35. package/apps/realworld/view/article/CommentComponent.mjs +4 -4
  36. package/apps/realworld/view/article/Component.mjs +14 -14
  37. package/apps/realworld/view/article/CreateCommentComponent.mjs +3 -3
  38. package/apps/realworld/view/article/CreateComponent.mjs +3 -3
  39. package/apps/realworld/view/article/PreviewComponent.mjs +1 -1
  40. package/apps/realworld/view/article/TagListComponent.mjs +2 -2
  41. package/apps/realworld/view/user/ProfileComponent.mjs +8 -8
  42. package/apps/realworld/view/user/SettingsComponent.mjs +4 -4
  43. package/apps/realworld/view/user/SignUpComponent.mjs +4 -4
  44. package/apps/realworld2/view/FooterComponent.mjs +1 -1
  45. package/apps/realworld2/view/HomeContainer.mjs +3 -3
  46. package/apps/realworld2/view/article/DetailsContainer.mjs +1 -1
  47. package/apps/realworld2/view/article/PreviewComponent.mjs +7 -7
  48. package/apps/realworld2/view/article/TagListComponent.mjs +2 -2
  49. package/apps/realworld2/view/user/ProfileContainer.mjs +1 -1
  50. package/apps/route/view/center/CardAdministration.mjs +2 -2
  51. package/apps/route/view/center/CardAdministrationDenied.mjs +1 -1
  52. package/apps/route/view/center/CardContact.mjs +2 -2
  53. package/apps/route/view/center/CardHome.mjs +1 -1
  54. package/apps/route/view/center/CardSection1.mjs +1 -1
  55. package/apps/route/view/center/CardSection2.mjs +1 -1
  56. package/apps/sharedcovid/view/AttributionComponent.mjs +1 -1
  57. package/apps/sharedcovid/view/HeaderContainer.mjs +6 -6
  58. package/apps/sharedcovid/view/MainContainerController.mjs +5 -5
  59. package/apps/sharedcovid/view/TableContainerController.mjs +1 -1
  60. package/apps/sharedcovid/view/country/Gallery.mjs +13 -13
  61. package/apps/sharedcovid/view/country/Helix.mjs +13 -13
  62. package/apps/sharedcovid/view/country/HistoricalDataTable.mjs +1 -1
  63. package/apps/shareddialog/childapps/shareddialog2/view/MainContainer.mjs +1 -1
  64. package/apps/shareddialog/view/MainContainer.mjs +1 -1
  65. package/buildScripts/createApp.mjs +2 -2
  66. package/examples/table/cellEditing/MainContainer.mjs +1 -1
  67. package/examples/table/container/MainContainer.mjs +3 -3
  68. package/examples/table/nestedRecordFields/Viewport.mjs +6 -6
  69. package/examples/tableFiltering/MainContainer.mjs +1 -1
  70. package/examples/tablePerformance/MainContainer.mjs +1 -1
  71. package/examples/tablePerformance/MainContainer2.mjs +1 -1
  72. package/examples/tablePerformance/MainContainer3.mjs +2 -2
  73. package/examples/tableStore/MainContainer.mjs +2 -2
  74. package/learn/Glossary.md +261 -0
  75. package/learn/UsingTheseTopics.md +2 -2
  76. package/learn/benefits/ConfigSystem.md +538 -28
  77. package/learn/benefits/Effort.md +47 -2
  78. package/learn/benefits/Features.md +50 -32
  79. package/learn/benefits/FormsEngine.md +68 -38
  80. package/learn/benefits/MultiWindow.md +33 -7
  81. package/learn/benefits/OffTheMainThread.md +2 -2
  82. package/learn/benefits/Quick.md +45 -12
  83. package/learn/benefits/RPCLayer.md +75 -0
  84. package/learn/benefits/Speed.md +16 -11
  85. package/learn/gettingstarted/ComponentModels.md +4 -4
  86. package/learn/gettingstarted/Config.md +6 -6
  87. package/learn/gettingstarted/DescribingTheUI.md +4 -4
  88. package/learn/gettingstarted/Events.md +6 -6
  89. package/learn/gettingstarted/Extending.md +4 -4
  90. package/learn/gettingstarted/References.md +6 -6
  91. package/learn/gettingstarted/Workspaces.md +6 -6
  92. package/learn/guides/ApplicationBootstrap.md +26 -26
  93. package/learn/guides/ComponentsAndContainers.md +12 -12
  94. package/learn/guides/ConfigSystemDeepDive.md +280 -0
  95. package/learn/guides/CustomComponents.md +2 -2
  96. package/learn/guides/DeclarativeComponentTreesVsImperativeVdom.md +17 -17
  97. package/learn/guides/InstanceLifecycle.md +295 -1
  98. package/learn/guides/MainThreadAddons.md +475 -0
  99. package/learn/guides/PortalApp.md +2 -2
  100. package/learn/guides/StateProviders.md +12 -12
  101. package/learn/guides/WorkingWithVDom.md +14 -14
  102. package/learn/guides/events/CustomEvents.md +16 -16
  103. package/learn/guides/events/DomEvents.md +12 -12
  104. package/learn/javascript/ClassFeatures.md +3 -2
  105. package/learn/javascript/Classes.md +8 -8
  106. package/learn/javascript/NewNode.md +4 -4
  107. package/learn/javascript/Overrides.md +8 -8
  108. package/learn/javascript/Super.md +10 -8
  109. package/learn/tree.json +52 -51
  110. package/learn/tutorials/Earthquakes.md +54 -57
  111. package/learn/tutorials/TodoList.md +4 -4
  112. package/package.json +2 -2
  113. package/resources/scss/src/apps/portal/learn/ContentComponent.scss +12 -0
  114. package/resources/scss/src/table/{View.scss → Body.scss} +1 -1
  115. package/resources/scss/src/table/plugin/CellEditing.scss +1 -1
  116. package/resources/scss/theme-dark/table/{View.scss → Body.scss} +1 -1
  117. package/resources/scss/theme-light/table/{View.scss → Body.scss} +1 -1
  118. package/resources/scss/theme-neo-light/Global.scss +1 -2
  119. package/resources/scss/theme-neo-light/table/{View.scss → Body.scss} +1 -1
  120. package/src/DefaultConfig.mjs +2 -2
  121. package/src/Main.mjs +8 -7
  122. package/src/Neo.mjs +16 -2
  123. package/src/button/Base.mjs +2 -2
  124. package/src/calendar/view/SettingsContainer.mjs +2 -2
  125. package/src/calendar/view/YearComponent.mjs +9 -9
  126. package/src/calendar/view/calendars/ColorsList.mjs +1 -1
  127. package/src/calendar/view/calendars/List.mjs +1 -1
  128. package/src/calendar/view/month/Component.mjs +15 -15
  129. package/src/calendar/view/week/Component.mjs +12 -12
  130. package/src/calendar/view/week/EventDragZone.mjs +4 -4
  131. package/src/calendar/view/week/TimeAxisComponent.mjs +3 -3
  132. package/src/component/Base.mjs +17 -2
  133. package/src/component/Carousel.mjs +2 -2
  134. package/src/component/Chip.mjs +3 -3
  135. package/src/component/Circle.mjs +2 -2
  136. package/src/component/DateSelector.mjs +8 -8
  137. package/src/component/Helix.mjs +1 -1
  138. package/src/component/Label.mjs +3 -18
  139. package/src/component/Legend.mjs +3 -3
  140. package/src/component/MagicMoveText.mjs +6 -14
  141. package/src/component/Process.mjs +3 -3
  142. package/src/component/Progress.mjs +1 -1
  143. package/src/component/StatusBadge.mjs +2 -2
  144. package/src/component/Timer.mjs +2 -2
  145. package/src/component/Toast.mjs +5 -3
  146. package/src/container/AccordionItem.mjs +2 -2
  147. package/src/container/Base.mjs +1 -1
  148. package/src/core/Base.mjs +77 -14
  149. package/src/core/Util.mjs +14 -2
  150. package/src/date/DayViewComponent.mjs +2 -2
  151. package/src/date/SelectorContainer.mjs +1 -1
  152. package/src/draggable/grid/header/toolbar/SortZone.mjs +21 -21
  153. package/src/draggable/table/header/toolbar/SortZone.mjs +1 -1
  154. package/src/form/field/CheckBox.mjs +4 -4
  155. package/src/form/field/FileUpload.mjs +25 -39
  156. package/src/form/field/Range.mjs +1 -1
  157. package/src/form/field/Text.mjs +3 -3
  158. package/src/form/field/TextArea.mjs +2 -3
  159. package/src/grid/Body.mjs +8 -5
  160. package/src/grid/_export.mjs +1 -1
  161. package/src/list/Color.mjs +2 -2
  162. package/src/main/DeltaUpdates.mjs +157 -98
  163. package/src/main/addon/AmCharts.mjs +61 -84
  164. package/src/main/addon/Base.mjs +161 -42
  165. package/src/main/addon/GoogleMaps.mjs +9 -16
  166. package/src/main/addon/HighlightJS.mjs +2 -13
  167. package/src/main/addon/IntersectionObserver.mjs +21 -21
  168. package/src/main/addon/MonacoEditor.mjs +32 -64
  169. package/src/manager/ClassHierarchy.mjs +114 -0
  170. package/src/menu/List.mjs +1 -1
  171. package/src/plugin/Popover.mjs +2 -2
  172. package/src/sitemap/Component.mjs +1 -1
  173. package/src/table/{View.mjs → Body.mjs} +25 -22
  174. package/src/table/Container.mjs +43 -43
  175. package/src/table/_export.mjs +2 -2
  176. package/src/table/plugin/CellEditing.mjs +19 -19
  177. package/src/tooltip/Base.mjs +1 -6
  178. package/src/tree/Accordion.mjs +3 -3
  179. package/src/vdom/Helper.mjs +19 -22
  180. package/src/worker/App.mjs +1 -2
  181. package/src/worker/Base.mjs +7 -5
  182. package/src/worker/Canvas.mjs +2 -3
  183. package/src/worker/Data.mjs +5 -7
  184. package/src/worker/Task.mjs +2 -3
  185. package/src/worker/VDom.mjs +3 -4
  186. package/src/worker/mixin/RemoteMethodAccess.mjs +5 -2
  187. package/learn/guides/MainThreadAddonExample.md +0 -15
  188. package/learn/guides/MainThreadAddonIntro.md +0 -44
@@ -69,7 +69,7 @@ class CellEditing extends Plugin {
69
69
  me.onSelectionModelChange({value: selectionModel})
70
70
  }
71
71
 
72
- owner.view.keys.add({
72
+ owner.body.keys.add({
73
73
  Enter: 'onTableKeyDown',
74
74
  Space: 'onTableKeyDown',
75
75
  scope: me
@@ -109,9 +109,9 @@ class CellEditing extends Plugin {
109
109
 
110
110
  let me = this,
111
111
  {appName, windowId} = me,
112
- {view} = me.owner,
113
- cellId = view.getCellId(record, dataField),
114
- cellNode = VdomUtil.find(view.vdom, cellId).vdom,
112
+ {body} = me.owner,
113
+ cellId = body.getCellId(record, dataField),
114
+ cellNode = VdomUtil.find(body.vdom, cellId).vdom,
115
115
  column = me.owner.headerToolbar.getColumn(dataField),
116
116
  editor = me.editors[dataField],
117
117
  value = record[dataField],
@@ -133,7 +133,7 @@ class CellEditing extends Plugin {
133
133
  cls : me.editorCls,
134
134
  dataField,
135
135
  hideLabel: true,
136
- parentId : view.id,
136
+ parentId : body.id,
137
137
  record,
138
138
  value,
139
139
  windowId,
@@ -163,9 +163,9 @@ class CellEditing extends Plugin {
163
163
  cellNode.cn = [editor.createVdomReference()];
164
164
  delete cellNode.html;
165
165
 
166
- view.updateDepth = -1;
166
+ body.updateDepth = -1;
167
167
 
168
- await view.promiseUpdate();
168
+ await body.promiseUpdate();
169
169
 
170
170
  await me.timeout(30);
171
171
 
@@ -175,13 +175,13 @@ class CellEditing extends Plugin {
175
175
  /**
176
176
  *
177
177
  * @param {Object} data
178
- * @param {Object} data.data
179
- * @param {String} data.dataField
180
- * @param {Object} data.record
181
- * @param {Neo.table.View} data.view
178
+ * @param {Neo.table.Body} data.body
179
+ * @param {Object} data.data
180
+ * @param {String} data.dataField
181
+ * @param {Object} data.record
182
182
  * @returns {Promise<void>}
183
183
  */
184
- async onCellDoubleClick({data, dataField, record, view}) {
184
+ async onCellDoubleClick({body, data, dataField, record}) {
185
185
  await this.mountEditor(record, dataField)
186
186
  }
187
187
 
@@ -262,12 +262,12 @@ class CellEditing extends Plugin {
262
262
  async onTableKeyDown(data) {
263
263
  let me = this,
264
264
  {target} = data,
265
- {view} = me.owner,
265
+ {body} = me.owner,
266
266
  dataField, record;
267
267
 
268
268
  if (!me.mountedEditor && target.cls?.includes('neo-selected')) {
269
- dataField = view.getCellDataField(target.id);
270
- record = view.getRecord(target.id);
269
+ dataField = body.getCellDataField(target.id);
270
+ record = body.getRecord(target.id);
271
271
 
272
272
  await me.mountEditor(record, dataField)
273
273
  }
@@ -328,13 +328,13 @@ class CellEditing extends Plugin {
328
328
 
329
329
  let me = this,
330
330
  record = me.mountedEditor.record,
331
- {view} = me.owner,
332
- rowIndex = view.store.indexOf(record);
331
+ {body} = me.owner,
332
+ rowIndex = body.store.indexOf(record);
333
333
 
334
334
  me.mountedEditor = null;
335
335
 
336
- view.getVdomRoot().cn[rowIndex] = view.createRow({record, rowIndex});
337
- await view.promiseUpdate()
336
+ body.getVdomRoot().cn[rowIndex] = body.createRow({record, rowIndex});
337
+ await body.promiseUpdate()
338
338
  }
339
339
  }
340
340
 
@@ -76,12 +76,7 @@ class Tooltip extends Container {
76
76
  * True prevents the tooltip from hiding while the mouse cursor is above it
77
77
  * @member {Boolean|null} stayOnHover_=true
78
78
  */
79
- stayOnHover_: true,
80
- /**
81
- * Shortcut to add a label item
82
- * @member {String} text_=null
83
- */
84
- text_: null
79
+ stayOnHover_: true
85
80
  }
86
81
 
87
82
  /**
@@ -277,13 +277,13 @@ class AccordionTree extends TreeList {
277
277
  tag : 'span',
278
278
  cls : [itemCls + '-content-header'],
279
279
  id : id + '__item-content-header',
280
- html: item[me.fields.header]
280
+ text: item[me.fields.header]
281
281
  }, {
282
282
  flag: 'content',
283
283
  tag : 'span',
284
284
  cls : [itemCls + '-content-text'],
285
285
  id : id + '__item-content-text',
286
- html: item[me.fields.text]
286
+ text: item[me.fields.text]
287
287
  }]
288
288
  }],
289
289
  style: {
@@ -428,7 +428,7 @@ class AccordionTree extends TreeList {
428
428
  NeoArray.add(cls, clsItems);
429
429
  itemVdom.cls = cls
430
430
  } else {
431
- itemVdom.html = field.value
431
+ itemVdom.text = field.value
432
432
  }
433
433
  }
434
434
  });
@@ -37,26 +37,6 @@ class Helper extends Base {
37
37
  singleton: true
38
38
  }
39
39
 
40
- /**
41
- * @param {Object} config
42
- */
43
- construct(config) {
44
- super.construct(config);
45
-
46
- let me = this;
47
-
48
- // Ensure Neo.currentWorker is defined before attaching listeners
49
- Promise.resolve().then(async () => {
50
- // Subscribe to global Neo.config changes for dynamic renderer switching.
51
- Neo.currentWorker.on({
52
- neoConfigChange: me.onNeoConfigChange,
53
- scope : me
54
- });
55
-
56
- await me.importUtil()
57
- })
58
- }
59
-
60
40
  /**
61
41
  * @param {Object} config
62
42
  * @param {Object} config.deltas
@@ -520,6 +500,23 @@ class Helper extends Base {
520
500
  }
521
501
  }
522
502
 
503
+ /**
504
+ * @returns {Promise<void>}
505
+ */
506
+ async initAsync() {
507
+ super.initAsync();
508
+
509
+ let me = this;
510
+
511
+ // Subscribe to global Neo.config changes for dynamic renderer switching.
512
+ Neo.currentWorker.on({
513
+ neoConfigChange: me.onNeoConfigChange,
514
+ scope : me
515
+ });
516
+
517
+ await me.importUtil()
518
+ }
519
+
523
520
  /**
524
521
  * @param {Object} config
525
522
  * @param {Object} config.deltas
@@ -632,12 +629,12 @@ class Helper extends Base {
632
629
 
633
630
  /**
634
631
  * Handler for global Neo.config changes.
635
- * If 'useDomApiRenderer' property changes, this method dynamically loads/clears the renderer utilities.
632
+ * If the `Neo.config.useDomApiRenderer` value changes, this method dynamically loads the renderer utilities.
636
633
  * @param {Object} config
637
634
  * @return {Promise<void>}
638
635
  */
639
636
  async onNeoConfigChange(config) {
640
- if(Object.hasOwn(config, 'useDomApiRenderer')) {
637
+ if (Object.hasOwn(config, 'useDomApiRenderer')) {
641
638
  await this.importUtil()
642
639
  }
643
640
  }
@@ -1,8 +1,7 @@
1
1
  import Neo from '../Neo.mjs';
2
2
  import Base from './Base.mjs';
3
- import * as core from '../core/_export.mjs';
4
3
  import Application from '../controller/Application.mjs';
5
- import Instance from '../manager/Instance.mjs';
4
+ import InstanceManager from '../manager/Instance.mjs';
6
5
  import DomEventManager from '../manager/DomEvent.mjs';
7
6
  import HashHistory from '../util/HashHistory.mjs';
8
7
 
@@ -1,10 +1,12 @@
1
- import Base from '../core/Base.mjs';
2
- import Observable from '../core/Observable.mjs';
3
- import Message from './Message.mjs';
4
- import RemoteMethodAccess from './mixin/RemoteMethodAccess.mjs';
1
+ import Base from '../core/Base.mjs';
2
+ import * as core from '../core/_export.mjs';
3
+ import Observable from '../core/Observable.mjs';
4
+ import ClassHierarchyManager from '../manager/ClassHierarchy.mjs';
5
+ import Message from './Message.mjs';
6
+ import RemoteMethodAccess from './mixin/RemoteMethodAccess.mjs';
5
7
 
6
8
  /**
7
- * The abstract base class for the App, Data & VDom worker
9
+ * The abstract base class for e.g. the App, Data & VDom worker
8
10
  * @class Neo.worker.Base
9
11
  * @extends Neo.core.Base
10
12
  * @abstract
@@ -1,6 +1,5 @@
1
- import Neo from '../Neo.mjs';
2
- import Base from './Base.mjs';
3
- import * as core from '../core/_export.mjs';
1
+ import Neo from '../Neo.mjs';
2
+ import Base from './Base.mjs';
4
3
 
5
4
  /**
6
5
  * The Canvas worker is responsible for dynamically manipulating offscreen canvas.
@@ -1,12 +1,10 @@
1
- import Neo from '../Neo.mjs';
2
- import Base from './Base.mjs';
3
- import Compare from '../core/Compare.mjs';
4
- import Fetch from '../Fetch.mjs';
5
- import Util from '../core/Util.mjs';
6
- import Xhr from '../Xhr.mjs';
1
+ import Neo from '../Neo.mjs';
2
+ import Base from './Base.mjs';
3
+ import Fetch from '../Fetch.mjs';
4
+ import Xhr from '../Xhr.mjs';
7
5
 
8
6
  /**
9
- * The Data worker is responsible to handle all of the communication to the backend (e.g. Ajax-calls).
7
+ * The Data worker is responsible to handle all the communication to the backend (e.g. Ajax-calls).
10
8
  * See the tutorials for further infos.
11
9
  * @class Neo.worker.Data
12
10
  * @extends Neo.worker.Base
@@ -1,6 +1,5 @@
1
- import Neo from '../Neo.mjs';
2
- import Base from './Base.mjs';
3
- import * as core from '../core/_export.mjs';
1
+ import Neo from '../Neo.mjs';
2
+ import Base from './Base.mjs';
4
3
 
5
4
  /**
6
5
  * The Task worker can get filled with custom remote methods as needed.
@@ -1,7 +1,6 @@
1
- import Neo from '../Neo.mjs';
2
- import Base from './Base.mjs';
3
- import * as core from '../core/_export.mjs';
4
- import Helper from '../vdom/Helper.mjs';
1
+ import Neo from '../Neo.mjs';
2
+ import Base from './Base.mjs';
3
+ import Helper from '../vdom/Helper.mjs';
5
4
 
6
5
  /**
7
6
  * The Vdom worker converts vdom templates into vnodes, as well as creating delta-updates.
@@ -90,13 +90,16 @@ class RemoteMethodAccess extends Base {
90
90
  throw new Error('Invalid remote method name "' + msg.remoteMethod + '"')
91
91
  }
92
92
 
93
- if (Array.isArray(msg.data)) {
93
+ // Check for interception
94
+ if (!pkg.isReady && pkg.interceptRemotes?.includes(msg.remoteMethod)) {
95
+ out = pkg.onInterceptRemotes(msg);
96
+ } else if (Array.isArray(msg.data)) {
94
97
  out = method.call(pkg, ...msg.data)
95
98
  } else {
96
99
  out = method.call(pkg, msg.data)
97
100
  }
98
101
 
99
- if (out instanceof Promise) {
102
+ if (Neo.isPromise(out)) {
100
103
  out
101
104
  /*
102
105
  * Intended logic:
@@ -1,15 +0,0 @@
1
- Let's go through the steps of creating a main thread addon.
2
-
3
- Let's say we needed to show a code editor. There are a lot of libraries
4
- for this, such as Ace (<a href="https://ace.c9.io/" target="_blank">ace.c9.io</a>).
5
- From a coding perspective, these editors have a simple API: a setter
6
- to specify the string being edited, a getter to read the string, and
7
- a change event fired as the user types.
8
-
9
- Here's what we need to do:
10
- - Define a main thread addon and its API
11
- - Define a component wrapper
12
-
13
- ### Define the Main Thread Addon
14
-
15
- ### Define the component wrapper
@@ -1,44 +0,0 @@
1
- Neo.mjs is multi-threaded. There are worker threads
2
- that handle data access, application logic,
3
- and keeping track of DOM updates. Practically all your
4
- application logic is run in parallel in these threads.
5
- However, anything that needs to actually reference or update
6
- the DOM (`window.document`), or just use the `window` object, must be done in the main
7
- application thread.
8
-
9
- That's the purpose of main thread addons. These are classes whose
10
- methods can be accessed from other web workers, but are
11
- actually executed in the main thread.
12
-
13
- For example, what if you needed to read the browser's
14
- URL? That information is in `window.location`.
15
- But `window` is a main thread variable! To access that
16
- from a web-worker our code has to say "hey main thread,
17
- please return a specified `window` property." Neo.mjs
18
- lets you do that via `Neo.Main.getByPath()`. For
19
- example, the following statement logs the URL query string.
20
-
21
- <pre data-code-readonly>
22
- const search = await Neo.Main.getByPath({path: 'window.location.search'});
23
- console.log(search); // Logs the search string
24
- </pre>
25
-
26
- `Neo.Main` & `Neo.main.DomAccess` provide some basic methods for accessing the
27
- main thread, but in case you want to use a third party library which relies on directly
28
- working with the DOM, you'd use a _main thread addon_.
29
-
30
- Google Maps is a good example of this. In Neo.mjs, most
31
- views are responsible for updating their own vdom, but
32
- the responsibility for rendering maps and markers is handled
33
- by Google Maps itself &mdash; we _ask_ Google Maps to do
34
- certain things via the Google Maps API. Therefore, in Neo.mjs,
35
- Google Maps is implemented as a main thread addon which
36
- loads the libraries and exposes whatever methods we'll need
37
- to run from the other Neo.mjs threads. In addition, in a
38
- Neo.mjs application we want to use Google Maps like any other
39
- component, so Neo.mjs also provides a component wrapper. In
40
- summary:
41
- - The main-thread addon contains the code run in the main thread,
42
- and exposes what methods can be run by other web-workers (remote method access)
43
- - The component wrapper lets you use it like any other component,
44
- internally calling the main thread methods as needed.