1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | function _defineProperty(obj, key, value) {
|
7 | if (key in obj) {
|
8 | Object.defineProperty(obj, key, {
|
9 | value: value,
|
10 | enumerable: true,
|
11 | configurable: true,
|
12 | writable: true
|
13 | });
|
14 | } else {
|
15 | obj[key] = value;
|
16 | }
|
17 |
|
18 | return obj;
|
19 | }
|
20 |
|
21 | function ownKeys(object, enumerableOnly) {
|
22 | var keys = Object.keys(object);
|
23 |
|
24 | if (Object.getOwnPropertySymbols) {
|
25 | var symbols = Object.getOwnPropertySymbols(object);
|
26 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
27 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
28 | });
|
29 | keys.push.apply(keys, symbols);
|
30 | }
|
31 |
|
32 | return keys;
|
33 | }
|
34 |
|
35 | function _objectSpread2(target) {
|
36 | for (var i = 1; i < arguments.length; i++) {
|
37 | var source = arguments[i] != null ? arguments[i] : {};
|
38 |
|
39 | if (i % 2) {
|
40 | ownKeys(Object(source), true).forEach(function (key) {
|
41 | _defineProperty(target, key, source[key]);
|
42 | });
|
43 | } else if (Object.getOwnPropertyDescriptors) {
|
44 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
45 | } else {
|
46 | ownKeys(Object(source)).forEach(function (key) {
|
47 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
48 | });
|
49 | }
|
50 | }
|
51 |
|
52 | return target;
|
53 | }
|
54 |
|
55 | function isFunction(value) {
|
56 | return typeof value === 'function';
|
57 | }
|
58 |
|
59 | function getSuperOptions(Ctor) {
|
60 | var superProto = Object.getPrototypeOf(Ctor.prototype);
|
61 |
|
62 | if (!superProto) {
|
63 | return undefined;
|
64 | }
|
65 |
|
66 | var Super = superProto.constructor;
|
67 | return Super.__vccOpts;
|
68 | }
|
69 |
|
70 | class Vue {
|
71 | constructor(props) {
|
72 | this.$props = props;
|
73 | Object.keys(props).forEach(key => {
|
74 | Object.defineProperty(this, key, {
|
75 | enumerable: false,
|
76 | configurable: true,
|
77 | writable: true,
|
78 | value: props[key]
|
79 | });
|
80 | });
|
81 | }
|
82 |
|
83 |
|
84 |
|
85 | static get __vccOpts() {
|
86 |
|
87 | if (this === Vue) {
|
88 | return {};
|
89 | }
|
90 |
|
91 | var cache = this.hasOwnProperty('__vccCache') && this.__vccCache;
|
92 |
|
93 | if (cache) {
|
94 | return cache;
|
95 | }
|
96 |
|
97 | var Ctor = this;
|
98 |
|
99 | var options = this.__vccCache = this.hasOwnProperty('__vccBase') ? _objectSpread2({}, this.__vccBase) : {};
|
100 |
|
101 | options.extends = getSuperOptions(Ctor);
|
102 |
|
103 | var mixins = this.hasOwnProperty('__vccMixins') && this.__vccMixins;
|
104 |
|
105 | if (mixins) {
|
106 | options.mixins = options.mixins ? options.mixins.concat(mixins) : mixins;
|
107 | }
|
108 |
|
109 |
|
110 | options.name = options.name || Ctor.name;
|
111 | options.methods = _objectSpread2({}, options.methods);
|
112 | options.computed = _objectSpread2({}, options.computed);
|
113 | var proto = Ctor.prototype;
|
114 | Object.getOwnPropertyNames(proto).forEach(key => {
|
115 | if (key === 'constructor') {
|
116 | return;
|
117 | }
|
118 |
|
119 |
|
120 | if (Ctor.__vccHooks.indexOf(key) > -1) {
|
121 | options[key] = proto[key];
|
122 | return;
|
123 | }
|
124 |
|
125 | var descriptor = Object.getOwnPropertyDescriptor(proto, key);
|
126 |
|
127 | if (typeof descriptor.value === 'function') {
|
128 | options.methods[key] = descriptor.value;
|
129 | return;
|
130 | }
|
131 |
|
132 |
|
133 | if (descriptor.get || descriptor.set) {
|
134 | options.computed[key] = {
|
135 | get: descriptor.get,
|
136 | set: descriptor.set
|
137 | };
|
138 | return;
|
139 | }
|
140 | }); // Class properties -> reactive data
|
141 |
|
142 | var hookDataOption = options.data;
|
143 |
|
144 | options.data = function () {
|
145 | var hookData = isFunction(hookDataOption) ? hookDataOption.call(this, this) : hookDataOption;
|
146 |
|
147 | var data = new Ctor(this.$props);
|
148 |
|
149 | var plainData = {};
|
150 | Object.keys(data).forEach(key => {
|
151 | if (data[key] !== undefined && key !== '$props') {
|
152 | plainData[key] = data[key];
|
153 | }
|
154 | });
|
155 | return _objectSpread2({}, hookData, {}, plainData);
|
156 | };
|
157 |
|
158 | var decorators = this.hasOwnProperty('__vccDecorators') && this.__vccDecorators;
|
159 |
|
160 | if (decorators) {
|
161 | decorators.forEach(fn => fn(options));
|
162 | }
|
163 |
|
164 |
|
165 | if (Ctor.render) {
|
166 | options.render = Ctor.render;
|
167 | }
|
168 |
|
169 | if (Ctor.__file) {
|
170 | options.__file = Ctor.__file;
|
171 | }
|
172 |
|
173 | if (Ctor.__cssModules) {
|
174 | options.__cssModules = Ctor.__cssModules;
|
175 | }
|
176 |
|
177 | if (Ctor.__scopeId) {
|
178 | options.__scopeId = Ctor.__scopeId;
|
179 | }
|
180 |
|
181 | return options;
|
182 | }
|
183 |
|
184 | static registerHooks(keys) {
|
185 | this.__vccHooks.push(...keys);
|
186 | }
|
187 |
|
188 | }
|
189 |
|
190 |
|
191 | Vue.__vccHooks = ['data', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUnmount', 'unmounted', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'render', 'errorCaptured', 'serverPrefetch'];
|
192 |
|
193 | function Options(options) {
|
194 | return Component => {
|
195 | Component.__vccBase = options;
|
196 | return Component;
|
197 | };
|
198 | }
|
199 | function createDecorator(factory) {
|
200 | return (target, key, index) => {
|
201 | var Ctor = typeof target === 'function' ? target : target.constructor;
|
202 |
|
203 | if (!Ctor.__vccDecorators) {
|
204 | Ctor.__vccDecorators = [];
|
205 | }
|
206 |
|
207 | if (typeof index !== 'number') {
|
208 | index = undefined;
|
209 | }
|
210 |
|
211 | Ctor.__vccDecorators.push(options => factory(options, key, index));
|
212 | };
|
213 | }
|
214 | function mixins() {
|
215 | var _a;
|
216 |
|
217 | for (var _len = arguments.length, Ctors = new Array(_len), _key = 0; _key < _len; _key++) {
|
218 | Ctors[_key] = arguments[_key];
|
219 | }
|
220 |
|
221 | return _a = class MixedVue extends Vue {}, _a.__vccMixins = Ctors.map(Ctor => Ctor.__vccOpts), _a;
|
222 | }
|
223 |
|
224 | export { Options, Vue, createDecorator, mixins };
|