UNPKG

everything-dev

Version:

A consolidated product package for building Module Federation apps with oRPC APIs.

68 lines (66 loc) • 1.72 kB
import { isPlainObject } from "./resolution/merge.mjs"; //#region src/services/config-slots.ts function walkConfigSlots(config, visit) { const app = config.app; if (isPlainObject(app)) for (const [key, entry] of Object.entries(app)) { if (!isPlainObject(entry)) continue; visit({ slot: `app.${key}`, entry, isPluginRef: false }); if ("ui" in entry) { const ui = entry.ui; if (isPlainObject(ui) || ui === false) visit({ slot: `app.${key}.ui`, entry: ui, isPluginRef: false }); } } const plugins = config.plugins; if (isPlainObject(plugins)) for (const [id, entry] of Object.entries(plugins)) { if (typeof entry === "string") { if (entry.length > 0) visit({ slot: `plugins.${id}`, entry, isPluginRef: true }); continue; } if (!isPlainObject(entry)) continue; visit({ slot: `plugins.${id}`, entry, isPluginRef: false }); if ("ui" in entry) { const ui = entry.ui; if (isPlainObject(ui) || ui === false) visit({ slot: `plugins.${id}.ui`, entry: ui, isPluginRef: false }); } } } /** * Ensure every container of a dotted path exists (creating plain objects along * the way) and return the container that holds the final segment. Consumers * keep the final-set semantics (replace vs merge-into) local. */ function ensureObjectContainers(target, segments) { let container = target; for (const segment of segments) { const next = container[segment]; if (!isPlainObject(next)) { const created = {}; container[segment] = created; container = created; } else container = next; } return container; } //#endregion export { ensureObjectContainers, walkConfigSlots }; //# sourceMappingURL=config-slots.mjs.map