Skip to content

Commit fba39bb

Browse files
refactor(web): remove unused environment runtime wrappers
1 parent bfba778 commit fba39bb

21 files changed

Lines changed: 15 additions & 187 deletions

‎apps/web/src/assets/assetUrls.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ export function useAssetUrlState(
3232
);
3333
}
3434

35-
export function useAssetUrl(
36-
environmentId: EnvironmentId | null,
37-
resource: AssetResource | null,
38-
): string | null {
39-
const result = useAssetUrlState(environmentId, resource);
40-
return result._tag === "Success" ? result.url : null;
41-
}
42-
4335
export function useAssetUrlRefresh(
4436
environmentId: EnvironmentId | null,
4537
resource: AssetResource | null,

‎apps/web/src/assets/projectFaviconCache.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async function withStore<A>(
4646
}
4747

4848
/** Rasterizes a bitmap that is too large to inline, retrying at half size. */
49-
export async function downscaleProjectFavicon(
49+
async function downscaleProjectFavicon(
5050
image: { readonly mimeType: string; readonly bytes: Uint8Array<ArrayBuffer> },
5151
signal: AbortSignal,
5252
) {

‎apps/web/src/cloud/connectCliAuth.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { hasCloudPublicConfig, resolveCloudPublicConfig, trimNonEmpty } from "./
1212

1313
const CONNECT_CLI_AUTH_STATE_STORAGE_KEY = "t3code-connect-cli-auth-state";
1414

15-
export function resolveConnectCliOAuthClientId(): string | null {
15+
function resolveConnectCliOAuthClientId(): string | null {
1616
return trimNonEmpty(import.meta.env.VITE_CLERK_CLI_OAUTH_CLIENT_ID as string | undefined);
1717
}
1818

‎apps/web/src/cloud/managedRelayLayer.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
type BrowserDpopKey,
1414
} from "./dpop";
1515

16-
export const relayDpopSignerLayer = Layer.effect(
16+
const relayDpopSignerLayer = Layer.effect(
1717
ManagedRelay.ManagedRelayDpopSigner,
1818
Effect.gen(function* () {
1919
const crypto = yield* Crypto.Crypto;

‎apps/web/src/cloud/managedRelayState.ts‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const managedRelayAtomRuntime = Atom.runtime(
3333
),
3434
);
3535

36-
export const managedRelayQueryManager = createManagedRelayQueryManager(managedRelayAtomRuntime);
36+
const managedRelayQueryManager = createManagedRelayQueryManager(managedRelayAtomRuntime);
3737

3838
const managedRelayMutationScheduler = createAtomCommandScheduler();
3939

@@ -114,10 +114,3 @@ export function useManagedRelayDevices() {
114114
refresh,
115115
};
116116
}
117-
118-
export function refreshManagedRelayEnvironments(): void {
119-
const session = appAtomRegistry.get(managedRelaySessionAtom);
120-
if (session) {
121-
managedRelayQueryManager.refreshEnvironments(appAtomRegistry, session.accountId);
122-
}
123-
}

‎apps/web/src/cloud/primaryCloudLinkState.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function targetKey(target: CloudLinkTarget): string {
4242
return JSON.stringify(target);
4343
}
4444

45-
export function refreshPrimaryCloudLinkState(target: CloudLinkTarget | null): void {
45+
function refreshPrimaryCloudLinkState(target: CloudLinkTarget | null): void {
4646
if (target) {
4747
appAtomRegistry.refresh(primaryCloudLinkStateAtom(targetKey(target)));
4848
}

‎apps/web/src/connection/desktopLocal.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
* via {@link isDesktopLocalConnectionTarget}, so the convention can never drift
1818
* between the two.
1919
*/
20-
export const DESKTOP_LOCAL_CONNECTION_ID_PREFIX = "local:";
20+
const DESKTOP_LOCAL_CONNECTION_ID_PREFIX = "local:";
2121

2222
export function desktopLocalConnectionId(backendId: string): string {
2323
return `${DESKTOP_LOCAL_CONNECTION_ID_PREFIX}${backendId}`;

‎apps/web/src/environments/primary/auth.ts‎

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import type {
99
} from "@t3tools/contracts";
1010
import { EnvironmentHttpCommonError, PRIMARY_LOCAL_ENVIRONMENT_ID } from "@t3tools/contracts";
1111
import type { EnvironmentHttpCommonError as EnvironmentHttpCommonErrorType } from "@t3tools/contracts";
12-
import * as DateTime from "effect/DateTime";
1312
import * as Effect from "effect/Effect";
1413
import * as Schema from "effect/Schema";
1514
import { HttpClientError } from "effect/unstable/http";
@@ -66,7 +65,7 @@ export class PrimaryEnvironmentRequestError extends Schema.TaggedErrorClass<Prim
6665
}
6766
}
6867

69-
export const isPrimaryEnvironmentRequestError = Schema.is(PrimaryEnvironmentRequestError);
68+
const isPrimaryEnvironmentRequestError = Schema.is(PrimaryEnvironmentRequestError);
7069

7170
export class PrimaryEnvironmentPairingCredentialRejectedError extends Schema.TaggedErrorClass<PrimaryEnvironmentPairingCredentialRejectedError>()(
7271
"PrimaryEnvironmentPairingCredentialRejectedError",
@@ -96,10 +95,6 @@ export class PrimaryEnvironmentAuthSessionTimeoutError extends Schema.TaggedErro
9695
}
9796
}
9897

99-
export const isPrimaryEnvironmentAuthSessionTimeoutError = Schema.is(
100-
PrimaryEnvironmentAuthSessionTimeoutError,
101-
);
102-
10398
export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema.TaggedErrorClass<PrimaryEnvironmentPairingCredentialRequiredError>()(
10499
"PrimaryEnvironmentPairingCredentialRequiredError",
105100
{
@@ -111,10 +106,6 @@ export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema.Tag
111106
}
112107
}
113108

114-
export const isPrimaryEnvironmentPairingCredentialRequiredError = Schema.is(
115-
PrimaryEnvironmentPairingCredentialRequiredError,
116-
);
117-
118109
const isEnvironmentHttpCommonError = Schema.is(EnvironmentHttpCommonError);
119110

120111
export interface ServerPairingLinkRecord {
@@ -386,44 +377,6 @@ export async function createServerPairingCredential(input?: {
386377
}
387378
}
388379

389-
export async function listServerPairingLinks(): Promise<ReadonlyArray<ServerPairingLinkRecord>> {
390-
try {
391-
const pairingLinks = await runPrimaryHttp(
392-
PrimaryEnvironmentHttpClient.pipe(
393-
Effect.flatMap((client) => client.auth.pairingLinks({ headers: {} })),
394-
),
395-
);
396-
return pairingLinks.map((pairingLink) => {
397-
const timestamps = {
398-
createdAt: DateTime.formatIso(pairingLink.createdAt),
399-
expiresAt: DateTime.formatIso(pairingLink.expiresAt),
400-
};
401-
if (pairingLink.label === undefined) {
402-
return {
403-
id: pairingLink.id,
404-
scopes: pairingLink.scopes,
405-
subject: pairingLink.subject,
406-
createdAt: timestamps.createdAt,
407-
expiresAt: timestamps.expiresAt,
408-
};
409-
}
410-
return {
411-
id: pairingLink.id,
412-
scopes: pairingLink.scopes,
413-
subject: pairingLink.subject,
414-
label: pairingLink.label,
415-
createdAt: timestamps.createdAt,
416-
expiresAt: timestamps.expiresAt,
417-
};
418-
});
419-
} catch (error) {
420-
throw PrimaryEnvironmentRequestError.fromCause({
421-
operation: "list-pairing-links",
422-
cause: error,
423-
});
424-
}
425-
}
426-
427380
export async function revokeServerPairingLink(id: string): Promise<void> {
428381
try {
429382
await runPrimaryHttp(
@@ -440,38 +393,6 @@ export async function revokeServerPairingLink(id: string): Promise<void> {
440393
}
441394
}
442395

443-
export async function listServerClientSessions(): Promise<
444-
ReadonlyArray<ServerClientSessionRecord>
445-
> {
446-
try {
447-
const clientSessions = await runPrimaryHttp(
448-
PrimaryEnvironmentHttpClient.pipe(
449-
Effect.flatMap((client) => client.auth.clients({ headers: {} })),
450-
),
451-
);
452-
return clientSessions.map((clientSession) => ({
453-
sessionId: clientSession.sessionId,
454-
subject: clientSession.subject,
455-
scopes: clientSession.scopes,
456-
method: clientSession.method,
457-
client: clientSession.client,
458-
issuedAt: DateTime.formatIso(clientSession.issuedAt),
459-
expiresAt: DateTime.formatIso(clientSession.expiresAt),
460-
lastConnectedAt:
461-
clientSession.lastConnectedAt === null
462-
? null
463-
: DateTime.formatIso(clientSession.lastConnectedAt),
464-
connected: clientSession.connected,
465-
current: clientSession.current,
466-
}));
467-
} catch (error) {
468-
throw PrimaryEnvironmentRequestError.fromCause({
469-
operation: "list-client-sessions",
470-
cause: error,
471-
});
472-
}
473-
}
474-
475396
export async function revokeServerClientSession(sessionId: AuthSessionId): Promise<void> {
476397
try {
477398
await runPrimaryHttp(
@@ -531,16 +452,6 @@ export async function resolveInitialServerAuthGateState(): Promise<ServerAuthGat
531452
});
532453
}
533454

534-
// Used by the WSL backend swap: invalidate the cached authenticated state
535-
// (the new backend signs sessions with a different key) and re-bootstrap
536-
// against the desktop bootstrap credential so the next WS reconnect doesn't
537-
// hit 401 and start a reauth loop in the renderer.
538-
export async function reauthenticatePrimaryEnvironment(): Promise<ServerAuthGateState> {
539-
resolvedAuthenticatedGateState = null;
540-
bootstrapPromise = null;
541-
return resolveInitialServerAuthGateState();
542-
}
543-
544455
export function __resetServerAuthBootstrapForTests() {
545456
bootstrapPromise = null;
546457
resolvedAuthenticatedGateState = null;

‎apps/web/src/environments/primary/context.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function fetchPrimaryEnvironmentDescriptor(): Promise<ExecutionEnvironment
5454
});
5555
}
5656

57-
export function readPrimaryEnvironmentDescriptor(): ExecutionEnvironmentDescriptor | null {
57+
function readPrimaryEnvironmentDescriptor(): ExecutionEnvironmentDescriptor | null {
5858
return primaryEnvironmentDescriptor;
5959
}
6060

‎apps/web/src/environments/primary/index.ts‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
export {
22
getPrimaryKnownEnvironment,
3-
readPrimaryEnvironmentDescriptor,
43
resetPrimaryEnvironmentDescriptorForTests,
54
resolveInitialPrimaryEnvironmentDescriptor,
65
writePrimaryEnvironmentDescriptor,
76
} from "./context";
87

9-
export {
10-
resolveInitialPrimaryEnvironmentDescriptor as ensurePrimaryEnvironmentReady,
11-
writePrimaryEnvironmentDescriptor as updatePrimaryEnvironmentDescriptor,
12-
} from "./context";
13-
148
export {
159
createServerPairingCredential,
16-
fetchSessionState,
1710
isPrimaryEnvironmentPairingCredentialRejectedError,
18-
isPrimaryEnvironmentRequestError,
19-
listServerClientSessions,
20-
listServerPairingLinks,
2111
peekPairingTokenFromUrl,
2212
PrimaryEnvironmentPairingCredentialRejectedError,
2313
PrimaryEnvironmentRequestError,
24-
reauthenticatePrimaryEnvironment,
2514
resolveInitialServerAuthGateState,
2615
revokeOtherServerClientSessions,
2716
revokeServerClientSession,
@@ -34,9 +23,7 @@ export {
3423
__resetServerAuthBootstrapForTests,
3524
} from "./auth";
3625

37-
export { refreshPrimarySessionState, usePrimarySessionState } from "./sessionState";
38-
39-
export { PrimaryEnvironmentHttpClient } from "./httpClient";
26+
export { usePrimarySessionState } from "./sessionState";
4027

4128
export {
4229
DesktopEnvironmentBootstrapIncompleteError,

0 commit comments

Comments
 (0)