vue-mount-plugin 3.0.0 → 3.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.
@@ -1,65 +1,126 @@
1
1
  /*!
2
- * vue-mount-plugin v3.0.0
2
+ * vue-mount-plugin v3.1.0
3
3
  * A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
4
4
  * (c) 2021-2023 saqqdy <saqqdy@qq.com>
5
5
  * Released under the MIT License.
6
6
  */
7
7
  import { isVue2, Vue2, createVNode, render } from 'vue-demi';
8
8
 
9
- class Mount {
10
- vNode = null;
11
- target;
12
- options = {};
13
- seed = 1;
14
- constructor(component, options = {}) {
15
- if (typeof document === 'undefined')
16
- throw new Error('This plugin works in browser');
17
- this.options = options;
18
- this.target =
19
- (typeof options.target === 'string'
20
- ? document.querySelector(options.target)
21
- : options.target) || document.createElement(options.tagName || 'div');
22
- this.vNode = this.createVM(component, options);
23
- }
24
- createVM(component, { props, children, patchFlag, dynamicProps, isBlockNode, app, context, parent } = {}) {
25
- let vNode;
26
- if (isVue2) {
27
- const VueConstructor = Vue2.extend(Object.assign({}, context || {}, component));
28
- vNode = new VueConstructor({
29
- parent,
30
- propsData: props
31
- });
32
- vNode.id = 'mount-plugin-' + this.seed++;
33
- return vNode;
34
- }
35
- else {
36
- vNode = createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
37
- if (app?._context)
38
- vNode.appContext = app._context;
39
- return vNode;
40
- }
9
+ function _classCallCheck(instance, Constructor) {
10
+ if (!(instance instanceof Constructor)) {
11
+ throw new TypeError("Cannot call a class as a function");
12
+ }
13
+ }
14
+ function _defineProperties(target, props) {
15
+ for (var i = 0; i < props.length; i++) {
16
+ var descriptor = props[i];
17
+ descriptor.enumerable = descriptor.enumerable || false;
18
+ descriptor.configurable = true;
19
+ if ("value" in descriptor) descriptor.writable = true;
20
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
21
+ }
22
+ }
23
+ function _createClass(Constructor, protoProps, staticProps) {
24
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
25
+ if (staticProps) _defineProperties(Constructor, staticProps);
26
+ Object.defineProperty(Constructor, "prototype", {
27
+ writable: false
28
+ });
29
+ return Constructor;
30
+ }
31
+ function _defineProperty(obj, key, value) {
32
+ key = _toPropertyKey(key);
33
+ if (key in obj) {
34
+ Object.defineProperty(obj, key, {
35
+ value: value,
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true
39
+ });
40
+ } else {
41
+ obj[key] = value;
42
+ }
43
+ return obj;
44
+ }
45
+ function _toPrimitive(input, hint) {
46
+ if (typeof input !== "object" || input === null) return input;
47
+ var prim = input[Symbol.toPrimitive];
48
+ if (prim !== undefined) {
49
+ var res = prim.call(input, hint || "default");
50
+ if (typeof res !== "object") return res;
51
+ throw new TypeError("@@toPrimitive must return a primitive value.");
52
+ }
53
+ return (hint === "string" ? String : Number)(input);
54
+ }
55
+ function _toPropertyKey(arg) {
56
+ var key = _toPrimitive(arg, "string");
57
+ return typeof key === "symbol" ? key : String(key);
58
+ }
59
+
60
+ var Mount = /*#__PURE__*/function () {
61
+ function Mount(component) {
62
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
63
+ _classCallCheck(this, Mount);
64
+ _defineProperty(this, "vNode", null);
65
+ _defineProperty(this, "options", {});
66
+ _defineProperty(this, "seed", 1);
67
+ if (typeof document === 'undefined') throw new Error('This plugin works in browser');
68
+ this.options = options;
69
+ this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
70
+ this.vNode = this.createVM(component, options);
71
+ }
72
+ _createClass(Mount, [{
73
+ key: "createVM",
74
+ value: function createVM(component) {
75
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
76
+ props = _ref.props,
77
+ children = _ref.children,
78
+ patchFlag = _ref.patchFlag,
79
+ dynamicProps = _ref.dynamicProps,
80
+ isBlockNode = _ref.isBlockNode,
81
+ app = _ref.app,
82
+ context = _ref.context,
83
+ parent = _ref.parent;
84
+ var vNode;
85
+ if (isVue2) {
86
+ var VueConstructor = Vue2.extend(Object.assign({}, context || {}, component));
87
+ vNode = new VueConstructor({
88
+ parent: parent,
89
+ propsData: props
90
+ });
91
+ vNode.id = 'mount-plugin-' + this.seed++;
92
+ return vNode;
93
+ } else {
94
+ vNode = createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
95
+ if (app !== null && app !== void 0 && app._context) vNode.appContext = app._context;
96
+ return vNode;
97
+ }
41
98
  }
42
- mount() {
43
- !this.options.target && document.body.appendChild(this.target);
44
- if (isVue2) {
45
- this.vNode && this.vNode.$mount(this.target);
46
- }
47
- else {
48
- render(this.vNode, this.target);
49
- }
99
+ }, {
100
+ key: "mount",
101
+ value: function mount() {
102
+ !this.options.target && document.body.appendChild(this.target);
103
+ if (isVue2) {
104
+ this.vNode && this.vNode.$mount(this.target);
105
+ } else {
106
+ render(this.vNode, this.target);
107
+ }
50
108
  }
51
- unmount() {
52
- if (isVue2) {
53
- this.vNode.$destroy();
54
- document.body.removeChild(this.vNode.$el);
55
- }
56
- else {
57
- render(null, this.target);
58
- document.body.removeChild(this.target);
59
- }
60
- this.vNode = null;
61
- this.target = null;
109
+ }, {
110
+ key: "unmount",
111
+ value: function unmount() {
112
+ if (isVue2) {
113
+ this.vNode.$destroy();
114
+ document.body.removeChild(this.vNode.$el);
115
+ } else {
116
+ render(null, this.target);
117
+ document.body.removeChild(this.target);
118
+ }
119
+ this.vNode = null;
120
+ this.target = null;
62
121
  }
63
- }
122
+ }]);
123
+ return Mount;
124
+ }();
64
125
 
65
126
  export { Mount as default };
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * vue-mount-plugin v3.0.0
2
+ * vue-mount-plugin v3.1.0
3
3
  * A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
4
4
  * (c) 2021-2023 saqqdy <saqqdy@qq.com>
5
5
  * Released under the MIT License.
6
6
  */
7
- import{isVue2 as t,Vue2 as e,createVNode as o,render as r}from"vue-demi";class s{vNode=null;target;options={};seed=1;constructor(t,e={}){if("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)}createVM(r,{props:s,children:n,patchFlag:i,dynamicProps:a,isBlockNode:d,app:h,context:u,parent:p}={}){let c;return t?(c=new(e.extend(Object.assign({},u||{},r)))({parent:p,propsData:s}),c.id="mount-plugin-"+this.seed++,c):(c=o(r,s,n,i,a,d),h?._context&&(c.appContext=h._context),c)}mount(){!this.options.target&&document.body.appendChild(this.target),t?this.vNode&&this.vNode.$mount(this.target):r(this.vNode,this.target)}unmount(){t?(this.vNode.$destroy(),document.body.removeChild(this.vNode.$el)):(r(null,this.target),document.body.removeChild(this.target)),this.vNode=null,this.target=null}}export{s as default};
7
+ import{isVue2 as e,Vue2 as t,createVNode as r,render as n}from"vue-demi";function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function i(e,t,r){return(t=a(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function a(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var u=function(){function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),i(this,"vNode",null),i(this,"options",{}),i(this,"seed",1),"undefined"==typeof document)throw new Error("This plugin works in browser");this.options=t,this.target=("string"==typeof t.target?document.querySelector(t.target):t.target)||document.createElement(t.tagName||"div"),this.vNode=this.createVM(e,t)}var u,s;return u=a,s=[{key:"createVM",value:function(n){var o,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=i.props,u=i.children,s=i.patchFlag,l=i.dynamicProps,d=i.isBlockNode,c=i.app,p=i.context,h=i.parent;return e?((o=new(t.extend(Object.assign({},p||{},n)))({parent:h,propsData:a})).id="mount-plugin-"+this.seed++,o):(o=r(n,a,u,s,l,d),null!=c&&c._context&&(o.appContext=c._context),o)}},{key:"mount",value:function(){!this.options.target&&document.body.appendChild(this.target),e?this.vNode&&this.vNode.$mount(this.target):n(this.vNode,this.target)}},{key:"unmount",value:function(){e?(this.vNode.$destroy(),document.body.removeChild(this.vNode.$el)):(n(null,this.target),document.body.removeChild(this.target)),this.vNode=null,this.target=null}}],s&&o(u.prototype,s),Object.defineProperty(u,"prototype",{writable:!1}),a}();export{u as default};
@@ -1,59 +1,120 @@
1
1
  import { isVue2, Vue2, createVNode, render } from 'vue-demi';
2
2
 
3
- class Mount {
4
- vNode = null;
5
- target;
6
- options = {};
7
- seed = 1;
8
- constructor(component, options = {}) {
9
- if (typeof document === 'undefined')
10
- throw new Error('This plugin works in browser');
11
- this.options = options;
12
- this.target =
13
- (typeof options.target === 'string'
14
- ? document.querySelector(options.target)
15
- : options.target) || document.createElement(options.tagName || 'div');
16
- this.vNode = this.createVM(component, options);
17
- }
18
- createVM(component, { props, children, patchFlag, dynamicProps, isBlockNode, app, context, parent } = {}) {
19
- let vNode;
20
- if (isVue2) {
21
- const VueConstructor = Vue2.extend(Object.assign({}, context || {}, component));
22
- vNode = new VueConstructor({
23
- parent,
24
- propsData: props
25
- });
26
- vNode.id = 'mount-plugin-' + this.seed++;
27
- return vNode;
28
- }
29
- else {
30
- vNode = createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
31
- if (app?._context)
32
- vNode.appContext = app._context;
33
- return vNode;
34
- }
3
+ function _classCallCheck(instance, Constructor) {
4
+ if (!(instance instanceof Constructor)) {
5
+ throw new TypeError("Cannot call a class as a function");
6
+ }
7
+ }
8
+ function _defineProperties(target, props) {
9
+ for (var i = 0; i < props.length; i++) {
10
+ var descriptor = props[i];
11
+ descriptor.enumerable = descriptor.enumerable || false;
12
+ descriptor.configurable = true;
13
+ if ("value" in descriptor) descriptor.writable = true;
14
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
15
+ }
16
+ }
17
+ function _createClass(Constructor, protoProps, staticProps) {
18
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
19
+ if (staticProps) _defineProperties(Constructor, staticProps);
20
+ Object.defineProperty(Constructor, "prototype", {
21
+ writable: false
22
+ });
23
+ return Constructor;
24
+ }
25
+ function _defineProperty(obj, key, value) {
26
+ key = _toPropertyKey(key);
27
+ if (key in obj) {
28
+ Object.defineProperty(obj, key, {
29
+ value: value,
30
+ enumerable: true,
31
+ configurable: true,
32
+ writable: true
33
+ });
34
+ } else {
35
+ obj[key] = value;
36
+ }
37
+ return obj;
38
+ }
39
+ function _toPrimitive(input, hint) {
40
+ if (typeof input !== "object" || input === null) return input;
41
+ var prim = input[Symbol.toPrimitive];
42
+ if (prim !== undefined) {
43
+ var res = prim.call(input, hint || "default");
44
+ if (typeof res !== "object") return res;
45
+ throw new TypeError("@@toPrimitive must return a primitive value.");
46
+ }
47
+ return (hint === "string" ? String : Number)(input);
48
+ }
49
+ function _toPropertyKey(arg) {
50
+ var key = _toPrimitive(arg, "string");
51
+ return typeof key === "symbol" ? key : String(key);
52
+ }
53
+
54
+ var Mount = /*#__PURE__*/function () {
55
+ function Mount(component) {
56
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
57
+ _classCallCheck(this, Mount);
58
+ _defineProperty(this, "vNode", null);
59
+ _defineProperty(this, "options", {});
60
+ _defineProperty(this, "seed", 1);
61
+ if (typeof document === 'undefined') throw new Error('This plugin works in browser');
62
+ this.options = options;
63
+ this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
64
+ this.vNode = this.createVM(component, options);
65
+ }
66
+ _createClass(Mount, [{
67
+ key: "createVM",
68
+ value: function createVM(component) {
69
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
70
+ props = _ref.props,
71
+ children = _ref.children,
72
+ patchFlag = _ref.patchFlag,
73
+ dynamicProps = _ref.dynamicProps,
74
+ isBlockNode = _ref.isBlockNode,
75
+ app = _ref.app,
76
+ context = _ref.context,
77
+ parent = _ref.parent;
78
+ var vNode;
79
+ if (isVue2) {
80
+ var VueConstructor = Vue2.extend(Object.assign({}, context || {}, component));
81
+ vNode = new VueConstructor({
82
+ parent: parent,
83
+ propsData: props
84
+ });
85
+ vNode.id = 'mount-plugin-' + this.seed++;
86
+ return vNode;
87
+ } else {
88
+ vNode = createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
89
+ if (app !== null && app !== void 0 && app._context) vNode.appContext = app._context;
90
+ return vNode;
91
+ }
35
92
  }
36
- mount() {
37
- !this.options.target && document.body.appendChild(this.target);
38
- if (isVue2) {
39
- this.vNode && this.vNode.$mount(this.target);
40
- }
41
- else {
42
- render(this.vNode, this.target);
43
- }
93
+ }, {
94
+ key: "mount",
95
+ value: function mount() {
96
+ !this.options.target && document.body.appendChild(this.target);
97
+ if (isVue2) {
98
+ this.vNode && this.vNode.$mount(this.target);
99
+ } else {
100
+ render(this.vNode, this.target);
101
+ }
44
102
  }
45
- unmount() {
46
- if (isVue2) {
47
- this.vNode.$destroy();
48
- document.body.removeChild(this.vNode.$el);
49
- }
50
- else {
51
- render(null, this.target);
52
- document.body.removeChild(this.target);
53
- }
54
- this.vNode = null;
55
- this.target = null;
103
+ }, {
104
+ key: "unmount",
105
+ value: function unmount() {
106
+ if (isVue2) {
107
+ this.vNode.$destroy();
108
+ document.body.removeChild(this.vNode.$el);
109
+ } else {
110
+ render(null, this.target);
111
+ document.body.removeChild(this.target);
112
+ }
113
+ this.vNode = null;
114
+ this.target = null;
56
115
  }
57
- }
116
+ }]);
117
+ return Mount;
118
+ }();
58
119
 
59
120
  export { Mount as default };
@@ -115,7 +115,7 @@ var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
115
115
  );
116
116
  ;
117
117
  /*!
118
- * vue-mount-plugin v3.0.0
118
+ * vue-mount-plugin v3.1.0
119
119
  * A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
120
120
  * (c) 2021-2023 saqqdy <saqqdy@qq.com>
121
121
  * Released under the MIT License.
@@ -1,8 +1,8 @@
1
- var VueDemi=function(e,t,i){if(e.install)return e;if(!t)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if("2.7."===t.version.slice(0,4)){for(var n in t)e[n]=t[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.warn=t.util.warn,e.hasInjectionContext=()=>!!e.getCurrentInstance(),e.createApp=function(e,i){var n,o={},r={config:t.config,use:t.use.bind(t),mixin:t.mixin.bind(t),component:t.component.bind(t),provide:function(e,t){return o[e]=t,this},directive:function(e,i){return i?(t.directive(e,i),r):t.directive(e)},mount:function(r,s){return n||((n=new t(Object.assign({propsData:i},e,{provide:Object.assign(o,e.provide)}))).$mount(r,s),n)},unmount:function(){n&&(n.$destroy(),n=void 0)}};return r}}else if("2."===t.version.slice(0,2))if(i){for(var n in i)e[n]=i[n];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.hasInjectionContext=()=>!!e.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if("3."===t.version.slice(0,2)){for(var n in t)e[n]=t[n];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=t,e.Vue2=void 0,e.version=t.version,e.set=function(e,t,i){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,i),i):(e[t]=i,i)},e.del=function(e,t){Array.isArray(e)?e.splice(t,1):delete e[t]}}else console.error("[vue-demi] Vue version "+t.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(void 0!==VueDemi?VueDemi:{}),this.Vue||("undefined"!=typeof Vue?Vue:void 0),this.VueCompositionAPI||("undefined"!=typeof VueCompositionAPI?VueCompositionAPI:void 0));
1
+ var VueDemi=function(e,t,n){if(e.install)return e;if(!t)return console.error("[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`."),e;if("2.7."===t.version.slice(0,4)){for(var i in t)e[i]=t[i];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.warn=t.util.warn,e.hasInjectionContext=()=>!!e.getCurrentInstance(),e.createApp=function(e,n){var i,o={},r={config:t.config,use:t.use.bind(t),mixin:t.mixin.bind(t),component:t.component.bind(t),provide:function(e,t){return o[e]=t,this},directive:function(e,n){return n?(t.directive(e,n),r):t.directive(e)},mount:function(r,u){return i||((i=new t(Object.assign({propsData:n},e,{provide:Object.assign(o,e.provide)}))).$mount(r,u),i)},unmount:function(){i&&(i.$destroy(),i=void 0)}};return r}}else if("2."===t.version.slice(0,2))if(n){for(var i in n)e[i]=n[i];e.isVue2=!0,e.isVue3=!1,e.install=function(){},e.Vue=t,e.Vue2=t,e.version=t.version,e.hasInjectionContext=()=>!!e.getCurrentInstance()}else console.error("[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.");else if("3."===t.version.slice(0,2)){for(var i in t)e[i]=t[i];e.isVue2=!1,e.isVue3=!0,e.install=function(){},e.Vue=t,e.Vue2=void 0,e.version=t.version,e.set=function(e,t,n){return Array.isArray(e)?(e.length=Math.max(e.length,t),e.splice(t,1,n),n):(e[t]=n,n)},e.del=function(e,t){Array.isArray(e)?e.splice(t,1):delete e[t]}}else console.error("[vue-demi] Vue version "+t.version+" is unsupported.");return e}(this.VueDemi=this.VueDemi||(void 0!==VueDemi?VueDemi:{}),this.Vue||("undefined"!=typeof Vue?Vue:void 0),this.VueCompositionAPI||("undefined"!=typeof VueCompositionAPI?VueCompositionAPI:void 0));
2
2
  /*!
3
- * vue-mount-plugin v3.0.0
3
+ * vue-mount-plugin v3.1.0
4
4
  * A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
5
5
  * (c) 2021-2023 saqqdy <saqqdy@qq.com>
6
6
  * Released under the MIT License.
7
7
  */
8
- this.VueMount=function(e){"use strict";return class{vNode=null;target;options={};seed=1;constructor(e,t={}){if("undefined"==typeof document)throw new Error("This plugin works in browser");this.options=t,this.target=("string"==typeof t.target?document.querySelector(t.target):t.target)||document.createElement(t.tagName||"div"),this.vNode=this.createVM(e,t)}createVM(t,{props:i,children:n,patchFlag:o,dynamicProps:r,isBlockNode:s,app:u,context:d,parent:a}={}){let c;return e.isVue2?(c=new(e.Vue2.extend(Object.assign({},d||{},t)))({parent:a,propsData:i}),c.id="mount-plugin-"+this.seed++,c):(c=e.createVNode(t,i,n,o,r,s),u?._context&&(c.appContext=u._context),c)}mount(){!this.options.target&&document.body.appendChild(this.target),e.isVue2?this.vNode&&this.vNode.$mount(this.target):e.render(this.vNode,this.target)}unmount(){e.isVue2?(this.vNode.$destroy(),document.body.removeChild(this.vNode.$el)):(e.render(null,this.target),document.body.removeChild(this.target)),this.vNode=null,this.target=null}}}(VueDemi);
8
+ this.VueMount=function(e){"use strict";function t(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,i(o.key),o)}}function n(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function i(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}var o=function(){function i(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),n(this,"vNode",null),n(this,"options",{}),n(this,"seed",1),"undefined"==typeof document)throw new Error("This plugin works in browser");this.options=t,this.target=("string"==typeof t.target?document.querySelector(t.target):t.target)||document.createElement(t.tagName||"div"),this.vNode=this.createVM(e,t)}var o,r;return o=i,r=[{key:"createVM",value:function(t){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=i.props,r=i.children,u=i.patchFlag,s=i.dynamicProps,a=i.isBlockNode,c=i.app,l=i.context,d=i.parent;return e.isVue2?((n=new(e.Vue2.extend(Object.assign({},l||{},t)))({parent:d,propsData:o})).id="mount-plugin-"+this.seed++,n):(n=e.createVNode(t,o,r,u,s,a),null!=c&&c._context&&(n.appContext=c._context),n)}},{key:"mount",value:function(){!this.options.target&&document.body.appendChild(this.target),e.isVue2?this.vNode&&this.vNode.$mount(this.target):e.render(this.vNode,this.target)}},{key:"unmount",value:function(){e.isVue2?(this.vNode.$destroy(),document.body.removeChild(this.vNode.$el)):(e.render(null,this.target),document.body.removeChild(this.target)),this.vNode=null,this.target=null}}],r&&t(o.prototype,r),Object.defineProperty(o,"prototype",{writable:!1}),i}();return o}(VueDemi);
package/package.json CHANGED
@@ -1,7 +1,7 @@
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": "3.0.0",
4
+ "version": "3.1.0",
5
5
  "packageManager": "pnpm@8.5.1",
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.esm-bundler.js",