From f787f2b6d6bea386929db180574e60c321173824 Mon Sep 17 00:00:00 2001 From: Ryan Carniato Date: Fri, 9 Feb 2024 11:49:04 -0800 Subject: [PATCH] update router --- .changeset/heavy-zoos-help.md | 5 ++ docs/routes/advanced/session.md | 2 +- docs/routes/core-concepts/data-loading.mdx | 4 +- examples/basic/package.json | 2 +- examples/experiments/package.json | 2 +- examples/hackernews/package.json | 2 +- examples/notes/package.json | 2 +- examples/notes/src/components/NoteList.tsx | 2 +- examples/notes/src/lib/util.ts | 16 ------ examples/todomvc/package.json | 2 +- examples/todomvc/src/routes/index.tsx | 4 +- examples/with-auth/package.json | 2 +- examples/with-auth/src/routes/index.tsx | 2 +- examples/with-mdx/package.json | 2 +- examples/with-prisma/package.json | 2 +- examples/with-prisma/src/routes/index.tsx | 2 +- examples/with-solid-styled/package.json | 2 +- examples/with-tailwindcss/package.json | 2 +- examples/with-trpc/package.json | 2 +- examples/with-unocss/package.json | 2 +- examples/with-vitest/package.json | 2 +- package.json | 2 +- pnpm-lock.yaml | 66 +++++++++++----------- 23 files changed, 60 insertions(+), 71 deletions(-) create mode 100644 .changeset/heavy-zoos-help.md delete mode 100644 examples/notes/src/lib/util.ts diff --git a/.changeset/heavy-zoos-help.md b/.changeset/heavy-zoos-help.md new file mode 100644 index 000000000..b33174ad1 --- /dev/null +++ b/.changeset/heavy-zoos-help.md @@ -0,0 +1,5 @@ +--- +"@solidjs/start": patch +--- + +update router diff --git a/docs/routes/advanced/session.md b/docs/routes/advanced/session.md index 27d0843f6..98152c1d3 100644 --- a/docs/routes/advanced/session.md +++ b/docs/routes/advanced/session.md @@ -66,7 +66,7 @@ const getStudents = cache(async (house: string) => { // page component export default function Students() { - const students = createAsync(getStudents); + const students = createAsync(() => getStudents()); } ``` diff --git a/docs/routes/core-concepts/data-loading.mdx b/docs/routes/core-concepts/data-loading.mdx index fbd394825..62fab41ce 100644 --- a/docs/routes/core-concepts/data-loading.mdx +++ b/docs/routes/core-concepts/data-loading.mdx @@ -48,7 +48,7 @@ export const route = { }; export default function Page() { - const students = createAsync(getStudents); + const students = createAsync(() => getStudents()); return ; } @@ -91,7 +91,7 @@ export const route = { }; export default function Page() { - const students = createAsync(getStudents); + const students = createAsync(() => getStudents()); return ; } diff --git a/examples/basic/package.json b/examples/basic/package.json index 2ecabbc49..7cbbbc097 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "@solidjs/meta": "^0.29.2", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "solid-js": "^1.8.14", "vinxi": "^0.2.1" diff --git a/examples/experiments/package.json b/examples/experiments/package.json index 3f798c0f5..94e45de33 100644 --- a/examples/experiments/package.json +++ b/examples/experiments/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "@solidjs/meta": "^0.29.2", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "solid-js": "^1.8.14", "vinxi": "^0.2.1" diff --git a/examples/hackernews/package.json b/examples/hackernews/package.json index 8c762c6a1..3622d1adb 100644 --- a/examples/hackernews/package.json +++ b/examples/hackernews/package.json @@ -7,7 +7,7 @@ "start": "vinxi start" }, "dependencies": { - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "solid-js": "^1.8.14", "vinxi": "^0.2.1" diff --git a/examples/notes/package.json b/examples/notes/package.json index c86c3d21a..7cad225d0 100644 --- a/examples/notes/package.json +++ b/examples/notes/package.json @@ -7,7 +7,7 @@ "start": "vinxi start" }, "dependencies": { - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.2", "@types/marked": "^4.3.1", "date-fns": "^2.30.0", diff --git a/examples/notes/src/components/NoteList.tsx b/examples/notes/src/components/NoteList.tsx index c35e9fde7..3e981e85e 100644 --- a/examples/notes/src/components/NoteList.tsx +++ b/examples/notes/src/components/NoteList.tsx @@ -1,6 +1,6 @@ +import { createAsyncStore } from "@solidjs/router"; import { For, Show } from "solid-js"; import { getNotes } from "~/lib/api"; -import { createAsyncStore } from "~/lib/util"; import SidebarNote from "./SidebarNote"; export default function NoteList(props: { searchText: string }) { diff --git a/examples/notes/src/lib/util.ts b/examples/notes/src/lib/util.ts deleted file mode 100644 index 02f4a58ad..000000000 --- a/examples/notes/src/lib/util.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { createAsync } from "@solidjs/router"; -import { createMemo } from "solid-js"; -import { createStore, reconcile, unwrap } from "solid-js/store"; - -export function createAsyncStore(source: () => Promise) { - const resource = createAsync(source) - return createMemo((prev) => { - const next = resource(); - if (prev) reconcile(next)(unwrap(prev)); - else { - const [store] = createStore(next); - prev = store; - }; - return prev as T; - }) -} \ No newline at end of file diff --git a/examples/todomvc/package.json b/examples/todomvc/package.json index 746ca03cf..aa948dc51 100644 --- a/examples/todomvc/package.json +++ b/examples/todomvc/package.json @@ -7,7 +7,7 @@ "start": "vinxi start" }, "dependencies": { - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "solid-js": "^1.8.14", "unstorage": "1.10.1", diff --git a/examples/todomvc/src/routes/index.tsx b/examples/todomvc/src/routes/index.tsx index e427533e6..c18519a7b 100644 --- a/examples/todomvc/src/routes/index.tsx +++ b/examples/todomvc/src/routes/index.tsx @@ -1,6 +1,6 @@ import { RouteDefinition, - createAsync, + createAsyncStore, useSubmission, useSubmissions, type RouteSectionProps @@ -34,7 +34,7 @@ export const route = { } satisfies RouteDefinition; export default function TodoApp(props: RouteSectionProps) { - const todos = createAsync(getTodos, { initialValue: [], deferStream: true }); + const todos = createAsyncStore(() => getTodos(), { initialValue: [], deferStream: true }); const location = props.location; const addingTodo = useSubmissions(addTodo); diff --git a/examples/with-auth/package.json b/examples/with-auth/package.json index 82d6088ef..b495e42f7 100644 --- a/examples/with-auth/package.json +++ b/examples/with-auth/package.json @@ -10,7 +10,7 @@ "@types/node": "^20.10.1" }, "dependencies": { - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "solid-js": "^1.8.14", "unstorage": "1.10.1", diff --git a/examples/with-auth/src/routes/index.tsx b/examples/with-auth/src/routes/index.tsx index 2f560dd71..788f739c9 100644 --- a/examples/with-auth/src/routes/index.tsx +++ b/examples/with-auth/src/routes/index.tsx @@ -6,7 +6,7 @@ export const route = { } satisfies RouteDefinition; export default function Home() { - const user = createAsync(getUser, { deferStream: true }); + const user = createAsync(() => getUser(), { deferStream: true }); return (

Hello {user()?.username}

diff --git a/examples/with-mdx/package.json b/examples/with-mdx/package.json index 59e29eddf..ba0e5de59 100644 --- a/examples/with-mdx/package.json +++ b/examples/with-mdx/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "@mdx-js/mdx": "^2.3.0", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "@vinxi/plugin-mdx": "^3.6.7", "solid-js": "^1.8.14", diff --git a/examples/with-prisma/package.json b/examples/with-prisma/package.json index a3e2ea54b..46b08f5a0 100644 --- a/examples/with-prisma/package.json +++ b/examples/with-prisma/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@prisma/client": "^5.7.0", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "prisma": "^5.7.0", "solid-js": "^1.8.14", diff --git a/examples/with-prisma/src/routes/index.tsx b/examples/with-prisma/src/routes/index.tsx index 8f4d1b6f9..cbaf33dcc 100644 --- a/examples/with-prisma/src/routes/index.tsx +++ b/examples/with-prisma/src/routes/index.tsx @@ -6,7 +6,7 @@ export const route = { } satisfies RouteDefinition; export default function Home() { - const user = createAsync(getUser, { deferStream: true }); + const user = createAsync(() => getUser(), { deferStream: true }); return (

Hello {user()?.username}

diff --git a/examples/with-solid-styled/package.json b/examples/with-solid-styled/package.json index 423c779e0..6dce5bfb7 100644 --- a/examples/with-solid-styled/package.json +++ b/examples/with-solid-styled/package.json @@ -8,7 +8,7 @@ }, "dependencies": { "@solidjs/meta": "^0.29.2", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "solid-js": "^1.8.14", "solid-styled": "^0.8.2", diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index b4280b8a4..938520fed 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -7,7 +7,7 @@ "start": "vinxi start" }, "dependencies": { - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "autoprefixer": "^10.4.14", "postcss": "^8.4.26", diff --git a/examples/with-trpc/package.json b/examples/with-trpc/package.json index 3ee3bcbf6..e762e22b4 100644 --- a/examples/with-trpc/package.json +++ b/examples/with-trpc/package.json @@ -11,7 +11,7 @@ "@trpc/client": "^10.44.1", "@trpc/server": "^10.44.1", "@solidjs/meta": "^0.29.2", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "solid-js": "^1.8.14", "valibot": "^0.23.0", diff --git a/examples/with-unocss/package.json b/examples/with-unocss/package.json index c7606dbef..9abacc35b 100644 --- a/examples/with-unocss/package.json +++ b/examples/with-unocss/package.json @@ -7,7 +7,7 @@ "start": "vinxi start" }, "dependencies": { - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "@unocss/reset": "^0.58.3", "solid-js": "^1.8.14", diff --git a/examples/with-vitest/package.json b/examples/with-vitest/package.json index 3387c16ec..2aa6c401f 100644 --- a/examples/with-vitest/package.json +++ b/examples/with-vitest/package.json @@ -12,7 +12,7 @@ "type": "module", "devDependencies": { "@solidjs/meta": "^0.29.3", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "^0.5.4", "@solidjs/testing-library": "^0.8.5", "@testing-library/jest-dom": "^6.1.5", diff --git a/package.json b/package.json index a658a962c..5f18c2387 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@cloudflare/kv-asset-handler": "^0.2.0", "@decs/typeschema": "^0.12.1", "@solidjs/meta": "^0.29.0", - "@solidjs/router": "^0.11.5", + "@solidjs/router": "^0.12.0", "@solidjs/start": "workspace:*", "@tailwindcss/typography": "^0.5.9", "@trpc/client": "^9.27.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f9ccd2830..59a41e8dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,8 +28,8 @@ importers: specifier: ^0.29.0 version: 0.29.3(solid-js@1.8.14) '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: workspace:* version: link:packages/start @@ -112,8 +112,8 @@ importers: specifier: ^0.29.2 version: 0.29.3(solid-js@1.8.14) '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -130,8 +130,8 @@ importers: specifier: ^0.29.2 version: 0.29.3(solid-js@1.8.14) '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -145,8 +145,8 @@ importers: examples/hackernews: dependencies: '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -160,8 +160,8 @@ importers: examples/notes: dependencies: '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.2 version: link:../../packages/start @@ -187,8 +187,8 @@ importers: examples/todomvc: dependencies: '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -205,8 +205,8 @@ importers: examples/with-auth: dependencies: '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -230,8 +230,8 @@ importers: specifier: ^2.3.0 version: 2.3.0 '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -254,8 +254,8 @@ importers: specifier: ^5.7.0 version: 5.7.0(prisma@5.7.0) '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -279,8 +279,8 @@ importers: specifier: ^0.29.2 version: 0.29.3(solid-js@1.8.14) '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -300,8 +300,8 @@ importers: examples/with-tailwindcss: dependencies: '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -330,8 +330,8 @@ importers: specifier: ^0.29.2 version: 0.29.3(solid-js@1.8.14) '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -354,8 +354,8 @@ importers: examples/with-unocss: dependencies: '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start @@ -378,14 +378,14 @@ importers: specifier: ^0.29.3 version: 0.29.3(solid-js@1.8.14) '@solidjs/router': - specifier: ^0.11.5 - version: 0.11.5(solid-js@1.8.14) + specifier: ^0.12.0 + version: 0.12.0(solid-js@1.8.14) '@solidjs/start': specifier: ^0.5.4 version: link:../../packages/start '@solidjs/testing-library': specifier: ^0.8.5 - version: 0.8.5(@solidjs/router@0.11.5)(solid-js@1.8.14) + version: 0.8.5(@solidjs/router@0.12.0)(solid-js@1.8.14) '@testing-library/jest-dom': specifier: ^6.1.5 version: 6.1.5(vitest@1.2.1) @@ -2650,8 +2650,8 @@ packages: dependencies: solid-js: 1.8.14 - /@solidjs/router@0.11.5(solid-js@1.8.14): - resolution: {integrity: sha512-nclebUUufZT37rB5l0LbJn92vZwJOhYVltfjfLFI3yAcMlwiil5JOy6X2FEgekWsoX29No/GCBTkYfrSZCRfaw==} + /@solidjs/router@0.12.0(solid-js@1.8.14): + resolution: {integrity: sha512-9dyBL35T7x86RBSJBMu9jLGytBTmWQehb0uxez7TfzYtwI+v9poo2fzRbcCCrWVTQkwGD/rWvqmxUvczp2at3A==} peerDependencies: solid-js: ^1.8.6 dependencies: @@ -2664,14 +2664,14 @@ packages: dependencies: solid-js: 1.8.14 - /@solidjs/testing-library@0.8.5(@solidjs/router@0.11.5)(solid-js@1.8.14): + /@solidjs/testing-library@0.8.5(@solidjs/router@0.12.0)(solid-js@1.8.14): resolution: {integrity: sha512-L9TowCoqdRQGB8ikODh9uHXrYTjCUZseVUG0tIVa836//qeSqXP4m0BKG66v9Zp1y1wRxok5qUW97GwrtEBMcw==} engines: {node: '>= 14'} peerDependencies: '@solidjs/router': '>=0.6.0' solid-js: '>=1.0.0' dependencies: - '@solidjs/router': 0.11.5(solid-js@1.8.14) + '@solidjs/router': 0.12.0(solid-js@1.8.14) '@testing-library/dom': 9.3.4 solid-js: 1.8.14 dev: true