@jxrstudios/jxr 1.2.28 → 1.2.29
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/README.md +2 -2
- package/package.json +1 -1
- package/zzz_react_template/const.ts +2 -2
- package/dist/deployer.js +0 -278
- package/dist/deployer.js.map +0 -1
- package/dist/enhanced-transpiler.js +0 -272
- package/dist/enhanced-transpiler.js.map +0 -1
- package/dist/entry-point-detection.js +0 -415
- package/dist/entry-point-detection.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jxr-server-manager.js +0 -453
- package/dist/jxr-server-manager.js.map +0 -1
- package/dist/module-resolver.js +0 -430
- package/dist/module-resolver.js.map +0 -1
- package/dist/moq-transport.js +0 -188
- package/dist/moq-transport.js.map +0 -1
- package/dist/runtime.js +0 -150
- package/dist/runtime.js.map +0 -1
- package/dist/web-crypto.js +0 -186
- package/dist/web-crypto.js.map +0 -1
- package/dist/worker-pool.js +0 -238
- package/dist/worker-pool.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# JXR.js — Edge OS Runtime Framework
|
|
1
|
+
# JXR.js — Edge OS Web Runtime Framework
|
|
2
2
|
|
|
3
3
|
> **Execute JavaScript at the edge with zero-build JSX transformation.**
|
|
4
4
|
>
|
|
@@ -748,4 +748,4 @@ MIT License — see [LICENSE](LICENSE) file for details.
|
|
|
748
748
|
<p align="center">
|
|
749
749
|
<strong>Powered by JXR Studios × DamascusAI</strong><br>
|
|
750
750
|
<sub>The edge OS runtime for developers who take their game to the next level.</sub>
|
|
751
|
-
</p>
|
|
751
|
+
</p>
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@ export { COOKIE_NAME, ONE_YEAR_MS } from "@shared/const";
|
|
|
2
2
|
|
|
3
3
|
// Generate login URL at runtime so redirect URI reflects the current origin.
|
|
4
4
|
export const getLoginUrl = () => {
|
|
5
|
-
const oauthPortalUrl = import.meta.env.
|
|
6
|
-
const appId = import.meta.env.
|
|
5
|
+
const oauthPortalUrl = import.meta.env.JXR_OAUTH_PORTAL_URL;
|
|
6
|
+
const appId = import.meta.env.JXR_APP_ID;
|
|
7
7
|
const redirectUri = `${window.location.origin}/api/oauth/callback`;
|
|
8
8
|
const state = btoa(redirectUri);
|
|
9
9
|
|
package/dist/deployer.js
DELETED
|
@@ -1,278 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JXR.js — Wranglerless Deployer
|
|
3
|
-
* Deploy projects to JXR Studios' Cloudflare infrastructure without wrangler.
|
|
4
|
-
* Users only need a JXR API key - no Cloudflare account required.
|
|
5
|
-
*/
|
|
6
|
-
import { readFile, readdir, stat } from "fs/promises";
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { existsSync } from "fs";
|
|
9
|
-
import { spawn } from "child_process";
|
|
10
|
-
/**
|
|
11
|
-
* JXRDeployer — Deploy to JXR Cloudflare infrastructure
|
|
12
|
-
* No wrangler config needed. Just your JXR API key.
|
|
13
|
-
*/
|
|
14
|
-
export class JXRDeployer {
|
|
15
|
-
apiKey;
|
|
16
|
-
projectId;
|
|
17
|
-
constructor(apiKey, projectId) {
|
|
18
|
-
this.apiKey = apiKey;
|
|
19
|
-
this.projectId = projectId || this.generateProjectId();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Auto-detect build output directory
|
|
23
|
-
* Checks dist/, build/, out/, or any directory with index.html
|
|
24
|
-
*/
|
|
25
|
-
async detectBuildDir(projectPath = '.') {
|
|
26
|
-
const possibleDirs = ['dist', 'build', 'out'];
|
|
27
|
-
// Check standard build directories
|
|
28
|
-
for (const dir of possibleDirs) {
|
|
29
|
-
const fullPath = path.resolve(projectPath, dir);
|
|
30
|
-
if (existsSync(fullPath)) {
|
|
31
|
-
// Verify it has index.html
|
|
32
|
-
if (existsSync(path.join(fullPath, 'index.html'))) {
|
|
33
|
-
return fullPath;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Search for any directory with index.html
|
|
38
|
-
try {
|
|
39
|
-
const entries = await readdir(projectPath, { withFileTypes: true });
|
|
40
|
-
for (const entry of entries) {
|
|
41
|
-
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
42
|
-
const dirPath = path.join(projectPath, entry.name);
|
|
43
|
-
if (existsSync(path.join(dirPath, 'index.html'))) {
|
|
44
|
-
return dirPath;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
// Ignore errors
|
|
51
|
-
}
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Detect if running on Cloudflare Pages
|
|
56
|
-
*/
|
|
57
|
-
isCloudflarePages() {
|
|
58
|
-
return process.env.CF_PAGES === '1' || !!process.env.CF_PAGES_URL;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Get project name from package.json or directory
|
|
62
|
-
*/
|
|
63
|
-
async getProjectName(projectPath = '.') {
|
|
64
|
-
// Check CF_PAGES_PROJECT_NAME first
|
|
65
|
-
if (process.env.CF_PAGES_PROJECT_NAME) {
|
|
66
|
-
return process.env.CF_PAGES_PROJECT_NAME;
|
|
67
|
-
}
|
|
68
|
-
// Try to read from package.json
|
|
69
|
-
try {
|
|
70
|
-
const pkgPath = path.join(projectPath, 'package.json');
|
|
71
|
-
const pkgContent = await readFile(pkgPath, 'utf-8');
|
|
72
|
-
const pkg = JSON.parse(pkgContent);
|
|
73
|
-
if (pkg.name) {
|
|
74
|
-
return pkg.name;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
// Ignore errors
|
|
79
|
-
}
|
|
80
|
-
// Fall back to directory name
|
|
81
|
-
return path.basename(path.resolve(projectPath));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Deploy to Cloudflare Pages
|
|
85
|
-
*/
|
|
86
|
-
async deployToCloudflarePages(projectPath = '.', config = {}) {
|
|
87
|
-
const logs = [];
|
|
88
|
-
try {
|
|
89
|
-
// Auto-detect build directory
|
|
90
|
-
const buildDir = await this.detectBuildDir(projectPath);
|
|
91
|
-
if (!buildDir) {
|
|
92
|
-
throw new Error('No build output found. Run "jxr build" first.');
|
|
93
|
-
}
|
|
94
|
-
logs.push(`📁 Build directory: ${buildDir}`);
|
|
95
|
-
// Get project name
|
|
96
|
-
const projectName = await this.getProjectName(projectPath);
|
|
97
|
-
logs.push(`📦 Project: ${projectName}`);
|
|
98
|
-
// Check for manifest
|
|
99
|
-
const manifestPath = path.join(buildDir, 'jxr-manifest.json');
|
|
100
|
-
if (existsSync(manifestPath)) {
|
|
101
|
-
const manifest = JSON.parse(await readFile(manifestPath, 'utf-8'));
|
|
102
|
-
logs.push(`📋 Manifest: ${manifest.platform} platform, ${manifest.files?.length || 0} files`);
|
|
103
|
-
}
|
|
104
|
-
// Determine URL
|
|
105
|
-
const env = config.environment || 'production';
|
|
106
|
-
const url = `https://${projectName}.app.jxrstudios.online`;
|
|
107
|
-
logs.push(`🌐 URL: ${url}`);
|
|
108
|
-
// If running on Cloudflare Pages, the deployment is automatic
|
|
109
|
-
if (this.isCloudflarePages()) {
|
|
110
|
-
logs.push('☁️ Cloudflare Pages auto-detected');
|
|
111
|
-
logs.push('✅ Deployment ready - build output will be deployed automatically');
|
|
112
|
-
return {
|
|
113
|
-
success: true,
|
|
114
|
-
url,
|
|
115
|
-
deploymentId: `cf-pages-${Date.now()}`,
|
|
116
|
-
timestamp: new Date().toISOString(),
|
|
117
|
-
logs,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
// Manual deployment via JXR API
|
|
121
|
-
return await this.deploy(buildDir, { ...config, projectId: projectName });
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
125
|
-
logs.push(`❌ Error: ${errorMsg}`);
|
|
126
|
-
return {
|
|
127
|
-
success: false,
|
|
128
|
-
url: '',
|
|
129
|
-
deploymentId: '',
|
|
130
|
-
timestamp: new Date().toISOString(),
|
|
131
|
-
logs,
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Deploy the current project to JXR infrastructure
|
|
137
|
-
*/
|
|
138
|
-
async deploy(projectPath, config = {}) {
|
|
139
|
-
const env = config.environment || 'production';
|
|
140
|
-
const branch = config.branch || 'main';
|
|
141
|
-
const pid = config.projectId || this.projectId;
|
|
142
|
-
console.log(`🚀 Deploying to JXR ${env}...`);
|
|
143
|
-
const logs = [];
|
|
144
|
-
try {
|
|
145
|
-
// Verify project path exists
|
|
146
|
-
await stat(projectPath);
|
|
147
|
-
logs.push(`📁 Deploying from: ${projectPath}`);
|
|
148
|
-
// Create tarball of build files
|
|
149
|
-
const tarballPath = await this.createTarball(projectPath);
|
|
150
|
-
logs.push(`📦 Created tarball: ${tarballPath}`);
|
|
151
|
-
// Upload tarball
|
|
152
|
-
const uploadResult = await this.uploadTarball(tarballPath, pid, env, branch);
|
|
153
|
-
logs.push(`☁️ Uploaded to JXR`);
|
|
154
|
-
// Get deployment URL
|
|
155
|
-
const url = `https://${pid}.app.jxrstudios.online`;
|
|
156
|
-
logs.push(`🌐 Live at: ${url}`);
|
|
157
|
-
return {
|
|
158
|
-
success: true,
|
|
159
|
-
url,
|
|
160
|
-
deploymentId: uploadResult.deploymentId,
|
|
161
|
-
timestamp: new Date().toISOString(),
|
|
162
|
-
logs,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
catch (error) {
|
|
166
|
-
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
167
|
-
logs.push(`❌ Error: ${errorMsg}`);
|
|
168
|
-
return {
|
|
169
|
-
success: false,
|
|
170
|
-
url: '',
|
|
171
|
-
deploymentId: '',
|
|
172
|
-
timestamp: new Date().toISOString(),
|
|
173
|
-
logs,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Create a tarball of the build directory
|
|
179
|
-
*/
|
|
180
|
-
async createTarball(projectPath) {
|
|
181
|
-
const tarballPath = path.join(process.cwd(), '.jxr-deploy.tar.gz');
|
|
182
|
-
return new Promise((resolve, reject) => {
|
|
183
|
-
const tar = spawn('tar', ['-czf', tarballPath, '-C', projectPath, '.']);
|
|
184
|
-
tar.on('close', (code) => {
|
|
185
|
-
if (code === 0) {
|
|
186
|
-
resolve(tarballPath);
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
reject(new Error(`tar exited with code ${code}`));
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
tar.on('error', reject);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Upload tarball to JXR API
|
|
197
|
-
*/
|
|
198
|
-
async uploadTarball(tarballPath, projectId, environment, branch) {
|
|
199
|
-
const formData = new FormData();
|
|
200
|
-
const fileContent = await readFile(tarballPath);
|
|
201
|
-
const blob = new Blob([fileContent]);
|
|
202
|
-
formData.append('build', blob, 'build.tar.gz');
|
|
203
|
-
formData.append('projectId', projectId);
|
|
204
|
-
formData.append('environment', environment);
|
|
205
|
-
formData.append('branch', branch);
|
|
206
|
-
const response = await fetch('https://jxrstudios.workers.dev/v1/deployments', {
|
|
207
|
-
method: 'POST',
|
|
208
|
-
headers: {
|
|
209
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
210
|
-
},
|
|
211
|
-
body: formData,
|
|
212
|
-
});
|
|
213
|
-
if (!response.ok) {
|
|
214
|
-
throw new Error(`Upload failed: ${response.statusText}`);
|
|
215
|
-
}
|
|
216
|
-
const result = await response.json();
|
|
217
|
-
return { deploymentId: result.deploymentId };
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Get deployment status
|
|
221
|
-
*/
|
|
222
|
-
async getStatus(deploymentId) {
|
|
223
|
-
const response = await fetch(`https://jxrstudios.workers.dev/v1/deployments/${deploymentId}`, {
|
|
224
|
-
headers: {
|
|
225
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
if (!response.ok) {
|
|
229
|
-
throw new Error(`Failed to get status: ${response.statusText}`);
|
|
230
|
-
}
|
|
231
|
-
return response.json();
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* List all deployments for a project
|
|
235
|
-
*/
|
|
236
|
-
async listDeployments(projectId) {
|
|
237
|
-
const pid = projectId || this.projectId;
|
|
238
|
-
const response = await fetch(`https://jxrstudios.workers.dev/v1/projects/${pid}/deployments`, {
|
|
239
|
-
headers: {
|
|
240
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
if (!response.ok) {
|
|
244
|
-
throw new Error(`Failed to list deployments: ${response.statusText}`);
|
|
245
|
-
}
|
|
246
|
-
return response.json();
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Rollback to a previous deployment
|
|
250
|
-
*/
|
|
251
|
-
async rollback(deploymentId) {
|
|
252
|
-
const response = await fetch(`https://jxrstudios.workers.dev/v1/deployments/${deploymentId}/rollback`, {
|
|
253
|
-
method: 'POST',
|
|
254
|
-
headers: {
|
|
255
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
256
|
-
},
|
|
257
|
-
});
|
|
258
|
-
if (!response.ok) {
|
|
259
|
-
throw new Error(`Rollback failed: ${response.statusText}`);
|
|
260
|
-
}
|
|
261
|
-
const result = await response.json();
|
|
262
|
-
return {
|
|
263
|
-
success: true,
|
|
264
|
-
url: result.url,
|
|
265
|
-
deploymentId: result.deploymentId,
|
|
266
|
-
timestamp: new Date().toISOString(),
|
|
267
|
-
logs: ['Rollback successful'],
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
generateProjectId() {
|
|
271
|
-
const timestamp = Date.now().toString(36);
|
|
272
|
-
const random = Math.random().toString(36).substring(2, 8);
|
|
273
|
-
return `jxr-${timestamp}-${random}`;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
/** Global deployer singleton */
|
|
277
|
-
export const jxrDeployer = new JXRDeployer(process.env.JXR_API_KEY || '', process.env.JXR_PROJECT_ID);
|
|
278
|
-
//# sourceMappingURL=deployer.js.map
|
package/dist/deployer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deployer.js","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAqB,UAAU,EAAE,MAAM,IAAI,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAuBtC;;;GAGG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAS;IACf,SAAS,CAAS;IAE1B,YAAY,MAAc,EAAE,SAAkB;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACzD,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,cAAc,CAAC,cAAsB,GAAG;QAC5C,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAE9C,mCAAmC;QACnC,KAAK,MAAM,GAAG,IAAI,YAAY,EAAE,CAAC;YAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;YAChD,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACzB,2BAA2B;gBAC3B,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC;oBAClD,OAAO,QAAQ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MAAM,WAAW,GAAG,IAAI,WAAW,CACxC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,EAC7B,OAAO,CAAC,GAAG,CAAC,cAAc,CAC3B,CAAC"}
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
import * as Babel from "@babel/standalone";
|
|
2
|
-
export class EnhancedTranspiler {
|
|
3
|
-
transformCache = new Map();
|
|
4
|
-
dependencyGraph = new Map();
|
|
5
|
-
options;
|
|
6
|
-
constructor(options = {}) {
|
|
7
|
-
this.options = options;
|
|
8
|
-
}
|
|
9
|
-
transpileTypeScript(code, filename, options = {}) {
|
|
10
|
-
const mergedOptions = { ...this.options, ...options, filename };
|
|
11
|
-
const cacheKey = `${filename}:${code}:${JSON.stringify(mergedOptions)}`;
|
|
12
|
-
if (mergedOptions.cache !== false && this.transformCache.has(cacheKey)) {
|
|
13
|
-
return { ...this.transformCache.get(cacheKey), cached: true };
|
|
14
|
-
}
|
|
15
|
-
try {
|
|
16
|
-
const result = Babel.transform(code, {
|
|
17
|
-
filename,
|
|
18
|
-
presets: [
|
|
19
|
-
["react", { runtime: "automatic" }],
|
|
20
|
-
"typescript",
|
|
21
|
-
...(mergedOptions.presets || [])
|
|
22
|
-
],
|
|
23
|
-
plugins: [
|
|
24
|
-
// Handle import/export transformations - pass filename for context
|
|
25
|
-
this.createImportTransformer(filename),
|
|
26
|
-
...(mergedOptions.plugins || [])
|
|
27
|
-
],
|
|
28
|
-
sourceMaps: true,
|
|
29
|
-
sourceFileName: filename
|
|
30
|
-
});
|
|
31
|
-
const transformed = {
|
|
32
|
-
code: result.code || code,
|
|
33
|
-
map: result.map,
|
|
34
|
-
cached: false
|
|
35
|
-
};
|
|
36
|
-
if (mergedOptions.cache !== false) {
|
|
37
|
-
this.transformCache.set(cacheKey, transformed);
|
|
38
|
-
}
|
|
39
|
-
return transformed;
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error("[EnhancedTranspiler] Transpilation error:", error);
|
|
43
|
-
return {
|
|
44
|
-
code,
|
|
45
|
-
error: error,
|
|
46
|
-
cached: false
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
transpileJSX(code, filename, options = {}) {
|
|
51
|
-
const mergedOptions = { ...this.options, ...options, filename };
|
|
52
|
-
const cacheKey = `jsx:${filename}:${code}:${JSON.stringify(mergedOptions)}`;
|
|
53
|
-
if (mergedOptions.cache !== false && this.transformCache.has(cacheKey)) {
|
|
54
|
-
return { ...this.transformCache.get(cacheKey), cached: true };
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
const result = Babel.transform(code, {
|
|
58
|
-
filename,
|
|
59
|
-
presets: [
|
|
60
|
-
["react", { runtime: "automatic" }],
|
|
61
|
-
...(mergedOptions.presets || [])
|
|
62
|
-
],
|
|
63
|
-
plugins: mergedOptions.plugins || [],
|
|
64
|
-
sourceMaps: true,
|
|
65
|
-
sourceFileName: filename
|
|
66
|
-
});
|
|
67
|
-
console.log('[v0] Transpiled JSX for', filename);
|
|
68
|
-
console.log('[v0] Output (first 500 chars):', result.code?.substring(0, 500));
|
|
69
|
-
const transformed = {
|
|
70
|
-
code: result.code || code,
|
|
71
|
-
map: result.map,
|
|
72
|
-
cached: false
|
|
73
|
-
};
|
|
74
|
-
if (mergedOptions.cache !== false) {
|
|
75
|
-
this.transformCache.set(cacheKey, transformed);
|
|
76
|
-
}
|
|
77
|
-
return transformed;
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
console.error("[EnhancedTranspiler] JSX transformation error:", error);
|
|
81
|
-
return {
|
|
82
|
-
code,
|
|
83
|
-
error: error,
|
|
84
|
-
cached: false
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
createImportTransformer(filename) {
|
|
89
|
-
const self = this;
|
|
90
|
-
return function importTransformer() {
|
|
91
|
-
return {
|
|
92
|
-
visitor: {
|
|
93
|
-
ImportDeclaration(path) {
|
|
94
|
-
const source = path.node.source.value;
|
|
95
|
-
// Skip external packages
|
|
96
|
-
if (!source.startsWith('./') && !source.startsWith('../') && !source.startsWith('@/')) {
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
// Rewrite to absolute path that matches import map
|
|
100
|
-
const resolvedPath = self.resolveImportPath(filename, source);
|
|
101
|
-
if (resolvedPath) {
|
|
102
|
-
console.log(`[Transpiler] Rewriting: ${filename} imports "${source}" → "${resolvedPath}"`);
|
|
103
|
-
path.node.source.value = resolvedPath;
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
ExportNamedDeclaration(path) {
|
|
107
|
-
if (path.node.source) {
|
|
108
|
-
const source = path.node.source.value;
|
|
109
|
-
// Skip external packages
|
|
110
|
-
if (!source.startsWith('./') && !source.startsWith('../') && !source.startsWith('@/')) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const resolvedPath = self.resolveImportPath(filename, source);
|
|
114
|
-
if (resolvedPath) {
|
|
115
|
-
console.log(`[Transpiler] Rewriting export: ${filename} exports from "${source}" → "${resolvedPath}"`);
|
|
116
|
-
path.node.source.value = resolvedPath;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
ExportAllDeclaration(path) {
|
|
121
|
-
if (path.node.source) {
|
|
122
|
-
const source = path.node.source.value;
|
|
123
|
-
// Skip external packages
|
|
124
|
-
if (!source.startsWith('./') && !source.startsWith('../') && !source.startsWith('@/')) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const resolvedPath = self.resolveImportPath(filename, source);
|
|
128
|
-
if (resolvedPath) {
|
|
129
|
-
console.log(`[Transpiler] Rewriting export all: ${filename} exports from "${source}" → "${resolvedPath}"`);
|
|
130
|
-
path.node.source.value = resolvedPath;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
resolveImportPath(fromFile, importPath) {
|
|
139
|
-
// Normalize fromFile - remove leading slash for consistent resolution
|
|
140
|
-
const normalizedFromFile = fromFile.startsWith('/') ? fromFile.substring(1) : fromFile;
|
|
141
|
-
// Handle @/ alias
|
|
142
|
-
if (importPath.startsWith('@/')) {
|
|
143
|
-
// Convert @/components/Button → /src/components/Button (with leading slash)
|
|
144
|
-
return ('/src/' + importPath.substring(2)).replace(/\.(tsx|ts|jsx|js)$/, '');
|
|
145
|
-
}
|
|
146
|
-
// Handle relative imports
|
|
147
|
-
if (importPath.startsWith('./') || importPath.startsWith('../')) {
|
|
148
|
-
// Calculate absolute path from relative import
|
|
149
|
-
const fromDir = normalizedFromFile.split('/').slice(0, -1);
|
|
150
|
-
const importParts = importPath.split('/');
|
|
151
|
-
let currentPath = [...fromDir];
|
|
152
|
-
for (const part of importParts) {
|
|
153
|
-
if (part === '..') {
|
|
154
|
-
currentPath.pop();
|
|
155
|
-
}
|
|
156
|
-
else if (part !== '.') {
|
|
157
|
-
currentPath.push(part);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
// Return absolute path with leading slash and without extension
|
|
161
|
-
return '/' + currentPath.join('/').replace(/\.(tsx|ts|jsx|js)$/, '');
|
|
162
|
-
}
|
|
163
|
-
return null;
|
|
164
|
-
}
|
|
165
|
-
// Track dependencies for cache invalidation
|
|
166
|
-
trackDependencies(filename, dependencies) {
|
|
167
|
-
this.dependencyGraph.set(filename, new Set(dependencies));
|
|
168
|
-
}
|
|
169
|
-
// Invalidate cache entries that depend on changed files
|
|
170
|
-
invalidateCache(changedFiles) {
|
|
171
|
-
const toInvalidate = new Set();
|
|
172
|
-
// Find all entries that depend on changed files
|
|
173
|
-
for (const [file, deps] of this.dependencyGraph) {
|
|
174
|
-
for (const changedFile of changedFiles) {
|
|
175
|
-
if (deps.has(changedFile)) {
|
|
176
|
-
toInvalidate.add(file);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
// Invalidate cache entries
|
|
181
|
-
for (const file of toInvalidate) {
|
|
182
|
-
for (const [key] of this.transformCache) {
|
|
183
|
-
if (key.startsWith(`${file}:`)) {
|
|
184
|
-
this.transformCache.delete(key);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Clear all cache
|
|
190
|
-
clearCache() {
|
|
191
|
-
this.transformCache.clear();
|
|
192
|
-
this.dependencyGraph.clear();
|
|
193
|
-
}
|
|
194
|
-
invalidateFile(filename) {
|
|
195
|
-
// Invalidate cache entries for this file
|
|
196
|
-
for (const key of this.transformCache.keys()) {
|
|
197
|
-
if (key.startsWith(filename)) {
|
|
198
|
-
this.transformCache.delete(key);
|
|
199
|
-
console.log('[Transpiler] Invalidated cache for', filename);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
// Invalidate dependents
|
|
203
|
-
const dependents = this.dependencyGraph.get(filename);
|
|
204
|
-
if (dependents) {
|
|
205
|
-
for (const dependent of dependents) {
|
|
206
|
-
this.invalidateFile(dependent);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
// Get cache statistics
|
|
211
|
-
getCacheStats() {
|
|
212
|
-
return {
|
|
213
|
-
size: this.transformCache.size,
|
|
214
|
-
hitRate: 0 // Could be implemented with usage tracking
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
// Extract dependencies from code for tracking
|
|
218
|
-
extractDependencies(code) {
|
|
219
|
-
const dependencies = [];
|
|
220
|
-
try {
|
|
221
|
-
// Simple regex-based dependency extraction for browser compatibility
|
|
222
|
-
// Import statements: import ... from 'module'
|
|
223
|
-
const importRegex = /import\s+(?:[\w\s{},*]*\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
224
|
-
let match;
|
|
225
|
-
while ((match = importRegex.exec(code)) !== null) {
|
|
226
|
-
dependencies.push(match[1]);
|
|
227
|
-
}
|
|
228
|
-
// Export statements: export ... from 'module'
|
|
229
|
-
const exportRegex = /export\s+(?:[\w\s{},*]*\s+from\s+)?['"]([^'"]+)['"]/g;
|
|
230
|
-
while ((match = exportRegex.exec(code)) !== null) {
|
|
231
|
-
dependencies.push(match[1]);
|
|
232
|
-
}
|
|
233
|
-
// Dynamic imports: import('module')
|
|
234
|
-
const dynamicImportRegex = /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
235
|
-
while ((match = dynamicImportRegex.exec(code)) !== null) {
|
|
236
|
-
dependencies.push(match[1]);
|
|
237
|
-
}
|
|
238
|
-
// Require statements: require('module')
|
|
239
|
-
const requireRegex = /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
240
|
-
while ((match = requireRegex.exec(code)) !== null) {
|
|
241
|
-
dependencies.push(match[1]);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
catch (error) {
|
|
245
|
-
console.warn('[EnhancedTranspiler] Failed to extract dependencies:', error);
|
|
246
|
-
}
|
|
247
|
-
return [...new Set(dependencies)]; // Remove duplicates
|
|
248
|
-
}
|
|
249
|
-
// Validate transpiled code
|
|
250
|
-
validateTranspiledCode(code) {
|
|
251
|
-
const errors = [];
|
|
252
|
-
try {
|
|
253
|
-
// Basic syntax check
|
|
254
|
-
new Function(code);
|
|
255
|
-
}
|
|
256
|
-
catch (error) {
|
|
257
|
-
errors.push(`Syntax error: ${error.message}`);
|
|
258
|
-
}
|
|
259
|
-
// Check for common issues
|
|
260
|
-
if (code.includes('undefined') && code.includes('import')) {
|
|
261
|
-
errors.push('Possible import resolution issue detected');
|
|
262
|
-
}
|
|
263
|
-
if (code.includes('require(') && !code.includes('module.exports')) {
|
|
264
|
-
errors.push('CommonJS require() detected in ES module');
|
|
265
|
-
}
|
|
266
|
-
return {
|
|
267
|
-
valid: errors.length === 0,
|
|
268
|
-
errors
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
//# sourceMappingURL=enhanced-transpiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file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