From 8f064fe5ac651e51814dc92c0af8e1d99afa9ce9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Wed, 19 Sep 2018 12:02:11 -0400 Subject: [PATCH] update folder structure (#432) --- src/api/build.ts | 8 +- src/api/dev.ts | 12 +- src/api/export.ts | 3 +- src/cli/build.ts | 2 +- src/cli/export.ts | 1 + src/config.ts | 5 +- src/core/create_manifests.ts | 9 +- src/interfaces.ts | 2 +- src/middleware.ts | 2 +- src/rollup.ts | 6 +- src/webpack.ts | 6 +- test/app/{app => src}/client.js | 0 test/app/src/manifest/client.js | 299 ++++++++++++++++++ .../manifest/default-layout.html} | 0 test/app/src/manifest/server.js | 285 +++++++++++++++++ test/app/src/manifest/service-worker.js | 64 ++++ test/app/{ => src}/routes/[x]/[y]/[z].html | 0 .../app/{ => src}/routes/[x]/[y]/_layout.html | 0 test/app/{ => src}/routes/[x]/_counts.js | 0 test/app/{ => src}/routes/_error.html | 0 test/app/{ => src}/routes/_layout.html | 0 test/app/{ => src}/routes/about.html | 2 +- test/app/{ => src}/routes/api/delete/[id].js | 0 test/app/{ => src}/routes/blog/[slug].html | 0 test/app/{ => src}/routes/blog/[slug].json.js | 0 test/app/{ => src}/routes/blog/_posts.js | 0 test/app/{ => src}/routes/blog/index.html | 0 test/app/{ => src}/routes/blog/index.json.js | 0 test/app/{ => src}/routes/const.html | 0 .../{ => src}/routes/credentials/index.html | 0 .../{ => src}/routes/credentials/test.json.js | 0 test/app/{ => src}/routes/delete-test.html | 0 .../{ => src}/routes/echo/page/[slug].html | 0 .../routes/echo/server-route/[slug].js | 0 test/app/{ => src}/routes/fünke.html | 0 test/app/{ => src}/routes/fünke.json.js | 0 test/app/{ => src}/routes/index.html | 0 .../{ => src}/routes/missing-index/ok.html | 0 .../routes/non-sapper-redirect-to.html | 0 .../{ => src}/routes/preload-root/index.html | 0 .../routes/preload-values/custom-class.html | 0 test/app/src/routes/preload-values/index.html | 1 + .../{ => src}/routes/preload-values/set.html | 0 test/app/{ => src}/routes/redirect-from.html | 0 test/app/{ => src}/routes/redirect-root.html | 0 test/app/{ => src}/routes/redirect-to.html | 0 test/app/{ => src}/routes/slow-preload.html | 0 test/app/{ => src}/routes/store.html | 0 test/app/{ => src}/routes/throw-an-error.js | 0 .../{ => src}/routes/unsafe-replacement.html | 0 test/app/{app => src}/server.js | 0 test/app/{app => src}/service-worker.js | 0 test/app/{app => src}/template.html | 0 test/app/{assets => static}/favicon.png | Bin test/app/{assets => static}/global.css | 0 test/app/{assets => static}/great-success.png | Bin test/app/{assets => static}/manifest.json | 0 .../{assets => static}/svelte-logo-192.png | Bin .../{assets => static}/svelte-logo-512.png | Bin 59 files changed, 680 insertions(+), 27 deletions(-) rename test/app/{app => src}/client.js (100%) create mode 100644 test/app/src/manifest/client.js rename test/app/{routes/preload-values/index.html => src/manifest/default-layout.html} (100%) create mode 100644 test/app/src/manifest/server.js create mode 100644 test/app/src/manifest/service-worker.js rename test/app/{ => src}/routes/[x]/[y]/[z].html (100%) rename test/app/{ => src}/routes/[x]/[y]/_layout.html (100%) rename test/app/{ => src}/routes/[x]/_counts.js (100%) rename test/app/{ => src}/routes/_error.html (100%) rename test/app/{ => src}/routes/_layout.html (100%) rename test/app/{ => src}/routes/about.html (86%) rename test/app/{ => src}/routes/api/delete/[id].js (100%) rename test/app/{ => src}/routes/blog/[slug].html (100%) rename test/app/{ => src}/routes/blog/[slug].json.js (100%) rename test/app/{ => src}/routes/blog/_posts.js (100%) rename test/app/{ => src}/routes/blog/index.html (100%) rename test/app/{ => src}/routes/blog/index.json.js (100%) rename test/app/{ => src}/routes/const.html (100%) rename test/app/{ => src}/routes/credentials/index.html (100%) rename test/app/{ => src}/routes/credentials/test.json.js (100%) rename test/app/{ => src}/routes/delete-test.html (100%) rename test/app/{ => src}/routes/echo/page/[slug].html (100%) rename test/app/{ => src}/routes/echo/server-route/[slug].js (100%) rename test/app/{ => src}/routes/fünke.html (100%) rename test/app/{ => src}/routes/fünke.json.js (100%) rename test/app/{ => src}/routes/index.html (100%) rename test/app/{ => src}/routes/missing-index/ok.html (100%) rename test/app/{ => src}/routes/non-sapper-redirect-to.html (100%) rename test/app/{ => src}/routes/preload-root/index.html (100%) rename test/app/{ => src}/routes/preload-values/custom-class.html (100%) create mode 100644 test/app/src/routes/preload-values/index.html rename test/app/{ => src}/routes/preload-values/set.html (100%) rename test/app/{ => src}/routes/redirect-from.html (100%) rename test/app/{ => src}/routes/redirect-root.html (100%) rename test/app/{ => src}/routes/redirect-to.html (100%) rename test/app/{ => src}/routes/slow-preload.html (100%) rename test/app/{ => src}/routes/store.html (100%) rename test/app/{ => src}/routes/throw-an-error.js (100%) rename test/app/{ => src}/routes/unsafe-replacement.html (100%) rename test/app/{app => src}/server.js (100%) rename test/app/{app => src}/service-worker.js (100%) rename test/app/{app => src}/template.html (100%) rename test/app/{assets => static}/favicon.png (100%) rename test/app/{assets => static}/global.css (100%) rename test/app/{assets => static}/great-success.png (100%) rename test/app/{assets => static}/manifest.json (100%) rename test/app/{assets => static}/svelte-logo-192.png (100%) rename test/app/{assets => static}/svelte-logo-512.png (100%) diff --git a/src/api/build.ts b/src/api/build.ts index 4315640..18df442 100644 --- a/src/api/build.ts +++ b/src/api/build.ts @@ -39,9 +39,9 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) { mkdirp.sync(`${dirs.dest}/client`); copy_shimport(dirs.dest); - // minify app/template.html + // minify src/template.html // TODO compile this to a function? could be quicker than str.replace(...).replace(...).replace(...) - const template = fs.readFileSync(`${dirs.app}/template.html`, 'utf-8'); + const template = fs.readFileSync(`${dirs.src}/template.html`, 'utf-8'); // remove this in a future version if (template.indexOf('%sapper.base%') === -1) { @@ -54,7 +54,7 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) { const manifest_data = create_manifest_data(); - // create app/manifest/client.js and app/manifest/server.js + // create src/manifest/client.js and src/manifest/server.js create_main_manifests({ bundler: opts.bundler, manifest_data }); const { client, server, serviceworker } = create_compilers(opts.bundler, dirs); @@ -79,7 +79,7 @@ async function execute(emitter: EventEmitter, opts: Opts, dirs: Dirs) { // TODO duration/warnings result: client_result }); - + client_result.to_json(manifest_data, dirs); build_info.legacy_assets = client_result.assets; delete process.env.SAPPER_LEGACY_BUILD; diff --git a/src/api/dev.ts b/src/api/dev.ts index b3f9e45..ff549dd 100644 --- a/src/api/dev.ts +++ b/src/api/dev.ts @@ -23,7 +23,7 @@ export function dev(opts) { class Watcher extends EventEmitter { bundler: string; dirs: { - app: string; + src: string; dest: string; routes: string; rollup: string; @@ -53,7 +53,7 @@ class Watcher extends EventEmitter { } constructor({ - app = locations.app(), + src = locations.src(), dest = locations.dest(), routes = locations.routes(), 'dev-port': dev_port, @@ -65,7 +65,7 @@ class Watcher extends EventEmitter { rollup = 'rollup', port = +process.env.PORT }: { - app: string, + src: string, dest: string, routes: string, 'dev-port': number, @@ -80,7 +80,7 @@ class Watcher extends EventEmitter { super(); this.bundler = validate_bundler(bundler); - this.dirs = { app, dest, routes, webpack, rollup }; + this.dirs = { src, dest, routes, webpack, rollup }; this.port = port; this.closed = false; @@ -100,7 +100,7 @@ class Watcher extends EventEmitter { }; // remove this in a future version - const template = fs.readFileSync(path.join(app, 'template.html'), 'utf-8'); + const template = fs.readFileSync(path.join(src, 'template.html'), 'utf-8'); if (template.indexOf('%sapper.base%') === -1) { const error = new Error(`As of Sapper v0.10, your template.html file must include %sapper.base% in the `); error.code = `missing-sapper-base`; @@ -175,7 +175,7 @@ class Watcher extends EventEmitter { } ), - fs.watch(`${locations.app()}/template.html`, () => { + fs.watch(`${locations.src()}/template.html`, () => { this.dev_server.send({ action: 'reload' }); diff --git a/src/api/export.ts b/src/api/export.ts index d4deaca..e136398 100644 --- a/src/api/export.ts +++ b/src/api/export.ts @@ -13,6 +13,7 @@ import * as events from './interfaces'; type Opts = { build: string, dest: string, + static: string, basepath?: string, timeout: number | false }; @@ -46,7 +47,7 @@ async function execute(emitter: EventEmitter, opts: Opts) { // Prep output directory sander.rimrafSync(export_dir); - sander.copydirSync('assets').to(export_dir); + sander.copydirSync(opts.static).to(export_dir); sander.copydirSync(opts.build, 'client').to(export_dir, 'client'); if (sander.existsSync(opts.build, 'service-worker.js')) { diff --git a/src/cli/build.ts b/src/cli/build.ts index 362bf99..5f47eb1 100644 --- a/src/cli/build.ts +++ b/src/cli/build.ts @@ -18,7 +18,7 @@ export function build(opts: { bundler?: string, legacy?: boolean }) { bundler }, { dest: locations.dest(), - app: locations.app(), + src: locations.src(), routes: locations.routes(), webpack: 'webpack', rollup: 'rollup' diff --git a/src/cli/export.ts b/src/cli/export.ts index 51a0246..214228e 100644 --- a/src/cli/export.ts +++ b/src/cli/export.ts @@ -15,6 +15,7 @@ export function exporter(export_dir: string, { try { const emitter = _exporter({ build: locations.dest(), + static: locations.static(), dest: export_dir, basepath, timeout diff --git a/src/config.ts b/src/config.ts index 15aef1b..37074a4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -4,7 +4,8 @@ export const dev = () => process.env.NODE_ENV !== 'production'; export const locations = { base: () => path.resolve(process.env.SAPPER_BASE || ''), - app: () => path.resolve(process.env.SAPPER_BASE || '', process.env.SAPPER_APP || 'app'), - routes: () => path.resolve(process.env.SAPPER_BASE || '', process.env.SAPPER_ROUTES || 'routes'), + src: () => path.resolve(process.env.SAPPER_BASE || '', process.env.SAPPER_SRC || 'src'), + static: () => path.resolve(process.env.SAPPER_BASE || '', process.env.SAPPER_STATIC || 'static'), + routes: () => path.resolve(process.env.SAPPER_BASE || '', process.env.SAPPER_ROUTES || 'src/routes'), dest: () => path.resolve(process.env.SAPPER_BASE || '', process.env.SAPPER_DEST || `.sapper/${dev() ? 'dev' : 'prod'}`) }; \ No newline at end of file diff --git a/src/core/create_manifests.ts b/src/core/create_manifests.ts index 3d260e6..212bd9b 100644 --- a/src/core/create_manifests.ts +++ b/src/core/create_manifests.ts @@ -10,7 +10,7 @@ export function create_main_manifests({ bundler, manifest_data, dev_port }: { manifest_data: ManifestData; dev_port?: number; }) { - const manifest_dir = path.join(locations.app(), 'manifest'); + const manifest_dir = path.join(locations.src(), 'manifest'); if (!fs.existsSync(manifest_dir)) fs.mkdirSync(manifest_dir); const path_to_routes = path.relative(manifest_dir, locations.routes()); @@ -30,20 +30,21 @@ export function create_serviceworker_manifest({ manifest_data, client_files }: { manifest_data: ManifestData; client_files: string[]; }) { - const assets = glob('**', { cwd: 'assets', filesOnly: true }); + const files = glob('**', { cwd: locations.static(), filesOnly: true }); let code = ` // This file is generated by Sapper — do not edit it! export const timestamp = ${Date.now()}; - export const assets = [\n\t${assets.map((x: string) => `"${x}"`).join(',\n\t')}\n]; + export const files = [\n\t${files.map((x: string) => `"${x}"`).join(',\n\t')}\n]; + export { files as assets }; // legacy export const shell = [\n\t${client_files.map((x: string) => `"${x}"`).join(',\n\t')}\n]; export const routes = [\n\t${manifest_data.pages.map((r: Page) => `{ pattern: ${r.pattern} }`).join(',\n\t')}\n]; `.replace(/^\t\t/gm, '').trim(); - write_if_changed(`${locations.app()}/manifest/service-worker.js`, code); + write_if_changed(`${locations.src()}/manifest/service-worker.js`, code); } function generate_client( diff --git a/src/interfaces.ts b/src/interfaces.ts index 313da87..a123903 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -43,7 +43,7 @@ export type ServerRoute = { export type Dirs = { dest: string, - app: string, + src: string, routes: string, webpack: string, rollup: string diff --git a/src/middleware.ts b/src/middleware.ts index 705a04d..c8a5ef5 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -288,7 +288,7 @@ function get_page_handler( : (assets => () => assets)(JSON.parse(fs.readFileSync(path.join(output, 'build.json'), 'utf-8'))); const template = dev() - ? () => fs.readFileSync(`${locations.app()}/template.html`, 'utf-8') + ? () => fs.readFileSync(`${locations.src()}/template.html`, 'utf-8') : (str => () => str)(fs.readFileSync(`${locations.dest()}/template.html`, 'utf-8')); const { server_routes, pages } = manifest; diff --git a/src/rollup.ts b/src/rollup.ts index 1240e21..3910f93 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -5,7 +5,7 @@ export default { client: { input: () => { - return `${locations.app()}/client.js` + return `${locations.src()}/client.js` }, output: () => { @@ -24,7 +24,7 @@ export default { server: { input: () => { - return `${locations.app()}/server.js` + return `${locations.src()}/server.js` }, output: () => { @@ -38,7 +38,7 @@ export default { serviceworker: { input: () => { - return `${locations.app()}/service-worker.js`; + return `${locations.src()}/service-worker.js`; }, output: () => { diff --git a/src/webpack.ts b/src/webpack.ts index 28fefec..6fc0ccb 100644 --- a/src/webpack.ts +++ b/src/webpack.ts @@ -6,7 +6,7 @@ export default { client: { entry: () => { return { - main: `${locations.app()}/client` + main: `${locations.src()}/client` }; }, @@ -23,7 +23,7 @@ export default { server: { entry: () => { return { - server: `${locations.app()}/server` + server: `${locations.src()}/server` }; }, @@ -40,7 +40,7 @@ export default { serviceworker: { entry: () => { return { - 'service-worker': `${locations.app()}/service-worker` + 'service-worker': `${locations.src()}/service-worker` }; }, diff --git a/test/app/app/client.js b/test/app/src/client.js similarity index 100% rename from test/app/app/client.js rename to test/app/src/client.js diff --git a/test/app/src/manifest/client.js b/test/app/src/manifest/client.js new file mode 100644 index 0000000..e2db262 --- /dev/null +++ b/test/app/src/manifest/client.js @@ -0,0 +1,299 @@ +// This file is generated by Sapper — do not edit it! +import root from '../routes/_layout.html'; +import error from '../routes/_error.html'; + +const d = decodeURIComponent; + +const index = { + js: () => import(/* webpackChunkName: "index" */ '../routes/index.html'), + css: "__SAPPER_CSS_PLACEHOLDER:index.html__" +}; +const non$45sapper$45redirect$45to = { + js: () => import(/* webpackChunkName: "non$45sapper$45redirect$45to" */ '../routes/non-sapper-redirect-to.html'), + css: "__SAPPER_CSS_PLACEHOLDER:non-sapper-redirect-to.html__" +}; +const unsafe$45replacement = { + js: () => import(/* webpackChunkName: "unsafe$45replacement" */ '../routes/unsafe-replacement.html'), + css: "__SAPPER_CSS_PLACEHOLDER:unsafe-replacement.html__" +}; +const preload$45values = { + js: () => import(/* webpackChunkName: "preload$45values" */ '../routes/preload-values/index.html'), + css: "__SAPPER_CSS_PLACEHOLDER:preload-values/index.html__" +}; +const preload$45values_custom$45class = { + js: () => import(/* webpackChunkName: "preload$45values_custom$45class" */ '../routes/preload-values/custom-class.html'), + css: "__SAPPER_CSS_PLACEHOLDER:preload-values/custom-class.html__" +}; +const preload$45values_set = { + js: () => import(/* webpackChunkName: "preload$45values_set" */ '../routes/preload-values/set.html'), + css: "__SAPPER_CSS_PLACEHOLDER:preload-values/set.html__" +}; +const missing$45index_ok = { + js: () => import(/* webpackChunkName: "missing$45index_ok" */ '../routes/missing-index/ok.html'), + css: "__SAPPER_CSS_PLACEHOLDER:missing-index/ok.html__" +}; +const redirect$45from = { + js: () => import(/* webpackChunkName: "redirect$45from" */ '../routes/redirect-from.html'), + css: "__SAPPER_CSS_PLACEHOLDER:redirect-from.html__" +}; +const redirect$45root = { + js: () => import(/* webpackChunkName: "redirect$45root" */ '../routes/redirect-root.html'), + css: "__SAPPER_CSS_PLACEHOLDER:redirect-root.html__" +}; +const preload$45root = { + js: () => import(/* webpackChunkName: "preload$45root" */ '../routes/preload-root/index.html'), + css: "__SAPPER_CSS_PLACEHOLDER:preload-root/index.html__" +}; +const slow$45preload = { + js: () => import(/* webpackChunkName: "slow$45preload" */ '../routes/slow-preload.html'), + css: "__SAPPER_CSS_PLACEHOLDER:slow-preload.html__" +}; +const credentials = { + js: () => import(/* webpackChunkName: "credentials" */ '../routes/credentials/index.html'), + css: "__SAPPER_CSS_PLACEHOLDER:credentials/index.html__" +}; +const delete$45test = { + js: () => import(/* webpackChunkName: "delete$45test" */ '../routes/delete-test.html'), + css: "__SAPPER_CSS_PLACEHOLDER:delete-test.html__" +}; +const redirect$45to = { + js: () => import(/* webpackChunkName: "redirect$45to" */ '../routes/redirect-to.html'), + css: "__SAPPER_CSS_PLACEHOLDER:redirect-to.html__" +}; +const about = { + js: () => import(/* webpackChunkName: "about" */ '../routes/about.html'), + css: "__SAPPER_CSS_PLACEHOLDER:about.html__" +}; +const const_ = { + js: () => import(/* webpackChunkName: "const_" */ '../routes/const.html'), + css: "__SAPPER_CSS_PLACEHOLDER:const.html__" +}; +const f$252nke = { + js: () => import(/* webpackChunkName: "f$252nke" */ '../routes/fünke.html'), + css: "__SAPPER_CSS_PLACEHOLDER:fünke.html__" +}; +const store = { + js: () => import(/* webpackChunkName: "store" */ '../routes/store.html'), + css: "__SAPPER_CSS_PLACEHOLDER:store.html__" +}; +const blog = { + js: () => import(/* webpackChunkName: "blog" */ '../routes/blog/index.html'), + css: "__SAPPER_CSS_PLACEHOLDER:blog/index.html__" +}; +const blog_$slug = { + js: () => import(/* webpackChunkName: "blog_$slug" */ '../routes/blog/[slug].html'), + css: "__SAPPER_CSS_PLACEHOLDER:blog/[slug].html__" +}; +const echo_page_$slug = { + js: () => import(/* webpackChunkName: "echo_page_$slug" */ '../routes/echo/page/[slug].html'), + css: "__SAPPER_CSS_PLACEHOLDER:echo/page/[slug].html__" +}; +const $x$93_$91y__layout = { + js: () => import(/* webpackChunkName: "$x$93_$91y__layout" */ '../routes/[x]/[y]/_layout.html'), + css: "__SAPPER_CSS_PLACEHOLDER:[x]/[y]/_layout.html__" +}; +const $x$93_$91y$93_$91z = { + js: () => import(/* webpackChunkName: "$x$93_$91y$93_$91z" */ '../routes/[x]/[y]/[z].html'), + css: "__SAPPER_CSS_PLACEHOLDER:[x]/[y]/[z].html__" +}; + +export const manifest = { + ignore: [/^\/throw-an-error$/, /^\/credentials\/test.json$/, /^\/f%C3%BCnke.json$/, /^\/blog.json$/, /^\/blog\/([^\/]+?).json$/, /^\/echo\/server-route\/([^\/]+?)$/, /^\/api\/delete\/([^\/]+?)$/], + + pages: [ + { + // index.html + pattern: /^\/?$/, + parts: [ + { component: index } + ] + }, + + { + // non-sapper-redirect-to.html + pattern: /^\/non-sapper-redirect-to\/?$/, + parts: [ + { component: non$45sapper$45redirect$45to } + ] + }, + + { + // unsafe-replacement.html + pattern: /^\/unsafe-replacement\/?$/, + parts: [ + { component: unsafe$45replacement } + ] + }, + + { + // preload-values/index.html + pattern: /^\/preload-values\/?$/, + parts: [ + null, + { component: preload$45values } + ] + }, + + { + // preload-values/custom-class.html + pattern: /^\/preload-values\/custom-class\/?$/, + parts: [ + null, + { component: preload$45values_custom$45class } + ] + }, + + { + // preload-values/set.html + pattern: /^\/preload-values\/set\/?$/, + parts: [ + null, + { component: preload$45values_set } + ] + }, + + { + // missing-index/ok.html + pattern: /^\/missing-index\/ok\/?$/, + parts: [ + null, + { component: missing$45index_ok } + ] + }, + + { + // redirect-from.html + pattern: /^\/redirect-from\/?$/, + parts: [ + { component: redirect$45from } + ] + }, + + { + // redirect-root.html + pattern: /^\/redirect-root\/?$/, + parts: [ + { component: redirect$45root } + ] + }, + + { + // preload-root/index.html + pattern: /^\/preload-root\/?$/, + parts: [ + null, + { component: preload$45root } + ] + }, + + { + // slow-preload.html + pattern: /^\/slow-preload\/?$/, + parts: [ + { component: slow$45preload } + ] + }, + + { + // credentials/index.html + pattern: /^\/credentials\/?$/, + parts: [ + null, + { component: credentials } + ] + }, + + { + // delete-test.html + pattern: /^\/delete-test\/?$/, + parts: [ + { component: delete$45test } + ] + }, + + { + // redirect-to.html + pattern: /^\/redirect-to\/?$/, + parts: [ + { component: redirect$45to } + ] + }, + + { + // about.html + pattern: /^\/about\/?$/, + parts: [ + { component: about } + ] + }, + + { + // const.html + pattern: /^\/const\/?$/, + parts: [ + { component: const_ } + ] + }, + + { + // fünke.html + pattern: /^\/f%C3%BCnke\/?$/, + parts: [ + { component: f$252nke } + ] + }, + + { + // store.html + pattern: /^\/store\/?$/, + parts: [ + { component: store } + ] + }, + + { + // blog/index.html + pattern: /^\/blog\/?$/, + parts: [ + null, + { component: blog } + ] + }, + + { + // blog/[slug].html + pattern: /^\/blog\/([^\/]+?)\/?$/, + parts: [ + null, + { component: blog_$slug, params: match => ({ slug: d(match[1]) }) } + ] + }, + + { + // echo/page/[slug].html + pattern: /^\/echo\/page\/([^\/]+?)\/?$/, + parts: [ + null, + null, + { component: echo_page_$slug, params: match => ({ slug: d(match[1]) }) } + ] + }, + + { + // [x]/[y]/[z].html + pattern: /^\/([^\/]+?)\/([^\/]+?)\/([^\/]+?)\/?$/, + parts: [ + null, + { component: $x$93_$91y__layout, params: match => ({ x: d(match[1]), y: d(match[2]) }) }, + { component: $x$93_$91y$93_$91z, params: match => ({ x: d(match[1]), y: d(match[2]), z: d(match[3]) }) } + ] + } + ], + + root, + + error +}; + +// this is included for legacy reasons +export const routes = {}; \ No newline at end of file diff --git a/test/app/routes/preload-values/index.html b/test/app/src/manifest/default-layout.html similarity index 100% rename from test/app/routes/preload-values/index.html rename to test/app/src/manifest/default-layout.html diff --git a/test/app/src/manifest/server.js b/test/app/src/manifest/server.js new file mode 100644 index 0000000..8c5e3fa --- /dev/null +++ b/test/app/src/manifest/server.js @@ -0,0 +1,285 @@ +// This file is generated by Sapper — do not edit it! +import * as route_throw$45an$45error from '../routes/throw-an-error.js'; +import * as route_credentials_test_json from '../routes/credentials/test.json.js'; +import * as route_f$252nke_json from '../routes/fünke.json.js'; +import * as route_blog_json from '../routes/blog/index.json.js'; +import * as route_blog_$slug_json from '../routes/blog/[slug].json.js'; +import * as route_echo_server$45route_$slug from '../routes/echo/server-route/[slug].js'; +import * as route_api_delete_$id from '../routes/api/delete/[id].js'; +import index from '../routes/index.html'; +import non$45sapper$45redirect$45to from '../routes/non-sapper-redirect-to.html'; +import unsafe$45replacement from '../routes/unsafe-replacement.html'; +import preload$45values from '../routes/preload-values/index.html'; +import preload$45values_custom$45class from '../routes/preload-values/custom-class.html'; +import preload$45values_set from '../routes/preload-values/set.html'; +import missing$45index_ok from '../routes/missing-index/ok.html'; +import redirect$45from from '../routes/redirect-from.html'; +import redirect$45root from '../routes/redirect-root.html'; +import preload$45root from '../routes/preload-root/index.html'; +import slow$45preload from '../routes/slow-preload.html'; +import credentials from '../routes/credentials/index.html'; +import delete$45test from '../routes/delete-test.html'; +import redirect$45to from '../routes/redirect-to.html'; +import about from '../routes/about.html'; +import const_ from '../routes/const.html'; +import f$252nke from '../routes/fünke.html'; +import store from '../routes/store.html'; +import blog from '../routes/blog/index.html'; +import blog_$slug from '../routes/blog/[slug].html'; +import echo_page_$slug from '../routes/echo/page/[slug].html'; +import $x$93_$91y__layout from '../routes/[x]/[y]/_layout.html'; +import $x$93_$91y$93_$91z from '../routes/[x]/[y]/[z].html'; +import root from '../routes/_layout.html'; +import error from '../routes/_error.html'; + +const d = decodeURIComponent; + +export const manifest = { + server_routes: [ + { + // throw-an-error.js + pattern: /^\/throw-an-error$/, + handlers: route_throw$45an$45error, + params: () => ({}) + }, + + { + // credentials/test.json.js + pattern: /^\/credentials\/test.json$/, + handlers: route_credentials_test_json, + params: () => ({}) + }, + + { + // fünke.json.js + pattern: /^\/f%C3%BCnke.json$/, + handlers: route_f$252nke_json, + params: () => ({}) + }, + + { + // blog/index.json.js + pattern: /^\/blog.json$/, + handlers: route_blog_json, + params: () => ({}) + }, + + { + // blog/[slug].json.js + pattern: /^\/blog\/([^\/]+?).json$/, + handlers: route_blog_$slug_json, + params: match => ({ slug: d(match[1]) }) + }, + + { + // echo/server-route/[slug].js + pattern: /^\/echo\/server-route\/([^\/]+?)$/, + handlers: route_echo_server$45route_$slug, + params: match => ({ slug: d(match[1]) }) + }, + + { + // api/delete/[id].js + pattern: /^\/api\/delete\/([^\/]+?)$/, + handlers: route_api_delete_$id, + params: match => ({ id: d(match[1]) }) + } + ], + + pages: [ + { + // index.html + pattern: /^\/?$/, + parts: [ + { name: "index", file: "index.html", component: index } + ] + }, + + { + // non-sapper-redirect-to.html + pattern: /^\/non-sapper-redirect-to\/?$/, + parts: [ + { name: "non$45sapper$45redirect$45to", file: "non-sapper-redirect-to.html", component: non$45sapper$45redirect$45to } + ] + }, + + { + // unsafe-replacement.html + pattern: /^\/unsafe-replacement\/?$/, + parts: [ + { name: "unsafe$45replacement", file: "unsafe-replacement.html", component: unsafe$45replacement } + ] + }, + + { + // preload-values/index.html + pattern: /^\/preload-values\/?$/, + parts: [ + null, + { name: "preload$45values", file: "preload-values/index.html", component: preload$45values } + ] + }, + + { + // preload-values/custom-class.html + pattern: /^\/preload-values\/custom-class\/?$/, + parts: [ + null, + { name: "preload$45values_custom$45class", file: "preload-values/custom-class.html", component: preload$45values_custom$45class } + ] + }, + + { + // preload-values/set.html + pattern: /^\/preload-values\/set\/?$/, + parts: [ + null, + { name: "preload$45values_set", file: "preload-values/set.html", component: preload$45values_set } + ] + }, + + { + // missing-index/ok.html + pattern: /^\/missing-index\/ok\/?$/, + parts: [ + null, + { name: "missing$45index_ok", file: "missing-index/ok.html", component: missing$45index_ok } + ] + }, + + { + // redirect-from.html + pattern: /^\/redirect-from\/?$/, + parts: [ + { name: "redirect$45from", file: "redirect-from.html", component: redirect$45from } + ] + }, + + { + // redirect-root.html + pattern: /^\/redirect-root\/?$/, + parts: [ + { name: "redirect$45root", file: "redirect-root.html", component: redirect$45root } + ] + }, + + { + // preload-root/index.html + pattern: /^\/preload-root\/?$/, + parts: [ + null, + { name: "preload$45root", file: "preload-root/index.html", component: preload$45root } + ] + }, + + { + // slow-preload.html + pattern: /^\/slow-preload\/?$/, + parts: [ + { name: "slow$45preload", file: "slow-preload.html", component: slow$45preload } + ] + }, + + { + // credentials/index.html + pattern: /^\/credentials\/?$/, + parts: [ + null, + { name: "credentials", file: "credentials/index.html", component: credentials } + ] + }, + + { + // delete-test.html + pattern: /^\/delete-test\/?$/, + parts: [ + { name: "delete$45test", file: "delete-test.html", component: delete$45test } + ] + }, + + { + // redirect-to.html + pattern: /^\/redirect-to\/?$/, + parts: [ + { name: "redirect$45to", file: "redirect-to.html", component: redirect$45to } + ] + }, + + { + // about.html + pattern: /^\/about\/?$/, + parts: [ + { name: "about", file: "about.html", component: about } + ] + }, + + { + // const.html + pattern: /^\/const\/?$/, + parts: [ + { name: "const_", file: "const.html", component: const_ } + ] + }, + + { + // fünke.html + pattern: /^\/f%C3%BCnke\/?$/, + parts: [ + { name: "f$252nke", file: "fünke.html", component: f$252nke } + ] + }, + + { + // store.html + pattern: /^\/store\/?$/, + parts: [ + { name: "store", file: "store.html", component: store } + ] + }, + + { + // blog/index.html + pattern: /^\/blog\/?$/, + parts: [ + null, + { name: "blog", file: "blog/index.html", component: blog } + ] + }, + + { + // blog/[slug].html + pattern: /^\/blog\/([^\/]+?)\/?$/, + parts: [ + null, + { name: "blog_$slug", file: "blog/[slug].html", component: blog_$slug, params: match => ({ slug: d(match[1]) }) } + ] + }, + + { + // echo/page/[slug].html + pattern: /^\/echo\/page\/([^\/]+?)\/?$/, + parts: [ + null, + null, + { name: "echo_page_$slug", file: "echo/page/[slug].html", component: echo_page_$slug, params: match => ({ slug: d(match[1]) }) } + ] + }, + + { + // [x]/[y]/[z].html + pattern: /^\/([^\/]+?)\/([^\/]+?)\/([^\/]+?)\/?$/, + parts: [ + null, + { name: "$x$93_$91y__layout", file: "[x]/[y]/_layout.html", component: $x$93_$91y__layout, params: match => ({ x: d(match[1]), y: d(match[2]) }) }, + { name: "$x$93_$91y$93_$91z", file: "[x]/[y]/[z].html", component: $x$93_$91y$93_$91z, params: match => ({ x: d(match[1]), y: d(match[2]), z: d(match[3]) }) } + ] + } + ], + + root, + + error +}; + +// this is included for legacy reasons +export const routes = {}; \ No newline at end of file diff --git a/test/app/src/manifest/service-worker.js b/test/app/src/manifest/service-worker.js new file mode 100644 index 0000000..01084bf --- /dev/null +++ b/test/app/src/manifest/service-worker.js @@ -0,0 +1,64 @@ +// This file is generated by Sapper — do not edit it! +export const timestamp = 1537372892007; + +export const files = [ + "favicon.png", + "global.css", + "great-success.png", + "manifest.json", + "svelte-logo-192.png", + "svelte-logo-512.png" +]; +export { files as assets }; // legacy + +export const shell = [ + "client/1b495d0233ee9a023603/credentials.12.js", + "client/1b495d0233ee9a023603/main.js", + "client/1b495d0233ee9a023603/non$45sapper$45redirect$45to.2.js", + "client/1b495d0233ee9a023603/unsafe$45replacement.3.js", + "client/1b495d0233ee9a023603/preload$45values.4.js", + "client/1b495d0233ee9a023603/preload$45values_custom$45class.5.js", + "client/1b495d0233ee9a023603/preload$45values_set.6.js", + "client/1b495d0233ee9a023603/missing$45index_ok.7.js", + "client/1b495d0233ee9a023603/redirect$45from.8.js", + "client/1b495d0233ee9a023603/redirect$45root.9.js", + "client/1b495d0233ee9a023603/preload$45root.10.js", + "client/1b495d0233ee9a023603/slow$45preload.11.js", + "client/1b495d0233ee9a023603/index.1.js", + "client/1b495d0233ee9a023603/delete$45test.13.js", + "client/1b495d0233ee9a023603/redirect$45to.14.js", + "client/1b495d0233ee9a023603/about.15.js", + "client/1b495d0233ee9a023603/const_.16.js", + "client/1b495d0233ee9a023603/f$252nke.17.js", + "client/1b495d0233ee9a023603/store.18.js", + "client/1b495d0233ee9a023603/blog.19.js", + "client/1b495d0233ee9a023603/blog_$slug.20.js", + "client/1b495d0233ee9a023603/echo_page_$slug.21.js", + "client/1b495d0233ee9a023603/$x$93_$91y__layout.22.js", + "client/1b495d0233ee9a023603/$x$93_$91y$93_$91z.23.js" +]; + +export const routes = [ + { pattern: /^\/?$/ }, + { pattern: /^\/non-sapper-redirect-to\/?$/ }, + { pattern: /^\/unsafe-replacement\/?$/ }, + { pattern: /^\/preload-values\/?$/ }, + { pattern: /^\/preload-values\/custom-class\/?$/ }, + { pattern: /^\/preload-values\/set\/?$/ }, + { pattern: /^\/missing-index\/ok\/?$/ }, + { pattern: /^\/redirect-from\/?$/ }, + { pattern: /^\/redirect-root\/?$/ }, + { pattern: /^\/preload-root\/?$/ }, + { pattern: /^\/slow-preload\/?$/ }, + { pattern: /^\/credentials\/?$/ }, + { pattern: /^\/delete-test\/?$/ }, + { pattern: /^\/redirect-to\/?$/ }, + { pattern: /^\/about\/?$/ }, + { pattern: /^\/const\/?$/ }, + { pattern: /^\/f%C3%BCnke\/?$/ }, + { pattern: /^\/store\/?$/ }, + { pattern: /^\/blog\/?$/ }, + { pattern: /^\/blog\/([^\/]+?)\/?$/ }, + { pattern: /^\/echo\/page\/([^\/]+?)\/?$/ }, + { pattern: /^\/([^\/]+?)\/([^\/]+?)\/([^\/]+?)\/?$/ } +]; \ No newline at end of file diff --git a/test/app/routes/[x]/[y]/[z].html b/test/app/src/routes/[x]/[y]/[z].html similarity index 100% rename from test/app/routes/[x]/[y]/[z].html rename to test/app/src/routes/[x]/[y]/[z].html diff --git a/test/app/routes/[x]/[y]/_layout.html b/test/app/src/routes/[x]/[y]/_layout.html similarity index 100% rename from test/app/routes/[x]/[y]/_layout.html rename to test/app/src/routes/[x]/[y]/_layout.html diff --git a/test/app/routes/[x]/_counts.js b/test/app/src/routes/[x]/_counts.js similarity index 100% rename from test/app/routes/[x]/_counts.js rename to test/app/src/routes/[x]/_counts.js diff --git a/test/app/routes/_error.html b/test/app/src/routes/_error.html similarity index 100% rename from test/app/routes/_error.html rename to test/app/src/routes/_error.html diff --git a/test/app/routes/_layout.html b/test/app/src/routes/_layout.html similarity index 100% rename from test/app/routes/_layout.html rename to test/app/src/routes/_layout.html diff --git a/test/app/routes/about.html b/test/app/src/routes/about.html similarity index 86% rename from test/app/routes/about.html rename to test/app/src/routes/about.html index 65ebb57..949ad84 100644 --- a/test/app/routes/about.html +++ b/test/app/src/routes/about.html @@ -9,7 +9,7 @@