create-catalyst-app 0.0.1-beta.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.
Files changed (183) hide show
  1. package/package.json +20 -0
  2. package/readme.md +53 -0
  3. package/scripts/cli.mjs +267 -0
  4. package/templates/common/.babelrc +26 -0
  5. package/templates/common/.editorconfig +12 -0
  6. package/templates/common/.eslintignore +6 -0
  7. package/templates/common/.eslintrc +53 -0
  8. package/templates/common/.prettierrc.json +7 -0
  9. package/templates/common/.stylelintrc +35 -0
  10. package/templates/common/README.md +29 -0
  11. package/templates/common/api.js +29 -0
  12. package/templates/common/checkVersion.js +3 -0
  13. package/templates/common/client/index.js +39 -0
  14. package/templates/common/client/styles.js +15 -0
  15. package/templates/common/config/config.json +18 -0
  16. package/templates/common/config/config_template.json +18 -0
  17. package/templates/common/config/index.js +77 -0
  18. package/templates/common/package.json +57 -0
  19. package/templates/common/server/CustomDocument.js +14 -0
  20. package/templates/common/server/customIndex.js +3 -0
  21. package/templates/common/server/customServer.js +16 -0
  22. package/templates/common/src/js/containers/App/actions.js +20 -0
  23. package/templates/common/src/js/containers/App/index.js +46 -0
  24. package/templates/common/src/js/containers/App/reducer.js +21 -0
  25. package/templates/common/src/js/containers/Home/Home.js +40 -0
  26. package/templates/common/src/js/containers/PDP/PDP.js +37 -0
  27. package/templates/common/src/js/reducer/index.js +80 -0
  28. package/templates/common/src/js/routes/index.js +50 -0
  29. package/templates/common/src/js/stateManager/stateProvider.js +34 -0
  30. package/templates/common/src/js/store/index.js +77 -0
  31. package/templates/common/src/static/css/base/_overrides.scss +81 -0
  32. package/templates/common/src/static/css/base/animations.js +38 -0
  33. package/templates/common/src/static/css/base/index.scss +8 -0
  34. package/templates/common/src/static/css/base/layout.scss +242 -0
  35. package/templates/common/src/static/css/base/styles.scss +163 -0
  36. package/templates/common/src/static/css/base/typography.scss +285 -0
  37. package/templates/common/src/static/css/resources/_mixins.scss +196 -0
  38. package/templates/common/src/static/css/resources/_variables.scss +172 -0
  39. package/templates/common/src/static/css/resources/_vendors.scss +1 -0
  40. package/templates/common/src/static/fonts/.gitkeep +0 -0
  41. package/templates/common/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  42. package/templates/common/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  43. package/templates/common/src/static/fonts/Inter-Light-Subset.otf +0 -0
  44. package/templates/common/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  45. package/templates/common/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  46. package/templates/common/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  47. package/templates/common/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  48. package/templates/common/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  49. package/templates/common/src/static/fonts/Poppins-Light-Subset.woff2 +0 -0
  50. package/templates/common/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  51. package/templates/common/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  52. package/templates/common/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  53. package/templates/none-js/.babelrc +26 -0
  54. package/templates/none-js/.eslintignore +6 -0
  55. package/templates/none-js/.eslintrc +53 -0
  56. package/templates/none-js/.prettierrc.json +7 -0
  57. package/templates/none-js/.stylelintrc +35 -0
  58. package/templates/none-js/README.md +22 -0
  59. package/templates/none-js/api.js +29 -0
  60. package/templates/none-js/checkVersion.js +3 -0
  61. package/templates/none-js/client/index.js +27 -0
  62. package/templates/none-js/client/styles.js +15 -0
  63. package/templates/none-js/config/config.json +15 -0
  64. package/templates/none-js/config/config_template.json +18 -0
  65. package/templates/none-js/config/index.js +44 -0
  66. package/templates/none-js/package.json +53 -0
  67. package/templates/none-js/server/document.js +14 -0
  68. package/templates/none-js/server/index.js +3 -0
  69. package/templates/none-js/server/server.js +16 -0
  70. package/templates/none-js/src/js/containers/App/index.js +40 -0
  71. package/templates/none-js/src/js/containers/DemoPage/DemoPage.js +39 -0
  72. package/templates/none-js/src/js/containers/DemoPage/DemoPage.scss +3 -0
  73. package/templates/none-js/src/js/containers/Home/Home.js +27 -0
  74. package/templates/none-js/src/js/containers/Home/Home.scss +36 -0
  75. package/templates/none-js/src/js/routes/index.js +49 -0
  76. package/templates/none-js/src/js/stateManager/stateProvider.js +19 -0
  77. package/templates/none-js/src/js/store/index.js +6 -0
  78. package/templates/none-js/src/static/css/base/index.scss +3 -0
  79. package/templates/none-js/src/static/css/base/styles.scss +11 -0
  80. package/templates/none-js/src/static/css/base/typography.scss +53 -0
  81. package/templates/none-js/src/static/css/resources/_variables.scss +1 -0
  82. package/templates/none-js/src/static/fonts/.gitkeep +0 -0
  83. package/templates/none-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  84. package/templates/none-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  85. package/templates/none-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  86. package/templates/none-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  87. package/templates/none-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  88. package/templates/none-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  89. package/templates/none-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  90. package/templates/none-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  91. package/templates/none-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  92. package/templates/none-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  93. package/templates/none-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  94. package/templates/none-js/webpackConfig.js +5 -0
  95. package/templates/redux-js/.babelrc +26 -0
  96. package/templates/redux-js/.eslintignore +6 -0
  97. package/templates/redux-js/.eslintrc +53 -0
  98. package/templates/redux-js/.prettierrc.json +7 -0
  99. package/templates/redux-js/.stylelintrc +35 -0
  100. package/templates/redux-js/README.md +22 -0
  101. package/templates/redux-js/api.js +29 -0
  102. package/templates/redux-js/checkVersion.js +3 -0
  103. package/templates/redux-js/client/index.js +27 -0
  104. package/templates/redux-js/client/styles.js +15 -0
  105. package/templates/redux-js/config/config.json +15 -0
  106. package/templates/redux-js/config/config_template.json +18 -0
  107. package/templates/redux-js/config/index.js +44 -0
  108. package/templates/redux-js/package.json +53 -0
  109. package/templates/redux-js/server/document.js +14 -0
  110. package/templates/redux-js/server/index.js +3 -0
  111. package/templates/redux-js/server/server.js +16 -0
  112. package/templates/redux-js/src/js/containers/App/actions.js +20 -0
  113. package/templates/redux-js/src/js/containers/App/index.js +42 -0
  114. package/templates/redux-js/src/js/containers/App/reducer.js +21 -0
  115. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.js +39 -0
  116. package/templates/redux-js/src/js/containers/DemoPage/DemoPage.scss +3 -0
  117. package/templates/redux-js/src/js/containers/Home/Home.js +27 -0
  118. package/templates/redux-js/src/js/containers/Home/Home.scss +36 -0
  119. package/templates/redux-js/src/js/reducer/index.js +80 -0
  120. package/templates/redux-js/src/js/routes/index.js +49 -0
  121. package/templates/redux-js/src/js/stateManager/stateProvider.js +34 -0
  122. package/templates/redux-js/src/js/store/index.js +79 -0
  123. package/templates/redux-js/src/static/css/base/index.scss +3 -0
  124. package/templates/redux-js/src/static/css/base/styles.scss +11 -0
  125. package/templates/redux-js/src/static/css/base/typography.scss +53 -0
  126. package/templates/redux-js/src/static/css/resources/_variables.scss +1 -0
  127. package/templates/redux-js/src/static/fonts/.gitkeep +0 -0
  128. package/templates/redux-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  129. package/templates/redux-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  130. package/templates/redux-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  131. package/templates/redux-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  132. package/templates/redux-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  133. package/templates/redux-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  134. package/templates/redux-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  135. package/templates/redux-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  136. package/templates/redux-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  137. package/templates/redux-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  138. package/templates/redux-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  139. package/templates/redux-js/webpackConfig.js +5 -0
  140. package/templates/rtk-js/.babelrc +26 -0
  141. package/templates/rtk-js/.eslintignore +6 -0
  142. package/templates/rtk-js/.eslintrc +53 -0
  143. package/templates/rtk-js/.prettierrc.json +7 -0
  144. package/templates/rtk-js/.stylelintrc +35 -0
  145. package/templates/rtk-js/README.md +23 -0
  146. package/templates/rtk-js/api.js +29 -0
  147. package/templates/rtk-js/checkVersion.js +3 -0
  148. package/templates/rtk-js/client/index.js +27 -0
  149. package/templates/rtk-js/client/styles.js +15 -0
  150. package/templates/rtk-js/config/config.json +15 -0
  151. package/templates/rtk-js/config/config_template.json +18 -0
  152. package/templates/rtk-js/config/index.js +44 -0
  153. package/templates/rtk-js/package.json +53 -0
  154. package/templates/rtk-js/server/document.js +14 -0
  155. package/templates/rtk-js/server/index.js +3 -0
  156. package/templates/rtk-js/server/server.js +16 -0
  157. package/templates/rtk-js/src/js/containers/App/index.js +42 -0
  158. package/templates/rtk-js/src/js/containers/App/reducer.js +26 -0
  159. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.js +39 -0
  160. package/templates/rtk-js/src/js/containers/DemoPage/DemoPage.scss +3 -0
  161. package/templates/rtk-js/src/js/containers/Home/Home.js +27 -0
  162. package/templates/rtk-js/src/js/containers/Home/Home.scss +36 -0
  163. package/templates/rtk-js/src/js/reducer/index.js +80 -0
  164. package/templates/rtk-js/src/js/routes/index.js +49 -0
  165. package/templates/rtk-js/src/js/stateManager/stateProvider.js +34 -0
  166. package/templates/rtk-js/src/js/store/index.js +22 -0
  167. package/templates/rtk-js/src/static/css/base/index.scss +3 -0
  168. package/templates/rtk-js/src/static/css/base/styles.scss +11 -0
  169. package/templates/rtk-js/src/static/css/base/typography.scss +53 -0
  170. package/templates/rtk-js/src/static/css/resources/_variables.scss +1 -0
  171. package/templates/rtk-js/src/static/fonts/.gitkeep +0 -0
  172. package/templates/rtk-js/src/static/fonts/Inter-Bold-Subset.otf +0 -0
  173. package/templates/rtk-js/src/static/fonts/Inter-Italic-Subset.otf +0 -0
  174. package/templates/rtk-js/src/static/fonts/Inter-Light-Subset.otf +0 -0
  175. package/templates/rtk-js/src/static/fonts/Inter-Medium-Subset.otf +0 -0
  176. package/templates/rtk-js/src/static/fonts/Inter-Regular-Subset.otf +0 -0
  177. package/templates/rtk-js/src/static/fonts/Inter-SemiBold-Subset.otf +0 -0
  178. package/templates/rtk-js/src/static/fonts/Poppins-Bold-Subset.woff2 +0 -0
  179. package/templates/rtk-js/src/static/fonts/Poppins-Italic-Subset.woff2 +0 -0
  180. package/templates/rtk-js/src/static/fonts/Poppins-Medium-Subset.woff2 +0 -0
  181. package/templates/rtk-js/src/static/fonts/Poppins-Regular-Subset.woff2 +0 -0
  182. package/templates/rtk-js/src/static/fonts/Poppins-SemiBold-Subset.woff2 +0 -0
  183. package/templates/rtk-js/webpackConfig.js +5 -0
