@tanstack/react-start
Advanced tools
@@ -53,10 +53,2 @@ /** | ||
| const url = request.url.replace(fullUrl.origin, ''); | ||
| // console.log(handlers) | ||
| // if (hasHandler(fullUrl.pathname)) { | ||
| // return await handleEvent({ | ||
| // request, | ||
| // }) | ||
| // } | ||
| if (fullUrl.pathname.includes('.')) { | ||
@@ -63,0 +55,0 @@ return new Response(null, { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"server.js","sources":["../../src/server.tsx"],"sourcesContent":["import type { APIContext } from 'astro'\nimport {\n AnyRouter,\n createMemoryHistory,\n RouterProvider,\n} from '@tanstack/react-router'\n// import { handleEvent, hasHandler, handlers } from '@tanstack/bling/server'\nimport * as ReactDOMServer from 'react-dom/server'\nimport * as React from 'react'\nimport isbot from 'isbot'\nimport { PassThrough, Transform } from 'stream'\n// @ts-ignore\nimport cprc from '@gisatcz/cross-package-react-context'\n\nexport function createRequestHandler<TRouter extends AnyRouter>(opts: {\n createRouter: () => TRouter\n}) {\n return async ({ request }: APIContext) => {\n const fullUrl = new URL(request.url)\n const url = request.url.replace(fullUrl.origin, '')\n\n // console.log(handlers)\n // if (hasHandler(fullUrl.pathname)) {\n // return await handleEvent({\n // request,\n // })\n // }\n\n if (fullUrl.pathname.includes('.')) {\n return new Response(null, {\n status: 404,\n })\n }\n\n console.log('Rendering: ', url, '...')\n\n const history = createMemoryHistory({\n initialEntries: [url],\n })\n\n const router = opts.createRouter()\n\n router.update({\n history,\n })\n\n await router.load()\n\n return new Promise((resolve, reject) => {\n let didError = false\n\n const responseStatusCode = 200\n const responseHeaders = new Headers({\n 'Content-Type': 'text/html',\n })\n\n // Clever way to get the right callback. Thanks Remix!\n const callbackName = isbot(request.headers.get('user-agent'))\n ? 'onAllReady'\n : 'onShellReady'\n\n const stream = ReactDOMServer.renderToPipeableStream(\n <StartServer router={router} />,\n {\n [callbackName]: () => {\n const body = new PassThrough()\n\n responseHeaders.set('Content-Type', 'text/html')\n\n resolve(\n new Response(body as any, {\n headers: responseHeaders,\n status: didError ? 500 : responseStatusCode,\n }),\n )\n\n stream.pipe(body)\n },\n onShellError: (err) => {\n reject(err)\n },\n onError: (err) => {\n didError = true\n console.log(err)\n },\n },\n )\n\n setTimeout(() => stream.abort(), 10000)\n })\n }\n}\n\nexport function StartServer<TRouter extends AnyRouter>(props: {\n router: TRouter\n}) {\n const hydrationContext = cprc.getContext('TanStackRouterHydrationContext', {})\n\n const hydrationCtxValue = React.useMemo(\n () => ({\n router: props.router.dehydrate(),\n payload: props.router.options.dehydrate?.(),\n }),\n [],\n )\n\n return (\n // Provide the hydration context still, since `<DehydrateRouter />` needs it.\n <hydrationContext.Provider value={hydrationCtxValue}>\n <RouterProvider router={props.router} />\n </hydrationContext.Provider>\n )\n}\n\nexport function transformStreamWithRouter(router: AnyRouter) {\n return transformStreamHtmlCallback(async () => {\n const injectorPromises = router.injectedHtml.map((d) =>\n typeof d === 'function' ? d() : d,\n )\n const injectors = await Promise.all(injectorPromises)\n router.injectedHtml = []\n return injectors.join('')\n })\n}\n\nfunction transformStreamHtmlCallback(injector: () => Promise<string>) {\n let leftover = ''\n\n return new Transform({\n transform(chunk, encoding, callback) {\n let chunkString = leftover + chunk.toString()\n\n // regex pattern for matching closing body and html tags\n const patternBody = /(<\\/body>)/\n const patternHtml = /(<\\/html>)/\n\n const bodyMatch = chunkString.match(patternBody)\n const htmlMatch = chunkString.match(patternHtml)\n\n injector()\n .then((html) => {\n // If a </body></html> sequence was found\n if (bodyMatch && htmlMatch && bodyMatch.index! < htmlMatch.index!) {\n const bodyIndex = bodyMatch.index! + bodyMatch[0].length\n const htmlIndex = htmlMatch.index! + htmlMatch[0].length\n\n // Add the arbitrary HTML before the closing body tag\n const processed =\n chunkString.slice(0, bodyIndex) +\n html +\n chunkString.slice(bodyIndex, htmlIndex) +\n chunkString.slice(htmlIndex)\n\n this.push(processed)\n leftover = ''\n } else {\n // For all other closing tags, add the arbitrary HTML after them\n const pattern = /(<\\/[a-zA-Z][\\w:.-]*?>)/g\n let result\n let lastIndex = 0\n\n while ((result = pattern.exec(chunkString)) !== null) {\n lastIndex = result.index + result[0].length\n }\n\n // If a closing tag was found, add the arbitrary HTML and send it through\n if (lastIndex > 0) {\n const processed = chunkString.slice(0, lastIndex) + html\n this.push(processed)\n leftover = chunkString.slice(lastIndex)\n } else {\n // If no closing tag was found, store the chunk to process with the next one\n leftover = chunkString\n }\n }\n\n callback()\n })\n .catch((err) => {\n console.error(err)\n callback(err)\n })\n },\n flush(callback) {\n if (leftover) {\n this.push(leftover)\n }\n callback()\n },\n })\n}\n"],"names":["createRequestHandler","opts","request","fullUrl","URL","url","replace","origin","pathname","includes","Response","status","console","log","history","createMemoryHistory","initialEntries","router","createRouter","update","load","Promise","resolve","reject","didError","responseStatusCode","responseHeaders","Headers","callbackName","isbot","headers","get","stream","ReactDOMServer","renderToPipeableStream","React","createElement","StartServer","body","PassThrough","set","pipe","onShellError","err","onError","setTimeout","abort","props","hydrationContext","cprc","getContext","hydrationCtxValue","useMemo","dehydrate","payload","options","Provider","value","RouterProvider","transformStreamWithRouter","transformStreamHtmlCallback","injectorPromises","injectedHtml","map","d","injectors","all","join","injector","leftover","Transform","transform","chunk","encoding","callback","chunkString","toString","patternBody","patternHtml","bodyMatch","match","htmlMatch","then","html","index","bodyIndex","length","htmlIndex","processed","slice","push","pattern","result","lastIndex","exec","catch","error","flush"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAASA,oBAAoBA,CAA4BC,IAE/D,EAAE;AACD,EAAA,OAAO,OAAO;AAAEC,IAAAA,OAAAA;AAAoB,GAAC,KAAK;IACxC,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAACF,OAAO,CAACG,GAAG,CAAC,CAAA;AACpC,IAAA,MAAMA,GAAG,GAAGH,OAAO,CAACG,GAAG,CAACC,OAAO,CAACH,OAAO,CAACI,MAAM,EAAE,EAAE,CAAC,CAAA;;AAEnD;AACA;AACA;AACA;AACA;AACA;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CAAA;QAClB+B,QAAQ,CAAC/B,GAAG,CAAC,CAAA;AACf,OAAC,CAAC,CAAA;KACL;IACDsD,KAAKA,CAACvB,QAAQ,EAAE;AACd,MAAA,IAAIL,QAAQ,EAAE;AACZ,QAAA,IAAI,CAACqB,IAAI,CAACrB,QAAQ,CAAC,CAAA;AACrB,OAAA;AACAK,MAAAA,QAAQ,EAAE,CAAA;AACZ,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;;;"} | ||
| {"version":3,"file":"server.js","sources":["../../src/server.tsx"],"sourcesContent":["import type { APIContext } from 'astro'\nimport {\n AnyRouter,\n createMemoryHistory,\n RouterProvider,\n} from '@tanstack/react-router'\n// import { handleEvent, hasHandler, handlers } from '@tanstack/bling/server'\nimport * as ReactDOMServer from 'react-dom/server'\nimport * as React from 'react'\nimport isbot from 'isbot'\nimport { PassThrough, Transform } from 'stream'\n// @ts-ignore\nimport cprc from '@gisatcz/cross-package-react-context'\n\nexport function createRequestHandler<TRouter extends AnyRouter>(opts: {\n createRouter: () => TRouter\n}) {\n return async ({ request }: APIContext) => {\n const fullUrl = new URL(request.url)\n const url = request.url.replace(fullUrl.origin, '')\n\n if (fullUrl.pathname.includes('.')) {\n return new Response(null, {\n status: 404,\n })\n }\n\n console.log('Rendering: ', url, '...')\n\n const history = createMemoryHistory({\n initialEntries: [url],\n })\n\n const router = opts.createRouter()\n\n router.update({\n history,\n })\n\n await router.load()\n\n return new Promise((resolve, reject) => {\n let didError = false\n\n const responseStatusCode = 200\n const responseHeaders = new Headers({\n 'Content-Type': 'text/html',\n })\n\n // Clever way to get the right callback. Thanks Remix!\n const callbackName = isbot(request.headers.get('user-agent'))\n ? 'onAllReady'\n : 'onShellReady'\n\n const stream = ReactDOMServer.renderToPipeableStream(\n <StartServer router={router} />,\n {\n [callbackName]: () => {\n const body = new PassThrough()\n\n responseHeaders.set('Content-Type', 'text/html')\n\n resolve(\n new Response(body as any, {\n headers: responseHeaders,\n status: didError ? 500 : responseStatusCode,\n }),\n )\n\n stream.pipe(body)\n },\n onShellError: (err) => {\n reject(err)\n },\n onError: (err) => {\n didError = true\n console.log(err)\n },\n },\n )\n\n setTimeout(() => stream.abort(), 10000)\n })\n }\n}\n\nexport function StartServer<TRouter extends AnyRouter>(props: {\n router: TRouter\n}) {\n const hydrationContext = cprc.getContext('TanStackRouterHydrationContext', {})\n\n const hydrationCtxValue = React.useMemo(\n () => ({\n router: props.router.dehydrate(),\n payload: props.router.options.dehydrate?.(),\n }),\n [],\n )\n\n return (\n // Provide the hydration context still, since `<DehydrateRouter />` needs it.\n <hydrationContext.Provider value={hydrationCtxValue}>\n <RouterProvider router={props.router} />\n </hydrationContext.Provider>\n )\n}\n\nexport function transformStreamWithRouter(router: AnyRouter) {\n return transformStreamHtmlCallback(async () => {\n const injectorPromises = router.injectedHtml.map((d) =>\n typeof d === 'function' ? d() : d,\n )\n const injectors = await Promise.all(injectorPromises)\n router.injectedHtml = []\n return injectors.join('')\n })\n}\n\nfunction transformStreamHtmlCallback(injector: () => Promise<string>) {\n let leftover = ''\n\n return new Transform({\n transform(chunk, encoding, callback) {\n let chunkString = leftover + chunk.toString()\n\n // regex pattern for matching closing body and html tags\n const patternBody = /(<\\/body>)/\n const patternHtml = /(<\\/html>)/\n\n const bodyMatch = chunkString.match(patternBody)\n const htmlMatch = chunkString.match(patternHtml)\n\n injector()\n .then((html) => {\n // If a </body></html> sequence was found\n if (bodyMatch && htmlMatch && bodyMatch.index! < htmlMatch.index!) {\n const bodyIndex = bodyMatch.index! + bodyMatch[0].length\n const htmlIndex = htmlMatch.index! + htmlMatch[0].length\n\n // Add the arbitrary HTML before the closing body tag\n const processed =\n chunkString.slice(0, bodyIndex) +\n html +\n chunkString.slice(bodyIndex, htmlIndex) +\n chunkString.slice(htmlIndex)\n\n this.push(processed)\n leftover = ''\n } else {\n // For all other closing tags, add the arbitrary HTML after them\n const pattern = /(<\\/[a-zA-Z][\\w:.-]*?>)/g\n let result\n let lastIndex = 0\n\n while ((result = pattern.exec(chunkString)) !== null) {\n lastIndex = result.index + result[0].length\n }\n\n // If a closing tag was found, add the arbitrary HTML and send it through\n if (lastIndex > 0) {\n const processed = chunkString.slice(0, lastIndex) + html\n this.push(processed)\n leftover = chunkString.slice(lastIndex)\n } else {\n // If no closing tag was found, store the chunk to process with the next one\n leftover = chunkString\n }\n }\n\n callback()\n })\n .catch((err) => {\n console.error(err)\n callback(err)\n })\n },\n flush(callback) {\n if (leftover) {\n this.push(leftover)\n }\n callback()\n },\n })\n}\n"],"names":["createRequestHandler","opts","request","fullUrl","URL","url","replace","origin","pathname","includes","Response","status","console","log","history","createMemoryHistory","initialEntries","router","createRouter","update","load","Promise","resolve","reject","didError","responseStatusCode","responseHeaders","Headers","callbackName","isbot","headers","get","stream","ReactDOMServer","renderToPipeableStream","React","createElement","StartServer","body","PassThrough","set","pipe","onShellError","err","onError","setTimeout","abort","props","hydrationContext","cprc","getContext","hydrationCtxValue","useMemo","dehydrate","payload","options","Provider","value","RouterProvider","transformStreamWithRouter","transformStreamHtmlCallback","injectorPromises","injectedHtml","map","d","injectors","all","join","injector","leftover","Transform","transform","chunk","encoding","callback","chunkString","toString","patternBody","patternHtml","bodyMatch","match","htmlMatch","then","html","index","bodyIndex","length","htmlIndex","processed","slice","push","pattern","result","lastIndex","exec","catch","error","flush"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcO,SAASA,oBAAoBA,CAA4BC,IAE/D,EAAE;AACD,EAAA,OAAO,OAAO;AAAEC,IAAAA,OAAAA;AAAoB,GAAC,KAAK;IACxC,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAACF,OAAO,CAACG,GAAG,CAAC,CAAA;AACpC,IAAA,MAAMA,GAAG,GAAGH,OAAO,CAACG,GAAG,CAACC,OAAO,CAACH,OAAO,CAACI,MAAM,EAAE,EAAE,CAAC,CAAA;IAEnD,IAAIJ,OAAO,CAACK,QAAQ,CAACC,QAAQ,CAAC,GAAG,CAA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,CAAA;KACL;IACDsD,KAAKA,CAACvB,QAAQ,EAAE;AACd,MAAA,IAAIL,QAAQ,EAAE;AACZ,QAAA,IAAI,CAACqB,IAAI,CAACrB,QAAQ,CAAC,CAAA;AACrB,OAAA;AACAK,MAAAA,QAAQ,EAAE,CAAA;AACZ,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;;;"} |
@@ -24,10 +24,2 @@ /** | ||
| const url = request.url.replace(fullUrl.origin, ''); | ||
| // console.log(handlers) | ||
| // if (hasHandler(fullUrl.pathname)) { | ||
| // return await handleEvent({ | ||
| // request, | ||
| // }) | ||
| // } | ||
| if (fullUrl.pathname.includes('.')) { | ||
@@ -34,0 +26,0 @@ return new Response(null, { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"server.js","sources":["../../src/server.tsx"],"sourcesContent":["import type { APIContext } from 'astro'\nimport {\n AnyRouter,\n createMemoryHistory,\n RouterProvider,\n} from '@tanstack/react-router'\n// import { handleEvent, hasHandler, handlers } from '@tanstack/bling/server'\nimport * as ReactDOMServer from 'react-dom/server'\nimport * as React from 'react'\nimport isbot from 'isbot'\nimport { PassThrough, Transform } from 'stream'\n// @ts-ignore\nimport cprc from '@gisatcz/cross-package-react-context'\n\nexport function createRequestHandler<TRouter extends AnyRouter>(opts: {\n createRouter: () => TRouter\n}) {\n return async ({ request }: APIContext) => {\n const fullUrl = new URL(request.url)\n const url = request.url.replace(fullUrl.origin, '')\n\n // console.log(handlers)\n // if (hasHandler(fullUrl.pathname)) {\n // return await handleEvent({\n // request,\n // })\n // }\n\n if (fullUrl.pathname.includes('.')) {\n return new Response(null, {\n status: 404,\n })\n }\n\n console.log('Rendering: ', url, '...')\n\n const history = createMemoryHistory({\n initialEntries: [url],\n })\n\n const router = opts.createRouter()\n\n router.update({\n history,\n })\n\n await router.load()\n\n return new Promise((resolve, reject) => {\n let didError = false\n\n const responseStatusCode = 200\n const responseHeaders = new Headers({\n 'Content-Type': 'text/html',\n })\n\n // Clever way to get the right callback. Thanks Remix!\n const callbackName = isbot(request.headers.get('user-agent'))\n ? 'onAllReady'\n : 'onShellReady'\n\n const stream = ReactDOMServer.renderToPipeableStream(\n <StartServer router={router} />,\n {\n [callbackName]: () => {\n const body = new PassThrough()\n\n responseHeaders.set('Content-Type', 'text/html')\n\n resolve(\n new Response(body as any, {\n headers: responseHeaders,\n status: didError ? 500 : responseStatusCode,\n }),\n )\n\n stream.pipe(body)\n },\n onShellError: (err) => {\n reject(err)\n },\n onError: (err) => {\n didError = true\n console.log(err)\n },\n },\n )\n\n setTimeout(() => stream.abort(), 10000)\n })\n }\n}\n\nexport function StartServer<TRouter extends AnyRouter>(props: {\n router: TRouter\n}) {\n const hydrationContext = cprc.getContext('TanStackRouterHydrationContext', {})\n\n const hydrationCtxValue = React.useMemo(\n () => ({\n router: props.router.dehydrate(),\n payload: props.router.options.dehydrate?.(),\n }),\n [],\n )\n\n return (\n // Provide the hydration context still, since `<DehydrateRouter />` needs it.\n <hydrationContext.Provider value={hydrationCtxValue}>\n <RouterProvider router={props.router} />\n </hydrationContext.Provider>\n )\n}\n\nexport function transformStreamWithRouter(router: AnyRouter) {\n return transformStreamHtmlCallback(async () => {\n const injectorPromises = router.injectedHtml.map((d) =>\n typeof d === 'function' ? d() : d,\n )\n const injectors = await Promise.all(injectorPromises)\n router.injectedHtml = []\n return injectors.join('')\n })\n}\n\nfunction transformStreamHtmlCallback(injector: () => Promise<string>) {\n let leftover = ''\n\n return new Transform({\n transform(chunk, encoding, callback) {\n let chunkString = leftover + chunk.toString()\n\n // regex pattern for matching closing body and html tags\n const patternBody = /(<\\/body>)/\n const patternHtml = /(<\\/html>)/\n\n const bodyMatch = chunkString.match(patternBody)\n const htmlMatch = chunkString.match(patternHtml)\n\n injector()\n .then((html) => {\n // If a </body></html> sequence was found\n if (bodyMatch && htmlMatch && bodyMatch.index! < htmlMatch.index!) {\n const bodyIndex = bodyMatch.index! + bodyMatch[0].length\n const htmlIndex = htmlMatch.index! + htmlMatch[0].length\n\n // Add the arbitrary HTML before the closing body tag\n const processed =\n chunkString.slice(0, bodyIndex) +\n html +\n chunkString.slice(bodyIndex, htmlIndex) +\n chunkString.slice(htmlIndex)\n\n this.push(processed)\n leftover = ''\n } else {\n // For all other closing tags, add the arbitrary HTML after them\n const pattern = /(<\\/[a-zA-Z][\\w:.-]*?>)/g\n let result\n let lastIndex = 0\n\n while ((result = pattern.exec(chunkString)) !== null) {\n lastIndex = result.index + result[0].length\n }\n\n // If a closing tag was found, add the arbitrary HTML and send it through\n if (lastIndex > 0) {\n const processed = chunkString.slice(0, lastIndex) + html\n this.push(processed)\n leftover = chunkString.slice(lastIndex)\n } else {\n // If no closing tag was found, store the chunk to process with the next one\n leftover = chunkString\n }\n }\n\n callback()\n })\n .catch((err) => {\n console.error(err)\n callback(err)\n })\n },\n flush(callback) {\n if (leftover) {\n this.push(leftover)\n }\n callback()\n },\n })\n}\n"],"names":["createRequestHandler","opts","request","fullUrl","URL","url","replace","origin","pathname","includes","Response","status","console","log","history","createMemoryHistory","initialEntries","router","createRouter","update","load","Promise","resolve","reject","didError","responseStatusCode","responseHeaders","Headers","callbackName","isbot","headers","get","stream","ReactDOMServer","renderToPipeableStream","React","createElement","StartServer","body","PassThrough","set","pipe","onShellError","err","onError","setTimeout","abort","props","hydrationContext","cprc","getContext","hydrationCtxValue","useMemo","dehydrate","payload","options","Provider","value","RouterProvider","transformStreamWithRouter","transformStreamHtmlCallback","injectorPromises","injectedHtml","map","d","injectors","all","join","injector","leftover","Transform","transform","chunk","encoding","callback","chunkString","toString","patternBody","patternHtml","bodyMatch","match","htmlMatch","then","html","index","bodyIndex","length","htmlIndex","processed","slice","push","pattern","result","lastIndex","exec","catch","error","flush"],"mappings":";;;;;;;;;;;;;;;;;AAcO,SAASA,oBAAoBA,CAA4BC,IAE/D,EAAE;AACD,EAAA,OAAO,OAAO;AAAEC,IAAAA,OAAAA;AAAoB,GAAC,KAAK;IACxC,MAAMC,OAAO,GAAG,IAAIC,GAAG,CA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AA;AACxB,WAAA;AACF,SAAA;AAEAD,QAAAA,QAAQ,EAAE,CAAA;AACZ,OAAC,CAAC,CACDqB,KAAK,CAAEpD,GAAG,IAAK;AACd/B,QAAAA,OAAO,CAACoF,KAAK,CAACrD,GAAG,CAAC,CAAA;QAClB+B,QAAQ,CAAC/B,GAAG,CAAC,CAAA;AACf,OAAC,CAAC,CAAA;KACL;IACDsD,KAAKA,CAACvB,QAAQ,EAAE;AACd,MAAA,IAAIL,QAAQ,EAAE;AACZ,QAAA,IAAI,CAACqB,IAAI,CAACrB,QAAQ,CAAC,CAAA;AACrB,OAAA;AACAK,MAAAA,QAAQ,EAAE,CAAA;AACZ,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;"} | ||
| {"version":3,"file":"server.js","sources":["../../src/server.tsx"],"sourcesContent":["import type { APIContext } from 'astro'\nimport {\n AnyRouter,\n createMemoryHistory,\n RouterProvider,\n} from '@tanstack/react-router'\n// import { handleEvent, hasHandler, handlers } from '@tanstack/bling/server'\nimport * as ReactDOMServer from 'react-dom/server'\nimport * as React from 'react'\nimport isbot from 'isbot'\nimport { PassThrough, Transform } from 'stream'\n// @ts-ignore\nimport cprc from '@gisatcz/cross-package-react-context'\n\nexport function createRequestHandler<TRouter extends AnyRouter>(opts: {\n createRouter: () => TRouter\n}) {\n return async ({ request }: APIContext) => {\n const fullUrl = new URL(request.url)\n const url = request.url.replace(fullUrl.origin, '')\n\n if (fullUrl.pathname.includes('.')) {\n return new Response(null, {\n status: 404,\n })\n }\n\n console.log('Rendering: ', url, '...')\n\n const history = createMemoryHistory({\n initialEntries: [url],\n })\n\n const router = opts.createRouter()\n\n router.update({\n history,\n })\n\n await router.load()\n\n return new Promise((resolve, reject) => {\n let didError = false\n\n const responseStatusCode = 200\n const responseHeaders = new Headers({\n 'Content-Type': 'text/html',\n })\n\n // Clever way to get the right callback. Thanks Remix!\n const callbackName = isbot(request.headers.get('user-agent'))\n ? 'onAllReady'\n : 'onShellReady'\n\n const stream = ReactDOMServer.renderToPipeableStream(\n <StartServer router={router} />,\n {\n [callbackName]: () => {\n const body = new PassThrough()\n\n responseHeaders.set('Content-Type', 'text/html')\n\n resolve(\n new Response(body as any, {\n headers: responseHeaders,\n status: didError ? 500 : responseStatusCode,\n }),\n )\n\n stream.pipe(body)\n },\n onShellError: (err) => {\n reject(err)\n },\n onError: (err) => {\n didError = true\n console.log(err)\n },\n },\n )\n\n setTimeout(() => stream.abort(), 10000)\n })\n }\n}\n\nexport function StartServer<TRouter extends AnyRouter>(props: {\n router: TRouter\n}) {\n const hydrationContext = cprc.getContext('TanStackRouterHydrationContext', {})\n\n const hydrationCtxValue = React.useMemo(\n () => ({\n router: props.router.dehydrate(),\n payload: props.router.options.dehydrate?.(),\n }),\n [],\n )\n\n return (\n // Provide the hydration context still, since `<DehydrateRouter />` needs it.\n <hydrationContext.Provider value={hydrationCtxValue}>\n <RouterProvider router={props.router} />\n </hydrationContext.Provider>\n )\n}\n\nexport function transformStreamWithRouter(router: AnyRouter) {\n return transformStreamHtmlCallback(async () => {\n const injectorPromises = router.injectedHtml.map((d) =>\n typeof d === 'function' ? d() : d,\n )\n const injectors = await Promise.all(injectorPromises)\n router.injectedHtml = []\n return injectors.join('')\n })\n}\n\nfunction transformStreamHtmlCallback(injector: () => Promise<string>) {\n let leftover = ''\n\n return new Transform({\n transform(chunk, encoding, callback) {\n let chunkString = leftover + chunk.toString()\n\n // regex pattern for matching closing body and html tags\n const patternBody = /(<\\/body>)/\n const patternHtml = /(<\\/html>)/\n\n const bodyMatch = chunkString.match(patternBody)\n const htmlMatch = chunkString.match(patternHtml)\n\n injector()\n .then((html) => {\n // If a </body></html> sequence was found\n if (bodyMatch && htmlMatch && bodyMatch.index! < htmlMatch.index!) {\n const bodyIndex = bodyMatch.index! + bodyMatch[0].length\n const htmlIndex = htmlMatch.index! + htmlMatch[0].length\n\n // Add the arbitrary HTML before the closing body tag\n const processed =\n chunkString.slice(0, bodyIndex) +\n html +\n chunkString.slice(bodyIndex, htmlIndex) +\n chunkString.slice(htmlIndex)\n\n this.push(processed)\n leftover = ''\n } else {\n // For all other closing tags, add the arbitrary HTML after them\n const pattern = /(<\\/[a-zA-Z][\\w:.-]*?>)/g\n let result\n let lastIndex = 0\n\n while ((result = pattern.exec(chunkString)) !== null) {\n lastIndex = result.index + result[0].length\n }\n\n // If a closing tag was found, add the arbitrary HTML and send it through\n if (lastIndex > 0) {\n const processed = chunkString.slice(0, lastIndex) + html\n this.push(processed)\n leftover = chunkString.slice(lastIndex)\n } else {\n // If no closing tag was found, store the chunk to process with the next one\n leftover = chunkString\n }\n }\n\n callback()\n })\n .catch((err) => {\n console.error(err)\n callback(err)\n })\n },\n flush(callback) {\n if (leftover) {\n this.push(leftover)\n }\n callback()\n },\n })\n}\n"],"names":["createRequestHandler","opts","request","fullUrl","URL","url","replace","origin","pathname","includes","Response","status","console","log","history","createMemoryHistory","initialEntries","router","createRouter","update","load","Promise","resolve","reject","didError","responseStatusCode","responseHeaders","Headers","callbackName","isbot","headers","get","stream","ReactDOMServer","renderToPipeableStream","React","createElement","StartServer","body","PassThrough","set","pipe","onShellError","err","onError","setTimeout","abort","props","hydrationContext","cprc","getContext","hydrationCtxValue","useMemo","dehydrate","payload","options","Provider","value","RouterProvider","transformStreamWithRouter","transformStreamHtmlCallback","injectorPromises","injectedHtml","map","d","injectors","all","join","injector","leftover","Transform","transform","chunk","encoding","callback","chunkString","toString","patternBody","patternHtml","bodyMatch","match","htmlMatch","then","html","index","bodyIndex","length","htmlIndex","processed","slice","push","pattern","result","lastIndex","exec","catch","error","flush"],"mappings":";;;;;;;;;;;;;;;;;AAcO,SAASA,oBAAoBA,CAA4BC,IAE/D,EAAE;AACD,EAAA,OAAO,OAAO;AAAEC,IAAAA,OAAAA;AAAoB,GAAC,KAAK;IACxC,MAAMC,OAAO,GAAG,IAAIC,GAAG,CAACF,OAAO,CAACG,GAAG,CAAC,CAAA;AACpC,IAAA,MAAMA,GAAG,GAAGH,OAAO,CAACG,GA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ACd/B,QAAAA,OAAO,CAACoF,KAAK,CAACrD,GAAG,CAAC,CAAA;QAClB+B,QAAQ,CAAC/B,GAAG,CAAC,CAAA;AACf,OAAC,CAAC,CAAA;KACL;IACDsD,KAAKA,CAACvB,QAAQ,EAAE;AACd,MAAA,IAAIL,QAAQ,EAAE;AACZ,QAAA,IAAI,CAACqB,IAAI,CAACrB,QAAQ,CAAC,CAAA;AACrB,OAAA;AACAK,MAAAA,QAAQ,EAAE,CAAA;AACZ,KAAA;AACF,GAAC,CAAC,CAAA;AACJ;;;;"} |
+181
-181
@@ -10,28 +10,11 @@ { | ||
| { | ||
| "name": "packages", | ||
| "name": "node_modules/.pnpm", | ||
| "children": [ | ||
| { | ||
| "name": "react-store/build/esm/index.js", | ||
| "uid": "e1d4-334" | ||
| "name": "@tanstack+react-store@0.0.1/node_modules/@tanstack/react-store/build/esm/index.js", | ||
| "uid": "5c7c-312" | ||
| }, | ||
| { | ||
| "name": "router-core/build/esm/index.js", | ||
| "uid": "e1d4-338" | ||
| }, | ||
| { | ||
| "name": "react-router/build/esm/index.js", | ||
| "uid": "e1d4-340" | ||
| }, | ||
| { | ||
| "name": "react-start/src/server.tsx", | ||
| "uid": "e1d4-356" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "node_modules/.pnpm", | ||
| "children": [ | ||
| { | ||
| "name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
| "uid": "e1d4-336" | ||
| "uid": "5c7c-314" | ||
| }, | ||
@@ -45,7 +28,7 @@ { | ||
| { | ||
| "uid": "e1d4-344", | ||
| "uid": "5c7c-322", | ||
| "name": "react-dom-server-legacy.node.production.min.js" | ||
| }, | ||
| { | ||
| "uid": "e1d4-348", | ||
| "uid": "5c7c-326", | ||
| "name": "react-dom-server.node.production.min.js" | ||
@@ -56,3 +39,3 @@ } | ||
| { | ||
| "uid": "e1d4-350", | ||
| "uid": "5c7c-328", | ||
| "name": "server.node.js" | ||
@@ -64,7 +47,7 @@ } | ||
| "name": "isbot@3.6.6/node_modules/isbot/index.mjs", | ||
| "uid": "e1d4-352" | ||
| "uid": "5c7c-330" | ||
| }, | ||
| { | ||
| "name": "@gisatcz+cross-package-react-context@0.2.0/node_modules/@gisatcz/cross-package-react-context/lib/index.js", | ||
| "uid": "e1d4-354" | ||
| "uid": "5c7c-332" | ||
| } | ||
@@ -74,10 +57,27 @@ ] | ||
| { | ||
| "name": "packages", | ||
| "children": [ | ||
| { | ||
| "name": "router-core/build/esm/index.js", | ||
| "uid": "5c7c-316" | ||
| }, | ||
| { | ||
| "name": "react-router/build/esm/index.js", | ||
| "uid": "5c7c-318" | ||
| }, | ||
| { | ||
| "name": "react-start/src/server.tsx", | ||
| "uid": "5c7c-334" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "name": "\u0000/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs", | ||
| "children": [ | ||
| { | ||
| "uid": "e1d4-342", | ||
| "uid": "5c7c-320", | ||
| "name": "react-dom-server-legacy.node.production.min.js?commonjs-exports" | ||
| }, | ||
| { | ||
| "uid": "e1d4-346", | ||
| "uid": "5c7c-324", | ||
| "name": "react-dom-server.node.production.min.js?commonjs-exports" | ||
@@ -93,87 +93,87 @@ } | ||
| "nodeParts": { | ||
| "e1d4-334": { | ||
| "5c7c-312": { | ||
| "renderedLength": 1002, | ||
| "gzipLength": 474, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-333" | ||
| "mainUid": "5c7c-311" | ||
| }, | ||
| "e1d4-336": { | ||
| "5c7c-314": { | ||
| "renderedLength": 181, | ||
| "gzipLength": 129, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-335" | ||
| "mainUid": "5c7c-313" | ||
| }, | ||
| "e1d4-338": { | ||
| "5c7c-316": { | ||
| "renderedLength": 4302, | ||
| "gzipLength": 1303, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-337" | ||
| "mainUid": "5c7c-315" | ||
| }, | ||
| "e1d4-340": { | ||
| "5c7c-318": { | ||
| "renderedLength": 8967, | ||
| "gzipLength": 2229, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-339" | ||
| "mainUid": "5c7c-317" | ||
| }, | ||
| "e1d4-342": { | ||
| "5c7c-320": { | ||
| "renderedLength": 52, | ||
| "gzipLength": 72, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-341" | ||
| "mainUid": "5c7c-319" | ||
| }, | ||
| "e1d4-344": { | ||
| "5c7c-322": { | ||
| "renderedLength": 39760, | ||
| "gzipLength": 12920, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-343" | ||
| "mainUid": "5c7c-321" | ||
| }, | ||
| "e1d4-346": { | ||
| "5c7c-324": { | ||
| "renderedLength": 46, | ||
| "gzipLength": 66, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-345" | ||
| "mainUid": "5c7c-323" | ||
| }, | ||
| "e1d4-348": { | ||
| "5c7c-326": { | ||
| "renderedLength": 39881, | ||
| "gzipLength": 13432, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-347" | ||
| "mainUid": "5c7c-325" | ||
| }, | ||
| "e1d4-350": { | ||
| "5c7c-328": { | ||
| "renderedLength": 302, | ||
| "gzipLength": 166, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-349" | ||
| "mainUid": "5c7c-327" | ||
| }, | ||
| "e1d4-352": { | ||
| "5c7c-330": { | ||
| "renderedLength": 14785, | ||
| "gzipLength": 4482, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-351" | ||
| "mainUid": "5c7c-329" | ||
| }, | ||
| "e1d4-354": { | ||
| "5c7c-332": { | ||
| "renderedLength": 454, | ||
| "gzipLength": 189, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-353" | ||
| "mainUid": "5c7c-331" | ||
| }, | ||
| "e1d4-356": { | ||
| "renderedLength": 4913, | ||
| "gzipLength": 1676, | ||
| "5c7c-334": { | ||
| "renderedLength": 4750, | ||
| "gzipLength": 1629, | ||
| "brotliLength": 0, | ||
| "mainUid": "e1d4-355" | ||
| "mainUid": "5c7c-333" | ||
| } | ||
| }, | ||
| "nodeMetas": { | ||
| "e1d4-333": { | ||
| "id": "/packages/react-store/build/esm/index.js", | ||
| "5c7c-311": { | ||
| "id": "/node_modules/.pnpm/@tanstack+react-store@0.0.1/node_modules/@tanstack/react-store/build/esm/index.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-334" | ||
| "index.production.js": "5c7c-312" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-364" | ||
| "uid": "5c7c-342" | ||
| }, | ||
| { | ||
| "uid": "e1d4-365" | ||
| "uid": "5c7c-343" | ||
| } | ||
@@ -183,13 +183,10 @@ ], | ||
| { | ||
| "uid": "e1d4-339" | ||
| }, | ||
| { | ||
| "uid": "e1d4-337" | ||
| "uid": "5c7c-317" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-335": { | ||
| "5c7c-313": { | ||
| "id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-336" | ||
| "index.production.js": "5c7c-314" | ||
| }, | ||
@@ -199,23 +196,23 @@ "imported": [], | ||
| { | ||
| "uid": "e1d4-339" | ||
| "uid": "5c7c-317" | ||
| }, | ||
| { | ||
| "uid": "e1d4-337" | ||
| "uid": "5c7c-315" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-337": { | ||
| "5c7c-315": { | ||
| "id": "/packages/router-core/build/esm/index.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-338" | ||
| "index.production.js": "5c7c-316" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-335" | ||
| "uid": "5c7c-313" | ||
| }, | ||
| { | ||
| "uid": "e1d4-359" | ||
| "uid": "5c7c-337" | ||
| }, | ||
| { | ||
| "uid": "e1d4-333" | ||
| "uid": "5c7c-343" | ||
| } | ||
@@ -225,26 +222,26 @@ ], | ||
| { | ||
| "uid": "e1d4-339" | ||
| "uid": "5c7c-317" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-339": { | ||
| "5c7c-317": { | ||
| "id": "/packages/react-router/build/esm/index.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-340" | ||
| "index.production.js": "5c7c-318" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-333" | ||
| "uid": "5c7c-311" | ||
| }, | ||
| { | ||
| "uid": "e1d4-337" | ||
| "uid": "5c7c-315" | ||
| }, | ||
| { | ||
| "uid": "e1d4-357" | ||
| "uid": "5c7c-335" | ||
| }, | ||
| { | ||
| "uid": "e1d4-335" | ||
| "uid": "5c7c-313" | ||
| }, | ||
| { | ||
| "uid": "e1d4-359" | ||
| "uid": "5c7c-337" | ||
| } | ||
@@ -254,10 +251,10 @@ ], | ||
| { | ||
| "uid": "e1d4-355" | ||
| "uid": "5c7c-333" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-341": { | ||
| "5c7c-319": { | ||
| "id": "\u0000/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js?commonjs-exports", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-342" | ||
| "index.production.js": "5c7c-320" | ||
| }, | ||
@@ -267,23 +264,23 @@ "imported": [], | ||
| { | ||
| "uid": "e1d4-343" | ||
| "uid": "5c7c-321" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-343": { | ||
| "5c7c-321": { | ||
| "id": "/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.production.min.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-344" | ||
| "index.production.js": "5c7c-322" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-360" | ||
| "uid": "5c7c-338" | ||
| }, | ||
| { | ||
| "uid": "e1d4-341" | ||
| "uid": "5c7c-319" | ||
| }, | ||
| { | ||
| "uid": "e1d4-366" | ||
| "uid": "5c7c-344" | ||
| }, | ||
| { | ||
| "uid": "e1d4-367" | ||
| "uid": "5c7c-345" | ||
| } | ||
@@ -293,10 +290,10 @@ ], | ||
| { | ||
| "uid": "e1d4-349" | ||
| "uid": "5c7c-327" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-345": { | ||
| "5c7c-323": { | ||
| "id": "\u0000/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.node.production.min.js?commonjs-exports", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-346" | ||
| "index.production.js": "5c7c-324" | ||
| }, | ||
@@ -306,23 +303,23 @@ "imported": [], | ||
| { | ||
| "uid": "e1d4-347" | ||
| "uid": "5c7c-325" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-347": { | ||
| "5c7c-325": { | ||
| "id": "/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.node.production.min.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-348" | ||
| "index.production.js": "5c7c-326" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-360" | ||
| "uid": "5c7c-338" | ||
| }, | ||
| { | ||
| "uid": "e1d4-345" | ||
| "uid": "5c7c-323" | ||
| }, | ||
| { | ||
| "uid": "e1d4-368" | ||
| "uid": "5c7c-346" | ||
| }, | ||
| { | ||
| "uid": "e1d4-366" | ||
| "uid": "5c7c-344" | ||
| } | ||
@@ -332,29 +329,29 @@ ], | ||
| { | ||
| "uid": "e1d4-349" | ||
| "uid": "5c7c-327" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-349": { | ||
| "5c7c-327": { | ||
| "id": "/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/server.node.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-350" | ||
| "index.production.js": "5c7c-328" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-360" | ||
| "uid": "5c7c-338" | ||
| }, | ||
| { | ||
| "uid": "e1d4-361" | ||
| "uid": "5c7c-339" | ||
| }, | ||
| { | ||
| "uid": "e1d4-343" | ||
| "uid": "5c7c-321" | ||
| }, | ||
| { | ||
| "uid": "e1d4-347" | ||
| "uid": "5c7c-325" | ||
| }, | ||
| { | ||
| "uid": "e1d4-362" | ||
| "uid": "5c7c-340" | ||
| }, | ||
| { | ||
| "uid": "e1d4-363" | ||
| "uid": "5c7c-341" | ||
| } | ||
@@ -364,10 +361,10 @@ ], | ||
| { | ||
| "uid": "e1d4-355" | ||
| "uid": "5c7c-333" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-351": { | ||
| "5c7c-329": { | ||
| "id": "/node_modules/.pnpm/isbot@3.6.6/node_modules/isbot/index.mjs", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-352" | ||
| "index.production.js": "5c7c-330" | ||
| }, | ||
@@ -377,14 +374,14 @@ "imported": [], | ||
| { | ||
| "uid": "e1d4-355" | ||
| "uid": "5c7c-333" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-353": { | ||
| "5c7c-331": { | ||
| "id": "/node_modules/.pnpm/@gisatcz+cross-package-react-context@0.2.0/node_modules/@gisatcz/cross-package-react-context/lib/index.js", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-354" | ||
| "index.production.js": "5c7c-332" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-357" | ||
| "uid": "5c7c-335" | ||
| } | ||
@@ -394,29 +391,29 @@ ], | ||
| { | ||
| "uid": "e1d4-355" | ||
| "uid": "5c7c-333" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-355": { | ||
| "5c7c-333": { | ||
| "id": "/packages/react-start/src/server.tsx", | ||
| "moduleParts": { | ||
| "index.production.js": "e1d4-356" | ||
| "index.production.js": "5c7c-334" | ||
| }, | ||
| "imported": [ | ||
| { | ||
| "uid": "e1d4-339" | ||
| "uid": "5c7c-317" | ||
| }, | ||
| { | ||
| "uid": "e1d4-349" | ||
| "uid": "5c7c-327" | ||
| }, | ||
| { | ||
| "uid": "e1d4-357" | ||
| "uid": "5c7c-335" | ||
| }, | ||
| { | ||
| "uid": "e1d4-351" | ||
| "uid": "5c7c-329" | ||
| }, | ||
| { | ||
| "uid": "e1d4-358" | ||
| "uid": "5c7c-336" | ||
| }, | ||
| { | ||
| "uid": "e1d4-353" | ||
| "uid": "5c7c-331" | ||
| } | ||
@@ -427,3 +424,3 @@ ], | ||
| }, | ||
| "e1d4-357": { | ||
| "5c7c-335": { | ||
| "id": "react", | ||
@@ -434,12 +431,12 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-355" | ||
| "uid": "5c7c-333" | ||
| }, | ||
| { | ||
| "uid": "e1d4-339" | ||
| "uid": "5c7c-317" | ||
| }, | ||
| { | ||
| "uid": "e1d4-353" | ||
| "uid": "5c7c-331" | ||
| }, | ||
| { | ||
| "uid": "e1d4-366" | ||
| "uid": "5c7c-344" | ||
| } | ||
@@ -449,3 +446,3 @@ ], | ||
| }, | ||
| "e1d4-358": { | ||
| "5c7c-336": { | ||
| "id": "stream", | ||
@@ -456,6 +453,6 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-355" | ||
| "uid": "5c7c-333" | ||
| }, | ||
| { | ||
| "uid": "e1d4-367" | ||
| "uid": "5c7c-345" | ||
| } | ||
@@ -465,3 +462,3 @@ ], | ||
| }, | ||
| "e1d4-359": { | ||
| "5c7c-337": { | ||
| "id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js", | ||
@@ -472,10 +469,10 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-339" | ||
| "uid": "5c7c-317" | ||
| }, | ||
| { | ||
| "uid": "e1d4-337" | ||
| "uid": "5c7c-315" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-360": { | ||
| "5c7c-338": { | ||
| "id": "\u0000commonjsHelpers.js", | ||
@@ -486,19 +483,19 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-349" | ||
| "uid": "5c7c-327" | ||
| }, | ||
| { | ||
| "uid": "e1d4-343" | ||
| "uid": "5c7c-321" | ||
| }, | ||
| { | ||
| "uid": "e1d4-347" | ||
| "uid": "5c7c-325" | ||
| }, | ||
| { | ||
| "uid": "e1d4-362" | ||
| "uid": "5c7c-340" | ||
| }, | ||
| { | ||
| "uid": "e1d4-363" | ||
| "uid": "5c7c-341" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-361": { | ||
| "5c7c-339": { | ||
| "id": "\u0000/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/server.node.js?commonjs-exports", | ||
@@ -509,7 +506,7 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-349" | ||
| "uid": "5c7c-327" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-362": { | ||
| "5c7c-340": { | ||
| "id": "/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js", | ||
@@ -519,12 +516,12 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-360" | ||
| "uid": "5c7c-338" | ||
| }, | ||
| { | ||
| "uid": "e1d4-369" | ||
| "uid": "5c7c-347" | ||
| }, | ||
| { | ||
| "uid": "e1d4-366" | ||
| "uid": "5c7c-344" | ||
| }, | ||
| { | ||
| "uid": "e1d4-367" | ||
| "uid": "5c7c-345" | ||
| } | ||
@@ -534,7 +531,7 @@ ], | ||
| { | ||
| "uid": "e1d4-349" | ||
| "uid": "5c7c-327" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-363": { | ||
| "5c7c-341": { | ||
| "id": "/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.node.development.js", | ||
@@ -544,12 +541,12 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-360" | ||
| "uid": "5c7c-338" | ||
| }, | ||
| { | ||
| "uid": "e1d4-370" | ||
| "uid": "5c7c-348" | ||
| }, | ||
| { | ||
| "uid": "e1d4-366" | ||
| "uid": "5c7c-344" | ||
| }, | ||
| { | ||
| "uid": "e1d4-368" | ||
| "uid": "5c7c-346" | ||
| } | ||
@@ -559,7 +556,7 @@ ], | ||
| { | ||
| "uid": "e1d4-349" | ||
| "uid": "5c7c-327" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-364": { | ||
| "5c7c-342": { | ||
| "id": "use-sync-external-store/shim/with-selector", | ||
@@ -570,3 +567,3 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-333" | ||
| "uid": "5c7c-311" | ||
| } | ||
@@ -576,4 +573,4 @@ ], | ||
| }, | ||
| "e1d4-365": { | ||
| "id": "/packages/store/build/esm/index.js", | ||
| "5c7c-343": { | ||
| "id": "/node_modules/.pnpm/@tanstack+store@0.0.1/node_modules/@tanstack/store/build/esm/index.js", | ||
| "moduleParts": {}, | ||
@@ -583,7 +580,10 @@ "imported": [], | ||
| { | ||
| "uid": "e1d4-333" | ||
| "uid": "5c7c-311" | ||
| }, | ||
| { | ||
| "uid": "5c7c-315" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-366": { | ||
| "5c7c-344": { | ||
| "id": "\u0000react?commonjs-external", | ||
@@ -593,3 +593,3 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-357" | ||
| "uid": "5c7c-335" | ||
| } | ||
@@ -599,16 +599,16 @@ ], | ||
| { | ||
| "uid": "e1d4-343" | ||
| "uid": "5c7c-321" | ||
| }, | ||
| { | ||
| "uid": "e1d4-347" | ||
| "uid": "5c7c-325" | ||
| }, | ||
| { | ||
| "uid": "e1d4-362" | ||
| "uid": "5c7c-340" | ||
| }, | ||
| { | ||
| "uid": "e1d4-363" | ||
| "uid": "5c7c-341" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-367": { | ||
| "5c7c-345": { | ||
| "id": "\u0000stream?commonjs-external", | ||
@@ -618,3 +618,3 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-358" | ||
| "uid": "5c7c-336" | ||
| } | ||
@@ -624,10 +624,10 @@ ], | ||
| { | ||
| "uid": "e1d4-343" | ||
| "uid": "5c7c-321" | ||
| }, | ||
| { | ||
| "uid": "e1d4-362" | ||
| "uid": "5c7c-340" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-368": { | ||
| "5c7c-346": { | ||
| "id": "\u0000util?commonjs-external", | ||
@@ -637,3 +637,3 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-371" | ||
| "uid": "5c7c-349" | ||
| } | ||
@@ -643,10 +643,10 @@ ], | ||
| { | ||
| "uid": "e1d4-347" | ||
| "uid": "5c7c-325" | ||
| }, | ||
| { | ||
| "uid": "e1d4-363" | ||
| "uid": "5c7c-341" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-369": { | ||
| "5c7c-347": { | ||
| "id": "\u0000/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js?commonjs-exports", | ||
@@ -657,7 +657,7 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-362" | ||
| "uid": "5c7c-340" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-370": { | ||
| "5c7c-348": { | ||
| "id": "\u0000/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server.node.development.js?commonjs-exports", | ||
@@ -668,7 +668,7 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-363" | ||
| "uid": "5c7c-341" | ||
| } | ||
| ] | ||
| }, | ||
| "e1d4-371": { | ||
| "5c7c-349": { | ||
| "id": "util", | ||
@@ -679,3 +679,3 @@ "moduleParts": {}, | ||
| { | ||
| "uid": "e1d4-368" | ||
| "uid": "5c7c-346" | ||
| } | ||
@@ -682,0 +682,0 @@ ], |
+4
-4
| { | ||
| "name": "@tanstack/react-start", | ||
| "author": "Tanner Linsley", | ||
| "version": "0.0.1-beta.174", | ||
| "version": "0.0.1-beta.175", | ||
| "license": "MIT", | ||
@@ -65,2 +65,3 @@ "repository": "tanstack/router", | ||
| "@tanstack/bling": "^0.0.3", | ||
| "@tanstack/store": "^0.0.1", | ||
| "isbot": "^3.6.6", | ||
@@ -70,5 +71,4 @@ "jsesc": "^3.0.2", | ||
| "tiny-warning": "^1.0.3", | ||
| "@tanstack/react-router": "0.0.1-beta.174", | ||
| "@tanstack/store": "0.0.1-beta.174", | ||
| "@tanstack/react-loaders": "0.0.1-beta.174" | ||
| "@tanstack/react-loaders": "0.0.1-beta.175", | ||
| "@tanstack/react-router": "0.0.1-beta.175" | ||
| }, | ||
@@ -75,0 +75,0 @@ "peerDependencies": { |
+0
-7
@@ -22,9 +22,2 @@ import type { APIContext } from 'astro' | ||
| // console.log(handlers) | ||
| // if (hasHandler(fullUrl.pathname)) { | ||
| // return await handleEvent({ | ||
| // request, | ||
| // }) | ||
| // } | ||
| if (fullUrl.pathname.includes('.')) { | ||
@@ -31,0 +24,0 @@ return new Response(null, { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2161345
0.09%14786
-0.16%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated