neo.mjs 4.0.65 → 4.0.68
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/sharedcovid/view/MainContainerController.mjs +2 -0
- package/buildScripts/createClass.mjs +52 -9
- package/package.json +2 -2
- package/src/Xhr.mjs +2 -1
- package/src/controller/Application.mjs +9 -0
- package/src/data/connection/Xhr.mjs +9 -0
- package/src/form/field/Select.mjs +29 -19
- package/src/main/addon/DragDrop.mjs +5 -3
- package/src/worker/App.mjs +9 -0
- package/src/worker/Manager.mjs +1 -0
@@ -36,6 +36,7 @@ program
|
|
36
36
|
.version(packageJson.version)
|
37
37
|
.option('-i, --info', 'print environment debug info')
|
38
38
|
.option('-d, --drop', 'drops class in the currently selected folder')
|
39
|
+
.option('-n, --singleton <value>', 'Create a singleton? Pick "yes" or "no"')
|
39
40
|
.option('-s, --source <value>', `name of the folder containing the project. Defaults to any of ${sourceRootDirs.join(',')}`)
|
40
41
|
.option('-b, --baseClass <value>')
|
41
42
|
.option('-c, --className <value>')
|
@@ -117,11 +118,23 @@ if (programOpts.info) {
|
|
117
118
|
});
|
118
119
|
}
|
119
120
|
|
121
|
+
if (!programOpts.singleton) {
|
122
|
+
questions.push({
|
123
|
+
type : 'list',
|
124
|
+
name : 'singleton',
|
125
|
+
message: 'Singleton?',
|
126
|
+
default: 'no',
|
127
|
+
choices: ['yes', 'no']
|
128
|
+
});
|
129
|
+
}
|
130
|
+
|
120
131
|
inquirer.prompt(questions).then(answers => {
|
121
|
-
let baseClass
|
122
|
-
className
|
123
|
-
|
124
|
-
|
132
|
+
let baseClass = programOpts.baseClass || answers.baseClass,
|
133
|
+
className = programOpts.className || answers.className,
|
134
|
+
singleton = programOpts.singleton || answers.singleton || 'no',
|
135
|
+
isDrop = programOpts.drop,
|
136
|
+
isSingleton = singleton === 'yes',
|
137
|
+
startDate = new Date(),
|
125
138
|
baseFileName, baseType, classFolder, configName, file, folderDelta, importName, importPath, index, ns, root, rootLowerCase, viewFile;
|
126
139
|
|
127
140
|
if (className.endsWith('.mjs')) {
|
@@ -214,12 +227,11 @@ if (programOpts.info) {
|
|
214
227
|
baseFileName = baseFileName.map(e => capitalize(e)).join('');
|
215
228
|
}
|
216
229
|
|
217
|
-
console.log(baseFileName, baseClass);
|
218
|
-
|
219
230
|
fs.writeFileSync(path.join(classFolder, file + '.mjs'), createContent({
|
220
231
|
baseClass,
|
221
232
|
baseFileName,
|
222
233
|
className,
|
234
|
+
isSingleton,
|
223
235
|
file,
|
224
236
|
folderDelta,
|
225
237
|
ns,
|
@@ -477,6 +489,7 @@ if (programOpts.info) {
|
|
477
489
|
* @param {String} opts.baseClass
|
478
490
|
* @param {String} opts.baseFileName
|
479
491
|
* @param {String} opts.className
|
492
|
+
* @param {Boolean} opts.isSingleton
|
480
493
|
* @param {String} opts.file
|
481
494
|
* @param {String} opts.folderDelta
|
482
495
|
* @param {String} opts.ns
|
@@ -488,6 +501,7 @@ if (programOpts.info) {
|
|
488
501
|
baseFileName = opts.baseFileName,
|
489
502
|
baseClassPath = baseClass.split('.').join('/'),
|
490
503
|
className = opts.className,
|
504
|
+
isSingleton = opts.isSingleton,
|
491
505
|
file = opts.file,
|
492
506
|
i = 0,
|
493
507
|
importDelta = '';
|
@@ -501,7 +515,14 @@ if (programOpts.info) {
|
|
501
515
|
"",
|
502
516
|
"/**",
|
503
517
|
` * @class ${className}`,
|
504
|
-
` * @extends Neo.${baseClass}
|
518
|
+
` * @extends Neo.${baseClass}`
|
519
|
+
];
|
520
|
+
|
521
|
+
isSingleton && classContent.push(
|
522
|
+
" * @singleton"
|
523
|
+
);
|
524
|
+
|
525
|
+
classContent.push(
|
505
526
|
" */",
|
506
527
|
`class ${file} extends ${baseFileName} {`,
|
507
528
|
" static getConfig() {return {",
|
@@ -510,7 +531,7 @@ if (programOpts.info) {
|
|
510
531
|
" * @protected",
|
511
532
|
" */",
|
512
533
|
` className: '${className}'`
|
513
|
-
|
534
|
+
);
|
514
535
|
|
515
536
|
baseClass === 'data.Model' && addComma(classContent).push(
|
516
537
|
" /*",
|
@@ -529,6 +550,14 @@ if (programOpts.info) {
|
|
529
550
|
" items: []"
|
530
551
|
);
|
531
552
|
|
553
|
+
isSingleton && addComma(classContent).push(
|
554
|
+
" /*",
|
555
|
+
" * @member {Boolean} singleton=true",
|
556
|
+
" * @protected",
|
557
|
+
" */",
|
558
|
+
" singleton: true"
|
559
|
+
);
|
560
|
+
|
532
561
|
baseClass === 'component.Base' && addComma(classContent).push(
|
533
562
|
" /*",
|
534
563
|
" * @member {Object} _vdom",
|
@@ -542,8 +571,22 @@ if (programOpts.info) {
|
|
542
571
|
"}",
|
543
572
|
"",
|
544
573
|
`Neo.applyClassConfig(${file});`,
|
574
|
+
""
|
575
|
+
);
|
576
|
+
|
577
|
+
isSingleton && classContent.push(
|
578
|
+
`let instance = Neo.create(${file});`,
|
545
579
|
"",
|
546
|
-
|
580
|
+
"Neo.applyToGlobalNs(instance);",
|
581
|
+
"",
|
582
|
+
"export default instance;"
|
583
|
+
);
|
584
|
+
|
585
|
+
!isSingleton && classContent.push(
|
586
|
+
`export default ${file};`
|
587
|
+
);
|
588
|
+
|
589
|
+
classContent.push(
|
547
590
|
""
|
548
591
|
);
|
549
592
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "neo.mjs",
|
3
|
-
"version": "4.0.
|
3
|
+
"version": "4.0.68",
|
4
4
|
"description": "The webworkers driven UI framework",
|
5
5
|
"type": "module",
|
6
6
|
"repository": {
|
@@ -62,7 +62,7 @@
|
|
62
62
|
"webpack-node-externals": "^3.0.0"
|
63
63
|
},
|
64
64
|
"devDependencies": {
|
65
|
-
"siesta-lite": "
|
65
|
+
"siesta-lite": "5.5.2",
|
66
66
|
"url": "^0.11.0"
|
67
67
|
},
|
68
68
|
"funding": {
|
package/src/Xhr.mjs
CHANGED
@@ -99,6 +99,15 @@ class Application extends Base {
|
|
99
99
|
|
100
100
|
return null;
|
101
101
|
}
|
102
|
+
|
103
|
+
/**
|
104
|
+
* Unregister the app from the CSS map
|
105
|
+
* @param args
|
106
|
+
*/
|
107
|
+
destroy(...args) {
|
108
|
+
Neo.currentWorker.removeAppFromThemeMap(this.name);
|
109
|
+
super.destroy(...args);
|
110
|
+
}
|
102
111
|
}
|
103
112
|
|
104
113
|
Neo.applyClassConfig(Application);
|
@@ -217,6 +217,15 @@ class Xhr extends Base {
|
|
217
217
|
|
218
218
|
return this.request(opts);
|
219
219
|
}
|
220
|
+
|
221
|
+
/**
|
222
|
+
* Needed for remote method access
|
223
|
+
*
|
224
|
+
* @param {Object} value
|
225
|
+
*/
|
226
|
+
setDefaultHeaders(value) {
|
227
|
+
this.defaultHeaders = value;
|
228
|
+
}
|
220
229
|
}
|
221
230
|
|
222
231
|
Neo.applyClassConfig(Xhr);
|
@@ -463,24 +463,8 @@ class Select extends Picker {
|
|
463
463
|
* @protected
|
464
464
|
*/
|
465
465
|
onListItemClick(record) {
|
466
|
-
|
467
|
-
|
468
|
-
oldValue = me.value,
|
469
|
-
value = record[displayField];
|
470
|
-
|
471
|
-
if (me.value !== value) {
|
472
|
-
me.hintRecordId = null;
|
473
|
-
me.record = record;
|
474
|
-
me._value = value;
|
475
|
-
me.getInputHintEl().value = null;
|
476
|
-
|
477
|
-
me.afterSetValue(value, oldValue, true); // prevent the list from getting filtered
|
478
|
-
|
479
|
-
me.fire('select', {
|
480
|
-
record,
|
481
|
-
value: record[displayField]
|
482
|
-
});
|
483
|
-
}
|
466
|
+
this.onListItemChange(record);
|
467
|
+
this.hidePicker();
|
484
468
|
}
|
485
469
|
|
486
470
|
/**
|
@@ -518,12 +502,38 @@ class Select extends Picker {
|
|
518
502
|
this.focusInputEl();
|
519
503
|
}
|
520
504
|
|
505
|
+
|
506
|
+
/**
|
507
|
+
* @param {Object} record
|
508
|
+
* @protected
|
509
|
+
*/
|
510
|
+
onListItemChange(record) {
|
511
|
+
let me = this,
|
512
|
+
displayField = me.displayField,
|
513
|
+
oldValue = me.value,
|
514
|
+
value = record[displayField];
|
515
|
+
|
516
|
+
if (me.value !== value) {
|
517
|
+
me.hintRecordId = null;
|
518
|
+
me.record = record;
|
519
|
+
me._value = value;
|
520
|
+
me.getInputHintEl().value = null;
|
521
|
+
|
522
|
+
me.afterSetValue(value, oldValue, true); // prevent the list from getting filtered
|
523
|
+
|
524
|
+
me.fire('select', {
|
525
|
+
record,
|
526
|
+
value: record[displayField]
|
527
|
+
});
|
528
|
+
}
|
529
|
+
}
|
530
|
+
|
521
531
|
/**
|
522
532
|
* @param {Object} record
|
523
533
|
* @protected
|
524
534
|
*/
|
525
535
|
onListItemNavigate(record) {
|
526
|
-
this.
|
536
|
+
this.onListItemChange(record);
|
527
537
|
}
|
528
538
|
|
529
539
|
/**
|
@@ -149,14 +149,16 @@ class DragDrop extends Base {
|
|
149
149
|
|
150
150
|
me.addGlobalEventListeners();
|
151
151
|
|
152
|
+
if (Neo.config.hasMouseEvents) {
|
153
|
+
imports.push(import('../draggable/sensor/Mouse.mjs'));
|
154
|
+
}
|
155
|
+
|
152
156
|
if (Neo.config.hasTouchEvents) {
|
153
157
|
imports.push(import('../draggable/sensor/Touch.mjs'));
|
154
|
-
} else {
|
155
|
-
imports.push(import('../draggable/sensor/Mouse.mjs'));
|
156
158
|
}
|
157
159
|
|
158
160
|
Promise.all(imports).then(modules => {
|
159
|
-
// create the
|
161
|
+
// create the Mouse- and / or TouchSensor
|
160
162
|
Neo.create({
|
161
163
|
module: modules[0].default
|
162
164
|
});
|
package/src/worker/App.mjs
CHANGED
@@ -270,6 +270,15 @@ class App extends Base {
|
|
270
270
|
});
|
271
271
|
}
|
272
272
|
|
273
|
+
/**
|
274
|
+
* Unregister the app from the CSS map
|
275
|
+
* Only needed for SharedWorkers
|
276
|
+
* @param {String} appName
|
277
|
+
*/
|
278
|
+
removeAppFromThemeMap(appName) {
|
279
|
+
delete Neo.cssMap[appName.toLowerCase()];
|
280
|
+
}
|
281
|
+
|
273
282
|
/**
|
274
283
|
* @private
|
275
284
|
*/
|
package/src/worker/Manager.mjs
CHANGED
@@ -204,6 +204,7 @@ class Manager extends Base {
|
|
204
204
|
detectFeatures() {
|
205
205
|
let me = this;
|
206
206
|
|
207
|
+
NeoConfig.hasMouseEvents = matchMedia('(pointer:fine)').matches;
|
207
208
|
NeoConfig.hasTouchEvents = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0);
|
208
209
|
|
209
210
|
if (window.Worker) {
|