skybridge 0.0.0-dev.f6bca06 → 0.0.0-dev.f727bfa
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 +24 -16
- package/dist/cli/detect-port.d.ts +18 -0
- package/dist/cli/detect-port.js +61 -0
- package/dist/cli/detect-port.js.map +1 -0
- package/dist/cli/header.js +1 -1
- package/dist/cli/header.js.map +1 -1
- package/dist/cli/tunnel-control-server.d.ts +9 -0
- package/dist/cli/tunnel-control-server.js +31 -0
- package/dist/cli/tunnel-control-server.js.map +1 -0
- package/dist/cli/tunnel-control-server.test.js +39 -0
- package/dist/cli/tunnel-control-server.test.js.map +1 -0
- package/dist/cli/tunnel-handler.d.ts +3 -0
- package/dist/cli/tunnel-handler.js +48 -0
- package/dist/cli/tunnel-handler.js.map +1 -0
- package/dist/cli/tunnel-handler.test.js +105 -0
- package/dist/cli/tunnel-handler.test.js.map +1 -0
- package/dist/cli/tunnel.d.ts +57 -0
- package/dist/cli/tunnel.js +154 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/tunnel.test.d.ts +1 -0
- package/dist/cli/tunnel.test.js +190 -0
- package/dist/cli/tunnel.test.js.map +1 -0
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/use-messages.d.ts +3 -0
- package/dist/cli/use-messages.js +11 -0
- package/dist/cli/use-messages.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +2 -6
- package/dist/cli/use-nodemon.js +19 -16
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-tunnel.d.ts +14 -0
- package/dist/cli/use-tunnel.js +131 -0
- package/dist/cli/use-tunnel.js.map +1 -0
- package/dist/cli/use-typescript-check.d.ts +1 -0
- package/dist/cli/use-typescript-check.js +41 -6
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build.js +28 -7
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -1
- package/dist/commands/dev.js +50 -8
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.d.ts +3 -1
- package/dist/commands/start.js +30 -9
- package/dist/commands/start.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.d.ts +5 -6
- package/dist/server/asset-base-url-transform-plugin.js +9 -10
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +41 -13
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/content-helpers.d.ts +27 -0
- package/dist/server/content-helpers.js +46 -0
- package/dist/server/content-helpers.js.map +1 -0
- package/dist/server/content-helpers.test.d.ts +1 -0
- package/dist/server/content-helpers.test.js +70 -0
- package/dist/server/content-helpers.test.js.map +1 -0
- package/dist/server/express.d.ts +13 -3
- package/dist/server/express.js +53 -21
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.d.ts +1 -0
- package/dist/server/express.test.js +348 -0
- package/dist/server/express.test.js.map +1 -0
- package/dist/server/index.d.ts +5 -3
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.d.ts +6 -6
- package/dist/server/metric.d.ts +14 -0
- package/dist/server/metric.js +62 -0
- package/dist/server/metric.js.map +1 -0
- package/dist/server/middleware.d.ts +124 -0
- package/dist/server/middleware.js +93 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/middleware.test-d.d.ts +1 -0
- package/dist/server/middleware.test-d.js +75 -0
- package/dist/server/middleware.test-d.js.map +1 -0
- package/dist/server/middleware.test.d.ts +1 -0
- package/dist/server/middleware.test.js +493 -0
- package/dist/server/middleware.test.js.map +1 -0
- package/dist/server/server.d.ts +133 -69
- package/dist/server/server.js +329 -94
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +5 -6
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates/development.hbs +2 -57
- package/dist/server/templates/production.hbs +1 -1
- package/dist/server/tunnel-proxy-router.d.ts +7 -0
- package/dist/server/tunnel-proxy-router.js +110 -0
- package/dist/server/tunnel-proxy-router.js.map +1 -0
- package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
- package/dist/server/tunnel-proxy-router.test.js +229 -0
- package/dist/server/tunnel-proxy-router.test.js.map +1 -0
- package/dist/server/viewsDevServer.d.ts +14 -0
- package/dist/server/viewsDevServer.js +45 -0
- package/dist/server/viewsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +16 -244
- package/dist/test/utils.js +42 -37
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.d.ts +1 -0
- package/dist/test/view.test.js +523 -0
- package/dist/test/view.test.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +8 -6
- package/dist/web/bridges/apps-sdk/adaptor.js +46 -17
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -1
- package/dist/web/bridges/apps-sdk/bridge.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +24 -13
- package/dist/web/bridges/apps-sdk/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +20 -8
- package/dist/web/bridges/mcp-app/adaptor.js +141 -61
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +13 -30
- package/dist/web/bridges/mcp-app/bridge.js +43 -196
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +2 -2
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +22 -11
- package/dist/web/components/modal-provider.js +3 -5
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.js +17 -3
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +23 -20
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +1 -1
- package/dist/web/data-llm.js +3 -3
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +33 -30
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +20 -18
- package/dist/web/generate-helpers.js +20 -18
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +26 -26
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/helpers/state.d.ts +2 -2
- package/dist/web/helpers/state.js +11 -11
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js +9 -9
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +2 -2
- package/dist/web/hooks/index.js +1 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.js +4 -0
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +3 -3
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
- package/dist/web/hooks/use-display-mode.test-d.js +8 -0
- package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +2 -1
- package/dist/web/hooks/use-files.js +1 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +27 -3
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +3 -3
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.d.ts +3 -1
- package/dist/web/hooks/use-open-external.js +1 -1
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +26 -11
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.d.ts +1 -1
- package/dist/web/hooks/use-request-modal.js +4 -4
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +5 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +5 -11
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.js +18 -2
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +29 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +4 -0
- package/dist/web/hooks/use-view-state.js +32 -0
- package/dist/web/hooks/use-view-state.js.map +1 -0
- package/dist/web/hooks/use-view-state.test.d.ts +1 -0
- package/dist/web/hooks/use-view-state.test.js +177 -0
- package/dist/web/hooks/use-view-state.test.js.map +1 -0
- package/dist/web/index.d.ts +1 -2
- package/dist/web/index.js +1 -2
- package/dist/web/index.js.map +1 -1
- package/dist/web/mount-view.d.ts +1 -0
- package/dist/web/{mount-widget.js → mount-view.js} +2 -2
- package/dist/web/mount-view.js.map +1 -0
- package/dist/web/plugin/plugin.d.ts +4 -1
- package/dist/web/plugin/plugin.js +135 -18
- package/dist/web/plugin/plugin.js.map +1 -1
- package/dist/web/plugin/scan-views.d.ts +16 -0
- package/dist/web/plugin/scan-views.js +88 -0
- package/dist/web/plugin/scan-views.js.map +1 -0
- package/dist/web/plugin/scan-views.test.d.ts +1 -0
- package/dist/web/plugin/scan-views.test.js +99 -0
- package/dist/web/plugin/scan-views.test.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.js +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/web/plugin/validate-view.d.ts +1 -0
- package/dist/web/plugin/validate-view.js +9 -0
- package/dist/web/plugin/validate-view.js.map +1 -0
- package/dist/web/plugin/validate-view.test.d.ts +1 -0
- package/dist/web/plugin/validate-view.test.js +24 -0
- package/dist/web/plugin/validate-view.test.js.map +1 -0
- package/package.json +34 -24
- package/tsconfig.base.json +33 -0
- package/dist/server/widgetsDevServer.d.ts +0 -12
- package/dist/server/widgetsDevServer.js +0 -57
- package/dist/server/widgetsDevServer.js.map +0 -1
- package/dist/test/widget.test.js +0 -261
- package/dist/test/widget.test.js.map +0 -1
- package/dist/web/hooks/use-widget-state.d.ts +0 -4
- package/dist/web/hooks/use-widget-state.js +0 -32
- package/dist/web/hooks/use-widget-state.js.map +0 -1
- package/dist/web/hooks/use-widget-state.test.js +0 -61
- package/dist/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/web/mount-widget.d.ts +0 -1
- package/dist/web/mount-widget.js.map +0 -1
- /package/dist/{test/widget.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
- /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
|
@@ -1,6 +1,24 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { isAbsolute, relative } from "node:path";
|
|
3
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
// TypeScript nests from general to specific — the deepest line is the root cause.
|
|
5
|
+
function extractBestMessage(message, continuationLines) {
|
|
6
|
+
if (!continuationLines.length) {
|
|
7
|
+
return message;
|
|
8
|
+
}
|
|
9
|
+
let maxIndent = 0;
|
|
10
|
+
for (const line of continuationLines) {
|
|
11
|
+
const indent = line.length - line.trimStart().length;
|
|
12
|
+
if (indent > maxIndent) {
|
|
13
|
+
maxIndent = indent;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const deepest = continuationLines
|
|
17
|
+
.filter((l) => l.length - l.trimStart().length === maxIndent)
|
|
18
|
+
.map((l) => l.trim())
|
|
19
|
+
.filter(Boolean)[0];
|
|
20
|
+
return deepest ?? message;
|
|
21
|
+
}
|
|
4
22
|
export function useTypeScriptCheck() {
|
|
5
23
|
const tsProcessRef = useRef(null);
|
|
6
24
|
const [tsErrors, setTsErrors] = useState([]);
|
|
@@ -12,31 +30,48 @@ export function useTypeScriptCheck() {
|
|
|
12
30
|
tsProcessRef.current = tsProcess;
|
|
13
31
|
let outputBuffer = "";
|
|
14
32
|
let currentErrors = [];
|
|
33
|
+
let pendingError = null;
|
|
34
|
+
let continuationLines = [];
|
|
35
|
+
const flushPending = () => {
|
|
36
|
+
if (!pendingError) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
pendingError.message = extractBestMessage(pendingError.message, continuationLines);
|
|
40
|
+
currentErrors.push(pendingError);
|
|
41
|
+
pendingError = null;
|
|
42
|
+
continuationLines = [];
|
|
43
|
+
};
|
|
15
44
|
const processOutput = (data) => {
|
|
16
45
|
outputBuffer += data.toString();
|
|
17
46
|
const lines = outputBuffer.split("\n");
|
|
18
|
-
outputBuffer = lines.pop() || "";
|
|
47
|
+
outputBuffer = lines.pop() || "";
|
|
19
48
|
for (const line of lines) {
|
|
20
49
|
const trimmed = line.trim();
|
|
21
|
-
// Parse TypeScript error format: file.ts(10,5): error TS2322: message
|
|
22
|
-
// Match pattern: filename(line,col): error code: message
|
|
23
50
|
const errorMatch = trimmed.match(/^(.+?)\((\d+),(\d+)\):\s+error\s+(TS\d+)?\s*:?\s*(.+)$/);
|
|
24
51
|
if (errorMatch) {
|
|
25
|
-
|
|
52
|
+
flushPending();
|
|
53
|
+
const [, file, lineStr, colStr, code, message] = errorMatch;
|
|
26
54
|
if (file && lineStr && colStr && message) {
|
|
27
55
|
let cleanFile = file.trim();
|
|
28
56
|
if (isAbsolute(cleanFile)) {
|
|
29
57
|
cleanFile = relative(process.cwd(), cleanFile);
|
|
30
58
|
}
|
|
31
|
-
|
|
59
|
+
pendingError = {
|
|
32
60
|
file: cleanFile,
|
|
33
61
|
line: Number.parseInt(lineStr, 10),
|
|
34
62
|
col: Number.parseInt(colStr, 10),
|
|
63
|
+
code: code ?? "",
|
|
35
64
|
message: message.trim(),
|
|
36
|
-
}
|
|
65
|
+
};
|
|
37
66
|
}
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (pendingError && line.startsWith(" ")) {
|
|
70
|
+
continuationLines.push(line);
|
|
71
|
+
continue;
|
|
38
72
|
}
|
|
39
73
|
if (trimmed.includes("Found") && trimmed.includes("error")) {
|
|
74
|
+
flushPending();
|
|
40
75
|
setTsErrors(trimmed.match(/Found 0 error/) ? [] : [...currentErrors]);
|
|
41
76
|
currentErrors = [];
|
|
42
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-typescript-check.js","sourceRoot":"","sources":["../../src/cli/use-typescript-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"use-typescript-check.js","sourceRoot":"","sources":["../../src/cli/use-typescript-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUpD,kFAAkF;AAClF,SAAS,kBAAkB,CACzB,OAAe,EACf,iBAAgC;IAEhC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAC;QAC9B,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,IAAI,SAAS,GAAG,CAAC,CAAC;I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
2
|
-
import {
|
|
2
|
+
import { rmSync } from "node:fs";
|
|
3
3
|
import { Command } from "@oclif/core";
|
|
4
4
|
import { Box, render, Text } from "ink";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
6
|
import { Header } from "../cli/header.js";
|
|
7
7
|
import { useExecuteSteps } from "../cli/use-execute-steps.js";
|
|
8
|
+
import { scanAndWriteViewsDts } from "../web/plugin/scan-views.js";
|
|
9
|
+
async function resolveViewsDir(root) {
|
|
10
|
+
const { loadConfigFromFile } = await import("vite");
|
|
11
|
+
const loaded = await loadConfigFromFile({ command: "build", mode: "production" }, undefined, root);
|
|
12
|
+
const isPluginCandidate = (value) => typeof value === "object" && value !== null;
|
|
13
|
+
const plugins = [];
|
|
14
|
+
const walk = (value) => {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
value.forEach(walk);
|
|
17
|
+
}
|
|
18
|
+
else if (isPluginCandidate(value)) {
|
|
19
|
+
plugins.push(value);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
walk(loaded?.config.plugins ?? []);
|
|
23
|
+
return plugins.find((p) => p.name === "skybridge")?.api?.viewsDir;
|
|
24
|
+
}
|
|
8
25
|
export const commandSteps = [
|
|
9
26
|
{
|
|
10
|
-
label: "
|
|
11
|
-
|
|
27
|
+
label: "Scanning views",
|
|
28
|
+
run: async () => {
|
|
29
|
+
const root = process.cwd();
|
|
30
|
+
const viewsDir = await resolveViewsDir(root);
|
|
31
|
+
scanAndWriteViewsDts(root, viewsDir);
|
|
32
|
+
},
|
|
12
33
|
},
|
|
13
34
|
{
|
|
14
35
|
label: "Compiling server",
|
|
15
36
|
run: () => rmSync("dist", { recursive: true, force: true }),
|
|
16
|
-
command: "tsc -
|
|
37
|
+
command: "tsc -b --force",
|
|
17
38
|
},
|
|
18
39
|
{
|
|
19
|
-
label: "
|
|
20
|
-
|
|
40
|
+
label: "Building views",
|
|
41
|
+
command: "vite build",
|
|
21
42
|
},
|
|
22
43
|
];
|
|
23
44
|
export default class Build extends Command {
|
|
24
|
-
static description = "Build the
|
|
45
|
+
static description = "Build the views and MCP server";
|
|
25
46
|
static examples = ["skybridge build"];
|
|
26
47
|
static flags = {};
|
|
27
48
|
async run() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAoB,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEnE,KAAK,UAAU,eAAe,CAAC,IAAY;IACzC,MAAM,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,MAAM,GAAG,MAAM,kBAAkB,CACrC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,EACxC,SAAS,EACT,IAAI,CACL,CAAC;IAEF,MAAM,iBAAiB,GAAG,CACxB,KAAc,EAC2C,EAAE,CAC3D,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;IAE9C,MAAM,OAAO,GAA0D,EAAE,CAAC;IAC1E,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE;QAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,KA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AAI,2DAEjB,GACH,CACP,EAEA,MAAM,KAAK,OAAO,IAAI,KAAK,IAAI,CAC9B,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,EAAC,IAAI,0CAEf,EACP,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,YACtC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC/B,KAAC,IAAI,IAAY,KAAK,EAAC,KAAK,YACzB,IAAI,IADI,IAAI,CAER,CACR,CAAC,GACE,IACF,CACP,IACG,CACP,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE;YACd,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC"}
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export default class Dev extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
"
|
|
6
|
+
port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
tunnel: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
9
|
};
|
|
8
10
|
run(): Promise<void>;
|
|
9
11
|
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,31 +1,73 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Command, Flags } from "@oclif/core";
|
|
3
3
|
import { Box, render, Text } from "ink";
|
|
4
|
+
import { resolvePort } from "../cli/detect-port.js";
|
|
4
5
|
import { Header } from "../cli/header.js";
|
|
6
|
+
import { startTunnelControlServer } from "../cli/tunnel-control-server.js";
|
|
7
|
+
import { useMessages } from "../cli/use-messages.js";
|
|
5
8
|
import { useNodemon } from "../cli/use-nodemon.js";
|
|
9
|
+
import { useTunnel } from "../cli/use-tunnel.js";
|
|
6
10
|
import { useTypeScriptCheck } from "../cli/use-typescript-check.js";
|
|
7
11
|
export default class Dev extends Command {
|
|
8
12
|
static description = "Start development server";
|
|
9
13
|
static examples = ["skybridge"];
|
|
10
14
|
static flags = {
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
port: Flags.integer({
|
|
16
|
+
char: "p",
|
|
17
|
+
description: "Port to run the server on",
|
|
18
|
+
min: 1,
|
|
19
|
+
}),
|
|
20
|
+
tunnel: Flags.boolean({
|
|
21
|
+
description: "Open an Alpic tunnel for remote testing",
|
|
22
|
+
default: false,
|
|
23
|
+
}),
|
|
24
|
+
verbose: Flags.boolean({
|
|
25
|
+
char: "v",
|
|
26
|
+
description: "Show tunnel logs",
|
|
27
|
+
default: false,
|
|
13
28
|
}),
|
|
14
29
|
};
|
|
15
30
|
async run() {
|
|
16
31
|
const { flags } = await this.parse(Dev);
|
|
32
|
+
const { port, fallback, envWarning } = await resolvePort(flags.port);
|
|
33
|
+
if (envWarning) {
|
|
34
|
+
this.warn(envWarning);
|
|
35
|
+
}
|
|
36
|
+
const { port: controlPort, manager: tunnelManager, close: closeTunnelControl, } = await startTunnelControlServer(() => port);
|
|
17
37
|
const env = {
|
|
18
38
|
...process.env,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: {}),
|
|
39
|
+
__PORT: String(port),
|
|
40
|
+
__TUNNEL_CONTROL_PORT: String(controlPort),
|
|
22
41
|
};
|
|
23
42
|
const App = () => {
|
|
24
43
|
const tsErrors = useTypeScriptCheck();
|
|
25
|
-
const messages =
|
|
26
|
-
|
|
44
|
+
const [messages, pushMessage] = useMessages();
|
|
45
|
+
useNodemon(env, pushMessage);
|
|
46
|
+
const tunnelState = useTunnel(port, pushMessage, flags.verbose, flags.tunnel);
|
|
47
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDFE0", " "] }), fallback ? (_jsx(Text, { color: "yellow", children: "3000 in use, running on " })) : (_jsx(Text, { children: "Running on " })), _jsx(Text, { color: "green", children: `http://localhost:${port}/mcp` })] }), _jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test locally with DevTools:", " "] }), _jsx(Text, { color: "green", children: `http://localhost:${port}/` })] }), tunnelState.status === "idle" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Get a public URL and LLM Playground access with " }), _jsx(Text, { color: "cyan", bold: true, children: "--tunnel" }), _jsx(Text, { children: "." })] })), tunnelState.status === "starting" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { color: "yellow", children: tunnelState.message })] })), tunnelState.status === "connected" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Exposed on " }), _jsx(Text, { color: "green", children: `${tunnelState.url}/mcp` })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test with an LLM on Playground:", " "] }), _jsx(Text, { color: "green", children: `${tunnelState.url}/try` })] })] })), tunnelState.status === "error" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsxs(Text, { color: "red", children: ["Cannot open tunnel: ", tunnelState.message] })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "red", children: `Try manually: npx alpic tunnel --port ${port}` })] })] })), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83D\uDEDF", " "] }), _jsx(Text, { children: "Need help? Reach us on " }), _jsx(Text, { color: "white", underline: true, children: "https://discord.alpic.ai" })] }), tsErrors.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u26A0\uFE0F TypeScript errors found:" }), tsErrors.map((error) => (_jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "white", children: error.file }), _jsxs(Text, { color: "grey", children: ["(", error.line, ",", error.col, "):", " "] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: error.message }) })] }, `${error.file}:${error.line}:${error.col}`)))] })), messages.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Logs:" }), messages.map((message) => (_jsx(Box, { marginLeft: 2, children: message.type === "restart" ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: "green", children: ["\u2713", " "] }), _jsx(Text, { color: "white", children: message.text })] })) : message.type === "error" ? (_jsx(Text, { color: "red", children: message.text })) : (_jsx(Text, { children: message.text })) }, message.id)))] }))] }));
|
|
48
|
+
};
|
|
49
|
+
// Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee
|
|
50
|
+
// alpic gets killed before we exit. If anything ever calls `useInput` or
|
|
51
|
+
// puts stdin into raw mode, also wire an explicit `\x03` keypress to the
|
|
52
|
+
// shutdown function — Ink will otherwise swallow Ctrl-C without ever
|
|
53
|
+
// delivering SIGINT.
|
|
54
|
+
const ink = render(_jsx(App, {}), { exitOnCtrlC: false, patchConsole: true });
|
|
55
|
+
// Synchronous-first shutdown: kill the alpic subprocess up front so we
|
|
56
|
+
// can't leave it orphaned even if another SIGINT listener (e.g. nodemon's)
|
|
57
|
+
// exits the process before our async cleanup completes.
|
|
58
|
+
const shutdown = (code) => () => {
|
|
59
|
+
tunnelManager.stop();
|
|
60
|
+
void closeTunnelControl()
|
|
61
|
+
.catch((err) => {
|
|
62
|
+
console.error("Failed to close tunnel control server", err);
|
|
63
|
+
})
|
|
64
|
+
.finally(() => {
|
|
65
|
+
ink.unmount();
|
|
66
|
+
process.exit(code);
|
|
67
|
+
});
|
|
27
68
|
};
|
|
28
|
-
|
|
69
|
+
process.once("SIGINT", shutdown(130));
|
|
70
|
+
process.once("SIGTERM", shutdown(143));
|
|
29
71
|
}
|
|
30
72
|
}
|
|
31
73
|
//# sourceMappingURL=dev.js.map
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,OAAO;IACtC,MAAM,CAAU,WAAW,GAAG,0BAA0B,CAAC;IACzD,MAAM,CAAU,QAAQ,GAAG,CAAC,WAAW,CAAC,CAAC;IACzC,MAAM,CAAU,KAAK,GAAG;QACtB,
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAA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O,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC"}
|
package/dist/commands/start.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { Command } from "@oclif/core";
|
|
|
2
2
|
export default class Start extends Command {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
-
static flags: {
|
|
5
|
+
static flags: {
|
|
6
|
+
port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
};
|
|
6
8
|
run(): Promise<void>;
|
|
7
9
|
}
|
package/dist/commands/start.js
CHANGED
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
-
import { Command } from "@oclif/core";
|
|
3
|
+
import { Command, Flags } from "@oclif/core";
|
|
4
|
+
import { resolvePort } from "../cli/detect-port.js";
|
|
4
5
|
import { runCommand } from "../cli/run-command.js";
|
|
5
6
|
export default class Start extends Command {
|
|
6
7
|
static description = "Start production server";
|
|
7
8
|
static examples = ["skybridge start"];
|
|
8
|
-
static flags = {
|
|
9
|
+
static flags = {
|
|
10
|
+
port: Flags.integer({
|
|
11
|
+
char: "p",
|
|
12
|
+
description: "Port to run the server on",
|
|
13
|
+
min: 1,
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
9
16
|
async run() {
|
|
17
|
+
const { flags } = await this.parse(Start);
|
|
18
|
+
const { port, fallback, envWarning } = await resolvePort(flags.port);
|
|
19
|
+
if (envWarning) {
|
|
20
|
+
this.warn(envWarning);
|
|
21
|
+
}
|
|
10
22
|
console.clear();
|
|
11
|
-
const
|
|
12
|
-
if (!existsSync(
|
|
13
|
-
console.error("❌ Error:
|
|
23
|
+
const indexPath = resolve(process.cwd(), "dist/server.js");
|
|
24
|
+
if (!existsSync(indexPath)) {
|
|
25
|
+
console.error("❌ Error: No build output found");
|
|
14
26
|
console.error("");
|
|
15
27
|
console.error("Please build your project first:");
|
|
16
28
|
console.error(" skybridge build");
|
|
17
29
|
console.error("");
|
|
18
30
|
process.exit(1);
|
|
19
31
|
}
|
|
20
|
-
console.log(`\x1b[36m\x1b[1m⛰
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
console.log(`\x1b[36m\x1b[1m⛰ Skybridge\x1b[0m \x1b[36mv${this.config.version}\x1b[0m`);
|
|
33
|
+
if (fallback) {
|
|
34
|
+
console.log(`\x1b[33m3000 in use, running on\x1b[0m \x1b[32mhttp://localhost:${port}/mcp\x1b[0m`);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
console.log(`Running on \x1b[32mhttp://localhost:${port}/mcp\x1b[0m`);
|
|
38
|
+
}
|
|
39
|
+
await runCommand(`node ${indexPath}`, {
|
|
23
40
|
stdio: ["ignore", "inherit", "inherit"],
|
|
24
|
-
env: {
|
|
41
|
+
env: {
|
|
42
|
+
...process.env,
|
|
43
|
+
NODE_ENV: "production",
|
|
44
|
+
__PORT: String(port),
|
|
45
|
+
},
|
|
25
46
|
});
|
|
26
47
|
}
|
|
27
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,KAAK,EAA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CAAC;QAED,OAAO,CAAC,GAAG,CACT,8CAA8C,IAAI,CAAC,MAAM,CAAC,OAAO,SAAS,CAC3E,CAAC;QACF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CACT,mEAAmE,IAAI,aAAa,CACrF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,uCAAuC,IAAI,aAAa,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,UAAU,CAAC,QAAQ,SAAS,EAAE,EAAE;YACpC,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;YACvC,GAAG,EAAE;gBACH,GAAG,OAAO,CAAC,GAAG;gBACd,QAAQ,EAAE,YAAY;gBACtB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;aACrB;SACF,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
2
|
/**
|
|
3
|
-
* Transforms asset import paths to
|
|
3
|
+
* Transforms asset import paths to resolve at runtime via `window.skybridge.serverUrl`,
|
|
4
|
+
* so they work both locally and behind tunnels.
|
|
4
5
|
*/
|
|
5
|
-
export declare function assetBaseUrlTransform(code: string
|
|
6
|
+
export declare function assetBaseUrlTransform(code: string): string;
|
|
6
7
|
/**
|
|
7
|
-
* Vite plugin that transforms asset import paths to
|
|
8
|
+
* Vite plugin that transforms asset import paths to resolve at runtime via `window.skybridge.serverUrl`.
|
|
8
9
|
*/
|
|
9
|
-
export declare function assetBaseUrlTransformPlugin(
|
|
10
|
-
devServerOrigin: string;
|
|
11
|
-
}): Plugin;
|
|
10
|
+
export declare function assetBaseUrlTransformPlugin(): Plugin;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Transforms asset import paths to
|
|
2
|
+
* Transforms asset import paths to resolve at runtime via `window.skybridge.serverUrl`,
|
|
3
|
+
* so they work both locally and behind tunnels.
|
|
3
4
|
*/
|
|
4
|
-
export function assetBaseUrlTransform(code
|
|
5
|
-
const assetStringPattern = /(?<!https?:\/\/)(["'`])(\/[^"'`]+\.(svg|png|jpeg|jpg|gif|webp|mp3|mp4|woff|woff2|ttf|eot))\1/g;
|
|
6
|
-
code = code.replace(assetStringPattern, (_match,
|
|
7
|
-
return
|
|
5
|
+
export function assetBaseUrlTransform(code) {
|
|
6
|
+
const assetStringPattern = /(?<!\bfrom\s)(?<!https?:\/\/)(["'`])(\/[^"'`]+\.(svg|png|jpeg|jpg|gif|webp|mp3|mp4|woff|woff2|ttf|eot))\1/g;
|
|
7
|
+
code = code.replace(assetStringPattern, (_match, _quote, assetPath) => {
|
|
8
|
+
return `(window.skybridge?.serverUrl ?? "") + "${assetPath}"`;
|
|
8
9
|
});
|
|
9
10
|
return code;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
|
-
* Vite plugin that transforms asset import paths to
|
|
13
|
+
* Vite plugin that transforms asset import paths to resolve at runtime via `window.skybridge.serverUrl`.
|
|
13
14
|
*/
|
|
14
|
-
export function assetBaseUrlTransformPlugin(
|
|
15
|
-
const { devServerOrigin } = options;
|
|
15
|
+
export function assetBaseUrlTransformPlugin() {
|
|
16
16
|
return {
|
|
17
17
|
name: "asset-base-url-transform",
|
|
18
|
-
enforce: "pre",
|
|
19
18
|
transform(code) {
|
|
20
19
|
if (!code) {
|
|
21
20
|
return null;
|
|
22
21
|
}
|
|
23
|
-
const transformedCode = assetBaseUrlTransform(code
|
|
22
|
+
const transformedCode = assetBaseUrlTransform(code);
|
|
24
23
|
if (transformedCode === code) {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-base-url-transform-plugin.js","sourceRoot":"","sources":["../../src/server/asset-base-url-transform-plugin.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"asset-base-url-transform-plugin.js","sourceRoot":"","sources":["../../src/server/asset-base-url-transform-plugin.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAAY;IAChD,MAAM,kBAAkB,GACtB,4GAA4G,CAAC;IAE/G,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE;QACpE,OAAO,0CAA0C,SAAS,GAAG,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO;QACL,IAAI,EAAE,0BAA0B;QAChC,SAAS,CAAC,IAAI;YACZ,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,OAAO,IAAI,CAAC;YACd,CAAC;YAED,MAAM,eAAe,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAEpD,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;gBAC7B,OAAO,IAAI,CAAC;YACd,CAAC;YAED,OAAO;gBACL,IAAI,EAAE,eAAe;gBACrB,GAAG,EAAE,IAAI;aACV,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { assetBaseUrlTransform } from "./asset-base-url-transform-plugin.js";
|
|
3
3
|
describe("assetBaseUrlTransform", () => {
|
|
4
|
-
|
|
5
|
-
it("should transform asset paths in single, double, and backtick quotes", () => {
|
|
4
|
+
it("should transform asset paths to use window.skybridge.serverUrl", () => {
|
|
6
5
|
const cases = [
|
|
7
6
|
{
|
|
8
7
|
desc: "single-quoted",
|
|
9
8
|
code: `const image = '/assets/logo.png';`,
|
|
10
|
-
expected: `const image =
|
|
9
|
+
expected: `const image = (window.skybridge?.serverUrl ?? "") + "/assets/logo.png";`,
|
|
11
10
|
},
|
|
12
11
|
{
|
|
13
12
|
desc: "double-quoted",
|
|
14
13
|
code: `const image = "/assets/logo.png";`,
|
|
15
|
-
expected: `const image = "
|
|
14
|
+
expected: `const image = (window.skybridge?.serverUrl ?? "") + "/assets/logo.png";`,
|
|
16
15
|
},
|
|
17
16
|
{
|
|
18
17
|
desc: "backtick-quoted",
|
|
19
18
|
code: "const image = `/assets/logo.png`;",
|
|
20
|
-
expected: `const image =
|
|
19
|
+
expected: `const image = (window.skybridge?.serverUrl ?? "") + "/assets/logo.png";`,
|
|
21
20
|
},
|
|
22
21
|
];
|
|
23
22
|
for (const { code, expected } of cases) {
|
|
24
|
-
const result = assetBaseUrlTransform(code
|
|
23
|
+
const result = assetBaseUrlTransform(code);
|
|
25
24
|
expect(result).toBe(expected);
|
|
26
25
|
}
|
|
27
26
|
});
|
|
@@ -31,10 +30,10 @@ describe("assetBaseUrlTransform", () => {
|
|
|
31
30
|
const icon = '/assets/icon.svg';
|
|
32
31
|
const font = '/assets/font.woff2';
|
|
33
32
|
`;
|
|
34
|
-
const result = assetBaseUrlTransform(code
|
|
35
|
-
expect(result).toContain(
|
|
36
|
-
expect(result).toContain(
|
|
37
|
-
expect(result).toContain(
|
|
33
|
+
const result = assetBaseUrlTransform(code);
|
|
34
|
+
expect(result).toContain(`(window.skybridge?.serverUrl ?? "") + "/assets/logo.png"`);
|
|
35
|
+
expect(result).toContain(`(window.skybridge?.serverUrl ?? "") + "/assets/icon.svg"`);
|
|
36
|
+
expect(result).toContain(`(window.skybridge?.serverUrl ?? "") + "/assets/font.woff2"`);
|
|
38
37
|
});
|
|
39
38
|
it("should not transform already absolute URLs", () => {
|
|
40
39
|
const code = `
|
|
@@ -42,15 +41,44 @@ describe("assetBaseUrlTransform", () => {
|
|
|
42
41
|
const http = 'http://example.com/image.png';
|
|
43
42
|
const https = 'https://example.com/image.png';
|
|
44
43
|
`;
|
|
45
|
-
const result = assetBaseUrlTransform(code
|
|
46
|
-
expect(result).toContain(
|
|
44
|
+
const result = assetBaseUrlTransform(code);
|
|
45
|
+
expect(result).toContain(`(window.skybridge?.serverUrl ?? "") + "/assets/logo.png"`);
|
|
47
46
|
expect(result).toContain("http://example.com/image.png");
|
|
48
47
|
expect(result).toContain("https://example.com/image.png");
|
|
49
48
|
});
|
|
50
49
|
it("should not transform code without asset paths", () => {
|
|
51
50
|
const code = `const text = "Hello World";`;
|
|
52
|
-
const result = assetBaseUrlTransform(code
|
|
51
|
+
const result = assetBaseUrlTransform(code);
|
|
53
52
|
expect(result).toBe(code);
|
|
54
53
|
});
|
|
54
|
+
it("should not transform asset paths inside static `import ... from` clauses", () => {
|
|
55
|
+
// Reproducer for #713: a dep does `import * as sprite from './icons.svg'`,
|
|
56
|
+
// Vite resolves the relative path to absolute, then this transform used
|
|
57
|
+
// to rewrite the resolved string — producing invalid JS like
|
|
58
|
+
// `import * as sprite from (expr) + "..."` that crashes vite:import-analysis.
|
|
59
|
+
const cases = [
|
|
60
|
+
`import * as sprite from "/Users/me/proj/node_modules/pkg/icons.svg";`,
|
|
61
|
+
`import sprite from '/assets/icons.svg';`,
|
|
62
|
+
`import sprite from "/assets/icons.svg";`,
|
|
63
|
+
`export { default } from "/assets/icons.svg";`,
|
|
64
|
+
`export * from '/assets/sprites.svg';`,
|
|
65
|
+
];
|
|
66
|
+
for (const code of cases) {
|
|
67
|
+
expect(assetBaseUrlTransform(code)).toBe(code);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
it("should still transform value-position asset paths in files that also have unrelated imports", () => {
|
|
71
|
+
const code = [
|
|
72
|
+
`import { foo } from "./foo.js";`,
|
|
73
|
+
`import * as sprite from "/assets/sprite.svg";`,
|
|
74
|
+
`const logo = "/assets/logo.png";`,
|
|
75
|
+
].join("\n");
|
|
76
|
+
const result = assetBaseUrlTransform(code);
|
|
77
|
+
// Imports untouched
|
|
78
|
+
expect(result).toContain(`from "./foo.js"`);
|
|
79
|
+
expect(result).toContain(`from "/assets/sprite.svg"`);
|
|
80
|
+
// Value-position rewritten
|
|
81
|
+
expect(result).toContain(`const logo = (window.skybridge?.serverUrl ?? "") + "/assets/logo.png";`);
|
|
82
|
+
});
|
|
55
83
|
});
|
|
56
84
|
//# sourceMappingURL=asset-base-url-transform-plugin.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asset-base-url-transform-plugin.test.js","sourceRoot":"","sources":["../../src/server/asset-base-url-transform-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,
|
|
1
|
+
{"version":3,"file":"asset-base-url-transform-plugin.test.js","sourceRoot":"","sources":["../../src/server/asset-base-url-transform-plugin.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,gEAAgE,EAAE,GAAG,EAAE;QACxE,MAAM,KAAK,GAAG;YACZ;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,mCAAmC;gBACzC,QAAQ,EAAE,yEAAyE;aACpF;YACD;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,mCAAmC;gBACzC,QAAQ,EAAE,yEAAyE;aACpF;YACD;gBACE,IAAI,EAAE,iBAAiB;gBACvB,IAAI,EAAE,mCAAmC;gBACzC,QAAQ,EAAE,yEAAyE;aACpF;SACF,CAAC;QAEF,KAAK,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,EAAE,CAAC;YACvC,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAA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,CAAC;QAEF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6FAA6F,EAAE,GAAG,EAAE;QACrG,MAAM,IAAI,GAAG;YACX,iCAAiC;YACjC,+CAA+C;YAC/C,kCAAkC;SACnC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,MAAM,MAAM,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAE3C,oBAAoB;QACpB,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAC;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACtD,2BAA2B;QAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CACtB,wEAAwE,CACzE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AudioContent, EmbeddedResource, ImageContent, ResourceLink, TextContent } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
type ContentAnnotations = {
|
|
3
|
+
audience?: ("user" | "assistant")[];
|
|
4
|
+
priority?: number;
|
|
5
|
+
lastModified?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function text(value: string, annotations?: ContentAnnotations): TextContent;
|
|
8
|
+
export declare function image(data: string | Uint8Array, mimeType: string, annotations?: ContentAnnotations): ImageContent;
|
|
9
|
+
export declare function audio(data: string | Uint8Array, mimeType: string, annotations?: ContentAnnotations): AudioContent;
|
|
10
|
+
export declare function embeddedResource(resource: {
|
|
11
|
+
uri: string;
|
|
12
|
+
mimeType?: string;
|
|
13
|
+
text: string;
|
|
14
|
+
} | {
|
|
15
|
+
uri: string;
|
|
16
|
+
mimeType?: string;
|
|
17
|
+
blob: string;
|
|
18
|
+
}, annotations?: ContentAnnotations): EmbeddedResource;
|
|
19
|
+
export declare function resourceLink(link: {
|
|
20
|
+
uri: string;
|
|
21
|
+
name: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
mimeType?: string;
|
|
25
|
+
size?: number;
|
|
26
|
+
}, annotations?: ContentAnnotations): ResourceLink;
|
|
27
|
+
export {};
|