catalyst-core 0.2.0-beta.3 → 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.
- 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/index.jsx +8 -0
- package/dist/logger.js +74 -3
- package/dist/native/androidSetup.js +300 -8
- package/dist/native/bridge/WebBridge.js +481 -59
- package/dist/native/bridge/constants/NativeInterfaces.js +290 -45
- package/dist/native/bridge/errors.js +250 -26
- package/dist/native/bridge/hooks/index.js +125 -1
- 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 +374 -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 +250 -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 +433 -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 +422 -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 +124 -13
- package/mcp_v2/lib/helpers.js +10 -0
- package/mcp_v2/mcp.js +4 -4
- package/mcp_v2/package.json +1 -0
- package/mcp_v2/tools/build.js +116 -20
- 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/bin/catalyst.js
CHANGED
|
@@ -1,128 +1,72 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict"
|
|
3
|
-
process.on("unhandledRejection", (err) => {
|
|
4
|
-
throw err
|
|
5
|
-
})
|
|
6
|
-
const { spawnSync } = require("node:child_process")
|
|
7
|
-
const args = process.argv.slice(2)
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"plugin",
|
|
17
|
-
"plugins",
|
|
18
|
-
"buildApp",
|
|
19
|
-
"buildApp:ios",
|
|
20
|
-
"buildApp:android",
|
|
21
|
-
"setupEmulator",
|
|
22
|
-
"setupEmulator:ios",
|
|
23
|
-
"setupEmulator:android",
|
|
24
|
-
]
|
|
3
|
+
import { spawnSync } from "node:child_process"
|
|
4
|
+
import { dirname, resolve } from "node:path"
|
|
5
|
+
import { fileURLToPath } from "node:url"
|
|
6
|
+
|
|
7
|
+
process.on("unhandledRejection", (error) => {
|
|
8
|
+
throw error
|
|
9
|
+
})
|
|
25
10
|
|
|
26
|
-
|
|
11
|
+
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
12
|
+
const args = process.argv.slice(2)
|
|
13
|
+
const webCommands = new Set(["build", "start", "serve", "serve:inspect", "plugin", "plugins"])
|
|
27
14
|
const platformScripts = {
|
|
28
15
|
"setupEmulator:ios": "../dist/native/setupEmulatorIos.js",
|
|
29
16
|
"setupEmulator:android": "../dist/native/androidSetup.js",
|
|
30
17
|
"buildApp:ios": "../dist/native/buildAppIos.js",
|
|
31
18
|
"buildApp:android": "../dist/native/buildAppAndroid.js",
|
|
32
19
|
}
|
|
20
|
+
const validCommands = new Set([...webCommands, "buildApp", "setupEmulator", ...Object.keys(platformScripts)])
|
|
21
|
+
|
|
22
|
+
const scriptIndex = args.findIndex((arg) => validCommands.has(arg))
|
|
23
|
+
const script = scriptIndex === -1 ? args[0] : args[scriptIndex]
|
|
24
|
+
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []
|
|
25
|
+
const scriptArgs = args.slice(scriptIndex + 1)
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
function handleProcessResult(result) {
|
|
28
|
+
if (result.signal) {
|
|
29
|
+
if (result.signal === "SIGKILL") {
|
|
30
|
+
console.error("The Catalyst process was terminated with SIGKILL.")
|
|
31
|
+
} else if (result.signal === "SIGTERM") {
|
|
32
|
+
console.error("The Catalyst process was terminated with SIGTERM.")
|
|
33
|
+
}
|
|
34
|
+
process.exit(1)
|
|
35
|
+
}
|
|
36
|
+
process.exit(result.status ?? 1)
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const command = `${baseCommand}:${platform}`
|
|
44
|
-
const result = spawnSync(
|
|
39
|
+
function runScript(relativePath, extraArgs = []) {
|
|
40
|
+
return spawnSync(
|
|
45
41
|
process.execPath,
|
|
46
|
-
nodeArgs
|
|
47
|
-
{
|
|
42
|
+
[...nodeArgs, resolve(__dirname, relativePath), ...extraArgs, ...scriptArgs],
|
|
43
|
+
{
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
}
|
|
48
46
|
)
|
|
49
|
-
return result
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
49
|
+
function runPlatformCommand(command) {
|
|
50
|
+
return runScript(platformScripts[command])
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (script === "buildApp" || script === "setupEmulator") {
|
|
54
|
+
for (const platform of ["ios", "android"]) {
|
|
55
|
+
const result = runPlatformCommand(`${script}:${platform}`)
|
|
56
|
+
if (result.status !== 0 || result.signal) handleProcessResult(result)
|
|
61
57
|
}
|
|
62
58
|
process.exit(0)
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
(
|
|
67
|
-
x === "build" ||
|
|
68
|
-
x === "start" ||
|
|
69
|
-
x === "serve" ||
|
|
70
|
-
x === "devBuild" ||
|
|
71
|
-
x === "devServe" ||
|
|
72
|
-
x === "plugin" ||
|
|
73
|
-
x === "plugins" ||
|
|
74
|
-
isPlatformCommand(x, "buildApp") ||
|
|
75
|
-
isPlatformCommand(x, "setupEmulator")
|
|
76
|
-
)
|
|
77
|
-
const script = scriptIndex === -1 ? args[0] : args[scriptIndex]
|
|
78
|
-
const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []
|
|
79
|
-
const resolvedScript = script === "plugin" ? "plugins" : script
|
|
80
|
-
|
|
81
|
-
if (validCommands.includes(script)) {
|
|
82
|
-
// Handle platform-specific or combined commands
|
|
83
|
-
if (script === "buildApp" || script === "setupEmulator") {
|
|
84
|
-
// Run for all platforms if no specific platform is specified
|
|
85
|
-
runAllPlatforms(script)
|
|
86
|
-
} else if (script in platformScripts) {
|
|
87
|
-
// Run for specific platform
|
|
88
|
-
const result = spawnSync(
|
|
89
|
-
process.execPath,
|
|
90
|
-
nodeArgs.concat(require.resolve(platformScripts[script])).concat(args.slice(scriptIndex + 1)),
|
|
91
|
-
{ stdio: "inherit" }
|
|
92
|
-
)
|
|
93
|
-
handleProcessResult(result)
|
|
94
|
-
} else {
|
|
95
|
-
// Original commands
|
|
96
|
-
const result = spawnSync(
|
|
97
|
-
process.execPath,
|
|
98
|
-
nodeArgs
|
|
99
|
-
.concat(require.resolve("../dist/scripts/" + resolvedScript))
|
|
100
|
-
.concat(args.slice(scriptIndex + 1)),
|
|
101
|
-
{ stdio: "inherit" }
|
|
102
|
-
)
|
|
103
|
-
handleProcessResult(result)
|
|
104
|
-
}
|
|
105
|
-
} else {
|
|
106
|
-
console.log('Unknown script "' + script + '".')
|
|
61
|
+
if (platformScripts[script]) {
|
|
62
|
+
handleProcessResult(runPlatformCommand(script))
|
|
107
63
|
}
|
|
108
64
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
console.log(
|
|
114
|
-
"The build failed because the process exited too early. " +
|
|
115
|
-
"This probably means the system ran out of memory or someone called " +
|
|
116
|
-
"`kill -9` on the process."
|
|
117
|
-
)
|
|
118
|
-
} else if (result.signal === "SIGTERM") {
|
|
119
|
-
console.log(
|
|
120
|
-
"The build failed because the process exited too early. " +
|
|
121
|
-
"Someone might have called `kill` or `killall`, or the system could " +
|
|
122
|
-
"be shutting down."
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
process.exit(1)
|
|
126
|
-
}
|
|
127
|
-
process.exit(result.status)
|
|
65
|
+
if (webCommands.has(script)) {
|
|
66
|
+
const scriptName = script === "plugin" ? "plugins" : script === "serve:inspect" ? "serve" : script
|
|
67
|
+
const extraArgs = script === "serve:inspect" ? ["--inspect"] : []
|
|
68
|
+
handleProcessResult(runScript(`../dist/scripts/${scriptName}.js`, extraArgs))
|
|
128
69
|
}
|
|
70
|
+
|
|
71
|
+
console.error(`Unknown script "${script}".`)
|
|
72
|
+
process.exit(1)
|
package/changelog.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
# 1.0.0-beta.1
|
|
2
|
+
|
|
3
|
+
- Replaced the Webpack build and SSR pipeline with Vite and ESM.
|
|
4
|
+
- Added React 19 Suspense-aware routing, split components, and manifest-based asset loading.
|
|
5
|
+
- Added opt-in request, compression, flush, and bot-aware OpenTelemetry spans.
|
|
6
|
+
- Preserved native application builds, internal plugins, Sentry exports, and safe-area SSR hydration.
|
|
7
|
+
- Removed the legacy `devBuild` and `devServe` commands.
|
|
8
|
+
|
|
1
9
|
# Changelog
|
|
2
10
|
|
|
3
11
|
## [0.1.0-beta.2] - 2026-05-06
|
package/dist/caching.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from "@tata1mg/api-caching"
|
package/dist/index.jsx
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "react-router-dom"
|
|
2
|
+
export * from "./web-router/components/RouterDataProvider.jsx"
|
|
3
|
+
export * from "./web-router/components/MetaTag.jsx"
|
|
4
|
+
export { split, hydrationReady } from "./web-router/components/Split.jsx"
|
|
5
|
+
export { split as default } from "./web-router/components/Split.jsx"
|
|
6
|
+
export * from "./web-router/hooks.jsx"
|
|
7
|
+
export * from "./web-router/utils/metaDataUtils.jsx"
|
|
8
|
+
export * from "./server/renderer/document/index.jsx"
|
package/dist/logger.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import pc from "picocolors"
|
|
2
|
+
import winston from "winston"
|
|
3
|
+
import DailyRotateFile from "winston-daily-rotate-file"
|
|
4
|
+
|
|
5
|
+
const { createLogger, format, transports } = winston
|
|
6
|
+
|
|
7
|
+
/**
|
|
2
8
|
* @description Logger library with rotational strategy. Creates a logs folder in root.
|
|
3
9
|
* With debug, error and info log directories with their respective log files.
|
|
4
10
|
*
|
|
@@ -6,5 +12,70 @@
|
|
|
6
12
|
* @param config { @enableDebugLogs: Bool // default: true }
|
|
7
13
|
* @returns loggerInstance
|
|
8
14
|
*
|
|
9
|
-
*/
|
|
10
|
-
|
|
15
|
+
*/
|
|
16
|
+
const configureLogger = (config = {}) => {
|
|
17
|
+
const { enableDebugLogs = true, enableFileLogging = true, enableConsoleLogging = true } = config
|
|
18
|
+
|
|
19
|
+
const consoleTransport = new transports.Console({ level: "debug" })
|
|
20
|
+
|
|
21
|
+
const fileTransport = (type = "info") => {
|
|
22
|
+
return new DailyRotateFile({
|
|
23
|
+
filename: `${process.env.src_path}/logs/${type}/%DATE%.${type}.log`,
|
|
24
|
+
datePattern: "YYYY-MM-DD",
|
|
25
|
+
maxFiles: "3d", // Logs will be removed after 2days,
|
|
26
|
+
loglevel: type,
|
|
27
|
+
level: type,
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const infoLogger = createLogger({
|
|
32
|
+
format: format.combine(format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), format.json()),
|
|
33
|
+
defaultMeta: { loglevel: "info" },
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const debugLogger = createLogger({
|
|
37
|
+
format: format.combine(format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), format.json()),
|
|
38
|
+
defaultMeta: { loglevel: "debug" },
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const errorLogger = createLogger({
|
|
42
|
+
format: format.combine(format.timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), format.json()),
|
|
43
|
+
defaultMeta: { loglevel: "error" },
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
if (enableConsoleLogging && JSON.parse(enableConsoleLogging)) {
|
|
47
|
+
infoLogger.add(consoleTransport)
|
|
48
|
+
debugLogger.add(consoleTransport)
|
|
49
|
+
errorLogger.add(consoleTransport)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (enableFileLogging && JSON.parse(enableFileLogging)) {
|
|
53
|
+
infoLogger.add(fileTransport("info"))
|
|
54
|
+
debugLogger.add(fileTransport("debug"))
|
|
55
|
+
errorLogger.add(fileTransport("error"))
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const Logger = {
|
|
59
|
+
debug: () => {},
|
|
60
|
+
error: (msg) => {
|
|
61
|
+
console.log(pc.red(pc.bold("ERROR: " + JSON.stringify(msg))))
|
|
62
|
+
errorLogger.error(msg)
|
|
63
|
+
},
|
|
64
|
+
info: (msg) => {
|
|
65
|
+
console.log(pc.green(pc.bold("INFO: " + JSON.stringify(msg))))
|
|
66
|
+
infoLogger.info(msg)
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (enableDebugLogs && JSON.parse(enableDebugLogs)) {
|
|
71
|
+
Logger.debug = (msg) => {
|
|
72
|
+
console.log(pc.yellow(pc.bold("DEBUG: " + JSON.stringify(msg))))
|
|
73
|
+
debugLogger.debug(msg)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (global) global.logger = Logger
|
|
78
|
+
return Logger
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { configureLogger }
|
|
@@ -1,9 +1,301 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
4
|
+
var _path = _interopRequireDefault(require("path"));
|
|
5
|
+
var _child_process = require("child_process");
|
|
6
|
+
var _utils = require("./utils.js");
|
|
7
|
+
var _TerminalProgress = _interopRequireDefault(require("./TerminalProgress.js"));
|
|
8
|
+
var _setupServer = require("./setupServer.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const catalystCorePath = _path.default.dirname(require.resolve("catalyst-core/package.json"));
|
|
11
|
+
const pwd = _path.default.join(catalystCorePath, "dist/native");
|
|
12
|
+
const configPath = `${process.env.PWD}/config/config.json`;
|
|
13
|
+
const steps = {
|
|
14
|
+
java: "Check Java Environment",
|
|
15
|
+
config: "Initialize Configuration",
|
|
16
|
+
androidTools: "Validate Android Tools",
|
|
17
|
+
emulator: "Configure Android Emulator",
|
|
18
|
+
properties: "Update Local Properties",
|
|
19
|
+
saveConfig: "Save Configuration",
|
|
20
|
+
setupServer: "Setup Server"
|
|
21
|
+
};
|
|
22
|
+
const progressPaddingConfig = {
|
|
23
|
+
titlePaddingTop: 2,
|
|
24
|
+
titlePaddingBottom: 1,
|
|
25
|
+
stepPaddingLeft: 4,
|
|
26
|
+
stepSpacing: 1,
|
|
27
|
+
errorPaddingLeft: 6,
|
|
28
|
+
bottomMargin: 2
|
|
29
|
+
};
|
|
30
|
+
const progress = new _TerminalProgress.default(steps, "Catalyst Universal Android Setup", progressPaddingConfig);
|
|
31
|
+
async function checkJavaInstallation() {
|
|
32
|
+
try {
|
|
33
|
+
(0, _utils.runCommand)("java -version");
|
|
34
|
+
(0, _utils.runCommand)("javac -version");
|
|
35
|
+
progress.log("Java is installed and configured", "success");
|
|
36
|
+
return true;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
progress.log("Java installation not found or not properly configured", "error");
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function installJava() {
|
|
43
|
+
progress.log("Installing Java (Zulu JDK 17)...");
|
|
44
|
+
try {
|
|
45
|
+
try {
|
|
46
|
+
(0, _utils.runCommand)("brew --version");
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new Error("Homebrew is required but not installed. Please install Homebrew first.");
|
|
49
|
+
}
|
|
50
|
+
const javaHome = "/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home";
|
|
51
|
+
|
|
52
|
+
// Try installing Java
|
|
53
|
+
try {
|
|
54
|
+
await (0, _utils.runCommand)("brew install --cask zulu@17");
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error.message.includes("already installed")) {
|
|
57
|
+
progress.log("Attempting to reinstall Java...", "info");
|
|
58
|
+
try {
|
|
59
|
+
await (0, _utils.runCommand)("brew reinstall --cask zulu@17");
|
|
60
|
+
} catch (reinstallError) {
|
|
61
|
+
throw new Error(`Failed to reinstall Java: ${reinstallError.message}. Please run 'brew reinstall --cask zulu@17' manually.`);
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Verify Java installation
|
|
69
|
+
if (!_fs.default.existsSync(javaHome)) {
|
|
70
|
+
throw new Error(`Java installation not found at ${javaHome}. Please verify the installation manually.`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Set up environment variables
|
|
74
|
+
const homeDir = process.env.HOME;
|
|
75
|
+
const shellProfile = `${homeDir}/.zshrc`;
|
|
76
|
+
const exportCommand = `\n# Java Configuration\nexport JAVA_HOME=${javaHome}\nexport PATH=$JAVA_HOME/bin:$PATH\n`;
|
|
77
|
+
try {
|
|
78
|
+
_fs.default.appendFileSync(shellProfile, exportCommand);
|
|
79
|
+
} catch (error) {
|
|
80
|
+
throw new Error(`Failed to update ${shellProfile}: ${error.message}. Please add the following lines manually:\n${exportCommand}`);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Set for current process
|
|
84
|
+
process.env.JAVA_HOME = javaHome;
|
|
85
|
+
process.env.PATH = `${javaHome}/bin:${process.env.PATH}`;
|
|
86
|
+
|
|
87
|
+
// Verify Java configuration
|
|
88
|
+
try {
|
|
89
|
+
const javaVersion = (0, _utils.runCommand)("java -version");
|
|
90
|
+
progress.log("Java installed and configured successfully", "success");
|
|
91
|
+
progress.log(`Java Version: ${javaVersion}`, "info");
|
|
92
|
+
progress.log(`IMPORTANT: Please run the following commands to complete setup:`, "warning");
|
|
93
|
+
progress.log(`1. source ${shellProfile}`, "info");
|
|
94
|
+
progress.log(`2. echo $JAVA_HOME`, "info");
|
|
95
|
+
return true;
|
|
96
|
+
} catch (error) {
|
|
97
|
+
throw new Error(`Java installation verified but environment not configured. Please run:\n1. source ${shellProfile}\n2. echo $JAVA_HOME`);
|
|
98
|
+
}
|
|
99
|
+
} catch (error) {
|
|
100
|
+
progress.log(error.message, "error");
|
|
101
|
+
progress.log("Manual Setup Instructions:", "info");
|
|
102
|
+
progress.log("1. Run: brew reinstall --cask zulu@17", "info");
|
|
103
|
+
progress.log("2. Add to ~/.zshrc:", "info");
|
|
104
|
+
progress.log(" export JAVA_HOME=/Library/Java/JavaVirtualMachines/zulu-17.jdk/Contents/Home", "info");
|
|
105
|
+
progress.log(" export PATH=$JAVA_HOME/bin:$PATH", "info");
|
|
106
|
+
progress.log("3. Run: source ~/.zshrc", "info");
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async function validateJavaEnvironment() {
|
|
111
|
+
progress.start("java");
|
|
112
|
+
const hasJava = await checkJavaInstallation();
|
|
113
|
+
if (!hasJava) {
|
|
114
|
+
progress.log("Java installation required. Starting installation process...");
|
|
115
|
+
const javaInstalled = await installJava();
|
|
116
|
+
if (!javaInstalled) {
|
|
117
|
+
progress.fail("java", "Failed to set up Java environment");
|
|
118
|
+
throw new Error("Failed to set up Java environment");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
progress.complete("java");
|
|
122
|
+
}
|
|
123
|
+
async function initializeConfig() {
|
|
124
|
+
const configFile = _fs.default.readFileSync(configPath, "utf8");
|
|
125
|
+
const config = JSON.parse(configFile);
|
|
126
|
+
const {
|
|
127
|
+
WEBVIEW_CONFIG
|
|
128
|
+
} = config;
|
|
129
|
+
if (!WEBVIEW_CONFIG || Object.keys(WEBVIEW_CONFIG).length === 0) {
|
|
130
|
+
progress.log("WebView Config missing in " + configPath, "error");
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
if (!WEBVIEW_CONFIG.android) {
|
|
134
|
+
WEBVIEW_CONFIG.android = {};
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
WEBVIEW_CONFIG
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
async function saveConfig(newConfig) {
|
|
141
|
+
try {
|
|
142
|
+
const existingConfigFile = _fs.default.readFileSync(configPath, "utf8");
|
|
143
|
+
const existingConfig = JSON.parse(existingConfigFile);
|
|
144
|
+
const updatedConfig = {
|
|
145
|
+
...existingConfig,
|
|
146
|
+
WEBVIEW_CONFIG: {
|
|
147
|
+
...existingConfig.WEBVIEW_CONFIG,
|
|
148
|
+
android: newConfig.WEBVIEW_CONFIG.android
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
_fs.default.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));
|
|
152
|
+
progress.log("Configuration saved successfully", "success");
|
|
153
|
+
} catch (error) {
|
|
154
|
+
progress.log("Failed to save configuration: " + error.message, "error");
|
|
155
|
+
process.exit(1);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function validateAndroidTools(androidConfig) {
|
|
159
|
+
const ANDROID_SDK = androidConfig.sdkPath;
|
|
160
|
+
const EMULATOR_PATH = `${ANDROID_SDK}/emulator/emulator`;
|
|
161
|
+
const ADB_PATH = `${ANDROID_SDK}/platform-tools/adb`;
|
|
162
|
+
if (!ANDROID_SDK) {
|
|
163
|
+
throw new Error("Android SDK path is not configured");
|
|
164
|
+
}
|
|
165
|
+
if (!_fs.default.existsSync(ANDROID_SDK)) {
|
|
166
|
+
throw new Error(`Android SDK path does not exist: ${ANDROID_SDK}`);
|
|
167
|
+
}
|
|
168
|
+
if (!_fs.default.existsSync(ADB_PATH)) {
|
|
169
|
+
throw new Error(`ADB not found at: ${ADB_PATH}`);
|
|
170
|
+
}
|
|
171
|
+
try {
|
|
172
|
+
(0, _utils.runCommand)(`${ADB_PATH} version`);
|
|
173
|
+
progress.log("ADB is valid", "success");
|
|
174
|
+
} catch (error) {
|
|
175
|
+
throw new Error(`ADB is not working properly: ${error.message}`);
|
|
176
|
+
}
|
|
177
|
+
if (!_fs.default.existsSync(EMULATOR_PATH)) {
|
|
178
|
+
throw new Error(`Emulator not found at: ${EMULATOR_PATH}`);
|
|
179
|
+
}
|
|
180
|
+
try {
|
|
181
|
+
(0, _utils.runCommand)(`${EMULATOR_PATH} -version`);
|
|
182
|
+
progress.log("Emulator is valid", "success");
|
|
183
|
+
} catch (error) {
|
|
184
|
+
throw new Error(`Emulator is not working properly: ${error.message}`);
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const avdOutput = (0, _utils.runCommand)(`${EMULATOR_PATH} -list-avds`);
|
|
188
|
+
if (!avdOutput.includes(androidConfig.emulatorName)) {
|
|
189
|
+
throw new Error(`Specified emulator "${androidConfig.emulatorName}" not found in available AVDs`);
|
|
190
|
+
}
|
|
191
|
+
progress.log(`Emulator "${androidConfig.emulatorName}" exists`, "success");
|
|
192
|
+
} catch (error) {
|
|
193
|
+
throw new Error(`Error checking emulator AVD: ${error.message}`);
|
|
194
|
+
}
|
|
195
|
+
progress.log("Android tools validation completed successfully!", "success");
|
|
196
|
+
return {
|
|
197
|
+
EMULATOR_PATH,
|
|
198
|
+
ADB_PATH
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async function checkEmulator(ADB_PATH) {
|
|
202
|
+
try {
|
|
203
|
+
const devices = (0, _utils.runCommand)(`${ADB_PATH} devices`);
|
|
204
|
+
return devices.includes("emulator");
|
|
205
|
+
} catch (error) {
|
|
206
|
+
progress.log(`Error checking emulator: ${error}`, "error");
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async function startEmulator(EMULATOR_PATH, androidConfig) {
|
|
211
|
+
progress.log(`Starting emulator: ${androidConfig.emulatorName}...`);
|
|
212
|
+
// nosemgrep: javascript.lang.security.detect-child-process.detect-child-process - EMULATOR_PATH is derived from SDK configuration and emulatorName is local native setup config.
|
|
213
|
+
// eslint-disable-next-line security/detect-child-process
|
|
214
|
+
(0, _child_process.exec)(`${EMULATOR_PATH} -avd ${androidConfig.emulatorName} -read-only > /dev/null &`, error => {
|
|
215
|
+
if (error) {
|
|
216
|
+
progress.log(`Error starting emulator: ${error}`, "error");
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
async function updateLocalProperties(sdkPath) {
|
|
221
|
+
progress.start("properties");
|
|
222
|
+
try {
|
|
223
|
+
(0, _utils.runCommand)(`cd ${pwd}/androidProject && ./gradlew updateSdkPath -PsdkPath="${sdkPath}"`);
|
|
224
|
+
progress.log("Updated local.properties successfully", "success");
|
|
225
|
+
progress.complete("properties");
|
|
226
|
+
} catch (error) {
|
|
227
|
+
progress.fail("properties", `Failed to update local.properties: ${error.message}`);
|
|
228
|
+
throw error;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
async function setupAndroidEnvironment() {
|
|
232
|
+
try {
|
|
233
|
+
await validateJavaEnvironment();
|
|
234
|
+
progress.start("config");
|
|
235
|
+
await initializeConfig();
|
|
236
|
+
const config = await (0, _utils.validateAndCompleteConfig)("android", configPath);
|
|
237
|
+
progress.complete("config");
|
|
238
|
+
progress.start("androidTools");
|
|
239
|
+
const {
|
|
240
|
+
EMULATOR_PATH,
|
|
241
|
+
ADB_PATH
|
|
242
|
+
} = validateAndroidTools(config.android);
|
|
243
|
+
progress.complete("androidTools");
|
|
244
|
+
progress.start("emulator");
|
|
245
|
+
const emulatorRunning = await checkEmulator(ADB_PATH);
|
|
246
|
+
if (!emulatorRunning) {
|
|
247
|
+
progress.log("No emulator running, attempting to start one...");
|
|
248
|
+
await startEmulator(EMULATOR_PATH, config.android);
|
|
249
|
+
} else {
|
|
250
|
+
progress.log("Emulator already running, proceeding with installation...", "success");
|
|
251
|
+
}
|
|
252
|
+
progress.complete("emulator");
|
|
253
|
+
if (config.android?.sdkPath) {
|
|
254
|
+
await updateLocalProperties(config.android.sdkPath);
|
|
255
|
+
}
|
|
256
|
+
progress.start("saveConfig");
|
|
257
|
+
await saveConfig({
|
|
258
|
+
WEBVIEW_CONFIG: config
|
|
259
|
+
});
|
|
260
|
+
progress.complete("saveConfig");
|
|
261
|
+
progress.start("setupServer");
|
|
262
|
+
await (0, _setupServer.setupServer)(configPath);
|
|
263
|
+
progress.complete("setupServer");
|
|
264
|
+
progress.printTreeContent("Configuration Explanation", ["WEBVIEW_CONFIG: Main configuration object for the WebView setup", {
|
|
265
|
+
text: "port: Port number for the WebView server",
|
|
266
|
+
indent: 1,
|
|
267
|
+
prefix: "├─ ",
|
|
268
|
+
color: "gray"
|
|
269
|
+
}, {
|
|
270
|
+
text: "android: Android-specific configuration",
|
|
271
|
+
indent: 1,
|
|
272
|
+
prefix: "└─ ",
|
|
273
|
+
color: "gray"
|
|
274
|
+
}, {
|
|
275
|
+
text: "buildType: Build type (debug/release)",
|
|
276
|
+
indent: 2,
|
|
277
|
+
prefix: "├─ ",
|
|
278
|
+
color: "gray"
|
|
279
|
+
}, {
|
|
280
|
+
text: "sdkPath: Android SDK path",
|
|
281
|
+
indent: 2,
|
|
282
|
+
prefix: "├─ ",
|
|
283
|
+
color: "gray"
|
|
284
|
+
}, {
|
|
285
|
+
text: "emulatorName: Selected Android emulator name",
|
|
286
|
+
indent: 2,
|
|
287
|
+
prefix: "└─ ",
|
|
288
|
+
color: "gray"
|
|
289
|
+
}]);
|
|
290
|
+
progress.printTreeContent("Final Configuration", [JSON.stringify(config, null, 2)]);
|
|
291
|
+
process.exit(0);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
if (progress.currentStep) {
|
|
294
|
+
progress.fail(progress.currentStep.id, error.message);
|
|
295
|
+
}
|
|
296
|
+
process.exit(1);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Execute the main setup
|
|
9
301
|
setupAndroidEnvironment();
|