@symbiote-native/angular 0.6.0 → 0.6.2

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 (193) hide show
  1. package/README.md +1 -1
  2. package/babel-register-composed.cjs +11 -3
  3. package/build/angular/anchor-host-registry.d.ts +2 -0
  4. package/build/angular/anchor-host-registry.js +84 -0
  5. package/build/angular/anchor-host-registry.js.map +1 -0
  6. package/build/angular/components/input-accessory-view/index.d.ts +2 -1
  7. package/build/angular/components/input-accessory-view/index.js +28 -39
  8. package/build/angular/components/input-accessory-view/index.js.map +1 -1
  9. package/build/angular/components/scroll-view/projection.js +70 -48
  10. package/build/angular/components/scroll-view/projection.js.map +1 -1
  11. package/build/angular/components/scroll-view/shared.js +28 -25
  12. package/build/angular/components/scroll-view/shared.js.map +1 -1
  13. package/build/angular/components/scroll-view/sticky-header.d.ts +6 -7
  14. package/build/angular/components/scroll-view/sticky-header.js +82 -65
  15. package/build/angular/components/scroll-view/sticky-header.js.map +1 -1
  16. package/build/angular/components/touchable/index.d.ts +2 -5
  17. package/build/angular/components/touchable/index.js +36 -56
  18. package/build/angular/components/touchable/index.js.map +1 -1
  19. package/build/angular/components/virtualized-list/index.d.ts +5 -20
  20. package/build/angular/components/virtualized-list/index.js +145 -275
  21. package/build/angular/components/virtualized-list/index.js.map +1 -1
  22. package/build/angular/components/virtualized-section-list/index.js +2 -4
  23. package/build/angular/components/virtualized-section-list/index.js.map +1 -1
  24. package/build/angular/index.d.ts +2 -1
  25. package/build/angular/index.js +6 -1
  26. package/build/angular/index.js.map +1 -1
  27. package/build/angular/renderer/index.d.ts +0 -1
  28. package/build/angular/renderer/index.js +5 -60
  29. package/build/angular/renderer/index.js.map +1 -1
  30. package/package.json +8 -4
  31. package/src/anchor-host-registry.ts +88 -0
  32. package/src/components/input-accessory-view/index.ts +30 -39
  33. package/src/components/scroll-view/projection.ts +76 -46
  34. package/src/components/scroll-view/shared.ts +27 -19
  35. package/src/components/scroll-view/sticky-header.ts +89 -64
  36. package/src/components/touchable/index.ts +52 -66
  37. package/src/components/virtualized-list/index.ts +157 -368
  38. package/src/components/virtualized-section-list/index.ts +6 -3
  39. package/src/index.ts +6 -1
  40. package/src/renderer/index.ts +5 -63
  41. package/build/bootstrap.d.ts +0 -7
  42. package/build/bootstrap.js +0 -14
  43. package/build/components/activity-indicator/index.android.d.ts +0 -9
  44. package/build/components/activity-indicator/index.android.js +0 -64
  45. package/build/components/activity-indicator/index.d.ts +0 -1
  46. package/build/components/activity-indicator/index.ios.d.ts +0 -5
  47. package/build/components/activity-indicator/index.ios.js +0 -64
  48. package/build/components/activity-indicator/index.js +0 -3
  49. package/build/components/activity-indicator/shared.d.ts +0 -64
  50. package/build/components/activity-indicator/shared.js +0 -424
  51. package/build/components/button.d.ts +0 -60
  52. package/build/components/button.js +0 -456
  53. package/build/components/flat-list/index.d.ts +0 -119
  54. package/build/components/flat-list/index.js +0 -691
  55. package/build/components/image/index.android.d.ts +0 -7
  56. package/build/components/image/index.android.js +0 -88
  57. package/build/components/image/index.d.ts +0 -1
  58. package/build/components/image/index.ios.d.ts +0 -7
  59. package/build/components/image/index.ios.js +0 -88
  60. package/build/components/image/index.js +0 -2
  61. package/build/components/image/shared.d.ts +0 -101
  62. package/build/components/image/shared.js +0 -405
  63. package/build/components/image-background.d.ts +0 -78
  64. package/build/components/image-background.js +0 -583
  65. package/build/components/input-accessory-view/index.d.ts +0 -56
  66. package/build/components/input-accessory-view/index.js +0 -403
  67. package/build/components/keyboard-avoiding-view/index.d.ts +0 -79
  68. package/build/components/keyboard-avoiding-view/index.js +0 -504
  69. package/build/components/modal/index.d.ts +0 -89
  70. package/build/components/modal/index.js +0 -529
  71. package/build/components/pressable/index.d.ts +0 -120
  72. package/build/components/pressable/index.js +0 -639
  73. package/build/components/refresh-control/index.d.ts +0 -83
  74. package/build/components/refresh-control/index.js +0 -509
  75. package/build/components/safe-area-view/index.d.ts +0 -54
  76. package/build/components/safe-area-view/index.js +0 -388
  77. package/build/components/scroll-view/index.android.d.ts +0 -16
  78. package/build/components/scroll-view/index.android.js +0 -228
  79. package/build/components/scroll-view/index.d.ts +0 -3
  80. package/build/components/scroll-view/index.ios.d.ts +0 -6
  81. package/build/components/scroll-view/index.ios.js +0 -113
  82. package/build/components/scroll-view/index.js +0 -5
  83. package/build/components/scroll-view/projection.d.ts +0 -32
  84. package/build/components/scroll-view/projection.js +0 -311
  85. package/build/components/scroll-view/shared.d.ts +0 -225
  86. package/build/components/scroll-view/shared.js +0 -757
  87. package/build/components/scroll-view/sticky-header.d.ts +0 -38
  88. package/build/components/scroll-view/sticky-header.js +0 -257
  89. package/build/components/section-list/index.d.ts +0 -113
  90. package/build/components/section-list/index.js +0 -768
  91. package/build/components/switch/index.android.d.ts +0 -17
  92. package/build/components/switch/index.android.js +0 -107
  93. package/build/components/switch/index.d.ts +0 -1
  94. package/build/components/switch/index.ios.d.ts +0 -16
  95. package/build/components/switch/index.ios.js +0 -106
  96. package/build/components/switch/index.js +0 -3
  97. package/build/components/switch/shared.d.ts +0 -37
  98. package/build/components/switch/shared.js +0 -176
  99. package/build/components/text-input.d.ts +0 -150
  100. package/build/components/text-input.js +0 -821
  101. package/build/components/touchable/index.d.ts +0 -241
  102. package/build/components/touchable/index.js +0 -1672
  103. package/build/components/touchable-native-feedback/index.d.ts +0 -80
  104. package/build/components/touchable-native-feedback/index.js +0 -545
  105. package/build/components/virtualized-list/directives.d.ts +0 -41
  106. package/build/components/virtualized-list/directives.js +0 -249
  107. package/build/components/virtualized-list/index.d.ts +0 -265
  108. package/build/components/virtualized-list/index.js +0 -1343
  109. package/build/components/virtualized-section-list/directives.d.ts +0 -28
  110. package/build/components/virtualized-section-list/directives.js +0 -148
  111. package/build/components/virtualized-section-list/index.d.ts +0 -175
  112. package/build/components/virtualized-section-list/index.js +0 -854
  113. package/build/components.d.ts +0 -39
  114. package/build/components.js +0 -37
  115. package/build/create-portal/index.d.ts +0 -17
  116. package/build/create-portal/index.js +0 -128
  117. package/build/create-tunnel/index.d.ts +0 -29
  118. package/build/create-tunnel/index.js +0 -181
  119. package/build/descriptor-to-angular/index.d.ts +0 -19
  120. package/build/descriptor-to-angular/index.js +0 -186
  121. package/build/host-instance/index.d.ts +0 -2
  122. package/build/host-instance/index.js +0 -36
  123. package/build/index.d.ts +0 -21
  124. package/build/index.js +0 -40
  125. package/build/modules/animated/animated-leaf-binder/index.d.ts +0 -14
  126. package/build/modules/animated/animated-leaf-binder/index.js +0 -90
  127. package/build/modules/animated/animated-leaf-binder.d.ts +0 -14
  128. package/build/modules/animated/animated-leaf-binder.js +0 -90
  129. package/build/modules/animated/create-animated-component.d.ts +0 -48
  130. package/build/modules/animated/create-animated-component.js +0 -425
  131. package/build/modules/animated/index.d.ts +0 -51
  132. package/build/modules/animated/index.js +0 -58
  133. package/build/modules/app-registry/index.d.ts +0 -7
  134. package/build/modules/app-registry/index.js +0 -22
  135. package/build/modules/status-bar/index.d.ts +0 -17
  136. package/build/modules/status-bar/index.js +0 -121
  137. package/build/primitives/index.d.ts +0 -32
  138. package/build/primitives/index.js +0 -386
  139. package/build/primitives/shared.d.ts +0 -83
  140. package/build/primitives/shared.js +0 -230
  141. package/build/render/index.d.ts +0 -11
  142. package/build/render/index.js +0 -170
  143. package/build/renderer/index.d.ts +0 -38
  144. package/build/renderer/index.js +0 -355
  145. package/build/services/color-scheme.service.d.ts +0 -13
  146. package/build/services/color-scheme.service.js +0 -72
  147. package/build/services/index.d.ts +0 -2
  148. package/build/services/index.js +0 -2
  149. package/build/services/window-dimensions.service.d.ts +0 -13
  150. package/build/services/window-dimensions.service.js +0 -83
  151. package/src/__tests__/responder-change-detection.test.ts +0 -102
  152. package/src/__tests__/responder-nested-cd.test.ts +0 -113
  153. package/src/angular-gaps.test.ts +0 -142
  154. package/src/angular-imports.test.ts +0 -100
  155. package/src/components/activity-indicator/activity-indicator-class-style.test.ts +0 -44
  156. package/src/components/activity-indicator/activity-indicator.test.ts +0 -131
  157. package/src/components/flat-list/column-wrapper-style-class.test.ts +0 -116
  158. package/src/components/flat-list/flat-list-array-style.test.ts +0 -131
  159. package/src/components/flat-list/flat-list-class-style.test.ts +0 -74
  160. package/src/components/flat-list/flat-list-scroll-containment.test.ts +0 -107
  161. package/src/components/flat-list/flat-list.test.ts +0 -99
  162. package/src/components/image/image-class-style.test.ts +0 -46
  163. package/src/components/image-background-class-style.test.ts +0 -48
  164. package/src/components/image-background-style-class.test.ts +0 -79
  165. package/src/components/input-accessory-view/input-accessory-view.test.ts +0 -43
  166. package/src/components/keyboard-avoiding-view/keyboard-avoiding-view.test.ts +0 -54
  167. package/src/components/modal/modal.test.ts +0 -43
  168. package/src/components/pressable/pressable.test.ts +0 -85
  169. package/src/components/refresh-control/refresh-control.test.ts +0 -41
  170. package/src/components/safe-area-view/safe-area-view.test.ts +0 -43
  171. package/src/components/scroll-view/android-scroll-view-axis-projection.test.ts +0 -123
  172. package/src/components/scroll-view/content-container-style-class.test.ts +0 -75
  173. package/src/components/scroll-view/scroll-view-class-style.test.ts +0 -134
  174. package/src/components/scroll-view/scroll-view-projection.test.ts +0 -194
  175. package/src/components/switch/android-switch-class.test.ts +0 -42
  176. package/src/components/switch/switch.test.ts +0 -92
  177. package/src/components/text-input-class-style.test.ts +0 -54
  178. package/src/components/touchable/touchable.test.ts +0 -102
  179. package/src/components/touchable-native-feedback/touchable-native-feedback.test.ts +0 -49
  180. package/src/components/virtualized-list/virtualized-list-class-style.test.ts +0 -76
  181. package/src/components/virtualized-section-list/virtualized-section-list-class-style.test.ts +0 -60
  182. package/src/create-portal/create-portal.test.ts +0 -90
  183. package/src/create-tunnel/create-tunnel.test.ts +0 -120
  184. package/src/descriptor-to-angular/descriptor-outlet.test.ts +0 -94
  185. package/src/host-instance/host-instance.test.ts +0 -49
  186. package/src/modules/animated/animated-leaf-binder/animated-leaf-binder.test.ts +0 -116
  187. package/src/modules/animated/animated-leaf-binder.test.ts +0 -116
  188. package/src/modules/animated/animated-scroll-view.test.ts +0 -102
  189. package/src/modules/app-registry/app-registry.test.ts +0 -106
  190. package/src/modules/status-bar/status-bar.test.ts +0 -50
  191. package/src/render/render.test.ts +0 -147
  192. package/src/renderer/renderer.test.ts +0 -202
  193. package/src/services/services.test.ts +0 -163
