neo.mjs 3.2.6 → 3.2.9
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/buildScripts/webpack/json/myApps.template.json +1 -19
- package/examples/preloadingAssets/app.mjs +6 -0
- package/examples/preloadingAssets/index.html +11 -0
- package/examples/preloadingAssets/neo-config.json +7 -0
- package/examples/preloadingAssets/view/MainContainer.mjs +77 -0
- package/examples/preloadingAssets/view/MainContainerController.mjs +41 -0
- package/package.json +1 -1
- package/src/calendar/README.md +1 -1
- package/src/calendar/view/EditEventContainer.mjs +1 -4
- package/src/calendar/view/MainContainer.mjs +2 -4
- package/src/layout/HBox.mjs +1 -3
- package/src/layout/VBox.mjs +1 -3
- package/src/main/addon/ServiceWorker.mjs +16 -12
- package/src/main/addon/Stylesheet.mjs +0 -1
- package/src/tab/Container.mjs +4 -4
- package/src/worker/Manager.mjs +4 -4
- package/src/worker/ServiceBase.mjs +39 -1
|
@@ -13,23 +13,5 @@
|
|
|
13
13
|
"SharedDialog",
|
|
14
14
|
"SharedDialog2",
|
|
15
15
|
"Website"
|
|
16
|
-
]
|
|
17
|
-
"workers": {
|
|
18
|
-
"app": {
|
|
19
|
-
"input": "./src/worker/App.mjs",
|
|
20
|
-
"output": "appworker.js"
|
|
21
|
-
},
|
|
22
|
-
"canvas": {
|
|
23
|
-
"input": "./src/worker/Canvas.mjs",
|
|
24
|
-
"output": "canvasworker.js"
|
|
25
|
-
},
|
|
26
|
-
"data": {
|
|
27
|
-
"input": "./src/worker/Data.mjs",
|
|
28
|
-
"output": "dataworker.js"
|
|
29
|
-
},
|
|
30
|
-
"vdom": {
|
|
31
|
-
"input": "./src/worker/VDom.mjs",
|
|
32
|
-
"output": "vdomworker.js"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
16
|
+
]
|
|
35
17
|
}
|
|
@@ -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>Preloading Assets</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<script src="../../src/MicroLoader.mjs" type="module"></script>
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import Component from '../../../src/component/Base.mjs';
|
|
2
|
+
import MainContainerController from './MainContainerController.mjs'
|
|
3
|
+
import TabContainer from '../../../src/tab/Container.mjs';
|
|
4
|
+
import Viewport from '../../../src/container/Viewport.mjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class Neo.examples.preloadingAssets.view.MainContainer
|
|
8
|
+
* @extends Neo.container.Viewport
|
|
9
|
+
*/
|
|
10
|
+
class MainContainer extends Viewport {
|
|
11
|
+
static getConfig() {return {
|
|
12
|
+
/**
|
|
13
|
+
* @member {String} className='Neo.examples.preloadingAssets.view.MainContainer'
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
className: 'Neo.examples.preloadingAssets.view.MainContainer',
|
|
17
|
+
/**
|
|
18
|
+
* @member {Boolean} autoMount=true
|
|
19
|
+
*/
|
|
20
|
+
autoMount: true,
|
|
21
|
+
/**
|
|
22
|
+
* @member {Neo.controller.Component} controller=MainContainerController
|
|
23
|
+
*/
|
|
24
|
+
controller: MainContainerController,
|
|
25
|
+
/**
|
|
26
|
+
* @member {Object} layout={ntype:'fit'}
|
|
27
|
+
*/
|
|
28
|
+
layout: {ntype: 'fit'},
|
|
29
|
+
/**
|
|
30
|
+
* @member {Object[]} items
|
|
31
|
+
*/
|
|
32
|
+
items: [{
|
|
33
|
+
module: TabContainer,
|
|
34
|
+
height: 300,
|
|
35
|
+
width : 500,
|
|
36
|
+
style : {flex: 'none', margin: '20px'},
|
|
37
|
+
|
|
38
|
+
itemDefaults: {
|
|
39
|
+
module: Component,
|
|
40
|
+
style : {flex: 'none', padding: '20px'}
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
items: [{
|
|
44
|
+
tabButtonConfig: {
|
|
45
|
+
iconCls: 'fa fa-user-astronaut',
|
|
46
|
+
text : 'Bob'
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
vdom: {
|
|
50
|
+
tag: 'img',
|
|
51
|
+
src: 'https://raw.githubusercontent.com/neomjs/pages/master/resources/examples/ai_images/000150.jpg'
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
tabButtonConfig: {
|
|
55
|
+
iconCls: 'fa fa-user-ninja',
|
|
56
|
+
text : 'Alice'
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
vdom: {
|
|
60
|
+
tag: 'img',
|
|
61
|
+
src: 'https://raw.githubusercontent.com/neomjs/pages/master/resources/examples/ai_images/000074.jpg'
|
|
62
|
+
}
|
|
63
|
+
}],
|
|
64
|
+
/**
|
|
65
|
+
* @member {Object} listeners
|
|
66
|
+
*/
|
|
67
|
+
listeners: {
|
|
68
|
+
activeIndexChange: 'onActiveIndexChange',
|
|
69
|
+
mounted : 'onMounted'
|
|
70
|
+
}
|
|
71
|
+
}]
|
|
72
|
+
}}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Neo.applyClassConfig(MainContainer);
|
|
76
|
+
|
|
77
|
+
export default MainContainer;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Component from '../../../src/controller/Component.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class Neo.examples.preloadingAssets.view.MainContainerController
|
|
5
|
+
* @extends Neo.controller.Component
|
|
6
|
+
*/
|
|
7
|
+
class MainContainerController extends Component {
|
|
8
|
+
static getConfig() {return {
|
|
9
|
+
/**
|
|
10
|
+
* @member {String} className='Neo.examples.preloadingAssets.view.MainContainerController'
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
className: 'Neo.examples.preloadingAssets.view.MainContainerController'
|
|
14
|
+
}}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @param {Object} data
|
|
18
|
+
*/
|
|
19
|
+
onActiveIndexChange(data) {
|
|
20
|
+
console.log('onActiveIndexChange', data);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {String} id
|
|
25
|
+
*/
|
|
26
|
+
onMounted(id) {
|
|
27
|
+
console.log('onMounted', id);
|
|
28
|
+
|
|
29
|
+
setTimeout(() => {
|
|
30
|
+
Neo.ServiceWorker.preloadAssets({
|
|
31
|
+
files: ['https://raw.githubusercontent.com/neomjs/pages/master/resources/examples/ai_images/000074.jpg']
|
|
32
|
+
}).then(data => {
|
|
33
|
+
console.log(data);
|
|
34
|
+
});
|
|
35
|
+
}, 3000)
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Neo.applyClassConfig(MainContainerController);
|
|
40
|
+
|
|
41
|
+
export default MainContainerController;
|
package/package.json
CHANGED
package/src/calendar/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# Development in progress
|
|
2
|
-
Currently, scheduled for the
|
|
2
|
+
Currently, scheduled for the v4.x release
|
|
@@ -92,10 +92,7 @@ class EditEventContainer extends FormContainer {
|
|
|
92
92
|
*/
|
|
93
93
|
afterSetMounted(value, oldValue) {
|
|
94
94
|
super.afterSetMounted(value, oldValue);
|
|
95
|
-
|
|
96
|
-
if (value) {
|
|
97
|
-
this.getField('title').focus();
|
|
98
|
-
}
|
|
95
|
+
value && this.getField('title').focus();
|
|
99
96
|
}
|
|
100
97
|
|
|
101
98
|
/**
|
|
@@ -310,7 +310,7 @@ class MainContainer extends Container {
|
|
|
310
310
|
style : {marginLeft: '10px'}
|
|
311
311
|
});
|
|
312
312
|
}, 10);
|
|
313
|
-
} else if (value
|
|
313
|
+
} else if (!value && oldValue) {
|
|
314
314
|
// we only need this logic in case we dynamically change the config from true to false
|
|
315
315
|
me.items[1] .removeLast();
|
|
316
316
|
me.items[0].items[1].removeLast();
|
|
@@ -652,9 +652,7 @@ class MainContainer extends Container {
|
|
|
652
652
|
|
|
653
653
|
map[me.activeView]();
|
|
654
654
|
|
|
655
|
-
me.model.setData({
|
|
656
|
-
currentDate: currentDate
|
|
657
|
-
});
|
|
655
|
+
me.model.setData({currentDate});
|
|
658
656
|
}
|
|
659
657
|
}
|
|
660
658
|
|
package/src/layout/HBox.mjs
CHANGED
package/src/layout/VBox.mjs
CHANGED
|
@@ -36,23 +36,27 @@ class ServiceWorker extends Base {
|
|
|
36
36
|
*/
|
|
37
37
|
construct(config) {
|
|
38
38
|
if ('serviceWorker' in navigator) {
|
|
39
|
-
let me
|
|
40
|
-
config
|
|
41
|
-
devMode
|
|
42
|
-
fileName
|
|
43
|
-
folder
|
|
44
|
-
opts
|
|
39
|
+
let me = this,
|
|
40
|
+
config = Neo.config,
|
|
41
|
+
devMode = config.environment === 'development',
|
|
42
|
+
fileName = devMode ? 'ServiceWorker.mjs' : 'serviceworker.js',
|
|
43
|
+
folder = window.location.pathname.includes('/examples/') ? 'examples/' : 'apps/',
|
|
44
|
+
opts = devMode ? {type: 'module'} : {},
|
|
45
|
+
path = (devMode ? config.basePath : config.workerBasePath) + (devMode ? folder : '') + fileName,
|
|
46
|
+
serviceWorker = navigator.serviceWorker;
|
|
45
47
|
|
|
46
|
-
|
|
48
|
+
serviceWorker.register(path, opts)
|
|
47
49
|
.then(registration => {
|
|
48
50
|
me.registration = registration;
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
serviceWorker.ready.then(() => {
|
|
53
|
+
serviceWorker.onmessage = WorkerManager.onWorkerMessage.bind(WorkerManager);
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
WorkerManager.sendMessage('service', {
|
|
56
|
+
action : 'registerNeoConfig',
|
|
57
|
+
channelPort: registration.active,
|
|
58
|
+
data : config
|
|
59
|
+
});
|
|
56
60
|
});
|
|
57
61
|
})
|
|
58
62
|
}
|
package/src/tab/Container.mjs
CHANGED
|
@@ -139,9 +139,9 @@ class Container extends BaseContainer {
|
|
|
139
139
|
me.updateTabButtons();
|
|
140
140
|
|
|
141
141
|
me.fire('activeIndexChange', {
|
|
142
|
-
item
|
|
143
|
-
oldValue
|
|
144
|
-
value
|
|
142
|
+
item: me.getActiveCard(),
|
|
143
|
+
oldValue,
|
|
144
|
+
value
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
}
|
|
@@ -245,7 +245,7 @@ class Container extends BaseContainer {
|
|
|
245
245
|
tabButtons.push(me.getTabButtonConfig(item.tabButtonConfig, index));
|
|
246
246
|
|
|
247
247
|
if (!(item instanceof Neo.component.Base)) {
|
|
248
|
-
item = {...me.itemDefaults,
|
|
248
|
+
item = {flex: 1, ...me.itemDefaults, isTab: true, ...item};
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
tabComponents.push(item);
|
package/src/worker/Manager.mjs
CHANGED
|
@@ -390,9 +390,9 @@ class Manager extends Base {
|
|
|
390
390
|
message, worker;
|
|
391
391
|
|
|
392
392
|
if (!me.stopCommunication) {
|
|
393
|
-
if (opts.
|
|
394
|
-
worker = opts.
|
|
395
|
-
delete opts.
|
|
393
|
+
if (opts.channelPort) {
|
|
394
|
+
worker = opts.channelPort;
|
|
395
|
+
delete opts.channelPort;
|
|
396
396
|
} else {
|
|
397
397
|
worker = me.getWorker(dest);
|
|
398
398
|
}
|
|
@@ -405,7 +405,7 @@ class Manager extends Base {
|
|
|
405
405
|
|
|
406
406
|
message = new Message(opts);
|
|
407
407
|
|
|
408
|
-
(
|
|
408
|
+
(worker.port ? worker.port : worker).postMessage(message, transfer);
|
|
409
409
|
return message;
|
|
410
410
|
}
|
|
411
411
|
}
|
|
@@ -60,7 +60,8 @@ class ServiceBase extends Base {
|
|
|
60
60
|
remote: {
|
|
61
61
|
app: [
|
|
62
62
|
'clearCache',
|
|
63
|
-
'clearCaches'
|
|
63
|
+
'clearCaches',
|
|
64
|
+
'preloadAssets'
|
|
64
65
|
]
|
|
65
66
|
},
|
|
66
67
|
/**
|
|
@@ -254,6 +255,43 @@ class ServiceBase extends Base {
|
|
|
254
255
|
this.onConnect(event.source);
|
|
255
256
|
}
|
|
256
257
|
|
|
258
|
+
/**
|
|
259
|
+
* @param {Object} data
|
|
260
|
+
* @param {String} [data.cacheName=this.cacheName]
|
|
261
|
+
* @param {String[]|String} data.files
|
|
262
|
+
* @param {Boolean} [data.foreReload=false]
|
|
263
|
+
*/
|
|
264
|
+
async preloadAssets(data) {
|
|
265
|
+
let cacheName = data.cacheName || this.cacheName,
|
|
266
|
+
cache = await caches.open(cacheName),
|
|
267
|
+
files = data.files,
|
|
268
|
+
items = [],
|
|
269
|
+
asset, hasMatch, item;
|
|
270
|
+
|
|
271
|
+
if (!Array.isArray(files)) {
|
|
272
|
+
files = [files];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
for (item of files) {
|
|
276
|
+
hasMatch = false;
|
|
277
|
+
|
|
278
|
+
if (!data.forceReload) {
|
|
279
|
+
asset = await cache.match(item);
|
|
280
|
+
hasMatch = !!asset;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (!hasMatch) {
|
|
284
|
+
items.push(item);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (items.length > 0) {
|
|
289
|
+
await cache.addAll(items);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return {success: true};
|
|
293
|
+
}
|
|
294
|
+
|
|
257
295
|
/**
|
|
258
296
|
* @param {String} dest app, data, main or vdom (excluding the current worker)
|
|
259
297
|
* @param {Object} opts configs for Neo.worker.Message
|