@breakside/jskit 2023.7.0 → 2023.9.1
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/Frameworks/DOM.jsframework/Info.json +2 -2
- package/Frameworks/DOM.jsframework/JS/DOMParser.js +72 -63
- package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
- package/Frameworks/FontKit.jsframework/Info.json +2 -2
- package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/Info.json +2 -2
- package/Frameworks/Foundation.jsframework/JS/JSImage.js +13 -16
- package/Frameworks/Foundation.jsframework/JS/JSNumberFormatter.js +105 -8
- package/Frameworks/Foundation.jsframework/JS/JSXMLParser.js +206 -101
- package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/sources.json +2 -0
- package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
- package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
- package/Info.json +2 -2
- package/Node/Resources.js +13 -16
- package/Node/io.breakside.jskit-bundle.js +2 -2
- package/Root/Frameworks/APIKit/Info.yaml +1 -1
- package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/AuthKit/Info.yaml +1 -1
- package/Root/Frameworks/CSSOM/Info.yaml +1 -1
- package/Root/Frameworks/ChartKit/CHAreaChart.js +2 -0
- package/Root/Frameworks/ChartKit/CHLineChart.js +2 -0
- package/Root/Frameworks/ChartKit/CHSeriesStyle.js +1 -0
- package/Root/Frameworks/ChartKit/CHStackedAreaChart.js +1 -0
- package/Root/Frameworks/ChartKit/Info.yaml +1 -1
- package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
- package/Root/Frameworks/DBKit/Info.yaml +1 -1
- package/Root/Frameworks/DOM/DOMParser.js +72 -63
- package/Root/Frameworks/DOM/Info.yaml +1 -1
- package/Root/Frameworks/Dispatch/Info.yaml +1 -1
- package/Root/Frameworks/FontKit/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/JSImage.js +13 -16
- package/Root/Frameworks/Foundation/JSNumberFormatter.js +105 -8
- package/Root/Frameworks/Foundation/JSXMLParser.js +206 -101
- package/Root/Frameworks/ImageKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
- package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
- package/Root/Frameworks/PDFKit/Info.yaml +1 -1
- package/Root/Frameworks/QRKit/Info.yaml +1 -1
- package/Root/Frameworks/SearchKit/Info.yaml +1 -1
- package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/TestKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/UIAccessibility.js +1 -0
- package/Root/Frameworks/UIKit/UIColorPanel.js +4 -0
- package/Root/Frameworks/UIKit/UIHTMLWindowServer.js +9 -0
- package/Root/Frameworks/UIKit/UINavigationController.js +6 -1
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/package.json +1 -1
|
@@ -22,73 +22,82 @@ JSGlobalObject.DOMParser = function DOMParser(){
|
|
|
22
22
|
|
|
23
23
|
DOMParser.prototype = {
|
|
24
24
|
|
|
25
|
+
document: null,
|
|
26
|
+
currentNode: null,
|
|
27
|
+
|
|
25
28
|
parseFromString: function(str, mimetype){
|
|
26
|
-
var parser = JSXMLParser.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
parser.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
29
|
+
var parser = JSXMLParser.initWithString(str);
|
|
30
|
+
if (mimetype == "text/html"){
|
|
31
|
+
parser.mode = JSXMLParser.Mode.html;
|
|
32
|
+
}
|
|
33
|
+
this.document = null;
|
|
34
|
+
this.currentNode = null;
|
|
35
|
+
parser.delegate = this;
|
|
36
|
+
parser.parse();
|
|
37
|
+
return this.document;
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
xmlParserDidBeginDocument: function(parser){
|
|
41
|
+
this.document = DOM.createDocument();
|
|
42
|
+
this.currentNode = this.document;
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
xmlParserFoundDocumentType: function(parser, name, publicId, systemId){
|
|
46
|
+
var doctype = this.document.implementation.createDocumentType(name, publicId, systemId);
|
|
47
|
+
this.document.appendChild(doctype);
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
xmlParserFoundProcessingInstruction: function(parser, name, data){
|
|
51
|
+
var pi = this.document.createProcessingInstruction(name, data);
|
|
52
|
+
this.currentNode.appendChild(pi);
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
xmlParserFoundComment: function(parser, text){
|
|
56
|
+
var comment = this.document.createComment(text);
|
|
57
|
+
this.currentNode.appendChild(comment);
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
xmlParserFoundCDATA: function(parser, text){
|
|
61
|
+
var cdata = this.document.createCDATASection(text);
|
|
62
|
+
this.currentNode.appendChild(cdata);
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
xmlParserDidBeginElement: function(parser, name, prefix, namespace, attributes){
|
|
66
|
+
var element;
|
|
67
|
+
if (namespace !== null){
|
|
68
|
+
if (prefix !== null){
|
|
69
|
+
element = this.document.createElementNS(namespace, prefix + ':' + name);
|
|
70
|
+
}else{
|
|
71
|
+
element = this.document.createElementNS(namespace, name);
|
|
72
|
+
}
|
|
73
|
+
}else{
|
|
74
|
+
element = this.document.createElement(name);
|
|
75
|
+
}
|
|
76
|
+
var attrs = attributes.all();
|
|
77
|
+
var attr;
|
|
78
|
+
for (var i = 0, l = attrs.length; i < l; ++i){
|
|
79
|
+
attr = attrs[i];
|
|
80
|
+
if (attr.namespace){
|
|
81
|
+
if (attr.prefix !== null){
|
|
82
|
+
element.setAttributeNS(attr.namespace, attr.prefix + ':' + attr.name, attr.value);
|
|
61
83
|
}else{
|
|
62
|
-
element
|
|
63
|
-
}
|
|
64
|
-
var attr;
|
|
65
|
-
for (var i = 0, l = attributes.length; i < l; ++i){
|
|
66
|
-
attr = attributes[i];
|
|
67
|
-
if (attr.namespace){
|
|
68
|
-
if (attr.prefix !== null){
|
|
69
|
-
element.setAttributeNS(attr.namespace, attr.prefix + ':' + attr.name, attr.value);
|
|
70
|
-
}else{
|
|
71
|
-
element.setAttribute(attr.namespace, attr.name, attr.value);
|
|
72
|
-
}
|
|
73
|
-
}else{
|
|
74
|
-
element.setAttribute(attr.name, attr.value);
|
|
75
|
-
}
|
|
84
|
+
element.setAttribute(attr.namespace, attr.name, attr.value);
|
|
76
85
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
stack.push(node);
|
|
80
|
-
node = element;
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
handleText: function(text){
|
|
84
|
-
var textNode = document.createTextNode(text);
|
|
85
|
-
node.appendChild(textNode);
|
|
86
|
-
},
|
|
87
|
-
endElement: function(){
|
|
88
|
-
node = stack.pop();
|
|
86
|
+
}else{
|
|
87
|
+
element.setAttribute(attr.name, attr.value);
|
|
89
88
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
89
|
+
}
|
|
90
|
+
this.currentNode.appendChild(element);
|
|
91
|
+
this.currentNode = element;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
xmlParserFoundText: function(parser, text){
|
|
95
|
+
var textNode = this.document.createTextNode(text);
|
|
96
|
+
this.currentNode.appendChild(textNode);
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
xmlParserDidEndElement: function(parser){
|
|
100
|
+
this.currentNode = this.currentNode.parentNode;
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
};
|
|
@@ -373,10 +373,10 @@ _JSDataImage.sizeFromJPEGData = function(data){
|
|
|
373
373
|
};
|
|
374
374
|
|
|
375
375
|
_JSDataImage.sizeFromSVGData = function(data){
|
|
376
|
-
var parser = JSXMLParser.
|
|
376
|
+
var parser = JSXMLParser.initWithData(data);
|
|
377
377
|
var size = JSSize(1, 1);
|
|
378
|
-
parser.
|
|
379
|
-
|
|
378
|
+
parser.delegate = {
|
|
379
|
+
xmlParserDidBeginElement: function(parser, name, prefix, namespace, attributes){
|
|
380
380
|
var multiple = {
|
|
381
381
|
'em': 12,
|
|
382
382
|
'ex': 24,
|
|
@@ -406,25 +406,22 @@ _JSDataImage.sizeFromSVGData = function(data){
|
|
|
406
406
|
return multiple[unit] * n;
|
|
407
407
|
};
|
|
408
408
|
if (namespace == 'http://www.w3.org/2000/svg' && name.toLowerCase() == 'svg'){
|
|
409
|
-
var
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
size.width = px(attrs.width);
|
|
418
|
-
size.height = px(attrs.height);
|
|
419
|
-
}else if (attrs.viewBox){
|
|
420
|
-
var box = attrs.viewBox.split(/\s+/).map(function(n){ return parseInt(n); });
|
|
409
|
+
var width = attributes.get("width");
|
|
410
|
+
var height = attributes.get("height");
|
|
411
|
+
var viewBox = attributes.get("viewBox");
|
|
412
|
+
if (width && height){
|
|
413
|
+
size.width = px(width);
|
|
414
|
+
size.height = px(height);
|
|
415
|
+
}else if (viewBox){
|
|
416
|
+
var box = viewBox.split(/\s+/).map(function(n){ return parseInt(n); });
|
|
421
417
|
size.width = box[2];
|
|
422
418
|
size.height = box[3];
|
|
423
419
|
}
|
|
424
420
|
}
|
|
425
421
|
parser.stop();
|
|
426
422
|
}
|
|
427
|
-
}
|
|
423
|
+
};
|
|
424
|
+
parser.parse();
|
|
428
425
|
return size;
|
|
429
426
|
};
|
|
430
427
|
|
|
@@ -526,23 +526,120 @@ JSClass("JSNumberFormatter", JSObject, {
|
|
|
526
526
|
if (this._minimumFractionDigits > 0 || fraction !== 0){
|
|
527
527
|
fraction *= Math.pow(10, this._maximumFractionDigits);
|
|
528
528
|
fraction = Math.round(fraction);
|
|
529
|
-
var extras = this._maximumFractionDigits - this._minimumFractionDigits;
|
|
530
|
-
while (extras > 0 && ((fraction % 10) === 0)){
|
|
531
|
-
fraction /= 10;
|
|
532
|
-
--extras;
|
|
533
|
-
}
|
|
534
529
|
if (this._minimumFractionDigits > 0 || fraction !== 0){
|
|
535
530
|
str += ".";
|
|
536
531
|
var fractionString = fraction.toString();
|
|
537
|
-
while (fractionString.length < this.
|
|
538
|
-
fractionString
|
|
532
|
+
while (fractionString.length < this._maximumFractionDigits){
|
|
533
|
+
fractionString = "0" + fractionString;
|
|
534
|
+
}
|
|
535
|
+
while (fractionString.length > this._minimumFractionDigits && fractionString[fractionString.length - 1] === "0"){
|
|
536
|
+
fractionString = fractionString.substr(0, fractionString.length - 1);
|
|
539
537
|
}
|
|
540
538
|
str += fractionString;
|
|
541
539
|
}
|
|
542
540
|
}
|
|
543
541
|
}
|
|
544
542
|
return prefix + str + suffix;
|
|
545
|
-
}
|
|
543
|
+
},
|
|
544
|
+
|
|
545
|
+
numberFromString: function(string){
|
|
546
|
+
var n = 0;
|
|
547
|
+
var f = 0;
|
|
548
|
+
var d = 1;
|
|
549
|
+
var sign = 1;
|
|
550
|
+
var iterator = string.unicodeIterator();
|
|
551
|
+
var i = 0;
|
|
552
|
+
var l = string.length;
|
|
553
|
+
var c;
|
|
554
|
+
var canSeeSign = true;
|
|
555
|
+
var canSeeCurrency = true;
|
|
556
|
+
var canSeeDecimal = true;
|
|
557
|
+
var canSeeInteger = true;
|
|
558
|
+
var canSeeFraction = false;
|
|
559
|
+
var canSeePercent = false;
|
|
560
|
+
var canSeeGroup = false;
|
|
561
|
+
var seenDigit = false;
|
|
562
|
+
var stringMatches = function(substr){
|
|
563
|
+
if (substr.length === 0){
|
|
564
|
+
return false;
|
|
565
|
+
}
|
|
566
|
+
return string.substr(i, substr.length) === substr;
|
|
567
|
+
};
|
|
568
|
+
while (i < l){
|
|
569
|
+
c = string.charCodeAt(i);
|
|
570
|
+
if (c >= 0x30 && c <= 0x39){
|
|
571
|
+
if (canSeeInteger){
|
|
572
|
+
canSeeSign = false;
|
|
573
|
+
canSeeGroup = true;
|
|
574
|
+
canSeePercent = true;
|
|
575
|
+
n *= 10;
|
|
576
|
+
n += (c - 0x30);
|
|
577
|
+
}else if (canSeeFraction){
|
|
578
|
+
f *= 10;
|
|
579
|
+
f += (c - 0x30);
|
|
580
|
+
d *= 10;
|
|
581
|
+
}else{
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
seenDigit = true;
|
|
585
|
+
++i;
|
|
586
|
+
}else if (canSeeSign && stringMatches(this.minusSign)){
|
|
587
|
+
sign = -1;
|
|
588
|
+
canSeeSign = false;
|
|
589
|
+
i += this.minusSign.length;
|
|
590
|
+
}else if (canSeeSign && stringMatches(this.plusSign)){
|
|
591
|
+
canSeeSign = false;
|
|
592
|
+
i += this.plusSign.length;
|
|
593
|
+
}else if (canSeeCurrency && stringMatches(this.currencySymbol)){
|
|
594
|
+
canSeeCurrency = false;
|
|
595
|
+
if (seenDigit){
|
|
596
|
+
canSeeInteger = false;
|
|
597
|
+
canSeeDecimal = false;
|
|
598
|
+
canSeeFraction = false;
|
|
599
|
+
}
|
|
600
|
+
i += this.currencySymbol.length;
|
|
601
|
+
}else if (canSeePercent && stringMatches(this.percentSymbol)){
|
|
602
|
+
canSeePercent = false;
|
|
603
|
+
if (seenDigit){
|
|
604
|
+
canSeeInteger = false;
|
|
605
|
+
canSeeDecimal = false;
|
|
606
|
+
canSeeFraction = false;
|
|
607
|
+
}
|
|
608
|
+
i += this.percentSymbol.length;
|
|
609
|
+
}else if (canSeePercent && stringMatches(this.perMilleSymbol)){
|
|
610
|
+
canSeePercent = false;
|
|
611
|
+
if (seenDigit){
|
|
612
|
+
canSeeInteger = false;
|
|
613
|
+
canSeeDecimal = false;
|
|
614
|
+
canSeeFraction = false;
|
|
615
|
+
}
|
|
616
|
+
i += this.perMilleSymbol.length;
|
|
617
|
+
}else if (canSeeDecimal && stringMatches(this.decimalSeparator)){
|
|
618
|
+
canSeeDecimal = false;
|
|
619
|
+
canSeeGroup = false;
|
|
620
|
+
canSeeInteger = false;
|
|
621
|
+
canSeeFraction = true;
|
|
622
|
+
i += this.decimalSeparator.length;
|
|
623
|
+
}else if (canSeeGroup && stringMatches(this.groupingSeparator)){
|
|
624
|
+
i += this.groupingSeparator.length;
|
|
625
|
+
}else if (c == 0x20){
|
|
626
|
+
++i;
|
|
627
|
+
}else{
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
if (!seenDigit){
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
if (f > 0){
|
|
635
|
+
n += f / d;
|
|
636
|
+
}
|
|
637
|
+
n /= this.multiplier;
|
|
638
|
+
if (sign < 0){
|
|
639
|
+
n = -n;
|
|
640
|
+
}
|
|
641
|
+
return n;
|
|
642
|
+
},
|
|
546
643
|
|
|
547
644
|
});
|
|
548
645
|
|