neo.mjs 6.7.8 → 6.8.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.
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='6.7.8'
23
+ * @member {String} version='6.8.0'
24
24
  */
25
- version: '6.7.8'
25
+ version: '6.8.0'
26
26
  }
27
27
 
28
28
  /**
@@ -3,7 +3,6 @@ import path from 'path';
3
3
  import webpack from 'webpack';
4
4
 
5
5
  const cwd = process.cwd(),
6
- configPath = path.resolve(cwd, 'buildScripts/myApps.json'),
7
6
  requireJson = path => JSON.parse(fs.readFileSync((path))),
8
7
  packageJson = requireJson(path.resolve(cwd, 'package.json')),
9
8
  neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
@@ -13,26 +12,16 @@ const cwd = process.cwd(),
13
12
  regexIndexNodeModules = /node_modules/g,
14
13
  regexTopLevel = /\.\.\//g;
15
14
 
16
- let config, examplesPath;
17
-
18
- if (fs.existsSync(configPath)) {
19
- config = requireJson(configPath);
20
- } else {
21
- const myAppsPath = path.resolve(neoPath, 'buildScripts/webpack/json/myApps.json');
22
-
23
- if (fs.existsSync(myAppsPath)) {
24
- config = requireJson(myAppsPath);
25
- } else {
26
- config = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/myApps.template.json'));
27
- }
28
- }
15
+ let contextAdjusted = false,
16
+ examplesPath;
29
17
 
30
18
  if (!buildTarget.folder) {
31
19
  buildTarget.folder = 'dist/development';
32
20
  }
33
21
 
34
22
  export default env => {
35
- let examples = [],
23
+ let apps = [],
24
+ examples = [],
36
25
  insideNeo = env.insideNeo == 'true',
37
26
  content, inputPath, outputPath;
38
27
 
@@ -88,7 +77,7 @@ export default env => {
88
77
 
89
78
  const isFile = fileName => fs.lstatSync(fileName).isFile();
90
79
 
91
- const parseFolder = (folderPath, index, relativePath) => {
80
+ const parseFolder = (apps, folderPath, index, relativePath) => {
92
81
  let itemPath;
93
82
 
94
83
  fs.readdirSync(folderPath).forEach(itemName => {
@@ -96,22 +85,26 @@ export default env => {
96
85
 
97
86
  if (isFile(itemPath)) {
98
87
  if (itemName === 'app.mjs') {
99
- examples.push(relativePath);
88
+ apps.push(relativePath);
100
89
  }
101
90
  } else {
102
- parseFolder(itemPath, index + 1, relativePath + `/${itemName}`);
91
+ parseFolder(apps, itemPath, index + 1, relativePath + `/${itemName}`);
103
92
  }
104
93
  });
105
94
  };
106
95
 
107
- config.apps?.forEach(key => {
108
- createStartingPoint(key, key === 'Docs' ? '' : 'apps');
96
+ parseFolder(apps, path.join(cwd, 'apps'), 0, '');
97
+
98
+ apps.forEach(key => {
99
+ createStartingPoint(key.substr(1), 'apps');
109
100
  });
110
101
 
102
+ createStartingPoint('Docs', '');
103
+
111
104
  examplesPath = path.join(cwd, 'examples');
112
105
 
113
106
  if (fs.existsSync(examplesPath)) {
114
- parseFolder(examplesPath, 0, '');
107
+ parseFolder(examples, examplesPath, 0, '');
115
108
 
116
109
  examples.forEach(key => {
117
110
  createStartingPoint(key.substr(1), 'examples');
@@ -130,8 +123,11 @@ export default env => {
130
123
 
131
124
  plugins: [
132
125
  new webpack.ContextReplacementPlugin(/.*/, context => {
133
- if (!insideNeo && context.context.includes('/src/worker')) {
134
- context.request = '../../' + context.request;
126
+ let con = context.context;
127
+
128
+ if (!insideNeo && !contextAdjusted && (con.includes('/src/worker') || con.includes('\\src\\worker'))) {
129
+ context.request = path.join('../../', context.request);
130
+ contextAdjusted = true;
135
131
  }
136
132
  }),
