neo.mjs 4.0.47 → 4.0.50
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/createClass.mjs +191 -0
- package/buildScripts/webpack/production/webpack.config.appworker.mjs +7 -3
- package/package.json +4 -3
- package/src/component/DateSelector.mjs +3 -2
- package/src/component/mwc/TextField.mjs +2 -2
- package/src/draggable/DragZone.mjs +4 -4
- package/src/filter/BooleanContainer.mjs +2 -2
- package/src/filter/NumberContainer.mjs +4 -4
- package/src/filter/ToggleOperatorsButton.mjs +2 -2
- package/src/form/field/Base.mjs +2 -2
- package/src/main/addon/AmCharts.mjs +1 -1
- package/src/main/addon/WebComponent.mjs +5 -2
- package/src/main/mixin/TouchDomEvents.mjs +0 -1
- package/src/selection/GalleryModel.mjs +2 -2
- package/src/selection/HelixModel.mjs +3 -3
- package/src/table/View.mjs +1 -1
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { Command } from 'commander/esm.mjs';
|
|
3
|
+
import envinfo from 'envinfo';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import inquirer from 'inquirer';
|
|
6
|
+
import os from 'os';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
const __dirname = path.resolve(),
|
|
10
|
+
cwd = process.cwd(),
|
|
11
|
+
requireJson = path => JSON.parse(fs.readFileSync((path))),
|
|
12
|
+
packageJson = requireJson(path.join(__dirname, 'package.json')),
|
|
13
|
+
insideNeo = packageJson.name === 'neo.mjs',
|
|
14
|
+
program = new Command(),
|
|
15
|
+
programName = `${packageJson.name} create-class`,
|
|
16
|
+
questions = [];
|
|
17
|
+
|
|
18
|
+
program
|
|
19
|
+
.name(programName)
|
|
20
|
+
.version(packageJson.version)
|
|
21
|
+
.option('-i, --info', 'print environment debug info')
|
|
22
|
+
.option('-b, --baseClass <value>')
|
|
23
|
+
.option('-c, --className <value>')
|
|
24
|
+
.allowUnknownOption()
|
|
25
|
+
.on('--help', () => {
|
|
26
|
+
console.log('\nIn case you have any issues, please create a ticket here:');
|
|
27
|
+
console.log(chalk.cyan(process.env.npm_package_bugs_url));
|
|
28
|
+
})
|
|
29
|
+
.parse(process.argv);
|
|
30
|
+
|
|
31
|
+
const programOpts = program.opts();
|
|
32
|
+
|
|
33
|
+
if (programOpts.info) {
|
|
34
|
+
console.log(chalk.bold('\nEnvironment Info:'));
|
|
35
|
+
console.log(`\n current version of ${packageJson.name}: ${packageJson.version}`);
|
|
36
|
+
console.log(` running from ${__dirname}`);
|
|
37
|
+
|
|
38
|
+
envinfo
|
|
39
|
+
.run({
|
|
40
|
+
System : ['OS', 'CPU'],
|
|
41
|
+
Binaries : ['Node', 'npm', 'Yarn'],
|
|
42
|
+
Browsers : ['Chrome', 'Edge', 'Firefox', 'Safari'],
|
|
43
|
+
npmPackages: ['neo.mjs']
|
|
44
|
+
}, {
|
|
45
|
+
duplicates : true,
|
|
46
|
+
showNotFound: true
|
|
47
|
+
})
|
|
48
|
+
.then(console.log);
|
|
49
|
+
} else {
|
|
50
|
+
console.log(chalk.green(programName));
|
|
51
|
+
|
|
52
|
+
if (!programOpts.className) {
|
|
53
|
+
questions.push({
|
|
54
|
+
type : 'input',
|
|
55
|
+
name : 'className',
|
|
56
|
+
message: 'Please choose the namespace for your class:',
|
|
57
|
+
default: 'Covid.view.FooContainer'
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (!programOpts.baseClass) {
|
|
62
|
+
questions.push({
|
|
63
|
+
type : 'list',
|
|
64
|
+
name : 'baseClass',
|
|
65
|
+
message: 'Please pick the base class, which you want to extend:',
|
|
66
|
+
choices: ['component.Base', 'container.Base'],
|
|
67
|
+
default: 'component.Base'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
inquirer.prompt(questions).then(answers => {
|
|
72
|
+
let baseClass = programOpts.baseClass || answers.baseClass,
|
|
73
|
+
className = programOpts.className || answers.className,
|
|
74
|
+
startDate = new Date(),
|
|
75
|
+
classFolder, file, folderDelta, ns, root, rootLowerCase;
|
|
76
|
+
|
|
77
|
+
if (className.endsWith('.mjs')) {
|
|
78
|
+
className = className.slice(0, -4);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
ns = className.split('.');
|
|
82
|
+
file = ns.pop();
|
|
83
|
+
root = ns.shift();
|
|
84
|
+
rootLowerCase = root.toLowerCase();
|
|
85
|
+
|
|
86
|
+
if (root === 'Neo') {
|
|
87
|
+
console.log('todo: create the file inside the src folder');
|
|
88
|
+
} else {
|
|
89
|
+
if (fs.existsSync(path.resolve(cwd, 'apps', rootLowerCase))) {
|
|
90
|
+
classFolder = path.resolve(cwd, 'apps', rootLowerCase, ns.join('/'));
|
|
91
|
+
folderDelta = ns.length + 2;
|
|
92
|
+
|
|
93
|
+
fs.mkdirpSync(classFolder);
|
|
94
|
+
|
|
95
|
+
fs.writeFileSync(path.join(classFolder, file + '.mjs'), createContent({baseClass, className, file, folderDelta, ns, root}));
|
|
96
|
+
} else {
|
|
97
|
+
console.log('\nNon existing neo app name:', chalk.red(root));
|
|
98
|
+
process.exit(1);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const processTime = (Math.round((new Date - startDate) * 100) / 100000).toFixed(2);
|
|
103
|
+
console.log(`\nTotal time for ${programName}: ${processTime}s`);
|
|
104
|
+
|
|
105
|
+
process.exit();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Adds a comma to the last element of the contentArray
|
|
110
|
+
* @param {String[]} contentArray
|
|
111
|
+
*/
|
|
112
|
+
function addComma(contentArray) {
|
|
113
|
+
contentArray[contentArray.length - 1] += ',';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Creates the content of the neo-class .mjs file
|
|
118
|
+
* @param {Object} opts
|
|
119
|
+
* @param {String} opts.baseClass
|
|
120
|
+
* @param {String} opts.className
|
|
121
|
+
* @param {String} opts.file
|
|
122
|
+
* @param {String} opts.folderDelta
|
|
123
|
+
* @param {String} opts.ns
|
|
124
|
+
* @param {String} opts.root
|
|
125
|
+
* @returns {String}
|
|
126
|
+
*/
|
|
127
|
+
function createContent(opts) {
|
|
128
|
+
let baseClass = opts.baseClass,
|
|
129
|
+
baseClassNs = baseClass.split('.'),
|
|
130
|
+
baseFileName = baseClassNs.pop(),
|
|
131
|
+
className = opts.className,
|
|
132
|
+
file = opts.file,
|
|
133
|
+
i = 0,
|
|
134
|
+
importDelta = '';
|
|
135
|
+
|
|
136
|
+
for (; i < opts.folderDelta; i++) {
|
|
137
|
+
importDelta += '../';
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let classContent = [
|
|
141
|
+
`import ${baseFileName} from '${importDelta}${(insideNeo ? '' : 'node_modules/neo.mjs/')}src/${baseClassNs.join('/')}/${baseFileName}.mjs';`,
|
|
142
|
+
"",
|
|
143
|
+
"/**",
|
|
144
|
+
" * @class " + className,
|
|
145
|
+
" * @extends Neo." + baseClass,
|
|
146
|
+
" */",
|
|
147
|
+
`class ${file} extends ${baseFileName} {`,
|
|
148
|
+
" static getConfig() {return {",
|
|
149
|
+
" /*",
|
|
150
|
+
` * @member {String} className='${className}'`,
|
|
151
|
+
" * @protected",
|
|
152
|
+
" */",
|
|
153
|
+
` className: '${className}'`
|
|
154
|
+
];
|
|
155
|
+
|
|
156
|
+
if (baseClass === 'component.Base') {
|
|
157
|
+
addComma(classContent);
|
|
158
|
+
|
|
159
|
+
classContent.push(
|
|
160
|
+
" /*",
|
|
161
|
+
" * @member {Object} _vdom",
|
|
162
|
+
" */",
|
|
163
|
+
" _vdom:",
|
|
164
|
+
" {}",
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (baseClass === 'container.Base') {
|
|
169
|
+
addComma(classContent);
|
|
170
|
+
|
|
171
|
+
classContent.push(
|
|
172
|
+
" /*",
|
|
173
|
+
" * @member {Object[]} items",
|
|
174
|
+
" */",
|
|
175
|
+
" items: []",
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
classContent.push(
|
|
180
|
+
" }}",
|
|
181
|
+
"}",
|
|
182
|
+
"",
|
|
183
|
+
`Neo.applyClassConfig(${file});`,
|
|
184
|
+
"",
|
|
185
|
+
`export default ${file};`,
|
|
186
|
+
""
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
return classContent.join(os.EOL);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -16,7 +16,8 @@ const cwd = process.cwd(),
|
|
|
16
16
|
regexTrimEnd = /\s+$/gm,
|
|
17
17
|
regexTrimStart = /^\s+/gm;
|
|
18
18
|
|
|
19
|
-
let
|
|
19
|
+
let contextAdjusted = false,
|
|
20
|
+
config, examplesPath;
|
|
20
21
|
|
|
21
22
|
if (fs.existsSync(configPath)) {
|
|
22
23
|
config = requireJson(configPath);
|
|
@@ -134,8 +135,11 @@ export default env => {
|
|
|
134
135
|
|
|
135
136
|
plugins: [
|
|
136
137
|
new webpack.ContextReplacementPlugin(/.*/, context => {
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
let con = context.context;
|
|
139
|
+
|
|
140
|
+
if (!insideNeo && !contextAdjusted && (con.includes('/src/worker') || con.includes('\\src\\worker'))) {
|
|
141
|
+
context.request = path.join('../../', context.request);
|
|
142
|
+
contextAdjusted = true;
|
|
139
143
|
}
|
|
140
144
|
}),
|
|
141
145
|
...plugins
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neo.mjs",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.50",
|
|
4
4
|
"description": "The webworkers driven UI framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"build-themes": "node ./buildScripts/buildThemes.mjs -f",
|
|
15
15
|
"build-threads": "node ./buildScripts/webpack/buildThreads.mjs -f",
|
|
16
16
|
"create-app": "node ./buildScripts/createApp.mjs",
|
|
17
|
+
"create-class": "node ./buildScripts/createClass.mjs",
|
|
17
18
|
"generate-docs-json": "node ./buildScripts/docs/jsdocx.mjs",
|
|
18
19
|
"server-start": "webpack serve -c ./buildScripts/webpack/webpack.server.config.mjs --open",
|
|
19
20
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -42,11 +43,11 @@
|
|
|
42
43
|
"chalk": "^5.0.1",
|
|
43
44
|
"clean-webpack-plugin": "^4.0.0",
|
|
44
45
|
"commander": "^9.3.0",
|
|
45
|
-
"cssnano": "^5.1.
|
|
46
|
+
"cssnano": "^5.1.12",
|
|
46
47
|
"envinfo": "^7.8.1",
|
|
47
48
|
"fs-extra": "^10.1.0",
|
|
48
49
|
"highlightjs-line-numbers.js": "^2.8.0",
|
|
49
|
-
"inquirer": "^
|
|
50
|
+
"inquirer": "^9.0.0",
|
|
50
51
|
"neo-jsdoc": "^1.0.1",
|
|
51
52
|
"neo-jsdoc-x": "^1.0.4",
|
|
52
53
|
"postcss": "^8.4.14",
|
|
@@ -326,8 +326,9 @@ class DateSelector extends Component {
|
|
|
326
326
|
me.currentDate = new Date(`${value}T00:00:00`);
|
|
327
327
|
|
|
328
328
|
me.fire('change', {
|
|
329
|
-
|
|
330
|
-
|
|
329
|
+
component: me,
|
|
330
|
+
oldValue,
|
|
331
|
+
value
|
|
331
332
|
});
|
|
332
333
|
} else {
|
|
333
334
|
me.cacheUpdate();
|
|
@@ -325,8 +325,8 @@ class DragZone extends Base {
|
|
|
325
325
|
|
|
326
326
|
Object.assign(me, {
|
|
327
327
|
dragElementRect: rect,
|
|
328
|
-
offsetX
|
|
329
|
-
offsetY
|
|
328
|
+
offsetX,
|
|
329
|
+
offsetY
|
|
330
330
|
});
|
|
331
331
|
|
|
332
332
|
me.createDragProxy(rect);
|
|
@@ -337,8 +337,8 @@ class DragZone extends Base {
|
|
|
337
337
|
dragElementRect: rect,
|
|
338
338
|
eventData : data,
|
|
339
339
|
id : me.id,
|
|
340
|
-
offsetX
|
|
341
|
-
offsetY
|
|
340
|
+
offsetX,
|
|
341
|
+
offsetY
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
344
|
|
|
@@ -59,8 +59,8 @@ class NumberContainer extends Container {
|
|
|
59
59
|
if (oldValue !== undefined) {
|
|
60
60
|
this.fire('operatorChange', {
|
|
61
61
|
component: this,
|
|
62
|
-
oldValue
|
|
63
|
-
value
|
|
62
|
+
oldValue,
|
|
63
|
+
value
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -74,8 +74,8 @@ class NumberContainer extends Container {
|
|
|
74
74
|
if (oldValue !== undefined) {
|
|
75
75
|
this.fire('change', {
|
|
76
76
|
component: this,
|
|
77
|
-
oldValue
|
|
78
|
-
value
|
|
77
|
+
oldValue,
|
|
78
|
+
value
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
package/src/form/field/Base.mjs
CHANGED
|
@@ -36,10 +36,13 @@ class WebComponent extends Base {
|
|
|
36
36
|
customElements.define('element-loader', class extends HTMLElement {
|
|
37
37
|
async connectedCallback() {
|
|
38
38
|
let me = this,
|
|
39
|
-
content = await (await fetch(me.getAttribute('src'))).text()
|
|
39
|
+
content = await (await fetch(me.getAttribute('src'))).text(),
|
|
40
|
+
styles;
|
|
40
41
|
|
|
41
42
|
me.attachShadow({mode: 'open'}).innerHTML = content;
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
styles = me.querySelector('style');
|
|
45
|
+
styles && me.shadowRoot.append(styles);
|
|
43
46
|
}
|
|
44
47
|
});
|
|
45
48
|
}
|
|
@@ -140,7 +140,7 @@ class GalleryModel extends Model {
|
|
|
140
140
|
me.select(record[store.keyProperty]);
|
|
141
141
|
|
|
142
142
|
view.fire('select', {
|
|
143
|
-
record
|
|
143
|
+
record
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
|
|
@@ -190,7 +190,7 @@ class GalleryModel extends Model {
|
|
|
190
190
|
me.select(record[store.keyProperty]);
|
|
191
191
|
|
|
192
192
|
view.fire('select', {
|
|
193
|
-
record
|
|
193
|
+
record
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
196
|
|
|
@@ -154,7 +154,7 @@ class HelixModel extends Model {
|
|
|
154
154
|
me.select(record[store.keyProperty]);
|
|
155
155
|
|
|
156
156
|
view.fire('select', {
|
|
157
|
-
record
|
|
157
|
+
record
|
|
158
158
|
});
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -186,7 +186,7 @@ class HelixModel extends Model {
|
|
|
186
186
|
me.select(record[store.keyProperty]);
|
|
187
187
|
|
|
188
188
|
view.fire('select', {
|
|
189
|
-
record
|
|
189
|
+
record
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
|
|
@@ -259,7 +259,7 @@ class HelixModel extends Model {
|
|
|
259
259
|
view.mounted && Neo.currentWorker.promiseMessage('main', {
|
|
260
260
|
action : 'updateDom',
|
|
261
261
|
appName: view.appName,
|
|
262
|
-
deltas
|
|
262
|
+
deltas
|
|
263
263
|
}).then(() => {
|
|
264
264
|
view.onSelect?.(items);
|
|
265
265
|
me.fire('selectionChange', items, oldItems);
|