| 1209 | } |
| 1210 | |
| 1211 | const flush = (host: Native.ViewHost) => { |
| 1212 | for (const [name, n] of names) { |
| 1213 | if (n.host !== host) continue |
| 1214 | if (!mounted(n)) names.delete(name) |
| 1215 | } |
| 1216 | const d = drivers.get(host) |
| 1217 | if (d == null) return |
| 1218 | docking?.measure(d) |
| 1219 | for (const [n, e] of d.entries) { |
| 1220 | // A node outside a surface has been dropped. |
| 1221 | if (e.spec === undefined || !mounted(n)) { |
| 1222 | release(d, e) |
| 1223 | for (const t of e.targets.values()) drop(d, t) |
| 1224 | d.entries.delete(n) |
| 1225 | continue |
| 1226 | } |
| 1227 | // As React Native's `AnimatedScrollView`, the driver splits the keys |
| 1228 | // between the view and its wrapper as the host splits the props. |
| 1229 | const outer = n.outer?.kind.attach!(host)!.outer |
| 1230 | if (e.spec !== e.built || outer !== e.outer) update(d, e, e.spec, outer) |
| 1231 | // The host gives a recreated view a new tag. |
| 1232 | for (const c of e.graph!.props) { |
| 1233 | const view = (c.outer ? n.outer! : n).tag |
| 1234 | if (view === c.view) continue |
| 1235 | const m = native(d) |
| 1236 | if (c.view !== 0) m.disconnectAnimatedNodeFromView(c.tag, c.view) |
| 1237 | if (view !== 0) m.connectAnimatedNodeToView(c.tag, view) |
| 1238 | c.view = view |
| 1239 | } |
| 1240 | } |
| 1241 | for (const [name, s] of d.sources) { |
| 1242 | if (s.node !== undefined && !mounted(s.node)) { |
| 1243 | s.node = undefined |
| 1244 | s.pinned = false |
| 1245 | } |
| 1246 | const used = s.users > 0 || s.pinned === true |
| 1247 | bind(d, s, s.node !== undefined && used ? s.node.tag : 0, host.os) |
| 1248 | if (!used) { |
| 1249 | if (s.x !== undefined) native(d).dropAnimatedNode(s.x) |
| 1250 | if (s.y !== undefined) native(d).dropAnimatedNode(s.y) |
| 1251 | s.x = s.y = undefined |
| 1252 | if (s.node === undefined) d.sources.delete(name) |
| 1253 | } |
| 1254 | } |
| 1255 | finish(d, host) |
| 1256 | } |
| 1257 | |
| 1258 | const finish = (d: Driver, host: Native.ViewHost) => { |
| 1259 | if (!d.batching) return |