Skip to content

Commit

Permalink
Implement fallback children
Browse files Browse the repository at this point in the history
When you pass a fallback to renderIntoDocument it will emit the fallback if the shell of the primary children errors. It is possible for the fallback to also error in the shell in which case the result is a fatalError as if you did not provide a fallback.

Included in this change is a refactoring of how preamble and postamble work. They are now interned within the resposneState where we can have more careful control over what is flushed and when.

There is also a new concept of an early preamble. the early preamble is the html and head tags plus any resources that can flush (most things plus stylesheets up to the first precedence)
  • Loading branch information
gnoff committed Jan 16, 2023
1 parent fc2b823 commit 307c090
Show file tree
Hide file tree
Showing 9 changed files with 863 additions and 245 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export type Resources = {
preconnects: Set<LinkResource>,
fontPreloads: Set<PreloadResource>,
// usedImagePreloads: Set<PreloadResource>,
firstPrecedence: string,
firstPrecedenceFlushed: boolean,
precedences: Map<string, Set<StyleResource>>,
usedStylePreloads: Set<PreloadResource>,
scripts: Set<ScriptResource>,
Expand Down Expand Up @@ -161,6 +163,8 @@ export function createResources(): Resources {
preconnects: new Set(),
fontPreloads: new Set(),
// usedImagePreloads: new Set(),
firstPrecedence: '',
firstPrecedenceFlushed: false,
precedences: new Map(),
usedStylePreloads: new Set(),
scripts: new Set(),
Expand Down Expand Up @@ -485,14 +489,17 @@ function createStyleResource(
);
}
}
const {stylesMap, preloadsMap, precedences} = resources;
const {stylesMap, preloadsMap, precedences, firstPrecedence} = resources;

// If this is the first time we've seen this precedence we encode it's position in our set even though
// we don't add the resource to this set yet
let precedenceSet = precedences.get(precedence);
if (!precedenceSet) {
precedenceSet = new Set();
precedences.set(precedence, precedenceSet);
if (!firstPrecedence) {
resources.firstPrecedence = precedence;
}
}

let hint = preloadsMap.get(href);
Expand Down
Loading

0 comments on commit 307c090

Please sign in to comment.