'use strict'; var sirv = require('sirv'); var polka = require('polka'); var compression = require('compression'); var fs = require('fs'); var path = require('path'); var Stream = require('stream'); var http = require('http'); var Url = require('url'); var https = require('https'); var zlib = require('zlib'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var sirv__default = /*#__PURE__*/_interopDefaultLegacy(sirv); var polka__default = /*#__PURE__*/_interopDefaultLegacy(polka); var compression__default = /*#__PURE__*/_interopDefaultLegacy(compression); var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); var path__default = /*#__PURE__*/_interopDefaultLegacy(path); var Stream__default = /*#__PURE__*/_interopDefaultLegacy(Stream); var http__default = /*#__PURE__*/_interopDefaultLegacy(http); var Url__default = /*#__PURE__*/_interopDefaultLegacy(Url); var https__default = /*#__PURE__*/_interopDefaultLegacy(https); var zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib); // Ordinarily, you'd generate this data from markdown files in your // repo, or fetch them from a database of some kind. But in order to // avoid unnecessary dependencies in the starter template, and in the // service of obviousness, we're just going to leave it here. // This file is called `_posts.js` rather than `posts.js`, because // we don't want to create an `/blog/posts` route — the leading // underscore tells Sapper not to do that. const posts = [ { title: 'What is Sapper?', slug: 'what-is-sapper', html: `

First, you have to know what Svelte is. Svelte is a UI framework with a bold new idea: rather than providing a library that you write code with (like React or Vue, for example), it's a compiler that turns your components into highly optimized vanilla JavaScript. If you haven't already read the introductory blog post, you should!

Sapper is a Next.js-style framework (more on that here) built around Svelte. It makes it embarrassingly easy to create extremely high performance web apps. Out of the box, you get:

It's implemented as Express middleware. Everything is set up and waiting for you to get started, but you keep complete control over the server, service worker, webpack config and everything else, so it's as flexible as you need it to be.

` }, { title: 'How to use Sapper', slug: 'how-to-use-sapper', html: `

Step one

Create a new project, using degit:

npx degit "sveltejs/sapper-template#rollup" my-app
			cd my-app
			npm install # or yarn!
			npm run dev
			

Step two

Go to localhost:3000. Open my-app in your editor. Edit the files in the src/routes directory or add new ones.

Step three

...

Step four

Resist overdone joke formats.

` }, { title: 'Why the name?', slug: 'why-the-name', html: `

In war, the soldiers who build bridges, repair roads, clear minefields and conduct demolitions — all under combat conditions — are known as sappers.

For web developers, the stakes are generally lower than those for combat engineers. But we face our own hostile environment: underpowered devices, poor network connections, and the complexity inherent in front-end engineering. Sapper, which is short for Svelte app maker, is your courageous and dutiful ally.

` }, { title: 'How is Sapper different from Next.js?', slug: 'how-is-sapper-different-from-next', html: `

Next.js is a React framework from Vercel, and is the inspiration for Sapper. There are a few notable differences, however:

` }, { title: 'How can I get involved?', slug: 'how-can-i-get-involved', html: `

We're so glad you asked! Come on over to the Svelte and Sapper repos, and join us in the Discord chatroom. Everyone is welcome, especially you!

