@opensumi/ide-core-browser 2.23.3-next-1681270416.0 → 2.23.3

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 (46) hide show
  1. package/lib/bootstrap/app.d.ts.map +1 -1
  2. package/lib/bootstrap/app.js +8 -6
  3. package/lib/bootstrap/app.js.map +1 -1
  4. package/lib/bootstrap/inner-providers.js +4 -4
  5. package/lib/bootstrap/inner-providers.js.map +1 -1
  6. package/lib/components/layout/default-layout.d.ts.map +1 -1
  7. package/lib/components/layout/default-layout.js +2 -2
  8. package/lib/components/layout/default-layout.js.map +1 -1
  9. package/lib/components/layout/layout.d.ts +4 -4
  10. package/lib/components/layout/split-panel.d.ts.map +1 -1
  11. package/lib/components/layout/split-panel.js +1 -1
  12. package/lib/components/layout/split-panel.js.map +1 -1
  13. package/lib/components/resize/resize.d.ts.map +1 -1
  14. package/lib/components/resize/resize.js +27 -50
  15. package/lib/components/resize/resize.js.map +1 -1
  16. package/lib/react-providers/slot.d.ts +3 -0
  17. package/lib/react-providers/slot.d.ts.map +1 -1
  18. package/lib/react-providers/slot.js +3 -3
  19. package/lib/react-providers/slot.js.map +1 -1
  20. package/lib/utils/electron.d.ts +1 -1
  21. package/lib/utils/electron.d.ts.map +1 -1
  22. package/lib/utils/electron.js +1 -26
  23. package/lib/utils/electron.js.map +1 -1
  24. package/lib/utils/index.d.ts +1 -0
  25. package/lib/utils/index.d.ts.map +1 -1
  26. package/lib/utils/index.js +1 -0
  27. package/lib/utils/index.js.map +1 -1
  28. package/lib/utils/label.d.ts +1 -1
  29. package/lib/utils/label.d.ts.map +1 -1
  30. package/lib/utils/label.js +4 -11
  31. package/lib/utils/label.js.map +1 -1
  32. package/lib/utils/parse.d.ts +26 -0
  33. package/lib/utils/parse.d.ts.map +1 -0
  34. package/lib/utils/parse.js +81 -0
  35. package/lib/utils/parse.js.map +1 -0
  36. package/package.json +5 -5
  37. package/src/bootstrap/app.ts +3 -2
  38. package/src/bootstrap/inner-providers.ts +4 -4
  39. package/src/components/layout/default-layout.tsx +2 -4
  40. package/src/components/layout/split-panel.tsx +2 -4
  41. package/src/components/resize/resize.tsx +26 -50
  42. package/src/react-providers/slot.tsx +8 -9
  43. package/src/utils/electron.ts +2 -35
  44. package/src/utils/index.ts +1 -0
  45. package/src/utils/label.tsx +4 -17
  46. package/src/utils/parse.ts +82 -0
@@ -1,4 +1,4 @@
1
- import { IDisposable, isUndefined } from '@opensumi/ide-core-common';
1
+ import { IDisposable } from '@opensumi/ide-core-common';
2
2
  import { IElectronMainApi } from '@opensumi/ide-core-common/lib/electron';
3
3
  import type { MessageConnection } from '@opensumi/vscode-jsonrpc';
4
4
 
@@ -12,37 +12,13 @@ export interface IElectronIpcRenderer {
12
12
  send(channel: string, ...args: any[]): void;
13
13
  }
14
14
 
