neo.mjs 3.2.10 → 4.0.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.
|
@@ -32,6 +32,7 @@ program
|
|
|
32
32
|
.option('-i, --info', 'print environment debug info')
|
|
33
33
|
.option('-a, --appName <value>')
|
|
34
34
|
.option('-m, --mainThreadAddons <value>', `Comma separated list of:\n${addonChoices.join(', ')}\nDefaults to DragDrop, Stylesheet`)
|
|
35
|
+
.option('-s, --useServiceWorker <value>', '"yes", "no"')
|
|
35
36
|
.option('-t, --themes <value>', ['all', ...themeFolders, 'none'].join(", "))
|
|
36
37
|
.option('-u, --useSharedWorkers <value>', '"yes", "no"')
|
|
37
38
|
.allowUnknownOption()
|
|
@@ -105,11 +106,22 @@ if (programOpts.info) {
|
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
108
|
|
|
109
|
+
if (!programOpts.useServiceWorker) {
|
|
110
|
+
questions.push({
|
|
111
|
+
type : 'list',
|
|
112
|
+
name : 'useServiceWorker',
|
|
113
|
+
message: 'Do you want to use a ServiceWorker for caching assets?',
|
|
114
|
+
choices: ['yes', 'no'],
|
|
115
|
+
default: 'no'
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
108
119
|
inquirer.prompt(questions).then(answers => {
|
|
109
120
|
let appName = programOpts.appName || answers.appName,
|
|
110
121
|
mainThreadAddons = programOpts.mainThreadAddons || answers.mainThreadAddons,
|
|
111
122
|
themes = programOpts.themes || answers.themes,
|
|
112
123
|
useSharedWorkers = programOpts.useSharedWorkers || answers.useSharedWorkers,
|
|
124
|
+
useServiceWorker = programOpts.useServiceWorker || answers.useServiceWorker,
|
|
113
125
|
lAppName = appName.toLowerCase(),
|
|
114
126
|
appPath = 'apps/' + lAppName + '/',
|
|
115
127
|
dir = 'apps/' + lAppName,
|
|
@@ -181,6 +193,10 @@ if (programOpts.info) {
|
|
|
181
193
|
neoConfig.useSharedWorkers = true;
|
|
182
194
|
}
|
|
183
195
|
|
|
196
|
+
if (useServiceWorker !== 'no') {
|
|
197
|
+
neoConfig.useServiceWorker = true;
|
|
198
|
+
}
|
|
199
|
+
|
|
184
200
|
if (!insideNeo) {
|
|
185
201
|
neoConfig.workerBasePath = '../../node_modules/neo.mjs/src/worker/';
|
|
186
202
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo.mjs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "The webworkers driven UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -34,18 +34,18 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://neomjs.github.io/pages/",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@fortawesome/fontawesome-free": "^6.1.
|
|
37
|
+
"@fortawesome/fontawesome-free": "^6.1.1",
|
|
38
38
|
"@material/mwc-button": "^0.25.3",
|
|
39
39
|
"@material/mwc-textfield": "^0.25.3",
|
|
40
40
|
"autoprefixer": "^10.4.4",
|
|
41
41
|
"chalk": "^5.0.1",
|
|
42
42
|
"clean-webpack-plugin": "^4.0.0",
|
|
43
43
|
"commander": "^9.1.0",
|
|
44
|
-
"cssnano": "^5.1.
|
|
44
|
+
"cssnano": "^5.1.5",
|
|
45
45
|
"envinfo": "^7.8.1",
|
|
46
46
|
"fs-extra": "^10.0.1",
|
|
47
47
|
"highlightjs-line-numbers.js": "^2.8.0",
|
|
48
|
-
"inquirer": "^8.2.
|
|
48
|
+
"inquirer": "^8.2.2",
|
|
49
49
|
"neo-jsdoc": "^1.0.1",
|
|
50
50
|
"neo-jsdoc-x": "^1.0.4",
|
|
51
51
|
"postcss": "^8.4.12",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import Base
|
|
2
|
-
import
|
|
3
|
-
import WorkerManager from '../../worker/Manager.mjs';
|
|
1
|
+
import Base from '../../core/Base.mjs';
|
|
2
|
+
import WorkerManager from '../../worker/Manager.mjs';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Creates a ServiceWorker instance, in case Neo.config.useServiceWorker is set to true
|
|
@@ -15,15 +14,6 @@ class ServiceWorker extends Base {
|
|
|
15
14
|
* @protected
|
|
16
15
|
*/
|
|
17
16
|
className: 'Neo.main.addon.ServiceWorker',
|
|
18
|
-
/**
|
|
19
|
-
* @member {String[]|Neo.core.Base[]|null} mixins=[RemoteMethodAccess]
|
|
20
|
-
*/
|
|
21
|
-
mixins: [RemoteMethodAccess],
|
|
22
|
-
/**
|
|
23
|
-
* @member {ServiceWorkerRegistration|null} registration=null
|
|
24
|
-
* @protected
|
|
25
|
-
*/
|
|
26
|
-
registration: null,
|
|
27
17
|
/**
|
|
28
18
|
* @member {Boolean} singleton=true
|
|
29
19
|
* @protected
|
|
@@ -45,22 +35,30 @@ class ServiceWorker extends Base {
|
|
|
45
35
|
path = (devMode ? config.basePath : config.workerBasePath) + (devMode ? folder : '') + fileName,
|
|
46
36
|
serviceWorker = navigator.serviceWorker;
|
|
47
37
|
|
|
38
|
+
window.addEventListener('beforeunload', me.onBeforeUnload.bind(me));
|
|
39
|
+
|
|
48
40
|
serviceWorker.register(path, opts)
|
|
49
41
|
.then(registration => {
|
|
50
|
-
me.registration = registration;
|
|
51
|
-
|
|
52
42
|
serviceWorker.ready.then(() => {
|
|
53
43
|
serviceWorker.onmessage = WorkerManager.onWorkerMessage.bind(WorkerManager);
|
|
54
44
|
|
|
55
45
|
WorkerManager.sendMessage('service', {
|
|
56
|
-
action
|
|
57
|
-
|
|
58
|
-
data : config
|
|
46
|
+
action: 'registerNeoConfig',
|
|
47
|
+
data : config
|
|
59
48
|
});
|
|
60
49
|
});
|
|
61
50
|
})
|
|
62
51
|
}
|
|
63
52
|
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
onBeforeUnload() {
|
|
58
|
+
WorkerManager.sendMessage('service', {
|
|
59
|
+
action: 'unregisterPort'
|
|
60
|
+
});
|
|
61
|
+
}
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
Neo.applyClassConfig(ServiceWorker);
|
|
@@ -257,6 +257,19 @@ class ServiceBase extends Base {
|
|
|
257
257
|
this.onConnect(event.source);
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
+
/**
|
|
261
|
+
* @param {Object} msg
|
|
262
|
+
* @param {ExtendableMessageEvent} event
|
|
263
|
+
*/
|
|
264
|
+
onUnregisterPort(msg, event) {
|
|
265
|
+
for (let [index, value] of this.channelPorts.entries()) {
|
|
266
|
+
if (value.clientId === event.source.id) {
|
|
267
|
+
this.channelPorts.splice(index, 1);
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
260
273
|
/**
|
|
261
274
|
* @param {Object} data
|
|
262
275
|
* @param {String} [data.cacheName=this.cacheName]
|