@openedx/frontend-base 1.0.0-alpha.45 → 1.0.0-alpha.47

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.
@@ -19,6 +19,14 @@ const useThemeCore = ({ themeCore, onComplete, }) => {
19
19
  setIsThemeCoreComplete(true);
20
20
  return;
21
21
  }
22
+ const existingThemeCoreLink = document.head.querySelector('link[data-theme-core="true"]');
23
+ if (existingThemeCoreLink) {
24
+ if (existingThemeCoreLink.getAttribute('href') === themeCore.url) {
25
+ setIsThemeCoreComplete(true);
26
+ return;
27
+ }
28
+ existingThemeCoreLink.remove();
29
+ }
22
30
  const themeCoreLink = document.createElement('link');
23
31
  themeCoreLink.href = themeCore.url;
24
32
  themeCoreLink.rel = 'stylesheet';
@@ -1 +1 @@
1
- {"version":3,"file":"useThemeCore.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useThemeCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,EACpB,SAAS,EACT,UAAU,GACX,EAAE,EAAE;IACH,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,mBAAmB,EAAE,CAAC;YACxB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEtC,SAAS,CAAC,GAAG,EAAE;QACb,gDAAgD;QAChD,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAA,EAAE,CAAC;YACpB,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACrD,aAAa,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC;QACnC,aAAa,CAAC,GAAG,GAAG,YAAY,CAAC;QACjC,aAAa,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;QACzC,aAAa,CAAC,MAAM,GAAG,GAAG,EAAE;YAC1B,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC;QACF,aAAa,CAAC,OAAO,GAAG,GAAG,EAAE;YAC3B,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,8BAA8B,CAAC,CAAC;YAC1F,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;YACxC,QAAQ,CAAC,sCAAsC,SAAS,CAAC,GAAG,aAAa,CAAC,CAAC;YAC3E,OAAO;QACT,CAAC,CAAC;QAEF,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CACjC,WAAW,EACX,aAAa,CACd,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { logError } from '../../../logging';\nimport { removeExistingLinks } from './utils';\n\n/**\n * Custom React hook that manages the loading and updating of a theme's core\n * CSS, ensuring the theme's core CSS is added to the document `<head>` as a\n * `<link>` element.\n */\nconst useThemeCore = ({\n themeCore,\n onComplete,\n}) => {\n const [isThemeCoreComplete, setIsThemeCoreComplete] = useState(false);\n\n useEffect(() => {\n if (isThemeCoreComplete) {\n onComplete();\n }\n }, [isThemeCoreComplete, onComplete]);\n\n useEffect(() => {\n // If there is no theme core config, do nothing.\n if (!themeCore?.url) {\n setIsThemeCoreComplete(true);\n return;\n }\n\n const themeCoreLink = document.createElement('link');\n themeCoreLink.href = themeCore.url;\n themeCoreLink.rel = 'stylesheet';\n themeCoreLink.dataset.themeCore = 'true';\n themeCoreLink.onload = () => {\n setIsThemeCoreComplete(true);\n };\n themeCoreLink.onerror = () => {\n setIsThemeCoreComplete(true);\n const otherExistingLinks = document.head.querySelectorAll('link[data-theme-core=\"true\"]');\n removeExistingLinks(otherExistingLinks);\n logError(`Failed to load core theme CSS from ${themeCore.url}. Aborting.`);\n return;\n };\n\n document.head.insertAdjacentElement(\n 'beforeend',\n themeCoreLink,\n );\n }, [themeCore?.url, onComplete]);\n};\n\nexport default useThemeCore;\n"]}
1
+ {"version":3,"file":"useThemeCore.js","sourceRoot":"","sources":["../../../../../runtime/react/hooks/theme/useThemeCore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,EACpB,SAAS,EACT,UAAU,GACX,EAAE,EAAE;IACH,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAEtE,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,mBAAmB,EAAE,CAAC;YACxB,UAAU,EAAE,CAAC;QACf,CAAC;IACH,CAAC,EAAE,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC,CAAC;IAEtC,SAAS,CAAC,GAAG,EAAE;QACb,gDAAgD;QAChD,IAAI,CAAC,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,CAAA,EAAE,CAAC;YACpB,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,qBAAqB,GAA2B,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,8BAA8B,CAAC,CAAC;QAClH,IAAI,qBAAqB,EAAE,CAAC;YAC1B,IAAI,qBAAqB,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,SAAS,CAAC,GAAG,EAAE,CAAC;gBACjE,sBAAsB,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO;YACT,CAAC;YACD,qBAAqB,CAAC,MAAM,EAAE,CAAC;QACjC,CAAC;QAED,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACrD,aAAa,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC;QACnC,aAAa,CAAC,GAAG,GAAG,YAAY,CAAC;QACjC,aAAa,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;QACzC,aAAa,CAAC,MAAM,GAAG,GAAG,EAAE;YAC1B,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC,CAAC;QACF,aAAa,CAAC,OAAO,GAAG,GAAG,EAAE;YAC3B,sBAAsB,CAAC,IAAI,CAAC,CAAC;YAC7B,MAAM,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,8BAA8B,CAAC,CAAC;YAC1F,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;YACxC,QAAQ,CAAC,sCAAsC,SAAS,CAAC,GAAG,aAAa,CAAC,CAAC;YAC3E,OAAO;QACT,CAAC,CAAC;QAEF,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CACjC,WAAW,EACX,aAAa,CACd,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,GAAG,EAAE,UAAU,CAAC,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\n\nimport { logError } from '../../../logging';\nimport { removeExistingLinks } from './utils';\n\n/**\n * Custom React hook that manages the loading and updating of a theme's core\n * CSS, ensuring the theme's core CSS is added to the document `<head>` as a\n * `<link>` element.\n */\nconst useThemeCore = ({\n themeCore,\n onComplete,\n}) => {\n const [isThemeCoreComplete, setIsThemeCoreComplete] = useState(false);\n\n useEffect(() => {\n if (isThemeCoreComplete) {\n onComplete();\n }\n }, [isThemeCoreComplete, onComplete]);\n\n useEffect(() => {\n // If there is no theme core config, do nothing.\n if (!themeCore?.url) {\n setIsThemeCoreComplete(true);\n return;\n }\n\n const existingThemeCoreLink: HTMLLinkElement | null = document.head.querySelector('link[data-theme-core=\"true\"]');\n if (existingThemeCoreLink) {\n if (existingThemeCoreLink.getAttribute('href') === themeCore.url) {\n setIsThemeCoreComplete(true);\n return;\n }\n existingThemeCoreLink.remove();\n }\n\n const themeCoreLink = document.createElement('link');\n themeCoreLink.href = themeCore.url;\n themeCoreLink.rel = 'stylesheet';\n themeCoreLink.dataset.themeCore = 'true';\n themeCoreLink.onload = () => {\n setIsThemeCoreComplete(true);\n };\n themeCoreLink.onerror = () => {\n setIsThemeCoreComplete(true);\n const otherExistingLinks = document.head.querySelectorAll('link[data-theme-core=\"true\"]');\n removeExistingLinks(otherExistingLinks);\n logError(`Failed to load core theme CSS from ${themeCore.url}. Aborting.`);\n return;\n };\n\n document.head.insertAdjacentElement(\n 'beforeend',\n themeCoreLink,\n );\n }, [themeCore?.url, onComplete]);\n};\n\nexport default useThemeCore;\n"]}
@@ -1,4 +1,4 @@
1
- import { defineMessages } from '@openedx/frontend-base';
1
+ import { defineMessages } from '../../../../../runtime';
2
2
  const messages = defineMessages({
3
3
  userNameLabel: {
4
4
  id: 'masquerade-widget.userName.input.label',
@@ -1 +1 @@
1
- {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../../../shell/header/course-bar/masquerade/masquerade-widget/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,aAAa,EAAE;QACb,EAAE,EAAE,wCAAwC;QAC5C,cAAc,EAAE,mBAAmB;QACnC,WAAW,EAAE,gDAAgD;KAC9D;IACD,MAAM,EAAE;QACN,EAAE,EAAE,mCAAmC;QACvC,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,kDAAkD;KAChE;IACD,UAAU,EAAE;QACV,EAAE,EAAE,uCAAuC;QAC3C,cAAc,EAAE,YAAY;QAC5B,WAAW,EAAE,0DAA0D;KACxE;IACD,WAAW,EAAE;QACX,EAAE,EAAE,2BAA2B;QAC/B,cAAc,EAAE,sBAAsB;QACtC,WAAW,EAAE,+BAA+B;KAC7C;IACD,UAAU,EAAE;QACV,EAAE,EAAE,yBAAyB;QAC7B,cAAc,EAAE,OAAO;QACvB,WAAW,EAAE,cAAc;KAC5B;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n userNameLabel: {\n id: 'masquerade-widget.userName.input.label',\n defaultMessage: 'Username or email',\n description: 'Label for the masquerade username/email input.',\n },\n submit: {\n id: 'masquerade-widget.userName.submit',\n defaultMessage: 'Submit',\n description: 'Label for the masquerade username submit button.',\n },\n submitting: {\n id: 'masquerade-widget.userName.submitting',\n defaultMessage: 'Submitting',\n description: 'Pending label for the masquerade username submit button.',\n },\n titleViewAs: {\n id: 'masquerade-widget.view.as',\n defaultMessage: 'View this course as:',\n description: 'Button to view this course as',\n },\n titleStaff: {\n id: 'masquerade-widget.staff',\n defaultMessage: 'Staff',\n description: 'Button Staff',\n },\n});\n\nexport default messages;\n"]}
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../../../../shell/header/course-bar/masquerade/masquerade-widget/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,aAAa,EAAE;QACb,EAAE,EAAE,wCAAwC;QAC5C,cAAc,EAAE,mBAAmB;QACnC,WAAW,EAAE,gDAAgD;KAC9D;IACD,MAAM,EAAE;QACN,EAAE,EAAE,mCAAmC;QACvC,cAAc,EAAE,QAAQ;QACxB,WAAW,EAAE,kDAAkD;KAChE;IACD,UAAU,EAAE;QACV,EAAE,EAAE,uCAAuC;QAC3C,cAAc,EAAE,YAAY;QAC5B,WAAW,EAAE,0DAA0D;KACxE;IACD,WAAW,EAAE;QACX,EAAE,EAAE,2BAA2B;QAC/B,cAAc,EAAE,sBAAsB;QACtC,WAAW,EAAE,+BAA+B;KAC7C;IACD,UAAU,EAAE;QACV,EAAE,EAAE,yBAAyB;QAC7B,cAAc,EAAE,OAAO;QACvB,WAAW,EAAE,cAAc;KAC5B;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '../../../../../runtime';\n\nconst messages = defineMessages({\n userNameLabel: {\n id: 'masquerade-widget.userName.input.label',\n defaultMessage: 'Username or email',\n description: 'Label for the masquerade username/email input.',\n },\n submit: {\n id: 'masquerade-widget.userName.submit',\n defaultMessage: 'Submit',\n description: 'Label for the masquerade username submit button.',\n },\n submitting: {\n id: 'masquerade-widget.userName.submitting',\n defaultMessage: 'Submitting',\n description: 'Pending label for the masquerade username submit button.',\n },\n titleViewAs: {\n id: 'masquerade-widget.view.as',\n defaultMessage: 'View this course as:',\n description: 'Button to view this course as',\n },\n titleStaff: {\n id: 'masquerade-widget.staff',\n defaultMessage: 'Staff',\n description: 'Button Staff',\n },\n});\n\nexport default messages;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openedx/frontend-base",
3
- "version": "1.0.0-alpha.45",
3
+ "version": "1.0.0-alpha.47",
4
4
  "description": "Build tools, setup and config for frontend apps",
5
5
  "publishConfig": {
6
6
  "access": "public"