Rocky_Mountain_Vending/.pnpm-store/v10/files/a3/90e2629a111202e951241493ff5ba5618b1fbab7be9cdb0bdb2bb681eb0bfa64cf22ee89c7256747358a0951198a185d35edfd9dd21f42622d60c7a4ae39d4
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

62 lines
No EOL
2.8 KiB
Text

import React, { use, useMemo } from 'react';
import { isThenable } from '../../shared/lib/is-thenable';
// The app router state lives outside of React, so we can import the dispatch
// method directly wherever we need it, rather than passing it around via props
// or context.
let dispatch = null;
export function dispatchAppRouterAction(action) {
if (dispatch === null) {
throw Object.defineProperty(new Error('Internal Next.js error: Router action dispatched before initialization.'), "__NEXT_ERROR_CODE", {
value: "E668",
enumerable: false,
configurable: true
});
}
dispatch(action);
}
export function useActionQueue(actionQueue) {
const [state, setState] = React.useState(actionQueue.state);
// Because of a known issue that requires to decode Flight streams inside the
// render phase, we have to be a bit clever and assign the dispatch method to
// a module-level variable upon initialization. The useState hook in this
// module only exists to synchronize state that lives outside of React.
// Ideally, what we'd do instead is pass the state as a prop to root.render;
// this is conceptually how we're modeling the app router state, despite the
// weird implementation details.
if (process.env.NODE_ENV !== 'production') {
const { useAppDevRenderingIndicator } = require('../../next-devtools/userspace/use-app-dev-rendering-indicator');
// eslint-disable-next-line react-hooks/rules-of-hooks
const appDevRenderingIndicator = useAppDevRenderingIndicator();
dispatch = (action)=>{
appDevRenderingIndicator(()=>{
actionQueue.dispatch(action, setState);
});
};
} else {
dispatch = (action)=>actionQueue.dispatch(action, setState);
}
// When navigating to a non-prefetched route, then App Router state will be
// blocked until the server responds. We need to transfer the `_debugInfo`
// from the underlying Flight response onto the top-level promise that is
// passed to React (via `use`) so that the latency is accurately represented
// in the React DevTools.
const stateWithDebugInfo = useMemo(()=>{
if (isThenable(state)) {
const debugInfo = [];
const promiseWithDebugInfo = Promise.resolve(state).then((asyncState)=>{
if (asyncState.debugInfo !== null) {
debugInfo.push(...asyncState.debugInfo);
}
return asyncState;
});
promiseWithDebugInfo._debugInfo = debugInfo;
return promiseWithDebugInfo;
}
return state;
}, [
state
]);
return isThenable(stateWithDebugInfo) ? use(stateWithDebugInfo) : stateWithDebugInfo;
}
//# sourceMappingURL=use-action-queue.js.map