@codingame/monaco-vscode-lifecycle-service-override 25.1.2 → 26.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-lifecycle-service-override",
3
- "version": "25.1.2",
3
+ "version": "26.0.1",
4
4
  "private": false,
5
5
  "description": "VSCode public API plugged on the monaco editor - lifecycle service-override",
6
6
  "keywords": [],
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "type": "module",
17
17
  "dependencies": {
18
- "@codingame/monaco-vscode-api": "25.1.2"
18
+ "@codingame/monaco-vscode-api": "26.0.1"
19
19
  },
20
20
  "main": "index.js",
21
21
  "module": "index.js",
@@ -22,28 +22,28 @@ let BrowserLifecycleService = class BrowserLifecycleService extends AbstractLife
22
22
  this.registerListeners();
23
23
  }
24
24
  registerListeners() {
25
- this.beforeUnloadListener = addDisposableListener(mainWindow, EventType.BEFORE_UNLOAD, (e) => this.onBeforeUnload(e));
25
+ this.beforeUnloadListener = addDisposableListener(mainWindow, EventType.BEFORE_UNLOAD, e => this.onBeforeUnload(e));
26
26
  this.unloadListener = addDisposableListener(mainWindow, EventType.PAGE_HIDE, () => this.onUnload());
27
27
  }
28
28
  onBeforeUnload(event) {
29
29
  if (this.ignoreBeforeUnload) {
30
- this.logService.info('[lifecycle] onBeforeUnload triggered but ignored once');
30
+ this.logService.info("[lifecycle] onBeforeUnload triggered but ignored once");
31
31
  this.ignoreBeforeUnload = false;
32
32
  }
33
33
  else {
34
- this.logService.info('[lifecycle] onBeforeUnload triggered and handled with veto support');
34
+ this.logService.info("[lifecycle] onBeforeUnload triggered and handled with veto support");
35
35
  this.doShutdown(() => this.vetoBeforeUnload(event));
36
36
  }
37
37
  }
38
38
  vetoBeforeUnload(event) {
39
39
  event.preventDefault();
40
40
  event.returnValue = ( localize(
41
- 14183,
41
+ 14573,
42
42
  "Changes that you made may not be saved. Please check press 'Cancel' and try again."
43
43
  ));
44
44
  }
45
45
  withExpectedShutdown(reason, callback) {
46
- if (typeof reason === 'number') {
46
+ if (typeof reason === "number") {
47
47
  this.shutdownReason = reason;
48
48
  return this.storageService.flush(WillSaveStateReason.SHUTDOWN);
49
49
  }
@@ -51,14 +51,13 @@ let BrowserLifecycleService = class BrowserLifecycleService extends AbstractLife
51
51
  this.ignoreBeforeUnload = true;
52
52
  try {
53
53
  callback?.();
54
- }
55
- finally {
54
+ } finally {
56
55
  this.ignoreBeforeUnload = false;
57
56
  }
58
57
  }
59
58
  }