137
133
  ...plugins
@@ -7,12 +7,7 @@
7
7
  "RealWorld",
8
8
  "RealWorld2",
9
9
  "SharedCovid",
10
- "SharedCovidChart",
11
- "SharedCovidGallery",
12
- "SharedCovidHelix",
13
- "SharedCovidMap",
14
10
  "SharedDialog",
15
- "SharedDialog2",
16
11
  "Website"
17
12
  ]
18
13
  }
@@ -3,7 +3,6 @@ import path from 'path';
3
3
  import webpack from 'webpack';
4
4
 
5
5
  const cwd = process.cwd(),
6
- configPath = path.resolve(cwd, 'buildScripts/myApps.json'),
7
6
  requireJson = path => JSON.parse(fs.readFileSync((path))),
8
7
  packageJson = requireJson(path.resolve(cwd, 'package.json')),
9
8
  neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
@@ -17,26 +16,15 @@ const cwd = process.cwd(),
17
16
  regexTrimStart = /^\s+/gm;
18
17
 
19
18
  let contextAdjusted = false,
20
- config, examplesPath;
21
-
22
- if (fs.existsSync(configPath)) {
23
- config = requireJson(configPath);
24
- } else {
25
- const myAppsPath = path.resolve(neoPath, 'buildScripts/webpack/json/myApps.json');
26
-
27
- if (fs.existsSync(myAppsPath)) {
28
- config = requireJson(myAppsPath);
29
- } else {
30
- config = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/myApps.template.json'));
31
- }
32
- }
19
+ examplesPath;
33
20
 
34
21
  if (!buildTarget.folder) {
35
22
  buildTarget.folder = 'dist/production';
36
23
  }
37
24
 
