catalyst-core 0.2.0-beta.2 → 0.3.0-beta.1

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 (184) hide show
  1. package/babel.native.config.cjs +8 -0
  2. package/bin/catalyst.js +49 -105
  3. package/changelog.md +8 -0
  4. package/dist/caching.js +1 -1
  5. package/dist/index.jsx +8 -0
  6. package/dist/logger.js +74 -3
  7. package/dist/native/androidProject/app/build.gradle.kts +1 -0
  8. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/CustomWebview.kt +143 -4
  9. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/MainActivity.kt +26 -6
  10. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/MetricsMonitor.kt +143 -17
  11. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/NativeBridge.kt +6 -0
  12. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/WebCacheManager.kt +26 -0
  13. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/BridgeUtils.kt +56 -1
  14. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/KeyboardUtil.kt +48 -8
  15. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/PerfDeliveryState.kt +36 -0
  16. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/PerfEventBuffer.kt +289 -0
  17. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/ProfilerNavigationState.kt +13 -0
  18. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/ProfilerLifecycleTest.kt +51 -0
  19. package/dist/native/androidSetup.js +300 -8
  20. package/dist/native/bridge/WebBridge.js +481 -59
  21. package/dist/native/bridge/constants/NativeInterfaces.js +290 -44
  22. package/dist/native/bridge/errors.js +250 -26
  23. package/dist/native/bridge/hooks/index.js +125 -1
  24. package/dist/native/bridge/hooks/useCamera.js +347 -9
  25. package/dist/native/bridge/hooks/useDataProtection.js +200 -2
  26. package/dist/native/bridge/hooks/useDeviceInfo.js +71 -2
  27. package/dist/native/bridge/hooks/useFilePicker.js +429 -2
  28. package/dist/native/bridge/hooks/useGoogleSignIn.js +81 -1
  29. package/dist/native/bridge/hooks/useHapticFeedback.js +196 -1
  30. package/dist/native/bridge/hooks/useIntent.js +95 -1
  31. package/dist/native/bridge/hooks/useNativeTransition.js +202 -27
  32. package/dist/native/bridge/hooks/useNetworkStatus.js +84 -3
  33. package/dist/native/bridge/hooks/useNotification.js +318 -2
  34. package/dist/native/bridge/hooks/useSafeArea.js +84 -2
  35. package/dist/native/bridge/hooks/useVideoStream.js +434 -6
  36. package/dist/native/bridge/hooks/utils.js +27 -1
  37. package/dist/native/bridge/hooks.js +16 -1
  38. package/dist/native/bridge/perf/collectors/ApiCollector.js +85 -0
  39. package/dist/native/bridge/perf/collectors/CacheCollector.js +215 -0
  40. package/dist/native/bridge/perf/collectors/HookCollector.js +165 -0
  41. package/dist/native/bridge/perf/collectors/InsightsCollector.js +505 -0
  42. package/dist/native/bridge/perf/collectors/InteractionCollector.js +273 -0
  43. package/dist/native/bridge/perf/collectors/KeyboardCollector.js +124 -0
  44. package/dist/native/bridge/perf/collectors/NavigationCollector.js +294 -0
  45. package/dist/native/bridge/perf/collectors/NetworkTimingCollector.js +183 -0
  46. package/dist/native/bridge/perf/collectors/RenderCollector.js +284 -0
  47. package/dist/native/bridge/perf/collectors/ScrollCollector.js +111 -0
  48. package/dist/native/bridge/perf/collectors/ThreadCollector.js +111 -0
  49. package/dist/native/bridge/perf/core/constants.js +126 -0
  50. package/dist/native/bridge/perf/core/measure.js +189 -0
  51. package/dist/native/bridge/perf/core/session.js +100 -0
  52. package/dist/native/bridge/perf/core/store.js +554 -0
  53. package/dist/native/bridge/perf/core/summary.js +174 -0
  54. package/dist/native/bridge/perf/core/traceExport.js +240 -0
  55. package/dist/native/bridge/perf/core/waterfalls.js +146 -0
  56. package/dist/native/bridge/perf/index.js +402 -0
  57. package/dist/native/bridge/safeArea.js +53 -5
  58. package/dist/native/bridge/standardizedHooks.js +595 -82
  59. package/dist/native/bridge/useBaseHook.js +274 -38
  60. package/dist/native/bridge/utils/CameraUtils.js +201 -56
  61. package/dist/native/bridge/utils/FileObjectConverter.js +129 -18
  62. package/dist/native/bridge/utils/NativeBridge.js +425 -141
  63. package/dist/native/buildAndroid/assets.js +510 -13
  64. package/dist/native/buildAndroid/build.js +296 -19
  65. package/dist/native/buildAndroid/config.js +87 -1
  66. package/dist/native/buildAndroid/index.js +374 -1
  67. package/dist/native/buildAppAndroid.js +34 -2
  68. package/dist/native/buildAppIos.js +62 -2
  69. package/dist/native/buildIos/assets.js +609 -8
  70. package/dist/native/buildIos/build.js +639 -20
  71. package/dist/native/buildIos/config.js +294 -12
  72. package/dist/native/buildIos/index.js +343 -6
  73. package/dist/native/buildIos/plugins.js +343 -16
  74. package/dist/native/internal-plugins/device-info-plugin/android/DeviceInfoPlugin.kt +43 -0
  75. package/dist/native/internal-plugins/device-info-plugin/ios/DeviceInfoPlugin.swift +28 -0
  76. package/dist/native/internal-plugins/device-info-plugin/manifest.json +19 -0
  77. package/dist/native/internalPluginUtils.js +232 -7
  78. package/dist/native/iosnativeWebView/Sources/Core/Constants/CatalystConstants.swift +19 -0
  79. package/dist/native/iosnativeWebView/Sources/Core/Constants/ConfigConstants.swift +4 -0
  80. package/dist/native/iosnativeWebView/Sources/Core/Utils/BootTimingUtility.swift +5 -1
  81. package/dist/native/iosnativeWebView/Sources/Core/Utils/CacheManager.swift +10 -0
  82. package/dist/native/iosnativeWebView/Sources/Core/Utils/DisplayLinkPerfMonitor.swift +89 -0
  83. package/dist/native/iosnativeWebView/Sources/Core/Utils/PerfEventBuffer.swift +373 -0
  84. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeFileHandler.swift +35 -1
  85. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeMessageValidator.swift +24 -11
  86. package/dist/native/iosnativeWebView/Sources/Core/WebView/NativeBridge.swift +9 -0
  87. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebView.swift +126 -0
  88. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebViewNavigationDelegate.swift +75 -1
  89. package/dist/native/iosnativeWebView/iosnativeWebViewTests/BridgeMessageValidatorTests.swift +13 -0
  90. package/dist/native/package.json +3 -0
  91. package/dist/native/plugin-bridge/PluginBridge.js +227 -1
  92. package/dist/native/pluginComposerAndroid.js +407 -23
  93. package/dist/native/pluginComposerIos.js +435 -11
  94. package/dist/native/renameAndroidProject.js +1094 -88
  95. package/dist/native/setupEmulatorIos.js +289 -22
  96. package/dist/native/setupServer.js +160 -19
  97. package/dist/native/terminalProgress.js +199 -11
  98. package/dist/native/utils.js +193 -15
  99. package/dist/offline/catalyst-sw.js +145 -1
  100. package/dist/offline/registerServiceWorker.js +33 -1
  101. package/dist/otel.js +375 -46
  102. package/dist/router/ClientRouter.js +14 -2
  103. package/dist/router/ServerRouter.js +9 -1
  104. package/dist/router.js +1 -1
  105. package/dist/scripts/build.js +112 -3
  106. package/dist/scripts/checkVersion.js +3 -1
  107. package/dist/scripts/cleanCache.js +30 -1
  108. package/dist/scripts/generateOfflineManifest.js +116 -1
  109. package/dist/scripts/loadEnvironmentVariables.js +32 -6
  110. package/dist/scripts/plugins.js +309 -1
  111. package/dist/scripts/preServerInit.js +13 -0
  112. package/dist/scripts/scriptUtils.js +54 -3
  113. package/dist/scripts/serve.js +51 -4
  114. package/dist/scripts/start.js +47 -10
  115. package/dist/scripts/validator.js +149 -1
  116. package/dist/sentry.cjs +127 -0
  117. package/dist/sentry.js +125 -5
  118. package/dist/server/expressServer.js +250 -5
  119. package/dist/server/manifestCache.js +36 -0
  120. package/dist/server/renderer/ChunkExtractor.js +144 -0
  121. package/dist/server/renderer/document/Body.jsx +59 -0
  122. package/dist/server/renderer/document/FastRefresh.jsx +20 -0
  123. package/dist/server/renderer/document/Head.jsx +60 -0
  124. package/dist/server/renderer/document/index.jsx +2 -0
  125. package/dist/server/renderer/extract.js +149 -31
  126. package/dist/server/renderer/handler.jsx +433 -0
  127. package/dist/server/renderer/index.js +8 -1
  128. package/dist/server/renderer/render.js +47 -0
  129. package/dist/server/utils/botDetectionMiddleware.js +29 -0
  130. package/dist/server/utils/cjsRequire.js +10 -0
  131. package/dist/server/utils/userAgentUtil.js +87 -9
  132. package/dist/server/utils/validator.js +164 -1
  133. package/dist/vite/FastRefresh.jsx +20 -0
  134. package/dist/vite/inject-cache-key-plugin.js +276 -0
  135. package/dist/vite/loadCustomViteConfig.js +22 -0
  136. package/dist/vite/manifest-categorization-plugin.js +455 -0
  137. package/dist/vite/node-loader.mjs +458 -0
  138. package/dist/vite/scssParams.js +21 -0
  139. package/dist/vite/vite.config.client.js +130 -0
  140. package/dist/vite/vite.config.js +422 -0
  141. package/dist/vite/vite.config.server.js +84 -0
  142. package/dist/web-router/components/MetaTag.jsx +34 -0
  143. package/dist/web-router/components/RouterDataProvider.jsx +332 -0
  144. package/dist/web-router/components/Split.jsx +200 -0
  145. package/dist/web-router/components/SplitInview.jsx +106 -0
  146. package/dist/web-router/components/SsrRequestContext.jsx +14 -0
  147. package/dist/web-router/context.jsx +12 -0
  148. package/dist/web-router/hooks.jsx +72 -0
  149. package/dist/web-router/types/components/MetaTag.d.ts +2 -0
  150. package/dist/web-router/types/components/RouterDataProvider.d.ts +95 -0
  151. package/dist/web-router/types/context.d.ts +14 -0
  152. package/dist/web-router/types/hooks.d.ts +1 -0
  153. package/dist/web-router/types/index.d.ts +3 -0
  154. package/dist/web-router/types/utils/metaDataUtils.d.ts +24 -0
  155. package/dist/web-router/utils/metaDataUtils.jsx +119 -0
  156. package/mcp_v2/conversion-tasks.json +35 -17
  157. package/mcp_v2/knowledge-base.json +124 -13
  158. package/mcp_v2/lib/helpers.js +10 -0
  159. package/mcp_v2/mcp.js +4 -4
  160. package/mcp_v2/package.json +1 -0
  161. package/mcp_v2/tools/build.js +116 -20
  162. package/mcp_v2/tools/conversion.js +106 -5
  163. package/mcp_v2/tools/tasks.js +18 -14
  164. package/package.json +35 -68
  165. package/babel.config.js +0 -32
  166. package/dist/index.js +0 -1
  167. package/dist/scripts/devBuild.js +0 -3
  168. package/dist/scripts/devServe.js +0 -3
  169. package/dist/scripts/loadScriptsBeforeServerStarts.js +0 -4
  170. package/dist/scripts/registerAliases.js +0 -6
  171. package/dist/server/renderer/document/Body.js +0 -11
  172. package/dist/server/renderer/document/Head.js +0 -9
  173. package/dist/server/renderer/document/index.js +0 -1
  174. package/dist/server/renderer/handler.js +0 -47
  175. package/dist/server/startServer.js +0 -57
  176. package/dist/webpack/babel-plugins/remove-client.plugin.js +0 -5
  177. package/dist/webpack/babel-plugins/remove-ssr.plugin.js +0 -5
  178. package/dist/webpack/babel.config.client.js +0 -1
  179. package/dist/webpack/babel.config.ssr.js +0 -1
  180. package/dist/webpack/base.babel.js +0 -7
  181. package/dist/webpack/development.client.babel.js +0 -10
  182. package/dist/webpack/production.client.babel.js +0 -4
  183. package/dist/webpack/production.ssr.babel.js +0 -8
  184. package/dist/webpack/scssParams.js +0 -9
