@opensumi/ide-core-browser 2.21.8-rc-1670567192.0 → 2.21.8

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.
Files changed (317) hide show
  1. package/lib/components/actions/index.d.ts.map +1 -1
  2. package/lib/components/actions/index.js +22 -2
  3. package/lib/components/actions/index.js.map +1 -1
  4. package/lib/components/tree/tree.module.less +0 -1
  5. package/lib/contextkey/testing.d.ts +0 -1
  6. package/lib/contextkey/testing.d.ts.map +1 -1
  7. package/lib/contextkey/testing.js +1 -2
  8. package/lib/contextkey/testing.js.map +1 -1
  9. package/lib/menu/next/menu.contrib.interface.d.ts +2 -3
  10. package/lib/menu/next/menu.contrib.interface.d.ts.map +1 -1
  11. package/lib/menu/next/menu.contrib.interface.js.map +1 -1
  12. package/lib/preferences/preference-configurations.js +1 -1
  13. package/lib/preferences/preference-configurations.js.map +1 -1
  14. package/lib/react-providers/config-provider.d.ts +0 -4
  15. package/lib/react-providers/config-provider.d.ts.map +1 -1
  16. package/lib/react-providers/config-provider.js.map +1 -1
  17. package/lib/services/storage-service.d.ts.map +1 -1
  18. package/lib/services/storage-service.js +1 -7
  19. package/lib/services/storage-service.js.map +1 -1
  20. package/lib/utils/label.d.ts.map +1 -1
  21. package/lib/utils/label.js +9 -16
  22. package/lib/utils/label.js.map +1 -1
  23. package/package.json +6 -7
  24. package/src/application/application-state-service.ts +0 -54
  25. package/src/application/application.service.ts +0 -51
  26. package/src/application/index.ts +0 -2
  27. package/src/authentication/authentication.contribution.ts +0 -35
  28. package/src/authentication/authentication.service.ts +0 -517
  29. package/src/bootstrap/app.ts +0 -745
  30. package/src/bootstrap/app.view.tsx +0 -88
  31. package/src/bootstrap/connection.ts +0 -116
  32. package/src/bootstrap/index.ts +0 -3
  33. package/src/bootstrap/inner-providers.ts +0 -297
  34. package/src/bootstrap/lifecycle.service.ts +0 -19
  35. package/src/browser-module.ts +0 -24
  36. package/src/common/common.command.ts +0 -977
  37. package/src/common/common.contribution.ts +0 -343
  38. package/src/common/common.define.ts +0 -55
  39. package/src/common/common.module.ts +0 -33
  40. package/src/common/common.storage.ts +0 -22
  41. package/src/common/container-id.ts +0 -12
  42. package/src/common/index.ts +0 -4
  43. package/src/components/actions/index.tsx +0 -486
  44. package/src/components/actions/placements.ts +0 -47
  45. package/src/components/actions/styles.module.less +0 -144
  46. package/src/components/badge/index.tsx +0 -1
  47. package/src/components/index.ts +0 -26
  48. package/src/components/layout/box-panel.tsx +0 -88
  49. package/src/components/layout/default-layout.tsx +0 -61
  50. package/src/components/layout/index.ts +0 -4
  51. package/src/components/layout/layout.ts +0 -80
  52. package/src/components/layout/split-panel.service.ts +0 -56
  53. package/src/components/layout/split-panel.tsx +0 -296
  54. package/src/components/layout/styles.module.less +0 -21
  55. package/src/components/loading/index.ts +0 -1
  56. package/src/components/loading/loading.less +0 -14
  57. package/src/components/loading/loading.view.tsx +0 -7
  58. package/src/components/loading/media/loading-dark.svg +0 -52
  59. package/src/components/loading/media/loading-hc.svg +0 -52
  60. package/src/components/loading/media/loading.svg +0 -52
  61. package/src/components/popover/styles.module.less +0 -81
  62. package/src/components/portal/index.tsx +0 -13
  63. package/src/components/progressbar/index.tsx +0 -16
  64. package/src/components/progressbar/styles.module.less +0 -31
  65. package/src/components/recycle-tree/index.ts +0 -1
  66. package/src/components/recycle-tree/recycle-tree.view.tsx +0 -368
  67. package/src/components/resize/resize.module.less +0 -78
  68. package/src/components/resize/resize.tsx +0 -663
  69. package/src/components/scroll/index.tsx +0 -386
  70. package/src/components/scroll/scroll.module.less +0 -108
  71. package/src/components/scrollbar/index.ts +0 -1
  72. package/src/components/scrollbar/scrollbar.less +0 -36
  73. package/src/components/scrollbar/scrollbar.view.ts +0 -8
  74. package/src/components/select/index.tsx +0 -12
  75. package/src/components/select/styles.less +0 -6
  76. package/src/components/tree/index.ts +0 -3
  77. package/src/components/tree/tree-node.view.tsx +0 -546
  78. package/src/components/tree/tree.module.less +0 -297
  79. package/src/components/tree/tree.view.tsx +0 -486
  80. package/src/context-key.ts +0 -48
  81. package/src/contextkey/dialog.ts +0 -3
  82. package/src/contextkey/explorer.ts +0 -26
  83. package/src/contextkey/index.ts +0 -6
  84. package/src/contextkey/outline.ts +0 -4
  85. package/src/contextkey/resource.ts +0 -61
  86. package/src/contextkey/terminal.ts +0 -7
  87. package/src/contextkey/testing.ts +0 -9
  88. package/src/contextkey/workspace.ts +0 -7
  89. package/src/core-preferences.ts +0 -318
  90. package/src/dom/index.ts +0 -176
  91. package/src/encoding-registry.ts +0 -83
  92. package/src/extensions/extensions-point.service.ts +0 -78
  93. package/src/extensions/index.ts +0 -3
  94. package/src/extensions/schema/browserViews.ts +0 -96
  95. package/src/extensions/schema/menu.ts +0 -245
  96. package/src/extensions/schema/opensumiExtensionPackageSchema.ts +0 -12
  97. package/src/extensions/schema/toolbar.ts +0 -338
  98. package/src/extensions/schema/vscodeExtensionPackageSchema.ts +0 -330
  99. package/src/fs/index.ts +0 -12
  100. package/src/hash-calculate/hash-calculate.contribution.ts +0 -19
  101. package/src/index.ts +0 -42
  102. package/src/keybinding/index.ts +0 -1
  103. package/src/keybinding/keybinding.ts +0 -908
  104. package/src/keyboard/index.ts +0 -3
  105. package/src/keyboard/keyboard-layout-provider.ts +0 -412
  106. package/src/keyboard/keyboard-layout-service.ts +0 -449
  107. package/src/keyboard/keys.ts +0 -748
  108. package/src/keyboard/layouts/_.contribution.ts +0 -24
  109. package/src/keyboard/layouts/cz.win.ts +0 -168
  110. package/src/keyboard/layouts/de-swiss.win.ts +0 -168
  111. package/src/keyboard/layouts/de.darwin.ts +0 -131
  112. package/src/keyboard/layouts/de.linux.ts +0 -186
  113. package/src/keyboard/layouts/de.win.ts +0 -168
  114. package/src/keyboard/layouts/dk.win.ts +0 -168
  115. package/src/keyboard/layouts/dvorak.darwin.ts +0 -131
  116. package/src/keyboard/layouts/en-belgian.win.ts +0 -168
  117. package/src/keyboard/layouts/en-ext.darwin.ts +0 -131
  118. package/src/keyboard/layouts/en-in.win.ts +0 -168
  119. package/src/keyboard/layouts/en-intl.darwin.ts +0 -131
  120. package/src/keyboard/layouts/en-intl.win.ts +0 -168
  121. package/src/keyboard/layouts/en-uk.darwin.ts +0 -131
  122. package/src/keyboard/layouts/en-uk.win.ts +0 -168
  123. package/src/keyboard/layouts/en.darwin.ts +0 -139
  124. package/src/keyboard/layouts/en.linux.ts +0 -186
  125. package/src/keyboard/layouts/en.win.ts +0 -173
  126. package/src/keyboard/layouts/es-latin.win.ts +0 -168
  127. package/src/keyboard/layouts/es.darwin.ts +0 -131
  128. package/src/keyboard/layouts/es.linux.ts +0 -186
  129. package/src/keyboard/layouts/es.win.ts +0 -168
  130. package/src/keyboard/layouts/fr.darwin.ts +0 -131
  131. package/src/keyboard/layouts/fr.linux.ts +0 -186
  132. package/src/keyboard/layouts/fr.win.ts +0 -168
  133. package/src/keyboard/layouts/hu.win.ts +0 -168
  134. package/src/keyboard/layouts/it.darwin.ts +0 -131
  135. package/src/keyboard/layouts/it.win.ts +0 -168
  136. package/src/keyboard/layouts/jp-roman.darwin.ts +0 -131
  137. package/src/keyboard/layouts/jp.darwin.ts +0 -131
  138. package/src/keyboard/layouts/ko.darwin.ts +0 -131
  139. package/src/keyboard/layouts/layout.contribution.darwin.ts +0 -23
  140. package/src/keyboard/layouts/layout.contribution.linux.ts +0 -12
  141. package/src/keyboard/layouts/layout.contribution.ts +0 -9
  142. package/src/keyboard/layouts/layout.contribution.win.ts +0 -29
  143. package/src/keyboard/layouts/no.win.ts +0 -168
  144. package/src/keyboard/layouts/pl.darwin.ts +0 -131
  145. package/src/keyboard/layouts/pl.win.ts +0 -168
  146. package/src/keyboard/layouts/pt-br.win.ts +0 -169
  147. package/src/keyboard/layouts/pt.darwin.ts +0 -131
  148. package/src/keyboard/layouts/pt.win.ts +0 -168
  149. package/src/keyboard/layouts/ru.darwin.ts +0 -131
  150. package/src/keyboard/layouts/ru.linux.ts +0 -186
  151. package/src/keyboard/layouts/ru.win.ts +0 -168
  152. package/src/keyboard/layouts/sv.darwin.ts +0 -131
  153. package/src/keyboard/layouts/sv.win.ts +0 -168
  154. package/src/keyboard/layouts/thai.win.ts +0 -168
  155. package/src/keyboard/layouts/tr.win.ts +0 -168
  156. package/src/keyboard/layouts/zh-hans.darwin.ts +0 -131
  157. package/src/layout/accordion/tab-bar-toolbar.tsx +0 -59
  158. package/src/layout/accordion/view-context-key.registry.ts +0 -34
  159. package/src/layout/constants.ts +0 -7
  160. package/src/layout/index.ts +0 -5
  161. package/src/layout/layout-hooks.ts +0 -68
  162. package/src/layout/layout-state.ts +0 -107
  163. package/src/layout/layout.interface.ts +0 -101
  164. package/src/layout/layout.ts +0 -80
  165. package/src/layout/view-id.ts +0 -18
  166. package/src/logger/browser-logger.ts +0 -51
  167. package/src/logger/index.ts +0 -1
  168. package/src/markdown/index.tsx +0 -62
  169. package/src/menu/next/base.ts +0 -513
  170. package/src/menu/next/ctxmenu-service.ts +0 -188
  171. package/src/menu/next/index.ts +0 -10
  172. package/src/menu/next/menu-id.ts +0 -86
  173. package/src/menu/next/menu-service.ts +0 -252
  174. package/src/menu/next/menu-util.ts +0 -77
  175. package/src/menu/next/menu.contrib.interface.ts +0 -79
  176. package/src/menu/next/menu.interface.ts +0 -253
  177. package/src/menu/next/menubar-service.ts +0 -211
  178. package/src/menu/next/renderer/ctxmenu/base.ts +0 -18
  179. package/src/menu/next/renderer/ctxmenu/browser.ts +0 -45
  180. package/src/menu/next/renderer/ctxmenu/electron.ts +0 -207
  181. package/src/menu/next/toolbar-action.service.ts +0 -132
  182. package/src/monaco/index.ts +0 -128
  183. package/src/opener/command-opener.ts +0 -42
  184. package/src/opener/default-opener.ts +0 -31
  185. package/src/opener/http-opener.ts +0 -25
  186. package/src/opener/index.ts +0 -19
  187. package/src/opener/opener.contribution.ts +0 -57
  188. package/src/opener/opener.service.ts +0 -66
  189. package/src/preferences/early-preferences.ts +0 -117
  190. package/src/preferences/index.ts +0 -9
  191. package/src/preferences/preference-configurations.ts +0 -77
  192. package/src/preferences/preference-contribution.ts +0 -401
  193. package/src/preferences/preference-provider.ts +0 -414
  194. package/src/preferences/preference-proxy.ts +0 -292
  195. package/src/preferences/preference-scope.ts +0 -3
  196. package/src/preferences/preference-service.ts +0 -571
  197. package/src/preferences/settings.ts +0 -53
  198. package/src/preferences/types.ts +0 -111
  199. package/src/progress/index.ts +0 -58
  200. package/src/progress/progress-bar.tsx +0 -22
  201. package/src/progress/progress-indicator.ts +0 -90
  202. package/src/progress/progress.module.less +0 -46
  203. package/src/progress/progress.service.tsx +0 -429
  204. package/src/quick-open/index.ts +0 -655
  205. package/src/quick-open/recent-files.ts +0 -68
  206. package/src/raw-context-key.ts +0 -116
  207. package/src/react-hooks/event.tsx +0 -80
  208. package/src/react-hooks/hot-key.tsx +0 -58
  209. package/src/react-hooks/index.ts +0 -3
  210. package/src/react-hooks/injectable-hooks.tsx +0 -35
  211. package/src/react-hooks/portal-hooks.tsx +0 -38
  212. package/src/react-providers/config-provider.tsx +0 -263
  213. package/src/react-providers/index.tsx +0 -2
  214. package/src/react-providers/slot.module.less +0 -19
  215. package/src/react-providers/slot.tsx +0 -242
  216. package/src/services/clipboard.service.ts +0 -97
  217. package/src/services/credentials-service.ts +0 -91
  218. package/src/services/crypto-service.ts +0 -23
  219. package/src/services/external-uri.service.ts +0 -68
  220. package/src/services/index.ts +0 -7
  221. package/src/services/label-service.ts +0 -386
  222. package/src/services/status-bar-service.ts +0 -108
  223. package/src/services/storage-service.ts +0 -197
  224. package/src/style/codicons/README.md +0 -22
  225. package/src/style/codicons/codicon-animations.css +0 -15
  226. package/src/style/codicons/generator.js +0 -15
  227. package/src/style/entry.less +0 -25
  228. package/src/style/icon/fileicons/file-default.svg +0 -1
  229. package/src/style/icon/fileicons/folder-default.svg +0 -1
  230. package/src/style/icon/fileicons.less +0 -20
  231. package/src/style/icon/icon.ts +0 -543
  232. package/src/style/icon/ide-iconfont.ts +0 -13
  233. package/src/style/icon/index.less +0 -54
  234. package/src/style/icon/seti.woff +0 -0
  235. package/src/style/icon/symbol-icons/boolean-dark.svg +0 -3
  236. package/src/style/icon/symbol-icons/boolean-light.svg +0 -3
  237. package/src/style/icon/symbol-icons/class-dark.svg +0 -3
  238. package/src/style/icon/symbol-icons/class-light.svg +0 -3
  239. package/src/style/icon/symbol-icons/constant-dark.svg +0 -4
  240. package/src/style/icon/symbol-icons/constant-light.svg +0 -4
  241. package/src/style/icon/symbol-icons/enumerator-dark.svg +0 -3
  242. package/src/style/icon/symbol-icons/enumerator-item-dark.svg +0 -3
  243. package/src/style/icon/symbol-icons/enumerator-item-light.svg +0 -3
  244. package/src/style/icon/symbol-icons/enumerator-light.svg +0 -3
  245. package/src/style/icon/symbol-icons/event-dark.svg +0 -3
  246. package/src/style/icon/symbol-icons/event-light.svg +0 -3
  247. package/src/style/icon/symbol-icons/field-dark.svg +0 -3
  248. package/src/style/icon/symbol-icons/field-light.svg +0 -3
  249. package/src/style/icon/symbol-icons/file-dark.svg +0 -3
  250. package/src/style/icon/symbol-icons/file-light.svg +0 -3
  251. package/src/style/icon/symbol-icons/indexer-dark.svg +0 -3
  252. package/src/style/icon/symbol-icons/indexer-light.svg +0 -3
  253. package/src/style/icon/symbol-icons/interface-dark.svg +0 -3
  254. package/src/style/icon/symbol-icons/interface-light.svg +0 -3
  255. package/src/style/icon/symbol-icons/keyword-dark.svg +0 -3
  256. package/src/style/icon/symbol-icons/keyword-light.svg +0 -3
  257. package/src/style/icon/symbol-icons/method-dark.svg +0 -3
  258. package/src/style/icon/symbol-icons/method-light.svg +0 -3
  259. package/src/style/icon/symbol-icons/namespace-dark.svg +0 -3
  260. package/src/style/icon/symbol-icons/namespace-light.svg +0 -3
  261. package/src/style/icon/symbol-icons/numeric-dark.svg +0 -3
  262. package/src/style/icon/symbol-icons/numeric-light.svg +0 -3
  263. package/src/style/icon/symbol-icons/operator-dark.svg +0 -3
  264. package/src/style/icon/symbol-icons/operator-light.svg +0 -3
  265. package/src/style/icon/symbol-icons/property-dark.svg +0 -3
  266. package/src/style/icon/symbol-icons/property-light.svg +0 -3
  267. package/src/style/icon/symbol-icons/snippet-dark.svg +0 -3
  268. package/src/style/icon/symbol-icons/snippet-light.svg +0 -3
  269. package/src/style/icon/symbol-icons/string-dark.svg +0 -3
  270. package/src/style/icon/symbol-icons/string-light.svg +0 -3
  271. package/src/style/icon/symbol-icons/structure-dark.svg +0 -3
  272. package/src/style/icon/symbol-icons/structure-light.svg +0 -3
  273. package/src/style/icon/symbol-icons/symbol-icons.css +0 -284
  274. package/src/style/icon/symbol-icons/template-dark.svg +0 -3
  275. package/src/style/icon/symbol-icons/template-light.svg +0 -3
  276. package/src/style/icon/symbol-icons/variable-dark.svg +0 -3
  277. package/src/style/icon/symbol-icons/variable-light.svg +0 -3
  278. package/src/style/icon.less +0 -8
  279. package/src/style/index.less +0 -14
  280. package/src/style/monaco-override.less +0 -116
  281. package/src/style/normalize.less +0 -92
  282. package/src/style/octicons/octicons-cdn.css +0 -720
  283. package/src/style/octicons/octicons.css +0 -714
  284. package/src/style/octicons/octicons.html +0 -1882
  285. package/src/style/octicons/octicons.svg +0 -582
  286. package/src/style/octicons/octicons.ttf +0 -0
  287. package/src/style/override.less +0 -97
  288. package/src/style/toolbar.less +0 -199
  289. package/src/style/utilities.less +0 -8
  290. package/src/style/variable.less +0 -8
  291. package/src/terminal/index.ts +0 -7
  292. package/src/toolbar/components/auto-complete.tsx +0 -0
  293. package/src/toolbar/components/button.tsx +0 -440
  294. package/src/toolbar/components/index.ts +0 -2
  295. package/src/toolbar/components/select.tsx +0 -189
  296. package/src/toolbar/index.ts +0 -3
  297. package/src/toolbar/toolbar.popover.registry.ts +0 -32
  298. package/src/toolbar/toolbar.registry.ts +0 -352
  299. package/src/toolbar/toolbar.tsx +0 -710
  300. package/src/toolbar/types.ts +0 -383
  301. package/src/tree/index.ts +0 -3
  302. package/src/tree/tree-expansion.ts +0 -25
  303. package/src/tree/tree-selection.ts +0 -89
  304. package/src/tree/tree.ts +0 -294
  305. package/src/utils/create-overlay.tsx +0 -53
  306. package/src/utils/electron.ts +0 -92
  307. package/src/utils/env.ts +0 -26
  308. package/src/utils/icon.ts +0 -13
  309. package/src/utils/index.ts +0 -7
  310. package/src/utils/json.ts +0 -251
  311. package/src/utils/label.tsx +0 -36
  312. package/src/utils/parse.ts +0 -72
  313. package/src/utils/react-hooks.ts +0 -118
  314. package/src/variable/index.ts +0 -1
  315. package/src/variable/variable.ts +0 -84
  316. package/src/window/index.ts +0 -34
  317. package/src/window/window.service.ts +0 -100
