cavalion-js 1.0.70 โ†’ 1.0.72

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/.md CHANGED
@@ -1,45 +1,19 @@
1
- * [CHANGELOG.md]() - [README.md]() - [package.json]() - [.js]()
2
-
3
- # cavalion-js
4
-
5
- # `0725`
6
-
7
- Enhancing `js.groupBy` to accept multiple keys for grouping.
8
-
9
-
10
- # `0429`
11
-
12
- I want to be able to activate these source files with [an overlay]([!prototypes/Hover]{}) of Markdown. Or... no, I want to overlay the source I guess. ๐Ÿ˜‡๐Ÿคจ๐Ÿค”
13
-
14
- * [defineClass](src/js/:.js)
15
- * [JsObject](src/js/:.js)
16
- * [Method](src/js/:.js)
17
- * [Class](src/js/:.js)
18
- * [extensions](src/js/:.js)
19
- * [mixIn](src/js/:.js)
20
- * [nameOf](src/js/:.js)
21
- * [Method](src/js/:.js)
22
- * [Type](src/js/:.js)
23
-
24
- Still, it would be nice to just
25
-
26
- * Press (**โ‡งโŒ˜.**) and overlay _the current context_ (whatever that might be anyways, probably a JavaScript module, rapportage-script) with _whatever_, starting with a _context-local_-[.md]()-file, sprouting in to whatever, but _mas-que-nada_ a starting point in order to...
27
- * ...overlay notes, bookmarks, links, scripts, photos, ...
28
-
29
- # `0424`
30
-
31
- * `js.args(arr)` - concats and filters `arr` for non-undefined values
32
-
33
- >> var v = (a, b, c, d) => control.vars.apply(control, js.args(a, b, c, d));
1
+ * [CHANGELOG.md]() - [README.md]() - [package.json]()
2
+ * [.workspace](`(devtools/Workspace<${ws.getSpecializer()}>)`) - [.js]()
34
3
 
35
4
  # cavalion-js
36
5
 
37
6
  * [src](:/)
38
- * [console](src/:/)
39
- * [data](src/:/) - [design](src/:/)
40
- * [entities](src/:/) - [entities.js](src/) - [features](src/:/)
7
+ * **[console](src/:/)**
8
+ * **[data](src/:/)** - [design](src/:/)
9
+ * **[entities](src/:/)** - [entities.js](src/) - [features](src/:/)
41
10
  * [js](src/:/) / [\_js.js](src/js/:) - [extensions.js](src/js/:) - _[global.js](src/js/:)_? - _[define.js](src/js/:)?_
42
11
  - [defineClass.js](src/js/:) - [referenceClass.js](src/js/:)
12
+ - [json.js](src/:) - [locale.js](src/:) - [text.js](src/:)
13
+ - [script.js](src/:) - [relscript.js](src/:)
14
+ - [stylesheet.js](src/:)
15
+ - [persistence](src/:/) - [persistence2](src/:/)
16
+ - [test](src/:/) - [yell.js](src/:) - [unrequire.js](src/:)
43
17
  - [js.js](src/:)
44
18
  - [on.js](src/:)
45
19
  - [nameOf.js](src/js/:)
@@ -55,13 +29,8 @@ Still, it would be nice to just
55
29
  - [Rest.js](src/util/:)
56
30
  - [Stylesheet.js](src/util/:)
57
31
  - [Xml.js](src/util/:)
58
- - [json.js](src/:) - [locale.js](src/:) - [text.js](src/:)
59
- - [script.js](src/:) - [relscript.js](src/:)
60
- - [stylesheet.js](src/:)
61
- - [persistence](src/:/) - [persistence2](src/:/)
62
- - [test](src/:/) - [yell.js](src/:) - [unrequire.js](src/:)
63
32
 
64
- #
33
+ #
65
34
 
66
35
  - []()
67
36
  - [ArrayFactory.js](src/js/:)
@@ -77,8 +46,59 @@ Still, it would be nice to just
77
46
  - [Scaffold.js](src/js/:)
78
47
  - [Type.js](src/js/:)
79
48
 
