├── .gitignore
├── .prettierrc.js
├── .vscode
└── settings.json
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
├── scripts
├── banner.js
└── build.js
├── src
├── index.ts
├── utils.ts
├── vue-router.ts
└── vuex.ts
└── tsconfig.json
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | dist
3 | .DS_Store
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | tabWidth: 4,
3 | semi: true,
4 | singleQuote: true,
5 | trailingComma: 'es5',
6 | };
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.formatOnSave": true,
3 | "editor.codeActionsOnSave": {
4 | "source.fixAll.eslint": false,
5 | "source.fixAll.stylelint": false
6 | },
7 | "editor.defaultFormatter": "esbenp.prettier-vscode",
8 | "editor.detectIndentation": false,
9 | "editor.guides.bracketPairs": true,
10 | "editor.linkedEditing": true,
11 | "editor.tabSize": 4,
12 | "eslint.enable": false,
13 | "prettier.enable": true,
14 | "stylelint.enable": false,
15 | "files.associations": {
16 | "*.wxml": "html",
17 | "*.wxss": "css"
18 | },
19 | "files.exclude": {
20 | "**/CVS": true,
21 | "**/.DS_Store": true,
22 | "**/.ds": true,
23 | "**/.git": true,
24 | "**/.hg": true,
25 | "**/.svn": true,
26 | "**/.theia": true
27 | },
28 | "[javascript]": {
29 | "editor.defaultFormatter": "esbenp.prettier-vscode"
30 | },
31 | "[typescript]": {
32 | "editor.defaultFormatter": "esbenp.prettier-vscode"
33 | },
34 | "[json]": {
35 | "editor.defaultFormatter": "esbenp.prettier-vscode"
36 | },
37 | "[jsonc]": {
38 | "editor.defaultFormatter": "esbenp.prettier-vscode"
39 | },
40 | "[css]": {
41 | "editor.defaultFormatter": "esbenp.prettier-vscode"
42 | },
43 | "[less]": {
44 | "editor.defaultFormatter": "esbenp.prettier-vscode"
45 | },
46 | "[scss]": {
47 | "editor.defaultFormatter": "esbenp.prettier-vscode"
48 | },
49 | "[html]": {
50 | "editor.defaultFormatter": "esbenp.prettier-vscode"
51 | },
52 | "[markdown]": {
53 | "editor.formatOnSave": false
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2021 Ambit Tsai
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vue2 Helpers
2 | A util package to use Vue 2 with Composition API easily.
3 |
4 | > NOTE:
5 | > - vue2-helpers@**1** is for vue2.5 and 2.6
6 | > - vue2-helpers@**2** is for vue2.7
7 |
8 |
9 | ## ⬇️ Install
10 | ```
11 | npm i -S vue2-helpers
12 | ```
13 |
14 | ## 📃 Usage
15 | ```javascript
16 | import { createVuexHelpers } from 'vue2-helpers';
17 | import { useRouter } from 'vue2-helpers/vue-router';
18 |
19 | const { useState } = createVuexHelpers<
20 | RootState, RootGetters, RootMutations, RootActions
21 | >();
22 | // Get a reactive and mutable ref object "stateA"
23 | const { stateA } = useState('module', ['stateA']);
24 |
25 | const router = useRouter();
26 | router.push('/login');
27 | ```
28 |
29 |
30 | ## ✨ API
31 | ### vue2-helpers
32 | |Features|Description|
33 | |-|-|
34 | |`createVuexHelpers`<
RootState, RootGetters, RootMutations, RootActions
>(): {
`useState`, `useGetters`, `useMutations`, `useActions`
}|The helper methods in return value are
used to replace `mapState`, `mapGetters`,
`mapMutations`, `mapActions`|
35 |
36 | ### vue2-helpers/vuex
37 | |Features|Description|
38 | |-|-|
39 | |`createStore`<S>(options: StoreOptions<S>): Store<S>||
40 | |`useStore`<S = any>(): Store<S>|
41 |
42 | ### vue2-helpers/vue-router
43 | |Features|Description|
44 | |-|-|
45 | |`createRouter`(options: RouterOptions): Router||
46 | |`onBeforeRouteLeave`(leaveGuard: NavigationGuard): void||
47 | |`onBeforeRouteUpdate`(updateGuard: NavigationGuard): void||
48 | |`useRoute`(): RouteLocationNormalized||
49 | |`useRouter`(): Router||
50 | |router.`isReady`(): Promise\||
51 |
52 |
53 | ## ☎️ Contact
54 | 1. WeChat: cai_fanwei
55 | 1. QQ Group: 663286147
56 | 1. E-mail: ambit_tsai@qq.com
57 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue2-helpers",
3 | "version": "2.1.0",
4 | "lockfileVersion": 2,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "version": "2.1.0",
9 | "license": "Apache-2.0",
10 | "devDependencies": {
11 | "@rollup/plugin-typescript": "^8.3.3",
12 | "rollup": "^2.77.0",
13 | "rollup-plugin-terser": "^7.0.2",
14 | "typescript": "^4.7.4",
15 | "vue": "~2.7.0",
16 | "vue-router": "^3.5.4",
17 | "vuex": "^3.6.2"
18 | },
19 | "peerDependencies": {
20 | "vue": "~2.7.0",
21 | "vue-router": "^3",
22 | "vuex": "^3"
23 | },
24 | "peerDependenciesMeta": {
25 | "vue-router": {
26 | "optional": true
27 | },
28 | "vuex": {
29 | "optional": true
30 | }
31 | }
32 | },
33 | "node_modules/@babel/code-frame": {
34 | "version": "7.14.5",
35 | "integrity": "sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw==",
36 | "dev": true,
37 | "dependencies": {
38 | "@babel/highlight": "^7.14.5"
39 | },
40 | "engines": {
41 | "node": ">=6.9.0"
42 | }
43 | },
44 | "node_modules/@babel/helper-validator-identifier": {
45 | "version": "7.14.8",
46 | "integrity": "sha512-ZGy6/XQjllhYQrNw/3zfWRwZCTVSiBLZ9DHVZxn9n2gip/7ab8mv2TWlKPIBk26RwedCBoWdjLmn+t9na2Gcow==",
47 | "dev": true,
48 | "engines": {
49 | "node": ">=6.9.0"
50 | }
51 | },
52 | "node_modules/@babel/highlight": {
53 | "version": "7.14.5",
54 | "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==",
55 | "dev": true,
56 | "dependencies": {
57 | "@babel/helper-validator-identifier": "^7.14.5",
58 | "chalk": "^2.0.0",
59 | "js-tokens": "^4.0.0"
60 | },
61 | "engines": {
62 | "node": ">=6.9.0"
63 | }
64 | },
65 | "node_modules/@babel/parser": {
66 | "version": "7.19.1",
67 | "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.19.1.tgz",
68 | "integrity": "sha512-h7RCSorm1DdTVGJf3P2Mhj3kdnkmF/EiysUkzS2TdgAYqyjFdMQJbVuXOBej2SBJaXan/lIVtT6KkGbyyq753A==",
69 | "dev": true,
70 | "bin": {
71 | "parser": "bin/babel-parser.js"
72 | },
73 | "engines": {
74 | "node": ">=6.0.0"
75 | }
76 | },
77 | "node_modules/@rollup/plugin-typescript": {
78 | "version": "8.5.0",
79 | "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz",
80 | "integrity": "sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==",
81 | "dev": true,
82 | "dependencies": {
83 | "@rollup/pluginutils": "^3.1.0",
84 | "resolve": "^1.17.0"
85 | },
86 | "engines": {
87 | "node": ">=8.0.0"
88 | },
89 | "peerDependencies": {
90 | "rollup": "^2.14.0",
91 | "tslib": "*",
92 | "typescript": ">=3.7.0"
93 | },
94 | "peerDependenciesMeta": {
95 | "tslib": {
96 | "optional": true
97 | }
98 | }
99 | },
100 | "node_modules/@rollup/pluginutils": {
101 | "version": "3.1.0",
102 | "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==",
103 | "dev": true,
104 | "dependencies": {
105 | "@types/estree": "0.0.39",
106 | "estree-walker": "^1.0.1",
107 | "picomatch": "^2.2.2"
108 | },
109 | "engines": {
110 | "node": ">= 8.0.0"
111 | },
112 | "peerDependencies": {
113 | "rollup": "^1.20.0||^2.0.0"
114 | }
115 | },
116 | "node_modules/@types/estree": {
117 | "version": "0.0.39",
118 | "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
119 | "dev": true
120 | },
121 | "node_modules/@types/node": {
122 | "version": "16.4.1",
123 | "integrity": "sha512-UW7cbLqf/Wu5XH2RKKY1cHwUNLicIDRLMraYKz+HHAerJ0ZffUEk+fMnd8qU2JaS6cAy0r8tsaf7yqHASf/Y0Q==",
124 | "dev": true
125 | },
126 | "node_modules/@vue/compiler-sfc": {
127 | "version": "2.7.10",
128 | "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.10.tgz",
129 | "integrity": "sha512-55Shns6WPxlYsz4WX7q9ZJBL77sKE1ZAYNYStLs6GbhIOMrNtjMvzcob6gu3cGlfpCR4bT7NXgyJ3tly2+Hx8Q==",
130 | "dev": true,
131 | "dependencies": {
132 | "@babel/parser": "^7.18.4",
133 | "postcss": "^8.4.14",
134 | "source-map": "^0.6.1"
135 | }
136 | },
137 | "node_modules/@vue/compiler-sfc/node_modules/source-map": {
138 | "version": "0.6.1",
139 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
140 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
141 | "dev": true,
142 | "engines": {
143 | "node": ">=0.10.0"
144 | }
145 | },
146 | "node_modules/ansi-styles": {
147 | "version": "3.2.1",
148 | "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
149 | "dev": true,
150 | "dependencies": {
151 | "color-convert": "^1.9.0"
152 | },
153 | "engines": {
154 | "node": ">=4"
155 | }
156 | },
157 | "node_modules/buffer-from": {
158 | "version": "1.1.1",
159 | "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
160 | "dev": true
161 | },
162 | "node_modules/chalk": {
163 | "version": "2.4.2",
164 | "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
165 | "dev": true,
166 | "dependencies": {
167 | "ansi-styles": "^3.2.1",
168 | "escape-string-regexp": "^1.0.5",
169 | "supports-color": "^5.3.0"
170 | },
171 | "engines": {
172 | "node": ">=4"
173 | }
174 | },
175 | "node_modules/color-convert": {
176 | "version": "1.9.3",
177 | "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
178 | "dev": true,
179 | "dependencies": {
180 | "color-name": "1.1.3"
181 | }
182 | },
183 | "node_modules/color-name": {
184 | "version": "1.1.3",
185 | "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==",
186 | "dev": true
187 | },
188 | "node_modules/commander": {
189 | "version": "2.20.3",
190 | "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
191 | "dev": true
192 | },
193 | "node_modules/csstype": {
194 | "version": "3.1.1",
195 | "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
196 | "integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==",
197 | "dev": true
198 | },
199 | "node_modules/escape-string-regexp": {
200 | "version": "1.0.5",
201 | "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==",
202 | "dev": true,
203 | "engines": {
204 | "node": ">=0.8.0"
205 | }
206 | },
207 | "node_modules/estree-walker": {
208 | "version": "1.0.1",
209 | "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==",
210 | "dev": true
211 | },
212 | "node_modules/fsevents": {
213 | "version": "2.3.2",
214 | "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
215 | "dev": true,
216 | "hasInstallScript": true,
217 | "optional": true,
218 | "os": [
219 | "darwin"
220 | ],
221 | "engines": {
222 | "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
223 | }
224 | },
225 | "node_modules/function-bind": {
226 | "version": "1.1.1",
227 | "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
228 | "dev": true
229 | },
230 | "node_modules/has": {
231 | "version": "1.0.3",
232 | "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
233 | "dev": true,
234 | "dependencies": {
235 | "function-bind": "^1.1.1"
236 | },
237 | "engines": {
238 | "node": ">= 0.4.0"
239 | }
240 | },
241 | "node_modules/has-flag": {
242 | "version": "3.0.0",
243 | "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
244 | "dev": true,
245 | "engines": {
246 | "node": ">=4"
247 | }
248 | },
249 | "node_modules/is-core-module": {
250 | "version": "2.5.0",
251 | "integrity": "sha512-TXCMSDsEHMEEZ6eCA8rwRDbLu55MRGmrctljsBX/2v1d9/GzqHOxW5c5oPSgrUt2vBFXebu9rGqckXGPWOlYpg==",
252 | "dev": true,
253 | "dependencies": {
254 | "has": "^1.0.3"
255 | },
256 | "funding": {
257 | "url": "https://github.com/sponsors/ljharb"
258 | }
259 | },
260 | "node_modules/jest-worker": {
261 | "version": "26.6.2",
262 | "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==",
263 | "dev": true,
264 | "dependencies": {
265 | "@types/node": "*",
266 | "merge-stream": "^2.0.0",
267 | "supports-color": "^7.0.0"
268 | },
269 | "engines": {
270 | "node": ">= 10.13.0"
271 | }
272 | },
273 | "node_modules/jest-worker/node_modules/has-flag": {
274 | "version": "4.0.0",
275 | "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
276 | "dev": true,
277 | "engines": {
278 | "node": ">=8"
279 | }
280 | },
281 | "node_modules/jest-worker/node_modules/supports-color": {
282 | "version": "7.2.0",
283 | "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
284 | "dev": true,
285 | "dependencies": {
286 | "has-flag": "^4.0.0"
287 | },
288 | "engines": {
289 | "node": ">=8"
290 | }
291 | },
292 | "node_modules/js-tokens": {
293 | "version": "4.0.0",
294 | "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
295 | "dev": true
296 | },
297 | "node_modules/merge-stream": {
298 | "version": "2.0.0",
299 | "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
300 | "dev": true
301 | },
302 | "node_modules/nanoid": {
303 | "version": "3.3.4",
304 | "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
305 | "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
306 | "dev": true,
307 | "bin": {
308 | "nanoid": "bin/nanoid.cjs"
309 | },
310 | "engines": {
311 | "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
312 | }
313 | },
314 | "node_modules/path-parse": {
315 | "version": "1.0.7",
316 | "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
317 | "dev": true
318 | },
319 | "node_modules/picocolors": {
320 | "version": "1.0.0",
321 | "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
322 | "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
323 | "dev": true
324 | },
325 | "node_modules/picomatch": {
326 | "version": "2.3.0",
327 | "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==",
328 | "dev": true,
329 | "engines": {
330 | "node": ">=8.6"
331 | },
332 | "funding": {
333 | "url": "https://github.com/sponsors/jonschlinkert"
334 | }
335 | },
336 | "node_modules/postcss": {
337 | "version": "8.4.16",
338 | "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz",
339 | "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==",
340 | "dev": true,
341 | "funding": [
342 | {
343 | "type": "opencollective",
344 | "url": "https://opencollective.com/postcss/"
345 | },
346 | {
347 | "type": "tidelift",
348 | "url": "https://tidelift.com/funding/github/npm/postcss"
349 | }
350 | ],
351 | "dependencies": {
352 | "nanoid": "^3.3.4",
353 | "picocolors": "^1.0.0",
354 | "source-map-js": "^1.0.2"
355 | },
356 | "engines": {
357 | "node": "^10 || ^12 || >=14"
358 | }
359 | },
360 | "node_modules/randombytes": {
361 | "version": "2.1.0",
362 | "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
363 | "dev": true,
364 | "dependencies": {
365 | "safe-buffer": "^5.1.0"
366 | }
367 | },
368 | "node_modules/resolve": {
369 | "version": "1.20.0",
370 | "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==",
371 | "dev": true,
372 | "dependencies": {
373 | "is-core-module": "^2.2.0",
374 | "path-parse": "^1.0.6"
375 | },
376 | "funding": {
377 | "url": "https://github.com/sponsors/ljharb"
378 | }
379 | },
380 | "node_modules/rollup": {
381 | "version": "2.79.0",
382 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.0.tgz",
383 | "integrity": "sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==",
384 | "dev": true,
385 | "bin": {
386 | "rollup": "dist/bin/rollup"
387 | },
388 | "engines": {
389 | "node": ">=10.0.0"
390 | },
391 | "optionalDependencies": {
392 | "fsevents": "~2.3.2"
393 | }
394 | },
395 | "node_modules/rollup-plugin-terser": {
396 | "version": "7.0.2",
397 | "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==",
398 | "dev": true,
399 | "dependencies": {
400 | "@babel/code-frame": "^7.10.4",
401 | "jest-worker": "^26.2.1",
402 | "serialize-javascript": "^4.0.0",
403 | "terser": "^5.0.0"
404 | },
405 | "peerDependencies": {
406 | "rollup": "^2.0.0"
407 | }
408 | },
409 | "node_modules/safe-buffer": {
410 | "version": "5.2.1",
411 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
412 | "dev": true,
413 | "funding": [
414 | {
415 | "type": "github",
416 | "url": "https://github.com/sponsors/feross"
417 | },
418 | {
419 | "type": "patreon",
420 | "url": "https://www.patreon.com/feross"
421 | },
422 | {
423 | "type": "consulting",
424 | "url": "https://feross.org/support"
425 | }
426 | ]
427 | },
428 | "node_modules/serialize-javascript": {
429 | "version": "4.0.0",
430 | "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==",
431 | "dev": true,
432 | "dependencies": {
433 | "randombytes": "^2.1.0"
434 | }
435 | },
436 | "node_modules/source-map": {
437 | "version": "0.7.3",
438 | "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
439 | "dev": true,
440 | "engines": {
441 | "node": ">= 8"
442 | }
443 | },
444 | "node_modules/source-map-js": {
445 | "version": "1.0.2",
446 | "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
447 | "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
448 | "dev": true,
449 | "engines": {
450 | "node": ">=0.10.0"
451 | }
452 | },
453 | "node_modules/source-map-support": {
454 | "version": "0.5.19",
455 | "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==",
456 | "dev": true,
457 | "dependencies": {
458 | "buffer-from": "^1.0.0",
459 | "source-map": "^0.6.0"
460 | }
461 | },
462 | "node_modules/source-map-support/node_modules/source-map": {
463 | "version": "0.6.1",
464 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
465 | "dev": true,
466 | "engines": {
467 | "node": ">=0.10.0"
468 | }
469 | },
470 | "node_modules/supports-color": {
471 | "version": "5.5.0",
472 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
473 | "dev": true,
474 | "dependencies": {
475 | "has-flag": "^3.0.0"
476 | },
477 | "engines": {
478 | "node": ">=4"
479 | }
480 | },
481 | "node_modules/terser": {
482 | "version": "5.7.1",
483 | "integrity": "sha512-b3e+d5JbHAe/JSjwsC3Zn55wsBIM7AsHLjKxT31kGCldgbpFePaFo+PiddtO6uwRZWRw7sPXmAN8dTW61xmnSg==",
484 | "dev": true,
485 | "dependencies": {
486 | "commander": "^2.20.0",
487 | "source-map": "~0.7.2",
488 | "source-map-support": "~0.5.19"
489 | },
490 | "bin": {
491 | "terser": "bin/terser"
492 | },
493 | "engines": {
494 | "node": ">=10"
495 | }
496 | },
497 | "node_modules/tslib": {
498 | "version": "2.3.0",
499 | "integrity": "sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==",
500 | "dev": true,
501 | "optional": true,
502 | "peer": true
503 | },
504 | "node_modules/typescript": {
505 | "version": "4.8.3",
506 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
507 | "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
508 | "dev": true,
509 | "bin": {
510 | "tsc": "bin/tsc",
511 | "tsserver": "bin/tsserver"
512 | },
513 | "engines": {
514 | "node": ">=4.2.0"
515 | }
516 | },
517 | "node_modules/vue": {
518 | "version": "2.7.10",
519 | "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.10.tgz",
520 | "integrity": "sha512-HmFC70qarSHPXcKtW8U8fgIkF6JGvjEmDiVInTkKZP0gIlEPhlVlcJJLkdGIDiNkIeA2zJPQTWJUI4iWe+AVfg==",
521 | "dev": true,
522 | "dependencies": {
523 | "@vue/compiler-sfc": "2.7.10",
524 | "csstype": "^3.1.0"
525 | }
526 | },
527 | "node_modules/vue-router": {
528 | "version": "3.6.5",
529 | "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.6.5.tgz",
530 | "integrity": "sha512-VYXZQLtjuvKxxcshuRAwjHnciqZVoXAjTjcqBTz4rKc8qih9g9pI3hbDjmqXaHdgL3v8pV6P8Z335XvHzESxLQ==",
531 | "dev": true
532 | },
533 | "node_modules/vuex": {
534 | "version": "3.6.2",
535 | "integrity": "sha512-ETW44IqCgBpVomy520DT5jf8n0zoCac+sxWnn+hMe/CzaSejb/eVw2YToiXYX+Ex/AuHHia28vWTq4goAexFbw==",
536 | "dev": true,
537 | "peerDependencies": {
538 | "vue": "^2.0.0"
539 | }
540 | }
541 | },
542 | "dependencies": {
543 | "@babel/code-frame": {
544 | "version": "7.14.5",
545 | "dev": true,
546 | "requires": {
547 | "@babel/highlight": "^7.14.5"
548 | }
549 | },
550 | "@babel/helper-validator-identifier": {
551 | "version": "7.14.8",
552 | "dev": true
553 | },
554 | "@babel/highlight": {
555 | "version": "7.14.5",
556 | "dev": true,
557 | "requires": {
558 | "@babel/helper-validator-identifier": "^7.14.5",
559 | "chalk": "^2.0.0",
560 | "js-tokens": "^4.0.0"
561 | }
562 | },
563 | "@babel/parser": {
564 | "version": "7.19.1",
565 | "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.19.1.tgz",
566 | "integrity": "sha512-h7RCSorm1DdTVGJf3P2Mhj3kdnkmF/EiysUkzS2TdgAYqyjFdMQJbVuXOBej2SBJaXan/lIVtT6KkGbyyq753A==",
567 | "dev": true
568 | },
569 | "@rollup/plugin-typescript": {
570 | "version": "8.5.0",
571 | "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.5.0.tgz",
572 | "integrity": "sha512-wMv1/scv0m/rXx21wD2IsBbJFba8wGF3ErJIr6IKRfRj49S85Lszbxb4DCo8iILpluTjk2GAAu9CoZt4G3ppgQ==",
573 | "dev": true,
574 | "requires": {
575 | "@rollup/pluginutils": "^3.1.0",
576 | "resolve": "^1.17.0"
577 | }
578 | },
579 | "@rollup/pluginutils": {
580 | "version": "3.1.0",
581 | "dev": true,
582 | "requires": {
583 | "@types/estree": "0.0.39",
584 | "estree-walker": "^1.0.1",
585 | "picomatch": "^2.2.2"
586 | }
587 | },
588 | "@types/estree": {
589 | "version": "0.0.39",
590 | "dev": true
591 | },
592 | "@types/node": {
593 | "version": "16.4.1",
594 | "dev": true
595 | },
596 | "@vue/compiler-sfc": {
597 | "version": "2.7.10",
598 | "resolved": "https://registry.npmjs.org/@vue/compiler-sfc/-/compiler-sfc-2.7.10.tgz",
599 | "integrity": "sha512-55Shns6WPxlYsz4WX7q9ZJBL77sKE1ZAYNYStLs6GbhIOMrNtjMvzcob6gu3cGlfpCR4bT7NXgyJ3tly2+Hx8Q==",
600 | "dev": true,
601 | "requires": {
602 | "@babel/parser": "^7.18.4",
603 | "postcss": "^8.4.14",
604 | "source-map": "^0.6.1"
605 | },
606 | "dependencies": {
607 | "source-map": {
608 | "version": "0.6.1",
609 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
610 | "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
611 | "dev": true
612 | }
613 | }
614 | },
615 | "ansi-styles": {
616 | "version": "3.2.1",
617 | "dev": true,
618 | "requires": {
619 | "color-convert": "^1.9.0"
620 | }
621 | },
622 | "buffer-from": {
623 | "version": "1.1.1",
624 | "dev": true
625 | },
626 | "chalk": {
627 | "version": "2.4.2",
628 | "dev": true,
629 | "requires": {
630 | "ansi-styles": "^3.2.1",
631 | "escape-string-regexp": "^1.0.5",
632 | "supports-color": "^5.3.0"
633 | }
634 | },
635 | "color-convert": {
636 | "version": "1.9.3",
637 | "dev": true,
638 | "requires": {
639 | "color-name": "1.1.3"
640 | }
641 | },
642 | "color-name": {
643 | "version": "1.1.3",
644 | "dev": true
645 | },
646 | "commander": {
647 | "version": "2.20.3",
648 | "dev": true
649 | },
650 | "csstype": {
651 | "version": "3.1.1",
652 | "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.1.tgz",
653 | "integrity": "sha512-DJR/VvkAvSZW9bTouZue2sSxDwdTN92uHjqeKVm+0dAqdfNykRzQ95tay8aXMBAAPpUiq4Qcug2L7neoRh2Egw==",
654 | "dev": true
655 | },
656 | "escape-string-regexp": {
657 | "version": "1.0.5",
658 | "dev": true
659 | },
660 | "estree-walker": {
661 | "version": "1.0.1",
662 | "dev": true
663 | },
664 | "fsevents": {
665 | "version": "2.3.2",
666 | "dev": true,
667 | "optional": true
668 | },
669 | "function-bind": {
670 | "version": "1.1.1",
671 | "dev": true
672 | },
673 | "has": {
674 | "version": "1.0.3",
675 | "dev": true,
676 | "requires": {
677 | "function-bind": "^1.1.1"
678 | }
679 | },
680 | "has-flag": {
681 | "version": "3.0.0",
682 | "dev": true
683 | },
684 | "is-core-module": {
685 | "version": "2.5.0",
686 | "dev": true,
687 | "requires": {
688 | "has": "^1.0.3"
689 | }
690 | },
691 | "jest-worker": {
692 | "version": "26.6.2",
693 | "dev": true,
694 | "requires": {
695 | "@types/node": "*",
696 | "merge-stream": "^2.0.0",
697 | "supports-color": "^7.0.0"
698 | },
699 | "dependencies": {
700 | "has-flag": {
701 | "version": "4.0.0",
702 | "dev": true
703 | },
704 | "supports-color": {
705 | "version": "7.2.0",
706 | "dev": true,
707 | "requires": {
708 | "has-flag": "^4.0.0"
709 | }
710 | }
711 | }
712 | },
713 | "js-tokens": {
714 | "version": "4.0.0",
715 | "dev": true
716 | },
717 | "merge-stream": {
718 | "version": "2.0.0",
719 | "dev": true
720 | },
721 | "nanoid": {
722 | "version": "3.3.4",
723 | "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz",
724 | "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==",
725 | "dev": true
726 | },
727 | "path-parse": {
728 | "version": "1.0.7",
729 | "dev": true
730 | },
731 | "picocolors": {
732 | "version": "1.0.0",
733 | "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
734 | "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
735 | "dev": true
736 | },
737 | "picomatch": {
738 | "version": "2.3.0",
739 | "dev": true
740 | },
741 | "postcss": {
742 | "version": "8.4.16",
743 | "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.16.tgz",
744 | "integrity": "sha512-ipHE1XBvKzm5xI7hiHCZJCSugxvsdq2mPnsq5+UF+VHCjiBvtDrlxJfMBToWaP9D5XlgNmcFGqoHmUn0EYEaRQ==",
745 | "dev": true,
746 | "requires": {
747 | "nanoid": "^3.3.4",
748 | "picocolors": "^1.0.0",
749 | "source-map-js": "^1.0.2"
750 | }
751 | },
752 | "randombytes": {
753 | "version": "2.1.0",
754 | "dev": true,
755 | "requires": {
756 | "safe-buffer": "^5.1.0"
757 | }
758 | },
759 | "resolve": {
760 | "version": "1.20.0",
761 | "dev": true,
762 | "requires": {
763 | "is-core-module": "^2.2.0",
764 | "path-parse": "^1.0.6"
765 | }
766 | },
767 | "rollup": {
768 | "version": "2.79.0",
769 | "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.0.tgz",
770 | "integrity": "sha512-x4KsrCgwQ7ZJPcFA/SUu6QVcYlO7uRLfLAy0DSA4NS2eG8japdbpM50ToH7z4iObodRYOJ0soneF0iaQRJ6zhA==",
771 | "dev": true,
772 | "requires": {
773 | "fsevents": "~2.3.2"
774 | }
775 | },
776 | "rollup-plugin-terser": {
777 | "version": "7.0.2",
778 | "dev": true,
779 | "requires": {
780 | "@babel/code-frame": "^7.10.4",
781 | "jest-worker": "^26.2.1",
782 | "serialize-javascript": "^4.0.0",
783 | "terser": "^5.0.0"
784 | }
785 | },
786 | "safe-buffer": {
787 | "version": "5.2.1",
788 | "dev": true
789 | },
790 | "serialize-javascript": {
791 | "version": "4.0.0",
792 | "dev": true,
793 | "requires": {
794 | "randombytes": "^2.1.0"
795 | }
796 | },
797 | "source-map": {
798 | "version": "0.7.3",
799 | "dev": true
800 | },
801 | "source-map-js": {
802 | "version": "1.0.2",
803 | "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
804 | "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
805 | "dev": true
806 | },
807 | "source-map-support": {
808 | "version": "0.5.19",
809 | "dev": true,
810 | "requires": {
811 | "buffer-from": "^1.0.0",
812 | "source-map": "^0.6.0"
813 | },
814 | "dependencies": {
815 | "source-map": {
816 | "version": "0.6.1",
817 | "dev": true
818 | }
819 | }
820 | },
821 | "supports-color": {
822 | "version": "5.5.0",
823 | "dev": true,
824 | "requires": {
825 | "has-flag": "^3.0.0"
826 | }
827 | },
828 | "terser": {
829 | "version": "5.7.1",
830 | "dev": true,
831 | "requires": {
832 | "commander": "^2.20.0",
833 | "source-map": "~0.7.2",
834 | "source-map-support": "~0.5.19"
835 | }
836 | },
837 | "tslib": {
838 | "version": "2.3.0",
839 | "dev": true,
840 | "optional": true,
841 | "peer": true
842 | },
843 | "typescript": {
844 | "version": "4.8.3",
845 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
846 | "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
847 | "dev": true
848 | },
849 | "vue": {
850 | "version": "2.7.10",
851 | "resolved": "https://registry.npmjs.org/vue/-/vue-2.7.10.tgz",
852 | "integrity": "sha512-HmFC70qarSHPXcKtW8U8fgIkF6JGvjEmDiVInTkKZP0gIlEPhlVlcJJLkdGIDiNkIeA2zJPQTWJUI4iWe+AVfg==",
853 | "dev": true,
854 | "requires": {
855 | "@vue/compiler-sfc": "2.7.10",
856 | "csstype": "^3.1.0"
857 | }
858 | },
859 | "vue-router": {
860 | "version": "3.6.5",
861 | "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.6.5.tgz",
862 | "integrity": "sha512-VYXZQLtjuvKxxcshuRAwjHnciqZVoXAjTjcqBTz4rKc8qih9g9pI3hbDjmqXaHdgL3v8pV6P8Z335XvHzESxLQ==",
863 | "dev": true
864 | },
865 | "vuex": {
866 | "version": "3.6.2",
867 | "dev": true,
868 | "requires": {}
869 | }
870 | }
871 | }
872 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue2-helpers",
3 | "version": "2.1.0",
4 | "description": "A util package to use Vue 2 with Composition API easily",
5 | "author": {
6 | "name": "Ambit Tsai",
7 | "email": "ambit_tsai@qq.com"
8 | },
9 | "license": "Apache-2.0",
10 | "main": "index.js",
11 | "scripts": {
12 | "build": "node scripts/build.js"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "git+https://github.com/ambit-tsai/vue2-helpers.git"
17 | },
18 | "homepage": "https://github.com/ambit-tsai/vue2-helpers#readme",
19 | "bugs": {
20 | "url": "https://github.com/ambit-tsai/vue2-helpers/issues"
21 | },
22 | "peerDependencies": {
23 | "vue": "~2.7.0",
24 | "vue-router": "^3",
25 | "vuex": "^3"
26 | },
27 | "peerDependenciesMeta": {
28 | "vue-router": {
29 | "optional": true
30 | },
31 | "vuex": {
32 | "optional": true
33 | }
34 | },
35 | "devDependencies": {
36 | "@rollup/plugin-typescript": "^8.3.3",
37 | "rollup": "^2.77.0",
38 | "rollup-plugin-terser": "^7.0.2",
39 | "typescript": "^4.7.4",
40 | "vue": "~2.7.0",
41 | "vue-router": "^3.5.4",
42 | "vuex": "^3.6.2"
43 | },
44 | "keywords": [
45 | "vue",
46 | "vue2.7",
47 | "vue3",
48 | "utils",
49 | "helpers",
50 | "composition",
51 | "vuex",
52 | "vue-router"
53 | ]
54 | }
55 |
--------------------------------------------------------------------------------
/scripts/banner.js:
--------------------------------------------------------------------------------
1 | const pkg = require('../package.json');
2 |
3 | module.exports = `
4 | /**
5 | * ${pkg.name}@${pkg.version}
6 | * ${pkg.description}
7 | * @author ${pkg.author.name} <${pkg.author.email}>
8 | * @license ${pkg.license}
9 | * @see {@link ${pkg.homepage}}
10 | */`
11 |
--------------------------------------------------------------------------------
/scripts/build.js:
--------------------------------------------------------------------------------
1 | const rollup = require('rollup');
2 | const typescript = require('@rollup/plugin-typescript');
3 | const { terser } = require('rollup-plugin-terser');
4 | const banner = require('./banner');
5 | const fs = require('fs');
6 |
7 | (async () => {
8 | await compile('src/index.ts');
9 | compile('src/vuex.ts');
10 | compile('src/vue-router.ts');
11 | copyFile('package.json');
12 | copyFile('README.md');
13 | copyFile('LICENSE');
14 | })();
15 |
16 | async function compile(file) {
17 | const bundle = await rollup.rollup({
18 | input: file,
19 | external: ['vue', 'vuex', 'vue-router'],
20 | plugins: [typescript(), terser()],
21 | });
22 | await bundle.write({
23 | dir: 'dist',
24 | banner,
25 | format: 'esm',
26 | sourcemap: true,
27 | });
28 | }
29 |
30 | function copyFile(file) {
31 | fs.copyFile(file, `dist/${file}`, (err) => {
32 | if (err) console.log(err);
33 | });
34 | }
35 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';
2 | import { ComputedRef, computed, getCurrentInstance } from 'vue';
3 |
4 | type ActionReturnType any> = Promise<
5 | T extends (...args: any) => Promise ? U : ReturnType
6 | >;
7 |
8 | interface ResultMap {
9 | state: ComputedRef;
10 | getters: ComputedRef infer U ? U : never>;
11 | mutations: T extends (a: any) => any
12 | ? () => void
13 | : T extends (a: any, b: infer U) => any
14 | ? (payload: U) => void
15 | : never;
16 | actions: T extends (a: any) => any
17 | ? () => ActionReturnType
18 | : T extends (a: any, b: infer U) => any
19 | ? (payload: U) => ActionReturnType
20 | : never;
21 | }
22 |
23 | type ResultMapKey = keyof ResultMap;
24 |
25 | // TODO: 由于项目 TS 版本不支持 Template Literal Types,因此无法实现多层模块名 a/b/c 的推导
26 | type HelperReturnType = {
27 | [key in K]: ResultMap[RMK];
28 | };
29 |
30 | interface Helper {
31 | (keys: K[]): HelperReturnType;
32 |
33 | (
34 | namespace: N,
35 | keys: K[]
36 | ): HelperReturnType;
37 |
38 | (map: Record): HelperReturnType<
39 | RMK,
40 | K,
41 | RootType
42 | >;
43 |
44 | (
45 | namespace: N,
46 | map: Record
47 | ): HelperReturnType;
48 | }
49 |
50 | export function createVuexHelpers<
51 | RootState,
52 | RootGetters,
53 | RootMutations,
54 | RootActions
55 | >() {
56 | return {
57 | useState: useState as Helper<'state', RootState>,
58 | useGetters: useGetters as Helper<'getters', RootGetters>,
59 | useMutations: useMutations as Helper<'mutations', RootMutations>,
60 | useActions: useActions as Helper<'actions', RootActions>,
61 | };
62 | }
63 |
64 | function useState(...args: [any]) {
65 | const states = mapState(...args);
66 | const result: any = {};
67 | Object.keys(states).forEach((key) => {
68 | result[key] = computed(states[key]);
69 | });
70 | return result;
71 | }
72 |
73 | function useGetters(...args: [any]) {
74 | const getters = mapGetters(...args);
75 | const result: any = {};
76 | Object.keys(getters).forEach((key) => {
77 | result[key] = computed(getters[key]);
78 | });
79 | return result;
80 | }
81 |
82 | function getVueInstance() {
83 | const vm = getCurrentInstance();
84 | if (vm) {
85 | return vm.proxy;
86 | }
87 | throw new Error('helper method only works during setup or Lifecycle Hooks');
88 | }
89 |
90 | function useMutations(...args: [any]) {
91 | const vm = getVueInstance();
92 | const result: any = {};
93 | const mutations = mapMutations(...args);
94 | Object.keys(mutations).forEach((key) => {
95 | result[key] = mutations[key].bind(vm);
96 | });
97 | return result;
98 | }
99 |
100 | function useActions(...args: [any]) {
101 | const vm = getVueInstance();
102 | const result: any = {};
103 | const actions = mapActions(...args);
104 | Object.keys(actions).forEach((key) => {
105 | result[key] = actions[key].bind(vm);
106 | });
107 | return result;
108 | }
109 |
--------------------------------------------------------------------------------
/src/utils.ts:
--------------------------------------------------------------------------------
1 | export const { warn } = console;
2 |
3 | export const OUT_OF_SCOPE =
4 | 'method can only be used inside setup() or functional components';
5 |
--------------------------------------------------------------------------------
/src/vue-router.ts:
--------------------------------------------------------------------------------
1 | import Vue, { effectScope, getCurrentInstance, reactive } from 'vue';
2 | import VueRouter, {
3 | NavigationGuard,
4 | Route,
5 | RouterOptions as RawRouterOptions,
6 | RouteConfig as RouteRecordRaw,
7 | } from 'vue-router';
8 | import { OUT_OF_SCOPE, warn } from './utils';
9 |
10 | export type { NavigationGuard, RouteRecordRaw };
11 | export type {
12 | RouteMeta,
13 | RouteRecord,
14 | RedirectOption as RouteRecordRedirectOption,
15 | RawLocation as RouteLocationRaw,
16 | } from 'vue-router';
17 | export type RouterScrollBehavior = RawRouterOptions['scrollBehavior'];
18 | export type RouteLocationNormalized = Route;
19 | export type RouteLocationNormalizedLoaded = Route;
20 | export type RouteRecordName = string | symbol;
21 |
22 | export interface RouterOptions extends RawRouterOptions {
23 | routes: RouteRecordRaw[];
24 | scrollBehavior?: RouterScrollBehavior;
25 | }
26 |
27 | export interface Router extends VueRouter {
28 | isReady(): Promise;
29 |
30 | /** @deprecated */
31 | app: VueRouter['app'];
32 |
33 | /** @deprecated use `currentRoute.matched` instead */
34 | getMatchedComponents: VueRouter['getMatchedComponents'];
35 |
36 | /** @deprecated use `isReady` instead */
37 | onReady: VueRouter['onReady'];
38 | }
39 |
40 | // @ts-ignore
41 | VueRouter.prototype.isReady = function () {
42 | return new Promise((resolve, reject) => {
43 | this.onReady(resolve as any, reject);
44 | });
45 | };
46 |
47 | export function createRouter(options: RouterOptions) {
48 | Vue.use(VueRouter);
49 | return new VueRouter(options) as Router;
50 | }
51 |
52 | export function useRouter(): Router {
53 | const inst = getCurrentInstance();
54 | if (inst) {
55 | return inst.proxy.$root.$router as Router;
56 | }
57 | warn(OUT_OF_SCOPE);
58 | return undefined as any;
59 | }
60 |
61 | let currentRoute: Route;
62 |
63 | export function useRoute(): RouteLocationNormalizedLoaded {
64 | const router = useRouter();
65 | if (!router) {
66 | return undefined as any;
67 | }
68 | if (!currentRoute) {
69 | const scope = effectScope(true);
70 | scope.run(() => {
71 | currentRoute = reactive(assign({}, router.currentRoute)) as any;
72 | router.afterEach((to) => {
73 | assign(currentRoute, to);
74 | });
75 | });
76 | }
77 | return currentRoute;
78 | }
79 |
80 | function assign(target: Record, source: Record) {
81 | for (const key of Object.keys(source)) {
82 | target[key] = source[key];
83 | }
84 | return target;
85 | }
86 |
87 | export function onBeforeRouteLeave(leaveGuard: NavigationGuard) {
88 | const inst = getCurrentInstance();
89 | if (!inst) {
90 | warn(OUT_OF_SCOPE);
91 | return;
92 | }
93 | const { options } = inst.proxy.constructor as any;
94 | const hooks: any = options.beforeRouteLeave || [];
95 | hooks.push(leaveGuard);
96 | options.beforeRouteLeave = hooks;
97 | }
98 |
99 | export function onBeforeRouteUpdate(updateGuard: NavigationGuard) {
100 | const inst = getCurrentInstance();
101 | if (!inst) {
102 | warn(OUT_OF_SCOPE);
103 | return;
104 | }
105 | const { options } = inst.proxy.constructor as any;
106 | const hooks: any = options.beforeRouteUpdate || [];
107 | hooks.push(updateGuard);
108 | options.beforeRouteUpdate = hooks;
109 | }
110 |
--------------------------------------------------------------------------------
/src/vuex.ts:
--------------------------------------------------------------------------------
1 | import Vue, { getCurrentInstance } from 'vue';
2 | import Vuex, { Store, StoreOptions } from 'vuex';
3 | import { OUT_OF_SCOPE, warn } from './utils';
4 |
5 | export function createStore(options: StoreOptions) {
6 | Vue.use(Vuex);
7 | return new Store(options);
8 | }
9 |
10 | export function useStore(): Store {
11 | const inst = getCurrentInstance();
12 | if (inst) {
13 | return inst.proxy.$store;
14 | }
15 | warn(OUT_OF_SCOPE);
16 | return undefined as any;
17 | }
18 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES5",
4 | "lib": ["DOM", "ESNext"],
5 | "strict": true,
6 | "moduleResolution": "node",
7 | "declaration": true,
8 | "declarationDir": "dist/"
9 | },
10 | "include": [
11 | "src/**/*"
12 | ]
13 | }
--------------------------------------------------------------------------------