@nstudio/nativescript-compiler 9.2.0-alpha.16 → 9.2.0-alpha.18

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 (186) hide show
  1. package/README.md +3 -0
  2. package/dist/kit/kit-index.js +9 -0
  3. package/dist/kotlin/access.js +14 -15
  4. package/dist/kotlin/arguments.js +2 -2
  5. package/dist/kotlin/assignment.js +22 -13
  6. package/dist/kotlin/builtins.js +67 -0
  7. package/dist/kotlin/calls.js +3 -2
  8. package/dist/kotlin/class-declaration.js +16 -1
  9. package/dist/kotlin/class-methods.js +2 -2
  10. package/dist/kotlin/components.js +2 -7
  11. package/dist/kotlin/core-api.js +3 -22
  12. package/dist/kotlin/declarations.js +86 -9
  13. package/dist/kotlin/expression-statements.js +13 -1
  14. package/dist/kotlin/functions.js +2 -4
  15. package/dist/kotlin/global-calls.js +1 -4
  16. package/dist/kotlin/literals.js +3 -10
  17. package/dist/kotlin/names.js +6 -4
  18. package/dist/kotlin/native/api.js +1 -1
  19. package/dist/kotlin/native/classfiles.js +2 -13
  20. package/dist/kotlin/operators.js +36 -30
  21. package/dist/kotlin/optional-chains.js +3 -10
  22. package/dist/kotlin/overrides.js +5 -17
  23. package/dist/kotlin/placement.js +1 -12
  24. package/dist/kotlin/state-backend.js +6 -2
  25. package/dist/kotlin/statements.js +1 -13
  26. package/dist/kotlin/translator.js +3 -11
  27. package/dist/kotlin/type-tests.js +1 -1
  28. package/dist/kotlin/types.js +6 -23
  29. package/dist/program/core-facts.js +9 -0
  30. package/dist/semantics/classes.js +15 -0
  31. package/dist/semantics/facts.js +38 -2
  32. package/dist/semantics/lang.js +29 -0
  33. package/dist/semantics/lower.js +144 -0
  34. package/dist/semantics/lowering-methods.js +120 -3
  35. package/dist/semantics/marks.js +30 -0
  36. package/dist/semantics/placement.js +9 -3
  37. package/dist/semantics/refusals.js +12 -11
  38. package/dist/semantics/signals.js +11 -0
  39. package/dist/semantics/states/missing.js +7 -0
  40. package/dist/semantics/tdz.js +142 -8
  41. package/dist/semantics/throws.js +1 -1
  42. package/dist/semantics/translator-methods.js +1 -1
  43. package/dist/swift/access.js +13 -17
  44. package/dist/swift/assignment.js +30 -16
  45. package/dist/swift/calls.js +13 -5
  46. package/dist/swift/classes.js +22 -10
  47. package/dist/swift/components.js +3 -7
  48. package/dist/swift/control-flow.js +1 -1
  49. package/dist/swift/conversion.js +5 -2
  50. package/dist/swift/core-api.js +11 -31
  51. package/dist/swift/declarations.js +1 -6
  52. package/dist/swift/expression-statements.js +7 -0
  53. package/dist/swift/expressions.js +6 -2
  54. package/dist/swift/from-any.js +1 -1
  55. package/dist/swift/functions.js +5 -6
  56. package/dist/swift/global-calls.js +1 -5
  57. package/dist/swift/lenient.js +0 -7
  58. package/dist/swift/literals.js +8 -3
  59. package/dist/swift/method-values.js +1 -19
  60. package/dist/swift/modules.js +5 -3
  61. package/dist/swift/names.js +3 -12
  62. package/dist/swift/native/api.js +3 -1
  63. package/dist/swift/native/calls.js +1 -1
  64. package/dist/swift/native/dispatch.js +2 -8
  65. package/dist/swift/object-classes.js +84 -1
  66. package/dist/swift/operators.js +37 -34
  67. package/dist/swift/optional-chains.js +1 -8
  68. package/dist/swift/parameters.js +0 -4
  69. package/dist/swift/placement.js +5 -15
  70. package/dist/swift/results.js +0 -4
  71. package/dist/swift/state-backend.js +3 -2
  72. package/dist/swift/statements.js +1 -13
  73. package/dist/swift/static-calls.js +2 -3
  74. package/dist/swift/syntax.js +9 -5
  75. package/dist/swift/translator.js +1 -11
  76. package/dist/swift/type-facts.js +3 -3
  77. package/dist/swift/types.js +3 -3
  78. package/dist/targets/ios/build.js +1 -1
  79. package/dist/types/adapter-api.d.ts +3 -3
  80. package/kit-android/generated/kotlin/org/nativescript/kit/__Modules.kt +1 -0
  81. package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +525 -99
  82. package/kit-android/generated/kotlin/org/nativescript/kit/accessibility_accessibility_common.kt +2 -2
  83. package/kit-android/generated/kotlin/org/nativescript/kit/application_application_common.kt +29 -6
  84. package/kit-android/generated/kotlin/org/nativescript/kit/application_helpers_common.kt +14 -0
  85. package/kit-android/generated/kotlin/org/nativescript/kit/color_color_utils.kt +3 -3
  86. package/kit-android/generated/kotlin/org/nativescript/kit/css_mediaquery_index.kt +49 -1
  87. package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_array_index.kt +0 -8
  88. package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_index.kt +0 -16
  89. package/kit-android/generated/kotlin/org/nativescript/kit/data_virtual_array_index.kt +6 -4
  90. package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_index.kt +19 -7
  91. package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_http_request_internal_common.kt +14 -0
  92. package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_index.kt +19 -10
  93. package/kit-android/generated/kotlin/org/nativescript/kit/matrix_index.kt +17 -29
  94. package/kit-android/generated/kotlin/org/nativescript/kit/media_query_list_index.kt +144 -22
  95. package/kit-android/generated/kotlin/org/nativescript/kit/npm_css_what_src_parse.kt +8 -3
  96. package/kit-android/generated/kotlin/org/nativescript/kit/org.nativescript.NativeScriptLifecycleCallbacks.kt +2 -10
  97. package/kit-android/generated/kotlin/org/nativescript/kit/ui_builder_index.kt +0 -2
  98. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_bindable_expression_parser.kt +6 -10
  99. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_properties_index.kt +531 -8
  100. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_base_index.kt +0 -9
  101. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_weak_event_listener_index.kt +3 -3
  102. package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_index.kt +19 -0
  103. package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_properties.kt +5 -2
  104. package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_scope.kt +232 -174
  105. package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_view_text_view_common.kt +1 -1
  106. package/kit-android/generated/kotlin/org/nativescript/kit/utils_android_runtime_version.kt +75 -0
  107. package/kit-android/generated/manifest.json +21 -18
  108. package/kit-android/generated/source-lines.json +1 -1
  109. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Array.kt +547 -51
  110. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Intl.kt +1 -1
  111. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/JSON.kt +52 -6
  112. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Language.kt +33 -0
  113. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Prototypes.kt +9 -1
  114. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Strings.kt +32 -18
  115. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Values.kt +137 -28
  116. package/kit-apple/Overlays/xml-free/Core/ui.builder.index.swift +1 -1
  117. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +14 -10
  118. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +3 -9
  119. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity3Plus.swift +20 -21
  120. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_index_section_view_ios_android.swift +5 -7
  121. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_ios_android_.swift +130 -0
  122. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_oldIndex_newIndex.swift +2 -4
  123. package/kit-apple/Sources/NativeScriptKit/Core/Object_specified_substituted_reads.swift +115 -0
  124. package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads.swift +113 -0
  125. package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads_.swift +113 -0
  126. package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +348 -330
  127. package/kit-apple/Sources/NativeScriptKit/Core/application.application.ios.swift +358 -359
  128. package/kit-apple/Sources/NativeScriptKit/Core/application.helpers-common.swift +47 -29
  129. package/kit-apple/Sources/NativeScriptKit/Core/connectivity.index.ios.swift +3 -1
  130. package/kit-apple/Sources/NativeScriptKit/Core/css-mediaquery.index.swift +95 -53
  131. package/kit-apple/Sources/NativeScriptKit/Core/css.CSS3Parser.swift +1 -1
  132. package/kit-apple/Sources/NativeScriptKit/Core/css.parser.swift +1 -1
  133. package/kit-apple/Sources/NativeScriptKit/Core/data.observable-array.index.swift +2 -2
  134. package/kit-apple/Sources/NativeScriptKit/Core/file-system.file-system-access.ios.swift +52 -43
  135. package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.http-request-internal-common.swift +18 -0
  136. package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +66 -51
  137. package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +67 -51
  138. package/kit-apple/Sources/NativeScriptKit/Core/js-libs.easysax.easysax.swift +24 -6
  139. package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +143 -32
  140. package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +30 -19
  141. package/kit-apple/Sources/NativeScriptKit/Core/media-query-list.index.swift +190 -78
  142. package/kit-apple/Sources/NativeScriptKit/Core/native-window.native-window.ios.swift +1 -1
  143. package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.parse.swift +205 -201
  144. package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.stringify.swift +41 -42
  145. package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.types.swift +1 -1
  146. package/kit-apple/Sources/NativeScriptKit/Core/trace.index.swift +2 -2
  147. package/kit-apple/Sources/NativeScriptKit/Core/ui.animation.index.ios.swift +77 -65
  148. package/kit-apple/Sources/NativeScriptKit/Core/ui.builder.index.swift +4 -4
  149. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.properties.index.swift +1272 -824
  150. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view-base.index.swift +2 -2
  151. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +8 -8
  152. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -1
  153. package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.frame-common.swift +2 -1
  154. package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +6 -6
  155. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +22 -21
  156. package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +202 -188
  157. package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +2 -6
  158. package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +3 -3
  159. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +2 -2
  160. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.clip-path-function.swift +1 -1
  161. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-animation-parser.swift +1 -1
  162. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-selector.swift +2 -2
  163. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.font-common.swift +2 -2
  164. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style-scope.swift +869 -838
  165. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style.index.swift +46 -31
  166. package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.formatted-string.swift +1 -2
  167. package/kit-apple/Sources/NativeScriptKit/Core/ui.text-view.text-view-common.swift +1 -1
  168. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.index.ios.swift +2 -2
  169. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.modal-transition.ios.swift +4 -4
  170. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.page-transition.ios.swift +2 -2
  171. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.shared-transition-helper.ios.swift +17 -17
  172. package/kit-apple/Sources/NativeScriptKit/Core/utils.android-runtime-version.swift +77 -0
  173. package/kit-apple/Sources/NativeScriptKit/Core/utils.debug-source.swift +2 -2
  174. package/kit-apple/Sources/NativeScriptKit/Core/xhr.index.swift +62 -61
  175. package/kit-apple/Sources/NativeScriptKit/Runtime/Array.swift +4 -0
  176. package/kit-apple/Sources/NativeScriptKit/Runtime/Dynamic.swift +2 -0
  177. package/kit-apple/Sources/NativeScriptKit/Runtime/Interop.swift +1 -1
  178. package/kit-apple/Sources/NativeScriptKit/Runtime/Intl.swift +1 -1
  179. package/kit-apple/Sources/NativeScriptKit/Runtime/Iterators.swift +1 -1
  180. package/kit-apple/Sources/NativeScriptKit/Runtime/JSON.swift +413 -73
  181. package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +3 -2
  182. package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +14 -1
  183. package/kit-apple/Sources/NativeScriptKit/Runtime/Symbol.swift +1 -0
  184. package/kit-apple/Sources/NativeScriptKit/Runtime/Values.swift +1 -0
  185. package/kit-apple/Sources/NativeScriptKit/Runtime/Views.swift +2 -0
  186. package/package.json +2 -2
