Skip to content

Feature/improve bridge - #11

Merged
jjmhalew merged 3 commits into
mainfrom
feature/improve-bridge
Jul 22, 2026
Merged

jjmhalew merged 3 commits into
mainfrom
feature/improve-bridge

Conversation

@jjmhalew

Copy link
Copy Markdown
Owner

No description provided.

jjmhalew added 3 commits July 22, 2026 11:25
Core fixes

ngx-unity-viewport.component.ts: failed loader scripts are evicted from the cache so the same buildPath can retry; a broken build now emits a loadError output (with a fallbackToMock input and loadFailed signal to opt out of the silent mock fallback); compression probes run in parallel and overlap the loader download (~10 serialized round-trips down to ~2); loader failures no longer escape as unhandled rejections.
The ngx-unity peerDependency on @angular/core is now ^22.0.0 (was ^21), and empty string-array events from Unity now yield [] instead of [""].
Generators (JSLibExport.cs, AngularExposedExport.cs): wrapped in try/catch so a locked file can't crash Unity editor init, and they only write output when content actually changed — no more Angular dev-server rebuilds on every Unity domain reload. Shared helpers moved to a new BridgeGeneratorUtilities.cs. The client generator now emits unity-client.ts (kebab-case, matching what was committed) and imports IUnityInstance from a configurable path (default ngx-unity), so regenerating no longer breaks the app.
New features

Typed JSON payloads: JsonType = typeof(MyDto) on [AngularExposed]/[JSLibExport] generates a matching TS interface (new TypeScriptInterfaceGenerator.cs) plus automatic JSON.stringify/JSON.parse. Demonstrated in the demo via SpawnFromJson(SpawnRequest) and SendSceneState(SceneState).
Multi-instance routing: the generated jslib tags every Unity → Angular call with the canvas id from Module.canvas — zero C# API and no handshake race. The generated service gains forInstance(canvasId) returning a per-instance channel of signals/callbacks; flat signals keep their old behavior, and calls from older jslib builds route to a "default" channel (I confirmed this backward-compat path live, since the committed Unity build predates the feature). The viewport gained canvasId/resolvedCanvasId and an instanceCreated output carrying the id.
Tests + CI

Fixed broken test infra (the library's tsconfig.spec.json didn't exist; the app had no test target at all), then added 40 vitest specs across 5 files covering the viewport (mock fallback, compression detection, loader dedup, error paths, retry-after-failure), the mock utilities, the generated service contract (including forInstance and JSON parsing), and the bridge service. New ci.yml runs build + both suites + app build on pushes and PRs (Node 24).
Docs

Root README: fixed the wrong "Angular 16+" claim and broken license badge, added the JSON payloads section, rewrote Multi-Instance around forInstance, documented all new APIs, and ticked the JSON TODO. Rewrote the library README (what npm shows), and added CHANGELOG.md (retro-filled from the 21.0.0/22.0.0 tags) and CONTRIBUTING.md.
@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 8af686a):

https://ngx-unity--pr11-feature-improve-brid-a83epzxf.web.app

(expires Wed, 29 Jul 2026 09:34:25 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6d1b9e0f522683ad84db4253f6fed8bc0b01100d

@jjmhalew
jjmhalew merged commit 16a1b72 into main Jul 22, 2026
3 checks passed
@jjmhalew
jjmhalew deleted the feature/improve-bridge branch July 22, 2026 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant