nitrostack 1.0.55 → 1.0.57
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/init.d.ts.map +1 -1
- package/dist/cli/commands/init.js +14 -9
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/widgets/hooks/index.d.ts +7 -0
- package/dist/widgets/hooks/index.d.ts.map +1 -0
- package/dist/widgets/hooks/index.js +7 -0
- package/dist/widgets/hooks/index.js.map +1 -0
- package/dist/widgets/hooks/use-display-mode.d.ts +11 -0
- package/dist/widgets/hooks/use-display-mode.d.ts.map +1 -0
- package/dist/widgets/hooks/use-display-mode.js +13 -0
- package/dist/widgets/hooks/use-display-mode.js.map +1 -0
- package/dist/widgets/hooks/use-max-height.d.ts +10 -0
- package/dist/widgets/hooks/use-max-height.d.ts.map +1 -0
- package/dist/widgets/hooks/use-max-height.js +13 -0
- package/dist/widgets/hooks/use-max-height.js.map +1 -0
- package/dist/widgets/hooks/use-openai-global.d.ts +12 -0
- package/dist/widgets/hooks/use-openai-global.d.ts.map +1 -0
- package/dist/widgets/hooks/use-openai-global.js +32 -0
- package/dist/widgets/hooks/use-openai-global.js.map +1 -0
- package/dist/widgets/hooks/use-theme.d.ts +10 -0
- package/dist/widgets/hooks/use-theme.d.ts.map +1 -0
- package/dist/widgets/hooks/use-theme.js +12 -0
- package/dist/widgets/hooks/use-theme.js.map +1 -0
- package/dist/widgets/hooks/use-widget-state.d.ts +18 -0
- package/dist/widgets/hooks/use-widget-state.d.ts.map +1 -0
- package/dist/widgets/hooks/use-widget-state.js +27 -0
- package/dist/widgets/hooks/use-widget-state.js.map +1 -0
- package/dist/widgets/hooks/useWidgetSDK.d.ts +47 -0
- package/dist/widgets/hooks/useWidgetSDK.d.ts.map +1 -0
- package/dist/widgets/hooks/useWidgetSDK.js +67 -0
- package/dist/widgets/hooks/useWidgetSDK.js.map +1 -0
- package/dist/widgets/index.d.ts +7 -1
- package/dist/widgets/index.d.ts.map +1 -1
- package/dist/widgets/index.js +11 -1
- package/dist/widgets/index.js.map +1 -1
- package/dist/widgets/runtime/WidgetLayout.d.ts +32 -0
- package/dist/widgets/runtime/WidgetLayout.d.ts.map +1 -0
- package/dist/widgets/runtime/WidgetLayout.js +143 -0
- package/dist/widgets/runtime/WidgetLayout.js.map +1 -0
- package/dist/widgets/runtime/widget-polyfill.d.ts +1 -0
- package/dist/widgets/runtime/widget-polyfill.d.ts.map +1 -0
- package/dist/widgets/runtime/widget-polyfill.js +28 -0
- package/dist/widgets/runtime/widget-polyfill.js.map +1 -0
- package/dist/widgets/sdk.d.ts +109 -0
- package/dist/widgets/sdk.d.ts.map +1 -0
- package/dist/widgets/sdk.js +221 -0
- package/dist/widgets/sdk.js.map +1 -0
- package/dist/widgets/types.d.ts +89 -0
- package/dist/widgets/types.d.ts.map +1 -0
- package/dist/widgets/types.js +8 -0
- package/dist/widgets/types.js.map +1 -0
- package/dist/widgets/utils/media-queries.d.ts +34 -0
- package/dist/widgets/utils/media-queries.d.ts.map +1 -0
- package/dist/widgets/utils/media-queries.js +42 -0
- package/dist/widgets/utils/media-queries.js.map +1 -0
- package/package.json +2 -2
- package/src/studio/app/chat/page.tsx +274 -137
- package/src/studio/app/globals.css +140 -64
- package/src/studio/branding.md +807 -0
- package/src/studio/components/WidgetRenderer.tsx +222 -16
- package/src/studio/lib/llm-service.ts +39 -39
- package/templates/typescript-oauth/{env.example → .env.example} +4 -10
- package/templates/typescript-oauth/README.md +226 -306
- package/templates/typescript-oauth/package-lock.json +4253 -0
- package/templates/typescript-oauth/package.json +10 -5
- package/templates/typescript-oauth/src/app.module.ts +39 -36
- package/templates/typescript-oauth/src/guards/oauth.guard.ts +0 -1
- package/templates/typescript-oauth/src/index.ts +22 -30
- package/templates/typescript-oauth/src/modules/flights/booking.tools.ts +323 -0
- package/templates/typescript-oauth/src/modules/flights/flights.module.ts +14 -0
- package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +231 -0
- package/templates/typescript-oauth/src/modules/flights/flights.resources.ts +215 -0
- package/templates/typescript-oauth/src/modules/flights/flights.tools.ts +457 -0
- package/templates/typescript-oauth/src/services/duffel.service.ts +285 -0
- package/templates/typescript-oauth/src/widgets/app/airport-search/page.tsx +270 -0
- package/templates/typescript-oauth/src/widgets/app/flight-details/page.tsx +261 -0
- package/templates/typescript-oauth/src/widgets/app/flight-search-results/page.tsx +378 -0
- package/templates/typescript-oauth/src/widgets/app/globals.css +167 -0
- package/templates/typescript-oauth/src/widgets/app/layout.tsx +6 -2
- package/templates/typescript-oauth/src/widgets/app/order-cancellation/page.tsx +207 -0
- package/templates/typescript-oauth/src/widgets/app/order-summary/page.tsx +245 -0
- package/templates/typescript-oauth/src/widgets/app/payment-confirmation/page.tsx +152 -0
- package/templates/typescript-oauth/src/widgets/app/seat-selection/page.tsx +486 -0
- package/templates/typescript-oauth/src/widgets/next-env.d.ts +5 -0
- package/templates/typescript-oauth/src/widgets/package-lock.json +155 -126
- package/templates/typescript-oauth/src/widgets/widget-manifest.json +374 -27
- package/templates/typescript-pizzaz/IMPLEMENTATION.md +98 -0
- package/templates/typescript-pizzaz/README.md +233 -0
- package/templates/typescript-pizzaz/package.json +31 -0
- package/templates/typescript-pizzaz/src/app.module.ts +28 -0
- package/templates/typescript-pizzaz/src/index.ts +30 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.data.ts +106 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +11 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.service.ts +60 -0
- package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tools.ts +197 -0
- package/templates/typescript-pizzaz/src/widgets/app/layout.tsx +18 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-list/page.tsx +272 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-map/page.tsx +216 -0
- package/templates/typescript-pizzaz/src/widgets/app/pizza-shop/page.tsx +374 -0
- package/templates/typescript-pizzaz/src/widgets/components/CompactShopCard.tsx +144 -0
- package/templates/typescript-pizzaz/src/widgets/components/PizzaCard.tsx +191 -0
- package/templates/typescript-pizzaz/src/widgets/package.json +30 -0
- package/templates/typescript-pizzaz/src/widgets/widget-manifest.json +253 -0
- package/templates/typescript-pizzaz/tsconfig.json +30 -0
- package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +0 -1
- package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +102 -56
- package/templates/typescript-starter/src/widgets/app/layout.tsx +6 -2
- package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +0 -702
- package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +0 -1260
- package/templates/typescript-auth/README.md +0 -402
- package/templates/typescript-auth/env.example +0 -25
- package/templates/typescript-auth/package.json +0 -36
- package/templates/typescript-auth/src/app.module.ts +0 -103
- package/templates/typescript-auth/src/db/database.ts +0 -160
- package/templates/typescript-auth/src/db/seed.ts +0 -374
- package/templates/typescript-auth/src/db/setup.ts +0 -87
- package/templates/typescript-auth/src/events/analytics.service.ts +0 -52
- package/templates/typescript-auth/src/events/notification.service.ts +0 -40
- package/templates/typescript-auth/src/filters/global-exception.filter.ts +0 -28
- package/templates/typescript-auth/src/guards/README.md +0 -75
- package/templates/typescript-auth/src/guards/jwt.guard.ts +0 -105
- package/templates/typescript-auth/src/health/database.health.ts +0 -41
- package/templates/typescript-auth/src/index.ts +0 -29
- package/templates/typescript-auth/src/interceptors/transform.interceptor.ts +0 -24
- package/templates/typescript-auth/src/middleware/logging.middleware.ts +0 -42
- package/templates/typescript-auth/src/modules/addresses/addresses.module.ts +0 -16
- package/templates/typescript-auth/src/modules/addresses/addresses.prompts.ts +0 -114
- package/templates/typescript-auth/src/modules/addresses/addresses.resources.ts +0 -40
- package/templates/typescript-auth/src/modules/addresses/addresses.tools.ts +0 -284
- package/templates/typescript-auth/src/modules/auth/auth.module.ts +0 -16
- package/templates/typescript-auth/src/modules/auth/auth.prompts.ts +0 -147
- package/templates/typescript-auth/src/modules/auth/auth.resources.ts +0 -84
- package/templates/typescript-auth/src/modules/auth/auth.tools.ts +0 -139
- package/templates/typescript-auth/src/modules/cart/cart.module.ts +0 -16
- package/templates/typescript-auth/src/modules/cart/cart.prompts.ts +0 -95
- package/templates/typescript-auth/src/modules/cart/cart.resources.ts +0 -44
- package/templates/typescript-auth/src/modules/cart/cart.tools.ts +0 -277
- package/templates/typescript-auth/src/modules/orders/orders.module.ts +0 -16
- package/templates/typescript-auth/src/modules/orders/orders.prompts.ts +0 -88
- package/templates/typescript-auth/src/modules/orders/orders.resources.ts +0 -48
- package/templates/typescript-auth/src/modules/orders/orders.tools.ts +0 -303
- package/templates/typescript-auth/src/modules/products/products.module.ts +0 -16
- package/templates/typescript-auth/src/modules/products/products.prompts.ts +0 -146
- package/templates/typescript-auth/src/modules/products/products.resources.ts +0 -98
- package/templates/typescript-auth/src/modules/products/products.tools.ts +0 -266
- package/templates/typescript-auth/src/pipes/validation.pipe.ts +0 -42
- package/templates/typescript-auth/src/services/database.service.ts +0 -90
- package/templates/typescript-auth/src/widgets/app/add-to-cart/page.tsx +0 -122
- package/templates/typescript-auth/src/widgets/app/address-added/page.tsx +0 -116
- package/templates/typescript-auth/src/widgets/app/address-deleted/page.tsx +0 -105
- package/templates/typescript-auth/src/widgets/app/address-list/page.tsx +0 -139
- package/templates/typescript-auth/src/widgets/app/address-updated/page.tsx +0 -153
- package/templates/typescript-auth/src/widgets/app/cart-cleared/page.tsx +0 -86
- package/templates/typescript-auth/src/widgets/app/cart-updated/page.tsx +0 -116
- package/templates/typescript-auth/src/widgets/app/categories/page.tsx +0 -134
- package/templates/typescript-auth/src/widgets/app/layout.tsx +0 -21
- package/templates/typescript-auth/src/widgets/app/login-result/page.tsx +0 -129
- package/templates/typescript-auth/src/widgets/app/order-confirmation/page.tsx +0 -231
- package/templates/typescript-auth/src/widgets/app/order-details/page.tsx +0 -225
- package/templates/typescript-auth/src/widgets/app/order-history/page.tsx +0 -218
- package/templates/typescript-auth/src/widgets/app/product-card/page.tsx +0 -121
- package/templates/typescript-auth/src/widgets/app/products-grid/page.tsx +0 -198
- package/templates/typescript-auth/src/widgets/app/shopping-cart/page.tsx +0 -187
- package/templates/typescript-auth/src/widgets/app/whoami/page.tsx +0 -165
- package/templates/typescript-auth/src/widgets/next.config.js +0 -38
- package/templates/typescript-auth/src/widgets/package.json +0 -18
- package/templates/typescript-auth/src/widgets/styles/ecommerce.ts +0 -169
- package/templates/typescript-auth/src/widgets/tsconfig.json +0 -28
- package/templates/typescript-auth/src/widgets/types/tool-data.ts +0 -141
- package/templates/typescript-auth/src/widgets/widget-manifest.json +0 -464
- package/templates/typescript-auth/tsconfig.json +0 -27
- package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +0 -701
- package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +0 -1260
- package/templates/typescript-auth-api-key/README.md +0 -485
- package/templates/typescript-auth-api-key/env.example +0 -17
- package/templates/typescript-auth-api-key/package.json +0 -21
- package/templates/typescript-auth-api-key/src/app.module.ts +0 -38
- package/templates/typescript-auth-api-key/src/guards/apikey.guard.ts +0 -47
- package/templates/typescript-auth-api-key/src/guards/multi-auth.guard.ts +0 -157
- package/templates/typescript-auth-api-key/src/index.ts +0 -47
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.module.ts +0 -12
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.prompts.ts +0 -73
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.resources.ts +0 -60
- package/templates/typescript-auth-api-key/src/modules/calculator/calculator.tools.ts +0 -71
- package/templates/typescript-auth-api-key/src/modules/demo/demo.module.ts +0 -18
- package/templates/typescript-auth-api-key/src/modules/demo/demo.tools.ts +0 -155
- package/templates/typescript-auth-api-key/src/modules/demo/multi-auth.tools.ts +0 -123
- package/templates/typescript-auth-api-key/src/widgets/app/calculator-operations/page.tsx +0 -133
- package/templates/typescript-auth-api-key/src/widgets/app/calculator-result/page.tsx +0 -134
- package/templates/typescript-auth-api-key/src/widgets/app/layout.tsx +0 -14
- package/templates/typescript-auth-api-key/src/widgets/package.json +0 -24
- package/templates/typescript-auth-api-key/src/widgets/widget-manifest.json +0 -48
- package/templates/typescript-auth-api-key/tsconfig.json +0 -23
- package/templates/typescript-oauth/OAUTH_SETUP.md +0 -592
- package/templates/typescript-oauth/src/modules/demo/demo.module.ts +0 -16
- package/templates/typescript-oauth/src/modules/demo/demo.tools.ts +0 -190
- package/templates/typescript-oauth/src/widgets/app/calculator-operations/page.tsx +0 -133
- package/templates/typescript-oauth/src/widgets/app/calculator-result/page.tsx +0 -134
- package/templates/typescript-oauth/src/widgets/out/404.html +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_buildManifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_ssgManifest.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/117-eb57c7ef86f964a4.js +0 -2
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/_not-found/page-dcb83ba3e4d0aafd.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-operations/page-b8913a740073ea8a.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-result/page-ddaaab2fce95dea2.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/layout-cbd3ebdc4ecc5247.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/fd9d1056-749e5812300142af.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/framework-f66176bb897dc684.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-76df43fcef3db344.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-app-f9c40224d04023c5.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/webpack-100b9e646d9c912e.js +0 -1
- package/templates/typescript-oauth/src/widgets/out/calculator-operations.html +0 -1
- package/templates/typescript-oauth/src/widgets/out/calculator-operations.txt +0 -7
- package/templates/typescript-oauth/src/widgets/out/calculator-result.html +0 -1
- package/templates/typescript-oauth/src/widgets/out/calculator-result.txt +0 -7
- package/templates/typescript-starter/src/widgets/app/calculator-operations/page.tsx +0 -133
- /package/templates/{typescript-auth-api-key → typescript-oauth}/src/health/system.health.ts +0 -0
- /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/next.config.js +0 -0
- /package/templates/{typescript-auth-api-key → typescript-pizzaz}/src/widgets/tsconfig.json +0 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget Layout Component
|
|
3
|
+
*
|
|
4
|
+
* Handles all the RPC setup and window.openai initialization automatically.
|
|
5
|
+
* Developers just wrap their widget content with this component.
|
|
6
|
+
*/
|
|
7
|
+
'use client';
|
|
8
|
+
import React, { useEffect } from 'react';
|
|
9
|
+
/**
|
|
10
|
+
* Widget Layout component that sets up the widget runtime
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* export default function RootLayout({ children }) {
|
|
15
|
+
* return (
|
|
16
|
+
* <html lang="en">
|
|
17
|
+
* <body>
|
|
18
|
+
* <WidgetLayout>{children}</WidgetLayout>
|
|
19
|
+
* </body>
|
|
20
|
+
* </html>
|
|
21
|
+
* );
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export function WidgetLayout({ children, onReady }) {
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
console.log('🔧 WidgetLayout: Setting up widget runtime');
|
|
28
|
+
let rpcId = 0;
|
|
29
|
+
const pendingRpcCalls = new Map();
|
|
30
|
+
// RPC helper to call parent methods
|
|
31
|
+
const callParentRpc = (method, ...args) => {
|
|
32
|
+
return new Promise((resolve, reject) => {
|
|
33
|
+
const id = ++rpcId;
|
|
34
|
+
pendingRpcCalls.set(id, { resolve, reject });
|
|
35
|
+
window.parent.postMessage({
|
|
36
|
+
type: 'NITRO_WIDGET_RPC',
|
|
37
|
+
method,
|
|
38
|
+
args,
|
|
39
|
+
id
|
|
40
|
+
}, '*');
|
|
41
|
+
// Timeout after 5 seconds
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
if (pendingRpcCalls.has(id)) {
|
|
44
|
+
pendingRpcCalls.delete(id);
|
|
45
|
+
reject(new Error(`RPC timeout: ${method}`));
|
|
46
|
+
}
|
|
47
|
+
}, 5000);
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
// Listen for messages from parent
|
|
51
|
+
const handleMessage = (event) => {
|
|
52
|
+
// Handle openai data injection
|
|
53
|
+
if (event.data?.type === 'NITRO_INJECT_OPENAI') {
|
|
54
|
+
console.log('📦 WidgetLayout: Received window.openai data from parent');
|
|
55
|
+
const data = event.data.data;
|
|
56
|
+
// Set up window.openai with data + RPC functions
|
|
57
|
+
window.openai = {
|
|
58
|
+
...data,
|
|
59
|
+
// Functions that call back to parent via RPC
|
|
60
|
+
setWidgetState: async (state) => {
|
|
61
|
+
await callParentRpc('setWidgetState', state);
|
|
62
|
+
},
|
|
63
|
+
callTool: async (name, args) => {
|
|
64
|
+
return await callParentRpc('callTool', name, args);
|
|
65
|
+
},
|
|
66
|
+
sendFollowUpMessage: async ({ prompt }) => {
|
|
67
|
+
await callParentRpc('sendFollowUpMessage', { prompt });
|
|
68
|
+
},
|
|
69
|
+
openExternal: ({ href }) => {
|
|
70
|
+
callParentRpc('openExternal', { href });
|
|
71
|
+
},
|
|
72
|
+
requestClose: () => {
|
|
73
|
+
callParentRpc('requestClose');
|
|
74
|
+
},
|
|
75
|
+
requestDisplayMode: async ({ mode }) => {
|
|
76
|
+
return await callParentRpc('requestDisplayMode', { mode });
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
// Dispatch ready event
|
|
80
|
+
const readyEvent = new CustomEvent('openai:ready');
|
|
81
|
+
window.dispatchEvent(readyEvent);
|
|
82
|
+
console.log('✅ WidgetLayout: window.openai initialized');
|
|
83
|
+
// Call onReady callback if provided
|
|
84
|
+
onReady?.();
|
|
85
|
+
}
|
|
86
|
+
// Handle RPC responses
|
|
87
|
+
if (event.data?.type === 'NITRO_WIDGET_RPC_RESPONSE') {
|
|
88
|
+
const { id, result, error } = event.data;
|
|
89
|
+
const pending = pendingRpcCalls.get(id);
|
|
90
|
+
if (pending) {
|
|
91
|
+
pendingRpcCalls.delete(id);
|
|
92
|
+
if (error) {
|
|
93
|
+
pending.reject(new Error(error));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
pending.resolve(result);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// Handle legacy toolOutput for backward compatibility
|
|
101
|
+
if (event.data?.type === 'TOOL_OUTPUT' && event.data?.data) {
|
|
102
|
+
console.log('📦 WidgetLayout: Received legacy toolOutput');
|
|
103
|
+
if (window.openai) {
|
|
104
|
+
window.openai.toolOutput = event.data.data;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
window.addEventListener('message', handleMessage);
|
|
109
|
+
console.log('✅ WidgetLayout: Message listener registered');
|
|
110
|
+
return () => {
|
|
111
|
+
console.log('🔧 WidgetLayout: Cleaning up');
|
|
112
|
+
window.removeEventListener('message', handleMessage);
|
|
113
|
+
};
|
|
114
|
+
}, [onReady]);
|
|
115
|
+
// Set up ResizeObserver to track content height
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
// Reset body margins/padding for accurate measurement
|
|
118
|
+
document.body.style.margin = '0';
|
|
119
|
+
document.body.style.padding = '0';
|
|
120
|
+
document.body.style.overflow = 'hidden';
|
|
121
|
+
const contentWrapper = document.getElementById('nitro-widget-content');
|
|
122
|
+
if (!contentWrapper)
|
|
123
|
+
return;
|
|
124
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
125
|
+
for (const entry of entries) {
|
|
126
|
+
const height = entry.contentRect.height;
|
|
127
|
+
const finalHeight = Math.ceil(height) + 16;
|
|
128
|
+
console.log('📐 Widget content height:', height, '→ sending:', finalHeight);
|
|
129
|
+
// Send height update to parent
|
|
130
|
+
window.parent.postMessage({
|
|
131
|
+
type: 'NITRO_WIDGET_RESIZE',
|
|
132
|
+
height: finalHeight // Add small buffer
|
|
133
|
+
}, '*');
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
resizeObserver.observe(contentWrapper);
|
|
137
|
+
return () => {
|
|
138
|
+
resizeObserver.disconnect();
|
|
139
|
+
};
|
|
140
|
+
}, []);
|
|
141
|
+
return React.createElement("div", { id: "nitro-widget-content" }, children);
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=WidgetLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WidgetLayout.js","sourceRoot":"","sources":["../../../src/widgets/runtime/WidgetLayout.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,CAAC;AAEb,OAAO,KAAK,EAAE,EAAE,SAAS,EAAkB,MAAM,OAAO,CAAC;AAUzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAqB;IACjE,SAAS,CAAC,GAAG,EAAE;QACX,OAAO,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QAE1D,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,eAAe,GAAG,IAAI,GAAG,EAAmD,CAAC;QAEnF,oCAAoC;QACpC,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,GAAG,IAAW,EAAE,E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,OAAO,EAAE,CAAC;gBAC1B,MAAM,MAAM,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC;gBACxC,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;gBAC3C,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;gBAC5E,+BAA+B;gBAC/B,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;oBACtB,IAAI,EAAE,qBAAqB;oBAC3B,MAAM,EAAE,WAAW,CAAC,mBAAmB;iBAC1C,EAAE,GAAG,CAAC,CAAC;YACZ,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEvC,OAAO,GAAG,EAAE;YACR,cAAc,CAAC,UAAU,EAAE,CAAC;QAChC,CAAC,CAAC;IACN,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,6BAAK,EAAE,EAAC,sBAAsB,IAAE,QAAQ,CAAO,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=widget-polyfill.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-polyfill.d.ts","sourceRoot":"","sources":["../../../src/widgets/runtime/widget-polyfill.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// NitroStack Widget Runtime Polyfill
|
|
3
|
+
// This script listens for window.openai injection from the parent frame
|
|
4
|
+
(function () {
|
|
5
|
+
'use strict';
|
|
6
|
+
// Listen for openai runtime injection from parent
|
|
7
|
+
window.addEventListener('message', (event) => {
|
|
8
|
+
if (event.data?.type === 'NITRO_INJECT_OPENAI') {
|
|
9
|
+
console.log('📦 Received window.openai from parent frame');
|
|
10
|
+
// Set up window.openai
|
|
11
|
+
window.openai = event.data.openai;
|
|
12
|
+
// Dispatch event for widgets to know openai is ready
|
|
13
|
+
const readyEvent = new CustomEvent('openai:ready');
|
|
14
|
+
window.dispatchEvent(readyEvent);
|
|
15
|
+
console.log('✅ window.openai initialized');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
// Also handle legacy toolOutput postMessage for backward compatibility
|
|
19
|
+
window.addEventListener('message', (event) => {
|
|
20
|
+
if (event.data?.type === 'TOOL_OUTPUT' && event.data?.data) {
|
|
21
|
+
console.log('📦 Received legacy toolOutput');
|
|
22
|
+
if (window.openai) {
|
|
23
|
+
window.openai.toolOutput = event.data.data;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
})();
|
|
28
|
+
//# sourceMappingURL=widget-polyfill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-polyfill.js","sourceRoot":"","sources":["../../../src/widgets/runtime/widget-polyfill.ts"],"names":[],"mappings":";AAAA,qCAAqC;AACrC,wEAAwE;AAExE,CAAC;IACG,YAAY,CAAC;IAEb,kDAAkD;IAClD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,qBAAqB,EAAE,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAE3D,uBAAuB;YACtB,MAAc,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;YAE3C,qDAAqD;YACrD,MAAM,UAAU,GAAG,IAAI,WAAW,CAAC,cAAc,CAAC,CAAC;YACnD,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAEjC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC/C,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,uEAAuE;IACvE,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;QACzC,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,aAAa,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC7C,IAAK,MAAc,CAAC,MAAM,EAAE,CAAC;gBACxB,MAAc,CAAC,MAAM,CAAC,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YACxD,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget SDK - Clean abstraction over window.openai
|
|
3
|
+
*
|
|
4
|
+
* Provides a developer-friendly API for widget functionality without
|
|
5
|
+
* exposing OpenAI-specific implementation details.
|
|
6
|
+
*/
|
|
7
|
+
import type { DisplayMode, CallToolResponse } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Widget SDK class that wraps window.openai functionality
|
|
10
|
+
*/
|
|
11
|
+
export declare class WidgetSDK {
|
|
12
|
+
private static instance;
|
|
13
|
+
private constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Get the SDK instance
|
|
16
|
+
*/
|
|
17
|
+
static getInstance(): WidgetSDK;
|
|
18
|
+
/**
|
|
19
|
+
* Check if the SDK is ready (window.openai is available)
|
|
20
|
+
*/
|
|
21
|
+
isReady(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Wait for SDK to be ready
|
|
24
|
+
*/
|
|
25
|
+
waitForReady(timeout?: number): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Set widget state
|
|
28
|
+
*/
|
|
29
|
+
setState(state: any): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Get current widget state
|
|
32
|
+
*/
|
|
33
|
+
getState(): any;
|
|
34
|
+
/**
|
|
35
|
+
* Call a tool by name with arguments
|
|
36
|
+
*/
|
|
37
|
+
callTool(name: string, args?: Record<string, unknown>): Promise<CallToolResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* Request fullscreen mode
|
|
40
|
+
*/
|
|
41
|
+
requestFullscreen(): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Request inline mode
|
|
44
|
+
*/
|
|
45
|
+
requestInline(): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Request picture-in-picture mode
|
|
48
|
+
*/
|
|
49
|
+
requestPip(): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Request display mode change
|
|
52
|
+
*/
|
|
53
|
+
requestDisplayMode(mode: DisplayMode): Promise<{
|
|
54
|
+
mode: DisplayMode;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Close the widget
|
|
58
|
+
*/
|
|
59
|
+
requestClose(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Open external URL
|
|
62
|
+
*/
|
|
63
|
+
openExternal(url: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Send a follow-up message to the chat
|
|
66
|
+
*/
|
|
67
|
+
sendFollowUpMessage(prompt: string): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Get tool input data
|
|
70
|
+
*/
|
|
71
|
+
getToolInput<T = any>(): T | null;
|
|
72
|
+
/**
|
|
73
|
+
* Get tool output data
|
|
74
|
+
*/
|
|
75
|
+
getToolOutput<T = any>(): T | null;
|
|
76
|
+
/**
|
|
77
|
+
* Get tool response metadata
|
|
78
|
+
*/
|
|
79
|
+
getToolResponseMetadata<T = any>(): T | null;
|
|
80
|
+
/**
|
|
81
|
+
* Get current theme
|
|
82
|
+
*/
|
|
83
|
+
getTheme(): 'light' | 'dark';
|
|
84
|
+
/**
|
|
85
|
+
* Get maximum height constraint
|
|
86
|
+
*/
|
|
87
|
+
getMaxHeight(): number;
|
|
88
|
+
/**
|
|
89
|
+
* Get current display mode
|
|
90
|
+
*/
|
|
91
|
+
getDisplayMode(): DisplayMode;
|
|
92
|
+
/**
|
|
93
|
+
* Get user agent information
|
|
94
|
+
*/
|
|
95
|
+
getUserAgent(): import("./types").UserAgent | null;
|
|
96
|
+
/**
|
|
97
|
+
* Get locale
|
|
98
|
+
*/
|
|
99
|
+
getLocale(): string;
|
|
100
|
+
/**
|
|
101
|
+
* Get safe area insets
|
|
102
|
+
*/
|
|
103
|
+
getSafeArea(): import("./types").SafeArea | null;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get the global Widget SDK instance
|
|
107
|
+
*/
|
|
108
|
+
export declare function getWidgetSDK(): WidgetSDK;
|
|
109
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/widgets/sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE7D;;GAEG;AACH,qBAAa,SAAS;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA0B;IAEjD,OAAO;IAIP;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,SAAS;IAO/B;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACG,YAAY,CAAC,OAAO,SAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBjD;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzC;;OAEG;IACH,QAAQ,IAAI,GAAG;IAOf;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAS3F;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOxC;;OAEG;IACG,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAOpC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAOjC;;OAEG;IACG,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC;IAO3E;;OAEG;IACH,YAAY,IAAI,IAAI;IASpB;;OAEG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAO/B;;OAEG;IACG,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IASxD;;OAEG;IACH,YAAY,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI;IAKjC;;OAEG;IACH,aAAa,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI;IAKlC;;OAEG;IACH,uBAAuB,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,IAAI;IAK5C;;OAEG;IACH,QAAQ,IAAI,OAAO,GAAG,MAAM;IAK5B;;OAEG;IACH,YAAY,IAAI,MAAM;IAKtB;;OAEG;IACH,cAAc,IAAI,WAAW;IAK7B;;OAEG;IACH,YAAY;IAKZ;;OAEG;IACH,SAAS,IAAI,MAAM;IAKnB;;OAEG;IACH,WAAW;CAId;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget SDK - Clean abstraction over window.openai
|
|
3
|
+
*
|
|
4
|
+
* Provides a developer-friendly API for widget functionality without
|
|
5
|
+
* exposing OpenAI-specific implementation details.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Widget SDK class that wraps window.openai functionality
|
|
9
|
+
*/
|
|
10
|
+
export class WidgetSDK {
|
|
11
|
+
static instance = null;
|
|
12
|
+
constructor() {
|
|
13
|
+
// Private constructor for singleton
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get the SDK instance
|
|
17
|
+
*/
|
|
18
|
+
static getInstance() {
|
|
19
|
+
if (!WidgetSDK.instance) {
|
|
20
|
+
WidgetSDK.instance = new WidgetSDK();
|
|
21
|
+
}
|
|
22
|
+
return WidgetSDK.instance;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if the SDK is ready (window.openai is available)
|
|
26
|
+
*/
|
|
27
|
+
isReady() {
|
|
28
|
+
return typeof window !== 'undefined' && 'openai' in window;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Wait for SDK to be ready
|
|
32
|
+
*/
|
|
33
|
+
async waitForReady(timeout = 5000) {
|
|
34
|
+
if (this.isReady())
|
|
35
|
+
return;
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
const timeoutId = setTimeout(() => {
|
|
38
|
+
window.removeEventListener('openai:ready', handler);
|
|
39
|
+
reject(new Error('Widget SDK initialization timeout'));
|
|
40
|
+
}, timeout);
|
|
41
|
+
const handler = () => {
|
|
42
|
+
clearTimeout(timeoutId);
|
|
43
|
+
resolve();
|
|
44
|
+
};
|
|
45
|
+
window.addEventListener('openai:ready', handler, { once: true });
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
// ==================== State Management ====================
|
|
49
|
+
/**
|
|
50
|
+
* Set widget state
|
|
51
|
+
*/
|
|
52
|
+
async setState(state) {
|
|
53
|
+
if (!this.isReady()) {
|
|
54
|
+
throw new Error('Widget SDK not ready');
|
|
55
|
+
}
|
|
56
|
+
await window.openai.setWidgetState(state);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Get current widget state
|
|
60
|
+
*/
|
|
61
|
+
getState() {
|
|
62
|
+
if (!this.isReady())
|
|
63
|
+
return null;
|
|
64
|
+
return window.openai.widgetState;
|
|
65
|
+
}
|
|
66
|
+
// ==================== Tool Calling ====================
|
|
67
|
+
/**
|
|
68
|
+
* Call a tool by name with arguments
|
|
69
|
+
*/
|
|
70
|
+
async callTool(name, args = {}) {
|
|
71
|
+
if (!this.isReady()) {
|
|
72
|
+
throw new Error('Widget SDK not ready');
|
|
73
|
+
}
|
|
74
|
+
return await window.openai.callTool(name, args);
|
|
75
|
+
}
|
|
76
|
+
// ==================== Display Controls ====================
|
|
77
|
+
/**
|
|
78
|
+
* Request fullscreen mode
|
|
79
|
+
*/
|
|
80
|
+
async requestFullscreen() {
|
|
81
|
+
if (!this.isReady()) {
|
|
82
|
+
throw new Error('Widget SDK not ready');
|
|
83
|
+
}
|
|
84
|
+
await window.openai.requestDisplayMode({ mode: 'fullscreen' });
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Request inline mode
|
|
88
|
+
*/
|
|
89
|
+
async requestInline() {
|
|
90
|
+
if (!this.isReady()) {
|
|
91
|
+
throw new Error('Widget SDK not ready');
|
|
92
|
+
}
|
|
93
|
+
await window.openai.requestDisplayMode({ mode: 'inline' });
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Request picture-in-picture mode
|
|
97
|
+
*/
|
|
98
|
+
async requestPip() {
|
|
99
|
+
if (!this.isReady()) {
|
|
100
|
+
throw new Error('Widget SDK not ready');
|
|
101
|
+
}
|
|
102
|
+
await window.openai.requestDisplayMode({ mode: 'pip' });
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Request display mode change
|
|
106
|
+
*/
|
|
107
|
+
async requestDisplayMode(mode) {
|
|
108
|
+
if (!this.isReady()) {
|
|
109
|
+
throw new Error('Widget SDK not ready');
|
|
110
|
+
}
|
|
111
|
+
return await window.openai.requestDisplayMode({ mode });
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Close the widget
|
|
115
|
+
*/
|
|
116
|
+
requestClose() {
|
|
117
|
+
if (!this.isReady()) {
|
|
118
|
+
throw new Error('Widget SDK not ready');
|
|
119
|
+
}
|
|
120
|
+
window.openai.requestClose();
|
|
121
|
+
}
|
|
122
|
+
// ==================== Navigation ====================
|
|
123
|
+
/**
|
|
124
|
+
* Open external URL
|
|
125
|
+
*/
|
|
126
|
+
openExternal(url) {
|
|
127
|
+
if (!this.isReady()) {
|
|
128
|
+
throw new Error('Widget SDK not ready');
|
|
129
|
+
}
|
|
130
|
+
window.openai.openExternal({ href: url });
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Send a follow-up message to the chat
|
|
134
|
+
*/
|
|
135
|
+
async sendFollowUpMessage(prompt) {
|
|
136
|
+
if (!this.isReady()) {
|
|
137
|
+
throw new Error('Widget SDK not ready');
|
|
138
|
+
}
|
|
139
|
+
await window.openai.sendFollowUpMessage({ prompt });
|
|
140
|
+
}
|
|
141
|
+
// ==================== Data Access ====================
|
|
142
|
+
/**
|
|
143
|
+
* Get tool input data
|
|
144
|
+
*/
|
|
145
|
+
getToolInput() {
|
|
146
|
+
if (!this.isReady())
|
|
147
|
+
return null;
|
|
148
|
+
return window.openai.toolInput;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get tool output data
|
|
152
|
+
*/
|
|
153
|
+
getToolOutput() {
|
|
154
|
+
if (!this.isReady())
|
|
155
|
+
return null;
|
|
156
|
+
return window.openai.toolOutput;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get tool response metadata
|
|
160
|
+
*/
|
|
161
|
+
getToolResponseMetadata() {
|
|
162
|
+
if (!this.isReady())
|
|
163
|
+
return null;
|
|
164
|
+
return window.openai.toolResponseMetadata;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get current theme
|
|
168
|
+
*/
|
|
169
|
+
getTheme() {
|
|
170
|
+
if (!this.isReady())
|
|
171
|
+
return 'light';
|
|
172
|
+
return window.openai.theme;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get maximum height constraint
|
|
176
|
+
*/
|
|
177
|
+
getMaxHeight() {
|
|
178
|
+
if (!this.isReady())
|
|
179
|
+
return 0;
|
|
180
|
+
return window.openai.maxHeight;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get current display mode
|
|
184
|
+
*/
|
|
185
|
+
getDisplayMode() {
|
|
186
|
+
if (!this.isReady())
|
|
187
|
+
return 'inline';
|
|
188
|
+
return window.openai.displayMode;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Get user agent information
|
|
192
|
+
*/
|
|
193
|
+
getUserAgent() {
|
|
194
|
+
if (!this.isReady())
|
|
195
|
+
return null;
|
|
196
|
+
return window.openai.userAgent;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Get locale
|
|
200
|
+
*/
|
|
201
|
+
getLocale() {
|
|
202
|
+
if (!this.isReady())
|
|
203
|
+
return 'en-US';
|
|
204
|
+
return window.openai.locale;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get safe area insets
|
|
208
|
+
*/
|
|
209
|
+
getSafeArea() {
|
|
210
|
+
if (!this.isReady())
|
|
211
|
+
return null;
|
|
212
|
+
return window.openai.safeArea;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get the global Widget SDK instance
|
|
217
|
+
*/
|
|
218
|
+
export function getWidgetSDK() {
|
|
219
|
+
return WidgetSDK.getInstance();
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/widgets/sdk.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;GAEG;AACH,MAAM,OAAO,SAAS;IACV,MAAM,CAAC,QAAQ,GAAqB,IAAI,CAAC;IAEjD;QACI,oCAAoC;IACxC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW;QACd,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;YACtB,SAAS,CAAC,QAAQ,GAAG,IAAI,SAAS,EAAE,CAAC;QACzC,CAAC;QACD,OAAO,SAAS,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,OAAO;QACH,OAAO,OAAO,MAAM,KAAK,WA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AO,EAAE;YAAE,OAAO,OAAO,CAAC;QACpC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,YAAY;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,CAAC,CAAC;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,cAAc;QACV,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,QAAQ,CAAC;QACrC,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,YAAY;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,IAAI,CAAC;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,SAAS;QACL,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,OAAO,CAAC;QACpC,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,WAAW;QACP,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YAAE,OAAO,IAAI,CAAC;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;;AAGL;;GAEG;AACH,MAAM,UAAU,YAAY;IACxB,OAAO,SAAS,CAAC,WAAW,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export type UnknownObject = Record<string, unknown>;
|
|
2
|
+
export type Theme = 'light' | 'dark';
|
|
3
|
+
export type SafeAreaInsets = {
|
|
4
|
+
top: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
left: number;
|
|
7
|
+
right: number;
|
|
8
|
+
};
|
|
9
|
+
export type SafeArea = {
|
|
10
|
+
insets: SafeAreaInsets;
|
|
11
|
+
};
|
|
12
|
+
export type DeviceType = 'mobile' | 'tablet' | 'desktop' | 'unknown';
|
|
13
|
+
export type UserAgent = {
|
|
14
|
+
device: {
|
|
15
|
+
type: DeviceType;
|
|
16
|
+
};
|
|
17
|
+
capabilities: {
|
|
18
|
+
hover: boolean;
|
|
19
|
+
touch: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/** Display mode */
|
|
23
|
+
export type DisplayMode = 'pip' | 'inline' | 'fullscreen';
|
|
24
|
+
export type RequestDisplayMode = (args: {
|
|
25
|
+
mode: DisplayMode;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
/**
|
|
28
|
+
* The granted display mode. The host may reject the request.
|
|
29
|
+
* For mobile, PiP is always coerced to fullscreen.
|
|
30
|
+
*/
|
|
31
|
+
mode: DisplayMode;
|
|
32
|
+
}>;
|
|
33
|
+
export type CallToolResponse = {
|
|
34
|
+
result: string;
|
|
35
|
+
};
|
|
36
|
+
/** Calling APIs */
|
|
37
|
+
export type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
|
|
38
|
+
/**
|
|
39
|
+
* OpenAI globals injected into widget runtime
|
|
40
|
+
*/
|
|
41
|
+
export type OpenAiGlobals<ToolInput = UnknownObject, ToolOutput = UnknownObject, ToolResponseMetadata = UnknownObject, WidgetState = UnknownObject> = {
|
|
42
|
+
theme: Theme;
|
|
43
|
+
userAgent: UserAgent;
|
|
44
|
+
locale: string;
|
|
45
|
+
maxHeight: number;
|
|
46
|
+
displayMode: DisplayMode;
|
|
47
|
+
safeArea: SafeArea;
|
|
48
|
+
toolInput: ToolInput;
|
|
49
|
+
toolOutput: ToolOutput | null;
|
|
50
|
+
toolResponseMetadata: ToolResponseMetadata | null;
|
|
51
|
+
widgetState: WidgetState | null;
|
|
52
|
+
setWidgetState: (state: WidgetState) => Promise<void>;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* OpenAI API methods
|
|
56
|
+
*/
|
|
57
|
+
export type OpenAiAPI = {
|
|
58
|
+
callTool: CallTool;
|
|
59
|
+
sendFollowUpMessage: (args: {
|
|
60
|
+
prompt: string;
|
|
61
|
+
}) => Promise<void>;
|
|
62
|
+
openExternal(payload: {
|
|
63
|
+
href: string;
|
|
64
|
+
}): void;
|
|
65
|
+
requestClose(): void;
|
|
66
|
+
requestDisplayMode: RequestDisplayMode;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Custom event for globals updates
|
|
70
|
+
*/
|
|
71
|
+
export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
72
|
+
export declare class SetGlobalsEvent extends CustomEvent<{
|
|
73
|
+
globals: Partial<OpenAiGlobals>;
|
|
74
|
+
}> {
|
|
75
|
+
readonly type = "openai:set_globals";
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Global openai object injected by the web sandbox for communicating with chatgpt host page.
|
|
79
|
+
*/
|
|
80
|
+
declare global {
|
|
81
|
+
interface Window {
|
|
82
|
+
openai: OpenAiAPI & OpenAiGlobals;
|
|
83
|
+
}
|
|
84
|
+
interface WindowEventMap {
|
|
85
|
+
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/widgets/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpD,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAErC,MAAM,MAAM,cAAc,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG;IACnB,MAAM,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CAAC;IAClD,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,mBAAmB,EAAE,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,YAAY,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC9C,YAAY,IAAI,IAAI,CAAC;IAGrB,kBAAkB,EAAE,kBAAkB,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAE3D,qBAAa,eAAgB,SAAQ,WAAW,CAAC;IAC7C,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACnC,CAAC;IACE,QAAQ,CAAC,IAAI,wBAA0B;CAC1C;AAED;;GAEG;AACH,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,MAAM,EAAE,SAAS,GAAG,aAAa,CAAC;KACrC;IAED,UAAU,cAAc;QACpB,CAAC,sBAAsB,CAAC,EAAE,eAAe,CAAC;KAC7C;CACJ;AAED,OAAO,EAAG,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/widgets/types.ts"],"names":[],"mappings":"AAsFA;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAE3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACW,IAAI,GAAG,sBAAsB,CAAC;CAC1C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Media query utilities for responsive and accessible widget design
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Check if user prefers reduced motion
|
|
6
|
+
* Use this to disable animations for accessibility
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const shouldAnimate = !prefersReducedMotion();
|
|
10
|
+
*/
|
|
11
|
+
export declare const prefersReducedMotion: () => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Check if device is primarily touch-based
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const isTouchDevice = isPrimarilyTouchDevice();
|
|
17
|
+
*/
|
|
18
|
+
export declare const isPrimarilyTouchDevice: () => boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if hover is available
|
|
21
|
+
* Use this to conditionally show hover states
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const canHover = isHoverAvailable();
|
|
25
|
+
*/
|
|
26
|
+
export declare const isHoverAvailable: () => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check if user prefers dark color scheme
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const prefersDark = prefersDarkColorScheme();
|
|
32
|
+
*/
|
|
33
|
+
export declare const prefersDarkColorScheme: () => boolean;
|
|
34
|
+
//# sourceMappingURL=media-queries.d.ts.map
|