@@ -0,0 +1,72 @@
1
+ import { useNavigate, useLocation } from "react-router-dom"
2
+
3
+ /**
4
+ * @param {number} delay
5
+ */
6
+ function wait(delay) {
7
+ return new Promise((resolve) => {
8
+ setTimeout(resolve, delay)
9
+ })
10
+ }
11
+
12
+ // function navigationDirection(param) {
13
+ // if (typeof param === "string") {
14
+ // return "forward-navigation"
15
+ // } else if (typeof param === "number") {
16
+ // return param < 0 ? "backward-navigation" : param > 0 ? "forward-navigation" : "Same_page_navigation"
17
+ // } else {
18
+ // return "Invalid_param"
19
+ // }
20
+ // }
21
+
22
+ // export function useNavigateWithTransition() {
23
+ // const navigate = useNavigate()
24
+ // const { setIsExitComplete, updateScrollPosition } = useScrollRestorationContext()
25
+ // const location = useLocation()
26
+ // function transition(route, options = {}) {
27
+ // if (document.startViewTransition && options.skipTransition) {
28
+ // const directionForNavigation = navigationDirection(route)
29
+ // //decide whether to use backward transition or forward transition or no transition in case route is 0
30
+ // if (directionForNavigation === "Same_page_navigation") {
31
+ // navigate(route, options)
32
+ // return
33
+ // }
34
+ // //select the root element and give it the viewTransitionNameb by the directionForNavigation
35
+ // const rootElementRef = document.querySelector(":root")
36
+ // rootElementRef.style.viewTransitionName = directionForNavigation
37
+
38
+ // const viewTransition = document.startViewTransition(async function updateCallback() {
39
+ // // Update scroll position for the current route
40
+ // updateScrollPosition(location.key, parseInt(window.scrollY, 10))
41
+ // delete options.skipTransition
42
+ // navigate(route, options)
43
+ // await wait(50)
44
+ // })
45
+
46
+ // // A Promise that fulfills once the pseudo-element tree is created and the transition animation is about to start.
47
+ // viewTransition.ready.then(() => {
48
+ // if (directionForNavigation === "backward-navigation") {
49
+ // setIsExitComplete(true)
50
+ // } else {
51
+ // window.scrollTo({ top: 0, left: 0, behavior: "auto" })
52
+ // }
53
+ // })
54
+
55
+ // //A Promise that fulfills once the transition animation is finished, and the new page view is visible and interactive to the user.
56
+ // viewTransition.finished.finally(() => {
57
+ // // Clear the temporary tag
58
+ // if (rootElementRef) rootElementRef.style.viewTransitionName = ""
59
+ // })
60
+ // } else {
61
+ // // fallback for old browser
62
+ // delete options.skipTransition
63
+ // navigate(route, options)
64
+ // }
65
+ // }
66
+
67
+ // return transition
68
+ // }
69
+
70
+ export const useNavigateWithTransition = () => {
71
+ return useNavigate()
72
+ }
@@ -0,0 +1,2 @@
1
+ export function MetaTag(): React.JSX.Element
2
+ import React from "react"
@@ -0,0 +1,95 @@
1
+ /**
2
+ * @description Router Data
3
+ * @typedef {{data: any, error: any, isFetching: boolean, isFetched:boolean, refetch?:(args:any)=>Promise<void>}} RouteData
4
+ */
5
+ /**
6
+ * @type {import("react").Context<Object.<string, RouteData>>}
7
+ */
8
+ export const RouterContext: import("react").Context<{
9
+ [x: string]: RouteData
10
+ }>
11
+ export function serverDataFetcher(
12
+ serverFetchDataProps: ServerFetchDataProps,
13
+ fetcherArgs: {
14
+ [x: string]: any
15
+ }
16
+ ): Promise<{
17
+ [x: string]: RouteData
18
+ }>
19
+ export function RouterDataProvider({
20
+ children,
21
+ initialState,
22
+ fetcherArgs,
23
+ config,
24
+ }: RouterDataProviderProps): React.JSX.Element
25
+ export function useCurrentRouteData(): RouteData
26
+ export function useRouterData(): {
27
+ [x: string]: RouteData
28
+ }
29
+ export type RouteData = {
30
+ data: any
31
+ error: any
32
+ isFetching: boolean
33
+ isFetched: boolean
34
+ refetch?: (args: any) => Promise<void>
35
+ }
36
+ export type RouterDataProviderConfig = {
37
+ /**
38
+ * disableCaching disable caching of fetched data - default is false
39
+ */
40
+ disableCaching?: boolean | undefined
41
+ }
42
+ export type RouterFetcherProps = {
43
+ /**
44
+ * route object
45
+ */
46
+ route: any
47
+ /**
48
+ * the current location object, which represents the current URL in web browsers.
49
+ */
50
+ location: import("react-router-dom").Location
51
+ /**
52
+ * object of key/value pairs of the dynamic params from the current URL that were matched by the route path.
53
+ */
54
+ params: import("react-router-dom").Params
55
+ /**
56
+ * search parameters via URLSearchParams interface.
57
+ */
58
+ searchParams: URLSearchParams
59
+ /**
60
+ * function to navigate to other pages based on response.
61
+ */
62
+ navigate: import("react-router-dom").NavigateFunction
63
+ }
64
+ export type ServerFetchDataProps = {
65
+ /**
66
+ * routes Array
67
+ */
68
+ routes: import("react-router-dom").RouteObject[]
69
+ /**
70
+ * current url
71
+ */
72
+ url: string
73
+ /**
74
+ * Express request object
75
+ */
76
+ req: import("express").Request
77
+ }
78
+ export type RouterDataProviderProps = {
79
+ /**
80
+ * Initial State of Data Provider - Mostly used to hydrate client with data from server
81
+ */
82
+ initialState: any
83
+ children: any
84
+ /**
85
+ * anything passed in fetcherArgs is passed to all the fetcher functions
86
+ */
87
+ fetcherArgs: {
88
+ [x: string]: any
89
+ }
90
+ /**
91
+ * Global router data provider config
92
+ */
93
+ config: RouterDataProviderConfig
94
+ }
95
+ import React from "react"
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @typedef oneMgRouterContext
3
+ * @property {import("react-router-dom").RouteMatch<string, import("react-router-dom").RouteObject>[]=} matchedRoutes
4
+ */
5
+ /**
6
+ * @description This is internal context made for sharing data among router components
7
+ * @type {import("react").Context<oneMgRouterContext>}
8
+ */
9
+ export const OneMgRouterContext: import("react").Context<oneMgRouterContext>
10
+ export type oneMgRouterContext = {
11
+ matchedRoutes?:
12
+ | import("react-router-dom").RouteMatch<string, import("react-router-dom").RouteObject>[]
13
+ | undefined
14
+ }
@@ -0,0 +1 @@
1
+ export function useNavigateWithTransition(): import("react-router-dom").NavigateFunction
@@ -0,0 +1,3 @@
1
+ export * from "react-router-dom"
2
+ declare const _default: any
3
+ export default _default
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Merges multiple lists of head elements, ensuring that later lists override earlier ones in case of duplicates.
3
+ * Handles all types of head elements, including title, meta, link, etc.
4
+ *
5
+ * @param {...Array<JSX.Element>} lists - Multiple lists of JSX head elements, where the first argument is the parent and the rest are children in order.
6
+ * @returns {Array<JSX.Element>} - The combined list with later lists overriding duplicates from earlier ones.
7
+ */
8
+ export function mergeHeadElements(...lists: Array<JSX.Element>[]): Array<JSX.Element>
9
+ /**
10
+ * Deletes all elements in the head with a specific data attribute.
11
+ *
12
+ * @param {string} attributeName - The name of the data attribute to search for.
13
+ * @param {string} [attributeValue] - The specific value of the data attribute to match (optional).
14
+ */
15
+ export function deleteHeadTagsByDataAttribute(attributeName: string, attributeValue?: string): void
16
+ /**
17
+ * Returns resolved array of meta data elements.
18
+ *
19
+ *
20
+ * @param {Array<Match>} matchedRoutes - Array of all matches.
21
+ * @param {Object} routeData - Data returned from Router.
22
+ * @returns {Array<JSX.Element>} - List of all meta tags for the matched location.
23
+ */
24
+ export function getMetaData(matchedRoutes: Array<Match>, routeData: Object): Array<JSX.Element>
@@ -0,0 +1,119 @@
1
+ import React from "react"
2
+ /**
3
+ * Merges multiple lists of head elements, ensuring that later lists override earlier ones in case of duplicates.
4
+ * Handles all types of head elements, including title, meta, link, etc.
5
+ *
6
+ * @param {...Array<JSX.Element>} lists - Multiple lists of JSX head elements, where the first argument is the parent and the rest are children in order.
7
+ * @returns {Array<JSX.Element>} - The combined list with later lists overriding duplicates from earlier ones.
8
+ */
9
+ export function mergeHeadElements(...lists) {
10
+ const elementMap = new Map()
11
+
12
+ /**
13
+ * Function to get a unique key for a head element based on its type and attributes.
14
+ * @param {JSX.Element} element - The head element from which to derive a key.
15
+ * @returns {string} - A unique key representing the element.
16
+ */
17
+ const getKey = (element) => {
18
+ const { type, props } = element
19
+
20
+ if (type === "title") {
21
+ return "title" // Only one title should exist in a document
22
+ }
23
+
24
+ // For meta tags, use 'name' or 'property' as unique identifiers
25
+ if (type === "meta") {
26
+ if (props.charset) {
27
+ return "charset" // Charset should be unique in a document
28
+ }
29
+ return props.name || props.property || props["http-equiv"] || props.httpEquiv || ""
30
+ }
31
+
32
+ // For link tags, use 'rel' as a unique identifier
33
+ // if (type === "link") {
34
+ // return props.rel || "";
35
+ // }
36
+
37
+ // Create a unique representation for other types of elements
38
+ return `${type}:${Object.entries(props)
39
+ .map(([key, value]) => `${key}=${value}`)
40
+ .join(",")}`
41
+ }
42
+
43
+ // Loop through all the lists, ensuring later lists override earlier ones
44
+ lists?.forEach((list) => {
45
+ list?.forEach((element) => {
46
+ const key = getKey(element)
47
+ if (key) {
48
+ elementMap.set(key, element) // Overwrite earlier elements with later ones
49
+ }
50
+ })
51
+ })
52
+
53
+ // Return the combined list of head elements
54
+ return Array.from(elementMap.values())
55
+ }
56
+
57
+ /**
58
+ * Deletes all elements in the head with a specific data attribute.
59
+ *
60
+ * @param {string} attributeName - The name of the data attribute to search for.
61
+ * @param {string} [attributeValue] - The specific value of the data attribute to match (optional).
62
+ */
63
+ export function deleteHeadTagsByDataAttribute(attributeName, attributeValue) {
64
+ const head = document.head
65
+ const tagsToDelete = []
66
+
67
+ // Iterate over all children in the head section
68
+ Array.from(head.children).forEach((element) => {
69
+ const hasAttribute = element.hasAttribute(`data-${attributeName}`)
70
+
71
+ // If a specific attribute value is provided, check for it
72
+ if (attributeValue && hasAttribute) {
73
+ const matchesValue = element.getAttribute(`data-${attributeName}`) === attributeValue
74
+ if (matchesValue) {
75
+ tagsToDelete.push(element)
76
+ }
77
+ } else if (hasAttribute) {
78
+ // If no specific value, just check if the attribute is present
79
+ tagsToDelete.push(element)
80
+ }
81
+ })
82
+
83
+ // Delete all the tags that matched the attribute condition
84
+ tagsToDelete.forEach((tag) => {
85
+ head.removeChild(tag)
86
+ })
87
+ }
88
+
89
+ /**
90
+ * Returns resolved array of meta data elements.
91
+ *
92
+ *
93
+ * @param {Array<Match>} matchedRoutes - Array of all matches.
94
+ * @param {Object} routeData - Data returned from Router.
95
+ * @returns {Array<JSX.Element>} - List of all meta tags for the matched location.
96
+ */
97
+
98
+ export function getMetaData(matchedRoutes, routeData) {
99
+ let allTags = []
100
+ try {
101
+ matchedRoutes?.forEach?.((match) => {
102
+ const setMetaData = match?.route?.component?.setMetaData
103
+ if (setMetaData) {
104
+ let tags = setMetaData(routeData)
105
+ allTags = [...allTags, tags]
106
+ }
107
+ })
108
+ if (Array.isArray(allTags) && allTags.length > 0) {
109
+ let mergedTags = mergeHeadElements(...allTags)
110
+ allTags = mergedTags.map((el, index) =>
111
+ React.cloneElement(el, { "data-catalyst": true, key: index })
112
+ )
113
+ }
114
+ } catch (er) {
115
+ console.log("meta tags error is ===>", er)
116
+ }
117
+
118
+ return allTags
119
+ }
@@ -11,17 +11,20 @@
11
11
  "field: API_URL must be present"
