nitrostack 1.0.49 → 1.0.51
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/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +7 -33
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/core/component.d.ts +1 -7
- package/dist/core/component.d.ts.map +1 -1
- package/dist/core/component.js +4 -49
- package/dist/core/component.js.map +1 -1
- package/dist/core/server.d.ts.map +1 -1
- package/dist/core/server.js +3 -9
- package/dist/core/server.js.map +1 -1
- package/dist/core/tool.d.ts.map +1 -1
- package/dist/core/tool.js +1 -16
- package/dist/core/tool.js.map +1 -1
- package/dist/ui-next/index.d.ts +0 -1
- package/dist/ui-next/index.d.ts.map +1 -1
- package/dist/ui-next/index.js +125 -126
- package/dist/ui-next/index.js.map +1 -1
- package/package.json +2 -3
- package/src/studio/components/WidgetRenderer.tsx +15 -24
- package/src/studio/middleware.ts +1 -2
- package/src/studio/next.config.js +0 -2
- package/templates/typescript-auth/src/modules/products/products.tools.ts +29 -29
- package/templates/typescript-oauth/src/widgets/package-lock.json +4464 -0
- package/templates/typescript-auth/.env.example +0 -23
- package/templates/typescript-auth-api-key/.env.example +0 -4
- package/templates/typescript-oauth/.env.example +0 -102
- package/templates/typescript-oauth/src/widgets/.next/BUILD_ID +0 -1
- package/templates/typescript-oauth/src/widgets/.next/app-build-manifest.json +0 -32
- package/templates/typescript-oauth/src/widgets/.next/app-path-routes-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/build-manifest.json +0 -32
- package/templates/typescript-oauth/src/widgets/.next/cache/webpack/client-production/0.pack +0 -0
- package/templates/typescript-oauth/src/widgets/.next/cache/webpack/client-production/index.pack +0 -0
- package/templates/typescript-oauth/src/widgets/.next/cache/webpack/edge-server-production/0.pack +0 -0
- package/templates/typescript-oauth/src/widgets/.next/cache/webpack/edge-server-production/index.pack +0 -0
- package/templates/typescript-oauth/src/widgets/.next/cache/webpack/server-production/0.pack +0 -0
- package/templates/typescript-oauth/src/widgets/.next/cache/webpack/server-production/index.pack +0 -0
- package/templates/typescript-oauth/src/widgets/.next/export-detail.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/export-marker.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/images-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/next-minimal-server.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/next-server.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/package.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/prerender-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/react-loadable-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/required-server-files.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/routes-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/_not-found/page.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/_not-found/page.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/_not-found/page_client-reference-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/_not-found.html +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/_not-found.meta +0 -6
- package/templates/typescript-oauth/src/widgets/.next/server/app/_not-found.rsc +0 -9
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-operations/page.js +0 -6
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-operations/page.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-operations/page_client-reference-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-operations.html +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-operations.meta +0 -5
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-operations.rsc +0 -7
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-result/page.js +0 -6
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-result/page.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-result/page_client-reference-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-result.html +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-result.meta +0 -5
- package/templates/typescript-oauth/src/widgets/.next/server/app/calculator-result.rsc +0 -7
- package/templates/typescript-oauth/src/widgets/.next/server/app-paths-manifest.json +0 -5
- package/templates/typescript-oauth/src/widgets/.next/server/chunks/682.js +0 -6
- package/templates/typescript-oauth/src/widgets/.next/server/chunks/819.js +0 -3
- package/templates/typescript-oauth/src/widgets/.next/server/chunks/font-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/font-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/functions-config-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/interception-route-rewrite-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/middleware-build-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/middleware-manifest.json +0 -6
- package/templates/typescript-oauth/src/widgets/.next/server/middleware-react-loadable-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/next-font-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/next-font-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/404.html +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/500.html +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/_app.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/_app.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/_document.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/_document.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/_error.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages/_error.js.nft.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/pages-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/server-reference-manifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/server-reference-manifest.json +0 -1
- package/templates/typescript-oauth/src/widgets/.next/server/webpack-runtime.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/WU9THacVqL52RZbrZOLS1/_buildManifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/WU9THacVqL52RZbrZOLS1/_ssgManifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/117-eb57c7ef86f964a4.js +0 -2
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/app/_not-found/page-dcb83ba3e4d0aafd.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/app/calculator-operations/page-b8913a740073ea8a.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/app/calculator-result/page-ddaaab2fce95dea2.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/app/layout-cbd3ebdc4ecc5247.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/fd9d1056-749e5812300142af.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/framework-f66176bb897dc684.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/main-76df43fcef3db344.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/main-app-f9c40224d04023c5.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/static/chunks/webpack-100b9e646d9c912e.js +0 -1
- package/templates/typescript-oauth/src/widgets/.next/trace +0 -14
- package/templates/typescript-oauth/src/widgets/.next/types/app/calculator-operations/page.ts +0 -79
- package/templates/typescript-oauth/src/widgets/.next/types/app/calculator-result/page.ts +0 -79
- package/templates/typescript-oauth/src/widgets/.next/types/app/layout.ts +0 -79
- package/templates/typescript-oauth/src/widgets/.next/types/package.json +0 -1
- package/templates/typescript-oauth/src/widgets/next-env.d.ts +0 -5
- package/templates/typescript-starter/.env.example +0 -4
package/dist/ui-next/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { execSync } from 'node:child_process';
|
|
|
2
2
|
import * as fs from 'node:fs';
|
|
3
3
|
import * as path from 'node:path';
|
|
4
4
|
import { createComponent } from '../core/component.js';
|
|
5
|
-
|
|
5
|
+
function inlineHtmlWithAssets(htmlPath, outDir) {
|
|
6
6
|
let html = fs.readFileSync(htmlPath, 'utf8');
|
|
7
7
|
// Inline <link rel="stylesheet" href="...">
|
|
8
8
|
html = html.replace(/<link[^>]*rel=["']stylesheet["'][^>]*href=["']([^"']+)["'][^>]*>/g, (_m, href) => {
|
|
@@ -162,14 +162,14 @@ export function createComponentFromNextRoute(arg1, arg2) {
|
|
|
162
162
|
// Try flat structure (route-name.html)
|
|
163
163
|
outPath = path.resolve(projectDir, 'out', `${routePath}.html`);
|
|
164
164
|
if (!fs.existsSync(outPath)) {
|
|
165
|
-
throw new Error(`Exported HTML for route '${routePath}' not found. Tried
|
|
166
|
-
` - ${path.resolve(projectDir, 'out', routePath, 'index.html')}
|
|
165
|
+
throw new Error(`Exported HTML for route '${routePath}' not found. Tried:\n` +
|
|
166
|
+
` - ${path.resolve(projectDir, 'out', routePath, 'index.html')}\n` +
|
|
167
167
|
` - ${path.resolve(projectDir, 'out', `${routePath}.html`)}`);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
//
|
|
171
|
-
|
|
172
|
-
const widgetHtml =
|
|
170
|
+
// For Next.js widgets, we need to create a simple renderer that works with data
|
|
171
|
+
// Instead of using complex Next.js hydration, generate simple HTML dynamically
|
|
172
|
+
const widgetHtml = generateSimpleWidgetHtml(routePath, id);
|
|
173
173
|
return createComponent({
|
|
174
174
|
id,
|
|
175
175
|
name,
|
|
@@ -185,188 +185,187 @@ export function createComponentFromNextRoute(arg1, arg2) {
|
|
|
185
185
|
*/
|
|
186
186
|
function generateSimpleWidgetHtml(routePath, widgetId) {
|
|
187
187
|
// Base template that all widgets use
|
|
188
|
-
const baseTemplate =
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
* { box-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
font - family: -apple - system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans - serif;
|
|
188
|
+
const baseTemplate = `<!DOCTYPE html>
|
|
189
|
+
<html>
|
|
190
|
+
<head>
|
|
191
|
+
<meta charset="UTF-8">
|
|
192
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
193
|
+
<style>
|
|
194
|
+
* { box-sizing: border-box; }
|
|
195
|
+
body {
|
|
196
|
+
margin: 16px;
|
|
197
|
+
padding: 0;
|
|
198
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
200
199
|
background: #ffffff;
|
|
201
200
|
color: #1a1a1a;
|
|
202
|
-
min
|
|
201
|
+
min-height: 100px;
|
|
203
202
|
}
|
|
204
|
-
.widget
|
|
203
|
+
.widget-container {
|
|
205
204
|
background: #ffffff;
|
|
206
205
|
border: 1px solid #e5e7eb;
|
|
207
|
-
border
|
|
206
|
+
border-radius: 12px;
|
|
208
207
|
padding: 0;
|
|
209
208
|
overflow: hidden;
|
|
210
|
-
max
|
|
211
|
-
box
|
|
209
|
+
max-width: 100%;
|
|
210
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
212
211
|
}
|
|
213
|
-
.widget
|
|
212
|
+
.widget-header {
|
|
214
213
|
padding: 20px;
|
|
215
|
-
background: linear
|
|
214
|
+
background: linear-gradient(135deg, #D4AF37 0%, #F5C842 100%);
|
|
216
215
|
color: #000;
|
|
217
|
-
font
|
|
218
|
-
font
|
|
216
|
+
font-weight: 700;
|
|
217
|
+
font-size: 18px;
|
|
219
218
|
}
|
|
220
|
-
.widget
|
|
219
|
+
.widget-body {
|
|
221
220
|
padding: 20px;
|
|
222
221
|
}
|
|
223
|
-
.success {
|
|
224
|
-
color: #D4AF37;
|
|
225
|
-
font
|
|
226
|
-
margin
|
|
227
|
-
font
|
|
222
|
+
.success {
|
|
223
|
+
color: #D4AF37;
|
|
224
|
+
font-weight: 700;
|
|
225
|
+
margin-bottom: 16px;
|
|
226
|
+
font-size: 18px;
|
|
228
227
|
display: flex;
|
|
229
|
-
align
|
|
228
|
+
align-items: center;
|
|
230
229
|
gap: 8px;
|
|
231
230
|
}
|
|
232
|
-
.error {
|
|
233
|
-
color: #ef4444;
|
|
234
|
-
font
|
|
235
|
-
margin
|
|
236
|
-
font
|
|
231
|
+
.error {
|
|
232
|
+
color: #ef4444;
|
|
233
|
+
font-weight: 700;
|
|
234
|
+
margin-bottom: 16px;
|
|
235
|
+
font-size: 18px;
|
|
237
236
|
}
|
|
238
|
-
.profile
|
|
237
|
+
.profile-img {
|
|
239
238
|
width: 100px;
|
|
240
239
|
height: 100px;
|
|
241
|
-
border
|
|
242
|
-
object
|
|
240
|
+
border-radius: 50%;
|
|
241
|
+
object-fit: cover;
|
|
243
242
|
border: 4px solid #D4AF37;
|
|
244
|
-
margin
|
|
245
|
-
box
|
|
243
|
+
margin-bottom: 16px;
|
|
244
|
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
246
245
|
}
|
|
247
|
-
.product
|
|
248
|
-
width: 100
|
|
246
|
+
.product-img {
|
|
247
|
+
width: 100%;
|
|
249
248
|
height: 200px;
|
|
250
|
-
object
|
|
251
|
-
border
|
|
252
|
-
margin
|
|
249
|
+
object-fit: cover;
|
|
250
|
+
border-radius: 8px;
|
|
251
|
+
margin-bottom: 12px;
|
|
253
252
|
}
|
|
254
|
-
.card {
|
|
255
|
-
border: 1px solid #e5e7eb;
|
|
256
|
-
padding: 16px;
|
|
257
|
-
border
|
|
253
|
+
.card {
|
|
254
|
+
border: 1px solid #e5e7eb;
|
|
255
|
+
padding: 16px;
|
|
256
|
+
border-radius: 12px;
|
|
258
257
|
background: #f9fafb;
|
|
259
|
-
margin
|
|
258
|
+
margin-bottom: 12px;
|
|
260
259
|
transition: all 0.2s ease;
|
|
261
|
-
box
|
|
260
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
262
261
|
}
|
|
263
262
|
.card:hover {
|
|
264
|
-
border
|
|
265
|
-
box
|
|
263
|
+
border-color: #D4AF37;
|
|
264
|
+
box-shadow: 0 4px 6px rgba(212, 175, 55, 0.2);
|
|
266
265
|
transform: translateY(-2px);
|
|
267
266
|
}
|
|
268
|
-
.field { margin: 10px 0; font
|
|
269
|
-
.label { color: #6b7280; font
|
|
270
|
-
.token {
|
|
271
|
-
margin
|
|
272
|
-
padding: 12px;
|
|
273
|
-
background: #f3f4f6;
|
|
274
|
-
border
|
|
275
|
-
font
|
|
276
|
-
word
|
|
277
|
-
font
|
|
267
|
+
.field { margin: 10px 0; font-size: 14px; color: #374151; }
|
|
268
|
+
.label { color: #6b7280; font-size: 13px; margin-right: 8px; font-weight: 500; }
|
|
269
|
+
.token {
|
|
270
|
+
margin-top: 12px;
|
|
271
|
+
padding: 12px;
|
|
272
|
+
background: #f3f4f6;
|
|
273
|
+
border-radius: 8px;
|
|
274
|
+
font-size: 12px;
|
|
275
|
+
word-break: break-all;
|
|
276
|
+
font-family: monospace;
|
|
278
277
|
border: 1px solid #D4AF37;
|
|
279
278
|
color: #D4AF37;
|
|
280
279
|
}
|
|
281
|
-
.grid {
|
|
282
|
-
display: grid;
|
|
283
|
-
grid
|
|
284
|
-
gap: 16px;
|
|
280
|
+
.grid {
|
|
281
|
+
display: grid;
|
|
282
|
+
grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
|
|
283
|
+
gap: 16px;
|
|
285
284
|
}
|
|
286
|
-
.product
|
|
287
|
-
border: 1px solid #e5e7eb;
|
|
288
|
-
border
|
|
285
|
+
.product-card {
|
|
286
|
+
border: 1px solid #e5e7eb;
|
|
287
|
+
border-radius: 12px;
|
|
289
288
|
background: #ffffff;
|
|
290
289
|
transition: all 0.3s ease;
|
|
291
290
|
cursor: pointer;
|
|
292
291
|
overflow: hidden;
|
|
293
|
-
box
|
|
292
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
294
293
|
}
|
|
295
|
-
.product
|
|
296
|
-
border
|
|
297
|
-
box
|
|
294
|
+
.product-card:hover {
|
|
295
|
+
border-color: #D4AF37;
|
|
296
|
+
box-shadow: 0 8px 16px rgba(212, 175, 55, 0.3);
|
|
298
297
|
transform: translateY(-4px);
|
|
299
298
|
}
|
|
300
|
-
.product
|
|
301
|
-
width: 100
|
|
299
|
+
.product-card-img {
|
|
300
|
+
width: 100%;
|
|
302
301
|
height: 200px;
|
|
303
|
-
object
|
|
302
|
+
object-fit: cover;
|
|
304
303
|
background: #f9fafb;
|
|
305
304
|
}
|
|
306
|
-
.product
|
|
305
|
+
.product-card-body {
|
|
307
306
|
padding: 16px;
|
|
308
307
|
}
|
|
309
|
-
.product
|
|
310
|
-
font
|
|
311
|
-
font
|
|
312
|
-
margin
|
|
313
|
-
line
|
|
308
|
+
.product-name {
|
|
309
|
+
font-weight: 700;
|
|
310
|
+
font-size: 16px;
|
|
311
|
+
margin-bottom: 8px;
|
|
312
|
+
line-height: 1.3;
|
|
314
313
|
color: #1a1a1a;
|
|
315
314
|
}
|
|
316
|
-
.product
|
|
317
|
-
font
|
|
315
|
+
.product-desc {
|
|
316
|
+
font-size: 13px;
|
|
318
317
|
color: #6b7280;
|
|
319
|
-
margin
|
|
320
|
-
line
|
|
318
|
+
margin-bottom: 12px;
|
|
319
|
+
line-height: 1.5;
|
|
321
320
|
}
|
|
322
|
-
.empty {
|
|
323
|
-
color: #9ca3af;
|
|
324
|
-
text
|
|
325
|
-
padding: 60px 20px;
|
|
326
|
-
font
|
|
321
|
+
.empty {
|
|
322
|
+
color: #9ca3af;
|
|
323
|
+
text-align: center;
|
|
324
|
+
padding: 60px 20px;
|
|
325
|
+
font-size: 15px;
|
|
327
326
|
}
|
|
328
327
|
.price {
|
|
329
328
|
color: #D4AF37;
|
|
330
|
-
font
|
|
331
|
-
font
|
|
329
|
+
font-weight: 700;
|
|
330
|
+
font-size: 20px;
|
|
332
331
|
}
|
|
333
|
-
.stock
|
|
334
|
-
display: inline
|
|
332
|
+
.stock-badge {
|
|
333
|
+
display: inline-block;
|
|
335
334
|
padding: 6px 12px;
|
|
336
|
-
border
|
|
337
|
-
font
|
|
338
|
-
font
|
|
335
|
+
border-radius: 6px;
|
|
336
|
+
font-size: 12px;
|
|
337
|
+
font-weight: 600;
|
|
339
338
|
background: rgba(212, 175, 55, 0.1);
|
|
340
339
|
color: #D4AF37;
|
|
341
340
|
border: 1px solid rgba(212, 175, 55, 0.3);
|
|
342
|
-
margin
|
|
341
|
+
margin-top: 8px;
|
|
343
342
|
}
|
|
344
343
|
</style>
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
344
|
+
</head>
|
|
345
|
+
<body>
|
|
346
|
+
<div id="root">Loading...</div>
|
|
347
|
+
<script>
|
|
348
|
+
(function() {
|
|
349
|
+
function render() {
|
|
350
|
+
const data = (window.openai && window.openai.toolOutput) || {};
|
|
351
|
+
const root = document.getElementById('root');
|
|
353
352
|
|
|
354
353
|
${getWidgetRenderFunction(routePath)}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
354
|
+
|
|
355
|
+
root.innerHTML = html;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Render immediately if data available
|
|
359
|
+
if (window.openai && window.openai.toolOutput) {
|
|
360
|
+
render();
|
|
361
|
+
} else {
|
|
362
|
+
// Wait for data to be injected
|
|
363
|
+
setTimeout(render, 50);
|
|
364
|
+
}
|
|
365
|
+
})();
|
|
367
366
|
</script>
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
</body>
|
|
368
|
+
</html>`;
|
|
370
369
|
return baseTemplate;
|
|
371
370
|
}
|
|
372
371
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui-next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAa,MAAM,sBAAsB,CAAC;AAGlE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ui-next/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAa,MAAM,sBAAsB,CAAC;AAGlE,SAAS,oBAAoB,CAAC,QAAgB,EAAE,MAAc;IAC5D,IAAI,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE7C,4CAA4C;IAC5C,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,mEAAmE,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;QACpG,IAAI,CAAC;YACH,0CAA0C;YAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,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;;;;;;;;;;;;;;;;;;OAkBN,CAAC;QAEJ,KAAK,eAAe;YAClB,OAAO;;;;;;;;;;;;;;;;;;OAkBN,CAAC;QAEJ,KAAK,eAAe;YAClB,OAAO;;;;;;;;;;;;;;;;;;;;;;;OAuBN,CAAC;QAEJ,KAAK,YAAY;YACf,OAAO;;;;;;;;;;;;;;;OAeN,CAAC;QAEJ,KAAK,cAAc;YACjB,OAAO;;;;;;;;;;;;;;;OAeN,CAAC;QAEJ,KAAK,cAAc;YACjB,OAAO;;;;;;;;;;;;;OAaN,CAAC;QAEJ,KAAK,eAAe;YAClB,OAAO;;;;;;;;;;;;;;;;OAgBN,CAAC;QAEJ,KAAK,iBAAiB;YACpB,OAAO;;;;;;;;;;;;;;;;;;;;;;OAsBN,CAAC;QAEJ,KAAK,iBAAiB;YACpB,OAAO;;;;;;;;;;;;OAYN,CAAC;QAEJ;YACE,OAAO;;OAEN,CAAC;IACN,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nitrostack",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.51",
|
|
4
4
|
"description": "NitroStack - Build powerful MCP servers with TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/core/index.js",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
|
-
"build": "tsc &&
|
|
37
|
+
"build": "tsc && chmod +x dist/cli/index.js",
|
|
38
38
|
"dev": "tsc --watch",
|
|
39
39
|
"test": "jest",
|
|
40
40
|
"prepublishOnly": "npm run build"
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"commander": "^12.1.0",
|
|
63
63
|
"cors": "^2.8.5",
|
|
64
64
|
"dotenv": "^17.2.3",
|
|
65
|
-
"esbuild": "^0.24.2",
|
|
66
65
|
"express": "^4.21.2",
|
|
67
66
|
"fs-extra": "^11.3.2",
|
|
68
67
|
"http-proxy-middleware": "^3.0.3",
|
|
@@ -11,7 +11,7 @@ interface WidgetRendererProps {
|
|
|
11
11
|
|
|
12
12
|
export function WidgetRenderer({ uri, data, className = '' }: WidgetRendererProps) {
|
|
13
13
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
// Check if we're in dev mode (localhost)
|
|
16
16
|
const isDevMode =
|
|
17
17
|
typeof window !== 'undefined' &&
|
|
@@ -26,9 +26,9 @@ export function WidgetRenderer({ uri, data, className = '' }: WidgetRendererProp
|
|
|
26
26
|
// Remove leading slash if present
|
|
27
27
|
const widgetPath = uri.startsWith('/') ? uri.substring(1) : uri;
|
|
28
28
|
const widgetUrl = `http://localhost:3001/${widgetPath}`;
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
console.log('Loading widget in dev mode:', { uri, widgetPath, widgetUrl, data });
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
// Set up onload handler BEFORE setting src
|
|
33
33
|
iframeRef.current.onload = () => {
|
|
34
34
|
console.log('Widget iframe loaded, posting data...');
|
|
@@ -48,7 +48,7 @@ export function WidgetRenderer({ uri, data, className = '' }: WidgetRendererProp
|
|
|
48
48
|
}
|
|
49
49
|
}, 300);
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
// Set src AFTER onload handler is set
|
|
53
53
|
iframeRef.current.src = widgetUrl;
|
|
54
54
|
} else {
|
|
@@ -56,25 +56,16 @@ export function WidgetRenderer({ uri, data, className = '' }: WidgetRendererProp
|
|
|
56
56
|
const loadProductionWidget = async () => {
|
|
57
57
|
try {
|
|
58
58
|
// Convert widget route/path to resource URI format if needed
|
|
59
|
-
// Routes like "/calculator-result" or "calculator-result" should become "
|
|
60
|
-
// But if it's already a full URI, use it.
|
|
59
|
+
// Routes like "/calculator-result" or "calculator-result" should become "widget://calculator-result"
|
|
61
60
|
let resourceUri = uri;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// Remove .html extension if present in ID to avoid double extension
|
|
67
|
-
const cleanId = widgetId.replace(/\.html$/, '');
|
|
68
|
-
resourceUri = `ui://widget/${cleanId}.html`;
|
|
69
|
-
} else if (uri.startsWith('widget://')) {
|
|
70
|
-
// Legacy support or if user manually used widget://
|
|
71
|
-
// Convert to ui://widget/ if needed, or just use as is if the server supports it.
|
|
72
|
-
// But component.ts uses ui://widget/
|
|
73
|
-
// Let's assume the server resource map uses the full URI as key.
|
|
61
|
+
if (!uri.startsWith('widget://') && !uri.startsWith('http://') && !uri.startsWith('https://')) {
|
|
62
|
+
// Remove leading slash if present
|
|
63
|
+
const widgetPath = uri.startsWith('/') ? uri.substring(1) : uri;
|
|
64
|
+
resourceUri = `widget://${widgetPath}`;
|
|
74
65
|
}
|
|
75
|
-
|
|
66
|
+
|
|
76
67
|
console.log('Loading widget in production mode:', { originalUri: uri, resourceUri, data });
|
|
77
|
-
|
|
68
|
+
|
|
78
69
|
const response = await fetch(`/api/resources/${encodeURIComponent(resourceUri)}`);
|
|
79
70
|
const result = await response.json();
|
|
80
71
|
|
|
@@ -97,9 +88,9 @@ export function WidgetRenderer({ uri, data, className = '' }: WidgetRendererProp
|
|
|
97
88
|
console.warn('⚠️ Widget resource found but no content:', { resourceUri, result });
|
|
98
89
|
}
|
|
99
90
|
} catch (error) {
|
|
100
|
-
console.error('❌ Failed to load widget:', {
|
|
101
|
-
originalUri: uri,
|
|
102
|
-
resourceUri,
|
|
91
|
+
console.error('❌ Failed to load widget:', {
|
|
92
|
+
originalUri: uri,
|
|
93
|
+
resourceUri,
|
|
103
94
|
error: error instanceof Error ? error.message : String(error),
|
|
104
95
|
stack: error instanceof Error ? error.stack : undefined
|
|
105
96
|
});
|
|
@@ -111,7 +102,7 @@ export function WidgetRenderer({ uri, data, className = '' }: WidgetRendererProp
|
|
|
111
102
|
}, [uri, data, isDevMode]);
|
|
112
103
|
|
|
113
104
|
const isInChat = className?.includes('widget-in-chat');
|
|
114
|
-
|
|
105
|
+
|
|
115
106
|
return (
|
|
116
107
|
<iframe
|
|
117
108
|
ref={iframeRef}
|
package/src/studio/middleware.ts
CHANGED
|
@@ -8,13 +8,12 @@ export function middleware(request: NextRequest) {
|
|
|
8
8
|
// In development, proxy widget requests to the widget dev server
|
|
9
9
|
if (process.env.NODE_ENV === 'development' && process.env.WIDGETS_DEV_MODE === 'true') {
|
|
10
10
|
const widgetsDevPort = process.env.WIDGETS_DEV_PORT || '3001';
|
|
11
|
-
console.log(`[Middleware] Proxying widgets to port ${widgetsDevPort}`);
|
|
12
11
|
|
|
13
12
|
// Proxy /widgets/* to widget dev server
|
|
14
13
|
if (pathname.startsWith('/widgets/')) {
|
|
15
14
|
const widgetPath = pathname.replace('/widgets/', '');
|
|
16
15
|
const targetUrl = `http://localhost:${widgetsDevPort}/${widgetPath}`;
|
|
17
|
-
|
|
16
|
+
|
|
18
17
|
return NextResponse.rewrite(new URL(targetUrl));
|
|
19
18
|
}
|
|
20
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ToolDecorator as Tool,
|
|
3
|
-
Widget,
|
|
4
|
-
z,
|
|
1
|
+
import {
|
|
2
|
+
ToolDecorator as Tool,
|
|
3
|
+
Widget,
|
|
4
|
+
z,
|
|
5
5
|
ExecutionContext,
|
|
6
6
|
Injectable,
|
|
7
7
|
UseMiddleware,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
} from 'nitrostack';
|
|
14
14
|
import { DatabaseService } from '../../services/database.service.js';
|
|
15
15
|
import { LoggingMiddleware } from '../../middleware/logging.middleware.js';
|
|
16
|
-
|
|
16
|
+
import { TransformInterceptor } from '../../interceptors/transform.interceptor.js';
|
|
17
17
|
import { ValidationPipe } from '../../pipes/validation.pipe.js';
|
|
18
18
|
import { GlobalExceptionFilter } from '../../filters/global-exception.filter.js';
|
|
19
19
|
|
|
@@ -31,7 +31,7 @@ import { GlobalExceptionFilter } from '../../filters/global-exception.filter.js'
|
|
|
31
31
|
*/
|
|
32
32
|
@Injectable()
|
|
33
33
|
export class ProductsTools {
|
|
34
|
-
constructor(private database: DatabaseService) {
|
|
34
|
+
constructor(private database: DatabaseService) {}
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
37
|
* Browse products - No authentication required
|
|
@@ -102,7 +102,7 @@ export class ProductsTools {
|
|
|
102
102
|
})
|
|
103
103
|
@Widget('products-grid')
|
|
104
104
|
@UseMiddleware(LoggingMiddleware)
|
|
105
|
-
|
|
105
|
+
@UseInterceptors(TransformInterceptor)
|
|
106
106
|
@UsePipes(ValidationPipe)
|
|
107
107
|
@UseFilters(GlobalExceptionFilter)
|
|
108
108
|
@Cache({ ttl: 60, key: (input) => `products:${input.category}:${input.search}:${input.page}` })
|
|
@@ -112,50 +112,50 @@ export class ProductsTools {
|
|
|
112
112
|
const page = input.page || 1;
|
|
113
113
|
const limit = input.limit || 10;
|
|
114
114
|
const search = input.search || '';
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
const offset = (page - 1) * limit;
|
|
117
|
-
|
|
117
|
+
|
|
118
118
|
let query = 'SELECT * FROM products WHERE 1=1';
|
|
119
119
|
const params: any[] = [];
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
// Filter by category
|
|
122
122
|
if (category && category !== 'All') {
|
|
123
123
|
query += ' AND category = ?';
|
|
124
124
|
params.push(category);
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
// Search by name
|
|
128
128
|
if (search) {
|
|
129
129
|
query += ' AND name LIKE ?';
|
|
130
130
|
params.push(`%${search}%`);
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
// Add pagination
|
|
134
134
|
query += ' ORDER BY name LIMIT ? OFFSET ?';
|
|
135
135
|
params.push(limit, offset);
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
const products = this.database.query(query, params);
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
// Get total count
|
|
140
140
|
let countQuery = 'SELECT COUNT(*) as count FROM products WHERE 1=1';
|
|
141
141
|
const countParams: any[] = [];
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
if (category && category !== 'All') {
|
|
144
144
|
countQuery += ' AND category = ?';
|
|
145
145
|
countParams.push(category);
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
|
|
148
148
|
if (search) {
|
|
149
149
|
countQuery += ' AND name LIKE ?';
|
|
150
150
|
countParams.push(`%${search}%`);
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
|
|
153
153
|
const result = this.database.queryOne<{ count: number }>(countQuery, countParams);
|
|
154
154
|
const count = result?.count || 0;
|
|
155
155
|
const totalPages = Math.ceil(count / limit);
|
|
156
|
-
|
|
156
|
+
|
|
157
157
|
context.logger.info(`Browsing products: category=${category}, search=${search}, page=${page}, found=${products.length} products`);
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
return {
|
|
160
160
|
products,
|
|
161
161
|
pagination: {
|
|
@@ -199,27 +199,27 @@ export class ProductsTools {
|
|
|
199
199
|
})
|
|
200
200
|
@Widget('product-card')
|
|
201
201
|
@UseMiddleware(LoggingMiddleware)
|
|
202
|
-
|
|
202
|
+
@UseInterceptors(TransformInterceptor)
|
|
203
203
|
@UsePipes(ValidationPipe)
|
|
204
204
|
@UseFilters(GlobalExceptionFilter)
|
|
205
205
|
@Cache({ ttl: 300, key: (input) => `product:${input.product_id}` }) // Cache for 5 minutes
|
|
206
206
|
@RateLimit({ requests: 100, window: '1m' }) // 100 requests per minute
|
|
207
207
|
async getProductDetails(input: any, context: ExecutionContext) {
|
|
208
208
|
const product = this.database.queryOne(`SELECT * FROM products WHERE id = ?`, [input.product_id]);
|
|
209
|
-
|
|
209
|
+
|
|
210
210
|
if (!product) {
|
|
211
211
|
throw new Error(`Product with ID ${input.product_id} not found`);
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
|
|
214
214
|
context.logger.info(`Retrieved details for product: ${(product as any).name}`);
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
return {
|
|
217
217
|
product,
|
|
218
218
|
availability: (product as any).stock > 0 ? 'In Stock' : 'Out of Stock',
|
|
219
|
-
stockMessage: (product as any).stock > 10
|
|
220
|
-
? 'Available'
|
|
221
|
-
: (product as any).stock > 0
|
|
222
|
-
? `Only ${(product as any).stock} left!`
|
|
219
|
+
stockMessage: (product as any).stock > 10
|
|
220
|
+
? 'Available'
|
|
221
|
+
: (product as any).stock > 0
|
|
222
|
+
? `Only ${(product as any).stock} left!`
|
|
223
223
|
: 'Currently unavailable',
|
|
224
224
|
};
|
|
225
225
|
}
|
|
@@ -246,7 +246,7 @@ export class ProductsTools {
|
|
|
246
246
|
})
|
|
247
247
|
@Widget('categories')
|
|
248
248
|
@UseMiddleware(LoggingMiddleware)
|
|
249
|
-
|
|
249
|
+
@UseInterceptors(TransformInterceptor)
|
|
250
250
|
@Cache({ ttl: 300 }) // Cache for 5 minutes
|
|
251
251
|
async getCategories(input: any, context: ExecutionContext) {
|
|
252
252
|
const categories = this.database.query(`
|
|
@@ -255,7 +255,7 @@ export class ProductsTools {
|
|
|
255
255
|
GROUP BY category
|
|
256
256
|
ORDER BY category
|
|
257
257
|
`);
|
|
258
|
-
|
|
258
|
+
|
|
259
259
|
return {
|
|
260
260
|
categories: categories.map((c: any) => ({
|
|
261
261
|
name: c.category,
|