65 lines
57 KiB
JavaScript
65 lines
57 KiB
JavaScript
function t(t,e){var s,n,r,i;const o=tt.get();return window.__quarc.router?e?.pluginId?((n=window.__quarc).plugins??(n.plugins={}),(r=window.__quarc.plugins)[i=e.pluginId]??(r[i]={}),window.__quarc.plugins[e.pluginId].routes=t,window.__quarc.plugins[e.pluginId].routingMode=e.routingMode??"internal","root"===e.routingMode&&window.__quarc.router.resetConfig([...window.__quarc.router.config,...t])):window.__quarc.router.resetConfig([...window.__quarc.router.config,...t]):(s=window.__quarc).router??(s.router=new rt(t)),o.registerShared(rt,window.__quarc.router),o.registerShared(g,g),window.__quarc.router}function e(){return window.__quarcScopeRegistry||(window.__quarcScopeRegistry={counter:0,scopeMap:new Map,injectedStyles:new Set}),window.__quarcScopeRegistry}function s(t){const s=e();return s.scopeMap.has(t)||s.scopeMap.set(t,"q"+s.counter++),s.scopeMap.get(t)}function n(t,e,s,n){let r=s;const i=n?.alias??t,o=n?.transform,a=()=>{const t=e._nativeElement,s=t?.__inputs?.[i];if(s){
|
|
const t=s();r=o?o(t):t}else if(t){const e=t.getAttribute(i);null!==e&&(r=o?o(e):e)}return r};return a[A]=!0,a}function r(t,e,s,r){return"string"==typeof t&&e&&"_nativeElement"in e?n(t,e,s,r):n("",{},t,e)}function i(t,e,s){return"string"==typeof t&&e&&"_nativeElement"in e?n(t,e,void 0,s):n("",{},void 0,t)}function o(){return window.__quarc.currentEffect??null}function a(t){window.__quarc.currentEffect=t}function c(t,e){let s=t;const n=new Set,r=e?.equal??Object.is,i=()=>{const t=o();return t&&n.add(t),s};return i[M]=!0,i.set=t=>{r(s,t)||(s=t,p(n))},i.update=t=>{i.set(t(s))},i.asReadonly=()=>{const t=()=>i();return t[M]=!0,t},i}function l(t,e){let s,n=!0;const r=new Set,i=e?.equal??Object.is,c={destroy:()=>{},_run:()=>{n=!0,p(r)}},l=()=>{const e=o();a(c);try{const e=t();i(s,e)||(s=e)}finally{a(e)}n=!1};l();const u=()=>{const t=o();return t&&r.add(t),n&&l(),s};return u[M]=!0,u}function u(t,e){let s=!1;const n=()=>{if(s)return;const e=o();a(r);try{t()}finally{a(e)}},r={destroy:()=>{s=!0},
|
|
_run:n};return n(),r}function p(t){const e=Array.from(t);for(const t of e)t._run?.()}function h(t){return new Promise((e,s)=>{const n=document.createElement("script");n.src=t,n.type="module",n.async=!0,n.onload=()=>e(),n.onerror=()=>s(Error("Failed to load: "+t)),document.head.appendChild(n)})}async function d(t){const e=Array.isArray(t)?t:[t];for(const t of e)try{return void await h(t)}catch{}}async function m(t,e){var s;const n=R.bootstrap(t,e?.providers);return e?.externalUrls&&d(e.externalUrls),e?.enablePlugins&&(window.__quarc??(window.__quarc={}),window.__quarc.Core=R,(s=window.__quarc).plugins??(s.plugins={})),n}var g,f,v,_,C,y,w,b,R,S,x,T,q,A,I,E,M,D,O,L,P,$,W,F,k,N,B,j,H,U,z,V,J,Y,Q,Z,K,G,X,tt=class t{constructor(){this.instanceCache={},this.dependencyCache={},this.sharedInstances=this.getSharedInstances()}getSharedInstances(){var t;return(t=window.__quarc).sharedInstances??(t.sharedInstances={}),window.__quarc.sharedInstances}static get(){
|
|
return t.instance||(t.instance=new t),t.instance}createInstance(t){return this.createInstanceWithProviders(t,[])}findProvider(t,e){const s="string"==typeof t?t:t.__quarc_original_name__||t.name;return e.find(t=>("string"==typeof t.provide?t.provide:t.provide.__quarc_original_name__||t.provide.name)===s)}resolveProviderValue(t,e){if("useValue"in t)return t.useValue;if("useFactory"in t&&t.useFactory)return t.useFactory();if("useExisting"in t&&t.useExisting){const s=t.useExisting,n=this.findProvider(s,e);if(n)return this.resolveProviderValue(n,e);const r="string"==typeof s?s:s.__quarc_original_name__||s.name;return this.sharedInstances[r]||this.instanceCache[r]}return"useClass"in t&&t.useClass?this.createInstanceWithProviders(t.useClass,e):void 0}createInstanceWithProviders(t,e){if(!t)throw Error("[DI] createInstanceWithProviders called with undefined classType");try{const s=new t(...this.resolveDependenciesWithProviders(t,e)),n=t.__quarc_original_name__||t.name
|
|
;return this.instanceCache[n]=s,s}catch(e){const s=this.getReadableClassName(t),n=this.getDependencyInfo(t);throw Error(`[DI] Failed to create instance of "${s}" with providers: ${e.message}\nDependencies: ${n}`)}}getReadableClassName(t){const e=t.__quarc_original_name__;if(e)return e;const s=t.__quarc_original_name__;if(s)return s;const n=t?.name;if(n&&"Unknown"!==n&&n.length>1)return n;const r=t._quarcComponent?.[0]||t._quarcDirective?.[0];return r?.selector?r.selector+" (class)":"Unknown class"}getDependencyInfo(t){try{const e=this.getConstructorParameterTypes(t);return 0===e.length?"none":e.map((t,e)=>void 0===t?`index ${e}: undefined`:`index ${e}: ${t}`).join(", ")}catch(t){return"failed to resolve: "+t.message}}resolveDependencies(t){const e=t.__quarc_original_name__||t.name;if(this.dependencyCache[e])return this.dependencyCache[e].map(t=>{if("string"==typeof t)throw Error("[DI] Cannot resolve string token in global context: "+t);return this.createInstance(t)})
|
|
;const s=this.getConstructorParameterTypes(t);return this.dependencyCache[e]=s,s.map(t=>{if("string"==typeof t)throw Error("[DI] Cannot resolve string token in global context: "+t);return this.createInstance(t)})}resolveDependenciesWithProviders(t,e){return this.getConstructorParameterTypes(t).map(t=>this.resolveDependency(t,e))}resolveDependency(t,e){const s="string"==typeof t?t:t.__quarc_original_name__||t.name,n=this.findProvider(t,e);return n?this.resolveProviderValue(n,e):this.sharedInstances[s]?this.sharedInstances[s]:this.instanceCache[s]?this.instanceCache[s]:this.createInstanceWithProviders(t,e)}getConstructorParameterTypes(t){const e=t?.name||"Unknown";if(!t)throw Error("[DI] Cannot resolve dependencies: classType is undefined");if(t.__di_params__){const s=t.__di_params__
|
|
;for(let t=0;t<s.length;t++)if(void 0===s[t])throw Error(`[DI] Cannot resolve dependency at index ${t} for class "${e}". The dependency type is undefined. This usually means:\n 1. Circular dependency between modules\n 2. The dependency class is not exported or imported correctly\n 3. The import is type-only but used for DI`);return s}const s=Reflect.getMetadata;return s&&s("design:paramtypes",t)||[]}register(t,e){const s=t.__quarc_original_name__||t.name;this.instanceCache[s]=e}registerShared(t,e){const s=t.__quarc_original_name__||t.name;this.sharedInstances[s]=e}clear(){this.instanceCache={},this.dependencyCache={}}},et=class t{constructor(){this.components=new Map,this.componentsBySelector=new Map}static get(){return t.instance||(t.instance=new t),t.instance}register(t,e){const s=t._quarcComponent[0].imports||[];this.components.set(t,{type:t,instance:e,loaded:!1,dependencies:s}),this.componentsBySelector.set(t._quarcComponent[0].selector,t)}markAsLoaded(t,e){
|
|
const s=this.components.get(t);s&&(s.loaded=!0,s.webComponent=e)}isLoaded(t){return this.components.get(t)?.loaded??!1}getMetadata(t){return this.components.get(t)}getBySelector(t){const e=this.componentsBySelector.get(t);return e?this.components.get(e):void 0}getWebComponent(t){return this.components.get(t)?.webComponent}getDependencies(t){return this.components.get(t)?.dependencies??[]}getAllDependencies(t){const e=new Set,s=[],n=t=>{e.has(t)||(e.add(t),this.getDependencies(t).forEach(t=>{s.push(t),n(t)}))};return n(t),s}clear(){this.components.clear(),this.componentsBySelector.clear()}getAll(){return Array.from(this.components.values())}},st=class{constructor(){this.observers=new Set}next(t){for(const e of this.observers)e(t)}subscribe(t){return this.observers.add(t),{unsubscribe:()=>{this.observers.delete(t)}}}complete(){this.observers.clear()}},nt=class extends st{constructor(t){super(),this.currentValue=t}next(t){this.currentValue=t,super.next(t)}subscribe(t){
|
|
return t(this.currentValue),super.subscribe(t)}getValue(){return this.currentValue}},rt=class{constructor(t){this.config=t,this.events$=new st,this.routes=c([]),this.activeRoutes=c([]),this.rootOutlets=new Set,this.currentUrl=c("/"),this.activatedRoutePaths=l(()=>this.activeRoutes().map(t=>this.generateAbsolutePath(t))),this.currentUrl.set(location.pathname),this.setupPopStateListener(),this.initializeRouteParents(this.config,null),this.routes.set(this.config)}initializeRouteParents(t,e){for(const s of t)s.parent=e,s.children&&this.initializeRouteParents(s.children,s)}generateAbsolutePath(t){const e=[];for(e.push(t);t.parent;)e.push(t),t=t.parent;return e.reverse(),e.map(t=>t.path||"").filter(t=>t.length>0).join("/")}resetConfig(t){this.config=t,this.initializeRouteParents(t,null),this.routes.set([...t]),this.refresh()}refresh(){this.emitNavigationEvent(this.currentUrl())}isRouteMatch(t,e){
|
|
return t.routeConfig===e||t.path===e.path&&t.component===e.component&&t.loadComponent===e.loadComponent}registerActiveRoute(t){const e=this.activeRoutes();e.includes(t)||this.activeRoutes.set([...e,t])}unregisterActiveRoute(t){const e=this.activeRoutes();this.activeRoutes.set(e.filter(e=>e!==t))}clearActiveRoutes(){this.activeRoutes.set([])}withoutLeadingSlash(t){return t.startsWith("/")?t.slice(1):t}setupPopStateListener(){window.addEventListener("popstate",()=>{this.emitNavigationEvent(location.pathname)})}emitNavigationEvent(t){const e={url:t,previousUrl:this.currentUrl()};this.currentUrl.set(t),this.events$.next(e),this.notifyRootOutlets(e)}notifyRootOutlets(t){for(const e of this.rootOutlets)e.onNavigationChange(t)}registerRootOutlet(t){this.rootOutlets.add(t)}unregisterRootOutlet(t){this.rootOutlets.delete(t)}navigateByUrl(t,e){return new Promise(s=>{let n=t;if(!t.startsWith("/"))if(e?.relativeTo){const s=e.relativeTo.snapshot.url.join("/");n=s?"/"+s+"/"+t:"/"+t}else n="/"+t
|
|
;n=n.replace(/\/+/g,"/"),n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),e?.skipLocationChange||(e?.replaceUrl?history.replaceState(n,"",n):history.pushState(n,"",n)),this.emitNavigationEvent(n),s(!0)})}navigate(t,e){const s=this.createUrlFromCommands(t,e);return this.navigateByUrl(s,e)}createUrlFromCommands(t,e){let s;if(s=e?.relativeTo?"/"+(e.relativeTo.snapshot.url.join("/")||"")+"/"+t.join("/"):"/"+t.join("/"),e?.queryParams){const t=this.serializeQueryParams(e.queryParams);t&&(s+="?"+t)}return s}serializeQueryParams(t,e=""){const s=[];for(const[n,r]of Object.entries(t)){if(null==r)continue;const t=e?`${e}[${n}]`:n;"object"!=typeof r||Array.isArray(r)?s.push(`${encodeURIComponent(t)}=${encodeURIComponent(r+"")}`):s.push(this.serializeQueryParams(r,t))}return s.filter(t=>t).join("&")}};window.__quarc??(window.__quarc={}),(g=class{constructor(t,e,s){this.router=t,this._nativeElement=e,this.activatedRoute=s,this.routerLink=I("routerLink",this),
|
|
this._nativeElement.addEventListener("click",t=>{this.onClick(t)})}ngOnInit(){}ngOnDestroy(){}onClick(t){t.preventDefault();const e=this.routerLink(),s=Array.isArray(e)?e:[e],n=null!==this._nativeElement.closest("app-sidebar")?this.findActivatedRouteFromDOM():this.activatedRoute||this.getCurrentActivatedRoute()||this.findActivatedRouteFromDOM(),r=n?{relativeTo:n}:void 0;this.router.navigate(s,r).then(t=>{}).catch(t=>{})}getCurrentActivatedRoute(){const t=window.__quarc?.activatedRouteStack;return t&&t.length>0?t[t.length-1]:null}findActivatedRouteFromDOM(){let t=this._nativeElement;for(;t;){if("router-outlet"===t.tagName.toLowerCase()){const e=t.componentInstance;if(e&&"activatedRoute"in e){const t=e.activatedRoute;return this._nativeElement.closest("app-sidebar"),(e.parentRoute||t)??null}}t=t.parentElement}return null}}).__di_params__=["Router","HTMLElement","ActivatedRoute"],g._quarcDirective=[{selector:"[routerLink]"}],g.__quarc_original_name__="RouterLink",f=class{
|
|
constructor(t="",e={},s={},n=null,r=[],i=null){this.path=t,this.params=e,this.queryParams=s,this.fragment=n,this.url=r,this.routeConfig=i}},v=class{constructor(){this.__quarc_original_name__="ActivatedRoute",this.parent=null,this.outlet="primary",this._params=new nt({}),this._queryParams=new nt({}),this._fragment=new nt(null),this._url=new nt([]),this._snapshot=new f}get params(){return this._params}get queryParams(){return this._queryParams}get fragment(){return this._fragment}get url(){return this._url}get snapshot(){return this._snapshot}get routeConfig(){return this._snapshot.routeConfig??null}updateSnapshot(t,e,s,n,r,i){const o=!this.areParamsEqual(this._snapshot.params,e),a=!this.areParamsEqual(this._snapshot.queryParams,s),c=this._snapshot.fragment!==n;this._snapshot.url.join("/"),r.join("/"),this._snapshot=new f(t,e,s,n,r,i??null),o&&this._params.next(e),a&&this._queryParams.next(s),c&&this._fragment.next(n),this._url.next(r)}areParamsEqual(t,e){
|
|
const s=Object.keys(t),n=Object.keys(e);return s.length===n.length&&s.every(s=>t[s]===e[s])}},_=class{static matchRoutesRecursive(t,e,s,n){const r=this.findMatchingRoute(t,e,s,null,{},{});r&&n.push(r.route)}static async findMatchingRouteAsync(t,e,s,n,r,i){const o=e.length-s;for(const o of t){const t=(o.path||"").split("/").filter(t=>t.length>0);if(0===t.length)continue;if(!this.doesRouteMatch(t,e,s))continue;const a=await this.processRouteAsync(o,t,e,s,n,r,i);if(a)return a}for(const a of t){const t=(a.path||"").split("/").filter(t=>t.length>0);if(0!==t.length)continue;const c=!(!a.component&&!a.loadComponent),l=!(!a.children&&!a.loadChildren);if(!(c&&o>0)){if(!c&&l&&o>0){const o=await this.processRouteAsync(a,t,e,s,n,r,i);if(o)return o;continue}if(0===o){const o=await this.processRouteAsync(a,t,e,s,n,r,i);if(o)return o}}}return null}static async processRouteAsync(t,e,s,n,r,i,o){const a={...i};this.extractParams(e,s,n,a);const c={...o,...t.data},l=n+e.length
|
|
;if(t.component||t.loadComponent)return{route:this.createActivatedRoute(t,a,c,s,n,e.length,r),consumedSegments:l,hasComponent:!0};let u=[];if(t.children?u=t.children:t.loadChildren&&(u=await t.loadChildren()),u.length>0){const i=this.createActivatedRoute(t,a,c,s,n,e.length,r),o=await this.findMatchingRouteAsync(u,s,l,i,a,c);if(o)return o}return null}static findMatchingRoute(t,e,s,n,r,i){const o=e.length-s;for(const o of t){const t=(o.path||"").split("/").filter(t=>t.length>0);if(0===t.length)continue;if(!this.doesRouteMatch(t,e,s))continue;const a=this.processRoute(o,t,e,s,n,r,i);if(a)return a}for(const a of t){const t=(a.path||"").split("/").filter(t=>t.length>0);if(0!==t.length)continue;const c=!(!a.component&&!a.loadComponent),l=!!a.children;if(!(c&&o>0)){if(!c&&l&&o>0){const o=this.processRoute(a,t,e,s,n,r,i);if(o)return o;continue}if(0===o){const o=this.processRoute(a,t,e,s,n,r,i);if(o)return o}}}return null}static processRoute(t,e,s,n,r,i,o){const a={...i}
|
|
;this.extractParams(e,s,n,a);const c={...o,...t.data},l=n+e.length;if(t.component||t.loadComponent)return{route:this.createActivatedRoute(t,a,c,s,n,e.length,r),consumedSegments:l,hasComponent:!0};if(t.children&&t.children.length>0){const i=this.createActivatedRoute(t,a,c,s,n,e.length,r),o=this.findMatchingRoute(t.children,s,l,i,a,c);if(o)return o}return null}static createActivatedRoute(t,e,s,n,r,i,o){const a=new v;return a.path=t.path,a.component=t.component,a.loadComponent=t.loadComponent,a.loadChildren=t.loadChildren,a.data=s,a.parent=o,t.children&&(a.children=t.children),a.updateSnapshot(t.path??"",e,{},null,n.slice(r,r+i),t),t.parent=o??void 0,a}static doesRouteMatch(t,e,s){if(0===t.length&&s>=e.length)return!0;if(s+t.length>e.length)return!1;for(let n=0;n<t.length;n++){const r=t[n],i=e[s+n];if(!r.startsWith(":")&&r!==i)return!1}return!0}static extractParams(t,e,s,n){for(let r=0;r<t.length;r++){const i=t[r],o=e[s+r];i.startsWith(":")&&(n[i.substring(1)]=o)}}},(C=class{
|
|
constructor(t,e){this.router=t,this.element=e,this.urlSegments=[],this.parentUrlSegments=[],this.parentRoutes=[],this.navigationChange$=new st,this.childOutlets=new Set,this.isRootOutlet=!1,this.initialize()}async initialize(){this.element.innerHTML="";const t=this.getParentRouterOutlet();if(t){if(this.parentRouterOutlet=t,this.parentUrlSegments=t.urlSegments,t.registerChildOutlet(this),!t.activatedRoute)throw Error("Parent ActivatedRoute not set!");this.parentRoute=t.activatedRoute,this.parentRoutes=await this.loadRoutes(t.activatedRoute)}else this.isRootOutlet=!0,this.router.registerRootOutlet(this),this.parentUrlSegments=location.pathname.split("/").filter(t=>t.length>0),this.parentRoutes=this.router.config,this.parentRoute=void 0;const e=await this.getMatchedRoutes();await this.updateContent(e)}onNavigationChange(t){this.handleNavigationChange(t)}async handleNavigationChange(t){
|
|
const e=t.url.split("?")[0].split("#")[0].split("/").filter(t=>t.length>0),s=this.parseQueryParams(t.url),n=this.parseFragment(t.url);this.parentRouterOutlet?(this.parentUrlSegments=this.parentRouterOutlet.urlSegments,this.parentRouterOutlet.activatedRoute&&(this.parentRoute=this.parentRouterOutlet.activatedRoute,this.parentRoutes=await this.loadRoutes(this.parentRouterOutlet.activatedRoute))):(this.parentUrlSegments=e,this.parentRoutes=this.router.config,this.parentRoute=void 0);const r=await this.getMatchedRoutes(),i=r[0],o=i?.snapshot.params??{};if(this.hasComponentChanged(this.activatedRoute,i)||!this.activatedRoute)await this.updateContent(r);else if(this.activatedRoute&&i){const t=i.url.getValue();this.activatedRoute.updateSnapshot(i.path??"",o,s,n||null,t,i.routeConfig??void 0),this.urlSegments=this.calculateUrlSegments()}this.navigationChange$.next(t),this.notifyChildOutlets(t)}hasComponentChanged(t,e){
|
|
return!(!t&&!e||t&&e&&(t.component??t.loadComponent)===(e.component??e.loadComponent)&&this.getFullParentPath(t)===this.getFullParentPath(e))}getFullParentPath(t){const e=[];let s=t.parent;for(;s;)s.path&&e.unshift(s.path),s=s.parent;return e.join("/")}parseQueryParams(t){const e=t.split("?")[1]?.split("#")[0]??"",s={};if(!e)return s;for(const t of e.split("&")){const[e,n]=t.split("=");e&&(s[decodeURIComponent(e)]=decodeURIComponent(n??""))}return s}parseFragment(t){return t.split("#")[1]??""}areParamsEqual(t,e){if(!t&&!e)return!0;if(!t||!e)return!1;const s=Object.keys(t),n=Object.keys(e);return s.length===n.length&&s.every(s=>t[s]===e[s])}notifyChildOutlets(t){for(const e of this.childOutlets)e.onNavigationChange(t)}registerChildOutlet(t){this.childOutlets.add(t)}unregisterChildOutlet(t){this.childOutlets.delete(t)}async updateContent(t){this.childOutlets.clear(),this.activatedRoute&&(this.router.unregisterActiveRoute(this.activatedRoute),
|
|
this.popActivatedRouteFromStack(this.activatedRoute),this.activatedRoute=void 0),t.length>0?(this.activatedRoute=t[0],this.urlSegments=this.calculateUrlSegments(),this.router.registerActiveRoute(this.activatedRoute),this.pushActivatedRouteToStack(this.activatedRoute)):this.urlSegments=this.parentUrlSegments,await this.renderComponents(t)}pushActivatedRouteToStack(t){var e;(e=window.__quarc).activatedRouteStack??(e.activatedRouteStack=[]),window.__quarc.activatedRouteStack.push(t)}popActivatedRouteFromStack(t){if(!window.__quarc.activatedRouteStack)return;const e=window.__quarc.activatedRouteStack.indexOf(t);-1!==e&&window.__quarc.activatedRouteStack.splice(e,1)}calculateUrlSegments(){if(!this.activatedRoute?.path)return this.parentUrlSegments;const t=this.activatedRoute.url.getValue().length;return this.parentUrlSegments.slice(t)}async loadRoutes(t){let e=[];t.children?e=t.children:t.loadChildren&&(e=await t.loadChildren());for(const s of e)s.parent=t;return e}getParentRouterOutlet(){
|
|
let t=this.element.parentElement;for(;t;){if("router-outlet"===t.tagName.toLowerCase())return t.componentInstance;t=t.parentElement}return null}async getMatchedRoutes(){const t=await _.findMatchingRouteAsync(this.parentRoutes,this.parentUrlSegments,0,this.parentRouterOutlet?.activatedRoute??null,{},{});return t?[t.route]:[]}async renderComponents(t){const e=[];for(const s of t){const t=await this.resolveComponentSelector(s);t&&e.push(`<${t}></${t}>`)}this.element.innerHTML=e.join("")}async resolveComponentSelector(t){if("string"==typeof t.component)return t.component;if("function"==typeof t.component&&!this.isComponentType(t.component))return await t.component();let e;return t.component&&this.isComponentType(t.component)?e=t.component:t.loadComponent&&(e=await t.loadComponent()),e?(w.registerWithDependencies(e),e._quarcComponent[0].selector):null}isComponentType(t){return"function"==typeof t&&"_quarcComponent"in t}destroy(){
|
|
this.activatedRoute&&(this.router.unregisterActiveRoute(this.activatedRoute),this.popActivatedRouteFromStack(this.activatedRoute)),this.isRootOutlet?this.router.unregisterRootOutlet(this):this.parentRouterOutlet&&this.parentRouterOutlet.unregisterChildOutlet(this),this.navigationChange$.complete(),this.childOutlets.clear()}}).__di_params__=["Router","HTMLElement"],C._quarcComponent=[{selector:"router-outlet",style:"router-outlet{ display: contents; }",template:""}],C._scopeId="cxbv0wn",C.__quarc_original_name__="RouterOutlet",(y=class{constructor(t,e){this.router=t,this._nativeElement=e,this.routerLinkActive=I("routerLinkActive",this,"routerLinkActive",this,""),this.routerLinkActiveOptions=I("routerLinkActiveOptions",this,"routerLinkActiveOptions",this,{}),this.updateActiveState(),this.subscription=this.router.events$.subscribe(()=>{this.updateActiveState()}),u(()=>{this.routerLinkActive(),this.routerLinkActiveOptions(),this.updateActiveState()})}ngOnDestroy(){
|
|
this.subscription?.unsubscribe()}updateActiveState(){const t=this.checkIsActive(),e=this.routerLinkActive();e&&(t?this._nativeElement.classList.add(e):this._nativeElement.classList.remove(e))}checkIsActive(){let t;const e=this._nativeElement.__inputs;if(e?.routerLink&&(t=e.routerLink()),t||(t=this._nativeElement.getAttribute("router-link")||this._nativeElement.getAttribute("routerLink")||void 0),!t)return!1;const s=Array.isArray(t)?t.join("/"):t,n=this.normalizeUrl(location.pathname),r=this.normalizeUrl(s);return this.routerLinkActiveOptions().exact?n===r:n===r||n.startsWith(r+"/")}normalizeUrl(t){let e=t.startsWith("/")?t:"/"+t;return e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e}}).__di_params__=["Router","HTMLElement"],y._quarcDirective=[{selector:"[routerLinkActive]"}],y.__quarc_original_name__="RouterLinkActive",w=class t{static get registeredComponents(){var t;return(t=window.__quarc).registeredComponents??(t.registeredComponents=new Map),window.__quarc.registeredComponents}
|
|
static get componentTypes(){var t;return(t=window.__quarc).componentTypes??(t.componentTypes=new Map),window.__quarc.componentTypes}static registerWithDependencies(t){const e=D.getSelector(t),s=D.selectorToTagName(e);if(this.registeredComponents.has(s))return!1;const n=t._quarcComponent?.[0];if(!n)return!1;const r=n.imports||[];for(const t of r)if(D.isComponentType(t)){const e=t;this.registerWithDependencies(e)}return this.tryRegister(t)}static tryRegister(e){const s=D.getSelector(e),n=D.selectorToTagName(s);if(this.registeredComponents.has(n))return!1;try{const s=class extends S{constructor(){super()}connectedCallback(){const e=t.componentTypes.get(n);if(e&&!this.isInitialized()){const s=t.createComponentInstance(e,this);this.setComponentInstance(s,e)}super.connectedCallback()}};return customElements.define(n,s),this.registeredComponents.set(n,s),this.componentTypes.set(n,e),!0}catch(t){return!1}}static getWebComponentInstances(){var t
|
|
;return(t=window.__quarc).webComponentInstances??(t.webComponentInstances=new Map),window.__quarc.webComponentInstances}static generateWebComponentId(){var t;return(t=window.__quarc).webComponentIdCounter??(t.webComponentIdCounter=0),"wc-"+window.__quarc.webComponentIdCounter++}static createComponentInstance(t,e){const s=tt.get(),n=e,r=this.generateWebComponentId();this.getWebComponentInstances().set(r,n);const i=[{provide:HTMLElement,useValue:e},{provide:v,useValue:this.findActivatedRouteFromElement(e)}],o=t._quarcComponent?.[0];if(o?.providers)for(const t of o.providers)"function"==typeof t&&(i.some(e=>e.provide===t)||i.push({provide:t,useClass:t}));return s.createInstanceWithProviders(t,i)}static findActivatedRouteFromElement(t){let e=t;const s=[];for(;e;){if(s.push(`${e.tagName.toLowerCase()}${e.id?"#"+e.id:""}${e.className?"."+e.className.replace(/\s+/g,"."):""}`),"router-outlet"===e.tagName.toLowerCase()){const t=e.componentInstance
|
|
;if(t&&"activatedRoute"in t)return t.activatedRoute??null}e=e.parentElement}const n=window.__quarc?.activatedRouteStack;return n&&n.length>0?n[n.length-1]:null}static create(t,e){const s=e??D.getSelector(t),n=D.selectorToTagName(s);this.registerWithDependencies(t);let r=document.querySelector(n);return r||(r=document.createElement(n),document.body.appendChild(r)),r}static createInElement(t,e){const s=D.selectorToTagName(D.getSelector(t));this.registerWithDependencies(t);const n=document.createElement(s);return e.appendChild(n),n}static createFromElement(t,e){const s=D.selectorToTagName(D.getSelector(t));if(this.registerWithDependencies(t),e.tagName.toLowerCase()===s){const s=e;if(!s.isInitialized()){const e=this.createComponentInstance(t,s);s.setComponentInstance(e,t)}return s}const n=document.createElement(s);return e.replaceWith(n),n}static isRegistered(t){const e=D.selectorToTagName(t);return this.registeredComponents.has(e)}static getRegisteredTagName(t){
|
|
const e=D.selectorToTagName(t);return this.registeredComponents.has(e)?e:void 0}},(b=class t{constructor(t){this.component=t,this.injector=tt.get(),this.registry=et.get(),this.registry.register(t),this.instance={}}static bootstrap(e,s,n){t.MainComponent=e;const r=new t(e),i=et.get();i.getAllDependencies(e).forEach(t=>{i.isLoaded(t)||r.preloadComponent(t)}),n??(n=document.querySelector(e._quarcComponent[0].selector)??document.body);const o=r.createWebComponent(n);return t.mainWebComponent=o,i.markAsLoaded(e,o),r}preloadComponent(t){this.registry.register(t)}createWebComponent(t){const e=w.createFromElement(this.component,t);return this.webComponent=e,e}static getMainWebComponent(){return t.mainWebComponent}getWebComponent(){return this.webComponent}static loadComponent(t,e){tt.get();const s=et.get();let n=s.getMetadata(t);if(n||(s.register(t),n=s.getMetadata(t)),n&&!n.loaded){const n=e??document.querySelector(t._quarcComponent[0].selector)
|
|
;if(!n)throw Error("Cannot find element for component: "+t._quarcComponent[0].selector);const r=w.createFromElement(t,n);return s.markAsLoaded(t,r),r}return n.webComponent}static getRegistry(){return et.get()}}).MainComponent=null,b.mainWebComponent=null,R=b,S=class extends HTMLElement{constructor(){super(),this._initialized=!1,this.directiveInstances=[],this.isRendering=!1}setComponentInstance(t,e){this.componentInstance=t,this.componentType=e,e._scopeId&&(this.compiledScopeId=e._scopeId,this.runtimeScopeId=s(e._scopeId)),this.initialize()}getComponentOptions(){return this.componentType._quarcComponent[0]}isInitialized(){return this._initialized}connectedCallback(){this.componentInstance&&this.initialize()}disconnectedCallback(){this.destroy()}initialize(){if(!this.componentInstance||!this.componentType||this._initialized)return;const t=this.componentType._quarcComponent[0].encapsulation??2
|
|
;1!==t||this._shadowRoot?2===t&&this.runtimeScopeId&&this.setAttribute("_nghost-"+this.runtimeScopeId,""):this._shadowRoot=this.attachShadow({mode:"open"}),this.initializePipes(),this._initialized=!0,this.renderComponent()}initializePipes(){if(!this.componentInstance||!this.componentType)return;const t=this.componentType._quarcPipes||[],e=q.get(),s={};for(const n of t){e.register(n);const t=e.getPipeMetadata(n);if(t){const e=new n;s[t.name]=e}}this.componentInstance._pipes=s}renderComponent(){if(!this.componentInstance||!this.componentType)return;const t=this.componentType._quarcComponent[0].style??"",s=this.componentType._quarcComponent[0].encapsulation??2,n=this._shadowRoot??this;if(t)if(1===s){const e=document.createElement("style");e.textContent=t,n.appendChild(e)}else if(2===s&&this.runtimeScopeId){const s=e();if(!s.injectedStyles.has(this.runtimeScopeId)){const e=document.createElement("style");e.textContent=this.transformScopeAttributes(t),
|
|
e.setAttribute("data-scope-id",this.runtimeScopeId),document.head.appendChild(e),s.injectedStyles.add(this.runtimeScopeId)}}else if(0===s){const e=document.createElement("style");e.textContent=t,n.appendChild(e)}this.renderEffect=u(()=>this.renderTemplate()),queueMicrotask(()=>{this.callNgOnInit()})}renderTemplate(){if(!this.componentInstance||!this.componentType)return;if(this.isRendering)return;this.isRendering=!0;const t=this.componentType._quarcComponent[0].template??"",e=this.componentType._quarcComponent[0].encapsulation??2,s=this._shadowRoot??this;for(T.destroyInstances(this.directiveInstances),this.directiveInstances=[],O.destroyEffects(s);s.firstChild;)s.removeChild(s.firstChild);new O(s,this.componentInstance,t).render(),2===e&&this.runtimeScopeId&&this.applyScopeAttributes(s),this.isRendering=!1,queueMicrotask(()=>{this.applyDirectives()})}rerender(){this.componentInstance&&this.componentType&&this._initialized&&this.renderTemplate()}applyDirectives(){
|
|
const t=this.componentType?._quarcDirectives;if(!t||0===t.length||!this.runtimeScopeId)return;const e=this._shadowRoot??this;this.directiveInstances=T.apply(e,this.runtimeScopeId,t)}getAttributes(){return Array.from(this.attributes).map(t=>({name:t.name,value:t.value}))}toChildInfo(t){return{tagName:t.tagName.toLowerCase(),element:t,attributes:Array.from(t.attributes).map(t=>({name:t.name,value:t.value})),textContent:t.textContent}}getChildElements(){return Array.from((this._shadowRoot??this).querySelectorAll("*")).map(t=>this.toChildInfo(t))}getChildElementsByTagName(t){return this.getChildElements().filter(e=>e.tagName===t.toLowerCase())}getChildElementsBySelector(t){return Array.from((this._shadowRoot??this).querySelectorAll(t)).map(t=>this.toChildInfo(t))}getHostElement(){return this}getShadowRoot(){return this._shadowRoot}applyScopeAttributes(t){if(!this.runtimeScopeId)return;const e="_ngcontent-"+this.runtimeScopeId;t.querySelectorAll("*").forEach(t=>t.setAttribute(e,"")),
|
|
Array.from(t.children).forEach(t=>t.setAttribute(e,""))}transformScopeAttributes(t){return this.compiledScopeId&&this.runtimeScopeId?t.replace(RegExp("_nghost-"+this.compiledScopeId,"g"),"_nghost-"+this.runtimeScopeId).replace(RegExp("_ngcontent-"+this.compiledScopeId,"g"),"_ngcontent-"+this.runtimeScopeId):t}destroy(){this.callNgOnDestroy(),this.renderEffect?.destroy(),T.destroyInstances(this.directiveInstances),this.directiveInstances=[];const t=this._shadowRoot??this;for(O.destroyEffects(t);t.firstChild;)t.removeChild(t.firstChild);this._initialized=!1}callNgOnInit(){this.componentInstance&&"ngOnInit"in this.componentInstance&&this.componentInstance.ngOnInit()}callNgOnDestroy(){this.componentInstance&&"ngOnDestroy"in this.componentInstance&&this.componentInstance.ngOnDestroy()}},x=class t{constructor(){this.directives=new Map}static get(){return t.instance||(t.instance=new t),t.instance}register(t){if(this.directives.has(t))return;const e=t._quarcDirective?.[0];if(!e)return
|
|
;const s=this.createSelectorMatcher(e.selector);this.directives.set(t,{type:t,options:e,selectorMatcher:s})}createSelectorMatcher(t){if(t.startsWith("[")&&t.endsWith("]")){const e=t.slice(1,-1);return t=>t.hasAttribute(e)}if(t.startsWith(".")){const e=t.slice(1);return t=>t.classList.contains(e)}return t.includes("["),e=>e.matches(t)}getMatchingDirectives(t){const e=[];for(const s of this.directives.values())s.selectorMatcher(t)&&e.push(s);return e}getDirectiveMetadata(t){return this.directives.get(t)}isRegistered(t){return this.directives.has(t)}getSelector(t){return this.directives.get(t)?.options.selector}},(T=class{static apply(t,e,s){const n=[];for(const t of s)this.registry.register(t);for(const r of s){const s=r._quarcDirective?.[0]?.selector;if(!s)continue;const i=`[_ngcontent-${e}]${s}, ${this.convertToDataBindSelector(s,e)}`,o=t.querySelectorAll(i);for(const t of Array.from(o)){const e=this.createDirectiveForElement(r,t);e&&n.push(e)}}return n}
|
|
static createDirectiveForElement(t,e){const s=tt.get(),n=[{provide:HTMLElement,useValue:e}],r=this.findActivatedRouteFromElement(e);n.push({provide:v,useValue:r});const i=s.createInstanceWithProviders(t,n);i._nativeElement=e;const o={directive:i,element:e,type:t,effects:[]};return this.bindInputs(o,e),this.bindHostListeners(o,e),this.bindHostBindings(o,e),i.ngOnInit&&i.ngOnInit(),o}static bindInputs(t,e){const s=t.type._quarcDirective?.[0],n=s?.inputs??[],r=t.directive;for(const t of n){const s=e.getAttribute(`[${t}]`)??e.getAttribute(t);null!==s&&("function"==typeof r[t]&&r[t].set?r[t].set(s):r[t]=s)}}static bindHostListeners(t,e){const s=t.directive,n=Object.getPrototypeOf(s);if(n.__hostListeners)for(const[t,r]of Object.entries(n.__hostListeners)){const n=t=>{"function"==typeof s[r]&&s[r](t)};e.addEventListener(t,n)}}static bindHostBindings(t,e){const s=t.directive,n=Object.getPrototypeOf(s);if(n.__hostBindings)for(const[r,i]of Object.entries(n.__hostBindings)){const n=u(()=>{
|
|
const t="function"==typeof s[r]?s[r]():s[r];if(i.startsWith("class.")){const s=i.slice(6);t?e.classList.add(s):e.classList.remove(s)}else if(i.startsWith("style.")){const s=i.slice(6);e.style.setProperty(s,t??"")}else if(i.startsWith("attr.")){const s=i.slice(5);null!=t?e.setAttribute(s,t+""):e.removeAttribute(s)}else e[i]=t});t.effects.push(n)}}static destroyInstances(t){for(const e of t){for(const t of e.effects)t.destroy();e.directive.ngOnDestroy&&e.directive.ngOnDestroy()}}static convertToDataBindSelector(t,e){const s=t.match(/^\[(\w+)\]$/);if(s){const t=s[1];return`[_ngcontent-${e}][${this.camelToKebab(t)}]`}return`[_ngcontent-${e}]${t}`}static camelToKebab(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}static findActivatedRouteFromElement(t){let e=t;for(;e;){if("router-outlet"===e.tagName.toLowerCase()){const t=e.componentInstance;if(t&&"activatedRoute"in t)return t.activatedRoute??null}e=e.parentElement}const s=window.__quarc?.activatedRouteStack
|
|
;return s&&s.length>0?s[s.length-1]:null}}).registry=x.get(),q=class t{constructor(){this.pipes=new Map,this.pipeMetadata=new Map}static get(){return t.instance||(t.instance=new t),t.instance}register(t){const e=t._quarcPipe?.[0];if(!e)return;const s=e.name,n=!1!==e.pure;this.pipes.set(s,t),this.pipeMetadata.set(t,{name:s,pure:n})}getPipe(t){return this.pipes.get(t)}getPipeMetadata(t){return this.pipeMetadata.get(t)}getAllPipes(){return new Map(this.pipes)}},A=Symbol("inputSignal"),r.required=i,I=r,E=Symbol("outputEmitter"),M=Symbol("signal"),D=class{static selectorToTagName(t){return t.toLowerCase().replace(/[^a-z0-9-]/g,"-")}static isComponentType(t){return!("function"!=typeof t||!t._quarcComponent)||!(!t||"object"!=typeof t||!t._quarcComponent)}static getSelector(t){return t._quarcComponent?.[0]?.selector||""}},O=class t{constructor(t,e,s){for(this.ngContainerMarkers=[],this.currentContext=null,this.container=t,this.component=e,this.template=s??"",
|
|
this.originalContent=document.createDocumentFragment();t.firstChild;)this.originalContent.appendChild(t.firstChild);t.templateFragment=this,t.component=e,t.template=this.template,t.originalContent=this.originalContent}render(){if(!this.template)return;const t=document.createElement("template");t.innerHTML=this.template;const e=t.content.cloneNode(!0);this.processStructuralDirectives(e);const s=document.createElement("div");for(;e.firstChild;)s.appendChild(e.firstChild);for(this.processPropertyBindings(s);s.firstChild;)this.container.appendChild(s.firstChild)}processStructuralDirectives(t){this.processSelectFor(t);const e=Array.from(t.querySelectorAll("ng-container"));for(const t of e)this.processNgContainer(t)}processSelectFor(t){for(const e of Array.from(t.querySelectorAll("select,optgroup"))){const t=document.createTreeWalker(e,NodeFilter.SHOW_COMMENT),s=[];let n;for(;n=t.nextNode();)(n.textContent||"").startsWith("F:")&&s.push(n);for(const t of s)this.expandFor(e,t)}}expandFor(t,e){
|
|
const[,s,n]=(e.textContent||"").split(":"),r=[];let i=e.nextSibling;for(;i&&(8!==i.nodeType||"/F"!==i.textContent);)1===i.nodeType&&r.push(i),i=i.nextSibling;if(r.length)try{const o=this.evaluateExpression(n);if(!o)return;for(const n of Array.isArray(o)?o:Object.values(o))for(const i of r){const r=i.cloneNode(!0);r.__quarcContext={[s]:n},t.insertBefore(r,e)}r.forEach(t=>t.remove()),e.remove(),i?.parentNode?.removeChild(i)}catch{}}processNgContainer(t){const e=t.getAttribute("*ngIf"),s=t.getAttribute("*ngFor"),n=t.parentNode;if(!n)return;let r="ng-container-start";e&&(r+=` *ngIf="${e}"`),s&&(r+=` *ngFor="${s}"`);const i=document.createComment(r),o=document.createComment("ng-container-end"),a=t.innerHTML;if(this.ngContainerMarkers.push({startMarker:i,endMarker:o,condition:e||void 0,originalTemplate:a,ngForExpression:s||void 0}),n.insertBefore(i,t),s)this.processNgForDirective(t,s,n,o);else if(e)this.processNgIfDirective(t,e,n,o);else{for(;t.firstChild;)n.insertBefore(t.firstChild,t)
|
|
;n.insertBefore(o,t),t.remove()}}processNgIfDirective(t,e,s,n){const r=t.__quarcContext,{condition:i,aliasVariable:o}=this.parseNgIfExpression(e);try{const e=this.evaluateExpressionWithContext(i,r);if(!e)return s.insertBefore(n,t),void t.remove();if(o){const n={...r,[o]:e},i=t.childNodes,a=[];for(;i.length>0;)a.push(i[0]),s.insertBefore(i[0],t);for(const t of a)1===t.nodeType&&(t.__quarcContext=n,this.propagateContextToChildren(t,n))}else for(;t.firstChild;)s.insertBefore(t.firstChild,t);s.insertBefore(n,t),t.remove()}catch{s.insertBefore(n,t),t.remove()}}parseNgIfExpression(t){const e=t.match(/^(.+);\s*let\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*$/);return e?{condition:e[1].trim(),aliasVariable:e[2].trim()}:{condition:t.trim()}}propagateContextToChildren(t,e){const s=t.querySelectorAll("*");for(const t of Array.from(s))t.__quarcContext=e}processNgForDirective(e,s,n,r){
|
|
const i=s.split(";").map(t=>t.trim())[0],o=i.match(/^let\s+(\w+)\s+of\s+(.+)$/),a=i.match(/^let\s+(\w+)\s+in\s+(.+)$/),c=o||a,l=!!a;if(!c)return n.insertBefore(r,e),void e.remove();const p=c[1],h=c[2],d=e.innerHTML,m=document.createComment("ngFor-start: "+s),g=e.__quarcContext;n.insertBefore(m,e),n.insertBefore(r,e),e.remove(),this.registerEffect(this.container,u(()=>{let e=m.nextSibling;for(;e&&e!==r;){const s=e.nextSibling;1===e.nodeType&&t.destroyEffects(e),e.parentNode?.removeChild(e),e=s}try{const t=this.evaluateExpressionWithContext(h,g);if(null==t)return;const e=document.createDocumentFragment();if(l)for(const s in t)({}).hasOwnProperty.call(t,s)&&this.renderForItem(e,d,p,s,g);else{const s=Array.isArray(t)?t:Object.values(t);for(const t of s)this.renderForItem(e,d,p,t,g)}n.insertBefore(e,r),this.reapplyDirectives()}catch{}}))}getWebComponent(){let t=this.container;for(;t;){if(t instanceof S)return t;t=t.parentElement}return null}reapplyDirectives(){const t=this.getWebComponent()
|
|
;t&&queueMicrotask(()=>t.applyDirectives())}renderForItem(t,e,s,n,r){const i={...r,[s]:n},o=document.createElement("template");o.innerHTML=e;const a=o.content;for(const t of Array.from(a.querySelectorAll("*")))t.__quarcContext=i;this.processStructuralDirectivesWithContext(a,i);const c=document.createElement("div");for(;a.firstChild;)c.appendChild(a.firstChild);for(this.processPropertyBindings(c),this.applyScopeAttributes(c);c.firstChild;)t.appendChild(c.firstChild)}getScopeId(){let t=this.container;for(;t;){for(const e of Array.from(t.attributes))if(e.name.startsWith("_nghost-"))return e.name.substring(8);t=t.parentElement}return null}applyScopeAttributes(t){const e=this.getScopeId();if(!e)return;const s="_ngcontent-"+e;t.querySelectorAll("*").forEach(t=>t.setAttribute(s,"")),Array.from(t.children).forEach(t=>t.setAttribute(s,""))}processStructuralDirectivesWithContext(t,e){const s=Array.from(t.querySelectorAll("ng-container"));for(const t of s)t.__quarcContext=e,
|
|
this.processNgContainer(t)}evaluateCondition(t){try{return Function("component",`with(component) { return ${t}; }`)(this.component)}catch{return!1}}evaluateConditionWithContext(t,e){try{const s={...this.component,...e||{}};return Function("c",`with(c) { return ${t}; }`)(s)}catch{return!1}}rerenderFragment(t){if(t<0||t>=this.ngContainerMarkers.length)return;const e=this.ngContainerMarkers[t],{startMarker:s,endMarker:n,condition:r,originalTemplate:i}=e;let o=s.nextSibling;for(;o&&o!==n;){const t=o.nextSibling;o.remove(),o=t}if(!r||this.evaluateCondition(r)){const t=document.createElement("div");t.innerHTML=i;const e=document.createDocumentFragment();for(;t.firstChild;)e.appendChild(t.firstChild);const r=document.createElement("div");r.appendChild(e),this.processPropertyBindings(r);const o=s.parentNode;if(o)for(;r.firstChild;)o.insertBefore(r.firstChild,n)}}rerenderAllFragments(){for(let t=0;t<this.ngContainerMarkers.length;t++)this.rerenderFragment(t)}getFragmentMarkers(){
|
|
return this.ngContainerMarkers}processPropertyBindings(t){const e=Array.from(t.querySelectorAll("*"));for(const t of e)this.currentContext=this.buildContextForElement(t),this.processElementBindings(t),this.currentContext=null}buildContextForElement(t){const e=[];let s=t;for(;s&&(s.__quarcContext&&e.unshift(s.__quarcContext),!s.component);)s=s.parentElement;const n=Object.create(this.component);for(const t of e)Object.assign(n,t);return n}processElementBindings(t){const e=[],s=Array.from(t.attributes);for(const n of s)if(n.name.startsWith("(")&&n.name.endsWith(")"))this.processOutputBinding(t,n.name,n.value),e.push(n.name);else if(n.name.startsWith("[")&&n.name.endsWith("]")){const s=n.name.slice(1,-1),r=n.value;if(s.startsWith("attr."))this.processAttrBinding(t,s.slice(5),r);else if(s.startsWith("style."))this.processStyleBinding(t,s.slice(6),r);else if(s.startsWith("class."))this.processClassBinding(t,s.slice(6),r);else if(this.isCustomElement(t))this.processInputBinding(t,s,r);else{
|
|
const e=this.kebabToCamel(s);this.processDomPropertyBinding(t,e,r),this.processInputBinding(t,e,r),this.setInputAttribute(t,s,r)}e.push(n.name)}else if("data-bind"===n.name)this.processDataBind(t,n.value),e.push(n.name);else if(n.name.startsWith("data-input-")){const s=n.name.slice(11);this.processInputBinding(t,s,n.value),e.push(n.name)}else if(n.name.startsWith("data-on-")){const s=n.name.slice(8);this.processDataOutputBinding(t,s,n.value),e.push(n.name)}else"data-quarc-attr-bindings"===n.name&&(this.processQuarcAttrBindings(t,n.value),e.push(n.name));for(const s of e)t.removeAttribute(s)}processQuarcAttrBindings(t,e){try{const s=JSON.parse(e.replace(/'/g,"'").replace(/'/g,'"'));for(const{attr:e,expr:n}of s)this.setAttr(t,e,this.eval(n))}catch{}}isCustomElement(t){return t.tagName.includes("-")}processOutputBinding(t,e,s){const n=this.camelToKebab(e.slice(1,-1));this.processDataOutputBinding(t,n,s)}processDataOutputBinding(t,e,s){const n=this.currentContext??this.component
|
|
;t.addEventListener(e,t=>{try{Function("c","$event",`with(c){return ${s}}`)(n,t.detail??t)}catch{}})}processDataBind(t,e){const s=this.currentContext??this.component;this.registerEffect(t,u(()=>{try{t.innerHTML=(this.evalWithContext(e,s)??"")+""}catch{}}))}processInputBinding(t,e,s){t.__inputs||(t.__inputs={});const n=this.currentContext??this.component,r=c(this.evalWithContext(s,n));t.__inputs[e]=r,this.registerEffect(t,u(()=>{try{r.set(this.evalWithContext(s,n))}catch{}}))}processAttrBinding(t,e,s){const n=this.currentContext??this.component;this.registerEffect(t,u(()=>{try{this.setAttr(t,e,this.evalWithContext(s,n))}catch{}}))}setAttr(t,e,s){null==s||!1===s?t.removeAttribute(e):t.setAttribute(e,!0===s?"":s+"")}eval(t){return Function("c",`with(c){return ${t}}`)(this.currentContext??this.component)}evalWithContext(t,e){return Function("c",`with(c){return ${t}}`)(e)}registerEffect(t,e){t.__effects||(t.__effects=[]),t.__effects.push(e)}processStyleBinding(t,e,s){
|
|
const n=this.currentContext??this.component,r=e.replace(/([A-Z])/g,"-$1").toLowerCase();this.registerEffect(t,u(()=>{try{const e=this.evalWithContext(s,n);null==e||!1===e?t.style.removeProperty(r):t.style.setProperty(r,e+"")}catch{}}))}processClassBinding(t,e,s){const n=this.currentContext??this.component;this.registerEffect(t,u(()=>{try{this.evalWithContext(s,n)?t.classList.add(e):t.classList.remove(e)}catch{}}))}processDomPropertyBinding(t,e,s){const n=this.currentContext??this.component,r={innerhtml:"innerHTML",textcontent:"textContent",innertext:"innerText",classname:"className"}[e.toLowerCase()]??e;this.registerEffect(t,u(()=>{try{t[r]=this.evalWithContext(s,n)}catch{}}))}evaluateExpression(t){try{return this.eval(t)}catch{return}}evaluateExpressionWithContext(t,e){try{const s={...this.component,...e||{}};return Function("c",`with(c){return ${t}}`)(s)}catch{return}}static getOrCreate(e,s,n){return e.templateFragment?e.templateFragment:new t(e,s,n)}static destroyEffects(t){
|
|
const e=t.querySelectorAll("*");for(const t of Array.from(e)){const e=t;if(e.__effects){for(const t of e.__effects)t.destroy();e.__effects=[]}}if(t.__effects){for(const e of t.__effects)e.destroy();t.__effects=[]}}camelToKebab(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}kebabToCamel(t){return t.replace(/-([a-z])/g,(t,e)=>e.toUpperCase())}setInputAttribute(t,e,s){const n=this.currentContext??this.component;this.registerEffect(t,u(()=>{try{const r=this.evalWithContext(s,n);null==r||!1===r?t.removeAttribute(e):!0===r?t.setAttribute(e,""):"object"==typeof r?t.setAttribute(e,JSON.stringify(r)):t.setAttribute(e,r+"")}catch{}}))}},(L=class{transform(t){return null==t?"":(t+"").toUpperCase()}})._quarcPipe=[{name:"uppercase"}],(P=class{transform(t){return null==t?"":(t+"").toLowerCase()}})._quarcPipe=[{name:"lowercase"}],($=class{transform(t){try{return JSON.stringify(t,null,2)}catch(e){return t+""}}})._quarcPipe=[{name:"json"}],(W=class{transform(t){
|
|
return null==t?"":(t+"").replace(/[-_\s]+(.)?/g,(t,e)=>e?e.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase())}})._quarcPipe=[{name:"camelcase"}],(F=class{transform(t){return null==t?"":(t+"").replace(/[-_\s]+(.)?/g,(t,e)=>e?e.toUpperCase():"").replace(/^[a-z]/,t=>t.toUpperCase())}})._quarcPipe=[{name:"pascalcase"}],(k=class{transform(t){return null==t?"":(t+"").replace(/([A-Z])/g,"_$1").replace(/[-\s]+/g,"_").replace(/^_/,"").toLowerCase()}})._quarcPipe=[{name:"snakecase"}],(N=class{transform(t){return null==t?"":(t+"").replace(/([A-Z])/g,"-$1").replace(/[_\s]+/g,"-").replace(/^-/,"").toLowerCase()}})._quarcPipe=[{name:"kebabcase"}],(B=class{transform(t,e,s){if(null==t)return"";const n=t+"";return void 0!==s?n.substr(e,s):n.substr(e)}})._quarcPipe=[{name:"substr"}],(j=class{transform(t,e="medium"){if(null==t)return"";const s=t instanceof Date?t:new Date(t);if(isNaN(s.getTime()))return t+"";switch(e){case"short":return this.formatShort(s);case"medium":return this.formatMedium(s)
|
|
;case"long":return this.formatLong(s);case"full":return this.formatFull(s);case"shortDate":return this.formatShortDate(s);case"mediumDate":return this.formatMediumDate(s);case"longDate":return this.formatLongDate(s);case"fullDate":return this.formatFullDate(s);case"shortTime":return this.formatShortTime(s);case"mediumTime":return this.formatMediumTime(s);default:return this.formatCustom(s,e)}}pad(t,e=2){return(t+"").padStart(e,"0")}formatShort(t){return`${this.pad(t.getMonth()+1)}/${this.pad(t.getDate())}/${t.getFullYear().toString().substr(2)}, ${this.formatShortTime(t)}`}formatMedium(t){return`${this.getMonthShort(t)} ${t.getDate()}, ${t.getFullYear()}, ${this.formatMediumTime(t)}`}formatLong(t){return`${this.getMonthLong(t)} ${t.getDate()}, ${t.getFullYear()} at ${this.formatMediumTime(t)}`}formatFull(t){return`${this.getDayLong(t)}, ${this.getMonthLong(t)} ${t.getDate()}, ${t.getFullYear()} at ${this.formatMediumTime(t)}`}formatShortDate(t){
|
|
return`${this.pad(t.getMonth()+1)}/${this.pad(t.getDate())}/${t.getFullYear().toString().substr(2)}`}formatMediumDate(t){return`${this.getMonthShort(t)} ${t.getDate()}, ${t.getFullYear()}`}formatLongDate(t){return`${this.getMonthLong(t)} ${t.getDate()}, ${t.getFullYear()}`}formatFullDate(t){return`${this.getDayLong(t)}, ${this.getMonthLong(t)} ${t.getDate()}, ${t.getFullYear()}`}formatShortTime(t){const e=t.getHours(),s=t.getMinutes(),n=e>=12?"PM":"AM";return`${e%12||12}:${this.pad(s)} ${n}`}formatMediumTime(t){const e=t.getHours(),s=t.getMinutes(),n=t.getSeconds(),r=e>=12?"PM":"AM";return`${e%12||12}:${this.pad(s)}:${this.pad(n)} ${r}`}getMonthShort(t){return["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()]}getMonthLong(t){return["January","February","March","April","May","June","July","August","September","October","November","December"][t.getMonth()]}getDayLong(t){
|
|
return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][t.getDay()]}formatCustom(t,e){return e.replace(/yyyy/g,t.getFullYear()+"").replace(/yy/g,(t.getFullYear()+"").substr(2)).replace(/MM/g,this.pad(t.getMonth()+1)).replace(/M/g,t.getMonth()+1+"").replace(/dd/g,this.pad(t.getDate())).replace(/d/g,t.getDate()+"").replace(/HH/g,this.pad(t.getHours())).replace(/H/g,t.getHours()+"").replace(/hh/g,this.pad(t.getHours()%12||12)).replace(/h/g,(t.getHours()%12||12)+"").replace(/mm/g,this.pad(t.getMinutes())).replace(/m/g,t.getMinutes()+"").replace(/ss/g,this.pad(t.getSeconds())).replace(/s/g,t.getSeconds()+"").replace(/a/g,t.getHours()>=12?"PM":"AM")}})._quarcPipe=[{name:"date"}],(H=class{})._quarcComponent=[{selector:"app-root",
|
|
template:'<nav><a href="/">Home</a> |<a href="/uppercase">UpperCase</a> |<a href="/lowercase">LowerCase</a> |<a href="/json">JSON</a> |<a href="/case">Case</a> |<a href="/date">Date</a> |<a href="/substr">Substr</a> |<a href="/chain">Chain</a> </nav><router-outlet></router-outlet>',imports:[C]}],H._scopeId="c7z3d6i",H._quarcDirectives=[C],H.__quarc_original_name__="AppComponent",(U=class{})._quarcComponent=[{selector:"app-home",template:'<h1>E2E Pipes Test Suite</h1><p>Navigate to test different pipes</p><div id="test-status">ready</div>'}],U._scopeId="c3as1bp",U.__quarc_original_name__="HomeComponent",(z=class{constructor(){this.text=c("quarc framework"),this.nullValue=c(null)}getText(){return"from method"}})._quarcComponent=[{selector:"app-uppercase-test",
|
|
template:'<h2>UpperCase Pipe Test</h2><div class="test" id="test-1"><h3>Test 1: Hardcoded string</h3><div class="result"><span [inner-text]="_pipes?.[\'uppercase\']?.transform(\'hello world\')"></span></div><div class="expected">HELLO WORLD</div> </div><div class="test" id="test-2"><h3>Test 2: Signal value</h3><div class="result"><span [inner-text]="_pipes?.[\'uppercase\']?.transform(text())"></span></div><div class="expected">QUARC FRAMEWORK</div> </div><div class="test" id="test-3"><h3>Test 3: Method call</h3><div class="result"><span [inner-text]="_pipes?.[\'uppercase\']?.transform(getText())"></span></div><div class="expected">FROM METHOD</div> </div><div class="test" id="test-4"><h3>Test 4: With || operator</h3><div class="result"><span [inner-text]="_pipes?.[\'uppercase\']?.transform(nullValue() || \'default\')"></span></div><div class="expected">DEFAULT</div> </div>',imports:[L]}],z._scopeId="cqln131",z._quarcDirectives=[L],z.__quarc_original_name__="UpperCaseTestComponent",
|
|
(V=class{constructor(){this.text=c("QUARC FRAMEWORK")}getText(){return"FROM METHOD"}})._quarcComponent=[{selector:"app-lowercase-test",template:'<h2>LowerCase Pipe Test</h2><div class="test" id="test-1"><h3>Test 1: Hardcoded string</h3><div class="result"><span [inner-text]="_pipes?.[\'lowercase\']?.transform(\'HELLO WORLD\')"></span></div><div class="expected">hello world</div> </div><div class="test" id="test-2"><h3>Test 2: Signal value</h3><div class="result"><span [inner-text]="_pipes?.[\'lowercase\']?.transform(text())"></span></div><div class="expected">quarc framework</div> </div><div class="test" id="test-3"><h3>Test 3: Method call</h3><div class="result"><span [inner-text]="_pipes?.[\'lowercase\']?.transform(getText())"></span></div><div class="expected">from method</div> </div>',imports:[P]}],V._scopeId="c2cyq3o",V._quarcDirectives=[P],V.__quarc_original_name__="LowerCaseTestComponent",(J=class{constructor(){this.obj=c({name:"Test",value:123}),this.arr=c([1,2,3])}getObject(){
|
|
return{method:!0}}})._quarcComponent=[{selector:"app-json-test",
|
|
template:'<h2>JSON Pipe Test</h2><div class="test" id="test-1"><h3>Test 1: Number literal</h3><pre class="result"><span [inner-text]="_pipes?.[\'json\']?.transform(123)"></span></pre><pre class="expected">123</pre> </div><div class="test" id="test-2"><h3>Test 2: String literal</h3><pre class="result"><span [inner-text]="_pipes?.[\'json\']?.transform("string")"></span></pre><pre class="expected">"string"</pre> </div><div class="test" id="test-3"><h3>Test 3: Boolean literal</h3><pre class="result"><span [inner-text]="_pipes?.[\'json\']?.transform(true)"></span></pre><pre class="expected">true</pre> </div><div class="test" id="test-4"><h3>Test 4: Object from signal</h3><pre class="result"><span [inner-text]="_pipes?.[\'json\']?.transform(obj())"></span></pre><pre class="expected">{"name":"Test","value":123}</pre> </div><div class="test" id="test-5"><h3>Test 5: Array from signal</h3><pre class="result"><span [inner-text]="_pipes?.[\'json\']?.transform(arr())"></span></pre><pre class="expected">[1,2,3]</pre> </div><div class="test" id="test-6"><h3>Test 6: Object from method</h3><pre class="result"><span [inner-text]="_pipes?.[\'json\']?.transform(getObject())"></span></pre><pre class="expected">{"method":true}</pre> </div>',
|
|
imports:[$]}],J._scopeId="c5mjt4r",J._quarcDirectives=[$],J.__quarc_original_name__="JsonTestComponent",(Y=class{constructor(){this.text=c("test-value")}})._quarcComponent=[{selector:"app-case-test",
|
|
template:'<h2>Case Pipes Test</h2><div class="test" id="test-1"><h3>Test 1: CamelCase</h3><div class="result"><span [inner-text]="_pipes?.[\'camelcase\']?.transform(\'hello-world\')"></span></div><div class="expected">helloWorld</div> </div><div class="test" id="test-2"><h3>Test 2: PascalCase</h3><div class="result"><span [inner-text]="_pipes?.[\'pascalcase\']?.transform(\'hello-world\')"></span></div><div class="expected">HelloWorld</div> </div><div class="test" id="test-3"><h3>Test 3: SnakeCase</h3><div class="result"><span [inner-text]="_pipes?.[\'snakecase\']?.transform(\'helloWorld\')"></span></div><div class="expected">hello_world</div> </div><div class="test" id="test-4"><h3>Test 4: KebabCase</h3><div class="result"><span [inner-text]="_pipes?.[\'kebabcase\']?.transform(\'helloWorld\')"></span></div><div class="expected">hello-world</div> </div><div class="test" id="test-5"><h3>Test 5: CamelCase from signal</h3><div class="result"><span [inner-text]="_pipes?.[\'camelcase\']?.transform(text())"></span></div><div class="expected">testValue</div> </div>',
|
|
imports:[W,F,k,N]}],Y._scopeId="c6to77h",Y._quarcDirectives=[W,F,k,N],Y.__quarc_original_name__="CaseTestComponent",(Q=class{constructor(){this.date=c(new Date("2024-01-15T14:30:45"))}getDate(){return new Date("2024-01-15T14:30:45")}})._quarcComponent=[{selector:"app-date-test",
|
|
template:'<h2>Date Pipe Test</h2><div class="test" id="test-1"><h3>Test 1: Custom format yyyy-MM-dd</h3><div class="result"><span [inner-text]="_pipes?.[\'date\']?.transform(date(), \'yyyy-MM-dd\')"></span></div><div class="expected">2024-01-15</div> </div><div class="test" id="test-2"><h3>Test 2: Custom format HH:mm:ss</h3><div class="result"><span [inner-text]="_pipes?.[\'date\']?.transform(date(), \'HH, mm, ss\')"></span></div><div class="expected">14:30:45</div> </div><div class="test" id="test-3"><h3>Test 3: Short date</h3><div class="result"><span [inner-text]="_pipes?.[\'date\']?.transform(date(), \'shortDate\')"></span></div><div class="expected-pattern">01/15/24</div> </div><div class="test" id="test-4"><h3>Test 4: From method</h3><div class="result"><span [inner-text]="_pipes?.[\'date\']?.transform(getDate(), \'yyyy-MM-dd\')"></span></div><div class="expected">2024-01-15</div> </div>',imports:[j]}],Q._scopeId="cnqmpoh",Q._quarcDirectives=[j],
|
|
Q.__quarc_original_name__="DateTestComponent",(Z=class{constructor(){this.text=c("quarc framework")}getText(){return"from method call"}})._quarcComponent=[{selector:"app-substr-test",
|
|
template:'<h2>Substr Pipe Test</h2><div class="test" id="test-1"><h3>Test 1: Hardcoded with start and length</h3><div class="result"><span [inner-text]="_pipes?.[\'substr\']?.transform(\'hello world\', 0, 5)"></span></div><div class="expected">hello</div> </div><div class="test" id="test-2"><h3>Test 2: Hardcoded with start only</h3><div class="result"><span [inner-text]="_pipes?.[\'substr\']?.transform(\'hello world\', 6)"></span></div><div class="expected">world</div> </div><div class="test" id="test-3"><h3>Test 3: Signal value</h3><div class="result"><span [inner-text]="_pipes?.[\'substr\']?.transform(text(), 0, 10)"></span></div><div class="expected">quarc fram</div> </div><div class="test" id="test-4"><h3>Test 4: Method call</h3><div class="result"><span [inner-text]="_pipes?.[\'substr\']?.transform(getText(), 5, 6)"></span></div><div class="expected">method</div> </div>',imports:[B]}],Z._scopeId="cku4wzg",Z._quarcDirectives=[B],Z.__quarc_original_name__="SubstrTestComponent",
|
|
(K=class{constructor(){this.text=c("HELLO-WORLD")}getText(){return"test value"}})._quarcComponent=[{selector:"app-chain-test",
|
|
template:'<h2>Pipe Chain Test</h2><div class="test" id="test-1"><h3>Test 1: lowercase | uppercase</h3><div class="result"><span [inner-text]="_pipes?.[\'uppercase\']?.transform(_pipes?.[\'lowercase\']?.transform(\'Hello\'))"></span></div><div class="expected">HELLO</div> </div><div class="test" id="test-2"><h3>Test 2: uppercase | substr</h3><div class="result"><span [inner-text]="_pipes?.[\'substr\']?.transform(_pipes?.[\'uppercase\']?.transform(\'hello world\'), 0, 5)"></span></div><div class="expected">HELLO</div> </div><div class="test" id="test-3"><h3>Test 3: Signal with chain</h3><div class="result"><span [inner-text]="_pipes?.[\'camelcase\']?.transform(_pipes?.[\'lowercase\']?.transform(text()))"></span></div><div class="expected">helloWorld</div> </div><div class="test" id="test-4"><h3>Test 4: Method with chain</h3><div class="result"><span [inner-text]="_pipes?.[\'substr\']?.transform(_pipes?.[\'uppercase\']?.transform(getText()), 0, 4)"></span></div><div class="expected">TEST</div> </div><div class="test" id="test-5"><h3>Test 5: Triple chain</h3><div class="result"><span [inner-text]="_pipes?.[\'uppercase\']?.transform(_pipes?.[\'camelcase\']?.transform(_pipes?.[\'lowercase\']?.transform(\'HELLO-WORLD\')))"></span></div><div class="expected">HELLOWORLD</div> </div>',
|
|
imports:[L,P,B,W]}],K._scopeId="cjw5ze4",K._quarcDirectives=[L,P,B,W],K.__quarc_original_name__="ChainTestComponent",m(H,X={providers:[t(G=[{path:"",component:U},{path:"uppercase",component:z},{path:"lowercase",component:V},{path:"json",component:J},{path:"case",component:Y},{path:"date",component:Q},{path:"substr",component:Z},{path:"chain",component:K}])]}); |