@codingame/monaco-vscode-view-common-service-override 31.0.0 → 32.0.0

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 (67) hide show
  1. package/index.js +3 -0
  2. package/package.json +3 -3
  3. package/service-override/vs/workbench/contrib/webview/browser/pre/service-worker.js +107 -88
  4. package/vscode/src/vs/sessions/common/theme.d.ts +21 -0
  5. package/vscode/src/vs/sessions/common/theme.js +126 -0
  6. package/vscode/src/vs/workbench/api/browser/viewsExtensionPoint.js +56 -56
  7. package/vscode/src/vs/workbench/browser/actions/helpActions.js +20 -20
  8. package/vscode/src/vs/workbench/browser/actions/listCommands.js +3 -3
  9. package/vscode/src/vs/workbench/browser/actions/navigationActions.js +6 -6
  10. package/vscode/src/vs/workbench/browser/parts/editor/editor.contribution.js +173 -168
  11. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.d.ts +1 -0
  12. package/vscode/src/vs/workbench/browser/parts/editor/editorConfiguration.js +31 -10
  13. package/vscode/src/vs/workbench/browser/parts/titlebar/menubar.contribution.d.ts +1 -0
  14. package/vscode/src/vs/workbench/browser/parts/titlebar/menubar.contribution.js +78 -0
  15. package/vscode/src/vs/workbench/browser/workbench.zenMode.contribution.d.ts +1 -0
  16. package/vscode/src/vs/workbench/browser/workbench.zenMode.contribution.js +140 -0
  17. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchy.contribution.js +12 -12
  18. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyPeek.js +3 -3
  19. package/vscode/src/vs/workbench/contrib/callHierarchy/browser/callHierarchyTree.js +3 -3
  20. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditor.contribution.js +8 -2
  21. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.d.ts +18 -0
  22. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.js +84 -1
  23. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.d.ts +11 -1
  24. package/vscode/src/vs/workbench/contrib/customEditor/browser/customEditors.js +184 -19
  25. package/vscode/src/vs/workbench/contrib/customEditor/common/contributedCustomEditors.js +9 -5
  26. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.d.ts +11 -0
  27. package/vscode/src/vs/workbench/contrib/customEditor/common/customEditor.js +9 -2
  28. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.d.ts +27 -1
  29. package/vscode/src/vs/workbench/contrib/customEditor/common/extensionPoint.js +44 -12
  30. package/vscode/src/vs/workbench/contrib/languageStatus/browser/languageStatus.js +7 -7
  31. package/vscode/src/vs/workbench/contrib/limitIndicator/browser/limitIndicator.contribution.js +8 -8
  32. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/commands.js +29 -29
  33. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/commands/devCommands.js +14 -14
  34. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditor.contribution.js +2 -2
  35. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/mergeEditorAccessibilityHelp.js +5 -5
  36. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/colors.js +13 -13
  37. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/conflictActions.js +20 -20
  38. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editorGutter.js +1 -1
  39. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/baseCodeEditorView.js +3 -3
  40. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/inputCodeEditorView.js +10 -10
  41. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/editors/resultCodeEditorView.js +3 -3
  42. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/mergeEditor.js +1 -1
  43. package/vscode/src/vs/workbench/contrib/mergeEditor/browser/view/viewModel.js +1 -1
  44. package/vscode/src/vs/workbench/contrib/preferences/browser/keyboardLayoutPicker.js +12 -12
  45. package/vscode/src/vs/workbench/contrib/sash/browser/sash.contribution.js +2 -2
  46. package/vscode/src/vs/workbench/contrib/scrollLocking/browser/scrollLocking.js +7 -7
  47. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchy.contribution.js +10 -10
  48. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyPeek.js +3 -3
  49. package/vscode/src/vs/workbench/contrib/typeHierarchy/browser/typeHierarchyTree.js +3 -3
  50. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.d.ts +3 -2
  51. package/vscode/src/vs/workbench/contrib/webview/browser/overlayWebview.js +16 -8
  52. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.d.ts +9 -5
  53. package/vscode/src/vs/workbench/contrib/webview/browser/resourceLoading.js +22 -5
  54. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.d.ts +4 -7
  55. package/vscode/src/vs/workbench/contrib/webview/browser/webviewElement.js +133 -32
  56. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewCommands.js +5 -5
  57. package/vscode/src/vs/workbench/contrib/webviewPanel/browser/webviewPanel.contribution.js +1 -1
  58. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.d.ts +0 -5
  59. package/vscode/src/vs/workbench/contrib/webviewView/browser/webviewViewPane.js +5 -27
  60. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.d.ts +15 -7
  61. package/vscode/src/vs/workbench/services/editor/browser/editorResolverService.js +129 -55
  62. package/vscode/src/vs/workbench/services/history/browser/historyService.js +9 -9
  63. package/vscode/src/vs/workbench/services/progress/browser/progressService.js +7 -7
  64. package/vscode/src/vs/workbench/services/untitled/common/untitledTextEditorHandler.js +1 -2
  65. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.d.ts +3 -2
  66. package/vscode/src/vs/workbench/services/views/browser/viewDescriptorService.js +31 -33
  67. package/vscode/src/vs/workbench/services/views/browser/viewsService.js +9 -9