12
12
  ],
13
13
  "fix_guide": "Create config/config.json with: { NODE_SERVER_PORT: 3000, API_URL: 'https://api.example.com', CLIENT_ENV_KEYS: [], PUBLIC_STATIC_ASSET_URL: '', WEBVIEW_CONFIG: { port: 3000, accessControl: { enabled: true, allowedUrls: [] } } }",
14
- "verify_hint": "Run `npm run devServe`. Server should start without 'Cannot find module config' or 'missing required field' errors. Check terminal output — catalyst-core logs the config it loaded at boot.",
14
+ "verify_hint": "Run `npm run start` on Catalyst 0.3.x, or `npm run devServe` on legacy 0.2.x. The server should start without config errors.",
15
15
  "depends_on": []
16
16
  },
17
17
  {
18
18
  "id": "T2_ROUTER_DEP",
19
19
  "tier": 1,
20
- "title": "@tata1mg/router installed in package.json",
20
+ "title": "Router dependency matches the Catalyst runtime generation",
21
21
  "detect_pattern": "package_json_dep",
22
- "how_to_check": ["package.json dependencies or devDependencies must include @tata1mg/router"],
23
- "fix_guide": "Run: npm install @tata1mg/router. Then replace all react-router-dom imports with @tata1mg/router. Replace BrowserRouter/Routes/Route setup with RouterDataProvider + routes array in src/js/routes/index.js.",
24
- "verify_hint": "Run `npm run devServe`. No 'Cannot resolve @tata1mg/router' errors in build output. If react-router-dom was the previous router, confirm no leftover BrowserRouter/Routes imports remain — they will conflict.",
22
+ "how_to_check": [
23
+ "Catalyst 0.2.x: package.json includes @tata1mg/router and Catalyst router APIs import from it",
24
+ "Catalyst 0.3.x+: package.json does not include @tata1mg/router and Catalyst router APIs import from catalyst-core"
25
+ ],
26
+ "fix_guide": "Version-specific: for Catalyst 0.2.x install @tata1mg/router and import RouterDataProvider, Outlet, navigation, and data hooks from it. For Catalyst 0.3.x+, remove @tata1mg/router and import those APIs from catalyst-core. Never mix the two router generations.",
27
+ "verify_hint": "Run the development command for the installed generation. Confirm there are no unresolved router imports, duplicate React-element errors, or blank route outlets.",
25
28
  "depends_on": ["T1_CONFIG"]
26
29
  },