15
- interface IPCMessage {
16
- type: 'event' | 'request' | 'response';
17
- service: string;
18
- method: string;
19
- requestId?: number; // for connecting 'requst' and 'response'
20
- args: any[];
21
- }
22
-
23
- const getCapturer = () => {
24
- if (window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__?.captureIPC) {
25
- return window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__.captureIPC;
26
- }
27
- return;
28
- };
29
-
30
- const capture = (message: IPCMessage) => {
31
- const capturer = getCapturer();
32
- if (!isUndefined(capture)) {
33
- // if OpenSumi DevTools is opended
34
- capturer(message);
35
- }
36
- };
37
-
38
- export function createElectronMainApi(name: string, enableCaptured?: boolean): IElectronMainApi<any> {
15
+ export function createElectronMainApi(name: string): IElectronMainApi<any> {
39
16
  let id = 0;
40
17
  return new Proxy(
41
18
  {
42
19
  on: (event: string, listener: (...args) => void): IDisposable => {
43
20
  const wrappedListener = (e, eventName, ...args) => {
44
21
  if (eventName === event) {
45
- enableCaptured && capture({ type: 'event', service: name, method: event, args });
46
22
  return listener(...args);
47
23
  }
48
24
  };
@@ -63,7 +39,6 @@ export function createElectronMainApi(name: string, enableCaptured?: boolean): I
63
39
  new Promise((resolve, reject) => {
64
40
  const requestId = id++;
65
41
  ElectronIpcRenderer.send('request:' + name, method, requestId, ...args);
66
- enableCaptured && capture({ type: 'request', service: name, method: String(method), requestId, args });
67
42
  const listener = (event, id, error, result) => {
68
43
  if (id === requestId) {
69
44
  ElectronIpcRenderer.removeListener('response:' + name, listener);
@@ -74,14 +49,6 @@ export function createElectronMainApi(name: string, enableCaptured?: boolean): I
74
49
  } else {
75
50
  resolve(result);
76
51
  }
77
- enableCaptured &&
78
- capture({
79
- type: 'response',
80
- service: name,
81
- method: String(method),
82
- requestId,
83
- args: [error, result],
84
- });
85
52
  }
86
53
  };
87
54
  ElectronIpcRenderer.on('response:' + name, listener);
@@ -2,5 +2,6 @@ export * from './env';
2
2
  export * from './electron';
3
3
  export * from './react-hooks';
4
4
  export * from './icon';
5
+ export * from './parse';
5
6
  export * from './json';
6
7
  export * from './label';
@@ -1,4 +1,3 @@
1
- import clx from 'classnames';
2
1
  import React, { CSSProperties } from 'react';
3
2
 
4
3
  import { Icon } from '@opensumi/ide-components/lib/icon/icon';
@@ -8,42 +7,30 @@ const SEPERATOR = ' ';
8
7
 
9
8
  export function transformLabelWithCodicon(
10
9
  label: string,
11
- iconStyleProps: CSSProperties | string = {},
10
+ iconStyles: CSSProperties = {},
12
11
  transformer?: (str: string) => string | undefined,
13
12
  renderText?: (str: string, index: number) => React.ReactNode,
14
13
  ) {
15
14
  const ICON_REGX = /\$\(([a-z.]+\/)?([a-z-]+)(~[a-z]+)?\)/gi;
16
15
  const ICON_WITH_ANIMATE_REGX = /\$\(([a-z.]+\/)?([a-z-]+)~([a-z]+)\)/gi;
17
- // some string like $() $(~spin)
18
- const ICON_ERROR_REGX = /\$\(([a-z.]+\/)?([a-z-]+)?(~[a-z]+)?\)/gi;
19
-
20
- const generateIconStyle = (icon?: string, styleProps?: CSSProperties | string) =>
21
- typeof styleProps === 'string' ? { className: clx(icon, styleProps) } : { className: icon, style: styleProps };
22
-
23
16
  return label.split(SEPERATOR).map((e, index) => {
24
17
  if (!transformer) {
25
18
  return e;
26
19
  }
27
20
  const icon = transformer(e);
28
21
  if (icon) {
29
- return <Icon {...generateIconStyle(icon, iconStyleProps)} key={`${index}-${icon}`} />;
22
+ return <Icon className={icon} style={iconStyles} key={`${index}-${icon}`} />;
30
23
  } else if (ICON_REGX.test(e)) {
31
24
  if (e.includes('~')) {
32
25
  const [, , icon, animate] = ICON_WITH_ANIMATE_REGX.exec(e) || [];
33
26
  if (animate && icon) {
34
27
  return (
35
- <Icon
36
- {...generateIconStyle(transformer(`$(${icon})`), iconStyleProps)}
37
- animate={animate}
38
- key={`${index}-${icon}`}
39
- />
28
+ <Icon className={transformer(`$(${icon})`)} style={iconStyles} animate={animate} key={`${index}-${icon}`} />
40
29
  );
41
30
  }
42
31
  }
43
32
  const newStr = e.replaceAll(ICON_REGX, (e) => `${SEPERATOR}${e}${SEPERATOR}`);
44
- return transformLabelWithCodicon(newStr, iconStyleProps, transformer);
45
- } else if (ICON_ERROR_REGX.test(e)) {
46
- return transformLabelWithCodicon(e.replaceAll(ICON_ERROR_REGX, ''), iconStyleProps, transformer, renderText);
33
+ return transformLabelWithCodicon(newStr, iconStyles, transformer);
47
34
  } else {
48
35
  return isFunction(renderText) ? renderText(e, index) : <span key={`${index}-${e}`}>{e}</span>;
49
36
  }
@@ -0,0 +1,82 @@
1
+ /** ******************************************************************************
2
+ * Copyright (C) 2018 Red Hat, Inc. and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ // Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/core/src/browser/label-parser.ts
17
+
18
+ export interface LabelIcon {
19
+ name: string;
20
+ owner?: string;
21
+ animation?: string;
22
+ }
23
+
24
+ export namespace LabelIcon {
25
+ export function is(val: object): val is LabelIcon {
26
+ return 'name' in val;
27
+ }
28
+ }
29
+
30
+ export type LabelPart = string | LabelIcon;
31
+
32
+ export function parseLabel(text: string): LabelPart[] {
33
+ const parserArray: LabelPart[] = [];
34
+ let arrPointer = 0;
35
+ let potentialIcon = '';
36
+
37
+ for (let idx = 0; idx < text.length; idx++) {
38
+ const char = text.charAt(idx);
39
+ parserArray[arrPointer] = parserArray[arrPointer] || '';
40
+ if (potentialIcon === '') {
41
+ if (char === '$') {
42
+ potentialIcon += char;
43
+ } else {
44
+ parserArray[arrPointer] += char;
45
+ }
46
+ } else if (potentialIcon === '$') {
47
+ if (char === '(') {
48
+ potentialIcon += char;
49
+ } else {
50
+ parserArray[arrPointer] += potentialIcon + char;
51
+ potentialIcon = '';
52
+ }
53
+ } else {
54
+ if (char === ')') {
55
+ const iconClassArr = potentialIcon.substring(2, potentialIcon.length).split('~');
56
+ let name = iconClassArr[0];
57
+ let owner: string | undefined;
58
+ if (name) {
59
+ const index = name.indexOf('/');
60
+ if (index !== -1) {
61
+ owner = name.substring(0, index);
62
+ name = name.substring(index + 1);
63
+ }
64
+ }
65
+ if (parserArray[arrPointer] !== '') {
66
+ arrPointer++;
67
+ }
68
+ parserArray[arrPointer] = { name, owner, animation: iconClassArr[1] };
69
+ arrPointer++;
70
+ potentialIcon = '';
71
+ } else {
72
+ potentialIcon += char;
73
+ }
74
+ }
75
+ }
76
+
77
+ if (potentialIcon !== '') {
78
+ parserArray[arrPointer] += potentialIcon;
79
+ }
80
+
81
+ return parserArray;
82
+ }