add Angular adapter package#154
Conversation
There was a problem hiding this comment.
Important
The Angular adapter is well-structured and consistent with the existing React/Vue packages, but a couple of correctness and packaging issues should be addressed before merging.
Reviewed changes — adds a first-party Angular adapter package (@foresightjs/angular) with a directive, host-wrapper component, service, signal helper, and tests alongside ng-packagr build wiring.
- Adds
ForesightDirective,ForesightComponent,ForesightService, andinjectForesightEvent - Wires
ng-packagrpartial compilation, Vitest withjsdom, and workspace path aliases - Mirrors the React/Vue public API shape with core re-exports and
ForesightComponentOptions
⚠️ User callbacks run outside the Angular zone
ForesightService wraps state updates and manager events in this.zone.run, but the user-supplied callback is invoked bare inside ForesightManager. If a consumer mutates Angular state in their callback, change detection will not run in a Zone.js app.
Technical details
# User callbacks run outside the Angular zone
## Affected sites
- `packages/foresightjs-angular/src/services/ForesightService.ts:23` — callback wrapper does not re-enter Angular zone
## Required outcome
- User callbacks registered with `ForesightService.register()` must be executed inside `NgZone.run` so Angular change detection is triggered.
## Suggested approach
Change the callback wrapper to:
```ts
const callback = (s: ForesightElementState) => this.zone.run(() => optionsRef.callback(s))
```
Optionally wrap the synchronous `state.set` calls at lines 37 and 64 in `zone.run` as well for consistency.⚠️ tslib is only a dev dependency
tsconfig.json sets importHelpers: true, so compiled FESM output imports tslib. With tslib only in devDependencies, consumers using strict package managers may not resolve it at runtime.
Technical details
# `tslib` dependency placement
## Affected sites
- `packages/foresightjs-angular/package.json:66` — `tslib` under `devDependencies`
- `packages/foresightjs-angular/tsconfig.json:10` — `importHelpers: true`
## Required outcome
- Add `tslib` as a peer dependency (or a runtime dependency) so installed consumers can resolve it. Typical Angular libraries use a peer dependency like `"tslib": "^2.8.1"`.⚠️ build and build:prod produce identical artifacts
The two scripts are the same command, unlike React and Vue where build emits sourcemaps and build:prod strips them.
Technical details
# `build` vs `build:prod`
## Affected sites
- `packages/foresightjs-angular/package.json:8-9` — both scripts identical
## Required outcome
- Production builds should not ship sourcemaps.
## Suggested approach
Create a `tsconfig.lib.prod.json` that disables `sourceMap`/`inlineSources`, then change `build:prod` to use it:
```json
"build:prod": "ng-packagr -p ng-package.json -c tsconfig.lib.prod.json"
```ℹ️ Nitpicks
package.json:67declarestypescript: "^6.0.2"but TypeScript 6 has not been released; Angular 22 currently expects TypeScript 5.x.LICENSE:3uses 2024 while the other packages use 2025.README.md:10links to/docs/angularbut React/Vue docs use/docs/<framework>/installation.- No tests currently cover
ForesightComponent,injectForesightEvent, SSR guards, or Zone re-entry behavior. - Consider removing the redundant
*.d.tswildcard fromfilesto match@foresightjs/reactand@foresightjs/vue.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
Addressed the review feedback in Changes made:
Validation:
All five review threads have been replied to and resolved. |
There was a problem hiding this comment.
ℹ️ No critical issues — minor cleanup suggestions inline.
Reviewed changes — author response at 15b01e6 addresses the prior review's must-fix items: Zone.js re-entry for callbacks and state updates, moving tslib to runtime dependencies, and splitting build:prod to use a sourcemap-free production tsconfig.
- Wrapped
ForesightServicecallbacks, state updates, and manager-event listeners inNgZone.run - Added unit tests verifying callback and state-reset Zone re-entry
- Moved
tslibfromdevDependenciestodependencies - Added
tsconfig.lib.prod.jsonand aremove-sourcemaps.mjscleanup script for production builds - Fixed
LICENSEyear, README docs link, and removed redundant*.d.tsfromfiles - Restricted
injectForesightEventdynamic inputs to AngularSignals and documented static vs. dynamic behavior
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — minor suggestions inline.
Reviewed changes — added the Angular documentation site tree, sidebar entry, framework selector, beta banner detection, and README/CONTRIBUTING updates for the new @foresightjs/angular package.
- Added the full Angular docs tree (
directive,foresight-service,foresight-component,injectForesightEvent,quick-start,installation, etc.) - Wired
angularSidebarand framework-switching support across the docs site - Updated READMEs, CONTRIBUTING, and the core
what-is/migratingcross-references to list Angular alongside React and Vue
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
|
||
| /** | ||
| * Renders the early-release notice on every page of the React and Vue | ||
| * Renders the early-release notice on every page of the framework package |
There was a problem hiding this comment.
This comment now reads "framework package framework trees" — one of the two nouns should be removed to avoid the doubled-up phrase.
| author: Bart Spaans | ||
| --- | ||
|
|
||
| import MigratingCore from "../_partials/_migrating-core.mdx"; |
There was a problem hiding this comment.
The MDX import ends with a semicolon, while the other new Angular doc pages omit it. Aligning with the no-semicolon style keeps the Angular docs consistent.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — follow-up commit f12570d resolves the two remaining cleanup items from the prior review.
- Removed the duplicate
tslibentry fromdevDependencies - Guarded
remove-sourcemaps.mjsagainst a missingdistdirectory withexistsSync
Kimi K2 (free via Pullfrog for OSS) | 𝕏

Summary
Adds a first-party Angular adapter package alongside the existing React and Vue bindings.
The new
@foresightjs/angularpackage provides:ForesightDirective, a standalone[fsForesight]directive for HTML and SVG elementsForesightService, an injectable manual registration and event-subscription APIForesightComponent, a standalone host-wrapper componentinjectForesightEvent, an Angular injection-context helper for manager eventsFlow
Validation
pnpm --filter @foresightjs/angular lintpnpm --filter @foresightjs/angular test:runpnpm --filter @foresightjs/angular buildpnpm buildAll passed locally.
Notes
The Angular package is compiled with
ng-packagrin Angular partial-compilation mode, which is the expected publishing format for Angular libraries. Declared peer support is Angular 17 through Angular 22 because the adapter uses standalone APIs and signals.