@openedx/frontend-base 2.0.0-alpha.1 → 2.0.0-alpha.2

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.
Files changed (47) hide show
  1. package/dist/runtime/config/index.js.map +1 -1
  2. package/dist/runtime/i18n/lib.js.map +1 -1
  3. package/dist/runtime/logging/types.js.map +1 -1
  4. package/dist/runtime/react/CombinedAppProvider.js.map +1 -1
  5. package/dist/runtime/react/CurrentAppContext.js.map +1 -1
  6. package/dist/runtime/react/CurrentAppProvider.js.map +1 -1
  7. package/dist/runtime/react/SiteContext.js.map +1 -1
  8. package/dist/runtime/react/SiteProvider.js.map +1 -1
  9. package/dist/runtime/react/hooks/theme/useThemeVariants.js.map +1 -1
  10. package/dist/runtime/slots/Slot.js.map +1 -1
  11. package/dist/runtime/slots/SlotContext.js.map +1 -1
  12. package/dist/runtime/slots/layout/types.js.map +1 -1
  13. package/dist/runtime/slots/types.js.map +1 -1
  14. package/dist/runtime/slots/widget/WidgetContext.js.map +1 -1
  15. package/dist/runtime/slots/widget/WidgetProvider.js.map +1 -1
  16. package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.js.map +1 -1
  17. package/dist/runtime/slots/widget/iframe/IFrameWidget.js.map +1 -1
  18. package/dist/runtime/slots/widget/iframe/hooks.js.map +1 -1
  19. package/dist/runtime/slots/widget/iframe/types.js.map +1 -1
  20. package/dist/runtime/slots/widget/types.js.map +1 -1
  21. package/dist/runtime/testing/initializeMockApp.js.map +1 -1
  22. package/dist/shell/Logo.js.map +1 -1
  23. package/dist/shell/dev/devHeader/BarContext.js.map +1 -1
  24. package/dist/shell/dev/devHeader/BarProvider.js.map +1 -1
  25. package/dist/shell/dev/devHeader/FooContext.js.map +1 -1
  26. package/dist/shell/dev/devHeader/FooProvider.js.map +1 -1
  27. package/dist/shell/dev/slotShowcase/SlotShowcasePage.js.map +1 -1
  28. package/dist/shell/dev/slotShowcase/app.js.map +1 -1
  29. package/dist/shell/footer/CopyrightNotice.js.map +1 -1
  30. package/dist/shell/footer/LanguageMenuItem.js.map +1 -1
  31. package/dist/shell/header/AuthenticatedMenu.js.map +1 -1
  32. package/dist/shell/header/HelpButton.js.map +1 -1
  33. package/dist/shell/header/anonymous-menu/AnonymousMenu.js.map +1 -1
  34. package/dist/shell/header/course-bar/data/service.js.map +1 -1
  35. package/dist/shell/header/course-bar/masquerade/StudioLink.js.map +1 -1
  36. package/dist/shell/header/course-bar/masquerade/data/api.js.map +1 -1
  37. package/dist/shell/header/course-bar/masquerade/hooks.js.map +1 -1
  38. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.js.map +1 -1
  39. package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.js.map +1 -1
  40. package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.js.map +1 -1
  41. package/dist/shell/header/helpButtonSlotOperation.js.map +1 -1
  42. package/dist/shell/menus/LinkMenuItem.js.map +1 -1
  43. package/dist/shell/menus/NavDropdownMenuSlot.js.map +1 -1
  44. package/dist/shell/menus/ProfileLinkMenuItem.js.map +1 -1
  45. package/dist/tools/eslint/base.eslint.config.js +2 -2
  46. package/dist/types.js.map +1 -1
  47. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../runtime/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;;;;;;;;;;;;AAEH,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAGL,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE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;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;;IAC5C,wCAAwC;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAA,aAAa,EAAE,CAAC,wBAAwB,mCAAI,EAAE,CAAC;IAC1E,OAAO,MAAA,kBAAkB,CAAC,GAAG,CAAC,mCAAI,GAAG,CAAC;AACxC,CAAC","sourcesContent":["/**\n * #### Import members from **@edx/frontend-base**\n *\n * The configuration module provides utilities for working with an application's configuration\n * document (SiteConfig). Configuration variables can be supplied to the\n * application in three different ways. They are applied in the following order:\n *\n * - Site Configuration File (site.config.tsx)\n * - Initialization Config Handler\n * - Runtime Configuration\n *\n * Last one in wins, and are deep merged together. Variables with the same name defined via the\n * later methods will override any defined using an earlier method. i.e., if a variable is defined\n * in Runtime Configuration, that will override the same variable defined in either of the earlier\n * methods. Configuration defined in a JS file will override any default values below.\n *\n * ##### Site Configuration File\n *\n * Configuration variables can be supplied in a file named site.config.tsx. This file must\n * export either an Object containing configuration variables or a function. The function must\n * return an Object containing configuration variables or, alternately, a promise which resolves to\n * an Object.\n *\n * Using a function or async function allows the configuration to be resolved at runtime (because\n * the function will be executed at runtime). This is not common, and the capability is included\n * for the sake of flexibility.\n *\n * The Site Configuration File is well-suited to extensibility use cases or component overrides,\n * in that the configuration file can depend on any installed JavaScript module. It is also the\n * preferred way of doing build-time configuration if runtime configuration isn't used by your\n * deployment of the platform.\n *\n * Exporting a config object:\n * ```\n * const siteConfig = {\n * lmsBaseUrl: 'http://localhost:18000'\n * };\n *\n * export default siteConfig;\n * ```\n *\n * Exporting a function that returns an object:\n * ```\n * function getSiteConfig() {\n * return {\n * lmsBaseUrl: 'http://localhost:18000'\n * };\n * }\n * ```\n *\n * Exporting a function that returns a promise that resolves to an object:\n * ```\n * function getAsyncSiteConfig() {\n * return new Promise((resolve, reject) => {\n * resolve({\n * lmsBaseUrl: 'http://localhost:18000'\n * });\n * });\n * }\n *\n * export default getAsyncSiteConfig;\n * ```\n *\n * ##### Initialization Config Handler\n *\n * The configuration document can be extended by\n * applications at run-time using a `config` initialization handler. Please see the Initialization\n * documentation for more information on handlers and initialization phases.\n *\n * ```\n * initialize({\n * handlers: {\n * config: () => {\n * mergeSiteConfig({\n * CUSTOM_VARIABLE: 'custom value',\n * lmsBaseUrl: 'http://localhost:18001' // You can override variables, but this is uncommon.\n * }, 'App config override handler');\n * },\n * },\n * });\n * ```\n *\n * ##### Runtime Configuration\n *\n * Configuration variables can also be supplied using the \"runtime configuration\" method, taking\n * advantage of the Micro-frontend Config API in edx-platform. More information on this API can be\n * found in the ADR which introduced it:\n *\n * https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/mfe_config_api/docs/decisions/0001-mfe-config-api.rst\n *\n * The runtime configuration method can be enabled by supplying a runtimeConfigJsonUrl via one of the other\n * two configuration methods above.\n *\n * Runtime configuration is particularly useful if you need to supply different configurations to\n * a single deployment of a micro-frontend, for instance. It is also a perfectly valid alternative\n * to build-time configuration, though it introduces an additional API call to edx-platform on MFE\n * initialization.\n *\n *\n * @module Config\n */\n\nimport isEqual from 'lodash/isEqual';\nimport keyBy from 'lodash/keyBy';\nimport merge from 'lodash/merge';\nimport {\n App,\n AppConfig,\n EnvironmentTypes,\n SiteConfig\n} from '../../types';\nimport { ACTIVE_ROLES_CHANGED, CONFIG_CHANGED } from '../constants';\nimport { publish } from '../subscriptions';\n\nlet siteConfig: SiteConfig = {\n // Required\n siteId: '',\n baseUrl: '',\n siteName: '',\n loginUrl: '',\n logoutUrl: '',\n lmsBaseUrl: '',\n\n // Optional\n environment: EnvironmentTypes.PRODUCTION,\n cmsBaseUrl: '',\n apps: [],\n externalRoutes: [],\n externalLinkUrlOverrides: [],\n runtimeConfigJsonUrl: null,\n theme: {},\n accessTokenCookieName: 'edx-jwt-cookie-header-payload',\n csrfTokenApiPath: '/csrf/api/v1/token',\n ignoredErrorRegex: null,\n languagePreferenceCookieName: 'openedx-language-preference',\n refreshAccessTokenApiPath: '/login_refresh',\n userInfoCookieName: 'edx-user-info',\n segmentKey: null,\n};\n\n/**\n * Getter for the application configuration document. This is synchronous and merely returns a\n * reference to an existing object, and is thus safe to call as often as desired.\n *\n * Example:\n *\n * ```\n * import { getSiteConfig } from '@openedx/frontend-base';\n *\n * const {\n * lmsBaseUrl,\n * } = getSiteConfig();\n * ```\n *\n * @returns {SiteConfig}\n */\nexport function getSiteConfig() {\n return siteConfig;\n}\n\n/**\n * Replaces the existing SiteConfig. This is not commonly used, but can be helpful for tests.\n *\n * Example:\n *\n * ```\n * import { setSiteConfig } from '@openedx/frontend-base';\n *\n * setSiteConfig({\n * lmsBaseUrl, // This is overriding the ENTIRE document - this is not merged in!\n * });\n * ```\n *\n * @param newConfig A replacement SiteConfig which will completely override the current SiteConfig.\n */\nexport function setSiteConfig(newSiteConfig: SiteConfig) {\n siteConfig = newSiteConfig;\n publish(CONFIG_CHANGED);\n}\n\ninterface MergeSiteConfigOptions {\n limitAppMergeToConfig?: boolean,\n}\n\n/**\n * Merges additional configuration values into the site config returned by `getSiteConfig`. Will\n * override any values that exist with the same keys.\n *\n * ```\n * mergeSiteConfig({\n * NEW_KEY: 'new value',\n * OTHER_NEW_KEY: 'other new value',\n * });\n *\n * This function uses lodash.merge internally to merge configuration objects\n * which means they will be merged recursively. See https://lodash.com/docs/latest#merge for\n * documentation on the exact behavior.\n *\n * Apps are merged by appId rather than array index. By default, apps in the incoming config\n * that don't exist in the current config will be added.\n *\n * When `limitAppMergeToConfig` is true:\n * - All non-app parts of the config are still merged normally\n * - Only the `config` property of each existing app is merged\n * - Apps in the incoming config that don't exist in the current config are ignored\n *\n * @param {Object} newSiteConfig\n * @param {Object} options\n * @param {boolean} options.limitAppMergeToConfig - Limit app merging to only the config property of existing apps\n */\nexport function mergeSiteConfig(\n newSiteConfig: Partial<SiteConfig>,\n options: MergeSiteConfigOptions = {}\n) {\n const { limitAppMergeToConfig = false } = options;\n const { apps: newApps, ...restOfNewConfig } = newSiteConfig;\n\n /* `merge({}, ...)` deep-clones into the fresh target, so the new `siteConfig`\n is a brand-new reference and the previous one is never mutated. This is what\n lets React consumers detect that CONFIG_CHANGED actually changed something. */\n siteConfig = merge({}, siteConfig, restOfNewConfig);\n\n // if we don't have new apps, we're done\n if (!newApps?.length) {\n publish(CONFIG_CHANGED);\n return;\n }\n\n // if we're doing a full merge, merge the objects\n if (!limitAppMergeToConfig) {\n siteConfig.apps = mergeApps(siteConfig.apps || [], newApps);\n publish(CONFIG_CHANGED);\n return;\n }\n\n // we're doing a config-only merge, if we don't\n // have apps already, we can't update their configs\n if (!siteConfig.apps?.length) {\n publish(CONFIG_CHANGED);\n return;\n }\n\n // handle config-only merging\n siteConfig.apps = mergeApps(siteConfig.apps, newApps, { configOnly: true });\n\n publish(CONFIG_CHANGED);\n}\n\n/*\n * Merge two App[] by appId. Existing apps stay in their original positions\n * (with their pair-merged counterpart from `newApps` substituted in when\n * present); apps in `newApps` not already in `oldApps` append at the end.\n * With `{ configOnly: true }`, no apps are added and apps not appearing in\n * `newApps` pass through unchanged. Per-pair merging is delegated to\n * `mergeApp`.\n */\nfunction mergeApps(\n oldApps: App[],\n newApps: App[],\n options: { configOnly?: boolean } = {},\n): App[] {\n const incomingByAppId = keyBy(newApps, 'appId');\n\n // Phase 1: walk existing apps in their original order, pair-merging any\n // that have a counterpart in newApps.\n const updatedExisting = oldApps.map((oldApp) => {\n const newApp = incomingByAppId[oldApp.appId];\n return newApp ? mergeApp(oldApp, newApp, options) : oldApp;\n });\n\n // configOnly mode never adds apps, so we're done.\n if (options.configOnly) {\n return updatedExisting;\n }\n\n // Phase 2: append apps from newApps that weren't already in oldApps.\n const existingIds = new Set(oldApps.map((a) => a.appId));\n const additions = newApps.filter((a) => !existingIds.has(a.appId));\n return [...updatedExisting, ...additions];\n}\n\n/*\n * Merge a pair of Apps with the same appId. Deep-merges `config` (and, in the\n * full-merge case, `provides`); other fields take `newApp`'s value verbatim.\n * The result is built via `Object.getOwnPropertyDescriptors` so any lazy\n * getters survive: a snapshot via `lodash.merge` or spread would invoke the\n * getter at merge time and freeze its return value, which is typically empty\n * mid-init. Per-field replacement is also the only sensible behavior for the\n * array fields (`slots`/`routes`/`providers`/`externalScripts`), which don't\n * survive element-wise merging anyway.\n */\nfunction mergeApp(\n oldApp: App,\n newApp: App,\n options: { configOnly?: boolean } = {},\n): App {\n // configOnly mode: preserve `oldApp` (identity, slots, etc.) and deep-merge\n // only `newApp.config` on top.\n if (options.configOnly) {\n if (!newApp.config) {\n return oldApp;\n }\n return cloneAppDescriptors(oldApp, {\n config: merge({}, oldApp.config, newApp.config),\n });\n }\n\n // Full mode: take `newApp` (identity, slots, etc.) and deep-merge `config`\n // and `provides` from `oldApp`. Other fields take `newApp`'s value verbatim.\n const deepMerged: Record<string, unknown> = {};\n if (oldApp.config !== undefined || newApp.config !== undefined) {\n deepMerged.config = merge({}, oldApp.config, newApp.config);\n }\n if (oldApp.provides !== undefined || newApp.provides !== undefined) {\n deepMerged.provides = merge({}, oldApp.provides, newApp.provides);\n }\n return cloneAppDescriptors(newApp, deepMerged);\n}\n\nfunction cloneAppDescriptors(source: App, overrides: Record<string, unknown>): App {\n const descriptors = Object.getOwnPropertyDescriptors(source);\n for (const [key, value] of Object.entries(overrides)) {\n descriptors[key] = { value, writable: true, enumerable: true, configurable: true };\n }\n return Object.create(Object.getPrototypeOf(source), descriptors) as App;\n}\n\nconst appConfigs: Record<string, AppConfig> = {};\n\n/**\n * addAppConfigs finds any AppConfig objects in the apps in SiteConfig and makes their config\n * available to be used by Apps via getAppConfig(appId) or useAppConfig() functions. This is\n * used at initialization time to process any AppConfigs bundled with the site.\n */\nexport function addAppConfigs() {\n const { apps } = getSiteConfig();\n if (!apps) return;\n\n for (const app of apps) {\n const { appId, config } = app;\n if (config !== undefined) {\n appConfigs[appId] = config;\n }\n }\n\n publish(CONFIG_CHANGED);\n}\n\nexport function getAppConfig(id: string) {\n const { commonAppConfig } = getSiteConfig();\n if (commonAppConfig === undefined) {\n return appConfigs[id];\n }\n return merge({}, commonAppConfig, appConfigs[id]);\n}\n\nexport function mergeAppConfig(id: string, newAppConfig: AppConfig) {\n // Non-mutating: produce a fresh entry so consumers holding a reference to\n // the previous one don't observe the change underneath them.\n appConfigs[id] = merge({}, appConfigs[id], newAppConfig);\n publish(CONFIG_CHANGED);\n}\n\nlet activeRouteRoles: string[] = [];\n\nexport function setActiveRouteRoles(roles: string[]) {\n if (isEqual(activeRouteRoles, roles)) return;\n activeRouteRoles = roles;\n publish(ACTIVE_ROLES_CHANGED);\n}\n\nexport function getActiveRouteRoles() {\n return activeRouteRoles;\n}\n\nconst activeWidgetRoles: Record<string, number> = {};\n\nexport function addActiveWidgetRole(role: string) {\n // Only publish when the role transitions from absent to present.\n const wasPresent = (activeWidgetRoles[role] ?? 0) > 0;\n activeWidgetRoles[role] = (activeWidgetRoles[role] ?? 0) + 1;\n if (!wasPresent) publish(ACTIVE_ROLES_CHANGED);\n}\n\nexport function removeActiveWidgetRole(role: string) {\n if (activeWidgetRoles[role] === undefined) return;\n activeWidgetRoles[role] -= 1;\n if (activeWidgetRoles[role] < 1) {\n delete activeWidgetRoles[role];\n // Only publish when the role transitions from present to absent.\n publish(ACTIVE_ROLES_CHANGED);\n }\n}\n\nexport function getActiveWidgetRoles() {\n return Object.entries(activeWidgetRoles)\n .filter(([, count]: [role: string, count: number]) => count !== undefined && count > 0)\n .map(([role]: [role: string, count: number]) => role);\n}\n\n// Gets all active roles from the route roles and widget roles.\nexport function getActiveRoles() {\n return [...getActiveRouteRoles(), ...getActiveWidgetRoles()];\n}\n\n/**\n * Collects all `provides` entries from registered apps that match the given identifier.\n * This enables inter-app data sharing without frontend-base needing to understand the data shape.\n *\n * @param id - The namespaced provides identifier.\n * @returns An array of provided data from all apps that declared data for this identifier.\n */\nexport function getProvides(id: string): unknown[] {\n const { apps } = getSiteConfig();\n if (!apps) return [];\n\n const results: unknown[] = [];\n for (const app of apps) {\n if (app.provides && app.provides[id] !== undefined) {\n results.push(app.provides[id]);\n }\n }\n return results;\n}\n\n/**\n * Collects and flattens all `provides` entries for the given identifier\n * as strings. Each entry can be a single string or a string array; entries\n * of other types are silently skipped.\n *\n * @param id - The namespaced provides identifier.\n * @returns A flat array of strings from all apps that declared data for this identifier.\n */\nexport function getProvidesAsStrings(id: string): string[] {\n return getProvides(id)\n .filter((data): data is string | string[] => typeof data === 'string' || Array.isArray(data))\n .flat();\n}\n\n/**\n * Get an external link URL based on the URL provided. If the passed in URL is overridden in the\n * `externalLinkUrlOverrides` object, it will return the overridden URL. Otherwise, it will return\n * the provided URL.\n *\n *\n * @param {string} url - The default URL.\n * @returns {string} - The external link URL. Defaults to the input URL if not found in the\n * `externalLinkUrlOverrides` object. If the input URL is invalid, '#' is returned.\n *\n * @example\n * import { getExternalLinkUrl } from '@openedx/frontend-base';\n *\n * <Hyperlink\n * destination={getExternalLinkUrl(data.helpLink)}\n * target=\"_blank\"\n * >\n */\nexport function getExternalLinkUrl(url: string): string {\n // Guard against whitespace-only strings\n if (typeof url !== 'string' || !url.trim()) {\n return '#';\n }\n\n const overriddenLinkUrls = getSiteConfig().externalLinkUrlOverrides ?? {};\n return overriddenLinkUrls[url] ?? url;\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../runtime/config/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoGG;;;;;;;;;;;;AAEH,OAAO,OAAO,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAGL,gBAAgB,EAEjB,MAAM,aAAa,CAAC;AACrB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AC,IAAI,CAAC,CAAC;SAC5F,IAAI,EAAE,CAAC;AACZ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW;;IAC5C,wCAAwC;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC;QAC3C,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM,kBAAkB,GAAG,MAAA,aAAa,EAAE,CAAC,wBAAwB,mCAAI,EAAE,CAAC;IAC1E,OAAO,MAAA,kBAAkB,CAAC,GAAG,CAAC,mCAAI,GAAG,CAAC;AACxC,CAAC","sourcesContent":["/**\n * #### Import members from **@edx/frontend-base**\n *\n * The configuration module provides utilities for working with an application's configuration\n * document (SiteConfig). Configuration variables can be supplied to the\n * application in three different ways. They are applied in the following order:\n *\n * - Site Configuration File (site.config.tsx)\n * - Initialization Config Handler\n * - Runtime Configuration\n *\n * Last one in wins, and are deep merged together. Variables with the same name defined via the\n * later methods will override any defined using an earlier method. i.e., if a variable is defined\n * in Runtime Configuration, that will override the same variable defined in either of the earlier\n * methods. Configuration defined in a JS file will override any default values below.\n *\n * ##### Site Configuration File\n *\n * Configuration variables can be supplied in a file named site.config.tsx. This file must\n * export either an Object containing configuration variables or a function. The function must\n * return an Object containing configuration variables or, alternately, a promise which resolves to\n * an Object.\n *\n * Using a function or async function allows the configuration to be resolved at runtime (because\n * the function will be executed at runtime). This is not common, and the capability is included\n * for the sake of flexibility.\n *\n * The Site Configuration File is well-suited to extensibility use cases or component overrides,\n * in that the configuration file can depend on any installed JavaScript module. It is also the\n * preferred way of doing build-time configuration if runtime configuration isn't used by your\n * deployment of the platform.\n *\n * Exporting a config object:\n * ```\n * const siteConfig = {\n * lmsBaseUrl: 'http://localhost:18000'\n * };\n *\n * export default siteConfig;\n * ```\n *\n * Exporting a function that returns an object:\n * ```\n * function getSiteConfig() {\n * return {\n * lmsBaseUrl: 'http://localhost:18000'\n * };\n * }\n * ```\n *\n * Exporting a function that returns a promise that resolves to an object:\n * ```\n * function getAsyncSiteConfig() {\n * return new Promise((resolve, reject) => {\n * resolve({\n * lmsBaseUrl: 'http://localhost:18000'\n * });\n * });\n * }\n *\n * export default getAsyncSiteConfig;\n * ```\n *\n * ##### Initialization Config Handler\n *\n * The configuration document can be extended by\n * applications at run-time using a `config` initialization handler. Please see the Initialization\n * documentation for more information on handlers and initialization phases.\n *\n * ```\n * initialize({\n * handlers: {\n * config: () => {\n * mergeSiteConfig({\n * CUSTOM_VARIABLE: 'custom value',\n * lmsBaseUrl: 'http://localhost:18001' // You can override variables, but this is uncommon.\n * }, 'App config override handler');\n * },\n * },\n * });\n * ```\n *\n * ##### Runtime Configuration\n *\n * Configuration variables can also be supplied using the \"runtime configuration\" method, taking\n * advantage of the Micro-frontend Config API in edx-platform. More information on this API can be\n * found in the ADR which introduced it:\n *\n * https://github.com/openedx/edx-platform/blob/master/lms/djangoapps/mfe_config_api/docs/decisions/0001-mfe-config-api.rst\n *\n * The runtime configuration method can be enabled by supplying a runtimeConfigJsonUrl via one of the other\n * two configuration methods above.\n *\n * Runtime configuration is particularly useful if you need to supply different configurations to\n * a single deployment of a micro-frontend, for instance. It is also a perfectly valid alternative\n * to build-time configuration, though it introduces an additional API call to edx-platform on MFE\n * initialization.\n *\n *\n * @module Config\n */\n\nimport isEqual from 'lodash/isEqual';\nimport keyBy from 'lodash/keyBy';\nimport merge from 'lodash/merge';\nimport {\n App,\n AppConfig,\n EnvironmentTypes,\n SiteConfig\n} from '../../types';\nimport { ACTIVE_ROLES_CHANGED, CONFIG_CHANGED } from '../constants';\nimport { publish } from '../subscriptions';\n\nlet siteConfig: SiteConfig = {\n // Required\n siteId: '',\n baseUrl: '',\n siteName: '',\n loginUrl: '',\n logoutUrl: '',\n lmsBaseUrl: '',\n\n // Optional\n environment: EnvironmentTypes.PRODUCTION,\n cmsBaseUrl: '',\n apps: [],\n externalRoutes: [],\n externalLinkUrlOverrides: [],\n runtimeConfigJsonUrl: null,\n theme: {},\n accessTokenCookieName: 'edx-jwt-cookie-header-payload',\n csrfTokenApiPath: '/csrf/api/v1/token',\n ignoredErrorRegex: null,\n languagePreferenceCookieName: 'openedx-language-preference',\n refreshAccessTokenApiPath: '/login_refresh',\n userInfoCookieName: 'edx-user-info',\n segmentKey: null,\n};\n\n/**\n * Getter for the application configuration document. This is synchronous and merely returns a\n * reference to an existing object, and is thus safe to call as often as desired.\n *\n * Example:\n *\n * ```\n * import { getSiteConfig } from '@openedx/frontend-base';\n *\n * const {\n * lmsBaseUrl,\n * } = getSiteConfig();\n * ```\n *\n * @returns {SiteConfig}\n */\nexport function getSiteConfig() {\n return siteConfig;\n}\n\n/**\n * Replaces the existing SiteConfig. This is not commonly used, but can be helpful for tests.\n *\n * Example:\n *\n * ```\n * import { setSiteConfig } from '@openedx/frontend-base';\n *\n * setSiteConfig({\n * lmsBaseUrl, // This is overriding the ENTIRE document - this is not merged in!\n * });\n * ```\n *\n * @param newConfig A replacement SiteConfig which will completely override the current SiteConfig.\n */\nexport function setSiteConfig(newSiteConfig: SiteConfig) {\n siteConfig = newSiteConfig;\n publish(CONFIG_CHANGED);\n}\n\ninterface MergeSiteConfigOptions {\n limitAppMergeToConfig?: boolean;\n}\n\n/**\n * Merges additional configuration values into the site config returned by `getSiteConfig`. Will\n * override any values that exist with the same keys.\n *\n * ```\n * mergeSiteConfig({\n * NEW_KEY: 'new value',\n * OTHER_NEW_KEY: 'other new value',\n * });\n *\n * This function uses lodash.merge internally to merge configuration objects\n * which means they will be merged recursively. See https://lodash.com/docs/latest#merge for\n * documentation on the exact behavior.\n *\n * Apps are merged by appId rather than array index. By default, apps in the incoming config\n * that don't exist in the current config will be added.\n *\n * When `limitAppMergeToConfig` is true:\n * - All non-app parts of the config are still merged normally\n * - Only the `config` property of each existing app is merged\n * - Apps in the incoming config that don't exist in the current config are ignored\n *\n * @param {Object} newSiteConfig\n * @param {Object} options\n * @param {boolean} options.limitAppMergeToConfig - Limit app merging to only the config property of existing apps\n */\nexport function mergeSiteConfig(\n newSiteConfig: Partial<SiteConfig>,\n options: MergeSiteConfigOptions = {}\n) {\n const { limitAppMergeToConfig = false } = options;\n const { apps: newApps, ...restOfNewConfig } = newSiteConfig;\n\n /* `merge({}, ...)` deep-clones into the fresh target, so the new `siteConfig`\n is a brand-new reference and the previous one is never mutated. This is what\n lets React consumers detect that CONFIG_CHANGED actually changed something. */\n siteConfig = merge({}, siteConfig, restOfNewConfig);\n\n // if we don't have new apps, we're done\n if (!newApps?.length) {\n publish(CONFIG_CHANGED);\n return;\n }\n\n // if we're doing a full merge, merge the objects\n if (!limitAppMergeToConfig) {\n siteConfig.apps = mergeApps(siteConfig.apps || [], newApps);\n publish(CONFIG_CHANGED);\n return;\n }\n\n // we're doing a config-only merge, if we don't\n // have apps already, we can't update their configs\n if (!siteConfig.apps?.length) {\n publish(CONFIG_CHANGED);\n return;\n }\n\n // handle config-only merging\n siteConfig.apps = mergeApps(siteConfig.apps, newApps, { configOnly: true });\n\n publish(CONFIG_CHANGED);\n}\n\n/*\n * Merge two App[] by appId. Existing apps stay in their original positions\n * (with their pair-merged counterpart from `newApps` substituted in when\n * present); apps in `newApps` not already in `oldApps` append at the end.\n * With `{ configOnly: true }`, no apps are added and apps not appearing in\n * `newApps` pass through unchanged. Per-pair merging is delegated to\n * `mergeApp`.\n */\nfunction mergeApps(\n oldApps: App[],\n newApps: App[],\n options: { configOnly?: boolean } = {},\n): App[] {\n const incomingByAppId = keyBy(newApps, 'appId');\n\n // Phase 1: walk existing apps in their original order, pair-merging any\n // that have a counterpart in newApps.\n const updatedExisting = oldApps.map((oldApp) => {\n const newApp = incomingByAppId[oldApp.appId];\n return newApp ? mergeApp(oldApp, newApp, options) : oldApp;\n });\n\n // configOnly mode never adds apps, so we're done.\n if (options.configOnly) {\n return updatedExisting;\n }\n\n // Phase 2: append apps from newApps that weren't already in oldApps.\n const existingIds = new Set(oldApps.map((a) => a.appId));\n const additions = newApps.filter((a) => !existingIds.has(a.appId));\n return [...updatedExisting, ...additions];\n}\n\n/*\n * Merge a pair of Apps with the same appId. Deep-merges `config` (and, in the\n * full-merge case, `provides`); other fields take `newApp`'s value verbatim.\n * The result is built via `Object.getOwnPropertyDescriptors` so any lazy\n * getters survive: a snapshot via `lodash.merge` or spread would invoke the\n * getter at merge time and freeze its return value, which is typically empty\n * mid-init. Per-field replacement is also the only sensible behavior for the\n * array fields (`slots`/`routes`/`providers`/`externalScripts`), which don't\n * survive element-wise merging anyway.\n */\nfunction mergeApp(\n oldApp: App,\n newApp: App,\n options: { configOnly?: boolean } = {},\n): App {\n // configOnly mode: preserve `oldApp` (identity, slots, etc.) and deep-merge\n // only `newApp.config` on top.\n if (options.configOnly) {\n if (!newApp.config) {\n return oldApp;\n }\n return cloneAppDescriptors(oldApp, {\n config: merge({}, oldApp.config, newApp.config),\n });\n }\n\n // Full mode: take `newApp` (identity, slots, etc.) and deep-merge `config`\n // and `provides` from `oldApp`. Other fields take `newApp`'s value verbatim.\n const deepMerged: Record<string, unknown> = {};\n if (oldApp.config !== undefined || newApp.config !== undefined) {\n deepMerged.config = merge({}, oldApp.config, newApp.config);\n }\n if (oldApp.provides !== undefined || newApp.provides !== undefined) {\n deepMerged.provides = merge({}, oldApp.provides, newApp.provides);\n }\n return cloneAppDescriptors(newApp, deepMerged);\n}\n\nfunction cloneAppDescriptors(source: App, overrides: Record<string, unknown>): App {\n const descriptors = Object.getOwnPropertyDescriptors(source);\n for (const [key, value] of Object.entries(overrides)) {\n descriptors[key] = { value, writable: true, enumerable: true, configurable: true };\n }\n return Object.create(Object.getPrototypeOf(source), descriptors) as App;\n}\n\nconst appConfigs: Record<string, AppConfig> = {};\n\n/**\n * addAppConfigs finds any AppConfig objects in the apps in SiteConfig and makes their config\n * available to be used by Apps via getAppConfig(appId) or useAppConfig() functions. This is\n * used at initialization time to process any AppConfigs bundled with the site.\n */\nexport function addAppConfigs() {\n const { apps } = getSiteConfig();\n if (!apps) return;\n\n for (const app of apps) {\n const { appId, config } = app;\n if (config !== undefined) {\n appConfigs[appId] = config;\n }\n }\n\n publish(CONFIG_CHANGED);\n}\n\nexport function getAppConfig(id: string) {\n const { commonAppConfig } = getSiteConfig();\n if (commonAppConfig === undefined) {\n return appConfigs[id];\n }\n return merge({}, commonAppConfig, appConfigs[id]);\n}\n\nexport function mergeAppConfig(id: string, newAppConfig: AppConfig) {\n // Non-mutating: produce a fresh entry so consumers holding a reference to\n // the previous one don't observe the change underneath them.\n appConfigs[id] = merge({}, appConfigs[id], newAppConfig);\n publish(CONFIG_CHANGED);\n}\n\nlet activeRouteRoles: string[] = [];\n\nexport function setActiveRouteRoles(roles: string[]) {\n if (isEqual(activeRouteRoles, roles)) return;\n activeRouteRoles = roles;\n publish(ACTIVE_ROLES_CHANGED);\n}\n\nexport function getActiveRouteRoles() {\n return activeRouteRoles;\n}\n\nconst activeWidgetRoles: Record<string, number> = {};\n\nexport function addActiveWidgetRole(role: string) {\n // Only publish when the role transitions from absent to present.\n const wasPresent = (activeWidgetRoles[role] ?? 0) > 0;\n activeWidgetRoles[role] = (activeWidgetRoles[role] ?? 0) + 1;\n if (!wasPresent) publish(ACTIVE_ROLES_CHANGED);\n}\n\nexport function removeActiveWidgetRole(role: string) {\n if (activeWidgetRoles[role] === undefined) return;\n activeWidgetRoles[role] -= 1;\n if (activeWidgetRoles[role] < 1) {\n delete activeWidgetRoles[role];\n // Only publish when the role transitions from present to absent.\n publish(ACTIVE_ROLES_CHANGED);\n }\n}\n\nexport function getActiveWidgetRoles() {\n return Object.entries(activeWidgetRoles)\n .filter(([, count]: [role: string, count: number]) => count !== undefined && count > 0)\n .map(([role]: [role: string, count: number]) => role);\n}\n\n// Gets all active roles from the route roles and widget roles.\nexport function getActiveRoles() {\n return [...getActiveRouteRoles(), ...getActiveWidgetRoles()];\n}\n\n/**\n * Collects all `provides` entries from registered apps that match the given identifier.\n * This enables inter-app data sharing without frontend-base needing to understand the data shape.\n *\n * @param id - The namespaced provides identifier.\n * @returns An array of provided data from all apps that declared data for this identifier.\n */\nexport function getProvides(id: string): unknown[] {\n const { apps } = getSiteConfig();\n if (!apps) return [];\n\n const results: unknown[] = [];\n for (const app of apps) {\n if (app.provides && app.provides[id] !== undefined) {\n results.push(app.provides[id]);\n }\n }\n return results;\n}\n\n/**\n * Collects and flattens all `provides` entries for the given identifier\n * as strings. Each entry can be a single string or a string array; entries\n * of other types are silently skipped.\n *\n * @param id - The namespaced provides identifier.\n * @returns A flat array of strings from all apps that declared data for this identifier.\n */\nexport function getProvidesAsStrings(id: string): string[] {\n return getProvides(id)\n .filter((data): data is string | string[] => typeof data === 'string' || Array.isArray(data))\n .flat();\n}\n\n/**\n * Get an external link URL based on the URL provided. If the passed in URL is overridden in the\n * `externalLinkUrlOverrides` object, it will return the overridden URL. Otherwise, it will return\n * the provided URL.\n *\n *\n * @param {string} url - The default URL.\n * @returns {string} - The external link URL. Defaults to the input URL if not found in the\n * `externalLinkUrlOverrides` object. If the input URL is invalid, '#' is returned.\n *\n * @example\n * import { getExternalLinkUrl } from '@openedx/frontend-base';\n *\n * <Hyperlink\n * destination={getExternalLinkUrl(data.helpLink)}\n * target=\"_blank\"\n * >\n */\nexport function getExternalLinkUrl(url: string): string {\n // Guard against whitespace-only strings\n if (typeof url !== 'string' || !url.trim()) {\n return '#';\n }\n\n const overriddenLinkUrls = getSiteConfig().externalLinkUrlOverrides ?? {};\n return overriddenLinkUrls[url] ?? url;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../runtime/i18n/lib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B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;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,MAAM;IAC1B,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS;IACvB,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC;QACvB,UAAU,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjF,CAAC;SAAM,CAAC;QACN,UAAU,CAAC,QAAQ,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjF,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,WAAW,GAAG,EAAE;IAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAClF,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAEjC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAMD;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IAE/F,SAAS,EAAE,CAAC;AACd,CAAC","sourcesContent":["import merge from 'lodash/merge';\nimport { MessageFormatElement } from 'react-intl';\nimport Cookies from 'universal-cookie';\n\nimport { LocalizedMessages } from '../../types';\nimport { getSiteConfig } from '../config';\nimport { publish } from '../subscriptions';\n\nconst cookies = new Cookies();\n\n// This list is based on https://help.smartling.com/hc/en-us/articles/1260802028830-Right-to-left-RTL-Languages\n// There are very few resources available online outlining the locale codes for RTL languages;\n// If this list is inaccurate, we should change it.\nconst rtlLocales = [\n 'ar', // Arabic (International)\n 'ar-ae', // Arabic (United Arab Emirates)\n 'ar-bh', // Arabic (Bahrain)\n 'ar-dj', // Arabic (Djibouti)\n 'ar-dz', // Arabic (Algeria)\n 'ar-eg', // Arabic (Egypt)\n 'ar-iq', // Arabic (Iraq)\n 'ar-jo', // Arabic (Jordan)\n 'ar-kw', // Arabic (Kuwait)\n 'ar-lb', // Arabic (Lebanon)\n 'ar-ly', // Arabic (Libya)\n 'ar-ma', // Arabic (Morocco)\n 'ar-om', // Arabic (Oman)\n 'ar-qa', // Arabic (Qatar)\n 'ar-sa', // Arabic (Saudi Arabia)\n 'ar-sd', // Arabic (Sudan)\n 'ar-sy', // Arabic (Syria)\n 'ar-tn', // Arabic (Tunisia)\n 'ar-ye', // Arabic (Yemen)\n 'fa', // Persian\n 'fa-af', // Dari/Persian (Afghanistan)\n 'fa-ir', // Persian (Iran)\n 'he', // Hebrew (he)\n 'he-il', // Hebrew\n 'iw', // Hebrew (iw)\n 'kd', // Kurdish (Sorani) RTL\n 'pk-pk', // Panjabi-Shahmuki (Pakistan)\n 'ps', // Pushto; Pashto\n 'ug', // Uighur; Uyghur\n 'ur', // Urdu\n 'ur-in', // Urdu (India)\n 'ur-pk', // Urdu (Pakistan)\n 'yi', // Yiddish\n 'yi-us', // Yiddish (United States)\n];\n\nlet messages: Record<string, Record<string, string> | Record<string, MessageFormatElement[]> | undefined>;\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_TOPIC = 'LOCALE';\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_CHANGED = `${LOCALE_TOPIC}.CHANGED`;\n\n/**\n *\n * @memberof module:Internationalization\n * @returns {Cookies}\n */\nexport function getCookies() {\n return cookies;\n}\n\n/**\n * Some of our dependencies function on primary language subtags, rather than full locales.\n * This function strips a locale down to that first subtag. Depending on the code, this\n * may be 2 or more characters.\n *\n * @param {string} code\n * @memberof module:Internationalization\n */\nexport function getPrimaryLanguageSubtag(code) {\n return code.split('-')[0];\n}\n\n/**\n * Finds the closest supported locale to the one provided. This is done in three steps:\n *\n * 1. Returning the locale itself if its exact language code is supported.\n * 2. Returning the primary language subtag of the language code if it is supported (ar for ar-eg,\n * for instance).\n * 3. Returning 'en' if neither of the above produce a supported locale.\n *\n * @param {string} locale\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function findSupportedLocale(locale) {\n if (messages === undefined) {\n throw new Error('findSupportedLocale called before configuring i18n. Call configureI18n with messages first.');\n }\n\n if (messages[locale] !== undefined) {\n return locale;\n }\n\n if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {\n return getPrimaryLanguageSubtag(locale);\n }\n\n return 'en';\n}\n\n/**\n * Get the locale from the cookie or, failing that, the browser setting.\n * Gracefully fall back to a more general primary language subtag or to English (en)\n * if we don't support that language.\n *\n * @param {string|undefined} locale If a locale is provided, returns the closest supported locale. Optional.\n * @throws An error if i18n has not yet been configured.\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function getLocale(locale?: string) {\n if (messages === null) {\n throw new Error('getLocale called before configuring i18n. Call configureI18n with messages first.');\n }\n\n // 1. Explicit application request\n if (locale !== undefined) {\n return findSupportedLocale(locale);\n }\n // 2. User setting in cookie\n\n const { languagePreferenceCookieName } = getSiteConfig();\n if (languagePreferenceCookieName) {\n const languagePreference = cookies.get(languagePreferenceCookieName);\n if (languagePreference) {\n return findSupportedLocale(languagePreference.toLowerCase());\n }\n }\n\n // 3. Browser language (default)\n // Note that some browers prefer upper case for the region part of the locale, while others don't.\n // Thus the toLowerCase, for consistency.\n // https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language\n return findSupportedLocale(globalThis.navigator.language.toLowerCase());\n}\n\nexport function getLocalizedLanguageName(locale) {\n const localizedName = (new Intl.DisplayNames([locale], { type: 'language' })).of(locale);\n\n if (localizedName === undefined) {\n throw new Error(`Unsupported locale: ${locale}`);\n }\n\n return `${localizedName.charAt(0).toLocaleUpperCase(locale)}${localizedName.slice(1)}`;\n}\n\nexport function getSupportedLanguageList() {\n const locales = Object.keys(messages);\n locales.push('en'); // 'en' is not in the messages object because it's the default.\n locales.sort();\n\n return locales.map((locale) => ({\n code: locale,\n name: getLocalizedLanguageName(locale),\n }));\n}\n\nexport function updateLocale() {\n handleRtl();\n publish(LOCALE_CHANGED);\n}\n\n/**\n * Returns messages for the provided locale, or the user's preferred locale if no argument is\n * provided.\n *\n * @param {string} [locale=getLocale()]\n * @memberof module:Internationalization\n */\nexport function getMessages(locale = getLocale()) {\n if (messages === undefined) {\n throw new Error('getMessages called before configuring i18n. Call configureI18n with messages first.');\n }\n\n return messages[locale];\n}\n\n/**\n * Determines if the provided locale is a right-to-left language.\n *\n * @param {string} locale\n * @memberof module:Internationalization\n */\nexport function isRtl(locale) {\n return rtlLocales.includes(locale);\n}\n\n/**\n * Handles applying the RTL stylesheet and \"dir=rtl\" attribute to the html tag if the current locale\n * is a RTL language.\n *\n * @memberof module:Internationalization\n */\nexport function handleRtl() {\n if (isRtl(getLocale())) {\n globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');\n } else {\n globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');\n }\n}\n\n/**\n *\n *\n * @param {Object} newMessages\n * @returns {Object}\n * @memberof module:Internationalization\n */\nexport function mergeMessages(newMessages = {}) {\n const msgs = Array.isArray(newMessages) ? merge({}, ...newMessages) : newMessages;\n messages = merge(messages, msgs);\n\n return messages;\n}\n\ninterface ConfigureI18nOptions {\n messages: LocalizedMessages[] | LocalizedMessages,\n}\n\n/**\n * Configures the i18n library with messages for your application.\n *\n * Logs a warning if it detects a locale it doesn't expect (as defined by the supportedLocales list\n * above), or if an expected locale is not provided.\n *\n * @param {Object} options\n * @param {Object} options.messages\n * @memberof module:Internationalization\n */\nexport function configureI18n(options: ConfigureI18nOptions) {\n messages = Array.isArray(options.messages) ? merge({}, ...options.messages) : options.messages;\n\n handleRtl();\n}\n"]}
1
+ {"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../runtime/i18n/lib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AAEjC,OAAO,OAAO,MAAM,kBAAkB,CAAC;AAGvC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,+GAA+G;AAC/G,8FAA8F;AAC9F,mDAAmD;AACnD,MAAM,UAAU,GAAG;IACjB,IAAI,EAAE,yBAAyB;IAC/B,OAAO,EAAE,gCAAgC;IACzC,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,oBAAoB;IAC7B,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,gBAAgB;IACzB,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,gBAAgB;IACzB,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,wBAAwB;IACjC,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,iBAAiB;IAC1B,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,6BAA6B;IACtC,OAAO,EAAE,iBAAiB;IAC1B,IAAI,EAAE,cAAc;IACpB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,cAAc;IACpB,IAAI,EAAE,uBAAuB;IAC7B,OAAO,EAAE,8BAA8B;IACvC,IAAI,EAAE,iBAAiB;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AMD;;;;;;;;;GASG;AACH,MAAM,UAAU,aAAa,CAAC,OAA6B;IACzD,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IAE/F,SAAS,EAAE,CAAC;AACd,CAAC","sourcesContent":["import merge from 'lodash/merge';\nimport { MessageFormatElement } from 'react-intl';\nimport Cookies from 'universal-cookie';\n\nimport { LocalizedMessages } from '../../types';\nimport { getSiteConfig } from '../config';\nimport { publish } from '../subscriptions';\n\nconst cookies = new Cookies();\n\n// This list is based on https://help.smartling.com/hc/en-us/articles/1260802028830-Right-to-left-RTL-Languages\n// There are very few resources available online outlining the locale codes for RTL languages;\n// If this list is inaccurate, we should change it.\nconst rtlLocales = [\n 'ar', // Arabic (International)\n 'ar-ae', // Arabic (United Arab Emirates)\n 'ar-bh', // Arabic (Bahrain)\n 'ar-dj', // Arabic (Djibouti)\n 'ar-dz', // Arabic (Algeria)\n 'ar-eg', // Arabic (Egypt)\n 'ar-iq', // Arabic (Iraq)\n 'ar-jo', // Arabic (Jordan)\n 'ar-kw', // Arabic (Kuwait)\n 'ar-lb', // Arabic (Lebanon)\n 'ar-ly', // Arabic (Libya)\n 'ar-ma', // Arabic (Morocco)\n 'ar-om', // Arabic (Oman)\n 'ar-qa', // Arabic (Qatar)\n 'ar-sa', // Arabic (Saudi Arabia)\n 'ar-sd', // Arabic (Sudan)\n 'ar-sy', // Arabic (Syria)\n 'ar-tn', // Arabic (Tunisia)\n 'ar-ye', // Arabic (Yemen)\n 'fa', // Persian\n 'fa-af', // Dari/Persian (Afghanistan)\n 'fa-ir', // Persian (Iran)\n 'he', // Hebrew (he)\n 'he-il', // Hebrew\n 'iw', // Hebrew (iw)\n 'kd', // Kurdish (Sorani) RTL\n 'pk-pk', // Panjabi-Shahmuki (Pakistan)\n 'ps', // Pushto; Pashto\n 'ug', // Uighur; Uyghur\n 'ur', // Urdu\n 'ur-in', // Urdu (India)\n 'ur-pk', // Urdu (Pakistan)\n 'yi', // Yiddish\n 'yi-us', // Yiddish (United States)\n];\n\nlet messages: Record<string, Record<string, string> | Record<string, MessageFormatElement[]> | undefined>;\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_TOPIC = 'LOCALE';\n\n/**\n * @memberof module:Internationalization\n */\nexport const LOCALE_CHANGED = `${LOCALE_TOPIC}.CHANGED`;\n\n/**\n *\n * @memberof module:Internationalization\n * @returns {Cookies}\n */\nexport function getCookies() {\n return cookies;\n}\n\n/**\n * Some of our dependencies function on primary language subtags, rather than full locales.\n * This function strips a locale down to that first subtag. Depending on the code, this\n * may be 2 or more characters.\n *\n * @param {string} code\n * @memberof module:Internationalization\n */\nexport function getPrimaryLanguageSubtag(code) {\n return code.split('-')[0];\n}\n\n/**\n * Finds the closest supported locale to the one provided. This is done in three steps:\n *\n * 1. Returning the locale itself if its exact language code is supported.\n * 2. Returning the primary language subtag of the language code if it is supported (ar for ar-eg,\n * for instance).\n * 3. Returning 'en' if neither of the above produce a supported locale.\n *\n * @param {string} locale\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function findSupportedLocale(locale) {\n if (messages === undefined) {\n throw new Error('findSupportedLocale called before configuring i18n. Call configureI18n with messages first.');\n }\n\n if (messages[locale] !== undefined) {\n return locale;\n }\n\n if (messages[getPrimaryLanguageSubtag(locale)] !== undefined) {\n return getPrimaryLanguageSubtag(locale);\n }\n\n return 'en';\n}\n\n/**\n * Get the locale from the cookie or, failing that, the browser setting.\n * Gracefully fall back to a more general primary language subtag or to English (en)\n * if we don't support that language.\n *\n * @param {string|undefined} locale If a locale is provided, returns the closest supported locale. Optional.\n * @throws An error if i18n has not yet been configured.\n * @returns {string}\n * @memberof module:Internationalization\n */\nexport function getLocale(locale?: string) {\n if (messages === null) {\n throw new Error('getLocale called before configuring i18n. Call configureI18n with messages first.');\n }\n\n // 1. Explicit application request\n if (locale !== undefined) {\n return findSupportedLocale(locale);\n }\n // 2. User setting in cookie\n\n const { languagePreferenceCookieName } = getSiteConfig();\n if (languagePreferenceCookieName) {\n const languagePreference = cookies.get(languagePreferenceCookieName);\n if (languagePreference) {\n return findSupportedLocale(languagePreference.toLowerCase());\n }\n }\n\n // 3. Browser language (default)\n // Note that some browers prefer upper case for the region part of the locale, while others don't.\n // Thus the toLowerCase, for consistency.\n // https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language\n return findSupportedLocale(globalThis.navigator.language.toLowerCase());\n}\n\nexport function getLocalizedLanguageName(locale) {\n const localizedName = (new Intl.DisplayNames([locale], { type: 'language' })).of(locale);\n\n if (localizedName === undefined) {\n throw new Error(`Unsupported locale: ${locale}`);\n }\n\n return `${localizedName.charAt(0).toLocaleUpperCase(locale)}${localizedName.slice(1)}`;\n}\n\nexport function getSupportedLanguageList() {\n const locales = Object.keys(messages);\n locales.push('en'); // 'en' is not in the messages object because it's the default.\n locales.sort();\n\n return locales.map((locale) => ({\n code: locale,\n name: getLocalizedLanguageName(locale),\n }));\n}\n\nexport function updateLocale() {\n handleRtl();\n publish(LOCALE_CHANGED);\n}\n\n/**\n * Returns messages for the provided locale, or the user's preferred locale if no argument is\n * provided.\n *\n * @param {string} [locale=getLocale()]\n * @memberof module:Internationalization\n */\nexport function getMessages(locale = getLocale()) {\n if (messages === undefined) {\n throw new Error('getMessages called before configuring i18n. Call configureI18n with messages first.');\n }\n\n return messages[locale];\n}\n\n/**\n * Determines if the provided locale is a right-to-left language.\n *\n * @param {string} locale\n * @memberof module:Internationalization\n */\nexport function isRtl(locale) {\n return rtlLocales.includes(locale);\n}\n\n/**\n * Handles applying the RTL stylesheet and \"dir=rtl\" attribute to the html tag if the current locale\n * is a RTL language.\n *\n * @memberof module:Internationalization\n */\nexport function handleRtl() {\n if (isRtl(getLocale())) {\n globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl');\n } else {\n globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');\n }\n}\n\n/**\n *\n *\n * @param {Object} newMessages\n * @returns {Object}\n * @memberof module:Internationalization\n */\nexport function mergeMessages(newMessages = {}) {\n const msgs = Array.isArray(newMessages) ? merge({}, ...newMessages) : newMessages;\n messages = merge(messages, msgs);\n\n return messages;\n}\n\ninterface ConfigureI18nOptions {\n messages: LocalizedMessages[] | LocalizedMessages;\n}\n\n/**\n * Configures the i18n library with messages for your application.\n *\n * Logs a warning if it detects a locale it doesn't expect (as defined by the supportedLocales list\n * above), or if an expected locale is not provided.\n *\n * @param {Object} options\n * @param {Object} options.messages\n * @memberof module:Internationalization\n */\nexport function configureI18n(options: ConfigureI18nOptions) {\n messages = Array.isArray(options.messages) ? merge({}, ...options.messages) : options.messages;\n\n handleRtl();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../runtime/logging/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface LoggingService {\n logError: (errorStringOrObject: string | Error, customAttributes: any) => void,\n logInfo: (infoStringOrErrorObject: string | Error, customAttributes: any) => void,\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../runtime/logging/types.ts"],"names":[],"mappings":"","sourcesContent":["export interface LoggingService {\n logError: (errorStringOrObject: string | Error, customAttributes: any) => void;\n logInfo: (infoStringOrErrorObject: string | Error, customAttributes: any) => void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CombinedAppProvider.js","sourceRoot":"","sources":["../../../runtime/react/CombinedAppProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,QAAQ,EAA4B;IAChF,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CAAC;IAEjC,MAAM,SAAS,GAAG,OAAO,CAAgB,GAAG,EAAE;QAC5C,MAAM,IAAI,GAAkB,EAAE,CAAC;QAC/B,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;gBACxB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBACjC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,SAAS,CAAC,WAAW,CAC1B,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAC,QAAQ,cAAE,GAAG,GAAY,EAC7C,QAAQ,CACT,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import { ReactNode, useMemo } from 'react';\nimport { App, AppProvider } from '../../types';\nimport { getSiteConfig } from '../config';\n\ninterface CombinedAppProviderProps {\n children: ReactNode,\n}\n\nexport default function CombinedAppProvider({ children }: CombinedAppProviderProps) {\n const { apps } = getSiteConfig();\n\n const providers = useMemo<AppProvider[]>(() => {\n const list: AppProvider[] = [];\n if (apps) {\n apps.forEach((app: App) => {\n if (Array.isArray(app.providers)) {\n list.push(...app.providers);\n }\n });\n }\n return list;\n }, [apps]);\n\n return providers.reduceRight<ReactNode>(\n (acc, Provider) => <Provider>{acc}</Provider>,\n children,\n );\n};\n"]}
1
+ {"version":3,"file":"CombinedAppProvider.js","sourceRoot":"","sources":["../../../runtime/react/CombinedAppProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,MAAM,OAAO,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAM1C,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAAE,QAAQ,EAA4B;IAChF,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CAAC;IAEjC,MAAM,SAAS,GAAG,OAAO,CAAgB,GAAG,EAAE;QAC5C,MAAM,IAAI,GAAkB,EAAE,CAAC;QAC/B,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;gBACxB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;oBACjC,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,SAAS,CAAC,WAAW,CAC1B,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,KAAC,QAAQ,cAAE,GAAG,GAAY,EAC7C,QAAQ,CACT,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import { ReactNode, useMemo } from 'react';\nimport { App, AppProvider } from '../../types';\nimport { getSiteConfig } from '../config';\n\ninterface CombinedAppProviderProps {\n children: ReactNode;\n}\n\nexport default function CombinedAppProvider({ children }: CombinedAppProviderProps) {\n const { apps } = getSiteConfig();\n\n const providers = useMemo<AppProvider[]>(() => {\n const list: AppProvider[] = [];\n if (apps) {\n apps.forEach((app: App) => {\n if (Array.isArray(app.providers)) {\n list.push(...app.providers);\n }\n });\n }\n return list;\n }, [apps]);\n\n return providers.reduceRight<ReactNode>(\n (acc, Provider) => <Provider>{acc}</Provider>,\n children,\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CurrentAppContext.js","sourceRoot":"","sources":["../../../runtime/react/CurrentAppContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC;;;;;;;;;;;;;;GAcG;AACH,MAAM,iBAAiB,GAAG,aAAa,CAEpC;IACD,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,eAAe,iBAAiB,CAAC","sourcesContent":["import { createContext } from 'react';\nimport { AppConfig } from '../../types';\n\n/**\n * `CurrentAppContext` provides data from `App` in a way that React components can readily consume.\n * if it's mutable data. `CurrentAppContext` contains the following data structure:\n *\n * ```\n * {\n * config: <THE App.config OBJECT>\n * }\n * ```\n * If the `App.config` data changes, `CurrentAppContext` will be updated\n * accordingly and pass those changes onto React components using the context.\n *\n * `CurrentAppContext` is used in a React application like any other `[React Context](https://reactjs.org/docs/context.html)\n * @memberof module:React\n */\nconst CurrentAppContext = createContext<{\n appConfig: AppConfig,\n}>({\n appConfig: {},\n});\n\nexport default CurrentAppContext;\n"]}
1
+ {"version":3,"file":"CurrentAppContext.js","sourceRoot":"","sources":["../../../runtime/react/CurrentAppContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC;;;;;;;;;;;;;;GAcG;AACH,MAAM,iBAAiB,GAAG,aAAa,CAEpC;IACD,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,eAAe,iBAAiB,CAAC","sourcesContent":["import { createContext } from 'react';\nimport { AppConfig } from '../../types';\n\n/**\n * `CurrentAppContext` provides data from `App` in a way that React components can readily consume.\n * if it's mutable data. `CurrentAppContext` contains the following data structure:\n *\n * ```\n * {\n * config: <THE App.config OBJECT>\n * }\n * ```\n * If the `App.config` data changes, `CurrentAppContext` will be updated\n * accordingly and pass those changes onto React components using the context.\n *\n * `CurrentAppContext` is used in a React application like any other `[React Context](https://reactjs.org/docs/context.html)\n * @memberof module:React\n */\nconst CurrentAppContext = createContext<{\n appConfig: AppConfig;\n}>({\n appConfig: {},\n});\n\nexport default CurrentAppContext;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"CurrentAppProvider.js","sourceRoot":"","sources":["../../../runtime/react/CurrentAppProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAA2B;IACrF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAEhE,YAAY,CAAC,cAAc,EAAE,GAAG,EAAE;QAChC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrC,SAAS;KACV,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YAC/C,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\n\nimport { getAppConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\n\nimport CurrentAppContext from './CurrentAppContext';\nimport { useSiteEvent } from './hooks';\n\ninterface CurrentAppProviderProps {\n appId: string,\n children: ReactNode,\n}\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * <CurrentAppProvider appId=\"my.app\">\n * <HelloWorld />\n * </CurrentAppProvider>\n * ```\n *\n * This will provide the following to HelloWorld:\n * - A `CurrentAppContext` provider for React context data.\n *\n * @param {Object} props\n * @memberof module:React\n */\nexport default function CurrentAppProvider({ appId, children }: CurrentAppProviderProps) {\n const [appConfig, setAppConfig] = useState(getAppConfig(appId));\n\n useSiteEvent(CONFIG_CHANGED, () => {\n setAppConfig(getAppConfig(appId));\n });\n\n const appContextValue = useMemo(() => ({\n appConfig,\n }), [appConfig]);\n\n return (\n <CurrentAppContext.Provider value={appContextValue}>\n {children}\n </CurrentAppContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"file":"CurrentAppProvider.js","sourceRoot":"","sources":["../../../runtime/react/CurrentAppProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAOvC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAA2B;IACrF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IAEhE,YAAY,CAAC,cAAc,EAAE,GAAG,EAAE;QAChC,YAAY,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrC,SAAS;KACV,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEjB,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YAC/C,QAAQ,GACkB,CAC9B,CAAC;AACJ,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\n\nimport { getAppConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\n\nimport CurrentAppContext from './CurrentAppContext';\nimport { useSiteEvent } from './hooks';\n\ninterface CurrentAppProviderProps {\n appId: string;\n children: ReactNode;\n}\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * <CurrentAppProvider appId=\"my.app\">\n * <HelloWorld />\n * </CurrentAppProvider>\n * ```\n *\n * This will provide the following to HelloWorld:\n * - A `CurrentAppContext` provider for React context data.\n *\n * @param {Object} props\n * @memberof module:React\n */\nexport default function CurrentAppProvider({ appId, children }: CurrentAppProviderProps) {\n const [appConfig, setAppConfig] = useState(getAppConfig(appId));\n\n useSiteEvent(CONFIG_CHANGED, () => {\n setAppConfig(getAppConfig(appId));\n });\n\n const appContextValue = useMemo(() => ({\n appConfig,\n }), [appConfig]);\n\n return (\n <CurrentAppContext.Provider value={appContextValue}>\n {children}\n </CurrentAppContext.Provider>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SiteContext.js","sourceRoot":"","sources":["../../../runtime/react/SiteContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,GAAG,aAAa,CAI9B;IACD,iBAAiB,EAAE,IAAI;IACvB,UAAU,EAAE,aAAa,EAAE;IAC3B,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import { createContext } from 'react';\nimport { SiteConfig, User } from '../../types';\nimport { getSiteConfig } from '../config';\n\n/**\n * `SiteContext` provides data from `App` in a way that React components can readily consume, even\n * if it's mutable data. `SiteContext` contains the following data structure:\n *\n * ```\n * {\n * authenticatedUser\n * siteConfig\n * locale\n * }\n * ```\n * If `authenticatedUser`, `siteConfig`, or `locale` data changes, `SiteContext` will be updated\n * accordingly and pass those changes onto React components using the context.\n *\n * `SiteContext` is used in a React application like any other `[React Context](https://reactjs.org/docs/context.html)\n * @memberof module:React\n */\nconst SiteContext = createContext<{\n authenticatedUser: User | null,\n siteConfig: SiteConfig,\n locale: string,\n}>({\n authenticatedUser: null,\n siteConfig: getSiteConfig(),\n locale: 'en',\n});\n\nexport default SiteContext;\n"]}
1
+ {"version":3,"file":"SiteContext.js","sourceRoot":"","sources":["../../../runtime/react/SiteContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,GAAG,aAAa,CAI9B;IACD,iBAAiB,EAAE,IAAI;IACvB,UAAU,EAAE,aAAa,EAAE;IAC3B,MAAM,EAAE,IAAI;CACb,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import { createContext } from 'react';\nimport { SiteConfig, User } from '../../types';\nimport { getSiteConfig } from '../config';\n\n/**\n * `SiteContext` provides data from `App` in a way that React components can readily consume, even\n * if it's mutable data. `SiteContext` contains the following data structure:\n *\n * ```\n * {\n * authenticatedUser\n * siteConfig\n * locale\n * }\n * ```\n * If `authenticatedUser`, `siteConfig`, or `locale` data changes, `SiteContext` will be updated\n * accordingly and pass those changes onto React components using the context.\n *\n * `SiteContext` is used in a React application like any other `[React Context](https://reactjs.org/docs/context.html)\n * @memberof module:React\n */\nconst SiteContext = createContext<{\n authenticatedUser: User | null;\n siteConfig: SiteConfig;\n locale: string;\n}>({\n authenticatedUser: null,\n siteConfig: getSiteConfig(),\n locale: 'en',\n});\n\nexport default SiteContext;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SiteProvider.js","sourceRoot":"","sources":["../../../runtime/react/SiteProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC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Aa,CAAC,GAAG,QAAQ,EAAE,CAAC;IAE/C,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACtC,iBAAiB;QACjB,UAAU;QACV,MAAM;QACN,KAAK,EAAE;YACL,KAAK,EAAE,UAAU;YACjB,eAAe,EAAE,CAAC,YAAoB,EAAE,EAAE;gBACxC,aAAa,CAAC,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;gBAE1D,kDAAkD;gBAClD,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,0BAA0B,EAAE,YAAY,CAAC,CAAC;YACxE,CAAC;SACF;KACF,CAAC,EAAE,CAAC,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAExE,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,aAAa,CAAA,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,YACnD,KAAC,aAAa,cACZ,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB,YAC3C,KAAC,mBAAmB,cACjB,QAAQ,GACW,GACD,GACT,GACH,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\n\nimport { AUTHENTICATED_USER_CHANGED, getAuthenticatedUser } from '../auth';\nimport { getSiteConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\nimport {\n getLocale,\n getMessages,\n IntlProvider,\n LOCALE_CHANGED,\n} from '../i18n';\n\nimport CombinedAppProvider from './CombinedAppProvider';\nimport ErrorBoundary from './ErrorBoundary';\nimport SiteContext from './SiteContext';\nimport { SELECTED_THEME_VARIANT_KEY } from './constants';\nimport {\n useTheme,\n useSiteEvent,\n useTrackColorSchemeChoice\n} from './hooks';\nimport { themeActions } from './reducers';\n\ninterface SiteProviderProps {\n children: ReactNode,\n}\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * subscribe(SITE_READY, () => {\n * ReactDOM.render(\n * <SiteProvider>\n * <HelloWorld />\n * </SiteProvider>\n * )\n * });\n * ```\n *\n * This will provide the following to HelloWorld:\n * - An error boundary as described above.\n * - An `SiteContext` provider for React context data.\n * - IntlProvider for @edx/frontend-i18n internationalization\n * - A theme manager for Paragon.\n *\n * @param {Object} props\n * @memberof module:React\n */\nexport default function SiteProvider({ children }: SiteProviderProps) {\n const [siteConfig, setSiteConfig] = useState(getSiteConfig());\n const [authenticatedUser, setAuthenticatedUser] = useState(getAuthenticatedUser());\n const [locale, setLocale] = useState(getLocale());\n\n useSiteEvent(AUTHENTICATED_USER_CHANGED, () => {\n setAuthenticatedUser(getAuthenticatedUser());\n });\n\n useSiteEvent(CONFIG_CHANGED, () => {\n setSiteConfig(getSiteConfig());\n });\n\n useSiteEvent(LOCALE_CHANGED, () => {\n setLocale(getLocale());\n });\n\n useTrackColorSchemeChoice();\n const [themeState, themeDispatch] = useTheme();\n\n const siteContextValue = useMemo(() => ({\n authenticatedUser,\n siteConfig,\n locale,\n theme: {\n state: themeState,\n setThemeVariant: (themeVariant: string) => {\n themeDispatch(themeActions.setThemeVariant(themeVariant));\n\n // Persist selected theme variant to localStorage.\n window.localStorage.setItem(SELECTED_THEME_VARIANT_KEY, themeVariant);\n },\n },\n }), [authenticatedUser, siteConfig, locale, themeState, themeDispatch]);\n\n if (!themeState?.isThemeLoaded) {\n return null;\n }\n\n return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <ErrorBoundary>\n <SiteContext.Provider value={siteContextValue}>\n <CombinedAppProvider>\n {children}\n </CombinedAppProvider>\n </SiteContext.Provider>\n </ErrorBoundary>\n </IntlProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"SiteProvider.js","sourceRoot":"","sources":["../../../runtime/react/SiteProvider.tsx"],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GAAG,EAAE;QAChC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,yBAAyB,EAAE,CAAC;IAC5B,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,EAAE,CAAC;IAE/C,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACtC,iBAAiB;QACjB,UAAU;QACV,MAAM;QACN,KAAK,EAAE;YACL,KAAK,EAAE,UAAU;YACjB,eAAe,EAAE,CAAC,YAAoB,EAAE,EAAE;gBACxC,aAAa,CAAC,YAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;gBAE1D,kDAAkD;gBAClD,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,0BAA0B,EAAE,YAAY,CAAC,CAAC;YACxE,CAAC;SACF;KACF,CAAC,EAAE,CAAC,iBAAiB,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC,CAAC;IAExE,IAAI,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,aAAa,CAAA,EAAE,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,YACnD,KAAC,aAAa,cACZ,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,gBAAgB,YAC3C,KAAC,mBAAmB,cACjB,QAAQ,GACW,GACD,GACT,GACH,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\n\nimport { AUTHENTICATED_USER_CHANGED, getAuthenticatedUser } from '../auth';\nimport { getSiteConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\nimport {\n getLocale,\n getMessages,\n IntlProvider,\n LOCALE_CHANGED,\n} from '../i18n';\n\nimport CombinedAppProvider from './CombinedAppProvider';\nimport ErrorBoundary from './ErrorBoundary';\nimport SiteContext from './SiteContext';\nimport { SELECTED_THEME_VARIANT_KEY } from './constants';\nimport {\n useTheme,\n useSiteEvent,\n useTrackColorSchemeChoice\n} from './hooks';\nimport { themeActions } from './reducers';\n\ninterface SiteProviderProps {\n children: ReactNode;\n}\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * subscribe(SITE_READY, () => {\n * ReactDOM.render(\n * <SiteProvider>\n * <HelloWorld />\n * </SiteProvider>\n * )\n * });\n * ```\n *\n * This will provide the following to HelloWorld:\n * - An error boundary as described above.\n * - An `SiteContext` provider for React context data.\n * - IntlProvider for @edx/frontend-i18n internationalization\n * - A theme manager for Paragon.\n *\n * @param {Object} props\n * @memberof module:React\n */\nexport default function SiteProvider({ children }: SiteProviderProps) {\n const [siteConfig, setSiteConfig] = useState(getSiteConfig());\n const [authenticatedUser, setAuthenticatedUser] = useState(getAuthenticatedUser());\n const [locale, setLocale] = useState(getLocale());\n\n useSiteEvent(AUTHENTICATED_USER_CHANGED, () => {\n setAuthenticatedUser(getAuthenticatedUser());\n });\n\n useSiteEvent(CONFIG_CHANGED, () => {\n setSiteConfig(getSiteConfig());\n });\n\n useSiteEvent(LOCALE_CHANGED, () => {\n setLocale(getLocale());\n });\n\n useTrackColorSchemeChoice();\n const [themeState, themeDispatch] = useTheme();\n\n const siteContextValue = useMemo(() => ({\n authenticatedUser,\n siteConfig,\n locale,\n theme: {\n state: themeState,\n setThemeVariant: (themeVariant: string) => {\n themeDispatch(themeActions.setThemeVariant(themeVariant));\n\n // Persist selected theme variant to localStorage.\n window.localStorage.setItem(SELECTED_THEME_VARIANT_KEY, themeVariant);\n },\n },\n }), [authenticatedUser, siteConfig, locale, themeState, themeDispatch]);\n\n if (!themeState?.isThemeLoaded) {\n return null;\n }\n\n return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <ErrorBoundary>\n <SiteContext.Provider value={siteContextValue}>\n <CombinedAppProvider>\n {children}\n </CombinedAppProvider>\n </SiteContext.Provider>\n </ErrorBoundary>\n </IntlProvider>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"useThemeVariants.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useThemeVariants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAAG,CAAC,EACxB,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,gCAAgC,GAMjC,EAAE,EAAE;IACH,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5E,6EAA6E;IAC7E,SAAS,CAAC,GAAG,EAAE;;QACb,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,EAAE;YAC7C,gCAAgC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC;QACF,MAAM,gBAAgB,GAAG,MAAA,MAAM,CAAC,UAAU,uDAAG,8BAA8B,CAAC,CAAC;QAC7E,IAAI,gBAAgB,EAAE,CAAC;YACrB,gBAAgB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,GAAG,EAAE;YACV,IAAI,gBAAgB,EAAE,CAAC;gBACrB,gBAAgB,CAAC,mBAAmB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;YACpE,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,gCAAgC,CAAC,CAAC,CAAC;IAEvC,oEAAoE;IACpE,SAAS,CAAC,GAAG,EAAE;;QACb,IAAI,mBAAmB,KAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAG,mBAAmB,CAAC,CAAA,EAAE,CAAC;YAChE,MAAM,wBAAwB,GAAG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AC,YAAY,CAAC,CAAC;gBACrE,wBAAwB,CAAC,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;gBAC7D,OAAO;YACT,CAAC;YAED,MAAM,gBAAgB,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACxD,gBAAgB,CAAC,IAAI,GAAG,GAAG,CAAC;YAC5B,gBAAgB,CAAC,GAAG,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC;YAC7D,gBAAgB,CAAC,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;YAErD,gBAAgB,CAAC,MAAM,GAAG,GAAG,EAAE;gBAC7B,IAAI,YAAY,KAAK,mBAAmB,EAAE,CAAC;oBACzC,yBAAyB,CAAC,IAAI,CAAC,CAAC;gBAClC,CAAC;YACH,CAAC,CAAC;YAEF,gBAAgB,CAAC,OAAO,GAAG,GAAG,EAAE;gBAC9B,QAAQ,CAAC,iCAAiC,YAAY,cAAc,GAAG,aAAa,CAAC,CAAC;gBACtF,yBAAyB,CAAC,IAAI,CAAC,CAAC;YAClC,CAAC,CAAC;YAEF,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CACjC,WAAW,EACX,gBAAgB,CACjB,CAAC;YAEF,yBAAyB,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,aAAa,EAAE,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { logError } from '../../../logging';\n\nimport { ThemeVariants } from '../../../../types';\n\n/**\n * A custom React hook that manages the loading of theme variant CSS files dynamically.\n * Adds/updates a `<link>` element in the HTML document to load each theme variant's CSS, setting the\n * non-current theme variants as \"alternate\" stylesheets. That is, the browser will download\n * the CSS for the non-current theme variants, but at a lower priority than the current one.\n * This ensures that if the theme variant is changed at runtime, the new theme's CSS will already be loaded.\n *\n * The hook also listens for changes in the system's preference and triggers the provided callback accordingly.\n */\nconst useThemeVariants = ({\n themeVariants,\n currentThemeVariant,\n onComplete,\n onDarkModeSystemPreferenceChange,\n}: {\n themeVariants: ThemeVariants | undefined,\n currentThemeVariant: string,\n onComplete: () => void,\n onDarkModeSystemPreferenceChange: (prefersDarkMode: boolean) => void,\n}) => {\n const [isThemeVariantComplete, setIsThemeVariantComplete] = useState(false);\n\n // Effect hook that listens for changes in the system's dark mode preference.\n useEffect(() => {\n const changeColorScheme = (colorSchemeQuery) => {\n onDarkModeSystemPreferenceChange(colorSchemeQuery.matches);\n };\n const colorSchemeQuery = window.matchMedia?.('(prefers-color-scheme: dark)');\n if (colorSchemeQuery) {\n colorSchemeQuery.addEventListener('change', changeColorScheme);\n }\n return () => {\n if (colorSchemeQuery) {\n colorSchemeQuery.removeEventListener('change', changeColorScheme);\n }\n };\n }, [onDarkModeSystemPreferenceChange]);\n\n // Effect hook to set the theme current variant on the HTML element.\n useEffect(() => {\n if (currentThemeVariant && themeVariants?.[currentThemeVariant]) {\n const htmlDataThemeVariantAttr = 'data-theme-variant';\n document.querySelector('html')?.setAttribute(htmlDataThemeVariantAttr, currentThemeVariant);\n return () => {\n document.querySelector('html')?.removeAttribute(htmlDataThemeVariantAttr);\n };\n }\n return () => { }; // Cleanup: no action needed when theme variant is not set\n }, [themeVariants, currentThemeVariant]);\n\n // Effect hook that calls `onComplete` when brand theme variant processing is complete.\n useEffect(() => {\n if (isThemeVariantComplete) {\n onComplete();\n }\n }, [isThemeVariantComplete, onComplete]);\n\n useEffect(() => {\n if (!themeVariants) {\n return;\n }\n\n /**\n * Determines the value for the `rel` attribute for a given theme variant based\n * on if its the currently applied variant.\n */\n const getActiveOrAlternateRel = (themeVariant: string): string => (currentThemeVariant === themeVariant ? 'stylesheet' : 'alternate stylesheet');\n\n // Iterate over each theme variant URLs and inject them into the HTML document, if each doesn't already exist.\n Object.entries(themeVariants).forEach(([themeVariant, { url }]) => {\n // If the config for the theme variant does not have a URL, set the variant to complete and continue.\n if (!url) {\n setIsThemeVariantComplete(true);\n return;\n }\n\n const existingThemeVariantLink: HTMLAnchorElement | null = document.head.querySelector(`link[href='${url}']`);\n if (existingThemeVariantLink) {\n existingThemeVariantLink.rel = getActiveOrAlternateRel(themeVariant);\n existingThemeVariantLink.dataset.themeVariant = themeVariant;\n return;\n }\n\n const themeVariantLink = document.createElement('link');\n themeVariantLink.href = url;\n themeVariantLink.rel = getActiveOrAlternateRel(themeVariant);\n themeVariantLink.dataset.themeVariant = themeVariant;\n\n themeVariantLink.onload = () => {\n if (themeVariant === currentThemeVariant) {\n setIsThemeVariantComplete(true);\n }\n };\n\n themeVariantLink.onerror = () => {\n logError(`Failed to load theme variant (${themeVariant}) CSS from ${url}. Aborting.`);\n setIsThemeVariantComplete(true);\n };\n\n document.head.insertAdjacentElement(\n 'beforeend',\n themeVariantLink,\n );\n\n setIsThemeVariantComplete(true);\n });\n }, [themeVariants, currentThemeVariant, onComplete]);\n};\n\nexport default useThemeVariants;\n"]}
1
+ {"version":3,"file":"useThemeVariants.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useThemeVariants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C;;;;;;;;GAQG;AACH,MAAM,gBAAgB,GAAG,CAAC,EACxB,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,gCAAgC,GAMjC,EAAE,EAAE;IACH,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5E,6EAA6E;IAC7E,SAAS,CAAC,GAAG,EAAE;;QACb,MAAM,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,EAAE;YAC7C,gCAAgC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QAC7D,CAAC,CAAC;QACF,MAAM,gBAAgB,G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IAAI,CAAC,qBAAqB,CACjC,WAAW,EACX,gBAAgB,CACjB,CAAC;YAEF,yBAAyB,CAAC,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,aAAa,EAAE,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { logError } from '../../../logging';\n\nimport { ThemeVariants } from '../../../../types';\n\n/**\n * A custom React hook that manages the loading of theme variant CSS files dynamically.\n * Adds/updates a `<link>` element in the HTML document to load each theme variant's CSS, setting the\n * non-current theme variants as \"alternate\" stylesheets. That is, the browser will download\n * the CSS for the non-current theme variants, but at a lower priority than the current one.\n * This ensures that if the theme variant is changed at runtime, the new theme's CSS will already be loaded.\n *\n * The hook also listens for changes in the system's preference and triggers the provided callback accordingly.\n */\nconst useThemeVariants = ({\n themeVariants,\n currentThemeVariant,\n onComplete,\n onDarkModeSystemPreferenceChange,\n}: {\n themeVariants: ThemeVariants | undefined;\n currentThemeVariant: string;\n onComplete: () => void;\n onDarkModeSystemPreferenceChange: (prefersDarkMode: boolean) => void;\n}) => {\n const [isThemeVariantComplete, setIsThemeVariantComplete] = useState(false);\n\n // Effect hook that listens for changes in the system's dark mode preference.\n useEffect(() => {\n const changeColorScheme = (colorSchemeQuery) => {\n onDarkModeSystemPreferenceChange(colorSchemeQuery.matches);\n };\n const colorSchemeQuery = window.matchMedia?.('(prefers-color-scheme: dark)');\n if (colorSchemeQuery) {\n colorSchemeQuery.addEventListener('change', changeColorScheme);\n }\n return () => {\n if (colorSchemeQuery) {\n colorSchemeQuery.removeEventListener('change', changeColorScheme);\n }\n };\n }, [onDarkModeSystemPreferenceChange]);\n\n // Effect hook to set the theme current variant on the HTML element.\n useEffect(() => {\n if (currentThemeVariant && themeVariants?.[currentThemeVariant]) {\n const htmlDataThemeVariantAttr = 'data-theme-variant';\n document.querySelector('html')?.setAttribute(htmlDataThemeVariantAttr, currentThemeVariant);\n return () => {\n document.querySelector('html')?.removeAttribute(htmlDataThemeVariantAttr);\n };\n }\n return () => { }; // Cleanup: no action needed when theme variant is not set\n }, [themeVariants, currentThemeVariant]);\n\n // Effect hook that calls `onComplete` when brand theme variant processing is complete.\n useEffect(() => {\n if (isThemeVariantComplete) {\n onComplete();\n }\n }, [isThemeVariantComplete, onComplete]);\n\n useEffect(() => {\n if (!themeVariants) {\n return;\n }\n\n /**\n * Determines the value for the `rel` attribute for a given theme variant based\n * on if its the currently applied variant.\n */\n const getActiveOrAlternateRel = (themeVariant: string): string => (currentThemeVariant === themeVariant ? 'stylesheet' : 'alternate stylesheet');\n\n // Iterate over each theme variant URLs and inject them into the HTML document, if each doesn't already exist.\n Object.entries(themeVariants).forEach(([themeVariant, { url }]) => {\n // If the config for the theme variant does not have a URL, set the variant to complete and continue.\n if (!url) {\n setIsThemeVariantComplete(true);\n return;\n }\n\n const existingThemeVariantLink: HTMLAnchorElement | null = document.head.querySelector(`link[href='${url}']`);\n if (existingThemeVariantLink) {\n existingThemeVariantLink.rel = getActiveOrAlternateRel(themeVariant);\n existingThemeVariantLink.dataset.themeVariant = themeVariant;\n return;\n }\n\n const themeVariantLink = document.createElement('link');\n themeVariantLink.href = url;\n themeVariantLink.rel = getActiveOrAlternateRel(themeVariant);\n themeVariantLink.dataset.themeVariant = themeVariant;\n\n themeVariantLink.onload = () => {\n if (themeVariant === currentThemeVariant) {\n setIsThemeVariantComplete(true);\n }\n };\n\n themeVariantLink.onerror = () => {\n logError(`Failed to load theme variant (${themeVariant}) CSS from ${url}. Aborting.`);\n setIsThemeVariantComplete(true);\n };\n\n document.head.insertAdjacentElement(\n 'beforeend',\n themeVariantLink,\n );\n\n setIsThemeVariantComplete(true);\n });\n }, [themeVariants, currentThemeVariant, onComplete]);\n};\n\nexport default useThemeVariants;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Slot.js","sourceRoot":"","sources":["../../../runtime/slots/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actNode } from 'react';\nimport DefaultSlotLayout from './layout/DefaultSlotLayout';\nimport { useLayoutForSlotId } from './layout/hooks';\nimport SlotContext from './SlotContext';\nimport { useSlotContext } from './hooks';\n\ninterface SlotProps {\n id: string,\n idAliases?: string[],\n children?: ReactNode,\n layout?: ComponentType | ReactNode,\n [key: string]: unknown,\n}\n\nfunction SlotRenderer({ layout }: { layout: ComponentType | ReactNode }) {\n const { id } = useSlotContext();\n let layoutElement: ComponentType | ReactNode = layout;\n\n const overrideLayout = useLayoutForSlotId(id);\n\n // Weed out any ReactNode types that aren't actually JSX.\n if (overrideLayout && overrideLayout !== null && overrideLayout !== undefined && typeof overrideLayout !== 'boolean') {\n layoutElement = overrideLayout;\n }\n\n if (!isValidElement(layoutElement)) {\n layoutElement = createElement(layoutElement as ComponentType);\n }\n\n return <>{layoutElement}</>;\n}\n\nfunction Slot({ id, idAliases, children, layout = DefaultSlotLayout, ...props }: SlotProps) {\n return (\n <SlotContext.Provider value={{ id, idAliases, children, ...props }}>\n <SlotRenderer layout={layout} />\n </SlotContext.Provider>\n );\n}\n\n/* memo so parent re-renders don't cascade through Slot when props are shallow-equal. */\nexport default memo(Slot);\n"]}
1
+ {"version":3,"file":"Slot.js","sourceRoot":"","sources":["../../../runtime/slots/Slot.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAiB,aAAa,EAAE,cAAc,EAAE,IAAI,EAAa,MAAM,OAAO,CAAC;AACtF,OAAO,iBAAiB,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAUzC,SAAS,YAAY,CAAC,EAAE,MAAM,EAAyC;IACrE,MAAM,EAAE,EAAE,EAAE,GAAG,cAAc,EAAE,CAAC;IAChC,IAAI,aAAa,GAA8B,MAAM,CAAC;IAEtD,MAAM,cAAc,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAE9C,yDAAyD;IACzD,IAAI,cAAc,IAAI,cAAc,KAAK,IAAI,IAAI,cAAc,KAAK,SAAS,IAAI,OAAO,cAAc,KAAK,SAAS,EAAE,CAAC;QACrH,aAAa,GAAG,cAAc,CAAC;IACjC,CAAC;IAED,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC;QACnC,aAAa,GAAG,aAAa,CAAC,aAA8B,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,4BAAG,aAAa,GAAI,CAAC;AAC9B,CAAC;AAED,SAAS,IAAI,CAAC,EAA4E;QAA5E,EAAE,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,iBAAiB,OAAuB,EAAlB,KAAK,cAA/D,yCAAiE,CAAF;IAC3E,OAAO,CACL,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,kBAAI,EAAE,EAAE,SAAS,EAAE,QAAQ,IAAK,KAAK,aAC9D,KAAC,YAAY,IAAC,MAAM,EAAE,MAAM,GAAI,GACX,CACxB,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,eAAe,IAAI,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { ComponentType, createElement, isValidElement, memo, ReactNode } from 'react';\nimport DefaultSlotLayout from './layout/DefaultSlotLayout';\nimport { useLayoutForSlotId } from './layout/hooks';\nimport SlotContext from './SlotContext';\nimport { useSlotContext } from './hooks';\n\ninterface SlotProps {\n id: string;\n idAliases?: string[];\n children?: ReactNode;\n layout?: ComponentType | ReactNode;\n [key: string]: unknown;\n}\n\nfunction SlotRenderer({ layout }: { layout: ComponentType | ReactNode }) {\n const { id } = useSlotContext();\n let layoutElement: ComponentType | ReactNode = layout;\n\n const overrideLayout = useLayoutForSlotId(id);\n\n // Weed out any ReactNode types that aren't actually JSX.\n if (overrideLayout && overrideLayout !== null && overrideLayout !== undefined && typeof overrideLayout !== 'boolean') {\n layoutElement = overrideLayout;\n }\n\n if (!isValidElement(layoutElement)) {\n layoutElement = createElement(layoutElement as ComponentType);\n }\n\n return <>{layoutElement}</>;\n}\n\nfunction Slot({ id, idAliases, children, layout = DefaultSlotLayout, ...props }: SlotProps) {\n return (\n <SlotContext.Provider value={{ id, idAliases, children, ...props }}>\n <SlotRenderer layout={layout} />\n </SlotContext.Provider>\n );\n}\n\n/* memo so parent re-renders don't cascade through Slot when props are shallow-equal. */\nexport default memo(Slot);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SlotContext.js","sourceRoot":"","sources":["../../../runtime/slots/SlotContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,GAAG,aAAa,CAAqF;IACpH,EAAE,EAAE,EAAE;IACN,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import { createContext, ReactNode } from 'react';\n\nconst SlotContext = createContext<{ id: string, idAliases?: string[], children?: ReactNode, [key: string]: unknown }>({\n id: '',\n children: null,\n});\n\nexport default SlotContext;\n"]}
1
+ {"version":3,"file":"SlotContext.js","sourceRoot":"","sources":["../../../runtime/slots/SlotContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AAEjD,MAAM,WAAW,GAAG,aAAa,CAAqF;IACpH,EAAE,EAAE,EAAE;IACN,QAAQ,EAAE,IAAI;CACf,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC","sourcesContent":["import { createContext, ReactNode } from 'react';\n\nconst SlotContext = createContext<{ id: string; idAliases?: string[]; children?: ReactNode; [key: string]: unknown }>({\n id: '',\n children: null,\n});\n\nexport default SlotContext;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../runtime/slots/layout/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,iDAAyB,CAAA;IACzB,iDAAyB,CAAA;AAC3B,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","sourcesContent":["/**\n * Base UI Layout Operations\n *\n * \"Layout\" operations are a sub-type of UI operations which affect the layout component of a UI\n * slot. They have no effect on the widgets loaded into a UI slot.\n */\n\nimport { ReactNode } from 'react';\nimport { BaseSlotOperation } from '../types';\n\nexport enum LayoutOperationTypes {\n OPTIONS = 'layoutOptions',\n REPLACE = 'layoutReplace',\n}\n\nexport interface BaseLayoutOperation extends BaseSlotOperation {\n op: LayoutOperationTypes,\n}\n\n// Concrete UI Layout Operations\n\nexport type LayoutOptionsOperation = BaseLayoutOperation & {\n op: LayoutOperationTypes.OPTIONS,\n options: Record<string, unknown>,\n};\n\nexport interface LayoutComponentProps {\n component: React.ComponentType,\n}\n\nexport interface LayoutElementProps {\n element: ReactNode,\n}\n\nexport type LayoutRendererProps = (\n LayoutComponentProps | LayoutElementProps\n);\n\nexport type LayoutReplaceOperation = BaseLayoutOperation & LayoutRendererProps & {\n op: LayoutOperationTypes.REPLACE,\n};\n\n// Aggregate UI Layout Operations\n\nexport type LayoutOperation = LayoutOptionsOperation | LayoutReplaceOperation;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../runtime/slots/layout/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,MAAM,CAAN,IAAY,oBAGX;AAHD,WAAY,oBAAoB;IAC9B,iDAAyB,CAAA;IACzB,iDAAyB,CAAA;AAC3B,CAAC,EAHW,oBAAoB,KAApB,oBAAoB,QAG/B","sourcesContent":["/**\n * Base UI Layout Operations\n *\n * \"Layout\" operations are a sub-type of UI operations which affect the layout component of a UI\n * slot. They have no effect on the widgets loaded into a UI slot.\n */\n\nimport { ReactNode } from 'react';\nimport { BaseSlotOperation } from '../types';\n\nexport enum LayoutOperationTypes {\n OPTIONS = 'layoutOptions',\n REPLACE = 'layoutReplace',\n}\n\nexport interface BaseLayoutOperation extends BaseSlotOperation {\n op: LayoutOperationTypes;\n}\n\n// Concrete UI Layout Operations\n\nexport type LayoutOptionsOperation = BaseLayoutOperation & {\n op: LayoutOperationTypes.OPTIONS;\n options: Record<string, unknown>;\n};\n\nexport interface LayoutComponentProps {\n component: React.ComponentType;\n}\n\nexport interface LayoutElementProps {\n element: ReactNode;\n}\n\nexport type LayoutRendererProps = (\n LayoutComponentProps | LayoutElementProps\n);\n\nexport type LayoutReplaceOperation = BaseLayoutOperation & LayoutRendererProps & {\n op: LayoutOperationTypes.REPLACE;\n};\n\n// Aggregate UI Layout Operations\n\nexport type LayoutOperation = LayoutOptionsOperation | LayoutReplaceOperation;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../runtime/slots/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * Base Slot Operations\n *\n * These are properties shared by all slot operations defined below.\n */\n\nimport { LayoutOperation } from './layout/types';\nimport { WidgetOperation } from './widget/types';\n\nexport interface SlotOperationCondition {\n active?: string[],\n inactive?: string[],\n authenticated?: boolean,\n callback?: () => boolean,\n}\n\nexport interface BaseSlotOperation {\n slotId: string,\n condition?: SlotOperationCondition,\n}\n\n// Aggregate Slot Operations\n\nexport type SlotOperation = WidgetOperation | LayoutOperation;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../runtime/slots/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG","sourcesContent":["/**\n * Base Slot Operations\n *\n * These are properties shared by all slot operations defined below.\n */\n\nimport { LayoutOperation } from './layout/types';\nimport { WidgetOperation } from './widget/types';\n\nexport interface SlotOperationCondition {\n active?: string[];\n inactive?: string[];\n authenticated?: boolean;\n callback?: () => boolean;\n}\n\nexport interface BaseSlotOperation {\n slotId: string;\n condition?: SlotOperationCondition;\n}\n\n// Aggregate Slot Operations\n\nexport type SlotOperation = WidgetOperation | LayoutOperation;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetContext.js","sourceRoot":"","sources":["../../../../runtime/slots/widget/WidgetContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,aAAa,GAAG,aAAa,CAAsD;IACvF,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,SAAS;CAChB,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC","sourcesContent":["import { createContext } from 'react';\n\nconst WidgetContext = createContext<{ slotId: string, widgetId: string, role?: string }>({\n slotId: '',\n widgetId: '',\n role: undefined,\n});\n\nexport default WidgetContext;\n"]}
1
+ {"version":3,"file":"WidgetContext.js","sourceRoot":"","sources":["../../../../runtime/slots/widget/WidgetContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,MAAM,aAAa,GAAG,aAAa,CAAsD;IACvF,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE,SAAS;CAChB,CAAC,CAAC;AAEH,eAAe,aAAa,CAAC","sourcesContent":["import { createContext } from 'react';\n\nconst WidgetContext = createContext<{ slotId: string; widgetId: string; role?: string }>({\n slotId: '',\n widgetId: '',\n role: undefined,\n});\n\nexport default WidgetContext;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WidgetProvider.js","sourceRoot":"","sources":["../../../../runtime/slots/widget/WidgetProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAS5C,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAuB;IAC9F,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,GAAG,EAAE;YACV,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YACtD,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { ReactNode, useEffect } from 'react';\n\nimport { addActiveWidgetRole, removeActiveWidgetRole } from '../../config';\nimport WidgetContext from './WidgetContext';\n\ninterface WidgetProviderProps {\n children: ReactNode,\n slotId: string,\n widgetId: string,\n role?: string,\n}\n\nexport default function WidgetProvider({ children, slotId, widgetId, role }: WidgetProviderProps) {\n useEffect(() => {\n if (role !== undefined) {\n addActiveWidgetRole(role);\n }\n return () => {\n if (role !== undefined) {\n removeActiveWidgetRole(role);\n }\n };\n }, [role]);\n\n return (\n <WidgetContext.Provider value={{ slotId, widgetId, role }}>\n {children}\n </WidgetContext.Provider>\n );\n}\n"]}
1
+ {"version":3,"file":"WidgetProvider.js","sourceRoot":"","sources":["../../../../runtime/slots/widget/WidgetProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAS5C,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAuB;IAC9F,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,GAAG,EAAE;YACV,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAEX,OAAO,CACL,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,YACtD,QAAQ,GACc,CAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { ReactNode, useEffect } from 'react';\n\nimport { addActiveWidgetRole, removeActiveWidgetRole } from '../../config';\nimport WidgetContext from './WidgetContext';\n\ninterface WidgetProviderProps {\n children: ReactNode;\n slotId: string;\n widgetId: string;\n role?: string;\n}\n\nexport default function WidgetProvider({ children, slotId, widgetId, role }: WidgetProviderProps) {\n useEffect(() => {\n if (role !== undefined) {\n addActiveWidgetRole(role);\n }\n return () => {\n if (role !== undefined) {\n removeActiveWidgetRole(role);\n }\n };\n }, [role]);\n\n return (\n <WidgetContext.Provider value={{ slotId, widgetId, role }}>\n {children}\n </WidgetContext.Provider>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IFrameContentWrapper.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/IFrameContentWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,SAAS,EAAE,OAAO,EAAE,QAAQ,GAC7B,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AA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IAEZ,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,YAC1C,KAAC,aAAa,IAAC,iBAAiB,EAAE,KAAC,aAAa,KAAG,YAChD,QAAQ,GACK,GACZ,CACP,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import {\n FunctionComponent,\n ReactNode,\n useEffect, useMemo, useState,\n} from 'react';\n\nimport { useIntl } from '../../../i18n';\nimport { ErrorBoundary } from '../../../react';\nimport { IFRAME_RESIZE } from './constants';\nimport {\n dispatchMountedEvent,\n dispatchReadyEvent,\n dispatchUnmountedEvent,\n useHostEvent\n} from './hooks';\nimport messages from './IFrameContentWrapper.messages';\n\nconst ErrorFallbackDefault = () => {\n const { formatMessage } = useIntl();\n return (\n <div>\n <h2>\n {formatMessage(messages.unexpectedError)}\n </h2>\n </div>\n );\n};\n\ninterface IFrameContentWrapperProps {\n children: ReactNode,\n className?: string,\n style?: Record<string, string>,\n ready?: boolean,\n errorFallbackComponent?: FunctionComponent,\n}\n\nexport default function IFrameContentWrapper({\n children, className, style = {}, ready = true, errorFallbackComponent,\n}: IFrameContentWrapperProps) {\n const [dimensions, setDimensions] = useState({\n width: 0,\n height: 0,\n });\n\n const finalStyle = useMemo(() => ({\n ...dimensions,\n ...style,\n }), [dimensions, style]);\n\n // Need to confirm: When an error is caught here, the logging will be sent to the child MFE's logging service\n\n const ErrorFallback = errorFallbackComponent ?? ErrorFallbackDefault;\n\n useHostEvent(IFRAME_RESIZE, ({ payload }) => {\n setDimensions({\n width: payload.width,\n height: payload.height,\n });\n });\n\n useEffect(() => {\n dispatchMountedEvent();\n\n return () => {\n dispatchUnmountedEvent();\n };\n }, []);\n\n useEffect(() => {\n // Ready defaults to true, but can be used to defer rendering the Plugin until certain processes\n // have occurred or conditions have been met\n if (ready) {\n dispatchReadyEvent();\n }\n }, [ready]);\n\n return (\n <div className={className} style={finalStyle}>\n <ErrorBoundary fallbackComponent={<ErrorFallback />}>\n {children}\n </ErrorBoundary>\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"IFrameContentWrapper.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/IFrameContentWrapper.tsx"],"names":[],"mappings":";AAAA,OAAO,EAGL,SAAS,EAAE,OAAO,EAAE,QAAQ,GAC7B,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AACjB,OAAO,QAAQ,MAAM,iCAAiC,CAAC;AAEvD,MAAM,oBAAoB,GAAG,GAAG,EAAE;IAChC,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,OAAO,CACL,wBACE,uBACG,aAAa,CAAC,QAAQ,CAAC,eAAe,CAAC,GACrC,GACD,CACP,CAAC;AACJ,CAAC,CAAC;AAUF,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,EAAE,KAAK,GAAG,IAAI,EAAE,sBAAsB,GAC3C;IAC1B,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC;QAC3C,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV,CAAC,CAAC;IAEH,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,iCAC5B,UAAU,GACV,KAAK,EACR,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;IAEzB,6GAA6G;IAE7G,MAAM,aAAa,GAAG,sBAAsB,aAAtB,sBAAsB,cAAtB,sBAAsB,GAAI,oBAAoB,CAAC;IAErE,YAAY,CAAC,aAAa,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;QAC1C,aAAa,CAAC;YACZ,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACb,oBAAoB,EAAE,CAAC;QAEvB,OAAO,GAAG,EAAE;YACV,sBAAsB,EAAE,CAAC;QAC3B,CAAC,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,gGAAgG;QAChG,4CAA4C;QAC5C,IAAI,KAAK,EAAE,CAAC;YACV,kBAAkB,EAAE,CAAC;QACvB,CAAC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,cAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,YAC1C,KAAC,aAAa,IAAC,iBAAiB,EAAE,KAAC,aAAa,KAAG,YAChD,QAAQ,GACK,GACZ,CACP,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import {\n FunctionComponent,\n ReactNode,\n useEffect, useMemo, useState,\n} from 'react';\n\nimport { useIntl } from '../../../i18n';\nimport { ErrorBoundary } from '../../../react';\nimport { IFRAME_RESIZE } from './constants';\nimport {\n dispatchMountedEvent,\n dispatchReadyEvent,\n dispatchUnmountedEvent,\n useHostEvent\n} from './hooks';\nimport messages from './IFrameContentWrapper.messages';\n\nconst ErrorFallbackDefault = () => {\n const { formatMessage } = useIntl();\n return (\n <div>\n <h2>\n {formatMessage(messages.unexpectedError)}\n </h2>\n </div>\n );\n};\n\ninterface IFrameContentWrapperProps {\n children: ReactNode;\n className?: string;\n style?: Record<string, string>;\n ready?: boolean;\n errorFallbackComponent?: FunctionComponent;\n}\n\nexport default function IFrameContentWrapper({\n children, className, style = {}, ready = true, errorFallbackComponent,\n}: IFrameContentWrapperProps) {\n const [dimensions, setDimensions] = useState({\n width: 0,\n height: 0,\n });\n\n const finalStyle = useMemo(() => ({\n ...dimensions,\n ...style,\n }), [dimensions, style]);\n\n // Need to confirm: When an error is caught here, the logging will be sent to the child MFE's logging service\n\n const ErrorFallback = errorFallbackComponent ?? ErrorFallbackDefault;\n\n useHostEvent(IFRAME_RESIZE, ({ payload }) => {\n setDimensions({\n width: payload.width,\n height: payload.height,\n });\n });\n\n useEffect(() => {\n dispatchMountedEvent();\n\n return () => {\n dispatchUnmountedEvent();\n };\n }, []);\n\n useEffect(() => {\n // Ready defaults to true, but can be used to defer rendering the Plugin until certain processes\n // have occurred or conditions have been met\n if (ready) {\n dispatchReadyEvent();\n }\n }, [ready]);\n\n return (\n <div className={className} style={finalStyle}>\n <ErrorBoundary fallbackComponent={<ErrorFallback />}>\n {children}\n </ErrorBoundary>\n </div>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IFrameWidget.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/IFrameWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOjG,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,GAAG,EAAE,KAAK,EAAqB;IACpE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE1C,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IAEnF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,mBAAmB,CAAC,aAAkC,EAAE;gBACtD,IAAI,EAAE,aAAa;gBACnB,OAAO,EAAE;oBACP,KAAK;oBACL,MAAM;iBACP;aACF,EAAE,GAAG,CAAC,CAAC;QACV,CAAC;IACH,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjD,cAAc,CAAC,aAAa,EAAE,cAAc,EAAE,GAAG,EAAE;QACjD,UAAU,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;IAEH,cAAc,CAAC,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE;QAC/C,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,CACf,KAAC,OAAO,IAAC,SAAS,EAAC,QAAQ,EAAC,OAAO,EAAC,OAAO,EAAC,gBAAgB,EAAC,SAAS,GAAG,CAC1E,CAAC;IAEF,OAAO,CACL,8BACE,iBACE,GAAG,EAAE,SAAS,EACd,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,qBAAqB,EAC5B,cAAc,EAAC,QAAQ,CAAC,qGAAqG;kBAC7H,SAAS,EAAE,UAAU,CACnB,uBAAuB,EACvB,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CACrB,GACD,EACD,CAAC,KAAK,IAAI,QAAQ,IAClB,CACJ,CAAC;AACJ,CAAC","sourcesContent":["import { Spinner } from '@openedx/paragon';\nimport { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\nimport { dispatchPluginEvent, useElementSize, usePluginEvent } from './hooks';\nimport { IFRAME_FEATURE_POLICY, IFRAME_MOUNTED, IFRAME_READY, IFRAME_RESIZE } from './constants';\n\ninterface IFrameWidgetProps {\n url: string,\n title: string,\n}\n\nexport default function IFrameWidget({ url, title }: IFrameWidgetProps) {\n const [mounted, setMounted] = useState(false);\n const [ready, setReady] = useState(false);\n\n const { ref: iframeRef, element: iframeElement, width, height } = useElementSize();\n\n useEffect(() => {\n if (mounted) {\n dispatchPluginEvent(iframeElement as HTMLIFrameElement, {\n type: IFRAME_RESIZE,\n payload: {\n width,\n height,\n },\n }, url);\n }\n }, [iframeElement, mounted, width, height, url]);\n\n usePluginEvent(iframeElement, IFRAME_MOUNTED, () => {\n setMounted(true);\n });\n\n usePluginEvent(iframeElement, IFRAME_READY, () => {\n setReady(true);\n });\n\n const fallback = (\n <Spinner animation=\"border\" variant=\"light\" screenReaderText=\"Loading\" />\n );\n\n return (\n <>\n <iframe\n ref={iframeRef}\n title={title}\n src={url}\n allow={IFRAME_FEATURE_POLICY}\n referrerPolicy=\"origin\" // The sent referrer will be limited to the origin of the referring page: its scheme, host, and port.\n className={classNames(\n 'border border-0 w-100',\n { 'd-none': !ready },\n )}\n />\n {!ready && fallback}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"IFrameWidget.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/IFrameWidget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAOjG,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EAAE,GAAG,EAAE,KAAK,EAAqB;IACpE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAA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Effect, useState } from 'react';\n\nimport classNames from 'classnames';\nimport { dispatchPluginEvent, useElementSize, usePluginEvent } from './hooks';\nimport { IFRAME_FEATURE_POLICY, IFRAME_MOUNTED, IFRAME_READY, IFRAME_RESIZE } from './constants';\n\ninterface IFrameWidgetProps {\n url: string;\n title: string;\n}\n\nexport default function IFrameWidget({ url, title }: IFrameWidgetProps) {\n const [mounted, setMounted] = useState(false);\n const [ready, setReady] = useState(false);\n\n const { ref: iframeRef, element: iframeElement, width, height } = useElementSize();\n\n useEffect(() => {\n if (mounted) {\n dispatchPluginEvent(iframeElement as HTMLIFrameElement, {\n type: IFRAME_RESIZE,\n payload: {\n width,\n height,\n },\n }, url);\n }\n }, [iframeElement, mounted, width, height, url]);\n\n usePluginEvent(iframeElement, IFRAME_MOUNTED, () => {\n setMounted(true);\n });\n\n usePluginEvent(iframeElement, IFRAME_READY, () => {\n setReady(true);\n });\n\n const fallback = (\n <Spinner animation=\"border\" variant=\"light\" screenReaderText=\"Loading\" />\n );\n\n return (\n <>\n <iframe\n ref={iframeRef}\n title={title}\n src={url}\n allow={IFRAME_FEATURE_POLICY}\n referrerPolicy=\"origin\" // The sent referrer will be limited to the origin of the referring page: its scheme, host, and port.\n className={classNames(\n 'border border-0 w-100',\n { 'd-none': !ready },\n )}\n />\n {!ready && fallback}\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG7E,0BAA0B;AAE1B;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAwB,EAAE,IAAY,EAAE,QAA8B;IACpG,mEAAmE;IAC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AAC;IACxE,+GAA+G;IAC/G,MAAM,WAAW,GAAiC,WAAW,CAAC,QAAQ,CAAC,EAAE;QACvE,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,SAAS,CAAC,GAAG,EAAE;QACb,8BAA8B;QAC9B,WAAW,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC,GAAG,EAAE;YAC5C,IAAI,OAAO,EAAE,CAAC;gBACZ,gCAAgC;gBAChC,aAAa,CAAC;oBACZ,KAAK,EAAE,OAAO,CAAC,WAAW;oBAC1B,MAAM,EAAE,OAAO,CAAC,YAAY;iBAC7B,CAAC,CAAC;gBACH,SAAS,CAAC;oBACR,CAAC,EAAE,OAAO,CAAC,UAAU;oBACrB,CAAC,EAAE,OAAO,CAAC,SAAS;iBACrB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,mGAAmG;YACnG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,OAAO,CAQZ,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,EAAE,WAAW;QAChB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,CAAC,EAAE,MAAM,CAAC,CAAC;QACX,CAAC,EAAE,MAAM,CAAC,CAAC;KACZ,CAAC,EACF,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Hooks file for functions that handle the communication between a Plugin and its Host\n */\n\nimport {\n LegacyRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport { IFRAME_MOUNTED, IFRAME_READY, IFRAME_UNMOUNTED } from './constants';\nimport { MessageEventCallback } from './types';\n\n/* Listening for events */\n\n/**\n * Dynamically add an event listener to the provided source window.\n * The source window can be the global parent (ie. the \"window\" object in the browser)\n * or it can be the content window of an individual element (ie. iFrame plugin container)\n */\nexport function useMessageEvent(srcWindow: Window | null, type: string, callback: MessageEventCallback) {\n // useLayoutEffect is called before the browser repaints the screen\n useLayoutEffect(() => {\n // Create a listener callback function\n const listener = (event: MessageEvent<{ type: string, payload: any }>) => {\n // Filter messages to those from our source window.\n // NOTE: the \"srcWindow\" is determined by the below useHostEvent and usePluginEvent functions\n if (event.source === srcWindow) {\n // Fire callback if the type from the listened event matches the type from the message event\n if (event.data.type === type) {\n callback({ type, payload: event.data.payload });\n }\n }\n };\n // Add the listener to the global object if the srcWindow is not null\n if (srcWindow !== null) {\n global.addEventListener('message', listener);\n }\n // useEffect cleanup\n return () => {\n global.removeEventListener('message', listener);\n };\n }, [srcWindow, type, callback]);\n}\n\n/**\n * Called by the Plugin component to use events that were listened to (ie. PLUGIN_RESIZE)\n */\nexport function useHostEvent(type: string, callback: MessageEventCallback) {\n useMessageEvent(global.parent, type, callback);\n}\n\n/**\n * Used to listen for events from a wrapped Plugin element (eg. PluginContainerIframe)\n *\n * @param element - Plugin element (eg. <iframe>)\n * @param type - Event type (eg. PLUGIN_RESIZE)\n * @param callback - Function to call when the event is triggered\n */\nexport function usePluginEvent(element: HTMLIFrameElement | undefined, type: string, callback: MessageEventCallback) {\n const contentWindow = element ? element.contentWindow : null;\n useMessageEvent(contentWindow, type, callback);\n}\n\n/** Dispatching events */\n\n/**\n * Base dispatch function called by dispatchHostEvent and dispatchPluginEvent.\n * Uses the `postMessage` method to enable cross-origin communication between Window objects\n *\n * @param targetWindow - Window that the message event is being dispatched to\n * @param message - Data object for the message\n * @param targetOrigin - URL for the window that the message event is being dispatched from\n */\nexport function dispatchMessageEvent(targetWindow: Window | null, message: any, targetOrigin: string) {\n /** Checking targetOrigin falsiness here since '', null or undefined would all be\n * reasons not to try to post a message to the origin.\n */\n if (targetWindow && targetOrigin) {\n targetWindow.postMessage(message, targetOrigin);\n }\n}\n\n/**\n * Used to dispatch events for a Plugin\n *\n * @param element - Plugin element (eg. <iframe>)\n * @param message - Data object for the message\n * @param targetOrigin - URL for the window that the message event is being dispatched from\n */\nexport function dispatchPluginEvent(element: HTMLIFrameElement, message: any, targetOrigin: string) {\n dispatchMessageEvent(element.contentWindow, message, targetOrigin);\n}\n\n/**\n * Used to dispatch events for the Host\n *\n * @param message - Data object for the message\n */\nexport function dispatchHostEvent(message: any) {\n dispatchMessageEvent(global.parent, message, global.document.referrer);\n}\n\n// Called inside Plugin when 'ready' prop is true\nexport function dispatchReadyEvent() {\n dispatchHostEvent({ type: IFRAME_READY });\n}\n\n// Below mounted events are called in a useEffect inside Plugin with [] dependencies — https://react.dev/learn/synchronizing-with-effects\nexport function dispatchMountedEvent() {\n dispatchHostEvent({ type: IFRAME_MOUNTED });\n}\n\nexport function dispatchUnmountedEvent() {\n dispatchHostEvent({ type: IFRAME_UNMOUNTED });\n}\n\n/**\n * Used to determine the size of an element as it is being resized in the browser.\n * ResizeObserver (https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) is used to maintain a reference to the element's content/border box.\n *\n * @returns Memoized value that contains a reference to the Plugin element (eg. iframe)\n */\nexport function useElementSize() {\n // Holds a reference to the ResizeObserver\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const [dimensions, setDimensions] = useState({ width: 0, height: 0 });\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [element, setElement] = useState<HTMLIFrameElement | undefined>();\n // Sets a reference to the Plugin element when passed to the Plugin element as a \"ref\" attribute (eg. <iframe>)\n const measuredRef: LegacyRef<HTMLIFrameElement> = useCallback(_element => {\n setElement(_element);\n }, []);\n\n useEffect(() => {\n // Create a new ResizeObserver\n observerRef.current = new ResizeObserver(() => {\n if (element) {\n // Set dimensions and any offset\n setDimensions({\n width: element.clientWidth,\n height: element.clientHeight,\n });\n setOffset({\n x: element.offsetLeft,\n y: element.offsetTop,\n });\n }\n });\n if (element) {\n // Tell the ResizeObserver to start watching the element — this enables the hook to detect resizing\n observerRef.current.observe(element);\n }\n }, [element]);\n\n return useMemo<{\n ref: LegacyRef<HTMLIFrameElement>,\n element: HTMLIFrameElement | undefined,\n width: number,\n height: number,\n x: number,\n y: number,\n }>(\n () => ({\n ref: measuredRef,\n element: element,\n width: dimensions.width,\n height: dimensions.height,\n x: offset.x,\n y: offset.y\n }),\n [measuredRef, element, dimensions, offset],\n );\n}\n"]}
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/hooks.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,WAAW,EACX,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG7E,0BAA0B;AAE1B;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,SAAwB,EAAE,IAAY,EAAE,QAA8B;IACpG,mEAAmE;IACnE,eAAe,CAAC,GAAG,EAAE;QACnB,sCAAsC;QACtC,MAAM,QAAQ,GAAG,CAAC,KAAmD,EAAE,EAAE;YACvE,mDAAmD;YACnD,6FAA6F;YAC7F,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC/B,4FAA4F;gBAC5F,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;oBAC7B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBAClD,CAAC;YACH,CAAC;QACH,CAAC,CAAC;QACF,qEAAqE;QACrE,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,QAAQ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;iBACrB,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,OAAO,EAAE,CAAC;YACZ,mGAAmG;YACnG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACvC,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,OAAO,CAQZ,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,EAAE,WAAW;QAChB,OAAO,EAAE,OAAO;QAChB,KAAK,EAAE,UAAU,CAAC,KAAK;QACvB,MAAM,EAAE,UAAU,CAAC,MAAM;QACzB,CAAC,EAAE,MAAM,CAAC,CAAC;QACX,CAAC,EAAE,MAAM,CAAC,CAAC;KACZ,CAAC,EACF,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,CAAC,CAC3C,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Hooks file for functions that handle the communication between a Plugin and its Host\n */\n\nimport {\n LegacyRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState\n} from 'react';\n\nimport { IFRAME_MOUNTED, IFRAME_READY, IFRAME_UNMOUNTED } from './constants';\nimport { MessageEventCallback } from './types';\n\n/* Listening for events */\n\n/**\n * Dynamically add an event listener to the provided source window.\n * The source window can be the global parent (ie. the \"window\" object in the browser)\n * or it can be the content window of an individual element (ie. iFrame plugin container)\n */\nexport function useMessageEvent(srcWindow: Window | null, type: string, callback: MessageEventCallback) {\n // useLayoutEffect is called before the browser repaints the screen\n useLayoutEffect(() => {\n // Create a listener callback function\n const listener = (event: MessageEvent<{ type: string; payload: any }>) => {\n // Filter messages to those from our source window.\n // NOTE: the \"srcWindow\" is determined by the below useHostEvent and usePluginEvent functions\n if (event.source === srcWindow) {\n // Fire callback if the type from the listened event matches the type from the message event\n if (event.data.type === type) {\n callback({ type, payload: event.data.payload });\n }\n }\n };\n // Add the listener to the global object if the srcWindow is not null\n if (srcWindow !== null) {\n global.addEventListener('message', listener);\n }\n // useEffect cleanup\n return () => {\n global.removeEventListener('message', listener);\n };\n }, [srcWindow, type, callback]);\n}\n\n/**\n * Called by the Plugin component to use events that were listened to (ie. PLUGIN_RESIZE)\n */\nexport function useHostEvent(type: string, callback: MessageEventCallback) {\n useMessageEvent(global.parent, type, callback);\n}\n\n/**\n * Used to listen for events from a wrapped Plugin element (eg. PluginContainerIframe)\n *\n * @param element - Plugin element (eg. <iframe>)\n * @param type - Event type (eg. PLUGIN_RESIZE)\n * @param callback - Function to call when the event is triggered\n */\nexport function usePluginEvent(element: HTMLIFrameElement | undefined, type: string, callback: MessageEventCallback) {\n const contentWindow = element ? element.contentWindow : null;\n useMessageEvent(contentWindow, type, callback);\n}\n\n/** Dispatching events */\n\n/**\n * Base dispatch function called by dispatchHostEvent and dispatchPluginEvent.\n * Uses the `postMessage` method to enable cross-origin communication between Window objects\n *\n * @param targetWindow - Window that the message event is being dispatched to\n * @param message - Data object for the message\n * @param targetOrigin - URL for the window that the message event is being dispatched from\n */\nexport function dispatchMessageEvent(targetWindow: Window | null, message: any, targetOrigin: string) {\n /** Checking targetOrigin falsiness here since '', null or undefined would all be\n * reasons not to try to post a message to the origin.\n */\n if (targetWindow && targetOrigin) {\n targetWindow.postMessage(message, targetOrigin);\n }\n}\n\n/**\n * Used to dispatch events for a Plugin\n *\n * @param element - Plugin element (eg. <iframe>)\n * @param message - Data object for the message\n * @param targetOrigin - URL for the window that the message event is being dispatched from\n */\nexport function dispatchPluginEvent(element: HTMLIFrameElement, message: any, targetOrigin: string) {\n dispatchMessageEvent(element.contentWindow, message, targetOrigin);\n}\n\n/**\n * Used to dispatch events for the Host\n *\n * @param message - Data object for the message\n */\nexport function dispatchHostEvent(message: any) {\n dispatchMessageEvent(global.parent, message, global.document.referrer);\n}\n\n// Called inside Plugin when 'ready' prop is true\nexport function dispatchReadyEvent() {\n dispatchHostEvent({ type: IFRAME_READY });\n}\n\n// Below mounted events are called in a useEffect inside Plugin with [] dependencies — https://react.dev/learn/synchronizing-with-effects\nexport function dispatchMountedEvent() {\n dispatchHostEvent({ type: IFRAME_MOUNTED });\n}\n\nexport function dispatchUnmountedEvent() {\n dispatchHostEvent({ type: IFRAME_UNMOUNTED });\n}\n\n/**\n * Used to determine the size of an element as it is being resized in the browser.\n * ResizeObserver (https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver) is used to maintain a reference to the element's content/border box.\n *\n * @returns Memoized value that contains a reference to the Plugin element (eg. iframe)\n */\nexport function useElementSize() {\n // Holds a reference to the ResizeObserver\n const observerRef = useRef<ResizeObserver | null>(null);\n\n const [dimensions, setDimensions] = useState({ width: 0, height: 0 });\n const [offset, setOffset] = useState({ x: 0, y: 0 });\n const [element, setElement] = useState<HTMLIFrameElement | undefined>();\n // Sets a reference to the Plugin element when passed to the Plugin element as a \"ref\" attribute (eg. <iframe>)\n const measuredRef: LegacyRef<HTMLIFrameElement> = useCallback(_element => {\n setElement(_element);\n }, []);\n\n useEffect(() => {\n // Create a new ResizeObserver\n observerRef.current = new ResizeObserver(() => {\n if (element) {\n // Set dimensions and any offset\n setDimensions({\n width: element.clientWidth,\n height: element.clientHeight,\n });\n setOffset({\n x: element.offsetLeft,\n y: element.offsetTop,\n });\n }\n });\n if (element) {\n // Tell the ResizeObserver to start watching the element — this enables the hook to detect resizing\n observerRef.current.observe(element);\n }\n }, [element]);\n\n return useMemo<{\n ref: LegacyRef<HTMLIFrameElement>;\n element: HTMLIFrameElement | undefined;\n width: number;\n height: number;\n x: number;\n y: number;\n }>(\n () => ({\n ref: measuredRef,\n element: element,\n width: dimensions.width,\n height: dimensions.height,\n x: offset.x,\n y: offset.y\n }),\n [measuredRef, element, dimensions, offset],\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/types.ts"],"names":[],"mappings":"AAMA,CAAC","sourcesContent":["export interface MessageEventCallbackParams {\n type: string,\n payload: any,\n}\n\nexport type MessageEventCallback = ({ type, payload }: MessageEventCallbackParams) => void;\n;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../runtime/slots/widget/iframe/types.ts"],"names":[],"mappings":"AAMA,CAAC","sourcesContent":["export interface MessageEventCallbackParams {\n type: string;\n payload: any;\n}\n\nexport type MessageEventCallback = ({ type, payload }: MessageEventCallbackParams) => void;\n;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../runtime/slots/widget/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,CAAN,IAAY,oBAmCX;AAnCD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,+CAAuB,CAAA;IAEvB;;OAEG;IACH,iDAAyB,CAAA;IAEzB;;OAEG;IACH,0DAAkC,CAAA;IAElC;;OAEG;IACH,4DAAoC,CAAA;IAEpC;;OAEG;IACH,iDAAyB,CAAA;IAEzB;;OAEG;IACH,+CAAuB,CAAA;IAEvB;;OAEG;IACH,iDAAyB,CAAA;AAC3B,CAAC,EAnCW,oBAAoB,KAApB,oBAAoB,QAmC/B","sourcesContent":["/**\n * Base UI Widget Operations\n *\n * \"Widget\" operations are a sub-type of UI operations which allow manipulation of the list of widgets (UI components) loaded into the slot. Widget operations are divided further into two sub-types: absolute and relative.\n *\n * Absolute widget operations allow simple list operations like appending and prepending which don't depend on any other list elements.\n *\n * Relative widget operations depend on a relationship to some other list element, such as \"insert before\" and \"insert after\". Some affect those elements, some add something to the list near them.\n */\n\nimport { ReactNode } from 'react';\nimport { BaseSlotOperation } from '../types';\n\nexport enum WidgetOperationTypes {\n /**\n * Adds a widget to the end of the slot's list of widgets.\n */\n APPEND = 'widgetAppend',\n\n /**\n * Adds a widget to the beginning of the slot's list of widgets.\n */\n PREPEND = 'widgetPrepend',\n\n /**\n * Adds a widget after the specified widget ID. Multiple \"insert after\" operations on the same widget ID occur in the order they were declared.\n */\n INSERT_AFTER = 'widgetInsertAfter',\n\n /**\n * Adds a widget before the specified widget ID. Multiple \"insert after\" operations on the same widget ID occur in the order they were declared.\n */\n INSERT_BEFORE = 'widgetInsertBefore',\n\n /**\n * Removes the specified widget ID and adds a widget in its place. Multiple \"replace\" operations on the same widget ID occur in the order they were declared, and only the first will succeed unless the new widget's ID is the same as the one that was removed.\n */\n REPLACE = 'widgetReplace',\n\n /**\n * Removes the specified widget ID from the slot's list of widgets. Subsequent relative widget operations on that widget ID will not be applied.\n */\n REMOVE = 'widgetRemove',\n\n /**\n * Provides options to the specified widget ID. Multiple \"options\" operations on the same widget ID will merge with and override any duplicate properties in the options object - last one in wins.\n */\n OPTIONS = 'widgetOptions',\n}\n\nexport type AbsoluteWidgetOperationTypes = WidgetOperationTypes.APPEND | WidgetOperationTypes.PREPEND;\n\nexport type RelativeWidgetOperationTypes = WidgetOperationTypes.INSERT_AFTER | WidgetOperationTypes.INSERT_BEFORE | WidgetOperationTypes.REPLACE | WidgetOperationTypes.OPTIONS;\n\nexport interface BaseWidgetOperation extends BaseSlotOperation {\n op: WidgetOperationTypes,\n}\n\n// Widget renderer props\n\nexport interface WidgetComponentProps {\n component: React.ComponentType,\n}\n\nexport interface WidgetElementProps {\n element: ReactNode,\n}\n\nexport interface WidgetIFrameProps {\n url: string,\n title: string,\n}\n\nexport type WidgetRendererProps = (\n WidgetComponentProps | WidgetElementProps | WidgetIFrameProps\n);\n\nexport interface WidgetIdentityProps {\n id: string,\n role?: string,\n}\n\nexport interface WidgetRelationshipProps {\n relatedId: string,\n}\n\n// Concrete UI Widget Operations\n\nexport type WidgetAppendOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & {\n op: WidgetOperationTypes.APPEND,\n};\n\nexport type WidgetPrependOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & {\n op: WidgetOperationTypes.PREPEND,\n};\n\nexport type WidgetInsertAfterOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & WidgetRelationshipProps & {\n op: WidgetOperationTypes.INSERT_AFTER,\n};\n\nexport type WidgetInsertBeforeOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & WidgetRelationshipProps & {\n op: WidgetOperationTypes.INSERT_BEFORE,\n};\n\nexport type WidgetRemoveOperation = BaseWidgetOperation & WidgetRelationshipProps & {\n op: WidgetOperationTypes.REMOVE,\n};\n\nexport type WidgetOptionsOperation = BaseWidgetOperation & WidgetRelationshipProps & {\n op: WidgetOperationTypes.OPTIONS,\n options: Record<string, unknown>,\n};\n\nexport type WidgetReplaceOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & WidgetRelationshipProps & { op: WidgetOperationTypes.REPLACE };\n\nexport type WidgetAbsoluteOperation = WidgetAppendOperation | WidgetPrependOperation;\n\nexport type WidgetRelativeRendererOperation = WidgetInsertAfterOperation | WidgetInsertBeforeOperation | WidgetReplaceOperation;\n\nexport type WidgetRelativeOperation = WidgetRelativeRendererOperation | WidgetRemoveOperation | WidgetOptionsOperation;\n\nexport type WidgetRendererOperation = WidgetAbsoluteOperation | WidgetRelativeRendererOperation;\n\nexport type WidgetOperation = WidgetAbsoluteOperation | WidgetRelativeOperation;\n\n/**\n * An identified widget is a simple data structure to associate an ID with a ReactNode so we can\n * apply widget operations to our list of widgets. It helps us find a ReactNode with a particular\n * ID for relative widget operations.\n */\nexport interface IdentifiedWidget {\n id: string,\n role?: string,\n node: ReactNode,\n}\n\nexport interface WidgetList extends Array<ReactNode> {\n identified: IdentifiedWidget[],\n byId(id: string): ReactNode[],\n withoutId(id: string): ReactNode[],\n byRole(role: string): ReactNode[],\n withoutRole(role: string): ReactNode[],\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../runtime/slots/widget/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,CAAN,IAAY,oBAmCX;AAnCD,WAAY,oBAAoB;IAC9B;;OAEG;IACH,+CAAuB,CAAA;IAEvB;;OAEG;IACH,iDAAyB,CAAA;IAEzB;;OAEG;IACH,0DAAkC,CAAA;IAElC;;OAEG;IACH,4DAAoC,CAAA;IAEpC;;OAEG;IACH,iDAAyB,CAAA;IAEzB;;OAEG;IACH,+CAAuB,CAAA;IAEvB;;OAEG;IACH,iDAAyB,CAAA;AAC3B,CAAC,EAnCW,oBAAoB,KAApB,oBAAoB,QAmC/B","sourcesContent":["/**\n * Base UI Widget Operations\n *\n * \"Widget\" operations are a sub-type of UI operations which allow manipulation of the list of widgets (UI components) loaded into the slot. Widget operations are divided further into two sub-types: absolute and relative.\n *\n * Absolute widget operations allow simple list operations like appending and prepending which don't depend on any other list elements.\n *\n * Relative widget operations depend on a relationship to some other list element, such as \"insert before\" and \"insert after\". Some affect those elements, some add something to the list near them.\n */\n\nimport { ReactNode } from 'react';\nimport { BaseSlotOperation } from '../types';\n\nexport enum WidgetOperationTypes {\n /**\n * Adds a widget to the end of the slot's list of widgets.\n */\n APPEND = 'widgetAppend',\n\n /**\n * Adds a widget to the beginning of the slot's list of widgets.\n */\n PREPEND = 'widgetPrepend',\n\n /**\n * Adds a widget after the specified widget ID. Multiple \"insert after\" operations on the same widget ID occur in the order they were declared.\n */\n INSERT_AFTER = 'widgetInsertAfter',\n\n /**\n * Adds a widget before the specified widget ID. Multiple \"insert after\" operations on the same widget ID occur in the order they were declared.\n */\n INSERT_BEFORE = 'widgetInsertBefore',\n\n /**\n * Removes the specified widget ID and adds a widget in its place. Multiple \"replace\" operations on the same widget ID occur in the order they were declared, and only the first will succeed unless the new widget's ID is the same as the one that was removed.\n */\n REPLACE = 'widgetReplace',\n\n /**\n * Removes the specified widget ID from the slot's list of widgets. Subsequent relative widget operations on that widget ID will not be applied.\n */\n REMOVE = 'widgetRemove',\n\n /**\n * Provides options to the specified widget ID. Multiple \"options\" operations on the same widget ID will merge with and override any duplicate properties in the options object - last one in wins.\n */\n OPTIONS = 'widgetOptions',\n}\n\nexport type AbsoluteWidgetOperationTypes = WidgetOperationTypes.APPEND | WidgetOperationTypes.PREPEND;\n\nexport type RelativeWidgetOperationTypes = WidgetOperationTypes.INSERT_AFTER | WidgetOperationTypes.INSERT_BEFORE | WidgetOperationTypes.REPLACE | WidgetOperationTypes.OPTIONS;\n\nexport interface BaseWidgetOperation extends BaseSlotOperation {\n op: WidgetOperationTypes;\n}\n\n// Widget renderer props\n\nexport interface WidgetComponentProps {\n component: React.ComponentType;\n}\n\nexport interface WidgetElementProps {\n element: ReactNode;\n}\n\nexport interface WidgetIFrameProps {\n url: string;\n title: string;\n}\n\nexport type WidgetRendererProps = (\n WidgetComponentProps | WidgetElementProps | WidgetIFrameProps\n);\n\nexport interface WidgetIdentityProps {\n id: string;\n role?: string;\n}\n\nexport interface WidgetRelationshipProps {\n relatedId: string;\n}\n\n// Concrete UI Widget Operations\n\nexport type WidgetAppendOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & {\n op: WidgetOperationTypes.APPEND;\n};\n\nexport type WidgetPrependOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & {\n op: WidgetOperationTypes.PREPEND;\n};\n\nexport type WidgetInsertAfterOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & WidgetRelationshipProps & {\n op: WidgetOperationTypes.INSERT_AFTER;\n};\n\nexport type WidgetInsertBeforeOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & WidgetRelationshipProps & {\n op: WidgetOperationTypes.INSERT_BEFORE;\n};\n\nexport type WidgetRemoveOperation = BaseWidgetOperation & WidgetRelationshipProps & {\n op: WidgetOperationTypes.REMOVE;\n};\n\nexport type WidgetOptionsOperation = BaseWidgetOperation & WidgetRelationshipProps & {\n op: WidgetOperationTypes.OPTIONS;\n options: Record<string, unknown>;\n};\n\nexport type WidgetReplaceOperation = BaseWidgetOperation & WidgetIdentityProps & WidgetRendererProps & WidgetRelationshipProps & { op: WidgetOperationTypes.REPLACE };\n\nexport type WidgetAbsoluteOperation = WidgetAppendOperation | WidgetPrependOperation;\n\nexport type WidgetRelativeRendererOperation = WidgetInsertAfterOperation | WidgetInsertBeforeOperation | WidgetReplaceOperation;\n\nexport type WidgetRelativeOperation = WidgetRelativeRendererOperation | WidgetRemoveOperation | WidgetOptionsOperation;\n\nexport type WidgetRendererOperation = WidgetAbsoluteOperation | WidgetRelativeRendererOperation;\n\nexport type WidgetOperation = WidgetAbsoluteOperation | WidgetRelativeOperation;\n\n/**\n * An identified widget is a simple data structure to associate an ID with a ReactNode so we can\n * apply widget operations to our list of widgets. It helps us find a ReactNode with a particular\n * ID for relative widget operations.\n */\nexport interface IdentifiedWidget {\n id: string;\n role?: string;\n node: ReactNode;\n}\n\nexport interface WidgetList extends Array<ReactNode> {\n identified: IdentifiedWidget[];\n byId(id: string): ReactNode[];\n withoutId(id: string): ReactNode[];\n byRole(role: string): ReactNode[];\n withoutRole(role: string): ReactNode[];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"initializeMockApp.js","sourceRoot":"","sources":["../../../runtime/testing/initializeMockApp.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,QAAQ,GAAG,YAAY,EACvB,iBAAiB,GAAG,IAAI,MAItB,EAAE;IACJ,MAAM,MAAM,GAAG,UAAU,CAAC;IAC1B,eAAe,CAAC,MAAM,CAAC,CAAC;IAExB,MAAM,cAAc,GAAG,gBAAgB,CAAC,kBAAkB,EAAE;QAC1D,MAAM,EAAE,aAAa,EAAE;KACxB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,EAAE;QACjD,MAAM,EAAE,aAAa,EAAE;QACvB,cAAc;KACf,CAAC,CAAC;IAEH,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAExC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,oBAAoB,EAAE;QAChE,MAAM,EAAE,aAAa,EAAE;QACvB,UAAU,EAAE,WAAW,CAAC,0BAA0B,EAAE;QACpD,cAAc;KACf,CAAC,CAAC;IAEH,kGAAkG;IAClG,aAAa,CAAC;QACZ,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO;QACL,gBAAgB;QAChB,WAAW;QACX,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import siteConfig from 'site.config';\n\nimport { LocalizedMessages, User } from '../../types';\n\nimport { configureAnalytics, MockAnalyticsService } from '../analytics';\nimport { configureAuth, MockAuthService, setAuthenticatedUser } from '../auth';\nimport { getSiteConfig, mergeSiteConfig } from '../config';\nimport { configureI18n } from '../i18n';\nimport { configureLogging, MockLoggingService } from '../logging';\nimport mockMessages from './mockMessages';\n\n/**\n * Initializes a mock application for component testing. The mock application includes\n * mock analytics, auth, and logging services, and the real i18n service.\n *\n * See MockAnalyticsService, MockAuthService, and MockLoggingService for mock implementation\n * details. For the most part, the analytics and logging services just implement their functions\n * with jest.fn() and do nothing else, whereas the MockAuthService actually has some behavior\n * implemented, it just doesn't make any HTTP calls.\n *\n * Note that this mock application is not sufficient for testing the full application lifecycle or\n * initialization callbacks/custom handlers as described in the 'initialize' function's\n * documentation. It exists merely to set up the mock services that components themselves tend to\n * interact with most often. It could be extended to allow for setting up custom handlers fairly\n * easily, as this functionality would be more-or-less identical to what the real initialize\n * function does.\n *\n * Example:\n *\n * ```\n * import { initializeMockApp, logInfo } from '@openedx/frontend-base';\n *\n * describe('initializeMockApp', () => {\n * it('mocks things correctly', () => {\n * const { loggingService } = initializeMockApp();\n * logInfo('test', {});\n * expect(loggingService.logInfo).toHaveBeenCalledWith('test', {});\n * });\n * });\n * ```\n *\n * @param {Object} [options]\n * @param {*} [options.messages] A i18n-compatible messages object, or an array of such objects. If\n * an array is provided, duplicate keys are resolved with the last-one-in winning.\n * @param {UserData|null} [options.authenticatedUser] A UserData object representing the\n * authenticated user. This is passed directly to MockAuthService.\n * @memberof module:Testing\n */\nexport default function initializeMockApp({\n messages = mockMessages,\n authenticatedUser = null,\n}: {\n messages?: LocalizedMessages,\n authenticatedUser?: User | null,\n} = {}) {\n const config = siteConfig;\n mergeSiteConfig(config);\n\n const loggingService = configureLogging(MockLoggingService, {\n config: getSiteConfig(),\n });\n\n const authService = configureAuth(MockAuthService, {\n config: getSiteConfig(),\n loggingService,\n });\n\n setAuthenticatedUser(authenticatedUser);\n\n const analyticsService = configureAnalytics(MockAnalyticsService, {\n config: getSiteConfig(),\n httpClient: authService.getAuthenticatedHttpClient(),\n loggingService,\n });\n\n // The i18n service configureI18n function has no return value, since there isn't a service class.\n configureI18n({\n messages,\n });\n\n return {\n analyticsService,\n authService,\n loggingService,\n };\n}\n"]}
1
+ {"version":3,"file":"initializeMockApp.js","sourceRoot":"","sources":["../../../runtime/testing/initializeMockApp.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AAIrC,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAC,EACxC,QAAQ,GAAG,YAAY,EACvB,iBAAiB,GAAG,IAAI,MAItB,EAAE;IACJ,MAAM,MAAM,GAAG,UAAU,CAAC;IAC1B,eAAe,CAAC,MAAM,CAAC,CAAC;IAExB,MAAM,cAAc,GAAG,gBAAgB,CAAC,kBAAkB,EAAE;QAC1D,MAAM,EAAE,aAAa,EAAE;KACxB,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,aAAa,CAAC,eAAe,EAAE;QACjD,MAAM,EAAE,aAAa,EAAE;QACvB,cAAc;KACf,CAAC,CAAC;IAEH,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IAExC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,oBAAoB,EAAE;QAChE,MAAM,EAAE,aAAa,EAAE;QACvB,UAAU,EAAE,WAAW,CAAC,0BAA0B,EAAE;QACpD,cAAc;KACf,CAAC,CAAC;IAEH,kGAAkG;IAClG,aAAa,CAAC;QACZ,QAAQ;KACT,CAAC,CAAC;IAEH,OAAO;QACL,gBAAgB;QAChB,WAAW;QACX,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["import siteConfig from 'site.config';\n\nimport { LocalizedMessages, User } from '../../types';\n\nimport { configureAnalytics, MockAnalyticsService } from '../analytics';\nimport { configureAuth, MockAuthService, setAuthenticatedUser } from '../auth';\nimport { getSiteConfig, mergeSiteConfig } from '../config';\nimport { configureI18n } from '../i18n';\nimport { configureLogging, MockLoggingService } from '../logging';\nimport mockMessages from './mockMessages';\n\n/**\n * Initializes a mock application for component testing. The mock application includes\n * mock analytics, auth, and logging services, and the real i18n service.\n *\n * See MockAnalyticsService, MockAuthService, and MockLoggingService for mock implementation\n * details. For the most part, the analytics and logging services just implement their functions\n * with jest.fn() and do nothing else, whereas the MockAuthService actually has some behavior\n * implemented, it just doesn't make any HTTP calls.\n *\n * Note that this mock application is not sufficient for testing the full application lifecycle or\n * initialization callbacks/custom handlers as described in the 'initialize' function's\n * documentation. It exists merely to set up the mock services that components themselves tend to\n * interact with most often. It could be extended to allow for setting up custom handlers fairly\n * easily, as this functionality would be more-or-less identical to what the real initialize\n * function does.\n *\n * Example:\n *\n * ```\n * import { initializeMockApp, logInfo } from '@openedx/frontend-base';\n *\n * describe('initializeMockApp', () => {\n * it('mocks things correctly', () => {\n * const { loggingService } = initializeMockApp();\n * logInfo('test', {});\n * expect(loggingService.logInfo).toHaveBeenCalledWith('test', {});\n * });\n * });\n * ```\n *\n * @param {Object} [options]\n * @param {*} [options.messages] A i18n-compatible messages object, or an array of such objects. If\n * an array is provided, duplicate keys are resolved with the last-one-in winning.\n * @param {UserData|null} [options.authenticatedUser] A UserData object representing the\n * authenticated user. This is passed directly to MockAuthService.\n * @memberof module:Testing\n */\nexport default function initializeMockApp({\n messages = mockMessages,\n authenticatedUser = null,\n}: {\n messages?: LocalizedMessages;\n authenticatedUser?: User | null;\n} = {}) {\n const config = siteConfig;\n mergeSiteConfig(config);\n\n const loggingService = configureLogging(MockLoggingService, {\n config: getSiteConfig(),\n });\n\n const authService = configureAuth(MockAuthService, {\n config: getSiteConfig(),\n loggingService,\n });\n\n setAuthenticatedUser(authenticatedUser);\n\n const analyticsService = configureAnalytics(MockAnalyticsService, {\n config: getSiteConfig(),\n httpClient: authService.getAuthenticatedHttpClient(),\n loggingService,\n });\n\n // The i18n service configureI18n function has no return value, since there isn't a service class.\n configureI18n({\n messages,\n });\n\n return {\n analyticsService,\n authService,\n loggingService,\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Logo.js","sourceRoot":"","sources":["../../shell/Logo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAGjB;;QAHiB,EAC3B,QAAQ,GAAG,MAAA,aAAa,EAAE,CAAC,kBAAkB,mCAAI,yCAAyC,EAC1F,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,GAAG;IAEnD,MAAM,KAAK,GAAG,CACZ,KAAC,KAAK,IAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAI,CACvD,CAAC;IAEF,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CACL,KAAC,YAAY,IAAC,MAAM,EAAC,IAAI,YACvB,KAAC,SAAS,IAAC,WAAW,EAAE,cAAc,EAAE,SAAS,EAAC,KAAK,YACpD,KAAK,GACI,GACC,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { IntlProvider } from 'react-intl';\nimport { Hyperlink, Image } from '@openedx/paragon';\nimport { getSiteConfig } from '../runtime/config';\nimport { getUrlByRouteRole } from '../runtime/routing';\nimport { homeRole } from './constants';\n\ninterface LogoProps {\n imageUrl?: string,\n destinationUrl?: string,\n}\n\nexport default function Logo({\n imageUrl = getSiteConfig().headerLogoImageUrl ?? 'https://edx-cdn.org/v3/default/logo.svg',\n destinationUrl = getUrlByRouteRole(homeRole) || '/'\n}: LogoProps) {\n const image = (\n <Image src={imageUrl} style={{ maxHeight: '2rem' }} />\n );\n\n if (destinationUrl === undefined) {\n return image;\n }\n\n return (\n <IntlProvider locale=\"en\">\n <Hyperlink destination={destinationUrl} className=\"p-0\">\n {image}\n </Hyperlink>\n </IntlProvider>\n );\n}\n"]}
1
+ {"version":3,"file":"Logo.js","sourceRoot":"","sources":["../../shell/Logo.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAOvC,MAAM,CAAC,OAAO,UAAU,IAAI,CAAC,EAGjB;;QAHiB,EAC3B,QAAQ,GAAG,MAAA,aAAa,EAAE,CAAC,kBAAkB,mCAAI,yCAAyC,EAC1F,cAAc,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,GAAG;IAEnD,MAAM,KAAK,GAAG,CACZ,KAAC,KAAK,IAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAI,CACvD,CAAC;IAEF,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CACL,KAAC,YAAY,IAAC,MAAM,EAAC,IAAI,YACvB,KAAC,SAAS,IAAC,WAAW,EAAE,cAAc,EAAE,SAAS,EAAC,KAAK,YACpD,KAAK,GACI,GACC,CAChB,CAAC;AACJ,CAAC","sourcesContent":["import { IntlProvider } from 'react-intl';\nimport { Hyperlink, Image } from '@openedx/paragon';\nimport { getSiteConfig } from '../runtime/config';\nimport { getUrlByRouteRole } from '../runtime/routing';\nimport { homeRole } from './constants';\n\ninterface LogoProps {\n imageUrl?: string;\n destinationUrl?: string;\n}\n\nexport default function Logo({\n imageUrl = getSiteConfig().headerLogoImageUrl ?? 'https://edx-cdn.org/v3/default/logo.svg',\n destinationUrl = getUrlByRouteRole(homeRole) || '/'\n}: LogoProps) {\n const image = (\n <Image src={imageUrl} style={{ maxHeight: '2rem' }} />\n );\n\n if (destinationUrl === undefined) {\n return image;\n }\n\n return (\n <IntlProvider locale=\"en\">\n <Hyperlink destination={destinationUrl} className=\"p-0\">\n {image}\n </Hyperlink>\n </IntlProvider>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BarContext.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/BarContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,OAAO,CAAC;AAK/D,CAAC;AAEF,MAAM,UAAU,GAAG,aAAa,CAAsB;IACpD,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;CAClB,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { createContext, Dispatch, SetStateAction } from 'react';\n\ninterface BarContextInterface {\n bar: string,\n setBar: Dispatch<SetStateAction<string>>,\n};\n\nconst BarContext = createContext<BarContextInterface>({\n bar: '',\n setBar: () => { }\n});\n\nexport default BarContext;\n"]}
1
+ {"version":3,"file":"BarContext.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/BarContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,OAAO,CAAC;AAK/D,CAAC;AAEF,MAAM,UAAU,GAAG,aAAa,CAAsB;IACpD,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;CAClB,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { createContext, Dispatch, SetStateAction } from 'react';\n\ninterface BarContextInterface {\n bar: string;\n setBar: Dispatch<SetStateAction<string>>;\n};\n\nconst BarContext = createContext<BarContextInterface>({\n bar: '',\n setBar: () => { }\n});\n\nexport default BarContext;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"BarProvider.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/BarProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,SAAS,MAAM;IACb,OAAO,KAAK,CAAC;AACf,CAAC;AAMD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAoB;IAChE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEzC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrC,GAAG;QACH,MAAM;KACP,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YACxC,QAAQ,GACW,CACvB,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\nimport BarContext from './BarContext';\n\nfunction getBar() {\n return 'Bar';\n}\n\ninterface BarProviderProps {\n children?: ReactNode,\n}\n\nexport default function BarProvider({ children }: BarProviderProps) {\n const [bar, setBar] = useState(getBar());\n\n const barContextValue = useMemo(() => ({\n bar,\n setBar,\n }), [bar, setBar]);\n\n return (\n <BarContext.Provider value={barContextValue}>\n {children}\n </BarContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"BarProvider.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/BarProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,SAAS,MAAM;IACb,OAAO,KAAK,CAAC;AACf,CAAC;AAMD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAoB;IAChE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEzC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrC,GAAG;QACH,MAAM;KACP,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YACxC,QAAQ,GACW,CACvB,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\nimport BarContext from './BarContext';\n\nfunction getBar() {\n return 'Bar';\n}\n\ninterface BarProviderProps {\n children?: ReactNode;\n}\n\nexport default function BarProvider({ children }: BarProviderProps) {\n const [bar, setBar] = useState(getBar());\n\n const barContextValue = useMemo(() => ({\n bar,\n setBar,\n }), [bar, setBar]);\n\n return (\n <BarContext.Provider value={barContextValue}>\n {children}\n </BarContext.Provider>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FooContext.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/FooContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,OAAO,CAAC;AAK/D,CAAC;AAEF,MAAM,UAAU,GAAG,aAAa,CAAsB;IACpD,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;CAClB,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { createContext, Dispatch, SetStateAction } from 'react';\n\ninterface FooContextInterface {\n foo: string,\n setFoo: Dispatch<SetStateAction<string>>,\n};\n\nconst FooContext = createContext<FooContextInterface>({\n foo: '',\n setFoo: () => { }\n});\n\nexport default FooContext;\n"]}
1
+ {"version":3,"file":"FooContext.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/FooContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA4B,MAAM,OAAO,CAAC;AAK/D,CAAC;AAEF,MAAM,UAAU,GAAG,aAAa,CAAsB;IACpD,GAAG,EAAE,EAAE;IACP,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;CAClB,CAAC,CAAC;AAEH,eAAe,UAAU,CAAC","sourcesContent":["import { createContext, Dispatch, SetStateAction } from 'react';\n\ninterface FooContextInterface {\n foo: string;\n setFoo: Dispatch<SetStateAction<string>>;\n};\n\nconst FooContext = createContext<FooContextInterface>({\n foo: '',\n setFoo: () => { }\n});\n\nexport default FooContext;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FooProvider.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/FooProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,SAAS,MAAM;IACb,OAAO,KAAK,CAAC;AACf,CAAC;AAMD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAoB;IAChE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEzC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrC,GAAG;QACH,MAAM;KACP,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YACxC,QAAQ,GACW,CACvB,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\nimport FooContext from './FooContext';\n\nfunction getFoo() {\n return 'Foo';\n}\n\ninterface FooProviderProps {\n children?: ReactNode,\n}\n\nexport default function FooProvider({ children }: FooProviderProps) {\n const [foo, setFoo] = useState(getFoo());\n\n const fooContextValue = useMemo(() => ({\n foo,\n setFoo,\n }), [foo, setFoo]);\n\n return (\n <FooContext.Provider value={fooContextValue}>\n {children}\n </FooContext.Provider>\n );\n};\n"]}
1
+ {"version":3,"file":"FooProvider.js","sourceRoot":"","sources":["../../../../shell/dev/devHeader/FooProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAa,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,UAAU,MAAM,cAAc,CAAC;AAEtC,SAAS,MAAM;IACb,OAAO,KAAK,CAAC;AACf,CAAC;AAMD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAAE,QAAQ,EAAoB;IAChE,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAEzC,MAAM,eAAe,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QACrC,GAAG;QACH,MAAM;KACP,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,eAAe,YACxC,QAAQ,GACW,CACvB,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import { ReactNode, useMemo, useState } from 'react';\nimport FooContext from './FooContext';\n\nfunction getFoo() {\n return 'Foo';\n}\n\ninterface FooProviderProps {\n children?: ReactNode;\n}\n\nexport default function FooProvider({ children }: FooProviderProps) {\n const [foo, setFoo] = useState(getFoo());\n\n const fooContextValue = useMemo(() => ({\n foo,\n setFoo,\n }), [foo, setFoo]);\n\n return (\n <FooContext.Provider value={fooContextValue}>\n {children}\n </FooContext.Provider>\n );\n};\n"]}