diff --git a/chunk1.js b/chunk1.js new file mode 100644 index 0000000..cc695a8 --- /dev/null +++ b/chunk1.js @@ -0,0 +1,12 @@ +'use strict'; + +var path = require('path'); + +var dev = function () { return process.env.NODE_ENV !== 'production'; }; +var src = function () { return path.resolve(process.env.SAPPER_ROUTES || 'routes'); }; +var dest = function () { return path.resolve(process.env.SAPPER_DEST || '.sapper'); }; + +exports.dev = dev; +exports.src = src; +exports.dest = dest; +//# sourceMappingURL=./chunk1.js.map diff --git a/chunk1.js.map b/chunk1.js.map new file mode 100644 index 0000000..19e3ccb --- /dev/null +++ b/chunk1.js.map @@ -0,0 +1 @@ +{"version":3,"file":"chunk1.js","sources":["src/config.ts"],"sourcesContent":["import * as path from 'path';\n\nexport const dev = () => process.env.NODE_ENV !== 'production';\nexport const src = () => path.resolve(process.env.SAPPER_ROUTES || 'routes');\nexport const dest = () => path.resolve(process.env.SAPPER_DEST || '.sapper');\n"],"names":["path.resolve"],"mappings":";;;;IAEa,GAAG,GAAG,cAAM,OAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,GAAA,CAAC;AAC/D,IAAa,GAAG,GAAG,cAAM,OAAAA,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,QAAQ,CAAC,GAAA,CAAC;AAC7E,IAAa,IAAI,GAAG,cAAM,OAAAA,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,SAAS,CAAC,GAAA;;;;;;"} \ No newline at end of file diff --git a/cli.ts.js b/cli.ts.js new file mode 100644 index 0000000..158cb90 --- /dev/null +++ b/cli.ts.js @@ -0,0 +1,504 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var tslib_1 = require('tslib'); +var fs = require('fs'); +var path = require('path'); +var clorox = require('clorox'); +var mkdirp = _interopDefault(require('mkdirp')); +var rimraf = _interopDefault(require('rimraf')); +var __core_ts_js = require('./core.ts.js'); +var __chunk1_js = require('./chunk1.js'); +var child_process = require('child_process'); +var sander = require('sander'); +var polka = _interopDefault(require('polka')); +var cheerio = _interopDefault(require('cheerio')); +var URL = _interopDefault(require('url-parse')); +var fetch = _interopDefault(require('node-fetch')); +var ports = require('port-authority'); +var http = require('http'); +var format_messages = _interopDefault(require('webpack-format-messages')); +var prettyMs = _interopDefault(require('pretty-ms')); +var sade = _interopDefault(require('sade')); + +function build() { + return tslib_1.__awaiter(this, void 0, void 0, function () { + var output, routes, _a, client, server, serviceworker, client_stats, server_stats, serviceworker_stats; + return tslib_1.__generator(this, function (_b) { + switch (_b.label) { + case 0: + output = __chunk1_js.dest(); + mkdirp.sync(output); + rimraf.sync(path.join(output, '**/*')); + routes = __core_ts_js.create_routes(); + // create app/manifest/client.js and app/manifest/server.js + __core_ts_js.create_app({ routes: routes, src: __chunk1_js.src, dev: __chunk1_js.dev }); + _a = __core_ts_js.create_compilers(), client = _a.client, server = _a.server, serviceworker = _a.serviceworker; + return [4 /*yield*/, compile(client)]; + case 1: + client_stats = _b.sent(); + console.log(clorox.inverse("\nbuilt client")); + console.log(client_stats.toString({ colors: true })); + fs.writeFileSync(path.join(output, 'client_info.json'), JSON.stringify(client_stats.toJson())); + return [4 /*yield*/, compile(server)]; + case 2: + server_stats = _b.sent(); + console.log(clorox.inverse("\nbuilt server")); + console.log(server_stats.toString({ colors: true })); + if (!serviceworker) return [3 /*break*/, 4]; + __core_ts_js.create_serviceworker({ + routes: routes, + client_files: client_stats.toJson().assets.map(function (chunk) { return "/client/" + chunk.name; }), + src: __chunk1_js.src + }); + return [4 /*yield*/, compile(serviceworker)]; + case 3: + serviceworker_stats = _b.sent(); + console.log(clorox.inverse("\nbuilt service worker")); + console.log(serviceworker_stats.toString({ colors: true })); + _b.label = 4; + case 4: return [2 /*return*/]; + } + }); + }); +} +function compile(compiler) { + return new Promise(function (fulfil, reject) { + compiler.run(function (err, stats) { + if (err) { + reject(err); + process.exit(1); + } + if (stats.hasErrors()) { + console.error(stats.toString({ colors: true })); + reject(new Error("Encountered errors while building app")); + } + else { + fulfil(stats); + } + }); + }); +} + +var app = polka(); +function exporter(export_dir) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + function handle(url) { + if (url.origin !== origin) + return; + if (seen.has(url.pathname)) + return; + seen.add(url.pathname); + return fetch(url.href) + .then(function (r) { + if (r.headers.get('Content-Type') === 'text/html') { + return r.text().then(function (body) { + var $ = cheerio.load(body); + var hrefs = []; + $('a[href]').each(function (i, $a) { + hrefs.push($a.attribs.href); + }); + return hrefs.reduce(function (promise, href) { + return promise.then(function () { return handle(new URL(href, url.href)); }); + }, Promise.resolve()); + }); + } + })["catch"](function (err) { + console.error("Error rendering " + url.pathname + ": " + err.message); + }); + } + var build_dir, port, origin, proc, seen, saved; + return tslib_1.__generator(this, function (_a) { + switch (_a.label) { + case 0: + build_dir = __chunk1_js.dest(); + // Prep output directory + sander.rimrafSync(export_dir); + sander.copydirSync('assets').to(export_dir); + sander.copydirSync(build_dir, 'client').to(export_dir, 'client'); + if (sander.existsSync(build_dir, 'service-worker.js')) { + sander.copyFileSync(build_dir, 'service-worker.js').to(export_dir, 'service-worker.js'); + } + return [4 /*yield*/, ports.find(3000)]; + case 1: + port = _a.sent(); + origin = "http://localhost:" + port; + proc = child_process.fork(path.resolve(build_dir + "/server.js"), [], { + cwd: process.cwd(), + env: { + PORT: port, + NODE_ENV: 'production', + SAPPER_DEST: build_dir, + SAPPER_EXPORT: 'true' + } + }); + seen = new Set(); + saved = new Set(); + proc.on('message', function (message) { + if (!message.__sapper__) + return; + var url = new URL(message.url, origin); + if (saved.has(url.pathname)) + return; + saved.add(url.pathname); + if (message.type === 'text/html') { + var file = export_dir + "/" + url.pathname + "/index.html"; + sander.writeFileSync(file, message.body); + } + else { + var file = export_dir + "/" + url.pathname; + sander.writeFileSync(file, message.body); + } + }); + return [2 /*return*/, ports.wait(port) + .then(function () { return handle(new URL(origin)); }) // TODO all static routes + .then(function () { return proc.kill(); })]; + } + }); + }); +} + +function deferred() { + var d = {}; + d.promise = new Promise(function (fulfil, reject) { + d.fulfil = fulfil; + d.reject = reject; + }); + return d; +} +function create_hot_update_server(port, interval) { + if (interval === void 0) { interval = 10000; } + var clients = new Set(); + var server = http.createServer(function (req, res) { + if (req.url !== '/__sapper__') + return; + req.socket.setKeepAlive(true); + res.writeHead(200, { + 'Access-Control-Allow-Origin': '*', + 'Access-Control-Allow-Headers': 'Cache-Control', + 'Content-Type': 'text/event-stream;charset=utf-8', + 'Cache-Control': 'no-cache, no-transform', + 'Connection': 'keep-alive', + // While behind nginx, event stream should not be buffered: + // http://nginx.org/docs/http/ngx_http_proxy_module.html#proxy_buffering + 'X-Accel-Buffering': 'no' + }); + res.write('\n'); + clients.add(res); + req.on('close', function () { + clients["delete"](res); + }); + }); + server.listen(port); + function send(data) { + clients.forEach(function (client) { + client.write("data: " + JSON.stringify(data) + "\n\n"); + }); + } + setInterval(function () { + send(null); + }, interval); + return { send: send }; +} +function dev(port) { + return tslib_1.__awaiter(this, void 0, void 0, function () { + function restart_build(filename) { + if (restarting) + return; + restarting = true; + build = { + unique_warnings: new Set(), + unique_errors: new Set() + }; + process.nextTick(function () { + restarting = false; + }); + console.log("\n" + clorox.bold.cyan(path.relative(process.cwd(), filename)) + " changed. rebuilding..."); + } + function watch(compiler, _a) { + var name = _a.name, _b = _a.invalid, invalid = _b === void 0 ? noop : _b, _c = _a.error, error = _c === void 0 ? noop : _c, result = _a.result; + compiler.hooks.invalid.tap('sapper', function (filename) { + invalid(filename); + }); + compiler.watch({}, function (err, stats) { + if (err) { + console.error(clorox.red("\u2717 " + name)); + console.error(clorox.red(err.message)); + error(err); + } + else { + var messages = format_messages(stats); + var info = stats.toJson(); + if (messages.errors.length > 0) { + console.log(clorox.bold.red("\u2717 " + name)); + var filtered = messages.errors.filter(function (message) { + return !build.unique_errors.has(message); + }); + filtered.forEach(function (message) { + build.unique_errors.add(message); + console.log(message); + }); + var hidden = messages.errors.length - filtered.length; + if (hidden > 0) { + console.log(hidden + " duplicate " + (hidden === 1 ? 'error' : 'errors') + " hidden\n"); + } + } + else { + if (messages.warnings.length > 0) { + console.log(clorox.bold.yellow("\u2022 " + name)); + var filtered = messages.warnings.filter(function (message) { + return !build.unique_warnings.has(message); + }); + filtered.forEach(function (message) { + build.unique_warnings.add(message); + console.log(message + "\n"); + }); + var hidden = messages.warnings.length - filtered.length; + if (hidden > 0) { + console.log(hidden + " duplicate " + (hidden === 1 ? 'warning' : 'warnings') + " hidden\n"); + } + } + else { + console.log(clorox.bold.green("\u2714 " + name) + " " + clorox.gray("(" + prettyMs(info.time) + ")")); + } + result(info); + } + } + }); + } + var dir, dev_port, routes, hot_update_server, proc, deferreds, restarting, build, compilers, watch_serviceworker; + return tslib_1.__generator(this, function (_a) { + switch (_a.label) { + case 0: + process.env.NODE_ENV = 'development'; + dir = __chunk1_js.dest(); + rimraf.sync(dir); + mkdirp.sync(dir); + return [4 /*yield*/, ports.find(10000)]; + case 1: + dev_port = _a.sent(); + routes = __core_ts_js.create_routes(); + __core_ts_js.create_app({ routes: routes, dev_port: dev_port }); + hot_update_server = create_hot_update_server(dev_port); + watch_files('routes/**/*', ['add', 'unlink'], function () { + var routes = __core_ts_js.create_routes(); + __core_ts_js.create_app({ routes: routes, dev_port: dev_port }); + }); + watch_files('app/template.html', ['change'], function () { + hot_update_server.send({ + action: 'reload' + }); + }); + process.on('exit', function () { + // sometimes webpack crashes, so we need to kill our children + if (proc) + proc.kill(); + }); + deferreds = { + server: deferred(), + client: deferred() + }; + restarting = false; + build = { + unique_warnings: new Set(), + unique_errors: new Set() + }; + compilers = __core_ts_js.create_compilers(); + watch(compilers.server, { + name: 'server', + invalid: function (filename) { + restart_build(filename); + // TODO print message + deferreds.server = deferred(); + }, + result: function (info) { + // TODO log compile errors/warnings + fs.writeFileSync(path.join(dir, 'server_info.json'), JSON.stringify(info, null, ' ')); + deferreds.client.promise.then(function () { + function restart() { + ports.wait(port).then(deferreds.server.fulfil); + } + if (proc) { + proc.kill(); + proc.on('exit', restart); + } + else { + restart(); + } + proc = child_process.fork(dir + "/server.js", [], { + cwd: process.cwd(), + env: Object.assign({ + PORT: port + }, process.env) + }); + }); + } + }); + watch(compilers.client, { + name: 'client', + invalid: function (filename) { + restart_build(filename); + deferreds.client = deferred(); + // TODO we should delete old assets. due to a webpack bug + // i don't even begin to comprehend, this is apparently + // quite difficult + }, + result: function (info) { + fs.writeFileSync(path.join(dir, 'client_info.json'), JSON.stringify(info, null, ' ')); + deferreds.client.fulfil(); + var client_files = info.assets.map(function (chunk) { return "/client/" + chunk.name; }); + deferreds.server.promise.then(function () { + hot_update_server.send({ + status: 'completed' + }); + }); + __core_ts_js.create_serviceworker({ + routes: __core_ts_js.create_routes(), + client_files: client_files + }); + watch_serviceworker(); + } + }); + watch_serviceworker = compilers.serviceworker + ? function () { + watch_serviceworker = noop; + watch(compilers.serviceworker, { + name: 'service worker', + result: function (info) { + fs.writeFileSync(path.join(dir, 'serviceworker_info.json'), JSON.stringify(info, null, ' ')); + } + }); + } + : noop; + return [2 /*return*/]; + } + }); + }); +} +function noop() { } +function watch_files(pattern, events, callback) { + var chokidar = require('chokidar'); + var watcher = chokidar.watch(pattern, { + persistent: true, + ignoreInitial: true + }); + events.forEach(function (event) { + watcher.on(event, callback); + }); +} + +var version = "0.8.4"; + +var _this = undefined; +var prog = sade('sapper').version(version); +prog.command('dev') + .describe('Start a development server') + .option('-p, --port', 'Specify a port') + .action(function (opts) { return tslib_1.__awaiter(_this, void 0, void 0, function () { + var port; + return tslib_1.__generator(this, function (_a) { + switch (_a.label) { + case 0: + port = opts.port || +process.env.PORT; + if (!port) return [3 /*break*/, 2]; + return [4 /*yield*/, ports.check(port)]; + case 1: + if (!(_a.sent())) { + console.log(clorox.bold.red("> Port " + port + " is unavailable")); + return [2 /*return*/]; + } + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, ports.find(3000)]; + case 3: + port = _a.sent(); + _a.label = 4; + case 4: + dev(port); + return [2 /*return*/]; + } + }); +}); }); +prog.command('build [dest]') + .describe('Create a production-ready version of your app') + .action(function (dest) { + if (dest === void 0) { dest = 'build'; } + console.log("> Building..."); + process.env.NODE_ENV = 'production'; + process.env.SAPPER_DEST = dest; + var start = Date.now(); + build() + .then(function () { + var elapsed = Date.now() - start; + console.error("\n> Finished in " + prettyMs(elapsed) + ". Type " + clorox.bold.cyan(dest === 'build' ? 'npx sapper start' : "npx sapper start " + dest) + " to run the app."); + })["catch"](function (err) { + console.error(err ? err.details || err.stack || err.message || err : 'Unknown error'); + }); +}); +prog.command('start [dir]') + .describe('Start your app') + .option('-p, --port', 'Specify a port') + .action(function (dir, opts) { + if (dir === void 0) { dir = 'build'; } + return tslib_1.__awaiter(_this, void 0, void 0, function () { + var port, resolved, server; + return tslib_1.__generator(this, function (_a) { + switch (_a.label) { + case 0: + port = opts.port || +process.env.PORT; + resolved = path.resolve(dir); + server = path.resolve(dir, 'server.js'); + if (!fs.existsSync(server)) { + console.log(clorox.bold.red("> " + dir + "/server.js does not exist \u2014 type " + clorox.bold.cyan(dir === 'build' ? "npx sapper build" : "npx sapper build " + dir) + " to create it")); + return [2 /*return*/]; + } + if (!port) return [3 /*break*/, 2]; + return [4 /*yield*/, ports.check(port)]; + case 1: + if (!(_a.sent())) { + console.log(clorox.bold.red("> Port " + port + " is unavailable")); + return [2 /*return*/]; + } + return [3 /*break*/, 4]; + case 2: return [4 /*yield*/, ports.find(3000)]; + case 3: + port = _a.sent(); + _a.label = 4; + case 4: + child_process.fork(server, [], { + cwd: process.cwd(), + env: Object.assign({ + NODE_ENV: 'production', + PORT: port, + SAPPER_DEST: dir + }, process.env) + }); + return [2 /*return*/]; + } + }); + }); +}); +prog.command('export [dest]') + .describe('Export your app as static files (if possible)') + .action(function (dest) { + if (dest === void 0) { dest = 'export'; } + console.log("> Building..."); + process.env.NODE_ENV = 'production'; + process.env.SAPPER_DEST = '.sapper/.export'; + var start = Date.now(); + build() + .then(function () { + var elapsed = Date.now() - start; + console.error("\n> Built in " + prettyMs(elapsed) + ". Exporting..."); + }) + .then(function () { return exporter(dest); }) + .then(function () { + var elapsed = Date.now() - start; + console.error("\n> Finished in " + prettyMs(elapsed) + ". Type " + clorox.bold.cyan("npx serve " + dest) + " to run the app."); + })["catch"](function (err) { + console.error(err ? err.details || err.stack || err.message || err : 'Unknown error'); + }); +}); +// TODO upgrade +prog.parse(process.argv); +//# sourceMappingURL=./cli.ts.js.map diff --git a/cli.ts.js.map b/cli.ts.js.map new file mode 100644 index 0000000..bcfceef --- /dev/null +++ b/cli.ts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"cli.ts.js","sources":["src/cli/build.ts","src/cli/export.ts","src/cli/dev.ts","src/cli.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport * as clorox from 'clorox';\nimport mkdirp from 'mkdirp';\nimport rimraf from 'rimraf';\nimport { create_compilers, create_app, create_routes, create_serviceworker } from '../core'\nimport { src, dest, dev } from '../config';\n\nexport default async function build() {\n\tconst output = dest();\n\n\tmkdirp.sync(output);\n\trimraf.sync(path.join(output, '**/*'));\n\n\tconst routes = create_routes();\n\n\t// create app/manifest/client.js and app/manifest/server.js\n\tcreate_app({ routes, src, dev });\n\n\tconst { client, server, serviceworker } = create_compilers();\n\n\tconst client_stats = await compile(client);\n\tconsole.log(clorox.inverse(`\\nbuilt client`));\n\tconsole.log(client_stats.toString({ colors: true }));\n\tfs.writeFileSync(path.join(output, 'client_info.json'), JSON.stringify(client_stats.toJson()));\n\n\tconst server_stats = await compile(server);\n\tconsole.log(clorox.inverse(`\\nbuilt server`));\n\tconsole.log(server_stats.toString({ colors: true }));\n\n\tlet serviceworker_stats;\n\n\tif (serviceworker) {\n\t\tcreate_serviceworker({\n\t\t\troutes,\n\t\t\tclient_files: client_stats.toJson().assets.map((chunk: { name: string }) => `/client/${chunk.name}`),\n\t\t\tsrc\n\t\t});\n\n\t\tserviceworker_stats = await compile(serviceworker);\n\t\tconsole.log(clorox.inverse(`\\nbuilt service worker`));\n\t\tconsole.log(serviceworker_stats.toString({ colors: true }));\n\t}\n}\n\nfunction compile(compiler: any) {\n\treturn new Promise((fulfil, reject) => {\n\t\tcompiler.run((err: Error, stats: any) => {\n\t\t\tif (err) {\n\t\t\t\treject(err);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tif (stats.hasErrors()) {\n\t\t\t\tconsole.error(stats.toString({ colors: true }));\n\t\t\t\treject(new Error(`Encountered errors while building app`));\n\t\t\t}\n\n\t\t\telse {\n\t\t\t\tfulfil(stats);\n\t\t\t}\n\t\t});\n\t});\n}\n","import * as child_process from 'child_process';\nimport * as path from 'path';\nimport * as sander from 'sander';\nimport polka from 'polka';\nimport cheerio from 'cheerio';\nimport URL from 'url-parse';\nimport fetch from 'node-fetch';\nimport * as ports from 'port-authority';\nimport { dest } from '../config';\n\nconst app = polka();\n\nexport default async function exporter(export_dir: string) {\n\tconst build_dir = dest();\n\n\t// Prep output directory\n\tsander.rimrafSync(export_dir);\n\n\tsander.copydirSync('assets').to(export_dir);\n\tsander.copydirSync(build_dir, 'client').to(export_dir, 'client');\n\n\tif (sander.existsSync(build_dir, 'service-worker.js')) {\n\t\tsander.copyFileSync(build_dir, 'service-worker.js').to(export_dir, 'service-worker.js');\n\t}\n\n\tconst port = await ports.find(3000);\n\n\tconst origin = `http://localhost:${port}`;\n\n\tconst proc = child_process.fork(path.resolve(`${build_dir}/server.js`), [], {\n\t\tcwd: process.cwd(),\n\t\tenv: {\n\t\t\tPORT: port,\n\t\t\tNODE_ENV: 'production',\n\t\t\tSAPPER_DEST: build_dir,\n\t\t\tSAPPER_EXPORT: 'true'\n\t\t}\n\t});\n\n\tconst seen = new Set();\n\tconst saved = new Set();\n\n\tproc.on('message', message => {\n\t\tif (!message.__sapper__) return;\n\n\t\tconst url = new URL(message.url, origin);\n\n\t\tif (saved.has(url.pathname)) return;\n\t\tsaved.add(url.pathname);\n\n\t\tif (message.type === 'text/html') {\n\t\t\tconst file = `${export_dir}/${url.pathname}/index.html`;\n\t\t\tsander.writeFileSync(file, message.body);\n\t\t} else {\n\t\t\tconst file = `${export_dir}/${url.pathname}`;\n\t\t\tsander.writeFileSync(file, message.body);\n\t\t}\n\t});\n\n\tfunction handle(url: URL) {\n\t\tif (url.origin !== origin) return;\n\n\t\tif (seen.has(url.pathname)) return;\n\t\tseen.add(url.pathname);\n\n\t\treturn fetch(url.href)\n\t\t\t.then(r => {\n\t\t\t\tif (r.headers.get('Content-Type') === 'text/html') {\n\t\t\t\t\treturn r.text().then((body: string) => {\n\t\t\t\t\t\tconst $ = cheerio.load(body);\n\t\t\t\t\t\tconst hrefs: string[] = [];\n\n\t\t\t\t\t\t$('a[href]').each((i: number, $a) => {\n\t\t\t\t\t\t\threfs.push($a.attribs.href);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\treturn hrefs.reduce((promise, href) => {\n\t\t\t\t\t\t\treturn promise.then(() => handle(new URL(href, url.href)));\n\t\t\t\t\t\t}, Promise.resolve());\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.catch((err: Error) => {\n\t\t\t\tconsole.error(`Error rendering ${url.pathname}: ${err.message}`);\n\t\t\t});\n\t}\n\n\treturn ports.wait(port)\n\t\t.then(() => handle(new URL(origin))) // TODO all static routes\n\t\t.then(() => proc.kill());\n}","import * as fs from 'fs';\nimport * as path from 'path';\nimport * as net from 'net';\nimport * as clorox from 'clorox';\nimport * as child_process from 'child_process';\nimport * as http from 'http';\nimport mkdirp from 'mkdirp';\nimport rimraf from 'rimraf';\nimport format_messages from 'webpack-format-messages';\nimport prettyMs from 'pretty-ms';\nimport * as ports from 'port-authority';\nimport { dest } from '../config';\nimport { create_compilers, create_app, create_routes, create_serviceworker } from '../core';\n\ntype Deferred = {\n\tpromise?: Promise;\n\tfulfil?: (value?: any) => void;\n\treject?: (err: Error) => void;\n}\n\nfunction deferred() {\n\tconst d: Deferred = {};\n\n\td.promise = new Promise((fulfil, reject) => {\n\t\td.fulfil = fulfil;\n\t\td.reject = reject;\n\t});\n\n\treturn d;\n}\n\nfunction create_hot_update_server(port: number, interval = 10000) {\n\tconst clients = new Set();\n\n\tconst server = http.createServer((req, res) => {\n\t\tif (req.url !== '/__sapper__') return;\n\n\t\treq.socket.setKeepAlive(true);\n\t\tres.writeHead(200, {\n\t\t\t'Access-Control-Allow-Origin': '*',\n\t\t\t'Access-Control-Allow-Headers': 'Cache-Control',\n\t\t\t'Content-Type': 'text/event-stream;charset=utf-8',\n\t\t\t'Cache-Control': 'no-cache, no-transform',\n\t\t\t'Connection': 'keep-alive',\n\t\t\t// While behind nginx, event stream should not be buffered:\n\t\t\t// http://nginx.org/docs/http/ngx_http_proxy_module.html#proxy_buffering\n\t\t\t'X-Accel-Buffering': 'no'\n\t\t});\n\n\t\tres.write('\\n');\n\n\t\tclients.add(res);\n\t\treq.on('close', () => {\n\t\t\tclients.delete(res);\n\t\t});\n\t});\n\n\tserver.listen(port);\n\n\tfunction send(data: any) {\n\t\tclients.forEach(client => {\n\t\t\tclient.write(`data: ${JSON.stringify(data)}\\n\\n`);\n\t\t});\n\t}\n\n\tsetInterval(() => {\n\t\tsend(null)\n\t}, interval);\n\n\treturn { send };\n}\n\nexport default async function dev(port: number) {\n\tprocess.env.NODE_ENV = 'development';\n\n\tconst dir = dest();\n\trimraf.sync(dir);\n\tmkdirp.sync(dir);\n\n\tconst dev_port = await ports.find(10000);\n\n\tconst routes = create_routes();\n\tcreate_app({ routes, dev_port });\n\n\tconst hot_update_server = create_hot_update_server(dev_port);\n\n\twatch_files('routes/**/*', ['add', 'unlink'], () => {\n\t\tconst routes = create_routes();\n\t\tcreate_app({ routes, dev_port });\n\t});\n\n\twatch_files('app/template.html', ['change'], () => {\n\t\thot_update_server.send({\n\t\t\taction: 'reload'\n\t\t});\n\t});\n\n\tlet proc: child_process.ChildProcess;\n\n\tprocess.on('exit', () => {\n\t\t// sometimes webpack crashes, so we need to kill our children\n\t\tif (proc) proc.kill();\n\t});\n\n\tconst deferreds = {\n\t\tserver: deferred(),\n\t\tclient: deferred()\n\t};\n\n\tlet restarting = false;\n\tlet build = {\n\t\tunique_warnings: new Set(),\n\t\tunique_errors: new Set()\n\t};\n\n\tfunction restart_build(filename: string) {\n\t\tif (restarting) return;\n\n\t\trestarting = true;\n\t\tbuild = {\n\t\t\tunique_warnings: new Set(),\n\t\t\tunique_errors: new Set()\n\t\t};\n\n\t\tprocess.nextTick(() => {\n\t\t\trestarting = false;\n\t\t});\n\n\t\tconsole.log(`\\n${clorox.bold.cyan(path.relative(process.cwd(), filename))} changed. rebuilding...`);\n\t}\n\n\t// TODO watch the configs themselves?\n\tconst compilers = create_compilers();\n\n\tfunction watch(compiler: any, { name, invalid = noop, error = noop, result }: {\n\t\tname: string,\n\t\tinvalid?: (filename: string) => void;\n\t\terror?: (error: Error) => void;\n\t\tresult: (stats: any) => void;\n\t}) {\n\t\tcompiler.hooks.invalid.tap('sapper', (filename: string) => {\n\t\t\tinvalid(filename);\n\t\t});\n\n\t\tcompiler.watch({}, (err: Error, stats: any) => {\n\t\t\tif (err) {\n\t\t\t\tconsole.error(clorox.red(`✗ ${name}`));\n\t\t\t\tconsole.error(clorox.red(err.message));\n\t\t\t\terror(err);\n\t\t\t} else {\n\t\t\t\tconst messages = format_messages(stats);\n\t\t\t\tconst info = stats.toJson();\n\n\t\t\t\tif (messages.errors.length > 0) {\n\t\t\t\t\tconsole.log(clorox.bold.red(`✗ ${name}`));\n\n\t\t\t\t\tconst filtered = messages.errors.filter((message: string) => {\n\t\t\t\t\t\treturn !build.unique_errors.has(message);\n\t\t\t\t\t});\n\n\t\t\t\t\tfiltered.forEach((message: string) => {\n\t\t\t\t\t\tbuild.unique_errors.add(message);\n\t\t\t\t\t\tconsole.log(message);\n\t\t\t\t\t});\n\n\t\t\t\t\tconst hidden = messages.errors.length - filtered.length;\n\t\t\t\t\tif (hidden > 0) {\n\t\t\t\t\t\tconsole.log(`${hidden} duplicate ${hidden === 1 ? 'error' : 'errors'} hidden\\n`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tif (messages.warnings.length > 0) {\n\t\t\t\t\t\tconsole.log(clorox.bold.yellow(`• ${name}`));\n\n\t\t\t\t\t\tconst filtered = messages.warnings.filter((message: string) => {\n\t\t\t\t\t\t\treturn !build.unique_warnings.has(message);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tfiltered.forEach((message: string) => {\n\t\t\t\t\t\t\tbuild.unique_warnings.add(message);\n\t\t\t\t\t\t\tconsole.log(`${message}\\n`);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tconst hidden = messages.warnings.length - filtered.length;\n\t\t\t\t\t\tif (hidden > 0) {\n\t\t\t\t\t\t\tconsole.log(`${hidden} duplicate ${hidden === 1 ? 'warning' : 'warnings'} hidden\\n`);\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(`${clorox.bold.green(`✔ ${name}`)} ${clorox.gray(`(${prettyMs(info.time)})`)}`);\n\t\t\t\t\t}\n\n\t\t\t\t\tresult(info);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\twatch(compilers.server, {\n\t\tname: 'server',\n\n\t\tinvalid: filename => {\n\t\t\trestart_build(filename);\n\t\t\t// TODO print message\n\t\t\tdeferreds.server = deferred();\n\t\t},\n\n\t\tresult: info => {\n\t\t\t// TODO log compile errors/warnings\n\n\t\t\tfs.writeFileSync(path.join(dir, 'server_info.json'), JSON.stringify(info, null, ' '));\n\n\t\t\tdeferreds.client.promise.then(() => {\n\t\t\t\tfunction restart() {\n\t\t\t\t\tports.wait(port).then(deferreds.server.fulfil);\n\t\t\t\t}\n\n\t\t\t\tif (proc) {\n\t\t\t\t\tproc.kill();\n\t\t\t\t\tproc.on('exit', restart);\n\t\t\t\t} else {\n\t\t\t\t\trestart();\n\t\t\t\t}\n\n\t\t\t\tproc = child_process.fork(`${dir}/server.js`, [], {\n\t\t\t\t\tcwd: process.cwd(),\n\t\t\t\t\tenv: Object.assign({\n\t\t\t\t\t\tPORT: port\n\t\t\t\t\t}, process.env)\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t});\n\n\twatch(compilers.client, {\n\t\tname: 'client',\n\n\t\tinvalid: filename => {\n\t\t\trestart_build(filename);\n\t\t\tdeferreds.client = deferred();\n\n\t\t\t// TODO we should delete old assets. due to a webpack bug\n\t\t\t// i don't even begin to comprehend, this is apparently\n\t\t\t// quite difficult\n\t\t},\n\n\t\tresult: info => {\n\t\t\tfs.writeFileSync(path.join(dir, 'client_info.json'), JSON.stringify(info, null, ' '));\n\t\t\tdeferreds.client.fulfil();\n\n\t\t\tconst client_files = info.assets.map((chunk: { name: string }) => `/client/${chunk.name}`);\n\n\t\t\tdeferreds.server.promise.then(() => {\n\t\t\t\thot_update_server.send({\n\t\t\t\t\tstatus: 'completed'\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tcreate_serviceworker({\n\t\t\t\troutes: create_routes(),\n\t\t\t\tclient_files\n\t\t\t});\n\n\t\t\twatch_serviceworker();\n\t\t}\n\t});\n\n\tlet watch_serviceworker = compilers.serviceworker\n\t\t? function() {\n\t\t\twatch_serviceworker = noop;\n\n\t\t\twatch(compilers.serviceworker, {\n\t\t\t\tname: 'service worker',\n\n\t\t\t\tresult: info => {\n\t\t\t\t\tfs.writeFileSync(path.join(dir, 'serviceworker_info.json'), JSON.stringify(info, null, ' '));\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t: noop;\n}\n\nfunction noop() {}\n\nfunction watch_files(pattern: string, events: string[], callback: () => void) {\n\tconst chokidar = require('chokidar');\n\n\tconst watcher = chokidar.watch(pattern, {\n\t\tpersistent: true,\n\t\tignoreInitial: true\n\t});\n\n\tevents.forEach(event => {\n\t\twatcher.on(event, callback);\n\t});\n}\n","import * as fs from 'fs';\nimport * as path from 'path';\nimport * as child_process from 'child_process';\nimport sade from 'sade';\nimport * as clorox from 'clorox';\nimport prettyMs from 'pretty-ms';\nimport help from './cli/help.md';\nimport build from './cli/build';\nimport exporter from './cli/export';\nimport dev from './cli/dev';\nimport upgrade from './cli/upgrade';\nimport * as ports from 'port-authority';\nimport * as pkg from '../package.json';\n\nconst prog = sade('sapper').version(pkg.version);\n\nprog.command('dev')\n\t.describe('Start a development server')\n\t.option('-p, --port', 'Specify a port')\n\t.action(async (opts: { port: number }) => {\n\t\tlet port = opts.port || +process.env.PORT;\n\n\t\tif (port) {\n\t\t\tif (!await ports.check(port)) {\n\t\t\t\tconsole.log(clorox.bold.red(`> Port ${port} is unavailable`));\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\tport = await ports.find(3000);\n\t\t}\n\n\t\tdev(port);\n\t});\n\nprog.command('build [dest]')\n\t.describe('Create a production-ready version of your app')\n\t.action((dest = 'build') => {\n\t\tconsole.log(`> Building...`);\n\n\t\tprocess.env.NODE_ENV = 'production';\n\t\tprocess.env.SAPPER_DEST = dest;\n\n\t\tconst start = Date.now();\n\n\t\tbuild()\n\t\t\t.then(() => {\n\t\t\t\tconst elapsed = Date.now() - start;\n\t\t\t\tconsole.error(`\\n> Finished in ${prettyMs(elapsed)}. Type ${clorox.bold.cyan(dest === 'build' ? 'npx sapper start' : `npx sapper start ${dest}`)} to run the app.`);\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\tconsole.error(err ? err.details || err.stack || err.message || err : 'Unknown error');\n\t\t\t});\n\t});\n\nprog.command('start [dir]')\n\t.describe('Start your app')\n\t.option('-p, --port', 'Specify a port')\n\t.action(async (dir = 'build', opts: { port: number }) => {\n\t\tlet port = opts.port || +process.env.PORT;\n\n\t\tconst resolved = path.resolve(dir);\n\t\tconst server = path.resolve(dir, 'server.js');\n\n\t\tif (!fs.existsSync(server)) {\n\t\t\tconsole.log(clorox.bold.red(`> ${dir}/server.js does not exist — type ${clorox.bold.cyan(dir === 'build' ? `npx sapper build` : `npx sapper build ${dir}`)} to create it`));\n\t\t\treturn;\n\t\t}\n\n\t\tif (port) {\n\t\t\tif (!await ports.check(port)) {\n\t\t\t\tconsole.log(clorox.bold.red(`> Port ${port} is unavailable`));\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\tport = await ports.find(3000);\n\t\t}\n\n\t\tchild_process.fork(server, [], {\n\t\t\tcwd: process.cwd(),\n\t\t\tenv: Object.assign({\n\t\t\t\tNODE_ENV: 'production',\n\t\t\t\tPORT: port,\n\t\t\t\tSAPPER_DEST: dir\n\t\t\t}, process.env)\n\t\t});\n\t});\n\nprog.command('export [dest]')\n\t.describe('Export your app as static files (if possible)')\n\t.action((dest = 'export') => {\n\t\tconsole.log(`> Building...`);\n\n\t\tprocess.env.NODE_ENV = 'production';\n\t\tprocess.env.SAPPER_DEST = '.sapper/.export';\n\n\t\tconst start = Date.now();\n\n\t\tbuild()\n\t\t\t.then(() => {\n\t\t\t\tconst elapsed = Date.now() - start;\n\t\t\t\tconsole.error(`\\n> Built in ${prettyMs(elapsed)}. Exporting...`);\n\t\t\t})\n\t\t\t.then(() => exporter(dest))\n\t\t\t.then(() => {\n\t\t\t\tconst elapsed = Date.now() - start;\n\t\t\t\tconsole.error(`\\n> Finished in ${prettyMs(elapsed)}. Type ${clorox.bold.cyan(`npx serve ${dest}`)} to run the app.`);\n\t\t\t})\n\t\t\t.catch(err => {\n\t\t\t\tconsole.error(err ? err.details || err.stack || err.message || err : 'Unknown error');\n\t\t\t});\n\t});\n\n// TODO upgrade\n\nprog.parse(process.argv);\n"],"names":["dest","path.join","create_routes","create_app","create_compilers","clorox.inverse","fs.writeFileSync","create_serviceworker","sander.rimrafSync","sander.copydirSync","sander.existsSync","sander.copyFileSync","ports.find","child_process.fork","path.resolve","sander.writeFileSync","ports.wait","http.createServer","clorox.bold","path.relative","clorox.red","clorox.gray","pkg.version","ports.check","fs.existsSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBASO,MAAM,GAAGA,gBAAI,EAAE,CAAC;oBAEtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;oBACp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AC,eAAe,CAAC,CAAC;IAE7B,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;IACpC,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,iBAAiB,CAAC;IAE5C,IAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEzB,KAAK,EAAE;SACL,IAAI,CAAC;QACL,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACnC,OAAO,CAAC,KAAK,CAAC,kBAAgB,QAAQ,CAAC,OAAO,CAAC,mBAAgB,CAAC,CAAC;KACjE,CAAC;SACD,IAAI,CAAC,cAAM,OAAA,QAAQ,CAAC,IAAI,CAAC,GAAA,CAAC;SAC1B,IAAI,CAAC;QACL,IAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACnC,OAAO,CAAC,KAAK,CAAC,qBAAmB,QAAQ,CAAC,OAAO,CAAC,eAAUK,WAAW,CAAC,IAAI,CAAC,eAAa,IAAM,CAAC,qBAAkB,CAAC,CAAC;KACrH,CAAC,CACD,OAAK,CAAA,CAAC,UAAA,GAAG;QACT,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,GAAG,eAAe,CAAC,CAAC;KACtF,CAAC,CAAC;CACJ,CAAC,CAAC;;AAIJ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"} \ No newline at end of file diff --git a/core.ts.js b/core.ts.js new file mode 100644 index 0000000..c6272d4 --- /dev/null +++ b/core.ts.js @@ -0,0 +1,229 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var fs = require('fs'); +var __chunk1_js = require('./chunk1.js'); +var path = require('path'); +var mkdirp = _interopDefault(require('mkdirp')); +var glob = _interopDefault(require('glob')); +var relative = _interopDefault(require('require-relative')); + +function write(file, code) { + fs.writeFileSync(file, code); + fudge_mtime(file); +} +function posixify(file) { + return file.replace(/[/\\]/g, '/'); +} +function fudge_mtime(file) { + // need to fudge the mtime so that webpack doesn't go doolally + var _a = fs.statSync(file), atime = _a.atime, mtime = _a.mtime; + fs.utimesSync(file, new Date(atime.getTime() - 999999), new Date(mtime.getTime() - 999999)); +} + +// in dev mode, we avoid touching the fs unnecessarily +var last_client_manifest = null; +var last_server_manifest = null; +function create_app(_a) { + var routes = _a.routes, dev_port = _a.dev_port; + mkdirp.sync('app/manifest'); + var client_manifest = generate_client(routes, dev_port); + var server_manifest = generate_server(routes); + if (client_manifest !== last_client_manifest) { + write("app/manifest/client.js", client_manifest); + last_client_manifest = client_manifest; + } + if (server_manifest !== last_server_manifest) { + write("app/manifest/server.js", server_manifest); + last_server_manifest = server_manifest; + } +} +function generate_client(routes, dev_port) { + var code = ("\n\t\t// This file is generated by Sapper \u2014 do not edit it!\n\t\texport const routes = [\n\t\t\t" + routes + .map(function (route) { + if (route.type !== 'page') { + return "{ pattern: " + route.pattern + ", ignore: true }"; + } + var file = posixify("../../routes/" + route.file); + if (route.id === '_4xx' || route.id === '_5xx') { + return "{ error: '" + route.id.slice(1) + "', load: () => import(/* webpackChunkName: \"" + route.id + "\" */ '" + file + "') }"; + } + var params = route.params.length === 0 + ? '{}' + : "{ " + route.params.map(function (part, i) { return part + ": match[" + (i + 1) + "]"; }).join(', ') + " }"; + return "{ pattern: " + route.pattern + ", params: " + (route.params.length > 0 ? "match" : "()") + " => (" + params + "), load: () => import(/* webpackChunkName: \"" + route.id + "\" */ '" + file + "') }"; + }) + .join(',\n\t') + "\n\t\t];").replace(/^\t\t/gm, '').trim(); + if (__chunk1_js.dev()) { + var sapper_dev_client = posixify(path.resolve(__dirname, 'sapper-dev-client.js')); + code += ("\n\n\t\t\tif (module.hot) {\n\t\t\t\timport('" + sapper_dev_client + "').then(client => {\n\t\t\t\t\tclient.connect(" + dev_port + ");\n\t\t\t\t});\n\t\t\t}").replace(/^\t{3}/gm, ''); + } + return code; +} +function generate_server(routes) { + var code = ("\n\t\t// This file is generated by Sapper \u2014 do not edit it!\n\t\t" + routes + .map(function (route) { + var file = posixify("../../routes/" + route.file); + return route.type === 'page' + ? "import " + route.id + " from '" + file + "';" + : "import * as " + route.id + " from '" + file + "';"; + }) + .join('\n') + "\n\n\t\texport const routes = [\n\t\t\t" + routes + .map(function (route) { + var file = posixify("../../" + route.file); + if (route.id === '_4xx' || route.id === '_5xx') { + return "{ error: '" + route.id.slice(1) + "', module: " + route.id + " }"; + } + var params = route.params.length === 0 + ? '{}' + : "{ " + route.params.map(function (part, i) { return part + ": match[" + (i + 1) + "]"; }).join(', ') + " }"; + return "{ id: '" + route.id + "', type: '" + route.type + "', pattern: " + route.pattern + ", params: " + (route.params.length > 0 ? "match" : "()") + " => (" + params + "), module: " + route.id + " }"; + }) + .join(',\n\t') + "\n\t\t];").replace(/^\t\t/gm, '').trim(); + return code; +} + +function create_serviceworker(_a) { + var routes = _a.routes, client_files = _a.client_files; + var assets = glob.sync('**', { cwd: 'assets', nodir: true }); + var code = ("\n\t\t// This file is generated by Sapper \u2014 do not edit it!\n\t\texport const timestamp = " + Date.now() + ";\n\n\t\texport const assets = [\n\t" + assets.map(function (x) { return "\"" + x + "\""; }).join(',\n\t') + "\n];\n\n\t\texport const shell = [\n\t" + client_files.map(function (x) { return "\"" + x + "\""; }).join(',\n\t') + "\n];\n\n\t\texport const routes = [\n\t" + routes.filter(function (r) { return r.type === 'page' && !/^_[45]xx$/.test(r.id); }).map(function (r) { return "{ pattern: " + r.pattern + " }"; }).join(',\n\t') + "\n];\n\t").replace(/^\t\t/gm, '').trim(); + write('app/manifest/service-worker.js', code); +} + +function create_compilers() { + var webpack = relative('webpack', process.cwd()); + var serviceworker_config = try_require(path.resolve('webpack/service-worker.config.js')); + return { + client: webpack(require(path.resolve('webpack/client.config.js'))), + server: webpack(require(path.resolve('webpack/server.config.js'))), + serviceworker: serviceworker_config && webpack(serviceworker_config) + }; +} +function try_require(specifier) { + try { + return require(specifier); + } + catch (err) { + if (err.code === 'MODULE_NOT_FOUND') + return null; + throw err; + } +} + +function create_routes(_a) { + var files = (_a === void 0 ? { files: glob.sync('**/*.*', { cwd: __chunk1_js.src(), nodir: true }) } : _a).files; + var routes = files + .map(function (file) { + if (/(^|\/|\\)_/.test(file)) + return; + if (/]\[/.test(file)) { + throw new Error("Invalid route " + file + " \u2014 parameters must be separated"); + } + var base = file.replace(/\.[^/.]+$/, ''); + var parts = base.split('/'); // glob output is always posix-style + if (parts[parts.length - 1] === 'index') + parts.pop(); + var id = (parts.join('_').replace(/[[\]]/g, '$').replace(/^\d/, '_$&').replace(/[^a-zA-Z0-9_$]/g, '_')) || '_'; + var params = []; + var param_pattern = /\[([^\]]+)\]/g; + var match; + while (match = param_pattern.exec(base)) { + params.push(match[1]); + } + // TODO can we do all this with sub-parts? or does + // nesting make that impossible? + var pattern_string = ''; + var i = parts.length; + var nested = true; + while (i--) { + var part = encodeURIComponent(parts[i].normalize()).replace(/%5B/g, '[').replace(/%5D/g, ']'); + var dynamic = ~part.indexOf('['); + if (dynamic) { + var matcher = part.replace(param_pattern, "([^/]+?)"); + pattern_string = nested ? "(?:\\/" + matcher + pattern_string + ")?" : "\\/" + matcher + pattern_string; + } + else { + nested = false; + pattern_string = "\\/" + part + pattern_string; + } + } + var pattern = new RegExp("^" + pattern_string + "\\/?$"); + var test = function (url) { return pattern.test(url); }; + var exec = function (url) { + var match = pattern.exec(url); + if (!match) + return; + var result = {}; + params.forEach(function (param, i) { + result[param] = match[i + 1]; + }); + return result; + }; + return { + id: id, + type: path.extname(file) === '.html' ? 'page' : 'route', + file: file, + pattern: pattern, + test: test, + exec: exec, + parts: parts, + params: params + }; + }) + .filter(Boolean) + .sort(function (a, b) { + if (a.file === '4xx.html' || a.file === '5xx.html') + return -1; + if (b.file === '4xx.html' || b.file === '5xx.html') + return 1; + var max = Math.max(a.parts.length, b.parts.length); + for (var i = 0; i < max; i += 1) { + var a_part = a.parts[i]; + var b_part = b.parts[i]; + if (!a_part) + return -1; + if (!b_part) + return 1; + var a_sub_parts = get_sub_parts(a_part); + var b_sub_parts = get_sub_parts(b_part); + var max_1 = Math.max(a_sub_parts.length, b_sub_parts.length); + for (var i_1 = 0; i_1 < max_1; i_1 += 1) { + var a_sub_part = a_sub_parts[i_1]; + var b_sub_part = b_sub_parts[i_1]; + if (!a_sub_part) + return 1; // b is more specific, so goes first + if (!b_sub_part) + return -1; + if (a_sub_part.dynamic !== b_sub_part.dynamic) { + return a_sub_part.dynamic ? 1 : -1; + } + if (!a_sub_part.dynamic && a_sub_part.content !== b_sub_part.content) { + return b_sub_part.content.length - a_sub_part.content.length; + } + } + } + throw new Error("The " + a.file + " and " + b.file + " routes clash"); + }); + return routes; +} +function get_sub_parts(part) { + return part.split(/[\[\]]/) + .map(function (content, i) { + if (!content) + return null; + return { + content: content, + dynamic: i % 2 === 1 + }; + }) + .filter(Boolean); +} + +exports.create_app = create_app; +exports.create_serviceworker = create_serviceworker; +exports.create_compilers = create_compilers; +exports.create_routes = create_routes; +//# sourceMappingURL=./core.ts.js.map diff --git a/core.ts.js.map b/core.ts.js.map new file mode 100644 index 0000000..72fe51c --- /dev/null +++ b/core.ts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"core.ts.js","sources":["src/core/utils.ts","src/core/create_app.ts","src/core/create_serviceworker.ts","src/core/create_compilers.ts","src/core/create_routes.ts"],"sourcesContent":["import * as fs from 'fs';\n\nexport function write(file: string, code: string) {\n\tfs.writeFileSync(file, code);\n\tfudge_mtime(file);\n}\n\nexport function posixify(file: string) {\n\treturn file.replace(/[/\\\\]/g, '/');\n}\n\nexport function fudge_mtime(file: string) {\n\t// need to fudge the mtime so that webpack doesn't go doolally\n\tconst { atime, mtime } = fs.statSync(file);\n\tfs.utimesSync(\n\t\tfile,\n\t\tnew Date(atime.getTime() - 999999),\n\t\tnew Date(mtime.getTime() - 999999)\n\t);\n}","import * as fs from 'fs';\nimport * as path from 'path';\nimport mkdirp from 'mkdirp';\nimport create_routes from './create_routes';\nimport { fudge_mtime, posixify, write } from './utils';\nimport { dev } from '../config';\nimport { Route } from '../interfaces';\n\n// in dev mode, we avoid touching the fs unnecessarily\nlet last_client_manifest: string = null;\nlet last_server_manifest: string = null;\n\nexport default function create_app({ routes, dev_port }: {\n\troutes: Route[];\n\tdev_port: number;\n}) {\n\tmkdirp.sync('app/manifest');\n\n\tconst client_manifest = generate_client(routes, dev_port);\n\tconst server_manifest = generate_server(routes);\n\n\tif (client_manifest !== last_client_manifest) {\n\t\twrite(`app/manifest/client.js`, client_manifest);\n\t\tlast_client_manifest = client_manifest;\n\t}\n\n\tif (server_manifest !== last_server_manifest) {\n\t\twrite(`app/manifest/server.js`, server_manifest);\n\t\tlast_server_manifest = server_manifest;\n\t}\n}\n\nfunction generate_client(routes: Route[], dev_port?: number) {\n\tlet code = `\n\t\t// This file is generated by Sapper — do not edit it!\n\t\texport const routes = [\n\t\t\t${routes\n\t\t\t\t.map(route => {\n\t\t\t\t\tif (route.type !== 'page') {\n\t\t\t\t\t\treturn `{ pattern: ${route.pattern}, ignore: true }`;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst file = posixify(`../../routes/${route.file}`);\n\n\t\t\t\t\tif (route.id === '_4xx' || route.id === '_5xx') {\n\t\t\t\t\t\treturn `{ error: '${route.id.slice(1)}', load: () => import(/* webpackChunkName: \"${route.id}\" */ '${file}') }`;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst params = route.params.length === 0\n\t\t\t\t\t\t? '{}'\n\t\t\t\t\t\t: `{ ${route.params.map((part, i) => `${part}: match[${i + 1}]`).join(', ')} }`;\n\n\t\t\t\t\treturn `{ pattern: ${route.pattern}, params: ${route.params.length > 0 ? `match` : `()`} => (${params}), load: () => import(/* webpackChunkName: \"${route.id}\" */ '${file}') }`;\n\t\t\t\t})\n\t\t\t\t.join(',\\n\\t')}\n\t\t];`.replace(/^\\t\\t/gm, '').trim();\n\n\tif (dev()) {\n\t\tconst sapper_dev_client = posixify(\n\t\t\tpath.resolve(__dirname, 'sapper-dev-client.js')\n\t\t);\n\n\t\tcode += `\n\n\t\t\tif (module.hot) {\n\t\t\t\timport('${sapper_dev_client}').then(client => {\n\t\t\t\t\tclient.connect(${dev_port});\n\t\t\t\t});\n\t\t\t}`.replace(/^\\t{3}/gm, '');\n\t}\n\n\treturn code;\n}\n\nfunction generate_server(routes: Route[]) {\n\tlet code = `\n\t\t// This file is generated by Sapper — do not edit it!\n\t\t${routes\n\t\t\t.map(route => {\n\t\t\t\tconst file = posixify(`../../routes/${route.file}`);\n\t\t\t\treturn route.type === 'page'\n\t\t\t\t\t? `import ${route.id} from '${file}';`\n\t\t\t\t\t: `import * as ${route.id} from '${file}';`;\n\t\t\t})\n\t\t\t.join('\\n')}\n\n\t\texport const routes = [\n\t\t\t${routes\n\t\t\t\t.map(route => {\n\t\t\t\t\tconst file = posixify(`../../${route.file}`);\n\n\t\t\t\t\tif (route.id === '_4xx' || route.id === '_5xx') {\n\t\t\t\t\t\treturn `{ error: '${route.id.slice(1)}', module: ${route.id} }`;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst params = route.params.length === 0\n\t\t\t\t\t\t? '{}'\n\t\t\t\t\t\t: `{ ${route.params.map((part, i) => `${part}: match[${i + 1}]`).join(', ')} }`;\n\n\t\t\t\t\treturn `{ id: '${route.id}', type: '${route.type}', pattern: ${route.pattern}, params: ${route.params.length > 0 ? `match` : `()`} => (${params}), module: ${route.id} }`;\n\t\t\t\t})\n\t\t\t\t.join(',\\n\\t')\n\t\t\t}\n\t\t];`.replace(/^\\t\\t/gm, '').trim();\n\n\treturn code;\n}","import * as fs from 'fs';\nimport * as path from 'path';\nimport glob from 'glob';\nimport create_routes from './create_routes';\nimport { fudge_mtime, posixify, write } from './utils';\nimport { Route } from '../interfaces';\n\nexport default function create_serviceworker({ routes, client_files }: {\n\troutes: Route[];\n\tclient_files: string[];\n}) {\n\tconst assets = glob.sync('**', { cwd: 'assets', nodir: true });\n\n\tlet code = `\n\t\t// This file is generated by Sapper — do not edit it!\n\t\texport const timestamp = ${Date.now()};\n\n\t\texport const assets = [\\n\\t${assets.map((x: string) => `\"${x}\"`).join(',\\n\\t')}\\n];\n\n\t\texport const shell = [\\n\\t${client_files.map((x: string) => `\"${x}\"`).join(',\\n\\t')}\\n];\n\n\t\texport const routes = [\\n\\t${routes.filter((r: Route) => r.type === 'page' && !/^_[45]xx$/.test(r.id)).map((r: Route) => `{ pattern: ${r.pattern} }`).join(',\\n\\t')}\\n];\n\t`.replace(/^\\t\\t/gm, '').trim();\n\n\twrite('app/manifest/service-worker.js', code);\n}","import * as path from 'path';\nimport relative from 'require-relative';\n\nexport default function create_compilers() {\n\tconst webpack = relative('webpack', process.cwd());\n\n\tconst serviceworker_config = try_require(path.resolve('webpack/service-worker.config.js'));\n\n\treturn {\n\t\tclient: webpack(\n\t\t\trequire(path.resolve('webpack/client.config.js'))\n\t\t),\n\n\t\tserver: webpack(\n\t\t\trequire(path.resolve('webpack/server.config.js'))\n\t\t),\n\n\t\tserviceworker: serviceworker_config && webpack(serviceworker_config)\n\t};\n}\n\nfunction try_require(specifier: string) {\n\ttry {\n\t\treturn require(specifier);\n\t} catch (err) {\n\t\tif (err.code === 'MODULE_NOT_FOUND') return null;\n\t\tthrow err;\n\t}\n}","import * as path from 'path';\nimport glob from 'glob';\nimport { src } from '../config';\nimport { Route } from '../interfaces';\n\nexport default function create_routes({ files } = { files: glob.sync('**/*.*', { cwd: src(), nodir: true }) }) {\n\tconst routes: Route[] = files\n\t\t.map((file: string) => {\n\t\t\tif (/(^|\\/|\\\\)_/.test(file)) return;\n\n\t\t\tif (/]\\[/.test(file)) {\n\t\t\t\tthrow new Error(`Invalid route ${file} — parameters must be separated`);\n\t\t\t}\n\n\t\t\tconst base = file.replace(/\\.[^/.]+$/, '');\n\t\t\tconst parts = base.split('/'); // glob output is always posix-style\n\t\t\tif (parts[parts.length - 1] === 'index') parts.pop();\n\n\t\t\tconst id = (\n\t\t\t\tparts.join('_').replace(/[[\\]]/g, '$').replace(/^\\d/, '_$&').replace(/[^a-zA-Z0-9_$]/g, '_')\n\t\t\t ) || '_';\n\n\t\t\tconst params: string[] = [];\n\t\t\tconst param_pattern = /\\[([^\\]]+)\\]/g;\n\t\t\tlet match;\n\t\t\twhile (match = param_pattern.exec(base)) {\n\t\t\t\tparams.push(match[1]);\n\t\t\t}\n\n\t\t\t// TODO can we do all this with sub-parts? or does\n\t\t\t// nesting make that impossible?\n\t\t\tlet pattern_string = '';\n\t\t\tlet i = parts.length;\n\t\t\tlet nested = true;\n\t\t\twhile (i--) {\n\t\t\t\tconst part = encodeURIComponent(parts[i].normalize()).replace(/%5B/g, '[').replace(/%5D/g, ']');\n\t\t\t\tconst dynamic = ~part.indexOf('[');\n\n\t\t\t\tif (dynamic) {\n\t\t\t\t\tconst matcher = part.replace(param_pattern, `([^\\/]+?)`);\n\t\t\t\t\tpattern_string = nested ? `(?:\\\\/${matcher}${pattern_string})?` : `\\\\/${matcher}${pattern_string}`;\n\t\t\t\t} else {\n\t\t\t\t\tnested = false;\n\t\t\t\t\tpattern_string = `\\\\/${part}${pattern_string}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pattern = new RegExp(`^${pattern_string}\\\\/?$`);\n\n\t\t\tconst test = (url: string) => pattern.test(url);\n\n\t\t\tconst exec = (url: string) => {\n\t\t\t\tconst match = pattern.exec(url);\n\t\t\t\tif (!match) return;\n\n\t\t\t\tconst result: Record = {};\n\t\t\t\tparams.forEach((param, i) => {\n\t\t\t\t\tresult[param] = match[i + 1];\n\t\t\t\t});\n\n\t\t\t\treturn result;\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\tid,\n\t\t\t\ttype: path.extname(file) === '.html' ? 'page' : 'route',\n\t\t\t\tfile,\n\t\t\t\tpattern,\n\t\t\t\ttest,\n\t\t\t\texec,\n\t\t\t\tparts,\n\t\t\t\tparams\n\t\t\t};\n\t\t})\n\t\t.filter(Boolean)\n\t\t.sort((a: Route, b: Route) => {\n\t\t\tif (a.file === '4xx.html' || a.file === '5xx.html') return -1;\n\t\t\tif (b.file === '4xx.html' || b.file === '5xx.html') return 1;\n\n\t\t\tconst max = Math.max(a.parts.length, b.parts.length);\n\n\t\t\tfor (let i = 0; i < max; i += 1) {\n\t\t\t\tconst a_part = a.parts[i];\n\t\t\t\tconst b_part = b.parts[i];\n\n\t\t\t\tif (!a_part) return -1;\n\t\t\t\tif (!b_part) return 1;\n\n\t\t\t\tconst a_sub_parts = get_sub_parts(a_part);\n\t\t\t\tconst b_sub_parts = get_sub_parts(b_part);\n\t\t\t\tconst max = Math.max(a_sub_parts.length, b_sub_parts.length);\n\n\t\t\t\tfor (let i = 0; i < max; i += 1) {\n\t\t\t\t\tconst a_sub_part = a_sub_parts[i];\n\t\t\t\t\tconst b_sub_part = b_sub_parts[i];\n\n\t\t\t\t\tif (!a_sub_part) return 1; // b is more specific, so goes first\n\t\t\t\t\tif (!b_sub_part) return -1;\n\n\t\t\t\t\tif (a_sub_part.dynamic !== b_sub_part.dynamic) {\n\t\t\t\t\t\treturn a_sub_part.dynamic ? 1 : -1;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (!a_sub_part.dynamic && a_sub_part.content !== b_sub_part.content) {\n\t\t\t\t\t\treturn b_sub_part.content.length - a_sub_part.content.length;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tthrow new Error(`The ${a.file} and ${b.file} routes clash`);\n\t\t});\n\n\treturn routes;\n}\n\nfunction get_sub_parts(part: string) {\n\treturn part.split(/[\\[\\]]/)\n\t\t.map((content, i) => {\n\t\t\tif (!content) return null;\n\t\t\treturn {\n\t\t\t\tcontent,\n\t\t\t\tdynamic: i % 2 === 1\n\t\t\t};\n\t\t})\n\t\t.filter(Boolean);\n}"],"names":["fs.writeFileSync","fs.utimesSync","dev","path.resol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AC,IAAI,CAAC,EAAE;gBAChC,IAAM,UAAU,GAAG,WAAW,CAAC,GAAC,CAAC,CAAC;gBAClC,IAAM,UAAU,GAAG,WAAW,CAAC,GAAC,CAAC,CAAC;gBAElC,IAAI,CAAC,UAAU;oBAAE,OAAO,CAAC,CAAC;gBAC1B,IAAI,CAAC,UAAU;oBAAE,OAAO,CAAC,CAAC,CAAC;gBAE3B,IAAI,UAAU,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE;oBAC9C,OAAO,UAAU,CAAC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;iBACnC;gBAED,IAAI,CAAC,UAAU,CAAC,OAAO,IAAI,UAAU,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE;oBACrE,OAAO,UAAU,CAAC,OAAO,CAAC,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC;iBAC7D;aACD;SACD;QAED,MAAM,IAAI,KAAK,CAAC,SAAO,CAAC,CAAC,IAAI,aAAQ,CAAC,CAAC,IAAI,kBAAe,CAAC,CAAC;KAC5D,CAAC,CAAC;IAEJ,OAAO,MAAM,CAAC;CACd;AAED,uBAAuB,IAAY;IAClC,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;SACzB,GAAG,CAAC,UAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAC1B,OAAO;YACN,OAAO,SAAA;YACP,OAAO,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;SACpB,CAAC;KACF,CAAC;SACD,MAAM,CAAC,OAAO,CAAC,CAAC;CAClB;;;;;;;"} \ No newline at end of file diff --git a/middleware.ts.js b/middleware.ts.js new file mode 100644 index 0000000..ab8c158 --- /dev/null +++ b/middleware.ts.js @@ -0,0 +1,274 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var __chunk1_js = require('./chunk1.js'); +var fs = require('fs'); +var path = require('path'); +var devalue = _interopDefault(require('devalue')); +var sourceMapSupport = _interopDefault(require('source-map-support')); + +var mime_raw = "application/andrew-inset\t\t\tez\napplication/applixware\t\t\t\taw\napplication/atom+xml\t\t\t\tatom\napplication/atomcat+xml\t\t\t\tatomcat\napplication/atomsvc+xml\t\t\t\tatomsvc\napplication/ccxml+xml\t\t\t\tccxml\napplication/cdmi-capability\t\t\tcdmia\napplication/cdmi-container\t\t\tcdmic\napplication/cdmi-domain\t\t\t\tcdmid\napplication/cdmi-object\t\t\t\tcdmio\napplication/cdmi-queue\t\t\t\tcdmiq\napplication/cu-seeme\t\t\t\tcu\napplication/davmount+xml\t\t\tdavmount\napplication/docbook+xml\t\t\t\tdbk\napplication/dssc+der\t\t\t\tdssc\napplication/dssc+xml\t\t\t\txdssc\napplication/ecmascript\t\t\t\tecma\napplication/emma+xml\t\t\t\temma\napplication/epub+zip\t\t\t\tepub\napplication/exi\t\t\t\t\texi\napplication/font-tdpfr\t\t\t\tpfr\napplication/gml+xml\t\t\t\tgml\napplication/gpx+xml\t\t\t\tgpx\napplication/gxf\t\t\t\t\tgxf\napplication/hyperstudio\t\t\t\tstk\napplication/inkml+xml\t\t\t\tink inkml\napplication/ipfix\t\t\t\tipfix\napplication/java-archive\t\t\tjar\napplication/java-serialized-object\t\tser\napplication/java-vm\t\t\t\tclass\napplication/javascript\t\t\t\tjs\napplication/json\t\t\t\tjson\napplication/jsonml+json\t\t\t\tjsonml\napplication/lost+xml\t\t\t\tlostxml\napplication/mac-binhex40\t\t\thqx\napplication/mac-compactpro\t\t\tcpt\napplication/mads+xml\t\t\t\tmads\napplication/marc\t\t\t\tmrc\napplication/marcxml+xml\t\t\t\tmrcx\napplication/mathematica\t\t\t\tma nb mb\napplication/mathml+xml\t\t\t\tmathml\napplication/mbox\t\t\t\tmbox\napplication/mediaservercontrol+xml\t\tmscml\napplication/metalink+xml\t\t\tmetalink\napplication/metalink4+xml\t\t\tmeta4\napplication/mets+xml\t\t\t\tmets\napplication/mods+xml\t\t\t\tmods\napplication/mp21\t\t\t\tm21 mp21\napplication/mp4\t\t\t\t\tmp4s\napplication/msword\t\t\t\tdoc dot\napplication/mxf\t\t\t\t\tmxf\napplication/octet-stream\tbin dms lrf mar so dist distz pkg bpk dump elc deploy\napplication/oda\t\t\t\t\toda\napplication/oebps-package+xml\t\t\topf\napplication/ogg\t\t\t\t\togx\napplication/omdoc+xml\t\t\t\tomdoc\napplication/onenote\t\t\t\tonetoc onetoc2 onetmp onepkg\napplication/oxps\t\t\t\toxps\napplication/patch-ops-error+xml\t\t\txer\napplication/pdf\t\t\t\t\tpdf\napplication/pgp-encrypted\t\t\tpgp\napplication/pgp-signature\t\t\tasc sig\napplication/pics-rules\t\t\t\tprf\napplication/pkcs10\t\t\t\tp10\napplication/pkcs7-mime\t\t\t\tp7m p7c\napplication/pkcs7-signature\t\t\tp7s\napplication/pkcs8\t\t\t\tp8\napplication/pkix-attr-cert\t\t\tac\napplication/pkix-cert\t\t\t\tcer\napplication/pkix-crl\t\t\t\tcrl\napplication/pkix-pkipath\t\t\tpkipath\napplication/pkixcmp\t\t\t\tpki\napplication/pls+xml\t\t\t\tpls\napplication/postscript\t\t\t\tai eps ps\napplication/prs.cww\t\t\t\tcww\napplication/pskc+xml\t\t\t\tpskcxml\napplication/rdf+xml\t\t\t\trdf\napplication/reginfo+xml\t\t\t\trif\napplication/relax-ng-compact-syntax\t\trnc\napplication/resource-lists+xml\t\t\trl\napplication/resource-lists-diff+xml\t\trld\napplication/rls-services+xml\t\t\trs\napplication/rpki-ghostbusters\t\t\tgbr\napplication/rpki-manifest\t\t\tmft\napplication/rpki-roa\t\t\t\troa\napplication/rsd+xml\t\t\t\trsd\napplication/rss+xml\t\t\t\trss\napplication/rtf\t\t\t\t\trtf\napplication/sbml+xml\t\t\t\tsbml\napplication/scvp-cv-request\t\t\tscq\napplication/scvp-cv-response\t\t\tscs\napplication/scvp-vp-request\t\t\tspq\napplication/scvp-vp-response\t\t\tspp\napplication/sdp\t\t\t\t\tsdp\napplication/set-payment-initiation\t\tsetpay\napplication/set-registration-initiation\t\tsetreg\napplication/shf+xml\t\t\t\tshf\napplication/smil+xml\t\t\t\tsmi smil\napplication/sparql-query\t\t\trq\napplication/sparql-results+xml\t\t\tsrx\napplication/srgs\t\t\t\tgram\napplication/srgs+xml\t\t\t\tgrxml\napplication/sru+xml\t\t\t\tsru\napplication/ssdl+xml\t\t\t\tssdl\napplication/ssml+xml\t\t\t\tssml\napplication/tei+xml\t\t\t\ttei teicorpus\napplication/thraud+xml\t\t\t\ttfi\napplication/timestamped-data\t\t\ttsd\napplication/vnd.3gpp.pic-bw-large\t\tplb\napplication/vnd.3gpp.pic-bw-small\t\tpsb\napplication/vnd.3gpp.pic-bw-var\t\t\tpvb\napplication/vnd.3gpp2.tcap\t\t\ttcap\napplication/vnd.3m.post-it-notes\t\tpwn\napplication/vnd.accpac.simply.aso\t\taso\napplication/vnd.accpac.simply.imp\t\timp\napplication/vnd.acucobol\t\t\tacu\napplication/vnd.acucorp\t\t\t\tatc acutc\napplication/vnd.adobe.air-application-installer-package+zip\tair\napplication/vnd.adobe.formscentral.fcdt\t\tfcdt\napplication/vnd.adobe.fxp\t\t\tfxp fxpl\napplication/vnd.adobe.xdp+xml\t\t\txdp\napplication/vnd.adobe.xfdf\t\t\txfdf\napplication/vnd.ahead.space\t\t\tahead\napplication/vnd.airzip.filesecure.azf\t\tazf\napplication/vnd.airzip.filesecure.azs\t\tazs\napplication/vnd.amazon.ebook\t\t\tazw\napplication/vnd.americandynamics.acc\t\tacc\napplication/vnd.amiga.ami\t\t\tami\napplication/vnd.android.package-archive\t\tapk\napplication/vnd.anser-web-certificate-issue-initiation\tcii\napplication/vnd.anser-web-funds-transfer-initiation\tfti\napplication/vnd.antix.game-component\t\tatx\napplication/vnd.apple.installer+xml\t\tmpkg\napplication/vnd.apple.mpegurl\t\t\tm3u8\napplication/vnd.aristanetworks.swi\t\tswi\napplication/vnd.astraea-software.iota\t\tiota\napplication/vnd.audiograph\t\t\taep\napplication/vnd.blueice.multipass\t\tmpm\napplication/vnd.bmi\t\t\t\tbmi\napplication/vnd.businessobjects\t\t\trep\napplication/vnd.chemdraw+xml\t\t\tcdxml\napplication/vnd.chipnuts.karaoke-mmd\t\tmmd\napplication/vnd.cinderella\t\t\tcdy\napplication/vnd.claymore\t\t\tcla\napplication/vnd.cloanto.rp9\t\t\trp9\napplication/vnd.clonk.c4group\t\t\tc4g c4d c4f c4p c4u\napplication/vnd.cluetrust.cartomobile-config\t\tc11amc\napplication/vnd.cluetrust.cartomobile-config-pkg\tc11amz\napplication/vnd.commonspace\t\t\tcsp\napplication/vnd.contact.cmsg\t\t\tcdbcmsg\napplication/vnd.cosmocaller\t\t\tcmc\napplication/vnd.crick.clicker\t\t\tclkx\napplication/vnd.crick.clicker.keyboard\t\tclkk\napplication/vnd.crick.clicker.palette\t\tclkp\napplication/vnd.crick.clicker.template\t\tclkt\napplication/vnd.crick.clicker.wordbank\t\tclkw\napplication/vnd.criticaltools.wbs+xml\t\twbs\napplication/vnd.ctc-posml\t\t\tpml\napplication/vnd.cups-ppd\t\t\tppd\napplication/vnd.curl.car\t\t\tcar\napplication/vnd.curl.pcurl\t\t\tpcurl\napplication/vnd.dart\t\t\t\tdart\napplication/vnd.data-vision.rdz\t\t\trdz\napplication/vnd.dece.data\t\t\tuvf uvvf uvd uvvd\napplication/vnd.dece.ttml+xml\t\t\tuvt uvvt\napplication/vnd.dece.unspecified\t\tuvx uvvx\napplication/vnd.dece.zip\t\t\tuvz uvvz\napplication/vnd.denovo.fcselayout-link\t\tfe_launch\napplication/vnd.dna\t\t\t\tdna\napplication/vnd.dolby.mlp\t\t\tmlp\napplication/vnd.dpgraph\t\t\t\tdpg\napplication/vnd.dreamfactory\t\t\tdfac\napplication/vnd.ds-keypoint\t\t\tkpxx\napplication/vnd.dvb.ait\t\t\t\tait\napplication/vnd.dvb.service\t\t\tsvc\napplication/vnd.dynageo\t\t\t\tgeo\napplication/vnd.ecowin.chart\t\t\tmag\napplication/vnd.enliven\t\t\t\tnml\napplication/vnd.epson.esf\t\t\tesf\napplication/vnd.epson.msf\t\t\tmsf\napplication/vnd.epson.quickanime\t\tqam\napplication/vnd.epson.salt\t\t\tslt\napplication/vnd.epson.ssf\t\t\tssf\napplication/vnd.eszigno3+xml\t\t\tes3 et3\napplication/vnd.ezpix-album\t\t\tez2\napplication/vnd.ezpix-package\t\t\tez3\napplication/vnd.fdf\t\t\t\tfdf\napplication/vnd.fdsn.mseed\t\t\tmseed\napplication/vnd.fdsn.seed\t\t\tseed dataless\napplication/vnd.flographit\t\t\tgph\napplication/vnd.fluxtime.clip\t\t\tftc\napplication/vnd.framemaker\t\t\tfm frame maker book\napplication/vnd.frogans.fnc\t\t\tfnc\napplication/vnd.frogans.ltf\t\t\tltf\napplication/vnd.fsc.weblaunch\t\t\tfsc\napplication/vnd.fujitsu.oasys\t\t\toas\napplication/vnd.fujitsu.oasys2\t\t\toa2\napplication/vnd.fujitsu.oasys3\t\t\toa3\napplication/vnd.fujitsu.oasysgp\t\t\tfg5\napplication/vnd.fujitsu.oasysprs\t\tbh2\napplication/vnd.fujixerox.ddd\t\t\tddd\napplication/vnd.fujixerox.docuworks\t\txdw\napplication/vnd.fujixerox.docuworks.binder\txbd\napplication/vnd.fuzzysheet\t\t\tfzs\napplication/vnd.genomatix.tuxedo\t\ttxd\napplication/vnd.geogebra.file\t\t\tggb\napplication/vnd.geogebra.tool\t\t\tggt\napplication/vnd.geometry-explorer\t\tgex gre\napplication/vnd.geonext\t\t\t\tgxt\napplication/vnd.geoplan\t\t\t\tg2w\napplication/vnd.geospace\t\t\tg3w\napplication/vnd.gmx\t\t\t\tgmx\napplication/vnd.google-earth.kml+xml\t\tkml\napplication/vnd.google-earth.kmz\t\tkmz\napplication/vnd.grafeq\t\t\t\tgqf gqs\napplication/vnd.groove-account\t\t\tgac\napplication/vnd.groove-help\t\t\tghf\napplication/vnd.groove-identity-message\t\tgim\napplication/vnd.groove-injector\t\t\tgrv\napplication/vnd.groove-tool-message\t\tgtm\napplication/vnd.groove-tool-template\t\ttpl\napplication/vnd.groove-vcard\t\t\tvcg\napplication/vnd.hal+xml\t\t\t\thal\napplication/vnd.handheld-entertainment+xml\tzmm\napplication/vnd.hbci\t\t\t\thbci\napplication/vnd.hhe.lesson-player\t\tles\napplication/vnd.hp-hpgl\t\t\t\thpgl\napplication/vnd.hp-hpid\t\t\t\thpid\napplication/vnd.hp-hps\t\t\t\thps\napplication/vnd.hp-jlyt\t\t\t\tjlt\napplication/vnd.hp-pcl\t\t\t\tpcl\napplication/vnd.hp-pclxl\t\t\tpclxl\napplication/vnd.hydrostatix.sof-data\t\tsfd-hdstx\napplication/vnd.ibm.minipay\t\t\tmpy\napplication/vnd.ibm.modcap\t\t\tafp listafp list3820\napplication/vnd.ibm.rights-management\t\tirm\napplication/vnd.ibm.secure-container\t\tsc\napplication/vnd.iccprofile\t\t\ticc icm\napplication/vnd.igloader\t\t\tigl\napplication/vnd.immervision-ivp\t\t\tivp\napplication/vnd.immervision-ivu\t\t\tivu\napplication/vnd.insors.igm\t\t\tigm\napplication/vnd.intercon.formnet\t\txpw xpx\napplication/vnd.intergeo\t\t\ti2g\napplication/vnd.intu.qbo\t\t\tqbo\napplication/vnd.intu.qfx\t\t\tqfx\napplication/vnd.ipunplugged.rcprofile\t\trcprofile\napplication/vnd.irepository.package+xml\t\tirp\napplication/vnd.is-xpr\t\t\t\txpr\napplication/vnd.isac.fcs\t\t\tfcs\napplication/vnd.jam\t\t\t\tjam\napplication/vnd.jcp.javame.midlet-rms\t\trms\napplication/vnd.jisp\t\t\t\tjisp\napplication/vnd.joost.joda-archive\t\tjoda\napplication/vnd.kahootz\t\t\t\tktz ktr\napplication/vnd.kde.karbon\t\t\tkarbon\napplication/vnd.kde.kchart\t\t\tchrt\napplication/vnd.kde.kformula\t\t\tkfo\napplication/vnd.kde.kivio\t\t\tflw\napplication/vnd.kde.kontour\t\t\tkon\napplication/vnd.kde.kpresenter\t\t\tkpr kpt\napplication/vnd.kde.kspread\t\t\tksp\napplication/vnd.kde.kword\t\t\tkwd kwt\napplication/vnd.kenameaapp\t\t\thtke\napplication/vnd.kidspiration\t\t\tkia\napplication/vnd.kinar\t\t\t\tkne knp\napplication/vnd.koan\t\t\t\tskp skd skt skm\napplication/vnd.kodak-descriptor\t\tsse\napplication/vnd.las.las+xml\t\t\tlasxml\napplication/vnd.llamagraphics.life-balance.desktop\tlbd\napplication/vnd.llamagraphics.life-balance.exchange+xml\tlbe\napplication/vnd.lotus-1-2-3\t\t\t123\napplication/vnd.lotus-approach\t\t\tapr\napplication/vnd.lotus-freelance\t\t\tpre\napplication/vnd.lotus-notes\t\t\tnsf\napplication/vnd.lotus-organizer\t\t\torg\napplication/vnd.lotus-screencam\t\t\tscm\napplication/vnd.lotus-wordpro\t\t\tlwp\napplication/vnd.macports.portpkg\t\tportpkg\napplication/vnd.mcd\t\t\t\tmcd\napplication/vnd.medcalcdata\t\t\tmc1\napplication/vnd.mediastation.cdkey\t\tcdkey\napplication/vnd.mfer\t\t\t\tmwf\napplication/vnd.mfmp\t\t\t\tmfm\napplication/vnd.micrografx.flo\t\t\tflo\napplication/vnd.micrografx.igx\t\t\tigx\napplication/vnd.mif\t\t\t\tmif\napplication/vnd.mobius.daf\t\t\tdaf\napplication/vnd.mobius.dis\t\t\tdis\napplication/vnd.mobius.mbk\t\t\tmbk\napplication/vnd.mobius.mqy\t\t\tmqy\napplication/vnd.mobius.msl\t\t\tmsl\napplication/vnd.mobius.plc\t\t\tplc\napplication/vnd.mobius.txf\t\t\ttxf\napplication/vnd.mophun.application\t\tmpn\napplication/vnd.mophun.certificate\t\tmpc\napplication/vnd.mozilla.xul+xml\t\t\txul\napplication/vnd.ms-artgalry\t\t\tcil\napplication/vnd.ms-cab-compressed\t\tcab\napplication/vnd.ms-excel\t\t\txls xlm xla xlc xlt xlw\napplication/vnd.ms-excel.addin.macroenabled.12\t\txlam\napplication/vnd.ms-excel.sheet.binary.macroenabled.12\txlsb\napplication/vnd.ms-excel.sheet.macroenabled.12\t\txlsm\napplication/vnd.ms-excel.template.macroenabled.12\txltm\napplication/vnd.ms-fontobject\t\t\teot\napplication/vnd.ms-htmlhelp\t\t\tchm\napplication/vnd.ms-ims\t\t\t\tims\napplication/vnd.ms-lrm\t\t\t\tlrm\napplication/vnd.ms-officetheme\t\t\tthmx\napplication/vnd.ms-pki.seccat\t\t\tcat\napplication/vnd.ms-pki.stl\t\t\tstl\napplication/vnd.ms-powerpoint\t\t\tppt pps pot\napplication/vnd.ms-powerpoint.addin.macroenabled.12\t\tppam\napplication/vnd.ms-powerpoint.presentation.macroenabled.12\tpptm\napplication/vnd.ms-powerpoint.slide.macroenabled.12\t\tsldm\napplication/vnd.ms-powerpoint.slideshow.macroenabled.12\t\tppsm\napplication/vnd.ms-powerpoint.template.macroenabled.12\t\tpotm\napplication/vnd.ms-project\t\t\tmpp mpt\napplication/vnd.ms-word.document.macroenabled.12\tdocm\napplication/vnd.ms-word.template.macroenabled.12\tdotm\napplication/vnd.ms-works\t\t\twps wks wcm wdb\napplication/vnd.ms-wpl\t\t\t\twpl\napplication/vnd.ms-xpsdocument\t\t\txps\napplication/vnd.mseq\t\t\t\tmseq\napplication/vnd.musician\t\t\tmus\napplication/vnd.muvee.style\t\t\tmsty\napplication/vnd.mynfc\t\t\t\ttaglet\napplication/vnd.neurolanguage.nlu\t\tnlu\napplication/vnd.nitf\t\t\t\tntf nitf\napplication/vnd.noblenet-directory\t\tnnd\napplication/vnd.noblenet-sealer\t\t\tnns\napplication/vnd.noblenet-web\t\t\tnnw\napplication/vnd.nokia.n-gage.data\t\tngdat\napplication/vnd.nokia.n-gage.symbian.install\tn-gage\napplication/vnd.nokia.radio-preset\t\trpst\napplication/vnd.nokia.radio-presets\t\trpss\napplication/vnd.novadigm.edm\t\t\tedm\napplication/vnd.novadigm.edx\t\t\tedx\napplication/vnd.novadigm.ext\t\t\text\napplication/vnd.oasis.opendocument.chart\t\todc\napplication/vnd.oasis.opendocument.chart-template\totc\napplication/vnd.oasis.opendocument.database\t\todb\napplication/vnd.oasis.opendocument.formula\t\todf\napplication/vnd.oasis.opendocument.formula-template\todft\napplication/vnd.oasis.opendocument.graphics\t\todg\napplication/vnd.oasis.opendocument.graphics-template\totg\napplication/vnd.oasis.opendocument.image\t\todi\napplication/vnd.oasis.opendocument.image-template\toti\napplication/vnd.oasis.opendocument.presentation\t\todp\napplication/vnd.oasis.opendocument.presentation-template\totp\napplication/vnd.oasis.opendocument.spreadsheet\t\tods\napplication/vnd.oasis.opendocument.spreadsheet-template\tots\napplication/vnd.oasis.opendocument.text\t\t\todt\napplication/vnd.oasis.opendocument.text-master\t\todm\napplication/vnd.oasis.opendocument.text-template\tott\napplication/vnd.oasis.opendocument.text-web\t\toth\napplication/vnd.olpc-sugar\t\t\txo\napplication/vnd.oma.dd2+xml\t\t\tdd2\napplication/vnd.openofficeorg.extension\t\toxt\napplication/vnd.openxmlformats-officedocument.presentationml.presentation\tpptx\napplication/vnd.openxmlformats-officedocument.presentationml.slide\tsldx\napplication/vnd.openxmlformats-officedocument.presentationml.slideshow\tppsx\napplication/vnd.openxmlformats-officedocument.presentationml.template\tpotx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet\txlsx\napplication/vnd.openxmlformats-officedocument.spreadsheetml.template\txltx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.document\tdocx\napplication/vnd.openxmlformats-officedocument.wordprocessingml.template\tdotx\napplication/vnd.osgeo.mapguide.package\t\tmgp\napplication/vnd.osgi.dp\t\t\t\tdp\napplication/vnd.osgi.subsystem\t\t\tesa\napplication/vnd.palm\t\t\t\tpdb pqa oprc\napplication/vnd.pawaafile\t\t\tpaw\napplication/vnd.pg.format\t\t\tstr\napplication/vnd.pg.osasli\t\t\tei6\napplication/vnd.picsel\t\t\t\tefif\napplication/vnd.pmi.widget\t\t\twg\napplication/vnd.pocketlearn\t\t\tplf\napplication/vnd.powerbuilder6\t\t\tpbd\napplication/vnd.previewsystems.box\t\tbox\napplication/vnd.proteus.magazine\t\tmgz\napplication/vnd.publishare-delta-tree\t\tqps\napplication/vnd.pvi.ptid1\t\t\tptid\napplication/vnd.quark.quarkxpress\t\tqxd qxt qwd qwt qxl qxb\napplication/vnd.realvnc.bed\t\t\tbed\napplication/vnd.recordare.musicxml\t\tmxl\napplication/vnd.recordare.musicxml+xml\t\tmusicxml\napplication/vnd.rig.cryptonote\t\t\tcryptonote\napplication/vnd.rim.cod\t\t\t\tcod\napplication/vnd.rn-realmedia\t\t\trm\napplication/vnd.rn-realmedia-vbr\t\trmvb\napplication/vnd.route66.link66+xml\t\tlink66\napplication/vnd.sailingtracker.track\t\tst\napplication/vnd.seemail\t\t\t\tsee\napplication/vnd.sema\t\t\t\tsema\napplication/vnd.semd\t\t\t\tsemd\napplication/vnd.semf\t\t\t\tsemf\napplication/vnd.shana.informed.formdata\t\tifm\napplication/vnd.shana.informed.formtemplate\titp\napplication/vnd.shana.informed.interchange\tiif\napplication/vnd.shana.informed.package\t\tipk\napplication/vnd.simtech-mindmapper\t\ttwd twds\napplication/vnd.smaf\t\t\t\tmmf\napplication/vnd.smart.teacher\t\t\tteacher\napplication/vnd.solent.sdkm+xml\t\t\tsdkm sdkd\napplication/vnd.spotfire.dxp\t\t\tdxp\napplication/vnd.spotfire.sfs\t\t\tsfs\napplication/vnd.stardivision.calc\t\tsdc\napplication/vnd.stardivision.draw\t\tsda\napplication/vnd.stardivision.impress\t\tsdd\napplication/vnd.stardivision.math\t\tsmf\napplication/vnd.stardivision.writer\t\tsdw vor\napplication/vnd.stardivision.writer-global\tsgl\napplication/vnd.stepmania.package\t\tsmzip\napplication/vnd.stepmania.stepchart\t\tsm\napplication/vnd.sun.xml.calc\t\t\tsxc\napplication/vnd.sun.xml.calc.template\t\tstc\napplication/vnd.sun.xml.draw\t\t\tsxd\napplication/vnd.sun.xml.draw.template\t\tstd\napplication/vnd.sun.xml.impress\t\t\tsxi\napplication/vnd.sun.xml.impress.template\tsti\napplication/vnd.sun.xml.math\t\t\tsxm\napplication/vnd.sun.xml.writer\t\t\tsxw\napplication/vnd.sun.xml.writer.global\t\tsxg\napplication/vnd.sun.xml.writer.template\t\tstw\napplication/vnd.sus-calendar\t\t\tsus susp\napplication/vnd.svd\t\t\t\tsvd\napplication/vnd.symbian.install\t\t\tsis sisx\napplication/vnd.syncml+xml\t\t\txsm\napplication/vnd.syncml.dm+wbxml\t\t\tbdm\napplication/vnd.syncml.dm+xml\t\t\txdm\napplication/vnd.tao.intent-module-archive\ttao\napplication/vnd.tcpdump.pcap\t\t\tpcap cap dmp\napplication/vnd.tmobile-livetv\t\t\ttmo\napplication/vnd.trid.tpt\t\t\ttpt\napplication/vnd.triscape.mxs\t\t\tmxs\napplication/vnd.trueapp\t\t\t\ttra\napplication/vnd.ufdl\t\t\t\tufd ufdl\napplication/vnd.uiq.theme\t\t\tutz\napplication/vnd.umajin\t\t\t\tumj\napplication/vnd.unity\t\t\t\tunityweb\napplication/vnd.uoml+xml\t\t\tuoml\napplication/vnd.vcx\t\t\t\tvcx\napplication/vnd.visio\t\t\t\tvsd vst vss vsw\napplication/vnd.visionary\t\t\tvis\napplication/vnd.vsf\t\t\t\tvsf\napplication/vnd.wap.wbxml\t\t\twbxml\napplication/vnd.wap.wmlc\t\t\twmlc\napplication/vnd.wap.wmlscriptc\t\t\twmlsc\napplication/vnd.webturbo\t\t\twtb\napplication/vnd.wolfram.player\t\t\tnbp\napplication/vnd.wordperfect\t\t\twpd\napplication/vnd.wqd\t\t\t\twqd\napplication/vnd.wt.stf\t\t\t\tstf\napplication/vnd.xara\t\t\t\txar\napplication/vnd.xfdl\t\t\t\txfdl\napplication/vnd.yamaha.hv-dic\t\t\thvd\napplication/vnd.yamaha.hv-script\t\thvs\napplication/vnd.yamaha.hv-voice\t\t\thvp\napplication/vnd.yamaha.openscoreformat\t\t\tosf\napplication/vnd.yamaha.openscoreformat.osfpvg+xml\tosfpvg\napplication/vnd.yamaha.smaf-audio\t\tsaf\napplication/vnd.yamaha.smaf-phrase\t\tspf\napplication/vnd.yellowriver-custom-menu\t\tcmp\napplication/vnd.zul\t\t\t\tzir zirz\napplication/vnd.zzazz.deck+xml\t\t\tzaz\napplication/voicexml+xml\t\t\tvxml\napplication/widget\t\t\t\twgt\napplication/winhlp\t\t\t\thlp\napplication/wsdl+xml\t\t\t\twsdl\napplication/wspolicy+xml\t\t\twspolicy\napplication/x-7z-compressed\t\t\t7z\napplication/x-abiword\t\t\t\tabw\napplication/x-ace-compressed\t\t\tace\napplication/x-apple-diskimage\t\t\tdmg\napplication/x-authorware-bin\t\t\taab x32 u32 vox\napplication/x-authorware-map\t\t\taam\napplication/x-authorware-seg\t\t\taas\napplication/x-bcpio\t\t\t\tbcpio\napplication/x-bittorrent\t\t\ttorrent\napplication/x-blorb\t\t\t\tblb blorb\napplication/x-bzip\t\t\t\tbz\napplication/x-bzip2\t\t\t\tbz2 boz\napplication/x-cbr\t\t\t\tcbr cba cbt cbz cb7\napplication/x-cdlink\t\t\t\tvcd\napplication/x-cfs-compressed\t\t\tcfs\napplication/x-chat\t\t\t\tchat\napplication/x-chess-pgn\t\t\t\tpgn\napplication/x-conference\t\t\tnsc\napplication/x-cpio\t\t\t\tcpio\napplication/x-csh\t\t\t\tcsh\napplication/x-debian-package\t\t\tdeb udeb\napplication/x-dgc-compressed\t\t\tdgc\napplication/x-director\t\t\tdir dcr dxr cst cct cxt w3d fgd swa\napplication/x-doom\t\t\t\twad\napplication/x-dtbncx+xml\t\t\tncx\napplication/x-dtbook+xml\t\t\tdtb\napplication/x-dtbresource+xml\t\t\tres\napplication/x-dvi\t\t\t\tdvi\napplication/x-envoy\t\t\t\tevy\napplication/x-eva\t\t\t\teva\napplication/x-font-bdf\t\t\t\tbdf\napplication/x-font-ghostscript\t\t\tgsf\napplication/x-font-linux-psf\t\t\tpsf\napplication/x-font-pcf\t\t\t\tpcf\napplication/x-font-snf\t\t\t\tsnf\napplication/x-font-type1\t\t\tpfa pfb pfm afm\napplication/x-freearc\t\t\t\tarc\napplication/x-futuresplash\t\t\tspl\napplication/x-gca-compressed\t\t\tgca\napplication/x-glulx\t\t\t\tulx\napplication/x-gnumeric\t\t\t\tgnumeric\napplication/x-gramps-xml\t\t\tgramps\napplication/x-gtar\t\t\t\tgtar\napplication/x-hdf\t\t\t\thdf\napplication/x-install-instructions\t\tinstall\napplication/x-iso9660-image\t\t\tiso\napplication/x-java-jnlp-file\t\t\tjnlp\napplication/x-latex\t\t\t\tlatex\napplication/x-lzh-compressed\t\t\tlzh lha\napplication/x-mie\t\t\t\tmie\napplication/x-mobipocket-ebook\t\t\tprc mobi\napplication/x-ms-application\t\t\tapplication\napplication/x-ms-shortcut\t\t\tlnk\napplication/x-ms-wmd\t\t\t\twmd\napplication/x-ms-wmz\t\t\t\twmz\napplication/x-ms-xbap\t\t\t\txbap\napplication/x-msaccess\t\t\t\tmdb\napplication/x-msbinder\t\t\t\tobd\napplication/x-mscardfile\t\t\tcrd\napplication/x-msclip\t\t\t\tclp\napplication/x-msdownload\t\t\texe dll com bat msi\napplication/x-msmediaview\t\t\tmvb m13 m14\napplication/x-msmetafile\t\t\twmf wmz emf emz\napplication/x-msmoney\t\t\t\tmny\napplication/x-mspublisher\t\t\tpub\napplication/x-msschedule\t\t\tscd\napplication/x-msterminal\t\t\ttrm\napplication/x-mswrite\t\t\t\twri\napplication/x-netcdf\t\t\t\tnc cdf\napplication/x-nzb\t\t\t\tnzb\napplication/x-pkcs12\t\t\t\tp12 pfx\napplication/x-pkcs7-certificates\t\tp7b spc\napplication/x-pkcs7-certreqresp\t\t\tp7r\napplication/x-rar-compressed\t\t\trar\napplication/x-research-info-systems\t\tris\napplication/x-sh\t\t\t\tsh\napplication/x-shar\t\t\t\tshar\napplication/x-shockwave-flash\t\t\tswf\napplication/x-silverlight-app\t\t\txap\napplication/x-sql\t\t\t\tsql\napplication/x-stuffit\t\t\t\tsit\napplication/x-stuffitx\t\t\t\tsitx\napplication/x-subrip\t\t\t\tsrt\napplication/x-sv4cpio\t\t\t\tsv4cpio\napplication/x-sv4crc\t\t\t\tsv4crc\napplication/x-t3vm-image\t\t\tt3\napplication/x-tads\t\t\t\tgam\napplication/x-tar\t\t\t\ttar\napplication/x-tcl\t\t\t\ttcl\napplication/x-tex\t\t\t\ttex\napplication/x-tex-tfm\t\t\t\ttfm\napplication/x-texinfo\t\t\t\ttexinfo texi\napplication/x-tgif\t\t\t\tobj\napplication/x-ustar\t\t\t\tustar\napplication/x-wais-source\t\t\tsrc\napplication/x-x509-ca-cert\t\t\tder crt\napplication/x-xfig\t\t\t\tfig\napplication/x-xliff+xml\t\t\t\txlf\napplication/x-xpinstall\t\t\t\txpi\napplication/x-xz\t\t\t\txz\napplication/x-zmachine\t\t\t\tz1 z2 z3 z4 z5 z6 z7 z8\napplication/xaml+xml\t\t\t\txaml\napplication/xcap-diff+xml\t\t\txdf\napplication/xenc+xml\t\t\t\txenc\napplication/xhtml+xml\t\t\t\txhtml xht\napplication/xml\t\t\t\t\txml xsl\napplication/xml-dtd\t\t\t\tdtd\napplication/xop+xml\t\t\t\txop\napplication/xproc+xml\t\t\t\txpl\napplication/xslt+xml\t\t\t\txslt\napplication/xspf+xml\t\t\t\txspf\napplication/xv+xml\t\t\t\tmxml xhvml xvml xvm\napplication/yang\t\t\t\tyang\napplication/yin+xml\t\t\t\tyin\napplication/zip\t\t\t\t\tzip\naudio/adpcm\t\t\t\t\tadp\naudio/basic\t\t\t\t\tau snd\naudio/midi\t\t\t\t\tmid midi kar rmi\naudio/mp4\t\t\t\t\tm4a mp4a\naudio/mpeg\t\t\t\t\tmpga mp2 mp2a mp3 m2a m3a\naudio/ogg\t\t\t\t\toga ogg spx\naudio/s3m\t\t\t\t\ts3m\naudio/silk\t\t\t\t\tsil\naudio/vnd.dece.audio\t\t\t\tuva uvva\naudio/vnd.digital-winds\t\t\t\teol\naudio/vnd.dra\t\t\t\t\tdra\naudio/vnd.dts\t\t\t\t\tdts\naudio/vnd.dts.hd\t\t\t\tdtshd\naudio/vnd.lucent.voice\t\t\t\tlvp\naudio/vnd.ms-playready.media.pya\t\tpya\naudio/vnd.nuera.ecelp4800\t\t\tecelp4800\naudio/vnd.nuera.ecelp7470\t\t\tecelp7470\naudio/vnd.nuera.ecelp9600\t\t\tecelp9600\naudio/vnd.rip\t\t\t\t\trip\naudio/webm\t\t\t\t\tweba\naudio/x-aac\t\t\t\t\taac\naudio/x-aiff\t\t\t\t\taif aiff aifc\naudio/x-caf\t\t\t\t\tcaf\naudio/x-flac\t\t\t\t\tflac\naudio/x-matroska\t\t\t\tmka\naudio/x-mpegurl\t\t\t\t\tm3u\naudio/x-ms-wax\t\t\t\t\twax\naudio/x-ms-wma\t\t\t\t\twma\naudio/x-pn-realaudio\t\t\t\tram ra\naudio/x-pn-realaudio-plugin\t\t\trmp\naudio/x-wav\t\t\t\t\twav\naudio/xm\t\t\t\t\txm\nchemical/x-cdx\t\t\t\t\tcdx\nchemical/x-cif\t\t\t\t\tcif\nchemical/x-cmdf\t\t\t\t\tcmdf\nchemical/x-cml\t\t\t\t\tcml\nchemical/x-csml\t\t\t\t\tcsml\nchemical/x-xyz\t\t\t\t\txyz\nfont/collection\t\t\t\t\tttc\nfont/otf\t\t\t\t\totf\nfont/ttf\t\t\t\t\tttf\nfont/woff\t\t\t\t\twoff\nfont/woff2\t\t\t\t\twoff2\nimage/bmp\t\t\t\t\tbmp\nimage/cgm\t\t\t\t\tcgm\nimage/g3fax\t\t\t\t\tg3\nimage/gif\t\t\t\t\tgif\nimage/ief\t\t\t\t\tief\nimage/jpeg\t\t\t\t\tjpeg jpg jpe\nimage/ktx\t\t\t\t\tktx\nimage/png\t\t\t\t\tpng\nimage/prs.btif\t\t\t\t\tbtif\nimage/sgi\t\t\t\t\tsgi\nimage/svg+xml\t\t\t\t\tsvg svgz\nimage/tiff\t\t\t\t\ttiff tif\nimage/vnd.adobe.photoshop\t\t\tpsd\nimage/vnd.dece.graphic\t\t\t\tuvi uvvi uvg uvvg\nimage/vnd.djvu\t\t\t\t\tdjvu djv\nimage/vnd.dvb.subtitle\t\t\t\tsub\nimage/vnd.dwg\t\t\t\t\tdwg\nimage/vnd.dxf\t\t\t\t\tdxf\nimage/vnd.fastbidsheet\t\t\t\tfbs\nimage/vnd.fpx\t\t\t\t\tfpx\nimage/vnd.fst\t\t\t\t\tfst\nimage/vnd.fujixerox.edmics-mmr\t\t\tmmr\nimage/vnd.fujixerox.edmics-rlc\t\t\trlc\nimage/vnd.ms-modi\t\t\t\tmdi\nimage/vnd.ms-photo\t\t\t\twdp\nimage/vnd.net-fpx\t\t\t\tnpx\nimage/vnd.wap.wbmp\t\t\t\twbmp\nimage/vnd.xiff\t\t\t\t\txif\nimage/webp\t\t\t\t\twebp\nimage/x-3ds\t\t\t\t\t3ds\nimage/x-cmu-raster\t\t\t\tras\nimage/x-cmx\t\t\t\t\tcmx\nimage/x-freehand\t\t\t\tfh fhc fh4 fh5 fh7\nimage/x-icon\t\t\t\t\tico\nimage/x-mrsid-image\t\t\t\tsid\nimage/x-pcx\t\t\t\t\tpcx\nimage/x-pict\t\t\t\t\tpic pct\nimage/x-portable-anymap\t\t\t\tpnm\nimage/x-portable-bitmap\t\t\t\tpbm\nimage/x-portable-graymap\t\t\tpgm\nimage/x-portable-pixmap\t\t\t\tppm\nimage/x-rgb\t\t\t\t\trgb\nimage/x-tga\t\t\t\t\ttga\nimage/x-xbitmap\t\t\t\t\txbm\nimage/x-xpixmap\t\t\t\t\txpm\nimage/x-xwindowdump\t\t\t\txwd\nmessage/rfc822\t\t\t\t\teml mime\nmodel/iges\t\t\t\t\tigs iges\nmodel/mesh\t\t\t\t\tmsh mesh silo\nmodel/vnd.collada+xml\t\t\t\tdae\nmodel/vnd.dwf\t\t\t\t\tdwf\nmodel/vnd.gdl\t\t\t\t\tgdl\nmodel/vnd.gtw\t\t\t\t\tgtw\nmodel/vnd.mts\t\t\t\t\tmts\nmodel/vnd.vtu\t\t\t\t\tvtu\nmodel/vrml\t\t\t\t\twrl vrml\nmodel/x3d+binary\t\t\t\tx3db x3dbz\nmodel/x3d+vrml\t\t\t\t\tx3dv x3dvz\nmodel/x3d+xml\t\t\t\t\tx3d x3dz\ntext/cache-manifest\t\t\t\tappcache\ntext/calendar\t\t\t\t\tics ifb\ntext/css\t\t\t\t\tcss\ntext/csv\t\t\t\t\tcsv\ntext/html\t\t\t\t\thtml htm\ntext/n3\t\t\t\t\t\tn3\ntext/plain\t\t\t\t\ttxt text conf def list log in\ntext/prs.lines.tag\t\t\t\tdsc\ntext/richtext\t\t\t\t\trtx\ntext/sgml\t\t\t\t\tsgml sgm\ntext/tab-separated-values\t\t\ttsv\ntext/troff\t\t\t\t\tt tr roff man me ms\ntext/turtle\t\t\t\t\tttl\ntext/uri-list\t\t\t\t\turi uris urls\ntext/vcard\t\t\t\t\tvcard\ntext/vnd.curl\t\t\t\t\tcurl\ntext/vnd.curl.dcurl\t\t\t\tdcurl\ntext/vnd.curl.mcurl\t\t\t\tmcurl\ntext/vnd.curl.scurl\t\t\t\tscurl\ntext/vnd.dvb.subtitle\t\t\t\tsub\ntext/vnd.fly\t\t\t\t\tfly\ntext/vnd.fmi.flexstor\t\t\t\tflx\ntext/vnd.graphviz\t\t\t\tgv\ntext/vnd.in3d.3dml\t\t\t\t3dml\ntext/vnd.in3d.spot\t\t\t\tspot\ntext/vnd.sun.j2me.app-descriptor\t\tjad\ntext/vnd.wap.wml\t\t\t\twml\ntext/vnd.wap.wmlscript\t\t\t\twmls\ntext/x-asm\t\t\t\t\ts asm\ntext/x-c\t\t\t\t\tc cc cxx cpp h hh dic\ntext/x-fortran\t\t\t\t\tf for f77 f90\ntext/x-java-source\t\t\t\tjava\ntext/x-nfo\t\t\t\t\tnfo\ntext/x-opml\t\t\t\t\topml\ntext/x-pascal\t\t\t\t\tp pas\ntext/x-setext\t\t\t\t\tetx\ntext/x-sfv\t\t\t\t\tsfv\ntext/x-uuencode\t\t\t\t\tuu\ntext/x-vcalendar\t\t\t\tvcs\ntext/x-vcard\t\t\t\t\tvcf\nvideo/3gpp\t\t\t\t\t3gp\nvideo/3gpp2\t\t\t\t\t3g2\nvideo/h261\t\t\t\t\th261\nvideo/h263\t\t\t\t\th263\nvideo/h264\t\t\t\t\th264\nvideo/jpeg\t\t\t\t\tjpgv\nvideo/jpm\t\t\t\t\tjpm jpgm\nvideo/mj2\t\t\t\t\tmj2 mjp2\nvideo/mp4\t\t\t\t\tmp4 mp4v mpg4\nvideo/mpeg\t\t\t\t\tmpeg mpg mpe m1v m2v\nvideo/ogg\t\t\t\t\togv\nvideo/quicktime\t\t\t\t\tqt mov\nvideo/vnd.dece.hd\t\t\t\tuvh uvvh\nvideo/vnd.dece.mobile\t\t\t\tuvm uvvm\nvideo/vnd.dece.pd\t\t\t\tuvp uvvp\nvideo/vnd.dece.sd\t\t\t\tuvs uvvs\nvideo/vnd.dece.video\t\t\t\tuvv uvvv\nvideo/vnd.dvb.file\t\t\t\tdvb\nvideo/vnd.fvt\t\t\t\t\tfvt\nvideo/vnd.mpegurl\t\t\t\tmxu m4u\nvideo/vnd.ms-playready.media.pyv\t\tpyv\nvideo/vnd.uvvu.mp4\t\t\t\tuvu uvvu\nvideo/vnd.vivo\t\t\t\t\tviv\nvideo/webm\t\t\t\t\twebm\nvideo/x-f4v\t\t\t\t\tf4v\nvideo/x-fli\t\t\t\t\tfli\nvideo/x-flv\t\t\t\t\tflv\nvideo/x-m4v\t\t\t\t\tm4v\nvideo/x-matroska\t\t\t\tmkv mk3d mks\nvideo/x-mng\t\t\t\t\tmng\nvideo/x-ms-asf\t\t\t\t\tasf asx\nvideo/x-ms-vob\t\t\t\t\tvob\nvideo/x-ms-wm\t\t\t\t\twm\nvideo/x-ms-wmv\t\t\t\t\twmv\nvideo/x-ms-wmx\t\t\t\t\twmx\nvideo/x-ms-wvx\t\t\t\t\twvx\nvideo/x-msvideo\t\t\t\t\tavi\nvideo/x-sgi-movie\t\t\t\tmovie\nvideo/x-smv\t\t\t\t\tsmv\nx-conference/x-cooltalk\t\t\t\tice\n"; + +var map = new Map(); +mime_raw.split('\n').forEach(function (row) { + var match = /(.+?)\t+(.+)/.exec(row); + if (!match) + return; + var type = match[1]; + var extensions = match[2].split(' '); + extensions.forEach(function (ext) { + map.set(ext, type); + }); +}); +function lookup(file) { + var match = /\.([^\.]+)$/.exec(file); + return match && map.get(match[1]); +} + +sourceMapSupport.install(); +function middleware(_a) { + var routes = _a.routes; + var output = __chunk1_js.dest(); + var client_info = JSON.parse(fs.readFileSync(path.join(output, 'client_info.json'), 'utf-8')); + var middleware = compose_handlers([ + function (req, res, next) { + req.pathname = req.url.replace(/\?.*/, ''); + next(); + }, + fs.existsSync(path.join(output, 'index.html')) && serve({ + pathname: '/index.html', + cache_control: 'max-age=600' + }), + fs.existsSync(path.join(output, 'service-worker.js')) && serve({ + pathname: '/service-worker.js', + cache_control: 'max-age=600' + }), + serve({ + prefix: '/client/', + cache_control: 'max-age=31536000' + }), + get_route_handler(client_info.assetsByChunkName, routes) + ].filter(Boolean)); + return middleware; +} +function serve(_a) { + var prefix = _a.prefix, pathname = _a.pathname, cache_control = _a.cache_control; + var filter = pathname + ? function (req) { return req.pathname === pathname; } + : function (req) { return req.pathname.startsWith(prefix); }; + var output = __chunk1_js.dest(); + var cache = new Map(); + var read = __chunk1_js.dev() + ? function (file) { return fs.readFileSync(path.resolve(output, file)); } + : function (file) { return (cache.has(file) ? cache : cache.set(file, fs.readFileSync(path.resolve(output, file)))).get(file); }; + return function (req, res, next) { + if (filter(req)) { + var type = lookup(req.pathname); + try { + var data = read(req.pathname.slice(1)); + res.setHeader('Content-Type', type); + res.setHeader('Cache-Control', cache_control); + res.end(data); + } + catch (err) { + res.statusCode = 404; + res.end('not found'); + } + } + else { + next(); + } + }; +} +function get_route_handler(chunks, routes) { + var template = __chunk1_js.dev() + ? function () { return fs.readFileSync('app/template.html', 'utf-8'); } + : (function (str) { return function () { return str; }; })(fs.readFileSync('app/template.html', 'utf-8')); + function handle_route(route, req, res) { + req.params = route.params(route.pattern.exec(req.pathname)); + var mod = route.module; + if (route.type === 'page') { + res.setHeader('Content-Type', 'text/html'); + // preload main.js and current route + // TODO detect other stuff we can preload? images, CSS, fonts? + var link = [] + .concat(chunks.main, chunks[route.id]) + .map(function (file) { return ";rel=\"preload\";as=\"script\""; }) + .join(', '); + res.setHeader('Link', link); + var data_1 = { params: req.params, query: req.query }; + var redirect_1; + var error_1; + Promise.resolve(mod.preload ? mod.preload.call({ + redirect: function (statusCode, location) { + redirect_1 = { statusCode: statusCode, location: location }; + }, + error: function (statusCode, message) { + error_1 = { statusCode: statusCode, message: message }; + } + }, req) : {})["catch"](function (err) { + error_1 = { statusCode: 500, message: err }; + }).then(function (preloaded) { + if (redirect_1) { + res.statusCode = redirect_1.statusCode; + res.setHeader('Location', redirect_1.location); + res.end(); + return; + } + if (error_1) { + handle_error(req, res, error_1.statusCode, error_1.message); + return; + } + var serialized = try_serialize(preloaded); // TODO bail on non-POJOs + Object.assign(data_1, preloaded); + var _a = mod.render(data_1), html = _a.html, head = _a.head, css = _a.css; + var scripts = [] + .concat(chunks.main) // chunks main might be an array. it might not! thanks, webpack + .map(function (file) { return ""; }) + .join(''); + scripts = "" + scripts; + var page = template() + .replace('%sapper.scripts%', scripts) + .replace('%sapper.html%', html) + .replace('%sapper.head%', "" + head + "") + .replace('%sapper.styles%', (css && css.code ? "" : '')); + res.end(page); + if (process.send) { + process.send({ + __sapper__: true, + url: req.url, + method: req.method, + status: 200, + type: 'text/html', + body: page + }); + } + }); + } + else { + var method = req.method.toLowerCase(); + // 'delete' cannot be exported from a module because it is a keyword, + // so check for 'del' instead + var method_export = method === 'delete' ? 'del' : method; + var handler = mod[method_export]; + if (handler) { + if (process.env.SAPPER_EXPORT) { + var write_1 = res.write, end_1 = res.end, setHeader_1 = res.setHeader; + var chunks_1 = []; + var headers_1 = {}; + // intercept data so that it can be exported + res.write = function (chunk) { + chunks_1.push(new Buffer(chunk)); + write_1.apply(res, arguments); + }; + res.setHeader = function (name, value) { + headers_1[name.toLowerCase()] = value; + setHeader_1.apply(res, arguments); + }; + res.end = function (chunk) { + if (chunk) + chunks_1.push(new Buffer(chunk)); + end_1.apply(res, arguments); + process.send({ + __sapper__: true, + url: req.url, + method: req.method, + status: res.statusCode, + type: headers_1['content-type'], + body: Buffer.concat(chunks_1).toString() + }); + }; + } + var handle_bad_result = function (err) { + if (err) { + console.error(err.stack); + res.statusCode = 500; + res.end(err.message); + } + else { + handle_error(req, res, 404, 'Not found'); + } + }; + try { + handler(req, res, handle_bad_result); + } + catch (err) { + handle_bad_result(err); + } + } + else { + // no matching handler for method — 404 + handle_error(req, res, 404, 'Not found'); + } + } + } + var not_found_route = routes.find(function (route) { return route.error === '4xx'; }); + var error_route = routes.find(function (route) { return route.error === '5xx'; }); + function handle_error(req, res, statusCode, message) { + res.statusCode = statusCode; + res.setHeader('Content-Type', 'text/html'); + var error = message instanceof Error ? message : new Error(message); + var not_found = statusCode >= 400 && statusCode < 500; + var route = not_found + ? not_found_route + : error_route; + var title = not_found + ? 'Not found' + : "Internal server error: " + error.message; + var rendered = route ? route.module.render({ + status: statusCode, + error: error + }) : { head: '', css: null, html: title }; + var head = rendered.head, css = rendered.css, html = rendered.html; + var page = template() + .replace('%sapper.scripts%', "") + .replace('%sapper.html%', html) + .replace('%sapper.head%', "" + head + "") + .replace('%sapper.styles%', (css && css.code ? "" : '')); + res.end(page); + } + return function find_route(req, res) { + var url = req.pathname; + try { + for (var _i = 0, routes_1 = routes; _i < routes_1.length; _i++) { + var route = routes_1[_i]; + if (!route.error && route.pattern.test(url)) + return handle_route(route, req, res); + } + handle_error(req, res, 404, 'Not found'); + } + catch (error) { + handle_error(req, res, 500, error); + } + }; +} +function compose_handlers(handlers) { + return function (req, res, next) { + var i = 0; + function go() { + var handler = handlers[i]; + if (handler) { + handler(req, res, function () { + i += 1; + go(); + }); + } + else { + next(); + } + } + go(); + }; +} +function try_serialize(data) { + try { + return devalue(data); + } + catch (err) { + return null; + } +} + +module.exports = middleware; +//# sourceMappingURL=./middleware.ts.js.map diff --git a/middleware.ts.js.map b/middleware.ts.js.map new file mode 100644 index 0000000..339dd03 --- /dev/null +++ b/middleware.ts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"middleware.ts.js","sources":["src/middleware/mime.ts","src/middleware.ts"],"sourcesContent":["import mime_raw from './mime-types.md';\n\nconst map: Map = new Map();\n\nmime_raw.split('\\n').forEach((row: string) => {\n\tconst match = /(.+?)\\t+(.+)/.exec(row);\n\tif (!match) return;\n\n\tconst type = match[1];\n\tconst extensions = match[2].split(' ');\n\n\textensions.forEach(ext => {\n\t\tmap.set(ext, type);\n\t});\n});\n\nexport function lookup(file: string) {\n\tconst match = /\\.([^\\.]+)$/.exec(file);\n\treturn match && map.get(match[1]);\n}","import * as fs from 'fs';\nimport * as path from 'path';\nimport { ClientRequest, ServerResponse } from 'http';\nimport mkdirp from 'mkdirp';\nimport rimraf from 'rimraf';\nimport devalue from 'devalue';\nimport { lookup } from './middleware/mime';\nimport { create_routes, templates, create_compilers } from './core/index';\nimport { dest, dev } from './config';\nimport { Route, Template } from './interfaces';\nimport sourceMapSupport from 'source-map-support';\n\nsourceMapSupport.install();\n\ntype RouteObject = {\n\tid: string;\n\ttype: 'page' | 'route';\n\tpattern: RegExp;\n\tparams: (match: RegExpMatchArray) => Record;\n\tmodule: {\n\t\trender: (data: any) => {\n\t\t\thead: string;\n\t\t\tcss: { code: string, map: any };\n\t\t\thtml: string\n\t\t},\n\t\tpreload: (data: any) => any | Promise\n\t};\n\terror?: string;\n}\n\ntype Handler = (req: Req, res: ServerResponse, next: () => void) => void;\n\ninterface Req extends ClientRequest {\n\turl: string;\n\tmethod: string;\n\tpathname: string;\n\tparams: Record;\n}\n\nexport default function middleware({ routes }: {\n\troutes: RouteObject[]\n}) {\n\tconst output = dest();\n\n\tconst client_info = JSON.parse(fs.readFileSync(path.join(output, 'client_info.json'), 'utf-8'));\n\n\tconst middleware = compose_handlers([\n\t\t(req: Req, res: ServerResponse, next: () => void) => {\n\t\t\treq.pathname = req.url.replace(/\\?.*/, '');\n\t\t\tnext();\n\t\t},\n\n\t\tfs.existsSync(path.join(output, 'index.html')) && serve({\n\t\t\tpathname: '/index.html',\n\t\t\tcache_control: 'max-age=600'\n\t\t}),\n\n\t\tfs.existsSync(path.join(output, 'service-worker.js')) && serve({\n\t\t\tpathname: '/service-worker.js',\n\t\t\tcache_control: 'max-age=600'\n\t\t}),\n\n\t\tserve({\n\t\t\tprefix: '/client/',\n\t\t\tcache_control: 'max-age=31536000'\n\t\t}),\n\n\t\tget_route_handler(client_info.assetsByChunkName, routes)\n\t].filter(Boolean));\n\n\treturn middleware;\n}\n\nfunction serve({ prefix, pathname, cache_control }: {\n\tprefix?: string,\n\tpathname?: string,\n\tcache_control: string\n}) {\n\tconst filter = pathname\n\t\t? (req: Req) => req.pathname === pathname\n\t\t: (req: Req) => req.pathname.startsWith(prefix);\n\n\tconst output = dest();\n\n\tconst cache: Map = new Map();\n\n\tconst read = dev()\n\t\t? (file: string) => fs.readFileSync(path.resolve(output, file))\n\t\t: (file: string) => (cache.has(file) ? cache : cache.set(file, fs.readFileSync(path.resolve(output, file)))).get(file)\n\n\treturn (req: Req, res: ServerResponse, next: () => void) => {\n\t\tif (filter(req)) {\n\t\t\tconst type = lookup(req.pathname);\n\n\t\t\ttry {\n\t\t\t\tconst data = read(req.pathname.slice(1));\n\n\t\t\t\tres.setHeader('Content-Type', type);\n\t\t\t\tres.setHeader('Cache-Control', cache_control);\n\t\t\t\tres.end(data);\n\t\t\t} catch (err) {\n\t\t\t\tres.statusCode = 404;\n\t\t\t\tres.end('not found');\n\t\t\t}\n\t\t} else {\n\t\t\tnext();\n\t\t}\n\t};\n}\n\nconst resolved = Promise.resolve();\n\nfunction get_route_handler(chunks: Record, routes: RouteObject[]) {\n\tconst template = dev()\n\t\t? () => fs.readFileSync('app/template.html', 'utf-8')\n\t\t: (str => () => str)(fs.readFileSync('app/template.html', 'utf-8'));\n\n\tfunction handle_route(route: RouteObject, req: Req, res: ServerResponse) {\n\t\treq.params = route.params(route.pattern.exec(req.pathname));\n\n\t\tconst mod = route.module;\n\n\t\tif (route.type === 'page') {\n\t\t\tres.setHeader('Content-Type', 'text/html');\n\n\t\t\t// preload main.js and current route\n\t\t\t// TODO detect other stuff we can preload? images, CSS, fonts?\n\t\t\tconst link = []\n\t\t\t\t.concat(chunks.main, chunks[route.id])\n\t\t\t\t.map(file => `;rel=\"preload\";as=\"script\"`)\n\t\t\t\t.join(', ');\n\n\t\t\tres.setHeader('Link', link);\n\n\t\t\tconst data = { params: req.params, query: req.query };\n\n\t\t\tlet redirect: { statusCode: number, location: string };\n\t\t\tlet error: { statusCode: number, message: Error | string };\n\n\t\t\tPromise.resolve(\n\t\t\t\tmod.preload ? mod.preload.call({\n\t\t\t\t\tredirect: (statusCode: number, location: string) => {\n\t\t\t\t\t\tredirect = { statusCode, location };\n\t\t\t\t\t},\n\t\t\t\t\terror: (statusCode: number, message: Error | string) => {\n\t\t\t\t\t\terror = { statusCode, message };\n\t\t\t\t\t}\n\t\t\t\t}, req) : {}\n\t\t\t).catch(err => {\n\t\t\t\terror = { statusCode: 500, message: err };\n\t\t\t}).then(preloaded => {\n\t\t\t\tif (redirect) {\n\t\t\t\t\tres.statusCode = redirect.statusCode;\n\t\t\t\t\tres.setHeader('Location', redirect.location);\n\t\t\t\t\tres.end();\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error) {\n\t\t\t\t\thandle_error(req, res, error.statusCode, error.message);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst serialized = try_serialize(preloaded); // TODO bail on non-POJOs\n\t\t\t\tObject.assign(data, preloaded);\n\n\t\t\t\tconst { html, head, css } = mod.render(data);\n\n\t\t\t\tlet scripts = []\n\t\t\t\t\t.concat(chunks.main) // chunks main might be an array. it might not! thanks, webpack\n\t\t\t\t\t.map(file => ``)\n\t\t\t\t\t.join('');\n\n\t\t\t\tscripts = `${scripts}`;\n\n\t\t\t\tconst page = template()\n\t\t\t\t\t.replace('%sapper.scripts%', scripts)\n\t\t\t\t\t.replace('%sapper.html%', html)\n\t\t\t\t\t.replace('%sapper.head%', `${head}`)\n\t\t\t\t\t.replace('%sapper.styles%', (css && css.code ? `` : ''));\n\n\t\t\t\tres.end(page);\n\n\t\t\t\tif (process.send) {\n\t\t\t\t\tprocess.send({\n\t\t\t\t\t\t__sapper__: true,\n\t\t\t\t\t\turl: req.url,\n\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\tstatus: 200,\n\t\t\t\t\t\ttype: 'text/html',\n\t\t\t\t\t\tbody: page\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\n\t\telse {\n\t\t\tconst method = req.method.toLowerCase();\n\t\t\t// 'delete' cannot be exported from a module because it is a keyword,\n\t\t\t// so check for 'del' instead\n\t\t\tconst method_export = method === 'delete' ? 'del' : method;\n\t\t\tconst handler = mod[method_export];\n\t\t\tif (handler) {\n\t\t\t\tif (process.env.SAPPER_EXPORT) {\n\t\t\t\t\tconst { write, end, setHeader } = res;\n\t\t\t\t\tconst chunks: any[] = [];\n\t\t\t\t\tconst headers: Record = {};\n\n\t\t\t\t\t// intercept data so that it can be exported\n\t\t\t\t\tres.write = function(chunk: any) {\n\t\t\t\t\t\tchunks.push(new Buffer(chunk));\n\t\t\t\t\t\twrite.apply(res, arguments);\n\t\t\t\t\t};\n\n\t\t\t\t\tres.setHeader = function(name: string, value: string) {\n\t\t\t\t\t\theaders[name.toLowerCase()] = value;\n\t\t\t\t\t\tsetHeader.apply(res, arguments);\n\t\t\t\t\t};\n\n\t\t\t\t\tres.end = function(chunk?: any) {\n\t\t\t\t\t\tif (chunk) chunks.push(new Buffer(chunk));\n\t\t\t\t\t\tend.apply(res, arguments);\n\n\t\t\t\t\t\tprocess.send({\n\t\t\t\t\t\t\t__sapper__: true,\n\t\t\t\t\t\t\turl: req.url,\n\t\t\t\t\t\t\tmethod: req.method,\n\t\t\t\t\t\t\tstatus: res.statusCode,\n\t\t\t\t\t\t\ttype: headers['content-type'],\n\t\t\t\t\t\t\tbody: Buffer.concat(chunks).toString()\n\t\t\t\t\t\t});\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tconst handle_bad_result = (err?: Error) => {\n\t\t\t\t\tif (err) {\n\t\t\t\t\t\tconsole.error(err.stack);\n\t\t\t\t\t\tres.statusCode = 500;\n\t\t\t\t\t\tres.end(err.message);\n\t\t\t\t\t} else {\n\t\t\t\t\t\thandle_error(req, res, 404, 'Not found');\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\ttry {\n\t\t\t\t\thandler(req, res, handle_bad_result);\n\t\t\t\t} catch (err) {\n\t\t\t\t\thandle_bad_result(err);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// no matching handler for method — 404\n\t\t\t\thandle_error(req, res, 404, 'Not found');\n\t\t\t}\n\t\t}\n\t}\n\n\tconst not_found_route = routes.find((route: RouteObject) => route.error === '4xx');\n\tconst error_route = routes.find((route: RouteObject) => route.error === '5xx');\n\n\tfunction handle_error(req: Req, res: ServerResponse, statusCode: number, message: Error | string) {\n\t\tres.statusCode = statusCode;\n\t\tres.setHeader('Content-Type', 'text/html');\n\n\t\tconst error = message instanceof Error ? message : new Error(message);\n\n\t\tconst not_found = statusCode >= 400 && statusCode < 500;\n\n\t\tconst route = not_found\n\t\t\t? not_found_route\n\t\t\t: error_route;\n\n\t\tconst title: string = not_found\n\t\t\t? 'Not found'\n\t\t\t: `Internal server error: ${error.message}`;\n\n\t\tconst rendered = route ? route.module.render({\n\t\t\tstatus: statusCode,\n\t\t\terror\n\t\t}) : { head: '', css: null, html: title };\n\n\t\tconst { head, css, html } = rendered;\n\n\t\tconst page = template()\n\t\t\t.replace('%sapper.scripts%', ``)\n\t\t\t.replace('%sapper.html%', html)\n\t\t\t.replace('%sapper.head%', `${head}`)\n\t\t\t.replace('%sapper.styles%', (css && css.code ? `` : ''));\n\n\t\tres.end(page);\n\t}\n\n\treturn function find_route(req: Req, res: ServerResponse) {\n\t\tconst url = req.pathname;\n\n\t\ttry {\n\t\t\tfor (const route of routes) {\n\t\t\t\tif (!route.error && route.pattern.test(url)) return handle_route(route, req, res);\n\t\t\t}\n\n\t\t\thandle_error(req, res, 404, 'Not found');\n\t\t} catch (error) {\n\t\t\thandle_error(req, res, 500, error);\n\t\t}\n\t};\n}\n\nfunction compose_handlers(handlers: Handler[]) {\n\treturn (req: Req, res: ServerResponse, next: () => void) => {\n\t\tlet i = 0;\n\t\tfunction go() {\n\t\t\tconst handler = handlers[i];\n\n\t\t\tif (handler) {\n\t\t\t\thandler(req, res, () => {\n\t\t\t\t\ti += 1;\n\t\t\t\t\tgo();\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tnext();\n\t\t\t}\n\t\t}\n\n\t\tgo();\n\t};\n}\n\nfunction read_json(file: string) {\n\treturn JSON.parse(fs.readFileSync(file, 'utf-8'));\n}\n\nfunction try_serialize(data: any) {\n\ttry {\n\t\treturn devalue(data);\n\t} catch (err) {\n\t\treturn null;\n\t}\n}"],"names":["dest","fs.readFileSync","path.join","fs.existsSync","dev","path.resolve"],"mappings":";;;;;;;;;;;;AAEA,IAAM,GAAG,GAAwB,IAAI,GAAG,EAAE,CAAC;AAE3C,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAC,GAAW;IACxC,IAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,KAAK;QAAE,OAAO;IAEnB,IAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACtB,IAAM,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAEvC,UAAU,CAAC,OAAO,CAAC,UAAA,GAAG;QACrB,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;KACnB,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B;IAAC,OAAO,GAAG,EAAE;QACb,OAAO,IAAI,CAAC;KACZ;CACD;;;;"} \ No newline at end of file diff --git a/package.json b/package.json index 358fb4a..ed1eaf8 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,12 @@ "description": "Military-grade apps, engineered by Svelte", "main": "middleware.js", "bin": { - "sapper": "cli.js" + "sapper": "sapper" }, "files": [ - "cli.js", - "core.js", - "middleware.js", + "*.js", + "*.ts.js", "runtime", - "runtime.js", - "sapper-dev-client.js", "webpack" ], "directories": { @@ -51,7 +48,7 @@ "mocha": "^4.0.1", "nightmare": "^2.10.0", "npm-run-all": "^4.1.2", - "rollup": "^0.53.0", + "rollup": "^0.56.5", "rollup-plugin-commonjs": "^8.3.0", "rollup-plugin-json": "^2.3.0", "rollup-plugin-string": "^2.0.2", diff --git a/rollup.config.js b/rollup.config.js index 6bad2d6..cea6673 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -10,36 +10,39 @@ const external = [].concat( 'sapper/core.js' ); -const paths = { - 'sapper/core.js': './core.js' -}; - -const plugins = [ - string({ - include: '**/*.md' - }), - json(), - commonjs(), - typescript({ - typescript: require('typescript') - }) -]; - export default [ - { name: 'cli', banner: true }, - { name: 'core' }, - { name: 'middleware' }, - { name: 'runtime', format: 'es' }, - { name: 'webpack', file: 'webpack/config' } -].map(obj => ({ - input: `src/${obj.name}/index.ts`, - output: { - file: `${obj.file || obj.name}.js`, - format: obj.format || 'cjs', - banner: obj.banner && '#!/usr/bin/env node', - paths, - sourcemap: true + { + input: `src/runtime/index.ts`, + output: { + file: `runtime.js`, + format: 'es' + }, + plugins: [ + typescript({ + typescript: require('typescript') + }) + ] }, - external, - plugins -})); + + { + input: [`src/cli.ts`, `src/core.ts`, `src/middleware.ts`, `src/webpack.ts`], + output: { + dir: '.', + format: 'cjs', + sourcemap: true + }, + external, + plugins: [ + string({ + include: '**/*.md' + }), + json(), + commonjs(), + typescript({ + typescript: require('typescript') + }) + ], + experimentalCodeSplitting: true, + experimentalDynamicImport: true + } +]; \ No newline at end of file diff --git a/sapper b/sapper new file mode 100755 index 0000000..3f0b783 --- /dev/null +++ b/sapper @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require('./cli.ts.js'); \ No newline at end of file diff --git a/src/cli/index.ts b/src/cli.ts similarity index 93% rename from src/cli/index.ts rename to src/cli.ts index f6678ed..c80ef82 100755 --- a/src/cli/index.ts +++ b/src/cli.ts @@ -4,13 +4,13 @@ import * as child_process from 'child_process'; import sade from 'sade'; import * as clorox from 'clorox'; import prettyMs from 'pretty-ms'; -import help from './help.md'; -import build from './build'; -import exporter from './export'; -import dev from './dev'; -import upgrade from './upgrade'; +import help from './cli/help.md'; +import build from './cli/build'; +import exporter from './cli/export'; +import dev from './cli/dev'; +import upgrade from './cli/upgrade'; import * as ports from 'port-authority'; -import * as pkg from '../../package.json'; +import * as pkg from '../package.json'; const prog = sade('sapper').version(pkg.version); diff --git a/src/cli/build.ts b/src/cli/build.ts index f71b06e..b17e0da 100644 --- a/src/cli/build.ts +++ b/src/cli/build.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import * as clorox from 'clorox'; import mkdirp from 'mkdirp'; import rimraf from 'rimraf'; -import { create_compilers, create_app, create_routes, create_serviceworker } from 'sapper/core.js' +import { create_compilers, create_app, create_routes, create_serviceworker } from '../core' import { src, dest, dev } from '../config'; export default async function build() { diff --git a/src/cli/dev.ts b/src/cli/dev.ts index 2313479..80cc99b 100644 --- a/src/cli/dev.ts +++ b/src/cli/dev.ts @@ -10,7 +10,7 @@ import format_messages from 'webpack-format-messages'; import prettyMs from 'pretty-ms'; import * as ports from 'port-authority'; import { dest } from '../config'; -import { create_compilers, create_app, create_routes, create_serviceworker } from 'sapper/core.js'; +import { create_compilers, create_app, create_routes, create_serviceworker } from '../core'; type Deferred = { promise?: Promise; diff --git a/src/core.ts b/src/core.ts new file mode 100644 index 0000000..d6c2400 --- /dev/null +++ b/src/core.ts @@ -0,0 +1,4 @@ +export { default as create_app } from './core/create_app'; +export { default as create_serviceworker } from './core/create_serviceworker'; +export { default as create_compilers } from './core/create_compilers'; +export { default as create_routes } from './core/create_routes'; \ No newline at end of file diff --git a/src/core/index.ts b/src/core/index.ts deleted file mode 100644 index 80b7812..0000000 --- a/src/core/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export { default as create_app } from './create_app'; -export { default as create_serviceworker } from './create_serviceworker'; -export { default as create_compilers } from './create_compilers'; -export { default as create_routes } from './create_routes'; \ No newline at end of file diff --git a/src/middleware/index.ts b/src/middleware.ts similarity index 97% rename from src/middleware/index.ts rename to src/middleware.ts index ebe0db3..6aa9e5e 100644 --- a/src/middleware/index.ts +++ b/src/middleware.ts @@ -4,10 +4,10 @@ import { ClientRequest, ServerResponse } from 'http'; import mkdirp from 'mkdirp'; import rimraf from 'rimraf'; import devalue from 'devalue'; -import { lookup } from './mime'; -import { create_routes, templates, create_compilers } from 'sapper/core.js'; -import { dest, dev } from '../config'; -import { Route, Template } from '../interfaces'; +import { lookup } from './middleware/mime'; +import { create_routes, templates, create_compilers } from './core/index'; +import { dest, dev } from './config'; +import { Route, Template } from './interfaces'; import sourceMapSupport from 'source-map-support'; sourceMapSupport.install(); diff --git a/src/webpack/index.ts b/src/webpack.ts similarity index 95% rename from src/webpack/index.ts rename to src/webpack.ts index 5b29992..7fd3e86 100644 --- a/src/webpack/index.ts +++ b/src/webpack.ts @@ -1,4 +1,4 @@ -import { dest, dev } from '../config'; +import { dest, dev } from './config'; export default { dev: dev(), diff --git a/test/common/test.js b/test/common/test.js index f825e84..e40c87b 100644 --- a/test/common/test.js +++ b/test/common/test.js @@ -25,7 +25,7 @@ Nightmare.action('prefetchRoutes', function(done) { this.evaluate_now(() => window.prefetchRoutes(), done); }); -const cli = path.resolve(__dirname, '../../cli.js'); +const cli = path.resolve(__dirname, '../../sapper'); describe('sapper', function() { process.chdir(path.resolve(__dirname, '../app')); diff --git a/test/unit/create_routes.test.js b/test/unit/create_routes.test.js index a58b626..50924dd 100644 --- a/test/unit/create_routes.test.js +++ b/test/unit/create_routes.test.js @@ -1,5 +1,5 @@ const assert = require('assert'); -const { create_routes } = require('../../core.js'); +const { create_routes } = require('../../core.ts.js'); describe('create_routes', () => { it('sorts routes correctly', () => { diff --git a/webpack.js b/webpack.js new file mode 100644 index 0000000..38e44b8 --- /dev/null +++ b/webpack.js @@ -0,0 +1,2 @@ +// TODO write to this file, instead of webpack.ts.js +module.exports = require('./webpack.ts.js'); \ No newline at end of file diff --git a/webpack.ts.js b/webpack.ts.js new file mode 100644 index 0000000..b801fb7 --- /dev/null +++ b/webpack.ts.js @@ -0,0 +1,54 @@ +'use strict'; + +var __chunk1_js = require('./chunk1.js'); + +var webpack = { + dev: __chunk1_js.dev(), + client: { + entry: function () { + return { + main: './app/client' + }; + }, + output: function () { + return { + path: __chunk1_js.dest() + "/client", + filename: '[hash]/[name].js', + chunkFilename: '[hash]/[name].[id].js', + publicPath: '/client/' + }; + } + }, + server: { + entry: function () { + return { + server: './app/server' + }; + }, + output: function () { + return { + path: __chunk1_js.dest(), + filename: '[name].js', + chunkFilename: '[hash]/[name].[id].js', + libraryTarget: 'commonjs2' + }; + } + }, + serviceworker: { + entry: function () { + return { + 'service-worker': './app/service-worker' + }; + }, + output: function () { + return { + path: __chunk1_js.dest(), + filename: '[name].js', + chunkFilename: '[name].[id].[hash].js' + }; + } + } +}; + +module.exports = webpack; +//# sourceMappingURL=./webpack.ts.js.map diff --git a/webpack.ts.js.map b/webpack.ts.js.map new file mode 100644 index 0000000..eaadffa --- /dev/null +++ b/webpack.ts.js.map @@ -0,0 +1 @@ +{"version":3,"file":"webpack.ts.js","sources":["src/webpack.ts"],"sourcesContent":["import { dest, dev } from './config';\n\nexport default {\n\tdev: dev(),\n\n\tclient: {\n\t\tentry: () => {\n\t\t\treturn {\n\t\t\t\tmain: './app/client'\n\t\t\t};\n\t\t},\n\n\t\toutput: () => {\n\t\t\treturn {\n\t\t\t\tpath: `${dest()}/client`,\n\t\t\t\tfilename: '[hash]/[name].js',\n\t\t\t\tchunkFilename: '[hash]/[name].[id].js',\n\t\t\t\tpublicPath: '/client/'\n\t\t\t};\n\t\t}\n\t},\n\n\tserver: {\n\t\tentry: () => {\n\t\t\treturn {\n\t\t\t\tserver: './app/server'\n\t\t\t};\n\t\t},\n\n\t\toutput: () => {\n\t\t\treturn {\n\t\t\t\tpath: dest(),\n\t\t\t\tfilename: '[name].js',\n\t\t\t\tchunkFilename: '[hash]/[name].[id].js',\n\t\t\t\tlibraryTarget: 'commonjs2'\n\t\t\t};\n\t\t}\n\t},\n\n\tserviceworker: {\n\t\tentry: () => {\n\t\t\treturn {\n\t\t\t\t'service-worker': './app/service-worker'\n\t\t\t};\n\t\t},\n\n\t\toutput: () => {\n\t\t\treturn {\n\t\t\t\tpath: dest(),\n\t\t\t\tfilename: '[name].js',\n\t\t\t\tchunkFilename: '[name].[id].[hash].js'\n\t\t\t}\n\t\t}\n\t}\n};"],"names":["dev","dest"],"mappings":";;;;AAEA,cAAe;IACd,GAAG,EAAEA,eAAG,EAAE;IAEV,MAAM,EAAE;QACP,KAAK,EAAE;YACN,OAAO;gBACN,IAAI,EAAE,cAAc;aACpB,CAAC;SACF;QAED,MAAM,EAAE;YACP,OAAO;gBACN,IAAI,EAAKC,gBAAI,EAAE,YAAS;gBACxB,QAAQ,EAAE,kBAAkB;gBAC5B,aAAa,EAAE,uBAAuB;gBACtC,UAAU,EAAE,UAAU;aACtB,CAAC;SACF;KACD;IAED,MAAM,EAAE;QACP,KAAK,EAAE;YACN,OAAO;gBACN,MAAM,EAAE,cAAc;aACtB,CAAC;SACF;QAED,MAAM,EAAE;YACP,OAAO;gBACN,IAAI,EAAEA,gBAAI,EAAE;gBACZ,QAAQ,EAAE,WAAW;gBACrB,aAAa,EAAE,uBAAuB;gBACtC,aAAa,EAAE,WAAW;aAC1B,CAAC;SACF;KACD;IAED,aAAa,EAAE;QACd,KAAK,EAAE;YACN,OAAO;gBACN,gBAAgB,EAAE,sBAAsB;aACxC,CAAC;SACF;QAED,MAAM,EAAE;YACP,OAAO;gBACN,IAAI,EAAEA,gBAAI,EAAE;gBACZ,QAAQ,EAAE,WAAW;gBACrB,aAAa,EAAE,uBAAuB;aACtC,CAAA;SACD;KACD;CACD,CAAC;;;;"} \ No newline at end of file