@jxrstudios/jxr 1.2.19 → 1.2.21
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/dist/deployer.d.ts +83 -0
- package/dist/deployer.d.ts.map +1 -0
- package/dist/deployer.js +278 -0
- package/dist/deployer.js.map +1 -0
- package/dist/enhanced-transpiler.d.ts +36 -0
- package/dist/enhanced-transpiler.d.ts.map +1 -0
- package/dist/enhanced-transpiler.js +272 -0
- package/dist/enhanced-transpiler.js.map +1 -0
- package/dist/entry-point-detection.d.ts +22 -0
- package/dist/entry-point-detection.d.ts.map +1 -0
- package/dist/entry-point-detection.js +415 -0
- package/dist/entry-point-detection.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2315 -0
- package/dist/index.js.map +1 -0
- package/dist/jxr-server-manager.d.ts +32 -0
- package/dist/jxr-server-manager.d.ts.map +1 -0
- package/dist/jxr-server-manager.js +453 -0
- package/dist/jxr-server-manager.js.map +1 -0
- package/dist/module-resolver.d.ts +115 -0
- package/dist/module-resolver.d.ts.map +1 -0
- package/dist/module-resolver.js +430 -0
- package/dist/module-resolver.js.map +1 -0
- package/dist/moq-transport.d.ts +96 -0
- package/dist/moq-transport.d.ts.map +1 -0
- package/dist/moq-transport.js +188 -0
- package/dist/moq-transport.js.map +1 -0
- package/dist/runtime.d.ts +70 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +150 -0
- package/dist/runtime.js.map +1 -0
- package/dist/web-crypto.d.ts +77 -0
- package/dist/web-crypto.d.ts.map +1 -0
- package/dist/web-crypto.js +186 -0
- package/dist/web-crypto.js.map +1 -0
- package/dist/worker-pool.d.ts +83 -0
- package/dist/worker-pool.d.ts.map +1 -0
- package/dist/worker-pool.js +238 -0
- package/dist/worker-pool.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uBAAuB;AACvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAQ9C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAGvD,OAAO,EACL,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGtD,aAAa;AACb,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG9D,wBAAwB;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAGpE,iBAAiB;AACjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,WAAW;AACX,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AA+CzD,MAAM,UAAU,YAAY,CAAC,MAAiB;IAC5C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface JXRServerConfig {
|
|
2
|
+
port?: number;
|
|
3
|
+
host?: string;
|
|
4
|
+
srcDir?: string;
|
|
5
|
+
enableHMR?: boolean;
|
|
6
|
+
debounceMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare class JXRServerManager {
|
|
9
|
+
private runtime;
|
|
10
|
+
private transpiler;
|
|
11
|
+
private server;
|
|
12
|
+
private config;
|
|
13
|
+
private projectFiles;
|
|
14
|
+
private entryPoint;
|
|
15
|
+
private watchers;
|
|
16
|
+
private debounceTimer;
|
|
17
|
+
private pendingChanges;
|
|
18
|
+
private clients;
|
|
19
|
+
constructor(config?: JXRServerConfig);
|
|
20
|
+
initialize(): Promise<void>;
|
|
21
|
+
private loadProjectFiles;
|
|
22
|
+
private setupEntryPoint;
|
|
23
|
+
private startFileWatching;
|
|
24
|
+
private handleFileChange;
|
|
25
|
+
private scheduleReload;
|
|
26
|
+
private processPendingChanges;
|
|
27
|
+
private broadcastReload;
|
|
28
|
+
start(): Promise<void>;
|
|
29
|
+
stop(): Promise<void>;
|
|
30
|
+
private generateHTML;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=jxr-server-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jxr-server-manager.d.ts","sourceRoot":"","sources":["../src/jxr-server-manager.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,OAAO,CAAa;IAC5B,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,QAAQ,CAAoD;IACpE,OAAO,CAAC,aAAa,CAA+B;IACpD,OAAO,CAAC,cAAc,CAAuC;IAC7D,OAAO,CAAC,OAAO,CAAuC;gBAE1C,MAAM,GAAE,eAAoB;IAYlC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YASnB,gBAAgB;IAoC9B,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,iBAAiB;IAsBzB,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,cAAc;YAUR,qBAAqB;IA2BnC,OAAO,CAAC,eAAe;IAOjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAmLtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA+B3B,OAAO,CAAC,YAAY;CAsHrB"}
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { readFile, readdir, watch } from "fs/promises";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import http from "http";
|
|
4
|
+
import { JXRRuntime, findOrCreateEntryPoint, EnhancedTranspiler } from "./index.ts";
|
|
5
|
+
export class JXRServerManager {
|
|
6
|
+
runtime;
|
|
7
|
+
transpiler;
|
|
8
|
+
server = null;
|
|
9
|
+
config;
|
|
10
|
+
projectFiles = [];
|
|
11
|
+
entryPoint = "src/App.tsx";
|
|
12
|
+
watchers = new Map();
|
|
13
|
+
debounceTimer = null;
|
|
14
|
+
pendingChanges = new Map();
|
|
15
|
+
clients = new Set();
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
this.config = {
|
|
18
|
+
port: config.port || 3000,
|
|
19
|
+
host: config.host || "localhost",
|
|
20
|
+
srcDir: config.srcDir || "src",
|
|
21
|
+
enableHMR: config.enableHMR !== false,
|
|
22
|
+
debounceMs: config.debounceMs || 300,
|
|
23
|
+
};
|
|
24
|
+
this.runtime = new JXRRuntime();
|
|
25
|
+
this.transpiler = new EnhancedTranspiler();
|
|
26
|
+
}
|
|
27
|
+
async initialize() {
|
|
28
|
+
await this.runtime.init();
|
|
29
|
+
await this.loadProjectFiles();
|
|
30
|
+
this.setupEntryPoint();
|
|
31
|
+
if (this.config.enableHMR) {
|
|
32
|
+
this.startFileWatching();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async loadProjectFiles() {
|
|
36
|
+
const srcPath = path.resolve(process.cwd(), this.config.srcDir);
|
|
37
|
+
this.projectFiles = [];
|
|
38
|
+
async function readDirRecursive(dir, base, files, runtime) {
|
|
39
|
+
for (const entry of await readdir(dir, { withFileTypes: true })) {
|
|
40
|
+
const fullPath = path.join(dir, entry.name);
|
|
41
|
+
const relativePath = path.join(base, entry.name);
|
|
42
|
+
if (entry.isDirectory()) {
|
|
43
|
+
await readDirRecursive(fullPath, relativePath, files, runtime);
|
|
44
|
+
}
|
|
45
|
+
else if (/\.(tsx?|jsx?|css)$/.test(entry.name)) {
|
|
46
|
+
const content = await readFile(fullPath, "utf-8");
|
|
47
|
+
const vfsPath = "/" + relativePath.replace(/\\/g, "/");
|
|
48
|
+
runtime.vfs.write(vfsPath, content);
|
|
49
|
+
files.push({
|
|
50
|
+
id: Math.random().toString(36).slice(2),
|
|
51
|
+
path: relativePath.replace(/\\/g, "/"),
|
|
52
|
+
content,
|
|
53
|
+
language: entry.name.endsWith(".tsx") || entry.name.endsWith(".ts") ? "typescript" : "javascript",
|
|
54
|
+
createdAt: Date.now(),
|
|
55
|
+
updatedAt: Date.now(),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
await readDirRecursive(srcPath, this.config.srcDir, this.projectFiles, this.runtime);
|
|
62
|
+
console.log(`📁 Loaded ${this.projectFiles.length} files into VirtualFS`);
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
console.error("Error loading files:", err);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
setupEntryPoint() {
|
|
69
|
+
const result = findOrCreateEntryPoint(this.projectFiles);
|
|
70
|
+
this.entryPoint = result.entryPoint;
|
|
71
|
+
// If a new entry was created, add it to VFS
|
|
72
|
+
if (result.createdEntry) {
|
|
73
|
+
const entryFile = result.files.find(f => f.path === this.entryPoint);
|
|
74
|
+
if (entryFile) {
|
|
75
|
+
this.runtime.vfs.write("/" + entryFile.path, entryFile.content);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
console.log(`🎯 Entry point: ${this.entryPoint}`);
|
|
79
|
+
}
|
|
80
|
+
startFileWatching() {
|
|
81
|
+
const srcPath = path.resolve(process.cwd(), this.config.srcDir);
|
|
82
|
+
const watchDir = async (dir) => {
|
|
83
|
+
try {
|
|
84
|
+
const watcher = watch(dir, { recursive: true });
|
|
85
|
+
this.watchers.set(dir, watcher);
|
|
86
|
+
for await (const event of watcher) {
|
|
87
|
+
if (event.filename && /\.(tsx?|jsx?|css)$/.test(event.filename)) {
|
|
88
|
+
this.handleFileChange(event.filename);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
console.error(`Watch error for ${dir}:`, err);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
watchDir(srcPath);
|
|
97
|
+
console.log(`👀 Watching ${this.config.srcDir} for changes...`);
|
|
98
|
+
}
|
|
99
|
+
handleFileChange(filename) {
|
|
100
|
+
const fullPath = path.resolve(process.cwd(), this.config.srcDir, filename);
|
|
101
|
+
const relativePath = path.join(this.config.srcDir, filename).replace(/\\/g, "/");
|
|
102
|
+
readFile(fullPath, "utf-8")
|
|
103
|
+
.then(content => {
|
|
104
|
+
const file = {
|
|
105
|
+
id: Math.random().toString(36).slice(2),
|
|
106
|
+
path: relativePath,
|
|
107
|
+
content,
|
|
108
|
+
language: filename.endsWith(".tsx") || filename.endsWith(".ts") ? "typescript" : "javascript",
|
|
109
|
+
createdAt: Date.now(),
|
|
110
|
+
updatedAt: Date.now(),
|
|
111
|
+
};
|
|
112
|
+
this.pendingChanges.set(relativePath, file);
|
|
113
|
+
this.scheduleReload();
|
|
114
|
+
})
|
|
115
|
+
.catch(err => console.error(`Error reading ${filename}:`, err));
|
|
116
|
+
}
|
|
117
|
+
scheduleReload() {
|
|
118
|
+
if (this.debounceTimer) {
|
|
119
|
+
clearTimeout(this.debounceTimer);
|
|
120
|
+
}
|
|
121
|
+
this.debounceTimer = setTimeout(() => {
|
|
122
|
+
this.processPendingChanges();
|
|
123
|
+
}, this.config.debounceMs);
|
|
124
|
+
}
|
|
125
|
+
async processPendingChanges() {
|
|
126
|
+
if (this.pendingChanges.size === 0)
|
|
127
|
+
return;
|
|
128
|
+
console.log(`🔄 Processing ${this.pendingChanges.size} file change(s)...`);
|
|
129
|
+
for (const [path, file] of this.pendingChanges) {
|
|
130
|
+
this.runtime.vfs.write("/" + path, file.content);
|
|
131
|
+
// Update project files array
|
|
132
|
+
const existingIndex = this.projectFiles.findIndex(f => f.path === path);
|
|
133
|
+
if (existingIndex >= 0) {
|
|
134
|
+
this.projectFiles[existingIndex] = file;
|
|
135
|
+
}
|
|
136
|
+
// Invalidate transpiler cache for this file
|
|
137
|
+
this.transpiler.invalidateFile("/" + path);
|
|
138
|
+
console.log(` ✓ Updated: ${path}`);
|
|
139
|
+
}
|
|
140
|
+
this.pendingChanges.clear();
|
|
141
|
+
// Notify connected clients
|
|
142
|
+
this.broadcastReload();
|
|
143
|
+
console.log("🔥 HMR update sent to browser");
|
|
144
|
+
}
|
|
145
|
+
broadcastReload() {
|
|
146
|
+
const message = JSON.stringify({ type: "reload", timestamp: Date.now() });
|
|
147
|
+
this.clients.forEach(client => {
|
|
148
|
+
client.write(`data: ${message}\n\n`);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async start() {
|
|
152
|
+
this.server = http.createServer(async (req, res) => {
|
|
153
|
+
const url = new URL(req.url || "/", `http://${this.config.host}:${this.config.port}`);
|
|
154
|
+
// SSE endpoint for HMR
|
|
155
|
+
if (url.pathname === "/__hmr" && this.config.enableHMR) {
|
|
156
|
+
res.writeHead(200, {
|
|
157
|
+
"Content-Type": "text/event-stream",
|
|
158
|
+
"Cache-Control": "no-cache",
|
|
159
|
+
"Connection": "keep-alive",
|
|
160
|
+
"Access-Control-Allow-Origin": "*",
|
|
161
|
+
});
|
|
162
|
+
this.clients.add(res);
|
|
163
|
+
req.on("close", () => {
|
|
164
|
+
this.clients.delete(res);
|
|
165
|
+
});
|
|
166
|
+
// Send initial connection message
|
|
167
|
+
res.write(`data: ${JSON.stringify({ type: "connected" })}\n\n`);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
// Health check
|
|
171
|
+
if (url.pathname === "/__health") {
|
|
172
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
173
|
+
res.end(JSON.stringify({ status: "ok", runtime: "JXR", version: this.runtime.version }));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
// Serve index.html
|
|
177
|
+
if (url.pathname === "/") {
|
|
178
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
179
|
+
res.end(this.generateHTML());
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
// Serve transformed TSX/TS files (with or without extension)
|
|
183
|
+
if (url.pathname.match(/\.(tsx?|jsx?|ts|js)$/) || url.pathname.startsWith('/src/')) {
|
|
184
|
+
try {
|
|
185
|
+
let vfsPath = url.pathname;
|
|
186
|
+
// Try to resolve the file with various extensions
|
|
187
|
+
let file = this.runtime.vfs.read(vfsPath);
|
|
188
|
+
// If not found and no extension, try adding extensions
|
|
189
|
+
if (!file && !vfsPath.match(/\.(tsx?|jsx?|ts|js|css)$/)) {
|
|
190
|
+
const extensions = ['.tsx', '.ts', '.jsx', '.js', '.css'];
|
|
191
|
+
for (const ext of extensions) {
|
|
192
|
+
file = this.runtime.vfs.read(vfsPath + ext);
|
|
193
|
+
if (file) {
|
|
194
|
+
vfsPath = vfsPath + ext;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (!file) {
|
|
200
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
201
|
+
res.end(`// Module not found: ${url.pathname}`);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
// Serve CSS files as JavaScript that injects the CSS
|
|
205
|
+
if (vfsPath.endsWith('.css')) {
|
|
206
|
+
let cssContent = file.content;
|
|
207
|
+
// Check for pre-compiled Tailwind CSS first
|
|
208
|
+
if (vfsPath === '/src/index.css') {
|
|
209
|
+
try {
|
|
210
|
+
const fs = await import('fs');
|
|
211
|
+
const compiledPath = path.join(process.cwd(), 'src', 'index.compiled.css');
|
|
212
|
+
if (fs.existsSync(compiledPath)) {
|
|
213
|
+
cssContent = fs.readFileSync(compiledPath, 'utf-8');
|
|
214
|
+
console.log(`[JXR] Using pre-compiled Tailwind CSS from index.compiled.css`);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// Try to compile on-the-fly
|
|
218
|
+
const { execSync } = await import('child_process');
|
|
219
|
+
const os = await import('os');
|
|
220
|
+
const tmpDir = os.tmpdir();
|
|
221
|
+
const inputFile = path.join(tmpDir, `jxr-tailwind-${Date.now()}.css`);
|
|
222
|
+
const outputFile = path.join(tmpDir, `jxr-tailwind-${Date.now()}.compiled.css`);
|
|
223
|
+
fs.writeFileSync(inputFile, cssContent);
|
|
224
|
+
try {
|
|
225
|
+
execSync(`npx @tailwindcss/cli -i "${inputFile}" -o "${outputFile}" --minify`, {
|
|
226
|
+
timeout: 30000,
|
|
227
|
+
stdio: 'pipe'
|
|
228
|
+
});
|
|
229
|
+
cssContent = fs.readFileSync(outputFile, 'utf-8');
|
|
230
|
+
fs.unlinkSync(inputFile);
|
|
231
|
+
fs.unlinkSync(outputFile);
|
|
232
|
+
console.log(`[JXR] Compiled Tailwind CSS for ${vfsPath}`);
|
|
233
|
+
}
|
|
234
|
+
catch {
|
|
235
|
+
// CDN fallback
|
|
236
|
+
const js = `
|
|
237
|
+
const tailwindScript = document.createElement('script');
|
|
238
|
+
tailwindScript.src = 'https://cdn.tailwindcss.com';
|
|
239
|
+
tailwindScript.onload = function() {
|
|
240
|
+
const style = document.createElement('style');
|
|
241
|
+
style.textContent = \`${file.content.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$')}\`;
|
|
242
|
+
document.head.appendChild(style);
|
|
243
|
+
};
|
|
244
|
+
document.head.appendChild(tailwindScript);
|
|
245
|
+
export default \`${file.content.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$/g, '\\$')}\`;
|
|
246
|
+
`;
|
|
247
|
+
res.writeHead(200, {
|
|
248
|
+
"Content-Type": "application/javascript",
|
|
249
|
+
"Cache-Control": "no-cache"
|
|
250
|
+
});
|
|
251
|
+
res.end(js);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
catch (error) {
|
|
257
|
+
console.warn(`[JXR] Tailwind handling error: ${error?.message || error}`);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const escapedCSS = cssContent
|
|
261
|
+
.replace(/\\/g, '\\\\')
|
|
262
|
+
.replace(/`/g, '\\`')
|
|
263
|
+
.replace(/\$/g, '\\$');
|
|
264
|
+
const js = `
|
|
265
|
+
const style = document.createElement('style');
|
|
266
|
+
style.textContent = \`${escapedCSS}\`;
|
|
267
|
+
document.head.appendChild(style);
|
|
268
|
+
export default \`${escapedCSS}\`;
|
|
269
|
+
`;
|
|
270
|
+
res.writeHead(200, {
|
|
271
|
+
"Content-Type": "application/javascript",
|
|
272
|
+
"Cache-Control": "no-cache"
|
|
273
|
+
});
|
|
274
|
+
res.end(js);
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Use EnhancedTranspiler (Babel) for proper JSX transformation
|
|
278
|
+
const result = this.transpiler.transpileTypeScript(file.content, vfsPath);
|
|
279
|
+
if (result.error) {
|
|
280
|
+
console.error(`Transform error for ${url.pathname}:`, result.error);
|
|
281
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
282
|
+
res.end(`// Transform error: ${result.error.message}`);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
res.writeHead(200, {
|
|
286
|
+
"Content-Type": "application/javascript",
|
|
287
|
+
"Cache-Control": "no-cache"
|
|
288
|
+
});
|
|
289
|
+
res.end(result.code);
|
|
290
|
+
}
|
|
291
|
+
catch (err) {
|
|
292
|
+
console.error(`Error serving ${url.pathname}:`, err);
|
|
293
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
294
|
+
res.end(`// Error: ${err?.message || String(err)}`);
|
|
295
|
+
}
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
res.writeHead(404);
|
|
299
|
+
res.end("Not found");
|
|
300
|
+
});
|
|
301
|
+
return new Promise((resolve, reject) => {
|
|
302
|
+
this.server.listen(this.config.port, this.config.host, () => {
|
|
303
|
+
console.log(`🚀 JXR server running on http://${this.config.host}:${this.config.port}/`);
|
|
304
|
+
if (this.config.enableHMR) {
|
|
305
|
+
console.log(`🔥 HMR enabled (debounce: ${this.config.debounceMs}ms)`);
|
|
306
|
+
}
|
|
307
|
+
resolve();
|
|
308
|
+
});
|
|
309
|
+
this.server.on("error", reject);
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
async stop() {
|
|
313
|
+
// Stop watchers - we can't easily abort async iterators, but we can clear the map
|
|
314
|
+
// The watch() iterator will naturally stop when the process exits
|
|
315
|
+
this.watchers.clear();
|
|
316
|
+
// Clear any pending timers
|
|
317
|
+
if (this.debounceTimer) {
|
|
318
|
+
clearTimeout(this.debounceTimer);
|
|
319
|
+
this.debounceTimer = null;
|
|
320
|
+
}
|
|
321
|
+
// Close all SSE connections
|
|
322
|
+
this.clients.forEach(client => {
|
|
323
|
+
try {
|
|
324
|
+
client.end();
|
|
325
|
+
}
|
|
326
|
+
catch { }
|
|
327
|
+
});
|
|
328
|
+
this.clients.clear();
|
|
329
|
+
// Close server
|
|
330
|
+
if (this.server) {
|
|
331
|
+
await new Promise((resolve) => {
|
|
332
|
+
this.server.close(() => resolve());
|
|
333
|
+
});
|
|
334
|
+
this.server = null;
|
|
335
|
+
}
|
|
336
|
+
// Dispose runtime
|
|
337
|
+
this.runtime.dispose();
|
|
338
|
+
console.log("👋 JXR server stopped");
|
|
339
|
+
}
|
|
340
|
+
generateHTML() {
|
|
341
|
+
const hmrScript = this.config.enableHMR ? `
|
|
342
|
+
<script>
|
|
343
|
+
// HMR Client
|
|
344
|
+
const evtSource = new EventSource('/__hmr');
|
|
345
|
+
evtSource.onmessage = (e) => {
|
|
346
|
+
const data = JSON.parse(e.data);
|
|
347
|
+
if (data.type === 'reload') {
|
|
348
|
+
console.log('[JXR] Reloading...');
|
|
349
|
+
location.reload();
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
evtSource.onerror = () => console.log('[JXR] HMR connection lost');
|
|
353
|
+
</script>` : '';
|
|
354
|
+
// Import map with react/jsx-runtime for Babel's automatic runtime
|
|
355
|
+
// Includes common dependencies used by JXR projects
|
|
356
|
+
const importMap = {
|
|
357
|
+
"imports": {
|
|
358
|
+
"react": "https://esm.sh/react@19.2.4",
|
|
359
|
+
"react/jsx-runtime": "https://esm.sh/react@19.2.4/jsx-runtime",
|
|
360
|
+
"react/jsx-dev-runtime": "https://esm.sh/react@19.2.4/jsx-dev-runtime",
|
|
361
|
+
"react-dom/client": "https://esm.sh/react-dom@19.2.4/client",
|
|
362
|
+
"wouter": "https://esm.sh/wouter@3.6.0?external=react",
|
|
363
|
+
"lucide-react": "https://esm.sh/lucide-react@0.483.0?external=react",
|
|
364
|
+
"sonner": "https://esm.sh/sonner@2.0.1?external=react",
|
|
365
|
+
"next-themes": "https://esm.sh/next-themes@0.4.6?external=react",
|
|
366
|
+
"@radix-ui/react-dialog": "https://esm.sh/@radix-ui/react-dialog@1.1.6?external=react",
|
|
367
|
+
"@radix-ui/react-tooltip": "https://esm.sh/@radix-ui/react-tooltip@1.1.8?external=react",
|
|
368
|
+
"@radix-ui/react-slot": "https://esm.sh/@radix-ui/react-slot@1.1.2?external=react",
|
|
369
|
+
"@radix-ui/react-primitive": "https://esm.sh/@radix-ui/react-primitive@2.0.2?external=react",
|
|
370
|
+
"@radix-ui/react-compose-refs": "https://esm.sh/@radix-ui/react-compose-refs@1.1.1?external=react",
|
|
371
|
+
"@radix-ui/react-context": "https://esm.sh/@radix-ui/react-context@1.1.1?external=react",
|
|
372
|
+
"@radix-ui/react-use-controllable-state": "https://esm.sh/@radix-ui/react-use-controllable-state@1.1.0?external=react",
|
|
373
|
+
"@radix-ui/react-use-escape-keydown": "https://esm.sh/@radix-ui/react-use-escape-keydown@1.1.0?external=react",
|
|
374
|
+
"@radix-ui/react-use-layout-effect": "https://esm.sh/@radix-ui/react-use-layout-effect@1.1.0?external=react",
|
|
375
|
+
"@radix-ui/react-dismissable-layer": "https://esm.sh/@radix-ui/react-dismissable-layer@1.1.5?external=react",
|
|
376
|
+
"@radix-ui/react-focus-guards": "https://esm.sh/@radix-ui/react-focus-guards@1.1.1?external=react",
|
|
377
|
+
"@radix-ui/react-focus-scope": "https://esm.sh/@radix-ui/react-focus-scope@1.1.2?external=react",
|
|
378
|
+
"@radix-ui/react-portal": "https://esm.sh/@radix-ui/react-portal@1.1.4?external=react",
|
|
379
|
+
"@radix-ui/react-presence": "https://esm.sh/@radix-ui/react-presence@1.1.2?external=react",
|
|
380
|
+
"@radix-ui/react-id": "https://esm.sh/@radix-ui/react-id@1.1.0?external=react",
|
|
381
|
+
"@radix-ui/primitive": "https://esm.sh/@radix-ui/primitive@1.1.1",
|
|
382
|
+
"aria-hidden": "https://esm.sh/aria-hidden@1.2.4",
|
|
383
|
+
"react-remove-scroll": "https://esm.sh/react-remove-scroll@2.6.3?external=react",
|
|
384
|
+
"tslib": "https://esm.sh/tslib@2.8.1",
|
|
385
|
+
"get-nonce": "https://esm.sh/get-nonce@1.0.1",
|
|
386
|
+
"use-callback-ref": "https://esm.sh/use-callback-ref@1.3.3?external=react",
|
|
387
|
+
"use-sidecar": "https://esm.sh/use-sidecar@1.1.3?external=react",
|
|
388
|
+
"detect-node-es": "https://esm.sh/detect-node-es@1.1.0",
|
|
389
|
+
"copy-to-clipboard": "https://esm.sh/copy-to-clipboard@3.3.3",
|
|
390
|
+
"toggle-selection": "https://esm.sh/toggle-selection@1.0.6",
|
|
391
|
+
"clsx": "https://esm.sh/clsx@2.1.1",
|
|
392
|
+
"tailwind-merge": "https://esm.sh/tailwind-merge@3.0.2",
|
|
393
|
+
"class-variance-authority": "https://esm.sh/class-variance-authority@0.7.1",
|
|
394
|
+
"framer-motion": "https://esm.sh/framer-motion@12.5.0?external=react,motion-dom",
|
|
395
|
+
"motion-dom": "https://esm.sh/motion-dom@12.5.0"
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
// Check if we have a main.tsx/bootstrap file - if so, use it directly
|
|
399
|
+
// Otherwise use the component entry point pattern
|
|
400
|
+
const hasMainFile = this.projectFiles.some(f => f.path === 'src/main.tsx' || f.path === 'src/main.ts' ||
|
|
401
|
+
f.path === 'src/index.tsx' || f.path === 'src/index.ts');
|
|
402
|
+
if (hasMainFile) {
|
|
403
|
+
// Use the bootstrap file pattern (like the react template)
|
|
404
|
+
return `<!DOCTYPE html>
|
|
405
|
+
<html lang="en">
|
|
406
|
+
<head>
|
|
407
|
+
<meta charset="UTF-8">
|
|
408
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
409
|
+
<title>JXR.js — Edge OS Runtime Framework</title>
|
|
410
|
+
<meta name="description" content="JXR.js is the next-generation edge runtime framework for React Native and React. MoQ transport, Web Crypto, Worker pools.">
|
|
411
|
+
|
|
412
|
+
<!-- Google Fonts -->
|
|
413
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
414
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
415
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
416
|
+
|
|
417
|
+
<script type="importmap">
|
|
418
|
+
${JSON.stringify(importMap)}
|
|
419
|
+
</script>
|
|
420
|
+
</head>
|
|
421
|
+
<body>
|
|
422
|
+
<div id="root"></div>
|
|
423
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
424
|
+
${hmrScript}
|
|
425
|
+
</body>
|
|
426
|
+
</html>`;
|
|
427
|
+
}
|
|
428
|
+
// Fallback: use component entry point directly
|
|
429
|
+
return `<!DOCTYPE html>
|
|
430
|
+
<html lang="en">
|
|
431
|
+
<head>
|
|
432
|
+
<meta charset="UTF-8">
|
|
433
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
434
|
+
<title>JXR App</title>
|
|
435
|
+
<script type="importmap">
|
|
436
|
+
${JSON.stringify(importMap)}
|
|
437
|
+
</script>
|
|
438
|
+
</head>
|
|
439
|
+
<body>
|
|
440
|
+
<div id="root"></div>
|
|
441
|
+
<script type="module">
|
|
442
|
+
import { createRoot } from 'react-dom/client';
|
|
443
|
+
import App from '/${this.entryPoint}';
|
|
444
|
+
|
|
445
|
+
const root = createRoot(document.getElementById('root'));
|
|
446
|
+
root.render(App());
|
|
447
|
+
</script>
|
|
448
|
+
${hmrScript}
|
|
449
|
+
</body>
|
|
450
|
+
</html>`;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
//# sourceMappingURL=jxr-server-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jxr-server-manager.js","sourceRoot":"","sources":["../src/jxr-server-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAWpF,MAAM,OAAO,gBAAgB;IACnB,OAAO,CAAa;IACpB,UAAU,CAAqB;IAC/B,MAAM,GAAuB,IAAI,CAAC;IAClC,MAAM,CAA4B;IAClC,YAAY,GAAkB,EAAE,CAAC;IACjC,UAAU,GAAW,aAAa,CAAC;IACnC,QAAQ,GAA0C,IAAI,GAAG,EAAE,CAAC;IAC5D,aAAa,GAA0B,IAAI,CAAC;IAC5C,cAAc,GAA6B,IAAI,GAAG,EAAE,CAAC;IACrD,OAAO,GAA6B,IAAI,GAAG,EAAE,CAAC;IAEtD,YAAY,SAA0B,EAAE;QACtC,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI,EAAE,MAAM,CAA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AAC,IAAI,KAAK,aAAa;YACrD,CAAC,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,CAAC,IAAI,KAAK,cAAc,CACxD,CAAC;QAEF,IAAI,WAAW,EAAE,CAAC;YAChB,2DAA2D;YAC3D,OAAO;;;;;;;;;;;;;;MAcP,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;;;;;;IAM3B,SAAS;;QAEL,CAAC;QACL,CAAC;QAED,+CAA+C;QAC/C,OAAO;;;;;;;MAOL,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;;;;;;;wBAOP,IAAI,CAAC,UAAU;;;;;IAKnC,SAAS;;QAEL,CAAC;IACP,CAAC;CACF"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JXR.js — Module Resolver & Virtual File System
|
|
3
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
* Design: LavaFlow OS — Thermal Precision + Edge Command
|
|
5
|
+
* Layer: Core Runtime / Module System
|
|
6
|
+
*
|
|
7
|
+
* Architecture:
|
|
8
|
+
* Zero-build-step module resolution pipeline:
|
|
9
|
+
* 1. VirtualFS: In-memory file system with change notification
|
|
10
|
+
* 2. ModuleResolver: Resolves imports to VirtualFS entries
|
|
11
|
+
* 3. JSXTransformer: Browser-native JSX → JS transform (no Babel/esbuild)
|
|
12
|
+
* 4. ImportMapBuilder: Generates browser-native import maps for esm.sh CDN
|
|
13
|
+
* 5. ModuleCache: LRU cache with crypto integrity verification
|
|
14
|
+
*
|
|
15
|
+
* The resolver produces browser-executable ES modules from JSX/TSX source
|
|
16
|
+
* without any build step, using the esm.sh CDN for npm package resolution.
|
|
17
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
*/
|
|
19
|
+
export interface VirtualFile {
|
|
20
|
+
path: string;
|
|
21
|
+
content: string;
|
|
22
|
+
language: 'tsx' | 'ts' | 'jsx' | 'js' | 'css' | 'json' | 'md' | 'html';
|
|
23
|
+
lastModified: number;
|
|
24
|
+
size: number;
|
|
25
|
+
dirty: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface VirtualDirectory {
|
|
28
|
+
path: string;
|
|
29
|
+
name: string;
|
|
30
|
+
children: (VirtualFile | VirtualDirectory)[];
|
|
31
|
+
expanded: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface ResolvedModule {
|
|
34
|
+
path: string;
|
|
35
|
+
source: string;
|
|
36
|
+
transformed: string;
|
|
37
|
+
objectUrl: string | null;
|
|
38
|
+
dependencies: string[];
|
|
39
|
+
resolvedAt: number;
|
|
40
|
+
transformMs: number;
|
|
41
|
+
}
|
|
42
|
+
export interface ImportMap {
|
|
43
|
+
imports: Record<string, string>;
|
|
44
|
+
scopes?: Record<string, Record<string, string>>;
|
|
45
|
+
}
|
|
46
|
+
type FileChangeHandler = (file: VirtualFile, event: 'create' | 'update' | 'delete') => void;
|
|
47
|
+
/**
|
|
48
|
+
* VirtualFS — In-memory file system with reactive change notifications
|
|
49
|
+
*/
|
|
50
|
+
export declare class VirtualFS {
|
|
51
|
+
private files;
|
|
52
|
+
private changeHandlers;
|
|
53
|
+
constructor(initialFiles?: VirtualFile[]);
|
|
54
|
+
write(path: string, content: string): VirtualFile;
|
|
55
|
+
read(path: string): VirtualFile | null;
|
|
56
|
+
delete(path: string): boolean;
|
|
57
|
+
list(prefix?: string): VirtualFile[];
|
|
58
|
+
exists(path: string): boolean;
|
|
59
|
+
onChange(handler: FileChangeHandler): () => void;
|
|
60
|
+
private emit;
|
|
61
|
+
buildTree(rootPath?: string): VirtualDirectory;
|
|
62
|
+
toJSON(): Record<string, string>;
|
|
63
|
+
private detectLanguage;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* JSXTransformer — Zero-dependency JSX → JS transform
|
|
67
|
+
*
|
|
68
|
+
* Uses a lightweight regex-based transform for simple JSX,
|
|
69
|
+
* with Sucrase-style transforms for production accuracy.
|
|
70
|
+
* Falls back to esm.sh/sucrase for complex transforms.
|
|
71
|
+
*/
|
|
72
|
+
export declare class JSXTransformer {
|
|
73
|
+
private objectUrls;
|
|
74
|
+
/**
|
|
75
|
+
* Transform JSX/TSX source to browser-executable ES module
|
|
76
|
+
* Uses the automatic JSX runtime (React 17+)
|
|
77
|
+
*/
|
|
78
|
+
transform(source: string, filePath: string): string;
|
|
79
|
+
private stripTypeScript;
|
|
80
|
+
private transformJSX;
|
|
81
|
+
private parseProps;
|
|
82
|
+
private rewriteImports;
|
|
83
|
+
createObjectUrl(source: string, type?: string): string;
|
|
84
|
+
revokeObjectUrl(url: string): void;
|
|
85
|
+
cleanup(): void;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* ImportMapBuilder — Generates browser-native import maps
|
|
89
|
+
*/
|
|
90
|
+
export declare class ImportMapBuilder {
|
|
91
|
+
private imports;
|
|
92
|
+
/** Add a package mapping to the import map */
|
|
93
|
+
add(specifier: string, url: string): this;
|
|
94
|
+
/** Add React and common packages */
|
|
95
|
+
addReactDefaults(reactVersion?: string): this;
|
|
96
|
+
build(): ImportMap;
|
|
97
|
+
toScriptTag(): string;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* ModuleCache — LRU cache with integrity verification
|
|
101
|
+
*/
|
|
102
|
+
export declare class ModuleCache {
|
|
103
|
+
private cache;
|
|
104
|
+
private readonly maxSize;
|
|
105
|
+
constructor(maxSize?: number);
|
|
106
|
+
set(path: string, module: ResolvedModule): void;
|
|
107
|
+
get(path: string): ResolvedModule | null;
|
|
108
|
+
invalidate(path: string): void;
|
|
109
|
+
clear(): void;
|
|
110
|
+
get size(): number;
|
|
111
|
+
}
|
|
112
|
+
/** Default project template files */
|
|
113
|
+
export declare const DEFAULT_PROJECT_FILES: VirtualFile[];
|
|
114
|
+
export {};
|
|
115
|
+
//# sourceMappingURL=module-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-resolver.d.ts","sourceRoot":"","sources":["../src/module-resolver.ts"],"names":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