27
30
  {
@@ -34,7 +37,21 @@
34
37
  "pattern: file must export an array (export default [ or module.exports = [)"
35
38
  ],
36
39
  "fix_guide": "Create src/js/routes/index.js: import HomePage from '../pages/Home'; export default [{ path: '/', component: HomePage, exact: true }]. Add one entry per page component. Each component needs serverFetcher/clientFetcher attached (see T4_DATA_FETCHING).",
37
- "verify_hint": "Run `npm run devServe` and open the first route in browser (e.g. http://localhost:3000/). Page should render — not a blank screen or 404. Check browser console for 'No routes matched' warnings which mean the route array is empty or paths are wrong.",
40
+ "verify_hint": "Run `npm run start` on 0.3.x or `npm run devServe` on 0.2.x and open the first route. Check for blank output, 404s, or 'No routes matched' warnings.",
41
+ "depends_on": ["T2_ROUTER_DEP"]
42
+ },
43
+ {
44
+ "id": "T2b_RUNTIME_DEPS",
45
+ "tier": 1,
46
+ "title": "React runtime matches the Catalyst generation",
47
+ "detect_pattern": "package_json_dep + version_check",
48
+ "how_to_check": [
49
+ "Catalyst 0.3.x+: react and react-dom are exactly 19.0.0",
50
+ "Catalyst 0.3.x+: @tata1mg/router and @loadable/component are absent",
51
+ "Catalyst 0.2.x: retain the React and loadable versions supported by that release"
52
+ ],
53
+ "fix_guide": "For Catalyst 0.3.x+, set react and react-dom to exactly 19.0.0 without ^ or ~, remove @tata1mg/router and @loadable/component, and reinstall so the application and catalyst-core resolve one React runtime. Do not apply these dependency changes to an application staying on 0.2.x.",
54
+ "verify_hint": "Run npm ls react react-dom. A 0.3.x application should resolve React 19.0.0 without duplicate or invalid runtime copies.",
38
55
  "depends_on": ["T2_ROUTER_DEP"]
39
56
  },
