vue-mount-plugin 3.0.0 → 4.0.0-beta.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 +297 -19
- package/dist/index.cjs +969 -0
- package/dist/index.d.ts +266 -21
- package/dist/index.es5.js +7767 -0
- package/dist/index.es5.min.js +1 -0
- package/dist/index.iife.js +1103 -0
- package/dist/index.iife.min.js +1 -0
- package/dist/index.mjs +896 -90
- package/package.json +64 -63
- package/dist/index.cjs.js +0 -122
- package/dist/index.esm-browser.js +0 -65
- package/dist/index.esm-browser.prod.js +0 -7
- package/dist/index.esm-bundler.js +0 -59
- package/dist/index.global.js +0 -245
- package/dist/index.global.prod.js +0 -8
package/package.json
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
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
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"unpkg": "dist/index.
|
|
10
|
-
"jsdelivr": "dist/index.
|
|
4
|
+
"type": "module",
|
|
5
|
+
"version": "4.0.0-beta.0",
|
|
6
|
+
"packageManager": "pnpm@8.9.0",
|
|
7
|
+
"main": "dist/index.cjs",
|
|
8
|
+
"module": "dist/index.mjs",
|
|
9
|
+
"unpkg": "dist/index.iife.min.js",
|
|
10
|
+
"jsdelivr": "dist/index.iife.min.js",
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"
|
|
16
|
-
"require": "./dist/index.cjs.js",
|
|
15
|
+
"require": "./dist/index.cjs",
|
|
17
16
|
"import": "./dist/index.mjs"
|
|
18
17
|
},
|
|
19
18
|
"./*": "./*"
|
|
20
19
|
},
|
|
21
|
-
"files": [
|
|
22
|
-
"dist"
|
|
23
|
-
],
|
|
24
20
|
"directories": {
|
|
25
21
|
"dist": "dist",
|
|
26
22
|
"src": "src"
|
|
27
23
|
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"typings"
|
|
27
|
+
],
|
|
28
28
|
"scripts": {
|
|
29
|
-
"build": "run-s clean build:{bundle,types}",
|
|
30
|
-
"build:bundle": "
|
|
29
|
+
"build": "run-s clean build:{bundle,types,es5}",
|
|
30
|
+
"build:bundle": "tsx scripts/build",
|
|
31
31
|
"build:es5": "cross-env BABEL_ENV=es5 pnpm build:bundle",
|
|
32
32
|
"build:types": "tsc -p src/tsconfig.json && pnpm roll-types",
|
|
33
|
-
"build:docs": "rm-all docs && typedoc &&
|
|
33
|
+
"build:docs": "rm-all docs && typedoc && lint:fix",
|
|
34
34
|
"deploy": "sh scripts/deploy.sh",
|
|
35
35
|
"roll-types": "api-extractor run && rm-all temp",
|
|
36
36
|
"watch": "pnpm build:bundle -w",
|
|
37
|
-
"pub": "
|
|
38
|
-
"unpub": "
|
|
39
|
-
"sync": "
|
|
37
|
+
"pub": "tsx scripts/publish",
|
|
38
|
+
"unpub": "tsx scripts/unpublish",
|
|
39
|
+
"sync": "tsx scripts/sync",
|
|
40
40
|
"workflow:publish-test": "zx scripts/workflow.mjs",
|
|
41
41
|
"clean": "rm-all dist es lib",
|
|
42
|
-
"dist": "run-s
|
|
43
|
-
"test
|
|
44
|
-
"test:
|
|
45
|
-
"test:
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
42
|
+
"dist": "run-s lint:fix build",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest",
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
46
|
+
"test:2": "vue-demi-switch 2 vue2 && vitest run",
|
|
47
|
+
"test:3": "vue-demi-switch 3 && vitest run",
|
|
48
|
+
"lint": "eslint .",
|
|
49
|
+
"lint:fix": "eslint --fix ."
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"js-cool": "^
|
|
53
|
-
"
|
|
52
|
+
"js-cool": "^5.23.1",
|
|
53
|
+
"tslib": "^2.8.1",
|
|
54
|
+
"vue-demi": "^0.14.10"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
|
-
"@babel/core": "^7.
|
|
57
|
-
"@babel/preset-env": "^7.
|
|
58
|
-
"@babel/preset-typescript": "^7.
|
|
59
|
-
"@eslint-sets/eslint-config
|
|
60
|
-
"@microsoft/api-extractor": "^7.
|
|
61
|
-
"@rollup/plugin-alias": "^5.
|
|
62
|
-
"@rollup/plugin-babel": "^
|
|
63
|
-
"@rollup/plugin-commonjs": "^
|
|
64
|
-
"@rollup/plugin-node-resolve": "^
|
|
65
|
-
"@rollup/plugin-terser": "^0.4.
|
|
66
|
-
"@rollup/plugin-typescript": "^
|
|
67
|
-
"@types/
|
|
68
|
-
"@
|
|
69
|
-
"chalk": "^5.
|
|
70
|
-
"core-js": "^3.
|
|
71
|
-
"coveralls": "^3.1.1",
|
|
57
|
+
"@babel/core": "^7.26.0",
|
|
58
|
+
"@babel/preset-env": "^7.29.2",
|
|
59
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
60
|
+
"@eslint-sets/eslint-config": "^6.1.0",
|
|
61
|
+
"@microsoft/api-extractor": "^7.49.1",
|
|
62
|
+
"@rollup/plugin-alias": "^5.1.1",
|
|
63
|
+
"@rollup/plugin-babel": "^7.0.0",
|
|
64
|
+
"@rollup/plugin-commonjs": "^28.0.2",
|
|
65
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
66
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
67
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
68
|
+
"@types/node": "^22.19.15",
|
|
69
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
70
|
+
"chalk": "^5.4.1",
|
|
71
|
+
"core-js": "^3.49.0",
|
|
72
72
|
"cross-env": "^7.0.3",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
73
|
+
"esbuild": "^0.27.4",
|
|
74
|
+
"eslint": "^9.39.4",
|
|
75
|
+
"fast-glob": "^3.3.3",
|
|
76
|
+
"jsdom": "^29.0.0",
|
|
77
|
+
"load-yml": "^1.4.0",
|
|
77
78
|
"npm-run-all": "^4.1.5",
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"rm-all": "^1.0.0",
|
|
82
|
-
"rollup": "^3.23.0",
|
|
79
|
+
"reinstaller": "^3.0.2",
|
|
80
|
+
"rm-all": "^1.1.1",
|
|
81
|
+
"rollup": "^4.31.0",
|
|
83
82
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
83
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
84
84
|
"rollup-plugin-filesize": "^10.0.0",
|
|
85
85
|
"rollup-plugin-inject-code": "^1.0.0",
|
|
86
|
-
"rollup-plugin-visualizer": "^5.
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"typedoc": "^
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"vue": "^3.
|
|
86
|
+
"rollup-plugin-visualizer": "^5.14.0",
|
|
87
|
+
"tsx": "^4.19.2",
|
|
88
|
+
"typedoc": "^0.27.6",
|
|
89
|
+
"typedoc-plugin-markdown": "^4.4.1",
|
|
90
|
+
"typescript": "^5.7.3",
|
|
91
|
+
"vitest": "^4.1.0",
|
|
92
|
+
"vue": "^3.5.30",
|
|
93
93
|
"vue2": "npm:vue@^2.7.14",
|
|
94
|
-
"zx": "^
|
|
94
|
+
"zx": "^8.3.0"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"@vue/composition-api": ">=1.0.0",
|
|
@@ -104,8 +104,9 @@
|
|
|
104
104
|
}
|
|
105
105
|
},
|
|
106
106
|
"engines": {
|
|
107
|
-
"node": ">=
|
|
107
|
+
"node": ">=14.14.0"
|
|
108
108
|
},
|
|
109
|
+
"sideEffects": false,
|
|
109
110
|
"pnpm": {
|
|
110
111
|
"peerDependencyRules": {
|
|
111
112
|
"ignoreMissing": [
|
|
@@ -114,7 +115,7 @@
|
|
|
114
115
|
],
|
|
115
116
|
"allowedVersions": {
|
|
116
117
|
"rollup": ">=3.20.0",
|
|
117
|
-
"eslint": "^
|
|
118
|
+
"eslint": "^9.0.0"
|
|
118
119
|
}
|
|
119
120
|
}
|
|
120
121
|
},
|
package/dist/index.cjs.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var vueDemi = require('vue-demi');
|
|
4
|
-
|
|
5
|
-
function _classCallCheck(instance, Constructor) {
|
|
6
|
-
if (!(instance instanceof Constructor)) {
|
|
7
|
-
throw new TypeError("Cannot call a class as a function");
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
function _defineProperties(target, props) {
|
|
11
|
-
for (var i = 0; i < props.length; i++) {
|
|
12
|
-
var descriptor = props[i];
|
|
13
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
14
|
-
descriptor.configurable = true;
|
|
15
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
16
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
20
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
21
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
22
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
23
|
-
writable: false
|
|
24
|
-
});
|
|
25
|
-
return Constructor;
|
|
26
|
-
}
|
|
27
|
-
function _defineProperty(obj, key, value) {
|
|
28
|
-
key = _toPropertyKey(key);
|
|
29
|
-
if (key in obj) {
|
|
30
|
-
Object.defineProperty(obj, key, {
|
|
31
|
-
value: value,
|
|
32
|
-
enumerable: true,
|
|
33
|
-
configurable: true,
|
|
34
|
-
writable: true
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
obj[key] = value;
|
|
38
|
-
}
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
|
-
function _toPrimitive(input, hint) {
|
|
42
|
-
if (typeof input !== "object" || input === null) return input;
|
|
43
|
-
var prim = input[Symbol.toPrimitive];
|
|
44
|
-
if (prim !== undefined) {
|
|
45
|
-
var res = prim.call(input, hint || "default");
|
|
46
|
-
if (typeof res !== "object") return res;
|
|
47
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
48
|
-
}
|
|
49
|
-
return (hint === "string" ? String : Number)(input);
|
|
50
|
-
}
|
|
51
|
-
function _toPropertyKey(arg) {
|
|
52
|
-
var key = _toPrimitive(arg, "string");
|
|
53
|
-
return typeof key === "symbol" ? key : String(key);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var Mount = /*#__PURE__*/function () {
|
|
57
|
-
function Mount(component) {
|
|
58
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
59
|
-
_classCallCheck(this, Mount);
|
|
60
|
-
_defineProperty(this, "vNode", null);
|
|
61
|
-
_defineProperty(this, "options", {});
|
|
62
|
-
_defineProperty(this, "seed", 1);
|
|
63
|
-
if (typeof document === 'undefined') throw new Error('This plugin works in browser');
|
|
64
|
-
this.options = options;
|
|
65
|
-
this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
|
|
66
|
-
this.vNode = this.createVM(component, options);
|
|
67
|
-
}
|
|
68
|
-
_createClass(Mount, [{
|
|
69
|
-
key: "createVM",
|
|
70
|
-
value: function createVM(component) {
|
|
71
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
72
|
-
props = _ref.props,
|
|
73
|
-
children = _ref.children,
|
|
74
|
-
patchFlag = _ref.patchFlag,
|
|
75
|
-
dynamicProps = _ref.dynamicProps,
|
|
76
|
-
isBlockNode = _ref.isBlockNode,
|
|
77
|
-
app = _ref.app,
|
|
78
|
-
context = _ref.context,
|
|
79
|
-
parent = _ref.parent;
|
|
80
|
-
var vNode;
|
|
81
|
-
if (vueDemi.isVue2) {
|
|
82
|
-
var VueConstructor = vueDemi.Vue2.extend(Object.assign({}, context || {}, component));
|
|
83
|
-
vNode = new VueConstructor({
|
|
84
|
-
parent: parent,
|
|
85
|
-
propsData: props
|
|
86
|
-
});
|
|
87
|
-
vNode.id = 'mount-plugin-' + this.seed++;
|
|
88
|
-
return vNode;
|
|
89
|
-
} else {
|
|
90
|
-
vNode = vueDemi.createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
|
|
91
|
-
if (app !== null && app !== void 0 && app._context) vNode.appContext = app._context;
|
|
92
|
-
return vNode;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}, {
|
|
96
|
-
key: "mount",
|
|
97
|
-
value: function mount() {
|
|
98
|
-
!this.options.target && document.body.appendChild(this.target);
|
|
99
|
-
if (vueDemi.isVue2) {
|
|
100
|
-
this.vNode && this.vNode.$mount(this.target);
|
|
101
|
-
} else {
|
|
102
|
-
vueDemi.render(this.vNode, this.target);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "unmount",
|
|
107
|
-
value: function unmount() {
|
|
108
|
-
if (vueDemi.isVue2) {
|
|
109
|
-
this.vNode.$destroy();
|
|
110
|
-
document.body.removeChild(this.vNode.$el);
|
|
111
|
-
} else {
|
|
112
|
-
vueDemi.render(null, this.target);
|
|
113
|
-
document.body.removeChild(this.target);
|
|
114
|
-
}
|
|
115
|
-
this.vNode = null;
|
|
116
|
-
this.target = null;
|
|
117
|
-
}
|
|
118
|
-
}]);
|
|
119
|
-
return Mount;
|
|
120
|
-
}();
|
|
121
|
-
|
|
122
|
-
module.exports = Mount;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* vue-mount-plugin v3.0.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
|
-
import { isVue2, Vue2, createVNode, render } from 'vue-demi';
|
|
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
|
-
}
|
|
41
|
-
}
|
|
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
|
-
}
|
|
50
|
-
}
|
|
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;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export { Mount as default };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* vue-mount-plugin v3.0.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
|
-
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};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { isVue2, Vue2, createVNode, render } from 'vue-demi';
|
|
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
|
-
}
|
|
35
|
-
}
|
|
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
|
-
}
|
|
44
|
-
}
|
|
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;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export { Mount as default };
|
package/dist/index.global.js
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
var VueDemi = (function (VueDemi, Vue, VueCompositionAPI) {
|
|
2
|
-
if (VueDemi.install) {
|
|
3
|
-
return VueDemi
|
|
4
|
-
}
|
|
5
|
-
if (!Vue) {
|
|
6
|
-
console.error('[vue-demi] no Vue instance found, please be sure to import `vue` before `vue-demi`.')
|
|
7
|
-
return VueDemi
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// Vue 2.7
|
|
11
|
-
if (Vue.version.slice(0, 4) === '2.7.') {
|
|
12
|
-
for (var key in Vue) {
|
|
13
|
-
VueDemi[key] = Vue[key]
|
|
14
|
-
}
|
|
15
|
-
VueDemi.isVue2 = true
|
|
16
|
-
VueDemi.isVue3 = false
|
|
17
|
-
VueDemi.install = function () {}
|
|
18
|
-
VueDemi.Vue = Vue
|
|
19
|
-
VueDemi.Vue2 = Vue
|
|
20
|
-
VueDemi.version = Vue.version
|
|
21
|
-
VueDemi.warn = Vue.util.warn
|
|
22
|
-
VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
|
|
23
|
-
function createApp(rootComponent, rootProps) {
|
|
24
|
-
var vm
|
|
25
|
-
var provide = {}
|
|
26
|
-
var app = {
|
|
27
|
-
config: Vue.config,
|
|
28
|
-
use: Vue.use.bind(Vue),
|
|
29
|
-
mixin: Vue.mixin.bind(Vue),
|
|
30
|
-
component: Vue.component.bind(Vue),
|
|
31
|
-
provide: function (key, value) {
|
|
32
|
-
provide[key] = value
|
|
33
|
-
return this
|
|
34
|
-
},
|
|
35
|
-
directive: function (name, dir) {
|
|
36
|
-
if (dir) {
|
|
37
|
-
Vue.directive(name, dir)
|
|
38
|
-
return app
|
|
39
|
-
} else {
|
|
40
|
-
return Vue.directive(name)
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
mount: function (el, hydrating) {
|
|
44
|
-
if (!vm) {
|
|
45
|
-
vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
|
|
46
|
-
vm.$mount(el, hydrating)
|
|
47
|
-
return vm
|
|
48
|
-
} else {
|
|
49
|
-
return vm
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
unmount: function () {
|
|
53
|
-
if (vm) {
|
|
54
|
-
vm.$destroy()
|
|
55
|
-
vm = undefined
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
return app
|
|
60
|
-
}
|
|
61
|
-
VueDemi.createApp = createApp
|
|
62
|
-
}
|
|
63
|
-
// Vue 2.6.x
|
|
64
|
-
else if (Vue.version.slice(0, 2) === '2.') {
|
|
65
|
-
if (VueCompositionAPI) {
|
|
66
|
-
for (var key in VueCompositionAPI) {
|
|
67
|
-
VueDemi[key] = VueCompositionAPI[key]
|
|
68
|
-
}
|
|
69
|
-
VueDemi.isVue2 = true
|
|
70
|
-
VueDemi.isVue3 = false
|
|
71
|
-
VueDemi.install = function () {}
|
|
72
|
-
VueDemi.Vue = Vue
|
|
73
|
-
VueDemi.Vue2 = Vue
|
|
74
|
-
VueDemi.version = Vue.version
|
|
75
|
-
VueDemi.hasInjectionContext = () => !!VueDemi.getCurrentInstance()
|
|
76
|
-
} else {
|
|
77
|
-
console.error('[vue-demi] no VueCompositionAPI instance found, please be sure to import `@vue/composition-api` before `vue-demi`.')
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Vue 3
|
|
81
|
-
else if (Vue.version.slice(0, 2) === '3.') {
|
|
82
|
-
for (var key in Vue) {
|
|
83
|
-
VueDemi[key] = Vue[key]
|
|
84
|
-
}
|
|
85
|
-
VueDemi.isVue2 = false
|
|
86
|
-
VueDemi.isVue3 = true
|
|
87
|
-
VueDemi.install = function () {}
|
|
88
|
-
VueDemi.Vue = Vue
|
|
89
|
-
VueDemi.Vue2 = undefined
|
|
90
|
-
VueDemi.version = Vue.version
|
|
91
|
-
VueDemi.set = function (target, key, val) {
|
|
92
|
-
if (Array.isArray(target)) {
|
|
93
|
-
target.length = Math.max(target.length, key)
|
|
94
|
-
target.splice(key, 1, val)
|
|
95
|
-
return val
|
|
96
|
-
}
|
|
97
|
-
target[key] = val
|
|
98
|
-
return val
|
|
99
|
-
}
|
|
100
|
-
VueDemi.del = function (target, key) {
|
|
101
|
-
if (Array.isArray(target)) {
|
|
102
|
-
target.splice(key, 1)
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
delete target[key]
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
console.error('[vue-demi] Vue version ' + Vue.version + ' is unsupported.')
|
|
109
|
-
}
|
|
110
|
-
return VueDemi
|
|
111
|
-
})(
|
|
112
|
-
(this.VueDemi = this.VueDemi || (typeof VueDemi !== 'undefined' ? VueDemi : {})),
|
|
113
|
-
this.Vue || (typeof Vue !== 'undefined' ? Vue : undefined),
|
|
114
|
-
this.VueCompositionAPI || (typeof VueCompositionAPI !== 'undefined' ? VueCompositionAPI : undefined)
|
|
115
|
-
);
|
|
116
|
-
;
|
|
117
|
-
/*!
|
|
118
|
-
* vue-mount-plugin v3.0.0
|
|
119
|
-
* A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
120
|
-
* (c) 2021-2023 saqqdy <saqqdy@qq.com>
|
|
121
|
-
* Released under the MIT License.
|
|
122
|
-
*/
|
|
123
|
-
this.VueMount = (function (vueDemi) {
|
|
124
|
-
'use strict';
|
|
125
|
-
|
|
126
|
-
function _classCallCheck(instance, Constructor) {
|
|
127
|
-
if (!(instance instanceof Constructor)) {
|
|
128
|
-
throw new TypeError("Cannot call a class as a function");
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function _defineProperties(target, props) {
|
|
132
|
-
for (var i = 0; i < props.length; i++) {
|
|
133
|
-
var descriptor = props[i];
|
|
134
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
135
|
-
descriptor.configurable = true;
|
|
136
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
137
|
-
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
function _createClass(Constructor, protoProps, staticProps) {
|
|
141
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
142
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
143
|
-
Object.defineProperty(Constructor, "prototype", {
|
|
144
|
-
writable: false
|
|
145
|
-
});
|
|
146
|
-
return Constructor;
|
|
147
|
-
}
|
|
148
|
-
function _defineProperty(obj, key, value) {
|
|
149
|
-
key = _toPropertyKey(key);
|
|
150
|
-
if (key in obj) {
|
|
151
|
-
Object.defineProperty(obj, key, {
|
|
152
|
-
value: value,
|
|
153
|
-
enumerable: true,
|
|
154
|
-
configurable: true,
|
|
155
|
-
writable: true
|
|
156
|
-
});
|
|
157
|
-
} else {
|
|
158
|
-
obj[key] = value;
|
|
159
|
-
}
|
|
160
|
-
return obj;
|
|
161
|
-
}
|
|
162
|
-
function _toPrimitive(input, hint) {
|
|
163
|
-
if (typeof input !== "object" || input === null) return input;
|
|
164
|
-
var prim = input[Symbol.toPrimitive];
|
|
165
|
-
if (prim !== undefined) {
|
|
166
|
-
var res = prim.call(input, hint || "default");
|
|
167
|
-
if (typeof res !== "object") return res;
|
|
168
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
169
|
-
}
|
|
170
|
-
return (hint === "string" ? String : Number)(input);
|
|
171
|
-
}
|
|
172
|
-
function _toPropertyKey(arg) {
|
|
173
|
-
var key = _toPrimitive(arg, "string");
|
|
174
|
-
return typeof key === "symbol" ? key : String(key);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
var Mount = /*#__PURE__*/function () {
|
|
178
|
-
function Mount(component) {
|
|
179
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
180
|
-
_classCallCheck(this, Mount);
|
|
181
|
-
_defineProperty(this, "vNode", null);
|
|
182
|
-
_defineProperty(this, "options", {});
|
|
183
|
-
_defineProperty(this, "seed", 1);
|
|
184
|
-
if (typeof document === 'undefined') throw new Error('This plugin works in browser');
|
|
185
|
-
this.options = options;
|
|
186
|
-
this.target = (typeof options.target === 'string' ? document.querySelector(options.target) : options.target) || document.createElement(options.tagName || 'div');
|
|
187
|
-
this.vNode = this.createVM(component, options);
|
|
188
|
-
}
|
|
189
|
-
_createClass(Mount, [{
|
|
190
|
-
key: "createVM",
|
|
191
|
-
value: function createVM(component) {
|
|
192
|
-
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
193
|
-
props = _ref.props,
|
|
194
|
-
children = _ref.children,
|
|
195
|
-
patchFlag = _ref.patchFlag,
|
|
196
|
-
dynamicProps = _ref.dynamicProps,
|
|
197
|
-
isBlockNode = _ref.isBlockNode,
|
|
198
|
-
app = _ref.app,
|
|
199
|
-
context = _ref.context,
|
|
200
|
-
parent = _ref.parent;
|
|
201
|
-
var vNode;
|
|
202
|
-
if (vueDemi.isVue2) {
|
|
203
|
-
var VueConstructor = vueDemi.Vue2.extend(Object.assign({}, context || {}, component));
|
|
204
|
-
vNode = new VueConstructor({
|
|
205
|
-
parent: parent,
|
|
206
|
-
propsData: props
|
|
207
|
-
});
|
|
208
|
-
vNode.id = 'mount-plugin-' + this.seed++;
|
|
209
|
-
return vNode;
|
|
210
|
-
} else {
|
|
211
|
-
vNode = vueDemi.createVNode(component, props, children, patchFlag, dynamicProps, isBlockNode);
|
|
212
|
-
if (app !== null && app !== void 0 && app._context) vNode.appContext = app._context;
|
|
213
|
-
return vNode;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}, {
|
|
217
|
-
key: "mount",
|
|
218
|
-
value: function mount() {
|
|
219
|
-
!this.options.target && document.body.appendChild(this.target);
|
|
220
|
-
if (vueDemi.isVue2) {
|
|
221
|
-
this.vNode && this.vNode.$mount(this.target);
|
|
222
|
-
} else {
|
|
223
|
-
vueDemi.render(this.vNode, this.target);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}, {
|
|
227
|
-
key: "unmount",
|
|
228
|
-
value: function unmount() {
|
|
229
|
-
if (vueDemi.isVue2) {
|
|
230
|
-
this.vNode.$destroy();
|
|
231
|
-
document.body.removeChild(this.vNode.$el);
|
|
232
|
-
} else {
|
|
233
|
-
vueDemi.render(null, this.target);
|
|
234
|
-
document.body.removeChild(this.target);
|
|
235
|
-
}
|
|
236
|
-
this.vNode = null;
|
|
237
|
-
this.target = null;
|
|
238
|
-
}
|
|
239
|
-
}]);
|
|
240
|
-
return Mount;
|
|
241
|
-
}();
|
|
242
|
-
|
|
243
|
-
return Mount;
|
|
244
|
-
|
|
245
|
-
})(VueDemi);
|