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
3.8 KiB
Text
1 line
No EOL
3.8 KiB
Text
{"version":3,"sources":["../../../../src/client/components/errors/graceful-degrade-boundary.tsx"],"sourcesContent":["'use client'\n\nimport { Component, createRef, type ReactNode } from 'react'\n\ninterface ErrorBoundaryProps {\n children: ReactNode\n}\n\ninterface ErrorBoundaryState {\n hasError: boolean\n}\n\nfunction getDomNodeAttributes(node: HTMLElement): Record<string, string> {\n const result: Record<string, string> = {}\n for (let i = 0; i < node.attributes.length; i++) {\n const attr = node.attributes[i]\n result[attr.name] = attr.value\n }\n return result\n}\n\nexport class GracefulDegradeBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n private rootHtml: string\n private htmlAttributes: Record<string, string>\n private htmlRef: React.RefObject<HTMLHtmlElement | null>\n\n constructor(props: ErrorBoundaryProps) {\n super(props)\n this.state = { hasError: false }\n this.rootHtml = ''\n this.htmlAttributes = {}\n this.htmlRef = createRef<HTMLHtmlElement>()\n }\n\n static getDerivedStateFromError(_: unknown): ErrorBoundaryState {\n return { hasError: true }\n }\n\n componentDidMount() {\n const htmlNode = this.htmlRef.current\n if (this.state.hasError && htmlNode) {\n // Reapply the cached HTML attributes to the root element\n Object.entries(this.htmlAttributes).forEach(([key, value]) => {\n htmlNode.setAttribute(key, value)\n })\n }\n }\n\n render() {\n const { hasError } = this.state\n // Cache the root HTML content on the first render\n if (typeof window !== 'undefined' && !this.rootHtml) {\n this.rootHtml = document.documentElement.innerHTML\n this.htmlAttributes = getDomNodeAttributes(document.documentElement)\n }\n\n if (hasError) {\n // Render the current HTML content without hydration\n return (\n <html\n ref={this.htmlRef}\n suppressHydrationWarning\n dangerouslySetInnerHTML={{\n __html: this.rootHtml,\n }}\n />\n )\n }\n\n return this.props.children\n }\n}\n\nexport default GracefulDegradeBoundary\n"],"names":["Component","createRef","getDomNodeAttributes","node","result","i","attributes","length","attr","name","value","GracefulDegradeBoundary","constructor","props","state","hasError","rootHtml","htmlAttributes","htmlRef","getDerivedStateFromError","_","componentDidMount","htmlNode","current","Object","entries","forEach","key","setAttribute","render","window","document","documentElement","innerHTML","html","ref","suppressHydrationWarning","dangerouslySetInnerHTML","__html","children"],"mappings":"AAAA;;AAEA,SAASA,SAAS,EAAEC,SAAS,QAAwB,QAAO;AAU5D,SAASC,qBAAqBC,IAAiB;IAC7C,MAAMC,SAAiC,CAAC;IACxC,IAAK,IAAIC,IAAI,GAAGA,IAAIF,KAAKG,UAAU,CAACC,MAAM,EAAEF,IAAK;QAC/C,MAAMG,OAAOL,KAAKG,UAAU,CAACD,EAAE;QAC/BD,MAAM,CAACI,KAAKC,IAAI,CAAC,GAAGD,KAAKE,KAAK;IAChC;IACA,OAAON;AACT;AAEA,OAAO,MAAMO,gCAAgCX;IAQ3CY,YAAYC,KAAyB,CAAE;QACrC,KAAK,CAACA;QACN,IAAI,CAACC,KAAK,GAAG;YAAEC,UAAU;QAAM;QAC/B,IAAI,CAACC,QAAQ,GAAG;QAChB,IAAI,CAACC,cAAc,GAAG,CAAC;QACvB,IAAI,CAACC,OAAO,iBAAGjB;IACjB;IAEA,OAAOkB,yBAAyBC,CAAU,EAAsB;QAC9D,OAAO;YAAEL,UAAU;QAAK;IAC1B;IAEAM,oBAAoB;QAClB,MAAMC,WAAW,IAAI,CAACJ,OAAO,CAACK,OAAO;QACrC,IAAI,IAAI,CAACT,KAAK,CAACC,QAAQ,IAAIO,UAAU;YACnC,yDAAyD;YACzDE,OAAOC,OAAO,CAAC,IAAI,CAACR,cAAc,EAAES,OAAO,CAAC,CAAC,CAACC,KAAKjB,MAAM;gBACvDY,SAASM,YAAY,CAACD,KAAKjB;YAC7B;QACF;IACF;IAEAmB,SAAS;QACP,MAAM,EAAEd,QAAQ,EAAE,GAAG,IAAI,CAACD,KAAK;QAC/B,kDAA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