40
57
  {
@@ -51,7 +68,7 @@
51
68
  "signal: files with .serverFetcher = or .clientFetcher = (converted pages)",
52
69
  "llm judges: is any useEffect+fetch file a page component that needs conversion?"
53
70
  ],
54
- "fix_guide": "For each page component: 1) Remove useState+useEffect data loading. 2) Attach static function: HomePage.serverFetcher = async ({ params, searchParams }, { store }) => { return await fetchApi(); }. 3) In component body: const data = useCurrentRouteData() from @tata1mg/router. This is a full rewrite of every page's data layer.",
71
+ "fix_guide": "For each page component: remove initial useEffect data loading, attach serverFetcher/clientFetcher statics, and read route data with useCurrentRouteData(). Import the hook from @tata1mg/router on 0.2.x or catalyst-core on 0.3.x+.",
55
72
  "verify_hint": "Open a migrated page in browser. Open DevTools Network tab — on first load there should be NO XHR/fetch calls for page data (data arrives server-rendered in HTML). View Page Source and confirm the page content (not just a loading skeleton) is present in the raw HTML. If content is missing from source, serverFetcher is not attached or not running.",
56
73
  "depends_on": ["T3_ROUTES_FILE"]
57
74
  },
@@ -64,21 +81,21 @@
64
81
  "file: src/js/routes/utils.js must exist",