@@ -1,8 +1,7 @@
1
1
  import { VSBufferReadableStream } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
2
2
  import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
3
3
  import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
4
- import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
5
- import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
4
+ import { ServicesAccessor } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
6
5
  import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
7
6
  export declare namespace WebviewResourceResponse {
8
7
  enum Type {
@@ -16,8 +15,9 @@ export declare namespace WebviewResourceResponse {
16
15
  readonly etag: string | undefined;
17
16
  readonly mtime: number | undefined;
18
17
  readonly mimeType: string;
18
+ readonly size: number;
19
19
  readonly type = Type.Success;
20
- constructor(stream: VSBufferReadableStream, etag: string | undefined, mtime: number | undefined, mimeType: string);
20
+ constructor(stream: VSBufferReadableStream, etag: string | undefined, mtime: number | undefined, mimeType: string, size: number);
21
21
  }
22
22
  const Failed: {
23
23
  readonly type: Type.Failed;
@@ -33,8 +33,12 @@ export declare namespace WebviewResourceResponse {
33
33
  }
34
34
  type StreamResponse = StreamSuccess | typeof Failed | typeof AccessDenied | NotModified;
35
35
  }
36
- export declare function loadLocalResource(requestUri: URI, options: {
36
+ export declare function loadLocalResource(accessor: ServicesAccessor, requestUri: URI, options: {
37
37
  ifNoneMatch: string | undefined;
38
38
  roots: ReadonlyArray<URI>;
39
- }, uriIdentityService: IUriIdentityService, fileService: IFileService, logService: ILogService, token: CancellationToken): Promise<WebviewResourceResponse.StreamResponse>;
39
+ range?: {
40
+ readonly start: number;
41
+ readonly end?: number;
42
+ };
43
+ }, token: CancellationToken): Promise<WebviewResourceResponse.StreamResponse>;
40
44
  export declare function getResourceToLoad(requestUri: URI, roots: ReadonlyArray<URI>, uriIdentityService: IUriIdentityService): URI | undefined;
@@ -3,6 +3,9 @@ import { isUNC } from '@codingame/monaco-vscode-api/vscode/vs/base/common/extpat
3
3
  import { Schemas } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
4
4
  import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
5
5
  import { FileOperationError, FileOperationResult } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files';
6
+ import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
7
+ import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
8
+ import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
6
9
  import { getWebviewContentMimeType } from '../../../../platform/webview/common/mimeTypes.js';
7
10
 
8
11
  var WebviewResourceResponse;
@@ -15,11 +18,12 @@ var WebviewResourceResponse;
15
18
  Type[Type["NotModified"] = 3] = "NotModified";
16
19
  })(Type = WebviewResourceResponse.Type || (WebviewResourceResponse.Type = {}));
17
20
  class StreamSuccess {
18
- constructor(stream, etag, mtime, mimeType) {
21
+ constructor(stream, etag, mtime, mimeType, size) {
19
22
  this.stream = stream;
20
23
  this.etag = etag;
21
24
  this.mtime = mtime;
22
25
  this.mimeType = mimeType;
26
+ this.size = size;
23
27
  this.type = Type.Success;
24
28
  }
25
29
  }
@@ -39,7 +43,10 @@ var WebviewResourceResponse;
39
43
  }
40
44
  WebviewResourceResponse.NotModified = NotModified;
41
45
  })(WebviewResourceResponse || (WebviewResourceResponse = {}));
42
- async function loadLocalResource(requestUri, options, uriIdentityService, fileService, logService, token) {
46
+ async function loadLocalResource(accessor, requestUri, options, token) {
47
+ const uriIdentityService = accessor.get(IUriIdentityService);
48
+ const fileService = accessor.get(IFileService);
49
+ const logService = accessor.get(ILogService);
43
50
  const resourceToLoad = getResourceToLoad(requestUri, options.roots, uriIdentityService);
44
51
  logService.trace(
45
52
  `Webview.loadLocalResource - trying to load resource. requestUri=${requestUri}, resourceToLoad=${resourceToLoad}`
@@ -52,13 +59,23 @@ async function loadLocalResource(requestUri, options, uriIdentityService, fileSe
52
59
  }
53
60
  const mime = getWebviewContentMimeType(requestUri);
54
61
  try {
55
- const result = await fileService.readFileStream(resourceToLoad, {
62
+ const readOptions = {
56
63
  etag: options.ifNoneMatch
57
- }, token);
64
+ };
65
+ if (options.range) {
66
+ readOptions.position = options.range.start;
67
+ if (options.range.end !== undefined) {
68
+ if (options.range.end < options.range.start) {
69
+ return WebviewResourceResponse.Failed;
70
+ }
71
+ readOptions.length = options.range.end - options.range.start + 1;
72
+ }
73
+ }
74
+ const result = await fileService.readFileStream(resourceToLoad, readOptions, token);
58
75
  logService.trace(
59
76
  `Webview.loadLocalResource - Loaded. requestUri=${requestUri}, resourceToLoad=${resourceToLoad}`
60
77
  );
61
- return new WebviewResourceResponse.StreamSuccess(result.value, result.etag, result.mtime, mime);
78
+ return new WebviewResourceResponse.StreamSuccess(result.value, result.etag, result.mtime, mime, result.size);
62
79
  } catch (err) {
63
80
  if (err instanceof FileOperationError) {
64
81
  const result = err.fileOperationResult;
@@ -1,6 +1,5 @@
1
1
  import { IMouseWheelEvent } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/mouseEvent";
2
2
  import { CodeWindow } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/window";
3
- import { VSBufferReadableStream } from "@codingame/monaco-vscode-api/vscode/vs/base/common/buffer";
4
3
  import { Emitter, Event } from "@codingame/monaco-vscode-api/vscode/vs/base/common/event";
5
4
  import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
6
5
  import { URI } from "@codingame/monaco-vscode-api/vscode/vs/base/common/uri";
@@ -9,13 +8,11 @@ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/pl
9
8
  import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
10
9
  import { IContextMenuService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service";
11
10
  import { ExtensionIdentifier } from "@codingame/monaco-vscode-api/vscode/vs/platform/extensions/common/extensions";
12
- import { IFileService } from "@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service";
13
11
  import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
14
12
  import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service";
15
13
  import { INotificationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service";
16
14
  import { IRemoteAuthorityResolverService } from "@codingame/monaco-vscode-api/vscode/vs/platform/remote/common/remoteAuthorityResolver.service";
17
15
  import { ITunnelService } from "@codingame/monaco-vscode-api/vscode/vs/platform/tunnel/common/tunnel.service";
18
- import { IUriIdentityService } from "@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service";
19
16
  import { IWorkbenchEnvironmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service";
20
17
  import { WebviewThemeDataProvider } from "./themeing.js";
21
18
  import { IWebviewElement, WebviewContentOptions, WebviewExtensionDescription, WebviewInitInfo, WebviewMessageReceivedEvent } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/webview/browser/webview";
@@ -23,12 +20,11 @@ import { WebviewFindDelegate, WebviewFindWidget } from "./webviewFindWidget.js";
23
20
  export declare class WebviewElement extends Disposable implements IWebviewElement, WebviewFindDelegate {
24
21
  protected readonly webviewThemeDataProvider: WebviewThemeDataProvider;
25
22
  private readonly _environmentService;
26
- private readonly _fileService;
27
23
  private readonly _logService;
28
24
  private readonly _remoteAuthorityResolverService;
29
25
  private readonly _tunnelService;
30
26
  private readonly _accessibilityService;
31
- private readonly _uriIdentityService;
27
+ private readonly _instantiationService;
32
28
  protected readonly id: string;
33
29
  /**
34
30
  * The provided identifier of this webview.
@@ -43,6 +39,7 @@ export declare class WebviewElement extends Disposable implements IWebviewElemen
43
39
  private _encodedWebviewOriginPromise?;
44
40
  private _encodedWebviewOrigin;
45
41
  protected get platform(): string;
42
+ private static readonly _supportsTransferableStreams;
46
43
  private readonly _expectedServiceWorkerVersion;
47
44
  private _element;
48
45
  protected get element(): HTMLIFrameElement | undefined;
@@ -52,6 +49,7 @@ export declare class WebviewElement extends Disposable implements IWebviewElemen
52
49
  private _content;
53
50
  private readonly _portMappingManager;
54
51
  private readonly _resourceLoadingCts;
52
+ private readonly _activeStreamControllers;
55
53
  private _contextKeyService;
56
54
  private _confirmBeforeClose;
57
55
  private readonly _focusDelayer;
@@ -68,7 +66,7 @@ export declare class WebviewElement extends Disposable implements IWebviewElemen
68
66
  private _disposed;
69
67
  extension: WebviewExtensionDescription | undefined;
70
68
  private readonly _options;
71
- constructor(initInfo: WebviewInitInfo, webviewThemeDataProvider: WebviewThemeDataProvider, configurationService: IConfigurationService, contextMenuService: IContextMenuService, notificationService: INotificationService, _environmentService: IWorkbenchEnvironmentService, _fileService: IFileService, _logService: ILogService, _remoteAuthorityResolverService: IRemoteAuthorityResolverService, _tunnelService: ITunnelService, instantiationService: IInstantiationService, _accessibilityService: IAccessibilityService, _uriIdentityService: IUriIdentityService);
69
+ constructor(initInfo: WebviewInitInfo, webviewThemeDataProvider: WebviewThemeDataProvider, configurationService: IConfigurationService, contextMenuService: IContextMenuService, notificationService: INotificationService, _environmentService: IWorkbenchEnvironmentService, _logService: ILogService, _remoteAuthorityResolverService: IRemoteAuthorityResolverService, _tunnelService: ITunnelService, _accessibilityService: IAccessibilityService, _instantiationService: IInstantiationService);
72
70
  dispose(): void;
73
71
  setContextKeyService(contextKeyService: IContextKeyService): void;
74
72
  private readonly _onMissingCsp;
@@ -132,7 +130,6 @@ export declare class WebviewElement extends Disposable implements IWebviewElemen
132
130
  redo(): void;
133
131
  private execCommand;
134
132
  private loadResource;
135
- protected streamToBuffer(stream: VSBufferReadableStream): Promise<ArrayBufferLike>;
136
133
  private localLocalhost;
137
134
  focus(): void;
138
135
  private _doFocus;
@@ -4,10 +4,11 @@ import { isFirefox } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/b
4
4
  import { getWindowById, getActiveElement, createElement, EventType, addDisposableListener, getWindow } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
5
5
  import { parentOriginHash } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/iframe';
6
6
  import { ThrottledDelayer, promiseWithResolvers } from '@codingame/monaco-vscode-api/vscode/vs/base/common/async';
7
- import { streamToBuffer } from '@codingame/monaco-vscode-api/vscode/vs/base/common/buffer';
8
7
  import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
9
8
  import { Emitter, Event } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
9
+ import { Lazy } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lazy';
10
10
  import { Disposable, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
11
+ import { listenStream } from '@codingame/monaco-vscode-api/vscode/vs/base/common/stream';
11
12
  import { FileAccess, COI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/network';
12
13
  import '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/index';
13
14
  import { URI } from '@codingame/monaco-vscode-api/vscode/vs/base/common/uri';
@@ -17,13 +18,11 @@ import { IAccessibilityService } from '@codingame/monaco-vscode-api/vscode/vs/pl
17
18
  import { MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
18
19
  import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
19
20
  import { IContextMenuService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextview/browser/contextView.service';
20
- import { IFileService } from '@codingame/monaco-vscode-api/vscode/vs/platform/files/common/files.service';
21
21
  import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
22
22
  import { ILogService } from '@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service';
23
23
  import { INotificationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/notification/common/notification.service';
24
24
  import { IRemoteAuthorityResolverService } from '@codingame/monaco-vscode-api/vscode/vs/platform/remote/common/remoteAuthorityResolver.service';
25
25
  import { ITunnelService } from '@codingame/monaco-vscode-api/vscode/vs/platform/tunnel/common/tunnel.service';
26
- import { IUriIdentityService } from '@codingame/monaco-vscode-api/vscode/vs/platform/uriIdentity/common/uriIdentity.service';
27
26
  import { WebviewPortMappingManager } from '../../../../platform/webview/common/webviewPortMapping.js';
28
27
  import { IWorkbenchEnvironmentService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/environment/common/environmentService.service';
29
28
  import { decodeAuthority, webviewRootResourceAuthority, webviewGenericCspSource } from '@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/webview/common/webview';
@@ -32,6 +31,7 @@ import { areWebviewContentOptionsEqual } from '@codingame/monaco-vscode-api/vsco
32
31
  import { WebviewFindWidget } from './webviewFindWidget.js';
33
32
  import { observableValue } from '@codingame/monaco-vscode-api/vscode/vs/base/common/observableInternal/observables/observableValue';
34
33
 
34
+ var WebviewElement_1;
35
35
  var WebviewState;
36
36
  (function(WebviewState) {
37
37
  let Type;
@@ -52,12 +52,29 @@ var WebviewState;
52
52
  })(WebviewState || (WebviewState = {}));
53
53
  const webviewIdContext = "webviewId";
54
54
  let WebviewElement = class WebviewElement extends Disposable {
55
+ static {
56
+ WebviewElement_1 = this;
57
+ }
55
58
  get window() {
56
59
  return typeof this._windowId === "number" ? getWindowById(this._windowId)?.window : undefined;
57
60
  }
58
61
  get platform() {
59
62
  return "browser";
60
63
  }
64
+ static {
65
+ this._supportsTransferableStreams = ( new Lazy(() => {
66
+ try {
67
+ const stream = ( new ReadableStream());
68
+ const mc = ( new MessageChannel());
69
+ mc.port1.postMessage(stream, [stream]);
70
+ mc.port1.close();
71
+ mc.port2.close();
72
+ return true;
73
+ } catch {
74
+ return false;
75
+ }
76
+ }));
77
+ }
61
78
  get element() {
62
79
  return this._element;
63
80
  }
@@ -81,28 +98,26 @@ let WebviewElement = class WebviewElement extends Disposable {
81
98
  contextMenuService,
82
99
  notificationService,
83
100
  _environmentService,
84
- _fileService,
85
101
  _logService,
86
102
  _remoteAuthorityResolverService,
87
103
  _tunnelService,
88
- instantiationService,
89
104
  _accessibilityService,
90
- _uriIdentityService
105
+ _instantiationService
91
106
  ) {
92
107
  super();
93
108
  this.webviewThemeDataProvider = webviewThemeDataProvider;
94
109
  this._environmentService = _environmentService;
95
- this._fileService = _fileService;
96
110
  this._logService = _logService;
97
111
  this._remoteAuthorityResolverService = _remoteAuthorityResolverService;
98
112
  this._tunnelService = _tunnelService;
99
113
  this._accessibilityService = _accessibilityService;
100
- this._uriIdentityService = _uriIdentityService;
114
+ this._instantiationService = _instantiationService;
101
115
  this.id = generateUuid();
102
116
  this._windowId = undefined;
103
- this._expectedServiceWorkerVersion = 4;
117
+ this._expectedServiceWorkerVersion = 5;
104
118
  this._state = new WebviewState.Initializing([]);
105
119
  this._resourceLoadingCts = this._register(( new CancellationTokenSource()));
120
+ this._activeStreamControllers = ( new Set());
106
121
  this._focusDelayer = this._register(( new ThrottledDelayer(50)));
107
122
  this._onDidHtmlChange = this._register(( new Emitter()));
108
123
  this.onDidHtmlChange = this._onDidHtmlChange.event;
@@ -205,7 +220,7 @@ let WebviewElement = class WebviewElement extends Disposable {
205
220
  this._hasFindResult.fire(didFind);
206
221
  }));
207
222
  this._register(this.on("fatal-error", e => {
208
- notificationService.error(( localize(15317, "Error loading webview: {0}", e.message)));
223
+ notificationService.error(( localize(15622, "Error loading webview: {0}", e.message)));
209
224
  this._onFatalError.fire({
210
225
  message: e.message
211
226
  });
@@ -255,7 +270,10 @@ let WebviewElement = class WebviewElement extends Disposable {
255
270
  path: decodeURIComponent(entry.path),
256
271
  query: entry.query ? decodeURIComponent(entry.query) : entry.query
257
272
  }));
258
- this.loadResource(entry.id, uri, entry.ifNoneMatch);
273
+ this.loadResource(entry.id, uri, {
274
+ ifNoneMatch: entry.ifNoneMatch,
275
+ range: entry.range
276
+ }, this._resourceLoadingCts.token);
259
277
  } catch (e) {
260
278
  this._send("did-load-resource", {
261
279
  id: entry.id,
@@ -297,7 +315,7 @@ let WebviewElement = class WebviewElement extends Disposable {
297
315
  }, undefined, undefined);
298
316
  }));
299
317
  if (initInfo.options.enableFindWidget) {
300
- this._webviewFindWidget = this._register(instantiationService.createInstance(WebviewFindWidget, this));
318
+ this._webviewFindWidget = this._register(this._instantiationService.createInstance(WebviewFindWidget, this));
301
319
  }
302
320
  }
303
321
  dispose() {
@@ -312,6 +330,12 @@ let WebviewElement = class WebviewElement extends Disposable {
312
330
  this._state.pendingMessages = [];
313
331
  }
314
332
  this._onDidDispose.fire();
333
+ for (const controller of this._activeStreamControllers) {
334
+ try {
335
+ controller.close();
336
+ } catch {}
337
+ }
338
+ this._activeStreamControllers.clear();
315
339
  this._resourceLoadingCts.dispose(true);
316
340
  super.dispose();
317
341
  }
@@ -662,25 +686,106 @@ let WebviewElement = class WebviewElement extends Disposable {
662
686
  this._send("execCommand", command);
663
687
  }
664
688
  }
665
- async loadResource(id, uri, ifNoneMatch) {
689
+ async loadResource(id, uri, options, token) {
690
+ if (this._disposed) {
691
+ return;
692
+ }
666
693
  try {
667
- const result = await loadLocalResource(uri, {
668
- ifNoneMatch,
669
- roots: this._content.options.localResourceRoots || []
670
- }, this._uriIdentityService, this._fileService, this._logService, this._resourceLoadingCts.token);
694
+ const result = await this._instantiationService.invokeFunction(loadLocalResource, uri, {
695
+ ifNoneMatch: options.ifNoneMatch,
696
+ roots: this._content.options.localResourceRoots || [],
697
+ range: options.range
698
+ }, token);
699
+ if (this._disposed) {
700
+ return;
701
+ }
671
702
  switch (result.type) {
672
703
  case WebviewResourceResponse.Type.Success:
673
704
  {
674
- const buffer = await this.streamToBuffer(result.stream);
675
- return this._send("did-load-resource", {
676
- id,
677
- status: 200,
678
- path: uri.path,
679
- mime: result.mimeType,
680
- data: buffer,
681
- etag: result.etag,
682
- mtime: result.mtime
683
- }, [buffer]);
705
+ const range = options.range;
706
+ const requestedRangeEnd = range?.end !== undefined ? range.end : result.size - 1;
707
+ const rangeEnd = Math.min(requestedRangeEnd, result.size - 1);
708
+ const rangeHeader = range ? `bytes ${range.start}-${rangeEnd}/${result.size}` : undefined;
709
+ if (WebviewElement_1._supportsTransferableStreams.value) {
710
+ const stream = ( new ReadableStream({
711
+ start: controller => {
712
+ this._activeStreamControllers.add(controller);
713
+ let closed = false;
714
+ const close = () => {
715
+ if (!closed) {
716
+ closed = true;
717
+ this._activeStreamControllers.delete(controller);
718
+ try {
719
+ controller.close();
720
+ } catch {}
721
+ }
722
+ };
723
+ listenStream(result.stream, {
724
+ onData: chunk => {
725
+ if (!closed) {
726
+ try {
727
+ controller.enqueue(( new Uint8Array(chunk.buffer.buffer, chunk.buffer.byteOffset, chunk.buffer.byteLength)));
728
+ } catch {
729
+ closed = true;
730
+ this._activeStreamControllers.delete(controller);
731
+ }
732
+ }
733
+ },
734
+ onError: err => {
735
+ if (!closed) {
736
+ closed = true;
737
+ this._activeStreamControllers.delete(controller);
738
+ try {
739
+ controller.error(err);
740
+ } catch {}
741
+ }
742
+ },
743
+ onEnd: () => close()
744
+ }, token);
745
+ }
746
+ }));
747
+ this._send("did-load-resource", {
748
+ id,
749
+ status: range ? 206 : 200,
750
+ path: uri.path,
751
+ mime: result.mimeType,
752
+ etag: result.etag,
753
+ mtime: result.mtime,
754
+ range: rangeHeader,
755
+ stream
756
+ }, [stream]);
757
+ } else {
758
+ this._send("did-load-resource", {
759
+ id,
760
+ status: range ? 206 : 200,
761
+ path: uri.path,
762
+ mime: result.mimeType,
763
+ etag: result.etag,
764
+ mtime: result.mtime,
765
+ range: rangeHeader
766
+ });
767
+ listenStream(result.stream, {
768
+ onData: chunk => {
769
+ const data = ( new Uint8Array(chunk.buffer.buffer, chunk.buffer.byteOffset, chunk.buffer.byteLength));
770
+ this._send("did-load-resource-chunk", {
771
+ id,
772
+ data
773
+ }, [data.buffer]);
774
+ },
775
+ onError: () => {
776
+ this._send("did-load-resource-end", {
777
+ id,
778
+ error: true
779
+ });
780
+ },
781
+ onEnd: () => {
782
+ this._send("did-load-resource-end", {
783
+ id
784
+ });
785
+ }
786
+ }, token);
787
+ }
788
+ return;
684
789
  }
685
790
  case WebviewResourceResponse.Type.NotModified:
686
791
  {
@@ -708,10 +813,6 @@ let WebviewElement = class WebviewElement extends Disposable {
708
813
  path: uri.path
709
814
  });
710
815
  }
711
- async streamToBuffer(stream) {
712
- const vsBuffer = await streamToBuffer(stream);
713
- return vsBuffer.buffer.buffer;
714
- }
715
816
  async localLocalhost(id, origin) {
716
817
  const authority = this._environmentService.remoteAuthority;
717
818
  const resolveAuthority = authority ? await this._remoteAuthorityResolverService.resolveAuthority(authority) : undefined;
@@ -783,6 +884,6 @@ let WebviewElement = class WebviewElement extends Disposable {
783
884
  this._webviewFindWidget?.find(previous);
784
885
  }
785
886
  };
786
- WebviewElement = ( __decorate([( __param(2, IConfigurationService)), ( __param(3, IContextMenuService)), ( __param(4, INotificationService)), ( __param(5, IWorkbenchEnvironmentService)), ( __param(6, IFileService)), ( __param(7, ILogService)), ( __param(8, IRemoteAuthorityResolverService)), ( __param(9, ITunnelService)), ( __param(10, IInstantiationService)), ( __param(11, IAccessibilityService)), ( __param(12, IUriIdentityService))], WebviewElement));
887
+ WebviewElement = WebviewElement_1 = ( __decorate([( __param(2, IConfigurationService)), ( __param(3, IContextMenuService)), ( __param(4, INotificationService)), ( __param(5, IWorkbenchEnvironmentService)), ( __param(6, ILogService)), ( __param(7, IRemoteAuthorityResolverService)), ( __param(8, ITunnelService)), ( __param(9, IAccessibilityService)), ( __param(10, IInstantiationService))], WebviewElement));
787
888
 
788
889
  export { WebviewElement };
@@ -18,7 +18,7 @@ class ShowWebViewEditorFindWidgetAction extends Action2 {
18
18
  this.ID = "editor.action.webvieweditor.showFind";
19
19
  }
20
20
  static {
21
- this.LABEL = ( localize(15348, "Show find"));
21
+ this.LABEL = ( localize(15653, "Show find"));
22
22
  }
23
23
  constructor() {
24
24
  super({
@@ -43,7 +43,7 @@ class HideWebViewEditorFindCommand extends Action2 {
43
43
  this.ID = "editor.action.webvieweditor.hideFind";
44
44
  }
45
45
  static {
46
- this.LABEL = ( localize(15349, "Stop find"));
46
+ this.LABEL = ( localize(15654, "Stop find"));
47
47
  }
48
48
  constructor() {
49
49
  super({
@@ -68,7 +68,7 @@ class WebViewEditorFindNextCommand extends Action2 {
68
68
  this.ID = "editor.action.webvieweditor.findNext";
69
69
  }
70
70
  static {
71
- this.LABEL = ( localize(15350, "Find next"));
71
+ this.LABEL = ( localize(15655, "Find next"));
72
72
  }
73
73
  constructor() {
74
74
  super({
@@ -93,7 +93,7 @@ class WebViewEditorFindPreviousCommand extends Action2 {
93
93
  this.ID = "editor.action.webvieweditor.findPrevious";
94
94
  }
95
95
  static {
96
- this.LABEL = ( localize(15351, "Find previous"));
96
+ this.LABEL = ( localize(15656, "Find previous"));
97
97
  }
98
98
  constructor() {
99
99
  super({
@@ -118,7 +118,7 @@ class ReloadWebviewAction extends Action2 {
118
118
  this.ID = "workbench.action.webview.reloadWebviewAction";
119
119
  }
120
120
  static {
121
- this.LABEL = ( localize2(15352, "Reload Webviews"));
121
+ this.LABEL = ( localize2(15657, "Reload Webviews"));
122
122
  }
123
123
  constructor() {
124
124
  super({
@@ -19,7 +19,7 @@ import '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/ins
19
19
  import { IEditorService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/editor/common/editorService.service';
20
20
 
21
21
  ( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(
22
- EditorPaneDescriptor.create(WebviewEditor, WebviewEditor.ID, ( localize(15354, "webview editor"))),
22
+ EditorPaneDescriptor.create(WebviewEditor, WebviewEditor.ID, ( localize(15659, "webview editor"))),
23
23
  [( new SyncDescriptor(WebviewInput))]
24
24
  );
25
25
  let WebviewPanelContribution = class WebviewPanelContribution extends Disposable {
@@ -32,7 +32,6 @@ export declare class WebviewViewPane extends ViewPane {
32
32
  private _activated;
33
33
  private _container?;
34
34
  private _rootContainer?;
35
- private _resizeObserver?;
36
35
  private readonly defaultTitle;
37
36
  private setTitle;
38
37
  private badge;
@@ -40,7 +39,6 @@ export declare class WebviewViewPane extends ViewPane {
40
39
  private readonly memento;
41
40
  private readonly viewState;
42
41
  private readonly extensionId?;
43
- private _repositionTimeout?;
44
42
  constructor(options: IViewletViewOptions, configurationService: IConfigurationService, contextKeyService: IContextKeyService, contextMenuService: IContextMenuService, instantiationService: IInstantiationService, keybindingService: IKeybindingService, openerService: IOpenerService, hoverService: IHoverService, themeService: IThemeService, viewDescriptorService: IViewDescriptorService, activityService: IActivityService, extensionService: IExtensionService, progressService: IProgressService, storageService: IStorageService, viewService: IViewsService, webviewService: IWebviewService, webviewViewService: IWebviewViewService);
45
43
  private readonly _onDidChangeVisibility;
46
44
  readonly onDidChangeVisibility: import("@codingame/monaco-vscode-api/vscode/vs/base/common/event").Event<boolean>;
@@ -50,14 +48,11 @@ export declare class WebviewViewPane extends ViewPane {
50
48
  focus(): void;
51
49
  protected renderBody(container: HTMLElement): void;
52
50
  saveState(): void;
53
- protected layoutBody(height: number, width: number): void;
54
51
  private updateTreeVisibility;
55
52
  private activate;
56
53
  protected updateTitle(value: string | undefined): void;
57
54
  protected updateBadge(badge: IViewBadge | undefined): void;
58
55
  private withProgress;
59
- onDidScrollRoot(): void;
60
- private doLayoutWebview;
61
56
  private layoutWebview;
62
57
  private findRootContainer;
63
58
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
3
- import { DisposableResizeObserver, Dimension, getWindow, EventType, addDisposableListener, findParentWithClass } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
3
+ import { getWindow, EventType, addDisposableListener, findParentWithClass } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
4
4
  import { CancellationTokenSource } from '@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation';
5
5
  import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
6
6
  import { MutableDisposable, DisposableStore, toDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
@@ -93,7 +93,6 @@ let WebviewViewPane = class WebviewViewPane extends ViewPane {
93
93
  }
94
94
  dispose() {
95
95
  this._onDispose.fire();
96
- clearTimeout(this._repositionTimeout);
97
96
  super.dispose();
98
97
  }
99
98
  focus() {
@@ -104,14 +103,7 @@ let WebviewViewPane = class WebviewViewPane extends ViewPane {
104
103
  super.renderBody(container);
105
104
  this._container = container;
106
105
  this._rootContainer = undefined;
107
- if (!this._resizeObserver) {
108
- this._resizeObserver = this._register(( new DisposableResizeObserver(() => {
109
- setTimeout(() => {
110
- this.layoutWebview();
111
- }, 0);
112
- })));
113
- this._resizeObserver.observe(container);
114
- }
106
+ this.layoutWebview();
115
107
  }
116
108
  saveState() {
117
109
  if (this._webview.value) {
@@ -120,10 +112,6 @@ let WebviewViewPane = class WebviewViewPane extends ViewPane {
120
112
  this.memento.saveMemento();
121
113
  super.saveState();
122
114
  }
123
- layoutBody(height, width) {
124
- super.layoutBody(height, width);
125
- this.layoutWebview(( new Dimension(width, height)));
126
- }
127
115
  updateTreeVisibility() {
128
116
  if (this.isBodyVisible()) {
129
117
  this.activate();
@@ -152,9 +140,7 @@ let WebviewViewPane = class WebviewViewPane extends ViewPane {
152
140
  });
153
141
  webview.state = this.viewState[storageKeys.webviewState];
154
142
  this._webview.value = webview;
155
- if (this._container) {
156
- this.layoutWebview();
157
- }
143
+ this.layoutWebview();
158
144
  this._webviewDisposables.add(toDisposable(() => {
159
145
  this._webview.value?.release(this);
160
146
  }));
@@ -236,10 +222,7 @@ let WebviewViewPane = class WebviewViewPane extends ViewPane {
236
222
  delay: 500
237
223
  }, task);
238
224
  }
239
- onDidScrollRoot() {
240
- this.layoutWebview();
241
- }
242
- doLayoutWebview(dimension) {
225
+ layoutWebview() {
243
226
  const webviewEntry = this._webview.value;
244
227
  if (!this._container || !webviewEntry) {
245
228
  return;
@@ -247,12 +230,7 @@ let WebviewViewPane = class WebviewViewPane extends ViewPane {
247
230
  if (!this._rootContainer || !this._rootContainer.isConnected) {
248
231
  this._rootContainer = this.findRootContainer(this._container);
249
232
  }
250
- webviewEntry.layoutWebviewOverElement(this._container, dimension, this._rootContainer);
251
- }
252
- layoutWebview(dimension) {
253
- this.doLayoutWebview(dimension);
254
- clearTimeout(this._repositionTimeout);
255
- this._repositionTimeout = setTimeout(() => this.doLayoutWebview(dimension), 200);
233
+ webviewEntry.setAnchorElement(this._container, this._rootContainer);
256
234
  }
257
235
  findRootContainer(container) {
258
236
  return findParentWithClass(container, "monaco-scrollable-element") ?? undefined;