catalyst-core-internal 0.1.4 → 0.1.6

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 (43) hide show
  1. package/bin/catalyst.js +1 -8
  2. package/changelog.md +21 -0
  3. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/BridgeMessageValidator.kt +1 -1
  4. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/CustomWebview.kt +1 -12
  5. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/MainActivity.kt +3 -18
  6. package/dist/native/buildAppAndroid.js +2 -2
  7. package/dist/native/buildAppIos.js +17 -10
  8. package/dist/native/iosnativeWebView/Sources/Core/WebView/NativeBridge.swift +2 -13
  9. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebView.swift +0 -6
  10. package/dist/native/iosnativeWebView/iosnativeWebView.xcodeproj/project.pbxproj +0 -4
  11. package/mcp_v2/conversion-tasks.json +326 -0
  12. package/mcp_v2/knowledge-base.json +1068 -0
  13. package/mcp_v2/lib/helpers.js +170 -0
  14. package/mcp_v2/mcp.js +563 -0
  15. package/mcp_v2/package.json +13 -0
  16. package/mcp_v2/schema.sql +88 -0
  17. package/mcp_v2/setup.js +282 -0
  18. package/mcp_v2/tools/build.js +686 -0
  19. package/mcp_v2/tools/config.js +453 -0
  20. package/mcp_v2/tools/conversion.js +799 -0
  21. package/mcp_v2/tools/debug.js +113 -0
  22. package/mcp_v2/tools/knowledge.js +219 -0
  23. package/mcp_v2/tools/sync.js +23 -0
  24. package/mcp_v2/tools/tasks.js +945 -0
  25. package/package.json +7 -15
  26. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/CatalystPlugin.kt +0 -7
  27. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/GeneratedPluginIndex.kt +0 -6
  28. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/plugins/PluginBridge.kt +0 -253
  29. package/dist/native/androidProject/app/src/test/java/io/yourname/androidproject/plugins/PluginBridgeTest.kt +0 -139
  30. package/dist/native/internal-plugins/device-info-plugin/android/DeviceInfoPlugin.kt +0 -43
  31. package/dist/native/internal-plugins/device-info-plugin/ios/DeviceInfoPlugin.swift +0 -28
  32. package/dist/native/internal-plugins/device-info-plugin/manifest.json +0 -19
  33. package/dist/native/internalPluginUtils.js +0 -1
  34. package/dist/native/iosnativeWebView/Sources/Core/Plugins/CatalystPlugin.swift +0 -5
  35. package/dist/native/iosnativeWebView/Sources/Core/Plugins/GeneratedPluginIndex.swift +0 -6
  36. package/dist/native/iosnativeWebView/Sources/Core/Plugins/PluginBridge.swift +0 -364
  37. package/dist/native/iosnativeWebView/Sources/Core/WebView/WeakScriptMessageHandler.swift +0 -14
  38. package/dist/native/iosnativeWebView/iosnativeWebViewTests/PluginBridgeTests.swift +0 -160
  39. package/dist/native/plugin-bridge/PluginBridge.js +0 -1
  40. package/dist/native/pluginComposerAndroid.js +0 -9
  41. package/dist/native/pluginComposerIos.js +0 -7
  42. package/dist/scripts/plugins.js +0 -1
  43. package/license +0 -10
