@capillarytech/creatives-library 9.0.35 → 9.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/app.js +175 -10
  2. package/entry.js +1 -67
  3. package/mfe-exposed-components.js +4 -2
  4. package/package.json +2 -2
  5. package/services/api.js +1 -9
  6. package/styles/containers/layout/_layoutPage.scss +6 -8
  7. package/utils/gtmTrackers/gtmEvents/creativeDetails.js +1 -2
  8. package/utils/rcsPayloadUtils.js +2 -5
  9. package/utils/tests/rcsPayloadUtils.test.js +2 -54
  10. package/v2Components/CapActionButton/constants.js +0 -1
  11. package/v2Components/CapActionButton/index.js +9 -77
  12. package/v2Components/CapActionButton/index.scss +0 -13
  13. package/v2Components/CapActionButton/messages.js +0 -13
  14. package/v2Components/CapActionButton/tests/index.test.js +1 -32
  15. package/v2Components/CommonTestAndPreview/index.js +15 -44
  16. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -78
  17. package/v2Components/CommonTestAndPreview/utils.js +0 -34
  18. package/v2Components/NavigationBar/index.js +7 -9
  19. package/v2Components/NavigationBar/tests/index.test.js +19 -39
  20. package/v2Components/SmsFallback/index.js +0 -6
  21. package/v2Containers/Cap/constants.js +0 -1
  22. package/v2Containers/Cap/index.js +27 -57
  23. package/v2Containers/CreativesContainer/index.js +8 -11
  24. package/v2Containers/CreativesContainer/tests/index.test.js +0 -53
  25. package/v2Containers/Rcs/carouselUtils.js +73 -46
  26. package/v2Containers/Rcs/components/CarouselCard.js +9 -11
  27. package/v2Containers/Rcs/components/CarouselCardButtons.js +0 -20
  28. package/v2Containers/Rcs/constants.js +7 -2
  29. package/v2Containers/Rcs/index.js +205 -226
  30. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +47 -60
  31. package/v2Containers/Rcs/tests/CarouselCard.test.js +2 -1
  32. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -286
  33. package/v2Containers/Rcs/tests/carouselUtils.test.js +32 -28
  34. package/v2Containers/Rcs/tests/index.test.js +238 -151
  35. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -110
  36. package/v2Containers/Rcs/tests/utils.test.js +17 -36
  37. package/v2Containers/Rcs/utils.js +55 -28
  38. package/v2Containers/SmsTrai/Edit/index.js +24 -35
  39. package/v2Containers/Templates/_templates.scss +1 -1
  40. package/v2Containers/Templates/index.js +0 -1
  41. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +0 -5
  42. package/v2Containers/TemplatesV2/TemplatesV2.style.js +3 -8
  43. package/v2Containers/TemplatesV2/index.js +9 -22
  44. package/AppRoot.js +0 -124
  45. package/app-config.js +0 -61
  46. package/bootstrap.js +0 -185
  47. package/utils/getDataLayer.js +0 -15
  48. package/utils/mfeDetect.js +0 -1
  49. package/utils/mfeFirstPaintReady.js +0 -29
  50. package/utils/mfeHistory.js +0 -62
  51. package/v2Components/NavigationBar/mfeModuleHeader.config.js +0 -16
