one 2.0.0-beta.158.1 → 2.0.0-beta.161.1

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 (27) hide show
  1. package/android/src/main/java/dev/onejs/one/OneKotlinHostEvents.kt +0 -2
  2. package/android/src/main/java/dev/onejs/one/OneKotlinHostManager.kt +0 -8
  3. package/android/src/main/java/dev/onejs/one/OneKotlinHostView.kt +82 -53
  4. package/cpp/HybridOneStorage.cpp +7 -4
  5. package/dist/cjs/platform/native-source/view.native.cjs +25 -23
  6. package/dist/cjs/platform/native-source/view.native.js +25 -23
  7. package/dist/cjs/platform/native-source/view.native.js.map +1 -1
  8. package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.cjs +0 -2
  9. package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.native.cjs +0 -2
  10. package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.native.js +0 -2
  11. package/dist/cjs/platform/specs/OneKotlinHostNativeComponent.native.js.map +2 -2
  12. package/dist/esm/platform/native-source/view.native.js +27 -25
  13. package/dist/esm/platform/native-source/view.native.js.map +1 -1
  14. package/dist/esm/platform/specs/OneKotlinHostNativeComponent.mjs +0 -2
  15. package/dist/esm/platform/specs/OneKotlinHostNativeComponent.mjs.map +2 -2
  16. package/dist/esm/platform/specs/OneKotlinHostNativeComponent.native.js +0 -2
  17. package/dist/esm/platform/specs/OneKotlinHostNativeComponent.native.js.map +2 -2
  18. package/package.json +10 -10
  19. package/src/platform/native-source/view.native.tsx +32 -42
  20. package/src/platform/native-source/viewTypes.ts +3 -1
  21. package/src/platform/specs/OneKotlinHostNativeComponent.ts +5 -4
  22. package/types/platform/native-source/view.native.d.ts +1 -1
  23. package/types/platform/native-source/view.native.d.ts.map +1 -1
  24. package/types/platform/native-source/viewTypes.d.ts +4 -1
  25. package/types/platform/native-source/viewTypes.d.ts.map +1 -1
  26. package/types/platform/specs/OneKotlinHostNativeComponent.d.ts +0 -3
  27. package/types/platform/specs/OneKotlinHostNativeComponent.d.ts.map +1 -1
@@ -26,7 +26,6 @@ internal class OneKotlinHostSizeEvent(
26
26
  viewTag: Int,
27
27
  private val width: Double,
28
28
  private val height: Double,
29
- private val intrinsicWidth: Boolean,
30
29
  ) : Event<OneKotlinHostSizeEvent>(surfaceId, viewTag) {
31
30
  override fun getEventName(): String = "topHostSizeChange"
32
31
 
@@ -36,6 +35,5 @@ internal class OneKotlinHostSizeEvent(
36
35
  Arguments.createMap().apply {
37
36
  putDouble("width", width)
38
37
  putDouble("height", height)
39
- putBoolean("intrinsicWidth", intrinsicWidth)
40
38
  }
41
39
  }
@@ -59,14 +59,6 @@ class OneKotlinHostManager :
59
59
  view.stageContractHash(value)
60
60
  }
61
61
 
62
- override fun setIntrinsicWidth(view: OneKotlinHostView, value: Boolean) {
63
- view.setIntrinsicWidth(value)
64
- }
65
-
66
- override fun setIntrinsicHeight(view: OneKotlinHostView, value: Boolean) {
67
- view.setIntrinsicHeight(value)
68
- }
69
-
70
62
  override fun setProps(view: OneKotlinHostView, value: String?) {
71
63
  view.stageProps(value)
72
64
  }
@@ -5,8 +5,11 @@ import android.view.ViewGroup
5
5
  import androidx.compose.runtime.getValue
6
6
  import androidx.compose.runtime.mutableStateOf
7
7
  import androidx.compose.runtime.setValue
8
+ import androidx.compose.ui.layout.Layout
8
9
  import androidx.compose.ui.platform.ComposeView
9
10
  import androidx.compose.ui.platform.ViewCompositionStrategy
11
+ import androidx.compose.ui.unit.constrainHeight
12
+ import androidx.compose.ui.unit.constrainWidth
10
13
  import com.facebook.react.uimanager.UIManagerHelper
11
14
  import com.facebook.react.views.view.ReactViewGroup
12
15
 
@@ -31,15 +34,13 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
31
34
  private var committedContractHash by mutableStateOf("")
32
35
  private var committedProps by mutableStateOf("{}")
33
36
 
34
- private var intrinsicWidth = false
35
- private var intrinsicHeight = false
36
- private var measuresIntrinsicWidth: Boolean? = null
37
- private var hasYogaLayout = false
38
37
  private val contentLayout = Runnable { layoutComposeContent() }
39
38
 
40
- private var reportedIntrinsicWidth: Boolean? = null
41
39
  private var reportedWidth = -1.0
42
40
  private var reportedHeight = -1.0
41
+ private var observedWidth = -1
42
+ private var observedHeight = -1
43
+ private var measuringContent = false
43
44
 
44
45
  init {
45
46
  clipChildren = false
@@ -57,13 +58,38 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
57
58
  "native view $source.$view changed (contract hash mismatch: expected $hash, got ${dispatch.contractHash}); rebuild the app"
58
59
  )
59
60
  }
60
- dispatch.Content(
61
- view = view,
62
- propsJson = props,
63
- emit = { eventName, eventArgs ->
64
- onHostEvent(source, view, eventName, eventArgs)
61
+ Layout(
62
+ content = {
63
+ dispatch.Content(
64
+ view = view,
65
+ propsJson = props,
66
+ emit = { eventName, eventArgs ->
67
+ onHostEvent(source, view, eventName, eventArgs)
68
+ },
69
+ )
65
70
  },
66
- )
71
+ ) { measurables, constraints ->
72
+ // yoga owns the outer minimums; content keeps its natural size.
73
+ val contentConstraints = constraints.copy(minWidth = 0, minHeight = 0)
74
+ val placeables = measurables.map { it.measure(contentConstraints) }
75
+ val contentWidth = placeables.maxOfOrNull { it.width } ?: 0
76
+ val contentHeight = placeables.maxOfOrNull { it.height } ?: 0
77
+ if (source == committedSource && view == committedView) {
78
+ val changed = contentWidth != observedWidth || contentHeight != observedHeight
79
+ observedWidth = contentWidth
80
+ observedHeight = contentHeight
81
+ if (changed && !measuringContent && isAttachedToWindow) {
82
+ removeCallbacks(contentLayout)
83
+ post(contentLayout)
84
+ }
85
+ }
86
+ layout(
87
+ constraints.constrainWidth(contentWidth),
88
+ constraints.constrainHeight(contentHeight),
89
+ ) {
90
+ placeables.forEach { it.placeRelativeWithLayer(0, 0) }
91
+ }
92
+ }
67
93
  }
68
94
  }
69
95
  }
@@ -94,6 +120,8 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
94
120
  if (sourceOrViewChanged) {
95
121
  reportedWidth = -1.0
96
122
  reportedHeight = -1.0
123
+ observedWidth = -1
124
+ observedHeight = -1
97
125
  }
98
126
 
