neo.mjs 7.13.0 → 7.15.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 +2 -2
- package/apps/portal/index.html +1 -1
- package/apps/portal/resources/data/blog.json +12 -0
- package/apps/portal/view/home/FooterContainer.mjs +1 -1
- package/buildScripts/createApp.mjs +21 -35
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +2 -2
- package/resources/scss/src/apps/portal/home/parts/MainNeo.scss +40 -35
- package/src/DefaultConfig.mjs +2 -2
- package/src/main/addon/FileSystemAccess.mjs +88 -0
- package/src/main/addon/ServiceWorker.mjs +2 -2
- package/src/worker/ServiceBase.mjs +7 -6
package/apps/ServiceWorker.mjs
CHANGED
package/apps/portal/index.html
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
[{
|
2
|
+
"author" : "Henrique Sagara",
|
3
|
+
"authorImage" : "author_htsagara.png",
|
4
|
+
"date" : "Oct 04, 2024",
|
5
|
+
"id" : 62,
|
6
|
+
"image" : "neo-website-logo.png",
|
7
|
+
"name" : "Neo.mjs: A high-performance open-source JavaScript framework.",
|
8
|
+
"provider" : "Dev.to",
|
9
|
+
"publisher" : "",
|
10
|
+
"selectedInto": [],
|
11
|
+
"type" : "Blog Post",
|
12
|
+
"url" : "https://dev.to/htsagara/neomjs-a-high-performance-open-source-javascript-framework-739"
|
13
|
+
}, {
|
2
14
|
"author" : "Nikhilesh Joshi",
|
3
15
|
"authorImage" : "author_hashnj.jpg",
|
4
16
|
"date" : "Oct 01, 2024",
|
@@ -7,18 +7,19 @@ import inquirer from 'inquirer';
|
|
7
7
|
import os from 'os';
|
8
8
|
import path from 'path';
|
9
9
|
|
10
|
-
const
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
const
|
11
|
+
__dirname = path.resolve(),
|
12
|
+
cwd = process.cwd(),
|
13
|
+
requireJson = path => JSON.parse(fs.readFileSync((path))),
|
14
|
+
packageJson = requireJson(path.join(__dirname, 'package.json')),
|
15
|
+
insideNeo = packageJson.name === 'neo.mjs',
|
16
|
+
neoPath = insideNeo ? './' : './node_modules/neo.mjs/',
|
17
|
+
addonChoices = fs.readdirSync(path.join(neoPath, '/src/main/addon')).map(item => item.slice(0, -4)),
|
18
|
+
program = new Command(),
|
19
|
+
programName = `${packageJson.name} create-app`,
|
20
|
+
questions = [],
|
21
|
+
scssFolders = fs.readdirSync(path.join(neoPath, '/resources/scss')),
|
22
|
+
themeFolders = [];
|
22
23
|
|
23
24
|
scssFolders.forEach(folder => {
|
24
25
|
if (folder.includes('theme')) {
|
@@ -86,16 +87,6 @@ if (programOpts.info) {
|
|
86
87
|
});
|
87
88
|
}
|
88
89
|
|
89
|
-
if (!programOpts.mainThreadAddons) {
|
90
|
-
questions.push({
|
91
|
-
type : 'checkbox',
|
92
|
-
name : 'mainThreadAddons',
|
93
|
-
message: 'Please choose your main thread addons:',
|
94
|
-
choices: addonChoices,
|
95
|
-
default: ['DragDrop', 'Stylesheet']
|
96
|
-
});
|
97
|
-
}
|
98
|
-
|
99
90
|
if (!programOpts.useSharedWorkers) {
|
100
91
|
questions.push({
|
101
92
|
type : 'list',
|
@@ -106,22 +97,12 @@ if (programOpts.info) {
|
|
106
97
|
});
|
107
98
|
}
|
108
99
|
|
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
|
-
|
119
100
|
inquirer.prompt(questions).then(answers => {
|
120
101
|
let appName = programOpts.appName || answers.appName,
|
121
|
-
mainThreadAddons = programOpts.mainThreadAddons ||
|
102
|
+
mainThreadAddons = programOpts.mainThreadAddons || ['DragDrop', 'Navigator', 'Stylesheet'],
|
122
103
|
themes = programOpts.themes || answers.themes,
|
123
104
|
useSharedWorkers = programOpts.useSharedWorkers || answers.useSharedWorkers,
|
124
|
-
useServiceWorker = programOpts.useServiceWorker ||
|
105
|
+
useServiceWorker = programOpts.useServiceWorker || 'no',
|
125
106
|
lAppName = appName.toLowerCase(),
|
126
107
|
appPath = 'apps/' + lAppName + '/',
|
127
108
|
dir = 'apps/' + lAppName,
|
@@ -177,7 +158,12 @@ if (programOpts.info) {
|
|
177
158
|
mainPath : `${insideNeo ? './' : '../node_modules/neo.mjs/src/'}Main.mjs`
|
178
159
|
};
|
179
160
|
|
180
|
-
if (!(
|
161
|
+
if (!(
|
162
|
+
mainThreadAddons.includes('DragDrop') &&
|
163
|
+
mainThreadAddons.includes('Navigator') &&
|
164
|
+
mainThreadAddons.includes('Stylesheet') &&
|
165
|
+
mainThreadAddons.length === 3)
|
166
|
+
) {
|
181
167
|
neoConfig.mainThreadAddons = mainThreadAddons;
|
182
168
|
}
|
183
169
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.15.0",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -60,7 +60,7 @@
|
|
60
60
|
"neo-jsdoc": "1.0.1",
|
61
61
|
"neo-jsdoc-x": "1.0.5",
|
62
62
|
"postcss": "^8.4.47",
|
63
|
-
"sass": "^1.79.
|
63
|
+
"sass": "^1.79.5",
|
64
64
|
"siesta-lite": "5.5.2",
|
65
65
|
"url": "^0.11.4",
|
66
66
|
"webpack": "^5.95.0",
|
@@ -1,17 +1,22 @@
|
|
1
1
|
@font-face {
|
2
2
|
font-family: "GT-Planar";
|
3
|
-
src: url("../../../../../../../../resources/fonts/GT-Planar-Regular.otf") format("opentype");
|
3
|
+
src : url("../../../../../../../../resources/fonts/GT-Planar-Regular.otf") format("opentype");
|
4
4
|
}
|
5
|
+
|
5
6
|
.portal-home-main-neo.portal-home-content-view {
|
6
|
-
|
7
|
+
background-color: #ffffff;
|
8
|
+
background-image: url("data:image/svg+xml,%3Csvg width='8' height='8' viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23504e54' fill-opacity='0.18' fill-rule='evenodd'%3E%3Cpath d='M5 0h1L0 6V5zM6 5v1H5z'/%3E%3C/g%3E%3C/svg%3E");
|
9
|
+
padding : 3em;
|
7
10
|
|
8
11
|
.logo-container {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
align-items : center;
|
13
|
+
background-color: transparent;
|
14
|
+
display : flex;
|
15
|
+
flex-direction : row;
|
16
|
+
flex-wrap : wrap;
|
17
|
+
gap : 20px;
|
18
|
+
min-height : 130px;
|
19
|
+
min-width : 240px;
|
15
20
|
}
|
16
21
|
|
17
22
|
.button-group {
|
@@ -22,56 +27,47 @@
|
|
22
27
|
}
|
23
28
|
|
24
29
|
.neo-h1 {
|
25
|
-
font-size : 110px;
|
26
30
|
font-family: "GT-Planar";
|
27
|
-
|
31
|
+
font-size : 60px;
|
28
32
|
}
|
29
33
|
|
30
34
|
.neo-h2 {
|
31
|
-
|
35
|
+
font-size : 2.5rem;
|
36
|
+
font-weight: 800;
|
37
|
+
margin : 1.25rem;
|
32
38
|
}
|
33
39
|
|
34
40
|
.neo-h3 {
|
35
|
-
margin
|
36
|
-
max-width: 900px;
|
41
|
+
margin : 1rem 14rem;
|
42
|
+
max-width : 900px;
|
43
|
+
text-align: center;
|
37
44
|
}
|
38
45
|
|
39
46
|
.vector {
|
47
|
+
background-color : transparent;
|
40
48
|
background-image : url("../../../../../../../../resources/images/logo/neo_logo_primary.svg");
|
41
49
|
background-position: center center;
|
42
50
|
background-repeat : no-repeat;
|
43
51
|
background-size : contain;
|
44
|
-
height :
|
45
|
-
|
46
|
-
min-height : 120px;
|
47
|
-
min-width : 140px;
|
48
|
-
}
|
49
|
-
|
50
|
-
@media (max-width: 1000px) {
|
51
|
-
.neo-h3 {
|
52
|
-
margin: 1rem 10rem;
|
53
|
-
}
|
52
|
+
height : 80px;
|
53
|
+
width : 80px;
|
54
54
|
}
|
55
55
|
|
56
|
-
@media (max-width:
|
56
|
+
@media (max-width : 1000px) {
|
57
57
|
.neo-h3 {
|
58
58
|
margin: 1rem 7rem;
|
59
59
|
}
|
60
60
|
}
|
61
61
|
|
62
|
-
@media (max-width: 645px) {
|
62
|
+
@media (max-width : 645px) {
|
63
63
|
padding: 1.5em 0.5em;
|
64
64
|
|
65
65
|
.logo-container {
|
66
66
|
gap: 10px;
|
67
67
|
}
|
68
68
|
|
69
|
-
.neo-h1 {
|
70
|
-
line-height: 1.2;
|
71
|
-
}
|
72
|
-
|
73
69
|
.neo-h2 {
|
74
|
-
margin: 0.5rem 0;
|
70
|
+
margin: 0.5rem 0.5rem;
|
75
71
|
}
|
76
72
|
|
77
73
|
.neo-h3 {
|
@@ -79,7 +75,7 @@
|
|
79
75
|
}
|
80
76
|
|
81
77
|
.vector {
|
82
|
-
height:
|
78
|
+
height: 17vw;
|
83
79
|
}
|
84
80
|
|
85
81
|
.button-group {
|
@@ -87,18 +83,27 @@
|
|
87
83
|
}
|
88
84
|
}
|
89
85
|
|
90
|
-
@media (max-width: 500px) {
|
86
|
+
@media (max-width : 500px) {
|
91
87
|
.logo-container {
|
92
88
|
gap: 10px;
|
93
89
|
}
|
94
90
|
|
95
91
|
.neo-h1 {
|
96
|
-
font-size
|
97
|
-
line-height: 1.2;
|
92
|
+
font-size: 40px;
|
98
93
|
}
|
99
94
|
|
100
95
|
.neo-h2 {
|
101
|
-
|
96
|
+
font-size: 2rem;
|
97
|
+
margin : 0.5rem 2rem;
|
98
|
+
}
|
99
|
+
|
100
|
+
.neo-h3 {
|
101
|
+
font-size: 1.15rem;
|
102
|
+
}
|
103
|
+
|
104
|
+
.vector {
|
105
|
+
height: 70px;
|
106
|
+
width : 70px;
|
102
107
|
}
|
103
108
|
}
|
104
109
|
}
|
package/src/DefaultConfig.mjs
CHANGED
@@ -262,12 +262,12 @@ const DefaultConfig = {
|
|
262
262
|
useVdomWorker: true,
|
263
263
|
/**
|
264
264
|
* buildScripts/injectPackageVersion.mjs will update this value
|
265
|
-
* @default '7.
|
265
|
+
* @default '7.15.0'
|
266
266
|
* @memberOf! module:Neo
|
267
267
|
* @name config.version
|
268
268
|
* @type String
|
269
269
|
*/
|
270
|
-
version: '7.
|
270
|
+
version: '7.15.0'
|
271
271
|
};
|
272
272
|
|
273
273
|
Object.assign(DefaultConfig, {
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import Base from './Base.mjs';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Basic support for File System Access API
|
5
|
+
*
|
6
|
+
* Note: the "File System API" is available in Web Workers.
|
7
|
+
* However, the "File System Access API" extensions are Not available in Web Workers,
|
8
|
+
* because they must handle user gestures and Web Workers do Not have access to the
|
9
|
+
* UI, aka main, thread.
|
10
|
+
*
|
11
|
+
* The extensions return a promises fulfilled by FileSystemHandles,
|
12
|
+
* the FileSystemHandles are serializable and make it through (Neo's) Web Worker
|
13
|
+
* postMessage signaling to the App worker code, and we are in business,
|
14
|
+
*
|
15
|
+
* Only supported by Chrome, Edge, Opera; tested with Neo on Chrome, Opera, Edge:
|
16
|
+
* https://developer.chrome.com/docs/capabilities/web-apis/file-system-access#browser_support
|
17
|
+
*
|
18
|
+
* Note: method parameters (the opts below) are identical to the method parameters in
|
19
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/Window/showOpenFilePicker
|
20
|
+
*
|
21
|
+
* @class Neo.main.addon.FileSystemAccess
|
22
|
+
* @extends Neo.main.addon.Base
|
23
|
+
*/
|
24
|
+
class FileSystemAccess extends Base {
|
25
|
+
static config = {
|
26
|
+
/**
|
27
|
+
* @member {String} className='Neo.main.addon.FileSystemAccess'
|
28
|
+
* @protected
|
29
|
+
*/
|
30
|
+
className: 'Neo.main.addon.FileSystemAccess',
|
31
|
+
/**
|
32
|
+
* Remote method access for other workers
|
33
|
+
* @member {Object} remote
|
34
|
+
* @protected
|
35
|
+
*/
|
36
|
+
remote: {
|
37
|
+
app: [
|
38
|
+
'showDirectoryPicker',
|
39
|
+
'showOpenFilePicker',
|
40
|
+
'showSaveFilePicker',
|
41
|
+
'supported'
|
42
|
+
]
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Shows a directory picker which allows the user to select a directory.
|
48
|
+
* returns a promise fulfilled by a directory handle object.
|
49
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/Window/showDirectoryPicker
|
50
|
+
* @param {Object} [opts]
|
51
|
+
* @returns {Promise<FileSystemDirectoryHandle>}
|
52
|
+
*/
|
53
|
+
async showDirectoryPicker(opts) {
|
54
|
+
return await window.showDirectoryPicker(opts)
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
* Shows a file picker which allows a user to select a file or files.
|
59
|
+
* returns a promise fulfilled an array of 1 or more filehandle objects.
|
60
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/Window/showOpenFilePicker
|
61
|
+
* @param {Object} [opts]
|
62
|
+
* @returns {Promise<FileSystemFileHandle[]>}
|
63
|
+
*/
|
64
|
+
async showOpenFilePicker(opts) {
|
65
|
+
return await window.showOpenFilePicker(opts)
|
66
|
+
}
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Shows a file picker that allows a user to save a file.
|
70
|
+
* returns a promise fulfilled by a filehandle object fulfillment.
|
71
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/Window/showSaveFilePicker
|
72
|
+
* @param {Object} [opts]
|
73
|
+
* @returns {Promise<FileSystemFileHandle>}
|
74
|
+
*/
|
75
|
+
async showSaveFilePicker(opts) {
|
76
|
+
return await window.showSaveFilePicker(opts)
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Tests if the browser supports the File System Access API.
|
81
|
+
* @returns {Boolean}
|
82
|
+
**/
|
83
|
+
supported() {
|
84
|
+
return 'showOpenFilePicker' in window
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
export default Neo.setupClass(FileSystemAccess);
|
@@ -42,7 +42,7 @@ class ServiceWorker extends Base {
|
|
42
42
|
* or in case of a force refresh.
|
43
43
|
* See: https://www.w3.org/TR/service-workers/#navigator-service-worker-controller
|
44
44
|
*/
|
45
|
-
WorkerManager.serviceWorker = registration.active
|
45
|
+
WorkerManager.serviceWorker = registration.active
|
46
46
|
}
|
47
47
|
|
48
48
|
WorkerManager.sendMessage('service', {
|
@@ -60,7 +60,7 @@ class ServiceWorker extends Base {
|
|
60
60
|
onBeforeUnload() {
|
61
61
|
WorkerManager.sendMessage('service', {
|
62
62
|
action: 'unregisterPort'
|
63
|
-
})
|
63
|
+
})
|
64
64
|
}
|
65
65
|
}
|
66
66
|
|
@@ -96,7 +96,7 @@ class ServiceBase extends Base {
|
|
96
96
|
|
97
97
|
/**
|
98
98
|
* @param {String} name=this.cacheName
|
99
|
-
* @returns {Object}
|
99
|
+
* @returns {Promise<Object>}
|
100
100
|
*/
|
101
101
|
async clearCache(name=this.cacheName) {
|
102
102
|
await caches.delete(name);
|
@@ -104,7 +104,7 @@ class ServiceBase extends Base {
|
|
104
104
|
}
|
105
105
|
|
106
106
|
/**
|
107
|
-
* @returns {Object}
|
107
|
+
* @returns {Promise<Object>}
|
108
108
|
*/
|
109
109
|
async clearCaches() {
|
110
110
|
let keys = await caches.keys();
|
@@ -289,6 +289,7 @@ class ServiceBase extends Base {
|
|
289
289
|
* @param {String} [data.cacheName=this.cacheName]
|
290
290
|
* @param {String[]|String} data.files
|
291
291
|
* @param {Boolean} [data.foreReload=false]
|
292
|
+
* @returns {Promise<Object>}
|
292
293
|
*/
|
293
294
|
async preloadAssets(data) {
|
294
295
|
let cacheName = data.cacheName || this.cacheName,
|
@@ -348,7 +349,7 @@ class ServiceBase extends Base {
|
|
348
349
|
* @param {Boolean} data.options.ignoreMethod=false
|
349
350
|
* @param {Boolean} data.options.ignoreSearch=false
|
350
351
|
* @param {Boolean} data.options.ignoreVary=false
|
351
|
-
* @returns {Object}
|
352
|
+
* @returns {Promise<Object>}
|
352
353
|
*/
|
353
354
|
async removeAssets(data) {
|
354
355
|
if (!Neo.isObject(data)) {
|
@@ -356,9 +357,9 @@ class ServiceBase extends Base {
|
|
356
357
|
}
|
357
358
|
|
358
359
|
let {assets, options={}} = data,
|
359
|
-
cacheName
|
360
|
-
cache
|
361
|
-
promises
|
360
|
+
cacheName = data.cacheName || this.cacheName,
|
361
|
+
cache = await caches.open(cacheName),
|
362
|
+
promises = [];
|
362
363
|
|
363
364
|
if (!Array.isArray(assets)) {
|
364
365
|
assets = [assets]
|