65
82
  "pattern: RouterDataProvider must be imported and used in utils.js"
66
83
  ],
67
- "fix_guide": "Create src/js/routes/utils.js: import { RouterDataProvider } from '@tata1mg/router'; import routes from './index'; export default function AppRouter() { return <RouterDataProvider routes={routes} />; }. Without this, useCurrentRouteData() returns undefined everywhere.",
84
+ "fix_guide": "Create src/js/routes/utils.js using the CCA preparedRoutes pattern. Import RouterDataProvider and MetaTag from @tata1mg/router on 0.2.x or catalyst-core on 0.3.x+. Wrap App and pass routerInitialState plus fetcherArgs when a store is used.",
68
85
  "verify_hint": "In a page component that uses useCurrentRouteData(), console.log the return value. It should be the data object returned by serverFetcher — not undefined. If undefined, RouterDataProvider is not wrapping the tree or the route entry is missing the component reference.",
69
86
  "depends_on": ["T3_ROUTES_FILE"]
70
87
  },
71
88
  {
72
89
  "id": "T6_APP_SHELL",
73
90
  "tier": 1,
74
- "title": "App shell renders <Outlet /> from @tata1mg/router",
91
+ "title": "App shell renders the generation-appropriate <Outlet />",
75
92
  "detect_pattern": "file_exists + code_pattern",
76
93
  "how_to_check": [
77
94
  "file: src/js/containers/App/index.js must exist",
78
- "pattern: Outlet must be imported from @tata1mg/router",
95
+ "pattern: Outlet comes from @tata1mg/router on 0.2.x or catalyst-core on 0.3.x+",
79
96
  "pattern: <Outlet /> must be rendered in the component"
80
97
  ],
81
- "fix_guide": "In src/js/containers/App/index.js: import { Outlet } from '@tata1mg/router'. Render <Outlet /> where route content should appear (replacing any <Switch> or <Routes> block). Keep global layout (nav, footer) around it.",
98
+ "fix_guide": "Render <Outlet /> where route content belongs. Import it from @tata1mg/router on Catalyst 0.2.x or catalyst-core on 0.3.x+. Keep global layout around the outlet.",
82
99
  "verify_hint": "Open the app in browser. Global layout (header, footer, nav) should appear on every page. The area where page content changes should not be blank. If page content area is empty, <Outlet /> is missing or placed incorrectly in the App shell.",
83
100
  "depends_on": ["T5_ROUTER_DATA_PROVIDER"]
84
101
  },
@@ -92,8 +109,8 @@
92
109
  "file: server/server.js must exist",
93
110
  "file: server/document.js must exist"
94
111
  ],
95
- "fix_guide": "Create all 3 files: (1) server/index.js — export default { preServerInit: async () => {}, onRouteMatch: async (req, res) => {}, onServerError: (err) => {} }. (2) server/server.js — export const addMiddlewares = (app) => { /* add express middleware here */ }. (3) server/document.js — export default ({ html, head, scripts }) => `<!DOCTYPE html><html><head>${head}</head><body><div id='root'>${html}</div>${scripts}</body></html>`.",
96
- "verify_hint": "Run `npm run devServe`. Server must start without 'Cannot find module ./server/index' errors. Hit http://localhost:3000/ — the response HTML should contain your document.js shell structure (check View Source). A blank body or missing <div id='root'> means document.js is not returning valid HTML.",
112
+ "fix_guide": "Create server/index.js, server/server.js, and server/document.js using the template for the installed generation. On 0.3.x these are ESM: server/index.js exports preServerInit, server/server.js exports addMiddlewares(app), and server/document.js exports a React document that renders Head and Body from catalyst-core. Preserve the legacy 0.2.x server contract when not upgrading.",
113
+ "verify_hint": "Run the generation-appropriate development command and inspect View Source. The response must contain the document shell and rendered application root.",
97
114
  "depends_on": ["T1_CONFIG"]
