ReviewOS

also looking at this

craft-native/craft

fix(native): retain keyed controls and correct map and tab chrome

#368
Merged chris wants to merge codex/native-repeated-selector-identity into main
32 files +449 -100

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

packages/android/templates/CraftNativeMutation.kt.templatemodified+7-3
Changes to packages/android/templates/CraftNativeMutation.kt.template
@@ -30,7 +30,8 @@ class CraftNativeMutationDocument {
3030 var events: JSONObject,
3131 var text: MutableList<String>,
3232 var children: MutableList<String>,
33 var parent: String?
33 var parent: String?,
34 val key: String? = null
3435 ) {
3536 fun duplicate(): Node = copy(
3637 props = JSONObject(props.toString()),
@@ -175,7 +176,8 @@ class CraftNativeMutationDocument {
175176 dictionary(value.opt("events")),
176177 textChildren(if (value.has("children")) value.opt("children") else value.opt("text")),
177178 mutableListOf(),
178 null
179 null,
180 key = value.opt("key") as? String
179181 )
180182 return if (makeRoot) id else root
181183 }
@@ -299,6 +301,7 @@ class CraftNativeMutationDocument {
299301 .put("style", node.style)
300302 .put("events", node.events)
301303 .put("children", children)
304 .also { value -> node.key?.let { value.put("key", it) } }
302305 }
303306
304307 private fun importNode(
@@ -322,7 +325,8 @@ class CraftNativeMutationDocument {
322325 dictionary(value.opt("events")),
323326 mutableListOf(),
324327 mutableListOf(),
325 parent
328 parent,
329 key = value.opt("key") as? String
326330 )
327331 nodes[id] = node
328332 for (index in 0 until children.length()) {
packages/ios/templates/CraftNativeMutation.swiftmodified+4-0
Changes to packages/ios/templates/CraftNativeMutation.swift
@@ -29,6 +29,7 @@ struct CraftNativeMutationResult {
2929final class CraftNativeMutationDocument {
3030 private struct Node {
3131 let id: String
32 let key: String?
3233 var type: String
3334 var props: [String: Any]
3435 var style: [String: Any]
@@ -177,6 +178,7 @@ final class CraftNativeMutationDocument {
177178 }
178179 nodes[id] = Node(
179180 id: id,
181 key: value["key"] as? String,
180182 type: type,
181183 props: dictionary(value["props"]),
182184 style: dictionary(value["style"]),
@@ -330,6 +332,7 @@ final class CraftNativeMutationDocument {
330332 "style": node.style,
331333 "events": node.events,
332334 ]
335 if let key = node.key { value["key"] = key }
333336 let text: [Any] = node.text
334337 let children: [Any] = node.children.compactMap { materialize($0, nodes: nodes) }
335338 value["children"] = text + children
@@ -350,6 +353,7 @@ final class CraftNativeMutationDocument {
350353 let children = value["children"] as? [Any] ?? []
351354 nodes[id] = Node(
352355 id: id,
356 key: value["key"] as? String,
353357 type: value["type"] as? String ?? "View",
354358 props: props,
355359 style: dictionary(value["style"]),