@edx/frontend-plugin-advertisements 2.12.0 → 2.13.0

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.
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ const _excluded = ["widgetName"];
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
16
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
17
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
18
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
19
+ function useUCL() {
20
+ let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 5000;
21
+ const [ucl, setUcl] = (0, _react.useState)(() => window.UCL);
22
+ (0, _react.useEffect)(() => {
23
+ if (ucl) {
24
+ return undefined;
25
+ }
26
+ const start = Date.now();
27
+ const id = setInterval(() => {
28
+ if (window.UCL) {
29
+ setUcl(window.UCL);
30
+ clearInterval(id);
31
+ } else if (Date.now() - start > timeout) {
32
+ clearInterval(id);
33
+ }
34
+ }, 100);
35
+ return () => clearInterval(id);
36
+ }, [ucl, timeout]);
37
+ return ucl;
38
+ }
39
+ class RenderFallbackSignal extends Error {
40
+ constructor() {
41
+ super('Render fallback requested by widget');
42
+ this.name = 'RenderFallbackSignal';
43
+ }
44
+ }
45
+ const DynamicExperienceSlot = _ref => {
46
+ let {
47
+ widgetName
48
+ } = _ref,
49
+ rest = _objectWithoutProperties(_ref, _excluded);
50
+ const ref = (0, _react.useRef)(null);
51
+ const UCL = useUCL();
52
+ const [shouldThrow, setShouldThrow] = (0, _react.useState)(false);
53
+ const [error, setError] = (0, _react.useState)(null);
54
+
55
+ // Lock props to prevent unnecessary re-renders
56
+ const restPropsRef = (0, _react.useRef)(rest);
57
+ // Update ref on each render to prevent stale props
58
+ restPropsRef.current = rest;
59
+ (0, _react.useEffect)(() => {
60
+ const refCurrent = ref.current;
61
+ if (!refCurrent || !UCL) {
62
+ return undefined;
63
+ }
64
+ try {
65
+ UCL.mount(widgetName, refCurrent, _objectSpread(_objectSpread({}, restPropsRef.current), {}, {
66
+ onFallbackShouldRender: setShouldThrow
67
+ }));
68
+ } catch (e) {
69
+ setError(e);
70
+ }
71
+ return () => UCL.unmount(refCurrent);
72
+ }, [widgetName, UCL]);
73
+ if (error) {
74
+ throw error;
75
+ }
76
+ if (shouldThrow) {
77
+ throw new RenderFallbackSignal();
78
+ }
79
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
80
+ ref: ref
81
+ });
82
+ };
83
+ DynamicExperienceSlot.propTypes = {
84
+ widgetName: _propTypes.default.string.isRequired
85
+ };
86
+ var _default = exports.default = DynamicExperienceSlot;
87
+ //# sourceMappingURL=DynamicExperienceSlot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicExperienceSlot.js","names":["_react","require","_propTypes","_interopRequireDefault","_jsxRuntime","_excluded","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","_objectWithoutProperties","_objectWithoutPropertiesLoose","n","indexOf","propertyIsEnumerable","hasOwnProperty","useUCL","timeout","undefined","ucl","setUcl","useState","window","UCL","useEffect","start","Date","now","id","setInterval","clearInterval","RenderFallbackSignal","Error","constructor","name","DynamicExperienceSlot","_ref","widgetName","rest","ref","useRef","shouldThrow","setShouldThrow","error","setError","restPropsRef","current","refCurrent","mount","onFallbackShouldRender","unmount","jsx","propTypes","PropTypes","string","isRequired","_default","exports"],"sources":["../../src/dynamic-experience-slot/DynamicExperienceSlot.jsx"],"sourcesContent":["import { useState, useEffect, useRef } from 'react';\nimport PropTypes from 'prop-types';\n\nfunction useUCL(timeout = 5000) {\n const [ucl, setUcl] = useState(() => window.UCL);\n useEffect(() => {\n if (ucl) { return undefined; }\n const start = Date.now();\n const id = setInterval(() => {\n if (window.UCL) {\n setUcl(window.UCL);\n clearInterval(id);\n } else if (Date.now() - start > timeout) {\n clearInterval(id);\n }\n }, 100);\n return () => clearInterval(id);\n }, [ucl, timeout]);\n return ucl;\n}\nclass RenderFallbackSignal extends Error {\n constructor() {\n super('Render fallback requested by widget');\n this.name = 'RenderFallbackSignal';\n }\n}\n\nconst DynamicExperienceSlot = ({ widgetName, ...rest }) => {\n const ref = useRef(null);\n const UCL = useUCL();\n const [shouldThrow, setShouldThrow] = useState(false);\n const [error, setError] = useState(null);\n\n // Lock props to prevent unnecessary re-renders\n const restPropsRef = useRef(rest);\n // Update ref on each render to prevent stale props\n restPropsRef.current = rest;\n\n useEffect(() => {\n const refCurrent = ref.current;\n if (!refCurrent || !UCL) { return undefined; }\n try {\n UCL.mount(widgetName, refCurrent, {\n ...restPropsRef.current,\n onFallbackShouldRender: setShouldThrow,\n });\n } catch (e) {\n setError(e);\n }\n return () => UCL.unmount(refCurrent);\n }, [widgetName, UCL]);\n if (error) { throw error; }\n if (shouldThrow) { throw new RenderFallbackSignal(); }\n return <div ref={ref} />;\n};\n\nDynamicExperienceSlot.propTypes = {\n widgetName: PropTypes.string.isRequired,\n};\n\nexport default DynamicExperienceSlot;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAmC,IAAAG,WAAA,GAAAH,OAAA;AAAA,MAAAI,SAAA;AAAA,SAAAF,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,QAAAH,CAAA,EAAAI,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAP,CAAA,OAAAM,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAR,CAAA,GAAAI,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAX,CAAA,EAAAI,CAAA,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E3B,IAAAd,gBAAS,EAAC,MAAM;IACd,MAAMuB,UAAU,GAAGR,GAAG,CAACO,OAAO;IAC9B,IAAI,CAACC,UAAU,IAAI,CAACxB,GAAG,EAAE;MAAE,OAAOL,SAAS;IAAE;IAC7C,IAAI;MACFK,GAAG,CAACyB,KAAK,CAACX,UAAU,EAAEU,UAAU,EAAAzD,aAAA,CAAAA,aAAA,KAC3BuD,YAAY,CAACC,OAAO;QACvBG,sBAAsB,EAAEP;MAAc,EACvC,CAAC;IACJ,CAAC,CAAC,OAAOnE,CAAC,EAAE;MACVqE,QAAQ,CAACrE,CAAC,CAAC;IACb;IACA,OAAO,MAAMgD,GAAG,CAAC2B,OAAO,CAACH,UAAU,CAAC;EACtC,CAAC,EAAE,CAACV,UAAU,EAAEd,GAAG,CAAC,CAAC;EACrB,IAAIoB,KAAK,EAAE;IAAE,MAAMA,KAAK;EAAE;EAC1B,IAAIF,WAAW,EAAE;IAAE,MAAM,IAAIV,oBAAoB,CAAC,CAAC;EAAE;EACrD,oBAAO,IAAA1D,WAAA,CAAA8E,GAAA;IAAKZ,GAAG,EAAEA;EAAI,CAAE,CAAC;AAC1B,CAAC;AAEDJ,qBAAqB,CAACiB,SAAS,GAAG;EAChCf,UAAU,EAAEgB,kBAAS,CAACC,MAAM,CAACC;AAC/B,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAhF,OAAA,GAEa0D,qBAAqB","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _DynamicExperienceSlot = _interopRequireDefault(require("./DynamicExperienceSlot"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = _DynamicExperienceSlot.default;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_DynamicExperienceSlot","_interopRequireDefault","require","e","__esModule","default","_default","exports","DynamicExperienceSlot"],"sources":["../../src/dynamic-experience-slot/index.jsx"],"sourcesContent":["import DynamicExperienceSlot from './DynamicExperienceSlot';\n\nexport default DynamicExperienceSlot;\n"],"mappings":";;;;;;AAAA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAE7CG,8BAAqB","ignoreList":[]}
package/dist/index.js CHANGED
@@ -9,6 +9,12 @@ Object.defineProperty(exports, "AccessExpirationAlert", {
9
9
  return _accessExpirationAlert.default;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "DynamicExperienceSlot", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _dynamicExperienceSlot.default;
16
+ }
17
+ });
12
18
  Object.defineProperty(exports, "LockPaywall", {
13
19
  enumerable: true,
14
20
  get: function () {
@@ -27,6 +33,12 @@ Object.defineProperty(exports, "SectionList", {
27
33
  return _sectionOutline.default;
28
34
  }
29
35
  });
36
+ Object.defineProperty(exports, "UclWrapper", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _uclWrapper.default;
40
+ }
41
+ });
30
42
  Object.defineProperty(exports, "UpgradeNotification", {
31
43
  enumerable: true,
32
44
  get: function () {
@@ -45,6 +57,8 @@ var _upgradeModal = _interopRequireDefault(require("./upgrade-modal"));
45
57
  var _accessExpirationAlert = _interopRequireDefault(require("./access-expiration-alert"));
46
58
  var _generic = require("./generic");
47
59
  var _sectionOutline = _interopRequireDefault(require("./section-outline"));
60
+ var _dynamicExperienceSlot = _interopRequireDefault(require("./dynamic-experience-slot"));
61
+ var _uclWrapper = _interopRequireDefault(require("./ucl-wrapper"));
48
62
  require("./index.scss");
49
63
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
50
64
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_upgradeNotification","_interopRequireDefault","require","_paywall","_upgradeModal","_accessExpirationAlert","_generic","_sectionOutline","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import UpgradeNotification from './upgrade-notification';\nimport LockPaywall from './paywall';\nimport NextUnitButton from './upgrade-modal';\nimport AccessExpirationAlert from './access-expiration-alert';\nimport { UpsellBullets } from './generic';\nimport SectionList from './section-outline';\nimport './index.scss';\n\nexport {\n UpgradeNotification,\n LockPaywall,\n NextUnitButton,\n AccessExpirationAlert,\n UpsellBullets,\n SectionList,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,sBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_upgradeNotification","_interopRequireDefault","require","_paywall","_upgradeModal","_accessExpirationAlert","_generic","_sectionOutline","_dynamicExperienceSlot","_uclWrapper","e","__esModule","default"],"sources":["../src/index.jsx"],"sourcesContent":["import UpgradeNotification from './upgrade-notification';\nimport LockPaywall from './paywall';\nimport NextUnitButton from './upgrade-modal';\nimport AccessExpirationAlert from './access-expiration-alert';\nimport { UpsellBullets } from './generic';\nimport SectionList from './section-outline';\nimport DynamicExperienceSlot from './dynamic-experience-slot';\nimport UclWrapper from './ucl-wrapper';\nimport './index.scss';\n\nexport {\n UpgradeNotification,\n LockPaywall,\n NextUnitButton,\n AccessExpirationAlert,\n UpsellBullets,\n SectionList,\n DynamicExperienceSlot,\n UclWrapper,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,aAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,sBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,sBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,WAAA,GAAAR,sBAAA,CAAAC,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAS,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _logging = require("@edx/frontend-platform/logging");
9
+ const UclWrapper = () => {
10
+ const [isLoaded, setLoaded] = (0, _react.useState)(false);
11
+
12
+ // eslint-disable-next-line no-underscore-dangle
13
+ window._UCL = {
14
+ identity: '2u-edx-learning'
15
+ };
16
+ (0, _react.useEffect)(() => {
17
+ if (isLoaded) {
18
+ return;
19
+ }
20
+ const head = document.getElementsByTagName('head')[0];
21
+ const script = document.createElement('script');
22
+ script.src = 'https://affiliate-bundle.api.highereducation.com/latest/UCL.adapter.js';
23
+ script.dataset.testId = 'ucl-test';
24
+ script.async = true;
25
+ script.onload = () => {
26
+ if (window.UCL && typeof window.UCL === 'function') {
27
+ (0, _logging.logInfo)('UCL script loaded successfully!');
28
+ } else {
29
+ // in the case that the script successfully loaded but UCL is still not found
30
+ (0, _logging.logError)('window.UCL not found after UCL script load.');
31
+ }
32
+ };
33
+ script.onerror = e => {
34
+ (0, _logging.logError)('UCL script failed to load', e);
35
+ };
36
+ head.appendChild(script);
37
+ setLoaded(true);
38
+ }, [isLoaded]);
39
+ return null;
40
+ };
41
+ var _default = exports.default = UclWrapper;
42
+ //# sourceMappingURL=UclWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UclWrapper.js","names":["_react","require","_logging","UclWrapper","isLoaded","setLoaded","useState","window","_UCL","identity","useEffect","head","document","getElementsByTagName","script","createElement","src","dataset","testId","async","onload","UCL","logInfo","logError","onerror","e","appendChild","_default","exports","default"],"sources":["../../src/ucl-wrapper/UclWrapper.jsx"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { logError, logInfo } from '@edx/frontend-platform/logging';\n\nconst UclWrapper = () => {\n const [isLoaded, setLoaded] = useState(false);\n\n // eslint-disable-next-line no-underscore-dangle\n window._UCL = {\n identity: '2u-edx-learning',\n };\n\n useEffect(() => {\n if (isLoaded) {\n return;\n }\n\n const head = document.getElementsByTagName('head')[0];\n const script = document.createElement('script');\n script.src = 'https://affiliate-bundle.api.highereducation.com/latest/UCL.adapter.js';\n script.dataset.testId = 'ucl-test';\n script.async = true;\n\n script.onload = () => {\n if (window.UCL && typeof window.UCL === 'function') {\n logInfo('UCL script loaded successfully!');\n } else {\n // in the case that the script successfully loaded but UCL is still not found\n logError('window.UCL not found after UCL script load.');\n }\n };\n\n script.onerror = (e) => {\n logError('UCL script failed to load', e);\n };\n\n head.appendChild(script);\n setLoaded(true);\n }, [isLoaded]);\n\n return null;\n};\n\nexport default UclWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,UAAU,GAAGA,CAAA,KAAM;EACvB,MAAM,CAACC,QAAQ,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;;EAE7C;EACAC,MAAM,CAACC,IAAI,GAAG;IACZC,QAAQ,EAAE;EACZ,CAAC;EAED,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAIN,QAAQ,EAAE;MACZ;IACF;IAEA,MAAMO,IAAI,GAAGC,QAAQ,CAACC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACrD,MAAMC,MAAM,GAAGF,QAAQ,CAACG,aAAa,CAAC,QAAQ,CAAC;IAC/CD,MAAM,CAACE,GAAG,GAAG,wEAAwE;IACrFF,MAAM,CAACG,OAAO,CAACC,MAAM,GAAG,UAAU;IAClCJ,MAAM,CAACK,KAAK,GAAG,IAAI;IAEnBL,MAAM,CAACM,MAAM,GAAG,MAAM;MACpB,IAAIb,MAAM,CAACc,GAAG,IAAI,OAAOd,MAAM,CAACc,GAAG,KAAK,UAAU,EAAE;QAClD,IAAAC,gBAAO,EAAC,iCAAiC,CAAC;MAC5C,CAAC,MAAM;QACL;QACA,IAAAC,iBAAQ,EAAC,6CAA6C,CAAC;MACzD;IACF,CAAC;IAEDT,MAAM,CAACU,OAAO,GAAIC,CAAC,IAAK;MACtB,IAAAF,iBAAQ,EAAC,2BAA2B,EAAEE,CAAC,CAAC;IAC1C,CAAC;IAEDd,IAAI,CAACe,WAAW,CAACZ,MAAM,CAAC;IACxBT,SAAS,CAAC,IAAI,CAAC;EACjB,CAAC,EAAE,CAACD,QAAQ,CAAC,CAAC;EAEd,OAAO,IAAI;AACb,CAAC;AAAC,IAAAuB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa1B,UAAU","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _UclWrapper = _interopRequireDefault(require("./UclWrapper"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ var _default = exports.default = _UclWrapper.default;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_UclWrapper","_interopRequireDefault","require","e","__esModule","default","_default","exports","UclWrapper"],"sources":["../../src/ucl-wrapper/index.jsx"],"sourcesContent":["import UclWrapper from './UclWrapper';\n\nexport default UclWrapper;\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAsC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEvBG,mBAAU","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-plugin-advertisements",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "description": "Frontend plugin for edX in course advertisements",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
@@ -42,6 +42,7 @@
42
42
  "dependencies": {
43
43
  "@optimizely/react-sdk": "^3.1.0",
44
44
  "react-dom": "^18.3.1",
45
+ "react-error-boundary": "^6.1.1",
45
46
  "universal-cookie": "^8.0.1",
46
47
  "uuid": "^11.1.0"
47
48
  },