neo.mjs 5.10.9 → 5.10.11

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='5.10.9'
23
+ * @member {String} version='5.10.11'
24
24
  */
25
- version: '5.10.9'
25
+ version: '5.10.11'
26
26
  }
27
27
 
28
28
  /**
@@ -20,7 +20,6 @@ class MainContainerController extends Component {
20
20
  }
21
21
 
22
22
  /**
23
- *
24
23
  * @param {Object} record
25
24
  */
26
25
  onApiListLeafClick(record) {
@@ -36,11 +35,10 @@ class MainContainerController extends Component {
36
35
  iconCls: record.singleton ? 'fa fa-arrow-alt-circle-right' : 'fa fa-copyright',
37
36
  text : record.name
38
37
  }
39
- });
38
+ })
40
39
  }
41
40
 
42
41
  /**
43
- *
44
42
  * @param {Object} record
45
43
  */
46
44
  onExamplesListLeafClick(record) {
@@ -72,7 +70,7 @@ class MainContainerController extends Component {
72
70
  module: module.default,
73
71
  id : name,
74
72
  tabButtonConfig
75
- });
73
+ })
76
74
  }
77
75
  );
78
76
  } else {
@@ -95,13 +93,12 @@ class MainContainerController extends Component {
95
93
  items,
96
94
  style: {padding: '10px'},
97
95
  tabButtonConfig
98
- });
96
+ })
99
97
  })
100
98
  }
101
99
  }
102
100
 
103
101
  /**
104
- *
105
102
  * @param {Object} value
106
103
  * @param {Object} oldValue
107
104
  */
@@ -135,7 +132,6 @@ class MainContainerController extends Component {
135
132
  }
136
133
 
137
134
  /**
138
- *
139
135
  * @param {Object} data
140
136
  */
141
137
  onNavigationSearchFieldChange(data) {
@@ -169,7 +165,7 @@ class MainContainerController extends Component {
169
165
  id : 'hljs-theme'
170
166
  }).then(data => {
171
167
  button.text = buttonText;
172
- });
168
+ })
173
169
  }
174
170
 
175
171
  /**
@@ -206,7 +202,6 @@ class MainContainerController extends Component {
206
202
  }
207
203
 
208
204
  /**
209
- *
210
205
  * @param {Object} record
211
206
  */
212
207
  onTutorialListLeafClick(record) {
@@ -223,7 +218,7 @@ class MainContainerController extends Component {
223
218
  iconCls: 'fa fa-hands-helping',
224
219
  text : record.name
225
220
  }
226
- });
221
+ })
227
222
  }
228
223
  }
229
224
 
@@ -87,14 +87,14 @@ class MainContainer extends Container {
87
87
  iconCls : 'fa fa-check-square',
88
88
  reference: 'showPrivateMembers',
89
89
  style : {marginRight: '5px'},
90
- text : 'Private',
90
+ text : 'Private'
91
91
  }, {
92
92
  checked : true,
93
93
  handler : 'onToggleMembers',
94
94
  iconCls : 'fa fa-check-square',
95
95
  reference: 'showProtectedMembers',
96
96
  style : {marginRight: '5px'},
97
- text : 'Protected',
97
+ text : 'Protected'
98
98
  }, {
99
99
  checked : true,
100
100
  handler : 'onToggleMembers',
@@ -20,9 +20,9 @@ class ServiceWorker extends ServiceBase {
20
20
  */
21
21
  singleton: true,
22
22
  /**
23
- * @member {String} version='5.10.9'
23
+ * @member {String} version='5.10.11'
24
24
  */
25
- version: '5.10.9'
25
+ version: '5.10.11'
26
26
  }
27
27
 
28
28
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "5.10.9",
3
+ "version": "5.10.11",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -49,15 +49,15 @@
49
49
  "clean-webpack-plugin": "^4.0.0",
50
50
  "commander": "^11.0.0",
51
51
  "cssnano": "^6.0.1",
52
- "envinfo": "^7.8.1",
52
+ "envinfo": "^7.10.0",
53
53
  "fs-extra": "^11.1.1",
54
54
  "highlightjs-line-numbers.js": "^2.8.0",
55
55
  "inquirer": "^9.2.7",
56
56
  "neo-jsdoc": "^1.0.1",
57
57
  "neo-jsdoc-x": "^1.0.5",
58
58
  "postcss": "^8.4.24",
59
- "sass": "^1.63.4",
60
- "webpack": "^5.87.0",
59
+ "sass": "^1.63.6",
60
+ "webpack": "^5.88.0",
61
61
  "webpack-cli": "^5.1.4",
62
62
  "webpack-dev-server": "4.15.1",
63
63
  "webpack-hook-plugin": "^1.0.7",
@@ -236,12 +236,12 @@ const DefaultConfig = {
236
236
  useVdomWorker: true,
237
237
  /**
238
238
  * buildScripts/injectPackageVersion.mjs will update this value
239
- * @default '5.10.9'
239
+ * @default '5.10.11'
240
240
  * @memberOf! module:Neo
241
241
  * @name config.version
242
242
  * @type String
243
243
  */
244
- version: '5.10.9'
244
+ version: '5.10.11'
245
245
  };
246
246
 
247
247
  Object.assign(DefaultConfig, {
package/src/core/Base.mjs CHANGED
@@ -27,7 +27,6 @@ class Base {
27
27
  * @type {Object}
28
28
  */
29
29
  static overwrittenMethods = {}
30
-
31
30
  /**
32
31
  * Set this one to false in case you don't want to stick
33
32
  * to the "anti-pattern" to apply classes to the global Neo or App namespace
@@ -36,7 +35,6 @@ class Base {
36
35
  * @static
37
36
  */
38
37
  static registerToGlobalNs = true
39
-
40
38
  /**
41
39
  * Configs will get merged throughout the class hierarchy
42
40
  * @returns {Object} config
@@ -229,7 +227,7 @@ class Base {
229
227
  * @param {String} id
230
228
  */
231
229
  createId(id) {
232
- this.id = id || IdGenerator.getId(this.getIdKey());
230
+ this.id = id || IdGenerator.getId(this.getIdKey())
233
231
  }
234
232
 
235
233
  /**
@@ -249,7 +247,7 @@ class Base {
249
247
  if (Object.getOwnPropertyDescriptor(me, key).writable) {
250
248
  delete me[key];
251
249
  }
252
- });
250
+ })
253
251
  }
254
252
 
255
253
  /**
@@ -258,7 +256,7 @@ class Base {
258
256
  * @returns {String}
259
257
  */
260
258
  getIdKey() {
261
- return this.ntype;
259
+ return this.ntype
262
260
  }
263
261
 
264
262
  /**
@@ -267,7 +265,7 @@ class Base {
267
265
  * @returns {*}
268
266
  */
269
267
  getStaticConfig(key) {
270
- return this.constructor[key];
268
+ return this.constructor[key]
271
269
  }
272
270
 
273
271
  /**
@@ -286,7 +284,7 @@ class Base {
286
284
  let me = this;
287
285
 
288
286
  Object.assign(me[configSymbol], me.mergeConfig(config, preventOriginalConfig));
289
- me.processConfigs();
287
+ me.processConfigs()
290
288
  }
291
289
 
292
290
  /**
@@ -308,10 +306,10 @@ class Base {
308
306
  if (Neo.workerId !== 'main' && currentWorker.isSharedWorker && !currentWorker.isConnected) {
309
307
  listenerId = currentWorker.on('connected', () => {
310
308
  currentWorker.un('connected', listenerId);
311
- Base.sendRemotes(className, remote);
309
+ Base.sendRemotes(className, remote)
312
310
  });
313
311
  } else {
314
- Base.sendRemotes(className, remote);
312
+ Base.sendRemotes(className, remote)
315
313
  }
316
314
  }
317
315
  }
@@ -334,7 +332,7 @@ class Base {
334
332
  me.originalConfig = Neo.clone(config, true, true);
335
333
  }
336
334
 
337
- return {...ctor.config, ...config};
335
+ return {...ctor.config, ...config}
338
336
  }
339
337
 
340
338
  /**
@@ -346,7 +344,7 @@ class Base {
346
344
  me.isConstructed = true;
347
345
 
348
346
  // We can only fire the event in case the Observable mixin is included.
349
- me.getStaticConfig('observable') && me.fire('constructed', me);
347
+ me.getStaticConfig('observable') && me.fire('constructed', me)
350
348
  }
351
349
 
352
350
  /**
@@ -370,7 +368,7 @@ class Base {
370
368
  }
371
369
 
372
370
  items.forEach(item => {
373
- !Neo.typeOf(item) === 'NeoClass' && Object.entries(item).forEach(([key, value]) => {
371
+ Object.entries(item).forEach(([key, value]) => {
374
372
  if (Array.isArray(value)) {
375
373
  me.parseItemConfigs(value);
376
374
  } else if (typeof value === 'string' && value.startsWith('@config:')) {
@@ -392,8 +390,8 @@ class Base {
392
390
  }
393
391
  }
394
392
  }
395
- });
396
- });
393
+ })
394
+ })
397
395
  }
398
396
  }
399
397
 
@@ -420,7 +418,7 @@ class Base {
420
418
  // we need to keep this one for configs, which do not use getters (no trailing underscore)
421
419
  delete me[configSymbol][keys[0]];
422
420
 
423
- me.processConfigs(forceAssign);
421
+ me.processConfigs(forceAssign)
424
422
  }
425
423
  }
426
424
 
@@ -439,7 +437,7 @@ class Base {
439
437
  action: 'registerRemote',
440
438
  className,
441
439
  methods
442
- });
440
+ })
443
441
  }
444
442
  });
445
443
  }
@@ -462,7 +460,7 @@ class Base {
462
460
 
463
461
  Object.assign(me[configSymbol], values);
464
462
 
465
- me.processConfigs(true);
463
+ me.processConfigs(true)
466
464
  }
467
465
 
468
466
  /**
@@ -480,7 +478,7 @@ class Base {
480
478
  me[key] = value;
481
479
  delete config[key];
482
480
  }
483
- });
481
+ })
484
482
 
485
483
  return config;
486
484
  }
@@ -496,10 +494,10 @@ class Base {
496
494
 
497
495
  if (staticConfig.hasOwnProperty(key)) {
498
496
  staticConfig[key] = value;
499
- return true;
497
+ return true
500
498
  }
501
499
 
502
- return false;
500
+ return false
503
501
  }
504
502
 
505
503
  /**
@@ -508,7 +506,7 @@ class Base {
508
506
  * @returns {String}
509
507
  */
510
508
  get [Symbol.toStringTag]() {
511
- return `${this.className} (id: ${this.id})`;
509
+ return `${this.className} (id: ${this.id})`
512
510
  }
513
511
 
514
512
  /**
@@ -521,10 +519,10 @@ class Base {
521
519
  */
522
520
  static [Symbol.hasInstance](instance) {
523
521
  if (!instance) {
524
- return false;
522
+ return false
525
523
  }
526
524
 
527
- return instance[isInstance] === true ? super[Symbol.hasInstance](instance) : false;
525
+ return instance[isInstance] === true ? super[Symbol.hasInstance](instance) : false
528
526
  }
529
527
  }
530
528
 
@@ -30,6 +30,21 @@ class Container extends BaseContainer {
30
30
  {tag: 'form', cn: [], onsubmit: 'return false;'}
31
31
  }
32
32
 
33
+ /**
34
+ * Helper function used by setValues() which wraps the leaves of a tree structure into a new property
35
+ * @param {Object} values
36
+ * @param {String} configName
37
+ */
38
+ static adjustTreeLeaves(values={}, configName) {
39
+ Object.entries(values).forEach(([key, value]) => {
40
+ if (Neo.typeOf(value) === 'Object') {
41
+ this.adjustTreeLeaves(value, configName)
42
+ } else {
43
+ values[key] = {[configName]: value}
44
+ }
45
+ })
46
+ }
47
+
33
48
  /**
34
49
  * @param {Neo.container.Base} parent
35
50
  * @param {Object[]} modules
@@ -250,9 +265,7 @@ class Container extends BaseContainer {
250
265
  * @param {Boolean} suspendEvents=false
251
266
  */
252
267
  async setValues(values={}, suspendEvents=false) {
253
- Object.entries(values).forEach(([key, value]) => {
254
- values[key] = {value}
255
- })
268
+ Container.adjustTreeLeaves(values, 'value');
256
269
 
257
270
  await this.setConfigs(values, suspendEvents)
258
271
  }
@@ -1,36 +1,69 @@
1
1
  import Base from '../core/Base.mjs';
2
2
 
3
3
  /**
4
- * @class Neo.util.StringUtil
4
+ * @class Neo.util.String
5
5
  * @extends Neo.core.Base
6
6
  */
7
7
  class StringUtil extends Base {
8
+ /**
9
+ * @member {Object} charEntityMap
10
+ * @static
11
+ */
12
+ static charEntityMap = {
13
+ '&' : '&',
14
+ '<' : '&lt;',
15
+ '>' : '&gt;',
16
+ '"' : '&quot;',
17
+ '\'': '&#039;'
18
+ }
19
+ /**
20
+ * @member {RegExp} charPattern
21
+ * @static
22
+ */
23
+ static charPattern = /[&<>"']/g
24
+ /**
25
+ * @member {RegExp} entityPattern
26
+ * @static
27
+ */
28
+ static entityPattern = /(&amp;)|(&lt;)|(&gt;)|(&quot;)|(&#039;)/g
29
+
8
30
  static config = {
9
31
  /**
10
- * @member {String} className='Neo.util.StringUtil'
32
+ * @member {String} className='Neo.util.String'
11
33
  * @protected
12
34
  */
13
- className: 'Neo.util.StringUtil'
35
+ className: 'Neo.util.String'
14
36
  }
15
-
16
- static escapedChars = {
17
- '&': '&amp;',
18
- '<': '&lt;',
19
- '>': '&gt;',
20
- '"': '&quot;',
21
- '\'': '&#039;'
22
- }
23
37
 
24
38
  /**
25
39
  * Escape HTML special characters
26
40
  * @param {String} value
27
41
  */
28
42
  static escapeHtml(value) {
43
+ let me = this; // inside a static method, we are pointing to the class prototype
44
+
29
45
  if (Neo.typeOf(value) !== 'String') {
30
46
  return value;
31
47
  }
32
48
 
33
- return value.replace(/[&<>"']/g, (char) => this.escapedChars[char] || char);
49
+ return value.replace(me.charPattern, me.getEntityFromChar.bind(me));
50
+ }
51
+
52
+ /**
53
+ * Get char equivalent of a mapped entity
54
+ * @param {String} entity
55
+ */
56
+ static getCharFromEntity(entity) {
57
+ const mappedChar = Object.keys(this.charEntityMap).find(key => this.charEntityMap[key] === entity);
58
+ return mappedChar || entity;
59
+ }
60
+
61
+ /**
62
+ * Get entity equivalent of a mapped char
63
+ * @param {String} char
64
+ */
65
+ static getEntityFromChar(char) {
66
+ return this.charEntityMap[char] || char;
34
67
  }
35
68
 
36
69
  /**
@@ -38,19 +71,16 @@ class StringUtil extends Base {
38
71
  * @param {String} value
39
72
  */
40
73
  static unescapeHtml(value) {
74
+ let me = this; // inside a static method, we are pointing to the class prototype
75
+
41
76
  if (Neo.typeOf(value) !== 'String') {
42
77
  return value;
43
78
  }
44
79
 
45
- return value.replace(/(&amp;)|(&lt;)|(&gt;)|(&quot;)|(&#039;)/g, (entity) => this.getKeyByValue(entity) || entity);
80
+ return value.replace(me.entityPattern, me.getCharFromEntity.bind(me));
46
81
  }
47
-
48
- static getKeyByValue(value) {
49
- return Object.keys(this.escapedChars).find(key => this.escapedChars[key] === value);
50
- }
51
82
  }
52
83
 
53
-
54
84
  Neo.applyClassConfig(StringUtil);
55
85
 
56
86
  export default StringUtil;