vue-mount-plugin 1.1.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -18
- package/dist/es5/index.cjs +66 -0
- package/dist/es5/index.d.ts +42 -0
- package/dist/es5/index.iife.js +1046 -0
- package/dist/es5/index.iife.min.js +7 -0
- package/dist/es5/index.mjs +64 -0
- package/dist/index.cjs +22 -28
- package/dist/index.d.ts +1 -1
- package/dist/index.iife.js +72 -0
- package/dist/index.iife.min.js +7 -0
- package/dist/index.mjs +22 -28
- package/package.json +38 -27
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* vue-mount-plugin v2.1.0
|
|
3
|
+
* A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
4
|
+
* (c) 2021-2023 saqqdy <saqqdy@qq.com>
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
this.VueMount=function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=function(t){return t&&t.Math==Math&&t},r=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof e&&e)||function(){return this}()||Function("return this")(),o={},i=function(t){try{return!!t()}catch(t){return!0}},u=!i((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),c=!i((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),a=c,f=Function.prototype.call,s=a?f.bind(f):function(){return f.apply(f,arguments)},l={},p={}.propertyIsEnumerable,y=Object.getOwnPropertyDescriptor,b=y&&!p.call({1:2},1);l.f=b?function(t){var e=y(this,t);return!!e&&e.enumerable}:p;var h,g,d=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},v=c,m=Function.prototype,O=m.call,S=v&&m.bind.bind(O,O),w=v?S:function(t){return function(){return O.apply(t,arguments)}},j=w,P=j({}.toString),E=j("".slice),M=i,N=function(t){return E(P(t),8,-1)},T=Object,x=w("".split),C=M((function(){return!T("z").propertyIsEnumerable(0)}))?function(t){return"String"==N(t)?x(t,""):T(t)}:T,D=function(t){return null==t},I=D,k=TypeError,F=function(t){if(I(t))throw k("Can't call method on "+t);return t},L=C,_=F,V=function(t){return L(_(t))},A="object"==typeof document&&document.all,z={all:A,IS_HTMLDDA:void 0===A&&void 0!==A},R=z.all,$=z.IS_HTMLDDA?function(t){return"function"==typeof t||t===R}:function(t){return"function"==typeof t},q=$,B=z.all,G=z.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:q(t)||t===B}:function(t){return"object"==typeof t?null!==t:q(t)},H=r,W=$,U=function(t){return W(t)?t:void 0},K=function(t,e){return arguments.length<2?U(H[t]):H[t]&&H[t][e]},X=w({}.isPrototypeOf),Y=r,J="undefined"!=typeof navigator&&String(navigator.userAgent)||"",Q=Y.process,Z=Y.Deno,tt=Q&&Q.versions||Z&&Z.version,et=tt&&tt.v8;et&&(g=(h=et.split("."))[0]>0&&h[0]<4?1:+(h[0]+h[1])),!g&&J&&(!(h=J.match(/Edge\/(\d+)/))||h[1]>=74)&&(h=J.match(/Chrome\/(\d+)/))&&(g=+h[1]);var nt=g,rt=i,ot=!!Object.getOwnPropertySymbols&&!rt((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&nt&&nt<41})),it=ot&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,ut=K,ct=$,at=X,ft=Object,st=it?function(t){return"symbol"==typeof t}:function(t){var e=ut("Symbol");return ct(e)&&at(e.prototype,ft(t))},lt=String,pt=$,yt=function(t){try{return lt(t)}catch(t){return"Object"}},bt=TypeError,ht=function(t){if(pt(t))return t;throw bt(yt(t)+" is not a function")},gt=D,dt=s,vt=$,mt=G,Ot=TypeError,St={},wt={get exports(){return St},set exports(t){St=t}},jt=r,Pt=Object.defineProperty,Et=function(t,e){try{Pt(jt,t,{value:e,configurable:!0,writable:!0})}catch(n){jt[t]=e}return e},Mt=Et,Nt="__core-js_shared__",Tt=r[Nt]||Mt(Nt,{}),xt=Tt;(wt.exports=function(t,e){return xt[t]||(xt[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.29.1",mode:"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.29.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Ct=F,Dt=Object,It=function(t){return Dt(Ct(t))},kt=It,Ft=w({}.hasOwnProperty),Lt=Object.hasOwn||function(t,e){return Ft(kt(t),e)},_t=w,Vt=0,At=Math.random(),zt=_t(1..toString),Rt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+zt(++Vt+At,36)},$t=St,qt=Lt,Bt=Rt,Gt=ot,Ht=it,Wt=r.Symbol,Ut=$t("wks"),Kt=Ht?Wt.for||Wt:Wt&&Wt.withoutSetter||Bt,Xt=s,Yt=G,Jt=st,Qt=function(t,e){var n=t[e];return gt(n)?void 0:ht(n)},Zt=function(t,e){var n,r;if("string"===e&&vt(n=t.toString)&&!mt(r=dt(n,t)))return r;if(vt(n=t.valueOf)&&!mt(r=dt(n,t)))return r;if("string"!==e&&vt(n=t.toString)&&!mt(r=dt(n,t)))return r;throw Ot("Can't convert object to primitive value")},te=TypeError,ee=function(t){return qt(Ut,t)||(Ut[t]=Gt&&qt(Wt,t)?Wt[t]:Kt("Symbol."+t)),Ut[t]}("toPrimitive"),ne=function(t,e){if(!Yt(t)||Jt(t))return t;var n,r=Qt(t,ee);if(r){if(void 0===e&&(e="default"),n=Xt(r,t,e),!Yt(n)||Jt(n))return n;throw te("Can't convert object to primitive value")}return void 0===e&&(e="number"),Zt(t,e)},re=st,oe=function(t){var e=ne(t,"string");return re(e)?e:e+""},ie=G,ue=r.document,ce=ie(ue)&&ie(ue.createElement),ae=function(t){return ce?ue.createElement(t):{}},fe=!u&&!i((function(){return 7!=Object.defineProperty(ae("div"),"a",{get:function(){return 7}}).a})),se=u,le=s,pe=l,ye=d,be=V,he=oe,ge=Lt,de=fe,ve=Object.getOwnPropertyDescriptor;o.f=se?ve:function(t,e){if(t=be(t),e=he(e),de)try{return ve(t,e)}catch(t){}if(ge(t,e))return ye(!le(pe.f,t,e),t[e])};var me={},Oe=u&&i((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Se=G,we=String,je=TypeError,Pe=function(t){if(Se(t))return t;throw je(we(t)+" is not an object")},Ee=u,Me=fe,Ne=Oe,Te=Pe,xe=oe,Ce=TypeError,De=Object.defineProperty,Ie=Object.getOwnPropertyDescriptor,ke="enumerable",Fe="configurable",Le="writable";me.f=Ee?Ne?function(t,e,n){if(Te(t),e=xe(e),Te(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Le in n&&!n[Le]){var r=Ie(t,e);r&&r[Le]&&(t[e]=n.value,n={configurable:Fe in n?n[Fe]:r[Fe],enumerable:ke in n?n[ke]:r[ke],writable:!1})}return De(t,e,n)}:De:function(t,e,n){if(Te(t),e=xe(e),Te(n),Me)try{return De(t,e,n)}catch(t){}if("get"in n||"set"in n)throw Ce("Accessors not supported");return"value"in n&&(t[e]=n.value),t};var _e=me,Ve=d,Ae=u?function(t,e,n){return _e.f(t,e,Ve(1,n))}:function(t,e,n){return t[e]=n,t},ze={},Re={get exports(){return ze},set exports(t){ze=t}},$e=u,qe=Lt,Be=Function.prototype,Ge=$e&&Object.getOwnPropertyDescriptor,He=qe(Be,"name"),We={EXISTS:He,PROPER:He&&"something"===function(){}.name,CONFIGURABLE:He&&(!$e||$e&&Ge(Be,"name").configurable)},Ue=$,Ke=Tt,Xe=w(Function.toString);Ue(Ke.inspectSource)||(Ke.inspectSource=function(t){return Xe(t)});var Ye,Je,Qe,Ze=Ke.inspectSource,tn=$,en=r.WeakMap,nn=tn(en)&&/native code/.test(String(en)),rn=Rt,on=St("keys"),un={},cn=nn,an=r,fn=G,sn=Ae,ln=Lt,pn=Tt,yn=function(t){return on[t]||(on[t]=rn(t))},bn=un,hn="Object already initialized",gn=an.TypeError,dn=an.WeakMap;if(cn||pn.state){var vn=pn.state||(pn.state=new dn);vn.get=vn.get,vn.has=vn.has,vn.set=vn.set,Ye=function(t,e){if(vn.has(t))throw gn(hn);return e.facade=t,vn.set(t,e),e},Je=function(t){return vn.get(t)||{}},Qe=function(t){return vn.has(t)}}else{var mn=yn("state");bn[mn]=!0,Ye=function(t,e){if(ln(t,mn))throw gn(hn);return e.facade=t,sn(t,mn,e),e},Je=function(t){return ln(t,mn)?t[mn]:{}},Qe=function(t){return ln(t,mn)}}var On={set:Ye,get:Je,has:Qe,enforce:function(t){return Qe(t)?Je(t):Ye(t,{})},getterFor:function(t){return function(e){var n;if(!fn(e)||(n=Je(e)).type!==t)throw gn("Incompatible receiver, "+t+" required");return n}}},Sn=w,wn=i,jn=$,Pn=Lt,En=u,Mn=We.CONFIGURABLE,Nn=Ze,Tn=On.enforce,xn=On.get,Cn=String,Dn=Object.defineProperty,In=Sn("".slice),kn=Sn("".replace),Fn=Sn([].join),Ln=En&&!wn((function(){return 8!==Dn((function(){}),"length",{value:8}).length})),_n=String(String).split("String"),Vn=Re.exports=function(t,e,n){"Symbol("===In(Cn(e),0,7)&&(e="["+kn(Cn(e),/^Symbol\(([^)]*)\)/,"$1")+"]"),n&&n.getter&&(e="get "+e),n&&n.setter&&(e="set "+e),(!Pn(t,"name")||Mn&&t.name!==e)&&(En?Dn(t,"name",{value:e,configurable:!0}):t.name=e),Ln&&n&&Pn(n,"arity")&&t.length!==n.arity&&Dn(t,"length",{value:n.arity});try{n&&Pn(n,"constructor")&&n.constructor?En&&Dn(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var r=Tn(t);return Pn(r,"source")||(r.source=Fn(_n,"string"==typeof e?e:"")),t};Function.prototype.toString=Vn((function(){return jn(this)&&xn(this).source||Nn(this)}),"toString");var An=$,zn=me,Rn=ze,$n=Et,qn={},Bn=Math.ceil,Gn=Math.floor,Hn=Math.trunc||function(t){var e=+t;return(e>0?Gn:Bn)(e)},Wn=function(t){var e=+t;return e!=e||0===e?0:Hn(e)},Un=Wn,Kn=Math.max,Xn=Math.min,Yn=Wn,Jn=Math.min,Qn=function(t){return t>0?Jn(Yn(t),9007199254740991):0},Zn=V,tr=function(t,e){var n=Un(t);return n<0?Kn(n+e,0):Xn(n,e)},er=function(t){return Qn(t.length)},nr=function(t){return function(e,n,r){var o,i=Zn(e),u=er(i),c=tr(r,u);if(t&&n!=n){for(;u>c;)if((o=i[c++])!=o)return!0}else for(;u>c;c++)if((t||c in i)&&i[c]===n)return t||c||0;return!t&&-1}},rr={includes:nr(!0),indexOf:nr(!1)},or=Lt,ir=V,ur=rr.indexOf,cr=un,ar=w([].push),fr=function(t,e){var n,r=ir(t),o=0,i=[];for(n in r)!or(cr,n)&&or(r,n)&&ar(i,n);for(;e.length>o;)or(r,n=e[o++])&&(~ur(i,n)||ar(i,n));return i},sr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],lr=fr,pr=sr.concat("length","prototype");qn.f=Object.getOwnPropertyNames||function(t){return lr(t,pr)};var yr={};yr.f=Object.getOwnPropertySymbols;var br=K,hr=qn,gr=yr,dr=Pe,vr=w([].concat),mr=br("Reflect","ownKeys")||function(t){var e=hr.f(dr(t)),n=gr.f;return n?vr(e,n(t)):e},Or=Lt,Sr=mr,wr=o,jr=me,Pr=i,Er=$,Mr=/#|\.prototype\./,Nr=function(t,e){var n=xr[Tr(t)];return n==Dr||n!=Cr&&(Er(e)?Pr(e):!!e)},Tr=Nr.normalize=function(t){return String(t).replace(Mr,".").toLowerCase()},xr=Nr.data={},Cr=Nr.NATIVE="N",Dr=Nr.POLYFILL="P",Ir=Nr,kr=r,Fr=o.f,Lr=Ae,_r=function(t,e,n,r){r||(r={});var o=r.enumerable,i=void 0!==r.name?r.name:e;if(An(n)&&Rn(n,i,r),r.global)o?t[e]=n:$n(e,n);else{try{r.unsafe?t[e]&&(o=!0):delete t[e]}catch(t){}o?t[e]=n:zn.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},Vr=Et,Ar=function(t,e,n){for(var r=Sr(e),o=jr.f,i=wr.f,u=0;u<r.length;u++){var c=r[u];Or(t,c)||n&&Or(n,c)||o(t,c,i(e,c))}},zr=Ir,Rr=fr,$r=sr,qr=Object.keys||function(t){return Rr(t,$r)},Br=u,Gr=w,Hr=s,Wr=i,Ur=qr,Kr=yr,Xr=l,Yr=It,Jr=C,Qr=Object.assign,Zr=Object.defineProperty,to=Gr([].concat),eo=!Qr||Wr((function(){if(Br&&1!==Qr({b:1},Qr(Zr({},"a",{enumerable:!0,get:function(){Zr(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol(),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach((function(t){e[t]=t})),7!=Qr({},t)[n]||Ur(Qr({},e)).join("")!=r}))?function(t,e){for(var n=Yr(t),r=arguments.length,o=1,i=Kr.f,u=Xr.f;r>o;)for(var c,a=Jr(arguments[o++]),f=i?to(Ur(a),i(a)):Ur(a),s=f.length,l=0;s>l;)c=f[l++],Br&&!Hr(u,a,c)||(n[c]=a[c]);return n}:Qr,no=eo;return function(t,e){var n,r,o,i,u,c=t.target,a=t.global,f=t.stat;if(n=a?kr:f?kr[c]||Vr(c,{}):(kr[c]||{}).prototype)for(r in e){if(i=e[r],o=t.dontCallGetSet?(u=Fr(n,r))&&u.value:n[r],!zr(a?r:c+(f?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Ar(i,o)}(t.sham||o&&o.sham)&&Lr(i,"sham",!0),_r(n,r,i,t)}}({target:"Object",stat:!0,arity:2,forced:Object.assign!==no},{assign:no}),function(){function e(t,e){if(void 0===e&&(e={}),this.vNode=null,this.options={},this.seed=1,"undefined"==typeof document)throw new Error("This plugin works in browser");this.options=e,this.target=("string"==typeof e.target?document.querySelector(e.target):e.target)||document.createElement(e.tagName||"div"),this.vNode=this.createVM(t,e)}return e.prototype.createVM=function(e,n){var r,o=void 0===n?{}:n,i=o.props,u=o.children,c=o.patchFlag,a=o.dynamicProps,f=o.isBlockNode,s=o.app,l=o.context,p=o.parent;return t.isVue2?((r=new(t.Vue2.extend(Object.assign({},l||{},e)))({parent:p,propsData:i})).id="mount-plugin-"+this.seed++,r):(r=t.createVNode(e,i,u,c,a,f),(null==s?void 0:s._context)&&(r.appContext=s._context),r)},e.prototype.mount=function(){!this.options.target&&document.body.appendChild(this.target),t.isVue2?this.vNode&&this.vNode.$mount(this.target):t.render(this.vNode,this.target)},e.prototype.unmount=function(){t.isVue2?(this.vNode.$destroy(),document.body.removeChild(this.vNode.$el)):(t.render(null,this.target),document.body.removeChild(this.target)),this.vNode=null,this.target=null},e}()}(VueDemi);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import 'core-js/modules/es.object.assign.js';
|
|
2
|
+
import { isVue2, Vue2, createVNode, render } from 'vue-demi';
|
|
3
|
+
|
|
4
|
+
var Mount = function () {
|
|
5
|
+
function Mount(component, options) {
|
|
6
|
+
if (options === void 0) {
|
|
7
|
+
options = {};
|
|
8
|
+
}
|
|
9
|
+
this.vNode = null;
|
|
10
|
+
this.options = {};
|
|
11
|
+
this.seed = 1;
|
|
12
|
+
if (typeof document === 'undefined') throw new Error('This plugin works in browser');
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
|
|
15
|
+
this.vNode = this.createVM(component, options);
|
|
16
|
+
}
|
|
17
|
+
Mount.prototype.createVM = function (component, _a) {
|
|
18
|
+
var _b = _a === void 0 ? {} : _a,
|
|
19
|
+
props = _b.props,
|
|
20
|
+
children = _b.children,
|
|
21
|
+
patchFlag = _b.patchFlag,
|
|
22
|
+
dynamicProps = _b.dynamicProps,
|
|
23
|
+
isBlockNode = _b.isBlockNode,
|
|
24
|
+
app = _b.app,
|
|
25
|
+
context = _b.context,
|
|
26
|
+
parent = _b.parent;
|
|
27
|
+
var vNode;
|
|
28
|
+
if (isVue2) {
|
|
29
|
+
var VueConstructor = Vue2.extend(Object.assign({}, context || {}, component));
|
|
30
|
+
vNode = new VueConstructor({
|
|
31
|
+
parent: parent,
|
|
32
|
+
propsData: props
|
|
33
|
+
});
|
|
34
|
+
vNode.id = 'mount-plugin-' + this.seed++;
|
|
35
|
+
return vNode;
|
|
36
|
+
} else {
|
|
37
|
+
vNode = createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
|
|
38
|
+
if (app === null || app === void 0 ? void 0 : app._context) vNode.appContext = app._context;
|
|
39
|
+
return vNode;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
Mount.prototype.mount = function () {
|
|
43
|
+
!this.options.target && document.body.appendChild(this.target);
|
|
44
|
+
if (isVue2) {
|
|
45
|
+
this.vNode && this.vNode.$mount(this.target);
|
|
46
|
+
} else {
|
|
47
|
+
render(this.vNode, this.target);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
Mount.prototype.unmount = function () {
|
|
51
|
+
if (isVue2) {
|
|
52
|
+
this.vNode.$destroy();
|
|
53
|
+
document.body.removeChild(this.vNode.$el);
|
|
54
|
+
} else {
|
|
55
|
+
render(null, this.target);
|
|
56
|
+
document.body.removeChild(this.target);
|
|
57
|
+
}
|
|
58
|
+
this.vNode = null;
|
|
59
|
+
this.target = null;
|
|
60
|
+
};
|
|
61
|
+
return Mount;
|
|
62
|
+
}();
|
|
63
|
+
|
|
64
|
+
export { Mount as default };
|
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* vue-mount-plugin v1.1.0
|
|
3
|
-
* A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
4
|
-
* (c) 2021-2023 saqqdy
|
|
5
|
-
* Released under the MIT License.
|
|
6
|
-
*/
|
|
7
1
|
'use strict';
|
|
8
2
|
|
|
9
3
|
var vueDemi = require('vue-demi');
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
var Mount = function () {
|
|
6
|
+
function Mount(component, options) {
|
|
13
7
|
if (options === void 0) {
|
|
14
8
|
options = {};
|
|
15
9
|
}
|
|
@@ -21,22 +15,21 @@ class Mount {
|
|
|
21
15
|
this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
|
|
22
16
|
this.vNode = this.createVM(component, options);
|
|
23
17
|
}
|
|
24
|
-
createVM(component,
|
|
25
|
-
|
|
26
|
-
props,
|
|
27
|
-
children,
|
|
28
|
-
patchFlag,
|
|
29
|
-
dynamicProps,
|
|
30
|
-
isBlockNode,
|
|
31
|
-
app,
|
|
32
|
-
context,
|
|
33
|
-
parent
|
|
34
|
-
|
|
35
|
-
let vNode;
|
|
18
|
+
Mount.prototype.createVM = function (component, _a) {
|
|
19
|
+
var _b = _a === void 0 ? {} : _a,
|
|
20
|
+
props = _b.props,
|
|
21
|
+
children = _b.children,
|
|
22
|
+
patchFlag = _b.patchFlag,
|
|
23
|
+
dynamicProps = _b.dynamicProps,
|
|
24
|
+
isBlockNode = _b.isBlockNode,
|
|
25
|
+
app = _b.app,
|
|
26
|
+
context = _b.context,
|
|
27
|
+
parent = _b.parent;
|
|
28
|
+
var vNode;
|
|
36
29
|
if (vueDemi.isVue2) {
|
|
37
|
-
|
|
30
|
+
var VueConstructor = vueDemi.Vue2.extend(Object.assign({}, context || {}, component));
|
|
38
31
|
vNode = new VueConstructor({
|
|
39
|
-
parent,
|
|
32
|
+
parent: parent,
|
|
40
33
|
propsData: props
|
|
41
34
|
});
|
|
42
35
|
vNode.id = 'mount-plugin-' + this.seed++;
|
|
@@ -46,16 +39,16 @@ class Mount {
|
|
|
46
39
|
if (app === null || app === void 0 ? void 0 : app._context) vNode.appContext = app._context;
|
|
47
40
|
return vNode;
|
|
48
41
|
}
|
|
49
|
-
}
|
|
50
|
-
mount() {
|
|
42
|
+
};
|
|
43
|
+
Mount.prototype.mount = function () {
|
|
51
44
|
!this.options.target && document.body.appendChild(this.target);
|
|
52
45
|
if (vueDemi.isVue2) {
|
|
53
46
|
this.vNode && this.vNode.$mount(this.target);
|
|
54
47
|
} else {
|
|
55
48
|
vueDemi.render(this.vNode, this.target);
|
|
56
49
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
50
|
+
};
|
|
51
|
+
Mount.prototype.unmount = function () {
|
|
59
52
|
if (vueDemi.isVue2) {
|
|
60
53
|
this.vNode.$destroy();
|
|
61
54
|
document.body.removeChild(this.vNode.$el);
|
|
@@ -65,7 +58,8 @@ class Mount {
|
|
|
65
58
|
}
|
|
66
59
|
this.vNode = null;
|
|
67
60
|
this.target = null;
|
|
68
|
-
}
|
|
69
|
-
|
|
61
|
+
};
|
|
62
|
+
return Mount;
|
|
63
|
+
}();
|
|
70
64
|
|
|
71
65
|
module.exports = Mount;
|
package/dist/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ declare class Mount {
|
|
|
18
18
|
constructor(component: Component, options?: Options);
|
|
19
19
|
createVM(component: Component, { props, children, patchFlag, dynamicProps, isBlockNode, app, context, parent }?: Options): any;
|
|
20
20
|
mount(): void;
|
|
21
|
-
|
|
21
|
+
unmount(): void;
|
|
22
22
|
}
|
|
23
23
|
export default Mount;
|
|
24
24
|
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* vue-mount-plugin v2.1.0
|
|
3
|
+
* A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
4
|
+
* (c) 2021-2023 saqqdy <saqqdy@qq.com>
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
this.VueMount = (function (vueDemi) {
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var Mount = function () {
|
|
11
|
+
function Mount(component, options) {
|
|
12
|
+
if (options === void 0) {
|
|
13
|
+
options = {};
|
|
14
|
+
}
|
|
15
|
+
this.vNode = null;
|
|
16
|
+
this.options = {};
|
|
17
|
+
this.seed = 1;
|
|
18
|
+
if (typeof document === 'undefined') throw new Error('This plugin works in browser');
|
|
19
|
+
this.options = options;
|
|
20
|
+
this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
|
|
21
|
+
this.vNode = this.createVM(component, options);
|
|
22
|
+
}
|
|
23
|
+
Mount.prototype.createVM = function (component, _a) {
|
|
24
|
+
var _b = _a === void 0 ? {} : _a,
|
|
25
|
+
props = _b.props,
|
|
26
|
+
children = _b.children,
|
|
27
|
+
patchFlag = _b.patchFlag,
|
|
28
|
+
dynamicProps = _b.dynamicProps,
|
|
29
|
+
isBlockNode = _b.isBlockNode,
|
|
30
|
+
app = _b.app,
|
|
31
|
+
context = _b.context,
|
|
32
|
+
parent = _b.parent;
|
|
33
|
+
var vNode;
|
|
34
|
+
if (vueDemi.isVue2) {
|
|
35
|
+
var VueConstructor = vueDemi.Vue2.extend(Object.assign({}, context || {}, component));
|
|
36
|
+
vNode = new VueConstructor({
|
|
37
|
+
parent: parent,
|
|
38
|
+
propsData: props
|
|
39
|
+
});
|
|
40
|
+
vNode.id = 'mount-plugin-' + this.seed++;
|
|
41
|
+
return vNode;
|
|
42
|
+
} else {
|
|
43
|
+
vNode = vueDemi.createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
|
|
44
|
+
if (app === null || app === void 0 ? void 0 : app._context) vNode.appContext = app._context;
|
|
45
|
+
return vNode;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
Mount.prototype.mount = function () {
|
|
49
|
+
!this.options.target && document.body.appendChild(this.target);
|
|
50
|
+
if (vueDemi.isVue2) {
|
|
51
|
+
this.vNode && this.vNode.$mount(this.target);
|
|
52
|
+
} else {
|
|
53
|
+
vueDemi.render(this.vNode, this.target);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
Mount.prototype.unmount = function () {
|
|
57
|
+
if (vueDemi.isVue2) {
|
|
58
|
+
this.vNode.$destroy();
|
|
59
|
+
document.body.removeChild(this.vNode.$el);
|
|
60
|
+
} else {
|
|
61
|
+
vueDemi.render(null, this.target);
|
|
62
|
+
document.body.removeChild(this.target);
|
|
63
|
+
}
|
|
64
|
+
this.vNode = null;
|
|
65
|
+
this.target = null;
|
|
66
|
+
};
|
|
67
|
+
return Mount;
|
|
68
|
+
}();
|
|
69
|
+
|
|
70
|
+
return Mount;
|
|
71
|
+
|
|
72
|
+
})(VueDemi);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* vue-mount-plugin v2.1.0
|
|
3
|
+
* A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
4
|
+
* (c) 2021-2023 saqqdy <saqqdy@qq.com>
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
this.VueMount=function(t){"use strict";return function(){function e(t,e){if(void 0===e&&(e={}),this.vNode=null,this.options={},this.seed=1,"undefined"==typeof document)throw new Error("This plugin works in browser");this.options=e,this.target=("string"==typeof e.target?document.querySelector(e.target):e.target)||document.createElement(e.tagName||"div"),this.vNode=this.createVM(t,e)}return e.prototype.createVM=function(e,o){var n,i=void 0===o?{}:o,r=i.props,s=i.children,d=i.patchFlag,u=i.dynamicProps,a=i.isBlockNode,h=i.app,p=i.context,c=i.parent;return t.isVue2?((n=new(t.Vue2.extend(Object.assign({},p||{},e)))({parent:c,propsData:r})).id="mount-plugin-"+this.seed++,n):(n=t.createVNode(e,r,s,d,u,a),(null==h?void 0:h._context)&&(n.appContext=h._context),n)},e.prototype.mount=function(){!this.options.target&&document.body.appendChild(this.target),t.isVue2?this.vNode&&this.vNode.$mount(this.target):t.render(this.vNode,this.target)},e.prototype.unmount=function(){t.isVue2?(this.vNode.$destroy(),document.body.removeChild(this.vNode.$el)):(t.render(null,this.target),document.body.removeChild(this.target)),this.vNode=null,this.target=null},e}()}(VueDemi);
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* vue-mount-plugin v1.1.0
|
|
3
|
-
* A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
4
|
-
* (c) 2021-2023 saqqdy
|
|
5
|
-
* Released under the MIT License.
|
|
6
|
-
*/
|
|
7
1
|
import { isVue2, Vue2, createVNode, render } from 'vue-demi';
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
var Mount = function () {
|
|
4
|
+
function Mount(component, options) {
|
|
11
5
|
if (options === void 0) {
|
|
12
6
|
options = {};
|
|
13
7
|
}
|
|
@@ -19,22 +13,21 @@ class Mount {
|
|
|
19
13
|
this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
|
|
20
14
|
this.vNode = this.createVM(component, options);
|
|
21
15
|
}
|
|
22
|
-
createVM(component,
|
|
23
|
-
|
|
24
|
-
props,
|
|
25
|
-
children,
|
|
26
|
-
patchFlag,
|
|
27
|
-
dynamicProps,
|
|
28
|
-
isBlockNode,
|
|
29
|
-
app,
|
|
30
|
-
context,
|
|
31
|
-
parent
|
|
32
|
-
|
|
33
|
-
let vNode;
|
|
16
|
+
Mount.prototype.createVM = function (component, _a) {
|
|
17
|
+
var _b = _a === void 0 ? {} : _a,
|
|
18
|
+
props = _b.props,
|
|
19
|
+
children = _b.children,
|
|
20
|
+
patchFlag = _b.patchFlag,
|
|
21
|
+
dynamicProps = _b.dynamicProps,
|
|
22
|
+
isBlockNode = _b.isBlockNode,
|
|
23
|
+
app = _b.app,
|
|
24
|
+
context = _b.context,
|
|
25
|
+
parent = _b.parent;
|
|
26
|
+
var vNode;
|
|
34
27
|
if (isVue2) {
|
|
35
|
-
|
|
28
|
+
var VueConstructor = Vue2.extend(Object.assign({}, context || {}, component));
|
|
36
29
|
vNode = new VueConstructor({
|
|
37
|
-
parent,
|
|
30
|
+
parent: parent,
|
|
38
31
|
propsData: props
|
|
39
32
|
});
|
|
40
33
|
vNode.id = 'mount-plugin-' + this.seed++;
|
|
@@ -44,16 +37,16 @@ class Mount {
|
|
|
44
37
|
if (app === null || app === void 0 ? void 0 : app._context) vNode.appContext = app._context;
|
|
45
38
|
return vNode;
|
|
46
39
|
}
|
|
47
|
-
}
|
|
48
|
-
mount() {
|
|
40
|
+
};
|
|
41
|
+
Mount.prototype.mount = function () {
|
|
49
42
|
!this.options.target && document.body.appendChild(this.target);
|
|
50
43
|
if (isVue2) {
|
|
51
44
|
this.vNode && this.vNode.$mount(this.target);
|
|
52
45
|
} else {
|
|
53
46
|
render(this.vNode, this.target);
|
|
54
47
|
}
|
|
55
|
-
}
|
|
56
|
-
|
|
48
|
+
};
|
|
49
|
+
Mount.prototype.unmount = function () {
|
|
57
50
|
if (isVue2) {
|
|
58
51
|
this.vNode.$destroy();
|
|
59
52
|
document.body.removeChild(this.vNode.$el);
|
|
@@ -63,7 +56,8 @@ class Mount {
|
|
|
63
56
|
}
|
|
64
57
|
this.vNode = null;
|
|
65
58
|
this.target = null;
|
|
66
|
-
}
|
|
67
|
-
|
|
59
|
+
};
|
|
60
|
+
return Mount;
|
|
61
|
+
}();
|
|
68
62
|
|
|
69
63
|
export { Mount as default };
|
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-mount-plugin",
|
|
3
3
|
"description": "A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "2.1.0",
|
|
5
5
|
"packageManager": "pnpm@7.26.1",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
|
-
"
|
|
8
|
+
"unpkg": "./dist/index.iife.min.js",
|
|
9
|
+
"jsdelivr": "./dist/index.iife.min.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
9
11
|
"exports": {
|
|
10
12
|
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
11
14
|
"require": "./dist/index.cjs",
|
|
12
|
-
"import": "./dist/index.mjs"
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"browser": "./dist/index.mjs"
|
|
13
17
|
},
|
|
14
18
|
"./*": "./*"
|
|
15
19
|
},
|
|
@@ -25,18 +29,19 @@
|
|
|
25
29
|
"src": "src"
|
|
26
30
|
},
|
|
27
31
|
"scripts": {
|
|
28
|
-
"build": "run-s clean build:{bundle,types,docs} roll-types",
|
|
32
|
+
"build": "run-s clean build:{bundle,es5,types,docs} roll-types",
|
|
29
33
|
"build:bundle": "rollup -c build/rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
30
|
-
"build:
|
|
31
|
-
"build:
|
|
32
|
-
"
|
|
34
|
+
"build:es5": "cross-env BABEL_ENV=es5 pnpm build:bundle",
|
|
35
|
+
"build:types": "tsc -p src/tsconfig.declaration.json",
|
|
36
|
+
"build:docs": "rm-all docs && typedoc && prettier --write \"**/*.md\"",
|
|
37
|
+
"roll-types": "api-extractor run && rm-all temp && cp dist/index.d.ts dist/es5",
|
|
33
38
|
"watch": "pnpm build:bundle -w",
|
|
34
39
|
"pub": "tscjs scripts/publish",
|
|
35
40
|
"unpub": "tscjs scripts/unpublish",
|
|
36
41
|
"sync": "tscjs scripts/sync",
|
|
37
42
|
"workflow:publish-test": "zx scripts/workflow.mjs",
|
|
38
|
-
"clean": "
|
|
39
|
-
"dist": "run-s
|
|
43
|
+
"clean": "rm-all dist es lib",
|
|
44
|
+
"dist": "run-s eslint prettier build",
|
|
40
45
|
"test-unit": "jest --filter ./scripts/filter-unit.js",
|
|
41
46
|
"test:2": "vue-demi-switch 2 vue2 && jest",
|
|
42
47
|
"test:3": "vue-demi-switch 3 && jest",
|
|
@@ -46,46 +51,48 @@
|
|
|
46
51
|
"prettier": "prettier --write \"**/*.{js,ts,jsx,tsx,yml,json,md}\""
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"core-js": "^3.
|
|
50
|
-
"js-cool": "^
|
|
54
|
+
"core-js": "^3.29.1",
|
|
55
|
+
"js-cool": "^3.0.0-beta.6",
|
|
51
56
|
"vue-demi": "^0.13.11"
|
|
52
57
|
},
|
|
53
58
|
"devDependencies": {
|
|
54
|
-
"@babel/core": "^7.
|
|
55
|
-
"@babel/preset-env": "^7.
|
|
56
|
-
"@babel/preset-typescript": "^7.
|
|
57
|
-
"@eslint-sets/eslint-config-ts": "^5.0.
|
|
59
|
+
"@babel/core": "^7.21.4",
|
|
60
|
+
"@babel/preset-env": "^7.21.4",
|
|
61
|
+
"@babel/preset-typescript": "^7.21.4",
|
|
62
|
+
"@eslint-sets/eslint-config-ts": "^5.0.2",
|
|
58
63
|
"@microsoft/api-extractor": "^7.34.4",
|
|
59
64
|
"@rollup/plugin-alias": "^4.0.3",
|
|
60
65
|
"@rollup/plugin-babel": "^6.0.3",
|
|
61
66
|
"@rollup/plugin-commonjs": "^24.0.1",
|
|
62
67
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
68
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
63
69
|
"@rollup/plugin-typescript": "^11.0.0",
|
|
64
|
-
"@types/jest": "^29.
|
|
65
|
-
"@types/node": "^18.
|
|
70
|
+
"@types/jest": "^29.5.0",
|
|
71
|
+
"@types/node": "^18.15.11",
|
|
66
72
|
"chalk": "^5.2.0",
|
|
67
73
|
"coveralls": "^3.1.1",
|
|
68
74
|
"cross-env": "^7.0.3",
|
|
69
|
-
"eslint": "^8.
|
|
75
|
+
"eslint": "^8.37.0",
|
|
70
76
|
"fast-glob": "^3.2.12",
|
|
71
|
-
"jest": "^29.
|
|
72
|
-
"load-yml": "^1.
|
|
77
|
+
"jest": "^29.5.0",
|
|
78
|
+
"load-yml": "^1.3.0",
|
|
73
79
|
"npm-run-all": "^4.1.5",
|
|
74
|
-
"prettier": "^2.8.
|
|
80
|
+
"prettier": "^2.8.7",
|
|
75
81
|
"prettier-config-common": "^1.4.0",
|
|
76
82
|
"reinstaller": "^2.3.0",
|
|
77
|
-
"
|
|
78
|
-
"rollup": "^3.
|
|
79
|
-
"rollup-plugin-
|
|
83
|
+
"rm-all": "^1.0.0",
|
|
84
|
+
"rollup": "^3.20.2",
|
|
85
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
86
|
+
"rollup-plugin-filesize": "^10.0.0",
|
|
80
87
|
"rollup-plugin-visualizer": "^5.9.0",
|
|
81
|
-
"ts-jest": "^29.0
|
|
88
|
+
"ts-jest": "^29.1.0",
|
|
82
89
|
"tsnd": "^1.1.0",
|
|
83
|
-
"typedoc": "^0.23.
|
|
90
|
+
"typedoc": "^0.23.28",
|
|
84
91
|
"typedoc-plugin-markdown": "^3.14.0",
|
|
85
92
|
"typescript": "^4.9.5",
|
|
86
93
|
"vue": "^3.2.47",
|
|
87
94
|
"vue2": "npm:vue@^2.7.14",
|
|
88
|
-
"zx": "^7.
|
|
95
|
+
"zx": "^7.2.1"
|
|
89
96
|
},
|
|
90
97
|
"peerDependencies": {
|
|
91
98
|
"@vue/composition-api": ">=1.0.0",
|
|
@@ -98,6 +105,9 @@
|
|
|
98
105
|
"optional": true
|
|
99
106
|
}
|
|
100
107
|
},
|
|
108
|
+
"engines": {
|
|
109
|
+
"node": ">=12.20"
|
|
110
|
+
},
|
|
101
111
|
"pnpm": {
|
|
102
112
|
"peerDependencyRules": {
|
|
103
113
|
"ignoreMissing": [
|
|
@@ -129,6 +139,7 @@
|
|
|
129
139
|
"type": "git",
|
|
130
140
|
"url": "git+https://github.com/saqqdy/vue-mount-plugin.git"
|
|
131
141
|
},
|
|
142
|
+
"funding": "https://github.com/sponsors/saqqdy",
|
|
132
143
|
"publishConfig": {
|
|
133
144
|
"registry": "https://registry.npmjs.org",
|
|
134
145
|
"access": "public"
|