-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Svelte 5 SSR support - experimental
- Loading branch information
1 parent
eaeafca
commit 4c8d98c
Showing
41 changed files
with
244 additions
and
116 deletions.
There are no files selected for viewing
This file contains 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 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,6 +1,6 @@ | ||
import { mount } from 'svelte' | ||
import { hydrate } from 'svelte' | ||
import App from './App.svelte' | ||
|
||
mount(App, { | ||
hydrate(App, { | ||
target: document.body, | ||
}) |
This file contains 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 +1,3 @@ | ||
<h1>Hello world!</h1> | ||
|
||
<a href="/">Back</a> |
This file contains 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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,47 @@ | ||
import { render } from 'svelte/server' | ||
import { preloadUrl } from '../../runtime/index.js' | ||
|
||
const polyfillFetch = async () => { | ||
const fetch = await import('node-fetch') | ||
|
||
// @ts-ignore | ||
globalThis.fetch = fetch.default | ||
// @ts-ignore | ||
globalThis.Headers = fetch.Headers | ||
// @ts-ignore | ||
globalThis.Request = fetch.Request | ||
// @ts-ignore | ||
globalThis.Response = fetch.Response | ||
} | ||
|
||
/** | ||
* Returns a statically rendered Routify app - uses Svelte 5 | ||
* @param {(SvelteComponentDev|{default: SvelteComponentDev}) & {load: (url:string)=>Promise<any>}} module App.svelte | ||
* @param {string | string[] | import('../../runtime').PreloadOptions=} urlOrOptions one or multiple urls separated by ";<routerName>=" | ||
* @returns {Promise<{ | ||
* html: string, | ||
* status: number, | ||
* css: { code: string, map: string }, | ||
* head: '', | ||
* error: string, | ||
* maxage: number, | ||
* props: Object.<string, string>, | ||
* redirect: string | ||
* }>} | ||
*/ | ||
export const renderModule = async (module, urlOrOptions) => { | ||
await polyfillFetch() | ||
// const render = module.default?.render || module['render'] | ||
|
||
const url = urlOrOptions.url || urlOrOptions | ||
const load = module.load ? await module.load(url) : {} | ||
|
||
const preloadUrlLoad = await preloadUrl(urlOrOptions) | ||
|
||
return { | ||
status: 200, | ||
...(await render(module.default)), | ||
...load, | ||
...preloadUrlLoad?.flat()[0], | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 @@ | ||
/// <reference types="node" /> | ||
export class File { | ||
constructor(path: any); | ||
path: string; | ||
|
2 changes: 1 addition & 1 deletion
2
typings/lib/buildtime/plugins/filemapper/lib/utils/createRoot404.d.ts
This file contains 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 +1 @@ | ||
export function createRoot404(rootNode: import("../../../../../common/RNode.js").RNode<any>, routifyDir: any): void; | ||
export function createRoot404(rootNode: RNode, routifyDir: any): void; |
This file contains 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,9 +1,9 @@ | ||
export function themes({ instance }: { | ||
instance: any; | ||
}): Promise<void>; | ||
export function createThemedRootNodes(instance: RoutifyBuildtime, config: import('./utils.js').ThemeConfig): void; | ||
export function createThemedRootNodes(instance: RoutifyBuildtime, config: import("./utils.js").ThemeConfig): void; | ||
export function createThemedRootNode(instance: RoutifyBuildtime, name: any, themePreferenceGroups: (string[] | string)[], rootNodeName: any): void; | ||
export function nodeMatchesThemes(node: any, themes: any): any; | ||
export function copyNodeToTheme(rootNode: any): (node: any) => void; | ||
export function copyNode(node: import("../../../common/RNode.js").RNode<any>, rootNode: any, location?: string): void; | ||
export function tagNodeThemes(node: import("../../../common/RNode.js").RNode<any>): void; | ||
export function copyNode(node: RNode, rootNode: any, location?: string): void; | ||
export function tagNodeThemes(node: RNode): void; |
This file contains 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 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 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 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 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,3 +1,3 @@ | ||
export function assignNode(target: RNodeRuntime, ...sources: RNodeRuntime[]): RNodeRuntime; | ||
export function findNearestParent(node: RNodeRuntime, callback: (arg0: RNodeRuntime['parent']) => any): RNodeRuntime['parent'] | undefined; | ||
export function findNearestParent(node: RNodeRuntime, callback: (arg0: RNodeRuntime["parent"]) => any): RNodeRuntime["parent"] | undefined; | ||
export function getDistance(parentNode: RNodeRuntime, childNode: RNodeRuntime): number | undefined; |
This file contains 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 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 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,20 @@ | ||
export function dynamicImport(specifier: any): Promise<any>; | ||
export function renderModule(module: (SvelteComponentDev | { | ||
default: SvelteComponentDev; | ||
}) & { | ||
load: (url: string) => Promise<any>; | ||
}, urlOrOptions?: (string | string[] | import("../../runtime").PreloadOptions) | undefined): Promise<{ | ||
html: string; | ||
status: number; | ||
css: { | ||
code: string; | ||
map: string; | ||
}; | ||
head: ""; | ||
error: string; | ||
maxage: number; | ||
props: { | ||
[x: string]: string; | ||
}; | ||
redirect: string; | ||
}>; |
This file contains 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,19 @@ | ||
export function renderModule(module: (SvelteComponentDev | { | ||
default: SvelteComponentDev; | ||
}) & { | ||
load: (url: string) => Promise<any>; | ||
}, urlOrOptions?: (string | string[] | import("../../runtime").PreloadOptions) | undefined): Promise<{ | ||
html: string; | ||
status: number; | ||
css: { | ||
code: string; | ||
map: string; | ||
}; | ||
head: ""; | ||
error: string; | ||
maxage: number; | ||
props: { | ||
[x: string]: string; | ||
}; | ||
redirect: string; | ||
}>; |
Oops, something went wrong.