@tamagui/web 3.0.5 → 3.0.7

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 (40) hide show
  1. package/dist/cjs/_withNativeStyle.cjs +37 -20
  2. package/dist/cjs/_withNativeStyle.native.cjs +37 -20
  3. package/dist/cjs/_withNativeStyle.native.js +37 -20
  4. package/dist/cjs/_withNativeStyle.native.js.map +1 -1
  5. package/dist/cjs/createComponent.native.cjs +1 -0
  6. package/dist/cjs/createComponent.native.js +1 -0
  7. package/dist/cjs/createComponent.native.js.map +1 -1
  8. package/dist/cjs/helpers/getSplitStyles.cjs +2 -1
  9. package/dist/cjs/helpers/getSplitStyles.native.cjs +2 -1
  10. package/dist/cjs/helpers/getSplitStyles.native.js +2 -1
  11. package/dist/cjs/helpers/getSplitStyles.native.js.map +1 -1
  12. package/dist/cjs/helpers/nativeStyleEngine.cjs +80 -122
  13. package/dist/cjs/helpers/nativeStyleEngine.native.cjs +81 -161
  14. package/dist/cjs/helpers/nativeStyleEngine.native.js +81 -161
  15. package/dist/cjs/helpers/nativeStyleEngine.native.js.map +1 -1
  16. package/dist/esm/_withNativeStyle.mjs +38 -21
  17. package/dist/esm/_withNativeStyle.mjs.map +1 -1
  18. package/dist/esm/_withNativeStyle.native.js +38 -21
  19. package/dist/esm/_withNativeStyle.native.js.map +1 -1
  20. package/dist/esm/createComponent.native.js +2 -1
  21. package/dist/esm/createComponent.native.js.map +1 -1
  22. package/dist/esm/helpers/getSplitStyles.mjs +2 -1
  23. package/dist/esm/helpers/getSplitStyles.mjs.map +1 -1
  24. package/dist/esm/helpers/getSplitStyles.native.js +2 -1
  25. package/dist/esm/helpers/getSplitStyles.native.js.map +1 -1
  26. package/dist/esm/helpers/nativeStyleEngine.mjs +78 -122
  27. package/dist/esm/helpers/nativeStyleEngine.mjs.map +1 -1
  28. package/dist/esm/helpers/nativeStyleEngine.native.js +79 -161
  29. package/dist/esm/helpers/nativeStyleEngine.native.js.map +1 -1
  30. package/package.json +17 -17
  31. package/src/_withNativeStyle.tsx +67 -31
  32. package/src/createComponent.tsx +6 -1
  33. package/src/helpers/getSplitStyles.tsx +3 -0
  34. package/src/helpers/nativeStyleEngine.ts +118 -163
  35. package/types/_withNativeStyle.d.ts +4 -3
  36. package/types/_withNativeStyle.d.ts.map +1 -1
  37. package/types/createComponent.d.ts.map +1 -1
  38. package/types/helpers/getSplitStyles.d.ts.map +1 -1
  39. package/types/helpers/nativeStyleEngine.d.ts +26 -6
  40. package/types/helpers/nativeStyleEngine.d.ts.map +1 -1
@@ -107,17 +107,17 @@ export interface NativeStyleEngine {
107
107
  ): NativeStyleEngineLinkHandle | null
108
108
  /**
109
109
  * links many mounted hosts to shared tables in one call: entry i links
110
- * refs[i] to tableIds[i] under scopes[scopeIndexes[i]]. returns the id of
111
- * entry 0; ids are consecutive, and an entry whose host is gone consumes
112
- * its id unlinked
110
+ * refs[i] to tableIds[i] under scopes[scopeIndexes[i]]. a host already
111
+ * linked moves to its new entry, and the engine drops linked views that
112
+ * have left the tree, so table links are never unlinked by id
113
113
  */
