@codingame/monaco-vscode-lifecycle-service-override 4.4.1 → 4.5.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.
package/lifecycle.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
2
  import { BrowserLifecycleService } from './vscode/src/vs/workbench/services/lifecycle/browser/lifecycleService.js';
3
- import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
4
- import { ITimerService, TimerService } from 'vscode/vscode/vs/workbench/services/timer/browser/timerService';
3
+ import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
4
+ import { TimerService } from './vscode/src/vs/workbench/services/timer/browser/timerService.js';
5
+ import { ITimerService } from 'vscode/vscode/vs/workbench/services/timer/browser/timerService.service';
5
6
 
6
7
  function getServiceOverride() {
7
8
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-lifecycle-service-override",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -17,7 +17,15 @@
17
17
  "main": "index.js",
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
+ "exports": {
21
+ ".": {
22
+ "default": "./index.js"
23
+ },
24
+ "./vscode/*": {
25
+ "default": "./vscode/src/*.js"
26
+ }
27
+ },
20
28
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@4.4.1"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@4.5.0"
22
30
  }
23
31
  }
@@ -1,10 +1,11 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
3
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
3
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
4
4
  import { AbstractLifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycleService';
5
5
  import { localizeWithPath } from 'vscode/vscode/vs/nls';
6
6
  import { addDisposableListener, EventType } from 'vscode/vscode/vs/base/browser/dom';
7
- import { IStorageService, WillSaveStateReason } from 'vscode/vscode/vs/platform/storage/common/storage';
7
+ import { WillSaveStateReason } from 'vscode/vscode/vs/platform/storage/common/storage';
8
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
8
9
  import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
9
10
  import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
10
11
  import { firstOrDefault } from 'vscode/vscode/vs/base/common/arrays';
@@ -0,0 +1,243 @@
1
+ import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
+ import { getMarks } from 'vscode/vscode/vs/base/common/performance';
3
+ import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
4
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions.service';
5
+ import { IUpdateService } from 'vscode/vscode/vs/platform/update/common/update.service';
6
+ import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
7
+ import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
8
+ import { IAccessibilityService } from 'vscode/vscode/vs/platform/accessibility/common/accessibility.service';
9
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
10
+ import { Barrier, timeout } from 'vscode/vscode/vs/base/common/async';
11
+ import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService.service';
12
+ import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service';
13
+ import { TelemetryTrustedValue } from 'vscode/vscode/vs/platform/telemetry/common/telemetryUtils';
14
+ import { isWeb } from 'vscode/vscode/vs/base/common/platform';
15
+ import { createBlobWorker } from 'vscode/vscode/vs/base/browser/defaultWorkerFactory';
16
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
17
+ import { TerminalExtensions } from 'vscode/vscode/vs/platform/terminal/common/terminal';
18
+
19
+ class PerfMarks {
20
+ constructor() {
21
+ this._entries = [];
22
+ }
23
+ setMarks(source, entries) {
24
+ this._entries.push([source, entries]);
25
+ }
26
+ getDuration(from, to) {
27
+ const fromEntry = this._findEntry(from);
28
+ if (!fromEntry) {
29
+ return 0;
30
+ }
31
+ const toEntry = this._findEntry(to);
32
+ if (!toEntry) {
33
+ return 0;
34
+ }
35
+ return toEntry.startTime - fromEntry.startTime;
36
+ }
37
+ _findEntry(name) {
38
+ for (const [, marks] of this._entries) {
39
+ for (let i = marks.length - 1; i >= 0; i--) {
40
+ if (marks[i].name === name) {
41
+ return marks[i];
42
+ }
43
+ }
44
+ }
45
+ }
46
+ getEntries() {
47
+ return this._entries.slice(0);
48
+ }
49
+ }
50
+ let AbstractTimerService = class AbstractTimerService {
51
+ constructor(_lifecycleService, _contextService, _extensionService, _updateService, _paneCompositeService, _editorService, _accessibilityService, _telemetryService, layoutService) {
52
+ this._lifecycleService = _lifecycleService;
53
+ this._contextService = _contextService;
54
+ this._extensionService = _extensionService;
55
+ this._updateService = _updateService;
56
+ this._paneCompositeService = _paneCompositeService;
57
+ this._editorService = _editorService;
58
+ this._accessibilityService = _accessibilityService;
59
+ this._telemetryService = _telemetryService;
60
+ this._barrier = ( new Barrier());
61
+ this._marks = ( new PerfMarks());
62
+ this._rndValueShouldSendTelemetry = Math.random() < .05;
63
+ Promise.all([
64
+ this._extensionService.whenInstalledExtensionsRegistered(),
65
+ _lifecycleService.when(3 ),
66
+ layoutService.whenRestored,
67
+ Promise.all(( Array.from(( ( Registry.as(TerminalExtensions.Backend)).backends.values())).map(e => e.whenReady)))
68
+ ]).then(() => {
69
+ this.setPerformanceMarks('renderer', getMarks());
70
+ return this._computeStartupMetrics();
71
+ }).then(metrics => {
72
+ this._startupMetrics = metrics;
73
+ this._reportStartupTimes(metrics);
74
+ this._barrier.open();
75
+ });
76
+ this.perfBaseline = this._barrier.wait()
77
+ .then(() => this._lifecycleService.when(4 ))
78
+ .then(() => timeout(this._startupMetrics.timers.ellapsedRequire))
79
+ .then(() => {
80
+ const jsSrc = ( (function () {
81
+ let tooSlow = false;
82
+ function fib(n) {
83
+ if (tooSlow) {
84
+ return 0;
85
+ }
86
+ if (performance.now() - t1 >= 1000) {
87
+ tooSlow = true;
88
+ }
89
+ if (n <= 2) {
90
+ return n;
91
+ }
92
+ return fib(n - 1) + fib(n - 2);
93
+ }
94
+ const t1 = performance.now();
95
+ fib(24);
96
+ const value = Math.round(performance.now() - t1);
97
+ postMessage({ value: tooSlow ? -1 : value });
98
+ }).toString());
99
+ const blob = ( new Blob([`(${jsSrc})();`], { type: 'application/javascript' }));
100
+ const blobUrl = URL.createObjectURL(blob);
101
+ const worker = createBlobWorker(blobUrl, { name: 'perfBaseline' });
102
+ return ( new Promise(resolve => {
103
+ worker.onmessage = e => resolve(e.data.value);
104
+ })).finally(() => {
105
+ worker.terminate();
106
+ URL.revokeObjectURL(blobUrl);
107
+ });
108
+ });
109
+ }
110
+ whenReady() {
111
+ return this._barrier.wait();
112
+ }
113
+ get startupMetrics() {
114
+ if (!this._startupMetrics) {
115
+ throw new Error('illegal state, MUST NOT access startupMetrics before whenReady has resolved');
116
+ }
117
+ return this._startupMetrics;
118
+ }
119
+ setPerformanceMarks(source, marks) {
120
+ const codeMarks = marks.filter(mark => mark.name.startsWith('code/'));
121
+ this._marks.setMarks(source, codeMarks);
122
+ this._reportPerformanceMarks(source, codeMarks);
123
+ }
124
+ getPerformanceMarks() {
125
+ return this._marks.getEntries();
126
+ }
127
+ getDuration(from, to) {
128
+ return this._marks.getDuration(from, to);
129
+ }
130
+ _reportStartupTimes(metrics) {
131
+ this._telemetryService.publicLog('startupTimeVaried', metrics);
132
+ }
133
+ _shouldReportPerfMarks() {
134
+ return this._rndValueShouldSendTelemetry;
135
+ }
136
+ _reportPerformanceMarks(source, marks) {
137
+ if (!this._shouldReportPerfMarks()) {
138
+ return;
139
+ }
140
+ for (const mark of marks) {
141
+ this._telemetryService.publicLog2('startup.timer.mark', {
142
+ source,
143
+ name: ( new TelemetryTrustedValue(mark.name)),
144
+ startTime: mark.startTime
145
+ });
146
+ }
147
+ }
148
+ async _computeStartupMetrics() {
149
+ const initialStartup = this._isInitialStartup();
150
+ let startMark;
151
+ if (isWeb) {
152
+ startMark = 'code/timeOrigin';
153
+ }
154
+ else {
155
+ startMark = initialStartup ? 'code/didStartMain' : 'code/willOpenNewWindow';
156
+ }
157
+ const activeViewlet = this._paneCompositeService.getActivePaneComposite(0 );
158
+ const activePanel = this._paneCompositeService.getActivePaneComposite(1 );
159
+ const info = {
160
+ version: 2,
161
+ ellapsed: this._marks.getDuration(startMark, 'code/didStartWorkbench'),
162
+ isLatestVersion: Boolean(await this._updateService.isLatestVersion()),
163
+ didUseCachedData: this._didUseCachedData(),
164
+ windowKind: this._lifecycleService.startupKind,
165
+ windowCount: await this._getWindowCount(),
166
+ viewletId: activeViewlet?.getId(),
167
+ editorIds: ( this._editorService.visibleEditors.map(input => input.typeId)),
168
+ panelId: activePanel ? activePanel.getId() : undefined,
169
+ timers: {
170
+ ellapsedAppReady: initialStartup ? this._marks.getDuration('code/didStartMain', 'code/mainAppReady') : undefined,
171
+ ellapsedNlsGeneration: initialStartup ? this._marks.getDuration('code/willGenerateNls', 'code/didGenerateNls') : undefined,
172
+ ellapsedLoadMainBundle: initialStartup ? this._marks.getDuration('code/willLoadMainBundle', 'code/didLoadMainBundle') : undefined,
173
+ ellapsedCrashReporter: initialStartup ? this._marks.getDuration('code/willStartCrashReporter', 'code/didStartCrashReporter') : undefined,
174
+ ellapsedMainServer: initialStartup ? this._marks.getDuration('code/willStartMainServer', 'code/didStartMainServer') : undefined,
175
+ ellapsedWindowCreate: initialStartup ? this._marks.getDuration('code/willCreateCodeWindow', 'code/didCreateCodeWindow') : undefined,
176
+ ellapsedWindowRestoreState: initialStartup ? this._marks.getDuration('code/willRestoreCodeWindowState', 'code/didRestoreCodeWindowState') : undefined,
177
+ ellapsedBrowserWindowCreate: initialStartup ? this._marks.getDuration('code/willCreateCodeBrowserWindow', 'code/didCreateCodeBrowserWindow') : undefined,
178
+ ellapsedWindowMaximize: initialStartup ? this._marks.getDuration('code/willMaximizeCodeWindow', 'code/didMaximizeCodeWindow') : undefined,
179
+ ellapsedWindowLoad: initialStartup ? this._marks.getDuration('code/mainAppReady', 'code/willOpenNewWindow') : undefined,
180
+ ellapsedWindowLoadToRequire: this._marks.getDuration('code/willOpenNewWindow', 'code/willLoadWorkbenchMain'),
181
+ ellapsedRequire: this._marks.getDuration('code/willLoadWorkbenchMain', 'code/didLoadWorkbenchMain'),
182
+ ellapsedWaitForWindowConfig: this._marks.getDuration('code/willWaitForWindowConfig', 'code/didWaitForWindowConfig'),
183
+ ellapsedStorageInit: this._marks.getDuration('code/willInitStorage', 'code/didInitStorage'),
184
+ ellapsedSharedProcesConnected: this._marks.getDuration('code/willConnectSharedProcess', 'code/didConnectSharedProcess'),
185
+ ellapsedWorkspaceServiceInit: this._marks.getDuration('code/willInitWorkspaceService', 'code/didInitWorkspaceService'),
186
+ ellapsedRequiredUserDataInit: this._marks.getDuration('code/willInitRequiredUserData', 'code/didInitRequiredUserData'),
187
+ ellapsedOtherUserDataInit: this._marks.getDuration('code/willInitOtherUserData', 'code/didInitOtherUserData'),
188
+ ellapsedExtensions: this._marks.getDuration('code/willLoadExtensions', 'code/didLoadExtensions'),
189
+ ellapsedEditorRestore: this._marks.getDuration('code/willRestoreEditors', 'code/didRestoreEditors'),
190
+ ellapsedViewletRestore: this._marks.getDuration('code/willRestoreViewlet', 'code/didRestoreViewlet'),
191
+ ellapsedPanelRestore: this._marks.getDuration('code/willRestorePanel', 'code/didRestorePanel'),
192
+ ellapsedWorkbenchContributions: this._marks.getDuration('code/willCreateWorkbenchContributions/1', 'code/didCreateWorkbenchContributions/2'),
193
+ ellapsedWorkbench: this._marks.getDuration('code/willStartWorkbench', 'code/didStartWorkbench'),
194
+ ellapsedExtensionsReady: this._marks.getDuration(startMark, 'code/didLoadExtensions'),
195
+ ellapsedRenderer: this._marks.getDuration('code/didStartRenderer', 'code/didStartWorkbench')
196
+ },
197
+ platform: undefined,
198
+ release: undefined,
199
+ arch: undefined,
200
+ totalmem: undefined,
201
+ freemem: undefined,
202
+ meminfo: undefined,
203
+ cpus: undefined,
204
+ loadavg: undefined,
205
+ isVMLikelyhood: undefined,
206
+ initialStartup,
207
+ hasAccessibilitySupport: this._accessibilityService.isScreenReaderOptimized(),
208
+ emptyWorkbench: this._contextService.getWorkbenchState() === 1
209
+ };
210
+ await this._extendStartupInfo(info);
211
+ return info;
212
+ }
213
+ };
214
+ AbstractTimerService = ( __decorate([
215
+ ( __param(0, ILifecycleService)),
216
+ ( __param(1, IWorkspaceContextService)),
217
+ ( __param(2, IExtensionService)),
218
+ ( __param(3, IUpdateService)),
219
+ ( __param(4, IPaneCompositePartService)),
220
+ ( __param(5, IEditorService)),
221
+ ( __param(6, IAccessibilityService)),
222
+ ( __param(7, ITelemetryService)),
223
+ ( __param(8, IWorkbenchLayoutService))
224
+ ], AbstractTimerService));
225
+ class TimerService extends AbstractTimerService {
226
+ _isInitialStartup() {
227
+ return false;
228
+ }
229
+ _didUseCachedData() {
230
+ return false;
231
+ }
232
+ async _getWindowCount() {
233
+ return 1;
234
+ }
235
+ async _extendStartupInfo(info) {
236
+ info.isVMLikelyhood = 0;
237
+ info.isARM64Emulated = false;
238
+ info.platform = navigator.userAgent;
239
+ info.release = navigator.appVersion;
240
+ }
241
+ }
242
+
243
+ export { AbstractTimerService, TimerService };