Skip to content

Commit ec60591

Browse files
committed
feat: make it works
1 parent ec549c7 commit ec60591

File tree

14 files changed

+550
-36
lines changed

14 files changed

+550
-36
lines changed

.vscode/tasks.json

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,35 @@
1010
"presentation": {
1111
"reveal": "never"
1212
},
13-
"problemMatcher": [
14-
{
15-
"base": "$ts-webpack-watch",
16-
"background": {
17-
"activeOnStart": true,
18-
"beginsPattern": "Build start",
19-
"endsPattern": "Build success"
20-
}
13+
"problemMatcher": {
14+
"owner": "typescript",
15+
"fileLocation": "relative",
16+
"pattern": {
17+
// TODO: correct "regexp"
18+
"regexp": "^([a-zA-Z]\\:/?([\\w\\-]/?)+\\.\\w+):(\\d+):(\\d+): (ERROR|WARNING)\\: (.*)$",
19+
"file": 1,
20+
"line": 3,
21+
"column": 4,
22+
"code": 5,
23+
"message": 6
24+
},
25+
"background": {
26+
"activeOnStart": true,
27+
"beginsPattern": "Build start",
28+
"endsPattern": "Build success"
2129
}
22-
],
23-
"group": "build"
30+
}
31+
// "problemMatcher": [
32+
// {
33+
// "owner": "typescript",
34+
// "fileLocation": "relative",
35+
// "background": {
36+
// "activeOnStart": true,
37+
// "beginsPattern": "Build start",
38+
// "endsPattern": "Build success"
39+
// }
40+
// }
41+
// ]
2442
}
2543
]
2644
}

eslint.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { defineEslintConfig } from '@subframe7536/eslint-config'
22

3-
export default defineEslintConfig()
3+
export default defineEslintConfig({
4+
type: 'app',
5+
})

package.json

