@breakside/jskit 2022.3.1 → 2022.7.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/JSUserDefaults.js +28 -7
- 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/Docs/DocComponent.js +11 -0
- 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/Info.yaml +1 -1
- package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
- package/Root/Frameworks/DBKit/DBMongoStore.js +1 -0
- package/Root/Frameworks/DBKit/DBRedisStore.js +136 -117
- 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/JSUserDefaults.js +28 -7
- package/Root/Frameworks/ImageKit/IKMatrix.js +1 -1
- 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/SKAMQPJobQueue.js +1 -1
- package/Root/Frameworks/ServerKit/SKApplication+Node.js +5 -3
- package/Root/Frameworks/ServerKit/SKJobQueue.js +1 -1
- package/Root/Frameworks/ServerKit/SKRedisJobQueue.js +7 -3
- package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/TestKit/Info.yaml +1 -1
- package/Root/Frameworks/TestKit/TKMock.js +1 -1
- package/Root/Frameworks/UIKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/UIBrowserViewController.js +2 -6
- package/Root/Frameworks/UIKit/UIHTMLApplication.js +21 -5
- package/Root/Frameworks/UIKit/UINavigationBar.js +7 -1
- package/Root/Frameworks/UIKit/UINavigationController.js +228 -112
- package/Root/Frameworks/UIKit/UINavigationItem.js +4 -0
- package/Root/Frameworks/UIKit/UIPopupButton.js +8 -0
- package/Root/Frameworks/UIKit/UISplitViewController.js +185 -77
- package/Root/Frameworks/UIKit/UITabViewController.js +4 -10
- package/Root/Frameworks/UIKit/UIViewController.js +133 -50
- package/Root/Frameworks/UIKit/UIWindow.js +4 -15
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/UIKitTesting/UIMockApplication.js +6 -0
- package/Root/Templates/http/${PROJECT_NAME}/Dockerfile +1 -1
- package/Root/Templates/node/${PROJECT_NAME}/Dockerfile +4 -2
- package/package.json +1 -1
|
@@ -29,12 +29,17 @@ var logger = JSLog("foundation", "user-defaults");
|
|
|
29
29
|
JSClass("JSUserDefaults", JSObject, {
|
|
30
30
|
|
|
31
31
|
identifier: JSReadOnlyProperty('_identifier', null),
|
|
32
|
+
_fileManager: null,
|
|
32
33
|
_defaults: null,
|
|
33
34
|
_values: null,
|
|
34
35
|
|
|
35
|
-
initWithIdentifier: function(identifier){
|
|
36
|
+
initWithIdentifier: function(identifier, fileManager){
|
|
37
|
+
if (fileManager === undefined){
|
|
38
|
+
fileManager = JSFileManager.shared;
|
|
39
|
+
}
|
|
40
|
+
this._fileManager = fileManager;
|
|
36
41
|
this._identifier = identifier;
|
|
37
|
-
this._url =
|
|
42
|
+
this._url = this._fileManager.persistentContainerURL.appendingPathComponents(['Preferences', '%s.prefs.json'.sprintf(this._identifier)]);
|
|
38
43
|
this._defaults = {};
|
|
39
44
|
},
|
|
40
45
|
|
|
@@ -42,7 +47,7 @@ JSClass("JSUserDefaults", JSObject, {
|
|
|
42
47
|
if (!completion){
|
|
43
48
|
completion = Promise.completion(Promise.resolveTrue);
|
|
44
49
|
}
|
|
45
|
-
|
|
50
|
+
this._fileManager.contentsAtURL(this._url, function JSUserDefaults_open_contents(data){
|
|
46
51
|
try{
|
|
47
52
|
if (data !== null){
|
|
48
53
|
var json = String.initWithData(data, String.Encoding.utf8);
|
|
@@ -60,6 +65,19 @@ JSClass("JSUserDefaults", JSObject, {
|
|
|
60
65
|
},
|
|
61
66
|
|
|
62
67
|
close: function(completion, target){
|
|
68
|
+
if (!completion){
|
|
69
|
+
completion = Promise.completion(Promise.resolveTrue);
|
|
70
|
+
}
|
|
71
|
+
this.synchronize(function(success){
|
|
72
|
+
if (success){
|
|
73
|
+
this._values = null;
|
|
74
|
+
}
|
|
75
|
+
completion.call(target, success);
|
|
76
|
+
}, this);
|
|
77
|
+
return completion.promise;
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
synchronize: function(completion, target){
|
|
63
81
|
if (!completion){
|
|
64
82
|
completion = Promise.completion(Promise.resolveTrue);
|
|
65
83
|
}
|
|
@@ -75,9 +93,6 @@ JSClass("JSUserDefaults", JSObject, {
|
|
|
75
93
|
}
|
|
76
94
|
if (needsSave){
|
|
77
95
|
this._persist(function JSUserDefaults_close_persisted(success){
|
|
78
|
-
if (success){
|
|
79
|
-
this._values = null;
|
|
80
|
-
}
|
|
81
96
|
completion.call(target, success);
|
|
82
97
|
}, this);
|
|
83
98
|
}else{
|
|
@@ -89,6 +104,9 @@ JSClass("JSUserDefaults", JSObject, {
|
|
|
89
104
|
// MARK: - Getting and Setting values
|
|
90
105
|
|
|
91
106
|
valueForKey: function(key){
|
|
107
|
+
if (this._values === null){
|
|
108
|
+
throw new Error("JSUserDefaults is closed, cannot get value. Be sure to call open() first.");
|
|
109
|
+
}
|
|
92
110
|
if (key in this._values){
|
|
93
111
|
return this._values[key];
|
|
94
112
|
}
|
|
@@ -99,6 +117,9 @@ JSClass("JSUserDefaults", JSObject, {
|
|
|
99
117
|
},
|
|
100
118
|
|
|
101
119
|
setValueForKey: function(value, key){
|
|
120
|
+
if (this._values === null){
|
|
121
|
+
throw new Error("JSUserDefaults is closed, cannot set value. Be sure to call open() first.");
|
|
122
|
+
}
|
|
102
123
|
this._values[key] = value;
|
|
103
124
|
this._persistAfterDelay();
|
|
104
125
|
this._definePropertyForKey(key);
|
|
@@ -161,7 +182,7 @@ JSClass("JSUserDefaults", JSObject, {
|
|
|
161
182
|
}else{
|
|
162
183
|
var data = JSON.stringify(this._values).utf8();
|
|
163
184
|
logger.info("saving user defaults");
|
|
164
|
-
|
|
185
|
+
this._fileManager.createFileAtURL(this._url, data, function JSUserDefaults_persist_createFile(success){
|
|
165
186
|
if (!success){
|
|
166
187
|
logger.error("failed to write user defaults");
|
|
167
188
|
}else{
|
|
@@ -151,7 +151,7 @@ JSClass("SKAMQPJobQueue", SKJobQueue, {
|
|
|
151
151
|
|
|
152
152
|
enqueueDictionary: async function(dictionary){
|
|
153
153
|
var json = JSON.stringify(dictionary);
|
|
154
|
-
var content = json.utf8();
|
|
154
|
+
var content = json.utf8().nodeBuffer();
|
|
155
155
|
await this.channel.sendToQueue(this.identifier, content, {persistent: true, priority: dictionary.priority});
|
|
156
156
|
},
|
|
157
157
|
|
|
@@ -54,18 +54,20 @@ SKApplication.definePropertiesFromExtensions({
|
|
|
54
54
|
var logs = JSLog.getRecords();
|
|
55
55
|
var promise = this.delegate.applicationDidCrash(this, error, logs);
|
|
56
56
|
if (promise instanceof Promise){
|
|
57
|
-
promise.catch(function(
|
|
58
|
-
logger.error("
|
|
57
|
+
promise.catch(function(e){
|
|
58
|
+
logger.error("SKApplication crash: %{error}", error);
|
|
59
|
+
logger.error("Error while handling crash: %{error}", e);
|
|
59
60
|
}).finally(stop);
|
|
60
61
|
}else{
|
|
61
62
|
stop();
|
|
62
63
|
}
|
|
63
64
|
}catch (e){
|
|
65
|
+
logger.error("SKApplication crash: %{error}", error);
|
|
64
66
|
logger.error("Error while handling crash: %{error}", e);
|
|
65
67
|
stop();
|
|
66
68
|
}
|
|
67
69
|
}else{
|
|
68
|
-
logger.error(error);
|
|
70
|
+
logger.error("SKApplication crash: %{error}", error);
|
|
69
71
|
stop();
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -35,7 +35,7 @@ JSClass("SKJobQueue", JSObject, {
|
|
|
35
35
|
return SKFileJobQueue.initWithURL(url, fileManager);
|
|
36
36
|
}else if (url.scheme === "redis"){
|
|
37
37
|
return SKRedisJobQueue.initWithURL(url, service);
|
|
38
|
-
}else if (url.scheme === "amqp"){
|
|
38
|
+
}else if (url.scheme === "amqp" || url.scheme === "amqps"){
|
|
39
39
|
return SKAMQPJobQueue.initWithURL(url, service);
|
|
40
40
|
}else if (url.scheme === "memory"){
|
|
41
41
|
return SKMemoryJobQueue.init();
|
|
@@ -46,7 +46,7 @@ JSClass("SKRedisJobQueue", SKJobQueue, {
|
|
|
46
46
|
if (this.openPromise === null){
|
|
47
47
|
this.openPromise = new Promise(function(resolve, reject){
|
|
48
48
|
logger.info("Redis client connecting to %{public}:%d...", queue.url.host, queue.url.port || 6379);
|
|
49
|
-
var client = queue.redis.createClient({url: queue.url.encodedString});
|
|
49
|
+
var client = queue.redis.createClient({url: queue.url.encodedString, legacyMode: true});
|
|
50
50
|
var errorHandler = function(error){
|
|
51
51
|
logger.info("Failed to open Redis connection: %{error}", error);
|
|
52
52
|
queue.openPromise = null;
|
|
@@ -61,8 +61,12 @@ JSClass("SKRedisJobQueue", SKJobQueue, {
|
|
|
61
61
|
queue.client = client;
|
|
62
62
|
resolve();
|
|
63
63
|
};
|
|
64
|
-
client.
|
|
65
|
-
|
|
64
|
+
if (client.connect){
|
|
65
|
+
client.connect().then(readyHandler, errorHandler);
|
|
66
|
+
}else{
|
|
67
|
+
client.on("error", errorHandler);
|
|
68
|
+
client.on("ready", readyHandler);
|
|
69
|
+
}
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
72
|
return this.openPromise;
|
|
@@ -87,8 +87,7 @@ JSClass("UIBrowserViewController", UIViewController, {
|
|
|
87
87
|
this._viewControllers.push(viewController);
|
|
88
88
|
this.view.pushView(viewController.view);
|
|
89
89
|
if (this.isViewVisible){
|
|
90
|
-
viewController.
|
|
91
|
-
viewController.viewDidAppear(false);
|
|
90
|
+
viewController.scheduleAppearance();
|
|
92
91
|
}
|
|
93
92
|
},
|
|
94
93
|
|
|
@@ -102,13 +101,10 @@ JSClass("UIBrowserViewController", UIViewController, {
|
|
|
102
101
|
vc = this._viewControllers.pop();
|
|
103
102
|
--count;
|
|
104
103
|
if (this.isViewVisible){
|
|
105
|
-
vc.
|
|
104
|
+
vc.scheduleDisappearance();
|
|
106
105
|
}
|
|
107
106
|
this.view.popView();
|
|
108
107
|
this.removeFromParentViewController(vc);
|
|
109
|
-
if (this.isViewVisible){
|
|
110
|
-
vc.viewDidDisappear(false);
|
|
111
|
-
}
|
|
112
108
|
}
|
|
113
109
|
}
|
|
114
110
|
|
|
@@ -190,7 +190,27 @@ JSClass("UIHTMLApplication", UIApplication, {
|
|
|
190
190
|
},
|
|
191
191
|
|
|
192
192
|
_crash: function(error){
|
|
193
|
-
|
|
193
|
+
if (this.delegate && this.delegate.applicationDidCrash){
|
|
194
|
+
try{
|
|
195
|
+
var logs = JSLog.getRecords();
|
|
196
|
+
var promise = this.delegate.applicationDidCrash(this, error, logs);
|
|
197
|
+
if (promise instanceof Promise){
|
|
198
|
+
promise.catch(function(e){
|
|
199
|
+
logger.error("UIApplication crash: %{error}", error);
|
|
200
|
+
logger.error("Error while handling crash: %{error}", e);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}catch (e){
|
|
204
|
+
logger.error("UIApplication crash: %{error}", error);
|
|
205
|
+
logger.error("Error while handling crash: %{error}", e);
|
|
206
|
+
}
|
|
207
|
+
}else{
|
|
208
|
+
logger.error("UIApplication crash: %{error}", error);
|
|
209
|
+
}
|
|
210
|
+
this._showCrashScreen();
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
_showCrashScreen: function(){
|
|
194
214
|
this.windowServer.stop();
|
|
195
215
|
var root = this.windowServer.displayServer.rootElement;
|
|
196
216
|
var cover = root.appendChild(root.ownerDocument.createElement('div'));
|
|
@@ -201,10 +221,6 @@ JSClass("UIHTMLApplication", UIApplication, {
|
|
|
201
221
|
cover.style.right = '0';
|
|
202
222
|
cover.style.bottom = '0';
|
|
203
223
|
var message;
|
|
204
|
-
if (this.delegate && this.delegate.applicationDidCrash){
|
|
205
|
-
var logs = JSLog.getRecords();
|
|
206
|
-
message = this.delegate.applicationDidCrash(this, error, logs);
|
|
207
|
-
}
|
|
208
224
|
if (!message){
|
|
209
225
|
message = "Sorry, there was a problem and the application needs to restart.\n\nPlease reload the page to continue.";
|
|
210
226
|
}
|
|
@@ -303,6 +303,7 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
|
|
|
303
303
|
contentSeparatorSize: 0,
|
|
304
304
|
titleColor: null,
|
|
305
305
|
titleTextAlignment: JSTextAlignment.center,
|
|
306
|
+
titleInsets: null,
|
|
306
307
|
itemColor: null,
|
|
307
308
|
activeItemColor: null,
|
|
308
309
|
disabledItemColor: null,
|
|
@@ -347,6 +348,9 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
|
|
|
347
348
|
if (spec.containsKey("titleTextAlignment")){
|
|
348
349
|
this.titleTextAlignment = spec.valueForKey("titleTextAlignment", JSTextAlignment);
|
|
349
350
|
}
|
|
351
|
+
if (spec.containsKey("titleInsets")){
|
|
352
|
+
this.titleInsets = spec.valueForKey("titleInsets", JSInsets);
|
|
353
|
+
}
|
|
350
354
|
if (spec.containsKey("itemColor")){
|
|
351
355
|
this.itemColor = spec.valueForKey("itemColor", JSColor);
|
|
352
356
|
}
|
|
@@ -702,10 +706,13 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
|
|
|
702
706
|
var itemHeight = size.height - this.itemInsets.height;
|
|
703
707
|
var y = this.itemInsets.top;
|
|
704
708
|
var barItemView = props.backBarItemView;
|
|
709
|
+
var titleTextAlignment = item ? item.titleTextAlignment || this.titleTextAlignment : this.titleTextAlignment;
|
|
705
710
|
barItemView.sizeToFitSize(JSSize(xRight - xLeft, itemHeight));
|
|
706
711
|
barItemView.frame = JSRect(JSPoint(xLeft, y + (itemHeight - barItemView.bounds.size.height) / 2), barItemView.bounds.size);
|
|
707
712
|
if (!barItemView.hidden){
|
|
708
713
|
xLeft += barItemView.bounds.size.width;
|
|
714
|
+
}else if (props.leftBarItemViews.length === 0 && titleTextAlignment === JSTextAlignment.left && this.titleInsets !== null){
|
|
715
|
+
xLeft = this.titleInsets.left;
|
|
709
716
|
}
|
|
710
717
|
for (i = 0, l = props.leftBarItemViews.length; i < l; ++i){
|
|
711
718
|
barItemView = props.leftBarItemViews[i];
|
|
@@ -738,7 +745,6 @@ JSClass("UINavigationBarDefaultStyler", UINavigationBarStyler, {
|
|
|
738
745
|
var maxX = xRight - viewSize.width;
|
|
739
746
|
var centeredX = (size.width - viewSize.width) / 2;
|
|
740
747
|
var centeredY = (size.height - viewSize.height) / 2;
|
|
741
|
-
var titleTextAlignment = item ? item.titleTextAlignment || this.titleTextAlignment : this.titleTextAlignment;
|
|
742
748
|
if (titleTextAlignment === JSTextAlignment.center){
|
|
743
749
|
titleView.frame = JSRect(JSPoint(Math.min(Math.max(minX, centeredX), maxX), centeredY), viewSize);
|
|
744
750
|
}else if (titleTextAlignment === JSTextAlignment.right){
|