openmagic 0.14.1 → 0.15.0
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/cli.js +26 -12
- package/dist/cli.js.map +1 -1
- package/dist/toolbar/index.global.js +1 -1
- package/dist/toolbar/index.global.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1356,16 +1356,17 @@ async function handleLlmChat(params, onChunk, onDone, onError) {
|
|
|
1356
1356
|
}
|
|
1357
1357
|
|
|
1358
1358
|
// src/server.ts
|
|
1359
|
-
var VERSION = "0.
|
|
1359
|
+
var VERSION = "0.15.0";
|
|
1360
1360
|
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
1361
1361
|
function attachOpenMagic(httpServer, roots) {
|
|
1362
1362
|
function handleRequest(req, res) {
|
|
1363
1363
|
if (!req.url?.startsWith("/__openmagic__/")) return false;
|
|
1364
|
-
|
|
1364
|
+
const urlPath = req.url.split("?")[0];
|
|
1365
|
+
if (urlPath === "/__openmagic__/toolbar.js") {
|
|
1365
1366
|
serveToolbarBundle(res);
|
|
1366
1367
|
return true;
|
|
1367
1368
|
}
|
|
1368
|
-
if (
|
|
1369
|
+
if (urlPath === "/__openmagic__/health") {
|
|
1369
1370
|
res.writeHead(200, {
|
|
1370
1371
|
"Content-Type": "application/json",
|
|
1371
1372
|
"Access-Control-Allow-Origin": "*"
|
|
@@ -1604,12 +1605,15 @@ function serveToolbarBundle(res) {
|
|
|
1604
1605
|
function createProxyServer(targetHost, targetPort, roots) {
|
|
1605
1606
|
const proxy = httpProxy.createProxyServer({
|
|
1606
1607
|
target: `http://${targetHost}:${targetPort}`,
|
|
1607
|
-
ws: true,
|
|
1608
1608
|
selfHandleResponse: true
|
|
1609
|
+
// ws: false — we handle WebSocket upgrades manually in server.on("upgrade")
|
|
1609
1610
|
});
|
|
1610
1611
|
const token = getSessionToken();
|
|
1611
|
-
proxy.on("proxyReq", (proxyReq) => {
|
|
1612
|
-
|
|
1612
|
+
proxy.on("proxyReq", (proxyReq, req) => {
|
|
1613
|
+
const accept = req.headers.accept || "";
|
|
1614
|
+
if (accept.includes("text/html") || accept.includes("*/*") || !accept) {
|
|
1615
|
+
proxyReq.removeHeader("Accept-Encoding");
|
|
1616
|
+
}
|
|
1613
1617
|
});
|
|
1614
1618
|
proxy.on("proxyRes", (proxyRes, req, res) => {
|
|
1615
1619
|
const contentType = proxyRes.headers["content-type"] || "";
|
|
@@ -1702,14 +1706,10 @@ var COMMON_DEV_PORTS = [
|
|
|
1702
1706
|
// Vue CLI, generic
|
|
1703
1707
|
8e3,
|
|
1704
1708
|
// Django, Python
|
|
1705
|
-
8888,
|
|
1706
|
-
// Jupyter, generic
|
|
1707
1709
|
3001,
|
|
1708
1710
|
// Common alternate
|
|
1709
1711
|
4e3,
|
|
1710
1712
|
// Phoenix, generic
|
|
1711
|
-
5e3,
|
|
1712
|
-
// Flask
|
|
1713
1713
|
1234,
|
|
1714
1714
|
// Parcel
|
|
1715
1715
|
4321,
|
|
@@ -1718,8 +1718,12 @@ var COMMON_DEV_PORTS = [
|
|
|
1718
1718
|
// Remix
|
|
1719
1719
|
8081,
|
|
1720
1720
|
// Metro (React Native)
|
|
1721
|
-
9e3
|
|
1721
|
+
9e3,
|
|
1722
1722
|
// generic
|
|
1723
|
+
8888,
|
|
1724
|
+
// Jupyter, generic
|
|
1725
|
+
5e3
|
|
1726
|
+
// Flask (last — macOS AirPlay also uses 5000)
|
|
1723
1727
|
];
|
|
1724
1728
|
function checkPort(port, host = "127.0.0.1") {
|
|
1725
1729
|
return new Promise((resolve3) => {
|
|
@@ -1739,6 +1743,16 @@ function checkPort(port, host = "127.0.0.1") {
|
|
|
1739
1743
|
});
|
|
1740
1744
|
}
|
|
1741
1745
|
async function detectDevServer() {
|
|
1746
|
+
const scripts = detectDevScripts();
|
|
1747
|
+
const scriptPorts = scripts.map((s) => s.defaultPort).filter((p, i, a) => a.indexOf(p) === i);
|
|
1748
|
+
if (scriptPorts.length > 0) {
|
|
1749
|
+
for (const port of scriptPorts) {
|
|
1750
|
+
if (await checkPort(port)) {
|
|
1751
|
+
return { port, host: "127.0.0.1" };
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
return null;
|
|
1755
|
+
}
|
|
1742
1756
|
const checks = COMMON_DEV_PORTS.map(async (port) => {
|
|
1743
1757
|
const isOpen = await checkPort(port);
|
|
1744
1758
|
return isOpen ? port : null;
|
|
@@ -1861,7 +1875,7 @@ process.on("uncaughtException", (err) => {
|
|
|
1861
1875
|
process.exit(1);
|
|
1862
1876
|
});
|
|
1863
1877
|
var childProcesses = [];
|
|
1864
|
-
var VERSION2 = "0.
|
|
1878
|
+
var VERSION2 = "0.15.0";
|
|
1865
1879
|
function ask(question) {
|
|
1866
1880
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
1867
1881
|
return new Promise((resolve3) => {
|