mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-20 06:15:15 +00:00
tidy up
This commit is contained in:
@@ -9,7 +9,6 @@ import {
|
|||||||
Redirect,
|
Redirect,
|
||||||
ComponentLoader,
|
ComponentLoader,
|
||||||
ComponentConstructor,
|
ComponentConstructor,
|
||||||
RootProps,
|
|
||||||
Page,
|
Page,
|
||||||
PageData
|
PageData
|
||||||
} from './types';
|
} from './types';
|
||||||
@@ -25,6 +24,7 @@ let segments: string[] = [];
|
|||||||
let current_token: {};
|
let current_token: {};
|
||||||
let root_preload: Promise<any>;
|
let root_preload: Promise<any>;
|
||||||
let root_data: any;
|
let root_data: any;
|
||||||
|
let current_branch = [];
|
||||||
|
|
||||||
export let prefetching: {
|
export let prefetching: {
|
||||||
href: string;
|
href: string;
|
||||||
@@ -189,12 +189,10 @@ async function render(results: any[], props: any, page: PageData, scroll: Scroll
|
|||||||
if (scroll) scrollTo(scroll.x, scroll.y);
|
if (scroll) scrollTo(scroll.x, scroll.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
previous_thingummy = results;
|
current_branch = results;
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let previous_thingummy = [];
|
|
||||||
|
|
||||||
export function prepare_page(target: Target): Promise<{
|
export function prepare_page(target: Target): Promise<{
|
||||||
redirect?: Redirect;
|
redirect?: Redirect;
|
||||||
data?: any;
|
data?: any;
|
||||||
@@ -245,7 +243,7 @@ export function prepare_page(target: Target): Promise<{
|
|||||||
return Promise.all(page.parts.map((part, i) => {
|
return Promise.all(page.parts.map((part, i) => {
|
||||||
const segment = new_segments[i];
|
const segment = new_segments[i];
|
||||||
|
|
||||||
if (i < changed_from || !part) return previous_thingummy[i];
|
if (i < changed_from || !part) return current_branch[i];
|
||||||
if (!part) return null;
|
if (!part) return null;
|
||||||
|
|
||||||
return load_component(components[part.i]).then(({ default: Component, preload }) => {
|
return load_component(components[part.i]).then(({ default: Component, preload }) => {
|
||||||
|
|||||||
@@ -8,13 +8,6 @@ type Child = {
|
|||||||
component?: Component;
|
component?: Component;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type RootProps = {
|
|
||||||
path: string;
|
|
||||||
params: Record<string, string>;
|
|
||||||
query: Record<string, string>;
|
|
||||||
child: Child;
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface ComponentConstructor {
|
export interface ComponentConstructor {
|
||||||
new (options: { target: Node, props: any, store: Store, hydrate: boolean }): Component;
|
new (options: { target: Node, props: any, store: Store, hydrate: boolean }): Component;
|
||||||
preload: (props: { params: Params, query: Query }) => Promise<any>;
|
preload: (props: { params: Params, query: Query }) => Promise<any>;
|
||||||
|
|||||||
Reference in New Issue
Block a user