@runic-artifex/angular 0.3.0-preview.1 → 0.5.0-preview.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Viktor Jannicke
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,24 +1,20 @@
1
- # @runic-artifex/angular
1
+ # `@runic-artifex/angular`
2
2
 
3
- Angular DI and signal projection for the framework-neutral Runic Application
4
- Bridge. The package owns Angular lifecycle integration; the supplied Application
5
- Bridge Layer remains the only Effect runtime owner.
3
+ Angular outlet for generated Runic View references. Register a component for
4
+ each generated View kind and pass the current reference to the outlet.
6
5
 
7
6
  ```ts
8
- bootstrapApplication(App, {
9
- providers: [provideApplicationBridge({
10
- controller: createApplicationBridgeController(
11
- CounterContract,
12
- ApplicationBridgeLive(CounterContract, createDesktopFrameChannel()),
13
- ),
14
- snapshotFromEvent: event => event._tag === "CounterChanged" ? event.snapshot : undefined,
15
- })],
16
- });
7
+ import { RunicViewOutlet, type ViewRegistry } from "@runic-artifex/angular";
8
+ import { DocumentPage } from "./document-page";
9
+ import type { DocumentReference } from "./generated/document";
10
+
11
+ const registry = { document: DocumentPage } satisfies ViewRegistry<DocumentReference>;
12
+
13
+ // Add RunicViewOutlet to the parent's imports and bind:
14
+ // <runic-view-outlet [content]="current()" [registry]="registry" />
17
15
  ```
18
16
 
