@breakside/jskit 2022.22.3 → 2022.23.0

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.
Files changed (49) hide show
  1. package/Frameworks/DOM.jsframework/Info.json +2 -2
  2. package/Frameworks/DOM.jsframework/JS/XMLSerializer.js +9 -4
  3. package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
  4. package/Frameworks/FontKit.jsframework/Info.json +2 -2
  5. package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
  6. package/Frameworks/Foundation.jsframework/Info.json +2 -2
  7. package/Frameworks/Foundation.jsframework/JS/JSAttributedString.js +144 -0
  8. package/Frameworks/Foundation.jsframework/JS/JSFont.js +39 -15
  9. package/Frameworks/Foundation.jsframework/JS/JSFontDescriptor+HTML.js +8 -0
  10. package/Frameworks/Foundation.jsframework/JS/JSFontDescriptor.js +105 -27
  11. package/Frameworks/Foundation.jsframework/JS/String+JS.js +34 -0
  12. package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
  13. package/Frameworks/Foundation.jsframework/sources.json +23 -22
  14. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  15. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  16. package/Info.json +2 -2
  17. package/Node/io.breakside.jskit-bundle.js +2 -2
  18. package/Node/jskit +7 -7
  19. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  20. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  21. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  22. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  23. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  24. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  25. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  26. package/Root/Frameworks/DOM/Info.yaml +1 -1
  27. package/Root/Frameworks/DOM/XMLSerializer.js +9 -4
  28. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  29. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  30. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  31. package/Root/Frameworks/Foundation/JSAttributedString.js +144 -0
  32. package/Root/Frameworks/Foundation/JSFont.js +39 -15
  33. package/Root/Frameworks/Foundation/JSFontDescriptor+HTML.js +8 -0
  34. package/Root/Frameworks/Foundation/JSFontDescriptor.js +105 -27
  35. package/Root/Frameworks/Foundation/String+JS.js +34 -0
  36. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  37. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  38. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  39. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  40. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  41. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  42. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  43. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  44. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  45. package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
  46. package/Root/Frameworks/TestKit/Info.yaml +1 -1
  47. package/Root/Frameworks/UIKit/Info.yaml +1 -1
  48. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  49. package/package.json +1 -1
@@ -48,19 +48,19 @@
48
48
  "JSXMLParser.js",
49
49
  "JSImage.js",
50
50
  "JSTextAttachment.js",
51
- "JSAttributedString.js",
52
- "JSSpec.js",
53
- "JSArrayController.js",
54
- "JSSparseArrayController.js",
55
- "JSColorSpace.js",
56
- "JSColor.js",
57
- "JSGradient.js",
58
51
  "Huffman.js",
59
52
  "Deflate.js",
60
53
  "Adler32.js",
61
54
  "Zlib.js",
62
55
  "JSFontDescriptor.js",
63
56
  "JSFont.js",
57
+ "JSColorSpace.js",
58
+ "JSColor.js",
59
+ "JSAttributedString.js",
60
+ "JSSpec.js",
61
+ "JSArrayController.js",
62
+ "JSSparseArrayController.js",
63
+ "JSGradient.js",
64
64
  "JSPath.js",
65
65
  "JSContext.js",
66
66
  "JSDateFormatter.js",
@@ -193,10 +193,18 @@
193
193
  "_JSDataImage",
194
194
  "_JSURLImage",
195
195
  "JSTextAttachment",
196
- "JSAttributedString",
197
- "JSSpec",
198
- "JSArrayController",
199
- "JSSparseArrayController",
196
+ "HuffmanTree",
197
+ "DeflateStream",
198
+ "Deflate",
199
+ "Adler32",
200
+ "Zlib",
201
+ "ZlibStream",
202
+ "JSFontDescriptor",
203
+ "JSDataFontDescriptor",
204
+ "JSResourceFontDescriptor",
205
+ "JSURLFontDescriptor",
206
+ "JSTestFontDescriptor",
207
+ "JSFont",
200
208
  "JSColorSpace",
