cavalion-js 1.0.73 → 1.0.74
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/CHANGELOG.md +5 -1
- package/package.json +1 -1
- package/src/js/Property.js +0 -124
- package/src/js/extensions.js +8 -6
- package/src/locale.js +7 -2
- package/.js +0 -0
- package/Resource-o4rk6z5bml.md +0 -69
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
### 2023/03/
|
|
1
|
+
### 2023/03/30 - 1.0.74
|
|
2
|
+
|
|
3
|
+
* Introduces `locale.has()`
|
|
4
|
+
|
|
5
|
+
### 2023/03/01 - 1.0.73
|
|
2
6
|
|
|
3
7
|
* Introduces `js.mi` alias for `js.mixIn`
|
|
4
8
|
* Fixes a bug in `js.sf` (ie. String.format) where specifiers where not handled correctly for %X.Yf like formats
|
package/package.json
CHANGED
package/src/js/Property.js
CHANGED
|
@@ -18,10 +18,6 @@ define(function(require) {
|
|
|
18
18
|
return (Property = Property(require, {
|
|
19
19
|
|
|
20
20
|
prototype: {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
21
|
constructor: function(declaringClass, name, decl) {
|
|
26
22
|
this._declaringClass = declaringClass;
|
|
27
23
|
this._name = name;
|
|
@@ -76,10 +72,6 @@ define(function(require) {
|
|
|
76
72
|
getDeclaringClass: function() {
|
|
77
73
|
return this._declaringClass;
|
|
78
74
|
},
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
83
75
|
getPropertyClass: function() {
|
|
84
76
|
throw new Error("Unknown class");
|
|
85
77
|
},
|
|
@@ -101,10 +93,6 @@ define(function(require) {
|
|
|
101
93
|
}
|
|
102
94
|
return this._editorClass;
|
|
103
95
|
},
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
*/
|
|
108
96
|
getEditorInfo: function(path) {
|
|
109
97
|
return path === undefined ? this._editorInfo : js.get(path, this._editorInfo || {});
|
|
110
98
|
},
|
|
@@ -168,10 +156,6 @@ define(function(require) {
|
|
|
168
156
|
isStrict: function() {
|
|
169
157
|
return this._strict;
|
|
170
158
|
},
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
*
|
|
174
|
-
*/
|
|
175
159
|
isReadOnly: function() {
|
|
176
160
|
return this.__set === Property.prototype.__set;
|
|
177
161
|
},
|
|
@@ -202,10 +186,6 @@ define(function(require) {
|
|
|
202
186
|
get: function(obj) {
|
|
203
187
|
return this.__get(obj);
|
|
204
188
|
},
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
*
|
|
208
|
-
*/
|
|
209
189
|
__get: function(obj) {
|
|
210
190
|
throw new Error("No getter defined");
|
|
211
191
|
},
|
|
@@ -216,10 +196,6 @@ define(function(require) {
|
|
|
216
196
|
set: function(obj, value) {
|
|
217
197
|
return this.__set(obj, value);
|
|
218
198
|
},
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
*
|
|
222
|
-
*/
|
|
223
199
|
__set: function(obj, value) {
|
|
224
200
|
throw new Error("No setter defined");
|
|
225
201
|
}
|
|
@@ -227,10 +203,6 @@ define(function(require) {
|
|
|
227
203
|
},
|
|
228
204
|
|
|
229
205
|
statics: {
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
*
|
|
233
|
-
*/
|
|
234
206
|
isReferencedClass: function(cls) {
|
|
235
207
|
if(Class.isConstructor(cls)) {
|
|
236
208
|
if(referencedClasses.indexOf(cls) !== -1) {
|
|
@@ -241,10 +213,6 @@ define(function(require) {
|
|
|
241
213
|
return false;
|
|
242
214
|
},
|
|
243
215
|
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
*
|
|
247
|
-
*/
|
|
248
216
|
registerReferencedClass: function(cls) {
|
|
249
217
|
if(Class.isConstructor(cls)) {
|
|
250
218
|
referencedClasses.push(cls);
|
|
@@ -252,10 +220,6 @@ define(function(require) {
|
|
|
252
220
|
throw new Error(String.format("%s is not a class constructor"));
|
|
253
221
|
}
|
|
254
222
|
},
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
*
|
|
258
|
-
*/
|
|
259
223
|
initialize: function(property, prop) {
|
|
260
224
|
|
|
261
225
|
var ctor = property._declaringClass;
|
|
@@ -465,171 +429,83 @@ define(function(require) {
|
|
|
465
429
|
},
|
|
466
430
|
|
|
467
431
|
GetDefaultValue: {
|
|
468
|
-
|
|
469
|
-
/**
|
|
470
|
-
*
|
|
471
|
-
*/
|
|
472
432
|
VALUE: function(obj) {
|
|
473
433
|
return this._defaultValue;
|
|
474
434
|
},
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
*
|
|
478
|
-
*/
|
|
479
435
|
METHOD: function(obj) {
|
|
480
436
|
return obj[this._defaultValue]();
|
|
481
437
|
},
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
*
|
|
485
|
-
*/
|
|
486
438
|
INLINE: function(obj) {
|
|
487
439
|
return this._defaultValue.apply(obj, []);
|
|
488
440
|
}
|
|
489
441
|
},
|
|
490
|
-
|
|
491
442
|
Getter: {
|
|
492
|
-
|
|
493
|
-
/**
|
|
494
|
-
*
|
|
495
|
-
*/
|
|
496
443
|
MEMBER: function(obj) {
|
|
497
444
|
return obj[this._getter];
|
|
498
445
|
},
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
*
|
|
502
|
-
*/
|
|
503
446
|
METHOD: function(obj) {
|
|
504
447
|
return obj[this._getter]();
|
|
505
448
|
},
|
|
506
|
-
|
|
507
|
-
/**
|
|
508
|
-
*
|
|
509
|
-
*/
|
|
510
449
|
INLINE: function(obj) {
|
|
511
450
|
return this._getter.apply(obj, []);
|
|
512
451
|
}
|
|
513
452
|
},
|
|
514
453
|
|
|
515
454
|
IsAssignable: {
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
*
|
|
519
|
-
*/
|
|
520
455
|
VALUE: function(obj) {
|
|
521
456
|
return this._assignable;
|
|
522
457
|
},
|
|
523
|
-
|
|
524
|
-
/**
|
|
525
|
-
*
|
|
526
|
-
*/
|
|
527
458
|
METHOD: function(obj) {
|
|
528
459
|
return obj[this._assignable](obj);
|
|
529
460
|
},
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
*
|
|
533
|
-
*/
|
|
534
461
|
INLINE: function(obj) {
|
|
535
462
|
return this._assignable.apply(this, [obj]);
|
|
536
463
|
}
|
|
537
464
|
},
|
|
538
|
-
|
|
539
465
|
IsEnabled: {
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
*
|
|
543
|
-
*/
|
|
544
466
|
VALUE: function(obj) {
|
|
545
467
|
return this._enabled;
|
|
546
468
|
},
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
*
|
|
550
|
-
*/
|
|
551
469
|
METHOD: function(obj) {
|
|
552
470
|
return obj[this._enabled]();
|
|
553
471
|
},
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
*
|
|
557
|
-
*/
|
|
558
472
|
INLINE: function(obj) {
|
|
559
473
|
return this._enabled.apply(obj, []);
|
|
560
474
|
}
|
|
561
475
|
},
|
|
562
|
-
|
|
563
476
|
IsStored: {
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
*
|
|
567
|
-
*/
|
|
568
477
|
VALUE: function(obj) {
|
|
569
478
|
return this.hasDefaultValue(obj) ? false : this._stored;
|
|
570
479
|
},
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
*
|
|
574
|
-
*/
|
|
575
480
|
METHOD: function(obj) {
|
|
576
481
|
return this.hasDefaultValue(obj) ? false : obj[this._stored](obj);
|
|
577
482
|
},
|
|
578
|
-
|
|
579
|
-
/**
|
|
580
|
-
*
|
|
581
|
-
*/
|
|
582
483
|
INLINE: function(obj) {
|
|
583
484
|
return this.hasDefaultValue(obj) ? false : this._stored.apply(this, [obj]);
|
|
584
485
|
}
|
|
585
486
|
},
|
|
586
|
-
|
|
587
487
|
IsVisible: {
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
*
|
|
591
|
-
*/
|
|
592
488
|
VALUE: function(obj) {
|
|
593
489
|
return this._visible;
|
|
594
490
|
},
|
|
595
|
-
|
|
596
|
-
/**
|
|
597
|
-
*
|
|
598
|
-
*/
|
|
599
491
|
METHOD: function(obj) {
|
|
600
492
|
return obj[this._visible]();
|
|
601
493
|
},
|
|
602
|
-
|
|
603
|
-
/**
|
|
604
|
-
*
|
|
605
|
-
*/
|
|
606
494
|
INLINE: function(obj) {
|
|
607
495
|
return this._visible.apply(obj, []);
|
|
608
496
|
}
|
|
609
497
|
},
|
|
610
498
|
|
|
611
499
|
Setter: {
|
|
612
|
-
|
|
613
|
-
/**
|
|
614
|
-
*
|
|
615
|
-
*/
|
|
616
500
|
MEMBER: function(obj, value) {
|
|
617
501
|
if(this._strict === true && !Type.isCompatible(this._type, value)) {
|
|
618
502
|
throw new TypeError(String.format("%s is not a valid %s", value, this._type));
|
|
619
503
|
}
|
|
620
504
|
return (obj[this._setter] = value);
|
|
621
505
|
},
|
|
622
|
-
|
|
623
|
-
/**
|
|
624
|
-
*
|
|
625
|
-
*/
|
|
626
506
|
METHOD: function(obj, value) {
|
|
627
507
|
return obj[this._setter](value);
|
|
628
508
|
},
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
*
|
|
632
|
-
*/
|
|
633
509
|
INLINE: function(obj, value) {
|
|
634
510
|
return this._setter.apply(obj, [value]);
|
|
635
511
|
}
|
package/src/js/extensions.js
CHANGED
|
@@ -141,18 +141,20 @@ define(function(require) {
|
|
|
141
141
|
return r.toLowerCase();
|
|
142
142
|
};
|
|
143
143
|
String.escape = function (s) {
|
|
144
|
+
return JSON.stringify(s).slice(1, -1);
|
|
144
145
|
/**
|
|
145
146
|
*
|
|
146
147
|
* @param s
|
|
147
148
|
* @returns
|
|
148
149
|
*/
|
|
149
|
-
return ('"' + s.replace(/(["\\])/g, '\\$1') + '"').
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
150
|
+
// return ('"' + s.replace(/(["\\])/g, '\\$1') + '"').
|
|
151
|
+
// replace(/[\f]/g, "\\f").
|
|
152
|
+
// replace(/[\b]/g, "\\b").
|
|
153
|
+
// replace(/\n/g, "\\n").
|
|
154
|
+
// replace(/[\t]/g, "\\t").
|
|
155
|
+
// replace(/[\r]/g, "\\r");
|
|
155
156
|
};
|
|
157
|
+
String.unescape = (escapedString) => JSON.parse(`"${escapedString}"`);
|
|
156
158
|
String.escapeHtml = function(s) {
|
|
157
159
|
/**
|
|
158
160
|
*
|
package/src/locale.js
CHANGED
|
@@ -14,7 +14,7 @@ define(function(require) {
|
|
|
14
14
|
|
|
15
15
|
function locale(id) {
|
|
16
16
|
var loc = locale.loc;//arguments.callee.loc;
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
function resolve(id) {
|
|
19
19
|
/*- Find in the dictionary */
|
|
20
20
|
var r = window.locale[loc][id], i, nid, dash = id.indexOf("-"), dot = id.indexOf(".");
|
|
@@ -157,7 +157,7 @@ define(function(require) {
|
|
|
157
157
|
locale.define(prefix, arguments[1]);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
const prefixed = function(id/*, ... */) {
|
|
161
161
|
if(arguments.length === 0) {
|
|
162
162
|
return prefix;
|
|
163
163
|
}
|
|
@@ -171,6 +171,10 @@ define(function(require) {
|
|
|
171
171
|
}
|
|
172
172
|
return locale.apply(this, args);
|
|
173
173
|
};
|
|
174
|
+
|
|
175
|
+
prefixed.has = (id) => locale.has(prefix + id);
|
|
176
|
+
|
|
177
|
+
return prefixed;
|
|
174
178
|
};
|
|
175
179
|
locale.define = function(prefix, defaults) {
|
|
176
180
|
for(var loc in defaults) {
|
|
@@ -184,6 +188,7 @@ define(function(require) {
|
|
|
184
188
|
// console.log(2, locale[loc], L);
|
|
185
189
|
}
|
|
186
190
|
};
|
|
191
|
+
locale.has = (key) => locale[locale.loc].hasOwnProperty(key);
|
|
187
192
|
|
|
188
193
|
if(typeof window !== "undefined" && typeof window.location !== "undefined") {
|
|
189
194
|
locale.loc = (location.search.split('locale=')[1]||'').split('&')[0];
|
package/.js
DELETED
|
File without changes
|
package/Resource-o4rk6z5bml.md
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# JavaScript Classes: The Complete Guide To Creating Your Own Custom Class System
|
|
2
|
-
|
|
3
|
-
JavaScript is a powerful programming language that allows you to create custom code that works in the browser. If you want to create your own custom class system, then this article is for you. It will teach you how to define classes in JavaScript and turn them into something that can be used anywhere on your website.
|
|
4
|
-
|
|
5
|
-
## The Basics of JavaScript Classes
|
|
6
|
-
|
|
7
|
-
In JavaScript, a class is just a special type of function. Classes are in fact "special functions", and just like you can define function expressions and function declarations, the same goes for classes.
|
|
8
|
-
There are two ways to create a class in JavaScript:
|
|
9
|
-
|
|
10
|
-
The first way is to use a class declaration. To do this, you use the class keyword followed by the name of the class. For example:
|
|
11
|
-
|
|
12
|
-
class Rectangle {
|
|
13
|
-
// ...
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
This creates a new class called Rectangle. You can then add properties and methods to this class by using the prototype property of the Rectangle class:
|
|
17
|
-
|
|
18
|
-
Rectangle.prototype.width = 10;
|
|
19
|
-
Rectangle.prototype.height = 5;
|
|
20
|
-
|
|
21
|
-
You can also add methods to the prototype:
|
|
22
|
-
|
|
23
|
-
Rectangle.prototype.getArea = function() {
|
|
24
|
-
return this.width * this.height;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
## Defining a Class System in JavaScript
|
|
28
|
-
|
|
29
|
-
In JavaScript, a class is a blueprint for an object. It is a template that you can use to create new objects with the same characteristics. A class system is a way of organizing and defining classes so that they can be easily reused and extended.
|
|
30
|
-
|
|
31
|
-
There are several ways to define a class system in JavaScript. The most common way is to use the prototype-based approach. This approach uses the prototype property of objects to create new classes. The prototype property is an object that contains the properties and methods that will be inherited by all instances of the class.
|
|
32
|
-
|
|
33
|
-
Another way to define a class system in JavaScript is to use the constructor function. This function allows you to create objects with the same characteristics as the constructor function's prototype object. The constructor function is used to initialize the new object's properties and methods.
|
|
34
|
-
|
|
35
|
-
Once you have defined your class system, you can use it to create new objects. To do this, you first need to create a constructor function for your class. This function will take any arguments that you want to pass into your new object. Once you have created your constructor function, you can then use the new keyword to create an instance of your class.
|
|
36
|
-
|
|
37
|
-
## Step by Step Creation of a Class Definition
|
|
38
|
-
|
|
39
|
-
Assuming you have a basic understanding of Object-Oriented Programming concepts, creating a class in JavaScript is very simple. In fact, there are only a few steps involved:
|
|
40
|
-
|
|
41
|
-
* 1) First, create a function that will serve as the class constructor. This function should accept any parameters that you wish to pass into the class instance when it is created.
|
|
42
|
-
|
|
43
|
-
* 2) Next, create any properties or methods that you wish to add to the class. These can be defined directly within the constructor function, or they can be added after the fact using the prototype object.
|
|
44
|
-
|
|
45
|
-
* 3) Finally, return the newly created class from the constructor function.
|
|
46
|
-
|
|
47
|
-
That's all there is to it! With these three steps, you can create your own custom classes in JavaScript.
|
|
48
|
-
|
|
49
|
-
## Using the New Class in JS
|
|
50
|
-
|
|
51
|
-
Assuming you have a basic understanding of JavaScript classes, let's explore how to use the new class in JS.
|
|
52
|
-
|
|
53
|
-
As we discussed earlier, the new keyword is used to create an instance of a class. When creating an instance of a class, you must provide the arguments that will be passed to the class constructor function. For example:
|
|
54
|
-
|
|
55
|
-
class MyClass {
|
|
56
|
-
constructor(arg1, arg2) {
|
|
57
|
-
this.arg1 = arg1;
|
|
58
|
-
this.arg2 = arg2;
|
|
59
|
-
}
|
|
60
|
-
myMethod() {
|
|
61
|
-
// do something with this.arg1 and this.arg2 here
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const myInstance = new MyClass('foo', 'bar');
|
|
66
|
-
|
|
67
|
-
## Conclusion
|
|
68
|
-
|
|
69
|
-
In conclusion, JavaScript classes provide a great way to create your own custom class system. With the help of this guide, you should now be able to create your own custom classes and use them in your web development projects. If you have any questions or if there is anything we missed, please feel free to reach out and let us know. We would be more than happy to help you out.
|