@@ -1,116 +0,0 @@
1
- import { ContextKeyValue } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
2
-
3
- import { IContextKeyService, IContextKey } from './context-key';
4
-
5
- export abstract class IRawContextKey<T extends ContextKeyValue> {
6
- raw: string;
7
- not: string;
8
- abstract equalsTo(value: string): string;
9
- abstract notEqualTo(value: string): string;
10
- abstract regexMatches(regexp: RegExp): string;
11
- abstract bind(target: IContextKeyService): IContextKey<T>;
12
- abstract getValue(target: IContextKeyService): T | undefined;
13
- }
14
-
15
- type ContextkeyCombinedClause<T extends ContextKeyValue = ContextKeyValue> = Array<RawContextKey<T> | string>;
16
-
17
- function whenNormalizer(arr: ContextkeyCombinedClause, separator: '&&' | '||'): string {
18
- const result: string[] = [];
19
- if (Array.isArray(arr) && arr.length) {
20
- for (const item of arr) {
21
- if (item instanceof RawContextKey) {
22
- result.push(item.raw);
23
- } else {
24
- result.push(item);
25
- }
26
- }
27
- }
28
-
29
- return result.join(' ' + separator + ' ');
30
- }
31
-
32
- /**
33
- * 我们目前的 when 的使用并没有直接使用 monaco.contextkey.ContextKeyExpr
34
- * 实现了 bind/getValue 方法
35
- * 实现了 and/or/not/equals/notEquals/regexMatches 等工具方法
36
- * 实现了类似效果:
37
- * when: RawContextKey.and(ExplorerRootContext, ExplorerFolderContext)
38
- * 参考 https://code.visualstudio.com/docs/getstarted/keybindings#_when-clause-contexts
39
- */
40
- export class RawContextKey<T extends ContextKeyValue> implements IRawContextKey<T> {
41
- private key: string;
42
- private defaultValue: T | undefined;
43
-
44
- /**
45
- * and alias '&&'
46
- */
47
- static and(...args: ContextkeyCombinedClause): string {
48
- if (!args.length) {
49
- return '';
50
- }
51
- return whenNormalizer(args, '&&');
52
- }
53
-
54
- /**
55
- * or alias '||'
56
- */
57
- static or(...args: ContextkeyCombinedClause) {
58
- if (!args.length) {
59
- return '';
60
- }
61
- return whenNormalizer(args, '||');
62
- }
63
-
64
- constructor(key: string, defaultValue: T | undefined) {
65
- this.key = key;
66
- this.defaultValue = defaultValue;
67
- }
68
-
69
- public bind(target: IContextKeyService): IContextKey<T> {
70
- return target.createKey(this.key, this.defaultValue);
71
- }
72
-
73
- public getValue(target: IContextKeyService): T | undefined {
74
- return target.getContextValue<T>(this.key);
75
- }
76
-
77
- /**
78
- * maybe you don't need use this directly
79
- */
80
- public get raw() {
81
- return this.key;
82
- }
83
-
84
- /**
85
- * get negated value
86
- */
87
- public get not() {
88
- return '!' + this.raw;
89
- }
90
-
91
- /**
92
- * is equal to
93
- */
94
- public equalsTo<T = string>(value: T): string {
95
- return this.raw + ' == ' + value;
96
- }
97
-
98
- /**
99
- * is not equal to
100
- */
101
- public notEqualTo(value: string): string {
102
- return this.raw + ' != ' + value;
103
- }
104
-
105
- /**
106
- * matches regex
107
- */
108
- public regexMatches(regexp: RegExp): string {
109
- const regexpStr = regexp ? `/${regexp.source}/${regexp.ignoreCase ? 'i' : ''}` : '/invalid/';
110
- return this.raw + ' =~ ' + regexpStr;
111
- }
112
-
113
- public evaluate(target: IContextKeyService): boolean {
114
- return !!target.getValue(this.key);
115
- }
116
- }
@@ -1,80 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Event, Disposable, ConstructorOf, BasicEvent, IEventBus } from '@opensumi/ide-core-common';
4
-
5
- import { useInjectable } from './injectable-hooks';
6
-
7
- /**
8
- * 在事件来临时更新当前元素
9
- * 会自动 dispose 监听器
10
- * @param event 要监听的事件
11
- * @param dependencies React.useEffect的依赖
12
- * @param condition 返回 true 时
13
- */
14
- export function useUpdateOnEvent<T = any>(
15
- event: Event<T>,
16
- dependencies: any[] = [],
17
- condition?: (payload: T) => boolean,
18
- ) {
19
- const [, updateState] = React.useState<any>();
20
- const forceUpdate = React.useCallback(() => updateState({}), []);
21
-
22
- React.useEffect(() => {
23
- const disposer = new Disposable();
24
- disposer.addDispose(
25
- event((payload: T) => {
26
- if (disposer.disposed) {
27
- return;
28
- }
29
- if (!condition) {
30
- forceUpdate();
31
- } else {
32
- if (condition(payload)) {
33
- forceUpdate();
34
- }
35
- }
36
- }),
37
- );
38
- return () => {
39
- disposer.dispose();
40
- };
41
- }, dependencies);
42
- }
43
-
44
- export function useUpdateOnEventBusEvent<T = any>(
45
- eventType: ConstructorOf<BasicEvent<T>>,
46
- dependencies: any[] = [],
47
- condition?: (payload: T) => boolean,
48
- ) {
49
- const [, updateState] = React.useState<any>();
50
- const forceUpdate = React.useCallback(() => updateState({}), []);
51
- const eventBus: IEventBus = useInjectable(IEventBus);
52
-
53
- React.useEffect(() => {
54
- const disposer = new Disposable();
55
- disposer.addDispose(
56
- eventBus.on(eventType, (event: BasicEvent<T>) => {
57
- if (disposer.disposed) {
58
- return;
59
- }
60
- if (!condition) {
61
- forceUpdate();
62
- } else {
63
- if (condition(event.payload)) {
64
- forceUpdate();
65
- }
66
- }
67
- }),
68
- );
69
- return () => {
70
- disposer.dispose();
71
- };
72
- }, dependencies);
73
- }
74
-
75
- export function useEventEffect<T = any>(event: Event<T>, listener: (args: T) => void, dependencies: any[] = []) {
76
- React.useEffect(() => {
77
- const disposable = event(listener);
78
- return disposable.dispose.bind(disposable);
79
- }, dependencies);
80
- }
@@ -1,58 +0,0 @@
1
- import keycode from 'keycode';
2
- import { useState, useCallback } from 'react';
3
-
4
- // todo: hotkeys 增加类型提示
5
- // 键位值请查看 https://github.com/timoxley/keycode
6
- export const useHotKey = (
7
- hotkeys: string[],
8
- handler: () => void,
9
- ): {
10
- onKeyDown: (keyCode: number) => void;
11
- onKeyUp: () => void;
12
- } => {
13
- // 初始化函数
14
- const initializer = useCallback(
15
- () =>
16
- hotkeys.reduce((prev, key) => {
17
- const keycodeNum = keycode(key);
18
- if (typeof keycodeNum === 'number') {
19
- prev[keycodeNum] = false;
20
- }
21
- return prev;
22
- }, {}),
23
- [hotkeys],
24
- );
25
-
26
- const [keyPressRecords, setKeyPressRecords] = useState<{
27
- [key: string]: boolean;
28
- }>(initializer);
29
-
30
- function onKeyDown(keyCode: number) {
31
- setKeyPressRecords((r) => {
32
- if (keyCode in r) {
33
- return { ...r, [keyCode]: true };
34
- }
35
- return r;
36
- });
37
- }
38
-
39
- function onKeyUp() {
40
- // 快捷键匹配触发
41
- if (Object.values(keyPressRecords).every((n) => n === true)) {
42
- handler();
43
- }
44
-
45
- // reset value
46
- setKeyPressRecords((r) =>
47
- Object.keys(keyPressRecords).reduce((prev, keyNum) => {
48
- prev[keyNum] = false;
49
- return prev;
50
- }, {}),
51
- );
52
- }
53
-
54
- return {
55
- onKeyDown,
56
- onKeyUp,
57
- };
58
- };
@@ -1,3 +0,0 @@
1
- export * from './injectable-hooks';
2
- export * from './portal-hooks';
3
- export * from './event';
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
-
3
- import { Token, Injector } from '@opensumi/di';
4
- import { Disposable } from '@opensumi/ide-core-common';
5
-
6
- import { ConfigContext } from '../react-providers/config-provider';
7
-
8
- function isDisposable(target: any): target is Disposable {
9
- return target && (target as any).dispose;
10
- }
11
-
12
- export function useInjectable<T = any>(Constructor: Token, args?: any): T {
13
- const { injector } = React.useContext(ConfigContext);
14
-
15
- const instance = React.useMemo(() => injector.get(Constructor, args), [injector, Constructor]);
16
-
17
- React.useEffect(
18
- () => () => {
19
- // 如果这是多例模式,DI 中不会留有这个实例对象
20
- // 由于实例可能存在在父 injector 中,需要做一下递归判断
21
- let curr: Injector | undefined = injector;
22
- while (curr && !curr.hasInstance(instance)) {
23
- curr = (curr as any).parent;
24
- }
25
- if (!curr) {
26
- if (isDisposable(instance)) {
27
- instance.dispose();
28
- }
29
- }
30
- },
31
- [instance],
32
- );
33
-
34
- return instance;
35
- }
@@ -1,38 +0,0 @@
1
- import { useRef, useEffect } from 'react';
2
-
3
- function createRootElement(id: string) {
4
- const rootContainer = document.createElement('div');
5
- rootContainer.setAttribute('id', id);
6
- return rootContainer;
7
- }
8
-
9
- export function usePortal(id: string) {
10
- const rootElemRef = useRef<HTMLDivElement | null>(null);
11
-
12
- useEffect(() => {
13
- const existingParent = document.querySelector(`#${id}`);
14
- const parentElem = existingParent || createRootElement(id);
15
-
16
- if (!existingParent) {
17
- document.body.appendChild(parentElem);
18
- }
19
-
20
- if (rootElemRef.current) {
21
- parentElem.appendChild(rootElemRef.current);
22
- }
23
-
24
- return () => {
25
- if (rootElemRef.current) {
26
- rootElemRef.current.remove();
27
- }
28
- if (parentElem.childNodes.length === -1) {
29
- parentElem.remove();
30
- }
31
- };
32
- }, []);
33
-
34
- if (!rootElemRef.current) {
35
- rootElemRef.current = document.createElement('div');
36
- }
37
- return rootElemRef.current;
38
- }
@@ -1,263 +0,0 @@
1
- import React from 'react';
2
-
3
- import type { Injector } from '@opensumi/di';
4
- import type {
5
- ExtensionBrowserStyleSheet,
6
- ExtensionCandidate,
7
- ExtensionConnectOption,
8
- UrlProvider,
9
- } from '@opensumi/ide-core-common';
10
-
11
- import type { IPreferences, LayoutConfig } from '../bootstrap';
12
-
13
- export const AppConfig = Symbol('AppConfig');
14
- export interface AppConfig {
15
- /**
16
- * APP的名称
17
- * 默认值为 `ClientApp.DEFAULT_APPLICATION_NAME` 即 `OPENSUMI`
18
- */
19
- appName?: string;
20
- /**
21
- * 应用程序的托管位置
22
- * 默认桌面端下为 `desktop`, Web 下为 `web`
23
- * 可以传入自定义的名称
24
- */
25
- appHost?: string;
26
- /**
27
- * 应用绝对安装路径
28
- *
29
- * 部分插件,如 `typescript-vue-language-features` 可能会基于该路径获取相关依赖地址
30
- * refs: https://github.com/search?q=getVscodeTypescriptPath&type=code
31
- *
32
- * 注意: 在没有应用绝对安装路径的环境中运行时,该值是空字符
33
- */
34
- appRoot?: string;
35
- /**
36
- * 默认内部的 uriScheme,用于桌面版 app 的唤起
37
- * 同时也默认为 vscode.env.uriScheme 的值
38
- * 默认值为 `ClientApp.DEFAULT_URI_SCHEME` 即 `sumi`
39
- */
40
- uriScheme?: string;
41
- /**
42
- * 打开的工作区路径
43
- */
44
- workspaceDir: string;
45
- /**
46
- * 插件目录路径
47
- */
48
- extensionDir?: string;
49
- /**
50
- * 设置全局存储的文件夹名称
51
- * 默认值为 .sumi
52
- */
53
- storageDirName?: string;
54
- /**
55
- * 设置工作区配置文件的文件夹名称
56
- * 默认值为 .sumi
57
- */
58
- preferenceDirName?: string;
59
- /**
60
- * 更精细的项目工作区配置存储位置
61
- * 即当 preferenceDirName = '.sumi' , workspacePreferenceDirName = '.o2'时,
62
- * 对应全局配置为 ~/.sumi/settings.json , 工作区配置为 {workspaceDir}/.o2/settings.json
63
- */
64
- workspacePreferenceDirName?: string;
65
- /**
66
- * 更精细的项目用户配置存储位置
67
- * 即当 preferenceDirName = '.sumi' , userPreferenceDirName = '.o2'时,
68
- * 对应全局配置为 ~/.sumi/settings.json , 工作区配置为 {userDir}/.o2/settings.json
69
- */
70
- userPreferenceDirName?: string;
71
- /**
72
- * 全局插件数据存储目录名称,默认 .sumi
73
- */
74
- extensionStorageDirName?: string;
75
- /**
76
- * 默认配置
77
- */
78
- defaultPreferences?: IPreferences;
79
- /**
80
- * 初始化的 DI 实例,一般可在外部进行 DI 初始化之后传入,便于提前进行一些依赖的初始化
81
- */
82
- injector: Injector;
83
- /**
84
- * 定义 WebScoket 通信路径
85
- */
86
- wsPath: UrlProvider;
87
- /**
88
- * 定义 IDE 各个布局区块默认加载的模块,可针对性对模块进行增删改
89
- * 默认值可参考:https://github.com/opensumi/core/tree/58b998d9e1f721928f576579f16ded46b7505e84/packages/main-layout/src/browser/default-config.ts
90
- */
91
- layoutConfig: LayoutConfig;
92
- /**
93
- * 定义 IDE 的整体布局,可以通过传入自定义布局的方式定义各个区块的默认大小及缩放选项等
94
- * 默认值可参考:https://github.com/opensumi/core/blob/58b998d9e1f721928f576579f16ded46b7505e84/packages/core-browser/src/components/layout/default-layout.tsx
95
- */
96
- layoutComponent?: React.FC;
97
- /**
98
- * 可基于 `layoutComponent` 配置的基础上
99
- * 定义面板大小,宽度/高度
100
- */
101
- panelSizes?: { [slotLocation: string]: number };
102
- /**
103
- * 定义各个区块的默认面板
104
- * 如:{ [SlotLocation.bottom]: '@opensumi/ide-terminal-next' }
105
- * 定义了底部区块默认使用 `@opensumi/ide-terminal-next` 模块进行初始化
106
- */
107
- defaultPanels?: { [slotLocation: string]: string };
108
- /**
109
- * 用于挂载webview的iframe地址
110
- * 默认值:`http://${deviceIp}:${port}/webview`,
111
- */
112
- webviewEndpoint?: string;
113
- /**
114
- * Worker 插件的默认启动路径
115
- * 默认值为: https://dev.g.alicdn.com/tao-ide/ide-lite/${version}/worker-host.js
116
- */
117
- extWorkerHost?: string;
118
- /**
119
- * 额外指定的插件路径,一般用于内置插件
120
- */
121
- extensionCandidate?: ExtensionCandidate[];
122
- /**
123
- * 定义静态资源的加载路径
124
- * 默认值为:`http://${HOST}:8000/assets/${path}`
125
- */
126
- staticServicePath?: string;
127
- /**
128
- * 定义是否以插件开发模式启动
129
- */
130
- extensionDevelopmentHost?: boolean;
131
- /**
132
- * 定义编辑器默认背景图片
133
- */
134
- editorBackgroundImage?: string;
135
- /**
136
- * 用于插件 UI 部分开启实验性 ShadowDOM
137
- */
138
- useExperimentalShadowDom?: boolean;
139
- /**
140
- * 加载 workerHost 时使用 iframe 包装
141
- * 对于跨域的场景,加载 workerHost 时会使用 base64 编码后通过 importScripts 引入(importScripts 不受跨域限制)
142
- * 但这会导致 workerHost 的 origin 为 null,使某些请求失败
143
- */
144
- useIframeWrapWorkerHost?: boolean;
145
-
146
- /**
147
- * 忽略 Worker Host 可能出现的跨域问题
148
- */
149
- ignoreWorkerHostCors?: boolean;
150
- /**
151
- * 自定义客户端 id,是 websocket 服务的唯一标识
152
- * 也是传给声明了 backServices 的后端 Service 的唯一标识
153
- * 注意保持这个 id 的唯一性
154
- */
155
- clientId?: string;
156
- /**
157
- * 是否禁用插件进程
158
- */
159
- noExtHost?: boolean;
160
- /**
161
- * @ClientOption
162
- * 额外的 ConfigProvider
163
- * 可以让 IDE-framework 内部的 ReactDOM.render 调用时
164
- * 都被其包裹一层,以达到额外的 context 传递效果
165
- */
166
- extraContextProvider?: React.ComponentType<React.PropsWithChildren<any>>;
167
- /**
168
- * @ClientOption
169
- * @default true
170
- * 允许按照工作区路径去动态设置 document#title, 默认为 true
171
- */
172
- allowSetDocumentTitleFollowWorkspaceDir?: boolean;
173
- /**
174
- * @ClientOption
175
- * 远程访问地址,可以通过该地址访问当容器服务
176
- * 默认为 window.location.hostname
177
- */
178
- remoteHostname?: string;
179
- /**
180
- * 开启插件进程的调试能力,默认为 false
181
- */
182
- enableDebugExtensionHost?: boolean;
183
- /**
184
- * 加载插件前端资源时的 fetch credentials 选项
185
- * 可选项为 "include" | "omit" | "same-origin"
186
- */
187
- extensionFetchCredentials?: RequestCredentials;
188
- /**
189
- * 插件进程连接时候一些配置选项
190
- */
191
- extensionConnectOption?: ExtensionConnectOption;
192
- /**
193
- * 当 DOM 首次渲染完成后调用
194
- * 此时表示 IDE 界面已经完成渲染并可以操作
195
- */
196
- didRendered?: () => void;
197
- /**
198
- * @deprecated
199
- * vscode-oniguruma-wasm 资源地址,在 Windows 版本中很容易传送错误的地址,请使用 onigWasmUri 参数
200
- */
201
- onigWasmPath?: string;
202
- /**
203
- * vscode-oniguruma-wasm 资源 Uri 地址
204
- */
205
- onigWasmUri?: string;
206
- /**
207
- * 工作区文件后缀,默认后缀为 `sumi-workspace`
208
- */
209
- workspaceSuffixName?: string;
210
- /**
211
- * 视图组件内默认的组件样式资源 CDN 来源
212
- * 默认值为 'alipay'
213
- */
214
- componentCDNType?: 'unpkg' | 'jsdelivr' | 'alipay';
215
- /**
216
- * 指定前端是否为 Electron 环境 (Electron Renderer)
217
- * 为兼容老的逻辑,若不兼容则 fallback 到 isElectronRenderer 的判断
218
- * 新版本中建议优先使用 isElectronRenderer
219
- */
220
- isElectronRenderer: boolean;
221
- /**
222
- * 指定当前是否通过 remote 模式连接到远程的 Server 端
223
- * 这将影响 Terminal 与 Extension 模块与子进程的连接方式
224
- */
225
- isRemote?: boolean;
226
- /**
227
- * 是否开启对 OpenSumi DevTools 的支持
228
- * 默认值为 false
229
- */
230
- devtools?: boolean;
231
- /**
232
- * 配置插件 browser 层的 component 样式文件和 iconfont 样式文件
233
- */
234
- extensionBrowserStyleSheet?: ExtensionBrowserStyleSheet;
235
- /**
236
- * 是否采用工作区内的 .vscode 配置作为项目启动的配置默认值
237
- */
238
- useVSCodeWorkspaceConfiguration?: boolean;
239
- }
240
-
241
- export const ConfigContext = React.createContext<AppConfig>({
242
- workspaceDir: '',
243
- injector: null as any,
244
- wsPath: '',
245
- layoutConfig: {},
246
- extWorkerHost: '',
247
- isElectronRenderer: false,
248
- });
249
-
250
- export function ConfigProvider(props: React.PropsWithChildren<{ value: AppConfig }>) {
251
- const { extraContextProvider, ...restPropsValue } = props.value;
252
- const app = (
253
- <ConfigContext.Provider value={restPropsValue}>
254
- <ConfigContext.Consumer>{(value) => (restPropsValue === value ? props.children : null)}</ConfigContext.Consumer>
255
- </ConfigContext.Provider>
256
- );
257
-
258
- if (!extraContextProvider) {
259
- return app;
260
- }
261
-
262
- return React.createElement(extraContextProvider, { children: app });
263
- }
@@ -1,2 +0,0 @@
1
- export * from './config-provider';
2
- export * from './slot';
@@ -1,19 +0,0 @@
1
- .error_message {
2
- padding: 15px;
3
- .title {
4
- color: var(--foreground);
5
- font-size: 18px;
6
- }
7
- .detial {
8
- white-space: pre-wrap;
9
- margin-bottom: 10px;
10
- cursor: pointer;
11
- .label,
12
- .message {
13
- color: var(--kt-inputValidation-errorTextForeground);
14
- }
15
- .label {
16
- font-weight: bold;
17
- }
18
- }
19
- }