98
115
  },
99
116
  {
@@ -108,9 +125,10 @@
108
125
  "pattern: client/index.js must call WebBridge.init()",
109
126
  "pattern: client/index.js must use hydrateRoot from 'react-dom/client' (not ReactDOM.render or hydrate)",
110
127
  "pattern: client/index.js must import clientRouter from 'catalyst-core/router/ClientRouter'",
111
- "pattern: client/index.js must wrap app in RouterProvider from '@tata1mg/router'"
128
+ "pattern: RouterProvider comes from @tata1mg/router on 0.2.x or catalyst-core on 0.3.x+",
129
+ "pattern: 0.2.x waits for loadableReady; 0.3.x+ waits for hydrationReady"
112
130
  ],
113
- "fix_guide": "Create client/index.js:\nimport React from 'react';\nimport './styles';\nimport { hydrateRoot } from 'react-dom/client';\nimport { loadableReady } from '@loadable/component';\nimport { Provider } from 'react-redux';\nimport { RouterProvider } from '@tata1mg/router';\nimport { HelmetProvider } from 'react-helmet-async';\nimport clientRouter from 'catalyst-core/router/ClientRouter';\nimport WebBridge from 'catalyst-core/WebBridge';\nimport configureStore from '@store';\n\nwindow.addEventListener('load', () => {\n loadableReady(() => {\n const { __ROUTER_INITIAL_DATA__: routerInitialData, __INITIAL_STATE__ } = window;\n const store = configureStore(__INITIAL_STATE__ || {});\n const router = clientRouter({ store, routerInitialState: routerInitialData });\n const Application = (\n <Provider store={store} serverState={__INITIAL_STATE__}>\n <HelmetProvider>\n <React.StrictMode>\n <RouterProvider router={router} />\n </React.StrictMode>\n </HelmetProvider>\n </Provider>\n );\n WebBridge.init();\n const container = document.getElementById('app');\n hydrateRoot(container, Application);\n });\n});\n\nCreate client/styles.js: import '../src/styles/global.css' (adjust path to your global stylesheet).\n\nCRITICAL: WebBridge.init() must be called before hydrateRoot — it registers native bridge event handlers. Missing this call means no JS-to-native communication (postMessage, camera, file picker, haptics all break silently on device).",
131
+ "fix_guide": "Use hydrateRoot and initialize WebBridge before hydration. On 0.2.x, import RouterProvider from @tata1mg/router and wait for loadableReady from @loadable/component. On 0.3.x+, import RouterProvider and hydrationReady from catalyst-core, then call hydrationReady().then(() => hydrateRoot(...)). Do not retain @loadable/component in the Vite runtime.",
114
132
  "verify_hint": "Open the app in browser. Open DevTools Console — there should be no 'hydrateRoot' mismatch warnings (if there are, server HTML and client render differ). Open DevTools Elements — the #app or #root div should have React content inside it (not empty). Click an interactive element — if nothing responds, hydration failed. Also confirm global styles are applied (CSS loads).",
115
133
  "depends_on": ["T6_APP_SHELL"]
116
134
  },
@@ -127,8 +145,8 @@
127
145
  "package.json scripts must include: setupEmulator:ios",
128
146
  "package.json scripts must include: setupEmulator:android"
129
147
  ],
130
- "fix_guide": "Add to package.json scripts:\n\"devBuild\": \"catalyst devBuild\",\n\"devServe\": \"catalyst devServe\",\n\"buildApp\": \"catalyst buildApp\",\n\"buildApp:ios\": \"catalyst buildApp:ios\",\n\"buildApp:android\": \"catalyst buildApp:android\",\n\"setupEmulator\": \"catalyst setupEmulator\",\n\"setupEmulator:ios\": \"catalyst setupEmulator:ios\",\n\"setupEmulator:android\": \"catalyst setupEmulator:android\"\n\nThese scripts are required to run native builds and launch emulators. Without them, 'npm run buildApp:android' and MCP build flow commands will fail with 'missing script' errors.",
131
- "verify_hint": "Run `npm run devBuild` — should start webpack compilation without 'missing script' error. Run `npm run devServe` — server should start on NODE_SERVER_PORT. Both commands should be found by npm, not fail with 'ERR_INVALID_ARG_TYPE' or 'script not found'.",
148
+ "fix_guide": "Add buildApp, buildApp:ios, buildApp:android, setupEmulator, setupEmulator:ios, and setupEmulator:android scripts. Legacy 0.2.x may also expose devBuild/devServe. Current 0.3.x removes those commands: use catalyst start for development and catalyst build followed by catalyst serve for production validation.",
149
+ "verify_hint": "Run `npm run start`, then verify the required platform command resolves. On 0.3.x, devBuild/devServe should not be present.",
132
150
  "depends_on": ["T1_CONFIG"]
133
151
  },
134
152
  {