Rocky_Mountain_Vending/.pnpm-store/v10/files/d1/d00c10a234783f583dbd52b3c318edaab52c74ff6d735f707418c720c1e70a820000f6f700836b0b2d5cad1547ac7cee2526aaef42b458a4c0676f9c1a8442
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

90 lines
No EOL
3 KiB
Text

/**
* Shared utilities for MCP tools that communicate with the browser.
* This module provides a common infrastructure for request-response
* communication between MCP endpoints and browser sessions via HMR.
*/ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
DEFAULT_BROWSER_REQUEST_TIMEOUT_MS: null,
createBrowserRequest: null,
handleBrowserPageResponse: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
DEFAULT_BROWSER_REQUEST_TIMEOUT_MS: function() {
return DEFAULT_BROWSER_REQUEST_TIMEOUT_MS;
},
createBrowserRequest: function() {
return createBrowserRequest;
},
handleBrowserPageResponse: function() {
return handleBrowserPageResponse;
}
});
const _nanoid = require("next/dist/compiled/nanoid");
const DEFAULT_BROWSER_REQUEST_TIMEOUT_MS = 5000;
const pendingRequests = new Map();
function createBrowserRequest(messageType, sendHmrMessage, getActiveConnectionCount, timeoutMs) {
const connectionCount = getActiveConnectionCount();
if (connectionCount === 0) {
return Promise.resolve([]);
}
const requestId = `mcp-${messageType}-${(0, _nanoid.nanoid)()}`;
const responsePromise = new Promise((resolve, reject)=>{
const timeout = setTimeout(()=>{
const pending = pendingRequests.get(requestId);
if (pending && pending.responses.length > 0) {
resolve(pending.responses);
} else {
reject(Object.defineProperty(new Error(`Timeout waiting for response from frontend. The browser may not be responding to HMR messages.`), "__NEXT_ERROR_CODE", {
value: "E825",
enumerable: false,
configurable: true
}));
}
pendingRequests.delete(requestId);
}, timeoutMs);
pendingRequests.set(requestId, {
responses: [],
expectedCount: connectionCount,
resolve: resolve,
reject,
timeout
});
});
sendHmrMessage({
type: messageType,
requestId
});
return responsePromise;
}
function handleBrowserPageResponse(requestId, data, url) {
if (!url) {
throw Object.defineProperty(new Error('URL is required in MCP browser response. This is a bug in Next.js.'), "__NEXT_ERROR_CODE", {
value: "E824",
enumerable: false,
configurable: true
});
}
const pending = pendingRequests.get(requestId);
if (pending) {
pending.responses.push({
url,
data
});
if (pending.responses.length >= pending.expectedCount) {
clearTimeout(pending.timeout);
pending.resolve(pending.responses);
pendingRequests.delete(requestId);
}
}
}
//# sourceMappingURL=browser-communication.js.map