{"version":3,"sources":["rendering.ts"],"sourcesContent":["import { Path } from \"datex-core-legacy/utils/path.ts\";\nimport { Datex } from \"datex-core-legacy\";\nimport {evaluateFilter, filter} from \"./route-filter.ts\";\nimport { Entrypoint, EntrypointRouteMap, RouteHandler, RouteManager, html_generator } from \"../providers/entrypoints.ts\"\n\nimport { CACHED_CONTENT, getOuterHTML } from \"../html/render.ts\";\nimport { HTTPStatus } from \"../html/http-status.ts\";\nimport { RenderPreset, RenderMethod } from \"../base/render-methods.ts\"\nimport { client_type } from \"datex-core-legacy/utils/constants.ts\";\nimport { createErrorHTML } from \"../html/errors.tsx\";\nimport { Context, ContextGenerator } from \"./context.ts\";\nimport { Component } from \"../components/Component.ts\";\nimport { logger } from \"../utils/global-values.ts\";\nimport { domContext } from \"../app/dom-context.ts\";\nimport { UIX } from \"../../uix.ts\";\nimport { convertToWebPath } from \"../app/convert-to-web-path.ts\";\nimport { FileHandle } from \"../providers/common.tsx\";\n\n// URLPattern polyfill\n// @ts-ignore\nif (!globalThis.URLPattern) { \n\tawait import(\"../lib/urlpattern-polyfill/index.js\" /*lazy*/);\n}\n\n\n\n\n/**\n * Render the current state of the element as HTML and cache for SSR\n * @param content\n * @param render_method \n * @returns \n */\nexport async function createSnapshot<T extends Element|DocumentFragment>(content:T, render_method = RenderMethod.HYBRID):Promise<T> {\n\tawait preloadElementOnBackend(content);\n\t// @ts-ignore\n\tcontent[CACHED_CONTENT] = getOuterHTML(content, {\n\t\tinjectStandaloneJS:render_method!=RenderMethod.STATIC, \n\t\tinjectStandaloneComponents:render_method!=RenderMethod.STATIC, \n\t\tlang:Datex.Runtime.ENV.LANG,\n\t\textractedData: {},\n\t\tincludeShadowRoots: true\n\t});\n\treturn content;\n}\n\n\n\ntype match_path<C extends EntrypointRouteMap, P extends string & keyof C> = C[P];\n\ntype get_content<C extends Entrypoint, Path extends string = string> = \n\t// if C is EntrypointRouteMap -> return object value\n\tC extends EntrypointRouteMap ? get_content<match_path<C,Path>> : (\n\t\t// if C is RenderPreset -> return RenderPreset.__content\n\t\tC extends RenderPreset<infer R, infer T> ? get_content<T> : (\n\t\t\t// else if C is generator function\n\t\t\tC extends (...args:unknown[])=>infer T ? (\n\t\t\t\t// if generator returns preset -> return RenderPreset.content\n\t\t\t\tT extends RenderPreset<infer R, infer T2> ? get_content<T2> :\n\t\t\t\t// else return generator return value\n\t\t\t\tT\n\t\t\t) :\n\t\t\tC\n\t\t)\n\t)\n\ntype get_render_method<C extends Entrypoint, Path extends string = string> = \n\t// if C is EntrypointRouteMap -> get render method for property\n\tC extends EntrypointRouteMap ? get_render_method<match_path<C,Path>> : (\n\t\t// if C is RenderPreset -> return RenderPreset.__render_method\n\t\tC extends RenderPreset<infer R, infer T> ? R : (\n\t\t\t// else if C is generator function\n\t\t\tC extends (...args:unknown[])=>infer T ? (\n\t\t\t\t// if generator returns preset -> return RenderPreset.__render_method\n\t\t\t\tT extends RenderPreset<infer R, infer T2> ? R :\n\t\t\t\t// else return default RenderMethod.HYDRATION\n\t\t\t\tRenderMethod.HYBRID\n\t\t\t) :\n\t\t\tRenderMethod.HYBRID\n\t\t)\n\t);\n\n\ntype entrypointData<T extends Entrypoint = Entrypoint> = {\n\tentrypoint: T,\n\troute?:Path.Route, \n\tcontext?:ContextGenerator|Context, \n\tonly_return_static_content?: boolean\n\treturn_first_routing_handler?: boolean,\n\tprobe_no_side_effects?: boolean, // if true, only check if the route exists, if possible, but don' call function etc\n}\n\ntype resolvedEntrypointData<T extends Entrypoint = Entrypoint> = {\n\tcontent: get_content<T>,\n\trender_method: RenderMethod, // get_render_method<T>, \n\tstatus_code?: number, \n\tloaded: boolean, \n\tremaining_route?: Path.Route,\n\theaders?: Headers // additional response headers\n}\n\nfunction reconstructMatchedURLPart(input:string, partResult:URLPatternComponentResult) {\n\tfor (const [name,val] of Object.entries(partResult.groups)) {\n\t\tinput = input.replace(':'+name, val??'');\n\t}\n\treturn input\n}\n\n/**\n * replaces ':name' parts of url pattern with matched values to reconstruct a valid url (keeps *)\n * @param input \n * @param match \n * @returns \n */\nfunction reconstructMatchedURL(input:string, match:URLPatternResult) {\n\tinput = reconstructMatchedURLPart(input, match.protocol);\n\tinput = reconstructMatchedURLPart(input, match.username);\n\tinput = reconstructMatchedURLPart(input, match.password);\n\tinput = reconstructMatchedURLPart(input, match.hostname);\n\tinput = reconstructMatchedURLPart(input, match.pathname);\n\tinput = reconstructMatchedURLPart(input, match.hash);\n\tinput = reconstructMatchedURLPart(input, match.search);\n\treturn input\n}\n\nfunction resolveContext(entrypointData: entrypointData): asserts entrypointData is entrypointData & {context: Context} {\n\tif (typeof entrypointData.context == \"function\") entrypointData.context = entrypointData.context();\n\tif (!entrypointData.context) throw new Error(\"missing UIX context for generator function\")\n}\n\nasync function resolveGeneratorFunction(entrypointData: entrypointData<html_generator>): Promise<resolvedEntrypointData> {\n\tresolveContext(entrypointData)\n\n\tlet returnValue: Entrypoint|undefined;\n\tlet hasError = false;\n\ttry {\n\t\treturnValue = await entrypointData.entrypoint(entrypointData.context, (entrypointData.context).params);\n\t}\n\t// return error as response with HTTPStatus error 500\n\tcatch (e) {\n\t\t\n\t\tif (e instanceof Error) {\n\t\t\thasError = true;\n\t\t\treturnValue = e;\n\t\t}\n\t\telse if (e instanceof HTTPStatus) {\n\t\t\thasError = true;\n\t\t\treturnValue = e;\n\t\t}\n\t\t// TODO: fix instance check if transmitted via datex, currently just force converted to HTTPStatus\n\t\telse if (typeof e == \"object\" && \"code\" in e && \"content\" in e && Object.keys(e).length == 2) {\n\t\t\thasError = true;\n\t\t\treturnValue = new HTTPStatus(e.code, e.content);\n\t\t}\n\n\t\t// keep responses if they have an error code\n\t\telse if (e instanceof Response) {\n\t\t\tif (e.status >= 400) {\n\t\t\t\thasError = true;\n\t\t\t\treturnValue = e;\n\t\t\t}\n\t\t\telse {\n\t\t\t\tlogger.warn(\"A Response with a non-error status code was thrown in a generator function. This is not recommended - when using throw, the response should always have a status code >= 400.\");\n\t\t\t}\n\t\t}\n\n\t\t// warn if URL was thrown\n\t\telse if (e instanceof URL) {\n\t\t\tlogger.warn(\"A URL indicating a redirect (302) was thrown in a generator function. This is not recommended - URLs should always be returned and not thrown.\");\n\t\t\thasError = true;\n\t\t\treturnValue = e;\n\t\t}\n\n\t\telse {\n\t\t\treturnValue = HTTPStatus.INTERNAL_SERVER_ERROR.with(e)\n\t\t}\n\t}\n\n\tconst resolved = await resolveEntrypointRoute({...entrypointData, entrypoint: returnValue})\n\tif (hasError) resolved.render_method = RenderMethod.BACKEND; // override: render errors as backend\n\n\treturn resolved;\n}\n\nasync function resolveRenderPreset(entrypointData: entrypointData<RenderPreset>): Promise<resolvedEntrypointData> {\n\t// handle cached response on server\n\tif (entrypointData.entrypoint.__render_method == RenderMethod.CACHED_RESPONSE) {\n\t\tif (!entrypointData.route) throw new Error(\"missing entrypoint route (required for cached response)\");\n\t\tconst response = await fetch(entrypointData.route, {\n\t\t\theaders: new Headers({ \"UIX-Cache-Token\": entrypointData.entrypoint.__content as string }),\n\t\t\tcredentials: \"include\"\n\t\t});\n\t\treturn {\n\t\t\tcontent: response,\n\t\t\trender_method: entrypointData.entrypoint.__render_method,\n\t\t\tstatus_code: response.status,\n\t\t\theaders: response.headers,\n\t\t\tloaded: true\n\t\t}\n\t}\n\t\n\tconst content = await entrypointData.entrypoint.__content;\n\tconst resolved = await resolveEntrypointRoute({...entrypointData, entrypoint: content});\n\tresolved.render_method = entrypointData.entrypoint.__render_method;\n\tif (entrypointData.entrypoint.__status_code != undefined) resolved.status_code = entrypointData.entrypoint.__status_code;\n\treturn resolved;\n}\n\nasync function resolveHTTPStatus(entrypointData: entrypointData<HTTPStatus>): Promise<resolvedEntrypointData> {\n\tconst content = await entrypointData.entrypoint.content;\n\tconst resolved = await resolveEntrypointRoute({...entrypointData, entrypoint: content});\n\tresolved.status_code = entrypointData.entrypoint.code;\n\treturn resolved;\n}\n\n\nasync function resolveRouteHandler(entrypointData: entrypointData<RouteHandler>): Promise<resolvedEntrypointData> {\n\tresolveContext(entrypointData)\n\tif (!entrypointData.route) throw new Error(\"missing entrypoint route (required for RouteHandler\")\n\tconst route2 = await entrypointData.entrypoint.getRoute(entrypointData.route, entrypointData.context);\n\tentrypointData.route = Path.Route(\"/\"); // route completely resolved by getRoute\n\treturn resolveEntrypointRoute({...entrypointData, entrypoint: route2})\n}\n\nfunction resolveModule(entrypointData: entrypointData<{default?:Entrypoint}>): Promise<resolvedEntrypointData> {\n\tif (!entrypointData.entrypoint.default) throw new Error(\"invalid module as entrypoint: no default export\")\n\tconst content = entrypointData.entrypoint.default\n\treturn resolveEntrypointRoute({...entrypointData, entrypoint: content});\n}\n\nfunction generateURLParamsObject(matches: URLPatternResult) {\n\tconst params:Record<string, string> = {};\n\tconst groups = {\n\t\t...matches.hash.groups??{},\n\t\t...matches.hostname.groups??{},\n\t\t...matches.password.groups??{},\n\t\t...matches.pathname.groups??{},\n\t\t...matches.port.groups??{},\n\t\t...matches.protocol.groups??{},\n\t\t...matches.search.groups??{},\n\t\t...matches.username.groups??{},\n\t}\n\tfor (const [key, val] of Object.entries(groups)) {\n\t\t// ignore number keys\n\t\tif (!isNaN(Number(key))) continue;\n\t\tparams[key] = val as string;\n\t}\n\treturn params;\n}\n\nfunction hasWildcard(route: string | URL) {\n\troute = route instanceof URL ? route.pathname : route;\n\treturn route.includes(\"*\") || route.includes(\"/:\")\n}\n\nasync function resolvePathMap(entrypointData: entrypointData<EntrypointRouteMap>): Promise<resolvedEntrypointData|undefined> {\n\tresolveContext(entrypointData)\n\n\t// find longest matching route\n\tlet closest_match_key:string|filter|null = null;\n\tlet closest_match_route:Path.Route|null = null;\n\tconst isBetterMatch = (potential_route_key: string) => {\n\t\t// compare length of current closest_match with potential_route, ignoring *\n\t\tif (!closest_match_route) return true;\n\t\tif (closest_match_route.routename === potential_route_key) return true;\n\t\tif (\n\t\t\t(hasWildcard(closest_match_route.routename) && hasWildcard(potential_route_key)) ||\n\t\t\t(!hasWildcard(closest_match_route.routename) && !hasWildcard(potential_route_key))\n\t\t)\n\t\t\treturn potential_route_key.replace(/\\*$/, '').length > \n\t\t\t\tclosest_match_route.routename.replace(/\\*$/, '').length\n\t\treturn false;\n\t}\n\t// if true, the remaing '*' child routes are resolved in the next layer\n\tlet handle_children_separately = false;\n\n\t// handle symbol keys (request methods)\n\tlet matchingSymbol = false;\n\tlet lastMatch:URLPatternResult|null = null;\n\n\tfor (const potential_route_key of Object.keys(entrypointData.entrypoint)) {\n\t\tlet matchWith = entrypointData.route!;\n\n\t\tlet urlPattern:URLPattern;\n\t\t// url with http - match with base origin\n\t\tif (potential_route_key.startsWith(\"http://\") || potential_route_key.startsWith(\"https://\")) {\n\t\t\t// avoid confusion with http and https, allow both\n\t\t\tconst normalizedRouteKey = potential_route_key.replace(/^https?/, \"http{s}?\");\n\t\t\turlPattern = new URLPattern(normalizedRouteKey);\n\t\t\tmatchWith = entrypointData.context.request?.url ? new Path(entrypointData.context.request?.url) : new Path(entrypointData.route!.routename, globalThis.location?.href??'http:///unknown')\n\t\t}\n\t\t// just match a generic route\n\t\telse {\n\t\t\tlet normalized_route_key = potential_route_key;\n\t\t\tif (!potential_route_key.startsWith(\"/\")) normalized_route_key = \"/\" + potential_route_key\n\t\t\tconst [pathname, hash] = normalized_route_key.split(\"#\");\n\t\t\turlPattern = new URLPattern({pathname, hash})\n\t\t}\n\t\t\n\t\tlet match:URLPatternResult|null;\n\t\tif ((match=urlPattern.exec(matchWith.toString())) && isBetterMatch(potential_route_key)) {\n\t\t\tclosest_match_key = potential_route_key;\n\t\t\tclosest_match_route = Path.Route(reconstructMatchedURL(potential_route_key, match));\n\t\t\t// route ends with * -> allow child routes\n\t\t\thandle_children_separately = potential_route_key.endsWith(\"*\");\n\t\t\tlastMatch = match;\n\t\t}\n\t}\n\t\n\n\t// check symbols if no match key found, or only default wildcard\n\tif (closest_match_key==null || closest_match_key == \"*\") {\n\t\tfor (const symbolKey of Object.getOwnPropertySymbols(entrypointData.entrypoint)) {\n\t\t\tif (await evaluateFilter(symbolKey as filter, entrypointData.context)) {\n\t\t\t\tmatchingSymbol = true;\n\t\t\t\tclosest_match_key = symbolKey as filter;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\t\n\t\n\tif (closest_match_key!==null) {\n\t\tlet val = <any> entrypointData.entrypoint.$ ? (<any>entrypointData.entrypoint.$)[closest_match_key] : (<EntrypointRouteMap>entrypointData.entrypoint)[closest_match_key];\n\t\tif (val instanceof Datex.ReactiveValue && !(val instanceof Datex.Pointer && val.is_js_primitive)) val = val.val; // only keep primitive pointer references\n\t\tval = await val;\n\t\t// only update route if a string key, symbol keys don't mutate the route\n\t\tconst new_path = matchingSymbol ? entrypointData.route : closest_match_route ? Path.Route(entrypointData.route!.routename.replace(closest_match_route.routename.replace(/\\*$/,\"\"), \"\") || \"/\") : Path.Route(\"/\");\n\n\t\t// extend context with additional URL params\n\t\tif (lastMatch) {\n\t\t\tentrypointData.context.params = {...entrypointData.context.params, ...generateURLParamsObject(lastMatch)};\n\t\t\tentrypointData.context.urlPattern = lastMatch;\n\t\t}\n\t\t\n\t\tconst resolved = await resolveEntrypointRoute({...entrypointData, entrypoint: val, route: new_path});\n\t\tif (!handle_children_separately) resolved.remaining_route = Path.Route(\"/\");\n\t\treturn resolved;\n\t} \n\telse {\n\t\t// pass through if nothing found\n\t\treturn {\n\t\t\tstatus_code: undefined,\n\t\t\tcontent: null,\n\t\t\tloaded: true,\n\t\t\trender_method: RenderMethod.DYNAMIC\n\t\t}\n\t}\n}\n\n\nexport async function resolveEntrypointRoute<T extends Entrypoint>(entrypointData: entrypointData<T>): Promise<resolvedEntrypointData<Entrypoint>> {\n\n\t// init context if missing\n\tif (!entrypointData.context) {\n\t\tentrypointData.context = new Context()\n\t\tif (entrypointData.route) entrypointData.context.path = entrypointData.route.pathname\n\t}\n\t// init route if missing\n\tentrypointData.route ??= Path.Route();\n\n\t// make sure entrypoint Promise is awaited\n\tentrypointData.entrypoint = await entrypointData.entrypoint;\n\n\tlet resolved: resolvedEntrypointData = {\n\t\tcontent: undefined,\n\t\trender_method: RenderMethod.HYBRID,\n\t\tremaining_route: entrypointData.route,\n\t\tloaded: false,\n\t\tstatus_code: undefined\n\t}\n\n\t// handle only return static\n\tif (entrypointData.only_return_static_content && entrypointData.entrypoint && (<any> entrypointData.entrypoint).__render_method == RenderMethod.DYNAMIC) {\n\t\tresolved.remaining_route = Path.Route(\"/\");\n\t\tresolved.render_method = RenderMethod.DYNAMIC;\n\t\tresolved.content = \"\";\n\t}\n\n\t// handle generator functions (exclude class)\n\telse if (!entrypointData.probe_no_side_effects && typeof entrypointData.entrypoint == \"function\" && !/^\\s*class/.test(entrypointData.entrypoint.toString())) {\n\t\tresolved = await resolveGeneratorFunction(entrypointData as entrypointData<html_generator>);\n\t}\n\n\t// handle render presets\n\telse if (entrypointData.entrypoint instanceof RenderPreset || (entrypointData.entrypoint && typeof entrypointData.entrypoint == \"object\" && !(entrypointData.entrypoint instanceof domContext.Element) && '__content' in entrypointData.entrypoint)) {\n\t\tresolved = await resolveRenderPreset(entrypointData as entrypointData<RenderPreset>);\n\t}\n\n\t// handle RouteHandler TODO: better checks for interfaces? (not just 'getRoute')\n\telse if (!entrypointData.probe_no_side_effects && typeof (entrypointData.entrypoint as any)?.getRoute == \"function\") {\n\t\tresolved = await resolveRouteHandler(entrypointData as entrypointData<RouteHandler>);\n\t}\n\n\t// handle FsFile\n\telse if (client_type === \"deno\" && entrypointData.entrypoint instanceof Deno.FsFile) {\n\t\tresolved.content = new Response(entrypointData.entrypoint.readable)\n\t\t// TODO: get mime type from FsFile\n\t\tlogger.warn(\"Mime type cannot be determined for FsFile\");\n\t\t// cors headers (TODO: more general way to define cors behavior)\n\t\tresolved.content.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n\t\tresolved.content.headers.set(\"Access-Control-Allow-Headers\", \"*\");\n\t}\n\n\t// handle FileHandle\n\telse if (client_type === \"deno\" && entrypointData.entrypoint instanceof FileHandle) {\n\t\ttry {\n\t\t\tconst file = await Deno.open(entrypointData.entrypoint.path.normal_pathname);\n\t\t\tconst { mime } = await import(\"https://deno.land/x/mimetypes@v1.0.0/mod.ts\");\n\t\t\tconst mimeType = mime.getType(entrypointData.entrypoint.path.name);\n\n\t\t\tresolved.content = new Response(file.readable)\n\t\t\t// cors headers (TODO: more general way to define cors behavior)\n\t\t\tresolved.content.headers.set(\"Access-Control-Allow-Origin\", \"*\");\n\t\t\tresolved.content.headers.set(\"Access-Control-Allow-Headers\", \"*\");\n\t\t\tif (mimeType) resolved.content.headers.set(\"Content-Type\", mimeType);\n\t\t}\n\t\tcatch {\n\t\t\tthrow HTTPStatus.NOT_FOUND\n\t\t}\n\t}\n\n\n\t// handle status code from HTTPStatus\n\telse if (entrypointData.entrypoint instanceof HTTPStatus) {\n\t\tresolved = await resolveHTTPStatus(entrypointData as entrypointData<HTTPStatus>);\n\t}\n\n\t// await Promise\n\telse if (entrypointData.entrypoint instanceof Promise) {\n\t\tresolved.content = await entrypointData.entrypoint;\n\t}\n\t\n\t// handle path object, not element/markdown/special_content\n\telse if (!(entrypointData.entrypoint instanceof domContext.Element || entrypointData.entrypoint instanceof Datex.Markdown || entrypointData.entrypoint instanceof URL || (client_type === \"deno\" && entrypointData.entrypoint instanceof globalThis.Deno.FsFile)) && entrypointData.entrypoint && typeof entrypointData.entrypoint == \"object\" && Object.getPrototypeOf(entrypointData.entrypoint) == Object.prototype) {\n\t\tresolved = await resolvePathMap(entrypointData as entrypointData<EntrypointRouteMap>) ?? resolved;\n\t}\n\n\t// handle module (prototype null) - get default value\n\telse if (typeof entrypointData.entrypoint == \"object\" && entrypointData.entrypoint && Object.getPrototypeOf(entrypointData.entrypoint) == null) {\n\t\tresolved = await resolveModule(entrypointData as entrypointData<{default?:Entrypoint}>);\n\t}\n\n\t// handle URL\n\telse if (entrypointData.entrypoint instanceof URL) {\n\t\tresolved.content = new Response(null, {\n\t\t\tstatus: 302,\n\t\t\theaders: new Headers({ location: convertToWebPath(entrypointData.entrypoint), \"Access-Control-Allow-Origin\": \"*\", \"Access-Control-Allow-Headers\": \"*\" })\n\t\t});\n\t}\n\n\t// handle Error\n\telse if (entrypointData.entrypoint instanceof Error) {\n\t\tconst [statusCode, html] = createErrorHTML('Routing failed: ' + entrypointData.entrypoint.message, entrypointData.entrypoint);\n\t\tresolved.content = html;\n\t\tresolved.status_code = statusCode;\n\t}\n\t\n\n\t// else just return current entrypoint\n\telse {\n\t\tresolved.content = entrypointData.entrypoint\n\t\t// if (entrypointData.entrypoint != null) {\n\t\t\t\n\t\t// }\n\t\t// else {\n\t\t// \tresolved = {\n\t\t// \t\tstatus_code: 404,\n\t\t// \t\tcontent: \"No Content\",\n\t\t// \t\tloaded: true,\n\t\t// \t\trender_method: RenderMethod.RAW_CONTENT\n\t\t// \t}\n\t\t// }\n\t\t\n\t\t\n\t}\n\n\t// @ts-ignore TODO: is this if condition required? currently commented out, because paths are overriden incorrectly\n\t// if (typeof entrypointData.entrypoint?.resolveRoute !== \"function\") \n\t// \tresolved.remaining_route = Path.Route(\"/\");\n\n\t// only load once in recursive calls when deepest level reached\n\tif (!resolved.loaded) {\n\t\t// preload in deno, TODO: better solution?\n\t\tif (UIX.context == \"backend\" && (entrypointData.entrypoint instanceof domContext.Element || entrypointData.entrypoint instanceof domContext.DocumentFragment)) {\n\t\t\tawait preloadElementOnBackend(entrypointData.entrypoint)\n\t\t}\n\n\t\t// routing handler?\n\t\t// @ts-ignore\n\t\tif (entrypointData.return_first_routing_handler && typeof resolved.content?.getInternalRoute == \"function\") {\n\t\t\t// return [<get_content<T>>collapsed, <any>render_method, status_code, loaded, remaining_route];\n\t\t}\n\n\t\t// @ts-ignore\n\t\telse if (entrypointData.route && typeof resolved.content?.resolveRoute == \"function\") {\n\n\t\t\t// wait until at least construct lifecycle finished\n\t\t\tif (entrypointData.entrypoint instanceof Component) await entrypointData.entrypoint.constructed\n\n\t\t\tif (!await resolveRouteForRouteManager(resolved.content as RouteManager, entrypointData.route, entrypointData.context)) {\n\t\t\t\tresolved.content = null; // reset content, route could not be resolved\n\t\t\t}\n\t\t}\n\n\t\tresolveContext(entrypointData)\n\t\tif ((entrypointData.context as any)._responseHeaders) resolved.headers = (entrypointData.context as any)._responseHeaders;\n\n\t\tresolved.loaded = true;\n\t}\n\n\treturn resolved;\n}\n\n\nexport async function preloadElementOnBackend(element:Element|DocumentFragment, parent?:Element|DocumentFragment) {\n\t// preload in deno, TODO: better solution?\n\tif (UIX.context == \"backend\") {\n\n\t\tconst promises = [];\n\n\t\t// fake dom append for UIX Component\n\t\tif (element instanceof Component) {\n\t\t\tlet resolved = false;\n\t\t\tconst timeoutSec = `${(element.CREATE_TIMEOUT/1000)}s`\n\t\t\tawait Promise.race([\n\t\t\t\telement.connectedCallback(),\n\t\t\t\telement.created,\n\t\t\t\tnew Promise<void>(resolve=>setTimeout(()=>{\n\t\t\t\t\tif (!resolved) {\n\t\t\t\t\t\tlogger.error(\"onCreate() method of \"+element.constructor.name+\" has not resolved after \"+timeoutSec+\", generating static snapshot for available state. Increase the CREATE_TIMEOUT for this component if the onCreate method is supposed to take longer than \"+timeoutSec+\".\");\n\t\t\t\t\t\tresolve()\n\t\t\t\t\t}\n\t\t\t\t},element.CREATE_TIMEOUT))\n\t\t\t])\n\t\t\tresolved = true;\n\t\t}\n\t\t\n\t\t// fake dom append for other elements with connectedCallback (e.g light-root)\n\t\telse if (typeof (element as any).connectedCallback == \"function\") {\n\t\t\t(element as any).connectedCallback();\n\t\t}\n\n\t\t// load shadow root\n\t\tif ((element as Element).shadowRoot) promises.push(preloadElementOnBackend((element as Element).shadowRoot!, element))\n\t\t// load children\n\t\tfor (const child of (element.childNodes as unknown as Element[])) {\n\t\t\tpromises.push(preloadElementOnBackend(child, element));\n\t\t}\n\n\t\tawait Promise.all(promises)\n\t}\n}\n\n/**\n * Resolve a route on a RouteManager\n * @param routeManager RouteManager impl\n * @param route array of route parts\n * @param context UIX context\n * @returns true if the route could be fully resolved\n */\nasync function resolveRouteForRouteManager(routeManager: RouteManager, route:Path.Route, context: Context|ContextGenerator) {\n\tif (typeof context == \"function\") context = await context();\n\tconst valid_route_part = <Path.route_representation> await Promise.race([\n\t\trouteManager.resolveRoute(route, context),\n\t\tnew Promise((_,reject) => setTimeout(()=>{\n\t\t\treject(new Error(\"Route Manager (\"+routeManager.constructor.name+\") did not resolve after 5s. There is probably a deadlock somehere. This can for example happen in a Component when awaiting defer() in the onRoute() handler.\"))\n\t\t}, 5000))\n\t])\n\treturn Path.routesAreEqual(route, valid_route_part);\n}\n\n/**\n * gets the part of the route that is calculated without internal routing (RouteManager). \n * Recalculate the current path from the inner Routing Handler if it exists\n * @param route \n * @param entrypoint \n * @param context \n * @returns \n */\nexport async function refetchRoute(route: Path.route_representation, entrypoint: Entrypoint, context?:Context) {\n\tconst route_path = Path.Route(route);\n\n\tconst {content: routing_handler, remaining_route} = await resolveEntrypointRoute({entrypoint, route: route_path, context, return_first_routing_handler: true});\n\n\t// resolve internal route in RouteManager\n\tif (routing_handler?.getInternalRoute) {\n\t\tif (!remaining_route) throw new Error(\"could not reconstruct route \" + route_path.routename);\n\t\n\t\t// valid part of route before potential RouteManager\n\t\tconst existing_route = Path.Route(route_path.routename.replace(remaining_route.routename,\"\"));\n\t\n\t\tconst combined_route = <Path.Route> existing_route.getChildRoute(Path.Route(await (<RouteManager>routing_handler).getInternalRoute()));\n\t\treturn combined_route;\n\t}\n\t// no internal routing, just return original route\n\telse return route_path;\n\t\n}"],"names":["Path","Datex","evaluateFilter","CACHED_CONTENT","getOuterHTML","HTTPStatus","RenderPreset","RenderMethod","client_type","createErrorHTML","Context","Component","logger","domContext","UIX","convertToWebPath","FileHandle","globalThis","URLPattern","createSnapshot","content","render_method","HYBRID","preloadElementOnBackend","injectStandaloneJS","STATIC","injectStandaloneComponents","lang","Runtime","ENV","LANG","extractedData","includeShadowRoots","reconstructMatchedURLPart","input","partResult","name","val","Object","entries","groups","replace","reconstructMatchedURL","match","protocol","username","password","hostname","pathname","hash","search","resolveContext","entrypointData","context","Error","resolveGeneratorFunction","returnValue","hasError","entrypoint","params","e","keys","length","code","Response","status","warn","URL","INTERNAL_SERVER_ERROR","with","resolved","resolveEntrypointRoute","BACKEND","resolveRenderPreset","__render_method","CACHED_RESPONSE","route","response","fetch","headers","Headers","__content","credentials","status_code","loaded","undefined","__status_code","resolveHTTPStatus","resolveRouteHandler","route2","getRoute","Route","resolveModule","default","generateURLParamsObject","matches","key","port","isNaN","Number","hasWildcard","includes","resolvePathMap","closest_match_key","closest_match_route","isBetterMatch","potential_route_key","routename","handle_children_separately","matchingSymbol","lastMatch","urlPattern","matchWith","startsWith","request","url","location","href","normalized_route_key","split","exec","toString","endsWith","symbolKey","getOwnPropertySymbols","DYNAMIC","$","ReactiveValue","Pointer","is_js_primitive","new_path","remaining_route","path","only_return_static_content","probe_no_side_effects","test","Element","Deno","FsFile","readable","set","file","open","normal_pathname","mime","mimeType","getType","NOT_FOUND","Promise","Markdown","getPrototypeOf","prototype","statusCode","html","message","DocumentFragment","return_first_routing_handler","getInternalRoute","resolveRoute","constructed","resolveRouteForRouteManager","_responseHeaders","element","parent","promises","timeoutSec","CREATE_TIMEOUT","race","connectedCallback","created","resolve","setTimeout","error","constructor","child","shadowRoot","push","childNodes","all","routeManager","valid_route_part","_","reject","routesAreEqual","refetchRoute","route_path","routing_handler","existing_route","getChildRoute"],"mappings":"AAAA,SAASA,IAAI,QAAQ,kCAAkC;AACvD,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAAQC,cAAc,QAAe,oBAAoB;AAGzD,SAASC,cAAc,EAAEC,YAAY,QAAQ,oBAAoB;AACjE,SAASC,UAAU,QAAQ,yBAAyB;AACpD,SAASC,YAAY,EAAEC,YAAY,QAAQ,4BAA2B;AACtE,SAASC,WAAW,QAAQ,uCAAuC;AACnE,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,OAAO,QAA0B,eAAe;AACzD,SAASC,SAAS,QAAQ,6BAA6B;AACvD,SAASC,MAAM,QAAQ,4BAA4B;AACn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