@codingame/monaco-vscode-walkthrough-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/package.json +10 -2
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.contribution.js +14 -10
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStarted.js +30 -24
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedDetailsRenderer.js +3 -3
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedExtensionPoint.js +377 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js +528 -0
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/startupPage.js +16 -14
- package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/common/gettingStartedContent.js +936 -0
- package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/editor/editorWalkThrough.js +1 -1
- package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/editor/vs_code_editor_walkthrough.js +1 -1
- package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/walkThroughActions.js +1 -1
- package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/browser/walkThroughPart.js +11 -10
- package/vscode/src/vs/workbench/contrib/welcomeWalkthrough/common/walkThroughContentProvider.js +1 -1
- package/walkthrough.js +2 -1
package/vscode/src/vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService.js
ADDED
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
+
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
3
|
+
import { Emitter } from 'vscode/vscode/vs/base/common/event';
|
|
4
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
5
|
+
import { Memento } from 'vscode/vscode/vs/workbench/common/memento';
|
|
6
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
|
|
7
|
+
import { RawContextKey, ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
8
|
+
import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
|
|
9
|
+
import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
10
|
+
import { IUserDataSyncEnablementService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync.service';
|
|
11
|
+
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
12
|
+
import { joinPath } from 'vscode/vscode/vs/base/common/resources';
|
|
13
|
+
import { FileAccess } from 'vscode/vscode/vs/base/common/network';
|
|
14
|
+
import { EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT, EXTENSION_INSTALL_DEP_PACK_CONTEXT } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement';
|
|
15
|
+
import { IExtensionManagementService } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagement.service';
|
|
16
|
+
import { walkthroughs } from '../common/gettingStartedContent.js';
|
|
17
|
+
import { IWorkbenchAssignmentService } from 'vscode/vscode/vs/workbench/services/assignment/common/assignmentService.service';
|
|
18
|
+
import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host.service';
|
|
19
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
20
|
+
import { parseLinkedText } from 'vscode/vscode/vs/base/common/linkedText';
|
|
21
|
+
import { walkthroughsExtensionPoint } from './gettingStartedExtensionPoint.js';
|
|
22
|
+
import { dirname } from 'vscode/vscode/vs/base/common/path';
|
|
23
|
+
import { coalesce, flatten } from 'vscode/vscode/vs/base/common/arrays';
|
|
24
|
+
import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
|
|
25
|
+
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
26
|
+
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
27
|
+
import { checkGlobFileExists } from 'vscode/vscode/vs/workbench/services/extensions/common/workspaceContains';
|
|
28
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
29
|
+
import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
|
|
30
|
+
import { getDefaultIconPath } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
|
|
31
|
+
|
|
32
|
+
const HasMultipleNewFileEntries = ( new RawContextKey('hasMultipleNewFileEntries', false));
|
|
33
|
+
const hiddenEntriesConfigurationKey = 'workbench.welcomePage.hiddenCategories';
|
|
34
|
+
const walkthroughMetadataConfigurationKey = 'workbench.welcomePage.walkthroughMetadata';
|
|
35
|
+
const BUILT_IN_SOURCE = ( localizeWithPath(
|
|
36
|
+
'vs/workbench/contrib/welcomeGettingStarted/browser/gettingStartedService',
|
|
37
|
+
'builtin',
|
|
38
|
+
"Built-In"
|
|
39
|
+
));
|
|
40
|
+
const DAYS = 24 * 60 * 60 * 1000;
|
|
41
|
+
const NEW_WALKTHROUGH_TIME = 7 * DAYS;
|
|
42
|
+
let WalkthroughsService = class WalkthroughsService extends Disposable {
|
|
43
|
+
constructor(storageService, commandService, instantiationService, workspaceContextService, contextService, userDataSyncEnablementService, configurationService, extensionManagementService, hostService, viewsService, telemetryService, tasExperimentService) {
|
|
44
|
+
super();
|
|
45
|
+
this.storageService = storageService;
|
|
46
|
+
this.commandService = commandService;
|
|
47
|
+
this.instantiationService = instantiationService;
|
|
48
|
+
this.workspaceContextService = workspaceContextService;
|
|
49
|
+
this.contextService = contextService;
|
|
50
|
+
this.userDataSyncEnablementService = userDataSyncEnablementService;
|
|
51
|
+
this.configurationService = configurationService;
|
|
52
|
+
this.extensionManagementService = extensionManagementService;
|
|
53
|
+
this.hostService = hostService;
|
|
54
|
+
this.viewsService = viewsService;
|
|
55
|
+
this.telemetryService = telemetryService;
|
|
56
|
+
this.tasExperimentService = tasExperimentService;
|
|
57
|
+
this._onDidAddWalkthrough = ( new Emitter());
|
|
58
|
+
this.onDidAddWalkthrough = this._onDidAddWalkthrough.event;
|
|
59
|
+
this._onDidRemoveWalkthrough = ( new Emitter());
|
|
60
|
+
this.onDidRemoveWalkthrough = this._onDidRemoveWalkthrough.event;
|
|
61
|
+
this._onDidChangeWalkthrough = ( new Emitter());
|
|
62
|
+
this.onDidChangeWalkthrough = this._onDidChangeWalkthrough.event;
|
|
63
|
+
this._onDidProgressStep = ( new Emitter());
|
|
64
|
+
this.onDidProgressStep = this._onDidProgressStep.event;
|
|
65
|
+
this.sessionEvents = ( new Set());
|
|
66
|
+
this.completionListeners = ( new Map());
|
|
67
|
+
this.gettingStartedContributions = ( new Map());
|
|
68
|
+
this.steps = ( new Map());
|
|
69
|
+
this.sessionInstalledExtensions = ( new Set());
|
|
70
|
+
this.categoryVisibilityContextKeys = ( new Set());
|
|
71
|
+
this.stepCompletionContextKeyExpressions = ( new Set());
|
|
72
|
+
this.stepCompletionContextKeys = ( new Set());
|
|
73
|
+
this.metadata = ( new Map(
|
|
74
|
+
JSON.parse(this.storageService.get(walkthroughMetadataConfigurationKey, 0 , '[]'))
|
|
75
|
+
));
|
|
76
|
+
this.memento = ( new Memento('gettingStartedService', this.storageService));
|
|
77
|
+
this.stepProgress = this.memento.getMemento(0 , 0 );
|
|
78
|
+
this.initCompletionEventListeners();
|
|
79
|
+
HasMultipleNewFileEntries.bindTo(this.contextService).set(false);
|
|
80
|
+
this.registerWalkthroughs();
|
|
81
|
+
}
|
|
82
|
+
registerWalkthroughs() {
|
|
83
|
+
walkthroughs.forEach(async (category, index) => {
|
|
84
|
+
this._registerWalkthrough({
|
|
85
|
+
...category,
|
|
86
|
+
icon: { type: 'icon', icon: category.icon },
|
|
87
|
+
order: walkthroughs.length - index,
|
|
88
|
+
source: BUILT_IN_SOURCE,
|
|
89
|
+
when: ContextKeyExpr.deserialize(category.when) ?? ContextKeyExpr.true(),
|
|
90
|
+
steps: ( category.content.steps.map((step, index) => {
|
|
91
|
+
return ({
|
|
92
|
+
...step,
|
|
93
|
+
completionEvents: step.completionEvents ?? [],
|
|
94
|
+
description: parseDescription(step.description),
|
|
95
|
+
category: category.id,
|
|
96
|
+
order: index,
|
|
97
|
+
when: ContextKeyExpr.deserialize(step.when) ?? ContextKeyExpr.true(),
|
|
98
|
+
media: step.media.type === 'image'
|
|
99
|
+
? {
|
|
100
|
+
type: 'image',
|
|
101
|
+
altText: step.media.altText,
|
|
102
|
+
path: convertInternalMediaPathsToBrowserURIs(step.media.path)
|
|
103
|
+
}
|
|
104
|
+
: step.media.type === 'svg'
|
|
105
|
+
? {
|
|
106
|
+
type: 'svg',
|
|
107
|
+
altText: step.media.altText,
|
|
108
|
+
path: convertInternalMediaPathToFileURI(step.media.path).with({ query: JSON.stringify({ moduleId: 'vs/workbench/contrib/welcomeGettingStarted/common/media/' + step.media.path }) })
|
|
109
|
+
}
|
|
110
|
+
: {
|
|
111
|
+
type: 'markdown',
|
|
112
|
+
path: convertInternalMediaPathToFileURI(step.media.path).with({ query: JSON.stringify({ moduleId: 'vs/workbench/contrib/welcomeGettingStarted/common/media/' + step.media.path }) }),
|
|
113
|
+
base: ( FileAccess.asFileUri('vs/workbench/contrib/welcomeGettingStarted/common/media/')),
|
|
114
|
+
root: ( FileAccess.asFileUri('vs/workbench/contrib/welcomeGettingStarted/common/media/')),
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}))
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
walkthroughsExtensionPoint.setHandler((_, { added, removed }) => {
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
initCompletionEventListeners() {
|
|
124
|
+
this._register(this.commandService.onDidExecuteCommand(command => this.progressByEvent(`onCommand:${command.commandId}`)));
|
|
125
|
+
this.extensionManagementService.getInstalled().then(installed => {
|
|
126
|
+
installed.forEach(ext => this.progressByEvent(`extensionInstalled:${ext.identifier.id.toLowerCase()}`));
|
|
127
|
+
});
|
|
128
|
+
this._register(this.extensionManagementService.onDidInstallExtensions(async (result) => {
|
|
129
|
+
const hadLastFoucs = await this.hostService.hadLastFocus();
|
|
130
|
+
for (const e of result) {
|
|
131
|
+
const skipWalkthrough = e?.context?.[EXTENSION_INSTALL_SKIP_WALKTHROUGH_CONTEXT] || e?.context?.[EXTENSION_INSTALL_DEP_PACK_CONTEXT];
|
|
132
|
+
if (hadLastFoucs && !skipWalkthrough) {
|
|
133
|
+
this.sessionInstalledExtensions.add(e.identifier.id.toLowerCase());
|
|
134
|
+
}
|
|
135
|
+
this.progressByEvent(`extensionInstalled:${e.identifier.id.toLowerCase()}`);
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
this._register(this.contextService.onDidChangeContext(event => {
|
|
139
|
+
if (event.affectsSome(this.stepCompletionContextKeys)) {
|
|
140
|
+
this.stepCompletionContextKeyExpressions.forEach(expression => {
|
|
141
|
+
if (event.affectsSome(( new Set(( expression.keys())))) && this.contextService.contextMatchesRules(expression)) {
|
|
142
|
+
this.progressByEvent(`onContext:` + expression.serialize());
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}));
|
|
147
|
+
this._register(this.viewsService.onDidChangeViewVisibility(e => {
|
|
148
|
+
if (e.visible) {
|
|
149
|
+
this.progressByEvent('onView:' + e.id);
|
|
150
|
+
}
|
|
151
|
+
}));
|
|
152
|
+
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
|
153
|
+
e.affectedKeys.forEach(key => { this.progressByEvent('onSettingChanged:' + key); });
|
|
154
|
+
}));
|
|
155
|
+
if (this.userDataSyncEnablementService.isEnabled()) {
|
|
156
|
+
this.progressByEvent('onEvent:sync-enabled');
|
|
157
|
+
}
|
|
158
|
+
this._register(this.userDataSyncEnablementService.onDidChangeEnablement(() => {
|
|
159
|
+
if (this.userDataSyncEnablementService.isEnabled()) {
|
|
160
|
+
this.progressByEvent('onEvent:sync-enabled');
|
|
161
|
+
}
|
|
162
|
+
}));
|
|
163
|
+
}
|
|
164
|
+
markWalkthroughOpened(id) {
|
|
165
|
+
const walkthrough = this.gettingStartedContributions.get(id);
|
|
166
|
+
const prior = this.metadata.get(id);
|
|
167
|
+
if (prior && walkthrough) {
|
|
168
|
+
this.metadata.set(id, { ...prior, manaullyOpened: true, stepIDs: ( walkthrough.steps.map(s => s.id)) });
|
|
169
|
+
}
|
|
170
|
+
this.storageService.store(walkthroughMetadataConfigurationKey, JSON.stringify([...this.metadata.entries()]), 0 , 0 );
|
|
171
|
+
}
|
|
172
|
+
async registerExtensionWalkthroughContributions(extension) {
|
|
173
|
+
const convertExtensionPathToFileURI = (path) => path.startsWith('https://')
|
|
174
|
+
? ( URI.parse(path, true))
|
|
175
|
+
: FileAccess.uriToFileUri(joinPath(extension.extensionLocation, path));
|
|
176
|
+
const convertExtensionRelativePathsToBrowserURIs = (path) => {
|
|
177
|
+
const convertPath = (path) => path.startsWith('https://')
|
|
178
|
+
? ( URI.parse(path, true))
|
|
179
|
+
: FileAccess.uriToBrowserUri(joinPath(extension.extensionLocation, path));
|
|
180
|
+
if (typeof path === 'string') {
|
|
181
|
+
const converted = convertPath(path);
|
|
182
|
+
return { hcDark: converted, hcLight: converted, dark: converted, light: converted };
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
return {
|
|
186
|
+
hcDark: convertPath(path.hc),
|
|
187
|
+
hcLight: convertPath(path.hcLight ?? path.light),
|
|
188
|
+
light: convertPath(path.light),
|
|
189
|
+
dark: convertPath(path.dark)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
if (!(extension.contributes?.walkthroughs?.length)) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
let sectionToOpen;
|
|
197
|
+
let sectionToOpenIndex = Math.min();
|
|
198
|
+
await Promise.all(extension.contributes?.walkthroughs?.map(async (walkthrough, index) => {
|
|
199
|
+
const categoryID = extension.identifier.value + '#' + walkthrough.id;
|
|
200
|
+
const isNewlyInstalled = !this.metadata.get(categoryID);
|
|
201
|
+
if (isNewlyInstalled) {
|
|
202
|
+
this.metadata.set(categoryID, { firstSeen: +( new Date()), stepIDs: walkthrough.steps?.map(s => s.id) ?? [], manaullyOpened: false });
|
|
203
|
+
}
|
|
204
|
+
const override = await Promise.race([
|
|
205
|
+
this.tasExperimentService?.getTreatment(`gettingStarted.overrideCategory.${extension.identifier.value + '.' + walkthrough.id}.when`),
|
|
206
|
+
( new Promise(resolve => setTimeout(() => resolve(walkthrough.when), 5000)))
|
|
207
|
+
]);
|
|
208
|
+
if (( this.sessionInstalledExtensions.has(extension.identifier.value.toLowerCase()))
|
|
209
|
+
&& this.contextService.contextMatchesRules(ContextKeyExpr.deserialize(override ?? walkthrough.when) ?? ContextKeyExpr.true())) {
|
|
210
|
+
this.sessionInstalledExtensions.delete(extension.identifier.value.toLowerCase());
|
|
211
|
+
if (index < sectionToOpenIndex && isNewlyInstalled) {
|
|
212
|
+
sectionToOpen = categoryID;
|
|
213
|
+
sectionToOpenIndex = index;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const steps = ( (walkthrough.steps ?? []).map((step, index) => {
|
|
217
|
+
const description = parseDescription(step.description || '');
|
|
218
|
+
const fullyQualifiedID = extension.identifier.value + '#' + walkthrough.id + '#' + step.id;
|
|
219
|
+
let media;
|
|
220
|
+
if (!step.media) {
|
|
221
|
+
throw Error('missing media in walkthrough step: ' + walkthrough.id + '@' + step.id);
|
|
222
|
+
}
|
|
223
|
+
if (step.media.image) {
|
|
224
|
+
const altText = step.media.altText;
|
|
225
|
+
if (altText === undefined) {
|
|
226
|
+
console.error('Walkthrough item:', fullyQualifiedID, 'is missing altText for its media element.');
|
|
227
|
+
}
|
|
228
|
+
media = { type: 'image', altText, path: convertExtensionRelativePathsToBrowserURIs(step.media.image) };
|
|
229
|
+
}
|
|
230
|
+
else if (step.media.markdown) {
|
|
231
|
+
media = {
|
|
232
|
+
type: 'markdown',
|
|
233
|
+
path: convertExtensionPathToFileURI(step.media.markdown),
|
|
234
|
+
base: convertExtensionPathToFileURI(dirname(step.media.markdown)),
|
|
235
|
+
root: FileAccess.uriToFileUri(extension.extensionLocation),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
else if (step.media.svg) {
|
|
239
|
+
media = {
|
|
240
|
+
type: 'svg',
|
|
241
|
+
path: convertExtensionPathToFileURI(step.media.svg),
|
|
242
|
+
altText: step.media.svg,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
throw new Error('Unknown walkthrough format detected for ' + fullyQualifiedID);
|
|
247
|
+
}
|
|
248
|
+
return ({
|
|
249
|
+
description,
|
|
250
|
+
media,
|
|
251
|
+
completionEvents: step.completionEvents?.filter(x => typeof x === 'string') ?? [],
|
|
252
|
+
id: fullyQualifiedID,
|
|
253
|
+
title: step.title,
|
|
254
|
+
when: ContextKeyExpr.deserialize(step.when) ?? ContextKeyExpr.true(),
|
|
255
|
+
category: categoryID,
|
|
256
|
+
order: index,
|
|
257
|
+
});
|
|
258
|
+
}));
|
|
259
|
+
let isFeatured = false;
|
|
260
|
+
if (walkthrough.featuredFor) {
|
|
261
|
+
const folders = ( this.workspaceContextService.getWorkspace().folders.map(f => f.uri));
|
|
262
|
+
const token = ( new CancellationTokenSource());
|
|
263
|
+
setTimeout(() => token.cancel(), 2000);
|
|
264
|
+
isFeatured = await this.instantiationService.invokeFunction(a => checkGlobFileExists(a, folders, walkthrough.featuredFor, token.token));
|
|
265
|
+
}
|
|
266
|
+
const iconStr = walkthrough.icon ?? extension.icon;
|
|
267
|
+
const walkthoughDescriptor = {
|
|
268
|
+
description: walkthrough.description,
|
|
269
|
+
title: walkthrough.title,
|
|
270
|
+
id: categoryID,
|
|
271
|
+
isFeatured,
|
|
272
|
+
source: extension.displayName ?? extension.name,
|
|
273
|
+
order: 0,
|
|
274
|
+
steps,
|
|
275
|
+
icon: {
|
|
276
|
+
type: 'image',
|
|
277
|
+
path: iconStr
|
|
278
|
+
? ( FileAccess.uriToBrowserUri(joinPath(extension.extensionLocation, iconStr)).toString(true))
|
|
279
|
+
: getDefaultIconPath()
|
|
280
|
+
},
|
|
281
|
+
when: ContextKeyExpr.deserialize(override ?? walkthrough.when) ?? ContextKeyExpr.true(),
|
|
282
|
+
};
|
|
283
|
+
this._registerWalkthrough(walkthoughDescriptor);
|
|
284
|
+
this._onDidAddWalkthrough.fire(this.resolveWalkthrough(walkthoughDescriptor));
|
|
285
|
+
}));
|
|
286
|
+
this.storageService.store(walkthroughMetadataConfigurationKey, JSON.stringify([...this.metadata.entries()]), 0 , 0 );
|
|
287
|
+
if (sectionToOpen && this.configurationService.getValue('workbench.welcomePage.walkthroughs.openOnInstall')) {
|
|
288
|
+
this.telemetryService.publicLog2('gettingStarted.didAutoOpenWalkthrough', { id: sectionToOpen });
|
|
289
|
+
this.commandService.executeCommand('workbench.action.openWalkthrough', sectionToOpen, true);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
unregisterExtensionWalkthroughContributions(extension) {
|
|
293
|
+
if (!(extension.contributes?.walkthroughs?.length)) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
extension.contributes?.walkthroughs?.forEach(section => {
|
|
297
|
+
const categoryID = extension.identifier.value + '#' + section.id;
|
|
298
|
+
section.steps.forEach(step => {
|
|
299
|
+
const fullyQualifiedID = extension.identifier.value + '#' + section.id + '#' + step.id;
|
|
300
|
+
this.steps.delete(fullyQualifiedID);
|
|
301
|
+
});
|
|
302
|
+
this.gettingStartedContributions.delete(categoryID);
|
|
303
|
+
this._onDidRemoveWalkthrough.fire(categoryID);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
getWalkthrough(id) {
|
|
307
|
+
const walkthrough = this.gettingStartedContributions.get(id);
|
|
308
|
+
if (!walkthrough) {
|
|
309
|
+
throw Error('Trying to get unknown walkthrough: ' + id);
|
|
310
|
+
}
|
|
311
|
+
return this.resolveWalkthrough(walkthrough);
|
|
312
|
+
}
|
|
313
|
+
getWalkthroughs() {
|
|
314
|
+
const registeredCategories = [...( this.gettingStartedContributions.values())];
|
|
315
|
+
const categoriesWithCompletion = ( ( registeredCategories
|
|
316
|
+
.map(category => {
|
|
317
|
+
return {
|
|
318
|
+
...category,
|
|
319
|
+
content: {
|
|
320
|
+
type: 'steps',
|
|
321
|
+
steps: category.steps
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}))
|
|
325
|
+
.filter(category => category.content.type !== 'steps' || category.content.steps.length)
|
|
326
|
+
.map(category => this.resolveWalkthrough(category)));
|
|
327
|
+
return categoriesWithCompletion;
|
|
328
|
+
}
|
|
329
|
+
resolveWalkthrough(category) {
|
|
330
|
+
const stepsWithProgress = ( category.steps.map(step => this.getStepProgress(step)));
|
|
331
|
+
const hasOpened = this.metadata.get(category.id)?.manaullyOpened;
|
|
332
|
+
const firstSeenDate = this.metadata.get(category.id)?.firstSeen;
|
|
333
|
+
const isNew = firstSeenDate && firstSeenDate > (+( new Date()) - NEW_WALKTHROUGH_TIME);
|
|
334
|
+
const lastStepIDs = this.metadata.get(category.id)?.stepIDs;
|
|
335
|
+
const rawCategory = this.gettingStartedContributions.get(category.id);
|
|
336
|
+
if (!rawCategory) {
|
|
337
|
+
throw Error('Could not find walkthrough with id ' + category.id);
|
|
338
|
+
}
|
|
339
|
+
const currentStepIds = ( rawCategory.steps.map(s => s.id));
|
|
340
|
+
const hasNewSteps = lastStepIDs && (currentStepIds.length !== lastStepIDs.length || ( currentStepIds.some((id, index) => id !== lastStepIDs[index])));
|
|
341
|
+
let recencyBonus = 0;
|
|
342
|
+
if (firstSeenDate) {
|
|
343
|
+
const currentDate = +( new Date());
|
|
344
|
+
const timeSinceFirstSeen = currentDate - firstSeenDate;
|
|
345
|
+
recencyBonus = Math.max(0, (NEW_WALKTHROUGH_TIME - timeSinceFirstSeen) / NEW_WALKTHROUGH_TIME);
|
|
346
|
+
}
|
|
347
|
+
return {
|
|
348
|
+
...category,
|
|
349
|
+
recencyBonus,
|
|
350
|
+
steps: stepsWithProgress,
|
|
351
|
+
newItems: !!hasNewSteps,
|
|
352
|
+
newEntry: !!(isNew && !hasOpened),
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
getStepProgress(step) {
|
|
356
|
+
return {
|
|
357
|
+
...step,
|
|
358
|
+
done: false,
|
|
359
|
+
...this.stepProgress[step.id]
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
progressStep(id) {
|
|
363
|
+
const oldProgress = this.stepProgress[id];
|
|
364
|
+
if (!oldProgress || oldProgress.done !== true) {
|
|
365
|
+
this.stepProgress[id] = { done: true };
|
|
366
|
+
this.memento.saveMemento();
|
|
367
|
+
const step = this.getStep(id);
|
|
368
|
+
if (!step) {
|
|
369
|
+
throw Error('Tried to progress unknown step');
|
|
370
|
+
}
|
|
371
|
+
this._onDidProgressStep.fire(this.getStepProgress(step));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
deprogressStep(id) {
|
|
375
|
+
delete this.stepProgress[id];
|
|
376
|
+
this.memento.saveMemento();
|
|
377
|
+
const step = this.getStep(id);
|
|
378
|
+
this._onDidProgressStep.fire(this.getStepProgress(step));
|
|
379
|
+
}
|
|
380
|
+
progressByEvent(event) {
|
|
381
|
+
if (( this.sessionEvents.has(event))) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
this.sessionEvents.add(event);
|
|
385
|
+
this.completionListeners.get(event)?.forEach(id => this.progressStep(id));
|
|
386
|
+
}
|
|
387
|
+
registerWalkthrough(walkthoughDescriptor) {
|
|
388
|
+
this._registerWalkthrough({
|
|
389
|
+
...walkthoughDescriptor,
|
|
390
|
+
steps: ( walkthoughDescriptor.steps.map(step => ({ ...step, description: parseDescription(step.description) })))
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
_registerWalkthrough(walkthroughDescriptor) {
|
|
394
|
+
const oldCategory = this.gettingStartedContributions.get(walkthroughDescriptor.id);
|
|
395
|
+
if (oldCategory) {
|
|
396
|
+
console.error(`Skipping attempt to overwrite walkthrough. (${walkthroughDescriptor.id})`);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
this.gettingStartedContributions.set(walkthroughDescriptor.id, walkthroughDescriptor);
|
|
400
|
+
walkthroughDescriptor.steps.forEach(step => {
|
|
401
|
+
if (( this.steps.has(step.id))) {
|
|
402
|
+
throw Error('Attempting to register step with id ' + step.id + ' twice. Second is dropped.');
|
|
403
|
+
}
|
|
404
|
+
this.steps.set(step.id, step);
|
|
405
|
+
( step.when.keys()).forEach(key => this.categoryVisibilityContextKeys.add(key));
|
|
406
|
+
this.registerDoneListeners(step);
|
|
407
|
+
});
|
|
408
|
+
( walkthroughDescriptor.when.keys()).forEach(key => this.categoryVisibilityContextKeys.add(key));
|
|
409
|
+
}
|
|
410
|
+
registerDoneListeners(step) {
|
|
411
|
+
if (step.doneOn) {
|
|
412
|
+
console.error(`wakthrough step`, step, `uses deprecated 'doneOn' property. Adopt 'completionEvents' to silence this warning`);
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
if (!step.completionEvents.length) {
|
|
416
|
+
step.completionEvents = coalesce(flatten(( step.description
|
|
417
|
+
.filter(linkedText => linkedText.nodes.length === 1)
|
|
418
|
+
.map(linkedText => ( linkedText.nodes
|
|
419
|
+
.filter(((node) => typeof node !== 'string'))
|
|
420
|
+
.map(({ href }) => {
|
|
421
|
+
if (href.startsWith('command:')) {
|
|
422
|
+
return 'onCommand:' + href.slice('command:'.length, href.includes('?') ? href.indexOf('?') : undefined);
|
|
423
|
+
}
|
|
424
|
+
if (href.startsWith('https://') || href.startsWith('http://')) {
|
|
425
|
+
return 'onLink:' + href;
|
|
426
|
+
}
|
|
427
|
+
return undefined;
|
|
428
|
+
}))))));
|
|
429
|
+
}
|
|
430
|
+
if (!step.completionEvents.length) {
|
|
431
|
+
step.completionEvents.push('stepSelected');
|
|
432
|
+
}
|
|
433
|
+
for (let event of step.completionEvents) {
|
|
434
|
+
const [_, eventType, argument] = /^([^:]*):?(.*)$/.exec(event) ?? [];
|
|
435
|
+
if (!eventType) {
|
|
436
|
+
console.error(`Unknown completionEvent ${event} when registering step ${step.id}`);
|
|
437
|
+
continue;
|
|
438
|
+
}
|
|
439
|
+
switch (eventType) {
|
|
440
|
+
case 'onLink':
|
|
441
|
+
case 'onEvent':
|
|
442
|
+
case 'onView':
|
|
443
|
+
case 'onSettingChanged':
|
|
444
|
+
break;
|
|
445
|
+
case 'onContext': {
|
|
446
|
+
const expression = ContextKeyExpr.deserialize(argument);
|
|
447
|
+
if (expression) {
|
|
448
|
+
this.stepCompletionContextKeyExpressions.add(expression);
|
|
449
|
+
( expression.keys()).forEach(key => this.stepCompletionContextKeys.add(key));
|
|
450
|
+
event = eventType + ':' + expression.serialize();
|
|
451
|
+
if (this.contextService.contextMatchesRules(expression)) {
|
|
452
|
+
this.sessionEvents.add(event);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
console.error('Unable to parse context key expression:', expression, 'in walkthrough step', step.id);
|
|
457
|
+
}
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
case 'onStepSelected':
|
|
461
|
+
case 'stepSelected':
|
|
462
|
+
event = 'stepSelected:' + step.id;
|
|
463
|
+
break;
|
|
464
|
+
case 'onCommand':
|
|
465
|
+
event = eventType + ':' + argument.replace(/^toSide:/, '');
|
|
466
|
+
break;
|
|
467
|
+
case 'onExtensionInstalled':
|
|
468
|
+
case 'extensionInstalled':
|
|
469
|
+
event = 'extensionInstalled:' + argument.toLowerCase();
|
|
470
|
+
break;
|
|
471
|
+
default:
|
|
472
|
+
console.error(`Unknown completionEvent ${event} when registering step ${step.id}`);
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
this.registerCompletionListener(event, step);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
registerCompletionListener(event, step) {
|
|
479
|
+
if (!( this.completionListeners.has(event))) {
|
|
480
|
+
this.completionListeners.set(event, ( new Set()));
|
|
481
|
+
}
|
|
482
|
+
this.completionListeners.get(event)?.add(step.id);
|
|
483
|
+
}
|
|
484
|
+
getStep(id) {
|
|
485
|
+
const step = this.steps.get(id);
|
|
486
|
+
if (!step) {
|
|
487
|
+
throw Error('Attempting to access step which does not exist in registry ' + id);
|
|
488
|
+
}
|
|
489
|
+
return step;
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
WalkthroughsService = ( __decorate([
|
|
493
|
+
( __param(0, IStorageService)),
|
|
494
|
+
( __param(1, ICommandService)),
|
|
495
|
+
( __param(2, IInstantiationService)),
|
|
496
|
+
( __param(3, IWorkspaceContextService)),
|
|
497
|
+
( __param(4, IContextKeyService)),
|
|
498
|
+
( __param(5, IUserDataSyncEnablementService)),
|
|
499
|
+
( __param(6, IConfigurationService)),
|
|
500
|
+
( __param(7, IExtensionManagementService)),
|
|
501
|
+
( __param(8, IHostService)),
|
|
502
|
+
( __param(9, IViewsService)),
|
|
503
|
+
( __param(10, ITelemetryService)),
|
|
504
|
+
( __param(11, IWorkbenchAssignmentService))
|
|
505
|
+
], WalkthroughsService));
|
|
506
|
+
const parseDescription = (desc) => ( desc.split('\n').filter(x => x).map(text => parseLinkedText(text)));
|
|
507
|
+
const convertInternalMediaPathToFileURI = (path) => path.startsWith('https://')
|
|
508
|
+
? ( URI.parse(path, true))
|
|
509
|
+
: ( FileAccess.asFileUri(`vs/workbench/contrib/welcomeGettingStarted/common/media/${path}`));
|
|
510
|
+
const convertInternalMediaPathToBrowserURI = (path) => path.startsWith('https://')
|
|
511
|
+
? ( URI.parse(path, true))
|
|
512
|
+
: ( FileAccess.asBrowserUri(`vs/workbench/contrib/welcomeGettingStarted/common/media/${path}`));
|
|
513
|
+
const convertInternalMediaPathsToBrowserURIs = (path) => {
|
|
514
|
+
if (typeof path === 'string') {
|
|
515
|
+
const converted = convertInternalMediaPathToBrowserURI(path);
|
|
516
|
+
return { hcDark: converted, hcLight: converted, dark: converted, light: converted };
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
return {
|
|
520
|
+
hcDark: convertInternalMediaPathToBrowserURI(path.hc),
|
|
521
|
+
hcLight: convertInternalMediaPathToBrowserURI(path.hcLight ?? path.light),
|
|
522
|
+
light: convertInternalMediaPathToBrowserURI(path.light),
|
|
523
|
+
dark: convertInternalMediaPathToBrowserURI(path.dark)
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
export { HasMultipleNewFileEntries, WalkthroughsService, convertInternalMediaPathToFileURI, hiddenEntriesConfigurationKey, parseDescription, walkthroughMetadataConfigurationKey };
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
|
|
2
|
-
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands';
|
|
2
|
+
import { ICommandService } from 'vscode/vscode/vs/platform/commands/common/commands.service';
|
|
3
3
|
import { coalesce } from 'vscode/vscode/vs/base/common/arrays';
|
|
4
4
|
import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
|
|
5
|
-
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
|
|
5
|
+
import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
|
|
6
6
|
import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
|
|
7
|
-
import { UNKNOWN_EMPTY_WINDOW_WORKSPACE
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
7
|
+
import { UNKNOWN_EMPTY_WINDOW_WORKSPACE } from 'vscode/vscode/vs/platform/workspace/common/workspace';
|
|
8
|
+
import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
|
|
9
|
+
import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
|
|
10
|
+
import { IWorkingCopyBackupService } from 'vscode/vscode/vs/workbench/services/workingCopy/common/workingCopyBackup.service';
|
|
11
|
+
import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle.service';
|
|
12
|
+
import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
|
|
12
13
|
import { joinPath } from 'vscode/vscode/vs/base/common/resources';
|
|
13
|
-
import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
|
|
14
|
+
import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService.service';
|
|
14
15
|
import { GettingStartedInput, gettingStartedInputTypeId } from './gettingStartedInput.js';
|
|
15
|
-
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
|
|
16
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
|
|
16
|
+
import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService.service';
|
|
17
|
+
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
17
18
|
import { getTelemetryLevel } from 'vscode/vscode/vs/platform/telemetry/common/telemetryUtils';
|
|
18
|
-
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
|
|
19
|
-
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
|
|
20
|
-
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
|
|
19
|
+
import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
|
|
20
|
+
import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
|
|
21
|
+
import { INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification.service';
|
|
21
22
|
import { localizeWithPath } from 'vscode/vscode/vs/nls';
|
|
22
|
-
import { RegisteredEditorPriority
|
|
23
|
+
import { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
24
|
+
import { IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService.service';
|
|
23
25
|
|
|
24
26
|
const restoreWalkthroughsConfigurationKey = 'workbench.welcomePage.restorableWalkthroughs';
|
|
25
27
|
const configurationKey = 'workbench.startupEditor';
|