Skip to content

Commit 68c7356

Browse files
committed
It would be funny to watch me lose my sanity over time
1 parent 1c9f4cd commit 68c7356

16 files changed

Lines changed: 150 additions & 142 deletions

File tree

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,8 @@
819819
"build:web:esbuild": "node ./scripts/esbuild.mjs --mode web",
820820
"build:desktop:tsc": "tsc --noEmit --project tsconfig.app.json",
821821
"build:desktop:esbuild": "node ./scripts/esbuild.mjs --mode desktop",
822+
"build:webview:tsc": "tsc --noEmit --project tsconfig.webview.json",
823+
"build:webview:esbuild": "node ./scripts/esbuild.mjs --mode webview",
822824
"watch:web": "npm-run-all -p watch:web:* watch:webview:*",
823825
"watch:desktop": "npm-run-all -p watch:desktop:* watch:webview:*",
824826
"watch:web:esbuild": "node ./scripts/esbuild.mjs --watch --mode web",

src/config.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import * as vscode from 'vscode';
33
import { NEURO } from '@/constants';
44
import { logOutput } from '@/utils/misc';
55
import { getAction } from '@/rce';
6+
import { PermissionLevel } from '@typing/actions';
7+
8+
export { PermissionLevel }; // re-exporting for the sake of compat I'm done with this
69

710
//#region Types
811

@@ -410,13 +413,6 @@ export async function checkDeprecatedSettings(version: string) {
410413
}
411414
}
412415

