Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/desktop/scripts/electron-launcher.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const repoRoot = NodePath.resolve(desktopDir, "..", "..");
const devBundleIdSuffix = NodePath.basename(repoRoot)
.toLowerCase()
.replaceAll(/[^a-z0-9]+/g, "");
export const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
export const APP_BUNDLE_ID = isDevelopment
const APP_DISPLAY_NAME = isDevelopment ? "T3 Code (Dev)" : "T3 Code (Alpha)";
const APP_BUNDLE_ID = isDevelopment
? `com.t3tools.t3code.dev.${devBundleIdSuffix || "local"}`
: "com.t3tools.t3code";
const APP_PROTOCOL_SCHEMES = isDevelopment ? ["t3code-dev"] : ["t3code"];
Expand Down Expand Up @@ -387,7 +387,7 @@ function resolveLinuxSandboxArgs(electronBinaryPath) {
return ["--no-sandbox"];
}

export function resolveElectronPath() {
function resolveElectronPath() {
const electronBinaryPath = resolveElectronBinaryPath();

if (hostPlatform !== "darwin") {
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopAppActivation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export class DesktopAppActivation extends Context.Service<

const { logWarning } = makeComponentLogger("desktop-app-activation");

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const desktopEnvironment = yield* DesktopEnvironment.DesktopEnvironment;
const desktopWindow = yield* DesktopWindow.DesktopWindow;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopAppIdentity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const resolveUserDataPath = Effect.gen(function* () {
: environment.path.join(environment.appDataDirectory, environment.userDataDirName);
}).pipe(Effect.withSpan("desktop.appIdentity.resolveUserDataPath"));

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const assets = yield* DesktopAssets.DesktopAssets;
const electronApp = yield* ElectronApp.ElectronApp;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopAssets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const resolveIconPath = Effect.fn("desktop.assets.resolveIconPath")(function* (
return yield* resolveResourcePath(`icon.${ext}`);
});

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const context = yield* Effect.context<
FileSystem.FileSystem | DesktopEnvironment.DesktopEnvironment
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopClerk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function createDesktopClerkBridge(stateDir: string, isDevelopment: boolean) {
});
}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const electronApp = yield* ElectronApp.ElectronApp;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopConnectionCatalogStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ const migrateSavedEnvironmentRecords = Effect.fn(
};
});

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopLifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function quitFromSignal(
);
}

