@jasonshimmy/custom-elements-runtime 3.3.0 → 3.5.0
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.
- package/README.md +28 -7
- package/dist/css-utils-Bn-dO44e.js +203 -0
- package/dist/{css-utils-CC43BbEy.js.map → css-utils-Bn-dO44e.js.map} +1 -1
- package/dist/{css-utils-CC43BbEy.js → css-utils-CFeP8SK1.cjs} +5 -71
- package/dist/{css-utils-mgjmH8qX.cjs.map → css-utils-CFeP8SK1.cjs.map} +1 -1
- package/dist/custom-elements-runtime.cjs.js +3 -4
- package/dist/custom-elements-runtime.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.colors.cjs.js +1 -2
- package/dist/custom-elements-runtime.colors.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.colors.es.js +277 -277
- package/dist/custom-elements-runtime.colors.es.js.map +1 -1
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js +1 -2
- package/dist/custom-elements-runtime.directive-enhancements.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.directive-enhancements.es.js +106 -122
- package/dist/custom-elements-runtime.directive-enhancements.es.js.map +1 -1
- package/dist/custom-elements-runtime.directives.cjs.js +1 -2
- package/dist/custom-elements-runtime.directives.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.directives.es.js +60 -65
- package/dist/custom-elements-runtime.directives.es.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js +1 -7
- package/dist/custom-elements-runtime.dom-jit-css.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.dom-jit-css.es.js +103 -115
- package/dist/custom-elements-runtime.dom-jit-css.es.js.map +1 -1
- package/dist/custom-elements-runtime.es.js +206 -253
- package/dist/custom-elements-runtime.es.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.cjs.js +1 -2
- package/dist/custom-elements-runtime.event-bus.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.event-bus.es.js +102 -108
- package/dist/custom-elements-runtime.event-bus.es.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.cjs.js +1 -2
- package/dist/custom-elements-runtime.jit-css.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.jit-css.es.js +14 -32
- package/dist/custom-elements-runtime.jit-css.es.js.map +1 -1
- package/dist/custom-elements-runtime.router.cjs.js +20 -21
- package/dist/custom-elements-runtime.router.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.router.es.js +866 -926
- package/dist/custom-elements-runtime.router.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js +3 -4
- package/dist/custom-elements-runtime.ssr-middleware.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.ssr-middleware.es.js +67 -73
- package/dist/custom-elements-runtime.ssr-middleware.es.js.map +1 -1
- package/dist/custom-elements-runtime.ssr.cjs.js +1 -1
- package/dist/custom-elements-runtime.ssr.es.js +3 -13
- package/dist/custom-elements-runtime.store.cjs.js +1 -2
- package/dist/custom-elements-runtime.store.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.store.es.js +32 -33
- package/dist/custom-elements-runtime.store.es.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.cjs.js +1 -2
- package/dist/custom-elements-runtime.transitions.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.transitions.es.js +200 -210
- package/dist/custom-elements-runtime.transitions.es.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.cjs.js +4 -2
- package/dist/custom-elements-runtime.vite-plugin.cjs.js.map +1 -1
- package/dist/custom-elements-runtime.vite-plugin.es.js +155 -78
- package/dist/custom-elements-runtime.vite-plugin.es.js.map +1 -1
- package/dist/helpers-DcEpRwq5.cjs +5 -0
- package/dist/helpers-DcEpRwq5.cjs.map +1 -0
- package/dist/helpers-tJgb4Qve.js +693 -0
- package/dist/helpers-tJgb4Qve.js.map +1 -0
- package/dist/hooks-CEUnvtsA.js +407 -0
- package/dist/hooks-CEUnvtsA.js.map +1 -0
- package/dist/hooks-CNfugc95.cjs +2 -0
- package/dist/hooks-CNfugc95.cjs.map +1 -0
- package/dist/logger-DIJ0UH3R.js +36 -0
- package/dist/{logger-L25axmB-.js.map → logger-DIJ0UH3R.js.map} +1 -1
- package/dist/logger-Dkht1dCX.cjs +2 -0
- package/dist/{logger-BYIN7ysT.cjs.map → logger-Dkht1dCX.cjs.map} +1 -1
- package/dist/namespace-helpers-CIUkG8Mn.js +56 -0
- package/dist/{namespace-helpers-BucDdgz_.js.map → namespace-helpers-CIUkG8Mn.js.map} +1 -1
- package/dist/namespace-helpers-yYIb7INq.cjs +2 -0
- package/dist/{namespace-helpers-Bf7rm9JV.cjs.map → namespace-helpers-yYIb7INq.cjs.map} +1 -1
- package/dist/runtime/tag-utils.d.ts +11 -0
- package/dist/ssr-BpYy9XlW.js +170 -0
- package/dist/{ssr-B3lxl1vr.js.map → ssr-BpYy9XlW.js.map} +1 -1
- package/dist/ssr-CFabTOyi.cjs +4 -0
- package/dist/{ssr-DtD9e5iA.cjs.map → ssr-CFabTOyi.cjs.map} +1 -1
- package/dist/ssr.d.ts +33 -0
- package/dist/style-A8l3aQ52.cjs +55 -0
- package/dist/{style-Bjn8zDiZ.cjs.map → style-A8l3aQ52.cjs.map} +1 -1
- package/dist/style-DSSoCbC9.js +1877 -0
- package/dist/{style-DuDoj_xK.js.map → style-DSSoCbC9.js.map} +1 -1
- package/dist/tag-utils-CoSXTr1F.js +10 -0
- package/dist/tag-utils-CoSXTr1F.js.map +1 -0
- package/dist/tag-utils-XJ3dkcPQ.cjs +2 -0
- package/dist/tag-utils-XJ3dkcPQ.cjs.map +1 -0
- package/dist/template-compiler-B4B_jAPN.cjs +19 -0
- package/dist/{template-compiler-BB4JJdqk.cjs.map → template-compiler-B4B_jAPN.cjs.map} +1 -1
- package/dist/template-compiler-C3h8_vbE.js +3044 -0
- package/dist/{template-compiler-Cs5axmn4.js.map → template-compiler-C3h8_vbE.js.map} +1 -1
- package/dist/vite-plugin.d.ts +96 -2
- package/package.json +8 -8
- package/dist/css-utils-mgjmH8qX.cjs +0 -577
- package/dist/hooks-_3xP4G2N.js +0 -1189
- package/dist/hooks-_3xP4G2N.js.map +0 -1
- package/dist/hooks-fYQgZk2g.cjs +0 -7
- package/dist/hooks-fYQgZk2g.cjs.map +0 -1
- package/dist/logger-BYIN7ysT.cjs +0 -3
- package/dist/logger-L25axmB-.js +0 -41
- package/dist/namespace-helpers-Bf7rm9JV.cjs +0 -3
- package/dist/namespace-helpers-BucDdgz_.js +0 -61
- package/dist/ssr-B3lxl1vr.js +0 -165
- package/dist/ssr-DtD9e5iA.cjs +0 -5
- package/dist/style-Bjn8zDiZ.cjs +0 -56
- package/dist/style-DuDoj_xK.js +0 -1972
- package/dist/template-compiler-BB4JJdqk.cjs +0 -23
- package/dist/template-compiler-Cs5axmn4.js +0 -3236
|
@@ -1,36 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { w as e } from "./helpers-tJgb4Qve.js";
|
|
2
|
+
import { f as t, i as n, l as r } from "./hooks-CEUnvtsA.js";
|
|
3
|
+
import { _ as i, a, c as o, d as s, f as c, g as l, h as u, i as d, l as f, m as p, n as m, o as h, p as g, r as _, s as v, t as y, u as b, v as x } from "./style-DSSoCbC9.js";
|
|
4
|
+
//#region src/lib/runtime/jit-hooks.ts
|
|
5
|
+
function S(t) {
|
|
6
|
+
if (e()) return;
|
|
7
|
+
let r = n()?._host?.shadowRoot ?? null;
|
|
8
|
+
r ? l(r, t) : d(t);
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/lib/jit-css.ts
|
|
12
|
+
function C(e) {
|
|
13
|
+
return e;
|
|
10
14
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
y as colors,
|
|
14
|
-
I as containerVariants,
|
|
15
|
-
g as disableJITCSS,
|
|
16
|
-
t as enableJITCSS,
|
|
17
|
-
p as extractClassesFromHTML,
|
|
18
|
-
J as getJITCSSOptions,
|
|
19
|
-
h as isJITCSSEnabled,
|
|
20
|
-
c as isJITCSSEnabledFor,
|
|
21
|
-
T as jitCSS,
|
|
22
|
-
x as mediaVariants,
|
|
23
|
-
u as parseArbitrary,
|
|
24
|
-
d as parseColorClass,
|
|
25
|
-
b as parseColorWithOpacity,
|
|
26
|
-
f as parseGradientColorStop,
|
|
27
|
-
m as parseSpacing,
|
|
28
|
-
o as registerJITCSSComponent,
|
|
29
|
-
C as selectorVariants,
|
|
30
|
-
l as useDesignTokens,
|
|
31
|
-
n as useGlobalStyle,
|
|
32
|
-
V as useJITCSS,
|
|
33
|
-
R as utilityMap
|
|
34
|
-
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { C as cls, y as colors, m as containerVariants, _ as disableJITCSS, d as enableJITCSS, a as extractClassesFromHTML, h as getJITCSSOptions, v as isJITCSSEnabled, o as isJITCSSEnabledFor, f as jitCSS, b as mediaVariants, s as parseArbitrary, c as parseColorClass, g as parseColorWithOpacity, p as parseGradientColorStop, u as parseSpacing, l as registerJITCSSComponent, i as selectorVariants, r as useDesignTokens, t as useGlobalStyle, S as useJITCSS, x as utilityMap };
|
|
35
17
|
|
|
36
18
|
//# sourceMappingURL=custom-elements-runtime.jit-css.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-elements-runtime.jit-css.es.js","names":[],"sources":["../src/lib/runtime/jit-hooks.ts","../src/lib/jit-css.ts"],"sourcesContent":["/**\n * JIT CSS hooks — lives in a separate module so that hooks.ts does not\n * statically import style.ts. Consumers who never call `useJITCSS` will\n * have the entire JIT engine tree-shaken out of their bundle.\n */\n\nimport { isDiscoveryRender as _isDiscoveryRenderFn } from './discovery-state';\nimport { getCurrentComponentContext } from './hooks';\nimport {\n enableJITCSS,\n registerJITCSSComponent,\n type JITCSSOptions,\n} from './style';\n\n/**\n * Configure the JIT CSS engine for the current session.\n * This is a convenience wrapper around `enableJITCSS()` that can be called\n * inside a component render function or at module initialisation time.\n *\n * @example\n * ```ts\n * component('my-component', () => {\n * // Enable extended Tailwind colors so bg-blue-500, text-violet-700, etc. generate CSS\n * useJITCSS({ extendedColors: true });\n * return html`<div class=\"bg-blue-500 text-white\">Hello</div>`;\n * });\n * ```\n *\n * @example\n * ```ts\n * // At app entry – enable once for all components\n * useJITCSS({ extendedColors: true, customColors: { brand: { '500': '#e63946' } } });\n * ```\n */\nexport function useJITCSS(options?: JITCSSOptions): void {\n // During discovery renders (component registration phase) there is no real\n // shadow root. Without this guard, useJITCSS() falls through to\n // enableJITCSS() and globally enables JIT CSS for every component — exactly\n // the opt-in behaviour we are trying to prevent.\n if (_isDiscoveryRenderFn()) return;\n\n // When called inside a component render function, register this component's\n // shadow root for per-component JIT CSS opt-in. Context is always set during\n // a real render; it may be absent (null) or missing _host when called at app\n // startup level (outside any component context).\n const host = (getCurrentComponentContext() as { _host?: Element } | null)\n ?._host;\n const shadowRoot = host?.shadowRoot ?? null;\n\n if (shadowRoot) {\n // Per-component opt-in: register this shadow root only.\n registerJITCSSComponent(shadowRoot, options);\n } else {\n // App-level call (outside component context) — enable for all components\n // globally, preserving v2 behaviour when called at the entry point.\n enableJITCSS(options);\n }\n}\n\nexport type { JITCSSOptions };\n","/**\n * JIT CSS entry point — opt-in import for the full JIT CSS engine.\n *\n * @example\n * ```ts\n * import {\n * useJITCSS,\n * enableJITCSS,\n * } from '@jasonshimmy/custom-elements-runtime/jit-css';\n * ```\n */\n\n// Hooks\nexport { useJITCSS } from './runtime/jit-hooks';\nexport { useDesignTokens, useGlobalStyle } from './runtime/hooks';\nexport type { JITCSSOptions, DesignTokens } from './runtime/hooks';\n\n// Global configuration\nexport {\n enableJITCSS,\n disableJITCSS,\n isJITCSSEnabled,\n isJITCSSEnabledFor,\n registerJITCSSComponent,\n getJITCSSOptions,\n jitCSS,\n extractClassesFromHTML,\n parseColorClass,\n parseColorWithOpacity,\n parseGradientColorStop,\n parseSpacing,\n parseArbitrary,\n utilityMap,\n selectorVariants,\n mediaVariants,\n containerVariants,\n colors,\n} from './runtime/style';\n\n/**\n * A no-op identity function that signals to development tools (IDE\n * autocomplete, linters, PurgeCSS-style scanners) that the string contains\n * JIT CSS utility class names.\n *\n * At runtime this is simply `return className` — zero overhead.\n *\n * @example\n * ```ts\n * import { cls } from '@jasonshimmy/custom-elements-runtime/jit-css';\n *\n * const containerClasses = cls('flex items-center gap-4 bg-primary-500 text-white');\n * ```\n */\nexport function cls(className: string): string {\n return className;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"custom-elements-runtime.jit-css.es.js","names":[],"sources":["../src/lib/runtime/jit-hooks.ts","../src/lib/jit-css.ts"],"sourcesContent":["/**\n * JIT CSS hooks — lives in a separate module so that hooks.ts does not\n * statically import style.ts. Consumers who never call `useJITCSS` will\n * have the entire JIT engine tree-shaken out of their bundle.\n */\n\nimport { isDiscoveryRender as _isDiscoveryRenderFn } from './discovery-state';\nimport { getCurrentComponentContext } from './hooks';\nimport {\n enableJITCSS,\n registerJITCSSComponent,\n type JITCSSOptions,\n} from './style';\n\n/**\n * Configure the JIT CSS engine for the current session.\n * This is a convenience wrapper around `enableJITCSS()` that can be called\n * inside a component render function or at module initialisation time.\n *\n * @example\n * ```ts\n * component('my-component', () => {\n * // Enable extended Tailwind colors so bg-blue-500, text-violet-700, etc. generate CSS\n * useJITCSS({ extendedColors: true });\n * return html`<div class=\"bg-blue-500 text-white\">Hello</div>`;\n * });\n * ```\n *\n * @example\n * ```ts\n * // At app entry – enable once for all components\n * useJITCSS({ extendedColors: true, customColors: { brand: { '500': '#e63946' } } });\n * ```\n */\nexport function useJITCSS(options?: JITCSSOptions): void {\n // During discovery renders (component registration phase) there is no real\n // shadow root. Without this guard, useJITCSS() falls through to\n // enableJITCSS() and globally enables JIT CSS for every component — exactly\n // the opt-in behaviour we are trying to prevent.\n if (_isDiscoveryRenderFn()) return;\n\n // When called inside a component render function, register this component's\n // shadow root for per-component JIT CSS opt-in. Context is always set during\n // a real render; it may be absent (null) or missing _host when called at app\n // startup level (outside any component context).\n const host = (getCurrentComponentContext() as { _host?: Element } | null)\n ?._host;\n const shadowRoot = host?.shadowRoot ?? null;\n\n if (shadowRoot) {\n // Per-component opt-in: register this shadow root only.\n registerJITCSSComponent(shadowRoot, options);\n } else {\n // App-level call (outside component context) — enable for all components\n // globally, preserving v2 behaviour when called at the entry point.\n enableJITCSS(options);\n }\n}\n\nexport type { JITCSSOptions };\n","/**\n * JIT CSS entry point — opt-in import for the full JIT CSS engine.\n *\n * @example\n * ```ts\n * import {\n * useJITCSS,\n * enableJITCSS,\n * } from '@jasonshimmy/custom-elements-runtime/jit-css';\n * ```\n */\n\n// Hooks\nexport { useJITCSS } from './runtime/jit-hooks';\nexport { useDesignTokens, useGlobalStyle } from './runtime/hooks';\nexport type { JITCSSOptions, DesignTokens } from './runtime/hooks';\n\n// Global configuration\nexport {\n enableJITCSS,\n disableJITCSS,\n isJITCSSEnabled,\n isJITCSSEnabledFor,\n registerJITCSSComponent,\n getJITCSSOptions,\n jitCSS,\n extractClassesFromHTML,\n parseColorClass,\n parseColorWithOpacity,\n parseGradientColorStop,\n parseSpacing,\n parseArbitrary,\n utilityMap,\n selectorVariants,\n mediaVariants,\n containerVariants,\n colors,\n} from './runtime/style';\n\n/**\n * A no-op identity function that signals to development tools (IDE\n * autocomplete, linters, PurgeCSS-style scanners) that the string contains\n * JIT CSS utility class names.\n *\n * At runtime this is simply `return className` — zero overhead.\n *\n * @example\n * ```ts\n * import { cls } from '@jasonshimmy/custom-elements-runtime/jit-css';\n *\n * const containerClasses = cls('flex items-center gap-4 bg-primary-500 text-white');\n * ```\n */\nexport function cls(className: string): string {\n return className;\n}\n"],"mappings":";;;;AAkCA,SAAgB,EAAU,GAA+B;AAKvD,KAAI,GAAsB,CAAE;CAQ5B,IAAM,IAFQ,GAA4B,EACtC,OACqB,cAAc;AAEvC,CAAI,IAEF,EAAwB,GAAY,EAAQ,GAI5C,EAAa,EAAQ;;;;ACFzB,SAAgB,EAAI,GAA2B;AAC7C,QAAO"}
|
|
@@ -1,32 +1,31 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./logger-BYIN7ysT.cjs"),y=require("./hooks-fYQgZk2g.cjs"),L=require("./template-compiler-BB4JJdqk.cjs"),be=require("./custom-elements-runtime.directives.cjs.js"),se=require("./custom-elements-runtime.store.cjs.js");var ne={enabled:!0,offset:0,timeoutMs:2e3},te=e=>e?typeof URLSearchParams>"u"?{}:Object.fromEntries(new URLSearchParams(e)):{},de=e=>{if(!e||Object.keys(e).length===0)return"";try{return"?"+new URLSearchParams(e).toString()}catch{return""}},ae=e=>e?/^\s*javascript\s*:/i.test(e):!1,F=e=>/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.startsWith("//"),he=e=>{try{return decodeURIComponent(e)}catch{return e}};function $(e){if(!e)return"/";let r=e.replace(/\/+/g,"/");return r.startsWith("/")||(r="/"+r),r.length>1&&r.endsWith("/")&&(r=r.slice(0,-1)),r}var pe=e=>{if(!e)return"";const r=$(e);return r==="/"?"":r},ce=new WeakMap;function we(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Se(e){const r=$(e.path||"/"),h=r==="/"?[]:r.split("/").filter(Boolean),a=[],i=[];for(let m=0;m<h.length;m++){const b=h[m];if(b==="*"){if(m!==h.length-1)return c.devWarn(`Route '${e.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};const l=`splat${a.length}`;a.push(l),i.push("__SPLAT__");continue}const g=b.match(/^:([A-Za-z0-9_-]+)(\*)?$/);if(g){const l=g[1],E=!!g[2];if(E&&m!==h.length-1)return c.devWarn(`Route '${e.path}' contains a splat param ':${l}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};a.push(l),i.push(E?"__SPLAT__":"([^/]+)");continue}i.push(we(b))}let o;if(i.length===0)o="^/$";else if(i[i.length-1]==="__SPLAT__"){const m=i.slice(0,-1).join("/");m?o=`^/${m}(?:/(.*))?(?:/)?$`:o="^(?:/(.*))?(?:/)?$"}else o=`^/${i.join("/")}(?:/)?$`;try{return{regex:new RegExp(o),paramNames:a}}catch(m){return c.devWarn(`Failed to compile route regex for '${e.path}': ${String(m)}`),{invalid:!0}}}var K=(e,r)=>{const h=$(r);for(const a of e){let i=ce.get(a);if(i||(i=Se(a),ce.set(a,i)),i.invalid)continue;const{regex:o,paramNames:m}=i,b=o.exec(h);if(b){const g={};for(let l=0;l<m.length;l++){const E=b[l+1]||"";g[m[l]]=E?he(E):""}return{route:a,params:g}}}return{route:null,params:{}}};function Z(e,r){for(const h of e)if(K([h],r).route!==null)return h;return null}function Re(e,r){const h=r.split("?")[0].split("#")[0];return K(e,h)}var ie=50,G={},B={};function ve(){G={},B={}}function Ee(){const e=Object.entries(G);if(e.length<=ie)return;const r=e.sort(([,h],[,a])=>h.lastAccessed-a.lastAccessed).slice(0,e.length-ie);for(const[h]of r)delete G[h]}async function oe(e){if(e.component)return e.component;if(e.load){const r=G[e.path];if(r)return r.lastAccessed=Date.now(),r.component;if(B[e.path]!==void 0)return B[e.path];const h=typeof window>"u";try{const a=e.load().then(i=>{Ee();const o=i.default;return G[e.path]={component:o,lastAccessed:Date.now()},delete B[e.path],o}).catch(i=>{delete B[e.path];const o=i instanceof Error?i.message:String(i);throw h&&c.devError(`SSR component load failed for route: ${e.path}. ${o}`),new Error(`Failed to load component for route: ${e.path}. ${o}`)});return B[e.path]=a,await a}catch(a){const i=a instanceof Error?a.message:String(a);throw new Error(`Failed to load component for route: ${e.path}. ${i}`,{cause:a})}}throw new Error(`No component or loader defined for route: ${e.path}`)}var v=null;function Ce(e){v=e}function le(){return v}var H=new Set,D=null;function ye(){if(D){try{D()}catch{}D=null}if(v)try{let e=!1;D=v.subscribe(r=>{e=!0;for(const h of H)try{h(r)}catch{}});try{W.base=v.base}catch{}if(e){const r=v.getCurrent();for(const h of H)try{h(r)}catch{}}else{const r=v.getCurrent();for(const h of H)try{h(r)}catch{}}try{typeof window<"u"&&y.flushDOMUpdates()}catch{}}catch{D=null}}function $e(){ye()}var W={store:{subscribe(e){if(v)return v.store.subscribe(e);try{e({path:"/",params:{},query:{}})}catch{}return()=>{}},getState(){return v?v.getCurrent():{path:"/",params:{},query:{}}},setState(e){if(v)try{v.store.setState(e)}catch{}}},subscribe(e){if(typeof e!="function")return c.devWarn("activeRouterProxy.subscribe: listener must be a function"),()=>{};if(H.add(e),v)if(!D)ye();else try{const r=v.getCurrent();r&&e(r)}catch(r){c.devWarn("activeRouterProxy subscription failed",r)}else try{e({path:"/",params:{},query:{}})}catch(r){c.devWarn("activeRouterProxy fallback state delivery failed",r)}return()=>{try{if(H.delete(e),H.size===0&&D){try{D()}catch(r){c.devWarn("activeRouterProxy inner unsubscribe failed",r)}D=null}}catch(r){c.devWarn("activeRouterProxy unsubscribe failed",r)}}},getCurrent(){return v?v.getCurrent():{path:"/",params:{},query:{}}},async push(e){return v?v.push(e):Promise.resolve()},async replace(e){return v?v.replace(e):Promise.resolve()},back(){if(v)return v.back()},matchRoute(e){return v?v.matchRoute(e):{route:null,params:{}}},resolveRouteComponent(e){return v?v.resolveRouteComponent(e):Promise.reject(new Error("No active router"))},base:"",scrollToFragment(e){return v?v.scrollToFragment(e):Promise.resolve(!1)},destroy(){v&&v.destroy()}};function me(e){const{routes:r,base:h="",initialUrl:a,scrollToFragment:i=!0}=e,o=pe(h),m=typeof i=="boolean"?{...ne,enabled:i}:{...ne,...i};let b,g,l,E,M,U,V,J=()=>{};const _=new Set,z=10;let P=0;const X=async(s,u)=>{const t=Z(r,s.path);if(!t||!t.beforeEnter)return!0;try{const n=await t.beforeEnter(s,u);if(typeof n=="string"){const d=`${s.path}->${n}`;return _.has(d)||P>=z?(c.devError(`Redirect loop detected: ${d}`),!1):n}return n!==!1}catch(n){c.devError("beforeEnter error",n);try{l.setState(u)}catch{}throw n}},re=async(s,u)=>{const t=Z(r,s.path);if(!t||!t.onEnter)return!0;try{const n=await t.onEnter(s,u);if(typeof n=="string"){const d=`${s.path}->${n}`;return _.has(d)||P>=z?(c.devError(`Redirect loop detected: ${d}`),!1):n}return n!==!1}catch(n){c.devError("onEnter error",n);try{l.setState(u)}catch{}throw n}},Y=(s,u)=>{const t=Z(r,s.path);if(!(!t||!t.afterEnter))try{const n=t.afterEnter(s,u);n instanceof Promise&&n.catch(d=>{c.devError("afterEnter async error",d)})}catch(n){c.devError("afterEnter error",n)}},A=new Map,j=100,O=s=>{if(A.has(s))return A.get(s);const u=K(r,s);if(A.size>=j){const t=Math.floor(j*.25),n=Array.from(A.keys());for(let d=0;d<t&&d<n.length;d++)A.delete(n[d])}return A.set(s,u),u},ee=()=>{};async function p(s,u=0){try{const t=document.getElementById(s);if(!t)return!1;if(u>0)try{const n=t.getBoundingClientRect(),d=Math.max(0,window.scrollY+n.top-u);typeof window.scrollTo=="function"&&window.scrollTo({top:d,behavior:"auto"})}catch{try{t.scrollIntoView()}catch{return!1}}else if(typeof t.scrollIntoView=="function")try{t.scrollIntoView({behavior:"auto",block:"start",inline:"nearest"})}catch{try{t.scrollIntoView()}catch{return!1}}return!0}catch{return!1}}function S(s,u=0,t=2e3){return new Promise(n=>{let d=!1,C=null,R=null;const q=Date.now(),w=I=>{d||(d=!0,C&&clearTimeout(C),R!==null&&cancelAnimationFrame(R),n(I))},N=async()=>{if(!d)try{if(await p(s,u))return w(!0);const I=async()=>{if(!d){if(Date.now()-q>=t)return w(!1);try{if(await p(s,u))return w(!0);R=requestAnimationFrame(I)}catch(ge){c.devWarn("Scroll retry attempt failed:",ge),R=requestAnimationFrame(I)}}};R=requestAnimationFrame(I)}catch(I){c.devWarn("Initial scroll attempt failed:",I),w(!1)}};C=setTimeout(()=>{w(!1)},t),N().catch(I=>{c.devWarn("Scroll attempt failed:",I),w(!1)})})}let k=!1;const T=async(s,u=!1)=>{if(k){c.devWarn(`Navigation to ${s} blocked - navigation already in progress`);return}k=!0,P=0,_.clear();try{await x(s,u)}finally{k=!1,P=0,_.clear()}},f=s=>{const u=s.indexOf("#"),t=u>=0?s.slice(u+1):"",n=u>=0?s.slice(0,u):s,d=n.indexOf("?"),C=d>=0?n.slice(0,d):n,R=d>=0?te(n.slice(d)):{};return{path:$((C.startsWith(o)?C.slice(o.length):C)||"/"),query:R,fragment:t}},x=async(s,u=!1)=>{try{const t=f(s),n=O(t.path);if(!n.route)throw new Error(`No route found for ${t.path}`);const d=l.getState(),C={path:t.path,params:n.params,query:t.query,fragment:t.fragment},R=await X(C,d);if(R===!1)return;if(typeof R=="string"){P++;const w=`${C.path}->${R}`;_.add(w),await x(R,!0);return}const q=await re(C,d);if(q===!1)return;if(typeof q=="string"){P++;const w=`${C.path}->${q}`;_.add(w),await x(q,!0);return}if(typeof window<"u"&&typeof document<"u"){const w=de(t.query),N=o+t.path+(w||"")+(t.fragment?"#"+t.fragment:"");u?window.history.replaceState({},"",N):window.history.pushState({},"",N)}if(l.setState(C),Y(C,d),typeof window<"u"&&typeof document<"u")try{const w=C.fragment;m.enabled&&w&&S(String(w),m.offset,m.timeoutMs).catch(()=>{})}catch{}}catch(t){if(c.devError("Navigation error:",t),t instanceof Error&&(t.stack?.includes("runBeforeEnter")||t.stack?.includes("runOnEnter")))throw t;try{if(!K(r,l.getState().path).route){let n=r.find(d=>d.path==="/");if(n||(n=r.find(d=>!d.path.includes(":")&&!d.path.includes("*"))),!n&&r.length>0&&(n=r[0]),n){const d=K(r,n.path);l.setState({path:n.path,params:d.params,query:{}})}else c.devError("No fallback route available for error recovery")}}catch(n){c.devWarn("State recovery failed during navigation error:",n)}}};if((s=>{if(!s||s.length===0)return c.devError("Router configuration error: No routes provided"),!1;const u=new Set;for(const t of s){if(!t.path)return c.devError("Router configuration error: Route missing path",t),!1;u.has(t.path)&&c.devWarn(`Duplicate route path detected: ${t.path}`),u.add(t.path),!t.component&&!t.load&&c.devWarn(`Route '${t.path}' has no component or load function`)}return!0})(r),typeof window>"u"||typeof a<"u"){for(const s of r)O(s.path);c.devWarn(`Pre-compiled ${r.length} routes for SSR`)}if(typeof window<"u"&&typeof document<"u"&&typeof a>"u"){b=()=>{try{const t=new URL(window.location.href),n=t.pathname;return{path:$((n.startsWith(o)?n.slice(o.length):n)||"/"),query:te(t.search),fragment:t.hash&&t.hash.length?t.hash.slice(1):""}}catch(t){return c.devWarn("Invalid URL detected, falling back to safe defaults",t),{path:"/",query:{},fragment:""}}},g=b();const s=O(g.path);l=se.createStore({path:g.path,params:s.params,query:g.query,fragment:g.fragment}),E=async(t=!1)=>{await T(b().path,t)};const u=()=>E(!0);window.addEventListener("popstate",u),J=()=>window.removeEventListener("popstate",u),M=t=>T(t,!1),U=t=>T(t,!0),V=()=>window.history.back(),queueMicrotask(()=>{T(g.path,!0).catch(t=>{c.devError("Initial navigation error:",t)})})}else{b=()=>{try{const t=new URL(a||"/","http://localhost"),n=t.pathname;return{path:$((n.startsWith(o)?n.slice(o.length):n)||"/"),query:te(t.search),fragment:t.hash&&t.hash.length?t.hash.slice(1):""}}catch(t){return c.devWarn("Invalid SSR URL detected, falling back to safe defaults",t),{path:"/",query:{},fragment:""}}},g=b();const s=O(g.path);l=se.createStore({path:g.path,params:s.params,query:g.query,fragment:g.fragment}),E=async()=>{await u(b().path)};const u=async t=>{if(P++,P>z){c.devError(`SSR redirect depth exceeded for path: ${t}`);return}try{const n=f(t),d=O(n.path);if(!d.route)throw new Error(`No route found for ${n.path}`);const C=l.getState(),R={path:n.path,params:d.params,query:n.query,fragment:n.fragment},q=Z(r,R.path);if(q?.beforeEnter){const w=await q.beforeEnter(R,C);if(typeof w=="string"){const N=`${R.path}->${w}`;_.add(N),await u(w);return}if(w===!1)return}if(q?.onEnter){const w=await q.onEnter(R,C);if(typeof w=="string"){const N=`${R.path}->${w}`;_.add(N),await u(w);return}if(w===!1)return}l.setState(R),q?.afterEnter&&q.afterEnter(R,C)}catch(n){throw c.devError("SSR navigation error:",n),n}};M=async t=>(P=0,_.clear(),u(t)),U=async t=>(P=0,_.clear(),u(t)),V=()=>{}}return{_cleanupScrollState:ee,destroy:J,store:l,push:M,replace:U,back:V,subscribe:l.subscribe,matchRoute:s=>O(s),getCurrent:()=>l.getState(),resolveRouteComponent:oe,base:o,scrollToFragment:s=>{const u=s||l.getState().fragment;return!u||typeof window>"u"||typeof document>"u"?Promise.resolve(!1):S(u,m.offset,m.timeoutMs)}}}function xe(e){ve();const r=me(e),h=le();if(h){try{h.destroy()}catch{}try{h._cleanupScrollState?.()}catch{}}Ce(r);try{$e();try{typeof window<"u"&&y.flushDOMUpdates()}catch{}try{typeof window<"u"&&queueMicrotask(()=>{try{y.flushDOMUpdates()}catch{}})}catch{}}catch{}return L.component("router-view",async()=>{const a=y.getCurrentComponentContext()?._router,i=a??W;if(!le()&&!a)return L.html`<div>Router not initialized.</div>`;const o=y.ref(i.getCurrent()),m=typeof window>"u";let b;m||(y.useOnConnected(()=>{try{typeof i.subscribe=="function"&&(b=i.subscribe(l=>{try{l&&typeof l=="object"&&typeof l.path=="string"?o.value=l:(c.devWarn("router-view received invalid state",l),o.value={path:"/",params:{},query:{}})}catch(E){c.devWarn("router-view subscription update failed",E);try{o.value={path:"/",params:{},query:{}}}catch{}}}))}catch(l){c.devWarn("router-view subscribe failed",l)}}),y.useOnDisconnected(()=>{if(typeof b=="function"){try{b()}catch(l){c.devWarn("router-view unsubscribe failed",l)}b=void 0}}));const g=i.matchRoute(o.value.path);if(!g||!g.route)return L.html`<div>Not found</div>`;try{const l=await i.resolveRouteComponent(g.route);if(typeof l=="string")return{tag:l,props:{attrs:{...o.value.params}},children:[]};if(typeof l=="function"){const E=l();return(E instanceof Promise?E:Promise.resolve(E)).then(M=>typeof M=="string"?{tag:M,props:{},children:[]}:M)}return L.html`<div>Invalid route component</div>`}catch{return L.html`<div>Invalid route component</div>`}}),L.component("router-link",()=>{const a=y.useProps({to:"",tag:"a",replace:!1,exact:!1,activeClass:"active",exactActiveClass:"exact-active",ariaCurrentValue:"page",disabled:!1,external:!1,class:"",style:""}),i=typeof window>"u",o=y.ref(W.getCurrent()),m=o.value?.path||"/",b=String(a.to||""),g=i?{isExactActive:ue(m,b,W.base),isActive:fe(m,b,W.base),isExternal:F(b)||!!a.external}:null;let l;y.useStyle(()=>"a,button{display:inline-block;}");const E=y.ref(a.class||""),M=y.ref(a.style||"");if(!i){const p=y.getCurrentComponentContext(),S=p?._host??null;let k=null,T=null;y.useOnConnected(()=>{S instanceof HTMLElement&&(T=()=>{const f=String(a.to||"");if(f&&!F(f))try{const{route:x}=W.matchRoute(f);x?.load&&oe(x).catch(()=>{})}catch{}},S.addEventListener("mouseenter",T,{once:!0}));try{if(typeof W.subscribe=="function"){l=W.subscribe(f=>{try{f&&typeof f=="object"&&typeof f.path=="string"?o.value=f:(c.devWarn("router-link received invalid state",f),o.value={path:"/",params:{},query:{}})}catch(x){c.devWarn("router-link subscription update failed",x);try{o.value={path:"/",params:{},query:{}}}catch{}}});try{const f=W.getCurrent();f&&typeof f.path=="string"&&(o.value=f)}catch(f){c.devWarn("router-link initial state sync failed",f)}k=setInterval(()=>{try{const f=W.getCurrent();f&&typeof f.path=="string"&&JSON.stringify(o.value)!==JSON.stringify(f)&&(o.value=f)}catch{}},100)}}catch(f){c.devWarn("router-link subscribe failed",f)}try{if(S instanceof HTMLElement){const f=S.getAttribute("class"),x=S.getAttribute("style");f&&(E.value=f),x&&(M.value=x),f!==null&&S.removeAttribute("class"),x!==null&&S.removeAttribute("style");try{p?._requestRender?.();try{y.flushDOMUpdates()}catch{}}catch{}}}catch(f){c.devWarn("router-link host migration failed",f)}}),y.useOnDisconnected(()=>{if(T&&S instanceof HTMLElement)try{S.removeEventListener("mouseenter",T)}catch{}finally{T=null}if(typeof l=="function")try{l()}catch(f){c.devWarn("router-link unsubscribe failed",f)}finally{l=void 0}if(k)try{clearInterval(k)}catch(f){c.devWarn("router-link sync interval cleanup failed",f)}finally{k=null}})}const U=y.computed(()=>{if(i&&g)return g.isExactActive;try{const p=W.base??"",S=a.to||"";return!o.value||typeof o.value.path!="string"?!1:ue(o.value.path,S,p)}catch(p){return c.devWarn("isExactActive computation error",p),!1}}),V=y.computed(()=>{if(i&&g)return g.isActive;try{const p=W.base??"",S=a.to||"";return!o.value||typeof o.value.path!="string"?!1:a.exact?U.value:fe(o.value.path,S,p)}catch(p){return c.devWarn("isActive computation error",p),!1}}),J=y.computed(()=>{const p=String(a.to||"");if(ae(p))return null;if(F(p))return p;const[S,k]=p.split("#"),[T,f]=(S||"").split("?"),x=W.base??"";let Q=T||"/";if(x&&x!=="/"){const s=$(x),u=$(Q);u.startsWith(s)?Q=u.slice(s.length)||"/":Q=u}return x+$(Q||"/")+(f?"?"+f:"")+(k?"#"+k:"")}),_=y.computed(()=>{const p=(E&&E.value||a.class||"").split(/\s+/).filter(Boolean),S={};for(const k of p)S[k]=!0;return S}),z=y.computed(()=>({..._.value,[a.activeClass||"active"]:V.value,[a.exactActiveClass||"exact-active"]:U.value})),P=y.computed(()=>Object.keys(z.value).filter(p=>z.value[p]).join(" ")),X=y.computed(()=>a.tag||"a"),re=y.computed(()=>X.value==="button"),Y=y.computed(()=>U.value?a.ariaCurrentValue:null),A=y.computed(()=>!!a.disabled),j=y.computed(()=>(F(String(a.to||""))||!!a.external)&&X.value==="a"),O=y.computed(()=>M&&M.value||a.style||""),ee=p=>{if(!(p.defaultPrevented||p.button!==0||p.metaKey||p.altKey||p.ctrlKey||p.shiftKey)){if(A.value){p.preventDefault();return}if(ae(String(a.to||""))){try{p.preventDefault()}catch{}c.devWarn("Blocked unsafe javascript: URI in router-link.to");return}j.value||(p.preventDefault(),a.replace?W.replace(a.to):W.push(a.to))}};return L.html`
|
|
2
|
-
${
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./logger-Dkht1dCX.cjs`),t=require(`./helpers-DcEpRwq5.cjs`),n=require(`./template-compiler-B4B_jAPN.cjs`),r=require(`./custom-elements-runtime.directives.cjs.js`),i=require(`./hooks-CNfugc95.cjs`),a=require(`./custom-elements-runtime.store.cjs.js`);var o={enabled:!0,offset:0,timeoutMs:2e3},s=e=>!e||typeof URLSearchParams>`u`?{}:Object.fromEntries(new URLSearchParams(e)),c=e=>{if(!e||Object.keys(e).length===0)return``;try{return`?`+new URLSearchParams(e).toString()}catch{return``}},l=e=>e?/^\s*javascript\s*:/i.test(e):!1,u=e=>/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.startsWith(`//`),d=e=>{try{return decodeURIComponent(e)}catch{return e}};function f(e){if(!e)return`/`;let t=e.replace(/\/+/g,`/`);return t.startsWith(`/`)||(t=`/`+t),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t}var p=e=>{if(!e)return``;let t=f(e);return t===`/`?``:t},m=new WeakMap;function h(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function g(t){let n=f(t.path||`/`),r=n===`/`?[]:n.split(`/`).filter(Boolean),i=[],a=[];for(let n=0;n<r.length;n++){let o=r[n];if(o===`*`){if(n!==r.length-1)return e.r(`Route '${t.path}' contains a '*' splat in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};let o=`splat${i.length}`;i.push(o),a.push(`__SPLAT__`);continue}let s=o.match(/^:([A-Za-z0-9_-]+)(\*)?$/);if(s){let o=s[1],c=!!s[2];if(c&&n!==r.length-1)return e.r(`Route '${t.path}' contains a splat param ':${o}*' in a non-terminal position; splats must be the last segment. This route will be ignored.`),{invalid:!0};i.push(o),a.push(c?`__SPLAT__`:`([^/]+)`);continue}a.push(h(o))}let o;if(a.length===0)o=`^/$`;else if(a[a.length-1]===`__SPLAT__`){let e=a.slice(0,-1).join(`/`);o=e?`^/${e}(?:/(.*))?(?:/)?$`:`^(?:/(.*))?(?:/)?$`}else o=`^/${a.join(`/`)}(?:/)?$`;try{return{regex:new RegExp(o),paramNames:i}}catch(n){return e.r(`Failed to compile route regex for '${t.path}': ${String(n)}`),{invalid:!0}}}var _=(e,t)=>{let n=f(t);for(let t of e){let e=m.get(t);if(e||(e=g(t),m.set(t,e)),e.invalid)continue;let{regex:r,paramNames:i}=e,a=r.exec(n);if(a){let e={};for(let t=0;t<i.length;t++){let n=a[t+1]||``;e[i[t]]=n?d(n):``}return{route:t,params:e}}}return{route:null,params:{}}};function v(e,t){for(let n of e)if(_([n],t).route!==null)return n;return null}function y(e,t){let n=t.split(`?`)[0].split(`#`)[0];return _(e,n)}var b=50,x={},S={};function C(){x={},S={}}function w(){let e=Object.entries(x);if(e.length<=b)return;let t=e.sort(([,e],[,t])=>e.lastAccessed-t.lastAccessed).slice(0,e.length-b);for(let[e]of t)delete x[e]}async function T(t){if(t.component)return t.component;if(t.load){let n=x[t.path];if(n)return n.lastAccessed=Date.now(),n.component;if(S[t.path]!==void 0)return S[t.path];let r=typeof window>`u`;try{let n=t.load().then(e=>{w();let n=e.default;return x[t.path]={component:n,lastAccessed:Date.now()},delete S[t.path],n}).catch(n=>{delete S[t.path];let i=n instanceof Error?n.message:String(n);throw r&&e.t(`SSR component load failed for route: ${t.path}. ${i}`),Error(`Failed to load component for route: ${t.path}. ${i}`)});return S[t.path]=n,await n}catch(e){let n=e instanceof Error?e.message:String(e);throw Error(`Failed to load component for route: ${t.path}. ${n}`,{cause:e})}}throw Error(`No component or loader defined for route: ${t.path}`)}var E=null;function D(e){E=e}function O(){return E}var k=new Set,A=null;function j(){if(A){try{A()}catch{}A=null}if(E)try{let e=!1;A=E.subscribe(t=>{e=!0;for(let e of k)try{e(t)}catch{}});try{N.base=E.base}catch{}if(e){let e=E.getCurrent();for(let t of k)try{t(e)}catch{}}else{let e=E.getCurrent();for(let t of k)try{t(e)}catch{}}try{typeof window<`u`&&t.E()}catch{}}catch{A=null}}function M(){j()}var N={store:{subscribe(e){if(E)return E.store.subscribe(e);try{e({path:`/`,params:{},query:{}})}catch{}return()=>{}},getState(){return E?E.getCurrent():{path:`/`,params:{},query:{}}},setState(e){if(E)try{E.store.setState(e)}catch{}}},subscribe(t){if(typeof t!=`function`)return e.r(`activeRouterProxy.subscribe: listener must be a function`),()=>{};if(k.add(t),E)if(!A)j();else try{let e=E.getCurrent();e&&t(e)}catch(t){e.r(`activeRouterProxy subscription failed`,t)}else try{t({path:`/`,params:{},query:{}})}catch(t){e.r(`activeRouterProxy fallback state delivery failed`,t)}return()=>{try{if(k.delete(t),k.size===0&&A){try{A()}catch(t){e.r(`activeRouterProxy inner unsubscribe failed`,t)}A=null}}catch(t){e.r(`activeRouterProxy unsubscribe failed`,t)}}},getCurrent(){return E?E.getCurrent():{path:`/`,params:{},query:{}}},async push(e){return E?E.push(e):Promise.resolve()},async replace(e){return E?E.replace(e):Promise.resolve()},back(){if(E)return E.back()},matchRoute(e){return E?E.matchRoute(e):{route:null,params:{}}},resolveRouteComponent(e){return E?E.resolveRouteComponent(e):Promise.reject(Error(`No active router`))},base:``,scrollToFragment(e){return E?E.scrollToFragment(e):Promise.resolve(!1)},destroy(){E&&E.destroy()}};function P(t){let{routes:n,base:r=``,initialUrl:i,scrollToFragment:l=!0}=t,u=p(r),d=typeof l==`boolean`?{...o,enabled:l}:{...o,...l},m,h,g,y,b,x,S,C=()=>{},w=new Set,E=0,D=async(t,r)=>{let i=v(n,t.path);if(!i||!i.beforeEnter)return!0;try{let n=await i.beforeEnter(t,r);if(typeof n==`string`){let r=`${t.path}->${n}`;return w.has(r)||E>=10?(e.t(`Redirect loop detected: ${r}`),!1):n}return n!==!1}catch(t){e.t(`beforeEnter error`,t);try{g.setState(r)}catch{}throw t}},O=async(t,r)=>{let i=v(n,t.path);if(!i||!i.onEnter)return!0;try{let n=await i.onEnter(t,r);if(typeof n==`string`){let r=`${t.path}->${n}`;return w.has(r)||E>=10?(e.t(`Redirect loop detected: ${r}`),!1):n}return n!==!1}catch(t){e.t(`onEnter error`,t);try{g.setState(r)}catch{}throw t}},k=(t,r)=>{let i=v(n,t.path);if(!(!i||!i.afterEnter))try{let n=i.afterEnter(t,r);n instanceof Promise&&n.catch(t=>{e.t(`afterEnter async error`,t)})}catch(t){e.t(`afterEnter error`,t)}},A=new Map,j=e=>{if(A.has(e))return A.get(e);let t=_(n,e);if(A.size>=100){let e=Array.from(A.keys());for(let t=0;t<25&&t<e.length;t++)A.delete(e[t])}return A.set(e,t),t},M=()=>{};async function N(e,t=0){try{let n=document.getElementById(e);if(!n)return!1;if(t>0)try{let e=n.getBoundingClientRect(),r=Math.max(0,window.scrollY+e.top-t);typeof window.scrollTo==`function`&&window.scrollTo({top:r,behavior:`auto`})}catch{try{n.scrollIntoView()}catch{return!1}}else if(typeof n.scrollIntoView==`function`)try{n.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`})}catch{try{n.scrollIntoView()}catch{return!1}}return!0}catch{return!1}}function P(t,n=0,r=2e3){return new Promise(i=>{let a=!1,o=null,s=null,c=Date.now(),l=e=>{a||(a=!0,o&&clearTimeout(o),s!==null&&cancelAnimationFrame(s),i(e))};o=setTimeout(()=>{l(!1)},r),(async()=>{if(!a)try{if(await N(t,n))return l(!0);let i=async()=>{if(!a){if(Date.now()-c>=r)return l(!1);try{if(await N(t,n))return l(!0);s=requestAnimationFrame(i)}catch(t){e.r(`Scroll retry attempt failed:`,t),s=requestAnimationFrame(i)}}};s=requestAnimationFrame(i)}catch(t){e.r(`Initial scroll attempt failed:`,t),l(!1)}})().catch(t=>{e.r(`Scroll attempt failed:`,t),l(!1)})})}let F=!1,I=async(t,n=!1)=>{if(F){e.r(`Navigation to ${t} blocked - navigation already in progress`);return}F=!0,E=0,w.clear();try{await R(t,n)}finally{F=!1,E=0,w.clear()}},L=e=>{let t=e.indexOf(`#`),n=t>=0?e.slice(t+1):``,r=t>=0?e.slice(0,t):e,i=r.indexOf(`?`),a=i>=0?r.slice(0,i):r,o=i>=0?s(r.slice(i)):{};return{path:f((a.startsWith(u)?a.slice(u.length):a)||`/`),query:o,fragment:n}},R=async(t,r=!1)=>{try{let e=L(t),n=j(e.path);if(!n.route)throw Error(`No route found for ${e.path}`);let i=g.getState(),a={path:e.path,params:n.params,query:e.query,fragment:e.fragment},o=await D(a,i);if(o===!1)return;if(typeof o==`string`){E++;let e=`${a.path}->${o}`;w.add(e),await R(o,!0);return}let s=await O(a,i);if(s===!1)return;if(typeof s==`string`){E++;let e=`${a.path}->${s}`;w.add(e),await R(s,!0);return}if(typeof window<`u`&&typeof document<`u`){let t=c(e.query),n=u+e.path+(t||``)+(e.fragment?`#`+e.fragment:``);r?window.history.replaceState({},``,n):window.history.pushState({},``,n)}if(g.setState(a),k(a,i),typeof window<`u`&&typeof document<`u`)try{let e=a.fragment;d.enabled&&e&&P(String(e),d.offset,d.timeoutMs).catch(()=>{})}catch{}}catch(t){if(e.t(`Navigation error:`,t),t instanceof Error&&(t.stack?.includes(`runBeforeEnter`)||t.stack?.includes(`runOnEnter`)))throw t;try{if(!_(n,g.getState().path).route){let t=n.find(e=>e.path===`/`);if(t||=n.find(e=>!e.path.includes(`:`)&&!e.path.includes(`*`)),!t&&n.length>0&&(t=n[0]),t){let e=_(n,t.path);g.setState({path:t.path,params:e.params,query:{}})}else e.t(`No fallback route available for error recovery`)}}catch(t){e.r(`State recovery failed during navigation error:`,t)}}};if((t=>{if(!t||t.length===0)return e.t(`Router configuration error: No routes provided`),!1;let n=new Set;for(let r of t){if(!r.path)return e.t(`Router configuration error: Route missing path`,r),!1;n.has(r.path)&&e.r(`Duplicate route path detected: ${r.path}`),n.add(r.path),!r.component&&!r.load&&e.r(`Route '${r.path}' has no component or load function`)}return!0})(n),typeof window>`u`||i!==void 0){for(let e of n)j(e.path);e.r(`Pre-compiled ${n.length} routes for SSR`)}if(typeof window<`u`&&typeof document<`u`&&i===void 0){m=()=>{try{let e=new URL(window.location.href),t=e.pathname;return{path:f((t.startsWith(u)?t.slice(u.length):t)||`/`),query:s(e.search),fragment:e.hash&&e.hash.length?e.hash.slice(1):``}}catch(t){return e.r(`Invalid URL detected, falling back to safe defaults`,t),{path:`/`,query:{},fragment:``}}},h=m();let t=j(h.path);g=a.createStore({path:h.path,params:t.params,query:h.query,fragment:h.fragment}),y=async(e=!1)=>{await I(m().path,e)};let n=()=>y(!0);window.addEventListener(`popstate`,n),C=()=>window.removeEventListener(`popstate`,n),b=e=>I(e,!1),x=e=>I(e,!0),S=()=>window.history.back(),queueMicrotask(()=>{I(h.path,!0).catch(t=>{e.t(`Initial navigation error:`,t)})})}else{m=()=>{try{let e=new URL(i||`/`,`http://localhost`),t=e.pathname;return{path:f((t.startsWith(u)?t.slice(u.length):t)||`/`),query:s(e.search),fragment:e.hash&&e.hash.length?e.hash.slice(1):``}}catch(t){return e.r(`Invalid SSR URL detected, falling back to safe defaults`,t),{path:`/`,query:{},fragment:``}}},h=m();let t=j(h.path);g=a.createStore({path:h.path,params:t.params,query:h.query,fragment:h.fragment}),y=async()=>{await r(m().path)};let r=async t=>{if(E++,E>10){e.t(`SSR redirect depth exceeded for path: ${t}`);return}try{let e=L(t),i=j(e.path);if(!i.route)throw Error(`No route found for ${e.path}`);let a=g.getState(),o={path:e.path,params:i.params,query:e.query,fragment:e.fragment},s=v(n,o.path);if(s?.beforeEnter){let e=await s.beforeEnter(o,a);if(typeof e==`string`){let t=`${o.path}->${e}`;w.add(t),await r(e);return}if(e===!1)return}if(s?.onEnter){let e=await s.onEnter(o,a);if(typeof e==`string`){let t=`${o.path}->${e}`;w.add(t),await r(e);return}if(e===!1)return}g.setState(o),s?.afterEnter&&s.afterEnter(o,a)}catch(t){throw e.t(`SSR navigation error:`,t),t}};b=async e=>(E=0,w.clear(),r(e)),x=async e=>(E=0,w.clear(),r(e)),S=()=>{}}return{_cleanupScrollState:M,destroy:C,store:g,push:b,replace:x,back:S,subscribe:g.subscribe,matchRoute:e=>j(e),getCurrent:()=>g.getState(),resolveRouteComponent:T,base:u,scrollToFragment:e=>{let t=e||g.getState().fragment;return!t||typeof window>`u`||typeof document>`u`?Promise.resolve(!1):P(t,d.offset,d.timeoutMs)}}}function F(a){C();let o=P(a),s=O();if(s){try{s.destroy()}catch{}try{s._cleanupScrollState?.()}catch{}}D(o);try{M();try{typeof window<`u`&&t.E()}catch{}try{typeof window<`u`&&queueMicrotask(()=>{try{t.E()}catch{}})}catch{}}catch{}return n.n(`router-view`,async()=>{let r=i.i()?._router,a=r??N;if(!O()&&!r)return n.t`<div>Router not initialized.</div>`;let o=t.y(a.getCurrent()),s=typeof window>`u`,c;s||(i.m(()=>{try{typeof a.subscribe==`function`&&(c=a.subscribe(t=>{try{t&&typeof t==`object`&&typeof t.path==`string`?o.value=t:(e.r(`router-view received invalid state`,t),o.value={path:`/`,params:{},query:{}})}catch(t){e.r(`router-view subscription update failed`,t);try{o.value={path:`/`,params:{},query:{}}}catch{}}}))}catch(t){e.r(`router-view subscribe failed`,t)}}),i.h(()=>{if(typeof c==`function`){try{c()}catch(t){e.r(`router-view unsubscribe failed`,t)}c=void 0}}));let l=a.matchRoute(o.value.path);if(!l||!l.route)return n.t`<div>Not found</div>`;try{let e=await a.resolveRouteComponent(l.route);if(typeof e==`string`)return{tag:e,props:{attrs:{...o.value.params}},children:[]};if(typeof e==`function`){let t=e();return(t instanceof Promise?t:Promise.resolve(t)).then(e=>typeof e==`string`?{tag:e,props:{},children:[]}:e)}return n.t`<div>Invalid route component</div>`}catch{return n.t`<div>Invalid route component</div>`}}),n.n(`router-link`,()=>{let a=i._({to:``,tag:`a`,replace:!1,exact:!1,activeClass:`active`,exactActiveClass:`exact-active`,ariaCurrentValue:`page`,disabled:!1,external:!1,class:``,style:``}),o=typeof window>`u`,s=t.y(N.getCurrent()),c=s.value?.path||`/`,d=String(a.to||``),p=o?{isExactActive:I(c,d,N.base),isActive:L(c,d,N.base),isExternal:u(d)||!!a.external}:null,m;i.y(()=>`a,button{display:inline-block;}`);let h=t.y(a.class||``),g=t.y(a.style||``);if(!o){let n=i.i(),r=n?._host??null,o=null,c=null;i.m(()=>{r instanceof HTMLElement&&(c=()=>{let e=String(a.to||``);if(e&&!u(e))try{let{route:t}=N.matchRoute(e);t?.load&&T(t).catch(()=>{})}catch{}},r.addEventListener(`mouseenter`,c,{once:!0}));try{if(typeof N.subscribe==`function`){m=N.subscribe(t=>{try{t&&typeof t==`object`&&typeof t.path==`string`?s.value=t:(e.r(`router-link received invalid state`,t),s.value={path:`/`,params:{},query:{}})}catch(t){e.r(`router-link subscription update failed`,t);try{s.value={path:`/`,params:{},query:{}}}catch{}}});try{let e=N.getCurrent();e&&typeof e.path==`string`&&(s.value=e)}catch(t){e.r(`router-link initial state sync failed`,t)}o=setInterval(()=>{try{let e=N.getCurrent();e&&typeof e.path==`string`&&JSON.stringify(s.value)!==JSON.stringify(e)&&(s.value=e)}catch{}},100)}}catch(t){e.r(`router-link subscribe failed`,t)}try{if(r instanceof HTMLElement){let e=r.getAttribute(`class`),i=r.getAttribute(`style`);e&&(h.value=e),i&&(g.value=i),e!==null&&r.removeAttribute(`class`),i!==null&&r.removeAttribute(`style`);try{n?._requestRender?.();try{t.E()}catch{}}catch{}}}catch(t){e.r(`router-link host migration failed`,t)}}),i.h(()=>{if(c&&r instanceof HTMLElement)try{r.removeEventListener(`mouseenter`,c)}catch{}finally{c=null}if(typeof m==`function`)try{m()}catch(t){e.r(`router-link unsubscribe failed`,t)}finally{m=void 0}if(o)try{clearInterval(o)}catch(t){e.r(`router-link sync interval cleanup failed`,t)}finally{o=null}})}let _=t.g(()=>{if(o&&p)return p.isExactActive;try{let e=N.base??``,t=a.to||``;return!s.value||typeof s.value.path!=`string`?!1:I(s.value.path,t,e)}catch(t){return e.r(`isExactActive computation error`,t),!1}}),v=t.g(()=>{if(o&&p)return p.isActive;try{let e=N.base??``,t=a.to||``;return!s.value||typeof s.value.path!=`string`?!1:a.exact?_.value:L(s.value.path,t,e)}catch(t){return e.r(`isActive computation error`,t),!1}}),y=t.g(()=>{let e=String(a.to||``);if(l(e))return null;if(u(e))return e;let[t,n]=e.split(`#`),[r,i]=(t||``).split(`?`),o=N.base??``,s=r||`/`;if(o&&o!==`/`){let e=f(o),t=f(s);s=t.startsWith(e)?t.slice(e.length)||`/`:t}return o+f(s||`/`)+(i?`?`+i:``)+(n?`#`+n:``)}),b=t.g(()=>{let e=(h&&h.value||a.class||``).split(/\s+/).filter(Boolean),t={};for(let n of e)t[n]=!0;return t}),x=t.g(()=>({...b.value,[a.activeClass||`active`]:v.value,[a.exactActiveClass||`exact-active`]:_.value})),S=t.g(()=>Object.keys(x.value).filter(e=>x.value[e]).join(` `)),C=t.g(()=>a.tag||`a`),w=t.g(()=>C.value===`button`),E=t.g(()=>_.value?a.ariaCurrentValue:null),D=t.g(()=>!!a.disabled),O=t.g(()=>(u(String(a.to||``))||!!a.external)&&C.value===`a`),k=t.g(()=>g&&g.value||a.style||``),A=t=>{if(!(t.defaultPrevented||t.button!==0||t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)){if(D.value){t.preventDefault();return}if(l(String(a.to||``))){try{t.preventDefault()}catch{}e.r(`Blocked unsafe javascript: URI in router-link.to`);return}O.value||(t.preventDefault(),a.replace?N.replace(a.to):N.push(a.to))}};return n.t`
|
|
2
|
+
${r.match().when(w.value,n.t`
|
|
3
3
|
<button
|
|
4
4
|
part="button"
|
|
5
|
-
class="${
|
|
6
|
-
style="${
|
|
7
|
-
aria-current="${
|
|
8
|
-
disabled="${
|
|
9
|
-
aria-disabled="${
|
|
10
|
-
tabindex="${
|
|
11
|
-
@click="${
|
|
5
|
+
class="${S.value}"
|
|
6
|
+
style="${k.value||null}"
|
|
7
|
+
aria-current="${E.value}"
|
|
8
|
+
disabled="${D.value?``:null}"
|
|
9
|
+
aria-disabled="${D.value?`true`:null}"
|
|
10
|
+
tabindex="${D.value?`-1`:null}"
|
|
11
|
+
@click="${A}"
|
|
12
12
|
>
|
|
13
13
|
<slot></slot>
|
|
14
14
|
</button>
|
|
15
|
-
`).otherwise(
|
|
15
|
+
`).otherwise(n.t`
|
|
16
16
|
<a
|
|
17
17
|
part="link"
|
|
18
|
-
href="${
|
|
19
|
-
class="${
|
|
20
|
-
style="${
|
|
21
|
-
aria-current="${
|
|
22
|
-
aria-disabled="${
|
|
23
|
-
tabindex="${
|
|
24
|
-
target="${
|
|
25
|
-
rel="${
|
|
26
|
-
@click="${
|
|
18
|
+
href="${D.value?null:y.value}"
|
|
19
|
+
class="${S.value}"
|
|
20
|
+
style="${k.value||null}"
|
|
21
|
+
aria-current="${E.value}"
|
|
22
|
+
aria-disabled="${D.value?`true`:null}"
|
|
23
|
+
tabindex="${D.value?`-1`:null}"
|
|
24
|
+
target="${O.value?`_blank`:null}"
|
|
25
|
+
rel="${O.value?`noopener noreferrer`:null}"
|
|
26
|
+
@click="${A}"
|
|
27
27
|
><slot></slot
|
|
28
28
|
></a>
|
|
29
29
|
`).done()}
|
|
30
|
-
`}),
|
|
31
|
-
|
|
30
|
+
`}),o}function I(e,t,n){if(u(t))return!1;let r=(t.split(`#`)[0]||`/`).split(`?`)[0];if(n&&n!==`/`){let e=f(n),t=f(r);r=t.startsWith(e)?t.slice(e.length)||`/`:t}return f(e)===f(r)}function L(e,t,n){if(u(t))return!1;let r=(t.split(`#`)[0]||`/`).split(`?`)[0];if(n&&n!==`/`){let e=f(n),t=f(r);r=t.startsWith(e)?t.slice(e.length)||`/`:t}let i=f(e),a=f(r);return a===`/`?i===`/`:i===a?!0:i.startsWith(a.endsWith(`/`)?a:a+`/`)}exports.DEFAULT_SCROLL_CONFIG=o,exports.activeRouterProxy=N,exports.canonicalizeBase=p,exports.clearComponentCache=C,exports.findMatchedRoute=v,exports.initRouter=F,exports.isAbsoluteUrl=u,exports.isDangerousScheme=l,exports.matchRoute=_,exports.matchRouteSSR=y,exports.normalizePathForRoute=f,exports.parseQuery=s,exports.resolveRouteComponent=T,exports.safeDecode=d,exports.serializeQuery=c,exports.useRouter=P;
|
|
32
31
|
//# sourceMappingURL=custom-elements-runtime.router.cjs.js.map
|