99
127
  if (sourceOrViewChanged || nextHash != committedContractHash || nextProps != committedProps) {
@@ -105,22 +133,9 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
105
133
  }
106
134
  }
107
135
 
108
- internal fun setIntrinsicWidth(value: Boolean) {
109
- if (intrinsicWidth == value) return
110
- intrinsicWidth = value
111
- measuresIntrinsicWidth = null
112
- requestLayout()
113
- }
114
-
115
- internal fun setIntrinsicHeight(value: Boolean) {
116
- if (intrinsicHeight == value) return
117
- intrinsicHeight = value
118
- requestLayout()
119
- }
120
-
121
136
  override fun requestLayout() {
122
137
  super.requestLayout()
123
- if (hasYogaLayout) {
138
+ if (isAttachedToWindow) {
124
139
  removeCallbacks(contentLayout)
125
140
  post(contentLayout)
126
141
  }
@@ -146,15 +161,13 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
146
161
  sizeView: String,
147
162
  widthPx: Int,
148
163
  heightPx: Int,
149
- widthIsIntrinsic: Boolean,
150
164
  ) {
151
165
  if (!isAttachedToWindow || sizeSource != committedSource || sizeView != committedView) return
152
166
  val density = resources.displayMetrics.density.toDouble()
153
167
  if (density <= 0.0) return
154
168
  val widthDp = widthPx / density
155
169
  val heightDp = heightPx / density
156
- if (widthDp == reportedWidth && heightDp == reportedHeight && widthIsIntrinsic == reportedIntrinsicWidth) return
157
- reportedIntrinsicWidth = widthIsIntrinsic
170
+ if (widthDp == reportedWidth && heightDp == reportedHeight) return
158
171
  reportedWidth = widthDp
159
172
  reportedHeight = heightDp
160
173
  val reactContext = UIManagerHelper.getReactContext(this) ?: return
@@ -165,14 +178,12 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
165
178
  viewTag = id,
166
179
  width = widthDp,
167
180
  height = heightDp,
168
- intrinsicWidth = widthIsIntrinsic,
169
181
  )
170
182
  )
171
183
  }
172
184
 
173
185
  override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
174
186
  super.onLayout(changed, left, top, right, bottom)
175
- hasYogaLayout = true
176
187
  layoutComposeContent()
177
188
  }
178
189
 
@@ -182,25 +193,46 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
182
193
  }
183
194
 
184
195
  private fun layoutComposeContent() {
185
- if (!hasYogaLayout || !composeView.isAttachedToWindow || committedSource.isEmpty() || committedView.isEmpty()) return
186
- // a nonzero initial yoga width can come from the parent's default stretch.
187
- val widthIsIntrinsic = measuresIntrinsicWidth ?: (intrinsicWidth && width == 0).also {
188
- measuresIntrinsicWidth = it
196
+ if (!composeView.isAttachedToWindow || committedSource.isEmpty() || committedView.isEmpty()) return
197
+ measuringContent = true
198
+ try {
199
+ // measure content before letting yoga apply the outer constraints.
200
+ measureComposeContent(
201
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
202
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
203
+ )
204
+ val naturalWidth = composeView.measuredWidth
205
+ var naturalHeight = composeView.measuredHeight
206
+ if (width > 0 && width != naturalWidth) {
207
+ measureComposeContent(
208
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
209
+ MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
210
+ )
211
+ naturalHeight = composeView.measuredHeight
212
+ }
213
+ onContentSizeChanged(
214
+ committedSource,
215
+ committedView,
216
+ naturalWidth,
217
+ naturalHeight,
218
+ )
219
+ measureComposeContent(
220
+ MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
221
+ MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
222
+ )
223
+ composeView.layout(0, 0, width, height)
224
+ } finally {
225
+ measuringContent = false
189
226
  }
190
- composeView.measure(
191
- if (widthIsIntrinsic) MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
192
- else MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
193
- if (intrinsicHeight) MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED)
194
- else MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY),
195
- )
196
- composeView.layout(0, 0, composeView.measuredWidth, composeView.measuredHeight)
197
- onContentSizeChanged(
198
- committedSource,
199
- committedView,
200
- composeView.measuredWidth,
201
- composeView.measuredHeight,
202
- widthIsIntrinsic,
203
- )
227
+ }
228
+
229
+ private fun measureComposeContent(widthSpec: Int, heightSpec: Int) {
230
+ // each explicit pass must update compose constraints rather than reuse android's cache.
231
+ composeView.forceLayout()
232
+ for (index in 0 until composeView.childCount) {
233
+ composeView.getChildAt(index).forceLayout()
234
+ }
235
+ composeView.measure(widthSpec, heightSpec)
204
236
  }
205
237
 
