@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
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
// declare const __non_webpack_require__;
|
|
2
|
+
import { Length } from '@nativescript/core';
|
|
3
|
+
import { parseUnit } from '@nativescript/core/css/parser';
|
|
4
|
+
import { Tree } from '../tree';
|
|
5
|
+
import { isMasonView_, style_ } from '../symbols';
|
|
6
|
+
import { masonLayout } from '../display-density';
|
|
7
|
+
export function parseLength(length, parent = 0) {
|
|
8
|
+
switch (length.unit) {
|
|
9
|
+
case '%':
|
|
10
|
+
return length.value * parent;
|
|
11
|
+
case 'dip':
|
|
12
|
+
return masonLayout.toDevicePixels(length.value);
|
|
13
|
+
case 'px':
|
|
14
|
+
return masonLayout.toDevicePixels(length.value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
let sharedMason = null;
|
|
18
|
+
function getMasonInstance(instance) {
|
|
19
|
+
const nativeView = instance?.android;
|
|
20
|
+
if (instance[isMasonView_]) {
|
|
21
|
+
return nativeView.getNode();
|
|
22
|
+
}
|
|
23
|
+
if (!sharedMason) {
|
|
24
|
+
sharedMason = org.nativescript.mason.masonkit.Mason.getShared();
|
|
25
|
+
}
|
|
26
|
+
return sharedMason.nodeForView(nativeView);
|
|
27
|
+
}
|
|
28
|
+
function getStyleInstance(instance) {
|
|
29
|
+
const nativeView = instance?.android;
|
|
30
|
+
if (instance[isMasonView_]) {
|
|
31
|
+
return nativeView.getStyle();
|
|
32
|
+
}
|
|
33
|
+
if (!sharedMason) {
|
|
34
|
+
sharedMason = org.nativescript.mason.masonkit.Mason.getShared();
|
|
35
|
+
}
|
|
36
|
+
return sharedMason.nodeForView(nativeView).getStyle();
|
|
37
|
+
}
|
|
38
|
+
export function _forceStyleUpdate(instance) {
|
|
39
|
+
if (!instance[isMasonView_]) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (instance[isMasonView_]) {
|
|
43
|
+
}
|
|
44
|
+
// const nodeOrView = getMasonInstance(instance) as org.nativescript.mason.masonkit.TextView;
|
|
45
|
+
// nodeOrView.getStyle().updateNodeAndStyle();
|
|
46
|
+
}
|
|
47
|
+
export function _markDirty(instance) {
|
|
48
|
+
if (!instance[isMasonView_]) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const nodeOrView = getMasonInstance(instance);
|
|
52
|
+
nodeOrView.dirty();
|
|
53
|
+
}
|
|
54
|
+
export function _isDirty(instance) {
|
|
55
|
+
if (!instance[isMasonView_]) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const nodeOrView = getMasonInstance(instance);
|
|
59
|
+
return nodeOrView.isDirty();
|
|
60
|
+
}
|
|
61
|
+
export function _intoType(type) {
|
|
62
|
+
switch (type) {
|
|
63
|
+
case 'auto':
|
|
64
|
+
return 0 /* MasonDimensionCompatType.Auto */;
|
|
65
|
+
case 'points':
|
|
66
|
+
return 1 /* MasonDimensionCompatType.Points */;
|
|
67
|
+
case 'percent':
|
|
68
|
+
return 2 /* MasonDimensionCompatType.Percent */;
|
|
69
|
+
case 'min-content':
|
|
70
|
+
return 3 /* MasonDimensionCompatType.MinContent */;
|
|
71
|
+
case 'max-content':
|
|
72
|
+
return 4 /* MasonDimensionCompatType.MaxContent */;
|
|
73
|
+
case 'fit-content':
|
|
74
|
+
return 5 /* MasonDimensionCompatType.FitContent */;
|
|
75
|
+
case 'fit-content-points':
|
|
76
|
+
return 6 /* MasonDimensionCompatType.FitContentPoints */;
|
|
77
|
+
case 'fit-content-percent':
|
|
78
|
+
return 7 /* MasonDimensionCompatType.FitContentPercent */;
|
|
79
|
+
case 'stretch':
|
|
80
|
+
return 8 /* MasonDimensionCompatType.Stretch */;
|
|
81
|
+
case 'content':
|
|
82
|
+
return 9 /* MasonDimensionCompatType.Content */;
|
|
83
|
+
default:
|
|
84
|
+
return 0 /* MasonDimensionCompatType.Auto */;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
export function _parseDimension(dim) {
|
|
88
|
+
const name = dim.getClass().getName();
|
|
89
|
+
switch (name) {
|
|
90
|
+
case 'org.nativescript.mason.masonkit.Dimension$Points':
|
|
91
|
+
return { value: dim.getPoints(), unit: 'px' };
|
|
92
|
+
case 'org.nativescript.mason.masonkit.Dimension$Percent':
|
|
93
|
+
return { value: dim.getPercentage(), unit: '%' };
|
|
94
|
+
case 'org.nativescript.mason.masonkit.Dimension$Auto':
|
|
95
|
+
return 'auto';
|
|
96
|
+
case 'org.nativescript.mason.masonkit.Dimension$MinContent':
|
|
97
|
+
return 'min-content';
|
|
98
|
+
case 'org.nativescript.mason.masonkit.Dimension$MaxContent':
|
|
99
|
+
return 'max-content';
|
|
100
|
+
case 'org.nativescript.mason.masonkit.Dimension$FitContent':
|
|
101
|
+
return 'fit-content';
|
|
102
|
+
case 'org.nativescript.mason.masonkit.Dimension$FitContentPoints':
|
|
103
|
+
return `fit-content(${dim.getPoints()}px)`;
|
|
104
|
+
case 'org.nativescript.mason.masonkit.Dimension$FitContentPercent':
|
|
105
|
+
return `fit-content(${dim.getPercentage()}%)`;
|
|
106
|
+
case 'org.nativescript.mason.masonkit.Dimension$Stretch':
|
|
107
|
+
return 'stretch';
|
|
108
|
+
case 'org.nativescript.mason.masonkit.Dimension$Content':
|
|
109
|
+
return 'content';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
export function _parseLengthPercentage(dim) {
|
|
113
|
+
const name = dim.getClass().getName();
|
|
114
|
+
switch (name) {
|
|
115
|
+
case 'org.nativescript.mason.masonkit.LengthPercentage$Points':
|
|
116
|
+
return { value: dim.getPoints(), unit: 'px' };
|
|
117
|
+
case 'org.nativescript.mason.masonkit.LengthPercentage$Percent':
|
|
118
|
+
return { value: dim.getPercentage(), unit: '%' };
|
|
119
|
+
case 'org.nativescript.mason.masonkit.LengthPercentage$Auto':
|
|
120
|
+
return 'auto';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
export function _parseLengthPercentageAuto(dim) {
|
|
124
|
+
const name = dim.getClass().getName();
|
|
125
|
+
switch (name) {
|
|
126
|
+
case 'org.nativescript.mason.masonkit.LengthPercentageAuto$Points':
|
|
127
|
+
return { value: dim.getPoints(), unit: 'px' };
|
|
128
|
+
case 'org.nativescript.mason.masonkit.LengthPercentageAuto$Percent':
|
|
129
|
+
return { value: dim.getPercentage(), unit: '%' };
|
|
130
|
+
case 'org.nativescript.mason.masonkit.LengthPercentageAuto$Auto':
|
|
131
|
+
return 'auto';
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export function _toMasonDimension(value) {
|
|
135
|
+
if (value === undefined || value === null) {
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
if (value === 'auto') {
|
|
139
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonDimensionCompatType.Auto */ };
|
|
140
|
+
}
|
|
141
|
+
if (typeof value === 'string') {
|
|
142
|
+
const parsed = _parseDimensionString(value);
|
|
143
|
+
if (parsed) {
|
|
144
|
+
return parsed;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
let typeOf = typeof value;
|
|
148
|
+
if (typeOf === 'number') {
|
|
149
|
+
return { value: masonLayout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
150
|
+
}
|
|
151
|
+
if (typeOf === 'string') {
|
|
152
|
+
value = parseUnit(value).value;
|
|
153
|
+
typeOf = 'object';
|
|
154
|
+
}
|
|
155
|
+
if (typeOf === 'object') {
|
|
156
|
+
switch (value?.unit) {
|
|
157
|
+
case '%':
|
|
158
|
+
return { value: value.value, type: 'percent', native_type: 2 /* MasonDimensionCompatType.Percent */ };
|
|
159
|
+
case 'px':
|
|
160
|
+
return { value: masonLayout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
161
|
+
case 'dip':
|
|
162
|
+
return { value: masonLayout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return { value: value, type: 'points', native_type: 1 /* MasonDimensionCompatType.Points */ };
|
|
166
|
+
}
|
|
167
|
+
function _parseDimensionString(value) {
|
|
168
|
+
const t = value.trim();
|
|
169
|
+
switch (t) {
|
|
170
|
+
case 'auto':
|
|
171
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonDimensionCompatType.Auto */ };
|
|
172
|
+
case 'min-content':
|
|
173
|
+
return { value: 0, type: 'min-content', native_type: 3 /* MasonDimensionCompatType.MinContent */ };
|
|
174
|
+
case 'max-content':
|
|
175
|
+
return { value: 0, type: 'max-content', native_type: 4 /* MasonDimensionCompatType.MaxContent */ };
|
|
176
|
+
case 'fit-content':
|
|
177
|
+
return { value: 0, type: 'fit-content', native_type: 5 /* MasonDimensionCompatType.FitContent */ };
|
|
178
|
+
case 'stretch':
|
|
179
|
+
return { value: 0, type: 'stretch', native_type: 8 /* MasonDimensionCompatType.Stretch */ };
|
|
180
|
+
case 'content':
|
|
181
|
+
return { value: 0, type: 'content', native_type: 9 /* MasonDimensionCompatType.Content */ };
|
|
182
|
+
}
|
|
183
|
+
if (t.startsWith('fit-content(') && t.endsWith(')')) {
|
|
184
|
+
const limit = t.slice('fit-content('.length, -1).trim();
|
|
185
|
+
if (limit.endsWith('%')) {
|
|
186
|
+
return { value: parseFloat(limit) || 0, type: 'fit-content-percent', native_type: 7 /* MasonDimensionCompatType.FitContentPercent */ };
|
|
187
|
+
}
|
|
188
|
+
const n = parseFloat(limit) || 0;
|
|
189
|
+
return { value: limit.endsWith('px') ? n : masonLayout.toDevicePixels(n), type: 'fit-content-points', native_type: 6 /* MasonDimensionCompatType.FitContentPoints */ };
|
|
190
|
+
}
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
export function _intoMasonDimension(value) {
|
|
194
|
+
if (value === undefined || value === null) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
if (typeof value === 'string') {
|
|
198
|
+
const parsed = _parseDimensionString(value);
|
|
199
|
+
if (parsed) {
|
|
200
|
+
const Dimension = org.nativescript.mason.masonkit.Dimension;
|
|
201
|
+
switch (parsed.native_type) {
|
|
202
|
+
case 0 /* MasonDimensionCompatType.Auto */:
|
|
203
|
+
return Dimension.Auto;
|
|
204
|
+
case 3 /* MasonDimensionCompatType.MinContent */:
|
|
205
|
+
return Dimension.MinContent;
|
|
206
|
+
case 4 /* MasonDimensionCompatType.MaxContent */:
|
|
207
|
+
return Dimension.MaxContent;
|
|
208
|
+
case 5 /* MasonDimensionCompatType.FitContent */:
|
|
209
|
+
return Dimension.FitContent;
|
|
210
|
+
case 6 /* MasonDimensionCompatType.FitContentPoints */:
|
|
211
|
+
return new Dimension.FitContentPoints(parsed.value);
|
|
212
|
+
case 7 /* MasonDimensionCompatType.FitContentPercent */:
|
|
213
|
+
return new Dimension.FitContentPercent(parsed.value);
|
|
214
|
+
case 8 /* MasonDimensionCompatType.Stretch */:
|
|
215
|
+
return Dimension.Stretch;
|
|
216
|
+
case 9 /* MasonDimensionCompatType.Content */:
|
|
217
|
+
return Dimension.Content;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const typeOf = typeof value;
|
|
222
|
+
if (typeOf === 'object') {
|
|
223
|
+
switch (value?.unit) {
|
|
224
|
+
case '%':
|
|
225
|
+
return new org.nativescript.mason.masonkit.Dimension.Percent(value.value);
|
|
226
|
+
case 'px':
|
|
227
|
+
return new org.nativescript.mason.masonkit.Dimension.Points(masonLayout.toDevicePixels(value.value));
|
|
228
|
+
case 'dip':
|
|
229
|
+
return new org.nativescript.mason.masonkit.Dimension.Points(masonLayout.toDevicePixels(value.value));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (typeOf === 'number') {
|
|
233
|
+
return new org.nativescript.mason.masonkit.Dimension.Points(masonLayout.toDevicePixels(value));
|
|
234
|
+
}
|
|
235
|
+
return new org.nativescript.mason.masonkit.Dimension.Points(masonLayout.toDevicePixels(value));
|
|
236
|
+
}
|
|
237
|
+
export function _toLengthPercentageAuto(value) {
|
|
238
|
+
if (value === undefined || value === null) {
|
|
239
|
+
return value;
|
|
240
|
+
}
|
|
241
|
+
if (value === 'auto') {
|
|
242
|
+
return { value: 0, type: 'auto', native_type: 0 /* MasonLengthPercentageAutoCompatType.Auto */ };
|
|
243
|
+
}
|
|
244
|
+
const typeOf = typeof value;
|
|
245
|
+
if (typeOf === 'object') {
|
|
246
|
+
switch (value?.unit) {
|
|
247
|
+
case '%':
|
|
248
|
+
return { value: value.value, type: 'percent', native_type: 2 /* MasonLengthPercentageAutoCompatType.Percent */ };
|
|
249
|
+
case 'px':
|
|
250
|
+
return { value: masonLayout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
251
|
+
case 'dip':
|
|
252
|
+
return { value: masonLayout.toDevicePixels(value.value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
if (typeOf === 'number') {
|
|
256
|
+
return { value: masonLayout.toDevicePixels(value), type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
257
|
+
}
|
|
258
|
+
return { value: value, type: 'points', native_type: 1 /* MasonLengthPercentageAutoCompatType.Points */ };
|
|
259
|
+
}
|
|
260
|
+
export function _toLengthPercentage(value) {
|
|
261
|
+
if (value === undefined || value === null) {
|
|
262
|
+
return value;
|
|
263
|
+
}
|
|
264
|
+
if (typeof value === 'string') {
|
|
265
|
+
const parsed = Length.parse(value);
|
|
266
|
+
if (parsed) {
|
|
267
|
+
value = parsed;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const typeOf = typeof value;
|
|
271
|
+
if (typeOf === 'object') {
|
|
272
|
+
switch (value?.unit) {
|
|
273
|
+
case '%':
|
|
274
|
+
return { value: value.value, type: 'percent', native_type: 1 /* MasonLengthPercentageCompatType.Percent */ };
|
|
275
|
+
case 'px':
|
|
276
|
+
return { value: masonLayout.toDevicePixels(value.value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
277
|
+
case 'dip':
|
|
278
|
+
return { value: masonLayout.toDevicePixels(value.value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (typeOf === 'number') {
|
|
282
|
+
return { value: masonLayout.toDevicePixels(value), type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
283
|
+
}
|
|
284
|
+
return { value: value, type: 'points', native_type: 0 /* MasonLengthPercentageCompatType.Points */ };
|
|
285
|
+
}
|
|
286
|
+
function syncStyle(instance) {
|
|
287
|
+
// noop
|
|
288
|
+
}
|
|
289
|
+
export function _parseGridLine(value) {
|
|
290
|
+
let parsedValue = undefined;
|
|
291
|
+
let parsedType = undefined;
|
|
292
|
+
if (value === 'auto' || value === undefined) {
|
|
293
|
+
parsedValue = 0;
|
|
294
|
+
parsedType = 0; /* GridPlacementCompatType.Auto */
|
|
295
|
+
}
|
|
296
|
+
if (typeof value === 'string') {
|
|
297
|
+
if (value.startsWith('span')) {
|
|
298
|
+
parsedValue = Number(value.replace('span', '').trim());
|
|
299
|
+
parsedType = 2; /* GridPlacementCompatType.Span */
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
parsedValue = Number(value.trim());
|
|
303
|
+
if (parsedValue < 1) {
|
|
304
|
+
parsedValue = 0;
|
|
305
|
+
parsedType = 0; /* GridPlacementCompatType.Auto */
|
|
306
|
+
}
|
|
307
|
+
else {
|
|
308
|
+
parsedType = 1; /* GridPlacementCompatType.Line */
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
if (typeof value === 'number') {
|
|
313
|
+
parsedValue = value;
|
|
314
|
+
if (parsedValue < 1) {
|
|
315
|
+
parsedValue = 0;
|
|
316
|
+
parsedType = 0; /* GridPlacementCompatType.Auto */
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
parsedType = 1; /* GridPlacementCompatType.Line */
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return { value: Number.isNaN(parsedValue) ? undefined : parsedValue, type: parsedType };
|
|
323
|
+
}
|
|
324
|
+
const Auto = 'auto';
|
|
325
|
+
const None = 'none';
|
|
326
|
+
const MinContent = 'min-content';
|
|
327
|
+
const MaxContent = 'max-content';
|
|
328
|
+
export function _parseMinMaxValue(value) {
|
|
329
|
+
if (typeof value === 'string') {
|
|
330
|
+
if (value === Auto || value === None) {
|
|
331
|
+
return {
|
|
332
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
333
|
+
min_value: 0,
|
|
334
|
+
max_type: 0 /* MaxSizingType.Auto */,
|
|
335
|
+
max_value: 0,
|
|
336
|
+
};
|
|
337
|
+
}
|
|
338
|
+
else if (value === MinContent) {
|
|
339
|
+
return {
|
|
340
|
+
min_type: 1 /* MinSizingType.MinContent */,
|
|
341
|
+
min_value: 0,
|
|
342
|
+
max_type: 1 /* MaxSizingType.MinContent */,
|
|
343
|
+
max_value: 0,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
else if (value === MaxContent) {
|
|
347
|
+
return {
|
|
348
|
+
min_type: 2 /* MinSizingType.MaxContent */,
|
|
349
|
+
min_value: 0,
|
|
350
|
+
max_type: 2 /* MaxSizingType.MaxContent */,
|
|
351
|
+
max_value: 0,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
else if (value.indexOf('fr') > -1) {
|
|
355
|
+
const flex = parseInt(value.replace('fr', '').trim());
|
|
356
|
+
return {
|
|
357
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
358
|
+
min_value: 0,
|
|
359
|
+
max_type: 5 /* MaxSizingType.Fraction */,
|
|
360
|
+
max_value: flex,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
else if (value.startsWith('minmax')) {
|
|
364
|
+
// todo
|
|
365
|
+
const minMax = parseInt(value.replace('minmax(', '').replace(')', '').trim());
|
|
366
|
+
}
|
|
367
|
+
else if (value.startsWith('fit-content')) {
|
|
368
|
+
const fitContent = value.replace('fit-content(', '').replace(')', '').trim();
|
|
369
|
+
if (fitContent.indexOf('px') > -1) {
|
|
370
|
+
const px = parseInt(fitContent.replace('px', ''));
|
|
371
|
+
return {
|
|
372
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
373
|
+
min_value: px,
|
|
374
|
+
max_type: 6 /* MaxSizingType.FitContent */,
|
|
375
|
+
max_value: px,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
if (fitContent.indexOf('px') > -1) {
|
|
379
|
+
const dip = masonLayout.toDevicePixels(parseInt(fitContent.replace('dip', '')));
|
|
380
|
+
return {
|
|
381
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
382
|
+
min_value: dip,
|
|
383
|
+
max_type: 6 /* MaxSizingType.FitContent */,
|
|
384
|
+
max_value: dip,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
if (fitContent.indexOf('%') > -1) {
|
|
388
|
+
const percent = parseFloat(fitContent.replace('%', ''));
|
|
389
|
+
return {
|
|
390
|
+
min_type: 0 /* MinSizingType.Auto */,
|
|
391
|
+
min_value: percent,
|
|
392
|
+
max_type: 7 /* MaxSizingType.FitContentPercent */,
|
|
393
|
+
max_value: percent,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
else if (value.indexOf('px') > -1) {
|
|
398
|
+
const px = parseInt(value.replace('px', ''));
|
|
399
|
+
return {
|
|
400
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
401
|
+
min_value: px,
|
|
402
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
403
|
+
max_value: px,
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
else if (value.indexOf('dip') > -1) {
|
|
407
|
+
const dip = masonLayout.toDevicePixels(parseInt(value.replace('dip', '')));
|
|
408
|
+
return {
|
|
409
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
410
|
+
min_value: dip,
|
|
411
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
412
|
+
max_value: dip,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
else if (value.indexOf('%') > -1) {
|
|
416
|
+
const percent = parseFloat(value.replace('%', ''));
|
|
417
|
+
return {
|
|
418
|
+
min_type: 4 /* MinSizingType.Percent */,
|
|
419
|
+
min_value: percent,
|
|
420
|
+
max_type: 4 /* MaxSizingType.Percent */,
|
|
421
|
+
max_value: percent,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
else {
|
|
425
|
+
const dip = masonLayout.toDevicePixels(Number(value));
|
|
426
|
+
return {
|
|
427
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
428
|
+
min_value: dip,
|
|
429
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
430
|
+
max_value: dip,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (typeof value === 'number') {
|
|
435
|
+
const dip = masonLayout.toDevicePixels(value);
|
|
436
|
+
return {
|
|
437
|
+
min_type: 3 /* MinSizingType.Points */,
|
|
438
|
+
min_value: dip,
|
|
439
|
+
max_type: 3 /* MaxSizingType.Points */,
|
|
440
|
+
max_value: dip,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
return undefined;
|
|
444
|
+
}
|
|
445
|
+
const grid_templates_regex = /[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g;
|
|
446
|
+
export function _parseGridTemplates(value) {
|
|
447
|
+
const array = [];
|
|
448
|
+
if (typeof value === 'string') {
|
|
449
|
+
const values = Array.from(value.matchAll(grid_templates_regex), (m) => m[0]);
|
|
450
|
+
values.forEach((item) => {
|
|
451
|
+
if (item.startsWith('repeat(')) {
|
|
452
|
+
const repeatValue = item.replace('repeat(', '').replace(')', '');
|
|
453
|
+
const trackEnd = repeatValue.indexOf(',');
|
|
454
|
+
const repetition = repeatValue.substring(0, trackEnd);
|
|
455
|
+
const tracks = repeatValue
|
|
456
|
+
.substring(trackEnd + 1)
|
|
457
|
+
.split(' ')
|
|
458
|
+
.filter((a) => {
|
|
459
|
+
return a.length || a.trim() === ',';
|
|
460
|
+
});
|
|
461
|
+
let isValid = true;
|
|
462
|
+
let repeating_type = 0;
|
|
463
|
+
let repeat_count = 0;
|
|
464
|
+
switch (repetition) {
|
|
465
|
+
case 'repeat-fill':
|
|
466
|
+
repeating_type = 0 /* TSCGridTrackRepetition.AutoFill */;
|
|
467
|
+
break;
|
|
468
|
+
case 'repeat-fit':
|
|
469
|
+
repeating_type = 1 /* TSCGridTrackRepetition.AutoFit */;
|
|
470
|
+
break;
|
|
471
|
+
default:
|
|
472
|
+
{
|
|
473
|
+
const number = parseInt(repetition);
|
|
474
|
+
repeating_type = 2 /* TSCGridTrackRepetition.Count */;
|
|
475
|
+
isValid = !Number.isNaN(number);
|
|
476
|
+
if (isValid) {
|
|
477
|
+
repeat_count = number;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
if (isValid) {
|
|
483
|
+
const tracks_array = [];
|
|
484
|
+
tracks.forEach((track) => {
|
|
485
|
+
const minMax = _parseMinMaxValue(track.trim());
|
|
486
|
+
tracks_array.push(minMax);
|
|
487
|
+
});
|
|
488
|
+
array.push({
|
|
489
|
+
is_repeating: true,
|
|
490
|
+
repeating_type,
|
|
491
|
+
repeating_count: repeat_count,
|
|
492
|
+
value: tracks_array,
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
const value = _parseMinMaxValue(item);
|
|
498
|
+
array.push({
|
|
499
|
+
is_repeating: false,
|
|
500
|
+
repeating_type: 0,
|
|
501
|
+
value,
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
return array;
|
|
507
|
+
}
|
|
508
|
+
export function _setGridTemplateRows(value, instance, initial = false) {
|
|
509
|
+
if (!instance[isMasonView_]) {
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
export function _setGridTemplateColumns(value, instance, initial = false) { }
|
|
514
|
+
export function _parseGridAutoRowsColumns(value) {
|
|
515
|
+
const array = [];
|
|
516
|
+
if (typeof value === 'string') {
|
|
517
|
+
const values = value.split(' ');
|
|
518
|
+
values.forEach((item) => {
|
|
519
|
+
const value = _parseMinMaxValue(item);
|
|
520
|
+
array.push({
|
|
521
|
+
is_repeating: false,
|
|
522
|
+
repeating_type: 0,
|
|
523
|
+
value,
|
|
524
|
+
});
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
return array;
|
|
528
|
+
}
|
|
529
|
+
export function _setGridAutoRows(value, instance, initial = false) {
|
|
530
|
+
if (!instance[isMasonView_]) {
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const values = _parseGridAutoRowsColumns(value);
|
|
534
|
+
const array = Array.create('org.nativescript.mason.masonkit.MinMax', values.length);
|
|
535
|
+
const length = array.length;
|
|
536
|
+
for (let i = 0; i < length; i++) {
|
|
537
|
+
const item = value[i];
|
|
538
|
+
const minMax = org.nativescript.mason.masonkit.MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
|
|
539
|
+
array[i] = minMax;
|
|
540
|
+
}
|
|
541
|
+
if (instance.android?.setGridAutoRows) {
|
|
542
|
+
instance.android.setGridAutoRows(array);
|
|
543
|
+
}
|
|
544
|
+
else {
|
|
545
|
+
const style = org.nativescript.mason.masonkit.Mason.getShared().styleForView(instance.android);
|
|
546
|
+
if (style) {
|
|
547
|
+
style.setGridAutoRows(array);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
export function _setGridAutoColumns(value, instance, initial = false) {
|
|
552
|
+
if (!instance[isMasonView_]) {
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
const values = _parseGridAutoRowsColumns(value);
|
|
556
|
+
const array = Array.create('org.nativescript.mason.masonkit.MinMax', values.length);
|
|
557
|
+
const length = value.length;
|
|
558
|
+
for (let i = 0; i < length; i++) {
|
|
559
|
+
const item = value[i];
|
|
560
|
+
const minMax = org.nativescript.mason.masonkit.MinMax.fromTypeValue(item.min_type, item.min_value, item.max_type, item.max_value);
|
|
561
|
+
array[i] = minMax;
|
|
562
|
+
}
|
|
563
|
+
if (instance.android?.setGridAutoColumns) {
|
|
564
|
+
instance.android.setGridAutoColumns(array);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
const style = org.nativescript.mason.masonkit.Mason.getShared().styleForView(instance.android);
|
|
568
|
+
if (style) {
|
|
569
|
+
style.setGridAutoColumns(array);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
export function _getGridTemplateRows(instance) {
|
|
574
|
+
if (!instance[isMasonView_]) {
|
|
575
|
+
return '';
|
|
576
|
+
}
|
|
577
|
+
if (__ANDROID__) {
|
|
578
|
+
return org.nativescript.mason.masonkit.StyleHelpers.gridTemplateRowsCSS(Tree.instance.native, instance.android);
|
|
579
|
+
}
|
|
580
|
+
const style = org.nativescript.mason.masonkit.Mason.getShared().styleForView(instance.android);
|
|
581
|
+
if (style) {
|
|
582
|
+
return style.getGridTemplateRows();
|
|
583
|
+
}
|
|
584
|
+
return [];
|
|
585
|
+
}
|
|
586
|
+
export function _getGridTemplateColumns(instance) {
|
|
587
|
+
if (!instance[isMasonView_]) {
|
|
588
|
+
return [];
|
|
589
|
+
}
|
|
590
|
+
const style = org.nativescript.mason.masonkit.Mason.getShared().styleForView(instance.android);
|
|
591
|
+
if (style) {
|
|
592
|
+
return style.getGridTemplateColumns();
|
|
593
|
+
}
|
|
594
|
+
return [];
|
|
595
|
+
}
|