skybridge 0.0.0-dev.e861765 → 0.0.0-dev.e93cc2e
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 +9 -5
- package/dist/commands/build.js +11 -2
- package/dist/commands/build.js.map +1 -1
- package/dist/server/express.js +4 -2
- package/dist/server/express.js.map +1 -1
- package/dist/server/index.d.ts +0 -1
- package/dist/server/index.js +0 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/server.d.ts +7 -1
- package/dist/server/server.js +18 -2
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +0 -2
- package/dist/server/templateHelper.js +4 -22
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates/development.js +27 -0
- package/dist/server/templates/production.js +23 -0
- package/package.json +9 -9
- package/dist/server/templates/development.hbs +0 -67
- package/dist/server/templates/production.hbs +0 -6
package/README.md
CHANGED
|
@@ -120,11 +120,15 @@ Explore production-ready examples:
|
|
|
120
120
|
|
|
121
121
|
| Example | Description | Demo | Code |
|
|
122
122
|
|------------------------|----------------------------------------------------------------------------------|-----------------------------------------------------|-------------------------------------------------------------------------------------|
|
|
123
|
-
| **Capitals Explorer**
|
|
124
|
-
| **Ecommerce Carousel**
|
|
125
|
-
| **Everything**
|
|
126
|
-
| **
|
|
127
|
-
| **
|
|
123
|
+
| **Capitals Explorer** | Interactive world map with geolocation and Wikipedia integration | [Try Demo](https://capitals.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/capitals) |
|
|
124
|
+
| **Ecommerce Carousel** | Product carousel with cart, localization, and modals | [Try Demo](https://ecommerce.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/ecom-carousel) |
|
|
125
|
+
| **Everything** | Comprehensive playground showcasing all hooks and features | [Try Demo](https://everything.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/everything) |
|
|
126
|
+
| **Investigation Game** | Interactive murder mystery game with multi-screen gameplay and dynamic story progression | [Try Demo](https://investigation-game.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/investigation-game) |
|
|
127
|
+
| **Productivity** | Data visualization dashboard demonstrating Skybridge capabilities for MCP Apps | [Try Demo](https://productivity.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/productivity) |
|
|
128
|
+
| **Time's Up** | Word-guessing party game where the user gives hints and the AI tries to guess the secret word | [Try Demo](https://times-up.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/times-up) |
|
|
129
|
+
| **Auth — Clerk** | Full OAuth authentication with Clerk and personalized coffee shop search | — | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-clerk) |
|
|
130
|
+
| **Auth — WorkOS AuthKit** | Full OAuth authentication with WorkOS AuthKit and personalized coffee shop search | — | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-workos) |
|
|
131
|
+
| **Manifest Starter** | Starter app with Manifest UI agentic components out-of-the-box | [Try Demo](https://manifest-ui.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/manifest-ui) |
|
|
128
132
|
|
|
129
133
|
See all examples in the [Showcase](https://docs.skybridge.tech/showcase) or browse the [examples/](examples/) directory.
|
|
130
134
|
|
package/dist/commands/build.js
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { cpSync, rmSync } from "node:fs";
|
|
2
|
+
import { cpSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
3
4
|
import { Command } from "@oclif/core";
|
|
4
5
|
import { Box, render, Text } from "ink";
|
|
5
6
|
import { useEffect } from "react";
|
|
6
7
|
import { Header } from "../cli/header.js";
|
|
7
8
|
import { useExecuteSteps } from "../cli/use-execute-steps.js";
|
|
9
|
+
function generateViteManifestModule() {
|
|
10
|
+
const manifestPath = join("web", "dist", ".vite", "manifest.json");
|
|
11
|
+
const manifest = readFileSync(manifestPath, "utf-8");
|
|
12
|
+
writeFileSync(join("dist", "server", "src", "vite-manifest.js"), `export default ${manifest};\n`);
|
|
13
|
+
}
|
|
8
14
|
export const commandSteps = [
|
|
9
15
|
{
|
|
10
16
|
label: "Building widgets",
|
|
@@ -17,7 +23,10 @@ export const commandSteps = [
|
|
|
17
23
|
},
|
|
18
24
|
{
|
|
19
25
|
label: "Copying static assets",
|
|
20
|
-
run: () =>
|
|
26
|
+
run: () => {
|
|
27
|
+
cpSync("web/dist", "dist/assets", { recursive: true });
|
|
28
|
+
generateViteManifestModule();
|
|
29
|
+
},
|
|
21
30
|
},
|
|
22
31
|
];
|
|
23
32
|
export default class Build extends Command {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACtE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,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;AAEhF,SAAS,0BAA0B;IACjC,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,CA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AAC,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/server/express.js
CHANGED
|
@@ -15,9 +15,11 @@ export async function createServer({ server, customMiddleware = [], }) {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
if (env !== "production") {
|
|
18
|
-
const
|
|
18
|
+
const devtoolsModule = "@skybridge/devtools";
|
|
19
|
+
const { devtoolsStaticServer } = await import(devtoolsModule);
|
|
19
20
|
app.use(await devtoolsStaticServer());
|
|
20
|
-
const
|
|
21
|
+
const widgetsModule = "./widgetsDevServer.js";
|
|
22
|
+
const { widgetsDevServer } = await import(widgetsModule);
|
|
21
23
|
app.use(await widgetsDevServer());
|
|
22
24
|
}
|
|
23
25
|
if (env === "production") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.js","sourceRoot":"","sources":["../../src/server/express.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,SAAS,CAAC;AAG9B,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,EACjC,MAAM,EACN,gBAAgB,GAAG,EAAE,GAItB;IACC,MAAM,GAAG,GAAG,OAAO,EAAE,CAAC;IACtB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IACxB,MAAM,GA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gBACD,EAAE,EAAE,IAAI;aACT,CAAC,CACH,CAAC;YACF,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAI,6BAA6B,CAAC;gBAClD,kBAAkB,EAAE,SAAS;aAC9B,CAAC,CAAC;YAEH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE;gBACnB,SAAS,CAAC,KAAK,EAAE,CAAC;YACpB,CAAC,CAAC,CAAC;YAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YAChC,wEAAwE;YACxE,4DAA4D;YAC5D,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC;YAC1B,MAAM,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,6BAA6B,EAAE,KAAK,CAAC,CAAC;YACpD,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC;gBACrB,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;oBACnB,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE;wBACL,IAAI,EAAE,CAAC,KAAK;wBACZ,OAAO,EAAE,uBAAuB;qBACjC;oBACD,EAAE,EAAE,IAAI;iBACT,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, Too
|
|
|
2
2
|
export type { McpExtra, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpTypedMiddlewareFn, } from "./middleware.js";
|
|
3
3
|
export type { McpServerTypes, ToolDef, WidgetHostType } from "./server.js";
|
|
4
4
|
export { McpServer } from "./server.js";
|
|
5
|
-
export { widgetsDevServer } from "./widgetsDevServer.js";
|
package/dist/server/index.js
CHANGED
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/server/server.d.ts
CHANGED
|
@@ -87,8 +87,12 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
87
87
|
private customMiddleware;
|
|
88
88
|
private mcpMiddlewareEntries;
|
|
89
89
|
private mcpMiddlewareApplied;
|
|
90
|
+
private viteManifest;
|
|
90
91
|
use(...handlers: RequestHandler[]): this;
|
|
91
92
|
use(path: string, ...handlers: RequestHandler[]): this;
|
|
93
|
+
setViteManifest(manifest: Record<string, {
|
|
94
|
+
file: string;
|
|
95
|
+
}>): this;
|
|
92
96
|
/**
|
|
93
97
|
* Register MCP protocol-level middleware (catch-all).
|
|
94
98
|
*/
|
|
@@ -120,7 +124,9 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
120
124
|
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn): this;
|
|
121
125
|
private applyMcpMiddleware;
|
|
122
126
|
connect(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
123
|
-
run(): Promise<
|
|
127
|
+
run(): Promise<{
|
|
128
|
+
fetch: (...args: unknown[]) => unknown;
|
|
129
|
+
} | undefined>;
|
|
124
130
|
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends {
|
|
125
131
|
content: CallToolResult["content"];
|
|
126
132
|
}>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
|
package/dist/server/server.js
CHANGED
|
@@ -20,6 +20,7 @@ export class McpServer extends McpServerBase {
|
|
|
20
20
|
customMiddleware = [];
|
|
21
21
|
mcpMiddlewareEntries = [];
|
|
22
22
|
mcpMiddlewareApplied = false;
|
|
23
|
+
viteManifest = null;
|
|
23
24
|
use(pathOrHandler, ...handlers) {
|
|
24
25
|
if (typeof pathOrHandler === "string") {
|
|
25
26
|
this.customMiddleware.push({
|
|
@@ -34,6 +35,10 @@ export class McpServer extends McpServerBase {
|
|
|
34
35
|
}
|
|
35
36
|
return this;
|
|
36
37
|
}
|
|
38
|
+
setViteManifest(manifest) {
|
|
39
|
+
this.viteManifest = manifest;
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
37
42
|
mcpMiddleware(filterOrHandler,
|
|
38
43
|
// biome-ignore lint/suspicious/noExplicitAny: overloads narrow the handler type at call sites; implementation must accept all variants
|
|
39
44
|
maybeHandler) {
|
|
@@ -92,17 +97,25 @@ export class McpServer extends McpServerBase {
|
|
|
92
97
|
});
|
|
93
98
|
}
|
|
94
99
|
const express = this.express;
|
|
95
|
-
|
|
100
|
+
const port = parseInt(process.env.__PORT ?? "3000", 10);
|
|
101
|
+
await new Promise((resolve, reject) => {
|
|
96
102
|
const server = http.createServer(express);
|
|
97
103
|
server.on("error", (error) => {
|
|
98
104
|
console.error("Failed to start server:", error);
|
|
99
105
|
reject(error);
|
|
100
106
|
});
|
|
101
|
-
const port = parseInt(process.env.__PORT ?? "3000", 10);
|
|
102
107
|
server.listen(port, () => {
|
|
103
108
|
resolve();
|
|
104
109
|
});
|
|
105
110
|
});
|
|
111
|
+
try {
|
|
112
|
+
const cloudflareNode = "cloudflare:node";
|
|
113
|
+
const { httpServerHandler } = await import(cloudflareNode);
|
|
114
|
+
return httpServerHandler({ port });
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
106
119
|
}
|
|
107
120
|
registerWidget(name, resourceConfig, toolConfig, toolCallback) {
|
|
108
121
|
const userMeta = resourceConfig._meta;
|
|
@@ -253,6 +266,9 @@ export class McpServer extends McpServerBase {
|
|
|
253
266
|
return manifest[flatFileKey]?.file ?? manifest[indexFileKey]?.file;
|
|
254
267
|
}
|
|
255
268
|
readManifest() {
|
|
269
|
+
if (this.viteManifest) {
|
|
270
|
+
return this.viteManifest;
|
|
271
|
+
}
|
|
256
272
|
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
257
273
|
}
|
|
258
274
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAcjD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAS5C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,MAAS,EACF,EAAE;IACT,OAAO,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;QACxD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACzD,OAAO,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrC,CAAC;IACH,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EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE;iBAC5D;aACF,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAEO,cAAc,CAAC,GAAW;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACrC,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAC7B,CAAC;IAEO,+BAA+B,CAAC,QAAgB;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAErC,MAAM,WAAW,GAAG,GAAG,QAAQ,MAAM,CAAC;QACtC,MAAM,YAAY,GAAG,GAAG,QAAQ,YAAY,CAAC;QAC7C,OAAO,QAAQ,CAAC,WAAW,CAAC,EAAE,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,CAAC;IACrE,CAAC;IAEO,YAAY;QAClB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CACf,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,OAAO,CACR,CACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import Handlebars from "handlebars";
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = dirname(__filename);
|
|
1
|
+
import developmentTemplate from "./templates/development.js";
|
|
2
|
+
import productionTemplate from "./templates/production.js";
|
|
7
3
|
class TemplateHelper {
|
|
8
|
-
templateCache = new Map();
|
|
9
|
-
loadTemplate(templateName) {
|
|
10
|
-
const cached = this.templateCache.get(templateName);
|
|
11
|
-
if (cached) {
|
|
12
|
-
return cached;
|
|
13
|
-
}
|
|
14
|
-
const templatePath = join(__dirname, "templates", `${templateName}.hbs`);
|
|
15
|
-
const templateSource = readFileSync(templatePath, "utf-8");
|
|
16
|
-
const template = Handlebars.compile(templateSource);
|
|
17
|
-
this.templateCache.set(templateName, template);
|
|
18
|
-
return template;
|
|
19
|
-
}
|
|
20
4
|
renderProduction(data) {
|
|
21
|
-
|
|
22
|
-
return template(data);
|
|
5
|
+
return productionTemplate(data);
|
|
23
6
|
}
|
|
24
7
|
renderDevelopment(data) {
|
|
25
|
-
|
|
26
|
-
return template(data);
|
|
8
|
+
return developmentTemplate(data);
|
|
27
9
|
}
|
|
28
10
|
}
|
|
29
11
|
export const templateHelper = new TemplateHelper();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../src/server/templateHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../src/server/templateHelper.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,4BAA4B,CAAC;AAC7D,OAAO,kBAAkB,MAAM,2BAA2B,CAAC;AAE3D,MAAM,cAAc;IAClB,gBAAgB,CAAC,IAKhB;QACC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,IAKjB;QACC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Handlebars from "handlebars/runtime.js";
|
|
2
|
+
export default Handlebars.template({"1":function(container,depth0,helpers,partials,data) {
|
|
3
|
+
return "<script type=\"module\">\n // Checks for browser support and shows error if local network access is denied\n (async () => {\n if (!navigator.permissions?.query) {\n return;\n }\n\n // Skip for non-http(s) protocols (file://, custom protocols in Electron, etc.)\n const protocol = window.location.protocol;\n const isNonHttpProtocol = protocol !== 'http:' && protocol !== 'https:'\n if (isNonHttpProtocol) {\n return;\n }\n\n const host = window.location.hostname;\n const isLoopback = host === 'localhost'\n || /^127\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})$/.test(host)\n || host === '::1';\n if (isLoopback) {\n return;\n }\n \n try {\n const status = await navigator.permissions.query({ name: \"local-network-access\" });\n if (status.state === \"denied\") {\n const errorDiv = document.createElement(\"div\");\n errorDiv.style.cssText = \"background: #fef2f2; border: 2px solid #ef4444; border-radius: 8px; padding: 16px; text-align: center; z-index: 10000; font-family: system-ui, sans-serif;\";\n\n const errorTitle = document.createElement(\"div\");\n errorTitle.style.cssText = \"color: #ef4444; font-size: 18px; font-weight: 600; margin-bottom: 8px;\";\n errorTitle.textContent = \"Error: Local network access permission is denied.\";\n\n const errorMessage = document.createElement(\"div\");\n errorMessage.style.cssText = \"color: #ef4444; font-size: 14px;\";\n errorMessage.textContent = \"Local network access is required for your widget to connect to the local dev server. Please enable it in your browser settings. \";\n\n const link = document.createElement(\"a\");\n link.href = \"https://developer.chrome.com/blog/local-network-access\";\n link.target = \"_blank\";\n link.rel = \"noopener noreferrer\";\n link.style.cssText = \"color: #ef4444; text-decoration: underline;\";\n link.textContent = \"Learn more\";\n errorMessage.appendChild(link);\n\n errorDiv.appendChild(errorTitle);\n errorDiv.appendChild(errorMessage);\n document.body.appendChild(errorDiv);\n }\n } catch (e) {\n // Permission API doesn't support local-network-access, ignore silently\n }\n })();\n</script>\n";
|
|
4
|
+
},"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
|
|
5
|
+
var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
7
|
+
return parent[propertyName];
|
|
8
|
+
}
|
|
9
|
+
return undefined
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return "<script type=\"module\">window.skybridge = { hostType: \""
|
|
13
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"hostType") || (depth0 != null ? lookupProperty(depth0,"hostType") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"hostType","hash":{},"data":data,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":66}}}) : helper)))
|
|
14
|
+
+ "\", serverUrl: \""
|
|
15
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":1,"column":81},"end":{"line":1,"column":94}}}) : helper)))
|
|
16
|
+
+ "\" };</script>\n<script type=\"module\">\n import { injectIntoGlobalHook } from \""
|
|
17
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":3,"column":40},"end":{"line":3,"column":53}}}) : helper)))
|
|
18
|
+
+ "/assets/@react-refresh\";\n injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};\n window.$RefreshSig$ = () => (type) => type;\n window.__vite_plugin_react_preamble_installed__ = true;\n</script>\n<script type=\"module\" src=\""
|
|
19
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":8,"column":27},"end":{"line":8,"column":40}}}) : helper)))
|
|
20
|
+
+ "/@vite/client\"></script>\n"
|
|
21
|
+
+ ((stack1 = lookupProperty(helpers,"if").call(alias1,(depth0 != null ? lookupProperty(depth0,"useLocalNetworkAccess") : depth0),{"name":"if","hash":{},"fn":container.program(1, data, 0),"inverse":container.noop,"data":data,"loc":{"start":{"line":9,"column":0},"end":{"line":63,"column":7}}})) != null ? stack1 : "")
|
|
22
|
+
+ "<div id=\"root\"></div>\n<script type=\"module\" id=\"dev-widget-entry\">\n import('"
|
|
23
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":66,"column":10},"end":{"line":66,"column":23}}}) : helper)))
|
|
24
|
+
+ "/src/widgets/"
|
|
25
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"widgetName") || (depth0 != null ? lookupProperty(depth0,"widgetName") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"widgetName","hash":{},"data":data,"loc":{"start":{"line":66,"column":36},"end":{"line":66,"column":50}}}) : helper)))
|
|
26
|
+
+ "');\n</script>";
|
|
27
|
+
},"useData":true});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Handlebars from "handlebars/runtime.js";
|
|
2
|
+
export default Handlebars.template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
|
|
3
|
+
var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3="function", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
|
|
4
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
5
|
+
return parent[propertyName];
|
|
6
|
+
}
|
|
7
|
+
return undefined
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
return "<script type=\"module\">window.skybridge = { hostType: \""
|
|
11
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"hostType") || (depth0 != null ? lookupProperty(depth0,"hostType") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"hostType","hash":{},"data":data,"loc":{"start":{"line":1,"column":54},"end":{"line":1,"column":66}}}) : helper)))
|
|
12
|
+
+ "\", serverUrl: \""
|
|
13
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":1,"column":81},"end":{"line":1,"column":94}}}) : helper)))
|
|
14
|
+
+ "\" };</script>\n<div id=\"root\"></div>\n<script type=\"module\">\n import('"
|
|
15
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":4,"column":10},"end":{"line":4,"column":23}}}) : helper)))
|
|
16
|
+
+ "/assets/"
|
|
17
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"widgetFile") || (depth0 != null ? lookupProperty(depth0,"widgetFile") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"widgetFile","hash":{},"data":data,"loc":{"start":{"line":4,"column":31},"end":{"line":4,"column":45}}}) : helper)))
|
|
18
|
+
+ "');\n</script>\n<link rel=\"stylesheet\" crossorigin href=\""
|
|
19
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"serverUrl") || (depth0 != null ? lookupProperty(depth0,"serverUrl") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"serverUrl","hash":{},"data":data,"loc":{"start":{"line":6,"column":41},"end":{"line":6,"column":54}}}) : helper)))
|
|
20
|
+
+ "/assets/"
|
|
21
|
+
+ alias4(((helper = (helper = lookupProperty(helpers,"styleFile") || (depth0 != null ? lookupProperty(depth0,"styleFile") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{"name":"styleFile","hash":{},"data":data,"loc":{"start":{"line":6,"column":62},"end":{"line":6,"column":75}}}) : helper)))
|
|
22
|
+
+ "\" />";
|
|
23
|
+
},"useData":true});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.e93cc2e",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT and MCP Apps",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@babel/core": "^7.29.0",
|
|
45
|
-
"@oclif/core": "^4.
|
|
45
|
+
"@oclif/core": "^4.9.0",
|
|
46
46
|
"ci-info": "^4.4.0",
|
|
47
47
|
"cors": "^2.8.6",
|
|
48
48
|
"dequal": "^2.0.3",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"express": "^5.2.1",
|
|
51
51
|
"handlebars": "^4.7.8",
|
|
52
52
|
"ink": "^6.8.0",
|
|
53
|
-
"posthog-node": "^5.28.
|
|
53
|
+
"posthog-node": "^5.28.2",
|
|
54
54
|
"superjson": "^2.2.6",
|
|
55
|
-
"zustand": "^5.0.
|
|
55
|
+
"zustand": "^5.0.12"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@modelcontextprotocol/ext-apps": "^1.2.
|
|
58
|
+
"@modelcontextprotocol/ext-apps": "^1.2.2",
|
|
59
59
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
60
60
|
"@testing-library/dom": "^10.4.1",
|
|
61
61
|
"@testing-library/react": "^16.3.2",
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"@types/node": "^24.12.0",
|
|
68
68
|
"@types/react": "^19.2.14",
|
|
69
69
|
"@types/react-dom": "^19.2.3",
|
|
70
|
-
"@vitest/ui": "^4.0
|
|
71
|
-
"jsdom": "^
|
|
70
|
+
"@vitest/ui": "^4.1.0",
|
|
71
|
+
"jsdom": "^29.0.0",
|
|
72
72
|
"shx": "^0.4.0",
|
|
73
73
|
"ts-node": "^10.9.2",
|
|
74
74
|
"typescript": "^5.9.3",
|
|
75
|
-
"vitest": "^4.0
|
|
75
|
+
"vitest": "^4.1.0",
|
|
76
76
|
"zod": "^4.3.6"
|
|
77
77
|
},
|
|
78
78
|
"bin": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
},
|
|
91
91
|
"scripts": {
|
|
92
92
|
"build": "shx rm -rf dist && tsc && pnpm run build:templates",
|
|
93
|
-
"build:templates": "
|
|
93
|
+
"build:templates": "node scripts/precompile-templates.mjs",
|
|
94
94
|
"format": "biome check --write --error-on-warnings",
|
|
95
95
|
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
96
96
|
"test:unit": "vitest run",
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
<script type="module">window.skybridge = { hostType: "{{hostType}}", serverUrl: "{{serverUrl}}" };</script>
|
|
2
|
-
<script type="module">
|
|
3
|
-
import { injectIntoGlobalHook } from "{{serverUrl}}/assets/@react-refresh";
|
|
4
|
-
injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};
|
|
5
|
-
window.$RefreshSig$ = () => (type) => type;
|
|
6
|
-
window.__vite_plugin_react_preamble_installed__ = true;
|
|
7
|
-
</script>
|
|
8
|
-
<script type="module" src="{{serverUrl}}/@vite/client"></script>
|
|
9
|
-
{{#if useLocalNetworkAccess}}
|
|
10
|
-
<script type="module">
|
|
11
|
-
// Checks for browser support and shows error if local network access is denied
|
|
12
|
-
(async () => {
|
|
13
|
-
if (!navigator.permissions?.query) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Skip for non-http(s) protocols (file://, custom protocols in Electron, etc.)
|
|
18
|
-
const protocol = window.location.protocol;
|
|
19
|
-
const isNonHttpProtocol = protocol !== 'http:' && protocol !== 'https:'
|
|
20
|
-
if (isNonHttpProtocol) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const host = window.location.hostname;
|
|
25
|
-
const isLoopback = host === 'localhost'
|
|
26
|
-
|| /^127\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.test(host)
|
|
27
|
-
|| host === '::1';
|
|
28
|
-
if (isLoopback) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const status = await navigator.permissions.query({ name: "local-network-access" });
|
|
34
|
-
if (status.state === "denied") {
|
|
35
|
-
const errorDiv = document.createElement("div");
|
|
36
|
-
errorDiv.style.cssText = "background: #fef2f2; border: 2px solid #ef4444; border-radius: 8px; padding: 16px; text-align: center; z-index: 10000; font-family: system-ui, sans-serif;";
|
|
37
|
-
|
|
38
|
-
const errorTitle = document.createElement("div");
|
|
39
|
-
errorTitle.style.cssText = "color: #ef4444; font-size: 18px; font-weight: 600; margin-bottom: 8px;";
|
|
40
|
-
errorTitle.textContent = "Error: Local network access permission is denied.";
|
|
41
|
-
|
|
42
|
-
const errorMessage = document.createElement("div");
|
|
43
|
-
errorMessage.style.cssText = "color: #ef4444; font-size: 14px;";
|
|
44
|
-
errorMessage.textContent = "Local network access is required for your widget to connect to the local dev server. Please enable it in your browser settings. ";
|
|
45
|
-
|
|
46
|
-
const link = document.createElement("a");
|
|
47
|
-
link.href = "https://developer.chrome.com/blog/local-network-access";
|
|
48
|
-
link.target = "_blank";
|
|
49
|
-
link.rel = "noopener noreferrer";
|
|
50
|
-
link.style.cssText = "color: #ef4444; text-decoration: underline;";
|
|
51
|
-
link.textContent = "Learn more";
|
|
52
|
-
errorMessage.appendChild(link);
|
|
53
|
-
|
|
54
|
-
errorDiv.appendChild(errorTitle);
|
|
55
|
-
errorDiv.appendChild(errorMessage);
|
|
56
|
-
document.body.appendChild(errorDiv);
|
|
57
|
-
}
|
|
58
|
-
} catch (e) {
|
|
59
|
-
// Permission API doesn't support local-network-access, ignore silently
|
|
60
|
-
}
|
|
61
|
-
})();
|
|
62
|
-
</script>
|
|
63
|
-
{{/if}}
|
|
64
|
-
<div id="root"></div>
|
|
65
|
-
<script type="module" id="dev-widget-entry">
|
|
66
|
-
import('{{serverUrl}}/src/widgets/{{widgetName}}');
|
|
67
|
-
</script>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<script type="module">window.skybridge = { hostType: "{{hostType}}", serverUrl: "{{serverUrl}}" };</script>
|
|
2
|
-
<div id="root"></div>
|
|
3
|
-
<script type="module">
|
|
4
|
-
import('{{serverUrl}}/assets/{{widgetFile}}');
|
|
5
|
-
</script>
|
|
6
|
-
<link rel="stylesheet" crossorigin href="{{serverUrl}}/assets/{{styleFile}}" />
|