206
238
  override fun onDetachedFromWindow() {
@@ -211,13 +243,10 @@ class OneKotlinHostView(context: Context) : ReactViewGroup(context) {
211
243
 
212
244
  internal fun resetForReuse() {
213
245
  removeCallbacks(contentLayout)
214
- intrinsicWidth = false
215
- intrinsicHeight = false
216
- measuresIntrinsicWidth = null
217
- hasYogaLayout = false
218
- reportedIntrinsicWidth = null
219
246
  reportedWidth = -1.0
220
247
  reportedHeight = -1.0
248
+ observedWidth = -1
249
+ observedHeight = -1
221
250
  committedSource = ""
222
251
  committedView = ""
223
252
  committedContractHash = ""
@@ -173,11 +173,12 @@ class StorageLog {
173
173
  // room for a `size` byte record that replaces `replaced` live bytes. the
174
174
  // log is only compacted when it is full: if at least half of it is dead it
175
175
  // is rewritten at twice the live size, otherwise it doubles. writes into
176
- // existing room never pay for compaction.
176
+ // existing room never pay for compaction. the snapshot still holds the
177
+ // replaced record, so the compacted log is sized to fit it and the new one.
177
178
  uint8_t* reserve(size_t size, size_t replaced) {
178
179
  if (used_ + size > capacity_) {
179
180
  size_t live = live_ - replaced + size;
180
- if (live * 2 <= used_) compact(pageAligned(live * 2));
181
+ if (live * 2 <= used_) compact(pageAligned(std::max(live * 2, live_ + size)));
181
182
  if (used_ + size > capacity_) remap(fd_, capacity_, pageAligned(std::max(capacity_ * 2, used_ + size)));
182
183
  }
183
184
  return base_ + used_;
@@ -247,13 +248,15 @@ class StorageLog {
247
248
  uint8_t op = base_[offset++];
248
249
  size_t keyStart = 0;
249
250
  size_t keySize = 0;
251
+ Slot slot{};
252
+ // the whole record parses before it touches the map, so a torn record
253
+ // leaves the entries and their live size exactly as the prior ones left them.
250
254
  if ((op != kSetOp && op != kRemoveOp) || !field(keyStart, keySize)) break;
255
+ if (op == kSetOp && !field(slot.offset, slot.size)) break;
251
256
  key.assign(reinterpret_cast<const char*>(base_ + keyStart), keySize);
252
257
  auto found = entries_.find(key);
253
258
  if (found != entries_.end()) live_ -= setSize(keySize, found->second.size);
254
259
  if (op == kSetOp) {
255
- Slot slot{};
256
- if (!field(slot.offset, slot.size)) break;
257
260
  live_ += setSize(keySize, slot.size);
258
261
  if (found != entries_.end()) {
259
262
  found->second = slot;
@@ -36,28 +36,30 @@ var import_OneKotlinHostNativeComponent = __toESM(require("../specs/OneKotlinHos
36
36
  function KotlinSourceView(param) {
37
37
  var { source, view, contractHash, props } = param;
38
38
  var [contentSize, setContentSize] = (0, import_react.useState)();
39
- var rootStyle = import_react_native.StyleSheet.flatten(props === null || props === void 0 ? void 0 : props.style);
40
- var stretchedWidth = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.width) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === "number" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === "number" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === "stretch";
41
- var stretchedHeight = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.height) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === "number" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === "number" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === "stretch";
42
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneKotlinHostNativeComponent.default, {
43
- source,
44
- view,
45
- contractHash,
46
- intrinsicWidth: !stretchedWidth,
47
- intrinsicHeight: !stretchedHeight,
48
- props: JSON.stringify(props, function(_key, value) {
49
- return typeof value === "function" ? true : value;
50
- }),
51
- onHostEvent: function(event) {
52
- var callback = props[event.nativeEvent.name];
53
- if (typeof callback === "function") callback(...JSON.parse(event.nativeEvent.args));
54
- },
55
- onHostSizeChange: function(event) {
56
- setContentSize(event.nativeEvent);
57
- },
58
- style: [contentSize && {
59
- width: stretchedWidth || !contentSize.intrinsicWidth ? void 0 : contentSize.width,
60
- height: stretchedHeight ? void 0 : contentSize.height
61
- }, props === null || props === void 0 ? void 0 : props.style]
39
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, {
40
+ style: props.style,
41
+ collapsable: false,
42
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
43
+ pointerEvents: "none",
44
+ style: contentSize
45
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneKotlinHostNativeComponent.default, {
46
+ source,
47
+ view,
48
+ contractHash,
49
+ props: JSON.stringify(props, function(_key, value) {
50
+ return typeof value === "function" ? true : value;
51
+ }),
52
+ onHostEvent: function(event) {
53
+ var callback = props[event.nativeEvent.name];
54
+ if (typeof callback === "function") callback(...JSON.parse(event.nativeEvent.args));
55
+ },
56
+ onHostSizeChange: function(event) {
57
+ setContentSize({
58
+ width: event.nativeEvent.width,
59
+ height: event.nativeEvent.height
60
+ });
61
+ },
62
+ style: import_react_native.StyleSheet.absoluteFill
63
+ })]
62
64
  });
63
65
  }
@@ -36,29 +36,31 @@ var import_OneKotlinHostNativeComponent = __toESM(require("../specs/OneKotlinHos
36
36
  function KotlinSourceView(param) {
37
37
  var { source, view, contractHash, props } = param;
38
38
  var [contentSize, setContentSize] = (0, import_react.useState)();
39
- var rootStyle = import_react_native.StyleSheet.flatten(props === null || props === void 0 ? void 0 : props.style);
40
- var stretchedWidth = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.width) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === "number" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === "number" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === "stretch";
41
- var stretchedHeight = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.height) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === "number" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === "number" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === "stretch";
42
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneKotlinHostNativeComponent.default, {
43
- source,
44
- view,
45
- contractHash,
46
- intrinsicWidth: !stretchedWidth,
47
- intrinsicHeight: !stretchedHeight,
48
- props: JSON.stringify(props, function(_key, value) {
49
- return typeof value === "function" ? true : value;
50
- }),
51
- onHostEvent: function(event) {
52
- var callback = props[event.nativeEvent.name];
53
- if (typeof callback === "function") callback(...JSON.parse(event.nativeEvent.args));
54
- },
55
- onHostSizeChange: function(event) {
56
- setContentSize(event.nativeEvent);
57
- },
58
- style: [contentSize && {
59
- width: stretchedWidth || !contentSize.intrinsicWidth ? void 0 : contentSize.width,
60
- height: stretchedHeight ? void 0 : contentSize.height
61
- }, props === null || props === void 0 ? void 0 : props.style]
39
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, {
40
+ style: props.style,
41
+ collapsable: false,
42
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
43
+ pointerEvents: "none",
44
+ style: contentSize
45
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneKotlinHostNativeComponent.default, {
46
+ source,
47
+ view,
48
+ contractHash,
49
+ props: JSON.stringify(props, function(_key, value) {
50
+ return typeof value === "function" ? true : value;
51
+ }),
52
+ onHostEvent: function(event) {
53
+ var callback = props[event.nativeEvent.name];
54
+ if (typeof callback === "function") callback(...JSON.parse(event.nativeEvent.args));
55
+ },
56
+ onHostSizeChange: function(event) {
57
+ setContentSize({
58
+ width: event.nativeEvent.width,
59
+ height: event.nativeEvent.height
60
+ });
61
+ },
62
+ style: import_react_native.StyleSheet.absoluteFill
63
+ })]
62
64
  });
63
65
  }
64
66
 
@@ -1 +1 @@
1
- {"version":3,"file":"view.native.js","names":[],"sources":["cjs/platform/native-source/view.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar view_native_exports = {};\n__export(view_native_exports, {\n KotlinSourceView: () => KotlinSourceView\n});\nmodule.exports = __toCommonJS(view_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_react = require(\"react\");\nvar import_react_native = require(\"react-native\");\nvar import_OneKotlinHostNativeComponent = __toESM(require(\"../specs/OneKotlinHostNativeComponent\"), 1);\nfunction KotlinSourceView(param) {\n var { source, view, contractHash, props } = param;\n var [contentSize, setContentSize] = (0, import_react.useState)();\n var rootStyle = import_react_native.StyleSheet.flatten(props === null || props === void 0 ? void 0 : props.style);\n var stretchedWidth = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.width) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === \"number\" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === \"number\" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === \"stretch\";\n var stretchedHeight = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.height) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === \"number\" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === \"number\" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === \"stretch\";\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneKotlinHostNativeComponent.default, {\n source,\n view,\n contractHash,\n intrinsicWidth: !stretchedWidth,\n intrinsicHeight: !stretchedHeight,\n // a callback travels as true; the composable's lambda reports its call\n props: JSON.stringify(props, function(_key, value) {\n return typeof value === \"function\" ? true : value;\n }),\n onHostEvent: function(event) {\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") callback(...JSON.parse(event.nativeEvent.args));\n },\n onHostSizeChange: function(event) {\n setContentSize(event.nativeEvent);\n },\n style: [\n contentSize && {\n width: stretchedWidth || !contentSize.intrinsicWidth ? void 0 : contentSize.width,\n height: stretchedHeight ? void 0 : contentSize.height\n },\n props === null || props === void 0 ? void 0 : props.style\n ]\n });\n}\n//# sourceMappingURL=view.native.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,WAAW,KAAK,YAAY,YAAY,SAAS,OAAO,OAAO,SAAS,aAAa,GAAG,CAAC,IAAI,CAAC,GAAG,YAKnG,cAAc,CAAC,OAAO,CAAC,IAAI,aAAa,UAAU,QAAQ,WAAW;CAAE,OAAO;CAAK,YAAY;AAAK,CAAC,IAAI,QACzG,GACF;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,sBAAsB,CAAC;AAC3B,SAAS,qBAAqB,EAC5B,wBAAwB,iBAC1B,CAAC;AACD,OAAO,UAAU,aAAa,mBAAmB;A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SAAS,OAAO;GAC3B,IAAI,WAAW,MAAM,MAAM,YAAY;GACvC,IAAI,OAAO,aAAa,YAAY,SAAS,GAAG,KAAK,MAAM,MAAM,YAAY,IAAI,CAAC;EACpF;EACA,kBAAkB,SAAS,OAAO;GAChC,eAAe,MAAM,WAAW;EAClC;EACA,OAAO,CACL,eAAe;GACb,OAAO,kBAAkB,CAAC,YAAY,iBAAiB,KAAK,IAAI,YAAY;GAC5E,QAAQ,kBAAkB,KAAK,IAAI,YAAY;EACjD,GACA,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,KACtD;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"view.native.js","names":[],"sources":["cjs/platform/native-source/view.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar view_native_exports = {};\n__export(view_native_exports, {\n KotlinSourceView: () => KotlinSourceView\n});\nmodule.exports = __toCommonJS(view_native_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_react = require(\"react\");\nvar import_react_native = require(\"react-native\");\nvar import_OneKotlinHostNativeComponent = __toESM(require(\"../specs/OneKotlinHostNativeComponent\"), 1);\nfunction KotlinSourceView(param) {\n var { source, view, contractHash, props } = param;\n var [contentSize, setContentSize] = (0, import_react.useState)();\n return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react_native.View, {\n style: props.style,\n collapsable: false,\n children: [\n /* yoga uses the natural child size while retaining parent flex and stretch. */\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {\n pointerEvents: \"none\",\n style: contentSize\n }),\n /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_OneKotlinHostNativeComponent.default, {\n source,\n view,\n contractHash,\n props: JSON.stringify(props, function(_key, value) {\n return typeof value === \"function\" ? true : value;\n }),\n onHostEvent: function(event) {\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") callback(...JSON.parse(event.nativeEvent.args));\n },\n onHostSizeChange: function(event) {\n setContentSize({\n width: event.nativeEvent.width,\n height: event.nativeEvent.height\n });\n },\n style: import_react_native.StyleSheet.absoluteFill\n })\n ]\n });\n}\n//# sourceMappingURL=view.native.js.map\n"],"mappings":";;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO;AAC1B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,S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MAAM,OAAO;IACjD,OAAO,OAAO,UAAU,aAAa,OAAO;GAC9C,CAAC;GACD,aAAa,SAAS,OAAO;IAC3B,IAAI,WAAW,MAAM,MAAM,YAAY;IACvC,IAAI,OAAO,aAAa,YAAY,SAAS,GAAG,KAAK,MAAM,MAAM,YAAY,IAAI,CAAC;GACpF;GACA,kBAAkB,SAAS,OAAO;IAChC,eAAe;KACb,OAAO,MAAM,YAAY;KACzB,QAAQ,MAAM,YAAY;IAC5B,CAAC;GACH;GACA,OAAO,oBAAoB,WAAW;EACxC,CAAC,CACH;CACF,CAAC;AACH"}
@@ -41,8 +41,6 @@ const __INTERNAL_VIEW_CONFIG = {
41
41
  view: true,
42
42
  contractHash: true,
43
43
  props: true,
44
- intrinsicWidth: true,
45
- intrinsicHeight: true,
46
44
  ...ConditionallyIgnoredEventHandlers({
47
45
  onHostEvent: true,
48
46
  onHostSizeChange: true
@@ -41,8 +41,6 @@ const __INTERNAL_VIEW_CONFIG = {
41
41
  view: true,
42
42
  contractHash: true,
43
43
  props: true,
44
- intrinsicWidth: true,
45
- intrinsicHeight: true,
46
44
  ...ConditionallyIgnoredEventHandlers({
47
45
  onHostEvent: true,
48
46
  onHostSizeChange: true
@@ -41,8 +41,6 @@ const __INTERNAL_VIEW_CONFIG = {
41
41
  view: true,
42
42
  contractHash: true,
43
43
  props: true,
44
- intrinsicWidth: true,
45
- intrinsicHeight: true,
46
44
  ...ConditionallyIgnoredEventHandlers({
47
45
  onHostEvent: true,
48
46
  onHostSizeChange: true
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/platform/specs/OneKotlinHostNativeComponent.ts"],
4
- "sourcesContent": ["// the device host for a composable imported from a react native `.kt` file:\n// the app's generated view dispatch renders it with the element's props as\n// json text, and reports each callback call back as an event.\nimport type { ViewProps } from 'react-native';\nimport type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\ntype KotlinHostEvent = Readonly<{\n name: string;\n args: string;\n}>;\ntype KotlinHostSizeEvent = Readonly<{\n width: Double;\n height: Double;\n intrinsicWidth: boolean;\n}>;\ninterface NativeProps extends ViewProps {\n // the kotlin source id the bundler derived from the imported file's path\n source: string;\n view: string;\n contractHash: string;\n props: string;\n intrinsicWidth: boolean;\n intrinsicHeight: boolean;\n onHostEvent?: DirectEventHandler<KotlinHostEvent>;\n onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nlet nativeComponentName = 'OneKotlinHost';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneKotlinHost\",\n directEventTypes: {\n topHostEvent: {\n registrationName: \"onHostEvent\"\n },\n topHostSizeChange: {\n registrationName: \"onHostSizeChange\"\n }\n },\n validAttributes: {\n source: true,\n view: true,\n contractHash: true,\n props: true,\n intrinsicWidth: true,\n intrinsicHeight: true,\n ...ConditionallyIgnoredEventHandlers({\n onHostEvent: true,\n onHostSizeChange: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,MAAM,0BAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ;AACF,IAAI,QAAQ,yDAAyD;AACrE,IAAI,sBAAsB;AACnB,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,cAAc;AAAA,MACZ,kBAAkB;AAAA,IACpB;AAAA,IACA,mBAAmB;AAAA,MACjB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,cAAc;AAAA,IACd,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,GAAG,kCAAkC;AAAA,MACnC,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AACA,IAAO,uCAAQ,wBAAwB,IAAI,qBAAqB,MAAM,sBAAsB;",
4
+ "sourcesContent": ["// the device host for a composable imported from a react native `.kt` file:\n// the app's generated view dispatch renders it with the element's props as\n// json text, and reports each callback call back as an event.\nimport type { ViewProps } from 'react-native';\nimport type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\ntype KotlinHostEvent = Readonly<{\n name: string;\n args: string;\n}>;\ntype KotlinHostSizeEvent = Readonly<{\n width: Double;\n height: Double;\n}>;\ninterface NativeProps extends ViewProps {\n // the kotlin source id the bundler derived from the imported file's path\n source: string;\n view: string;\n contractHash: string;\n props: string;\n onHostEvent?: DirectEventHandler<KotlinHostEvent>;\n onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nlet nativeComponentName = 'OneKotlinHost';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneKotlinHost\",\n directEventTypes: {\n topHostEvent: {\n registrationName: \"onHostEvent\"\n },\n topHostSizeChange: {\n registrationName: \"onHostSizeChange\"\n }\n },\n validAttributes: {\n source: true,\n view: true,\n contractHash: true,\n props: true,\n ...ConditionallyIgnoredEventHandlers({\n onHostEvent: true,\n onHostSizeChange: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,MAAM,0BAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ;AACF,IAAI,QAAQ,yDAAyD;AACrE,IAAI,sBAAsB;AACnB,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,cAAc;AAAA,MACZ,kBAAkB;AAAA,IACpB;AAAA,IACA,mBAAmB;AAAA,MACjB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,cAAc;AAAA,IACd,OAAO;AAAA,IACP,GAAG,kCAAkC;AAAA,MACnC,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AACA,IAAO,uCAAQ,wBAAwB,IAAI,qBAAqB,MAAM,sBAAsB;",
6
6
  "names": []
7
7
  }
@@ -1,34 +1,36 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useState } from "react";
3
- import { StyleSheet } from "react-native";
3
+ import { StyleSheet, View } from "react-native";
4
4
  import NativeKotlinHost from "../specs/OneKotlinHostNativeComponent.native.js";
5
5
 
6
6
  function KotlinSourceView(param) {
7
7
  var { source, view, contractHash, props } = param;
8
8
  var [contentSize, setContentSize] = useState();
9
- var rootStyle = StyleSheet.flatten(props === null || props === void 0 ? void 0 : props.style);
10
- var stretchedWidth = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.width) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === "number" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === "number" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === "stretch";
11
- var stretchedHeight = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.height) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === "number" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === "number" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === "stretch";
12
- return /* @__PURE__ */ jsx(NativeKotlinHost, {
13
- source,
14
- view,
15
- contractHash,
16
- intrinsicWidth: !stretchedWidth,
17
- intrinsicHeight: !stretchedHeight,
18
- props: JSON.stringify(props, function(_key, value) {
19
- return typeof value === "function" ? true : value;
20
- }),
21
- onHostEvent: function(event) {
22
- var callback = props[event.nativeEvent.name];
23
- if (typeof callback === "function") callback(...JSON.parse(event.nativeEvent.args));
24
- },
25
- onHostSizeChange: function(event) {
26
- setContentSize(event.nativeEvent);
27
- },
28
- style: [contentSize && {
29
- width: stretchedWidth || !contentSize.intrinsicWidth ? void 0 : contentSize.width,
30
- height: stretchedHeight ? void 0 : contentSize.height
31
- }, props === null || props === void 0 ? void 0 : props.style]
9
+ return /* @__PURE__ */ jsxs(View, {
10
+ style: props.style,
11
+ collapsable: false,
12
+ children: [/* @__PURE__ */ jsx(View, {
13
+ pointerEvents: "none",
14
+ style: contentSize
15
+ }), /* @__PURE__ */ jsx(NativeKotlinHost, {
16
+ source,
17
+ view,
18
+ contractHash,
19
+ props: JSON.stringify(props, function(_key, value) {
20
+ return typeof value === "function" ? true : value;
21
+ }),
22
+ onHostEvent: function(event) {
23
+ var callback = props[event.nativeEvent.name];
24
+ if (typeof callback === "function") callback(...JSON.parse(event.nativeEvent.args));
25
+ },
26
+ onHostSizeChange: function(event) {
27
+ setContentSize({
28
+ width: event.nativeEvent.width,
29
+ height: event.nativeEvent.height
30
+ });
31
+ },
32
+ style: StyleSheet.absoluteFill
33
+ })]
32
34
  });
33
35
  }
34
36
 
@@ -1 +1 @@
1
- {"version":3,"file":"view.native.js","names":[],"sources":["esm/platform/native-source/view.native.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useState } from \"react\";\nimport { StyleSheet } from \"react-native\";\nimport NativeKotlinHost from \"../specs/OneKotlinHostNativeComponent\";\nfunction KotlinSourceView(param) {\n var { source, view, contractHash, props } = param;\n var [contentSize, setContentSize] = useState();\n var rootStyle = StyleSheet.flatten(props === null || props === void 0 ? void 0 : props.style);\n var stretchedWidth = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.width) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === \"number\" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === \"number\" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === \"stretch\";\n var stretchedHeight = (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.height) != null || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flex) === \"number\" && rootStyle.flex > 0 || typeof (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.flexGrow) === \"number\" && rootStyle.flexGrow > 0 || (rootStyle === null || rootStyle === void 0 ? void 0 : rootStyle.alignSelf) === \"stretch\";\n return /* @__PURE__ */ _jsx(NativeKotlinHost, {\n source,\n view,\n contractHash,\n intrinsicWidth: !stretchedWidth,\n intrinsicHeight: !stretchedHeight,\n // a callback travels as true; the composable's lambda reports its call\n props: JSON.stringify(props, function(_key, value) {\n return typeof value === \"function\" ? true : value;\n }),\n onHostEvent: function(event) {\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") callback(...JSON.parse(event.nativeEvent.args));\n },\n onHostSizeChange: function(event) {\n setContentSize(event.nativeEvent);\n },\n style: [\n contentSize && {\n width: stretchedWidth || !contentSize.intrinsicWidth ? void 0 : contentSize.width,\n height: stretchedHeight ? void 0 : contentSize.height\n },\n props === null || props === void 0 ? void 0 : props.style\n ]\n });\n}\nexport {\n KotlinSourceView\n};\n//# sourceMappingURL=view.native.js.map\n"],"mappings":";;;;;;AAIA,SAAS,iBAAiB,OAAO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Y,iBAAiB,KAAK,IAAI,YAAY;GAC5E,QAAQ,kBAAkB,KAAK,IAAI,YAAY;EACjD,GACA,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,KACtD;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"view.native.js","names":[],"sources":["esm/platform/native-source/view.native.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useState } from \"react\";\nimport { StyleSheet, View } from \"react-native\";\nimport NativeKotlinHost from \"../specs/OneKotlinHostNativeComponent\";\nfunction KotlinSourceView(param) {\n var { source, view, contractHash, props } = param;\n var [contentSize, setContentSize] = useState();\n return /* @__PURE__ */ _jsxs(View, {\n style: props.style,\n collapsable: false,\n children: [\n /* yoga uses the natural child size while retaining parent flex and stretch. */\n /* @__PURE__ */ _jsx(View, {\n pointerEvents: \"none\",\n style: contentSize\n }),\n /* @__PURE__ */ _jsx(NativeKotlinHost, {\n source,\n view,\n contractHash,\n props: JSON.stringify(props, function(_key, value) {\n return typeof value === \"function\" ? true : value;\n }),\n onHostEvent: function(event) {\n var callback = props[event.nativeEvent.name];\n if (typeof callback === \"function\") callback(...JSON.parse(event.nativeEvent.args));\n },\n onHostSizeChange: function(event) {\n setContentSize({\n width: event.nativeEvent.width,\n height: event.nativeEvent.height\n });\n },\n style: StyleSheet.absoluteFill\n })\n ]\n });\n}\nexport {\n KotlinSourceView\n};\n//# sourceMappingURL=view.native.js.map\n"],"mappings":";;;;;;AAIA,SAAS,iBAAiB,OAAO;CAC/B,IAAI,EAAE,QAAQ,MAAM,cAAc,UAAU;CAC5C,IAAI,CAAC,aAAa,kBAAkB,SAAS;CAC7C,OAAuB,qBAAM,MAAM;EACjC,OAAO,MAAM;EACb,aAAa;EACb,UAAU,CAEQ,oBAAK,MAAM;GACzB,eAAe;GACf,OAAO;EACT,CAAC,GACe,oBAAK,kBAAkB;GACrC;GACA;GACA;GACA,OAAO,KAAK,UAAU,OAAO,SAAS,MAAM,OAAO;IACjD,OAAO,OAAO,UAAU,aAAa,OAAO;GAC9C,CAAC;GACD,aAAa,SAAS,OAAO;IAC3B,IAAI,WAAW,MAAM,MAAM,YAAY;IACvC,IAAI,OAAO,aAAa,YAAY,SAAS,GAAG,KAAK,MAAM,MAAM,YAAY,IAAI,CAAC;GACpF;GACA,kBAAkB,SAAS,OAAO;IAChC,eAAe;KACb,OAAO,MAAM,YAAY;KACzB,QAAQ,MAAM,YAAY;IAC5B,CAAC;GACH;GACA,OAAO,WAAW;EACpB,CAAC,CACH;CACF,CAAC;AACH"}
@@ -18,8 +18,6 @@ const __INTERNAL_VIEW_CONFIG = {
18
18
  view: true,
19
19
  contractHash: true,
20
20
  props: true,
21
- intrinsicWidth: true,
22
- intrinsicHeight: true,
23
21
  ...ConditionallyIgnoredEventHandlers({
24
22
  onHostEvent: true,
25
23
  onHostSizeChange: true
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/platform/specs/OneKotlinHostNativeComponent.ts"],
4
- "sourcesContent": ["// the device host for a composable imported from a react native `.kt` file:\n// the app's generated view dispatch renders it with the element's props as\n// json text, and reports each callback call back as an event.\nimport type { ViewProps } from 'react-native';\nimport type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\ntype KotlinHostEvent = Readonly<{\n name: string;\n args: string;\n}>;\ntype KotlinHostSizeEvent = Readonly<{\n width: Double;\n height: Double;\n intrinsicWidth: boolean;\n}>;\ninterface NativeProps extends ViewProps {\n // the kotlin source id the bundler derived from the imported file's path\n source: string;\n view: string;\n contractHash: string;\n props: string;\n intrinsicWidth: boolean;\n intrinsicHeight: boolean;\n onHostEvent?: DirectEventHandler<KotlinHostEvent>;\n onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nlet nativeComponentName = 'OneKotlinHost';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneKotlinHost\",\n directEventTypes: {\n topHostEvent: {\n registrationName: \"onHostEvent\"\n },\n topHostSizeChange: {\n registrationName: \"onHostSizeChange\"\n }\n },\n validAttributes: {\n source: true,\n view: true,\n contractHash: true,\n props: true,\n intrinsicWidth: true,\n intrinsicHeight: true,\n ...ConditionallyIgnoredEventHandlers({\n onHostEvent: true,\n onHostSizeChange: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"],
5
- "mappings": "AA0BA,MAAM,0BAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ;AACF,IAAI,QAAQ,yDAAyD;AACrE,IAAI,sBAAsB;AACnB,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,cAAc;AAAA,MACZ,kBAAkB;AAAA,IACpB;AAAA,IACA,mBAAmB;AAAA,MACjB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,cAAc;AAAA,IACd,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,GAAG,kCAAkC;AAAA,MACnC,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AACA,IAAO,uCAAQ,wBAAwB,IAAI,qBAAqB,MAAM,sBAAsB;",
4
+ "sourcesContent": ["// the device host for a composable imported from a react native `.kt` file:\n// the app's generated view dispatch renders it with the element's props as\n// json text, and reports each callback call back as an event.\nimport type { ViewProps } from 'react-native';\nimport type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\ntype KotlinHostEvent = Readonly<{\n name: string;\n args: string;\n}>;\ntype KotlinHostSizeEvent = Readonly<{\n width: Double;\n height: Double;\n}>;\ninterface NativeProps extends ViewProps {\n // the kotlin source id the bundler derived from the imported file's path\n source: string;\n view: string;\n contractHash: string;\n props: string;\n onHostEvent?: DirectEventHandler<KotlinHostEvent>;\n onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nlet nativeComponentName = 'OneKotlinHost';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneKotlinHost\",\n directEventTypes: {\n topHostEvent: {\n registrationName: \"onHostEvent\"\n },\n topHostSizeChange: {\n registrationName: \"onHostSizeChange\"\n }\n },\n validAttributes: {\n source: true,\n view: true,\n contractHash: true,\n props: true,\n ...ConditionallyIgnoredEventHandlers({\n onHostEvent: true,\n onHostSizeChange: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"],
5
+ "mappings": "AAuBA,MAAM,0BAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ;AACF,IAAI,QAAQ,yDAAyD;AACrE,IAAI,sBAAsB;AACnB,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,cAAc;AAAA,MACZ,kBAAkB;AAAA,IACpB;AAAA,IACA,mBAAmB;AAAA,MACjB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,cAAc;AAAA,IACd,OAAO;AAAA,IACP,GAAG,kCAAkC;AAAA,MACnC,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AACA,IAAO,uCAAQ,wBAAwB,IAAI,qBAAqB,MAAM,sBAAsB;",
6
6
  "names": []
7
7
  }
@@ -18,8 +18,6 @@ const __INTERNAL_VIEW_CONFIG = {
18
18
  view: true,
19
19
  contractHash: true,
20
20
  props: true,
21
- intrinsicWidth: true,
22
- intrinsicHeight: true,
23
21
  ...ConditionallyIgnoredEventHandlers({
24
22
  onHostEvent: true,
25
23
  onHostSizeChange: true
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["src/platform/specs/OneKotlinHostNativeComponent.ts"],
4
- "sourcesContent": ["// the device host for a composable imported from a react native `.kt` file:\n// the app's generated view dispatch renders it with the element's props as\n// json text, and reports each callback call back as an event.\nimport type { ViewProps } from 'react-native';\nimport type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\ntype KotlinHostEvent = Readonly<{\n name: string;\n args: string;\n}>;\ntype KotlinHostSizeEvent = Readonly<{\n width: Double;\n height: Double;\n intrinsicWidth: boolean;\n}>;\ninterface NativeProps extends ViewProps {\n // the kotlin source id the bundler derived from the imported file's path\n source: string;\n view: string;\n contractHash: string;\n props: string;\n intrinsicWidth: boolean;\n intrinsicHeight: boolean;\n onHostEvent?: DirectEventHandler<KotlinHostEvent>;\n onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nlet nativeComponentName = 'OneKotlinHost';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneKotlinHost\",\n directEventTypes: {\n topHostEvent: {\n registrationName: \"onHostEvent\"\n },\n topHostSizeChange: {\n registrationName: \"onHostSizeChange\"\n }\n },\n validAttributes: {\n source: true,\n view: true,\n contractHash: true,\n props: true,\n intrinsicWidth: true,\n intrinsicHeight: true,\n ...ConditionallyIgnoredEventHandlers({\n onHostEvent: true,\n onHostSizeChange: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"],
5
- "mappings": "AA0BA,MAAM,0BAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ;AACF,IAAI,QAAQ,yDAAyD;AACrE,IAAI,sBAAsB;AACnB,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,cAAc;AAAA,MACZ,kBAAkB;AAAA,IACpB;AAAA,IACA,mBAAmB;AAAA,MACjB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,cAAc;AAAA,IACd,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,GAAG,kCAAkC;AAAA,MACnC,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AACA,IAAO,uCAAQ,wBAAwB,IAAI,qBAAqB,MAAM,sBAAsB;",
4
+ "sourcesContent": ["// the device host for a composable imported from a react native `.kt` file:\n// the app's generated view dispatch renders it with the element's props as\n// json text, and reports each callback call back as an event.\nimport type { ViewProps } from 'react-native';\nimport type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes';\nimport codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';\ntype KotlinHostEvent = Readonly<{\n name: string;\n args: string;\n}>;\ntype KotlinHostSizeEvent = Readonly<{\n width: Double;\n height: Double;\n}>;\ninterface NativeProps extends ViewProps {\n // the kotlin source id the bundler derived from the imported file's path\n source: string;\n view: string;\n contractHash: string;\n props: string;\n onHostEvent?: DirectEventHandler<KotlinHostEvent>;\n onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>;\n}\nconst NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');\nconst {\n ConditionallyIgnoredEventHandlers\n} = require('react-native/Libraries/NativeComponent/ViewConfigIgnore');\nlet nativeComponentName = 'OneKotlinHost';\nexport const __INTERNAL_VIEW_CONFIG = {\n uiViewClassName: \"OneKotlinHost\",\n directEventTypes: {\n topHostEvent: {\n registrationName: \"onHostEvent\"\n },\n topHostSizeChange: {\n registrationName: \"onHostSizeChange\"\n }\n },\n validAttributes: {\n source: true,\n view: true,\n contractHash: true,\n props: true,\n ...ConditionallyIgnoredEventHandlers({\n onHostEvent: true,\n onHostSizeChange: true\n })\n }\n};\nexport default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"],
5
+ "mappings": "AAuBA,MAAM,0BAA0B,QAAQ,gEAAgE;AACxG,MAAM;AAAA,EACJ;AACF,IAAI,QAAQ,yDAAyD;AACrE,IAAI,sBAAsB;AACnB,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,EACjB,kBAAkB;AAAA,IAChB,cAAc;AAAA,MACZ,kBAAkB;AAAA,IACpB;AAAA,IACA,mBAAmB;AAAA,MACjB,kBAAkB;AAAA,IACpB;AAAA,EACF;AAAA,EACA,iBAAiB;AAAA,IACf,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,cAAc;AAAA,IACd,OAAO;AAAA,IACP,GAAG,kCAAkC;AAAA,MACnC,aAAa;AAAA,MACb,kBAAkB;AAAA,IACpB,CAAC;AAAA,EACH;AACF;AACA,IAAO,uCAAQ,wBAAwB,IAAI,qBAAqB,MAAM,sBAAsB;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one",
3
- "version": "2.0.0-beta.158.1",
3
+ "version": "2.0.0-beta.161.1",
4
4
  "description": "One is a React framework for web, iOS, and Android apps.",
5
5
  "license": "BSD-3-Clause",
6
6
  "sideEffects": [
@@ -218,18 +218,18 @@
218
218
  "@react-navigation/native-stack": "8.0.0-alpha.52",
219
219
  "@react-navigation/routers": "8.0.0-alpha.17",
220
220
  "@ungap/structured-clone": "^1.2.0",
221
- "@vxrn/color-scheme": "2.0.0-beta.158.1",
222
- "@vxrn/compiler": "2.0.0-beta.158.1",
223
- "@vxrn/resolve": "2.0.0-beta.158.1",
224
- "@vxrn/tslib-lite": "2.0.0-beta.158.1",
225
- "@vxrn/use-isomorphic-layout-effect": "2.0.0-beta.158.1",
226
- "@vxrn/utils": "2.0.0-beta.158.1",
227
- "@vxrn/vite-plugin-metro": "2.0.0-beta.158.1",
221
+ "@vxrn/color-scheme": "2.0.0-beta.161.1",
222
+ "@vxrn/compiler": "2.0.0-beta.161.1",
223
+ "@vxrn/resolve": "2.0.0-beta.161.1",
224
+ "@vxrn/tslib-lite": "2.0.0-beta.161.1",
225
+ "@vxrn/use-isomorphic-layout-effect": "2.0.0-beta.161.1",
226
+ "@vxrn/utils": "2.0.0-beta.161.1",
227
+ "@vxrn/vite-plugin-metro": "2.0.0-beta.161.1",
228
228
  "babel-dead-code-elimination": "1.0.10",
229
229
  "babel-plugin-module-resolver": "^5.0.2",
230
230
  "citty": "^0.1.6",
231
231
  "core-js": "^3.38.1",
232
- "create-vxrn": "2.0.0-beta.158.1",
232
+ "create-vxrn": "2.0.0-beta.161.1",
233
233
  "escape-string-regexp": "^5.0.0",
234
234
  "fast-deep-equal": "^3.1.3",
235
235
  "fast-glob": "^3.3.3",
@@ -251,7 +251,7 @@
251
251
  "tsconfig-paths": "^4",
252
252
  "use-latest-callback": "^0.2.3",
253
253
  "vite": "^8.2.2",
254
- "vxrn": "2.0.0-beta.158.1",
254
+ "vxrn": "2.0.0-beta.161.1",
255
255
  "web-streams-polyfill": "^4.3.0",
256
256
  "ws": "^8.21.0",
257
257
  "xxhashjs": "^0.2.2"
@@ -1,51 +1,41 @@
1
- // the component a device build answers `import { X } from './X.kt'` with: the
2
- // composable compiled into the app, rendered by the kotlin host view.
3
1
  import { useState } from 'react'
4
- import { StyleSheet } from 'react-native'
2
+ import { StyleSheet, View } from 'react-native'
5
3
  import NativeKotlinHost from '../specs/OneKotlinHostNativeComponent'
6
4
  import type { KotlinSourceViewProps } from './viewTypes'
7
5
 
8
6
  export type { KotlinSourceViewProps } from './viewTypes'
9
7
 
10
- export function KotlinSourceView({ source, view, contractHash, props }: KotlinSourceViewProps) {
11
- const [contentSize, setContentSize] = useState<{ width: number; height: number; intrinsicWidth: boolean }>()
12
- const rootStyle = StyleSheet.flatten((props as any)?.style)
13
-
14
- const stretchedWidth =
15
- rootStyle?.width != null ||
16
- (typeof rootStyle?.flex === 'number' && rootStyle.flex > 0) ||
17
- (typeof rootStyle?.flexGrow === 'number' && rootStyle.flexGrow > 0) ||
18
- rootStyle?.alignSelf === 'stretch'
19
-
20
- const stretchedHeight =
21
- rootStyle?.height != null ||
22
- (typeof rootStyle?.flex === 'number' && rootStyle.flex > 0) ||
23
- (typeof rootStyle?.flexGrow === 'number' && rootStyle.flexGrow > 0) ||
24
- rootStyle?.alignSelf === 'stretch'
25
-
8
+ export function KotlinSourceView({
9
+ source,
10
+ view,
11
+ contractHash,
12
+ props,
13
+ }: KotlinSourceViewProps) {
14
+ const [contentSize, setContentSize] = useState<{ width: number; height: number }>()
26
15
  return (
27
- <NativeKotlinHost
28
- source={source}
29
- view={view}
30
- contractHash={contractHash}
31
- intrinsicWidth={!stretchedWidth}
32
- intrinsicHeight={!stretchedHeight}
33
- // a callback travels as true; the composable's lambda reports its call
34
- props={JSON.stringify(props, (_key, value) => (typeof value === 'function' ? true : value))}
35
- onHostEvent={(event) => {
36
- const callback = props[event.nativeEvent.name]
37
- if (typeof callback === 'function') callback(...JSON.parse(event.nativeEvent.args))
38
- }}
39
- onHostSizeChange={(event) => {
40
- setContentSize(event.nativeEvent)
41
- }}
42
- style={[
43
- contentSize && {
44
- width: stretchedWidth || !contentSize.intrinsicWidth ? undefined : contentSize.width,
45
- height: stretchedHeight ? undefined : contentSize.height,
46
- },
47
- (props as any)?.style,
48
- ]}
49
- />
16
+ <View style={props.style} collapsable={false}>
17
+ {/* yoga uses the natural child size while retaining parent flex and stretch. */}
18
+ <View pointerEvents="none" style={contentSize} />
19
+ <NativeKotlinHost
20
+ source={source}
21
+ view={view}
22
+ contractHash={contractHash}
23
+ props={JSON.stringify(props, (_key, value) =>
24
+ typeof value === 'function' ? true : value
25
+ )}
26
+ onHostEvent={(event) => {
27
+ const callback = props[event.nativeEvent.name]
28
+ if (typeof callback === 'function')
29
+ callback(...JSON.parse(event.nativeEvent.args))
30
+ }}
31
+ onHostSizeChange={(event) => {
32
+ setContentSize({
33
+ width: event.nativeEvent.width,
34
+ height: event.nativeEvent.height,
35
+ })
36
+ }}
37
+ style={StyleSheet.absoluteFill}
38
+ />
39
+ </View>
50
40
  )
51
41
  }
@@ -1,3 +1,5 @@
1
+ import type { StyleProp, ViewStyle } from 'react-native'
2
+
1
3
  export interface KotlinSourceViewProps {
2
4
  // the kotlin source id the bundler derived from the imported file's path
3
5
  source: string
@@ -5,5 +7,5 @@ export interface KotlinSourceViewProps {
5
7
  view: string
6
8
  contractHash: string
7
9
  // the importing element's props, the composable's parameters
8
- props: Record<string, unknown>
10
+ props: Record<string, unknown> & { style?: StyleProp<ViewStyle> }
9
11
  }
@@ -2,11 +2,14 @@
2
2
  // the app's generated view dispatch renders it with the element's props as
3
3
  // json text, and reports each callback call back as an event.
4
4
  import type { ViewProps } from 'react-native'
5
- import type { DirectEventHandler, Double } from 'react-native/Libraries/Types/CodegenTypes'
5
+ import type {
6
+ DirectEventHandler,
7
+ Double,
8
+ } from 'react-native/Libraries/Types/CodegenTypes'
6
9
  import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent'
7
10
 
8
11
  type KotlinHostEvent = Readonly<{ name: string; args: string }>
9
- type KotlinHostSizeEvent = Readonly<{ width: Double; height: Double; intrinsicWidth: boolean }>
12
+ type KotlinHostSizeEvent = Readonly<{ width: Double; height: Double }>
10
13
 
11
14
  interface NativeProps extends ViewProps {
12
15
  // the kotlin source id the bundler derived from the imported file's path
@@ -14,8 +17,6 @@ interface NativeProps extends ViewProps {
14
17
  view: string
15
18
  contractHash: string
16
19
  props: string
17
- intrinsicWidth: boolean
18
- intrinsicHeight: boolean
19
20
  onHostEvent?: DirectEventHandler<KotlinHostEvent>
20
21
  onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>
21
22
  }
@@ -1,4 +1,4 @@
1
1
  import type { KotlinSourceViewProps } from './viewTypes';
2
2
  export type { KotlinSourceViewProps } from './viewTypes';
3
- export declare function KotlinSourceView({ source, view, contractHash, props }: KotlinSourceViewProps): import("react/jsx-runtime").JSX.Element;
3
+ export declare function KotlinSourceView({ source, view, contractHash, props, }: KotlinSourceViewProps): import("react/jsx-runtime").JSX.Element;
4
4
  //# sourceMappingURL=view.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"view.native.d.ts","sourceRoot":"","sources":["../../../src/platform/native-source/view.native.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,wBAAgB,gBAAgB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,qBAAqB,2CAyC5F"}
1
+ {"version":3,"file":"view.native.d.ts","sourceRoot":"","sources":["../../../src/platform/native-source/view.native.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAExD,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,IAAI,EACJ,YAAY,EACZ,KAAK,GACN,EAAE,qBAAqB,2CA4BvB"}
@@ -1,7 +1,10 @@
1
+ import type { StyleProp, ViewStyle } from 'react-native';
1
2
  export interface KotlinSourceViewProps {
2
3
  source: string;
3
4
  view: string;
4
5
  contractHash: string;
5
- props: Record<string, unknown>;
6
+ props: Record<string, unknown> & {
7
+ style?: StyleProp<ViewStyle>;
8
+ };
6
9
  }
7
10
  //# sourceMappingURL=viewTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewTypes.d.ts","sourceRoot":"","sources":["../../../src/platform/native-source/viewTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IAEpC,MAAM,EAAE,MAAM,CAAA;IAEd,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B"}
1
+ {"version":3,"file":"viewTypes.d.ts","sourceRoot":"","sources":["../../../src/platform/native-source/viewTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExD,MAAM,WAAW,qBAAqB;IAEpC,MAAM,EAAE,MAAM,CAAA;IAEd,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;QAAE,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAA;KAAE,CAAA;CAClE"}
@@ -7,15 +7,12 @@ type KotlinHostEvent = Readonly<{
7
7
  type KotlinHostSizeEvent = Readonly<{
8
8
  width: Double;
9
9
  height: Double;
10
- intrinsicWidth: boolean;
11
10
  }>;
12
11
  interface NativeProps extends ViewProps {
13
12
  source: string;
14
13
  view: string;
15
14
  contractHash: string;
16
15
  props: string;
17
- intrinsicWidth: boolean;
18
- intrinsicHeight: boolean;
19
16
  onHostEvent?: DirectEventHandler<KotlinHostEvent>;
20
17
  onHostSizeChange?: DirectEventHandler<KotlinHostSizeEvent>;
21
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OneKotlinHostNativeComponent.d.ts","sourceRoot":"","sources":["../../../src/platform/specs/OneKotlinHostNativeComponent.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,S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