neo.mjs 9.9.0 → 9.10.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/ServiceWorker.mjs CHANGED
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='9.9.0'
23
+ * @member {String} version='9.10.0'
24
24
  */
25
- version: '9.9.0'
25
+ version: '9.10.0'
26
26
  }
27
27
 
28
28
  /**
@@ -107,7 +107,7 @@ class FooterContainer extends Container {
107
107
  }, {
108
108
  module: Component,
109
109
  cls : ['neo-version'],
110
- html : 'v9.9.0'
110
+ html : 'v9.10.0'
111
111
  }]
112
112
  }],
113
113
  /**
@@ -5,13 +5,23 @@ import {minifyHtml} from './util/minifyHtml.mjs';
5
5
  import {fileURLToPath} from 'url';
6
6
 
7
7
  const
8
- __filename = fileURLToPath(import.meta.url),
9
- __dirname = path.dirname(__filename),
10
- inputDirectories = ['apps', 'docs', 'examples', 'src'],
11
- outputBasePath = '../dist/esm/',
8
+ outputBasePath = 'dist/esm/',
12
9
  // Regex to find import statements with 'node_modules' in the path
13
10
  // It captures the entire import statement (excluding the leading 'import') and the path itself.
14
- regexImport = /(import(?:["'\s]*(?:[\w*{}\n\r\t, ]+)from\s*)?)(["'`])((?:(?!\2).)*node_modules(?:(?!\2).)*)\2/g;
11
+ regexImport = /(import(?:["'\s]*(?:[\w*{}\n\r\t, ]+)from\s*)?)(["'`])((?:(?!\2).)*node_modules(?:(?!\2).)*)\2/g,
12
+ root = path.resolve(),
13
+ requireJson = path => JSON.parse(fs.readFileSync(path, 'utf-8')),
14
+ packageJson = requireJson(path.join(root, 'package.json')),
15
+ insideNeo = packageJson.name.includes('neo.mjs'),
16
+ startDate = new Date();
17
+
18
+ let inputDirectories;
19
+
20
+ if (insideNeo) {
21
+ inputDirectories = ['apps', 'docs', 'examples', 'src']
22
+ } else {
23
+ inputDirectories = ['apps', 'docs', 'node_modules/neo.mjs/src', 'src']
24
+ }
15
25
 
16
26
  async function minifyDirectory(inputDir, outputDir) {
17
27
  if (fs.existsSync(inputDir)) {
@@ -20,6 +30,11 @@ async function minifyDirectory(inputDir, outputDir) {
20
30
  const dirents = fs.readdirSync(inputDir, {recursive: true, withFileTypes: true});
21
31
 
22
32
  for (const dirent of dirents) {
33
+ // Intended to skip the docs/output folder, since the content is already minified
34
+ if (dirent.path.includes('/docs/output/')) {
35
+ continue
36
+ }
37
+
23
38
  if (dirent.isFile()) {
24
39
  const
25
40
  inputPath = path.join(dirent.path, dirent.name),
@@ -27,7 +42,7 @@ async function minifyDirectory(inputDir, outputDir) {
27
42
  outputPath = path.join(outputDir, relativePath),
28
43
  content = fs.readFileSync(inputPath, 'utf8');
29
44
 
30
- await minifyFile(content, outputPath);
45
+ await minifyFile(content, outputPath)
31
46
  }
32
47
  // Copy resources folders
33
48
  else if (dirent.name === 'resources') {
@@ -50,7 +65,7 @@ async function minifyDirectory(inputDir, outputDir) {
50
65
  resourcePath = path.join(resource.path, resource.name),
51
66
  content = fs.readFileSync(resourcePath, 'utf8');
52
67
 
53
- fs.writeFileSync(resourcePath, JSON.stringify(JSON.parse(content)));
68
+ fs.writeFileSync(resourcePath, JSON.stringify(JSON.parse(content)))
54
69
  }
55
70
  }
56
71
  }
@@ -71,19 +86,20 @@ async function minifyFile(content, outputPath) {
71
86
  Object.assign(jsonContent, {
72
87
  basePath : '../../' + jsonContent.basePath,
73
88
  environment : 'dist/esm',
89
+ mainPath : './Main.mjs',
74
90
  workerBasePath: jsonContent.basePath + 'src/worker/'
75
91
  })
76
92
  }
77
93
 
78
94
  fs.writeFileSync(outputPath, JSON.stringify(jsonContent));
79
- console.log(`Minified JSON: ${outputPath}`);
95
+ console.log(`Minified JSON: ${outputPath}`)
80
96
  }
81
97
  // Minify HTML files
82
98
  else if (outputPath.endsWith('.html')) {
83
99
  const minifiedContent = await minifyHtml(content);
84
100
 
85
101
  fs.writeFileSync(outputPath, minifiedContent);
86
- console.log(`Minified HTML: ${outputPath}`);
102
+ console.log(`Minified HTML: ${outputPath}`)
87
103
  }
88
104
  // Minify JS files
89
105
  else if (outputPath.endsWith('.mjs')) {
@@ -95,7 +111,7 @@ async function minifyFile(content, outputPath) {
95
111
  const newPath = '../../' + p3; // Prepend 2 levels up
96
112
 
97
113
  // Reconstruct the import statement with the new path
98
- return p1 + p2 + newPath + p2;
114
+ return p1 + p2 + newPath + p2
99
115
  });
100
116
 
101
117
  const result = await minifyJs(adjustedContent, {
@@ -109,28 +125,38 @@ async function minifyFile(content, outputPath) {
109
125
  });
110
126
 
111
127
  fs.writeFileSync(outputPath, result.code);
112
- console.log(`Minified JS: ${outputPath}`);
128
+ console.log(`Minified JS: ${outputPath}`)
113
129
  }
114
130
  } catch (e) {
115
- console.error(`Error minifying ${outputPath}:`, e);
131
+ console.error(`Error minifying ${outputPath}:`, e)
116
132
  }
117
133
  }
118
134
 
119
135
  const
120
- swContent = fs.readFileSync(path.resolve(__dirname, '../ServiceWorker.mjs'), 'utf8'),
121
- promises = [minifyFile(swContent, path.resolve(__dirname, outputBasePath, 'ServiceWorker.mjs'))];
136
+ swContent = fs.readFileSync(path.resolve(root, 'ServiceWorker.mjs'), 'utf8'),
137
+ promises = [minifyFile(swContent, path.resolve(root, outputBasePath, 'ServiceWorker.mjs'))];
122
138
 
123
139
  // Execute the minification
124
140
  inputDirectories.forEach(folder => {
125
- promises.push(minifyDirectory(path.resolve(__dirname, '../' + folder), path.resolve(__dirname, outputBasePath, folder))
141
+ const outputPath = path.resolve(root, outputBasePath, folder.replace('node_modules/neo.mjs/', ''));
142
+
143
+ promises.push(minifyDirectory(path.resolve(root, folder), outputPath)
126
144
  .catch(err => {
127
145
  console.error('dist/esm Minification failed:', err);
128
146
  process.exit(1) // Exit with error code
129
147
  })
130
- );
148
+ )
131
149
  });
132
150
 
133
151
  Promise.all(promises).then(() => {
134
- console.log('dist/esm Minification complete.');
152
+ // Copying the already skipped and minified docs/output folder
153
+ const docsOutputPath = path.resolve(root, 'docs/output');
154
+
155
+ if (fs.existsSync(docsOutputPath)) {
156
+ fs.copySync(docsOutputPath, path.resolve(root, outputBasePath, 'docs/output'))
157
+ }
158
+
159
+ const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
160
+ console.log(`\nTotal time for dist/esm: ${processTime}s`);
135
161
  process.exit()
136
- });
162
+ })
@@ -26,7 +26,7 @@ program
26
26
  .option('-e, --env <value>', '"all", "dev", "prod"')
27
27
  .option('-f, --framework')
28
28
  .option('-n, --noquestions')
29
- .option('-t, --threads <value>', '"all", "app", "data", "main", "vdom"')
29
+ .option('-t, --threads <value>', '"all", "app", "canvas", "data", "main", "service", "task", "vdom"')
30
30
  .allowUnknownOption()
31
31
  .on('--help', () => {
32
32
  console.log('\nIn case you have any issues, please create a ticket here:');
@@ -61,7 +61,7 @@ if (programOpts.info) {
61
61
  type : 'list',
62
62
  name : 'threads',
63
63
  message: 'Please choose the threads to build:',
64
- choices: ['all', 'app', 'canvas', 'data', 'main', 'service', 'vdom'],
64
+ choices: ['all', 'app', 'canvas', 'data', 'main', 'service', 'task', 'vdom'],
65
65
  default: 'all'
66
66
  });
67
67
  }
@@ -110,6 +110,10 @@ if (programOpts.info) {
110
110
  childProcess = spawnSync(webpack, ['--config', `${tPath}.worker.mjs`, `--env insideNeo=${insideNeo} worker=service`], cpOpts);
111
111
  childProcess.status && process.exit(childProcess.status);
112
112
  }
113
+ if (threads === 'all' || threads === 'task') {
114
+ childProcess = spawnSync(webpack, ['--config', `${tPath}.worker.mjs`, `--env insideNeo=${insideNeo} worker=task`], cpOpts);
115
+ childProcess.status && process.exit(childProcess.status);
116
+ }
113
117
  if (threads === 'all' || threads === 'vdom') {
114
118
  childProcess = spawnSync(webpack, ['--config', `${tPath}.worker.mjs`, `--env insideNeo=${insideNeo} worker=vdom`], cpOpts);
115
119
  childProcess.status && process.exit(childProcess.status);
@@ -1,25 +1,30 @@
1
1
  {
2
- "mainInput": "./src/Main.mjs",
2
+ "mainInput" : "./src/Main.mjs",
3
3
  "mainOutput": "main.js",
4
+
4
5
  "workers": {
5
6
  "app": {
6
- "input": "./src/worker/App.mjs",
7
+ "input" : "./src/worker/App.mjs",
7
8
  "output": "appworker.js"
8
9
  },
9
10
  "canvas": {
10
- "input": "./src/worker/Canvas.mjs",
11
+ "input" : "./src/worker/Canvas.mjs",
11
12
  "output": "canvasworker.js"
12
13
  },
13
14
  "data": {
14
- "input": "./src/worker/Data.mjs",
15
+ "input" : "./src/worker/Data.mjs",
15
16
  "output": "dataworker.js"
16
17
  },
17
18
  "service": {
18
- "input": "./ServiceWorker.mjs",
19
+ "input" : "./ServiceWorker.mjs",
19
20
  "output": "serviceworker.js"
20
21
  },
22
+ "task": {
23
+ "input" : "./src/worker/Task.mjs",
24
+ "output": "taskworker.js"
25
+ },
21
26
  "vdom": {
22
- "input": "./src/worker/VDom.mjs",
27
+ "input" : "./src/worker/VDom.mjs",
23
28
  "output": "vdomworker.js"
24
29
  }
25
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name" : "neo.mjs",
3
- "version" : "9.9.0",
3
+ "version" : "9.10.0",
4
4
  "description" : "The webworkers driven UI framework",
5
5
  "type" : "module",
6
6
  "repository" : {
@@ -264,12 +264,12 @@ const DefaultConfig = {
264
264
  useVdomWorker: true,
265
265
  /**
266
266
  * buildScripts/injectPackageVersion.mjs will update this value
267
- * @default '9.9.0'
267
+ * @default '9.10.0'
268
268
  * @memberOf! module:Neo
269
269
  * @name config.version
270
270
  * @type String
271
271
  */
