@breakside/jskit 2021.52.0 → 2022.3.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 (60) 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/JSColorSpace.js +106 -20
  7. package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
  8. package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
  9. package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
  10. package/Info.json +2 -2
  11. package/Node/io.breakside.jskit-bundle.js +2 -2
  12. package/Root/Frameworks/APIKit/Info.yaml +1 -1
  13. package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
  14. package/Root/Frameworks/AuthKit/Info.yaml +1 -1
  15. package/Root/Frameworks/CSSOM/Info.yaml +1 -1
  16. package/Root/Frameworks/ChartKit/Info.yaml +1 -1
  17. package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
  18. package/Root/Frameworks/DBKit/Info.yaml +1 -1
  19. package/Root/Frameworks/DOM/Info.yaml +1 -1
  20. package/Root/Frameworks/Dispatch/Info.yaml +1 -1
  21. package/Root/Frameworks/FontKit/Info.yaml +1 -1
  22. package/Root/Frameworks/Foundation/Info.yaml +1 -1
  23. package/Root/Frameworks/Foundation/JSColorSpace.js +106 -20
  24. package/Root/Frameworks/ImageKit/IKColorProfile.js +979 -0
  25. package/Root/Frameworks/ImageKit/IKColorSpace.js +49 -198
  26. package/Root/Frameworks/ImageKit/IKMatrix.js +124 -0
  27. package/Root/Frameworks/ImageKit/ImageKit.js +2 -0
  28. package/Root/Frameworks/ImageKit/Info.yaml +1 -1
  29. package/Root/Frameworks/MediaKit/Info.yaml +1 -1
  30. package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
  31. package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
  32. package/Root/Frameworks/PDFKit/Info.yaml +1 -1
  33. package/Root/Frameworks/QRKit/Info.yaml +1 -1
  34. package/Root/Frameworks/SearchKit/Info.yaml +1 -1
  35. package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
  36. package/Root/Frameworks/ServerKit/Info.yaml +1 -1
  37. package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
  38. package/Root/Frameworks/TestKit/Info.yaml +1 -1
  39. package/Root/Frameworks/UIKit/Info.yaml +1 -1
  40. package/Root/Frameworks/UIKit/UICollectionReusableView.js +91 -0
  41. package/Root/Frameworks/UIKit/UICollectionView.js +1254 -0
  42. package/Root/Frameworks/UIKit/UICollectionViewCell.js +121 -0
  43. package/Root/Frameworks/UIKit/UICollectionViewGridLayout.js +425 -0
  44. package/Root/Frameworks/UIKit/UICollectionViewLayout.js +82 -0
  45. package/Root/Frameworks/UIKit/UIColorWell.js +12 -1
  46. package/Root/Frameworks/UIKit/UIDisplayServer.js +5 -1
  47. package/Root/Frameworks/UIKit/UIKit.js +7 -0
  48. package/Root/Frameworks/UIKit/UILayer.js +3 -0
  49. package/Root/Frameworks/UIKit/UIListView.js +8 -9
  50. package/Root/Frameworks/UIKit/UIMenu.js +1 -1
  51. package/Root/Frameworks/UIKit/UIMenuView.js +5 -1
  52. package/Root/Frameworks/UIKit/UINavigationBar.js +2 -2
  53. package/Root/Frameworks/UIKit/UIPopupButton.js +31 -3
  54. package/Root/Frameworks/UIKit/UIScrollView.js +2 -0
  55. package/Root/Frameworks/UIKit/UISplitViewController.js +43 -9
  56. package/Root/Frameworks/UIKit/UITextField.js +3 -0
  57. package/Root/Frameworks/UIKit/UIView.js +3 -0
  58. package/Root/Frameworks/UIKit/UIViewController.js +8 -0
  59. package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
  60. package/package.json +1 -1
