@openmrs/esm-extensions 3.1.10-pre.563 → 3.1.10-pre.579

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"openmrs-esm-extensions.js","mappings":"obAAA,MAAMA,EAAmB,SAEzBC,EAAQ,EAAiB,SAAwBC,GAY7C,GAXGA,IACHA,EAAe,IAUV,IAAmBC,OAAS,IAAmBA,KAAKC,IAEvD,MADAC,QAAQC,MAAM,qBAAsB,KAC9BC,MACJ,uHAIJ,IAA0BP,EACxB,IAAmBG,KAAKC,IACxBF,K,cCuDND,EAAQ,EAlCR,SAA0BO,EAAWC,GAKnC,IAAIC,EAAIC,SAASC,cAAc,KAC/BF,EAAEG,KAAOL,EAKT,IAHA,IAAIM,EAA6B,MAAlBJ,EAAEI,SAAS,GAAaJ,EAAEI,SAAW,IAAMJ,EAAEI,SACxDC,EAAmB,EACrBC,EAAQF,EAASG,OACZF,IAAqBN,GAAsBO,GAAS,GAE5C,MADFF,IAAWE,IAEpBD,IAIJ,GAAIA,IAAqBN,EACvB,MAAMF,MACJ,iDACEE,EACA,gDACAM,EACA,qBACAP,GAIN,IAAIU,EAAYJ,EAASK,MAAM,EAAGH,EAAQ,GAE1C,OAAON,EAAEU,SAAW,KAAOV,EAAEW,KAAOH,GAOpCI,OAAOC,W,qBClFTC,EAAOvB,QAAUwB,G,qBCAjBD,EAAOvB,QAAUyB,G,qBCAjBF,EAAOvB,QAAU0B,ICCbC,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAa9B,QAGrB,IAAIuB,EAASI,EAAyBE,GAAY,CAGjD7B,QAAS,IAOV,OAHAgC,EAAoBH,GAAUN,EAAQA,EAAOvB,QAAS4B,GAG/CL,EAAOvB,QCrBf4B,EAAoBK,EAAIC,ECCxBN,EAAoBO,EAAI,CAACnC,EAASoC,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MK,GAASC,EAAAA,EAAAA,iBACbV,EAAeO,MAAAA,EAAAA,EAAUC,GACzB,IACKb,EAAeP,EAAQC,MACvBa,EACHS,MAAO7L,EACP8L,kBAAmB,CACjBtF,YAAAA,EACAK,kBAAAA,EACAoE,wBAAAA,EACA5E,oBAAqBC,GAEvB0E,WAAAA,IAGJM,EAASK,MAIb1G,GAAsBI,IACpB0G,EAAAA,EAAAA,QACE1G,EACA,CACE,aACA4B,EACA,YACAgE,EACApE,GAEF,CAAEmE,WAAAA,EAAYvE,GAAID,OAM1B,MAAO,KACL,GAAsB,kBAAX8E,EACTA,GAAS,MACJ,CACL,MAAMtH,EAAIsH,EAEY,YAAlBtH,EAAEgI,YACJhI,EAAEiI,aAAa9G,MAAK,IAAMnB,EAAEkI,YAE5BlI,EAAEkI,c","sources":["webpack://@openmrs/esm-extensions/../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js","webpack://@openmrs/esm-extensions/../../../node_modules/systemjs-webpack-interop/public-path.js","webpack://@openmrs/esm-extensions/external system \"@openmrs/esm-config\"","webpack://@openmrs/esm-extensions/external system \"@openmrs/esm-state\"","webpack://@openmrs/esm-extensions/external system \"single-spa\"","webpack://@openmrs/esm-extensions/webpack/bootstrap","webpack://@openmrs/esm-extensions/webpack/runtime/__system_context__","webpack://@openmrs/esm-extensions/webpack/runtime/define property getters","webpack://@openmrs/esm-extensions/webpack/runtime/global","webpack://@openmrs/esm-extensions/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-extensions/webpack/runtime/make namespace object","webpack://@openmrs/esm-extensions/webpack/runtime/publicPath","webpack://@openmrs/esm-extensions/../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js","webpack://@openmrs/esm-extensions/./src/contexts.ts","webpack://@openmrs/esm-extensions/./src/store.ts","webpack://@openmrs/esm-extensions/./src/extensions.ts","webpack://@openmrs/esm-extensions/./src/helpers.ts","webpack://@openmrs/esm-extensions/./src/render.ts"],"sourcesContent":["const resolveDirectory = require(\"../public-path\").resolveDirectory;\n\nexports.autoPublicPath = function autoPublicPath(rootDirLevel) {\n if (!rootDirLevel) {\n rootDirLevel = 1;\n }\n\n if (typeof __webpack_public_path__ !== \"undefined\") {\n if (typeof __system_context__ === \"undefined\") {\n throw Error(\n \"systemjs-webpack-interop requires webpack@>=5.0.0-beta.15 and output.libraryTarget set to 'system'\"\n );\n }\n\n if (!__system_context__.meta || !__system_context__.meta.url) {\n console.error(\"__system_context__\", __system_context__);\n throw Error(\n \"systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(\n __system_context__.meta.url,\n rootDirLevel\n );\n }\n};\n","exports.setPublicPath = function setPublicPath(\n systemjsModuleName,\n rootDirectoryLevel\n) {\n if (!rootDirectoryLevel) {\n rootDirectoryLevel = 1;\n }\n if (\n typeof systemjsModuleName !== \"string\" ||\n systemjsModuleName.trim().length === 0\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'\"\n );\n }\n\n if (\n typeof rootDirectoryLevel !== \"number\" ||\n rootDirectoryLevel <= 0 ||\n isNaN(rootDirectoryLevel) ||\n !isInteger(rootDirectoryLevel)\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'\"\n );\n }\n\n var moduleUrl;\n try {\n moduleUrl = window.System.resolve(systemjsModuleName);\n if (!moduleUrl) {\n throw Error();\n }\n } catch (err) {\n throw Error(\n \"systemjs-webpack-interop: There is no such module '\" +\n systemjsModuleName +\n \"' in the SystemJS registry. Did you misspell the name of your module?\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(moduleUrl, rootDirectoryLevel);\n};\n\nfunction resolveDirectory(urlString, rootDirectoryLevel) {\n // Our friend IE11 doesn't support new URL()\n // https://github.com/single-spa/single-spa/issues/612\n // https://gist.github.com/jlong/2428561\n\n var a = document.createElement(\"a\");\n a.href = urlString;\n\n var pathname = a.pathname[0] === \"/\" ? a.pathname : \"/\" + a.pathname;\n var numDirsProcessed = 0,\n index = pathname.length;\n while (numDirsProcessed !== rootDirectoryLevel && index >= 0) {\n var char = pathname[--index];\n if (char === \"/\") {\n numDirsProcessed++;\n }\n }\n\n if (numDirsProcessed !== rootDirectoryLevel) {\n throw Error(\n \"systemjs-webpack-interop: rootDirectoryLevel (\" +\n rootDirectoryLevel +\n \") is greater than the number of directories (\" +\n numDirsProcessed +\n \") in the URL path \" +\n urlString\n );\n }\n\n var finalPath = pathname.slice(0, index + 1);\n\n return a.protocol + \"//\" + a.host + finalPath;\n}\n\nexports.resolveDirectory = resolveDirectory;\n\n// borrowed from https://github.com/parshap/js-is-integer/blob/master/index.js\nvar isInteger =\n Number.isInteger ||\n function isInteger(val) {\n return typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n };\n","module.exports = __WEBPACK_EXTERNAL_MODULE__824__;","module.exports = __WEBPACK_EXTERNAL_MODULE__685__;","module.exports = __WEBPACK_EXTERNAL_MODULE__645__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.y = __system_context__;","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) scriptUrl = scripts[scripts.length - 1].src\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","const autoPublicPath = require(\"./auto-public-path\").autoPublicPath;\n\nautoPublicPath(1);\n","import { navigate } from \"@openmrs/esm-config\";\n\nexport type NavigationContextType = \"workspace\" | \"dialog\" | \"link\";\n\nexport interface NavigationContext {\n type: NavigationContextType;\n handler<T = any>(link: string, state: T): boolean;\n}\n\n/**\n * @deprecated use `navigate` directly\n */\nexport function switchTo<T>(\n _type: NavigationContextType,\n link: string,\n _state?: T\n) {\n navigate({ to: link });\n}\n\n/**\n * @deprecated don't use\n */\nexport function pushNavigationContext(_context: NavigationContext) {\n return () => {\n //STUB - remove soon\n };\n}\n","import {\n configExtensionStore,\n ConfigExtensionStoreElement,\n} from \"@openmrs/esm-config\";\nimport { createGlobalStore } from \"@openmrs/esm-state\";\n\nexport interface ExtensionMeta {\n [_: string]: any;\n}\n\nexport interface ExtensionRegistration {\n name: string;\n load(): Promise<any>;\n moduleName: string;\n meta: ExtensionMeta;\n order?: number;\n online?: boolean | object;\n offline?: boolean | object;\n}\n\nexport interface ExtensionInfo extends ExtensionRegistration {\n /**\n * The instances where the extension has been rendered using `renderExtension`,\n * indexed by slotModuleName and slotName.\n */\n instances: Record<string, Record<string, ExtensionInstance>>;\n}\n\nexport interface ExtensionInstance {\n id: string;\n}\n\nexport interface ExtensionStore {\n /** Slots indexed by name */\n slots: Record<string, ExtensionSlotInfo>;\n /** Extensions indexed by name */\n extensions: Record<string, ExtensionInfo>;\n}\n\nexport interface ExtensionSlotInstance {\n /**\n * A set of additional extension IDs which have been added to to this slot despite not being\n * explicitly `attach`ed to it.\n * An example may be an extension which is added to the slot via the configuration.\n */\n addedIds: Array<string>;\n /**\n * A set of extension IDs which have been removed/hidden from this slot, even though they have\n * previously been `attach`ed/added to it.\n * An example may be an extension which is removed from the slot via the configuration.\n */\n removedIds: Array<string>;\n /**\n * A set allowing explicit ordering of the `assignedIds`.\n */\n idOrder: Array<string>;\n}\n\nexport interface ExtensionSlotInfo {\n /**\n * The name under which the extension slot has been registered.\n */\n name: string;\n /**\n * The mapping of modules / extension slot instances where the extension slot has been used.\n */\n instances: Record<string, ExtensionSlotInstance>;\n /**\n * The set of extension IDs which have been attached to this slot.\n * This is essentially a complete history of `attach` calls to this specific slot.\n * However, not all of these extension IDs should be rendered.\n * `assignedIds` is the set defining those.\n */\n attachedIds: Array<string>;\n}\n\nexport const extensionStore = createGlobalStore<ExtensionStore>(\"extensions\", {\n slots: {},\n extensions: {},\n});\n\nexport type MaybeAsync<T> = T | Promise<T>;\n\nlet storeUpdates: Promise<void> = Promise.resolve();\n\nexport function updateExtensionStore<U extends keyof ExtensionStore>(\n updater: (state: ExtensionStore) => MaybeAsync<Pick<ExtensionStore, U>>\n) {\n storeUpdates = storeUpdates.then(async () => {\n const state = extensionStore.getState();\n const newState = await updater(state);\n\n if (newState !== state) {\n extensionStore.setState(newState);\n }\n });\n}\n\n/**\n * esm-config maintains its own store of the extension information it needs\n * to generate extension configs. We keep it updated based on what's in\n * `extensionStore`.\n */\n\nupdateConfigExtensionStore(extensionStore.getState());\nextensionStore.subscribe(updateConfigExtensionStore);\n\nfunction updateConfigExtensionStore(extensionState: ExtensionStore) {\n const configExtensionRecords: Array<ConfigExtensionStoreElement> = [];\n\n for (let extensionInfo of Object.values(extensionState.extensions)) {\n for (let [slotModuleName, extensionBySlot] of Object.entries(\n extensionInfo.instances\n )) {\n for (let [actualSlotName, extensionInstance] of Object.entries(\n extensionBySlot\n )) {\n configExtensionRecords.push({\n slotModuleName,\n extensionModuleName: extensionInfo.moduleName,\n slotName: actualSlotName,\n extensionId: extensionInstance.id,\n });\n }\n }\n }\n configExtensionStore.setState({ mountedExtensions: configExtensionRecords });\n}\n","import { getExtensionSlotsConfigStore } from \"@openmrs/esm-config\";\nimport {\n ExtensionRegistration,\n ExtensionSlotInfo,\n ExtensionSlotInstance,\n ExtensionStore,\n extensionStore,\n updateExtensionStore,\n} from \"./store\";\n\nfunction createNewExtensionSlotInstance(): ExtensionSlotInstance {\n return {\n addedIds: [],\n idOrder: [],\n removedIds: [],\n };\n}\n\nfunction createNewExtensionSlotInfo(\n extensionSlotName: string\n): ExtensionSlotInfo {\n return {\n name: extensionSlotName,\n attachedIds: [],\n instances: {},\n };\n}\n\nexport function getExtensionNameFromId(extensionId: string) {\n const [extensionName] = extensionId.split(\"#\");\n return extensionName;\n}\n\nexport function getExtensionRegistrationFrom(\n state: ExtensionStore,\n extensionId: string\n): ExtensionRegistration | undefined {\n const name = getExtensionNameFromId(extensionId);\n return state.extensions[name];\n}\n\nexport function getExtensionRegistration(\n extensionId: string\n): ExtensionRegistration | undefined {\n const state = extensionStore.getState();\n return getExtensionRegistrationFrom(state, extensionId);\n}\n\nexport interface ExtensionDetails {\n moduleName: string;\n load: () => Promise<any>;\n meta: Record<string, any>;\n online?: boolean | object;\n offline?: boolean | object;\n order?: number;\n}\n\nexport const registerExtension: (\n name: string,\n details: ExtensionDetails\n) => void = extensionStore.action(\n (state, name: string, details: ExtensionDetails) => {\n state.extensions[name] = {\n ...details,\n name,\n instances: {},\n };\n }\n);\n\nexport function attach(extensionSlotName: string, extensionId: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[extensionSlotName];\n\n if (!existingSlot) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...createNewExtensionSlotInfo(extensionSlotName),\n attachedIds: [extensionId],\n },\n },\n };\n } else {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...existingSlot,\n attachedIds: [...existingSlot.attachedIds, extensionId],\n },\n },\n };\n }\n });\n}\n\nexport function detach(extensionSlotName: string, extensionId: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[extensionSlotName];\n\n if (existingSlot && existingSlot.attachedIds.includes(extensionId)) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...existingSlot,\n attachedIds: existingSlot.attachedIds.filter(\n (id) => id !== extensionId\n ),\n },\n },\n };\n } else {\n return state;\n }\n });\n}\n\nexport function detachAll(extensionSlotName: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[extensionSlotName];\n\n if (existingSlot) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...existingSlot,\n attachedIds: [],\n },\n },\n };\n } else {\n return state;\n }\n });\n}\n\nfunction getOrder(\n configuredOrder: number,\n extension: Partial<ExtensionRegistration> = {}\n) {\n if (configuredOrder === -1) {\n const { order = -1 } = extension;\n return order;\n }\n\n return configuredOrder;\n}\n\nexport function getAssignedIds(\n instance: ExtensionSlotInstance,\n attachedIds: Array<string>\n) {\n const { addedIds, removedIds, idOrder } = instance;\n const { extensions } = extensionStore.getState();\n\n return [...attachedIds, ...addedIds]\n .filter((m) => !removedIds.includes(m))\n .sort((a, b) => {\n const ai = getOrder(idOrder.indexOf(a), extensions[a]);\n const bi = getOrder(idOrder.indexOf(b), extensions[b]);\n\n if (bi === -1) {\n return -1;\n } else if (ai === -1) {\n return 1;\n } else {\n return ai - bi;\n }\n });\n}\n\nfunction getUpdatedExtensionSlotInfoForRegistration(\n existingSlot: ExtensionSlotInfo,\n slotName: string,\n moduleName: string\n) {\n if (!existingSlot) {\n return getUpdatedExtensionSlotInfo(slotName, moduleName, {\n ...createNewExtensionSlotInfo(slotName),\n instances: {\n [moduleName]: createNewExtensionSlotInstance(),\n },\n });\n } else if (moduleName in existingSlot.instances) {\n return getUpdatedExtensionSlotInfo(slotName, moduleName, existingSlot);\n } else {\n return getUpdatedExtensionSlotInfo(slotName, moduleName, {\n ...existingSlot,\n instances: {\n ...existingSlot.instances,\n [moduleName]: createNewExtensionSlotInstance(),\n },\n });\n }\n}\n\nfunction getUpdatedExtensionSlotInfoForUnregistration(\n existingSlot: ExtensionSlotInfo,\n extensionSlotName: string,\n moduleName: string\n) {\n const { [moduleName]: existing, ...instances } = existingSlot.instances;\n\n return getUpdatedExtensionSlotInfo(extensionSlotName, moduleName, {\n ...existingSlot,\n instances,\n });\n}\n\n/**\n * @param moduleName The name of the module that contains the extension slot\n * @param slotName The extension slot name that is actually used\n */\nexport function registerExtensionSlot(moduleName: string, slotName: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[slotName];\n const updatedSlot = getUpdatedExtensionSlotInfoForRegistration(\n existingSlot,\n slotName,\n moduleName\n );\n\n if (existingSlot !== updatedSlot) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [slotName]: updatedSlot,\n },\n };\n }\n\n return state;\n });\n}\n\nexport function unregisterExtensionSlot(moduleName: string, slotName: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[slotName];\n\n if (existingSlot && moduleName in existingSlot.instances) {\n const updatedSlot = getUpdatedExtensionSlotInfoForUnregistration(\n existingSlot,\n slotName,\n moduleName\n );\n\n return {\n ...state,\n slots: {\n ...state.slots,\n [slotName]: updatedSlot,\n },\n };\n }\n\n return state;\n });\n}\n\nexport function getExtensionSlotsForModule(moduleName: string) {\n const state = extensionStore.getState();\n return Object.keys(state.slots).filter(\n (name) => moduleName in state.slots[name].instances\n );\n}\n\n/**\n * @internal\n * Just for testing.\n */\nexport const reset: () => void = extensionStore.action(() => {\n return {\n slots: {},\n extensions: {},\n };\n});\n\n/**\n * Returns information describing all extensions which can be rendered into an extension slot with\n * the specified name.\n * The returned information describe the extension itself, as well as the extension slot name(s)\n * with which it has been attached.\n * @param slotName The extension slot name for which matching extension info should be returned.\n * @param moduleName The module name. Used for applying extension-specific config values to the result.\n * @param extensionSlot The extension slot information object.\n */\nexport function getUpdatedExtensionSlotInfo(\n slotName: string,\n moduleName: string,\n extensionSlot: ExtensionSlotInfo\n): ExtensionSlotInfo {\n let instance = extensionSlot.instances[moduleName];\n\n if (instance) {\n const originalInstance = instance;\n const config =\n getExtensionSlotsConfigStore(moduleName).getState().extensionSlotConfigs[\n slotName\n ] ?? {};\n\n if (Array.isArray(config.add)) {\n config.add.forEach((extensionId) => {\n if (!instance.addedIds.includes(extensionId)) {\n instance = {\n ...instance,\n addedIds: [...instance.addedIds, extensionId],\n };\n }\n });\n }\n\n if (Array.isArray(config.remove)) {\n config.remove.forEach((extensionId) => {\n if (!instance.removedIds.includes(extensionId)) {\n instance = {\n ...instance,\n removedIds: [...instance.removedIds, extensionId],\n };\n }\n });\n }\n\n if (Array.isArray(config.order)) {\n const testOrder = config.order.join(\",\");\n const fullOrder = instance.idOrder.join(\",\");\n\n if (!fullOrder.endsWith(testOrder)) {\n config.order.forEach((extensionId) => {\n instance = {\n ...instance,\n idOrder: [\n ...instance.idOrder.filter((m) => m !== extensionId),\n extensionId,\n ],\n };\n });\n }\n }\n\n if (instance !== originalInstance) {\n return {\n ...extensionSlot,\n instances: {\n ...extensionSlot.instances,\n [moduleName]: instance,\n },\n };\n }\n }\n\n return extensionSlot;\n}\n","export function checkStatus(\n online: boolean | object = true,\n offline: boolean | object = false\n) {\n const status = navigator.onLine;\n return checkStatusFor(status, online, offline);\n}\n\nexport function checkStatusFor(\n status: boolean,\n online: boolean | object = true,\n offline: boolean | object = false\n) {\n return Boolean(status ? online : offline);\n}\n\nexport function getCustomProps(\n online: boolean | object | undefined,\n offline: boolean | object | undefined\n) {\n const status = navigator.onLine;\n const props = status ? online : offline;\n return typeof props === \"object\" ? props : {};\n}\n","import { update } from \"@openmrs/esm-state\";\nimport { mountRootParcel, Parcel } from \"single-spa\";\nimport { getExtensionNameFromId, getExtensionRegistration } from \"./extensions\";\nimport { checkStatus, getCustomProps } from \"./helpers\";\nimport { updateExtensionStore } from \"./store\";\n\nexport interface Lifecycle {\n bootstrap(): void;\n mount(): void;\n unmount(): void;\n update?(): void;\n}\n\nexport interface CancelLoading {\n (): void;\n}\n\n/**\n * Mounts into a DOM node (representing an extension slot)\n * a lazy-loaded component from *any* microfrontend\n * that registered an extension component for this slot.\n */\nexport function renderExtension(\n domElement: HTMLElement,\n extensionSlotName: string,\n extensionSlotModuleName: string,\n extensionId: string,\n renderFunction: (lifecycle: Lifecycle) => Lifecycle = (x) => x,\n additionalProps: Record<string, any> = {}\n): CancelLoading {\n const extensionName = getExtensionNameFromId(extensionId);\n const extensionRegistration = getExtensionRegistration(extensionId);\n let active: boolean | Parcel = true;\n\n if (domElement) {\n if (!extensionRegistration) {\n throw Error(\n `Couldn't find extension '${extensionName}' to attach to '${extensionSlotName}'`\n );\n }\n\n const { load, online, offline, meta, moduleName } = extensionRegistration;\n\n if (checkStatus(online, offline)) {\n load().then(({ default: result, ...lifecycle }) => {\n if (active) {\n const parcel = mountRootParcel(\n renderFunction(result ?? lifecycle) as any,\n {\n ...getCustomProps(online, offline),\n ...additionalProps,\n _meta: meta,\n _extensionContext: {\n extensionId,\n extensionSlotName,\n extensionSlotModuleName,\n extensionModuleName: moduleName,\n },\n domElement,\n }\n );\n active = parcel;\n }\n });\n\n updateExtensionStore((state) =>\n update(\n state,\n [\n \"extensions\",\n extensionName,\n \"instances\",\n extensionSlotModuleName,\n extensionSlotName,\n ],\n { domElement, id: extensionId }\n )\n );\n }\n }\n\n return () => {\n if (typeof active === \"boolean\") {\n active = false;\n } else {\n const p = active;\n\n if (p.getStatus() !== \"MOUNTED\") {\n p.mountPromise.then(() => p.unmount());\n } else {\n p.unmount();\n }\n }\n };\n}\n"],"names":["resolveDirectory","exports","rootDirLevel","meta","url","console","error","Error","urlString","rootDirectoryLevel","a","document","createElement","href","pathname","numDirsProcessed","index","length","finalPath","slice","protocol","host","Number","isInteger","module","__WEBPACK_EXTERNAL_MODULE__824__","__WEBPACK_EXTERNAL_MODULE__685__","__WEBPACK_EXTERNAL_MODULE__645__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","y","__system_context__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","this","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","scriptUrl","importScripts","location","currentScript","src","scripts","getElementsByTagName","replace","p","autoPublicPath","switchTo","_type","link","_state","navigate","to","pushNavigationContext","_context","extensionStore","createGlobalStore","slots","extensions","storeUpdates","Promise","resolve","updateExtensionStore","updater","then","async","state","getState","newState","setState","updateConfigExtensionStore","extensionState","configExtensionRecords","extensionInfo","values","slotModuleName","extensionBySlot","entries","instances","actualSlotName","extensionInstance","push","extensionModuleName","moduleName","slotName","extensionId","id","configExtensionStore","mountedExtensions","createNewExtensionSlotInfo","extensionSlotName","name","attachedIds","getExtensionNameFromId","extensionName","split","getExtensionRegistrationFrom","getExtensionRegistration","subscribe","registerExtension","action","details","attach","existingSlot","detach","includes","filter","detachAll","getOrder","configuredOrder","extension","order","getAssignedIds","instance","addedIds","removedIds","idOrder","m","sort","b","ai","indexOf","bi","registerExtensionSlot","updatedSlot","getUpdatedExtensionSlotInfo","getUpdatedExtensionSlotInfoForRegistration","unregisterExtensionSlot","existing","getUpdatedExtensionSlotInfoForUnregistration","getExtensionSlotsForModule","keys","reset","extensionSlot","originalInstance","config","getExtensionSlotsConfigStore","extensionSlotConfigs","Array","isArray","add","forEach","remove","testOrder","join","endsWith","checkStatus","online","offline","checkStatusFor","navigator","onLine","status","Boolean","getCustomProps","props","renderExtension","domElement","extensionSlotModuleName","renderFunction","x","additionalProps","extensionRegistration","active","load","default","result","lifecycle","parcel","mountRootParcel","_meta","_extensionContext","update","getStatus","mountPromise","unmount"],"sourceRoot":""}
1
+ {"version":3,"file":"openmrs-esm-extensions.js","mappings":"obAAA,MAAMA,EAAmB,SAEzBC,EAAQ,EAAiB,SAAwBC,GAY7C,GAXGA,IACHA,EAAe,IAUV,IAAmBC,OAAS,IAAmBA,KAAKC,IAEvD,MADAC,QAAQC,MAAM,qBAAsB,KAC9BC,MACJ,uHAIJ,IAA0BP,EACxB,IAAmBG,KAAKC,IACxBF,K,cCuDND,EAAQ,EAlCR,SAA0BO,EAAWC,GAKnC,IAAIC,EAAIC,SAASC,cAAc,KAC/BF,EAAEG,KAAOL,EAKT,IAHA,IAAIM,EAA6B,MAAlBJ,EAAEI,SAAS,GAAaJ,EAAEI,SAAW,IAAMJ,EAAEI,SACxDC,EAAmB,EACrBC,EAAQF,EAASG,OACZF,IAAqBN,GAAsBO,GAAS,GAE5C,MADFF,IAAWE,IAEpBD,IAIJ,GAAIA,IAAqBN,EACvB,MAAMF,MACJ,iDACEE,EACA,gDACAM,EACA,qBACAP,GAIN,IAAIU,EAAYJ,EAASK,MAAM,EAAGH,EAAQ,GAE1C,OAAON,EAAEU,SAAW,KAAOV,EAAEW,KAAOH,GAOpCI,OAAOC,W,qBClFTC,EAAOvB,QAAUwB,G,qBCAjBD,EAAOvB,QAAUyB,G,qBCAjBF,EAAOvB,QAAU0B,ICCbC,EAA2B,GAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA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J,MAIhE,MAAM,KAAE0E,EAAF,OAAQjB,EAAR,QAAgBC,EAAhB,KAAyBvK,EAAzB,WAA+BsG,GAAe+E,EAEhDhB,EAAYC,EAAQC,KACtBgB,IAAOpG,MAAK,EAAGqG,QAASC,KAAWC,MACjC,GAAIJ,EAAQ,CACV,MAAMK,GAASC,EAAAA,EAAAA,iBACbV,EAAeO,MAAAA,EAAAA,EAAUC,GACzB,IACKb,EAAeP,EAAQC,MACvBa,EACHS,MAAO7L,EACP8L,kBAAmB,CACjBtF,YAAAA,EACAK,kBAAAA,EACAoE,wBAAAA,EACA5E,oBAAqBC,GAEvB0E,WAAAA,IAGJM,EAASK,MAIb1G,GAAsBI,IACpB0G,EAAAA,EAAAA,QACE1G,EACA,CACE,aACA4B,EACA,YACAgE,EACApE,GAEF,CAAEmE,WAAAA,EAAYvE,GAAID,OAM1B,MAAO,KACL,GAAsB,kBAAX8E,EACTA,GAAS,MACJ,CACL,MAAMtH,EAAIsH,EAEY,YAAlBtH,EAAEgI,YACJhI,EAAEiI,aAAa9G,MAAK,IAAMnB,EAAEkI,YAE5BlI,EAAEkI,c","sources":["webpack://@openmrs/esm-extensions/../../../node_modules/systemjs-webpack-interop/auto-public-path/auto-public-path.js","webpack://@openmrs/esm-extensions/../../../node_modules/systemjs-webpack-interop/public-path.js","webpack://@openmrs/esm-extensions/external system \"@openmrs/esm-config\"","webpack://@openmrs/esm-extensions/external system \"@openmrs/esm-state\"","webpack://@openmrs/esm-extensions/external system \"single-spa\"","webpack://@openmrs/esm-extensions/webpack/bootstrap","webpack://@openmrs/esm-extensions/webpack/runtime/__system_context__","webpack://@openmrs/esm-extensions/webpack/runtime/define property getters","webpack://@openmrs/esm-extensions/webpack/runtime/global","webpack://@openmrs/esm-extensions/webpack/runtime/hasOwnProperty shorthand","webpack://@openmrs/esm-extensions/webpack/runtime/make namespace object","webpack://@openmrs/esm-extensions/webpack/runtime/publicPath","webpack://@openmrs/esm-extensions/../../../node_modules/systemjs-webpack-interop/auto-public-path/1.js","webpack://@openmrs/esm-extensions/./src/contexts.ts","webpack://@openmrs/esm-extensions/./src/store.ts","webpack://@openmrs/esm-extensions/./src/extensions.ts","webpack://@openmrs/esm-extensions/./src/helpers.ts","webpack://@openmrs/esm-extensions/./src/render.ts"],"sourcesContent":["const resolveDirectory = require(\"../public-path\").resolveDirectory;\n\nexports.autoPublicPath = function autoPublicPath(rootDirLevel) {\n if (!rootDirLevel) {\n rootDirLevel = 1;\n }\n\n if (typeof __webpack_public_path__ !== \"undefined\") {\n if (typeof __system_context__ === \"undefined\") {\n throw Error(\n \"systemjs-webpack-interop requires webpack@>=5.0.0-beta.15 and output.libraryTarget set to 'system'\"\n );\n }\n\n if (!__system_context__.meta || !__system_context__.meta.url) {\n console.error(\"__system_context__\", __system_context__);\n throw Error(\n \"systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(\n __system_context__.meta.url,\n rootDirLevel\n );\n }\n};\n","exports.setPublicPath = function setPublicPath(\n systemjsModuleName,\n rootDirectoryLevel\n) {\n if (!rootDirectoryLevel) {\n rootDirectoryLevel = 1;\n }\n if (\n typeof systemjsModuleName !== \"string\" ||\n systemjsModuleName.trim().length === 0\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName) must be called with a non-empty string 'systemjsModuleName'\"\n );\n }\n\n if (\n typeof rootDirectoryLevel !== \"number\" ||\n rootDirectoryLevel <= 0 ||\n isNaN(rootDirectoryLevel) ||\n !isInteger(rootDirectoryLevel)\n ) {\n throw Error(\n \"systemjs-webpack-interop: setPublicPath(systemjsModuleName, rootDirectoryLevel) must be called with a positive integer 'rootDirectoryLevel'\"\n );\n }\n\n var moduleUrl;\n try {\n moduleUrl = window.System.resolve(systemjsModuleName);\n if (!moduleUrl) {\n throw Error();\n }\n } catch (err) {\n throw Error(\n \"systemjs-webpack-interop: There is no such module '\" +\n systemjsModuleName +\n \"' in the SystemJS registry. Did you misspell the name of your module?\"\n );\n }\n\n __webpack_public_path__ = resolveDirectory(moduleUrl, rootDirectoryLevel);\n};\n\nfunction resolveDirectory(urlString, rootDirectoryLevel) {\n // Our friend IE11 doesn't support new URL()\n // https://github.com/single-spa/single-spa/issues/612\n // https://gist.github.com/jlong/2428561\n\n var a = document.createElement(\"a\");\n a.href = urlString;\n\n var pathname = a.pathname[0] === \"/\" ? a.pathname : \"/\" + a.pathname;\n var numDirsProcessed = 0,\n index = pathname.length;\n while (numDirsProcessed !== rootDirectoryLevel && index >= 0) {\n var char = pathname[--index];\n if (char === \"/\") {\n numDirsProcessed++;\n }\n }\n\n if (numDirsProcessed !== rootDirectoryLevel) {\n throw Error(\n \"systemjs-webpack-interop: rootDirectoryLevel (\" +\n rootDirectoryLevel +\n \") is greater than the number of directories (\" +\n numDirsProcessed +\n \") in the URL path \" +\n urlString\n );\n }\n\n var finalPath = pathname.slice(0, index + 1);\n\n return a.protocol + \"//\" + a.host + finalPath;\n}\n\nexports.resolveDirectory = resolveDirectory;\n\n// borrowed from https://github.com/parshap/js-is-integer/blob/master/index.js\nvar isInteger =\n Number.isInteger ||\n function isInteger(val) {\n return typeof val === \"number\" && isFinite(val) && Math.floor(val) === val;\n };\n","module.exports = __WEBPACK_EXTERNAL_MODULE__824__;","module.exports = __WEBPACK_EXTERNAL_MODULE__685__;","module.exports = __WEBPACK_EXTERNAL_MODULE__645__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","__webpack_require__.y = __system_context__;","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","var scriptUrl;\nif (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + \"\";\nvar document = __webpack_require__.g.document;\nif (!scriptUrl && document) {\n\tif (document.currentScript)\n\t\tscriptUrl = document.currentScript.src\n\tif (!scriptUrl) {\n\t\tvar scripts = document.getElementsByTagName(\"script\");\n\t\tif(scripts.length) scriptUrl = scripts[scripts.length - 1].src\n\t}\n}\n// When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration\n// or pass an empty string (\"\") and set the __webpack_public_path__ variable from your code to use your own logic.\nif (!scriptUrl) throw new Error(\"Automatic publicPath is not supported in this browser\");\nscriptUrl = scriptUrl.replace(/#.*$/, \"\").replace(/\\?.*$/, \"\").replace(/\\/[^\\/]+$/, \"/\");\n__webpack_require__.p = scriptUrl;","const autoPublicPath = require(\"./auto-public-path\").autoPublicPath;\n\nautoPublicPath(1);\n","import { navigate } from \"@openmrs/esm-config\";\n\nexport type NavigationContextType = \"workspace\" | \"dialog\" | \"link\";\n\nexport interface NavigationContext {\n type: NavigationContextType;\n handler<T = any>(link: string, state: T): boolean;\n}\n\n/**\n * @deprecated use `navigate` directly\n */\nexport function switchTo<T>(\n _type: NavigationContextType,\n link: string,\n _state?: T\n) {\n navigate({ to: link });\n}\n\n/**\n * @deprecated don't use\n */\nexport function pushNavigationContext(_context: NavigationContext) {\n return () => {\n //STUB - remove soon\n };\n}\n","import {\n configExtensionStore,\n ConfigExtensionStoreElement,\n} from \"@openmrs/esm-config\";\nimport { createGlobalStore } from \"@openmrs/esm-state\";\n\nexport interface ExtensionMeta {\n [_: string]: any;\n}\n\nexport interface ExtensionRegistration {\n name: string;\n load(): Promise<any>;\n moduleName: string;\n meta: ExtensionMeta;\n order?: number;\n online?: boolean | object;\n offline?: boolean | object;\n}\n\nexport interface ExtensionInfo extends ExtensionRegistration {\n /**\n * The instances where the extension has been rendered using `renderExtension`,\n * indexed by slotModuleName and slotName.\n */\n instances: Record<string, Record<string, ExtensionInstance>>;\n}\n\nexport interface ExtensionInstance {\n id: string;\n}\n\nexport interface ExtensionStore {\n /** Slots indexed by name */\n slots: Record<string, ExtensionSlotInfo>;\n /** Extensions indexed by name */\n extensions: Record<string, ExtensionInfo>;\n}\n\nexport interface ExtensionSlotInstance {\n /**\n * A set of additional extension IDs which have been added to to this slot despite not being\n * explicitly `attach`ed to it.\n * An example may be an extension which is added to the slot via the configuration.\n */\n addedIds: Array<string>;\n /**\n * A set of extension IDs which have been removed/hidden from this slot, even though they have\n * previously been `attach`ed/added to it.\n * An example may be an extension which is removed from the slot via the configuration.\n */\n removedIds: Array<string>;\n /**\n * A set allowing explicit ordering of the `assignedIds`.\n */\n idOrder: Array<string>;\n}\n\nexport interface ExtensionSlotInfo {\n /**\n * The name under which the extension slot has been registered.\n */\n name: string;\n /**\n * The mapping of modules / extension slot instances where the extension slot has been used.\n */\n instances: Record<string, ExtensionSlotInstance>;\n /**\n * The set of extension IDs which have been attached to this slot.\n * This is essentially a complete history of `attach` calls to this specific slot.\n * However, not all of these extension IDs should be rendered.\n * `assignedIds` is the set defining those.\n */\n attachedIds: Array<string>;\n}\n\nexport const extensionStore = createGlobalStore<ExtensionStore>(\"extensions\", {\n slots: {},\n extensions: {},\n});\n\nexport type MaybeAsync<T> = T | Promise<T>;\n\nlet storeUpdates: Promise<void> = Promise.resolve();\n\nexport function updateExtensionStore<U extends keyof ExtensionStore>(\n updater: (state: ExtensionStore) => MaybeAsync<Pick<ExtensionStore, U>>\n) {\n storeUpdates = storeUpdates.then(async () => {\n const state = extensionStore.getState();\n const newState = await updater(state);\n\n if (newState !== state) {\n extensionStore.setState(newState);\n }\n });\n}\n\n/**\n * esm-config maintains its own store of the extension information it needs\n * to generate extension configs. We keep it updated based on what's in\n * `extensionStore`.\n */\n\nupdateConfigExtensionStore(extensionStore.getState());\nextensionStore.subscribe(updateConfigExtensionStore);\n\nfunction updateConfigExtensionStore(extensionState: ExtensionStore) {\n const configExtensionRecords: Array<ConfigExtensionStoreElement> = [];\n\n for (let extensionInfo of Object.values(extensionState.extensions)) {\n for (let [slotModuleName, extensionBySlot] of Object.entries(\n extensionInfo.instances\n )) {\n for (let [actualSlotName, extensionInstance] of Object.entries(\n extensionBySlot\n )) {\n configExtensionRecords.push({\n slotModuleName,\n extensionModuleName: extensionInfo.moduleName,\n slotName: actualSlotName,\n extensionId: extensionInstance.id,\n });\n }\n }\n }\n configExtensionStore.setState({ mountedExtensions: configExtensionRecords });\n}\n","import { getExtensionSlotsConfigStore } from \"@openmrs/esm-config\";\nimport {\n ExtensionRegistration,\n ExtensionSlotInfo,\n ExtensionSlotInstance,\n ExtensionStore,\n extensionStore,\n updateExtensionStore,\n} from \"./store\";\n\nfunction createNewExtensionSlotInstance(): ExtensionSlotInstance {\n return {\n addedIds: [],\n idOrder: [],\n removedIds: [],\n };\n}\n\nfunction createNewExtensionSlotInfo(\n extensionSlotName: string\n): ExtensionSlotInfo {\n return {\n name: extensionSlotName,\n attachedIds: [],\n instances: {},\n };\n}\n\nexport function getExtensionNameFromId(extensionId: string) {\n const [extensionName] = extensionId.split(\"#\");\n return extensionName;\n}\n\nexport function getExtensionRegistrationFrom(\n state: ExtensionStore,\n extensionId: string\n): ExtensionRegistration | undefined {\n const name = getExtensionNameFromId(extensionId);\n return state.extensions[name];\n}\n\nexport function getExtensionRegistration(\n extensionId: string\n): ExtensionRegistration | undefined {\n const state = extensionStore.getState();\n return getExtensionRegistrationFrom(state, extensionId);\n}\n\nexport interface ExtensionDetails {\n moduleName: string;\n load: () => Promise<any>;\n meta: Record<string, any>;\n online?: boolean | object;\n offline?: boolean | object;\n order?: number;\n}\n\nexport const registerExtension: (\n name: string,\n details: ExtensionDetails\n) => void = extensionStore.action(\n (state, name: string, details: ExtensionDetails) => {\n state.extensions[name] = {\n ...details,\n name,\n instances: {},\n };\n }\n);\n\nexport function attach(extensionSlotName: string, extensionId: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[extensionSlotName];\n\n if (!existingSlot) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...createNewExtensionSlotInfo(extensionSlotName),\n attachedIds: [extensionId],\n },\n },\n };\n } else {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...existingSlot,\n attachedIds: [...existingSlot.attachedIds, extensionId],\n },\n },\n };\n }\n });\n}\n\nexport function detach(extensionSlotName: string, extensionId: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[extensionSlotName];\n\n if (existingSlot && existingSlot.attachedIds.includes(extensionId)) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...existingSlot,\n attachedIds: existingSlot.attachedIds.filter(\n (id) => id !== extensionId\n ),\n },\n },\n };\n } else {\n return state;\n }\n });\n}\n\nexport function detachAll(extensionSlotName: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[extensionSlotName];\n\n if (existingSlot) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [extensionSlotName]: {\n ...existingSlot,\n attachedIds: [],\n },\n },\n };\n } else {\n return state;\n }\n });\n}\n\nfunction getOrder(\n configuredOrder: number,\n extension: Partial<ExtensionRegistration> = {}\n) {\n if (configuredOrder === -1) {\n const { order = -1 } = extension;\n return order;\n }\n\n return configuredOrder;\n}\n\nexport function getAssignedIds(\n instance: ExtensionSlotInstance,\n attachedIds: Array<string>\n) {\n const { addedIds, removedIds, idOrder } = instance;\n const { extensions } = extensionStore.getState();\n\n return [...attachedIds, ...addedIds]\n .filter((m) => !removedIds.includes(m))\n .sort((a, b) => {\n const ai = getOrder(idOrder.indexOf(a), extensions[a]);\n const bi = getOrder(idOrder.indexOf(b), extensions[b]);\n\n if (bi === -1) {\n return -1;\n } else if (ai === -1) {\n return 1;\n } else {\n return ai - bi;\n }\n });\n}\n\nfunction getUpdatedExtensionSlotInfoForRegistration(\n existingSlot: ExtensionSlotInfo,\n slotName: string,\n moduleName: string\n) {\n if (!existingSlot) {\n return getUpdatedExtensionSlotInfo(slotName, moduleName, {\n ...createNewExtensionSlotInfo(slotName),\n instances: {\n [moduleName]: createNewExtensionSlotInstance(),\n },\n });\n } else if (moduleName in existingSlot.instances) {\n return getUpdatedExtensionSlotInfo(slotName, moduleName, existingSlot);\n } else {\n return getUpdatedExtensionSlotInfo(slotName, moduleName, {\n ...existingSlot,\n instances: {\n ...existingSlot.instances,\n [moduleName]: createNewExtensionSlotInstance(),\n },\n });\n }\n}\n\nfunction getUpdatedExtensionSlotInfoForUnregistration(\n existingSlot: ExtensionSlotInfo,\n extensionSlotName: string,\n moduleName: string\n) {\n const { [moduleName]: existing, ...instances } = existingSlot.instances;\n\n return getUpdatedExtensionSlotInfo(extensionSlotName, moduleName, {\n ...existingSlot,\n instances,\n });\n}\n\n/**\n * @param moduleName The name of the module that contains the extension slot\n * @param slotName The extension slot name that is actually used\n */\nexport function registerExtensionSlot(moduleName: string, slotName: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[slotName];\n const updatedSlot = getUpdatedExtensionSlotInfoForRegistration(\n existingSlot,\n slotName,\n moduleName\n );\n\n if (existingSlot !== updatedSlot) {\n return {\n ...state,\n slots: {\n ...state.slots,\n [slotName]: updatedSlot,\n },\n };\n }\n\n return state;\n });\n}\n\nexport function unregisterExtensionSlot(moduleName: string, slotName: string) {\n updateExtensionStore((state) => {\n const existingSlot = state.slots[slotName];\n\n if (existingSlot && moduleName in existingSlot.instances) {\n const updatedSlot = getUpdatedExtensionSlotInfoForUnregistration(\n existingSlot,\n slotName,\n moduleName\n );\n\n return {\n ...state,\n slots: {\n ...state.slots,\n [slotName]: updatedSlot,\n },\n };\n }\n\n return state;\n });\n}\n\nexport function getExtensionSlotsForModule(moduleName: string) {\n const state = extensionStore.getState();\n return Object.keys(state.slots).filter(\n (name) => moduleName in state.slots[name].instances\n );\n}\n\n/**\n * @internal\n * Just for testing.\n */\nexport const reset: () => void = extensionStore.action(() => {\n return {\n slots: {},\n extensions: {},\n };\n});\n\n/**\n * Returns information describing all extensions which can be rendered into an extension slot with\n * the specified name.\n * The returned information describe the extension itself, as well as the extension slot name(s)\n * with which it has been attached.\n * @param slotName The extension slot name for which matching extension info should be returned.\n * @param moduleName The module name. Used for applying extension-specific config values to the result.\n * @param extensionSlot The extension slot information object.\n */\nexport function getUpdatedExtensionSlotInfo(\n slotName: string,\n moduleName: string,\n extensionSlot: ExtensionSlotInfo\n): ExtensionSlotInfo {\n let instance = extensionSlot.instances[moduleName];\n\n if (instance) {\n const originalInstance = instance;\n const config =\n getExtensionSlotsConfigStore(moduleName).getState().extensionSlotConfigs[\n slotName\n ] ?? {};\n\n if (Array.isArray(config.add)) {\n config.add.forEach((extensionId) => {\n if (!instance.addedIds.includes(extensionId)) {\n instance = {\n ...instance,\n addedIds: [...instance.addedIds, extensionId],\n };\n }\n });\n }\n\n if (Array.isArray(config.remove)) {\n config.remove.forEach((extensionId) => {\n if (!instance.removedIds.includes(extensionId)) {\n instance = {\n ...instance,\n removedIds: [...instance.removedIds, extensionId],\n };\n }\n });\n }\n\n if (Array.isArray(config.order)) {\n const testOrder = config.order.join(\",\");\n const fullOrder = instance.idOrder.join(\",\");\n\n if (!fullOrder.endsWith(testOrder)) {\n config.order.forEach((extensionId) => {\n instance = {\n ...instance,\n idOrder: [\n ...instance.idOrder.filter((m) => m !== extensionId),\n extensionId,\n ],\n };\n });\n }\n }\n\n if (instance !== originalInstance) {\n return {\n ...extensionSlot,\n instances: {\n ...extensionSlot.instances,\n [moduleName]: instance,\n },\n };\n }\n }\n\n return extensionSlot;\n}\n","export function checkStatus(\n online: boolean | object = true,\n offline: boolean | object = false\n) {\n const status = navigator.onLine;\n return checkStatusFor(status, online, offline);\n}\n\nexport function checkStatusFor(\n status: boolean,\n online: boolean | object = true,\n offline: boolean | object = false\n) {\n return Boolean(status ? online : offline);\n}\n\nexport function getCustomProps(\n online: boolean | object | undefined,\n offline: boolean | object | undefined\n) {\n const status = navigator.onLine;\n const props = status ? online : offline;\n return typeof props === \"object\" ? props : {};\n}\n","import { update } from \"@openmrs/esm-state\";\nimport { mountRootParcel, Parcel } from \"single-spa\";\nimport { getExtensionNameFromId, getExtensionRegistration } from \"./extensions\";\nimport { checkStatus, getCustomProps } from \"./helpers\";\nimport { updateExtensionStore } from \"./store\";\n\nexport interface Lifecycle {\n bootstrap(): void;\n mount(): void;\n unmount(): void;\n update?(): void;\n}\n\nexport interface CancelLoading {\n (): void;\n}\n\n/**\n * Mounts into a DOM node (representing an extension slot)\n * a lazy-loaded component from *any* frontend module\n * that registered an extension component for this slot.\n */\nexport function renderExtension(\n domElement: HTMLElement,\n extensionSlotName: string,\n extensionSlotModuleName: string,\n extensionId: string,\n renderFunction: (lifecycle: Lifecycle) => Lifecycle = (x) => x,\n additionalProps: Record<string, any> = {}\n): CancelLoading {\n const extensionName = getExtensionNameFromId(extensionId);\n const extensionRegistration = getExtensionRegistration(extensionId);\n let active: boolean | Parcel = true;\n\n if (domElement) {\n if (!extensionRegistration) {\n throw Error(\n `Couldn't find extension '${extensionName}' to attach to '${extensionSlotName}'`\n );\n }\n\n const { load, online, offline, meta, moduleName } = extensionRegistration;\n\n if (checkStatus(online, offline)) {\n load().then(({ default: result, ...lifecycle }) => {\n if (active) {\n const parcel = mountRootParcel(\n renderFunction(result ?? lifecycle) as any,\n {\n ...getCustomProps(online, offline),\n ...additionalProps,\n _meta: meta,\n _extensionContext: {\n extensionId,\n extensionSlotName,\n extensionSlotModuleName,\n extensionModuleName: moduleName,\n },\n domElement,\n }\n );\n active = parcel;\n }\n });\n\n updateExtensionStore((state) =>\n update(\n state,\n [\n \"extensions\",\n extensionName,\n \"instances\",\n extensionSlotModuleName,\n extensionSlotName,\n ],\n { domElement, id: extensionId }\n )\n );\n }\n }\n\n return () => {\n if (typeof active === \"boolean\") {\n active = false;\n } else {\n const p = active;\n\n if (p.getStatus() !== \"MOUNTED\") {\n p.mountPromise.then(() => p.unmount());\n } else {\n p.unmount();\n }\n }\n };\n}\n"],"names":["resolveDirectory","exports","rootDirLevel","meta","url","console","error","Error","urlString","rootDirectoryLevel","a","document","createElement","href","pathname","numDirsProcessed","index","length","finalPath","slice","protocol","host","Number","isInteger","module","__WEBPACK_EXTERNAL_MODULE__824__","__WEBPACK_EXTERNAL_MODULE__685__","__WEBPACK_EXTERNAL_MODULE__645__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","y","__system_context__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","this","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","scriptUrl","importScripts","location","currentScript","src","scripts","getElementsByTagName","replace","p","autoPublicPath","switchTo","_type","link","_state","navigate","to","pushNavigationContext","_context","extensionStore","createGlobalStore","slots","extensions","storeUpdates","Promise","resolve","updateExtensionStore","updater","then","async","state","getState","newState","setState","updateConfigExtensionStore","extensionState","configExtensionRecords","extensionInfo","values","slotModuleName","extensionBySlot","entries","instances","actualSlotName","extensionInstance","push","extensionModuleName","moduleName","slotName","extensionId","id","configExtensionStore","mountedExtensions","createNewExtensionSlotInfo","extensionSlotName","name","attachedIds","getExtensionNameFromId","extensionName","split","getExtensionRegistrationFrom","getExtensionRegistration","subscribe","registerExtension","action","details","attach","existingSlot","detach","includes","filter","detachAll","getOrder","configuredOrder","extension","order","getAssignedIds","instance","addedIds","removedIds","idOrder","m","sort","b","ai","indexOf","bi","registerExtensionSlot","updatedSlot","getUpdatedExtensionSlotInfo","getUpdatedExtensionSlotInfoForRegistration","unregisterExtensionSlot","existing","getUpdatedExtensionSlotInfoForUnregistration","getExtensionSlotsForModule","keys","reset","extensionSlot","originalInstance","config","getExtensionSlotsConfigStore","extensionSlotConfigs","Array","isArray","add","forEach","remove","testOrder","join","endsWith","checkStatus","online","offline","checkStatusFor","navigator","onLine","status","Boolean","getCustomProps","props","renderExtension","domElement","extensionSlotModuleName","renderFunction","x","additionalProps","extensionRegistration","active","load","default","result","lifecycle","parcel","mountRootParcel","_meta","_extensionContext","update","getStatus","mountPromise","unmount"],"sourceRoot":""}
package/docs/API.md CHANGED
@@ -417,7 +417,7 @@ ___
417
417
  ▸ **renderExtension**(`domElement`, `extensionSlotName`, `extensionSlotModuleName`, `extensionId`, `renderFunction?`, `additionalProps?`): [`CancelLoading`](interfaces/CancelLoading.md)
