@octane-xplat/nativescript-mason-core 0.0.1 → 1.0.0-beta.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/LICENSE +201 -0
- package/README.md +113 -2
- package/artifact-inventory.json +746 -0
- package/box-shadow.d.ts +10 -0
- package/box-shadow.js +48 -0
- package/common.d.ts +482 -0
- package/common.js +2645 -0
- package/css-colors.d.ts +17 -0
- package/css-colors.js +54 -0
- package/css-filter.d.ts +17 -0
- package/css-filter.js +140 -0
- package/css-keyframes.d.ts +41 -0
- package/css-keyframes.js +437 -0
- package/css-math.d.ts +34 -0
- package/css-math.js +300 -0
- package/css-shorthands.d.ts +65 -0
- package/css-shorthands.js +673 -0
- package/css-transform.d.ts +6 -0
- package/css-transform.js +100 -0
- package/diagnostics.d.ts +51 -0
- package/diagnostics.js +52 -0
- package/display-density.d.ts +9 -0
- package/display-density.js +20 -0
- package/fonts.d.ts +20 -0
- package/fonts.js +88 -0
- package/foreign-layout.d.ts +6 -0
- package/foreign-layout.js +149 -0
- package/gradient-stops.d.ts +25 -0
- package/gradient-stops.js +112 -0
- package/index.android.d.ts +9 -0
- package/index.android.js +8 -0
- package/index.d.ts +10 -0
- package/index.ios.d.ts +9 -0
- package/index.ios.js +8 -0
- package/ios-host-README.md +124 -0
- package/layout-types.d.ts +192 -0
- package/mask.d.ts +54 -0
- package/mask.js +26 -0
- package/native-types-README.md +51 -0
- package/package.json +44 -6
- package/panel-helpers.d.ts +3 -0
- package/panel-helpers.js +8 -0
- package/platforms/android/MasonCore.aar +0 -0
- package/platforms/android/include.gradle +6 -0
- package/platforms/android/manifest.json +73 -0
- package/platforms/ios/FontManager.LICENSE +201 -0
- package/platforms/ios/MasonCore.xcframework/Info.plist +43 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/Mason.h +25 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Headers/mason_native.h +601 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/MasonCore +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios.swiftsourceinfo +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.abi.json +100095 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.private.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/Modules/module.modulemap +9 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/Mason.h +25 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/MasonCore-Swift.h +1739 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Headers/mason_native.h +601 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/MasonCore +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/Project/arm64-apple-ios-simulator.swiftsourceinfo +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.abi.json +100095 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/MasonCore.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3174 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/Modules/module.modulemap +9 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/Info.plist +0 -0
- package/platforms/ios/MasonCore.xcframework/ios-arm64-simulator/MasonCore.framework/SDWebImage_SDWebImage.bundle/PrivacyInfo.xcprivacy +23 -0
- package/platforms/ios/Package.resolved +24 -0
- package/platforms/ios/SDWebImage.LICENSE +20 -0
- package/platforms/ios/build.xcconfig +4 -0
- package/platforms/ios/device-manifest.json +213 -0
- package/platforms/ios/include/FontManager/NSCFontDescriptors.h +36 -0
- package/platforms/ios/include/FontManager/NSCFontFace.h +98 -0
- package/platforms/ios/include/FontManager/NSCFontFaceSet.h +73 -0
- package/platforms/ios/include/FontManager/NSCFontManagerUmbrella.h +7 -0
- package/platforms/ios/include/FontManager/NSCFontParser.h +22 -0
- package/platforms/ios/include/FontManager/NSCFontRegex.h +4 -0
- package/platforms/ios/include/FontManager/NSCFontResolver.h +43 -0
- package/platforms/ios/include/FontManager/NSCFontStyle.h +27 -0
- package/platforms/ios/include/FontManager/NSCFontTypes.h +41 -0
- package/platforms/ios/include/SDWebImage/NSButton+WebCache.h +340 -0
- package/platforms/ios/include/SDWebImage/NSData+ImageContentType.h +63 -0
- package/platforms/ios/include/SDWebImage/NSImage+Compatibility.h +67 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImage.h +136 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImagePlayer.h +113 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageRep.h +33 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageView+WebCache.h +168 -0
- package/platforms/ios/include/SDWebImage/SDAnimatedImageView.h +125 -0
- package/platforms/ios/include/SDWebImage/SDCallbackQueue.h +59 -0
- package/platforms/ios/include/SDWebImage/SDDiskCache.h +146 -0
- package/platforms/ios/include/SDWebImage/SDGraphicsImageRenderer.h +84 -0
- package/platforms/ios/include/SDWebImage/SDImageAPNGCoder.h +19 -0
- package/platforms/ios/include/SDWebImage/SDImageAWebPCoder.h +23 -0
- package/platforms/ios/include/SDWebImage/SDImageCache.h +482 -0
- package/platforms/ios/include/SDWebImage/SDImageCacheConfig.h +153 -0
- package/platforms/ios/include/SDWebImage/SDImageCacheDefine.h +179 -0
- package/platforms/ios/include/SDWebImage/SDImageCachesManager.h +81 -0
- package/platforms/ios/include/SDWebImage/SDImageCoder.h +347 -0
- package/platforms/ios/include/SDWebImage/SDImageCoderHelper.h +251 -0
- package/platforms/ios/include/SDWebImage/SDImageCodersManager.h +58 -0
- package/platforms/ios/include/SDWebImage/SDImageFrame.h +44 -0
- package/platforms/ios/include/SDWebImage/SDImageGIFCoder.h +22 -0
- package/platforms/ios/include/SDWebImage/SDImageGraphics.h +28 -0
- package/platforms/ios/include/SDWebImage/SDImageHEICCoder.h +25 -0
- package/platforms/ios/include/SDWebImage/SDImageIOAnimatedCoder.h +65 -0
- package/platforms/ios/include/SDWebImage/SDImageIOCoder.h +30 -0
- package/platforms/ios/include/SDWebImage/SDImageLoader.h +146 -0
- package/platforms/ios/include/SDWebImage/SDImageLoadersManager.h +40 -0
- package/platforms/ios/include/SDWebImage/SDImageTransformer.h +283 -0
- package/platforms/ios/include/SDWebImage/SDMemoryCache.h +78 -0
- package/platforms/ios/include/SDWebImage/SDWebImage.h +91 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCacheKeyFilter.h +35 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCacheSerializer.h +39 -0
- package/platforms/ios/include/SDWebImage/SDWebImageCompat.h +102 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDefine.h +420 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloader.h +320 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderConfig.h +113 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderDecryptor.h +52 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderOperation.h +191 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderRequestModifier.h +72 -0
- package/platforms/ios/include/SDWebImage/SDWebImageDownloaderResponseModifier.h +72 -0
- package/platforms/ios/include/SDWebImage/SDWebImageError.h +33 -0
- package/platforms/ios/include/SDWebImage/SDWebImageIndicator.h +119 -0
- package/platforms/ios/include/SDWebImage/SDWebImageManager.h +290 -0
- package/platforms/ios/include/SDWebImage/SDWebImageOperation.h +27 -0
- package/platforms/ios/include/SDWebImage/SDWebImageOptionsProcessor.h +78 -0
- package/platforms/ios/include/SDWebImage/SDWebImagePrefetcher.h +168 -0
- package/platforms/ios/include/SDWebImage/SDWebImageTransition.h +131 -0
- package/platforms/ios/include/SDWebImage/UIButton+WebCache.h +402 -0
- package/platforms/ios/include/SDWebImage/UIImage+ExtendedCacheData.h +24 -0
- package/platforms/ios/include/SDWebImage/UIImage+ForceDecode.h +52 -0
- package/platforms/ios/include/SDWebImage/UIImage+GIF.h +26 -0
- package/platforms/ios/include/SDWebImage/UIImage+MemoryCacheCost.h +27 -0
- package/platforms/ios/include/SDWebImage/UIImage+Metadata.h +104 -0
- package/platforms/ios/include/SDWebImage/UIImage+MultiFormat.h +81 -0
- package/platforms/ios/include/SDWebImage/UIImage+Transform.h +164 -0
- package/platforms/ios/include/SDWebImage/UIImageView+HighlightedWebCache.h +142 -0
- package/platforms/ios/include/SDWebImage/UIImageView+WebCache.h +209 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCache.h +131 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCacheOperation.h +52 -0
- package/platforms/ios/include/SDWebImage/UIView+WebCacheState.h +63 -0
- package/platforms/ios/include/module.modulemap +2 -0
- package/platforms/ios/manifest.json +132 -0
- package/platforms/ios/simulator-manifest.json +213 -0
- package/plugin-README.md +197 -0
- package/properties.d.ts +154 -0
- package/properties.js +2454 -0
- package/pseudo.d.ts +9 -0
- package/pseudo.js +57 -0
- package/scroll/index.android.d.ts +15 -0
- package/scroll/index.android.js +72 -0
- package/scroll/index.d.ts +5 -0
- package/scroll/index.ios.d.ts +18 -0
- package/scroll/index.ios.js +106 -0
- package/style.d.ts +768 -0
- package/style.js +7151 -0
- package/symbols.d.ts +25 -0
- package/symbols.js +41 -0
- package/tree/index.android.d.ts +11 -0
- package/tree/index.android.js +42 -0
- package/tree/index.d.ts +15 -0
- package/tree/index.ios.d.ts +26 -0
- package/tree/index.ios.js +53 -0
- package/typings/android-declarations.d.ts +4 -0
- package/typings/android.d.ts +9730 -0
- package/typings/manifest.json +45 -0
- package/typings/native.d.ts +5 -0
- package/typings/objc!FontManager.d.ts +389 -0
- package/typings/objc!MasonCore.d.ts +2472 -0
- package/typings/objc!SDWebImage.d.ts +3378 -0
- package/units.d.ts +29 -0
- package/units.js +44 -0
- package/utils/index.android.d.ts +211 -0
- package/utils/index.android.js +595 -0
- package/utils/index.ios.d.ts +222 -0
- package/utils/index.ios.js +790 -0
- package/view/index.android.d.ts +13 -0
- package/view/index.android.js +74 -0
- package/view/index.d.ts +2 -0
- package/view/index.ios.d.ts +24 -0
- package/view/index.ios.js +157 -0
package/css-math.js
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `calc()`, `min()`, `max()` and `clamp()` evaluated with Mason's units. Lengths resolve to CSS px
|
|
3
|
+
* as read; a pure `%` result stays a percentage, `%` mixed with a length is left unresolved.
|
|
4
|
+
*/
|
|
5
|
+
const MATH_FUNCTION = /^(calc|min|max|clamp)\(/i;
|
|
6
|
+
const MATH_FUNCTION_ANYWHERE = /(?<![\w-])(calc|min|max|clamp)\(/i;
|
|
7
|
+
const URL = /(?<![\w-])url\(/i;
|
|
8
|
+
/** Whether `value` is a single math function, e.g. `calc(1rem + 2px)`. */
|
|
9
|
+
export function isCssMathFunction(value) {
|
|
10
|
+
return MATH_FUNCTION.test(value.trim());
|
|
11
|
+
}
|
|
12
|
+
/** Whether `value` holds a math function anywhere. */
|
|
13
|
+
export function hasCssMathFunction(value) {
|
|
14
|
+
return MATH_FUNCTION_ANYWHERE.test(value);
|
|
15
|
+
}
|
|
16
|
+
const NUMBER = /^[+-]?(\d+\.?\d*|\.\d+)(e[+-]?\d+)?/i;
|
|
17
|
+
const UNIT = /^(%|[a-z]+)/i;
|
|
18
|
+
const IDENT = /^[a-z-]+/i;
|
|
19
|
+
function tokenize(source) {
|
|
20
|
+
const tokens = [];
|
|
21
|
+
let i = 0;
|
|
22
|
+
while (i < source.length) {
|
|
23
|
+
const ch = source[i];
|
|
24
|
+
if (/\s/.test(ch)) {
|
|
25
|
+
i++;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const rest = source.slice(i);
|
|
29
|
+
const previous = tokens[tokens.length - 1];
|
|
30
|
+
// A sign belongs to the number unless it follows an operand.
|
|
31
|
+
const signAllowed = !previous || previous.type === 'op' || previous.type === 'open' || previous.type === 'comma';
|
|
32
|
+
const number = (signAllowed || (ch !== '+' && ch !== '-')) && NUMBER.exec(rest);
|
|
33
|
+
if (number) {
|
|
34
|
+
i += number[0].length;
|
|
35
|
+
const unit = UNIT.exec(source.slice(i));
|
|
36
|
+
if (unit) {
|
|
37
|
+
i += unit[0].length;
|
|
38
|
+
}
|
|
39
|
+
tokens.push({ type: 'number', value: parseFloat(number[0]), unit: unit ? unit[0].toLowerCase() : '' });
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (ch === '+' || ch === '-' || ch === '*' || ch === '/') {
|
|
43
|
+
tokens.push({ type: 'op', op: ch });
|
|
44
|
+
i++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (ch === '(') {
|
|
48
|
+
tokens.push({ type: 'open', fn: '' });
|
|
49
|
+
i++;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (ch === ')') {
|
|
53
|
+
tokens.push({ type: 'close' });
|
|
54
|
+
i++;
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (ch === ',') {
|
|
58
|
+
tokens.push({ type: 'comma' });
|
|
59
|
+
i++;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const ident = IDENT.exec(rest);
|
|
63
|
+
if (ident && source[i + ident[0].length] === '(') {
|
|
64
|
+
tokens.push({ type: 'open', fn: ident[0].toLowerCase() });
|
|
65
|
+
i += ident[0].length + 1;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
return tokens;
|
|
71
|
+
}
|
|
72
|
+
class Parser {
|
|
73
|
+
constructor(tokens, resolveUnit) {
|
|
74
|
+
this.tokens = tokens;
|
|
75
|
+
this.resolveUnit = resolveUnit;
|
|
76
|
+
this.at = 0;
|
|
77
|
+
}
|
|
78
|
+
done() {
|
|
79
|
+
return this.at === this.tokens.length;
|
|
80
|
+
}
|
|
81
|
+
peek() {
|
|
82
|
+
return this.tokens[this.at];
|
|
83
|
+
}
|
|
84
|
+
next() {
|
|
85
|
+
return this.tokens[this.at++];
|
|
86
|
+
}
|
|
87
|
+
sum() {
|
|
88
|
+
let left = this.product();
|
|
89
|
+
while (left) {
|
|
90
|
+
const token = this.peek();
|
|
91
|
+
if (token?.type !== 'op' || (token.op !== '+' && token.op !== '-')) {
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
this.next();
|
|
95
|
+
const right = this.product();
|
|
96
|
+
if (!right || right.number !== left.number) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
const sign = token.op === '+' ? 1 : -1;
|
|
100
|
+
left = { number: left.number, px: left.px + sign * right.px, pct: left.pct + sign * right.pct };
|
|
101
|
+
}
|
|
102
|
+
return left;
|
|
103
|
+
}
|
|
104
|
+
product() {
|
|
105
|
+
let left = this.operand();
|
|
106
|
+
while (left) {
|
|
107
|
+
const token = this.peek();
|
|
108
|
+
if (token?.type !== 'op' || (token.op !== '*' && token.op !== '/')) {
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
this.next();
|
|
112
|
+
const right = this.operand();
|
|
113
|
+
if (!right) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
if (token.op === '*') {
|
|
117
|
+
// One side has to be a plain number.
|
|
118
|
+
if (left.number) {
|
|
119
|
+
left = { number: right.number, px: right.px * left.px, pct: right.pct * left.px };
|
|
120
|
+
}
|
|
121
|
+
else if (right.number) {
|
|
122
|
+
left = { number: false, px: left.px * right.px, pct: left.pct * right.px };
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// Only by a number; dividing by zero gives an infinity the caller rejects.
|
|
130
|
+
if (!right.number) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
left = { number: left.number, px: left.px / right.px, pct: left.pct / right.px };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return left;
|
|
137
|
+
}
|
|
138
|
+
operand() {
|
|
139
|
+
const token = this.next();
|
|
140
|
+
if (!token) {
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
if (token.type === 'number') {
|
|
144
|
+
if (token.unit === '') {
|
|
145
|
+
return { number: true, px: token.value, pct: 0 };
|
|
146
|
+
}
|
|
147
|
+
const resolved = this.resolveUnit(token.value, token.unit);
|
|
148
|
+
if (resolved === undefined) {
|
|
149
|
+
return token.unit === '%' ? { number: false, px: 0, pct: token.value } : undefined;
|
|
150
|
+
}
|
|
151
|
+
return typeof resolved === 'number' ? { number: false, px: resolved, pct: 0 } : { number: false, px: 0, pct: resolved.percent };
|
|
152
|
+
}
|
|
153
|
+
if (token.type === 'open') {
|
|
154
|
+
return this.call(token.fn);
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
call(fn) {
|
|
159
|
+
const args = [];
|
|
160
|
+
for (;;) {
|
|
161
|
+
const arg = this.sum();
|
|
162
|
+
if (!arg) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
args.push(arg);
|
|
166
|
+
const token = this.next();
|
|
167
|
+
if (token?.type === 'close') {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
if (token?.type !== 'comma') {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
switch (fn) {
|
|
175
|
+
case '':
|
|
176
|
+
case 'calc':
|
|
177
|
+
return args.length === 1 ? args[0] : undefined;
|
|
178
|
+
case 'min':
|
|
179
|
+
return compare(args, Math.min);
|
|
180
|
+
case 'max':
|
|
181
|
+
return compare(args, Math.max);
|
|
182
|
+
case 'clamp': {
|
|
183
|
+
if (args.length !== 3) {
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
const [min, preferred, max] = args;
|
|
187
|
+
const upper = compare([preferred, max], Math.min);
|
|
188
|
+
return upper && compare([min, upper], Math.max);
|
|
189
|
+
}
|
|
190
|
+
default:
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* min()/max() over values of one kind. A length and a percentage can't be
|
|
197
|
+
* compared before layout, so mixing them is unresolved.
|
|
198
|
+
*/
|
|
199
|
+
function compare(args, pick) {
|
|
200
|
+
const [first] = args;
|
|
201
|
+
if (args.some((arg) => arg.number !== first.number)) {
|
|
202
|
+
return undefined;
|
|
203
|
+
}
|
|
204
|
+
if (first.number) {
|
|
205
|
+
return { number: true, px: pick(...args.map((arg) => arg.px)), pct: 0 };
|
|
206
|
+
}
|
|
207
|
+
if (args.every((arg) => arg.pct === 0)) {
|
|
208
|
+
return { number: false, px: pick(...args.map((arg) => arg.px)), pct: 0 };
|
|
209
|
+
}
|
|
210
|
+
if (args.every((arg) => arg.px === 0)) {
|
|
211
|
+
return { number: false, px: 0, pct: pick(...args.map((arg) => arg.pct)) };
|
|
212
|
+
}
|
|
213
|
+
return undefined;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Evaluate one math function, e.g. `clamp(1rem, 2.5vw, 2rem)`, or undefined
|
|
217
|
+
* when it isn't one, doesn't parse, or mixes `%` with a length.
|
|
218
|
+
*/
|
|
219
|
+
export function evaluateCssMath(value, resolveUnit) {
|
|
220
|
+
const source = value.trim();
|
|
221
|
+
if (!MATH_FUNCTION.test(source)) {
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
const tokens = tokenize(source);
|
|
225
|
+
if (!tokens) {
|
|
226
|
+
return undefined;
|
|
227
|
+
}
|
|
228
|
+
const parser = new Parser(tokens, resolveUnit);
|
|
229
|
+
const result = parser.sum();
|
|
230
|
+
if (!result || !parser.done()) {
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
if (result.number) {
|
|
234
|
+
return Number.isFinite(result.px) ? { kind: 'number', value: result.px } : undefined;
|
|
235
|
+
}
|
|
236
|
+
if (result.pct !== 0 && result.px !== 0) {
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
if (result.pct !== 0) {
|
|
240
|
+
return Number.isFinite(result.pct) ? { kind: 'percent', percent: result.pct } : undefined;
|
|
241
|
+
}
|
|
242
|
+
return Number.isFinite(result.px) ? { kind: 'length', px: result.px } : undefined;
|
|
243
|
+
}
|
|
244
|
+
function round(n) {
|
|
245
|
+
return Math.round(n * 10000) / 10000;
|
|
246
|
+
}
|
|
247
|
+
/** A result as CSS text: `12px`, `50%` or `1.5`. */
|
|
248
|
+
export function cssMathText(result) {
|
|
249
|
+
switch (result.kind) {
|
|
250
|
+
case 'length':
|
|
251
|
+
return `${round(result.px)}px`;
|
|
252
|
+
case 'percent':
|
|
253
|
+
return `${round(result.percent)}%`;
|
|
254
|
+
case 'number':
|
|
255
|
+
return `${round(result.value)}`;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Replace every math function in `value` that resolves with its result, leaving the rest as is:
|
|
260
|
+
* `0 0 calc(0.5rem + 1px) red` becomes `0 0 9px red`.
|
|
261
|
+
*/
|
|
262
|
+
export function substituteCssMath(value, resolveUnit) {
|
|
263
|
+
if (!hasCssMathFunction(value)) {
|
|
264
|
+
return value;
|
|
265
|
+
}
|
|
266
|
+
const pattern = new RegExp(`${URL.source}|${MATH_FUNCTION_ANYWHERE.source}`, 'gi');
|
|
267
|
+
let out = '';
|
|
268
|
+
let last = 0;
|
|
269
|
+
let match;
|
|
270
|
+
while ((match = pattern.exec(value))) {
|
|
271
|
+
const open = match.index + match[0].length - 1;
|
|
272
|
+
const close = closingParen(value, open);
|
|
273
|
+
if (close === -1) {
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
pattern.lastIndex = close + 1;
|
|
277
|
+
// A url() is opaque: a data: URL may contain anything.
|
|
278
|
+
if (/^url\(/i.test(match[0])) {
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
const result = evaluateCssMath(value.slice(match.index, close + 1), resolveUnit);
|
|
282
|
+
if (result) {
|
|
283
|
+
out += value.slice(last, match.index) + cssMathText(result);
|
|
284
|
+
last = close + 1;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return out + value.slice(last);
|
|
288
|
+
}
|
|
289
|
+
function closingParen(value, open) {
|
|
290
|
+
let depth = 0;
|
|
291
|
+
for (let i = open; i < value.length; i++) {
|
|
292
|
+
if (value[i] === '(') {
|
|
293
|
+
depth++;
|
|
294
|
+
}
|
|
295
|
+
else if (value[i] === ')' && --depth === 0) {
|
|
296
|
+
return i;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return -1;
|
|
300
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { unsetValue } from '@nativescript/core';
|
|
2
|
+
export type LonghandValue = string | typeof unsetValue;
|
|
3
|
+
export declare function tokenizeCss(value: string): string[];
|
|
4
|
+
export interface CssLength {
|
|
5
|
+
value: number;
|
|
6
|
+
unit: 'dip' | 'px' | '%';
|
|
7
|
+
css: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function cssLength(css: string, parse: (value: string) => unknown): CssLength;
|
|
10
|
+
export declare function isCssLength(value: unknown): value is CssLength;
|
|
11
|
+
/** "background-color" -> "backgroundColor". */
|
|
12
|
+
export declare function toCamelCase(prop: string): string;
|
|
13
|
+
export declare const splitMargin: (value: string) => string[];
|
|
14
|
+
export declare const splitPadding: (value: string) => string[];
|
|
15
|
+
export declare const BORDER_WIDTH_KEYWORDS: ReadonlyMap<string, string>;
|
|
16
|
+
export declare const splitBorderWidth: (value: string) => string[];
|
|
17
|
+
export declare const splitBorderColor: (value: string) => string[];
|
|
18
|
+
export declare const splitMarginStartEnd: (value: string) => string[];
|
|
19
|
+
export declare const splitPaddingStartEnd: (value: string) => string[];
|
|
20
|
+
export declare const splitInsetStartEnd: (value: string) => string[];
|
|
21
|
+
export declare const splitBorderWidthStartEnd: (value: string) => string[];
|
|
22
|
+
export declare const splitBorderColorStartEnd: (value: string) => string[];
|
|
23
|
+
/** A logical property that maps onto one physical longhand: the value as is. */
|
|
24
|
+
export declare function passThrough(value: string): string[];
|
|
25
|
+
export declare const BORDER_STYLES: ReadonlySet<string>;
|
|
26
|
+
export declare const splitBorderStyle: (value: string) => string[];
|
|
27
|
+
export declare const splitBorderStyleStartEnd: (value: string) => string[];
|
|
28
|
+
/** `border-<side>` as its width, style and color; omitted parts take BORDER_OMITTED. */
|
|
29
|
+
export declare function splitBorderSide(value: string): string[];
|
|
30
|
+
/**
|
|
31
|
+
* `border` as four widths, four styles and four colors (top, right, bottom, left).
|
|
32
|
+
* Accepts up to four widths, as `border-width` does.
|
|
33
|
+
*/
|
|
34
|
+
export declare function splitBorder(value: string): string[];
|
|
35
|
+
export declare function splitBorderRadius(value: string): string[];
|
|
36
|
+
export type CornerRadius = [horizontal: string, vertical: string];
|
|
37
|
+
export type CornerIndex = 0 | 1 | 2 | 3;
|
|
38
|
+
export declare function parseCornerRadius(value: string): CornerRadius;
|
|
39
|
+
export declare function borderRadiusCorners(value: string): CornerRadius[];
|
|
40
|
+
export declare function composeBorderRadius(corners: CornerRadius[]): string;
|
|
41
|
+
export declare function splitBackground(value: string): LonghandValue[];
|
|
42
|
+
/** `mask` into image, position, size, repeat, origin, clip, composite and mode, per layer. */
|
|
43
|
+
export declare function splitMask(value: string): LonghandValue[];
|
|
44
|
+
/** A -webkit-mask-composite list as `mask-composite`; operators with no equivalent become `add`. */
|
|
45
|
+
export declare function webkitMaskComposite(value: string): string;
|
|
46
|
+
/** A -webkit-mask-origin or -clip list as the standard property. */
|
|
47
|
+
export declare function webkitMaskBox(value: string): string;
|
|
48
|
+
/** `-webkit-mask`: `mask` with WebKit's composite operators and box keywords. */
|
|
49
|
+
export declare function splitWebkitMask(value: string): LonghandValue[];
|
|
50
|
+
/**
|
|
51
|
+
* `mask-border` (and `-webkit-mask-box-image`) into source, slice, width, outset, repeat and mode:
|
|
52
|
+
* `<source> || <slice> [ / <width>? [ / <outset> ]? ]? || <repeat> || <mode>`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function splitMaskBorder(value: string): LonghandValue[];
|
|
55
|
+
export declare function splitOverflow(value: string): string[];
|
|
56
|
+
export declare function splitFlexFlow(value: string): LonghandValue[];
|
|
57
|
+
export declare function splitFlex(value: string): string[];
|
|
58
|
+
export declare function splitGap(value: string): string[];
|
|
59
|
+
/** `place-items` / `place-content` / `place-self`: the align value, then the justify value, which defaults to it. */
|
|
60
|
+
export declare function splitPlace(value: string): string[];
|
|
61
|
+
/**
|
|
62
|
+
* Splits `list-style` into type and position, in any order. An image is accepted
|
|
63
|
+
* and dropped; omitted parts reset to `disc` and `outside`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function splitListStyle(value: string): string[];
|