create-skybridge 0.0.0-dev.e0ed208 → 0.0.0-dev.e38035c
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/LICENSE +21 -0
- package/dist/index.js +124 -18
- package/package.json +12 -13
- package/template/README.md +13 -2
- package/template/node_modules/.bin/mcp-inspector +21 -0
- package/template/node_modules/.bin/nodemon +21 -0
- package/template/node_modules/.bin/shx +21 -0
- package/template/node_modules/.bin/tsc +21 -0
- package/template/node_modules/.bin/tsserver +21 -0
- package/template/node_modules/.bin/tsx +21 -0
- package/template/node_modules/.bin/vite +21 -0
- package/template/nodemon.json +5 -0
- package/template/package.json +31 -10
- package/template/server/src/index.ts +6 -2
- package/template/server/src/server.ts +0 -5
- package/template/tsconfig.json +23 -0
- package/template/tsconfig.server.json +11 -0
- package/template/web/src/index.css +1 -0
- package/template/web/src/widgets/magic-8-ball.tsx +3 -1
- package/template/web/vite.config.ts +1 -1
- package/template-ecom/README.md +89 -0
- package/template-ecom/alpic.json +4 -0
- package/template-ecom/nodemon.json +5 -0
- package/template-ecom/package.json +40 -0
- package/template-ecom/server/src/index.ts +39 -0
- package/template-ecom/server/src/middleware.ts +54 -0
- package/template-ecom/server/src/server.ts +73 -0
- package/template-ecom/tsconfig.json +23 -0
- package/template-ecom/tsconfig.server.json +11 -0
- package/template-ecom/web/src/helpers.ts +4 -0
- package/template-ecom/web/src/index.css +194 -0
- package/template-ecom/web/src/widgets/ecom-carousel.tsx +181 -0
- package/template-ecom/web/vite.config.ts +15 -0
- package/template/_gitignore +0 -4
- package/template/pnpm-workspace.yaml +0 -7
- package/template/server/nodemon.json +0 -5
- package/template/server/package.json +0 -32
- package/template/server/tsconfig.json +0 -17
- package/template/web/package.json +0 -24
- package/template/web/tsconfig.app.json +0 -34
- package/template/web/tsconfig.json +0 -13
- package/template/web/tsconfig.node.json +0 -26
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import "@/index.css";
|
|
2
|
+
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import {
|
|
5
|
+
mountWidget,
|
|
6
|
+
useLayout,
|
|
7
|
+
useOpenExternal,
|
|
8
|
+
useRequestModal,
|
|
9
|
+
useUser,
|
|
10
|
+
useWidgetState,
|
|
11
|
+
} from "skybridge/web";
|
|
12
|
+
import { useToolInfo } from "../helpers.js";
|
|
13
|
+
|
|
14
|
+
const translations: Record<string, Record<string, string>> = {
|
|
15
|
+
en: {
|
|
16
|
+
loading: "Loading products...",
|
|
17
|
+
noProducts: "No product found",
|
|
18
|
+
addToCart: "Add to cart",
|
|
19
|
+
removeFromCart: "Remove",
|
|
20
|
+
},
|
|
21
|
+
fr: {
|
|
22
|
+
loading: "Chargement des produits...",
|
|
23
|
+
noProducts: "Aucun produit trouvé",
|
|
24
|
+
addToCart: "Ajouter",
|
|
25
|
+
removeFromCart: "Retirer",
|
|
26
|
+
},
|
|
27
|
+
es: {
|
|
28
|
+
loading: "Cargando productos...",
|
|
29
|
+
noProducts: "No se encontraron productos",
|
|
30
|
+
addToCart: "Añadir",
|
|
31
|
+
removeFromCart: "Quitar",
|
|
32
|
+
},
|
|
33
|
+
de: {
|
|
34
|
+
loading: "Produkte werden geladen...",
|
|
35
|
+
noProducts: "Keine Produkte gefunden",
|
|
36
|
+
addToCart: "Hinzufügen",
|
|
37
|
+
removeFromCart: "Entfernen",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const CHECKOUT_URL = "https://alpic.ai";
|
|
42
|
+
|
|
43
|
+
function EcomCarousel() {
|
|
44
|
+
const { theme } = useLayout();
|
|
45
|
+
const { locale } = useUser();
|
|
46
|
+
const { open, isOpen } = useRequestModal();
|
|
47
|
+
const openExternal = useOpenExternal();
|
|
48
|
+
|
|
49
|
+
const lang = locale?.split("-")[0] ?? "en";
|
|
50
|
+
|
|
51
|
+
function translate(key: string) {
|
|
52
|
+
return translations[lang]?.[key] ?? translations.en[key];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const { output, isPending } = useToolInfo<"ecom-carousel">();
|
|
56
|
+
type Product = NonNullable<typeof output>["products"][number];
|
|
57
|
+
const [selected, setSelected] = useState<Product | null>(null);
|
|
58
|
+
|
|
59
|
+
const [cart, setCart] = useWidgetState<{ ids: number[] }>({ ids: [] });
|
|
60
|
+
|
|
61
|
+
function toggleCart(productId: number) {
|
|
62
|
+
if (cart.ids.includes(productId)) {
|
|
63
|
+
setCart({ ids: cart.ids.filter((id) => id !== productId) });
|
|
64
|
+
} else {
|
|
65
|
+
setCart({ ids: [...cart.ids, productId] });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (isPending) {
|
|
70
|
+
return (
|
|
71
|
+
<div className={`${theme} container`}>
|
|
72
|
+
<div className="message">{translate("loading")}</div>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!output || output.products.length === 0) {
|
|
78
|
+
return (
|
|
79
|
+
<div className={`${theme} container`}>
|
|
80
|
+
<div className="message">{translate("noProducts")}</div>
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (isOpen) {
|
|
86
|
+
const cartItems: Product[] = [];
|
|
87
|
+
let total = 0;
|
|
88
|
+
for (const p of output.products) {
|
|
89
|
+
if (cart.ids.includes(p.id)) {
|
|
90
|
+
cartItems.push(p);
|
|
91
|
+
total += p.price;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const checkoutUrl = new URL(CHECKOUT_URL);
|
|
95
|
+
checkoutUrl.searchParams.set("cart", cart.ids.join(","));
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<div className={`${theme} checkout`}>
|
|
99
|
+
<div className="checkout-title">Order summary</div>
|
|
100
|
+
<div className="checkout-items">
|
|
101
|
+
{cartItems.map((item) => (
|
|
102
|
+
<div key={item.id} className="checkout-item">
|
|
103
|
+
<span>{item.title}</span>
|
|
104
|
+
<span>${item.price.toFixed(2)}</span>
|
|
105
|
+
</div>
|
|
106
|
+
))}
|
|
107
|
+
</div>
|
|
108
|
+
<div className="checkout-total">
|
|
109
|
+
<span>Total</span>
|
|
110
|
+
<span>${total.toFixed(2)}</span>
|
|
111
|
+
</div>
|
|
112
|
+
<button
|
|
113
|
+
type="button"
|
|
114
|
+
className="checkout-button"
|
|
115
|
+
onClick={() => openExternal(checkoutUrl.toString())}
|
|
116
|
+
>
|
|
117
|
+
Checkout
|
|
118
|
+
</button>
|
|
119
|
+
</div>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const activeProduct = selected ?? output.products[0];
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<div className={`${theme} container`}>
|
|
127
|
+
<button
|
|
128
|
+
type="button"
|
|
129
|
+
className="cart-indicator"
|
|
130
|
+
onClick={() => open({ title: "Proceed to checkout ?" })}
|
|
131
|
+
disabled={cart.ids.length === 0}
|
|
132
|
+
>
|
|
133
|
+
🛒 {cart.ids.length}
|
|
134
|
+
</button>
|
|
135
|
+
<div className="carousel">
|
|
136
|
+
{output.products.map((product) => {
|
|
137
|
+
const inCart = cart.ids.includes(product.id);
|
|
138
|
+
return (
|
|
139
|
+
<div key={product.id} className="product-wrapper">
|
|
140
|
+
<button
|
|
141
|
+
type="button"
|
|
142
|
+
className={`product-card ${activeProduct?.id === product.id ? "selected" : ""}`}
|
|
143
|
+
onClick={() => setSelected(product)}
|
|
144
|
+
>
|
|
145
|
+
<img
|
|
146
|
+
src={product.image}
|
|
147
|
+
alt={product.title}
|
|
148
|
+
className="product-image"
|
|
149
|
+
/>
|
|
150
|
+
<div className="product-info">
|
|
151
|
+
<div className="product-title">{product.title}</div>
|
|
152
|
+
<div className="product-price">
|
|
153
|
+
${product.price.toFixed(2)}
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
</button>
|
|
157
|
+
<button
|
|
158
|
+
type="button"
|
|
159
|
+
className={`cart-button ${inCart ? "in-cart" : ""}`}
|
|
160
|
+
onClick={() => toggleCart(product.id)}
|
|
161
|
+
>
|
|
162
|
+
{inCart ? translate("removeFromCart") : translate("addToCart")}
|
|
163
|
+
</button>
|
|
164
|
+
</div>
|
|
165
|
+
);
|
|
166
|
+
})}
|
|
167
|
+
</div>
|
|
168
|
+
<div className="product-detail">
|
|
169
|
+
<div className="detail-title">{activeProduct.title}</div>
|
|
170
|
+
<div className="detail-rating">
|
|
171
|
+
⭐ {activeProduct.rating.rate} ({activeProduct.rating.count} reviews)
|
|
172
|
+
</div>
|
|
173
|
+
<div className="detail-description">{activeProduct.description}</div>
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default EcomCarousel;
|
|
180
|
+
|
|
181
|
+
mountWidget(<EcomCarousel />);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import { skybridge } from "skybridge/web";
|
|
4
|
+
import { defineConfig } from "vite";
|
|
5
|
+
|
|
6
|
+
// https://vite.dev/config/
|
|
7
|
+
export default defineConfig({
|
|
8
|
+
plugins: [skybridge(), react()],
|
|
9
|
+
root: __dirname,
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
"@": path.resolve(__dirname, "./src"),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
package/template/_gitignore
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@apps-sdk-template/server",
|
|
3
|
-
"version": "0.0.1",
|
|
4
|
-
"private": true,
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"description": "Alpic MCP Server Template",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
10
|
-
"type": "module",
|
|
11
|
-
"scripts": {
|
|
12
|
-
"dev": "nodemon",
|
|
13
|
-
"build": "tsc",
|
|
14
|
-
"start": "node dist/index.js",
|
|
15
|
-
"inspector": "mcp-inspector http://localhost:3000/mcp"
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
19
|
-
"express": "^5.1.0",
|
|
20
|
-
"skybridge": "catalog:",
|
|
21
|
-
"vite": "^7.1.11",
|
|
22
|
-
"zod": "^4.1.13"
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"@modelcontextprotocol/inspector": "^0.17.5",
|
|
26
|
-
"@types/express": "^5.0.3",
|
|
27
|
-
"@types/node": "^22.15.30",
|
|
28
|
-
"nodemon": "^3.1.10",
|
|
29
|
-
"tsx": "^4.19.2",
|
|
30
|
-
"typescript": "^5.7.2"
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"esModuleInterop": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"forceConsistentCasingInFileNames": true,
|
|
10
|
-
"outDir": "dist",
|
|
11
|
-
"sourceMap": true,
|
|
12
|
-
"jsx": "react",
|
|
13
|
-
"inlineSources": true
|
|
14
|
-
},
|
|
15
|
-
"include": ["**/*.ts", "**/*.tsx"],
|
|
16
|
-
"exclude": ["dist", "node_modules"]
|
|
17
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@apps-sdk-template/web",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "echo 'Not implemented",
|
|
8
|
-
"build": "tsc -b && vite build",
|
|
9
|
-
"preview": "vite preview"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"skybridge": "catalog:",
|
|
13
|
-
"react": "^19.1.1",
|
|
14
|
-
"react-dom": "^19.1.1"
|
|
15
|
-
},
|
|
16
|
-
"devDependencies": {
|
|
17
|
-
"@types/node": "^24.6.0",
|
|
18
|
-
"@types/react": "^19.1.16",
|
|
19
|
-
"@types/react-dom": "^19.1.9",
|
|
20
|
-
"@vitejs/plugin-react": "^5.0.4",
|
|
21
|
-
"typescript": "~5.9.3",
|
|
22
|
-
"vite": "^7.1.11"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
|
4
|
-
"target": "ES2022",
|
|
5
|
-
"useDefineForClassFields": true,
|
|
6
|
-
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
-
"module": "ESNext",
|
|
8
|
-
"types": ["vite/client"],
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
|
|
11
|
-
/* Bundler mode */
|
|
12
|
-
"moduleResolution": "bundler",
|
|
13
|
-
"allowImportingTsExtensions": true,
|
|
14
|
-
"verbatimModuleSyntax": true,
|
|
15
|
-
"moduleDetection": "force",
|
|
16
|
-
"noEmit": true,
|
|
17
|
-
"jsx": "react-jsx",
|
|
18
|
-
|
|
19
|
-
/* Linting */
|
|
20
|
-
"strict": true,
|
|
21
|
-
"noUnusedLocals": true,
|
|
22
|
-
"noUnusedParameters": true,
|
|
23
|
-
"erasableSyntaxOnly": true,
|
|
24
|
-
"noFallthroughCasesInSwitch": true,
|
|
25
|
-
"noUncheckedSideEffectImports": true,
|
|
26
|
-
|
|
27
|
-
/* Shadcn Config */
|
|
28
|
-
"baseUrl": ".",
|
|
29
|
-
"paths": {
|
|
30
|
-
"@/*": ["./src/*"]
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"include": ["src"]
|
|
34
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
|
4
|
-
"target": "ES2023",
|
|
5
|
-
"lib": ["ES2023"],
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"types": ["node"],
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
|
|
10
|
-
/* Bundler mode */
|
|
11
|
-
"moduleResolution": "bundler",
|
|
12
|
-
"allowImportingTsExtensions": true,
|
|
13
|
-
"verbatimModuleSyntax": true,
|
|
14
|
-
"moduleDetection": "force",
|
|
15
|
-
"noEmit": true,
|
|
16
|
-
|
|
17
|
-
/* Linting */
|
|
18
|
-
"strict": true,
|
|
19
|
-
"noUnusedLocals": true,
|
|
20
|
-
"noUnusedParameters": true,
|
|
21
|
-
"erasableSyntaxOnly": true,
|
|
22
|
-
"noFallthroughCasesInSwitch": true,
|
|
23
|
-
"noUncheckedSideEffectImports": true
|
|
24
|
-
},
|
|
25
|
-
"include": ["vite.config.ts"]
|
|
26
|
-
}
|