Skip to content

Commit b59b38c

Browse files
committed
v1.7.3
1 parent 1448592 commit b59b38c

File tree

13 files changed

+85
-51
lines changed

13 files changed

+85
-51
lines changed

src/vscode-windhawk-ui/apps/vscode-windhawk-ui/src/app/panel/ModDetails.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
useGetModSourceData,
77
useGetRepositoryModSourceData,
88
} from '../webviewIPC';
9-
import { ModConfig, ModMetadata, RepositoryDetails } from '../webviewIPCMessages';
9+
import { ModConfig, ModMetadata, RepositoryDetails, InitialSettings } from '../webviewIPCMessages';
1010
import ModDetailsAdvanced from './ModDetailsAdvanced';
1111
import ModDetailsChangelog from './ModDetailsChangelog';
1212
import ModDetailsHeader, { ModStatus } from './ModDetailsHeader';
@@ -61,7 +61,7 @@ type ModSourceData = {
6161
source: string | null;
6262
metadata: ModMetadata | null;
6363
readme: string | null;
64-
initialSettings: any;
64+
initialSettings: InitialSettings | null;
6565
};
6666

6767
type TabKey = 'details' | 'settings' | 'code' | 'changelog' | 'advanced' | 'changes';

src/vscode-windhawk-ui/apps/vscode-windhawk-ui/src/app/panel/ModDetailsSettings.tsx

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ import styled from 'styled-components';
1111
import { useEventListener } from 'usehooks-ts';
1212
import { DropdownModal, dropdownModalDismissed, InputNumberWithContextMenu, InputWithContextMenu, SelectModal } from '../components/InputWithContextMenu';
1313
import { useGetModSettings, useSetModSettings } from '../webviewIPC';
14+
import {
15+
InitialSettings,
16+
InitialSettingItem,
17+
InitialSettingsValue,
18+
InitialSettingsArrayValue,
19+
} from '../webviewIPCMessages';
1420
import { mockModSettings } from './mockData';
1521

1622
// Configure Monaco Editor to use local npm package instead of CDN.
@@ -114,28 +120,10 @@ interface NestedSettings {
114120
[key: string]: NestedValue;
115121
}
116122

117-
type InitialSettings = InitialSettingItem[];
118-
119-
type InitialSettingItem = {
120-
key: string;
121-
value: InitialSettingsValue;
122-
name?: string;
123-
description?: string;
124-
} & InitialSettingItemExtra;
125-
126123
type InitialSettingItemExtra = {
127124
options?: Record<string, string>[];
128125
};
129126

130-
type InitialSettingsValue =
131-
| boolean
132-
| number
133-
| string
134-
| InitialSettings
135-
| InitialSettingsArrayValue;
136-
137-
type InitialSettingsArrayValue = number[] | string[] | InitialSettings[];
138-
139127
enum SettingType {
140128
Boolean = 'boolean',
141129
Number = 'number',

src/vscode-windhawk-ui/apps/vscode-windhawk-ui/src/app/panel/mockData.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ More text...`,
190190
name: 'Mock Setting Dropdown Name',
191191
description: 'Mock setting dropdown description',
192192
options: [
193-
{ a: 'a option' },
194-
{ b: 'b option' },
195-
{ c: 'c option' },
196-
{ d: 'd option' },
197-
{ e: 'e option' },
198-
{ f: 'f option' },
199-
{ g: 'g option' },
200-
{ h: 'h option' },
201-
{ i: 'i option' },
193+
{ a: 'a option' } as Record<string, string>,
194+
{ b: 'b option' } as Record<string, string>,
195+
{ c: 'c option' } as Record<string, string>,
196+
{ d: 'd option' } as Record<string, string>,
197+
{ e: 'e option' } as Record<string, string>,
198+
{ f: 'f option' } as Record<string, string>,
199+
{ g: 'g option' } as Record<string, string>,
200+
{ h: 'h option' } as Record<string, string>,
201+
{ i: 'i option' } as Record<string, string>,
202202
],
203203
},
204204
{

src/vscode-windhawk-ui/apps/vscode-windhawk-ui/src/app/webviewIPCMessages.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,25 @@ export type AppUISettings = {
125125
safeMode: boolean;
126126
};
127127

128+
export type InitialSettingsValue =
129+
| boolean
130+
| number
131+
| string
132+
| InitialSettings
133+
| InitialSettingsArrayValue;
134+
135+
export type InitialSettingsArrayValue = number[] | string[] | InitialSettings[];
136+
137+
export type InitialSettingItem = {
138+
key: string;
139+
value: InitialSettingsValue;
140+
name?: string;
141+
description?: string;
142+
options?: Record<string, string>[];
143+
};
144+
145+
export type InitialSettings = InitialSettingItem[];
146+
128147
////////////////////////////////////////////////////////////
129148
// Messages.
130149

@@ -234,7 +253,7 @@ export type GetModSourceDataReplyData = {
234253
source: string | null;
235254
metadata: ModMetadata | null;
236255
readme: string | null;
237-
initialSettings: Record<string, any>[] | null;
256+
initialSettings: InitialSettings | null;
238257
};
239258
};
240259

@@ -250,7 +269,7 @@ export type GetRepositoryModSourceDataReplyData = {
250269
source: string | null;
251270
metadata: ModMetadata | null;
252271
readme: string | null;
253-
initialSettings: Record<string, any>[] | null;
272+
initialSettings: InitialSettings | null;
254273
};
255274
};
256275

@@ -286,12 +305,12 @@ export type GetModSettingsData = {
286305

287306
export type GetModSettingsReplyData = {
288307
modId: string;
289-
settings: Record<string, any>;
308+
settings: Record<string, string | number>;
290309
};
291310

292311
export type SetModSettingsData = {
293312
modId: string;
294-
settings: Record<string, any>;
313+
settings: Record<string, string | number>;
295314
};
296315

297316
export type SetModSettingsReplyData = {

src/vscode-windhawk-ui/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vscode-windhawk-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vscode-windhawk-ui-nx",
3-
"version": "1.7.2",
3+
"version": "1.7.3",
44
"scripts": {
55
"start": "nx serve",
66
"watch": "nx build --configuration=development --watch",

src/vscode-windhawk/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/vscode-windhawk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "windhawk",
33
"displayName": "Windhawk",
44
"description": "Part of the Windhawk Windows customization tool",
5-
"version": "1.7.2",
5+
"version": "1.7.3",
66
"icon": "assets/main-icon.png",
77
"publisher": "m417z",
88
"engines": {

src/vscode-windhawk/src/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import {
3838
GetModVersionsReplyData,
3939
GetRepositoryModSourceDataData,
4040
GetRepositoryModsReplyData,
41+
InitialSettings,
4142
InstallModData,
4243
InstallModReplyData,
4344
ModConfig,
@@ -537,7 +538,7 @@ class WindhawkPanel {
537538

538539
let metadata: ModMetadata | null = null;
539540
let readme: string | null = null;
540-
let initialSettings: Record<string, any>[] | null = null;
541+
let initialSettings: InitialSettings | null = null;
541542
if (source) {
542543
try {
543544
metadata = this._utils.modSource.extractMetadata(source, this._language);
@@ -594,7 +595,7 @@ class WindhawkPanel {
594595

595596
let metadata: ModMetadata | null = null;
596597
let readme: string | null = null;
597-
let initialSettings: Record<string, any>[] | null = null;
598+
let initialSettings: InitialSettings | null = null;
598599
if (source) {
599600
try {
600601
metadata = this._utils.modSource.extractMetadata(source, this._language);

src/vscode-windhawk/src/utils/modSourceUtils.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as fs from 'fs';
22
import * as yaml from 'js-yaml';
33
import * as jsonschema from 'jsonschema';
44
import * as path from 'path';
5+
import { InitialSettingItem, InitialSettings, InitialSettingsValue } from '../webviewIPCMessages';
56

67
const modMetadataParams = {
78
singleValue: [
@@ -371,12 +372,12 @@ export default class ModSourceUtils {
371372
return settings as Record<string, any>[];
372373
}
373374

374-
public extractInitialSettings(modSource: string, language: string) {
375-
const parseSettings = (settings: Record<string, any>[]) => {
375+
public extractInitialSettings(modSource: string, language: string): InitialSettings | null {
376+
const parseSettings = (settings: Record<string, any>[]): InitialSettings => {
376377
return settings.map(parseSettingsValueAnnotated);
377378
};
378379

379-
const parseSettingsValueAnnotated = (value: Record<string, any>) => {
380+
const parseSettingsValueAnnotated = (value: Record<string, any>): InitialSettingItem => {
380381
const actualParameters = Object.keys(value).filter(x => !x.startsWith('$'));
381382
if (actualParameters.length === 0) {
382383
throw new Error('Missing settings key');
@@ -407,10 +408,10 @@ export default class ModSourceUtils {
407408
result.key = actualParameter;
408409
result.value = parseSettingsValue(value[actualParameter]);
409410

410-
return result;
411+
return result as InitialSettingItem;
411412
};
412413

413-
const parseSettingsValue = (value: any): any => {
414+
const parseSettingsValue = (value: any): InitialSettingsValue => {
414415
if (typeof value === 'boolean' ||
415416
typeof value === 'number' ||
416417
typeof value === 'string' ||

0 commit comments

Comments
 (0)