@codingame/monaco-vscode-view-banner-service-override 4.1.0 → 4.1.2

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,3 @@
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 };
@@ -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.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { default } from './viewBanner.js';
2
- export { BannerPart } from 'vscode/vscode/vs/workbench/browser/parts/banner/bannerPart';
2
+ export { BannerPart } from './vscode/src/vs/workbench/browser/parts/banner/bannerPart.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-view-banner-service-override",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
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@4.1.0"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.1.2"
22
22
  }
23
23
  }
package/viewBanner.js CHANGED
@@ -1,9 +1,8 @@
1
1
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
2
- import { BannerPart } from 'vscode/vscode/vs/workbench/browser/parts/banner/bannerPart';
3
- export { BannerPart } from 'vscode/vscode/vs/workbench/browser/parts/banner/bannerPart';
2
+ import { BannerPart } from './vscode/src/vs/workbench/browser/parts/banner/bannerPart.js';
4
3
  import { IBannerService } from 'vscode/vscode/vs/workbench/services/banner/browser/bannerService';
5
4
  import { registerServiceInitializePostParticipant } from 'vscode/lifecycle';
6
- import 'vscode/vscode/vs/workbench/contrib/welcomeBanner/browser/welcomeBanner.contribution';
5
+ import './vscode/src/vs/workbench/contrib/welcomeBanner/browser/welcomeBanner.contribution.js';
7
6
 
