@symbiote-native/angular 0.0.0-canary-20260724081123
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.
- package/LICENSE +21 -0
- package/README.md +157 -0
- package/babel-linker.cjs +7 -0
- package/babel-register-composed.cjs +127 -0
- package/bin/symbiote-angular-dev.cjs +93 -0
- package/build/angular/anchor-host-registry.d.ts +2 -0
- package/build/angular/anchor-host-registry.js +84 -0
- package/build/angular/anchor-host-registry.js.map +1 -0
- package/build/angular/bootstrap.d.ts +7 -0
- package/build/angular/bootstrap.js +15 -0
- package/build/angular/bootstrap.js.map +1 -0
- package/build/angular/components/activity-indicator/index.android.d.ts +12 -0
- package/build/angular/components/activity-indicator/index.android.js +21 -0
- package/build/angular/components/activity-indicator/index.android.js.map +1 -0
- package/build/angular/components/activity-indicator/index.d.ts +1 -0
- package/build/angular/components/activity-indicator/index.ios.d.ts +8 -0
- package/build/angular/components/activity-indicator/index.ios.js +21 -0
- package/build/angular/components/activity-indicator/index.ios.js.map +1 -0
- package/build/angular/components/activity-indicator/index.js +4 -0
- package/build/angular/components/activity-indicator/index.js.map +1 -0
- package/build/angular/components/activity-indicator/shared.d.ts +67 -0
- package/build/angular/components/activity-indicator/shared.js +260 -0
- package/build/angular/components/activity-indicator/shared.js.map +1 -0
- package/build/angular/components/button.d.ts +63 -0
- package/build/angular/components/button.js +332 -0
- package/build/angular/components/button.js.map +1 -0
- package/build/angular/components/flat-list/index.d.ts +122 -0
- package/build/angular/components/flat-list/index.js +688 -0
- package/build/angular/components/flat-list/index.js.map +1 -0
- package/build/angular/components/image/index.android.d.ts +10 -0
- package/build/angular/components/image/index.android.js +59 -0
- package/build/angular/components/image/index.android.js.map +1 -0
- package/build/angular/components/image/index.d.ts +1 -0
- package/build/angular/components/image/index.ios.d.ts +10 -0
- package/build/angular/components/image/index.ios.js +59 -0
- package/build/angular/components/image/index.ios.js.map +1 -0
- package/build/angular/components/image/index.js +3 -0
- package/build/angular/components/image/index.js.map +1 -0
- package/build/angular/components/image/shared.d.ts +101 -0
- package/build/angular/components/image/shared.js +406 -0
- package/build/angular/components/image/shared.js.map +1 -0
- package/build/angular/components/image-background.d.ts +81 -0
- package/build/angular/components/image-background.js +418 -0
- package/build/angular/components/image-background.js.map +1 -0
- package/build/angular/components/input-accessory-view/index.d.ts +60 -0
- package/build/angular/components/input-accessory-view/index.js +251 -0
- package/build/angular/components/input-accessory-view/index.js.map +1 -0
- package/build/angular/components/keyboard-avoiding-view/index.d.ts +82 -0
- package/build/angular/components/keyboard-avoiding-view/index.js +358 -0
- package/build/angular/components/keyboard-avoiding-view/index.js.map +1 -0
- package/build/angular/components/modal/index.d.ts +92 -0
- package/build/angular/components/modal/index.js +360 -0
- package/build/angular/components/modal/index.js.map +1 -0
- package/build/angular/components/pressable/index.d.ts +123 -0
- package/build/angular/components/pressable/index.js +420 -0
- package/build/angular/components/pressable/index.js.map +1 -0
- package/build/angular/components/refresh-control/index.d.ts +86 -0
- package/build/angular/components/refresh-control/index.js +342 -0
- package/build/angular/components/refresh-control/index.js.map +1 -0
- package/build/angular/components/safe-area-view/index.d.ts +57 -0
- package/build/angular/components/safe-area-view/index.js +248 -0
- package/build/angular/components/safe-area-view/index.js.map +1 -0
- package/build/angular/components/scroll-view/index.android.d.ts +21 -0
- package/build/angular/components/scroll-view/index.android.js +235 -0
- package/build/angular/components/scroll-view/index.android.js.map +1 -0
- package/build/angular/components/scroll-view/index.d.ts +3 -0
- package/build/angular/components/scroll-view/index.ios.d.ts +9 -0
- package/build/angular/components/scroll-view/index.ios.js +86 -0
- package/build/angular/components/scroll-view/index.ios.js.map +1 -0
- package/build/angular/components/scroll-view/index.js +6 -0
- package/build/angular/components/scroll-view/index.js.map +1 -0
- package/build/angular/components/scroll-view/projection.d.ts +32 -0
- package/build/angular/components/scroll-view/projection.js +334 -0
- package/build/angular/components/scroll-view/projection.js.map +1 -0
- package/build/angular/components/scroll-view/shared.d.ts +230 -0
- package/build/angular/components/scroll-view/shared.js +682 -0
- package/build/angular/components/scroll-view/shared.js.map +1 -0
- package/build/angular/components/scroll-view/sticky-header.d.ts +40 -0
- package/build/angular/components/scroll-view/sticky-header.js +225 -0
- package/build/angular/components/scroll-view/sticky-header.js.map +1 -0
- package/build/angular/components/section-list/index.d.ts +116 -0
- package/build/angular/components/section-list/index.js +641 -0
- package/build/angular/components/section-list/index.js.map +1 -0
- package/build/angular/components/switch/index.android.d.ts +20 -0
- package/build/angular/components/switch/index.android.js +70 -0
- package/build/angular/components/switch/index.android.js.map +1 -0
- package/build/angular/components/switch/index.d.ts +1 -0
- package/build/angular/components/switch/index.ios.d.ts +19 -0
- package/build/angular/components/switch/index.ios.js +69 -0
- package/build/angular/components/switch/index.ios.js.map +1 -0
- package/build/angular/components/switch/index.js +4 -0
- package/build/angular/components/switch/index.js.map +1 -0
- package/build/angular/components/switch/shared.d.ts +40 -0
- package/build/angular/components/switch/shared.js +127 -0
- package/build/angular/components/switch/shared.js.map +1 -0
- package/build/angular/components/text-input.d.ts +153 -0
- package/build/angular/components/text-input.js +599 -0
- package/build/angular/components/text-input.js.map +1 -0
- package/build/angular/components/touchable/index.d.ts +245 -0
- package/build/angular/components/touchable/index.js +1186 -0
- package/build/angular/components/touchable/index.js.map +1 -0
- package/build/angular/components/touchable-native-feedback/index.d.ts +83 -0
- package/build/angular/components/touchable-native-feedback/index.js +371 -0
- package/build/angular/components/touchable-native-feedback/index.js.map +1 -0
- package/build/angular/components/virtualized-list/directives.d.ts +54 -0
- package/build/angular/components/virtualized-list/directives.js +153 -0
- package/build/angular/components/virtualized-list/directives.js.map +1 -0
- package/build/angular/components/virtualized-list/index.d.ts +253 -0
- package/build/angular/components/virtualized-list/index.js +1031 -0
- package/build/angular/components/virtualized-list/index.js.map +1 -0
- package/build/angular/components/virtualized-section-list/directives.d.ts +37 -0
- package/build/angular/components/virtualized-section-list/directives.js +76 -0
- package/build/angular/components/virtualized-section-list/directives.js.map +1 -0
- package/build/angular/components/virtualized-section-list/index.d.ts +178 -0
- package/build/angular/components/virtualized-section-list/index.js +720 -0
- package/build/angular/components/virtualized-section-list/index.js.map +1 -0
- package/build/angular/components.d.ts +39 -0
- package/build/angular/components.js +38 -0
- package/build/angular/components.js.map +1 -0
- package/build/angular/create-portal/index.d.ts +22 -0
- package/build/angular/create-portal/index.js +74 -0
- package/build/angular/create-portal/index.js.map +1 -0
- package/build/angular/create-tunnel/index.d.ts +34 -0
- package/build/angular/create-tunnel/index.js +126 -0
- package/build/angular/create-tunnel/index.js.map +1 -0
- package/build/angular/descriptor-to-angular/index.d.ts +22 -0
- package/build/angular/descriptor-to-angular/index.js +142 -0
- package/build/angular/descriptor-to-angular/index.js.map +1 -0
- package/build/angular/host-instance/index.d.ts +2 -0
- package/build/angular/host-instance/index.js +37 -0
- package/build/angular/host-instance/index.js.map +1 -0
- package/build/angular/index.d.ts +22 -0
- package/build/angular/index.js +46 -0
- package/build/angular/index.js.map +1 -0
- package/build/angular/modules/animated/animated-leaf-binder/index.d.ts +14 -0
- package/build/angular/modules/animated/animated-leaf-binder/index.js +91 -0
- package/build/angular/modules/animated/animated-leaf-binder/index.js.map +1 -0
- package/build/angular/modules/animated/animated-leaf-binder.d.ts +14 -0
- package/build/angular/modules/animated/animated-leaf-binder.js +91 -0
- package/build/angular/modules/animated/animated-leaf-binder.js.map +1 -0
- package/build/angular/modules/animated/create-animated-component.d.ts +59 -0
- package/build/angular/modules/animated/create-animated-component.js +364 -0
- package/build/angular/modules/animated/create-animated-component.js.map +1 -0
- package/build/angular/modules/animated/index.d.ts +51 -0
- package/build/angular/modules/animated/index.js +59 -0
- package/build/angular/modules/animated/index.js.map +1 -0
- package/build/angular/modules/app-registry/index.d.ts +7 -0
- package/build/angular/modules/app-registry/index.js +23 -0
- package/build/angular/modules/app-registry/index.js.map +1 -0
- package/build/angular/modules/status-bar/index.d.ts +20 -0
- package/build/angular/modules/status-bar/index.js +59 -0
- package/build/angular/modules/status-bar/index.js.map +1 -0
- package/build/angular/primitives/index.d.ts +63 -0
- package/build/angular/primitives/index.js +189 -0
- package/build/angular/primitives/index.js.map +1 -0
- package/build/angular/primitives/shared.d.ts +88 -0
- package/build/angular/primitives/shared.js +171 -0
- package/build/angular/primitives/shared.js.map +1 -0
- package/build/angular/render/index.d.ts +11 -0
- package/build/angular/render/index.js +171 -0
- package/build/angular/render/index.js.map +1 -0
- package/build/angular/renderer/index.d.ts +37 -0
- package/build/angular/renderer/index.js +301 -0
- package/build/angular/renderer/index.js.map +1 -0
- package/build/angular/services/color-scheme.service.d.ts +16 -0
- package/build/angular/services/color-scheme.service.js +31 -0
- package/build/angular/services/color-scheme.service.js.map +1 -0
- package/build/angular/services/index.d.ts +2 -0
- package/build/angular/services/index.js +3 -0
- package/build/angular/services/index.js.map +1 -0
- package/build/angular/services/window-dimensions.service.d.ts +16 -0
- package/build/angular/services/window-dimensions.service.js +42 -0
- package/build/angular/services/window-dimensions.service.js.map +1 -0
- package/metro-config.cjs +48 -0
- package/metro-css-parser.cjs +13 -0
- package/package.json +80 -0
- package/src/__tests__/responder-change-detection.test.ts +102 -0
- package/src/__tests__/responder-nested-cd.test.ts +113 -0
- package/src/anchor-host-registry.ts +88 -0
- package/src/angular-gaps.test.ts +142 -0
- package/src/angular-imports.test.ts +100 -0
- package/src/bootstrap.ts +26 -0
- package/src/components/activity-indicator/activity-indicator-class-style.test.ts +44 -0
- package/src/components/activity-indicator/activity-indicator.test.ts +131 -0
- package/src/components/activity-indicator/index.android.ts +16 -0
- package/src/components/activity-indicator/index.ios.ts +17 -0
- package/src/components/activity-indicator/index.ts +4 -0
- package/src/components/activity-indicator/shared.ts +206 -0
- package/src/components/button.ts +193 -0
- package/src/components/flat-list/column-wrapper-style-class.test.ts +116 -0
- package/src/components/flat-list/flat-list-array-style.test.ts +131 -0
- package/src/components/flat-list/flat-list-class-style.test.ts +74 -0
- package/src/components/flat-list/flat-list-scroll-containment.test.ts +107 -0
- package/src/components/flat-list/flat-list.test.ts +99 -0
- package/src/components/flat-list/index.ts +574 -0
- package/src/components/image/image-class-style.test.ts +46 -0
- package/src/components/image/index.android.ts +48 -0
- package/src/components/image/index.ios.ts +48 -0
- package/src/components/image/index.ts +3 -0
- package/src/components/image/shared.ts +479 -0
- package/src/components/image-background-class-style.test.ts +48 -0
- package/src/components/image-background-style-class.test.ts +79 -0
- package/src/components/image-background.ts +270 -0
- package/src/components/input-accessory-view/index.ts +185 -0
- package/src/components/input-accessory-view/input-accessory-view.test.ts +43 -0
- package/src/components/keyboard-avoiding-view/index.ts +303 -0
- package/src/components/keyboard-avoiding-view/keyboard-avoiding-view.test.ts +54 -0
- package/src/components/modal/index.ts +299 -0
- package/src/components/modal/modal.test.ts +43 -0
- package/src/components/pressable/index.ts +373 -0
- package/src/components/pressable/pressable.test.ts +85 -0
- package/src/components/refresh-control/index.ts +284 -0
- package/src/components/refresh-control/refresh-control.test.ts +41 -0
- package/src/components/safe-area-view/index.ts +177 -0
- package/src/components/safe-area-view/safe-area-view.test.ts +43 -0
- package/src/components/scroll-view/android-scroll-view-axis-projection.test.ts +123 -0
- package/src/components/scroll-view/content-container-style-class.test.ts +75 -0
- package/src/components/scroll-view/index.android.ts +190 -0
- package/src/components/scroll-view/index.ios.ts +79 -0
- package/src/components/scroll-view/index.ts +7 -0
- package/src/components/scroll-view/projection.ts +414 -0
- package/src/components/scroll-view/scroll-view-class-style.test.ts +134 -0
- package/src/components/scroll-view/scroll-view-projection.test.ts +194 -0
- package/src/components/scroll-view/shared.ts +844 -0
- package/src/components/scroll-view/sticky-header.ts +255 -0
- package/src/components/section-list/index.ts +445 -0
- package/src/components/switch/android-switch-class.test.ts +42 -0
- package/src/components/switch/index.android.ts +61 -0
- package/src/components/switch/index.ios.ts +60 -0
- package/src/components/switch/index.ts +4 -0
- package/src/components/switch/shared.ts +197 -0
- package/src/components/switch/switch.test.ts +92 -0
- package/src/components/text-input-class-style.test.ts +54 -0
- package/src/components/text-input.ts +531 -0
- package/src/components/touchable/index.ts +629 -0
- package/src/components/touchable/touchable.test.ts +102 -0
- package/src/components/touchable-native-feedback/index.ts +254 -0
- package/src/components/touchable-native-feedback/touchable-native-feedback.test.ts +49 -0
- package/src/components/virtualized-list/directives.ts +168 -0
- package/src/components/virtualized-list/index.ts +992 -0
- package/src/components/virtualized-list/virtualized-list-class-style.test.ts +76 -0
- package/src/components/virtualized-section-list/directives.ts +90 -0
- package/src/components/virtualized-section-list/index.ts +601 -0
- package/src/components/virtualized-section-list/virtualized-section-list-class-style.test.ts +60 -0
- package/src/components.ts +149 -0
- package/src/create-portal/create-portal.test.ts +90 -0
- package/src/create-portal/index.ts +74 -0
- package/src/create-tunnel/create-tunnel.test.ts +120 -0
- package/src/create-tunnel/index.ts +136 -0
- package/src/descriptor-to-angular/descriptor-outlet.test.ts +94 -0
- package/src/descriptor-to-angular/index.ts +190 -0
- package/src/host-instance/host-instance.test.ts +49 -0
- package/src/host-instance/index.ts +36 -0
- package/src/index.ts +261 -0
- package/src/modules/animated/animated-leaf-binder/animated-leaf-binder.test.ts +116 -0
- package/src/modules/animated/animated-leaf-binder/index.ts +101 -0
- package/src/modules/animated/animated-leaf-binder.test.ts +116 -0
- package/src/modules/animated/animated-leaf-binder.ts +101 -0
- package/src/modules/animated/animated-scroll-view.test.ts +102 -0
- package/src/modules/animated/create-animated-component.ts +365 -0
- package/src/modules/animated/index.ts +105 -0
- package/src/modules/app-registry/app-registry.test.ts +106 -0
- package/src/modules/app-registry/index.ts +60 -0
- package/src/modules/status-bar/index.ts +57 -0
- package/src/modules/status-bar/status-bar.test.ts +50 -0
- package/src/primitives/index.ts +119 -0
- package/src/primitives/shared.ts +190 -0
- package/src/render/index.ts +235 -0
- package/src/render/render.test.ts +147 -0
- package/src/renderer/index.ts +347 -0
- package/src/renderer/renderer.test.ts +203 -0
- package/src/services/color-scheme.service.ts +27 -0
- package/src/services/index.ts +2 -0
- package/src/services/services.test.ts +163 -0
- package/src/services/window-dimensions.service.ts +41 -0
- package/tsconfig.angular.base.json +30 -0
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
// createAnimatedComponent for @symbiote-native/angular: the Angular twin of the React/Vue
|
|
2
|
+
// wrapper. React/Vue have a runtime HOC (`createAnimatedComponent(Component)` builds a
|
|
3
|
+
// fresh wrapped component on the fly). Angular has NO such idiom AND it cannot have one:
|
|
4
|
+
// the AOT-under-Metro build compiles every @Component at build
|
|
5
|
+
// time and ships NO JIT compiler to Hermes, so a runtime `Component({...})(class)` would
|
|
6
|
+
// throw. The idiomatic, AOT-safe equivalent is therefore an EXPLICIT set of standalone
|
|
7
|
+
// components — AnimatedView / AnimatedText / AnimatedImage / AnimatedScrollView — each a
|
|
8
|
+
// thin @Component over the matching host primitive, all sharing one abstract lifecycle
|
|
9
|
+
// base. The mechanism (build an AnimatedProps leaf, reduce animated props to current
|
|
10
|
+
// values for the first paint, bind the leaf to the committed host node, swap leaves on
|
|
11
|
+
// re-render, tear down on destroy) lives once in AnimatedComponentBase; only the per-host
|
|
12
|
+
// template differs.
|
|
13
|
+
//
|
|
14
|
+
// The framework-agnostic half (reduceProps / readPassthroughStyle / resolveHostNode /
|
|
15
|
+
// AnimatedProps / attachNativeEventHandler / isNativeAnimatedAvailable) comes from
|
|
16
|
+
// @symbiote-native/engine, shared verbatim with React and Vue. Angular supplies
|
|
17
|
+
// only the lifecycle wiring. The per-frame path NEVER goes through Angular change
|
|
18
|
+
// detection: value.setValue / animation -> flushValue -> AnimatedProps.update() ->
|
|
19
|
+
// setNativeProps(node), exactly as on the other adapters.
|
|
20
|
+
|
|
21
|
+
import {
|
|
22
|
+
ChangeDetectionStrategy,
|
|
23
|
+
Component,
|
|
24
|
+
CUSTOM_ELEMENTS_SCHEMA,
|
|
25
|
+
Directive,
|
|
26
|
+
ElementRef,
|
|
27
|
+
inject,
|
|
28
|
+
ViewChild,
|
|
29
|
+
type AfterViewInit,
|
|
30
|
+
type OnChanges,
|
|
31
|
+
type OnDestroy,
|
|
32
|
+
type Type,
|
|
33
|
+
} from '@angular/core';
|
|
34
|
+
import {
|
|
35
|
+
isNativeAnimatedAvailable,
|
|
36
|
+
isSymbioteNode,
|
|
37
|
+
reduceProps,
|
|
38
|
+
readPassthroughStyle,
|
|
39
|
+
resolveHostNode,
|
|
40
|
+
type ISymbioteNode,
|
|
41
|
+
} from '@symbiote-native/engine';
|
|
42
|
+
import { selectScrollIntrinsics } from '@symbiote-native/components';
|
|
43
|
+
import { Image, ScrollView, Text, View } from '../../components';
|
|
44
|
+
import {
|
|
45
|
+
anchorHostStyle,
|
|
46
|
+
ViewHost,
|
|
47
|
+
TextHost,
|
|
48
|
+
ImageHost,
|
|
49
|
+
ScrollViewHost,
|
|
50
|
+
SymbioteHostPropsDirective,
|
|
51
|
+
} from '../../primitives';
|
|
52
|
+
import { FlatList } from '../../components/flat-list';
|
|
53
|
+
import {
|
|
54
|
+
IMAGE_INPUTS,
|
|
55
|
+
IMAGE_OUTPUTS,
|
|
56
|
+
ImageBase,
|
|
57
|
+
resolveImageProps,
|
|
58
|
+
} from '../../components/image/shared';
|
|
59
|
+
import { SectionList } from '../../components/section-list';
|
|
60
|
+
import { AnimatedLeafBinder } from './animated-leaf-binder';
|
|
61
|
+
|
|
62
|
+
// RN's prop carrying explicit (already-rasterized) values that override the animated prop in
|
|
63
|
+
// the COMMITTED props (sticky-header passthrough). Named once so the directive input and the
|
|
64
|
+
// reconcile agree.
|
|
65
|
+
const PASSTHROUGH_PROP = 'passthroughAnimatedPropExplicitValues';
|
|
66
|
+
|
|
67
|
+
// The inputs every animated wrapper accepts. `style` is the (possibly animated) style — the
|
|
68
|
+
// common path (TouchableOpacity passes `[style, { opacity }]`). `animatedProps` is the generic
|
|
69
|
+
// escape hatch for any OTHER prop that may hold an AnimatedNode or an Animated.event handler,
|
|
70
|
+
// plus static host props to forward (the React/Vue `rest`). The passthrough drives native.
|
|
71
|
+
// Each concrete @Component re-lists these (Angular's inputs-on-base convention, mirroring
|
|
72
|
+
// Switch/Image), so they are inherited consistently.
|
|
73
|
+
export const ANIMATED_INPUTS = ['style', 'animatedProps', PASSTHROUGH_PROP];
|
|
74
|
+
export const ANIMATED_IMAGE_INPUTS = [...IMAGE_INPUTS, 'animatedProps', PASSTHROUGH_PROP];
|
|
75
|
+
|
|
76
|
+
// The shared lifecycle for every animated wrapper. Concrete subclasses add ONLY a @Component
|
|
77
|
+
// decorator (selector + the host-primitive template) — no behavior. Plain fields (no @Input
|
|
78
|
+
// here): the inputs are declared on each concrete via ANIMATED_INPUTS, the adapter convention.
|
|
79
|
+
// @Directive() (no selector) is the Angular-sanctioned decorator for an abstract base that
|
|
80
|
+
// declares lifecycle hooks — without it ngtsc rejects the inherited hooks (NG2007).
|
|
81
|
+
@Directive()
|
|
82
|
+
export abstract class AnimatedComponentBase implements AfterViewInit, OnChanges, OnDestroy {
|
|
83
|
+
style: unknown;
|
|
84
|
+
animatedProps: Record<string, unknown> | undefined;
|
|
85
|
+
passthroughAnimatedPropExplicitValues: unknown;
|
|
86
|
+
|
|
87
|
+
// This component's OWN host — every Animated* wrapper is a non-painting ANCHOR
|
|
88
|
+
// (ANCHOR_HOST_COMPONENTS in renderer.ts), so a `class="..."` at the use site resolves onto
|
|
89
|
+
// THIS element, never the real inner host primitive one level down (see anchorHostStyle's doc
|
|
90
|
+
// comment in primitives/shared.ts — the same reason ScrollView's own scrollProps merges it in).
|
|
91
|
+
private readonly elementRef = inject(ElementRef);
|
|
92
|
+
|
|
93
|
+
// The directive sitting on the inner host primitive; its `node` is the committed SymbioteNode
|
|
94
|
+
// the leaf binds to. Inherited by the decorated subclass (Angular collects base-class queries).
|
|
95
|
+
@ViewChild(SymbioteHostPropsDirective) private hostDirective?: SymbioteHostPropsDirective;
|
|
96
|
+
|
|
97
|
+
// The leaf-lifecycle orchestration (build/attach/swap/bind/detach an AnimatedProps leaf) is a
|
|
98
|
+
// Pure Fabrication shared with AnimatedImage, which cannot extend this class (it must extend
|
|
99
|
+
// ImageBase — see the file header). `resolveNode` stays a resolver, not a captured node: the
|
|
100
|
+
// committed node only exists after `hostDirective` is populated post-view-init.
|
|
101
|
+
private readonly leafBinder = new AnimatedLeafBinder(
|
|
102
|
+
() => this.hostNode(),
|
|
103
|
+
this.constructor.name,
|
|
104
|
+
);
|
|
105
|
+
// Set once the view (and the inner host directive) exists; ngOnChanges before then is a no-op.
|
|
106
|
+
private viewReady = false;
|
|
107
|
+
|
|
108
|
+
// The concrete props for the host element each change-detection pass: animated entries reduced
|
|
109
|
+
// to their current value, then the passthrough style layered on top (last wins via the style
|
|
110
|
+
// array, which the commit layer flattens) so the ShadowTree carries the current transform.
|
|
111
|
+
get reducedProps(): Record<string, unknown> {
|
|
112
|
+
const reduced = reduceProps(this.mergedProps());
|
|
113
|
+
const passthroughStyle = readPassthroughStyle(this.passthroughAnimatedPropExplicitValues);
|
|
114
|
+
if (passthroughStyle !== undefined) {
|
|
115
|
+
reduced['style'] =
|
|
116
|
+
reduced['style'] === undefined ? passthroughStyle : [reduced['style'], passthroughStyle];
|
|
117
|
+
}
|
|
118
|
+
reduced['style'] = [anchorHostStyle(this.elementRef), reduced['style']];
|
|
119
|
+
return reduced;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
ngAfterViewInit(): void {
|
|
123
|
+
this.viewReady = true;
|
|
124
|
+
this.reconcile();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
ngOnChanges(): void {
|
|
128
|
+
this.reconcile();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
ngOnDestroy(): void {
|
|
132
|
+
this.leafBinder.destroy();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// A non-stable [animatedProps]/[style] input (a fresh object literal in the template) pushes
|
|
136
|
+
// a new reference on every change-detection pass of the HOST view, re-triggering this on every
|
|
137
|
+
// unrelated interaction elsewhere in the app — DEBUG=1 turns this into a visible tick count in
|
|
138
|
+
// AnimatedLeafBinder.reconcile, so an unexpectedly high rate for a component nobody is
|
|
139
|
+
// animating is the tell (see AnimatedScrollView's stable-reference fix in examples/angular/App.ts).
|
|
140
|
+
private reconcile(): void {
|
|
141
|
+
if (!this.viewReady) return;
|
|
142
|
+
const props = this.mergedProps();
|
|
143
|
+
const hasPassthroughAnimatedValues =
|
|
144
|
+
this.passthroughAnimatedPropExplicitValues !== null &&
|
|
145
|
+
this.passthroughAnimatedPropExplicitValues !== undefined;
|
|
146
|
+
const wantsNative = hasPassthroughAnimatedValues && isNativeAnimatedAvailable();
|
|
147
|
+
this.leafBinder.reconcile(props, wantsNative);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Merge the dedicated `style` input over the generic `animatedProps` bag into one props map —
|
|
151
|
+
// the equivalent of React/Vue `rest`. `style` wins so `[style]` and `[animatedProps].style`
|
|
152
|
+
// never disagree.
|
|
153
|
+
private mergedProps(): Record<string, unknown> {
|
|
154
|
+
const base = this.animatedProps ?? {};
|
|
155
|
+
return this.style === undefined ? { ...base } : { ...base, style: this.style };
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// The committed host node held by IDENTITY. resolveHostNode unwraps an imperative scroll
|
|
159
|
+
// handle to the underlying SymbioteNode (View / Text already hand back the node directly);
|
|
160
|
+
// the isSymbioteNode guard keeps us off a cast.
|
|
161
|
+
private hostNode(): ISymbioteNode | null {
|
|
162
|
+
const resolved = resolveHostNode(this.hostDirective?.node);
|
|
163
|
+
return isSymbioteNode(resolved) ? resolved : null;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@Component({
|
|
168
|
+
selector: 'AnimatedView, symbiote-animated-view',
|
|
169
|
+
standalone: true,
|
|
170
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
171
|
+
imports: [SymbioteHostPropsDirective, ViewHost],
|
|
172
|
+
inputs: ANIMATED_INPUTS,
|
|
173
|
+
template: `
|
|
174
|
+
<symbiote-view [symbioteHostProps]="reducedProps">
|
|
175
|
+
<ng-content></ng-content>
|
|
176
|
+
</symbiote-view>
|
|
177
|
+
`,
|
|
178
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
179
|
+
})
|
|
180
|
+
export class AnimatedView extends AnimatedComponentBase {}
|
|
181
|
+
|
|
182
|
+
@Component({
|
|
183
|
+
selector: 'AnimatedText, symbiote-animated-text',
|
|
184
|
+
standalone: true,
|
|
185
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
186
|
+
imports: [SymbioteHostPropsDirective, TextHost],
|
|
187
|
+
inputs: ANIMATED_INPUTS,
|
|
188
|
+
template: `
|
|
189
|
+
<symbiote-text [symbioteHostProps]="reducedProps">
|
|
190
|
+
<ng-content></ng-content>
|
|
191
|
+
</symbiote-text>
|
|
192
|
+
`,
|
|
193
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
194
|
+
})
|
|
195
|
+
export class AnimatedText extends AnimatedComponentBase {}
|
|
196
|
+
|
|
197
|
+
@Component({
|
|
198
|
+
selector: 'AnimatedImage, symbiote-animated-image',
|
|
199
|
+
standalone: true,
|
|
200
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
201
|
+
imports: [SymbioteHostPropsDirective, ImageHost],
|
|
202
|
+
inputs: ANIMATED_IMAGE_INPUTS,
|
|
203
|
+
outputs: IMAGE_OUTPUTS,
|
|
204
|
+
template: `
|
|
205
|
+
<symbiote-image
|
|
206
|
+
[symbioteHostProps]="animatedImageProps"
|
|
207
|
+
(accessibilityAction)="handleAccessibilityAction($event)"
|
|
208
|
+
(accessibilityTap)="handleAccessibilityTap($event)"
|
|
209
|
+
(magicTap)="handleMagicTap($event)"
|
|
210
|
+
(accessibilityEscape)="handleAccessibilityEscape($event)"
|
|
211
|
+
(loadStart)="handleLoadStart($event)"
|
|
212
|
+
(load)="handleLoad($event)"
|
|
213
|
+
(loadEnd)="handleLoadEnd($event)"
|
|
214
|
+
(error)="handleError($event)"
|
|
215
|
+
(progress)="handleProgress($event)"
|
|
216
|
+
(partialLoad)="handlePartialLoad($event)"
|
|
217
|
+
>
|
|
218
|
+
<ng-content></ng-content>
|
|
219
|
+
</symbiote-image>
|
|
220
|
+
`,
|
|
221
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
222
|
+
})
|
|
223
|
+
export class AnimatedImage extends ImageBase implements AfterViewInit, OnChanges, OnDestroy {
|
|
224
|
+
animatedProps: Record<string, unknown> | undefined;
|
|
225
|
+
passthroughAnimatedPropExplicitValues: unknown;
|
|
226
|
+
|
|
227
|
+
// AnimatedImage is a non-painting ANCHOR too (ANCHOR_HOST_COMPONENTS) — see the matching
|
|
228
|
+
// comment on AnimatedComponentBase.elementRef.
|
|
229
|
+
private readonly elementRef = inject(ElementRef);
|
|
230
|
+
|
|
231
|
+
@ViewChild(SymbioteHostPropsDirective) private hostDirective?: SymbioteHostPropsDirective;
|
|
232
|
+
|
|
233
|
+
// Same Pure Fabrication AnimatedComponentBase holds — see its matching comment. AnimatedImage
|
|
234
|
+
// can't extend AnimatedComponentBase (it must extend ImageBase, see the file header), so it
|
|
235
|
+
// gets the leaf-lifecycle via composition instead of duplicating it.
|
|
236
|
+
private readonly leafBinder = new AnimatedLeafBinder(
|
|
237
|
+
() => this.hostNode(),
|
|
238
|
+
this.constructor.name,
|
|
239
|
+
);
|
|
240
|
+
private viewReady = false;
|
|
241
|
+
|
|
242
|
+
get animatedImageProps(): Record<string, unknown> {
|
|
243
|
+
const reduced = reduceProps(this.mergedProps());
|
|
244
|
+
const passthroughStyle = readPassthroughStyle(this.passthroughAnimatedPropExplicitValues);
|
|
245
|
+
if (passthroughStyle !== undefined) {
|
|
246
|
+
reduced['style'] =
|
|
247
|
+
reduced['style'] === undefined ? passthroughStyle : [reduced['style'], passthroughStyle];
|
|
248
|
+
}
|
|
249
|
+
const resolved = resolveImageProps(reduced);
|
|
250
|
+
resolved['style'] = [anchorHostStyle(this.elementRef), resolved['style']];
|
|
251
|
+
return resolved;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
ngAfterViewInit(): void {
|
|
255
|
+
this.viewReady = true;
|
|
256
|
+
this.reconcile();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
ngOnChanges(): void {
|
|
260
|
+
this.reconcile();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
ngOnDestroy(): void {
|
|
264
|
+
this.leafBinder.destroy();
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private reconcile(): void {
|
|
268
|
+
if (!this.viewReady) return;
|
|
269
|
+
const props = this.mergedProps();
|
|
270
|
+
const hasPassthroughAnimatedValues =
|
|
271
|
+
this.passthroughAnimatedPropExplicitValues !== null &&
|
|
272
|
+
this.passthroughAnimatedPropExplicitValues !== undefined;
|
|
273
|
+
const wantsNative = hasPassthroughAnimatedValues && isNativeAnimatedAvailable();
|
|
274
|
+
this.leafBinder.reconcile(props, wantsNative);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private mergedProps(): Record<string, unknown> {
|
|
278
|
+
const props: Record<string, unknown> = { ...(this.animatedProps ?? {}) };
|
|
279
|
+
for (const [key, value] of Object.entries(this.imageInputProps)) {
|
|
280
|
+
if (value !== undefined) props[key] = value;
|
|
281
|
+
}
|
|
282
|
+
return props;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private hostNode(): ISymbioteNode | null {
|
|
286
|
+
const resolved = resolveHostNode(this.hostDirective?.node);
|
|
287
|
+
return isSymbioteNode(resolved) ? resolved : null;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
@Component({
|
|
292
|
+
selector: 'AnimatedScrollView, symbiote-animated-scroll-view',
|
|
293
|
+
standalone: true,
|
|
294
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
295
|
+
imports: [SymbioteHostPropsDirective, ScrollViewHost],
|
|
296
|
+
inputs: ANIMATED_INPUTS,
|
|
297
|
+
template: `
|
|
298
|
+
<symbiote-scroll-view [symbioteHostProps]="reducedProps">
|
|
299
|
+
<symbiote-scroll-content [symbioteHostProps]="contentProps">
|
|
300
|
+
<ng-content></ng-content>
|
|
301
|
+
</symbiote-scroll-content>
|
|
302
|
+
</symbiote-scroll-view>
|
|
303
|
+
`,
|
|
304
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
305
|
+
})
|
|
306
|
+
export class AnimatedScrollView extends AnimatedComponentBase {
|
|
307
|
+
// RN defaults nested scrolling ON (ScrollView.js `nestedScrollEnabled ?? true`) — Android
|
|
308
|
+
// needs it explicit or a ScrollView nested inside another scrollable container never
|
|
309
|
+
// receives touch (swallowed by the outer scroll view; iOS doesn't gate on this). The real
|
|
310
|
+
// ScrollView component already defaults this (scroll-view/shared.ts), but AnimatedScrollView
|
|
311
|
+
// talks to the raw primitive directly and has no such defaulting, so it must apply it too.
|
|
312
|
+
//
|
|
313
|
+
// scrollViewBaseStyle (overflow: 'scroll' + the per-axis flexDirection) is the OTHER thing
|
|
314
|
+
// the real ScrollView applies that this bespoke template used to skip entirely — without it,
|
|
315
|
+
// iOS Fabric never clips the scroll view's content to its own frame (Android's native
|
|
316
|
+
// ViewGroup clips regardless of the style prop, which is why this was invisible there). This
|
|
317
|
+
// wrapper has no dedicated `horizontal` input (only the generic `animatedProps`/`style`
|
|
318
|
+
// surface), and its template is hardcoded to the vertical intrinsics
|
|
319
|
+
// (symbiote-scroll-view/symbiote-scroll-content, not the horizontal variants), so
|
|
320
|
+
// selectScrollIntrinsics is always called with isHorizontal=false here — matching what the
|
|
321
|
+
// template can actually render.
|
|
322
|
+
override get reducedProps(): Record<string, unknown> {
|
|
323
|
+
const reduced = super.reducedProps;
|
|
324
|
+
const { scrollViewBaseStyle } = selectScrollIntrinsics(false, undefined);
|
|
325
|
+
const withScrollBase: Record<string, unknown> = {
|
|
326
|
+
...reduced,
|
|
327
|
+
style: [scrollViewBaseStyle, reduced.style],
|
|
328
|
+
};
|
|
329
|
+
return withScrollBase.nestedScrollEnabled === undefined
|
|
330
|
+
? { ...withScrollBase, nestedScrollEnabled: true }
|
|
331
|
+
: withScrollBase;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// The content (inner) view's props: contentStyle from the same intrinsics selection, plus
|
|
335
|
+
// `collapsable: false` (the Android multi-child fix this file's tests already cover) — mirrors
|
|
336
|
+
// the real ScrollView's own `contentProps` getter (scroll-view/shared.ts).
|
|
337
|
+
get contentProps(): Record<string, unknown> {
|
|
338
|
+
const { contentStyle } = selectScrollIntrinsics(false, undefined);
|
|
339
|
+
return { style: contentStyle, collapsable: false };
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// List components are already explicit AOT-compiled Angular components with their own full input
|
|
344
|
+
// surface and inner ScrollView composition. Expose them in the Animated namespace without runtime
|
|
345
|
+
// synthesis; app code passes animated style/onScroll through the existing list inputs.
|
|
346
|
+
export const AnimatedFlatList = FlatList;
|
|
347
|
+
export const AnimatedSectionList = SectionList;
|
|
348
|
+
|
|
349
|
+
// Surface-parity shim for the React/Vue `createAnimatedComponent(Component)`. Angular cannot
|
|
350
|
+
// synthesize a component at runtime (no JIT under AOT/Metro — see the file header), so this maps
|
|
351
|
+
// the built-in primitives to their pre-authored wrappers and refuses anything else with a
|
|
352
|
+
// pointer to the real Angular idiom: author a standalone @Component extending
|
|
353
|
+
// AnimatedComponentBase.
|
|
354
|
+
export function createAnimatedComponent(base: unknown): Type<unknown> {
|
|
355
|
+
if (base === View) return AnimatedView;
|
|
356
|
+
if (base === Text) return AnimatedText;
|
|
357
|
+
if (base === Image) return AnimatedImage;
|
|
358
|
+
if (base === ScrollView) return AnimatedScrollView;
|
|
359
|
+
throw new Error(
|
|
360
|
+
'createAnimatedComponent: Angular cannot synthesize a component at runtime (no JIT compiler ' +
|
|
361
|
+
'under AOT/Metro). Author an explicit standalone @Component extending AnimatedComponentBase ' +
|
|
362
|
+
'instead. The built-in primitives View / Text / Image / ScrollView map to ' +
|
|
363
|
+
'AnimatedView / AnimatedText / AnimatedImage / AnimatedScrollView.',
|
|
364
|
+
);
|
|
365
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// The Animated namespace for @symbiote-native/angular: the Angular twin of adapters/vue/src/modules/
|
|
2
|
+
// animated/index.ts. The animated COMPONENTS (View / Text / Image / ScrollView) are explicit
|
|
3
|
+
// standalone components (Angular has no runtime HOC — see create-animated-component.ts); the
|
|
4
|
+
// value graph, easing and imperative drivers come from @symbiote-native/engine (framework-agnostic,
|
|
5
|
+
// JS-driven), spread in verbatim. Both halves meet here so the familiar surface,
|
|
6
|
+
// `Animated.timing(new Animated.Value(0), …).start()`, works against the Angular-driven engine.
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
AnimatedValue,
|
|
10
|
+
AnimatedValueXY,
|
|
11
|
+
AnimatedColor,
|
|
12
|
+
AnimatedMock,
|
|
13
|
+
Easing,
|
|
14
|
+
Platform,
|
|
15
|
+
timing,
|
|
16
|
+
spring,
|
|
17
|
+
decay,
|
|
18
|
+
parallel,
|
|
19
|
+
sequence,
|
|
20
|
+
stagger,
|
|
21
|
+
loop,
|
|
22
|
+
delay,
|
|
23
|
+
add,
|
|
24
|
+
subtract,
|
|
25
|
+
multiply,
|
|
26
|
+
divide,
|
|
27
|
+
modulo,
|
|
28
|
+
diffClamp,
|
|
29
|
+
event,
|
|
30
|
+
forkEvent,
|
|
31
|
+
unforkEvent,
|
|
32
|
+
} from '@symbiote-native/engine';
|
|
33
|
+
import {
|
|
34
|
+
AnimatedFlatList,
|
|
35
|
+
AnimatedImage,
|
|
36
|
+
AnimatedScrollView,
|
|
37
|
+
AnimatedSectionList,
|
|
38
|
+
AnimatedText,
|
|
39
|
+
AnimatedView,
|
|
40
|
+
createAnimatedComponent,
|
|
41
|
+
} from './create-animated-component';
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
AnimatedComponentBase,
|
|
45
|
+
AnimatedFlatList,
|
|
46
|
+
AnimatedImage,
|
|
47
|
+
AnimatedScrollView,
|
|
48
|
+
AnimatedSectionList,
|
|
49
|
+
AnimatedText,
|
|
50
|
+
AnimatedView,
|
|
51
|
+
createAnimatedComponent,
|
|
52
|
+
} from './create-animated-component';
|
|
53
|
+
|
|
54
|
+
// ScrollView is exposed DIRECTLY, not behind the lazy getter the React/Vue modules use: that
|
|
55
|
+
// getter only exists to defer a RUNTIME createAnimatedComponent(ScrollView) past module init so
|
|
56
|
+
// it cannot read ScrollView inside its own TDZ during an import cycle. AnimatedScrollView here is
|
|
57
|
+
// a statically-declared component that never reads the ScrollView class at init (it targets the
|
|
58
|
+
// `symbiote-scroll-view` host by string), so there is no cycle to defer.
|
|
59
|
+
//
|
|
60
|
+
// FlatList / SectionList are exposed as explicit AOT-safe list entries now that the Angular list
|
|
61
|
+
// components exist. Angular still cannot synthesize arbitrary animated wrappers at runtime; custom
|
|
62
|
+
// animated components remain explicit standalone components over AnimatedComponentBase.
|
|
63
|
+
|
|
64
|
+
// The live, JS-driven driver namespace (real frames). RN's AnimatedImplementation.
|
|
65
|
+
const liveDrivers = {
|
|
66
|
+
Value: AnimatedValue,
|
|
67
|
+
ValueXY: AnimatedValueXY,
|
|
68
|
+
Color: AnimatedColor,
|
|
69
|
+
Easing,
|
|
70
|
+
timing,
|
|
71
|
+
spring,
|
|
72
|
+
decay,
|
|
73
|
+
parallel,
|
|
74
|
+
sequence,
|
|
75
|
+
stagger,
|
|
76
|
+
loop,
|
|
77
|
+
delay,
|
|
78
|
+
add,
|
|
79
|
+
subtract,
|
|
80
|
+
multiply,
|
|
81
|
+
divide,
|
|
82
|
+
modulo,
|
|
83
|
+
diffClamp,
|
|
84
|
+
event,
|
|
85
|
+
forkEvent,
|
|
86
|
+
unforkEvent,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// RN swaps the WHOLE driver namespace for the mock when the host reports isDisableAnimations
|
|
90
|
+
// (reduced motion / test env): the mock keeps the same surface but jumps each animation to its
|
|
91
|
+
// final value synchronously, no frames. The animated COMPONENTS are live in both branches; only
|
|
92
|
+
// the drivers/value/operators/events half is swapped, exactly like RN spreading `...Animated`
|
|
93
|
+
// (impl or mock) over the same components.
|
|
94
|
+
const drivers = Platform.isDisableAnimations ? AnimatedMock : liveDrivers;
|
|
95
|
+
|
|
96
|
+
export const Animated = {
|
|
97
|
+
View: AnimatedView,
|
|
98
|
+
Text: AnimatedText,
|
|
99
|
+
Image: AnimatedImage,
|
|
100
|
+
ScrollView: AnimatedScrollView,
|
|
101
|
+
FlatList: AnimatedFlatList,
|
|
102
|
+
SectionList: AnimatedSectionList,
|
|
103
|
+
createAnimatedComponent,
|
|
104
|
+
...drivers,
|
|
105
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Co-located Angular-driven test, Angular twin of adapters/react/src/modules/
|
|
2
|
+
// app-registry/app-registry.test.tsx. Proves the AppRegistry entry point:
|
|
3
|
+
// `registerComponent(appKey, () => App)` stores a runnable that calls `mount` (driving
|
|
4
|
+
// @symbiote-native/engine) AND bridges it to the host registrar (RN's own AppRegistry, injected via
|
|
5
|
+
// `setHostRegistrar`) so native can find it by key. Also proves the Angular-specific
|
|
6
|
+
// `setWrapperComponentProvider` seam: a pre-authored standalone wrapper receives the root's
|
|
7
|
+
// host node as projected `<ng-content>`, the AOT-safe twin of React's
|
|
8
|
+
// createElement(Wrapper, null, rootElement).
|
|
9
|
+
|
|
10
|
+
import '@angular/compiler';
|
|
11
|
+
import { Component, Input, type Type } from '@angular/core';
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
13
|
+
import { installFabric } from '@symbiote-native/test-utils';
|
|
14
|
+
import { AppRegistry, setHostRegistrar, type IAppParameters, type IRunnable } from '../..';
|
|
15
|
+
import { unmount } from '../../render';
|
|
16
|
+
|
|
17
|
+
const APP_KEY = 'canary';
|
|
18
|
+
const ROOT_TAG = 212;
|
|
19
|
+
const WRAPPED_APP_KEY = 'canary-wrapped';
|
|
20
|
+
const WRAPPED_ROOT_TAG = 213;
|
|
21
|
+
|
|
22
|
+
// Angular's mount() batches change detection on a microtask, so a committed native tag isn't
|
|
23
|
+
// available synchronously — assertions on the committed tree need one tick, same as Vue.
|
|
24
|
+
const tick = (): Promise<void> => new Promise(resolve => setTimeout(resolve, 0));
|
|
25
|
+
|
|
26
|
+
class TestText {}
|
|
27
|
+
Component({
|
|
28
|
+
selector: 'symbiote-text',
|
|
29
|
+
standalone: true,
|
|
30
|
+
template: '<ng-content></ng-content>',
|
|
31
|
+
})(TestText);
|
|
32
|
+
|
|
33
|
+
class SmokeComponent {}
|
|
34
|
+
Component({
|
|
35
|
+
selector: 'symbiote-app-registry-smoke',
|
|
36
|
+
standalone: true,
|
|
37
|
+
imports: [TestText],
|
|
38
|
+
template: '<symbiote-text>hi</symbiote-text>',
|
|
39
|
+
})(SmokeComponent);
|
|
40
|
+
|
|
41
|
+
class WrapperComponent {
|
|
42
|
+
@Input() label = '';
|
|
43
|
+
}
|
|
44
|
+
Component({
|
|
45
|
+
selector: 'symbiote-app-registry-wrapper',
|
|
46
|
+
standalone: true,
|
|
47
|
+
imports: [TestText],
|
|
48
|
+
template: '<symbiote-text>{{ label }}</symbiote-text><ng-content></ng-content>',
|
|
49
|
+
})(WrapperComponent);
|
|
50
|
+
|
|
51
|
+
const fabric = installFabric();
|
|
52
|
+
|
|
53
|
+
// The host registrar the native side drives (RN's AppRegistry stand-in).
|
|
54
|
+
const hostRunnables = new Map<string, IRunnable>();
|
|
55
|
+
|
|
56
|
+
beforeEach(() => {
|
|
57
|
+
fabric.reset();
|
|
58
|
+
hostRunnables.clear();
|
|
59
|
+
setHostRegistrar({
|
|
60
|
+
registerRunnable: (appKey: string, run: IRunnable): string => {
|
|
61
|
+
hostRunnables.set(appKey, run);
|
|
62
|
+
return appKey;
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
AppRegistry.registerComponent(APP_KEY, () => SmokeComponent);
|
|
66
|
+
});
|
|
67
|
+
afterEach(() => {
|
|
68
|
+
unmount(ROOT_TAG);
|
|
69
|
+
unmount(WRAPPED_ROOT_TAG);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('AppRegistry', () => {
|
|
73
|
+
it('exposes the app key and bridges the runnable to the host registrar', () => {
|
|
74
|
+
expect(AppRegistry.getAppKeys()).toContain(APP_KEY);
|
|
75
|
+
expect(hostRunnables.get(APP_KEY)).toBeDefined();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('mounts the tree when the host invokes the runnable with a rootTag', async () => {
|
|
79
|
+
const hostRun = hostRunnables.get(APP_KEY);
|
|
80
|
+
expect(hostRun).toBeDefined();
|
|
81
|
+
|
|
82
|
+
const nativeParams: IAppParameters = { rootTag: ROOT_TAG };
|
|
83
|
+
hostRun!(nativeParams);
|
|
84
|
+
await tick();
|
|
85
|
+
|
|
86
|
+
expect(fabric.find(n => n.viewName === 'RCTText')).toBeDefined();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('runApplication drives the same runnable locally', async () => {
|
|
90
|
+
AppRegistry.runApplication(APP_KEY, { rootTag: ROOT_TAG });
|
|
91
|
+
await tick();
|
|
92
|
+
|
|
93
|
+
expect(fabric.find(n => n.viewName === 'RCTText')).toBeDefined();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('projects the root component into a registered wrapper via <ng-content>', async () => {
|
|
97
|
+
AppRegistry.setWrapperComponentProvider(() => WrapperComponent as Type<unknown>);
|
|
98
|
+
AppRegistry.registerComponent(WRAPPED_APP_KEY, () => SmokeComponent);
|
|
99
|
+
|
|
100
|
+
AppRegistry.runApplication(WRAPPED_APP_KEY, { rootTag: WRAPPED_ROOT_TAG });
|
|
101
|
+
await tick();
|
|
102
|
+
|
|
103
|
+
const texts = fabric.appRoot().children.flatMap(n => fabric.serialize([n]));
|
|
104
|
+
expect(texts.join('')).toContain('hi');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// AppRegistry: the JS entry point RN apps already use:
|
|
2
|
+
// AppRegistry.registerComponent(appKey, () => App)
|
|
3
|
+
// The registry bookkeeping (sections, host-registrar bridge, headless tasks) is
|
|
4
|
+
// framework-agnostic and lives in @symbiote-native/engine's createAppRegistry; this file supplies
|
|
5
|
+
// only the one Angular-specific seam — building a runnable from a component provider via
|
|
6
|
+
// `mount`'s wrapper/initialProps support (render.ts) — so examples/angular's own
|
|
7
|
+
// registerRunnable + mount call can move onto the same entry point React/Vue already have.
|
|
8
|
+
|
|
9
|
+
import type { Type } from '@angular/core';
|
|
10
|
+
import {
|
|
11
|
+
createAppRegistry,
|
|
12
|
+
dlog,
|
|
13
|
+
type IAppParameters,
|
|
14
|
+
type IRunnable,
|
|
15
|
+
} from '@symbiote-native/engine';
|
|
16
|
+
import { mount } from '../../render';
|
|
17
|
+
|
|
18
|
+
// RN's IComponentProvider: a thunk returning the root component (lazy so the module
|
|
19
|
+
// graph stays cheap until the app actually runs).
|
|
20
|
+
export type IComponentProvider = () => Type<unknown>;
|
|
21
|
+
|
|
22
|
+
// RN's IWrapperComponentProvider: given the surface's parameters, returns a
|
|
23
|
+
// component to wrap the app root in (e.g. a context provider). Optional. Angular has no
|
|
24
|
+
// runtime template synthesis (no JIT under AOT/Metro — see create-animated-component.ts),
|
|
25
|
+
// so the wrapper must be a pre-authored standalone @Component whose template renders
|
|
26
|
+
// `<ng-content>` — the Angular idiom for "render my children" (mount() projects the root's
|
|
27
|
+
// host node into it, the twin of React's createElement(Wrapper, null, rootElement)).
|
|
28
|
+
export type IWrapperComponentProvider = (appParameters: IAppParameters) => Type<unknown>;
|
|
29
|
+
|
|
30
|
+
function runnableFor(
|
|
31
|
+
componentProvider: IComponentProvider,
|
|
32
|
+
getWrapperComponentProvider: () => IWrapperComponentProvider | undefined,
|
|
33
|
+
): IRunnable {
|
|
34
|
+
return appParameters => {
|
|
35
|
+
dlog(`AppRegistry: mounting on rootTag ${String(appParameters.rootTag)}`);
|
|
36
|
+
// Read live (not at registration time) so setWrapperComponentProvider affects every
|
|
37
|
+
// runnable's next run, not just future ones.
|
|
38
|
+
mount(appParameters.rootTag, componentProvider(), {
|
|
39
|
+
initialProps: appParameters.initialProps,
|
|
40
|
+
wrapperComponent: getWrapperComponentProvider()?.(appParameters),
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { AppRegistry, setHostRegistrar } = createAppRegistry<
|
|
46
|
+
IComponentProvider,
|
|
47
|
+
IWrapperComponentProvider
|
|
48
|
+
>(runnableFor);
|
|
49
|
+
|
|
50
|
+
export { AppRegistry, setHostRegistrar };
|
|
51
|
+
export type {
|
|
52
|
+
IAppParameters,
|
|
53
|
+
IRunnable,
|
|
54
|
+
IHostRegistrar,
|
|
55
|
+
IRegistry,
|
|
56
|
+
IHeadlessTask,
|
|
57
|
+
ITaskProvider,
|
|
58
|
+
ITaskCanceller,
|
|
59
|
+
ITaskCancelProvider,
|
|
60
|
+
} from '@symbiote-native/engine';
|