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>
1 line
No EOL
8.6 KiB
Text
1 line
No EOL
8.6 KiB
Text
{"version":3,"sources":["../../src/client/router.ts"],"sourcesContent":["/* global window */\nimport React from 'react'\nimport Router from '../shared/lib/router/router'\nimport type { NextRouter } from '../shared/lib/router/router'\nimport { RouterContext } from '../shared/lib/router-context.shared-runtime'\nimport isError from '../lib/is-error'\n\ntype SingletonRouterBase = {\n router: Router | null\n readyCallbacks: Array<() => any>\n ready(cb: () => any): void\n}\n\nexport { Router }\n\nexport type { NextRouter }\n\nexport type SingletonRouter = SingletonRouterBase & NextRouter\n\nconst singletonRouter: SingletonRouterBase = {\n router: null, // holds the actual router instance\n readyCallbacks: [],\n ready(callback: () => void) {\n if (this.router) return callback()\n if (typeof window !== 'undefined') {\n this.readyCallbacks.push(callback)\n }\n },\n}\n\n// Create public properties and methods of the router in the singletonRouter\nconst urlPropertyFields = [\n 'pathname',\n 'route',\n 'query',\n 'asPath',\n 'components',\n 'isFallback',\n 'basePath',\n 'locale',\n 'locales',\n 'defaultLocale',\n 'isReady',\n 'isPreview',\n 'isLocaleDomain',\n 'domainLocales',\n] as const\nconst routerEvents = [\n 'routeChangeStart',\n 'beforeHistoryChange',\n 'routeChangeComplete',\n 'routeChangeError',\n 'hashChangeStart',\n 'hashChangeComplete',\n] as const\nexport type RouterEvent = (typeof routerEvents)[number]\n\nconst coreMethodFields = [\n 'push',\n 'replace',\n 'reload',\n 'back',\n 'prefetch',\n 'beforePopState',\n] as const\n\n// Events is a static property on the router, the router doesn't have to be initialized to use it\nObject.defineProperty(singletonRouter, 'events', {\n get() {\n return Router.events\n },\n})\n\nfunction getRouter(): Router {\n if (!singletonRouter.router) {\n const message =\n 'No router instance found.\\n' +\n 'You should only use \"next/router\" on the client side of your app.\\n'\n throw new Error(message)\n }\n return singletonRouter.router\n}\n\nurlPropertyFields.forEach((field) => {\n // Here we need to use Object.defineProperty because we need to return\n // the property assigned to the actual router\n // The value might get changed as we change routes and this is the\n // proper way to access it\n Object.defineProperty(singletonRouter, field, {\n get() {\n const router = getRouter()\n return router[field] as string\n },\n })\n})\n\ncoreMethodFields.forEach((field) => {\n // We don't really know the types here, so we add them later instead\n ;(singletonRouter as any)[field] = (...args: any[]) => {\n const router = getRouter() as any\n return router[field](...args)\n }\n})\n\nrouterEvents.forEach((event) => {\n singletonRouter.ready(() => {\n Router.events.on(event, (...args) => {\n const eventField = `on${event.charAt(0).toUpperCase()}${event.substring(\n 1\n )}`\n const _singletonRouter = singletonRouter as any\n if (_singletonRouter[eventField]) {\n try {\n _singletonRouter[eventField](...args)\n } catch (err) {\n console.error(`Error when running the Router event: ${eventField}`)\n console.error(\n isError(err) ? `${err.message}\\n${err.stack}` : err + ''\n )\n }\n }\n })\n })\n})\n\n// Export the singletonRouter and this is the public API.\nexport default singletonRouter as SingletonRouter\n\n// Reexport the withRouter HOC\nexport { default as withRouter } from './with-router'\n\n/**\n * This hook gives access the [router object](https://nextjs.org/docs/pages/api-reference/functions/use-router#router-object)\n * inside the [Pages Router](https://nextjs.org/docs/pages/building-your-application).\n *\n * Read more: [Next.js Docs: `useRouter`](https://nextjs.org/docs/pages/api-reference/functions/use-router)\n */\nexport function useRouter(): NextRouter {\n const router = React.useContext(RouterContext)\n if (!router) {\n throw new Error(\n 'NextRouter was not mounted. https://nextjs.org/docs/messages/next-router-not-mounted'\n )\n }\n\n return router\n}\n\n/**\n * Create a router and assign it as the singleton instance.\n * This is used in client side when we are initializing the app.\n * This should **not** be used inside the server.\n * @internal\n */\nexport function createRouter(\n ...args: ConstructorParameters<typeof Router>\n): Router {\n singletonRouter.router = new Router(...args)\n singletonRouter.readyCallbacks.forEach((cb) => cb())\n singletonRouter.readyCallbacks = []\n\n return singletonRouter.router\n}\n\n/**\n * This function is used to create the `withRouter` router instance\n * @internal\n */\nexport function makePublicRouterInstance(router: Router): NextRouter {\n const scopedRouter = router as any\n const instance = {} as any\n\n for (const property of urlPropertyFields) {\n if (typeof scopedRouter[property] === 'object') {\n instance[property] = Object.assign(\n Array.isArray(scopedRouter[property]) ? [] : {},\n scopedRouter[property]\n ) // makes sure query is not stateful\n continue\n }\n\n instance[property] = scopedRouter[property]\n }\n\n // Events is a static property on the router, the router doesn't have to be initialized to use it\n instance.events = Router.events\n\n coreMethodFields.forEach((field) => {\n instance[field] = (...args: any[]) => {\n return scopedRouter[field](...args)\n }\n })\n\n return instance\n}\n"],"names":["React","Router","RouterContext","isError","singletonRouter","router","readyCallbacks","ready","callback","window","push","urlPropertyFields","routerEvents","coreMethodFields","Object","defineProperty","get","events","getRouter","message","Error","forEach","field","args","event","on","eventField","charAt","toUpperCase","substring","_singletonRouter","err","console","error","stack","default","withRouter","useRouter","useContext","createRouter","cb","makePublicRouterInstance","scopedRouter","instance","property","assign","Array","isArray"],"mappings":"AAAA,iBAAiB,GACjB,OAAOA,WAAW,QAAO;AACzB,OAAOC,YAAY,8BAA6B;AAEhD,SAASC,aAAa,QAAQ,8CAA6C;AAC3E,OAAOC,aAAa,kBAAiB;AAQrC,SAASF,MAAM,GAAE;AAMjB,MAAMG,kBAAuC;IAC3CC,QAAQ;IACRC,gBAAgB,EAAE;IAClBC,OAAMC,QAAoB;QACxB,IAAI,IAAI,CAACH,MAAM,EAAE,OAAOG;QACxB,IAAI,OAAOC,WAAW,aAAa;YACjC,IAAI,CAACH,cAAc,CAACI,IAAI,CAACF;QAC3B;IACF;AACF;AAEA,4EAA4E;AAC5E,MAAMG,oBAAoB;IACxB;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AACD,MAAMC,eAAe;IACnB;IACA;IACA;IACA;IACA;IACA;CACD;AAGD,MAAMC,mBAAmB;IACvB;IACA;IACA;IACA;IACA;IACA;CACD;AAED,iGAAiG;AACjGC,OAAOC,cAAc,CAACX,iBAAiB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