@breakside/jskit 2021.36.0 → 2021.39.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.
- package/Frameworks/DOM.jsframework/Info.json +2 -2
- 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/JSColor+HTML.js +11 -2
- package/Frameworks/Foundation.jsframework/JS/JSColor.js +62 -26
- package/Frameworks/Foundation.jsframework/JS/JSColorSpace.js +209 -1
- package/Frameworks/Foundation.jsframework/JS/JSSpec.js +1 -1
- package/Frameworks/Foundation.jsframework/JS/JSSynchronizer.js +9 -1
- package/Frameworks/Foundation.jsframework/JS/JSURL.js +42 -3
- package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
- 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/HTMLBuilder.js +10 -10
- package/Node/NodeBuilder.js +10 -7
- package/Node/io.breakside.jskit-bundle.js +4 -4
- package/Resources/doc-default.css +86 -0
- 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/Info.yaml +1 -1
- package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
- package/Root/Frameworks/DBKit/Info.yaml +1 -1
- 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/JSColor+HTML.js +11 -2
- package/Root/Frameworks/Foundation/JSColor.js +62 -26
- package/Root/Frameworks/Foundation/JSColorSpace.js +209 -1
- package/Root/Frameworks/Foundation/JSSpec.js +1 -1
- package/Root/Frameworks/Foundation/JSSynchronizer.js +9 -1
- package/Root/Frameworks/Foundation/JSURL.js +42 -3
- 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/ServerKit/SKValidatingObject.js +21 -0
- 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/JSColor+UIKit.js +75 -0
- package/Root/Frameworks/UIKit/UIAccessibility.js +15 -0
- package/Root/Frameworks/UIKit/UIActivityIndicatorView.js +2 -1
- package/Root/Frameworks/UIKit/UIAlertController.js +4 -3
- package/Root/Frameworks/UIKit/UIAnimation.js +7 -13
- package/Root/Frameworks/UIKit/UIApplication.js +3 -0
- package/Root/Frameworks/UIKit/UIBasicAnimation.js +6 -0
- package/Root/Frameworks/UIKit/UIButton.js +48 -25
- package/Root/Frameworks/UIKit/UICheckbox.js +11 -22
- package/Root/Frameworks/UIKit/UIColorPanel.js +27 -15
- package/Root/Frameworks/UIKit/UIColorSpace.js +132 -0
- package/Root/Frameworks/UIKit/UIColorWell.js +18 -2
- package/Root/Frameworks/UIKit/UIControl.js +15 -4
- package/Root/Frameworks/UIKit/UIHTMLDisplayServer.js +1 -5
- package/Root/Frameworks/UIKit/UIHTMLTextField.js +3 -15
- package/Root/Frameworks/UIKit/UIHTMLWindowServer.js +72 -1
- package/Root/Frameworks/UIKit/UIImageView.js +4 -0
- package/Root/Frameworks/UIKit/UIKit.js +2 -0
- package/Root/Frameworks/UIKit/UILabel.js +14 -2
- package/Root/Frameworks/UIKit/UILayer.js +29 -1
- package/Root/Frameworks/UIKit/UIListView.js +23 -12
- package/Root/Frameworks/UIKit/UIListViewCell.js +10 -2
- package/Root/Frameworks/UIKit/UIMenu.js +21 -13
- package/Root/Frameworks/UIKit/UIMenuBar.js +5 -4
- package/Root/Frameworks/UIKit/UIMenuView.js +9 -5
- package/Root/Frameworks/UIKit/UINavigationBar.js +8 -5
- package/Root/Frameworks/UIKit/UINavigationController.js +3 -2
- package/Root/Frameworks/UIKit/UIOutlineViewCell.js +2 -1
- package/Root/Frameworks/UIKit/UIPopupButton.js +13 -24
- package/Root/Frameworks/UIKit/UIPopupWindow.js +3 -2
- package/Root/Frameworks/UIKit/UIProgressIndicatorView.js +1 -1
- package/Root/Frameworks/UIKit/UIRadioGroup.js +11 -22
- package/Root/Frameworks/UIKit/UIScroller.js +4 -3
- package/Root/Frameworks/UIKit/UISegmentedControl.js +16 -15
- package/Root/Frameworks/UIKit/UISlider.js +20 -36
- package/Root/Frameworks/UIKit/UISplitView.js +40 -0
- package/Root/Frameworks/UIKit/UISplitViewController.js +7 -7
- package/Root/Frameworks/UIKit/UISplitViewDivider.js +9 -0
- package/Root/Frameworks/UIKit/UITabView.js +34 -31
- package/Root/Frameworks/UIKit/UITextEditor.js +2 -1
- package/Root/Frameworks/UIKit/UITextField.js +34 -23
- package/Root/Frameworks/UIKit/UITextLayer.js +5 -0
- package/Root/Frameworks/UIKit/UITokenField.js +3 -3
- package/Root/Frameworks/UIKit/UIToolbar.js +84 -38
- package/Root/Frameworks/UIKit/UIToolbarOverflow.svg +8 -0
- package/Root/Frameworks/UIKit/UITooltipWindow.js +38 -15
- package/Root/Frameworks/UIKit/UITraitCollection.js +21 -0
- package/Root/Frameworks/UIKit/UIUserInterface.js +6 -0
- package/Root/Frameworks/UIKit/UIWebView.js +3 -2
- package/Root/Frameworks/UIKit/UIWindow.js +139 -21
- package/Root/Frameworks/UIKit/UIWindowButtonCloseInactive.svg +1 -1
- package/Root/Frameworks/UIKit/UIWindowButtonCloseNormal.svg +1 -1
- package/Root/Frameworks/UIKit/UIWindowServer.js +72 -9
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/Root/Templates/html/${PROJECT_NAME}/www/index.html +24 -4
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"JSBundleType": "framework",
|
|
3
3
|
"JSBundleIdentifier": "io.breakside.JSKit.DOM",
|
|
4
|
-
"JSBundleVersion": "2021.
|
|
4
|
+
"JSBundleVersion": "2021.39.0",
|
|
5
5
|
"JSDevelopmentLanguage": "en",
|
|
6
6
|
"JSCopyright": "Copyright © 2020 Breakside Inc.",
|
|
7
7
|
"JSBundleEnvironments": {
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
"node": "DOM+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": "
|
|
12
|
+
"GitRevision": "8e2a12a2f49c7be2623e2ac6d371a68b2cdfeaa5"
|
|
13
13
|
}
|
|
@@ -3,7 +3,7 @@ JSBundle.bundles['io.breakside.JSKit.DOM'] = {
|
|
|
3
3
|
"Info": {
|
|
4
4
|
"JSBundleType": "framework",
|
|
5
5
|
"JSBundleIdentifier": "io.breakside.JSKit.DOM",
|
|
6
|
-
"JSBundleVersion": "2021.
|
|
6
|
+
"JSBundleVersion": "2021.39.0",
|
|
7
7
|
"JSDevelopmentLanguage": "en",
|
|
8
8
|
"JSCopyright": "Copyright © 2020 Breakside Inc.",
|
|
9
9
|
"JSBundleEnvironments": {
|
|
@@ -11,7 +11,7 @@ JSBundle.bundles['io.breakside.JSKit.DOM'] = {
|
|
|
11
11
|
"node": "DOM+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": "
|
|
14
|
+
"GitRevision": "8e2a12a2f49c7be2623e2ac6d371a68b2cdfeaa5"
|
|
15
15
|
},
|
|
16
16
|
"Resources": [],
|
|
17
17
|
"ResourceLookup": {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"JSBundleType": "framework",
|
|
3
3
|
"JSBundleIdentifier": "io.breakside.JSKit.FontKit",
|
|
4
|
-
"JSBundleVersion": "2021.
|
|
4
|
+
"JSBundleVersion": "2021.39.0",
|
|
5
5
|
"JSDevelopmentLanguage": "en",
|
|
6
6
|
"JSCopyright": "Copyright © 2020 Breakside Inc.",
|
|
7
7
|
"JSBundleEnvironments": {
|
|
8
8
|
"html": "FontKit+HTML.js"
|
|
9
9
|
},
|
|
10
10
|
"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",
|
|
11
|
-
"GitRevision": "
|
|
11
|
+
"GitRevision": "8e2a12a2f49c7be2623e2ac6d371a68b2cdfeaa5"
|
|
12
12
|
}
|
|
@@ -3,14 +3,14 @@ JSBundle.bundles['io.breakside.JSKit.FontKit'] = {
|
|
|
3
3
|
"Info": {
|
|
4
4
|
"JSBundleType": "framework",
|
|
5
5
|
"JSBundleIdentifier": "io.breakside.JSKit.FontKit",
|
|
6
|
-
"JSBundleVersion": "2021.
|
|
6
|
+
"JSBundleVersion": "2021.39.0",
|
|
7
7
|
"JSDevelopmentLanguage": "en",
|
|
8
8
|
"JSCopyright": "Copyright © 2020 Breakside Inc.",
|
|
9
9
|
"JSBundleEnvironments": {
|
|
10
10
|
"html": "FontKit+HTML.js"
|
|
11
11
|
},
|
|
12
12
|
"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",
|
|
13
|
-
"GitRevision": "
|
|
13
|
+
"GitRevision": "8e2a12a2f49c7be2623e2ac6d371a68b2cdfeaa5"
|
|
14
14
|
},
|
|
15
15
|
"Resources": [],
|
|
16
16
|
"ResourceLookup": {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"JSBundleType": "framework",
|
|
3
3
|
"JSBundleIdentifier": "io.breakside.JSKit.Foundation",
|
|
4
|
-
"JSBundleVersion": "2021.
|
|
4
|
+
"JSBundleVersion": "2021.39.0",
|
|
5
5
|
"JSDevelopmentLanguage": "en",
|
|
6
6
|
"JSCopyright": "Copyright © 2020 Breakside Inc.",
|
|
7
7
|
"JSBundleEnvironments": {
|
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
"node": "Foundation+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": "
|
|
12
|
+
"GitRevision": "8e2a12a2f49c7be2623e2ac6d371a68b2cdfeaa5"
|
|
13
13
|
}
|
|
@@ -19,12 +19,21 @@
|
|
|
19
19
|
JSColor.definePropertiesFromExtensions({
|
|
20
20
|
|
|
21
21
|
_cachedCSSString: null,
|
|
22
|
+
_cachedCSSNumber: -1,
|
|
22
23
|
|
|
23
24
|
cssString: function(){
|
|
24
|
-
if (this._cachedCSSString === null){
|
|
25
|
+
if (this._cachedCSSString === null || this._cachedCSSNumber !== JSColorSpace._cssCacheNumber){
|
|
25
26
|
var rgbaColor = this.rgbaColor();
|
|
26
27
|
this._cachedCSSString = 'rgba(%d, %d, %d, %f)'.sprintf(Math.round(rgbaColor.components[0] * 255), Math.round(rgbaColor.components[1] * 255), Math.round(rgbaColor.components[2] * 255), rgbaColor.components[3]);
|
|
28
|
+
this._cachedCSSNumber = JSColor._cssCacheNumber;
|
|
27
29
|
}
|
|
28
30
|
return this._cachedCSSString;
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
JSColor._cssCacheNumber = 0;
|
|
36
|
+
|
|
37
|
+
JSColor.invalidateCSSCache = function(){
|
|
38
|
+
++JSColor._cssCacheNumber;
|
|
39
|
+
};
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// #import "JSObject.js"
|
|
17
17
|
// #import "CoreTypes.js"
|
|
18
18
|
// #import "JSColorSpace.js"
|
|
19
|
+
/* global JSBundle, JSSpec */
|
|
19
20
|
'use strict';
|
|
20
21
|
|
|
21
22
|
(function(){
|
|
@@ -153,12 +154,19 @@ JSClass('JSColor', JSObject, {
|
|
|
153
154
|
},
|
|
154
155
|
|
|
155
156
|
initWithBlendedColor: function(base, otherColor, blendPercentage){
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
while (base._space instanceof JSMappedColorSpace){
|
|
158
|
+
base = base._space.colorFromComponents(base._components);
|
|
159
|
+
}
|
|
160
|
+
while (otherColor._space instanceof JSMappedColorSpace){
|
|
161
|
+
otherColor = otherColor._space.colorFromComponents(otherColor._components);
|
|
162
|
+
}
|
|
163
|
+
if (base.space !== otherColor.space || !base.space.canMixComponents){
|
|
164
|
+
base = base.rgbaColor();
|
|
165
|
+
otherColor = otherColor.rgbaColor();
|
|
166
|
+
}
|
|
167
|
+
var components = base.space.mixedComponents(base.components, otherColor.components, blendPercentage);
|
|
168
|
+
components.push(base.alpha);
|
|
169
|
+
this.initWithSpaceAndComponents(base.space, components);
|
|
162
170
|
},
|
|
163
171
|
|
|
164
172
|
initWithSpec: function(spec){
|
|
@@ -180,12 +188,38 @@ JSClass('JSColor', JSObject, {
|
|
|
180
188
|
}
|
|
181
189
|
this.initWithRGBA.apply(this, components);
|
|
182
190
|
}else if (spec.containsKey("white")){
|
|
183
|
-
|
|
191
|
+
var white = spec.valueForKey("white");
|
|
192
|
+
components = white.parseNumberArray();
|
|
193
|
+
this.initWithWhite.apply(this, components);
|
|
184
194
|
}else if (spec.containsKey("blendBase") && spec.containsKey("with") && spec.containsKey("percent")){
|
|
185
195
|
var base = spec.valueForKey("blendBase", JSColor);
|
|
186
196
|
var otherColor = spec.valueForKey("with", JSColor);
|
|
187
197
|
var blendPercentage = spec.valueForKey("percent") / 100;
|
|
188
198
|
this.initWithBlendedColor(base, otherColor, blendPercentage);
|
|
199
|
+
}else if (spec.containsKey("space")){
|
|
200
|
+
var spaceName = spec.valueForKey("space");
|
|
201
|
+
var space = JSColorSpace[spaceName];
|
|
202
|
+
if (space === undefined){
|
|
203
|
+
throw new Error("Unknown color space: %s".sprintf(spaceName));
|
|
204
|
+
}
|
|
205
|
+
components = [];
|
|
206
|
+
for (var componentName in space.componentNames){
|
|
207
|
+
if (!spec.containsKey(componentName)){
|
|
208
|
+
throw new Error("Missing component %s for color in space: %s".sprintf(componentName, spaceName));
|
|
209
|
+
}
|
|
210
|
+
components[space.componentNames[componentName]] = spec.valueForKey(componentName);
|
|
211
|
+
}
|
|
212
|
+
if (space instanceof JSMappedColorSpace){
|
|
213
|
+
components.push(1);
|
|
214
|
+
}
|
|
215
|
+
var alpha = 1;
|
|
216
|
+
if (spec.containsKey("alpha")){
|
|
217
|
+
alpha = spec.valueForKey("alpha");
|
|
218
|
+
}else if (space instanceof JSMappedColorSpace){
|
|
219
|
+
alpha = -1;
|
|
220
|
+
}
|
|
221
|
+
components.push(alpha);
|
|
222
|
+
this.initWithSpaceAndComponents(space, components);
|
|
189
223
|
}
|
|
190
224
|
},
|
|
191
225
|
|
|
@@ -196,12 +230,7 @@ JSClass('JSColor', JSObject, {
|
|
|
196
230
|
if (this._space !== other._space){
|
|
197
231
|
return false;
|
|
198
232
|
}
|
|
199
|
-
|
|
200
|
-
if (Math.round(this._components[i] * 255) != Math.round(other._components[i] * 255)){
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return true;
|
|
233
|
+
return this._space.compareComponents(this._components, other._components) && Math.round(this.alpha * 255) === Math.round(other.alpha * 255);
|
|
205
234
|
},
|
|
206
235
|
|
|
207
236
|
toString: function(){
|
|
@@ -209,21 +238,29 @@ JSClass('JSColor', JSObject, {
|
|
|
209
238
|
},
|
|
210
239
|
|
|
211
240
|
getAlpha: function(){
|
|
212
|
-
|
|
241
|
+
var alpha = this._components[this._space.numberOfComponents];
|
|
242
|
+
if (alpha < 0){
|
|
243
|
+
alpha = this._space.alphaFromComponents(this._components);
|
|
244
|
+
}
|
|
245
|
+
return alpha;
|
|
213
246
|
},
|
|
214
247
|
|
|
215
248
|
colorWithAlpha: function(alpha){
|
|
216
249
|
var components = JSCopy(this._components);
|
|
217
|
-
components[
|
|
250
|
+
components[this._space.numberOfComponents] = alpha;
|
|
218
251
|
return JSColor.initWithSpaceAndComponents(this._space, components);
|
|
219
252
|
},
|
|
220
253
|
|
|
221
254
|
colorDarkenedByPercentage: function(darkenPercentage){
|
|
222
|
-
|
|
255
|
+
var components = this._space.componentsDarkenedByPercentage(this._components, darkenPercentage);
|
|
256
|
+
components.push(this.alpha);
|
|
257
|
+
return JSColor.initWithSpaceAndComponents(this._space, components);
|
|
223
258
|
},
|
|
224
259
|
|
|
225
260
|
colorLightenedByPercentage: function(lightenPercentage){
|
|
226
|
-
|
|
261
|
+
var components = this._space.componentsLightenedByPercentage(this._components, lightenPercentage);
|
|
262
|
+
components.push(this.alpha);
|
|
263
|
+
return JSColor.initWithSpaceAndComponents(this._space, components);
|
|
227
264
|
},
|
|
228
265
|
|
|
229
266
|
colorByBlendingColor: function(otherColor, blendPercentage){
|
|
@@ -231,7 +268,6 @@ JSClass('JSColor', JSObject, {
|
|
|
231
268
|
},
|
|
232
269
|
|
|
233
270
|
rgbaColor: function(){
|
|
234
|
-
var components;
|
|
235
271
|
if (this._space === JSColorSpace.rgb){
|
|
236
272
|
return this;
|
|
237
273
|
}
|
|
@@ -241,7 +277,6 @@ JSClass('JSColor', JSObject, {
|
|
|
241
277
|
},
|
|
242
278
|
|
|
243
279
|
grayColor: function(){
|
|
244
|
-
var components;
|
|
245
280
|
if (this._space === JSColorSpace.gray){
|
|
246
281
|
return this;
|
|
247
282
|
}
|
|
@@ -268,7 +303,7 @@ JSClass('JSColor', JSObject, {
|
|
|
268
303
|
}
|
|
269
304
|
return {
|
|
270
305
|
space: this._space.name,
|
|
271
|
-
components: JSCopy(this.
|
|
306
|
+
components: JSCopy(this._components)
|
|
272
307
|
};
|
|
273
308
|
},
|
|
274
309
|
|
|
@@ -344,7 +379,7 @@ Object.defineProperties(JSColor, {
|
|
|
344
379
|
configurable: true,
|
|
345
380
|
get: function JSColor_getClearColor(){
|
|
346
381
|
var color = JSColor.initWithRGBA(0, 0, 0, 0);
|
|
347
|
-
Object.defineProperty(
|
|
382
|
+
Object.defineProperty(JSColor, 'clear', {value: color});
|
|
348
383
|
return color;
|
|
349
384
|
}
|
|
350
385
|
},
|
|
@@ -353,7 +388,7 @@ Object.defineProperties(JSColor, {
|
|
|
353
388
|
configurable: true,
|
|
354
389
|
get: function JSColor_getWhiteColor(){
|
|
355
390
|
var color = JSColor.initWithWhite(1.0);
|
|
356
|
-
Object.defineProperty(
|
|
391
|
+
Object.defineProperty(JSColor, 'white', {value: color});
|
|
357
392
|
return color;
|
|
358
393
|
}
|
|
359
394
|
},
|
|
@@ -362,7 +397,7 @@ Object.defineProperties(JSColor, {
|
|
|
362
397
|
configurable: true,
|
|
363
398
|
get: function JSColor_getBlackColor(){
|
|
364
399
|
var color = JSColor.initWithWhite(0);
|
|
365
|
-
Object.defineProperty(
|
|
400
|
+
Object.defineProperty(JSColor, 'black', {value: color});
|
|
366
401
|
return color;
|
|
367
402
|
}
|
|
368
403
|
},
|
|
@@ -371,7 +406,7 @@ Object.defineProperties(JSColor, {
|
|
|
371
406
|
configurable: true,
|
|
372
407
|
get: function JSColor_getBlackColor(){
|
|
373
408
|
var color = JSColor.initWithRGBA(1.0, 0, 0);
|
|
374
|
-
Object.defineProperty(
|
|
409
|
+
Object.defineProperty(JSColor, 'red', {value: color});
|
|
375
410
|
return color;
|
|
376
411
|
}
|
|
377
412
|
},
|
|
@@ -380,7 +415,7 @@ Object.defineProperties(JSColor, {
|
|
|
380
415
|
configurable: true,
|
|
381
416
|
get: function JSColor_getBlackColor(){
|
|
382
417
|
var color = JSColor.initWithRGBA(0, 1.0, 0);
|
|
383
|
-
Object.defineProperty(
|
|
418
|
+
Object.defineProperty(JSColor, 'green', {value: color});
|
|
384
419
|
return color;
|
|
385
420
|
}
|
|
386
421
|
},
|
|
@@ -389,13 +424,14 @@ Object.defineProperties(JSColor, {
|
|
|
389
424
|
configurable: true,
|
|
390
425
|
get: function JSColor_getBlackColor(){
|
|
391
426
|
var color = JSColor.initWithRGBA(0, 0, 1.0);
|
|
392
|
-
Object.defineProperty(
|
|
427
|
+
Object.defineProperty(JSColor, 'blue', {value: color});
|
|
393
428
|
return color;
|
|
394
429
|
}
|
|
395
430
|
},
|
|
396
431
|
|
|
397
432
|
});
|
|
398
433
|
|
|
434
|
+
|
|
399
435
|
JSColor.contentType = "x-jskit/jscolor";
|
|
400
436
|
|
|
401
437
|
})();
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
// #import "JSObject.js"
|
|
17
17
|
// #import "CoreTypes.js"
|
|
18
|
+
/* global JSSpec, JSBundle, JSColor */
|
|
18
19
|
'use strict';
|
|
19
20
|
|
|
20
21
|
(function(){
|
|
@@ -22,6 +23,7 @@
|
|
|
22
23
|
JSClass("JSColorSpace", JSObject, {
|
|
23
24
|
|
|
24
25
|
numberOfComponents: 0,
|
|
26
|
+
canMixComponents: true,
|
|
25
27
|
|
|
26
28
|
rgbFromComponents: function(components){
|
|
27
29
|
return JSColorSpace.rgb.componentsFromSpace(this, components);
|
|
@@ -31,6 +33,10 @@ JSClass("JSColorSpace", JSObject, {
|
|
|
31
33
|
return JSColorSpace.gray.componentsFromSpace(this, components);
|
|
32
34
|
},
|
|
33
35
|
|
|
36
|
+
alphaFromComponents: function(components){
|
|
37
|
+
return 1;
|
|
38
|
+
},
|
|
39
|
+
|
|
34
40
|
xyzFromComponents: function(components){
|
|
35
41
|
},
|
|
36
42
|
|
|
@@ -45,7 +51,36 @@ JSClass("JSColorSpace", JSObject, {
|
|
|
45
51
|
}
|
|
46
52
|
var xyz = space.xyzFromComponents(components);
|
|
47
53
|
return this.componentsFromXYZ(xyz);
|
|
48
|
-
}
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
mixedComponents: function(a, b, percentage){
|
|
57
|
+
var mixed = [];
|
|
58
|
+
for (var i = 0; i < this.numberOfComponents; ++i){
|
|
59
|
+
mixed.push(a[i] + (b[i] - a[i]) * percentage);
|
|
60
|
+
}
|
|
61
|
+
return mixed;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
componentsDarkenedByPercentage: function(components, percentage){
|
|
65
|
+
var rgb = this.rgbFromComponents(components);
|
|
66
|
+
var darkenedRGB = JSColorSpace.rgb.componentsDarkenedByPercentage(rgb, percentage);
|
|
67
|
+
return this.componentsFromSpace(JSColorSpace.rgb, darkenedRGB);
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
componentsLightenedByPercentage: function(components, percentage){
|
|
71
|
+
var rgb = this.rgbFromComponents(components);
|
|
72
|
+
var lightenedRGB = JSColorSpace.rgb.componentsLightenedByPercentage(rgb, percentage);
|
|
73
|
+
return this.componentsFromSpace(JSColorSpace.rgb, lightenedRGB);
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
compareComponents: function(a, b){
|
|
77
|
+
for (var i = 0; i < this.numberOfComponents; ++i){
|
|
78
|
+
if (a[i] !== b[i]){
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
},
|
|
49
84
|
|
|
50
85
|
});
|
|
51
86
|
|
|
@@ -186,6 +221,22 @@ JSClass("JSRGBColorSpace", JSColorSpace, {
|
|
|
186
221
|
return [(components[0] + components[1] + components[2]) / 3];
|
|
187
222
|
},
|
|
188
223
|
|
|
224
|
+
componentsDarkenedByPercentage: function(components, percentage){
|
|
225
|
+
return [
|
|
226
|
+
components[0] - components[0] * percentage,
|
|
227
|
+
components[1] - components[1] * percentage,
|
|
228
|
+
components[2] - components[2] * percentage
|
|
229
|
+
];
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
componentsLightenedByPercentage: function(components, percentage){
|
|
233
|
+
return [
|
|
234
|
+
components[0] + (1.0 - components[0]) * percentage,
|
|
235
|
+
components[1] + (1.0 - components[1]) * percentage,
|
|
236
|
+
components[2] + (1.0 - components[2]) * percentage
|
|
237
|
+
];
|
|
238
|
+
},
|
|
239
|
+
|
|
189
240
|
// MARK: - Lab conversions
|
|
190
241
|
|
|
191
242
|
xyzFromComponents: function(components){
|
|
@@ -328,6 +379,15 @@ JSClass("JSRGBColorSpace", JSColorSpace, {
|
|
|
328
379
|
];
|
|
329
380
|
},
|
|
330
381
|
|
|
382
|
+
compareComponents: function(a, b){
|
|
383
|
+
for (var i = 0; i < this.numberOfComponents; ++i){
|
|
384
|
+
if (Math.round(a[i] * 255) !== Math.round(b[i] * 255)){
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
|
|
331
391
|
});
|
|
332
392
|
|
|
333
393
|
JSClass("JSGrayColorSpace", JSColorSpace, {
|
|
@@ -346,6 +406,27 @@ JSClass("JSGrayColorSpace", JSColorSpace, {
|
|
|
346
406
|
return [components[0]];
|
|
347
407
|
},
|
|
348
408
|
|
|
409
|
+
compareComponents: function(a, b){
|
|
410
|
+
for (var i = 0; i < this.numberOfComponents; ++i){
|
|
411
|
+
if (Math.round(a[i] * 255) !== Math.round(b[i] * 255)){
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
componentsDarkenedByPercentage: function(components, percentage){
|
|
419
|
+
return [
|
|
420
|
+
components[0] - components[0] * percentage
|
|
421
|
+
];
|
|
422
|
+
},
|
|
423
|
+
|
|
424
|
+
componentsLightenedByPercentage: function(components, percentage){
|
|
425
|
+
return [
|
|
426
|
+
components[0] + (1.0 - components[0]) * percentage
|
|
427
|
+
];
|
|
428
|
+
}
|
|
429
|
+
|
|
349
430
|
});
|
|
350
431
|
|
|
351
432
|
JSClass("JSDerivedColorSpace", JSColorSpace, {
|
|
@@ -382,6 +463,133 @@ JSClass("JSDerivedColorSpace", JSColorSpace, {
|
|
|
382
463
|
|
|
383
464
|
});
|
|
384
465
|
|
|
466
|
+
JSClass("JSMappedColorSpace", JSColorSpace, {
|
|
467
|
+
|
|
468
|
+
canMixComponents: false,
|
|
469
|
+
|
|
470
|
+
colorFromComponents: function(components){
|
|
471
|
+
},
|
|
472
|
+
|
|
473
|
+
rgbFromComponents: function(components){
|
|
474
|
+
var rgba = this.colorFromComponents(components).rgbaColor().components;
|
|
475
|
+
return [
|
|
476
|
+
rgba[0],
|
|
477
|
+
rgba[1],
|
|
478
|
+
rgba[2],
|
|
479
|
+
];
|
|
480
|
+
},
|
|
481
|
+
|
|
482
|
+
grayFromComponents: function(components){
|
|
483
|
+
var graya = this.colorFromComponents(components).grayColor().components;
|
|
484
|
+
return [
|
|
485
|
+
graya[0],
|
|
486
|
+
];
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
alphaFromComponents: function(components){
|
|
490
|
+
return this.colorFromComponents(components).alpha;
|
|
491
|
+
},
|
|
492
|
+
|
|
493
|
+
xyzFromComponents: function(components){
|
|
494
|
+
var rgb = this.rgbFromComponents(components);
|
|
495
|
+
return JSColorSpace.rgb.xyzFromComponents(rgb);
|
|
496
|
+
},
|
|
497
|
+
|
|
498
|
+
componentsFromXYZ: function(xyz){
|
|
499
|
+
throw new Error("Unable to convert from xyz -> %s mapped color space".sprintf(this.name));
|
|
500
|
+
},
|
|
501
|
+
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
JSClass("JSIndexedColorSpace", JSMappedColorSpace, {
|
|
505
|
+
|
|
506
|
+
name: "indexed",
|
|
507
|
+
numberOfComponents: 2,
|
|
508
|
+
componentNames: {"index": 0},
|
|
509
|
+
colors: null,
|
|
510
|
+
|
|
511
|
+
init: function(){
|
|
512
|
+
this.colors = [];
|
|
513
|
+
},
|
|
514
|
+
|
|
515
|
+
addColor: function(color){
|
|
516
|
+
var index = this.colors.length;
|
|
517
|
+
this.colors.push(color);
|
|
518
|
+
return JSColor.initWithSpaceAndComponents(this, [index, 1, -1]);
|
|
519
|
+
},
|
|
520
|
+
|
|
521
|
+
setColorAtIndex: function(color, index){
|
|
522
|
+
this.colors[index] = color;
|
|
523
|
+
},
|
|
524
|
+
|
|
525
|
+
colorFromComponents: function(components){
|
|
526
|
+
var color = this.colors[components[0]];
|
|
527
|
+
if (components[1] < 1){
|
|
528
|
+
color = color.colorDarkenedByPercentage(1 - components[1]);
|
|
529
|
+
}else if (components[1] > 1){
|
|
530
|
+
color = color.colorLightenedByPercentage(components[1] - 1);
|
|
531
|
+
}
|
|
532
|
+
return color;
|
|
533
|
+
},
|
|
534
|
+
|
|
535
|
+
componentsDarkenedByPercentage: function(components, percentage){
|
|
536
|
+
return [
|
|
537
|
+
components[0],
|
|
538
|
+
components[1] * (1.0 - percentage)
|
|
539
|
+
];
|
|
540
|
+
},
|
|
541
|
+
|
|
542
|
+
componentsLightenedByPercentage: function(components, percentage){
|
|
543
|
+
return [
|
|
544
|
+
components[0],
|
|
545
|
+
components[1] * (1.0 + percentage)
|
|
546
|
+
];
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
});
|
|
550
|
+
|
|
551
|
+
JSClass("JSNamedColorSpace", JSMappedColorSpace, {
|
|
552
|
+
|
|
553
|
+
name: "named",
|
|
554
|
+
numberOfComponents: 2,
|
|
555
|
+
componentNames: {"name": 0},
|
|
556
|
+
colors: null,
|
|
557
|
+
|
|
558
|
+
init: function(){
|
|
559
|
+
this.colors = {};
|
|
560
|
+
},
|
|
561
|
+
|
|
562
|
+
setColorForName: function(name, color){
|
|
563
|
+
this.colors[name] = color;
|
|
564
|
+
return JSColor.initWithSpaceAndComponents(this, [name, 1, -1]);
|
|
565
|
+
},
|
|
566
|
+
|
|
567
|
+
colorFromComponents: function(components){
|
|
568
|
+
var color = this.colors[components[0]];
|
|
569
|
+
if (components[1] < 1){
|
|
570
|
+
color = color.colorDarkenedByPercentage(1 - components[1]);
|
|
571
|
+
}else if (components[1] > 1){
|
|
572
|
+
color = color.colorLightenedByPercentage(components[1] - 1);
|
|
573
|
+
}
|
|
574
|
+
return color;
|
|
575
|
+
},
|
|
576
|
+
|
|
577
|
+
componentsDarkenedByPercentage: function(components, percentage){
|
|
578
|
+
return [
|
|
579
|
+
components[0],
|
|
580
|
+
components[1] * (1.0 - percentage)
|
|
581
|
+
];
|
|
582
|
+
},
|
|
583
|
+
|
|
584
|
+
componentsLightenedByPercentage: function(components, percentage){
|
|
585
|
+
return [
|
|
586
|
+
components[0],
|
|
587
|
+
components[1] * (1.0 + percentage)
|
|
588
|
+
];
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
});
|
|
592
|
+
|
|
385
593
|
Object.defineProperties(JSColorSpace, {
|
|
386
594
|
|
|
387
595
|
rgb: {
|
|
@@ -101,7 +101,15 @@ JSClass("JSSynchronizer", JSObject, {
|
|
|
101
101
|
},
|
|
102
102
|
};
|
|
103
103
|
try{
|
|
104
|
-
this.action.call(this.target, context);
|
|
104
|
+
var promise = this.action.call(this.target, context);
|
|
105
|
+
if (promise instanceof Promise){
|
|
106
|
+
context.started();
|
|
107
|
+
promise.then(function(){
|
|
108
|
+
context.completed();
|
|
109
|
+
}, function(error){
|
|
110
|
+
context.completed(error);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
105
113
|
}catch (e){
|
|
106
114
|
logger.error(e);
|
|
107
115
|
this.error = e;
|
|
@@ -361,9 +361,48 @@ JSClass("JSURL", JSObject, {
|
|
|
361
361
|
this._query = null;
|
|
362
362
|
},
|
|
363
363
|
|
|
364
|
+
_createQuery: function(other){
|
|
365
|
+
var url = this;
|
|
366
|
+
var query = Object.create(JSFormFieldMap.prototype, {
|
|
367
|
+
|
|
368
|
+
add: {
|
|
369
|
+
value: function(name, value){
|
|
370
|
+
JSFormFieldMap.prototype.add.call(this, name, value);
|
|
371
|
+
url._encodedQuery = this.urlEncoded();
|
|
372
|
+
if (url._encodedQuery.length === 0){
|
|
373
|
+
url._encodedQuery = null;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
|
|
378
|
+
set: {
|
|
379
|
+
value: function(name, value){
|
|
380
|
+
JSFormFieldMap.prototype.set.call(this, name, value);
|
|
381
|
+
url._encodedQuery = this.urlEncoded();
|
|
382
|
+
if (url._encodedQuery.length === 0){
|
|
383
|
+
url._encodedQuery = null;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
unset: {
|
|
389
|
+
value: function(name, value){
|
|
390
|
+
JSFormFieldMap.prototype.unset.call(this, name);
|
|
391
|
+
url._encodedQuery = this.urlEncoded();
|
|
392
|
+
if (url._encodedQuery.length === 0){
|
|
393
|
+
url._encodedQuery = null;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
});
|
|
399
|
+
JSFormFieldMap.call(query, other);
|
|
400
|
+
return query;
|
|
401
|
+
},
|
|
402
|
+
|
|
364
403
|
getQuery: function(){
|
|
365
404
|
if (this._query === null){
|
|
366
|
-
this._query =
|
|
405
|
+
this._query = this._createQuery();
|
|
367
406
|
if (this._encodedQuery !== null){
|
|
368
407
|
this._query.decode(this._encodedQuery, true);
|
|
369
408
|
}
|
|
@@ -373,9 +412,9 @@ JSClass("JSURL", JSObject, {
|
|
|
373
412
|
|
|
374
413
|
setQuery: function(query){
|
|
375
414
|
if (query === null){
|
|
376
|
-
this._query =
|
|
415
|
+
this._query = this._createQuery();
|
|
377
416
|
}else{
|
|
378
|
-
this._query =
|
|
417
|
+
this._query = this._createQuery(query);
|
|
379
418
|
}
|
|
380
419
|
this._encodedQuery = this._query.urlEncoded();
|
|
381
420
|
if (this._encodedQuery.length === 0){
|