@@ -201,6 +201,9 @@ JSClass("UILayer", JSObject, {
201
201
  },
202
202
 
203
203
  setTransform: function(transform){
204
+ if (transform.isEqual(this.model.transform)){
205
+ return;
206
+ }
204
207
  // When the transform changes, the frame needs to be recalculated. The position, however, does
205
208
  // not change. The transform essentially defines a new relationship between the position and frame
206
209
  this._addImplicitAnimationForKey('transform');
@@ -126,7 +126,7 @@ JSClass("UIListView", UIScrollView, {
126
126
  if (typeof(reuse) === 'string'){
127
127
  this.registerHeaderFooterClassForReuseIdentifier(JSClass.FromName(reuse), identifier);
128
128
  }else{
129
- this.registerCellClassForReuseIdentifier(JSClass.FromName(reuse.valueForKey('className')), identifier);
129
+ this.registerHeaderFooterClassForReuseIdentifier(JSClass.FromName(reuse.valueForKey('className')), identifier);
130
130
  }
131
131
  }
132
132
  }
@@ -140,7 +140,7 @@ JSClass("UIListView", UIScrollView, {
140
140
  this._headersStickToTop = spec.valueForKey("headersStickToTop");
141
141
  }
142
142
  if (spec.containsKey("showsFocusRing")){
143
- this._showsFocusRing = spec.valueForKey("showsFocusRing");
143
+ this.showsFocusRing = spec.valueForKey("showsFocusRing");
144
144
  }
145
145
  if (spec.containsKey("listHeaderView")){
146
146
  this.listHeaderView = spec.valueForKey("listHeaderView", UIView);
@@ -339,7 +339,6 @@ JSClass("UIListView", UIScrollView, {
339
339
  var lastVisibleItem = this._visibleItems[this._visibleItems.length - 1];
340
340
  var searcher = JSBinarySearcher(this._visibleItems, VisibleItem.cellIndexPathCompare);
341
341
  var visibleSizeChanged = false;
342
- var listView = this;
343
342
  var contentSize = JSSize(this.contentSize);
344
343
  var contentOffset = JSPoint(this.contentOffset);
345
344
 
@@ -391,13 +390,13 @@ JSClass("UIListView", UIScrollView, {
391
390
 
392
391
  if (animator && visibleSizeChanged){
393
392
  animator.addAnimations(function(){
394
- listView.contentSize = contentSize;
395
- listView.contentOffset = contentOffset;
396
- listView._layoutVisibleItems(this._visibleItems, y0);
397
- });
393
+ this.contentSize = contentSize;
394
+ this.contentOffset = contentOffset;
395
+ this._layoutVisibleItems(this._visibleItems, y0);
396
+ }, this);
398
397
  }else{
399
- listView.contentSize = contentSize;
400
- listView.contentOffset = contentOffset;
398
+ this.contentSize = contentSize;
399
+ this.contentOffset = contentOffset;
401
400
  }
402
401
 
403
402
  },
@@ -894,7 +894,7 @@ JSClass("UIMenuWindowStyler", UIMenuStyler, {
894
894
  var item = menu.items[itemIndex];
895
895
  var window = this.windowForMenu(menu);
896
896
  if (window !== null){
897
- return window.viewForITem(item);
897
+ return window.viewForItem(item);
898
898
  }
899
899
  return null;
900
900
  }
@@ -214,7 +214,11 @@ JSClass("UIMenuWindow", UIWindow, {
214
214
  },
215
215
 
216
216
  viewForItem: function(item){
217
- return this._itemViewIndexesByItemId[item.objectID] || null;
217
+ var index = this._itemViewIndexesByItemId[item.objectID];
218
+ if (index !== undefined){
219
+ return this.menuView.itemViews[index];
220
+ }
221
+ return null;
218
222
  },
219
223
 
220
224
  // -----------------------------------------------------------------------
@@ -490,9 +490,9 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
490
490
  props.backBarItemView.alpha = 0;
491
491
  var backTitleFrame = props.backBarItemView.titleLabel.convertRectToView(props.backBarItemView.titleLabel.bounds, props.backBarItemView.superview);
492
492
  if (removingCustomView){
493
- props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(removingCustomView.frame.origin.x - backTitleFrame.origin.x, 0).scaledBy(backToTitleScale);
493
+ props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(Math.max(0, removingCustomView.frame.origin.x - backTitleFrame.origin.x), 0).scaledBy(backToTitleScale);
494
494
  }else{
495
- props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(removingTitleLabel.frame.origin.x - backTitleFrame.origin.x, 0).scaledBy(backToTitleScale);
495
+ props.backBarItemView.titleLabel.transform = JSAffineTransform.Translated(Math.max(0, removingTitleLabel.frame.origin.x - backTitleFrame.origin.x), 0).scaledBy(backToTitleScale);
496
496
  }
497
497
  animator.addAnimations(function(){
498
498
  var i, l;
@@ -467,18 +467,21 @@ JSClass("UIPopupButtonStyler", UIControlStyler, {
467
467
 
468
468
  JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
469
469
 
470
- showsOverState: false,
471
470
  titleInsets: null,
472
471
  normalBackgroundColor: null,
473
472
  disabledBackgroundColor: null,
473
+ overBackgroundColor: null,
474
474
  activeBackgroundColor: null,
475
475
  normalBackgroundGradient: null,
476
+ overBackgroundGradient: null,
476
477
  disabledBackgroundGradient: null,
477
478
  activeBackgroundGradient: null,
478
479
  normalBorderColor: null,
479
480
  disabledBorderColor: null,
481
+ overBorderColor: null,
480
482
  activeBorderColor: null,
481
483
  normalTitleColor: null,
484
+ overTitleColor: null,
482
485
  disabledTitleColor: null,
483
486
  activeTitleColor: null,
484
487
  borderWidth: 0,
@@ -508,7 +511,7 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
508
511
  },
509
512
 
510
513
  initWithSpec: function(spec){
511
- UIPopupButtonCustomStyler.$super.initWithSpec(spec);
514
+ UIPopupButtonCustomStyler.$super.initWithSpec.call(this, spec);
512
515
 
513
516
  this._populateDefaults();
514
517
 
@@ -518,6 +521,9 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
518
521
  if (spec.containsKey("normalBackgroundColor")){
519
522
  this.normalBackgroundColor = spec.valueForKey("normalBackgroundColor", JSColor);
520
523
  }
524
+ if (spec.containsKey("overBackgroundColor")){
525
+ this.overBackgroundColor = spec.valueForKey("overBackgroundColor", JSColor);
526
+ }
521
527
  if (spec.containsKey("disabledBackgroundColor")){
522
528
  this.disabledBackgroundColor = spec.valueForKey("disabledBackgroundColor", JSColor);
523
529
  }
@@ -527,6 +533,9 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
527
533
  if (spec.containsKey("normalBackgroundGradient")){
528
534
  this.normalBackgroundGradient = spec.valueForKey("normalBackgroundGradient", JSGradient);
529
535
  }
536
+ if (spec.containsKey("overBackgroundGradient")){
537
+ this.overBackgroundGradient = spec.valueForKey("overBackgroundGradient", JSGradient);
538
+ }
530
539
  if (spec.containsKey("disabledBackgroundGradient")){
531
540
  this.disabledBackgroundGradient = spec.valueForKey("disabledBackgroundGradient", JSGradient);
532
541
  }
@@ -536,6 +545,9 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
536
545
  if (spec.containsKey("normalBorderColor")){
537
546
  this.normalBorderColor = spec.valueForKey("normalBorderColor", JSColor);
538
547
  }
548
+ if (spec.containsKey("overBorderColor")){
549
+ this.overBorderColor = spec.valueForKey("overBorderColor", JSColor);
550
+ }
539
551
  if (spec.containsKey("disabledBorderColor")){
540
552
  this.disabledBorderColor = spec.valueForKey("disabledBorderColor", JSColor);
541
553
  }
@@ -545,6 +557,9 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
545
557
  if (spec.containsKey("normalTitleColor")){
546
558
  this.normalTitleColor = spec.valueForKey("normalTitleColor", JSColor);
547
559
  }
560
+ if (spec.containsKey("overTitleColor")){
561
+ this.overTitleColor = spec.valueForKey("overTitleColor", JSColor);
562
+ }
548
563
  if (spec.containsKey("disabledTitleColor")){
549
564
  this.disabledTitleColor = spec.valueForKey("disabledTitleColor", JSColor);
550
565
  }
@@ -595,6 +610,9 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
595
610
  if (this.activeBorderColor === null){
596
611
  this.activeBorderColor = this.normalBorderColor.colorDarkenedByPercentage(0.2);
597
612
  }
613
+ if (this.overBorderColor === null){
614
+ this.overBorderColor = this.normalBorderColor.colorDarkenedByPercentage(0.2);
615
+ }
598
616
  if (this.disabledBorderColor === null){
599
617
  this.disabledBorderColor = this.normalBorderColor.colorWithAlpha(0.5);
600
618
  }
@@ -602,6 +620,9 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
602
620
  if (this.normalTitleColor === null){
603
621
  this.normalTitleColor = JSColor.text;
604
622
  }
623
+ if (this.overTitleColor === null){
624
+ this.overTitleColor = this.normalTitleColor.colorDarkenedByPercentage(0.2);
625
+ }
605
626
  if (this.activeTitleColor === null){
606
627
  this.activeTitleColor = this.normalTitleColor.colorDarkenedByPercentage(0.2);
607
628
  }
@@ -628,6 +649,13 @@ JSClass("UIPopupButtonCustomStyler", UIPopupButtonStyler, {
628
649
  button._titleLabel.textColor = this.disabledTitleColor;
629
650
  button._imageView.templateColor = this.disabledTitleColor;
630
651
  button._indicatorView.templateColor = this.disabledTitleColor;
652
+ }else if (button.over){
653
+ button.layer.backgroundColor = this.overBackgroundColor;
654
+ button.layer.backgroundGradient = this.overBackgroundGradient;
655
+ button.layer.borderColor = this.overBorderColor;
656
+ button._titleLabel.textColor = this.overTitleColor;
657
+ button._imageView.templateColor = this.overTitleColor;
658
+ button._indicatorView.templateColor = this.overTitleColor;
631
659
  }else if (button.active){
632
660
  button.layer.backgroundColor = this.activeBackgroundColor;
633
661
  button.layer.backgroundGradient = this.activeBackgroundGradient;
@@ -766,7 +794,7 @@ JSClass("UIPopupButtonImageStyler", UIPopupButtonStyler, {
766
794
  },
767
795
 
768
796
  initWithSpec: function(spec){
769
- UIPopupButtonCustomStyler.$super.initWithSpec(spec);
797
+ UIPopupButtonCustomStyler.$super.initWithSpec.call(this, spec);
770
798
  if (spec.containsKey("normalColor")){
771
799
  this.normalColor = spec.valueForKey("normalColor", JSColor);
772
800
  }
@@ -276,6 +276,8 @@ JSClass('UIScrollView', UIView, {
276
276
 
277
277
  _sanitizedOffset: function(offset){
278
278
  offset = JSPoint(offset);
279
+ offset.x = Math.round(offset.x);
280
+ offset.y = Math.round(offset.y);
279
281
  if (!this.scrollsHorizontally){
280
282
  offset.x = this._contentOffset.x;
281
283
  }else if (offset.x < this._minContentOffset.x){
@@ -148,22 +148,56 @@ JSClass("UISplitViewController", UIViewController, {
148
148
  },
149
149
 
150
150
  _setMainViewControllerCollapsed: function(mainViewController){
151
+ if (this._leadingViewController.isKindOfClass(UINavigationController)){
152
+ this._pushMainViewControllerOnNavigationController(mainViewController, this._leadingViewController);
153
+ }else{
154
+ this._presentMainViewControllerOnViewController(mainViewController, this._leadingViewController);
155
+ }
156
+ },
157
+
158
+ _pushMainViewControllerOnNavigationController: function(mainViewController, navigationController){
159
+ var i = navigationController.viewControllers.length - 1;
160
+ // 1. Pop off all view controllers up to and including our current mainViewController
151
161
  if (this._mainViewController !== null){
152
- if (this._leadingViewController.isKindOfClass(UINavigationController)){
153
- if (this._mainViewController === this._leadingViewController.topViewController){
154
- this._leadingViewController.popViewController(false);
155
- }
156
- }else{
157
- if (this._mainViewController === this._leadingViewController.presentedViewController){
158
- this._leadingViewController.dismiss(false);
162
+ while (i >= 1 && navigationController.viewControllers[i] !== this._mainViewController){
163
+ --i;
164
+ }
165
+ if (i > 0){
166
+ if (mainViewController === this._mainViewController){
167
+ // Bail if we're being asked to show the same view controller that's already shown
168
+ // NOTE: this check only comes after finding that the view controller
169
+ // is indeed part of the presentation tree becuase without a notification
170
+ // from the navigation controller when views are popped by the user,
171
+ // we may be in a situation where this._mainViewController is set, but
172
+ // is not part of the navigation stack
173
+ return;
159
174
  }
175
+ navigationController.popToViewController(navigationController.viewControllers[i - 1], false);
160
176
  }
161
- this._leadingViewController.view.layoutIfNeeded();
177
+ }
178
+ // 2. Push the new new mainViewController, animating if we're not currently changing traits
179
+ if (mainViewController !== null){
180
+ navigationController.pushViewController(mainViewController, !this.isChangingTraits);
162
181
  }
163
182
  this._mainViewController = mainViewController;
183
+ },
184
+
185
+ _presentMainViewControllerOnViewController: function(mainViewController, viewController){
186
+ // Bail if we're being asked to show the same view controller that's already shown
187
+ if (mainViewController === this._mainViewController){
188
+ return;
189
+ }
190
+ // 1. Dismiss the current mainViewController
164
191
  if (this._mainViewController !== null){
165
- this._leadingViewController.show(this._mainViewController, this);
192
+ if (this._mainViewController === viewController.presentedViewController){
193
+ viewController.dismiss();
194
+ }
195
+ }
196
+ // 2. Present the new mainViewController
197
+ if (mainViewController !== null){
198
+ viewController.presentViewController(mainViewController);
166
199
  }
200
+ this._mainViewController = mainViewController;
167
201
  },
168
202
 
169
203
  getSplitView: function(){
@@ -788,6 +788,9 @@ JSClass("UITextField", UIControl, {
788
788
  this.delegate.textFieldDidChange(this);
789
789
  }
790
790
  this._didChange = true;
791
+ if (this._textLayer.textAlignment !== JSTextAlignment.left){
792
+ this.setNeedsLayout();
793
+ }
791
794
  },
792
795
 
793
796
  _adjustCursorPositionToCenterIfNeeded: function(){
@@ -145,6 +145,9 @@ JSClass('UIView', UIResponder, {
145
145
  this.addSubview(subview);
146
146
  }
147
147
  }
148
+ if (spec.containsKey("clipsToBounds")){
149
+ this.clipsToBounds = spec.valueForKey("clipsToBounds");
150
+ }
148
151
  // NOTE: constraints are still and work in progress, and aren't actually
149
152
  // used yet during layout
150
153
  if (spec.containsKey("constraints")){
@@ -162,6 +162,9 @@ JSClass("UIViewController", UIResponder, {
162
162
  this._isViewVisible = false;
163
163
  },
164
164
 
165
+ // -------------------------------------------------------------------------
166
+ // MARK: - Layout
167
+
165
168
  viewDidLayoutSubviews: function(){
166
169
  },
167
170
 
@@ -169,6 +172,11 @@ JSClass("UIViewController", UIResponder, {
169
172
  this.view.sizeToFitSize(size);
170
173
  },
171
174
 
175
+ contentSizeThatFitsSize: function(maxSize){
176
+ this.view.sizeToFitSize(maxSize);
177
+ return JSSize(this.view.bounds.size);
178
+ },
179
+
172
180
  // -------------------------------------------------------------------------
173
181
  // MARK: - Child View Controllers
174
182
 
@@ -1,6 +1,6 @@
1
1
  JSBundleType: framework
2
2
  JSBundleIdentifier: io.breakside.JSKit.UIKitTesting
3
- JSBundleVersion: 2021.52.0
3
+ JSBundleVersion: 2022.3.0
4
4
  JSDevelopmentLanguage: en
5
5
  JSCopyright: Copyright © 2020 Breakside Inc.
6
6
  JSLicenseNotice: |
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "node": ">=10.10.0"
10
10
  },
11
11
  "name": "@breakside/jskit",
12
- "version": "2021.52.0",
12
+ "version": "2022.3.0",
13
13
  "license": "SEE LICENSE IN LICENSE.txt",
14
14
  "files": [
15
15
  "*"