mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-14 03:54:46 +00:00
Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ecc7b80d91 | ||
|
|
40024e7d86 | ||
|
|
6f71f7ad4d | ||
|
|
6eb99b195e | ||
|
|
9e08fee9a1 | ||
|
|
442ce366e2 | ||
|
|
dc929fcd83 | ||
|
|
2dc246398b | ||
|
|
b7ac067459 | ||
|
|
8b50ff34b8 | ||
|
|
62abdb2a87 | ||
|
|
34d0bae4a1 | ||
|
|
4f0b336627 | ||
|
|
e71bf298fb | ||
|
|
e4936375db | ||
|
|
08ff7ad234 | ||
|
|
5995b7ae6a | ||
|
|
71ed3864b7 | ||
|
|
bd7f6e2b1a | ||
|
|
dd1f2d79ff | ||
|
|
dccd3cdeb0 | ||
|
|
b3b5d9f352 | ||
|
|
10ddaeb7a3 | ||
|
|
060f9b2f5e | ||
|
|
32dfa94247 | ||
|
|
797cc3cde1 | ||
|
|
9eca90067c | ||
|
|
57f293e872 | ||
|
|
7e65c481d8 | ||
|
|
0fe93cd177 | ||
|
|
67fe570f6d | ||
|
|
a3d44aba31 | ||
|
|
80ae909b73 | ||
|
|
892b18cf80 | ||
|
|
0eb96bf01f | ||
|
|
419f5c5235 | ||
|
|
4c61ed5fdd | ||
|
|
c19447cf05 | ||
|
|
cb2364f476 | ||
|
|
de427d400e | ||
|
|
e810ead93f | ||
|
|
f5a19ef34b | ||
|
|
b8c03d330b | ||
|
|
6e769496ec | ||
|
|
e46aceb2fe | ||
|
|
a87cac2481 | ||
|
|
608fdb7533 | ||
|
|
80166b5a7d | ||
|
|
24b259f80b | ||
|
|
8a9f4bd268 | ||
|
|
d940da1a77 | ||
|
|
91269f5705 | ||
|
|
80a9818e95 | ||
|
|
478ccf53cc | ||
|
|
b32278e88b | ||
|
|
881d411db0 | ||
|
|
2a5786d7d7 | ||
|
|
8b89a5f27e | ||
|
|
d46a270cf0 | ||
|
|
72efde9515 | ||
|
|
7c0789cabf | ||
|
|
bffffe0035 | ||
|
|
22d3cb2b1e | ||
|
|
e1ed1896e6 | ||
|
|
6d4c26d15d | ||
|
|
941867f0a4 | ||
|
|
c7e3fc4493 | ||
|
|
a8373c1568 | ||
|
|
db4223133e | ||
|
|
ef3a3e83e8 | ||
|
|
86292d119b | ||
|
|
2549477e05 | ||
|
|
cf0ab4b9c7 | ||
|
|
58768ae27d | ||
|
|
fa70024a92 | ||
|
|
33fcb865c8 | ||
|
|
c6778c961b | ||
|
|
cea14b4b53 | ||
|
|
12661449c2 | ||
|
|
2f51435d93 | ||
|
|
642c2904df |
14
CHANGELOG.md
Normal file
14
CHANGELOG.md
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# sapper changelog
|
||||||
|
|
||||||
|
## 0.1.2
|
||||||
|
|
||||||
|
* Use `atime.getTime()` and `mtime.getTime()` instead of `atimeMs` and `mtimeMs` ([#11](https://github.com/sveltejs/sapper/issues/11))
|
||||||
|
* Make dest dir before anyone tries to write to it ([#18](https://github.com/sveltejs/sapper/pull/18))
|
||||||
|
|
||||||
|
## 0.1.1
|
||||||
|
|
||||||
|
* Expose resolved pathname to `sapper/runtime/app.js` as `__app__` inside main.js
|
||||||
|
|
||||||
|
## 0.1.0
|
||||||
|
|
||||||
|
* First public preview
|
||||||
12
README.md
12
README.md
@@ -44,13 +44,13 @@ Like Next, routes are defined by the project directory structure, but with some
|
|||||||
|
|
||||||
* Files with an `.html` extension are treated as Svelte components. The `routes/about.html` (or `routes/about/index.html`) would create the `/about` route.
|
* Files with an `.html` extension are treated as Svelte components. The `routes/about.html` (or `routes/about/index.html`) would create the `/about` route.
|
||||||
* Files with a `.js` or `.mjs` extension are more generic route handlers. These files should export functions corresponding to the HTTP methods they support (example below).
|
* Files with a `.js` or `.mjs` extension are more generic route handlers. These files should export functions corresponding to the HTTP methods they support (example below).
|
||||||
* Instead of route masking, we embed parameters in the filename. For example `post/%id%.html` maps to `/post/:id`, and the component will be rendered with the appropriate parameter.
|
* Instead of route masking, we embed parameters in the filename. For example `post/[id].html` maps to `/post/:id`, and the component will be rendered with the appropriate parameter.
|
||||||
* Nested routes (read [this article](https://joshduff.com/2015-06-why-you-need-a-state-router.md)) can be handled by creating a file that matches the subroute — for example, `routes/app/settings/%submenu%.html` would match `/app/settings/profile` *and* `app/settings`, but in the latter case the `submenu` parameter would be `null`.
|
* Nested routes (read [this article](https://joshduff.com/2015-06-why-you-need-a-state-router.md)) can be handled by creating a file that matches the subroute — for example, `routes/app/settings/[submenu].html` would match `/app/settings/profile` *and* `app/settings`, but in the latter case the `submenu` parameter would be `null`.
|
||||||
|
|
||||||
An example of a generic route:
|
An example of a generic route:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// routes/api/post/%id%.js
|
// routes/api/post/[id].js
|
||||||
export async function get(req, res) {
|
export async function get(req, res) {
|
||||||
try {
|
try {
|
||||||
const data = await getPostFromDatabase(req.params.id);
|
const data = await getPostFromDatabase(req.params.id);
|
||||||
@@ -71,7 +71,7 @@ export async function get(req, res) {
|
|||||||
Or, if you omit the `res` argument, it can use the return value:
|
Or, if you omit the `res` argument, it can use the return value:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// routes/api/post/%id%.js
|
// routes/api/post/[id].js
|
||||||
export async function get(req) {
|
export async function get(req) {
|
||||||
return await getPostFromDatabase(req.params.id);
|
return await getPostFromDatabase(req.params.id);
|
||||||
}
|
}
|
||||||
@@ -121,10 +121,10 @@ function navigate(url) {
|
|||||||
import('/index.js').then(render);
|
import('/index.js').then(render);
|
||||||
} else if (match = /^\/post\/([^\/]+)$/.exec(url.pathname)) {
|
} else if (match = /^\/post\/([^\/]+)$/.exec(url.pathname)) {
|
||||||
params.id = match[1];
|
params.id = match[1];
|
||||||
import('/post/%id%.html').then(render);
|
import('/post/[id].html').then(render);
|
||||||
} else if (match = /^\/([^\/]+)$/.exec(url.pathname)) {
|
} else if (match = /^\/([^\/]+)$/.exec(url.pathname)) {
|
||||||
params.wildcard = match[1];
|
params.wildcard = match[1];
|
||||||
import('/%wildcard%.html').then(render);
|
import('/[wildcard].html').then(render);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
94
connect.js
94
connect.js
@@ -1,94 +0,0 @@
|
|||||||
require('svelte/ssr/register');
|
|
||||||
const esm = require('@std/esm');
|
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const glob = require('glob');
|
|
||||||
const tmp = require('tmp');
|
|
||||||
const create_matchers = require('./utils/create_matchers.js');
|
|
||||||
const create_app = require('./utils/create_app.js');
|
|
||||||
const create_webpack_compiler = require('./utils/create_webpack_compiler.js');
|
|
||||||
|
|
||||||
const esmRequire = esm(module, {
|
|
||||||
esm: 'all'
|
|
||||||
});
|
|
||||||
|
|
||||||
const dir = tmp.dirSync({ unsafeCleanup: true });
|
|
||||||
|
|
||||||
module.exports = function connect(opts) {
|
|
||||||
const routes = path.resolve('routes');
|
|
||||||
const out = path.resolve('.sapper');
|
|
||||||
|
|
||||||
let pages = glob.sync('**/*.html', { cwd: routes });
|
|
||||||
let page_matchers = create_matchers(pages);
|
|
||||||
|
|
||||||
let server_routes = glob.sync('**/*.+(js|mjs)', { cwd: routes });
|
|
||||||
let server_route_matchers = create_matchers(server_routes);
|
|
||||||
|
|
||||||
// create_app(routes, dir.name, page_matchers, opts.dev);
|
|
||||||
create_app(routes, out, page_matchers, opts.dev);
|
|
||||||
|
|
||||||
const webpack_compiler = create_webpack_compiler(
|
|
||||||
path.join(out, 'main.js'),
|
|
||||||
path.resolve('.sapper/webpack'),
|
|
||||||
opts.dev
|
|
||||||
);
|
|
||||||
|
|
||||||
return async function(req, res, next) {
|
|
||||||
const url = req.url.replace(/\?.+/, '');
|
|
||||||
|
|
||||||
if (url.startsWith('/webpack/')) {
|
|
||||||
fs.createReadStream(path.resolve('.sapper' + url)).pipe(res);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < page_matchers.length; i += 1) {
|
|
||||||
const matcher = page_matchers[i];
|
|
||||||
if (matcher.test(url)) {
|
|
||||||
const params = matcher.exec(url);
|
|
||||||
const Component = require(`${routes}/${matcher.file}`);
|
|
||||||
|
|
||||||
const app = await webpack_compiler.app;
|
|
||||||
|
|
||||||
const page = opts.template({
|
|
||||||
app,
|
|
||||||
html: Component.render({
|
|
||||||
params,
|
|
||||||
query: req.query
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
res.end(page);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < server_route_matchers.length; i += 1) {
|
|
||||||
const matcher = server_route_matchers[i];
|
|
||||||
if (matcher.test(url)) {
|
|
||||||
req.params = matcher.exec(url);
|
|
||||||
const route = esmRequire(`${routes}/${matcher.file}`);
|
|
||||||
|
|
||||||
const handler = route[req.method.toLowerCase()];
|
|
||||||
if (handler) {
|
|
||||||
if (handler.length === 2) {
|
|
||||||
handler(req, res);
|
|
||||||
} else {
|
|
||||||
const data = await handler(req);
|
|
||||||
|
|
||||||
// TODO headers, error handling
|
|
||||||
if (typeof data === 'string') {
|
|
||||||
res.end(data);
|
|
||||||
} else {
|
|
||||||
res.end(JSON.stringify(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
next();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
19
lib/config.js
Normal file
19
lib/config.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const mkdirp = require('mkdirp');
|
||||||
|
const rimraf = require('rimraf');
|
||||||
|
|
||||||
|
exports.dev = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
|
exports.templates = path.resolve(process.env.SAPPER_TEMPLATES || 'templates');
|
||||||
|
|
||||||
|
exports.src = path.resolve(process.env.SAPPER_ROUTES || 'routes');
|
||||||
|
|
||||||
|
exports.dest = path.resolve(
|
||||||
|
process.env.NOW ? '/tmp' :
|
||||||
|
process.env.SAPPER_DEST || '.sapper'
|
||||||
|
);
|
||||||
|
|
||||||
|
mkdirp(exports.dest);
|
||||||
|
rimraf.sync(path.join(exports.dest, '**/*'));
|
||||||
|
|
||||||
|
exports.server_routes = path.resolve(exports.dest, 'server-routes.js');
|
||||||
162
lib/index.js
Normal file
162
lib/index.js
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const glob = require('glob');
|
||||||
|
const rimraf = require('rimraf');
|
||||||
|
const mkdirp = require('mkdirp');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const create_routes = require('./utils/create_routes.js');
|
||||||
|
const templates = require('./templates.js');
|
||||||
|
const create_app = require('./utils/create_app.js');
|
||||||
|
const create_compiler = require('./utils/create_compiler.js');
|
||||||
|
const escape_html = require('escape-html');
|
||||||
|
const { src, dest, dev } = require('./config.js');
|
||||||
|
|
||||||
|
module.exports = function connect(opts) {
|
||||||
|
let routes = create_routes(
|
||||||
|
glob.sync('**/*.+(html|js|mjs)', { cwd: src })
|
||||||
|
);
|
||||||
|
|
||||||
|
create_app(src, dest, routes, opts);
|
||||||
|
|
||||||
|
const client = webpack(
|
||||||
|
require(path.resolve('webpack.client.config.js'))
|
||||||
|
);
|
||||||
|
|
||||||
|
const server = webpack(
|
||||||
|
require(path.resolve('webpack.server.config.js'))
|
||||||
|
);
|
||||||
|
|
||||||
|
const compiler = create_compiler(
|
||||||
|
client,
|
||||||
|
server,
|
||||||
|
dest,
|
||||||
|
routes,
|
||||||
|
dev
|
||||||
|
);
|
||||||
|
|
||||||
|
const dev_middleware = dev ? require('webpack-dev-middleware')(client, {
|
||||||
|
noInfo: true,
|
||||||
|
logLevel: 'silent',
|
||||||
|
publicPath: '/client/'
|
||||||
|
}) : null;
|
||||||
|
|
||||||
|
const hot_middleware = dev ? require('webpack-hot-middleware')(client, {
|
||||||
|
reload: true,
|
||||||
|
path: '/__webpack_hmr',
|
||||||
|
heartbeat: 10 * 1000
|
||||||
|
}) : null;
|
||||||
|
|
||||||
|
async function handle_webpack_generated_files(url, req, res, next) {
|
||||||
|
if (dev) {
|
||||||
|
dev_middleware(req, res, () => {
|
||||||
|
hot_middleware(req, res, next);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (url.startsWith('/client/')) {
|
||||||
|
await compiler.ready;
|
||||||
|
res.set({
|
||||||
|
'Content-Type': 'application/javascript',
|
||||||
|
'Cache-Control': 'max-age=31536000'
|
||||||
|
});
|
||||||
|
res.end(compiler.asset_cache[url]);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handle_index(url, req, res, next) {
|
||||||
|
if (url === '/index.html') {
|
||||||
|
await compiler.ready;
|
||||||
|
res.set({
|
||||||
|
'Content-Type': 'text/html',
|
||||||
|
'Cache-Control': dev ? 'no-cache' : 'max-age=600'
|
||||||
|
});
|
||||||
|
res.end(compiler.shell);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handle_service_worker(url, req, res, next) {
|
||||||
|
if (url === '/service-worker.js') {
|
||||||
|
await compiler.ready;
|
||||||
|
res.set({
|
||||||
|
'Content-Type': 'application/javascript',
|
||||||
|
'Cache-Control': dev ? 'no-cache' : 'max-age=600'
|
||||||
|
});
|
||||||
|
res.end(compiler.service_worker);
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handle_route(url, req, res, next) {
|
||||||
|
// whatever happens, we're going to serve some HTML
|
||||||
|
res.set({
|
||||||
|
'Content-Type': 'text/html'
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (const route of routes) {
|
||||||
|
if (route.test(url)) {
|
||||||
|
await compiler.ready;
|
||||||
|
|
||||||
|
req.params = route.exec(url);
|
||||||
|
|
||||||
|
const mod = require(compiler.server_routes)[route.id];
|
||||||
|
|
||||||
|
if (route.type === 'page') {
|
||||||
|
let data = { params: req.params, query: req.query };
|
||||||
|
if (mod.preload) data = Object.assign(data, await mod.preload(data));
|
||||||
|
|
||||||
|
const { html, head, css } = mod.render(data);
|
||||||
|
|
||||||
|
const page = templates.render(200, {
|
||||||
|
main: compiler.client_main,
|
||||||
|
html,
|
||||||
|
head: `<noscript id='sapper-head-start'></noscript>${head}<noscript id='sapper-head-end'></noscript>`,
|
||||||
|
styles: (css && css.code ? `<style>${css.code}</style>` : '')
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(200);
|
||||||
|
res.end(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
const handler = mod[req.method.toLowerCase()];
|
||||||
|
if (handler) handler(req, res, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res.status(404).end(templates.render(404, {
|
||||||
|
title: 'Not found',
|
||||||
|
status: 404,
|
||||||
|
method: req.method,
|
||||||
|
url
|
||||||
|
}));
|
||||||
|
} catch(err) {
|
||||||
|
res.status(500).end(templates.render(500, {
|
||||||
|
title: (err && err.name) || 'Internal server error',
|
||||||
|
url,
|
||||||
|
error: escape_html(err && (err.details || err.message || err) || 'Unknown error'),
|
||||||
|
stack: err && err.stack.split('\n').slice(1).join('\n')
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return async function(req, res, next) {
|
||||||
|
const url = req.url.replace(/\?.+/, '');
|
||||||
|
|
||||||
|
handle_index(url, req, res, () => {
|
||||||
|
handle_service_worker(url, req, res, () => {
|
||||||
|
handle_webpack_generated_files(url, req, res, () => {
|
||||||
|
handle_route(url, req, res, next);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
16
lib/route_manager.js
Normal file
16
lib/route_manager.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
const glob = require('glob');
|
||||||
|
const create_routes = require('./utils/create_routes.js');
|
||||||
|
const { src } = require('./config.js');
|
||||||
|
|
||||||
|
const route_manager = {
|
||||||
|
routes: create_routes(
|
||||||
|
glob.sync('**/*.+(html|js|mjs)', { cwd: src })
|
||||||
|
),
|
||||||
|
|
||||||
|
onchange(fn) {
|
||||||
|
// TODO in dev mode, keep this updated, and allow
|
||||||
|
// webpack compiler etc to hook into it
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = route_manager;
|
||||||
43
lib/templates.js
Normal file
43
lib/templates.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const glob = require('glob');
|
||||||
|
|
||||||
|
const templates = glob.sync('*.html', { cwd: 'templates' })
|
||||||
|
.map(file => {
|
||||||
|
const template = fs.readFileSync(`templates/${file}`, 'utf-8');
|
||||||
|
const status = file.replace('.html', '').toLowerCase();
|
||||||
|
|
||||||
|
if (!/^[0-9x]{3}$/.test(status)) {
|
||||||
|
throw new Error(`Bad template — should be a valid status code like 404.html, or a wildcard like 2xx.html`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const specificity = (
|
||||||
|
(status[0] === 'x' ? 0 : 4) +
|
||||||
|
(status[1] === 'x' ? 0 : 2) +
|
||||||
|
(status[2] === 'x' ? 0 : 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
const pattern = new RegExp(`^${status.split('').map(d => d === 'x' ? '\\d' : d).join('')}$`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
test: status => pattern.test(status),
|
||||||
|
specificity,
|
||||||
|
render(data) {
|
||||||
|
return template.replace(/%sapper\.(\w+)%/g, (match, key) => {
|
||||||
|
return key in data ? data[key] : '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sort((a, b) => b.specificity - a.specificity);
|
||||||
|
|
||||||
|
exports.render = (status, data) => {
|
||||||
|
const template = templates.find(template => template.test(status));
|
||||||
|
if (template) return template.render(data);
|
||||||
|
|
||||||
|
return `Missing template for status code ${status}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.onchange = fn => {
|
||||||
|
// TODO in dev mode, keep this updated, and allow
|
||||||
|
// webpack compiler etc to hook into it
|
||||||
|
};
|
||||||
57
lib/utils/create_app.js
Normal file
57
lib/utils/create_app.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const { dest, server_routes, dev } = require('../config.js');
|
||||||
|
|
||||||
|
module.exports = function create_app(src, dest, routes, options) {
|
||||||
|
function create_client_main() {
|
||||||
|
const template = fs.readFileSync('templates/main.js', 'utf-8');
|
||||||
|
|
||||||
|
const code = `[${
|
||||||
|
routes
|
||||||
|
.filter(route => route.type === 'page')
|
||||||
|
.map(route => {
|
||||||
|
const params = route.dynamic.length === 0 ?
|
||||||
|
'{}' :
|
||||||
|
`{ ${route.dynamic.map((part, i) => `${part}: match[${i + 1}]`).join(', ') } }`;
|
||||||
|
|
||||||
|
return `{ pattern: ${route.pattern}, params: match => (${params}), load: () => import(/* webpackChunkName: "${route.id}" */ '${src}/${route.file}') }`
|
||||||
|
})
|
||||||
|
.join(', ')
|
||||||
|
}]`;
|
||||||
|
|
||||||
|
const main = template
|
||||||
|
.replace(/__app__/g, path.resolve(__dirname, '../../runtime/app.js'))
|
||||||
|
.replace(/__routes__/g, code)
|
||||||
|
.replace(/__dev__/g, String(dev));
|
||||||
|
|
||||||
|
const file = path.resolve(dest, 'main.js');
|
||||||
|
|
||||||
|
fs.writeFileSync(file, main);
|
||||||
|
|
||||||
|
// need to fudge the mtime, because webpack is soft in the head
|
||||||
|
const stats = fs.statSync(file);
|
||||||
|
const { atime, mtime } = statSync(file);
|
||||||
|
fs.utimesSync(file, atime.getTime() - 999999, mtime.getTime() - 999999);
|
||||||
|
}
|
||||||
|
|
||||||
|
function create_server_routes() {
|
||||||
|
const imports = routes
|
||||||
|
.map(route => {
|
||||||
|
return route.type === 'page' ?
|
||||||
|
`import ${route.id} from '${src}/${route.file}';` :
|
||||||
|
`import * as ${route.id} from '${src}/${route.file}';`;
|
||||||
|
})
|
||||||
|
.join('\n');
|
||||||
|
|
||||||
|
const exports = `export { ${routes.map(route => route.id)} };`;
|
||||||
|
|
||||||
|
fs.writeFileSync(server_routes, `${imports}\n\n${exports}`);
|
||||||
|
|
||||||
|
const { atime, mtime } = statSync(server_routes);
|
||||||
|
fs.utimesSync(server_routes, atime.getTime() - 999999, mtime.getTime() - 999999);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO in dev mode, watch files
|
||||||
|
create_client_main();
|
||||||
|
create_server_routes();
|
||||||
|
};
|
||||||
152
lib/utils/create_compiler.js
Normal file
152
lib/utils/create_compiler.js
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const glob = require('glob');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
const { dev } = require('../config.js');
|
||||||
|
const templates = require('../templates.js');
|
||||||
|
|
||||||
|
module.exports = function create_compiler(client, server, dest, routes, dev) {
|
||||||
|
const compiler = {};
|
||||||
|
|
||||||
|
function client_updated(stats) {
|
||||||
|
console.log(stats.toString({ colors: true }));
|
||||||
|
|
||||||
|
const info = stats.toJson();
|
||||||
|
|
||||||
|
compiler.client_main = `/client/${info.assetsByChunkName.main}`;
|
||||||
|
compiler.assets = info.assets.map(asset => `/client/${asset.name}`);
|
||||||
|
|
||||||
|
const _fs = client.outputFileSystem && client.outputFileSystem.readFileSync ? client.outputFileSystem : fs;
|
||||||
|
compiler.asset_cache = {};
|
||||||
|
compiler.assets.forEach(file => {
|
||||||
|
compiler.asset_cache[file] = _fs.readFileSync(path.join(dest, file), 'utf-8');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function server_updated(stats) {
|
||||||
|
console.log(stats.toString({ colors: true }));
|
||||||
|
|
||||||
|
const info = stats.toJson();
|
||||||
|
compiler.server_routes = path.resolve(dest, 'server', info.assetsByChunkName.server_routes);
|
||||||
|
compiler.chunks = info.assetsByChunkName;
|
||||||
|
}
|
||||||
|
|
||||||
|
function both_updated() {
|
||||||
|
const assets = glob.sync('**', { cwd: 'assets', nodir: true });
|
||||||
|
|
||||||
|
const route_code = `[${
|
||||||
|
routes
|
||||||
|
.filter(route => route.type === 'page')
|
||||||
|
.map(route => `{ pattern: ${route.pattern} }`)
|
||||||
|
.join(', ')
|
||||||
|
}]`;
|
||||||
|
|
||||||
|
compiler.service_worker = fs.readFileSync('templates/service-worker.js', 'utf-8')
|
||||||
|
.replace('__timestamp__', Date.now())
|
||||||
|
.replace('__assets__', JSON.stringify(assets))
|
||||||
|
.replace('__shell__', JSON.stringify(compiler.assets.concat('/index.html')))
|
||||||
|
.replace('__routes__', route_code);
|
||||||
|
|
||||||
|
compiler.shell = templates.render(200, {
|
||||||
|
styles: '',
|
||||||
|
head: '',
|
||||||
|
html: '<noscript>Please enable JavaScript!</noscript>',
|
||||||
|
main: compiler.client_main
|
||||||
|
});
|
||||||
|
|
||||||
|
// useful for debugging, but the files are served from memory
|
||||||
|
fs.writeFileSync(path.resolve(dest, 'service-worker.js'), compiler.service_worker);
|
||||||
|
fs.writeFileSync(path.resolve(dest, 'index.html'), compiler.shell);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dev) {
|
||||||
|
let client_is_ready = false;
|
||||||
|
let server_is_ready = false;
|
||||||
|
|
||||||
|
let fulfil;
|
||||||
|
let reject;
|
||||||
|
|
||||||
|
const invalidate = () => new Promise((f, r) => {
|
||||||
|
fulfil = f;
|
||||||
|
reject = r;
|
||||||
|
});
|
||||||
|
|
||||||
|
compiler.ready = invalidate();
|
||||||
|
|
||||||
|
client.plugin('invalid', filename => {
|
||||||
|
console.log(chalk.red(`client bundle invalidated, file changed: ${chalk.bold(filename)}`));
|
||||||
|
client_is_ready = false;
|
||||||
|
compiler.ready = invalidate();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.plugin('done', stats => {
|
||||||
|
if (stats.hasErrors()) {
|
||||||
|
reject(stats.toJson().errors[0]);
|
||||||
|
} else {
|
||||||
|
client_updated(stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
client_is_ready = true;
|
||||||
|
if (server_is_ready) fulfil();
|
||||||
|
});
|
||||||
|
|
||||||
|
client.plugin('failed', reject);
|
||||||
|
|
||||||
|
server.plugin('invalid', filename => {
|
||||||
|
console.log(chalk.red(`server bundle invalidated, file changed: ${chalk.bold(filename)}`));
|
||||||
|
server_is_ready = false;
|
||||||
|
compiler.ready = invalidate();
|
||||||
|
});
|
||||||
|
|
||||||
|
server.plugin('done', stats => {
|
||||||
|
if (stats.hasErrors()) {
|
||||||
|
reject(stats.toJson().errors[0]);
|
||||||
|
} else {
|
||||||
|
server_updated(stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
server_is_ready = true;
|
||||||
|
if (client_is_ready) fulfil();
|
||||||
|
});
|
||||||
|
|
||||||
|
server.plugin('failed', reject);
|
||||||
|
|
||||||
|
// client is already being watched by the middleware,
|
||||||
|
// so we only need to start the server compiler
|
||||||
|
server.watch({}, (err, stats) => {
|
||||||
|
if (stats.hasErrors()) {
|
||||||
|
reject(stats.toJson().errors[0]);
|
||||||
|
} else {
|
||||||
|
server_updated(stats);
|
||||||
|
server_is_ready = true;
|
||||||
|
if (client_is_ready) fulfil();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
compiler.ready = Promise.all([
|
||||||
|
new Promise((fulfil, reject) => {
|
||||||
|
client.run((err, stats) => {
|
||||||
|
if (stats.hasErrors()) {
|
||||||
|
reject(stats.toJson().errors[0]);
|
||||||
|
} else {
|
||||||
|
client_updated(stats);
|
||||||
|
}
|
||||||
|
fulfil();
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
|
||||||
|
new Promise((fulfil, reject) => {
|
||||||
|
server.run((err, stats) => {
|
||||||
|
if (stats.hasErrors()) {
|
||||||
|
reject(stats.toJson().errors[0]);
|
||||||
|
} else {
|
||||||
|
server_updated(stats);
|
||||||
|
}
|
||||||
|
fulfil();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
]).then(both_updated);
|
||||||
|
}
|
||||||
|
|
||||||
|
return compiler;
|
||||||
|
};
|
||||||
@@ -3,15 +3,21 @@ const path = require('path');
|
|||||||
module.exports = function create_matchers(files) {
|
module.exports = function create_matchers(files) {
|
||||||
return files
|
return files
|
||||||
.map(file => {
|
.map(file => {
|
||||||
|
if (/(^|\/|\\)_/.test(file)) return;
|
||||||
|
|
||||||
const parts = file.replace(/\.(html|js|mjs)$/, '').split(path.sep);
|
const parts = file.replace(/\.(html|js|mjs)$/, '').split(path.sep);
|
||||||
if (parts[parts.length - 1] === 'index') parts.pop();
|
if (parts[parts.length - 1] === 'index') parts.pop();
|
||||||
|
|
||||||
|
const id = (
|
||||||
|
parts.join('_').replace(/[[\]]/g, '$').replace(/^\d/, '_$&').replace(/[^a-zA-Z0-9_$]/g, '_')
|
||||||
|
) || '_';
|
||||||
|
|
||||||
const dynamic = parts
|
const dynamic = parts
|
||||||
.filter(part => part[0] === '%')
|
.filter(part => part[0] === '[')
|
||||||
.map(part => part.slice(1, -1));
|
.map(part => part.slice(1, -1));
|
||||||
|
|
||||||
const pattern = new RegExp(
|
const pattern = new RegExp(
|
||||||
`^\\/${parts.map(p => p[0] === '%' ? '([^/]+)' : p).join('\\/')}$`
|
`^\\/${parts.map(p => p[0] === '[' ? '([^/]+)' : p).join('\\/')}$`
|
||||||
);
|
);
|
||||||
|
|
||||||
const test = url => pattern.test(url);
|
const test = url => pattern.test(url);
|
||||||
@@ -29,6 +35,8 @@ module.exports = function create_matchers(files) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
id,
|
||||||
|
type: path.extname(file) === '.html' ? 'page' : 'route',
|
||||||
file,
|
file,
|
||||||
pattern,
|
pattern,
|
||||||
test,
|
test,
|
||||||
@@ -37,6 +45,7 @@ module.exports = function create_matchers(files) {
|
|||||||
dynamic
|
dynamic
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
.filter(Boolean)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
return (
|
return (
|
||||||
(a.dynamic.length - b.dynamic.length) || // match static paths first
|
(a.dynamic.length - b.dynamic.length) || // match static paths first
|
||||||
@@ -5,21 +5,21 @@ const create_matchers = require('./create_matchers.js');
|
|||||||
|
|
||||||
describe('create_matchers', () => {
|
describe('create_matchers', () => {
|
||||||
it('sorts routes correctly', () => {
|
it('sorts routes correctly', () => {
|
||||||
const matchers = create_matchers(['index.html', 'about.html', '%wildcard%.html', 'post/%id%.html']);
|
const matchers = create_matchers(['index.html', 'about.html', '[wildcard].html', 'post/[id].html']);
|
||||||
|
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
matchers.map(m => m.file),
|
matchers.map(m => m.file),
|
||||||
[
|
[
|
||||||
'about.html',
|
'about.html',
|
||||||
'index.html',
|
'index.html',
|
||||||
'post/%id%.html',
|
'post/[id].html',
|
||||||
'%wildcard%.html'
|
'[wildcard].html'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates params', () => {
|
it('generates params', () => {
|
||||||
const matchers = create_matchers(['index.html', 'about.html', '%wildcard%.html', 'post/%id%.html']);
|
const matchers = create_matchers(['index.html', 'about.html', '[wildcard].html', 'post/[id].html']);
|
||||||
|
|
||||||
let file;
|
let file;
|
||||||
let params;
|
let params;
|
||||||
@@ -31,9 +31,21 @@ describe('create_matchers', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.equal(file, 'post/%id%.html');
|
assert.equal(file, 'post/[id].html');
|
||||||
assert.deepEqual(params, {
|
assert.deepEqual(params, {
|
||||||
id: '123'
|
id: '123'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('ignores files and directories with leading underscores', () => {
|
||||||
|
const matches = create_matchers(['index.html', '_foo.html', 'a/_b/c/d.html', 'e/f/g/h.html', 'i/_j.html']);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
matches.map(m => m.file),
|
||||||
|
[
|
||||||
|
'e/f/g/h.html',
|
||||||
|
'index.html'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
254
package-lock.json
generated
254
package-lock.json
generated
@@ -1,14 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.0.1",
|
"version": "0.0.21",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"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": {
|
"acorn": {
|
||||||
"version": "5.2.1",
|
"version": "5.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz",
|
||||||
@@ -30,9 +25,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ajv": {
|
"ajv": {
|
||||||
"version": "5.5.1",
|
"version": "5.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
|
||||||
"integrity": "sha1-s4u4h22ehr7plJVqBOch6IskjrI=",
|
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"co": "4.6.0",
|
"co": "4.6.0",
|
||||||
"fast-deep-equal": "1.0.0",
|
"fast-deep-equal": "1.0.0",
|
||||||
@@ -55,11 +50,24 @@
|
|||||||
"repeat-string": "1.6.1"
|
"repeat-string": "1.6.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ansi-html": {
|
||||||
|
"version": "0.0.7",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-html/-/ansi-html-0.0.7.tgz",
|
||||||
|
"integrity": "sha1-gTWEAhliqenm/QOflA0S9WynhZ4="
|
||||||
|
},
|
||||||
"ansi-regex": {
|
"ansi-regex": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||||
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
|
"integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8="
|
||||||
},
|
},
|
||||||
|
"ansi-styles": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz",
|
||||||
|
"integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==",
|
||||||
|
"requires": {
|
||||||
|
"color-convert": "1.9.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"anymatch": {
|
"anymatch": {
|
||||||
"version": "1.3.2",
|
"version": "1.3.2",
|
||||||
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz",
|
||||||
@@ -82,6 +90,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz",
|
||||||
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg=="
|
"integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg=="
|
||||||
},
|
},
|
||||||
|
"array-find-index": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/array-find-index/-/array-find-index-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E="
|
||||||
|
},
|
||||||
"array-unique": {
|
"array-unique": {
|
||||||
"version": "0.2.1",
|
"version": "0.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz",
|
||||||
@@ -276,6 +289,16 @@
|
|||||||
"lazy-cache": "1.0.4"
|
"lazy-cache": "1.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"chalk": {
|
||||||
|
"version": "2.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz",
|
||||||
|
"integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==",
|
||||||
|
"requires": {
|
||||||
|
"ansi-styles": "3.2.0",
|
||||||
|
"escape-string-regexp": "1.0.5",
|
||||||
|
"supports-color": "4.5.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"chokidar": {
|
"chokidar": {
|
||||||
"version": "1.7.0",
|
"version": "1.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz",
|
||||||
@@ -321,6 +344,19 @@
|
|||||||
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
||||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
|
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
|
||||||
},
|
},
|
||||||
|
"color-convert": {
|
||||||
|
"version": "1.9.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
|
||||||
|
"integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==",
|
||||||
|
"requires": {
|
||||||
|
"color-name": "1.1.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"color-name": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||||
|
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||||
|
},
|
||||||
"commander": {
|
"commander": {
|
||||||
"version": "2.11.0",
|
"version": "2.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz",
|
||||||
@@ -411,6 +447,14 @@
|
|||||||
"randomfill": "1.0.3"
|
"randomfill": "1.0.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"currently-unhandled": {
|
||||||
|
"version": "0.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz",
|
||||||
|
"integrity": "sha1-mI3zP+qxke95mmE2nddsF635V+o=",
|
||||||
|
"requires": {
|
||||||
|
"array-find-index": "1.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"d": {
|
"d": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz",
|
||||||
@@ -499,9 +543,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"errno": {
|
"errno": {
|
||||||
"version": "0.1.5",
|
"version": "0.1.6",
|
||||||
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/errno/-/errno-0.1.6.tgz",
|
||||||
"integrity": "sha512-tv2H+e3KBnMmNRuoVG24uorOj3XfYo+/nJJd07PUISRr0kaMKQKL5kyD+6ANXk1ZIIsvbORsjvHnCfC4KIc7uQ==",
|
"integrity": "sha512-IsORQDpaaSwcDP4ZZnHxgE85werpo34VYn1Ud3mq+eUsF593faR8oCZNXrROVkpFu2TsbrNhHin0aUrTsQ9vNw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"prr": "1.0.1"
|
"prr": "1.0.1"
|
||||||
}
|
}
|
||||||
@@ -578,11 +622,15 @@
|
|||||||
"es6-symbol": "3.1.1"
|
"es6-symbol": "3.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"escape-html": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||||
|
"integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
|
||||||
|
},
|
||||||
"escape-string-regexp": {
|
"escape-string-regexp": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"escope": {
|
"escope": {
|
||||||
"version": "3.6.0",
|
"version": "3.6.0",
|
||||||
@@ -670,17 +718,6 @@
|
|||||||
"is-extglob": "1.0.0"
|
"is-extglob": "1.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extract-text-webpack-plugin": {
|
|
||||||
"version": "3.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/extract-text-webpack-plugin/-/extract-text-webpack-plugin-3.0.2.tgz",
|
|
||||||
"integrity": "sha512-bt/LZ4m5Rqt/Crl2HiKuAl/oqg0psx1tsTLkvWbJen1CtD+fftkZhMaQ9HOtY2gWsl2Wq+sABmMVi9z3DhKWQQ==",
|
|
||||||
"requires": {
|
|
||||||
"async": "2.6.0",
|
|
||||||
"loader-utils": "1.1.0",
|
|
||||||
"schema-utils": "0.3.0",
|
|
||||||
"webpack-sources": "1.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"fast-deep-equal": {
|
"fast-deep-equal": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz",
|
||||||
@@ -732,8 +769,7 @@
|
|||||||
"fs.realpath": {
|
"fs.realpath": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"fsevents": {
|
"fsevents": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.3",
|
||||||
@@ -1538,7 +1574,6 @@
|
|||||||
"version": "7.1.2",
|
"version": "7.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"fs.realpath": "1.0.0",
|
"fs.realpath": "1.0.0",
|
||||||
"inflight": "1.0.6",
|
"inflight": "1.0.6",
|
||||||
@@ -1619,6 +1654,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.5.0.tgz",
|
||||||
"integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg=="
|
"integrity": "sha512-pNgbURSuab90KbTqvRPsseaTxOJCZBD0a7t+haSN33piP9cCM4l0CqdzAif2hUqm716UovKB2ROmiabGAKVXyg=="
|
||||||
},
|
},
|
||||||
|
"html-entities": {
|
||||||
|
"version": "1.2.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/html-entities/-/html-entities-1.2.1.tgz",
|
||||||
|
"integrity": "sha1-DfKTUfByEWNRXfueVUPl9u7VFi8="
|
||||||
|
},
|
||||||
"https-browserify": {
|
"https-browserify": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz",
|
||||||
@@ -1638,7 +1678,6 @@
|
|||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"once": "1.4.0",
|
"once": "1.4.0",
|
||||||
"wrappy": "1.0.2"
|
"wrappy": "1.0.2"
|
||||||
@@ -1841,11 +1880,38 @@
|
|||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz",
|
||||||
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
|
"integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4="
|
||||||
},
|
},
|
||||||
|
"log-symbols": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-zLeLrzMA1A2vRF1e/0Mo+LNINzi6jzBylHj5WqvQ/WK/5WCZt8si9SyN4p9llr/HRYvVR1AoXHRHl4WTHyQAzQ==",
|
||||||
|
"requires": {
|
||||||
|
"chalk": "2.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loglevel": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/loglevel/-/loglevel-1.6.0.tgz",
|
||||||
|
"integrity": "sha1-rgyqVhERSYxboTcj1vtjHSQAOTQ="
|
||||||
|
},
|
||||||
|
"loglevel-plugin-prefix": {
|
||||||
|
"version": "0.5.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/loglevel-plugin-prefix/-/loglevel-plugin-prefix-0.5.3.tgz",
|
||||||
|
"integrity": "sha512-zRAJw3WYCQAJ6xfEIi04/oqlmR6jkwg3hmBcMW82Zic3iPWyju1gwntcgic0m5NgqYNJ62alCmb0g/div26WjQ=="
|
||||||
|
},
|
||||||
"longest": {
|
"longest": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz",
|
||||||
"integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc="
|
"integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc="
|
||||||
},
|
},
|
||||||
|
"loud-rejection": {
|
||||||
|
"version": "1.6.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz",
|
||||||
|
"integrity": "sha1-W0b4AUft7leIcPCG0Eghz5mOVR8=",
|
||||||
|
"requires": {
|
||||||
|
"currently-unhandled": "0.4.1",
|
||||||
|
"signal-exit": "3.0.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"lru-cache": {
|
"lru-cache": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.1.tgz",
|
||||||
@@ -1888,7 +1954,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz",
|
||||||
"integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=",
|
"integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"errno": "0.1.5",
|
"errno": "0.1.6",
|
||||||
"readable-stream": "2.3.3"
|
"readable-stream": "2.3.3"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1921,6 +1987,11 @@
|
|||||||
"brorand": "1.1.0"
|
"brorand": "1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"mime": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/mime/-/mime-2.0.3.tgz",
|
||||||
|
"integrity": "sha512-TrpAd/vX3xaLPDgVRm6JkZwLR0KHfukMdU2wTEbqMDdCnY6Yo3mE+mjs9YE6oMNw2QRfXVeBEYpmpO94BIqiug=="
|
||||||
|
},
|
||||||
"mimic-fn": {
|
"mimic-fn": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.1.0.tgz",
|
||||||
@@ -2078,7 +2149,6 @@
|
|||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1.0.2"
|
"wrappy": "1.0.2"
|
||||||
}
|
}
|
||||||
@@ -2098,11 +2168,6 @@
|
|||||||
"mem": "1.1.0"
|
"mem": "1.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"os-tmpdir": {
|
|
||||||
"version": "1.0.2",
|
|
||||||
"resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz",
|
|
||||||
"integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ="
|
|
||||||
},
|
|
||||||
"p-finally": {
|
"p-finally": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz",
|
||||||
@@ -2308,6 +2373,11 @@
|
|||||||
"safe-buffer": "5.1.1"
|
"safe-buffer": "5.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"range-parser": {
|
||||||
|
"version": "1.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
|
||||||
|
"integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4="
|
||||||
|
},
|
||||||
"read-pkg": {
|
"read-pkg": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz",
|
||||||
@@ -2393,6 +2463,14 @@
|
|||||||
"align-text": "0.1.4"
|
"align-text": "0.1.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"rimraf": {
|
||||||
|
"version": "2.6.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz",
|
||||||
|
"integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==",
|
||||||
|
"requires": {
|
||||||
|
"glob": "7.1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ripemd160": {
|
"ripemd160": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.1.tgz",
|
||||||
@@ -2407,14 +2485,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
|
||||||
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
"integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg=="
|
||||||
},
|
},
|
||||||
"schema-utils": {
|
|
||||||
"version": "0.3.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.3.0.tgz",
|
|
||||||
"integrity": "sha1-9YdyIs4+kx7a4DnxfrNxbnE3+M8=",
|
|
||||||
"requires": {
|
|
||||||
"ajv": "5.5.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"semver": {
|
"semver": {
|
||||||
"version": "5.4.1",
|
"version": "5.4.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz",
|
||||||
@@ -2468,9 +2538,9 @@
|
|||||||
"integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A=="
|
"integrity": "sha512-I2UmuJSRr/T8jisiROLU3A3ltr+swpniSmNPI4Ml3ZCX6tVnDsuZzK7F2hl5jTqbZBWCEKlj5HRQiPExXLgE8A=="
|
||||||
},
|
},
|
||||||
"source-map": {
|
"source-map": {
|
||||||
"version": "0.6.1",
|
"version": "0.5.7",
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
||||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
|
||||||
},
|
},
|
||||||
"spdx-correct": {
|
"spdx-correct": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@@ -2574,17 +2644,16 @@
|
|||||||
"has-flag": "2.0.0"
|
"has-flag": "2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"svelte": {
|
|
||||||
"version": "1.47.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-1.47.0.tgz",
|
|
||||||
"integrity": "sha512-+RrPJXW3BDbbfSWFd2G2kAtUJs3cre0b4bWWe4mIkqprzL0FqVNBgWoSQNKmDngbCDbeXXvYC6ldkPp8bNXlRA==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"tapable": {
|
"tapable": {
|
||||||
"version": "0.2.8",
|
"version": "0.2.8",
|
||||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz",
|
"resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.8.tgz",
|
||||||
"integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI="
|
"integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI="
|
||||||
},
|
},
|
||||||
|
"time-stamp": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/time-stamp/-/time-stamp-2.0.0.tgz",
|
||||||
|
"integrity": "sha1-lcakRTDhW6jW9KPsuMOj+sRto1c="
|
||||||
|
},
|
||||||
"timers-browserify": {
|
"timers-browserify": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.4.tgz",
|
||||||
@@ -2593,14 +2662,6 @@
|
|||||||
"setimmediate": "1.0.5"
|
"setimmediate": "1.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tmp": {
|
|
||||||
"version": "0.0.33",
|
|
||||||
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz",
|
|
||||||
"integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==",
|
|
||||||
"requires": {
|
|
||||||
"os-tmpdir": "1.0.2"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"to-arraybuffer": {
|
"to-arraybuffer": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
|
||||||
@@ -2621,11 +2682,6 @@
|
|||||||
"yargs": "3.10.0"
|
"yargs": "3.10.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"source-map": {
|
|
||||||
"version": "0.5.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
|
||||||
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
|
|
||||||
},
|
|
||||||
"yargs": {
|
"yargs": {
|
||||||
"version": "3.10.0",
|
"version": "3.10.0",
|
||||||
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
|
"resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz",
|
||||||
@@ -2653,13 +2709,6 @@
|
|||||||
"source-map": "0.5.7",
|
"source-map": "0.5.7",
|
||||||
"uglify-js": "2.8.29",
|
"uglify-js": "2.8.29",
|
||||||
"webpack-sources": "1.1.0"
|
"webpack-sources": "1.1.0"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"source-map": {
|
|
||||||
"version": "0.5.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
|
||||||
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
@@ -2678,6 +2727,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"url-join": {
|
||||||
|
"version": "2.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/url-join/-/url-join-2.0.2.tgz",
|
||||||
|
"integrity": "sha1-wHJ1aWetJLi1nldBVRyqx49QuLc="
|
||||||
|
},
|
||||||
"util": {
|
"util": {
|
||||||
"version": "0.10.3",
|
"version": "0.10.3",
|
||||||
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
|
"resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz",
|
||||||
@@ -2698,6 +2752,11 @@
|
|||||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
|
||||||
},
|
},
|
||||||
|
"uuid": {
|
||||||
|
"version": "3.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz",
|
||||||
|
"integrity": "sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g=="
|
||||||
|
},
|
||||||
"validate-npm-package-license": {
|
"validate-npm-package-license": {
|
||||||
"version": "3.0.1",
|
"version": "3.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz",
|
||||||
@@ -2732,7 +2791,7 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"acorn": "5.2.1",
|
"acorn": "5.2.1",
|
||||||
"acorn-dynamic-import": "2.0.2",
|
"acorn-dynamic-import": "2.0.2",
|
||||||
"ajv": "5.5.1",
|
"ajv": "5.5.2",
|
||||||
"ajv-keywords": "2.1.1",
|
"ajv-keywords": "2.1.1",
|
||||||
"async": "2.6.0",
|
"async": "2.6.0",
|
||||||
"enhanced-resolve": "3.4.1",
|
"enhanced-resolve": "3.4.1",
|
||||||
@@ -2752,13 +2811,36 @@
|
|||||||
"watchpack": "1.4.0",
|
"watchpack": "1.4.0",
|
||||||
"webpack-sources": "1.1.0",
|
"webpack-sources": "1.1.0",
|
||||||
"yargs": "8.0.2"
|
"yargs": "8.0.2"
|
||||||
},
|
}
|
||||||
"dependencies": {
|
},
|
||||||
"source-map": {
|
"webpack-dev-middleware": {
|
||||||
"version": "0.5.7",
|
"version": "2.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
"resolved": "https://registry.npmjs.org/webpack-dev-middleware/-/webpack-dev-middleware-2.0.1.tgz",
|
||||||
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
|
"integrity": "sha512-jEQgJK+eblBzE4blKmNuJqNd4cz3t4K3mFmN6uZz4Iq44x2vc1r+CwZBgcX+GzQoSOk5iWSVB3bIN5AYKpFRTw==",
|
||||||
}
|
"requires": {
|
||||||
|
"chalk": "2.3.0",
|
||||||
|
"log-symbols": "2.1.0",
|
||||||
|
"loglevel": "1.6.0",
|
||||||
|
"loglevel-plugin-prefix": "0.5.3",
|
||||||
|
"loud-rejection": "1.6.0",
|
||||||
|
"memory-fs": "0.4.1",
|
||||||
|
"mime": "2.0.3",
|
||||||
|
"path-is-absolute": "1.0.1",
|
||||||
|
"range-parser": "1.2.0",
|
||||||
|
"time-stamp": "2.0.0",
|
||||||
|
"url-join": "2.0.2",
|
||||||
|
"uuid": "3.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"webpack-hot-middleware": {
|
||||||
|
"version": "2.21.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/webpack-hot-middleware/-/webpack-hot-middleware-2.21.0.tgz",
|
||||||
|
"integrity": "sha512-P6xiOLy10QlSVSO7GanU9PLxN6zLLQ7RG16MPTvmFwf2KUG7jMp6m+fmdgsR7xoaVVLA7OlX3YO6JjoZEKjCuA==",
|
||||||
|
"requires": {
|
||||||
|
"ansi-html": "0.0.7",
|
||||||
|
"html-entities": "1.2.1",
|
||||||
|
"querystring": "0.2.0",
|
||||||
|
"strip-ansi": "3.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"webpack-sources": {
|
"webpack-sources": {
|
||||||
@@ -2768,6 +2850,13 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"source-list-map": "2.0.0",
|
"source-list-map": "2.0.0",
|
||||||
"source-map": "0.6.1"
|
"source-map": "0.6.1"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"source-map": {
|
||||||
|
"version": "0.6.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
|
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"which": {
|
"which": {
|
||||||
@@ -2817,8 +2906,7 @@
|
|||||||
"wrappy": {
|
"wrappy": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"xtend": {
|
"xtend": {
|
||||||
"version": "4.0.1",
|
"version": "4.0.1",
|
||||||
|
|||||||
25
package.json
25
package.json
@@ -1,20 +1,22 @@
|
|||||||
{
|
{
|
||||||
"name": "sapper",
|
"name": "sapper",
|
||||||
"version": "0.0.3",
|
"version": "0.1.2",
|
||||||
"description": "Combat-ready apps, engineered by Svelte",
|
"description": "Military-grade apps, engineered by Svelte",
|
||||||
"main": "connect.js",
|
"main": "lib/index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@std/esm": "^0.18.0",
|
"chalk": "^2.3.0",
|
||||||
"extract-text-webpack-plugin": "^3.0.2",
|
"escape-html": "^1.0.3",
|
||||||
"tmp": "0.0.33",
|
"mkdirp": "^0.5.1",
|
||||||
"webpack": "^3.10.0"
|
"rimraf": "^2.6.2",
|
||||||
|
"webpack": "^3.10.0",
|
||||||
|
"webpack-dev-middleware": "^2.0.1",
|
||||||
|
"webpack-hot-middleware": "^2.21.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "^4.0.1",
|
"mocha": "^4.0.1"
|
||||||
"svelte": "^1.47.1"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha --opts mocha.opts"
|
"test": "mocha --opts mocha.opts"
|
||||||
@@ -32,8 +34,5 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/sveltejs/sapper/issues"
|
"url": "https://github.com/sveltejs/sapper/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/sveltejs/sapper#readme",
|
"homepage": "https://github.com/sveltejs/sapper#readme"
|
||||||
"@std/esm": {
|
|
||||||
"esm": "js"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
192
runtime/app.js
Normal file
192
runtime/app.js
Normal file
@@ -0,0 +1,192 @@
|
|||||||
|
const detach = node => {
|
||||||
|
node.parentNode.removeChild(node);
|
||||||
|
};
|
||||||
|
|
||||||
|
export let component;
|
||||||
|
let target;
|
||||||
|
let routes;
|
||||||
|
|
||||||
|
const scroll_history = {};
|
||||||
|
let uid = 1;
|
||||||
|
let cid;
|
||||||
|
|
||||||
|
if ('scrollRestoration' in history) {
|
||||||
|
history.scrollRestoration = 'manual'
|
||||||
|
}
|
||||||
|
|
||||||
|
function select_route(url) {
|
||||||
|
if (url.origin !== window.location.origin) return null;
|
||||||
|
|
||||||
|
for (const route of routes) {
|
||||||
|
const match = route.pattern.exec(url.pathname);
|
||||||
|
if (match) {
|
||||||
|
const params = route.params(match);
|
||||||
|
|
||||||
|
const query = {};
|
||||||
|
for (const [key, value] of url.searchParams) query[key] = value || true;
|
||||||
|
|
||||||
|
return { route, data: { params, query } };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function render(Component, data, scroll) {
|
||||||
|
Promise.resolve(
|
||||||
|
Component.preload ? Component.preload(data) : {}
|
||||||
|
).then(preloaded => {
|
||||||
|
if (component) {
|
||||||
|
component.destroy();
|
||||||
|
} else {
|
||||||
|
// first load — remove SSR'd <head> contents
|
||||||
|
const start = document.querySelector('#sapper-head-start');
|
||||||
|
let end = document.querySelector('#sapper-head-end');
|
||||||
|
|
||||||
|
if (start && end) {
|
||||||
|
while (start.nextSibling !== end) detach(start.nextSibling);
|
||||||
|
detach(start);
|
||||||
|
detach(end);
|
||||||
|
}
|
||||||
|
|
||||||
|
// preload additional routes
|
||||||
|
routes.reduce((promise, route) => promise.then(route.load), Promise.resolve());
|
||||||
|
}
|
||||||
|
|
||||||
|
component = new Component({
|
||||||
|
target,
|
||||||
|
data: Object.assign(data, preloaded),
|
||||||
|
hydrate: !!component
|
||||||
|
});
|
||||||
|
|
||||||
|
if (scroll) {
|
||||||
|
window.scrollTo(scroll.x, scroll.y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function navigate(url, id) {
|
||||||
|
const selected = select_route(url);
|
||||||
|
if (selected) {
|
||||||
|
if (id) {
|
||||||
|
// popstate or initial navigation
|
||||||
|
cid = id;
|
||||||
|
} else {
|
||||||
|
// clicked on a link. preserve scroll state
|
||||||
|
scroll_history[cid] = scroll_state();
|
||||||
|
|
||||||
|
id = cid = ++uid;
|
||||||
|
scroll_history[cid] = { x: 0, y: 0 };
|
||||||
|
|
||||||
|
history.pushState({ id }, '', url.href);
|
||||||
|
}
|
||||||
|
|
||||||
|
selected.route.load().then(mod => {
|
||||||
|
render(mod.default, selected.data, scroll_history[id]);
|
||||||
|
});
|
||||||
|
|
||||||
|
cid = id;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_click(event) {
|
||||||
|
// Adapted from https://github.com/visionmedia/page.js
|
||||||
|
// MIT license https://github.com/visionmedia/page.js#license
|
||||||
|
if (which(event) !== 1) return;
|
||||||
|
if (event.metaKey || event.ctrlKey || event.shiftKey) return;
|
||||||
|
if (event.defaultPrevented) return;
|
||||||
|
|
||||||
|
const a = findAnchor(event.target);
|
||||||
|
if (!a) return;
|
||||||
|
|
||||||
|
// 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
|
||||||
|
if (a.hasAttribute('download') || a.getAttribute('rel') === 'external') return;
|
||||||
|
|
||||||
|
// Ignore if <a> has a target
|
||||||
|
if (svg ? a.target.baseVal : a.target) return;
|
||||||
|
|
||||||
|
const url = new URL(href);
|
||||||
|
|
||||||
|
// Don't handle hash changes
|
||||||
|
if (url.pathname === window.location.pathname && url.search === window.location.search) return;
|
||||||
|
|
||||||
|
if (navigate(url, null)) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_popstate(event) {
|
||||||
|
scroll_history[cid] = scroll_state();
|
||||||
|
|
||||||
|
if (event.state) {
|
||||||
|
navigate(new URL(window.location), event.state.id);
|
||||||
|
} else {
|
||||||
|
// hashchange
|
||||||
|
cid = ++uid;
|
||||||
|
history.replaceState({ id: cid }, '', window.location.href);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prefetch(event) {
|
||||||
|
const a = findAnchor(event.target);
|
||||||
|
if (!a || a.rel !== 'prefetch') return;
|
||||||
|
|
||||||
|
const selected = select_route(new URL(a.href));
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
selected.route.load().then(mod => {
|
||||||
|
if (mod.default.preload) mod.default.preload(selected.data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function findAnchor(node) {
|
||||||
|
while (node && node.nodeName.toUpperCase() !== 'A') node = node.parentNode; // SVG <a> elements have a lowercase name
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
let inited;
|
||||||
|
|
||||||
|
export function init(_target, _routes) {
|
||||||
|
target = _target;
|
||||||
|
routes = _routes;
|
||||||
|
|
||||||
|
if (!inited) { // this check makes HMR possible
|
||||||
|
window.addEventListener('click', handle_click);
|
||||||
|
window.addEventListener('popstate', handle_popstate);
|
||||||
|
|
||||||
|
// prefetch
|
||||||
|
window.addEventListener('touchstart', prefetch);
|
||||||
|
window.addEventListener('mouseover', prefetch);
|
||||||
|
|
||||||
|
inited = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scroll = scroll_history[uid] = scroll_state();
|
||||||
|
|
||||||
|
history.replaceState({ id: uid }, '', window.location.href);
|
||||||
|
navigate(new URL(window.location), uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
function which(event) {
|
||||||
|
event = event || window.event;
|
||||||
|
return event.which === null ? event.button : event.which;
|
||||||
|
}
|
||||||
|
|
||||||
|
function scroll_state() {
|
||||||
|
return {
|
||||||
|
x: window.scrollX,
|
||||||
|
y: window.scrollY
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
window.addEventListener('click', event => {
|
|
||||||
let a = event.target;
|
|
||||||
while (a && a.nodeName !== 'A') a = a.parentNode;
|
|
||||||
if (!a) return;
|
|
||||||
|
|
||||||
if (navigate(new URL(a.href))) event.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
const target = document.querySelector('main');
|
|
||||||
let component;
|
|
||||||
|
|
||||||
function navigate(url) {
|
|
||||||
if (url.origin !== window.location.origin) return;
|
|
||||||
|
|
||||||
let match;
|
|
||||||
let params = {};
|
|
||||||
const query = {};
|
|
||||||
|
|
||||||
function render(mod) {
|
|
||||||
if (component) {
|
|
||||||
component.destroy();
|
|
||||||
} else {
|
|
||||||
target.innerHTML = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
component = new mod.default({
|
|
||||||
target,
|
|
||||||
data: { query, params },
|
|
||||||
hydrate: !!component
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// ROUTES
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
navigate(window.location);
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tmp = require('tmp');
|
|
||||||
|
|
||||||
const template = fs.readFileSync(path.resolve(__dirname, '../templates/main.js'), 'utf-8');
|
|
||||||
|
|
||||||
module.exports = function create_app(routes, dest, matchers, dev) {
|
|
||||||
// TODO in dev mode, watch files
|
|
||||||
|
|
||||||
const code = matchers
|
|
||||||
.map(matcher => {
|
|
||||||
const condition = matcher.dynamic.length === 0 ?
|
|
||||||
`url.pathname === '/${matcher.parts.join('/')}'` :
|
|
||||||
`${matcher.pattern}.test(url.pathname)`;
|
|
||||||
|
|
||||||
return `
|
|
||||||
if (${condition}) {
|
|
||||||
// TODO set params, if applicable
|
|
||||||
import('${routes}/${matcher.file}').then(render);
|
|
||||||
}
|
|
||||||
`.replace(/^\t{3}/gm, '').trim();
|
|
||||||
})
|
|
||||||
.join(' else ');
|
|
||||||
|
|
||||||
const main = template.replace('// ROUTES', code);
|
|
||||||
|
|
||||||
fs.writeFileSync(path.join(dest, 'main.js'), main);
|
|
||||||
};
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
const fs = require('fs');
|
|
||||||
const webpack = require('webpack');
|
|
||||||
const ExtractTextPlugin = require("extract-text-webpack-plugin");
|
|
||||||
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
|
||||||
|
|
||||||
// TODO make the webpack config, err, configurable
|
|
||||||
|
|
||||||
module.exports = function create_webpack_compiler(main, dest, dev) {
|
|
||||||
const compiler = {};
|
|
||||||
|
|
||||||
const _ = webpack({
|
|
||||||
entry: {
|
|
||||||
main
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
extensions: ['.js', '.html']
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
path: dest,
|
|
||||||
filename: '[name].[hash].js',
|
|
||||||
chunkFilename: '[name].[id].js',
|
|
||||||
publicPath: '/webpack/'
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.html$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
use: {
|
|
||||||
loader: 'svelte-loader',
|
|
||||||
options: {
|
|
||||||
emitCss: true,
|
|
||||||
cascade: false,
|
|
||||||
store: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.css$/,
|
|
||||||
use: ExtractTextPlugin.extract({
|
|
||||||
fallback: 'style-loader',
|
|
||||||
use: [{ loader: 'css-loader', options: { sourceMap: dev } }]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
new ExtractTextPlugin('main.css'),
|
|
||||||
!dev && new webpack.optimize.ModuleConcatenationPlugin(),
|
|
||||||
!dev && new UglifyJSPlugin()
|
|
||||||
].filter(Boolean),
|
|
||||||
devtool: dev ? 'inline-source-map' : false
|
|
||||||
});
|
|
||||||
|
|
||||||
if (false) { // TODO watch in dev
|
|
||||||
// TODO how can we invalidate compiler.app when watcher restarts?
|
|
||||||
compiler.app = new Promise((fulfil, reject) => {
|
|
||||||
_.watch({}, (err, stats) => {
|
|
||||||
if (err || stats.hasErrors()) {
|
|
||||||
// TODO handle errors
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename = stats.toJson().assetsByChunkName.main;
|
|
||||||
fulfil(`/webpack/${filename}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
compiler.app = new Promise((fulfil, reject) => {
|
|
||||||
_.run((err, stats) => {
|
|
||||||
if (err || stats.hasErrors()) {
|
|
||||||
// TODO handle errors
|
|
||||||
}
|
|
||||||
|
|
||||||
const filename = stats.toJson().assetsByChunkName.main;
|
|
||||||
fulfil(`/webpack/${filename}`);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return compiler;
|
|
||||||
};
|
|
||||||
41
webpack/config.js
Normal file
41
webpack/config.js
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
const path = require('path');
|
||||||
|
const route_manager = require('../lib/route_manager.js');
|
||||||
|
const { src, dest, dev, server_routes } = require('../lib/config.js');
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
dev,
|
||||||
|
|
||||||
|
client: {
|
||||||
|
entry: () => {
|
||||||
|
return {
|
||||||
|
main: `${dest}/main.js`
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
output: () => {
|
||||||
|
return {
|
||||||
|
path: `${dest}/client`,
|
||||||
|
filename: '[name].[hash].js',
|
||||||
|
chunkFilename: '[name].[id].[hash].js',
|
||||||
|
publicPath: '/client/'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
server: {
|
||||||
|
entry: () => {
|
||||||
|
return {
|
||||||
|
server_routes
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
output: () => {
|
||||||
|
return {
|
||||||
|
path: `${dest}/server`,
|
||||||
|
filename: '[name].[hash].js',
|
||||||
|
chunkFilename: '[name].[id].[hash].js',
|
||||||
|
libraryTarget: 'commonjs2'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
1
webpack/hmr.js
Normal file
1
webpack/hmr.js
Normal file
@@ -0,0 +1 @@
|
|||||||
|
import 'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000';
|
||||||
Reference in New Issue
Block a user