60
59
  async shutdown() {
61
- this.logService.info('[lifecycle] shutdown triggered');
60
+ this.logService.info("[lifecycle] shutdown triggered");
62
61
  this.beforeUnloadListener?.dispose();
63
62
  this.unloadListener?.dispose();
64
63
  await this.storageService.flush(WillSaveStateReason.SHUTDOWN);
@@ -69,11 +68,13 @@ let BrowserLifecycleService = class BrowserLifecycleService extends AbstractLife
69
68
  this.storageService.flush(WillSaveStateReason.SHUTDOWN);
70
69
  let veto = false;
71
70
  function handleVeto(vetoResult, id) {
72
- if (typeof vetoShutdown !== 'function') {
71
+ if (typeof vetoShutdown !== "function") {
73
72
  return;
74
73
  }
75
74
  if (vetoResult instanceof Promise) {
76
- logService.error(`[lifecycle] Long running operations before shutdown are unsupported in the web (id: ${id})`);
75
+ logService.error(
76
+ `[lifecycle] Long running operations before shutdown are unsupported in the web (id: ${id})`
77
+ );
77
78
  veto = true;
78
79
  }
79
80
  if (vetoResult === true) {
@@ -90,7 +91,7 @@ let BrowserLifecycleService = class BrowserLifecycleService extends AbstractLife
90
91
  handleVeto(valueFn(), id);
91
92
  }
92
93
  });
93
- if (veto && typeof vetoShutdown === 'function') {
94
+ if (veto && typeof vetoShutdown === "function") {
94
95
  return vetoShutdown();
95
96
  }
96
97
  return this.onUnload();
@@ -101,19 +102,23 @@ let BrowserLifecycleService = class BrowserLifecycleService extends AbstractLife
101
102
  }
102
103
  this.didUnload = true;
103
104
  this._willShutdown = true;
104
- this._register(addDisposableListener(mainWindow, EventType.PAGE_SHOW, (e) => this.onLoadAfterUnload(e)));
105
+ this._register(
106
+ addDisposableListener(mainWindow, EventType.PAGE_SHOW, e => this.onLoadAfterUnload(e))
107
+ );
105
108
  const logService = this.logService;
106
109
  this._onWillShutdown.fire({
107
110
  reason: ShutdownReason.QUIT,
108
111
  joiners: () => [],
109
112
  token: CancellationToken.None,
110
113
  join(promise, joiner) {
111
- if (typeof promise === 'function') {
114
+ if (typeof promise === "function") {
112
115
  promise();
113
116
  }
114
- logService.error(`[lifecycle] Long running operations during shutdown are unsupported in the web (id: ${joiner.id})`);
117
+ logService.error(
118
+ `[lifecycle] Long running operations during shutdown are unsupported in the web (id: ${joiner.id})`
119
+ );
115
120
  },
116
- force: () => { },
121
+ force: () => {}
117
122
  });
118
123
  this._onDidShutdown.fire();
119
124
  }
@@ -122,22 +127,21 @@ let BrowserLifecycleService = class BrowserLifecycleService extends AbstractLife
122
127
  if (!wasRestoredFromCache) {
123
128
  return;
124
129
  }
125
- this.withExpectedShutdown({ disableShutdownHandling: true }, () => mainWindow.location.reload());
130
+ this.withExpectedShutdown({
131
+ disableShutdownHandling: true
132
+ }, () => mainWindow.location.reload());
126
133
  }
127
134
  doResolveStartupKind() {
128
135
  let startupKind = super.doResolveStartupKind();
129
- if (typeof startupKind !== 'number') {
130
- const timing = mainWindow.performance.getEntriesByType('navigation').at(0);
131
- if (timing?.type === 'reload') {
136
+ if (typeof startupKind !== "number") {
137
+ const timing = mainWindow.performance.getEntriesByType("navigation").at(0);
138
+ if (timing?.type === "reload") {
132
139
  startupKind = StartupKind.ReloadedWindow;
133
140
  }
134
141
  }
135
142
  return startupKind;
136
143
  }
137
144
  };
138
- BrowserLifecycleService = ( __decorate([
139
- ( __param(0, ILogService)),
140
- ( __param(1, IStorageService))
141
- ], BrowserLifecycleService));
145
+ BrowserLifecycleService = ( __decorate([( __param(0, ILogService)), ( __param(1, IStorageService))], BrowserLifecycleService));
142
146
 
143
147
  export { BrowserLifecycleService };
@@ -57,7 +57,17 @@ class PerfMarks {
57
57
  }
58
58
  }
