1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/core/src/renderer/bootstrap/root-component.injectable.ts
Sebastian Malton ed36b46e01 Try to fix problems with seperate chunks
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2023-02-02 14:28:40 -05:00

33 lines
955 B
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { getInjectable } from "@ogre-tools/injectable";
import { rootComponentInjectionToken } from "./tokens";
const rootComponentInjectable = getInjectable({
id: "root-component",
instantiate: (di) => {
const options = di.injectMany(rootComponentInjectionToken);
if (options.length === 0) {
throw new Error("No intializeApp registered");
}
const intializeApp = options.find(opt => opt.isActive);
const howManyActive = options.reduce((count, cur) => count + +cur.isActive, 0);
if (!intializeApp) {
throw new Error("No initializeApp registrations are active");
}
if (howManyActive > 1) {
throw new Error("Too many initiazlizeApp registrations are active");
}
return intializeApp.Component;
},
});
export default rootComponentInjectable;