8
7
  function getServiceOverride() {
9
8
  return {
@@ -14,4 +13,4 @@ registerServiceInitializePostParticipant(async (accessor) => {
14
13
  accessor.get(IBannerService);
15
14
  });
16
15
 
17
- export { getServiceOverride as default };
16
+ export { BannerPart, getServiceOverride as default };
@@ -0,0 +1,235 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import './media/bannerpart.css.js';
3
+ import { localize2WithPath } from 'vscode/vscode/vs/nls';
4
+ import { addDisposableListener, EventType, clearNode, $, append, asCSSUrl } from 'vscode/vscode/vs/base/browser/dom';
5
+ import { ActionBar } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionbar';
6
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
7
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
8
+ import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService';
9
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
10
+ import { Part } from 'vscode/vscode/vs/workbench/browser/part';
11
+ import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
12
+ import { Action } from 'vscode/vscode/vs/base/common/actions';
13
+ import { Link } from 'vscode/vscode/vs/platform/opener/browser/link';
14
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
15
+ import { IBannerService } from 'vscode/vscode/vs/workbench/services/banner/browser/bannerService';
16
+ import { MarkdownRenderer } from 'vscode/vscode/vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
17
+ import { Action2, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
18
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
19
+ import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
20
+ import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
21
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
22
+ import { widgetClose } from 'vscode/vscode/vs/platform/theme/common/iconRegistry';
23
+ import { BannerFocused } from 'vscode/vscode/vs/workbench/common/contextkeys';
24
+
25
+ let BannerPart = class BannerPart extends Part {
26
+ get minimumHeight() {
27
+ return this.visible ? this.height : 0;
28
+ }
29
+ get maximumHeight() {
30
+ return this.visible ? this.height : 0;
31
+ }
32
+ get onDidChange() { return this._onDidChangeSize.event; }
33
+ constructor(themeService, layoutService, storageService, contextKeyService, instantiationService) {
34
+ super("workbench.parts.banner" , { hasTitle: false }, themeService, storageService, layoutService);
35
+ this.contextKeyService = contextKeyService;
36
+ this.instantiationService = instantiationService;
37
+ this.height = 26;
38
+ this.minimumWidth = 0;
39
+ this.maximumWidth = Number.POSITIVE_INFINITY;
40
+ this._onDidChangeSize = this._register(( new Emitter()));
41
+ this.visible = false;
42
+ this.focusedActionIndex = -1;
43
+ this.markdownRenderer = this.instantiationService.createInstance(MarkdownRenderer, {});
44
+ }
45
+ createContentArea(parent) {
46
+ this.element = parent;
47
+ this.element.tabIndex = 0;
48
+ this._register(addDisposableListener(this.element, EventType.FOCUS, () => {
49
+ if (this.focusedActionIndex !== -1) {
50
+ this.focusActionLink();
51
+ }
52
+ }));
53
+ const scopedContextKeyService = this._register(this.contextKeyService.createScoped(this.element));
54
+ BannerFocused.bindTo(scopedContextKeyService).set(true);
55
+ return this.element;
56
+ }
57
+ close(item) {
58
+ this.setVisibility(false);
59
+ clearNode(this.element);
60
+ if (typeof item.onClose === 'function') {
61
+ item.onClose();
62
+ }
63
+ this.item = undefined;
64
+ }
65
+ focusActionLink() {
66
+ const length = this.item?.actions?.length ?? 0;
67
+ if (this.focusedActionIndex < length) {
68
+ const actionLink = this.messageActionsContainer?.children[this.focusedActionIndex];
69
+ if (actionLink instanceof HTMLElement) {
70
+ this.actionBar?.setFocusable(false);
71
+ actionLink.focus();
72
+ }
73
+ }
74
+ else {
75
+ this.actionBar?.focus(0);
76
+ }
77
+ }
78
+ getAriaLabel(item) {
79
+ if (item.ariaLabel) {
80
+ return item.ariaLabel;
81
+ }
82
+ if (typeof item.message === 'string') {
83
+ return item.message;
84
+ }
85
+ return undefined;
86
+ }
87
+ getBannerMessage(message) {
88
+ if (typeof message === 'string') {
89
+ const element = $('span');
90
+ element.innerText = message;
91
+ return element;
92
+ }
93
+ return this.markdownRenderer.render(message).element;
94
+ }
95
+ setVisibility(visible) {
96
+ if (visible !== this.visible) {
97
+ this.visible = visible;
98
+ this.focusedActionIndex = -1;
99
+ this.layoutService.setPartHidden(!visible, "workbench.parts.banner" );
100
+ this._onDidChangeSize.fire(undefined);
101
+ }
102
+ }
103
+ focus() {
104
+ this.focusedActionIndex = -1;
105
+ this.element.focus();
106
+ }
107
+ focusNextAction() {
108
+ const length = this.item?.actions?.length ?? 0;
109
+ this.focusedActionIndex = this.focusedActionIndex < length ? this.focusedActionIndex + 1 : 0;
110
+ this.focusActionLink();
111
+ }
112
+ focusPreviousAction() {
113
+ const length = this.item?.actions?.length ?? 0;
114
+ this.focusedActionIndex = this.focusedActionIndex > 0 ? this.focusedActionIndex - 1 : length;
115
+ this.focusActionLink();
116
+ }
117
+ hide(id) {
118
+ if (this.item?.id !== id) {
119
+ return;
120
+ }
121
+ this.setVisibility(false);
122
+ }
123
+ show(item) {
124
+ if (item.id === this.item?.id) {
125
+ this.setVisibility(true);
126
+ return;
127
+ }
128
+ clearNode(this.element);
129
+ const ariaLabel = this.getAriaLabel(item);
130
+ if (ariaLabel) {
131
+ this.element.setAttribute('aria-label', ariaLabel);
132
+ }
133
+ const iconContainer = append(this.element, $('div.icon-container'));
134
+ iconContainer.setAttribute('aria-hidden', 'true');
135
+ if (ThemeIcon.isThemeIcon(item.icon)) {
136
+ iconContainer.appendChild($(`div${ThemeIcon.asCSSSelector(item.icon)}`));
137
+ }
138
+ else {
139
+ iconContainer.classList.add('custom-icon');
140
+ if (URI.isUri(item.icon)) {
141
+ iconContainer.style.backgroundImage = asCSSUrl(item.icon);
142
+ }
143
+ }
144
+ const messageContainer = append(this.element, $('div.message-container'));
145
+ messageContainer.setAttribute('aria-hidden', 'true');
146
+ messageContainer.appendChild(this.getBannerMessage(item.message));
147
+ this.messageActionsContainer = append(this.element, $('div.message-actions-container'));
148
+ if (item.actions) {
149
+ for (const action of item.actions) {
150
+ this._register(this.instantiationService.createInstance(Link, this.messageActionsContainer, { ...action, tabIndex: -1 }, {}));
151
+ }
152
+ }
153
+ const actionBarContainer = append(this.element, $('div.action-container'));
154
+ this.actionBar = this._register(( new ActionBar(actionBarContainer)));
155
+ const label = item.closeLabel ?? 'Close Banner';
156
+ const closeAction = this._register(( new Action(
157
+ 'banner.close',
158
+ label,
159
+ ThemeIcon.asClassName(widgetClose),
160
+ true,
161
+ () => this.close(item)
162
+ )));
163
+ this.actionBar.push(closeAction, { icon: true, label: false });
164
+ this.actionBar.setFocusable(false);
165
+ this.setVisibility(true);
166
+ this.item = item;
167
+ }
168
+ toJSON() {
169
+ return {
170
+ type: "workbench.parts.banner"
171
+ };
172
+ }
173
+ };
174
+ BannerPart = ( __decorate([
175
+ ( __param(0, IThemeService)),
176
+ ( __param(1, IWorkbenchLayoutService)),
177
+ ( __param(2, IStorageService)),
178
+ ( __param(3, IContextKeyService)),
179
+ ( __param(4, IInstantiationService))
180
+ ], BannerPart));
181
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
182
+ id: 'workbench.banner.focusBanner',
183
+ weight: 200 ,
184
+ primary: 9 ,
185
+ when: BannerFocused,
186
+ handler: (accessor) => {
187
+ const bannerService = accessor.get(IBannerService);
188
+ bannerService.focus();
189
+ }
190
+ });
191
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
192
+ id: 'workbench.banner.focusNextAction',
193
+ weight: 200 ,
194
+ primary: 17 ,
195
+ secondary: [18 ],
196
+ when: BannerFocused,
197
+ handler: (accessor) => {
198
+ const bannerService = accessor.get(IBannerService);
199
+ bannerService.focusNextAction();
200
+ }
201
+ });
202
+ KeybindingsRegistry.registerCommandAndKeybindingRule({
203
+ id: 'workbench.banner.focusPreviousAction',
204
+ weight: 200 ,
205
+ primary: 15 ,
206
+ secondary: [16 ],
207
+ when: BannerFocused,
208
+ handler: (accessor) => {
209
+ const bannerService = accessor.get(IBannerService);
210
+ bannerService.focusPreviousAction();
211
+ }
212
+ });
213
+ class FocusBannerAction extends Action2 {
214
+ static { this.ID = 'workbench.action.focusBanner'; }
215
+ static { this.LABEL = ( localize2WithPath(
216
+ 'vs/workbench/browser/parts/banner/bannerPart',
217
+ 'focusBanner',
218
+ "Focus Banner"
219
+ )); }
220
+ constructor() {
221
+ super({
222
+ id: FocusBannerAction.ID,
223
+ title: FocusBannerAction.LABEL,
224
+ category: Categories.View,
225
+ f1: true
226
+ });
227
+ }
228
+ async run(accessor) {
229
+ const layoutService = accessor.get(IWorkbenchLayoutService);
230
+ layoutService.focusPart("workbench.parts.banner" );
231
+ }
232
+ }
233
+ registerAction2(FocusBannerAction);
234
+
235
+ export { BannerPart };
@@ -0,0 +1,6 @@
1
+ import n from '../../../../../../../../external/rollup-plugin-styles/dist/runtime/inject-css.js';
2
+
3
+ var css = ".monaco-workbench .part.banner{background-color:var(--vscode-banner-background);box-sizing:border-box;color:var(--vscode-banner-foreground);cursor:default;display:flex;font-size:12px;height:100%;overflow:visible;width:100%}.monaco-workbench .part.banner .icon-container{align-items:center;display:flex;flex-shrink:0;padding:0 6px 0 10px}.monaco-workbench .part.banner .icon-container .codicon{color:var(--vscode-banner-iconForeground)}.monaco-workbench .part.banner .icon-container.custom-icon{background-image:url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGQ9Ik0xMDI0IDEwMjRIMFYwaDEwMjR2MTAyNHoiIHN0eWxlPSJmaWxsOiNmNmY2ZjY7ZmlsbC1vcGFjaXR5OjAiIGZpbGw9Im5vbmUiLz48cGF0aCBkPSJNMTAyNCA4NS4zMzN2ODUzLjMzM0gwVjg1LjMzM2gxMDI0eiIgc3R5bGU9ImZpbGw6I2ZmZiIvPjxwYXRoIGQ9Ik0wIDg1LjMzM2gyOTguNjY3djg1My4zMzNIMFY4NS4zMzN6bTEwMjQgMHY4NTMuMzMzSDM4NFY4NS4zMzNoNjQwem0tNTU0LjY2NyAxNjBoMzQxLjMzM3YtNjRINDY5LjMzM3Y2NHptMzQxLjMzNCA1MzMuMzM0SDQ2OS4zMzN2NjRoMzQxLjMzM2wuMDAxLTY0em0xMjgtMTQ5LjMzNEg1OTcuMzMzdjY0aDM0MS4zMzNsLjAwMS02NHptMC0xNDkuMzMzSDU5Ny4zMzN2NjRoMzQxLjMzM2wuMDAxLTY0em0wLTE0OS4zMzNINTk3LjMzM3Y2NGgzNDEuMzMzbC4wMDEtNjR6IiBzdHlsZT0iZmlsbDojMTY3YWJmIi8+PC9zdmc+\");background-position:50%;background-repeat:no-repeat;background-size:16px;margin:0 6px 0 10px;padding:0;width:16px}.monaco-workbench .part.banner .message-container{line-height:26px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.monaco-workbench .part.banner .message-container a{color:var(--vscode-banner-foreground)}.monaco-workbench .part.banner .message-container p{margin-block-end:0;margin-block-start:0}.monaco-workbench .part.banner .message-actions-container{flex-grow:1;flex-shrink:0;line-height:26px}.monaco-workbench .part.banner .message-actions-container a{color:var(--vscode-banner-foreground);cursor:pointer;margin-left:12px;padding:3px;text-decoration:underline}.monaco-workbench .part.banner .message-container a{cursor:pointer;text-decoration:underline}.monaco-workbench .part.banner .action-container{padding:0 10px 0 6px}.monaco-workbench .part.banner .action-container .codicon{color:var(--vscode-banner-foreground)}";
4
+ n(css,{});
5
+
6
+ export { css, css as default };
@@ -0,0 +1,46 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
3
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
4
+ import { IBannerService } from 'vscode/vscode/vs/workbench/services/banner/browser/bannerService';
5
+ import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
6
+ import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
7
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
8
+ import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
9
+
10
+ var WelcomeBannerContribution_1;
11
+ let WelcomeBannerContribution = class WelcomeBannerContribution {
12
+ static { WelcomeBannerContribution_1 = this; }
13
+ static { this.WELCOME_BANNER_DISMISSED_KEY = 'workbench.banner.welcome.dismissed'; }
14
+ constructor(bannerService, storageService, environmentService) {
15
+ const welcomeBanner = environmentService.options?.welcomeBanner;
16
+ if (!welcomeBanner) {
17
+ return;
18
+ }
19
+ if (storageService.getBoolean(WelcomeBannerContribution_1.WELCOME_BANNER_DISMISSED_KEY, 0 , false)) {
20
+ return;
21
+ }
22
+ let icon = undefined;
23
+ if (typeof welcomeBanner.icon === 'string') {
24
+ icon = ThemeIcon.fromId(welcomeBanner.icon);
25
+ }
26
+ else if (welcomeBanner.icon) {
27
+ icon = URI.revive(welcomeBanner.icon);
28
+ }
29
+ bannerService.show({
30
+ id: 'welcome.banner',
31
+ message: welcomeBanner.message,
32
+ icon,
33
+ actions: welcomeBanner.actions,
34
+ onClose: () => {
35
+ storageService.store(WelcomeBannerContribution_1.WELCOME_BANNER_DISMISSED_KEY, true, 0 , 1 );
36
+ }
37
+ });
38
+ }
39
+ };
40
+ WelcomeBannerContribution = WelcomeBannerContribution_1 = ( __decorate([
41
+ ( __param(0, IBannerService)),
42
+ ( __param(1, IStorageService)),
43
+ ( __param(2, IBrowserWorkbenchEnvironmentService))
44
+ ], WelcomeBannerContribution));
45
+ ( Registry.as(Extensions.Workbench))
46
+ .registerWorkbenchContribution(WelcomeBannerContribution, 3 );