Compare commits

..

10 Commits

Author SHA1 Message Date
Rich Harris
dd1f2d79ff -> v0.0.21 2017-12-16 12:18:34 -05:00
Rich Harris
dccd3cdeb0 prevent default when navigating to current location 2017-12-16 10:59:46 -05:00
Rich Harris
b3b5d9f352 handle hashchange correctly 2017-12-16 08:53:42 -05:00
Rich Harris
10ddaeb7a3 dont navigate on hashchange 2017-12-16 08:16:09 -05:00
Rich Harris
060f9b2f5e tidy up dependencies 2017-12-16 08:07:40 -05:00
Rich Harris
32dfa94247 dont include directories in cache manifest 2017-12-16 08:07:22 -05:00
Rich Harris
797cc3cde1 remove esm stuff - no longer used 2017-12-16 08:07:10 -05:00
Rich Harris
9eca90067c -> v0.0.20 2017-12-15 18:37:19 -05:00
Rich Harris
57f293e872 dont cache shell/sw in dev 2017-12-15 18:37:08 -05:00
Rich Harris
7e65c481d8 doh 2017-12-15 18:34:38 -05:00
6 changed files with 34 additions and 2111 deletions

View File

@@ -1,5 +1,3 @@
require('svelte/ssr/register');
const esm = require('@std/esm');
const fs = require('fs');
const path = require('path');
const glob = require('glob');
@@ -12,10 +10,6 @@ const create_compiler = require('./lib/utils/create_compiler.js');
const escape_html = require('escape-html');
const { src, dest, dev } = require('./lib/config.js');
const esmRequire = esm(module, {
esm: 'js'
});
module.exports = function connect(opts) {
mkdirp(dest);
rimraf.sync(path.join(dest, '**/*'));
@@ -39,7 +33,7 @@ module.exports = function connect(opts) {
await compiler.ready;
res.set({
'Content-Type': 'application/javascript',
'Cache-Control': 'max-age=600'
'Cache-Control': dev ? 'no-cache' : 'max-age=600'
});
res.end(compiler.service_worker);
}
@@ -48,7 +42,7 @@ module.exports = function connect(opts) {
await compiler.ready;
res.set({
'Content-Type': 'text/html',
'Cache-Control': 'max-age=600'
'Cache-Control': dev ? 'no-cache' : 'max-age=600'
});
res.end(compiler.shell);
}
@@ -125,9 +119,10 @@ module.exports = function connect(opts) {
}));
} catch(err) {
res.status(500).end(templates.render(500, {
title: err.name || 'Internal server error',
title: (err && err.name) || 'Internal server error',
url,
error: escape_html(err.details || err.message || err || 'Unknown error')
error: escape_html(err && (err.details || err.message || err) || 'Unknown error'),
stack: err && err.stack.split('\n').slice(1).join('\n')
}));
}
}

View File

@@ -68,7 +68,7 @@ module.exports = function create_webpack_compiler(dest, routes, dev) {
});
})
]).then(() => {
const assets = glob.sync('**', { cwd: 'assets' });
const assets = glob.sync('**', { cwd: 'assets', nodir: true });
const route_code = `[${
routes

21
package-lock.json generated
View File

@@ -1,14 +1,9 @@
{
"name": "sapper",
"version": "0.0.9",
"version": "0.0.20",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@std/esm": {
"version": "0.18.0",
"resolved": "https://registry.npmjs.org/@std/esm/-/esm-0.18.0.tgz",
"integrity": "sha512-oeHSSVp/WxC08ngpKgyYR4LcI0+EBwZiJcB58jvIqyJnOGxudSkxTgAQKsVfpNsMXfOoILgu9PWhuzIZ8GQEjw=="
},
"acorn": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz",
@@ -499,9 +494,9 @@
}
},
"errno": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.5.tgz",
"integrity": "sha512-tv2H+e3KBnMmNRuoVG24uorOj3XfYo+/nJJd07PUISRr0kaMKQKL5kyD+6ANXk1ZIIsvbORsjvHnCfC4KIc7uQ==",
"version": "0.1.6",
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.6.tgz",
"integrity": "sha512-IsORQDpaaSwcDP4ZZnHxgE85werpo34VYn1Ud3mq+eUsF593faR8oCZNXrROVkpFu2TsbrNhHin0aUrTsQ9vNw==",
"requires": {
"prr": "1.0.1"
}
@@ -1879,7 +1874,7 @@
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
"integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=",
"requires": {
"errno": "0.1.5",
"errno": "0.1.6",
"readable-stream": "2.3.3"
}
},
@@ -2559,12 +2554,6 @@
"has-flag": "2.0.0"
}
},
"svelte": {
"version": "1.47.1",
"resolved": "https://registry.npmjs.org/svelte/-/svelte-1.47.1.tgz",
"integrity": "sha512-xRw4pjF19XKfeTxp+TOTE/MQmRS7tRzm0hhh0dr/nc3NuHBfCBXnfve0ZymF8tZ+J/WM0cqfZ83RxZid2zf7qA==",
"dev": true
},
"tapable": {
"version": "0.2.8",
"resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz",

View File

@@ -1,24 +1,19 @@
{
"name": "sapper",
"version": "0.0.19",
"version": "0.0.21",
"description": "Combat-ready apps, engineered by Svelte",
"main": "connect.js",
"directories": {
"test": "test"
},
"dependencies": {
"@std/esm": "^0.18.0",
"escape-html": "^1.0.3",
"mkdirp": "^0.5.1",
"rimraf": "^2.6.2",
"webpack": "^3.10.0"
},
"devDependencies": {
"mocha": "^4.0.1",
"svelte": "^1.47.1"
},
"peerDependencies": {
"svelte": "^1.47.1"
"mocha": "^4.0.1"
},
"scripts": {
"test": "mocha --opts mocha.opts"
@@ -36,8 +31,5 @@
"bugs": {
"url": "https://github.com/sveltejs/sapper/issues"
},
"homepage": "https://github.com/sveltejs/sapper#readme",
"@std/esm": {
"esm": "js"
}
"homepage": "https://github.com/sveltejs/sapper#readme"
}

View File

@@ -8,8 +8,6 @@ const scroll_history = {};
let uid = 1;
let cid;
window.scroll_history = scroll_history;
if ('scrollRestoration' in history) {
history.scrollRestoration = 'manual'
}
@@ -59,7 +57,9 @@ const app = {
hydrate: !!component
});
window.scrollTo(scroll.x, scroll.y);
if (scroll) {
window.scrollTo(scroll.x, scroll.y);
}
});
}
@@ -103,13 +103,16 @@ const app = {
const a = findAnchor(event.target);
if (!a) return;
event.preventDefault();
// check if link is inside an svg
// in this case, both href and target are always inside an object
const svg = typeof a.href === 'object' && a.href.constructor.name === 'SVGAnimatedString';
const href = svg ? a.href.baseVal : a.href;
if (href === window.location.href) {
event.preventDefault();
return;
}
// Ignore if tag has
// 1. 'download' attribute
// 2. rel='external' attribute
@@ -118,9 +121,12 @@ const app = {
// Ignore if <a> has a target
if (svg ? a.target.baseVal : a.target) return;
const scroll = scroll_state();
const url = new URL(href);
if (navigate(new URL(a.href), null)) {
// Don't handle hash changes
if (url.pathname === window.location.pathname && url.search === window.location.search) return;
if (navigate(url, null)) {
event.preventDefault();
}
});
@@ -142,10 +148,15 @@ const app = {
window.addEventListener('mouseover', preload);
window.addEventListener('popstate', event => {
if (!event.state) return; // hashchange, or otherwise outside sapper's control
scroll_history[cid] = scroll_state();
navigate(new URL(window.location), event.state.id);
if (event.state) {
navigate(new URL(window.location), event.state.id);
} else {
// hashchange
cid = ++uid;
history.replaceState({ id: cid }, '', window.location.href);
}
});
const scroll = scroll_history[uid] = scroll_state();

2064
yarn.lock

File diff suppressed because it is too large Load Diff