UNPKG

@visactor/vrender-core

Version:

```typescript import { xxx } from '@visactor/vrender-core'; ```

46 lines (39 loc) 1.99 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: !0 }), exports.ContributionStore = exports.bindContributionProviderNoSingletonScope = exports.bindContributionProvider = exports.ContributionProvider = void 0, exports.ContributionProvider = Symbol("ContributionProvider"); class ContributionProviderCache { constructor(serviceIdentifier, container) { this.serviceIdentifier = serviceIdentifier, this.container = container, ContributionStore.setStore(this.serviceIdentifier, this); } getContributions() { return this.caches || (this.caches = [], this.container && this.container.isBound(this.serviceIdentifier) && this.caches.push(...this.container.getAll(this.serviceIdentifier))), this.caches; } refresh() { this.caches && (this.caches.length = 0, this.container && this.container.isBound(this.serviceIdentifier) && this.caches.push(...this.container.getAll(this.serviceIdentifier))); } } function bindContributionProvider(bind, id) { bind(exports.ContributionProvider).toDynamicValue((({container: container}) => new ContributionProviderCache(id, container))).inSingletonScope().whenTargetNamed(id); } function bindContributionProviderNoSingletonScope(bind, id) { bind(exports.ContributionProvider).toDynamicValue((({container: container}) => new ContributionProviderCache(id, container))).whenTargetNamed(id); } exports.bindContributionProvider = bindContributionProvider, exports.bindContributionProviderNoSingletonScope = bindContributionProviderNoSingletonScope; class ContributionStore { static getStore(id) { return this.store.get(id); } static setStore(id, cache) { this.store.set(id, cache); } static refreshAllContributions() { this.store.forEach((cache => { cache.refresh(); })); } } exports.ContributionStore = ContributionStore, ContributionStore.store = new Map; //# sourceMappingURL=contribution-provider.js.map