@breakside/jskit 2021.46.0 → 2022.3.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.
Files changed (68) hide show
  1. package/Frameworks/DOM.jsframework/Info.json +2 -2
  2. package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
  3. package/Frameworks/FontKit.jsframework/Info.json +2 -2
  4. package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
  5. package/Frameworks/Foundation.jsframework/Info.json +2 -2
  6. package/Frameworks/Foundation.jsframework/JS/JSColor.js +9 -0
  7. package/Frameworks/Foundation.jsframework/JS/JSColorSpace.js +106 -20
  8. package/Frameworks/Foundation.jsframework/JS/JSMediaType.js +1 -1
  9. package/Frameworks/Foundation.jsframework/JS/JSTimer.js +6 -0
  10. package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
  11. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  12. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  13. package/Info.json +2 -2
  14. package/Node/io.breakside.jskit-bundle.js +2 -2
  15. package/Root/Frameworks/APIKit/APIRequest.js +99 -0
  16. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  17. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  18. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  19. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  20. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  21. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  22. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  23. package/Root/Frameworks/DOM/Info.yaml +1 -1
  24. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  25. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  26. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  27. package/Root/Frameworks/Foundation/JSColor.js +9 -0
  28. package/Root/Frameworks/Foundation/JSColorSpace.js +106 -20
  29. package/Root/Frameworks/Foundation/JSMediaType.js +1 -1
  30. package/Root/Frameworks/Foundation/JSTimer.js +6 -0
  31. package/Root/Frameworks/ImageKit/IKColorProfile.js +1091 -0
  32. package/Root/Frameworks/ImageKit/IKColorSpace.js +49 -198
  33. package/Root/Frameworks/ImageKit/IKMatrix.js +124 -0
  34. package/Root/Frameworks/ImageKit/ImageKit.js +2 -0
  35. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  36. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  37. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  38. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  39. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  40. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  41. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  42. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  43. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  44. package/Root/Frameworks/ServerKit/SKHTTPRequest.js +44 -0
  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/UIKit/UICollectionReusableView.js +91 -0
  49. package/Root/Frameworks/UIKit/UICollectionView.js +1254 -0
  50. package/Root/Frameworks/UIKit/UICollectionViewCell.js +121 -0
  51. package/Root/Frameworks/UIKit/UICollectionViewGridLayout.js +425 -0
  52. package/Root/Frameworks/UIKit/UICollectionViewLayout.js +82 -0
  53. package/Root/Frameworks/UIKit/UIColorWell.js +12 -1
  54. package/Root/Frameworks/UIKit/UIDisplayServer.js +5 -1
  55. package/Root/Frameworks/UIKit/UIKit.js +7 -0
  56. package/Root/Frameworks/UIKit/UILayer.js +3 -0
  57. package/Root/Frameworks/UIKit/UIListView.js +26 -11
  58. package/Root/Frameworks/UIKit/UIMenu.js +1 -1
  59. package/Root/Frameworks/UIKit/UIMenuView.js +5 -1
  60. package/Root/Frameworks/UIKit/UINavigationBar.js +2 -2
  61. package/Root/Frameworks/UIKit/UIPopupButton.js +31 -3
  62. package/Root/Frameworks/UIKit/UIScrollView.js +2 -0
  63. package/Root/Frameworks/UIKit/UISplitViewController.js +43 -9
  64. package/Root/Frameworks/UIKit/UITextField.js +3 -0
  65. package/Root/Frameworks/UIKit/UIView.js +3 -0
  66. package/Root/Frameworks/UIKit/UIViewController.js +11 -0
  67. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  68. package/package.json +1 -1