272
- version: '9.9.0'
272
+ version: '9.10.0'
273
273
  };
274
274
 
275
275
  Object.assign(DefaultConfig, {
@@ -67,11 +67,14 @@ class Canvas extends Base {
67
67
  onRegisterNeoConfig(msg) {
68
68
  super.onRegisterNeoConfig(msg);
69
69
 
70
- let path = Neo.config.appPath.slice(0, -8); // removing "/app.mjs"
70
+ let path = Neo.config.appPath;
71
+
72
+ if (path.endsWith('.mjs')) {
73
+ path = path.slice(0, -8); // removing "/app.mjs"
74
+ }
71
75
 
72
76
  import(
73
- /* webpackInclude: /\/canvas.mjs$/ */
74
- /* webpackExclude: /\/node_modules/ */
77
+ /* webpackExclude: /(?:\/|\\)(dist|node_modules)/ */
75
78
  /* webpackMode: "lazy" */
76
79
  `../../${path}/canvas.mjs`
77
80
  ).then(module => {
@@ -49,11 +49,14 @@ class Task extends Base {
49
49
  onRegisterNeoConfig(msg) {
50
50
  super.onRegisterNeoConfig(msg);
51
51
 
52
- let path = Neo.config.appPath.slice(0, -8); // removing "/app.mjs"
52
+ let path = Neo.config.appPath;
53
+
54
+ if (path.endsWith('.mjs')) {
55
+ path = path.slice(0, -8); // removing "/app.mjs"
56
+ }
53
57
 
54
58
  import(
55
- /* webpackInclude: /\/task.mjs$/ */
56
- /* webpackExclude: /\/node_modules/ */
59
+ /* webpackExclude: /(?:\/|\\)(dist|node_modules)/ */
57
60
  /* webpackMode: "lazy" */
58
61
  `../../${path}/task.mjs`
59
62
  ).then(module => {