Spaces:
Running
Running
var __accessCheck = (obj, member, msg) => { | |
if (!member.has(obj)) | |
throw TypeError("Cannot " + msg); | |
}; | |
var __privateGet = (obj, member, getter) => { | |
__accessCheck(obj, member, "read from private field"); | |
return getter ? getter.call(obj) : member.get(obj); | |
}; | |
var __privateAdd = (obj, member, value) => { | |
if (member.has(obj)) | |
throw TypeError("Cannot add the same private member more than once"); | |
member instanceof WeakSet ? member.add(obj) : member.set(obj, value); | |
}; | |
var __privateSet = (obj, member, value, setter) => { | |
__accessCheck(obj, member, "write to private field"); | |
setter ? setter.call(obj, value) : member.set(obj, value); | |
return value; | |
}; | |
var _map; | |
import { c as create_ssr_component, s as setContext, v as validate_component, m as missing_component } from "./chunks/index-c7a03ab5.js"; | |
import cookie from "cookie"; | |
import { v4 } from "@lukeed/uuid"; | |
function get_single_valued_header(headers, key) { | |
const value = headers[key]; | |
if (Array.isArray(value)) { | |
if (value.length === 0) { | |
return void 0; | |
} | |
if (value.length > 1) { | |
throw new Error(`Multiple headers provided for ${key}. Multiple may be provided only for set-cookie`); | |
} | |
return value[0]; | |
} | |
return value; | |
} | |
function lowercase_keys(obj) { | |
const clone = {}; | |
for (const key in obj) { | |
clone[key.toLowerCase()] = obj[key]; | |
} | |
return clone; | |
} | |
function decode_params(params) { | |
for (const key in params) { | |
params[key] = params[key].replace(/%23/g, "#").replace(/%3[Bb]/g, ";").replace(/%2[Cc]/g, ",").replace(/%2[Ff]/g, "/").replace(/%3[Ff]/g, "?").replace(/%3[Aa]/g, ":").replace(/%40/g, "@").replace(/%26/g, "&").replace(/%3[Dd]/g, "=").replace(/%2[Bb]/g, "+").replace(/%24/g, "$"); | |
} | |
return params; | |
} | |
function error(body) { | |
return { | |
status: 500, | |
body, | |
headers: {} | |
}; | |
} | |
function is_string(s2) { | |
return typeof s2 === "string" || s2 instanceof String; | |
} | |
const text_types = new Set([ | |
"application/xml", | |
"application/json", | |
"application/x-www-form-urlencoded", | |
"multipart/form-data" | |
]); | |
function is_text(content_type) { | |
if (!content_type) | |
return true; | |
const type = content_type.split(";")[0].toLowerCase(); | |
return type.startsWith("text/") || type.endsWith("+xml") || text_types.has(type); | |
} | |
async function render_endpoint(request, route, match) { | |
const mod = await route.load(); | |
const handler = mod[request.method.toLowerCase().replace("delete", "del")]; | |
if (!handler) { | |
return; | |
} | |
request.params = route.params ? decode_params(route.params(match)) : {}; | |
const response = await handler(request); | |
const preface = `Invalid response from route ${request.url.pathname}`; | |
if (!response) { | |
return; | |
} | |
if (typeof response !== "object") { | |
return error(`${preface}: expected an object, got ${typeof response}`); | |
} | |
let { status = 200, body, headers = {} } = response; | |
headers = lowercase_keys(headers); | |
const type = get_single_valued_header(headers, "content-type"); | |
if (!is_text(type) && !(body instanceof Uint8Array || is_string(body))) { | |
return error(`${preface}: body must be an instance of string or Uint8Array if content-type is not a supported textual content-type`); | |
} | |
let normalized_body; | |
if ((typeof body === "object" || typeof body === "undefined") && !(body instanceof Uint8Array) && (!type || type.startsWith("application/json"))) { | |
headers = { ...headers, "content-type": "application/json; charset=utf-8" }; | |
normalized_body = JSON.stringify(typeof body === "undefined" ? {} : body); | |
} else { | |
normalized_body = body; | |
} | |
return { status, body: normalized_body, headers }; | |
} | |
var chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$"; | |
var unsafeChars = /[<>\b\f\n\r\t\0\u2028\u2029]/g; | |
var reserved = /^(?:do|if|in|for|int|let|new|try|var|byte|case|char|else|enum|goto|long|this|void|with|await|break|catch|class|const|final|float|short|super|throw|while|yield|delete|double|export|import|native|return|switch|throws|typeof|boolean|default|extends|finally|package|private|abstract|continue|debugger|function|volatile|interface|protected|transient|implements|instanceof|synchronized)$/; | |
var escaped = { | |
"<": "\\u003C", | |
">": "\\u003E", | |
"/": "\\u002F", | |
"\\": "\\\\", | |
"\b": "\\b", | |
"\f": "\\f", | |
"\n": "\\n", | |
"\r": "\\r", | |
" ": "\\t", | |
"\0": "\\0", | |
"\u2028": "\\u2028", | |
"\u2029": "\\u2029" | |
}; | |
var objectProtoOwnPropertyNames = Object.getOwnPropertyNames(Object.prototype).sort().join("\0"); | |
function devalue(value) { | |
var counts = new Map(); | |
function walk(thing) { | |
if (typeof thing === "function") { | |
throw new Error("Cannot stringify a function"); | |
} | |
if (counts.has(thing)) { | |
counts.set(thing, counts.get(thing) + 1); | |
return; | |
} | |
counts.set(thing, 1); | |
if (!isPrimitive(thing)) { | |
var type = getType(thing); | |
switch (type) { | |
case "Number": | |
case "String": | |
case "Boolean": | |
case "Date": | |
case "RegExp": | |
return; | |
case "Array": | |
thing.forEach(walk); | |
break; | |
case "Set": | |
case "Map": | |
Array.from(thing).forEach(walk); | |
break; | |
default: | |
var proto = Object.getPrototypeOf(thing); | |
if (proto !== Object.prototype && proto !== null && Object.getOwnPropertyNames(proto).sort().join("\0") !== objectProtoOwnPropertyNames) { | |
throw new Error("Cannot stringify arbitrary non-POJOs"); | |
} | |
if (Object.getOwnPropertySymbols(thing).length > 0) { | |
throw new Error("Cannot stringify POJOs with symbolic keys"); | |
} | |
Object.keys(thing).forEach(function(key) { | |
return walk(thing[key]); | |
}); | |
} | |
} | |
} | |
walk(value); | |
var names = new Map(); | |
Array.from(counts).filter(function(entry) { | |
return entry[1] > 1; | |
}).sort(function(a, b) { | |
return b[1] - a[1]; | |
}).forEach(function(entry, i) { | |
names.set(entry[0], getName(i)); | |
}); | |
function stringify(thing) { | |
if (names.has(thing)) { | |
return names.get(thing); | |
} | |
if (isPrimitive(thing)) { | |
return stringifyPrimitive(thing); | |
} | |
var type = getType(thing); | |
switch (type) { | |
case "Number": | |
case "String": | |
case "Boolean": | |
return "Object(" + stringify(thing.valueOf()) + ")"; | |
case "RegExp": | |
return "new RegExp(" + stringifyString(thing.source) + ', "' + thing.flags + '")'; | |
case "Date": | |
return "new Date(" + thing.getTime() + ")"; | |
case "Array": | |
var members = thing.map(function(v, i) { | |
return i in thing ? stringify(v) : ""; | |
}); | |
var tail = thing.length === 0 || thing.length - 1 in thing ? "" : ","; | |
return "[" + members.join(",") + tail + "]"; | |
case "Set": | |
case "Map": | |
return "new " + type + "([" + Array.from(thing).map(stringify).join(",") + "])"; | |
default: | |
var obj = "{" + Object.keys(thing).map(function(key) { | |
return safeKey(key) + ":" + stringify(thing[key]); | |
}).join(",") + "}"; | |
var proto = Object.getPrototypeOf(thing); | |
if (proto === null) { | |
return Object.keys(thing).length > 0 ? "Object.assign(Object.create(null)," + obj + ")" : "Object.create(null)"; | |
} | |
return obj; | |
} | |
} | |
var str = stringify(value); | |
if (names.size) { | |
var params_1 = []; | |
var statements_1 = []; | |
var values_1 = []; | |
names.forEach(function(name, thing) { | |
params_1.push(name); | |
if (isPrimitive(thing)) { | |
values_1.push(stringifyPrimitive(thing)); | |
return; | |
} | |
var type = getType(thing); | |
switch (type) { | |
case "Number": | |
case "String": | |
case "Boolean": | |
values_1.push("Object(" + stringify(thing.valueOf()) + ")"); | |
break; | |
case "RegExp": | |
values_1.push(thing.toString()); | |
break; | |
case "Date": | |
values_1.push("new Date(" + thing.getTime() + ")"); | |
break; | |
case "Array": | |
values_1.push("Array(" + thing.length + ")"); | |
thing.forEach(function(v, i) { | |
statements_1.push(name + "[" + i + "]=" + stringify(v)); | |
}); | |
break; | |
case "Set": | |
values_1.push("new Set"); | |
statements_1.push(name + "." + Array.from(thing).map(function(v) { | |
return "add(" + stringify(v) + ")"; | |
}).join(".")); | |
break; | |
case "Map": | |
values_1.push("new Map"); | |
statements_1.push(name + "." + Array.from(thing).map(function(_a) { | |
var k = _a[0], v = _a[1]; | |
return "set(" + stringify(k) + ", " + stringify(v) + ")"; | |
}).join(".")); | |
break; | |
default: | |
values_1.push(Object.getPrototypeOf(thing) === null ? "Object.create(null)" : "{}"); | |
Object.keys(thing).forEach(function(key) { | |
statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key])); | |
}); | |
} | |
}); | |
statements_1.push("return " + str); | |
return "(function(" + params_1.join(",") + "){" + statements_1.join(";") + "}(" + values_1.join(",") + "))"; | |
} else { | |
return str; | |
} | |
} | |
function getName(num) { | |
var name = ""; | |
do { | |
name = chars[num % chars.length] + name; | |
num = ~~(num / chars.length) - 1; | |
} while (num >= 0); | |
return reserved.test(name) ? name + "_" : name; | |
} | |
function isPrimitive(thing) { | |
return Object(thing) !== thing; | |
} | |
function stringifyPrimitive(thing) { | |
if (typeof thing === "string") | |
return stringifyString(thing); | |
if (thing === void 0) | |
return "void 0"; | |
if (thing === 0 && 1 / thing < 0) | |
return "-0"; | |
var str = String(thing); | |
if (typeof thing === "number") | |
return str.replace(/^(-)?0\./, "$1."); | |
return str; | |
} | |
function getType(thing) { | |
return Object.prototype.toString.call(thing).slice(8, -1); | |
} | |
function escapeUnsafeChar(c) { | |
return escaped[c] || c; | |
} | |
function escapeUnsafeChars(str) { | |
return str.replace(unsafeChars, escapeUnsafeChar); | |
} | |
function safeKey(key) { | |
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key)); | |
} | |
function safeProp(key) { | |
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]"; | |
} | |
function stringifyString(str) { | |
var result = '"'; | |
for (var i = 0; i < str.length; i += 1) { | |
var char = str.charAt(i); | |
var code = char.charCodeAt(0); | |
if (char === '"') { | |
result += '\\"'; | |
} else if (char in escaped) { | |
result += escaped[char]; | |
} else if (code >= 55296 && code <= 57343) { | |
var next = str.charCodeAt(i + 1); | |
if (code <= 56319 && (next >= 56320 && next <= 57343)) { | |
result += char + str[++i]; | |
} else { | |
result += "\\u" + code.toString(16).toUpperCase(); | |
} | |
} else { | |
result += char; | |
} | |
} | |
result += '"'; | |
return result; | |
} | |
function noop() { | |
} | |
function safe_not_equal(a, b) { | |
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function"); | |
} | |
Promise.resolve(); | |
const subscriber_queue = []; | |
function writable(value, start = noop) { | |
let stop; | |
const subscribers = new Set(); | |
function set(new_value) { | |
if (safe_not_equal(value, new_value)) { | |
value = new_value; | |
if (stop) { | |
const run_queue = !subscriber_queue.length; | |
for (const subscriber of subscribers) { | |
subscriber[1](); | |
subscriber_queue.push(subscriber, value); | |
} | |
if (run_queue) { | |
for (let i = 0; i < subscriber_queue.length; i += 2) { | |
subscriber_queue[i][0](subscriber_queue[i + 1]); | |
} | |
subscriber_queue.length = 0; | |
} | |
} | |
} | |
} | |
function update(fn) { | |
set(fn(value)); | |
} | |
function subscribe(run, invalidate = noop) { | |
const subscriber = [run, invalidate]; | |
subscribers.add(subscriber); | |
if (subscribers.size === 1) { | |
stop = start(set) || noop; | |
} | |
run(value); | |
return () => { | |
subscribers.delete(subscriber); | |
if (subscribers.size === 0) { | |
stop(); | |
stop = null; | |
} | |
}; | |
} | |
return { set, update, subscribe }; | |
} | |
function coalesce_to_error(err) { | |
return err instanceof Error || err && err.name && err.message ? err : new Error(JSON.stringify(err)); | |
} | |
function hash(value) { | |
let hash2 = 5381; | |
let i = value.length; | |
if (typeof value === "string") { | |
while (i) | |
hash2 = hash2 * 33 ^ value.charCodeAt(--i); | |
} else { | |
while (i) | |
hash2 = hash2 * 33 ^ value[--i]; | |
} | |
return (hash2 >>> 0).toString(36); | |
} | |
const escape_json_string_in_html_dict = { | |
'"': '\\"', | |
"<": "\\u003C", | |
">": "\\u003E", | |
"/": "\\u002F", | |
"\\": "\\\\", | |
"\b": "\\b", | |
"\f": "\\f", | |
"\n": "\\n", | |
"\r": "\\r", | |
" ": "\\t", | |
"\0": "\\0", | |
"\u2028": "\\u2028", | |
"\u2029": "\\u2029" | |
}; | |
function escape_json_string_in_html(str) { | |
return escape(str, escape_json_string_in_html_dict, (code) => `\\u${code.toString(16).toUpperCase()}`); | |
} | |
const escape_html_attr_dict = { | |
"<": "<", | |
">": ">", | |
'"': """ | |
}; | |
function escape_html_attr(str) { | |
return '"' + escape(str, escape_html_attr_dict, (code) => `&#${code};`) + '"'; | |
} | |
function escape(str, dict, unicode_encoder) { | |
let result = ""; | |
for (let i = 0; i < str.length; i += 1) { | |
const char = str.charAt(i); | |
const code = char.charCodeAt(0); | |
if (char in dict) { | |
result += dict[char]; | |
} else if (code >= 55296 && code <= 57343) { | |
const next = str.charCodeAt(i + 1); | |
if (code <= 56319 && next >= 56320 && next <= 57343) { | |
result += char + str[++i]; | |
} else { | |
result += unicode_encoder(code); | |
} | |
} else { | |
result += char; | |
} | |
} | |
return result; | |
} | |
const s = JSON.stringify; | |
async function render_response({ | |
branch, | |
options, | |
$session, | |
page_config, | |
status, | |
error: error2, | |
url, | |
params | |
}) { | |
const css2 = new Set(options.manifest._.entry.css); | |
const js = new Set(options.manifest._.entry.js); | |
const styles = new Set(); | |
const serialized_data = []; | |
let rendered; | |
let is_private = false; | |
let maxage; | |
if (error2) { | |
error2.stack = options.get_stack(error2); | |
} | |
if (page_config.ssr) { | |
branch.forEach(({ node, loaded, fetched, uses_credentials }) => { | |
if (node.css) | |
node.css.forEach((url2) => css2.add(url2)); | |
if (node.js) | |
node.js.forEach((url2) => js.add(url2)); | |
if (node.styles) | |
node.styles.forEach((content) => styles.add(content)); | |
if (fetched && page_config.hydrate) | |
serialized_data.push(...fetched); | |
if (uses_credentials) | |
is_private = true; | |
maxage = loaded.maxage; | |
}); | |
const session = writable($session); | |
const props = { | |
stores: { | |
page: writable(null), | |
navigating: writable(null), | |
session | |
}, | |
page: { url, params, status, error: error2 }, | |
components: branch.map(({ node }) => node.module.default) | |
}; | |
const print_error = (property, replacement) => { | |
Object.defineProperty(props.page, property, { | |
get: () => { | |
throw new Error(`$page.${property} has been replaced by $page.url.${replacement}`); | |
} | |
}); | |
}; | |
print_error("origin", "origin"); | |
print_error("path", "pathname"); | |
print_error("query", "searchParams"); | |
for (let i = 0; i < branch.length; i += 1) { | |
props[`props_${i}`] = await branch[i].loaded.props; | |
} | |
let session_tracking_active = false; | |
const unsubscribe = session.subscribe(() => { | |
if (session_tracking_active) | |
is_private = true; | |
}); | |
session_tracking_active = true; | |
try { | |
rendered = options.root.render(props); | |
} finally { | |
unsubscribe(); | |
} | |
} else { | |
rendered = { head: "", html: "", css: { code: "", map: null } }; | |
} | |
const include_js = page_config.router || page_config.hydrate; | |
if (!include_js) | |
js.clear(); | |
const links = options.amp ? styles.size > 0 || rendered.css.code.length > 0 ? `<style amp-custom>${Array.from(styles).concat(rendered.css.code).join("\n")}</style>` : "" : [ | |
...Array.from(css2).map((dep) => `<link rel="stylesheet" href="${options.prefix}${dep}">`), | |
...Array.from(js).map((dep) => `<link rel="modulepreload" href="${options.prefix}${dep}">`) | |
].join("\n "); | |
let init = ""; | |
if (options.amp) { | |
init = ` | |
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style> | |
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript> | |
<script async src="https://cdn.ampproject.org/v0.js"><\/script>`; | |
init += options.service_worker ? '<script async custom-element="amp-install-serviceworker" src="https://cdn.ampproject.org/v0/amp-install-serviceworker-0.1.js"><\/script>' : ""; | |
} else if (include_js) { | |
init = `<script type="module"> | |
import { start } from ${s(options.prefix + options.manifest._.entry.file)}; | |
start({ | |
target: ${options.target ? `document.querySelector(${s(options.target)})` : "document.body"}, | |
paths: ${s(options.paths)}, | |
session: ${try_serialize($session, (error3) => { | |
throw new Error(`Failed to serialize session data: ${error3.message}`); | |
})}, | |
route: ${!!page_config.router}, | |
spa: ${!page_config.ssr}, | |
trailing_slash: ${s(options.trailing_slash)}, | |
hydrate: ${page_config.ssr && page_config.hydrate ? `{ | |
status: ${status}, | |
error: ${serialize_error(error2)}, | |
nodes: [ | |
${(branch || []).map(({ node }) => `import(${s(options.prefix + node.entry)})`).join(",\n ")} | |
], | |
url: new URL(${s(url.href)}), | |
params: ${devalue(params)} | |
}` : "null"} | |
}); | |
<\/script>`; | |
} | |
if (options.service_worker && !options.amp) { | |
init += `<script> | |
if ('serviceWorker' in navigator) { | |
navigator.serviceWorker.register('${options.service_worker}'); | |
} | |
<\/script>`; | |
} | |
const head = [ | |
rendered.head, | |
styles.size && !options.amp ? `<style data-svelte>${Array.from(styles).join("\n")}</style>` : "", | |
links, | |
init | |
].join("\n\n "); | |
let body = rendered.html; | |
if (options.amp) { | |
if (options.service_worker) { | |
body += `<amp-install-serviceworker src="${options.service_worker}" layout="nodisplay"></amp-install-serviceworker>`; | |
} | |
} else { | |
body += serialized_data.map(({ url: url2, body: body2, json }) => { | |
let attributes = `type="application/json" data-type="svelte-data" data-url=${escape_html_attr(url2)}`; | |
if (body2) | |
attributes += ` data-body="${hash(body2)}"`; | |
return `<script ${attributes}>${json}<\/script>`; | |
}).join("\n\n "); | |
} | |
const headers = { | |
"content-type": "text/html" | |
}; | |
if (maxage) { | |
headers["cache-control"] = `${is_private ? "private" : "public"}, max-age=${maxage}`; | |
} | |
if (!options.floc) { | |
headers["permissions-policy"] = "interest-cohort=()"; | |
} | |
const segments = url.pathname.slice(options.paths.base.length).split("/").slice(2); | |
const assets2 = options.paths.assets || (segments.length > 0 ? segments.map(() => "..").join("/") : "."); | |
return { | |
status, | |
headers, | |
body: options.template({ | |
head, | |
body, | |
assets: assets2 | |
}) | |
}; | |
} | |
function try_serialize(data, fail) { | |
try { | |
return devalue(data); | |
} catch (err) { | |
if (fail) | |
fail(coalesce_to_error(err)); | |
return null; | |
} | |
} | |
function serialize_error(error2) { | |
if (!error2) | |
return null; | |
let serialized = try_serialize(error2); | |
if (!serialized) { | |
const { name, message, stack } = error2; | |
serialized = try_serialize({ ...error2, name, message, stack }); | |
} | |
if (!serialized) { | |
serialized = "{}"; | |
} | |
return serialized; | |
} | |
function normalize(loaded) { | |
const has_error_status = loaded.status && loaded.status >= 400 && loaded.status <= 599 && !loaded.redirect; | |
if (loaded.error || has_error_status) { | |
const status = loaded.status; | |
if (!loaded.error && has_error_status) { | |
return { | |
status: status || 500, | |
error: new Error() | |
}; | |
} | |
const error2 = typeof loaded.error === "string" ? new Error(loaded.error) : loaded.error; | |
if (!(error2 instanceof Error)) { | |
return { | |
status: 500, | |
error: new Error(`"error" property returned from load() must be a string or instance of Error, received type "${typeof error2}"`) | |
}; | |
} | |
if (!status || status < 400 || status > 599) { | |
console.warn('"error" returned from load() without a valid status code \u2014 defaulting to 500'); | |
return { status: 500, error: error2 }; | |
} | |
return { status, error: error2 }; | |
} | |
if (loaded.redirect) { | |
if (!loaded.status || Math.floor(loaded.status / 100) !== 3) { | |
return { | |
status: 500, | |
error: new Error('"redirect" property returned from load() must be accompanied by a 3xx status code') | |
}; | |
} | |
if (typeof loaded.redirect !== "string") { | |
return { | |
status: 500, | |
error: new Error('"redirect" property returned from load() must be a string') | |
}; | |
} | |
} | |
if (loaded.context) { | |
throw new Error('You are returning "context" from a load function. "context" was renamed to "stuff", please adjust your code accordingly.'); | |
} | |
return loaded; | |
} | |
const absolute = /^([a-z]+:)?\/?\//; | |
const scheme = /^[a-z]+:/; | |
function resolve(base2, path) { | |
if (scheme.test(path)) | |
return path; | |
const base_match = absolute.exec(base2); | |
const path_match = absolute.exec(path); | |
if (!base_match) { | |
throw new Error(`bad base path: "${base2}"`); | |
} | |
const baseparts = path_match ? [] : base2.slice(base_match[0].length).split("/"); | |
const pathparts = path_match ? path.slice(path_match[0].length).split("/") : path.split("/"); | |
baseparts.pop(); | |
for (let i = 0; i < pathparts.length; i += 1) { | |
const part = pathparts[i]; | |
if (part === ".") | |
continue; | |
else if (part === "..") | |
baseparts.pop(); | |
else | |
baseparts.push(part); | |
} | |
const prefix = path_match && path_match[0] || base_match && base_match[0] || ""; | |
return `${prefix}${baseparts.join("/")}`; | |
} | |
function is_root_relative(path) { | |
return path[0] === "/" && path[1] !== "/"; | |
} | |
async function load_node({ | |
request, | |
options, | |
state, | |
route, | |
url, | |
params, | |
node, | |
$session, | |
stuff, | |
prerender_enabled, | |
is_leaf, | |
is_error, | |
status, | |
error: error2 | |
}) { | |
const { module } = node; | |
let uses_credentials = false; | |
const fetched = []; | |
let set_cookie_headers = []; | |
let loaded; | |
const url_proxy = new Proxy(url, { | |
get: (target, prop, receiver) => { | |
if (prerender_enabled && (prop === "search" || prop === "searchParams")) { | |
throw new Error("Cannot access query on a page with prerendering enabled"); | |
} | |
return Reflect.get(target, prop, receiver); | |
} | |
}); | |
if (module.load) { | |
const load_input = { | |
url: url_proxy, | |
params, | |
get session() { | |
uses_credentials = true; | |
return $session; | |
}, | |
fetch: async (resource, opts = {}) => { | |
let requested; | |
if (typeof resource === "string") { | |
requested = resource; | |
} else { | |
requested = resource.url; | |
opts = { | |
method: resource.method, | |
headers: resource.headers, | |
body: resource.body, | |
mode: resource.mode, | |
credentials: resource.credentials, | |
cache: resource.cache, | |
redirect: resource.redirect, | |
referrer: resource.referrer, | |
integrity: resource.integrity, | |
...opts | |
}; | |
} | |
opts.headers = new Headers(opts.headers); | |
const resolved = resolve(request.url.pathname, requested.split("?")[0]); | |
let response; | |
const prefix = options.paths.assets || options.paths.base; | |
const filename = (resolved.startsWith(prefix) ? resolved.slice(prefix.length) : resolved).slice(1); | |
const filename_html = `${filename}/index.html`; | |
const is_asset = options.manifest.assets.has(filename); | |
const is_asset_html = options.manifest.assets.has(filename_html); | |
if (is_asset || is_asset_html) { | |
const file = is_asset ? filename : filename_html; | |
if (options.read) { | |
const type = is_asset ? options.manifest._.mime[filename.slice(filename.lastIndexOf("."))] : "text/html"; | |
response = new Response(options.read(file), { | |
headers: type ? { "content-type": type } : {} | |
}); | |
} else { | |
response = await fetch(`${url.origin}/${file}`, opts); | |
} | |
} else if (is_root_relative(resolved)) { | |
const relative = resolved; | |
if (opts.credentials !== "omit") { | |
uses_credentials = true; | |
if (request.headers.cookie) { | |
opts.headers.set("cookie", request.headers.cookie); | |
} | |
if (request.headers.authorization && !opts.headers.has("authorization")) { | |
opts.headers.set("authorization", request.headers.authorization); | |
} | |
} | |
if (opts.body && typeof opts.body !== "string") { | |
throw new Error("Request body must be a string"); | |
} | |
const rendered = await respond({ | |
url: new URL(requested, request.url), | |
method: opts.method || "GET", | |
headers: Object.fromEntries(opts.headers), | |
rawBody: opts.body == null ? null : new TextEncoder().encode(opts.body) | |
}, options, { | |
fetched: requested, | |
initiator: route | |
}); | |
if (rendered) { | |
if (state.prerender) { | |
state.prerender.dependencies.set(relative, rendered); | |
} | |
response = new Response(rendered.body, { | |
status: rendered.status, | |
headers: rendered.headers | |
}); | |
} else { | |
return fetch(new URL(requested, request.url).href, { | |
method: opts.method || "GET", | |
headers: opts.headers | |
}); | |
} | |
} else { | |
if (resolved.startsWith("//")) { | |
throw new Error(`Cannot request protocol-relative URL (${requested}) in server-side fetch`); | |
} | |
if (`.${new URL(requested).hostname}`.endsWith(`.${request.url.hostname}`) && opts.credentials !== "omit") { | |
uses_credentials = true; | |
opts.headers.set("cookie", request.headers.cookie); | |
} | |
const external_request = new Request(requested, opts); | |
response = await options.hooks.externalFetch.call(null, external_request); | |
} | |
if (response) { | |
const proxy = new Proxy(response, { | |
get(response2, key, _receiver) { | |
async function text() { | |
const body = await response2.text(); | |
const headers = {}; | |
for (const [key2, value] of response2.headers) { | |
if (key2 === "set-cookie") { | |
set_cookie_headers = set_cookie_headers.concat(value); | |
} else if (key2 !== "etag") { | |
headers[key2] = value; | |
} | |
} | |
if (!opts.body || typeof opts.body === "string") { | |
fetched.push({ | |
url: requested, | |
body: opts.body, | |
json: `{"status":${response2.status},"statusText":${s(response2.statusText)},"headers":${s(headers)},"body":"${escape_json_string_in_html(body)}"}` | |
}); | |
} | |
return body; | |
} | |
if (key === "text") { | |
return text; | |
} | |
if (key === "json") { | |
return async () => { | |
return JSON.parse(await text()); | |
}; | |
} | |
return Reflect.get(response2, key, response2); | |
} | |
}); | |
return proxy; | |
} | |
return response || new Response("Not found", { | |
status: 404 | |
}); | |
}, | |
stuff: { ...stuff } | |
}; | |
if (options.dev) { | |
Object.defineProperty(load_input, "page", { | |
get: () => { | |
throw new Error("`page` in `load` functions has been replaced by `url` and `params`"); | |
} | |
}); | |
} | |
if (is_error) { | |
load_input.status = status; | |
load_input.error = error2; | |
} | |
loaded = await module.load.call(null, load_input); | |
} else { | |
loaded = {}; | |
} | |
if (!loaded && is_leaf && !is_error) | |
return; | |
if (!loaded) { | |
throw new Error(`${node.entry} - load must return a value except for page fall through`); | |
} | |
return { | |
node, | |
loaded: normalize(loaded), | |
stuff: loaded.stuff || stuff, | |
fetched, | |
set_cookie_headers, | |
uses_credentials | |
}; | |
} | |
async function respond_with_error({ request, options, state, $session, status, error: error2 }) { | |
const default_layout = await options.manifest._.nodes[0](); | |
const default_error = await options.manifest._.nodes[1](); | |
const params = {}; | |
const loaded = await load_node({ | |
request, | |
options, | |
state, | |
route: null, | |
url: request.url, | |
params, | |
node: default_layout, | |
$session, | |
stuff: {}, | |
prerender_enabled: is_prerender_enabled(options, default_error, state), | |
is_leaf: false, | |
is_error: false | |
}); | |
const branch = [ | |
loaded, | |
await load_node({ | |
request, | |
options, | |
state, | |
route: null, | |
url: request.url, | |
params, | |
node: default_error, | |
$session, | |
stuff: loaded ? loaded.stuff : {}, | |
prerender_enabled: is_prerender_enabled(options, default_error, state), | |
is_leaf: false, | |
is_error: true, | |
status, | |
error: error2 | |
}) | |
]; | |
try { | |
return await render_response({ | |
options, | |
$session, | |
page_config: { | |
hydrate: options.hydrate, | |
router: options.router, | |
ssr: options.ssr | |
}, | |
status, | |
error: error2, | |
branch, | |
url: request.url, | |
params | |
}); | |
} catch (err) { | |
const error3 = coalesce_to_error(err); | |
options.handle_error(error3, request); | |
return { | |
status: 500, | |
headers: {}, | |
body: error3.stack | |
}; | |
} | |
} | |
function is_prerender_enabled(options, node, state) { | |
return options.prerender && (!!node.module.prerender || !!state.prerender && state.prerender.all); | |
} | |
async function respond$1(opts) { | |
const { request, options, state, $session, route } = opts; | |
let nodes; | |
try { | |
nodes = await Promise.all(route.a.map((n) => options.manifest._.nodes[n] && options.manifest._.nodes[n]())); | |
} catch (err) { | |
const error3 = coalesce_to_error(err); | |
options.handle_error(error3, request); | |
return await respond_with_error({ | |
request, | |
options, | |
state, | |
$session, | |
status: 500, | |
error: error3 | |
}); | |
} | |
const leaf = nodes[nodes.length - 1].module; | |
let page_config = get_page_config(leaf, options); | |
if (!leaf.prerender && state.prerender && !state.prerender.all) { | |
return { | |
status: 204, | |
headers: {} | |
}; | |
} | |
let branch = []; | |
let status = 200; | |
let error2; | |
let set_cookie_headers = []; | |
ssr: | |
if (page_config.ssr) { | |
let stuff = {}; | |
for (let i = 0; i < nodes.length; i += 1) { | |
const node = nodes[i]; | |
let loaded; | |
if (node) { | |
try { | |
loaded = await load_node({ | |
...opts, | |
url: request.url, | |
node, | |
stuff, | |
prerender_enabled: is_prerender_enabled(options, node, state), | |
is_leaf: i === nodes.length - 1, | |
is_error: false | |
}); | |
if (!loaded) | |
return; | |
set_cookie_headers = set_cookie_headers.concat(loaded.set_cookie_headers); | |
if (loaded.loaded.redirect) { | |
return with_cookies({ | |
status: loaded.loaded.status, | |
headers: { | |
location: encodeURI(loaded.loaded.redirect) | |
} | |
}, set_cookie_headers); | |
} | |
if (loaded.loaded.error) { | |
({ status, error: error2 } = loaded.loaded); | |
} | |
} catch (err) { | |
const e = coalesce_to_error(err); | |
options.handle_error(e, request); | |
status = 500; | |
error2 = e; | |
} | |
if (loaded && !error2) { | |
branch.push(loaded); | |
} | |
if (error2) { | |
while (i--) { | |
if (route.b[i]) { | |
const error_node = await options.manifest._.nodes[route.b[i]](); | |
let node_loaded; | |
let j = i; | |
while (!(node_loaded = branch[j])) { | |
j -= 1; | |
} | |
try { | |
const error_loaded = await load_node({ | |
...opts, | |
url: request.url, | |
node: error_node, | |
stuff: node_loaded.stuff, | |
prerender_enabled: is_prerender_enabled(options, error_node, state), | |
is_leaf: false, | |
is_error: true, | |
status, | |
error: error2 | |
}); | |
if (error_loaded.loaded.error) { | |
continue; | |
} | |
page_config = get_page_config(error_node.module, options); | |
branch = branch.slice(0, j + 1).concat(error_loaded); | |
break ssr; | |
} catch (err) { | |
const e = coalesce_to_error(err); | |
options.handle_error(e, request); | |
continue; | |
} | |
} | |
} | |
return with_cookies(await respond_with_error({ | |
request, | |
options, | |
state, | |
$session, | |
status, | |
error: error2 | |
}), set_cookie_headers); | |
} | |
} | |
if (loaded && loaded.loaded.stuff) { | |
stuff = { | |
...stuff, | |
...loaded.loaded.stuff | |
}; | |
} | |
} | |
} | |
try { | |
return with_cookies(await render_response({ | |
...opts, | |
url: request.url, | |
page_config, | |
status, | |
error: error2, | |
branch: branch.filter(Boolean) | |
}), set_cookie_headers); | |
} catch (err) { | |
const error3 = coalesce_to_error(err); | |
options.handle_error(error3, request); | |
return with_cookies(await respond_with_error({ | |
...opts, | |
status: 500, | |
error: error3 | |
}), set_cookie_headers); | |
} | |
} | |
function get_page_config(leaf, options) { | |
return { | |
ssr: "ssr" in leaf ? !!leaf.ssr : options.ssr, | |
router: "router" in leaf ? !!leaf.router : options.router, | |
hydrate: "hydrate" in leaf ? !!leaf.hydrate : options.hydrate | |
}; | |
} | |
function with_cookies(response, set_cookie_headers) { | |
if (set_cookie_headers.length) { | |
response.headers["set-cookie"] = set_cookie_headers; | |
} | |
return response; | |
} | |
async function render_page(request, route, match, options, state) { | |
if (state.initiator === route) { | |
return { | |
status: 404, | |
headers: {}, | |
body: `Not found: ${request.url.pathname}` | |
}; | |
} | |
const params = route.params ? decode_params(route.params(match)) : {}; | |
const $session = await options.hooks.getSession(request); | |
const response = await respond$1({ | |
request, | |
options, | |
state, | |
$session, | |
route, | |
params | |
}); | |
if (response) { | |
return response; | |
} | |
if (state.fetched) { | |
return { | |
status: 500, | |
headers: {}, | |
body: `Bad request in load function: failed to fetch ${state.fetched}` | |
}; | |
} | |
} | |
function read_only_form_data() { | |
const map = new Map(); | |
return { | |
append(key, value) { | |
if (map.has(key)) { | |
(map.get(key) || []).push(value); | |
} else { | |
map.set(key, [value]); | |
} | |
}, | |
data: new ReadOnlyFormData(map) | |
}; | |
} | |
class ReadOnlyFormData { | |
constructor(map) { | |
__privateAdd(this, _map, void 0); | |
__privateSet(this, _map, map); | |
} | |
get(key) { | |
const value = __privateGet(this, _map).get(key); | |
return value && value[0]; | |
} | |
getAll(key) { | |
return __privateGet(this, _map).get(key); | |
} | |
has(key) { | |
return __privateGet(this, _map).has(key); | |
} | |
*[Symbol.iterator]() { | |
for (const [key, value] of __privateGet(this, _map)) { | |
for (let i = 0; i < value.length; i += 1) { | |
yield [key, value[i]]; | |
} | |
} | |
} | |
*entries() { | |
for (const [key, value] of __privateGet(this, _map)) { | |
for (let i = 0; i < value.length; i += 1) { | |
yield [key, value[i]]; | |
} | |
} | |
} | |
*keys() { | |
for (const [key] of __privateGet(this, _map)) | |
yield key; | |
} | |
*values() { | |
for (const [, value] of __privateGet(this, _map)) { | |
for (let i = 0; i < value.length; i += 1) { | |
yield value[i]; | |
} | |
} | |
} | |
} | |
_map = new WeakMap(); | |
function parse_body(raw, headers) { | |
if (!raw) | |
return raw; | |
const content_type = headers["content-type"]; | |
const [type, ...directives] = content_type ? content_type.split(/;\s*/) : []; | |
const text = () => new TextDecoder(headers["content-encoding"] || "utf-8").decode(raw); | |
switch (type) { | |
case "text/plain": | |
return text(); | |
case "application/json": | |
return JSON.parse(text()); | |
case "application/x-www-form-urlencoded": | |
return get_urlencoded(text()); | |
case "multipart/form-data": { | |
const boundary = directives.find((directive) => directive.startsWith("boundary=")); | |
if (!boundary) | |
throw new Error("Missing boundary"); | |
return get_multipart(text(), boundary.slice("boundary=".length)); | |
} | |
default: | |
return raw; | |
} | |
} | |
function get_urlencoded(text) { | |
const { data, append } = read_only_form_data(); | |
text.replace(/\+/g, " ").split("&").forEach((str) => { | |
const [key, value] = str.split("="); | |
append(decodeURIComponent(key), decodeURIComponent(value)); | |
}); | |
return data; | |
} | |
function get_multipart(text, boundary) { | |
const parts = text.split(`--${boundary}`); | |
if (parts[0] !== "" || parts[parts.length - 1].trim() !== "--") { | |
throw new Error("Malformed form data"); | |
} | |
const { data, append } = read_only_form_data(); | |
parts.slice(1, -1).forEach((part) => { | |
const match = /\s*([\s\S]+?)\r\n\r\n([\s\S]*)\s*/.exec(part); | |
if (!match) { | |
throw new Error("Malformed form data"); | |
} | |
const raw_headers = match[1]; | |
const body = match[2].trim(); | |
let key; | |
const headers = {}; | |
raw_headers.split("\r\n").forEach((str) => { | |
const [raw_header, ...raw_directives] = str.split("; "); | |
let [name, value] = raw_header.split(": "); | |
name = name.toLowerCase(); | |
headers[name] = value; | |
const directives = {}; | |
raw_directives.forEach((raw_directive) => { | |
const [name2, value2] = raw_directive.split("="); | |
directives[name2] = JSON.parse(value2); | |
}); | |
if (name === "content-disposition") { | |
if (value !== "form-data") | |
throw new Error("Malformed form data"); | |
if (directives.filename) { | |
throw new Error("File upload is not yet implemented"); | |
} | |
if (directives.name) { | |
key = directives.name; | |
} | |
} | |
}); | |
if (!key) | |
throw new Error("Malformed form data"); | |
append(key, body); | |
}); | |
return data; | |
} | |
async function respond(incoming, options, state = {}) { | |
if (incoming.url.pathname !== "/" && options.trailing_slash !== "ignore") { | |
const has_trailing_slash = incoming.url.pathname.endsWith("/"); | |
if (has_trailing_slash && options.trailing_slash === "never" || !has_trailing_slash && options.trailing_slash === "always" && !(incoming.url.pathname.split("/").pop() || "").includes(".")) { | |
incoming.url.pathname = has_trailing_slash ? incoming.url.pathname.slice(0, -1) : incoming.url.pathname + "/"; | |
if (incoming.url.search === "?") | |
incoming.url.search = ""; | |
return { | |
status: 301, | |
headers: { | |
location: incoming.url.pathname + incoming.url.search | |
} | |
}; | |
} | |
} | |
const headers = lowercase_keys(incoming.headers); | |
const request = { | |
...incoming, | |
headers, | |
body: parse_body(incoming.rawBody, headers), | |
params: {}, | |
locals: {} | |
}; | |
const print_error = (property, replacement) => { | |
Object.defineProperty(request, property, { | |
get: () => { | |
throw new Error(`request.${property} has been replaced by request.url.${replacement}`); | |
} | |
}); | |
}; | |
print_error("origin", "origin"); | |
print_error("path", "pathname"); | |
print_error("query", "searchParams"); | |
try { | |
return await options.hooks.handle({ | |
request, | |
resolve: async (request2) => { | |
if (state.prerender && state.prerender.fallback) { | |
return await render_response({ | |
url: request2.url, | |
params: request2.params, | |
options, | |
$session: await options.hooks.getSession(request2), | |
page_config: { ssr: false, router: true, hydrate: true }, | |
status: 200, | |
branch: [] | |
}); | |
} | |
const decoded = decodeURI(request2.url.pathname).replace(options.paths.base, ""); | |
for (const route of options.manifest._.routes) { | |
const match = route.pattern.exec(decoded); | |
if (!match) | |
continue; | |
const response = route.type === "endpoint" ? await render_endpoint(request2, route, match) : await render_page(request2, route, match, options, state); | |
if (response) { | |
if (response.status === 200) { | |
const cache_control = get_single_valued_header(response.headers, "cache-control"); | |
if (!cache_control || !/(no-store|immutable)/.test(cache_control)) { | |
let if_none_match_value = request2.headers["if-none-match"]; | |
if (if_none_match_value?.startsWith('W/"')) { | |
if_none_match_value = if_none_match_value.substring(2); | |
} | |
const etag = `"${hash(response.body || "")}"`; | |
if (if_none_match_value === etag) { | |
return { | |
status: 304, | |
headers: {} | |
}; | |
} | |
response.headers["etag"] = etag; | |
} | |
} | |
return response; | |
} | |
} | |
if (!state.initiator) { | |
const $session = await options.hooks.getSession(request2); | |
return await respond_with_error({ | |
request: request2, | |
options, | |
state, | |
$session, | |
status: 404, | |
error: new Error(`Not found: ${request2.url.pathname}`) | |
}); | |
} | |
} | |
}); | |
} catch (err) { | |
const e = coalesce_to_error(err); | |
options.handle_error(e, request); | |
return { | |
status: 500, | |
headers: {}, | |
body: options.dev ? e.stack : e.message | |
}; | |
} | |
} | |
function afterUpdate() { | |
} | |
var root_svelte_svelte_type_style_lang = ""; | |
const css = { | |
code: "#svelte-announcer.svelte-1j55zn5{position:absolute;left:0;top:0;clip:rect(0 0 0 0);clip-path:inset(50%);overflow:hidden;white-space:nowrap;width:1px;height:1px}", | |
map: null | |
}; | |
const Root = create_ssr_component(($$result, $$props, $$bindings, slots) => { | |
let { stores } = $$props; | |
let { page } = $$props; | |
let { components } = $$props; | |
let { props_0 = null } = $$props; | |
let { props_1 = null } = $$props; | |
let { props_2 = null } = $$props; | |
setContext("__svelte__", stores); | |
afterUpdate(stores.page.notify); | |
if ($$props.stores === void 0 && $$bindings.stores && stores !== void 0) | |
$$bindings.stores(stores); | |
if ($$props.page === void 0 && $$bindings.page && page !== void 0) | |
$$bindings.page(page); | |
if ($$props.components === void 0 && $$bindings.components && components !== void 0) | |
$$bindings.components(components); | |
if ($$props.props_0 === void 0 && $$bindings.props_0 && props_0 !== void 0) | |
$$bindings.props_0(props_0); | |
if ($$props.props_1 === void 0 && $$bindings.props_1 && props_1 !== void 0) | |
$$bindings.props_1(props_1); | |
if ($$props.props_2 === void 0 && $$bindings.props_2 && props_2 !== void 0) | |
$$bindings.props_2(props_2); | |
$$result.css.add(css); | |
{ | |
stores.page.set(page); | |
} | |
return ` | |
${components[1] ? `${validate_component(components[0] || missing_component, "svelte:component").$$render($$result, Object.assign(props_0 || {}), {}, { | |
default: () => `${components[2] ? `${validate_component(components[1] || missing_component, "svelte:component").$$render($$result, Object.assign(props_1 || {}), {}, { | |
default: () => `${validate_component(components[2] || missing_component, "svelte:component").$$render($$result, Object.assign(props_2 || {}), {}, {})}` | |
})}` : `${validate_component(components[1] || missing_component, "svelte:component").$$render($$result, Object.assign(props_1 || {}), {}, {})}`}` | |
})}` : `${validate_component(components[0] || missing_component, "svelte:component").$$render($$result, Object.assign(props_0 || {}), {}, {})}`} | |
${``}`; | |
}); | |
let base = ""; | |
let assets = ""; | |
function set_paths(paths) { | |
base = paths.base; | |
assets = paths.assets || base; | |
} | |
function set_prerendering(value) { | |
} | |
const handle = async ({ request, resolve: resolve2 }) => { | |
const cookies = cookie.parse(request.headers.cookie || ""); | |
request.locals.userid = cookies.userid || v4(); | |
const method = request.url.searchParams.get("_method"); | |
if (method) { | |
request.method = method.toUpperCase(); | |
} | |
const response = await resolve2(request); | |
if (!cookies.userid) { | |
response.headers["set-cookie"] = cookie.serialize("userid", request.locals.userid, { | |
path: "/", | |
httpOnly: true | |
}); | |
} | |
return response; | |
}; | |
var user_hooks = /* @__PURE__ */ Object.freeze({ | |
__proto__: null, | |
[Symbol.toStringTag]: "Module", | |
handle | |
}); | |
const template = ({ head, body, assets: assets2 }) => '<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="description" content="Svelte demo app" />\n <link rel="icon" href="' + assets2 + '/favicon.png" />\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n ' + head + '\n </head>\n <body>\n <div id="svelte">' + body + "</div>\n </body>\n</html>\n"; | |
let read = null; | |
set_paths({ "base": "/staticspaceiframe/pngwn/static-test/build", "assets": "" }); | |
const get_hooks = (hooks) => ({ | |
getSession: hooks.getSession || (() => ({})), | |
handle: hooks.handle || (({ request, resolve: resolve2 }) => resolve2(request)), | |
handleError: hooks.handleError || (({ error: error2 }) => console.error(error2.stack)), | |
externalFetch: hooks.externalFetch || fetch | |
}); | |
let default_protocol = "https"; | |
function override(settings) { | |
default_protocol = settings.protocol || default_protocol; | |
set_paths(settings.paths); | |
set_prerendering(settings.prerendering); | |
read = settings.read; | |
} | |
class App { | |
constructor(manifest) { | |
const hooks = get_hooks(user_hooks); | |
this.options = { | |
amp: false, | |
dev: false, | |
floc: false, | |
get_stack: (error2) => String(error2), | |
handle_error: (error2, request) => { | |
hooks.handleError({ error: error2, request }); | |
error2.stack = this.options.get_stack(error2); | |
}, | |
hooks, | |
hydrate: true, | |
manifest, | |
paths: { base, assets }, | |
prefix: assets + "/_app/", | |
prerender: true, | |
read, | |
root: Root, | |
service_worker: null, | |
router: true, | |
ssr: true, | |
target: "#svelte", | |
template, | |
trailing_slash: "never" | |
}; | |
} | |
render(request, { | |
prerender | |
} = {}) { | |
if (Object.keys(request).sort().join() !== "headers,method,rawBody,url") { | |
throw new Error("Adapters should call app.render({ url, method, headers, rawBody })"); | |
} | |
const host = request.headers["host"]; | |
const protocol = default_protocol; | |
return respond({ ...request, url: new URL(request.url, protocol + "://" + host) }, this.options, { prerender }); | |
} | |
} | |
export { App, override }; | |