neo.mjs 6.17.1 → 6.18.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/apps/ServiceWorker.mjs +3 -5
- package/apps/colors/README.md +8 -0
- package/apps/colors/app.mjs +6 -0
- package/apps/colors/childapps/widget/app.mjs +7 -0
- package/apps/colors/childapps/widget/index.html +11 -0
- package/apps/colors/childapps/widget/neo-config.json +10 -0
- package/apps/colors/childapps/widget/view/Viewport.mjs +19 -0
- package/apps/colors/index.html +11 -0
- package/apps/colors/model/Color.mjs +43 -0
- package/apps/colors/neo-config.json +10 -0
- package/apps/colors/remotes-api.json +13 -0
- package/apps/colors/store/Colors.mjs +24 -0
- package/apps/colors/view/BarChartComponent.mjs +64 -0
- package/apps/colors/view/HeaderToolbar.mjs +95 -0
- package/apps/colors/view/PieChartComponent.mjs +58 -0
- package/apps/colors/view/TableContainer.mjs +91 -0
- package/apps/colors/view/Viewport.mjs +57 -0
- package/apps/colors/view/ViewportController.mjs +277 -0
- package/apps/colors/view/ViewportModel.mjs +53 -0
- package/apps/portal/Util.mjs +11 -0
- package/apps/portal/childapps/preview/neo-config.json +2 -2
- package/apps/portal/neo-config.json +2 -1
- package/apps/portal/remotes-api.json +13 -0
- package/apps/portal/view/HeaderToolbar.mjs +44 -27
- package/apps/portal/view/Viewport.mjs +12 -1
- package/apps/portal/view/ViewportController.mjs +89 -1
- package/apps/portal/view/home/MainContainer.mjs +27 -60
- package/apps/portal/view/home/parts/AfterMath.mjs +58 -0
- package/apps/portal/view/home/parts/Colors.mjs +74 -0
- package/apps/portal/view/home/parts/Features.mjs +52 -0
- package/apps/portal/view/home/parts/Helix.mjs +75 -0
- package/apps/portal/view/home/parts/HelloWorld.mjs +82 -0
- package/apps/portal/view/home/parts/MainNeo.mjs +55 -0
- package/apps/portal/view/home/preview/PageCodeContainer.mjs +55 -0
- package/apps/portal/view/learn/LivePreview.mjs +72 -29
- package/apps/portal/view/learn/MainContainerController.mjs +10 -90
- package/apps/realworld/api/Article.mjs +1 -3
- package/apps/realworld/api/Favorite.mjs +1 -3
- package/apps/realworld/api/Profile.mjs +1 -3
- package/apps/realworld/api/Tag.mjs +1 -3
- package/apps/realworld/api/User.mjs +1 -3
- package/apps/realworld2/api/Article.mjs +1 -3
- package/apps/realworld2/api/Favorite.mjs +1 -3
- package/apps/realworld2/api/Profile.mjs +1 -3
- package/apps/realworld2/api/Tag.mjs +1 -3
- package/apps/realworld2/api/User.mjs +1 -3
- package/apps/realworld2/view/article/HelixContainer.mjs +5 -5
- package/buildScripts/webpack/json/myApps.template.json +1 -0
- package/buildScripts/webpack/webpack.server.config.mjs +4 -1
- package/docs/app/view/MainContainer.mjs +5 -0
- package/docs/app/view/classdetails/MembersList.mjs +1 -1
- package/examples/ServiceWorker.mjs +3 -5
- package/examples/component/helix/Viewport.mjs +309 -0
- package/examples/component/helix/ViewportController.mjs +122 -0
- package/examples/component/helix/app.mjs +2 -2
- package/examples/component/helix/neo-config.json +0 -1
- package/examples/component/multiWindowHelix/Viewport.mjs +11 -3
- package/examples/component/multiWindowHelix/ViewportController.mjs +21 -9
- package/examples/component/multiWindowHelix/neo-config.json +0 -1
- package/examples/fieldWithPrefix/MainContainer.mjs +1 -6
- package/examples/list/animate/MainContainerController.mjs +1 -1
- package/examples/worker/task/MyTasks.mjs +1 -3
- package/package.json +5 -5
- package/resources/data/deck/learnneo/pages/GuideEvents.md +131 -0
- package/resources/data/deck/learnneo/pages/WhyNeo-Speed.md +1 -1
- package/resources/images/logo/neo_logo_primary.svg +6 -0
- package/resources/images/logo/neo_logo_secondary.svg +6 -0
- package/resources/images/logo/neo_logo_text_primary.svg +5 -0
- package/resources/images/logo/neo_logo_text_secondary.svg +5 -0
- package/resources/images/logo/neo_logo_white.svg +6 -0
- package/resources/scss/src/apps/colors/BarChartComponent.scss +3 -0
- package/resources/scss/src/apps/colors/HeaderToolbar.scss +11 -0
- package/resources/scss/src/apps/colors/PieChartComponent.scss +3 -0
- package/resources/scss/src/apps/colors/TableContainer.scss +64 -0
- package/resources/scss/src/apps/colors/Viewport.scss +9 -0
- package/resources/scss/src/apps/portal/HeaderToolbar.scss +189 -17
- package/resources/scss/src/apps/portal/home/MainContainer.scss +46 -20
- package/resources/scss/src/apps/portal/home/parts/Features.scss +3 -0
- package/resources/scss/src/apps/portal/home/preview/PageCodeContainer.scss +115 -0
- package/resources/scss/src/component/Base.scss +2 -0
- package/resources/scss/src/examples/component/multiWindowHelix/Viewport.scss +3 -0
- package/resources/scss/src/form/field/CheckBox.scss +1 -0
- package/resources/scss/src/tab/header/Button.scss +2 -1
- package/resources/scss/theme-dark/Global.scss +8 -0
- package/resources/scss/theme-dark/button/Base.scss +1 -1
- package/resources/scss/theme-dark/tab/header/Button.scss +1 -0
- package/resources/scss/theme-light/Global.scss +8 -0
- package/resources/scss/theme-light/button/Base.scss +1 -1
- package/resources/scss/theme-light/tab/header/Button.scss +1 -0
- package/resources/scss/theme-neo-light/Global.scss +53 -53
- package/resources/scss/theme-neo-light/button/Base.scss +3 -4
- package/resources/scss/theme-neo-light/tab/header/Button.scss +6 -8
- package/src/DefaultConfig.mjs +2 -2
- package/src/Fetch.mjs +1 -3
- package/src/Main.mjs +13 -11
- package/src/MicroLoader.mjs +2 -2
- package/src/Neo.mjs +27 -26
- package/src/Xhr.mjs +1 -3
- package/src/button/Base.mjs +6 -4
- package/src/button/Split.mjs +10 -9
- package/src/calendar/view/EditEventContainer.mjs +13 -12
- package/src/calendar/view/MainContainer.mjs +40 -40
- package/src/calendar/view/MainContainerModel.mjs +5 -5
- package/src/calendar/view/SettingsContainer.mjs +11 -11
- package/src/calendar/view/YearComponent.mjs +73 -75
- package/src/calendar/view/calendars/ColorsList.mjs +2 -2
- package/src/calendar/view/calendars/EditContainer.mjs +2 -2
- package/src/calendar/view/calendars/List.mjs +12 -13
- package/src/calendar/view/month/Component.mjs +72 -73
- package/src/calendar/view/settings/GeneralContainer.mjs +5 -5
- package/src/calendar/view/settings/MonthContainer.mjs +5 -5
- package/src/calendar/view/settings/WeekContainer.mjs +6 -6
- package/src/calendar/view/settings/YearContainer.mjs +4 -4
- package/src/calendar/view/week/Component.mjs +47 -57
- package/src/calendar/view/week/EventDragZone.mjs +43 -50
- package/src/calendar/view/week/TimeAxisComponent.mjs +21 -21
- package/src/calendar/view/week/plugin/DragDrop.mjs +53 -45
- package/src/calendar/view/week/plugin/EventResizable.mjs +8 -3
- package/src/collection/Base.mjs +15 -22
- package/src/collection/Filter.mjs +4 -9
- package/src/collection/Sorter.mjs +6 -7
- package/src/component/Base.mjs +149 -87
- package/src/component/Canvas.mjs +9 -9
- package/src/component/Carousel.mjs +31 -33
- package/src/component/Chip.mjs +9 -9
- package/src/component/Circle.mjs +84 -91
- package/src/component/Clock.mjs +8 -8
- package/src/component/DateSelector.mjs +14 -15
- package/src/component/Gallery.mjs +82 -80
- package/src/component/Helix.mjs +131 -126
- package/src/component/Iframe.mjs +1 -1
- package/src/component/Label.mjs +1 -1
- package/src/component/Legend.mjs +3 -3
- package/src/component/Process.mjs +39 -37
- package/src/component/Splitter.mjs +9 -11
- package/src/component/StatusBadge.mjs +2 -3
- package/src/component/Timer.mjs +62 -68
- package/src/component/Toast.mjs +11 -11
- package/src/component/Video.mjs +7 -8
- package/src/component/mwc/Button.mjs +10 -10
- package/src/component/mwc/TextField.mjs +17 -17
- package/src/component/wrapper/AmChart.mjs +5 -5
- package/src/component/wrapper/CesiumJS.mjs +11 -17
- package/src/component/wrapper/GoogleMaps.mjs +58 -35
- package/src/component/wrapper/MapboxGL.mjs +112 -79
- package/src/component/wrapper/MonacoEditor.mjs +1 -6
- package/src/container/Accordion.mjs +18 -20
- package/src/container/AccordionItem.mjs +12 -11
- package/src/container/Base.mjs +29 -28
- package/src/container/Panel.mjs +9 -9
- package/src/container/Viewport.mjs +30 -1
- package/src/controller/Base.mjs +12 -14
- package/src/controller/Component.mjs +60 -66
- package/src/core/Base.mjs +5 -8
- package/src/core/IdGenerator.mjs +1 -3
- package/src/core/Observable.mjs +17 -17
- package/src/core/Util.mjs +5 -5
- package/src/data/Model.mjs +3 -3
- package/src/data/RecordFactory.mjs +3 -6
- package/src/data/Store.mjs +34 -34
- package/src/data/connection/Fetch.mjs +3 -3
- package/src/data/connection/WebSocket.mjs +21 -25
- package/src/data/connection/Xhr.mjs +31 -28
- package/src/date/DayViewComponent.mjs +1 -1
- package/src/date/SelectorContainer.mjs +2 -2
- package/src/dialog/Base.mjs +27 -25
- package/src/dialog/header/Toolbar.mjs +5 -4
- package/src/draggable/DragProxyComponent.mjs +7 -4
- package/src/draggable/DragZone.mjs +30 -30
- package/src/draggable/DropZone.mjs +7 -7
- package/src/draggable/list/DragZone.mjs +18 -18
- package/src/draggable/tab/header/toolbar/SortZone.mjs +7 -7
- package/src/draggable/toolbar/DragZone.mjs +15 -15
- package/src/draggable/toolbar/SortZone.mjs +30 -31
- package/src/draggable/tree/DragZone.mjs +9 -9
- package/src/filter/BooleanContainer.mjs +3 -3
- package/src/filter/NumberContainer.mjs +5 -5
- package/src/filter/ToggleOperatorsButton.mjs +5 -5
- package/src/form/Fieldset.mjs +26 -26
- package/src/form/field/Base.mjs +1 -1
- package/src/form/field/CheckBox.mjs +15 -16
- package/src/form/field/Color.mjs +13 -15
- package/src/form/field/ComboBox.mjs +16 -24
- package/src/form/field/Country.mjs +1 -1
- package/src/form/field/Date.mjs +3 -4
- package/src/form/field/Display.mjs +1 -1
- package/src/form/field/Email.mjs +2 -2
- package/src/form/field/Number.mjs +51 -56
- package/src/form/field/Picker.mjs +2 -2
- package/src/form/field/Radio.mjs +1 -1
- package/src/form/field/Range.mjs +7 -6
- package/src/form/field/Text.mjs +29 -36
- package/src/form/field/TextArea.mjs +9 -9
- package/src/form/field/Time.mjs +30 -30
- package/src/form/field/trigger/Base.mjs +19 -13
- package/src/form/field/trigger/Clear.mjs +13 -13
- package/src/form/field/trigger/CopyToClipboard.mjs +7 -7
- package/src/form/field/trigger/Picker.mjs +2 -2
- package/src/form/field/trigger/SpinDown.mjs +1 -1
- package/src/form/field/trigger/SpinUp.mjs +1 -1
- package/src/form/field/trigger/SpinUpDown.mjs +3 -3
- package/src/form/field/trigger/Time.mjs +3 -3
- package/src/grid/Container.mjs +33 -33
- package/src/grid/View.mjs +20 -22
- package/src/grid/header/Button.mjs +12 -12
- package/src/grid/header/Toolbar.mjs +4 -4
- package/src/layout/Base.mjs +5 -4
- package/src/layout/Card.mjs +15 -16
- package/src/layout/Fit.mjs +22 -8
- package/src/layout/Flexbox.mjs +30 -29
- package/src/layout/Form.mjs +15 -15
- package/src/layout/Grid.mjs +2 -2
- package/src/layout/HBox.mjs +3 -2
- package/src/layout/VBox.mjs +3 -2
- package/src/list/Base.mjs +45 -47
- package/src/list/Chip.mjs +4 -4
- package/src/list/Circle.mjs +3 -3
- package/src/list/Color.mjs +4 -4
- package/src/list/Component.mjs +10 -10
- package/src/list/plugin/Animate.mjs +18 -13
- package/src/main/DomAccess.mjs +92 -56
- package/src/main/DomEvents.mjs +38 -39
- package/src/main/addon/AmCharts.mjs +37 -37
- package/src/main/addon/AnalyticsByGoogle.mjs +4 -4
- package/src/main/addon/CesiumJS.mjs +8 -8
- package/src/main/addon/CloneNode.mjs +5 -5
- package/src/main/addon/Cookie.mjs +4 -4
- package/src/main/addon/DragDrop.mjs +35 -34
- package/src/main/addon/GoogleMaps.mjs +19 -19
- package/src/main/addon/LocalStorage.mjs +3 -3
- package/src/main/addon/MapboxGL.mjs +40 -41
- package/src/main/addon/MonacoEditor.mjs +5 -5
- package/src/main/addon/Mwc.mjs +6 -6
- package/src/main/addon/Navigator.mjs +35 -39
- package/src/main/addon/Popover.mjs +5 -6
- package/src/main/addon/PrefixField.mjs +1 -2
- package/src/main/addon/ServiceWorker.mjs +9 -9
- package/src/main/addon/Siesta.mjs +3 -2
- package/src/main/addon/Stylesheet.mjs +37 -37
- package/src/main/addon/WebComponent.mjs +2 -3
- package/src/main/addon/WindowPosition.mjs +18 -18
- package/src/main/draggable/sensor/Base.mjs +2 -2
- package/src/main/draggable/sensor/Mouse.mjs +15 -15
- package/src/main/draggable/sensor/Touch.mjs +24 -23
- package/src/main/mixin/DeltaUpdates.mjs +10 -12
- package/src/main/mixin/TouchDomEvents.mjs +6 -6
- package/src/manager/Base.mjs +4 -4
- package/src/manager/Component.mjs +41 -41
- package/src/manager/DomEvent.mjs +52 -50
- package/src/manager/Focus.mjs +14 -16
- package/src/manager/Instance.mjs +2 -4
- package/src/manager/Store.mjs +4 -8
- package/src/manager/Task.mjs +20 -22
- package/src/manager/Toast.mjs +14 -16
- package/src/manager/rpc/Api.mjs +1 -3
- package/src/manager/rpc/Message.mjs +16 -18
- package/src/menu/List.mjs +16 -16
- package/src/menu/Panel.mjs +4 -4
- package/src/model/Component.mjs +5 -5
- package/src/plugin/Base.mjs +2 -0
- package/src/plugin/Popover.mjs +1 -1
- package/src/plugin/PrefixField.mjs +35 -45
- package/src/plugin/Resizable.mjs +86 -101
- package/src/plugin/Responsive.mjs +175 -0
- package/src/remotes/Api.mjs +4 -6
- package/src/selection/CircleModel.mjs +12 -16
- package/src/selection/DateSelectorModel.mjs +21 -23
- package/src/selection/GalleryModel.mjs +49 -63
- package/src/selection/HelixModel.mjs +35 -41
- package/src/selection/ListModel.mjs +9 -14
- package/src/selection/Model.mjs +31 -31
- package/src/selection/TreeAccordionModel.mjs +74 -80
- package/src/selection/grid/CellColumnModel.mjs +10 -10
- package/src/selection/grid/CellColumnRowModel.mjs +10 -10
- package/src/selection/grid/CellModel.mjs +26 -28
- package/src/selection/grid/CellRowModel.mjs +24 -24
- package/src/selection/grid/ColumnModel.mjs +16 -20
- package/src/selection/grid/RowModel.mjs +27 -29
- package/src/selection/menu/ListModel.mjs +2 -2
- package/src/selection/table/CellColumnModel.mjs +12 -12
- package/src/selection/table/CellColumnRowModel.mjs +12 -12
- package/src/selection/table/CellModel.mjs +26 -29
- package/src/selection/table/CellRowModel.mjs +19 -19
- package/src/selection/table/ColumnModel.mjs +18 -22
- package/src/selection/table/RowModel.mjs +27 -29
- package/src/sitemap/Component.mjs +20 -20
- package/src/sitemap/Store.mjs +1 -1
- package/src/tab/Container.mjs +15 -15
- package/src/tab/Strip.mjs +1 -1
- package/src/tab/header/Toolbar.mjs +4 -4
- package/src/table/Container.mjs +8 -10
- package/src/table/View.mjs +29 -34
- package/src/table/header/Button.mjs +18 -18
- package/src/table/header/Toolbar.mjs +2 -2
- package/src/toolbar/Base.mjs +14 -14
- package/src/toolbar/Breadcrumb.mjs +11 -11
- package/src/toolbar/Paging.mjs +18 -18
- package/src/tooltip/Base.mjs +20 -22
- package/src/tree/Accordion.mjs +69 -75
- package/src/tree/List.mjs +22 -25
- package/src/util/Array.mjs +19 -18
- package/src/util/ClassSystem.mjs +9 -9
- package/src/util/Css.mjs +2 -2
- package/src/util/Date.mjs +9 -9
- package/src/util/Function.mjs +2 -2
- package/src/util/HashHistory.mjs +3 -5
- package/src/util/KeyNavigation.mjs +17 -17
- package/src/util/Logger.mjs +9 -9
- package/src/util/Matrix.mjs +19 -19
- package/src/util/String.mjs +9 -9
- package/src/util/Style.mjs +11 -11
- package/src/util/VDom.mjs +12 -14
- package/src/util/VNode.mjs +29 -29
- package/src/vdom/Helper.mjs +84 -93
- package/src/vdom/VNode.mjs +1 -1
- package/src/worker/App.mjs +19 -16
- package/src/worker/Base.mjs +14 -15
- package/src/worker/Canvas.mjs +1 -3
- package/src/worker/Data.mjs +4 -8
- package/src/worker/Manager.mjs +27 -32
- package/src/worker/Message.mjs +1 -1
- package/src/worker/ServiceBase.mjs +38 -42
- package/src/worker/Task.mjs +1 -3
- package/src/worker/VDom.mjs +2 -4
- package/src/worker/mixin/RemoteMethodAccess.mjs +5 -6
- package/examples/component/helix/MainContainer.mjs +0 -340
- package/resources/images/Neo_Vector.svg +0 -3
- package/resources/images/logos/Github-logo-black.svg +0 -1
- package/resources/images/logos/Slack-logo-black.svg +0 -17
package/src/worker/Base.mjs
CHANGED
@@ -66,13 +66,13 @@ class Base extends CoreBase {
|
|
66
66
|
});
|
67
67
|
|
68
68
|
if (me.isSharedWorker) {
|
69
|
-
gt.onconnect = me.onConnected.bind(me)
|
69
|
+
gt.onconnect = me.onConnected.bind(me)
|
70
70
|
} else {
|
71
|
-
gt.onmessage = me.onMessage.bind(me)
|
71
|
+
gt.onmessage = me.onMessage.bind(me)
|
72
72
|
}
|
73
73
|
|
74
74
|
Neo.currentWorker = me;
|
75
|
-
Neo.workerId = me.workerId
|
75
|
+
Neo.workerId = me.workerId
|
76
76
|
}
|
77
77
|
|
78
78
|
/**
|
@@ -93,16 +93,16 @@ class Base extends CoreBase {
|
|
93
93
|
|
94
94
|
Object.entries(opts).forEach(([key, value]) => {
|
95
95
|
if (value !== port[key]) {
|
96
|
-
hasMatch = false
|
96
|
+
hasMatch = false
|
97
97
|
}
|
98
98
|
});
|
99
99
|
|
100
100
|
if (hasMatch) {
|
101
|
-
returnPort = port
|
101
|
+
returnPort = port
|
102
102
|
}
|
103
103
|
});
|
104
104
|
|
105
|
-
return returnPort
|
105
|
+
return returnPort
|
106
106
|
}
|
107
107
|
|
108
108
|
/**
|
@@ -171,14 +171,13 @@ class Base extends CoreBase {
|
|
171
171
|
* @param {Object} e
|
172
172
|
*/
|
173
173
|
onMessage(e) {
|
174
|
-
let me
|
175
|
-
data
|
176
|
-
action
|
177
|
-
replyId = data.replyId,
|
174
|
+
let me = this,
|
175
|
+
{data} = e,
|
176
|
+
{action, replyId} = data,
|
178
177
|
promise;
|
179
178
|
|
180
179
|
if (!action) {
|
181
|
-
throw new Error('Message action is missing: ' + data.id)
|
180
|
+
throw new Error('Message action is missing: ' + data.id)
|
182
181
|
}
|
183
182
|
|
184
183
|
if (action !== 'reply') {
|
@@ -207,8 +206,8 @@ class Base extends CoreBase {
|
|
207
206
|
* @param {String} msg.appName
|
208
207
|
*/
|
209
208
|
onRegisterApp(msg) {
|
210
|
-
let me
|
211
|
-
appName = msg
|
209
|
+
let me = this,
|
210
|
+
{appName} = msg,
|
212
211
|
port;
|
213
212
|
|
214
213
|
for (port of me.ports) {
|
@@ -255,7 +254,7 @@ class Base extends CoreBase {
|
|
255
254
|
let message = me.sendMessage(dest, opts, transfer),
|
256
255
|
msgId = message.id;
|
257
256
|
|
258
|
-
me.promises[msgId] = {
|
257
|
+
me.promises[msgId] = {reject, resolve}
|
259
258
|
})
|
260
259
|
}
|
261
260
|
|
@@ -275,7 +274,7 @@ class Base extends CoreBase {
|
|
275
274
|
message, port, portObject;
|
276
275
|
|
277
276
|
if (me.channelPorts[dest]) {
|
278
|
-
port = me.channelPorts[dest]
|
277
|
+
port = me.channelPorts[dest]
|
279
278
|
} else if (!me.isSharedWorker) {
|
280
279
|
port = globalThis
|
281
280
|
} else {
|
package/src/worker/Canvas.mjs
CHANGED
package/src/worker/Data.mjs
CHANGED
@@ -55,7 +55,7 @@ class Data extends Base {
|
|
55
55
|
|
56
56
|
me.sendMessage('app', {action: 'registerPort', transfer: port2}, [port2]);
|
57
57
|
|
58
|
-
me.channelPorts.app = port1
|
58
|
+
me.channelPorts.app = port1
|
59
59
|
}
|
60
60
|
|
61
61
|
/**
|
@@ -91,8 +91,6 @@ class Data extends Base {
|
|
91
91
|
* @param {Object} msg
|
92
92
|
*/
|
93
93
|
async onRpc(msg) {
|
94
|
-
console.log('onRpc', msg);
|
95
|
-
|
96
94
|
let me = this,
|
97
95
|
response;
|
98
96
|
|
@@ -100,15 +98,13 @@ class Data extends Base {
|
|
100
98
|
// todo: we could store calls which arrive too early and pass them to the manager once it is ready
|
101
99
|
console.warn('manager.RemotesApi not loaded yet', msg);
|
102
100
|
|
103
|
-
me.reject(msg)
|
101
|
+
me.reject(msg)
|
104
102
|
} else {
|
105
103
|
response = await Neo.manager.rpc.Message.onMessage(msg);
|
106
104
|
|
107
|
-
me.resolve(msg, response)
|
105
|
+
me.resolve(msg, response)
|
108
106
|
}
|
109
107
|
}
|
110
108
|
}
|
111
109
|
|
112
|
-
|
113
|
-
|
114
|
-
export default instance;
|
110
|
+
export default Neo.setupClass(Data);
|
package/src/worker/Manager.mjs
CHANGED
@@ -157,13 +157,13 @@ class Manager extends Base {
|
|
157
157
|
* @returns {SharedWorker|Worker}
|
158
158
|
*/
|
159
159
|
createWorker(opts) {
|
160
|
-
let me
|
161
|
-
fileName = opts
|
162
|
-
filePath
|
163
|
-
name
|
164
|
-
isShared
|
165
|
-
cls
|
166
|
-
worker
|
160
|
+
let me = this,
|
161
|
+
{fileName} = opts,
|
162
|
+
filePath = (opts.basePath || me.basePath) + fileName,
|
163
|
+
name = `neomjs-${fileName.substring(0, fileName.indexOf('.')).toLowerCase()}-worker`,
|
164
|
+
isShared = me.sharedWorkersEnabled && NeoConfig.useSharedWorkers,
|
165
|
+
cls = isShared ? SharedWorker : Worker,
|
166
|
+
worker = devMode // todo: switch to the new syntax to create a worker from a JS module once browsers are ready
|
167
167
|
? new cls(filePath, {name: name, type: 'module'})
|
168
168
|
: new cls(filePath, {name: name});
|
169
169
|
|
@@ -179,10 +179,10 @@ class Manager extends Base {
|
|
179
179
|
* Calls createWorker for each worker inside the this.workers config.
|
180
180
|
*/
|
181
181
|
createWorkers() {
|
182
|
-
let me
|
183
|
-
config
|
184
|
-
hash
|
185
|
-
windowId
|
182
|
+
let me = this,
|
183
|
+
config = Neo.clone(NeoConfig, true),
|
184
|
+
{hash, href, search} = location,
|
185
|
+
{windowId} = me,
|
186
186
|
key, value;
|
187
187
|
|
188
188
|
// remove configs which are not relevant for the workers scope
|
@@ -193,14 +193,11 @@ class Manager extends Base {
|
|
193
193
|
config.hash = {
|
194
194
|
hash : DomEvents.parseHash(hash.substring(1)),
|
195
195
|
hashString: hash.substring(1),
|
196
|
-
windowId
|
196
|
+
windowId
|
197
197
|
}
|
198
198
|
}
|
199
199
|
|
200
|
-
config.url = {
|
201
|
-
href : location.href,
|
202
|
-
search: location.search
|
203
|
-
};
|
200
|
+
config.url = {href, search};
|
204
201
|
|
205
202
|
for ([key, value] of Object.entries(me.workers)) {
|
206
203
|
if (key === 'canvas' && !config.useCanvasWorker ||
|
@@ -278,7 +275,7 @@ class Manager extends Base {
|
|
278
275
|
|
279
276
|
if (me.constructedThreads === me.activeWorkers) {
|
280
277
|
NeoConfig.appPath && setTimeout(() => { // better safe than sorry => all remotes need to be registered
|
281
|
-
me.loadApplication(NeoConfig.appPath)
|
278
|
+
me.loadApplication(NeoConfig.appPath)
|
282
279
|
}, NeoConfig.loadApplicationDelay)
|
283
280
|
}
|
284
281
|
}
|
@@ -298,7 +295,7 @@ class Manager extends Base {
|
|
298
295
|
*/
|
299
296
|
onWorkerMessage(e) {
|
300
297
|
let me = this,
|
301
|
-
data
|
298
|
+
{data} = e,
|
302
299
|
transfer = null,
|
303
300
|
promise;
|
304
301
|
|
@@ -328,7 +325,7 @@ class Manager extends Base {
|
|
328
325
|
}
|
329
326
|
|
330
327
|
promise[data.reject ? 'reject' : 'resolve'](data);
|
331
|
-
delete me.promises[replyId]
|
328
|
+
delete me.promises[replyId]
|
332
329
|
}
|
333
330
|
}
|
334
331
|
|
@@ -338,7 +335,7 @@ class Manager extends Base {
|
|
338
335
|
}
|
339
336
|
|
340
337
|
me.promiseMessage(dest, data, transfer).then(response => {
|
341
|
-
me.sendMessage(response.destination, response)
|
338
|
+
me.sendMessage(response.destination, response)
|
342
339
|
}).catch(err => {
|
343
340
|
me.sendMessage(data.origin, {
|
344
341
|
action : 'reply',
|
@@ -351,12 +348,11 @@ class Manager extends Base {
|
|
351
348
|
|
352
349
|
// only needed for SharedWorkers
|
353
350
|
else if (dest === 'main' && action === 'registerAppName') {
|
354
|
-
|
351
|
+
let {appName} = data;
|
355
352
|
|
356
|
-
me.
|
357
|
-
|
358
|
-
|
359
|
-
})
|
353
|
+
me.appNames.push(appName);
|
354
|
+
|
355
|
+
me.broadcast({action: 'registerApp', appName})
|
360
356
|
}
|
361
357
|
|
362
358
|
else if (dest === 'main' && action === 'remoteMethod') {
|
@@ -371,7 +367,7 @@ class Manager extends Base {
|
|
371
367
|
*/
|
372
368
|
promiseForwardMessage(data) {
|
373
369
|
return new Promise((resolve, reject) => {
|
374
|
-
this.promises[data.replyId] = {
|
370
|
+
this.promises[data.replyId] = {data, reject, resolve}
|
375
371
|
})
|
376
372
|
}
|
377
373
|
|
@@ -390,7 +386,7 @@ class Manager extends Base {
|
|
390
386
|
let message = me.sendMessage(dest, opts, transfer),
|
391
387
|
msgId = message.id;
|
392
388
|
|
393
|
-
me.promises[msgId] = {
|
389
|
+
me.promises[msgId] = {reject, resolve}
|
394
390
|
})
|
395
391
|
}
|
396
392
|
|
@@ -399,11 +395,12 @@ class Manager extends Base {
|
|
399
395
|
*/
|
400
396
|
resolveDomOperationPromise(replyId) {
|
401
397
|
if (replyId) {
|
402
|
-
let
|
398
|
+
let {promises} = this,
|
399
|
+
promise = promises[replyId];
|
403
400
|
|
404
401
|
if (promise) {
|
405
402
|
promise.resolve(promise.data);
|
406
|
-
delete
|
403
|
+
delete promises[replyId]
|
407
404
|
}
|
408
405
|
}
|
409
406
|
}
|
@@ -443,6 +440,4 @@ class Manager extends Base {
|
|
443
440
|
}
|
444
441
|
}
|
445
442
|
|
446
|
-
|
447
|
-
|
448
|
-
export default instance;
|
443
|
+
export default Neo.setupClass(Manager);
|
package/src/worker/Message.mjs
CHANGED
@@ -91,7 +91,7 @@ class ServiceBase extends Base {
|
|
91
91
|
});
|
92
92
|
|
93
93
|
Neo.currentWorker = me;
|
94
|
-
Neo.workerId = me.workerId
|
94
|
+
Neo.workerId = me.workerId
|
95
95
|
}
|
96
96
|
|
97
97
|
/**
|
@@ -128,7 +128,7 @@ class ServiceBase extends Base {
|
|
128
128
|
clientId : client.id,
|
129
129
|
destination: 'app',
|
130
130
|
port : port1
|
131
|
-
})
|
131
|
+
})
|
132
132
|
}
|
133
133
|
|
134
134
|
/**
|
@@ -140,11 +140,11 @@ class ServiceBase extends Base {
|
|
140
140
|
getPort(destination, clientId=this.lastClient?.id) {
|
141
141
|
for (let port of this.channelPorts) {
|
142
142
|
if (clientId === port.clientId && destination === port.destination) {
|
143
|
-
return port.port
|
143
|
+
return port.port
|
144
144
|
}
|
145
145
|
}
|
146
146
|
|
147
|
-
return null
|
147
|
+
return null
|
148
148
|
}
|
149
149
|
|
150
150
|
/**
|
@@ -156,7 +156,7 @@ class ServiceBase extends Base {
|
|
156
156
|
|
157
157
|
if (lastClientId && !me.remotes.includes(lastClientId)) {
|
158
158
|
me.remotes.push(lastClientId);
|
159
|
-
super.initRemote()
|
159
|
+
super.initRemote()
|
160
160
|
}
|
161
161
|
}
|
162
162
|
|
@@ -164,7 +164,7 @@ class ServiceBase extends Base {
|
|
164
164
|
* @param {ExtendableMessageEvent} event
|
165
165
|
*/
|
166
166
|
onActivate(event) {
|
167
|
-
console.log('onActivate', event)
|
167
|
+
console.log('onActivate', event)
|
168
168
|
}
|
169
169
|
|
170
170
|
/**
|
@@ -174,21 +174,21 @@ class ServiceBase extends Base {
|
|
174
174
|
console.log('onConnect', source);
|
175
175
|
|
176
176
|
this.createMessageChannel(source);
|
177
|
-
this.initRemote()
|
177
|
+
this.initRemote()
|
178
178
|
}
|
179
179
|
|
180
180
|
/**
|
181
181
|
* @param {ExtendableMessageEvent} event
|
182
182
|
*/
|
183
183
|
onFetch(event) {
|
184
|
-
let hasMatch
|
185
|
-
request = event
|
184
|
+
let hasMatch = false,
|
185
|
+
{request} = event,
|
186
186
|
key;
|
187
187
|
|
188
188
|
for (key of this.cachePaths) {
|
189
189
|
if (request.url.includes(key)) {
|
190
190
|
hasMatch = true;
|
191
|
-
break
|
191
|
+
break
|
192
192
|
}
|
193
193
|
}
|
194
194
|
|
@@ -199,7 +199,7 @@ class ServiceBase extends Base {
|
|
199
199
|
.then(response => cache.put(request, response.clone())
|
200
200
|
.then(() => response)
|
201
201
|
)))
|
202
|
-
)
|
202
|
+
)
|
203
203
|
}
|
204
204
|
|
205
205
|
/**
|
@@ -207,7 +207,7 @@ class ServiceBase extends Base {
|
|
207
207
|
*/
|
208
208
|
onInstall(event) {
|
209
209
|
console.log('onInstall', event);
|
210
|
-
globalThis.skipWaiting()
|
210
|
+
globalThis.skipWaiting()
|
211
211
|
}
|
212
212
|
|
213
213
|
/**
|
@@ -216,25 +216,24 @@ class ServiceBase extends Base {
|
|
216
216
|
* @param {ExtendableMessageEvent|MessageEvent} event
|
217
217
|
*/
|
218
218
|
onMessage(event) {
|
219
|
-
let me
|
220
|
-
data
|
221
|
-
action
|
222
|
-
replyId = data.replyId,
|
219
|
+
let me = this,
|
220
|
+
{data} = event,
|
221
|
+
{action, replyId} = data,
|
223
222
|
promise;
|
224
223
|
|
225
224
|
if (event.source) { // ExtendableMessageEvent
|
226
|
-
me.lastClient = event.source
|
225
|
+
me.lastClient = event.source
|
227
226
|
}
|
228
227
|
|
229
228
|
if (!action) {
|
230
|
-
throw new Error('Message action is missing: ' + data.id)
|
229
|
+
throw new Error('Message action is missing: ' + data.id)
|
231
230
|
}
|
232
231
|
|
233
232
|
if (action !== 'reply') {
|
234
233
|
me['on' + Neo.capitalize(action)](data, event);
|
235
234
|
} else if (promise = action === 'reply' && me.promises[replyId]) {
|
236
235
|
promise[data.reject ? 'reject' : 'resolve'](data.data);
|
237
|
-
delete me.promises[replyId]
|
236
|
+
delete me.promises[replyId]
|
238
237
|
}
|
239
238
|
}
|
240
239
|
|
@@ -243,7 +242,7 @@ class ServiceBase extends Base {
|
|
243
242
|
* @param {ExtendableMessageEvent} event
|
244
243
|
*/
|
245
244
|
onPing(msg, event) {
|
246
|
-
this.resolve(msg, {originMsg: msg})
|
245
|
+
this.resolve(msg, {originMsg: msg})
|
247
246
|
}
|
248
247
|
|
249
248
|
/**
|
@@ -260,7 +259,7 @@ class ServiceBase extends Base {
|
|
260
259
|
await me.clearCaches()
|
261
260
|
}
|
262
261
|
|
263
|
-
me.onConnect(event.source)
|
262
|
+
me.onConnect(event.source)
|
264
263
|
}
|
265
264
|
|
266
265
|
/**
|
@@ -271,7 +270,7 @@ class ServiceBase extends Base {
|
|
271
270
|
for (let [index, value] of this.channelPorts.entries()) {
|
272
271
|
if (value.clientId === event.source.id) {
|
273
272
|
this.channelPorts.splice(index, 1);
|
274
|
-
break
|
273
|
+
break
|
275
274
|
}
|
276
275
|
}
|
277
276
|
}
|
@@ -285,12 +284,12 @@ class ServiceBase extends Base {
|
|
285
284
|
async preloadAssets(data) {
|
286
285
|
let cacheName = data.cacheName || this.cacheName,
|
287
286
|
cache = await caches.open(cacheName),
|
288
|
-
files
|
287
|
+
{files} = data,
|
289
288
|
items = [],
|
290
289
|
asset, hasMatch, item;
|
291
290
|
|
292
291
|
if (!Array.isArray(files)) {
|
293
|
-
files = [files]
|
292
|
+
files = [files]
|
294
293
|
}
|
295
294
|
|
296
295
|
for (item of files) {
|
@@ -298,17 +297,17 @@ class ServiceBase extends Base {
|
|
298
297
|
|
299
298
|
if (!data.forceReload) {
|
300
299
|
asset = await cache.match(item);
|
301
|
-
hasMatch = !!asset
|
300
|
+
hasMatch = !!asset
|
302
301
|
}
|
303
302
|
|
304
|
-
!hasMatch && items.push(item)
|
303
|
+
!hasMatch && items.push(item)
|
305
304
|
}
|
306
305
|
|
307
306
|
if (items.length > 0) {
|
308
|
-
await cache.addAll(items)
|
307
|
+
await cache.addAll(items)
|
309
308
|
}
|
310
309
|
|
311
|
-
return {success: true}
|
310
|
+
return {success: true}
|
312
311
|
}
|
313
312
|
|
314
313
|
/**
|
@@ -326,8 +325,8 @@ class ServiceBase extends Base {
|
|
326
325
|
let message = me.sendMessage(dest, opts, transfer),
|
327
326
|
msgId = message.id;
|
328
327
|
|
329
|
-
me.promises[msgId] = {reject, resolve}
|
330
|
-
})
|
328
|
+
me.promises[msgId] = {reject, resolve}
|
329
|
+
})
|
331
330
|
}
|
332
331
|
|
333
332
|
/**
|
@@ -344,28 +343,25 @@ class ServiceBase extends Base {
|
|
344
343
|
*/
|
345
344
|
async removeAssets(data) {
|
346
345
|
if (!Neo.isObject(data)) {
|
347
|
-
data = {
|
348
|
-
assets: data
|
349
|
-
};
|
346
|
+
data = {assets: data}
|
350
347
|
}
|
351
348
|
|
352
|
-
let assets
|
353
|
-
cacheName
|
354
|
-
|
355
|
-
|
356
|
-
promises = [];
|
349
|
+
let {assets, options={}} = data,
|
350
|
+
cacheName = data.cacheName || this.cacheName,
|
351
|
+
cache = await caches.open(cacheName),
|
352
|
+
promises = [];
|
357
353
|
|
358
354
|
if (!Array.isArray(assets)) {
|
359
|
-
assets = [assets]
|
355
|
+
assets = [assets]
|
360
356
|
}
|
361
357
|
|
362
358
|
assets.forEach(asset => {
|
363
|
-
promises.push(cache.delete(asset, options))
|
359
|
+
promises.push(cache.delete(asset, options))
|
364
360
|
});
|
365
361
|
|
366
362
|
await Promise.all(promises);
|
367
363
|
|
368
|
-
return {success: true}
|
364
|
+
return {success: true}
|
369
365
|
}
|
370
366
|
|
371
367
|
/**
|
@@ -384,7 +380,7 @@ class ServiceBase extends Base {
|
|
384
380
|
port = this.getPort(dest) || this.lastClient;
|
385
381
|
|
386
382
|
port.postMessage(message, transfer);
|
387
|
-
return message
|
383
|
+
return message
|
388
384
|
}
|
389
385
|
}
|
390
386
|
|
package/src/worker/Task.mjs
CHANGED
package/src/worker/VDom.mjs
CHANGED
@@ -39,10 +39,8 @@ class VDom extends Base {
|
|
39
39
|
|
40
40
|
channel.port1.onmessage = me.onMessage.bind(me);
|
41
41
|
|
42
|
-
me.sendMessage('app', {action: 'registerPort', transfer: port2}, [port2])
|
42
|
+
me.sendMessage('app', {action: 'registerPort', transfer: port2}, [port2])
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
export default instance;
|
46
|
+
export default Neo.setupClass(VDom);
|
@@ -35,8 +35,8 @@ class RemoteMethodAccess extends Base {
|
|
35
35
|
* @returns {function(*=, *=): Promise<any>}
|
36
36
|
*/
|
37
37
|
generateRemote(remote, method) {
|
38
|
-
let me
|
39
|
-
origin = remote
|
38
|
+
let me = this,
|
39
|
+
{origin} = remote;
|
40
40
|
|
41
41
|
return function(data, buffer) {
|
42
42
|
let opts = {
|
@@ -58,10 +58,9 @@ class RemoteMethodAccess extends Base {
|
|
58
58
|
*/
|
59
59
|
onRegisterRemote(remote) {
|
60
60
|
if (remote.destination === Neo.workerId) {
|
61
|
-
let me
|
62
|
-
className = remote
|
63
|
-
|
64
|
-
pkg = Neo.ns(className, true);
|
61
|
+
let me = this,
|
62
|
+
{className, methods} = remote,
|
63
|
+
pkg = Neo.ns(className, true);
|
65
64
|
|
66
65
|
methods.forEach(method => {
|
67
66
|
if (remote.origin !== 'main' && pkg[method]) {
|