@@ -0,0 +1,27 @@
1
+ import React from "react"
2
+ import { hydrateRoot } from "react-dom/client"
3
+ import { loadableReady } from "@loadable/component"
4
+ import { Provider } from "react-redux"
5
+ import { createBrowserRouter, RouterProvider } from "@tata1mg/router"
6
+ import { preparedRoutes } from "../src/js/routes/index.js"
7
+ import configureStore from "../src/js/store/index.js"
8
+ import "./styles"
9
+
10
+ window.addEventListener("load", () => {
11
+ loadableReady(() => {
12
+ const { __ROUTER_INITIAL_DATA__: routerInitialData, __INITIAL_STATE__ } = window
13
+ const store = configureStore(__INITIAL_STATE__ || {})
14
+ const router = createBrowserRouter(preparedRoutes({ store, routerInitialState: routerInitialData }))
15
+
16
+ const Application = (
17
+ <Provider store={store} serverState={__INITIAL_STATE__}>
18
+ <React.StrictMode>
19
+ <RouterProvider router={router} />
20
+ </React.StrictMode>
21
+ </Provider>
22
+ )
23
+
24
+ const container = document.getElementById("app")
25
+ hydrateRoot(container, Application)
26
+ })
27
+ })
@@ -0,0 +1,15 @@
1
+ /* Style Loader
2
+ *
3
+ * Anything imported in here will either be added to the vendor CSS chunk, or
4
+ * the main app CSS chunk. Where they will go depends on its location or its
5
+ * extension.
6
+ *
7
+ * Files will be added to the vendor.css chunk if:
8
+ * - they are located inside `node_modules`, or
9
+ * - they are plain .css files.
10
+ * Otherwise, files will be added to the main app.css chunk.
11
+ */
12
+
13
+ // Include initial base styles.
14
+ import "normalize.css"
15
+ import "@css/base/index.scss"
@@ -0,0 +1,15 @@
1
+ {
2
+ "APPLICATION_PORT": "3005",
3
+ "APPLICATION_BASE_URL": "http://localhost:3005",
4
+ "SERVER_PATH": "http://localhost:3005",
5
+ "OUTPUT_PATH": "build",
6
+ "PUBLIC_OUTPUT_PATH": "build/public",
7
+ "PUBLIC_ASSET_PATH": "http://localhost:3006/assets/",
8
+ "LOCAL_ASSET_PATH": "/assets/",
9
+ "EXTERNAL_BASE_URL": "http://localhost:3005",
10
+ "DEV_SERVER_PORT": 3006,
11
+ "DEV_SERVER_HOSTNAME": "localhost",
12
+ "DEV_SERVER_HOST_URL": "http://localhost:3006",
13
+ "ENV_NAME": "local",
14
+ "BUILD_ENV": ""
15
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "S3_BUCKET": "",
3
+ "S3_FOLDER": "",
4
+ "CDN_ASSET_PATH": "",
5
+ "APPLICATION_PORT": "",
6
+ "APPLICATION_BASE_URL": "",
7
+ "SERVER_PATH": "",
8
+ "OUTPUT_PATH": "",
9
+ "PUBLIC_OUTPUT_PATH": "",
10
+ "PUBLIC_ASSET_PATH": "",
11
+ "LOCAL_ASSET_PATH": "",
12
+ "EXTERNAL_BASE_URL": "",
13
+ "DEV_SERVER_PORT": 0,
14
+ "DEV_SERVER_HOSTNAME": "",
15
+ "DEV_SERVER_HOST_URL": "",
16
+ "ENV_NAME": "",
17
+ "BUILD_ENV": ""
18
+ }
@@ -0,0 +1,44 @@
1
+ module.exports = {
2
+ // Enable or disable server-side rendering
3
+ enableSSR: true,
4
+
5
+ // Enable or disable dynamic imports (code splitting)
6
+ enableDynamicImports: true,
7
+
8
+ // Enable or disable speed measure plugin to measure your webpack build speed
9
+ enableSpeedMeasure: false,
10
+
11
+ // The env vars to expose on the client side. If you add them here, they will
12
+ // be available on the client as process.env[VAR_NAME], same as they would be
13
+ // in node.js.
14
+ //
15
+ // **WARNING**: Be careful not to expose any secrets here!
16
+ clientEnv: [
17
+ "NODE_ENV",
18
+ "APPLICATION_BASE_URL",
19
+ "LOCAL_ASSET_PATH",
20
+ "INTERNAL_NODE_API_URL",
21
+ "BUILD_ENV",
22
+ "EXTERNAL_BASE_URL",
23
+ "SERVER_PATH",
24
+ "ENV_NAME",
25
+ "src_path"
26
+ ],
27
+
28
+ /* The identifier to use for css-modules.
29
+ */
30
+ cssModulesIdentifierProd: "[name]__[local]__[hash:base64:5]",
31
+ cssModulesIdentifierDev: "[name]__[local]",
32
+
33
+ // Isomorphic configuration
34
+ isomorphicConfig: {
35
+ debug: true,
36
+
37
+ assets: {
38
+ images: {
39
+ extensions: ["png", "jpg", "jpeg", "gif", "ico", "svg", "json"],
40
+ },
41
+ },
42
+ },
43
+
44
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "create-catalyst-app-starter",
3
+ "version": "1.0.0",
4
+ "description": "This README would normally document whatever steps are necessary to get your application up and running.",
5
+ "main": "index.js",
6
+ "bin": "scripts/cli.mjs",
7
+ "scripts": {
8
+ "start": "catalyst start",
9
+ "build": "catalyst build",
10
+ "serve": "catalyst serve"
11
+ },
12
+ "_moduleAliases": {
13
+ "@containers": "src/js/containers",
14
+ "@lib": "src/js/lib",
15
+ "$server": "server",
16
+ "@constants": "src/js/constants",
17
+ "@config": "config",
18
+ "@components": "src/js/components",
19
+ "@css": "src/static/css"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/tata1mg/catalyst"
24
+ },
25
+ "dependencies": {
26
+ "@loadable/component": "^5.16.3",
27
+ "@tata1mg/router": "^0.0.1-alpha.13",
28
+ "catalyst-core":"0.0.1-beta.1",
29
+ "event-source-polyfill": "^1.0.31",
30
+ "express-static-gzip": "^2.1.7",
31
+ "framer-motion": "^10.18.0",
32
+ "isomorphic-dompurify": "^2.2.0",
33
+ "normalize.css": "^8.0.1",
34
+ "prop-types": "^15.8.1",
35
+ "pwa": "git+git@bitbucket.org:tata1mg/catalyst.git#framework-scaffolding",
36
+ "react-dfp": "^0.21.0",
37
+ "react-helmet-async":"^1.3.0",
38
+ "react-intersection-observer": "^9.5.3",
39
+ "react-loadable-visibility": "^3.0.2",
40
+ "react-redux": "^8.1.3",
41
+ "@reduxjs/toolkit": "1.9.3"
42
+ },
43
+ "author": "",
44
+ "license": "ISC",
45
+ "bugs": {
46
+ "url": "https://github.com/tata1mg/catalyst/issues"
47
+ },
48
+ "homepage": "https://github.com/tata1mg/catalyst#readme",
49
+ "devDependencies": {
50
+ "@babel/core": "^7.23.7",
51
+ "@babel/node": "^7.22.19"
52
+ }
53
+ }
@@ -0,0 +1,14 @@
1
+ import React from "react"
2
+ import { Head, Body } from "catalyst-core"
3
+
4
+ function Document(props) {
5
+ return (
6
+ <html lang={props.lang}>
7
+ <Head {...props}>
8
+ <meta charset="final-order" />
9
+ </Head>
10
+ <Body {...props} />
11
+ </html>
12
+ )
13
+ }
14
+ export default Document
@@ -0,0 +1,3 @@
1
+ export const preServerInit = () => {
2
+ console.log("preServerInit")
3
+ }
@@ -0,0 +1,16 @@
1
+ export function addMiddlewares(app) {
2
+ const env = process.env.NODE_ENV || "development"
3
+ console.log("custom server called !!!!")
4
+
5
+ app.use("/pwa-api/service-worker.js", (req, res, next) => {
6
+
7
+ res.send("ok")
8
+ })
9
+ app.use(
10
+ "/favicon.ico",
11
+ (req, res, next) => {
12
+
13
+ res.send("ok")
14
+ }
15
+ )
16
+ }
@@ -0,0 +1,20 @@
1
+ const createActionTypes = (prefix, actionTypeList = []) => {
2
+ const actionTypesObject = {}
3
+ actionTypeList.forEach((item) => {
4
+ actionTypesObject[item] = `${prefix}/${item}`
5
+ })
6
+
7
+ return actionTypesObject
8
+ }
9
+
10
+ export default createActionTypes
11
+
12
+ export const ShellActions = createActionTypes("shellActions", [
13
+ "REDUX_TEST"
14
+ ])
15
+ export const reduxTest = () => {
16
+
17
+ return {
18
+ type: ShellActions.REDUX_TEST,
19
+ }
20
+ }
@@ -0,0 +1,42 @@
1
+ import React, { useState } from "react";
2
+ import {
3
+ useLocation,
4
+ useOutlet,
5
+ UNSAFE_LocationContext,
6
+ } from "react-router-dom";
7
+ import {reduxTest} from "./actions"
8
+ import "@css/base/index.scss";
9
+
10
+
11
+ export const BaseOutlet = () => {
12
+ const o = useOutlet();
13
+ const [outlet] = useState(o);
14
+
15
+ return <>{outlet}</>;
16
+ };
17
+ const App = () => {
18
+
19
+ const location = useLocation();
20
+ const page = (
21
+ <div key={location.pathname.includes("/auth") ? "" : location.pathname}>
22
+ <UNSAFE_LocationContext.Provider value={{ location }}>
23
+ <BaseOutlet />
24
+ </UNSAFE_LocationContext.Provider>
25
+ </div>
26
+ );
27
+ return (
28
+ <div className={"flexColumn"}>
29
+ <>
30
+ {/* <ShellLocusHeader /> */}
31
+ </>
32
+ <div>{page}</div>
33
+ </div>
34
+ );
35
+ };
36
+
37
+ App.serverSideFunction = ({store}) => {
38
+ store.dispatch(reduxTest())
39
+ return new Promise((resolve) => resolve());
40
+ };
41
+
42
+ export default App;
@@ -0,0 +1,21 @@
1
+ import { ShellActions } from "./actions";
2
+
3
+ export const defaultState = {
4
+ testActionDispatched: false,
5
+ };
6
+
7
+ const shellReducer = (state = defaultState, action) => {
8
+ switch (action.type) {
9
+ case ShellActions.REDUX_TEST: {
10
+ return {
11
+ ...state,
12
+ testActionDispatched: true,
13
+ };
14
+ }
15
+
16
+ default:
17
+ return state;
18
+ }
19
+ };
20
+
21
+ export default shellReducer;
@@ -0,0 +1,39 @@
1
+ import React, { useEffect } from "react";
2
+ import { useCurrentRouteData, Link } from "@tata1mg/router";
3
+ import css from './DemoPage.scss'
4
+
5
+ const Demo = () => {
6
+ const { data, isFetched, loading } = useCurrentRouteData() || {}
7
+
8
+ useEffect(() => {
9
+ console.log("data is =>", data)
10
+ })
11
+
12
+ return (
13
+
14
+ <div>
15
+ <div className={css.textColor}>Welcome to Demo page</div>
16
+ <Link to={"/"}>link</Link>
17
+ </div>
18
+ );
19
+ };
20
+
21
+ Demo.serverFetcher = async ({ req }, { store }) => {
22
+ console.log("server fetcher called!!")
23
+ const res = await fetch("https://jsonblob.com/api/1206830251241234432");
24
+ const json = await res.json();
25
+ return json;
26
+ };
27
+
28
+ Demo.clientFetcher = async ({ }, { }) => {
29
+ console.log("client fetcher called")
30
+ const res = await fetch("https://jsonblob.com/api/1206830251241234432");
31
+ const json = await res.json();
32
+ return json;
33
+ };
34
+
35
+ Demo.MetaTagFunction = (routerData) => {
36
+ return [<title key="PDP">PDP</title>]
37
+ };
38
+
39
+ export default Demo;
@@ -0,0 +1,3 @@
1
+ .textColor {
2
+ color: orange;
3
+ }
@@ -0,0 +1,27 @@
1
+ import React from 'react'
2
+ import { Link } from "@tata1mg/router";
3
+ import css from './Home.scss'
4
+
5
+ function Landing() {
6
+ return (
7
+ <div className={css.app}>
8
+ <header className={css.appHeader}>
9
+ <h1 className={css.heading}>Catalyst</h1>
10
+ <p>
11
+ Edit files inside src directory and save to reload.
12
+ </p>
13
+ <a
14
+ className={css.appLink}
15
+ href="https://catalyst.1mg.com"
16
+ target="_blank"
17
+ rel="noopener noreferrer"
18
+ >
19
+ Learn Catalyst
20
+ </a>
21
+ <Link to="/demo" className={css.appLink}>Navigate to demo page</Link>
22
+ </header>
23
+ </div>
24
+ )
25
+ }
26
+
27
+ export default Landing
@@ -0,0 +1,36 @@
1
+ body {
2
+ margin: 0;
3
+ }
4
+
5
+ .app {
6
+ text-align: center;
7
+ margin: 0;
8
+ }
9
+
10
+ .appLogo {
11
+ height: 40vmin;
12
+ pointer-events: none;
13
+ }
14
+
15
+ @media (prefers-reduced-motion: no-preference) {
16
+ .appLogo {
17
+ animation: App-logo-spin infinite 20s linear;
18
+ }
19
+ }
20
+
21
+ .appHeader {
22
+ background-color: #282c34;
23
+ min-height: 100vh;
24
+ display: flex;
25
+ flex-direction: column;
26
+ align-items: center;
27
+ justify-content: center;
28
+ font-size: calc(10px + 2vmin);
29
+ color: white;
30
+ }
31
+
32
+ .appLink {
33
+ color: #61dafb;
34
+ }
35
+
36
+
@@ -0,0 +1,80 @@
1
+ import { combineReducers } from "redux"
2
+ // Import your reducers here
3
+
4
+ import shellReducer from "@containers/App/reducer"
5
+
6
+ /**
7
+ * @description A 'Reducer Manager' object, which keeps track of all the registered reducers and exposes a reduce() function. For detailed info :- https://redux.js.org/usage/code-splitting#using-a-reducer-manager
8
+ */
9
+
10
+ function createReducerManager() {
11
+ // FRAMEWORK COMMENT THIS SHOULD BE EXPOSED TO USER
12
+ // Create an object which maps keys to reducers
13
+ const reducers = {
14
+ shellReducer,
15
+ }
16
+
17
+ // Create the initial combinedReducer
18
+ let reducerObj = combineReducers(reducers)
19
+
20
+ // An array which is used to delete state keys when reducers are removed
21
+ let keysToRemove = []
22
+
23
+ return {
24
+ getReducerMap: () => combineReducers(reducers),
25
+ // The root reducer function exposed by this object
26
+
27
+ // This will be passed to the store
28
+ reduce: (state, action) => {
29
+ // If any reducers have been removed, clean up their state first
30
+ if (keysToRemove.length > 0) {
31
+ state = { ...state }
32
+ for (let key of keysToRemove) {
33
+ delete state[key]
34
+ }
35
+ keysToRemove = []
36
+ }
37
+
38
+ // Delegate to the combined reducer
39
+ return reducerObj(state, action)
40
+ },
41
+
42
+ // Adds a new reducer with the specified key
43
+ add: (reducer) => {
44
+ for (let key in reducer) {
45
+ if (!key) {
46
+ return
47
+ }
48
+
49
+ // We will skip a step if the reducer is already present
50
+ if (reducers[key]) {
51
+ continue
52
+ }
53
+
54
+ // Add the reducer to the reducer mapping
55
+ reducers[key] = reducer[key]
56
+ }
57
+
58
+ // Generate a new combined reducer
59
+ return combineReducers(reducers)
60
+ },
61
+
62
+ // Removes a reducer with the specified key
63
+ remove: (key) => {
64
+ if (!key || !reducers[key]) {
65
+ return
66
+ }
67
+
68
+ // Remove it from the reducer mapping
69
+ delete reducers[key]
70
+
71
+ // Add the key to the list of keys to clean up
72
+ keysToRemove.push(key)
73
+
74
+ // Generate a new combined reducer
75
+ return combineReducers(reducers)
76
+ },
77
+ }
78
+ }
79
+
80
+ export default createReducerManager
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import { RouterDataProvider, MetaTag } from "@tata1mg/router";
3
+ import Home from "@containers/Home/Home";
4
+ import App from "@containers/App";
5
+ import Demo from "@containers/DemoPage/DemoPage"
6
+
7
+ const routes = [
8
+ {
9
+ path: "/",
10
+ end: true,
11
+ component: Home,
12
+ },
13
+ {
14
+ path:"/demo",
15
+ end:true,
16
+ component: Demo
17
+ }
18
+ ];
19
+ const getRoutes = () => {
20
+ return routes;
21
+ };
22
+
23
+ /**
24
+ * Making the routes array compatible with the format accepted by createBrowserRouter
25
+ * API on the client side
26
+ */
27
+ export const preparedRoutes = ({store,routerInitialState}) => {
28
+
29
+ return ([
30
+ {
31
+ element: (
32
+ <RouterDataProvider config={{}} initialState={routerInitialState} fetcherArgs={{store}} >
33
+ <MetaTag/>
34
+ <App />
35
+ </RouterDataProvider>
36
+ ),
37
+ children: getRoutes()?.map((route, index) => {
38
+ const Component = route.component;
39
+ // const pageType = route.staticPageType ? route.staticPageType : null
40
+ return {
41
+ ...route,
42
+ element: <Component key={index} />,
43
+ };
44
+ }),
45
+ },
46
+ ])
47
+ }
48
+
49
+ export default getRoutes;
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import { Provider } from "react-redux";
3
+ import configureStore from "../store";
4
+
5
+ const ClientProvider = ({ children }) => {
6
+ const { __INITIAL_STATE__ } = window;
7
+
8
+ let store = configureStore(__INITIAL_STATE__);
9
+ return (
10
+ <Provider store={store} serverState={__INITIAL_STATE__}>
11
+ {children}
12
+ </Provider>
13
+ );
14
+ };
15
+
16
+ const ServerProvider = ({ store, children }) => {
17
+ return <Provider store={store}>{children}</Provider>; //on server
18
+ };
19
+
20
+
21
+ const serverStore = (initialState,req) => {
22
+ // will create a new store on server and this store would be available in server provider
23
+ return configureStore(initialState, req);
24
+ };
25
+
26
+ const hydrateClient = (serverStore) => {
27
+ const state = serverStore.getState();
28
+
29
+ return <script>{`window.__INITIAL_STATE__ = ${state} `}</script>;
30
+ };
31
+
32
+ // will be calling hydrate client in the template wrapper
33
+
34
+ export { ClientProvider, ServerProvider, hydrateClient, serverStore };
@@ -0,0 +1,79 @@
1
+ import { compose, applyMiddleware,combineReducers } from "redux"
2
+ import {configureStore as createStore} from "@reduxjs/toolkit"
3
+ import thunk from "redux-thunk"
4
+ import { createLogger } from "redux-logger"
5
+ import shellReducer from "@containers/App/reducer.js"
6
+ import createReducerManager from "../reducer/index.js"
7
+ import fetchInstance from "../../../api.js"
8
+ /**
9
+ * Function that initializes the store with the initialstate and adds middlewares that can be used during action dispatch
10
+ * @param {object} initialState Default state
11
+ * @param {object} cookies additional headers if needed
12
+ * @param {object} requestObj additional information
13
+ * @return {object} the store itself
14
+ */
15
+
16
+ process.env.NODE_ENV === "production"
17
+
18
+ export default function configureStore(initialState, request) {
19
+
20
+ // The variable defined below acts as a flag when the store is initialized on the client side
21
+ // Reason being that for the first time we need to actually need to forcefully set the reducer for which we have the initial data
22
+ let initializeClient = true
23
+
24
+ const reducerManager = createReducerManager()
25
+
26
+ // FRAMEWORK COMMENT. This should be exposed to user.
27
+ const api = fetchInstance
28
+
29
+
30
+ // disable redux-logger in server - https://github.com/LogRocket/redux-logger/issues/6
31
+ const reduxLogger = createLogger({
32
+ predicate: () => typeof window !== "undefined",
33
+ })
34
+ const addReducer = (reducer) => {
35
+ // Only executed once when for the first run in client - side
36
+ if (initializeClient) {
37
+ initializeClient = false
38
+ return store.replaceReducer(reducerManager.add(reducer))
39
+ }
40
+
41
+ // This blocks check if the reducer is already added or not in store
42
+ // If not then it only add the missing reducers
43
+ // And if the required reducers are already present then we simply return without performing any change
44
+ let reducerToAdd = {}
45
+ const currentState = store.getState()
46
+ for (let key in reducer) {
47
+ if (!currentState[key]) {
48
+ reducerToAdd[key] = reducer[key]
49
+ }
50
+ }
51
+ if (Object.keys(reducerToAdd).length > 0) {
52
+ return store.replaceReducer(reducerManager.add(reducerToAdd))
53
+ }
54
+ return
55
+ }
56
+ let middleware = [thunk.withExtraArgument({ api, addReducer })]
57
+ if(process.env.NODE_ENV !== "production"){
58
+ middleware = [...middleware,reduxLogger]
59
+ }
60
+ // Add universal enhancers here
61
+ let enhancers = []
62
+
63
+ const composeEnhancers = process.env.NODE_ENV === "production" && (typeof window !== "undefined" && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose
64
+ const enhancer = composeEnhancers(...[applyMiddleware(...middleware), ...enhancers])
65
+
66
+ // create store with enhancers, middleware, reducers, and initialState
67
+ // When the store is initialized on the client side, we are passing a function that just returns the initial State from the server
68
+ // This is way we are able to maintain the initial state from the server on the client side and then add the relevant reducers
69
+ // Which then consumes the initial state
70
+ const store = createStore({
71
+ reducer:combineReducers({shellReducer}),
72
+ preloadedState:initialState
73
+ })
74
+
75
+
76
+ return store
77
+ }
78
+
79
+
@@ -0,0 +1,3 @@
1
+
2
+ @import "styles";
3
+ @import "../resources/variables";
@@ -0,0 +1,11 @@
1
+ html {
2
+ box-sizing: border-box;
3
+ }
4
+
5
+ html,
6
+ body {
7
+ height: 100%;
8
+ font-family: Inter, Poppins, Avenir, "Century Gothic", Arial, sans-serif;
9
+ -webkit-tap-highlight-color: transparent;
10
+ margin: 0;
11
+ }