refactor(web): remove unused runtime wrappers and exports (#10225)
This commit is contained in:
1 parent
b2e15185ae
commit
fdcc491e0b
21 files changed
+15
-187
No files matched your search
@@ -32,14 +32,6 @@ export function useAssetUrlState(
|
||||
);
|
||||
}
|
||||
|
||||
export function useAssetUrl(
|
||||
environmentId: EnvironmentId | null,
|
||||
resource: AssetResource | null,
|
||||
): string | null {
|
||||
const result = useAssetUrlState(environmentId, resource);
|
||||
return result._tag === "Success" ? result.url : null;
|
||||
}
|
||||
|
||||
export function useAssetUrlRefresh(
|
||||
environmentId: EnvironmentId | null,
|
||||
resource: AssetResource | null,
|
||||
|
||||
@@ -46,7 +46,7 @@ async function withStore<A>(
|
||||
}
|
||||
|
||||
/** Rasterizes a bitmap that is too large to inline, retrying at half size. */
|
||||
export async function downscaleProjectFavicon(
|
||||
async function downscaleProjectFavicon(
|
||||
image: { readonly mimeType: string; readonly bytes: Uint8Array<ArrayBuffer> },
|
||||
signal: AbortSignal,
|
||||
) {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { hasCloudPublicConfig, resolveCloudPublicConfig, trimNonEmpty } from "./
|
||||
|
||||
const CONNECT_CLI_AUTH_STATE_STORAGE_KEY = "t3code-connect-cli-auth-state";
|
||||
|
||||
export function resolveConnectCliOAuthClientId(): string | null {
|
||||
function resolveConnectCliOAuthClientId(): string | null {
|
||||
return trimNonEmpty(import.meta.env.VITE_CLERK_CLI_OAUTH_CLIENT_ID as string | undefined);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
type BrowserDpopKey,
|
||||
} from "./dpop";
|
||||
|
||||
export const relayDpopSignerLayer = Layer.effect(
|
||||
const relayDpopSignerLayer = Layer.effect(
|
||||
ManagedRelay.ManagedRelayDpopSigner,
|
||||
Effect.gen(function* () {
|
||||
const crypto = yield* Crypto.Crypto;
|
||||
|
||||
@@ -33,7 +33,7 @@ const managedRelayAtomRuntime = Atom.runtime(
|
||||
),
|
||||
);
|
||||
|
||||
export const managedRelayQueryManager = createManagedRelayQueryManager(managedRelayAtomRuntime);
|
||||
const managedRelayQueryManager = createManagedRelayQueryManager(managedRelayAtomRuntime);
|
||||
|
||||
const managedRelayMutationScheduler = createAtomCommandScheduler();
|
||||
|
||||
@@ -114,10 +114,3 @@ export function useManagedRelayDevices() {
|
||||
refresh,
|
||||
};
|
||||
}
|
||||
|
||||
export function refreshManagedRelayEnvironments(): void {
|
||||
const session = appAtomRegistry.get(managedRelaySessionAtom);
|
||||
if (session) {
|
||||
managedRelayQueryManager.refreshEnvironments(appAtomRegistry, session.accountId);
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ function targetKey(target: CloudLinkTarget): string {
|
||||
return JSON.stringify(target);
|
||||
}
|
||||
|
||||
export function refreshPrimaryCloudLinkState(target: CloudLinkTarget | null): void {
|
||||
function refreshPrimaryCloudLinkState(target: CloudLinkTarget | null): void {
|
||||
if (target) {
|
||||
appAtomRegistry.refresh(primaryCloudLinkStateAtom(targetKey(target)));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
* via {@link isDesktopLocalConnectionTarget}, so the convention can never drift
|
||||
* between the two.
|
||||
*/
|
||||
export const DESKTOP_LOCAL_CONNECTION_ID_PREFIX = "local:";
|
||||
const DESKTOP_LOCAL_CONNECTION_ID_PREFIX = "local:";
|
||||
|
||||
export function desktopLocalConnectionId(backendId: string): string {
|
||||
return `${DESKTOP_LOCAL_CONNECTION_ID_PREFIX}${backendId}`;
|
||||
|
||||
@@ -9,7 +9,6 @@ import type {
|
||||
} from "@t3tools/contracts";
|
||||
import { EnvironmentHttpCommonError, PRIMARY_LOCAL_ENVIRONMENT_ID } from "@t3tools/contracts";
|
||||
import type { EnvironmentHttpCommonError as EnvironmentHttpCommonErrorType } from "@t3tools/contracts";
|
||||
import * as DateTime from "effect/DateTime";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Schema from "effect/Schema";
|
||||
import { HttpClientError } from "effect/unstable/http";
|
||||
@@ -66,7 +65,7 @@ export class PrimaryEnvironmentRequestError extends Schema.TaggedErrorClass<Prim
|
||||
}
|
||||
}
|
||||
|
||||
export const isPrimaryEnvironmentRequestError = Schema.is(PrimaryEnvironmentRequestError);
|
||||
const isPrimaryEnvironmentRequestError = Schema.is(PrimaryEnvironmentRequestError);
|
||||
|
||||
export class PrimaryEnvironmentPairingCredentialRejectedError extends Schema.TaggedErrorClass<PrimaryEnvironmentPairingCredentialRejectedError>()(
|
||||
"PrimaryEnvironmentPairingCredentialRejectedError",
|
||||
@@ -96,10 +95,6 @@ export class PrimaryEnvironmentAuthSessionTimeoutError extends Schema.TaggedErro
|
||||
}
|
||||
}
|
||||
|
||||
export const isPrimaryEnvironmentAuthSessionTimeoutError = Schema.is(
|
||||
PrimaryEnvironmentAuthSessionTimeoutError,
|
||||
);
|
||||
|
||||
export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema.TaggedErrorClass<PrimaryEnvironmentPairingCredentialRequiredError>()(
|
||||
"PrimaryEnvironmentPairingCredentialRequiredError",
|
||||
{
|
||||
@@ -111,10 +106,6 @@ export class PrimaryEnvironmentPairingCredentialRequiredError extends Schema.Tag
|
||||
}
|
||||
}
|
||||
|
||||
export const isPrimaryEnvironmentPairingCredentialRequiredError = Schema.is(
|
||||
PrimaryEnvironmentPairingCredentialRequiredError,
|
||||
);
|
||||
|
||||
const isEnvironmentHttpCommonError = Schema.is(EnvironmentHttpCommonError);
|
||||
|
||||
export interface ServerPairingLinkRecord {
|
||||
@@ -386,44 +377,6 @@ export async function createServerPairingCredential(input?: {
|
||||
}
|
||||
}
|
||||
|
||||
export async function listServerPairingLinks(): Promise<ReadonlyArray<ServerPairingLinkRecord>> {
|
||||
try {
|
||||
const pairingLinks = await runPrimaryHttp(
|
||||
PrimaryEnvironmentHttpClient.pipe(
|
||||
Effect.flatMap((client) => client.auth.pairingLinks({ headers: {} })),
|
||||
),
|
||||
);
|
||||
return pairingLinks.map((pairingLink) => {
|
||||
const timestamps = {
|
||||
createdAt: DateTime.formatIso(pairingLink.createdAt),
|
||||
expiresAt: DateTime.formatIso(pairingLink.expiresAt),
|
||||
};
|
||||
if (pairingLink.label === undefined) {
|
||||
return {
|
||||
id: pairingLink.id,
|
||||
scopes: pairingLink.scopes,
|
||||
subject: pairingLink.subject,
|
||||
createdAt: timestamps.createdAt,
|
||||
expiresAt: timestamps.expiresAt,
|
||||
};
|
||||
}
|
||||
return {
|
||||
id: pairingLink.id,
|
||||
scopes: pairingLink.scopes,
|
||||
subject: pairingLink.subject,
|
||||
label: pairingLink.label,
|
||||
createdAt: timestamps.createdAt,
|
||||
expiresAt: timestamps.expiresAt,
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
throw PrimaryEnvironmentRequestError.fromCause({
|
||||
operation: "list-pairing-links",
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function revokeServerPairingLink(id: string): Promise<void> {
|
||||
try {
|
||||
await runPrimaryHttp(
|
||||
@@ -440,38 +393,6 @@ export async function revokeServerPairingLink(id: string): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function listServerClientSessions(): Promise<
|
||||
ReadonlyArray<ServerClientSessionRecord>
|
||||
> {
|
||||
try {
|
||||
const clientSessions = await runPrimaryHttp(
|
||||
PrimaryEnvironmentHttpClient.pipe(
|
||||
Effect.flatMap((client) => client.auth.clients({ headers: {} })),
|
||||
),
|
||||
);
|
||||
return clientSessions.map((clientSession) => ({
|
||||
sessionId: clientSession.sessionId,
|
||||
subject: clientSession.subject,
|
||||
scopes: clientSession.scopes,
|
||||
method: clientSession.method,
|
||||
client: clientSession.client,
|
||||
issuedAt: DateTime.formatIso(clientSession.issuedAt),
|
||||
expiresAt: DateTime.formatIso(clientSession.expiresAt),
|
||||
lastConnectedAt:
|
||||
clientSession.lastConnectedAt === null
|
||||
? null
|
||||
: DateTime.formatIso(clientSession.lastConnectedAt),
|
||||
connected: clientSession.connected,
|
||||
current: clientSession.current,
|
||||
}));
|
||||
} catch (error) {
|
||||
throw PrimaryEnvironmentRequestError.fromCause({
|
||||
operation: "list-client-sessions",
|
||||
cause: error,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function revokeServerClientSession(sessionId: AuthSessionId): Promise<void> {
|
||||
try {
|
||||
await runPrimaryHttp(
|
||||
@@ -531,16 +452,6 @@ export async function resolveInitialServerAuthGateState(): Promise<ServerAuthGat
|
||||
});
|
||||
}
|
||||
|
||||
// Used by the WSL backend swap: invalidate the cached authenticated state
|
||||
// (the new backend signs sessions with a different key) and re-bootstrap
|
||||
// against the desktop bootstrap credential so the next WS reconnect doesn't
|
||||
// hit 401 and start a reauth loop in the renderer.
|
||||
export async function reauthenticatePrimaryEnvironment(): Promise<ServerAuthGateState> {
|
||||
resolvedAuthenticatedGateState = null;
|
||||
bootstrapPromise = null;
|
||||
return resolveInitialServerAuthGateState();
|
||||
}
|
||||
|
||||
export function __resetServerAuthBootstrapForTests() {
|
||||
bootstrapPromise = null;
|
||||
resolvedAuthenticatedGateState = null;
|
||||
|
||||
@@ -54,7 +54,7 @@ async function fetchPrimaryEnvironmentDescriptor(): Promise<ExecutionEnvironment
|
||||
});
|
||||
}
|
||||
|
||||
export function readPrimaryEnvironmentDescriptor(): ExecutionEnvironmentDescriptor | null {
|
||||
function readPrimaryEnvironmentDescriptor(): ExecutionEnvironmentDescriptor | null {
|
||||
return primaryEnvironmentDescriptor;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,16 @@
|
||||
export {
|
||||
getPrimaryKnownEnvironment,
|
||||
readPrimaryEnvironmentDescriptor,
|
||||
resetPrimaryEnvironmentDescriptorForTests,
|
||||
resolveInitialPrimaryEnvironmentDescriptor,
|
||||
writePrimaryEnvironmentDescriptor,
|
||||
} from "./context";
|
||||
|
||||
export {
|
||||
resolveInitialPrimaryEnvironmentDescriptor as ensurePrimaryEnvironmentReady,
|
||||
writePrimaryEnvironmentDescriptor as updatePrimaryEnvironmentDescriptor,
|
||||
} from "./context";
|
||||
|
||||
export {
|
||||
createServerPairingCredential,
|
||||
fetchSessionState,
|
||||
isPrimaryEnvironmentPairingCredentialRejectedError,
|
||||
isPrimaryEnvironmentRequestError,
|
||||
listServerClientSessions,
|
||||
listServerPairingLinks,
|
||||
peekPairingTokenFromUrl,
|
||||
PrimaryEnvironmentPairingCredentialRejectedError,
|
||||
PrimaryEnvironmentRequestError,
|
||||
reauthenticatePrimaryEnvironment,
|
||||
resolveInitialServerAuthGateState,
|
||||
revokeOtherServerClientSessions,
|
||||
revokeServerClientSession,
|
||||
@@ -34,9 +23,7 @@ export {
|
||||
__resetServerAuthBootstrapForTests,
|
||||
} from "./auth";
|
||||
|
||||
export { refreshPrimarySessionState, usePrimarySessionState } from "./sessionState";
|
||||
|
||||
export { PrimaryEnvironmentHttpClient } from "./httpClient";
|
||||
export { usePrimarySessionState } from "./sessionState";
|
||||
|
||||
export {
|
||||
DesktopEnvironmentBootstrapIncompleteError,
|
||||
|
||||
@@ -14,7 +14,7 @@ const primarySessionStateAtom = Atom.make(Effect.promise(fetchSessionState)).pip
|
||||
Atom.withLabel("primary-environment:session"),
|
||||
);
|
||||
|
||||
export function refreshPrimarySessionState(): void {
|
||||
function refreshPrimarySessionState(): void {
|
||||
appAtomRegistry.refresh(primarySessionStateAtom);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ type RuntimeLayerSource =
|
||||
| typeof relayTracingLayer
|
||||
| ReturnType<typeof managedRelayClientLayer>;
|
||||
|
||||
export const remoteHttpRuntime = ManagedRuntime.make(httpClientLayer);
|
||||
|
||||
const primaryHttpRuntime = ManagedRuntime.make(
|
||||
PrimaryEnvironmentHttpClient.layer.pipe(Layer.provide(primaryEnvironmentHttpLayer)),
|
||||
);
|
||||
|
||||
@@ -41,15 +41,6 @@ export interface ClientTracingConfig {
|
||||
readonly exportIntervalMs?: number;
|
||||
}
|
||||
|
||||
export const ClientTracingLive = Layer.succeed(
|
||||
Tracer.Tracer,
|
||||
Tracer.make({
|
||||
span(options) {
|
||||
return activeDelegate?.span(options) ?? new Tracer.NativeSpan(options);
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
export function configureClientTracing(config: ClientTracingConfig = {}): Promise<void> {
|
||||
if (config.exportIntervalMs === undefined && activeConfigKey !== null) {
|
||||
return pendingConfiguration;
|
||||
|
||||
@@ -112,7 +112,7 @@ export function acknowledgeRpcRequest(requestId: string): void {
|
||||
setSlowRpcAckRequests(slowRequests.filter((request) => request.requestId !== requestId));
|
||||
}
|
||||
|
||||
export function clearAllTrackedRpcRequests(): void {
|
||||
function clearAllTrackedRpcRequests(): void {
|
||||
for (const pending of pendingRpcAckRequests.values()) {
|
||||
clearTimeout(pending.timeoutId);
|
||||
}
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
export {
|
||||
isTransportConnectionErrorMessage,
|
||||
sanitizeThreadErrorMessage,
|
||||
} from "@t3tools/client-runtime/errors";
|
||||
export { sanitizeThreadErrorMessage } from "@t3tools/client-runtime/errors";
|
||||
@@ -39,7 +39,7 @@ const EMPTY_THREAD_STATUS_ATOM = Atom.make<EnvironmentThreadStatus>("empty").pip
|
||||
Atom.withLabel("web-thread-status:empty"),
|
||||
);
|
||||
|
||||
export const activeEnvironmentIdAtom = Atom.make<EnvironmentId | null>(null).pipe(
|
||||
const activeEnvironmentIdAtom = Atom.make<EnvironmentId | null>(null).pipe(
|
||||
Atom.keepAlive,
|
||||
Atom.withLabel("web-active-environment-id"),
|
||||
);
|
||||
|
||||
@@ -11,7 +11,6 @@ import { useMemo } from "react";
|
||||
import { environmentCatalog } from "../connection/catalog";
|
||||
import { environmentPresentations, useEnvironmentPresentation } from "./presentation";
|
||||
import { primaryEnvironmentIdAtom } from "./primaryEnvironment";
|
||||
import { useEnvironmentQuery } from "./query";
|
||||
import { relayEnvironmentDiscovery } from "./relay";
|
||||
import { usePreparedConnection } from "./session";
|
||||
|
||||
@@ -85,7 +84,3 @@ export function useEnvironmentHttpBaseUrl(environmentId: EnvironmentId | null):
|
||||
export function useRelayEnvironmentDiscovery(): Discovery.RelayEnvironmentDiscoveryState {
|
||||
return useAtomValue(relayEnvironmentDiscovery.stateValueAtom);
|
||||
}
|
||||
|
||||
export function useEnvironmentConnectionState(environmentId: EnvironmentId) {
|
||||
return useEnvironmentQuery(environmentCatalog.stateAtom(environmentId));
|
||||
}
|
||||
@@ -14,7 +14,6 @@ import type {
|
||||
OrchestrationThread,
|
||||
ProjectContentMatch,
|
||||
ProjectEntryKind,
|
||||
ThreadId,
|
||||
VcsListRefsResult,
|
||||
VcsRef,
|
||||
} from "@t3tools/contracts";
|
||||
@@ -28,7 +27,6 @@ import { orchestrationEnvironment } from "./orchestration";
|
||||
import { isPaginatedBranchesNextPagePending } from "./paginatedBranches";
|
||||
import { projectContentSearch, projectEnvironment } from "./projects";
|
||||
import { useEnvironmentQuery } from "./query";
|
||||
import { useEnvironmentThread } from "./threads";
|
||||
import { vcsEnvironment } from "./vcs";
|
||||
|
||||
const PROJECT_PATH_SEARCH_DEBOUNCE_MS = 120;
|
||||
@@ -103,35 +101,6 @@ export function useThreadSearch(
|
||||
};
|
||||
}
|
||||
|
||||
export function useThreadDetail(
|
||||
environmentId: EnvironmentId | null,
|
||||
threadId: ThreadId | null,
|
||||
): ThreadDetailView {
|
||||
const state = useEnvironmentThread(environmentId, threadId);
|
||||
return {
|
||||
data: Option.getOrNull(state.data),
|
||||
error: Option.getOrNull(state.error),
|
||||
isPending: state.status === "synchronizing",
|
||||
isDeleted: state.status === "deleted",
|
||||
};
|
||||
}
|
||||
|
||||
export function useBranches(target: VcsRefTarget) {
|
||||
const query = target.query?.trim() ?? "";
|
||||
return useEnvironmentQuery(
|
||||
target.environmentId !== null && target.cwd !== null
|
||||
? vcsEnvironment.listRefs({
|
||||
environmentId: target.environmentId,
|
||||
input: {
|
||||
cwd: target.cwd,
|
||||
...(query.length > 0 ? { query } : {}),
|
||||
limit: VCS_REF_LIST_LIMIT,
|
||||
},
|
||||
})
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
export function usePaginatedBranches(target: VcsRefTarget) {
|
||||
const query = target.query?.trim() ?? "";
|
||||
const targetKey =
|
||||
|
||||
@@ -50,7 +50,7 @@ const EMPTY_PRIMARY_SERVER_STATE: PrimaryServerState = {
|
||||
welcome: null,
|
||||
};
|
||||
|
||||
export const primaryServerStateAtom = Atom.make((get): PrimaryServerState => {
|
||||
const primaryServerStateAtom = Atom.make((get): PrimaryServerState => {
|
||||
const environmentId = get(primaryEnvironmentIdAtom);
|
||||
if (environmentId === null) {
|
||||
return EMPTY_PRIMARY_SERVER_STATE;
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
} from "@t3tools/client-runtime/connection";
|
||||
import {
|
||||
createEnvironmentShellAtoms,
|
||||
createEnvironmentShellSummaryAtom,
|
||||
createEnvironmentSnapshotAtom,
|
||||
createShellEnvironmentAtoms,
|
||||
type EnvironmentShellState,
|
||||
@@ -21,10 +20,6 @@ import { isHostedStaticApp } from "../hostedPairing";
|
||||
export const shellEnvironment = createShellEnvironmentAtoms(connectionAtomRuntime);
|
||||
export const environmentShell = createEnvironmentShellAtoms(connectionAtomRuntime);
|
||||
export const environmentSnapshotAtom = createEnvironmentSnapshotAtom(environmentShell.stateAtom);
|
||||
export const environmentShellSummaryAtom = createEnvironmentShellSummaryAtom({
|
||||
catalogValueAtom: environmentCatalog.catalogValueAtom,
|
||||
shellStateValueAtom: environmentShell.stateValueAtom,
|
||||
});
|
||||
|
||||
export const allEnvironmentShellsBootstrappedAtom = Atom.make((get) => {
|
||||
const catalog = AsyncResult.value(get(environmentCatalog.catalogAtom));
|
||||
|
||||
@@ -16,7 +16,7 @@ import { connectionAtomRuntime } from "../connection/runtime";
|
||||
import { environmentSnapshotAtom } from "./shell";
|
||||
|
||||
export const threadEnvironment = createThreadEnvironmentAtoms(connectionAtomRuntime);
|
||||
export const environmentThreads = createEnvironmentThreadStateAtoms(connectionAtomRuntime);
|
||||
const environmentThreads = createEnvironmentThreadStateAtoms(connectionAtomRuntime);
|
||||
export const environmentThreadDetails = createEnvironmentThreadDetailAtoms(
|
||||
environmentThreads.stateAtom,
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user