-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: server and client init hook
#13103
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 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a86cffd
feat: server and client `init` hook
paoloricciuti 7950b9a
fix: provide client_hooks fallback even if universal hooks are present
paoloricciuti 10f4b84
chore: add tests
paoloricciuti 2a051d3
chore: cache server instance in `vite dev`
paoloricciuti 306d37f
chore: remove only (duh)
paoloricciuti 61aaf24
chore: revert single server in dev
paoloricciuti 7ba6cd3
chore: revert weird did_it_run thing
paoloricciuti 5cace24
chore: add additional inited check to prevent multiple init in case o…
paoloricciuti a7a7bb0
fix: remove `init` from client hooks
paoloricciuti c5f46c6
docs: write some documentation, use proper exported types
paoloricciuti 7e5e75e
chore: regenerate types
paoloricciuti feb3b7c
simplify
Rich-Harris c2adc54
chore: docs suggestions from review
paoloricciuti 4cd7488
try this
Rich-Harris 21f8a12
Merge branch 'init-hook' of github.com:paoloricciuti/kit into pr/13103
Rich-Harris 917d71b
chore: fix lint
paoloricciuti 43e2623
chore: fix types
paoloricciuti bacfbe7
save a couple bytes
Rich-Harris fc11907
Merge branch 'init-hook' of github.com:paoloricciuti/kit into pr/13103
Rich-Harris a9c85b0
Apply suggestions from code review
dummdidumm 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,5 @@ | ||
| --- | ||
| '@sveltejs/kit': minor | ||
| --- | ||
|
|
||
| feat: server and client `init` hook |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| declare module '__SERVER__/internal.js' { | ||
| export const options: import('types').SSROptions; | ||
| export const get_hooks: () => Promise<Partial<import('types').ServerHooks>>; | ||
| } |
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
11 changes: 11 additions & 0 deletions
11
packages/kit/test/apps/basics/src/routes/init-hooks/+page.server.ts
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 @@ | ||
| let did_init_run = 0; | ||
|
|
||
| export function _set_from_init() { | ||
| did_init_run++; | ||
| } | ||
|
|
||
| export function load() { | ||
| return { | ||
| did_init_run | ||
| }; | ||
| } |
7 changes: 7 additions & 0 deletions
7
packages/kit/test/apps/basics/src/routes/init-hooks/+page.svelte
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,7 @@ | ||
| <script> | ||
| const { data } = $props(); | ||
| </script> | ||
|
|
||
| <p>{data.did_init_run}</p> | ||
|
|
||
| <a href="/init-hooks/navigate">navigate</a> |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/basics/src/routes/init-hooks/navigate/+page.svelte
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 @@ | ||
| navigated |
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
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.