@loozo/angular-launch 0.0.0-stage → 0.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.
package/dist/json.js ADDED
@@ -0,0 +1,48 @@
1
+ // Deliberately strict wire subset: no toJSON hooks, Date, undefined, holes,
2
+ // nonfinite numbers, symbols, cycles or custom prototypes on either transport.
3
+ export function serializeJson(value) {
4
+ const active = new Set();
5
+ function visit(current) {
6
+ if (current === null || typeof current === "string" || typeof current === "boolean") {
7
+ return;
8
+ }
9
+ if (typeof current === "number" && Number.isFinite(current)) {
10
+ return;
11
+ }
12
+ if (typeof current !== "object" || current === null || active.has(current)) {
13
+ throw new TypeError("RPC values must be strict JSON");
14
+ }
15
+ active.add(current);
16
+ if (Array.isArray(current)) {
17
+ if (Object.getPrototypeOf(current) !== Array.prototype) {
18
+ throw new TypeError("RPC arrays must have a plain prototype");
19
+ }
20
+ for (let index = 0; index < current.length; index += 1) {
21
+ const descriptor = Object.getOwnPropertyDescriptor(current, index);
22
+ if (!descriptor || !descriptor.enumerable || !("value" in descriptor)) {
23
+ throw new TypeError("RPC arrays require dense data properties");
24
+ }
25
+ visit(descriptor.value);
26
+ }
27
+ if (Reflect.ownKeys(current).length !== current.length + 1) {
28
+ throw new TypeError("RPC arrays cannot have extra properties");
29
+ }
30
+ }
31
+ else {
32
+ if (Object.getPrototypeOf(current) !== Object.prototype &&
33
+ Object.getPrototypeOf(current) !== null) {
34
+ throw new TypeError("RPC objects must have a plain prototype");
35
+ }
36
+ for (const key of Reflect.ownKeys(current)) {
37
+ const descriptor = Object.getOwnPropertyDescriptor(current, key);
38
+ if (typeof key !== "string" || !descriptor.enumerable || !("value" in descriptor)) {
39
+ throw new TypeError("RPC objects require enumerable string data properties");
40
+ }
41
+ visit(descriptor.value);
42
+ }
43
+ }
44
+ active.delete(current);
45
+ }
46
+ visit(value);
47
+ return JSON.stringify(value);
48
+ }
@@ -0,0 +1,4 @@
1
+ import type { ApplicationRef, EnvironmentProviders } from "@angular/core";
2
+ import { type ApplicationBinding, type Registry } from "./dispatch.js";
3
+ export declare function provideLaunchServer(registry: Registry, application: ApplicationBinding): EnvironmentProviders;
4
+ export declare function finishLaunchRendering(app: ApplicationRef): Promise<ApplicationRef>;
@@ -0,0 +1,112 @@
1
+ import { inject, InjectionToken, REQUEST, REQUEST_CONTEXT, makeEnvironmentProviders, } from "@angular/core";
2
+ import { FetchBackend, HttpBackend, HttpErrorResponse, HttpResponse } from "@angular/common/http";
3
+ import { Observable } from "rxjs";
4
+ import { RPC_CALL } from "../generated.js";
5
+ import { dispatch, failure, isJsonMediaType, assertBoundScope, } from "./dispatch.js";
6
+ const renderFaults = new InjectionToken("Launch render faults");
7
+ export function provideLaunchServer(registry, application) {
8
+ return makeEnvironmentProviders([
9
+ { provide: renderFaults, useFactory: () => ({}) },
10
+ {
11
+ provide: HttpBackend,
12
+ useFactory: () => {
13
+ const context = inject(REQUEST_CONTEXT);
14
+ const nativeRequest = inject(REQUEST);
15
+ const fallback = inject(FetchBackend);
16
+ const faults = inject(renderFaults);
17
+ return {
18
+ handle(request) {
19
+ const marked = request.context.get(RPC_CALL);
20
+ let target;
21
+ if (nativeRequest instanceof Request) {
22
+ target = new URL(request.urlWithParams, nativeRequest.url);
23
+ }
24
+ else {
25
+ target = new URL(request.urlWithParams, "http://launch.invalid");
26
+ const localRpc = target.origin === "http://launch.invalid" && target.pathname.startsWith("/_rpc/");
27
+ if (!marked && !localRpc) {
28
+ return fallback.handle(request);
29
+ }
30
+ const error = new Error("Launch RPC requires live request context; prerender RPC is unsupported");
31
+ faults.unsupportedContext = error;
32
+ return new Observable((subscriber) => subscriber.error(error));
33
+ }
34
+ const ownOrigin = target.origin === new URL(nativeRequest.url).origin;
35
+ const ownRpc = ownOrigin && target.pathname.startsWith("/_rpc/");
36
+ if (!marked && !ownRpc) {
37
+ return fallback.handle(request);
38
+ }
39
+ return new Observable((subscriber) => {
40
+ function deliver(reply) {
41
+ if (reply.status >= 400) {
42
+ subscriber.error(new HttpErrorResponse({
43
+ status: reply.status,
44
+ error: reply.body,
45
+ url: request.urlWithParams,
46
+ }));
47
+ return;
48
+ }
49
+ subscriber.next(new HttpResponse({
50
+ status: reply.status,
51
+ body: reply.body,
52
+ url: request.urlWithParams,
53
+ }));
54
+ subscriber.complete();
55
+ }
56
+ try {
57
+ assertBoundScope(context, application, nativeRequest);
58
+ }
59
+ catch (error) {
60
+ console.error("Launch SSR scope binding failed", error);
61
+ deliver(failure("INTERNAL"));
62
+ return;
63
+ }
64
+ const authOverride = request.headers.has("authorization") ||
65
+ request.headers.has("proxy-authorization") ||
66
+ request.headers.has("cookie") ||
67
+ request.withCredentials ||
68
+ request.credentials !== undefined;
69
+ const contentType = request.headers.get("content-type") ?? request.detectContentTypeHeader();
70
+ if (!ownRpc ||
71
+ target.search !== "" ||
72
+ target.hash !== "" ||
73
+ target.username !== "" ||
74
+ target.password !== "" ||
75
+ request.method !== "POST" ||
76
+ !isJsonMediaType(contentType) ||
77
+ authOverride) {
78
+ deliver(failure("INVALID_INPUT"));
79
+ return;
80
+ }
81
+ let envelope;
82
+ try {
83
+ const body = request.serializeBody();
84
+ if (typeof body !== "string") {
85
+ deliver(failure("INVALID_INPUT"));
86
+ return;
87
+ }
88
+ envelope = JSON.parse(body);
89
+ }
90
+ catch {
91
+ deliver(failure("INVALID_INPUT"));
92
+ return;
93
+ }
94
+ void dispatch(registry, target.pathname, envelope, context, application, nativeRequest, "rendering").then(deliver);
95
+ });
96
+ },
97
+ };
98
+ },
99
+ },
100
+ ]);
101
+ }
102
+ // Native prerender can swallow resolver errors. Propagate only the unsupported
103
+ // Launch context fault after native stability, without manufacturing a request.
104
+ export async function finishLaunchRendering(app) {
105
+ await app.whenStable();
106
+ const fault = app.injector.get(renderFaults).unsupportedContext;
107
+ if (fault) {
108
+ app.destroy();
109
+ throw fault;
110
+ }
111
+ return app;
112
+ }
@@ -0,0 +1,108 @@
1
+ import type { JsonShape } from "../json.js";
2
+ import type { FrameworkCode } from "../client.js";
3
+ import { declaredFailures } from "./errors.js";
4
+ import type { DeclaredFailure } from "./errors.js";
5
+ export interface Register {
6
+ }
7
+ export type Context = Register extends {
8
+ context: infer Value;
9
+ } ? Value : never;
10
+ export interface Schema<Input = unknown, Output = Input> {
11
+ readonly "~standard": {
12
+ readonly version: 1;
13
+ readonly vendor: string;
14
+ readonly types?: {
15
+ readonly input: Input;
16
+ readonly output: Output;
17
+ };
18
+ readonly validate: (value: unknown) => {
19
+ readonly value: Output;
20
+ readonly issues?: undefined;
21
+ } | {
22
+ readonly issues: readonly {
23
+ readonly message: string;
24
+ }[];
25
+ } | Promise<{
26
+ readonly value: Output;
27
+ readonly issues?: undefined;
28
+ } | {
29
+ readonly issues: readonly {
30
+ readonly message: string;
31
+ }[];
32
+ }>;
33
+ };
34
+ }
35
+ export type InputOf<S extends Schema> = NonNullable<S["~standard"]["types"]>["input"];
36
+ export type OutputOf<S> = S extends Schema<unknown, infer Output> ? Output : undefined;
37
+ export interface ContextDefinition<Value> {
38
+ readonly create: (request: Request) => Value;
39
+ }
40
+ export declare function defineContext<Value>(create: (request: Request) => Value): ContextDefinition<Value>;
41
+ export type ContextOf<Definition> = Definition extends ContextDefinition<infer Value> ? Awaited<Value> : never;
42
+ export type Guard = (args: {
43
+ readonly context: Context;
44
+ readonly request: Request;
45
+ }) => boolean | Promise<boolean>;
46
+ export type ProcedureGuard<Input> = (args: {
47
+ readonly context: Context;
48
+ readonly request: Request;
49
+ readonly input: OutputOf<Input>;
50
+ }) => boolean | Promise<boolean>;
51
+ type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
52
+ type StatusNumber<Value> = Value extends `${infer Status extends number}` ? Status : never;
53
+ export type ErrorStatus = StatusNumber<`${4 | 5}${Digit}${Digit}`>;
54
+ export interface ErrorDefinition<Data extends Schema = Schema> {
55
+ readonly status: ErrorStatus;
56
+ readonly message: string;
57
+ readonly data: Data;
58
+ }
59
+ export type ErrorDefinitions = Readonly<Record<string, ErrorDefinition>>;
60
+ export type ErrorFactories<Definitions extends ErrorDefinitions> = {
61
+ readonly [Code in keyof Definitions]: (data: InputOf<Definitions[Code]["data"]>) => Error;
62
+ };
63
+ type JsonContract<Value> = 0 extends 1 & Value ? never : [Value] extends [JsonShape<Value>] ? unknown : never;
64
+ type InputContract<Input> = Input extends Schema ? JsonContract<InputOf<Input>> : unknown;
65
+ type ErrorContract<Definitions extends ErrorDefinitions> = {
66
+ readonly [Code in keyof Definitions]: Code extends FrameworkCode | "__proto__" ? never : Definitions[Code]["message"] extends "" ? never : Definitions[Code] & JsonContract<OutputOf<Definitions[Code]["data"]>>;
67
+ };
68
+ type JsonResult<Value> = Value extends Promise<infer Result> ? Promise<JsonShape<Result>> : JsonShape<Value>;
69
+ export type ProcedureKind = "query" | "mutation";
70
+ export interface Procedure<Input, Output, Kind extends ProcedureKind = "query", Errors extends ErrorDefinitions = {}> {
71
+ readonly kind: Kind;
72
+ readonly input: Input;
73
+ readonly errors: Errors;
74
+ readonly canActivate: readonly ProcedureGuard<Input>[];
75
+ readonly handler: (args: {
76
+ readonly context: Context;
77
+ readonly input: OutputOf<Input>;
78
+ readonly errors: ErrorFactories<Errors>;
79
+ }) => Output | Promise<Output>;
80
+ readonly [declaredFailures]: WeakMap<object, DeclaredFailure>;
81
+ }
82
+ interface ProcedureOptions<Input, Output, Errors extends ErrorDefinitions> {
83
+ readonly input?: Input & InputContract<NoInfer<Input>>;
84
+ readonly errors?: Errors & ErrorContract<NoInfer<Errors>>;
85
+ readonly canActivate?: readonly ProcedureGuard<Input>[];
86
+ readonly handler: (args: {
87
+ readonly context: Context;
88
+ readonly input: OutputOf<Input>;
89
+ readonly errors: ErrorFactories<Errors>;
90
+ }) => Output & JsonResult<NoInfer<Output>>;
91
+ }
92
+ export declare function query<Input extends Schema | undefined = undefined, Output = unknown, const Errors extends ErrorDefinitions = {}>(options: ProcedureOptions<Input, Output, Errors>): Procedure<Input, Output, "query", Errors>;
93
+ export declare function mutation<Input extends Schema | undefined = undefined, Output = unknown, const Errors extends ErrorDefinitions = {}>(options: ProcedureOptions<Input, Output, Errors>): Procedure<Input, Output, "mutation", Errors>;
94
+ export interface ProcedureDefinition {
95
+ readonly kind: ProcedureKind;
96
+ }
97
+ export interface QueryDefinition extends ProcedureDefinition {
98
+ readonly kind: "query";
99
+ }
100
+ export interface Group<Name extends string, Procedures extends Record<string, ProcedureDefinition>> {
101
+ readonly name: Name;
102
+ readonly procedures: Procedures;
103
+ readonly canActivate: readonly Guard[];
104
+ }
105
+ export declare function defineRpc<Name extends string, Procedures extends Record<string, ProcedureDefinition>>(name: Name, procedures: Procedures, { canActivate }?: {
106
+ readonly canActivate?: readonly Guard[];
107
+ }): Group<Name, Procedures>;
108
+ export {};
@@ -0,0 +1,25 @@
1
+ import { createErrors, declaredFailures } from "./errors.js";
2
+ export function defineContext(create) {
3
+ return { create };
4
+ }
5
+ function procedure(kind, options) {
6
+ const definitions = (options.errors ?? {});
7
+ const { factories, failures } = createErrors(definitions);
8
+ return {
9
+ kind,
10
+ input: options.input,
11
+ errors: definitions,
12
+ canActivate: options.canActivate ?? [],
13
+ handler: ({ context, input }) => options.handler({ context, input, errors: factories }),
14
+ [declaredFailures]: failures,
15
+ };
16
+ }
17
+ export function query(options) {
18
+ return procedure("query", options);
19
+ }
20
+ export function mutation(options) {
21
+ return procedure("mutation", options);
22
+ }
23
+ export function defineRpc(name, procedures, { canActivate = [] } = {}) {
24
+ return { name, procedures, canActivate };
25
+ }
@@ -0,0 +1,27 @@
1
+ import { type FrameworkCode } from "../client.js";
2
+ import type { ContextDefinition, ContextOf, Group, ProcedureDefinition } from "./definitions.js";
3
+ export type Registry = Readonly<Record<string, Group<string, Record<string, ProcedureDefinition>>>>;
4
+ declare const scopeMarker: unique symbol;
5
+ export interface ApplicationBinding<Definition extends ContextDefinition<unknown> = ContextDefinition<unknown>> {
6
+ readonly id: string;
7
+ readonly context: Definition;
8
+ }
9
+ export interface RequestScope<Value = unknown> {
10
+ readonly appId: string;
11
+ readonly binding: string;
12
+ readonly request: Request;
13
+ readonly value: Value;
14
+ readonly [scopeMarker]: true;
15
+ }
16
+ export declare function isRequestScope(value: unknown): value is RequestScope;
17
+ export declare function createRequestScope<Definition extends ContextDefinition<unknown>>(application: ApplicationBinding<Definition>, request: Request): Promise<RequestScope<ContextOf<Definition>>>;
18
+ export declare function assertBoundScope(scope: unknown, application: ApplicationBinding, request: Request): asserts scope is RequestScope;
19
+ export interface Reply {
20
+ readonly status: number;
21
+ readonly body: unknown;
22
+ }
23
+ export declare function failure(code: FrameworkCode): Reply;
24
+ export declare function isJsonMediaType(contentType: string | null): boolean;
25
+ export declare function dispatch(registry: Registry, path: string, envelope: unknown, scope: RequestScope, application: ApplicationBinding, request: Request, mode?: "http" | "rendering"): Promise<Reply>;
26
+ export declare function handleRpc<Definition extends ContextDefinition<unknown>>(registry: Registry, application: ApplicationBinding<Definition>, request: Request): Promise<Response | null>;
27
+ export {};
@@ -0,0 +1,173 @@
1
+ import { frameworkFailures } from "../client.js";
2
+ import { serializeJson } from "../json.js";
3
+ import { declaredFailures } from "./errors.js";
4
+ const scopeMarker = Symbol.for("@loozo/angular-launch/private-request-scope/v1");
5
+ const bindingHeader = "x-loozo-launch-scope";
6
+ export function isRequestScope(value) {
7
+ return (typeof value === "object" &&
8
+ value !== null &&
9
+ scopeMarker in value &&
10
+ value[scopeMarker] === true &&
11
+ "request" in value &&
12
+ value.request instanceof Request &&
13
+ "appId" in value &&
14
+ typeof value.appId === "string" &&
15
+ "binding" in value &&
16
+ typeof value.binding === "string" &&
17
+ "value" in value);
18
+ }
19
+ export async function createRequestScope(application, request) {
20
+ const binding = crypto.randomUUID();
21
+ const headers = new Headers(request.headers);
22
+ headers.set(bindingHeader, binding);
23
+ // Keep the caller's body usable and its signal linked via native Request clones.
24
+ const boundRequest = new Request(request.clone(), { headers });
25
+ const value = await application.context.create(boundRequest);
26
+ return {
27
+ appId: application.id,
28
+ binding,
29
+ request: boundRequest,
30
+ value: value,
31
+ [scopeMarker]: true,
32
+ };
33
+ }
34
+ export function assertBoundScope(scope, application, request) {
35
+ if (!isRequestScope(scope) ||
36
+ scope.appId !== application.id ||
37
+ scope.binding.length === 0 ||
38
+ scope.request.headers.get(bindingHeader) !== scope.binding ||
39
+ request.headers.get(bindingHeader) !== scope.binding) {
40
+ throw new Error("Launch request/application scope binding mismatch");
41
+ }
42
+ }
43
+ export function failure(code) {
44
+ const frame = frameworkFailures[code];
45
+ return { status: frame.status, body: { error: { code, message: frame.message, data: null } } };
46
+ }
47
+ export function isJsonMediaType(contentType) {
48
+ return contentType?.split(";", 1)[0].trim().toLowerCase() === "application/json";
49
+ }
50
+ export async function dispatch(registry, path, envelope, scope, application, request, mode = "http") {
51
+ try {
52
+ assertBoundScope(scope, application, request);
53
+ const parts = /^\/_rpc\/([a-f0-9]{24})\/([A-Za-z_][A-Za-z0-9_]*)$/.exec(path);
54
+ if (!parts || !Object.hasOwn(registry, parts[1])) {
55
+ return failure("RPC_NOT_FOUND");
56
+ }
57
+ const group = registry[parts[1]];
58
+ if (!Object.hasOwn(group.procedures, parts[2])) {
59
+ return failure("RPC_NOT_FOUND");
60
+ }
61
+ const procedure = group.procedures[parts[2]];
62
+ if (procedure.kind !== "query" && procedure.kind !== "mutation") {
63
+ throw new Error("Launch registry contains an unsupported procedure");
64
+ }
65
+ // Rendering never performs writes, even for unmarked HttpClient calls or
66
+ // callers/interceptors that relabel a generated method or enable caching.
67
+ if (mode === "rendering" && procedure.kind === "mutation") {
68
+ return failure("FORBIDDEN");
69
+ }
70
+ // Even direct transport crosses the exact same strict JSON boundary.
71
+ const normalized = JSON.parse(serializeJson(envelope));
72
+ if (typeof normalized !== "object" ||
73
+ normalized === null ||
74
+ Array.isArray(normalized) ||
75
+ !("input" in normalized) ||
76
+ Object.keys(normalized).length !== 1) {
77
+ return failure("INVALID_INPUT");
78
+ }
79
+ let input;
80
+ if (procedure.input) {
81
+ const parsed = await procedure.input["~standard"].validate(normalized.input);
82
+ if (parsed.issues) {
83
+ return failure("INVALID_INPUT");
84
+ }
85
+ input = parsed.value;
86
+ }
87
+ else if (normalized.input !== null) {
88
+ return failure("INVALID_INPUT");
89
+ }
90
+ const context = scope.value;
91
+ for (const guard of group.canActivate) {
92
+ if (!(await guard({ context, request }))) {
93
+ return failure("FORBIDDEN");
94
+ }
95
+ }
96
+ for (const guard of procedure.canActivate) {
97
+ if (!(await guard({ context, request, input }))) {
98
+ return failure("FORBIDDEN");
99
+ }
100
+ }
101
+ let output;
102
+ try {
103
+ output = await procedure.handler({ context, input });
104
+ }
105
+ catch (error) {
106
+ let declared;
107
+ if (typeof error === "object" && error !== null) {
108
+ declared = procedure[declaredFailures]?.get(error);
109
+ }
110
+ if (!declared || !Object.hasOwn(procedure.errors, declared.code)) {
111
+ throw error;
112
+ }
113
+ const definition = procedure.errors[declared.code];
114
+ if (definition !== declared.definition) {
115
+ throw error;
116
+ }
117
+ const parsed = await definition.data["~standard"].validate(declared.data);
118
+ if (parsed.issues) {
119
+ throw new Error("Declared RPC error data failed validation", { cause: error });
120
+ }
121
+ const data = JSON.parse(serializeJson(parsed.value));
122
+ return {
123
+ status: definition.status,
124
+ body: { error: { code: declared.code, message: definition.message, data } },
125
+ };
126
+ }
127
+ return { status: 200, body: JSON.parse(serializeJson(output)) };
128
+ }
129
+ catch (error) {
130
+ console.error("Launch RPC failed", error);
131
+ return failure("INTERNAL");
132
+ }
133
+ }
134
+ export async function handleRpc(registry, application, request) {
135
+ const url = new URL(request.url);
136
+ if (!url.pathname.startsWith("/_rpc/")) {
137
+ return null;
138
+ }
139
+ let reply;
140
+ if (request.method !== "POST" ||
141
+ !isJsonMediaType(request.headers.get("content-type")) ||
142
+ url.search !== "") {
143
+ reply = failure("INVALID_INPUT");
144
+ }
145
+ else {
146
+ try {
147
+ const scope = await createRequestScope(application, request);
148
+ let envelope;
149
+ try {
150
+ envelope = await request.json();
151
+ }
152
+ catch {
153
+ return response(failure("INVALID_INPUT"));
154
+ }
155
+ reply = await dispatch(registry, url.pathname, envelope, scope, application, scope.request);
156
+ }
157
+ catch (error) {
158
+ console.error("Launch context failed", error);
159
+ reply = failure("INTERNAL");
160
+ }
161
+ }
162
+ return response(reply);
163
+ }
164
+ function response(reply) {
165
+ return new Response(serializeJson(reply.body), {
166
+ status: reply.status,
167
+ headers: {
168
+ "content-type": "application/json",
169
+ "cache-control": "private, no-store",
170
+ vary: "Cookie",
171
+ },
172
+ });
173
+ }
@@ -0,0 +1,11 @@
1
+ import type { ErrorDefinition, ErrorDefinitions, ErrorFactories } from "./definitions.js";
2
+ export declare const declaredFailures: unique symbol;
3
+ export interface DeclaredFailure {
4
+ readonly code: string;
5
+ readonly definition: ErrorDefinition;
6
+ readonly data: unknown;
7
+ }
8
+ export declare function createErrors<Definitions extends ErrorDefinitions>(definitions: Definitions): {
9
+ factories: ErrorFactories<Definitions>;
10
+ failures: WeakMap<object, DeclaredFailure>;
11
+ };
@@ -0,0 +1,32 @@
1
+ import { frameworkFailures } from "../client.js";
2
+ // The map lives on the actual registered procedure, not in module/global state.
3
+ // A native SSR bundle may load this module twice; both copies read that same map.
4
+ export const declaredFailures = Symbol.for("@loozo/angular-launch/private-declared-failures/v1");
5
+ export function createErrors(definitions) {
6
+ const factories = Object.create(null);
7
+ const failures = new WeakMap();
8
+ for (const [code, definition] of Object.entries(definitions)) {
9
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(code) ||
10
+ code === "__proto__" ||
11
+ Object.hasOwn(frameworkFailures, code) ||
12
+ !Number.isInteger(definition.status) ||
13
+ definition.status < 400 ||
14
+ definition.status > 599 ||
15
+ typeof definition.message !== "string" ||
16
+ definition.message.length === 0 ||
17
+ !definition.data ||
18
+ definition.data["~standard"]?.version !== 1 ||
19
+ typeof definition.data["~standard"].vendor !== "string" ||
20
+ typeof definition.data["~standard"].validate !== "function") {
21
+ throw new TypeError(`Invalid declared RPC error: ${code}`);
22
+ }
23
+ factories[code] = (data) => {
24
+ const error = new Error(definition.message);
25
+ failures.set(error, { code, definition, data });
26
+ return error;
27
+ };
28
+ }
29
+ // Every key above closes over its own declaration; the generic mapping only
30
+ // exposes that schema's input to TypeScript. Data is validated on dispatch.
31
+ return { factories: factories, failures };
32
+ }
@@ -0,0 +1,5 @@
1
+ export { defineContext, defineRpc, query, mutation } from "./definitions.js";
2
+ export type { Register, Context, ContextOf, ContextDefinition, Group, Guard, Procedure, ProcedureGuard, Schema, InputOf, OutputOf, QueryDefinition, ProcedureDefinition, ProcedureKind, ErrorDefinition, ErrorDefinitions, ErrorFactories, ErrorStatus, } from "./definitions.js";
3
+ export { createRequestScope, isRequestScope, dispatch, handleRpc } from "./dispatch.js";
4
+ export type { ApplicationBinding, Registry, RequestScope, Reply } from "./dispatch.js";
5
+ export { provideLaunchServer, finishLaunchRendering } from "./backend.js";
@@ -0,0 +1,3 @@
1
+ export { defineContext, defineRpc, query, mutation } from "./definitions.js";
2
+ export { createRequestScope, isRequestScope, dispatch, handleRpc } from "./dispatch.js";
3
+ export { provideLaunchServer, finishLaunchRendering } from "./backend.js";
package/package.json CHANGED
@@ -1,6 +1,63 @@
1
1
  {
2
2
  "name": "@loozo/angular-launch",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.1",
4
+ "description": "Typed queries, mutations and declared errors on Angular's native router, HTTP and SSR pipeline.",
5
+ "bugs": "https://github.com/theo-matzavinos/loozo/issues",
6
+ "license": "MIT",
7
+ "author": "Theophilos Matzavinos",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/theo-matzavinos/loozo.git",
11
+ "directory": "packages/angular-launch"
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "README.md"
16
+ ],
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/client.d.ts",
21
+ "default": "./dist/client.js"
22
+ },
23
+ "./server": {
24
+ "types": "./dist/server/index.d.ts",
25
+ "default": "./dist/server/index.js"
26
+ },
27
+ "./_generated": {
28
+ "types": "./dist/generated.d.ts",
29
+ "default": "./dist/generated.js"
30
+ },
31
+ "./generation": {
32
+ "types": "./dist/generation/index.d.ts",
33
+ "node": "./dist/generation/index.js"
34
+ },
35
+ "./package.json": "./package.json"
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "registry": "https://registry.npmjs.org/"
40
+ },
41
+ "dependencies": {
42
+ "typescript": "6.0.3"
43
+ },
44
+ "devDependencies": {
45
+ "@angular/common": "22.2.2",
46
+ "@angular/compiler": "22.2.2",
47
+ "@angular/core": "22.2.2",
48
+ "@loozo/angular-router": "0.0.3",
49
+ "@types/node": "24.13.3",
50
+ "playwright": "1.63.0"
51
+ },
52
+ "peerDependencies": {
53
+ "@angular/common": "^22.0.0",
54
+ "@angular/core": "^22.0.0",
55
+ "@loozo/angular-router": "0.0.3",
56
+ "rxjs": "^7.8.2"
57
+ },
58
+ "scripts": {
59
+ "build": "rm -rf dist && tsc -p tsconfig.json",
60
+ "typecheck": "tsc -p tsconfig.json --noEmit",
61
+ "test": "node --test tests/*.test.mjs"
62
+ }
6
63
  }