Skip to content
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

[feat] add App.PageData type #6226

Merged
merged 6 commits into from
Aug 25, 2022
Merged

[feat] add App.PageData type #6226

merged 6 commits into from
Aug 25, 2022

Conversation

dummdidumm
Copy link
Member

Closes #5951

Marking as draft because the "layout data is required if one of the pages doesn't have a load function" check isn't implemented yet. If have an idea about storing the layout nodes in a map, which is updated by its pages, which also solves the O(n^2) problem, but my head needs a break so I'll revisit it later.
This all has gotten pretty sophisticated, which is why I'm also inclined to create some tests for it.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. All changesets should be patch until SvelteKit 1.0

@changeset-bot
Copy link

changeset-bot bot commented Aug 24, 2022

🦋 Changeset detected

Latest commit: 7fe3c4c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
create-svelte Patch
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris
Copy link
Member

I was thinking we could add a children: PageNode[] property on PageNode and add children at the same time as we do this:

current_node.parent = current_node = current_route.layout;

That would solve the O(n^2) problem and also ensure that the parent-child relationships were correct (which the current naive approach doesn't, since src/routes/foo/+layout.svelte treats src/routes/foo/bar/[email protected] as a child, incorrectly)

Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just had some minor comments, but to the extent I was able to understand this (it's brain-bending stuff 😅) it looks awesome. Very excited for this one

packages/kit/src/core/sync/write_types/index.js Outdated Show resolved Hide resolved
packages/kit/src/core/sync/write_types/index.js Outdated Show resolved Hide resolved
let server_load;
let errors;
function process_node(node, outdir, is_page, all_pages_have_load = true) {
const params = `${is_page ? 'Route' : 'Layout'}Params`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a side-note, probably for a separate PR, but I've been wondering if we should just always spell out the params type, i.e.

PageLoad<{ id: string }>

rather than

PageLoad<RouteParams>

It's obviously more repetitive, but it means that if you hover over the params object you see this...

image

...instead of this, which is less useful:

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a good idea yeah, let's do this in a separate PR.

packages/kit/src/core/sync/write_types/index.js Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce a feature for bottom-up page-to-layout communication
2 participants