` } ]; posts.forEach(post => { post.html = post.html.replace(/^\t{3}/gm, ''); }); const contents = JSON.stringify(posts.map(post => { return { title: post.title, slug: post.slug }; })); function get$1(req, res) { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(contents); } var route_0 = /*#__PURE__*/Object.freeze({ __proto__: null, get: get$1 }); const lookup = new Map(); posts.forEach(post => { lookup.set(post.slug, JSON.stringify(post)); }); function get(req, res, next) { // the `slug` parameter is available because // this file is called [slug].json.js const { slug } = req.params; if (lookup.has(slug)) { res.writeHead(200, { 'Content-Type': 'application/json' }); res.end(lookup.get(slug)); } else { res.writeHead(404, { 'Content-Type': 'application/json' }); res.end(JSON.stringify({ message: `Not found` })); } } var route_1 = /*#__PURE__*/Object.freeze({ __proto__: null, get: get }); function noop$1() { } function run(fn) { return fn(); } function blank_object() { return Object.create(null); } function run_all(fns) { fns.forEach(run); } function safe_not_equal(a, b) { return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function'); } let current_component; function set_current_component(component) { current_component = component; } function get_current_component() { if (!current_component) throw new Error('Function called outside component initialization'); return current_component; } function afterUpdate(fn) { get_current_component().$$.after_update.push(fn); } function setContext(key, context) { get_current_component().$$.context.set(key, context); } Promise.resolve(); const escaped$1 = { '"': '"', "'": ''', '&': '&', '<': '<', '>': '>' }; function escape(html) { return String(html).replace(/["'&<>]/g, match => escaped$1[match]); } function each(items, fn) { let str = ''; for (let i = 0; i < items.length; i += 1) { str += fn(items[i], i); } return str; } const missing_component = { $$render: () => '' }; function validate_component(component, name) { if (!component || !component.$$render) { if (name === 'svelte:component') name += ' this={...}'; throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`); } return component; } let on_destroy; function create_ssr_component(fn) { function $$render(result, props, bindings, slots, context) { const parent_component = current_component; const $$ = { on_destroy, context: new Map(parent_component ? parent_component.$$.context : context || []), // these will be immediately discarded on_mount: [], before_update: [], after_update: [], callbacks: blank_object() }; set_current_component({ $$ }); const html = fn(result, props, bindings, slots); set_current_component(parent_component); return html; } return { render: (props = {}, { $$slots = {}, context = new Map() } = {}) => { on_destroy = []; const result = { title: '', head: '', css: new Set() }; const html = $$render(result, props, {}, $$slots, context); run_all(on_destroy); return { html, css: { code: Array.from(result.css).map(css => css.code).join('\n'), map: null // TODO }, head: result.title + result.head }; }, $$render }; } function add_attribute(name, value, boolean) { if (value == null || (boolean && !value)) return ''; return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `"${value}"`}`}`; } var successkid = "/client/465898c830bb9d2c.jpg"; /* src/routes/index.svelte generated by Svelte v3.42.1 */ const css$5 = { code: "h1.svelte-1kk9opm,figure.svelte-1kk9opm,p.svelte-1kk9opm{text-align:center;margin:0 auto}h1.svelte-1kk9opm{font-size:2.8em;text-transform:uppercase;font-weight:700;margin:0 0 0.5em 0}figure.svelte-1kk9opm{margin:0 0 1em 0}img.svelte-1kk9opm{width:100%;max-width:400px;margin:0 0 1em 0}p.svelte-1kk9opm{margin:1em auto}@media(min-width: 480px){h1.svelte-1kk9opm{font-size:4em}}", map: "{\"version\":3,\"file\":\"index.svelte\",\"sources\":[\"index.svelte\"],\"sourcesContent\":[\"\\n\\n\\n\\n\\n\\tSapper project template\\n\\n\\n

Great success!

\\n\\n
\\n\\t\\\"Success\\n\\t
Have fun with Sapper!
\\n
\\n\\n

Try editing this file (src/routes/index.svelte) to test live reloading.

\\n\"],\"names\":[],\"mappings\":\"AAKC,iBAAE,CAAE,qBAAM,CAAE,CAAC,eAAC,CAAC,AACd,UAAU,CAAE,MAAM,CAClB,MAAM,CAAE,CAAC,CAAC,IAAI,AACf,CAAC,AAED,EAAE,eAAC,CAAC,AACH,SAAS,CAAE,KAAK,CAChB,cAAc,CAAE,SAAS,CACzB,WAAW,CAAE,GAAG,CAChB,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,AACpB,CAAC,AAED,MAAM,eAAC,CAAC,AACP,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,AAClB,CAAC,AAED,GAAG,eAAC,CAAC,AACJ,KAAK,CAAE,IAAI,CACX,SAAS,CAAE,KAAK,CAChB,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,AAClB,CAAC,AAED,CAAC,eAAC,CAAC,AACF,MAAM,CAAE,GAAG,CAAC,IAAI,AACjB,CAAC,AAED,MAAM,AAAC,YAAY,KAAK,CAAC,AAAC,CAAC,AAC1B,EAAE,eAAC,CAAC,AACH,SAAS,CAAE,GAAG,AACf,CAAC,AACF,CAAC\"}" }; const Routes = create_ssr_component(($$result, $$props, $$bindings, slots) => { $$result.css.add(css$5); return `${($$result.head += `${($$result.title = `Sapper project template`, "")}`, "")}

Great success!

${
Have fun with Sapper!

Try editing this file (src/routes/index.svelte) to test live reloading.

`; }); var component_0 = /*#__PURE__*/Object.freeze({ __proto__: null, 'default': Routes }); /* src/routes/about.svelte generated by Svelte v3.42.1 */ const About = create_ssr_component(($$result, $$props, $$bindings, slots) => { return `${($$result.head += `${($$result.title = `About`, "")}`, "")}

About this site

This is the 'about' page. There's not much here.

`; }); var component_1 = /*#__PURE__*/Object.freeze({ __proto__: null, 'default': About }); /* src/routes/blog/index.svelte generated by Svelte v3.42.1 */ const css$4 = { code: "ul.svelte-1frg2tf{margin:0 0 1em 0;line-height:1.5}", map: "{\"version\":3,\"file\":\"index.svelte\",\"sources\":[\"index.svelte\"],\"sourcesContent\":[\"\\n\\n\\n\\n\\n\\n\\n\\tBlog\\n\\n\\n

Recent posts

\\n\\n\\n\"],\"names\":[],\"mappings\":\"AAaC,EAAE,eAAC,CAAC,AACH,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CACjB,WAAW,CAAE,GAAG,AACjB,CAAC\"}" }; function preload$1() { return this.fetch(`blog.json`).then(r => r.json()).then(posts => { return { posts }; }); } const Blog = create_ssr_component(($$result, $$props, $$bindings, slots) => { let { posts } = $$props; if ($$props.posts === void 0 && $$bindings.posts && posts !== void 0) $$bindings.posts(posts); $$result.css.add(css$4); return `${($$result.head += `${($$result.title = `Blog`, "")}`, "")}

Recent posts

`; }); var component_2 = /*#__PURE__*/Object.freeze({ __proto__: null, 'default': Blog, preload: preload$1 }); /* src/routes/blog/[slug].svelte generated by Svelte v3.42.1 */ const css$3 = { code: ".content.svelte-emm3f3 h2{font-size:1.4em;font-weight:500}.content.svelte-emm3f3 pre{background-color:#f9f9f9;box-shadow:inset 1px 1px 5px rgba(0, 0, 0, 0.05);padding:0.5em;border-radius:2px;overflow-x:auto}.content.svelte-emm3f3 pre code{background-color:transparent;padding:0}.content.svelte-emm3f3 ul{line-height:1.5}.content.svelte-emm3f3 li{margin:0 0 0.5em 0}", map: "{\"version\":3,\"file\":\"[slug].svelte\",\"sources\":[\"[slug].svelte\"],\"sourcesContent\":[\"\\n\\n\\n\\n\\n\\n\\n\\t{post.title}\\n\\n\\n

{post.title}

\\n\\n
\\n\\t{@html post.html}\\n
\\n\"],\"names\":[],\"mappings\":\"AA4BC,sBAAQ,CAAC,AAAQ,EAAE,AAAE,CAAC,AACrB,SAAS,CAAE,KAAK,CAChB,WAAW,CAAE,GAAG,AACjB,CAAC,AAED,sBAAQ,CAAC,AAAQ,GAAG,AAAE,CAAC,AACtB,gBAAgB,CAAE,OAAO,CACzB,UAAU,CAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CACjD,OAAO,CAAE,KAAK,CACd,aAAa,CAAE,GAAG,CAClB,UAAU,CAAE,IAAI,AACjB,CAAC,AAED,sBAAQ,CAAC,AAAQ,GAAG,AAAC,CAAC,AAAQ,IAAI,AAAE,CAAC,AACpC,gBAAgB,CAAE,WAAW,CAC7B,OAAO,CAAE,CAAC,AACX,CAAC,AAED,sBAAQ,CAAC,AAAQ,EAAE,AAAE,CAAC,AACrB,WAAW,CAAE,GAAG,AACjB,CAAC,AAED,sBAAQ,CAAC,AAAQ,EAAE,AAAE,CAAC,AACrB,MAAM,CAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,AACpB,CAAC\"}" }; async function preload({ params }) { // the `slug` parameter is available because // this file is called [slug].svelte const res = await this.fetch(`blog/${params.slug}.json`); const data = await res.json(); if (res.status === 200) { return { post: data }; } else { this.error(res.status, data.message); } } const U5Bslugu5D = create_ssr_component(($$result, $$props, $$bindings, slots) => { let { post } = $$props; if ($$props.post === void 0 && $$bindings.post && post !== void 0) $$bindings.post(post); $$result.css.add(css$3); return `${($$result.head += `${($$result.title = `${escape(post.title)}`, "")}`, "")}

${escape(post.title)}

${post.html}
`; }); var component_3 = /*#__PURE__*/Object.freeze({ __proto__: null, 'default': U5Bslugu5D, preload: preload }); /* src/components/Nav.svelte generated by Svelte v3.42.1 */ const css$2 = { code: "nav.svelte-1dbd5up{border-bottom:1px solid rgba(255,62,0,0.1);font-weight:300;padding:0 1em}ul.svelte-1dbd5up{margin:0;padding:0}ul.svelte-1dbd5up::after{content:'';display:block;clear:both}li.svelte-1dbd5up{display:block;float:left}[aria-current].svelte-1dbd5up{position:relative;display:inline-block}[aria-current].svelte-1dbd5up::after{position:absolute;content:'';width:calc(100% - 1em);height:2px;background-color:rgb(255,62,0);display:block;bottom:-1px}a.svelte-1dbd5up{text-decoration:none;padding:1em 0.5em;display:block}", map: "{\"version\":3,\"file\":\"Nav.svelte\",\"sources\":[\"Nav.svelte\"],\"sourcesContent\":[\"\\n\\n\\n\\n\\n\"],\"names\":[],\"mappings\":\"AAKC,GAAG,eAAC,CAAC,AACJ,aAAa,CAAE,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAC3C,WAAW,CAAE,GAAG,CAChB,OAAO,CAAE,CAAC,CAAC,GAAG,AACf,CAAC,AAED,EAAE,eAAC,CAAC,AACH,MAAM,CAAE,CAAC,CACT,OAAO,CAAE,CAAC,AACX,CAAC,AAGD,iBAAE,OAAO,AAAC,CAAC,AACV,OAAO,CAAE,EAAE,CACX,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,AACZ,CAAC,AAED,EAAE,eAAC,CAAC,AACH,OAAO,CAAE,KAAK,CACd,KAAK,CAAE,IAAI,AACZ,CAAC,AAED,CAAC,YAAY,CAAC,eAAC,CAAC,AACf,QAAQ,CAAE,QAAQ,CAClB,OAAO,CAAE,YAAY,AACtB,CAAC,AAED,CAAC,YAAY,gBAAC,OAAO,AAAC,CAAC,AACtB,QAAQ,CAAE,QAAQ,CAClB,OAAO,CAAE,EAAE,CACX,KAAK,CAAE,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CACvB,MAAM,CAAE,GAAG,CACX,gBAAgB,CAAE,IAAI,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAC/B,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,IAAI,AACb,CAAC,AAED,CAAC,eAAC,CAAC,AACF,eAAe,CAAE,IAAI,CACrB,OAAO,CAAE,GAAG,CAAC,KAAK,CAClB,OAAO,CAAE,KAAK,AACf,CAAC\"}" }; const Nav = create_ssr_component(($$result, $$props, $$bindings, slots) => { let { segment } = $$props; if ($$props.segment === void 0 && $$bindings.segment && segment !== void 0) $$bindings.segment(segment); $$result.css.add(css$2); return ``; }); /* src/routes/_layout.svelte generated by Svelte v3.42.1 */ const css$1 = { code: "main.svelte-1uhnsl8{position:relative;max-width:56em;background-color:white;padding:2em;margin:0 auto;box-sizing:border-box}", map: "{\"version\":3,\"file\":\"_layout.svelte\",\"sources\":[\"_layout.svelte\"],\"sourcesContent\":[\"\\n\\n\\n\\n