Lines changed: 99 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"publisher": "[email protected]",
33
"name": "custom-ui-style",
4-
"displayName": "custom-ui-style",
4+
"displayName": "Custom UI Style",
55
"version": "0.0.0",
66
"private": true,
77
"packageManager": "[email protected]",
8-
"description": "",
8+
"description": "Custom ui css style in both editor and webview, unify global font family, setup background image",
99
"author": "subframe7536 <[email protected]>",
1010
"license": "MIT",
1111
"homepage": "https://github.com/subframe7536/custom-ui-style#readme",
@@ -32,31 +32,122 @@
3232
"activationEvents": [
3333
"onStartupFinished"
3434
],
35+
"extensionKind": [
36+
"ui",
37+
"workspace"
38+
],
3539
"contributes": {
36-
"commands": [],
40+
"commands": [
41+
{
42+
"command": "custom-ui-style.reload",
43+
"title": "Custom UI Style: Load custom style"
44+
},
45+
{
46+
"command": "custom-ui-style.rollback",
47+
"title": "Custom UI Style: Rollback"
48+
}
49+
],
3750
"configuration": {
3851
"type": "object",
39-
"title": "custom-ui-style",
40-
"properties": {}
52+
"title": "Custom UI Style",
53+
"properties": {
54+
"custom-ui-style.monospace": {
55+
"type": "string",
56+
"title": "Custom global monospace font family"
57+
},
58+
"custom-ui-style.sansSerif": {
59+
"type": "string",
60+
"title": "Custom global sans-serif font family"
61+
},
62+
"custom-ui-style.backgroundUrl": {
63+
"type": "string",
64+
"pattern": "^(https://|file://|data:)",
65+
"patternErrorMessage": "Only allow https: file:// data:",
66+
"title": "Custom background image url"
67+
},
68+
"custom-ui-style.backgroundUrlWin32": {
69+
"type": "string",
70+
"pattern": "^(https://|file://|data:)",
71+
"patternErrorMessage": "Only allow https: file:// data:",
72+
"title": "Custom background image url (For Windows)"
73+
},
74+
"custom-ui-style.backgroundUrlDarWin": {
75+
"type": "string",
76+
"pattern": "^(https://|file://|data:)",
77+
"patternErrorMessage": "Only allow https: file:// data:",
78+
"title": "Custom background image url (For MacOS)"
79+
},
80+
"custom-ui-style.backgroundUrlLinux": {
81+
"type": "string",
82+
"pattern": "^(https://|file://|data:)",
83+
"patternErrorMessage": "Only allow https: file:// data:",
84+
"title": "Custom background image url (For Linux)"
85+
},
86+
"custom-ui-style.backgroundOpacity": {
87+
"type": "number",
88+
"title": "Custom background image opacity",
89+
"default": 0.9
90+
},
91+
"custom-ui-style.backgroundSize": {
92+
"type": "string",
93+
"enum": [
94+
"cover",
95+
"contain"
96+
],
97+
"title": "Custom background image size",
98+
"default": "cover"
99+
},
100+
"custom-ui-style.backgroundPosition": {
101+
"type": "string",
102+
"title": "Custom background image size",
103+
"default": "center"
104+
},
105+
"custom-ui-style.stylesheet": {
106+
"type": "object",
107+
"title": "Custom css",
108+
"description": "support nest selectors"
109+
},
110+
"custom-ui-style.webviewMonospaceSelector": {
111+
"type": "array",
112+
"items": {
113+
"type": "string"
114+
},
115+
"title": "Custom monospace selector in webview"
116+
},
117+
"custom-ui-style.webviewSansSerifSelector": {
118+
"type": "array",
119+
"items": {
120+
"type": "string"
121+
},
122+
"title": "Custom sans-serif selector in webview"
123+
},
124+
"custom-ui-style.webviewStylesheet": {
125+
"type": "object",
126+
"title": "Custom css",
127+
"description": "support nest selectors"
128+
}
129+
}
41130
}
42131
},
43132
"scripts": {
44-
"build": "tsup src/index.ts --external vscode",
45-
"dev": "pnpm run build --watch",
133+
"build": "tsup --treeshake",
134+
"dev": "tsup --watch",
46135
"prepare": "pnpm run update",
47136
"update": "vscode-ext-gen --output src/generated/meta.ts",
48137
"format": "eslint . --fix",
49138
"vscode:prepublish": "pnpm run build",
50139
"publish": "vsce publish --no-dependencies",
51140
"pack": "vsce package --no-dependencies",
52141
"typecheck": "tsc --noEmit",
53-
"release": "bumpp && pnpm publish"
142+
"release": "bumpp && pnpm run publish"
54143
},
55144
"devDependencies": {
56145
"@subframe7536/eslint-config": "^0.9.4",
146+
"@subframe7536/type-utils": "^0.1.6",
57147
"@types/node": "^20.16.11",
58148
"@types/vscode": "^1.94.0",
59149
"@vscode/vsce": "^3.1.1",
150+
"atomically": "^2.0.3",
60151
"bumpp": "^9.7.1",
61152
"eslint": "^9.12.0",
62153
"reactive-vscode": "^0.2.5",

pnpm-lock.yaml

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

src/config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ export const config = defineConfigObject<Meta.ScopedConfigKeyTypeMap>(
55
Meta.scopedConfigs.scope,
66
Meta.scopedConfigs.defaults,
77
)
8+
9+
export const editorConfig = defineConfigObject('editor', {
10+
fontFamily: String,
11+
})
12+
13+
export function getFamilies() {
14+
let { monospace, sansSerif } = config
15+
monospace ||= editorConfig.fontFamily
16+
return { monospace, sansSerif }
17+
}

src/index.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
import { defineExtension } from 'reactive-vscode'
2-
import { window } from 'vscode'
1+
import { defineExtension, useCommand, watch } from 'reactive-vscode'
2+
import { config, editorConfig } from './config'
3+
import * as Meta from './generated/meta'
4+
import { createFileManagers } from './manager'
35

46
const { activate, deactivate } = defineExtension(() => {
5-
window.showInformationMessage('Hello')
7+
const { reload, rollback } = createFileManagers()
8+
useCommand(Meta.commands.reload, () => {
9+
reload('UI style changed')
10+
})
11+
useCommand(Meta.commands.rollback, () => {
12+
rollback('UI style rollback')
13+
})
14+
15+
watch(
16+
() => editorConfig.fontFamily,
17+
() => !config.monospace && reload('Configuration changed, reload'),
18+
)
19+
watch(
20+
config,
21+
() => reload('Configuration changed, reload'),
22+
)
623
})
724

825
export { activate, deactivate }

0 commit comments

Comments
 (0)