-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
refactor: improved types (#189)
- v3.9.0
- v3.8.2
- v3.8.1
- v3.8.0
- v3.7.1
- v3.7.0
- v3.6.0
- v3.5.0
- v3.4.0
- catppuccin-vsc-v3.16.0
- catppuccin-vsc-v3.15.2
- catppuccin-vsc-v3.15.1
- catppuccin-vsc-v3.15.0
- catppuccin-vsc-v3.14.0
- catppuccin-vsc-v3.13.0
- catppuccin-vsc-v3.12.0
- catppuccin-vsc-v3.11.2
- catppuccin-vsc-v3.11.1
- catppuccin-vsc-v3.11.0
- catppuccin-vsc-v3.10.1
- catppuccin-vsc-v3.10.0
- catppuccin-vsc-pack-v1.0.2
- catppuccin-vsc-pack-v1.0.1
- catppuccin-vsc-pack-v1.0.0
- @catppuccin/vscode-v3.16.0
- @catppuccin/vscode-v3.15.2
- @catppuccin/vscode-v3.15.1
- @catppuccin/vscode-v3.15.0
- @catppuccin/vscode-v3.14.0
- @catppuccin/vscode-v3.13.0
- @catppuccin/vscode-v3.12.0
- @catppuccin/vscode-v3.11.2
- @catppuccin/vscode-v3.11.1
- @catppuccin/vscode-v3.11.0
- @catppuccin/vscode-v3.10.1
- @catppuccin/vscode-v3.10.0
1 parent
4e05650
commit 1adf178
Showing
8 changed files
with
224 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,78 @@ | ||
import * as path from "path"; | ||
import { writeFileSync } from "fs"; | ||
import { JSONSchema, compile } from "json-schema-to-typescript"; | ||
import { compile, JSONSchema } from "json-schema-to-typescript"; | ||
import fetch from "node-fetch"; | ||
|
||
const vscodeSchemasRoot = | ||
"https://raw.githubusercontent.com/wraith13/vscode-schemas/master/en/latest/schemas/"; | ||
const tag = process.argv[2] ?? "latest"; | ||
const vscodeSchemasRoot = `https://raw.githubusercontent.com/wraith13/vscode-schemas/master/en/${tag}/schemas/`; | ||
|
||
const bannerComment = `/* eslint-disable */ | ||
/** | ||
* This file was automatically generated. | ||
* DO NOT MODIFY IT BY HAND. | ||
* Instead, run \`yarn run updateVSCtypes\` to regenerate this file. | ||
*/`; | ||
|
||
const mappings = [ | ||
{ | ||
schema: "token-styling.json", | ||
schema: vscodeSchemasRoot + "token-styling.json", | ||
name: "SemanticTokens", | ||
fname: "token-styling.d.ts", | ||
kind: "jsonschema", | ||
}, | ||
{ | ||
schema: "textmate-colors.json", | ||
schema: vscodeSchemasRoot + "textmate-colors.json", | ||
name: "TextmateColors", | ||
fname: "textmate-colors.d.ts", | ||
kind: "jsonschema", | ||
}, | ||
{ | ||
schema: "workbench-colors.json", | ||
schema: vscodeSchemasRoot + "workbench-colors.json", | ||
name: "WorkbenchColors", | ||
fname: "workbench-colors.d.ts", | ||
kind: "jsonschema", | ||
}, | ||
{ | ||
schema: | ||
"https://raw.githubusercontent.com/usernamehw/vscode-error-lens/v3.13.0/package.json", | ||
name: "ErrorLensColors", | ||
fname: "errorlens.d.ts", | ||
kind: "extension-packagejson", | ||
}, | ||
]; | ||
|
||
for (const { schema, name, fname } of mappings) { | ||
fetch(vscodeSchemasRoot + schema) | ||
for (const { schema, name, fname, kind } of mappings) { | ||
fetch(schema) | ||
.then((data) => data.json()) | ||
.then((data) => { | ||
compile(data as JSONSchema, name, { | ||
additionalProperties: false, | ||
}).then((typeDefs) => { | ||
const fp = path.join(__dirname, `../types/${fname}`); | ||
writeFileSync(fp, typeDefs, "utf-8"); | ||
}); | ||
switch (kind) { | ||
case "jsonschema": | ||
return compile(data as JSONSchema, name, { | ||
additionalProperties: false, | ||
bannerComment, | ||
}); | ||
case "extension-packagejson": | ||
return fromVSIXColors(name, data); | ||
default: | ||
throw new Error(`Unknown kind: ${kind}`); | ||
} | ||
}) | ||
.then((typeDefs) => { | ||
const fp = path.join(__dirname, `../types/${fname}`); | ||
writeFileSync(fp, typeDefs, "utf-8"); | ||
}); | ||
} | ||
|
||
const fromVSIXColors = (interfaceName: string, data: any) => { | ||
let content = `${bannerComment} | ||
export interface ${interfaceName} {`; | ||
data.contributes.colors.map((color: any) => { | ||
content += ` | ||
/** | ||
* ${color.description} | ||
*/ | ||
"${color.id}": string; | ||
`; | ||
}); | ||
return content + "};\n"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
import type { ThemeContext } from "../../types"; | ||
import type { ErrorLensColors, ThemeContext } from "../../types"; | ||
import { opacity } from "../utils"; | ||
|
||
export default function colors(context: ThemeContext) { | ||
export default function colors( | ||
context: ThemeContext, | ||
): Partial<ErrorLensColors> { | ||
const { palette } = context; | ||
|
||
return { | ||
"errorLens.errorBackground": opacity(palette.red, 0.15), | ||
"errorLens.errorMessageBackground": opacity(palette.red, 0.15), | ||
"errorLens.errorBackgroundLight": opacity(palette.red, 0.15), | ||
"errorLens.errorForeground": palette.red, | ||
"errorLens.errorForegroundLight": palette.red, | ||
"errorLens.warningBackground": opacity(palette.peach, 0.15), | ||
"errorLens.warningMessageBackground": opacity(palette.peach, 0.15), | ||
"errorLens.warningBackgroundLight": opacity(palette.peach, 0.15), | ||
"errorLens.warningForeground": palette.peach, | ||
"errorLens.warningForegroundLight": palette.peach, | ||
"errorLens.infoBackground": opacity(palette.blue, 0.15), | ||
"errorLens.infoMessageBackground": opacity(palette.blue, 0.15), | ||
"errorLens.infoBackgroundLight": opacity(palette.blue, 0.15), | ||
"errorLens.infoForeground": palette.blue, | ||
"errorLens.infoForegroundLight": palette.blue, | ||
"errorLens.errorMessageBackground": opacity(palette.red, 0.15), | ||
"errorLens.hintBackground": opacity(palette.green, 0.15), | ||
"errorLens.hintMessageBackground": opacity(palette.green, 0.15), | ||
"errorLens.hintBackgroundLight": opacity(palette.green, 0.15), | ||
"errorLens.hintForeground": palette.green, | ||
"errorLens.hintForegroundLight": palette.green, | ||
"errorLens.hintMessageBackground": opacity(palette.green, 0.15), | ||
"errorLens.infoBackground": opacity(palette.blue, 0.15), | ||
"errorLens.infoBackgroundLight": opacity(palette.blue, 0.15), | ||
"errorLens.infoForeground": palette.blue, | ||
"errorLens.infoForegroundLight": palette.blue, | ||
"errorLens.infoMessageBackground": opacity(palette.blue, 0.15), | ||
"errorLens.statusBarErrorForeground": palette.red, | ||
"errorLens.statusBarHintForeground": palette.green, | ||
"errorLens.statusBarIconErrorForeground": palette.red, | ||
"errorLens.statusBarIconWarningForeground": palette.peach, | ||
"errorLens.statusBarErrorForeground": palette.red, | ||
"errorLens.statusBarWarningForeground": palette.peach, | ||
"errorLens.statusBarInfoForeground": palette.blue, | ||
"errorLens.statusBarHintForeground": palette.green, | ||
"errorLens.statusBarWarningForeground": palette.peach, | ||
"errorLens.warningBackground": opacity(palette.peach, 0.15), | ||
"errorLens.warningBackgroundLight": opacity(palette.peach, 0.15), | ||
"errorLens.warningForeground": palette.peach, | ||
"errorLens.warningForegroundLight": palette.peach, | ||
"errorLens.warningMessageBackground": opacity(palette.peach, 0.15), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* eslint-disable */ | ||
/** | ||
* This file was automatically generated. | ||
* DO NOT MODIFY IT BY HAND. | ||
* Instead, run `yarn run updateVSCtypes` to regenerate this file. | ||
*/ | ||
export interface ErrorLensColors { | ||
/** | ||
* Background color of the entire line containing error. | ||
*/ | ||
"errorLens.errorBackground": string; | ||
|
||
/** | ||
* Background color of the error message. | ||
*/ | ||
"errorLens.errorMessageBackground": string; | ||
|
||
/** | ||
* Background color of the entire line containing error (Only in light themes). | ||
*/ | ||
"errorLens.errorBackgroundLight": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing errors. | ||
*/ | ||
"errorLens.errorForeground": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing errors (Only in light themes). | ||
*/ | ||
"errorLens.errorForegroundLight": string; | ||
|
||
/** | ||
* Background color used to highlight lines containing warnings. | ||
*/ | ||
"errorLens.warningBackground": string; | ||
|
||
/** | ||
* Background color of the warning message. | ||
*/ | ||
"errorLens.warningMessageBackground": string; | ||
|
||
/** | ||
* Background color used to highlight lines containing warnings (Only in light themes). | ||
*/ | ||
"errorLens.warningBackgroundLight": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing warnings. | ||
*/ | ||
"errorLens.warningForeground": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing warnings (Only in light themes). | ||
*/ | ||
"errorLens.warningForegroundLight": string; | ||
|
||
/** | ||
* Background color used to highlight lines containing info. | ||
*/ | ||
"errorLens.infoBackground": string; | ||
|
||
/** | ||
* Background color of the info message. | ||
*/ | ||
"errorLens.infoMessageBackground": string; | ||
|
||
/** | ||
* Background color used to highlight lines containing info (Only in light themes). | ||
*/ | ||
"errorLens.infoBackgroundLight": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing info. | ||
*/ | ||
"errorLens.infoForeground": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing info (Only in light themes). | ||
*/ | ||
"errorLens.infoForegroundLight": string; | ||
|
||
/** | ||
* Background color used to highlight lines containing hints. | ||
*/ | ||
"errorLens.hintBackground": string; | ||
|
||
/** | ||
* Background color of the hint message. | ||
*/ | ||
"errorLens.hintMessageBackground": string; | ||
|
||
/** | ||
* Background color used to highlight lines containing hints (Only in light themes). | ||
*/ | ||
"errorLens.hintBackgroundLight": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing hints. | ||
*/ | ||
"errorLens.hintForeground": string; | ||
|
||
/** | ||
* Text color used to highlight lines containing hints (Only in light themes). | ||
*/ | ||
"errorLens.hintForegroundLight": string; | ||
|
||
/** | ||
* Status bar icon item error color. Foreground is used when the `errorLens.statusBarIconsUseBackground` setting is disabled. | ||
*/ | ||
"errorLens.statusBarIconErrorForeground": string; | ||
|
||
/** | ||
* Status bar icon item error color. Foreground is used when the `errorLens.statusBarIconsUseBackground` setting is disabled. | ||
*/ | ||
"errorLens.statusBarIconWarningForeground": string; | ||
|
||
/** | ||
* Status bar item error color. | ||
*/ | ||
"errorLens.statusBarErrorForeground": string; | ||
|
||
/** | ||
* Status bar item warning color. | ||
*/ | ||
"errorLens.statusBarWarningForeground": string; | ||
|
||
/** | ||
* Status bar item info color. | ||
*/ | ||
"errorLens.statusBarInfoForeground": string; | ||
|
||
/** | ||
* Status bar item hint color. | ||
*/ | ||
"errorLens.statusBarHintForeground": string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters