@capillarytech/creatives-library 8.0.171 → 8.0.172

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.171",
4
+ "version": "8.0.172",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -0,0 +1,37 @@
1
+ import withReactRouterV3Compatibility from './hoc/withReactRouterV3Compatibility';
2
+ import SomethingWentWrong from '@capillarytech/cap-ui-library/CapSomethingWentWrong';
3
+ import NotFoundPage from './v2Containers/NotFoundPage';
4
+ import TemplatesV2 from './v2Containers/TemplatesV2';
5
+
6
+ // Package-specific routes that only include V2 components
7
+ // This is used when building the npm package where containers are excluded
8
+ const routes = [
9
+ // V2 Routes (always available in package)
10
+ {
11
+ exact: true,
12
+ path: '/v2/somethingwentwrong',
13
+ name: 'somethingwentwrong',
14
+ component: withReactRouterV3Compatibility(SomethingWentWrong),
15
+ },
16
+ {
17
+ exact: true,
18
+ path: '/v2',
19
+ name: 'templatesV2',
20
+ component: withReactRouterV3Compatibility(TemplatesV2),
21
+ },
22
+ {
23
+ exact: true,
24
+ path: '/v2/loyalty',
25
+ name: 'loyalty',
26
+ component: withReactRouterV3Compatibility(TemplatesV2),
27
+ },
28
+
29
+ // Catch-all fallback
30
+ {
31
+ path: '*',
32
+ name: 'notfound',
33
+ component: withReactRouterV3Compatibility(NotFoundPage),
34
+ },
35
+ ];
36
+
37
+ export default routes;
package/routes.js CHANGED
@@ -1,146 +1,37 @@
1
1
  import withReactRouterV3Compatibility from './hoc/withReactRouterV3Compatibility';
2
-
3
2
  import SomethingWentWrong from '@capillarytech/cap-ui-library/CapSomethingWentWrong';
4
3
  import NotFoundPage from './v2Containers/NotFoundPage';
5
4
  import TemplatesV2 from './v2Containers/TemplatesV2';
6
5
 
7
- // Utility function to detect if we're in embedded mode
8
- const isEmbeddedMode = () => {
9
- // Check if we're in embedded mode by looking for embedded mode indicators
10
- // This could be from URL params, environment variables, or build configuration
11
- if (typeof window !== 'undefined') {
12
- const urlParams = new URLSearchParams(window.location.search);
13
- return urlParams.get('type') === 'embedded';
14
- }
15
- // Fallback: check if containers folder exists (indicating non-embedded mode)
16
- try {
17
- // This will throw an error in embedded mode since containers are excluded
18
- require('./containers/Dashboard');
19
- return false;
20
- } catch (error) {
21
- return true;
22
- }
23
- };
24
-
25
- // Check if we're in embedded mode at module load time
26
- const isEmbedded = isEmbeddedMode();
27
-
28
- // Clean all-or-nothing approach for static imports
29
- const getStaticImports = () => {
30
- if (isEmbedded) return {}; // Only v2 uses static imports
31
-
32
- try {
33
- return {
34
- Dashboard: require('./containers/Dashboard').default,
35
- SmsCreate: require('./containers/Sms/Create').default,
36
- SmsEdit: require('./containers/Sms/Edit').default,
37
- Templates: require('./containers/Templates').default,
38
- WeChatMapTemplate: require('./containers/WeChat/MapTemplates').default,
39
- Gallary: require('./containers/Assets/Gallery').default,
40
- WeChatRichmediaCreate: require('./containers/WeChat/RichmediaTemplates/Create').default,
41
- WeChatRichmediaEdit: require('./containers/WeChat/RichmediaTemplates/Edit').default,
42
- Email: require('./containers/Email').default,
43
- Ebill: require('./containers/Ebill').default,
44
- MobilePushCreate: require('./containers/MobilePush/Create').default,
45
- MobilePushEdit: require('./containers/MobilePush/Edit').default,
46
- LineCreate: require('./containers/Line/Create').default,
47
- };
48
- } catch (error) {
49
- console.log('Error importing v1 components:', error.message);
50
- return {}; // Fallback to v2 only
51
- }
52
- };
53
-
54
- // Declarative route configuration
55
- const ROUTES = [
56
- // ✅ V2 Routes (always included)
57
- { path: '/v2/somethingwentwrong', name: 'somethingwentwrong', component: SomethingWentWrong },
58
- { path: '/v2', name: 'templatesV2', component: TemplatesV2 },
59
- { path: '/v2/loyalty', name: 'loyalty', component: TemplatesV2 },
60
-
61
- // ✅ V1 Routes (conditional based on `!isEmbedded`)
62
- { path: '/', componentKey: 'Dashboard' },
63
-
64
- // SMS routes v1
65
- { path: '/sms/create', name: 'create', componentKey: 'SmsCreate' },
66
- { path: '/sms/view', name: 'view', componentKey: 'SmsCreate' },
67
- { path: '/sms/edit/:id', name: 'edit', componentKey: 'SmsEdit' },
68
- { path: '/sms', name: 'sms', componentKey: 'Templates' },
69
-
70
- // WeChat routes v1
71
- { path: '/wechat', name: 'wechat', componentKey: 'Templates' },
72
- { path: '/wechat/create', name: 'create weChat', componentKey: 'WeChatMapTemplate' },
73
- { path: '/wechat/edit/:id', name: 'edit weChat', componentKey: 'WeChatMapTemplate' },
74
- { path: '/wechat/richmedia/create', name: 'wechat_richmedia_create', componentKey: 'WeChatRichmediaCreate' },
75
- { path: '/wechat/richmedia/edit/:id', name: 'wechat_richmedia_edit', componentKey: 'WeChatRichmediaEdit' },
76
-
77
- // Email routes v1
78
- { path: '/email', name: 'email', componentKey: 'Templates' },
79
- { path: '/email/create', name: 'EmailCreate', componentKey: 'Email' },
80
- { path: '/email/view', name: 'EmailView', componentKey: 'Email' },
81
- { path: '/email/edit/:id', name: 'EmailEdit', componentKey: 'Email' },
82
-
83
- // Ebill routes v1
84
- { path: '/ebill', name: 'Ebill', componentKey: 'Templates' },
85
- { path: '/ebill/create', name: 'Ebill', componentKey: 'Ebill' },
86
- { path: '/ebill/edit/:id', name: 'Ebill', componentKey: 'Ebill' },
6
+ // Package-specific routes that only include V2 components
7
+ // This is used when building the npm package where containers are excluded
8
+ const routes = [
9
+ // V2 Routes (always available in package)
10
+ {
11
+ exact: true,
12
+ path: '/v2/somethingwentwrong',
13
+ name: 'somethingwentwrong',
14
+ component: withReactRouterV3Compatibility(SomethingWentWrong),
15
+ },
16
+ {
17
+ exact: true,
18
+ path: '/v2',
19
+ name: 'templatesV2',
20
+ component: withReactRouterV3Compatibility(TemplatesV2),
21
+ },
22
+ {
23
+ exact: true,
24
+ path: '/v2/loyalty',
25
+ name: 'loyalty',
26
+ component: withReactRouterV3Compatibility(TemplatesV2),
27
+ },
87
28
 
88
- // MobilePush routes v1
89
- { path: '/mobilepush', name: 'mobilepush', componentKey: 'Templates' },
90
- { path: '/mobilepush/create/:mode', name: 'create', componentKey: 'MobilePushCreate' },
91
- { path: '/mobilepush/edit/:id', name: 'edit', componentKey: 'MobilePushEdit' },
92
-
93
- // Assets routes v1
94
- { path: '/assets', name: 'GALLERY', componentKey: 'Gallary' },
95
-
96
- // Line routes v1
97
- { path: '/line', name: 'line', componentKey: 'Templates' },
98
- { path: '/line/create/:mode', name: 'create line', componentKey: 'LineCreate' },
99
- { path: '/line/view/:mode', name: 'view', componentKey: 'LineCreate' },
100
- { path: '/line/edit/text/:id', name: 'edit_text', componentKey: 'LineCreate' },
101
- { path: '/line/edit/image/:id', name: 'edit_image', componentKey: 'LineCreate' },
102
- ];
103
-
104
- // Simplified route creation
105
- const createRoutes = (components = {}) => {
106
- const routes = ROUTES.flatMap(({ path, component, componentKey, name }) => {
107
- // V2 component is statically imported
108
- if (component) {
109
- return [{
110
- exact: true,
111
- path,
112
- name,
113
- component: withReactRouterV3Compatibility(component),
114
- }];
115
- }
116
-
117
- // V1 component: only include if available
118
- const resolved = components[componentKey];
119
- if (resolved) {
120
- return [{
121
- exact: true,
122
- path,
123
- name,
124
- component: withReactRouterV3Compatibility(resolved),
125
- }];
126
- }
127
-
128
- return []; // Skip if not in embedded or missing
129
- });
130
-
131
29
  // Catch-all fallback
132
- routes.push({
30
+ {
133
31
  path: '*',
134
32
  name: 'notfound',
135
33
  component: withReactRouterV3Compatibility(NotFoundPage),
136
- });
137
-
138
- return routes;
139
- };
140
-
141
- // Initialize routes synchronously with available components
142
- const staticImports = getStaticImports();
143
- const routes = createRoutes(staticImports);
34
+ },
35
+ ];
144
36
 
145
- // Export the routes array
146
- export default routes;
37
+ export default routes;