UNPKG

@mt-kit/vue-config

Version:
165 lines (140 loc) 15.4 kB
(function(h,f){typeof exports=="object"&&typeof module<"u"?f(exports):typeof define=="function"&&define.amd?define(["exports"],f):(h=typeof globalThis<"u"?globalThis:h||self,f(h.microVueConfig={}))})(this,function(h){"use strict";var f=Object.defineProperty,L=(e,t,r)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,g=(e,t,r)=>L(e,typeof t!="symbol"?t+"":t,r),w=function(){if(typeof Map<"u")return Map;function e(t,r){var n=-1;return t.some(function(o,i){return o[0]===r?(n=i,!0):!1}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(r){var n=e(this.__entries__,r),o=this.__entries__[n];return o&&o[1]},t.prototype.set=function(r,n){var o=e(this.__entries__,r);~o?this.__entries__[o][1]=n:this.__entries__.push([r,n])},t.prototype.delete=function(r){var n=this.__entries__,o=e(n,r);~o&&n.splice(o,1)},t.prototype.has=function(r){return!!~e(this.__entries__,r)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(r,n){n===void 0&&(n=null);for(var o=0,i=this.__entries__;o<i.length;o++){var s=i[o];r.call(n,s[1],s[0])}},t}()}(),m=typeof window<"u"&&typeof document<"u"&&window.document===document,p=function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()}(),$=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(p):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),C=2;function S(e,t){var r=!1,n=!1,o=0;function i(){r&&(r=!1,e()),n&&c()}function s(){$(i)}function c(){var a=Date.now();if(r){if(a-o<C)return;n=!0}else r=!0,n=!1,setTimeout(s,t);o=a}return c}var R=20,j=["top","right","bottom","left","width","height","size","weight"],D=typeof MutationObserver<"u",H=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=S(this.refresh.bind(this),R)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var r=this.observers_,n=r.indexOf(t);~n&&r.splice(n,1),!r.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(r){return r.gatherActive(),r.hasActive()});return t.forEach(function(r){return r.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!m||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),D?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!m||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var r=t.propertyName,n=r===void 0?"":r,o=j.some(function(i){return!!~n.indexOf(i)});o&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),x=function(e,t){for(var r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];Object.defineProperty(e,o,{value:t[o],enumerable:!1,writable:!1,configurable:!0})}return e},d=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||p},E=v(0,0,0,0);function b(e){return parseFloat(e)||0}function O(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return t.reduce(function(n,o){var i=e["border-"+o+"-width"];return n+b(i)},0)}function q(e){for(var t=["top","right","bottom","left"],r={},n=0,o=t;n<o.length;n++){var i=o[n],s=e["padding-"+i];r[i]=b(s)}return r}function N(e){var t=e.getBBox();return v(0,0,t.width,t.height)}function W(e){var t=e.clientWidth,r=e.clientHeight;if(!t&&!r)return E;var n=d(e).getComputedStyle(e),o=q(n),i=o.left+o.right,s=o.top+o.bottom,c=b(n.width),a=b(n.height);if(n.boxSizing==="border-box"&&(Math.round(c+i)!==t&&(c-=O(n,"left","right")+i),Math.round(a+s)!==r&&(a-=O(n,"top","bottom")+s)),!F(e)){var l=Math.round(c+i)-t,u=Math.round(a+s)-r;Math.abs(l)!==1&&(c-=l),Math.abs(u)!==1&&(a-=u)}return v(o.left,o.top,c,a)}var B=function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof d(e).SVGGraphicsElement}:function(e){return e instanceof d(e).SVGElement&&typeof e.getBBox=="function"}}();function F(e){return e===d(e).document.documentElement}function G(e){return m?B(e)?N(e):W(e):E}function I(e){var t=e.x,r=e.y,n=e.width,o=e.height,i=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,s=Object.create(i.prototype);return x(s,{x:t,y:r,width:n,height:o,top:r,right:t+n,bottom:o+r,left:t}),s}function v(e,t,r,n){return{x:e,y:t,width:r,height:n}}var P=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=v(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=G(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e}(),V=function(){function e(t,r){var n=I(r);x(this,{target:t,contentRect:n})}return e}(),J=function(){function e(t,r,n){if(this.activeObservations_=[],this.observations_=new w,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=r,this.callbackCtx_=n}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(t)||(r.set(t,new P(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof d(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(t)&&(r.delete(t),r.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(r){r.isActive()&&t.activeObservations_.push(r)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,r=this.activeObservations_.map(function(n){return new V(n.target,n.broadcastRect())});this.callback_.call(t,r,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),k=typeof WeakMap<"u"?new WeakMap:new w,M=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=H.getInstance(),n=new J(t,r,this);k.set(this,n)}return e}();["observe","unobserve","disconnect"].forEach(function(e){M.prototype[e]=function(){var t;return(t=k.get(this))[e].apply(t,arguments)}}),function(){return typeof p.ResizeObserver<"u"?p.ResizeObserver:M}();function K(e=!1){return` <style> :host { ${e?` position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 99999;`:""} --monospace: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace; --red: #ff5555; --yellow: #e2aa53; --purple: #cfa4ff; --cyan: #2dd9da; --dim: #c9c9c9; ${e?` --window-background: #181818; --window-color: #d8d8d8;`:""} } .backdrop { ${e?` position: fixed; z-index: 99999; top: 0; left: 0;`:""} width: 100%; height: 100%; overflow-y: scroll; margin: 0; ${e?"background: rgba(0, 0, 0, 0.66);":""} background: rgba(0, 0, 0, 0.66); } .window { font-family: var(--monospace); line-height: 1.5; ${e?"width: 800px;":"width: 100%"} color: var(--window-color); ${e?"margin: 30px auto;":""} padding: 25px 40px; position: relative; background: var(--window-background); border-radius: 6px 6px 8px 8px; overflow: hidden; border-top: 8px solid var(--red); direction: ltr; text-align: left; } pre { font-family: var(--monospace); font-size: 16px; margin-top: 0; margin-bottom: 1em; overflow-x: scroll; scrollbar-width: none; } pre::-webkit-scrollbar { display: none; } pre.frame::-webkit-scrollbar { display: block; height: 5px; } pre.frame::-webkit-scrollbar-thumb { background: #999; border-radius: 5px; } pre.frame { scrollbar-width: thin; } .message { line-height: 1.3; font-weight: 600; white-space: pre-wrap; } .message-body { color: var(--red); } .plugin { color: var(--purple); } .file { color: var(--cyan); margin-bottom: 0; white-space: pre-wrap; word-break: break-all; } .frame { color: var(--yellow); } .stack { font-size: 13px; color: var(--dim); } .tip { font-size: 13px; color: #999; border-top: 1px dotted #999; padding-top: 13px; line-height: 1.8; } code { font-size: 13px; font-family: var(--monospace); color: var(--yellow); } .file-link { text-decoration: underline; cursor: pointer; } a { color: var(--dim); } kbd { line-height: 1.5; font-family: ui-monospace, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; font-size: 0.75rem; font-weight: 700; background-color: rgb(38, 40, 44); color: rgb(166, 167, 171); padding: 0.15rem 0.3rem; border-radius: 0.25rem; border-width: 0.0625rem 0.0625rem 0.1875rem; border-style: solid; border-color: rgb(54, 57, 64); border-image: initial; } </style> <div class="backdrop" part="backdrop"> <div class="window" part="window"> <pre class="message" part="message"><span class="plugin" part="plugin"></span><span class="message-body" part="message-body"></span></pre> <pre class="file" part="file"></pre> <pre class="frame" part="frame"></pre> <pre class="stack" part="stack"></pre> <div class="tip" part="tip"> Click outside, press <kbd>Esc</kbd> key, or fix the code to dismiss. </div> </div> </div> `}const T=/(?:[a-z]:\\|\/).*?:\d+:\d+/gi,_=/^(?:>?\s*\d+\s+\|.*|\s+\|\s*\^.*)\r?\n/gm,{HTMLElement:Q=class{}}=globalThis;let U=class extends Q{constructor(e,t=!1,r=!0){var n,o,i;super(),g(this,"root"),g(this,"closeOnEsc"),g(this,"dialog"),this.root=this.attachShadow({mode:"open"}),this.root.innerHTML=K(t),this.dialog=t,t||this.closeText(),_.lastIndex=0;const s=e.frame&&_.test(e.frame),c=s?e.message.replaceAll(_,""):e.message;e.plugin&&this.text(".plugin",`[plugin:${e.plugin}] `),this.text(".message-body",c.trim());const[a]=(((n=e.loc)==null?void 0:n.file)||e.id||"unknown file").split("?");e.loc?this.text(".file",`${a}:${e.loc.line}:${e.loc.column}`,r):e.id&&this.text(".file",a),s&&this.text(".frame",((o=e.frame)==null?void 0:o.trim())||""),this.text(".stack",e.stack,r),(i=this.root.querySelector(".window"))==null||i.addEventListener("click",l=>{l.stopPropagation()}),this.addEventListener("click",()=>{this.close()}),this.closeOnEsc=l=>{(l.key==="Escape"||l.code==="Escape")&&this.close()},document.addEventListener("keydown",this.closeOnEsc)}text(e,t,r=!1){const n=this.root.querySelector(e);if(r){let o=0,i;for(T.lastIndex=0;i=T.exec(t);){const{0:s,index:c}=i;if(c!=null){const a=t.slice(o,c),l=document.location.protocol+s;n.append(document.createTextNode(a));const u=document.createElement("a");u.textContent=s,u.className="file-link",u.href=l,u.target="_blank",n.append(u),o+=a.length+s.length}}}else n.textContent=t}closeText(){const e=this.root.querySelector(".tip");e.style.display="none"}close(){var e;this.dialog&&((e=this.parentNode)==null||e.removeChild(this),document.removeEventListener("keydown",this.closeOnEsc))}};const A="imitation-vue-error",{customElements:y}=globalThis;y&&!y.get(A)&&y.define(A,U);const X=customElements.get("imitation-vue-error");function z(e,t){return new X(e,t)}function Z(e,t,r){t==null||t.$nextTick(()=>{if((t==null?void 0:t.$el.childNodes.length)>0){(t==null?void 0:t.$el).innerHTML="",(t==null?void 0:t.$el).append(z(e));return}(t==null?void 0:t.$el).textContent=`${r}: ${e}`,document.body.append(z(e,!0))})}h.configErrorHandler=Z,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"})});