dsh-gufa-code 1.3.118 → 1.3.173

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.
@@ -133,6 +133,11 @@ try {
133
133
  const missingMtimes = await call(router, 'fs.mtimes', { root, paths: [] })
134
134
  check('fs.mtimes handles empty list', missingMtimes.files !== null && typeof missingMtimes.files === 'object' && Object.keys(missingMtimes.files).length === 0)
135
135
 
136
+ const resolvedPath = await call(router, 'code.resolvePath', { root, path: 'main.ts' })
137
+ check('code.resolvePath resolves basename', resolvedPath.path === 'src/main.ts', JSON.stringify(resolvedPath))
138
+ const resolvedMissing = await call(router, 'code.resolvePath', { root, path: 'not-exist-file.ts' })
139
+ check('code.resolvePath returns null for missing', resolvedMissing.path === null, JSON.stringify(resolvedMissing))
140
+
136
141
  console.log('lint.javascript')
137
142
  await call(router, 'fs.create', { root, path: 'src/lint-sample.js', kind: 'file' })
138
143
  const lintResult = await call(router, 'lint.javascript', {
@@ -141,14 +146,14 @@ try {
141
146
  language: 'javascript',
142
147
  content: 'const lintValue = undefinedVariable\n',
143
148
  })
144
- check('lint reports undefined variable', lintResult.diagnostics.some((item) => item.code === 2304 && item.line === 1), JSON.stringify(lintResult.diagnostics))
149
+ check('lint reports undefined variable', lintResult.diagnostics.some((item) => item.code === 'no-undef' && item.line === 1 && String(item.message).includes('not defined')), JSON.stringify(lintResult.diagnostics))
145
150
  const lintSyntax = await call(router, 'lint.javascript', {
146
151
  root,
147
152
  path: 'src/lint-sample.js',
148
153
  language: 'javascript',
149
154
  content: 'const = 1\n',
150
155
  })
151
- check('lint reports syntax error', lintSyntax.diagnostics.some((item) => item.severity === 1 && item.code === 1134), JSON.stringify(lintSyntax.diagnostics))
156
+ check('lint reports syntax error', lintSyntax.diagnostics.some((item) => item.severity === 1 && item.code === 'parsing-error'), JSON.stringify(lintSyntax.diagnostics))
152
157
  const lintNoisy = await call(router, 'lint.javascript', {
153
158
  root,
154
159
  path: 'src/lint-sample.js',
@@ -156,8 +161,55 @@ try {
156
161
  content: 'const someObject = {}\nsomeObject.missingProperty\n',
157
162
  })
158
163
  check('lint suppresses dynamic property warnings', lintNoisy.diagnostics.length === 0, JSON.stringify(lintNoisy.diagnostics))
164
+ await call(router, 'fs.create', { root, path: '.eslintrc.json', kind: 'file' })
165
+ await call(router, 'fs.write', { root, path: '.eslintrc.json', content: JSON.stringify({ globals: { zzConfiguredGlobal: 'readonly' } }) })
166
+ const lintConfigured = await call(router, 'lint.javascript', {
167
+ root,
168
+ path: 'src/lint-sample.js',
169
+ language: 'javascript',
170
+ content: 'zzConfiguredGlobal\n',
171
+ })
172
+ check('lint respects project eslint globals', lintConfigured.diagnostics.length === 0, JSON.stringify(lintConfigured.diagnostics))
173
+ await call(router, 'fs.delete', { root, path: '.eslintrc.json' }).catch(() => {})
159
174
  await call(router, 'fs.delete', { root, path: 'src/lint-sample.js' }).catch(() => {})
160
175
 
176
+ console.log('code.tsDefinition')
177
+ await call(router, 'fs.create', { root, path: 'src/tsdef-sample.js', kind: 'file' })
178
+ await call(router, 'fs.write', {
179
+ root,
180
+ path: 'src/tsdef-sample.js',
181
+ content: 'function zzDefinitionTarget() {\n return 1\n}\nzzDefinitionTarget()\n',
182
+ })
183
+ const tsDefResult = await call(router, 'code.tsDefinition', {
184
+ root,
185
+ path: 'src/tsdef-sample.js',
186
+ line: 4,
187
+ column: 1,
188
+ content: 'function zzDefinitionTarget() {\n return 1\n}\nzzDefinitionTarget()\n',
189
+ })
190
+ check('tsDefinition resolves local function', tsDefResult.matches.length > 0 && tsDefResult.matches[0].path === 'src/tsdef-sample.js' && tsDefResult.matches[0].line === 1, JSON.stringify(tsDefResult.matches))
191
+ check('tsDefinition lands on function name column', tsDefResult.matches[0].column === 10, JSON.stringify(tsDefResult.matches))
192
+ const tsLibResult = await call(router, 'code.tsDefinition', {
193
+ root,
194
+ path: 'src/tsdef-sample.js',
195
+ line: 1,
196
+ column: 18,
197
+ content: 'const zzParsed = parseInt("42", 10)\n',
198
+ })
199
+ check('tsDefinition resolves builtin to TS lib', tsLibResult.matches.some((item) => item.external === true && String(item.absolutePath || '').includes('/typescript/lib/lib.')), JSON.stringify(tsLibResult.matches))
200
+ const tsLibApi = await call(router, 'code.readTsLib', { absolutePath: tsLibResult.matches.find((item) => item.external === true)?.absolutePath ?? '' })
201
+ check('readTsLib returns d.ts content', typeof tsLibApi.content === 'string' && tsLibApi.content.includes('parseInt') && tsLibApi.language === 'typescript')
202
+ const tsLibByName = await call(router, 'code.readTsLib', { libName: 'lib.es5.d.ts' })
203
+ check('readTsLib by libName', typeof tsLibByName.content === 'string' && tsLibByName.content.includes('parseInt'), String(tsLibByName.content?.length))
204
+ let badLibName = false
205
+ try {
206
+ await call(router, 'code.readTsLib', { libName: '../package.json' })
207
+ } catch (error) {
208
+ badLibName = error.code === 'forbidden'
209
+ }
210
+ check('readTsLib rejects traversal', badLibName)
211
+ await call(router, 'fs.delete', { root, path: 'src/tsdef-sample.js' }).catch(() => {})
212
+
161
213
  console.log('fs.search')
162
214
  await call(router, 'fs.create', { root, path: 'search.txt', kind: 'file' })
163
215
  await call(router, 'fs.write', { root, path: 'search.txt', content: 'Alpha beta\nBETA gamma\nbeta BETA\n' })
@@ -268,12 +268,12 @@ test('主题映射 dark→vs-dark / light→vs', () => {
268
268
  assert.equal(monacoTheme(undefined), 'vs')
269
269
  })
270
270
 
271
- test('编辑器选项:automaticLayout 开、minimap/overview ruler 关', () => {
271
+ test('编辑器选项:automaticLayout 开、minimap 关、ruler 开(查找标记)', () => {
272
272
  const options = G.EditorPane.internals.editorOptions('dark')
273
273
  assert.equal(options.automaticLayout, true)
274
274
  assert.equal(options.minimap.enabled, false)
275
- assert.equal(options.overviewRulerLanes, 0)
276
- assert.equal(options.renderOverviewRuler, false)
275
+ assert.equal(options.overviewRulerLanes, 1)
276
+ assert.equal(options.renderOverviewRuler, true)
277
277
  assert.equal(options.theme, 'vs-dark')
278
278
  assert.equal(G.EditorPane.internals.editorOptions('light').theme, 'vs')
279
279
  })
@@ -1153,6 +1153,7 @@ G.errorText = (error) => {
1153
1153
  G.CSS = `
1154
1154
  .gufa-overlay-root{position:fixed;inset:0;z-index:1;display:flex;box-sizing:border-box;background:var(--gufa-solid-bg, var(--dsw-alias-bg-base));pointer-events:auto;overflow:hidden}
1155
1155
  .gufa-backdrop{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
1156
+
1156
1157
  /* 桌面悬浮层(摸鱼)模式:整窗半透明,透明度由 --gufa-float-alpha 控制(标题栏滑块) */
1157
1158
  html[data-gufa-float]{--gufa-float-alpha:0.55}
1158
1159
  html[data-gufa-float] body{background:transparent!important;color-scheme:dark;
@@ -1293,7 +1294,17 @@ html[data-gufa-float] #root [data-gufa-dock],
1293
1294
  html[data-gufa-float] #root .gufa-overlay-root *,
1294
1295
  html[data-gufa-float] #root [data-gufa-dock] *{visibility:visible!important}
1295
1296
  /* 桌宠提到覆盖层之上:同时兼容 @linxin666/dsh-pet(data-dsh-pet-root)与官方 dsh-pet(.dsh-pet-root) */
1297
+ /* 古法覆盖层打开时,DSH 右侧栏被覆盖却仍参与 layout/paint;
1298
+ myrta 这类会话会给右侧栏渲染 7000+ 节点,导致编辑器滚动每帧 style/layout 50ms。 */
1299
+ html[data-gufa-ide] [class*="rightbarCol"],
1300
+ html[data-gufa-float] [class*="rightbarCol"]{display:none!important}
1301
+
1296
1302
  html[data-gufa-ide] .dsh-pet-root{z-index:2147483050!important}
1303
+ /* 聊天栏收起时,把覆盖层下面的官方会话(可能几千个 DOM 节点)真正隐藏,
1304
+ 避免编辑器滚动时整页 layout/paint 把它一起算进去。 */
1305
+ /* 古法/摸鱼模式下皮肤自身的粒子 canvas 不参与绘制(防止 WebGL/rAF 在覆盖层下面持续跑) */
1306
+ html[data-gufa-ide] .liang-ambient,
1307
+ html[data-gufa-float] .liang-ambient{display:none!important}
1297
1308
  /* 外部弹窗(DSH 设置等)打开时:停靠会话、古法 portal、桌宠全部降到官方弹窗之下 */
1298
1309
  html[data-gufa-external-modal] [data-gufa-dock]{z-index:2!important}
1299
1310
  html[data-gufa-external-modal] #gufa-portal-root{z-index:1!important}
@@ -1684,6 +1695,8 @@ html[data-platform=darwin][data-fullscreen] .gufa-titlebar{height:44px;padding-l
1684
1695
  .gufa-breadcrumb b{font-weight:500;color:var(--gufa-text)}
1685
1696
  .gufa-editor-host{flex:1 1 auto;position:relative;min-height:0;min-width:0;overflow:hidden}
1686
1697
  .gufa-def-link{text-decoration:underline;text-decoration-color:var(--gufa-accent);text-decoration-thickness:1px;text-underline-offset:2px;cursor:pointer}
1698
+ /* Cmd 悬停:只变正经链接蓝,不下划线、不弹框 */
1699
+ .gufa-def-link-color{color:#4aa8ff!important;text-decoration:none!important;cursor:pointer}
1687
1700
  .monaco-editor.gufa-def-hover .view-lines{cursor:pointer}
1688
1701
  .gufa-editor-fallback{position:absolute;inset:0;overflow:auto;margin:0;padding:14px 18px;font:12.5px/1.55 ui-monospace,SFMono-Regular,Menlo,monospace;white-space:pre;tab-size:2}
1689
1702
  .gufa-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;height:100%;padding:28px;