59
59
  let AbstractTimerService = class AbstractTimerService {
60
- constructor(_lifecycleService, _contextService, _extensionService, _updateService, _paneCompositeService, _editorService, _accessibilityService, _telemetryService, layoutService) {
60
+ constructor(
61
+ _lifecycleService,
62
+ _contextService,
63
+ _extensionService,
64
+ _updateService,
65
+ _paneCompositeService,
66
+ _editorService,
67
+ _accessibilityService,
68
+ _telemetryService,
69
+ layoutService
70
+ ) {
61
71
  this._lifecycleService = _lifecycleService;
62
72
  this._contextService = _contextService;
63
73
  this._extensionService = _extensionService;
@@ -70,23 +80,18 @@ let AbstractTimerService = class AbstractTimerService {
70
80
  this._marks = ( new PerfMarks());
71
81
  this._rndValueShouldSendTelemetry = Math.random() < .03;
72
82
  Promise.all([
73
- this._extensionService.whenInstalledExtensionsRegistered(),
74
- _lifecycleService.when(LifecyclePhase.Restored),
75
- layoutService.whenRestored,
76
- Promise.all(( Array.from(( ( Registry.as(TerminalExtensions.Backend)).backends.values())).map(e => e.whenReady)))
77
- ]).then(() => {
78
- this.setPerformanceMarks('renderer', getMarks());
83
+ this._extensionService.whenInstalledExtensionsRegistered(),
84
+ _lifecycleService.when(LifecyclePhase.Restored),
85
+ layoutService.whenRestored, Promise.all(( Array.from(( ( Registry.as(TerminalExtensions.Backend)).backends.values())).map(e => e.whenReady)))]).then(() => {
86
+ this.setPerformanceMarks("renderer", getMarks());
79
87
  return this._computeStartupMetrics();
80
88
  }).then(metrics => {
81
89
  this._startupMetrics = metrics;
82
90
  this._reportStartupTimes(metrics);
83
91
  this._barrier.open();
84
92
  });
85
- this.perfBaseline = this._barrier.wait()
86
- .then(() => this._lifecycleService.when(LifecyclePhase.Eventually))
87
- .then(() => timeout(this._startupMetrics.timers.ellapsedRequire))
88
- .then(() => {
89
- const jsSrc = ( (function () {
93
+ this.perfBaseline = this._barrier.wait().then(() => this._lifecycleService.when(LifecyclePhase.Eventually)).then(() => timeout(this._startupMetrics.timers.ellapsedRequire)).then(() => {
94
+ const jsSrc = ( (function() {
90
95
  let tooSlow = false;
91
96
  function fib(n) {
92
97
  if (tooSlow) {
@@ -103,11 +108,17 @@ let AbstractTimerService = class AbstractTimerService {
103
108
  const t1 = performance.now();
104
109
  fib(24);
105
110
  const value = Math.round(performance.now() - t1);
106
- self.postMessage({ value: tooSlow ? -1 : value });
111
+ self.postMessage({
112
+ value: tooSlow ? -1 : value
113
+ });
107
114
  }).toString());
108
- const blob = ( new Blob([`(${jsSrc})();`], { type: 'application/javascript' }));
115
+ const blob = ( new Blob([`(${jsSrc})();`], {
116
+ type: "application/javascript"
117
+ }));
109
118
  const blobUrl = URL.createObjectURL(blob);
110
- const worker = createBlobWorker(blobUrl, { name: 'perfBaseline' });
119
+ const worker = createBlobWorker(blobUrl, {
120
+ name: "perfBaseline"
121
+ });
111
122
  return ( new Promise(resolve => {
112
123
  worker.onmessage = e => resolve(e.data.value);
113
124
  })).finally(() => {
@@ -122,13 +133,13 @@ let AbstractTimerService = class AbstractTimerService {
122
133
  get startupMetrics() {
123
134
  if (!this._startupMetrics) {
124
135
  throw ( new Error(
125
- 'illegal state, MUST NOT access startupMetrics before whenReady has resolved'
136
+ "illegal state, MUST NOT access startupMetrics before whenReady has resolved"
126
137
  ));
127
138
  }
128
139
  return this._startupMetrics;
129
140
  }
130
141
  setPerformanceMarks(source, marks) {
131
- const codeMarks = marks.filter(mark => mark.name.startsWith('code/'));
142
+ const codeMarks = marks.filter(mark => mark.name.startsWith("code/"));
132
143
  this._marks.setMarks(source, codeMarks);
133
144
  this._reportPerformanceMarks(source, codeMarks);
134
145
  }
@@ -142,7 +153,7 @@ let AbstractTimerService = class AbstractTimerService {
142
153
  return this._marks.getStartTime(mark);
143
154
  }
144
155
  _reportStartupTimes(metrics) {
145
- this._telemetryService.publicLog('startupTimeVaried', metrics);
156
+ this._telemetryService.publicLog("startupTimeVaried", metrics);
146
157
  }
147
158
  _shouldReportPerfMarks() {
148
159
  return this._rndValueShouldSendTelemetry;
@@ -152,7 +163,7 @@ let AbstractTimerService = class AbstractTimerService {
152
163
  return;
153
164
  }
154
165
  for (const mark of marks) {
155
- this._telemetryService.publicLog2('startup.timer.mark', {
166
+ this._telemetryService.publicLog2("startup.timer.mark", {
156
167
  source,
157
168
  name: ( new TelemetryTrustedValue(mark.name)),
158
169
  startTime: mark.startTime
@@ -163,16 +174,15 @@ let AbstractTimerService = class AbstractTimerService {
163
174
  const initialStartup = this._isInitialStartup();
164
175
  let startMark;
165
176
  if (isWeb) {
166
- startMark = 'code/timeOrigin';
167
- }
168
- else {
169
- startMark = initialStartup ? 'code/didStartMain' : 'code/willOpenNewWindow';
177
+ startMark = "code/timeOrigin";
178
+ } else {
179
+ startMark = initialStartup ? "code/didStartMain" : "code/willOpenNewWindow";
170
180
  }
171
181
  const activeViewlet = this._paneCompositeService.getActivePaneComposite(ViewContainerLocation.Sidebar);
172
182
  const activeAuxiliaryViewlet = this._paneCompositeService.getActivePaneComposite(ViewContainerLocation.AuxiliaryBar);
173
183
  const activePanel = this._paneCompositeService.getActivePaneComposite(ViewContainerLocation.Panel);
174
184
  const info = {
175
- ellapsed: this._marks.getDuration(startMark, 'code/didStartWorkbench'),
185
+ ellapsed: this._marks.getDuration(startMark, "code/didStartWorkbench"),
176
186
  isLatestVersion: Boolean(await this._updateService.isLatestVersion()),
177
187
  didUseCachedData: this._didUseCachedData(),
178
188
  windowKind: this._lifecycleService.startupKind,
@@ -182,34 +192,37 @@ let AbstractTimerService = class AbstractTimerService {
182
192
  editorIds: ( this._editorService.visibleEditors.map(input => input.typeId)),
183
193
  panelId: activePanel ? activePanel.getId() : undefined,
184
194
  timers: {
185
- ellapsedAppReady: initialStartup ? this._marks.getDuration('code/didStartMain', 'code/mainAppReady') : undefined,
186
- ellapsedNlsGeneration: initialStartup ? this._marks.getDuration('code/willGenerateNls', 'code/didGenerateNls') : undefined,
187
- ellapsedLoadMainBundle: initialStartup ? this._marks.getDuration('code/willLoadMainBundle', 'code/didLoadMainBundle') : undefined,
188
- ellapsedRunMainBundle: initialStartup ? this._marks.getDuration('code/didStartMain', 'code/didRunMainBundle') : undefined,
189
- ellapsedCrashReporter: initialStartup ? this._marks.getDuration('code/willStartCrashReporter', 'code/didStartCrashReporter') : undefined,
190
- ellapsedMainServer: initialStartup ? this._marks.getDuration('code/willStartMainServer', 'code/didStartMainServer') : undefined,
191
- ellapsedWindowCreate: initialStartup ? this._marks.getDuration('code/willCreateCodeWindow', 'code/didCreateCodeWindow') : undefined,
192
- ellapsedWindowRestoreState: initialStartup ? this._marks.getDuration('code/willRestoreCodeWindowState', 'code/didRestoreCodeWindowState') : undefined,
193
- ellapsedBrowserWindowCreate: initialStartup ? this._marks.getDuration('code/willCreateCodeBrowserWindow', 'code/didCreateCodeBrowserWindow') : undefined,
194
- ellapsedWindowMaximize: initialStartup ? this._marks.getDuration('code/willMaximizeCodeWindow', 'code/didMaximizeCodeWindow') : undefined,
195
- ellapsedWindowLoad: initialStartup ? this._marks.getDuration('code/mainAppReady', 'code/willOpenNewWindow') : undefined,
196
- ellapsedWindowLoadToRequire: this._marks.getDuration('code/willOpenNewWindow', 'code/willLoadWorkbenchMain'),
197
- ellapsedRequire: this._marks.getDuration('code/willLoadWorkbenchMain', 'code/didLoadWorkbenchMain'),
198
- ellapsedWaitForWindowConfig: this._marks.getDuration('code/willWaitForWindowConfig', 'code/didWaitForWindowConfig'),
199
- ellapsedStorageInit: this._marks.getDuration('code/willInitStorage', 'code/didInitStorage'),
200
- ellapsedSharedProcesConnected: this._marks.getDuration('code/willConnectSharedProcess', 'code/didConnectSharedProcess'),
201
- ellapsedWorkspaceServiceInit: this._marks.getDuration('code/willInitWorkspaceService', 'code/didInitWorkspaceService'),
202
- ellapsedRequiredUserDataInit: this._marks.getDuration('code/willInitRequiredUserData', 'code/didInitRequiredUserData'),
203
- ellapsedOtherUserDataInit: this._marks.getDuration('code/willInitOtherUserData', 'code/didInitOtherUserData'),
204
- ellapsedExtensions: this._marks.getDuration('code/willLoadExtensions', 'code/didLoadExtensions'),
205
- ellapsedEditorRestore: this._marks.getDuration('code/willRestoreEditors', 'code/didRestoreEditors'),
206
- ellapsedViewletRestore: this._marks.getDuration('code/willRestoreViewlet', 'code/didRestoreViewlet'),
207
- ellapsedAuxiliaryViewletRestore: this._marks.getDuration('code/willRestoreAuxiliaryBar', 'code/didRestoreAuxiliaryBar'),
208
- ellapsedPanelRestore: this._marks.getDuration('code/willRestorePanel', 'code/didRestorePanel'),
209
- ellapsedWorkbenchContributions: this._marks.getDuration('code/willCreateWorkbenchContributions/1', 'code/didCreateWorkbenchContributions/2'),
210
- ellapsedWorkbench: this._marks.getDuration('code/willStartWorkbench', 'code/didStartWorkbench'),
211
- ellapsedExtensionsReady: this._marks.getDuration(startMark, 'code/didLoadExtensions'),
212
- ellapsedRenderer: this._marks.getDuration('code/didStartRenderer', 'code/didStartWorkbench')
195
+ ellapsedAppReady: initialStartup ? this._marks.getDuration("code/didStartMain", "code/mainAppReady") : undefined,
196
+ ellapsedNlsGeneration: initialStartup ? this._marks.getDuration("code/willGenerateNls", "code/didGenerateNls") : undefined,
197
+ ellapsedLoadMainBundle: initialStartup ? this._marks.getDuration("code/willLoadMainBundle", "code/didLoadMainBundle") : undefined,
198
+ ellapsedRunMainBundle: initialStartup ? this._marks.getDuration("code/didStartMain", "code/didRunMainBundle") : undefined,
199
+ ellapsedCrashReporter: initialStartup ? this._marks.getDuration("code/willStartCrashReporter", "code/didStartCrashReporter") : undefined,
200
+ ellapsedMainServer: initialStartup ? this._marks.getDuration("code/willStartMainServer", "code/didStartMainServer") : undefined,
201
+ ellapsedWindowCreate: initialStartup ? this._marks.getDuration("code/willCreateCodeWindow", "code/didCreateCodeWindow") : undefined,
202
+ ellapsedWindowRestoreState: initialStartup ? this._marks.getDuration("code/willRestoreCodeWindowState", "code/didRestoreCodeWindowState") : undefined,
203
+ ellapsedBrowserWindowCreate: initialStartup ? this._marks.getDuration("code/willCreateCodeBrowserWindow", "code/didCreateCodeBrowserWindow") : undefined,
204
+ ellapsedWindowMaximize: initialStartup ? this._marks.getDuration("code/willMaximizeCodeWindow", "code/didMaximizeCodeWindow") : undefined,
205
+ ellapsedWindowLoad: initialStartup ? this._marks.getDuration("code/mainAppReady", "code/willOpenNewWindow") : undefined,
206
+ ellapsedWindowLoadToRequire: this._marks.getDuration("code/willOpenNewWindow", "code/willLoadWorkbenchMain"),
207
+ ellapsedRequire: this._marks.getDuration("code/willLoadWorkbenchMain", "code/didLoadWorkbenchMain"),
208
+ ellapsedWaitForWindowConfig: this._marks.getDuration("code/willWaitForWindowConfig", "code/didWaitForWindowConfig"),
209
+ ellapsedStorageInit: this._marks.getDuration("code/willInitStorage", "code/didInitStorage"),
210
+ ellapsedSharedProcesConnected: this._marks.getDuration("code/willConnectSharedProcess", "code/didConnectSharedProcess"),
211
+ ellapsedWorkspaceServiceInit: this._marks.getDuration("code/willInitWorkspaceService", "code/didInitWorkspaceService"),
212
+ ellapsedRequiredUserDataInit: this._marks.getDuration("code/willInitRequiredUserData", "code/didInitRequiredUserData"),
213
+ ellapsedOtherUserDataInit: this._marks.getDuration("code/willInitOtherUserData", "code/didInitOtherUserData"),
214
+ ellapsedExtensions: this._marks.getDuration("code/willLoadExtensions", "code/didLoadExtensions"),
215
+ ellapsedEditorRestore: this._marks.getDuration("code/willRestoreEditors", "code/didRestoreEditors"),
216
+ ellapsedViewletRestore: this._marks.getDuration("code/willRestoreViewlet", "code/didRestoreViewlet"),
217
+ ellapsedAuxiliaryViewletRestore: this._marks.getDuration("code/willRestoreAuxiliaryBar", "code/didRestoreAuxiliaryBar"),
218
+ ellapsedPanelRestore: this._marks.getDuration("code/willRestorePanel", "code/didRestorePanel"),
219
+ ellapsedWorkbenchContributions: this._marks.getDuration(
220
+ "code/willCreateWorkbenchContributions/1",
221
+ "code/didCreateWorkbenchContributions/2"
222
+ ),
223
+ ellapsedWorkbench: this._marks.getDuration("code/willStartWorkbench", "code/didStartWorkbench"),
224
+ ellapsedExtensionsReady: this._marks.getDuration(startMark, "code/didLoadExtensions"),
225
+ ellapsedRenderer: this._marks.getDuration("code/didStartRenderer", "code/didStartWorkbench")
213
226
  },
214
227
  platform: undefined,
215
228
  release: undefined,
@@ -228,17 +241,7 @@ let AbstractTimerService = class AbstractTimerService {
228
241
  return info;
229
242
  }
230
243
  };
231
- AbstractTimerService = ( __decorate([
232
- ( __param(0, ILifecycleService)),
233
- ( __param(1, IWorkspaceContextService)),
234
- ( __param(2, IExtensionService)),
235
- ( __param(3, IUpdateService)),
236
- ( __param(4, IPaneCompositePartService)),
237
- ( __param(5, IEditorService)),
238
- ( __param(6, IAccessibilityService)),
239
- ( __param(7, ITelemetryService)),
240
- ( __param(8, IWorkbenchLayoutService))
241
- ], AbstractTimerService));
244
+ AbstractTimerService = ( __decorate([( __param(0, ILifecycleService)), ( __param(1, IWorkspaceContextService)), ( __param(2, IExtensionService)), ( __param(3, IUpdateService)), ( __param(4, IPaneCompositePartService)), ( __param(5, IEditorService)), ( __param(6, IAccessibilityService)), ( __param(7, ITelemetryService)), ( __param(8, IWorkbenchLayoutService))], AbstractTimerService));
242
245
  class TimerService extends AbstractTimerService {
243
246
  _isInitialStartup() {
244
247
  return false;