@noego/forge 0.1.25 → 0.1.28

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.
Files changed (35) hide show
  1. package/README.md +18 -1
  2. package/dist/client.cjs +2 -2
  3. package/dist/client.cjs.map +1 -1
  4. package/dist/client.d.ts +30 -1
  5. package/dist/client.mjs +756 -728
  6. package/dist/client.mjs.map +1 -1
  7. package/dist/options/ServerOptions.cjs.map +1 -1
  8. package/dist/options/ServerOptions.d.ts +3 -0
  9. package/dist/options/ServerOptions.mjs.map +1 -1
  10. package/dist/page.svelte-4uv4nQ2i.js.map +1 -1
  11. package/dist/page.svelte-CW8PJDdH.cjs.map +1 -1
  12. package/dist/plugins-cjs/options/ServerOptions.js.map +1 -1
  13. package/dist/plugins-es/options/ServerOptions.d.ts +3 -0
  14. package/dist/plugins-es/options/ServerOptions.js.map +1 -1
  15. package/dist-ssr/{path-BqcF5dbs.js → path-2bYzpvRB.js} +3 -1
  16. package/dist-ssr/{path-BqcF5dbs.js.map → path-2bYzpvRB.js.map} +1 -1
  17. package/dist-ssr/{path-sxXxpB6R.cjs → path-DCxJMpj7.cjs} +3 -1
  18. package/dist-ssr/{path-sxXxpB6R.cjs.map → path-DCxJMpj7.cjs.map} +1 -1
  19. package/dist-ssr/server.cjs +4 -3
  20. package/dist-ssr/server.cjs.map +1 -1
  21. package/dist-ssr/server.d.ts +4 -0
  22. package/dist-ssr/server.js +4 -3
  23. package/dist-ssr/server.js.map +1 -1
  24. package/dist-ssr/shared.cjs +1 -1
  25. package/dist-ssr/shared.js +1 -1
  26. package/dist-ssr/static.cjs +1 -1
  27. package/dist-ssr/static.d.ts +1 -0
  28. package/dist-ssr/static.js +1 -1
  29. package/dist-ssr/test.d.ts +1 -0
  30. package/dist-ssr/{url_parser-BX00zzMP.js → url_parser-B6dvK0DX.js} +2 -2
  31. package/dist-ssr/{url_parser-BX00zzMP.js.map → url_parser-B6dvK0DX.js.map} +1 -1
  32. package/dist-ssr/{url_parser-Dipo_fiS.cjs → url_parser-D7ZqJUTw.cjs} +2 -2
  33. package/dist-ssr/{url_parser-Dipo_fiS.cjs.map → url_parser-D7ZqJUTw.cjs.map} +1 -1
  34. package/package.json +1 -1
  35. package/src/components/RecursiveRender.svelte +37 -16
