@symbiote-native/angular 2.0.1 → 3.0.1

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 (96) hide show
  1. package/README.md +5 -4
  2. package/babel-register-composed.cjs +0 -8
  3. package/build/angular/callback-host.d.ts +25 -0
  4. package/build/angular/callback-host.js +211 -0
  5. package/build/angular/callback-host.js.map +1 -0
  6. package/build/angular/change-detection-flush.d.ts +14 -2
  7. package/build/angular/change-detection-flush.js +54 -6
  8. package/build/angular/change-detection-flush.js.map +1 -1
  9. package/build/angular/components/flat-list/index.js +39 -86
  10. package/build/angular/components/flat-list/index.js.map +1 -1
  11. package/build/angular/components/image-shared.js +49 -110
  12. package/build/angular/components/image-shared.js.map +1 -1
  13. package/build/angular/components/keyboard-avoiding-view/index.js +33 -72
  14. package/build/angular/components/keyboard-avoiding-view/index.js.map +1 -1
  15. package/build/angular/components/modal/index.js +58 -103
  16. package/build/angular/components/modal/index.js.map +1 -1
  17. package/build/angular/components/pressable-props.d.ts +2 -0
  18. package/build/angular/components/section-list/index.js +20 -103
  19. package/build/angular/components/section-list/index.js.map +1 -1
  20. package/build/angular/components/touchable-props.d.ts +1 -0
  21. package/build/angular/components/virtualized-list/directives.js +32 -22
  22. package/build/angular/components/virtualized-list/directives.js.map +1 -1
  23. package/build/angular/components/virtualized-list/index.d.ts +7 -1
  24. package/build/angular/components/virtualized-list/index.js +350 -359
  25. package/build/angular/components/virtualized-list/index.js.map +1 -1
  26. package/build/angular/components/virtualized-section-list/directives.js +20 -12
  27. package/build/angular/components/virtualized-section-list/directives.js.map +1 -1
  28. package/build/angular/components/virtualized-section-list/index.js +36 -142
  29. package/build/angular/components/virtualized-section-list/index.js.map +1 -1
  30. package/build/angular/components.d.ts +1 -1
  31. package/build/angular/components.js +1 -1
  32. package/build/angular/components.js.map +1 -1
  33. package/build/angular/create-portal/index.js +9 -8
  34. package/build/angular/create-portal/index.js.map +1 -1
  35. package/build/angular/create-tunnel/index.js +13 -12
  36. package/build/angular/create-tunnel/index.js.map +1 -1
  37. package/build/angular/descriptor-to-angular/index.js +6 -6
  38. package/build/angular/descriptor-to-angular/index.js.map +1 -1
  39. package/build/angular/diagnostics.d.ts +13 -0
  40. package/build/angular/diagnostics.js +18 -0
  41. package/build/angular/diagnostics.js.map +1 -1
  42. package/build/angular/element-props.d.ts +1 -3
  43. package/build/angular/elements.d.ts +46 -32
  44. package/build/angular/elements.js +217 -434
  45. package/build/angular/elements.js.map +1 -1
  46. package/build/angular/index.d.ts +3 -1
  47. package/build/angular/index.js +44 -13
  48. package/build/angular/index.js.map +1 -1
  49. package/build/angular/modules/animated/animated-leaf-binder.js +0 -2
  50. package/build/angular/modules/animated/animated-leaf-binder.js.map +1 -1
  51. package/build/angular/modules/animated/create-animated-component.js +69 -74
  52. package/build/angular/modules/animated/create-animated-component.js.map +1 -1
  53. package/build/angular/modules/animated/index.d.ts +30 -19
  54. package/build/angular/modules/status-bar/index.js +2 -8
  55. package/build/angular/modules/status-bar/index.js.map +1 -1
  56. package/build/angular/primitives/index.d.ts +14 -28
  57. package/build/angular/primitives/index.js +44 -107
  58. package/build/angular/primitives/index.js.map +1 -1
  59. package/build/angular/primitives/shared.d.ts +1 -0
  60. package/build/angular/primitives/shared.js +47 -32
  61. package/build/angular/primitives/shared.js.map +1 -1
  62. package/build/angular/render/index.js +40 -3
  63. package/build/angular/render/index.js.map +1 -1
  64. package/build/angular/renderer/index.d.ts +80 -0
  65. package/build/angular/renderer/index.js +324 -114
  66. package/build/angular/renderer/index.js.map +1 -1
  67. package/build/angular/runtime-matching.d.ts +9 -0
  68. package/build/angular/runtime-matching.js +82 -0
  69. package/build/angular/runtime-matching.js.map +1 -0
  70. package/build/angular/services/color-scheme.service.js +4 -4
  71. package/build/angular/services/color-scheme.service.js.map +1 -1
  72. package/build/angular/services/window-dimensions.service.js +4 -4
  73. package/build/angular/services/window-dimensions.service.js.map +1 -1
  74. package/build/angular/style-host.d.ts +11 -0
  75. package/build/angular/style-host.js +86 -0
  76. package/build/angular/style-host.js.map +1 -0
  77. package/package.json +6 -6
  78. package/src/callback-host.ts +229 -0
  79. package/src/change-detection-flush.ts +62 -9
  80. package/src/components/flat-list/index.ts +2 -1
  81. package/src/components/keyboard-avoiding-view/index.ts +8 -0
  82. package/src/components/pressable-props.ts +8 -0
  83. package/src/components/touchable-props.ts +4 -0
  84. package/src/components/virtualized-list/index.ts +98 -45
  85. package/src/components.ts +0 -2
  86. package/src/diagnostics.ts +18 -0
  87. package/src/element-props.ts +1 -5
  88. package/src/elements.ts +159 -38
  89. package/src/index.ts +47 -14
  90. package/src/primitives/index.ts +14 -70
  91. package/src/primitives/shared.ts +21 -6
  92. package/src/render/index.ts +56 -2
  93. package/src/renderer/index.ts +378 -104
  94. package/src/runtime-matching.ts +80 -0
  95. package/src/style-host.ts +94 -0
  96. package/tsconfig.angular.base.json +11 -0
