UNPKG

@macrof/shared

Version:

React MicroFrontend Shared, Typescript, Webpack 5, ModuleFederation

44 lines (43 loc) 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FactoryStore = void 0; const inversify_1 = require("inversify"); const __1 = require("../../.."); const AFactoryStore_1 = require("./AFactoryStore"); class FactoryStore extends AFactoryStore_1.AFactoryStore { constructor() { super(...arguments); this.rootContainerFactory = () => { const container = this.createParentDev(); container.parent = new inversify_1.Container(); return container; }; } createParentDev() { const container = new inversify_1.Container(); if (__1.IS_DEV) { container.bind(__1.MF_TYPES.ILogger).to(__1.Common); } else { const { location } = window; const isDebugMode = Boolean(new URLSearchParams(location.search).get('DEBUG')); container .bind(__1.MF_TYPES.ILogger) .to(__1.Production) .when(() => !isDebugMode); container .bind(__1.MF_TYPES.ILogger) .to(__1.ProductionDebug) .when(() => isDebugMode); } container.bind(__1.MF_TYPES.IResponseService).to(__1.Response); container.bind(__1.MF_TYPES.Token).toConstantValue(new __1.Token()); container.bind(__1.MF_TYPES.ILoader).to(__1.LoaderService).inSingletonScope(); container .bind(__1.MF_TYPES.IHttpService) .toDynamicValue((context) => new __1.Service(context.container.get(__1.MF_TYPES.ILogger), context.container.get(__1.MF_TYPES.Token))) .inSingletonScope(); return container; } } exports.FactoryStore = FactoryStore;