UNPKG

infrastructure-components

Version:

Infrastructure-Components configure the infrastructure of your React-App as part of your React-Components.

45 lines 1.75 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const types_1 = __importDefault(require("../types")); const middleware_component_1 = require("../middleware/middleware-component"); const libs_1 = require("../libs"); exports.SERVICE_INSTANCE_TYPE = "ServiceComponent"; /** * identifies a component as a WebApp: it implements all the required fields * * @param component to be tested */ function isService(component) { return component !== undefined && component.instanceType === exports.SERVICE_INSTANCE_TYPE; } exports.isService = isService; /** * The WebApp is a client that runs in the browser, SPA or SSR * * @param props */ exports.default = (props) => { //console.log ("webapp: ", props); // the ServiceComponent must have all the properties of IClient const componentProps = { infrastructureType: types_1.default.INFRASTRUCTURE_TYPE_COMPONENT, instanceType: exports.SERVICE_INSTANCE_TYPE, instanceId: props.id, insulatesChildComponent: (child) => { // a webapp insulates (handles itself) middlewares and routes and does not privide to higher levels return middleware_component_1.isMiddleware(child); } }; const serviceProps = { middlewares: libs_1.getChildrenArray(props.children) .filter(child => middleware_component_1.isMiddleware(child)), setDataLayerId: (dataLayerId) => { props.dataLayerId = dataLayerId; } }; return Object.assign(props, componentProps, serviceProps); }; //# sourceMappingURL=service-component.js.map