201
209
  "JSXYZColorSpace",
202
210
  "JSXYZScaledColorSpace",
@@ -208,18 +216,11 @@
208
216
  "JSIndexedColorSpace",
209
217
  "JSNamedColorSpace",
210
218
  "JSColor",
219
+ "JSAttributedString",
220
+ "JSSpec",
221
+ "JSArrayController",
222
+ "JSSparseArrayController",
211
223
  "JSGradient",
212
- "HuffmanTree",
213
- "DeflateStream",
214
- "Deflate",
215
- "Adler32",
216
- "Zlib",
217
- "ZlibStream",
218
- "JSFontDescriptor",
219
- "JSDataFontDescriptor",
220
- "JSResourceFontDescriptor",
221
- "JSTestFontDescriptor",
222
- "JSFont",
223
224
  "JSPath",
224
225
  "JSContext",
225
226
  "JSDateFormatter",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "JSBundleType": "framework",
3
3
  "JSBundleIdentifier": "io.breakside.JSKit.SecurityKit",
4
- "JSBundleVersion": "2022.22.3",
4
+ "JSBundleVersion": "2022.23.0",
5
5
  "JSDevelopmentLanguage": "en",
6
6
  "JSCopyright": "Copyright © 2020 Breakside Inc.",
7
7
  "JSBundleEnvironments": {
@@ -9,5 +9,5 @@
9
9
  "node": "SecurityKit+Node.js"
10
10
  },
11
11
  "JSLicenseNotice": "Licensed under the Breakside Public License, Version 1.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nIf a copy of the License was not distributed with this file, you may\nobtain a copy at\n\n http://breakside.io/licenses/LICENSE-1.0.txt\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
12
- "GitRevision": "6f0b376edf61fbea02fd94b92f86de9e17d3b716"
12
+ "GitRevision": "e2a77335b26d1a321448e73eb7b733cdd0714cc8"
13
13
  }
