@onekeyfe/react-native-native-list 6.7.0-4 → 6.7.0-41
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/README.md +4 -0
- package/android/src/main/java/com/onekey/nativelist/HybridNativeList.kt +14 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListAccessoryStack.kt +250 -9
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityDetailsView.kt +35 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListActivityRenderer.kt +25 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListAdapter.kt +17 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListButtonGroupRenderer.kt +102 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListContainerSlotAdapter.kt +12 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListDataRowRenderer.kt +102 -7
- package/android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt +47 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListIdentityRenderer.kt +225 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListLeadingVisual.kt +152 -33
- package/android/src/main/java/com/onekey/nativelist/NativeListMarketRenderer.kt +92 -28
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPlaceholderView.kt +244 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaPreviewSlot.kt +66 -31
- package/android/src/main/java/com/onekey/nativelist/NativeListMediaTileRenderer.kt +32 -11
- package/android/src/main/java/com/onekey/nativelist/NativeListMessageRenderer.kt +25 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListModels.kt +149 -3
- package/android/src/main/java/com/onekey/nativelist/NativeListPrimitives.kt +120 -287
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRegistry.kt +2 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListRendererRowView.kt +7 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListResolvedText.kt +3 -2
- package/android/src/main/java/com/onekey/nativelist/NativeListSectionHeaderRenderer.kt +69 -0
- package/android/src/main/java/com/onekey/nativelist/NativeListTextView.kt +55 -1
- package/android/src/main/java/com/onekey/nativelist/NativeListView.kt +1953 -117
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListActivityHostClipPolicyTest.kt +35 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListIdentityTrailingAxisTest.kt +36 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingSlotFrameTest.kt +68 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListLeadingVisualClipPolicyTest.kt +44 -0
- package/android/src/test/java/com/margelo/nitro/nativelist/NativeListPressPolicyTest.kt +10 -0
- package/docs/ROW_TEMPLATES.md +74 -13
- package/docs/SPEC.md +1206 -15
- package/docs/STYLE_SPEC.md +14 -0
- package/ios/HybridNativeList.swift +21 -2
- package/ios/NativeListAccessoryStack.swift +237 -51
- package/ios/NativeListActivityDetailsView.swift +30 -11
- package/ios/NativeListActivityRenderer.swift +8 -2
- package/ios/NativeListButtonGroupRenderer.swift +89 -0
- package/ios/NativeListDataRowRenderer.swift +167 -30
- package/ios/NativeListDesignAssets.swift +13 -75
- package/ios/NativeListGeneratedIcons.swift +55 -0
- package/ios/NativeListIconBinding.swift +171 -0
- package/ios/NativeListIdentityRenderer.swift +256 -39
- package/ios/NativeListLeadingVisual.swift +127 -28
- package/ios/NativeListMarketRenderer.swift +120 -31
- package/ios/NativeListMediaPlaceholderView.swift +189 -0
- package/ios/NativeListMediaPreviewSlot.swift +122 -61
- package/ios/NativeListMediaTileRenderer.swift +15 -11
- package/ios/NativeListMessageRenderer.swift +34 -1
- package/ios/NativeListMetricCardRenderer.swift +4 -2
- package/ios/NativeListModels.swift +42 -2
- package/ios/NativeListRendererRegistry.swift +1 -0
- package/ios/NativeListResolvedText.swift +2 -1
- package/ios/NativeListRowHost.swift +14 -0
- package/ios/NativeListSectionHeaderRenderer.swift +100 -4
- package/ios/RNCNativeListView.swift +1053 -58
- package/ios/tests/NativeListAccessoryStackTests.swift +101 -0
- package/ios/tests/NativeListAccountSelectorLayoutTests.swift +96 -0
- package/ios/tests/NativeListActivityPresentationTests.swift +153 -0
- package/ios/tests/NativeListIdentityTitleIconLayoutTests.swift +81 -0
- package/ios/tests/NativeListLeadingVisualPairBackdropTests.swift +50 -0
- package/ios/tests/NativeListLifecycleTests.swift +2819 -3
- package/ios/tests/NativeListMarketMetricsTests.swift +117 -0
- package/ios/tests/NativeListMediaVisibilityTests.swift +26 -1
- package/ios/tests/NativeListSharedIconTests.swift +236 -0
- package/lib/module/NativeList.js +221 -36
- package/lib/module/NativeList.web.js +167 -46
- package/lib/module/index.js +1 -1
- package/lib/module/models.js +3 -0
- package/lib/module/selection.js +1 -1
- package/lib/module/validation.js +1246 -48
- package/lib/module/web/NativeListGeneratedIcons.js +31 -0
- package/lib/module/web/NativeListWebEngine.js +513 -275
- package/lib/module/web/templates/ActivityRowRenderer.js +120 -87
- package/lib/module/web/templates/ButtonGroupRowRenderer.js +47 -0
- package/lib/module/web/templates/DataRowRenderer.js +40 -5
- package/lib/module/web/templates/IdentityRowRenderer.js +158 -6
- package/lib/module/web/templates/MarketTableRowRenderer.js +36 -19
- package/lib/module/web/templates/MediaTileRowRenderer.js +84 -25
- package/lib/module/web/templates/MessageRowRenderer.js +18 -2
- package/lib/module/web/templates/RowContainerStyle.js +1 -0
- package/lib/module/web/templates/RowRendererRegistry.js +3 -0
- package/lib/module/web/templates/SectionHeaderRowRenderer.js +36 -2
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/lib/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/lib/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/lib/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/lib/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/lib/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/lib/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/lib/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/lib/typescript/src/NativeList.d.ts +3 -3
- package/lib/typescript/src/NativeList.nitro.d.ts +2 -0
- package/lib/typescript/src/NativeList.types.d.ts +20 -2
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/models.d.ts +126 -17
- package/lib/typescript/src/validation.d.ts +20 -0
- package/lib/typescript/src/web/NativeListGeneratedIcons.d.ts +2 -0
- package/lib/typescript/src/web/NativeListWebEngine.d.ts +32 -1
- package/lib/typescript/src/web/templates/ButtonGroupRowRenderer.d.ts +14 -0
- package/lib/typescript/src/web/templates/IdentityRowRenderer.d.ts +1 -1
- package/lib/typescript/src/web/templates/MessageRowRenderer.d.ts +9 -3
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.cpp +26 -0
- package/nitrogen/generated/android/c++/JHybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/android/c++/views/JHybridNativeListStateUpdater.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nativelist/HybridNativeListSpec.kt +20 -0
- package/nitrogen/generated/ios/c++/HybridNativeListSpecSwift.hpp +14 -0
- package/nitrogen/generated/ios/c++/views/HybridNativeListComponent.mm +12 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNativeListSpec_cxx.swift +43 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.cpp +4 -0
- package/nitrogen/generated/shared/c++/HybridNativeListSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.cpp +4 -0
- package/nitrogen/generated/shared/c++/views/HybridNativeListComponent.hpp +6 -0
- package/nitrogen/generated/shared/json/NativeListConfig.json +2 -0
- package/package.json +16 -10
- package/react-native-native-list.podspec +2 -6
- package/scripts/generate-icons.mjs +150 -0
- package/scripts/generate-icons.test.mjs +288 -0
- package/scripts/native-list-icons.json +260 -0
- package/src/NativeList.nitro.ts +2 -0
- package/src/NativeList.tsx +416 -89
- package/src/NativeList.types.ts +24 -2
- package/src/NativeList.web.tsx +295 -89
- package/src/index.ts +2 -0
- package/src/models.ts +263 -144
- package/src/selection.ts +1 -0
- package/src/validation.ts +3013 -152
- package/src/web/NativeListGeneratedIcons.ts +28 -0
- package/src/web/NativeListWebEngine.ts +818 -343
- package/src/web/templates/ActivityRowRenderer.ts +178 -141
- package/src/web/templates/ButtonGroupRowRenderer.ts +58 -0
- package/src/web/templates/DataRowRenderer.ts +93 -20
- package/src/web/templates/IdentityRowRenderer.ts +231 -6
- package/src/web/templates/MarketTableRowRenderer.ts +53 -33
- package/src/web/templates/MediaTileRowRenderer.ts +90 -28
- package/src/web/templates/MessageRowRenderer.ts +23 -7
- package/src/web/templates/RowContainerStyle.ts +2 -0
- package/src/web/templates/RowRendererRegistry.ts +11 -1
- package/src/web/templates/SectionHeaderRowRenderer.ts +47 -4
- package/ios/Resources/NativeListIcons.xcassets/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_arrow_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_badge_verified_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chart_trending_up.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_checked.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_checkbox_indeterminate.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_bottom.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_grabber_ver.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_right_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_chevron_top.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_dot_hor.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_drag.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_error_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_image_square_waves.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_info_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_minus_circle_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_pencil.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_circle.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_plus_small.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_questionmark_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_account_error_custom.imageset/icon.svg +0 -14
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_all_networks_solid.imageset/icon.svg +0 -12
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_apple_brand.imageset/icon.svg +0 -6
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_bot_illus.imageset/icon.svg +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_crossed_small_solid.imageset/icon.svg +0 -3
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_globus_outline.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_google_illus.imageset/icon.svg +0 -18
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/Contents.json +0 -15
- package/ios/Resources/NativeListIcons.xcassets/onekey_selector_lock_solid.imageset/icon.svg +0 -7
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_shield_exclamation.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_speaker_promote.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_star_solid.imageset/icon.svg +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/Contents.json +0 -1
- package/ios/Resources/NativeListIcons.xcassets/onekey_swap_hor.imageset/icon.svg +0 -1
|
@@ -130,6 +130,12 @@ using namespace margelo::nitro::nativelist::views;
|
|
|
130
130
|
: !newViewProps.containerSlotHeightsJson.hasSameValue(oldViewProps->containerSlotHeightsJson)) {
|
|
131
131
|
swiftPart.setContainerSlotHeightsJson(newViewProps.containerSlotHeightsJson.get());
|
|
132
132
|
}
|
|
133
|
+
// sidecarLayoutJson: string
|
|
134
|
+
if (oldViewProps == nullptr
|
|
135
|
+
? newViewProps.sidecarLayoutJson.isProvided()
|
|
136
|
+
: !newViewProps.sidecarLayoutJson.hasSameValue(oldViewProps->sidecarLayoutJson)) {
|
|
137
|
+
swiftPart.setSidecarLayoutJson(newViewProps.sidecarLayoutJson.get());
|
|
138
|
+
}
|
|
133
139
|
// topScrollEdgeEffect: enum
|
|
134
140
|
if (oldViewProps == nullptr
|
|
135
141
|
? newViewProps.topScrollEdgeEffect.isProvided()
|
|
@@ -202,6 +208,12 @@ using namespace margelo::nitro::nativelist::views;
|
|
|
202
208
|
: !newViewProps.onVisibleRangeChanged.hasSameValue(oldViewProps->onVisibleRangeChanged)) {
|
|
203
209
|
swiftPart.setOnVisibleRangeChanged(newViewProps.onVisibleRangeChanged.get());
|
|
204
210
|
}
|
|
211
|
+
// onStructuralTransitionSettled: optional
|
|
212
|
+
if (oldViewProps == nullptr
|
|
213
|
+
? newViewProps.onStructuralTransitionSettled.isProvided()
|
|
214
|
+
: !newViewProps.onStructuralTransitionSettled.hasSameValue(oldViewProps->onStructuralTransitionSettled)) {
|
|
215
|
+
swiftPart.setOnStructuralTransitionSettled(newViewProps.onStructuralTransitionSettled.get());
|
|
216
|
+
}
|
|
205
217
|
|
|
206
218
|
// Update hybridRef if it changed
|
|
207
219
|
if (oldViewProps == nullptr
|
|
@@ -13,6 +13,7 @@ public protocol HybridNativeListSpec_protocol: HybridObject, HybridView {
|
|
|
13
13
|
var snapshotJson: String { get set }
|
|
14
14
|
var fontFamiliesJson: String { get set }
|
|
15
15
|
var containerSlotHeightsJson: String { get set }
|
|
16
|
+
var sidecarLayoutJson: String { get set }
|
|
16
17
|
var topScrollEdgeEffect: NativeListScrollEdgeEffect { get set }
|
|
17
18
|
var topOverlayHeight: Double { get set }
|
|
18
19
|
var scrollPositionThresholdsJson: String { get set }
|
|
@@ -25,6 +26,7 @@ public protocol HybridNativeListSpec_protocol: HybridObject, HybridView {
|
|
|
25
26
|
var onReorder: ((_ payloadJson: String) -> Void)? { get set }
|
|
26
27
|
var onEndReached: ((_ payloadJson: String) -> Void)? { get set }
|
|
27
28
|
var onVisibleRangeChanged: ((_ payloadJson: String) -> Void)? { get set }
|
|
29
|
+
var onStructuralTransitionSettled: ((_ payloadJson: String) -> Void)? { get set }
|
|
28
30
|
|
|
29
31
|
// Methods
|
|
30
32
|
func applySnapshot(snapshotJson: String) throws -> Void
|
|
@@ -154,6 +154,17 @@ open class HybridNativeListSpec_cxx {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
public final var sidecarLayoutJson: std.string {
|
|
158
|
+
@inline(__always)
|
|
159
|
+
get {
|
|
160
|
+
return std.string(self.__implementation.sidecarLayoutJson)
|
|
161
|
+
}
|
|
162
|
+
@inline(__always)
|
|
163
|
+
set {
|
|
164
|
+
self.__implementation.sidecarLayoutJson = String(newValue)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
157
168
|
public final var topScrollEdgeEffect: Int32 {
|
|
158
169
|
@inline(__always)
|
|
159
170
|
get {
|
|
@@ -432,6 +443,38 @@ open class HybridNativeListSpec_cxx {
|
|
|
432
443
|
}()
|
|
433
444
|
}
|
|
434
445
|
}
|
|
446
|
+
|
|
447
|
+
public final var onStructuralTransitionSettled: bridge.std__optional_std__function_void_const_std__string_____payloadJson______ {
|
|
448
|
+
@inline(__always)
|
|
449
|
+
get {
|
|
450
|
+
return { () -> bridge.std__optional_std__function_void_const_std__string_____payloadJson______ in
|
|
451
|
+
if let __unwrappedValue = self.__implementation.onStructuralTransitionSettled {
|
|
452
|
+
return bridge.create_std__optional_std__function_void_const_std__string_____payloadJson______({ () -> bridge.Func_void_std__string in
|
|
453
|
+
let __closureWrapper = Func_void_std__string(__unwrappedValue)
|
|
454
|
+
return bridge.create_Func_void_std__string(__closureWrapper.toUnsafe())
|
|
455
|
+
}())
|
|
456
|
+
} else {
|
|
457
|
+
return .init()
|
|
458
|
+
}
|
|
459
|
+
}()
|
|
460
|
+
}
|
|
461
|
+
@inline(__always)
|
|
462
|
+
set {
|
|
463
|
+
self.__implementation.onStructuralTransitionSettled = { () -> ((_ payloadJson: String) -> Void)? in
|
|
464
|
+
if bridge.has_value_std__optional_std__function_void_const_std__string_____payloadJson______(newValue) {
|
|
465
|
+
let __unwrapped = bridge.get_std__optional_std__function_void_const_std__string_____payloadJson______(newValue)
|
|
466
|
+
return { () -> (String) -> Void in
|
|
467
|
+
let __wrappedFunction = bridge.wrap_Func_void_std__string(__unwrapped)
|
|
468
|
+
return { (__payloadJson: String) -> Void in
|
|
469
|
+
__wrappedFunction.call(std.string(__payloadJson))
|
|
470
|
+
}
|
|
471
|
+
}()
|
|
472
|
+
} else {
|
|
473
|
+
return nil
|
|
474
|
+
}
|
|
475
|
+
}()
|
|
476
|
+
}
|
|
477
|
+
}
|
|
435
478
|
|
|
436
479
|
// Methods
|
|
437
480
|
@inline(__always)
|
|
@@ -20,6 +20,8 @@ namespace margelo::nitro::nativelist {
|
|
|
20
20
|
prototype.registerHybridSetter("fontFamiliesJson", &HybridNativeListSpec::setFontFamiliesJson);
|
|
21
21
|
prototype.registerHybridGetter("containerSlotHeightsJson", &HybridNativeListSpec::getContainerSlotHeightsJson);
|
|
22
22
|
prototype.registerHybridSetter("containerSlotHeightsJson", &HybridNativeListSpec::setContainerSlotHeightsJson);
|
|
23
|
+
prototype.registerHybridGetter("sidecarLayoutJson", &HybridNativeListSpec::getSidecarLayoutJson);
|
|
24
|
+
prototype.registerHybridSetter("sidecarLayoutJson", &HybridNativeListSpec::setSidecarLayoutJson);
|
|
23
25
|
prototype.registerHybridGetter("topScrollEdgeEffect", &HybridNativeListSpec::getTopScrollEdgeEffect);
|
|
24
26
|
prototype.registerHybridSetter("topScrollEdgeEffect", &HybridNativeListSpec::setTopScrollEdgeEffect);
|
|
25
27
|
prototype.registerHybridGetter("topOverlayHeight", &HybridNativeListSpec::getTopOverlayHeight);
|
|
@@ -44,6 +46,8 @@ namespace margelo::nitro::nativelist {
|
|
|
44
46
|
prototype.registerHybridSetter("onEndReached", &HybridNativeListSpec::setOnEndReached);
|
|
45
47
|
prototype.registerHybridGetter("onVisibleRangeChanged", &HybridNativeListSpec::getOnVisibleRangeChanged);
|
|
46
48
|
prototype.registerHybridSetter("onVisibleRangeChanged", &HybridNativeListSpec::setOnVisibleRangeChanged);
|
|
49
|
+
prototype.registerHybridGetter("onStructuralTransitionSettled", &HybridNativeListSpec::getOnStructuralTransitionSettled);
|
|
50
|
+
prototype.registerHybridSetter("onStructuralTransitionSettled", &HybridNativeListSpec::setOnStructuralTransitionSettled);
|
|
47
51
|
prototype.registerHybridMethod("applySnapshot", &HybridNativeListSpec::applySnapshot);
|
|
48
52
|
prototype.registerHybridMethod("applyPatches", &HybridNativeListSpec::applyPatches);
|
|
49
53
|
prototype.registerHybridMethod("reconcileSelection", &HybridNativeListSpec::reconcileSelection);
|
|
@@ -63,6 +63,8 @@ namespace margelo::nitro::nativelist {
|
|
|
63
63
|
virtual void setFontFamiliesJson(const std::string& fontFamiliesJson) = 0;
|
|
64
64
|
virtual std::string getContainerSlotHeightsJson() = 0;
|
|
65
65
|
virtual void setContainerSlotHeightsJson(const std::string& containerSlotHeightsJson) = 0;
|
|
66
|
+
virtual std::string getSidecarLayoutJson() = 0;
|
|
67
|
+
virtual void setSidecarLayoutJson(const std::string& sidecarLayoutJson) = 0;
|
|
66
68
|
virtual NativeListScrollEdgeEffect getTopScrollEdgeEffect() = 0;
|
|
67
69
|
virtual void setTopScrollEdgeEffect(NativeListScrollEdgeEffect topScrollEdgeEffect) = 0;
|
|
68
70
|
virtual double getTopOverlayHeight() = 0;
|
|
@@ -87,6 +89,8 @@ namespace margelo::nitro::nativelist {
|
|
|
87
89
|
virtual void setOnEndReached(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onEndReached) = 0;
|
|
88
90
|
virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnVisibleRangeChanged() = 0;
|
|
89
91
|
virtual void setOnVisibleRangeChanged(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onVisibleRangeChanged) = 0;
|
|
92
|
+
virtual std::optional<std::function<void(const std::string& /* payloadJson */)>> getOnStructuralTransitionSettled() = 0;
|
|
93
|
+
virtual void setOnStructuralTransitionSettled(const std::optional<std::function<void(const std::string& /* payloadJson */)>>& onStructuralTransitionSettled) = 0;
|
|
90
94
|
|
|
91
95
|
public:
|
|
92
96
|
// Methods
|
|
@@ -23,6 +23,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
23
23
|
snapshotJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "snapshotJson", rawProps, sourceProps.snapshotJson)),
|
|
24
24
|
fontFamiliesJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "fontFamiliesJson", rawProps, sourceProps.fontFamiliesJson)),
|
|
25
25
|
containerSlotHeightsJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "containerSlotHeightsJson", rawProps, sourceProps.containerSlotHeightsJson)),
|
|
26
|
+
sidecarLayoutJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "sidecarLayoutJson", rawProps, sourceProps.sidecarLayoutJson)),
|
|
26
27
|
topScrollEdgeEffect(nitro::ReactProp<NativeListScrollEdgeEffect>::fromRawValue("NativeList", "topScrollEdgeEffect", rawProps, sourceProps.topScrollEdgeEffect)),
|
|
27
28
|
topOverlayHeight(nitro::ReactProp<double>::fromRawValue("NativeList", "topOverlayHeight", rawProps, sourceProps.topOverlayHeight)),
|
|
28
29
|
scrollPositionThresholdsJson(nitro::ReactProp<std::string>::fromRawValue("NativeList", "scrollPositionThresholdsJson", rawProps, sourceProps.scrollPositionThresholdsJson)),
|
|
@@ -35,6 +36,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
35
36
|
onReorder(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onReorder", rawProps, sourceProps.onReorder)),
|
|
36
37
|
onEndReached(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onEndReached", rawProps, sourceProps.onEndReached)),
|
|
37
38
|
onVisibleRangeChanged(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onVisibleRangeChanged", rawProps, sourceProps.onVisibleRangeChanged)),
|
|
39
|
+
onStructuralTransitionSettled(nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>>::fromRawValue("NativeList", "onStructuralTransitionSettled", rawProps, sourceProps.onStructuralTransitionSettled)),
|
|
38
40
|
hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNativeListSpec>& /* ref */)>>>::fromRawValue("NativeList", "hybridRef", rawProps, sourceProps.hybridRef)) { }
|
|
39
41
|
|
|
40
42
|
bool HybridNativeListProps::filterObjectKeys(const std::string& propName) {
|
|
@@ -42,6 +44,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
42
44
|
case hashString("snapshotJson"): return true;
|
|
43
45
|
case hashString("fontFamiliesJson"): return true;
|
|
44
46
|
case hashString("containerSlotHeightsJson"): return true;
|
|
47
|
+
case hashString("sidecarLayoutJson"): return true;
|
|
45
48
|
case hashString("topScrollEdgeEffect"): return true;
|
|
46
49
|
case hashString("topOverlayHeight"): return true;
|
|
47
50
|
case hashString("scrollPositionThresholdsJson"): return true;
|
|
@@ -54,6 +57,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
54
57
|
case hashString("onReorder"): return true;
|
|
55
58
|
case hashString("onEndReached"): return true;
|
|
56
59
|
case hashString("onVisibleRangeChanged"): return true;
|
|
60
|
+
case hashString("onStructuralTransitionSettled"): return true;
|
|
57
61
|
case hashString("hybridRef"): return true;
|
|
58
62
|
default: return false;
|
|
59
63
|
}
|
|
@@ -49,6 +49,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
49
49
|
nitro::ReactProp<std::string> snapshotJson;
|
|
50
50
|
nitro::ReactProp<std::string> fontFamiliesJson;
|
|
51
51
|
nitro::ReactProp<std::string> containerSlotHeightsJson;
|
|
52
|
+
nitro::ReactProp<std::string> sidecarLayoutJson;
|
|
52
53
|
nitro::ReactProp<NativeListScrollEdgeEffect> topScrollEdgeEffect;
|
|
53
54
|
nitro::ReactProp<double> topOverlayHeight;
|
|
54
55
|
nitro::ReactProp<std::string> scrollPositionThresholdsJson;
|
|
@@ -61,6 +62,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
61
62
|
nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onReorder;
|
|
62
63
|
nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onEndReached;
|
|
63
64
|
nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onVisibleRangeChanged;
|
|
65
|
+
nitro::ReactProp<std::optional<std::function<void(const std::string& /* payloadJson */)>>> onStructuralTransitionSettled;
|
|
64
66
|
nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNativeListSpec>& /* ref */)>>> hybridRef;
|
|
65
67
|
|
|
66
68
|
[[nodiscard]]
|
|
@@ -68,6 +70,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
68
70
|
return snapshotJson.hasSameValue(other.snapshotJson) &&
|
|
69
71
|
fontFamiliesJson.hasSameValue(other.fontFamiliesJson) &&
|
|
70
72
|
containerSlotHeightsJson.hasSameValue(other.containerSlotHeightsJson) &&
|
|
73
|
+
sidecarLayoutJson.hasSameValue(other.sidecarLayoutJson) &&
|
|
71
74
|
topScrollEdgeEffect.hasSameValue(other.topScrollEdgeEffect) &&
|
|
72
75
|
topOverlayHeight.hasSameValue(other.topOverlayHeight) &&
|
|
73
76
|
scrollPositionThresholdsJson.hasSameValue(other.scrollPositionThresholdsJson) &&
|
|
@@ -80,6 +83,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
80
83
|
onReorder.hasSameValue(other.onReorder) &&
|
|
81
84
|
onEndReached.hasSameValue(other.onEndReached) &&
|
|
82
85
|
onVisibleRangeChanged.hasSameValue(other.onVisibleRangeChanged) &&
|
|
86
|
+
onStructuralTransitionSettled.hasSameValue(other.onStructuralTransitionSettled) &&
|
|
83
87
|
hybridRef.hasSameValue(other.hybridRef);
|
|
84
88
|
}
|
|
85
89
|
|
|
@@ -88,6 +92,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
88
92
|
return snapshotJson.isProvided() ||
|
|
89
93
|
fontFamiliesJson.isProvided() ||
|
|
90
94
|
containerSlotHeightsJson.isProvided() ||
|
|
95
|
+
sidecarLayoutJson.isProvided() ||
|
|
91
96
|
topScrollEdgeEffect.isProvided() ||
|
|
92
97
|
topOverlayHeight.isProvided() ||
|
|
93
98
|
scrollPositionThresholdsJson.isProvided() ||
|
|
@@ -100,6 +105,7 @@ namespace margelo::nitro::nativelist::views {
|
|
|
100
105
|
onReorder.isProvided() ||
|
|
101
106
|
onEndReached.isProvided() ||
|
|
102
107
|
onVisibleRangeChanged.isProvided() ||
|
|
108
|
+
onStructuralTransitionSettled.isProvided() ||
|
|
103
109
|
hybridRef.isProvided();
|
|
104
110
|
}
|
|
105
111
|
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
"snapshotJson": true,
|
|
8
8
|
"fontFamiliesJson": true,
|
|
9
9
|
"containerSlotHeightsJson": true,
|
|
10
|
+
"sidecarLayoutJson": true,
|
|
10
11
|
"topScrollEdgeEffect": true,
|
|
11
12
|
"topOverlayHeight": true,
|
|
12
13
|
"scrollPositionThresholdsJson": true,
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
"onReorder": true,
|
|
20
21
|
"onEndReached": true,
|
|
21
22
|
"onVisibleRangeChanged": true,
|
|
23
|
+
"onStructuralTransitionSettled": true,
|
|
22
24
|
"hybridRef": true
|
|
23
25
|
}
|
|
24
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/react-native-native-list",
|
|
3
|
-
"version": "6.7.0-
|
|
3
|
+
"version": "6.7.0-41",
|
|
4
4
|
"description": "Template-driven native RecyclerView and UICollectionView for React Native",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./lib/module/index.js",
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
"scripts"
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
|
+
"icons:generate": "node scripts/generate-icons.mjs",
|
|
37
|
+
"icons:check": "node scripts/generate-icons.mjs --check",
|
|
38
|
+
"icons:test": "node scripts/generate-icons.test.mjs",
|
|
36
39
|
"clean": "del-cli lib",
|
|
37
40
|
"prepare": "del-cli lib && bob build && cp -r nitrogen lib/nitrogen",
|
|
38
41
|
"nitrogen": "nitrogen && node scripts/enable-container-slots.mjs",
|
|
@@ -67,10 +70,10 @@
|
|
|
67
70
|
"@eslint/compat": "^1.3.2",
|
|
68
71
|
"@eslint/eslintrc": "^3.3.1",
|
|
69
72
|
"@eslint/js": "^9.35.0",
|
|
70
|
-
"@react-native/babel-preset": "0.
|
|
71
|
-
"@react-native/eslint-config": "0.
|
|
73
|
+
"@react-native/babel-preset": "0.88.0",
|
|
74
|
+
"@react-native/eslint-config": "0.88.0",
|
|
72
75
|
"@types/jest": "^29.5.14",
|
|
73
|
-
"@types/react": "^19.
|
|
76
|
+
"@types/react": "^19.3.0",
|
|
74
77
|
"del-cli": "^6.0.0",
|
|
75
78
|
"eslint": "^9.35.0",
|
|
76
79
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -79,15 +82,15 @@
|
|
|
79
82
|
"jsdom": "26.1.0",
|
|
80
83
|
"nitrogen": "0.37.0",
|
|
81
84
|
"prettier": "^2.8.8",
|
|
82
|
-
"react": "19.
|
|
83
|
-
"react-native": "patch:react-native@npm%3A0.
|
|
85
|
+
"react": "19.3.0",
|
|
86
|
+
"react-native": "patch:react-native@npm%3A0.88.0#~/.yarn/patches/react-native-npm-0.88.0-60c6201dd2.patch",
|
|
84
87
|
"react-native-builder-bob": "^0.40.13",
|
|
85
88
|
"react-native-nitro-modules": "0.37.0",
|
|
86
89
|
"typescript": "^5.9.2"
|
|
87
90
|
},
|
|
88
91
|
"peerDependencies": {
|
|
89
|
-
"@onekeyfe/react-native-image": "
|
|
90
|
-
"@onekeyfe/react-native-native-logger": "
|
|
92
|
+
"@onekeyfe/react-native-image": "*",
|
|
93
|
+
"@onekeyfe/react-native-native-logger": "*",
|
|
91
94
|
"react": "*",
|
|
92
95
|
"react-native": "*",
|
|
93
96
|
"react-native-nitro-modules": "0.37.0"
|
|
@@ -118,10 +121,13 @@
|
|
|
118
121
|
]
|
|
119
122
|
},
|
|
120
123
|
"jest": {
|
|
121
|
-
"preset": "react-native",
|
|
124
|
+
"preset": "@react-native/jest-preset",
|
|
122
125
|
"modulePathIgnorePatterns": [
|
|
123
126
|
"<rootDir>/lib/"
|
|
124
|
-
]
|
|
127
|
+
],
|
|
128
|
+
"moduleNameMapper": {
|
|
129
|
+
"^#onekey-icon-assets$": "<rootDir>/../../example/react-native/icon-fixtures/web/assetUrls.ts"
|
|
130
|
+
}
|
|
125
131
|
},
|
|
126
132
|
"prettier": {
|
|
127
133
|
"singleQuote": true,
|
|
@@ -14,11 +14,6 @@ Pod::Spec.new do |s|
|
|
|
14
14
|
s.source = { :git => "https://github.com/OneKeyHQ/app-modules.git", :tag => "#{s.version}" }
|
|
15
15
|
s.source_files = ["ios/**/*.{swift,h,m,mm,cpp}"]
|
|
16
16
|
s.exclude_files = "ios/tests/**/*"
|
|
17
|
-
s.resource_bundles = {
|
|
18
|
-
"NativeListResources" => [
|
|
19
|
-
"ios/Resources/NativeListIcons.xcassets"
|
|
20
|
-
]
|
|
21
|
-
}
|
|
22
17
|
s.static_framework = true
|
|
23
18
|
|
|
24
19
|
s.pod_target_xcconfig = {
|
|
@@ -28,11 +23,12 @@ Pod::Spec.new do |s|
|
|
|
28
23
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20"
|
|
29
24
|
}
|
|
30
25
|
|
|
31
|
-
s.dependency "OneKeyImage"
|
|
26
|
+
s.dependency "OneKeyImage"
|
|
32
27
|
s.dependency "React-jsi"
|
|
33
28
|
s.dependency "React-callinvoker"
|
|
34
29
|
|
|
35
30
|
s.test_spec "Tests" do |test_spec|
|
|
31
|
+
test_spec.requires_app_host = true
|
|
36
32
|
test_spec.source_files = "ios/tests/**/*.swift"
|
|
37
33
|
test_spec.pod_target_xcconfig = {
|
|
38
34
|
"PRODUCT_MODULE_NAME" => "NativeListModuleTests",
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const prettier = require('prettier');
|
|
9
|
+
const format = JSON.parse(
|
|
10
|
+
fs.readFileSync(path.join(root, 'package.json'), 'utf8')
|
|
11
|
+
).prettier;
|
|
12
|
+
const header =
|
|
13
|
+
'// Generated by scripts/generate-icons.mjs. Coverage and legacy names only; hosts provide SVG resources.\n';
|
|
14
|
+
export function generateOutputs(
|
|
15
|
+
fixtureRoot = path.resolve(
|
|
16
|
+
root,
|
|
17
|
+
'../../example/react-native/icon-fixtures/native/icons'
|
|
18
|
+
),
|
|
19
|
+
outputRoot = root
|
|
20
|
+
) {
|
|
21
|
+
const entries = JSON.parse(
|
|
22
|
+
fs.readFileSync(path.join(root, 'scripts/native-list-icons.json'), 'utf8')
|
|
23
|
+
);
|
|
24
|
+
const catalog = JSON.parse(
|
|
25
|
+
fs.readFileSync(path.join(fixtureRoot, 'manifest.json'), 'utf8')
|
|
26
|
+
);
|
|
27
|
+
const records = resolveRecords(entries, catalog, fixtureRoot);
|
|
28
|
+
return renderOutputs(records, outputRoot);
|
|
29
|
+
}
|
|
30
|
+
export function resolveRecords(entries, catalog, fixtureRoot) {
|
|
31
|
+
const names = new Set();
|
|
32
|
+
if (!Array.isArray(entries)) throw new Error('Invalid icon manifest');
|
|
33
|
+
return entries
|
|
34
|
+
.map((entry) => {
|
|
35
|
+
if (
|
|
36
|
+
!entry ||
|
|
37
|
+
typeof entry.name !== 'string' ||
|
|
38
|
+
!/^[A-Z][A-Za-z0-9]*$/.test(entry.name) ||
|
|
39
|
+
names.has(entry.name) ||
|
|
40
|
+
!Array.isArray(entry.platforms) ||
|
|
41
|
+
!entry.platforms.length ||
|
|
42
|
+
new Set(entry.platforms).size !== entry.platforms.length ||
|
|
43
|
+
entry.platforms.some((p) => !['ios', 'android', 'web'].includes(p)) ||
|
|
44
|
+
!['template', 'original', 'primitive'].includes(entry.rendering)
|
|
45
|
+
)
|
|
46
|
+
throw new Error('Invalid icon manifest entry');
|
|
47
|
+
names.add(entry.name);
|
|
48
|
+
if (entry.name === 'Circle')
|
|
49
|
+
return { ...entry, canonical: 'Circle', width: 24, height: 24 };
|
|
50
|
+
if (
|
|
51
|
+
typeof entry.source !== 'string' ||
|
|
52
|
+
entry.source.includes('..') ||
|
|
53
|
+
path.isAbsolute(entry.source)
|
|
54
|
+
)
|
|
55
|
+
throw new Error('Invalid icon manifest entry');
|
|
56
|
+
const matches = Object.entries(catalog).filter(
|
|
57
|
+
([, value]) => value.source === entry.source
|
|
58
|
+
);
|
|
59
|
+
if (matches.length > 1)
|
|
60
|
+
throw new Error(`Ambiguous shared SVG source: ${entry.source}`);
|
|
61
|
+
const match = matches[0];
|
|
62
|
+
if (!match) throw new Error(`Missing shared SVG source: ${entry.source}`);
|
|
63
|
+
const [canonical, metadata] = match;
|
|
64
|
+
const source = fs.readFileSync(
|
|
65
|
+
path.join(fixtureRoot, `${canonical}.svg`),
|
|
66
|
+
'utf8'
|
|
67
|
+
);
|
|
68
|
+
const raw = source.endsWith('\n') ? source : source + '\n';
|
|
69
|
+
if (
|
|
70
|
+
crypto.createHash('sha256').update(raw).digest('hex') !==
|
|
71
|
+
metadata.digest
|
|
72
|
+
)
|
|
73
|
+
throw new Error(`Shared SVG resources stale: ${entry.source}`);
|
|
74
|
+
return {
|
|
75
|
+
...entry,
|
|
76
|
+
canonical,
|
|
77
|
+
width: metadata.viewBox[2],
|
|
78
|
+
height: metadata.viewBox[3],
|
|
79
|
+
};
|
|
80
|
+
})
|
|
81
|
+
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
82
|
+
}
|
|
83
|
+
function renderOutputs(records, outputRoot) {
|
|
84
|
+
const swift =
|
|
85
|
+
header +
|
|
86
|
+
'import UIKit\n\nstruct NativeListIconMetadata {\n let name: String\n let size: CGSize\n let original: Bool\n}\n\nenum NativeListGeneratedIcons {\n static let icons: [String: NativeListIconMetadata] = [\n' +
|
|
87
|
+
records
|
|
88
|
+
.filter((x) => x.platforms.includes('ios'))
|
|
89
|
+
.map(
|
|
90
|
+
(x) =>
|
|
91
|
+
` "${x.name}": NativeListIconMetadata(name: "${
|
|
92
|
+
x.canonical
|
|
93
|
+
}", size: CGSize(width: ${x.width}, height: ${x.height}), original: ${
|
|
94
|
+
x.rendering === 'original'
|
|
95
|
+
}),`
|
|
96
|
+
)
|
|
97
|
+
.join('\n') +
|
|
98
|
+
'\n ]\n}\n';
|
|
99
|
+
const kotlin =
|
|
100
|
+
header +
|
|
101
|
+
'package com.margelo.nitro.nativelist\n\ninternal data class NativeListIconMetadata(val name: String, val width: Float, val height: Float)\ninternal val nativeListGeneratedIcons: Map<String, NativeListIconMetadata> = mapOf(\n' +
|
|
102
|
+
records
|
|
103
|
+
.filter((x) => x.platforms.includes('android'))
|
|
104
|
+
.map(
|
|
105
|
+
(x) =>
|
|
106
|
+
` "${x.name}" to NativeListIconMetadata("${x.canonical}", ${x.width}f, ${x.height}f),`
|
|
107
|
+
)
|
|
108
|
+
.join('\n') +
|
|
109
|
+
'\n)\n';
|
|
110
|
+
const web =
|
|
111
|
+
header +
|
|
112
|
+
'export const nativeListGeneratedIcons: Readonly<Record<string, string>> = ' +
|
|
113
|
+
JSON.stringify(
|
|
114
|
+
Object.fromEntries(
|
|
115
|
+
records
|
|
116
|
+
.filter((x) => x.platforms.includes('web'))
|
|
117
|
+
.map((x) => [x.name, x.canonical])
|
|
118
|
+
)
|
|
119
|
+
) +
|
|
120
|
+
';\n';
|
|
121
|
+
return new Map([
|
|
122
|
+
[path.join(outputRoot, 'ios/NativeListGeneratedIcons.swift'), swift],
|
|
123
|
+
[
|
|
124
|
+
path.join(
|
|
125
|
+
outputRoot,
|
|
126
|
+
'android/src/main/java/com/onekey/nativelist/NativeListGeneratedIcons.kt'
|
|
127
|
+
),
|
|
128
|
+
kotlin,
|
|
129
|
+
],
|
|
130
|
+
[
|
|
131
|
+
path.join(outputRoot, 'src/web/NativeListGeneratedIcons.ts'),
|
|
132
|
+
prettier.format(web, { ...format, parser: 'typescript' }),
|
|
133
|
+
],
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
|
137
|
+
const outputs = generateOutputs();
|
|
138
|
+
const stale = [...outputs].filter(
|
|
139
|
+
([file, text]) =>
|
|
140
|
+
!fs.existsSync(file) || fs.readFileSync(file, 'utf8') !== text
|
|
141
|
+
);
|
|
142
|
+
if (process.argv.includes('--check') && stale.length)
|
|
143
|
+
throw new Error('Stale NativeList icon metadata');
|
|
144
|
+
if (!process.argv.includes('--check'))
|
|
145
|
+
for (const [file, text] of stale) {
|
|
146
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
147
|
+
fs.writeFileSync(file, text);
|
|
148
|
+
}
|
|
149
|
+
console.log(JSON.stringify({ outputs: outputs.size, changed: stale.length }));
|
|
150
|
+
}
|