dsh-ide-window 0.1.1 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +10 -2
- package/CHANGELOG.md +66 -0
- package/README.md +38 -4
- package/client.js +382 -17
- package/enable-navigation.ps1 +1 -1
- package/enable-navigation.sh +1 -1
- package/index.js +62 -2
- package/install.ps1 +1 -1
- package/install.sh +1 -1
- package/locale/en.json +16 -1
- package/locale/zh.json +16 -1
- package/package.json +6 -4
- package/platform/windows.js +5 -1
- package/themes/atom-one-light.css +44 -0
- package/themes/dracula.css +44 -0
- package/themes/github-light.css +44 -0
- package/themes/index.json +42 -0
- package/themes/intellij-light.css +44 -0
- package/themes/material-light.css +44 -0
- package/themes/material-oceanic.css +44 -0
- package/themes/material-palenight.css +44 -0
- package/themes/monokai-pro.css +44 -0
- package/themes/night-owl.css +44 -0
- package/themes/solarized-light.css +44 -0
package/client.js
CHANGED
|
@@ -220,6 +220,21 @@ window.__ModuleLoader__.load({
|
|
|
220
220
|
"setupStepLicence": "Step 2: license the server (opens a browser; an existing license prints \"licensed\")",
|
|
221
221
|
"setupStepRestart": "Finally: quit DSH completely (⌘Q / tray) and reopen it.",
|
|
222
222
|
"setupCopyAll": "Copy commands",
|
|
223
|
+
"theme": "Theme",
|
|
224
|
+
"themeTitle": "Theme",
|
|
225
|
+
"themeDark": "Dark themes",
|
|
226
|
+
"themeLight": "Light themes",
|
|
227
|
+
"themeFollowDsh": "Follow DSH",
|
|
228
|
+
"theme_material_oceanic": "Oceanic",
|
|
229
|
+
"theme_material_palenight": "Palenight",
|
|
230
|
+
"theme_dracula": "Dracula",
|
|
231
|
+
"theme_monokai_pro": "Monokai Pro",
|
|
232
|
+
"theme_night_owl": "Night Owl",
|
|
233
|
+
"theme_material_light": "Material Light",
|
|
234
|
+
"theme_github_light": "GitHub Light",
|
|
235
|
+
"theme_atom_one_light": "Atom One Light",
|
|
236
|
+
"theme_solarized_light": "Solarized Light",
|
|
237
|
+
"theme_intellij_light": "IntelliJ Light",
|
|
223
238
|
}
|
|
224
239
|
const IDE_TEXT_ZH = {
|
|
225
240
|
"title": "代码工作区",
|
|
@@ -433,6 +448,21 @@ window.__ModuleLoader__.load({
|
|
|
433
448
|
"setupStepLicence": "第 2 步:授权(会打开浏览器;已授权会直接显示 licensed)",
|
|
434
449
|
"setupStepRestart": "最后:完全退出 DSH(⌘Q / 托盘退出)再打开。",
|
|
435
450
|
"setupCopyAll": "复制命令",
|
|
451
|
+
"theme": "主题",
|
|
452
|
+
"themeTitle": "主题切换器",
|
|
453
|
+
"themeDark": "深色主题",
|
|
454
|
+
"themeLight": "浅色主题",
|
|
455
|
+
"themeFollowDsh": "跟随 DSH",
|
|
456
|
+
"theme_material_oceanic": "海洋蓝 Oceanic",
|
|
457
|
+
"theme_material_palenight": "淡紫夜色 Palenight",
|
|
458
|
+
"theme_dracula": "德古拉 Dracula",
|
|
459
|
+
"theme_monokai_pro": "Monokai Pro",
|
|
460
|
+
"theme_night_owl": "夜枭 Night Owl",
|
|
461
|
+
"theme_material_light": "Material 浅色",
|
|
462
|
+
"theme_github_light": "GitHub 浅色",
|
|
463
|
+
"theme_atom_one_light": "Atom One 浅色",
|
|
464
|
+
"theme_solarized_light": "Solarized 浅色",
|
|
465
|
+
"theme_intellij_light": "IntelliJ 浅色",
|
|
436
466
|
}
|
|
437
467
|
|
|
438
468
|
// ---- 00-css.js -----------------------------------------------------------
|
|
@@ -841,14 +871,17 @@ const IDE_CSS = `
|
|
|
841
871
|
user-select: none;
|
|
842
872
|
font-style: italic;
|
|
843
873
|
}
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
.iw-
|
|
848
|
-
.iw-
|
|
849
|
-
.iw-
|
|
850
|
-
.iw-
|
|
851
|
-
.iw-
|
|
874
|
+
/* Syntax colours are their own layer: a palette sets --iw-syn-* because a
|
|
875
|
+
keyword colour that reads on #282a36 is unreadable on #ffffff. The literals
|
|
876
|
+
are the DSH-palette defaults for "follow DSH". */
|
|
877
|
+
.iw-kw { color: var(--iw-syn-keyword, #cf8ee6); }
|
|
878
|
+
.iw-str { color: var(--iw-syn-string, #9ddc8b); }
|
|
879
|
+
.iw-num { color: var(--iw-syn-number, #e0b072); }
|
|
880
|
+
.iw-com { color: var(--iw-syn-comment, #6d7683); font-style: italic; }
|
|
881
|
+
.iw-ann { color: var(--iw-syn-annotation, #e0c56b); }
|
|
882
|
+
.iw-type { color: var(--iw-syn-type, #7fc8f0); }
|
|
883
|
+
.iw-fn { color: var(--iw-syn-function, #8fd7d0); }
|
|
884
|
+
.iw-punct { color: var(--iw-syn-punct, var(--dsw-alias-label-secondary, #98a0ad)); }
|
|
852
885
|
.iw-sym { cursor: pointer; border-radius: 3px; }
|
|
853
886
|
.iw-sym:hover {
|
|
854
887
|
background: color-mix(in srgb, var(--dsw-alias-brand-primary, #5b9dff) 22%, transparent);
|
|
@@ -1793,6 +1826,128 @@ html.iw-select-code .iw-code .iw-vision {
|
|
|
1793
1826
|
gap: 8px;
|
|
1794
1827
|
}
|
|
1795
1828
|
|
|
1829
|
+
/* ---- colour theme switcher (bottom-right corner of the status bar) ----
|
|
1830
|
+
The palettes live in themes/*.css and only override the alias tokens these
|
|
1831
|
+
rules consume, so nothing here knows which theme is active. */
|
|
1832
|
+
.iw-theme-host {
|
|
1833
|
+
position: relative;
|
|
1834
|
+
display: inline-flex;
|
|
1835
|
+
flex: 0 0 auto;
|
|
1836
|
+
align-items: center;
|
|
1837
|
+
}
|
|
1838
|
+
.iw-theme-button {
|
|
1839
|
+
display: inline-flex;
|
|
1840
|
+
align-items: center;
|
|
1841
|
+
gap: 5px;
|
|
1842
|
+
height: 20px;
|
|
1843
|
+
padding: 0 6px;
|
|
1844
|
+
border: 1px solid transparent;
|
|
1845
|
+
border-radius: var(--dsw-radius-sm, 4px);
|
|
1846
|
+
background: transparent;
|
|
1847
|
+
color: var(--dsw-alias-label-secondary, #98a0ad);
|
|
1848
|
+
font: inherit;
|
|
1849
|
+
font-size: 11.5px;
|
|
1850
|
+
cursor: pointer;
|
|
1851
|
+
}
|
|
1852
|
+
.iw-theme-button:hover {
|
|
1853
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
|
|
1854
|
+
color: var(--dsw-alias-label-primary, #e6e8ec);
|
|
1855
|
+
}
|
|
1856
|
+
.iw-theme-button[aria-expanded="true"] {
|
|
1857
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
|
|
1858
|
+
border-color: var(--dsw-alias-border-l1, #2c3038);
|
|
1859
|
+
}
|
|
1860
|
+
.iw-theme-swatch {
|
|
1861
|
+
width: 11px;
|
|
1862
|
+
height: 11px;
|
|
1863
|
+
border-radius: 50%;
|
|
1864
|
+
background: linear-gradient(135deg, var(--dsw-alias-bg-base, #1b1d21) 50%, var(--dsw-alias-brand-primary, #4f8cff) 50%);
|
|
1865
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-label-primary, #e6e8ec) 30%, transparent);
|
|
1866
|
+
}
|
|
1867
|
+
.iw-theme-pop {
|
|
1868
|
+
/* Anchored to the panel, not the status bar: the bar clips overflow, so the
|
|
1869
|
+
list would be cut off at the bottom edge. */
|
|
1870
|
+
position: absolute;
|
|
1871
|
+
right: 12px;
|
|
1872
|
+
bottom: 34px;
|
|
1873
|
+
width: 236px;
|
|
1874
|
+
max-height: min(62vh, 460px);
|
|
1875
|
+
overflow-y: auto;
|
|
1876
|
+
padding: 6px;
|
|
1877
|
+
box-sizing: border-box;
|
|
1878
|
+
border: 1px solid var(--dsw-alias-border-l1, #2c3038);
|
|
1879
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
1880
|
+
/* A solid surface: the menu token is translucent in some DSH themes, and the
|
|
1881
|
+
source would show through the list. */
|
|
1882
|
+
background: var(--dsw-alias-bg-layer-2, var(--dsw-specific-menu, #23262c));
|
|
1883
|
+
box-shadow: var(--dsw-elevation-prominent, 0 10px 28px rgba(0, 0, 0, 0.35));
|
|
1884
|
+
backdrop-filter: var(--dsw-menu-backdrop-filter, none);
|
|
1885
|
+
z-index: 30;
|
|
1886
|
+
}
|
|
1887
|
+
.iw-theme-title {
|
|
1888
|
+
padding: 4px 8px 6px;
|
|
1889
|
+
color: var(--dsw-alias-label-secondary, #98a0ad);
|
|
1890
|
+
font-size: 12px;
|
|
1891
|
+
font-weight: 500;
|
|
1892
|
+
}
|
|
1893
|
+
.iw-theme-group {
|
|
1894
|
+
padding: 8px 8px 4px;
|
|
1895
|
+
color: var(--dsw-alias-label-tertiary, #767f8c);
|
|
1896
|
+
font-size: 11px;
|
|
1897
|
+
}
|
|
1898
|
+
.iw-theme-row {
|
|
1899
|
+
display: flex;
|
|
1900
|
+
align-items: center;
|
|
1901
|
+
gap: 8px;
|
|
1902
|
+
width: 100%;
|
|
1903
|
+
height: 26px;
|
|
1904
|
+
padding: 0 8px;
|
|
1905
|
+
box-sizing: border-box;
|
|
1906
|
+
border: 0;
|
|
1907
|
+
border-radius: var(--dsw-radius-sm, 4px);
|
|
1908
|
+
background: transparent;
|
|
1909
|
+
color: var(--dsw-alias-label-primary, #e6e8ec);
|
|
1910
|
+
font: inherit;
|
|
1911
|
+
font-size: 12px;
|
|
1912
|
+
text-align: left;
|
|
1913
|
+
cursor: pointer;
|
|
1914
|
+
}
|
|
1915
|
+
.iw-theme-row:hover {
|
|
1916
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
|
|
1917
|
+
}
|
|
1918
|
+
.iw-theme-row--on {
|
|
1919
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.14));
|
|
1920
|
+
}
|
|
1921
|
+
.iw-theme-name {
|
|
1922
|
+
flex: 1 1 auto;
|
|
1923
|
+
overflow: hidden;
|
|
1924
|
+
text-overflow: ellipsis;
|
|
1925
|
+
white-space: nowrap;
|
|
1926
|
+
}
|
|
1927
|
+
.iw-theme-check {
|
|
1928
|
+
color: var(--dsw-alias-brand-primary, #4f8cff);
|
|
1929
|
+
font-size: 11px;
|
|
1930
|
+
}
|
|
1931
|
+
.iw-theme-dot {
|
|
1932
|
+
width: 10px;
|
|
1933
|
+
height: 10px;
|
|
1934
|
+
flex: 0 0 auto;
|
|
1935
|
+
border-radius: 50%;
|
|
1936
|
+
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--dsw-alias-label-primary, #e6e8ec) 24%, transparent);
|
|
1937
|
+
}
|
|
1938
|
+
/* One dot per palette: the same colours the theme file applies. */
|
|
1939
|
+
.iw-theme-dot--follow { background: linear-gradient(135deg, #1b1d21 50%, #f3f4f6 50%); }
|
|
1940
|
+
.iw-theme-dot--material-oceanic { background: #0f111a; }
|
|
1941
|
+
.iw-theme-dot--material-palenight { background: #292d3e; }
|
|
1942
|
+
.iw-theme-dot--dracula { background: #282a36; }
|
|
1943
|
+
.iw-theme-dot--monokai-pro { background: #2d2a2e; }
|
|
1944
|
+
.iw-theme-dot--night-owl { background: #011627; }
|
|
1945
|
+
.iw-theme-dot--material-light { background: #fafafa; }
|
|
1946
|
+
.iw-theme-dot--github-light { background: #ffffff; }
|
|
1947
|
+
.iw-theme-dot--atom-one-light { background: #f0f0f1; }
|
|
1948
|
+
.iw-theme-dot--solarized-light { background: #fdf6e3; }
|
|
1949
|
+
.iw-theme-dot--intellij-light { background: #f7f8fa; }
|
|
1950
|
+
|
|
1796
1951
|
`
|
|
1797
1952
|
|
|
1798
1953
|
/** Render the stylesheet as a React element so unmounting removes it. */
|
|
@@ -2405,9 +2560,12 @@ function ideShortcutDefault(command, runtime) {
|
|
|
2405
2560
|
function idePlatformOf(name) {
|
|
2406
2561
|
// Only macOS is treated as macOS; every other value means Windows.
|
|
2407
2562
|
const windows = name !== 'macos' && name !== 'mac' && name !== 'darwin'
|
|
2563
|
+
// Windows compares paths case-insensitively, and tools disagree on the drive
|
|
2564
|
+
// letter's case (`c:/…` from the language server, `C:/…` from the workspace):
|
|
2565
|
+
// canonicalise it so the rest of the panel compares strings.
|
|
2408
2566
|
const toPosix = (path) => {
|
|
2409
2567
|
const text = String(path ?? '')
|
|
2410
|
-
return windows ? text.replace(/\\/g, '/') : text
|
|
2568
|
+
return windows ? text.replace(/\\/g, '/').replace(/^([a-z]):/, (_, drive) => `${drive.toUpperCase()}:`) : text
|
|
2411
2569
|
}
|
|
2412
2570
|
return {
|
|
2413
2571
|
name: windows ? 'windows' : 'macos',
|
|
@@ -2415,6 +2573,8 @@ function idePlatformOf(name) {
|
|
|
2415
2573
|
toPosix,
|
|
2416
2574
|
/** Slash form → the form the user's own tools accept. */
|
|
2417
2575
|
toNative: (path) => (windows ? String(path ?? '').replace(/\//g, '\\') : String(path ?? '')),
|
|
2576
|
+
/** Comparison key for "is this path inside that root": case-insensitive on Windows. */
|
|
2577
|
+
pathKey: (path) => (windows ? toPosix(path).toLowerCase() : toPosix(path)),
|
|
2418
2578
|
isAbsolutePath: (path) => {
|
|
2419
2579
|
const text = toPosix(path)
|
|
2420
2580
|
return windows ? /^[A-Za-z]:\//.test(text) || text.startsWith('//') || text.startsWith('/') : text.startsWith('/')
|
|
@@ -2661,8 +2821,13 @@ function ideRelativeTo(root, path) {
|
|
|
2661
2821
|
const text = idePlatform.toPosix(path)
|
|
2662
2822
|
const trimmedRoot = idePlatform.toPosix(root).replace(/\/+$/, '')
|
|
2663
2823
|
if (trimmedRoot === '') return text.startsWith('/') ? null : text
|
|
2664
|
-
|
|
2665
|
-
|
|
2824
|
+
// Windows is case-insensitive (and the language server may hand back a lower
|
|
2825
|
+
// -case drive); the key folds that without changing the length, so the
|
|
2826
|
+
// relative path is still a slice of the original text.
|
|
2827
|
+
const key = idePlatform.pathKey(text)
|
|
2828
|
+
const rootKey = idePlatform.pathKey(trimmedRoot)
|
|
2829
|
+
if (key === rootKey) return ''
|
|
2830
|
+
if (key.startsWith(`${rootKey}/`)) return text.slice(trimmedRoot.length + 1)
|
|
2666
2831
|
return idePlatform.isAbsolutePath(text) ? null : text
|
|
2667
2832
|
}
|
|
2668
2833
|
|
|
@@ -2953,6 +3118,10 @@ function ideCreateStore(refs) {
|
|
|
2953
3118
|
revealFile: null,
|
|
2954
3119
|
/** Files shown with Git annotate: `path → true`. */
|
|
2955
3120
|
annotate: {},
|
|
3121
|
+
/** Colour theme id (a file in `themes/`); empty follows the DSH palette. */
|
|
3122
|
+
theme: typeof prefs.theme === 'string' ? prefs.theme : '',
|
|
3123
|
+
/** Whether the palette popup is open (rendered at panel level, not in the bar). */
|
|
3124
|
+
themeMenu: false,
|
|
2956
3125
|
/** Editor and tree font sizes, in px, shared by the whole workspace. */
|
|
2957
3126
|
codeFontSize: Number.isFinite(prefs.codeFontSize) ? prefs.codeFontSize : 12.5,
|
|
2958
3127
|
treeFontSize: Number.isFinite(prefs.treeFontSize) ? prefs.treeFontSize : 14.5,
|
|
@@ -4003,6 +4172,13 @@ function ideCreateStore(refs) {
|
|
|
4003
4172
|
setIndexInfo: (indexInfo) => patch({ indexInfo }),
|
|
4004
4173
|
markRemoteReady: () => patch({ remoteReady: true }),
|
|
4005
4174
|
/** Turn reference interception on or off (persisted). */
|
|
4175
|
+
/** Open or close the palette popup. */
|
|
4176
|
+
setThemeMenu: (themeMenu) => patch({ themeMenu }),
|
|
4177
|
+
/** Switch the panel palette; an empty id goes back to the DSH colours. */
|
|
4178
|
+
setTheme: (theme) => {
|
|
4179
|
+
ideWritePrefs({ theme })
|
|
4180
|
+
patch({ theme })
|
|
4181
|
+
},
|
|
4006
4182
|
/** Change the editor font size, clamped to a readable range. */
|
|
4007
4183
|
setCodeFontSize: (size) => {
|
|
4008
4184
|
const codeFontSize = Math.min(24, Math.max(10, Math.round(size * 2) / 2))
|
|
@@ -4115,6 +4291,178 @@ function ideCreateStore(refs) {
|
|
|
4115
4291
|
}
|
|
4116
4292
|
}
|
|
4117
4293
|
|
|
4294
|
+
// ---- 12-theme.js ---------------------------------------------------------
|
|
4295
|
+
/**
|
|
4296
|
+
* Colour themes for the code workspace.
|
|
4297
|
+
*
|
|
4298
|
+
* A palette is a file: `themes/<id>.css` overrides the DSH alias tokens, scoped
|
|
4299
|
+
* to `.iw-root[data-iw-theme="<id>"]`. Every `.iw-*` rule already reads those
|
|
4300
|
+
* tokens, so a theme never touches a component style — switching a theme points
|
|
4301
|
+
* `<link id="iw-theme-link">` at another file and sets one attribute. A palette
|
|
4302
|
+
* can be edited without rebuilding the bundle.
|
|
4303
|
+
*
|
|
4304
|
+
* `themes/index.json` lists the same ids; `test/theme.mjs` holds the two in sync
|
|
4305
|
+
* and checks that every file defines the same token set.
|
|
4306
|
+
*/
|
|
4307
|
+
|
|
4308
|
+
/** Registry for the switcher: `mode` decides the group, the file name is `id`. */
|
|
4309
|
+
const IDE_THEMES = [
|
|
4310
|
+
{ id: 'material-oceanic', mode: 'dark' },
|
|
4311
|
+
{ id: 'material-palenight', mode: 'dark' },
|
|
4312
|
+
{ id: 'dracula', mode: 'dark' },
|
|
4313
|
+
{ id: 'monokai-pro', mode: 'dark' },
|
|
4314
|
+
{ id: 'night-owl', mode: 'dark' },
|
|
4315
|
+
{ id: 'material-light', mode: 'light' },
|
|
4316
|
+
{ id: 'github-light', mode: 'light' },
|
|
4317
|
+
{ id: 'atom-one-light', mode: 'light' },
|
|
4318
|
+
{ id: 'solarized-light', mode: 'light' },
|
|
4319
|
+
{ id: 'intellij-light', mode: 'light' },
|
|
4320
|
+
]
|
|
4321
|
+
|
|
4322
|
+
/**
|
|
4323
|
+
* Cache-buster for the stylesheet URL. A palette change keeps the same file
|
|
4324
|
+
* name, so the browser needs a reason to fetch it again; bump this when the
|
|
4325
|
+
* shipped palettes change.
|
|
4326
|
+
*/
|
|
4327
|
+
const IDE_THEME_REVISION = 1
|
|
4328
|
+
|
|
4329
|
+
const IDE_THEME_LINK_ID = 'iw-theme-link'
|
|
4330
|
+
|
|
4331
|
+
/** Ids the panel accepts: keeps an invalid preference from requesting a file. */
|
|
4332
|
+
function ideIsThemeId(value) {
|
|
4333
|
+
return typeof value === 'string' && IDE_THEMES.some((theme) => theme.id === value)
|
|
4334
|
+
}
|
|
4335
|
+
|
|
4336
|
+
/** Localised display name for a theme id; falls back to the id. */
|
|
4337
|
+
function ideThemeLabel(tr, id) {
|
|
4338
|
+
const key = `theme_${id.replace(/-/g, '_')}`
|
|
4339
|
+
const text = tr(key)
|
|
4340
|
+
return text === key ? id : text
|
|
4341
|
+
}
|
|
4342
|
+
|
|
4343
|
+
/**
|
|
4344
|
+
* Point the stylesheet at `id`'s file. An empty id removes it, which is the
|
|
4345
|
+
* "follow DSH" default: the panel keeps the host palette.
|
|
4346
|
+
*/
|
|
4347
|
+
function ideApplyTheme(id) {
|
|
4348
|
+
const existing = document.getElementById(IDE_THEME_LINK_ID)
|
|
4349
|
+
if (typeof id !== 'string' || id === '') {
|
|
4350
|
+
existing?.remove()
|
|
4351
|
+
return
|
|
4352
|
+
}
|
|
4353
|
+
const href = `/dsh-ide/theme?id=${encodeURIComponent(id)}&rev=${IDE_THEME_REVISION}`
|
|
4354
|
+
if (existing === null) {
|
|
4355
|
+
const link = document.createElement('link')
|
|
4356
|
+
link.id = IDE_THEME_LINK_ID
|
|
4357
|
+
link.rel = 'stylesheet'
|
|
4358
|
+
link.href = href
|
|
4359
|
+
document.head.append(link)
|
|
4360
|
+
return
|
|
4361
|
+
}
|
|
4362
|
+
if (existing.getAttribute('href') !== href) existing.setAttribute('href', href)
|
|
4363
|
+
}
|
|
4364
|
+
|
|
4365
|
+
/** Apply the saved theme once, and after every change; the panel owns the DOM. */
|
|
4366
|
+
function ideUseTheme(themeId) {
|
|
4367
|
+
useEffect(() => {
|
|
4368
|
+
ideApplyTheme(themeId)
|
|
4369
|
+
}, [themeId])
|
|
4370
|
+
}
|
|
4371
|
+
|
|
4372
|
+
/**
|
|
4373
|
+
* The trigger in the status-bar corner. The list itself is rendered by the panel
|
|
4374
|
+
* (`.iw-root` level), because `.iw-status` clips its overflow and a popup nested
|
|
4375
|
+
* inside it would be cut off at the panel edge.
|
|
4376
|
+
*/
|
|
4377
|
+
function IdeThemeButton({ store, themeId, open, tr }) {
|
|
4378
|
+
const current = IDE_THEMES.find((theme) => theme.id === themeId)
|
|
4379
|
+
return h('span', { className: 'iw-theme-host' }, [
|
|
4380
|
+
h('button', {
|
|
4381
|
+
key: 'button',
|
|
4382
|
+
type: 'button',
|
|
4383
|
+
className: 'iw-theme-button',
|
|
4384
|
+
title: current === undefined ? tr('themeFollowDsh') : ideThemeLabel(tr, current.id),
|
|
4385
|
+
'aria-haspopup': 'listbox',
|
|
4386
|
+
'aria-expanded': open ? 'true' : 'false',
|
|
4387
|
+
onClick: (event) => {
|
|
4388
|
+
event.stopPropagation()
|
|
4389
|
+
store.setThemeMenu(!open)
|
|
4390
|
+
},
|
|
4391
|
+
}, [
|
|
4392
|
+
h('span', { key: 'icon', className: 'iw-theme-swatch' }),
|
|
4393
|
+
h('span', { key: 'label', className: 'iw-theme-caption' }, tr('theme')),
|
|
4394
|
+
]),
|
|
4395
|
+
])
|
|
4396
|
+
}
|
|
4397
|
+
|
|
4398
|
+
/**
|
|
4399
|
+
* The palette list, anchored to the panel's bottom-right corner. Three ways out:
|
|
4400
|
+
* picking a theme, clicking anywhere else, and Escape.
|
|
4401
|
+
*/
|
|
4402
|
+
function IdeThemePopup({ store, themeId, tr }) {
|
|
4403
|
+
useEffect(() => {
|
|
4404
|
+
// A capture-phase listener runs before the row's own click, so the popup has
|
|
4405
|
+
// to ignore presses inside itself (and on the trigger, which toggles): closing
|
|
4406
|
+
// on those would unmount the row under the pointer and swallow the choice.
|
|
4407
|
+
const closeOnOutside = (event) => {
|
|
4408
|
+
const target = event.target
|
|
4409
|
+
if (target instanceof Element && target.closest('.iw-theme-pop, .iw-theme-button') !== null) return
|
|
4410
|
+
store.setThemeMenu(false)
|
|
4411
|
+
}
|
|
4412
|
+
const onKey = (event) => {
|
|
4413
|
+
if (event.key === 'Escape') store.setThemeMenu(false)
|
|
4414
|
+
}
|
|
4415
|
+
document.addEventListener('pointerdown', closeOnOutside, true)
|
|
4416
|
+
document.addEventListener('keydown', onKey, true)
|
|
4417
|
+
return () => {
|
|
4418
|
+
document.removeEventListener('pointerdown', closeOnOutside, true)
|
|
4419
|
+
document.removeEventListener('keydown', onKey, true)
|
|
4420
|
+
}
|
|
4421
|
+
}, [store])
|
|
4422
|
+
|
|
4423
|
+
const pick = (id) => {
|
|
4424
|
+
store.setTheme(id)
|
|
4425
|
+
store.setThemeMenu(false)
|
|
4426
|
+
}
|
|
4427
|
+
const row = (theme) => h('button', {
|
|
4428
|
+
key: theme.id,
|
|
4429
|
+
type: 'button',
|
|
4430
|
+
className: `iw-theme-row${themeId === theme.id ? ' iw-theme-row--on' : ''}`,
|
|
4431
|
+
onClick: (event) => {
|
|
4432
|
+
event.stopPropagation()
|
|
4433
|
+
pick(theme.id)
|
|
4434
|
+
},
|
|
4435
|
+
}, [
|
|
4436
|
+
h('span', { key: 'dot', className: `iw-theme-dot iw-theme-dot--${theme.id}` }),
|
|
4437
|
+
h('span', { key: 'name', className: 'iw-theme-name' }, ideThemeLabel(tr, theme.id)),
|
|
4438
|
+
themeId === theme.id ? h('span', { key: 'check', className: 'iw-theme-check' }, '✓') : null,
|
|
4439
|
+
])
|
|
4440
|
+
|
|
4441
|
+
return h('div', {
|
|
4442
|
+
className: 'iw-theme-pop',
|
|
4443
|
+
onPointerDown: (event) => event.stopPropagation(),
|
|
4444
|
+
}, [
|
|
4445
|
+
h('div', { key: 'title', className: 'iw-theme-title' }, tr('themeTitle')),
|
|
4446
|
+
h('button', {
|
|
4447
|
+
key: 'follow',
|
|
4448
|
+
type: 'button',
|
|
4449
|
+
className: `iw-theme-row${themeId === '' ? ' iw-theme-row--on' : ''}`,
|
|
4450
|
+
onClick: (event) => {
|
|
4451
|
+
event.stopPropagation()
|
|
4452
|
+
pick('')
|
|
4453
|
+
},
|
|
4454
|
+
}, [
|
|
4455
|
+
h('span', { key: 'dot', className: 'iw-theme-dot iw-theme-dot--follow' }),
|
|
4456
|
+
h('span', { key: 'name', className: 'iw-theme-name' }, tr('themeFollowDsh')),
|
|
4457
|
+
themeId === '' ? h('span', { key: 'check', className: 'iw-theme-check' }, '✓') : null,
|
|
4458
|
+
]),
|
|
4459
|
+
h('div', { key: 'dark', className: 'iw-theme-group' }, tr('themeDark')),
|
|
4460
|
+
...IDE_THEMES.filter((theme) => theme.mode === 'dark').map(row),
|
|
4461
|
+
h('div', { key: 'light', className: 'iw-theme-group' }, tr('themeLight')),
|
|
4462
|
+
...IDE_THEMES.filter((theme) => theme.mode === 'light').map(row),
|
|
4463
|
+
])
|
|
4464
|
+
}
|
|
4465
|
+
|
|
4118
4466
|
// ---- 20-tree.js ----------------------------------------------------------
|
|
4119
4467
|
/**
|
|
4120
4468
|
* The workspace file tree: lazy directories, a name filter over loaded
|
|
@@ -4153,13 +4501,22 @@ function ideRequestJavaKinds(root, paths, done) {
|
|
|
4153
4501
|
}
|
|
4154
4502
|
if (wanted.size === 0) return
|
|
4155
4503
|
const missing = [...wanted]
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4504
|
+
// One directory can hold hundreds of long package paths; the Host caps the body,
|
|
4505
|
+
// so ask in batches instead of losing the whole directory to a 413.
|
|
4506
|
+
const batches = []
|
|
4507
|
+
for (let index = 0; index < missing.length; index += 120) batches.push(missing.slice(index, index + 120))
|
|
4508
|
+
void (async () => {
|
|
4509
|
+
let answered = false
|
|
4510
|
+
for (const batch of batches) {
|
|
4511
|
+
const found = await ideKindsQuery(root, batch)
|
|
4512
|
+
if (found.ok !== true) continue
|
|
4513
|
+
answered = true
|
|
4514
|
+
for (const rel of batch) {
|
|
4515
|
+
ideJavaKinds.set(`${root}|${rel}`, typeof found.kinds[rel] === 'string' ? found.kinds[rel] : '')
|
|
4516
|
+
}
|
|
4160
4517
|
}
|
|
4161
|
-
done()
|
|
4162
|
-
})
|
|
4518
|
+
if (answered) done()
|
|
4519
|
+
})()
|
|
4163
4520
|
}
|
|
4164
4521
|
|
|
4165
4522
|
/**
|
|
@@ -6193,6 +6550,7 @@ function IdeStatusBar({ store, state, tab, tr }) {
|
|
|
6193
6550
|
style: { display: 'inline-flex', alignItems: 'center', gap: '5px' },
|
|
6194
6551
|
}, [h(IdeLiveDot, { key: 'dot', on: state.watching }), tr('live')]),
|
|
6195
6552
|
h('span', { key: 'ro' }, tr('readOnly')),
|
|
6553
|
+
h(IdeThemeButton, { key: 'theme', store, themeId: ideIsThemeId(state.theme) ? state.theme : '', open: state.themeMenu === true, tr }),
|
|
6196
6554
|
total === 0 ? null : h('span', { key: 'total', style: { opacity: 0.7 } }, `${state.tabs.length}`),
|
|
6197
6555
|
])
|
|
6198
6556
|
}
|
|
@@ -6701,10 +7059,14 @@ function IdePanel({ store, translate, onBackToChat, onToggleSidebar, onEnter, us
|
|
|
6701
7059
|
store.setNotice(`${tr('tabMenuCopied')}: ${text}`)
|
|
6702
7060
|
}
|
|
6703
7061
|
|
|
7062
|
+
// The palette is one stylesheet link, so it is applied here rather than in each
|
|
7063
|
+
// component: a theme change swaps the file and every rule follows it.
|
|
7064
|
+
ideUseTheme(ideIsThemeId(state.theme) ? state.theme : '')
|
|
6704
7065
|
const codeSize = Number.isFinite(state.codeFontSize) ? state.codeFontSize : 12.5
|
|
6705
7066
|
const treeSize = Number.isFinite(state.treeFontSize) ? state.treeFontSize : 14.5
|
|
6706
7067
|
return h('div', {
|
|
6707
7068
|
className: 'iw-root',
|
|
7069
|
+
'data-iw-theme': ideIsThemeId(state.theme) ? state.theme : undefined,
|
|
6708
7070
|
// The editor and the tree share one typographic scale, set in Settings.
|
|
6709
7071
|
style: {
|
|
6710
7072
|
'--iw-code-font-size': `${codeSize}px`,
|
|
@@ -6716,6 +7078,9 @@ function IdePanel({ store, translate, onBackToChat, onToggleSidebar, onEnter, us
|
|
|
6716
7078
|
h(IdeStyles, { key: 'style' }),
|
|
6717
7079
|
h(IdeToolbar, { key: 'toolbar', store, state, tr, projects, onSelectProject: selectProject, onToggleSidebar }),
|
|
6718
7080
|
banner,
|
|
7081
|
+
state.themeMenu === true
|
|
7082
|
+
? h(IdeThemePopup, { key: 'themepopup', store, themeId: ideIsThemeId(state.theme) ? state.theme : '', tr })
|
|
7083
|
+
: null,
|
|
6719
7084
|
h(IdeTreeMenu, {
|
|
6720
7085
|
key: 'treemenu',
|
|
6721
7086
|
store,
|
package/enable-navigation.ps1
CHANGED
|
@@ -30,7 +30,7 @@ trap {
|
|
|
30
30
|
exit 1
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
$lspVersion = '0.2.2-rc.
|
|
33
|
+
$lspVersion = '0.2.2-rc.5'
|
|
34
34
|
$packages = @("@deepseek-ai/dsh-lsp@$lspVersion", "@deepseek-ai/dsh-lsp-stdio@$lspVersion")
|
|
35
35
|
|
|
36
36
|
# JetBrains publishes the server per platform under the same build. The CDN host
|
package/enable-navigation.sh
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# application itself is never modified.
|
|
11
11
|
set -euo pipefail
|
|
12
12
|
|
|
13
|
-
LSP_VERSION="0.2.2-rc.
|
|
13
|
+
LSP_VERSION="0.2.2-rc.5"
|
|
14
14
|
PACKAGES=("@deepseek-ai/dsh-lsp@${LSP_VERSION}" "@deepseek-ai/dsh-lsp-stdio@${LSP_VERSION}")
|
|
15
15
|
SERVER_URL="https://download.jetbrains.com/language-server/intellij-server/271.2085.0/intellij-server-271.2085.0-aarch64.sit"
|
|
16
16
|
|
package/index.js
CHANGED
|
@@ -44,6 +44,10 @@ const ROUTE_PATCH = '/dsh-ide/patch'
|
|
|
44
44
|
const ROUTE_TEXT = '/dsh-ide/text'
|
|
45
45
|
const ROUTE_LICENSE = '/dsh-ide/license'
|
|
46
46
|
const ROUTE_DIAG = '/dsh-ide/diagnostics'
|
|
47
|
+
const ROUTE_THEME = '/dsh-ide/theme'
|
|
48
|
+
|
|
49
|
+
/** Where this file lives: the themes sit next to it, not in the profile. */
|
|
50
|
+
const PLUGIN_ROOT = fileURLToPath(new URL('.', import.meta.url))
|
|
47
51
|
|
|
48
52
|
/** Entries kept in memory; the file keeps everything up to its size cap. */
|
|
49
53
|
const IDE_LOG_LIMIT = 200
|
|
@@ -757,8 +761,8 @@ function grepWorkspace(payload) {
|
|
|
757
761
|
})
|
|
758
762
|
}
|
|
759
763
|
|
|
760
|
-
/** Largest JSON request body accepted. */
|
|
761
|
-
const MAX_BODY_BYTES =
|
|
764
|
+
/** Largest JSON request body accepted; `/dsh-ide/kinds` sends a directory of paths. */
|
|
765
|
+
const MAX_BODY_BYTES = 64 * 1024
|
|
762
766
|
|
|
763
767
|
/** The four queries the seam exposes; anything else is a caller bug. */
|
|
764
768
|
const OPERATIONS = new Set(['goToDefinition', 'findReferences', 'goToImplementation', 'hover'])
|
|
@@ -772,6 +776,55 @@ class RouteError extends Error {
|
|
|
772
776
|
}
|
|
773
777
|
}
|
|
774
778
|
|
|
779
|
+
/**
|
|
780
|
+
* Read one palette stylesheet.
|
|
781
|
+
*
|
|
782
|
+
* A theme is a file, so the browser can point a `<link>` at it and switching
|
|
783
|
+
* costs one request. The name is validated before it reaches the filesystem:
|
|
784
|
+
* anything but the shipped `[a-z0-9-]` ids is refused, which also rules out
|
|
785
|
+
* `../` traversal.
|
|
786
|
+
*/
|
|
787
|
+
export function themeCss(id) {
|
|
788
|
+
if (typeof id !== 'string' || !/^[a-z0-9][a-z0-9-]{0,40}$/.test(id)) {
|
|
789
|
+
throw new RouteError(400, 'invalid-argument', 'invalid theme id')
|
|
790
|
+
}
|
|
791
|
+
const file = join(PLUGIN_ROOT, 'themes', `${id}.css`)
|
|
792
|
+
try {
|
|
793
|
+
return readFileSync(file, 'utf8')
|
|
794
|
+
} catch {
|
|
795
|
+
throw new RouteError(404, 'not-found', `unknown theme: ${id}`)
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/** Serve one palette as CSS; the ETag keeps a reopened panel from refetching. */
|
|
800
|
+
function createThemeHandler() {
|
|
801
|
+
return async (request, response) => {
|
|
802
|
+
let id = ''
|
|
803
|
+
try {
|
|
804
|
+
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
805
|
+
writeJson(response, 405, { ok: false, error: { code: 'method-error', message: 'method not allowed' } })
|
|
806
|
+
return
|
|
807
|
+
}
|
|
808
|
+
id = new URL(request.url ?? '/', 'http://dsh-ide.internal').searchParams.get('id') ?? ''
|
|
809
|
+
const body = themeCss(id)
|
|
810
|
+
response.statusCode = 200
|
|
811
|
+
response.setHeader('content-type', 'text/css; charset=utf-8')
|
|
812
|
+
response.setHeader('cache-control', 'no-cache')
|
|
813
|
+
response.setHeader('etag', `"${Buffer.byteLength(body)}-${id}"`)
|
|
814
|
+
if (request.method === 'HEAD') {
|
|
815
|
+
response.end()
|
|
816
|
+
return
|
|
817
|
+
}
|
|
818
|
+
response.end(body)
|
|
819
|
+
} catch (error) {
|
|
820
|
+
const status = error instanceof RouteError ? error.status : 500
|
|
821
|
+
const code = error instanceof RouteError ? error.code : 'internal'
|
|
822
|
+
logEvent(status >= 500 ? 'error' : 'warn', 'route', `${ROUTE_THEME} → ${status} ${code}`, error?.message ?? String(error))
|
|
823
|
+
writeJson(response, status, { ok: false, error: { code, message: error?.message ?? String(error) } })
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
|
|
775
828
|
/** Write one JSON response. */
|
|
776
829
|
function writeJson(response, status, payload) {
|
|
777
830
|
const body = JSON.stringify(payload)
|
|
@@ -1349,4 +1402,11 @@ export function apply(ctx) {
|
|
|
1349
1402
|
path: ROUTE_DIAG,
|
|
1350
1403
|
handler,
|
|
1351
1404
|
}), 'dsh-ide-window: diagnostics route')
|
|
1405
|
+
// The palettes are the only route the browser fetches with `<link>`, so it
|
|
1406
|
+
// answers GET instead of the JSON POST every other route speaks.
|
|
1407
|
+
ctx.effect(() => ctx.webServer.register({
|
|
1408
|
+
kind: 'prefix',
|
|
1409
|
+
path: ROUTE_THEME,
|
|
1410
|
+
handler: createThemeHandler(),
|
|
1411
|
+
}), 'dsh-ide-window: theme route')
|
|
1352
1412
|
}
|
package/install.ps1
CHANGED
|
@@ -38,7 +38,7 @@ trap {
|
|
|
38
38
|
|
|
39
39
|
$repoUrl = 'https://github.com/simons-jiang/dsh-ide-window.git'
|
|
40
40
|
$packageName = 'dsh-ide-window'
|
|
41
|
-
$lspPackages = @('@deepseek-ai/dsh-lsp@0.2.2-rc.
|
|
41
|
+
$lspPackages = @('@deepseek-ai/dsh-lsp@0.2.2-rc.5', '@deepseek-ai/dsh-lsp-stdio@0.2.2-rc.5')
|
|
42
42
|
|
|
43
43
|
function Step([string]$Text) { Write-Host "`n==> $Text" }
|
|
44
44
|
function Fail([string]$Text) {
|
package/install.sh
CHANGED
|
@@ -14,7 +14,7 @@ set -euo pipefail
|
|
|
14
14
|
|
|
15
15
|
REPO_URL="https://github.com/simons-jiang/dsh-ide-window.git"
|
|
16
16
|
PACKAGE="dsh-ide-window"
|
|
17
|
-
LSP_PACKAGES=("@deepseek-ai/dsh-lsp@0.2.2-rc.
|
|
17
|
+
LSP_PACKAGES=("@deepseek-ai/dsh-lsp@0.2.2-rc.5" "@deepseek-ai/dsh-lsp-stdio@0.2.2-rc.5")
|
|
18
18
|
|
|
19
19
|
PROFILE="desktop"
|
|
20
20
|
DIR="${DSH_IDE_DIR:-$HOME/dev/dsh-ide-window}"
|
package/locale/en.json
CHANGED
|
@@ -213,5 +213,20 @@
|
|
|
213
213
|
"setupStepScript": "Step 1: run the install script (packages, server download, config; use your own path if it is not at the default location)",
|
|
214
214
|
"setupStepLicence": "Step 2: license the server (opens a browser; an existing license prints \"licensed\")",
|
|
215
215
|
"setupStepRestart": "Finally: quit DSH completely (⌘Q / tray) and reopen it.",
|
|
216
|
-
"setupCopyAll": "Copy commands"
|
|
216
|
+
"setupCopyAll": "Copy commands",
|
|
217
|
+
"theme": "Theme",
|
|
218
|
+
"themeTitle": "Theme",
|
|
219
|
+
"themeDark": "Dark themes",
|
|
220
|
+
"themeLight": "Light themes",
|
|
221
|
+
"themeFollowDsh": "Follow DSH",
|
|
222
|
+
"theme_material_oceanic": "Oceanic",
|
|
223
|
+
"theme_material_palenight": "Palenight",
|
|
224
|
+
"theme_dracula": "Dracula",
|
|
225
|
+
"theme_monokai_pro": "Monokai Pro",
|
|
226
|
+
"theme_night_owl": "Night Owl",
|
|
227
|
+
"theme_material_light": "Material Light",
|
|
228
|
+
"theme_github_light": "GitHub Light",
|
|
229
|
+
"theme_atom_one_light": "Atom One Light",
|
|
230
|
+
"theme_solarized_light": "Solarized Light",
|
|
231
|
+
"theme_intellij_light": "IntelliJ Light"
|
|
217
232
|
}
|
package/locale/zh.json
CHANGED
|
@@ -213,5 +213,20 @@
|
|
|
213
213
|
"setupStepScript": "第 1 步:运行安装脚本(装管道包、下载服务器、写好配置;脚本不在默认位置就改成你的路径)",
|
|
214
214
|
"setupStepLicence": "第 2 步:授权(会打开浏览器;已授权会直接显示 licensed)",
|
|
215
215
|
"setupStepRestart": "最后:完全退出 DSH(⌘Q / 托盘退出)再打开。",
|
|
216
|
-
"setupCopyAll": "复制命令"
|
|
216
|
+
"setupCopyAll": "复制命令",
|
|
217
|
+
"theme": "主题",
|
|
218
|
+
"themeTitle": "主题切换器",
|
|
219
|
+
"themeDark": "深色主题",
|
|
220
|
+
"themeLight": "浅色主题",
|
|
221
|
+
"themeFollowDsh": "跟随 DSH",
|
|
222
|
+
"theme_material_oceanic": "海洋蓝 Oceanic",
|
|
223
|
+
"theme_material_palenight": "淡紫夜色 Palenight",
|
|
224
|
+
"theme_dracula": "德古拉 Dracula",
|
|
225
|
+
"theme_monokai_pro": "Monokai Pro",
|
|
226
|
+
"theme_night_owl": "夜枭 Night Owl",
|
|
227
|
+
"theme_material_light": "Material 浅色",
|
|
228
|
+
"theme_github_light": "GitHub 浅色",
|
|
229
|
+
"theme_atom_one_light": "Atom One 浅色",
|
|
230
|
+
"theme_solarized_light": "Solarized 浅色",
|
|
231
|
+
"theme_intellij_light": "IntelliJ 浅色"
|
|
217
232
|
}
|