@nstudio/nativescript-compiler 9.2.0-alpha.10 → 9.2.0-alpha.12

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 (181) hide show
  1. package/dist/api/ir.js +7 -1
  2. package/dist/cli/runtime.cjs +7 -1
  3. package/dist/css/css.js +30 -6
  4. package/dist/driver/cli.js +2 -0
  5. package/dist/driver/compile.js +23 -10
  6. package/dist/driver/paths.js +7 -0
  7. package/dist/driver/unimplemented.js +15 -0
  8. package/dist/kotlin/access.js +23 -5
  9. package/dist/kotlin/arguments.js +5 -0
  10. package/dist/kotlin/builtins.js +0 -4
  11. package/dist/kotlin/calls.js +6 -2
  12. package/dist/kotlin/class-methods.js +9 -3
  13. package/dist/kotlin/components.js +13 -8
  14. package/dist/kotlin/conversion.js +17 -5
  15. package/dist/kotlin/core-api.js +2 -13
  16. package/dist/kotlin/declarations.js +2 -0
  17. package/dist/kotlin/expression-statements.js +5 -4
  18. package/dist/kotlin/expressions.js +8 -3
  19. package/dist/kotlin/functions.js +13 -4
  20. package/dist/kotlin/global-calls.js +11 -0
  21. package/dist/kotlin/literals.js +58 -14
  22. package/dist/kotlin/names.js +2 -2
  23. package/dist/kotlin/native/api.js +9 -1
  24. package/dist/kotlin/native/calls.js +84 -3
  25. package/dist/kotlin/native/subclasses.js +4 -3
  26. package/dist/kotlin/native/types.js +8 -5
  27. package/dist/kotlin/operators.js +4 -1
  28. package/dist/kotlin/overrides.js +7 -5
  29. package/dist/kotlin/placement.js +3 -1
  30. package/dist/kotlin/prototype-calls.js +5 -0
  31. package/dist/kotlin/render.js +62 -0
  32. package/dist/kotlin/statements.js +9 -0
  33. package/dist/kotlin/static-calls.js +10 -7
  34. package/dist/kotlin/translator.js +31 -11
  35. package/dist/kotlin/type-facts.js +10 -2
  36. package/dist/kotlin/types.js +6 -6
  37. package/dist/plugins/native-android.js +37 -5
  38. package/dist/plugins/native-ios.js +2 -0
  39. package/dist/plugins/source.js +73 -23
  40. package/dist/program/app-modules.js +91 -16
  41. package/dist/program/app-paths.js +80 -12
  42. package/dist/program/class-mixins.js +463 -0
  43. package/dist/program/core-facts.js +7 -0
  44. package/dist/program/glob.js +274 -0
  45. package/dist/program/platform.js +32 -4
  46. package/dist/program/program.js +239 -38
  47. package/dist/program/source-lines.js +4 -1
  48. package/dist/program/vite-plugins.js +144 -0
  49. package/dist/semantics/apis/globals.js +2 -2
  50. package/dist/semantics/apis/object.js +1 -0
  51. package/dist/semantics/apis/statics.js +6 -0
  52. package/dist/semantics/ast.js +20 -2
  53. package/dist/semantics/classes.js +36 -1
  54. package/dist/semantics/facts.js +28 -1
  55. package/dist/semantics/globals.js +3 -0
  56. package/dist/semantics/lang.js +13 -1
  57. package/dist/semantics/nullish.js +29 -11
  58. package/dist/semantics/refuse-receivers.js +3 -3
  59. package/dist/semantics/refuse-scope.js +2 -7
  60. package/dist/semantics/runtime.js +1 -0
  61. package/dist/semantics/shapes.js +21 -1
  62. package/dist/semantics/states/value-states.js +1 -1
  63. package/dist/semantics/throws.js +1 -0
  64. package/dist/semantics/translator-methods.js +1 -1
  65. package/dist/semantics/types.js +21 -1
  66. package/dist/swift/access.js +25 -10
  67. package/dist/swift/arguments.js +10 -2
  68. package/dist/swift/assignment.js +12 -1
  69. package/dist/swift/builtins.js +0 -4
  70. package/dist/swift/calls.js +6 -2
  71. package/dist/swift/class-methods.js +3 -3
  72. package/dist/swift/components.js +28 -8
  73. package/dist/swift/construction.js +4 -0
  74. package/dist/swift/conversion.js +1 -1
  75. package/dist/swift/core-api.js +9 -12
  76. package/dist/swift/from-any.js +2 -2
  77. package/dist/swift/functions.js +13 -2
  78. package/dist/swift/generics.js +5 -1
  79. package/dist/swift/global-calls.js +2 -0
  80. package/dist/swift/literals.js +57 -10
  81. package/dist/swift/modules.js +1 -1
  82. package/dist/swift/names.js +1 -1
  83. package/dist/swift/native/sdk-tables.js +52 -4
  84. package/dist/swift/native/sdk.js +9 -1
  85. package/dist/swift/operators.js +4 -1
  86. package/dist/swift/parameters.js +5 -2
  87. package/dist/swift/placement.js +44 -4
  88. package/dist/swift/prototype-calls.js +17 -2
  89. package/dist/swift/render.js +64 -0
  90. package/dist/swift/results.js +1 -1
  91. package/dist/swift/statements.js +9 -0
  92. package/dist/swift/static-calls.js +13 -6
  93. package/dist/swift/types.js +9 -9
  94. package/dist/targets/android/build.js +18 -12
  95. package/dist/targets/ios/build.js +11 -10
  96. package/dist/targets/ios/dependencies.js +12 -0
  97. package/dist/targets/resources.js +15 -1
  98. package/dist/template/plan.js +105 -8
  99. package/dist/types/adapter-api.d.ts +13 -0
  100. package/dist/types/ir.d.ts +47 -0
  101. package/kit-android/generated/kotlin/org/nativescript/kit/__Objects.kt +102 -7485
  102. package/kit-android/generated/kotlin/org/nativescript/kit/application_application.kt +4 -4
  103. package/kit-android/generated/kotlin/org/nativescript/kit/image_source_index.kt +1 -1
  104. package/kit-android/generated/kotlin/org/nativescript/kit/ui_animation_animation_common.kt +7 -3
  105. package/kit-android/generated/kotlin/org/nativescript/kit/ui_animation_index.kt +3 -1
  106. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_base_index.kt +2 -4
  107. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_index.kt +5 -6
  108. package/kit-android/generated/kotlin/org/nativescript/kit/ui_core_view_view_common.kt +1 -3
  109. package/kit-android/generated/kotlin/org/nativescript/kit/ui_dialogs_index.kt +11 -6
  110. package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_fragment_transitions.kt +1 -1
  111. package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_frame_common.kt +1 -1
  112. package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_frame_helper_for_android.kt +7 -5
  113. package/kit-android/generated/kotlin/org/nativescript/kit/ui_frame_index.kt +6 -3
  114. package/kit-android/generated/kotlin/org/nativescript/kit/ui_gestures_touch_manager.kt +1 -1
  115. package/kit-android/generated/kotlin/org/nativescript/kit/ui_layouts_flexbox_layout_index.kt +1 -1
  116. package/kit-android/generated/kotlin/org/nativescript/kit/ui_search_bar_index.kt +4 -3
  117. package/kit-android/generated/kotlin/org/nativescript/kit/ui_segmented_bar_index.kt +2 -2
  118. package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_base_formatted_string.kt +1 -3
  119. package/kit-android/generated/kotlin/org/nativescript/kit/ui_text_base_index.kt +1 -1
  120. package/kit-android/generated/kotlin/org/nativescript/kit/ui_transition_fade_transition.kt +1 -1
  121. package/kit-android/generated/kotlin/org/nativescript/kit/ui_transition_flip_transition.kt +8 -8
  122. package/kit-android/generated/kotlin/org/nativescript/kit/utils_index.kt +1 -1
  123. package/kit-android/generated/source-lines.json +1 -1
  124. package/kit-android/gradlew.bat +94 -0
  125. package/kit-android/src/fromcore/kotlin/org/nativescript/kit/CoreBridge.kt +67 -1
  126. package/kit-android/src/main/kotlin/org/nativescript/kit/Signals.kt +15 -2
  127. package/kit-android/src/main/kotlin/org/nativescript/kit/runtime/Prototypes.kt +26 -0
  128. package/kit-apple/Overlays/xml-free/Core/ui.core.bindable.index.swift +4 -4
  129. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity1.swift +26 -161
  130. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity2.swift +9 -284
  131. package/kit-apple/Sources/NativeScriptKit/Core/FunctionCells.Arity3Plus.swift +11 -7
  132. package/kit-apple/Sources/NativeScriptKit/Core/Object_callback_thisArg_once.swift +1 -1
  133. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_index_section_view_ios_android.swift +7 -5
  134. package/kit-apple/Sources/NativeScriptKit/Core/Object_eventName_object_oldIndex_newIndex.swift +4 -2
  135. package/kit-apple/Sources/NativeScriptKit/Core/{Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_91b5f3.swift → Object_iterator_prototype_for_keyFor_hasInstance_isConcatSpreadable_and_19_more_fa18e1.swift} +28 -103
  136. package/kit-apple/Sources/NativeScriptKit/Core/__Namespace.Utils.swift +17 -15
  137. package/kit-apple/Sources/NativeScriptKit/Core/application-settings.index.ios.swift +8 -8
  138. package/kit-apple/Sources/NativeScriptKit/Core/application.application-common.swift +4 -4
  139. package/kit-apple/Sources/NativeScriptKit/Core/color.color-common.swift +7 -7
  140. package/kit-apple/Sources/NativeScriptKit/Core/data.observable.index.swift +3 -3
  141. package/kit-apple/Sources/NativeScriptKit/Core/http.http-request-internal.index.ios.swift +2 -1
  142. package/kit-apple/Sources/NativeScriptKit/Core/image-source.index.ios.swift +1 -1
  143. package/kit-apple/Sources/NativeScriptKit/Core/kit-index.json +40 -246
  144. package/kit-apple/Sources/NativeScriptKit/Core/manifest.json +1 -2
  145. package/kit-apple/Sources/NativeScriptKit/Core/ui.action-bar.index.ios.swift +3 -3
  146. package/kit-apple/Sources/NativeScriptKit/Core/ui.button.index.ios.swift +4 -4
  147. package/kit-apple/Sources/NativeScriptKit/Core/ui.content-view.index.swift +8 -8
  148. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.bindable.index.swift +4 -4
  149. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.index.ios.swift +8 -8
  150. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-common.swift +1 -3
  151. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.view.view-helper.view-helper-common.swift +7 -7
  152. package/kit-apple/Sources/NativeScriptKit/Core/ui.core.weak-event-listener.index.swift +3 -3
  153. package/kit-apple/Sources/NativeScriptKit/Core/ui.frame.index.ios.swift +4 -4
  154. package/kit-apple/Sources/NativeScriptKit/Core/ui.gestures.index.ios.swift +2 -2
  155. package/kit-apple/Sources/NativeScriptKit/Core/ui.html-view.index.ios.swift +4 -4
  156. package/kit-apple/Sources/NativeScriptKit/Core/ui.image.image-common.swift +2 -2
  157. package/kit-apple/Sources/NativeScriptKit/Core/ui.image.index.ios.swift +4 -4
  158. package/kit-apple/Sources/NativeScriptKit/Core/ui.label.index.ios.swift +4 -4
  159. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.absolute-layout.index.ios.swift +4 -4
  160. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.dock-layout.index.ios.swift +4 -4
  161. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.flexbox-layout.index.ios.swift +3 -3
  162. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.grid-layout.index.ios.swift +4 -4
  163. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.stack-layout.index.ios.swift +4 -4
  164. package/kit-apple/Sources/NativeScriptKit/Core/ui.layouts.wrap-layout.index.ios.swift +4 -4
  165. package/kit-apple/Sources/NativeScriptKit/Core/ui.list-view.index.ios.swift +3 -3
  166. package/kit-apple/Sources/NativeScriptKit/Core/ui.page.index.ios.swift +4 -4
  167. package/kit-apple/Sources/NativeScriptKit/Core/ui.repeater.index.swift +10 -6
  168. package/kit-apple/Sources/NativeScriptKit/Core/ui.scroll-view.index.ios.swift +4 -4
  169. package/kit-apple/Sources/NativeScriptKit/Core/ui.split-view.index.ios.swift +4 -4
  170. package/kit-apple/Sources/NativeScriptKit/Core/ui.styling.background.ios.swift +1 -1
  171. package/kit-apple/Sources/NativeScriptKit/Core/ui.tab-view.index.ios.swift +4 -4
  172. package/kit-apple/Sources/NativeScriptKit/Core/ui.text-base.formatted-string.swift +2 -1
  173. package/kit-apple/Sources/NativeScriptKit/Core/utils.common.swift +9 -9
  174. package/kit-apple/Sources/NativeScriptKit/Core/utils.layout-helper.index.ios.swift +10 -10
  175. package/kit-apple/Sources/NativeScriptKit/CoreBridge.swift +67 -1
  176. package/kit-apple/Sources/NativeScriptKit/Runtime/Lowering.swift +4 -0
  177. package/kit-apple/Sources/NativeScriptKit/Runtime/Prototypes.swift +25 -0
  178. package/kit-apple/Sources/NativeScriptKit/Runtime/RegExp.swift +6 -0
  179. package/kit-apple/Sources/NativeScriptKit/Signals.swift +20 -2
  180. package/package.json +2 -1
  181. package/kit-apple/Sources/NativeScriptKit/Core/Object_toString_charAt_charCodeAt_concat_indexOf_lastIndexOf_and_44_more_fc25df.swift +0 -481
