@codingame/monaco-vscode-issue-service-override 2.2.0-next.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.
@@ -0,0 +1,11 @@
1
+ function __decorate(decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ }
7
+ function __param(paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ }
10
+
11
+ export { __decorate, __param };
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { default } from './issue.js';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from './issue.js';
package/issue.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { IEditorOverrideServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
2
+
3
+ declare function getServiceOverride(): IEditorOverrideServices;
4
+
5
+ export { getServiceOverride as default };
package/issue.js ADDED
@@ -0,0 +1,12 @@
1
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
+ import { IWorkbenchIssueService } from 'vscode/vscode/vs/workbench/services/issue/common/issue';
3
+ import { WebIssueService } from './vscode/src/vs/workbench/services/issue/browser/issueService.js';
4
+ import './vscode/src/vs/workbench/contrib/issue/browser/issue.contribution.js';
5
+
6
+ function getServiceOverride() {
7
+ return {
8
+ [( IWorkbenchIssueService.toString())]: new SyncDescriptor(WebIssueService, [], false)
9
+ };
10
+ }
11
+
12
+ export { getServiceOverride as default };
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@codingame/monaco-vscode-issue-service-override",
3
+ "version": "2.2.0-next.1",
4
+ "keywords": [],
5
+ "author": {
6
+ "name": "CodinGame",
7
+ "url": "http://www.codingame.com"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git@github.com:CodinGame/monaco-vscode-api.git"
13
+ },
14
+ "type": "module",
15
+ "private": false,
16
+ "description": "VSCode public API plugged on the monaco editor - issue service-override",
17
+ "main": "index.js",
18
+ "module": "index.js",
19
+ "types": "index.d.ts",
20
+ "dependencies": {
21
+ "vscode": "npm:@codingame/monaco-vscode-api@2.2.0-next.1"
22
+ }
23
+ }
@@ -0,0 +1,17 @@
1
+ import { rtrim } from 'vscode/vscode/vs/base/common/strings';
2
+
3
+ function normalizeGitHubUrl(url) {
4
+ if (url.endsWith('.git')) {
5
+ url = url.substr(0, url.length - 4);
6
+ }
7
+ url = rtrim(url, '/');
8
+ if (url.endsWith('/new')) {
9
+ url = rtrim(url, '/new');
10
+ }
11
+ if (url.endsWith('/issues')) {
12
+ url = rtrim(url, '/issues');
13
+ }
14
+ return url;
15
+ }
16
+
17
+ export { normalizeGitHubUrl };
@@ -0,0 +1,24 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
4
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
5
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
6
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
7
+ import { BaseIssueContribution } from '../common/issue.contribution.js';
8
+
9
+ let WebIssueContribution = class WebIssueContribution extends BaseIssueContribution {
10
+ constructor(productService) {
11
+ super(productService);
12
+ }
13
+ };
14
+ WebIssueContribution = ( __decorate([
15
+ ( __param(0, IProductService))
16
+ ], WebIssueContribution));
17
+ ( Registry.as(Extensions.Workbench)).registerWorkbenchContribution(WebIssueContribution, 3 );
18
+ CommandsRegistry.registerCommand('_issues.getSystemStatus', (accessor) => {
19
+ return ( localizeWithPath(
20
+ 'vs/workbench/contrib/issue/browser/issue.contribution',
21
+ 'statusUnsupported',
22
+ "The --status argument is not yet supported in browsers."
23
+ ));
24
+ });
@@ -0,0 +1,103 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
4
+ import { MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
5
+ import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
6
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
7
+ import { IWorkbenchIssueService } from 'vscode/vscode/vs/workbench/services/issue/common/issue';
8
+
9
+ const OpenIssueReporterActionId = 'workbench.action.openIssueReporter';
10
+ const OpenIssueReporterApiId = 'vscode.openIssueReporter';
11
+ const OpenIssueReporterCommandMetadata = {
12
+ description: 'Open the issue reporter and optionally prefill part of the form.',
13
+ args: [
14
+ {
15
+ name: 'options',
16
+ description: 'Data to use to prefill the issue reporter with.',
17
+ isOptional: true,
18
+ schema: {
19
+ oneOf: [
20
+ {
21
+ type: 'string',
22
+ description: 'The extension id to preselect.'
23
+ },
24
+ {
25
+ type: 'object',
26
+ properties: {
27
+ extensionId: {
28
+ type: 'string'
29
+ },
30
+ issueTitle: {
31
+ type: 'string'
32
+ },
33
+ issueBody: {
34
+ type: 'string'
35
+ }
36
+ }
37
+ }
38
+ ]
39
+ }
40
+ },
41
+ ]
42
+ };
43
+ let BaseIssueContribution = class BaseIssueContribution {
44
+ constructor(productService) {
45
+ if (!productService.reportIssueUrl) {
46
+ return;
47
+ }
48
+ CommandsRegistry.registerCommand({
49
+ id: OpenIssueReporterActionId,
50
+ handler: function (accessor, args) {
51
+ const data = typeof args === 'string'
52
+ ? { extensionId: args }
53
+ : Array.isArray(args)
54
+ ? { extensionId: args[0] }
55
+ : args ?? {};
56
+ return accessor.get(IWorkbenchIssueService).openReporter(data);
57
+ },
58
+ metadata: OpenIssueReporterCommandMetadata
59
+ });
60
+ CommandsRegistry.registerCommand({
61
+ id: OpenIssueReporterApiId,
62
+ handler: function (accessor, args) {
63
+ const data = typeof args === 'string'
64
+ ? { extensionId: args }
65
+ : Array.isArray(args)
66
+ ? { extensionId: args[0] }
67
+ : args ?? {};
68
+ return accessor.get(IWorkbenchIssueService).openReporter(data);
69
+ },
70
+ metadata: OpenIssueReporterCommandMetadata
71
+ });
72
+ const reportIssue = {
73
+ id: OpenIssueReporterActionId,
74
+ title: {
75
+ value: ( localizeWithPath(
76
+ 'vs/workbench/contrib/issue/common/issue.contribution',
77
+ { key: 'reportIssueInEnglish', comment: ['Translate this to "Report Issue in English" in all languages please!'] },
78
+ "Report Issue..."
79
+ )),
80
+ original: 'Report Issue...'
81
+ },
82
+ category: Categories.Help
83
+ };
84
+ MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: reportIssue });
85
+ MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
86
+ group: '3_feedback',
87
+ command: {
88
+ id: OpenIssueReporterActionId,
89
+ title: ( localizeWithPath(
90
+ 'vs/workbench/contrib/issue/common/issue.contribution',
91
+ { key: 'miReportIssue', comment: ['&& denotes a mnemonic', 'Translate this to "Report Issue in English" in all languages please!'] },
92
+ "Report &&Issue"
93
+ ))
94
+ },
95
+ order: 3
96
+ });
97
+ }
98
+ };
99
+ BaseIssueContribution = ( __decorate([
100
+ ( __param(0, IProductService))
101
+ ], BaseIssueContribution));
102
+
103
+ export { BaseIssueContribution };
@@ -0,0 +1,99 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { windowOpenNoOpener } from 'vscode/vscode/vs/base/browser/dom';
3
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
4
+ import { toDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
+ import { userAgent } from 'vscode/vscode/vs/base/common/platform';
6
+ import { normalizeGitHubUrl } from '../../../../platform/issue/common/issueReporterUtil.js';
7
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
8
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
9
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
10
+
11
+ let WebIssueService = class WebIssueService {
12
+ constructor(extensionService, productService, logService) {
13
+ this.extensionService = extensionService;
14
+ this.productService = productService;
15
+ this.logService = logService;
16
+ this._handlers = ( new Map());
17
+ this._providers = ( new Map());
18
+ }
19
+ async openProcessExplorer() {
20
+ console.error('openProcessExplorer is not implemented in web');
21
+ }
22
+ async openReporter(options) {
23
+ const extensionId = options.extensionId;
24
+ if (!extensionId) {
25
+ if (this.productService.reportIssueUrl) {
26
+ const uri = this.getIssueUriFromStaticContent(this.productService.reportIssueUrl);
27
+ windowOpenNoOpener(uri);
28
+ return;
29
+ }
30
+ throw new Error(`No issue reporting URL configured for ${this.productService.nameLong}.`);
31
+ }
32
+ if (( this._handlers.has(extensionId))) {
33
+ try {
34
+ const uri = await this.getIssueUriFromHandler(extensionId, CancellationToken.None);
35
+ windowOpenNoOpener(uri);
36
+ return;
37
+ }
38
+ catch (e) {
39
+ this.logService.error(e);
40
+ }
41
+ }
42
+ const selectedExtension = this.extensionService.extensions.filter(ext => ext.identifier.value === options.extensionId)[0];
43
+ const extensionGitHubUrl = this.getExtensionGitHubUrl(selectedExtension);
44
+ if (!extensionGitHubUrl) {
45
+ throw new Error(`Unable to find issue reporting url for ${extensionId}`);
46
+ }
47
+ const uri = this.getIssueUriFromStaticContent(`${extensionGitHubUrl}/issues/new`, selectedExtension);
48
+ windowOpenNoOpener(uri);
49
+ }
50
+ registerIssueUriRequestHandler(extensionId, handler) {
51
+ this._handlers.set(extensionId, handler);
52
+ return toDisposable(() => this._handlers.delete(extensionId));
53
+ }
54
+ registerIssueDataProvider(extensionId, handler) {
55
+ this._providers.set(extensionId, handler);
56
+ return toDisposable(() => this._providers.delete(extensionId));
57
+ }
58
+ async getIssueUriFromHandler(extensionId, token) {
59
+ const handler = this._handlers.get(extensionId);
60
+ if (!handler) {
61
+ throw new Error(`No handler registered for extension ${extensionId}`);
62
+ }
63
+ const result = await handler.provideIssueUrl(token);
64
+ return ( result.toString(true));
65
+ }
66
+ getExtensionGitHubUrl(extension) {
67
+ if (extension.isBuiltin && this.productService.reportIssueUrl) {
68
+ return normalizeGitHubUrl(this.productService.reportIssueUrl);
69
+ }
70
+ let repositoryUrl = '';
71
+ const bugsUrl = extension?.bugs?.url;
72
+ const extensionUrl = extension?.repository?.url;
73
+ if (bugsUrl && bugsUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
74
+ repositoryUrl = normalizeGitHubUrl(bugsUrl);
75
+ }
76
+ else if (extensionUrl && extensionUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
77
+ repositoryUrl = normalizeGitHubUrl(extensionUrl);
78
+ }
79
+ return repositoryUrl;
80
+ }
81
+ getIssueUriFromStaticContent(baseUri, extension) {
82
+ const issueDescription = `ADD ISSUE DESCRIPTION HERE
83
+
84
+ Version: ${this.productService.version}
85
+ Commit: ${this.productService.commit ?? 'unknown'}
86
+ User Agent: ${userAgent ?? 'unknown'}
87
+ Embedder: ${this.productService.embedderIdentifier ?? 'unknown'}
88
+ ${extension?.version ? `\nExtension version: ${extension.version}` : ''}
89
+ <!-- generated by web issue reporter -->`;
90
+ return `${baseUri}?body=${encodeURIComponent(issueDescription)}&labels=web`;
91
+ }
92
+ };
93
+ WebIssueService = ( __decorate([
94
+ ( __param(0, IExtensionService)),
95
+ ( __param(1, IProductService)),
96
+ ( __param(2, ILogService))
97
+ ], WebIssueService));
98
+
99
+ export { WebIssueService };