@aevantec/litevue 0.5.8 → 0.5.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/litevue-devtools.iife.js +1 -1
- package/dist/litevue-devtools.mjs +1 -1
- package/dist/litevue-devtools.umd.js +1 -1
- package/dist/litevue-plugins.dev.iife.js +10 -5
- package/dist/litevue-plugins.dev.mjs +10 -5
- package/dist/litevue-plugins.iife.js +1 -1
- package/dist/litevue-plugins.mjs +1 -1
- package/dist/litevue-plugins.umd.js +1 -1
- package/dist/litevue.dev.iife.js +89 -73
- package/dist/litevue.dev.mjs +89 -73
- package/dist/litevue.iife.js +1 -1
- package/dist/litevue.mjs +1 -1
- package/dist/litevue.umd.js +1 -1
- package/dist/plugins/media.iife.js +1 -1
- package/dist/plugins/media.mjs +1 -1
- package/dist/plugins/media.umd.js +1 -1
- package/dist/plugins/morph.dev.iife.js +10 -5
- package/dist/plugins/morph.dev.mjs +10 -5
- package/dist/plugins/morph.iife.js +1 -1
- package/dist/plugins/morph.mjs +1 -1
- package/dist/plugins/morph.umd.js +1 -1
- package/dist/types/context.d.mts +0 -1
- package/dist/types/context.d.ts +0 -1
- package/dist/types/devtools-panel/chrome.d.mts +30 -0
- package/dist/types/devtools-panel/chrome.d.ts +30 -0
- package/dist/types/devtools-panel/styles.d.mts +17 -0
- package/dist/types/devtools-panel/styles.d.ts +17 -0
- package/dist/types/devtools-panel/values.d.mts +25 -0
- package/dist/types/devtools-panel/values.d.ts +25 -0
- package/dist/types/eval.d.mts +3 -0
- package/dist/types/eval.d.ts +3 -0
- package/dist/types/magics.d.mts +6 -4
- package/dist/types/magics.d.ts +6 -4
- package/dist/types/plugins/morph/index.d.mts +6 -0
- package/dist/types/plugins/morph/index.d.ts +6 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@aevantec/litevue")):"function"==typeof define&&define.amd?define(["exports","@aevantec/litevue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVuePlugins={},e.LiteVue)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var n={9:/\d/,a:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},r=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),o=(e,t)=>{const n=e.split(","),o=t.split(",");let i=0;for(let s=0;s<n.length;s++)i=Math.max(i,r(n[s])+r(o[s%o.length]));return i},i="litevue:",s=Object.create(null),c="local",a=e=>{const t=e??c;return"string"!=typeof t?t:s[t]??(e=>{try{if("local"===e||"localStorage"===e)return localStorage;if("session"===e||"sessionStorage"===e)return sessionStorage}catch{}})(t)},l=(e,t,n,r,o)=>{if(!r)return o(()=>{});const i=((e,t)=>(t??Object.keys(e)).filter(t=>{if("$"===t[0])return!1;const n=Object.getOwnPropertyDescriptor(e,t);if(n&&n.get&&!n.set)return!1;const r=n&&n.value;return(!r||!0!==r.__v_isRef||!0!==r.__v_isReadonly)&&"function"!=typeof e[t]}))(e,n);try{const n=JSON.parse(r.getItem(t)||"null");if(n)for(const t of i)t in n&&(e[t]=n[t])}catch{}return o(()=>{const n={};for(const t of i)n[t]=e[t];try{r.setItem(t,JSON.stringify(n))}catch{}})},f=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||!!t.preserve?.(e)),d=/^(?:v-|:|@)/,u=/^(?::|v-bind:)/,p=["id","data-key","data-id"],m=e=>{for(const t of p){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},v=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},h=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),b=(e,t)=>{const n=(e=>{const t=new Set;for(const{name:n}of e.attributes)u.test(n)?t.add(n.replace(u,"").split(".")[0]):"v-model"===n&&(t.add("value"),t.add("checked"));return t})(t);for(const{name:r,value:o}of[...t.attributes])d.test(r)||n.has(r)||e.getAttribute(r)!==o&&e.setAttribute(r,o);for(const{name:r}of[...e.attributes])n.has(r)||t.hasAttribute(r)||e.removeAttribute(r)},g=(e,t,n,r)=>{if(e.nodeType!==t.nodeType)return y(e,t,n,r);if(3===e.nodeType||8===e.nodeType){const r=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(r,n))return;return void(e.data!==r&&(e.data=r))}if(1!==e.nodeType)return;const o=e,i=t;if(o.tagName!==i.tagName)return y(e,t,n,r);r.skip?.(o,i)||o.hasAttribute("data-morph-skip")||(b(o,i),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||h(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(h(t))return!0;return!1})(i)||x(o,i,o.__ctx||n,r))},y=(e,t,n,r)=>{if(f(e,r))return;const o=t.cloneNode(!0);!1!==r.beforeNodeAdded?.(o)&&(n?.dispose?.(e),e.parentNode.replaceChild(o,e),r.afterNodeRemoved?.(e),k(o,n))},k=(e,t)=>{const n=t||v(e.parentNode);n?.walk?.(e,n)},x=(e,t,n,r)=>{const o=r.key||m,i=new Map;for(let f=e.firstChild;f;f=f.nextSibling)if(1===f.nodeType){const e=o(f);if(null==e)continue;i.set(e,f)}const s=e=>e&&1===e.nodeType?o(e):null;let c=e.firstChild,a=t.firstChild;const l=t=>{const o=t.cloneNode(!0);!1!==r.beforeNodeAdded?.(o)&&(e.insertBefore(o,c),k(o,n))};for(;a;){const t=a.nextSibling,o=s(a);if(null!=o){const t=i.get(o);t?(t===c?c=c.nextSibling:e.insertBefore(t,c),i.delete(o),g(t,a,n,r)):l(a)}else if(c&&null==s(c)){const e=c.nextSibling;g(c,a,n,r),c=e}else l(a);a=t}for(;c;){const t=c.nextSibling;f(c,r)||(n?.dispose?.(c),e.removeChild(c),r.afterNodeRemoved?.(c)),c=t}},w=(e,t,n={})=>{let r;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const o=n.content;r=1===o.childElementCount?o.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(o),t})()}else r=t;if(r){const t=S();g(e,r,v(e),n),t()}return e},S=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,r=null;try{n=t.selectionStart,r=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,r)}catch{}}},E={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},A=Object.freeze({...E}),O={mobile:"base",tablet:"md",desktop:"lg"},L=/^\d+$/,T=(0,t.reactive)({bp:"base",tick:0}),$={...E},j=["base"],_=!1,N=[],q=new Map,P=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia,C=(e,t)=>e.addEventListener?(e.addEventListener("change",t),{mql:e,off:()=>e.removeEventListener("change",t)}):(e.addListener(t),{mql:e,off:()=>e.removeListener(t)}),D=()=>{for(let e=N.length-1;e>=0;e--)if(N[e].mql.matches)return j[e+1];return"base"},M=()=>{N.forEach(e=>e.off()),N=[];const e=Object.keys($).filter(e=>$[e]>0).sort((e,t)=>$[e]-$[t]);j=["base",...e],P()&&(N=e.map(e=>{const t=window.matchMedia(`(min-width: ${$[e]}px)`);return C(t,()=>{T.bp=D()})}),T.bp=D())},R=()=>{_||(_=!0,M()),T.tick},z=e=>{if(!P())return!1;let t=q.get(e);if(!t){const n=window.matchMedia(e);t=C(n,()=>T.tick++),q.set(e,t)}return t.mql.matches},I=e=>{if("number"==typeof e)return e;if("base"===e)return 0;if(L.test(e))return Number(e);const t=O[e];return void 0!==t?"base"===t?0:$[t]:$[e]},B=e=>{if(e<=0)return!0;const t=j.findIndex(t=>"base"!==t&&$[t]===e);return-1!==t?j.indexOf(T.bp)>=t:(T.tick,z(`(min-width: ${e}px)`))},H=new Set,J=(e,t)=>{let n;R();let r=-1;for(const o of Object.keys(e)){const t=I(o);void 0!==t?t>=r&&B(t)&&(r=t,n=e[o]):(j.join(", "),Object.keys(O).join(", "))}return void 0!==n?n:t},K=e=>{const t=O[e],n=$[t];return void 0!==n?n:E[t]},V=Object.defineProperties((e,t)=>J(e,t),{props:{value:e=>{R();const t={};for(const n of Object.keys(e))t[n]=J(e[n]);return t}},breakpoint:{get:()=>(R(),T.bp),enumerable:!0},device:{get:()=>(R(),B(K("tablet"))?B(K("desktop"))?"desktop":"tablet":"mobile"),enumerable:!0},atLeast:{value:e=>{R();const t=I(e);return void 0!==t&&B(t)}},match:{value:e=>(R(),z(e))},configure:{value:({breakpoints:e})=>{e&&($={...e},_&&(M(),T.tick++))}}}),Z=()=>{N.forEach(e=>e.off()),q.forEach(e=>e.off()),N=[],q.clear(),_=!1};e.collapse=e=>{e.directive("collapse",({el:e,get:t,effect:n,modifiers:r})=>{const o=e;let i=250;for(const u in r||{}){const e=/^duration-(\d+)$/.exec(u);e&&(i=+e[1])}const s=["overflow","height","transition"],c=s.map(e=>o.style[e]);o.style.overflow="hidden";let a=!0,l=0;const f=new Set,d=(e,t)=>{const n=setTimeout(()=>{f.delete(n),e()},t);f.add(n)};return n(()=>{const e=!!t(),n=++l;if(a)return a=!1,e||(o.style.height="0px"),void d(()=>{o.style.transition=`height ${i}ms ease`});e?(o.style.height=o.scrollHeight+"px",d(()=>{n===l&&(o.style.height="")},i)):(o.style.height=o.scrollHeight+"px",o.offsetHeight,o.style.height="0px")}),()=>{f.forEach(clearTimeout),s.forEach((e,t)=>o.style[e]=c[t])}})},e.defaultBreakpoints=A,e.focus=e=>{e.directive("focus",({el:e,get:t,effect:n,modifiers:r})=>{let o=!0;return n(()=>{const n=!!t();Promise.resolve().then(()=>{o&&n&&(e.focus(),r?.select&&e.select&&e.select())})}),()=>{o=!1}}),e.directive("trap",({el:e,get:t,effect:n})=>{let r=!1,o=null;const i=()=>[...e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')].filter(e=>!e.hasAttribute("disabled")),s=t=>{if("Tab"!==t.key)return;const n=i();if(!n.length)return void t.preventDefault();const r=n[0],o=n[n.length-1],s=document.activeElement;e.contains(s)?t.shiftKey&&s===r?(t.preventDefault(),o.focus()):t.shiftKey||s!==o||(t.preventDefault(),r.focus()):(t.preventDefault(),r.focus())},c=()=>{r=!1,document.removeEventListener("keydown",s,!0),o&&o.focus&&o.focus()};return n(()=>{const n=!!t();n&&!r?(r=!0,o=document.activeElement,document.addEventListener("keydown",s,!0),Promise.resolve().then(()=>{r&&(i()[0]||e).focus()})):!n&&r&&c()}),()=>{r&&c()}})},e.intersect=e=>{e.directive("intersect",({el:e,get:t,modifiers:n})=>{const r=new IntersectionObserver(e=>{for(const o of e)(n?.leave?!o.isIntersecting:o.isIntersecting)&&(t(),n?.once&&r.disconnect())},{threshold:n?.full?1:0});return r.observe(e),()=>r.disconnect()})},e.mask=e=>{e.directive("mask",({el:e,exp:t})=>{const r=e,o=()=>{const e=((e,t)=>{let r="",o="",i=0;for(let s=0;s<t.length;s++){const c=n[t[s]];if(c){for(;i<e.length&&!c.test(e[i]);)i++;if(i>=e.length)break;r+=o+e[i++],o=""}else o+=t[s],e[i]===t[s]&&i++}return r})(r.value,t);e!==r.value&&(r.value=e)};return e.addEventListener("input",o),o(),()=>e.removeEventListener("input",o)})},e.media=(e,t)=>(t?.breakpoints&&JSON.stringify(t.breakpoints),t&&V.configure(t),e.scope.$mq=V,e.scope.$mqProps=V.props,e.scope.$mqAtLeast=V.atLeast,e.scope.$mqMatch=V.match,Object.defineProperty(e.scope,"$mqBreakpoint",{get:()=>V.breakpoint,enumerable:!0,configurable:!0}),Object.defineProperty(e.scope,"$mqDevice",{get:()=>V.device,enumerable:!0,configurable:!0}),Z),e.morph=w,e.morphPlugin=e=>{e.scope.$morph=w},e.mq=V,e.persist=e=>{e.directive("persist",({ctx:e,el:t,exp:n,arg:r,modifiers:o,effect:s})=>{const c=i+(n||t.id);let f;for(const i in o||{})if(a(i)){f=i;break}const d=r?r.split(",").map(e=>e.trim()).filter(Boolean):void 0;l(e.scope,c,d,a(f),s)})},e.persistStore=(e,n={})=>{const r=(0,t.store)(e);if(!r)return()=>{};const o=a(n.storage);return l(r,i+(n.key??e),n.keys,o,t.watchEffect)},e.registerStorage=(e,t)=>{s[e]=t},e.resetMedia=()=>{Z(),$={...E},j=["base",...Object.keys($).sort((e,t)=>$[e]-$[t])],_=!1,H.clear(),T.bp="base",T.tick=0},e.resize=e=>{e.directive("resize",({el:e,get:t,exp:n})=>{const r=t(`(($width, $height) => { ${n} })`),o=new ResizeObserver(e=>{for(const t of e){const e=t.contentRect;r(e.width,e.height)}});return o.observe(e),()=>o.disconnect()})},e.setDefaultStorage=e=>{c=e},e.transition=e=>{e.directive("transition",({el:e,get:t,effect:n,arg:r,modifiers:i,exp:s})=>{const c=e,a=r||"v",l=e=>`${a}-${e}`;let f,d=0,u=!0;const p=()=>{c.classList.remove(l("enter-from"),l("enter-active"),l("enter-to"),l("leave-from"),l("leave-active"),l("leave-to"))},m=(e,t)=>{const n=++d;p(),c.classList.add(l(e+"-from"),l(e+"-active")),c.offsetWidth,c.classList.remove(l(e+"-from")),c.classList.add(l(e+"-to")),clearTimeout(f),f=setTimeout(()=>{n===d&&(p(),t&&t())},(e=>{const t=getComputedStyle(e);return Math.max(o(t.transitionDuration,t.transitionDelay),o(t.animationDuration,t.animationDelay))})(c))};if(!s){let e=!0;return Promise.resolve().then(()=>{e&&m("enter")}),c.__leave=()=>new Promise(e=>m("leave",e)),()=>{e=!1,clearTimeout(f),delete c.__leave}}return n(()=>{const e=!!t();if(u)return u=!1,c.style.display=e?"":"none",void(e&&i?.appear&&m("enter"));e?(c.style.display="",m("enter")):m("leave",()=>{c.style.display="none"})}),()=>clearTimeout(f)})}});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@aevantec/litevue")):"function"==typeof define&&define.amd?define(["exports","@aevantec/litevue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LiteVuePlugins={},e.LiteVue)}(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});var n={9:/\d/,a:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},r=e=>(parseFloat(e)||0)*(e.includes("ms")?1:1e3),o=(e,t)=>{const n=e.split(","),o=t.split(",");let i=0;for(let s=0;s<n.length;s++)i=Math.max(i,r(n[s])+r(o[s%o.length]));return i},i="litevue:",s=Object.create(null),c="local",a=e=>{const t=e??c;return"string"!=typeof t?t:s[t]??(e=>{try{if("local"===e||"localStorage"===e)return localStorage;if("session"===e||"sessionStorage"===e)return sessionStorage}catch{}})(t)},l=(e,t,n,r,o)=>{if(!r)return o(()=>{});const i=((e,t)=>(t??Object.keys(e)).filter(t=>{if("$"===t[0])return!1;const n=Object.getOwnPropertyDescriptor(e,t);if(n&&n.get&&!n.set)return!1;const r=n&&n.value;return(!r||!0!==r.__v_isRef||!0!==r.__v_isReadonly)&&"function"!=typeof e[t]}))(e,n);try{const n=JSON.parse(r.getItem(t)||"null");if(n)for(const t of i)t in n&&(e[t]=n[t])}catch{}return o(()=>{const n={};for(const t of i)n[t]=e[t];try{r.setItem(t,JSON.stringify(n))}catch{}})},f=(e,t)=>1===e.nodeType&&(e.hasAttribute("data-morph-preserve")||!!t.preserve?.(e)),d=/^(?:v-|:|@)/,u=/^(?::|v-bind:)/,p=/^v-(?!scope|on:)/,m=["id","data-key","data-id"],v=e=>{for(const t of m){const n=e.getAttribute(t);if(null!=n)return t+"="+n}return null},h=e=>{for(let t=e;t;t=t.parentElement)if(t.__ctx)return t.__ctx},b=e=>e.hasAttribute("v-for")||e.hasAttribute("v-if")||e.hasAttribute("v-else")||e.hasAttribute("v-else-if"),g=(e,t)=>{const n=(e=>{const t=new Set;for(const{name:n}of e.attributes)u.test(n)?t.add(n.replace(u,"").split(".")[0]):"v-model"===n?(t.add("value"),t.add("checked")):"v-bind"===n?t.add("*"):p.test(n)&&t.add("style");return t})(t);for(const{name:r,value:o}of[...t.attributes])d.test(r)||n.has(r)||e.getAttribute(r)!==o&&e.setAttribute(r,o);for(const{name:r}of[...e.attributes])n.has("*")||n.has(r)||t.hasAttribute(r)||e.removeAttribute(r)},y=(e,t,n,r)=>{if(e.nodeType!==t.nodeType)return k(e,t,n,r);if(3===e.nodeType||8===e.nodeType){const r=t.data;if(((e,t)=>e.includes(t?t.delimiters[0]:"{{"))(r,n))return;return void(e.data!==r&&(e.data=r))}if(1!==e.nodeType)return;const o=e,i=t;if(o.tagName!==i.tagName)return k(e,t,n,r);r.skip?.(o,i)||o.hasAttribute("data-morph-skip")||(g(o,i),(e=>{if(e.hasAttribute("v-text")||e.hasAttribute("v-html")||e.hasAttribute("v-pre")||e.hasAttribute("v-once")||b(e))return!0;for(let t=e.firstElementChild;t;t=t.nextElementSibling)if(b(t))return!0;return!1})(i)||w(o,i,o.__ctx||n,r))},k=(e,t,n,r)=>{if(f(e,r))return;const o=t.cloneNode(!0);!1!==r.beforeNodeAdded?.(o)&&(n?.dispose?.(e),e.parentNode.replaceChild(o,e),r.afterNodeRemoved?.(e),x(o,n))},x=(e,t)=>{const n=t||h(e.parentNode);n?.walk?.(e,n)},w=(e,t,n,r)=>{const o=r.key||v,i=new Map;for(let f=e.firstChild;f;f=f.nextSibling)if(1===f.nodeType){const e=o(f);if(null==e)continue;i.set(e,f)}const s=e=>e&&1===e.nodeType?o(e):null;let c=e.firstChild,a=t.firstChild;const l=t=>{const o=t.cloneNode(!0);!1!==r.beforeNodeAdded?.(o)&&(e.insertBefore(o,c),x(o,n))};for(;a;){const t=a.nextSibling,o=s(a);if(null!=o){const t=i.get(o);t?(t===c?c=c.nextSibling:e.insertBefore(t,c),i.delete(o),y(t,a,n,r)):l(a)}else if(c&&null==s(c)){const e=c.nextSibling;y(c,a,n,r),c=e}else l(a);a=t}for(;c;){const t=c.nextSibling;f(c,r)||(n?.dispose?.(c),e.removeChild(c),r.afterNodeRemoved?.(c)),c=t}},S=(e,t,n={})=>{let r;if("string"==typeof t){const n=document.createElement("template");n.innerHTML=t.trim();const o=n.content;r=1===o.childElementCount?o.firstElementChild:(()=>{const t=e.cloneNode(!1);return t.appendChild(o),t})()}else r=t;if(r){const t=()=>{const t=E();y(e,r,h(e),n),t()};n.transition&&document.startViewTransition?document.startViewTransition(t):t()}return e},E=()=>{const e=document.activeElement;if(!e||e===document.body)return()=>{};const t=e;let n=null,r=null;try{n=t.selectionStart,r=t.selectionEnd}catch{}return()=>{if(e!==document.activeElement&&e.isConnected&&(e.focus(),null!==n))try{t.setSelectionRange(n,r)}catch{}}},A={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},T=Object.freeze({...A}),O={mobile:"base",tablet:"md",desktop:"lg"},L=/^\d+$/,$=(0,t.reactive)({bp:"base",tick:0}),j={...A},_=["base"],N=!1,q=[],P=new Map,C=()=>"undefined"!=typeof window&&"function"==typeof window.matchMedia,D=(e,t)=>e.addEventListener?(e.addEventListener("change",t),{mql:e,off:()=>e.removeEventListener("change",t)}):(e.addListener(t),{mql:e,off:()=>e.removeListener(t)}),M=()=>{for(let e=q.length-1;e>=0;e--)if(q[e].mql.matches)return _[e+1];return"base"},R=()=>{q.forEach(e=>e.off()),q=[];const e=Object.keys(j).filter(e=>j[e]>0).sort((e,t)=>j[e]-j[t]);_=["base",...e],C()&&(q=e.map(e=>{const t=window.matchMedia(`(min-width: ${j[e]}px)`);return D(t,()=>{$.bp=M()})}),$.bp=M())},z=()=>{N||(N=!0,R()),$.tick},I=e=>{if(!C())return!1;let t=P.get(e);if(!t){const n=window.matchMedia(e);t=D(n,()=>$.tick++),P.set(e,t)}return t.mql.matches},B=e=>{if("number"==typeof e)return e;if("base"===e)return 0;if(L.test(e))return Number(e);const t=O[e];return void 0!==t?"base"===t?0:j[t]:j[e]},H=e=>{if(e<=0)return!0;const t=_.findIndex(t=>"base"!==t&&j[t]===e);return-1!==t?_.indexOf($.bp)>=t:($.tick,I(`(min-width: ${e}px)`))},V=new Set,J=(e,t)=>{if(z(),!e||"object"!=typeof e)return t;let n,r=-1;for(const o of Object.keys(e)){const t=B(o);void 0!==t?t>=r&&H(t)&&(r=t,n=e[o]):(_.join(", "),Object.keys(O).join(", "))}return void 0!==n?n:t},K=e=>{const t=O[e],n=j[t];return void 0!==n?n:A[t]},Z=Object.defineProperties((e,t)=>J(e,t),{props:{value:e=>{z();const t={};for(const n of Object.keys(e))t[n]=J(e[n]);return t}},breakpoint:{get:()=>(z(),$.bp),enumerable:!0},device:{get:()=>(z(),H(K("tablet"))?H(K("desktop"))?"desktop":"tablet":"mobile"),enumerable:!0},atLeast:{value:e=>{z();const t=B(e);return void 0!==t&&H(t)}},match:{value:e=>(z(),I(e))},configure:{value:({breakpoints:e})=>{e&&(j={...e},N&&(R(),$.tick++))}}}),F=()=>{q.forEach(e=>e.off()),P.forEach(e=>e.off()),q=[],P.clear(),N=!1};e.collapse=e=>{e.directive("collapse",({el:e,get:t,effect:n,modifiers:r})=>{const o=e;let i=250;for(const u in r||{}){const e=/^duration-(\d+)$/.exec(u);e&&(i=+e[1])}const s=["overflow","height","transition"],c=s.map(e=>o.style[e]);o.style.overflow="hidden";let a=!0,l=0;const f=new Set,d=(e,t)=>{const n=setTimeout(()=>{f.delete(n),e()},t);f.add(n)};return n(()=>{const e=!!t(),n=++l;if(a)return a=!1,e||(o.style.height="0px"),void d(()=>{o.style.transition=`height ${i}ms ease`});e?(o.style.height=o.scrollHeight+"px",d(()=>{n===l&&(o.style.height="")},i)):(o.style.height=o.scrollHeight+"px",o.offsetHeight,o.style.height="0px")}),()=>{f.forEach(clearTimeout),s.forEach((e,t)=>o.style[e]=c[t])}})},e.defaultBreakpoints=T,e.focus=e=>{e.directive("focus",({el:e,get:t,effect:n,modifiers:r})=>{let o=!0;return n(()=>{const n=!!t();Promise.resolve().then(()=>{o&&n&&(e.focus(),r?.select&&e.select&&e.select())})}),()=>{o=!1}}),e.directive("trap",({el:e,get:t,effect:n})=>{let r=!1,o=null;const i=()=>[...e.querySelectorAll('a[href], button, input, textarea, select, details, [tabindex]:not([tabindex="-1"])')].filter(e=>!e.hasAttribute("disabled")),s=t=>{if("Tab"!==t.key)return;const n=i();if(!n.length)return void t.preventDefault();const r=n[0],o=n[n.length-1],s=document.activeElement;e.contains(s)?t.shiftKey&&s===r?(t.preventDefault(),o.focus()):t.shiftKey||s!==o||(t.preventDefault(),r.focus()):(t.preventDefault(),r.focus())},c=()=>{r=!1,document.removeEventListener("keydown",s,!0),o&&o.focus&&o.focus()};return n(()=>{const n=!!t();n&&!r?(r=!0,o=document.activeElement,document.addEventListener("keydown",s,!0),Promise.resolve().then(()=>{r&&(i()[0]||e).focus()})):!n&&r&&c()}),()=>{r&&c()}})},e.intersect=e=>{e.directive("intersect",({el:e,get:t,modifiers:n})=>{const r=new IntersectionObserver(e=>{for(const o of e)(n?.leave?!o.isIntersecting:o.isIntersecting)&&(t(),n?.once&&r.disconnect())},{threshold:n?.full?1:0});return r.observe(e),()=>r.disconnect()})},e.mask=e=>{e.directive("mask",({el:e,exp:t})=>{const r=e,o=()=>{const e=((e,t)=>{let r="",o="",i=0;for(let s=0;s<t.length;s++){const c=n[t[s]];if(c){for(;i<e.length&&!c.test(e[i]);)i++;if(i>=e.length)break;r+=o+e[i++],o=""}else o+=t[s],e[i]===t[s]&&i++}return r})(r.value,t);e!==r.value&&(r.value=e)};return e.addEventListener("input",o),o(),()=>e.removeEventListener("input",o)})},e.media=(e,t)=>(t?.breakpoints&&JSON.stringify(t.breakpoints),t&&Z.configure(t),e.scope.$mq=Z,e.scope.$mqProps=Z.props,e.scope.$mqAtLeast=Z.atLeast,e.scope.$mqMatch=Z.match,Object.defineProperty(e.scope,"$mqBreakpoint",{get:()=>Z.breakpoint,enumerable:!0,configurable:!0}),Object.defineProperty(e.scope,"$mqDevice",{get:()=>Z.device,enumerable:!0,configurable:!0}),F),e.morph=S,e.morphPlugin=e=>{e.scope.$morph=S},e.mq=Z,e.persist=e=>{e.directive("persist",({ctx:e,el:t,exp:n,arg:r,modifiers:o,effect:s})=>{const c=i+(n||t.id);let f;for(const i in o||{})if(a(i)){f=i;break}const d=r?r.split(",").map(e=>e.trim()).filter(Boolean):void 0;l(e.scope,c,d,a(f),s)})},e.persistStore=(e,n={})=>{const r=(0,t.store)(e);if(!r)return()=>{};const o=a(n.storage);return l(r,i+(n.key??e),n.keys,o,t.watchEffect)},e.registerStorage=(e,t)=>{s[e]=t},e.resetMedia=()=>{F(),j={...A},_=["base",...Object.keys(j).sort((e,t)=>j[e]-j[t])],N=!1,V.clear(),$.bp="base",$.tick=0},e.resize=e=>{e.directive("resize",({el:e,get:t,exp:n})=>{const r=t(`(($width, $height) => { ${n} })`),o=new ResizeObserver(e=>{for(const t of e){const e=t.contentRect;r(e.width,e.height)}});return o.observe(e),()=>o.disconnect()})},e.setDefaultStorage=e=>{c=e},e.transition=e=>{e.directive("transition",({el:e,get:t,effect:n,arg:r,modifiers:i,exp:s})=>{const c=e,a=r||"v",l=e=>`${a}-${e}`;let f,d=0,u=!0;const p=()=>{c.classList.remove(l("enter-from"),l("enter-active"),l("enter-to"),l("leave-from"),l("leave-active"),l("leave-to"))},m=(e,t)=>{const n=++d;p(),c.classList.add(l(e+"-from"),l(e+"-active")),c.offsetWidth,c.classList.remove(l(e+"-from")),c.classList.add(l(e+"-to")),clearTimeout(f),f=setTimeout(()=>{n===d&&(p(),t&&t())},(e=>{const t=getComputedStyle(e);return Math.max(o(t.transitionDuration,t.transitionDelay),o(t.animationDuration,t.animationDelay))})(c))};if(!s){let e=!0;return Promise.resolve().then(()=>{e&&m("enter")}),c.__leave=()=>new Promise(e=>m("leave",e)),()=>{e=!1,clearTimeout(f),delete c.__leave}}return n(()=>{const e=!!t();if(u)return u=!1,c.style.display=e?"":"none",void(e&&i?.appear&&m("enter"));e?(c.style.display="",m("enter")):m("leave",()=>{c.style.display="none"})}),()=>clearTimeout(f)})}});
|
package/dist/litevue.dev.iife.js
CHANGED
|
@@ -617,41 +617,6 @@ getter: `, this.getter);
|
|
|
617
617
|
return !!(r && r.__v_isRef === true);
|
|
618
618
|
}
|
|
619
619
|
//#endregion
|
|
620
|
-
//#region src/magics.ts
|
|
621
|
-
var uid = 0;
|
|
622
|
-
/**
|
|
623
|
-
* $id('name') — unique ids for accessibility attributes. Stable within a scope
|
|
624
|
-
* so label/input pairs match, unique across scopes.
|
|
625
|
-
*/
|
|
626
|
-
var createId = () => {
|
|
627
|
-
const memo = Object.create(null);
|
|
628
|
-
return (name = "id") => memo[name] || (memo[name] = `${name}-${++uid}`);
|
|
629
|
-
};
|
|
630
|
-
/**
|
|
631
|
-
* $watch(source, callback) — watches a dot-path string or getter and calls
|
|
632
|
-
* back with (value, oldValue). Tied to the owning scope's effects, so it stops
|
|
633
|
-
* when the scope unmounts.
|
|
634
|
-
*/
|
|
635
|
-
var createWatch = (ctx) => (source, cb) => {
|
|
636
|
-
const getter = typeof source === "function" ? source : () => source.split(".").reduce((o, k) => o == null ? o : o[k], ctx.scope);
|
|
637
|
-
let oldValue;
|
|
638
|
-
let init = false;
|
|
639
|
-
ctx.effect(() => {
|
|
640
|
-
const value = getter();
|
|
641
|
-
const previous = oldValue;
|
|
642
|
-
oldValue = value;
|
|
643
|
-
if (init && value !== previous) {
|
|
644
|
-
pauseTracking();
|
|
645
|
-
try {
|
|
646
|
-
cb(value, previous);
|
|
647
|
-
} finally {
|
|
648
|
-
resetTracking();
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
init = true;
|
|
652
|
-
});
|
|
653
|
-
};
|
|
654
|
-
//#endregion
|
|
655
620
|
//#region src/devtools.ts
|
|
656
621
|
var scopes = /* @__PURE__ */ new Map();
|
|
657
622
|
var exps = /* @__PURE__ */ new Map();
|
|
@@ -880,6 +845,42 @@ getter: `, this.getter);
|
|
|
880
845
|
emitFlush();
|
|
881
846
|
};
|
|
882
847
|
//#endregion
|
|
848
|
+
//#region src/magics.ts
|
|
849
|
+
var uid = 0;
|
|
850
|
+
/**
|
|
851
|
+
* $id('name') — unique ids for accessibility attributes. Stable within a scope
|
|
852
|
+
* so label/input pairs match, unique across scopes.
|
|
853
|
+
*/
|
|
854
|
+
var createId = () => {
|
|
855
|
+
const memo = Object.create(null);
|
|
856
|
+
return (name = "id") => memo[name] || (memo[name] = `${name}-${++uid}`);
|
|
857
|
+
};
|
|
858
|
+
/**
|
|
859
|
+
* $watch(source, callback, { immediate }) — watches a dot-path string or getter
|
|
860
|
+
* and calls back with (value, oldValue). Returns a stop function; it also stops
|
|
861
|
+
* when the owning scope unmounts.
|
|
862
|
+
*/
|
|
863
|
+
var createWatch = (ctx) => (source, cb, options) => {
|
|
864
|
+
const getter = typeof source === "function" ? source : () => source.split(".").reduce((o, k) => o == null ? o : o[k], ctx.scope);
|
|
865
|
+
let oldValue;
|
|
866
|
+
let init = false;
|
|
867
|
+
const runner = ctx.effect(() => {
|
|
868
|
+
const value = getter();
|
|
869
|
+
const previous = oldValue;
|
|
870
|
+
oldValue = value;
|
|
871
|
+
if (init ? value !== previous : options?.immediate) {
|
|
872
|
+
pauseTracking();
|
|
873
|
+
try {
|
|
874
|
+
cb(value, previous);
|
|
875
|
+
} finally {
|
|
876
|
+
resetTracking();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
init = true;
|
|
880
|
+
});
|
|
881
|
+
return () => runner.effect && stopEffect(runner);
|
|
882
|
+
};
|
|
883
|
+
//#endregion
|
|
883
884
|
//#region src/directives/bind.ts
|
|
884
885
|
var forceAttrRE = /^(spellcheck|draggable|form|list|type)$/;
|
|
885
886
|
var bind = ({ el, get, effect, arg, modifiers }) => {
|
|
@@ -1245,13 +1246,13 @@ getter: `, this.getter);
|
|
|
1245
1246
|
}
|
|
1246
1247
|
};
|
|
1247
1248
|
var trigger = (el, type) => {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1249
|
+
el.dispatchEvent(new Event(type, {
|
|
1250
|
+
bubbles: true,
|
|
1251
|
+
cancelable: true
|
|
1252
|
+
}));
|
|
1251
1253
|
};
|
|
1252
|
-
//#endregion
|
|
1253
|
-
//#region src/eval.ts
|
|
1254
1254
|
var evalCache = Object.create(null);
|
|
1255
|
+
var cached = 0;
|
|
1255
1256
|
var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(event, {
|
|
1256
1257
|
detail,
|
|
1257
1258
|
bubbles: true
|
|
@@ -1259,7 +1260,14 @@ getter: `, this.getter);
|
|
|
1259
1260
|
var unwrap = (exp) => exp.replace(/^return\(([^]*)\)$/, "$1");
|
|
1260
1261
|
var evaluate = (scope, exp, el, meta) => execute(scope, `return(${exp})`, el, meta);
|
|
1261
1262
|
var execute = (scope, exp, el, meta) => {
|
|
1262
|
-
|
|
1263
|
+
let fn = evalCache[exp];
|
|
1264
|
+
if (!fn) {
|
|
1265
|
+
if (++cached > 1e3) {
|
|
1266
|
+
evalCache = Object.create(null);
|
|
1267
|
+
cached = 1;
|
|
1268
|
+
}
|
|
1269
|
+
fn = evalCache[exp] = toFunction(exp, el, meta);
|
|
1270
|
+
}
|
|
1263
1271
|
try {
|
|
1264
1272
|
return fn(scope, el, el && mkDispatch(el));
|
|
1265
1273
|
} catch (e) {
|
|
@@ -1366,7 +1374,7 @@ getter: `, this.getter);
|
|
|
1366
1374
|
const anchor = new Comment("v-if");
|
|
1367
1375
|
el.before(anchor);
|
|
1368
1376
|
const branches = [{
|
|
1369
|
-
exp,
|
|
1377
|
+
exp: exp.trim() || "0",
|
|
1370
1378
|
el
|
|
1371
1379
|
}];
|
|
1372
1380
|
let elseEl;
|
|
@@ -1461,20 +1469,20 @@ getter: `, this.getter);
|
|
|
1461
1469
|
}
|
|
1462
1470
|
let mounted = false;
|
|
1463
1471
|
let blocks;
|
|
1464
|
-
let
|
|
1472
|
+
let rows;
|
|
1465
1473
|
let keyToIndexMap;
|
|
1466
|
-
const
|
|
1474
|
+
const createRows = (source) => {
|
|
1467
1475
|
const map = /* @__PURE__ */ new Map();
|
|
1468
|
-
const
|
|
1469
|
-
if (isArray(source)) for (let i = 0; i < source.length; i++)
|
|
1470
|
-
else if (typeof source === "number") for (let i = 0; i < source; i++)
|
|
1476
|
+
const rows = [];
|
|
1477
|
+
if (isArray(source)) for (let i = 0; i < source.length; i++) rows.push(createRow(map, source[i], i));
|
|
1478
|
+
else if (typeof source === "number") for (let i = 0; i < source; i++) rows.push(createRow(map, i + 1, i));
|
|
1471
1479
|
else if (isObject(source)) {
|
|
1472
1480
|
let i = 0;
|
|
1473
|
-
for (const key in source)
|
|
1481
|
+
for (const key in source) rows.push(createRow(map, source[key], i++, key));
|
|
1474
1482
|
}
|
|
1475
|
-
return [
|
|
1483
|
+
return [rows, map];
|
|
1476
1484
|
};
|
|
1477
|
-
const
|
|
1485
|
+
const createRow = (map, value, index, objKey) => {
|
|
1478
1486
|
const data = {};
|
|
1479
1487
|
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value[isArrayDestructure ? i : b]);
|
|
1480
1488
|
else data[valueExp] = value;
|
|
@@ -1482,18 +1490,19 @@ getter: `, this.getter);
|
|
|
1482
1490
|
indexExp && (data[indexExp] = objKey);
|
|
1483
1491
|
objIndexExp && (data[objIndexExp] = index);
|
|
1484
1492
|
} else indexExp && (data[indexExp] = index);
|
|
1485
|
-
const
|
|
1486
|
-
const key = keyExp ? evaluate(childCtx.scope, keyExp, el, {
|
|
1493
|
+
const key = keyExp ? evaluate(Object.setPrototypeOf(data, ctx.scope), keyExp, el, {
|
|
1487
1494
|
source: ":key",
|
|
1488
1495
|
el
|
|
1489
1496
|
}) : index;
|
|
1490
1497
|
map.set(key, index);
|
|
1491
|
-
|
|
1492
|
-
|
|
1498
|
+
return {
|
|
1499
|
+
data,
|
|
1500
|
+
key
|
|
1501
|
+
};
|
|
1493
1502
|
};
|
|
1494
|
-
const mountBlock = (
|
|
1495
|
-
const block = new Block(el, ctx);
|
|
1496
|
-
block.key =
|
|
1503
|
+
const mountBlock = (row, ref) => {
|
|
1504
|
+
const block = new Block(el, createScopedContext(ctx, row.data));
|
|
1505
|
+
block.key = row.key;
|
|
1497
1506
|
block.insert(parent(), ref);
|
|
1498
1507
|
return block;
|
|
1499
1508
|
};
|
|
@@ -1504,14 +1513,14 @@ getter: `, this.getter);
|
|
|
1504
1513
|
el
|
|
1505
1514
|
});
|
|
1506
1515
|
const prevKeyToIndexMap = keyToIndexMap;
|
|
1507
|
-
[
|
|
1508
|
-
if (keyToIndexMap.size !==
|
|
1516
|
+
[rows, keyToIndexMap] = createRows(source);
|
|
1517
|
+
if (keyToIndexMap.size !== rows.length) {
|
|
1509
1518
|
const counts = /* @__PURE__ */ new Map();
|
|
1510
1519
|
let dup;
|
|
1511
|
-
for (const
|
|
1512
|
-
const n = (counts.get(
|
|
1513
|
-
counts.set(
|
|
1514
|
-
if (n > 1 && dup === void 0) dup =
|
|
1520
|
+
for (const row of rows) {
|
|
1521
|
+
const n = (counts.get(row.key) || 0) + 1;
|
|
1522
|
+
counts.set(row.key, n);
|
|
1523
|
+
if (n > 1 && dup === void 0) dup = row.key;
|
|
1515
1524
|
}
|
|
1516
1525
|
warnOnce(`for-dup-key:${exp}`, `v-for="${exp}" produced a duplicate :key ${JSON.stringify(dup)}. Keys must be unique among siblings — with a repeat, one item's element and its scope state are silently dropped. Key by something stable and unique, such as a record id.`);
|
|
1517
1526
|
}
|
|
@@ -1526,22 +1535,22 @@ getter: `, this.getter);
|
|
|
1526
1535
|
prevItems = items;
|
|
1527
1536
|
}
|
|
1528
1537
|
if (!mounted) {
|
|
1529
|
-
blocks =
|
|
1538
|
+
blocks = rows.map((row) => mountBlock(row, anchor));
|
|
1530
1539
|
mounted = true;
|
|
1531
1540
|
} else {
|
|
1532
1541
|
for (let i = 0; i < blocks.length; i++) if (!keyToIndexMap.has(blocks[i].key)) blocks[i].remove();
|
|
1533
1542
|
const nextBlocks = [];
|
|
1534
|
-
let i =
|
|
1543
|
+
let i = rows.length;
|
|
1535
1544
|
let nextBlock;
|
|
1536
1545
|
let prevMovedBlock;
|
|
1537
1546
|
while (i--) {
|
|
1538
|
-
const
|
|
1539
|
-
const oldIndex = prevKeyToIndexMap.get(
|
|
1547
|
+
const row = rows[i];
|
|
1548
|
+
const oldIndex = prevKeyToIndexMap.get(row.key);
|
|
1540
1549
|
let block;
|
|
1541
|
-
if (oldIndex == null) block = mountBlock(
|
|
1550
|
+
if (oldIndex == null) block = mountBlock(row, nextBlock ? nextBlock.el : anchor);
|
|
1542
1551
|
else {
|
|
1543
1552
|
block = blocks[oldIndex];
|
|
1544
|
-
Object.assign(block.ctx.scope,
|
|
1553
|
+
Object.assign(block.ctx.scope, row.data);
|
|
1545
1554
|
if (oldIndex !== i) {
|
|
1546
1555
|
if (blocks[oldIndex + 1] !== nextBlock || prevMovedBlock === nextBlock) {
|
|
1547
1556
|
prevMovedBlock = block;
|
|
@@ -1564,7 +1573,7 @@ getter: `, this.getter);
|
|
|
1564
1573
|
const ref = get();
|
|
1565
1574
|
{
|
|
1566
1575
|
const existing = $refs[ref];
|
|
1567
|
-
if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name
|
|
1576
|
+
if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
|
|
1568
1577
|
}
|
|
1569
1578
|
$refs[ref] = el;
|
|
1570
1579
|
if (prevRef && ref !== prevRef) delete $refs[prevRef];
|
|
@@ -1690,7 +1699,7 @@ getter: `, this.getter);
|
|
|
1690
1699
|
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1691
1700
|
checkAttr(el, "v-cloak");
|
|
1692
1701
|
let exp;
|
|
1693
|
-
if (exp = checkAttr(el, "v-if")) return _if(el, exp, ctx);
|
|
1702
|
+
if ((exp = checkAttr(el, "v-if")) != null) return _if(el, exp, ctx);
|
|
1694
1703
|
if (exp = checkAttr(el, "v-for")) return _for(el, exp, ctx);
|
|
1695
1704
|
const name = checkAttr(el, "v-name");
|
|
1696
1705
|
let teleportNext;
|
|
@@ -1961,8 +1970,15 @@ getter: `, this.getter);
|
|
|
1961
1970
|
}
|
|
1962
1971
|
this.teardown();
|
|
1963
1972
|
};
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1973
|
+
const leaves = [];
|
|
1974
|
+
let node = this.start || this.template;
|
|
1975
|
+
while (node) {
|
|
1976
|
+
const leave = node.__leave;
|
|
1977
|
+
if (leave) leaves.push(leave());
|
|
1978
|
+
if (!this.start || node === this.end) break;
|
|
1979
|
+
node = node.nextSibling;
|
|
1980
|
+
}
|
|
1981
|
+
if (leaves.length) Promise.all(leaves).then(removeNow);
|
|
1966
1982
|
else removeNow();
|
|
1967
1983
|
}
|
|
1968
1984
|
/**
|
package/dist/litevue.dev.mjs
CHANGED
|
@@ -615,41 +615,6 @@ function isRef(r) {
|
|
|
615
615
|
return !!(r && r.__v_isRef === true);
|
|
616
616
|
}
|
|
617
617
|
//#endregion
|
|
618
|
-
//#region src/magics.ts
|
|
619
|
-
var uid = 0;
|
|
620
|
-
/**
|
|
621
|
-
* $id('name') — unique ids for accessibility attributes. Stable within a scope
|
|
622
|
-
* so label/input pairs match, unique across scopes.
|
|
623
|
-
*/
|
|
624
|
-
var createId = () => {
|
|
625
|
-
const memo = Object.create(null);
|
|
626
|
-
return (name = "id") => memo[name] || (memo[name] = `${name}-${++uid}`);
|
|
627
|
-
};
|
|
628
|
-
/**
|
|
629
|
-
* $watch(source, callback) — watches a dot-path string or getter and calls
|
|
630
|
-
* back with (value, oldValue). Tied to the owning scope's effects, so it stops
|
|
631
|
-
* when the scope unmounts.
|
|
632
|
-
*/
|
|
633
|
-
var createWatch = (ctx) => (source, cb) => {
|
|
634
|
-
const getter = typeof source === "function" ? source : () => source.split(".").reduce((o, k) => o == null ? o : o[k], ctx.scope);
|
|
635
|
-
let oldValue;
|
|
636
|
-
let init = false;
|
|
637
|
-
ctx.effect(() => {
|
|
638
|
-
const value = getter();
|
|
639
|
-
const previous = oldValue;
|
|
640
|
-
oldValue = value;
|
|
641
|
-
if (init && value !== previous) {
|
|
642
|
-
pauseTracking();
|
|
643
|
-
try {
|
|
644
|
-
cb(value, previous);
|
|
645
|
-
} finally {
|
|
646
|
-
resetTracking();
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
init = true;
|
|
650
|
-
});
|
|
651
|
-
};
|
|
652
|
-
//#endregion
|
|
653
618
|
//#region src/devtools.ts
|
|
654
619
|
var scopes = /* @__PURE__ */ new Map();
|
|
655
620
|
var exps = /* @__PURE__ */ new Map();
|
|
@@ -878,6 +843,42 @@ var flushJobs = () => {
|
|
|
878
843
|
emitFlush();
|
|
879
844
|
};
|
|
880
845
|
//#endregion
|
|
846
|
+
//#region src/magics.ts
|
|
847
|
+
var uid = 0;
|
|
848
|
+
/**
|
|
849
|
+
* $id('name') — unique ids for accessibility attributes. Stable within a scope
|
|
850
|
+
* so label/input pairs match, unique across scopes.
|
|
851
|
+
*/
|
|
852
|
+
var createId = () => {
|
|
853
|
+
const memo = Object.create(null);
|
|
854
|
+
return (name = "id") => memo[name] || (memo[name] = `${name}-${++uid}`);
|
|
855
|
+
};
|
|
856
|
+
/**
|
|
857
|
+
* $watch(source, callback, { immediate }) — watches a dot-path string or getter
|
|
858
|
+
* and calls back with (value, oldValue). Returns a stop function; it also stops
|
|
859
|
+
* when the owning scope unmounts.
|
|
860
|
+
*/
|
|
861
|
+
var createWatch = (ctx) => (source, cb, options) => {
|
|
862
|
+
const getter = typeof source === "function" ? source : () => source.split(".").reduce((o, k) => o == null ? o : o[k], ctx.scope);
|
|
863
|
+
let oldValue;
|
|
864
|
+
let init = false;
|
|
865
|
+
const runner = ctx.effect(() => {
|
|
866
|
+
const value = getter();
|
|
867
|
+
const previous = oldValue;
|
|
868
|
+
oldValue = value;
|
|
869
|
+
if (init ? value !== previous : options?.immediate) {
|
|
870
|
+
pauseTracking();
|
|
871
|
+
try {
|
|
872
|
+
cb(value, previous);
|
|
873
|
+
} finally {
|
|
874
|
+
resetTracking();
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
init = true;
|
|
878
|
+
});
|
|
879
|
+
return () => runner.effect && stopEffect(runner);
|
|
880
|
+
};
|
|
881
|
+
//#endregion
|
|
881
882
|
//#region src/directives/bind.ts
|
|
882
883
|
var forceAttrRE = /^(spellcheck|draggable|form|list|type)$/;
|
|
883
884
|
var bind = ({ el, get, effect, arg, modifiers }) => {
|
|
@@ -1243,13 +1244,13 @@ var onCompositionEnd = (e) => {
|
|
|
1243
1244
|
}
|
|
1244
1245
|
};
|
|
1245
1246
|
var trigger = (el, type) => {
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1247
|
+
el.dispatchEvent(new Event(type, {
|
|
1248
|
+
bubbles: true,
|
|
1249
|
+
cancelable: true
|
|
1250
|
+
}));
|
|
1249
1251
|
};
|
|
1250
|
-
//#endregion
|
|
1251
|
-
//#region src/eval.ts
|
|
1252
1252
|
var evalCache = Object.create(null);
|
|
1253
|
+
var cached = 0;
|
|
1253
1254
|
var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(event, {
|
|
1254
1255
|
detail,
|
|
1255
1256
|
bubbles: true
|
|
@@ -1257,7 +1258,14 @@ var mkDispatch = (el) => (event, detail) => el.dispatchEvent(new CustomEvent(eve
|
|
|
1257
1258
|
var unwrap = (exp) => exp.replace(/^return\(([^]*)\)$/, "$1");
|
|
1258
1259
|
var evaluate = (scope, exp, el, meta) => execute(scope, `return(${exp})`, el, meta);
|
|
1259
1260
|
var execute = (scope, exp, el, meta) => {
|
|
1260
|
-
|
|
1261
|
+
let fn = evalCache[exp];
|
|
1262
|
+
if (!fn) {
|
|
1263
|
+
if (++cached > 1e3) {
|
|
1264
|
+
evalCache = Object.create(null);
|
|
1265
|
+
cached = 1;
|
|
1266
|
+
}
|
|
1267
|
+
fn = evalCache[exp] = toFunction(exp, el, meta);
|
|
1268
|
+
}
|
|
1261
1269
|
try {
|
|
1262
1270
|
return fn(scope, el, el && mkDispatch(el));
|
|
1263
1271
|
} catch (e) {
|
|
@@ -1364,7 +1372,7 @@ var _if = (el, exp, ctx) => {
|
|
|
1364
1372
|
const anchor = new Comment("v-if");
|
|
1365
1373
|
el.before(anchor);
|
|
1366
1374
|
const branches = [{
|
|
1367
|
-
exp,
|
|
1375
|
+
exp: exp.trim() || "0",
|
|
1368
1376
|
el
|
|
1369
1377
|
}];
|
|
1370
1378
|
let elseEl;
|
|
@@ -1459,20 +1467,20 @@ var _for = (el, exp, ctx) => {
|
|
|
1459
1467
|
}
|
|
1460
1468
|
let mounted = false;
|
|
1461
1469
|
let blocks;
|
|
1462
|
-
let
|
|
1470
|
+
let rows;
|
|
1463
1471
|
let keyToIndexMap;
|
|
1464
|
-
const
|
|
1472
|
+
const createRows = (source) => {
|
|
1465
1473
|
const map = /* @__PURE__ */ new Map();
|
|
1466
|
-
const
|
|
1467
|
-
if (isArray(source)) for (let i = 0; i < source.length; i++)
|
|
1468
|
-
else if (typeof source === "number") for (let i = 0; i < source; i++)
|
|
1474
|
+
const rows = [];
|
|
1475
|
+
if (isArray(source)) for (let i = 0; i < source.length; i++) rows.push(createRow(map, source[i], i));
|
|
1476
|
+
else if (typeof source === "number") for (let i = 0; i < source; i++) rows.push(createRow(map, i + 1, i));
|
|
1469
1477
|
else if (isObject(source)) {
|
|
1470
1478
|
let i = 0;
|
|
1471
|
-
for (const key in source)
|
|
1479
|
+
for (const key in source) rows.push(createRow(map, source[key], i++, key));
|
|
1472
1480
|
}
|
|
1473
|
-
return [
|
|
1481
|
+
return [rows, map];
|
|
1474
1482
|
};
|
|
1475
|
-
const
|
|
1483
|
+
const createRow = (map, value, index, objKey) => {
|
|
1476
1484
|
const data = {};
|
|
1477
1485
|
if (destructureBindings) destructureBindings.forEach((b, i) => data[b] = value[isArrayDestructure ? i : b]);
|
|
1478
1486
|
else data[valueExp] = value;
|
|
@@ -1480,18 +1488,19 @@ var _for = (el, exp, ctx) => {
|
|
|
1480
1488
|
indexExp && (data[indexExp] = objKey);
|
|
1481
1489
|
objIndexExp && (data[objIndexExp] = index);
|
|
1482
1490
|
} else indexExp && (data[indexExp] = index);
|
|
1483
|
-
const
|
|
1484
|
-
const key = keyExp ? evaluate(childCtx.scope, keyExp, el, {
|
|
1491
|
+
const key = keyExp ? evaluate(Object.setPrototypeOf(data, ctx.scope), keyExp, el, {
|
|
1485
1492
|
source: ":key",
|
|
1486
1493
|
el
|
|
1487
1494
|
}) : index;
|
|
1488
1495
|
map.set(key, index);
|
|
1489
|
-
|
|
1490
|
-
|
|
1496
|
+
return {
|
|
1497
|
+
data,
|
|
1498
|
+
key
|
|
1499
|
+
};
|
|
1491
1500
|
};
|
|
1492
|
-
const mountBlock = (
|
|
1493
|
-
const block = new Block(el, ctx);
|
|
1494
|
-
block.key =
|
|
1501
|
+
const mountBlock = (row, ref) => {
|
|
1502
|
+
const block = new Block(el, createScopedContext(ctx, row.data));
|
|
1503
|
+
block.key = row.key;
|
|
1495
1504
|
block.insert(parent(), ref);
|
|
1496
1505
|
return block;
|
|
1497
1506
|
};
|
|
@@ -1502,14 +1511,14 @@ var _for = (el, exp, ctx) => {
|
|
|
1502
1511
|
el
|
|
1503
1512
|
});
|
|
1504
1513
|
const prevKeyToIndexMap = keyToIndexMap;
|
|
1505
|
-
[
|
|
1506
|
-
if (keyToIndexMap.size !==
|
|
1514
|
+
[rows, keyToIndexMap] = createRows(source);
|
|
1515
|
+
if (keyToIndexMap.size !== rows.length) {
|
|
1507
1516
|
const counts = /* @__PURE__ */ new Map();
|
|
1508
1517
|
let dup;
|
|
1509
|
-
for (const
|
|
1510
|
-
const n = (counts.get(
|
|
1511
|
-
counts.set(
|
|
1512
|
-
if (n > 1 && dup === void 0) dup =
|
|
1518
|
+
for (const row of rows) {
|
|
1519
|
+
const n = (counts.get(row.key) || 0) + 1;
|
|
1520
|
+
counts.set(row.key, n);
|
|
1521
|
+
if (n > 1 && dup === void 0) dup = row.key;
|
|
1513
1522
|
}
|
|
1514
1523
|
warnOnce(`for-dup-key:${exp}`, `v-for="${exp}" produced a duplicate :key ${JSON.stringify(dup)}. Keys must be unique among siblings — with a repeat, one item's element and its scope state are silently dropped. Key by something stable and unique, such as a record id.`);
|
|
1515
1524
|
}
|
|
@@ -1524,22 +1533,22 @@ var _for = (el, exp, ctx) => {
|
|
|
1524
1533
|
prevItems = items;
|
|
1525
1534
|
}
|
|
1526
1535
|
if (!mounted) {
|
|
1527
|
-
blocks =
|
|
1536
|
+
blocks = rows.map((row) => mountBlock(row, anchor));
|
|
1528
1537
|
mounted = true;
|
|
1529
1538
|
} else {
|
|
1530
1539
|
for (let i = 0; i < blocks.length; i++) if (!keyToIndexMap.has(blocks[i].key)) blocks[i].remove();
|
|
1531
1540
|
const nextBlocks = [];
|
|
1532
|
-
let i =
|
|
1541
|
+
let i = rows.length;
|
|
1533
1542
|
let nextBlock;
|
|
1534
1543
|
let prevMovedBlock;
|
|
1535
1544
|
while (i--) {
|
|
1536
|
-
const
|
|
1537
|
-
const oldIndex = prevKeyToIndexMap.get(
|
|
1545
|
+
const row = rows[i];
|
|
1546
|
+
const oldIndex = prevKeyToIndexMap.get(row.key);
|
|
1538
1547
|
let block;
|
|
1539
|
-
if (oldIndex == null) block = mountBlock(
|
|
1548
|
+
if (oldIndex == null) block = mountBlock(row, nextBlock ? nextBlock.el : anchor);
|
|
1540
1549
|
else {
|
|
1541
1550
|
block = blocks[oldIndex];
|
|
1542
|
-
Object.assign(block.ctx.scope,
|
|
1551
|
+
Object.assign(block.ctx.scope, row.data);
|
|
1543
1552
|
if (oldIndex !== i) {
|
|
1544
1553
|
if (blocks[oldIndex + 1] !== nextBlock || prevMovedBlock === nextBlock) {
|
|
1545
1554
|
prevMovedBlock = block;
|
|
@@ -1562,7 +1571,7 @@ var ref = ({ el, ctx: { scope: { $refs } }, get, effect }) => {
|
|
|
1562
1571
|
const ref = get();
|
|
1563
1572
|
{
|
|
1564
1573
|
const existing = $refs[ref];
|
|
1565
|
-
if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name
|
|
1574
|
+
if (existing && existing !== el && existing.isConnected) warnOnce(`ref-dup:${ref}`, `two elements claim ref="${ref}" in the same scope; $refs.${ref} points at the last one mounted and the earlier element is no longer reachable. Give each element its own name.`);
|
|
1566
1575
|
}
|
|
1567
1576
|
$refs[ref] = el;
|
|
1568
1577
|
if (prevRef && ref !== prevRef) delete $refs[prevRef];
|
|
@@ -1688,7 +1697,7 @@ var walkNode = (node, ctx) => {
|
|
|
1688
1697
|
if (deferScope(el, ctx, walkDeferred, inOnce)) return;
|
|
1689
1698
|
checkAttr(el, "v-cloak");
|
|
1690
1699
|
let exp;
|
|
1691
|
-
if (exp = checkAttr(el, "v-if")) return _if(el, exp, ctx);
|
|
1700
|
+
if ((exp = checkAttr(el, "v-if")) != null) return _if(el, exp, ctx);
|
|
1692
1701
|
if (exp = checkAttr(el, "v-for")) return _for(el, exp, ctx);
|
|
1693
1702
|
const name = checkAttr(el, "v-name");
|
|
1694
1703
|
let teleportNext;
|
|
@@ -1959,8 +1968,15 @@ var Block = class {
|
|
|
1959
1968
|
}
|
|
1960
1969
|
this.teardown();
|
|
1961
1970
|
};
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1971
|
+
const leaves = [];
|
|
1972
|
+
let node = this.start || this.template;
|
|
1973
|
+
while (node) {
|
|
1974
|
+
const leave = node.__leave;
|
|
1975
|
+
if (leave) leaves.push(leave());
|
|
1976
|
+
if (!this.start || node === this.end) break;
|
|
1977
|
+
node = node.nextSibling;
|
|
1978
|
+
}
|
|
1979
|
+
if (leaves.length) Promise.all(leaves).then(removeNow);
|
|
1964
1980
|
else removeNow();
|
|
1965
1981
|
}
|
|
1966
1982
|
/**
|