/** @public Service construction is part of the module API alongside layer. */
export const make = DesktopLifecycle.of({
relaunch: Effect.fn("desktop.lifecycle.relaunch")(function* (reason) {
const electronApp = yield* ElectronApp.ElectronApp;
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/app/DesktopLinuxUrlHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { makeComponentLogger } from "./DesktopObservability.ts";
// our own handler entry pointing at the current AppImage and claim the
// scheme default via xdg-mime, exactly what the file manager's "set as
// default" checkbox would record in mimeapps.list.
export const URL_HANDLER_DESKTOP_ENTRY_NAME = "t3code-url-handler.desktop";
const URL_HANDLER_DESKTOP_ENTRY_NAME = "t3code-url-handler.desktop";

const { logInfo, logWarning } = makeComponentLogger("desktop-linux-url-handler");

Expand Down Expand Up @@ -92,6 +92,7 @@ export class DesktopLinuxUrlHandler extends Context.Service<
}
>()("@t3tools/desktop/app/DesktopLinuxUrlHandler") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/app/DesktopPreReadyPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class DesktopPreReadyElectronOptions extends Context.Service<
}
>()("@t3tools/desktop/app/DesktopPreReadyPlatform/DesktopPreReadyElectronOptions") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;
return yield* Effect.sync((): DesktopPreReadyElectronOptions["Service"] => {
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/backend/DesktopBackendConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ const resolveWslStartConfig = Effect.fn("desktop.backendConfiguration.resolveWsl
} satisfies DesktopBackendManager.DesktopBackendStartConfig;
});

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/backend/DesktopLocalEnvironmentAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class DesktopLocalEnvironmentAuth extends Context.Service<
}
>()("@t3tools/desktop/backend/DesktopLocalEnvironmentAuth") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const pool = yield* DesktopBackendPool.DesktopBackendPool;
const httpClient = yield* HttpClient.HttpClient;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/backend/DesktopNetworkInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class DesktopNetworkInterfaces extends Context.Service<
}
>()("@t3tools/desktop/backend/DesktopNetworkInterfaces") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;
return DesktopNetworkInterfaces.of({
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/backend/DesktopServerExposure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { resolveTailscaleAdvertisedEndpoints } from "./tailscaleEndpointProvider

const TAILSCALE_STATUS_CACHE_TTL = Duration.seconds(60);

export const DESKTOP_LOOPBACK_HOST = "127.0.0.1";
const DESKTOP_LOOPBACK_HOST = "127.0.0.1";
const DESKTOP_LAN_BIND_HOST = "0.0.0.0";

interface ResolvedDesktopServerExposure {
Expand Down Expand Up @@ -411,6 +411,7 @@ const requiresBackendRelaunch = (previous: RuntimeState, next: RuntimeState): bo
previous.bindHost !== next.bindHost ||
previous.localHttpUrl !== next.localHttpUrl;

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const config = yield* DesktopConfig.DesktopConfig;
const networkInterfaces = yield* DesktopNetworkInterfaces.DesktopNetworkInterfaces;
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/backend/tailscaleEndpointProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawne

import type { NetworkInterfaces } from "./DesktopNetworkInterfaces.ts";

export { isTailscaleIpv4Address, parseTailscaleMagicDnsName } from "@t3tools/tailscale";
export { parseTailscaleMagicDnsName } from "@t3tools/tailscale";

const TAILSCALE_ENDPOINT_PROVIDER: AdvertisedEndpointProvider = {
id: "tailscale",
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const addScopedAppListener = <Args extends ReadonlyArray<unknown>>(
}),
).pipe(Effect.asVoid);

/** @public Service construction is part of the module API alongside layer. */
export const make = ElectronApp.of({
metadata: Effect.gen(function* () {
const appVersion = yield* Effect.try({
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class ElectronDialog extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronDialog") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = ElectronDialog.of({
pickFolder: Effect.fn("desktop.electron.dialog.pickFolder")(function* (input) {
const ownerWindowId = Option.match(input.owner, {
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const normalizePosition = (
Option.map(({ x, y }) => ({ x: Math.floor(x * zoomFactor), y: Math.floor(y * zoomFactor) })),
);

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;
let destructiveMenuIconCache: Option.Option<Electron.NativeImage> | undefined;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronPowerMonitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const onSpeedLimitChange: ElectronPowerMonitor["Service"]["onSpeedLimitChange"]
).pipe(Effect.asVoid);
};

/** @public Service construction is part of the module API alongside layer. */
export const make = ElectronPowerMonitor.of({
isOnBatteryPower: Effect.sync(() => Electron.powerMonitor.isOnBatteryPower()),
getSystemIdleTime: Effect.sync(() => Electron.powerMonitor.getSystemIdleTime()),
Expand Down
9 changes: 5 additions & 4 deletions apps/desktop/src/electron/ElectronProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import * as Scope from "effect/Scope";
import * as Electron from "electron";

export const DESKTOP_HOST = "app";
export const DESKTOP_PRODUCTION_SCHEME = "t3code";
export const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";
const DESKTOP_PRODUCTION_SCHEME = "t3code";
const DESKTOP_DEVELOPMENT_SCHEME = "t3code-dev";

export function getDesktopScheme(isDevelopment: boolean): string {
return isDevelopment ? DESKTOP_DEVELOPMENT_SCHEME : DESKTOP_PRODUCTION_SCHEME;
}

export function getDesktopOrigin(isDevelopment: boolean): string {
function getDesktopOrigin(isDevelopment: boolean): string {
return `${getDesktopScheme(isDevelopment)}://${DESKTOP_HOST}`;
}

Expand Down Expand Up @@ -109,7 +109,7 @@ function withContentSecurityPolicy(response: Response, policy: string): Response
/**
* Must run synchronously during process bootstrap, before Electron emits `ready`.
*/
export function registerDesktopSchemePrivilegesSync(): void {
function registerDesktopSchemePrivilegesSync(): void {
Electron.protocol.registerSchemesAsPrivileged([
{
scheme: DESKTOP_PRODUCTION_SCHEME,
Expand Down Expand Up @@ -205,6 +205,7 @@ async function fetchWithTransientRetry(url: string, init: RequestInit): Promise<
throw lastError;
}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const registered = yield* Ref.make(false);

Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/electron/ElectronSafeStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const ElectronSafeStorageError = Schema.Union([
ElectronSafeStorageDecryptError,
]);
export type ElectronSafeStorageError = typeof ElectronSafeStorageError.Type;
export const isElectronSafeStorageError = Schema.is(ElectronSafeStorageError);

export class ElectronSafeStorage extends Context.Service<
ElectronSafeStorage,
Expand All @@ -66,6 +65,7 @@ export class ElectronSafeStorage extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronSafeStorage") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;

Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export class ElectronShell extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronShell") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = ElectronShell.of({
openExternal: (rawUrl) =>
Option.match(parseSafeExternalUrl(rawUrl), {
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class ElectronTheme extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronTheme") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = ElectronTheme.of({
shouldUseDarkColors: Effect.sync(() => Electron.nativeTheme.shouldUseDarkColors),
setSource: (theme) =>
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class ElectronUpdater extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronUpdater") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = ElectronUpdater.of({
setFeedURL: (options) =>
Effect.suspend(() => {
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/electron/ElectronWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class ElectronWindow extends Context.Service<
}
>()("@t3tools/desktop/electron/ElectronWindow") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const platform = yield* HostProcessPlatform;
const mainWindowRef = yield* Ref.make<Option.Option<Electron.BrowserWindow>>(Option.none());
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/preview/BrowserImport/BrowserImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export const writeCookies = Effect.fn("BrowserImport.writeCookies")(function* (
return { imported, skipped, skippedDomains: [...skippedDomains].slice(0, 20) };
});

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* BrowserImportMake() {
const browserSession = yield* BrowserSession.BrowserSession;
const platform = yield* HostProcessPlatform;
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/preview/BrowserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const encodeScopeForDigest = (scope: string): Uint8Array =>
),
);

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* BrowserSessionMake() {
const crypto = yield* Crypto.Crypto;
const sessionsRef = yield* SynchronizedRef.make<ReadonlyMap<string, Session>>(new Map());
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/preview/FaviconCapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { FAVICON_DATA_URL_MAX_LENGTH } from "@t3tools/contracts";

export const MAX_FAVICON_RESPONSE_BYTES = 100_000;
export const MAX_FAVICON_CANDIDATES = 8;
export const MAX_FAVICON_HTTP_URL_LENGTH = 2_048;
const MAX_FAVICON_HTTP_URL_LENGTH = 2_048;

const MAX_FAVICON_CANDIDATE_INPUT_UNITS = 262_144;
const MIN_FAVICON_CANDIDATE_INPUT_UNITS = 256;
Expand Down
14 changes: 6 additions & 8 deletions apps/desktop/src/preview/Manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const DEFAULT_ANNOTATION_THEME: DesktopPreviewAnnotationTheme = {
fontMono: "ui-monospace, monospace",
};

export const buildPreviewPictureInPictureDataUrl = (): string => {
const buildPreviewPictureInPictureDataUrl = (): string => {
const html = `<!doctype html>
<html>
<head>
Expand Down Expand Up @@ -4271,7 +4271,7 @@ export class PreviewOperationError extends Schema.TaggedErrorClass<PreviewOperat
}
}

export const isPreviewOperationError = Schema.is(PreviewOperationError);
const isPreviewOperationError = Schema.is(PreviewOperationError);

export class PreviewArtifactPathOutsideDirectoryError extends Schema.TaggedErrorClass<PreviewArtifactPathOutsideDirectoryError>()(
"PreviewArtifactPathOutsideDirectoryError",
Expand Down Expand Up @@ -4472,14 +4472,11 @@ export const PreviewManagerError = Schema.Union([
]);
export type PreviewManagerError = typeof PreviewManagerError.Type;

export const isPreviewManagerError = Schema.is(PreviewManagerError);
export const isPreviewAutomationControlInterruptedError = Schema.is(
const isPreviewAutomationControlInterruptedError = Schema.is(
PreviewAutomationControlInterruptedError,
);
export const isPreviewAutomationEvaluationError = Schema.is(PreviewAutomationEvaluationError);
export const isPreviewAutomationInvalidSelectorError = Schema.is(
PreviewAutomationInvalidSelectorError,
);
const isPreviewAutomationEvaluationError = Schema.is(PreviewAutomationEvaluationError);
const isPreviewAutomationInvalidSelectorError = Schema.is(PreviewAutomationInvalidSelectorError);

export class PreviewManager extends Context.Service<
PreviewManager,
Expand Down Expand Up @@ -4592,6 +4589,7 @@ export class PreviewManager extends Context.Service<
}
>()("@t3tools/desktop/preview/Manager/PreviewManager") {}

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* PreviewManagerMake() {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const browserSession = yield* BrowserSession.BrowserSession;
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/src/settings/DesktopAppSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export interface DesktopSettingsChange {
readonly changed: boolean;
}

export const DEFAULT_TAILSCALE_SERVE_PORT = 443;
const DEFAULT_TAILSCALE_SERVE_PORT = 443;
const MIN_MAIN_WINDOW_SIZE = {
width: 840,
height: 620,
Expand Down Expand Up @@ -450,6 +450,7 @@ const writeSettings = Effect.fn("desktop.settings.writeSettings")(function* (inp
);
});

/** @public Service construction is part of the module API alongside layer. */
export const make = Effect.gen(function* () {
const environment = yield* DesktopEnvironment.DesktopEnvironment;
const fileSystem = yield* FileSystem.FileSystem;
Expand Down
Loading
Loading