catalyst-core 0.2.0-beta.3 → 0.3.0-beta.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/babel.native.config.cjs +8 -0
- package/bin/catalyst.js +49 -105
- package/changelog.md +8 -0
- package/dist/caching.js +1 -1
- package/dist/globals.d.ts +7 -0
- package/dist/index.jsx +8 -0
- package/dist/logger.js +74 -3
- package/dist/native/androidProject/app/build.gradle.kts +45 -4
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/NativeBridge.kt +86 -0
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/BridgeUtils.kt +8 -0
- package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/FrameworkServerUtils.kt +173 -13
- package/dist/native/androidProject/settings.gradle.kts +10 -0
- package/dist/native/androidSetup.js +300 -8
- package/dist/native/bridge/WebBridge.js +481 -59
- package/dist/native/bridge/constants/NativeInterfaces.js +304 -45
- package/dist/native/bridge/errors.js +250 -26
- package/dist/native/bridge/hooks/index.js +132 -1
- package/dist/native/bridge/hooks/useAI.js +94 -0
- package/dist/native/bridge/hooks/useCamera.js +347 -9
- package/dist/native/bridge/hooks/useDataProtection.js +200 -2
- package/dist/native/bridge/hooks/useDeviceInfo.js +71 -2
- package/dist/native/bridge/hooks/useFilePicker.js +429 -2
- package/dist/native/bridge/hooks/useGoogleSignIn.js +81 -1
- package/dist/native/bridge/hooks/useHapticFeedback.js +196 -1
- package/dist/native/bridge/hooks/useIntent.js +95 -1
- package/dist/native/bridge/hooks/useNativeTransition.js +202 -27
- package/dist/native/bridge/hooks/useNetworkStatus.js +84 -3
- package/dist/native/bridge/hooks/useNotification.js +318 -2
- package/dist/native/bridge/hooks/useSafeArea.js +84 -2
- package/dist/native/bridge/hooks/useVideoStream.js +434 -6
- package/dist/native/bridge/hooks/utils.js +27 -1
- package/dist/native/bridge/hooks.js +16 -1
- package/dist/native/bridge/perf/collectors/ApiCollector.js +66 -3
- package/dist/native/bridge/perf/collectors/CacheCollector.js +186 -11
- package/dist/native/bridge/perf/collectors/HookCollector.js +141 -19
- package/dist/native/bridge/perf/collectors/InsightsCollector.js +481 -23
- package/dist/native/bridge/perf/collectors/InteractionCollector.js +245 -10
- package/dist/native/bridge/perf/collectors/KeyboardCollector.js +107 -8
- package/dist/native/bridge/perf/collectors/NavigationCollector.js +273 -32
- package/dist/native/bridge/perf/collectors/NetworkTimingCollector.js +178 -2
- package/dist/native/bridge/perf/collectors/RenderCollector.js +258 -14
- package/dist/native/bridge/perf/collectors/ScrollCollector.js +95 -9
- package/dist/native/bridge/perf/collectors/ThreadCollector.js +90 -6
- package/dist/native/bridge/perf/core/constants.js +103 -20
- package/dist/native/bridge/perf/core/measure.js +179 -30
- package/dist/native/bridge/perf/core/session.js +89 -23
- package/dist/native/bridge/perf/core/store.js +554 -1
- package/dist/native/bridge/perf/core/summary.js +174 -1
- package/dist/native/bridge/perf/core/traceExport.js +240 -1
- package/dist/native/bridge/perf/core/waterfalls.js +146 -1
- package/dist/native/bridge/perf/index.js +359 -38
- package/dist/native/bridge/safeArea.js +53 -5
- package/dist/native/bridge/standardizedHooks.js +595 -82
- package/dist/native/bridge/useBaseHook.js +274 -38
- package/dist/native/bridge/utils/CameraUtils.js +201 -56
- package/dist/native/bridge/utils/FileObjectConverter.js +129 -18
- package/dist/native/bridge/utils/NativeBridge.js +425 -141
- package/dist/native/buildAndroid/assets.js +510 -13
- package/dist/native/buildAndroid/build.js +296 -19
- package/dist/native/buildAndroid/config.js +87 -1
- package/dist/native/buildAndroid/index.js +406 -1
- package/dist/native/buildAppAndroid.js +34 -2
- package/dist/native/buildAppIos.js +62 -2
- package/dist/native/buildIos/assets.js +609 -8
- package/dist/native/buildIos/build.js +639 -20
- package/dist/native/buildIos/config.js +294 -12
- package/dist/native/buildIos/index.js +343 -6
- package/dist/native/buildIos/plugins.js +343 -16
- package/dist/native/internal-plugins/device-info-plugin/android/DeviceInfoPlugin.kt +43 -0
- package/dist/native/internal-plugins/device-info-plugin/ios/DeviceInfoPlugin.swift +28 -0
- package/dist/native/internal-plugins/device-info-plugin/manifest.json +19 -0
- package/dist/native/internalPluginUtils.js +232 -7
- package/dist/native/package.json +3 -0
- package/dist/native/plugin-bridge/PluginBridge.js +227 -1
- package/dist/native/pluginComposerAndroid.js +407 -23
- package/dist/native/pluginComposerIos.js +435 -11
- package/dist/native/renameAndroidProject.js +1094 -88
- package/dist/native/setupEmulatorIos.js +289 -22
- package/dist/native/setupServer.js +160 -19
- package/dist/native/terminalProgress.js +199 -11
- package/dist/native/utils.js +193 -15
- package/dist/offline/catalyst-sw.js +145 -1
- package/dist/offline/registerServiceWorker.js +33 -1
- package/dist/otel.js +375 -46
- package/dist/router/ClientRouter.js +14 -2
- package/dist/router/ServerRouter.js +9 -1
- package/dist/router.js +1 -1
- package/dist/scripts/build.js +112 -3
- package/dist/scripts/checkVersion.js +3 -1
- package/dist/scripts/cleanCache.js +30 -1
- package/dist/scripts/generateOfflineManifest.js +116 -1
- package/dist/scripts/loadEnvironmentVariables.js +32 -6
- package/dist/scripts/plugins.js +309 -1
- package/dist/scripts/preServerInit.js +13 -0
- package/dist/scripts/scriptUtils.js +54 -3
- package/dist/scripts/serve.js +51 -4
- package/dist/scripts/start.js +47 -10
- package/dist/scripts/validator.js +149 -1
- package/dist/sentry.cjs +127 -0
- package/dist/sentry.js +125 -5
- package/dist/server/expressServer.js +296 -5
- package/dist/server/manifestCache.js +36 -0
- package/dist/server/renderer/ChunkExtractor.js +144 -0
- package/dist/server/renderer/document/Body.jsx +59 -0
- package/dist/server/renderer/document/FastRefresh.jsx +20 -0
- package/dist/server/renderer/document/Head.jsx +60 -0
- package/dist/server/renderer/document/index.jsx +2 -0
- package/dist/server/renderer/extract.js +149 -31
- package/dist/server/renderer/handler.jsx +450 -0
- package/dist/server/renderer/index.js +8 -1
- package/dist/server/renderer/render.js +47 -0
- package/dist/server/utils/botDetectionMiddleware.js +29 -0
- package/dist/server/utils/cjsRequire.js +10 -0
- package/dist/server/utils/userAgentUtil.js +87 -9
- package/dist/server/utils/validator.js +164 -1
- package/dist/vite/FastRefresh.jsx +20 -0
- package/dist/vite/inject-cache-key-plugin.js +276 -0
- package/dist/vite/loadCustomViteConfig.js +22 -0
- package/dist/vite/manifest-categorization-plugin.js +455 -0
- package/dist/vite/node-loader.mjs +458 -0
- package/dist/vite/scssParams.js +21 -0
- package/dist/vite/vite.config.client.js +130 -0
- package/dist/vite/vite.config.js +498 -0
- package/dist/vite/vite.config.server.js +84 -0
- package/dist/web-router/components/MetaTag.jsx +34 -0
- package/dist/web-router/components/RouterDataProvider.jsx +332 -0
- package/dist/web-router/components/Split.jsx +200 -0
- package/dist/web-router/components/SplitInview.jsx +106 -0
- package/dist/web-router/components/SsrRequestContext.jsx +14 -0
- package/dist/web-router/context.jsx +12 -0
- package/dist/web-router/hooks.jsx +72 -0
- package/dist/web-router/types/components/MetaTag.d.ts +2 -0
- package/dist/web-router/types/components/RouterDataProvider.d.ts +95 -0
- package/dist/web-router/types/context.d.ts +14 -0
- package/dist/web-router/types/hooks.d.ts +1 -0
- package/dist/web-router/types/index.d.ts +3 -0
- package/dist/web-router/types/utils/metaDataUtils.d.ts +24 -0
- package/dist/web-router/utils/metaDataUtils.jsx +119 -0
- package/mcp_v2/conversion-tasks.json +35 -17
- package/mcp_v2/knowledge-base.json +176 -17
- package/mcp_v2/lib/helpers.js +10 -0
- package/mcp_v2/mcp.js +40 -8
- package/mcp_v2/package.json +1 -0
- package/mcp_v2/tools/build.js +161 -37
- package/mcp_v2/tools/conversion.js +106 -5
- package/mcp_v2/tools/tasks.js +18 -14
- package/package.json +35 -68
- package/babel.config.js +0 -32
- package/dist/index.js +0 -1
- package/dist/scripts/devBuild.js +0 -3
- package/dist/scripts/devServe.js +0 -3
- package/dist/scripts/loadScriptsBeforeServerStarts.js +0 -4
- package/dist/scripts/registerAliases.js +0 -6
- package/dist/server/renderer/document/Body.js +0 -11
- package/dist/server/renderer/document/Head.js +0 -9
- package/dist/server/renderer/document/index.js +0 -1
- package/dist/server/renderer/handler.js +0 -47
- package/dist/server/startServer.js +0 -57
- package/dist/webpack/babel-plugins/remove-client.plugin.js +0 -5
- package/dist/webpack/babel-plugins/remove-ssr.plugin.js +0 -5
- package/dist/webpack/babel.config.client.js +0 -1
- package/dist/webpack/babel.config.ssr.js +0 -1
- package/dist/webpack/base.babel.js +0 -7
- package/dist/webpack/development.client.babel.js +0 -10
- package/dist/webpack/production.client.babel.js +0 -4
- package/dist/webpack/production.ssr.babel.js +0 -8
- package/dist/webpack/scssParams.js +0 -9
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catalyst-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.3.0-beta.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.jsx",
|
|
5
6
|
"description": "Web framework that provides great performance out of the box",
|
|
6
7
|
"bin": {
|
|
7
8
|
"catalyst": "bin/catalyst.js"
|
|
@@ -12,97 +13,59 @@
|
|
|
12
13
|
"directory": "packages/catalyst-core"
|
|
13
14
|
},
|
|
14
15
|
"_moduleAliases": {
|
|
15
|
-
"@catalyst/template": "."
|
|
16
|
-
"@catalyst/template/src": "src",
|
|
17
|
-
"@catalyst/template/routes": "src/js/routes",
|
|
18
|
-
"@catalyst/template/server": "server",
|
|
19
|
-
"@catalyst/template/store": "src/js/store",
|
|
20
|
-
"@catalyst/template/config": "config",
|
|
21
|
-
"@catalyst": ".",
|
|
22
|
-
"@catalyst/root": "../",
|
|
23
|
-
"@catalyst/router": "router",
|
|
24
|
-
"@catalyst/scripts": "scripts",
|
|
25
|
-
"@catalyst/server": "server",
|
|
26
|
-
"@catalyst/webpack": "webpack"
|
|
16
|
+
"@catalyst/template": "."
|
|
27
17
|
},
|
|
28
18
|
"exports": {
|
|
29
|
-
".": "./dist/index.
|
|
19
|
+
".": "./dist/index.jsx",
|
|
30
20
|
"./package.json": "./package.json",
|
|
31
21
|
"./logger": "./dist/logger.js",
|
|
32
22
|
"./caching": "./dist/caching.js",
|
|
33
23
|
"./router/ClientRouter": "./dist/router/ClientRouter.js",
|
|
24
|
+
"./document": "./dist/server/renderer/document/index.jsx",
|
|
34
25
|
"./WebBridge": "./dist/native/bridge/WebBridge.js",
|
|
35
26
|
"./hooks": "./dist/native/bridge/hooks.js",
|
|
36
|
-
"./sentry": "./dist/sentry.
|
|
27
|
+
"./sentry": "./dist/sentry.cjs",
|
|
37
28
|
"./otel": "./dist/otel.js"
|
|
38
29
|
},
|
|
39
30
|
"scripts": {
|
|
40
31
|
"lint": "eslint .",
|
|
32
|
+
"lint-staged": "lint-staged",
|
|
41
33
|
"prettify": "prettier . --write",
|
|
42
|
-
"prepare": "
|
|
34
|
+
"prepare": "node ../../scripts/safe-rimraf.js ./dist && cp -r ./src ./dist && babel src/native --out-dir dist/native --config-file ./babel.native.config.cjs --ignore '**/.build/**' && babel src/sentry.js --out-file dist/sentry.cjs --config-file ./babel.native.config.cjs",
|
|
43
35
|
"prepublishOnly": "npm run prepare",
|
|
44
36
|
"test:fixture": "sh ../../scripts/test-catalyst-core.sh"
|
|
45
37
|
},
|
|
46
38
|
"license": "MIT",
|
|
47
39
|
"dependencies": {
|
|
48
|
-
"@
|
|
49
|
-
"@babel/core": "^7.23.2",
|
|
50
|
-
"@babel/node": "^7.22.19",
|
|
51
|
-
"@babel/preset-env": "^7.23.2",
|
|
52
|
-
"@babel/preset-react": "^7.22.15",
|
|
53
|
-
"@babel/preset-typescript": "^7.24.7",
|
|
54
|
-
"@babel/register": "^7.22.15",
|
|
55
|
-
"@dr.pogodin/css-modules-require-hook": "^4.7.3",
|
|
56
|
-
"@loadable/babel-plugin": "^5.16.1",
|
|
57
|
-
"@loadable/component": "^5.15.3",
|
|
58
|
-
"@loadable/server": "^5.16.1",
|
|
59
|
-
"@loadable/webpack-plugin": "^5.15.2",
|
|
60
|
-
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
|
|
61
|
-
"@svgr/webpack": "^8.1.0",
|
|
62
|
-
"@tata1mg/router": "0.1.0-beta",
|
|
63
|
-
"app-root-path": "^3.1.0",
|
|
64
|
-
"babel-loader": "^9.1.3",
|
|
65
|
-
"babel-plugin-react-compiler": "^19.0.0-beta-decd7b8-20250118",
|
|
40
|
+
"@vitejs/plugin-react": "^4.4.1",
|
|
66
41
|
"body-parser": "^1.20.2",
|
|
67
|
-
"chokidar": "^3.6.0",
|
|
68
42
|
"compression": "^1.7.4",
|
|
69
43
|
"cookie-parser": "^1.4.6",
|
|
70
|
-
"cross-env": "^7.0.3",
|
|
71
|
-
"css-hot-loader": "^1.4.4",
|
|
72
|
-
"css-loader": "^6.8.1",
|
|
73
44
|
"express": "^4.18.2",
|
|
74
45
|
"express-static-gzip": "^2.1.7",
|
|
75
|
-
"file-loader": "^6.2.0",
|
|
76
|
-
"html-loader": "^4.2.0",
|
|
77
|
-
"img-loader": "^4.0.0",
|
|
78
|
-
"mini-css-extract-plugin": "^2.7.6",
|
|
79
|
-
"module-alias": "^2.2.3",
|
|
80
46
|
"picocolors": "^1.0.0",
|
|
81
|
-
"postcss-loader": "^7.3.3",
|
|
82
|
-
"postcss-scss": "^4.0.9",
|
|
83
47
|
"react": "19.0.0",
|
|
84
|
-
"react-compiler-runtime": "^19.0.0-beta-decd7b8-20250118",
|
|
85
48
|
"react-dom": "19.0.0",
|
|
49
|
+
"react-helmet-async": "^1.3.0",
|
|
86
50
|
"react-redux": "^9.2.0",
|
|
87
51
|
"react-refresh": "^0.14.0",
|
|
88
52
|
"react-router-dom": "^6.16.0",
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"sass
|
|
53
|
+
"redux": "^4.2.1",
|
|
54
|
+
"sanitize-html": "^2.13.1",
|
|
55
|
+
"sass": "^1.89.2",
|
|
92
56
|
"ua-parser-js": "^1.0.37",
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"webpack": "^5.88.2",
|
|
96
|
-
"webpack-bundle-analyzer": "^4.9.1",
|
|
97
|
-
"webpack-cli": "^5.1.4",
|
|
98
|
-
"webpack-dev-server": "^5.2.4",
|
|
99
|
-
"webpack-merge": "^5.9.0",
|
|
100
|
-
"webpack-node-externals": "^3.0.0",
|
|
57
|
+
"vite": "^6.4.3",
|
|
58
|
+
"vite-plugin-svgr": "^5.0.0",
|
|
101
59
|
"winston": "^3.11.0",
|
|
102
60
|
"winston-daily-rotate-file": "^5.0.0"
|
|
103
61
|
},
|
|
104
62
|
"devDependencies": {
|
|
63
|
+
"@babel/cli": "^7.23.0",
|
|
64
|
+
"@babel/core": "^7.23.2",
|
|
105
65
|
"@babel/eslint-parser": "^7.19.1",
|
|
66
|
+
"@babel/preset-env": "^7.23.2",
|
|
67
|
+
"@babel/preset-react": "^7.22.15",
|
|
68
|
+
"@babel/preset-typescript": "^7.24.7",
|
|
106
69
|
"@commitlint/cli": "^19.3.0",
|
|
107
70
|
"@commitlint/config-conventional": "^19.2.2",
|
|
108
71
|
"eslint": "^8.26.0",
|
|
@@ -112,20 +75,24 @@
|
|
|
112
75
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
113
76
|
"eslint-plugin-risxss": "^2.1.0",
|
|
114
77
|
"eslint-plugin-security": "^3.0.0",
|
|
78
|
+
"husky": "^9.0.11",
|
|
79
|
+
"lint-staged": "^15.2.2",
|
|
115
80
|
"prettier": "^3.2.5"
|
|
116
81
|
},
|
|
82
|
+
"lint-staged": {
|
|
83
|
+
"*.{js,jsx}": [
|
|
84
|
+
"eslint .",
|
|
85
|
+
"prettier . --write"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
117
88
|
"overrides": {
|
|
118
|
-
"
|
|
119
|
-
"react": "
|
|
120
|
-
|
|
121
|
-
"@loadable/server": {
|
|
122
|
-
"react": "^16.3.0 || ^17.0.0 || ^18.0.0 || 19.0.0"
|
|
89
|
+
"react-helmet-async": {
|
|
90
|
+
"react": "19.0.0",
|
|
91
|
+
"react-dom": "19.0.0"
|
|
123
92
|
},
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"webpack-dev-server": {
|
|
128
|
-
"http-proxy-middleware": "3.0.7"
|
|
93
|
+
"react-redux": {
|
|
94
|
+
"react": "19.0.0",
|
|
95
|
+
"react-dom": "19.0.0"
|
|
129
96
|
}
|
|
130
97
|
}
|
|
131
98
|
}
|
package/babel.config.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
module.exports = (api) => {
|
|
2
|
-
api.cache(true)
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
presets: [
|
|
6
|
-
[
|
|
7
|
-
"@babel/preset-typescript",
|
|
8
|
-
{
|
|
9
|
-
isTSX: true,
|
|
10
|
-
allExtensions: true,
|
|
11
|
-
},
|
|
12
|
-
],
|
|
13
|
-
[
|
|
14
|
-
"@babel/preset-env",
|
|
15
|
-
{
|
|
16
|
-
targets: {
|
|
17
|
-
node: "current",
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
["@babel/preset-react", { runtime: "automatic" }],
|
|
22
|
-
],
|
|
23
|
-
compact: true,
|
|
24
|
-
plugins: ["@loadable/babel-plugin"],
|
|
25
|
-
env: {
|
|
26
|
-
test: {
|
|
27
|
-
presets: ["@babel/preset-react"],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
ignore: ["__TEST__"],
|
|
31
|
-
}
|
|
32
|
-
}
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _index=require("./server/renderer/document/index");Object.keys(_index).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_index[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _index[key];}});});
|
package/dist/scripts/devBuild.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const path=require("path");const{green,cyan,yellow}=require("picocolors");const{name}=require(`${process.cwd()}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.cwd()}/config/config.json`);const{arrayToObject,printBundleInformation,runBuildCommands}=require("./scriptUtils.js");/**
|
|
2
|
-
* @description - creates a production build of the application.
|
|
3
|
-
*/function devBuild(){const isWindows=process.platform==="win32";const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../../");const commands=["node ./dist/scripts/checkVersion",`${isWindows?"rd -r -fo":"rm -rf"} ${process.cwd()}/${BUILD_OUTPUT_PATH} & node ./dist/scripts/loadScriptsBeforeServerStarts.js`,`cross-env APPLICATION=${name||"catalyst_app"} webpack --config ./dist/webpack/production.client.babel.js --progress`,`cross-env APPLICATION=${name||"catalyst_app"} SSR=true webpack --config ./dist/webpack/production.ssr.babel.js`,`cross-env APPLICATION=${name||"catalyst_app"} node ./dist/scripts/generateOfflineManifest.js`,`cross-env APPLICATION=${name||"catalyst_app"} npx babel ./dist/server --out-dir ${process.cwd()}/${BUILD_OUTPUT_PATH} --ignore '**/*.test.js,./dist/server/renderer/handler.js' --quiet`,`cross-env APPLICATION=${name||"catalyst_app"} npx babel ${process.cwd()}/server --out-dir ${process.cwd()}/${BUILD_OUTPUT_PATH} --quiet`];console.log("Creating an optimized local build...");runBuildCommands({commands,cwd:dirname,env:{...process.env,src_path:process.cwd(),BUILD_OUTPUT_PATH:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,...argumentsObject}});console.log(green("Compiled successfully."));console.log("\nFile sizes after gzip:\n");printBundleInformation();console.log(`\nThe ${cyan(BUILD_OUTPUT_PATH)} folder is ready to be deployed.`);console.log("You may serve it with a serve command:");console.log(cyan("\n npm run devServe"));console.log("\nFind out more about deployment here:");console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/Deployment%20and%20Production/deployment\n"));}devBuild();
|
package/dist/scripts/devServe.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.cwd()}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.cwd()}/config/config.json`);/**
|
|
2
|
-
* @description - Serves production build of the application.
|
|
3
|
-
*/function devServe(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../../");spawnSync("node",["-r","./dist/scripts/loadScriptsBeforeServerStarts.js",path.join(process.cwd(),BUILD_OUTPUT_PATH,"startServer.js")],{cwd:dirname,stdio:"inherit",env:{...process.env,src_path:process.cwd(),BUILD_OUTPUT_PATH:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,APPLICATION:name||"catalyst_app",...argumentsObject}});}devServe();
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";require("./registerAliases.js");var _cssModulesRequireHook=_interopRequireDefault(require("@dr.pogodin/css-modules-require-hook"));var _path=_interopRequireDefault(require("path"));var _loadEnvironmentVariables=_interopRequireDefault(require("./loadEnvironmentVariables"));var _postcssScss=_interopRequireDefault(require("postcss-scss"));var _logger=require("@catalyst/logger.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}/* eslint-disable */const{cssModulesIdentifierDev}=require("@catalyst/root/config.json");// stores your config keys in enviorments variables
|
|
2
|
-
(0,_loadEnvironmentVariables.default)();// creates logger instance with provided config and stores them at global level.
|
|
3
|
-
(0,_logger.configureLogger)({enableDebugLogs:process.env.ENABLE_DEBUG_LOGS,enableFileLogging:process.env.ENABLE_FILE_LOGGING,enableConsoleLogging:process.env.ENABLE_CONSOLE_LOGGING});// compile css-variables in realtime in dev mode.
|
|
4
|
-
if(process.env.NODE_ENV==="development")(0,_cssModulesRequireHook.default)({extensions:[".scss",".css"],processorOpts:{parser:_postcssScss.default.parse},generateScopedName:cssModulesIdentifierDev,devMode:true,ignore:_path.default.posix.join(process.env.src_path,"/src/static/css/base/(?!.*.scss$).*")});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.catalystResultMap=void 0;var _path=_interopRequireDefault(require("path"));var _moduleAlias=_interopRequireDefault(require("module-alias"));var _package=require("../../package.json");var _validator=require("./validator.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}const{_moduleAliases:templateModuleAliases}=require(`${process.env.src_path}/package.json`);const catalystResultMap=exports.catalystResultMap=Object.keys(_package._moduleAliases||[]).reduce((resultMap,aliasName)=>{const aliasPath=_package._moduleAliases[aliasName];if(aliasName?.includes("@catalyst/template")){if(aliasName?.includes("server")&&process.env.NODE_ENV==="production"){resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}else{// nosemgrep
|
|
2
|
-
resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);}return resultMap;}if(aliasName?.includes("@catalyst")&&!aliasName?.includes("@catalyst/template")){if(aliasName?.includes("server")&&process.env.NODE_ENV==="production"){resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}else{// nosemgrep
|
|
3
|
-
resultMap[aliasName]=_path.default.join(__dirname,"../",aliasPath);}return resultMap;}return resultMap;},{});_moduleAlias.default.addAliases(catalystResultMap);// resolves module alias imports
|
|
4
|
-
if((0,_validator.validateModuleAlias)(templateModuleAliases)){_moduleAlias.default.addAliases(Object.keys(templateModuleAliases||[]).reduce((resultMap,aliasName)=>{const aliasPath=templateModuleAliases[aliasName];if(aliasPath.includes("server")){if(process.env.NODE_ENV!=="production"){// nosemgrep
|
|
5
|
-
resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);}else{resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}}else{// nosemgrep
|
|
6
|
-
resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);}return resultMap;},{}));}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Body=Body;var _react=_interopRequireDefault(require("react"));var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}/**
|
|
2
|
-
* Body component which will be used in page component
|
|
3
|
-
* @param {object} jsx - page jsx code
|
|
4
|
-
* @param {object} initialState - initial state object for redux store
|
|
5
|
-
* @param {object} firstFoldCss - style elements extracted for initial page load
|
|
6
|
-
* @param {object} fetcherData - contains data from executing serverFetcher function
|
|
7
|
-
* @param {object} children - contains any child elements defined within the component
|
|
8
|
-
*/const DEFAULT_SAFE_AREA={top:0,right:0,bottom:0,left:0};function Body({jsx="",initialState={},fetcherData={},children,safeArea=DEFAULT_SAFE_AREA,nativeWebView=false}){return/*#__PURE__*/(0,_jsxRuntime.jsxs)("body",{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("script",{/* eslint-disable-next-line risxss/catch-potential-xss-react */dangerouslySetInnerHTML:{__html:`window.__SAFE_AREA_INITIAL__ = ${JSON.stringify(safeArea)}; window.__CATALYST_NATIVE_WEBVIEW__ = ${nativeWebView?"true":"false"}`}}),jsx,/*#__PURE__*/(0,_jsxRuntime.jsx)("script",{/* eslint-disable */dangerouslySetInnerHTML:{__html:`
|
|
9
|
-
window.__INITIAL_STATE__ = ${JSON.stringify(initialState)}
|
|
10
|
-
window.__ROUTER_INITIAL_DATA__ = ${JSON.stringify(fetcherData)}
|
|
11
|
-
`}}),children]});}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Head=Head;var _react=_interopRequireDefault(require("react"));var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}/**
|
|
2
|
-
* Head component which will be used in page rendering
|
|
3
|
-
* @param {boolean} isBot - checks if request is made by bot
|
|
4
|
-
* @param {string} pageCss - includes all styles for page css
|
|
5
|
-
* @param {object} preloadJSLinks - async scripts for loading chunks
|
|
6
|
-
* @param {array} metaTags - user defined function which returns meta tags in array
|
|
7
|
-
* @param {string} publicAssetPath - public asset path for assets
|
|
8
|
-
* @param {object} children - contains any child elements defined within the component
|
|
9
|
-
*/function Head({pageCss,preloadJSLinks,metaTags,isBot,publicAssetPath,children}){if(children){return/*#__PURE__*/(0,_jsxRuntime.jsxs)("head",{children:[children,metaTags&&metaTags,pageCss&&/*#__PURE__*/(0,_jsxRuntime.jsx)("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks]});}return/*#__PURE__*/(0,_jsxRuntime.jsxs)("head",{children:[/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{charSet:"utf-8"}),/*#__PURE__*/(0,_jsxRuntime.jsx)("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),publicAssetPath&&/*#__PURE__*/(0,_jsxRuntime.jsx)("link",{rel:"preconnect",href:publicAssetPath}),publicAssetPath&&/*#__PURE__*/(0,_jsxRuntime.jsx)("link",{rel:"dns-prefetch",href:publicAssetPath}),metaTags&&metaTags,pageCss&&/*#__PURE__*/(0,_jsxRuntime.jsx)("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks]});}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _Head=require("./Head");Object.keys(_Head).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_Head[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _Head[key];}});});var _Body=require("./Body");Object.keys(_Body).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_Body[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _Body[key];}});});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _react=_interopRequireDefault(require("react"));var _extract=_interopRequireWildcard(require("./extract"));var _otel=require("../../otel");var _reactRedux=require("react-redux");var _document=require("./document");var _server=require("react-router-dom/server");var _ServerRouter=_interopRequireDefault(require("@catalyst/router/ServerRouter.js"));var _index=_interopRequireDefault(require("@catalyst/template/src/js/containers/App/index.js"));var _server2=require("@loadable/server");var _server3=require("react-dom/server");var _userAgentUtil=require("@catalyst/server/utils/userAgentUtil");var _router=require("@tata1mg/router");var _validator=require("@catalyst/server/utils/validator");var _document2=_interopRequireDefault(require("@catalyst/template/server/document.js"));var _utils=require("@catalyst/template/src/js/routes/utils.js");var _index2=require("@catalyst/template/server/index.js");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,t){if("function"==typeof WeakMap)var r=new WeakMap(),n=new WeakMap();return(_interopRequireWildcard=function(e,t){if(!t&&e&&e.__esModule)return e;var o,i,f={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return f;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,f);}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?o(f,t,i):f[t]=e[t]);return f;})(e,t);}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}const storePath=_path.default.resolve(`${process.env.src_path}/src/js/store/index.js`);let createStore;if(_fs.default.existsSync(storePath)){try{const{default:configureStore}=require(`${process.env.src_path}/src/js/store/index.js`);createStore=configureStore;}catch(error){createStore=()=>{return{getState:()=>{}};};}}else{createStore=()=>{return{getState:()=>{}};};}const isProduction=process.env.NODE_ENV==="production";const DEFAULT_SAFE_AREA_INSETS={top:0,right:0,bottom:0,left:0};const parseSafeAreaFromHeaders=req=>{const readEdge=header=>{const raw=req.get(header)??req.headers[header.toLowerCase()];const value=Number(raw);return Number.isFinite(value)&&value>=0?value:null;};const top=readEdge("X-Safe-Area-Top");const right=readEdge("X-Safe-Area-Right");const bottom=readEdge("X-Safe-Area-Bottom");const left=readEdge("X-Safe-Area-Left");const hasAny=[top,right,bottom,left].some(value=>value!==null);if(!hasAny){return null;}return{top:top??0,right:right??0,bottom:bottom??0,left:left??0};};const isNativeWebViewRequest=req=>{const raw=req.get("X-Catalyst-Native-WebView")??req.headers["x-catalyst-native-webview"];return raw==="1"||raw==="true";};// Cache webStats path - computed once at module load
|
|
2
|
-
const webStatsPath=isProduction?_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public/loadable-stats.json`):_path.default.join(__dirname,"../../..",`loadable-stats.json`);// Cache for parsed stats (production only)
|
|
3
|
-
let cachedWebStats=null;const getWebStats=()=>{if(!isProduction){// In development, stats can change; always read fresh.
|
|
4
|
-
return JSON.parse(_fs.default.readFileSync(webStatsPath,"utf-8"));}if(!cachedWebStats){cachedWebStats=JSON.parse(_fs.default.readFileSync(webStatsPath,"utf-8"));logger.info("ChunkExtractor stats cached in memory");}return cachedWebStats;};// Cache for ChunkExtractor instances per route (production only)
|
|
5
|
-
if(!process.extractorCache){process.extractorCache={};}const getOrCreateExtractorForRoute=routePath=>{if(!isProduction){// In dev, always create fresh extractor (HMR compatible)
|
|
6
|
-
return new _server2.ChunkExtractor({stats:getWebStats(),entrypoints:["app"]});}// Production: cache extractor per route
|
|
7
|
-
if(!process.extractorCache[routePath]){process.extractorCache[routePath]=new _server2.ChunkExtractor({stats:getWebStats(),entrypoints:["app"]});logger.info(`ChunkExtractor created and cached for route: ${routePath}`);}return process.extractorCache[routePath];};// Cache routes array - getRoutes() returns same reference, but validate once
|
|
8
|
-
let cachedRoutes=null;const getCachedRoutes=()=>{if(!cachedRoutes){cachedRoutes=(0,_validator.validateGetRoutes)(_utils.getRoutes)?(0,_utils.getRoutes)():[];}return cachedRoutes;};const SSR_SERVICE=process.env.SERVICE_NAME||`pwa-${process.env.APPLICATION}-node-server-otel`;const traceHandlerHook=(fn,spanName)=>typeof fn==="function"?(0,_otel.withSyncObservability)(SSR_SERVICE,fn,spanName):fn;const onRouteMatch=traceHandlerHook(_index2.onRouteMatch,"onRouteMatch");const onFetcherSuccess=traceHandlerHook(_index2.onFetcherSuccess,"onFetcherSuccess");const onFetcherError=traceHandlerHook(_index2.onFetcherError,"onFetcherError");const onAppServerSideSuccess=traceHandlerHook(_index2.onAppServerSideSuccess,"onAppServerSideSuccess");const onAppServerSideError=traceHandlerHook(_index2.onAppServerSideError,"onAppServerSideError");const onRenderError=traceHandlerHook(_index2.onRenderError,"onRenderError");const onRequestError=traceHandlerHook(_index2.onRequestError,"onRequestError");// Phase 1b dry-run: wrapped separately so it appears as a distinct span inside getMatchRoutes.
|
|
9
|
-
const renderToStringWithObservability=(0,_otel.withSyncObservability)(SSR_SERVICE,function dryRunRender(webExtractor,store,context,req,fetcherData){(0,_server3.renderToString)(/*#__PURE__*/(0,_jsxRuntime.jsx)(_server2.ChunkExtractorManager,{extractor:webExtractor,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactRedux.Provider,{store:store,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server.StaticRouter,{context:context,location:req.originalUrl,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_ServerRouter.default,{store:store,intialData:fetcherData})})})}));},"renderToString");// Internal recursive implementation — called directly to avoid creating a new span on each recursion.
|
|
10
|
-
const _getMatchRoutes=(routes,req,res,store,context,fetcherData,basePath="")=>{return routes.reduce((matches,route)=>{const{path}=route;const match=(0,_router.matchPath)({path:`${basePath}/${path}`,caseSensitive:false,end:true},req.baseUrl||"/");if(match){if(!res.locals.pageCss&&!res.locals.preloadJSLinks&&!res.locals.routePath){res.locals.routePath=path;// Phase 1a: try to serve CSS/preloadLinks from the extractor cache (production only).
|
|
11
|
-
// On a cache hit, res.locals.pageCss and preloadJSLinks are populated and
|
|
12
|
-
// the renderToString dry-run below is skipped entirely for this request.
|
|
13
|
-
(0,_extract.default)(res,route);}// Production: reuses the same ChunkExtractor per route (chunks accumulate over time).
|
|
14
|
-
// Dev: always creates a fresh extractor so HMR chunk changes are picked up immediately.
|
|
15
|
-
if(!res.locals.webExtractor){res.locals.webExtractor=getOrCreateExtractorForRoute(path);}if(!res.locals.pageCss&&!res.locals.preloadJSLinks){// Phase 1b: dry-run renderToString solely to let the ChunkExtractor record which
|
|
16
|
-
// chunks this route needs. The output is discarded — the real render happens later
|
|
17
|
-
// in renderMarkUp via renderToPipeableStream.
|
|
18
|
-
renderToStringWithObservability(res.locals.webExtractor,store,context,req,fetcherData);}const wc=route.component;matches.push({route,match,serverSideFunction:wc&&wc.serverSideFunction||(()=>Promise.resolve())});}if(!match&&route.children){const nested=_getMatchRoutes(route.children,req,res,store,context,fetcherData,`${basePath}/${path}`);if(nested.length){matches=matches.concat(nested);}}return matches;},[]);};const getMatchRoutes=(0,_otel.withSyncObservability)(SSR_SERVICE,_getMatchRoutes,"getMatchRoutes");// Preloads chunks required for rendering document
|
|
19
|
-
const getComponent=(store,context,req,fetcherData)=>{return/*#__PURE__*/(0,_jsxRuntime.jsx)("div",{id:"app",children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_reactRedux.Provider,{store:store,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_server.StaticRouter,{context:context,location:req.originalUrl,children:/*#__PURE__*/(0,_jsxRuntime.jsx)(_ServerRouter.default,{store:store,intialData:fetcherData})})})});};const tracedResWriteFirstFoldCss=(0,_otel.withSyncObservability)(SSR_SERVICE,(res,chunk)=>res.write(chunk),"res.write.firstFoldCss");const tracedResWriteFirstFoldJS=(0,_otel.withSyncObservability)(SSR_SERVICE,(res,chunk)=>res.write(chunk),"res.write.firstFoldJS");const tracedResEnd=(0,_otel.withSyncObservability)(SSR_SERVICE,res=>res.end(),"res.end");const renderMarkUp=async(errorCode,req,res,metaTags,fetcherData,store,matches,context,webExtractor)=>{const deviceDetails=(0,_userAgentUtil.getUserAgentDetails)(req.headers["user-agent"]||"");const isBot=deviceDetails.googleBot||deviceDetails.aiBot?true:false;const safeArea=parseSafeAreaFromHeaders(req)||{...DEFAULT_SAFE_AREA_INSETS};const nativeWebView=isNativeWebViewRequest(req);/* eslint-disable no-undef */const previousSafeArea=globalThis.__SAFE_AREA_INITIAL__;const previousNativeWebView=globalThis.__CATALYST_NATIVE_WEBVIEW__;globalThis.__SAFE_AREA_INITIAL__=safeArea;globalThis.__CATALYST_NATIVE_WEBVIEW__=nativeWebView;/* eslint-enable no-undef */let state=store.getState();// collectChunks wraps the component tree so the extractor can track which loadable
|
|
20
|
-
// chunks are actually rendered, building the final script/link tag lists.
|
|
21
|
-
const jsx=webExtractor.collectChunks(getComponent(store,context,req,fetcherData));const{IS_DEV_COMMAND,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT}=process.env;let publicAssetPath=`${process.env.PUBLIC_STATIC_ASSET_URL}${process.env.PUBLIC_STATIC_ASSET_PATH}`;// serves assets from localhost on running devBuild and devServe command
|
|
22
|
-
if(IS_DEV_COMMAND==="true"){publicAssetPath=`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/assets/`;}const finalProps={req,res,lang:"en",pageCss:res.locals.pageCss,preloadJSLinks:res.locals.preloadJSLinks,metaTags,isBot,publicAssetPath,jsx,initialState:state,fetcherData,safeArea,nativeWebView};let CompleteDocument=()=>{if((0,_validator.validateCustomDocument)(_document2.default)){return(0,_document2.default)(finalProps);}else{return/*#__PURE__*/(0,_jsxRuntime.jsxs)("html",{lang:finalProps.lang,children:[/*#__PURE__*/(0,_jsxRuntime.jsx)(_document.Head,{isBot:finalProps.isBot,pageCss:finalProps.pageCss,metaTags:finalProps.metaTags,preloadJSLinks:finalProps.preloadJSLinks,publicAssetPath:finalProps.publicAssetPath}),/*#__PURE__*/(0,_jsxRuntime.jsx)(_document.Body,{jsx:finalProps.jsx,fetcherData:finalProps.fetcherData,initialState:finalProps.initialState,safeArea:finalProps.safeArea,nativeWebView:finalProps.nativeWebView})]});}};const cleanupGlobalThis=()=>{/* eslint-disable no-undef */if(previousSafeArea===undefined){delete globalThis.__SAFE_AREA_INITIAL__;}else{globalThis.__SAFE_AREA_INITIAL__=previousSafeArea;}if(previousNativeWebView===undefined){delete globalThis.__CATALYST_NATIVE_WEBVIEW__;}else{globalThis.__CATALYST_NATIVE_WEBVIEW__=previousNativeWebView;}/* eslint-enable no-undef */};try{let status=errorCode||(matches.length&&matches[0].match.path==="*"?404:200);res.set({"content-type":"text/html; charset=utf-8"});res.status(status);return new Promise((resolve,reject)=>{const{pipe}=(0,_server3.renderToPipeableStream)(/*#__PURE__*/(0,_jsxRuntime.jsx)(CompleteDocument,{}),{onShellReady(){// Start streaming the HTML shell (everything above Suspense boundaries)
|
|
23
|
-
// as soon as it's ready to minimise TTFB.
|
|
24
|
-
res.setHeader("content-type","text/html");pipe(res);},onAllReady(){// All Suspense boundaries have resolved. Append inline CSS and script
|
|
25
|
-
// tags at the end of the stream so the browser can start executing JS.
|
|
26
|
-
const{firstFoldCss,firstFoldJS}=(0,_extract.cacheAndFetchAssets)({webExtractor,res,isBot});tracedResWriteFirstFoldCss(res,firstFoldCss);tracedResWriteFirstFoldJS(res,firstFoldJS);tracedResEnd(res);cleanupGlobalThis();resolve();},onError(error){logger.error({message:`\n Error while renderToPipeableStream : ${error.toString()}`});// function defined by user which needs to run if rendering fails
|
|
27
|
-
(0,_validator.safeCall)(onRenderError,{req,res,store,error});cleanupGlobalThis();reject(error);}});});}catch(error){logger.error({message:`Error in rendering document on server - ${error}`,trace:error.stack,url:req.originalUrl});// function defined by user which needs to run if rendering fails
|
|
28
|
-
(0,_validator.safeCall)(onRenderError,{req,res,store,error});cleanupGlobalThis();return Promise.reject(error);}};const tracedAppServerSideFunction=(0,_otel.withObservability)(SSR_SERVICE,args=>_index.default.serverSideFunction(args),"App.serverSideFunction");const tracedServerDataFetcher=(0,_otel.withObservability)(SSR_SERVICE,_router.serverDataFetcher,"serverDataFetcher");const tracedRenderMarkUp=(0,_otel.withObservability)(SSR_SERVICE,renderMarkUp,"renderMarkUp");const tracedGetMetaData=(0,_otel.withSyncObservability)(SSR_SERVICE,_router.getMetaData,"getMetaData");/**
|
|
29
|
-
* SSR request handler. Execution pipeline per request:
|
|
30
|
-
* 1. Match route → collect loadable chunks (Phase 1 dry-run)
|
|
31
|
-
* 2. App.serverSideFunction (app-level server hook)
|
|
32
|
-
* 3. serverDataFetcher (route-level data fetching)
|
|
33
|
-
* 4. renderMarkUp → renderToPipeableStream (Phase 2 — real render + stream to client)
|
|
34
|
-
*
|
|
35
|
-
* res.headersSent is checked after each async step: if a user hook (onRouteMatch,
|
|
36
|
-
* onAppServerSideSuccess, etc.) has already sent a response (e.g. a redirect), we
|
|
37
|
-
* bail out early without attempting another render.
|
|
38
|
-
*/async function _handler(req,res){try{let context={};let fetcherData={};const store=(0,_validator.validateConfigureStore)(createStore)?createStore({},req,res):null;const routes=getCachedRoutes();// matches: routes that exactly match this URL — used for serverSideFunction execution.
|
|
39
|
-
// allMatches: full nested match tree — used by getMetaData to collect meta tags.
|
|
40
|
-
const matches=getMatchRoutes(routes,req,res,store,context,fetcherData);const allMatches=(0,_router.matchRoutes)(routes,req.baseUrl);let allTags=[];// Extractor is attached to res.locals inside getMatchRoutes; reused for collectChunks in renderMarkUp
|
|
41
|
-
const webExtractor=res.locals.webExtractor;(0,_validator.safeCall)(onRouteMatch,{req,res,matches,store});if(res.headersSent){return Promise.resolve(res);}try{await tracedAppServerSideFunction({store,req,res});(0,_validator.safeCall)(onAppServerSideSuccess,{req,res,store});if(res.headersSent){return Promise.resolve(res);}try{fetcherData=await tracedServerDataFetcher({routes:routes,req,res,url:req.originalUrl},{store});if(res.headersSent){return Promise.resolve(res);}// Check if serverDataFetcher returned an error in the response
|
|
42
|
-
const err=fetcherData?.[req.originalUrl]?.error;allTags=tracedGetMetaData(allMatches,fetcherData);if(err){(0,_validator.safeCall)(onFetcherError,{req,res,store,error:err});if(res.headersSent){return Promise.reject(err);}// TODO: this seems very dependent on developers error handling, we are assuming they attach status_code key in their errors (same in App.serverSideFunction error)
|
|
43
|
-
const statusCode=err.status_code||404;return new Promise((resolve,reject)=>{tracedRenderMarkUp(statusCode,req,res,allTags,fetcherData,store,matches,context,webExtractor).then(resolve).catch(reject);});}else{// function defined by user which needs to run after SSR functions are executed successfully
|
|
44
|
-
(0,_validator.safeCall)(onFetcherSuccess,{req,res,store});if(res.headersSent){return Promise.resolve(res);}return new Promise((resolve,reject)=>{tracedRenderMarkUp(null,req,res,allTags,fetcherData,store,matches,context,webExtractor).then(resolve).catch(reject);});}}catch(error){// TODO: This catch block is kept for any unexpected errors from serverDataFetcher or getMetaData
|
|
45
|
-
logger.error("Error in executing serverFetcher functions: "+error);(0,_validator.safeCall)(onFetcherError,{req,res,store,error});if(res.headersSent){return Promise.reject(error);}return new Promise((resolve,reject)=>{tracedRenderMarkUp(404,req,res,allTags,fetcherData,store,matches,context,webExtractor).then(resolve).catch(reject);});}}catch(error){logger.error("Error in executing serverSideFunction inside App: "+error);// function defined by user which needs to run after app server side function fails
|
|
46
|
-
(0,_validator.safeCall)(onAppServerSideError,{req,res,store,error});if(res.headersSent){return Promise.reject(error);}return new Promise((resolve,reject)=>{tracedRenderMarkUp(error.status_code,req,res,allTags,fetcherData,store,matches,context,webExtractor).then(resolve).catch(reject);});}}catch(error){logger.error("Error in handling document request: "+error.toString());// function defined by user which needs to run when an error occurs in the handler
|
|
47
|
-
(0,_validator.safeCall)(onRequestError,{req,res,error});return Promise.reject(error);}}const handler=(0,_otel.withObservability)(SSR_SERVICE,_handler,"handler");var _default=exports.default=handler;
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";var _fs=_interopRequireDefault(require("fs"));var _net=_interopRequireDefault(require("net"));var _path=_interopRequireDefault(require("path"));var _nodeUtil=_interopRequireDefault(require("node:util"));var _chokidar=_interopRequireDefault(require("chokidar"));var _picocolors=require("picocolors");var _index=require("@catalyst/template/server/index.js");var _validator=require("@catalyst/server/utils/validator.js");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}/**
|
|
2
|
-
* Entry point for the Catalyst Node.js server process.
|
|
3
|
-
*
|
|
4
|
-
* Dev hot-reload strategy:
|
|
5
|
-
* - loadable-stats.json change → clear require cache (picks up new client chunks)
|
|
6
|
-
* - /server file change → clear require cache + full Express restart
|
|
7
|
-
*
|
|
8
|
-
* EADDRINUSE prevention: restartServer() nulls `serverInstance` before close() so
|
|
9
|
-
* concurrent watcher events only schedule one startServer() on the closing socket.
|
|
10
|
-
*/const env=process.env.NODE_ENV||"development";// Run any app-defined pre-start hook (e.g. seed config, connect to DB)
|
|
11
|
-
(0,_validator.safeCall)(_index.preServerInit);// ─── Process-level error handlers ────────────────────────────────────────────
|
|
12
|
-
process.on("uncaughtException",(err,origin)=>{console.log(process.stderr.fd);console.log(`Caught exception: ${err}\n`+`Exception origin: ${origin}`);});process.on("uncaughtExceptionMonitor",(err,origin)=>{console.log(err,origin);});process.on("unhandledRejection",err=>console.log("unhandledRejection in Catalyst",safeStringify(err)));process.on("SIGINT",function(data){console.log("SIGINT");console.log(data);process.exit(0);});// Parent process can send "shutdown" to trigger a clean exit (used by cluster managers)
|
|
13
|
-
process.on("message",function(msg){if(msg=="shutdown"){console.log("Closing all connections...");setTimeout(function(){console.log("Finished closing connections");process.exit(0);},1500);}});// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
14
|
-
function safeStringify(err){try{return JSON.stringify(err);}catch(e){console.log("error in safeStringify",e);return err;}}// ─── Configuration ────────────────────────────────────────────────────────────
|
|
15
|
-
const port=process.env.NODE_SERVER_PORT??3005;const host=process.env.NODE_SERVER_HOSTNAME??"localhost";// loadable-stats.json is emitted by webpack (@loadable/webpack-plugin) after every
|
|
16
|
-
// successful client-side build. Its presence signals that at least one build has
|
|
17
|
-
// completed and the server can safely start serving SSR responses.
|
|
18
|
-
let statsPath=_path.default.join(__dirname,"../../",`loadable-stats.json`);if(env==="production"){statsPath=_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public/loadable-stats.json`);}// Watcher on loadable-stats.json — used to detect completed webpack rebuilds
|
|
19
|
-
const watcher=_chokidar.default.watch(statsPath,{persistent:true});// Holds the active http.Server instance. Kept at module scope so restartServer()
|
|
20
|
-
// can close the old instance before creating a new one.
|
|
21
|
-
let serverInstance=null;// ─── Cache management ─────────────────────────────────────────────────────────
|
|
22
|
-
/**
|
|
23
|
-
* Purges all app and framework modules from Node's require cache.
|
|
24
|
-
* Called after every webpack rebuild so that the next require("./expressServer")
|
|
25
|
-
* loads the freshly compiled server bundle instead of the stale cached version.
|
|
26
|
-
* node_modules are intentionally left in cache to avoid re-evaluating them on
|
|
27
|
-
* every hot reload.
|
|
28
|
-
*/const clearServerCache=(filePath="")=>{const projectPath=process.env.src_path;Object.keys(require.cache).forEach(key=>{if(key.startsWith(projectPath)||key.includes("catalyst-core")||key.includes(filePath)){delete require.cache[key];}});};// ─── Server lifecycle ─────────────────────────────────────────────────────────
|
|
29
|
-
/**
|
|
30
|
-
* Safely restarts the Express server.
|
|
31
|
-
*
|
|
32
|
-
* Nulls out `serverInstance` before calling close() so that any watcher events
|
|
33
|
-
* that fire concurrently (e.g. an editor writing multiple files on save) hit the
|
|
34
|
-
* `!serverInstance` guard and schedule a single startServer() — rather than each
|
|
35
|
-
* queuing their own close() callback that would all call startServer() once the
|
|
36
|
-
* socket finally closes, causing EADDRINUSE on the second and later attempts.
|
|
37
|
-
*/const restartServer=()=>{if(!serverInstance){startServer();return;}const closing=serverInstance;serverInstance=null;closing.close(()=>startServer());};/**
|
|
38
|
-
* Requires and starts the Express server.
|
|
39
|
-
* expressServer.js is re-required on every call so that, combined with
|
|
40
|
-
* clearServerCache(), hot-reloaded changes are always picked up.
|
|
41
|
-
*/const startServer=()=>{const server=require("./expressServer.js").default;serverInstance=server.listen({port,host},error=>{const{APPLICATION,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;if(error){console.log("An error occured while starting the Application server : ",error);(0,_validator.safeCall)(_index.onServerError);return;}if(env==="development")console.log((0,_picocolors.green)("Compiled successfully!"));console.log(`\nYou can now view ${APPLICATION} in the browser.\n`);console.log(_nodeUtil.default.format("\tLocal:".padEnd(8),(0,_picocolors.cyan)(`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`)));if(env==="development"){console.log("\nNote that the development build is not optimized.");console.log("To create a production build, use "+(0,_picocolors.cyan)("npm run build"));}console.log("\nFind out more about deployment here:");console.log((0,_picocolors.yellow)("\n https://catalyst.1mg.com/public_docs/content/Deployment%20and%20Production/deployment\n"));});};// ─── Port check ───────────────────────────────────────────────────────────────
|
|
42
|
-
/**
|
|
43
|
-
* Verifies the target port is free before we attempt to bind.
|
|
44
|
-
* Probing with a temporary server gives a clear, actionable error message
|
|
45
|
-
* instead of a cryptic EADDRINUSE from Express.
|
|
46
|
-
*/const checkPortAvailability=(port,host)=>{return new Promise((resolve,reject)=>{const tester=_net.default.createServer().once("error",err=>{tester.close(()=>{if(err.code==="EADDRINUSE"){reject(new Error(`Port ${port} is already in use on ${host}. Please free the port or set a different NODE_SERVER_PORT.`));}else{reject(err);}});}).once("listening",()=>{tester.close(()=>resolve());}).listen(port,host);});};// ─── Startup ──────────────────────────────────────────────────────────────────
|
|
47
|
-
checkPortAvailability(port,host).then(()=>{if(process.env.NODE_ENV==="development"){if(_fs.default.existsSync(statsPath)){// loadable-stats.json already exists (e.g. dev server restarted mid-session):
|
|
48
|
-
// start immediately and clear the module cache on every subsequent webpack rebuild
|
|
49
|
-
// so SSR always uses the latest client chunks.
|
|
50
|
-
watcher.on("change",()=>{clearServerCache();});startServer();}else{// First boot — webpack hasn't finished the initial build yet.
|
|
51
|
-
// Wait for loadable-stats.json to be created before starting the server,
|
|
52
|
-
// otherwise @loadable/server would fail trying to read chunk metadata.
|
|
53
|
-
watcher.on("add",()=>{startServer();});}// Watch the app's /server directory for source changes.
|
|
54
|
-
// Any modification, addition, or deletion of a server-side file triggers
|
|
55
|
-
// a full server restart so the new code is loaded via a fresh require().
|
|
56
|
-
const serverPath=_path.default.join(process.env.src_path,"server");const serverWatcher=_chokidar.default.watch(serverPath,{persistent:true,ignoreInitial:true,// Don't trigger on initial scan
|
|
57
|
-
ignored:/node_modules/});serverWatcher.on("change",filePath=>{clearServerCache(filePath);restartServer();});serverWatcher.on("add",()=>restartServer());serverWatcher.on("unlink",()=>restartServer());}else{startServer();}}).catch(err=>{console.error(`\n[Catalyst] Server startup failed: ${err.message}\n`);process.exit(1);});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=removeClientCodePlugin;/**
|
|
2
|
-
* @description babel plugin used to remove unwanted code from the build.
|
|
3
|
-
* @return babel plugin object
|
|
4
|
-
*/function removeClientCodePlugin(){return{name:"ast-transform",// not required
|
|
5
|
-
visitor:{ImportDefaultSpecifier(path){path.parentPath.parent.body=path.parentPath.parent.body.map(astStructure=>{if(astStructure.type==="VariableDeclaration"){if(astStructure.declarations[0]?.init?.type==="ArrowFunctionExpression"&&astStructure.declarations[0]?.init?.body?.body?.length>0){astStructure.declarations[0].init.body.body=astStructure.declarations[0].init.body.body.filter(node=>!(node?.type==="ExpressionStatement"&&node?.expression?.callee?.name==="useEffect"));}}if(astStructure?.type==="FunctionDeclaration"&&astStructure?.body?.body?.length>0){astStructure.body.body=astStructure.body.body.filter(node=>!(node?.type==="ExpressionStatement"&&node?.expression?.callee?.name==="useEffect"));}return astStructure;});}}};}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=removeSsrCodePlugin;/**
|
|
2
|
-
* @description babel plugin used to remove unwanted code from the build.
|
|
3
|
-
* @return babel plugin object
|
|
4
|
-
*/function removeSsrCodePlugin(){return{name:"ast-transform",// not required
|
|
5
|
-
visitor:{ImportDefaultSpecifier(path){path.parentPath.parent.body=path.parentPath.parent.body.filter(val=>val?.expression?.left?.property?.name!=="serverSideFunction"&&val?.expression?.left?.property?.name!=="serverFetcher");}}};}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}const isCompilerEnabled=!!_webpackConfig.default.reactCompiler;const reactCompilerOptions=typeof _webpackConfig.default.reactCompiler==="object"?_webpackConfig.default.reactCompiler:{target:"19"};var _default=exports.default={babelrc:false,presets:[["@babel/preset-typescript",{isTSX:true,allExtensions:true}],["@babel/preset-env",{targets:{browsers:"last 2 versions"}}],["@babel/preset-react",{runtime:"automatic"}]],plugins:[...(isCompilerEnabled?[["babel-plugin-react-compiler",reactCompilerOptions]]:[]),"@loadable/babel-plugin"],env:{production:{plugins:[require("./babel-plugins/remove-ssr.plugin").default]},test:{presets:["@babel/preset-react"]},development:{plugins:["react-refresh/babel"]}},ignore:["__TEST__"]};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}const isCompilerEnabled=!!_webpackConfig.default.reactCompiler;const reactCompilerOptions=typeof _webpackConfig.default.reactCompiler==="object"?_webpackConfig.default.reactCompiler:{target:"19"};var _default=exports.default={babelrc:false,presets:[["@babel/preset-typescript",{isTSX:true,allExtensions:true}],["@babel/preset-env",{targets:{node:"current"}}],["@babel/preset-react",{runtime:"automatic"}]],plugins:[...(isCompilerEnabled?[["babel-plugin-react-compiler",reactCompilerOptions]]:[]),"@loadable/babel-plugin"],env:{development:{plugins:["react-refresh/babel"]},production:{plugins:[require("./babel-plugins/remove-client.plugin").default]}},ignore:["__TEST__"]};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.basePlugins=void 0;var _path=_interopRequireDefault(require("path"));var _webpack=_interopRequireDefault(require("webpack"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _webpackBundleAnalyzer=require("webpack-bundle-analyzer");var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _package=require("@catalyst/template/package.json");var _scssParams=require("@catalyst/webpack/scssParams");var _babelConfig=_interopRequireDefault(require("@catalyst/webpack/babel.config.ssr"));var _babelConfig2=_interopRequireDefault(require("@catalyst/webpack/babel.config.client"));var _loadEnvironmentVariables=_interopRequireDefault(require("@catalyst/scripts/loadEnvironmentVariables"));var _config2=require("@catalyst/template/config/config.json");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}(0,_loadEnvironmentVariables.default)();const isDev=process.env.NODE_ENV==="development";const isSSR=!!process.env.SSR||false;const basePlugins=exports.basePlugins=[// Expose only the whitelisted env vars to the client bundle
|
|
2
|
-
new _webpack.default.DefinePlugin({"process.env":([..._config2.CLIENT_ENV_VARIABLES,"BUILD_OUTPUT_PATH","NODE_ENV","PUBLIC_STATIC_ASSET_PATH","PUBLIC_STATIC_ASSET_URL","src_path","PWD","SENTRY_CONFIG"]||[]).reduce((clientEnvMap,env)=>{clientEnvMap[env]=JSON.stringify(process.env[env]);return clientEnvMap;},{})}),_config2.ANALYZE_BUNDLE&&new _webpackBundleAnalyzer.BundleAnalyzerPlugin({generateStatsFile:_config2.ANALYZE_BUNDLE}),new _webpack.default.IgnorePlugin({resourceRegExp:/^\.\/locale$/,contextRegExp:/moment$/})];const{IS_DEV_COMMAND,PUBLIC_STATIC_ASSET_URL,PUBLIC_STATIC_ASSET_PATH,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;let publicPath=isDev?`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/`:`${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;// serves assets from local on running devBuild and devServe command
|
|
3
|
-
if(IS_DEV_COMMAND==="true"&&!isDev){publicPath=`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/assets/`;}var _default=exports.default={context:_path.default.resolve(process.env.src_path),mode:isDev?"development":"production",// Use filesystem cache to reduce memory pressure and improve rebuild performance
|
|
4
|
-
cache:isDev?{type:"filesystem",buildDependencies:{config:[__filename]},cacheDirectory:_path.default.join(process.env.src_path,"node_modules/catalyst-core/.cache/webpack")}:false,entry:{app:[_path.default.resolve(process.env.src_path,"./client/index.js")]},output:{path:_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`),filename:process.env.NODE_ENV==="development"?"[name].bundle.js":"[name].[contenthash].js",chunkFilename:process.env.NODE_ENV==="development"?"[name].bundle.js":"[name].[contenthash].js",publicPath:publicPath},resolve:{fallback:{url:require.resolve("url")},extensions:[".js",".jsx",".scss",".ts",".tsx"],alias:Object.keys(_package._moduleAliases||{}).reduce((moduleEnvMap,alias)=>{// nosemgrep
|
|
5
|
-
moduleEnvMap[alias]=_path.default.join(process.env.src_path,..._package._moduleAliases[alias].split("/"));return moduleEnvMap;},{})},plugins:basePlugins,module:{rules:[{test:/\.jsx$|\.js$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig.default:_babelConfig2.default}},{test:/\.tsx$|\.ts$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig.default:_babelConfig2.default}},{// CSS Modules for component-scoped styles; excludes node_modules and global base styles
|
|
6
|
-
test:/\.scss$/,exclude:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader",options:{modules:{mode:"local",exportOnlyLocals:!isDev&&isSSR,localIdentName:isDev?_config.default.cssModulesIdentifierDev:_config.default.cssModulesIdentifierProd}}},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{// Global styles (node_modules + base CSS): not modularized, served by dev-server in dev / inlined by server in prod
|
|
7
|
-
test:/\.scss$/,include:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader"},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{test:/\.css$/,use:[!isSSR&&_miniCssExtractPlugin.default.loader,"css-loader","postcss-loader"]},{test:/\.(png|jpg|gif|jpeg|ico?)$/,use:["url-loader?limit=10240","img-loader"]},{test:/\.svg$/i,issuer:/\.[jt]sx?$/,use:["@svgr/webpack","url-loader?limit=10240","img-loader"]},{test:/\.(ttf|eot|woff2?)$/,use:[{loader:"url-loader",options:{limit:10240,outputPath:[_path.default.resolve(process.env.src_path,"./src/static/fonts/")]}},"file-loader"]},{test:/\.html$/,use:[{loader:"html-loader",options:{minimize:{minifyJS:true,minifyCSS:true,removeComments:false,collapseWhitespace:true}}}]}]}};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";var _net=_interopRequireDefault(require("net"));var _webpack=_interopRequireDefault(require("webpack"));var _webpackMerge=_interopRequireDefault(require("webpack-merge"));var _webpackDevServer=_interopRequireDefault(require("webpack-dev-server"));var _webpackPlugin=_interopRequireDefault(require("@loadable/webpack-plugin"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _reactRefreshWebpackPlugin=_interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));var _path=_interopRequireDefault(require("path"));var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _baseBabel=_interopRequireDefault(require("@catalyst/webpack/base.babel.js"));var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}const{WEBPACK_DEV_SERVER_PORT,WEBPACK_DEV_SERVER_HOSTNAME}=process.env;const webpackClientConfig=(0,_webpackMerge.default)(_baseBabel.default,{// eval-cheap-module-source-map: faster rebuilds and lower memory than inline-source-map
|
|
2
|
-
devtool:"inline-source-map",stats:"none",infrastructureLogging:{level:"none"},plugins:[// writeToDisk is required because the Node server runs in a separate process
|
|
3
|
-
// and cannot access webpack's in-memory filesystem to read loadable-stats.json.
|
|
4
|
-
new _webpackPlugin.default({filename:"loadable-stats.json",writeToDisk:{filename:_path.default.join(__dirname,"../..")}}),new _reactRefreshWebpackPlugin.default({overlay:{entry:false}}),new _miniCssExtractPlugin.default({filename:_config.default.cssChunkFileName,ignoreOrder:true}),..._webpackConfig.default.developmentPlugins].filter(Boolean),optimization:{runtimeChunk:"single",moduleIds:"deterministic",splitChunks:_webpackConfig.default.splitChunksConfig?_webpackConfig.default.splitChunksConfig:{cacheGroups:{commonVendor:{test:/[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,name:"commonVendor",minSize:30000},utilityVendor:{maxInitialRequests:Infinity,chunks:"all",// minSize: 0, // Enable to replicate stand alone chunking for all packages
|
|
5
|
-
reuseExistingChunk:true,// Disable to replicate stand alone chunking for all packages
|
|
6
|
-
minRemainingSize:1000,// Disable to replicate stand alone chunking for all packages
|
|
7
|
-
test:/[\\/]node_modules[\\/]/,name(module){const moduleFileName=module.identifier().split("node_modules")?.[1]?.split("/").reverse().slice(0,3).reduce((item,current)=>{item=current+"."+item;return item;},[]);return`npm.${moduleFileName}`;}}}}}});// SSR compiler runs in a separate process; this process handles client-side HMR only
|
|
8
|
-
let devServer=new _webpackDevServer.default({port:WEBPACK_DEV_SERVER_PORT,host:WEBPACK_DEV_SERVER_HOSTNAME,static:{publicPath:webpackClientConfig.output.publicPath},hot:true,historyApiFallback:true,headers:{"Access-Control-Allow-Origin":"*"},client:{logging:"error",overlay:{errors:false,warnings:false,runtimeErrors:false},reconnect:true}},(0,_webpack.default)(webpackClientConfig));const checkPortAvailability=(port,host)=>{return new Promise((resolve,reject)=>{const tester=_net.default.createServer().once("error",err=>{tester.close(()=>{if(err.code==="EADDRINUSE"){reject(new Error(`Port ${port} is already in use on ${host}. Please free the port or set a different WEBPACK_DEV_SERVER_PORT.`));}else{reject(err);}});}).once("listening",()=>{tester.close(()=>resolve());}).listen(port,host);});};checkPortAvailability(WEBPACK_DEV_SERVER_PORT,WEBPACK_DEV_SERVER_HOSTNAME).then(()=>{devServer.start().then(()=>{console.log("Catalyst is compiling your files.");console.log("Please wait until bundling is finished.\n");}).catch(err=>{console.error("Failed to start webpack-dev-server:",err);process.exit(1);});}).catch(err=>{console.error(`\n[Catalyst] Dev server startup failed: ${err.message}\n`);process.exit(1);});const cleanup=()=>{console.log("[Client] Shutting down client dev server...");devServer.stop().then(()=>{process.exit();});};// Handle various ways the process might exit
|
|
9
|
-
process.on("SIGINT",cleanup);// Ctrl+C
|
|
10
|
-
process.on("SIGTERM",cleanup);// kill
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _registerAliases2=require("../scripts/registerAliases.js");require("../scripts/loadScriptsBeforeServerStarts.js");var _path=_interopRequireDefault(require("path"));var _webpackPlugin=_interopRequireDefault(require("@loadable/webpack-plugin"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _webpackMerge=require("webpack-merge");var _base=_interopRequireDefault(require("@catalyst/webpack/base.babel"));var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}/* eslint-disable */const clientConfig=(0,_webpackMerge.mergeWithCustomize)({customizeArray:(0,_webpackMerge.customizeArray)({entry:"prepend",plugins:"append",module:"prepend"}),customizeObject:(0,_webpackMerge.customizeObject)({entry:"prepend",plugins:"append",module:"prepend"})})(_base.default,{mode:"production",devtool:"source-map",stats:"errors-only",resolve:{alias:_registerAliases2.catalystResultMap},optimization:{runtimeChunk:"single",moduleIds:"deterministic",splitChunks:_webpackConfig.default.splitChunksConfig?_webpackConfig.default.splitChunksConfig:{cacheGroups:{commonVendor:{chunks:"all",test:/[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,name:"commonVendor",minSize:400000,maxSize:400000},utilityVendor:{maxInitialRequests:Infinity,chunks:"all",// minSize: 0, // Enable to replicate stand alone chunking for all packages
|
|
2
|
-
reuseExistingChunk:true,// Disable to replicate stand alone chunking for all packages
|
|
3
|
-
minRemainingSize:1000,// Disable to replicate stand alone chunking for all packages
|
|
4
|
-
minSize:1000,maxSize:120000,test:/[\\/]node_modules[\\/]/,name(module){const moduleFileName=module.identifier().split("/").reverse().slice(0,3).reduce((item,current)=>{item=current+"."+item;return item;},[]);return`npm.${moduleFileName}`;}}},chunks:"all",name(module){const moduleFileName=module.identifier().split("/").reverse().slice(0,3).reduce((item,current)=>{item=current+"."+item;return item;},[]);return`npm.${moduleFileName}`;}}},plugins:[new _webpackPlugin.default({filename:"loadable-stats.json",writeToDisk:{filename:_path.default.join(__dirname,"../..")}}),new _miniCssExtractPlugin.default({filename:_config.default.cssChunkFileName,ignoreOrder:true}),..._webpackConfig.default.clientPlugins]});var _default=exports.default=clientConfig;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _registerAliases2=require("../scripts/registerAliases.js");require("../scripts/loadScriptsBeforeServerStarts.js");var _path=_interopRequireDefault(require("path"));var _webpackNodeExternals=_interopRequireDefault(require("webpack-node-externals"));var _webpackPlugin=_interopRequireDefault(require("@loadable/webpack-plugin"));var _appRootPath=_interopRequireDefault(require("app-root-path"));var _base=_interopRequireDefault(require("@catalyst/webpack/base.babel"));var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}/* eslint-disable */const{mergeWithCustomize,customizeArray,customizeObject}=require("webpack-merge");const ssrConfig=mergeWithCustomize({customizeArray:customizeArray({entry:"replace",optimization:"replace",plugins:"prepend"}),customizeObject:customizeObject({entry:"replace",optimization:"replace",plugins:"prepend"})})(_base.default,{mode:"production",stats:"errors-only",optimization:{splitChunks:{chunks:"all",minSize:10000000,name:false}},resolve:{alias:_registerAliases2.catalystResultMap},plugins:[..._webpackConfig.default.ssrPlugins,new _webpackPlugin.default({filename:"loadable-stats.json",writeToDisk:{filename:_path.default.join(__dirname,"../..")}})],target:"node",entry:{handler:_path.default.resolve(__dirname,"..","./server/renderer/handler.js")},externals:[// images are handled by isomorphic webpack.
|
|
2
|
-
// html files are required directly
|
|
3
|
-
/\.(html|png|gif|jpg)$/,// OpenTelemetry is an opt-in peer dependency that may not be installed.
|
|
4
|
-
// Always treat it (and @grpc/grpc-js, pulled in by the gRPC exporters) as
|
|
5
|
-
// external so the build never tries to resolve it; the lazy import() in
|
|
6
|
-
// src/otel.js then only requires it at runtime when OTEL_ENABLE=true.
|
|
7
|
-
/^@opentelemetry\//,"@grpc/grpc-js",// treat all node modules as external to keep this bundle small
|
|
8
|
-
(0,_webpackNodeExternals.default)({modulesDir:_path.default.resolve(process.env.src_path,"./node_modules"),allowlist:_webpackConfig.default.transpileModules?_webpackConfig.default.transpileModules:[]}),(0,_webpackNodeExternals.default)({modulesDir:_path.default.join(_appRootPath.default.path,"./node_modules"),allowlist:_webpackConfig.default.transpileModules?_webpackConfig.default.transpileModules:[]})],output:{path:_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH,"/renderer"),chunkFilename:_config.default.chunkFileNameProd,filename:"handler.js",libraryTarget:"commonjs"}});var _default=exports.default=ssrConfig;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.imageUrl=exports.fontUrl=void 0;/**
|
|
2
|
-
* @description generate assets url according to enviorment
|
|
3
|
-
* @returns returns path required for loading assets according to enviorment
|
|
4
|
-
*/const imageUrl=()=>{const{PUBLIC_STATIC_ASSET_URL,PUBLIC_STATIC_ASSET_PATH,IS_DEV_COMMAND,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;let publicPath=`${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;// serves assets from localhost on running devBuild and devServe command
|
|
5
|
-
if(IS_DEV_COMMAND==="true"){publicPath=`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/${PUBLIC_STATIC_ASSET_PATH}`;}const imagePath=JSON.stringify(`${publicPath}images/`);return imagePath;};/**
|
|
6
|
-
* @description generate assets font url according to enviorment
|
|
7
|
-
* @returns returns path required for loading fonts according to enviorment
|
|
8
|
-
*/exports.imageUrl=imageUrl;const fontUrl=()=>{const{PUBLIC_STATIC_ASSET_URL,PUBLIC_STATIC_ASSET_PATH,IS_DEV_COMMAND,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;let publicPath=`${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;// serves assets from localhost on running devBuild and devServe command
|
|
9
|
-
if(IS_DEV_COMMAND==="true"){publicPath=`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/${PUBLIC_STATIC_ASSET_PATH}`;}const fontPath=JSON.stringify(`${publicPath}fonts/`);return fontPath;};exports.fontUrl=fontUrl;
|