-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
679 additions
and
444 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ todo.md | |
# cloudflare | ||
.wrangler/ | ||
functions/ | ||
|
||
# Sentry Config File | ||
.sentryclirc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
import { RemixBrowser } from '@remix-run/react' | ||
import { StrictMode, startTransition } from 'react' | ||
import { hydrateRoot } from 'react-dom/client' | ||
|
||
function hydrate() { | ||
startTransition(() => { | ||
hydrateRoot( | ||
// biome-ignore lint/style/noNonNullAssertion: from remix-island | ||
document.getElementById('root')!, | ||
<StrictMode> | ||
<RemixBrowser /> | ||
</StrictMode> | ||
) | ||
}) | ||
} | ||
|
||
if (typeof requestIdleCallback === 'function') { | ||
requestIdleCallback(hydrate) | ||
} else { | ||
// Safari doesn't support requestIdleCallback | ||
// https://caniuse.com/requestidlecallback | ||
setTimeout(hydrate, 1) | ||
} | ||
import * as Sentry from "@sentry/remix"; | ||
import { RemixBrowser, useLocation, useMatches } from '@remix-run/react'; | ||
import { StrictMode, startTransition, useEffect } from 'react'; | ||
import { hydrateRoot } from 'react-dom/client' | ||
|
||
Sentry.init({ | ||
dsn: "https://0158c725913324618a2d2e625ffb9fde@o4506276018192384.ingest.sentry.io/4506276020092928", | ||
tracesSampleRate: 1, | ||
replaysSessionSampleRate: 0.1, | ||
replaysOnErrorSampleRate: 1, | ||
|
||
integrations: [new Sentry.BrowserTracing({ | ||
routingInstrumentation: Sentry.remixRouterInstrumentation(useEffect, useLocation, useMatches) | ||
}), new Sentry.Replay()] | ||
}) | ||
|
||
function hydrate() { | ||
startTransition(() => { | ||
hydrateRoot( | ||
// biome-ignore lint/style/noNonNullAssertion: from remix-island | ||
document.getElementById('root')!, | ||
<StrictMode> | ||
<RemixBrowser /> | ||
</StrictMode> | ||
) | ||
}) | ||
} | ||
|
||
if (typeof requestIdleCallback === 'function') { | ||
requestIdleCallback(hydrate) | ||
} else { | ||
// Safari doesn't support requestIdleCallback | ||
// https://caniuse.com/requestidlecallback | ||
setTimeout(hydrate, 1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,77 @@ | ||
import type { EntryContext } from '@remix-run/cloudflare' | ||
import { RemixServer } from '@remix-run/react' | ||
import { renderHeadToString } from 'remix-island' | ||
import { Head } from './root' | ||
|
||
import { renderToReadableStream } from 'react-dom/server' | ||
|
||
export default function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext | ||
) { | ||
return handleBrowserRequest( | ||
request, | ||
responseStatusCode, | ||
responseHeaders, | ||
remixContext | ||
) | ||
} | ||
|
||
async function handleBrowserRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext | ||
) { | ||
const didError = false | ||
const readable = await renderToReadableStream( | ||
<RemixServer context={remixContext} url={request.url} /> | ||
) | ||
|
||
responseHeaders.set('Content-Type', 'text/html') | ||
const stream = new ReadableStream({ | ||
start(controller) { | ||
// Add the HTML head to the response | ||
const head = renderHeadToString({ request, remixContext, Head }) | ||
controller.enqueue( | ||
new Uint8Array( | ||
new TextEncoder().encode( | ||
`<!DOCTYPE html><html><head>${head}</head><body><div id="root">` | ||
) | ||
) | ||
) | ||
|
||
const reader = readable.getReader() | ||
function read() { | ||
reader | ||
.read() | ||
.then(({ done, value }) => { | ||
if (done) { | ||
controller.enqueue( | ||
new Uint8Array(new TextEncoder().encode('</div></body></html>')) | ||
) | ||
controller.close() | ||
return | ||
} | ||
controller.enqueue(value) | ||
read() | ||
}) | ||
.catch(error => { | ||
controller.error(error) | ||
readable.cancel() | ||
}) | ||
} | ||
read() | ||
}, | ||
cancel() { | ||
readable.cancel() | ||
} | ||
}) | ||
|
||
return new Response(stream, { | ||
headers: responseHeaders, | ||
status: didError ? 500 : responseStatusCode | ||
}) | ||
} | ||
import { type EntryContext } from '@remix-run/cloudflare' | ||
import { RemixServer } from '@remix-run/react' | ||
import { renderHeadToString } from 'remix-island' | ||
import { Head } from './root' | ||
|
||
import { renderToReadableStream } from 'react-dom/server' | ||
|
||
export default function handleRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext | ||
) { | ||
return handleBrowserRequest( | ||
request, | ||
responseStatusCode, | ||
responseHeaders, | ||
remixContext | ||
) | ||
} | ||
|
||
async function handleBrowserRequest( | ||
request: Request, | ||
responseStatusCode: number, | ||
responseHeaders: Headers, | ||
remixContext: EntryContext | ||
) { | ||
const didError = false | ||
const readable = await renderToReadableStream( | ||
<RemixServer context={remixContext} url={request.url} /> | ||
) | ||
|
||
responseHeaders.set('Content-Type', 'text/html') | ||
const stream = new ReadableStream({ | ||
start(controller) { | ||
// Add the HTML head to the response | ||
const head = renderHeadToString({ request, remixContext, Head }) | ||
controller.enqueue( | ||
new Uint8Array( | ||
new TextEncoder().encode( | ||
`<!DOCTYPE html><html><head>${head}</head><body><div id="root">` | ||
) | ||
) | ||
) | ||
|
||
const reader = readable.getReader() | ||
function read() { | ||
reader | ||
.read() | ||
.then(({ done, value }) => { | ||
if (done) { | ||
controller.enqueue( | ||
new Uint8Array(new TextEncoder().encode('</div></body></html>')) | ||
) | ||
controller.close() | ||
return | ||
} | ||
controller.enqueue(value) | ||
read() | ||
}) | ||
.catch(error => { | ||
controller.error(error) | ||
readable.cancel() | ||
}) | ||
} | ||
read() | ||
}, | ||
cancel() { | ||
readable.cancel() | ||
} | ||
}) | ||
|
||
return new Response(stream, { | ||
headers: responseHeaders, | ||
status: didError ? 500 : responseStatusCode | ||
}) | ||
} |
Oops, something went wrong.