@@ -1,90 +0,0 @@
1
- // Proves createPortal (create-portal.ts) paints content into an already-mounted destination
2
- // WITHIN THE SAME SURFACE — mirrors adapters/react/src/create-portal.test.tsx's "same surface,
3
- // already-mounted target" case (Angular has no cross-surface equivalent of this primitive;
4
- // createTunnel covers that, see create-tunnel.test.ts).
5
-
6
- import '@angular/compiler';
7
- import { Component, signal } from '@angular/core';
8
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
9
- import { installFabric, type IFakeNode } from '@symbiote-native/test-utils';
10
-
11
- import { mount, unmount } from '../render';
12
- import { ViewHost, TextHost } from '../primitives';
13
- import { PortalDirective, PortalOutletDirective } from './index';
14
-
15
- const ROOT_TAG = 930;
16
-
17
- const fabric = installFabric();
18
- const tick = (): Promise<void> => new Promise(resolve => setTimeout(resolve, 0));
19
- const settle = async (): Promise<void> => {
20
- await tick();
21
- await tick();
22
- };
23
-
24
- let capturedHost: HostApp | undefined;
25
-
26
- @Component({
27
- selector: 'symbiote-portal-host-app',
28
- standalone: true,
29
- imports: [ViewHost, TextHost, PortalDirective, PortalOutletDirective],
30
- template: `
31
- <View>
32
- <View portalOutlet #overlayHost="portalOutlet" testID="overlay-host"></View>
33
- @if (visible()) {
34
- <View *portal="overlayHost"><Text>portaled content</Text></View>
35
- }
36
- </View>
37
- `,
38
- })
39
- class HostApp {
40
- readonly visible = signal(false);
41
-
42
- constructor() {
43
- // Captures the live component instance so the test can drive its signals after mount.
44
- // eslint-disable-next-line @typescript-eslint/no-this-alias
45
- capturedHost = this;
46
- }
47
- }
48
-
49
- beforeEach(() => {
50
- capturedHost = undefined;
51
- fabric.reset();
52
- });
53
- afterEach(() => unmount(ROOT_TAG));
54
-
55
- function walk(nodes: IFakeNode[], visit: (node: IFakeNode) => void): void {
56
- for (const node of nodes) {
57
- visit(node);
58
- walk(node.children, visit);
59
- }
60
- }
61
-
62
- function findText(text: string): IFakeNode | undefined {
63
- let found: IFakeNode | undefined;
64
- walk(fabric.committed, node => {
65
- if (node.viewName === 'RCTRawText' && node.props.text === text) found = node;
66
- });
67
- return found;
68
- }
69
-
70
- describe('createPortal (Angular) — same-surface delivery', () => {
71
- it('renders nothing until the portal is toggled on', async () => {
72
- mount(ROOT_TAG, HostApp);
73
- await settle();
74
- expect(findText('portaled content')).toBeUndefined();
75
- });
76
-
77
- it('paints content into the outlet once toggled on, and removes it once toggled off', async () => {
78
- mount(ROOT_TAG, HostApp);
79
- await settle();
80
-
81
- if (!capturedHost) throw new Error('host was not captured');
82
- capturedHost.visible.set(true);
83
- await settle();
84
- expect(findText('portaled content'), 'painted once the portal renders').toBeDefined();
85
-
86
- capturedHost.visible.set(false);
87
- await settle();
88
- expect(findText('portaled content'), 'gone once the portal unmounts').toBeUndefined();
89
- });
90
- });
@@ -1,120 +0,0 @@
1
- // Proves createTunnel (create-tunnel.ts) actually delivers across two GENUINELY separate,
2
- // independently-mounted SymbioteSurfaces — the same proof React's/Vue's create-tunnel tests
3
- // give, via two real `mount()` calls on different rootTags. Mirrors
4
- // adapters/react/src/create-tunnel.test.tsx and adapters/vue/src/create-tunnel.test.ts.
5
-
6
- import '@angular/compiler';
7
- import { Component } from '@angular/core';
8
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
9
- import { installFabric, type IFakeNode } from '@symbiote-native/test-utils';
10
-
11
- import { mount, unmount } from '../render';
12
- import { ViewHost, TextHost } from '../primitives';
13
- import { createTunnel, TunnelInDirective, TunnelOut } from './index';
14
-
15
- const SOURCE_TAG = 920;
16
- const TARGET_TAG = 921;
17
-
18
- const fabric = installFabric();
19
- const tick = (): Promise<void> => new Promise(resolve => setTimeout(resolve, 0));
20
- const settle = async (): Promise<void> => {
21
- await tick();
22
- await tick();
23
- };
24
-
25
- beforeEach(() => fabric.reset());
26
- afterEach(() => {
27
- unmount(SOURCE_TAG);
28
- unmount(TARGET_TAG);
29
- });
30
-
31
- function walk(nodes: IFakeNode[], visit: (node: IFakeNode) => void): void {
32
- for (const node of nodes) {
33
- visit(node);
34
- walk(node.children, visit);
35
- }
36
- }
37
-
38
- function findText(text: string): IFakeNode | undefined {
39
- let found: IFakeNode | undefined;
40
- walk(fabric.committed, node => {
41
- if (node.viewName === 'RCTRawText' && node.props.text === text) found = node;
42
- });
43
- return found;
44
- }
45
-
46
- describe('createTunnel (Angular) — genuine cross-surface delivery', () => {
47
- it('paints content registered by surface A on surface B, a DIFFERENT mounted surface', async () => {
48
- const tunnel = createTunnel();
49
-
50
- @Component({
51
- selector: 'symbiote-tunnel-source-app',
52
- standalone: true,
53
- imports: [TextHost, TunnelInDirective],
54
- template: '<Text *tunnelIn="tunnel">ported across surfaces</Text>',
55
- })
56
- class SourceApp {
57
- readonly tunnel = tunnel;
58
- }
59
-
60
- @Component({
61
- selector: 'symbiote-tunnel-target-app',
62
- standalone: true,
63
- imports: [ViewHost, TunnelOut],
64
- template: '<View><tunnel-out [tunnel]="tunnel" /></View>',
65
- })
66
- class TargetApp {
67
- readonly tunnel = tunnel;
68
- }
69
-
70
- // Surface A registers, fully independently, before surface B ever mounts.
71
- mount(SOURCE_TAG, SourceApp);
72
- // Surface B mounts SEPARATELY (its own rootTag, its own SymbioteSurface) and reads the
73
- // tunnel via its own TunnelOut — no ref, no rootTag lookup, no shared Fabric node at all.
74
- mount(TARGET_TAG, TargetApp);
75
- await settle();
76
-
77
- // fake-fabric's `committed` is last-write-wins across rootTags (core/test-utils
78
- // limitation, not the engine's), so after mounting B second it reflects B's own tree.
79
- expect(
80
- findText('ported across surfaces'),
81
- 'content is present in the LAST-committed tree (surface B)',
82
- ).toBeDefined();
83
- });
84
-
85
- it('removes the content from the target once the source unmounts', async () => {
86
- const tunnel = createTunnel();
87
-
88
- @Component({
89
- selector: 'symbiote-tunnel-source-app-2',
90
- standalone: true,
91
- imports: [TextHost, TunnelInDirective],
92
- template: '<Text *tunnelIn="tunnel">still here</Text>',
93
- })
94
- class SourceApp {
95
- readonly tunnel = tunnel;
96
- }
97
-
98
- @Component({
99
- selector: 'symbiote-tunnel-target-app-2',
100
- standalone: true,
101
- imports: [ViewHost, TunnelOut],
102
- template: '<View><tunnel-out [tunnel]="tunnel" /></View>',
103
- })
104
- class TargetApp {
105
- readonly tunnel = tunnel;
106
- }
107
-
108
- mount(SOURCE_TAG, SourceApp);
109
- mount(TARGET_TAG, TargetApp);
110
- await settle();
111
- expect(findText('still here'), 'present while the source is mounted').toBeDefined();
112
-
113
- // Tearing down surface A destroys TunnelInDirective, whose ngOnDestroy unregisters from
114
- // the shared store; surface B's TunnelOut effect reacts on its own next tick and destroys
115
- // its view.
116
- unmount(SOURCE_TAG);
117
- await settle();
118
- expect(findText('still here'), 'gone from surface B after the source unmounts').toBeUndefined();
119
- });
120
- });
@@ -1,94 +0,0 @@
1
- import '@angular/compiler';
2
- import { Component, signal } from '@angular/core';
3
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
4
- import { el, txt, type IDescriptor } from '@symbiote-native/components';
5
- import { installFabric } from '@symbiote-native/test-utils';
6
-
7
- import { mount, unmount } from '../render';
8
- import { DescriptorOutlet } from './index.ts';
9
-
10
- const ROOT_TAG = 904;
11
- const fabric = installFabric();
12
-
13
- let capturedHost: DescriptorOutletHost | undefined;
14
-
15
- async function flushAngular(): Promise<void> {
16
- await Promise.resolve();
17
- await new Promise<void>(resolve => setTimeout(resolve, 0));
18
- }
19
-
20
- function currentOutletChild() {
21
- const child = fabric.appRoot().children[0];
22
- if (!child) throw new Error('descriptor outlet rendered no root child');
23
- return child;
24
- }
25
-
26
- @Component({
27
- selector: 'symbiote-descriptor-outlet-host',
28
- standalone: true,
29
- imports: [DescriptorOutlet],
30
- template: '<symbiote-descriptor-outlet [node]="node()" />',
31
- })
32
- class DescriptorOutletHost {
33
- readonly node = signal<IDescriptor>(
34
- el('symbiote-view', { testID: 'root', style: { width: 10 } }, [txt({}, ['hello'])]),
35
- );
36
-
37
- constructor() {
38
- // Captures the live component instance so the test can drive its signals after mount.
39
- // eslint-disable-next-line @typescript-eslint/no-this-alias
40
- capturedHost = this;
41
- }
42
- }
43
-
44
- beforeEach(() => {
45
- capturedHost = undefined;
46
- fabric.reset();
47
- });
48
- afterEach(() => unmount(ROOT_TAG));
49
-
50
- describe('DescriptorOutlet', () => {
51
- it('renders a Descriptor tree through Renderer2', async () => {
52
- mount(ROOT_TAG, DescriptorOutletHost);
53
- await flushAngular();
54
-
55
- expect(fabric.serialize(fabric.appRoot().children)).toBe(
56
- 'RCTView(RCTText(RCTRawText "hello"))',
57
- );
58
- const root = currentOutletChild();
59
- expect(root.props.testID).toBe('root');
60
- expect(root.props.width).toBe(10);
61
- });
62
-
63
- it('does not recommit a structurally identical descriptor through anchor flattening', async () => {
64
- mount(ROOT_TAG, DescriptorOutletHost);
65
- await flushAngular();
66
-
67
- const completeRootBefore = fabric.counts.completeRoot;
68
-
69
- capturedHost?.node.set(
70
- el('symbiote-view', { testID: 'root', style: { width: 10 } }, [txt({}, ['hello'])]),
71
- );
72
- await flushAngular();
73
-
74
- expect(fabric.counts.completeRoot).toBe(completeRootBefore);
75
- });
76
-
77
- it('patches same type/key descriptors without recreating the Fabric node', async () => {
78
- mount(ROOT_TAG, DescriptorOutletHost);
79
- await flushAngular();
80
-
81
- const before = currentOutletChild();
82
- const createdBefore = fabric.counts.createNode;
83
-
84
- capturedHost?.node.set(
85
- el('symbiote-view', { testID: 'root', style: { width: 20 } }, [txt({}, ['hello'])]),
86
- );
87
- await flushAngular();
88
-
89
- const after = currentOutletChild();
90
- expect(fabric.counts.createNode).toBe(createdBefore);
91
- expect(after.instanceHandle).toBe(before.instanceHandle);
92
- expect(after.props.width).toBe(20);
93
- });
94
- });
@@ -1,49 +0,0 @@
1
- // Co-located test for findNodeHandle, the Angular twin of adapters/vue/src/host-instance/host-instance.test.ts.
2
- // Proves the Angular adapter can resolve a raw engine node, an engine public instance, a bare
3
- // reactTag, and null/undefined to a native tag using the engine's getNativeTag.
4
-
5
- import { describe, expect, it } from 'vitest';
6
- import { createElement, createSurface, getNativeTag } from '@symbiote-native/engine';
7
- import { installFabric } from '@symbiote-native/test-utils';
8
- import { findNodeHandle } from './index';
9
-
10
- installFabric();
11
- const ROOT_TAG = 708;
12
-
13
- describe('Angular findNodeHandle on the engine', () => {
14
- it('returns the committed tag for a raw engine node', async () => {
15
- const surface = createSurface(ROOT_TAG);
16
- const node = createElement('RCTView');
17
- surface.appendChild(node);
18
- surface.commit();
19
- await new Promise<void>(resolve => setTimeout(resolve, 0));
20
-
21
- const tag = getNativeTag(node);
22
- expect(tag).toBeGreaterThan(0);
23
- expect(findNodeHandle(node)).toBe(tag);
24
- });
25
-
26
- it('returns the committed tag for a public instance (toPublicInstance graft)', async () => {
27
- const surface = createSurface(ROOT_TAG + 1);
28
- const node = createElement('RCTView');
29
- surface.appendChild(node);
30
- surface.commit();
31
- await new Promise<void>(resolve => setTimeout(resolve, 0));
32
-
33
- const tag = getNativeTag(node);
34
- // The public instance is the same identity as the engine node; findNodeHandle accepts it.
35
- const publicInstance = node;
36
- expect(findNodeHandle(publicInstance)).toBe(tag);
37
- });
38
-
39
- it('passes a bare number through idempotently', () => {
40
- expect(findNodeHandle(42)).toBe(42);
41
- });
42
-
43
- it('returns null for null, undefined, and unknown inputs', () => {
44
- expect(findNodeHandle(null)).toBeNull();
45
- expect(findNodeHandle(undefined)).toBeNull();
46
- expect(findNodeHandle('not-a-node' as any)).toBeNull();
47
- expect(findNodeHandle({} as any)).toBeNull();
48
- });
49
- });
@@ -1,116 +0,0 @@
1
- // Unit tests for AnimatedLeafBinder in isolation — no Angular involved. Both
2
- // AnimatedComponentBase and AnimatedImage delegate their leaf-lifecycle (build a leaf,
3
- // bind it to the committed Fabric node, swap leaves on re-render, tear down) to this Pure
4
- // Fabrication; these tests exercise the binder directly against a real engine node
5
- // (SymbioteSurface + the fake Fabric backend), so a break here isolates to the shared
6
- // orchestration rather than either owning component.
7
- import { beforeEach, describe, expect, it } from 'vitest';
8
- import { installFabric } from '@symbiote-native/test-utils';
9
- import {
10
- AnimatedValue,
11
- createElement,
12
- createSurface,
13
- type ISymbioteNode,
14
- } from '@symbiote-native/engine';
15
- import { AnimatedLeafBinder } from './index';
16
-
17
- const fabric = installFabric();
18
- let nextRootTag = 9001;
19
-
20
- beforeEach(() => fabric.reset());
21
-
22
- // A node that has already gone through a commit — whenCommitted fires synchronously.
23
- function committedNode(): ISymbioteNode {
24
- const surface = createSurface(nextRootTag++);
25
- const node = createElement('RCTView');
26
- surface.appendChild(node);
27
- surface.commit();
28
- return node;
29
- }
30
-
31
- // A node that is attached to a surface but has NOT been committed yet — whenCommitted
32
- // must defer until the caller commits the surface.
33
- function uncommittedNode(): { node: ISymbioteNode; commit: () => void } {
34
- const surface = createSurface(nextRootTag++);
35
- const node = createElement('RCTView');
36
- surface.appendChild(node);
37
- return { node, commit: () => surface.commit() };
38
- }
39
-
40
- // `appRoot()` unwraps RN's synthetic box-none AppContainer, which is ALSO an RCTView, so a
41
- // plain `fabric.find(viewName === 'RCTView')` would match it instead of the node under test.
42
- // Each test appends exactly one child, so the container's first (only) child is the real node.
43
- function fakeView(): ReturnType<typeof fabric.find> {
44
- return fabric.appRoot().children[0];
45
- }
46
-
47
- describe('AnimatedLeafBinder', () => {
48
- it('creates and attaches an AnimatedProps leaf, wiring value changes onto the host node', () => {
49
- const node = committedNode();
50
- const binder = new AnimatedLeafBinder(() => node, 'test');
51
- const opacity = new AnimatedValue(1);
52
-
53
- // The leaf itself never pushes the INITIAL value — that first paint comes from the
54
- // owning component's own reduceProps template binding (out of scope here). The leaf
55
- // only drives value CHANGES after it is bound.
56
- binder.reconcile({ style: { opacity } }, false);
57
-
58
- opacity.setValue(0.4);
59
- expect(fakeView()?.props.opacity).toBe(0.4);
60
- });
61
-
62
- it('binds to the host node via whenCommitted, deferring until the node is actually committed', () => {
63
- const { node, commit } = uncommittedNode();
64
- const binder = new AnimatedLeafBinder(() => node, 'test');
65
- const opacity = new AnimatedValue(1);
66
-
67
- binder.reconcile({ style: { opacity } }, false);
68
- // Not committed yet: the value graph exists, but no Fabric node to flush onto.
69
- opacity.setValue(0.5);
70
- expect(fabric.created).toHaveLength(0);
71
-
72
- commit();
73
- // whenCommitted's post-commit retry binds the leaf now; a subsequent change flushes.
74
- opacity.setValue(0.7);
75
- expect(fakeView()?.props.opacity).toBe(0.7);
76
- });
77
-
78
- it('attaches the new leaf before detaching the old one on a second reconcile', () => {
79
- const node = committedNode();
80
- const binder = new AnimatedLeafBinder(() => node, 'test');
81
- const shared = new AnimatedValue(1);
82
- const order: string[] = [];
83
- const originalAddChild = shared.__addChild.bind(shared);
84
- const originalRemoveChild = shared.__removeChild.bind(shared);
85
- shared.__addChild = child => {
86
- order.push('add');
87
- originalAddChild(child);
88
- };
89
- shared.__removeChild = child => {
90
- order.push('remove');
91
- originalRemoveChild(child);
92
- };
93
-
94
- binder.reconcile({ style: { opacity: shared } }, false);
95
- order.length = 0; // only care about the SECOND reconcile's swap order
96
-
97
- binder.reconcile({ style: { opacity: shared } }, false);
98
-
99
- expect(order).toEqual(['add', 'remove']);
100
- });
101
-
102
- it('detaches the leaf and cancels any pending bind on destroy', () => {
103
- const { node, commit } = uncommittedNode();
104
- const binder = new AnimatedLeafBinder(() => node, 'test');
105
- const opacity = new AnimatedValue(1);
106
-
107
- binder.reconcile({ style: { opacity } }, false);
108
- binder.destroy();
109
- commit();
110
-
111
- // The pending whenCommitted bind was cancelled by destroy, so committing afterward
112
- // must not retroactively bind the (already-detached) leaf.
113
- opacity.setValue(0.9);
114
- expect(fakeView()?.props.opacity).toBeUndefined();
115
- });
116
- });
@@ -1,116 +0,0 @@
1
- // Unit tests for AnimatedLeafBinder in isolation — no Angular involved. Both
2
- // AnimatedComponentBase and AnimatedImage delegate their leaf-lifecycle (build a leaf,
3
- // bind it to the committed Fabric node, swap leaves on re-render, tear down) to this Pure
4
- // Fabrication; these tests exercise the binder directly against a real engine node
5
- // (SymbioteSurface + the fake Fabric backend), so a break here isolates to the shared
6
- // orchestration rather than either owning component.
7
- import { beforeEach, describe, expect, it } from 'vitest';
8
- import { installFabric } from '@symbiote-native/test-utils';
9
- import {
10
- AnimatedValue,
11
- createElement,
12
- createSurface,
13
- type ISymbioteNode,
14
- } from '@symbiote-native/engine';
15
- import { AnimatedLeafBinder } from './animated-leaf-binder';
16
-
17
- const fabric = installFabric();
18
- let nextRootTag = 9001;
19
-
20
- beforeEach(() => fabric.reset());
21
-
22
- // A node that has already gone through a commit — whenCommitted fires synchronously.
23
- function committedNode(): ISymbioteNode {
24
- const surface = createSurface(nextRootTag++);
25
- const node = createElement('RCTView');
26
- surface.appendChild(node);
27
- surface.commit();
28
- return node;
29
- }
30
-
31
- // A node that is attached to a surface but has NOT been committed yet — whenCommitted
32
- // must defer until the caller commits the surface.
33
- function uncommittedNode(): { node: ISymbioteNode; commit: () => void } {
34
- const surface = createSurface(nextRootTag++);
35
- const node = createElement('RCTView');
36
- surface.appendChild(node);
37
- return { node, commit: () => surface.commit() };
38
- }
39
-
40
- // `appRoot()` unwraps RN's synthetic box-none AppContainer, which is ALSO an RCTView, so a
41
- // plain `fabric.find(viewName === 'RCTView')` would match it instead of the node under test.
42
- // Each test appends exactly one child, so the container's first (only) child is the real node.
43
- function fakeView(): ReturnType<typeof fabric.find> {
44
- return fabric.appRoot().children[0];
45
- }
46
-
47
- describe('AnimatedLeafBinder', () => {
48
- it('creates and attaches an AnimatedProps leaf, wiring value changes onto the host node', () => {
49
- const node = committedNode();
50
- const binder = new AnimatedLeafBinder(() => node, 'test');
51
- const opacity = new AnimatedValue(1);
52
-
53
- // The leaf itself never pushes the INITIAL value — that first paint comes from the
54
- // owning component's own reduceProps template binding (out of scope here). The leaf
55
- // only drives value CHANGES after it is bound.
56
- binder.reconcile({ style: { opacity } }, false);
57
-
58
- opacity.setValue(0.4);
59
- expect(fakeView()?.props.opacity).toBe(0.4);
60
- });
61
-
62
- it('binds to the host node via whenCommitted, deferring until the node is actually committed', () => {
63
- const { node, commit } = uncommittedNode();
64
- const binder = new AnimatedLeafBinder(() => node, 'test');
65
- const opacity = new AnimatedValue(1);
66
-
67
- binder.reconcile({ style: { opacity } }, false);
68
- // Not committed yet: the value graph exists, but no Fabric node to flush onto.
69
- opacity.setValue(0.5);
70
- expect(fabric.created).toHaveLength(0);
71
-
72
- commit();
73
- // whenCommitted's post-commit retry binds the leaf now; a subsequent change flushes.
74
- opacity.setValue(0.7);
75
- expect(fakeView()?.props.opacity).toBe(0.7);
76
- });
77
-
78
- it('attaches the new leaf before detaching the old one on a second reconcile', () => {
79
- const node = committedNode();
80
- const binder = new AnimatedLeafBinder(() => node, 'test');
81
- const shared = new AnimatedValue(1);
82
- const order: string[] = [];
83
- const originalAddChild = shared.__addChild.bind(shared);
84
- const originalRemoveChild = shared.__removeChild.bind(shared);
85
- shared.__addChild = child => {
86
- order.push('add');
87
- originalAddChild(child);
88
- };
89
- shared.__removeChild = child => {
90
- order.push('remove');
91
- originalRemoveChild(child);
92
- };
93
-
94
- binder.reconcile({ style: { opacity: shared } }, false);
95
- order.length = 0; // only care about the SECOND reconcile's swap order
96
-
97
- binder.reconcile({ style: { opacity: shared } }, false);
98
-
99
- expect(order).toEqual(['add', 'remove']);
100
- });
101
-
102
- it('detaches the leaf and cancels any pending bind on destroy', () => {
103
- const { node, commit } = uncommittedNode();
104
- const binder = new AnimatedLeafBinder(() => node, 'test');
105
- const opacity = new AnimatedValue(1);
106
-
107
- binder.reconcile({ style: { opacity } }, false);
108
- binder.destroy();
109
- commit();
110
-
111
- // The pending whenCommitted bind was cancelled by destroy, so committing afterward
112
- // must not retroactively bind the (already-detached) leaf.
113
- opacity.setValue(0.9);
114
- expect(fakeView()?.props.opacity).toBeUndefined();
115
- });
116
- });
@@ -1,102 +0,0 @@
1
- // Regression tests for two Android-only bugs AnimatedScrollView's bespoke template hit because
2
- // it talks to the raw symbiote-scroll-view primitive directly instead of reusing the real
3
- // ScrollView component (which already has both fixes — see scroll-view/shared.ts):
4
- //
5
- // 1. It projected <ng-content> straight into symbiote-scroll-view with no content wrapper. On
6
- // Android, symbiote-scroll-content resolves to a plain RCTView, which Fabric view-flattens
7
- // away unless collapsable:false pins it — so multiple projected children were hoisted up as
8
- // direct children of the scroll view, which natively hosts exactly one ("ScrollView can
9
- // host only one direct child" -> addViewAt crash).
10
- // 2. It never defaulted nestedScrollEnabled. RN defaults nested scrolling ON (ScrollView.js
11
- // `nestedScrollEnabled ?? true`), but Android needs it explicit or a ScrollView nested
12
- // inside another scrollable container (this canary's own nested demo) never receives touch
13
- // — it renders fine but is static, the outer ScrollView swallows the gesture.
14
- //
15
- // The fake Fabric harness doesn't simulate Android's real view-flattening or touch dispatch, so
16
- // these tests only prove the structural/prop invariants that prevent both bugs, not the
17
- // on-device symptoms themselves — those still need a real Android host.
18
- import '@angular/compiler';
19
- import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
20
- import { afterEach, beforeEach, describe, expect, it } from 'vitest';
21
- import { installFabric } from '@symbiote-native/test-utils';
22
- import { mount, unmount } from '../../render';
23
- import { AnimatedScrollView } from './create-animated-component';
24
-
25
- const ROOT_TAG = 927;
26
- const OVERRIDE_ROOT_TAG = 928;
27
- const fabric = installFabric();
28
- const tick = (): Promise<void> => new Promise(resolve => setTimeout(resolve, 0));
29
-
30
- class AnimatedScrollViewApp {}
31
- Component({
32
- selector: 'animated-scroll-view-test',
33
- standalone: true,
34
- imports: [AnimatedScrollView],
35
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
36
- template: `
37
- <AnimatedScrollView>
38
- <symbiote-view testID="a"></symbiote-view>
39
- <symbiote-view testID="b"></symbiote-view>
40
- </AnimatedScrollView>
41
- `,
42
- })(AnimatedScrollViewApp);
43
-
44
- class AnimatedScrollViewOverrideApp {}
45
- Component({
46
- selector: 'animated-scroll-view-override-test',
47
- standalone: true,
48
- imports: [AnimatedScrollView],
49
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
50
- template: `
51
- <AnimatedScrollView [animatedProps]="{ nestedScrollEnabled: false }">
52
- <symbiote-view testID="a"></symbiote-view>
53
- </AnimatedScrollView>
54
- `,
55
- })(AnimatedScrollViewOverrideApp);
56
-
57
- beforeEach(() => fabric.reset());
58
- afterEach(() => {
59
- unmount(ROOT_TAG);
60
- unmount(OVERRIDE_ROOT_TAG);
61
- });
62
-
63
- describe('AnimatedScrollView', () => {
64
- it('wraps multiple projected children in a single non-collapsable content view', async () => {
65
- mount(ROOT_TAG, AnimatedScrollViewApp);
66
- await tick();
67
-
68
- const scrollView = fabric.find(node => node.viewName === 'RCTScrollView');
69
- expect(scrollView?.children).toHaveLength(1);
70
- expect(scrollView?.props.nestedScrollEnabled).toBe(true);
71
-
72
- const content = scrollView?.children[0];
73
- expect(content?.viewName).toBe('RCTScrollContentView');
74
- expect(content?.props.collapsable).toBe(false);
75
- expect(content?.children.map(child => child.props.testID)).toEqual(['a', 'b']);
76
- });
77
-
78
- // Regression test for a THIRD bug in this same bespoke-template class, this one iOS-only (the
79
- // inverse of the two Android bugs above): AnimatedScrollView never applied
80
- // selectScrollIntrinsics' scrollViewBaseStyle (overflow: 'scroll') to its host node, unlike the
81
- // real ScrollView component. On iOS Fabric a scroll view only clips its content to its own
82
- // frame when `overflow: 'scroll'` is set; without it, content taller than the frame bleeds out
83
- // over sibling views instead of scrolling clipped (Android's native ViewGroup clips regardless
84
- // of the style prop, which is why this was invisible there). See
85
- // core/components/src/view/render-scroll-view.ts's SCROLL_VIEW_BASE_VERTICAL comment.
86
- it('applies the scroll-view base style (overflow: scroll) so content clips to the frame', async () => {
87
- mount(ROOT_TAG, AnimatedScrollViewApp);
88
- await tick();
89
-
90
- const scrollView = fabric.find(node => node.viewName === 'RCTScrollView');
91
- expect(scrollView?.props.overflow).toBe('scroll');
92
- expect(scrollView?.props.flexDirection).toBe('column');
93
- });
94
-
95
- it('lets an explicit nestedScrollEnabled in animatedProps override the default', async () => {
96
- mount(OVERRIDE_ROOT_TAG, AnimatedScrollViewOverrideApp);
97
- await tick();
98
-
99
- const scrollView = fabric.find(node => node.viewName === 'RCTScrollView');
100
- expect(scrollView?.props.nestedScrollEnabled).toBe(false);
101
- });
102
- });