@@ -515,13 +515,13 @@ open class SplitView: SplitViewBase {
515
515
  #sourceLocation(file:"@nativescript/core/ui.split-view.index.ios.ts",line:215)
516
516
  try super.onMeasure(widthMeasureSpec, heightMeasureSpec)
517
517
  #sourceLocation(file:"@nativescript/core/ui.split-view.index.ios.ts",line:217)
518
- let width: Double = NativeScriptKit.layout.getMeasureSpecSize(widthMeasureSpec)
518
+ let width: Double = try NativeScriptKit.layout.getMeasureSpecSize(widthMeasureSpec)
519
519
  #sourceLocation(file:"@nativescript/core/ui.split-view.index.ios.ts",line:218)
520
- let widthMode: Double = NativeScriptKit.layout.getMeasureSpecMode(widthMeasureSpec)
520
+ let widthMode: Double = try NativeScriptKit.layout.getMeasureSpecMode(widthMeasureSpec)
521
521
  #sourceLocation(file:"@nativescript/core/ui.split-view.index.ios.ts",line:219)
522
- let height: Double = NativeScriptKit.layout.getMeasureSpecSize(heightMeasureSpec)
522
+ let height: Double = try NativeScriptKit.layout.getMeasureSpecSize(heightMeasureSpec)
523
523
  #sourceLocation(file:"@nativescript/core/ui.split-view.index.ios.ts",line:220)
524
- let heightMode: Double = NativeScriptKit.layout.getMeasureSpecMode(heightMeasureSpec)
524
+ let heightMode: Double = try NativeScriptKit.layout.getMeasureSpecMode(heightMeasureSpec)
525
525
  #sourceLocation(file:"@nativescript/core/ui.split-view.index.ios.ts",line:222)
526
526
  let horizontal: Double =
527
527
  self.effectivePaddingLeft + self.effectivePaddingRight + self.effectiveBorderLeftWidth
@@ -272,7 +272,7 @@ public enum ios__background_ios {
272
272
  return jsTruthy(__v_2) ? try jsUnwrap(imageSource, "ios").ios : nil
273
273
  }()))
274
274
  }
275
- } else if Core_utils_common.isFileOrResourcePath(imageURI) {
275
+ } else if try Core_utils_common.isFileOrResourcePath(imageURI) {
276
276
  #sourceLocation(file:"@nativescript/core/ui.styling.background.ios.ts",line:207)
277
277
  let imageSource: ImageSource? = try ImageSource.fromFileOrResourceSync(imageURI)
278
278
  #sourceLocation(file:"@nativescript/core/ui.styling.background.ios.ts",line:208)
@@ -1138,13 +1138,13 @@ open class TabView: TabViewBase {
1138
1138
  #sourceLocation()
1139
1139
  open override func onMeasure(_ widthMeasureSpec: Double, _ heightMeasureSpec: Double) throws {
1140
1140
  #sourceLocation(file:"@nativescript/core/ui.tab-view.index.ios.ts",line:450)
1141
- let width: Double = NativeScriptKit.layout.getMeasureSpecSize(widthMeasureSpec)
1141
+ let width: Double = try NativeScriptKit.layout.getMeasureSpecSize(widthMeasureSpec)
1142
1142
  #sourceLocation(file:"@nativescript/core/ui.tab-view.index.ios.ts",line:451)
1143
- let widthMode: Double = NativeScriptKit.layout.getMeasureSpecMode(widthMeasureSpec)
1143
+ let widthMode: Double = try NativeScriptKit.layout.getMeasureSpecMode(widthMeasureSpec)
1144
1144
  #sourceLocation(file:"@nativescript/core/ui.tab-view.index.ios.ts",line:453)
1145
- let height: Double = NativeScriptKit.layout.getMeasureSpecSize(heightMeasureSpec)
1145
+ let height: Double = try NativeScriptKit.layout.getMeasureSpecSize(heightMeasureSpec)
1146
1146
  #sourceLocation(file:"@nativescript/core/ui.tab-view.index.ios.ts",line:454)
1147
- let heightMode: Double = NativeScriptKit.layout.getMeasureSpecMode(heightMeasureSpec)
1147
+ let heightMode: Double = try NativeScriptKit.layout.getMeasureSpecMode(heightMeasureSpec)
1148
1148
  #sourceLocation(file:"@nativescript/core/ui.tab-view.index.ios.ts",line:456)
1149
1149
  let widthAndState: Double = View.resolveSizeAndState(width, width, widthMode, 0)
1150
1150
  #sourceLocation(file:"@nativescript/core/ui.tab-view.index.ios.ts",line:457)
@@ -661,7 +661,8 @@ open class FormattedString: ViewBase {
661
661
  case 6:
662
662
  switch key {
663
663
  case "_spans":
664
- self._spans = (newValue as? ObservableArray)
664
+ self._spans = jsUnlessNullish(
665
+ newValue, { (jsFlat($0) as? ObservableArray) ?? ObservableArray(jsObject: $0) })
665
666
  return
666
667
  default: break
667
668
  }
@@ -28,11 +28,11 @@ public enum Core_utils_common {
28
28
  return try jsReplace(source, jsObjectRequired(escapeRegex), "\\$&")
29
29
  }
30
30
  #sourceLocation()
31
- public static func convertString(_ value: Any?) -> Any? {
31
+ public static func convertString(_ value: Any?) throws -> Any? {
32
32
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:35)
33
33
  var result: Any? = nil
34
34
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:37)
35
- if !Core_utils_types.isString(value) || jsStringEquals(jsTrim(jsLenientString(value)), "") {
35
+ if try !Core_utils_types.isString(value) || jsStringEquals(jsTrim(jsLenientString(value)), "") {
36
36
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:38)
37
37
  result = value
38
38
  } else {
@@ -95,9 +95,9 @@ public enum Core_utils_common {
95
95
  return moduleName
96
96
  }
97
97
  #sourceLocation()
98
- public static func isFileOrResourcePath(_ path: String) -> Bool {
98
+ public static func isFileOrResourcePath(_ path: String) throws -> Bool {
99
99
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:86)
100
- if !Core_utils_types.isString(path) {
100
+ if try !Core_utils_types.isString(path) {
101
101
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:87)
102
102
  return false
103
103
  }
@@ -108,9 +108,9 @@ public enum Core_utils_common {
108
108
  || jsIndexOf(path, Core_utils_common.SYSTEM_PREFIX, nil) == 0)
109
109
  }
110
110
  #sourceLocation()
111
- public static func isFontIconURI(_ uri: String) -> Bool {
111
+ public static func isFontIconURI(_ uri: String) throws -> Bool {
112
112
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:99)
113
- if !Core_utils_types.isString(uri) {
113
+ if try !Core_utils_types.isString(uri) {
114
114
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:100)
115
115
  return false
116
116
  }
@@ -118,9 +118,9 @@ public enum Core_utils_common {
118
118
  return jsStartsWith(jsTrim(uri), Core_utils_common.FONT_PREFIX, nil)
119
119
  }
120
120
  #sourceLocation()
121
- public static func isSystemURI(_ uri: String) -> Bool {
121
+ public static func isSystemURI(_ uri: String) throws -> Bool {
122
122
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:106)
123
- if !Core_utils_types.isString(uri) {
123
+ if try !Core_utils_types.isString(uri) {
124
124
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:107)
125
125
  return false
126
126
  }
@@ -130,7 +130,7 @@ public enum Core_utils_common {
130
130
  #sourceLocation()
131
131
  public static func isDataURI(_ uri: String) throws -> Bool {
132
132
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:113)
133
- if !Core_utils_types.isString(uri) {
133
+ if try !Core_utils_types.isString(uri) {
134
134
  #sourceLocation(file:"@nativescript/core/utils.common.ts",line:114)
135
135
  return false
136
136
  }
@@ -25,19 +25,19 @@ public enum layout {
25
25
  public static let MEASURED_STATE_TOO_SMALL: Double = 16_777_216
26
26
  public static let MEASURED_STATE_MASK: Double = 4_278_190_080
27
27
  public static let MEASURED_SIZE_MASK: Double = 16_777_215
28
- public static func getMode(_ mode: Double) -> String {
28
+ public static func getMode(_ mode: Double) throws -> String {
29
29
  #sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:30)
30
- return Core_utils_layout_helper_layout_helper_common.getMode(mode)
30
+ return try Core_utils_layout_helper_layout_helper_common.getMode(mode)
31
31
  }
32
32
  #sourceLocation()
33
- public static func getMeasureSpecMode(_ spec: Double) -> Double {
33
+ public static func getMeasureSpecMode(_ spec: Double) throws -> Double {
34
34
  #sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:34)
35
- return Core_utils_layout_helper_layout_helper_common.getMeasureSpecMode(spec)
35
+ return try Core_utils_layout_helper_layout_helper_common.getMeasureSpecMode(spec)
36
36
  }
37
37
  #sourceLocation()
38
- public static func getMeasureSpecSize(_ spec: Double) -> Double {
38
+ public static func getMeasureSpecSize(_ spec: Double) throws -> Double {
39
39
  #sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:38)
40
- return Core_utils_layout_helper_layout_helper_common.getMeasureSpecSize(spec)
40
+ return try Core_utils_layout_helper_layout_helper_common.getMeasureSpecSize(spec)
41
41
  }
42
42
  #sourceLocation()
43
43
  public static func makeMeasureSpec(_ size: Double, _ mode: Double) -> Double {
@@ -67,9 +67,9 @@ public enum layout {
67
67
  return try value / Core_utils_layout_helper_index.getMainScreenScale()
68
68
  }
69
69
  #sourceLocation()
70
- public static func round(_ value: Double) -> Double {
70
+ public static func round(_ value: Double) throws -> Double {
71
71
  #sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:62)
72
- return Core_utils_layout_helper_layout_helper_common.round(value)
72
+ return try Core_utils_layout_helper_layout_helper_common.round(value)
73
73
  }
74
74
  #sourceLocation()
75
75
  public static func measureNativeView(
@@ -99,9 +99,9 @@ public enum layout {
99
99
  return nativeSize
100
100
  }
101
101
  #sourceLocation()
102
- public static func measureSpecToString(_ measureSpec: Double) -> String {
102
+ public static func measureSpecToString(_ measureSpec: Double) throws -> String {
103
103
  #sourceLocation(file:"@nativescript/core/utils.layout-helper.index.ios.ts",line:79)
104
- return Core_utils_layout_helper_layout_helper_common.measureSpecToString(measureSpec)
104
+ return try Core_utils_layout_helper_layout_helper_common.measureSpecToString(measureSpec)
105
105
  }
106
106
  }
107
107
 
@@ -5,6 +5,49 @@ import UIKit
5
5
  // a framework's renderer adds them, properties set as the XML builder
6
6
  // sets them, errors reported as core reports what nothing catches.
7
7
 
8
+ /// Registered `ViewClassMeta` (`insertChild` / `removeChild`) hooks from `registerElement(tag, () => Class, meta)`.
9
+ private enum ViewMetaRegistry {
10
+ struct Entry {
11
+ let insertChild: Any?
12
+ let removeChild: Any?
13
+ }
14
+ private static var byName: [String: Entry] = [:]
15
+ private static var byType: [ObjectIdentifier: Entry] = [:]
16
+
17
+ static func register(_ tag: String, _ resolver: Any?, _ meta: Any?) {
18
+ guard let m = jsFlat(meta), !jsIsNullish(m) else { return }
19
+ let insertChild = (try? jsGet(m, "insertChild")).flatMap { jsIsNullish($0) ? nil : $0 }
20
+ let removeChild = (try? jsGet(m, "removeChild")).flatMap { jsIsNullish($0) ? nil : $0 }
21
+ guard insertChild != nil || removeChild != nil else { return }
22
+ let entry = Entry(insertChild: insertChild, removeChild: removeChild)
23
+ byName[tag.lowercased()] = entry
24
+ if let resolver = jsFlat(resolver), !jsIsNullish(resolver), let ctor = try? jsCall(resolver) {
25
+ if let cls = ctor as? Any.Type {
26
+ byType[ObjectIdentifier(cls)] = entry
27
+ byName[String(describing: cls).lowercased()] = entry
28
+ }
29
+ let name = jsConstructorName(ctor)
30
+ if !name.isEmpty, name != "Object" { byName[name.lowercased()] = entry }
31
+ }
32
+ }
33
+
34
+ static func meta(for view: ViewBase) -> Entry? {
35
+ var cls: AnyClass? = type(of: view)
36
+ while let cur = cls {
37
+ if let hit = byType[ObjectIdentifier(cur)] { return hit }
38
+ if let hit = byName[String(describing: cur).lowercased()] { return hit }
39
+ cls = class_getSuperclass(cur)
40
+ }
41
+ let name = jsConstructorName(view).lowercased()
42
+ return byName[name]
43
+ }
44
+ }
45
+
46
+ /// Registers a plugin element's `ViewClassMeta` (`insertChild` / `removeChild`) so compiled templates attach children through it.
47
+ public func kitRegisterViewMeta(_ tag: String, _ resolver: Any?, _ meta: Any?) {
48
+ ViewMetaRegistry.register(tag, resolver, meta)
49
+ }
50
+
8
51
  /// The template children of a container: its static views and its regions, in template order.
9
52
  final class TemplateChildren: RegionHost {
10
53
  nonisolated deinit {}
@@ -34,7 +77,30 @@ final class TemplateChildren: RegionHost {
34
77
  guard let owner else { return }
35
78
  let next: [ViewBase] = parts.flatMap(\.views)
36
79
  jsReport {
37
- if let layout = owner as? LayoutBase {
80
+ if let meta = ViewMetaRegistry.meta(for: owner) {
81
+ let kept = Set(next.map(ObjectIdentifier.init))
82
+ var active: [ViewBase] = []
83
+ for old in placed {
84
+ if kept.contains(ObjectIdentifier(old)) {
85
+ active.append(old)
86
+ } else if let remove = meta.removeChild {
87
+ _ = try jsCall(remove, owner, old)
88
+ }
89
+ }
90
+ let keptOrder = next.filter { view in active.contains(where: { $0 === view }) }
91
+ if active.count == keptOrder.count, zip(active, keptOrder).contains(where: { $0 !== $1 }), let remove = meta.removeChild {
92
+ for old in active { _ = try jsCall(remove, owner, old) }
93
+ active = []
94
+ }
95
+ var activeIds = Set(active.map(ObjectIdentifier.init))
96
+ if let insert = meta.insertChild {
97
+ for (index, view) in next.enumerated() where !activeIds.contains(ObjectIdentifier(view)) {
98
+ let nextSibling = next.dropFirst(index + 1).first { activeIds.contains(ObjectIdentifier($0)) }
99
+ _ = try jsCall(insert, owner, view, nextSibling as Any?)
100
+ activeIds.insert(ObjectIdentifier(view))
101
+ }
102
+ }
103
+ } else if let layout = owner as? LayoutBase {
38
104
  let kept = Set(next.map(ObjectIdentifier.init))
39
105
  for old in placed where !kept.contains(ObjectIdentifier(old)) {
40
106
  if let view = old as? View { try layout.removeChild(view) }
@@ -339,6 +339,10 @@ public func jsFromCharCode(codes: [Double]) -> String {
339
339
  }
340
340
 
341
341
  public func jsFromCodePoint(_ points: Double...) throws -> String {
342
+ try jsFromCodePoint(codes: points)
343
+ }
344
+
345
+ public func jsFromCodePoint(codes points: [Double]) throws -> String {
342
346
  var units: [UInt16] = []
343
347
  for p in points {
344
348
  guard p >= 0, p <= 0x10FFFF, p.rounded(.towardZero) == p else { throw JSException(JSRangeError("Invalid code point \(jsNumberToString(p))")) }
@@ -112,10 +112,24 @@ public enum JSPrototypes {
112
112
  return p
113
113
  }
114
114
 
115
+ /// Custom prototypes assigned via `Object.setPrototypeOf(obj, proto)`.
116
+ private static var customPrototypes: [ObjectIdentifier: Any?] = [:]
117
+
118
+ /// `Object.setPrototypeOf(target, proto)`.
119
+ static func setPrototype(object o: AnyObject, to proto: Any?) {
120
+ tableLock.lock()
121
+ customPrototypes[ObjectIdentifier(o)] = proto
122
+ tableLock.unlock()
123
+ }
124
+
115
125
  /// `Object.getPrototypeOf` of a plain object: a class's prototype leads to its superclass's.
116
126
  static func prototypeOf(object o: JSObject) -> Any? {
117
127
  if o === objectPrototype { return jsNull }
118
128
  tableLock.lock()
129
+ if let custom = customPrototypes[ObjectIdentifier(o)] {
130
+ tableLock.unlock()
131
+ return custom
132
+ }
119
133
  let cls: AnyClass? = owners[ObjectIdentifier(o)]
120
134
  tableLock.unlock()
121
135
  if let cls, let superclass = class_getSuperclass(cls), !isRoot(superclass) { return of(superclass) }
@@ -277,6 +291,17 @@ struct JSHolding {
277
291
  let setter: ((Any?, Any?) throws -> Void)?
278
292
  }
279
293
 
294
+ /// `Object.setPrototypeOf(target, proto)`.
295
+ public func jsSetPrototypeOf(_ target: Any?, _ proto: Any?) throws -> Any? {
296
+ guard let v = jsFlat(target), !(v is JSNull) else { throw JSException(JSTypeError("Object.setPrototypeOf called on null or undefined")) }
297
+ let p = jsFlat(proto)
298
+ if let p, !(p is JSNull), !(p is JSObject), !(p is JSDynamic), !(p is AnyClass) { throw JSException(JSTypeError("Object prototype may only be an Object or null")) }
299
+ let targetProto: Any? = (p == nil || p is JSNull) ? jsNull : p
300
+ if let o = v as? JSObject { o.jsPrototype = (p == nil || p is JSNull) ? nil : p }
301
+ if let obj = v as AnyObject? { JSPrototypes.setPrototype(object: obj, to: targetProto) }
302
+ return target
303
+ }
304
+
280
305
  /// `Object.getPrototypeOf(value)`.
281
306
  public func jsGetPrototypeOf(_ value: Any?) throws -> Any? {
282
307
  guard let v = jsFlat(value), !(v is JSNull) else { throw JSException(JSTypeError("Cannot convert undefined or null to object")) }
@@ -485,6 +485,12 @@ public func jsReplaceAll(_ s: String, _ re: JSRegExp, _ replacement: String) thr
485
485
  return jsReplace(s, re, replacement)
486
486
  }
487
487
 
488
+ /// `s.replaceAll(re, (match, ...groups) => …)`: the expression must be global.
489
+ public func jsReplaceAll(_ s: String, _ re: JSRegExp, _ replacer: (JSMatch) throws -> String) throws -> String {
490
+ guard re.global else { throw JSException(value: JSTypeError("replaceAll must be called with a global RegExp")) }
491
+ return try jsReplace(s, re, replacer)
492
+ }
493
+
488
494
  /// RegExp.prototype[@@replace]: every match is found before the first replacement is computed.
489
495
  private func replaceMatches(_ subject: JSRegExpSubject, _ re: JSRegExp, _ replacement: ([Int]) throws -> String) rethrows -> String {
490
496
  var results: [[Int]] = []
@@ -419,7 +419,7 @@ protocol MemoReader: AnyObject {
419
419
  /// A computed value: kept, so reads share it, until a value it read has a new version; then it is computed again on
420
420
  /// the next read. A result `same` as the kept one keeps the kept one and its version. Nothing it read holds it: a
421
421
  /// reader asks for its value.
422
- public final class Memo<T>: Versioned, MemoReader {
422
+ public final class Memo<T>: Versioned, MemoReader, JSDynamic {
423
423
  nonisolated deinit {}
424
424
  private let compute: () throws -> T
425
425
  private let same: (T, T) throws -> Bool
@@ -483,6 +483,13 @@ public final class Memo<T>: Versioned, MemoReader {
483
483
  }
484
484
 
485
485
  public var value: T { jsReportedOrZero(read) }
486
+
487
+ public var jsKeys: [String] { ["value"] }
488
+ public var jsClassName: String? { nil }
489
+ public subscript(jsKey key: String) -> Any? {
490
+ get { key == "value" ? value : nil }
491
+ set {}
492
+ }
486
493
  }
487
494
 
488
495
  /// The `equal` of a signal's options, read by name; `default` when they give none.
@@ -497,7 +504,7 @@ public func jsReportingEquals<T>(_ equal: @escaping (T, T) throws -> Bool) -> (T
497
504
  }
498
505
 
499
506
  /// A value that notifies the effects that read it.
500
- public final class Signal<T>: Versioned, Holding {
507
+ public final class Signal<T>: Versioned, Holding, JSDynamic {
501
508
  nonisolated deinit {}
502
509
  private enum Backing {
503
510
  case stored(T)
@@ -742,6 +749,17 @@ public final class Signal<T>: Versioned, Holding {
742
749
  }
743
750
 
744
751
  func unsubscribe(_ subscriber: Subscriber) { subscribers[ObjectIdentifier(subscriber)] = nil }
752
+
753
+ public var jsKeys: [String] { ["value"] }
754
+ public var jsClassName: String? { nil }
755
+ public subscript(jsKey key: String) -> Any? {
756
+ get { key == "value" ? value : nil }
757
+ set {
758
+ guard key == "value" else { return }
759
+ let unwrapped: Any? = jsIsNullish(newValue) ? nil : newValue
760
+ if let v = unwrapped as? T { value = v }
761
+ }
762
+ }
745
763
  }
746
764
 
747
765
  /// State the handlers of a render read as it rendered (untracked reads see the last flush) until the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nstudio/nativescript-compiler",
3
- "version": "9.2.0-alpha.10",
3
+ "version": "9.2.0-alpha.12",
4
4
  "description": "NativeScript CLI plugin (`ns compile`) and compiler turning a NativeScript app into native Swift (iOS) or Kotlin (Android) with no JavaScript runtime; framework adapters (`@nstudio/nativescript-compiler-<framework>`) compile each framework.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -54,6 +54,7 @@
54
54
  "kit-android/build.gradle.kts",
55
55
  "kit-android/consumer-rules.pro",
56
56
  "kit-android/gradlew",
57
+ "kit-android/gradlew.bat",
57
58
  "kit-android/gradle/",
58
59
  "kit-android/src/",
59
60
  "kit-android/generated/",