114
114
  linkTables(
115
115
  refs: unknown[],
116
116
  tableIds: number[],
117
117
  scopeIndexes: number[],
118
118
  scopes: string[]
119
- ): number
120
- /** unlinks an id from linkTables */
119
+ ): void
120
+ /** unlinks an id from link with per-view slots */
121
121
  unlink(id: number): void
122
122
  /**
123
123
  * fills one state of a shared table, read by every view linked to it;
@@ -155,7 +155,7 @@ const compiledMappings = new Map<string, CompiledMapping>()
155
155
  // linked mappings per scope, with their live link counts. they remain update
156
156
  // owners across memo-generation rollovers, and a scope change only syncs the
157
157
  // mappings linked under that scope
158
- const scopeMappings = new Map<string, Map<CompiledMapping, number>>()
158
+ const scopeMappings = new Map<string, Set<CompiledMapping>>()
159
159
  let nextTableId = 1
160
160
 
161
161
  function getCompiledMapping(mapping: NativeStyleThemeMapping): CompiledMapping {
@@ -223,11 +223,10 @@ function syncTableState(
223
223
 
224
224
  export function setNativeStyleEngine(next: NativeStyleEngine | null): void {
225
225
  if (engine !== next) {
226
- settleReleases()
227
226
  compiledMappings.clear()
228
227
  scopeMappings.clear()
229
- pendingLinks = []
230
- unlinkedPending = 0
228
+ pendingHosts = []
229
+ pendingStates = []
231
230
  }
232
231
  engine = next
233
232
  if (next) {
@@ -257,7 +256,7 @@ export function updateNativeStyleScope(
257
256
  // one theme, so every scope showing it reads the same table entry
258
257
  const linked = scopeMappings.get(scopeId)
259
258
  if (linked) {
260
- for (const compiled of linked.keys()) {
259
+ for (const compiled of linked) {
261
260
  syncTableState(compiled, stateName, theme as Record<string, unknown>)
262
261
  }
263
262
  }
@@ -267,6 +266,11 @@ export function updateNativeStyleScope(
267
266
 
268
267
  export function removeNativeStyleScope(scopeId: string): void {
269
268
  if (!scopeStates.delete(scopeId)) return
269
+ // a <Theme> removes and re-adds its scope in one commit whenever its state
270
+ // changes; only a scope still gone after that commit drops its mappings
271
+ queueMicrotask(() => {
272
+ if (!scopeStates.has(scopeId)) scopeMappings.delete(scopeId)
273
+ })
270
274
  engine?.removeScope(scopeId)
271
275
  }
272
276
 
@@ -278,179 +282,108 @@ export function resolveNativeStyleMapping(
278
282
  return resolveCompiledMapping(getCompiledMapping(mapping), stateName, theme).renderProps
279
283
  }
280
284
 
281
- interface MappingLink {
282
- ref: unknown
283
- compiled: CompiledMapping
285
+ /**
286
+ * what a host rendered: one mapping under one scope state. every host of a
287
+ * compiled component that rendered that state shares one record, so a mount
288
+ * allocates nothing to link
289
+ */
290
+ export interface NativeStyleLinkState {
291
+ mapping: NativeStyleThemeMapping
284
292
  scopeId: string
285
- /** 0 while pending, -1 once unlinked */
286
- id: number
287
- /** the engine that assigned `id`: a later engine swap must not receive its unlink */
288
- owner: NativeStyleEngine | null
293
+ stateName: string
294
+ theme: Record<string, unknown>
289
295
  }
290
296
 
