@oatscenter/trellis-svelte 0.100.0-rc.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 (38) hide show
  1. package/README.md +16 -0
  2. package/dist/authorization_context.d.ts +18 -0
  3. package/dist/authorization_context.js +150 -0
  4. package/dist/components/TrellisContextProvider.svelte +24 -0
  5. package/dist/components/TrellisContextProvider.svelte.d.ts +11 -0
  6. package/dist/components/TrellisProvider.svelte +192 -0
  7. package/dist/components/TrellisProvider.svelte.d.ts +6 -0
  8. package/dist/components/TrellisProvider.types.d.ts +15 -0
  9. package/dist/components/TrellisProvider.types.js +1 -0
  10. package/dist/context.d.ts +72 -0
  11. package/dist/context.js +116 -0
  12. package/dist/device_activation.d.ts +6 -0
  13. package/dist/device_activation.js +19 -0
  14. package/dist/device_activation_controller.d.ts +91 -0
  15. package/dist/device_activation_controller.js +318 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.js +5 -0
  18. package/dist/internal/activation_view.d.ts +44 -0
  19. package/dist/internal/activation_view.js +95 -0
  20. package/dist/internal/callback_state.d.ts +9 -0
  21. package/dist/internal/callback_state.js +24 -0
  22. package/dist/internal/portal_url.d.ts +13 -0
  23. package/dist/internal/portal_url.js +57 -0
  24. package/dist/portal_flow.d.ts +24 -0
  25. package/dist/portal_flow.js +173 -0
  26. package/package.json +42 -0
  27. package/src/authorization_context.svelte.ts +153 -0
  28. package/src/components/TrellisContextProvider.svelte +24 -0
  29. package/src/components/TrellisProvider.svelte +192 -0
  30. package/src/components/TrellisProvider.types.ts +28 -0
  31. package/src/context.svelte.ts +205 -0
  32. package/src/device_activation.svelte.ts +28 -0
  33. package/src/device_activation_controller.ts +528 -0
  34. package/src/index.ts +31 -0
  35. package/src/internal/activation_view.ts +179 -0
  36. package/src/internal/callback_state.ts +48 -0
  37. package/src/internal/portal_url.ts +94 -0
  38. package/src/portal_flow.svelte.ts +143 -0
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @oatscenter/trellis-svelte
2
+
3
+ Svelte integration for Trellis browser applications.
4
+
5
+ Provides `TrellisProvider` for app-level wiring and `createTrellisApp(...)` for
6
+ app-scoped typed Svelte context around the real connected Trellis client.
7
+
8
+ Use `TrellisProvider` as the primary integration surface:
9
+
10
+ - create an app context with `createTrellisApp({ contract, trellisUrl })`
11
+ - pass `trellisApp` to `TrellisProvider`
12
+ - read the live client synchronously with `app.getTrellis()` from child
13
+ components
14
+
15
+ Uses the contract/runtime model from `@oatscenter/trellis/contracts` and
16
+ `@oatscenter/trellis`.
@@ -0,0 +1,18 @@
1
+ import { type AuthorizationContextBundle, type AuthorizationRoutingMaterial, type TrellisAuth, type VerifiedAuthorizationContext } from "@oatscenter/trellis/auth";
2
+ export type AuthorizationContextStatus = "empty" | "loading" | "ready" | "refreshing" | "degraded" | "expired" | "authRequired" | "failed";
3
+ /** Reactive projection of the shared TypeScript authorization context cache. */
4
+ export declare class AuthorizationContextController {
5
+ #private;
6
+ constructor(trellisUrl: string, fetch?: typeof globalThis.fetch);
7
+ get context(): VerifiedAuthorizationContext | undefined;
8
+ get status(): AuthorizationContextStatus;
9
+ get error(): unknown;
10
+ get refreshAt(): number | undefined;
11
+ get expiresAt(): number | undefined;
12
+ install(bundle: AuthorizationContextBundle, routing: AuthorizationRoutingMaterial): Promise<void>;
13
+ refresh(sessionId: string, auth: TrellisAuth): Promise<void>;
14
+ refreshNow(sessionId: string, auth: TrellisAuth): Promise<void>;
15
+ start(sessionId: string, auth: TrellisAuth): void;
16
+ stop(): void;
17
+ clear(): Promise<void>;
18
+ }
@@ -0,0 +1,150 @@
1
+ /* authorization_context.js generated by Svelte v5.55.5 */
2
+ import * as $ from 'svelte/internal/client';
3
+
4
+ import {
5
+ AuthorizationContextCache,
6
+ AuthorizationContextRefreshError,
7
+ refreshAuthorizationContext,
8
+ startAuthorizationContextRefresh
9
+ } from "@oatscenter/trellis/auth";
10
+
11
+ export class AuthorizationContextController {
12
+ #cache;
13
+ #context = $.state();
14
+ #status = $.state("empty");
15
+ #error = $.state();
16
+ #stop;
17
+ #epoch = 0;
18
+
19
+ constructor(trellisUrl, fetch) {
20
+ this.#cache = new AuthorizationContextCache(trellisUrl, fetch);
21
+ }
22
+
23
+ get context() {
24
+ return $.get(this.#context);
25
+ }
26
+
27
+ get status() {
28
+ return $.get(this.#status);
29
+ }
30
+
31
+ get error() {
32
+ return $.get(this.#error);
33
+ }
34
+
35
+ get refreshAt() {
36
+ return $.get(this.#context)?.refreshAt;
37
+ }
38
+
39
+ get expiresAt() {
40
+ return $.get(this.#context)?.context.expiresAt;
41
+ }
42
+
43
+ async install(bundle, routing) {
44
+ $.set(this.#status, "loading");
45
+ $.set(this.#error, undefined);
46
+
47
+ try {
48
+ $.set(this.#context, await this.#cache.install(bundle, routing));
49
+ $.set(this.#status, "ready");
50
+ } catch(error) {
51
+ $.set(this.#status, "failed");
52
+ $.set(this.#error, error);
53
+
54
+ throw error;
55
+ }
56
+ }
57
+
58
+ async refresh(sessionId, auth) {
59
+ const epoch = this.#epoch;
60
+ const clearGuard = this.#cache.clearGuard();
61
+
62
+ $.set(this.#status, "refreshing");
63
+
64
+ try {
65
+ $.set(this.#context, await refreshAuthorizationContext({
66
+ trellisUrl: this.#cache.trellisUrl,
67
+ sessionId,
68
+ auth,
69
+ cache: this.#cache,
70
+ shouldInstall: () => epoch === this.#epoch
71
+ }));
72
+
73
+ $.set(this.#status, "ready");
74
+ $.set(this.#error, undefined);
75
+ } catch(error) {
76
+ if (epoch !== this.#epoch) return;
77
+
78
+ if (error instanceof AuthorizationContextRefreshError && error.terminal) {
79
+ if (!await this.#cache.clearIfCurrent(clearGuard)) {
80
+ $.set(this.#context, this.#cache.current());
81
+ $.set(this.#status, "ready");
82
+ $.set(this.#error, undefined);
83
+
84
+ return;
85
+ }
86
+
87
+ $.set(this.#context, undefined);
88
+ }
89
+
90
+ $.set(
91
+ this.#status,
92
+ error instanceof AuthorizationContextRefreshError && error.terminal
93
+ ? "authRequired"
94
+ : $.get(this.#context)?.context.expiresAt !== undefined && $.get(this.#context).context.expiresAt <= this.#cache.correctedNowSeconds() ? "expired" : "degraded",
95
+ true
96
+ );
97
+
98
+ $.set(this.#error, error);
99
+
100
+ throw error;
101
+ }
102
+ }
103
+
104
+ async refreshNow(sessionId, auth) {
105
+ await this.refresh(sessionId, auth);
106
+ }
107
+
108
+ start(sessionId, auth) {
109
+ this.stop();
110
+
111
+ if (!$.get(this.#context)) $.set(this.#status, "refreshing");
112
+
113
+ this.#stop = startAuthorizationContextRefresh({
114
+ trellisUrl: this.#cache.trellisUrl,
115
+ sessionId,
116
+ auth,
117
+ cache: this.#cache,
118
+ onRefresh: (context) => {
119
+ $.set(this.#context, context);
120
+ $.set(this.#status, "ready");
121
+ $.set(this.#error, undefined);
122
+ },
123
+
124
+ onTerminalFailure: (error) => {
125
+ $.set(this.#context, undefined);
126
+ $.set(this.#status, "authRequired");
127
+ $.set(this.#error, error);
128
+ },
129
+
130
+ onTransientFailure: (error) => {
131
+ $.set(this.#status, "degraded");
132
+ $.set(this.#error, error);
133
+ }
134
+ });
135
+ }
136
+
137
+ stop() {
138
+ this.#stop?.();
139
+ this.#stop = undefined;
140
+ }
141
+
142
+ async clear() {
143
+ this.#epoch += 1;
144
+ this.stop();
145
+ await this.#cache.clear();
146
+ $.set(this.#context, undefined);
147
+ $.set(this.#status, "empty");
148
+ $.set(this.#error, undefined);
149
+ }
150
+ }
@@ -0,0 +1,24 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import {
4
+ provideConnectedTrellisContext,
5
+ type TrellisAppOwner,
6
+ type TrellisContextClient,
7
+ } from "../context.js";
8
+
9
+ type Props = {
10
+ trellisApp: TrellisAppOwner;
11
+ trellis: TrellisContextClient;
12
+ children: Snippet;
13
+ };
14
+
15
+ const { trellisApp, trellis, children }: Props = $props();
16
+
17
+ function installContext(): void {
18
+ provideConnectedTrellisContext(trellisApp, trellis);
19
+ }
20
+
21
+ installContext();
22
+ </script>
23
+
24
+ {@render children()}
@@ -0,0 +1,11 @@
1
+ import type { Component, Snippet } from "svelte";
2
+ import type { TrellisAppOwner, TrellisContextClient } from "../context.js";
3
+
4
+ type TrellisContextProviderProps = {
5
+ trellisApp: TrellisAppOwner;
6
+ trellis: TrellisContextClient;
7
+ children: Snippet;
8
+ };
9
+
10
+ declare const TrellisContextProvider: Component<TrellisContextProviderProps>;
11
+ export default TrellisContextProvider;
@@ -0,0 +1,192 @@
1
+ <script lang="ts" generics="TContract extends TrellisParticipantLike">
2
+ import {
3
+ classifyBrowserAuthError,
4
+ ClientAuthHandledError,
5
+ TrellisClient,
6
+ type ClientAuthOptions,
7
+ } from "@oatscenter/trellis";
8
+ import { onMount } from "svelte";
9
+ import type {
10
+ TrellisClientFor,
11
+ TrellisParticipantLike,
12
+ } from "../context.js";
13
+ import { resolveTrellisAppUrl } from "../context.js";
14
+ import TrellisContextProvider from "./TrellisContextProvider.svelte";
15
+ import type { TrellisProviderProps } from "./TrellisProvider.types.js";
16
+
17
+ const {
18
+ trellisApp,
19
+ auth,
20
+ client,
21
+ children,
22
+ loading,
23
+ recoveringAuth,
24
+ error: errorSnippet,
25
+ onAuthRequired,
26
+ onRecoverableAuthError,
27
+ }: TrellisProviderProps<TContract> = $props();
28
+
29
+ type ProviderState = "connecting" | "connected" | "auth_handled" | "failed";
30
+
31
+ let trellis = $state<TrellisClientFor<TContract> | null>(null);
32
+ let connectError = $state<unknown>(null);
33
+ let providerState = $state<ProviderState>("connecting");
34
+
35
+ type SerializableTrellisError = {
36
+ message?: unknown;
37
+ code?: unknown;
38
+ hint?: unknown;
39
+ context?: unknown;
40
+ };
41
+
42
+ function maybeSerializableError(
43
+ value: unknown,
44
+ ): SerializableTrellisError | undefined {
45
+ if (!value || typeof value !== "object" || !("toSerializable" in value)) {
46
+ return undefined;
47
+ }
48
+ const serialize = value.toSerializable;
49
+ if (typeof serialize !== "function") return undefined;
50
+ const serialized = serialize.call(value);
51
+ return serialized && typeof serialized === "object"
52
+ ? (serialized as SerializableTrellisError)
53
+ : undefined;
54
+ }
55
+
56
+ function contextRecord(value: unknown): Record<string, unknown> | undefined {
57
+ return value && typeof value === "object" && !Array.isArray(value)
58
+ ? (value as Record<string, unknown>)
59
+ : undefined;
60
+ }
61
+
62
+ function logConnectionError(error: unknown): void {
63
+ const serialized = maybeSerializableError(error);
64
+ const context = contextRecord(serialized?.context);
65
+ const causeMessage =
66
+ typeof context?.causeMessage === "string"
67
+ ? context.causeMessage
68
+ : undefined;
69
+ const message =
70
+ typeof serialized?.message === "string"
71
+ ? serialized.message
72
+ : error instanceof Error
73
+ ? error.message
74
+ : String(error);
75
+
76
+ console.error("TrellisProvider failed to connect", {
77
+ message,
78
+ code: serialized?.code,
79
+ hint: serialized?.hint,
80
+ causeMessage,
81
+ context: serialized?.context,
82
+ error,
83
+ });
84
+ }
85
+
86
+ onMount(() => {
87
+ let active = true;
88
+
89
+ function withBrowserAuthDefaults(
90
+ authOptions: ClientAuthOptions | undefined,
91
+ ): ClientAuthOptions {
92
+ if (authOptions?.mode === "session_key") {
93
+ return authOptions;
94
+ }
95
+
96
+ return {
97
+ ...authOptions,
98
+ currentUrl:
99
+ authOptions?.currentUrl ?? (() => new URL(window.location.href)),
100
+ };
101
+ }
102
+
103
+ const connectAuth = withBrowserAuthDefaults(auth);
104
+ const trellisUrl = resolveTrellisAppUrl(trellisApp.trellisUrl);
105
+ if (!trellisUrl) {
106
+ connectError = new TypeError(
107
+ "Expected trellisApp to resolve a Trellis URL",
108
+ );
109
+ providerState = "failed";
110
+ return;
111
+ }
112
+
113
+ void (async () => {
114
+ try {
115
+ const connected = await TrellisClient.connect({
116
+ ...client,
117
+ trellisUrl,
118
+ participant: trellisApp.participant,
119
+ auth: connectAuth,
120
+ onAuthRequired: onAuthRequired
121
+ ? async (ctx) => {
122
+ await onAuthRequired(ctx.loginUrl, ctx);
123
+ return { status: "handled" };
124
+ }
125
+ : undefined,
126
+ }).orThrow();
127
+
128
+ if (active) {
129
+ trellis = connected;
130
+ providerState = "connected";
131
+ } else {
132
+ await connected.connection.close();
133
+ }
134
+ } catch (error) {
135
+ if (!active) return;
136
+ if (error instanceof ClientAuthHandledError) {
137
+ providerState = "auth_handled";
138
+ return;
139
+ }
140
+ const authRecovery = classifyBrowserAuthError(error);
141
+ if (authRecovery.recoverable) {
142
+ if (onRecoverableAuthError) {
143
+ providerState = "auth_handled";
144
+ try {
145
+ await onRecoverableAuthError(error);
146
+ return;
147
+ } catch (recoveryError) {
148
+ if (!active) return;
149
+ console.error("TrellisProvider auth recovery callback failed", {
150
+ recoveryError,
151
+ error,
152
+ });
153
+ logConnectionError(recoveryError);
154
+ connectError = recoveryError;
155
+ providerState = "failed";
156
+ return;
157
+ }
158
+ }
159
+ if (recoveringAuth) {
160
+ providerState = "auth_handled";
161
+ return;
162
+ }
163
+ }
164
+ logConnectionError(error);
165
+ connectError = error;
166
+ providerState = "failed";
167
+ }
168
+ })();
169
+
170
+ return () => {
171
+ active = false;
172
+ const connected = trellis;
173
+ trellis = null;
174
+ providerState = "connecting";
175
+ if (connected) {
176
+ void connected.connection.close();
177
+ }
178
+ };
179
+ });
180
+ </script>
181
+
182
+ {#if trellis}
183
+ <TrellisContextProvider {trellisApp} {trellis} {children} />
184
+ {:else if providerState === "failed" && connectError}
185
+ {#if errorSnippet}
186
+ {@render errorSnippet(connectError)}
187
+ {/if}
188
+ {:else if providerState === "auth_handled" && recoveringAuth}
189
+ {@render recoveringAuth()}
190
+ {:else if loading}
191
+ {@render loading()}
192
+ {/if}
@@ -0,0 +1,6 @@
1
+ import type { Component } from "svelte";
2
+ import type { TrellisProviderProps } from "./TrellisProvider.types.js";
3
+
4
+ /** Svelte component that connects a Trellis app and provides context to children. */
5
+ declare const TrellisProvider: Component<TrellisProviderProps>;
6
+ export default TrellisProvider;
@@ -0,0 +1,15 @@
1
+ import type { ClientAuthOptions, ClientAuthRequiredContext, ClientOpts } from "@oatscenter/trellis";
2
+ import type { Snippet } from "svelte";
3
+ import type { TrellisAppOwner, TrellisParticipantLike } from "../context.js";
4
+ /** Props accepted by the Svelte Trellis provider component. */
5
+ export type TrellisProviderProps<TContract extends TrellisParticipantLike = TrellisParticipantLike> = {
6
+ trellisApp: TrellisAppOwner<TContract>;
7
+ auth?: ClientAuthOptions;
8
+ client?: ClientOpts;
9
+ children: Snippet;
10
+ loading?: Snippet;
11
+ recoveringAuth?: Snippet;
12
+ error?: Snippet<[unknown]>;
13
+ onAuthRequired?: (loginUrl: string, context: ClientAuthRequiredContext) => void | Promise<void>;
14
+ onRecoverableAuthError?: (error: unknown) => void | Promise<void>;
15
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,72 @@
1
+ import type { CallerParticipant, ConnectedTrellisClient, TrellisConnection, TrellisConnectionStatus } from "@oatscenter/trellis";
2
+ /** Minimal contract shape required to create a typed Trellis Svelte app context. */
3
+ export type TrellisParticipantLike = CallerParticipant;
4
+ /** Real connected Trellis client type exposed by a Svelte app context. */
5
+ export type TrellisClientFor<TContract extends TrellisParticipantLike> = ConnectedTrellisClient<TContract>;
6
+ /** Minimal client surface required for Trellis Svelte context clients. */
7
+ export type TrellisContextClient = {
8
+ readonly connection: TrellisConnection;
9
+ };
10
+ /** URL value accepted by a Trellis Svelte app owner. */
11
+ export type TrellisAppUrl = string | URL;
12
+ /**
13
+ * Trellis URL configuration for a Svelte app owner.
14
+ *
15
+ * A function resolver supports apps whose Trellis instance is selected at
16
+ * runtime. Returning `undefined` means no instance is currently available.
17
+ */
18
+ export type TrellisAppUrlResolver = TrellisAppUrl | (() => TrellisAppUrl | undefined);
19
+ /** Options used to create a Trellis Svelte app owner. */
20
+ export type CreateTrellisAppOptions<TContract extends TrellisParticipantLike = TrellisParticipantLike> = {
21
+ /** Generated participant used by this app context and its connections. */
22
+ participant: TContract;
23
+ /** Trellis URL, or a resolver for runtime-selected Trellis URLs. */
24
+ trellisUrl: TrellisAppUrlResolver;
25
+ };
26
+ /** Resolves a Trellis app URL config to the string shape required by the client. */
27
+ export declare function resolveTrellisAppUrl(trellisUrl: TrellisAppUrlResolver): string | undefined;
28
+ /** Svelte-reactive adapter around a framework-neutral Trellis connection. */
29
+ export declare class SvelteTrellisConnection {
30
+ #private;
31
+ /** Creates a reactive connection adapter for a connected Trellis runtime. */
32
+ constructor(connection: TrellisConnection);
33
+ /** Latest connection status, reactive when read by Svelte effects or markup. */
34
+ get status(): TrellisConnectionStatus;
35
+ /** Closes the underlying Trellis runtime connection. */
36
+ close(): Promise<void>;
37
+ }
38
+ declare const trellisAppOwnerBrand: unique symbol;
39
+ /** Minimal branded app owner surface accepted by the Trellis Svelte provider. */
40
+ export type TrellisAppOwner<TContract extends TrellisParticipantLike = TrellisParticipantLike> = {
41
+ readonly participant: TContract;
42
+ readonly trellisUrl: TrellisAppUrlResolver;
43
+ readonly [trellisAppOwnerBrand]: true;
44
+ };
45
+ /**
46
+ * Public app-scoped typed Svelte context owner for a Trellis browser app.
47
+ *
48
+ * `TClient` is a type-only refinement over the descriptor-inferred caller runtime.
49
+ */
50
+ export interface TrellisApp<TContract extends TrellisParticipantLike = TrellisParticipantLike, TClient extends TrellisContextClient = TrellisClientFor<TContract>> extends TrellisAppOwner<TContract> {
51
+ /** Generated participant used by this app context and its connections. */
52
+ readonly participant: TContract;
53
+ /** Trellis URL configuration used by `TrellisProvider` connections. */
54
+ readonly trellisUrl: TrellisAppUrlResolver;
55
+ /** Returns the contract-typed connected Trellis client from Svelte context synchronously. */
56
+ getTrellis(): TClient;
57
+ /** Returns a Svelte-reactive adapter for the real Trellis connection. */
58
+ getConnection(): SvelteTrellisConnection;
59
+ }
60
+ /**
61
+ * Creates an app-scoped typed Svelte context owner for a Trellis contract and URL.
62
+ *
63
+ * The optional `TClient` type parameter refines the connected caller runtime.
64
+ */
65
+ export declare function createTrellisApp<TContract extends TrellisParticipantLike, TClient extends TrellisContextClient = TrellisClientFor<TContract>>(options: CreateTrellisAppOptions<TContract>): TrellisApp<TContract, TClient>;
66
+ /**
67
+ * Internal provider helper that synchronously installs connected Trellis context.
68
+ *
69
+ * This is intentionally not exported from `src/index.ts`.
70
+ */
71
+ export declare function provideConnectedTrellisContext(app: TrellisAppOwner, trellis: TrellisContextClient): void;
72
+ export {};
@@ -0,0 +1,116 @@
1
+ /* context.js generated by Svelte v5.55.5 */
2
+ import * as $ from 'svelte/internal/client';
3
+ import { createContext } from "svelte";
4
+ import { createSubscriber } from "svelte/reactivity";
5
+
6
+ export function resolveTrellisAppUrl(trellisUrl) {
7
+ const resolved = typeof trellisUrl === "function" ? trellisUrl() : trellisUrl;
8
+
9
+ return resolved?.toString();
10
+ }
11
+
12
+ /** Svelte-reactive adapter around a framework-neutral Trellis connection. */
13
+ export class SvelteTrellisConnection {
14
+ #connection;
15
+ #subscribe;
16
+
17
+ /** Creates a reactive connection adapter for a connected Trellis runtime. */
18
+ constructor(connection) {
19
+ this.#connection = connection;
20
+
21
+ this.#subscribe = createSubscriber((update) => {
22
+ return this.#connection.subscribe(() => update());
23
+ });
24
+ }
25
+
26
+ /** Latest connection status, reactive when read by Svelte effects or markup. */
27
+ get status() {
28
+ this.#subscribe();
29
+
30
+ return this.#connection.status;
31
+ }
32
+
33
+ /** Closes the underlying Trellis runtime connection. */
34
+ close() {
35
+ return this.#connection.close();
36
+ }
37
+ }
38
+
39
+ const provideTrellisContext = Symbol("provideTrellisContext");
40
+ const trellisAppOwnerBrand = Symbol("trellisAppOwner");
41
+
42
+ /** Internal app-scoped typed Svelte context implementation. */
43
+ class TrellisAppImpl {
44
+ [trellisAppOwnerBrand] = true;
45
+ #participant;
46
+ #trellisUrl;
47
+ #getContext;
48
+ #setContext;
49
+
50
+ /** Creates an app-scoped context owner for a specific Trellis contract. */
51
+ constructor(options) {
52
+ const { participant, trellisUrl } = options;
53
+
54
+ this.#participant = participant;
55
+ this.#trellisUrl = trellisUrl;
56
+
57
+ const [getContext, setContext] = createContext();
58
+
59
+ this.#getContext = getContext;
60
+ this.#setContext = setContext;
61
+ }
62
+
63
+ /** Generated participant used by `TrellisProvider` connections. */
64
+ get participant() {
65
+ return this.#participant;
66
+ }
67
+
68
+ /** Trellis URL configuration used by `TrellisProvider` connections. */
69
+ get trellisUrl() {
70
+ return this.#trellisUrl;
71
+ }
72
+
73
+ /** Returns the contract-typed connected Trellis client from Svelte context synchronously. */
74
+ getTrellis() {
75
+ return this.#getContext().trellis;
76
+ }
77
+
78
+ /** Returns a Svelte-reactive adapter for the real Trellis connection. */
79
+ getConnection() {
80
+ return this.#getContext().connection;
81
+ }
82
+
83
+ /** Installs the connected Trellis runtime into Svelte context synchronously. */
84
+ [provideTrellisContext](trellis) {
85
+ this.#setContext({
86
+ trellis,
87
+ connection: new SvelteTrellisConnection(trellis.connection)
88
+ });
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Creates an app-scoped typed Svelte context owner for a Trellis contract and URL.
94
+ *
95
+ * The optional `TClient` type parameter refines the connected caller runtime.
96
+ */
97
+ export function createTrellisApp(options) {
98
+ return new TrellisAppImpl(options);
99
+ }
100
+
101
+ function isTrellisAppImpl(app) {
102
+ return app instanceof TrellisAppImpl;
103
+ }
104
+
105
+ /**
106
+ * Internal provider helper that synchronously installs connected Trellis context.
107
+ *
108
+ * This is intentionally not exported from `src/index.ts`.
109
+ */
110
+ export function provideConnectedTrellisContext(app, trellis) {
111
+ if (!isTrellisAppImpl(app)) {
112
+ throw new TypeError("Expected an app created by createTrellisApp");
113
+ }
114
+
115
+ app[provideTrellisContext](trellis);
116
+ }
@@ -0,0 +1,6 @@
1
+ import { type DeviceActivationControllerConfig, DeviceActivationControllerCore } from "./device_activation_controller.js";
2
+ export type { DeviceActivationAuth, DeviceActivationClient, DeviceActivationControllerConfig, DeviceActivationOperationRef, } from "./device_activation_controller.js";
3
+ export declare class DeviceActivationController extends DeviceActivationControllerCore {
4
+ constructor(config: DeviceActivationControllerConfig);
5
+ }
6
+ export declare function createDeviceActivationController(config: DeviceActivationControllerConfig): DeviceActivationController;
@@ -0,0 +1,19 @@
1
+ /* device_activation.js generated by Svelte v5.55.5 */
2
+ import * as $ from 'svelte/internal/client';
3
+
4
+ import {
5
+ createInitialDeviceActivationState,
6
+ DeviceActivationControllerCore
7
+ } from "./device_activation_controller.js";
8
+
9
+ export class DeviceActivationController extends DeviceActivationControllerCore {
10
+ constructor(config) {
11
+ const state = $.proxy(createInitialDeviceActivationState());
12
+
13
+ super(config, state);
14
+ }
15
+ }
16
+
17
+ export function createDeviceActivationController(config) {
18
+ return new DeviceActivationController(config);
19
+ }