19
- Components inject the typed facade with `injectApplicationBridge()`. The same
20
- provided controller can target Runic Desktop, CS-WebUI compatibility, a hosted
21
- WebSocket, or a mock Layer; it does not bind Angular to a particular host or let
22
- Angular own the controller runtime. `DestroyRef` releases Angular's event
23
- subscription; the application composition that created the controller disposes
24
- its Effect scope during application teardown.
17
+ The outlet remounts the component when the logical View reference changes. A
18
+ component's `page` input receives that reference and owns its page connection
19
+ and cleanup. Missing kinds render an alert. The generated TypeScript client can
20
+ also be used directly without Angular.
@@ -0,0 +1,25 @@
1
+ import { type InputSignal, type Type } from "@angular/core";
2
+ import * as i0 from "@angular/core";
3
+ export interface ViewReference {
4
+ readonly kind: string;
5
+ connect(): Promise<unknown>;
6
+ }
7
+ /** A build-known map checks each generated reference against its component input. */
8
+ export type ViewRegistry<R extends ViewReference> = {
9
+ readonly [K in R["kind"]]: Type<{
10
+ readonly page: InputSignal<Extract<R, {
11
+ readonly kind: K;
12
+ }>>;
13
+ }>;
14
+ };
15
+ /** Headless host for a selected logical .NET View. A changed reference remounts its component. */
16
+ export declare class RunicViewOutlet {
17
+ readonly content: InputSignal<ViewReference | null | undefined>;
18
+ readonly registry: InputSignal<Readonly<Record<string, Type<unknown>>>>;
19
+ readonly error: import("@angular/core").WritableSignal<string | undefined>;
20
+ private readonly mount;
21
+ private readonly selected;
22
+ constructor();
23
+ static ɵfac: i0.ɵɵFactoryDeclaration<RunicViewOutlet, never>;
24
+ static ɵcmp: i0.ɵɵComponentDeclaration<RunicViewOutlet, "runic-view-outlet", never, { "content": { "alias": "content"; "required": false; "isSignal": true; }; "registry": { "alias": "registry"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
25
+ }
@@ -0,0 +1,49 @@
1
+ import { Component, computed, effect, input, signal, viewChild, ViewContainerRef } from "@angular/core";
2
+ import * as i0 from "@angular/core";
3
+ /** Headless host for a selected logical .NET View. A changed reference remounts its component. */
4
+ export class RunicViewOutlet {
5
+ content = input(/* @ts-ignore */
6
+ ...(ngDevMode ? [undefined, { debugName: "content" }] : /* istanbul ignore next */ []));
7
+ registry = input.required(/* @ts-ignore */
8
+ ...(ngDevMode ? [{ debugName: "registry" }] : /* istanbul ignore next */ []));
9
+ error = signal(undefined, /* @ts-ignore */
10
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
11
+ mount = viewChild.required("mount", { ...(ngDevMode ? { debugName: "mount" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
12
+ selected = computed(() => {
13
+ const reference = this.content();
14
+ return reference ? { reference, component: this.registry()[reference.kind] } : undefined;
15
+ }, /* @ts-ignore */
16
+ ...(ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []));
17
+ constructor() {
18
+ effect(() => {
19
+ const container = this.mount();
20
+ const selection = this.selected();
21
+ container.clear();
22
+ this.error.set(undefined);
23
+ if (!selection)
24
+ return;
25
+ if (!selection.component) {
26
+ this.error.set(`No web component is registered for ${selection.reference.kind}.`);
27
+ return;
28
+ }
29
+ const component = container.createComponent(selection.component);
30
+ component.setInput("page", selection.reference);
31
+ });
32
+ }
33
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: RunicViewOutlet, deps: [], target: i0.ɵɵFactoryTarget.Component });
34
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.5", type: RunicViewOutlet, isStandalone: true, selector: "runic-view-outlet", inputs: { content: { classPropertyName: "content", publicName: "content", isSignal: true, isRequired: false, transformFunction: null }, registry: { classPropertyName: "registry", publicName: "registry", isSignal: true, isRequired: true, transformFunction: null } }, viewQueries: [{ propertyName: "mount", first: true, predicate: ["mount"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: `
35
+ <ng-container #mount />
36
+ @if (error(); as issue) { <p role="alert">{{ issue }}</p> }
37
+ `, isInline: true });
38
+ }
39
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.5", ngImport: i0, type: RunicViewOutlet, decorators: [{
40
+ type: Component,
41
+ args: [{
42
+ selector: "runic-view-outlet",
43
+ standalone: true,
44
+ template: `
45
+ <ng-container #mount />
46
+ @if (error(); as issue) { <p role="alert">{{ issue }}</p> }
47
+ `,
48
+ }]
49
+ }], ctorParameters: () => [], propDecorators: { content: [{ type: i0.Input, args: [{ isSignal: true, alias: "content", required: false }] }], registry: [{ type: i0.Input, args: [{ isSignal: true, alias: "registry", required: true }] }], mount: [{ type: i0.ViewChild, args: ["mount", { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
package/package.json CHANGED
@@ -1,58 +1,48 @@
1
1
  {
2
2
  "name": "@runic-artifex/angular",
3
- "version": "0.3.0-preview.1",
3
+ "version": "0.5.0-preview.2",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/esm/view-outlet.d.ts",
8
+ "import": "./dist/esm/view-outlet.js"
9
+ },
10
+ "./package.json": "./package.json"
11
+ },
12
+ "peerDependencies": {
13
+ "@angular/core": ">=20.3.26 <23"
14
+ },
15
+ "description": "Angular outlet for Runic Views",
16
+ "license": "MIT",
4
17
  "repository": {
5
18
  "type": "git",
6
19
  "url": "git+https://github.com/Runic-Artifex/runic-sdk.git",
7
20
  "directory": "packages/web/angular"
8
21
  },
9
- "publishConfig": {
10
- "access": "public",
11
- "tag": "preview"
12
- },
13
- "description": "Angular DI and signal adapter for the Runic Application Bridge.",
14
22
  "homepage": "https://github.com/Runic-Artifex/runic-sdk/tree/main/packages/web/angular#readme",
15
23
  "bugs": {
16
24
  "url": "https://github.com/Runic-Artifex/runic-sdk/issues"
17
25
  },
18
- "keywords": [
19
- "runic-artifex",
20
- "angular",
21
- "application-bridge",
22
- "signals",
23
- "desktop"
24
- ],
25
- "license": "MIT",
26
- "type": "module",
27
- "sideEffects": false,
28
- "main": "./dist/esm/index.js",
29
- "module": "./dist/esm/index.js",
30
- "types": "./dist/esm/index.d.ts",
31
- "exports": {
32
- ".": {
33
- "types": "./dist/esm/index.d.ts",
34
- "import": "./dist/esm/index.js",
35
- "default": "./dist/esm/index.js"
36
- },
37
- "./package.json": "./package.json"
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "tag": "preview"
38
29
  },
39
30
  "files": [
40
31
  "dist",
41
- "README.md"
32
+ "README.md",
33
+ "LICENSE"
42
34
  ],
43
35
  "engines": {
44
36
  "node": ">=24.18.0 <25"
45
37
  },
38
+ "packageManager": "bun@1.4.2",
39
+ "sideEffects": false,
40
+ "main": "./dist/esm/view-outlet.js",
41
+ "types": "./dist/esm/view-outlet.d.ts",
46
42
  "scripts": {
47
- "clean": "bun --input-type=module --eval \"import { rmSync } from 'node:fs'; rmSync('dist', { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\"",
48
- "build": "bun run --bun clean && tsc --project tsconfig.json",
49
- "prepack": "bun run --bun build"
50
- },
51
- "dependencies": {
52
- "@runic-artifex/application-bridge": "0.3.0-preview.1"
53
- },
54
- "peerDependencies": {
55
- "@angular/core": ">=20.3.26 <23"
43
+ "build": "ngc -p tsconfig.json",
44
+ "check": "ngc -p tsconfig.json --noEmit",
45
+ "pack:check": "bun pm pack --dry-run"
56
46
  },
57
47
  "devDependencies": {
58
48
  "@angular/compiler": "22.1.5",
@@ -60,6 +50,5 @@
60
50
  "@angular/core": "22.1.5",
61
51
  "typescript": "6.0.3"
62
52
  },
63
- "packageManager": "bun@1.4.2",
64
- "gitHead": "92e75481565ea1b8a4c579ec1d2e27f3384aa9aa"
53
+ "gitHead": "1870bc34b044abfdea9341769090e42b4096a0ec"
65
54
  }
@@ -1,30 +0,0 @@
1
- import { type EnvironmentProviders, type Signal } from "@angular/core";
2
- import { type ApplicationBridgeController, type BridgeError } from "@runic-artifex/application-bridge";
3
- /** Host-neutral composition for an Angular Application Bridge client. */
4
- export interface ApplicationBridgeAngularConfiguration<Command, Receipt, HostEvent, Snapshot, Failure = BridgeError> {
5
- /** The composition-owned neutral controller. Angular never creates or disposes its runtime. */
6
- readonly controller: ApplicationBridgeController<Command, Receipt, HostEvent, Snapshot, Failure>;
7
- /** Projects validated host events into the authoritative snapshot, when applicable. */
8
- readonly snapshotFromEvent?: (event: HostEvent) => Snapshot | undefined;
9
- }
10
- /** Angular-facing facade over the controller's one owned Effect runtime. */
11
- export interface ApplicationBridgeClient<Command, Receipt, HostEvent, Snapshot, Failure = BridgeError> {
12
- readonly snapshot: Signal<Snapshot | undefined>;
13
- readonly error: Signal<Failure | undefined>;
14
- readonly initialized: Signal<boolean>;
15
- initialize(): Promise<Snapshot>;
16
- dispatch(command: Command): Promise<Receipt>;
17
- cancel(operationId: string): Promise<void>;
18
- reconnect(): Promise<Snapshot>;
19
- uiReady(): Promise<void>;
20
- uiRendered(): Promise<void>;
21
- subscribe(onEvent: (event: HostEvent) => void): () => void;
22
- }
23
- /**
24
- * Registers a single bridge client in the application injector. The supplied
25
- * controller can target Runic Desktop, CS-WebUI compatibility, a hosted
26
- * WebSocket, or a mock without changing the Angular package boundary.
27
- */
28
- export declare function provideApplicationBridge<Command, Receipt, HostEvent, Snapshot, Failure = BridgeError>(configuration: ApplicationBridgeAngularConfiguration<Command, Receipt, HostEvent, Snapshot, Failure>): EnvironmentProviders;
29
- /** Injects the typed facade registered by {@link provideApplicationBridge}. */
30
- export declare function injectApplicationBridge<Command, Receipt, HostEvent, Snapshot, Failure = BridgeError>(): ApplicationBridgeClient<Command, Receipt, HostEvent, Snapshot, Failure>;
package/dist/esm/index.js DELETED
@@ -1,69 +0,0 @@
1
- import { DestroyRef, InjectionToken, inject, makeEnvironmentProviders, signal, } from "@angular/core";
2
- import { Cause, Effect, Exit, Option, } from "effect";
3
- import { bridgeError, } from "@runic-artifex/application-bridge";
4
- const configurationToken = new InjectionToken("RunicApplicationBridgeConfiguration");
5
- const clientToken = new InjectionToken("RunicApplicationBridgeClient");
6
- /**
7
- * Registers a single bridge client in the application injector. The supplied
8
- * controller can target Runic Desktop, CS-WebUI compatibility, a hosted
9
- * WebSocket, or a mock without changing the Angular package boundary.
10
- */
11
- export function provideApplicationBridge(configuration) {
12
- return makeEnvironmentProviders([
13
- { provide: configurationToken, useValue: configuration },
14
- {
15
- provide: clientToken,
16
- useFactory: () => createClient(inject(configurationToken), inject(DestroyRef)),
17
- },
18
- ]);
19
- }
20
- /** Injects the typed facade registered by {@link provideApplicationBridge}. */
21
- export function injectApplicationBridge() {
22
- return inject(clientToken);
23
- }
24
- function createClient(configuration, destroyRef) {
25
- const controller = configuration.controller;
26
- const snapshot = signal(undefined);
27
- const error = signal(undefined);
28
- const initialized = signal(false);
29
- const unsubscribe = controller.subscribe((event) => {
30
- const projected = configuration.snapshotFromEvent?.(event);
31
- if (projected !== undefined)
32
- snapshot.set(projected);
33
- }, (failure) => error.set(failure));
34
- destroyRef.onDestroy(() => {
35
- unsubscribe();
36
- });
37
- return {
38
- snapshot: snapshot.asReadonly(),
39
- error: error.asReadonly(),
40
- initialized: initialized.asReadonly(),
41
- initialize: () => run(controller, controller.effects.initialize, snapshot, error, initialized),
42
- dispatch: (command) => run(controller, controller.effects.dispatch(command), undefined, error),
43
- cancel: (operationId) => run(controller, controller.effects.cancel(operationId), undefined, error),
44
- reconnect: () => run(controller, controller.effects.reconnect, snapshot, error, initialized),
45
- uiReady: () => run(controller, controller.effects.uiReady, undefined, error),
46
- uiRendered: () => run(controller, controller.effects.uiRendered, undefined, error),
47
- subscribe: (onEvent) => controller.subscribe(onEvent, (failure) => error.set(failure)),
48
- };
49
- }
50
- async function run(controller, operation, snapshot, error, initialized) {
51
- error.set(undefined);
52
- try {
53
- const outcome = await controller.runExit(operation);
54
- if (Exit.isFailure(outcome)) {
55
- const failure = Cause.findErrorOption(outcome.cause);
56
- throw Option.isSome(failure)
57
- ? failure.value
58
- : bridgeError("OperationFailed", "The Application Bridge operation was interrupted.");
59
- }
60
- const value = outcome.value;
61
- snapshot?.set(value);
62
- initialized?.set(true);
63
- return value;
64
- }
65
- catch (failure) {
66
- error.set(failure);
67
- throw failure;
68
- }
69
- }