418
418
 
419
419
  Mounts into a DOM node (representing an extension slot)
420
- a lazy-loaded component from *any* microfrontend
420
+ a lazy-loaded component from *any* frontend module
421
421
  that registered an extension component for this slot.
422
422
 
423
423
  #### Parameters
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-extensions",
3
- "version": "3.1.10-pre.563",
3
+ "version": "3.1.10-pre.579",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Coordinates extensions and extension points in the OpenMRS Frontend",
6
6
  "browser": "dist/openmrs-esm-extensions.js",
@@ -43,10 +43,10 @@
43
43
  "single-spa": "5.x"
44
44
  },
45
45
  "devDependencies": {
46
- "@openmrs/esm-api": "^3.1.10-pre.563",
47
- "@openmrs/esm-config": "^3.1.10-pre.563",
48
- "@openmrs/esm-state": "^3.1.10-pre.563",
46
+ "@openmrs/esm-api": "^3.1.10-pre.579",
47
+ "@openmrs/esm-config": "^3.1.10-pre.579",
48
+ "@openmrs/esm-state": "^3.1.10-pre.579",
49
49
  "single-spa": "^5.9.2"
50
50
  },
51
- "gitHead": "615c93434521a0341a9425dcd32f381d87cbdab3"
51
+ "gitHead": "703d899a7ccb4757ec0646f191d2b96a7e41963f"
52
52
  }
package/src/render.ts CHANGED
@@ -17,7 +17,7 @@ export interface CancelLoading {
17
17
 
18
18
  /**
19
19
  * Mounts into a DOM node (representing an extension slot)
20
- * a lazy-loaded component from *any* microfrontend
20
+ * a lazy-loaded component from *any* frontend module
21
21
  * that registered an extension component for this slot.
22
22
  */
23
23
  export function renderExtension(