x-next 0.0.0-alpha.1 → 0.0.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -21
- package/README.md +93 -2
- package/dist/favicon.ico +0 -0
- package/dist/index.d.ts +0 -0
- package/dist/types/_hooks/use-overflow.d.ts +5 -0
- package/dist/types/_hooks/use-popup-manager.d.ts +11 -0
- package/dist/types/_props/css.d.ts +13 -0
- package/dist/types/_props/global.d.ts +1 -0
- package/dist/types/_utils/config.d.ts +9 -0
- package/dist/types/_utils/convert-case.d.ts +3 -0
- package/dist/types/_utils/dom.d.ts +10 -0
- package/dist/types/_utils/helpers.d.ts +12 -0
- package/dist/types/_utils/icon.d.ts +59 -0
- package/dist/types/_utils/is.d.ts +25 -0
- package/dist/types/_utils/keyboard.d.ts +24 -0
- package/dist/types/_utils/number.d.ts +0 -0
- package/dist/types/_utils/vue-eco.d.ts +32 -0
- package/dist/types/componets/button/index.vue.d.ts +107 -0
- package/dist/types/componets/button/props.d.ts +45 -0
- package/dist/types/componets/dialog/index.vue.d.ts +221 -0
- package/dist/types/componets/dialog/props.d.ts +83 -0
- package/dist/types/componets/dialog/use-props.d.ts +33 -0
- package/dist/types/componets/dialog/use.d.ts +3 -0
- package/dist/types/componets/dialog/warp.d.ts +2 -0
- package/dist/types/componets/message/index.vue.d.ts +116 -0
- package/dist/types/componets/message/props.d.ts +31 -0
- package/dist/types/componets/message/warp.d.ts +3 -0
- package/dist/types/componets/message-box/index.d.ts +3 -0
- package/dist/types/componets/message-box/props.d.ts +52 -0
- package/dist/types/componets/message-box/warp.d.ts +2 -0
- package/dist/types/componets/notification/index.vue.d.ts +160 -0
- package/dist/types/componets/notification/props.d.ts +54 -0
- package/dist/types/componets/notification/warp.d.ts +3 -0
- package/dist/types/componets/space/index.d.ts +42 -0
- package/dist/types/componets/tag-cloud/index.d.ts +0 -0
- package/dist/types/componets/trend-chart/components/trend-chart-curve.d.ts +114 -0
- package/dist/types/componets/trend-chart/components/trend-chart-grid.d.ts +55 -0
- package/dist/types/componets/trend-chart/components/trend-chart-labels.d.ts +22 -0
- package/dist/types/componets/trend-chart/components/trend-chart.d.ts +270 -0
- package/dist/types/componets/trend-chart/helpers/genPath.d.ts +8 -0
- package/dist/types/componets/trend-chart/helpers/genPoints.d.ts +3 -0
- package/dist/types/componets/trend-chart/helpers/getPadding.d.ts +7 -0
- package/dist/types/componets/trend-chart/helpers/validatePadding.d.ts +2 -0
- package/dist/types/componets/trend-chart/index.d.ts +2 -0
- package/dist/types/componets/trend-chart/props.d.ts +206 -0
- package/dist/types/icons/animation/animation-loading.vue.d.ts +55 -0
- package/dist/types/icons/default/check-circle-fill.vue.d.ts +55 -0
- package/dist/types/icons/default/close-circle-fill.vue.d.ts +55 -0
- package/dist/types/icons/default/exclamation-circle-fill.vue.d.ts +55 -0
- package/dist/types/icons/default/info-circle-fill.vue.d.ts +55 -0
- package/dist/types/icons/default/minus-circle-fill.vue.d.ts +55 -0
- package/dist/types/icons/index.d.ts +7 -0
- package/dist/types/ui.d.ts +5 -0
- package/dist/ui.cjs.js +2 -0
- package/dist/ui.es.js +1395 -0
- package/dist/ui.umd.js +3 -0
- package/package.json +64 -63
- package/framework/es/client.io.js +0 -2
- package/framework/es/client.io.js.map +0 -1
- package/framework/es/exception.d.ts +0 -25
- package/framework/es/index.d.ts +0 -2
- package/framework/es/types.d.ts +0 -33
- package/framework/es/util.d.ts +0 -36
- package/framework/es/websocket.d.ts +0 -118
- package/framework/umd/client.io.js +0 -2
- package/framework/umd/client.io.js.map +0 -1
- package/framework/umd/exception.d.ts +0 -25
- package/framework/umd/index.d.ts +0 -2
- package/framework/umd/types.d.ts +0 -33
- package/framework/umd/util.d.ts +0 -36
- package/framework/umd/websocket.d.ts +0 -118
- package/index.d.ts +0 -159
package/dist/ui.umd.js
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode(".icon-loading-svg[data-v-62d46830]{animation:animated-loading-rotate-62d46830 1.5s infinite ease-in-out}.icon-loading-svg>.path[data-v-62d46830]{stroke:#fffc;stroke-width:5;animation:animated-loading-62d46830 1.5s infinite ease-in-out}@keyframes animated-loading-62d46830{0%{stroke-dasharray:1,125;stroke-dashoffset:0}50%{stroke-dasharray:95,31;stroke-dashoffset:-31px}to{stroke-dasharray:6,120;stroke-dashoffset:-120px}}@keyframes animated-loading-rotate-62d46830{to{transform:rotate(1turn)}}")),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
2
|
+
(function(B,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(B=typeof globalThis<"u"?globalThis:B||self,t(B.MyLibrary={},B.Vue))})(this,function(B,t){"use strict";var te=document.createElement("style");te.textContent=`.icon-loading-svg[data-v-62d46830]{animation:animated-loading-rotate-62d46830 1.5s infinite ease-in-out}.icon-loading-svg>.path[data-v-62d46830]{stroke:#fffc;stroke-width:5;animation:animated-loading-62d46830 1.5s infinite ease-in-out}@keyframes animated-loading-62d46830{0%{stroke-dasharray:1,125;stroke-dashoffset:0}50%{stroke-dasharray:95,31;stroke-dashoffset:-31px}to{stroke-dasharray:6,120;stroke-dashoffset:-120px}}@keyframes animated-loading-rotate-62d46830{to{transform:rotate(1turn)}}
|
3
|
+
`,document.head.appendChild(te);const ge="X",ke="x",ne=e=>e?ke+"-"+e:e||"",L=e=>ge+e,S=e=>{const n=ne(e);return{block:n,element:r=>`${n}--${r}`,modifier:r=>`${n}-${r}`,is:r=>`${n}-is-${r}`}},he=["px","%","vh","vw","calc"],oe=(e,n="px")=>{if(e===void 0)return"";const o=String(e);return he.some(l=>o.includes(l))?o:o+n},A=Object.prototype.toString;function le(e){return A.call(e)==="[object Array]"}function re(e){return A.call(e)==="[object Object]"}const se=e=>A.call(e)==="[object Promise]";function ae(e){return A.call(e)==="[object String]"}function Ne(e){return A.call(e)==="[object Number]"&&e===e}function E(e){return typeof e=="function"}function j(){return typeof window<"u"}const Ee=1e3,be=3e3,Be=1;class we{constructor(){this.popupStack={popup:new Set,dialog:new Set,message:new Set},this.getNextZIndex=n=>(n==="message"?Array.from(this.popupStack.message).pop()||be:Array.from(this.popupStack.popup).pop()||Ee)+Be,this.add=n=>{const o=this.getNextZIndex(n);return this.popupStack[n].add(o),n==="dialog"&&this.popupStack.popup.add(o),o},this.delete=(n,o)=>{this.popupStack[o].delete(n),o==="dialog"&&this.popupStack.popup.delete(n)},this.isLastDialog=n=>this.popupStack.dialog.size>1?n===Array.from(this.popupStack.dialog).pop():!0}}const v=new we;function W(e,{visible:n,runOnMounted:o}={}){const l=t.ref(0),a=()=>{l.value=v.add(e)},r=()=>{v.delete(l.value,e)},i=()=>e==="dialog"?v.isLastDialog(l.value):!1;return t.watch(()=>n==null?void 0:n.value,s=>{s?a():r()},{immediate:!0}),o&&(t.onMounted(()=>{a()}),t.onBeforeUnmount(()=>{r()})),{zIndex:t.readonly(l),open:a,close:r,isLastDialog:i}}const ie=e=>e.replace(/^./,n=>n.toLowerCase()).replace(/-(\w)/g,(n,o)=>{var l;return(l=o==null?void 0:o.toUpperCase())!==null&&l!==void 0?l:""}),ce=()=>{},Ve=(e,n)=>{var o;if(j)return(o=document.querySelector(e))!==null&&o!==void 0?o:void 0},Oe=e=>{if(e.tagName==="BODY")return window.innerWidth-(document.documentElement.offsetWidth||document.body.offsetWidth);const{borderLeftWidth:n,borderRightWidth:o}=window.getComputedStyle(e),l=Number(n.replace("px",""))+Number(o.replace("px",""));return e.offsetWidth-(e.clientWidth+l)},Se=e=>e.tagName==="BODY"?document.documentElement.scrollHeight>window.innerHeight:e.scrollHeight>e.offsetHeight,$e=(e,n)=>{var o;if(!j||!e||!n)return"";let l=ie(n);l==="float"&&(l="cssFloat");try{const a=e.style[l];if(a)return a;const r=(o=document.defaultView)===null||o===void 0?void 0:o.getComputedStyle(e,"");return r?r[l]:""}catch{return e.style[l]}},D=(e,n,o)=>{if(!(!e||!n))if(re(n))Object.entries(n).forEach(([l,a])=>D(e,l,a));else{const l=ie(n);e.style[l]=o}},Z=(e,n)=>{if(ae(e)){const o=e[0]==="#"?`[id='${e.slice(1)}']`:e;return Ve(o)}return e},Te=j?(e,n,o,l=!1)=>{e.addEventListener(n,o,l)}:ce,ze=j?(e,n,o,l=!1)=>{e.removeEventListener(n,o,l)}:ce,Me=(e,n)=>{let o=!1;const l={overflow:"",width:""},a=s=>s.tagName==="BODY",r=()=>{if(e.value){const s=e.value;if(!o&&s.style.overflow!=="hidden"){const d=Oe(s);if(d>0||Se(s)){l.overflow=s.style.overflow,l.width=s.style.width;let f=0;a(s)&&(f=s.getBoundingClientRect().left||0),D(s,{width:`calc(100% - ${Math.ceil(d-f)}px)`,overflow:"hidden"}),o=!0}}}},i=()=>{if(e.value&&o){const s=e.value;D(s,{overflow:l.overflow,width:l.width}),o=!1}};return t.watch(()=>n==null?void 0:n.value,s=>{e.value&&!a(e.value)&&(s&&D(s,{position:"absolute"}),$e(e.value,"position")==="static"&&D(e.value,{position:"relative"}))}),{setOverflowHidden:r,resetOverflow:i}},Le={ENTER:"Enter",ESC:"Escape",BACKSPACE:"Backspace",TAB:"Tab",SPACE:" ",ARROW_UP:"ArrowUp",ARROW_DOWN:"ArrowDown",ARROW_LEFT:"ArrowLeft",ARROW_RIGHT:"ArrowRight"},I=e=>e;var z;(function(e){e[e.ELEMENT=1]="ELEMENT",e[e.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",e[e.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",e[e.COMPONENT=6]="COMPONENT",e[e.TEXT_CHILDREN=8]="TEXT_CHILDREN",e[e.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",e[e.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",e[e.TELEPORT=64]="TELEPORT",e[e.SUSPENSE=128]="SUSPENSE",e[e.COMPONENT_SHOULD_KEEP_ALIVE=256]="COMPONENT_SHOULD_KEEP_ALIVE",e[e.COMPONENT_KEPT_ALIVE=512]="COMPONENT_KEPT_ALIVE"})(z||(z={}));const Ae=e=>!!(e&&e.shapeFlag&z.ELEMENT),De=(e,n)=>!!(e&&e.shapeFlag&z.COMPONENT),Ie=(e,n)=>!!(e&&e.shapeFlag&8),Pe=(e,n)=>!!(e&&e.shapeFlag&z.ARRAY_CHILDREN),He=(e,n)=>!!(e&&e.shapeFlag&z.SLOTS_CHILDREN),R=(e,n=!1)=>{var o,l;const a=[];for(const r of e??[])Ae(r)||De(r)||n&&Ie(r,r.children)?a.push(r):Pe(r,r.children)?a.push(...R(r.children,n)):He(r,r.children)?a.push(...R((l=(o=r.children).default)===null||l===void 0?void 0:l.call(o),n)):le(r)&&a.push(...R(r,n));return a},je={renderTo:{type:I([String,Object]),default:"body"},disabled:{type:Boolean,default:!1},modelValue:{type:Boolean,default:!1},top:{type:[String,Number],default:"3vh"},center:{type:Boolean,default:!1},width:{type:[String,Number],default:0},height:{type:[String,Number],default:0},minWidth:{type:[String,Number],default:0},minHeight:{type:[String,Number],default:0},title:{type:String,default:""},mask:{type:Boolean,default:!0},destroyOnClosed:{type:Boolean,default:!0},onBeforeCancel:{type:Function},maskToClose:{type:Boolean,default:!0},escToClose:{type:Boolean,default:!0},fullscreen:{type:Boolean,default:!1},messageBox:{type:Boolean,default:!1},popupClass:{type:String,default:void 0},showClose:{type:Boolean,default:!0},showHeaderBottomLine:{type:Boolean,default:!1}},Re=["width","minWidth","height","minHeight"],Fe=t.defineComponent({name:L("Dialog"),inheritAttrs:!1,props:je,emits:["closed","close","open","opened","update:modelValue"],setup(e,{emit:n}){const o=S("dialog"),l=o.block,a=S("message-box"),r=a.block,i=t.computed(()=>[l,e.messageBox&&"is-message-box",e.popupClass&&e.popupClass]),s=t.computed(()=>Z(e.renderTo)),d=t.ref(),f=t.computed(()=>e.disabled||!s.value),g=t.computed(()=>({zIndex:h.value})),m=t.computed(()=>{const k={};return e.fullscreen||(!e.center&&e.top&&(k.top=oe(e.top)),Re.forEach(T=>{e[T]&&(k[T]=oe(e[T]))})),k}),y=t.ref(!1),u=t.computed(()=>e.modelValue),N=t.computed(()=>u.value||y.value),{zIndex:h,isLastDialog:b}=W("dialog",{visible:u}),{setOverflowHidden:p,resetOverflow:c}=Me(s,d),C=(k,T)=>{n("update:modelValue",!1),n("close",e.messageBox?k:void 0,e.messageBox?T:void 0)},V=()=>{y.value=!1,c(),n("closed")},O=()=>{n("opened")},$=t.reactive({ok:!1,cancel:!1}),H=(k,T)=>{let U=!0;if($[k]=!0,E(e.onBeforeCancel)&&(U=e.onBeforeCancel(k)??!1),se(U)){U.then(wt=>{$[k]=!1,wt&&C(k,T)});return}$[k]=!1,U&&C(k,T)},Nt=()=>{e.maskToClose&&e.mask&&H("cancel")},Et=k=>{H("cancel",k)},bt=k=>{H("ok",k)};let ee=!1;const Ce=k=>{e.escToClose&&k.key===Le.ESC&&b()&&H("cancel")},Bt=()=>{e.escToClose&&!ee&&(ee=!0,Te(document.documentElement,"keydown",Ce))},ye=()=>{ee=!1,ze(document.documentElement,"keydown",Ce)};return t.onBeforeUnmount(()=>{c(),ye()}),t.watch(()=>u.value,k=>{k?(n("open"),p(),y.value=!0,Bt()):ye()},{immediate:!0}),{cls:i,ns:l,cn:o,cnOMB:a,messageBoxNs:r,containerStyle:m,dialogStyle:g,dialogRef:d,teleportContainer:s,teleportDisabled:f,modelVisible:u,mergeVisible:N,interceptClose:H,afterLeave:V,afterEnter:O,handleMaskClick:Nt,handleCancel:Et,handleOk:bt,loadingObj:$}}}),w=(e,n)=>{const o=e.__vccOpts||e;for(const[l,a]of n)o[l]=a;return o};function _e(e,n,o,l,a,r){return t.openBlock(),t.createBlock(t.Teleport,{to:e.teleportContainer,disabled:e.teleportDisabled},[!e.destroyOnClosed||e.mergeVisible?t.withDirectives((t.openBlock(),t.createElementBlock("div",{key:0,ref:"dialogRef",class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.dialogStyle)},[t.createVNode(t.Transition,{name:"x-fade-in-standard",appear:""},{default:t.withCtx(()=>[e.mask?t.withDirectives((t.openBlock(),t.createElementBlock("div",{key:0,class:t.normalizeClass([e.cn.element("mask")])},null,2)),[[t.vShow,e.modelVisible]]):t.createCommentVNode("",!0)]),_:1}),t.createElementVNode("div",{class:t.normalizeClass([e.cn.element("wrapper"),{"is-center":e.center}]),onClick:n[1]||(n[1]=t.withModifiers((...i)=>e.handleMaskClick&&e.handleMaskClick(...i),["self"]))},[t.createVNode(t.Transition,{name:"x-zoom-in",appear:"",onAfterEnter:e.afterEnter,onAfterLeave:e.afterLeave},{default:t.withCtx(()=>[t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass([e.cn.element("container"),{"is-fullscreen":e.fullscreen}]),style:t.normalizeStyle(e.containerStyle)},[t.createElementVNode("div",{class:t.normalizeClass([e.messageBox?e.cnOMB.element("header"):e.cn.element("header"),e.showHeaderBottomLine&&"is-bottom-line"])},[t.renderSlot(e.$slots,"title",{},()=>[t.createElementVNode("div",{class:t.normalizeClass([e.cn.element("header-title")])},t.toDisplayString(e.title),3)])],2),t.createElementVNode("div",{class:t.normalizeClass([e.messageBox?e.cnOMB.element("body"):e.cn.element("body")])},[t.renderSlot(e.$slots,"default")],2),t.createElementVNode("div",{class:t.normalizeClass([e.messageBox?e.cnOMB.element("footer"):e.cn.element("footer")])},[t.renderSlot(e.$slots,"footer",{cancel:e.handleCancel,ok:e.handleOk,loadingObj:e.loadingObj})],2),e.showClose?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass([e.cn.element("close-icon"),e.messageBox&&e.cnOMB.element("close-icon")]),onClick:n[0]||(n[0]=i=>e.interceptClose("cancel"))},null,2)):t.createCommentVNode("",!0)],6),[[t.vShow,e.modelVisible]])]),_:3},8,["onAfterEnter","onAfterLeave"])],2)],6)),[[t.vShow,e.mergeVisible]]):t.createCommentVNode("",!0)],8,["to","disabled"])}const de=w(Fe,[["render",_e]]),Ue={disabled:Boolean,block:Boolean,loading:Boolean,loadingFill:{type:Boolean,default:!1},debounce:{type:Number,default:0},shape:{type:I(String),default:void 0},link:{type:Boolean,default:!1},type:{type:I(String),default:void 0},status:{type:I(String),default:void 0},plain:{type:Boolean,default:!1},size:{type:I(String),default:"medium"},border:{type:Boolean,default:!0}},ve=e=>ae(e)?e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(""):"",We=(e,n="px")=>{if(e===void 0)return"";const o=typeof e=="number"?`${e}`:e;return["px","%","vh","vw","calc"].some(a=>o.includes(a))?o:o+n};function M(e){return t.defineComponent({name:ne(`Icon${ve(e)}`),props:{size:{type:[Number,String],default:void 0},rotate:{type:Number,default:void 0},spin:{type:Boolean,default:!1},color:{type:String,default:void 0},fillColor:{type:Array,default:void 0}},setup(n){const o="x-icon",l=t.computed(()=>{const r={};return n.size&&(r.fontSize=We(n.size)),n.rotate&&(r.transform=`rotate(${n.rotate}deg)`),n.color&&(r.color=n.color),r});return{cls:t.computed(()=>[o,{[`${o}-loading`]:n.spin}]),styles:l}}})}const Ze=M("animation-loading");function Ke(e,n,o,l,a,r){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.styles)},n[0]||(n[0]=[t.createElementVNode("svg",{viewBox:"0 0 50 50",class:"icon-loading-svg"},[t.createElementVNode("circle",{cx:"25",cy:"25",r:"20",class:"path",fill:"none",stroke:"currentColor"})],-1)]),6)}const Xe=w(Ze,[["render",Ke],["__scopeId","data-v-62d46830"]]),Ye=t.defineComponent({name:L("Button"),components:{AnimationLoading:Xe},props:Ue,emits:["click"],setup(e){const n=t.reactive({clicked:!1,isDebounce:!1}),o=S("button"),l=t.computed(()=>[o.block,e.type&&o.modifier(e.type),e.status&&o.modifier(e.status),e.disabled&&o.is("disabled"),e.block&&o.modifier("block"),e.plain&&o.is("plain"),e.shape&&o.modifier(e.shape),e.link&&o.modifier("is-link"),e.size&&o.modifier(e.size),!e.border&&o.modifier("is-hide-border"),r.value&&o.modifier("is-loading")]),a=()=>{e.debounce>0&&!n.isDebounce&&(n.isDebounce=!0,setTimeout(()=>{n.isDebounce=!1},e.debounce))},r=t.computed(()=>e.loading||n.clicked||n.isDebounce),i=t.getCurrentInstance(),s=(f,g)=>{const m=f(g);se(m)&&(n.clicked=!0,m.finally(()=>{n.clicked=!1}))};return{cn:o,cls:l,handleClick:async f=>{var m,y,u,N;if((y=(m=f.target).blur)==null||y.call(m),r.value)return;a();const g=(N=(u=i==null?void 0:i.vnode)==null?void 0:u.props)==null?void 0:N.onClick;le(g)?g.forEach(h=>s(h,f)):E(g)&&s(g,f)},isLoading:r}}}),xe=["disabled"];function Ge(e,n,o,l,a,r){const i=t.resolveComponent("AnimationLoading");return t.openBlock(),t.createElementBlock("button",{class:t.normalizeClass(e.cls),type:"button",disabled:e.disabled,onClick:n[0]||(n[0]=(...s)=>e.handleClick&&e.handleClick(...s))},[t.withDirectives(t.createElementVNode("span",{class:t.normalizeClass([e.cn.element("loading")])},[t.createVNode(i)],2),[[t.vShow,e.isLoading]]),e.$slots.prefix?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass([e.cn.element("prefix")])},[t.renderSlot(e.$slots,"prefix")],2)):t.createCommentVNode("",!0),t.renderSlot(e.$slots,"default"),e.$slots.suffix?(t.openBlock(),t.createElementBlock("span",{key:1,class:t.normalizeClass([e.cn.element("suffix")])},[t.renderSlot(e.$slots,"suffix")],2)):t.createCommentVNode("",!0)],10,xe)}const F=w(Ye,[["render",Ge]]),fe=t.defineComponent({name:L("Space"),props:{direction:{type:String,default:"horizontal"},size:{type:[Number,String],default:"small"},align:{type:String,default:"center"},fill:{type:Boolean,default:!1}},setup(e,{slots:n}){const o=S("space"),l=t.computed(()=>[o.block,o.element(e.direction),e.fill&&"is-fill",o.element(`${e.direction}-${e.align}`)]);function a(i){if(Ne(i))return i;switch(i){case"mini":return 4;case"small":return 8;case"medium":return 16;case"large":return 24;default:return 8}}const r=i=>{const s={};if(i)return s;const d=`${a(e.size)}px`,f=`${a(e.size)}px`;return e.direction==="horizontal"&&(s.marginRight=d),e.direction==="vertical"&&(s.marginBottom=f),s};return()=>{var i;const s=R((i=n.default)===null||i===void 0?void 0:i.call(n),!0).filter(d=>d.type!==t.Comment);return t.createVNode("div",{class:[l.value]},[s.map((d,f)=>{var g;const m=n.split&&f>0;return t.createVNode(t.Fragment,{key:`space-item-${f}`},[m&&t.createVNode("div",{className:o.element("split"),style:r(!1)},[(g=n.split)===null||g===void 0?void 0:g.call(n)]),t.createVNode("div",{className:o.element("item"),style:r(f===s.length-1)},[d])])})])}}});function me(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const ue=S("dialog"),qe=e=>{var n,o,l,a,r,i;const s=document.createElement("div"),d=()=>{t.render(null,s)},f=p=>{if(p==="cancel")return e.beforeOnCancel?e.beforeOnCancel():!0;if(p==="ok")return e.beforeOnOk?e.beforeOnOk():!0},g=(p,c)=>{p==="cancel"&&e.onCancel&&e.onCancel(c),p==="ok"&&e.onOk&&e.onOk(c)},m=p=>{if(t.isVNode(p))return p;if(E(p)){const c=p();return t.isVNode(c)?c:null}return t.createVNode("div",{className:ue.element("header-title")},[t.createTextVNode(" "),p,t.createTextVNode(" ")])},y=p=>{if(t.isVNode(p))return p;if(E(p)){const c=p();return t.isVNode(c)?c:null}return t.createVNode("div",{className:ue.element("content")},[t.createTextVNode(" "),e.content,t.createTextVNode(" ")])},u=()=>()=>t.createVNode(t.Fragment,null,[e.title&&m(e.title)]),N=()=>()=>t.createVNode(t.Fragment,null,[e.content&&y(e.content)]),h=()=>{if(t.isVNode(e.footer)||E(e.footer))return e.footer;const p=(e==null?void 0:e.cancelText)||"取消",c=(e==null?void 0:e.okText)||"确认";return C=>{var V,O;return t.createVNode(fe,{size:12},{default:()=>[!e.hideCancel&&t.createVNode(F,{size:"small",onClick:C.cancel,loading:(V=C.loadingObj)===null||V===void 0?void 0:V.cancel},me(p)?p:{default:()=>[p]}),!e.hideOk&&t.createVNode(F,{type:"primary",size:"small",onClick:C.ok,loading:(O=C.loadingObj)===null||O===void 0?void 0:O.ok},me(c)?c:{default:()=>[c]})]})}},b=t.createVNode(de,{width:(n=e==null?void 0:e.width)!==null&&n!==void 0?n:368,height:(o=e==null?void 0:e.height)!==null&&o!==void 0?o:"auto",modelValue:!0,renderTo:e==null?void 0:e.renderTo,center:e!=null&&e.top?!1:(l=e==null?void 0:e.center)!==null&&l!==void 0?l:!0,top:(a=e==null?void 0:e.top)!==null&&a!==void 0?a:0,mask:(r=e==null?void 0:e.mask)!==null&&r!==void 0?r:!0,maskToClose:(i=e==null?void 0:e.maskToClose)!==null&&i!==void 0?i:!0,popupClass:e.popupClass,onClose:g,onBeforeCancel:f,"onUpdate:modelValue":()=>{b.component.props.modelValue=!1},onClosed:d,onOpened:()=>{}},{title:u(),default:N(),footer:h()});t.render(b,s)},Je=["success","warning","error","strong","info"],Qe=M("close-circle-fill");function et(e,n,o,l,a,r){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.styles)},n[0]||(n[0]=[t.createElementVNode("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"4","stroke-linecap":"butt","stroke-linejoin":"miter",filter:""},[t.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M24 44c11.046 0 20-8.954 20-20S35.046 4 24 4 4 12.954 4 24s8.954 20 20 20Zm4.955-27.771-4.95 4.95-4.95-4.95a1 1 0 0 0-1.414 0l-1.414 1.414a1 1 0 0 0 0 1.414l4.95 4.95-4.95 4.95a1 1 0 0 0 0 1.414l1.414 1.414a1 1 0 0 0 1.414 0l4.95-4.95 4.95 4.95a1 1 0 0 0 1.414 0l1.414-1.414a1 1 0 0 0 0-1.414l-4.95-4.95 4.95-4.95a1 1 0 0 0 0-1.414l-1.414-1.414a1 1 0 0 0-1.414 0Z",fill:"currentColor",stroke:"none"})],-1)]),6)}const K=w(Qe,[["render",et]]),tt=M("check-circle-fill");function nt(e,n,o,l,a,r){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.styles)},n[0]||(n[0]=[t.createElementVNode("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"4","stroke-linecap":"butt","stroke-linejoin":"miter",filter:""},[t.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M24 44c11.046 0 20-8.954 20-20S35.046 4 24 4 4 12.954 4 24s8.954 20 20 20Zm10.207-24.379a1 1 0 0 0 0-1.414l-1.414-1.414a1 1 0 0 0-1.414 0L22 26.172l-4.878-4.88a1 1 0 0 0-1.415 0l-1.414 1.415a1 1 0 0 0 0 1.414l7 7a1 1 0 0 0 1.414 0l11.5-11.5Z",fill:"currentColor",stroke:"none"})],-1)]),6)}const X=w(tt,[["render",nt]]),ot=M("exclamation-circle-fill");function lt(e,n,o,l,a,r){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.styles)},n[0]||(n[0]=[t.createElementVNode("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"4","stroke-linecap":"butt","stroke-linejoin":"miter",filter:""},[t.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M24 44c11.046 0 20-8.954 20-20S35.046 4 24 4 4 12.954 4 24s8.954 20 20 20Zm-2-11a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v2Zm4-18a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1V15Z",fill:"currentColor",stroke:"none"})],-1)]),6)}const Y=w(ot,[["render",lt]]),rt=M("info-circle-fill");function st(e,n,o,l,a,r){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.styles)},n[0]||(n[0]=[t.createElementVNode("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"4","stroke-linecap":"butt","stroke-linejoin":"miter",filter:""},[t.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M24 44c11.046 0 20-8.954 20-20S35.046 4 24 4 4 12.954 4 24s8.954 20 20 20Zm2-30a1 1 0 0 0-1-1h-2a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2Zm0 17h1a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-6a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1h1v-8a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v11Z",fill:"currentColor",stroke:"none"})],-1)]),6)}const x=w(rt,[["render",st]]),at=M("minus-circle-fill");function it(e,n,o,l,a,r){return t.openBlock(),t.createElementBlock("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.styles)},n[0]||(n[0]=[t.createElementVNode("svg",{viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",stroke:"currentColor","stroke-width":"4","stroke-linecap":"butt","stroke-linejoin":"miter",filter:""},[t.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M24 44c11.046 0 20-8.954 20-20S35.046 4 24 4 4 12.954 4 24s8.954 20 20 20Zm-7-22a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1H17Z",fill:"currentColor",stroke:"none"})],-1)]),6)}const G=w(at,[["render",it]]),ct=t.defineComponent({name:L("Message"),components:{CloseCircleFill:K,CheckCircleFill:X,ExclamationCircleFill:Y,InfoCircleFill:x,MinusCircleFill:G},props:{id:{type:String,default:""},message:{type:[String,Number,Object],default:""},type:{type:String,default:"success"},duration:{type:Number,default:1500},center:{type:Boolean,default:!1},onClose:{type:Function,default:()=>{}},offset:{type:Number,default:20},zIndex:{type:Number,default:0},showClose:{type:Boolean,default:!1},useHTML:Boolean,popupClass:{type:String,default:void 0}},emits:["destroy"],setup(e){const n=S("message"),o=t.computed(()=>[n.block,n.modifier(e.type),e.center&&n.modifier("center"),e.showClose&&!e.center&&n.element("show-close"),e.popupClass&&e.popupClass]),l=t.ref(!1);let a=null;const r=()=>{a=setTimeout(()=>{l.value=!1},e.duration)};t.onMounted(()=>{l.value=!0,e.duration!==0&&r()}),t.onUnmounted(()=>{clearTimeout(a)});const{zIndex:i}=W("message",{runOnMounted:!0}),s=t.computed(()=>({top:`${e.offset}px`,zIndex:i.value}));return{cn:n,cls:o,styles:s,visible:l,handleClose:()=>{l.value=!1}}}}),dt=["innerHTML"],ft={key:1};function mt(e,n,o,l,a,r){const i=t.resolveComponent("CheckCircleFill"),s=t.resolveComponent("ExclamationCircleFill"),d=t.resolveComponent("MinusCircleFill"),f=t.resolveComponent("CloseCircleFill"),g=t.resolveComponent("InfoCircleFill");return t.openBlock(),t.createBlock(t.Transition,{name:"x-message-slide-top",onBeforeLeave:e.onClose,onAfterLeave:n[1]||(n[1]=m=>e.$emit("destroy"))},{default:t.withCtx(()=>[t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.styles)},[e.$slots.icon?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass([e.cn.element("icon"),e.cn.modifier(`icon-${e.type}`)])},[t.renderSlot(e.$slots,"icon",{},()=>[e.type==="success"?(t.openBlock(),t.createBlock(i,{key:0})):e.type==="warning"?(t.openBlock(),t.createBlock(s,{key:1})):e.type==="strong"?(t.openBlock(),t.createBlock(d,{key:2})):e.type==="error"?(t.openBlock(),t.createBlock(f,{key:3})):e.type==="info"?(t.openBlock(),t.createBlock(g,{key:4})):t.createCommentVNode("",!0)])],2)),t.renderSlot(e.$slots,"default",{},()=>[e.useHTML?(t.openBlock(),t.createElementBlock("span",{key:0,innerHTML:e.message},null,8,dt)):(t.openBlock(),t.createElementBlock("span",ft,t.toDisplayString(e.message),1)),e.showClose?(t.openBlock(),t.createElementBlock("span",{key:2,class:t.normalizeClass([e.cn.element("close-icon")]),onClick:n[0]||(n[0]=(...m)=>e.handleClose&&e.handleClose(...m))},null,2)):t.createCommentVNode("",!0)])],6),[[t.vShow,e.visible]])]),_:3},8,["onBeforeLeave"])}const ut=w(ct,[["render",mt]]),q=new WeakMap,_=e=>{(typeof e=="string"||t.isVNode(e))&&(e={message:e});const n=Z(e.renderTo||"body");q.has(n)||q.set(n,[]);const o=q.get(n);let l=e.offset||20;o.forEach(m=>{var y;l+=((y=m.el)===null||y===void 0?void 0:y.offsetHeight)+20});const a=e.onClose;let r={};r={...e,onClose:()=>{var m;const y=o.findIndex(N=>N===d);if(y<0)return;const u=((m=d.el)===null||m===void 0?void 0:m.offsetHeight)+20;o.slice(y+1).forEach(N=>{var h;const b=(h=N.component)===null||h===void 0?void 0:h.props.offset;N.component.props.offset=b-u}),o.splice(y,1),a&&a(d)},onDestroy:()=>{t.render(null,f)},offset:l};const d=t.createVNode(ut,r,E(r.message)||t.isVNode(r.message)?{default:E(r.message)?r.message:()=>r.message}:null),f=document.createElement("div");return t.render(d,f),n.tagName==="BODY"?d.el.style.position="fixed":(n.style.position="relative",d.el.style.position="absolute"),n.appendChild(f.firstElementChild),o.push(d),{close:()=>{d.component.proxy.handleClose()}}};(()=>{Je.forEach(e=>{_[e]=n=>re(n)?_({type:e,...n}):_({message:n,type:e})})})();const pt=["info","success","warning","strong","error"];function pe(e){return typeof e=="function"||Object.prototype.toString.call(e)==="[object Object]"&&!t.isVNode(e)}const J=S("message-box"),Q=e=>{var n,o,l,a,r,i;const s=document.createElement("div"),d=()=>{t.render(null,s)},f=c=>{if(c==="cancel")return e.beforeOnCancel?e.beforeOnCancel():!0;if(c==="ok")return e.beforeOnOk?e.beforeOnOk():!0},g=(c,C)=>{c==="cancel"&&e.onCancel&&e.onCancel(C),c==="ok"&&e.onOk&&e.onOk(C)},m=c=>{let C;switch(c){case"warning":C=t.createVNode(Y,{size:"22px",color:"#f6c64b"},null);break;case"strong":C=t.createVNode(G,{size:"22px",color:"#ff7125"},null);break;case"error":C=t.createVNode(K,{size:"22px",color:"#e24f48"},null);break;case"success":C=t.createVNode(X,{size:"22px",color:"#68d1ab"},null);break;case"info":C=t.createVNode(x,{size:"22px",color:"#2355f5"},null);break}return t.createVNode("div",{className:J.element("icon")},[C])},y=c=>{if(t.isVNode(c))return c;if(E(c)){const C=c();return t.isVNode(C)?C:null}return t.createVNode("div",{className:J.element("title")},[t.createTextVNode(" "),c,t.createTextVNode(" ")])},u=c=>{if(t.isVNode(c))return c;if(E(c)){const C=c();return t.isVNode(C)?C:null}return t.createVNode("div",{className:J.element("content")},[t.createTextVNode(" "),e.content,t.createTextVNode(" ")])},N=()=>()=>t.createVNode(t.Fragment,null,[m(e.type||"success"),e.title&&y(e.title)]),h=()=>()=>t.createVNode(t.Fragment,null,[e.content&&u(e.content)]),b=()=>{if(t.isVNode(e.footer)||E(e.footer))return e.footer;const c=(e==null?void 0:e.cancelText)||"取消",C=(e==null?void 0:e.okText)||"确认";return V=>{var O,$;return t.createVNode(fe,{size:12},{default:()=>[!e.hideCancel&&t.createVNode(F,{size:"small",onClick:V.cancel,loading:(O=V.loadingObj)===null||O===void 0?void 0:O.cancel},pe(c)?c:{default:()=>[c]}),!e.hideOk&&t.createVNode(F,{type:"primary",size:"small",onClick:V.ok,loading:($=V.loadingObj)===null||$===void 0?void 0:$.ok},pe(C)?C:{default:()=>[C]})]})}},p=t.createVNode(de,{messageBox:!0,width:(n=e==null?void 0:e.width)!==null&&n!==void 0?n:358,height:(o=e==null?void 0:e.height)!==null&&o!==void 0?o:"auto",modelValue:!0,renderTo:e==null?void 0:e.renderTo,center:e!=null&&e.top?!1:(l=e==null?void 0:e.center)!==null&&l!==void 0?l:!0,top:(a=e==null?void 0:e.top)!==null&&a!==void 0?a:0,mask:(r=e==null?void 0:e.mask)!==null&&r!==void 0?r:!0,maskToClose:(i=e==null?void 0:e.maskToClose)!==null&&i!==void 0?i:!0,popupClass:e.popupClass,onClose:g,onBeforeCancel:f,"onUpdate:modelValue":()=>{p.component.props.modelValue=!1},onClosed:d,onOpened:()=>{}},{title:N(),default:h(),footer:b()});t.render(p,s)};(()=>{pt.forEach(e=>{Q[e]=(n,o)=>{const l=[],a=[];let r=()=>!0,i=()=>!0;return setTimeout(()=>{Q({title:n,content:o,type:e,beforeOnCancel:i,beforeOnOk:r,onOk:()=>{l.forEach(s=>E(s)&&s())},onCancel:()=>{a.forEach(s=>E(s)&&s())}})},0),{ok(...s){return s.length===1&&l.push(s[0]),s.length===2&&(r=s[0],l.push(s[1])),this},cancel(...s){return s.length===1&&a.push(s[0]),s.length===2&&(i=s[0],a.push(s[1])),this}}}})})();const Ct={position:{type:String,default:"top-right"},offset:{type:Number,default:0},title:{type:String,default:""},type:{type:String,default:"info"},message:{type:String,default:void 0},duration:{type:Number,default:3e3},showClose:{type:Boolean,default:!0},onClose:{type:Function,default:()=>{}},renderToBody:{type:Boolean,default:!1}},yt=t.defineComponent({name:L("Notification"),props:Ct,emits:["close","destroy"],setup(e){const n=S("notification"),o=n.block,l=t.computed(()=>[o,n.modifier(r.value.ver)]),{zIndex:a}=W("message",{runOnMounted:!0}),r=t.computed(()=>{const u=e.position.split("-");return{hor:u[1],ver:u[0]}}),i=t.computed(()=>`x-notification-slide-${r.value.hor}`),s=t.computed(()=>{const u={};return u.position=e.renderToBody?"fixed":"absolute",u.zIndex=a.value,u[r.value.hor]="20px",u[r.value.ver]=`${e.offset}px`,u}),d=t.ref(!1);let f=0;const g=()=>{f=setTimeout(()=>{d.value=!1},e.duration)},m=t.computed(()=>e.type==="info"?x:e.type==="warning"?Y:e.type==="strong"?G:e.type==="success"?X:e.type==="error"?K:""),y=()=>{d.value=!1};return t.onMounted(()=>{e.duration!==0&&g(),d.value=!0}),t.onUnmounted(()=>{clearTimeout(f)}),{ns:o,cn:n,cls:l,animationClsName:i,positionStyle:s,visible:d,positionPropMap:r,currentIcon:m,handleClose:y}}});function gt(e,n,o,l,a,r){return t.openBlock(),t.createBlock(t.Transition,{name:e.animationClsName,onBeforeLeave:n[1]||(n[1]=i=>e.$emit("close")),onAfterLeave:n[2]||(n[2]=i=>e.$emit("destroy"))},{default:t.withCtx(()=>[t.withDirectives(t.createElementVNode("div",{class:t.normalizeClass(e.cls),style:t.normalizeStyle(e.positionStyle)},[t.createElementVNode("div",{class:t.normalizeClass([e.cn.element("header")])},[t.createElementVNode("div",{class:t.normalizeClass([e.cn.element("icon"),e.cn.modifier(`icon-${e.type}`)])},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.currentIcon)))],2),t.createElementVNode("div",null,[t.createElementVNode("div",{class:t.normalizeClass([e.cn.element("title")])},t.toDisplayString(e.title),3),t.createElementVNode("div",{class:t.normalizeClass([e.cn.element("message")])},[t.renderSlot(e.$slots,"default",{},()=>[t.createTextVNode(t.toDisplayString(e.message),1)])],2)])],2),e.showClose?(t.openBlock(),t.createElementBlock("span",{key:0,class:t.normalizeClass([e.cn.element("close-icon")]),onClick:n[0]||(n[0]=t.withModifiers((...i)=>e.handleClose&&e.handleClose(...i),["self"]))},null,2)):t.createCommentVNode("",!0)],6),[[t.vShow,e.visible]])]),_:3},8,["name"])}const kt=w(yt,[["render",gt]]),P=new WeakMap,ht=e=>{var n,o;const l=Z(e.renderTo||"body"),a=document.createElement("div");P.get(l)||P.set(l,{}),P.get(l)[e.position]||(P.get(l)[e.position]=[]);const r=P.get(l)[e.position];let i=e.offset||20;r.forEach(y=>{var u;i+=((u=y.el)===null||u===void 0?void 0:u.offsetHeight)+20});const s=l.tagName==="BODY";s||(l.style.position="relative",l.style.overflowX="hidden");const d=e.onClose,f=()=>{var y;const u=r.findIndex(h=>h===m);if(u<0)return;const N=((y=m.el)===null||y===void 0?void 0:y.offsetHeight)+20;r.slice(u+1).forEach(h=>{var b;const p=(b=h.component)===null||b===void 0?void 0:b.props.offset;h.component.props.offset=p-N}),r.splice(u,1),d&&d(m)},g=()=>{t.render(null,a)},m=t.createVNode(kt,{message:e.message,title:e.title,type:e.type,offset:i,renderToBody:s,position:e.position,duration:(n=e.duration)!==null&&n!==void 0?n:3e3,showClose:(o=e.showClose)!==null&&o!==void 0?o:!0,onClose:f,onDestroy:g},E(e.message)||t.isVNode(e.message)?{default:E(e.message)?e.message:()=>e.message}:null);t.render(m,a),r.push(m),l==null||l.appendChild(a.firstChild)};B.Dialog=qe,B.Message=_,B.MessageBox=Q,B.Notification=ht,Object.defineProperty(B,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,65 +1,66 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
"
|
4
|
-
"
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
"
|
13
|
-
|
14
|
-
|
15
|
-
"
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
"
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
2
|
+
"author": {
|
3
|
+
"email": "xy@ztes.com",
|
4
|
+
"name": "XuYu"
|
5
|
+
},
|
6
|
+
"license": "MIT",
|
7
|
+
"engines": {
|
8
|
+
"node": ">=10.16.0"
|
9
|
+
},
|
10
|
+
"repository": {
|
11
|
+
"type": "git",
|
12
|
+
"url": "https://github.com/ztes/x-next.git"
|
13
|
+
},
|
14
|
+
"bugs": {
|
15
|
+
"url": "https://github.com/ztes/x-next/issues"
|
16
|
+
},
|
17
|
+
"private": false,
|
18
|
+
"name": "x-next",
|
19
|
+
"version": "0.0.0-alpha.2",
|
20
|
+
"publishConfig": {
|
21
|
+
"access": "public"
|
22
|
+
},
|
23
|
+
"description": "A simple Vue 3 UI component. ",
|
24
|
+
"keywords": [
|
25
|
+
"vue",
|
26
|
+
"vue 3",
|
27
|
+
"component"
|
28
|
+
],
|
29
|
+
"main": "dist/ui.umd.js",
|
30
|
+
"module": "dist/ui.es.js",
|
31
|
+
"types": "./dist/types/ui.d.ts",
|
32
|
+
"files": [
|
33
|
+
"dist"
|
34
|
+
],
|
35
|
+
"scripts": {
|
36
|
+
"dev": "vite",
|
37
|
+
"dev:docs": "vitepress dev docs",
|
38
|
+
"build:component": "vite build",
|
39
|
+
"build:docs": "vitepress build docs",
|
40
|
+
"preview:docs": "vitepress preview docs",
|
41
|
+
"format": "prettier -w ."
|
42
|
+
},
|
43
|
+
"devDependencies": {
|
44
|
+
"@babel/types": "^7.22.4",
|
45
|
+
"@types/node": "^20.2.5",
|
46
|
+
"@vitejs/plugin-vue": "^4.2.3",
|
47
|
+
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
48
|
+
"@vue/compiler-sfc": "^3.5.12",
|
49
|
+
"prettier": "^2.8.8",
|
50
|
+
"sass": "^1.80.3",
|
51
|
+
"sass-loader": "^16.0.2",
|
52
|
+
"typescript": "^5.4.5",
|
53
|
+
"vite": "^5.2.13",
|
54
|
+
"vite-plugin-css-injected-by-js": "^3.1.1",
|
55
|
+
"vite-plugin-dts": "^2.3.0",
|
56
|
+
"vitepress": "^1.4.1",
|
57
|
+
"vue": "^3.5.12"
|
58
|
+
},
|
59
|
+
"peerDependencies": {
|
60
|
+
"vue": "^3.0.0"
|
61
|
+
},
|
62
|
+
"dependencies": {
|
63
|
+
"date-fns": "^2.22.1",
|
64
|
+
"dayjs": "^1.11.13"
|
65
|
+
}
|
65
66
|
}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
function consoleLog(e,t,n,c){console.log("".concat("\n"," %c ").concat(e," %c ").concat(t," ").concat("\n"),"color: ".concat(n,"; background: ").concat(c,"; padding:5px 0;border-radius:3px 0 0 3px;"),"color:#666666;background: #f1f5fa; padding:5px 0;border-radius:0 3px 3px 0;")}function now(){return"".concat((new Date).getHours()<10?"0"+(new Date).getHours():(new Date).getHours(),":").concat((new Date).getMinutes()<10?"0"+(new Date).getMinutes():(new Date).getMinutes(),":").concat((new Date).getSeconds()<10?"0"+(new Date).getSeconds():(new Date).getSeconds())}function jsonStringify2Parse(t){if("string"==typeof t)try{return JSON.parse(t)}catch(e){return JSON.parse(JSON.stringify('{"value":'.concat(t)))}return{}}var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var WebSocketBucketState,Exception=function(c){function e(e,t){var n=c.call(this,t)||this;return n.name="Client.io Error",n.message="Error message",n.name=e||n.name,n.message=t||n.message,n.stack=(new Error).stack,n}return __extends(e,c),e}(Error),WebSocketBucket=(!function(e){e.CONNECTING="CONNECTING",e.OPEN="OPEN",e.CLOSING="CLOSING",e.CLOSED="CLOSED",e.FAIL="FAIL"}(WebSocketBucketState=WebSocketBucketState||{}),function(){function k(){this.bucketName=k.DEFAULT_NAME,this.buckets=new Map,this.bucketName=k.DEFAULT_NAME}return k.create=function(e){var c,o,t,n=e.url,a=e.name,r=e.heartbeat,s=e.heartRate,s=void 0===s?3e3:s,i=e.restartTime,i=void 0===i?5e3:i,u=e.restartTimes,u=void 0===u?0:u,f=e.restartedTimes,g=void 0===f?0:f,f=e.receive,e=e.send;if(/(ws|wss):\/\/\s*/.test(n))return c=a||k.getBucketName(a),t=new WebSocket(n),o=-1,t.onopen=function(e){consoleLog("".concat(c," ▶ SUCCESS"),"◔ ".concat(now()),"#ffffff","#1bc800"),k.setBucketKeyValue("restartedTimes",0,c),k.bindMessage(a)},t.onerror=function(e){consoleLog("".concat(c," ▶ ERROR"),"◔ ".concat(now()," ▶ ").concat(c),"#ffffff","#c80000")},t.onclose=function(e){consoleLog("".concat(c," ▶ CLOSE"),"◔ ".concat(now()," ▶ ").concat(c),"#ffffff","#000000"),clearInterval(o);var t=k.getBucket(c),n=(t.restartedTimes!==g?g=t.restartedTimes+1:g+=1,Math.pow(2,g-1)*t.restartTime);consoleLog("".concat(c," ▶ REBOOT WAITING"),"◔ ".concat(now()," ▶ ").concat(c," RESTART IN ").concat(Math.round(n/1e3)," SECONDS"),"#ffffff","#00c8b4"),setTimeout(function(){t.restartedTimes=g,k.create(t)},n)},"function"==typeof r&&(o=setInterval(function(){r(function(e){k.sendMessage(e,c)})},s)),t={name:c,client:t,url:n,heartbeat:r,heartRate:s,heartRateTimer:o,restartTime:i,restartTimes:u,restartedTimes:g,receive:f,send:e,receiveMessageCallbacks:new Map},k.getInstance().buckets.set(c,t),k.getBucketClient(c);throw new Error("传入的url必须是ws或wss地址")},k.getBucket=function(e){e=k.getBucketName(e);if(!k.getInstance().buckets.has(e))throw new Exception("名称为".concat(e,"是WebSocket实例不存在"),k.NO_BUCKET);var t=k.getInstance().buckets.get(e);if(t&&t.client instanceof WebSocket)return t;throw new Exception("名称为".concat(e,"是WebSocket实例不存在"),k.NO_BUCKET_CLIENT)},k.setBucketKeyValue=function(e,t,n){var c=k.getBucket(n);if(!c||"object"!=typeof c||!Reflect.has(c,e))throw new Exception("名称为".concat(k.getBucketName(n),"的WebSocket Bucket不存在").concat(e,"属性"),k.NO_BUCKET_KEY);c[e]=t,k.getInstance().buckets.set(n,c)},k.getBucketClient=function(e){try{return k.getBucket(e).client}catch(e){console.log("Exception",e)}},k.getBucketName=function(e){return e||k.getInstance().bucketName},k.getBucketClientState=function(e){try{switch(k.getBucketClient(e).readyState){case WebSocket.CONNECTING:return WebSocketBucketState.CONNECTING;case WebSocket.OPEN:return WebSocketBucketState.OPEN;case WebSocket.CLOSING:return WebSocketBucketState.CLOSING;case WebSocket.CLOSED:return WebSocketBucketState.CLOSED;default:return WebSocketBucketState.FAIL}}catch(e){return WebSocketBucketState.FAIL}},k.wsErrorEventListener=function(t,e){void 0===e&&(e=void 0);try{k.getBucketClient(e).onerror=function(e){"function"==typeof t?t(e):console.warn("监听ws报错的回调函数wsError不存在")}}catch(e){console.warn("".concat(e))}},k.wsCloseEventListener=function(t,e){void 0===e&&(e=void 0);try{k.getBucketClient(e).onclose=function(e){"function"==typeof t?t(e):console.warn("监听ws关闭的回调函数wsClose不存在")}}catch(e){console.warn("".concat(e))}},k.wsOpenEventListener=function(t,e){void 0===e&&(e=void 0);try{k.getBucketClient(e).onopen=function(e){"function"==typeof t?t(e):console.warn("wsOpenEventListener缺少回调函数")}}catch(e){console.warn("".concat(e))}},k.sendMessage=function(e,t,n){if(void 0===e&&(e=""),void 0===n&&(n=!1),["CONNECTING","CLOSING","CLOSED"].includes(k.getBucketClientState(t=void 0===t?void 0:t)))n||console.warn("BUCKET:".concat(k.getBucketName(t),"|STATUS:").concat(k.getBucketClientState(t),"|无法进行消息发送"));else try{var c=k.getBucket(t).send;"function"==typeof c&&(e=c(e)),k.getBucketClient(t).send(e)}catch(e){console.warn("".concat(e))}},k.bindMessage=function(e){0<k.getBucket(e).receiveMessageCallbacks.size&&k.registerOnMessage(e)},k.receiveMessage=function(e,t){try{var n;"function"==typeof e?(n="".concat(e),k.getBucket(t).receiveMessageCallbacks.get(n)||k.getBucket(t).receiveMessageCallbacks.set(n,e)):console.warn("receiveMessage缺少回调"),k.registerOnMessage(t)}catch(e){console.warn("".concat(e))}},k.registerOnMessage=function(n){k.getBucketClient(n).onmessage=function(t){var e=k.getBucket(n).receive;"function"==typeof e&&(t=e(t,function(e){k.sendMessage(e,n)})),k.getBucket(n).receiveMessageCallbacks.forEach(function(e){try{e(t)}catch(e){console.warn("".concat(e))}})}},k.getInstance=function(){var e=k.instance;return e=e&&e instanceof k?e:k.instance=new k},k.NO_BUCKET="10001",k.NO_BUCKET_CLIENT="10002",k.NO_BUCKET_KEY="10003",k.DEFAULT_NAME="DEFAULT_BUCKET",k}());export{WebSocketBucket,jsonStringify2Parse};
|
2
|
-
//# sourceMappingURL=client.io.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"client.io.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Exception Class
|
3
|
-
* throw diy Exception
|
4
|
-
* https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error
|
5
|
-
* 目前原生的错误类型
|
6
|
-
* Error [一般错误类型]
|
7
|
-
* SyntaxError [语法错误]
|
8
|
-
* ReferenceError [不存在的变量]
|
9
|
-
* RangeError [超出有效范围]
|
10
|
-
* TypeError [非预期类型]
|
11
|
-
* URIError [URI参数错误]
|
12
|
-
* EvalError [eval函数没有正确执行]
|
13
|
-
* example:: throw new Exception() catch(error) error.message,error.name,error.code,error.stack
|
14
|
-
* NewException extends Exception diy yourself Exception;
|
15
|
-
*/
|
16
|
-
export declare class Exception extends Error {
|
17
|
-
name: string;
|
18
|
-
message: string;
|
19
|
-
/**
|
20
|
-
* Error constructor
|
21
|
-
* @param {String} name 自定义错误名称
|
22
|
-
* @param {String|Number} message 自定义错误提示
|
23
|
-
*/
|
24
|
-
constructor(name?: string, message?: string);
|
25
|
-
}
|
package/framework/es/index.d.ts
DELETED
package/framework/es/types.d.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
export declare type WebSocketUrl = `ws://${string}` | `wss://${string}`;
|
2
|
-
export declare type Heartbeat = (callback: HeartbeatCallback) => void;
|
3
|
-
export declare type HeartbeatCallback = (msg: string) => void;
|
4
|
-
export declare type ReceiveInterceptor = (event: MessageEvent<any>, send: (msg: SendMsg) => void) => any;
|
5
|
-
export declare type SendInterceptor = (event: any) => any;
|
6
|
-
export declare type WebSocketBucketCreate = {
|
7
|
-
url: WebSocketUrl;
|
8
|
-
name?: string;
|
9
|
-
heartbeat?: Heartbeat;
|
10
|
-
heartRate?: Millisecond;
|
11
|
-
restartTime?: Millisecond;
|
12
|
-
restartTimes?: number;
|
13
|
-
restartedTimes?: number;
|
14
|
-
receive?: ReceiveInterceptor;
|
15
|
-
send?: SendInterceptor;
|
16
|
-
};
|
17
|
-
export declare type WebSocketBucketOptions = {
|
18
|
-
name: string;
|
19
|
-
client: WebSocket;
|
20
|
-
url: WebSocketUrl;
|
21
|
-
heartbeat?: Heartbeat;
|
22
|
-
heartRate: Millisecond;
|
23
|
-
heartRateTimer: number;
|
24
|
-
restartTime: Millisecond;
|
25
|
-
restartTimes: number;
|
26
|
-
restartedTimes: number;
|
27
|
-
receive?: ReceiveInterceptor;
|
28
|
-
send?: SendInterceptor;
|
29
|
-
receiveMessageCallbacks: Map<string, (event: MessageEvent<any>) => void>;
|
30
|
-
[key: string]: unknown;
|
31
|
-
};
|
32
|
-
export declare type Millisecond = number;
|
33
|
-
export declare type SendMsg = string | ArrayBufferLike | Blob | ArrayBufferView;
|
package/framework/es/util.d.ts
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
export declare function isArray(obj: any): obj is any[];
|
2
|
-
export declare function isNull(obj: any): obj is null;
|
3
|
-
export declare function isBoolean(obj: unknown): obj is boolean;
|
4
|
-
export declare function isObject(obj: any): obj is Record<string, unknown>;
|
5
|
-
export declare const isPromise: <T>(obj: unknown) => obj is Promise<T>;
|
6
|
-
export declare function isString(obj: any): obj is string;
|
7
|
-
export declare function isNumber(obj: any): obj is number;
|
8
|
-
export declare function isRegExp(obj: any): boolean;
|
9
|
-
export declare function isDate(obj: any): boolean;
|
10
|
-
export declare function isColor(color: any): boolean;
|
11
|
-
export declare function isUndefined(obj: any): obj is undefined;
|
12
|
-
export declare function isFunction(obj: any): obj is (...args: any[]) => any;
|
13
|
-
export declare function isClass(value: unknown): boolean;
|
14
|
-
export declare function isEmptyObject(obj: any): boolean;
|
15
|
-
export declare function isEmpty(obj: any): boolean;
|
16
|
-
export declare function isExist(obj: any): boolean;
|
17
|
-
export declare function isWindow(el: any): el is Window;
|
18
|
-
/**
|
19
|
-
* 控制台消息打印
|
20
|
-
* @param name
|
21
|
-
* @param message
|
22
|
-
* @param color
|
23
|
-
* @param bgColor
|
24
|
-
*/
|
25
|
-
export declare function consoleLog(name: string, message: string, color: string, bgColor: string): void;
|
26
|
-
/**
|
27
|
-
* 当前时间
|
28
|
-
* @description 用于控制台打印使用
|
29
|
-
*/
|
30
|
-
export declare function now(): string;
|
31
|
-
/**
|
32
|
-
* jsonStringify2Parse
|
33
|
-
* @param value
|
34
|
-
* @description 将JSON字符串转换为JSON对象
|
35
|
-
*/
|
36
|
-
export declare function jsonStringify2Parse(value: unknown): any;
|
@@ -1,118 +0,0 @@
|
|
1
|
-
import { SendMsg, WebSocketBucketCreate, WebSocketBucketOptions } from './types';
|
2
|
-
declare enum WebSocketBucketState {
|
3
|
-
CONNECTING = "CONNECTING",
|
4
|
-
OPEN = "OPEN",
|
5
|
-
CLOSING = "CLOSING",
|
6
|
-
CLOSED = "CLOSED",
|
7
|
-
FAIL = "FAIL"
|
8
|
-
}
|
9
|
-
/**
|
10
|
-
* @class WebSocketBucket
|
11
|
-
* @public
|
12
|
-
* @classdesc WebSocket快速部署开发,可同开多个WebSocket,并分别命名,可对多个Client进行监听,每一个Bucket为Client运行所必需的空间环境。
|
13
|
-
* @example
|
14
|
-
* WebSocketBucket.create({url:'wss://ws.demo.com/socket-io'})
|
15
|
-
* WebSocketBucket.sendMessage('Hello World')
|
16
|
-
*/
|
17
|
-
export declare class WebSocketBucket {
|
18
|
-
static NO_BUCKET: string;
|
19
|
-
static NO_BUCKET_CLIENT: string;
|
20
|
-
static NO_BUCKET_KEY: string;
|
21
|
-
static DEFAULT_NAME: string;
|
22
|
-
client: WebSocket | undefined;
|
23
|
-
buckets: Map<string, WebSocketBucketOptions>;
|
24
|
-
bucketName: string;
|
25
|
-
static instance: WebSocketBucket;
|
26
|
-
constructor();
|
27
|
-
/**
|
28
|
-
* create
|
29
|
-
* 创建一个Bucket空间
|
30
|
-
* @param url {string} 服务地址(SSL)
|
31
|
-
* @param name {string} 实例名称
|
32
|
-
* @param heartbeat {function} (sendMessage,instanceName)=>void 心跳执行函数 send {Function} 消息发送函数
|
33
|
-
* @param heartRate 心跳频率 毫秒
|
34
|
-
* @param restartTime 重启时间,按照通用方式,例如第一次3秒后重连如果没连上第二次就3*2=6秒后重连,如果还没有连上第三次就是3*2*2=12秒后重连,以此类推直到重连上为止,一旦重连上重连等待时间就会自动回到3秒这个初始值
|
35
|
-
* @param restartTimes 重启次数,0为不限制,>0为最大重启次数
|
36
|
-
* @param restartedTimes 已重启次数
|
37
|
-
* @param receive 接收拦截器
|
38
|
-
* @param send 发送拦截器
|
39
|
-
*/
|
40
|
-
static create({ url, name, heartbeat, heartRate, restartTime, restartTimes, restartedTimes, receive, send, }: WebSocketBucketCreate): WebSocket | undefined;
|
41
|
-
/**
|
42
|
-
* readBucket
|
43
|
-
* 读取Bucket空间
|
44
|
-
* @param name
|
45
|
-
* @return WebSocketBucketOptions
|
46
|
-
*/
|
47
|
-
static getBucket(name: string | undefined): WebSocketBucketOptions;
|
48
|
-
/**
|
49
|
-
* setBucketKeyValue
|
50
|
-
* 设置Bucket属性值
|
51
|
-
* @param key
|
52
|
-
* @param value
|
53
|
-
* @param name
|
54
|
-
*/
|
55
|
-
static setBucketKeyValue(key: string, value: number, name: string): void;
|
56
|
-
/**
|
57
|
-
* 获取Bucket客户端
|
58
|
-
* @param name
|
59
|
-
*/
|
60
|
-
static getBucketClient(name: string | undefined): WebSocket | undefined;
|
61
|
-
/**
|
62
|
-
* 获取Bucket空间名称
|
63
|
-
* @param name
|
64
|
-
*/
|
65
|
-
static getBucketName(name: string | undefined): string;
|
66
|
-
/**
|
67
|
-
* 获取Bucket客户端状态
|
68
|
-
* @param name
|
69
|
-
*/
|
70
|
-
static getBucketClientState(name: string | undefined): WebSocketBucketState;
|
71
|
-
/**
|
72
|
-
* 监听WebSocket报错
|
73
|
-
* @param callback
|
74
|
-
* @param name
|
75
|
-
*/
|
76
|
-
static wsErrorEventListener(callback: (event: Event) => void, name?: undefined): void;
|
77
|
-
/**
|
78
|
-
* 监听WebSocket关闭
|
79
|
-
* @param callback
|
80
|
-
* @param name
|
81
|
-
*/
|
82
|
-
static wsCloseEventListener(callback: (event: CloseEvent) => void, name?: undefined): void;
|
83
|
-
/**
|
84
|
-
* 监听WebSocket打开
|
85
|
-
* @param callback
|
86
|
-
* @param name
|
87
|
-
*/
|
88
|
-
static wsOpenEventListener(callback: (event: Event) => void, name?: undefined): void;
|
89
|
-
/**
|
90
|
-
* 发送消息
|
91
|
-
* @param msg 消息
|
92
|
-
* @param name Bucket名称
|
93
|
-
* @param isCloseWarn 是否关闭警告
|
94
|
-
*/
|
95
|
-
static sendMessage(msg?: SendMsg, name?: string | undefined, isCloseWarn?: boolean): void;
|
96
|
-
/**
|
97
|
-
* 绑定消息
|
98
|
-
* @param name
|
99
|
-
*/
|
100
|
-
static bindMessage(name: string | undefined): void;
|
101
|
-
/**
|
102
|
-
* 接收消息
|
103
|
-
* @param callback 接收消息的回调函数
|
104
|
-
* @param name Bucket名称
|
105
|
-
*/
|
106
|
-
static receiveMessage(callback: (event: MessageEvent<any>) => void, name?: string): void;
|
107
|
-
/**
|
108
|
-
* 注册消息接收事件
|
109
|
-
* @param name
|
110
|
-
*/
|
111
|
-
static registerOnMessage(name?: string): void;
|
112
|
-
/**
|
113
|
-
* 获取单例实例
|
114
|
-
* @description 采用单例方式有利于减少内存占用
|
115
|
-
*/
|
116
|
-
static getInstance(): WebSocketBucket;
|
117
|
-
}
|
118
|
-
export {};
|
@@ -1,2 +0,0 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Transform={})}(this,function(e){"use strict";function g(e,t,n,c){console.log("".concat("\n"," %c ").concat(e," %c ").concat(t," ").concat("\n"),"color: ".concat(n,"; background: ").concat(c,"; padding:5px 0;border-radius:3px 0 0 3px;"),"color:#666666;background: #f1f5fa; padding:5px 0;border-radius:0 3px 3px 0;")}function d(){return"".concat((new Date).getHours()<10?"0"+(new Date).getHours():(new Date).getHours(),":").concat((new Date).getMinutes()<10?"0"+(new Date).getMinutes():(new Date).getMinutes(),":").concat((new Date).getSeconds()<10?"0"+(new Date).getSeconds():(new Date).getSeconds())}var r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};var t,o=function(c){var e=o,t=c;if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}function o(e,t){var n=c.call(this,t)||this;return n.name="Client.io Error",n.message="Error message",n.name=e||n.name,n.message=t||n.message,n.stack=(new Error).stack,n}return r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n),o}(Error),n=((n=t=t||{}).CONNECTING="CONNECTING",n.OPEN="OPEN",n.CLOSING="CLOSING",n.CLOSED="CLOSED",n.FAIL="FAIL",k.create=function(e){var c,o,t,n=e.url,r=e.name,a=e.heartbeat,s=e.heartRate,s=void 0===s?3e3:s,i=e.restartTime,i=void 0===i?5e3:i,u=e.restartTimes,u=void 0===u?0:u,f=e.restartedTimes,l=void 0===f?0:f,f=e.receive,e=e.send;if(/(ws|wss):\/\/\s*/.test(n))return c=r||k.getBucketName(r),t=new WebSocket(n),o=-1,t.onopen=function(e){g("".concat(c," ▶ SUCCESS"),"◔ ".concat(d()),"#ffffff","#1bc800"),k.setBucketKeyValue("restartedTimes",0,c),k.bindMessage(r)},t.onerror=function(e){g("".concat(c," ▶ ERROR"),"◔ ".concat(d()," ▶ ").concat(c),"#ffffff","#c80000")},t.onclose=function(e){g("".concat(c," ▶ CLOSE"),"◔ ".concat(d()," ▶ ").concat(c),"#ffffff","#000000"),clearInterval(o);var t=k.getBucket(c),n=(t.restartedTimes!==l?l=t.restartedTimes+1:l+=1,Math.pow(2,l-1)*t.restartTime);g("".concat(c," ▶ REBOOT WAITING"),"◔ ".concat(d()," ▶ ").concat(c," RESTART IN ").concat(Math.round(n/1e3)," SECONDS"),"#ffffff","#00c8b4"),setTimeout(function(){t.restartedTimes=l,k.create(t)},n)},"function"==typeof a&&(o=setInterval(function(){a(function(e){k.sendMessage(e,c)})},s)),t={name:c,client:t,url:n,heartbeat:a,heartRate:s,heartRateTimer:o,restartTime:i,restartTimes:u,restartedTimes:l,receive:f,send:e,receiveMessageCallbacks:new Map},k.getInstance().buckets.set(c,t),k.getBucketClient(c);throw new Error("传入的url必须是ws或wss地址")},k.getBucket=function(e){e=k.getBucketName(e);if(!k.getInstance().buckets.has(e))throw new o("名称为".concat(e,"是WebSocket实例不存在"),k.NO_BUCKET);var t=k.getInstance().buckets.get(e);if(t&&t.client instanceof WebSocket)return t;throw new o("名称为".concat(e,"是WebSocket实例不存在"),k.NO_BUCKET_CLIENT)},k.setBucketKeyValue=function(e,t,n){var c=k.getBucket(n);if(!c||"object"!=typeof c||!Reflect.has(c,e))throw new o("名称为".concat(k.getBucketName(n),"的WebSocket Bucket不存在").concat(e,"属性"),k.NO_BUCKET_KEY);c[e]=t,k.getInstance().buckets.set(n,c)},k.getBucketClient=function(e){try{return k.getBucket(e).client}catch(e){console.log("Exception",e)}},k.getBucketName=function(e){return e||k.getInstance().bucketName},k.getBucketClientState=function(e){try{switch(k.getBucketClient(e).readyState){case WebSocket.CONNECTING:return t.CONNECTING;case WebSocket.OPEN:return t.OPEN;case WebSocket.CLOSING:return t.CLOSING;case WebSocket.CLOSED:return t.CLOSED;default:return t.FAIL}}catch(e){return t.FAIL}},k.wsErrorEventListener=function(t,e){void 0===e&&(e=void 0);try{k.getBucketClient(e).onerror=function(e){"function"==typeof t?t(e):console.warn("监听ws报错的回调函数wsError不存在")}}catch(e){console.warn("".concat(e))}},k.wsCloseEventListener=function(t,e){void 0===e&&(e=void 0);try{k.getBucketClient(e).onclose=function(e){"function"==typeof t?t(e):console.warn("监听ws关闭的回调函数wsClose不存在")}}catch(e){console.warn("".concat(e))}},k.wsOpenEventListener=function(t,e){void 0===e&&(e=void 0);try{k.getBucketClient(e).onopen=function(e){"function"==typeof t?t(e):console.warn("wsOpenEventListener缺少回调函数")}}catch(e){console.warn("".concat(e))}},k.sendMessage=function(e,t,n){if(void 0===e&&(e=""),void 0===n&&(n=!1),["CONNECTING","CLOSING","CLOSED"].includes(k.getBucketClientState(t=void 0===t?void 0:t)))n||console.warn("BUCKET:".concat(k.getBucketName(t),"|STATUS:").concat(k.getBucketClientState(t),"|无法进行消息发送"));else try{var c=k.getBucket(t).send;"function"==typeof c&&(e=c(e)),k.getBucketClient(t).send(e)}catch(e){console.warn("".concat(e))}},k.bindMessage=function(e){0<k.getBucket(e).receiveMessageCallbacks.size&&k.registerOnMessage(e)},k.receiveMessage=function(e,t){try{var n;"function"==typeof e?(n="".concat(e),k.getBucket(t).receiveMessageCallbacks.get(n)||k.getBucket(t).receiveMessageCallbacks.set(n,e)):console.warn("receiveMessage缺少回调"),k.registerOnMessage(t)}catch(e){console.warn("".concat(e))}},k.registerOnMessage=function(n){k.getBucketClient(n).onmessage=function(t){var e=k.getBucket(n).receive;"function"==typeof e&&(t=e(t,function(e){k.sendMessage(e,n)})),k.getBucket(n).receiveMessageCallbacks.forEach(function(e){try{e(t)}catch(e){console.warn("".concat(e))}})}},k.getInstance=function(){var e=k.instance;return e=e&&e instanceof k?e:k.instance=new k},k.NO_BUCKET="10001",k.NO_BUCKET_CLIENT="10002",k.NO_BUCKET_KEY="10003",k.DEFAULT_NAME="DEFAULT_BUCKET",k);function k(){this.bucketName=k.DEFAULT_NAME,this.buckets=new Map,this.bucketName=k.DEFAULT_NAME}e.WebSocketBucket=n,e.jsonStringify2Parse=function(t){if("string"==typeof t)try{return JSON.parse(t)}catch(e){return JSON.parse(JSON.stringify('{"value":'.concat(t)))}return{}},Object.defineProperty(e,"__esModule",{value:!0})});
|
2
|
-
//# sourceMappingURL=client.io.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"client.io.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
@@ -1,25 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Exception Class
|
3
|
-
* throw diy Exception
|
4
|
-
* https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Error
|
5
|
-
* 目前原生的错误类型
|
6
|
-
* Error [一般错误类型]
|
7
|
-
* SyntaxError [语法错误]
|
8
|
-
* ReferenceError [不存在的变量]
|
9
|
-
* RangeError [超出有效范围]
|
10
|
-
* TypeError [非预期类型]
|
11
|
-
* URIError [URI参数错误]
|
12
|
-
* EvalError [eval函数没有正确执行]
|
13
|
-
* example:: throw new Exception() catch(error) error.message,error.name,error.code,error.stack
|
14
|
-
* NewException extends Exception diy yourself Exception;
|
15
|
-
*/
|
16
|
-
export declare class Exception extends Error {
|
17
|
-
name: string;
|
18
|
-
message: string;
|
19
|
-
/**
|
20
|
-
* Error constructor
|
21
|
-
* @param {String} name 自定义错误名称
|
22
|
-
* @param {String|Number} message 自定义错误提示
|
23
|
-
*/
|
24
|
-
constructor(name?: string, message?: string);
|
25
|
-
}
|
package/framework/umd/index.d.ts
DELETED
package/framework/umd/types.d.ts
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
export declare type WebSocketUrl = `ws://${string}` | `wss://${string}`;
|
2
|
-
export declare type Heartbeat = (callback: HeartbeatCallback) => void;
|
3
|
-
export declare type HeartbeatCallback = (msg: string) => void;
|
4
|
-
export declare type ReceiveInterceptor = (event: MessageEvent<any>, send: (msg: SendMsg) => void) => any;
|
5
|
-
export declare type SendInterceptor = (event: any) => any;
|
6
|
-
export declare type WebSocketBucketCreate = {
|
7
|
-
url: WebSocketUrl;
|
8
|
-
name?: string;
|
9
|
-
heartbeat?: Heartbeat;
|
10
|
-
heartRate?: Millisecond;
|
11
|
-
restartTime?: Millisecond;
|
12
|
-
restartTimes?: number;
|
13
|
-
restartedTimes?: number;
|
14
|
-
receive?: ReceiveInterceptor;
|
15
|
-
send?: SendInterceptor;
|
16
|
-
};
|
17
|
-
export declare type WebSocketBucketOptions = {
|
18
|
-
name: string;
|
19
|
-
client: WebSocket;
|
20
|
-
url: WebSocketUrl;
|
21
|
-
heartbeat?: Heartbeat;
|
22
|
-
heartRate: Millisecond;
|
23
|
-
heartRateTimer: number;
|
24
|
-
restartTime: Millisecond;
|
25
|
-
restartTimes: number;
|
26
|
-
restartedTimes: number;
|
27
|
-
receive?: ReceiveInterceptor;
|
28
|
-
send?: SendInterceptor;
|
29
|
-
receiveMessageCallbacks: Map<string, (event: MessageEvent<any>) => void>;
|
30
|
-
[key: string]: unknown;
|
31
|
-
};
|
32
|
-
export declare type Millisecond = number;
|
33
|
-
export declare type SendMsg = string | ArrayBufferLike | Blob | ArrayBufferView;
|
package/framework/umd/util.d.ts
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
export declare function isArray(obj: any): obj is any[];
|
2
|
-
export declare function isNull(obj: any): obj is null;
|
3
|
-
export declare function isBoolean(obj: unknown): obj is boolean;
|
4
|
-
export declare function isObject(obj: any): obj is Record<string, unknown>;
|
5
|
-
export declare const isPromise: <T>(obj: unknown) => obj is Promise<T>;
|
6
|
-
export declare function isString(obj: any): obj is string;
|
7
|
-
export declare function isNumber(obj: any): obj is number;
|
8
|
-
export declare function isRegExp(obj: any): boolean;
|
9
|
-
export declare function isDate(obj: any): boolean;
|
10
|
-
export declare function isColor(color: any): boolean;
|
11
|
-
export declare function isUndefined(obj: any): obj is undefined;
|
12
|
-
export declare function isFunction(obj: any): obj is (...args: any[]) => any;
|
13
|
-
export declare function isClass(value: unknown): boolean;
|
14
|
-
export declare function isEmptyObject(obj: any): boolean;
|
15
|
-
export declare function isEmpty(obj: any): boolean;
|
16
|
-
export declare function isExist(obj: any): boolean;
|
17
|
-
export declare function isWindow(el: any): el is Window;
|
18
|
-
/**
|
19
|
-
* 控制台消息打印
|
20
|
-
* @param name
|
21
|
-
* @param message
|
22
|
-
* @param color
|
23
|
-
* @param bgColor
|
24
|
-
*/
|
25
|
-
export declare function consoleLog(name: string, message: string, color: string, bgColor: string): void;
|
26
|
-
/**
|
27
|
-
* 当前时间
|
28
|
-
* @description 用于控制台打印使用
|
29
|
-
*/
|
30
|
-
export declare function now(): string;
|
31
|
-
/**
|
32
|
-
* jsonStringify2Parse
|
33
|
-
* @param value
|
34
|
-
* @description 将JSON字符串转换为JSON对象
|
35
|
-
*/
|
36
|
-
export declare function jsonStringify2Parse(value: unknown): any;
|