@@ -88,14 +88,14 @@ JSClass("JSXYZColorSpace", JSColorSpace, {
88
88
 
89
89
  name: "xyz",
90
90
 
91
- initWithWhitepoint: function(mediaWhitepoint, connectionWhitepoint){
92
- if (mediaWhitepoint === connectionWhitepoint){
91
+ initWithWhitepoint: function(mediaWhitepoint){
92
+ if (mediaWhitepoint === JSColorSpace.Whitepoint.profileConnection){
93
93
  return JSColorSpace.xyz;
94
94
  }
95
- if (mediaWhitepoint[0] === connectionWhitepoint[0] && mediaWhitepoint[1] === connectionWhitepoint[1] && mediaWhitepoint[2] === connectionWhitepoint[2]){
95
+ if (mediaWhitepoint[0] === JSColorSpace.Whitepoint.profileConnection[0] && mediaWhitepoint[1] === JSColorSpace.Whitepoint.profileConnection[1] && mediaWhitepoint[2] === JSColorSpace.Whitepoint.profileConnection[2]){
96
96
  return JSColorSpace.xyz;
97
97
  }
98
- return JSXYZScaledColorSpace.initWithWhitepoint(mediaWhitepoint, connectionWhitepoint);
98
+ return JSXYZScaledColorSpace.initWithWhitepoint(mediaWhitepoint);
99
99
  },
100
100
 
101
101
  initWithScale: function(scale){
@@ -125,11 +125,11 @@ JSClass("JSXYZScaledColorSpace", JSXYZColorSpace, {
125
125
  _scale: null,
126
126
  _inverseScale: null,
127
127
 
128
- initWithWhitepoint: function(mediaWhitepoint, connectionWhitepoint){
128
+ initWithWhitepoint: function(mediaWhitepoint){
129
129
  this.initWithScale([
130
- mediaWhitepoint[0] / connectionWhitepoint[0],
131
- mediaWhitepoint[1] / connectionWhitepoint[1],
132
- mediaWhitepoint[2] / connectionWhitepoint[2]
130
+ mediaWhitepoint[0] / JSColorSpace.Whitepoint.profileConnection[0],
131
+ mediaWhitepoint[1] / JSColorSpace.Whitepoint.profileConnection[1],
132
+ mediaWhitepoint[2] / JSColorSpace.Whitepoint.profileConnection[2]
133
133
  ]);
134
134
  },
135
135
 
@@ -164,10 +164,7 @@ JSClass("JSLabColorSpace", JSColorSpace, {
164
164
 
165
165
  name: "lab",
166
166
 
167
- mediaWhitepoint: null,
168
-
169
- initWithWhitepoint: function(mediaWhitepoint){
170
- this.mediaWhitepoint = mediaWhitepoint;
167
+ init: function(){
171
168
  },
172
169
 
173
170
  xyzFromComponents: function(components){
@@ -181,9 +178,9 @@ JSClass("JSLabColorSpace", JSColorSpace, {
181
178
  var fx = components[1] / 500.0 + fy;
182
179
  var fz = fy - components[2] / 200.0;
183
180
  return [
184
- this.mediaWhitepoint[0] * fi(fx),
185
- this.mediaWhitepoint[1] * fi(fy),
186
- this.mediaWhitepoint[2] * fi(fz)
181
+ JSColorSpace.Whitepoint.profileConnection[0] * fi(fx),
182
+ JSColorSpace.Whitepoint.profileConnection[1] * fi(fy),
183
+ JSColorSpace.Whitepoint.profileConnection[2] * fi(fz)
187
184
  ];
188
185
  },
189
186
 
@@ -194,9 +191,9 @@ JSClass("JSLabColorSpace", JSColorSpace, {
194
191
  }
195
192
  return (841.0 / 108.0) * x + 4.0 / 29.0;
196
193
  };
197
- var fx = f(xyz[0] / this.mediaWhitepoint[0]);
198
- var fy = f(xyz[1] / this.mediaWhitepoint[1]);
199
- var fz = f(xyz[2] / this.mediaWhitepoint[2]);
194
+ var fx = f(xyz[0] / JSColorSpace.Whitepoint.profileConnection[0]);
195
+ var fy = f(xyz[1] / JSColorSpace.Whitepoint.profileConnection[1]);
196
+ var fz = f(xyz[2] / JSColorSpace.Whitepoint.profileConnection[2]);
200
197
  return [
201
198
  116.0 * fy - 16.0,
202
199
  500.0 * (fx - fy),
@@ -239,10 +236,52 @@ JSClass("JSRGBColorSpace", JSColorSpace, {
239
236
 
240
237
  // MARK: - Lab conversions
241
238
 
239
+ xyzMatrix: [
240
+ [0.4360, 0.3851, 0.1431],
241
+ [0.2225, 0.7169, 0.0606],
242
+ [0.0139, 0.09710, 0.7139]
243
+ ],
244
+
245
+ xyzInverseMatrix: [
246
+ [3.13458, -1.61731, -0.491034],
247
+ [-0.978957, 1.91622, 0.0335704],
248
+ [0.0721194, -0.229142, 1.40575]
249
+ ],
250
+
251
+ g: 2.4,
252
+ a: 1.0 / 1.055,
253
+ b: 0.055 / 1.055,
254
+ c: 1.0 / 12.92,
255
+ d: 0.04045,
256
+
257
+ curve: function(x){
258
+ return parametricCurve3(x, this.g, this.a, this.b, this.c, this.d);
259
+ },
260
+
261
+ inverseCurve: function(y){
262
+ y = Math.max(0, Math.min(1, y));
263
+ return inverseParametricCurve3(y, this.g, this.a, this.b, this.c, this.d);
264
+ },
265
+
242
266
  xyzFromComponents: function(components){
267
+ var rgb = [
268
+ this.curve(components[0]),
269
+ this.curve(components[1]),
270
+ this.curve(components[2])
271
+ ];
272
+ return [
273
+ this.xyzMatrix[0][0] * rgb[0] + this.xyzMatrix[0][1] * rgb[1] + this.xyzMatrix[0][2] * rgb[2],
274
+ this.xyzMatrix[1][0] * rgb[0] + this.xyzMatrix[1][1] * rgb[1] + this.xyzMatrix[1][2] * rgb[2],
275
+ this.xyzMatrix[2][0] * rgb[0] + this.xyzMatrix[2][1] * rgb[1] + this.xyzMatrix[2][2] * rgb[2]
276
+ ];
243
277
  },
244
278
 
245
279
  componentsFromXYZ: function(xyz){
280
+ return [
281
+ this.inverseCurve(this.xyzInverseMatrix[0][0] * xyz[0] + this.xyzInverseMatrix[0][1] * xyz[1] + this.xyzInverseMatrix[0][2] * xyz[2]),
282
+ this.inverseCurve(this.xyzInverseMatrix[1][0] * xyz[0] + this.xyzInverseMatrix[1][1] * xyz[1] + this.xyzInverseMatrix[1][2] * xyz[2]),
283
+ this.inverseCurve(this.xyzInverseMatrix[2][0] * xyz[0] + this.xyzInverseMatrix[2][1] * xyz[1] + this.xyzInverseMatrix[2][2] * xyz[2])
284
+ ];
246
285
  },
247
286
 
248
287
  // MARK: - rgb <-> hsl
@@ -425,7 +464,38 @@ JSClass("JSGrayColorSpace", JSColorSpace, {
425
464
  return [
426
465
  components[0] + (1.0 - components[0]) * percentage
427
466
  ];
428
- }
467
+ },
468
+
469
+ g: 2.4,
470
+ a: 1.0 / 1.055,
471
+ b: 0.055 / 1.055,
472
+ c: 1.0 / 12.92,
473
+ d: 0.04045,
474
+
475
+ curve: function(x){
476
+ return parametricCurve3(x, this.g, this.a, this.b, this.c, this.d);
477
+ },
478
+
479
+ inverseCurve: function(y){
480
+ y = Math.max(0, Math.min(1, y));
481
+ return inverseParametricCurve3(y, this.g, this.a, this.b, this.c, this.d);
482
+ },
483
+
484
+ // MARK: - Lab conversions
485
+
486
+ xyzFromComponents: function(components){
487
+ var w = this.curve(components[0]);
488
+ return [
489
+ JSColorSpace.Whitepoint.profileConnection[0] * w,
490
+ JSColorSpace.Whitepoint.profileConnection[1] * w,
491
+ JSColorSpace.Whitepoint.profileConnection[2] * w
492
+ ];
493
+ },
494
+
495
+ componentsFromXYZ: function(xyz){
496
+ var y = Math.min(JSColorSpace.Whitepoint.profileConnection[1], Math.max(0, xyz[1])) / JSColorSpace.Whitepoint.profileConnection[1];
497
+ return [this.inverseCurve(y)];
498
+ },
429
499
 
430
500
  });
431
501
 
@@ -622,7 +692,7 @@ Object.defineProperties(JSColorSpace, {
622
692
  lab: {
623
693
  configurable: true,
624
694
  get: function(){
625
- var space = JSLabColorSpace.initWithWhitepoint(JSColorSpace.Whitepoint.D50);
695
+ var space = JSLabColorSpace.init();
626
696
  Object.defineProperty(this, "lab", {value: space});
627
697
  return space;
628
698
  }
@@ -635,4 +705,20 @@ JSColorSpace.Whitepoint = {
635
705
  D65: [0.9505, 1.0, 1.08883]
636
706
  };
637
707
 
708
+ JSColorSpace.Whitepoint.profileConnection = JSColorSpace.Whitepoint.D50;
709
+
710
+ var parametricCurve3 = function(x, g, a, b, c, d){
711
+ if (x >= d){
712
+ return Math.pow(a * x + b, g);
713
+ }
714
+ return c * x;
715
+ };
716
+
717
+ var inverseParametricCurve3 = function(y, g, a, b, c, d){
718
+ if (y < c * d){
719
+ return y / c;
720
+ }
721
+ return (Math.pow(y, 1.0 / g) - b) / a;
722
+ };
723
+
638
724
  })();
@@ -17,7 +17,7 @@
17
17
  'use strict';
18
18
 
19
19
  JSGlobalObject.JSMediaType = function(str, parameters){
20
- if (str === null || str === undefined){
20
+ if (str === null || str === undefined || str === ""){
21
21
  return null;
22
22
  }
23
23
  if (this === undefined){
@@ -72,4 +72,10 @@ JSTimer.scheduledRepeatingTimerWithInterval = function(interval, action, target)
72
72
  var timer = JSTimer.initWithInterval(interval, true, action, target);
73
73
  timer.schedule();
74
74
  return timer;
75
+ };
76
+
77
+ JSTimer.waitInterval = function(interval){
78
+ return new Promise(function(resolve, reject){
79
+ JSTimer.scheduledTimerWithInterval(interval, resolve);
80
+ });
75
81
  };