@nstudio/nativescript-compiler 9.2.0-alpha.17 → 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 (162) hide show
  1. package/README.md +3 -0
  2. package/dist/kotlin/access.js +8 -7
  3. package/dist/kotlin/assignment.js +22 -13
  4. package/dist/kotlin/builtins.js +67 -0
  5. package/dist/kotlin/calls.js +3 -2
  6. package/dist/kotlin/class-declaration.js +4 -9
  7. package/dist/kotlin/class-methods.js +2 -2
  8. package/dist/kotlin/core-api.js +1 -1
  9. package/dist/kotlin/declarations.js +1 -1
  10. package/dist/kotlin/expression-statements.js +13 -1
  11. package/dist/kotlin/functions.js +1 -0
  12. package/dist/kotlin/literals.js +4 -8
  13. package/dist/kotlin/names.js +4 -4
  14. package/dist/kotlin/native/api.js +1 -1
  15. package/dist/kotlin/operators.js +25 -25
  16. package/dist/kotlin/optional-chains.js +1 -1
  17. package/dist/kotlin/overrides.js +2 -2
  18. package/dist/kotlin/state-backend.js +6 -2
  19. package/dist/kotlin/translator.js +1 -1
  20. package/dist/kotlin/types.js +4 -4
  21. package/dist/semantics/classes.js +15 -0
  22. package/dist/semantics/facts.js +1 -1
  23. package/dist/semantics/lang.js +10 -0
  24. package/dist/semantics/lower.js +54 -0
  25. package/dist/semantics/lowering-methods.js +5 -0
  26. package/dist/semantics/placement.js +9 -3
  27. package/dist/semantics/signals.js +11 -0
  28. package/dist/semantics/states/missing.js +7 -0
  29. package/dist/semantics/tdz.js +54 -15
  30. package/dist/semantics/throws.js +1 -1
  31. package/dist/semantics/translator-methods.js +1 -1
  32. package/dist/swift/access.js +7 -9
  33. package/dist/swift/assignment.js +20 -14
  34. package/dist/swift/calls.js +6 -3
  35. package/dist/swift/classes.js +7 -9
  36. package/dist/swift/components.js +3 -3
  37. package/dist/swift/control-flow.js +1 -1
  38. package/dist/swift/conversion.js +5 -2
  39. package/dist/swift/core-api.js +2 -2
  40. package/dist/swift/declarations.js +1 -1
  41. package/dist/swift/expressions.js +6 -2
  42. package/dist/swift/from-any.js +1 -1
  43. package/dist/swift/functions.js +5 -6
  44. package/dist/swift/global-calls.js +1 -1
  45. package/dist/swift/lenient.js +1 -6
  46. package/dist/swift/literals.js +8 -3
  47. package/dist/swift/modules.js +3 -3
  48. package/dist/swift/names.js +3 -3
  49. package/dist/swift/native/calls.js +1 -1
  50. package/dist/swift/object-classes.js +84 -1
  51. package/dist/swift/operators.js +31 -29
  52. package/dist/swift/placement.js +4 -3
  53. package/dist/swift/state-backend.js +3 -2
  54. package/dist/swift/static-calls.js +2 -3
  55. package/dist/swift/syntax.js +9 -5
  56. package/dist/swift/translator.js +1 -1
  57. package/dist/swift/type-facts.js +3 -3
  58. package/dist/swift/types.js +3 -3
  59. package/dist/targets/ios/build.js +1 -1
  60. package/kit-android/generated/kotlin/org/nativescript/kit/__Modules.kt +1 -0
  61. package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +525 -99
  62. package/kit-android/generated/kotlin/org/nativescript/kit/accessibility_accessibility_common.kt +2 -2
  63. package/kit-android/generated/kotlin/org/nativescript/kit/application_application_common.kt +29 -6
  64. package/kit-android/generated/kotlin/org/nativescript/kit/application_helpers_common.kt +14 -0
  65. package/kit-android/generated/kotlin/org/nativescript/kit/color_color_utils.kt +3 -3
  66. package/kit-android/generated/kotlin/org/nativescript/kit/css_mediaquery_index.kt +49 -1
  67. package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_array_index.kt +0 -8
  68. package/kit-android/generated/kotlin/org/nativescript/kit/data_observable_index.kt +0 -16
  69. package/kit-android/generated/kotlin/org/nativescript/kit/data_virtual_array_index.kt +6 -4
  70. package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_index.kt +19 -7
  71. package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_http_request_internal_common.kt +14 -0
  72. package/kit-android/generated/kotlin/org/nativescript/kit/http_http_request_internal_index.kt +19 -10
  73. package/kit-android/generated/kotlin/org/nativescript/kit/matrix_index.kt +17 -29
  74. package/kit-android/generated/kotlin/org/nativescript/kit/media_query_list_index.kt +144 -22
  75. package/kit-android/generated/kotlin/org/nativescript/kit/npm_css_what_src_parse.kt +8 -3
  76. package/kit-android/generated/kotlin/org/nativescript/kit/org.nativescript.NativeScriptLifecycleCallbacks.kt +2 -10
  77. package/kit-android/generated/kotlin/org/nativescript/kit/ui_builder_index.kt +0 -2
  78. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_bindable_expression_parser.kt +6 -10
  79. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_properties_index.kt +531 -8
  80. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_base_index.kt +0 -9
  81. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_weak_event_listener_index.kt +3 -3
  82. package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_index.kt +19 -0
  83. package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_properties.kt +5 -2
  84. package/kit-android/generated/kotlin/org/nativescript/kit/ui_styling_style_scope.kt +232 -174
  85. package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_view_text_view_common.kt +1 -1
  86. package/kit-android/generated/kotlin/org/nativescript/kit/utils_android_runtime_version.kt +75 -0
  87. package/kit-android/generated/manifest.json +21 -18
  88. package/kit-android/generated/source-lines.json +1 -1
  89. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Array.kt +497 -42
  90. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Intl.kt +1 -1
  91. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/JSON.kt +22 -2
  92. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Strings.kt +32 -18
  93. package/kit-apple/Overlays/xml-free/Core/ui.builder.index.swift +1 -1
  94. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +14 -10
  95. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +3 -9
  96. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity3Plus.swift +20 -21
  97. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_index_section_view_ios_android.swift +5 -7
  98. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_ios_android_.swift +130 -0
  99. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_oldIndex_newIndex.swift +2 -4
  100. package/kit-apple/Sources/NativeScriptKit/Core/Object_specified_substituted_reads.swift +115 -0
  101. package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads.swift +113 -0
  102. package/kit-apple/Sources/NativeScriptKit/Core/Object_substituted_values_reads_.swift +113 -0
  103. package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +348 -330
  104. package/kit-apple/Sources/NativeScriptKit/Core/application.application.ios.swift +358 -359
  105. package/kit-apple/Sources/NativeScriptKit/Core/application.helpers-common.swift +47 -29
  106. package/kit-apple/Sources/NativeScriptKit/Core/connectivity.index.ios.swift +3 -1
  107. package/kit-apple/Sources/NativeScriptKit/Core/css-mediaquery.index.swift +95 -53
  108. package/kit-apple/Sources/NativeScriptKit/Core/css.CSS3Parser.swift +1 -1
  109. package/kit-apple/Sources/NativeScriptKit/Core/css.parser.swift +1 -1
  110. package/kit-apple/Sources/NativeScriptKit/Core/data.observable-array.index.swift +2 -2
  111. package/kit-apple/Sources/NativeScriptKit/Core/file-system.file-system-access.ios.swift +52 -43
  112. package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.http-request-internal-common.swift +18 -0
  113. package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +66 -51
  114. package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +67 -51
  115. package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +143 -32
  116. package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +30 -19
  117. package/kit-apple/Sources/NativeScriptKit/Core/media-query-list.index.swift +190 -78
  118. package/kit-apple/Sources/NativeScriptKit/Core/native-window.native-window.ios.swift +1 -1
  119. package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.parse.swift +205 -201
  120. package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.stringify.swift +41 -42
  121. package/kit-apple/Sources/NativeScriptKit/Core/npm.css-what.src.types.swift +1 -1
  122. package/kit-apple/Sources/NativeScriptKit/Core/trace.index.swift +2 -2
  123. package/kit-apple/Sources/NativeScriptKit/Core/ui.animation.index.ios.swift +77 -65
  124. package/kit-apple/Sources/NativeScriptKit/Core/ui.builder.index.swift +4 -4
  125. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.properties.index.swift +1272 -824
  126. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view-base.index.swift +2 -2
  127. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +8 -8
  128. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -1
  129. package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.frame-common.swift +2 -1
  130. package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +6 -6
  131. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +22 -21
  132. package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +202 -188
  133. package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +2 -6
  134. package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +3 -3
  135. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +2 -2
  136. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.clip-path-function.swift +1 -1
  137. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-animation-parser.swift +1 -1
  138. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.css-selector.swift +2 -2
  139. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.font-common.swift +2 -2
  140. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style-scope.swift +869 -838
  141. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.style.index.swift +46 -31
  142. package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.formatted-string.swift +1 -2
  143. package/kit-apple/Sources/NativeScriptKit/Core/ui.text-view.text-view-common.swift +1 -1
  144. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.index.ios.swift +2 -2
  145. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.modal-transition.ios.swift +4 -4
  146. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.page-transition.ios.swift +2 -2
  147. package/kit-apple/Sources/NativeScriptKit/Core/ui.transition.shared-transition-helper.ios.swift +17 -17
  148. package/kit-apple/Sources/NativeScriptKit/Core/utils.android-runtime-version.swift +77 -0
  149. package/kit-apple/Sources/NativeScriptKit/Core/utils.debug-source.swift +2 -2
  150. package/kit-apple/Sources/NativeScriptKit/Core/xhr.index.swift +62 -61
  151. package/kit-apple/Sources/NativeScriptKit/Runtime/Array.swift +4 -0
  152. package/kit-apple/Sources/NativeScriptKit/Runtime/Dynamic.swift +2 -0
  153. package/kit-apple/Sources/NativeScriptKit/Runtime/Interop.swift +1 -1
  154. package/kit-apple/Sources/NativeScriptKit/Runtime/Intl.swift +1 -1
  155. package/kit-apple/Sources/NativeScriptKit/Runtime/Iterators.swift +1 -1
  156. package/kit-apple/Sources/NativeScriptKit/Runtime/JSON.swift +280 -9
  157. package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +3 -2
  158. package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +1 -0
  159. package/kit-apple/Sources/NativeScriptKit/Runtime/Symbol.swift +1 -0
  160. package/kit-apple/Sources/NativeScriptKit/Runtime/Values.swift +1 -0
  161. package/kit-apple/Sources/NativeScriptKit/Runtime/Views.swift +2 -0
  162. package/package.json +2 -2
