aptechka 0.83.1 → 0.84.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/lib/Animation-BAiM6_n1.js +111 -0
- package/lib/Animation-DMWabSR0.cjs +1 -0
- package/lib/Composed-B0fvCtZz.cjs +1 -0
- package/lib/Composed-CgA9lLWA.js +75 -0
- package/lib/Damped-BLo-OAVb.cjs +1 -0
- package/lib/Damped-Dcz5UdMH.js +57 -0
- package/lib/DerivedArray-DFhxap_z.js +63 -0
- package/lib/DerivedArray-DYtWMW0n.cjs +1 -0
- package/lib/DragControls-BPHsDeH6.cjs +1 -0
- package/lib/DragControls-D2a1Cifp.js +234 -0
- package/lib/LocalLinks-BWFJYhGX.cjs +1 -0
- package/lib/LocalLinks-Dwgf3No6.js +65 -0
- package/lib/PageAnnouncerElement-DPMlVJZG.cjs +1 -0
- package/lib/PageAnnouncerElement-DV9pm_od.js +28 -0
- package/lib/PageScroll-BAatKJx6.cjs +1 -0
- package/lib/PageScroll-m3TsHnzR.js +65 -0
- package/lib/SourceElement-941MrYpq.js +265 -0
- package/lib/SourceElement-DBLZ7b5k.cjs +5 -0
- package/lib/Store-BCW70G3Z.cjs +1 -0
- package/lib/Store-uLDYY9ed.js +158 -0
- package/lib/Tweened-BvtjLCa3.js +48 -0
- package/lib/Tweened-DdXm1dbF.cjs +1 -0
- package/lib/Viewport-BiDoiU8M.js +113 -0
- package/lib/Viewport-CXGKUyDy.cjs +1 -0
- package/lib/accordion/index.cjs +1 -1
- package/lib/accordion/index.js +97 -93
- package/lib/animation/index.cjs +1 -1
- package/lib/animation/index.js +6 -6
- package/lib/api-fetcher/index.cjs +1 -1
- package/lib/api-fetcher/index.js +67 -66
- package/lib/attribute/index.cjs +1 -1
- package/lib/attribute/index.js +37 -34
- package/lib/attributes-BADnRZpK.cjs +1 -0
- package/lib/attributes-FObgMNCf.js +36 -0
- package/lib/billboard/index.cjs +1 -1
- package/lib/billboard/index.js +240 -232
- package/lib/cache/index.cjs +1 -1
- package/lib/cache/index.js +26 -23
- package/lib/canvas/index.cjs +1 -1
- package/lib/canvas/index.js +62 -59
- package/lib/canvas-BP1ceie3.cjs +1 -0
- package/lib/canvas-DsglKco1.js +40 -0
- package/lib/connector/index.cjs +1 -1
- package/lib/connector/index.js +44 -41
- package/lib/controls/index.cjs +1 -1
- package/lib/controls/index.js +6 -6
- package/lib/coordinates--JG1U6kQ.js +29 -0
- package/lib/coordinates-DQ9XV9M1.cjs +1 -0
- package/lib/css-property/index.cjs +1 -1
- package/lib/css-property/index.d.ts +1 -1
- package/lib/css-property/index.js +40 -37
- package/lib/css-unit-parser/index.cjs +2 -2
- package/lib/css-unit-parser/index.js +22 -19
- package/lib/css-value-parser/index.cjs +1 -1
- package/lib/css-value-parser/index.js +13 -11
- package/lib/custom-elements-BfZCJde6.cjs +1 -0
- package/lib/custom-elements-HEMuF7yH.js +27 -0
- package/lib/dev/index.cjs +2 -1
- package/lib/dev/index.d.ts +1 -0
- package/lib/dev/index.js +25 -10
- package/lib/device/index.cjs +1 -1
- package/lib/device/index.js +5 -5
- package/lib/dom-B40i6NXw.cjs +1 -0
- package/lib/dom-D8D-_9ty.js +108 -0
- package/lib/easings-BSGJFMAo.js +40 -0
- package/lib/easings-BWq0pPLq.cjs +1 -0
- package/lib/element-CqD0jqBJ.cjs +1 -0
- package/lib/element-DKw5H-Tu.js +10 -0
- package/lib/element-linked-store/index.cjs +1 -1
- package/lib/element-linked-store/index.js +53 -52
- package/lib/element-resizer/index.cjs +1 -1
- package/lib/element-resizer/index.js +47 -44
- package/lib/en3/index.cjs +4 -4
- package/lib/en3/index.js +192 -185
- package/lib/events-Ds-TuvYW.js +9 -0
- package/lib/events-UlGk63iC.cjs +1 -0
- package/lib/file-DwQs6bB6.js +28 -0
- package/lib/file-RHfA3OS-.cjs +1 -0
- package/lib/function-H4b_gTg6.cjs +1 -0
- package/lib/function-UmbPrOHm.js +19 -0
- package/lib/gestures-DmKKNnh4.js +14 -0
- package/lib/gestures-DtYbQr49.cjs +1 -0
- package/lib/history/index.cjs +1 -1
- package/lib/history/index.js +24 -21
- package/lib/iframe/index.cjs +1 -1
- package/lib/iframe/index.js +27 -24
- package/lib/image/index.cjs +1 -1
- package/lib/image/index.js +17 -13
- package/lib/index-BpO2RJ__.cjs +1 -0
- package/lib/index-DpKsHe97.js +68 -0
- package/lib/intersector/index.cjs +1 -1
- package/lib/intersector/index.js +3 -3
- package/lib/jsx/ComponentElement.d.ts +4 -0
- package/lib/jsx/h.d.ts +7 -16
- package/lib/jsx/hooks/component/useStylesheet.d.ts +1 -1
- package/lib/jsx/hooks/cssProperty.d.ts +6 -0
- package/lib/jsx/hooks/resize.d.ts +4 -0
- package/lib/jsx/hooks/store.d.ts +1 -2
- package/lib/jsx/hooks/ticker.d.ts +5 -0
- package/lib/jsx/index.cjs +1 -1
- package/lib/jsx/index.d.ts +4 -4
- package/lib/jsx/index.js +171 -349
- package/lib/jsx/plugins/vite/index.cjs +49 -0
- package/lib/jsx/plugins/vite/index.d.ts +38 -0
- package/lib/jsx/plugins/vite/index.js +104 -0
- package/lib/jsx/render.d.ts +2 -0
- package/lib/jsx/type.d.ts +228 -190
- package/lib/ladder/index.cjs +1 -1
- package/lib/ladder/index.js +86 -84
- package/lib/layout-C26zkY7D.js +35 -0
- package/lib/layout-CnGLl7oe.cjs +1 -0
- package/lib/layout-box/index.cjs +1 -1
- package/lib/layout-box/index.js +221 -217
- package/lib/loading/index.cjs +1 -1
- package/lib/loading/index.js +48 -45
- package/lib/local-links/index.cjs +1 -1
- package/lib/local-links/index.js +2 -2
- package/lib/masonry-layout/index.cjs +1 -1
- package/lib/masonry-layout/index.js +48 -45
- package/lib/math-C-knY2TL.cjs +1 -0
- package/lib/math-r8V23YFe.js +57 -0
- package/lib/media/index.cjs +1 -1
- package/lib/media/index.js +28 -25
- package/lib/metadata-BNdkmeeD.js +15 -0
- package/lib/metadata-BrHUfpV9.cjs +1 -0
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +561 -556
- package/lib/morph-BtgB1YQP.js +256 -0
- package/lib/morph-Buhxq-X0.cjs +1 -0
- package/lib/need_redo_tweaker/index.cjs +4 -4
- package/lib/need_redo_tweaker/index.js +862 -834
- package/lib/notifier/index.cjs +1 -1
- package/lib/notifier/index.js +29 -26
- package/lib/number-Bu4sGvW7.cjs +1 -0
- package/lib/number-DiVt2xnh.js +47 -0
- package/lib/object-CiIdEmJx.js +98 -0
- package/lib/object-DTY_W6xG.cjs +1 -0
- package/lib/order/index.cjs +1 -1
- package/lib/order/index.js +3 -3
- package/lib/page-announcer/index.cjs +1 -1
- package/lib/page-announcer/index.js +2 -2
- package/lib/page-scroll/index.cjs +1 -1
- package/lib/page-scroll/index.js +2 -2
- package/lib/pixel-perfect/index.cjs +4 -4
- package/lib/pixel-perfect/index.js +43 -40
- package/lib/pointer/index.cjs +1 -1
- package/lib/pointer/index.js +125 -122
- package/lib/polyfills-CG1XJNia.js +28 -0
- package/lib/polyfills-DZCuDBkA.cjs +1 -0
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +249 -245
- package/lib/radio/index.cjs +1 -1
- package/lib/radio/index.js +58 -55
- package/lib/render-DLcWVnuH.js +355 -0
- package/lib/render-DdomypCo.cjs +1 -0
- package/lib/router/index.cjs +1 -1
- package/lib/router/index.js +196 -194
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +890 -877
- package/lib/scroll-BvIWh1xB.js +41 -0
- package/lib/scroll-CT0lpyRZ.cjs +1 -0
- package/lib/scroll-entries/index.cjs +1 -1
- package/lib/scroll-entries/index.js +37 -34
- package/lib/scroll-kit/index.cjs +1 -1
- package/lib/scroll-kit/index.js +214 -209
- package/lib/sequence/index.cjs +1 -1
- package/lib/sequence/index.js +102 -98
- package/lib/size-element/index.cjs +1 -1
- package/lib/size-element/index.js +29 -26
- package/lib/slicer/index.cjs +1 -1
- package/lib/slicer/index.js +118 -113
- package/lib/source/index.cjs +1 -1
- package/lib/source/index.js +5 -5
- package/lib/spa/index.cjs +1 -1
- package/lib/spa/index.js +94 -94
- package/lib/store/index.cjs +1 -1
- package/lib/store/index.d.ts +2 -2
- package/lib/store/index.js +10 -8
- package/lib/string-B3lm2b7v.js +84 -0
- package/lib/string-CbRNzmd9.cjs +1 -0
- package/lib/style-DBoQWK0d.js +14 -0
- package/lib/style-IDJ6db6n.cjs +1 -0
- package/lib/stylesheet-CHvuef16.js +28 -0
- package/lib/stylesheet-CQdBaIAA.cjs +1 -0
- package/lib/ticker/index.cjs +1 -1
- package/lib/ticker/index.js +96 -92
- package/lib/url-CPCO10Sy.cjs +1 -0
- package/lib/url-CWCY_qe_.js +124 -0
- package/lib/utils/attributes.d.ts +2 -0
- package/lib/utils/dom.d.ts +1 -0
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.js +245 -226
- package/lib/utils/polyfills.d.ts +1 -1
- package/lib/video/index.cjs +1 -1
- package/lib/video/index.js +36 -33
- package/lib/window-resizer/index.cjs +1 -1
- package/lib/window-resizer/index.js +27 -24
- package/lib/youtube/index.cjs +1 -1
- package/lib/youtube/index.js +56 -54
- package/package.json +11 -24
- package/lib/Animation-BzTjZIE-.js +0 -108
- package/lib/Animation-C39Ah-LM.cjs +0 -1
- package/lib/Composed-C-TV9te3.cjs +0 -1
- package/lib/Composed-DyAWjEXE.js +0 -121
- package/lib/Damped-CRusiRIV.js +0 -56
- package/lib/Damped-Prr0iKu1.cjs +0 -1
- package/lib/DragControls-8rNZwQrs.cjs +0 -1
- package/lib/DragControls-DBNdMBA4.js +0 -228
- package/lib/LocalLinks-BxhSFv_Q.cjs +0 -1
- package/lib/LocalLinks-DFZFpbjs.js +0 -62
- package/lib/PageAnnouncerElement-0LxZjtVH.js +0 -24
- package/lib/PageAnnouncerElement-AQ0Ja6HM.cjs +0 -1
- package/lib/PageScroll-0LxFblry.js +0 -62
- package/lib/PageScroll-BXJUQwG7.cjs +0 -1
- package/lib/SourceElement-BHqPFbna.cjs +0 -5
- package/lib/SourceElement-DjbHjynf.js +0 -260
- package/lib/Store-Blf4msDz.cjs +0 -1
- package/lib/Store-ZThXYBQd.js +0 -152
- package/lib/Tweened-Bw1Cn1PJ.js +0 -47
- package/lib/Tweened-DWtk9E-O.cjs +0 -1
- package/lib/Viewport-BxCr0GlB.cjs +0 -1
- package/lib/Viewport-Dt-d9DPi.js +0 -109
- package/lib/attributes-69we3byR.js +0 -10
- package/lib/attributes-Bf2svn4j.cjs +0 -1
- package/lib/canvas-CU5Xjahf.cjs +0 -1
- package/lib/canvas-DeZ0SLUJ.js +0 -34
- package/lib/coordinates-CgdGoSYs.js +0 -24
- package/lib/coordinates-D8Np3cPD.cjs +0 -1
- package/lib/custom-elements-DBnCK7Zx.js +0 -24
- package/lib/custom-elements-Dh4TWRDJ.cjs +0 -1
- package/lib/dom-BETkVSSZ.js +0 -82
- package/lib/dom-CBLlqORw.cjs +0 -1
- package/lib/easings-BEmRlrDd.js +0 -38
- package/lib/easings-GegIwET5.cjs +0 -1
- package/lib/element-CGVl1jA-.js +0 -7
- package/lib/element-yhcBhsho.cjs +0 -1
- package/lib/events-CsVF98U6.js +0 -6
- package/lib/events-KVanG9sR.cjs +0 -1
- package/lib/file-DSpfWdd9.cjs +0 -1
- package/lib/file-GHShUlue.js +0 -24
- package/lib/function-C10DGppn.js +0 -17
- package/lib/function-MthRj-GJ.cjs +0 -1
- package/lib/gestures-C7gbKx11.cjs +0 -1
- package/lib/gestures-CcXV6fCp.js +0 -11
- package/lib/index-OE2INULi.cjs +0 -1
- package/lib/index-e9eDuagL.js +0 -65
- package/lib/jsx/hydrate.d.ts +0 -1
- package/lib/jsx/integrations/astro/client.cjs +0 -1
- package/lib/jsx/integrations/astro/client.d.ts +0 -2
- package/lib/jsx/integrations/astro/client.js +0 -50
- package/lib/jsx/integrations/astro/index.cjs +0 -1
- package/lib/jsx/integrations/astro/index.d.ts +0 -2
- package/lib/jsx/integrations/astro/index.js +0 -54
- package/lib/jsx/integrations/astro/server.cjs +0 -1
- package/lib/jsx/integrations/astro/server.d.ts +0 -3
- package/lib/jsx/integrations/astro/server.js +0 -35
- package/lib/jsx/plugins/vite.d.ts +0 -21
- package/lib/layout-BSMtwCga.js +0 -29
- package/lib/layout-Ctc2p3uz.cjs +0 -1
- package/lib/math-BOBiC4TN.js +0 -45
- package/lib/math-GDWEqu7y.cjs +0 -1
- package/lib/metadata-BcYZ5w3T.cjs +0 -1
- package/lib/metadata-jfowcCyz.js +0 -12
- package/lib/morph-B6sGhLCi.cjs +0 -1
- package/lib/morph-BQErz7qP.js +0 -242
- package/lib/number-ChAm68cm.cjs +0 -1
- package/lib/number-CumqY64S.js +0 -40
- package/lib/object-CcMK4y_r.js +0 -87
- package/lib/object-baN9pgbU.cjs +0 -1
- package/lib/polyfills-DJrTJQky.js +0 -24
- package/lib/polyfills-Df4r-ETT.cjs +0 -1
- package/lib/render-DQs7rIoN.cjs +0 -1
- package/lib/render-D_0FCWEu.js +0 -18
- package/lib/scroll-BA2WnUrb.cjs +0 -1
- package/lib/scroll-DY5senkF.js +0 -37
- package/lib/string-BlMQbe8b.js +0 -70
- package/lib/string-DUXXtU8v.cjs +0 -1
- package/lib/style-At6aDoqG.cjs +0 -1
- package/lib/style-j2TwriJ_.js +0 -10
- package/lib/stylesheet-5_o7PFzM.cjs +0 -1
- package/lib/stylesheet-DdBzowZY.js +0 -24
- package/lib/url-CHgcNwJ1.cjs +0 -1
- package/lib/url-CYgo5vrG.js +0 -113
- package/lib/vite-C-i3hVDL.js +0 -75
- package/lib/vite-DzanPumM.cjs +0 -44
package/lib/router/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ue=Object.defineProperty,ce=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var Y=i=>{throw TypeError(i)};var W=(i,e,s)=>e in i?ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s,$=(i,e)=>{for(var s in e||(e={}))me.call(e,s)&&W(i,s,e[s]);if(K)for(var s of K(e))fe.call(e,s)&&W(i,s,e[s]);return i},G=(i,e)=>ce(i,de(e));var U=(i,e,s)=>e.has(i)||Y("Cannot "+s);var t=(i,e,s)=>(U(i,e,"read from private field"),s?s.call(i):e.get(i)),n=(i,e,s)=>e.has(i)?Y("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,s),h=(i,e,s,r)=>(U(i,e,"write to private field"),r?r.call(i,s):e.set(i,s),s),d=(i,e,s)=>(U(i,e,"access private method"),s);var J=(i,e,s,r)=>({set _(a){h(i,e,a,s)},get _(){return t(i,e,r)}});var R=(i,e,s)=>new Promise((r,a)=>{var o=f=>{try{g(s.next(f))}catch(N){a(N)}},C=f=>{try{g(s.throw(f))}catch(N){a(N)}},g=f=>f.done?r(f.value):Promise.resolve(f.value).then(o,C);g((s=s.apply(i,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const pe=require("../history/index.cjs"),ge=require("../LocalLinks-BxhSFv_Q.cjs"),Re=require("../PageAnnouncerElement-AQ0Ja6HM.cjs"),we=require("../PageScroll-BXJUQwG7.cjs");require("construct-style-sheets-polyfill");require("../index-OE2INULi.cjs");const Q=require("../url-CHgcNwJ1.cjs"),ve=require("urlpattern-polyfill"),Pe=require("../render-DQs7rIoN.cjs"),be=require("../object-baN9pgbU.cjs");var S,H,q,p,u,T,M,v,P,b,l,X,Z,ee,te,se,ie,re,ae,B,y;class ye{constructor(e,s){n(this,l);n(this,S);n(this,H);n(this,q);n(this,p,null);n(this,u,null);n(this,T,!1);n(this,M,null);n(this,v);n(this,P,[]);n(this,b,[]);n(this,y,e=>{t(this,u).removeEventListener("__hmrInstanceReplace",t(this,y)),h(this,u,e.detail.element),t(this,u).addEventListener("__hmrInstanceReplace",t(this,y))});h(this,S,e),h(this,H,s),h(this,q,new URLPattern({pathname:t(this,S)})),h(this,v,new MutationObserver(d(this,l,re).bind(this)))}get pattern(){return t(this,S)}get isActive(){return t(this,T)}get element(){return t(this,u)}get nest(){return t(this,M)}testPathname(e){return t(this,q).test({pathname:e})}render(e,s){return R(this,null,function*(){t(this,v).observe(document.head,{childList:!0,subtree:!0}),t(this,p)?d(this,l,Z).call(this):yield d(this,l,X).call(this),yield d(this,l,ae).call(this),t(this,p)&&(yield d(this,l,ee).call(this,e,s)),t(this,v).disconnect()})}close(){d(this,l,se).call(this)}}S=new WeakMap,H=new WeakMap,q=new WeakMap,p=new WeakMap,u=new WeakMap,T=new WeakMap,M=new WeakMap,v=new WeakMap,P=new WeakMap,b=new WeakMap,l=new WeakSet,X=function(){return R(this,null,function*(){const e=yield t(this,H).call(this);h(this,b,[...t(this,P)]),typeof e.default=="function"&&h(this,p,e.default)})},Z=function(){t(this,P).forEach(e=>{document.head.appendChild(e.cloneNode(!0))})},ee=function(e,s){return R(this,null,function*(){var o;const a={urlPatternResult:t(this,q).exec({pathname:s.pathname})};be.isESClass(t(this,p))?(h(this,u,new(t(this,p))(a)),e.appendChild(t(this,u))):h(this,u,Pe.render(e,t(this,p),a)),(o=t(this,u))==null||o.addEventListener("__hmrInstanceReplace",t(this,y)),d(this,l,te).call(this),h(this,T,!0)})},te=function(){var e;t(this,u)&&h(this,M,t(this,u).querySelector("[data-nest]")||((e=t(this,u).shadowRoot)==null?void 0:e.querySelector("[data-nest]"))||t(this,u).shadowRoot||t(this,u))},se=function(){t(this,v).disconnect(),t(this,u)&&(t(this,u).removeEventListener("__hmrInstanceReplace",t(this,y)),t(this,u).remove()),h(this,T,!1),d(this,l,ie).call(this)},ie=function(){t(this,b).forEach(e=>{e.parentNode===document.head&&document.head.removeChild(e)}),h(this,b,[])},re=function(e){e.forEach(s=>{s.addedNodes.forEach(r=>{t(this,p)?t(this,b).push(r):t(this,P).push(r)})})},ae=function(){return R(this,null,function*(){const e=t(this,P).filter(d(this,l,B));yield Promise.all(e.map(s=>new Promise(r=>{d(this,l,B).call(this,s)?s.onload=()=>r():r()})))})},B=function(e){return e instanceof HTMLElement&&(e.tagName==="STYLE"||e.tagName==="SCRIPT"||e.tagName==="LINK")},y=new WeakMap;globalThis.URLPattern=ve.URLPattern;var c,L,k,E,I,_,w,A,m,ne,he,le,z,oe;class Le{constructor(e){n(this,m);n(this,c,null);n(this,L,null);n(this,k,null);n(this,E,null);n(this,I,null);n(this,_,0);n(this,w,[]);n(this,A,null);h(this,c,G($({},e),{rootElement:(e==null?void 0:e.rootElement)||document.body,base:Q.normalizeBase(e==null?void 0:e.base)})),h(this,I,new Re.PageAnnouncerElement),h(this,L,new we.PageScroll(t(this,c).scrollSelector)),t(this,L).update(),h(this,k,new ge.LocalLinks({base:t(this,c).base,trailingSlash:t(this,c).trailingSlash,includeAnchor:e==null?void 0:e.includeAnchor,onClick:(s,r)=>{try{this.navigate(s,r)}catch(a){window.location.assign(s)}}})),t(this,k).update(),h(this,E,new pe.History({onPop:s=>{this.navigate(s)}}))}history(){return t(this,E)}get scroll(){return scroll}get routes(){return t(this,w)}run(){d(this,m,oe).call(this),this.navigate(new URL(location.href),{revalidate:!0})}defineRoute(e,s){const r=new ye(e,s);t(this,w).push(r)}navigate(e,s){return R(this,null,function*(){var O,j,x,V,D,F;const r=t(this,E).isBack,a=++J(this,_)._;let o=Q.normalizeURL(e,{base:t(this,c).base,trailingSlash:t(this,c).trailingSlash});if(t(this,c).urlModifier&&(o=t(this,c).urlModifier(o)),!(yield d(this,m,ne).call(this,o))||t(this,_)!==a||(yield(j=(O=t(this,c)).beforeNavigation)==null?void 0:j.call(O),t(this,_)!==a))return;const{activeRoutes:C,newRoutes:g,oldRoutes:f,keepRoutes:N}=d(this,m,he).call(this,o);h(this,A,(x=N[N.length-1])!=null?x:null),r||(t(this,E).push(o),((V=s==null?void 0:s.keepScrollPosition)==null||V)&&t(this,L).element.scrollTo({top:0,behavior:"instant"})),t(this,I).create(document,o.pathname),t(this,c).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>d(this,m,z).call(this,f,g,o)).finished:yield d(this,m,z).call(this,f,g,o),t(this,L).update(),t(this,k).update(),t(this,I).done(),yield(F=(D=t(this,c)).afterNavigation)==null?void 0:F.call(D)})}}c=new WeakMap,L=new WeakMap,k=new WeakMap,E=new WeakMap,I=new WeakMap,_=new WeakMap,w=new WeakMap,A=new WeakMap,m=new WeakSet,ne=function(e){return R(this,null,function*(){if(!t(this,c).preprocessor)return!0;try{return yield new Promise((s,r)=>{var a,o;(o=(a=t(this,c)).preprocessor)==null||o.call(a,{url:e,resolve:s,reject:r})}),!0}catch(s){return console.error(s!=null?s:"Route change canceled"),!1}})},he=function(e){let s=e.pathname.replace(t(this,c).base,"");s.startsWith("/")||(s=`/${s}`);const r=t(this,w).filter(a=>a.isActive);return{activeRoutes:r,newRoutes:t(this,w).filter(a=>!r.includes(a)&&a.testPathname(s)),oldRoutes:r.filter(a=>!a.testPathname(s)),keepRoutes:r.filter(a=>a.testPathname(s))}},le=function(e){e.forEach(s=>s.close())},z=function(e,s,r){return R(this,null,function*(){var a,o;d(this,m,le).call(this,e);for(const C of s){const g=(o=(a=t(this,A))==null?void 0:a.nest)!=null?o:t(this,c).rootElement;yield C.render(g,r),h(this,A,C)}})},oe=function(){t(this,w).sort((e,s)=>{const r=e.pattern.split("/").length,a=s.pattern.split("/").length;return r-a})};exports.Router=Le;
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__defProps=Object.defineProperties;var __getOwnPropDescs=Object.getOwnPropertyDescriptors;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable;var __typeError=msg=>{throw TypeError(msg)};var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:!0,configurable:!0,writable:!0,value}):obj[key]=value,__spreadValues=(a,b)=>{for(var prop in b||(b={}))__hasOwnProp.call(b,prop)&&__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b))__propIsEnum.call(b,prop)&&__defNormalProp(a,prop,b[prop]);return a},__spreadProps=(a,b)=>__defProps(a,__getOwnPropDescs(b)),__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __accessCheck=(obj,member,msg)=>member.has(obj)||__typeError("Cannot "+msg);var __privateGet=(obj,member,getter)=>(__accessCheck(obj,member,"read from private field"),getter?getter.call(obj):member.get(obj)),__privateAdd=(obj,member,value)=>member.has(obj)?__typeError("Cannot add the same private member more than once"):member instanceof WeakSet?member.add(obj):member.set(obj,value),__privateSet=(obj,member,value,setter)=>(__accessCheck(obj,member,"write to private field"),setter?setter.call(obj,value):member.set(obj,value),value),__privateMethod=(obj,member,method)=>(__accessCheck(obj,member,"access private method"),method);var __privateWrapper=(obj,member,setter,getter)=>({set _(value){__privateSet(obj,member,value,setter)},get _(){return __privateGet(obj,member,getter)}});var __async=(__this,__arguments,generator)=>new Promise((resolve,reject)=>{var fulfilled=value=>{try{step(generator.next(value))}catch(e){reject(e)}},rejected=value=>{try{step(generator.throw(value))}catch(e){reject(e)}},step=x=>x.done?resolve(x.value):Promise.resolve(x.value).then(fulfilled,rejected);step((generator=generator.apply(__this,__arguments)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const history_index=require("../history/index.cjs"),LocalLinks=require("../LocalLinks-BWFJYhGX.cjs"),PageAnnouncerElement=require("../PageAnnouncerElement-DPMlVJZG.cjs"),PageScroll=require("../PageScroll-BAatKJx6.cjs");require("construct-style-sheets-polyfill");require("../index-BpO2RJ__.cjs");const url=require("../url-CPCO10Sy.cjs"),urlpatternPolyfill=require("urlpattern-polyfill"),render=require("../render-DdomypCo.cjs"),object=require("../object-DTY_W6xG.cjs");var _pattern,_module,_urlPattern,_elementConstructor,_elementInstance,_isActive,_nestTarget,_mutationObserver,_permanentHeadNodes,_temporalHeadNodes,_Route_instances,initializeRouteModule_fn,appendPermanentHeadNodes_fn,renderRouteComponent_fn,findNestTarget_fn,cleanup_fn,removeTemporalHeadNodes_fn,handleHeadMutations_fn,waitForHeadNodesLoad_fn,isLoadableNode_fn,_instanceReplaceListener;const _Route=class _Route{constructor(pattern,module2){__privateAdd(this,_Route_instances);__privateAdd(this,_pattern);__privateAdd(this,_module);__privateAdd(this,_urlPattern);__privateAdd(this,_elementConstructor,null);__privateAdd(this,_elementInstance,null);__privateAdd(this,_isActive,!1);__privateAdd(this,_nestTarget,null);__privateAdd(this,_mutationObserver);__privateAdd(this,_permanentHeadNodes,[]);__privateAdd(this,_temporalHeadNodes,[]);__privateAdd(this,_instanceReplaceListener,__name(e=>{__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateSet(this,_elementInstance,e.detail.element),__privateGet(this,_elementInstance).addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener))},"#instanceReplaceListener"));__privateSet(this,_pattern,pattern),__privateSet(this,_module,module2),__privateSet(this,_urlPattern,new URLPattern({pathname:__privateGet(this,_pattern)})),__privateSet(this,_mutationObserver,new MutationObserver(__privateMethod(this,_Route_instances,handleHeadMutations_fn).bind(this)))}get pattern(){return __privateGet(this,_pattern)}get isActive(){return __privateGet(this,_isActive)}get element(){return __privateGet(this,_elementInstance)}get nest(){return __privateGet(this,_nestTarget)}testPathname(pathname){return __privateGet(this,_urlPattern).test({pathname})}render(container,url2){return __async(this,null,function*(){__privateGet(this,_mutationObserver).observe(document.head,{childList:!0,subtree:!0}),__privateGet(this,_elementConstructor)?__privateMethod(this,_Route_instances,appendPermanentHeadNodes_fn).call(this):yield __privateMethod(this,_Route_instances,initializeRouteModule_fn).call(this),yield __privateMethod(this,_Route_instances,waitForHeadNodesLoad_fn).call(this),__privateGet(this,_elementConstructor)&&(yield __privateMethod(this,_Route_instances,renderRouteComponent_fn).call(this,container,url2)),__privateGet(this,_mutationObserver).disconnect()})}close(){__privateMethod(this,_Route_instances,cleanup_fn).call(this)}};_pattern=new WeakMap,_module=new WeakMap,_urlPattern=new WeakMap,_elementConstructor=new WeakMap,_elementInstance=new WeakMap,_isActive=new WeakMap,_nestTarget=new WeakMap,_mutationObserver=new WeakMap,_permanentHeadNodes=new WeakMap,_temporalHeadNodes=new WeakMap,_Route_instances=new WeakSet,initializeRouteModule_fn=__name(function(){return __async(this,null,function*(){const content=yield __privateGet(this,_module).call(this);__privateSet(this,_temporalHeadNodes,[...__privateGet(this,_permanentHeadNodes)]),typeof content.default=="function"&&__privateSet(this,_elementConstructor,content.default)})},"#initializeRouteModule"),appendPermanentHeadNodes_fn=__name(function(){__privateGet(this,_permanentHeadNodes).forEach(node=>{document.head.appendChild(node.cloneNode(!0))})},"#appendPermanentHeadNodes"),renderRouteComponent_fn=__name(function(container,url2){return __async(this,null,function*(){var _a;const routeParams={urlPatternResult:__privateGet(this,_urlPattern).exec({pathname:url2.pathname})};object.isESClass(__privateGet(this,_elementConstructor))?(__privateSet(this,_elementInstance,new(__privateGet(this,_elementConstructor))(routeParams)),container.appendChild(__privateGet(this,_elementInstance))):__privateSet(this,_elementInstance,render.render(container,__privateGet(this,_elementConstructor),routeParams)),(_a=__privateGet(this,_elementInstance))==null||_a.addEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateMethod(this,_Route_instances,findNestTarget_fn).call(this),__privateSet(this,_isActive,!0)})},"#renderRouteComponent"),findNestTarget_fn=__name(function(){var _a;__privateGet(this,_elementInstance)&&__privateSet(this,_nestTarget,__privateGet(this,_elementInstance).querySelector("[data-nest]")||((_a=__privateGet(this,_elementInstance).shadowRoot)==null?void 0:_a.querySelector("[data-nest]"))||__privateGet(this,_elementInstance).shadowRoot||__privateGet(this,_elementInstance))},"#findNestTarget"),cleanup_fn=__name(function(){__privateGet(this,_mutationObserver).disconnect(),__privateGet(this,_elementInstance)&&(__privateGet(this,_elementInstance).removeEventListener("__hmrInstanceReplace",__privateGet(this,_instanceReplaceListener)),__privateGet(this,_elementInstance).remove()),__privateSet(this,_isActive,!1),__privateMethod(this,_Route_instances,removeTemporalHeadNodes_fn).call(this)},"#cleanup"),removeTemporalHeadNodes_fn=__name(function(){__privateGet(this,_temporalHeadNodes).forEach(node=>{node.parentNode===document.head&&document.head.removeChild(node)}),__privateSet(this,_temporalHeadNodes,[])},"#removeTemporalHeadNodes"),handleHeadMutations_fn=__name(function(mutations){mutations.forEach(mutation=>{mutation.addedNodes.forEach(node=>{__privateGet(this,_elementConstructor)?__privateGet(this,_temporalHeadNodes).push(node):__privateGet(this,_permanentHeadNodes).push(node)})})},"#handleHeadMutations"),waitForHeadNodesLoad_fn=__name(function(){return __async(this,null,function*(){const loadableNodes=__privateGet(this,_permanentHeadNodes).filter(__privateMethod(this,_Route_instances,isLoadableNode_fn));yield Promise.all(loadableNodes.map(node=>new Promise(resolve=>{__privateMethod(this,_Route_instances,isLoadableNode_fn).call(this,node)?node.onload=()=>resolve():resolve()})))})},"#waitForHeadNodesLoad"),isLoadableNode_fn=__name(function(node){return node instanceof HTMLElement&&(node.tagName==="STYLE"||node.tagName==="SCRIPT"||node.tagName==="LINK")},"#isLoadableNode"),_instanceReplaceListener=new WeakMap,__name(_Route,"Route");let Route=_Route;globalThis.URLPattern=urlpatternPolyfill.URLPattern;var _options,_scroll,_links,_history,_announcerElement,_updateId,_routes,_lastRoute,_Router_instances,runPreprocessor_fn,categorizeRoutes_fn,closeOldRoutes_fn,renderNewRoutes_fn,sortRoutesByPathDepth_fn;const _Router=class _Router{constructor(options){__privateAdd(this,_Router_instances);__privateAdd(this,_options,null);__privateAdd(this,_scroll,null);__privateAdd(this,_links,null);__privateAdd(this,_history,null);__privateAdd(this,_announcerElement,null);__privateAdd(this,_updateId,0);__privateAdd(this,_routes,[]);__privateAdd(this,_lastRoute,null);__privateSet(this,_options,__spreadProps(__spreadValues({},options),{rootElement:(options==null?void 0:options.rootElement)||document.body,base:url.normalizeBase(options==null?void 0:options.base)})),__privateSet(this,_announcerElement,new PageAnnouncerElement.PageAnnouncerElement),__privateSet(this,_scroll,new PageScroll.PageScroll(__privateGet(this,_options).scrollSelector)),__privateGet(this,_scroll).update(),__privateSet(this,_links,new LocalLinks.LocalLinks({base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash,includeAnchor:options==null?void 0:options.includeAnchor,onClick:__name((url2,options2)=>{try{this.navigate(url2,options2)}catch(e){window.location.assign(url2)}},"onClick")})),__privateGet(this,_links).update(),__privateSet(this,_history,new history_index.History({onPop:__name(url2=>{this.navigate(url2)},"onPop")}))}history(){return __privateGet(this,_history)}get scroll(){return scroll}get routes(){return __privateGet(this,_routes)}run(){__privateMethod(this,_Router_instances,sortRoutesByPathDepth_fn).call(this),this.navigate(new URL(location.href),{revalidate:!0})}defineRoute(pattern,module2){const route=new Route(pattern,module2);__privateGet(this,_routes).push(route)}navigate(url$1,options){return __async(this,null,function*(){var _a,_b,_c,_d,_e,_f;const isBack=__privateGet(this,_history).isBack,updateId=++__privateWrapper(this,_updateId)._;let fullUrl=url.normalizeURL(url$1,{base:__privateGet(this,_options).base,trailingSlash:__privateGet(this,_options).trailingSlash});if(__privateGet(this,_options).urlModifier&&(fullUrl=__privateGet(this,_options).urlModifier(fullUrl)),!(yield __privateMethod(this,_Router_instances,runPreprocessor_fn).call(this,fullUrl))||__privateGet(this,_updateId)!==updateId||(yield(_b=(_a=__privateGet(this,_options)).beforeNavigation)==null?void 0:_b.call(_a),__privateGet(this,_updateId)!==updateId))return;const{activeRoutes,newRoutes,oldRoutes,keepRoutes}=__privateMethod(this,_Router_instances,categorizeRoutes_fn).call(this,fullUrl);__privateSet(this,_lastRoute,(_c=keepRoutes[keepRoutes.length-1])!=null?_c:null),isBack||(__privateGet(this,_history).push(fullUrl),((_d=options==null?void 0:options.keepScrollPosition)==null||_d)&&__privateGet(this,_scroll).element.scrollTo({top:0,behavior:"instant"})),__privateGet(this,_announcerElement).create(document,fullUrl.pathname),__privateGet(this,_options).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>__privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl)).finished:yield __privateMethod(this,_Router_instances,renderNewRoutes_fn).call(this,oldRoutes,newRoutes,fullUrl),__privateGet(this,_scroll).update(),__privateGet(this,_links).update(),__privateGet(this,_announcerElement).done(),yield(_f=(_e=__privateGet(this,_options)).afterNavigation)==null?void 0:_f.call(_e)})}};_options=new WeakMap,_scroll=new WeakMap,_links=new WeakMap,_history=new WeakMap,_announcerElement=new WeakMap,_updateId=new WeakMap,_routes=new WeakMap,_lastRoute=new WeakMap,_Router_instances=new WeakSet,runPreprocessor_fn=__name(function(url2){return __async(this,null,function*(){if(!__privateGet(this,_options).preprocessor)return!0;try{return yield new Promise((resolve,reject)=>{var _a,_b;(_b=(_a=__privateGet(this,_options)).preprocessor)==null||_b.call(_a,{url:url2,resolve,reject})}),!0}catch(error){return console.error(error!=null?error:"Route change canceled"),!1}})},"#runPreprocessor"),categorizeRoutes_fn=__name(function(url2){let leaf=url2.pathname.replace(__privateGet(this,_options).base,"");leaf.startsWith("/")||(leaf=`/${leaf}`);const activeRoutes=__privateGet(this,_routes).filter(route=>route.isActive);return{activeRoutes,newRoutes:__privateGet(this,_routes).filter(route=>!activeRoutes.includes(route)&&route.testPathname(leaf)),oldRoutes:activeRoutes.filter(route=>!route.testPathname(leaf)),keepRoutes:activeRoutes.filter(route=>route.testPathname(leaf))}},"#categorizeRoutes"),closeOldRoutes_fn=__name(function(routes){routes.forEach(route=>route.close())},"#closeOldRoutes"),renderNewRoutes_fn=__name(function(oldRoutes,routes,url2){return __async(this,null,function*(){var _a,_b;__privateMethod(this,_Router_instances,closeOldRoutes_fn).call(this,oldRoutes);for(const route of routes){const target=(_b=(_a=__privateGet(this,_lastRoute))==null?void 0:_a.nest)!=null?_b:__privateGet(this,_options).rootElement;yield route.render(target,url2),__privateSet(this,_lastRoute,route)}})},"#renderNewRoutes"),sortRoutesByPathDepth_fn=__name(function(){__privateGet(this,_routes).sort((a,b)=>{const depthA=a.pattern.split("/").length,depthB=b.pattern.split("/").length;return depthA-depthB})},"#sortRoutesByPathDepth"),__name(_Router,"Router");let Router=_Router;exports.Router=Router;
|
package/lib/router/index.js
CHANGED
|
@@ -1,268 +1,270 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
throw TypeError(
|
|
1
|
+
var __defProp = Object.defineProperty, __defProps = Object.defineProperties;
|
|
2
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty, __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __typeError = (msg) => {
|
|
6
|
+
throw TypeError(msg);
|
|
7
7
|
};
|
|
8
|
-
var
|
|
9
|
-
for (var
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
for (var
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
set _(
|
|
20
|
-
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
__hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);
|
|
11
|
+
if (__getOwnPropSymbols)
|
|
12
|
+
for (var prop of __getOwnPropSymbols(b))
|
|
13
|
+
__propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);
|
|
14
|
+
return a;
|
|
15
|
+
}, __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)), __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
16
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
17
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
18
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
19
|
+
set _(value) {
|
|
20
|
+
__privateSet(obj, member, value, setter);
|
|
21
21
|
},
|
|
22
22
|
get _() {
|
|
23
|
-
return
|
|
23
|
+
return __privateGet(obj, member, getter);
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
var
|
|
27
|
-
var
|
|
26
|
+
var __async = (__this, __arguments, generator) => new Promise((resolve, reject) => {
|
|
27
|
+
var fulfilled = (value) => {
|
|
28
28
|
try {
|
|
29
|
-
|
|
30
|
-
} catch (
|
|
31
|
-
|
|
29
|
+
step(generator.next(value));
|
|
30
|
+
} catch (e) {
|
|
31
|
+
reject(e);
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, rejected = (value) => {
|
|
34
34
|
try {
|
|
35
|
-
|
|
36
|
-
} catch (
|
|
37
|
-
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
40
|
-
|
|
39
|
+
}, step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
40
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
41
41
|
});
|
|
42
|
-
import { History
|
|
43
|
-
import { L as
|
|
44
|
-
import { P as
|
|
45
|
-
import { P as
|
|
42
|
+
import { History } from "../history/index.js";
|
|
43
|
+
import { L as LocalLinks } from "../LocalLinks-Dwgf3No6.js";
|
|
44
|
+
import { P as PageAnnouncerElement } from "../PageAnnouncerElement-DV9pm_od.js";
|
|
45
|
+
import { P as PageScroll } from "../PageScroll-m3TsHnzR.js";
|
|
46
46
|
import "construct-style-sheets-polyfill";
|
|
47
|
-
import "../index-
|
|
48
|
-
import { a as
|
|
49
|
-
import { URLPattern as
|
|
50
|
-
import { r as
|
|
51
|
-
import { i as
|
|
52
|
-
var
|
|
53
|
-
class
|
|
54
|
-
constructor(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
import "../index-DpKsHe97.js";
|
|
48
|
+
import { a as normalizeBase, n as normalizeURL } from "../url-CWCY_qe_.js";
|
|
49
|
+
import { URLPattern as URLPattern$1 } from "urlpattern-polyfill";
|
|
50
|
+
import { r as render } from "../render-DLcWVnuH.js";
|
|
51
|
+
import { i as isESClass } from "../object-CiIdEmJx.js";
|
|
52
|
+
var _pattern, _module, _urlPattern, _elementConstructor, _elementInstance, _isActive, _nestTarget, _mutationObserver, _permanentHeadNodes, _temporalHeadNodes, _Route_instances, initializeRouteModule_fn, appendPermanentHeadNodes_fn, renderRouteComponent_fn, findNestTarget_fn, cleanup_fn, removeTemporalHeadNodes_fn, handleHeadMutations_fn, waitForHeadNodesLoad_fn, isLoadableNode_fn, _instanceReplaceListener;
|
|
53
|
+
const _Route = class _Route {
|
|
54
|
+
constructor(pattern, module) {
|
|
55
|
+
__privateAdd(this, _Route_instances);
|
|
56
|
+
__privateAdd(this, _pattern);
|
|
57
|
+
__privateAdd(this, _module);
|
|
58
|
+
__privateAdd(this, _urlPattern);
|
|
59
|
+
__privateAdd(this, _elementConstructor, null);
|
|
60
|
+
__privateAdd(this, _elementInstance, null);
|
|
61
|
+
__privateAdd(this, _isActive, !1);
|
|
62
|
+
__privateAdd(this, _nestTarget, null);
|
|
63
|
+
__privateAdd(this, _mutationObserver);
|
|
64
|
+
__privateAdd(this, _permanentHeadNodes, []);
|
|
65
|
+
__privateAdd(this, _temporalHeadNodes, []);
|
|
66
|
+
__privateAdd(this, _instanceReplaceListener, /* @__PURE__ */ __name((e) => {
|
|
67
|
+
__privateGet(this, _elementInstance).removeEventListener(
|
|
68
68
|
"__hmrInstanceReplace",
|
|
69
|
-
|
|
70
|
-
),
|
|
69
|
+
__privateGet(this, _instanceReplaceListener)
|
|
70
|
+
), __privateSet(this, _elementInstance, e.detail.element), __privateGet(this, _elementInstance).addEventListener(
|
|
71
71
|
"__hmrInstanceReplace",
|
|
72
|
-
|
|
72
|
+
__privateGet(this, _instanceReplaceListener)
|
|
73
73
|
);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
}, "#instanceReplaceListener"));
|
|
75
|
+
__privateSet(this, _pattern, pattern), __privateSet(this, _module, module), __privateSet(this, _urlPattern, new URLPattern({ pathname: __privateGet(this, _pattern) })), __privateSet(this, _mutationObserver, new MutationObserver(
|
|
76
|
+
__privateMethod(this, _Route_instances, handleHeadMutations_fn).bind(this)
|
|
77
77
|
));
|
|
78
78
|
}
|
|
79
79
|
get pattern() {
|
|
80
|
-
return
|
|
80
|
+
return __privateGet(this, _pattern);
|
|
81
81
|
}
|
|
82
82
|
get isActive() {
|
|
83
|
-
return
|
|
83
|
+
return __privateGet(this, _isActive);
|
|
84
84
|
}
|
|
85
85
|
get element() {
|
|
86
|
-
return
|
|
86
|
+
return __privateGet(this, _elementInstance);
|
|
87
87
|
}
|
|
88
88
|
get nest() {
|
|
89
|
-
return
|
|
89
|
+
return __privateGet(this, _nestTarget);
|
|
90
90
|
}
|
|
91
|
-
testPathname(
|
|
92
|
-
return
|
|
91
|
+
testPathname(pathname) {
|
|
92
|
+
return __privateGet(this, _urlPattern).test({ pathname });
|
|
93
93
|
}
|
|
94
|
-
render(
|
|
95
|
-
return
|
|
96
|
-
|
|
94
|
+
render(container, url) {
|
|
95
|
+
return __async(this, null, function* () {
|
|
96
|
+
__privateGet(this, _mutationObserver).observe(document.head, {
|
|
97
97
|
childList: !0,
|
|
98
98
|
subtree: !0
|
|
99
|
-
}),
|
|
99
|
+
}), __privateGet(this, _elementConstructor) ? __privateMethod(this, _Route_instances, appendPermanentHeadNodes_fn).call(this) : yield __privateMethod(this, _Route_instances, initializeRouteModule_fn).call(this), yield __privateMethod(this, _Route_instances, waitForHeadNodesLoad_fn).call(this), __privateGet(this, _elementConstructor) && (yield __privateMethod(this, _Route_instances, renderRouteComponent_fn).call(this, container, url)), __privateGet(this, _mutationObserver).disconnect();
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
close() {
|
|
103
|
-
|
|
103
|
+
__privateMethod(this, _Route_instances, cleanup_fn).call(this);
|
|
104
104
|
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
const
|
|
109
|
-
|
|
105
|
+
};
|
|
106
|
+
_pattern = new WeakMap(), _module = new WeakMap(), _urlPattern = new WeakMap(), _elementConstructor = new WeakMap(), _elementInstance = new WeakMap(), _isActive = new WeakMap(), _nestTarget = new WeakMap(), _mutationObserver = new WeakMap(), _permanentHeadNodes = new WeakMap(), _temporalHeadNodes = new WeakMap(), _Route_instances = new WeakSet(), initializeRouteModule_fn = /* @__PURE__ */ __name(function() {
|
|
107
|
+
return __async(this, null, function* () {
|
|
108
|
+
const content = yield __privateGet(this, _module).call(this);
|
|
109
|
+
__privateSet(this, _temporalHeadNodes, [...__privateGet(this, _permanentHeadNodes)]), typeof content.default == "function" && __privateSet(this, _elementConstructor, content.default);
|
|
110
110
|
});
|
|
111
|
-
},
|
|
112
|
-
|
|
113
|
-
document.head.appendChild(
|
|
111
|
+
}, "#initializeRouteModule"), appendPermanentHeadNodes_fn = /* @__PURE__ */ __name(function() {
|
|
112
|
+
__privateGet(this, _permanentHeadNodes).forEach((node) => {
|
|
113
|
+
document.head.appendChild(node.cloneNode(!0));
|
|
114
114
|
});
|
|
115
|
-
},
|
|
116
|
-
return
|
|
117
|
-
var
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)), (
|
|
115
|
+
}, "#appendPermanentHeadNodes"), renderRouteComponent_fn = /* @__PURE__ */ __name(function(container, url) {
|
|
116
|
+
return __async(this, null, function* () {
|
|
117
|
+
var _a;
|
|
118
|
+
const routeParams = { urlPatternResult: __privateGet(this, _urlPattern).exec({ pathname: url.pathname }) };
|
|
119
|
+
isESClass(__privateGet(this, _elementConstructor)) ? (__privateSet(this, _elementInstance, new (__privateGet(this, _elementConstructor))(routeParams)), container.appendChild(__privateGet(this, _elementInstance))) : __privateSet(this, _elementInstance, render(
|
|
120
|
+
container,
|
|
121
|
+
__privateGet(this, _elementConstructor),
|
|
122
|
+
routeParams
|
|
123
|
+
)), (_a = __privateGet(this, _elementInstance)) == null || _a.addEventListener(
|
|
124
124
|
"__hmrInstanceReplace",
|
|
125
|
-
|
|
126
|
-
),
|
|
125
|
+
__privateGet(this, _instanceReplaceListener)
|
|
126
|
+
), __privateMethod(this, _Route_instances, findNestTarget_fn).call(this), __privateSet(this, _isActive, !0);
|
|
127
127
|
});
|
|
128
|
-
},
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
},
|
|
132
|
-
|
|
128
|
+
}, "#renderRouteComponent"), findNestTarget_fn = /* @__PURE__ */ __name(function() {
|
|
129
|
+
var _a;
|
|
130
|
+
__privateGet(this, _elementInstance) && __privateSet(this, _nestTarget, __privateGet(this, _elementInstance).querySelector("[data-nest]") || ((_a = __privateGet(this, _elementInstance).shadowRoot) == null ? void 0 : _a.querySelector("[data-nest]")) || __privateGet(this, _elementInstance).shadowRoot || __privateGet(this, _elementInstance));
|
|
131
|
+
}, "#findNestTarget"), cleanup_fn = /* @__PURE__ */ __name(function() {
|
|
132
|
+
__privateGet(this, _mutationObserver).disconnect(), __privateGet(this, _elementInstance) && (__privateGet(this, _elementInstance).removeEventListener(
|
|
133
133
|
"__hmrInstanceReplace",
|
|
134
|
-
|
|
135
|
-
),
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}),
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
__privateGet(this, _instanceReplaceListener)
|
|
135
|
+
), __privateGet(this, _elementInstance).remove()), __privateSet(this, _isActive, !1), __privateMethod(this, _Route_instances, removeTemporalHeadNodes_fn).call(this);
|
|
136
|
+
}, "#cleanup"), removeTemporalHeadNodes_fn = /* @__PURE__ */ __name(function() {
|
|
137
|
+
__privateGet(this, _temporalHeadNodes).forEach((node) => {
|
|
138
|
+
node.parentNode === document.head && document.head.removeChild(node);
|
|
139
|
+
}), __privateSet(this, _temporalHeadNodes, []);
|
|
140
|
+
}, "#removeTemporalHeadNodes"), handleHeadMutations_fn = /* @__PURE__ */ __name(function(mutations) {
|
|
141
|
+
mutations.forEach((mutation) => {
|
|
142
|
+
mutation.addedNodes.forEach((node) => {
|
|
143
|
+
__privateGet(this, _elementConstructor) ? __privateGet(this, _temporalHeadNodes).push(node) : __privateGet(this, _permanentHeadNodes).push(node);
|
|
144
144
|
});
|
|
145
145
|
});
|
|
146
|
-
},
|
|
147
|
-
return
|
|
148
|
-
const
|
|
146
|
+
}, "#handleHeadMutations"), waitForHeadNodesLoad_fn = /* @__PURE__ */ __name(function() {
|
|
147
|
+
return __async(this, null, function* () {
|
|
148
|
+
const loadableNodes = __privateGet(this, _permanentHeadNodes).filter(__privateMethod(this, _Route_instances, isLoadableNode_fn));
|
|
149
149
|
yield Promise.all(
|
|
150
|
-
|
|
151
|
-
(
|
|
152
|
-
|
|
150
|
+
loadableNodes.map(
|
|
151
|
+
(node) => new Promise((resolve) => {
|
|
152
|
+
__privateMethod(this, _Route_instances, isLoadableNode_fn).call(this, node) ? node.onload = () => resolve() : resolve();
|
|
153
153
|
})
|
|
154
154
|
)
|
|
155
155
|
);
|
|
156
156
|
});
|
|
157
|
-
},
|
|
158
|
-
return
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
157
|
+
}, "#waitForHeadNodesLoad"), isLoadableNode_fn = /* @__PURE__ */ __name(function(node) {
|
|
158
|
+
return node instanceof HTMLElement && (node.tagName === "STYLE" || node.tagName === "SCRIPT" || node.tagName === "LINK");
|
|
159
|
+
}, "#isLoadableNode"), _instanceReplaceListener = new WeakMap(), __name(_Route, "Route");
|
|
160
|
+
let Route = _Route;
|
|
161
|
+
globalThis.URLPattern = URLPattern$1;
|
|
162
|
+
var _options, _scroll, _links, _history, _announcerElement, _updateId, _routes, _lastRoute, _Router_instances, runPreprocessor_fn, categorizeRoutes_fn, closeOldRoutes_fn, renderNewRoutes_fn, sortRoutesByPathDepth_fn;
|
|
163
|
+
const _Router = class _Router {
|
|
164
|
+
constructor(options) {
|
|
165
|
+
__privateAdd(this, _Router_instances);
|
|
166
|
+
__privateAdd(this, _options, null);
|
|
167
|
+
__privateAdd(this, _scroll, null);
|
|
168
|
+
__privateAdd(this, _links, null);
|
|
169
|
+
__privateAdd(this, _history, null);
|
|
170
|
+
__privateAdd(this, _announcerElement, null);
|
|
171
|
+
__privateAdd(this, _updateId, 0);
|
|
172
|
+
__privateAdd(this, _routes, []);
|
|
173
|
+
__privateAdd(this, _lastRoute, null);
|
|
174
|
+
__privateSet(this, _options, __spreadProps(__spreadValues({}, options), {
|
|
175
|
+
rootElement: (options == null ? void 0 : options.rootElement) || document.body,
|
|
176
|
+
base: normalizeBase(options == null ? void 0 : options.base)
|
|
177
|
+
})), __privateSet(this, _announcerElement, new PageAnnouncerElement()), __privateSet(this, _scroll, new PageScroll(__privateGet(this, _options).scrollSelector)), __privateGet(this, _scroll).update(), __privateSet(this, _links, new LocalLinks({
|
|
178
|
+
base: __privateGet(this, _options).base,
|
|
179
|
+
trailingSlash: __privateGet(this, _options).trailingSlash,
|
|
180
|
+
includeAnchor: options == null ? void 0 : options.includeAnchor,
|
|
181
|
+
onClick: /* @__PURE__ */ __name((url, options2) => {
|
|
181
182
|
try {
|
|
182
|
-
this.navigate(
|
|
183
|
-
} catch (
|
|
184
|
-
window.location.assign(
|
|
183
|
+
this.navigate(url, options2);
|
|
184
|
+
} catch (e) {
|
|
185
|
+
window.location.assign(url);
|
|
185
186
|
}
|
|
186
|
-
}
|
|
187
|
-
})),
|
|
188
|
-
onPop: (
|
|
189
|
-
this.navigate(
|
|
190
|
-
}
|
|
187
|
+
}, "onClick")
|
|
188
|
+
})), __privateGet(this, _links).update(), __privateSet(this, _history, new History({
|
|
189
|
+
onPop: /* @__PURE__ */ __name((url) => {
|
|
190
|
+
this.navigate(url);
|
|
191
|
+
}, "onPop")
|
|
191
192
|
}));
|
|
192
193
|
}
|
|
193
194
|
history() {
|
|
194
|
-
return
|
|
195
|
+
return __privateGet(this, _history);
|
|
195
196
|
}
|
|
196
197
|
get scroll() {
|
|
197
198
|
return scroll;
|
|
198
199
|
}
|
|
199
200
|
get routes() {
|
|
200
|
-
return
|
|
201
|
+
return __privateGet(this, _routes);
|
|
201
202
|
}
|
|
202
203
|
run() {
|
|
203
|
-
|
|
204
|
+
__privateMethod(this, _Router_instances, sortRoutesByPathDepth_fn).call(this), this.navigate(new URL(location.href), { revalidate: !0 });
|
|
204
205
|
}
|
|
205
|
-
defineRoute(
|
|
206
|
-
const
|
|
207
|
-
|
|
206
|
+
defineRoute(pattern, module) {
|
|
207
|
+
const route = new Route(pattern, module);
|
|
208
|
+
__privateGet(this, _routes).push(route);
|
|
208
209
|
}
|
|
209
|
-
navigate(
|
|
210
|
-
return
|
|
211
|
-
var
|
|
212
|
-
const
|
|
213
|
-
let
|
|
214
|
-
base:
|
|
215
|
-
trailingSlash:
|
|
210
|
+
navigate(url, options) {
|
|
211
|
+
return __async(this, null, function* () {
|
|
212
|
+
var _a, _b, _c, _d, _e, _f;
|
|
213
|
+
const isBack = __privateGet(this, _history).isBack, updateId = ++__privateWrapper(this, _updateId)._;
|
|
214
|
+
let fullUrl = normalizeURL(url, {
|
|
215
|
+
base: __privateGet(this, _options).base,
|
|
216
|
+
trailingSlash: __privateGet(this, _options).trailingSlash
|
|
216
217
|
});
|
|
217
|
-
if (
|
|
218
|
+
if (__privateGet(this, _options).urlModifier && (fullUrl = __privateGet(this, _options).urlModifier(fullUrl)), !(yield __privateMethod(this, _Router_instances, runPreprocessor_fn).call(this, fullUrl)) || __privateGet(this, _updateId) !== updateId || (yield (_b = (_a = __privateGet(this, _options)).beforeNavigation) == null ? void 0 : _b.call(_a), __privateGet(this, _updateId) !== updateId))
|
|
218
219
|
return;
|
|
219
|
-
const { activeRoutes
|
|
220
|
-
|
|
220
|
+
const { activeRoutes, newRoutes, oldRoutes, keepRoutes } = __privateMethod(this, _Router_instances, categorizeRoutes_fn).call(this, fullUrl);
|
|
221
|
+
__privateSet(this, _lastRoute, (_c = keepRoutes[keepRoutes.length - 1]) != null ? _c : null), isBack || (__privateGet(this, _history).push(fullUrl), ((_d = options == null ? void 0 : options.keepScrollPosition) == null || _d) && __privateGet(this, _scroll).element.scrollTo({ top: 0, behavior: "instant" })), __privateGet(this, _announcerElement).create(document, fullUrl.pathname), __privateGet(this, _options).viewTransition && document.startViewTransition ? yield document.startViewTransition(() => __privateMethod(this, _Router_instances, renderNewRoutes_fn).call(this, oldRoutes, newRoutes, fullUrl)).finished : yield __privateMethod(this, _Router_instances, renderNewRoutes_fn).call(this, oldRoutes, newRoutes, fullUrl), __privateGet(this, _scroll).update(), __privateGet(this, _links).update(), __privateGet(this, _announcerElement).done(), yield (_f = (_e = __privateGet(this, _options)).afterNavigation) == null ? void 0 : _f.call(_e);
|
|
221
222
|
});
|
|
222
223
|
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return
|
|
226
|
-
if (!
|
|
224
|
+
};
|
|
225
|
+
_options = new WeakMap(), _scroll = new WeakMap(), _links = new WeakMap(), _history = new WeakMap(), _announcerElement = new WeakMap(), _updateId = new WeakMap(), _routes = new WeakMap(), _lastRoute = new WeakMap(), _Router_instances = new WeakSet(), runPreprocessor_fn = /* @__PURE__ */ __name(function(url) {
|
|
226
|
+
return __async(this, null, function* () {
|
|
227
|
+
if (!__privateGet(this, _options).preprocessor)
|
|
227
228
|
return !0;
|
|
228
229
|
try {
|
|
229
|
-
return yield new Promise((
|
|
230
|
-
var
|
|
231
|
-
(
|
|
230
|
+
return yield new Promise((resolve, reject) => {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
(_b = (_a = __privateGet(this, _options)).preprocessor) == null || _b.call(_a, { url, resolve, reject });
|
|
232
233
|
}), !0;
|
|
233
|
-
} catch (
|
|
234
|
-
return console.error(
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return console.error(error != null ? error : "Route change canceled"), !1;
|
|
235
236
|
}
|
|
236
237
|
});
|
|
237
|
-
},
|
|
238
|
-
let
|
|
239
|
-
|
|
240
|
-
const
|
|
238
|
+
}, "#runPreprocessor"), categorizeRoutes_fn = /* @__PURE__ */ __name(function(url) {
|
|
239
|
+
let leaf = url.pathname.replace(__privateGet(this, _options).base, "");
|
|
240
|
+
leaf.startsWith("/") || (leaf = `/${leaf}`);
|
|
241
|
+
const activeRoutes = __privateGet(this, _routes).filter((route) => route.isActive);
|
|
241
242
|
return {
|
|
242
|
-
activeRoutes
|
|
243
|
-
newRoutes:
|
|
244
|
-
(
|
|
243
|
+
activeRoutes,
|
|
244
|
+
newRoutes: __privateGet(this, _routes).filter(
|
|
245
|
+
(route) => !activeRoutes.includes(route) && route.testPathname(leaf)
|
|
245
246
|
),
|
|
246
|
-
oldRoutes:
|
|
247
|
-
keepRoutes:
|
|
247
|
+
oldRoutes: activeRoutes.filter((route) => !route.testPathname(leaf)),
|
|
248
|
+
keepRoutes: activeRoutes.filter((route) => route.testPathname(leaf))
|
|
248
249
|
};
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
},
|
|
252
|
-
return
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
for (const
|
|
256
|
-
const
|
|
257
|
-
yield
|
|
250
|
+
}, "#categorizeRoutes"), closeOldRoutes_fn = /* @__PURE__ */ __name(function(routes) {
|
|
251
|
+
routes.forEach((route) => route.close());
|
|
252
|
+
}, "#closeOldRoutes"), renderNewRoutes_fn = /* @__PURE__ */ __name(function(oldRoutes, routes, url) {
|
|
253
|
+
return __async(this, null, function* () {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
__privateMethod(this, _Router_instances, closeOldRoutes_fn).call(this, oldRoutes);
|
|
256
|
+
for (const route of routes) {
|
|
257
|
+
const target = (_b = (_a = __privateGet(this, _lastRoute)) == null ? void 0 : _a.nest) != null ? _b : __privateGet(this, _options).rootElement;
|
|
258
|
+
yield route.render(target, url), __privateSet(this, _lastRoute, route);
|
|
258
259
|
}
|
|
259
260
|
});
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
const
|
|
263
|
-
return
|
|
261
|
+
}, "#renderNewRoutes"), sortRoutesByPathDepth_fn = /* @__PURE__ */ __name(function() {
|
|
262
|
+
__privateGet(this, _routes).sort((a, b) => {
|
|
263
|
+
const depthA = a.pattern.split("/").length, depthB = b.pattern.split("/").length;
|
|
264
|
+
return depthA - depthB;
|
|
264
265
|
});
|
|
265
|
-
};
|
|
266
|
+
}, "#sortRoutesByPathDepth"), __name(_Router, "Router");
|
|
267
|
+
let Router = _Router;
|
|
266
268
|
export {
|
|
267
|
-
|
|
269
|
+
Router
|
|
268
270
|
};
|