@noego/forge 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"client.mjs","sources":["../src/routing/url_parser.ts","../node_modules/@babel/runtime/helpers/esm/extends.js","../node_modules/history/index.js","../src/client/navigation.svelte.ts","../src/routing/manifest/store.svelte.ts","../src/client/events.ts","../src/client/client.ts"],"sourcesContent":["import pathToRegex from 'path-to-regex';\nimport type { IRoute } from '../parser/IRoute';\n\n\n\nexport function makeUrlParser(pattern: string) {\n const parser = new pathToRegex(pattern);\n return (pathname: string) => {\n const result = parser.match(pathname);\n return result || null;\n };\n}\n\n\nexport type UrlMatcher = {\n pattern: string,\n parser: ReturnType<typeof makeUrlParser>\n}\n\nexport function findRoute(pathname:string, routes: UrlMatcher[]) {\n for (const { pattern, parser } of routes) {\n const params = parser(pathname);\n if (params) {\n return { pattern, params };\n }\n }\n return null;\n}\n\n\n\n\n\nexport function initialize_route_matchers(routes: IRoute[]): UrlMatcher[] {\n return routes.map((route: IRoute) => {\n const pattern = route.path;\n const parser = makeUrlParser(pattern);\n return { pattern, parser };\n })\n}\n","function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","import _extends from '@babel/runtime/helpers/esm/extends';\n\n/**\r\n * Actions represent the type of change to a location value.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#action\r\n */\nvar Action;\n\n(function (Action) {\n /**\r\n * A POP indicates a change to an arbitrary index in the history stack, such\r\n * as a back or forward navigation. It does not describe the direction of the\r\n * navigation, only that the current index changed.\r\n *\r\n * Note: This is the default action for newly created history objects.\r\n */\n Action[\"Pop\"] = \"POP\";\n /**\r\n * A PUSH indicates a new entry being added to the history stack, such as when\r\n * a link is clicked and a new page loads. When this happens, all subsequent\r\n * entries in the stack are lost.\r\n */\n\n Action[\"Push\"] = \"PUSH\";\n /**\r\n * A REPLACE indicates the entry at the current index in the history stack\r\n * being replaced by a new one.\r\n */\n\n Action[\"Replace\"] = \"REPLACE\";\n})(Action || (Action = {}));\n\nvar readOnly = process.env.NODE_ENV !== \"production\" ? function (obj) {\n return Object.freeze(obj);\n} : function (obj) {\n return obj;\n};\n\nfunction warning(cond, message) {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== 'undefined') console.warn(message);\n\n try {\n // Welcome to debugging history!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message); // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nvar BeforeUnloadEventType = 'beforeunload';\nvar HashChangeEventType = 'hashchange';\nvar PopStateEventType = 'popstate';\n/**\r\n * Browser history stores the location in regular URLs. This is the standard for\r\n * most web apps, but it requires some configuration on the server to ensure you\r\n * serve the same app at multiple URLs.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory\r\n */\n\nfunction createBrowserHistory(options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n _options$window = _options.window,\n window = _options$window === void 0 ? document.defaultView : _options$window;\n var globalHistory = window.history;\n\n function getIndexAndLocation() {\n var _window$location = window.location,\n pathname = _window$location.pathname,\n search = _window$location.search,\n hash = _window$location.hash;\n var state = globalHistory.state || {};\n return [state.idx, readOnly({\n pathname: pathname,\n search: search,\n hash: hash,\n state: state.usr || null,\n key: state.key || 'default'\n })];\n }\n\n var blockedPopTx = null;\n\n function handlePop() {\n if (blockedPopTx) {\n blockers.call(blockedPopTx);\n blockedPopTx = null;\n } else {\n var nextAction = Action.Pop;\n\n var _getIndexAndLocation = getIndexAndLocation(),\n nextIndex = _getIndexAndLocation[0],\n nextLocation = _getIndexAndLocation[1];\n\n if (blockers.length) {\n if (nextIndex != null) {\n var delta = index - nextIndex;\n\n if (delta) {\n // Revert the POP\n blockedPopTx = {\n action: nextAction,\n location: nextLocation,\n retry: function retry() {\n go(delta * -1);\n }\n };\n go(delta);\n }\n } else {\n // Trying to POP to a location with no index. We did not create\n // this location, so we can't effectively block the navigation.\n process.env.NODE_ENV !== \"production\" ? warning(false, // TODO: Write up a doc that explains our blocking strategy in\n // detail and link to it here so people can understand better what\n // is going on and how to avoid it.\n \"You are trying to block a POP navigation to a location that was not \" + \"created by the history library. The block will fail silently in \" + \"production, but in general you should do all navigation with the \" + \"history library (instead of using window.history.pushState directly) \" + \"to avoid this situation.\") : void 0;\n }\n } else {\n applyTx(nextAction);\n }\n }\n }\n\n window.addEventListener(PopStateEventType, handlePop);\n var action = Action.Pop;\n\n var _getIndexAndLocation2 = getIndexAndLocation(),\n index = _getIndexAndLocation2[0],\n location = _getIndexAndLocation2[1];\n\n var listeners = createEvents();\n var blockers = createEvents();\n\n if (index == null) {\n index = 0;\n globalHistory.replaceState(_extends({}, globalHistory.state, {\n idx: index\n }), '');\n }\n\n function createHref(to) {\n return typeof to === 'string' ? to : createPath(to);\n } // state defaults to `null` because `window.history.state` does\n\n\n function getNextLocation(to, state) {\n if (state === void 0) {\n state = null;\n }\n\n return readOnly(_extends({\n pathname: location.pathname,\n hash: '',\n search: ''\n }, typeof to === 'string' ? parsePath(to) : to, {\n state: state,\n key: createKey()\n }));\n }\n\n function getHistoryStateAndUrl(nextLocation, index) {\n return [{\n usr: nextLocation.state,\n key: nextLocation.key,\n idx: index\n }, createHref(nextLocation)];\n }\n\n function allowTx(action, location, retry) {\n return !blockers.length || (blockers.call({\n action: action,\n location: location,\n retry: retry\n }), false);\n }\n\n function applyTx(nextAction) {\n action = nextAction;\n\n var _getIndexAndLocation3 = getIndexAndLocation();\n\n index = _getIndexAndLocation3[0];\n location = _getIndexAndLocation3[1];\n listeners.call({\n action: action,\n location: location\n });\n }\n\n function push(to, state) {\n var nextAction = Action.Push;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n push(to, state);\n }\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr = getHistoryStateAndUrl(nextLocation, index + 1),\n historyState = _getHistoryStateAndUr[0],\n url = _getHistoryStateAndUr[1]; // TODO: Support forced reloading\n // try...catch because iOS limits us to 100 pushState calls :/\n\n\n try {\n globalHistory.pushState(historyState, '', url);\n } catch (error) {\n // They are going to lose state here, but there is no real\n // way to warn them about it since the page will refresh...\n window.location.assign(url);\n }\n\n applyTx(nextAction);\n }\n }\n\n function replace(to, state) {\n var nextAction = Action.Replace;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n replace(to, state);\n }\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr2 = getHistoryStateAndUrl(nextLocation, index),\n historyState = _getHistoryStateAndUr2[0],\n url = _getHistoryStateAndUr2[1]; // TODO: Support forced reloading\n\n\n globalHistory.replaceState(historyState, '', url);\n applyTx(nextAction);\n }\n }\n\n function go(delta) {\n globalHistory.go(delta);\n }\n\n var history = {\n get action() {\n return action;\n },\n\n get location() {\n return location;\n },\n\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n back: function back() {\n go(-1);\n },\n forward: function forward() {\n go(1);\n },\n listen: function listen(listener) {\n return listeners.push(listener);\n },\n block: function block(blocker) {\n var unblock = blockers.push(blocker);\n\n if (blockers.length === 1) {\n window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n\n return function () {\n unblock(); // Remove the beforeunload listener so the document may\n // still be salvageable in the pagehide event.\n // See https://html.spec.whatwg.org/#unloading-documents\n\n if (!blockers.length) {\n window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n };\n }\n };\n return history;\n}\n/**\r\n * Hash history stores the location in window.location.hash. This makes it ideal\r\n * for situations where you don't want to send the location to the server for\r\n * some reason, either because you do cannot configure it or the URL space is\r\n * reserved for something else.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory\r\n */\n\nfunction createHashHistory(options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options2 = options,\n _options2$window = _options2.window,\n window = _options2$window === void 0 ? document.defaultView : _options2$window;\n var globalHistory = window.history;\n\n function getIndexAndLocation() {\n var _parsePath = parsePath(window.location.hash.substr(1)),\n _parsePath$pathname = _parsePath.pathname,\n pathname = _parsePath$pathname === void 0 ? '/' : _parsePath$pathname,\n _parsePath$search = _parsePath.search,\n search = _parsePath$search === void 0 ? '' : _parsePath$search,\n _parsePath$hash = _parsePath.hash,\n hash = _parsePath$hash === void 0 ? '' : _parsePath$hash;\n\n var state = globalHistory.state || {};\n return [state.idx, readOnly({\n pathname: pathname,\n search: search,\n hash: hash,\n state: state.usr || null,\n key: state.key || 'default'\n })];\n }\n\n var blockedPopTx = null;\n\n function handlePop() {\n if (blockedPopTx) {\n blockers.call(blockedPopTx);\n blockedPopTx = null;\n } else {\n var nextAction = Action.Pop;\n\n var _getIndexAndLocation4 = getIndexAndLocation(),\n nextIndex = _getIndexAndLocation4[0],\n nextLocation = _getIndexAndLocation4[1];\n\n if (blockers.length) {\n if (nextIndex != null) {\n var delta = index - nextIndex;\n\n if (delta) {\n // Revert the POP\n blockedPopTx = {\n action: nextAction,\n location: nextLocation,\n retry: function retry() {\n go(delta * -1);\n }\n };\n go(delta);\n }\n } else {\n // Trying to POP to a location with no index. We did not create\n // this location, so we can't effectively block the navigation.\n process.env.NODE_ENV !== \"production\" ? warning(false, // TODO: Write up a doc that explains our blocking strategy in\n // detail and link to it here so people can understand better\n // what is going on and how to avoid it.\n \"You are trying to block a POP navigation to a location that was not \" + \"created by the history library. The block will fail silently in \" + \"production, but in general you should do all navigation with the \" + \"history library (instead of using window.history.pushState directly) \" + \"to avoid this situation.\") : void 0;\n }\n } else {\n applyTx(nextAction);\n }\n }\n }\n\n window.addEventListener(PopStateEventType, handlePop); // popstate does not fire on hashchange in IE 11 and old (trident) Edge\n // https://developer.mozilla.org/de/docs/Web/API/Window/popstate_event\n\n window.addEventListener(HashChangeEventType, function () {\n var _getIndexAndLocation5 = getIndexAndLocation(),\n nextLocation = _getIndexAndLocation5[1]; // Ignore extraneous hashchange events.\n\n\n if (createPath(nextLocation) !== createPath(location)) {\n handlePop();\n }\n });\n var action = Action.Pop;\n\n var _getIndexAndLocation6 = getIndexAndLocation(),\n index = _getIndexAndLocation6[0],\n location = _getIndexAndLocation6[1];\n\n var listeners = createEvents();\n var blockers = createEvents();\n\n if (index == null) {\n index = 0;\n globalHistory.replaceState(_extends({}, globalHistory.state, {\n idx: index\n }), '');\n }\n\n function getBaseHref() {\n var base = document.querySelector('base');\n var href = '';\n\n if (base && base.getAttribute('href')) {\n var url = window.location.href;\n var hashIndex = url.indexOf('#');\n href = hashIndex === -1 ? url : url.slice(0, hashIndex);\n }\n\n return href;\n }\n\n function createHref(to) {\n return getBaseHref() + '#' + (typeof to === 'string' ? to : createPath(to));\n }\n\n function getNextLocation(to, state) {\n if (state === void 0) {\n state = null;\n }\n\n return readOnly(_extends({\n pathname: location.pathname,\n hash: '',\n search: ''\n }, typeof to === 'string' ? parsePath(to) : to, {\n state: state,\n key: createKey()\n }));\n }\n\n function getHistoryStateAndUrl(nextLocation, index) {\n return [{\n usr: nextLocation.state,\n key: nextLocation.key,\n idx: index\n }, createHref(nextLocation)];\n }\n\n function allowTx(action, location, retry) {\n return !blockers.length || (blockers.call({\n action: action,\n location: location,\n retry: retry\n }), false);\n }\n\n function applyTx(nextAction) {\n action = nextAction;\n\n var _getIndexAndLocation7 = getIndexAndLocation();\n\n index = _getIndexAndLocation7[0];\n location = _getIndexAndLocation7[1];\n listeners.call({\n action: action,\n location: location\n });\n }\n\n function push(to, state) {\n var nextAction = Action.Push;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n push(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(nextLocation.pathname.charAt(0) === '/', \"Relative pathnames are not supported in hash history.push(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr3 = getHistoryStateAndUrl(nextLocation, index + 1),\n historyState = _getHistoryStateAndUr3[0],\n url = _getHistoryStateAndUr3[1]; // TODO: Support forced reloading\n // try...catch because iOS limits us to 100 pushState calls :/\n\n\n try {\n globalHistory.pushState(historyState, '', url);\n } catch (error) {\n // They are going to lose state here, but there is no real\n // way to warn them about it since the page will refresh...\n window.location.assign(url);\n }\n\n applyTx(nextAction);\n }\n }\n\n function replace(to, state) {\n var nextAction = Action.Replace;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n replace(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(nextLocation.pathname.charAt(0) === '/', \"Relative pathnames are not supported in hash history.replace(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr4 = getHistoryStateAndUrl(nextLocation, index),\n historyState = _getHistoryStateAndUr4[0],\n url = _getHistoryStateAndUr4[1]; // TODO: Support forced reloading\n\n\n globalHistory.replaceState(historyState, '', url);\n applyTx(nextAction);\n }\n }\n\n function go(delta) {\n globalHistory.go(delta);\n }\n\n var history = {\n get action() {\n return action;\n },\n\n get location() {\n return location;\n },\n\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n back: function back() {\n go(-1);\n },\n forward: function forward() {\n go(1);\n },\n listen: function listen(listener) {\n return listeners.push(listener);\n },\n block: function block(blocker) {\n var unblock = blockers.push(blocker);\n\n if (blockers.length === 1) {\n window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n\n return function () {\n unblock(); // Remove the beforeunload listener so the document may\n // still be salvageable in the pagehide event.\n // See https://html.spec.whatwg.org/#unloading-documents\n\n if (!blockers.length) {\n window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n };\n }\n };\n return history;\n}\n/**\r\n * Memory history stores the current location in memory. It is designed for use\r\n * in stateful non-browser environments like tests and React Native.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#creatememoryhistory\r\n */\n\nfunction createMemoryHistory(options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options3 = options,\n _options3$initialEntr = _options3.initialEntries,\n initialEntries = _options3$initialEntr === void 0 ? ['/'] : _options3$initialEntr,\n initialIndex = _options3.initialIndex;\n var entries = initialEntries.map(function (entry) {\n var location = readOnly(_extends({\n pathname: '/',\n search: '',\n hash: '',\n state: null,\n key: createKey()\n }, typeof entry === 'string' ? parsePath(entry) : entry));\n process.env.NODE_ENV !== \"production\" ? warning(location.pathname.charAt(0) === '/', \"Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: \" + JSON.stringify(entry) + \")\") : void 0;\n return location;\n });\n var index = clamp(initialIndex == null ? entries.length - 1 : initialIndex, 0, entries.length - 1);\n var action = Action.Pop;\n var location = entries[index];\n var listeners = createEvents();\n var blockers = createEvents();\n\n function createHref(to) {\n return typeof to === 'string' ? to : createPath(to);\n }\n\n function getNextLocation(to, state) {\n if (state === void 0) {\n state = null;\n }\n\n return readOnly(_extends({\n pathname: location.pathname,\n search: '',\n hash: ''\n }, typeof to === 'string' ? parsePath(to) : to, {\n state: state,\n key: createKey()\n }));\n }\n\n function allowTx(action, location, retry) {\n return !blockers.length || (blockers.call({\n action: action,\n location: location,\n retry: retry\n }), false);\n }\n\n function applyTx(nextAction, nextLocation) {\n action = nextAction;\n location = nextLocation;\n listeners.call({\n action: action,\n location: location\n });\n }\n\n function push(to, state) {\n var nextAction = Action.Push;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n push(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(location.pathname.charAt(0) === '/', \"Relative pathnames are not supported in memory history.push(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n index += 1;\n entries.splice(index, entries.length, nextLocation);\n applyTx(nextAction, nextLocation);\n }\n }\n\n function replace(to, state) {\n var nextAction = Action.Replace;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n replace(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(location.pathname.charAt(0) === '/', \"Relative pathnames are not supported in memory history.replace(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n entries[index] = nextLocation;\n applyTx(nextAction, nextLocation);\n }\n }\n\n function go(delta) {\n var nextIndex = clamp(index + delta, 0, entries.length - 1);\n var nextAction = Action.Pop;\n var nextLocation = entries[nextIndex];\n\n function retry() {\n go(delta);\n }\n\n if (allowTx(nextAction, nextLocation, retry)) {\n index = nextIndex;\n applyTx(nextAction, nextLocation);\n }\n }\n\n var history = {\n get index() {\n return index;\n },\n\n get action() {\n return action;\n },\n\n get location() {\n return location;\n },\n\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n back: function back() {\n go(-1);\n },\n forward: function forward() {\n go(1);\n },\n listen: function listen(listener) {\n return listeners.push(listener);\n },\n block: function block(blocker) {\n return blockers.push(blocker);\n }\n };\n return history;\n} ////////////////////////////////////////////////////////////////////////////////\n// UTILS\n////////////////////////////////////////////////////////////////////////////////\n\nfunction clamp(n, lowerBound, upperBound) {\n return Math.min(Math.max(n, lowerBound), upperBound);\n}\n\nfunction promptBeforeUnload(event) {\n // Cancel the event.\n event.preventDefault(); // Chrome (and legacy IE) requires returnValue to be set.\n\n event.returnValue = '';\n}\n\nfunction createEvents() {\n var handlers = [];\n return {\n get length() {\n return handlers.length;\n },\n\n push: function push(fn) {\n handlers.push(fn);\n return function () {\n handlers = handlers.filter(function (handler) {\n return handler !== fn;\n });\n };\n },\n call: function call(arg) {\n handlers.forEach(function (fn) {\n return fn && fn(arg);\n });\n }\n };\n}\n\nfunction createKey() {\n return Math.random().toString(36).substr(2, 8);\n}\n/**\r\n * Creates a string URL path from the given pathname, search, and hash components.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createpath\r\n */\n\n\nfunction createPath(_ref) {\n var _ref$pathname = _ref.pathname,\n pathname = _ref$pathname === void 0 ? '/' : _ref$pathname,\n _ref$search = _ref.search,\n search = _ref$search === void 0 ? '' : _ref$search,\n _ref$hash = _ref.hash,\n hash = _ref$hash === void 0 ? '' : _ref$hash;\n if (search && search !== '?') pathname += search.charAt(0) === '?' ? search : '?' + search;\n if (hash && hash !== '#') pathname += hash.charAt(0) === '#' ? hash : '#' + hash;\n return pathname;\n}\n/**\r\n * Parses a string URL path into its separate pathname, search, and hash components.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#parsepath\r\n */\n\nfunction parsePath(path) {\n var parsedPath = {};\n\n if (path) {\n var hashIndex = path.indexOf('#');\n\n if (hashIndex >= 0) {\n parsedPath.hash = path.substr(hashIndex);\n path = path.substr(0, hashIndex);\n }\n\n var searchIndex = path.indexOf('?');\n\n if (searchIndex >= 0) {\n parsedPath.search = path.substr(searchIndex);\n path = path.substr(0, searchIndex);\n }\n\n if (path) {\n parsedPath.pathname = path;\n }\n }\n\n return parsedPath;\n}\n\nexport { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath };\n//# sourceMappingURL=index.js.map\n","\nimport type { IRoute } from '../parser/IRoute'\nimport { hydrate } from 'svelte'\nimport RecursiveLoader from '../components/RecursiveRender.svelte'\nimport { createBrowserHistory } from 'history';\nimport { FORGE_LOAD_SYMBOL } from './client';\nimport {page} from \"./page.svelte\";\n\nconst history = createBrowserHistory()\n\nconst ROOT = $state({\n layouts: [] as any[],\n view: null,\n data: null as any,\n params: null,\n urlParams: null as any,\n query: null as any,\n page\n})\n\nfunction urlJoin(...parts) {\n let url = parts\n .map((part, i) => {\n if (i === 0) return part.replace(/\\/+$/, ''); // trim trailing slash\n return part.replace(/^\\/+|\\/+$/g, ''); // trim both for middle parts\n })\n .join('/');\n\n if (!url.startsWith('/')) {\n url = '/' + url; // add leading slash if not present\n }\n return url.split('?')[0]; // remove query string\n}\n\nexport async function loadRoute(node:any,base_path:string, route: IRoute, combinedParams: any, urlParams:any, query:any) {\n try {\n const layouts_paths = (route.layout || []).map(layout => {\n return urlJoin(base_path,layout).toString()\n })\n let view_path = urlJoin(base_path,route.view).toString()\n\n console.log({layouts_paths,view_path})\n\n const layouts = await Promise.all(layouts_paths.map((layout) => {\n return import(/* @vite-ignore */ layout).then(layout => {\n return layout.default\n })\n }))\n\n if (!view_path.startsWith('/')){\n view_path = '/'+view_path\n }\n const view = await import(/* @vite-ignore */ view_path).then(view => {\n return view.default\n })\n\n ROOT.layouts = layouts\n ROOT.view = view\n ROOT.params = combinedParams\n ROOT.data = (window as any).__INITIAL_DATA__\n ROOT.urlParams = urlParams\n ROOT.query = query\n\n hydrate(RecursiveLoader, {\n target: node,\n props: ROOT,\n })\n } catch (error) {\n console.log('Client-side route loading failed - falling back to SSR navigation');\n console.error('Route loading error:', error);\n // Fallback: Use SSR rendering by triggering a full page load\n const currentUrl = window.location.pathname || '/';\n window.location.href = currentUrl;\n }\n}\n\n\n\nexport async function updateRoute(url:string,base_path:string, route: IRoute, params: any,urlParams:any,query:any,server_loading:boolean = false,update = true) {\n try {\n const layouts_paths = (route.layout || []).map(layout => {\n return urlJoin(base_path,layout).toString()\n })\n const view_path = urlJoin(base_path,route.view).toString()\n const layouts = await Promise.all(layouts_paths.map((layout) => {\n return import(/* @vite-ignore */ layout).then(layout => {\n return layout.default\n })\n }))\n const view = await import(/* @vite-ignore */ view_path).then(view => {\n return view.default\n })\n\n if (server_loading) {\n const fetchOptions: any = {\n method: route.method,\n headers: {\n 'Content-Type': 'application/json',\n 'Accept': 'application/json'\n }\n };\n fetchOptions[FORGE_LOAD_SYMBOL] = true;\n \n await fetch(url, fetchOptions).then((response) => {\n if (response.ok) {\n return response.json()\n } else {\n throw new Error('Network response was not ok')\n }\n }).then((data)=>{\n \n console.log('Server data',data)\n // The server returns structured data: { layout: [...], view: {...} }\n // We need to pass this structure to RecursiveRender correctly\n ROOT.data = data\n ROOT.params = params\n ROOT.layouts = layouts\n ROOT.view = view\n ROOT.urlParams = urlParams\n ROOT.query = query\n })\n }else{\n ROOT.data = {layout:[],view:{}}\n ROOT.params = params\n ROOT.layouts = layouts\n ROOT.view = view\n ROOT.urlParams = urlParams\n ROOT.query = query\n }\n if(window){\n window.scroll(0,0)\n }\n\n if(update){\n history.push(url)\n }\n } catch (error) {\n console.log('Client-side navigation failed for URL:', url, '- falling back to SSR navigation');\n console.error('Navigation error:', error);\n // Fallback: Use SSR rendering by triggering a full page load\n window.location.href = url;\n }\n}\n","\n\n\nexport const MANIFEST_STORE = $state({})\n\n\n\nexport async function updateManifestStore() {\n Object.assign(MANIFEST_STORE, window['__MANIFEST__'])\n // await fetch('/manifest.json')\n // .then(async (response) => {\n // if (response.ok) {\n // const manifest = await response.json();\n // console.log(manifest)\n // Object.assign(MANIFEST_STORE, manifest);\n // }\n // })\n}","\n\nimport type {IRoute} from \"../parser/IRoute\";\nimport type { UrlMatcher } from \"../routing/url_parser\";\nimport { updateRoute } from \"./navigation.svelte\";\nimport { MANIFEST_STORE } from \"../routing/manifest/store.svelte\";\nimport {page} from './page.svelte'\n\n\n\n\nexport function bootstrap_events(base_path:string,routes:IRoute[], matchers: UrlMatcher[]) {\n if(!document){\n console.error('Document not found')\n return\n }\n\n document.addEventListener('click', (event:any) => {\n const currentUrl = window.location.pathname;\n const a = event.target?.tagName === 'A' ? event.target : event.target?.closest('A');\n \n if (a) {\n let url = a.getAttribute('href');\n if (currentUrl === url) {\n event.preventDefault();\n return;\n }\n if (url && url.startsWith('/') || url.startsWith('.')) {\n const pathname = url.split('?')[0];\n const method = a.getAttribute('method') || 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(pathname) && m.pattern === r.path));\n if (route) {\n event.preventDefault();\n const m = matchers.find(m => m.parser(pathname) && m.pattern === route.path);\n const params = m?.parser(pathname) || {};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(url.split('?')[1] || '');\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(url,base_path, route, combinedParams,params,queryParams,requires_server_data);\n } else {\n console.log('No matching route found for URL:', url, '- using fallback navigation');\n // Fallback: Don't prevent default, let browser handle the navigation\n // This will trigger a full page load that the server can handle\n }\n }\n }\n });\n\n\n window.addEventListener('popstate', (_) => {\n const path = window.location.pathname;\n const fullUrl = window.location.pathname + window.location.search;\n // update page data\n page.url = fullUrl\n page.pathname = window.location.pathname\n const method = 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(path) && m.pattern === r.path));\n if (route) {\n const m = matchers.find(m => m.parser(path) && m.pattern === route.path);\n const params = m?.parser(path) || {};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(window.location.search);\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n\n // Object.assign(page.params,params)\n page.params = params\n page.query = queryParams\n\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(fullUrl,base_path, route, combinedParams,params,queryParams,requires_server_data,false);\n } else {\n console.log('No matching route found for popstate navigation to:', path, '- using fallback navigation');\n // Fallback: Trigger full page reload for unknown routes\n window.location.href = path;\n }\n });\n\n\n // Run this once in your bootstrap code\n (function () {\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n\n history.pushState = function (...args) {\n const result = originalPushState.apply(this, args);\n const evt= new Event('pushstate')\n evt['state'] = args[0]\n evt['url'] = args[2]\n window.dispatchEvent(evt);\n return result;\n };\n\n\n history.replaceState = function (...args) {\n const result = originalReplaceState.apply(this, args);\n \n // Only trigger navigation if pathname actually changes\n const newUrl = args[2];\n const currentPathname = window.location.pathname;\n const newPathname = newUrl ? new URL(newUrl, window.location.origin).pathname : currentPathname;\n \n if (newPathname !== currentPathname) {\n const evt= new Event('replacestate')\n evt['state'] = args[0]\n evt['url'] = args[2]\n window.dispatchEvent(evt);\n }\n \n return result;\n }\n // Add a listener to the popstate event\n })();\n\n window.addEventListener('pushstate', (event) => {\n const fullPath = event['url'] || window.location.pathname + window.location.search;\n const path = fullPath.split('?')[0];\n const method = 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(path) && m.pattern === r.path));\n if (route) {\n const m = matchers.find(m => m.parser(path) && m.pattern === route.path);\n const params = m?.parser(path);\n\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(fullPath.split('?')[1] || '');\n const queryParams = Object.fromEntries(urlParams.entries());\n \n page.url = fullPath\n page.pathname = window.location.pathname\n Object.assign(page.params,params)\n Object.assign(page.query,queryParams)\n\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(fullPath,base_path, route, combinedParams,params,queryParams,requires_server_data,false);\n } else {\n console.log('No matching route found for pushstate to:', path, '- using fallback navigation');\n // Fallback: Use full page navigation for unknown routes\n window.location.href = path;\n }\n });\n\n window.addEventListener('replacestate', (event) => {\n const fullPath = event['url'] || window.location.pathname + window.location.search;\n const path = fullPath.split('?')[0];\n\n // update page data\n page.url = fullPath\n page.pathname = window.location.pathname\n page.query = Object.fromEntries(new URLSearchParams(fullPath.split('?')[1] || ''))\n\n const method = 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(path) && m.pattern === r.path));\n if (route) {\n const m = matchers.find(m => m.parser(path) && m.pattern === route.path);\n const params = m?.parser(path) || {};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(fullPath.split('?')[1] || '');\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(fullPath,base_path, route, combinedParams,params,queryParams,requires_server_data,false);\n } else {\n console.log('No matching route found for replacestate to:', path, '- using fallback navigation');\n // Fallback: Use full page navigation for unknown routes\n window.location.href = path;\n }\n });\n \n}\n","import { initialize_route_matchers } from '../routing/url_parser';\nimport { loadRoute } from './navigation.svelte';\nimport { bootstrap_events } from './events';\nimport { updateManifestStore } from '../routing/manifest/store.svelte';\nimport type { ServerOptions } from '../options/ServerOptions';\nimport type { FetchMiddleware, FetchMiddlewareAPI, HeadersObject, AsyncMiddleware, CallbackMiddleware } from '../types/FetchMiddleware';\n\n// Symbol for marking load function fetches\nexport const FORGE_LOAD_SYMBOL = Symbol('forge-load-function');\n\n// Middleware storage\nlet middlewares: Array<FetchMiddleware> = [];\nlet originalFetch: typeof window.fetch | null = null;\n\n// Helper to determine if a URL is an internal route\nfunction isInternalRoute(url: string): boolean {\n try {\n const urlObj = new URL(url, window.location.origin);\n return urlObj.origin === window.location.origin && !urlObj.pathname.startsWith('/api/');\n } catch {\n // Relative URL, assume internal\n return !url.startsWith('/api/');\n }\n}\n\n// Initialize fetch override immediately when module is imported\nfunction initializeFetch(): void {\n if (typeof window !== 'undefined' && !originalFetch) {\n originalFetch = window.fetch;\n\n window.fetch = async function(input: RequestInfo | URL, init: RequestInit = {}): Promise<Response> {\n console.log('🔵 Enhanced fetch called for:', input);\n console.log('🔵 Initial init:', init);\n\n // Start with the original init\n let currentInit: RequestInit = { ...init };\n\n // Run all configured middleware\n for (const middleware of middlewares) {\n try {\n if (middleware.length === 2) {\n // Callback style (legacy): (headers, next) => {}\n // Convert headers for middleware\n const headers = new Headers(currentInit.headers);\n const headersObject: HeadersObject = Object.fromEntries(headers.entries());\n\n console.log('🟡 Running callback-style middleware (length=2)');\n await new Promise<void>((resolve, reject) => {\n try {\n (middleware as any)(headersObject, (error?: any) => {\n if (error) {\n reject(error);\n } else {\n // Convert headers back\n const finalHeaders = new Headers();\n Object.entries(headersObject).forEach(([key, value]) => {\n if (value !== undefined) {\n finalHeaders.set(key, value);\n }\n });\n currentInit.headers = finalHeaders;\n resolve();\n }\n });\n } catch (error) {\n reject(error);\n }\n });\n } else {\n // New style middleware (returns RequestInit)\n console.log('🟡 Running new-style RequestInit middleware (length=' + middleware.length + ')');\n const result = await (middleware as any)(currentInit, input);\n\n if (result && typeof result === 'object') {\n // Middleware returned a value - use it as new RequestInit\n console.log('🟢 Middleware returned RequestInit:', result);\n currentInit = result;\n } else {\n console.log('🟢 Middleware returned:', result);\n }\n }\n } catch (error) {\n console.error('🔴 Middleware error:', error);\n throw error;\n }\n }\n\n console.log('🟢 Final init after middleware:', currentInit);\n\n // Make the actual request\n const response = await originalFetch!(input, currentInit);\n\n // Handle frontend route redirects\n if (response.status >= 300 && response.status < 400 && (init as any)[FORGE_LOAD_SYMBOL]) {\n const location = response.headers.get('location');\n if (location && isInternalRoute(location)) {\n // For internal routes, let the browser handle the redirect\n window.location.href = location;\n return response;\n }\n }\n\n return response;\n };\n }\n}\n\n// Initialize fetch override immediately\ninitializeFetch();\n\n// Export fetch API with middleware configuration\nexport const fetch: FetchMiddlewareAPI & { getMiddlewareCount(): number } = {\n /**\n * Add middleware to the fetch pipeline\n */\n configUpdate(middleware: FetchMiddleware): void {\n if (typeof middleware !== 'function') {\n throw new Error('Middleware must be a function');\n }\n middlewares.push(middleware);\n },\n \n /**\n * Reset all middleware\n */\n reset(): void {\n middlewares.length = 0;\n },\n \n /**\n * Get current middleware count (for debugging)\n */\n getMiddlewareCount(): number {\n return middlewares.length;\n }\n};\n\nlet routing;\n\nexport async function createApp<T extends HTMLElement = HTMLElement>(\n node: T,\n options: ServerOptions\n): Promise<void> {\n\n let base_path = options.component_dir\n\n if(!base_path && typeof base_path !== 'string') {\n throw new Error('No component directory provided');\n }\n let routes = window['__ROUTING__']\n routing = initialize_route_matchers(routes)\n\n if (window && window.location) {\n const application_url = (window.location.pathname || '/').split('?')[0];\n console.log(`Current pathname: ${application_url}`);\n const needle = routing.find(r => r.parser(application_url));\n let route = needle ? routes.find(r => r.path === needle.pattern) : null;\n if (needle && route) {\n console.log(`Found route:`, route);\n const params = needle.parser(application_url) ||{};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(window.location.search);\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n const combinedParams = { ...params, ...queryParams };\n updateManifestStore()\n loadRoute(node, base_path, route, combinedParams,params, queryParams);\n bootstrap_events(base_path, routes, routing);\n } else {\n console.log('No matching route found, using fallback navigation');\n // Fallback: Use window.location.href to navigate to the current URL\n // This will trigger a full page load, allowing the server to handle the route\n window.location.href = application_url;\n return; // Exit early since we're doing a full page navigation\n }\n\n }\n}\n\n\n"],"names":["makeUrlParser","pattern","parser","pathToRegex","pathname","initialize_route_matchers","routes","route","_extends","n","e","t","r","Action","readOnly","obj","warning","cond","message","BeforeUnloadEventType","PopStateEventType","createBrowserHistory","options","_options","_options$window","window","globalHistory","getIndexAndLocation","_window$location","search","hash","state","blockedPopTx","handlePop","blockers","nextAction","_getIndexAndLocation","nextIndex","nextLocation","delta","index","go","applyTx","action","_getIndexAndLocation2","location","listeners","createEvents","createHref","to","createPath","getNextLocation","parsePath","createKey","getHistoryStateAndUrl","allowTx","retry","_getIndexAndLocation3","push","_getHistoryStateAndUr","historyState","url","replace","_getHistoryStateAndUr2","history","listener","blocker","unblock","promptBeforeUnload","event","handlers","fn","handler","arg","_ref","_ref$pathname","_ref$search","_ref$hash","path","parsedPath","hashIndex","searchIndex","ROOT","page","urlJoin","parts","part","i","loadRoute","node","base_path","combinedParams","urlParams","query","layouts_paths","layout","view_path","layouts","view","hydrate","RecursiveLoader","error","currentUrl","updateRoute","params","server_loading","update","fetchOptions","FORGE_LOAD_SYMBOL","response","data","MANIFEST_STORE","$","updateManifestStore","bootstrap_events","matchers","a","_a","_b","method","m","queryParams","requires_server_data","_","fullUrl","originalPushState","originalReplaceState","args","result","evt","newUrl","currentPathname","fullPath","middlewares","originalFetch","isInternalRoute","urlObj","initializeFetch","input","init","currentInit","middleware","headers","headersObject","resolve","reject","finalHeaders","key","value","fetch","routing","createApp","application_url","needle"],"mappings":";;;;;AAKO,SAASA,EAAcC,GAAiB;AACvC,QAAAC,IAAS,IAAIC,EAAYF,CAAO;AACtC,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D,EAAO,OAAOD,CAAe,KAAI,CAAC,GAE3C5D,IAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACtD6B,IAAc,OAAO,YAAY7B,EAAU,QAAS,CAAA,KAAK,CAAC,GAC1DD,IAAiB,EAAE,GAAGa,GAAQ,GAAGiB,EAAY;AAC/B,MAAAR,GAAA,GACpBzB,GAAUC,GAAMC,GAAWnF,GAAOoF,GAAea,GAAQiB,CAAW,GACnDP,GAAAxB,GAAWpF,GAAQgJ,CAAO;AAAA,IAAA,OACxC;AACH,cAAQ,IAAI,oDAAoD,GAGhE,OAAO,SAAS,OAAOE;AACvB;AAAA,IAAA;AAAA,EACJ;AAGR;","x_google_ignoreList":[1,2]}
1
+ {"version":3,"file":"client.mjs","sources":["../src/routing/url_parser.ts","../node_modules/@babel/runtime/helpers/esm/extends.js","../node_modules/history/index.js","../src/client/navigation.svelte.ts","../src/routing/manifest/store.svelte.ts","../src/client/events.ts","../src/client/client.ts"],"sourcesContent":["import pathToRegex from 'path-to-regex';\nimport type { IRoute } from '../parser/IRoute';\n\n\n\nexport function makeUrlParser(pattern: string) {\n const parser = new pathToRegex(pattern);\n return (pathname: string) => {\n const result = parser.match(pathname);\n return result || null;\n };\n}\n\n\nexport type UrlMatcher = {\n pattern: string,\n parser: ReturnType<typeof makeUrlParser>\n}\n\nexport function findRoute(pathname:string, routes: UrlMatcher[]) {\n for (const { pattern, parser } of routes) {\n const params = parser(pathname);\n if (params) {\n return { pattern, params };\n }\n }\n return null;\n}\n\n\n\n\n\nexport function initialize_route_matchers(routes: IRoute[]): UrlMatcher[] {\n return routes.map((route: IRoute) => {\n const pattern = route.path;\n const parser = makeUrlParser(pattern);\n return { pattern, parser };\n })\n}\n","function _extends() {\n return _extends = Object.assign ? Object.assign.bind() : function (n) {\n for (var e = 1; e < arguments.length; e++) {\n var t = arguments[e];\n for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);\n }\n return n;\n }, _extends.apply(null, arguments);\n}\nexport { _extends as default };","import _extends from '@babel/runtime/helpers/esm/extends';\n\n/**\r\n * Actions represent the type of change to a location value.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#action\r\n */\nvar Action;\n\n(function (Action) {\n /**\r\n * A POP indicates a change to an arbitrary index in the history stack, such\r\n * as a back or forward navigation. It does not describe the direction of the\r\n * navigation, only that the current index changed.\r\n *\r\n * Note: This is the default action for newly created history objects.\r\n */\n Action[\"Pop\"] = \"POP\";\n /**\r\n * A PUSH indicates a new entry being added to the history stack, such as when\r\n * a link is clicked and a new page loads. When this happens, all subsequent\r\n * entries in the stack are lost.\r\n */\n\n Action[\"Push\"] = \"PUSH\";\n /**\r\n * A REPLACE indicates the entry at the current index in the history stack\r\n * being replaced by a new one.\r\n */\n\n Action[\"Replace\"] = \"REPLACE\";\n})(Action || (Action = {}));\n\nvar readOnly = process.env.NODE_ENV !== \"production\" ? function (obj) {\n return Object.freeze(obj);\n} : function (obj) {\n return obj;\n};\n\nfunction warning(cond, message) {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== 'undefined') console.warn(message);\n\n try {\n // Welcome to debugging history!\n //\n // This error is thrown as a convenience so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message); // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nvar BeforeUnloadEventType = 'beforeunload';\nvar HashChangeEventType = 'hashchange';\nvar PopStateEventType = 'popstate';\n/**\r\n * Browser history stores the location in regular URLs. This is the standard for\r\n * most web apps, but it requires some configuration on the server to ensure you\r\n * serve the same app at multiple URLs.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory\r\n */\n\nfunction createBrowserHistory(options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options = options,\n _options$window = _options.window,\n window = _options$window === void 0 ? document.defaultView : _options$window;\n var globalHistory = window.history;\n\n function getIndexAndLocation() {\n var _window$location = window.location,\n pathname = _window$location.pathname,\n search = _window$location.search,\n hash = _window$location.hash;\n var state = globalHistory.state || {};\n return [state.idx, readOnly({\n pathname: pathname,\n search: search,\n hash: hash,\n state: state.usr || null,\n key: state.key || 'default'\n })];\n }\n\n var blockedPopTx = null;\n\n function handlePop() {\n if (blockedPopTx) {\n blockers.call(blockedPopTx);\n blockedPopTx = null;\n } else {\n var nextAction = Action.Pop;\n\n var _getIndexAndLocation = getIndexAndLocation(),\n nextIndex = _getIndexAndLocation[0],\n nextLocation = _getIndexAndLocation[1];\n\n if (blockers.length) {\n if (nextIndex != null) {\n var delta = index - nextIndex;\n\n if (delta) {\n // Revert the POP\n blockedPopTx = {\n action: nextAction,\n location: nextLocation,\n retry: function retry() {\n go(delta * -1);\n }\n };\n go(delta);\n }\n } else {\n // Trying to POP to a location with no index. We did not create\n // this location, so we can't effectively block the navigation.\n process.env.NODE_ENV !== \"production\" ? warning(false, // TODO: Write up a doc that explains our blocking strategy in\n // detail and link to it here so people can understand better what\n // is going on and how to avoid it.\n \"You are trying to block a POP navigation to a location that was not \" + \"created by the history library. The block will fail silently in \" + \"production, but in general you should do all navigation with the \" + \"history library (instead of using window.history.pushState directly) \" + \"to avoid this situation.\") : void 0;\n }\n } else {\n applyTx(nextAction);\n }\n }\n }\n\n window.addEventListener(PopStateEventType, handlePop);\n var action = Action.Pop;\n\n var _getIndexAndLocation2 = getIndexAndLocation(),\n index = _getIndexAndLocation2[0],\n location = _getIndexAndLocation2[1];\n\n var listeners = createEvents();\n var blockers = createEvents();\n\n if (index == null) {\n index = 0;\n globalHistory.replaceState(_extends({}, globalHistory.state, {\n idx: index\n }), '');\n }\n\n function createHref(to) {\n return typeof to === 'string' ? to : createPath(to);\n } // state defaults to `null` because `window.history.state` does\n\n\n function getNextLocation(to, state) {\n if (state === void 0) {\n state = null;\n }\n\n return readOnly(_extends({\n pathname: location.pathname,\n hash: '',\n search: ''\n }, typeof to === 'string' ? parsePath(to) : to, {\n state: state,\n key: createKey()\n }));\n }\n\n function getHistoryStateAndUrl(nextLocation, index) {\n return [{\n usr: nextLocation.state,\n key: nextLocation.key,\n idx: index\n }, createHref(nextLocation)];\n }\n\n function allowTx(action, location, retry) {\n return !blockers.length || (blockers.call({\n action: action,\n location: location,\n retry: retry\n }), false);\n }\n\n function applyTx(nextAction) {\n action = nextAction;\n\n var _getIndexAndLocation3 = getIndexAndLocation();\n\n index = _getIndexAndLocation3[0];\n location = _getIndexAndLocation3[1];\n listeners.call({\n action: action,\n location: location\n });\n }\n\n function push(to, state) {\n var nextAction = Action.Push;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n push(to, state);\n }\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr = getHistoryStateAndUrl(nextLocation, index + 1),\n historyState = _getHistoryStateAndUr[0],\n url = _getHistoryStateAndUr[1]; // TODO: Support forced reloading\n // try...catch because iOS limits us to 100 pushState calls :/\n\n\n try {\n globalHistory.pushState(historyState, '', url);\n } catch (error) {\n // They are going to lose state here, but there is no real\n // way to warn them about it since the page will refresh...\n window.location.assign(url);\n }\n\n applyTx(nextAction);\n }\n }\n\n function replace(to, state) {\n var nextAction = Action.Replace;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n replace(to, state);\n }\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr2 = getHistoryStateAndUrl(nextLocation, index),\n historyState = _getHistoryStateAndUr2[0],\n url = _getHistoryStateAndUr2[1]; // TODO: Support forced reloading\n\n\n globalHistory.replaceState(historyState, '', url);\n applyTx(nextAction);\n }\n }\n\n function go(delta) {\n globalHistory.go(delta);\n }\n\n var history = {\n get action() {\n return action;\n },\n\n get location() {\n return location;\n },\n\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n back: function back() {\n go(-1);\n },\n forward: function forward() {\n go(1);\n },\n listen: function listen(listener) {\n return listeners.push(listener);\n },\n block: function block(blocker) {\n var unblock = blockers.push(blocker);\n\n if (blockers.length === 1) {\n window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n\n return function () {\n unblock(); // Remove the beforeunload listener so the document may\n // still be salvageable in the pagehide event.\n // See https://html.spec.whatwg.org/#unloading-documents\n\n if (!blockers.length) {\n window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n };\n }\n };\n return history;\n}\n/**\r\n * Hash history stores the location in window.location.hash. This makes it ideal\r\n * for situations where you don't want to send the location to the server for\r\n * some reason, either because you do cannot configure it or the URL space is\r\n * reserved for something else.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory\r\n */\n\nfunction createHashHistory(options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options2 = options,\n _options2$window = _options2.window,\n window = _options2$window === void 0 ? document.defaultView : _options2$window;\n var globalHistory = window.history;\n\n function getIndexAndLocation() {\n var _parsePath = parsePath(window.location.hash.substr(1)),\n _parsePath$pathname = _parsePath.pathname,\n pathname = _parsePath$pathname === void 0 ? '/' : _parsePath$pathname,\n _parsePath$search = _parsePath.search,\n search = _parsePath$search === void 0 ? '' : _parsePath$search,\n _parsePath$hash = _parsePath.hash,\n hash = _parsePath$hash === void 0 ? '' : _parsePath$hash;\n\n var state = globalHistory.state || {};\n return [state.idx, readOnly({\n pathname: pathname,\n search: search,\n hash: hash,\n state: state.usr || null,\n key: state.key || 'default'\n })];\n }\n\n var blockedPopTx = null;\n\n function handlePop() {\n if (blockedPopTx) {\n blockers.call(blockedPopTx);\n blockedPopTx = null;\n } else {\n var nextAction = Action.Pop;\n\n var _getIndexAndLocation4 = getIndexAndLocation(),\n nextIndex = _getIndexAndLocation4[0],\n nextLocation = _getIndexAndLocation4[1];\n\n if (blockers.length) {\n if (nextIndex != null) {\n var delta = index - nextIndex;\n\n if (delta) {\n // Revert the POP\n blockedPopTx = {\n action: nextAction,\n location: nextLocation,\n retry: function retry() {\n go(delta * -1);\n }\n };\n go(delta);\n }\n } else {\n // Trying to POP to a location with no index. We did not create\n // this location, so we can't effectively block the navigation.\n process.env.NODE_ENV !== \"production\" ? warning(false, // TODO: Write up a doc that explains our blocking strategy in\n // detail and link to it here so people can understand better\n // what is going on and how to avoid it.\n \"You are trying to block a POP navigation to a location that was not \" + \"created by the history library. The block will fail silently in \" + \"production, but in general you should do all navigation with the \" + \"history library (instead of using window.history.pushState directly) \" + \"to avoid this situation.\") : void 0;\n }\n } else {\n applyTx(nextAction);\n }\n }\n }\n\n window.addEventListener(PopStateEventType, handlePop); // popstate does not fire on hashchange in IE 11 and old (trident) Edge\n // https://developer.mozilla.org/de/docs/Web/API/Window/popstate_event\n\n window.addEventListener(HashChangeEventType, function () {\n var _getIndexAndLocation5 = getIndexAndLocation(),\n nextLocation = _getIndexAndLocation5[1]; // Ignore extraneous hashchange events.\n\n\n if (createPath(nextLocation) !== createPath(location)) {\n handlePop();\n }\n });\n var action = Action.Pop;\n\n var _getIndexAndLocation6 = getIndexAndLocation(),\n index = _getIndexAndLocation6[0],\n location = _getIndexAndLocation6[1];\n\n var listeners = createEvents();\n var blockers = createEvents();\n\n if (index == null) {\n index = 0;\n globalHistory.replaceState(_extends({}, globalHistory.state, {\n idx: index\n }), '');\n }\n\n function getBaseHref() {\n var base = document.querySelector('base');\n var href = '';\n\n if (base && base.getAttribute('href')) {\n var url = window.location.href;\n var hashIndex = url.indexOf('#');\n href = hashIndex === -1 ? url : url.slice(0, hashIndex);\n }\n\n return href;\n }\n\n function createHref(to) {\n return getBaseHref() + '#' + (typeof to === 'string' ? to : createPath(to));\n }\n\n function getNextLocation(to, state) {\n if (state === void 0) {\n state = null;\n }\n\n return readOnly(_extends({\n pathname: location.pathname,\n hash: '',\n search: ''\n }, typeof to === 'string' ? parsePath(to) : to, {\n state: state,\n key: createKey()\n }));\n }\n\n function getHistoryStateAndUrl(nextLocation, index) {\n return [{\n usr: nextLocation.state,\n key: nextLocation.key,\n idx: index\n }, createHref(nextLocation)];\n }\n\n function allowTx(action, location, retry) {\n return !blockers.length || (blockers.call({\n action: action,\n location: location,\n retry: retry\n }), false);\n }\n\n function applyTx(nextAction) {\n action = nextAction;\n\n var _getIndexAndLocation7 = getIndexAndLocation();\n\n index = _getIndexAndLocation7[0];\n location = _getIndexAndLocation7[1];\n listeners.call({\n action: action,\n location: location\n });\n }\n\n function push(to, state) {\n var nextAction = Action.Push;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n push(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(nextLocation.pathname.charAt(0) === '/', \"Relative pathnames are not supported in hash history.push(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr3 = getHistoryStateAndUrl(nextLocation, index + 1),\n historyState = _getHistoryStateAndUr3[0],\n url = _getHistoryStateAndUr3[1]; // TODO: Support forced reloading\n // try...catch because iOS limits us to 100 pushState calls :/\n\n\n try {\n globalHistory.pushState(historyState, '', url);\n } catch (error) {\n // They are going to lose state here, but there is no real\n // way to warn them about it since the page will refresh...\n window.location.assign(url);\n }\n\n applyTx(nextAction);\n }\n }\n\n function replace(to, state) {\n var nextAction = Action.Replace;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n replace(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(nextLocation.pathname.charAt(0) === '/', \"Relative pathnames are not supported in hash history.replace(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n var _getHistoryStateAndUr4 = getHistoryStateAndUrl(nextLocation, index),\n historyState = _getHistoryStateAndUr4[0],\n url = _getHistoryStateAndUr4[1]; // TODO: Support forced reloading\n\n\n globalHistory.replaceState(historyState, '', url);\n applyTx(nextAction);\n }\n }\n\n function go(delta) {\n globalHistory.go(delta);\n }\n\n var history = {\n get action() {\n return action;\n },\n\n get location() {\n return location;\n },\n\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n back: function back() {\n go(-1);\n },\n forward: function forward() {\n go(1);\n },\n listen: function listen(listener) {\n return listeners.push(listener);\n },\n block: function block(blocker) {\n var unblock = blockers.push(blocker);\n\n if (blockers.length === 1) {\n window.addEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n\n return function () {\n unblock(); // Remove the beforeunload listener so the document may\n // still be salvageable in the pagehide event.\n // See https://html.spec.whatwg.org/#unloading-documents\n\n if (!blockers.length) {\n window.removeEventListener(BeforeUnloadEventType, promptBeforeUnload);\n }\n };\n }\n };\n return history;\n}\n/**\r\n * Memory history stores the current location in memory. It is designed for use\r\n * in stateful non-browser environments like tests and React Native.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#creatememoryhistory\r\n */\n\nfunction createMemoryHistory(options) {\n if (options === void 0) {\n options = {};\n }\n\n var _options3 = options,\n _options3$initialEntr = _options3.initialEntries,\n initialEntries = _options3$initialEntr === void 0 ? ['/'] : _options3$initialEntr,\n initialIndex = _options3.initialIndex;\n var entries = initialEntries.map(function (entry) {\n var location = readOnly(_extends({\n pathname: '/',\n search: '',\n hash: '',\n state: null,\n key: createKey()\n }, typeof entry === 'string' ? parsePath(entry) : entry));\n process.env.NODE_ENV !== \"production\" ? warning(location.pathname.charAt(0) === '/', \"Relative pathnames are not supported in createMemoryHistory({ initialEntries }) (invalid entry: \" + JSON.stringify(entry) + \")\") : void 0;\n return location;\n });\n var index = clamp(initialIndex == null ? entries.length - 1 : initialIndex, 0, entries.length - 1);\n var action = Action.Pop;\n var location = entries[index];\n var listeners = createEvents();\n var blockers = createEvents();\n\n function createHref(to) {\n return typeof to === 'string' ? to : createPath(to);\n }\n\n function getNextLocation(to, state) {\n if (state === void 0) {\n state = null;\n }\n\n return readOnly(_extends({\n pathname: location.pathname,\n search: '',\n hash: ''\n }, typeof to === 'string' ? parsePath(to) : to, {\n state: state,\n key: createKey()\n }));\n }\n\n function allowTx(action, location, retry) {\n return !blockers.length || (blockers.call({\n action: action,\n location: location,\n retry: retry\n }), false);\n }\n\n function applyTx(nextAction, nextLocation) {\n action = nextAction;\n location = nextLocation;\n listeners.call({\n action: action,\n location: location\n });\n }\n\n function push(to, state) {\n var nextAction = Action.Push;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n push(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(location.pathname.charAt(0) === '/', \"Relative pathnames are not supported in memory history.push(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n index += 1;\n entries.splice(index, entries.length, nextLocation);\n applyTx(nextAction, nextLocation);\n }\n }\n\n function replace(to, state) {\n var nextAction = Action.Replace;\n var nextLocation = getNextLocation(to, state);\n\n function retry() {\n replace(to, state);\n }\n\n process.env.NODE_ENV !== \"production\" ? warning(location.pathname.charAt(0) === '/', \"Relative pathnames are not supported in memory history.replace(\" + JSON.stringify(to) + \")\") : void 0;\n\n if (allowTx(nextAction, nextLocation, retry)) {\n entries[index] = nextLocation;\n applyTx(nextAction, nextLocation);\n }\n }\n\n function go(delta) {\n var nextIndex = clamp(index + delta, 0, entries.length - 1);\n var nextAction = Action.Pop;\n var nextLocation = entries[nextIndex];\n\n function retry() {\n go(delta);\n }\n\n if (allowTx(nextAction, nextLocation, retry)) {\n index = nextIndex;\n applyTx(nextAction, nextLocation);\n }\n }\n\n var history = {\n get index() {\n return index;\n },\n\n get action() {\n return action;\n },\n\n get location() {\n return location;\n },\n\n createHref: createHref,\n push: push,\n replace: replace,\n go: go,\n back: function back() {\n go(-1);\n },\n forward: function forward() {\n go(1);\n },\n listen: function listen(listener) {\n return listeners.push(listener);\n },\n block: function block(blocker) {\n return blockers.push(blocker);\n }\n };\n return history;\n} ////////////////////////////////////////////////////////////////////////////////\n// UTILS\n////////////////////////////////////////////////////////////////////////////////\n\nfunction clamp(n, lowerBound, upperBound) {\n return Math.min(Math.max(n, lowerBound), upperBound);\n}\n\nfunction promptBeforeUnload(event) {\n // Cancel the event.\n event.preventDefault(); // Chrome (and legacy IE) requires returnValue to be set.\n\n event.returnValue = '';\n}\n\nfunction createEvents() {\n var handlers = [];\n return {\n get length() {\n return handlers.length;\n },\n\n push: function push(fn) {\n handlers.push(fn);\n return function () {\n handlers = handlers.filter(function (handler) {\n return handler !== fn;\n });\n };\n },\n call: function call(arg) {\n handlers.forEach(function (fn) {\n return fn && fn(arg);\n });\n }\n };\n}\n\nfunction createKey() {\n return Math.random().toString(36).substr(2, 8);\n}\n/**\r\n * Creates a string URL path from the given pathname, search, and hash components.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createpath\r\n */\n\n\nfunction createPath(_ref) {\n var _ref$pathname = _ref.pathname,\n pathname = _ref$pathname === void 0 ? '/' : _ref$pathname,\n _ref$search = _ref.search,\n search = _ref$search === void 0 ? '' : _ref$search,\n _ref$hash = _ref.hash,\n hash = _ref$hash === void 0 ? '' : _ref$hash;\n if (search && search !== '?') pathname += search.charAt(0) === '?' ? search : '?' + search;\n if (hash && hash !== '#') pathname += hash.charAt(0) === '#' ? hash : '#' + hash;\n return pathname;\n}\n/**\r\n * Parses a string URL path into its separate pathname, search, and hash components.\r\n *\r\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#parsepath\r\n */\n\nfunction parsePath(path) {\n var parsedPath = {};\n\n if (path) {\n var hashIndex = path.indexOf('#');\n\n if (hashIndex >= 0) {\n parsedPath.hash = path.substr(hashIndex);\n path = path.substr(0, hashIndex);\n }\n\n var searchIndex = path.indexOf('?');\n\n if (searchIndex >= 0) {\n parsedPath.search = path.substr(searchIndex);\n path = path.substr(0, searchIndex);\n }\n\n if (path) {\n parsedPath.pathname = path;\n }\n }\n\n return parsedPath;\n}\n\nexport { Action, createBrowserHistory, createHashHistory, createMemoryHistory, createPath, parsePath };\n//# sourceMappingURL=index.js.map\n","\nimport type { IRoute } from '../parser/IRoute'\nimport { hydrate } from 'svelte'\nimport RecursiveLoader from '../components/RecursiveRender.svelte'\nimport { createBrowserHistory } from 'history';\nimport { FORGE_LOAD_SYMBOL } from './client';\nimport {page} from \"./page.svelte\";\n\nconst history = createBrowserHistory()\n\nconst ROOT = $state({\n layouts: [] as any[],\n view: null,\n data: null as any,\n params: null,\n urlParams: null as any,\n query: null as any,\n page\n})\n\nfunction urlJoin(...parts) {\n let url = parts\n .map((part, i) => {\n if (i === 0) return part.replace(/\\/+$/, ''); // trim trailing slash\n return part.replace(/^\\/+|\\/+$/g, ''); // trim both for middle parts\n })\n .join('/');\n\n if (!url.startsWith('/')) {\n url = '/' + url; // add leading slash if not present\n }\n return url.split('?')[0]; // remove query string\n}\n\nexport async function loadRoute(node:any,base_path:string, route: IRoute, combinedParams: any, urlParams:any, query:any) {\n try {\n // When serving precompiled client bundles (dist/client), resolve to .js files\n const useCompiledClient = typeof base_path === 'string' && base_path.indexOf('dist/client') !== -1;\n\n const layouts_paths = (route.layout || []).map(layout => {\n let p = urlJoin(base_path,layout).toString();\n if (useCompiledClient) {\n p = p.endsWith('.svelte') ? p.replace(/\\.svelte$/, '.js') : (/[.][a-z]+$/.test(p) ? p : p + '.js');\n }\n return p;\n })\n let view_path = urlJoin(base_path,route.view).toString()\n if (useCompiledClient) {\n view_path = view_path.endsWith('.svelte') ? view_path.replace(/\\.svelte$/, '.js') : (/[.][a-z]+$/.test(view_path) ? view_path : view_path + '.js');\n }\n\n console.log({layouts_paths,view_path})\n\n const layouts = await Promise.all(layouts_paths.map((layout) => {\n return import(/* @vite-ignore */ layout).then(layout => {\n return layout.default\n })\n }))\n\n if (!view_path.startsWith('/')){\n view_path = '/'+view_path\n }\n const view = await import(/* @vite-ignore */ view_path).then(view => {\n return view.default\n })\n\n ROOT.layouts = layouts\n ROOT.view = view\n ROOT.params = combinedParams\n ROOT.data = (window as any).__INITIAL_DATA__\n ROOT.urlParams = urlParams\n ROOT.query = query\n\n hydrate(RecursiveLoader, {\n target: node,\n props: ROOT,\n })\n } catch (error) {\n console.log('Client-side route loading failed - falling back to SSR navigation');\n console.error('Route loading error:', error);\n // Fallback: Use SSR rendering by triggering a full page load\n const currentUrl = window.location.pathname || '/';\n window.location.href = currentUrl;\n }\n}\n\n\n\nexport async function updateRoute(url:string,base_path:string, route: IRoute, params: any,urlParams:any,query:any,server_loading:boolean = false,update = true) {\n try {\n const useCompiledClient = typeof base_path === 'string' && base_path.indexOf('dist/client') !== -1;\n const layouts_paths = (route.layout || []).map(layout => {\n let p = urlJoin(base_path,layout).toString();\n if (useCompiledClient) {\n p = p.endsWith('.svelte') ? p.replace(/\\.svelte$/, '.js') : (/[.][a-z]+$/.test(p) ? p : p + '.js');\n }\n return p;\n })\n let view_path = urlJoin(base_path,route.view).toString()\n if (useCompiledClient) {\n view_path = view_path.endsWith('.svelte') ? view_path.replace(/\\.svelte$/, '.js') : (/[.][a-z]+$/.test(view_path) ? view_path : view_path + '.js');\n }\n const layouts = await Promise.all(layouts_paths.map((layout) => {\n return import(/* @vite-ignore */ layout).then(layout => {\n return layout.default\n })\n }))\n const view = await import(/* @vite-ignore */ view_path).then(view => {\n return view.default\n })\n\n if (server_loading) {\n const fetchOptions: any = {\n method: route.method,\n headers: {\n 'Content-Type': 'application/json',\n 'Accept': 'application/json'\n }\n };\n fetchOptions[FORGE_LOAD_SYMBOL] = true;\n \n await fetch(url, fetchOptions).then((response) => {\n if (response.ok) {\n return response.json()\n } else {\n throw new Error('Network response was not ok')\n }\n }).then((data)=>{\n \n console.log('Server data',data)\n // The server returns structured data: { layout: [...], view: {...} }\n // We need to pass this structure to RecursiveRender correctly\n ROOT.data = data\n ROOT.params = params\n ROOT.layouts = layouts\n ROOT.view = view\n ROOT.urlParams = urlParams\n ROOT.query = query\n })\n }else{\n ROOT.data = {layout:[],view:{}}\n ROOT.params = params\n ROOT.layouts = layouts\n ROOT.view = view\n ROOT.urlParams = urlParams\n ROOT.query = query\n }\n if(window){\n window.scroll(0,0)\n }\n\n if(update){\n history.push(url)\n }\n } catch (error) {\n console.log('Client-side navigation failed for URL:', url, '- falling back to SSR navigation');\n console.error('Navigation error:', error);\n // Fallback: Use SSR rendering by triggering a full page load\n // window.location.href = url;\n }\n}\n","\n\n\nexport const MANIFEST_STORE = $state({})\n\n\n\nexport async function updateManifestStore() {\n Object.assign(MANIFEST_STORE, window['__MANIFEST__'])\n // await fetch('/manifest.json')\n // .then(async (response) => {\n // if (response.ok) {\n // const manifest = await response.json();\n // console.log(manifest)\n // Object.assign(MANIFEST_STORE, manifest);\n // }\n // })\n}","\n\nimport type {IRoute} from \"../parser/IRoute\";\nimport type { UrlMatcher } from \"../routing/url_parser\";\nimport { updateRoute } from \"./navigation.svelte\";\nimport { MANIFEST_STORE } from \"../routing/manifest/store.svelte\";\nimport {page} from './page.svelte'\n\n\n\n\nexport function bootstrap_events(base_path:string,routes:IRoute[], matchers: UrlMatcher[]) {\n if(!document){\n console.error('Document not found')\n return\n }\n\n document.addEventListener('click', (event:any) => {\n const currentUrl = window.location.pathname;\n const a = event.target?.tagName === 'A' ? event.target : event.target?.closest('A');\n \n if (a) {\n let url = a.getAttribute('href');\n if (currentUrl === url) {\n event.preventDefault();\n return;\n }\n if (url && url.startsWith('/') || url.startsWith('.')) {\n const pathname = url.split('?')[0];\n const method = a.getAttribute('method') || 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(pathname) && m.pattern === r.path));\n if (route) {\n event.preventDefault();\n const m = matchers.find(m => m.parser(pathname) && m.pattern === route.path);\n const params = m?.parser(pathname) || {};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(url.split('?')[1] || '');\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(url,base_path, route, combinedParams,params,queryParams,requires_server_data);\n } else {\n console.log('No matching route found for URL:', url, '- using fallback navigation');\n // Fallback: Don't prevent default, let browser handle the navigation\n // This will trigger a full page load that the server can handle\n }\n }\n }\n });\n\n\n window.addEventListener('popstate', (_) => {\n const path = window.location.pathname;\n const fullUrl = window.location.pathname + window.location.search;\n // update page data\n page.url = fullUrl\n page.pathname = window.location.pathname\n const method = 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(path) && m.pattern === r.path));\n if (route) {\n const m = matchers.find(m => m.parser(path) && m.pattern === route.path);\n const params = m?.parser(path) || {};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(window.location.search);\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n\n // Object.assign(page.params,params)\n page.params = params\n page.query = queryParams\n\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(fullUrl,base_path, route, combinedParams,params,queryParams,requires_server_data,false);\n } else {\n console.log('No matching route found for popstate navigation to:', path, '- using fallback navigation');\n // Fallback: Trigger full page reload for unknown routes\n window.location.href = path;\n }\n });\n\n\n // Run this once in your bootstrap code\n (function () {\n const originalPushState = history.pushState;\n const originalReplaceState = history.replaceState;\n\n history.pushState = function (...args) {\n const result = originalPushState.apply(this, args);\n const evt= new Event('pushstate')\n evt['state'] = args[0]\n evt['url'] = args[2]\n window.dispatchEvent(evt);\n return result;\n };\n\n\n history.replaceState = function (...args) {\n const result = originalReplaceState.apply(this, args);\n \n // Only trigger navigation if pathname actually changes\n const newUrl = args[2];\n const currentPathname = window.location.pathname;\n const newPathname = newUrl ? new URL(newUrl, window.location.origin).pathname : currentPathname;\n \n if (newPathname !== currentPathname) {\n const evt= new Event('replacestate')\n evt['state'] = args[0]\n evt['url'] = args[2]\n window.dispatchEvent(evt);\n }\n \n return result;\n }\n // Add a listener to the popstate event\n })();\n\n window.addEventListener('pushstate', (event) => {\n const fullPath = event['url'] || window.location.pathname + window.location.search;\n const path = fullPath.split('?')[0];\n const method = 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(path) && m.pattern === r.path));\n if (route) {\n const m = matchers.find(m => m.parser(path) && m.pattern === route.path);\n const params = m?.parser(path);\n\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(fullPath.split('?')[1] || '');\n const queryParams = Object.fromEntries(urlParams.entries());\n \n page.url = fullPath\n page.pathname = window.location.pathname\n Object.assign(page.params,params)\n Object.assign(page.query,queryParams)\n\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(fullPath,base_path, route, combinedParams,params,queryParams,requires_server_data,false);\n } else {\n console.log('No matching route found for pushstate to:', path, '- using fallback navigation');\n // Fallback: Use full page navigation for unknown routes\n window.location.href = path;\n }\n });\n\n window.addEventListener('replacestate', (event) => {\n const fullPath = event['url'] || window.location.pathname + window.location.search;\n const path = fullPath.split('?')[0];\n\n // update page data\n page.url = fullPath\n page.pathname = window.location.pathname\n page.query = Object.fromEntries(new URLSearchParams(fullPath.split('?')[1] || ''))\n\n const method = 'get';\n const route = routes.find(r => r.method.toLowerCase() === method && matchers.find(m => m.parser(path) && m.pattern === r.path));\n if (route) {\n const m = matchers.find(m => m.parser(path) && m.pattern === route.path);\n const params = m?.parser(path) || {};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(fullPath.split('?')[1] || '');\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n const combinedParams = { ...params, ...queryParams };\n const requires_server_data = MANIFEST_STORE[m?.pattern as string]\n updateRoute(fullPath,base_path, route, combinedParams,params,queryParams,requires_server_data,false);\n } else {\n console.log('No matching route found for replacestate to:', path, '- using fallback navigation');\n // Fallback: Use full page navigation for unknown routes\n window.location.href = path;\n }\n });\n \n}\n","import { initialize_route_matchers } from '../routing/url_parser';\nimport { loadRoute } from './navigation.svelte';\nimport { bootstrap_events } from './events';\nimport { updateManifestStore } from '../routing/manifest/store.svelte';\nimport type { ServerOptions } from '../options/ServerOptions';\nimport type { FetchMiddleware, FetchMiddlewareAPI, HeadersObject, AsyncMiddleware, CallbackMiddleware } from '../types/FetchMiddleware';\n\n// Symbol for marking load function fetches\nexport const FORGE_LOAD_SYMBOL = Symbol('forge-load-function');\n\n// Middleware storage\nlet middlewares: Array<FetchMiddleware> = [];\nlet originalFetch: typeof window.fetch | null = null;\n\n// Helper to determine if a URL is an internal route\nfunction isInternalRoute(url: string): boolean {\n try {\n const urlObj = new URL(url, window.location.origin);\n return urlObj.origin === window.location.origin && !urlObj.pathname.startsWith('/api/');\n } catch {\n // Relative URL, assume internal\n return !url.startsWith('/api/');\n }\n}\n\n// Initialize fetch override immediately when module is imported\nfunction initializeFetch(): void {\n if (typeof window !== 'undefined' && !originalFetch) {\n originalFetch = window.fetch;\n\n window.fetch = async function(input: RequestInfo | URL, init: RequestInit = {}): Promise<Response> {\n console.log('🔵 Enhanced fetch called for:', input);\n console.log('🔵 Initial init:', init);\n\n // Start with the original init\n let currentInit: RequestInit = { ...init };\n\n // Run all configured middleware\n for (const middleware of middlewares) {\n try {\n if (middleware.length === 2) {\n // Callback style (legacy): (headers, next) => {}\n // Convert headers for middleware\n const headers = new Headers(currentInit.headers);\n const headersObject: HeadersObject = Object.fromEntries(headers.entries());\n\n console.log('🟡 Running callback-style middleware (length=2)');\n await new Promise<void>((resolve, reject) => {\n try {\n (middleware as any)(headersObject, (error?: any) => {\n if (error) {\n reject(error);\n } else {\n // Convert headers back\n const finalHeaders = new Headers();\n Object.entries(headersObject).forEach(([key, value]) => {\n if (value !== undefined) {\n finalHeaders.set(key, value);\n }\n });\n currentInit.headers = finalHeaders;\n resolve();\n }\n });\n } catch (error) {\n reject(error);\n }\n });\n } else {\n // New style middleware (returns RequestInit)\n console.log('🟡 Running new-style RequestInit middleware (length=' + middleware.length + ')');\n const result = await (middleware as any)(currentInit, input);\n\n if (result && typeof result === 'object') {\n // Middleware returned a value - use it as new RequestInit\n console.log('🟢 Middleware returned RequestInit:', result);\n currentInit = result;\n } else {\n console.log('🟢 Middleware returned:', result);\n }\n }\n } catch (error) {\n console.error('🔴 Middleware error:', error);\n throw error;\n }\n }\n\n console.log('🟢 Final init after middleware:', currentInit);\n\n // Make the actual request\n const response = await originalFetch!(input, currentInit);\n\n // Handle frontend route redirects\n if (response.status >= 300 && response.status < 400 && (init as any)[FORGE_LOAD_SYMBOL]) {\n const location = response.headers.get('location');\n if (location && isInternalRoute(location)) {\n // For internal routes, let the browser handle the redirect\n window.location.href = location;\n return response;\n }\n }\n\n return response;\n };\n }\n}\n\n// Initialize fetch override immediately\ninitializeFetch();\n\n// Export fetch API with middleware configuration\nexport const fetch: FetchMiddlewareAPI & { getMiddlewareCount(): number } = {\n /**\n * Add middleware to the fetch pipeline\n */\n configUpdate(middleware: FetchMiddleware): void {\n if (typeof middleware !== 'function') {\n throw new Error('Middleware must be a function');\n }\n middlewares.push(middleware);\n },\n \n /**\n * Reset all middleware\n */\n reset(): void {\n middlewares.length = 0;\n },\n \n /**\n * Get current middleware count (for debugging)\n */\n getMiddlewareCount(): number {\n return middlewares.length;\n }\n};\n\nlet routing;\n\nexport async function createApp<T extends HTMLElement = HTMLElement>(\n node: T,\n options: ServerOptions\n): Promise<void> {\n\n let base_path = options.component_dir\n\n if(!base_path && typeof base_path !== 'string') {\n throw new Error('No component directory provided');\n }\n let routes = window['__ROUTING__']\n routing = initialize_route_matchers(routes)\n\n if (window && window.location) {\n const application_url = (window.location.pathname || '/').split('?')[0];\n console.log(`Current pathname: ${application_url}`);\n const needle = routing.find(r => r.parser(application_url));\n let route = needle ? routes.find(r => r.path === needle.pattern) : null;\n if (needle && route) {\n console.log(`Found route:`, route);\n const params = needle.parser(application_url) ||{};\n // Parse query parameters and combine with path parameters\n const urlParams = new URLSearchParams(window.location.search);\n const queryParams = Object.fromEntries(urlParams.entries()) || {};\n const combinedParams = { ...params, ...queryParams };\n updateManifestStore()\n loadRoute(node, base_path, route, combinedParams,params, queryParams);\n bootstrap_events(base_path, routes, routing);\n } else {\n console.log('No matching route found, using fallback navigation');\n // Fallback: Use window.location.href to navigate to the current URL\n // This will trigger a full page load, allowing the server to handle the route\n window.location.href = application_url;\n return; // Exit early since we're doing a full page navigation\n }\n\n }\n}\n\n\n"],"names":["makeUrlParser","pattern","parser","pathToRegex","pathname","initialize_route_matchers","routes","route","_extends","n","e","t","r","Action","readOnly","obj","warning","cond","message","BeforeUnloadEventType","PopStateEventType","createBrowserHistory","options","_options","_options$window","window","globalHistory","getIndexAndLocation","_window$location","search","hash","state","blockedPopTx","handlePop","blockers","nextAction","_getIndexAndLocation","nextIndex","nextLocation","delta","index","go","applyTx","action","_getIndexAndLocation2","location","listeners","createEvents","createHref","to","createPath","getNextLocation","parsePath","createKey","getHistoryStateAndUrl","allowTx","retry","_getIndexAndLocation3","push","_getHistoryStateAndUr","historyState","url","replace","_getHistoryStateAndUr2","history","listener","blocker","unblock","promptBeforeUnload","event","handlers","fn","handler","arg","_ref","_ref$pathname","_ref$search","_ref$hash","path","parsedPath","hashIndex","searchIndex","ROOT","page","urlJoin","parts","part","i","loadRoute","node","base_path","combinedParams","urlParams","query","useCompiledClient","layouts_paths","layout","p","view_path","layouts","view","hydrate","RecursiveLoader","error","currentUrl","updateRoute","params","server_loading","update","fetchOptions","FORGE_LOAD_SYMBOL","response","data","MANIFEST_STORE","$","updateManifestStore","bootstrap_events","matchers","a","_a","_b","method","m","queryParams","requires_server_data","_","fullUrl","originalPushState","originalReplaceState","args","result","evt","newUrl","currentPathname","fullPath","middlewares","originalFetch","isInternalRoute","urlObj","initializeFetch","input","init","currentInit","middleware","headers","headersObject","resolve","reject","finalHeaders","key","value","fetch","routing","createApp","application_url","needle"],"mappings":";;;;;AAKO,SAASA,EAAcC,GAAiB;AACvC,QAAAC,IAAS,IAAIC,EAAYF,CAAO;AACtC,SAAO,CAACG,MACSF,EAAO,MAAME,CAAQ,KACnB;AAErB;AAsBO,SAASC,EAA0BC,GAAgC;AACjE,SAAAA,EAAO,IAAI,CAACC,MAAkB;AACnC,UAAMN,IAAUM,EAAM,MAChBL,IAASF,EAAcC,CAAO;AAC7B,WAAA,EAAE,SAAAA,GAAS,QAAAC,EAAO;AAAA,EAAA,CAC1B;AACH;ACvCA,SAASM,IAAW;AAClB,SAAOA,IAAW,OAAO,SAAS,OAAO,OAAO,KAAI,IAAK,SAAUC,GAAG;A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OAAO,SAAS,YAAY,KAAK,MAAM,GAAG,EAAE,CAAC;AAC9D,YAAA,IAAI,qBAAqBA,CAAe,EAAE;AAClD,UAAMC,IAASH,EAAQ,KAAK,OAAK5I,EAAE,OAAO8I,CAAe,CAAC;AACtD,QAAAnJ,IAAQoJ,IAASrJ,EAAO,KAAK,OAAKM,EAAE,SAAS+I,EAAO,OAAO,IAAI;AACnE,QAAIA,KAAUpJ,GAAO;AACT,cAAA,IAAI,gBAAgBA,CAAK;AACjC,YAAMmG,IAASiD,EAAO,OAAOD,CAAe,KAAI,CAAC,GAE3C9D,IAAY,IAAI,gBAAgB,OAAO,SAAS,MAAM,GACtD+B,IAAc,OAAO,YAAY/B,EAAU,QAAS,CAAA,KAAK,CAAC,GAC1DD,IAAiB,EAAE,GAAGe,GAAQ,GAAGiB,EAAY;AAC/B,MAAAR,GAAA,GACpB3B,GAAUC,GAAMC,GAAWnF,GAAOoF,GAAee,GAAQiB,CAAW,GACnDP,GAAA1B,GAAWpF,GAAQkJ,CAAO;AAAA,IAAA,OACxC;AACH,cAAQ,IAAI,oDAAoD,GAGhE,OAAO,SAAS,OAAOE;AACvB;AAAA,IAAA;AAAA,EACJ;AAGR;","x_google_ignoreList":[1,2]}
@@ -634,7 +634,7 @@ function initialize_route_matchers(routes) {
634
634
  class ServerAdapter {
635
635
  }
636
636
  class ExpressServerAdapter extends ServerAdapter {
637
- constructor(server2, manager, htmlRender, api_adapter, middleware_adapter, context_builder) {
637
+ constructor(server2, manager, htmlRender, api_adapter, middleware_adapter, context_builder, isProd = false) {
638
638
  super();
639
639
  this.server = server2;
640
640
  this.manager = manager;
@@ -642,6 +642,22 @@ class ExpressServerAdapter extends ServerAdapter {
642
642
  this.api_adapter = api_adapter;
643
643
  this.middleware_adapter = middleware_adapter;
644
644
  this.context_builder = context_builder;
645
+ this.isProd = isProd;
646
+ }
647
+ transformRoutesForClient(routes) {
648
+ var _a, _b;
649
+ if (!this.isProd) return routes;
650
+ console.log(`[transformRoutesForClient] Transforming ${routes.length} routes for production`);
651
+ const transformed = routes.map((route) => {
652
+ var _a2, _b2;
653
+ return {
654
+ ...route,
655
+ layout: (_a2 = route.layout) == null ? void 0 : _a2.map((path2) => path2.replace(/\.svelte$/, ".js")),
656
+ view: (_b2 = route.view) == null ? void 0 : _b2.replace(/\.svelte$/, ".js")
657
+ };
658
+ });
659
+ console.log(`[transformRoutesForClient] First route view transformed: ${(_a = routes[0]) == null ? void 0 : _a.view} → ${(_b = transformed[0]) == null ? void 0 : _b.view}`);
660
+ return transformed;
645
661
  }
646
662
  async handleRoutes(routes, manifest) {
647
663
  const matchers = initialize_route_matchers(routes);
@@ -765,7 +781,7 @@ ${e.stack}</pre>
765
781
  });
766
782
  const head_routing = `
767
783
  <script type='text/javascript'>
768
- window.__ROUTING__ = ${JSON.stringify(routes)}
784
+ window.__ROUTING__ = ${JSON.stringify(this.transformRoutesForClient(routes))}
769
785
  <\/script>
770
786
 
771
787
  <script type='text/javascript'>
@@ -857,7 +873,7 @@ async function createServer(app, options) {
857
873
  const full_options = deepmerge(defaultOptions, options);
858
874
  full_options.open_api_path = ensureFullPath(full_options.viteOptions.root, full_options.open_api_path);
859
875
  const isProd = full_options.development === false;
860
- console.log(`Running in ${isProd ? "production" : "development"} mode`);
876
+ console.log(`Running in ${isProd ? "production" : "development"} mode (development flag: ${full_options.development}, NODE_ENV: ${process.env.NODE_ENV})`);
861
877
  const COMPONENT_DIR = !full_options.component_dir ? full_options.viteOptions.root : path.join(full_options.viteOptions.root, full_options.component_dir);
862
878
  const root = full_options.viteOptions.root;
863
879
  let componentLoader;
@@ -908,7 +924,8 @@ ${JSON.stringify(options, null, 2)}`);
908
924
  htmlRenderer,
909
925
  api_adapter,
910
926
  middleware_adapter,
911
- full_options.context_builder
927
+ full_options.context_builder,
928
+ isProd
912
929
  );
913
930
  await adapter.handleRoutes(routeDefs, manifest);
914
931
  console.log("Routes registered");