-
Notifications
You must be signed in to change notification settings - Fork 414
feat(2.0): server function inspector #2049
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
Open
lxsmnsyc
wants to merge
13
commits into
main
Choose a base branch
from
feat-server-function-inspector
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
79724e7
add seroval json mode
lxsmnsyc a5300d2
Fix client-server comms
lxsmnsyc 42a18a3
Update server-functions-handler.ts
lxsmnsyc e4a991c
Add server function inspector
lxsmnsyc 1b36316
Fix styling
lxsmnsyc d3af5d9
Fix new lines
lxsmnsyc f83ea00
Create HexViewer.tsx
lxsmnsyc 471d0b5
Add `FormDataViewer`
lxsmnsyc a2f7c4b
add the remaining viewers
lxsmnsyc 723b4f5
Add plugin and sequence renderer
lxsmnsyc 186e548
add more tests
lxsmnsyc 73e6e3d
final output
lxsmnsyc 78c44de
fix paths
lxsmnsyc 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,23 @@ | ||
| import { createEffect, createSignal } from "solid-js"; | ||
|
|
||
| async function ping(file: File) { | ||
| "use server"; | ||
| return await file.text(); | ||
| } | ||
|
|
||
| export default function App() { | ||
| const [output, setOutput] = createSignal<{ result?: boolean }>({}); | ||
|
|
||
| createEffect(async () => { | ||
| const file = new File(['Hello, World!'], 'hello-world.txt'); | ||
| const result = await ping(file); | ||
| const value = await file.text(); | ||
| setOutput(prev => ({ ...prev, result: value === result })); | ||
| }); | ||
|
|
||
| return ( | ||
| <main> | ||
| <span id="server-fn-test">{JSON.stringify(output())}</span> | ||
| </main> | ||
| ); | ||
| } |
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,35 @@ | ||
| import { createEffect, createSignal } from "solid-js"; | ||
|
|
||
| async function ping(value: Date) { | ||
| "use server"; | ||
|
|
||
| const current = [ | ||
| value, | ||
| { | ||
| name: 'example', | ||
| *[Symbol.iterator]() { | ||
| yield 'foo'; | ||
| yield 'bar'; | ||
| yield 'baz'; | ||
| } | ||
| } | ||
| ]; | ||
|
|
||
| return current; | ||
| } | ||
|
|
||
| export default function App() { | ||
| const [output, setOutput] = createSignal<{ result?: boolean }>({}); | ||
|
|
||
| createEffect(async () => { | ||
| const value = new Date(); | ||
| const result = await ping(value); | ||
| setOutput((prev) => ({ ...prev, result: value.toString() === result[0].toString() })); | ||
| }); | ||
|
|
||
| return ( | ||
| <main> | ||
| <span id="server-fn-test">{JSON.stringify(output())}</span> | ||
| </main> | ||
| ); | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| import { createEffect, createSignal } from "solid-js"; | ||
|
|
||
| async function sleep(value: unknown, ms: number) { | ||
| return new Promise((res) => { | ||
| setTimeout(res, ms, value); | ||
| }) | ||
| } | ||
|
|
||
| async function ping(value: URLSearchParams, clone: URLSearchParams) { | ||
| "use server"; | ||
|
|
||
| const current = [ | ||
| value.toString() === clone.toString(), | ||
| value, | ||
| clone, | ||
| ] as const; | ||
|
|
||
| return current; | ||
| } | ||
|
|
||
| export default function App() { | ||
| const [output, setOutput] = createSignal<{ result?: boolean }>({}); | ||
|
|
||
| createEffect(async () => { | ||
| const value = new URLSearchParams([ | ||
| ['foo', 'bar'], | ||
| ['hello', 'world'], | ||
| ]); | ||
| const result = await ping(value, value); | ||
| setOutput((prev) => ({ ...prev, result: result[0] })); | ||
| }); | ||
|
|
||
| return ( | ||
| <main> | ||
| <span id="server-fn-test">{JSON.stringify(output())}</span> | ||
| </main> | ||
| ); | ||
| } |
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,39 @@ | ||
| import { createEffect, createSignal } from "solid-js"; | ||
|
|
||
| async function sleep<T>(value: T, ms: number) { | ||
| return new Promise<T>((res) => { | ||
| setTimeout(res, ms, value); | ||
| }) | ||
| } | ||
|
|
||
| async function ping(value: ReadableStream<string>) { | ||
| "use server"; | ||
| return value; | ||
| } | ||
|
|
||
| export default function App() { | ||
| const [output, setOutput] = createSignal<{ result?: boolean }>({}); | ||
|
|
||
| createEffect(async () => { | ||
| const result = await ping( | ||
| new ReadableStream({ | ||
| async start(controller) { | ||
| controller.enqueue(await sleep('foo', 100)); | ||
| controller.enqueue(await sleep('bar', 100)); | ||
| controller.enqueue(await sleep('baz', 100)); | ||
| controller.close(); | ||
| }, | ||
| }) | ||
| ); | ||
|
|
||
| const reader = result.getReader(); | ||
| const first = await reader.read(); | ||
| setOutput((prev) => ({ ...prev, result: first.value === 'foo' })); | ||
| }); | ||
|
|
||
| return ( | ||
| <main> | ||
| <span id="server-fn-test">{JSON.stringify(output())}</span> | ||
| </main> | ||
| ); | ||
| } |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't have to stay but you want to watch the inspector track streams, then enjoy