vue-mount-plugin 1.0.0-alpha.0 → 1.0.0-alpha.1
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/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/index.cjs +66 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.mjs +64 -0
- package/package.json +134 -27
- package/index.js +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 saqqdy <saqqdy@qq.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<div style="text-align: center;" align="center">
|
|
2
|
+
|
|
3
|
+
# vue-mount-plugin
|
|
4
|
+
|
|
5
|
+
A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0
|
|
6
|
+
|
|
7
|
+
[![NPM version][npm-image]][npm-url]
|
|
8
|
+
[![Codacy Badge][codacy-image]][codacy-url]
|
|
9
|
+
[![Test coverage][codecov-image]][codecov-url]
|
|
10
|
+
[![npm download][download-image]][download-url]
|
|
11
|
+
[![License][license-image]][license-url]
|
|
12
|
+
|
|
13
|
+
[![Sonar][sonar-image]][sonar-url]
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<div style="text-align: center; margin-bottom: 20px;" align="center">
|
|
18
|
+
|
|
19
|
+
## **For API documentation, see: [API Docs](./docs/modules.md)**
|
|
20
|
+
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
## Installing
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# use pnpm
|
|
27
|
+
$ pnpm install vue-mount-plugin
|
|
28
|
+
|
|
29
|
+
# use npm
|
|
30
|
+
$ npm install vue-mount-plugin --save
|
|
31
|
+
|
|
32
|
+
# use yarn
|
|
33
|
+
$ yarn add vue-mount-plugin
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Usage
|
|
37
|
+
|
|
38
|
+
## Support & Issues
|
|
39
|
+
|
|
40
|
+
Please open an issue [here](https://github.com/saqqdy/vue-mount-plugin/issues).
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
[MIT](LICENSE)
|
|
45
|
+
|
|
46
|
+
[npm-image]: https://img.shields.io/npm/v/vue-mount-plugin.svg?style=flat-square
|
|
47
|
+
[npm-url]: https://npmjs.org/package/vue-mount-plugin
|
|
48
|
+
[codacy-image]: https://app.codacy.com/project/badge/Grade/f70d4880e4ad4f40aa970eb9ee9d0696
|
|
49
|
+
[codacy-url]: https://www.codacy.com/gh/saqqdy/vue-mount-plugin/dashboard?utm_source=github.com&utm_medium=referral&utm_content=saqqdy/vue-mount-plugin&utm_campaign=Badge_Grade
|
|
50
|
+
[codecov-image]: https://img.shields.io/codecov/c/github/saqqdy/vue-mount-plugin.svg?style=flat-square
|
|
51
|
+
[codecov-url]: https://codecov.io/github/saqqdy/vue-mount-plugin?branch=master
|
|
52
|
+
[download-image]: https://img.shields.io/npm/dm/vue-mount-plugin.svg?style=flat-square
|
|
53
|
+
[download-url]: https://npmjs.org/package/vue-mount-plugin
|
|
54
|
+
[license-image]: https://img.shields.io/badge/License-MIT-blue.svg
|
|
55
|
+
[license-url]: LICENSE
|
|
56
|
+
[sonar-image]: https://sonarcloud.io/api/project_badges/quality_gate?project=saqqdy_vue-mount-plugin
|
|
57
|
+
[sonar-url]: https://sonarcloud.io/dashboard?id=saqqdy_vue-mount-plugin
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* vue-mount-plugin v1.0.0-alpha.1
|
|
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
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var vueDemi = require('vue-demi');
|
|
10
|
+
|
|
11
|
+
var MountPlugin = function () {
|
|
12
|
+
function MountPlugin(component, options) {
|
|
13
|
+
if (options === void 0) {
|
|
14
|
+
options = {};
|
|
15
|
+
}
|
|
16
|
+
this.vNode = null;
|
|
17
|
+
this.seed = 1;
|
|
18
|
+
if (options.target) this.target = options.target;else {
|
|
19
|
+
this.target = document.createElement('div');
|
|
20
|
+
document.body.appendChild(this.target);
|
|
21
|
+
}
|
|
22
|
+
this.vNode = this.createVM(component, options);
|
|
23
|
+
}
|
|
24
|
+
MountPlugin.prototype.createVM = function (component, _a) {
|
|
25
|
+
var _b = _a === void 0 ? {} : _a,
|
|
26
|
+
props = _b.props,
|
|
27
|
+
children = _b.children,
|
|
28
|
+
app = _b.app,
|
|
29
|
+
context = _b.context;
|
|
30
|
+
var vNode;
|
|
31
|
+
if (vueDemi.isVue2) {
|
|
32
|
+
var VueConstructor = vueDemi.Vue2.extend(Object.assign({}, context || {}, component));
|
|
33
|
+
vNode = new VueConstructor({
|
|
34
|
+
el: this.target,
|
|
35
|
+
propsData: props
|
|
36
|
+
});
|
|
37
|
+
vNode.id = 'captcha' + this.seed++;
|
|
38
|
+
return vNode;
|
|
39
|
+
} else {
|
|
40
|
+
vNode = vueDemi.createVNode(component, props, children);
|
|
41
|
+
if (app === null || app === void 0 ? void 0 : app._context) vNode.appContext = app._context;
|
|
42
|
+
return vNode;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
MountPlugin.prototype.mount = function () {
|
|
46
|
+
if (vueDemi.isVue2) {
|
|
47
|
+
this.vNode && this.vNode.$mount();
|
|
48
|
+
} else {
|
|
49
|
+
vueDemi.render(this.vNode, this.target);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
MountPlugin.prototype.destroy = function () {
|
|
53
|
+
if (vueDemi.isVue2) {
|
|
54
|
+
this.vNode.$destroy();
|
|
55
|
+
document.body.removeChild(this.vNode.$el);
|
|
56
|
+
this.vNode = null;
|
|
57
|
+
} else {
|
|
58
|
+
vueDemi.render(null, this.target);
|
|
59
|
+
document.body.removeChild(this.target);
|
|
60
|
+
this.vNode = null;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
return MountPlugin;
|
|
64
|
+
}();
|
|
65
|
+
|
|
66
|
+
module.exports = MountPlugin;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { App } from 'vue-demi';
|
|
2
|
+
import { createVNode } from 'vue-demi';
|
|
3
|
+
import type { VNode } from 'vue-demi';
|
|
4
|
+
import type { VNodeProps } from 'vue-demi';
|
|
5
|
+
import { Vue2 } from 'vue-demi';
|
|
6
|
+
|
|
7
|
+
export declare type Component = CreateVNodeParameters['0'];
|
|
8
|
+
|
|
9
|
+
export declare type CreateVNodeParameters = Parameters<typeof createVNode>;
|
|
10
|
+
|
|
11
|
+
export declare type Data = Record<string, unknown>;
|
|
12
|
+
|
|
13
|
+
declare class MountPlugin {
|
|
14
|
+
vNode: VNode | typeof Vue2 | null;
|
|
15
|
+
target: Element | ShadowRoot;
|
|
16
|
+
seed: number;
|
|
17
|
+
constructor(component: Component, options?: Options);
|
|
18
|
+
createVM(component: Component, { props, children, app, context }?: Options): any;
|
|
19
|
+
mount(): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
}
|
|
22
|
+
export default MountPlugin;
|
|
23
|
+
|
|
24
|
+
export declare interface Options {
|
|
25
|
+
props?: (Data & VNodeProps) | null;
|
|
26
|
+
children?: unknown;
|
|
27
|
+
patchFlag?: number;
|
|
28
|
+
dynamicProps?: string[] | null;
|
|
29
|
+
isBlockNode?: boolean;
|
|
30
|
+
target?: Element | ShadowRoot;
|
|
31
|
+
app?: App;
|
|
32
|
+
context?: Data & {
|
|
33
|
+
router: unknown;
|
|
34
|
+
store: unknown;
|
|
35
|
+
i18n: unknown;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { }
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* vue-mount-plugin v1.0.0-alpha.1
|
|
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
|
+
import { isVue2, Vue2, createVNode, render } from 'vue-demi';
|
|
8
|
+
|
|
9
|
+
var MountPlugin = function () {
|
|
10
|
+
function MountPlugin(component, options) {
|
|
11
|
+
if (options === void 0) {
|
|
12
|
+
options = {};
|
|
13
|
+
}
|
|
14
|
+
this.vNode = null;
|
|
15
|
+
this.seed = 1;
|
|
16
|
+
if (options.target) this.target = options.target;else {
|
|
17
|
+
this.target = document.createElement('div');
|
|
18
|
+
document.body.appendChild(this.target);
|
|
19
|
+
}
|
|
20
|
+
this.vNode = this.createVM(component, options);
|
|
21
|
+
}
|
|
22
|
+
MountPlugin.prototype.createVM = function (component, _a) {
|
|
23
|
+
var _b = _a === void 0 ? {} : _a,
|
|
24
|
+
props = _b.props,
|
|
25
|
+
children = _b.children,
|
|
26
|
+
app = _b.app,
|
|
27
|
+
context = _b.context;
|
|
28
|
+
var vNode;
|
|
29
|
+
if (isVue2) {
|
|
30
|
+
var VueConstructor = Vue2.extend(Object.assign({}, context || {}, component));
|
|
31
|
+
vNode = new VueConstructor({
|
|
32
|
+
el: this.target,
|
|
33
|
+
propsData: props
|
|
34
|
+
});
|
|
35
|
+
vNode.id = 'captcha' + this.seed++;
|
|
36
|
+
return vNode;
|
|
37
|
+
} else {
|
|
38
|
+
vNode = createVNode(component, props, children);
|
|
39
|
+
if (app === null || app === void 0 ? void 0 : app._context) vNode.appContext = app._context;
|
|
40
|
+
return vNode;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
MountPlugin.prototype.mount = function () {
|
|
44
|
+
if (isVue2) {
|
|
45
|
+
this.vNode && this.vNode.$mount();
|
|
46
|
+
} else {
|
|
47
|
+
render(this.vNode, this.target);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
MountPlugin.prototype.destroy = function () {
|
|
51
|
+
if (isVue2) {
|
|
52
|
+
this.vNode.$destroy();
|
|
53
|
+
document.body.removeChild(this.vNode.$el);
|
|
54
|
+
this.vNode = null;
|
|
55
|
+
} else {
|
|
56
|
+
render(null, this.target);
|
|
57
|
+
document.body.removeChild(this.target);
|
|
58
|
+
this.vNode = null;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
return MountPlugin;
|
|
62
|
+
}();
|
|
63
|
+
|
|
64
|
+
export { MountPlugin as default };
|
package/package.json
CHANGED
|
@@ -1,29 +1,136 @@
|
|
|
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
|
-
|
|
2
|
+
"name": "vue-mount-plugin",
|
|
3
|
+
"description": "A simple and easy to use vue instance extension plugin that supports vue2.0 and vue3.0",
|
|
4
|
+
"version": "1.0.0-alpha.1",
|
|
5
|
+
"packageManager": "pnpm@7.26.1",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"typings": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"require": "./dist/index.cjs",
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"./*": "./*"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"es",
|
|
19
|
+
"lib"
|
|
20
|
+
],
|
|
21
|
+
"directories": {
|
|
22
|
+
"dist": "dist",
|
|
23
|
+
"es": "es",
|
|
24
|
+
"lib": "lib",
|
|
25
|
+
"src": "src"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "run-s clean build:{bundle,types,docs} roll-types",
|
|
29
|
+
"build:bundle": "rollup -c build/rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
30
|
+
"build:types": "tsc --emitDeclarationOnly --outDir temp -p src",
|
|
31
|
+
"build:docs": "rimraf docs && typedoc && prettier --write \"**/*.md\"",
|
|
32
|
+
"roll-types": "api-extractor run && rimraf temp",
|
|
33
|
+
"watch": "pnpm build:bundle -w",
|
|
34
|
+
"pub": "tscjs scripts/publish",
|
|
35
|
+
"unpub": "tscjs scripts/unpublish",
|
|
36
|
+
"sync": "tscjs scripts/sync",
|
|
37
|
+
"workflow:publish-test": "zx scripts/workflow.mjs",
|
|
38
|
+
"clean": "rimraf dist",
|
|
39
|
+
"dist": "run-s clean build",
|
|
40
|
+
"test-unit": "jest --filter ./scripts/filter-unit.js",
|
|
41
|
+
"test:2": "vue-demi-switch 2 vue2 && jest",
|
|
42
|
+
"test:3": "vue-demi-switch 3 && jest",
|
|
43
|
+
"jest": "cross-env NODE_OPTIONS=--experimental-vm-modules npx jest --coverage",
|
|
44
|
+
"coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
|
|
45
|
+
"eslint": "eslint --fix .",
|
|
46
|
+
"prettier": "prettier --write \"**/*.{js,ts,jsx,tsx,yml,json,md}\""
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"core-js": "^3.27.2",
|
|
50
|
+
"js-cool": "^2.8.0",
|
|
51
|
+
"vue-demi": "^0.13.11"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@babel/core": "^7.20.12",
|
|
55
|
+
"@babel/preset-env": "^7.20.2",
|
|
56
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
57
|
+
"@eslint-sets/eslint-config-ts": "^4.2.1",
|
|
58
|
+
"@microsoft/api-extractor": "^7.34.2",
|
|
59
|
+
"@rollup/plugin-alias": "^4.0.3",
|
|
60
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
61
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
62
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
63
|
+
"@rollup/plugin-typescript": "^11.0.0",
|
|
64
|
+
"@types/jest": "^29.4.0",
|
|
65
|
+
"@types/node": "^18.11.18",
|
|
66
|
+
"chalk": "^5.2.0",
|
|
67
|
+
"coveralls": "^3.1.1",
|
|
68
|
+
"cross-env": "^7.0.3",
|
|
69
|
+
"eslint": "^8.33.0",
|
|
70
|
+
"fast-glob": "^3.2.12",
|
|
71
|
+
"jest": "^29.4.1",
|
|
72
|
+
"load-yml": "^1.2.0",
|
|
73
|
+
"npm-run-all": "^4.1.5",
|
|
74
|
+
"prettier": "^2.8.3",
|
|
75
|
+
"prettier-config-common": "^1.3.0",
|
|
76
|
+
"reinstaller": "^2.3.0",
|
|
77
|
+
"rimraf": "^4.1.2",
|
|
78
|
+
"rollup": "^3.13.0",
|
|
79
|
+
"rollup-plugin-filesize": "^9.1.2",
|
|
80
|
+
"rollup-plugin-visualizer": "^5.9.0",
|
|
81
|
+
"ts-jest": "^29.0.5",
|
|
82
|
+
"tsnd": "^1.1.0",
|
|
83
|
+
"typedoc": "^0.23.24",
|
|
84
|
+
"typedoc-plugin-markdown": "^3.14.0",
|
|
85
|
+
"typescript": "^4.9.5",
|
|
86
|
+
"vue": "^3.2.47",
|
|
87
|
+
"vue2": "npm:vue@2",
|
|
88
|
+
"zx": "^7.1.1"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"@vue/composition-api": ">=1.0.0",
|
|
92
|
+
"core-js": ">= 3",
|
|
93
|
+
"js-cool": ">= 2",
|
|
94
|
+
"vue": "^2.0.0 || >=3.0.0"
|
|
95
|
+
},
|
|
96
|
+
"peerDependenciesMeta": {
|
|
97
|
+
"@vue/composition-api": {
|
|
98
|
+
"optional": true
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
"pnpm": {
|
|
102
|
+
"peerDependencyRules": {
|
|
103
|
+
"ignoreMissing": [
|
|
104
|
+
"tslib",
|
|
105
|
+
"webpack"
|
|
106
|
+
],
|
|
107
|
+
"allowedVersions": {
|
|
108
|
+
"eslint": "^8.0.0"
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
"keywords": [
|
|
113
|
+
"vue",
|
|
114
|
+
"vue2.0",
|
|
115
|
+
"vue3.0",
|
|
116
|
+
"vue-extend",
|
|
117
|
+
"mount-plugin",
|
|
118
|
+
"vue-plugin",
|
|
119
|
+
"vue-mount-plugin",
|
|
120
|
+
"saqqdy"
|
|
121
|
+
],
|
|
122
|
+
"license": "MIT",
|
|
123
|
+
"author": "saqqdy <https://github.com/saqqdy>",
|
|
124
|
+
"homepage": "https://github.com/saqqdy/vue-mount-plugin#readme",
|
|
125
|
+
"bugs": {
|
|
126
|
+
"url": "https://github.com/saqqdy/vue-mount-plugin/issues"
|
|
127
|
+
},
|
|
128
|
+
"repository": {
|
|
129
|
+
"type": "git",
|
|
130
|
+
"url": "git+https://github.com/saqqdy/vue-mount-plugin.git"
|
|
131
|
+
},
|
|
132
|
+
"publishConfig": {
|
|
133
|
+
"registry": "https://registry.npmjs.org",
|
|
134
|
+
"access": "public"
|
|
135
|
+
}
|
|
29
136
|
}
|
package/index.js
DELETED
|
File without changes
|