@breakside/jskit 2021.44.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.
- 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/Deflate.js +2 -3
- package/Frameworks/Foundation.jsframework/JS/Error+JS.js +10 -0
- package/Frameworks/Foundation.jsframework/JS/JSColorSpace.js +106 -20
- package/Frameworks/Foundation.jsframework/JS/JSDateFormatter.js +2 -2
- package/Frameworks/Foundation.jsframework/JS/JSTimer.js +6 -0
- package/Frameworks/Foundation.jsframework/JS/JSURLResponse.js +60 -1
- package/Frameworks/Foundation.jsframework/JS/Zlib.js +2 -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/JavascriptCompilation.js +1 -1
- package/Node/io.breakside.jskit-bundle.js +2 -2
- package/Root/Frameworks/APIKit/APIError.js +2 -3
- 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/DBObjectDatabase.js +6 -5
- 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/Deflate.js +2 -3
- package/Root/Frameworks/Foundation/Error+JS.js +10 -0
- package/Root/Frameworks/Foundation/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/JSColorSpace.js +106 -20
- package/Root/Frameworks/Foundation/JSDateFormatter.js +2 -2
- package/Root/Frameworks/Foundation/JSTimer.js +6 -0
- package/Root/Frameworks/Foundation/JSURLResponse.js +60 -1
- package/Root/Frameworks/Foundation/Zlib.js +2 -3
- package/Root/Frameworks/ImageKit/IKColorProfile.js +979 -0
- package/Root/Frameworks/ImageKit/IKColorSpace.js +49 -198
- package/Root/Frameworks/ImageKit/IKDecoderPNG.js +1 -3
- package/Root/Frameworks/ImageKit/IKMatrix.js +124 -0
- package/Root/Frameworks/ImageKit/ImageKit.js +2 -0
- 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/SKFileJobQueue.js +3 -1
- package/Root/Frameworks/ServerKit/SKHTTPError.js +2 -3
- package/Root/Frameworks/ServerKit/SKHTTPRequest.js +7 -0
- package/Root/Frameworks/ServerKit/SKHTTPResponder.js +9 -2
- package/Root/Frameworks/ServerKit/SKUserAgent.js +130 -0
- package/Root/Frameworks/ServerKit/SKValidatingObject.js +1 -3
- package/Root/Frameworks/ServerKit/ServerKit.js +1 -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/UICollectionReusableView.js +91 -0
- package/Root/Frameworks/UIKit/UICollectionView.js +1254 -0
- package/Root/Frameworks/UIKit/UICollectionViewCell.js +121 -0
- package/Root/Frameworks/UIKit/UICollectionViewGridLayout.js +425 -0
- package/Root/Frameworks/UIKit/UICollectionViewLayout.js +82 -0
- package/Root/Frameworks/UIKit/UIColorWell.js +12 -1
- package/Root/Frameworks/UIKit/UIDisplayServer.js +5 -1
- package/Root/Frameworks/UIKit/UIKit.js +7 -0
- package/Root/Frameworks/UIKit/UILayer.js +3 -0
- package/Root/Frameworks/UIKit/UIListView.js +39 -15
- package/Root/Frameworks/UIKit/UIMenu.js +1 -1
- package/Root/Frameworks/UIKit/UIMenuView.js +5 -1
- package/Root/Frameworks/UIKit/UINavigationBar.js +2 -2
- package/Root/Frameworks/UIKit/UIPopupButton.js +31 -3
- package/Root/Frameworks/UIKit/UIScrollView.js +2 -0
- package/Root/Frameworks/UIKit/UISplitViewController.js +52 -96
- package/Root/Frameworks/UIKit/UITabView.js +2 -2
- package/Root/Frameworks/UIKit/UITabViewController.js +6 -5
- package/Root/Frameworks/UIKit/UITextField.js +3 -0
- package/Root/Frameworks/UIKit/UIView.js +18 -0
- package/Root/Frameworks/UIKit/UIViewController.js +11 -0
- package/Root/Frameworks/UIKit/UIWindowServer.js +2 -2
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
|
|
16
16
|
// #import Foundation
|
|
17
|
+
// #import "IKColorProfile.js"
|
|
17
18
|
'use strict';
|
|
18
19
|
|
|
19
20
|
(function(){
|
|
@@ -23,220 +24,70 @@ var logger = JSLog("imagekit", "colorspace");
|
|
|
23
24
|
JSClass("IKColorSpace", JSColorSpace, {
|
|
24
25
|
|
|
25
26
|
initWithProfileData: function(data){
|
|
26
|
-
|
|
27
|
-
this.
|
|
28
|
-
try{
|
|
29
|
-
this._readHeader();
|
|
30
|
-
this._readTags();
|
|
31
|
-
this._createConnectionSpace();
|
|
32
|
-
}catch (e){
|
|
33
|
-
logger.error(e);
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
27
|
+
var profile = IKColorProfile.initWithData(data);
|
|
28
|
+
return this.initWithProfile(profile);
|
|
36
29
|
},
|
|
37
30
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
preferredCMM: 0,
|
|
42
|
-
version: 0,
|
|
43
|
-
profileClass: null,
|
|
44
|
-
type: null,
|
|
45
|
-
connectionType: null,
|
|
46
|
-
createdDate: null,
|
|
47
|
-
signature: null,
|
|
48
|
-
platform: null,
|
|
49
|
-
manufacturer: null,
|
|
50
|
-
embedded: false,
|
|
51
|
-
independent: false,
|
|
52
|
-
model: null,
|
|
53
|
-
renderingIntent: 0,
|
|
54
|
-
creator: 0,
|
|
55
|
-
id: null,
|
|
56
|
-
|
|
57
|
-
_readHeader: function(){
|
|
58
|
-
if (this._data.length < 128){
|
|
59
|
-
throw new Error("Invalid profile, not enough data for header");
|
|
60
|
-
}
|
|
61
|
-
var data = this._data;
|
|
62
|
-
var dataView = this._dataView;
|
|
63
|
-
if (dataView.getUint32(0) != data.length){
|
|
64
|
-
throw new Error("Invalid profile, size does not match data length");
|
|
31
|
+
initWithProfile: function(profile){
|
|
32
|
+
if (profile === undefined || profile === null){
|
|
33
|
+
return null;
|
|
65
34
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
this.type = String.initWithData(data.subdataInRange(JSRange(16, 4)), String.Encoding.latin1);
|
|
70
|
-
this.connectionType = String.initWithData(data.subdataInRange(JSRange(20, 4)), String.Encoding.latin1);
|
|
71
|
-
this.createdDate = JSCalendar.gregorian.dateFromComponents({
|
|
72
|
-
year: dataView.getUint16(24),
|
|
73
|
-
month: dataView.getUint16(26),
|
|
74
|
-
day: dataView.getUint16(28),
|
|
75
|
-
hour: dataView.getUint16(30),
|
|
76
|
-
minute: dataView.getUint16(32),
|
|
77
|
-
second: dataView.getUint16(34)
|
|
78
|
-
});
|
|
79
|
-
this.signature = String.initWithData(data.subdataInRange(JSRange(36, 4)), String.Encoding.latin1);
|
|
80
|
-
this.platform = String.initWithData(data.subdataInRange(JSRange(40, 4)), String.Encoding.latin1);
|
|
81
|
-
var flags = dataView.getUint32(44);
|
|
82
|
-
this.embedded = (flags & 0x01) === 0x01;
|
|
83
|
-
this.independent = (flags & 0x02) === 0x02;
|
|
84
|
-
this.manufacturer = dataView.getUint32(48);
|
|
85
|
-
this.model = dataView.getUint32(52);
|
|
86
|
-
// attributes1: dataView.getUint32(56),
|
|
87
|
-
// attributes2: dataView.getUint32(60),
|
|
88
|
-
this.renderingIntent = dataView.getUint32(64);
|
|
89
|
-
this.connectionWhitepoint = XYZ32(dataView.getUint32(68), dataView.getUint32(72), dataView.getUint32(76));
|
|
90
|
-
this.creator = dataView.getUint32(80);
|
|
91
|
-
this.id = data.subdataInRange(JSRange(84, 16)).hexStringRepresentation();
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
_tags: null,
|
|
95
|
-
|
|
96
|
-
_readTags: function(){
|
|
97
|
-
if (this._data.length < 128){
|
|
98
|
-
throw new Error("Invalid profile, not enough data for tag count");
|
|
35
|
+
if (profile.profileClass === IKColorProfile.ProfileClass.deviceLink){
|
|
36
|
+
logger.warn("color profile must not be a device link class");
|
|
37
|
+
return null;
|
|
99
38
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
39
|
+
if (profile.connectionWhitepoint !== JSColorSpace.Whitepoint.D50){
|
|
40
|
+
logger.warn("color profile must use the D50 pcs illuminant");
|
|
41
|
+
return null;
|
|
103
42
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
};
|
|
112
|
-
if (tag.range.end > this._data.length){
|
|
113
|
-
throw new Error("Invalid profile, not enough data for tag %s at %d (%d)".sprintf(tag.name, tag.range.location, tag.range.length));
|
|
114
|
-
}
|
|
115
|
-
this._tags[tag.name.trim()] = tag;
|
|
116
|
-
offset += 12;
|
|
43
|
+
if (profile.connectionSpace === IKColorProfile.ColorSpace.lab){
|
|
44
|
+
this._connectionSpace = JSColorSpace.lab;
|
|
45
|
+
}else if (profile.connectionSpace === IKColorProfile.ColorSpace.xyz){
|
|
46
|
+
this._connectionSpace = JSColorSpace.xyz;
|
|
47
|
+
}else{
|
|
48
|
+
logger.warn("color profile must have a Lab or XYZ connection space");
|
|
49
|
+
return null;
|
|
117
50
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
51
|
+
if (profile.numberOfComponents === 1 && profile.grayToneReproductionCurve !== null){
|
|
52
|
+
this._componentConverter = IKColorProfileCurveComponentConverter.initWithCurve(profile.grayToneReproductionCurve.fn);
|
|
53
|
+
}else if (profile.aToB0 !== null && profile.bToA0 !== null){
|
|
54
|
+
this._componentConverter = IKColorProfileLookupComponentConverter.initWithLookupTables(profile.aToB0, profile.bToA0, profile.connectionSpace);
|
|
55
|
+
}else if (profile.redToneReproductionCurve !== null && profile.greenToneReproductionCurve !== null && profile.blueToneReproductionCurve !== null && profile.redMatrixColumn !== null && profile.greenMatrixColumn !== null && profile.blueMatrixColumn !== null){
|
|
56
|
+
var matrix = [
|
|
57
|
+
[profile.redMatrixColumn.value[0], profile.greenMatrixColumn.value[0], profile.blueMatrixColumn.value[0]],
|
|
58
|
+
[profile.redMatrixColumn.value[1], profile.greenMatrixColumn.value[1], profile.blueMatrixColumn.value[1]],
|
|
59
|
+
[profile.redMatrixColumn.value[2], profile.greenMatrixColumn.value[2], profile.blueMatrixColumn.value[2]]
|
|
60
|
+
];
|
|
61
|
+
var curves = [
|
|
62
|
+
profile.redToneReproductionCurve.fn,
|
|
63
|
+
profile.greenToneReproductionCurve.fn,
|
|
64
|
+
profile.blueToneReproductionCurve.fn
|
|
65
|
+
];
|
|
66
|
+
this._componentConverter = IKColorProfileMatrixComponentConverter.initWithMatrix(matrix, curves);
|
|
128
67
|
}else{
|
|
129
|
-
|
|
68
|
+
logger.warn("color profile does not contain supported conversion tags");
|
|
69
|
+
return null;
|
|
130
70
|
}
|
|
71
|
+
// TODO: anything with media white point?
|
|
72
|
+
this._profile = profile;
|
|
73
|
+
this.numberOfComponents = profile.numberOfComponents;
|
|
74
|
+
this.name = "icc-%s".sprintf(profile.colorSpace.trim());
|
|
131
75
|
},
|
|
132
76
|
|
|
77
|
+
profile: JSReadOnlyProperty("_profile", null),
|
|
78
|
+
connectionSpace:JSReadOnlyProperty("_connectionSpace", null),
|
|
79
|
+
_componentConverter: null,
|
|
80
|
+
|
|
133
81
|
xyzFromComponents: function(components){
|
|
134
|
-
var connectionComponents = this.connectionComponentsFromComponents(components);
|
|
135
|
-
return this.
|
|
82
|
+
var connectionComponents = this._componentConverter.connectionComponentsFromComponents(components);
|
|
83
|
+
return this._connectionSpace.xyzFromComponents(connectionComponents);
|
|
136
84
|
},
|
|
137
85
|
|
|
138
86
|
componentsFromXYZ: function(xyz){
|
|
139
|
-
var connectionComponents = this.
|
|
140
|
-
return this.componentsFromConnectionComponents(connectionComponents);
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
connectionComponentsFromComponents: function(components){
|
|
144
|
-
// TODO:
|
|
87
|
+
var connectionComponents = this._connectionSpace.componentsFromXYZ(xyz);
|
|
88
|
+
return this._componentConverter.componentsFromConnectionComponents(connectionComponents);
|
|
145
89
|
},
|
|
146
90
|
|
|
147
|
-
componentsFromConnectionComponents: function(connectionComponents){
|
|
148
|
-
// TODO:
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
mediaWhitepoint: JSLazyInitProperty("_readMediaWhitepoint"),
|
|
152
|
-
|
|
153
|
-
_readMediaWhitepoint: function(){
|
|
154
|
-
var tag = this.tags.wtpt;
|
|
155
|
-
if (!tag){
|
|
156
|
-
throw new Error("wtpt tag not found");
|
|
157
|
-
}
|
|
158
|
-
return XYZ32(
|
|
159
|
-
this._dataView.getUint32(tag.offset + 8),
|
|
160
|
-
this._dataView.getUint32(tag.offset + 12),
|
|
161
|
-
this._dataView.getUint32(tag.offset + 16)
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
91
|
});
|
|
166
92
|
|
|
167
|
-
var s15Fixed16 = function(i){
|
|
168
|
-
var f = ((i & 0x7FFF0000) >> 16) + ((i & 0xFFFF) / 65536.0);
|
|
169
|
-
if (i & (0x80000000) != 0){
|
|
170
|
-
return -f;
|
|
171
|
-
}
|
|
172
|
-
return f;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
var u8Fixed8 = function(i){
|
|
176
|
-
return (i >> 8) + ((i & 0xFF) / 256.0);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
var XYZ32 = function(x, y, z){
|
|
180
|
-
if (x == 0x0000F6D6 && y == 0x00010000 && z == 0x0000D32D){
|
|
181
|
-
return JSColorSpace.Whitepoint.D50;
|
|
182
|
-
}
|
|
183
|
-
return [
|
|
184
|
-
s15Fixed16(x),
|
|
185
|
-
s15Fixed16(y),
|
|
186
|
-
s15Fixed16(z)
|
|
187
|
-
];
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
IKColorSpace.ProfileClass = {
|
|
191
|
-
input: "scnr",
|
|
192
|
-
display: "mntr",
|
|
193
|
-
output: "prtr",
|
|
194
|
-
deviceLink: "link",
|
|
195
|
-
colorSpace: "spac",
|
|
196
|
-
abstract: "abst",
|
|
197
|
-
namedColor: "nmcl"
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
IKColorSpace.Type = {
|
|
201
|
-
xyz: "XYZ ",
|
|
202
|
-
lab: "Lab ",
|
|
203
|
-
luv: "Luv ",
|
|
204
|
-
ycbcr: "YCbr",
|
|
205
|
-
yxy: "Yxy ",
|
|
206
|
-
rgb: "RGB",
|
|
207
|
-
gray: "GRAY",
|
|
208
|
-
hsv: "HSV ",
|
|
209
|
-
hls: "HLS ",
|
|
210
|
-
cmyk: "CMYK",
|
|
211
|
-
cmy: "CMY ",
|
|
212
|
-
twoColor: "2CLR",
|
|
213
|
-
threeColor: "3CLR",
|
|
214
|
-
fourColor: "4CLR",
|
|
215
|
-
fiveColor: "5CLR",
|
|
216
|
-
sixColor: "6CLR",
|
|
217
|
-
sevenColor: "7CLR",
|
|
218
|
-
eightColor: "8CLR",
|
|
219
|
-
nineColor: "9CLR",
|
|
220
|
-
tenColor: "ACLR",
|
|
221
|
-
elevenColor: "BCLR",
|
|
222
|
-
twelveColor: "CCLR",
|
|
223
|
-
thirteenColor: "DCLR",
|
|
224
|
-
fourteenColor: "ECLR",
|
|
225
|
-
fifteenColor: "FCLR"
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
IKColorSpace.Platform = {
|
|
229
|
-
apple: "APPL",
|
|
230
|
-
microsoft: "MSFT",
|
|
231
|
-
siliconGraphics: "SGI ",
|
|
232
|
-
sunMicrosystems: "SUNW"
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
IKColorSpace.RenderingIntent = {
|
|
236
|
-
perceptual: 0,
|
|
237
|
-
mediaRelative: 1,
|
|
238
|
-
saturation: 2,
|
|
239
|
-
absolute: 3
|
|
240
|
-
};
|
|
241
|
-
|
|
242
93
|
})();
|
|
@@ -701,9 +701,7 @@ var IKDecoderPNGError = function(code, byteOffset, msg){
|
|
|
701
701
|
this.code = code;
|
|
702
702
|
this.byteOffset = byteOffset;
|
|
703
703
|
this.msg = msg;
|
|
704
|
-
|
|
705
|
-
Error.captureStackTrace(this, IKDecoderPNGError);
|
|
706
|
-
}
|
|
704
|
+
Error.captureStackTrace(this, IKDecoderPNGError);
|
|
707
705
|
};
|
|
708
706
|
|
|
709
707
|
IKDecoderPNGError.prototype = Object.create(Error.prototype);
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// // Copyright 2022 Breakside Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Breakside Public License, Version 1.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// If a copy of the License was not distributed with this file, you may
|
|
6
|
+
// obtain a copy at
|
|
7
|
+
//
|
|
8
|
+
// http://breakside.io/licenses/LICENSE-1.0.txt
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
|
|
16
|
+
// #import Foundation
|
|
17
|
+
'use strict';
|
|
18
|
+
|
|
19
|
+
JSGlobalObject.IKMatrix = function(m){
|
|
20
|
+
Object.defineProperties(m, {
|
|
21
|
+
rows: {
|
|
22
|
+
configurable: true,
|
|
23
|
+
enumerable: false,
|
|
24
|
+
value: m.length
|
|
25
|
+
},
|
|
26
|
+
columns: {
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: false,
|
|
29
|
+
value: m.length > 0 ? m[0].length : 0
|
|
30
|
+
},
|
|
31
|
+
determinant: {
|
|
32
|
+
configurable: true,
|
|
33
|
+
enumerable: false,
|
|
34
|
+
value: function(){
|
|
35
|
+
if (m.rows === 2 && m.columns === 2){
|
|
36
|
+
return m[0][0] * m[1][1] - m[0][1] * m[1][0];
|
|
37
|
+
}
|
|
38
|
+
if (m.rows === 3 && m.columns === 3){
|
|
39
|
+
return m[0][0] * m[1][1] * m[2][2] -
|
|
40
|
+
m[0][0] * m[1][2] * m[2][1] -
|
|
41
|
+
m[0][1] * m[1][0] * m[2][2] +
|
|
42
|
+
m[0][1] * m[1][2] * m[2][0] +
|
|
43
|
+
m[0][2] * m[1][0] * m[2][1] -
|
|
44
|
+
m[0][2] * m[1][1] * m[2][0];
|
|
45
|
+
}
|
|
46
|
+
throw new Error("Unable to compute %dx%d determinant".sprintf(m.rows, m.columns));
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
inverse: {
|
|
50
|
+
configurable: true,
|
|
51
|
+
enumerable: false,
|
|
52
|
+
value: function(){
|
|
53
|
+
if (m.rows === 2 && m.columns === 2){
|
|
54
|
+
return IKMatrix([
|
|
55
|
+
[m[1][1], -m[0][1]],
|
|
56
|
+
[-m[1][0], m[0][0]]
|
|
57
|
+
]).multiplied(1.0 / m.determinant());
|
|
58
|
+
}
|
|
59
|
+
if (m.rows === 3 && m.columns === 3){
|
|
60
|
+
return IKMatrix([
|
|
61
|
+
[
|
|
62
|
+
IKMatrix([
|
|
63
|
+
[m[1][1], m[1][2]],
|
|
64
|
+
[m[2][1], m[2][2]]
|
|
65
|
+
]).determinant(),
|
|
66
|
+
IKMatrix([
|
|
67
|
+
[m[0][2], m[0][1]],
|
|
68
|
+
[m[2][2], m[2][1]]
|
|
69
|
+
]).determinant(),
|
|
70
|
+
IKMatrix([
|
|
71
|
+
[m[0][1], m[0][2]],
|
|
72
|
+
[m[1][1], m[1][2]]
|
|
73
|
+
]).determinant()
|
|
74
|
+
],
|
|
75
|
+
[
|
|
76
|
+
IKMatrix([
|
|
77
|
+
[m[1][2], m[1][0]],
|
|
78
|
+
[m[2][2], m[2][0]]
|
|
79
|
+
]).determinant(),
|
|
80
|
+
IKMatrix([
|
|
81
|
+
[m[0][0], m[0][2]],
|
|
82
|
+
[m[2][0], m[2][2]]
|
|
83
|
+
]).determinant(),
|
|
84
|
+
IKMatrix([
|
|
85
|
+
[m[0][2], m[0][0]],
|
|
86
|
+
[m[1][2], m[1][0]]
|
|
87
|
+
]).determinant()
|
|
88
|
+
],
|
|
89
|
+
[
|
|
90
|
+
IKMatrix([
|
|
91
|
+
[m[1][0], m[1][1]],
|
|
92
|
+
[m[2][0], m[2][1]]
|
|
93
|
+
]).determinant(),
|
|
94
|
+
IKMatrix([
|
|
95
|
+
[m[0][1], m[0][0]],
|
|
96
|
+
[m[2][1], m[2][0]]
|
|
97
|
+
]).determinant(),
|
|
98
|
+
IKMatrix([
|
|
99
|
+
[m[0][0], m[0][1]],
|
|
100
|
+
[m[1][0], m[1][1]]
|
|
101
|
+
]).determinant()
|
|
102
|
+
]
|
|
103
|
+
]).multiplied(1.0 / m.determinant());
|
|
104
|
+
}
|
|
105
|
+
throw new Error("Unable to compute %dx%d inverse".sprintf(m.rows, m.columns));
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
multiplied: {
|
|
109
|
+
configurable: true,
|
|
110
|
+
enumerable: false,
|
|
111
|
+
value: function(x){
|
|
112
|
+
var result = IKMatrix(JSDeepCopy(m));
|
|
113
|
+
var row, col;
|
|
114
|
+
for (row = 0; row < result.rows; ++row){
|
|
115
|
+
for (col = 0; col < result.columns; ++col){
|
|
116
|
+
result[row][col] *= x;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return m;
|
|
124
|
+
};
|
|
@@ -49,7 +49,9 @@ JSClass("SKFileJobQueue", SKJobQueue, {
|
|
|
49
49
|
},
|
|
50
50
|
|
|
51
51
|
handleChange: function(eventType, filename){
|
|
52
|
-
|
|
52
|
+
let url = JSURL.initWithString(filename, this.queueURL);
|
|
53
|
+
let path = this.fileManager.pathForURL(url);
|
|
54
|
+
if (fs.existsSync(path)){
|
|
53
55
|
this.notifyConsumer(this);
|
|
54
56
|
}
|
|
55
57
|
},
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
|
|
16
|
+
// #import Foundation
|
|
16
17
|
'use strict';
|
|
17
18
|
|
|
18
19
|
JSGlobalObject.SKHTTPError = function(statusCode, message, object){
|
|
@@ -28,9 +29,7 @@ JSGlobalObject.SKHTTPError = function(statusCode, message, object){
|
|
|
28
29
|
this.message = message;
|
|
29
30
|
this.object = object || null;
|
|
30
31
|
}
|
|
31
|
-
|
|
32
|
-
Error.captureStackTrace(this, SKHTTPError);
|
|
33
|
-
}
|
|
32
|
+
Error.captureStackTrace(this, SKHTTPError);
|
|
34
33
|
};
|
|
35
34
|
|
|
36
35
|
JSGlobalObject.SKHTTPError.prototype = Object.create(Error.prototype);
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
// #import Foundation
|
|
17
17
|
// #import "SKHTTPResponse.js"
|
|
18
18
|
// #import "SKValidatingObject.js"
|
|
19
|
+
// #import "SKUserAgent.js"
|
|
19
20
|
'use strict';
|
|
20
21
|
|
|
21
22
|
JSClass("SKHTTPRequest", JSObject, {
|
|
@@ -299,4 +300,10 @@ JSClass("SKHTTPRequest", JSObject, {
|
|
|
299
300
|
return null;
|
|
300
301
|
},
|
|
301
302
|
|
|
303
|
+
userAgent: JSReadOnlyProperty(),
|
|
304
|
+
|
|
305
|
+
getUserAgent: function(){
|
|
306
|
+
return SKUserAgent.initWithString(this.headerMap.get("User-Agent", null));
|
|
307
|
+
},
|
|
308
|
+
|
|
302
309
|
});
|
|
@@ -197,16 +197,20 @@ JSClass("SKHTTPResponder", JSObject, {
|
|
|
197
197
|
return Promise.reject(new Error("not implemented"));
|
|
198
198
|
},
|
|
199
199
|
|
|
200
|
-
addAllowedOrigin: function(origin, methods, headers){
|
|
200
|
+
addAllowedOrigin: function(origin, methods, headers, credentials){
|
|
201
201
|
if (methods === undefined){
|
|
202
202
|
methods = ["*"];
|
|
203
203
|
}
|
|
204
204
|
if (headers === undefined){
|
|
205
205
|
headers = ["Authorization", "Content-Type"];
|
|
206
206
|
}
|
|
207
|
+
if (credentials === undefined){
|
|
208
|
+
credentials = false;
|
|
209
|
+
}
|
|
207
210
|
this.allowedOrigins[origin] = {
|
|
208
211
|
methods: methods,
|
|
209
|
-
headers: headers
|
|
212
|
+
headers: headers,
|
|
213
|
+
credentials: credentials
|
|
210
214
|
};
|
|
211
215
|
},
|
|
212
216
|
|
|
@@ -229,6 +233,9 @@ JSClass("SKHTTPResponder", JSObject, {
|
|
|
229
233
|
if (this.request.headerMap.get('Access-Control-Request-Headers', null) !== null){
|
|
230
234
|
this.response.headerMap.set("Access-Control-Allow-Headers", allowed.headers.join(", "));
|
|
231
235
|
}
|
|
236
|
+
if (allowed.credentials){
|
|
237
|
+
this.response.headerMap.set("Access-Control-Allow-Credentials", "true");
|
|
238
|
+
}
|
|
232
239
|
if (this.request.method == "OPTIONS"){
|
|
233
240
|
this.response.headerMap.set("Access-Control-Max-Age", 60 * 60);
|
|
234
241
|
}
|