@octane-xplat/nativescript-mason-core 0.0.1 → 1.0.0-beta.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.
- package/LICENSE +201 -0
- package/README.md +198 -2
- package/artifact-inventory.json +774 -0
- package/box-shadow.d.ts +10 -0
- package/box-shadow.js +48 -0
- package/common.d.ts +485 -0
- package/common.js +2659 -0
- package/css-colors.d.ts +17 -0
- package/css-colors.js +54 -0
- package/css-environment.d.ts +49 -0
- package/css-environment.js +309 -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 +151 -0
- package/gradient-stops.d.ts +25 -0
- package/gradient-stops.js +112 -0
- package/index.android.d.ts +11 -0
- package/index.android.js +9 -0
- package/index.d.ts +12 -0
- package/index.ios.d.ts +11 -0
- package/index.ios.js +9 -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-environment.android.d.ts +3 -0
- package/native-environment.android.js +69 -0
- package/native-environment.d.ts +3 -0
- package/native-environment.ios.d.ts +3 -0
- package/native-environment.ios.js +65 -0
- package/native-types-README.md +51 -0
- package/package.json +47 -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 +234 -0
- package/properties.d.ts +154 -0
- package/properties.js +2456 -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 +7167 -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
|
@@ -0,0 +1,790 @@
|
|
|
1
|
+
import { Length, Utils } from '@nativescript/core';
|
|
2
|
+
import { parseUnit } from '@nativescript/core/css/parser';
|
|
3
|
+
import { isMasonView_, style_ } from '../symbols';
|
|
4
|
+
// if (__ANDROID__) {
|
|
5
|
+
// try {
|
|
6
|
+
// java.lang.System.loadLibrary('masonnative');
|
|
7
|
+
// __non_webpack_require__('system_lib://libmasonnativev8.so');
|
|
8
|
+
// UseV8Module = true;
|
|
9
|
+
// } catch (error) {
|
|
10
|
+
// console.warn('Failed to enable on FastAPI');
|
|
11
|
+
// }
|
|
12
|
+
// }
|
|
13
|
+
// if (__APPLE__) {
|
|
14
|
+
// NSCMason.alwaysEnable = true;
|
|
15
|
+
// if (!UseV8Module) {
|
|
16
|
+
// try {
|
|
17
|
+
// const installer = MasonV8Module.new();
|
|
18
|
+
// installer.install();
|
|
19
|
+
// UseV8Module = true;
|
|
20
|
+
// } catch (error) {
|
|
21
|
+
// console.warn('Failed to enable on FastAPI');
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
// }
|
|
25
|
+
let sharedMason = null;
|
|
26
|
+
function getNode(instance) {
|
|
27
|
+
const nativeView = instance?.ios;
|
|
28
|
+
if (instance[isMasonView_]) {
|
|
29
|
+
return nativeView.node;
|
|
30
|
+
}
|
|
31
|
+
if (!sharedMason) {
|
|
32
|
+
sharedMason = NSCMason.shared;
|
|
33
|
+
}
|
|
34
|
+
return sharedMason.nodeForView(nativeView, true);
|
|
35
|
+
}
|
|
36
|
+
function getStyle(instance) {
|
|
37
|
+
const nativeView = instance?.ios;
|
|
38
|
+
if (instance[isMasonView_]) {
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
return nativeView.node.style;
|
|
41
|
+
}
|
|
42
|
+
if (!sharedMason) {
|
|
43
|
+
sharedMason = NSCMason.shared;
|
|
44
|
+
}
|
|
45
|
+
return sharedMason.nodeForView(nativeView, true).style;
|
|
46
|
+
}
|
|
47
|
+
export function _forceStyleUpdate(instance) {
|
|
48
|
+
if (!instance._hasNativeView) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
// if (__ANDROID__) {
|
|
52
|
+
// const nodeOrView = getMasonInstance(instance) as org.nativescript.mason.masonkit.TextView;
|
|
53
|
+
// nodeOrView.getStyle().updateNodeAndStyle();
|
|
54
|
+
// }
|
|
55
|
+
// if (__APPLE__) {
|
|
56
|
+
// (instance.ios as MasonUIView).node.style.updateNativeStyle();
|
|
57
|
+
// }
|
|
58
|
+
}
|
|
59
|
+
export function _markDirty(instance) {
|
|
60
|
+
if (!instance._hasNativeView) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
getNode(instance).markDirty();
|
|
64
|
+
}
|
|
65
|
+
export function _isDirty(instance) {
|
|
66
|
+
if (!instance._hasNativeView) {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return getNode(instance).isDirty;
|
|
70
|
+
}
|
|
71
|
+
export function _intoType(type) {
|
|
72
|
+
switch (type) {
|
|
73
|
+
case 'auto':
|
|
74
|
+
return 0 /* MasonDimensionCompatType.Auto */;
|
|
75
|
+
case 'points':
|
|
76
|
+
return 1 /* MasonDimensionCompatType.Points */;
|
|
77
|
+
case 'percent':
|
|
78
|
+
return 2 /* MasonDimensionCompatType.Percent */;
|
|
79
|
+
case 'min-content':
|
|
80
|
+
return 3 /* MasonDimensionCompatType.MinContent */;
|
|
81
|
+
case 'max-content':
|
|
82
|
+
return 4 /* MasonDimensionCompatType.MaxContent */;
|
|
83
|
+
case 'fit-content':
|
|
84
|
+
return 5 /* MasonDimensionCompatType.FitContent */;
|
|
85
|
+
case 'fit-content-points':
|
|
86
|
+
return 6 /* MasonDimensionCompatType.FitContentPoints */;
|
|
87
|
+
case 'fit-content-percent':
|
|
88
|
+
return 7 /* MasonDimensionCompatType.FitContentPercent */;
|
|
89
|
+
case 'stretch':
|
|
90
|
+
return 8 /* MasonDimensionCompatType.Stretch */;
|
|
91
|
+
case 'content':
|
|
92
|
+
return 9 /* MasonDimensionCompatType.Content */;
|
|
93
|
+
default:
|
|
94
|
+
return 0 /* MasonDimensionCompatType.Auto */;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export function _parseDimension(dim) {
|
|
98
|
+
const type = dim.type;
|
|
99
|
+
const value = dim.value;
|
|
100
|
+
switch (type) {
|
|
101
|
+
case 0 /* MasonDimensionCompatType.Auto */:
|
|
102
|
+
return 'auto';
|
|
103
|
+
case 1 /* MasonDimensionCompatType.Points */:
|
|
104
|
+
return { value: value, unit: 'px' };
|
|
105
|
+
case 2 /* MasonDimensionCompatType.Percent */:
|
|
106
|
+
return { value: value, unit: '%' };
|
|
107
|
+
case 3 /* MasonDimensionCompatType.MinContent */:
|
|
108
|
+
return 'min-content';
|
|
109
|
+
case 4 /* MasonDimensionCompatType.MaxContent */:
|
|
110
|
+
return 'max-content';
|
|
111
|
+
case 5 /* MasonDimensionCompatType.FitContent */:
|
|
112
|
+
return 'fit-content';
|
|
113
|
+
case 6 /* MasonDimensionCompatType.FitContentPoints */:
|
|
114
|
+
return `fit-content(${value}px)`;
|
|
115
|
+
case 7 /* MasonDimensionCompatType.FitContentPercent */:
|
|
116
|
+
return `fit-content(${value}%)`;
|
|
117
|
+
case 8 /* MasonDimensionCompatType.Stretch */:
|
|
118
|
+
return 'stretch';
|
|
119
|
+
case 9 /* MasonDimensionCompatType.Content */:
|
|
120
|
+
return 'content';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export function parseLength(length, parent = 0) {
|
|
124
|
+
switch (length.unit) {
|
|
125
|
+
case '%':
|
|
126
|
+
return length.value * parent;
|
|
127
|
+
case 'dip':
|
|
128
|
+
return Utils.layout.toDevicePixels(length.value);
|
|
129
|
+
case 'px':
|
|
130
|
+
return Utils.layout.toDevicePixels(length.value);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export function _parseLengthPercentage(dim) {
|
|
134
|
+
const type = dim.type;
|
|
135
|
+
const value = dim.value;
|
|
136
|
+
switch (type) {
|
|
137
|
+
case 0 /* MasonLengthPercentageCompatType.Points */:
|
|
138
|
+
return { value: value, unit: 'px' };
|
|
139
|
+
case 1 /* MasonLengthPercentageCompatType.Percent */:
|
|
140
|
+
return { value: value, unit: '%' };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
export function _parseLengthPercentageAuto(dim) {
|
|
144
|
+
const type = dim.type;
|
|
145
|
+
const value = dim.value;
|
|
146
|
+
switch (type) {
|
|
147
|
+
case 0 /* MasonLengthPercentageAutoCompatType.Auto */:
|
|
148
|
+
return 'auto';
|
|
149
|
+
case 1 /* MasonLengthPercentageAutoCompatType.Points */:
|
|
150
|
+
return { value: value, unit: 'px' };
|
|
151
|
+
case 2 /* MasonLengthPercentageAutoCompatType.Percent */:
|
|
152
|
+
return { value: value, unit: '%' };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
export function _toMasonDimension(value) {
|
|
156
|
+
if (value === undefined || value === null) {
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
if (value === 'auto') {
|
|
160
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonDimensionCompatType.Auto */ };
|
|
161
|
+
}
|
|
162
|
+
if (typeof value === 'string') {
|
|
163
|
+
const parsed = _parseDimensionString(value);
|
|
164
|
+
if (parsed) {
|
|
165
|
+
return parsed;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
let typeOf = typeof value;
|
|
169
|
+
if (typeOf === 'number') {
|
|
170
|
+
return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
171
|
+
}
|
|
172
|
+
if (typeOf === 'string') {
|
|
173
|
+
value = parseUnit(value).value;
|
|
174
|
+
typeOf = 'object';
|
|
175
|
+
}
|
|
176
|
+
if (typeOf === 'object') {
|
|
177
|
+
switch (value?.unit) {
|
|
178
|
+
case '%':
|
|
179
|
+
return { value: value.value, type: 'percent', native_type: 2 /* MasonDimensionCompatType.Percent */ };
|
|
180
|
+
case 'px':
|
|
181
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
182
|
+
case 'dip':
|
|
183
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return { value: value, type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
187
|
+
}
|
|
188
|
+
function _parseDimensionString(value) {
|
|
189
|
+
const t = value.trim();
|
|
190
|
+
switch (t) {
|
|
191
|
+
case 'auto':
|
|
192
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonDimensionCompatType.Auto */ };
|
|
193
|
+
case 'min-content':
|
|
194
|
+
return { value: 0, type: 'min-content', native_type: 3 /* MasonDimensionCompatType.MinContent */ };
|
|
195
|
+
case 'max-content':
|
|
196
|
+
return { value: 0, type: 'max-content', native_type: 4 /* MasonDimensionCompatType.MaxContent */ };
|
|
197
|
+
case 'fit-content':
|
|
198
|
+
return { value: 0, type: 'fit-content', native_type: 5 /* MasonDimensionCompatType.FitContent */ };
|
|
199
|
+
case 'stretch':
|
|
200
|
+
return { value: 0, type: 'stretch', native_type: 8 /* MasonDimensionCompatType.Stretch */ };
|
|
201
|
+
case 'content':
|
|
202
|
+
return { value: 0, type: 'content', native_type: 9 /* MasonDimensionCompatType.Content */ };
|
|
203
|
+
}
|
|
204
|
+
if (t.startsWith('fit-content(') && t.endsWith(')')) {
|
|
205
|
+
const limit = t.slice('fit-content('.length, -1).trim();
|
|
206
|
+
if (limit.endsWith('%')) {
|
|
207
|
+
return { value: parseFloat(limit) || 0, type: 'fit-content-percent', native_type: 7 /* MasonDimensionCompatType.FitContentPercent */ };
|
|
208
|
+
}
|
|
209
|
+
const n = parseFloat(limit) || 0;
|
|
210
|
+
return { value: limit.endsWith('px') ? n : Utils.layout.toDevicePixels(n), type: 'fit-content-points', native_type: 6 /* MasonDimensionCompatType.FitContentPoints */ };
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
export function _intoMasonDimension(value) {
|
|
215
|
+
if (value === undefined || value === null) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
if (typeof value === 'string') {
|
|
219
|
+
const parsed = _parseDimensionString(value);
|
|
220
|
+
if (parsed) {
|
|
221
|
+
const DimensionCompat = MasonDimensionCompat;
|
|
222
|
+
switch (parsed.native_type) {
|
|
223
|
+
case 0 /* MasonDimensionCompatType.Auto */:
|
|
224
|
+
return DimensionCompat.Auto;
|
|
225
|
+
case 3 /* MasonDimensionCompatType.MinContent */:
|
|
226
|
+
return DimensionCompat.MinContent;
|
|
227
|
+
case 4 /* MasonDimensionCompatType.MaxContent */:
|
|
228
|
+
return DimensionCompat.MaxContent;
|
|
229
|
+
case 5 /* MasonDimensionCompatType.FitContent */:
|
|
230
|
+
return DimensionCompat.FitContent;
|
|
231
|
+
case 6 /* MasonDimensionCompatType.FitContentPoints */:
|
|
232
|
+
return DimensionCompat.alloc().initWithFitContentPoints(parsed.value);
|
|
233
|
+
case 7 /* MasonDimensionCompatType.FitContentPercent */:
|
|
234
|
+
return DimensionCompat.alloc().initWithFitContentPercent(parsed.value);
|
|
235
|
+
case 8 /* MasonDimensionCompatType.Stretch */:
|
|
236
|
+
return DimensionCompat.Stretch;
|
|
237
|
+
case 9 /* MasonDimensionCompatType.Content */:
|
|
238
|
+
return DimensionCompat.Content;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const typeOf = typeof value;
|
|
243
|
+
if (typeOf === 'object') {
|
|
244
|
+
switch (value?.unit) {
|
|
245
|
+
case '%':
|
|
246
|
+
return MasonDimensionCompat.alloc().initWithPercent(value.value);
|
|
247
|
+
case 'px':
|
|
248
|
+
return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value.value));
|
|
249
|
+
case 'dip':
|
|
250
|
+
return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value.value));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (typeOf === 'number') {
|
|
254
|
+
return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value));
|
|
255
|
+
}
|
|
256
|
+
return MasonDimensionCompat.alloc().initWithPoints(Utils.layout.toDevicePixels(value));
|
|
257
|
+
}
|
|
258
|
+
export function _toLengthPercentageAuto(value) {
|
|
259
|
+
if (value === undefined || value === null) {
|
|
260
|
+
return value;
|
|
261
|
+
}
|
|
262
|
+
if (value === 'auto') {
|
|
263
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonLengthPercentageAutoCompatType.Auto */ };
|
|
264
|
+
}
|
|
265
|
+
const typeOf = typeof value;
|
|
266
|
+
if (typeOf === 'object') {
|
|
267
|
+
switch (value?.unit) {
|
|
268
|
+
case '%':
|
|
269
|
+
return { value: value.value, type: 'percent', native_type: 2 /* MasonLengthPercentageAutoCompatType.Percent */ };
|
|
270
|
+
case 'px':
|
|
271
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
272
|
+
case 'dip':
|
|
273
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (typeOf === 'number') {
|
|
277
|
+
return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
278
|
+
}
|
|
279
|
+
return { value: value, type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
280
|
+
}
|
|
281
|
+
export function _toLengthPercentage(value) {
|
|
282
|
+
if (value === undefined || value === null) {
|
|
283
|
+
return value;
|
|
284
|
+
}
|
|
285
|
+
if (typeof value === 'string') {
|
|
286
|
+
const parsed = Length.parse(value);
|
|
287
|
+
if (parsed) {
|
|
288
|
+
value = parsed;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
const typeOf = typeof value;
|
|
292
|
+
if (typeOf === 'object') {
|
|
293
|
+
switch (value?.unit) {
|
|
294
|
+
case '%':
|
|
295
|
+
return { value: value.value, type: 'percent', native_type: 1 /* MasonLengthPercentageCompatType.Percent */ };
|
|
296
|
+
case 'px':
|
|
297
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
298
|
+
case 'dip':
|
|
299
|
+
return { value: Utils.layout.toDevicePixels(value.value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (typeOf === 'number') {
|
|
303
|
+
return { value: Utils.layout.toDevicePixels(value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
304
|
+
}
|
|
305
|
+
return { value: value, type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
306
|
+
}
|
|
307
|
+
function syncStyle(instance) {
|
|
308
|
+
// noop
|
|
309
|
+
}
|
|
310
|
+
export function _getAspectRatio(instance) {
|
|
311
|
+
if (!instance._hasNativeView) {
|
|
312
|
+
return instance.style.aspectRatio;
|
|
313
|
+
}
|
|
314
|
+
const ratio = instance._styleHelper.aspectRatio;
|
|
315
|
+
return Number.isNaN(ratio) ? null : ratio;
|
|
316
|
+
}
|
|
317
|
+
export function _parseGridLine(value) {
|
|
318
|
+
let parsedValue = undefined;
|
|
319
|
+
let parsedType = undefined;
|
|
320
|
+
if (value === 'auto' || value === undefined) {
|
|
321
|
+
parsedValue = 0;
|
|
322
|
+
parsedType = 0 /* GridPlacementCompatType.Auto */;
|
|
323
|
+
}
|
|
324
|
+
if (typeof value === 'string') {
|
|
325
|
+
if (value.startsWith('span')) {
|
|
326
|
+
parsedValue = Number(value.replace('span', '').trim());
|
|
327
|
+
parsedType = 2 /* GridPlacementCompatType.Span */;
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
parsedValue = Number(value.trim());
|
|
331
|
+
if (parsedValue < 1) {
|
|
332
|
+
parsedValue = 0;
|
|
333
|
+
parsedType = 0 /* GridPlacementCompatType.Auto */;
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
parsedType = 1 /* GridPlacementCompatType.Line */;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (typeof value === 'number') {
|
|
341
|
+
parsedValue = value;
|
|
342
|
+
if (parsedValue < 1) {
|
|
343
|
+
parsedValue = 0;
|
|
344
|
+
parsedType = 0 /* GridPlacementCompatType.Auto */;
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
parsedType = 1 /* GridPlacementCompatType.Line */;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return { value: Number.isNaN(parsedValue) ? undefined : parsedValue, type: parsedType };
|
|
351
|
+
}
|
|
352
|
+
export function _setGridColumnStart(value, instance, initial = false) {
|
|
353
|
+
if (!instance._hasNativeView) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const val = _parseGridLine(value);
|
|
357
|
+
if (val.value === undefined || val.type === undefined) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
// switch (val.type) {
|
|
361
|
+
// case 0 /* GridPlacementCompatType.Auto */:
|
|
362
|
+
// instance.ios.gridColumnStartCompat = GridPlacementCompat.Auto;
|
|
363
|
+
// break;
|
|
364
|
+
// case 1 /* GridPlacementCompatType.Line */:
|
|
365
|
+
// instance.ios.gridColumnStartCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
366
|
+
// break;
|
|
367
|
+
// case 2 /* GridPlacementCompatType.Span */:
|
|
368
|
+
// instance.ios.gridColumnStartCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
369
|
+
// break;
|
|
370
|
+
// }
|
|
371
|
+
}
|
|
372
|
+
export function _setGridColumnEnd(value, instance, initial = false) {
|
|
373
|
+
if (!instance._hasNativeView) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
const val = _parseGridLine(value);
|
|
377
|
+
if (val.value === undefined || val.type === undefined) {
|
|
378
|
+
return;
|
|
379
|
+
}
|
|
380
|
+
// switch (val.type) {
|
|
381
|
+
// case 0 /* GridPlacementCompatType.Auto */:
|
|
382
|
+
// instance.ios.gridColumnEndCompat = GridPlacementCompat.Auto;
|
|
383
|
+
// break;
|
|
384
|
+
// case 1 /* GridPlacementCompatType.Line */:
|
|
385
|
+
// instance.ios.gridColumnEndCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
386
|
+
// break;
|
|
387
|
+
// case 2 /* GridPlacementCompatType.Span */:
|
|
388
|
+
// instance.ios.gridColumnEndCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
389
|
+
// break;
|
|
390
|
+
// }
|
|
391
|
+
}
|
|
392
|
+
export function _setGridRowStart(value, instance, initial = false) {
|
|
393
|
+
if (!instance._hasNativeView) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const val = _parseGridLine(value);
|
|
397
|
+
if (val.value === undefined || val.type === undefined) {
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
// switch (val.type) {
|
|
401
|
+
// case 0 /* GridPlacementCompatType.Auto */:
|
|
402
|
+
// instance.ios.gridRowStartCompat = GridPlacementCompat.Auto;
|
|
403
|
+
// break;
|
|
404
|
+
// case 1 /* GridPlacementCompatType.Line */:
|
|
405
|
+
// instance.ios.gridRowStartCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
406
|
+
// break;
|
|
407
|
+
// case 2 /* GridPlacementCompatType.Span */:
|
|
408
|
+
// instance.ios.gridRowStartCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
409
|
+
// break;
|
|
410
|
+
// }
|
|
411
|
+
}
|
|
412
|
+
export function _setGridRowEnd(value, instance, initial = false) {
|
|
413
|
+
if (!instance._hasNativeView) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const val = _parseGridLine(value);
|
|
417
|
+
if (val.value === undefined || val.type === undefined) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
// switch (val.type) {
|
|
421
|
+
// case 0 /* GridPlacementCompatType.Auto */:
|
|
422
|
+
// instance.ios.gridRowEndCompat = GridPlacementCompat.Auto;
|
|
423
|
+
// break;
|
|
424
|
+
// case 1 /* GridPlacementCompatType.Line */:
|
|
425
|
+
// instance.ios.gridRowEndCompat = GridPlacementCompat.alloc().initWithLine(val.value);
|
|
426
|
+
// break;
|
|
427
|
+
// case 2 /* GridPlacementCompatType.Span */:
|
|
428
|
+
// instance.ios.gridRowEndCompat = GridPlacementCompat.alloc().initWithSpan(val.value);
|
|
429
|
+
// break;
|
|
430
|
+
// }
|
|
431
|
+
}
|
|
432
|
+
export function _setRowGap(value, instance, initial = false) {
|
|
433
|
+
if (!instance._hasNativeView) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
instance._styleHelper.rowGap = value;
|
|
437
|
+
}
|
|
438
|
+
export function _getRowGap(instance) {
|
|
439
|
+
if (!instance._hasNativeView) {
|
|
440
|
+
return instance.style.rowGap;
|
|
441
|
+
}
|
|
442
|
+
return instance._styleHelper.rowGap;
|
|
443
|
+
}
|
|
444
|
+
export function _setColumnGap(value, instance, initial = false) {
|
|
445
|
+
if (!instance._hasNativeView) {
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
instance._styleHelper.columnGap = value;
|
|
449
|
+
}
|
|
450
|
+
export function _getColumnGap(instance) {
|
|
451
|
+
if (!instance._hasNativeView) {
|
|
452
|
+
return instance.style.gap;
|
|
453
|
+
}
|
|
454
|
+
return instance._styleHelper.columnGap;
|
|
455
|
+
}
|
|
456
|
+
const Auto = 'auto';
|
|
457
|
+
const None = 'none';
|
|
458
|
+
const MinContent = 'min-content';
|
|
459
|
+
const MaxContent = 'max-content';
|
|
460
|
+
export function _parseMinMaxValue(value) {
|
|
461
|
+
if (typeof value === 'string') {
|
|
462
|
+
if (value === Auto || value === None) {
|
|
463
|
+
return {
|
|
464
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
465
|
+
min_value: 0,
|
|
466
|
+
max_type: 0 /* MaxSizingType.Auto */,
|
|
467
|
+
max_value: 0,
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
else if (value === MinContent) {
|
|
471
|
+
return {
|
|
472
|
+
min_type: 1 /* MinSizingType.MinContent */,
|
|
473
|
+
min_value: 0,
|
|
474
|
+
max_type: 1 /* MaxSizingType.MinContent */,
|
|
475
|
+
max_value: 0,
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
else if (value === MaxContent) {
|
|
479
|
+
return {
|
|
480
|
+
min_type: 2 /* MinSizingType.MaxContent */,
|
|
481
|
+
min_value: 0,
|
|
482
|
+
max_type: 2 /* MaxSizingType.MaxContent */,
|
|
483
|
+
max_value: 0,
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
else if (value.indexOf('fr') > -1) {
|
|
487
|
+
const flex = parseInt(value.replace('fr', '').trim());
|
|
488
|
+
return {
|
|
489
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
490
|
+
min_value: 0,
|
|
491
|
+
max_type: 5 /* MaxSizingType.Fraction */,
|
|
492
|
+
max_value: flex,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
else if (value.startsWith('minmax')) {
|
|
496
|
+
// todo
|
|
497
|
+
const minMax = parseInt(value.replace('minmax(', '').replace(')', '').trim());
|
|
498
|
+
}
|
|
499
|
+
else if (value.startsWith('fit-content')) {
|
|
500
|
+
const fitContent = value.replace('fit-content(', '').replace(')', '').trim();
|
|
501
|
+
if (fitContent.indexOf('px') > -1) {
|
|
502
|
+
const px = parseInt(fitContent.replace('px', ''));
|
|
503
|
+
return {
|
|
504
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
505
|
+
min_value: px,
|
|
506
|
+
max_type: 6 /* MaxSizingType.FitContent */,
|
|
507
|
+
max_value: px,
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
if (fitContent.indexOf('px') > -1) {
|
|
511
|
+
const dip = Utils.layout.toDevicePixels(parseInt(fitContent.replace('dip', '')));
|
|
512
|
+
return {
|
|
513
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
514
|
+
min_value: dip,
|
|
515
|
+
max_type: 6 /* MaxSizingType.FitContent */,
|
|
516
|
+
max_value: dip,
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
if (fitContent.indexOf('%') > -1) {
|
|
520
|
+
const percent = parseFloat(fitContent.replace('%', ''));
|
|
521
|
+
return {
|
|
522
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
523
|
+
min_value: percent,
|
|
524
|
+
max_type: 7 /* MaxSizingType.FitContentPercent */,
|
|
525
|
+
max_value: percent,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
else if (value.indexOf('px') > -1) {
|
|
530
|
+
const px = parseInt(value.replace('px', ''));
|
|
531
|
+
return {
|
|
532
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
533
|
+
min_value: px,
|
|
534
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
535
|
+
max_value: px,
|
|
536
|
+
};
|
|
537
|
+
}
|
|
538
|
+
else if (value.indexOf('dip') > -1) {
|
|
539
|
+
const dip = Utils.layout.toDevicePixels(parseInt(value.replace('dip', '')));
|
|
540
|
+
return {
|
|
541
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
542
|
+
min_value: dip,
|
|
543
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
544
|
+
max_value: dip,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
else if (value.indexOf('%') > -1) {
|
|
548
|
+
const percent = parseFloat(value.replace('%', ''));
|
|
549
|
+
return {
|
|
550
|
+
min_type: 4 /* MinSizingType.Percent */,
|
|
551
|
+
min_value: percent,
|
|
552
|
+
max_type: 4 /* MaxSizingType.Percent */,
|
|
553
|
+
max_value: percent,
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
const dip = Utils.layout.toDevicePixels(Number(value));
|
|
558
|
+
return {
|
|
559
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
560
|
+
min_value: dip,
|
|
561
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
562
|
+
max_value: dip,
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
if (typeof value === 'number') {
|
|
567
|
+
const dip = Utils.layout.toDevicePixels(value);
|
|
568
|
+
return {
|
|
569
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
570
|
+
min_value: dip,
|
|
571
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
572
|
+
max_value: dip,
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
return undefined;
|
|
576
|
+
}
|
|
577
|
+
const grid_templates_regex = /[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g;
|
|
578
|
+
export function _parseGridTemplates(value) {
|
|
579
|
+
const array = [];
|
|
580
|
+
if (typeof value === 'string') {
|
|
581
|
+
const values = Array.from(value.matchAll(grid_templates_regex), (m) => m[0]);
|
|
582
|
+
values.forEach((item) => {
|
|
583
|
+
if (item.startsWith('repeat(')) {
|
|
584
|
+
const repeatValue = item.replace('repeat(', '').replace(')', '');
|
|
585
|
+
const trackEnd = repeatValue.indexOf(',');
|
|
586
|
+
const repetition = repeatValue.substring(0, trackEnd);
|
|
587
|
+
const tracks = repeatValue
|
|
588
|
+
.substring(trackEnd + 1)
|
|
589
|
+
.split(' ')
|
|
590
|
+
.filter((a) => {
|
|
591
|
+
return a.length || a.trim() === ',';
|
|
592
|
+
});
|
|
593
|
+
let isValid = true;
|
|
594
|
+
let repeating_type = 0;
|
|
595
|
+
let repeat_count = 0;
|
|
596
|
+
switch (repetition) {
|
|
597
|
+
case 'repeat-fill':
|
|
598
|
+
repeating_type = 0 /* TSCGridTrackRepetition.AutoFill */;
|
|
599
|
+
break;
|
|
600
|
+
case 'repeat-fit':
|
|
601
|
+
repeating_type = 1 /* TSCGridTrackRepetition.AutoFit */;
|
|
602
|
+
break;
|
|
603
|
+
default:
|
|
604
|
+
{
|
|
605
|
+
const number = parseInt(repetition);
|
|
606
|
+
repeating_type = 2 /* TSCGridTrackRepetition.Count */;
|
|
607
|
+
isValid = !Number.isNaN(number);
|
|
608
|
+
if (isValid) {
|
|
609
|
+
repeat_count = number;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
break;
|
|
613
|
+
}
|
|
614
|
+
if (isValid) {
|
|
615
|
+
const tracks_array = [];
|
|
616
|
+
tracks.forEach((track) => {
|
|
617
|
+
const minMax = _parseMinMaxValue(track.trim());
|
|
618
|
+
tracks_array.push(minMax);
|
|
619
|
+
});
|
|
620
|
+
array.push({
|
|
621
|
+
is_repeating: true,
|
|
622
|
+
repeating_type,
|
|
623
|
+
repeating_count: repeat_count,
|
|
624
|
+
value: tracks_array,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
else {
|
|
629
|
+
const value = _parseMinMaxValue(item);
|
|
630
|
+
array.push({
|
|
631
|
+
is_repeating: false,
|
|
632
|
+
repeating_type: 0,
|
|
633
|
+
value,
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
return array;
|
|
639
|
+
}
|
|
640
|
+
export function _setGridTemplateRows(value, instance, initial = false) {
|
|
641
|
+
if (!instance[isMasonView_]) {
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
const length = value.length;
|
|
645
|
+
const array = NSMutableArray.arrayWithCapacity(length);
|
|
646
|
+
for (let i = 0; i < length; i++) {
|
|
647
|
+
const item = value[i];
|
|
648
|
+
if (item.is_repeating) {
|
|
649
|
+
const repeating = item.value;
|
|
650
|
+
const repeatingLength = repeating.length;
|
|
651
|
+
const tracks = NSMutableArray.arrayWithCapacity(repeatingLength);
|
|
652
|
+
let gridTrackRepetition = null;
|
|
653
|
+
switch (item.repeating_type) {
|
|
654
|
+
case 0 /* TSCGridTrackRepetition.AutoFill */:
|
|
655
|
+
gridTrackRepetition = MasonGridTrackRepetition.AutoFill;
|
|
656
|
+
break;
|
|
657
|
+
case 1 /* TSCGridTrackRepetition.AutoFit */:
|
|
658
|
+
gridTrackRepetition = MasonGridTrackRepetition.AutoFit;
|
|
659
|
+
break;
|
|
660
|
+
case 2 /* TSCGridTrackRepetition.Count */:
|
|
661
|
+
gridTrackRepetition = MasonGridTrackRepetition.Count(item.repeating_count);
|
|
662
|
+
break;
|
|
663
|
+
}
|
|
664
|
+
if (gridTrackRepetition === null) {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
for (let j = 0; j < repeatingLength; j++) {
|
|
668
|
+
const repeat = repeating[j];
|
|
669
|
+
tracks.addObject(MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value));
|
|
670
|
+
}
|
|
671
|
+
const repeat = TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
|
|
672
|
+
array.addObject(repeat);
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
const single = item.value;
|
|
676
|
+
const trackSizingFunction = TrackSizingFunction.Single(MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value));
|
|
677
|
+
array.addObject(trackSizingFunction);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
// instance.ios.gridTemplateRows = array;
|
|
681
|
+
}
|
|
682
|
+
export function _setGridTemplateColumns(value, instance, initial = false) {
|
|
683
|
+
if (!instance[isMasonView_]) {
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
const length = value.length;
|
|
687
|
+
const array = NSMutableArray.new();
|
|
688
|
+
for (let i = 0; i < length; i++) {
|
|
689
|
+
const item = value[i];
|
|
690
|
+
if (item.is_repeating) {
|
|
691
|
+
const repeating = item.value;
|
|
692
|
+
const repeatingLength = repeating.length;
|
|
693
|
+
const tracks = NSMutableArray.arrayWithCapacity(repeatingLength);
|
|
694
|
+
let gridTrackRepetition = null;
|
|
695
|
+
switch (item.repeating_type) {
|
|
696
|
+
case 0 /* TSCGridTrackRepetition.AutoFill */:
|
|
697
|
+
gridTrackRepetition = 0 /* TSCGridTrackRepetition.AutoFill */;
|
|
698
|
+
break;
|
|
699
|
+
case 1 /* TSCGridTrackRepetition.AutoFit */:
|
|
700
|
+
gridTrackRepetition = 1 /* TSCGridTrackRepetition.AutoFit */;
|
|
701
|
+
break;
|
|
702
|
+
case 2 /* TSCGridTrackRepetition.Count */:
|
|
703
|
+
gridTrackRepetition = MasonGridTrackRepetition.Count(item.repeating_count);
|
|
704
|
+
break;
|
|
705
|
+
}
|
|
706
|
+
if (gridTrackRepetition === null) {
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
for (let j = 0; j < repeatingLength; j++) {
|
|
710
|
+
const repeat = repeating[j];
|
|
711
|
+
tracks.addObject(MinMax.fromTypeValue(repeat.min_type, repeat.min_value, repeat.max_type, repeat.max_value));
|
|
712
|
+
}
|
|
713
|
+
const repeat = TrackSizingFunction.AutoRepeat(gridTrackRepetition, tracks);
|
|
714
|
+
array.addObject(repeat);
|
|
715
|
+
}
|
|
716
|
+
else {
|
|
717
|
+
const single = item.value;
|
|
718
|
+
const trackSizingFunction = TrackSizingFunction.Single(MinMax.fromTypeValue(single.min_type, single.min_value, single.max_type, single.max_value));
|
|
719
|
+
array.addObject(trackSizingFunction);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
// instance.ios.gridTemplateColumns = array;
|
|
723
|
+
}
|
|
724
|
+
export function _parseGridAutoRowsColumns(value) {
|
|
725
|
+
const array = [];
|
|
726
|
+
if (typeof value === 'string') {
|
|
727
|
+
const values = value.split(' ');
|
|
728
|
+
values.forEach((item) => {
|
|
729
|
+
const value = _parseMinMaxValue(item);
|
|
730
|
+
array.push({
|
|
731
|
+
is_repeating: false,
|
|
732
|
+
repeating_type: 0,
|
|
733
|
+
value,
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
return array;
|
|
738
|
+
}
|
|
739
|
+
export function _setGridAutoFlow(value, instance) {
|
|
740
|
+
if (!instance[isMasonView_]) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
instance.ios.gridAutoFlow = value;
|
|
744
|
+
}
|
|
745
|
+
export function _getGridAutoFlow(instance) {
|
|
746
|
+
if (!instance[isMasonView_]) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
return this._styleHelper.gridAutoFlow;
|
|
750
|
+
}
|
|
751
|
+
export function _setGridAutoRows(value, instance, initial = false) {
|
|
752
|
+
if (!instance[isMasonView_]) {
|
|
753
|
+
return;
|
|
754
|
+
}
|
|
755
|
+
const values = _parseGridAutoRowsColumns(value);
|
|
756
|
+
const length = value.length;
|
|
757
|
+
const array = NSMutableArray.arrayWithCapacity(length);
|
|
758
|
+
for (let i = 0; i < length; i++) {
|
|
759
|
+
const item = value[i];
|
|
760
|
+
const minMax = MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
|
|
761
|
+
array.addObject(minMax);
|
|
762
|
+
}
|
|
763
|
+
// instance.ios.gridAutoRows = array;
|
|
764
|
+
}
|
|
765
|
+
export function _setGridAutoColumns(value, instance, initial = false) {
|
|
766
|
+
if (!instance[isMasonView_]) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
const values = _parseGridAutoRowsColumns(value);
|
|
770
|
+
const length = value.length;
|
|
771
|
+
const array = NSMutableArray.arrayWithCapacity(length);
|
|
772
|
+
for (let i = 0; i < length; i++) {
|
|
773
|
+
const item = values[i];
|
|
774
|
+
const minMax = MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
|
|
775
|
+
array.addObject(minMax);
|
|
776
|
+
}
|
|
777
|
+
// instance.ios.gridAutoColumns = array;
|
|
778
|
+
}
|
|
779
|
+
export function _getGridTemplateRows(instance) {
|
|
780
|
+
if (!instance[isMasonView_]) {
|
|
781
|
+
return '';
|
|
782
|
+
}
|
|
783
|
+
return ''; //instance.ios.style.gridTemplateRowsCSS;
|
|
784
|
+
}
|
|
785
|
+
export function _getGridTemplateColumns(instance) {
|
|
786
|
+
if (!instance[isMasonView_]) {
|
|
787
|
+
return '';
|
|
788
|
+
}
|
|
789
|
+
return ''; //instance.ios.style.gridTemplateColumnsCSS;
|
|
790
|
+
}
|