neo.mjs 4.0.72 → 4.0.75
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 +114 -78
- package/examples/component/carousel/MainContainer.mjs +54 -0
- package/examples/component/carousel/app.mjs +6 -0
- package/examples/component/carousel/index.html +11 -0
- package/examples/component/carousel/neo-config.json +6 -0
- package/package.json +1 -1
- package/src/DefaultConfig.mjs +8 -0
- package/src/collection/Base.mjs +2 -2
- package/src/component/Carousel.mjs +25 -22
- package/src/controller/Base.mjs +11 -0
- package/src/util/HashHistory.mjs +2 -7
- package/src/worker/Base.mjs +1 -4
- package/src/worker/Manager.mjs +1 -1
- package/src/worker/mixin/RemoteMethodAccess.mjs +0 -8
- package/test/siesta/tests/CollectionBase.mjs +24 -0
@@ -143,7 +143,7 @@ if (programOpts.info) {
|
|
143
143
|
isDrop = programOpts.drop,
|
144
144
|
isSingleton = singleton === 'yes',
|
145
145
|
startDate = new Date(),
|
146
|
-
|
146
|
+
baseType, classFolder, configName, file, folderDelta, importName, importPath, index, ns, root, rootLowerCase, viewFile;
|
147
147
|
|
148
148
|
if (className.endsWith('.mjs')) {
|
149
149
|
className = className.slice(0, -4);
|
@@ -162,8 +162,8 @@ if (programOpts.info) {
|
|
162
162
|
if (isDrop === true) {
|
163
163
|
ns = [];
|
164
164
|
|
165
|
-
let pathInfo
|
166
|
-
sep
|
165
|
+
let pathInfo = path.parse(cwd),
|
166
|
+
sep = path.sep,
|
167
167
|
baseName, loc = baseName = '',
|
168
168
|
tmpNs;
|
169
169
|
|
@@ -226,89 +226,18 @@ if (programOpts.info) {
|
|
226
226
|
folderDelta = ns.length + 2;
|
227
227
|
}
|
228
228
|
|
229
|
-
|
230
|
-
|
231
|
-
baseFileName = baseClass.split('.').pop();
|
232
|
-
|
233
|
-
if (baseFileName === file) {
|
234
|
-
baseFileName = baseClass.split('.');
|
235
|
-
baseFileName = baseFileName.map(e => capitalize(e)).join('');
|
236
|
-
}
|
237
|
-
|
238
|
-
fs.writeFileSync(path.join(classFolder, file + '.mjs'), createContent({
|
229
|
+
createClass({
|
239
230
|
baseClass,
|
240
|
-
baseFileName,
|
241
231
|
className,
|
242
232
|
isSingleton,
|
243
233
|
file,
|
244
234
|
folderDelta,
|
245
235
|
ns,
|
246
236
|
root
|
247
|
-
})
|
248
|
-
|
249
|
-
switch(baseClass) {
|
250
|
-
case 'controller.Component': {
|
251
|
-
baseType = 'Neo.controller.Component';
|
252
|
-
configName = 'controller';
|
253
|
-
importName = file;
|
254
|
-
importPath = `./${importName}.mjs`;
|
255
|
-
index = file.indexOf('Controller');
|
256
|
-
|
257
|
-
if (index > 0) {
|
258
|
-
viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
|
259
|
-
|
260
|
-
if (fs.existsSync(viewFile)) {
|
261
|
-
adjustView({baseType, configName, importName, importPath, viewFile});
|
262
|
-
}
|
263
|
-
}
|
264
|
-
break;
|
265
|
-
}
|
266
|
-
|
267
|
-
case 'data.Store': {
|
268
|
-
baseType = 'Neo.data.Model';
|
269
|
-
configName = 'model';
|
270
|
-
importName = className.replace('.store.', '.model.');
|
271
|
-
|
272
|
-
if (importName.endsWith('ies')) {
|
273
|
-
importName.replace(new RegExp('ies$'), 'y')
|
274
|
-
} else {
|
275
|
-
importName = importName.slice(0, -1);
|
276
|
-
}
|
277
|
-
|
278
|
-
viewFile = importName.split('.');
|
279
|
-
viewFile.shift();
|
280
|
-
|
281
|
-
importPath = `../${viewFile.join('/')}.mjs`;
|
282
|
-
viewFile = path.join(classFolder, importPath);
|
283
|
-
|
284
|
-
// checking for the data.Model file
|
285
|
-
if (fs.existsSync(viewFile)) {
|
286
|
-
// adjusting the data.Store file
|
287
|
-
viewFile = path.join(classFolder, file + '.mjs');
|
288
|
-
importName = importName.split('.');
|
289
|
-
importName = importName.pop();
|
290
|
-
|
291
|
-
adjustView({baseType, configName, importName, importPath, viewFile});
|
292
|
-
}
|
293
|
-
break;
|
294
|
-
}
|
295
|
-
|
296
|
-
case 'model.Component': {
|
297
|
-
baseType = 'Neo.model.Component';
|
298
|
-
configName = 'model';
|
299
|
-
importName = file;
|
300
|
-
importPath = `./${importName}.mjs`;
|
301
|
-
index = file.indexOf('Model');
|
302
|
-
|
303
|
-
if (index > 0) {
|
304
|
-
viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
|
237
|
+
});
|
305
238
|
|
306
|
-
|
307
|
-
|
308
|
-
}
|
309
|
-
}
|
310
|
-
break;
|
311
|
-
}
|
239
|
+
if (baseClass === 'data.Model') {
|
240
|
+
// todo: add a question for auto-generating a matching store
|
312
241
|
}
|
313
242
|
}
|
314
243
|
|
@@ -490,6 +419,113 @@ if (programOpts.info) {
|
|
490
419
|
return typeof value === 'string' && value[0].toUpperCase() + value.slice(1);
|
491
420
|
}
|
492
421
|
|
422
|
+
/**
|
423
|
+
* @param {Object} opts
|
424
|
+
* @param {String} opts.baseClass
|
425
|
+
* @param {String} opts.className
|
426
|
+
* @param {Boolean} opts.isSingleton
|
427
|
+
* @param {String} opts.file
|
428
|
+
* @param {Number} opts.folderDelta
|
429
|
+
* @param {String[]} opts.ns
|
430
|
+
* @param {String} opts.root
|
431
|
+
*/
|
432
|
+
function createClass(opts) {
|
433
|
+
let {
|
434
|
+
baseClass,
|
435
|
+
className,
|
436
|
+
isSingleton,
|
437
|
+
file,
|
438
|
+
folderDelta,
|
439
|
+
ns,
|
440
|
+
root
|
441
|
+
} = opts, baseFileName;
|
442
|
+
|
443
|
+
fs.mkdirpSync(classFolder);
|
444
|
+
|
445
|
+
baseFileName = baseClass.split('.').pop();
|
446
|
+
|
447
|
+
if (baseFileName === file) {
|
448
|
+
baseFileName = baseClass.split('.');
|
449
|
+
baseFileName = baseFileName.map(e => capitalize(e)).join('');
|
450
|
+
}
|
451
|
+
|
452
|
+
fs.writeFileSync(path.join(classFolder, file + '.mjs'), createContent({
|
453
|
+
baseClass,
|
454
|
+
baseFileName,
|
455
|
+
className,
|
456
|
+
isSingleton,
|
457
|
+
file,
|
458
|
+
folderDelta,
|
459
|
+
ns,
|
460
|
+
root
|
461
|
+
}));
|
462
|
+
|
463
|
+
switch(baseClass) {
|
464
|
+
case 'controller.Component': {
|
465
|
+
baseType = 'Neo.controller.Component';
|
466
|
+
configName = 'controller';
|
467
|
+
importName = file;
|
468
|
+
importPath = `./${importName}.mjs`;
|
469
|
+
index = file.indexOf('Controller');
|
470
|
+
|
471
|
+
if (index > 0) {
|
472
|
+
viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
|
473
|
+
|
474
|
+
if (fs.existsSync(viewFile)) {
|
475
|
+
adjustView({baseType, configName, importName, importPath, viewFile});
|
476
|
+
}
|
477
|
+
}
|
478
|
+
break;
|
479
|
+
}
|
480
|
+
|
481
|
+
case 'data.Store': {
|
482
|
+
baseType = 'Neo.data.Model';
|
483
|
+
configName = 'model';
|
484
|
+
importName = className.replace('.store.', '.model.');
|
485
|
+
|
486
|
+
if (importName.endsWith('ies')) {
|
487
|
+
importName.replace(new RegExp('ies$'), 'y')
|
488
|
+
} else {
|
489
|
+
importName = importName.slice(0, -1);
|
490
|
+
}
|
491
|
+
|
492
|
+
viewFile = importName.split('.');
|
493
|
+
viewFile.shift();
|
494
|
+
|
495
|
+
importPath = `../${viewFile.join('/')}.mjs`;
|
496
|
+
viewFile = path.join(classFolder, importPath);
|
497
|
+
|
498
|
+
// checking for the data.Model file
|
499
|
+
if (fs.existsSync(viewFile)) {
|
500
|
+
// adjusting the data.Store file
|
501
|
+
viewFile = path.join(classFolder, file + '.mjs');
|
502
|
+
importName = importName.split('.');
|
503
|
+
importName = importName.pop();
|
504
|
+
|
505
|
+
adjustView({baseType, configName, importName, importPath, viewFile});
|
506
|
+
}
|
507
|
+
break;
|
508
|
+
}
|
509
|
+
|
510
|
+
case 'model.Component': {
|
511
|
+
baseType = 'Neo.model.Component';
|
512
|
+
configName = 'model';
|
513
|
+
importName = file;
|
514
|
+
importPath = `./${importName}.mjs`;
|
515
|
+
index = file.indexOf('Model');
|
516
|
+
|
517
|
+
if (index > 0) {
|
518
|
+
viewFile = path.join(classFolder, file.substr(0, index) + '.mjs');
|
519
|
+
|
520
|
+
if (fs.existsSync(viewFile)) {
|
521
|
+
adjustView({baseType, configName, importName, importPath, viewFile});
|
522
|
+
}
|
523
|
+
}
|
524
|
+
break;
|
525
|
+
}
|
526
|
+
}
|
527
|
+
}
|
528
|
+
|
493
529
|
/**
|
494
530
|
* Creates the content of the neo-class .mjs file
|
495
531
|
* @param {Object} opts
|
@@ -0,0 +1,54 @@
|
|
1
|
+
import CheckBox from '../../../src/form/field/CheckBox.mjs';
|
2
|
+
import Carousel from '../../../src/component/Carousel.mjs';
|
3
|
+
import ConfigurationViewport from '../../ConfigurationViewport.mjs';
|
4
|
+
import RangeField from '../../../src/form/field/Range.mjs';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @class Neo.examples.component.carousel.MainContainer
|
8
|
+
* @extends Neo.examples.ConfigurationViewport
|
9
|
+
*/
|
10
|
+
class MainContainer extends ConfigurationViewport {
|
11
|
+
static getConfig() {return {
|
12
|
+
className: 'Neo.examples.component.carousel.MainContainer',
|
13
|
+
autoMount: true,
|
14
|
+
layout : {ntype: 'hbox', align: 'stretch'}
|
15
|
+
}}
|
16
|
+
|
17
|
+
createConfigurationComponents() {
|
18
|
+
let me = this;
|
19
|
+
|
20
|
+
return [{
|
21
|
+
module : CheckBox,
|
22
|
+
checked : me.exampleComponent.autoRun,
|
23
|
+
labelText: 'autoRun',
|
24
|
+
listeners: {change: me.onConfigChange.bind(me, 'autoRun')}
|
25
|
+
}, {
|
26
|
+
module : RangeField,
|
27
|
+
labelText : 'height',
|
28
|
+
listeners : {change: me.onConfigChange.bind(me, 'height')},
|
29
|
+
maxValue : 800,
|
30
|
+
minValue : 200,
|
31
|
+
stepSize : 1,
|
32
|
+
value : me.exampleComponent.height
|
33
|
+
}, {
|
34
|
+
module : RangeField,
|
35
|
+
labelText : 'width',
|
36
|
+
listeners : {change: me.onConfigChange.bind(me, 'width')},
|
37
|
+
maxValue : 800,
|
38
|
+
minValue : 200,
|
39
|
+
stepSize : 1,
|
40
|
+
value : me.exampleComponent.width
|
41
|
+
}];
|
42
|
+
}
|
43
|
+
|
44
|
+
createExampleComponent() {
|
45
|
+
return Neo.create(Carousel, {
|
46
|
+
height: 500,
|
47
|
+
width : 500
|
48
|
+
});
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
Neo.applyClassConfig(MainContainer);
|
53
|
+
|
54
|
+
export default MainContainer;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!DOCTYPE HTML>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
<title>Neo Carousel</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<script src="../../../src/MicroLoader.mjs" type="module"></script>
|
10
|
+
</body>
|
11
|
+
</html>
|
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -78,6 +78,14 @@ const DefaultConfig = {
|
|
78
78
|
* @type Boolean
|
79
79
|
*/
|
80
80
|
isInsideSiesta: false,
|
81
|
+
/**
|
82
|
+
* delay in ms for the worker.Manager:loadApplication() call
|
83
|
+
* @default 20
|
84
|
+
* @memberOf! module:Neo
|
85
|
+
* @name config.loadApplicationDelay
|
86
|
+
* @type Number
|
87
|
+
*/
|
88
|
+
loadApplicationDelay: 20,
|
81
89
|
/**
|
82
90
|
* Used by Intl.DateTimeFormat, for details take a look at:
|
83
91
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
|
package/src/collection/Base.mjs
CHANGED
@@ -1099,8 +1099,8 @@ class Base extends CoreBase {
|
|
1099
1099
|
* If the toRemoveArray is used, then the index is not used for removing, the entries are found by key and removed from where they are.
|
1100
1100
|
* If index is not passed, toAddArray is appended to the Collection.
|
1101
1101
|
* @param {Number|null} index
|
1102
|
-
* @param {Number|
|
1103
|
-
* @param {
|
1102
|
+
* @param {Number|Object[]} [removeCountOrToRemoveArray]
|
1103
|
+
* @param {Object|Object[]} [toAddArray]
|
1104
1104
|
* @returns {Object} An object containing the addedItems & removedItems arrays
|
1105
1105
|
*/
|
1106
1106
|
splice(index, removeCountOrToRemoveArray, toAddArray) {
|
@@ -3,7 +3,6 @@ import Component from './Base.mjs';
|
|
3
3
|
import Store from '../data/Store.mjs';
|
4
4
|
import TaskManager from '../manager/Task.mjs';
|
5
5
|
|
6
|
-
|
7
6
|
/**
|
8
7
|
* @class Neo.component.Carousel
|
9
8
|
* @extends Neo.component.Base
|
@@ -107,26 +106,27 @@ class Carousel extends Component {
|
|
107
106
|
|
108
107
|
/**
|
109
108
|
* Triggered after autoRun config got changed
|
110
|
-
* @param {
|
109
|
+
* @param {Boolean|Number} value
|
110
|
+
* @param {Boolean|Number} oldValue
|
111
111
|
* @protected
|
112
112
|
*/
|
113
113
|
afterSetAutoRun(value, oldValue) {
|
114
|
-
|
114
|
+
if (value) {
|
115
|
+
let me = this,
|
116
|
+
vdom = me._vdom;
|
115
117
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
}
|
124
|
-
});
|
118
|
+
TaskManager.start({
|
119
|
+
id : me.id,
|
120
|
+
interval: value,
|
121
|
+
run : function () {
|
122
|
+
me.onCarouselBtnClick('forward');
|
123
|
+
}
|
124
|
+
});
|
125
125
|
|
126
|
-
|
127
|
-
vdom.cn[0].cn[0].removeDom = true;
|
126
|
+
vdom.cn[0].cn[0].removeDom = true;
|
128
127
|
|
129
|
-
|
128
|
+
me._vdom = vdom;
|
129
|
+
}
|
130
130
|
}
|
131
131
|
|
132
132
|
/**
|
@@ -148,18 +148,21 @@ class Carousel extends Component {
|
|
148
148
|
|
149
149
|
/**
|
150
150
|
* Ensure the itemTpl is setup correctly to match a valid JSON
|
151
|
-
* @param {String} value
|
151
|
+
* @param {String|null} value
|
152
|
+
* @param {String|null} oldValue
|
152
153
|
* @returns {String}
|
153
154
|
* @protected
|
154
155
|
*/
|
155
|
-
beforeSetItemTpl(value) {
|
156
|
-
|
156
|
+
beforeSetItemTpl(value, oldValue) {
|
157
|
+
if (value) {
|
158
|
+
value = value.replaceAll('\'', '"');
|
157
159
|
|
158
|
-
|
159
|
-
|
160
|
-
|
160
|
+
value = value.replace(/(\w+:)|(\w+ :)/g, function(matchedStr) {
|
161
|
+
return `"${matchedStr.substring(0, matchedStr.length - 1)}":`;
|
162
|
+
});
|
163
|
+
}
|
161
164
|
|
162
|
-
return
|
165
|
+
return value;
|
163
166
|
}
|
164
167
|
|
165
168
|
/**
|
package/src/controller/Base.mjs
CHANGED
@@ -53,6 +53,17 @@ class Base extends CoreBase {
|
|
53
53
|
onHashChange(value, oldValue) {
|
54
54
|
|
55
55
|
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
*
|
59
|
+
*/
|
60
|
+
onConstructed() {
|
61
|
+
let currentHash = HashHistory.first();
|
62
|
+
|
63
|
+
currentHash && this.onHashChange(currentHash, null);
|
64
|
+
|
65
|
+
super.onConstructed();
|
66
|
+
}
|
56
67
|
}
|
57
68
|
|
58
69
|
Neo.applyClassConfig(Base);
|
package/src/util/HashHistory.mjs
CHANGED
@@ -22,11 +22,6 @@ class HashHistory extends Base {
|
|
22
22
|
* @protected
|
23
23
|
*/
|
24
24
|
className: 'Neo.util.HashHistory',
|
25
|
-
/**
|
26
|
-
* @member {String} ntype='hash-history'
|
27
|
-
* @protected
|
28
|
-
*/
|
29
|
-
ntype: 'hash-history',
|
30
25
|
/**
|
31
26
|
* @member {Boolean} singleton=true
|
32
27
|
* @protected
|
@@ -71,10 +66,10 @@ class HashHistory extends Base {
|
|
71
66
|
stack.unshift(data);
|
72
67
|
|
73
68
|
if (stack.length > me.maxItems) {
|
74
|
-
stack.
|
69
|
+
stack.pop();
|
75
70
|
}
|
76
71
|
|
77
|
-
me.fire('change', data, stack[1]);
|
72
|
+
me.fire('change', data, stack[1] || null);
|
78
73
|
}
|
79
74
|
}
|
80
75
|
|
package/src/worker/Base.mjs
CHANGED
package/src/worker/Manager.mjs
CHANGED
@@ -252,7 +252,7 @@ class Manager extends Base {
|
|
252
252
|
if (me.constructedThreads === me.activeWorkers) {
|
253
253
|
NeoConfig.appPath && setTimeout(() => { // better save than sorry => all remotes need to be registered
|
254
254
|
me.loadApplication(NeoConfig.appPath);
|
255
|
-
},
|
255
|
+
}, NeoConfig.loadApplicationDelay);
|
256
256
|
}
|
257
257
|
}
|
258
258
|
|
@@ -52,7 +52,6 @@ class RemoteMethodAccess extends Base {
|
|
52
52
|
if (remote.destination === Neo.workerId) {
|
53
53
|
let me = this,
|
54
54
|
className = remote.className,
|
55
|
-
exists = false,
|
56
55
|
methods = remote.methods,
|
57
56
|
pkg = Neo.ns(className, true);
|
58
57
|
|
@@ -63,15 +62,8 @@ class RemoteMethodAccess extends Base {
|
|
63
62
|
|
64
63
|
if (!pkg[method] ) {
|
65
64
|
pkg[method] = me.generateRemote(remote, method);
|
66
|
-
} else {
|
67
|
-
exists = true;
|
68
65
|
}
|
69
66
|
});
|
70
|
-
|
71
|
-
// todo: inspect if this can get removed
|
72
|
-
if (!exists && Neo.workerId !== 'main') {
|
73
|
-
me.fire('remoteregistered', remote);
|
74
|
-
}
|
75
67
|
}
|
76
68
|
}
|
77
69
|
|
@@ -251,4 +251,28 @@ StartTest(t => {
|
|
251
251
|
t.isStrict(collection3.getCount(), 5, 'collection3 count is 5');
|
252
252
|
t.isStrict(collection3.allItems.getCount(), 9, 'collection3 allItems count is 9');
|
253
253
|
});
|
254
|
+
|
255
|
+
t.it('Add & remove at same time', t => {
|
256
|
+
collection = Neo.create(Collection, {
|
257
|
+
items: [
|
258
|
+
{id: 'a'},
|
259
|
+
{id: 'b'},
|
260
|
+
{id: 'c'},
|
261
|
+
{id: 'd'},
|
262
|
+
{id: 'e'},
|
263
|
+
{id: 'f'}
|
264
|
+
]
|
265
|
+
});
|
266
|
+
|
267
|
+
collection.splice(2, [{id: 'a'}, {id: 'd'}, {id: 'f'}], [{id: 'x'}, {id: 'y'}, {id: 'z'}]);
|
268
|
+
|
269
|
+
t.isDeeplyStrict(collection.getRange(), [
|
270
|
+
{id: 'b'},
|
271
|
+
{id: 'c'},
|
272
|
+
{id: 'x'},
|
273
|
+
{id: 'y'},
|
274
|
+
{id: 'z'},
|
275
|
+
{id: 'e'}
|
276
|
+
], 'collection.getRange()');
|
277
|
+
});
|
254
278
|
});
|