Skip to content
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

breaking: multiple elements in a single response #124

Merged
merged 38 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b6480c3
wip: examples 01 dev
dai-shi Sep 1, 2023
70ffa5a
hack with _ssr, not ideal though
dai-shi Sep 2, 2023
071fc25
examples 02
dai-shi Sep 2, 2023
78a29ad
simplify waku/client usage
dai-shi Sep 2, 2023
3dba373
example 03
dai-shi Sep 3, 2023
151d761
example 04
dai-shi Sep 3, 2023
0a19471
improve example 04
dai-shi Sep 3, 2023
9bae9c4
examples 05
dai-shi Sep 3, 2023
718ca38
example 06
dai-shi Sep 3, 2023
200e0c0
fix example 06
dai-shi Sep 3, 2023
c2cbb7c
support children
dai-shi Sep 3, 2023
2e655e6
wip: waku/router, which is tough one
dai-shi Sep 8, 2023
b91205e
rename from Server to Slot
dai-shi Sep 8, 2023
66c5501
wip: fix router
dai-shi Sep 8, 2023
c9c2f9e
refactor consistent names
dai-shi Sep 8, 2023
0fc4473
wip: fix router
dai-shi Sep 8, 2023
41a7aa1
add react hooks eslint plugin
dai-shi Sep 8, 2023
48293ac
improve prefetched
dai-shi Sep 8, 2023
b93e01a
fix example 08
dai-shi Sep 9, 2023
b7f9247
fix example 09
dai-shi Sep 9, 2023
41e7eeb
fix test
dai-shi Sep 9, 2023
365a700
wip: ssr config
dai-shi Sep 9, 2023
485a17f
fix ex 06
dai-shi Sep 9, 2023
4330e02
fix waku/router
dai-shi Sep 9, 2023
9e7f6e4
wip: website
dai-shi Sep 9, 2023
4e20861
fix interleaveHtmlSnippets
dai-shi Sep 9, 2023
9a8d27a
remove unstable_rootDir
dai-shi Sep 9, 2023
939e887
fix router build
dai-shi Sep 10, 2023
02d3b5b
fix explicit index path (suboptimal?)
dai-shi Sep 10, 2023
af24113
this should be a proper fix
dai-shi Sep 10, 2023
80d82ed
website: use path prop #84
dai-shi Sep 10, 2023
986ae26
fix action and improve example/06
dai-shi Sep 10, 2023
a77e290
re-design router input string and allow client cache control
dai-shi Sep 11, 2023
91f7e10
update website
dai-shi Sep 11, 2023
ad89ead
make initialInput prop optional
dai-shi Sep 11, 2023
22fb587
use "" for initial input for simplicity
dai-shi Sep 11, 2023
1d2d27f
fix and a workaround for empty input string, seems suboptimal..
dai-shi Sep 11, 2023
bec7d16
Merge branch 'main' into feat/rscs-in-a-response
dai-shi Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
Expand Down
2 changes: 1 addition & 1 deletion examples/01_counter/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Counter } from "./Counter.js";

