Skip to content

Commit

Permalink
Merge branch 'master' of github.com:sveltejs/kit into camara/sveltejs…
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcamaram committed Apr 12, 2021
2 parents d90c015 + b202c1e commit 447f4f6
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-spoons-dress.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Make --open option work with --https
5 changes: 5 additions & 0 deletions .changeset/olive-frogs-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Make --open option work on WSL
9 changes: 8 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"sandbox": "1.0.0",
"svelte-kit-demo": "1.0.0",
"@sveltejs/vite-plugin-svelte": "1.0.0-next.0",
"@sveltejs/adapter-cloudflare-workers": "0.0.1"
"@sveltejs/adapter-cloudflare-workers": "0.0.1",
"set-env-action": "1.0.0"
},
"changesets": [
"beige-bananas-press",
Expand All @@ -43,6 +44,8 @@
"clever-dolls-poke",
"clever-tools-enjoy",
"cold-llamas-brake",
"cool-spoons-dress",
"curvy-sloths-brake",
"cyan-roses-act",
"cyan-seals-trade",
"dirty-ligers-protect",
Expand Down Expand Up @@ -75,6 +78,7 @@
"heavy-papayas-smile",
"hot-keys-walk",
"hungry-lemons-scream",
"itchy-birds-admire",
"khaki-socks-tan",
"khaki-wolves-shout",
"kind-steaks-bake",
Expand Down Expand Up @@ -102,8 +106,10 @@
"nice-bags-bathe",
"nine-actors-whisper",
"old-files-jump",
"olive-frogs-drive",
"pink-ducks-press",
"plenty-cougars-invite",
"polite-worms-happen",
"poor-bobcats-unite",
"poor-snakes-explode",
"poor-years-hear",
Expand Down Expand Up @@ -172,6 +178,7 @@
"tough-chefs-remember",
"tough-lamps-brake",
"tricky-avocados-smile",
"tricky-bats-smoke",
"tricky-wolves-confess",
"two-crabs-tease",
"unlucky-parrots-vanish",
Expand Down
10 changes: 6 additions & 4 deletions documentation/docs/01-routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ At the heart of SvelteKit is a _filesystem-based router_. This means that the st
There are two types of route — **pages** and **endpoints**.

Pages typically generate HTML to display to the user (as well as any CSS and JavaScript needed for the page). By default pages are rendered on both the client and server though this behavior is configurable.

Endpoints run only on the server (or when you build your site, if [prerendering](#ssr-and-javascript-prerender)). This means it's the place to do things like access databases or APIs that require private credentials or return data that lives on a machine in your production network. Pages can request data from endpoints. Endpoints return JSON by default though may also return data in other formats.

### Pages

Pages are Svelte components written in `.svelte` files (or any file with an extension listed in [`config.extensions`](#configuration)). When a user first visits the application, they will be served a server-rendered version of the page in question, plus some JavaScript that 'hydrates' the page and initialises a client-side router. From that point forward, navigating to other pages is handled entirely on the client for a fast, app-like feel.
Pages are Svelte components written in `.svelte` files (or any file with an extension listed in [`config.extensions`](#configuration)). By default, when a user first visits the application, they will be served a server-rendered version of the page in question, plus some JavaScript that 'hydrates' the page and initialises a client-side router. From that point forward, navigating to other pages is handled entirely on the client for a fast, app-like feel where the common portions in the layout do not need to be rerendered.

The filename determines the route. For example, `src/routes/index.svelte` is the root of your site:

Expand Down Expand Up @@ -89,9 +93,7 @@ export async function get({ params }) {

> Returning nothing is equivalent to an explicit 404 response.
Because this module only runs on the server (or when you build your site, if [prerendering](#prerendering)), you can freely access things like databases. (Don't worry about `$lib`, we'll get to that [later](#$lib).)

The job of this function is to return a `{status, headers, body}` object representing the response. If the returned `body` is an object, and no `content-type` header is returned, it will automatically be turned into a JSON response.
The job of this function is to return a `{status, headers, body}` object representing the response. If the returned `body` is an object, and no `content-type` header is returned, it will automatically be turned into a JSON response. (Don't worry about `$lib`, we'll get to that [later](#$lib).)

For endpoints that handle other HTTP methods, like POST, export the corresponding function:

Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/13-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ An object containing zero or more of the following `string` values:

### prerender

See [Prerendering](#prerendering). An object containing zero or more of the following:
See [Prerendering](#ssr-and-javascript-prerender). An object containing zero or more of the following:

- `crawl` — determines whether SvelteKit should find pages to prerender by following links from the seed page(s)
- `enabled` — set to `false` to disable prerendering altogether
Expand Down
8 changes: 8 additions & 0 deletions packages/create-svelte/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# create-svelte

## 2.0.0-next.47

### Patch Changes

- 59a1e06: Add button:focus CSS styles to index page of default app
- 39b6967: Add ambient type definitions for \$app imports
- dfbe62b: Add title tag to index page of default app

## 2.0.0-next.46

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/create-svelte/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-svelte",
"version": "2.0.0-next.46",
"version": "2.0.0-next.47",
"bin": "./bin",
"devDependencies": {
"@rollup/plugin-json": "^4.1.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/kit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @sveltejs/kit

## 1.0.0-next.72

### Patch Changes

- 1d5228c: Make --open option work with --https
- 39b6967: Add ambient type definitions for \$app imports
- 1d5228c: Make --open option work on WSL
- bb2d97d: Fix argument type for RequestHandler

## 1.0.0-next.71

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sveltejs/kit",
"version": "1.0.0-next.71",
"version": "1.0.0-next.72",
"type": "module",
"dependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.5",
Expand Down
19 changes: 13 additions & 6 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sade from 'sade';
import colors from 'kleur';
import * as ports from 'port-authority';
import { load_config } from './core/load_config/index.js';
import { networkInterfaces } from 'os';
import { networkInterfaces, release } from 'os';

async function get_config() {
// TODO this is temporary, for the benefit of early adopters
Expand Down Expand Up @@ -51,16 +51,23 @@ function handle_error(error) {
process.exit(1);
}

/** @param {number} port */
async function launch(port) {
/**
* @param {number} port
* @param {boolean} https
*/
async function launch(port, https) {
const { exec } = await import('child_process');
let cmd = 'open';
if (process.platform == 'win32') {
cmd = 'start';
} else if (process.platform == 'linux') {
cmd = 'xdg-open';
if (/microsoft/i.test(release())) {
cmd = 'cmd.exe /c start';
} else {
cmd = 'xdg-open';
}
}
exec(`${cmd} http://localhost:${port}`);
exec(`${cmd} ${https ? 'https' : 'http'}://localhost:${port}`);
}

const prog = sade('svelte-kit').version('__VERSION__');
Expand Down Expand Up @@ -187,7 +194,7 @@ async function check_port(port) {
* }} param0
*/
function welcome({ port, host, https, open }) {
if (open) launch(port);
if (open) launch(port, https);

console.log(colors.bold().cyan(`\n SvelteKit v${'__VERSION__'}\n`));

Expand Down

0 comments on commit 447f4f6

Please sign in to comment.