@thelacanians/vue-native-cli 0.4.11 → 0.4.13

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.
Files changed (69) hide show
  1. package/dist/cli.js +1 -1
  2. package/native/android/.editorconfig +25 -0
  3. package/native/android/VueNativeCore/build.gradle.kts +25 -1
  4. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSPolyfills.kt +17 -10
  5. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSRuntime.kt +5 -5
  6. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/NativeBridge.kt +13 -13
  7. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/ComponentRegistry.kt +27 -27
  8. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActionSheetFactory.kt +6 -4
  9. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActivityIndicatorFactory.kt +1 -1
  10. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VAlertDialogFactory.kt +24 -12
  11. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VButtonFactory.kt +5 -2
  12. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VImageFactory.kt +7 -7
  13. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VInputFactory.kt +12 -12
  14. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VKeyboardAvoidingFactory.kt +0 -1
  15. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VListFactory.kt +5 -2
  16. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VModalFactory.kt +5 -2
  17. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPickerFactory.kt +3 -2
  18. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPressableFactory.kt +5 -3
  19. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VRootFactory.kt +5 -2
  20. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VScrollViewFactory.kt +5 -2
  21. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSectionListFactory.kt +5 -2
  22. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSegmentedControlFactory.kt +3 -3
  23. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VStatusBarFactory.kt +3 -3
  24. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSwitchFactory.kt +0 -1
  25. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VViewFactory.kt +9 -3
  26. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VWebViewFactory.kt +7 -5
  27. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/NativeComponentFactory.kt +5 -2
  28. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Helpers/GestureHelper.kt +4 -1
  29. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AnimationModule.kt +77 -21
  30. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AsyncStorageModule.kt +20 -5
  31. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BackgroundTaskModule.kt +12 -3
  32. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BiometryModule.kt +5 -2
  33. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BluetoothModule.kt +88 -23
  34. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/CalendarModule.kt +24 -11
  35. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ClipboardModule.kt +7 -2
  36. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ContactsModule.kt +24 -12
  37. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/DeviceInfoModule.kt +14 -11
  38. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/FileSystemModule.kt +79 -24
  39. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/GeolocationModule.kt +10 -7
  40. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HapticsModule.kt +5 -5
  41. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HttpModule.kt +17 -8
  42. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/IAPModule.kt +20 -5
  43. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/KeyboardModule.kt +4 -1
  44. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/LinkingModule.kt +12 -3
  45. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NetworkModule.kt +4 -1
  46. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NotificationsModule.kt +24 -6
  47. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/OTAModule.kt +13 -5
  48. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PerformanceModule.kt +8 -2
  49. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PermissionsModule.kt +17 -8
  50. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SecureStorageModule.kt +20 -5
  51. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SensorsModule.kt +16 -4
  52. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ShareModule.kt +6 -3
  53. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SocialAuthModule.kt +4 -2
  54. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/WebSocketModule.kt +26 -8
  55. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Styling/StyleEngine.kt +127 -84
  56. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Tags.kt +26 -26
  57. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/VueNativeActivity.kt +1 -1
  58. package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/ComponentRegistryTest.kt +173 -0
  59. package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/NativeBridgeTest.kt +436 -0
  60. package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/NativeModuleRegistryTest.kt +251 -0
  61. package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/StyleEngineTest.kt +482 -0
  62. package/native/android/build.gradle.kts +1 -0
  63. package/native/ios/.swiftlint.yml +62 -0
  64. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/NativeBridge.swift +4 -1
  65. package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/ComponentRegistryTests.swift +237 -0
  66. package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/NativeBridgeOperationTests.swift +398 -0
  67. package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/NativeModuleRegistryTests.swift +203 -0
  68. package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/StyleEngineTests.swift +381 -0
  69. package/package.json +1 -1
@@ -0,0 +1,482 @@
1
+ package com.vuenative.core
2
+
3
+ import android.content.Context
4
+ import android.graphics.Color
5
+ import android.graphics.drawable.GradientDrawable
6
+ import android.view.View
7
+ import android.widget.FrameLayout
8
+ import android.widget.TextView
9
+ import androidx.test.core.app.ApplicationProvider
10
+ import com.google.android.flexbox.AlignItems
11
+ import com.google.android.flexbox.FlexDirection
12
+ import com.google.android.flexbox.FlexboxLayout
13
+ import com.google.android.flexbox.JustifyContent
14
+ import org.junit.Assert.assertEquals
15
+ import org.junit.Assert.assertNotNull
16
+ import org.junit.Assert.assertNull
17
+ import org.junit.Assert.assertTrue
18
+ import org.junit.Before
19
+ import org.junit.Test
20
+ import org.junit.runner.RunWith
21
+ import org.robolectric.RobolectricTestRunner
22
+ import org.robolectric.annotation.Config
23
+
24
+ @RunWith(RobolectricTestRunner::class)
25
+ @Config(sdk = [34])
26
+ class StyleEngineTest {
27
+
28
+ private lateinit var context: Context
29
+
30
+ @Before
31
+ fun setUp() {
32
+ context = ApplicationProvider.getApplicationContext()
33
+ }
34
+
35
+ // -------------------------------------------------------------------------
36
+ // backgroundColor
37
+ // -------------------------------------------------------------------------
38
+
39
+ @Test
40
+ fun testBackgroundColor() {
41
+ val view = View(context)
42
+ StyleEngine.apply("backgroundColor", "#ff0000", view)
43
+
44
+ assertNotNull("Background should be set", view.background)
45
+ assertTrue("Background should be a GradientDrawable", view.background is GradientDrawable)
46
+ }
47
+
48
+ // -------------------------------------------------------------------------
49
+ // opacity
50
+ // -------------------------------------------------------------------------
51
+
52
+ @Test
53
+ fun testOpacity() {
54
+ val view = View(context)
55
+ StyleEngine.apply("opacity", 0.5, view)
56
+
57
+ assertEquals(0.5f, view.alpha, 0.01f)
58
+ }
59
+
60
+ @Test
61
+ fun testOpacityFromInt() {
62
+ val view = View(context)
63
+ StyleEngine.apply("opacity", 1, view)
64
+
65
+ assertEquals(1.0f, view.alpha, 0.01f)
66
+ }
67
+
68
+ // -------------------------------------------------------------------------
69
+ // borderRadius
70
+ // -------------------------------------------------------------------------
71
+
72
+ @Test
73
+ fun testBorderRadius() {
74
+ val view = View(context)
75
+ StyleEngine.apply("borderRadius", 10, view)
76
+
77
+ assertNotNull("Background should be set", view.background)
78
+ assertTrue("Background should be a GradientDrawable", view.background is GradientDrawable)
79
+ val bg = view.background as GradientDrawable
80
+ assertEquals(
81
+ "Corner radius should be 10dp in px",
82
+ StyleEngine.dpToPx(context, 10f),
83
+ bg.cornerRadius,
84
+ 0.1f
85
+ )
86
+ }
87
+
88
+ // -------------------------------------------------------------------------
89
+ // padding
90
+ // -------------------------------------------------------------------------
91
+
92
+ @Test
93
+ fun testPadding() {
94
+ val view = View(context)
95
+ StyleEngine.apply("padding", 16, view)
96
+
97
+ val expectedPx = StyleEngine.dpToPx(context, 16f).toInt()
98
+ assertEquals(expectedPx, view.paddingLeft)
99
+ assertEquals(expectedPx, view.paddingTop)
100
+ assertEquals(expectedPx, view.paddingRight)
101
+ assertEquals(expectedPx, view.paddingBottom)
102
+ }
103
+
104
+ // -------------------------------------------------------------------------
105
+ // paddingHorizontal / paddingVertical
106
+ // -------------------------------------------------------------------------
107
+
108
+ @Test
109
+ fun testPaddingHorizontal() {
110
+ val view = View(context)
111
+ StyleEngine.apply("paddingHorizontal", 20, view)
112
+
113
+ val expectedPx = StyleEngine.dpToPx(context, 20f).toInt()
114
+ assertEquals(expectedPx, view.paddingLeft)
115
+ assertEquals(expectedPx, view.paddingRight)
116
+ assertEquals("Top padding should not be set", 0, view.paddingTop)
117
+ assertEquals("Bottom padding should not be set", 0, view.paddingBottom)
118
+ }
119
+
120
+ @Test
121
+ fun testPaddingVertical() {
122
+ val view = View(context)
123
+ StyleEngine.apply("paddingVertical", 12, view)
124
+
125
+ val expectedPx = StyleEngine.dpToPx(context, 12f).toInt()
126
+ assertEquals(expectedPx, view.paddingTop)
127
+ assertEquals(expectedPx, view.paddingBottom)
128
+ assertEquals("Left padding should not be set", 0, view.paddingLeft)
129
+ assertEquals("Right padding should not be set", 0, view.paddingRight)
130
+ }
131
+
132
+ // -------------------------------------------------------------------------
133
+ // margin (stored in FlexProps)
134
+ // -------------------------------------------------------------------------
135
+
136
+ @Test
137
+ fun testMargin() {
138
+ val view = View(context)
139
+ StyleEngine.apply("margin", 8, view)
140
+
141
+ val fp = StyleEngine.getFlexProps(view)
142
+ val expectedPx = StyleEngine.dpToPx(context, 8f).toInt()
143
+ assertEquals(expectedPx, fp.marginLeft)
144
+ assertEquals(expectedPx, fp.marginTop)
145
+ assertEquals(expectedPx, fp.marginRight)
146
+ assertEquals(expectedPx, fp.marginBottom)
147
+ }
148
+
149
+ // -------------------------------------------------------------------------
150
+ // width / height (stored in FlexProps)
151
+ // -------------------------------------------------------------------------
152
+
153
+ @Test
154
+ fun testWidth() {
155
+ val view = View(context)
156
+ StyleEngine.apply("width", 100, view)
157
+
158
+ val fp = StyleEngine.getFlexProps(view)
159
+ val expectedPx = StyleEngine.dpToPx(context, 100f).toInt()
160
+ assertEquals(expectedPx, fp.width)
161
+ }
162
+
163
+ @Test
164
+ fun testHeight() {
165
+ val view = View(context)
166
+ StyleEngine.apply("height", 50, view)
167
+
168
+ val fp = StyleEngine.getFlexProps(view)
169
+ val expectedPx = StyleEngine.dpToPx(context, 50f).toInt()
170
+ assertEquals(expectedPx, fp.height)
171
+ }
172
+
173
+ // -------------------------------------------------------------------------
174
+ // flex
175
+ // -------------------------------------------------------------------------
176
+
177
+ @Test
178
+ fun testFlex() {
179
+ val view = View(context)
180
+ StyleEngine.apply("flex", 1, view)
181
+
182
+ val fp = StyleEngine.getFlexProps(view)
183
+ assertEquals("flexGrow should be 1", 1f, fp.flexGrow, 0.01f)
184
+ assertEquals("flexShrink should be 1", 1f, fp.flexShrink, 0.01f)
185
+ }
186
+
187
+ // -------------------------------------------------------------------------
188
+ // flexDirection
189
+ // -------------------------------------------------------------------------
190
+
191
+ @Test
192
+ fun testFlexDirection() {
193
+ val flexbox = FlexboxLayout(context)
194
+ StyleEngine.apply("flexDirection", "row", flexbox)
195
+
196
+ assertEquals(FlexDirection.ROW, flexbox.flexDirection)
197
+ }
198
+
199
+ @Test
200
+ fun testFlexDirectionColumn() {
201
+ val flexbox = FlexboxLayout(context)
202
+ StyleEngine.apply("flexDirection", "column", flexbox)
203
+
204
+ assertEquals(FlexDirection.COLUMN, flexbox.flexDirection)
205
+ }
206
+
207
+ // -------------------------------------------------------------------------
208
+ // justifyContent
209
+ // -------------------------------------------------------------------------
210
+
211
+ @Test
212
+ fun testJustifyContent() {
213
+ val flexbox = FlexboxLayout(context)
214
+ StyleEngine.apply("justifyContent", "center", flexbox)
215
+
216
+ assertEquals(JustifyContent.CENTER, flexbox.justifyContent)
217
+ }
218
+
219
+ @Test
220
+ fun testJustifyContentSpaceBetween() {
221
+ val flexbox = FlexboxLayout(context)
222
+ StyleEngine.apply("justifyContent", "space-between", flexbox)
223
+
224
+ assertEquals(JustifyContent.SPACE_BETWEEN, flexbox.justifyContent)
225
+ }
226
+
227
+ // -------------------------------------------------------------------------
228
+ // alignItems
229
+ // -------------------------------------------------------------------------
230
+
231
+ @Test
232
+ fun testAlignItems() {
233
+ val flexbox = FlexboxLayout(context)
234
+ StyleEngine.apply("alignItems", "center", flexbox)
235
+
236
+ assertEquals(AlignItems.CENTER, flexbox.alignItems)
237
+ }
238
+
239
+ @Test
240
+ fun testAlignItemsFlexStart() {
241
+ val flexbox = FlexboxLayout(context)
242
+ StyleEngine.apply("alignItems", "flex-start", flexbox)
243
+
244
+ assertEquals(AlignItems.FLEX_START, flexbox.alignItems)
245
+ }
246
+
247
+ // -------------------------------------------------------------------------
248
+ // overflow
249
+ // -------------------------------------------------------------------------
250
+
251
+ @Test
252
+ fun testOverflowHidden() {
253
+ val viewGroup = FrameLayout(context)
254
+ StyleEngine.apply("overflow", "hidden", viewGroup)
255
+
256
+ assertTrue("clipChildren should be true", viewGroup.clipChildren)
257
+ assertTrue("clipToPadding should be true", viewGroup.clipToPadding)
258
+ }
259
+
260
+ // -------------------------------------------------------------------------
261
+ // accessibilityLabel
262
+ // -------------------------------------------------------------------------
263
+
264
+ @Test
265
+ fun testAccessibilityLabel() {
266
+ val view = View(context)
267
+ StyleEngine.apply("accessibilityLabel", "Submit button", view)
268
+
269
+ assertEquals("Submit button", view.contentDescription)
270
+ assertEquals(
271
+ View.IMPORTANT_FOR_ACCESSIBILITY_YES,
272
+ view.importantForAccessibility
273
+ )
274
+ }
275
+
276
+ // -------------------------------------------------------------------------
277
+ // Text properties on TextView
278
+ // -------------------------------------------------------------------------
279
+
280
+ @Test
281
+ fun testTextColor() {
282
+ val textView = TextView(context)
283
+ StyleEngine.apply("color", "#0000ff", textView)
284
+
285
+ assertEquals(Color.BLUE, textView.currentTextColor)
286
+ }
287
+
288
+ @Test
289
+ fun testFontSize() {
290
+ val textView = TextView(context)
291
+ StyleEngine.apply("fontSize", 20, textView)
292
+
293
+ // textSize is returned in px; we set it in SP
294
+ // In Robolectric default density, 1sp = 1px
295
+ assertEquals(20f, textView.textSize, 1f)
296
+ }
297
+
298
+ // -------------------------------------------------------------------------
299
+ // Internal props
300
+ // -------------------------------------------------------------------------
301
+
302
+ @Test
303
+ fun testInternalProps() {
304
+ val view = View(context)
305
+ StyleEngine.apply("__myProp", "hello", view)
306
+
307
+ val stored = StyleEngine.getInternalProp("__myProp", view)
308
+ assertEquals("hello", stored)
309
+ }
310
+
311
+ @Test
312
+ fun testInternalPropsOverwrite() {
313
+ val view = View(context)
314
+ StyleEngine.apply("__myProp", "first", view)
315
+ StyleEngine.apply("__myProp", "second", view)
316
+
317
+ val stored = StyleEngine.getInternalProp("__myProp", view)
318
+ assertEquals("second", stored)
319
+ }
320
+
321
+ // -------------------------------------------------------------------------
322
+ // parseColor
323
+ // -------------------------------------------------------------------------
324
+
325
+ @Test
326
+ fun testParseColorHex6() {
327
+ val color = StyleEngine.parseColor("#ff0000")
328
+ assertNotNull(color)
329
+ assertEquals(Color.RED, color)
330
+ }
331
+
332
+ @Test
333
+ fun testParseColorHex8() {
334
+ val color = StyleEngine.parseColor("#80ff0000")
335
+ assertNotNull(color)
336
+ assertEquals(0x80, Color.alpha(color!!))
337
+ assertEquals(0xff, Color.red(color))
338
+ assertEquals(0x00, Color.green(color))
339
+ assertEquals(0x00, Color.blue(color))
340
+ }
341
+
342
+ @Test
343
+ fun testParseColorNamedWhite() {
344
+ assertEquals(Color.WHITE, StyleEngine.parseColor("white"))
345
+ }
346
+
347
+ @Test
348
+ fun testParseColorNamedBlack() {
349
+ assertEquals(Color.BLACK, StyleEngine.parseColor("black"))
350
+ }
351
+
352
+ @Test
353
+ fun testParseColorNamedRed() {
354
+ assertEquals(Color.RED, StyleEngine.parseColor("red"))
355
+ }
356
+
357
+ @Test
358
+ fun testParseColorTransparent() {
359
+ assertEquals(Color.TRANSPARENT, StyleEngine.parseColor("transparent"))
360
+ }
361
+
362
+ @Test
363
+ fun testParseColorNull() {
364
+ assertNull(StyleEngine.parseColor(null))
365
+ }
366
+
367
+ @Test
368
+ fun testParseColorInvalid() {
369
+ assertNull(StyleEngine.parseColor("notacolor"))
370
+ }
371
+
372
+ // -------------------------------------------------------------------------
373
+ // toFloat
374
+ // -------------------------------------------------------------------------
375
+
376
+ @Test
377
+ fun testToFloatFromInt() {
378
+ assertEquals(42f, StyleEngine.toFloat(42, 0f), 0.01f)
379
+ }
380
+
381
+ @Test
382
+ fun testToFloatFromDouble() {
383
+ assertEquals(3.14f, StyleEngine.toFloat(3.14, 0f), 0.01f)
384
+ }
385
+
386
+ @Test
387
+ fun testToFloatFromString() {
388
+ assertEquals(7.5f, StyleEngine.toFloat("7.5", 0f), 0.01f)
389
+ }
390
+
391
+ @Test
392
+ fun testToFloatFromNull() {
393
+ assertEquals(99f, StyleEngine.toFloat(null, 99f), 0.01f)
394
+ }
395
+
396
+ @Test
397
+ fun testToFloatFromInvalidString() {
398
+ assertEquals(5f, StyleEngine.toFloat("abc", 5f), 0.01f)
399
+ }
400
+
401
+ // -------------------------------------------------------------------------
402
+ // toInt
403
+ // -------------------------------------------------------------------------
404
+
405
+ @Test
406
+ fun testToIntFromInt() {
407
+ assertEquals(42, StyleEngine.toInt(42, 0))
408
+ }
409
+
410
+ @Test
411
+ fun testToIntFromDouble() {
412
+ assertEquals(3, StyleEngine.toInt(3.7, 0))
413
+ }
414
+
415
+ @Test
416
+ fun testToIntFromString() {
417
+ assertEquals(10, StyleEngine.toInt("10", 0))
418
+ }
419
+
420
+ @Test
421
+ fun testToIntFromNull() {
422
+ assertEquals(99, StyleEngine.toInt(null, 99))
423
+ }
424
+
425
+ // -------------------------------------------------------------------------
426
+ // dpToPx
427
+ // -------------------------------------------------------------------------
428
+
429
+ @Test
430
+ fun testDpToPx() {
431
+ val density = context.resources.displayMetrics.density
432
+ val result = StyleEngine.dpToPx(context, 10f)
433
+ assertEquals(10f * density, result, 0.01f)
434
+ }
435
+
436
+ @Test
437
+ fun testDpToPxZero() {
438
+ assertEquals(0f, StyleEngine.dpToPx(context, 0f), 0.01f)
439
+ }
440
+
441
+ // -------------------------------------------------------------------------
442
+ // spToPx
443
+ // -------------------------------------------------------------------------
444
+
445
+ @Test
446
+ fun testSpToPx() {
447
+ val result = StyleEngine.spToPx(context, 14f)
448
+ assertTrue("spToPx should return a positive value for positive input", result > 0f)
449
+ }
450
+
451
+ // -------------------------------------------------------------------------
452
+ // display: none / visible
453
+ // -------------------------------------------------------------------------
454
+
455
+ @Test
456
+ fun testDisplayNone() {
457
+ val view = View(context)
458
+ StyleEngine.apply("display", "none", view)
459
+ assertEquals(View.GONE, view.visibility)
460
+ }
461
+
462
+ @Test
463
+ fun testDisplayFlex() {
464
+ val view = View(context)
465
+ view.visibility = View.GONE
466
+ StyleEngine.apply("display", "flex", view)
467
+ assertEquals(View.VISIBLE, view.visibility)
468
+ }
469
+
470
+ // -------------------------------------------------------------------------
471
+ // elevation
472
+ // -------------------------------------------------------------------------
473
+
474
+ @Test
475
+ fun testElevation() {
476
+ val view = View(context)
477
+ StyleEngine.apply("elevation", 4, view)
478
+
479
+ val expectedPx = StyleEngine.dpToPx(context, 4f)
480
+ assertEquals(expectedPx, view.elevation, 0.1f)
481
+ }
482
+ }
@@ -3,4 +3,5 @@ plugins {
3
3
  id("com.android.application") version "8.2.2" apply false
4
4
  id("com.android.library") version "8.2.2" apply false
5
5
  id("org.jetbrains.kotlin.android") version "1.9.22" apply false
6
+ id("org.jlleitschuh.gradle.ktlint") version "12.1.0" apply false
6
7
  }