const App = ({ name = "Anonymous" }) => {
const App = ({ name }: { name: string }) => {
return (
<div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
<h1>Hello {name}!!</h1>
Expand Down
30 changes: 0 additions & 30 deletions examples/01_counter/src/entries.ts

This file was deleted.

34 changes: 34 additions & 0 deletions examples/01_counter/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { lazy } from "react";

import { defineEntries } from "waku/server";

const App = lazy(() => import("./components/App.js"));

export default defineEntries(
// renderEntries
async (input) => {
return {
App: <App name={input || "Waku"} />,
};
},
// getBuildConfig
async () => {
return {
"/": {
entries: [[""]],
},
};
},
// getSsrConfig
async () => ({
getInput: (pathStr) => {
switch (pathStr) {
case "/":
return "";
default:
return null;
}
},
filter: (elements) => elements.App,
}),
);
7 changes: 4 additions & 3 deletions examples/01_counter/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { serve } from "waku/client";
import { Root, Slot } from "waku/client";

const App = serve<{ name: string }>("App");
const rootElement = (
<StrictMode>
<App name="Waku" />
<Root>
<Slot id="App" />
</Root>
</StrictMode>
);

Expand Down
2 changes: 1 addition & 1 deletion examples/02_async/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Suspense } from "react";

import { Counter } from "./Counter.js";

const App = ({ name = "Anonymous" }) => {
const App = ({ name }: { name: string }) => {
return (
<div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
<h1>Hello {name}!!</h1>
Expand Down
30 changes: 0 additions & 30 deletions examples/02_async/src/entries.ts

This file was deleted.

34 changes: 34 additions & 0 deletions examples/02_async/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { lazy } from "react";

import { defineEntries } from "waku/server";

const App = lazy(() => import("./components/App.js"));

export default defineEntries(
// renderEntries
async (input) => {
return {
App: <App name={input || "Waku"} />,
};
},
// getBuildConfig
async () => {
return {
"/": {
entries: [[""]],
},
};
},
// getSsrConfig
async () => ({
getInput: (pathStr) => {
switch (pathStr) {
case "/":
return "";
default:
return null;
}
},
filter: (elements) => elements.App,
}),
);
7 changes: 4 additions & 3 deletions examples/02_async/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";
import { serve } from "waku/client";
import { Root, Slot } from "waku/client";

const App = serve<{ name: string }>("App");
const rootElement = (
<StrictMode>
<App name="Waku" />
<Root>
<Slot id="App" />
</Root>
</StrictMode>
);

Expand Down
4 changes: 3 additions & 1 deletion examples/03_promise/src/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { ReactNode } from "react";
import { Counter } from "./Counter.js";

const App = ({ name = "Anonymous" }) => {
const App = ({ name, children }: { name: string; children: ReactNode }) => {
const delayedMessage = new Promise<string>((resolve) => {
setTimeout(() => resolve("Hello from server!"), 2000);
});
Expand All @@ -9,6 +10,7 @@ const App = ({ name = "Anonymous" }) => {
<h1>Hello {name}!!</h1>
<h3>This is a server component.</h3>
<Counter delayedMessage={delayedMessage} />
{children}
</div>
);
};
Expand Down
30 changes: 0 additions & 30 deletions examples/03_promise/src/entries.ts

This file was deleted.

39 changes: 39 additions & 0 deletions examples/03_promise/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { lazy } from "react";

import { defineEntries } from "waku/server";
import { Children } from "waku/client";

const App = lazy(() => import("./components/App.js"));

export default defineEntries(
// renderEntries
async (input) => {
return {
App: (
<App name={input || "Waku"}>
<Children />
</App>
),
};
},
// getBuildConfig
async () => {
return {
"/": {
entries: [[""]],
},
};
},
// getSsrConfig
async () => ({
getInput: (pathStr) => {
switch (pathStr) {
case "/":
return "";
default:
return null;
}
},
filter: (elements) => elements.App,
}),
);
9 changes: 6 additions & 3 deletions examples/03_promise/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { serve } from "waku/client";
import { Root, Slot } from "waku/client";

const App = serve<{ name: string }>("App");
const rootElement = (
<StrictMode>
<App name="Waku" />
<Root>
<Slot id="App">
<h3>A client element</h3>
</Slot>
</Root>
</StrictMode>
);

Expand Down
2 changes: 1 addition & 1 deletion examples/04_callserver/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type ServerFunction<T> = T extends (...args: infer A) => infer R
? (...args: A) => Promise<R>
: never;

const App = ({ name = "Anonymous" }) => {
const App = ({ name }: { name: string }) => {
return (
<div style={{ border: "3px red dashed", margin: "1em", padding: "1em" }}>
<h1>Hello {name}!!</h1>
Expand Down
2 changes: 1 addition & 1 deletion examples/04_callserver/src/components/Counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useState, useTransition } from "react";
export const Counter = ({
greet,
}: {
greet: (name: string) => string | Promise<string>;
greet: (name: string) => Promise<string>;
}) => {
const [count, setCount] = useState(0);
const [text, setText] = useState<string | Promise<string>>("");
Expand Down
30 changes: 0 additions & 30 deletions examples/04_callserver/src/entries.ts

This file was deleted.

34 changes: 34 additions & 0 deletions examples/04_callserver/src/entries.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { lazy } from "react";

import { defineEntries } from "waku/server";

const App = lazy(() => import("./components/App.js"));

export default defineEntries(
// renderEntries
async (input) => {
return {
App: <App name={input || "Waku"} />,
};
},
// getBuildConfig
async () => {
return {
"/": {
entries: [[""]],
},
};
},
// getSsrConfig
async () => ({
getInput: (pathStr) => {
switch (pathStr) {
case "/":
return "";
default:
return null;
}
},
filter: (elements) => elements.App,
}),
);
7 changes: 4 additions & 3 deletions examples/04_callserver/src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { serve } from "waku/client";
import { Root, Slot } from "waku/client";

const App = serve<{ name: string }>("App");
const rootElement = (
<StrictMode>
<App name="Waku" />
<Root>
<Slot id="App" />
</Root>
</StrictMode>
);

Expand Down
Loading
Loading