-
Notifications
You must be signed in to change notification settings - Fork 1k
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
26 changed files
with
584 additions
and
178 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
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,16 +1,22 @@ | ||
import type { TagDescriptor } from '@redwoodjs/web/dist/components/htmlTags' | ||
|
||
import { Document } from './Document' | ||
import Routes from './Routes' | ||
|
||
interface Props { | ||
css: string[] | ||
meta?: TagDescriptor[] | ||
location: { | ||
pathname: string | ||
hash?: string | ||
search?: string | ||
} | ||
} | ||
|
||
export const ServerEntry: React.FC<Props> = ({ css, meta }) => { | ||
export const ServerEntry: React.FC<Props> = ({ css, meta, location }) => { | ||
return ( | ||
<Document css={css} meta={meta}> | ||
<div>App</div> | ||
<Routes location={location} /> | ||
</Document> | ||
) | ||
} |
6 changes: 5 additions & 1 deletion
6
__fixtures__/test-project-rsa/web/src/layouts/NavigationLayout/NavigationLayout.tsx
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
85 changes: 0 additions & 85 deletions
85
__fixtures__/test-project-rsc-kitchen-sink/web/src/ServerRoutes.tsx
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
44 changes: 44 additions & 0 deletions
44
...est-project-rsc-kitchen-sink/web/src/components/ReadFileServerCell/ReadFileServerCell.tsx
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import fs from 'node:fs' | ||
import path from 'node:path' | ||
import { fileURLToPath } from 'node:url' | ||
|
||
import type { CellSuccessProps, CellFailureProps } from '@redwoodjs/web' | ||
|
||
export const data = async () => { | ||
const srcPath = path.join( | ||
path.dirname(fileURLToPath(import.meta.url)), | ||
'..', | ||
'..', | ||
'..', | ||
'src', | ||
'components', | ||
'ReadFileServerCell', | ||
'ReadFileServerCell.tsx' | ||
) | ||
|
||
const file = fs.readFileSync(srcPath, 'utf-8') | ||
|
||
return { file } | ||
} | ||
|
||
export const Loading = () => <div>Reading file...</div> | ||
|
||
export const Empty = () => <div>Empty file</div> | ||
|
||
export const Failure = ({ error }: CellFailureProps) => ( | ||
<div className="rw-cell-error">{error?.message}</div> | ||
) | ||
|
||
type SuccessProps = CellSuccessProps<Awaited<ReturnType<typeof data>>> | ||
export const Success = ({ file }: SuccessProps) => { | ||
return ( | ||
<div className="read-file-server-cell"> | ||
<p>The source of this server cell:</p> | ||
<pre | ||
style={{ border: '1px solid gray', margin: '1em', background: '#ddd' }} | ||
> | ||
<code>{file}</code> | ||
</pre> | ||
</div> | ||
) | ||
} |
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 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
6 changes: 5 additions & 1 deletion
6
packages/cli/src/commands/experimental/templates/rsc/NavigationLayout.tsx.template
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
35 changes: 35 additions & 0 deletions
35
packages/cli/src/commands/experimental/templates/rsc/entry.client.tsx.template
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { hydrateRoot, createRoot } from 'react-dom/client' | ||
|
||
import App from './App' | ||
import Routes from './Routes' | ||
|
||
/** | ||
* When `#redwood-app` isn't empty then it's very likely that you're using | ||
* pre-rendering. So React attaches event listeners to the existing markup | ||
* rather than replacing it. | ||
* https://react.dev/reference/react-dom/client/hydrateRoot | ||
*/ | ||
const redwoodAppElement = document.getElementById('redwood-app') | ||
|
||
if (!redwoodAppElement) { | ||
throw new Error( | ||
"Could not find an element with ID 'redwood-app'. Please ensure it " + | ||
"exists in your 'web/src/index.html' file." | ||
) | ||
} | ||
|
||
if (redwoodAppElement.children?.length > 0) { | ||
hydrateRoot( | ||
redwoodAppElement, | ||
<App> | ||
<Routes /> | ||
</App> | ||
) | ||
} else { | ||
const root = createRoot(redwoodAppElement) | ||
root.render( | ||
<App> | ||
<Routes /> | ||
</App> | ||
) | ||
} |
Oops, something went wrong.