80
- # js.nameOf for Array in console
49
+ # `2022/11/02`
50
+
51
+ What about a shared _polyfill_-like file, loaded at startup in order to fill in the gaps of packages that are not updated/compiled just yet.
52
+
53
+ if(!js.waitAll) {
54
+ js.waitAll = function(/* ... */) {
55
+ return Promise.all(js.copy_args(arguments).flat().map(p => {
56
+ if(typeof p === "string" && p.endsWith("ms")) { // for syntax/code that says it all
57
+ return new Promise(resolve => setTimeout(resolve, parseInt(p, 10)));
58
+ } else if(typeof p === "number") { // ok, we'll do this too ;-)
59
+ return new Promise(resolve => setTimeout(resolve, p));
60
+ } else if(!(p instanceof Promise)) {
61
+ throw new Error("Can not wait for", p);
62
+ }
63
+ return p;
64
+ }));
65
+ }
66
+ }
67
+
68
+ # `2022/09/13`
69
+
70
+ * Working on [README.md]().
71
+
72
+ # `2022/07/25`
81
73
 
74
+ * Enhancing `js.groupBy` to accept multiple keys for grouping.
75
+
76
+ # `2022/04/29`
77
+
78
+ I want to be able to activate these source files with [an overlay]([!prototypes/Hover]{}) of Markdown. Or... no, I want to overlay the source I guess. ๐Ÿ˜‡๐Ÿคจ๐Ÿค”
79
+
80
+ * [defineClass](src/js/:.js)
81
+ * [JsObject](src/js/:.js)
82
+ * [Method](src/js/:.js)
83
+ * [Class](src/js/:.js)
84
+ * [extensions](src/js/:.js)
85
+ * [mixIn](src/js/:.js)
86
+ * [nameOf](src/js/:.js)
87
+ * [Method](src/js/:.js)
88
+ * [Type](src/js/:.js)
89
+
90
+ Still, it would be nice to just:
91
+
92
+ * Press (**โ‡งโŒ˜.**) and overlay _the current context_ (whatever that might be anyways, probably a JavaScript module, rapportage-script) with _whatever_, starting with a _context-local_-[.md]()-file, sprouting in to whatever, but _mas-que-nada_ a starting point in order to...
93
+ * ...overlay notes, bookmarks, links, scripts, photos, ...
94
+
95
+ # `2022/04/24`
96
+
97
+ * `js.args(arr)` - concats and filters `arr` for non-undefined values
98
+
99
+ >> var v = (a, b, c, d) => control.vars.apply(control, js.args(a, b, c, d));
100
+
101
+ # js.nameOf for Array in console
82
102
 
83
103
  # sort
84
104
 
package/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ### 2022/11/15 - 1.0.72
2
+
3
+ * DocumentHook: Adds the events onmouseover and onmouseout
4
+
5
+ ### 2022/11/07
6
+
7
+ * Adds `js.waitAll()`
8
+
9
+ ### 2022/07/28 10/29 - 1.0.71
10
+
11
+ * Adjusts/enhances `js.groupBy()` to use js.get(key,obj) in case obj doesn't have key
12
+ * !!!???? Implements the support for falling back automatically ([CVLN-20220901-2-](/Dropbox-cavalion/Issues/:/))
13
+ fixes a bug where falling back on wildcarded terms was not working correctly
14
+
1
15
  ### 2022/07/28 - 1.0.70
2
16
 
3
17
  * 2bb8d17 - updates/commits code that has been shipped for months now
package/README.md CHANGED
@@ -1,13 +1,46 @@
1
1
  # cavalion-js
2
2
 
3
- ## TL;DR:
3
+ Cavalion common JavaScript library. It consist of:
4
4
 
5
- Cavalion common JavaScript library.
5
+ * Constructor class registration
6
+ * Console printing out vars
7
+ * Data interfaces
8
+ * Design(er) package (in development)
9
+ * Utility Classes
10
+ * RequireJS plugins
6
11
 
7
- ## src/js.js
12
+ # Installation
8
13
 