@@ -385,7 +385,7 @@ object Core_accessibility_accessibility_common {
385
385
  return JSArray<String>()
386
386
  }
387
387
 
388
- @JvmField val VALID_FONT_SCALES: JSArray<Double> = jsArrayOf<Double>(0.85, 1.0, 1.15, 1.3)
388
+ @JvmField val VALID_FONT_SCALES: JSArray<Double> = JSArray.doublesOf(0.85, 1.0, 1.15, 1.3)
389
389
 
390
390
  fun getClosestValidFontScale(fontScale: Double): Double {
391
391
  var fontScale: Double = fontScale
@@ -393,7 +393,7 @@ object Core_accessibility_accessibility_common {
393
393
  val __v_1 = fontScale
394
394
  if (jsTruthy(__v_1)) __v_1 else 1.0
395
395
  }
396
- return (Core_accessibility_accessibility_common.VALID_FONT_SCALES.sort({
396
+ return (Core_accessibility_accessibility_common.VALID_FONT_SCALES.sortDouble({
397
397
  a: Double,
398
398
  b: Double ->
399
399
  Math.abs(fontScale - a) - Math.abs(fontScale - b)
@@ -29,8 +29,8 @@ open class ApplicationCommon : JSExpando, JSKeysMade {
29
29
  * it also fires on a background launch where no window is created.
30
30
  *
31
31
  * Guaranteed ordering: `ready` -> `windowOpen` -> raw connect/create events -> content
32
- * resolution (the legacy `launch` bridge runs here, for the first window only) ->
33
- * `contentLoaded` -> `activate`/`displayed`.
32
+ * resolution (the legacy `launch` bridge runs here, for the first window and the first one
33
+ * after `exit`) -> `contentLoaded` -> `activate`/`displayed`.
34
34
  */
35
35
  @JvmField var readyEvent: String = "ready"
36
36
  /**
@@ -782,6 +782,23 @@ open class ApplicationCommon : JSExpando, JSKeysMade {
782
782
  )
783
783
  }
784
784
 
785
+ /**
786
+ * @internal - raises `exit` and re-arms the legacy `launch` bridge, since the process can
787
+ * outlive the exit and open a new first window.
788
+ */
789
+ open fun notifyExit(data: Any? = null) {
790
+ this._launchBridgeConsumed = false
791
+ this.notify(
792
+ kotlin.run {
793
+ val __o_1 = JSObject()
794
+ __o_1["eventName"] = this.exitEvent
795
+ __o_1["object"] = this
796
+ jsObjectSpread(__o_1, data)
797
+ __o_1
798
+ }
799
+ )
800
+ }
801
+
785
802
  /**
786
803
  * @param options.install `false` returns the resolved view instead of applying it, for platform
787
804
  * pipelines that install the root view on the native surface themselves.
@@ -790,10 +807,10 @@ open class ApplicationCommon : JSExpando, JSKeysMade {
790
807
  * @internal - produces the content for a window that has none.
791
808
  *
792
809
  * Resolution order: the window content resolver, then the legacy `launch` event (offered to the
793
- * first window that asks for content and to no other), then the application main entry. A
794
- * resolver or a `launch` handler returning `null` takes ownership of the content, so nothing
795
- * else is tried. A missing main entry leaves the window empty instead of throwing, because
796
- * content can still arrive later through `run()`/`resetRootView()`.
810
+ * first window that asks for content, and again to the first one after `exit`), then the
811
+ * application main entry. A resolver or a `launch` handler returning `null` takes ownership of
812
+ * the content, so nothing else is tried. A missing main entry leaves the window empty instead
813
+ * of throwing, because content can still arrive later through `run()`/`resetRootView()`.
797
814
  */
798
815
  open fun _resolveWindowContent(
799
816
  window: NativeWindow?,
@@ -1548,6 +1565,11 @@ open class ApplicationCommon : JSExpando, JSKeysMade {
1548
1565
  this.notifyReady()
1549
1566
  null
1550
1567
  }
1568
+ "notifyExit" ->
1569
+ jsFunction { __a ->
1570
+ this.notifyExit(__a.getOrNull(0))
1571
+ null
1572
+ }
1551
1573
  "_resolveWindowContent" ->
1552
1574
  jsFunction { __a ->
1553
1575
  this._resolveWindowContent(
@@ -1796,6 +1818,7 @@ open class ApplicationCommon : JSExpando, JSKeysMade {
1796
1818
  "onWindowSystemAppearanceChanged",
1797
1819
  "onWindowLayoutDirectionChanged",
1798
1820
  "notifyReady",
1821
+ "notifyExit",
1799
1822
  "_resolveWindowContent",
1800
1823
  "resolveWindowContent",
1801
1824
  "buildContentView",
@@ -174,6 +174,7 @@ object Core_application_helpers_common {
174
174
 
175
175
  @JvmField
176
176
  var _toggleApplicationEventListenersHandler: ((Boolean, (Any?) -> Unit) -> Unit)? = null
177
+ @JvmField val _pendingApplicationEventListeners: JSSet<(Any?) -> Unit> = JSSet<(Any?) -> Unit>()
177
178
 
178
179
  fun toggleApplicationEventListeners(toAdd: Boolean, callback: (Any?) -> Unit) {
179
180
  if (
@@ -181,12 +182,25 @@ object Core_application_helpers_common {
181
182
  ) {
182
183
  (Core_application_helpers_common._toggleApplicationEventListenersHandler
183
184
  ?: jsNotAFunction("_toggleApplicationEventListenersHandler"))(toAdd, callback)
185
+ } else if (toAdd) {
186
+ Core_application_helpers_common._pendingApplicationEventListeners.add(
187
+ callback
188
+ )
189
+ } else {
190
+ Core_application_helpers_common._pendingApplicationEventListeners.delete(
191
+ callback
192
+ )
184
193
  }
185
194
  }
186
195
 
187
196
  fun setToggleApplicationEventListenersCallback(callback: (Boolean, (Any?) -> Unit) -> Unit) {
188
197
  Core_application_helpers_common._toggleApplicationEventListenersHandler =
189
198
  callback
199
+ for (listener in
200
+ Core_application_helpers_common._pendingApplicationEventListeners) {
201
+ callback(true, listener)
202
+ }
203
+ Core_application_helpers_common._pendingApplicationEventListeners.clear()
190
204
  }
191
205
 
192
206
  @JvmField var _applicationPropertiesCallback: (() -> Any?)? = null
@@ -342,9 +342,9 @@ object Core_color_color_utils {
342
342
  val q: Double = v * (1.0 - f * s)
343
343
  val t: Double = v * (1.0 - (1.0 - f) * s)
344
344
  val mod: Double = i % 6.0
345
- val r: Double? = jsArrayOf<Double>(v, q, p, p, t, v).element(mod)
346
- val g: Double? = jsArrayOf<Double>(t, v, v, q, p, p).element(mod)
347
- val b: Double? = jsArrayOf<Double>(p, p, t, v, v, q).element(mod)
345
+ val r: Double? = JSArray.doublesOf(v, q, p, p, t, v).element(mod)
346
+ val g: Double? = JSArray.doublesOf(t, v, v, q, p, p).element(mod)
347
+ val b: Double? = JSArray.doublesOf(p, p, t, v, v, q).element(mod)
348
348
  return Object_r_g_b(
349
349
  r = (r ?: Double.NaN) * 255.0,
350
350
  g = (g ?: Double.NaN) * 255.0,
@@ -22,10 +22,58 @@ object Core_css_mediaquery_index {
22
22
  @JvmField
23
23
  val RESERVED_MEDIA_TYPES: JSSet<String> =
24
24
  JSSet<String>(jsArrayOf<String>("only", "not", "and", "or", "layer"))
25
+ @JvmField
26
+ val EVALUABLE_FEATURES: JSSet<String> =
27
+ JSSet<String>(
28
+ jsArrayOf<String>(
29
+ "width",
30
+ "height",
31
+ "device-width",
32
+ "device-height",
33
+ "orientation",
34
+ "prefers-color-scheme",
35
+ )
36
+ )
37
+ @JvmField val parsedQueryCache: JSMap<String, JSArray<Any?>> = JSMap<String, JSArray<Any?>>()
38
+
39
+ fun getParsedQuery(mediaQuery: String?): JSArray<Any?>? {
40
+ var expressions: JSArray<Any?>? =
41
+ Core_css_mediaquery_index.parsedQueryCache.get((mediaQuery ?: "undefined"))
42
+ if (!jsTruthy(expressions)) {
43
+ expressions = Core_css_mediaquery_index.parseQuery(mediaQuery)
44
+ Core_css_mediaquery_index.parsedQueryCache.set(
45
+ (mediaQuery ?: "undefined"),
46
+ jsUnchecked<JSArray<Any?>>(expressions),
47
+ )
48
+ }
49
+ return expressions
50
+ }
51
+
52
+ /**
53
+ * Whether a media query is valid and uses only features the runtime can evaluate.
54
+ *
55
+ * @param mediaQuery The media query string.
56
+ */
57
+ fun isEvaluableMediaQuery(mediaQuery: String?): Boolean {
58
+ var expressions: JSArray<Any?>?
59
+ try {
60
+ expressions = Core_css_mediaquery_index.getParsedQuery(mediaQuery)
61
+ } catch (__e_1: Throwable) {
62
+ return false
63
+ }
64
+ return (expressions ?: jsCannotRead("every")).every({ query: Any? ->
65
+ (jsAsOrNull<JSArray<Any?>>(jsGet(query, "features")) ?: JSArray<Any?>())
66
+ .every({ feature: Any? ->
67
+ Core_css_mediaquery_index.EVALUABLE_FEATURES.has(
68
+ (jsConvertedStringOrNull(jsGet(feature, "property")) ?: "undefined")
69
+ )
70
+ })
71
+ })
72
+ }
25
73
 
26
74
  fun matchQuery(mediaQuery: String?, values: Any?): Boolean {
27
75
  val expressions: JSArray<Any?>? =
28
- Core_css_mediaquery_index.parseQuery(mediaQuery)
76
+ Core_css_mediaquery_index.getParsedQuery(mediaQuery)
29
77
  return (expressions ?: jsCannotRead("some")).some(
30
78
  fn1@{ query: Any? ->
31
79
  val __d_1: Any? = query
@@ -717,13 +717,6 @@ open class ObservableArray : Observable, JSStringConvertible, JSToJSON, JSIterab
717
717
  )
718
718
  null
719
719
  }
720
- "map" ->
721
- jsFunction { __a ->
722
- this.map(
723
- jsFunction3<Any?, Double, ObservableArray, Any?>(__a.getOrNull(0)),
724
- __a.getOrNull(1),
725
- )
726
- }
727
720
  "filter" ->
728
721
  jsFunction { __a ->
729
722
  this.filter(
@@ -780,7 +773,6 @@ open class ObservableArray : Observable, JSStringConvertible, JSToJSON, JSIterab
780
773
  "every",
781
774
  "some",
782
775
  "forEach",
783
- "map",
784
776
  "filter",
785
777
  "reduce",
786
778
  "reduceRight" -> true
@@ -661,20 +661,6 @@ open class Observable : JSExpando, JSKeysMade {
661
661
  this._clearEventListeners()
662
662
  null
663
663
  }
664
- "_globalNotify" ->
665
- jsFunction { __a ->
666
- this._globalNotify(
667
- jsConvertedStringOrNull(__a.getOrNull(0)),
668
- jsConvertedStringOrNull(__a.getOrNull(1)),
669
- __a.getOrNull(2),
670
- )
671
- null
672
- }
673
- "notify" ->
674
- jsFunction { __a ->
675
- this.notify(__a.getOrNull(0))
676
- null
677
- }
678
664
  "notifyPropertyChange" ->
679
665
  jsFunction { __a ->
680
666
  this.notifyPropertyChange(
@@ -728,8 +714,6 @@ open class Observable : JSExpando, JSKeysMade {
728
714
  "addEventListener",
729
715
  "removeEventListener",
730
716
  "_clearEventListeners",
731
- "_globalNotify",
732
- "notify",
733
717
  "notifyPropertyChange",
734
718
  "hasListeners",
735
719
  "_createPropertyChangeData",
@@ -27,8 +27,8 @@ open class VirtualArray : Observable {
27
27
  constructor(length: Double = 0.0) : super() {
28
28
  this._length = length
29
29
  this._cache = jsObjectOf()
30
- this._requestedIndexes = JSArray<Double>()
31
- this._loadedIndexes = JSArray<Double>()
30
+ this._requestedIndexes = JSArray.doubles()
31
+ this._loadedIndexes = JSArray.doubles()
32
32
  }
33
33
 
34
34
  open var length: Double
@@ -99,7 +99,7 @@ open class VirtualArray : Observable {
99
99
  if (
100
100
  (this._loadedIndexes ?: jsCannotRead("indexOf")).indexOf(itemIndex) < 0.0
101
101
  ) {
102
- (this._loadedIndexes ?: jsCannotRead("push")).push(itemIndex)
102
+ (this._loadedIndexes ?: jsCannotRead("push")).pushDouble(itemIndex)
103
103
  }
104
104
  i += 1.0
105
105
  }
@@ -149,7 +149,9 @@ open class VirtualArray : Observable {
149
149
  if (
150
150
  (this._requestedIndexes ?: jsCannotRead("indexOf")).indexOf(itemIndex) < 0.0
151
151
  ) {
152
- (this._requestedIndexes ?: jsCannotRead("push")).push(itemIndex)
152
+ (this._requestedIndexes ?: jsCannotRead("push")).pushDouble(
153
+ itemIndex
154
+ )
153
155
  }
154
156
  count += 1.0
155
157
  } else {
@@ -5,6 +5,7 @@ import androidx.annotation.AnyThread
5
5
  import java.io.ByteArrayOutputStream
6
6
  import java.io.File as java_io_File
7
7
  import java.io.FileOutputStream
8
+ import java.nio.ByteBuffer
8
9
 
9
10
  @AnyThread
10
11
  object Core_http_http_request_index {
@@ -13,14 +14,25 @@ object Core_http_http_request_index {
13
14
  val __o_1 = JSObject()
14
15
  __o_1["toArrayBuffer"] = JSMethod { __this, _ ->
15
16
  (fun(): JSArrayBuffer? {
16
- return JSUint8Array.from(
17
- (JSArray(
18
- (jsCastCarried(jsGet(__this, "raw"), ByteArrayOutputStream::class.java))
19
- .toByteArray()
20
- .map { it.toDouble() }
21
- ) ?: JSNull)
17
+ val bytes: JSArray<Double>? =
18
+ JSArray(
19
+ (jsCastCarried(jsGet(__this, "raw"), ByteArrayOutputStream::class.java))
20
+ .toByteArray()
21
+ .map { it.toDouble() }
22
+ )
23
+ val buffer: JSArrayBuffer? =
24
+ jsCast(
25
+ JSArrayBuffer.from(
26
+ ((ByteBuffer.wrap(
27
+ (bytes?.elements?.map { it.toLong().toByte() }?.toByteArray()
28
+ ?: jsObjectRequired())
29
+ ) ?: JSNull)
30
+ as ByteBuffer)
31
+ ),
32
+ JSArrayBuffer::class.java,
22
33
  )
23
- .buffer
34
+ jsDelete(((buffer ?: jsObjectRequired())), "nativeObject")
35
+ return buffer
24
36
  })()
25
37
  }
26
38
  __o_1["toString"] = JSMethod { __this, __a ->
@@ -58,4 +58,18 @@ object Core_http_http_request_internal_http_request_internal_common {
58
58
  }
59
59
  return jsObjectOf("method" to method)
60
60
  }
61
+
62
+ fun getRequestBodyBytes(content: Any?): JSUint8Array? {
63
+ if ((content is JSArrayBuffer)) {
64
+ return JSUint8Array.from(content)
65
+ }
66
+ if (JSArrayBuffer.isView(content)) {
67
+ return JSUint8Array.from(
68
+ jsGet(content, "buffer"),
69
+ jsConvertedNumberOrZero(jsGet(content, "byteOffset")),
70
+ jsConvertedNumberOrZero(jsGet(content, "byteLength")),
71
+ )
72
+ }
73
+ return null
74
+ }
61
75
  }
@@ -161,17 +161,26 @@ object Core_http_http_request_internal_index {
161
161
  ?: jsObjectRequired())
162
162
  )
163
163
  javaOptions.content = nativeBuffer
164
- } else if ((jsGet(options, "content") is JSArrayBuffer)) {
165
- val typedArray: JSUint8Array =
166
- JSUint8Array(jsCastCarried(jsGet(options, "content"), JSArrayBuffer::class.java))
167
- val nativeBuffer: ByteBuffer? =
168
- ByteBuffer.wrap(
169
- (JSArray(typedArray.toList())
170
- ?.elements
171
- ?.map { it.toLong().toByte() }
172
- ?.toByteArray() ?: jsObjectRequired())
164
+ } else {
165
+ val bytes: JSUint8Array? =
166
+ Core_http_http_request_internal_http_request_internal_common.getRequestBodyBytes(
167
+ jsGet(options, "content")
173
168
  )
174
- javaOptions.content = nativeBuffer
169
+ if (jsTruthy(bytes)) {
170
+ javaOptions.content =
171
+ ByteBuffer.wrap(
172
+ (toJavaValue(
173
+ (if (
174
+ Core_utils_android_runtime_version
175
+ .runtimeCopiesTypedArraysToByteArrays()
176
+ )
177
+ ((bytes ?: jsObjectRequired()))
178
+ else JSArray((bytes ?: jsObjectRequired()).toList())),
179
+ ByteArray::class.java,
180
+ )
181
+ as ByteArray?)
182
+ )
183
+ }
175
184
  }
176
185
  if (jsTypeof(jsConvertedNumberOrNull(jsGet(options, "timeout"))) == "number") {
177
186
  javaOptions.timeout =
@@ -43,7 +43,7 @@ object Core_matrix_index {
43
43
  Core_utils_number_utils.degreesToRadians(jsConvertedNumberOrZero(z))
44
44
  val cosZ: Double = Math.cos(radZ)
45
45
  val sinZ: Double = Math.sin(radZ)
46
- return jsArrayOf<Double>(
46
+ return JSArray.doublesOf(
47
47
  cosZ,
48
48
  -(sinZ),
49
49
  0.0,
@@ -58,7 +58,7 @@ object Core_matrix_index {
58
58
  )
59
59
  @JvmField
60
60
  val matrixArrayToCssMatrix: (JSArray<Double>) -> JSArray<Double> = { m: JSArray<Double>? ->
61
- jsArrayOf<Double>(
61
+ JSArray.doublesOf(
62
62
  ((m ?: jsCannotRead("0")).element(0.0) ?: Double.NaN),
63
63
  ((m ?: jsCannotRead("3")).element(3.0) ?: Double.NaN),
64
64
  ((m ?: jsCannotRead("1")).element(1.0) ?: Double.NaN),
@@ -69,33 +69,21 @@ object Core_matrix_index {
69
69
  }
70
70
 
71
71
  fun multiplyAffine2d(m1: JSArray<Double>?, m2: JSArray<Double>?): JSArray<Double>? {
72
- return jsArrayOf<Double>(
73
- ((m1 ?: jsCannotRead("0")).element(0.0) ?: Double.NaN) *
74
- ((m2 ?: jsCannotRead("0")).element(0.0) ?: Double.NaN) +
75
- ((m1 ?: jsCannotRead("1")).element(1.0) ?: Double.NaN) *
76
- ((m2 ?: jsCannotRead("3")).element(3.0) ?: Double.NaN),
77
- ((m1 ?: jsCannotRead("0")).element(0.0) ?: Double.NaN) *
78
- ((m2 ?: jsCannotRead("1")).element(1.0) ?: Double.NaN) +
79
- ((m1 ?: jsCannotRead("1")).element(1.0) ?: Double.NaN) *
80
- ((m2 ?: jsCannotRead("4")).element(4.0) ?: Double.NaN),
81
- ((m1 ?: jsCannotRead("0")).element(0.0) ?: Double.NaN) *
82
- ((m2 ?: jsCannotRead("2")).element(2.0) ?: Double.NaN) +
83
- ((m1 ?: jsCannotRead("1")).element(1.0) ?: Double.NaN) *
84
- ((m2 ?: jsCannotRead("5")).element(5.0) ?: Double.NaN) +
85
- ((m1 ?: jsCannotRead("2")).element(2.0) ?: Double.NaN),
86
- ((m1 ?: jsCannotRead("3")).element(3.0) ?: Double.NaN) *
87
- ((m2 ?: jsCannotRead("0")).element(0.0) ?: Double.NaN) +
88
- ((m1 ?: jsCannotRead("4")).element(4.0) ?: Double.NaN) *
89
- ((m2 ?: jsCannotRead("3")).element(3.0) ?: Double.NaN),
90
- ((m1 ?: jsCannotRead("3")).element(3.0) ?: Double.NaN) *
91
- ((m2 ?: jsCannotRead("1")).element(1.0) ?: Double.NaN) +
92
- ((m1 ?: jsCannotRead("4")).element(4.0) ?: Double.NaN) *
93
- ((m2 ?: jsCannotRead("4")).element(4.0) ?: Double.NaN),
94
- ((m1 ?: jsCannotRead("3")).element(3.0) ?: Double.NaN) *
95
- ((m2 ?: jsCannotRead("2")).element(2.0) ?: Double.NaN) +
96
- ((m1 ?: jsCannotRead("4")).element(4.0) ?: Double.NaN) *
97
- ((m2 ?: jsCannotRead("5")).element(5.0) ?: Double.NaN) +
98
- ((m1 ?: jsCannotRead("5")).element(5.0) ?: Double.NaN),
72
+ return JSArray.doublesOf(
73
+ (m1 ?: jsCannotRead("0")).numberAt(0.0) * (m2 ?: jsCannotRead("0")).numberAt(0.0) +
74
+ (m1 ?: jsCannotRead("1")).numberAt(1.0) * (m2 ?: jsCannotRead("3")).numberAt(3.0),
75
+ (m1 ?: jsCannotRead("0")).numberAt(0.0) * (m2 ?: jsCannotRead("1")).numberAt(1.0) +
76
+ (m1 ?: jsCannotRead("1")).numberAt(1.0) * (m2 ?: jsCannotRead("4")).numberAt(4.0),
77
+ (m1 ?: jsCannotRead("0")).numberAt(0.0) * (m2 ?: jsCannotRead("2")).numberAt(2.0) +
78
+ (m1 ?: jsCannotRead("1")).numberAt(1.0) * (m2 ?: jsCannotRead("5")).numberAt(5.0) +
79
+ (m1 ?: jsCannotRead("2")).numberAt(2.0),
80
+ (m1 ?: jsCannotRead("3")).numberAt(3.0) * (m2 ?: jsCannotRead("0")).numberAt(0.0) +
81
+ (m1 ?: jsCannotRead("4")).numberAt(4.0) * (m2 ?: jsCannotRead("3")).numberAt(3.0),
82
+ (m1 ?: jsCannotRead("3")).numberAt(3.0) * (m2 ?: jsCannotRead("1")).numberAt(1.0) +
83
+ (m1 ?: jsCannotRead("4")).numberAt(4.0) * (m2 ?: jsCannotRead("4")).numberAt(4.0),
84
+ (m1 ?: jsCannotRead("3")).numberAt(3.0) * (m2 ?: jsCannotRead("2")).numberAt(2.0) +
85
+ (m1 ?: jsCannotRead("4")).numberAt(4.0) * (m2 ?: jsCannotRead("5")).numberAt(5.0) +
86
+ (m1 ?: jsCannotRead("5")).numberAt(5.0),
99
87
  )
100
88
  }
101
89
 
@@ -325,8 +325,26 @@ class MediaQueryListImpl : Observable {
325
325
  object Core_media_query_list_index {
326
326
  @JvmField val mediaQueryLists: JSArray<MediaQueryListImpl> = JSArray<MediaQueryListImpl>()
327
327
  @JvmField var isMediaInitializationEnabled: Boolean = false
328
+ @JvmField val matchResultCache: JSMap<String, Boolean> = JSMap<String, Boolean>()
329
+ @JvmField var isCacheInvalidationRegistered: Boolean = false
330
+
331
+ fun clearMatchResultCache() {
332
+ Core_media_query_list_index.matchResultCache.clear()
333
+ }
334
+
335
+ fun registerCacheInvalidation() {
336
+ if (Core_media_query_list_index.isCacheInvalidationRegistered) {
337
+ return
338
+ }
339
+ Core_media_query_list_index.isCacheInvalidationRegistered = true
340
+ Core_application_helpers_common.toggleApplicationEventListeners(
341
+ true,
342
+ { _: Any? -> Core_media_query_list_index.clearMatchResultCache() },
343
+ )
344
+ }
328
345
 
329
346
  fun onDeviceChange(args: Any?) {
347
+ Core_media_query_list_index.clearMatchResultCache()
330
348
  for (mql in Core_media_query_list_index.mediaQueryLists) {
331
349
  val matches: Boolean =
332
350
  Core_media_query_list_index.checkIfMediaQueryMatches(
@@ -347,35 +365,139 @@ object Core_media_query_list_index {
347
365
  }
348
366
 
349
367
  fun checkIfMediaQueryMatches(mediaQueryString: String?): Boolean {
350
- val __d_1: MainScreen = (Screen.mainScreen ?: jsObjectRequired())
351
- val widthPixels: Double = __d_1.widthPixels
352
- val heightPixels: Double = __d_1.heightPixels
368
+ val cachedResult: Boolean? =
369
+ Core_media_query_list_index.matchResultCache.get((mediaQueryString ?: "undefined"))
370
+ if (cachedResult != null) {
371
+ return (cachedResult ?: false)
372
+ }
353
373
  var matches: Boolean
354
- try {
355
- val appProperties: Any? =
356
- Core_application_helpers_common.getApplicationProperties()
357
- matches =
358
- Core_css_mediaquery_index.matchQuery(
359
- mediaQueryString,
360
- jsObjectOf(
361
- "type" to MediaQueryType.screen,
362
- "width" to widthPixels,
363
- "height" to heightPixels,
364
- "device-width" to widthPixels,
365
- "device-height" to heightPixels,
366
- "orientation" to jsGet(appProperties, "orientation"),
367
- "prefers-color-scheme" to jsGet(appProperties, "systemAppearance"),
368
- ),
374
+ if (Core_css_mediaquery_index.isEvaluableMediaQuery(mediaQueryString)) {
375
+ Core_media_query_list_index.registerCacheInvalidation()
376
+ var screenPixels: Any? = null
377
+ var appProperties: Any? = null
378
+ val getScreenPixels: () -> Any? = {
379
+ (kotlin.run {
380
+ if (jsIsNullish(screenPixels))
381
+ screenPixels =
382
+ jsObjectOf(
383
+ "width" to
384
+ (Screen.mainScreen ?: jsCannotRead("widthPixels")).widthPixels,
385
+ "height" to
386
+ (Screen.mainScreen ?: jsCannotRead("heightPixels")).heightPixels,
387
+ )
388
+ screenPixels
389
+ })
390
+ }
391
+ val getAppProperties: () -> Any? = {
392
+ (kotlin.run {
393
+ if (jsIsNullish(appProperties))
394
+ appProperties = Core_application_helpers_common.getApplicationProperties()
395
+ appProperties
396
+ })
397
+ }
398
+ try {
399
+ matches =
400
+ Core_css_mediaquery_index.matchQuery(
401
+ mediaQueryString,
402
+ kotlin.run {
403
+ val __o_1 = JSObject()
404
+ __o_1["type"] = MediaQueryType.screen
405
+ __o_1.defineProperty(
406
+ "width",
407
+ JSPropertyDescriptor(
408
+ get =
409
+ fun(__this: Any?): Any? {
410
+ return jsGet(getScreenPixels(), "width")
411
+ },
412
+ enumerable = true,
413
+ configurable = true,
414
+ ),
415
+ )
416
+ __o_1.defineProperty(
417
+ "height",
418
+ JSPropertyDescriptor(
419
+ get =
420
+ fun(__this: Any?): Any? {
421
+ return jsGet(getScreenPixels(), "height")
422
+ },
423
+ enumerable = true,
424
+ configurable = true,
425
+ ),
426
+ )
427
+ __o_1.defineProperty(
428
+ "device-width",
429
+ JSPropertyDescriptor(
430
+ get =
431
+ fun(__this: Any?): Any? {
432
+ return jsGet(getScreenPixels(), "width")
433
+ },
434
+ enumerable = true,
435
+ configurable = true,
436
+ ),
437
+ )
438
+ __o_1.defineProperty(
439
+ "device-height",
440
+ JSPropertyDescriptor(
441
+ get =
442
+ fun(__this: Any?): Any? {
443
+ return jsGet(getScreenPixels(), "height")
444
+ },
445
+ enumerable = true,
446
+ configurable = true,
447
+ ),
448
+ )
449
+ __o_1.defineProperty(
450
+ "orientation",
451
+ JSPropertyDescriptor(
452
+ get =
453
+ fun(__this: Any?): Any? {
454
+ return jsGet(
455
+ getAppProperties(),
456
+ "orientation",
457
+ )
458
+ },
459
+ enumerable = true,
460
+ configurable = true,
461
+ ),
462
+ )
463
+ __o_1.defineProperty(
464
+ "prefers-color-scheme",
465
+ JSPropertyDescriptor(
466
+ get =
467
+ fun(__this: Any?): Any? {
468
+ return jsGet(
469
+ getAppProperties(),
470
+ "systemAppearance",
471
+ )
472
+ },
473
+ enumerable = true,
474
+ configurable = true,
475
+ ),
476
+ )
477
+ __o_1
478
+ },
479
+ )
480
+ } catch (__e_1: Throwable) {
481
+ val err: Any? = jsCaught(__e_1)
482
+ matches = false
483
+ org.nativescript.kit.Trace.write(
484
+ err,
485
+ org.nativescript.kit.Trace.categories.MediaQuery,
486
+ org.nativescript.kit.Trace.messageType.error,
369
487
  )
370
- } catch (__e_1: Throwable) {
371
- val err: Any? = jsCaught(__e_1)
488
+ }
489
+ } else {
372
490
  matches = false
373
491
  org.nativescript.kit.Trace.write(
374
- err,
492
+ "Media query '${jsToString((mediaQueryString ?: "undefined"))}' cannot be evaluated and will never match",
375
493
  org.nativescript.kit.Trace.categories.MediaQuery,
376
- org.nativescript.kit.Trace.messageType.error,
494
+ org.nativescript.kit.Trace.messageType.warn,
377
495
  )
378
496
  }
497
+ Core_media_query_list_index.matchResultCache.set(
498
+ (mediaQueryString ?: "undefined"),
499
+ matches,
500
+ )
379
501
  return matches
380
502
  }
381
503