1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
18 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
19 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
20 | 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;
|
21 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
22 | };
|
23 | var __metadata = (this && this.__metadata) || function (k, v) {
|
24 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
25 | };
|
26 | Object.defineProperty(exports, "__esModule", { value: true });
|
27 | exports.BreadcrumbsService = void 0;
|
28 | const inversify_1 = require("inversify");
|
29 | const common_1 = require("../../common");
|
30 | const breadcrumb_popup_container_1 = require("./breadcrumb-popup-container");
|
31 | const breadcrumbs_constants_1 = require("./breadcrumbs-constants");
|
32 | let BreadcrumbsService = class BreadcrumbsService {
|
33 | constructor() {
|
34 | this.hasSubscribed = false;
|
35 | this.onDidChangeBreadcrumbsEmitter = new common_1.Emitter();
|
36 | }
|
37 | init() {
|
38 | this.createOverlayContainer();
|
39 | }
|
40 | createOverlayContainer() {
|
41 | this.popupsOverlayContainer = window.document.createElement('div');
|
42 | this.popupsOverlayContainer.id = breadcrumbs_constants_1.Styles.BREADCRUMB_POPUP_OVERLAY_CONTAINER;
|
43 | if (window.document.body) {
|
44 | window.document.body.appendChild(this.popupsOverlayContainer);
|
45 | }
|
46 | }
|
47 | |
48 |
|
49 |
|
50 |
|
51 | get onDidChangeBreadcrumbs() {
|
52 |
|
53 |
|
54 |
|
55 | if (!this.hasSubscribed) {
|
56 | this.subscribeToContributions();
|
57 | }
|
58 | return this.onDidChangeBreadcrumbsEmitter.event;
|
59 | }
|
60 | |
61 |
|
62 |
|
63 | subscribeToContributions() {
|
64 | this.hasSubscribed = true;
|
65 | for (const contribution of this.contributions.getContributions()) {
|
66 | contribution.onDidChangeBreadcrumbs(uri => this.onDidChangeBreadcrumbsEmitter.fire(uri));
|
67 | }
|
68 | }
|
69 | |
70 |
|
71 |
|
72 | async getBreadcrumbs(uri) {
|
73 | const result = [];
|
74 | for (const contribution of await this.prioritizedContributions()) {
|
75 | result.push(...await contribution.computeBreadcrumbs(uri));
|
76 | }
|
77 | return result;
|
78 | }
|
79 | async prioritizedContributions() {
|
80 | const prioritized = await common_1.Prioritizeable.prioritizeAll(this.contributions.getContributions(), contribution => contribution.priority);
|
81 | return prioritized.map(p => p.value).reverse();
|
82 | }
|
83 | |
84 |
|
85 |
|
86 | async openPopup(breadcrumb, position) {
|
87 | const contribution = this.contributions.getContributions().find(c => c.type === breadcrumb.type);
|
88 | if (contribution) {
|
89 | const popup = this.breadcrumbPopupContainerFactory(this.popupsOverlayContainer, breadcrumb.id, position);
|
90 | const popupContent = await contribution.attachPopupContent(breadcrumb, popup.container);
|
91 | if (popupContent && popup.isOpen) {
|
92 | popup.onDidDispose(() => popupContent.dispose());
|
93 | }
|
94 | else {
|
95 | popupContent === null || popupContent === void 0 ? void 0 : popupContent.dispose();
|
96 | }
|
97 | return popup;
|
98 | }
|
99 | }
|
100 | };
|
101 | __decorate([
|
102 | (0, inversify_1.inject)(common_1.ContributionProvider),
|
103 | (0, inversify_1.named)(breadcrumbs_constants_1.BreadcrumbsContribution),
|
104 | __metadata("design:type", Object)
|
105 | ], BreadcrumbsService.prototype, "contributions", void 0);
|
106 | __decorate([
|
107 | (0, inversify_1.inject)(breadcrumb_popup_container_1.BreadcrumbPopupContainerFactory),
|
108 | __metadata("design:type", Function)
|
109 | ], BreadcrumbsService.prototype, "breadcrumbPopupContainerFactory", void 0);
|
110 | __decorate([
|
111 | (0, inversify_1.postConstruct)(),
|
112 | __metadata("design:type", Function),
|
113 | __metadata("design:paramtypes", []),
|
114 | __metadata("design:returntype", void 0)
|
115 | ], BreadcrumbsService.prototype, "init", null);
|
116 | BreadcrumbsService = __decorate([
|
117 | (0, inversify_1.injectable)()
|
118 | ], BreadcrumbsService);
|
119 | exports.BreadcrumbsService = BreadcrumbsService;
|
120 |
|
\ | No newline at end of file |