@@ -22,6 +22,7 @@ import {
22
22
  createComponent,
23
23
  createEnvironmentInjector,
24
24
  DOCUMENT,
25
+ enableProdMode,
25
26
  ErrorHandler,
26
27
  RendererFactory2,
27
28
  ɵINJECTOR_SCOPE as INJECTOR_SCOPE,
@@ -100,6 +101,12 @@ interface IMountedApp {
100
101
  cmpRef: ComponentRef<unknown>;
101
102
  rootRef: ComponentRef<unknown> | undefined;
102
103
  injector: EnvironmentInjector;
104
+ /**
105
+ * Kept so teardown can release it. Angular never will: it is provided as a `useValue`, so the
106
+ * injector has nothing to destroy, and the renderer it owns listens to the engine's flush door
107
+ * for as long as the surface lives. See `SymbioteRendererFactory.dispose`.
108
+ */
109
+ rendererFactory: SymbioteRendererFactory;
103
110
  }
104
111
 
105
112
  // AppRegistry's `wrapperComponentProvider` support: the root renders detached (Angular gives
@@ -133,24 +140,71 @@ function teardown(rootTag: IRootTag): void {
133
140
  app.rootRef?.destroy();
134
141
  app.cmpRef.destroy();
135
142
  app.injector.destroy();
143
+ // AFTER Angular's own teardown, so anything those destroys wrote is published rather than
144
+ // dropped — the renderer flushes what it holds on its way out.
145
+ app.rendererFactory.dispose();
136
146
  apps.delete(rootTag);
137
147
  disposeRoot(rootTag);
138
148
  }
139
149
 
150
+ // Metro's build switch, and esbuild's in this repo's headless runner. Declared HERE rather than in
151
+ // an ambient `globals.d.ts`, because the AOT tests (`elements.test.ts`, `style-input-aot.test.ts`)
152
+ // build their own ngtsc programs from an explicit file list that an ambient declaration never
153
+ // reaches — seven of them went red with `Cannot find name '__DEV__'`, reported as an empty
154
+ // diagnostic set, which reads as "the template checker found nothing" and is not that.
155
+ //
156
+ // `declare const` emits no JavaScript, so it shadows nothing at runtime and both bundlers still
157
+ // substitute the identifier.
158
+ declare const __DEV__: boolean;
159
+
160
+ /**
161
+ * Turn Angular's assertions off when — and only when — the bundler has said this is a release.
162
+ *
163
+ * `ngDevMode` is a THIRD dev switch, and neither of the two this project already handles reaches
164
+ * it: `initNgDevMode()` turns itself ON whenever the global is undefined (`ng_dev_mode.ts:85`), and
165
+ * `@react-native/babel-preset` inlines `__DEV__` while knowing nothing about Angular. So every
166
+ * release build made with this adapter shipped dev-mode Angular — `inject()` of a special token
167
+ * builds a `new NodeInjector` and emits two profiler events PER ELEMENT
168
+ * (`di.ts:525`, `runInInjectorProfilerContext`). Measured on `angular-elements-suite.itest.ts`,
169
+ * `build-release`, with the census byte-identical on both sides: a 1 000-row create went from
170
+ * ~300 ms to ~223 ms, all of it in pass 1.
171
+ *
172
+ * AN EXPLICIT `false` IS THE ONLY RELEASE SIGNAL. A host that never defines `__DEV__` reads
173
+ * `undefined`, and a `!__DEV__` test would silence every NG-code diagnostic there in exchange for a
174
+ * speed-up nobody asked for. Metro writes a literal `true` or `false`, so the signal exists exactly
175
+ * where it can be trusted.
176
+ *
177
+ * Per mount rather than once per process: `enableProdMode()` only ever writes `false`, so repeating
178
+ * it costs a property write and a guard that has already been taken on every surface but the first.
179
+ *
180
+ * READ AS AN IDENTIFIER, NEVER AS `globalThis.__DEV__`, and that distinction is the whole
181
+ * mechanism. Both Metro and esbuild deliver `__DEV__` by SUBSTITUTING the identifier for a literal,
182
+ * so a property lookup finds nothing whatever the build says. The first spelling of this function
183
+ * used `Reflect.get(globalThis, '__DEV__')`, never fired once in the bench bundle, and measured a
184
+ * clean zero — which reads exactly like "this optimization does not work" and is not that. The
185
+ * `typeof` guard is what makes the bare identifier safe where nothing declares it at all.
186
+ */
187
+ function settleAngularDevMode(): void {
188
+ if (typeof __DEV__ === 'undefined' || __DEV__ !== false) return;
189
+ enableProdMode();
190
+ }
191
+
140
192
  export function mount(
141
193
  rootTag: IRootTag,
142
194
  rootComponent: Type<unknown>,
143
195
  options?: IMountOptions,
144
196
  ): SymbioteSurface {
197
+ settleAngularDevMode();
145
198
  // A re-mount on a live rootTag starts clean; otherwise the stale app double-drives the surface.
146
199
  teardown(rootTag);
147
200
 
148
201
  const surface = createSurface(rootTag);
202
+ const rendererFactory = new SymbioteRendererFactory(surface);
149
203
  const injector = createEnvironmentInjector(
150
204
  [
151
205
  {
152
206
  provide: RendererFactory2,
153
- useValue: new SymbioteRendererFactory(surface),
207
+ useValue: rendererFactory,
154
208
  },
155
209
  // `getElementById` is not decoration: `resource()` resolves TransferState, whose root
156
210
  // factory runs `retrieveTransferredState(doc, appId)` ->
@@ -245,7 +299,7 @@ export function mount(
245
299
  appRef.tick(); // first paint
246
300
  surface.requestCommit();
247
301
 
248
- apps.set(rootTag, { cmpRef, rootRef, injector });
302
+ apps.set(rootTag, { cmpRef, rootRef, injector, rendererFactory });
249
303
  return surface;
250
304
  }
251
305