291
- // views link lazily: a mount only records its host here, and the engine
292
- // links every pending view in one call before a scope next changes. linking
293
- // exists for theme switches, so a mount pays nothing native, and a view that
294
- // unmounts before any switch never reaches the engine
295
- let pendingLinks: MappingLink[] = []
296
- // pending entries unlinked before any flush; compacted once they dominate
297
- let unlinkedPending = 0
298
-
299
- function trackScopeMapping(link: MappingLink, delta: 1 | -1) {
300
- let linked = scopeMappings.get(link.scopeId)
301
- if (!linked) scopeMappings.set(link.scopeId, (linked = new Map()))
302
- const count = (linked.get(link.compiled) ?? 0) + delta
303
- if (count) {
304
- linked.set(link.compiled, count)
305
- } else {
306
- linked.delete(link.compiled)
307
- if (!linked.size) scopeMappings.delete(link.scopeId)
308
- }
297
+ export function createNativeStyleLinkState(
298
+ mapping: NativeStyleThemeMapping,
299
+ scopeId: string,
300
+ stateName: string,
301
+ theme: Record<string, unknown>
302
+ ): NativeStyleLinkState {
303
+ return { mapping, scopeId, stateName, theme }
309
304
  }
310
305
 
311
- /** links every pending view in one engine call */
312
- export function flushNativeStyleLinks(): void {
313
- settleReleases()
314
- if (!pendingLinks.length) return
315
- const links = pendingLinks
316
- pendingLinks = []
317
- unlinkedPending = 0
318
- if (!engine) return
319
- const live = links.filter((link) => link.id === 0)
320
- if (!live.length) return
321
- const refs: unknown[] = []
322
- const tableIds: number[] = []
323
- const scopeIndexes: number[] = []
324
- const scopes: string[] = []
325
- for (const link of live) {
326
- let scopeIndex = scopes.indexOf(link.scopeId)
327
- if (scopeIndex === -1) scopeIndex = scopes.push(link.scopeId) - 1
328
- refs.push(link.ref)
329
- tableIds.push(link.compiled.tableId)
330
- scopeIndexes.push(scopeIndex)
331
- }
332
- const firstId = engine.linkTables(refs, tableIds, scopeIndexes, scopes)
333
- for (let i = 0; i < live.length; i++) {
334
- const link = live[i]!
335
- link.id = firstId + i
336
- link.owner = engine
337
- link.ref = null
338
- trackScopeMapping(link, 1)
339
- }
306
+ // views link lazily: a mount only records its host and the state it rendered,
307
+ // and the engine links every pending view in one call before a scope next
308
+ // changes. linking exists for theme switches, so a mount pays nothing native.
309
+ // nothing unlinks: the engine drops views that left the tree when it links, so
310
+ // an unmount costs nothing either
311
+ let pendingHosts: unknown[] = []
312
+ let pendingStates: NativeStyleLinkState[] = []
313
+ // past this many pending hosts, link them once the JS thread idles, so hosts
314
+ // that mount and unmount without a scope change never accumulate
315
+ const maxPendingHosts = 4096
316
+ let idleFlushQueued = false
317
+
318
+ function idleFlush() {
319
+ idleFlushQueued = false
320
+ flushNativeStyleLinks()
340
321
  }
341
322
 
342
- // React detaches and re-attaches a callback ref whenever the callback changes,
343
- // which a parent re-render does to every child. a release settles after the
344
- // commit, so the same host attaching again keeps its link and the engine keeps
345
- // its per-view caches instead of unlinking and relinking every view
346
- interface Release {
347
- compiled: CompiledMapping
348
- scopeId: string
349
- handle: NativeStyleEngineLinkHandle
350
- settle: () => void
351
- }
352
- const releases = new Map<unknown, Release>()
353
- let settleQueued = false
354
-
355
- function settleReleases() {
356
- settleQueued = false
357
- if (!releases.size) return
358
- const settling = [...releases.values()]
359
- releases.clear()
360
- for (const release of settling) release.settle()
323
+ function addScopeMapping(scopeId: string, compiled: CompiledMapping) {
324
+ let linked = scopeMappings.get(scopeId)
325
+ if (!linked) scopeMappings.set(scopeId, (linked = new Set()))
326
+ linked.add(compiled)
361
327
  }
362
328
 
363
- function releasable(
364
- ref: unknown,
365
- compiled: CompiledMapping,
366
- scopeId: string,
367
- id: number,
368
- settle: () => void
369
- ): NativeStyleEngineLinkHandle {
370
- const handle: NativeStyleEngineLinkHandle = {
371
- id,
372
- unlink: () => {
373
- const prior = releases.get(ref)
374
- if (prior && prior.handle !== handle) prior.settle()
375
- releases.set(ref, { compiled, scopeId, handle, settle })
376
- if (!settleQueued) {
377
- settleQueued = true
378
- queueMicrotask(settleReleases)
379
- }
380
- },
329
+ /** links every pending view in one engine call */
330
+ export function flushNativeStyleLinks(): void {
331
+ if (!pendingHosts.length) return
332
+ const hosts = pendingHosts
333
+ const states = pendingStates
334
+ pendingHosts = []
335
+ pendingStates = []
336
+ if (!engine) return
337
+ const tableIds: number[] = new Array(hosts.length)
338
+ const scopeIndexes: number[] = new Array(hosts.length)
339
+ const scopes: string[] = []
340
+ let last: NativeStyleLinkState | undefined
341
+ let tableId = 0
342
+ let scopeIndex = 0
343
+ for (let i = 0; i < hosts.length; i++) {
344
+ const state = states[i]!
345
+ if (state !== last) {
346
+ last = state
347
+ const compiled = getCompiledMapping(state.mapping)
348
+ // the table must hold the state each view rendered before the switch
349
+ syncTableState(compiled, state.stateName, state.theme)
350
+ addScopeMapping(state.scopeId, compiled)
351
+ tableId = compiled.tableId
352
+ scopeIndex = scopes.indexOf(state.scopeId)
353
+ if (scopeIndex === -1) scopeIndex = scopes.push(state.scopeId) - 1
354
+ }
355
+ tableIds[i] = tableId
356
+ scopeIndexes[i] = scopeIndex
381
357
  }
382
- return handle
358
+ engine.linkTables(hosts, tableIds, scopeIndexes, scopes)
383
359
  }
384
360
 
385
- export function linkNativeStyleMapping(
386
- ref: unknown,
387
- mapping: NativeStyleThemeMapping,
388
- scopeId: string,
389
- stateName: string,
390
- theme: Record<string, unknown>
391
- ): NativeStyleEngineLinkHandle | null {
392
- if (!engine) return null
393
-
394
- const compiled = getCompiledMapping(mapping)
361
+ /** records a mounted host for linking. a host attaching twice links once */
362
+ export function linkNativeStyleHost(host: unknown, state: NativeStyleLinkState): void {
363
+ if (!engine) return
395
364
  // a scope can advance (layout effect) after a concurrent render captured its
396
- // theme but before that render's host ref links. link that host now against
365
+ // theme but before that render's host attaches. link that host now against
397
366
  // the live scope state and have the engine commit it once to correct the
398
367
  // stale React commit.
399
- const scopeState = scopeStates.get(scopeId)
400
- const stale =
401
- scopeState && (scopeState.name !== stateName || scopeState.theme !== theme)
402
- const kept = releases.get(ref)
403
- if (kept) {
404
- releases.delete(ref)
405
- if (!stale && kept.compiled === compiled && kept.scopeId === scopeId)
406
- return kept.handle
407
- kept.settle()
368
+ const live = scopeStates.get(state.scopeId)
369
+ if (live && (live.name !== state.stateName || live.theme !== state.theme)) {
370
+ const compiled = getCompiledMapping(state.mapping)
371
+ syncTableState(compiled, live.name, live.theme as Record<string, unknown>)
372
+ addScopeMapping(state.scopeId, compiled)
373
+ engine.link(host, compiled.tableId, state.scopeId, true)
374
+ return
408
375
  }
409
- if (stale) {
410
- syncTableState(compiled, scopeState.name, scopeState.theme as Record<string, unknown>)
411
- const handle = engine.link(ref, compiled.tableId, scopeId, true)
412
- if (!handle) return null
413
- const link: MappingLink = {
414
- ref: null,
415
- compiled,
416
- scopeId,
417
- id: handle.id,
418
- owner: engine,
419
- }
420
- trackScopeMapping(link, 1)
421
- return releasable(ref, compiled, scopeId, handle.id, () => {
422
- if (link.id === -1) return
423
- link.id = -1
424
- if (link.owner === engine) trackScopeMapping(link, -1)
425
- handle.unlink()
426
- })
376
+ pendingHosts.push(host)
377
+ pendingStates.push(state)
378
+ if (pendingHosts.length >= maxPendingHosts && !idleFlushQueued) {
379
+ idleFlushQueued = true
380
+ requestIdleCallback(idleFlush)
427
381
  }
428
-
429
- // the table must hold the state this view rendered before a switch links it
430
- syncTableState(compiled, stateName, theme)
431
- const link: MappingLink = { ref, compiled, scopeId, id: 0, owner: null }
432
- pendingLinks.push(link)
433
- return releasable(ref, compiled, scopeId, 0, () => {
434
- const id = link.id
435
- if (id === -1) return
436
- link.id = -1
437
- link.ref = null
438
- if (id > 0) {
439
- // scope accounting was reset when the engine changed
440
- if (link.owner === engine) trackScopeMapping(link, -1)
441
- link.owner!.unlink(id)
442
- } else if (++unlinkedPending > 512 && unlinkedPending * 2 > pendingLinks.length) {
443
- pendingLinks = pendingLinks.filter((pending) => pending.id === 0)
444
- unlinkedPending = 0
445
- }
446
- })
447
382
  }
448
383
 
449
384
  /** memo-generation and live-owner sizes for development diagnostics and probes */
450
385
  export const getNativeStyleEngineCacheStats = () => {
451
- const active = new Set(
452
- [...scopeMappings.values()].flatMap((linked) => [...linked.keys()])
453
- )
386
+ const active = new Set([...scopeMappings.values()].flatMap((linked) => [...linked]))
454
387
  return {
455
388
  mappings: compiledMappings.size,
456
389
  activeMappings: active.size,
@@ -499,16 +432,38 @@ export function updateNativeStyleLink(
499
432
  }
500
433
  }
501
434
 
435
+ // per view id, how many pending entries a render of that view superseded
436
+ let superseded: Map<number, number> | null = null
437
+
502
438
  export function queueNativeViewState(entry: NativeViewStateUpdate): void {
503
439
  if (!engine) return
504
440
  if (!pending) {
505
441
  pending = []
506
442
  queueMicrotask(() => {
507
- const entries = pending!
443
+ let entries = pending!
444
+ const dropped = superseded
508
445
  pending = null
446
+ superseded = null
447
+ if (dropped) {
448
+ entries = entries.filter(
449
+ (queued, index) => index >= (dropped.get(queued.id) ?? 0)
450
+ )
451
+ }
452
+ if (!entries.length) return
509
453
  engine?.applyViewStates(entries)
510
454
  flushListener?.(entries)
511
455
  })
512
456
  }
513
457
  pending.push(entry)
514
458
  }
459
+
460
+ /**
461
+ * a render of a linked view commits its current styles, so updates it queued
462
+ * before rendering carry older props and must not land after that commit: a
463
+ * parent passing a raw theme value re-renders the view with the new value
464
+ * while the view's own theme listener queued a push of the old one
465
+ */
466
+ export function supersedeNativeViewStates(id: number): void {
467
+ if (!pending) return
468
+ ;(superseded ||= new Map()).set(id, pending.length)
469
+ }
@@ -3,9 +3,10 @@ import { type NativeStyleThemeMapping } from './helpers/nativeStyleEngine';
3
3
  /**
4
4
  * internal: emitted by the native compiler when experimental.nativeFastPath is on.
5
5
  *
6
- * One component over the host: the theme scope is the only context read, the
7
- * host ref links straight to the engine and unlinks through React's ref
8
- * cleanup, so a themed view costs one component and one engine call to mount.
6
+ * One component over the host: the theme scope is the only context read and
7
+ * the host ref queues the host for the engine's next batched link. Links never
8
+ * detach (the engine prunes unmounted views), so a themed view costs one
9
+ * component and one array push to mount.
9
10
  *
10
11
  * `host: 'view'`: `Component` is RN's host view (`unstable_NativeView`).
11
12
  * <View> resets TextAncestorContext for its children when it sits inside a
@@ -1 +1 @@
1
- {"version":3,"file":"_withNativeStyle.d.ts","sourceRoot":"","sources":["../src/_withNativeStyle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAc,MAAM,OAAO,CAAA;AAElC,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAA;AAYpC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB,cAChB,GAAG,aACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAClB,uBAAuB,SAChC,MAAM,GAAG,MAAM;YAkHU,GAAG;sBAIA,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC;CAG3D,CAAA"}
1
+ {"version":3,"file":"_withNativeStyle.d.ts","sourceRoot":"","sources":["../src/_withNativeStyle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAc,MAAM,OAAO,CAAA;AAElC,OAAO,EAML,KAAK,uBAAuB,EAC7B,MAAM,6BAA6B,CAAA;AAYpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,gBAAgB,cAChB,GAAG,aACH,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAClB,uBAAuB,SAChC,MAAM,GAAG,MAAM;YA0IU,GAAG;sBAIA,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC;CAG3D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAuC/D,OAAO,KAAK,EASV,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EAOf,MAAM,SAAS,CAAA;AAahB,KAAK,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAEpF,eAAO,MAAM,kBAAkB,wBAA+B,CAAA;AAuK9D,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACnD,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,SAAS,GAAG,KAAK,EACjB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,YAAY,EAAE,YAAY,wEAqkE3B"}
1
+ {"version":3,"file":"createComponent.d.ts","sourceRoot":"","sources":["../src/createComponent.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2C,MAAM,OAAO,CAAA;AAwC/D,OAAO,KAAK,EASV,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EAOf,MAAM,SAAS,CAAA;AAahB,KAAK,iBAAiB,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAAA;AAEpF,eAAO,MAAM,kBAAkB,wBAA+B,CAAA;AAuK9D,wBAAgB,eAAe,CAC7B,kBAAkB,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACnD,GAAG,SAAS,cAAc,GAAG,cAAc,EAC3C,SAAS,GAAG,KAAK,EACjB,UAAU,SAAS,MAAM,GAAG,KAAK,EACjC,YAAY,EAAE,YAAY,wEAykE3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"getSplitStyles.d.ts","sourceRoot":"","sources":["../../src/helpers/getSplitStyles.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,gBAAgB,EAEhB,mBAAmB,EAEnB,iBAAiB,EACjB,SAAS,EACT,cAAc,EACd,aAAa,EAGb,eAAe,EACf,YAAY,EAGZ,qBAAqB,EACrB,qBAAqB,EAErB,WAAW,EAGZ,MAAM,UAAU,CAAA;AAkBjB,OAAO,EAAE,oBAAoB,EAAE,KAAK,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAKlF,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAqB/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAe3D,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAA;AACvF,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,mBAAmB,CAAA;AAC1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wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,GAAG,EACV,QAAQ,EAAE,GAAG,EACb,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,OAAO,QAyBlB;AAID,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,qBAAqB,sBAgBtF;AAMD,cAAc,mBAAmB,CAAA"}
@@ -42,12 +42,12 @@ export interface NativeStyleEngine {
42
42
  link(ref: unknown, table: NativeStyleEngineSlots | number, scopeId?: string, commitNow?: boolean): NativeStyleEngineLinkHandle | null;
43
43
  /**
44
44
  * links many mounted hosts to shared tables in one call: entry i links
45
- * refs[i] to tableIds[i] under scopes[scopeIndexes[i]]. returns the id of
46
- * entry 0; ids are consecutive, and an entry whose host is gone consumes
47
- * its id unlinked
45
+ * refs[i] to tableIds[i] under scopes[scopeIndexes[i]]. a host already
46
+ * linked moves to its new entry, and the engine drops linked views that
47
+ * have left the tree, so table links are never unlinked by id
48
48
  */
49
- linkTables(refs: unknown[], tableIds: number[], scopeIndexes: number[], scopes: string[]): number;
50
- /** unlinks an id from linkTables */
49
+ linkTables(refs: unknown[], tableIds: number[], scopeIndexes: number[], scopes: string[]): void;
50
+ /** unlinks an id from link with per-view slots */
51
51
  unlink(id: number): void;
52
52
  /**
53
53
  * fills one state of a shared table, read by every view linked to it;
@@ -64,9 +64,22 @@ export declare function getNativeStyleEngine(): NativeStyleEngine | null;
64
64
  export declare function updateNativeStyleScope(scopeId: string, stateName: string, theme: object): void;
65
65
  export declare function removeNativeStyleScope(scopeId: string): void;
66
66
  export declare function resolveNativeStyleMapping(mapping: NativeStyleThemeMapping, stateName: string, theme: Record<string, unknown>): Record<string, unknown>;
67
+ /**
68
+ * what a host rendered: one mapping under one scope state. every host of a
69
+ * compiled component that rendered that state shares one record, so a mount
70
+ * allocates nothing to link
71
+ */
72
+ export interface NativeStyleLinkState {
73
+ mapping: NativeStyleThemeMapping;
74
+ scopeId: string;
75
+ stateName: string;
76
+ theme: Record<string, unknown>;
77
+ }
78
+ export declare function createNativeStyleLinkState(mapping: NativeStyleThemeMapping, scopeId: string, stateName: string, theme: Record<string, unknown>): NativeStyleLinkState;
67
79
  /** links every pending view in one engine call */
68
80
  export declare function flushNativeStyleLinks(): void;
69
- export declare function linkNativeStyleMapping(ref: unknown, mapping: NativeStyleThemeMapping, scopeId: string, stateName: string, theme: Record<string, unknown>): NativeStyleEngineLinkHandle | null;
81
+ /** records a mounted host for linking. a host attaching twice links once */
82
+ export declare function linkNativeStyleHost(host: unknown, state: NativeStyleLinkState): void;
70
83
  /** memo-generation and live-owner sizes for development diagnostics and probes */
71
84
  export declare const getNativeStyleEngineCacheStats: () => {
72
85
  mappings: number;
@@ -89,4 +102,11 @@ export declare function updateNativeStyleLink(ref: {
89
102
  nativePushedKeys?: Set<string>;
90
103
  }, host: unknown): void;
91
104
  export declare function queueNativeViewState(entry: NativeViewStateUpdate): void;
105
+ /**
106
+ * a render of a linked view commits its current styles, so updates it queued
107
+ * before rendering carry older props and must not land after that commit: a
108
+ * parent passing a raw theme value re-renders the view with the new value
109
+ * while the view's own theme listener queued a push of the old one
110
+ */
111
+ export declare function supersedeNativeViewStates(id: number): void;
92
112
  //# sourceMappingURL=nativeStyleEngine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nativeStyleEngine.d.ts","sourceRoot":"","sources":["../../src/helpers/nativeStyleEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAKtE,CAAA;AAkBD,yFAAyF;AACzF,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,KAAK,UAAQ,GACZ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CA2BzB;AAED,M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