Skip to content

Commit b20a777

Browse files
committed
lint
1 parent 68cdbe1 commit b20a777

11 files changed

Lines changed: 56 additions & 15 deletions

File tree

apps/code/src/main/di/container.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { ElectronAppMetrics } from "../platform-adapters/electron-app-metrics";
1616
import { ElectronBundledResources } from "../platform-adapters/electron-bundled-resources";
1717
import { ElectronClipboard } from "../platform-adapters/electron-clipboard";
1818
import { ElectronContextMenu } from "../platform-adapters/electron-context-menu";
19+
import { ElectronDevHostActions } from "../platform-adapters/electron-dev-host-actions";
1920
import { ElectronDialog } from "../platform-adapters/electron-dialog";
2021
import { ElectronFileIcon } from "../platform-adapters/electron-file-icon";
2122
import { ElectronImageProcessor } from "../platform-adapters/electron-image-processor";
@@ -110,6 +111,7 @@ container.bind(MAIN_TOKENS.ContextMenu).to(ElectronContextMenu);
110111
container.bind(MAIN_TOKENS.BundledResources).to(ElectronBundledResources);
111112
container.bind(MAIN_TOKENS.ImageProcessor).to(ElectronImageProcessor);
112113
container.bind(MAIN_TOKENS.AppMetrics).to(ElectronAppMetrics);
114+
container.bind(MAIN_TOKENS.DevHostActions).to(ElectronDevHostActions);
113115

114116
container.bind(MAIN_TOKENS.DatabaseService).to(DatabaseService);
115117
container

apps/code/src/main/di/tokens.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const MAIN_TOKENS = Object.freeze({
2222
BundledResources: Symbol.for("Platform.BundledResources"),
2323
ImageProcessor: Symbol.for("Platform.ImageProcessor"),
2424
AppMetrics: Symbol.for("Platform.AppMetrics"),
25+
DevHostActions: Symbol.for("Platform.DevHostActions"),
2526

2627
// Stores
2728
SettingsStore: Symbol.for("Main.SettingsStore"),
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import type { IDevHostActions } from "@posthog/platform/dev-host-actions";
2+
import { app, BrowserWindow, shell } from "electron";
3+
import { injectable } from "inversify";
4+
5+
@injectable()
6+
export class ElectronDevHostActions implements IDevHostActions {
7+
public async openPath(path: string): Promise<void> {
8+
await shell.openPath(path);
9+
}
10+
11+
public reloadAllWindows(): void {
12+
for (const window of BrowserWindow.getAllWindows()) {
13+
window.webContents.reload();
14+
}
15+
}
16+
17+
public relaunch(): void {
18+
app.relaunch();
19+
app.exit(0);
20+
}
21+
22+
public crash(): void {
23+
process.crash();
24+
}
25+
}

apps/code/src/main/services/dev-actions/service.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { app, BrowserWindow, shell } from "electron";
1+
import type { IDevHostActions } from "@posthog/platform/dev-host-actions";
22
import { inject, injectable } from "inversify";
33
import { MAIN_TOKENS } from "../../di/tokens";
44
import { getUserDataDir } from "../../utils/env";
@@ -20,33 +20,32 @@ export class DevActionsService extends TypedEventEmitter<DevActionsEvents> {
2020
constructor(
2121
@inject(MAIN_TOKENS.DevNetworkService)
2222
private readonly network: DevNetworkService,
23+
@inject(MAIN_TOKENS.DevHostActions)
24+
private readonly host: IDevHostActions,
2325
) {
2426
super();
2527
}
2628

2729
async openUserDataDir(): Promise<void> {
28-
await shell.openPath(getUserDataDir());
30+
await this.host.openPath(getUserDataDir());
2931
}
3032

3133
async openLogFile(): Promise<void> {
32-
await shell.openPath(getLogFilePath());
34+
await this.host.openPath(getLogFilePath());
3335
}
3436

3537
reloadRenderer(): void {
36-
for (const window of BrowserWindow.getAllWindows()) {
37-
window.webContents.reload();
38-
}
38+
this.host.reloadAllWindows();
3939
}
4040

4141
restartMain(): void {
4242
log.warn("Restarting main process from dev toolbar");
43-
app.relaunch();
44-
app.exit(0);
43+
this.host.relaunch();
4544
}
4645

4746
crashMain(): void {
4847
log.warn("Crashing main process from dev toolbar");
49-
process.crash();
48+
this.host.crash();
5049
}
5150

5251
triggerToast(variant: "info" | "error", message: string): DevToast {

apps/code/src/main/services/dev-network/service.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,13 @@ export class DevNetworkService extends TypedEventEmitter<DevNetworkEvents> {
149149
}
150150
};
151151

152+
const preconnect = (
153+
original as unknown as {
154+
preconnect?: (...args: unknown[]) => unknown;
155+
}
156+
).preconnect;
152157
Object.defineProperty(wrapped, "preconnect", {
153-
value: original.preconnect?.bind(original) ?? (() => undefined),
158+
value: preconnect?.bind(original) ?? (() => undefined),
154159
});
155160

156161
globalThis.fetch = wrapped as typeof fetch;

apps/code/src/renderer/features/dev-toolbar/components/DevToolbar.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,7 @@ function ResizeHandle({
291291

292292
return (
293293
<div
294-
role="separator"
295-
aria-orientation="horizontal"
296-
aria-label="Resize panel"
294+
aria-hidden="true"
297295
onPointerDown={handlePointerDown}
298296
onPointerMove={handlePointerMove}
299297
onPointerUp={handlePointerUp}

apps/code/src/renderer/features/dev-toolbar/components/LogsPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function LogsPanel({ enabled }: LogsPanelProps) {
8989
placeholder="Filter message or scope..."
9090
value={filter}
9191
onChange={(e) => setFilter(e.target.value)}
92-
className="flex-1 min-w-[180px]"
92+
className="min-w-[180px] flex-1"
9393
/>
9494
<Select.Root
9595
size="1"

apps/code/src/renderer/features/dev-toolbar/components/NetworkPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function NetworkPanel({ enabled }: NetworkPanelProps) {
9696
placeholder="Filter url, host, status..."
9797
value={filter}
9898
onChange={(e) => setFilter(e.target.value)}
99-
className="flex-1 min-w-[180px]"
99+
className="min-w-[180px] flex-1"
100100
/>
101101
<Flex align="center" gap="1">
102102
<Switch

packages/platform/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
"./app-metrics": {
6868
"types": "./dist/app-metrics.d.ts",
6969
"import": "./dist/app-metrics.js"
70+
},
71+
"./dev-host-actions": {
72+
"types": "./dist/dev-host-actions.d.ts",
73+
"import": "./dist/dev-host-actions.js"
7074
}
7175
},
7276
"scripts": {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export interface IDevHostActions {
2+
openPath(path: string): Promise<void>;
3+
reloadAllWindows(): void;
4+
relaunch(): void;
5+
crash(): void;
6+
}

0 commit comments

Comments
 (0)