@codingame/monaco-vscode-share-service-override 3.2.3 → 4.1.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-share-service-override",
3
- "version": "3.2.3",
3
+ "version": "4.1.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,6 +18,6 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@3.2.3"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.1.0"
22
22
  }
23
23
  }
package/share.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
- import { ShareService } from './vscode/src/vs/workbench/contrib/share/browser/shareService.js';
2
+ import { ShareService } from 'vscode/vscode/vs/workbench/contrib/share/browser/shareService';
3
3
  import { IShareService } from 'vscode/vscode/vs/workbench/contrib/share/common/share';
4
- import './vscode/src/vs/workbench/contrib/share/browser/share.contribution.js';
4
+ import 'vscode/vscode/vs/workbench/contrib/share/browser/share.contribution';
5
5
 
6
6
  function getServiceOverride() {
7
7
  return {
@@ -1,3 +0,0 @@
1
- var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=( Object.keys(r.attributes)),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
2
-
3
- export { n as default };
@@ -1,11 +0,0 @@
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 };
@@ -1,8 +0,0 @@
1
- var ConfirmResult;
2
- ( (function(ConfirmResult) {
3
- ConfirmResult[ConfirmResult["SAVE"] = 0] = "SAVE";
4
- ConfirmResult[ConfirmResult["DONT_SAVE"] = 1] = "DONT_SAVE";
5
- ConfirmResult[ConfirmResult["CANCEL"] = 2] = "CANCEL";
6
- })(ConfirmResult || (ConfirmResult = {})));
7
-
8
- export { ConfirmResult };
@@ -1,168 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import './share.css.js';
3
- import { CancellationTokenSource } from 'vscode/vscode/vs/base/common/cancellation';
4
- import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
5
- import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
6
- import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
7
- import { MenuId, registerAction2, Action2, MenuRegistry } from 'vscode/vscode/vs/platform/actions/common/actions';
8
- import { IClipboardService } from 'vscode/vscode/vs/platform/clipboard/common/clipboardService';
9
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
10
- import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
11
- import { EditorResourceAccessor, SideBySideEditor } from 'vscode/vscode/vs/workbench/common/editor';
12
- import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
13
- import { Severity } from 'vscode/vscode/vs/platform/notification/common/notification';
14
- import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
15
- import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
16
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
17
- import { WorkspaceFolderCountContext } from 'vscode/vscode/vs/workbench/common/contextkeys';
18
- import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
19
- import { ShareProviderCountContext } from './shareService.js';
20
- import { IShareService } from 'vscode/vscode/vs/workbench/contrib/share/common/share';
21
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
22
- import { IProgressService } from 'vscode/vscode/vs/platform/progress/common/progress';
23
- import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
24
- import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
25
- import { workbenchConfigurationNodeBase } from 'vscode/vscode/vs/workbench/common/configuration';
26
- import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
27
- import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
28
-
29
- var ShareWorkbenchContribution_1;
30
- const targetMenus = [
31
- MenuId.EditorContextShare,
32
- MenuId.SCMResourceContextShare,
33
- MenuId.OpenEditorsContextShare,
34
- MenuId.EditorTitleContextShare,
35
- MenuId.MenubarShare,
36
- MenuId.ExplorerContextShare
37
- ];
38
- let ShareWorkbenchContribution = class ShareWorkbenchContribution {
39
- static { ShareWorkbenchContribution_1 = this; }
40
- static { this.SHARE_ENABLED_SETTING = 'workbench.experimental.share.enabled'; }
41
- constructor(shareService, configurationService) {
42
- this.shareService = shareService;
43
- this.configurationService = configurationService;
44
- if (this.configurationService.getValue(ShareWorkbenchContribution_1.SHARE_ENABLED_SETTING)) {
45
- this.registerActions();
46
- }
47
- this.configurationService.onDidChangeConfiguration(e => {
48
- if (e.affectsConfiguration(ShareWorkbenchContribution_1.SHARE_ENABLED_SETTING)) {
49
- const settingValue = this.configurationService.getValue(ShareWorkbenchContribution_1.SHARE_ENABLED_SETTING);
50
- if (settingValue === true && this._disposables === undefined) {
51
- this.registerActions();
52
- }
53
- else if (settingValue === false && this._disposables !== undefined) {
54
- this._disposables?.clear();
55
- this._disposables = undefined;
56
- }
57
- }
58
- });
59
- }
60
- registerActions() {
61
- if (!this._disposables) {
62
- this._disposables = ( new DisposableStore());
63
- }
64
- this._disposables.add(registerAction2(class ShareAction extends Action2 {
65
- static { this.ID = 'workbench.action.share'; }
66
- static { this.LABEL = ( localize2WithPath(
67
- 'vs/workbench/contrib/share/browser/share.contribution',
68
- 'share',
69
- 'Share...'
70
- )); }
71
- constructor() {
72
- super({
73
- id: ShareAction.ID,
74
- title: ShareAction.LABEL,
75
- f1: true,
76
- icon: Codicon.linkExternal,
77
- precondition: ( ContextKeyExpr.and(( ShareProviderCountContext.notEqualsTo(0)), ( WorkspaceFolderCountContext.notEqualsTo(0)))),
78
- keybinding: {
79
- weight: 200 ,
80
- primary: 512 | 2048 | 49 ,
81
- },
82
- menu: [
83
- { id: MenuId.CommandCenter, order: 1000 }
84
- ]
85
- });
86
- }
87
- async run(accessor, ...args) {
88
- const shareService = accessor.get(IShareService);
89
- const activeEditor = accessor.get(IEditorService)?.activeEditor;
90
- const resourceUri = (activeEditor && EditorResourceAccessor.getOriginalUri(activeEditor, { supportSideBySide: SideBySideEditor.PRIMARY }))
91
- ?? accessor.get(IWorkspaceContextService).getWorkspace().folders[0].uri;
92
- const clipboardService = accessor.get(IClipboardService);
93
- const dialogService = accessor.get(IDialogService);
94
- const urlService = accessor.get(IOpenerService);
95
- const progressService = accessor.get(IProgressService);
96
- const selection = accessor.get(ICodeEditorService).getActiveCodeEditor()?.getSelection() ?? undefined;
97
- const result = await progressService.withProgress({
98
- location: 10 ,
99
- detail: ( localizeWithPath(
100
- 'vs/workbench/contrib/share/browser/share.contribution',
101
- 'generating link',
102
- 'Generating link...'
103
- ))
104
- }, async () => shareService.provideShare({ resourceUri, selection }, ( new CancellationTokenSource()).token));
105
- if (result) {
106
- const uriText = ( result.toString());
107
- const isResultText = typeof result === 'string';
108
- await clipboardService.writeText(uriText);
109
- dialogService.prompt({
110
- type: Severity.Info,
111
- message: isResultText ? ( localizeWithPath(
112
- 'vs/workbench/contrib/share/browser/share.contribution',
113
- 'shareTextSuccess',
114
- 'Copied text to clipboard!'
115
- )) : ( localizeWithPath(
116
- 'vs/workbench/contrib/share/browser/share.contribution',
117
- 'shareSuccess',
118
- 'Copied link to clipboard!'
119
- )),
120
- custom: {
121
- icon: Codicon.check,
122
- markdownDetails: [{
123
- markdown: ( new MarkdownString(`<div aria-label='${uriText}'>${uriText}</div>`, { supportHtml: true })),
124
- classes: [isResultText ? 'share-dialog-input-text' : 'share-dialog-input-link']
125
- }]
126
- },
127
- cancelButton: ( localizeWithPath('vs/workbench/contrib/share/browser/share.contribution', 'close', 'Close')),
128
- buttons: isResultText ? [] : [{ label: ( localizeWithPath(
129
- 'vs/workbench/contrib/share/browser/share.contribution',
130
- 'open link',
131
- 'Open Link'
132
- )), run: () => { urlService.open(result, { openExternal: true }); } }]
133
- });
134
- }
135
- }
136
- }));
137
- const actions = this.shareService.getShareActions();
138
- for (const menuId of targetMenus) {
139
- for (const action of actions) {
140
- this._disposables.add(MenuRegistry.appendMenuItem(menuId, action));
141
- }
142
- }
143
- }
144
- };
145
- ShareWorkbenchContribution = ShareWorkbenchContribution_1 = ( __decorate([
146
- ( __param(0, IShareService)),
147
- ( __param(1, IConfigurationService))
148
- ], ShareWorkbenchContribution));
149
- const workbenchContributionsRegistry = ( Registry.as(Extensions.Workbench));
150
- workbenchContributionsRegistry.registerWorkbenchContribution(ShareWorkbenchContribution, 4 );
151
- ( Registry.as(Extensions$1.Configuration)).registerConfiguration({
152
- ...workbenchConfigurationNodeBase,
153
- properties: {
154
- 'workbench.experimental.share.enabled': {
155
- type: 'boolean',
156
- default: false,
157
- tags: ['experimental'],
158
- markdownDescription: ( localizeWithPath(
159
- 'vs/workbench/contrib/share/browser/share.contribution',
160
- 'experimental.share.enabled',
161
- "Controls whether to render the Share action next to the command center when {0} is {1}.",
162
- '`#window.commandCenter#`',
163
- '`true`'
164
- )),
165
- restricted: false,
166
- }
167
- }
168
- });
@@ -1,6 +0,0 @@
1
- import n from '../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
2
-
3
- var css = "div.share-dialog-input-link,div.share-dialog-input-text{background-color:var(--vscode-input-background);border:1px solid var(--vscode-input-border,transparent);border-radius:2px;color:var(--vscode-input-foreground);line-height:24px;padding:2px;user-select:all}div.share-dialog-input-link{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}";
4
- n(css,{});
5
-
6
- export { css, css as default };
@@ -1,72 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
3
- import { score } from 'vscode/vscode/vs/editor/common/languageSelector';
4
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
5
- import { RawContextKey, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
6
- import { ILabelService } from 'vscode/vscode/vs/platform/label/common/label';
7
- import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
8
- import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
9
-
10
- const ShareProviderCountContext = ( new RawContextKey('shareProviderCount', 0, ( localizeWithPath(
11
- 'vs/workbench/contrib/share/browser/shareService',
12
- 'shareProviderCount',
13
- "The number of available share providers"
14
- ))));
15
- let ShareService = class ShareService {
16
- constructor(contextKeyService, labelService, quickInputService, codeEditorService, telemetryService) {
17
- this.contextKeyService = contextKeyService;
18
- this.labelService = labelService;
19
- this.quickInputService = quickInputService;
20
- this.codeEditorService = codeEditorService;
21
- this.telemetryService = telemetryService;
22
- this._providers = ( new Set());
23
- this.providerCount = ShareProviderCountContext.bindTo(this.contextKeyService);
24
- }
25
- registerShareProvider(provider) {
26
- this._providers.add(provider);
27
- this.providerCount.set(this._providers.size);
28
- return {
29
- dispose: () => {
30
- this._providers.delete(provider);
31
- this.providerCount.set(this._providers.size);
32
- }
33
- };
34
- }
35
- getShareActions() {
36
- return [];
37
- }
38
- async provideShare(item, token) {
39
- const language = this.codeEditorService.getActiveCodeEditor()?.getModel()?.getLanguageId() ?? '';
40
- const providers = [...( this._providers.values())]
41
- .filter((p) => score(p.selector, item.resourceUri, language, true, undefined, undefined) > 0)
42
- .sort((a, b) => a.priority - b.priority);
43
- if (providers.length === 0) {
44
- return undefined;
45
- }
46
- if (providers.length === 1) {
47
- this.telemetryService.publicLog2('shareService.share', { providerId: providers[0].id });
48
- return providers[0].provideShare(item, token);
49
- }
50
- const items = ( providers.map((p) => ({ label: p.label, provider: p })));
51
- const selected = await this.quickInputService.pick(items, { canPickMany: false, placeHolder: ( localizeWithPath(
52
- 'vs/workbench/contrib/share/browser/shareService',
53
- 'type to filter',
54
- 'Choose how to share {0}',
55
- this.labelService.getUriLabel(item.resourceUri)
56
- )) }, token);
57
- if (selected !== undefined) {
58
- this.telemetryService.publicLog2('shareService.share', { providerId: selected.provider.id });
59
- return selected.provider.provideShare(item, token);
60
- }
61
- return;
62
- }
63
- };
64
- ShareService = ( __decorate([
65
- ( __param(0, IContextKeyService)),
66
- ( __param(1, ILabelService)),
67
- ( __param(2, IQuickInputService)),
68
- ( __param(3, ICodeEditorService)),
69
- ( __param(4, ITelemetryService))
70
- ], ShareService));
71
-
72
- export { ShareProviderCountContext, ShareService };