38
25
  export default env => {
39
- let examples = [],
26
+ let apps = [],
27
+ examples = [],
40
28
  insideNeo = env.insideNeo == 'true',
41
29
  content, inputPath, outputPath;
42
30
 
@@ -98,7 +86,7 @@ export default env => {
98
86
 
99
87
  const isFile = fileName => fs.lstatSync(fileName).isFile();
100
88
 
101
- const parseFolder = (folderPath, index, relativePath) => {
89
+ const parseFolder = (apps, folderPath, index, relativePath) => {
102
90
  let itemPath;
103
91
 
104
92
  fs.readdirSync(folderPath).forEach(itemName => {
@@ -106,22 +94,26 @@ export default env => {
106
94
 
107
95
  if (isFile(itemPath)) {
108
96
  if (itemName === 'app.mjs') {
109
- examples.push(relativePath);
97
+ apps.push(relativePath);
110
98
  }
111
99
  } else {
112
- parseFolder(itemPath, index + 1, relativePath + `/${itemName}`);
100
+ parseFolder(apps, itemPath, index + 1, relativePath + `/${itemName}`);
113
101
  }
114
102
  });
115
103
  };
116
104
 
117
- config.apps?.forEach(key => {
118
- createStartingPoint(key, key === 'Docs' ? '' : 'apps');
105
+ parseFolder(apps, path.join(cwd, 'apps'), 0, '');
106
+
107
+ apps.forEach(key => {
108
+ createStartingPoint(key.substr(1), 'apps');
119
109
  });
120
110
 
111
+ createStartingPoint('Docs', '');
112
+
121
113
  examplesPath = path.join(cwd, 'examples');
122
114
 
123
115
  if (fs.existsSync(examplesPath)) {
124
- parseFolder(examplesPath, 0, '');
116
+ parseFolder(examples, examplesPath, 0, '');
125
117
 
126
118
  examples.forEach(key => {
127
119
  createStartingPoint(key.substr(1), 'examples');
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='6.7.8'
23
+ * @member {String} version='6.8.0'
24
24
  */
25
- version: '6.7.8'
25
+ version: '6.8.0'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "6.7.8",
3
+ "version": "6.8.0",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -14,7 +14,6 @@
14
14
  "add-config": "node ./buildScripts/addConfig.mjs",
15
15
  "build-all": "node ./buildScripts/buildAll.mjs -f -n",
16
16
  "build-all-questions": "node ./buildScripts/buildAll.mjs -f",
17
- "build-my-apps": "node ./buildScripts/webpack/buildMyApps.mjs -f",
18
17
  "build-themes": "node ./buildScripts/buildThemes.mjs -f",
19
18
  "build-threads": "node ./buildScripts/webpack/buildThreads.mjs -f",
20
19
  "create-app": "node ./buildScripts/createApp.mjs",
@@ -1,6 +1,6 @@
1
1
  .neo-switchfield {
2
2
  .neo-switchfield-input {
3
- background-color: var(--switchfield-color-off-idle);
3
+ background-color: var(--switchfield-color-off);
4
4
  border-radius : 999px;
5
5
  height : var(--switchfield-height);
6
6
  margin : 0;
@@ -20,32 +20,33 @@
20
20
  background-color: var(--switchfield-color-knob);
21
21
  border-radius : 50%;
22
22
  height : var(--switchfield-knobsize);
23
- left : 0;
24
- top : 1.5px;
23
+ left : 2px;
24
+ top : 2px;
25
25
  transition : transform 150ms ease-out;
26
26
  width : var(--switchfield-knobsize);
27
27
  }
28
28
 
29
29
  &:after {
30
- border : 1px solid var(--switchfield-color-knob);
30
+ border : 1px solid var(--switchfield-color-icon-off);
31
31
  border-radius: 50%;
32
- bottom : 7px;
33
- height : 8px;
34
- right : 7px;
35
- width : 8px;
32
+ bottom : 8px;
33
+ height : 6px;
34
+ right : 5px;
35
+ width : 6px;
36
36
  }
37
37
 
38
38
  &:checked {
39
- background-color: var(--switchfield-color-on-idle);
39
+ background-color: var(--switchfield-color-on);
40
40
 
41
41
  &:before {
42
- transform: translateX(100%);
42
+ transform: translateX(80%);
43
43
  }
44
44
 
45
45
  &:after {
46
- background-color: var(--switchfield-color-knob);
46
+ background-color: var(--switchfield-color-icon-on);
47
47
  border : 0;
48
- bottom : 8px;
48
+ border-radius : 0;
49
+ height : 8px;
49
50
  left : 9px;
50
51
  right : auto;
51
52
  width : 1px;
@@ -2,12 +2,14 @@
2
2
  --switchfield-bordercolor-focused: #57B2EF;
3
3
  --switchfield-borderwidth-focused: 4px;
4
4
  --switchfield-color-knob : #fff;
5
+ --switchfield-color-icon-on : #fff;
6
+ --switchfield-color-icon-off : #767676;
7
+ --switchfield-color-off : #BDBDBD;
5
8
  --switchfield-color-off-disabled : #BDBDBD;
6
9
  --switchfield-color-off-hovered : #9E9E9E;
7
- --switchfield-color-off-idle : #BDBDBD;
10
+ --switchfield-color-on : #005A96;
8
11
  --switchfield-color-on-disabled : #005A96;
9
12
  --switchfield-color-on-hovered : #004C7E;
10
- --switchfield-color-on-idle : #005A96;
11
13
  --switchfield-height : 24px;
12
14
  --switchfield-knobsize : 20px;
13
15
  --switchfield-opacity-disabled : .5;
@@ -2,12 +2,14 @@
2
2
  --switchfield-bordercolor-focused: #57B2EF;
3
3
  --switchfield-borderwidth-focused: 4px;
4
4
  --switchfield-color-knob : #fff;
5
+ --switchfield-color-icon-on : #fff;
6
+ --switchfield-color-icon-off : #767676;
7
+ --switchfield-color-off : #BDBDBD;
5
8
  --switchfield-color-off-disabled : #BDBDBD;
6
9
  --switchfield-color-off-hovered : #9E9E9E;
7
- --switchfield-color-off-idle : #BDBDBD;
10
+ --switchfield-color-on : #005A96;
8
11
  --switchfield-color-on-disabled : #005A96;
9
12
  --switchfield-color-on-hovered : #004C7E;
10
- --switchfield-color-on-idle : #005A96;
11
13
  --switchfield-height : 24px;
12
14
  --switchfield-knobsize : 20px;
13
15
  --switchfield-opacity-disabled : .5;
@@ -236,12 +236,12 @@ const DefaultConfig = {
236
236
  useVdomWorker: true,
237
237
  /**
238
238
  * buildScripts/injectPackageVersion.mjs will update this value
239
- * @default '6.7.8'
239
+ * @default '6.8.0'
240
240
  * @memberOf! module:Neo
241
241
  * @name config.version
242
242
  * @type String
243
243
  */
244
- version: '6.7.8'
244
+ version: '6.8.0'
245
245
  };
246
246
 
247
247
  Object.assign(DefaultConfig, {
@@ -109,7 +109,7 @@ class DateField extends Picker {
109
109
  me.dateSelector.on({
110
110
  change: me.onDatePickerChange,
111
111
  scope : me
112
- });
112
+ })
113
113
  }
114
114
 
115
115
  /**
@@ -162,7 +162,7 @@ class DateField extends Picker {
162
162
  * @returns {Neo.component.DateSelector}
163
163
  */
164
164
  createPickerComponent() {
165
- return this.dateSelector;
165
+ return this.dateSelector
166
166
  }
167
167
 
168
168
  /**
@@ -193,7 +193,7 @@ class DateField extends Picker {
193
193
  let me = this;
194
194
 
195
195
  me.hidePicker();
196
- me.focus(me.getInputElId());
196
+ me.focus(me.getInputElId())
197
197
  }
198
198
 
199
199
  /**
@@ -204,15 +204,15 @@ class DateField extends Picker {
204
204
  vdom = me.vdom;
205
205
 
206
206
  me.clean = false;
207
-
207
+
208
208
  if (me.hidePickerOnSelect) {
209
209
  VDomUtil.removeVdomChild(vdom, me.getPickerId());
210
210
 
211
211
  me.promiseUpdate().then(data => {
212
- me.value = opts.value;
213
- });
212
+ me.value = opts.value
213
+ })
214
214
  } else {
215
- me.value = opts.value;
215
+ me.value = opts.value
216
216
  }
217
217
  }
218
218
 
@@ -239,9 +239,9 @@ class DateField extends Picker {
239
239
 
240
240
  if (me.pickerIsMounted) {
241
241
  me.dateSelector.focusCurrentItem();
242
- super.onKeyDownEnter(data);
242
+ super.onKeyDownEnter(data)
243
243
  } else {
244
- super.onKeyDownEnter(data, me.dateSelector.focusCurrentItem, me.dateSelector);
244
+ super.onKeyDownEnter(data, me.dateSelector.focusCurrentItem, me.dateSelector)
245
245
  }
246
246
  }
247
247
 
@@ -2,12 +2,16 @@ import Base from '../../form/field/Base.mjs';
2
2
  import NeoArray from '../../util/Array.mjs';
3
3
 
4
4
  const
5
- sizeRE = /^(\d+)(kb|mb|gb)?$/i,
6
- sizeMultiplier = {
5
+ sizeRE = /^(\d+)(kb|mb|gb)?$/i,
6
+ sizeMultiplier = {
7
7
  unit : 1,
8
8
  kb : 1000,
9
9
  mb : 1000000,
10
10
  gb : 1000000000
11
+ },
12
+ httpSuccessCodes = {
13
+ 2 : 1,
14
+ 4 : 1
11
15
  };
12
16
 
13
17
  /**
@@ -509,7 +513,7 @@ class FileUpload extends Base {
509
513
 
510
514
  // Successful network request.
511
515
  // Check the resulting JSON packet for details and any error.
512
- if (String(xhr.status).startsWith('2')) {
516
+ if (httpSuccessCodes[String(xhr.status)[0]]) {
513
517
  if (loaded !== 0) {
514
518
  const response = JSON.parse(xhr.response);
515
519
 
@@ -600,7 +604,7 @@ class FileUpload extends Base {
600
604
  });
601
605
 
602
606
  // Success
603
- if (String(statusResponse.status).slice(0, 1) === '2') {
607
+ if (httpSuccessCodes[String(statusResponse.status)[0]]) {
604
608
  me.clear();
605
609
  me.state = 'ready';
606
610
  }
@@ -624,7 +628,7 @@ class FileUpload extends Base {
624
628
  });
625
629
 
626
630
  // Success
627
- if (String(statusResponse.status).slice(0, 1) === '2') {
631
+ if (httpSuccessCodes[String(statusResponse.status)[0]]) {
628
632
  const
629
633
  serverJson = await statusResponse.json(),
630
634
  serverStatus = serverJson.status,
@@ -1,128 +0,0 @@
1
- import chalk from 'chalk';
2
- import { spawnSync } from 'child_process';
3
- import { Command } from 'commander/esm.mjs';
4
- import envinfo from 'envinfo';
5
- import fs from 'fs-extra';
6
- import inquirer from 'inquirer';
7
- import os from 'os';
8
- import path from 'path';
9
-
10
- const __dirname = path.resolve(),
11
- cwd = process.cwd(),
12
- cpOpts = {env: process.env, cwd: cwd, stdio: 'inherit', shell: true},
13
- requireJson = path => JSON.parse(fs.readFileSync((path))),
14
- packageJson = requireJson(path.resolve(cwd, 'package.json')),
15
- program = new Command(),
16
- configPath = path.resolve(cwd, 'buildScripts/myApps.json'),
17
- neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
18
- webpackPath = path.resolve(neoPath, 'buildScripts/webpack'),
19
- programName = `${packageJson.name} buildMyApps`,
20
- questions = [];
21
-
22
- let webpack = './node_modules/.bin/webpack',
23
- config;
24
-
25
- if (fs.existsSync(configPath)) {
26
- config = requireJson(configPath);
27
- } else {
28
- const myAppsPath = path.resolve(neoPath, 'buildScripts/webpack/json/myApps.json');
29
-
30
- if (fs.existsSync(myAppsPath)) {
31
- config = requireJson(myAppsPath);
32
- } else {
33
- config = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/myApps.template.json'));
34
- }
35
- }
36
-
37
- let index = config.apps.indexOf('Docs');
38
-
39
- index > -1 && config.apps.splice(index, 1);
40
-
41
- program
42
- .name(programName)
43
- .version(packageJson.version)
44
- .option('-i, --info', 'print environment debug info')
45
- .option('-a, --apps <value>', ['all'].concat(config.apps).map(e => `"${e}"`).join(', '))
46
- .option('-e, --env <value>', '"all", "dev", "prod"')
47
- .option('-f, --framework')
48
- .option('-n, --noquestions')
49
- .allowUnknownOption()
50
- .on('--help', () => {
51
- console.log('\nIn case you have any issues, please create a ticket here:');
52
- console.log(chalk.cyan(packageJson.bugs.url));
53
- })
54
- .parse(process.argv);
55
-
56
- const programOpts = program.opts();
57
-
58
- if (programOpts.info) {
59
- console.log(chalk.bold('\nEnvironment Info:'));
60
- console.log(`\n current version of ${packageJson.name}: ${packageJson.version}`);
61
- console.log(` running from ${__dirname}`);
62
-
63
- envinfo
64
- .run({
65
- System : ['OS', 'CPU'],
66
- Binaries : ['Node', 'npm', 'Yarn'],
67
- Browsers : ['Chrome', 'Edge', 'Firefox', 'Safari'],
68
- npmPackages: ['neo.mjs']
69
- }, {
70
- duplicates : true,
71
- showNotFound: true
72
- })
73
- .then(console.log);
74
- } else {
75
- console.log(chalk.green(programName));
76
-
77
- if (!programOpts.noquestions) {
78
- if (!programOpts.env) {
79
- questions.push({
80
- type : 'list',
81
- name : 'env',
82
- message: 'Please choose the environment:',
83
- choices: ['all', 'dev', 'prod'],
84
- default: 'all'
85
- });
86
- }
87
-
88
- if (!programOpts.apps && config.apps.length > 1) {
89
- questions.push({
90
- type : 'checkbox',
91
- name : 'apps',
92
- message: 'Please choose which apps you want to build:',
93
- choices: config.apps
94
- });
95
- }
96
- }
97
-
98
- inquirer.prompt(questions).then(answers => {
99
- const apps = (answers.apps.length > 0 ? answers.apps : null) || programOpts.apps || ['all'],
100
- env = answers.env || programOpts.env || ['all'],
101
- insideNeo = !!programOpts.framework || false,
102
- startDate = new Date();
103
- let childProcess;
104
-
105
- if (os.platform().startsWith('win')) {
106
- webpack = path.resolve(webpack).replace(/\\/g,'/');
107
- }
108
-
109
- // dist/development
110
- if (env === 'all' || env === 'dev') {
111
- console.log(chalk.blue(`${programName} starting dist/development`));
112
- childProcess = spawnSync(webpack, ['--config', `${webpackPath}/development/webpack.config.myapps.mjs`, `--env apps=${apps}`, `--env insideNeo=${insideNeo}`], cpOpts);
113
- childProcess.status && process.exit(childProcess.status);
114
- }
115
-
116
- // dist/production
117
- if (env === 'all' || env === 'prod') {
118
- console.log(chalk.blue(`${programName} starting dist/production`));
119
- childProcess = spawnSync(webpack, ['--config', `${webpackPath}/production/webpack.config.myapps.mjs`, `--env apps=${apps}`, `--env insideNeo=${insideNeo}`], cpOpts);
120
- childProcess.status && process.exit(childProcess.status);
121
- }
122
-
123
- const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
124
- console.log(`\nTotal time for ${programName}: ${processTime}s`);
125
-
126
- process.exit();
127
- });
128
- }
@@ -1,127 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import webpack from 'webpack';
4
-
5
- const cwd = process.cwd(),
6
- configPath = path.resolve(cwd, 'buildScripts/myApps.json'),
7
- requireJson = path => JSON.parse(fs.readFileSync((path))),
8
- packageJson = requireJson(path.resolve(cwd, 'package.json')),
9
- neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
10
- buildTarget = requireJson(path.resolve(neoPath, 'buildScripts/webpack/development/buildTarget.json')),
11
- filenameConfig = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/build.json')),
12
- plugins = [],
13
- regexIndexNodeModules = /node_modules/g,
14
- regexTopLevel = /\.\.\//g;
15
-
16
- let config;
17
-
18
- if (fs.existsSync(configPath)) {
19
- config = requireJson(configPath);
20
- } else {
21
- const myAppsPath = path.resolve(neoPath, 'buildScripts/webpack/json/myApps.json');
22
-
23
- if (fs.existsSync(myAppsPath)) {
24
- config = requireJson(myAppsPath);
25
- } else {
26
- config = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/myApps.template.json'));
27
- }
28
- }
29
-
30
- let index = config.apps.indexOf('Docs');
31
-
32
- index > -1 && config.apps.splice(index, 1);
33
-
34
- if (!buildTarget.folder) {
35
- buildTarget.folder = 'dist/development';
36
- }
37
-
38
- export default env => {
39
- let apps = env.apps.split(','),
40
- insideNeo = env.insideNeo == 'true',
41
- buildAll = apps.includes('all'),
42
- choices = [],
43
- basePath, content, i, inputPath, outputPath, lAppName, treeLevel, workerBasePath;
44
-
45
- // MicroLoader.mjs
46
- inputPath = path.resolve(cwd, 'src/MicroLoader.mjs');
47
- outputPath = path.resolve(cwd, buildTarget.folder, 'src/MicroLoader.mjs');
48
-
49
- content = fs.readFileSync(inputPath).toString().replace(/\s/gm, '');
50
- fs.mkdirpSync(path.resolve(cwd, buildTarget.folder, 'src/'));
51
- fs.writeFileSync(outputPath, content);
52
-
53
- if (config.apps) {
54
- config.apps.forEach(key => {
55
- choices.push(key);
56
- });
57
-
58
- config.apps.forEach(key => {
59
- if (buildAll || choices.length < 2 || apps.includes(key)) {
60
- basePath = '';
61
- workerBasePath = '';
62
- treeLevel = key.replace('.', '/').split('/').length + 3;
63
-
64
- for (i=0; i < treeLevel; i++) {
65
- basePath += '../';
66
-
67
- if (i > 1) {
68
- workerBasePath += '../';
69
- }
70
- }
71
-
72
- lAppName = key.toLowerCase();
73
-
74
- // neo-config.json
75
- inputPath = path.resolve(cwd, 'apps', lAppName, 'neo-config.json');
76
- outputPath = path.resolve(cwd, buildTarget.folder, 'apps', lAppName, 'neo-config.json');
77
-
78
- content = requireJson(inputPath);
79
-
80
- content.appPath = content.appPath.replace(regexTopLevel, '');
81
-
82
- Object.assign(content, {
83
- basePath,
84
- environment: 'dist/development',
85
- mainPath : '../main.js',
86
- workerBasePath
87
- });
88
-
89
- fs.writeFileSync(outputPath, JSON.stringify(content, null, 4));
90
-
91
- // index.html
92
- inputPath = path.resolve(cwd, 'apps', lAppName, 'index.html');
93
- outputPath = path.resolve(cwd, buildTarget.folder, 'apps', lAppName, 'index.html');
94
-
95
- content = fs.readFileSync(inputPath).toString().replace(regexIndexNodeModules, '../../node_modules');
96
-
97
- fs.writeFileSync(outputPath, content);
98
- }
99
- });
100
- }
101
-
102
- return {
103
- mode: 'development',
104
-
105
- // see: https://webpack.js.org/configuration/devtool/
106
- devtool: 'inline-source-map',
107
- //devtool: 'cheap-module-eval-source-map',
108
-
109
- entry : {app: path.resolve(neoPath, './src/worker/App.mjs')},
110
- target: 'webworker',
111
-
112
- plugins: [
113
- new webpack.ContextReplacementPlugin(/.*/, context => {
114
- if (!insideNeo && context.context.includes('/src/worker')) {
115
- context.request = '../../' + context.request;
116
- }
117
- }),
118
- ...plugins
119
- ],
120
-
121
- output: {
122
- chunkFilename: 'chunks/app/[id].js',
123
- filename : filenameConfig.workers.app.output,
124
- path : path.resolve(cwd, buildTarget.folder)
125
- }
126
- }
127
- };
@@ -1,132 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- import webpack from 'webpack';
4
-
5
- const cwd = process.cwd(),
6
- configPath = path.resolve(cwd, 'buildScripts/myApps.json'),
7
- requireJson = path => JSON.parse(fs.readFileSync((path))),
8
- packageJson = requireJson(path.resolve(cwd, 'package.json')),
9
- neoPath = packageJson.name === 'neo.mjs' ? './' : './node_modules/neo.mjs/',
10
- buildTarget = requireJson(path.resolve(neoPath, 'buildScripts/webpack/production/buildTarget.json')),
11
- filenameConfig = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/build.json')),
12
- plugins = [],
13
- regexIndexNodeModules = /node_modules/g,
14
- regexLineBreak = /(\r\n|\n|\r)/gm,
15
- regexTopLevel = /\.\.\//g,
16
- regexTrimEnd = /\s+$/gm,
17
- regexTrimStart = /^\s+/gm;
18
-
19
- let config;
20
-
21
- if (fs.existsSync(configPath)) {
22
- config = requireJson(configPath);
23
- } else {
24
- const myAppsPath = path.resolve(neoPath, 'buildScripts/webpack/json/myApps.json');
25
-
26
- if (fs.existsSync(myAppsPath)) {
27
- config = requireJson(myAppsPath);
28
- } else {
29
- config = requireJson(path.resolve(neoPath, 'buildScripts/webpack/json/myApps.template.json'));
30
- }
31
- }
32
-
33
- let index = config.apps.indexOf('Docs');
34
-
35
- index > -1 && config.apps.splice(index, 1);
36
-
37
- if (!buildTarget.folder) {
38
- buildTarget.folder = 'dist/production';
39
- }
40
-
41
- export default env => {
42
- let apps = env.apps.split(','),
43
- insideNeo = env.insideNeo == 'true',
44
- buildAll = apps.includes('all'),
45
- choices = [],
46
- basePath, content, i, inputPath, outputPath, lAppName, treeLevel, workerBasePath;
47
-
48
- // MicroLoader.mjs
49
- inputPath = path.resolve(cwd, 'src/MicroLoader.mjs');
50
- outputPath = path.resolve(cwd, buildTarget.folder, 'src/MicroLoader.mjs');
51
-
52
- content = fs.readFileSync(inputPath).toString().replace(/\s/gm, '');
53
- fs.mkdirpSync(path.resolve(cwd, buildTarget.folder, 'src/'));
54
- fs.writeFileSync(outputPath, content);
55
-
56
-
57
-
58
- if (config.apps) {
59
- config.apps.forEach(key => {
60
- choices.push(key);
61
- });
62
-
63
- config.apps.forEach(key => {
64
- if (buildAll || choices.length < 2 || apps.includes(key)) {
65
- basePath = '';
66
- workerBasePath = '';
67
- treeLevel = key.replace('.', '/').split('/').length + 3;
68
-
69
- for (i=0; i < treeLevel; i++) {
70
- basePath += '../';
71
-
72
- if (i > 1) {
73
- workerBasePath += '../';
74
- }
75
- }
76
-
77
- lAppName = key.toLowerCase();
78
-
79
- // neo-config.json
80
- inputPath = path.resolve(cwd, 'apps', lAppName, 'neo-config.json');
81
- outputPath = path.resolve(cwd, buildTarget.folder, 'apps', lAppName, 'neo-config.json');
82
-
83
- content = requireJson(inputPath);
84
- delete content.environment;
85
-
86
- content.appPath = content.appPath.replace(regexTopLevel, '');
87
-
88
- Object.assign(content, {
89
- basePath,
90
- mainPath: '../main.js',
91
- workerBasePath
92
- });
93
-
94
- fs.writeFileSync(outputPath, JSON.stringify(content));
95
-
96
- // index.html
97
- inputPath = path.resolve(cwd, 'apps', lAppName, 'index.html');
98
- outputPath = path.resolve(cwd, buildTarget.folder, 'apps', lAppName, 'index.html');
99
-
100
- content = fs.readFileSync(inputPath).toString()
101
- .replace(regexIndexNodeModules, '../../node_modules')
102
- .replace(regexTrimStart, '')
103
- .replace(regexTrimEnd, '')
104
- .replace(', ', ',')
105
- .replace(regexLineBreak, '');
106
-
107
- fs.writeFileSync(outputPath, content);
108
- }
109
- });
110
- }
111
-
112
- return {
113
- mode : 'production',
114
- entry : {app: path.resolve(neoPath, './src/worker/App.mjs')},
115
- target: 'webworker',
116
-
117
- plugins: [
118
- new webpack.ContextReplacementPlugin(/.*/, context => {
119
- if (!insideNeo && context.context.includes('/src/worker')) {
120
- context.request = '../../' + context.request;
121
- }
122
- }),
123
- ...plugins
124
- ],
125
-
126
- output: {
127
- chunkFilename: 'chunks/app/[id].js',
128
- filename : filenameConfig.workers.app.output,
129
- path : path.resolve(cwd, buildTarget.folder)
130
- }
131
- }
132
- };