413-
/** Permission level enums */
414-
export const enum PermissionLevel {
415-
OFF = 0,
416-
COPILOT = 1,
417-
AUTOPILOT = 2,
418-
}
419-
420416
export function permissionLevelToString(level: PermissionLevel): string {
421417
switch (level) {
422418
case PermissionLevel.AUTOPILOT:

src/events/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Disposable, EventEmitter } from 'vscode';
22
import { ActionData } from 'neuro-game-sdk';
3+
import type { ActionStatus } from '@typing/actions';
34

4-
export type ActionStatus = 'pending' | 'success' | 'failure' | 'denied' | 'exception' | 'timeout' | 'schema' | 'cancelled';
5+
export { ActionStatus }; // re-exporting for the sake of compat I'm done with this
56

67
export interface ActionsEventData {
78
readonly action: string;

src/types/actions.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** Permission level enums */
2+
export const enum PermissionLevel {
3+
OFF = 0,
4+
COPILOT = 1,
5+
AUTOPILOT = 2,
6+
}
7+
8+
export type ActionStatus = 'pending' | 'success' | 'failure' | 'denied' | 'exception' | 'timeout' | 'schema' | 'cancelled';

src/types/views/actions.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
export type SettingsContext = 'user' | 'workspace';
2+
3+
export interface ActionNode {
4+
id: string;
5+
label: string;
6+
category: string;
7+
description?: string;
8+
permissionLevel: PermissionLevel;
9+
modifiedInCurrentContext: boolean;
10+
modifiedExternally: boolean;
11+
isRegistered: boolean;
12+
}
13+
14+
export type ActionsViewProviderMessage = {
15+
type: 'providerToggledPermission';
16+
actionId: string;
17+
newPermissionLevel: PermissionLevel;
18+
} | {
19+
type: 'refreshActions';
20+
actions: ActionNode[];
21+
};
22+
23+
export type ActionsViewMessage = {
24+
type: 'viewToggledPermissions';
25+
actionIds: string[];
26+
newPermissionLevel: PermissionLevel;
27+
} | {
28+
type: 'error';
29+
message: string;
30+
} | {
31+
type: 'requestInitialization';
32+
currentContext: SettingsContext;
33+
} | {
34+
type: 'changeContext';
35+
newContext: SettingsContext;
36+
};

src/types/views/execute.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export interface ExecuteResult {
2+
status: ActionStatus;
3+
action: string;
4+
message?: string;
5+
executionId: string;
6+
sessionId: string;
7+
}
8+
9+
export interface ExecutionHistoryItem extends ExecuteResult {
10+
timestamp: number;
11+
}
12+
13+
export type ExecuteViewProviderMessage = {
14+
type: 'executionResult';
15+
result: ExecutionHistoryItem;
16+
} | {
17+
type: 'updateStatus';
18+
executionId: string;
19+
status: ActionStatus;
20+
message?: string;
21+
} | {
22+
type: 'currentSession';
23+
sessionId: string;
24+
} | {
25+
type: 'addHistoryItem';
26+
item: ExecutionHistoryItem;
27+
};

src/types/views/images.d.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export interface ImageData {
2+
name: string;
3+
path: string;
4+
credits: string;
5+
set: {
6+
name: string;
7+
description: string;
8+
};
9+
}
10+
11+
export type ImagesViewProviderMessage = {
12+
type: 'newImage';
13+
image: ImageData;
14+
sets: Record<string, ImageSet>;
15+
} | {
16+
type: 'searchResult';
17+
names: string[];
18+
} | {
19+
type: 'setList';
20+
sets: string[];
21+
};
22+
23+
export type ImagesViewMessage = {
24+
type: 'randomImage' | 'randomSet' | 'searchSet';
25+
} | {
26+
type: 'searchImage' | 'switchSet' | 'switchImage';
27+
name: string;
28+
} | {
29+
type: 'nextImage' | 'previousImage' | 'randomImageInSet';
30+
current: string;
31+
} | {
32+
type: 'viewReady';
33+
} | {
34+
type: 'updateSets';
35+
};
36+
37+
interface GallerySet {
38+
title: string;
39+
rotation: boolean;
40+
description: string;
41+
images: {
42+
name: string;
43+
filePath: string;
44+
attributions: string;
45+
}[];
46+
}
47+
48+
interface GalleryConfig {
49+
version: number;
50+
sets: Record<string, GallerySet>;
51+
}
52+
53+
export interface ImageSet {
54+
description: string;
55+
images: Omit<ImageData, 'set'>[];
56+
}

src/types/views/index.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface Message {
2+
type: string;
3+
}

src/views/actions.ts

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,7 @@ import { PermissionLevel, setPermissions } from '@/config';
33
import { BaseWebviewViewProvider } from './base';
44
import { getExtendedActionsInfo } from '@/rce';
55
import { toTitleCase } from '@/utils/misc';
6-
7-
export type SettingsContext = 'user' | 'workspace';
8-
9-
export interface ActionNode {
10-
id: string;
11-
label: string;
12-
category: string;
13-
description?: string;
14-
permissionLevel: PermissionLevel;
15-
modifiedInCurrentContext: boolean;
16-
modifiedExternally: boolean;
17-
isRegistered: boolean;
18-
}
19-
20-
export type ActionsViewProviderMessage = {
21-
type: 'providerToggledPermission';
22-
actionId: string;
23-
newPermissionLevel: PermissionLevel;
24-
} | {
25-
type: 'refreshActions';
26-
actions: ActionNode[];
27-
};
28-
29-
export type ActionsViewMessage = {
30-
type: 'viewToggledPermissions';
31-
actionIds: string[];
32-
newPermissionLevel: PermissionLevel;
33-
} | {
34-
type: 'error';
35-
message: string;
36-
} | {
37-
type: 'requestInitialization';
38-
currentContext: SettingsContext;
39-
} | {
40-
type: 'changeContext';
41-
newContext: SettingsContext;
42-
};
6+
import type { ActionsViewMessage, ActionsViewProviderMessage, SettingsContext, ActionNode } from '@typing/views/actions';
437

448
export class ActionsViewProvider extends BaseWebviewViewProvider<ActionsViewMessage, ActionsViewProviderMessage> {
459
public static readonly viewId = 'neuropilot.actionsView';

src/views/base.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import * as vscode from 'vscode';
22
import { NEURO } from '../constants';
33
import { formatString } from '@/utils/misc';
4-
5-
export interface Message {
6-
type: string;
7-
}
4+
import type { Message } from '@typing/views';
85

96
export abstract class BaseWebviewViewProvider<TViewMessage extends Message, TProviderMessage extends Message> implements vscode.WebviewViewProvider {
107
/** defaults to test view, override with its own dedicated view when extending this */

0 commit comments

Comments
 (0)