@@ -3,7 +3,7 @@ JSBundle.bundles['io.breakside.JSKit.SecurityKit'] = {
3
3
  "Info": {
4
4
  "JSBundleType": "framework",
5
5
  "JSBundleIdentifier": "io.breakside.JSKit.SecurityKit",
6
- "JSBundleVersion": "2022.22.3",
6
+ "JSBundleVersion": "2022.23.0",
7
7
  "JSDevelopmentLanguage": "en",
8
8
  "JSCopyright": "Copyright © 2020 Breakside Inc.",
9
9
  "JSBundleEnvironments": {
@@ -11,7 +11,7 @@ JSBundle.bundles['io.breakside.JSKit.SecurityKit'] = {
11
11
  "node": "SecurityKit+Node.js"
12
12
  },
13
13
  "JSLicenseNotice": "Licensed under the Breakside Public License, Version 1.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nIf a copy of the License was not distributed with this file, you may\nobtain a copy at\n\n http://breakside.io/licenses/LICENSE-1.0.txt\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
14
- "GitRevision": "6f0b376edf61fbea02fd94b92f86de9e17d3b716"
14
+ "GitRevision": "e2a77335b26d1a321448e73eb7b733cdd0714cc8"
15
15
  },
16
16
  "Resources": [],
17
17
  "ResourceLookup": {
package/Info.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "JSBundleType": "node",
3
3
  "JSBundleIdentifier": "io.breakside.jskit",
4
- "JSBundleVersion": "2022.22.3",
4
+ "JSBundleVersion": "2022.23.0",
5
5
  "JSExecutableName": "jskit",
6
6
  "NPMOrganization": "breakside",
7
7
  "JSResources": [
8
8
  "Tests/HTMLTestRunner.js",
9
9
  "Tests/NodeTestRunner.js"
10
10
  ],
11
- "GitRevision": "6f0b376edf61fbea02fd94b92f86de9e17d3b716"
11
+ "GitRevision": "e2a77335b26d1a321448e73eb7b733cdd0714cc8"
12
12
  }
@@ -3,14 +3,14 @@ JSBundle.bundles['io.breakside.jskit'] = {
3
3
  "Info": {
4
4
  "JSBundleType": "node",
5
5
  "JSBundleIdentifier": "io.breakside.jskit",
6
- "JSBundleVersion": "2022.22.3",
6
+ "JSBundleVersion": "2022.23.0",
7
7
  "JSExecutableName": "jskit",
8
8
  "NPMOrganization": "breakside",
9
9
  "JSResources": [
10
10
  "Tests/HTMLTestRunner.js",
11
11
  "Tests/NodeTestRunner.js"
12
12
  ],
13
- "GitRevision": "6f0b376edf61fbea02fd94b92f86de9e17d3b716"
13
+ "GitRevision": "e2a77335b26d1a321448e73eb7b733cdd0714cc8"
14
14
  },
15
15
  "Resources": [
16
16
  {
package/Node/jskit CHANGED
@@ -49,19 +49,19 @@ require("./../Frameworks/Foundation.jsframework/JS/JSURLResponse.js");
49
49
  require("./../Frameworks/Foundation.jsframework/JS/JSXMLParser.js");
50
50
  require("./../Frameworks/Foundation.jsframework/JS/JSImage.js");
51
51
  require("./../Frameworks/Foundation.jsframework/JS/JSTextAttachment.js");
52
- require("./../Frameworks/Foundation.jsframework/JS/JSAttributedString.js");
53
- require("./../Frameworks/Foundation.jsframework/JS/JSSpec.js");
54
- require("./../Frameworks/Foundation.jsframework/JS/JSArrayController.js");
55
- require("./../Frameworks/Foundation.jsframework/JS/JSSparseArrayController.js");
56
- require("./../Frameworks/Foundation.jsframework/JS/JSColorSpace.js");
57
- require("./../Frameworks/Foundation.jsframework/JS/JSColor.js");
58
- require("./../Frameworks/Foundation.jsframework/JS/JSGradient.js");
59
52
  require("./../Frameworks/Foundation.jsframework/JS/Huffman.js");
60
53
  require("./../Frameworks/Foundation.jsframework/JS/Deflate.js");
61
54
  require("./../Frameworks/Foundation.jsframework/JS/Adler32.js");
62
55
  require("./../Frameworks/Foundation.jsframework/JS/Zlib.js");
63
56
  require("./../Frameworks/Foundation.jsframework/JS/JSFontDescriptor.js");
64
57
  require("./../Frameworks/Foundation.jsframework/JS/JSFont.js");
58
+ require("./../Frameworks/Foundation.jsframework/JS/JSColorSpace.js");
59
+ require("./../Frameworks/Foundation.jsframework/JS/JSColor.js");
60
+ require("./../Frameworks/Foundation.jsframework/JS/JSAttributedString.js");
61
+ require("./../Frameworks/Foundation.jsframework/JS/JSSpec.js");
62
+ require("./../Frameworks/Foundation.jsframework/JS/JSArrayController.js");
63
+ require("./../Frameworks/Foundation.jsframework/JS/JSSparseArrayController.js");
64
+ require("./../Frameworks/Foundation.jsframework/JS/JSGradient.js");
65
65
  require("./../Frameworks/Foundation.jsframework/JS/JSPath.js");
66
66
  require("./../Frameworks/Foundation.jsframework/JS/JSContext.js");
67
67
  require("./../Frameworks/Foundation.jsframework/JS/JSDateFormatter.js");
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.APIKit
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSIncludeDirectories:
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.APIKitTesting
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSLicenseNotice: |
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.AuthKit
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSLicenseNotice: |
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.CSSOM
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSBundleEnvironments:
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.ChartKit
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2021 Breakside Inc.
6
6
  # JSBundleEnvironments:
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.ConferenceKit
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSBundleEnvironments:
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.DBKit
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSBundleEnvironments:
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.DOM
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSBundleEnvironments:
@@ -113,10 +113,15 @@ XMLSerializer.prototype = {
113
113
  str += " " + node.name;
114
114
  }
115
115
  if (node.publicId.length > 0){
116
- str += " " + node.publicId;
117
- }
118
- if (node.systemId.length > 0){
119
- str += " " + node.systemId;
116
+ value = node.publicId.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
117
+ str += ' PUBLIC "%s"'.sprintf(value);
118
+ if (node.systemId.length > 0){
119
+ value = node.systemId.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
120
+ str += ' "%s"'.sprintf(value);
121
+ }
122
+ }else if (node.systemId.length > 0){
123
+ value = node.systemId.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
124
+ str += ' SYSTEM "%s"'.sprintf(value);
120
125
  }
121
126
  str += ">\n";
122
127
  }
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.Dispatch
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSCopyright: Copyright © 2020 Breakside Inc.
5
5
  JSBundleEnvironments:
6
6
  html: Dispatch+HTML.js
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.FontKit
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSBundleEnvironments:
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.Foundation
3
- JSBundleVersion: 2022.22.3
3
+ JSBundleVersion: 2022.23.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSBundleEnvironments:
@@ -16,6 +16,8 @@
16
16
  // #import "Javascript.js"
17
17
  // #import "JSObject.js"
18
18
  // #import "JSTextAttachment.js"
19
+ // #import "JSFont.js"
20
+ // #import "JSColor.js"
19
21
  'use strict';
20
22
 
21
23
  (function(){
@@ -40,6 +42,123 @@ JSClass("JSAttributedString", JSObject, {
40
42
  this._runs = [run];
41
43
  },
42
44
 
45
+ initFromDictionary: function(dictionary){
46
+ this._string = typeof(dictionary.string) === "string" ? dictionary.string : "";
47
+ this._runs = [];
48
+ var i, l;
49
+ var runDictionary;
50
+ var run;
51
+ var attributes;
52
+ var name;
53
+ var location = 0;
54
+ var length;
55
+ var maxLength = this._string.length;
56
+ var decodeAttribute = function(name, value){
57
+ switch (name){
58
+ case JSAttributedString.Attribute.font:
59
+ return JSAttributedString.AttributeDecoder.font(value);
60
+ case JSAttributedString.Attribute.textColor:
61
+ case JSAttributedString.Attribute.backgroundColor:
62
+ return JSAttributedString.AttributeDecoder.color(value);
63
+ case JSAttributedString.Attribute.link:
64
+ return JSAttributedString.AttributeDecoder.url(value);
65
+ case JSAttributedString.Attribute.cursor:
66
+ return JSAttributedString.AttributeDecoder.skip(value);
67
+ case JSAttributedString.Attribute.attachment:
68
+ // TODO:
69
+ return JSAttributedString.AttributeDecoder.skip(value);
70
+ case JSAttributedString.Attribute.maskCharacter:
71
+ return JSAttributedString.AttributeDecoder.string(value);
72
+ case JSAttributedString.Attribute.bold:
73
+ case JSAttributedString.Attribute.italic:
74
+ case JSAttributedString.Attribute.underline:
75
+ case JSAttributedString.Attribute.strike:
76
+ return JSAttributedString.AttributeDecoder.boolean(value);
77
+ case JSAttributedString.Attribute.lineHeight:
78
+ case JSAttributedString.Attribute.lineSpacing:
79
+ return JSAttributedString.AttributeDecoder.number(value);
80
+ case JSAttributedString.Attribute.textAlignment:
81
+ // TODO: validate
82
+ case JSAttributedString.Attribute.lineBreakMode:
83
+ // TODO: validate
84
+ default:
85
+ return value;
86
+ }
87
+
88
+ };
89
+ if (dictionary.runs instanceof Array){
90
+ for (i = 0, l = dictionary.runs.length; i < l && maxLength > 0; ++i){
91
+ runDictionary = dictionary.runs[i];
92
+ attributes = {};
93
+ length = typeof(runDictionary.length) === "number" ? Math.min(maxLength, Math.floor(runDictionary.length)) : 0;
94
+ if (length > 0 && typeof(runDictionary.attributes) === "object"){
95
+ for (name in runDictionary.attributes){
96
+ attributes[name] = decodeAttribute(name, runDictionary.attributes[name]);
97
+ }
98
+ this._runs.push(JSAttributedStringRun(JSRange(location, length), attributes));
99
+ }
100
+ location += length;
101
+ maxLength -= length;
102
+ }
103
+ }
104
+ if (maxLength > 0){
105
+ this._runs.push(JSAttributedStringRun(JSRange(location, maxLength), {}));
106
+ }
107
+ if (this._runs.length === 0){
108
+ this._runs.push(JSAttributedStringRun(JSRange(0, 0), {}));
109
+ }
110
+ },
111
+
112
+ dictionaryRepresentation: function(){
113
+ var dictionary = {
114
+ string: this._string,
115
+ runs: []
116
+ };
117
+ var i, l;
118
+ var run;
119
+ var name;
120
+ var runDictionary;
121
+ var encodeAttribute = function(name, value){
122
+ switch (name){
123
+ case JSAttributedString.Attribute.font:
124
+ return JSAttributedString.AttributeEncoder.font(value);
125
+ case JSAttributedString.Attribute.textColor:
126
+ case JSAttributedString.Attribute.backgroundColor:
127
+ return JSAttributedString.AttributeEncoder.color(value);
128
+ case JSAttributedString.Attribute.link:
129
+ return JSAttributedString.AttributeEncoder.url(value);
130
+ case JSAttributedString.Attribute.cursor:
131
+ return JSAttributedString.Attribute.Encoder.skip(value);
132
+ case JSAttributedString.Attribute.attachment:
133
+ // TODO:
134
+ return JSAttributedString.Attribute.Encoder.skip(value);
135
+ case JSAttributedString.Attribute.bold:
136
+ case JSAttributedString.Attribute.italic:
137
+ case JSAttributedString.Attribute.underline:
138
+ case JSAttributedString.Attribute.strike:
139
+ case JSAttributedString.Attribute.lineHeight:
140
+ case JSAttributedString.Attribute.lineSpacing:
141
+ case JSAttributedString.Attribute.textAlignment:
142
+ case JSAttributedString.Attribute.lineBreakMode:
143
+ case JSAttributedString.Attribute.maskCharacter:
144
+ default:
145
+ return value;
146
+ }
147
+ };
148
+ for (i = 0, l = this._runs.length; i < l; ++i){
149
+ run = this._runs[i];
150
+ runDictionary = {
151
+ length: run.range.length,
152
+ attributes: {}
153
+ };
154
+ for (name in run.attributes){
155
+ runDictionary.attributes[name] = encodeAttribute(name, run.attributes[name]);
156
+ }
157
+ dictionary.runs.push(runDictionary);
158
+ }
159
+ return dictionary;
160
+ },
161
+
43
162
  initWithAttributedString: function(attributedString, defaultAttributes){
44
163
  this._string = attributedString.string;
45
164
  this._runs = [];
@@ -481,6 +600,31 @@ JSAttributedString.Attribute = {
481
600
  link: "link"
482
601
  };
483
602
 
603
+ JSAttributedString.AttributeEncoder = {
604
+ skip: function(value){ return undefined; },
605
+ identity: function(value){ return value; },
606
+ dataBase64: function(value){ return value.base64StringRepresentation(); },
607
+ dataBase64URL: function(value){ return value.base64URLStringRepresentation(); },
608
+ dataHex: function(value){ return value.hexStringRepresentation(); },
609
+ url: function(value){ return value.encodedString; },
610
+ font: function(value){ return value.dictionaryRepresentation(); },
611
+ color: function(value){ return value.dictionaryRepresentation(); },
612
+ };
613
+
614
+ JSAttributedString.AttributeDecoder = {
615
+ skip: function(value){ return undefined; },
616
+ identity: function(value){ return value; },
617
+ dataBase64: function(value){ return value.dataByDecodingBase64(); },
618
+ dataBase64URL: function(value){ return value.dataByDecodingBase64URL(); },
619
+ dataHex: function(value){ return value.dataByDecodingHex(); },
620
+ url: function(value){ return JSURL.initWithString(value); },
621
+ font: function(value){ return JSFont.initFromDictionary(value); },
622
+ color: function(value){ return JSColor.initFromDictionary(value); },
623
+ boolean: function(value){ return typeof(value) === "boolean" ? value : undefined; },
624
+ number: function(value){ return typeof(value) === "number" ? value : undefined; },
625
+ string: function(value){ return typeof(value) === "string" ? value : undefined; },
626
+ };
627
+
484
628
  JSAttributedString.SpecialCharacter = {
485
629
  attachment: 0xFFFC,
486
630
  attachmentUTF16: "\uFFFC"
@@ -49,7 +49,7 @@ JSClass("JSFont", JSObject, {
49
49
  var weight;
50
50
  var style;
51
51
  var size;
52
- var defaults = JSFont._systemFontDescriptor;
52
+ var defaults = JSFontDescriptor.system;
53
53
  // if ('descriptor' in values){
54
54
  // values = values.descriptor;
55
55
  // }
@@ -78,7 +78,7 @@ JSClass("JSFont", JSObject, {
78
78
  size = JSFont.Size.normal;
79
79
  }
80
80
  if (family){
81
- var descriptor = JSResourceFontDescriptor.descriptorWithFamily(family, weight, style);
81
+ var descriptor = JSFontDescriptor.descriptorWithFamily(family, weight, style);
82
82
  if (descriptor !== null){
83
83
  return JSFont.initWithDescriptor(descriptor, size);
84
84
  }
@@ -86,6 +86,30 @@ JSClass("JSFont", JSObject, {
86
86
  return null;
87
87
  },
88
88
 
89
+ initFromDictionary: function(dictionary){
90
+ var descriptor = JSFontDescriptor.descriptorWithFamily(dictionary.family, dictionary.weight, dictionary.style);
91
+ if (descriptor === null){
92
+ if (dictionary.url){
93
+ descriptor = JSURLFontDescriptor.initWithURL(JSURL.initWithString(dictionary.url), dictionary.family, dictionary.weight, dictionary.style);
94
+ JSFontDescriptor.registerDescriptor(descriptor);
95
+ }
96
+ }
97
+ if (descriptor !== null){
98
+ return JSFont.initWithDescriptor(descriptor, dictionary.size);
99
+ }
100
+ return null;
101
+ },
102
+
103
+ dictionaryRepresentation: function(){
104
+ return {
105
+ url: this.descriptor instanceof JSURLFontDescriptor ? this._descriptor.url : undefined,
106
+ family: this._descriptor.family,
107
+ weight: this._descriptor.weight,
108
+ style: this._descriptor.style,
109
+ size: this.pointSize
110
+ };
111
+ },
112
+
89
113
  getFullName: function(){
90
114
  return this._descriptor.name;
91
115
  },
@@ -187,7 +211,7 @@ JSClass("JSFont", JSObject, {
187
211
  });
188
212
 
189
213
  JSFont.fontWithFamily = function(family, pointSize, weight, style){
190
- var descriptor = JSResourceFontDescriptor.descriptorWithFamily(family, weight || JSFont.Weight.regular, style || JSFont.Style.normal);
214
+ var descriptor = JSFontDescriptor.descriptorWithFamily(family, weight || JSFont.Weight.regular, style || JSFont.Style.normal);
191
215
  return JSFont.initWithDescriptor(descriptor, pointSize);
192
216
  };
193
217
 
@@ -204,12 +228,12 @@ JSFont.registerBundleFonts = function(bundle){
204
228
 
205
229
  JSFont._registerFontResource = function(bundle, metadata){
206
230
  var descriptor = JSResourceFontDescriptor.initWithMetadata(bundle, metadata);
231
+ JSFontDescriptor.registerDescriptor(descriptor);
207
232
  return descriptor;
208
233
  };
209
234
 
210
- JSFont._systemFontDescriptor = null;
211
-
212
- JSFont.registerSystemFontResource = function(name){
235
+ JSFont.registerSystemFontResource = function(name, bundle){
236
+ bundle = bundle || JSBundle.mainBundle;
213
237
  var ext;
214
238
  var extIndex = name.lastIndexOf('.');
215
239
  var i, l;
@@ -221,33 +245,33 @@ JSFont.registerSystemFontResource = function(name){
221
245
  extGuessed = true;
222
246
  ext = "ttf";
223
247
  }
224
- var metadata = JSBundle.mainBundle.metadataForResourceName(name, ext);
248
+ var metadata = bundle.metadataForResourceName(name, ext);
225
249
  if (extGuessed && metadata === null){
226
250
  ext = "otf";
227
- metadata = JSBundle.mainBundle.metadataForResourceName(name, ext);
251
+ metadata = bundle.metadataForResourceName(name, ext);
228
252
  }
229
- this._systemFontDescriptor = JSResourceFontDescriptor.descriptorsByName[metadata.font.unique_identifier];
253
+ JSFontDescriptor.system = JSResourceFontDescriptor.descriptorsByName[metadata.font.unique_identifier];
230
254
  };
231
255
 
232
256
  JSFont.registerSystemFont = function(familyName, weight, style){
233
- this._systemFontDescriptor = JSResourceFontDescriptor.descriptorWithFamily(familyName, weight || JSFont.Weight.regular, style || JSFont.Style.normal);
257
+ JSFontDescriptor.system = JSFontDescriptor.descriptorWithFamily(familyName, weight || JSFont.Weight.regular, style || JSFont.Style.normal);
234
258
  };
235
259
 
236
260
  JSFont.registerSystemFontDescriptor = function(descriptor){
237
- this._systemFontDescriptor = descriptor;
261
+ JSFontDescriptor.system = descriptor;
238
262
  };
239
263
 
240
264
  JSFont.unregisterAllFonts = function(){
241
- JSResourceFontDescriptor.descriptorsByFamily = {};
265
+ JSFontDescriptor.descriptorsByFamily = {};
242
266
  JSResourceFontDescriptor.descriptorsByName = {};
243
- this._systemFontDescriptor = null;
267
+ JSFontDescriptor.system = null;
244
268
  };
245
269
 
246
270
  JSFont.systemFontOfSize = function(pointSize){
247
- if (this._systemFontDescriptor === null){
271
+ if (JSFontDescriptor.system === null){
248
272
  return null;
249
273
  }
250
- return JSFont.initWithDescriptor(this._systemFontDescriptor, pointSize);
274
+ return JSFont.initWithDescriptor(JSFontDescriptor.system, pointSize);
251
275
  };
252
276
 
253
277
  JSFont.Size = {
@@ -94,4 +94,12 @@ JSDataFontDescriptor.definePropertiesFromExtensions({
94
94
 
95
95
  });
96
96
 
97
+ JSURLFontDescriptor.definePropertiesFromExtensions({
98
+
99
+ htmlURLString: function(){
100
+ return this.url.encodedString;
101
+ }
102
+
103
+ });
104
+
97
105
  })();