@openedx/frontend-base 1.0.0-alpha.0 → 1.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/config/types.js +0 -2
- package/config/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +66 -0
- package/package.json +8 -1
- package/runtime/__mocks__/file.js +1 -0
- package/runtime/__mocks__/svg.js +1 -0
- package/runtime/__mocks__/universal-cookie.js +6 -0
- package/runtime/analytics/interface.test.js +242 -0
- package/runtime/auth/AxiosJwtAuthService.test.jsx +1076 -0
- package/runtime/auth/interceptors/createRetryInterceptor.test.js +23 -0
- package/runtime/config/getExternalLinkUrl.test.js +76 -0
- package/runtime/i18n/lib.test.js +230 -0
- package/runtime/initialize.async.function.config.test.js +43 -0
- package/runtime/initialize.const.config.test.js +41 -0
- package/runtime/initialize.function.config.test.js +41 -0
- package/runtime/initialize.test.js +356 -0
- package/runtime/logging/NewRelicLoggingService.test.js +214 -0
- package/runtime/react/AuthenticatedPageRoute.test.jsx +135 -0
- package/runtime/react/ErrorBoundary.test.jsx +83 -0
- package/runtime/react/SiteProvider.test.jsx +66 -0
- package/runtime/react/hooks.test.jsx +104 -0
- package/runtime/routing/utils.test.ts +7 -0
- package/runtime/scripts/GoogleAnalyticsLoader.test.ts +77 -0
- package/runtime/site.config.test.tsx +33 -0
- package/runtime/slots/Slot.test.tsx +40 -0
- package/runtime/slots/layout/DefaultSlotLayout.test.tsx +31 -0
- package/runtime/slots/layout/hooks.test.tsx +178 -0
- package/runtime/slots/layout/utils.test.ts +67 -0
- package/runtime/slots/types.ts +1 -0
- package/runtime/slots/utils.test.ts +64 -0
- package/runtime/slots/utils.ts +28 -9
- package/runtime/testing/initializeMockApp.test.ts +66 -0
- package/runtime/utils.test.js +116 -0
- package/shell/Logo.test.tsx +32 -0
- package/shell/__mocks__/file.js +1 -0
- package/shell/__mocks__/svg.js +1 -0
- package/shell/__mocks__/universal-cookie.js +6 -0
- package/shell/app.ts +14 -0
- package/shell/dev/devHome/app.ts +2 -2
- package/shell/dev/slotShowcase/app.tsx +9 -9
- package/shell/header/app.tsx +3 -3
- package/shell/router/createRouter.test.tsx +50 -0
- package/shell/router/getAppRoutes.test.tsx +59 -0
- package/shell/site.config.dev.tsx +3 -3
- package/shell/site.config.test.tsx +16 -0
- package/tools/dist/cli/intl-imports.test.js +146 -0
- package/tools/dist/cli/openedx.js +1 -15
- package/tools/dist/cli/utils/printUsage.js +0 -9
- package/tools/dist/types.js +0 -2
- package/tools/dist/webpack/plugins/html-webpack-new-relic-plugin/test/HtmlWebpackNewRelicPlugin.test.js +66 -0
- package/types.ts +1 -1
- package/eslint.config.js +0 -18
- package/frontend-base.d.ts +0 -8
- package/jest.config.js +0 -7
- package/openedx-frontend-base.tgz +0 -0
- package/test-site/app.d.ts +0 -15
- package/test-site/dist/176.436443549ebb858db483.js +0 -2
- package/test-site/dist/176.436443549ebb858db483.js.map +0 -1
- package/test-site/dist/362.536eff787d2380fe246c.js +0 -2
- package/test-site/dist/362.536eff787d2380fe246c.js.map +0 -1
- package/test-site/dist/653.486966b108d224551296.js +0 -2
- package/test-site/dist/653.486966b108d224551296.js.map +0 -1
- package/test-site/dist/74e025d3fe9a7b7f8503054e2563b353.jpg +0 -0
- package/test-site/dist/806.323cf6496ad0a7fe73a7.js +0 -3
- package/test-site/dist/806.323cf6496ad0a7fe73a7.js.LICENSE.txt +0 -106
- package/test-site/dist/806.323cf6496ad0a7fe73a7.js.map +0 -1
- package/test-site/dist/95ec738c0b7faac5b5c9126794446bbd.svg +0 -4
- package/test-site/dist/app.612058b36c74787759ac.css +0 -61
- package/test-site/dist/app.612058b36c74787759ac.css.map +0 -1
- package/test-site/dist/app.612058b36c74787759ac.js +0 -2
- package/test-site/dist/app.612058b36c74787759ac.js.map +0 -1
- package/test-site/dist/cb28cdb1468c915e27e5cec9af64f22f.svg +0 -1
- package/test-site/dist/index.html +0 -1
- package/test-site/dist/report.html +0 -39
- package/test-site/dist/runtime.c7aeaf7b967496cb076f.js +0 -2
- package/test-site/dist/runtime.c7aeaf7b967496cb076f.js.map +0 -1
- package/test-site/eslint.config.js +0 -12
- package/test-site/package-lock.json +0 -19226
- package/test-site/package.json +0 -29
- package/test-site/public/index.html +0 -10
- package/test-site/site.config.build.tsx +0 -27
- package/test-site/site.config.dev.tsx +0 -27
- package/test-site/src/authenticated-page/AuthenticatedPage.tsx +0 -18
- package/test-site/src/authenticated-page/i18n/index.ts +0 -27
- package/test-site/src/authenticated-page/index.tsx +0 -28
- package/test-site/src/example-page/ExamplePage.tsx +0 -79
- package/test-site/src/example-page/Image.tsx +0 -11
- package/test-site/src/example-page/ParagonPreview.jsx +0 -66
- package/test-site/src/example-page/apple.jpg +0 -0
- package/test-site/src/example-page/apple.svg +0 -1
- package/test-site/src/example-page/index.ts +0 -16
- package/test-site/src/i18n/README.md +0 -3
- package/test-site/src/i18n/messages/frontend-app-sample/ar.json +0 -4
- package/test-site/src/i18n/messages/frontend-app-sample/eo.json +0 -1
- package/test-site/src/i18n/messages/frontend-app-sample/es_419.json +0 -4
- package/test-site/src/i18n/messages/frontend-component-emptylangs/ar.json +0 -1
- package/test-site/src/i18n/messages/frontend-component-singlelang/ar.json +0 -3
- package/test-site/src/iframe-widget/IframeWidget.tsx +0 -14
- package/test-site/src/iframe-widget/index.ts +0 -16
- package/test-site/src/index.tsx +0 -3
- package/test-site/src/messages.js +0 -11
- package/test-site/src/site.scss +0 -11
- package/test-site/tsconfig.json +0 -14
- package/tools/babel/babel.config.js +0 -27
- package/tools/babel.config.js +0 -3
- package/tools/cli/README.md +0 -29
- package/tools/cli/commands/pack.ts +0 -9
- package/tools/cli/commands/release.ts +0 -27
- package/tools/cli/commands/serve.ts +0 -43
- package/tools/cli/intl-imports.ts +0 -274
- package/tools/cli/openedx.ts +0 -101
- package/tools/cli/transifex-utils.ts +0 -75
- package/tools/cli/utils/ensureConfigFilenameOption.ts +0 -40
- package/tools/cli/utils/formatter.ts +0 -10
- package/tools/cli/utils/getResolvedConfigPath.ts +0 -23
- package/tools/cli/utils/prettyPrintTitle.ts +0 -15
- package/tools/cli/utils/printUsage.ts +0 -53
- package/tools/config-helpers/createConfig.ts +0 -8
- package/tools/config-helpers/createLintConfig.ts +0 -14
- package/tools/config-helpers/getBaseConfig.ts +0 -11
- package/tools/defaultConfigPaths.ts +0 -30
- package/tools/dist/cli/commands/pack.js +0 -14
- package/tools/dist/cli/commands/release.js +0 -28
- package/tools/eslint/base.eslint.config.js +0 -124
- package/tools/eslint/modules.d.ts +0 -5
- package/tools/eslint.config.js +0 -15
- package/tools/index.ts +0 -3
- package/tools/jest/jest.config.js +0 -30
- package/tools/jest.config.js +0 -19
- package/tools/tsconfig.json +0 -24
- package/tools/types.ts +0 -21
- package/tools/typescript/tsconfig.json +0 -32
- package/tools/webpack/common-config/README.md +0 -15
- package/tools/webpack/common-config/all/getCodeRules.ts +0 -51
- package/tools/webpack/common-config/all/getFileLoaderRules.ts +0 -23
- package/tools/webpack/common-config/all/getIgnoreWarnings.ts +0 -13
- package/tools/webpack/common-config/all/getImageMinimizer.ts +0 -26
- package/tools/webpack/common-config/all/getStylesheetRule.ts +0 -111
- package/tools/webpack/common-config/dev/getDevServer.ts +0 -35
- package/tools/webpack/common-config/index.ts +0 -6
- package/tools/webpack/common-config/site/getHtmlWebpackPlugin.ts +0 -11
- package/tools/webpack/modules.d.ts +0 -6
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/HtmlWebpackNewRelicPlugin.ts +0 -102
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/LICENSE +0 -21
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/README.md +0 -7
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/index.js +0 -3
- package/tools/webpack/plugins/html-webpack-new-relic-plugin/test/fixtures/entry.js +0 -1
- package/tools/webpack/plugins/paragon-webpack-plugin/ParagonWebpackPlugin.ts +0 -134
- package/tools/webpack/plugins/paragon-webpack-plugin/index.ts +0 -3
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/assetUtils.ts +0 -71
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/htmlUtils.ts +0 -72
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/index.ts +0 -6
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/paragonStylesheetUtils.ts +0 -131
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/scriptUtils.ts +0 -144
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/stylesheetUtils.ts +0 -106
- package/tools/webpack/plugins/paragon-webpack-plugin/utils/tagUtils.ts +0 -54
- package/tools/webpack/types.ts +0 -69
- package/tools/webpack/utils/getLocalAliases.ts +0 -65
- package/tools/webpack/utils/getPublicPath.ts +0 -3
- package/tools/webpack/utils/getResolvedSiteConfigPath.ts +0 -28
- package/tools/webpack/utils/paragonUtils.ts +0 -152
- package/tools/webpack/webpack.config.build.ts +0 -93
- package/tools/webpack/webpack.config.dev.shell.ts +0 -122
- package/tools/webpack/webpack.config.dev.ts +0 -90
- package/tsconfig.json +0 -23
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
// This class comes from https://github.com/victorrodrigues/html-webpack-new-relic-plugin.
|
|
2
|
-
// We're bringing it in so that we can more easily maintain the new relic snippet, and haven't found
|
|
3
|
-
// much value in having it in a separate package.
|
|
4
|
-
|
|
5
|
-
/* eslint no-useless-escape: [0] */
|
|
6
|
-
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
7
|
-
import { Compiler } from 'webpack';
|
|
8
|
-
|
|
9
|
-
enum OptionTypes {
|
|
10
|
-
ACCOUNT_ID = 'accountID',
|
|
11
|
-
AGENT_ID = 'agentID',
|
|
12
|
-
APPLICATION_ID = 'applicationID',
|
|
13
|
-
LICENSE_KEY = 'licenseKey',
|
|
14
|
-
TRUST_KEY = 'trustKey',
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
type HtmlWebpackNewRelicPluginOptions = {
|
|
18
|
-
[key in OptionTypes]: string | undefined;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default class HtmlWebpackNewRelicPlugin {
|
|
22
|
-
options: HtmlWebpackNewRelicPluginOptions;
|
|
23
|
-
newRelicString: string;
|
|
24
|
-
|
|
25
|
-
constructor(options: Partial<HtmlWebpackNewRelicPluginOptions>) {
|
|
26
|
-
this.options = {
|
|
27
|
-
accountID: undefined,
|
|
28
|
-
agentID: undefined,
|
|
29
|
-
applicationID: undefined,
|
|
30
|
-
licenseKey: undefined,
|
|
31
|
-
trustKey: undefined,
|
|
32
|
-
...options,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
/**
|
|
37
|
-
* New Relic Pro+SPA snippet (version 1212)
|
|
38
|
-
*
|
|
39
|
-
***********************************************************************************************
|
|
40
|
-
* READ THIS BEFORE UPDATING BELOW
|
|
41
|
-
***********************************************************************************************
|
|
42
|
-
*
|
|
43
|
-
* If you update this to the latest version, there are three things you must do:
|
|
44
|
-
*
|
|
45
|
-
* 1. Update the version number above. You can find the version number by searching for
|
|
46
|
-
* 'js-agent.newrelic.com/nr-spa' in the new snippet and copying the number up above.
|
|
47
|
-
*
|
|
48
|
-
* 2. Replace the hard-coded values for accountID, agentID, applicationID, licenseKey, and trustKey
|
|
49
|
-
* with the options above, via string interpolation: ${this.options.accountId} for instance.
|
|
50
|
-
*
|
|
51
|
-
* 3. Because this snippet is in a string here, you need to ensure that it is escaped properly.
|
|
52
|
-
* As of this writing, that means escaping any backslashes ('\') in it.
|
|
53
|
-
* There are a number of them in regexes that will get stripped out unless they're escaped.
|
|
54
|
-
*
|
|
55
|
-
* As an example, this is original code from New Relic's snippet:
|
|
56
|
-
*
|
|
57
|
-
* a=/Version\/(\S+)\s+Safari/
|
|
58
|
-
*
|
|
59
|
-
* If that's put directly into the string below, it'll become this when dumped into the page:
|
|
60
|
-
*
|
|
61
|
-
* a=/Version/(\S+)s+Safari/
|
|
62
|
-
*
|
|
63
|
-
* Which is NOT the correct regex.
|
|
64
|
-
*
|
|
65
|
-
* Instead, EDIT THE SNIPPET YOU GET FROM NEW RELIC to escape backslashes:
|
|
66
|
-
*
|
|
67
|
-
* a=/Version\\/(\\S+)\\s+Safari/
|
|
68
|
-
*
|
|
69
|
-
* The above is an example of the correct escaping.
|
|
70
|
-
*/
|
|
71
|
-
this.newRelicString = `
|
|
72
|
-
;window.NREUM||(NREUM={});NREUM.init={privacy:{cookies_enabled:true},ajax:{deny_list:["bam-cell.nr-data.net"]}};
|
|
73
|
-
window.NREUM||(NREUM={}),__nr_require=function(t,e,n){function r(n){if(!e[n]){var o=e[n]={exports:{}};t[n][0].call(o.exports,function(e){var o=t[n][1][e];return r(o||e)},o,o.exports)}return e[n].exports}if("function"==typeof __nr_require)return __nr_require;for(var o=0;o<n.length;o++)r(n[o]);return r}({1:[function(t,e,n){function r(t){try{s.console&&console.log(t)}catch(e){}}var o,i=t("ee"),a=t(32),s={};try{o=localStorage.getItem("__nr_flags").split(","),console&&"function"==typeof console.log&&(s.console=!0,o.indexOf("dev")!==-1&&(s.dev=!0),o.indexOf("nr_dev")!==-1&&(s.nrDev=!0))}catch(c){}s.nrDev&&i.on("internal-error",function(t){r(t.stack)}),s.dev&&i.on("fn-err",function(t,e,n){r(n.stack)}),s.dev&&(r("NR AGENT IN DEVELOPMENT MODE"),r("flags: "+a(s,function(t,e){return t}).join(", ")))},{}],2:[function(t,e,n){function r(t,e,n,r,s){try{l?l-=1:o(s||new UncaughtException(t,e,n),!0)}catch(f){try{i("ierr",[f,c.now(),!0])}catch(d){}}return"function"==typeof u&&u.apply(this,a(arguments))}function UncaughtException(t,e,n){this.message=t||"Uncaught error with no additional information",this.sourceURL=e,this.line=n}function o(t,e){var n=e?null:c.now();i("err",[t,n])}var i=t("handle"),a=t(33),s=t("ee"),c=t("loader"),f=t("gos"),u=window.onerror,d=!1,p="nr@seenError";if(!c.disabled){var l=0;c.features.err=!0,t(1),window.onerror=r;try{throw new Error}catch(h){"stack"in h&&(t(14),t(13),"addEventListener"in window&&t(7),c.xhrWrappable&&t(15),d=!0)}s.on("fn-start",function(t,e,n){d&&(l+=1)}),s.on("fn-err",function(t,e,n){d&&!n[p]&&(f(n,p,function(){return!0}),this.thrown=!0,o(n))}),s.on("fn-end",function(){d&&!this.thrown&&l>0&&(l-=1)}),s.on("internal-error",function(t){i("ierr",[t,c.now(),!0])})}},{}],3:[function(t,e,n){var r=t("loader");r.disabled||(r.features.ins=!0)},{}],4:[function(t,e,n){function r(){U++,L=g.hash,this[u]=y.now()}function o(){U--,g.hash!==L&&i(0,!0);var t=y.now();this[h]=~~this[h]+t-this[u],this[d]=t}function i(t,e){E.emit("newURL",[""+g,e])}function a(t,e){t.on(e,function(){this[e]=y.now()})}var s="-start",c="-end",f="-body",u="fn"+s,d="fn"+c,p="cb"+s,l="cb"+c,h="jsTime",m="fetch",v="addEventListener",w=window,g=w.location,y=t("loader");if(w[v]&&y.xhrWrappable&&!y.disabled){var x=t(11),b=t(12),E=t(9),R=t(7),O=t(14),T=t(8),P=t(15),S=t(10),M=t("ee"),N=M.get("tracer"),C=t(23);t(17),y.features.spa=!0;var L,U=0;M.on(u,r),b.on(p,r),S.on(p,r),M.on(d,o),b.on(l,o),S.on(l,o),M.buffer([u,d,"xhr-resolved"]),R.buffer([u]),O.buffer(["setTimeout"+c,"clearTimeout"+s,u]),P.buffer([u,"new-xhr","send-xhr"+s]),T.buffer([m+s,m+"-done",m+f+s,m+f+c]),E.buffer(["newURL"]),x.buffer([u]),b.buffer(["propagate",p,l,"executor-err","resolve"+s]),N.buffer([u,"no-"+u]),S.buffer(["new-jsonp","cb-start","jsonp-error","jsonp-end"]),a(T,m+s),a(T,m+"-done"),a(S,"new-jsonp"),a(S,"jsonp-end"),a(S,"cb-start"),E.on("pushState-end",i),E.on("replaceState-end",i),w[v]("hashchange",i,C(!0)),w[v]("load",i,C(!0)),w[v]("popstate",function(){i(0,U>1)},C(!0))}},{}],5:[function(t,e,n){function r(){var t=new PerformanceObserver(function(t,e){var n=t.getEntries();s(v,[n])});try{t.observe({entryTypes:["resource"]})}catch(e){}}function o(t){if(s(v,[window.performance.getEntriesByType(w)]),window.performance["c"+p])try{window.performance[h](m,o,!1)}catch(t){}else try{window.performance[h]("webkit"+m,o,!1)}catch(t){}}function i(t){}if(window.performance&&window.performance.timing&&window.performance.getEntriesByType){var a=t("ee"),s=t("handle"),c=t(14),f=t(13),u=t(6),d=t(23),p="learResourceTimings",l="addEventListener",h="removeEventListener",m="resourcetimingbufferfull",v="bstResource",w="resource",g="-start",y="-end",x="fn"+g,b="fn"+y,E="bstTimer",R="pushState",O=t("loader");if(!O.disabled){O.features.stn=!0,t(9),"addEventListener"in window&&t(7);var T=NREUM.o.EV;a.on(x,function(t,e){var n=t[0];n instanceof T&&(this.bstStart=O.now())}),a.on(b,function(t,e){var n=t[0];n instanceof T&&s("bst",[n,e,this.bstStart,O.now()])}),c.on(x,function(t,e,n){this.bstStart=O.now(),this.bstType=n}),c.on(b,function(t,e){s(E,[e,this.bstStart,O.now(),this.bstType])}),f.on(x,function(){this.bstStart=O.now()}),f.on(b,function(t,e){s(E,[e,this.bstStart,O.now(),"requestAnimationFrame"])}),a.on(R+g,function(t){this.time=O.now(),this.startPath=location.pathname+location.hash}),a.on(R+y,function(t){s("bstHist",[location.pathname+location.hash,this.startPath,this.time])}),u()?(s(v,[window.performance.getEntriesByType("resource")]),r()):l in window.performance&&(window.performance["c"+p]?window.performance[l](m,o,d(!1)):window.performance[l]("webkit"+m,o,d(!1))),document[l]("scroll",i,d(!1)),document[l]("keypress",i,d(!1)),document[l]("click",i,d(!1))}}},{}],6:[function(t,e,n){e.exports=function(){return"PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver}},{}],7:[function(t,e,n){function r(t){for(var e=t;e&&!e.hasOwnProperty(u);)e=Object.getPrototypeOf(e);e&&o(e)}function o(t){s.inPlace(t,[u,d],"-",i)}function i(t,e){return t[1]}var a=t("ee").get("events"),s=t("wrap-function")(a,!0),c=t("gos"),f=XMLHttpRequest,u="addEventListener",d="removeEventListener";e.exports=a,"getPrototypeOf"in Object?(r(document),r(window),r(f.prototype)):f.prototype.hasOwnProperty(u)&&(o(window),o(f.prototype)),a.on(u+"-start",function(t,e){var n=t[1];if(null!==n&&("function"==typeof n||"object"==typeof n)){var r=c(n,"nr@wrapped",function(){function t(){if("function"==typeof n.handleEvent)return n.handleEvent.apply(n,arguments)}var e={object:t,"function":n}[typeof n];return e?s(e,"fn-",null,e.name||"anonymous"):n});this.wrapped=t[1]=r}}),a.on(d+"-start",function(t){t[1]=this.wrapped||t[1]})},{}],8:[function(t,e,n){function r(t,e,n){var r=t[e];"function"==typeof r&&(t[e]=function(){var t=i(arguments),e={};o.emit(n+"before-start",[t],e);var a;e[m]&&e[m].dt&&(a=e[m].dt);var s=r.apply(this,t);return o.emit(n+"start",[t,a],s),s.then(function(t){return o.emit(n+"end",[null,t],s),t},function(t){throw o.emit(n+"end",[t],s),t})})}var o=t("ee").get("fetch"),i=t(33),a=t(32);e.exports=o;var s=window,c="fetch-",f=c+"body-",u=["arrayBuffer","blob","json","text","formData"],d=s.Request,p=s.Response,l=s.fetch,h="prototype",m="nr@context";d&&p&&l&&(a(u,function(t,e){r(d[h],e,f),r(p[h],e,f)}),r(s,"fetch",c),o.on(c+"end",function(t,e){var n=this;if(e){var r=e.headers.get("content-length");null!==r&&(n.rxSize=r),o.emit(c+"done",[null,e],n)}else o.emit(c+"done",[t],n)}))},{}],9:[function(t,e,n){var r=t("ee").get("history"),o=t("wrap-function")(r);e.exports=r;var i=window.history&&window.history.constructor&&window.history.constructor.prototype,a=window.history;i&&i.pushState&&i.replaceState&&(a=i),o.inPlace(a,["pushState","replaceState"],"-")},{}],10:[function(t,e,n){function r(t){function e(){f.emit("jsonp-end",[],l),t.removeEventListener("load",e,c(!1)),t.removeEventListener("error",n,c(!1))}function n(){f.emit("jsonp-error",[],l),f.emit("jsonp-end",[],l),t.removeEventListener("load",e,c(!1)),t.removeEventListener("error",n,c(!1))}var r=t&&"string"==typeof t.nodeName&&"script"===t.nodeName.toLowerCase();if(r){var o="function"==typeof t.addEventListener;if(o){var a=i(t.src);if(a){var d=s(a),p="function"==typeof d.parent[d.key];if(p){var l={};u.inPlace(d.parent,[d.key],"cb-",l),t.addEventListener("load",e,c(!1)),t.addEventListener("error",n,c(!1)),f.emit("new-jsonp",[t.src],l)}}}}}function o(){return"addEventListener"in window}function i(t){var e=t.match(d);return e?e[1]:null}function a(t,e){var n=t.match(l),r=n[1],o=n[3];return o?a(o,e[r]):e[r]}function s(t){var e=t.match(p);return e&&e.length>=3?{key:e[2],parent:a(e[1],window)}:{key:t,parent:window}}var c=t(23),f=t("ee").get("jsonp"),u=t("wrap-function")(f);if(e.exports=f,o()){var d=/[?&](?:callback|cb)=([^&#]+)/,p=/(.*)\\.([^.]+)/,l=/^(\\w+)(\\.|$)(.*)$/,h=["appendChild","insertBefore","replaceChild"];Node&&Node.prototype&&Node.prototype.appendChild?u.inPlace(Node.prototype,h,"dom-"):(u.inPlace(HTMLElement.prototype,h,"dom-"),u.inPlace(HTMLHeadElement.prototype,h,"dom-"),u.inPlace(HTMLBodyElement.prototype,h,"dom-")),f.on("dom-start",function(t){r(t[0])})}},{}],11:[function(t,e,n){var r=t("ee").get("mutation"),o=t("wrap-function")(r),i=NREUM.o.MO;e.exports=r,i&&(window.MutationObserver=function(t){return this instanceof i?new i(o(t,"fn-")):i.apply(this,arguments)},MutationObserver.prototype=i.prototype)},{}],12:[function(t,e,n){function r(t){var e=i.context(),n=s(t,"executor-",e,null,!1),r=new f(n);return i.context(r).getCtx=function(){return e},r}var o=t("wrap-function"),i=t("ee").get("promise"),a=t("ee").getOrSetContext,s=o(i),c=t(32),f=NREUM.o.PR;e.exports=i,f&&(window.Promise=r,["all","race"].forEach(function(t){var e=f[t];f[t]=function(n){function r(t){return function(){i.emit("propagate",[null,!o],a,!1,!1),o=o||!t}}var o=!1;c(n,function(e,n){Promise.resolve(n).then(r("all"===t),r(!1))});var a=e.apply(f,arguments),s=f.resolve(a);return s}}),["resolve","reject"].forEach(function(t){var e=f[t];f[t]=function(t){var n=e.apply(f,arguments);return t!==n&&i.emit("propagate",[t,!0],n,!1,!1),n}}),f.prototype["catch"]=function(t){return this.then(null,t)},f.prototype=Object.create(f.prototype,{constructor:{value:r}}),c(Object.getOwnPropertyNames(f),function(t,e){try{r[e]=f[e]}catch(n){}}),o.wrapInPlace(f.prototype,"then",function(t){return function(){var e=this,n=o.argsToArray.apply(this,arguments),r=a(e);r.promise=e,n[0]=s(n[0],"cb-",r,null,!1),n[1]=s(n[1],"cb-",r,null,!1);var c=t.apply(this,n);return r.nextPromise=c,i.emit("propagate",[e,!0],c,!1,!1),c}}),i.on("executor-start",function(t){t[0]=s(t[0],"resolve-",this,null,!1),t[1]=s(t[1],"resolve-",this,null,!1)}),i.on("executor-err",function(t,e,n){t[1](n)}),i.on("cb-end",function(t,e,n){i.emit("propagate",[n,!0],this.nextPromise,!1,!1)}),i.on("propagate",function(t,e,n){this.getCtx&&!e||(this.getCtx=function(){if(t instanceof Promise)var e=i.context(t);return e&&e.getCtx?e.getCtx():this})}),r.toString=function(){return""+f})},{}],13:[function(t,e,n){var r=t("ee").get("raf"),o=t("wrap-function")(r),i="equestAnimationFrame";e.exports=r,o.inPlace(window,["r"+i,"mozR"+i,"webkitR"+i,"msR"+i],"raf-"),r.on("raf-start",function(t){t[0]=o(t[0],"fn-")})},{}],14:[function(t,e,n){function r(t,e,n){t[0]=a(t[0],"fn-",null,n)}function o(t,e,n){this.method=n,this.timerDuration=isNaN(t[1])?0:+t[1],t[0]=a(t[0],"fn-",this,n)}var i=t("ee").get("timer"),a=t("wrap-function")(i),s="setTimeout",c="setInterval",f="clearTimeout",u="-start",d="-";e.exports=i,a.inPlace(window,[s,"setImmediate"],s+d),a.inPlace(window,[c],c+d),a.inPlace(window,[f,"clearImmediate"],f+d),i.on(c+u,r),i.on(s+u,o)},{}],15:[function(t,e,n){function r(t,e){d.inPlace(e,["onreadystatechange"],"fn-",s)}function o(){var t=this,e=u.context(t);t.readyState>3&&!e.resolved&&(e.resolved=!0,u.emit("xhr-resolved",[],t)),d.inPlace(t,y,"fn-",s)}function i(t){x.push(t),m&&(E?E.then(a):w?w(a):(R=-R,O.data=R))}function a(){for(var t=0;t<x.length;t++)r([],x[t]);x.length&&(x=[])}function s(t,e){return e}function c(t,e){for(var n in t)e[n]=t[n];return e}t(7);var f=t("ee"),u=f.get("xhr"),d=t("wrap-function")(u),p=t(23),l=NREUM.o,h=l.XHR,m=l.MO,v=l.PR,w=l.SI,g="readystatechange",y=["onload","onerror","onabort","onloadstart","onloadend","onprogress","ontimeout"],x=[];e.exports=u;var b=window.XMLHttpRequest=function(t){var e=new h(t);try{u.emit("new-xhr",[e],e),e.addEventListener(g,o,p(!1))}catch(n){try{u.emit("internal-error",[n])}catch(r){}}return e};if(c(h,b),b.prototype=h.prototype,d.inPlace(b.prototype,["open","send"],"-xhr-",s),u.on("send-xhr-start",function(t,e){r(t,e),i(e)}),u.on("open-xhr-start",r),m){var E=v&&v.resolve();if(!w&&!v){var R=1,O=document.createTextNode(R);new m(a).observe(O,{characterData:!0})}}else f.on("fn-end",function(t){t[0]&&t[0].type===g||a()})},{}],16:[function(t,e,n){function r(t){if(!s(t))return null;var e=window.NREUM;if(!e.loader_config)return null;var n=(e.loader_config.accountID||"").toString()||null,r=(e.loader_config.agentID||"").toString()||null,f=(e.loader_config.trustKey||"").toString()||null;if(!n||!r)return null;var h=l.generateSpanId(),m=l.generateTraceId(),v=Date.now(),w={spanId:h,traceId:m,timestamp:v};return(t.sameOrigin||c(t)&&p())&&(w.traceContextParentHeader=o(h,m),w.traceContextStateHeader=i(h,v,n,r,f)),(t.sameOrigin&&!u()||!t.sameOrigin&&c(t)&&d())&&(w.newrelicHeader=a(h,m,v,n,r,f)),w}function o(t,e){return"00-"+e+"-"+t+"-01"}function i(t,e,n,r,o){var i=0,a="",s=1,c="",f="";return o+"@nr="+i+"-"+s+"-"+n+"-"+r+"-"+t+"-"+a+"-"+c+"-"+f+"-"+e}function a(t,e,n,r,o,i){var a="btoa"in window&&"function"==typeof window.btoa;if(!a)return null;var s={v:[0,1],d:{ty:"Browser",ac:r,ap:o,id:t,tr:e,ti:n}};return i&&r!==i&&(s.d.tk=i),btoa(JSON.stringify(s))}function s(t){return f()&&c(t)}function c(t){var e=!1,n={};if("init"in NREUM&&"distributed_tracing"in NREUM.init&&(n=NREUM.init.distributed_tracing),t.sameOrigin)e=!0;else if(n.allowed_origins instanceof Array)for(var r=0;r<n.allowed_origins.length;r++){var o=h(n.allowed_origins[r]);if(t.hostname===o.hostname&&t.protocol===o.protocol&&t.port===o.port){e=!0;break}}return e}function f(){return"init"in NREUM&&"distributed_tracing"in NREUM.init&&!!NREUM.init.distributed_tracing.enabled}function u(){return"init"in NREUM&&"distributed_tracing"in NREUM.init&&!!NREUM.init.distributed_tracing.exclude_newrelic_header}function d(){return"init"in NREUM&&"distributed_tracing"in NREUM.init&&NREUM.init.distributed_tracing.cors_use_newrelic_header!==!1}function p(){return"init"in NREUM&&"distributed_tracing"in NREUM.init&&!!NREUM.init.distributed_tracing.cors_use_tracecontext_headers}var l=t(29),h=t(18);e.exports={generateTracePayload:r,shouldGenerateTrace:s}},{}],17:[function(t,e,n){function r(t){var e=this.params,n=this.metrics;if(!this.ended){this.ended=!0;for(var r=0;r<p;r++)t.removeEventListener(d[r],this.listener,!1);e.aborted||(n.duration=a.now()-this.startTime,this.loadCaptureCalled||4!==t.readyState?null==e.status&&(e.status=0):i(this,t),n.cbTime=this.cbTime,s("xhr",[e,n,this.startTime,this.endTime,"xhr"],this))}}function o(t,e){var n=c(e),r=t.params;r.hostname=n.hostname,r.port=n.port,r.protocol=n.protocol,r.host=n.hostname+":"+n.port,r.pathname=n.pathname,t.parsedOrigin=n,t.sameOrigin=n.sameOrigin}function i(t,e){t.params.status=e.status;var n=v(e,t.lastSize);if(n&&(t.metrics.rxSize=n),t.sameOrigin){var r=e.getResponseHeader("X-NewRelic-App-Data");r&&(t.params.cat=r.split(", ").pop())}t.loadCaptureCalled=!0}var a=t("loader");if(a.xhrWrappable&&!a.disabled){var s=t("handle"),c=t(18),f=t(16).generateTracePayload,u=t("ee"),d=["load","error","abort","timeout"],p=d.length,l=t("id"),h=t(24),m=t(22),v=t(19),w=t(23),g=NREUM.o.REQ,y=window.XMLHttpRequest;a.features.xhr=!0,t(15),t(8),u.on("new-xhr",function(t){var e=this;e.totalCbs=0,e.called=0,e.cbTime=0,e.end=r,e.ended=!1,e.xhrGuids={},e.lastSize=null,e.loadCaptureCalled=!1,e.params=this.params||{},e.metrics=this.metrics||{},t.addEventListener("load",function(n){i(e,t)},w(!1)),h&&(h>34||h<10)||t.addEventListener("progress",function(t){e.lastSize=t.loaded},w(!1))}),u.on("open-xhr-start",function(t){this.params={method:t[0]},o(this,t[1]),this.metrics={}}),u.on("open-xhr-end",function(t,e){"loader_config"in NREUM&&"xpid"in NREUM.loader_config&&this.sameOrigin&&e.setRequestHeader("X-NewRelic-ID",NREUM.loader_config.xpid);var n=f(this.parsedOrigin);if(n){var r=!1;n.newrelicHeader&&(e.setRequestHeader("newrelic",n.newrelicHeader),r=!0),n.traceContextParentHeader&&(e.setRequestHeader("traceparent",n.traceContextParentHeader),n.traceContextStateHeader&&e.setRequestHeader("tracestate",n.traceContextStateHeader),r=!0),r&&(this.dt=n)}}),u.on("send-xhr-start",function(t,e){var n=this.metrics,r=t[0],o=this;if(n&&r){var i=m(r);i&&(n.txSize=i)}this.startTime=a.now(),this.listener=function(t){try{"abort"!==t.type||o.loadCaptureCalled||(o.params.aborted=!0),("load"!==t.type||o.called===o.totalCbs&&(o.onloadCalled||"function"!=typeof e.onload))&&o.end(e)}catch(n){try{u.emit("internal-error",[n])}catch(r){}}};for(var s=0;s<p;s++)e.addEventListener(d[s],this.listener,w(!1))}),u.on("xhr-cb-time",function(t,e,n){this.cbTime+=t,e?this.onloadCalled=!0:this.called+=1,this.called!==this.totalCbs||!this.onloadCalled&&"function"==typeof n.onload||this.end(n)}),u.on("xhr-load-added",function(t,e){var n=""+l(t)+!!e;this.xhrGuids&&!this.xhrGuids[n]&&(this.xhrGuids[n]=!0,this.totalCbs+=1)}),u.on("xhr-load-removed",function(t,e){var n=""+l(t)+!!e;this.xhrGuids&&this.xhrGuids[n]&&(delete this.xhrGuids[n],this.totalCbs-=1)}),u.on("xhr-resolved",function(){this.endTime=a.now()}),u.on("addEventListener-end",function(t,e){e instanceof y&&"load"===t[0]&&u.emit("xhr-load-added",[t[1],t[2]],e)}),u.on("removeEventListener-end",function(t,e){e instanceof y&&"load"===t[0]&&u.emit("xhr-load-removed",[t[1],t[2]],e)}),u.on("fn-start",function(t,e,n){e instanceof y&&("onload"===n&&(this.onload=!0),("load"===(t[0]&&t[0].type)||this.onload)&&(this.xhrCbStart=a.now()))}),u.on("fn-end",function(t,e){this.xhrCbStart&&u.emit("xhr-cb-time",[a.now()-this.xhrCbStart,this.onload,e],e)}),u.on("fetch-before-start",function(t){function e(t,e){var n=!1;return e.newrelicHeader&&(t.set("newrelic",e.newrelicHeader),n=!0),e.traceContextParentHeader&&(t.set("traceparent",e.traceContextParentHeader),e.traceContextStateHeader&&t.set("tracestate",e.traceContextStateHeader),n=!0),n}var n,r=t[1]||{};"string"==typeof t[0]?n=t[0]:t[0]&&t[0].url?n=t[0].url:window.URL&&t[0]&&t[0]instanceof URL&&(n=t[0].href),n&&(this.parsedOrigin=c(n),this.sameOrigin=this.parsedOrigin.sameOrigin);var o=f(this.parsedOrigin);if(o&&(o.newrelicHeader||o.traceContextParentHeader))if("string"==typeof t[0]||window.URL&&t[0]&&t[0]instanceof URL){var i={};for(var a in r)i[a]=r[a];i.headers=new Headers(r.headers||{}),e(i.headers,o)&&(this.dt=o),t.length>1?t[1]=i:t.push(i)}else t[0]&&t[0].headers&&e(t[0].headers,o)&&(this.dt=o)}),u.on("fetch-start",function(t,e){this.params={},this.metrics={},this.startTime=a.now(),this.dt=e,t.length>=1&&(this.target=t[0]),t.length>=2&&(this.opts=t[1]);var n,r=this.opts||{},i=this.target;"string"==typeof i?n=i:"object"==typeof i&&i instanceof g?n=i.url:window.URL&&"object"==typeof i&&i instanceof URL&&(n=i.href),o(this,n);var s=(""+(i&&i instanceof g&&i.method||r.method||"GET")).toUpperCase();this.params.method=s,this.txSize=m(r.body)||0}),u.on("fetch-done",function(t,e){this.endTime=a.now(),this.params||(this.params={}),this.params.status=e?e.status:0;var n;"string"==typeof this.rxSize&&this.rxSize.length>0&&(n=+this.rxSize);var r={txSize:this.txSize,rxSize:n,duration:a.now()-this.startTime};s("xhr",[this.params,r,this.startTime,this.endTime,"fetch"],this)})}},{}],18:[function(t,e,n){var r={};e.exports=function(t){if(t in r)return r[t];var e=document.createElement("a"),n=window.location,o={};e.href=t,o.port=e.port;var i=e.href.split("://");!o.port&&i[1]&&(o.port=i[1].split("/")[0].split("@").pop().split(":")[1]),o.port&&"0"!==o.port||(o.port="https"===i[0]?"443":"80"),o.hostname=e.hostname||n.hostname,o.pathname=e.pathname,o.protocol=i[0],"/"!==o.pathname.charAt(0)&&(o.pathname="/"+o.pathname);var a=!e.protocol||":"===e.protocol||e.protocol===n.protocol,s=e.hostname===document.domain&&e.port===n.port;return o.sameOrigin=a&&(!e.hostname||s),"/"===o.pathname&&(r[t]=o),o}},{}],19:[function(t,e,n){function r(t,e){var n=t.responseType;return"json"===n&&null!==e?e:"arraybuffer"===n||"blob"===n||"json"===n?o(t.response):"text"===n||""===n||void 0===n?o(t.responseText):void 0}var o=t(22);e.exports=r},{}],20:[function(t,e,n){function r(){}function o(t,e,n,r){return function(){return u.recordSupportability("API/"+e+"/called"),i(t+e,[f.now()].concat(s(arguments)),n?null:this,r),n?void 0:this}}var i=t("handle"),a=t(32),s=t(33),c=t("ee").get("tracer"),f=t("loader"),u=t(25),d=NREUM;"undefined"==typeof window.newrelic&&(newrelic=d);var p=["setPageViewName","setCustomAttribute","setErrorHandler","finished","addToTrace","inlineHit","addRelease"],l="api-",h=l+"ixn-";a(p,function(t,e){d[e]=o(l,e,!0,"api")}),d.addPageAction=o(l,"addPageAction",!0),d.setCurrentRouteName=o(l,"routeName",!0),e.exports=newrelic,d.interaction=function(){return(new r).get()};var m=r.prototype={createTracer:function(t,e){var n={},r=this,o="function"==typeof e;return i(h+"tracer",[f.now(),t,n],r),function(){if(c.emit((o?"":"no-")+"fn-start",[f.now(),r,o],n),o)try{return e.apply(this,arguments)}catch(t){throw c.emit("fn-err",[arguments,this,t],n),t}finally{c.emit("fn-end",[f.now()],n)}}}};a("actionText,setName,setAttribute,save,ignore,onEnd,getContext,end,get".split(","),function(t,e){m[e]=o(h,e)}),newrelic.noticeError=function(t,e){"string"==typeof t&&(t=new Error(t)),u.recordSupportability("API/noticeError/called"),i("err",[t,f.now(),!1,e])}},{}],21:[function(t,e,n){function r(t){if(NREUM.init){for(var e=NREUM.init,n=t.split("."),r=0;r<n.length-1;r++)if(e=e[n[r]],"object"!=typeof e)return;return e=e[n[n.length-1]]}}e.exports={getSiteConfiguration:r}},{}],22:[function(t,e,n){e.exports=function(t){if("string"==typeof t&&t.length)return t.length;if("object"==typeof t){if("undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer&&t.byteLength)return t.byteLength;if("undefined"!=typeof Blob&&t instanceof Blob&&t.size)return t.size;if(!("undefined"!=typeof FormData&&t instanceof FormData))try{return JSON.stringify(t).length}catch(e){return}}}},{}],23:[function(t,e,n){var r=!1;try{var o=Object.defineProperty({},"passive",{get:function(){r=!0}});window.addEventListener("testPassive",null,o),window.removeEventListener("testPassive",null,o)}catch(i){}e.exports=function(t){return r?{passive:!0,capture:!!t}:!!t}},{}],24:[function(t,e,n){var r=0,o=navigator.userAgent.match(/Firefox[\\/\\s](\\d+\\.\\d+)/);o&&(r=+o[1]),e.exports=r},{}],25:[function(t,e,n){function r(t,e){var n=[a,t,{name:t},e];return i("storeMetric",n,null,"api"),n}function o(t,e){var n=[s,t,{name:t},e];return i("storeEventMetrics",n,null,"api"),n}var i=t("handle"),a="sm",s="cm";e.exports={constants:{SUPPORTABILITY_METRIC:a,CUSTOM_METRIC:s},recordSupportability:r,recordCustom:o}},{}],26:[function(t,e,n){function r(){return s.exists&&performance.now?Math.round(performance.now()):(i=Math.max((new Date).getTime(),i))-a}function o(){return i}var i=(new Date).getTime(),a=i,s=t(34);e.exports=r,e.exports.offset=a,e.exports.getLastTimestamp=o},{}],27:[function(t,e,n){function r(t){return!(!t||!t.protocol||"file:"===t.protocol)}e.exports=r},{}],28:[function(t,e,n){function r(t,e){var n=t.getEntries();n.forEach(function(t){"first-paint"===t.name?p("timing",["fp",Math.floor(t.startTime)]):"first-contentful-paint"===t.name&&p("timing",["fcp",Math.floor(t.startTime)])})}function o(t,e){var n=t.getEntries();if(n.length>0){var r=n[n.length-1];if(c&&c<r.startTime)return;p("lcp",[r])}}function i(t){t.getEntries().forEach(function(t){t.hadRecentInput||p("cls",[t])})}function a(t){if(t instanceof v&&!g){var e=Math.round(t.timeStamp),n={type:t.type};e<=l.now()?n.fid=l.now()-e:e>l.offset&&e<=Date.now()?(e-=l.offset,n.fid=l.now()-e):e=l.now(),g=!0,p("timing",["fi",e,n])}}function s(t){"hidden"===t&&(c=l.now(),p("pageHide",[c]))}if(!("init"in NREUM&&"page_view_timing"in NREUM.init&&"enabled"in NREUM.init.page_view_timing&&NREUM.init.page_view_timing.enabled===!1)){var c,f,u,d,p=t("handle"),l=t("loader"),h=t(31),m=t(23),v=NREUM.o.EV;if("PerformanceObserver"in window&&"function"==typeof window.PerformanceObserver){f=new PerformanceObserver(r);try{f.observe({entryTypes:["paint"]})}catch(w){}u=new PerformanceObserver(o);try{u.observe({entryTypes:["largest-contentful-paint"]})}catch(w){}d=new PerformanceObserver(i);try{d.observe({type:"layout-shift",buffered:!0})}catch(w){}}if("addEventListener"in document){var g=!1,y=["click","keydown","mousedown","pointerdown","touchstart"];y.forEach(function(t){document.addEventListener(t,a,m(!1))})}h(s)}},{}],29:[function(t,e,n){function r(){function t(){return e?15&e[n++]:16*Math.random()|0}var e=null,n=0,r=window.crypto||window.msCrypto;r&&r.getRandomValues&&(e=r.getRandomValues(new Uint8Array(31)));for(var o,i="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx",a="",s=0;s<i.length;s++)o=i[s],"x"===o?a+=t().toString(16):"y"===o?(o=3&t()|8,a+=o.toString(16)):a+=o;return a}function o(){return a(16)}function i(){return a(32)}function a(t){function e(){return n?15&n[r++]:16*Math.random()|0}var n=null,r=0,o=window.crypto||window.msCrypto;o&&o.getRandomValues&&Uint8Array&&(n=o.getRandomValues(new Uint8Array(31)));for(var i=[],a=0;a<t;a++)i.push(e().toString(16));return i.join("")}e.exports={generateUuid:r,generateSpanId:o,generateTraceId:i}},{}],30:[function(t,e,n){function r(t,e){if(!o)return!1;if(t!==o)return!1;if(!e)return!0;if(!i)return!1;for(var n=i.split("."),r=e.split("."),a=0;a<r.length;a++)if(r[a]!==n[a])return!1;return!0}var o=null,i=null,a=/Version\\/(\\S+)\\s+Safari/;if(navigator.userAgent){var s=navigator.userAgent,c=s.match(a);c&&s.indexOf("Chrome")===-1&&s.indexOf("Chromium")===-1&&(o="Safari",i=c[1])}e.exports={agent:o,version:i,match:r}},{}],31:[function(t,e,n){function r(t){function e(){t(s&&document[s]?document[s]:document[i]?"hidden":"visible")}"addEventListener"in document&&a&&document.addEventListener(a,e,o(!1))}var o=t(23);e.exports=r;var i,a,s;"undefined"!=typeof document.hidden?(i="hidden",a="visibilitychange",s="visibilityState"):"undefined"!=typeof document.msHidden?(i="msHidden",a="msvisibilitychange"):"undefined"!=typeof document.webkitHidden&&(i="webkitHidden",a="webkitvisibilitychange",s="webkitVisibilityState")},{}],32:[function(t,e,n){function r(t,e){var n=[],r="",i=0;for(r in t)o.call(t,r)&&(n[i]=e(r,t[r]),i+=1);return n}var o=Object.prototype.hasOwnProperty;e.exports=r},{}],33:[function(t,e,n){function r(t,e,n){e||(e=0),"undefined"==typeof n&&(n=t?t.length:0);for(var r=-1,o=n-e||0,i=Array(o<0?0:o);++r<o;)i[r]=t[e+r];return i}e.exports=r},{}],34:[function(t,e,n){e.exports={exists:"undefined"!=typeof window.performance&&window.performance.timing&&"undefined"!=typeof window.performance.timing.navigationStart}},{}],ee:[function(t,e,n){function r(){}function o(t){function e(t){return t&&t instanceof r?t:t?f(t,c,a):a()}function n(n,r,o,i,a){if(a!==!1&&(a=!0),!l.aborted||i){t&&a&&t(n,r,o);for(var s=e(o),c=m(n),f=c.length,u=0;u<f;u++)c[u].apply(s,r);var p=d[y[n]];return p&&p.push([x,n,r,s]),s}}function i(t,e){g[t]=m(t).concat(e)}function h(t,e){var n=g[t];if(n)for(var r=0;r<n.length;r++)n[r]===e&&n.splice(r,1)}function m(t){return g[t]||[]}function v(t){return p[t]=p[t]||o(n)}function w(t,e){l.aborted||u(t,function(t,n){e=e||"feature",y[n]=e,e in d||(d[e]=[])})}var g={},y={},x={on:i,addEventListener:i,removeEventListener:h,emit:n,get:v,listeners:m,context:e,buffer:w,abort:s,aborted:!1};return x}function i(t){return f(t,c,a)}function a(){return new r}function s(){(d.api||d.feature)&&(l.aborted=!0,d=l.backlog={})}var c="nr@context",f=t("gos"),u=t(32),d={},p={},l=e.exports=o();e.exports.getOrSetContext=i,l.backlog=d},{}],gos:[function(t,e,n){function r(t,e,n){if(o.call(t,e))return t[e];var r=n();if(Object.defineProperty&&Object.keys)try{return Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!1}),r}catch(i){}return t[e]=r,r}var o=Object.prototype.hasOwnProperty;e.exports=r},{}],handle:[function(t,e,n){function r(t,e,n,r){o.buffer([t],r),o.emit(t,e,n)}var o=t("ee").get("handle");e.exports=r,r.ee=o},{}],id:[function(t,e,n){function r(t){var e=typeof t;return!t||"object"!==e&&"function"!==e?-1:t===window?0:a(t,i,function(){return o++})}var o=1,i="nr@id",a=t("gos");e.exports=r},{}],loader:[function(t,e,n){function r(){if(!P++){var t=T.info=NREUM.info,e=v.getElementsByTagName("script")[0];if(setTimeout(f.abort,3e4),!(t&&t.licenseKey&&t.applicationID&&e))return f.abort();c(R,function(e,n){t[e]||(t[e]=n)});var n=a();s("mark",["onload",n+T.offset],null,"api"),s("timing",["load",n]);var r=v.createElement("script");0===t.agent.indexOf("http://")||0===t.agent.indexOf("https://")?r.src=t.agent:r.src=h+"://"+t.agent,e.parentNode.insertBefore(r,e)}}function o(){"complete"===v.readyState&&i()}function i(){s("mark",["domContent",a()+T.offset],null,"api")}var a=t(26),s=t("handle"),c=t(32),f=t("ee"),u=t(30),d=t(27),p=t(21),l=t(23),h=p.getSiteConfiguration("ssl")===!1?"http":"https",m=window,v=m.document,w="addEventListener",g="attachEvent",y=m.XMLHttpRequest,x=y&&y.prototype,b=!d(m.location);NREUM.o={ST:setTimeout,SI:m.setImmediate,CT:clearTimeout,XHR:y,REQ:m.Request,EV:m.Event,PR:m.Promise,MO:m.MutationObserver};var E=""+location,R={beacon:"bam.nr-data.net",errorBeacon:"bam.nr-data.net",agent:"js-agent.newrelic.com/nr-spa-1212.min.js"},O=y&&x&&x[w]&&!/CriOS/.test(navigator.userAgent),T=e.exports={offset:a.getLastTimestamp(),now:a,origin:E,features:{},xhrWrappable:O,userAgent:u,disabled:b};if(!b){t(20),t(28),v[w]?(v[w]("DOMContentLoaded",i,l(!1)),m[w]("load",r,l(!1))):(v[g]("onreadystatechange",o),m[g]("onload",r)),s("mark",["firstbyte",a.getLastTimestamp()],null,"api");var P=0}},{}],"wrap-function":[function(t,e,n){function r(t,e){function n(e,n,r,c,f){function nrWrapper(){var i,a,u,p;try{a=this,i=d(arguments),u="function"==typeof r?r(i,a):r||{}}catch(l){o([l,"",[i,a,c],u],t)}s(n+"start",[i,a,c],u,f);try{return p=e.apply(a,i)}catch(h){throw s(n+"err",[i,a,h],u,f),h}finally{s(n+"end",[i,a,p],u,f)}}return a(e)?e:(n||(n=""),nrWrapper[p]=e,i(e,nrWrapper,t),nrWrapper)}function r(t,e,r,o,i){r||(r="");var s,c,f,u="-"===r.charAt(0);for(f=0;f<e.length;f++)c=e[f],s=t[c],a(s)||(t[c]=n(s,u?c+r:r,o,c,i))}function s(n,r,i,a){if(!h||e){var s=h;h=!0;try{t.emit(n,r,i,e,a)}catch(c){o([c,n,r,i],t)}h=s}}return t||(t=u),n.inPlace=r,n.flag=p,n}function o(t,e){e||(e=u);try{e.emit("internal-error",t)}catch(n){}}function i(t,e,n){if(Object.defineProperty&&Object.keys)try{var r=Object.keys(t);return r.forEach(function(n){Object.defineProperty(e,n,{get:function(){return t[n]},set:function(e){return t[n]=e,e}})}),e}catch(i){o([i],n)}for(var a in t)l.call(t,a)&&(e[a]=t[a]);return e}function a(t){return!(t&&t instanceof Function&&t.apply&&!t[p])}function s(t,e){var n=e(t);return n[p]=t,i(t,n,u),n}function c(t,e,n){var r=t[e];t[e]=s(r,n)}function f(){for(var t=arguments.length,e=new Array(t),n=0;n<t;++n)e[n]=arguments[n];return e}var u=t("ee"),d=t(33),p="nr@original",l=Object.prototype.hasOwnProperty,h=!1;e.exports=r,e.exports.wrapFunction=s,e.exports.wrapInPlace=c,e.exports.argsToArray=f},{}]},{},["loader",2,17,5,3,4]);
|
|
74
|
-
;NREUM.loader_config={accountID:"${this.options.accountID}",trustKey:"${this.options.trustKey}",agentID:"${this.options.agentID}",licenseKey:"${this.options.licenseKey}",applicationID:"${this.options.applicationID}"}
|
|
75
|
-
;NREUM.info={beacon:"bam-cell.nr-data.net",errorBeacon:"bam-cell.nr-data.net",licenseKey:"${this.options.licenseKey}",applicationID:"${this.options.applicationID}",sa:1}
|
|
76
|
-
`;
|
|
77
|
-
|
|
78
|
-
const optionKeys = Object.keys(this.options) as OptionTypes[];
|
|
79
|
-
optionKeys.forEach((key: OptionTypes) => {
|
|
80
|
-
if (!this.options[key]) {
|
|
81
|
-
throw new Error(`${key} argument is required`);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
apply(compiler: Compiler) {
|
|
87
|
-
compiler.hooks.compilation.tap('HtmlWebpackNewRelicPlugin', (compilation) => {
|
|
88
|
-
HtmlWebpackPlugin.getHooks(compilation).alterAssetTagGroups.tap(
|
|
89
|
-
'HtmlWebpackNewRelicPlugin',
|
|
90
|
-
// @ts-expect-error TS doesn't like this declaration, but it seems to work fine.
|
|
91
|
-
(data) => {
|
|
92
|
-
const newRelicScriptTag = HtmlWebpackPlugin.createHtmlTagObject(
|
|
93
|
-
'script',
|
|
94
|
-
{ type: 'text/javascript' },
|
|
95
|
-
this.newRelicString,
|
|
96
|
-
);
|
|
97
|
-
data.headTags.unshift(newRelicScriptTag);
|
|
98
|
-
},
|
|
99
|
-
);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Dineshkumar Pandiyan <flexdinesh@gmail.com>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# html-webpack-new-relic-plugin
|
|
2
|
-
|
|
3
|
-
This plugin comes from https://github.com/victorrodrigues/html-webpack-new-relic-plugin.
|
|
4
|
-
|
|
5
|
-
We're bringing it into frontend-build so that we can more easily maintain the new relic snippet. We
|
|
6
|
-
haven't found much value in having it as a separate package - it mostly just adds a step when we're
|
|
7
|
-
trying to keep it up to date.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('Hello World');
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { Compilation, Compiler, WebpackPluginInstance, sources } from 'webpack';
|
|
2
|
-
|
|
3
|
-
import { ParagonThemeUrls } from '../../types';
|
|
4
|
-
import {
|
|
5
|
-
getParagonThemeCss,
|
|
6
|
-
getParagonVersion,
|
|
7
|
-
} from '../../utils/paragonUtils';
|
|
8
|
-
import {
|
|
9
|
-
getParagonStylesheetUrls,
|
|
10
|
-
injectMetadataIntoDocument,
|
|
11
|
-
injectParagonCoreStylesheets,
|
|
12
|
-
injectParagonThemeVariantStylesheets,
|
|
13
|
-
} from './utils';
|
|
14
|
-
|
|
15
|
-
// Get Paragon and brand versions / CSS files from disk.
|
|
16
|
-
const paragonVersion = getParagonVersion(process.cwd());
|
|
17
|
-
const paragonThemeCss = getParagonThemeCss(process.cwd());
|
|
18
|
-
const brandVersion = getParagonVersion(process.cwd(), { isBrandOverride: true });
|
|
19
|
-
const brandThemeCss = getParagonThemeCss(process.cwd(), { isBrandOverride: true });
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* 1. Injects `PARAGON_THEME` global variable into the HTML document during the Webpack compilation process.
|
|
23
|
-
* 2. Injects `<link rel="preload" as="style">` element(s) for the Paragon and brand CSS into the HTML document.
|
|
24
|
-
*/
|
|
25
|
-
export default class ParagonWebpackPlugin implements WebpackPluginInstance {
|
|
26
|
-
pluginName: string;
|
|
27
|
-
paragonThemeUrlsConfig: ParagonThemeUrls | object;
|
|
28
|
-
processAssetsHandlers: ((compilation: any) => void)[];
|
|
29
|
-
paragonMetadata: any;
|
|
30
|
-
|
|
31
|
-
constructor({ processAssetsHandlers = [] } = {}) {
|
|
32
|
-
this.pluginName = 'ParagonWebpackPlugin';
|
|
33
|
-
this.paragonThemeUrlsConfig = {};
|
|
34
|
-
this.paragonMetadata = {};
|
|
35
|
-
|
|
36
|
-
// List of handlers to be executed after processing assets during the Webpack compilation.
|
|
37
|
-
this.processAssetsHandlers = [
|
|
38
|
-
this.resolveParagonThemeUrlsFromConfig,
|
|
39
|
-
this.injectParagonMetadataIntoDocument,
|
|
40
|
-
this.injectParagonStylesheetsIntoDocument,
|
|
41
|
-
...processAssetsHandlers,
|
|
42
|
-
].map(handler => handler.bind(this));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Resolves the MFE configuration from ``PARAGON_THEME_URLS`` in the environment variables. `
|
|
47
|
-
*
|
|
48
|
-
* @returns {Object} Metadata about the Paragon and brand theme URLs from configuration.
|
|
49
|
-
*/
|
|
50
|
-
async resolveParagonThemeUrlsFromConfig() {
|
|
51
|
-
try {
|
|
52
|
-
this.paragonThemeUrlsConfig = JSON.parse(process.env.PARAGON_THEME_URLS ?? '{}');
|
|
53
|
-
} catch (error) {
|
|
54
|
-
console.info('Paragon Plugin cannot load PARAGON_THEME_URLS env variable, skipping.');
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Generates `PARAGON_THEME` global variable in HTML document.
|
|
60
|
-
* @param {Object} compilation Webpack compilation object.
|
|
61
|
-
*/
|
|
62
|
-
injectParagonMetadataIntoDocument(compilation: Compilation) {
|
|
63
|
-
const paragonMetadata = injectMetadataIntoDocument(compilation, {
|
|
64
|
-
paragonThemeCss,
|
|
65
|
-
paragonVersion,
|
|
66
|
-
brandThemeCss,
|
|
67
|
-
brandVersion,
|
|
68
|
-
});
|
|
69
|
-
if (paragonMetadata) {
|
|
70
|
-
this.paragonMetadata = paragonMetadata;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
injectParagonStylesheetsIntoDocument(compilation: Compilation) {
|
|
75
|
-
const file = compilation.getAsset('index.html');
|
|
76
|
-
|
|
77
|
-
// If the `index.html` hasn't loaded yet, or there are no Paragon theme URLs, then there is nothing to do yet.
|
|
78
|
-
if (!file || Object.keys(this.paragonThemeUrlsConfig || {}).length === 0) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Generates `<link rel="preload" as="style">` element(s) for the Paragon and brand CSS files.
|
|
83
|
-
const paragonStylesheetUrls = getParagonStylesheetUrls({
|
|
84
|
-
paragonThemeUrls: this.paragonThemeUrlsConfig as ParagonThemeUrls,
|
|
85
|
-
paragonVersion,
|
|
86
|
-
brandVersion,
|
|
87
|
-
});
|
|
88
|
-
const {
|
|
89
|
-
core: paragonCoreCss,
|
|
90
|
-
variants: paragonThemeVariantCss,
|
|
91
|
-
} = paragonStylesheetUrls;
|
|
92
|
-
|
|
93
|
-
// We do not expect to have a Buffer here, ever.
|
|
94
|
-
const originalSource = file.source.source() as string;
|
|
95
|
-
|
|
96
|
-
// Inject core CSS
|
|
97
|
-
let newSource = injectParagonCoreStylesheets({
|
|
98
|
-
source: originalSource,
|
|
99
|
-
paragonCoreCss,
|
|
100
|
-
paragonThemeCss,
|
|
101
|
-
brandThemeCss,
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
// Inject theme variant CSS
|
|
105
|
-
newSource = injectParagonThemeVariantStylesheets({
|
|
106
|
-
// @ts-expect-error newSource is possibly undefined here.
|
|
107
|
-
source: newSource.source(),
|
|
108
|
-
paragonThemeVariantCss,
|
|
109
|
-
paragonThemeCss,
|
|
110
|
-
brandThemeCss,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
// @ts-expect-error newSource is possibly undefined here.
|
|
114
|
-
compilation.updateAsset('index.html', new sources.RawSource(newSource.source()));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
apply(compiler: Compiler) {
|
|
118
|
-
compiler.hooks.thisCompilation.tap(this.pluginName, (compilation) => {
|
|
119
|
-
compilation.hooks.processAssets.tap(
|
|
120
|
-
{
|
|
121
|
-
name: this.pluginName,
|
|
122
|
-
stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
123
|
-
additionalAssets: true,
|
|
124
|
-
},
|
|
125
|
-
() => {
|
|
126
|
-
// Iterate through each configured handler, passing the compilation to each.
|
|
127
|
-
this.processAssetsHandlers.forEach(async (handler) => {
|
|
128
|
-
await handler(compilation);
|
|
129
|
-
});
|
|
130
|
-
},
|
|
131
|
-
);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Compilation } from 'webpack';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Finds the core CSS asset from the given array of Paragon assets.
|
|
5
|
-
*
|
|
6
|
-
* @param {Array} paragonAssets - An array of Paragon assets.
|
|
7
|
-
* @return {Object|undefined} The core CSS asset, or undefined if not found.
|
|
8
|
-
*/
|
|
9
|
-
export function findCoreCssAsset(paragonAssets: any) {
|
|
10
|
-
return paragonAssets?.find((asset: any) => asset.name.includes('core') && asset.name.endsWith('.css'));
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Finds the theme variant CSS assets from the given Paragon assets based on the provided options.
|
|
15
|
-
*
|
|
16
|
-
* @param {Array} paragonAssets - An array of Paragon assets.
|
|
17
|
-
* @param {Object} options - The options for finding the theme variant CSS assets.
|
|
18
|
-
* @param {boolean} [options.isBrandOverride=false] - Indicates if the theme variant is a brand override.
|
|
19
|
-
* @param {Object} [options.brandThemeCss] - The brand theme CSS object.
|
|
20
|
-
* @param {Object} [options.paragonThemeCss] - The Paragon theme CSS object.
|
|
21
|
-
* @return {Object} - The theme variant CSS assets.
|
|
22
|
-
*/
|
|
23
|
-
export function findThemeVariantCssAssets(paragonAssets: any[], {
|
|
24
|
-
isBrandOverride = false,
|
|
25
|
-
brandThemeCss,
|
|
26
|
-
paragonThemeCss,
|
|
27
|
-
}: { isBrandOverride: boolean, brandThemeCss: any, paragonThemeCss: any }) {
|
|
28
|
-
const themeVariantsSource = isBrandOverride ? brandThemeCss?.variants : paragonThemeCss?.variants;
|
|
29
|
-
const themeVariantCssAssets: any = {};
|
|
30
|
-
Object.entries(themeVariantsSource || {}).forEach(([themeVariant, value]: any) => {
|
|
31
|
-
const foundThemeVariantAsset = paragonAssets.find((asset) => asset.name.includes(value.outputChunkName));
|
|
32
|
-
if (!foundThemeVariantAsset) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
themeVariantCssAssets[themeVariant] = {
|
|
36
|
-
fileName: foundThemeVariantAsset.name,
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
return themeVariantCssAssets;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Retrieves the CSS assets from the compilation based on the provided options.
|
|
44
|
-
*
|
|
45
|
-
* @param {Object} compilation - The compilation object.
|
|
46
|
-
* @param {Object} options - The options for retrieving the CSS assets.
|
|
47
|
-
* @param {boolean} [options.isBrandOverride=false] - Indicates if the assets are for a brand override.
|
|
48
|
-
* @param {Object} [options.brandThemeCss] - The brand theme CSS object.
|
|
49
|
-
* @param {Object} [options.paragonThemeCss] - The Paragon theme CSS object.
|
|
50
|
-
* @return {Object} - The CSS assets, including the core CSS asset and theme variant CSS assets.
|
|
51
|
-
*/
|
|
52
|
-
export function getCssAssetsFromCompilation(compilation: Compilation, {
|
|
53
|
-
isBrandOverride = false,
|
|
54
|
-
brandThemeCss,
|
|
55
|
-
paragonThemeCss,
|
|
56
|
-
}: { isBrandOverride?: boolean, brandThemeCss: any, paragonThemeCss: any }) {
|
|
57
|
-
const assetSubstring = isBrandOverride ? 'brand' : 'paragon';
|
|
58
|
-
const paragonAssets = compilation.getAssets().filter(asset => asset.name.includes(assetSubstring) && asset.name.endsWith('.css'));
|
|
59
|
-
const coreCssAsset = findCoreCssAsset(paragonAssets);
|
|
60
|
-
const themeVariantCssAssets = findThemeVariantCssAssets(paragonAssets, {
|
|
61
|
-
isBrandOverride,
|
|
62
|
-
paragonThemeCss,
|
|
63
|
-
brandThemeCss,
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
coreCssAsset: {
|
|
67
|
-
fileName: coreCssAsset?.name,
|
|
68
|
-
},
|
|
69
|
-
themeVariantCssAssets,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { Compilation, sources } from 'webpack';
|
|
2
|
-
|
|
3
|
-
import { getCssAssetsFromCompilation } from './assetUtils';
|
|
4
|
-
import { generateScriptContents, insertScriptContentsIntoDocument } from './scriptUtils';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Injects metadata into the HTML document by modifying the 'index.html' asset in the compilation.
|
|
8
|
-
*
|
|
9
|
-
* @param {Object} compilation - The Webpack compilation object.
|
|
10
|
-
* @param {Object} options - The options object.
|
|
11
|
-
* @param {Object} options.paragonThemeCss - The Paragon theme CSS object.
|
|
12
|
-
* @param {string} options.paragonVersion - The version of the Paragon theme.
|
|
13
|
-
* @param {Object} options.brandThemeCss - The brand theme CSS object.
|
|
14
|
-
* @param {string} options.brandVersion - The version of the brand theme.
|
|
15
|
-
* @return {Object|undefined} The script contents object if the 'index.html' asset exists, otherwise undefined.
|
|
16
|
-
*/
|
|
17
|
-
export function injectMetadataIntoDocument(compilation: Compilation, {
|
|
18
|
-
paragonThemeCss,
|
|
19
|
-
paragonVersion,
|
|
20
|
-
brandThemeCss,
|
|
21
|
-
brandVersion,
|
|
22
|
-
}: {
|
|
23
|
-
paragonThemeCss: any,
|
|
24
|
-
paragonVersion: string,
|
|
25
|
-
brandThemeCss: any,
|
|
26
|
-
brandVersion: string,
|
|
27
|
-
}) {
|
|
28
|
-
const file = compilation.getAsset('index.html');
|
|
29
|
-
if (!file) {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
const {
|
|
33
|
-
coreCssAsset: paragonCoreCssAsset,
|
|
34
|
-
themeVariantCssAssets: paragonThemeVariantCssAssets,
|
|
35
|
-
} = getCssAssetsFromCompilation(compilation, {
|
|
36
|
-
brandThemeCss,
|
|
37
|
-
paragonThemeCss,
|
|
38
|
-
});
|
|
39
|
-
const {
|
|
40
|
-
coreCssAsset: brandCoreCssAsset,
|
|
41
|
-
themeVariantCssAssets: brandThemeVariantCssAssets,
|
|
42
|
-
} = getCssAssetsFromCompilation(compilation, {
|
|
43
|
-
isBrandOverride: true,
|
|
44
|
-
brandThemeCss,
|
|
45
|
-
paragonThemeCss,
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
const scriptContents = generateScriptContents({
|
|
49
|
-
paragonCoreCssAsset,
|
|
50
|
-
paragonThemeVariantCssAssets,
|
|
51
|
-
brandCoreCssAsset,
|
|
52
|
-
brandThemeVariantCssAssets,
|
|
53
|
-
paragonThemeCss,
|
|
54
|
-
paragonVersion,
|
|
55
|
-
brandThemeCss,
|
|
56
|
-
brandVersion,
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
// We expect this to be a string at all times.
|
|
60
|
-
const originalSource = file.source.source() as string;
|
|
61
|
-
const newSource = insertScriptContentsIntoDocument({
|
|
62
|
-
originalSource,
|
|
63
|
-
// @ts-expect-error This parameter doesn't exist in the function.
|
|
64
|
-
coreCssAsset: paragonCoreCssAsset,
|
|
65
|
-
themeVariantCssAssets: paragonThemeVariantCssAssets,
|
|
66
|
-
scriptContents,
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
compilation.updateAsset('index.html', new sources.RawSource(newSource.source()));
|
|
70
|
-
|
|
71
|
-
return scriptContents;
|
|
72
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { sources } from 'webpack';
|
|
2
|
-
import { ParagonThemeUrls } from '../../../types';
|
|
3
|
-
import { insertStylesheetsIntoDocument } from './stylesheetUtils';
|
|
4
|
-
import { handleVersionSubstitution } from './tagUtils';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Injects Paragon core stylesheets into the document.
|
|
8
|
-
*
|
|
9
|
-
* @param {Object} options - The options object.
|
|
10
|
-
* @param {string|object} options.source - The source HTML document.
|
|
11
|
-
* @param {Object} options.paragonCoreCss - The Paragon core CSS object.
|
|
12
|
-
* @param {Object} options.paragonThemeCss - The Paragon theme CSS object.
|
|
13
|
-
* @param {Object} options.brandThemeCss - The brand theme CSS object.
|
|
14
|
-
* @return {string|object} The modified HTML document with Paragon core stylesheets injected.
|
|
15
|
-
*/
|
|
16
|
-
export function injectParagonCoreStylesheets({
|
|
17
|
-
source,
|
|
18
|
-
paragonCoreCss,
|
|
19
|
-
paragonThemeCss,
|
|
20
|
-
brandThemeCss,
|
|
21
|
-
}: {
|
|
22
|
-
source: string,
|
|
23
|
-
paragonCoreCss: any,
|
|
24
|
-
paragonThemeCss: any,
|
|
25
|
-
brandThemeCss: any,
|
|
26
|
-
}) {
|
|
27
|
-
return insertStylesheetsIntoDocument({
|
|
28
|
-
source,
|
|
29
|
-
urls: paragonCoreCss.urls,
|
|
30
|
-
// @ts-expect-error These two parameters don't exist on insertStylesheetsIntoDocument
|
|
31
|
-
paragonThemeCss,
|
|
32
|
-
brandThemeCss,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Injects Paragon theme variant stylesheets into the document.
|
|
38
|
-
*
|
|
39
|
-
* @param {Object} options - The options object.
|
|
40
|
-
* @param {string|object} options.source - The source HTML document.
|
|
41
|
-
* @param {Object} options.paragonThemeVariantCss - The Paragon theme variant CSS object.
|
|
42
|
-
* @param {Object} options.paragonThemeCss - The Paragon theme CSS object.
|
|
43
|
-
* @param {Object} options.brandThemeCss - The brand theme CSS object.
|
|
44
|
-
* @return {string|object} The modified HTML document with Paragon theme variant stylesheets injected.
|
|
45
|
-
*/
|
|
46
|
-
export function injectParagonThemeVariantStylesheets({
|
|
47
|
-
source,
|
|
48
|
-
paragonThemeVariantCss,
|
|
49
|
-
paragonThemeCss,
|
|
50
|
-
brandThemeCss,
|
|
51
|
-
}: { source: sources.ReplaceSource | undefined, paragonThemeVariantCss: any, paragonThemeCss: any, brandThemeCss: any }) {
|
|
52
|
-
let newSource: sources.ReplaceSource | undefined = source;
|
|
53
|
-
Object.values(paragonThemeVariantCss).forEach(({ urls }: any) => {
|
|
54
|
-
newSource = insertStylesheetsIntoDocument({
|
|
55
|
-
source: (typeof newSource === 'object' ? newSource.source() : newSource) as string,
|
|
56
|
-
urls,
|
|
57
|
-
// @ts-expect-error These two parameters don't exist on insertStylesheetsIntoDocument
|
|
58
|
-
paragonThemeCss,
|
|
59
|
-
brandThemeCss,
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
return newSource;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Retrieves the URLs of the Paragon stylesheets based on the provided theme URLs, Paragon version, and brand version.
|
|
66
|
-
*
|
|
67
|
-
* @param {Object} options - The options object.
|
|
68
|
-
* @param {Object} options.paragonThemeUrls - The URLs of the Paragon theme.
|
|
69
|
-
* @param {string} options.paragonVersion - The version of the Paragon theme.
|
|
70
|
-
* @param {string} options.brandVersion - The version of the brand theme.
|
|
71
|
-
* @return {Object} An object containing the URLs of the Paragon stylesheets.
|
|
72
|
-
*/
|
|
73
|
-
export function getParagonStylesheetUrls({ paragonThemeUrls, paragonVersion, brandVersion }: { paragonThemeUrls: ParagonThemeUrls, paragonVersion: string, brandVersion: string }): ParagonThemeUrls {
|
|
74
|
-
const paragonCoreCssUrl = 'urls' in paragonThemeUrls.core && paragonThemeUrls.core.urls !== undefined ? paragonThemeUrls.core.urls.default : paragonThemeUrls.core.url;
|
|
75
|
-
const brandCoreCssUrl = 'urls' in paragonThemeUrls.core && paragonThemeUrls.core.urls !== undefined ? paragonThemeUrls.core.urls.brandOverride : undefined;
|
|
76
|
-
|
|
77
|
-
const defaultThemeVariants = paragonThemeUrls.defaults || {};
|
|
78
|
-
|
|
79
|
-
const coreCss = {
|
|
80
|
-
urls: {
|
|
81
|
-
default: handleVersionSubstitution({
|
|
82
|
-
url: paragonCoreCssUrl,
|
|
83
|
-
wildcardKeyword: '$paragonVersion',
|
|
84
|
-
localVersion: paragonVersion
|
|
85
|
-
}),
|
|
86
|
-
brandOverride: handleVersionSubstitution({
|
|
87
|
-
url: brandCoreCssUrl,
|
|
88
|
-
wildcardKeyword: '$brandVersion',
|
|
89
|
-
localVersion: brandVersion
|
|
90
|
-
}),
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const themeVariantsCss: any = {};
|
|
95
|
-
const themeVariantsEntries = Object.entries(paragonThemeUrls.variants || {});
|
|
96
|
-
themeVariantsEntries.forEach(([themeVariant, { url, urls }]) => {
|
|
97
|
-
const themeVariantMetadata = { urls: {} };
|
|
98
|
-
if (url) {
|
|
99
|
-
themeVariantMetadata.urls = {
|
|
100
|
-
default: handleVersionSubstitution({
|
|
101
|
-
url,
|
|
102
|
-
wildcardKeyword: '$paragonVersion',
|
|
103
|
-
localVersion: paragonVersion,
|
|
104
|
-
}),
|
|
105
|
-
// If there is no brand override URL, then we don't need to do any version substitution
|
|
106
|
-
// but we still need to return the property.
|
|
107
|
-
brandOverride: undefined,
|
|
108
|
-
};
|
|
109
|
-
} else if (urls) {
|
|
110
|
-
themeVariantMetadata.urls = {
|
|
111
|
-
default: handleVersionSubstitution({
|
|
112
|
-
url: urls.default,
|
|
113
|
-
wildcardKeyword: '$paragonVersion',
|
|
114
|
-
localVersion: paragonVersion,
|
|
115
|
-
}),
|
|
116
|
-
brandOverride: handleVersionSubstitution({
|
|
117
|
-
url: urls.brandOverride,
|
|
118
|
-
wildcardKeyword: '$brandVersion',
|
|
119
|
-
localVersion: brandVersion,
|
|
120
|
-
}),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
themeVariantsCss[themeVariant] = themeVariantMetadata;
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
core: coreCss,
|
|
128
|
-
variants: themeVariantsCss,
|
|
129
|
-
defaults: defaultThemeVariants,
|
|
130
|
-
};
|
|
131
|
-
}
|