9
- * Entry point for RequireJS
14
+ ## Node
15
+
16
+ $ npm install cavalion-js
17
+
18
+ ## RequireJS
19
+
20
+ require.config({ paths: { js: `${path-to-cavalion-js}/src/js`}})
21
+
22
+ require("js");
23
+
24
+ # Class System
25
+
26
+ * [defineClass](src/js/:.js) - _basically a shortcut to Class.define with some sugar_
27
+ * [JsObject](src/js/:.js) - _kind of super class_
28
+ * [Method](src/js/:.js) - _hacking with functions_
29
+ * [Class](src/js/:.js) - _Class.make() is where the meat is_
30
+ * [extensions](src/js/:.js)
31
+ * [mixIn](src/js/:.js)
32
+ * [nameOf](src/js/:.js)
33
+ * [Method](src/js/:.js)
34
+ * [Type](src/js/:.js)
35
+
36
+ ![20220915-014041-tAzlRV](https://raw.githubusercontent.com/relluf/screenshots/master/20220915-014041-tAzlRV.png)
37
+
38
+ # RequireJS plugins
39
+
40
+ * [json](src/:.js)
41
+ * [stylesheet](src/:.js)
42
+ * [script](src/:.js)
43
+ * [relscript](src/:.js)
44
+ * [text](src/:.js)
10
45
 
11
- require.config({ paths: { js: "`${npm("cavalion-js")}`/src/js"}})
12
46
 
13
- require("js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-js",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "description": "Cavalion common JavaScript library",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/js/Class.js CHANGED
@@ -20,9 +20,6 @@ define(function(require) {
20
20
  }
21
21
  });
22
22
 
23
- /**
24
- *
25
- */
26
23
  function getDefaultInherits() {
27
24
  if(classMap["js/JsObject"] === undefined) {
28
25
  console.log("JsObject not defined!");
@@ -33,21 +30,21 @@ define(function(require) {
33
30
  return classMap["js/JsObject"];
34
31
  }
35
32
 
36
- /**
37
- * toString implementation for constructors
38
- */
39
33
  function classConstructorToString() {
34
+ /**
35
+ * toString implementation for constructors
36
+ */
40
37
  if(this.hasOwnProperty(classObjKeyName)) {
41
38
  return String.format("function %s() { [constructor code] }", this[classObjKeyName].name);
42
39
  }
43
40
  return Function.prototype.toString.apply(this, arguments);
44
41
  }
45
42
 
46
- /**
47
- * This is Chrome specific (as far as I know). It will show fancy names for
48
- * object instances in the console.
49
- */
50
43
  function namedFunction(name, f) {
44
+ /**
45
+ * This is Chrome specific (as far as I know). It will show fancy names for
46
+ * object instances in the console.
47
+ */
51
48
  var symbol;
52
49
  var g = f, fname = f.name;
53
50
 
@@ -80,12 +77,12 @@ define(function(require) {
80
77
  return f;
81
78
  }
82
79
 
83
- /**
84
- * Create a constructor function used for instances of Class.defin(e)itions
85
- *
86
- * @returns {Function}
87
- */
88
80
  function createConstructor(name) {
81
+ /**
82
+ * Create a constructor function used for instances of Class.defin(e)itions
83
+ *
84
+ * @returns {Function}
85
+ */
89
86
  return namedFunction(name || "AnonymousClass", function() {
90
87
  /**
91
88
  * js/Class.constructor: This constructor inspects it's classObj in
package/src/js/_js.js CHANGED
@@ -41,9 +41,6 @@ define(function(require) {
41
41
  nameOf: nameOf,
42
42
  defineClass: defineClass,
43
43
  mixIn: mixIn,
44
- // groupBy: (arr, key) => {
45
- // return arr.reduce((a, o) => ((a[js.get(key, o)] || (a[js.get(key, o)] = [])).push(o), a), {});
46
- // },
47
44
  groupBy: (arr, keys, mth) => {
48
45
  /*- groupBy: receives an array of objects and returns an object
49
46
  which keys hold reference to the resulting groups.
@@ -59,13 +56,14 @@ define(function(require) {
59
56
 
60
57
  var obj = groupBy(arr, keys.shift());
61
58
 
62
- for(var k in obj) {
63
- if(keys.length) {
64
- obj[k] = js.groupBy(obj[k], [].concat(keys), mth);
65
- } else if(mth) {
66
- obj[k] = mth(obj[k]);
67
- }
68
- }
59
+ for (var k in obj) {
60
+ var v = obj.hasOwnProperty(k) ? obj[k] : js.get(k, obj);
61
+ if (keys.length) {
62
+ obj[k] = js.groupBy(v, [].concat(keys), mth);
63
+ } else if (mth) {
64
+ obj[k] = mth(v);
65
+ }
66
+ }
69
67
 
70
68
  return obj;
71
69
  },
@@ -380,6 +378,17 @@ define(function(require) {
380
378
  * @returns
381
379
  */
382
380
  return window.clearTimeout(id);
383
- }
384
- });
381
+ },
382
+ waitAll: function(/* ... */) {
383
+ return Promise.all(js.copy_args(arguments).flat().map(p => {
384
+ if(typeof p === "string" && p.endsWith("ms")) { // for syntax/code that says it all
385
+ return new Promise(resolve => setTimeout(resolve, parseInt(p, 10)));
386
+ } else if(typeof p === "number") { // ok, we'll do this too ;-)
387
+ return new Promise(resolve => setTimeout(resolve, p));
388
+ } else if(!(p instanceof Promise)) {
389
+ throw new Error("Can not wait for", p);
390
+ }
391
+ return p;
392
+ }));
393
+ }, });
385
394
  });
package/src/locale.js CHANGED
@@ -15,35 +15,7 @@ define(function(require) {
15
15
  function locale(id) {
16
16
  var loc = locale.loc;//arguments.callee.loc;
17
17
 
18
- if(id === undefined || locale[loc] === undefined) {
19
- return "{{" + id + "}}";
20
- }
21
-
22
- if(id instanceof RegExp) {
23
- var m = [], match;
24
- for(var k in locale[loc]) {
25
- if((match = id.exec(k)) !== null && match.length > 0) {
26
- if(m.indexOf(match[0]) === -1) {
27
- m.push(match[0]);
28
- }
29
- }
30
- }
31
- return m;
32
- }
33
-
34
- if(locale.slashDotRepl === true) {
35
- id = id.replace(/\/\./g, "#");
36
- }
37
-
38
18
  function resolve(id) {
39
- if(id === undefined) debugger;
40
-
41
- var began;
42
- if((began = locale.debug)) {
43
- console.group("locale-resolve", id);
44
- }
45
- try {
46
-
47
19
  /*- Find in the dictionary */
48
20
  var r = window.locale[loc][id], i, nid, dash = id.indexOf("-"), dot = id.indexOf(".");
49
21
  var preferdash = (dot === -1 || dot > dash);
@@ -101,14 +73,43 @@ try {
101
73
  }
102
74
 
103
75
  return r;
104
- } finally {
105
- if(began) {
106
- console.groupEnd();
107
- }
108
- }
109
76
  }
110
77
 
111
- var r = resolve(id);
78
+ if(id === undefined || locale[loc] === undefined) {
79
+ return "{{" + id + "}}";
80
+ }
81
+
82
+ if(id instanceof RegExp) {
83
+ var m = [], match;
84
+ for(var k in locale[loc]) {
85
+ if((match = id.exec(k)) !== null && match.length > 0) {
86
+ // if(m.indexOf(match[0]) === -1) {
87
+ m.push([k, locale[loc][k]]);
88
+ // }
89
+ }
90
+ }
91
+ return m.sort((i1, i2) => i1[0] < i2[0] ? -1 : i1[0] === i2[0] ? 0 : 1);
92
+ }
93
+
94
+ var r;
95
+ if(id instanceof Array) { // #CVLN-202209091-1
96
+ // r = resolve(id.join(""));
97
+ var id_ = id.join("");
98
+ r = locale[loc][id.join("")];
99
+ while(r === undefined && id.length > 1) {
100
+ while(id.shift() === "*") ;
101
+ id.unshift("*");
102
+
103
+ r = resolve(id.join(""));
104
+ }
105
+ if(r == undefined) r = locale(id_);
106
+ } else {
107
+ if(locale.slashDotRepl === true) {
108
+ id = id.replace(/\/\./g, "#");
109
+ }
110
+ r = resolve(id);
111
+ }
112
+
112
113
  if(r === undefined) {
113
114
  var arr = (window.locale.missing = (window.locale.missing || []));
114
115
  arr.push(id);
@@ -162,7 +163,12 @@ try {
162
163
  }
163
164
 
164
165
  var args = js.copy_args(arguments);
165
- args[0] = prefix + id;
166
+ if(args[0] instanceof Array) {
167
+ args[0].unshift(prefix);
168
+ args[0] = [args[0].pop(), args[0].join("")].reverse();
169
+ } else {
170
+ args[0] = [prefix, id];
171
+ }
166
172
  return locale.apply(this, args);
167
173
  };
168
174
  };
@@ -18,7 +18,7 @@ define(function(require) {
18
18
  _events: [
19
19
  "ontransitionend",
20
20
  "ontouchstart", "ontouchend", "ontouchmove", "ontap", "ondbltap", "ongesture",
21
- "onclick", "ondblclick",
21
+ "onclick", "ondblclick", "onmouseout", "onmouseover",
22
22
  "onmousemove", "onmousedown", "onmouseup", "_onmousewheel", "onmouseenter", "onmouseleave",
23
23
  "onkeydown", "onkeyup", "onkeypress",
24
24
  "onfocus", "onblur",