@@ -0,0 +1,170 @@
1
+ "use strict"
2
+ const fs = require("fs")
3
+ const path = require("path")
4
+ const supportedCatalystPackages = ["catalyst-core", "catalyst-core-internal"]
5
+
6
+ /**
7
+ * Parse a semver-like version string into comparable parts.
8
+ * Handles: "0.0.3-canary.3", "0.1.0-canary.4", "^0.1.0-canary.4"
9
+ * Returns { major, minor, patch, pre, preNum } or null if unparseable.
10
+ */
11
+ function parseVersion(v) {
12
+ if (!v) return null
13
+ const clean = v.replace(/^[\^~]/, "")
14
+ const m = clean.match(/^(\d+)\.(\d+)\.(\d+)(?:-(\w+)\.(\d+))?/)
15
+ if (!m) return null
16
+ return {
17
+ major: +m[1],
18
+ minor: +m[2],
19
+ patch: +m[3],
20
+ pre: m[4] || null,
21
+ preNum: m[5] ? +m[5] : 0,
22
+ raw: clean,
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Returns true if version a is older than version b.
28
+ * Only works for matching pre-release labels (e.g. both "canary").
29
+ */
30
+ function versionOlderThan(a, b) {
31
+ const pa = parseVersion(a)
32
+ const pb = parseVersion(b)
33
+ if (!pa || !pb) return false
34
+ if (pa.major !== pb.major) return pa.major < pb.major
35
+ if (pa.minor !== pb.minor) return pa.minor < pb.minor
36
+ if (pa.patch !== pb.patch) return pa.patch < pb.patch
37
+ if (pa.pre && pb.pre && pa.pre === pb.pre) return pa.preNum < pb.preNum
38
+ return false
39
+ }
40
+
41
+ /**
42
+ * Walk up the directory tree looking for a package.json that depends on Catalyst.
43
+ * Returns { dir, pkg, catalystPackageName, catalystVersion, installedVersion, versionMeta } or null.
44
+ */
45
+ function findCatalystRoot() {
46
+ // Walk up from __dirname first (mcp always lives inside the project at .catalyst/mcp/),
47
+ // then fall back to cwd. This ensures the right root is found regardless of what
48
+ // cwd the editor/IDE sets when spawning the MCP process.
49
+ const startDirs = [path.resolve(__dirname, "..", ".."), process.cwd()]
50
+
51
+ for (const start of startDirs) {
52
+ let dir = start
53
+ while (dir !== path.parse(dir).root) {
54
+ const pkgPath = path.join(dir, "package.json")
55
+ if (fs.existsSync(pkgPath)) {
56
+ try {
57
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"))
58
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies }
59
+ const catalystPackageName = supportedCatalystPackages.find(
60
+ (packageName) => deps[packageName]
61
+ )
62
+ if (catalystPackageName) {
63
+ const nmPath = path.join(dir, "node_modules", catalystPackageName)
64
+ const installed = fs.existsSync(nmPath)
65
+ // Read the actual installed version from node_modules
66
+ let installedVersion = null
67
+ if (installed) {
68
+ try {
69
+ const nmPkg = JSON.parse(
70
+ fs.readFileSync(path.join(nmPath, "package.json"), "utf8")
71
+ )
72
+ installedVersion = nmPkg.version || null
73
+ } catch {
74
+ /* ignore */
75
+ }
76
+ }
77
+ const declaredRef = deps[catalystPackageName]
78
+ const isGithubRef = declaredRef.startsWith("github:") || declaredRef.includes("#")
79
+ return {
80
+ dir,
81
+ pkg,
82
+ catalystPackageName,
83
+ catalystVersion: declaredRef, // what package.json says (may be github ref)
84
+ installedVersion, // what's actually in node_modules e.g. "0.0.3-canary.3"
85
+ notInstalled: !installed,
86
+ versionMeta: {
87
+ declaredRef,
88
+ isGithubRef,
89
+ installedVersion,
90
+ parsed: parseVersion(installedVersion),
91
+ },
92
+ }
93
+ }
94
+ } catch {
95
+ // Malformed package.json — skip, keep walking up
96
+ }
97
+ }
98
+ dir = path.dirname(dir)
99
+ }
100
+ }
101
+ return null
102
+ }
103
+
104
+ /**
105
+ * File-system helpers scoped to a project root.
106
+ */
107
+ function makeProjectHelpers(root) {
108
+ function fileExists(rel) {
109
+ return fs.existsSync(path.join(root, rel))
110
+ }
111
+
112
+ function readJson(rel) {
113
+ try {
114
+ return JSON.parse(fs.readFileSync(path.join(root, rel), "utf8"))
115
+ } catch {
116
+ return null
117
+ }
118
+ }
119
+
120
+ function readText(rel) {
121
+ try {
122
+ return fs.readFileSync(path.join(root, rel), "utf8")
123
+ } catch {
124
+ return null
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Walk src/**\/*.{js,jsx,ts,tsx} and return relative paths that match pattern.
130
+ */
131
+ function grepSrc(pattern) {
132
+ const re = new RegExp(pattern)
133
+ const matches = []
134
+ function walk(dir) {
135
+ let entries
136
+ try {
137
+ entries = fs.readdirSync(dir, { withFileTypes: true })
138
+ } catch {
139
+ return
140
+ }
141
+ for (const e of entries) {
142
+ if (e.name === "node_modules" || e.name === ".git") continue
143
+ const full = path.join(dir, e.name)
144
+ if (e.isDirectory()) {
145
+ walk(full)
146
+ } else if (/\.(js|jsx|ts|tsx)$/.test(e.name)) {
147
+ try {
148
+ if (re.test(fs.readFileSync(full, "utf8"))) {
149
+ matches.push(path.relative(root, full))
150
+ }
151
+ } catch {
152
+ // Ignore unreadable files during source scan.
153
+ }
154
+ }
155
+ }
156
+ }
157
+ walk(path.join(root, "src"))
158
+ return matches
159
+ }
160
+
161
+ return { fileExists, readJson, readText, grepSrc }
162
+ }
163
+
164
+ module.exports = {
165
+ findCatalystRoot,
166
+ makeProjectHelpers,
167
+ versionOlderThan,
168
+ parseVersion,
169
+ supportedCatalystPackages,
170
+ }