@@ -0,0 +1,62 @@
1
+ # SwiftLint Configuration for VueNativeCore
2
+
3
+ included:
4
+ - VueNativeCore/Sources
5
+ - VueNativeCore/Tests
6
+
7
+ excluded:
8
+ - VueNativeCore/.build
9
+
10
+ # Rules
11
+ disabled_rules:
12
+ - trailing_whitespace
13
+ - line_length
14
+ - type_body_length
15
+ - file_length
16
+ - function_body_length
17
+ - cyclomatic_complexity
18
+ - force_cast
19
+ - force_try
20
+ - trailing_comma
21
+
22
+ opt_in_rules:
23
+ - closure_spacing
24
+ - contains_over_filter_count
25
+ - contains_over_first_not_nil
26
+ - discouraged_object_literal
27
+ - empty_string
28
+ - first_where
29
+ - modifier_order
30
+ - overridden_super_call
31
+ - redundant_nil_coalescing
32
+ - toggle_bool
33
+ - unavailable_function
34
+ - unneeded_parentheses_in_closure_argument
35
+
36
+ # Config
37
+ identifier_name:
38
+ min_length:
39
+ warning: 1
40
+ allowed_symbols:
41
+ - _
42
+ excluded:
43
+ - id
44
+ - x
45
+ - y
46
+ - w
47
+ - h
48
+ - i
49
+ - j
50
+ - k
51
+ - n
52
+ - vc
53
+
54
+ type_name:
55
+ min_length: 2
56
+ max_length: 60
57
+
58
+ nesting:
59
+ type_level: 3
60
+ function_level: 5
61
+
62
+ reporter: xcode
@@ -158,7 +158,10 @@ public final class NativeBridge {
158
158
  /// Only triggers a Yoga layout pass when the batch contains tree mutations
159
159
  /// (create, appendChild, insertBefore, removeChild, etc.). Batches that
160
160
  /// only update props/styles/events skip the expensive layout recalculation.
161
- private func processOperations(_ operations: [[String: Any]]) {
161
+ ///
162
+ /// Access: internal (not private) so that `@testable import` can exercise
163
+ /// operation handling without going through JSContext.
164
+ func processOperations(_ operations: [[String: Any]]) {
162
165
  dispatchPrecondition(condition: .onQueue(.main))
163
166
  NSLog("[VueNative Bridge] Processing %d operations", operations.count)
164
167