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.
- package/ServiceWorker.mjs +2 -2
- package/apps/colors/view/GridContainer.mjs +1 -1
- package/apps/covid/view/AttributionComponent.mjs +1 -1
- package/apps/covid/view/HeaderContainer.mjs +6 -6
- package/apps/covid/view/MainContainerController.mjs +5 -5
- package/apps/covid/view/TableContainerController.mjs +1 -1
- package/apps/covid/view/country/Gallery.mjs +13 -13
- package/apps/covid/view/country/Helix.mjs +13 -13
- package/apps/covid/view/country/HistoricalDataTable.mjs +1 -1
- package/apps/email/view/Viewport.mjs +2 -2
- package/apps/form/view/SideNavList.mjs +1 -1
- package/apps/portal/index.html +1 -1
- package/apps/portal/resources/data/examples_devmode.json +26 -27
- package/apps/portal/resources/data/examples_dist_dev.json +26 -27
- package/apps/portal/resources/data/examples_dist_esm.json +25 -26
- package/apps/portal/resources/data/examples_dist_prod.json +26 -27
- package/apps/portal/view/HeaderToolbar.mjs +3 -3
- package/apps/portal/view/about/Container.mjs +2 -2
- package/apps/portal/view/about/MemberContainer.mjs +3 -3
- package/apps/portal/view/blog/List.mjs +7 -7
- package/apps/portal/view/examples/List.mjs +4 -4
- package/apps/portal/view/home/ContentBox.mjs +2 -2
- package/apps/portal/view/home/FeatureSection.mjs +3 -3
- package/apps/portal/view/home/FooterContainer.mjs +7 -7
- package/apps/portal/view/home/parts/AfterMath.mjs +3 -3
- package/apps/portal/view/home/parts/MainNeo.mjs +3 -3
- package/apps/portal/view/home/parts/References.mjs +6 -6
- package/apps/portal/view/learn/ContentComponent.mjs +102 -111
- package/apps/portal/view/learn/PageSectionsContainer.mjs +1 -1
- package/apps/portal/view/learn/PageSectionsList.mjs +2 -2
- package/apps/portal/view/services/Component.mjs +16 -16
- package/apps/realworld/view/FooterComponent.mjs +1 -1
- package/apps/realworld/view/HeaderComponent.mjs +8 -8
- package/apps/realworld/view/HomeComponent.mjs +6 -6
- package/apps/realworld/view/article/CommentComponent.mjs +4 -4
- package/apps/realworld/view/article/Component.mjs +14 -14
- package/apps/realworld/view/article/CreateCommentComponent.mjs +3 -3
- package/apps/realworld/view/article/CreateComponent.mjs +3 -3
- package/apps/realworld/view/article/PreviewComponent.mjs +1 -1
- package/apps/realworld/view/article/TagListComponent.mjs +2 -2
- package/apps/realworld/view/user/ProfileComponent.mjs +8 -8
- package/apps/realworld/view/user/SettingsComponent.mjs +4 -4
- package/apps/realworld/view/user/SignUpComponent.mjs +4 -4
- package/apps/realworld2/view/FooterComponent.mjs +1 -1
- package/apps/realworld2/view/HomeContainer.mjs +3 -3
- package/apps/realworld2/view/article/DetailsContainer.mjs +1 -1
- package/apps/realworld2/view/article/PreviewComponent.mjs +7 -7
- package/apps/realworld2/view/article/TagListComponent.mjs +2 -2
- package/apps/realworld2/view/user/ProfileContainer.mjs +1 -1
- package/apps/route/view/center/CardAdministration.mjs +2 -2
- package/apps/route/view/center/CardAdministrationDenied.mjs +1 -1
- package/apps/route/view/center/CardContact.mjs +2 -2
- package/apps/route/view/center/CardHome.mjs +1 -1
- package/apps/route/view/center/CardSection1.mjs +1 -1
- package/apps/route/view/center/CardSection2.mjs +1 -1
- package/apps/sharedcovid/view/AttributionComponent.mjs +1 -1
- package/apps/sharedcovid/view/HeaderContainer.mjs +6 -6
- package/apps/sharedcovid/view/MainContainerController.mjs +5 -5
- package/apps/sharedcovid/view/TableContainerController.mjs +1 -1
- package/apps/sharedcovid/view/country/Gallery.mjs +13 -13
- package/apps/sharedcovid/view/country/Helix.mjs +13 -13
- package/apps/sharedcovid/view/country/HistoricalDataTable.mjs +1 -1
- package/apps/shareddialog/childapps/shareddialog2/view/MainContainer.mjs +1 -1
- package/apps/shareddialog/view/MainContainer.mjs +1 -1
- package/buildScripts/createApp.mjs +2 -2
- package/examples/table/cellEditing/MainContainer.mjs +1 -1
- package/examples/table/container/MainContainer.mjs +3 -3
- package/examples/table/nestedRecordFields/Viewport.mjs +6 -6
- package/examples/tableFiltering/MainContainer.mjs +1 -1
- package/examples/tablePerformance/MainContainer.mjs +1 -1
- package/examples/tablePerformance/MainContainer2.mjs +1 -1
- package/examples/tablePerformance/MainContainer3.mjs +2 -2
- package/examples/tableStore/MainContainer.mjs +2 -2
- package/learn/Glossary.md +261 -0
- package/learn/UsingTheseTopics.md +2 -2
- package/learn/benefits/ConfigSystem.md +538 -28
- package/learn/benefits/Effort.md +47 -2
- package/learn/benefits/Features.md +50 -32
- package/learn/benefits/FormsEngine.md +68 -38
- package/learn/benefits/MultiWindow.md +33 -7
- package/learn/benefits/OffTheMainThread.md +2 -2
- package/learn/benefits/Quick.md +45 -12
- package/learn/benefits/RPCLayer.md +75 -0
- package/learn/benefits/Speed.md +16 -11
- package/learn/gettingstarted/ComponentModels.md +4 -4
- package/learn/gettingstarted/Config.md +6 -6
- package/learn/gettingstarted/DescribingTheUI.md +4 -4
- package/learn/gettingstarted/Events.md +6 -6
- package/learn/gettingstarted/Extending.md +4 -4
- package/learn/gettingstarted/References.md +6 -6
- package/learn/gettingstarted/Workspaces.md +6 -6
- package/learn/guides/ApplicationBootstrap.md +26 -26
- package/learn/guides/ComponentsAndContainers.md +12 -12
- package/learn/guides/ConfigSystemDeepDive.md +280 -0
- package/learn/guides/CustomComponents.md +2 -2
- package/learn/guides/DeclarativeComponentTreesVsImperativeVdom.md +17 -17
- package/learn/guides/InstanceLifecycle.md +295 -1
- package/learn/guides/MainThreadAddons.md +475 -0
- package/learn/guides/PortalApp.md +2 -2
- package/learn/guides/StateProviders.md +12 -12
- package/learn/guides/WorkingWithVDom.md +14 -14
- package/learn/guides/events/CustomEvents.md +16 -16
- package/learn/guides/events/DomEvents.md +12 -12
- package/learn/javascript/ClassFeatures.md +3 -2
- package/learn/javascript/Classes.md +8 -8
- package/learn/javascript/NewNode.md +4 -4
- package/learn/javascript/Overrides.md +8 -8
- package/learn/javascript/Super.md +10 -8
- package/learn/tree.json +52 -51
- package/learn/tutorials/Earthquakes.md +54 -57
- package/learn/tutorials/TodoList.md +4 -4
- package/package.json +2 -2
- package/resources/scss/src/apps/portal/learn/ContentComponent.scss +12 -0
- package/resources/scss/src/table/{View.scss → Body.scss} +1 -1
- package/resources/scss/src/table/plugin/CellEditing.scss +1 -1
- package/resources/scss/theme-dark/table/{View.scss → Body.scss} +1 -1
- package/resources/scss/theme-light/table/{View.scss → Body.scss} +1 -1
- package/resources/scss/theme-neo-light/Global.scss +1 -2
- package/resources/scss/theme-neo-light/table/{View.scss → Body.scss} +1 -1
- package/src/DefaultConfig.mjs +2 -2
- package/src/Main.mjs +8 -7
- package/src/Neo.mjs +16 -2
- package/src/button/Base.mjs +2 -2
- package/src/calendar/view/SettingsContainer.mjs +2 -2
- package/src/calendar/view/YearComponent.mjs +9 -9
- package/src/calendar/view/calendars/ColorsList.mjs +1 -1
- package/src/calendar/view/calendars/List.mjs +1 -1
- package/src/calendar/view/month/Component.mjs +15 -15
- package/src/calendar/view/week/Component.mjs +12 -12
- package/src/calendar/view/week/EventDragZone.mjs +4 -4
- package/src/calendar/view/week/TimeAxisComponent.mjs +3 -3
- package/src/component/Base.mjs +17 -2
- package/src/component/Carousel.mjs +2 -2
- package/src/component/Chip.mjs +3 -3
- package/src/component/Circle.mjs +2 -2
- package/src/component/DateSelector.mjs +8 -8
- package/src/component/Helix.mjs +1 -1
- package/src/component/Label.mjs +3 -18
- package/src/component/Legend.mjs +3 -3
- package/src/component/MagicMoveText.mjs +6 -14
- package/src/component/Process.mjs +3 -3
- package/src/component/Progress.mjs +1 -1
- package/src/component/StatusBadge.mjs +2 -2
- package/src/component/Timer.mjs +2 -2
- package/src/component/Toast.mjs +5 -3
- package/src/container/AccordionItem.mjs +2 -2
- package/src/container/Base.mjs +1 -1
- package/src/core/Base.mjs +77 -14
- package/src/core/Util.mjs +14 -2
- package/src/date/DayViewComponent.mjs +2 -2
- package/src/date/SelectorContainer.mjs +1 -1
- package/src/draggable/grid/header/toolbar/SortZone.mjs +21 -21
- package/src/draggable/table/header/toolbar/SortZone.mjs +1 -1
- package/src/form/field/CheckBox.mjs +4 -4
- package/src/form/field/FileUpload.mjs +25 -39
- package/src/form/field/Range.mjs +1 -1
- package/src/form/field/Text.mjs +3 -3
- package/src/form/field/TextArea.mjs +2 -3
- package/src/grid/Body.mjs +8 -5
- package/src/grid/_export.mjs +1 -1
- package/src/list/Color.mjs +2 -2
- package/src/main/DeltaUpdates.mjs +157 -98
- package/src/main/addon/AmCharts.mjs +61 -84
- package/src/main/addon/Base.mjs +161 -42
- package/src/main/addon/GoogleMaps.mjs +9 -16
- package/src/main/addon/HighlightJS.mjs +2 -13
- package/src/main/addon/IntersectionObserver.mjs +21 -21
- package/src/main/addon/MonacoEditor.mjs +32 -64
- package/src/manager/ClassHierarchy.mjs +114 -0
- package/src/menu/List.mjs +1 -1
- package/src/plugin/Popover.mjs +2 -2
- package/src/sitemap/Component.mjs +1 -1
- package/src/table/{View.mjs → Body.mjs} +25 -22
- package/src/table/Container.mjs +43 -43
- package/src/table/_export.mjs +2 -2
- package/src/table/plugin/CellEditing.mjs +19 -19
- package/src/tooltip/Base.mjs +1 -6
- package/src/tree/Accordion.mjs +3 -3
- package/src/vdom/Helper.mjs +19 -22
- package/src/worker/App.mjs +1 -2
- package/src/worker/Base.mjs +7 -5
- package/src/worker/Canvas.mjs +2 -3
- package/src/worker/Data.mjs +5 -7
- package/src/worker/Task.mjs +2 -3
- package/src/worker/VDom.mjs +3 -4
- package/src/worker/mixin/RemoteMethodAccess.mjs +5 -2
- package/learn/guides/MainThreadAddonExample.md +0 -15
- 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.
|
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
|
-
{
|
113
|
-
cellId =
|
114
|
-
cellNode = VdomUtil.find(
|
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 :
|
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
|
-
|
166
|
+
body.updateDepth = -1;
|
167
167
|
|
168
|
-
await
|
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 {
|
179
|
-
* @param {
|
180
|
-
* @param {
|
181
|
-
* @param {
|
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
|
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
|
-
{
|
265
|
+
{body} = me.owner,
|
266
266
|
dataField, record;
|
267
267
|
|
268
268
|
if (!me.mountedEditor && target.cls?.includes('neo-selected')) {
|
269
|
-
dataField =
|
270
|
-
record =
|
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
|
-
{
|
332
|
-
rowIndex =
|
331
|
+
{body} = me.owner,
|
332
|
+
rowIndex = body.store.indexOf(record);
|
333
333
|
|
334
334
|
me.mountedEditor = null;
|
335
335
|
|
336
|
-
|
337
|
-
await
|
336
|
+
body.getVdomRoot().cn[rowIndex] = body.createRow({record, rowIndex});
|
337
|
+
await body.promiseUpdate()
|
338
338
|
}
|
339
339
|
}
|
340
340
|
|
package/src/tooltip/Base.mjs
CHANGED
@@ -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
|
/**
|
package/src/tree/Accordion.mjs
CHANGED
@@ -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
|
-
|
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
|
-
|
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.
|
431
|
+
itemVdom.text = field.value
|
432
432
|
}
|
433
433
|
}
|
434
434
|
});
|
package/src/vdom/Helper.mjs
CHANGED
@@ -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
|
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
|
}
|
package/src/worker/App.mjs
CHANGED
@@ -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
|
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
|
|
package/src/worker/Base.mjs
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
import Base
|
2
|
-
import
|
3
|
-
import
|
4
|
-
import
|
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
|
package/src/worker/Canvas.mjs
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
import Neo
|
2
|
-
import Base
|
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.
|
package/src/worker/Data.mjs
CHANGED
@@ -1,12 +1,10 @@
|
|
1
|
-
import Neo
|
2
|
-
import Base
|
3
|
-
import
|
4
|
-
import
|
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
|
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
|
package/src/worker/Task.mjs
CHANGED
package/src/worker/VDom.mjs
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
import Neo
|
2
|
-
import Base
|
3
|
-
import
|
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
|
-
|
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
|
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 — 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.
|