Skip to content

Commit

Permalink
Merge branch 'main' into declaration-maps
Browse files Browse the repository at this point in the history
  • Loading branch information
eltigerchino authored Apr 7, 2024
2 parents a68768c + 41b7ae9 commit 59c8961
Show file tree
Hide file tree
Showing 346 changed files with 8,419 additions and 4,354 deletions.
8 changes: 8 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<!-- Your PR description here -->

---

### 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.
Expand All @@ -8,3 +12,7 @@

### 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. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`.

### Edits

- [ ] Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.
2 changes: 1 addition & 1 deletion .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.4.0
- uses: pnpm/action-setup@v3.0.0
- uses: actions/setup-node@v4
with:
node-version: '20.x'
Expand Down
23 changes: 13 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ permissions:
contents: read # to fetch code (actions/checkout)

jobs:
Lint:
lint-all:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.4.0
- uses: pnpm/action-setup@v3.0.0
- uses: actions/setup-node@v4
with:
node-version: '18.x'
Expand All @@ -32,7 +32,7 @@ jobs:
- run: pnpm run lint
- run: cd packages/kit && pnpm prepublishOnly && { [ "`git status --porcelain=v1`" == "" ] || (echo "Generated types have changed — please run prepublishOnly locally and commit the changes after you have reviewed them"; git diff; exit 1); }
- run: pnpm run check
Tests:
test-kit:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
Expand All @@ -50,14 +50,15 @@ jobs:
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.4.0
- uses: pnpm/action-setup@v3.0.0
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm playwright install ${{ matrix.e2e-browser }}
- run: pnpm test
- run: pnpm run sync-all
- run: pnpm test:kit
- name: Archive test results
if: failure()
shell: bash
Expand All @@ -69,7 +70,7 @@ jobs:
retention-days: 3
name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
path: test-results.tar.gz
Cross-browser-test:
test-kit-cross-browser:
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
Expand Down Expand Up @@ -105,13 +106,14 @@ jobs:
steps:
- run: git config --global core.autocrlf false
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.4.0
- uses: pnpm/action-setup@v3.0.0
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm playwright install ${{ matrix.e2e-browser }}
- run: pnpm run sync-all
- run: pnpm test:cross-platform:${{ matrix.mode }}
- name: Archive test results
if: failure()
Expand All @@ -124,15 +126,16 @@ jobs:
retention-days: 3
name: test-failure-cross-platform-${{ matrix.mode }}-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}-${{ matrix.e2e-browser }}
path: test-results-cross-platform-${{ matrix.mode }}.tar.gz
Test-create-svelte:
test-others:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.4.0
- uses: pnpm/action-setup@v3.0.0
- uses: actions/setup-node@v4
with:
node-version: 18
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm playwright install chromium
- run: cd packages/kit && pnpm prepublishOnly
- run: pnpm run test:create-svelte
- run: pnpm run test:others
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- uses: pnpm/action-setup@v2.4.0
- uses: pnpm/action-setup@v3.0.0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
Expand Down
7 changes: 7 additions & 0 deletions FUNDING.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"drips": {
"ethereum": {
"ownedBy": "0x99D414693dD65E4a0664a16D155dB66283A162D1"
}
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Web development, streamlined. Read the [documentation](https://kit.svelte.dev/do
| [create-svelte](packages/create-svelte) | [Changelog](packages/create-svelte/CHANGELOG.md) |
| [svelte-migrate](packages/migrate) | [Changelog](packages/migrate/CHANGELOG.md) |

[Additional adapters](<(https://sveltesociety.dev/components#adapters)>) are maintained by the community.
[Additional adapters](https://sveltesociety.dev/packages?category=sveltekit-adapters) are maintained by the community.

## Bug reporting

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Try editing the files to get a feel for how everything works.

## Editor setup

We recommend using [Visual Studio Code (aka VS Code)](https://code.visualstudio.com/download) with [the Svelte extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), but [support also exists for numerous other editors](https://sveltesociety.dev/tools#editor-support).
We recommend using [Visual Studio Code (aka VS Code)](https://code.visualstudio.com/download) with [the Svelte extension](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode), but [support also exists for numerous other editors](https://sveltesociety.dev/resources#editor-support).
2 changes: 2 additions & 0 deletions documentation/docs/20-core-concepts/10-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ We can create a layout that only applies to pages below `/settings` (while inher
<slot></slot>
```

You can see how `data` is populated by looking at the `+layout.js` example in the next section just below.

By default, each layout inherits the layout above it. Sometimes that isn't what you want - in this case, [advanced layouts](advanced-routing#advanced-layouts) can help you.

### +layout.js
Expand Down
28 changes: 26 additions & 2 deletions documentation/docs/20-core-concepts/20-load.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ Server `load` functions _always_ run on the server.

By default, universal `load` functions run on the server during SSR when the user first visits your page. They will then run again during hydration, reusing any responses from [fetch requests](#making-fetch-requests). All subsequent invocations of universal `load` functions happen in the browser. You can customize the behavior through [page options](page-options). If you disable [server side rendering](page-options#ssr), you'll get an SPA and universal `load` functions _always_ run on the client.

If a route contains both universal and server `load` functions, the server `load` runs first.

A `load` function is invoked at runtime, unless you [prerender](page-options#prerender) the page — in that case, it's invoked at build time.

### Input
Expand All @@ -190,7 +192,29 @@ Server `load` functions are convenient when you need to access data directly fro

Universal `load` functions are useful when you need to `fetch` data from an external API and don't need private credentials, since SvelteKit can get the data directly from the API rather than going via your server. They are also useful when you need to return something that can't be serialized, such as a Svelte component constructor.

In rare cases, you might need to use both together — for example, you might need to return an instance of a custom class that was initialised with data from your server.
In rare cases, you might need to use both together — for example, you might need to return an instance of a custom class that was initialised with data from your server. When using both, the server `load` return value is _not_ passed directly to the page, but to the universal `load` function (as the `data` property):

```js
/// file: src/routes/+page.server.js
/** @type {import('./$types').PageServerLoad} */
export async function load() {
return {
serverMessage: 'hello from server load function'
};
}
```

```js
/// file: src/routes/+page.js
// @errors: 18047
/** @type {import('./$types').PageLoad} */
export async function load({ data }) {
return {
serverMessage: data.serverMessage,
universalMessage: 'hello from universal load function'
};
}
```

## Using URL data

Expand Down Expand Up @@ -510,7 +534,7 @@ export function load({ fetch }) {
}
```

> On platforms that do not support streaming, such as AWS Lambda, responses will be buffered. This means the page will only render once all promises resolve. If you are using a proxy (e.g. NGINX), make sure it does not buffer responses from the proxied server.
> On platforms that do not support streaming, such as AWS Lambda or Firebase, responses will be buffered. This means the page will only render once all promises resolve. If you are using a proxy (e.g. NGINX), make sure it does not buffer responses from the proxied server.
> Streaming data will only work when JavaScript is enabled. You should avoid returning promises from a universal `load` function if the page is server rendered, as these are _not_ streamed — instead, the promise is recreated when the function reruns in the browser.
Expand Down
8 changes: 4 additions & 4 deletions documentation/docs/20-core-concepts/30-form-actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const actions = {
const password = data.get('password');

const user = await db.getUser(email);
cookies.set('sessionid', await db.createSession(user));
cookies.set('sessionid', await db.createSession(user), { path: '/' });

return { success: true };
},
Expand Down Expand Up @@ -174,7 +174,7 @@ export const actions = {
+ return fail(400, { email, incorrect: true });
+ }

cookies.set('sessionid', await db.createSession(user));
cookies.set('sessionid', await db.createSession(user), { path: '/' });

return { success: true };
},
Expand Down Expand Up @@ -231,7 +231,7 @@ export const actions = {
return fail(400, { email, incorrect: true });
}

cookies.set('sessionid', await db.createSession(user));
cookies.set('sessionid', await db.createSession(user), { path: '/' });

+ if (url.searchParams.has('redirectTo')) {
+ redirect(303, url.searchParams.get('redirectTo'));
Expand Down Expand Up @@ -303,7 +303,7 @@ export function load(event) {
/** @type {import('./$types').Actions} */
export const actions = {
logout: async (event) => {
event.cookies.delete('sessionid');
event.cookies.delete('sessionid', { path: '/' });
event.locals.user = null;
}
};
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/20-core-concepts/50-state-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ You might wonder how we're able to use `$page.data` and other [app stores](modul
<p>Welcome {$user.name}</p>
```

Updating the context-based store value in deeper-level pages or components will not affect the value in the parent component when the page is rendered via SSR: The parent component has already been rendered by the time the store value is updated. To avoid values 'flashing' during state updates during hydration, it is generally recommended to pass state down into components rather than up.
Updating the value of a context-based store in deeper-level pages or components while the page is being rendered via SSR will not affect the value in the parent component because it has already been rendered by the time the store value is updated. In contrast, on the client (when CSR is enabled, which is the default) the value will be propagated and components, pages, and layouts higher in the hierarchy will react to the new value. Therefore, to avoid values 'flashing' during state updates during hydration, it is generally recommended to pass state down into components rather than up.

If you're not using SSR (and can guarantee that you won't need to use SSR in future) then you can safely keep state in a shared module, without using the context API.

Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/25-build-and-deploy/20-adapters.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Official adapters exist for a variety of platforms — these are documented on t
- [`@sveltejs/adapter-static`](adapter-static) for static site generation (SSG)
- [`@sveltejs/adapter-vercel`](adapter-vercel) for Vercel

Additional [community-provided adapters](https://sveltesociety.dev/components#adapters) exist for other platforms.
Additional [community-provided adapters](https://sveltesociety.dev/packages?category=sveltekit-adapters) exist for other platforms.

## Using adapters

Expand Down
5 changes: 3 additions & 2 deletions documentation/docs/25-build-and-deploy/30-adapter-auto.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ When you create a new SvelteKit project with `npm create svelte@latest`, it inst
- [`@sveltejs/adapter-netlify`](adapter-netlify) for [Netlify](https://netlify.com/)
- [`@sveltejs/adapter-vercel`](adapter-vercel) for [Vercel](https://vercel.com/)
- [`svelte-adapter-azure-swa`](https://github.com/geoffrich/svelte-adapter-azure-swa) for [Azure Static Web Apps](https://docs.microsoft.com/en-us/azure/static-web-apps/)
- [`svelte-kit-sst`](https://github.com/serverless-stack/sst/tree/main/packages/svelte-kit-sst) for [AWS via SST](https://docs.sst.dev/start/svelte)
- [`svelte-kit-sst`](https://github.com/sst/sst/tree/master/packages/svelte-kit-sst) for [AWS via SST](https://docs.sst.dev/start/svelte)
- [`@sveltejs/adapter-node`](https://kit.svelte.dev/docs/adapter-node) for [Google Cloud Run](https://cloud.google.com/run)

It's recommended to install the appropriate adapter to your `devDependencies` once you've settled on a target environment, since this will add the adapter to your lockfile and slightly improve install times on CI.

Expand All @@ -18,4 +19,4 @@ To add configuration options, such as `{ edge: true }` in [`adapter-vercel`](ada

## Adding community adapters

You can add zero-config support for additional adapters by editing [adapters.js](https://github.com/sveltejs/kit/blob/main/packages/adapter-auto/adapters.js) and opening a pull request.
You can add zero-config support for additional adapters by editing [adapters.js](https://github.com/sveltejs/kit/blob/main/packages/adapter-auto/adapters.js) and opening a pull request.
Loading

0 comments on commit 59c8961

Please sign in to comment.