@@ -1 +1 @@
1
- {"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAmBF,QAAA,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEW,QAAA,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,0BAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
1
+ {"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAsBF,QAAA,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEW,QAAA,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,0BAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
@@ -3,6 +3,7 @@ import type { ForgeAssets } from './assets';
3
3
  export { assets } from './assets';
4
4
  export type htmlRenderer = 'default' | string | IHTMLRender;
5
5
  export type ContextBuilder = (req: any, res: any) => Record<string, any>;
6
+ export type ControllerFactory = (controllerClass: new (...args: any[]) => any) => Promise<unknown> | unknown;
6
7
  export interface ServerOptions {
7
8
  development?: boolean;
8
9
  viteOptions?: any;
@@ -15,6 +16,8 @@ export interface ServerOptions {
15
16
  assets?: ForgeAssets;
16
17
  context_builder?: ContextBuilder;
17
18
  middleware_path?: string;
19
+ /** Optional PageController factory used by the client for each page/layout/controller instantiation. */
20
+ controller_factory?: ControllerFactory;
18
21
  }
19
22
  export declare const defaultViteOptions: any;
20
23
  export declare const defaultOptions: ServerOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAmBlC,MAAM,CAAC,MAAM,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,kBAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
1
+ {"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAsBlC,MAAM,CAAC,MAAM,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,kBAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"page.svelte-4uv4nQ2i.js","sources":["../node_modules/path-to-regex/index.js","../src/parser/path.ts","../src/client/page.svelte.ts"],"sourcesContent":["module.exports = Regex;\n\nif (typeof window !== 'undefined') {\n\twindow.pathToRegex = Regex;\n}\n\nconst escapeRe = /([$.+*?=!:[\\]{}(|)/\\\\])/g;\n\n/**\n * defaultParam - simplistic polyfill for default function parament\n * @param {any} [obj]\n * @param {any} defaultValue\n * @return {any}\n */\nfunction defaultParam(obj, defaultValue) {\n\treturn typeof obj !== 'undefined' ? obj : defaultValue;\n}\n\n/**\n * Класс Regex [description].\n * @constructor\n * @param {Object} options [description].\n */\nfunction Regex(path, options) {\n\tthis.init(path, options);\n\treturn this;\n}\n\nRegex.prototype.init = function (\n\tpath = \"/\",\n\toptions = {}\n) {\n\tthis.options = {\n\t\tcase: typeof options.case === \"boolean\" ? options.case : true,\n\t\tseparators: typeof options.separators === \"string\" ? options.separators : \"/\",\n\t\tfromStart: typeof options.fromStart === \"boolean\" ? options.fromStart : true,\n\t\ttoEnd: typeof options.toEnd === \"boolean\" ? options.toEnd : true\n\t};\n\tthis.options.separator = \"[\" + this.escape(this.options.separators) + \"]\";\n\n\tif (path instanceof RegExp) {\n\t\tthis.restructureRegExp(path);\n\t} else if (typeof path === \"string\") {\n\t\tthis.restructurePath(path);\n\t}\n};\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructureRegExp = function (regexp) {\n\tregexp = defaultParam(regexp, /.*/);\n\tthis.keys = [];\n\tthis.path = undefined;\n\tthis.regstr = (\"\" + regexp);\n\tthis.regstr = this.regstr.substr(1, this.regstr.length - 2);\n\tthis.regexp = new RegExp(\n\t\tthis.regstr,\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n\n}\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructurePath = function (path) {\n\tpath = defaultParam(path, '/');\n\tthis.keys = [];\n\tthis.path = path;\n\tthis.regstr = \"\";\n\n\tconst separator = this.options.separator;\n\tconst notseparator = \"[^\" + this.escape(this.options.separators) + \"]\";\n\n\tlet offset = 0;\n\tlet count = 0;\n\t// 11. REGEXP toEnd[true]: /^[\\/]?foo\\/(.*?)[\\/]?$/\n\t// 11. REGEXP toEnd[false]: /^[\\/]?foo\\/(.*?)([\\/]|[\\/]?$)/i\n\n\tpath = path.replace(new RegExp(\"^\" + separator + \"*(.*?)\" + separator + \"*$\"), \"$1\");\n\t//path += this.options.separators[0];\n\n\tpath.replace(/:([a-z]\\w*)(\\((.*?)\\))?([\\?\\*\\+])?/gi, (str, key, a, pat, quant, index, string) => {\n\t\t// console.log(\"-----------------------------\");\n\t\t// console.log(\"str:\", str);\n\t\t// console.log(\"key:\", key);\n\t\t// console.log(\"a:\", a);\n\t\t// console.log(\"pat:\", pat);\n\t\t// console.log(\"quant:\", quant);\n\t\t// console.log(\"index:\", index);\n\t\t// console.log(\"string:\", string);\n\t\tcount++;\n\n\n\n\t\tconst isMultiple = (quant === \"*\" || quant === \"+\") ? true : false;\n\t\tconst isExtrude = /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\+\\*]$/.test(pat) ? true : false;\n\n\t\tlet isRequired = (quant !== \"*\" && quant !== \"?\") ? true : false;\n\t\tif (!quant && pat && /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\*\\?]?$/.test(pat)) isRequired = false;\n\n\t\tconst quantifier = quant ? quant : \"\";\n\t\t// console.log(\"isMultiple\", isMultiple);\n\t\t// console.log(\"isRequired\", isRequired);\n\n\t\t// const startChar = path.charAt(index-1);\n\t\tconst isStarted = (!index) ? true : this.separator(path.charAt(index - 1));\n\t\tconst isStoped = (index + str.length >= path.length) ? true : this.separator(path.charAt(index + str.length));\n\t\tconst isToken = isStarted && isStoped;\n\n\t\tif (index > offset) {\n\t\t\tconst text = path.substring(offset, index);\n\t\t\tconst regstr = this.escape(text);\n\t\t\tthis.regstr += regstr;\n\t\t}\n\n\t\tif (isToken && index) {\n\t\t\tif (!isMultiple || !isRequired) {\n\t\t\t\tif (pat && !isExtrude) {\n\t\t\t\t\tthis.regstr += \"?\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//console.log(\"isStarted\", isStarted);\n\t\t//console.log(\"isStoped\", isStoped);\n\t\t//console.log(\"isToken\", isToken);\n\t\t//console.log(\"this.regstr 1:\", this.regstr);\n\n\t\tconst pattern = (pat ? pat : notseparator + \"+\");\n\n\t\tconst regstr =\n\t\t\tisMultiple ?\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"((?:\" + separator + \"?\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\t\"((?:\" + separator + \"\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\"((?:\" + notseparator + \"*\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"(\" + pattern + \"?)\" + quantifier :\n\t\t\t\t\t\t\"(\" + pattern + \")\" + quantifier :\n\t\t\t\t\t\"(\" + pattern + \")\" + quantifier;\n\n\t\tthis.regstr += regstr;\n\n\t\tconst data = {\n\t\t\tkey: key,\n\t\t\tmultiple: isMultiple,\n\t\t\trequired: isRequired,\n\t\t\tindex: count,\n\t\t\tpattern: pattern\n\t\t};\n\t\tif (isMultiple)\n\t\t\tdata.regexp = new RegExp(pattern, this.options.case ? \"g\" : \"gi\");\n\n\t\tthis.keys.push(data);\n\n\t\toffset = index + str.length;\n\t\treturn str;\n\t});\n\n\tif (offset < path.length - 1) {\n\t\tconst text = path.substring(offset);\n\t\tconst regstr = this.escape(text);\n\t\tthis.regstr += regstr;\n\t}\n\n\tthis.regexp = new RegExp(\n\t\t(this.options.fromStart ? \"^\" : \"\") +\n\t\tseparator + \"?\" +\n\t\tthis.regstr +\n\t\t(this.options.toEnd\n\t\t\t?\n\t\t\tseparator + \"?\" + \"$\"\n\t\t\t:\n\t\t\t\"(\" + separator + \"|\" + separator + \"?\" + \"$\" + \")\"\n\t\t),\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n}\n\n\n\n/**\n * Метод экранирует все спец символы указанные в глобальной для модуля, переменной escapeRe\n * @param {string} text Любая строка\n * @return {string} Строка text, в которой все символы указанные в переменной escapeRe заэкранированы\n */\nRegex.prototype.escape = function (text) {\n\treturn text.replace(escapeRe, s => {\n\t\treturn \"\\\\\" + s\n\t});\n}\n\n/**\n * Метод проверяет является ли char одним из разделителей указанных в this.options.separators\n * @param {string} char Cтрока содержащая в себе проверяемый символ (длинна строки должна быть равна 1)\n * @return {boolean} Если проверяемый символ является одним из символов указанных в this.options.separators то true иначе false\n */\nRegex.prototype.separator = function (char) {\n\treturn !!(this.options.separators.indexOf(char) + 1);\n}\n\n\n\nRegex.prototype.match = function (path) {\n\t// console.log(\"match 01\");\n\n\tif (typeof path !== \"string\") return;\n\n\tconst reseparator = this.options.separator;\n\tconst separator = this.options.separators[0];\n\tpath = path.replace(new RegExp(\"^\" + reseparator + \"*(.*?)\" + reseparator + \"*$\"), separator + \"$1\" + separator);\n\n\t// console.log(\"match 02\");\n\tconst result = path.match(this.regexp);\n\t// console.log(\"match 03\");\n\n\tif (!result) return;\n\n\t// console.log(\"match 04\");\n\tconst data = {};\n\n\t// console.log(\"match 05\");\n\tthis.keys.forEach(item => {\n\t\t// console.log(\"match foreach 01\");\n\t\tlet isMultiple = false;\n\n\t\tif (data[item.key])\n\t\t\tisMultiple = true;\n\n\n\t\tif (data[item.key] && !Array.isArray(data[item.key])) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [data[item.key]];\n\t\t}\n\n\t\tif (item.multiple && !data[item.key]) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [];\n\t\t}\n\n\t\tlet value = result[item.index] ? result[item.index] : undefined;\n\n\t\tif (!isMultiple && !item.multiple) {\n\t\t\tdata[item.key] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMultiple && !item.multiple && result[item.index]) {\n\t\t\tdata[item.key].push(value);\n\t\t\treturn;\n\t\t}\n\n\t\tif (result[item.index])\n\t\t\tresult[item.index].replace(item.regexp, str => {\n\t\t\t\tif (str) data[item.key].push(\n\t\t\t\t\tstr.replace(new RegExp(reseparator + \"*$\"), \"\")\n\t\t\t\t);\n\t\t\t});\n\n\t});\n\t// console.log(\"match 06\");\n\treturn data;\n};\n","import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n responses,\n parameters,\n query,\n body\n }\n}\n","import type { IPage } from \"../routing/page\";\nimport path_to_regex from \"path-to-regex\"\nimport {convertBraces} from \"../parser/path\";\nimport { writable } from 'svelte/store';\n\nexport const page = writable<IPage>({\n url: '',\n pathname:'',\n params: {},\n query:{},\n poll: async () => false, // Placeholder - will be set by navigation.svelte.ts\n});\n\n\nif(typeof window !== 'undefined') {\n page.update(p => {\n p.url = window.location.href;\n p.pathname = window.location.pathname;\n Object.assign(p.query, Object.fromEntries(new URLSearchParams(window.location.search)));\n p.params = {};\n return p;\n });\n}\n\n\nconst patterns:Record<string,any> = {}\nexport function shadowUrl(pattern:string, url: string){\n if(!patterns[pattern]) {\n patterns[pattern] = new path_to_regex(convertBraces(pattern))\n }\n const match = patterns[pattern].match(url)\n if(match) {\n return match\n }else{\n return {}\n }\n}\n"],"names":["pathToRegex","Regex","escapeRe","defaultParam","obj","defaultValue","path","options","regexp","separator","notseparator","offset","count","str","key","a","pat","quant","index","string","isMultiple","isExtrude","isRequired","quantifier","isStarted","isStoped","isToken","text","regstr","pattern","data","s","char","reseparator","result","item","value","convertBraces","out","i","start","depth","segment","colonIdx","name","modifier","m","page","writable","p","patterns","shadowUrl","url","path_to_regex","match"],"mappings":";;;;;;;;SAAAA,IAAiBC,GAEb,OAAO,SAAW,QACrB,OAAO,cAAcA;AAGtB,QAAMC,IAAW;AAQjB,WAASC,EAAaC,GAAKC,GAAc;AACxC,WAAO,OAAOD,IAAQ,MAAcA,IAAMC;AAAA,EAC3C;AAOA,WAASJ,EAAMK,GAAMC,GAAS;AAC7B,gBAAK,KAAKD,GAAMC,CAAO,GAChB;AAAA,EACR;AAEA,SAAAN,EAAM,UAAU,OAAO,SACtBK,IAAO,KACPC,IAAU,CAAA,GACT;AACD,SAAK,UAAU;AAAA,MACd,MAAM,OAAOA,EAAQ,QAAS,YAAYA,EAAQ,OAAO;AAAA,MACzD,YAAY,OAAOA,EAAQ,cAAe,WAAWA,EAAQ,aAAa;AAAA,MAC1E,WAAW,OAAOA,EAAQ,aAAc,YAAYA,EAAQ,YAAY;AAAA,MACxE,OAAO,OAAOA,EAAQ,SAAU,YAAYA,EAAQ,QAAQ;AAAA,OAE7D,KAAK,QAAQ,YAAY,MAAM,KAAK,OAAO,KAAK,QAAQ,UAAU,IAAI,KAElED,aAAgB,SACnB,KAAK,kBAAkBA,CAAI,IACjB,OAAOA,KAAS,YAC1B,KAAK,gBAAgBA,CAAI;AAAA,EAE3B,GA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,QAAOE,OACRA,EAAE,MAAM,OAAO,SAAS,MACxBA,EAAE,WAAW,OAAO,SAAS,UAC7B,OAAO,OAAOA,EAAE,OAAO,OAAO,gBAAgB,gBAAgB,OAAO,SAAS,MAAM,CAAA,CAAA,GACpFA,EAAE,aACKA,EACV;MAICC;AACU,SAAAC,EAAUtB,GAAgBuB,GAAY;EAC9CF,EAASrB,CAAO,MAChBqB,EAASrB,CAAO,IAAA,IAAQwB,EAAchB,EAAcR,CAAO,CAAA;AAEzD,QAAAyB,IAAQJ,EAASrB,CAAO,EAAE,MAAMuB,CAAG;AACtC,SAAAE;AAKP;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"page.svelte-4uv4nQ2i.js","sources":["../node_modules/path-to-regex/index.js","../src/parser/path.ts","../src/client/page.svelte.ts"],"sourcesContent":["module.exports = Regex;\n\nif (typeof window !== 'undefined') {\n\twindow.pathToRegex = Regex;\n}\n\nconst escapeRe = /([$.+*?=!:[\\]{}(|)/\\\\])/g;\n\n/**\n * defaultParam - simplistic polyfill for default function parament\n * @param {any} [obj]\n * @param {any} defaultValue\n * @return {any}\n */\nfunction defaultParam(obj, defaultValue) {\n\treturn typeof obj !== 'undefined' ? obj : defaultValue;\n}\n\n/**\n * Класс Regex [description].\n * @constructor\n * @param {Object} options [description].\n */\nfunction Regex(path, options) {\n\tthis.init(path, options);\n\treturn this;\n}\n\nRegex.prototype.init = function (\n\tpath = \"/\",\n\toptions = {}\n) {\n\tthis.options = {\n\t\tcase: typeof options.case === \"boolean\" ? options.case : true,\n\t\tseparators: typeof options.separators === \"string\" ? options.separators : \"/\",\n\t\tfromStart: typeof options.fromStart === \"boolean\" ? options.fromStart : true,\n\t\ttoEnd: typeof options.toEnd === \"boolean\" ? options.toEnd : true\n\t};\n\tthis.options.separator = \"[\" + this.escape(this.options.separators) + \"]\";\n\n\tif (path instanceof RegExp) {\n\t\tthis.restructureRegExp(path);\n\t} else if (typeof path === \"string\") {\n\t\tthis.restructurePath(path);\n\t}\n};\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructureRegExp = function (regexp) {\n\tregexp = defaultParam(regexp, /.*/);\n\tthis.keys = [];\n\tthis.path = undefined;\n\tthis.regstr = (\"\" + regexp);\n\tthis.regstr = this.regstr.substr(1, this.regstr.length - 2);\n\tthis.regexp = new RegExp(\n\t\tthis.regstr,\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n\n}\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructurePath = function (path) {\n\tpath = defaultParam(path, '/');\n\tthis.keys = [];\n\tthis.path = path;\n\tthis.regstr = \"\";\n\n\tconst separator = this.options.separator;\n\tconst notseparator = \"[^\" + this.escape(this.options.separators) + \"]\";\n\n\tlet offset = 0;\n\tlet count = 0;\n\t// 11. REGEXP toEnd[true]: /^[\\/]?foo\\/(.*?)[\\/]?$/\n\t// 11. REGEXP toEnd[false]: /^[\\/]?foo\\/(.*?)([\\/]|[\\/]?$)/i\n\n\tpath = path.replace(new RegExp(\"^\" + separator + \"*(.*?)\" + separator + \"*$\"), \"$1\");\n\t//path += this.options.separators[0];\n\n\tpath.replace(/:([a-z]\\w*)(\\((.*?)\\))?([\\?\\*\\+])?/gi, (str, key, a, pat, quant, index, string) => {\n\t\t// console.log(\"-----------------------------\");\n\t\t// console.log(\"str:\", str);\n\t\t// console.log(\"key:\", key);\n\t\t// console.log(\"a:\", a);\n\t\t// console.log(\"pat:\", pat);\n\t\t// console.log(\"quant:\", quant);\n\t\t// console.log(\"index:\", index);\n\t\t// console.log(\"string:\", string);\n\t\tcount++;\n\n\n\n\t\tconst isMultiple = (quant === \"*\" || quant === \"+\") ? true : false;\n\t\tconst isExtrude = /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\+\\*]$/.test(pat) ? true : false;\n\n\t\tlet isRequired = (quant !== \"*\" && quant !== \"?\") ? true : false;\n\t\tif (!quant && pat && /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\*\\?]?$/.test(pat)) isRequired = false;\n\n\t\tconst quantifier = quant ? quant : \"\";\n\t\t// console.log(\"isMultiple\", isMultiple);\n\t\t// console.log(\"isRequired\", isRequired);\n\n\t\t// const startChar = path.charAt(index-1);\n\t\tconst isStarted = (!index) ? true : this.separator(path.charAt(index - 1));\n\t\tconst isStoped = (index + str.length >= path.length) ? true : this.separator(path.charAt(index + str.length));\n\t\tconst isToken = isStarted && isStoped;\n\n\t\tif (index > offset) {\n\t\t\tconst text = path.substring(offset, index);\n\t\t\tconst regstr = this.escape(text);\n\t\t\tthis.regstr += regstr;\n\t\t}\n\n\t\tif (isToken && index) {\n\t\t\tif (!isMultiple || !isRequired) {\n\t\t\t\tif (pat && !isExtrude) {\n\t\t\t\t\tthis.regstr += \"?\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//console.log(\"isStarted\", isStarted);\n\t\t//console.log(\"isStoped\", isStoped);\n\t\t//console.log(\"isToken\", isToken);\n\t\t//console.log(\"this.regstr 1:\", this.regstr);\n\n\t\tconst pattern = (pat ? pat : notseparator + \"+\");\n\n\t\tconst regstr =\n\t\t\tisMultiple ?\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"((?:\" + separator + \"?\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\t\"((?:\" + separator + \"\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\"((?:\" + notseparator + \"*\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"(\" + pattern + \"?)\" + quantifier :\n\t\t\t\t\t\t\"(\" + pattern + \")\" + quantifier :\n\t\t\t\t\t\"(\" + pattern + \")\" + quantifier;\n\n\t\tthis.regstr += regstr;\n\n\t\tconst data = {\n\t\t\tkey: key,\n\t\t\tmultiple: isMultiple,\n\t\t\trequired: isRequired,\n\t\t\tindex: count,\n\t\t\tpattern: pattern\n\t\t};\n\t\tif (isMultiple)\n\t\t\tdata.regexp = new RegExp(pattern, this.options.case ? \"g\" : \"gi\");\n\n\t\tthis.keys.push(data);\n\n\t\toffset = index + str.length;\n\t\treturn str;\n\t});\n\n\tif (offset < path.length - 1) {\n\t\tconst text = path.substring(offset);\n\t\tconst regstr = this.escape(text);\n\t\tthis.regstr += regstr;\n\t}\n\n\tthis.regexp = new RegExp(\n\t\t(this.options.fromStart ? \"^\" : \"\") +\n\t\tseparator + \"?\" +\n\t\tthis.regstr +\n\t\t(this.options.toEnd\n\t\t\t?\n\t\t\tseparator + \"?\" + \"$\"\n\t\t\t:\n\t\t\t\"(\" + separator + \"|\" + separator + \"?\" + \"$\" + \")\"\n\t\t),\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n}\n\n\n\n/**\n * Метод экранирует все спец символы указанные в глобальной для модуля, переменной escapeRe\n * @param {string} text Любая строка\n * @return {string} Строка text, в которой все символы указанные в переменной escapeRe заэкранированы\n */\nRegex.prototype.escape = function (text) {\n\treturn text.replace(escapeRe, s => {\n\t\treturn \"\\\\\" + s\n\t});\n}\n\n/**\n * Метод проверяет является ли char одним из разделителей указанных в this.options.separators\n * @param {string} char Cтрока содержащая в себе проверяемый символ (длинна строки должна быть равна 1)\n * @return {boolean} Если проверяемый символ является одним из символов указанных в this.options.separators то true иначе false\n */\nRegex.prototype.separator = function (char) {\n\treturn !!(this.options.separators.indexOf(char) + 1);\n}\n\n\n\nRegex.prototype.match = function (path) {\n\t// console.log(\"match 01\");\n\n\tif (typeof path !== \"string\") return;\n\n\tconst reseparator = this.options.separator;\n\tconst separator = this.options.separators[0];\n\tpath = path.replace(new RegExp(\"^\" + reseparator + \"*(.*?)\" + reseparator + \"*$\"), separator + \"$1\" + separator);\n\n\t// console.log(\"match 02\");\n\tconst result = path.match(this.regexp);\n\t// console.log(\"match 03\");\n\n\tif (!result) return;\n\n\t// console.log(\"match 04\");\n\tconst data = {};\n\n\t// console.log(\"match 05\");\n\tthis.keys.forEach(item => {\n\t\t// console.log(\"match foreach 01\");\n\t\tlet isMultiple = false;\n\n\t\tif (data[item.key])\n\t\t\tisMultiple = true;\n\n\n\t\tif (data[item.key] && !Array.isArray(data[item.key])) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [data[item.key]];\n\t\t}\n\n\t\tif (item.multiple && !data[item.key]) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [];\n\t\t}\n\n\t\tlet value = result[item.index] ? result[item.index] : undefined;\n\n\t\tif (!isMultiple && !item.multiple) {\n\t\t\tdata[item.key] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMultiple && !item.multiple && result[item.index]) {\n\t\t\tdata[item.key].push(value);\n\t\t\treturn;\n\t\t}\n\n\t\tif (result[item.index])\n\t\t\tresult[item.index].replace(item.regexp, str => {\n\t\t\t\tif (str) data[item.key].push(\n\t\t\t\t\tstr.replace(new RegExp(reseparator + \"*$\"), \"\")\n\t\t\t\t);\n\t\t\t});\n\n\t});\n\t// console.log(\"match 06\");\n\treturn data;\n};\n","import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const controller = path_config['x-controller'] || undefined\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n controller,\n responses,\n parameters,\n query,\n body\n }\n}\n","import type { IPage } from \"../routing/page\";\nimport path_to_regex from \"path-to-regex\"\nimport {convertBraces} from \"../parser/path\";\nimport { writable } from 'svelte/store';\n\nexport const page = writable<IPage>({\n url: '',\n pathname:'',\n params: {},\n query:{},\n poll: async () => false, // Placeholder - will be set by navigation.svelte.ts\n});\n\n\nif(typeof window !== 'undefined') {\n page.update(p => {\n p.url = window.location.href;\n p.pathname = window.location.pathname;\n Object.assign(p.query, Object.fromEntries(new URLSearchParams(window.location.search)));\n p.params = {};\n return p;\n });\n}\n\n\nconst patterns:Record<string,any> = {}\nexport function shadowUrl(pattern:string, url: string){\n if(!patterns[pattern]) {\n patterns[pattern] = new path_to_regex(convertBraces(pattern))\n }\n const match = patterns[pattern].match(url)\n if(match) {\n return match\n }else{\n return {}\n }\n}\n"],"names":["pathToRegex","Regex","escapeRe","defaultParam","obj","defaultValue","path","options","regexp","separator","notseparator","offset","count","str","key","a","pat","quant","index","string","isMultiple","isExtrude","isRequired","quantifier","isStarted","isStoped","isToken","text","regstr","pattern","data","s","char","reseparator","result","item","value","convertBraces","out","i","start","depth","segment","colonIdx","name","modifier","m","page","writable","p","patterns","shadowUrl","url","path_to_regex","match"],"mappings":";;;;;;;;SAAAA,IAAiBC,GAEb,OAAO,SAAW,QACrB,OAAO,cAAcA;AAGtB,QAAMC,IAAW;AAQjB,WAASC,EAAaC,GAAKC,GAAc;AACxC,WAAO,OAAOD,IAAQ,MAAcA,IAAMC;AAAA,EAC3C;AAOA,WAASJ,EAAMK,GAAMC,GAAS;AAC7B,gBAAK,KAAKD,GAAMC,CAAO,GAChB;AAAA,EACR;A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,EAAQ,MAAM,qBAAqB;AAC7C,YAAI,CAACI;AACH,gBAAM,IAAI,MAAM,+BAA+BJ,CAAO,GAAG;AAE3D,WAAGE,GAAMC,CAAQ,IAAIC;AAAA,MACvB;AAEE,QAAAF,IAAUF,EAAQ,MAAM,GAAGC,CAAQ,GACnCd,IAAUa,EAAQ,MAAMC,IAAW,CAAC;AAItC,MAAAL,KAAO,IAAIM,CAAI,IACXf,MAAUS,KAAO,IAAIT,CAAO,MAC5BgB,MAAUP,KAAOO;AAAA,IACvB;AAEE,MAAAP,KAAOhC,EAAKiC,GAAG;AAInB,SAAOD;AACT;ACpEa,MAAAS,IAAOC,EAAA;AAAA,EAChB,KAAK;AAAA,EACL,UAAS;AAAA,EACT;EACA;EACA,kBAAkB;;OAIZ,SAAW,OACjBD,EAAK,QAAOE,OACRA,EAAE,MAAM,OAAO,SAAS,MACxBA,EAAE,WAAW,OAAO,SAAS,UAC7B,OAAO,OAAOA,EAAE,OAAO,OAAO,gBAAgB,gBAAgB,OAAO,SAAS,MAAM,CAAA,CAAA,GACpFA,EAAE,aACKA,EACV;MAICC;AACU,SAAAC,EAAUtB,GAAgBuB,GAAY;EAC9CF,EAASrB,CAAO,MAChBqB,EAASrB,CAAO,IAAA,IAAQwB,EAAchB,EAAcR,CAAO,CAAA;AAEzD,QAAAyB,IAAQJ,EAASrB,CAAO,EAAE,MAAMuB,CAAG;AACtC,SAAAE;AAKP;","x_google_ignoreList":[0]}
@@ -1 +1 @@
1
- {"version":3,"file":"page.svelte-CW8PJDdH.cjs","sources":["../node_modules/path-to-regex/index.js","../src/parser/path.ts","../src/client/page.svelte.ts"],"sourcesContent":["module.exports = Regex;\n\nif (typeof window !== 'undefined') {\n\twindow.pathToRegex = Regex;\n}\n\nconst escapeRe = /([$.+*?=!:[\\]{}(|)/\\\\])/g;\n\n/**\n * defaultParam - simplistic polyfill for default function parament\n * @param {any} [obj]\n * @param {any} defaultValue\n * @return {any}\n */\nfunction defaultParam(obj, defaultValue) {\n\treturn typeof obj !== 'undefined' ? obj : defaultValue;\n}\n\n/**\n * Класс Regex [description].\n * @constructor\n * @param {Object} options [description].\n */\nfunction Regex(path, options) {\n\tthis.init(path, options);\n\treturn this;\n}\n\nRegex.prototype.init = function (\n\tpath = \"/\",\n\toptions = {}\n) {\n\tthis.options = {\n\t\tcase: typeof options.case === \"boolean\" ? options.case : true,\n\t\tseparators: typeof options.separators === \"string\" ? options.separators : \"/\",\n\t\tfromStart: typeof options.fromStart === \"boolean\" ? options.fromStart : true,\n\t\ttoEnd: typeof options.toEnd === \"boolean\" ? options.toEnd : true\n\t};\n\tthis.options.separator = \"[\" + this.escape(this.options.separators) + \"]\";\n\n\tif (path instanceof RegExp) {\n\t\tthis.restructureRegExp(path);\n\t} else if (typeof path === \"string\") {\n\t\tthis.restructurePath(path);\n\t}\n};\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructureRegExp = function (regexp) {\n\tregexp = defaultParam(regexp, /.*/);\n\tthis.keys = [];\n\tthis.path = undefined;\n\tthis.regstr = (\"\" + regexp);\n\tthis.regstr = this.regstr.substr(1, this.regstr.length - 2);\n\tthis.regexp = new RegExp(\n\t\tthis.regstr,\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n\n}\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructurePath = function (path) {\n\tpath = defaultParam(path, '/');\n\tthis.keys = [];\n\tthis.path = path;\n\tthis.regstr = \"\";\n\n\tconst separator = this.options.separator;\n\tconst notseparator = \"[^\" + this.escape(this.options.separators) + \"]\";\n\n\tlet offset = 0;\n\tlet count = 0;\n\t// 11. REGEXP toEnd[true]: /^[\\/]?foo\\/(.*?)[\\/]?$/\n\t// 11. REGEXP toEnd[false]: /^[\\/]?foo\\/(.*?)([\\/]|[\\/]?$)/i\n\n\tpath = path.replace(new RegExp(\"^\" + separator + \"*(.*?)\" + separator + \"*$\"), \"$1\");\n\t//path += this.options.separators[0];\n\n\tpath.replace(/:([a-z]\\w*)(\\((.*?)\\))?([\\?\\*\\+])?/gi, (str, key, a, pat, quant, index, string) => {\n\t\t// console.log(\"-----------------------------\");\n\t\t// console.log(\"str:\", str);\n\t\t// console.log(\"key:\", key);\n\t\t// console.log(\"a:\", a);\n\t\t// console.log(\"pat:\", pat);\n\t\t// console.log(\"quant:\", quant);\n\t\t// console.log(\"index:\", index);\n\t\t// console.log(\"string:\", string);\n\t\tcount++;\n\n\n\n\t\tconst isMultiple = (quant === \"*\" || quant === \"+\") ? true : false;\n\t\tconst isExtrude = /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\+\\*]$/.test(pat) ? true : false;\n\n\t\tlet isRequired = (quant !== \"*\" && quant !== \"?\") ? true : false;\n\t\tif (!quant && pat && /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\*\\?]?$/.test(pat)) isRequired = false;\n\n\t\tconst quantifier = quant ? quant : \"\";\n\t\t// console.log(\"isMultiple\", isMultiple);\n\t\t// console.log(\"isRequired\", isRequired);\n\n\t\t// const startChar = path.charAt(index-1);\n\t\tconst isStarted = (!index) ? true : this.separator(path.charAt(index - 1));\n\t\tconst isStoped = (index + str.length >= path.length) ? true : this.separator(path.charAt(index + str.length));\n\t\tconst isToken = isStarted && isStoped;\n\n\t\tif (index > offset) {\n\t\t\tconst text = path.substring(offset, index);\n\t\t\tconst regstr = this.escape(text);\n\t\t\tthis.regstr += regstr;\n\t\t}\n\n\t\tif (isToken && index) {\n\t\t\tif (!isMultiple || !isRequired) {\n\t\t\t\tif (pat && !isExtrude) {\n\t\t\t\t\tthis.regstr += \"?\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//console.log(\"isStarted\", isStarted);\n\t\t//console.log(\"isStoped\", isStoped);\n\t\t//console.log(\"isToken\", isToken);\n\t\t//console.log(\"this.regstr 1:\", this.regstr);\n\n\t\tconst pattern = (pat ? pat : notseparator + \"+\");\n\n\t\tconst regstr =\n\t\t\tisMultiple ?\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"((?:\" + separator + \"?\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\t\"((?:\" + separator + \"\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\"((?:\" + notseparator + \"*\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"(\" + pattern + \"?)\" + quantifier :\n\t\t\t\t\t\t\"(\" + pattern + \")\" + quantifier :\n\t\t\t\t\t\"(\" + pattern + \")\" + quantifier;\n\n\t\tthis.regstr += regstr;\n\n\t\tconst data = {\n\t\t\tkey: key,\n\t\t\tmultiple: isMultiple,\n\t\t\trequired: isRequired,\n\t\t\tindex: count,\n\t\t\tpattern: pattern\n\t\t};\n\t\tif (isMultiple)\n\t\t\tdata.regexp = new RegExp(pattern, this.options.case ? \"g\" : \"gi\");\n\n\t\tthis.keys.push(data);\n\n\t\toffset = index + str.length;\n\t\treturn str;\n\t});\n\n\tif (offset < path.length - 1) {\n\t\tconst text = path.substring(offset);\n\t\tconst regstr = this.escape(text);\n\t\tthis.regstr += regstr;\n\t}\n\n\tthis.regexp = new RegExp(\n\t\t(this.options.fromStart ? \"^\" : \"\") +\n\t\tseparator + \"?\" +\n\t\tthis.regstr +\n\t\t(this.options.toEnd\n\t\t\t?\n\t\t\tseparator + \"?\" + \"$\"\n\t\t\t:\n\t\t\t\"(\" + separator + \"|\" + separator + \"?\" + \"$\" + \")\"\n\t\t),\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n}\n\n\n\n/**\n * Метод экранирует все спец символы указанные в глобальной для модуля, переменной escapeRe\n * @param {string} text Любая строка\n * @return {string} Строка text, в которой все символы указанные в переменной escapeRe заэкранированы\n */\nRegex.prototype.escape = function (text) {\n\treturn text.replace(escapeRe, s => {\n\t\treturn \"\\\\\" + s\n\t});\n}\n\n/**\n * Метод проверяет является ли char одним из разделителей указанных в this.options.separators\n * @param {string} char Cтрока содержащая в себе проверяемый символ (длинна строки должна быть равна 1)\n * @return {boolean} Если проверяемый символ является одним из символов указанных в this.options.separators то true иначе false\n */\nRegex.prototype.separator = function (char) {\n\treturn !!(this.options.separators.indexOf(char) + 1);\n}\n\n\n\nRegex.prototype.match = function (path) {\n\t// console.log(\"match 01\");\n\n\tif (typeof path !== \"string\") return;\n\n\tconst reseparator = this.options.separator;\n\tconst separator = this.options.separators[0];\n\tpath = path.replace(new RegExp(\"^\" + reseparator + \"*(.*?)\" + reseparator + \"*$\"), separator + \"$1\" + separator);\n\n\t// console.log(\"match 02\");\n\tconst result = path.match(this.regexp);\n\t// console.log(\"match 03\");\n\n\tif (!result) return;\n\n\t// console.log(\"match 04\");\n\tconst data = {};\n\n\t// console.log(\"match 05\");\n\tthis.keys.forEach(item => {\n\t\t// console.log(\"match foreach 01\");\n\t\tlet isMultiple = false;\n\n\t\tif (data[item.key])\n\t\t\tisMultiple = true;\n\n\n\t\tif (data[item.key] && !Array.isArray(data[item.key])) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [data[item.key]];\n\t\t}\n\n\t\tif (item.multiple && !data[item.key]) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [];\n\t\t}\n\n\t\tlet value = result[item.index] ? result[item.index] : undefined;\n\n\t\tif (!isMultiple && !item.multiple) {\n\t\t\tdata[item.key] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMultiple && !item.multiple && result[item.index]) {\n\t\t\tdata[item.key].push(value);\n\t\t\treturn;\n\t\t}\n\n\t\tif (result[item.index])\n\t\t\tresult[item.index].replace(item.regexp, str => {\n\t\t\t\tif (str) data[item.key].push(\n\t\t\t\t\tstr.replace(new RegExp(reseparator + \"*$\"), \"\")\n\t\t\t\t);\n\t\t\t});\n\n\t});\n\t// console.log(\"match 06\");\n\treturn data;\n};\n","import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n responses,\n parameters,\n query,\n body\n }\n}\n","import type { IPage } from \"../routing/page\";\nimport path_to_regex from \"path-to-regex\"\nimport {convertBraces} from \"../parser/path\";\nimport { writable } from 'svelte/store';\n\nexport const page = writable<IPage>({\n url: '',\n pathname:'',\n params: {},\n query:{},\n poll: async () => false, // Placeholder - will be set by navigation.svelte.ts\n});\n\n\nif(typeof window !== 'undefined') {\n page.update(p => {\n p.url = window.location.href;\n p.pathname = window.location.pathname;\n Object.assign(p.query, Object.fromEntries(new URLSearchParams(window.location.search)));\n p.params = {};\n return p;\n });\n}\n\n\nconst patterns:Record<string,any> = {}\nexport function shadowUrl(pattern:string, url: string){\n if(!patterns[pattern]) {\n patterns[pattern] = new path_to_regex(convertBraces(pattern))\n }\n const match = patterns[pattern].match(url)\n if(match) {\n return match\n }else{\n return {}\n }\n}\n"],"names":["pathToRegex","Regex","escapeRe","defaultParam","obj","defaultValue","path","options","regexp","separator","notseparator","offset","count","str","key","a","pat","quant","index","string","isMultiple","isExtrude","isRequired","quantifier","isStarted","isStoped","isToken","text","regstr","pattern","data","s","char","reseparator","result","item","value","convertBraces","out","i","start","depth","segment","colonIdx","name","modifier","m","page","writable","p","patterns","shadowUrl","url","path_to_regex","match"],"mappings":"0NAAAA,EAAiBC,EAEb,OAAO,OAAW,MACrB,OAAO,YAAcA,GAGtB,MAAMC,EAAW,2BAQjB,SAASC,EAAaC,EAAKC,EAAc,CACxC,OAAO,OAAOD,EAAQ,IAAcA,EAAMC,CAC3C,CAOA,SAASJ,EAAMK,EAAMC,EAAS,CAC7B,YAAK,KAAKD,EAAMC,CAAO,EAChB,IACR,CAEA,OAAAN,EAAM,UAAU,KAAO,SACtBK,EAAO,IACPC,EAAU,CAAA,EACT,CACD,KAAK,QAAU,CACd,KAAM,OAAOA,EAAQ,MAAS,UAAYA,EAAQ,KAAO,GACzD,WAAY,OAAOA,EAAQ,YAAe,SAAWA,EAAQ,WAAa,IAC1E,UAAW,OAAOA,EAAQ,WAAc,UAAYA,EAAQ,UAAY,GACxE,MAAO,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQ,IAE7D,KAAK,QAAQ,UAAY,IAAM,KAAK,OAAO,KAAK,QAAQ,UAAU,EAAI,IAElED,aAAgB,OACnB,KAAK,kBAAkBA,CAAI,EACjB,OAAOA,GAAS,UAC1B,KAAK,gBAAgBA,CAAI,CAE3B,EAOAL,EAAM,UAAU,kBAAoB,SAAUO,EAAQ,CACrDA,EAASL,EAAaK,EAAQ,IAAI,EAClC,KAAK,KAAO,CAAA,EACZ,KAAK,KAAO,OACZ,KAAK,OAAU,GAAKA,EACpB,KAAK,OAAS,KAAK,OAAO,OAAO,EAAG,KAAK,OAAO,OAAS,CAAC,EAC1D,KAAK,OAAS,IAAI,OACjB,KAAK,OACL,KAAK,QAAQ,KAAO,GAAK,IAG3B,EAOAP,EAAM,UAAU,g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nC,CAAI,EAAE,EAElD,MAAMoC,EAAUpC,EAAK,MAAMkC,EAAQ,EAAGD,EAAI,CAAC,EAarCI,EAAWD,EAAQ,QAAQ,GAAG,EACpC,IAAIE,EACAf,EACAgB,EAEJ,GAAIF,IAAa,GAAI,CAEnB,MAAMG,EAAIJ,EAAQ,MAAM,qBAAqB,EAC7C,GAAI,CAACI,EACH,MAAM,IAAI,MAAM,+BAA+BJ,CAAO,GAAG,EAE3D,EAAGE,EAAMC,CAAQ,EAAIC,CACvB,MAEEF,EAAUF,EAAQ,MAAM,EAAGC,CAAQ,EACnCd,EAAUa,EAAQ,MAAMC,EAAW,CAAC,EAItCL,GAAO,IAAIM,CAAI,GACXf,IAAUS,GAAO,IAAIT,CAAO,KAC5BgB,IAAUP,GAAOO,EACvB,MAEEP,GAAOhC,EAAKiC,GAAG,EAInB,OAAOD,CACT,CCpEa,MAAAS,EAAOC,EAAAA,SAAA,CAChB,IAAK,GACL,SAAS,GACT,UACA,SACA,cAAkB,YAIZ,OAAW,KACjBD,EAAK,OAAOE,IACRA,EAAE,IAAM,OAAO,SAAS,KACxBA,EAAE,SAAW,OAAO,SAAS,SAC7B,OAAO,OAAOA,EAAE,MAAO,OAAO,gBAAgB,gBAAgB,OAAO,SAAS,MAAM,CAAA,CAAA,EACpFA,EAAE,UACKA,EACV,QAICC,KACU,SAAAC,EAAUtB,EAAgBuB,EAAY,CAC9CF,EAASrB,CAAO,IAChBqB,EAASrB,CAAO,EAAA,IAAQwB,EAAchB,EAAcR,CAAO,CAAA,GAEzD,MAAAyB,EAAQJ,EAASrB,CAAO,EAAE,MAAMuB,CAAG,EACtC,OAAAE,KAKP","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"page.svelte-CW8PJDdH.cjs","sources":["../node_modules/path-to-regex/index.js","../src/parser/path.ts","../src/client/page.svelte.ts"],"sourcesContent":["module.exports = Regex;\n\nif (typeof window !== 'undefined') {\n\twindow.pathToRegex = Regex;\n}\n\nconst escapeRe = /([$.+*?=!:[\\]{}(|)/\\\\])/g;\n\n/**\n * defaultParam - simplistic polyfill for default function parament\n * @param {any} [obj]\n * @param {any} defaultValue\n * @return {any}\n */\nfunction defaultParam(obj, defaultValue) {\n\treturn typeof obj !== 'undefined' ? obj : defaultValue;\n}\n\n/**\n * Класс Regex [description].\n * @constructor\n * @param {Object} options [description].\n */\nfunction Regex(path, options) {\n\tthis.init(path, options);\n\treturn this;\n}\n\nRegex.prototype.init = function (\n\tpath = \"/\",\n\toptions = {}\n) {\n\tthis.options = {\n\t\tcase: typeof options.case === \"boolean\" ? options.case : true,\n\t\tseparators: typeof options.separators === \"string\" ? options.separators : \"/\",\n\t\tfromStart: typeof options.fromStart === \"boolean\" ? options.fromStart : true,\n\t\ttoEnd: typeof options.toEnd === \"boolean\" ? options.toEnd : true\n\t};\n\tthis.options.separator = \"[\" + this.escape(this.options.separators) + \"]\";\n\n\tif (path instanceof RegExp) {\n\t\tthis.restructureRegExp(path);\n\t} else if (typeof path === \"string\") {\n\t\tthis.restructurePath(path);\n\t}\n};\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructureRegExp = function (regexp) {\n\tregexp = defaultParam(regexp, /.*/);\n\tthis.keys = [];\n\tthis.path = undefined;\n\tthis.regstr = (\"\" + regexp);\n\tthis.regstr = this.regstr.substr(1, this.regstr.length - 2);\n\tthis.regexp = new RegExp(\n\t\tthis.regstr,\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n\n}\n\n/**\n * Метод преобразует строку с шаблоном пути, включающим в себя строковое представление регулярных выражений\n * и указадели на идентификаторы ключей в стиле Express.js в регулярное выражение\n * @param {string} path Строка содержащая шаблон пути. Может содержать в себе регулярные выражения и объявление ключей типа :id. Поведение имитирует аналогичный функционал библиотеки Express.js v.5.x\n */\nRegex.prototype.restructurePath = function (path) {\n\tpath = defaultParam(path, '/');\n\tthis.keys = [];\n\tthis.path = path;\n\tthis.regstr = \"\";\n\n\tconst separator = this.options.separator;\n\tconst notseparator = \"[^\" + this.escape(this.options.separators) + \"]\";\n\n\tlet offset = 0;\n\tlet count = 0;\n\t// 11. REGEXP toEnd[true]: /^[\\/]?foo\\/(.*?)[\\/]?$/\n\t// 11. REGEXP toEnd[false]: /^[\\/]?foo\\/(.*?)([\\/]|[\\/]?$)/i\n\n\tpath = path.replace(new RegExp(\"^\" + separator + \"*(.*?)\" + separator + \"*$\"), \"$1\");\n\t//path += this.options.separators[0];\n\n\tpath.replace(/:([a-z]\\w*)(\\((.*?)\\))?([\\?\\*\\+])?/gi, (str, key, a, pat, quant, index, string) => {\n\t\t// console.log(\"-----------------------------\");\n\t\t// console.log(\"str:\", str);\n\t\t// console.log(\"key:\", key);\n\t\t// console.log(\"a:\", a);\n\t\t// console.log(\"pat:\", pat);\n\t\t// console.log(\"quant:\", quant);\n\t\t// console.log(\"index:\", index);\n\t\t// console.log(\"string:\", string);\n\t\tcount++;\n\n\n\n\t\tconst isMultiple = (quant === \"*\" || quant === \"+\") ? true : false;\n\t\tconst isExtrude = /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\+\\*]$/.test(pat) ? true : false;\n\n\t\tlet isRequired = (quant !== \"*\" && quant !== \"?\") ? true : false;\n\t\tif (!quant && pat && /^(\\[[^\\[\\]]+\\]|\\([^\\(\\)]+\\)|\\.|\\\\.)[\\*\\?]?$/.test(pat)) isRequired = false;\n\n\t\tconst quantifier = quant ? quant : \"\";\n\t\t// console.log(\"isMultiple\", isMultiple);\n\t\t// console.log(\"isRequired\", isRequired);\n\n\t\t// const startChar = path.charAt(index-1);\n\t\tconst isStarted = (!index) ? true : this.separator(path.charAt(index - 1));\n\t\tconst isStoped = (index + str.length >= path.length) ? true : this.separator(path.charAt(index + str.length));\n\t\tconst isToken = isStarted && isStoped;\n\n\t\tif (index > offset) {\n\t\t\tconst text = path.substring(offset, index);\n\t\t\tconst regstr = this.escape(text);\n\t\t\tthis.regstr += regstr;\n\t\t}\n\n\t\tif (isToken && index) {\n\t\t\tif (!isMultiple || !isRequired) {\n\t\t\t\tif (pat && !isExtrude) {\n\t\t\t\t\tthis.regstr += \"?\";\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t//console.log(\"isStarted\", isStarted);\n\t\t//console.log(\"isStoped\", isStoped);\n\t\t//console.log(\"isToken\", isToken);\n\t\t//console.log(\"this.regstr 1:\", this.regstr);\n\n\t\tconst pattern = (pat ? pat : notseparator + \"+\");\n\n\t\tconst regstr =\n\t\t\tisMultiple ?\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"((?:\" + separator + \"?\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\t\"((?:\" + separator + \"\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\t\t\"((?:\" + notseparator + \"*\" + pattern + \")\" + quantifier + \")\" :\n\t\t\t\tisToken ?\n\t\t\t\t\tisExtrude ?\n\t\t\t\t\t\t\"(\" + pattern + \"?)\" + quantifier :\n\t\t\t\t\t\t\"(\" + pattern + \")\" + quantifier :\n\t\t\t\t\t\"(\" + pattern + \")\" + quantifier;\n\n\t\tthis.regstr += regstr;\n\n\t\tconst data = {\n\t\t\tkey: key,\n\t\t\tmultiple: isMultiple,\n\t\t\trequired: isRequired,\n\t\t\tindex: count,\n\t\t\tpattern: pattern\n\t\t};\n\t\tif (isMultiple)\n\t\t\tdata.regexp = new RegExp(pattern, this.options.case ? \"g\" : \"gi\");\n\n\t\tthis.keys.push(data);\n\n\t\toffset = index + str.length;\n\t\treturn str;\n\t});\n\n\tif (offset < path.length - 1) {\n\t\tconst text = path.substring(offset);\n\t\tconst regstr = this.escape(text);\n\t\tthis.regstr += regstr;\n\t}\n\n\tthis.regexp = new RegExp(\n\t\t(this.options.fromStart ? \"^\" : \"\") +\n\t\tseparator + \"?\" +\n\t\tthis.regstr +\n\t\t(this.options.toEnd\n\t\t\t?\n\t\t\tseparator + \"?\" + \"$\"\n\t\t\t:\n\t\t\t\"(\" + separator + \"|\" + separator + \"?\" + \"$\" + \")\"\n\t\t),\n\t\tthis.options.case ? \"\" : \"i\"\n\t);\n}\n\n\n\n/**\n * Метод экранирует все спец символы указанные в глобальной для модуля, переменной escapeRe\n * @param {string} text Любая строка\n * @return {string} Строка text, в которой все символы указанные в переменной escapeRe заэкранированы\n */\nRegex.prototype.escape = function (text) {\n\treturn text.replace(escapeRe, s => {\n\t\treturn \"\\\\\" + s\n\t});\n}\n\n/**\n * Метод проверяет является ли char одним из разделителей указанных в this.options.separators\n * @param {string} char Cтрока содержащая в себе проверяемый символ (длинна строки должна быть равна 1)\n * @return {boolean} Если проверяемый символ является одним из символов указанных в this.options.separators то true иначе false\n */\nRegex.prototype.separator = function (char) {\n\treturn !!(this.options.separators.indexOf(char) + 1);\n}\n\n\n\nRegex.prototype.match = function (path) {\n\t// console.log(\"match 01\");\n\n\tif (typeof path !== \"string\") return;\n\n\tconst reseparator = this.options.separator;\n\tconst separator = this.options.separators[0];\n\tpath = path.replace(new RegExp(\"^\" + reseparator + \"*(.*?)\" + reseparator + \"*$\"), separator + \"$1\" + separator);\n\n\t// console.log(\"match 02\");\n\tconst result = path.match(this.regexp);\n\t// console.log(\"match 03\");\n\n\tif (!result) return;\n\n\t// console.log(\"match 04\");\n\tconst data = {};\n\n\t// console.log(\"match 05\");\n\tthis.keys.forEach(item => {\n\t\t// console.log(\"match foreach 01\");\n\t\tlet isMultiple = false;\n\n\t\tif (data[item.key])\n\t\t\tisMultiple = true;\n\n\n\t\tif (data[item.key] && !Array.isArray(data[item.key])) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [data[item.key]];\n\t\t}\n\n\t\tif (item.multiple && !data[item.key]) {\n\t\t\tisMultiple = true;\n\t\t\tdata[item.key] = [];\n\t\t}\n\n\t\tlet value = result[item.index] ? result[item.index] : undefined;\n\n\t\tif (!isMultiple && !item.multiple) {\n\t\t\tdata[item.key] = value;\n\t\t\treturn;\n\t\t}\n\n\t\tif (isMultiple && !item.multiple && result[item.index]) {\n\t\t\tdata[item.key].push(value);\n\t\t\treturn;\n\t\t}\n\n\t\tif (result[item.index])\n\t\t\tresult[item.index].replace(item.regexp, str => {\n\t\t\t\tif (str) data[item.key].push(\n\t\t\t\t\tstr.replace(new RegExp(reseparator + \"*$\"), \"\")\n\t\t\t\t);\n\t\t\t});\n\n\t});\n\t// console.log(\"match 06\");\n\treturn data;\n};\n","import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const controller = path_config['x-controller'] || undefined\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n controller,\n responses,\n parameters,\n query,\n body\n }\n}\n","import type { IPage } from \"../routing/page\";\nimport path_to_regex from \"path-to-regex\"\nimport {convertBraces} from \"../parser/path\";\nimport { writable } from 'svelte/store';\n\nexport const page = writable<IPage>({\n url: '',\n pathname:'',\n params: {},\n query:{},\n poll: async () => false, // Placeholder - will be set by navigation.svelte.ts\n});\n\n\nif(typeof window !== 'undefined') {\n page.update(p => {\n p.url = window.location.href;\n p.pathname = window.location.pathname;\n Object.assign(p.query, Object.fromEntries(new URLSearchParams(window.location.search)));\n p.params = {};\n return p;\n });\n}\n\n\nconst patterns:Record<string,any> = {}\nexport function shadowUrl(pattern:string, url: string){\n if(!patterns[pattern]) {\n patterns[pattern] = new path_to_regex(convertBraces(pattern))\n }\n const match = patterns[pattern].match(url)\n if(match) {\n return match\n }else{\n return {}\n }\n}\n"],"names":["pathToRegex","Regex","escapeRe","defaultParam","obj","defaultValue","path","options","regexp","separator","notseparator","offset","count","str","key","a","pat","quant","index","string","isMultiple","isExtrude","isRequired","quantifier","isStarted","isStoped","isToken","text","regstr","pattern","data","s","char","reseparator","result","item","value","convertBraces","out","i","start","depth","segment","colonIdx","name","modifier","m","page","writable","p","patterns","shadowUrl","url","path_to_regex","match"],"mappings":"0NAAAA,EAAiBC,EAEb,OAAO,OAAW,MACrB,OAAO,YAAcA,GAGtB,MAAMC,EAAW,2BAQjB,SAASC,EAAaC,EAAKC,EAAc,CACxC,OAAO,OAAOD,EAAQ,IAAcA,EAAMC,CAC3C,CAOA,SAASJ,EAAMK,EAAMC,EAAS,CAC7B,YAAK,KAAKD,EAAMC,CAAO,EAChB,IACR,CAEA,OAAAN,EAAM,UAAU,KAAO,SACtBK,EAAO,IACPC,EAAU,CAAA,EACT,CACD,KAAK,QAAU,CACd,KAAM,OAAOA,EAAQ,MAAS,UAAYA,EAAQ,KAAO,GACzD,WAAY,OAAOA,EAAQ,YAAe,SAAWA,EAAQ,WAAa,IAC1E,UAAW,OAAOA,EAAQ,WAAc,UAAYA,EAAQ,UAAY,GACxE,MAAO,OAAOA,EAAQ,OAAU,UAAYA,EAAQ,MAAQ,IAE7D,KAAK,QAAQ,UAAY,IAAM,KAAK,OAAO,KAAK,QAAQ,UAAU,EAAI,IAElED,aAAgB,OACnB,KAAK,kBAAkBA,CAAI,EACjB,OAAOA,GAAS,UAC1B,KAAK,gBAAgBA,CAAI,CAE3B,EAOAL,EAAM,UAAU,kBAAoB,SAAUO,EAAQ,CACrDA,EAASL,EAAaK,EAAQ,IAAI,EAClC,KAAK,KAAO,CAAA,EACZ,KAAK,KAAO,OACZ,KAAK,OAAU,GAAKA,EAC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"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAmBF,QAAA,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEW,QAAA,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,0BAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
1
+ {"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAGxB,mCAAkC;AAAzB,gGAAA,MAAM,OAAA;AAsBF,QAAA,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEW,QAAA,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,0BAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
@@ -3,6 +3,7 @@ import type { ForgeAssets } from './assets';
3
3
  export { assets } from './assets';
4
4
  export type htmlRenderer = 'default' | string | IHTMLRender;
5
5
  export type ContextBuilder = (req: any, res: any) => Record<string, any>;
6
+ export type ControllerFactory = (controllerClass: new (...args: any[]) => any) => Promise<unknown> | unknown;
6
7
  export interface ServerOptions {
7
8
  development?: boolean;
8
9
  viteOptions?: any;
@@ -15,6 +16,8 @@ export interface ServerOptions {
15
16
  assets?: ForgeAssets;
16
17
  context_builder?: ContextBuilder;
17
18
  middleware_path?: string;
19
+ /** Optional PageController factory used by the client for each page/layout/controller instantiation. */
20
+ controller_factory?: ControllerFactory;
18
21
  }
19
22
  export declare const defaultViteOptions: any;
20
23
  export declare const defaultOptions: ServerOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAmBlC,MAAM,CAAC,MAAM,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,kBAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
1
+ {"version":3,"file":"ServerOptions.js","sourceRoot":"","sources":["../../../src/options/ServerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAsBlC,MAAM,CAAC,MAAM,kBAAkB,GAAQ;IACnC,OAAO,EAAE,QAAQ;IACjB,IAAI,EAAE,OAAO,CAAC,GAAG,EAAE;IACnB,MAAM,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE;IAChC,GAAG,EAAE;QACD,UAAU,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;KACxC;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAkB;IACzC,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;IAClD,WAAW,EAAE,kBAAkB;IAC/B,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,UAAU;IACrB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC;IACvD,iBAAiB,EAAE,gBAAgB;IACnC,eAAe,EAAE,SAAS;CAC7B,CAAC"}
@@ -46,6 +46,7 @@ function parsePathConfig(path, method, path_config, inheritedMiddleware = []) {
46
46
  const rawLayout = path_config == null ? void 0 : path_config["x-layout"];
47
47
  const layout = typeof rawLayout === "string" ? [rawLayout] : Array.isArray(rawLayout) ? rawLayout : void 0;
48
48
  const view = path_config["x-view"];
49
+ const controller = path_config["x-controller"] || void 0;
49
50
  const summary = path_config.summary;
50
51
  const query = path_config.query;
51
52
  const body = path_config.body;
@@ -60,6 +61,7 @@ function parsePathConfig(path, method, path_config, inheritedMiddleware = []) {
60
61
  layout,
61
62
  middleware,
62
63
  view,
64
+ controller,
63
65
  responses,
64
66
  parameters,
65
67
  query,
@@ -70,4 +72,4 @@ export {
70
72
  convertBraces as c,
71
73
  parsePathConfig as p
72
74
  };
73
- //# sourceMappingURL=path-BqcF5dbs.js.map
75
+ //# sourceMappingURL=path-2bYzpvRB.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-BqcF5dbs.js","sources":["../src/parser/path.ts"],"sourcesContent":["import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n responses,\n parameters,\n query,\n body\n }\n}\n"],"names":[],"mappings":"AAOO,SAAS,cAAc,MAAsB;AAClD,MAAI,MAAM;AACV,MAAI,IAAI;AAER,SAAO,IAAI,KAAK,QAAQ;AACtB,QAAI,KAAK,CAAC,MAAM,KAAK;AAEnB,UAAI,QAAQ;AACZ;AAEA,UAAI,QAAQ;AACZ,aAAO,IAAI,KAAK,UAAU,QAAQ,GAAG;AACnC,YAAI,KAAK,CAAC,MAAM,MAAM;AAEpB,eAAK;AAAA,QACP,OAAO;AACL,cAAI,KAAK,CAAC,MAAM,IAAK;AAAA,mBACZ,KAAK,CAAC,MAAM,IAAK;AAC1B;AAAA,QACF;AAAA,MACF;AACA,UAAI,UAAU,GAAG;AACf,cAAM,IAAI,MAAM,0BAA0B,IAAI,EAA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-2bYzpvRB.js","sources":["../src/parser/path.ts"],"sourcesContent":["import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const controller = path_config['x-controller'] || undefined\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n controller,\n responses,\n parameters,\n query,\n body\n }\n}\n"],"names":[],"mappings":"AAOO,SAAS,cAAc,MAAsB;AAClD,MAAI,MAAM;AACV,MAAI,IAAI;AAER,SAAO,IAAI,KAAK,QAAQ;AACtB,QAAI,KAAK,CAAC,MAAM,KAAK;AAEnB,UAAI,QAAQ;AACZ;AAEA,UAAI,QAAQ;AACZ,aAAO,IAAI,KAAK,UAAU,QAAQ,GAAG;AACnC,YAAI,KAAK,CAAC,MAAM,MAAM;AAEpB,eAAK;AAAA,QACP,OAAO;AACL,cAAI,KAAK,CAAC,MAAM,IAAK;AAAA,mBACZ,KAAK,CAAC,MAAM,IAAK;AAC1B;AAAA,QACF;AAAA,MACF;AACA,UAAI,UAAU,GAAG;AACf,cAAM,IAAI,MAAM,0BAA0B,IAAI,EAAE;AAAA,MAClD;AACA,YAAM,UAAU,KAAK,MAAM,QAAQ,GAAG,IAAI,CAAC;AAa3C,YAAM,WAAW,QAAQ,QAAQ,GAAG;AACpC,UAAI;AACJ,UAAI;AACJ,UAAI;AAEJ,UAAI,aAAa,IAAI;AAEnB,cAAM,IAAI,QAAQ,MAAM,qBAAqB;AAC7C,YAAI,CAAC,GAAG;AACN,gBAAM,IAAI,MAAM,+BAA+B,OAAO,GAAG;AAAA,QAC3D;AACA,WAAG,MAAM,QAAQ,IAAI;AAAA,MACvB,OAAO;AAEL,eAAU,QAAQ,MAAM,GAAG,QAAQ;AACnC,kBAAU,QAAQ,MAAM,WAAW,CAAC;AAAA,MAEtC;AAEA,aAAO,IAAI,IAAI;AACf,UAAI,QAAU,QAAO,IAAI,OAAO;AAChC,UAAI,SAAU,QAAO;AAAA,IACvB,OAAO;AAEL,aAAO,KAAK,GAAG;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;AAGO,SAAS,gBACZ,MACA,QACA,aACA,sBAAgC,CAAA,GAC3B;AACL,QAAM,YAAY,2CAAc;AAChC,QAAM,SAAU,OAAO,cAAc,WAAY,CAAC,SAAS,IACtD,MAAM,QAAQ,SAAS,IAAI,YAAY;AAC5C,QAAM,OAAO,YAAY,QAAQ;AACjC,QAAM,aAAa,YAAY,cAAc,KAAK;AAClD,QAAM,UAAU,YAAY;AAC5B,QAAM,QAAQ,YAAY;AAC1B,QAAM,OAAO,YAAY;AACzB,QAAM,aAAa,YAAY;AAC/B,QAAM,YAAY,YAAY;AAC9B,QAAM,kBAAkB,MAAM,QAAQ,YAAY,cAAc,CAAC,IAAI,YAAY,cAAc,IAAI,CAAA;AACnG,QAAM,aAAa,CAAC,GAAG,qBAAqB,GAAG,eAAe;AAE9D,SAAO;AAAA,IACH;AAAA,IACA,MAAM,cAAc,IAAI;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAER;"}
@@ -47,6 +47,7 @@ function parsePathConfig(path, method, path_config, inheritedMiddleware = []) {
47
47
  const rawLayout = path_config == null ? void 0 : path_config["x-layout"];
48
48
  const layout = typeof rawLayout === "string" ? [rawLayout] : Array.isArray(rawLayout) ? rawLayout : void 0;
49
49
  const view = path_config["x-view"];
50
+ const controller = path_config["x-controller"] || void 0;
50
51
  const summary = path_config.summary;
51
52
  const query = path_config.query;
52
53
  const body = path_config.body;
@@ -61,6 +62,7 @@ function parsePathConfig(path, method, path_config, inheritedMiddleware = []) {
61
62
  layout,
62
63
  middleware,
63
64
  view,
65
+ controller,
64
66
  responses,
65
67
  parameters,
66
68
  query,
@@ -69,4 +71,4 @@ function parsePathConfig(path, method, path_config, inheritedMiddleware = []) {
69
71
  }
70
72
  exports.convertBraces = convertBraces;
71
73
  exports.parsePathConfig = parsePathConfig;
72
- //# sourceMappingURL=path-sxXxpB6R.cjs.map
74
+ //# sourceMappingURL=path-DCxJMpj7.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"path-sxXxpB6R.cjs","sources":["../src/parser/path.ts"],"sourcesContent":["import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n responses,\n parameters,\n query,\n body\n }\n}\n"],"names":[],"mappings":";AAOO,SAAS,cAAc,MAAsB;AAClD,MAAI,MAAM;AACV,MAAI,IAAI;AAER,SAAO,IAAI,KAAK,QAAQ;AACtB,QAAI,KAAK,CAAC,MAAM,KAAK;AAEnB,UAAI,QAAQ;AACZ;AAEA,UAAI,QAAQ;AACZ,aAAO,IAAI,KAAK,UAAU,QAAQ,GAAG;AACnC,YAAI,KAAK,CAAC,MAAM,MAAM;AAEpB,eAAK;AAAA,QACP,OAAO;AACL,cAAI,KAAK,CAAC,MAAM,IAAK;A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I;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAER;;;"}
1
+ {"version":3,"file":"path-DCxJMpj7.cjs","sources":["../src/parser/path.ts"],"sourcesContent":["import type {IRoute} from \"./IRoute\"\n\n/**\n * Convert OpenAPI‐style `{name[:pattern][modifier]}` into\n * path-to-regexp’s `:name(pattern)?*+` syntax, while\n * allowing literal `{` or `}` inside the regex.\n */\nexport function convertBraces(path: string): string {\n let out = '';\n let i = 0;\n\n while (i < path.length) {\n if (path[i] === '{') {\n // start of a parameter spec\n let start = i;\n i++;\n // find the matching closing '}' that balances this one\n let depth = 1;\n while (i < path.length && depth > 0) {\n if (path[i] === '\\\\') {\n // skip escaped chars\n i += 2;\n } else {\n if (path[i] === '{') depth++;\n else if (path[i] === '}') depth--;\n i++;\n }\n }\n if (depth !== 0) {\n throw new Error(`Unmatched '{' in path: ${path}`);\n }\n const segment = path.slice(start + 1, i - 1);\n // A segment is one of the following forms:\n // 1. \"name\" – simple param, no pattern, no modifier\n // 2. \"name+\" / \"name*\" / \"name?\" – param with modifier only\n // 3. \"name:regex\" – explicit pattern (may itself contain +, *, ?)\n // In the third case we must **not** interpret a trailing +, * or ? as a\n // modifier because it belongs to the user-supplied regex. The original\n // implementation used a single regexp with an optional modifier group,\n // which incorrectly split patterns such as `.*` or `.+` into two parts\n // (`.` as the pattern and `*` or `+` as the modifier). Instead we now\n // split on the first ':'; if a pattern is present we treat the rest of\n // the segment verbatim.\n\n const colonIdx = segment.indexOf(':');\n let name: string;\n let pattern: string | undefined;\n let modifier: string | undefined;\n\n if (colonIdx === -1) {\n // Forms 1 & 2 – no explicit pattern, so a trailing modifier is allowed.\n const m = segment.match(/^([^?*+]+)([?*+])?$/);\n if (!m) {\n throw new Error(`Invalid parameter segment: {${segment}}`);\n }\n [, name, modifier] = m as RegExpMatchArray & [string, string, string?];\n } else {\n // Form 3 – everything after the first ':' is the pattern.\n name = segment.slice(0, colonIdx);\n pattern = segment.slice(colonIdx + 1);\n // No modifier allowed when an explicit pattern is used.\n }\n\n out += `:${name}`;\n if (pattern) out += `(${pattern})`;\n if (modifier) out += modifier;\n } else {\n // ordinary char, copy (also handles escaped chars)\n out += path[i++];\n }\n }\n\n return out;\n}\n\n\nexport function parsePathConfig(\n path:string,\n method:string,\n path_config:any,\n inheritedMiddleware: string[] = []\n):IRoute {\n const rawLayout = path_config?.['x-layout'];\n const layout = (typeof rawLayout === 'string') ? [rawLayout]\n : (Array.isArray(rawLayout) ? rawLayout : undefined);\n const view = path_config['x-view']\n const controller = path_config['x-controller'] || undefined\n const summary = path_config.summary\n const query = path_config.query\n const body = path_config.body\n const parameters = path_config.parameters\n const responses = path_config.responses\n const routeMiddleware = Array.isArray(path_config['x-middleware']) ? path_config['x-middleware'] : []\n const middleware = [...inheritedMiddleware, ...routeMiddleware]\n\n return {\n summary,\n path: convertBraces(path),\n method,\n layout,\n middleware,\n view,\n controller,\n responses,\n parameters,\n query,\n body\n }\n}\n"],"names":[],"mappings":";AAOO,SAAS,cAAc,MAAsB;AAClD,MAAI,MAAM;AACV,MAAI,IAAI;AAER,SAAO,IAAI,KAAK,QAAQ;AACtB,QAAI,KAAK,CAAC,MAAM,KAAK;AAEnB,UAAI,QAAQ;AACZ;AAEA,UAAI,QAAQ;AACZ,aAAO,IAAI,KAAK,UAAU,QAAQ,GAAG;AACnC,YAAI,KAAK,CAAC,MAAM,MAAM;AAEpB,eAAK;AAAA,QACP,OAAO;AACL,cAAI,KAAK,CAAC,MAAM,IAAK;AAAA,mBACZ,KAAK,CAAC,MAAM,IAAK;AAC1B;AAAA,QACF;AAAA,MACF;AACA,UAAI,UAAU,GAAG;AACf,cAAM,IAAI,MAAM,0BAA0B,IAAI,EAAE;AAAA,MAClD;AACA,YAAM,UAAU,KAAK,MAAM,QAAQ,GAAG,IAAI,CAAC;AAa3C,YAAM,WAAW,QAAQ,QAAQ,GAAG;AACpC,UAAI;AACJ,UAAI;AACJ,UAAI;AAEJ,UAAI,aAAa,IAAI;AAEnB,cAAM,IAAI,QAAQ,MAAM,qBAAqB;AAC7C,YAAI,CAAC,GAAG;AACN,gBAAM,IAAI,MAAM,+BAA+B,OAAO,GAAG;AAAA,QAC3D;AACA,WAAG,MAAM,QAAQ,IAAI;AAAA,MACvB,OAAO;AAEL,eAAU,QAAQ,MAAM,GAAG,QAAQ;AACnC,kBAAU,QAAQ,MAAM,WAAW,CAAC;AAAA,MAEtC;AAEA,aAAO,IAAI,IAAI;AACf,UAAI,QAAU,QAAO,IAAI,OAAO;AAChC,UAAI,SAAU,QAAO;AAAA,IACvB,OAAO;AAEL,aAAO,KAAK,GAAG;AAAA,IACjB;AAAA,EACF;AAEA,SAAO;AACT;AAGO,SAAS,gBACZ,MACA,QACA,aACA,sBAAgC,CAAA,GAC3B;AACL,QAAM,YAAY,2CAAc;AAChC,QAAM,SAAU,OAAO,cAAc,WAAY,CAAC,SAAS,IACtD,MAAM,QAAQ,SAAS,IAAI,YAAY;AAC5C,QAAM,OAAO,YAAY,QAAQ;AACjC,QAAM,aAAa,YAAY,cAAc,KAAK;AAClD,QAAM,UAAU,YAAY;AAC5B,QAAM,QAAQ,YAAY;AAC1B,QAAM,OAAO,YAAY;AACzB,QAAM,aAAa,YAAY;AAC/B,QAAM,YAAY,YAAY;AAC9B,QAAM,kBAAkB,MAAM,QAAQ,YAAY,cAAc,CAAC,IAAI,YAAY,cAAc,IAAI,CAAA;AACnG,QAAM,aAAa,CAAC,GAAG,qBAAqB,GAAG,eAAe;AAE9D,SAAO;AAAA,IACH;AAAA,IACA,MAAM,cAAc,IAAI;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAER;;;"}
@@ -28,7 +28,7 @@ const express = require("express");
28
28
  const path = require("path");
29
29
  const fs$1 = require("fs");
30
30
  const deepmerge = require("deepmerge");
31
- const url_parser = require("./url_parser-Dipo_fiS.cjs");
31
+ const url_parser = require("./url_parser-D7ZqJUTw.cjs");
32
32
  const Handlebars = require("handlebars");
33
33
  const fs = require("fs/promises");
34
34
  const devalue = require("devalue");
@@ -615,11 +615,12 @@ class ExpressServerAdapter extends ServerAdapter {
615
615
  if (!this.isProd) return routes;
616
616
  log$1.debug(`Transforming ${routes.length} routes for production`);
617
617
  const transformed = routes.map((route) => {
618
- var _a2, _b2;
618
+ var _a2, _b2, _c;
619
619
  return {
620
620
  ...route,
621
621
  layout: (_a2 = route.layout) == null ? void 0 : _a2.map((path2) => path2.replace(/\.svelte$/, ".js")),
622
- view: (_b2 = route.view) == null ? void 0 : _b2.replace(/\.svelte$/, ".js")
622
+ view: (_b2 = route.view) == null ? void 0 : _b2.replace(/\.svelte$/, ".js"),
623
+ controller: (_c = route.controller) == null ? void 0 : _c.replace(/\.svelte\.ts$/, ".js").replace(/\.ts$/, ".js")
623
624
  };
624
625
  });
625
626
  log$1.debug(`First route view transformed: ${(_a = routes[0]) == null ? void 0 : _a.view} → ${(_b = transformed[0]) == null ? void 0 : _b.view}`);