@@ -1411,7 +1411,15 @@ open class CssProperty : JSExpando, JSKeysMade {
1411
1411
  "enumerable" to true,
1412
1412
  "configurable" to true,
1413
1413
  "get" to JSMethod(0) { __self, _ -> get(__self) },
1414
- "set" to JSMethod(1) { __self, __a -> setLocalValue(__self, __a.getOrNull(0)) },
1414
+ "set" to
1415
+ Core_ui_core_properties_index.localCssExpressionSetter(
1416
+ kotlin.run {
1417
+ val __v_4 = jsConvertedStringOrNull(jsGet(options, "cssName"))
1418
+ if (jsTruthy(__v_4)) __v_4
1419
+ else ((propertyName ?: "undefined") ?: "undefined")
1420
+ },
1421
+ ::setLocalValue,
1422
+ ),
1415
1423
  )
1416
1424
  jsSet(Core_ui_core_properties_index.cssSymbolPropertyMap, key.key, this)
1417
1425
  }
@@ -1665,8 +1673,8 @@ open class CssAnimationProperty : JSExpando, JSKeysMade {
1665
1673
  val cssLocalName: String =
1666
1674
  jsConvertedStringOrEmpty(
1667
1675
  kotlin.run {
1668
- val __v_4 = jsConvertedStringOrNull(jsGet(options, "cssName"))
1669
- if (jsTruthy(__v_4)) __v_4 else ((propertyName ?: "undefined") ?: "undefined")
1676
+ val __v_5 = jsConvertedStringOrNull(jsGet(options, "cssName"))
1677
+ if (jsTruthy(__v_5)) __v_5 else ((propertyName ?: "undefined") ?: "undefined")
1670
1678
  }
1671
1679
  )
1672
1680
  this.cssLocalName = cssLocalName
@@ -1925,6 +1933,18 @@ open class CssAnimationProperty : JSExpando, JSKeysMade {
1925
1933
  descriptor(cssValue, ValueSource.Css, false, false, false)
1926
1934
  val stylePropertyDescriptor: Any? =
1927
1935
  descriptor(styleValue, ValueSource.Local, true, true, true)
1936
+ jsSet(
1937
+ stylePropertyDescriptor,
1938
+ "set",
1939
+ jsAs<(Style, Any?) -> Unit>(
1940
+ Core_ui_core_properties_index.localCssExpressionSetter(
1941
+ cssLocalName,
1942
+ jsFunction1<Any?, Unit>(jsGet(stylePropertyDescriptor, "set")).let { __f ->
1943
+ jsAdapt2<Any?, Any?, Unit>(__f) { __a0: Any?, __a1: Any? -> __f(__a0) }
1944
+ },
1945
+ )
1946
+ ),
1947
+ )
1928
1948
  val keyframePropertyDescriptor: Any? =
1929
1949
  descriptor(keyframeValue, ValueSource.Keyframe, false, false, false)
1930
1950
  jsSet(Core_ui_core_properties_index.symbolPropertyMap, computedValue.key, this)
@@ -2455,7 +2475,20 @@ open class InheritedCssProperty : CssProperty {
2455
2475
  setInheritedFunc = jsCall(setFunc, ValueSource.Inherited)
2456
2476
  this.setInheritedValue = setInheritedFunc
2457
2477
  jsSet(this.cssValueDescriptor, "set", jsCall(setFunc, ValueSource.Css))
2458
- jsSet(this.localValueDescriptor, "set", jsCall(setFunc, ValueSource.Local))
2478
+ jsSet(
2479
+ this.localValueDescriptor,
2480
+ "set",
2481
+ Core_ui_core_properties_index.localCssExpressionSetter(
2482
+ kotlin.run {
2483
+ val __v_8 = jsConvertedStringOrNull(jsGet(options, "cssName"))
2484
+ if (jsTruthy(__v_8)) __v_8 else ((propertyName ?: "undefined") ?: "undefined")
2485
+ },
2486
+ kotlin.run {
2487
+ val __f = jsCall(setFunc, ValueSource.Local)
2488
+ jsAs<(Any?, Any?) -> Unit>(jsThisFunction(__f, 2))
2489
+ },
2490
+ ),
2491
+ )
2459
2492
  Core_ui_core_properties_index.inheritableCssProperties.push(this)
2460
2493
  }
2461
2494
 
@@ -2548,7 +2581,9 @@ open class ShorthandProperty : JSExpando, JSKeysMade {
2548
2581
  jsUnlessNullish(jsGet(options, "converter")) {
2549
2582
  jsFunction1<Any?, JSArray<Pair<Any?, Any?>>>(it)
2550
2583
  }
2584
+ val cssLocalName: String? = this.cssLocalName
2551
2585
  fun setLocalValue(__this: Any?, value: Any?) {
2586
+ var value: Any? = value
2552
2587
  val view: ViewBase? =
2553
2588
  jsUnchecked<JSWeakRef<ViewBase>>(jsJavaArgument(jsGet(__this, "viewRef"))).get()
2554
2589
  if (!jsTruthy(view)) {
@@ -2559,13 +2594,67 @@ open class ShorthandProperty : JSExpando, JSKeysMade {
2559
2594
  )
2560
2595
  return
2561
2596
  }
2597
+ val pendingLonghands: JSArray<Pair<String, CssPendingSubstitution>>? =
2598
+ (if (Core_ui_core_properties_index.hasCssExpression(value))
2599
+ Core_ui_core_properties_index._pendingCssShorthandSubstitution(
2600
+ cssLocalName,
2601
+ jsConvertedString(value),
2602
+ )
2603
+ else null)
2604
+ if (jsTruthy(pendingLonghands)) {
2605
+ val pending: CssPendingSubstitution? =
2606
+ ((pendingLonghands ?: jsCannotRead("0")).element(0.0) ?: jsCannotRead("1"))
2607
+ .second
2608
+ val shorthand: Any? =
2609
+ Core_ui_core_properties_index._substituteCssShorthand(view, pending)
2610
+ (view ?: jsCannotRead("_batchUpdate"))._batchUpdate({
2611
+ for (__item1 in (pendingLonghands ?: jsObjectRequired())) {
2612
+ val longhand: String? = __item1.first
2613
+ Core_ui_core_properties_index._setLocalCssShorthandValue(
2614
+ jsCast(__this, Style::class.java),
2615
+ longhand,
2616
+ pending,
2617
+ shorthand,
2618
+ )
2619
+ }
2620
+ })
2621
+ return
2622
+ }
2623
+ if (Core_ui_core_properties_index.hasCssExpression(value)) {
2624
+ value =
2625
+ Core_ui_core_properties_index._evaluateCssExpressions(
2626
+ view,
2627
+ cssLocalName,
2628
+ jsConvertedString(value),
2629
+ )
2630
+ }
2562
2631
  (view ?: jsCannotRead("_batchUpdate"))._batchUpdate({
2563
- for (__item1 in (converter ?: jsNotAFunction("converter"))(value)) {
2564
- val p: Any? = __item1.first
2565
- val v: Any? = __item1.second
2632
+ for (__item2 in (converter ?: jsNotAFunction("converter"))(value)) {
2633
+ val p: Any? = __item2.first
2634
+ val v: Any? = __item2.second
2566
2635
  jsSet(__this, jsPropertyKey(jsGet(p, "name")), v)
2567
2636
  }
2568
2637
  })
2638
+ if (
2639
+ jsTruthy(
2640
+ jsAs<JSMap<String, Any?>?>(
2641
+ jsJavaArgument(jsGet(__this, "_localCssExpressions"))
2642
+ )
2643
+ )
2644
+ ) {
2645
+ val longhands: JSArray<String>? =
2646
+ Core_ui_core_properties_index.getCssShorthandLonghands(cssLocalName)
2647
+ var i: Double = 0.0
2648
+ val length: Double =
2649
+ (if (jsTruthy(longhands)) (longhands ?: jsCannotRead("length")).length else 0.0)
2650
+ while (i < length) {
2651
+ Core_ui_core_properties_index.releaseLocalCssExpression(
2652
+ jsCast(__this, Style::class.java),
2653
+ (longhands ?: jsCannotRead(js(i))).element(i),
2654
+ )
2655
+ i += 1.0
2656
+ }
2657
+ }
2569
2658
  }
2570
2659
  fun setCssValue(__this: Any?, value: String?) {
2571
2660
  val view: ViewBase? =
@@ -2953,7 +3042,17 @@ object Core_ui_core_properties_index {
2953
3042
  return jsIncludes((value ?: jsCannotRead("includes")), "var(--")
2954
3043
  }
2955
3044
 
2956
- fun _evaluateCssVariableExpression(view: ViewBase?, cssName: String?, value: String?): String {
3045
+ /**
3046
+ * Substitute the css-variables in a value.
3047
+ *
3048
+ * @param reads Collects every variable looked up, with the value the lookup returned.
3049
+ */
3050
+ fun _evaluateCssVariableExpression(
3051
+ view: ViewBase?,
3052
+ cssName: String?,
3053
+ value: String?,
3054
+ reads: JSMap<String, String>? = null,
3055
+ ): String {
2957
3056
  if (jsTypeof(value) != "string") {
2958
3057
  return jsConvertedStringOrEmpty(value)
2959
3058
  }
@@ -2982,6 +3081,12 @@ object Core_ui_core_properties_index {
2982
3081
  var cssVariableValue: String? =
2983
3082
  ((view ?: jsCannotRead("style")).style ?: jsCannotRead("getCssVariable"))
2984
3083
  .getCssVariable(cssVariableName)
3084
+ if (jsTruthy(reads)) {
3085
+ (reads ?: jsCannotRead("set")).set(
3086
+ cssVariableName,
3087
+ (cssVariableValue ?: "undefined"),
3088
+ )
3089
+ }
2985
3090
  if (
2986
3091
  jsTypeof(cssVariableValue) == "string" &&
2987
3092
  jsTrim((cssVariableValue ?: "undefined")) == "initial"
@@ -2994,6 +3099,7 @@ object Core_ui_core_properties_index {
2994
3099
  view,
2995
3100
  cssName,
2996
3101
  fallback,
3102
+ reads,
2997
3103
  )
2998
3104
  }
2999
3105
  if (cssVariableValue.isNullOrEmpty() || cssVariableValue == "unset") {
@@ -3073,6 +3179,422 @@ object Core_ui_core_properties_index {
3073
3179
  return (cssValue ?: "undefined")
3074
3180
  }
3075
3181
 
3182
+ fun hasCssExpression(value: Any?): Boolean {
3183
+ return jsTypeof(value) == "string" &&
3184
+ (Core_ui_core_properties_index.isCssVariableExpression(
3185
+ jsConvertedStringOrNull(value)
3186
+ ) || Core_ui_core_properties_index.isCssCalcExpression(jsConvertedStringOrNull(value)))
3187
+ }
3188
+
3189
+ /**
3190
+ * Evaluate the css-variable and css-calc expressions of a value against the view, or
3191
+ * `unsetValue` when they do not resolve.
3192
+ */
3193
+ fun _evaluateCssExpressions(
3194
+ view: ViewBase?,
3195
+ property: String?,
3196
+ value: String?,
3197
+ reads: JSMap<String, String>? = null,
3198
+ ): Any? {
3199
+ val newValue: String =
3200
+ Core_ui_core_properties_index._evaluateCssVariableExpression(
3201
+ view,
3202
+ property,
3203
+ value,
3204
+ reads,
3205
+ )
3206
+ if (newValue == "unset") {
3207
+ return Core_ui_core_properties_property_shared.unsetValue
3208
+ }
3209
+ try {
3210
+ return Core_ui_core_properties_index._evaluateCssCalcExpression(newValue)
3211
+ } catch (__e_1: Throwable) {
3212
+ val e: Any? = jsCaught(__e_1)
3213
+ org.nativescript.kit.Trace.write(
3214
+ "Failed to evaluate css-calc for property [${jsToString((property ?: "undefined"))}] for expression [${newValue}] to ${jsToStringThrowing(view)}. ${jsToStringThrowing(jsGet(e, "stack"))}",
3215
+ org.nativescript.kit.Trace.categories.Error,
3216
+ org.nativescript.kit.Trace.messageType.error,
3217
+ )
3218
+ return Core_ui_core_properties_property_shared.unsetValue
3219
+ }
3220
+ }
3221
+
3222
+ @JvmField var NO_LONGHAND_VALUES: JSRecord<Any?>? = null
3223
+
3224
+ fun expandSubstitutedShorthand(
3225
+ view: ViewBase?,
3226
+ shorthand: String?,
3227
+ substituted: Any?,
3228
+ ): JSRecord<Any?>? {
3229
+ if (
3230
+ jsStrictEquals(substituted, Core_ui_core_properties_property_shared.unsetValue)
3231
+ ) {
3232
+ return Core_ui_core_properties_index.NO_LONGHAND_VALUES
3233
+ }
3234
+ val expanded: JSArray<Pair<String, Any?>>? =
3235
+ Core_ui_core_properties_index._expandCssShorthand(
3236
+ shorthand,
3237
+ jsConvertedString(substituted),
3238
+ )
3239
+ if (!jsTruthy(expanded)) {
3240
+ org.nativescript.kit.Trace.write(
3241
+ "Failed to expand shorthand [${jsToString((shorthand ?: "undefined"))}] resolved to [${jsToStringThrowing(substituted)}] for ${jsToStringThrowing(view)}.",
3242
+ org.nativescript.kit.Trace.categories.Style,
3243
+ org.nativescript.kit.Trace.messageType.warn,
3244
+ )
3245
+ return Core_ui_core_properties_index.NO_LONGHAND_VALUES
3246
+ }
3247
+ val values: JSRecord<Any?> =
3248
+ (jsAsOrNull<JSRecord<Any?>>(JSRecord<Any?>()) ?: JSRecord<Any?>())
3249
+ var i: Double = 0.0
3250
+ val length: Double = (expanded ?: jsCannotRead("length")).length
3251
+ while (i < length) {
3252
+ values[
3253
+ ((expanded ?: jsCannotRead(js(i))).element(i) ?: jsCannotRead("0")).first] =
3254
+ ((expanded ?: jsCannotRead(js(i))).element(i) ?: jsCannotRead("1")).second
3255
+ i += 1.0
3256
+ }
3257
+ return values
3258
+ }
3259
+
3260
+ fun cssVariablesUnchanged(view: ViewBase?, reads: Any?): Boolean {
3261
+ kotlin.run {
3262
+ val __it1 = jsIteratorOf(reads)
3263
+ try {
3264
+ while (__it1.jsAdvance()) {
3265
+ val name: String? = jsConvertedStringOrEmpty(jsField(__it1.jsCurrent, "0"))
3266
+ val value: String? = jsConvertedStringOrEmpty(jsField(__it1.jsCurrent, "1"))
3267
+ kotlin.run {
3268
+ if (
3269
+ ((view ?: jsCannotRead("style")).style
3270
+ ?: jsCannotRead("getCssVariable"))
3271
+ .getCssVariable(name) != value
3272
+ ) {
3273
+ return false
3274
+ }
3275
+ }
3276
+ }
3277
+ } catch (__thrown: Throwable) {
3278
+ __it1.jsClose()
3279
+ throw __thrown
3280
+ } finally {
3281
+ __it1.jsCloseChecked()
3282
+ }
3283
+ }
3284
+ return true
3285
+ }
3286
+
3287
+ /**
3288
+ * Evaluate a pending-substitution shorthand against the view and parse it; a value that does
3289
+ * not survive evaluation expands to no longhands.
3290
+ */
3291
+ fun _substituteCssShorthand(view: ViewBase?, pending: CssPendingSubstitution?): Any? {
3292
+ val reads: Any? = JSMap<Any?, Any?>()
3293
+ val substituted: Any? =
3294
+ Core_ui_core_properties_index._evaluateCssExpressions(
3295
+ view,
3296
+ (pending ?: jsCannotRead("shorthand")).shorthand,
3297
+ (pending ?: jsCannotRead("value")).value,
3298
+ jsAs<JSMap<String, String>?>(jsJavaArgument(reads)),
3299
+ )
3300
+ return jsObjectOf(
3301
+ "substituted" to substituted,
3302
+ "values" to
3303
+ Core_ui_core_properties_index.expandSubstitutedShorthand(
3304
+ view,
3305
+ (pending ?: jsCannotRead("shorthand")).shorthand,
3306
+ substituted,
3307
+ ),
3308
+ "reads" to reads,
3309
+ )
3310
+ }
3311
+
3312
+ fun keepLocalCssExpression(
3313
+ style: Style?,
3314
+ cssName: String?,
3315
+ specified: Any?,
3316
+ substituted: Any?,
3317
+ reads: Any?,
3318
+ ) {
3319
+ if (
3320
+ !jsTruthy((style ?: jsCannotRead("_localCssExpressions"))._localCssExpressions)
3321
+ ) {
3322
+ (style ?: jsCannotSet("_localCssExpressions"))._localCssExpressions =
3323
+ JSMap<String, Any?>()
3324
+ }
3325
+ ((style ?: jsCannotRead("_localCssExpressions"))._localCssExpressions
3326
+ ?: jsCannotRead("set"))
3327
+ .set(
3328
+ (cssName ?: "undefined"),
3329
+ jsObjectOf("specified" to specified, "substituted" to substituted, "reads" to reads),
3330
+ )
3331
+ }
3332
+
3333
+ fun releaseLocalCssExpression(style: Style?, cssName: String?) {
3334
+ val expressions: JSMap<String, Any?>? =
3335
+ (style ?: jsCannotRead("_localCssExpressions"))._localCssExpressions
3336
+ if (
3337
+ (jsTruthy(expressions) &&
3338
+ (expressions ?: jsCannotRead("delete")).delete((cssName ?: "undefined"))) &&
3339
+ (expressions ?: jsCannotRead("size")).size == 0.0
3340
+ ) {
3341
+ (style ?: jsCannotSet("_localCssExpressions"))._localCssExpressions = null
3342
+ }
3343
+ }
3344
+
3345
+ /**
3346
+ * Wrap a local setter: a string holding var()/calc() is written substituted and kept for the
3347
+ * cascade to substitute again, any other write releases what was kept.
3348
+ */
3349
+ fun localCssExpressionSetter(
3350
+ cssName: String?,
3351
+ set: (Any?, Any?) -> Unit,
3352
+ ): (Any?, Any?) -> Unit {
3353
+ return fn1@{ __this: Any?, value: Any? ->
3354
+ if (Core_ui_core_properties_index.hasCssExpression(value)) {
3355
+ val view: ViewBase? =
3356
+ jsUnchecked<JSWeakRef<ViewBase>>(jsJavaArgument(jsGet(__this, "viewRef"))).get()
3357
+ if (jsTruthy(view)) {
3358
+ val reads: Any? = JSMap<Any?, Any?>()
3359
+ val substituted: Any? =
3360
+ Core_ui_core_properties_index._evaluateCssExpressions(
3361
+ view,
3362
+ cssName,
3363
+ jsConvertedStringOrNull(value),
3364
+ jsAs<JSMap<String, String>?>(jsJavaArgument(reads)),
3365
+ )
3366
+ set(__this, substituted)
3367
+ Core_ui_core_properties_index.keepLocalCssExpression(
3368
+ jsCast(__this, Style::class.java),
3369
+ cssName,
3370
+ value,
3371
+ substituted,
3372
+ reads,
3373
+ )
3374
+ return@fn1
3375
+ }
3376
+ }
3377
+ set(__this, value)
3378
+ Core_ui_core_properties_index.releaseLocalCssExpression(
3379
+ jsCast(__this, Style::class.java),
3380
+ cssName,
3381
+ )
3382
+ }
3383
+ }
3384
+
3385
+ fun setLocalCssExpression(
3386
+ style: Style?,
3387
+ cssName: String?,
3388
+ specified: Any?,
3389
+ substituted: Any?,
3390
+ reads: Any?,
3391
+ value: Any?,
3392
+ ) {
3393
+ jsSet(
3394
+ (style ?: jsObjectRequired()),
3395
+ jsToString((cssName ?: "undefined")),
3396
+ value,
3397
+ )
3398
+ Core_ui_core_properties_index.keepLocalCssExpression(
3399
+ style,
3400
+ cssName,
3401
+ specified,
3402
+ substituted,
3403
+ reads,
3404
+ )
3405
+ }
3406
+
3407
+ /**
3408
+ * Write a longhand's share of a pending-substitution shorthand as a local value, kept for the
3409
+ * cascade to substitute again.
3410
+ */
3411
+ fun _setLocalCssShorthandValue(
3412
+ style: Style?,
3413
+ longhand: String?,
3414
+ pending: CssPendingSubstitution?,
3415
+ shorthand: Any?,
3416
+ ) {
3417
+ Core_ui_core_properties_index.setLocalCssExpression(
3418
+ style,
3419
+ longhand,
3420
+ pending,
3421
+ jsGet(shorthand, "substituted"),
3422
+ jsGet(shorthand, "reads"),
3423
+ (if (jsHasKey(jsGet(shorthand, "values"), jsToString((longhand ?: "undefined"))))
3424
+ (jsAsOrNull<JSRecord<Any?>>(jsGet(shorthand, "values")) ?: JSRecord<Any?>())[
3425
+ jsToString((longhand ?: "undefined"))]
3426
+ else Core_ui_core_properties_property_shared.unsetValue),
3427
+ )
3428
+ }
3429
+
3430
+ /**
3431
+ * Substitute the kept local var()/calc() values again, writing only those whose substitution
3432
+ * changed since they were last written.
3433
+ */
3434
+ fun _reevaluateLocalCssExpressions(view: ViewBase?) {
3435
+ val style: Style? = (view ?: jsCannotRead("style")).style
3436
+ val expressions: JSMap<String, Any?>? =
3437
+ (style ?: jsCannotRead("_localCssExpressions"))._localCssExpressions
3438
+ if (!jsTruthy(expressions)) {
3439
+ return
3440
+ }
3441
+ var shorthands: JSMap<CssPendingSubstitution, Any?>? = null
3442
+ val entries: JSArray<Pair<String, Any?>>? =
3443
+ JSArray((expressions ?: jsObjectRequired()).entries().toList())
3444
+ var i: Double = 0.0
3445
+ val length: Double = (entries ?: jsCannotRead("length")).length
3446
+ var __first1 = true
3447
+ while (true) {
3448
+ if (!__first1) {
3449
+ i += 1.0
3450
+ }
3451
+ __first1 = false
3452
+ if (!(i < length)) break
3453
+ kotlin.run {
3454
+ val __d_1: Pair<String, Any?> =
3455
+ ((entries ?: jsCannotRead(js(i))).element(i) ?: jsObjectRequired())
3456
+ val cssName: String? = __d_1.first
3457
+ val expression: Any? = __d_1.second
3458
+ if (
3459
+ !jsStrictEquals(
3460
+ (style ?: jsCannotRead("_localCssExpressions"))
3461
+ ._localCssExpressions
3462
+ ?.get((cssName ?: "undefined")),
3463
+ expression,
3464
+ ) ||
3465
+ Core_ui_core_properties_index.cssVariablesUnchanged(
3466
+ view,
3467
+ jsGet(expression, "reads"),
3468
+ )
3469
+ ) {
3470
+ continue
3471
+ }
3472
+ val specified: Any? = jsGet(expression, "specified")
3473
+ val substituted: Any?
3474
+ var reads: Any?
3475
+ val value: Any?
3476
+ if ((specified is CssPendingSubstitution)) {
3477
+ if (!jsTruthy(shorthands)) {
3478
+ shorthands = JSMap<CssPendingSubstitution, Any?>()
3479
+ }
3480
+ var shorthand: Any? =
3481
+ (shorthands ?: jsCannotRead("get")).get(
3482
+ jsUnchecked<CssPendingSubstitution>(
3483
+ jsCastCarried(specified, CssPendingSubstitution::class.java)
3484
+ )
3485
+ )
3486
+ if (!jsTruthy(shorthand)) {
3487
+ reads = JSMap<Any?, Any?>()
3488
+ shorthand =
3489
+ jsObjectOf(
3490
+ "substituted" to
3491
+ Core_ui_core_properties_index._evaluateCssExpressions(
3492
+ view,
3493
+ jsCastCarried(specified, CssPendingSubstitution::class.java)
3494
+ .shorthand,
3495
+ jsCastCarried(specified, CssPendingSubstitution::class.java)
3496
+ .value,
3497
+ jsAs<JSMap<String, String>?>(jsJavaArgument(reads)),
3498
+ ),
3499
+ "values" to null,
3500
+ "reads" to reads,
3501
+ )
3502
+ (shorthands ?: jsCannotRead("set")).set(
3503
+ jsUnchecked<CssPendingSubstitution>(
3504
+ jsCastCarried(specified, CssPendingSubstitution::class.java)
3505
+ ),
3506
+ shorthand,
3507
+ )
3508
+ }
3509
+ substituted = jsGet(shorthand, "substituted")
3510
+ reads = jsGet(shorthand, "reads")
3511
+ if (
3512
+ jsStrictEquals(substituted, jsGet(expression, "substituted"))
3513
+ ) {
3514
+ jsSet(expression, "reads", reads)
3515
+ continue
3516
+ }
3517
+ if (!jsTruthy(jsRecordOrNull<Any?>(jsGet(shorthand, "values")))) {
3518
+ jsSet(
3519
+ shorthand,
3520
+ "values",
3521
+ Core_ui_core_properties_index.expandSubstitutedShorthand(
3522
+ view,
3523
+ jsCastCarried(specified, CssPendingSubstitution::class.java)
3524
+ .shorthand,
3525
+ substituted,
3526
+ ),
3527
+ )
3528
+ }
3529
+ value =
3530
+ (if (
3531
+ jsHasKey(
3532
+ jsGet(shorthand, "values"),
3533
+ jsToString((cssName ?: "undefined")),
3534
+ )
3535
+ )
3536
+ (jsAsOrNull<JSRecord<Any?>>(jsGet(shorthand, "values"))
3537
+ ?: JSRecord<Any?>())[jsToString((cssName ?: "undefined"))]
3538
+ else Core_ui_core_properties_property_shared.unsetValue)
3539
+ } else {
3540
+ reads = JSMap<Any?, Any?>()
3541
+ substituted =
3542
+ Core_ui_core_properties_index._evaluateCssExpressions(
3543
+ view,
3544
+ cssName,
3545
+ jsConvertedString(specified),
3546
+ jsAs<JSMap<String, String>?>(jsJavaArgument(reads)),
3547
+ )
3548
+ if (
3549
+ jsStrictEquals(substituted, jsGet(expression, "substituted"))
3550
+ ) {
3551
+ jsSet(expression, "reads", reads)
3552
+ continue
3553
+ }
3554
+ value = substituted
3555
+ }
3556
+ try {
3557
+ Core_ui_core_properties_index.setLocalCssExpression(
3558
+ style,
3559
+ cssName,
3560
+ specified,
3561
+ substituted,
3562
+ reads,
3563
+ value,
3564
+ )
3565
+ } catch (__e_1: Throwable) {
3566
+ val e: Any? = jsCaught(__e_1)
3567
+ org.nativescript.kit.Trace.write(
3568
+ "Failed to apply property [${jsToString((cssName ?: "undefined"))}] with value [${jsToStringThrowing(value)}] to ${jsToStringThrowing(view)}. ${jsToStringThrowing(jsGet(e, "stack"))}",
3569
+ org.nativescript.kit.Trace.categories.Error,
3570
+ org.nativescript.kit.Trace.messageType.error,
3571
+ )
3572
+ try {
3573
+ jsSet(
3574
+ (style ?: jsObjectRequired()),
3575
+ jsToString((cssName ?: "undefined")),
3576
+ Core_ui_core_properties_property_shared.unsetValue,
3577
+ )
3578
+ } catch (__e_2: Throwable) {
3579
+ val e: Any? = jsCaught(__e_2)
3580
+ org.nativescript.kit.Trace.write(
3581
+ "Failed to unset property [${jsToString((cssName ?: "undefined"))}] on ${jsToStringThrowing(view)}. ${jsToStringThrowing(jsGet(e, "stack"))}",
3582
+ org.nativescript.kit.Trace.categories.Error,
3583
+ org.nativescript.kit.Trace.messageType.error,
3584
+ )
3585
+ }
3586
+ Core_ui_core_properties_index.keepLocalCssExpression(
3587
+ style,
3588
+ cssName,
3589
+ specified,
3590
+ substituted,
3591
+ reads,
3592
+ )
3593
+ }
3594
+ }
3595
+ }
3596
+ }
3597
+
3076
3598
  fun getPropertiesFromMap(map: Any?): Any? {
3077
3599
  val symbols: JSArray<JSSymbol>? = jsOwnPropertySymbols(map)
3078
3600
  val len: Double = (symbols ?: jsCannotRead("length")).length
@@ -3554,6 +4076,7 @@ object Core_ui_core_properties_index {
3554
4076
  inheritableProperties = JSArray<InheritedProperty>()
3555
4077
  inheritableCssProperties = JSArray<InheritedCssProperty>()
3556
4078
  cssValueSourceKeys = jsRecordOrNull<JSSymbol>(jsObjectCreate(jsNull))
4079
+ NO_LONGHAND_VALUES = jsRecordOrNull<Any?>(jsFreeze(jsObjectOf()))
3557
4080
  initNativeView =
3558
4081
  Core_profiling_index.profile(
3559
4082
  "\"properties\".initNativeView",
@@ -2341,10 +2341,6 @@ abstract class ViewBase : Observable, JSStringConvertible {
2341
2341
  "page" -> this.page
2342
2342
  "visualState" -> this.visualState
2343
2343
  "getEffectivePaddingShorthand" -> jsFunction { this.getEffectivePaddingShorthand() }
2344
- "getViewById" ->
2345
- jsFunction { __a -> this.getViewById(jsConvertedStringOrNull(__a.getOrNull(0))) }
2346
- "getViewByDomId" ->
2347
- jsFunction { __a -> this.getViewByDomId(jsConvertedNumberOrZero(__a.getOrNull(0))) }
2348
2344
  "ensureDomNode" ->
2349
2345
  jsFunction {
2350
2346
  this.ensureDomNode()
@@ -2385,8 +2381,6 @@ abstract class ViewBase : Observable, JSStringConvertible {
2385
2381
  this._resumeNativeUpdates(jsConvertedNumberOrZero(__a.getOrNull(0)))
2386
2382
  null
2387
2383
  }
2388
- "_batchUpdate" ->
2389
- jsFunction { __a -> this._batchUpdate(jsFunction0<Any?>(__a.getOrNull(0))) }
2390
2384
  "setFlag" ->
2391
2385
  jsFunction { __a ->
2392
2386
  this.setFlag(
@@ -2820,8 +2814,6 @@ abstract class ViewBase : Observable, JSStringConvertible {
2820
2814
  "page",
2821
2815
  "visualState",
2822
2816
  "getEffectivePaddingShorthand",
2823
- "getViewById",
2824
- "getViewByDomId",
2825
2817
  "ensureDomNode",
2826
2818
  "set",
2827
2819
  "onLoaded",
@@ -2830,7 +2822,6 @@ abstract class ViewBase : Observable, JSStringConvertible {
2830
2822
  "_setDefaultPaddings",
2831
2823
  "_suspendNativeUpdates",
2832
2824
  "_resumeNativeUpdates",
2833
- "_batchUpdate",
2834
2825
  "setFlag",
2835
2826
  "isFlagSet",
2836
2827
  "callFunctionWithSuper",
@@ -215,7 +215,7 @@ object Core_ui_core_weak_event_listener_index {
215
215
  if (!jsTruthy(targetHandlerPairList)) {
216
216
  return
217
217
  }
218
- val targetHandlerPairsToRemove: JSArray<Double> = JSArray<Double>()
218
+ val targetHandlerPairsToRemove: JSArray<Double> = JSArray.doubles()
219
219
  var pair: TargetHandlerPair?
220
220
  var registeredTarget: Any?
221
221
  var i: Double = 0.0
@@ -228,7 +228,7 @@ object Core_ui_core_weak_event_listener_index {
228
228
  (jsStrictEquals(registeredTarget, target) &&
229
229
  jsStrictEquals(handler, (pair ?: jsCannotRead("handler")).handler))
230
230
  ) {
231
- targetHandlerPairsToRemove.push(i)
231
+ targetHandlerPairsToRemove.pushDouble(i)
232
232
  }
233
233
  i += 1.0
234
234
  }
@@ -247,7 +247,7 @@ object Core_ui_core_weak_event_listener_index {
247
247
  var j: Double = targetHandlerPairsToRemove.length - 1.0
248
248
  while (j >= 0.0) {
249
249
  (targetHandlerPairList ?: jsCannotRead("splice")).splice(
250
- (targetHandlerPairsToRemove.element(j) ?: Double.NaN),
250
+ targetHandlerPairsToRemove.numberAt(j),
251
251
  1.0,
252
252
  )
253
253
  j -= 1.0