@openedx/frontend-base 1.0.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.
- package/README.md +1 -1
- package/dist/runtime/config/index.js.map +1 -1
- package/dist/runtime/i18n/index.d.ts +26 -3
- package/dist/runtime/i18n/index.js +2 -53
- package/dist/runtime/i18n/index.js.map +1 -1
- package/dist/runtime/i18n/lib.d.ts +0 -12
- package/dist/runtime/i18n/lib.js +0 -12
- package/dist/runtime/i18n/lib.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/jest.config.js +1 -1
- package/dist/runtime/jest.config.js.map +1 -1
- package/dist/runtime/logging/types.js.map +1 -1
- package/dist/runtime/react/CombinedAppProvider.js.map +1 -1
- package/dist/runtime/react/CurrentAppContext.js.map +1 -1
- package/dist/runtime/react/CurrentAppProvider.js.map +1 -1
- package/dist/runtime/react/SiteContext.js.map +1 -1
- package/dist/runtime/react/SiteProvider.js.map +1 -1
- package/dist/runtime/react/hooks/theme/useThemeVariants.js.map +1 -1
- package/dist/runtime/slots/Slot.js.map +1 -1
- package/dist/runtime/slots/SlotContext.js.map +1 -1
- package/dist/runtime/slots/layout/types.js.map +1 -1
- package/dist/runtime/slots/types.js.map +1 -1
- package/dist/runtime/slots/widget/WidgetContext.js.map +1 -1
- package/dist/runtime/slots/widget/WidgetProvider.js.map +1 -1
- package/dist/runtime/slots/widget/iframe/IFrameContentWrapper.js.map +1 -1
- package/dist/runtime/slots/widget/iframe/IFrameWidget.js.map +1 -1
- package/dist/runtime/slots/widget/iframe/hooks.js.map +1 -1
- package/dist/runtime/slots/widget/iframe/types.js.map +1 -1
- package/dist/runtime/slots/widget/types.js.map +1 -1
- package/dist/runtime/testing/initializeMockApp.js.map +1 -1
- package/dist/shell/Logo.js.map +1 -1
- package/dist/shell/dev/devHeader/BarContext.js.map +1 -1
- package/dist/shell/dev/devHeader/BarProvider.js.map +1 -1
- package/dist/shell/dev/devHeader/FooContext.js.map +1 -1
- package/dist/shell/dev/devHeader/FooProvider.js.map +1 -1
- package/dist/shell/dev/slotShowcase/SlotShowcasePage.js.map +1 -1
- package/dist/shell/dev/slotShowcase/app.js.map +1 -1
- package/dist/shell/footer/CopyrightNotice.js.map +1 -1
- package/dist/shell/footer/LanguageMenuItem.js.map +1 -1
- package/dist/shell/header/AuthenticatedMenu.js.map +1 -1
- package/dist/shell/header/HelpButton.js.map +1 -1
- package/dist/shell/header/anonymous-menu/AnonymousMenu.js.map +1 -1
- package/dist/shell/header/course-bar/data/service.js.map +1 -1
- package/dist/shell/header/course-bar/masquerade/StudioLink.js.map +1 -1
- package/dist/shell/header/course-bar/masquerade/data/api.js.map +1 -1
- package/dist/shell/header/course-bar/masquerade/hooks.js.map +1 -1
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeUserNameInput.js.map +1 -1
- package/dist/shell/header/course-bar/masquerade/masquerade-widget/MasqueradeWidgetOption.js.map +1 -1
- package/dist/shell/header/course-bar/navigation/CourseTabsNavigation.js.map +1 -1
- package/dist/shell/header/helpButtonSlotOperation.js.map +1 -1
- package/dist/shell/jest.config.js +1 -1
- package/dist/shell/jest.config.js.map +1 -1
- package/dist/shell/menus/LinkMenuItem.js.map +1 -1
- package/dist/shell/menus/NavDropdownMenuSlot.js.map +1 -1
- package/dist/shell/menus/ProfileLinkMenuItem.js.map +1 -1
- package/dist/tools/eslint/base.eslint.config.js +2 -2
- package/dist/tools/jest/jest.config.js +1 -1
- package/dist/tools/jest.config.js +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
- package/dist/runtime/i18n/injectIntlWithShim.d.ts +0 -11
- package/dist/runtime/i18n/injectIntlWithShim.js +0 -45
- package/dist/runtime/i18n/injectIntlWithShim.js.map +0 -1
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ If a change requires corresponding updates to a consuming site (for example, new
|
|
|
36
36
|
|
|
37
37
|
### Releases
|
|
38
38
|
|
|
39
|
-
This library is published automatically to npm using `semantic-release`. On merges to `main`, `alpha` versions are published. Stable releases come from the `release` branch. See [ADR
|
|
39
|
+
This library is published automatically to npm using `semantic-release`. On merges to `main`, `alpha` versions are published. Stable releases come from the `release` branch. See [OEP-10 ADR 0002: Frontend Release Branches](https://open-edx-proposals.readthedocs.io/en/latest/processes/oep-0010/decisions/0002-frontend-release-branches.html) for details.
|
|
40
40
|
|
|
41
41
|
## Further reading
|
|
42
42
|
|
|
@@ -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,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,IAAI,UAAU,GAAe;IAC3B,WAAW;IACX,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,EAAE;IACb,UAAU,EAAE,EAAE;IAEd,WAAW;IACX,WAAW,EAAE,gBAAgB,CAAC,UAAU;IACxC,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,EAAE;IACR,cAAc,EAAE,EAAE;IAClB,wBAAwB,EAAE,EAAE;IAC5B,oBAAoB,EAAE,IAAI;IAC1B,KAAK,EAAE,EAAE;IACT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GAAG,mBAAmB,EAAE,EAAE,GAAG,oBAAoB,EAAE,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,EAAU;IACpC,MAAM,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CAAC;IACjC,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IAErB,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,SAAS,EAAE,CAAC;YACnD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAU;IAC7C,OAAO,WAAW,CAAC,EAAE,CAAC;SACnB,MAAM,CAAC,CAAC,IAAI,EAA6B,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,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
|
+
{"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,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C,IAAI,UAAU,GAAe;IAC3B,WAAW;IACX,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,EAAE;IACX,QAAQ,EAAE,EAAE;IACZ,QAAQ,EAAE,EAAE;IACZ,SAAS,EAAE,EAAE;IACb,UAAU,EAAE,EAAE;IAEd,WAAW;IACX,WAAW,EAAE,gBAAgB,CAAC,UAAU;IACxC,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,EAAE;IACR,cAAc,EAAE,EAAE;IAClB,wBAAwB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ourcesContent":["/**\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,3 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* #### Import members from **@openedx/frontend-base**
|
|
3
|
+
* The i18n module relies on react-intl and re-exports all of that package's exports.
|
|
4
|
+
*
|
|
5
|
+
* For each locale we want to support, react-intl needs 1) the locale-data, which includes
|
|
6
|
+
* information about how to format numbers, handle plurals, etc., and 2) the translations, as an
|
|
7
|
+
* object holding message id / translated string pairs. A locale string and the messages object are
|
|
8
|
+
* passed into the IntlProvider element that wraps your element hierarchy.
|
|
9
|
+
*
|
|
10
|
+
* Note that react-intl has no way of checking if the translations you give it actually have
|
|
11
|
+
* anything to do with the locale you pass it; it will happily use whatever messages object you pass
|
|
12
|
+
* in. However, if the locale data for the locale you passed into the IntlProvider was not
|
|
13
|
+
* correctly installed with addLocaleData, all of your translations will fall back to the default
|
|
14
|
+
* (in our case English), *even if you gave IntlProvider the correct messages object for that
|
|
15
|
+
* locale*.
|
|
16
|
+
*
|
|
17
|
+
* Messages are provided to this module via the configureI18n() function below.
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* @module Internationalization
|
|
21
|
+
* @see {@link https://github.com/openedx/frontend-base/blob/master/docs/how_tos/i18n.rst}
|
|
22
|
+
* @see {@link https://formatjs.io/docs/react-intl/components/ Intl} for components exported from this module.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export { createIntl, defineMessages, FormattedDate, FormattedMessage, FormattedNumber, FormattedPlural, FormattedRelativeTime, FormattedTime, IntlProvider, useIntl, type IntlConfig, type ResolvedIntlConfig, type IntlShape, } from 'react-intl';
|
|
26
|
+
export { configureI18n, getLocale, getLocalizedLanguageName, getMessages, getPrimaryLanguageSubtag, getSupportedLanguageList, handleRtl, isRtl, LOCALE_CHANGED, LOCALE_TOPIC, mergeMessages, updateLocale, } from './lib';
|
|
@@ -22,57 +22,6 @@
|
|
|
22
22
|
* @see {@link https://formatjs.io/docs/react-intl/components/ Intl} for components exported from this module.
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
* @kind function
|
|
28
|
-
* @see {@link https://formatjs.io/docs/react-intl/api#createIntl Intl}
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* @name FormattedDate
|
|
32
|
-
* @kind class
|
|
33
|
-
* @see {@link https://formatjs.io/docs/react-intl/components/#formatteddate Intl}
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* @name FormattedTime
|
|
37
|
-
* @kind class
|
|
38
|
-
* @see {@link https://formatjs.io/docs/react-intl/components/#formattedtime Intl}
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* @name FormattedRelativeTime
|
|
42
|
-
* @kind class
|
|
43
|
-
* @see {@link https://formatjs.io/docs/react-intl/components/#formattedrelativetime Intl}
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* @name FormattedNumber
|
|
47
|
-
* @kind class
|
|
48
|
-
* @see {@link https://formatjs.io/docs/react-intl/components/#formattednumber Intl}
|
|
49
|
-
*/
|
|
50
|
-
/**
|
|
51
|
-
* @name FormattedPlural
|
|
52
|
-
* @kind class
|
|
53
|
-
* @see {@link https://formatjs.io/docs/react-intl/components/#formattedplural Intl}
|
|
54
|
-
*/
|
|
55
|
-
/**
|
|
56
|
-
* @name FormattedMessage
|
|
57
|
-
* @kind class
|
|
58
|
-
* @see {@link https://formatjs.io/docs/react-intl/components/#formattedmessage Intl}
|
|
59
|
-
*/
|
|
60
|
-
/**
|
|
61
|
-
* @name IntlProvider
|
|
62
|
-
* @kind class
|
|
63
|
-
* @see {@link https://formatjs.io/docs/react-intl/components/#intlprovider Intl}
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* @name defineMessages
|
|
67
|
-
* @kind function
|
|
68
|
-
* @see {@link https://formatjs.io/docs/react-intl/api#definemessagesdefinemessage Intl}
|
|
69
|
-
*/
|
|
70
|
-
/**
|
|
71
|
-
* @name useIntl
|
|
72
|
-
* @kind function
|
|
73
|
-
* @see {@link https://formatjs.io/docs/react-intl/api#useIntl Intl}
|
|
74
|
-
*/
|
|
75
|
-
export { createIntl, defineMessages, FormattedDate, FormattedMessage, FormattedNumber, FormattedPlural, FormattedRelativeTime, FormattedTime, IntlProvider, useIntl } from 'react-intl';
|
|
76
|
-
export { configureI18n, getLocale, getLocalizedLanguageName, getMessages, getPrimaryLanguageSubtag, getSupportedLanguageList, handleRtl, intlShape, isRtl, LOCALE_CHANGED, LOCALE_TOPIC, mergeMessages, updateLocale } from './lib';
|
|
77
|
-
export { default as injectIntl } from './injectIntlWithShim';
|
|
25
|
+
export { createIntl, defineMessages, FormattedDate, FormattedMessage, FormattedNumber, FormattedPlural, FormattedRelativeTime, FormattedTime, IntlProvider, useIntl, } from 'react-intl';
|
|
26
|
+
export { configureI18n, getLocale, getLocalizedLanguageName, getMessages, getPrimaryLanguageSubtag, getSupportedLanguageList, handleRtl, isRtl, LOCALE_CHANGED, LOCALE_TOPIC, mergeMessages, updateLocale, } from './lib';
|
|
78
27
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../runtime/i18n/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../runtime/i18n/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,UAAU,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,OAAO,GAIR,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,aAAa,EACb,SAAS,EACT,wBAAwB,EACxB,WAAW,EACX,wBAAwB,EACxB,wBAAwB,EACxB,SAAS,EACT,KAAK,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,OAAO,CAAC","sourcesContent":["/**\n * #### Import members from **@openedx/frontend-base**\n * The i18n module relies on react-intl and re-exports all of that package's exports.\n *\n * For each locale we want to support, react-intl needs 1) the locale-data, which includes\n * information about how to format numbers, handle plurals, etc., and 2) the translations, as an\n * object holding message id / translated string pairs. A locale string and the messages object are\n * passed into the IntlProvider element that wraps your element hierarchy.\n *\n * Note that react-intl has no way of checking if the translations you give it actually have\n * anything to do with the locale you pass it; it will happily use whatever messages object you pass\n * in. However, if the locale data for the locale you passed into the IntlProvider was not\n * correctly installed with addLocaleData, all of your translations will fall back to the default\n * (in our case English), *even if you gave IntlProvider the correct messages object for that\n * locale*.\n *\n * Messages are provided to this module via the configureI18n() function below.\n *\n *\n * @module Internationalization\n * @see {@link https://github.com/openedx/frontend-base/blob/master/docs/how_tos/i18n.rst}\n * @see {@link https://formatjs.io/docs/react-intl/components/ Intl} for components exported from this module.\n *\n */\n\nexport {\n createIntl,\n defineMessages,\n FormattedDate,\n FormattedMessage,\n FormattedNumber,\n FormattedPlural,\n FormattedRelativeTime,\n FormattedTime,\n IntlProvider,\n useIntl,\n type IntlConfig,\n type ResolvedIntlConfig,\n type IntlShape,\n} from 'react-intl';\n\nexport {\n configureI18n,\n getLocale,\n getLocalizedLanguageName,\n getMessages,\n getPrimaryLanguageSubtag,\n getSupportedLanguageList,\n handleRtl,\n isRtl,\n LOCALE_CHANGED,\n LOCALE_TOPIC,\n mergeMessages,\n updateLocale,\n} from './lib';\n"]}
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
1
|
import { MessageFormatElement } from 'react-intl';
|
|
3
2
|
import Cookies from 'universal-cookie';
|
|
4
3
|
import { LocalizedMessages } from '../../types';
|
|
5
|
-
/**
|
|
6
|
-
* @memberof module:Internationalization
|
|
7
|
-
*
|
|
8
|
-
* Prior versions of react-intl (our primary implementation of the i18n service) included a
|
|
9
|
-
* PropTypes-based 'shape' for its `intl` object. This has since been removed. For legacy
|
|
10
|
-
* compatibility, we include an `intlShape` export that is set to PropTypes.object. Usage of this
|
|
11
|
-
* export is deprecated.
|
|
12
|
-
*
|
|
13
|
-
* @deprecated
|
|
14
|
-
*/
|
|
15
|
-
export declare const intlShape: PropTypes.Requireable<object>;
|
|
16
4
|
/**
|
|
17
5
|
* @memberof module:Internationalization
|
|
18
6
|
*/
|
package/dist/runtime/i18n/lib.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import merge from 'lodash/merge';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import Cookies from 'universal-cookie';
|
|
4
3
|
import { getSiteConfig } from '../config';
|
|
5
4
|
import { publish } from '../subscriptions';
|
|
@@ -44,17 +43,6 @@ const rtlLocales = [
|
|
|
44
43
|
'yi-us', // Yiddish (United States)
|
|
45
44
|
];
|
|
46
45
|
let messages;
|
|
47
|
-
/**
|
|
48
|
-
* @memberof module:Internationalization
|
|
49
|
-
*
|
|
50
|
-
* Prior versions of react-intl (our primary implementation of the i18n service) included a
|
|
51
|
-
* PropTypes-based 'shape' for its `intl` object. This has since been removed. For legacy
|
|
52
|
-
* compatibility, we include an `intlShape` export that is set to PropTypes.object. Usage of this
|
|
53
|
-
* export is deprecated.
|
|
54
|
-
*
|
|
55
|
-
* @deprecated
|
|
56
|
-
*/
|
|
57
|
-
export const intlShape = PropTypes.object;
|
|
58
46
|
/**
|
|
59
47
|
* @memberof module:Internationalization
|
|
60
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../../runtime/i18n/lib.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,SAAS,MAAM,YAAY,CAAC;AAEnC,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,SAA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,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 PropTypes from 'prop-types';\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 *\n * Prior versions of react-intl (our primary implementation of the i18n service) included a\n * PropTypes-based 'shape' for its `intl` object. This has since been removed. For legacy\n * compatibility, we include an `intlShape` export that is set to PropTypes.object. Usage of this\n * export is deprecated.\n *\n * @deprecated\n */\nexport const intlShape = PropTypes.object;\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,CA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AC;AAED;;;;;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"]}
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { configureAnalytics, getAnalyticsService, identifyAnonymousUser, identif
|
|
|
2
2
|
export { AUTHENTICATED_USER_CHANGED, AUTHENTICATED_USER_TOPIC, AxiosJwtAuthService, configureAuth, ensureAuthenticatedUser, fetchAuthenticatedUser, getAuthenticatedHttpClient, getAuthenticatedUser, getAuthService, getHttpClient, getLoginRedirectUrl, getLogoutRedirectUrl, hydrateAuthenticatedUser, MockAuthService, redirectToLogin, redirectToLogout, setAuthenticatedUser } from './auth';
|
|
3
3
|
export { getSiteConfig, setSiteConfig, mergeSiteConfig, addAppConfigs, getAppConfig, mergeAppConfig, setActiveRouteRoles, getActiveRouteRoles, addActiveWidgetRole, removeActiveWidgetRole, getActiveWidgetRoles, getActiveRoles, getExternalLinkUrl, getProvides, getProvidesAsStrings } from './config';
|
|
4
4
|
export * from './constants';
|
|
5
|
-
export { configureI18n, createIntl, defineMessages, FormattedDate, FormattedMessage, FormattedNumber, FormattedPlural, FormattedRelativeTime, FormattedTime, getLocale, getLocalizedLanguageName, getMessages, getPrimaryLanguageSubtag, getSupportedLanguageList, handleRtl,
|
|
5
|
+
export { configureI18n, createIntl, defineMessages, FormattedDate, FormattedMessage, FormattedNumber, FormattedPlural, FormattedRelativeTime, FormattedTime, getLocale, getLocalizedLanguageName, getMessages, getPrimaryLanguageSubtag, getSupportedLanguageList, handleRtl, IntlProvider, isRtl, LOCALE_CHANGED, LOCALE_TOPIC, mergeMessages, updateLocale, useIntl, type IntlConfig, type ResolvedIntlConfig, type IntlShape, } from './i18n';
|
|
6
6
|
export { auth, getBasename, initError, initialize } from './initialize';
|
|
7
7
|
export { loadExternalScripts } from './scripts';
|
|
8
8
|
export { configureLogging, getLoggingService, logError, logInfo, MockLoggingService, NewRelicLoggingService, resetLoggingService } from './logging';
|
package/dist/runtime/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export { configureAnalytics, getAnalyticsService, identifyAnonymousUser, identif
|
|
|
2
2
|
export { AUTHENTICATED_USER_CHANGED, AUTHENTICATED_USER_TOPIC, AxiosJwtAuthService, configureAuth, ensureAuthenticatedUser, fetchAuthenticatedUser, getAuthenticatedHttpClient, getAuthenticatedUser, getAuthService, getHttpClient, getLoginRedirectUrl, getLogoutRedirectUrl, hydrateAuthenticatedUser, MockAuthService, redirectToLogin, redirectToLogout, setAuthenticatedUser } from './auth';
|
|
3
3
|
export { getSiteConfig, setSiteConfig, mergeSiteConfig, addAppConfigs, getAppConfig, mergeAppConfig, setActiveRouteRoles, getActiveRouteRoles, addActiveWidgetRole, removeActiveWidgetRole, getActiveWidgetRoles, getActiveRoles, getExternalLinkUrl, getProvides, getProvidesAsStrings } from './config';
|
|
4
4
|
export * from './constants';
|
|
5
|
-
export { configureI18n, createIntl, defineMessages, FormattedDate, FormattedMessage, FormattedNumber, FormattedPlural, FormattedRelativeTime, FormattedTime, getLocale, getLocalizedLanguageName, getMessages, getPrimaryLanguageSubtag, getSupportedLanguageList, handleRtl,
|
|
5
|
+
export { configureI18n, createIntl, defineMessages, FormattedDate, FormattedMessage, FormattedNumber, FormattedPlural, FormattedRelativeTime, FormattedTime, getLocale, getLocalizedLanguageName, getMessages, getPrimaryLanguageSubtag, getSupportedLanguageList, handleRtl, IntlProvider, isRtl, LOCALE_CHANGED, LOCALE_TOPIC, mergeMessages, updateLocale, useIntl, } from './i18n';
|
|
6
6
|
export { auth, getBasename, initError, initialize } from './initialize';
|
|
7
7
|
export { loadExternalScripts } from './scripts';
|
|
8
8
|
export { configureLogging, getLoggingService, logError, logInfo, MockLoggingService, NewRelicLoggingService, resetLoggingService } from './logging';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B,EAC1B,oBAAoB,EACpB,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,aAAa,EACb,aAAa,EACb,eAAe,EACf,aAAa,EACb,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACrB,MAAM,UAAU,CAAC;AAElB,cAAc,aAAa,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,UAAU,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,SAAS,EACT,wBAAwB,EACxB,WAAW,EACX,wBAAwB,EACxB,wBAAwB,EACxB,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,aAAa,EACb,cAAc,EACd,oBAAoB,EACrB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,uBAAuB,EACvB,sBAAsB,EACtB,0BAA0B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B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,SAAS,EACT,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,iBAAiB,EACjB,YAAY,EACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,eAAe,EAChB,MAAM,SAAS,CAAC;AAEjB,cAAc,SAAS,CAAC","sourcesContent":["export {\n configureAnalytics,\n getAnalyticsService,\n identifyAnonymousUser,\n identifyAuthenticatedUser,\n MockAnalyticsService,\n resetAnalyticsService,\n SegmentAnalyticsService,\n sendPageEvent,\n sendTrackEvent,\n sendTrackingLogEvent\n} from './analytics';\n\nexport {\n AUTHENTICATED_USER_CHANGED,\n AUTHENTICATED_USER_TOPIC,\n AxiosJwtAuthService,\n configureAuth,\n ensureAuthenticatedUser,\n fetchAuthenticatedUser,\n getAuthenticatedHttpClient,\n getAuthenticatedUser,\n getAuthService,\n getHttpClient,\n getLoginRedirectUrl,\n getLogoutRedirectUrl,\n hydrateAuthenticatedUser,\n MockAuthService,\n redirectToLogin,\n redirectToLogout,\n setAuthenticatedUser\n} from './auth';\n\nexport {\n getSiteConfig,\n setSiteConfig,\n mergeSiteConfig,\n addAppConfigs,\n getAppConfig,\n mergeAppConfig,\n setActiveRouteRoles,\n getActiveRouteRoles,\n addActiveWidgetRole,\n removeActiveWidgetRole,\n getActiveWidgetRoles,\n getActiveRoles,\n getExternalLinkUrl,\n getProvides,\n getProvidesAsStrings\n} from './config';\n\nexport * from './constants';\n\nexport {\n configureI18n,\n createIntl,\n defineMessages,\n FormattedDate,\n FormattedMessage,\n FormattedNumber,\n FormattedPlural,\n FormattedRelativeTime,\n FormattedTime,\n getLocale,\n getLocalizedLanguageName,\n getMessages,\n getPrimaryLanguageSubtag,\n getSupportedLanguageList,\n handleRtl,\n IntlProvider,\n isRtl,\n LOCALE_CHANGED,\n LOCALE_TOPIC,\n mergeMessages,\n updateLocale,\n useIntl,\n type IntlConfig,\n type ResolvedIntlConfig,\n type IntlShape,\n} from './i18n';\n\nexport {\n auth,\n getBasename,\n initError,\n initialize\n} from './initialize';\n\nexport {\n loadExternalScripts\n} from './scripts';\n\nexport {\n configureLogging,\n getLoggingService,\n logError,\n logInfo,\n MockLoggingService,\n NewRelicLoggingService,\n resetLoggingService\n} from './logging';\n\nexport {\n CurrentAppContext,\n CurrentAppProvider,\n SiteContext,\n SiteProvider,\n AuthenticatedPageRoute,\n Divider,\n ErrorBoundary,\n ErrorPage,\n LoginRedirect,\n PageWrap,\n useSiteEvent,\n useAuthenticatedUser,\n useSiteConfig,\n useAppConfig\n} from './react';\n\nexport {\n authenticatedLoader,\n getUrlByRouteRole,\n isRoleRouteObject\n} from './routing';\n\nexport {\n clearAllSubscriptions,\n publish,\n subscribe,\n unsubscribe\n} from './subscriptions';\n\nexport {\n initializeMockApp,\n mockMessages\n} from './testing';\n\nexport {\n camelCaseObject,\n convertKeyNames,\n getQueryParameters,\n isValidVariableName,\n modifyObjectKeys,\n snakeCaseObject\n} from './utils';\n\nexport * from './slots';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../../runtime/jest.config.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,kBAAkB,EAAE;QAClB,wBAAwB;KACzB;IACD,gBAAgB,EAAE;QAChB,SAAS,EAAE,4BAA4B;QACvC,iFAAiF,EAAE,4BAA4B;QAC/G,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC;QACvD,aAAa,EAAE,gCAAgC;KAChD;IACD,eAAe,EAAE,OAAO;IACxB,sBAAsB,EAAE;QACtB,GAAG,EAAE,mBAAmB;KACzB;IACD,mBAAmB,EAAE;QACnB,gCAAgC;KACjC;IACD,0BAA0B,EAAE;QAC1B,wBAAwB;KACzB;IACD,uBAAuB,EAAE;QACvB,
|
|
1
|
+
{"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../../runtime/jest.config.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,kBAAkB,EAAE;QAClB,wBAAwB;KACzB;IACD,gBAAgB,EAAE;QAChB,SAAS,EAAE,4BAA4B;QACvC,iFAAiF,EAAE,4BAA4B;QAC/G,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,oBAAoB,CAAC;QACvD,aAAa,EAAE,gCAAgC;KAChD;IACD,eAAe,EAAE,OAAO;IACxB,sBAAsB,EAAE;QACtB,GAAG,EAAE,mBAAmB;KACzB;IACD,mBAAmB,EAAE;QACnB,gCAAgC;KACjC;IACD,0BAA0B,EAAE;QAC1B,wBAAwB;KACzB;IACD,uBAAuB,EAAE;QACvB,4EAA4E;KAC7E;IACD,wBAAwB,EAAE;QACxB,QAAQ;KACT;IACD,sBAAsB,EAAE;QACtB,uBAAuB;QACvB,gBAAgB;QAChB,QAAQ;KACT;CACF,CAAC","sourcesContent":["module.exports = {\n setupFilesAfterEnv: [\n '<rootDir>/setupTest.js',\n ],\n moduleNameMapper: {\n '\\\\.svg$': '<rootDir>/__mocks__/svg.js',\n '\\\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir/__mocks__/file.js',\n '\\\\.(css|scss)$': require.resolve('identity-obj-proxy'),\n 'site.config': '<rootDir>/site.config.test.tsx',\n },\n testEnvironment: 'jsdom',\n testEnvironmentOptions: {\n url: 'http://localhost/',\n },\n collectCoverageFrom: [\n '<rootDir>/**/*.{js,jsx,ts,tsx}',\n ],\n coveragePathIgnorePatterns: [\n '<rootDir>/setupTest.js',\n ],\n transformIgnorePatterns: [\n '/node_modules/(?!(@openedx|@edx|react-intl|@formatjs|intl-messageformat)/)',\n ],\n modulePathIgnorePatterns: [\n '/dist/',\n ],\n testPathIgnorePatterns: [\n '/site.config.test.tsx',\n '/node_modules/',\n '/dist/',\n ],\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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;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ACtC,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
|
|
1
|
+
{"version":3,"file":"SiteProvider.js","sourceRoot":"","sources":["../../../runtime/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AAC,cAAc,EAAE,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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wB,CAAC,GAAG,GAAG,uBAAuB,CAAC,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
|
|
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,a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C;YAC9G,IAAI,wBAAwB,EAAE,CAAC;gBAC7B,wBAAwB,CAAC,GAAG,GAAG,uBAAuB,CAAC,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 +1 @@
|
|
|
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
|
|
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
|
|
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
|
|
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[]
|
|
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
|
|
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"]}
|