-
Notifications
You must be signed in to change notification settings - Fork 78
Add a remote-dom to remote-ui adapter #511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 23 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
10208cf
Initial legacy adaptors
lemonmade e9f0c8e
Cleanup and documentation
lemonmade 1e3cac1
Add remote root adaptor
lemonmade 51bd6b5
Add fragment support
igor10k 6216542
Add remote-ui example
robin-drexler 3d33cd7
E2E tests for legacy adapter
igor10k 026fd14
changeset
lemonmade 4f22007
Delete legacy/remote
igor10k b83a127
remove unused file
robin-drexler 7cf9442
adjust remote ui example title
robin-drexler 9eced78
remove unused wait-on dep
robin-drexler 13efd1c
remove superfluous ts references
robin-drexler 27d47ba
Update packages/core/README.md
igor10k 2f93969
move remote-ui example into kitchen sink
robin-drexler 8933a30
Update changeset copy
igor10k 7f9689a
Change the order of functions
igor10k 41a30eb
Switch tree to Map
igor10k d771f15
Get rid of negation in conditions
igor10k 656152e
Lift out "update props" variables
igor10k 53c1b2e
Add slotWrapper
igor10k 19f7240
Update packages/core/source/legacy/host.ts
igor10k 410ad7c
slotWrapper -> slotProps.wrapper
igor10k 587f994
Add first set of tests
simontaisne 4a2ab2e
Update tests
simontaisne 9e4f271
Fix test imports
simontaisne 56eab19
Add additional tests
simontaisne c409934
Extract adapter into a separate package
igor10k 28c82ad
Use adapter component mapping
igor10k 2b839d0
ensure files are imported from source
robin-drexler 0e2ab31
renderRemoteUi -> renderLegacy
igor10k d1ad8d4
Merge imports
igor10k df77bf3
compat v0.1.0
igor10k File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,11 @@ | ||
| --- | ||
| '@remote-dom/core': minor | ||
| '@remote-dom/polyfill': minor | ||
| '@remote-dom/preact': minor | ||
| '@remote-dom/react': minor | ||
| '@remote-dom/signals': minor | ||
| --- | ||
|
|
||
| Add a `adaptToLegacyRemoteChannel` helper that adapts a Remote DOM `RemoteConnection` object into a `remote-ui` `RemoteChannel`. | ||
|
|
||
| It allows to use a Remote DOM receiver class on the host, even if the remote environment is using `remote-ui`. |
This file contains hidden or 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 hidden or 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 hidden or 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
96 changes: 96 additions & 0 deletions
96
examples/kitchen-sink/app/remote/examples/react-remote-ui.tsx
This file contains hidden or 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,96 @@ | ||
| /** @jsxRuntime automatic */ | ||
| /** @jsxImportSource react */ | ||
| import {retain} from '@quilted/threads'; | ||
|
|
||
| import {createRemoteReactComponent} from '@remote-ui/react'; | ||
| import { | ||
| ButtonProperties, | ||
| ModalProperties, | ||
| RenderAPI, | ||
| StackProperties, | ||
| TextProperties, | ||
| } from '../../types'; | ||
| import {useState} from 'react'; | ||
| import {createRoot, createRemoteRoot} from '@remote-ui/react'; | ||
| import {RemoteChannel} from '@remote-ui/core'; | ||
|
|
||
| const Button = createRemoteReactComponent< | ||
| 'Button', | ||
| ButtonProperties & {modal?: React.ReactNode} | ||
| >('Button', {fragmentProps: ['modal']}); | ||
|
|
||
| const Text = createRemoteReactComponent<'Text', TextProperties>('Text'); | ||
| const Stack = createRemoteReactComponent<'Stack', StackProperties>('Stack'); | ||
| const Modal = createRemoteReactComponent< | ||
| 'Modal', | ||
| ModalProperties & {primaryAction?: React.ReactNode} | ||
| >('Modal', {fragmentProps: ['primaryAction']}); | ||
|
|
||
| export function renderUsingReactRemoteUI( | ||
| channel: RemoteChannel, | ||
| api: RenderAPI, | ||
| ) { | ||
| retain(api); | ||
| retain(channel); | ||
|
|
||
| const remoteRoot = createRemoteRoot(channel, { | ||
| components: ['Button', 'Text', 'Stack', 'Modal'], | ||
| }); | ||
|
|
||
| createRoot(remoteRoot).render(<App api={api} />); | ||
| remoteRoot.mount(); | ||
| } | ||
|
|
||
| function App({api}: {api: RenderAPI}) { | ||
| return ( | ||
| <Stack spacing> | ||
| <Text> | ||
| Rendering example: <Text emphasis>{api.example}</Text> | ||
| </Text> | ||
| <Text> | ||
| Rendering in sandbox: <Text emphasis>{api.sandbox}</Text> | ||
| </Text> | ||
| <Button modal={<CountModal {...api} />}>Open modal</Button> | ||
| </Stack> | ||
| ); | ||
| } | ||
|
|
||
| function CountModal({alert, closeModal}: RenderAPI) { | ||
| const [count, setCount] = useState(0); | ||
|
|
||
| const primaryAction = ( | ||
| <Button | ||
| onPress={() => { | ||
| closeModal(); | ||
| }} | ||
| > | ||
| Close | ||
| </Button> | ||
| ); | ||
|
|
||
| return ( | ||
| <Modal | ||
| primaryAction={primaryAction} | ||
| onClose={() => { | ||
| if (count > 0) { | ||
| alert(`You clicked ${count} times!`); | ||
| } | ||
|
|
||
| setCount(0); | ||
| }} | ||
| > | ||
| <Stack spacing> | ||
| <Text> | ||
| Click count: <Text emphasis>{count}</Text> | ||
| </Text> | ||
| <Button | ||
| onPress={() => { | ||
| setCount((count) => count + 1); | ||
| }} | ||
| > | ||
| Click me! | ||
| </Button> | ||
| </Stack> | ||
| </Modal> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.