package/bootstrap.js DELETED
@@ -1,185 +0,0 @@
1
- /**
2
- * bootstrap.js
3
- *
4
- * Application setup and boilerplate. Loaded via the async boundary in app.js
5
- * (`import('./bootstrap')`) so Module Federation shared deps (eager: false in
6
- * prod) are resolved before this module executes.
7
- */
8
-
9
- import 'babel-polyfill';
10
- import 'whatwg-fetch';
11
- import React from 'react';
12
- import { createRoot } from 'react-dom/client';
13
- import { Provider } from 'react-redux';
14
- // import createHistory from 'history/lib/createBrowserHistory';
15
- // import { applyRouterMiddleware, Router, useRouterHistory } from 'react-router';
16
- // import { useScroll } from 'react-router-scroll';
17
- import history from 'utils/history';
18
- import CapSomethingWentWrong from '@capillarytech/cap-ui-library/CapSomethingWentWrong';
19
- import { addLocizeSavedHandler, startStandalone } from 'locize';
20
- import Bugsnag from '@bugsnag/js';
21
- import BugsnagPluginReact from '@bugsnag/plugin-react';
22
- // import { makeSelectLocationState } from 'containers/Cap/selectors';
23
- import LanguageProvider from 'v2Containers/LanguageProvider';
24
- import FontFaceObserver from 'fontfaceobserver';
25
- /* eslint-disable import/no-unresolved, import/extensions */
26
- import '!file-loader?name=[name].[ext]!./favicon.ico';
27
- /* eslint-enable import/no-unresolved, import/extensions */
28
- import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
29
- import { initialReducer } from './initialReducer';
30
- import { translationMessages } from './i18n';
31
- import './global-styles';
32
- import initialState from './initialState';
33
- import './styles/vendor/semantic/dist/semantic.min.css';
34
- import './styles/main.scss';
35
- import pathConfig from './config/path';
36
- import ignoredErrorMessages from './utils/ignoredErrorMessages';
37
- import App from './containers/App';
38
- import ConfigProvider from 'antd/lib/config-provider';
39
- import { getCapThemeConfig, loadCapUI } from '@capillarytech/cap-ui-library/utils';
40
-
41
- loadCapUI();
42
-
43
- try {
44
- if (!window.MFE_HOST) {
45
- const { setupNewrelicWebVitals } = require('./newRelic/utils');
46
- // Setup New Relic WebVitals tracking
47
- setupNewrelicWebVitals();
48
- }
49
- } catch (error) {
50
- Bugsnag.notify(error);
51
- }
52
-
53
- // const browserHistory = useRouterHistory(createHistory)({
54
- // basename: pathConfig.publicPath,
55
- // });
56
-
57
- const store = configureStore(initialState, initialReducer, history);
58
- const MOUNT_NODE = document.getElementById('app');
59
-
60
- // const history = syncHistoryWithStore(browserHistory, store, {
61
- // selectLocationState: makeSelectLocationState(),
62
- // });
63
- const BUGSNAG_APP_VERSION = `creatives-ui__${new Date().getTime()}`;
64
- const BUGSNAG_API_KEY = 'c4d96446438ff7dc7c08da08ef94c5b2';
65
-
66
- const bugSnagErrorCallback = (event) => {
67
- const { app: { releaseStage } = {}, originalError } = event || {};
68
- const errorMessage = originalError && originalError.message;
69
- if (
70
- (releaseStage || '').includes('nightly') ||
71
- process.env.NODE_ENV !== 'production' ||
72
- ignoredErrorMessages.includes(errorMessage)
73
- ) {
74
- return false;
75
- }
76
- let userId;
77
- let userName;
78
- let userEmail;
79
- let orgId;
80
- let orgName;
81
- try {
82
- const {
83
- id,
84
- firstName,
85
- lastName,
86
- loginName,
87
- proxyOrgList,
88
- } = JSON.parse(window.localStorage.getItem('user'));
89
- orgId = window.localStorage.getItem('orgID');
90
- userId = id;
91
- userName = `${firstName} ${lastName}`;
92
- userEmail = loginName;
93
- orgName = proxyOrgList.find(({ orgID }) => orgID === Number(orgId)).orgName;
94
- } catch (error) {
95
- userId = '';
96
- userName = '';
97
- userEmail = '';
98
- orgId = '';
99
- orgName = '';
100
- }
101
- event.addMetadata('org', {
102
- name: orgName,
103
- id: orgId,
104
- });
105
- event.setUser(userId, userEmail, userName);
106
- if (window.FS && window.FS.getCurrentSessionURL) {
107
- event.addMetadata('fullstory', {
108
- urlAtTime: window.FS.getCurrentSessionURL(true),
109
- });
110
- }
111
- };
112
-
113
- Bugsnag.start({
114
- appVersion: BUGSNAG_APP_VERSION,
115
- apiKey: BUGSNAG_API_KEY,
116
- releaseStage: window.location.hostname,
117
- plugins: [new BugsnagPluginReact()],
118
- onError: bugSnagErrorCallback,
119
- });
120
-
121
- const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React);
122
-
123
- export const BugsnagClient = Bugsnag;
124
-
125
- const ErrorScreen = () => <CapSomethingWentWrong url={`${pathConfig.publicPath}/v2`} />
126
- const root = createRoot(MOUNT_NODE);
127
- const render = (messages) => {
128
- root.render(
129
- <Provider store={store}>
130
- <LanguageProvider messages={messages}>
131
- <ErrorBoundary FallbackComponent={ErrorScreen}>
132
- <ConfigProvider theme={getCapThemeConfig()}>
133
- <App />
134
- </ConfigProvider>
135
- </ErrorBoundary>
136
- </LanguageProvider>
137
- </Provider>,
138
- );
139
- };
140
-
141
- // Hot reloadable translation json files
142
- if (module.hot) {
143
- // modules.hot.accept does not accept dynamic dependencies,
144
- // have to be constants at compile-time
145
- module.hot.accept('./i18n', () => {
146
- render(translationMessages);
147
- });
148
- }
149
-
150
- // for auto render UI on locize saved, since we cache the translations in redis it can't be update on real time as of now
151
- // need to comment as of now
152
- // addLocizeSavedHandler(res => {
153
- // res.updated.forEach(item => {
154
- // const { lng, ns, key, data } = item
155
- // // load the translations somewhere...
156
- // // and maybe rerender your UI
157
- // })
158
- // })
159
-
160
- // start
161
- startStandalone();
162
-
163
- const openSansObserver = new FontFaceObserver('Roboto', {});
164
- // When Open Sans is loaded, add a font-family using Open Sans to the body
165
- openSansObserver.load().then(() => {
166
- document.body.classList.add('fontLoaded');
167
- }, () => {
168
- document.body.classList.remove('fontLoaded');
169
- });
170
-
171
- // Chunked polyfill for browsers without Intl support
172
- if (!window.Intl) {
173
- (new Promise((resolve) => {
174
- resolve(import('intl'));
175
- }))
176
- .then(() => Promise.all([
177
- import('intl/locale-data/jsonp/en.js'),
178
- ]))
179
- .then(() => render(translationMessages))
180
- .catch((err) => {
181
- throw err;
182
- });
183
- } else {
184
- render(translationMessages);
185
- }
@@ -1,15 +0,0 @@
1
- import { isMFEMode } from './mfeDetect';
2
- import appConfig from '../app-config';
3
-
4
- const getDataLayerName = () => {
5
- if (isMFEMode()) {
6
- return `dataLayer_${appConfig.appName.replace(/-/g, '_')}`;
7
- }
8
- return 'dataLayer';
9
- };
10
-
11
- export const getDataLayer = () => {
12
- const name = getDataLayerName();
13
- window[name] = window[name] || [];
14
- return window[name];
15
- };
@@ -1 +0,0 @@
1
- export const isMFEMode = () => Boolean(window.MFE_HOST);
@@ -1,29 +0,0 @@
1
- import { MFEEventBus } from '@capillarytech/cap-ui-utils';
2
- import appConfig from '../app-config';
3
- import { isMFEMode } from './mfeDetect';
4
-
5
- // Routes whose containers emit the data-settled 'lcp' themselves —
6
- // the first-paint emit must NOT fire for these.
7
- // TemplatesV2 renders at relative '/v2' and '/v2/loyalty' (routes.js); in MFE mode
8
- // the shared history is rebased on publicPath, so the real browser pathname carries
9
- // the '/creatives/ui' prefix. Match the prefixed paths — this util reads
10
- // window.location.pathname, not the rebased router location. (v1 standalone is
11
- // non-MFE and irrelevant here.)
12
- const DATA_LANDING_MATCHERS = ['/creatives/ui/v2', '/creatives/ui/v2/loyalty'];
13
-
14
- export const isDataLandingPath = (pathname) => {
15
- const p = (pathname || '').replace(/\/+$/, '') || '/';
16
- return DATA_LANDING_MATCHERS.some((m) => (m instanceof RegExp ? m.test(p) : m === p));
17
- };
18
-
19
- export const emitFirstPaintReadyIfNotDataLanding = () => {
20
- if (!isMFEMode() || isDataLandingPath(window.location.pathname)) return;
21
- requestAnimationFrame(() => {
22
- MFEEventBus.emit('mfe:segment', {
23
- action: 'stop',
24
- appId: appConfig.appName,
25
- type: 'lcp',
26
- timestamp: performance.now(),
27
- });
28
- });
29
- };
@@ -1,62 +0,0 @@
1
- /**
2
- * Re-base the host's shared root history for this MFE remote.
3
- *
4
- * The MFE host owns ONE root history instance and hands it to every remote, so host + all
5
- * remotes stay perfectly in sync: a push on the shared instance notifies every mounted
6
- * router directly (no popstate hack, no drift on fast remote switching).
7
- *
8
- * This remote's routes / <Link>s / history.push calls are written RELATIVE to its serving
9
- * prefix. This adapter presents a basename'd VIEW of the shared history — stripping the
10
- * prefix when the router reads the location, and prepending it when the router navigates —
11
- * while delegating all actual navigation to the shared instance. Net effect: relative
12
- * routing keeps working unchanged, and navigation still flows through the single shared
13
- * history. Standalone (no host history) is unaffected; the remote keeps creating its own.
14
- */
15
- const addBase = (base, to) => {
16
- if (typeof to === 'string') {
17
- if (!to.startsWith('/')) return to; // already relative to current location
18
- return to === '/' ? base : `${base}${to}`;
19
- }
20
- if (to && typeof to === 'object') {
21
- return { ...to, pathname: addBase(base, to.pathname || '/') };
22
- }
23
- return to;
24
- };
25
-
26
- const stripBase = (base, pathname) => {
27
- if (!pathname) return pathname;
28
- if (pathname === base) return '/';
29
- if (pathname.startsWith(`${base}/`)) return pathname.slice(base.length);
30
- return pathname;
31
- };
32
-
33
- export default function rebaseHistory(history, rawBase) {
34
- const base = String(rawBase || '').replace(/\/+$/, ''); // normalise: no trailing slash
35
- if (!base) return history;
36
- const view = loc => ({ ...loc, pathname: stripBase(base, loc.pathname) });
37
- return {
38
- get length() {
39
- return history.length;
40
- },
41
- get action() {
42
- return history.action;
43
- },
44
- get location() {
45
- return view(history.location);
46
- },
47
- push: (to, state) => history.push(addBase(base, to), state),
48
- replace: (to, state) => history.replace(addBase(base, to), state),
49
- go: n => history.go(n),
50
- goBack: () => history.goBack(),
51
- goForward: () => history.goForward(),
52
- block: (...args) => history.block(...args),
53
- listen: listener =>
54
- history.listen((loc, action) => listener(view(loc), action)),
55
- createHref: to =>
56
- history.createHref(
57
- typeof to === 'string'
58
- ? addBase(base, to)
59
- : { ...to, pathname: addBase(base, (to && to.pathname) || '/') },
60
- ),
61
- };
62
- }
@@ -1,16 +0,0 @@
1
- // Static, module-specific config for the shared MFE module-header wrapper
2
- // (MFEModuleHeader). Runtime values (history) are supplied in NavigationBar.
3
- export const MFE_MODULE_HEADER = {
4
- header: {
5
- name: 'app.commonUtils.capUiLibrary.navigationSPA.moduleHeader.creatives.default.name',
6
- description: 'app.commonUtils.capUiLibrary.navigationSPA.moduleHeader.creatives.default.description',
7
- showBorder: false,
8
- showSettings: false,
9
- },
10
- landingRoutes: [
11
- '/creatives/ui/v2/',
12
- '/creatives/ui/v2',
13
- '/v2/',
14
- '/v2'
15
- ],
16
- };