1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
3 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueCompositionAPI = {}));
|
5 | })(this, (function (exports) { 'use strict';
|
6 |
|
7 | |
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var extendStatics = function(d, b) {
|
24 | extendStatics = Object.setPrototypeOf ||
|
25 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
26 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
27 | return extendStatics(d, b);
|
28 | };
|
29 |
|
30 | function __extends(d, b) {
|
31 | if (typeof b !== "function" && b !== null)
|
32 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
33 | extendStatics(d, b);
|
34 | function __() { this.constructor = d; }
|
35 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
36 | }
|
37 |
|
38 | var __assign = function() {
|
39 | __assign = Object.assign || function __assign(t) {
|
40 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
41 | s = arguments[i];
|
42 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
43 | }
|
44 | return t;
|
45 | };
|
46 | return __assign.apply(this, arguments);
|
47 | };
|
48 |
|
49 | function __values(o) {
|
50 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
51 | if (m) return m.call(o);
|
52 | if (o && typeof o.length === "number") return {
|
53 | next: function () {
|
54 | if (o && i >= o.length) o = void 0;
|
55 | return { value: o && o[i++], done: !o };
|
56 | }
|
57 | };
|
58 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
59 | }
|
60 |
|
61 | function __read(o, n) {
|
62 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
63 | if (!m) return o;
|
64 | var i = m.call(o), r, ar = [], e;
|
65 | try {
|
66 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
67 | }
|
68 | catch (error) { e = { error: error }; }
|
69 | finally {
|
70 | try {
|
71 | if (r && !r.done && (m = i["return"])) m.call(i);
|
72 | }
|
73 | finally { if (e) throw e.error; }
|
74 | }
|
75 | return ar;
|
76 | }
|
77 |
|
78 | function __spreadArray(to, from, pack) {
|
79 | if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
80 | if (ar || !(i in from)) {
|
81 | if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
82 | ar[i] = from[i];
|
83 | }
|
84 | }
|
85 | return to.concat(ar || Array.prototype.slice.call(from));
|
86 | }
|
87 |
|
88 | |
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | function warn$1(message) {
|
95 | var _a;
|
96 | warn(message, (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy);
|
97 | }
|
98 |
|
99 | var activeEffectScope;
|
100 | var effectScopeStack = [];
|
101 | var EffectScopeImpl = (function () {
|
102 | function EffectScopeImpl(vm) {
|
103 | this.active = true;
|
104 | this.effects = [];
|
105 | this.cleanups = [];
|
106 | this.vm = vm;
|
107 | }
|
108 | EffectScopeImpl.prototype.run = function (fn) {
|
109 | if (this.active) {
|
110 | try {
|
111 | this.on();
|
112 | return fn();
|
113 | }
|
114 | finally {
|
115 | this.off();
|
116 | }
|
117 | }
|
118 | else {
|
119 | warn$1("cannot run an inactive effect scope.");
|
120 | }
|
121 | return;
|
122 | };
|
123 | EffectScopeImpl.prototype.on = function () {
|
124 | if (this.active) {
|
125 | effectScopeStack.push(this);
|
126 | activeEffectScope = this;
|
127 | }
|
128 | };
|
129 | EffectScopeImpl.prototype.off = function () {
|
130 | if (this.active) {
|
131 | effectScopeStack.pop();
|
132 | activeEffectScope = effectScopeStack[effectScopeStack.length - 1];
|
133 | }
|
134 | };
|
135 | EffectScopeImpl.prototype.stop = function () {
|
136 | if (this.active) {
|
137 | this.vm.$destroy();
|
138 | this.effects.forEach(function (e) { return e.stop(); });
|
139 | this.cleanups.forEach(function (cleanup) { return cleanup(); });
|
140 | this.active = false;
|
141 | }
|
142 | };
|
143 | return EffectScopeImpl;
|
144 | }());
|
145 | var EffectScope = (function (_super) {
|
146 | __extends(EffectScope, _super);
|
147 | function EffectScope(detached) {
|
148 | if (detached === void 0) { detached = false; }
|
149 | var _this = this;
|
150 | var vm = undefined;
|
151 | withCurrentInstanceTrackingDisabled(function () {
|
152 | vm = defineComponentInstance(getVueConstructor());
|
153 | });
|
154 | _this = _super.call(this, vm) || this;
|
155 | if (!detached) {
|
156 | recordEffectScope(_this);
|
157 | }
|
158 | return _this;
|
159 | }
|
160 | return EffectScope;
|
161 | }(EffectScopeImpl));
|
162 | function recordEffectScope(effect, scope) {
|
163 | var _a;
|
164 | scope = scope || activeEffectScope;
|
165 | if (scope && scope.active) {
|
166 | scope.effects.push(effect);
|
167 | return;
|
168 | }
|
169 |
|
170 | var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
|
171 | vm && vm.$on('hook:destroyed', function () { return effect.stop(); });
|
172 | }
|
173 | function effectScope(detached) {
|
174 | return new EffectScope(detached);
|
175 | }
|
176 | function getCurrentScope() {
|
177 | return activeEffectScope;
|
178 | }
|
179 | function onScopeDispose(fn) {
|
180 | if (activeEffectScope) {
|
181 | activeEffectScope.cleanups.push(fn);
|
182 | }
|
183 | else {
|
184 | warn$1("onScopeDispose() is called when there is no active effect scope" +
|
185 | " to be associated with.");
|
186 | }
|
187 | }
|
188 | |
189 |
|
190 |
|
191 | function getCurrentScopeVM() {
|
192 | var _a, _b;
|
193 | return ((_a = getCurrentScope()) === null || _a === void 0 ? void 0 : _a.vm) || ((_b = getCurrentInstance()) === null || _b === void 0 ? void 0 : _b.proxy);
|
194 | }
|
195 | |
196 |
|
197 |
|
198 | function bindCurrentScopeToVM(vm) {
|
199 | if (!vm.scope) {
|
200 | var scope_1 = new EffectScopeImpl(vm.proxy);
|
201 | vm.scope = scope_1;
|
202 | vm.proxy.$on('hook:destroyed', function () { return scope_1.stop(); });
|
203 | }
|
204 | return vm.scope;
|
205 | }
|
206 |
|
207 | var vueDependency = undefined;
|
208 | try {
|
209 | var requiredVue = require('vue');
|
210 | if (requiredVue && isVue(requiredVue)) {
|
211 | vueDependency = requiredVue;
|
212 | }
|
213 | else if (requiredVue &&
|
214 | 'default' in requiredVue &&
|
215 | isVue(requiredVue.default)) {
|
216 | vueDependency = requiredVue.default;
|
217 | }
|
218 | }
|
219 | catch (_a) {
|
220 |
|
221 | }
|
222 | var vueConstructor = null;
|
223 | var currentInstance = null;
|
224 | var currentInstanceTracking = true;
|
225 | var PluginInstalledFlag = '__composition_api_installed__';
|
226 | function isVue(obj) {
|
227 | return obj && isFunction(obj) && obj.name === 'Vue';
|
228 | }
|
229 | function isVueRegistered(Vue) {
|
230 |
|
231 | return vueConstructor && hasOwn(Vue, PluginInstalledFlag);
|
232 | }
|
233 | function getVueConstructor() {
|
234 | {
|
235 | assert(vueConstructor, "must call Vue.use(VueCompositionAPI) before using any function.");
|
236 | }
|
237 | return vueConstructor;
|
238 | }
|
239 |
|
240 | function getRegisteredVueOrDefault() {
|
241 | var constructor = vueConstructor || vueDependency;
|
242 | {
|
243 | assert(constructor, "No vue dependency found.");
|
244 | }
|
245 | return constructor;
|
246 | }
|
247 | function setVueConstructor(Vue) {
|
248 |
|
249 | if (vueConstructor && Vue.__proto__ !== vueConstructor.__proto__) {
|
250 | warn('[vue-composition-api] another instance of Vue installed');
|
251 | }
|
252 | vueConstructor = Vue;
|
253 | Object.defineProperty(Vue, PluginInstalledFlag, {
|
254 | configurable: true,
|
255 | writable: true,
|
256 | value: true,
|
257 | });
|
258 | }
|
259 | |
260 |
|
261 |
|
262 |
|
263 | function withCurrentInstanceTrackingDisabled(fn) {
|
264 | var prev = currentInstanceTracking;
|
265 | currentInstanceTracking = false;
|
266 | try {
|
267 | fn();
|
268 | }
|
269 | finally {
|
270 | currentInstanceTracking = prev;
|
271 | }
|
272 | }
|
273 | function setCurrentInstance(instance) {
|
274 | if (!currentInstanceTracking)
|
275 | return;
|
276 | var prev = currentInstance;
|
277 | prev === null || prev === void 0 ? void 0 : prev.scope.off();
|
278 | currentInstance = instance;
|
279 | currentInstance === null || currentInstance === void 0 ? void 0 : currentInstance.scope.on();
|
280 | }
|
281 | function getCurrentInstance() {
|
282 | return currentInstance;
|
283 | }
|
284 | var instanceMapCache = new WeakMap();
|
285 | function toVue3ComponentInstance(vm) {
|
286 | if (instanceMapCache.has(vm)) {
|
287 | return instanceMapCache.get(vm);
|
288 | }
|
289 | var instance = {
|
290 | proxy: vm,
|
291 | update: vm.$forceUpdate,
|
292 | type: vm.$options,
|
293 | uid: vm._uid,
|
294 |
|
295 | emit: vm.$emit.bind(vm),
|
296 | parent: null,
|
297 | root: null,
|
298 | };
|
299 | bindCurrentScopeToVM(instance);
|
300 |
|
301 | var instanceProps = [
|
302 | 'data',
|
303 | 'props',
|
304 | 'attrs',
|
305 | 'refs',
|
306 | 'vnode',
|
307 | 'slots',
|
308 | ];
|
309 | instanceProps.forEach(function (prop) {
|
310 | proxy(instance, prop, {
|
311 | get: function () {
|
312 | return vm["$".concat(prop)];
|
313 | },
|
314 | });
|
315 | });
|
316 | proxy(instance, 'isMounted', {
|
317 | get: function () {
|
318 |
|
319 | return vm._isMounted;
|
320 | },
|
321 | });
|
322 | proxy(instance, 'isUnmounted', {
|
323 | get: function () {
|
324 |
|
325 | return vm._isDestroyed;
|
326 | },
|
327 | });
|
328 | proxy(instance, 'isDeactivated', {
|
329 | get: function () {
|
330 |
|
331 | return vm._inactive;
|
332 | },
|
333 | });
|
334 | proxy(instance, 'emitted', {
|
335 | get: function () {
|
336 |
|
337 | return vm._events;
|
338 | },
|
339 | });
|
340 | instanceMapCache.set(vm, instance);
|
341 | if (vm.$parent) {
|
342 | instance.parent = toVue3ComponentInstance(vm.$parent);
|
343 | }
|
344 | if (vm.$root) {
|
345 | instance.root = toVue3ComponentInstance(vm.$root);
|
346 | }
|
347 | return instance;
|
348 | }
|
349 |
|
350 | var toString = function (x) { return Object.prototype.toString.call(x); };
|
351 | function isNative(Ctor) {
|
352 | return typeof Ctor === 'function' && /native code/.test(Ctor.toString());
|
353 | }
|
354 | var hasSymbol = typeof Symbol !== 'undefined' &&
|
355 | isNative(Symbol) &&
|
356 | typeof Reflect !== 'undefined' &&
|
357 | isNative(Reflect.ownKeys);
|
358 | var noopFn = function (_) { return _; };
|
359 | function proxy(target, key, _a) {
|
360 | var get = _a.get, set = _a.set;
|
361 | Object.defineProperty(target, key, {
|
362 | enumerable: true,
|
363 | configurable: true,
|
364 | get: get || noopFn,
|
365 | set: set || noopFn,
|
366 | });
|
367 | }
|
368 | function def(obj, key, val, enumerable) {
|
369 | Object.defineProperty(obj, key, {
|
370 | value: val,
|
371 | enumerable: !!enumerable,
|
372 | writable: true,
|
373 | configurable: true,
|
374 | });
|
375 | }
|
376 | function hasOwn(obj, key) {
|
377 | return Object.hasOwnProperty.call(obj, key);
|
378 | }
|
379 | function assert(condition, msg) {
|
380 | if (!condition) {
|
381 | throw new Error("[vue-composition-api] ".concat(msg));
|
382 | }
|
383 | }
|
384 | function isPrimitive(value) {
|
385 | return (typeof value === 'string' ||
|
386 | typeof value === 'number' ||
|
387 |
|
388 | typeof value === 'symbol' ||
|
389 | typeof value === 'boolean');
|
390 | }
|
391 | function isArray(x) {
|
392 | return Array.isArray(x);
|
393 | }
|
394 | var objectToString = Object.prototype.toString;
|
395 | var toTypeString = function (value) {
|
396 | return objectToString.call(value);
|
397 | };
|
398 | var isMap = function (val) {
|
399 | return toTypeString(val) === '[object Map]';
|
400 | };
|
401 | var isSet = function (val) {
|
402 | return toTypeString(val) === '[object Set]';
|
403 | };
|
404 | var MAX_VALID_ARRAY_LENGTH = 4294967295;
|
405 | function isValidArrayIndex(val) {
|
406 | var n = parseFloat(String(val));
|
407 | return (n >= 0 &&
|
408 | Math.floor(n) === n &&
|
409 | isFinite(val) &&
|
410 | n <= MAX_VALID_ARRAY_LENGTH);
|
411 | }
|
412 | function isObject(val) {
|
413 | return val !== null && typeof val === 'object';
|
414 | }
|
415 | function isPlainObject(x) {
|
416 | return toString(x) === '[object Object]';
|
417 | }
|
418 | function isFunction(x) {
|
419 | return typeof x === 'function';
|
420 | }
|
421 | function isUndef(v) {
|
422 | return v === undefined || v === null;
|
423 | }
|
424 | function warn(msg, vm) {
|
425 | var Vue = getRegisteredVueOrDefault();
|
426 | if (!Vue || !Vue.util)
|
427 | console.warn("[vue-composition-api] ".concat(msg));
|
428 | else
|
429 | Vue.util.warn(msg, vm);
|
430 | }
|
431 | function logError(err, vm, info) {
|
432 | {
|
433 | warn("Error in ".concat(info, ": \"").concat(err.toString(), "\""), vm);
|
434 | }
|
435 | if (typeof window !== 'undefined' && typeof console !== 'undefined') {
|
436 | console.error(err);
|
437 | }
|
438 | else {
|
439 | throw err;
|
440 | }
|
441 | }
|
442 | |
443 |
|
444 |
|
445 |
|
446 | function isSame(value1, value2) {
|
447 | if (value1 === value2) {
|
448 | return value1 !== 0 || 1 / value1 === 1 / value2;
|
449 | }
|
450 | else {
|
451 | return value1 !== value1 && value2 !== value2;
|
452 | }
|
453 | }
|
454 |
|
455 | function getCurrentInstanceForFn(hook, target) {
|
456 | target = target || getCurrentInstance();
|
457 | if (!target) {
|
458 | warn("".concat(hook, " is called when there is no active component instance to be ") +
|
459 | "associated with. " +
|
460 | "Lifecycle injection APIs can only be used during execution of setup().");
|
461 | }
|
462 | return target;
|
463 | }
|
464 | function defineComponentInstance(Ctor, options) {
|
465 | if (options === void 0) { options = {}; }
|
466 | var silent = Ctor.config.silent;
|
467 | Ctor.config.silent = true;
|
468 | var vm = new Ctor(options);
|
469 | Ctor.config.silent = silent;
|
470 | return vm;
|
471 | }
|
472 | function isComponentInstance(obj) {
|
473 | var Vue = getVueConstructor();
|
474 | return Vue && obj instanceof Vue;
|
475 | }
|
476 | function createSlotProxy(vm, slotName) {
|
477 | return (function () {
|
478 | var args = [];
|
479 | for (var _i = 0; _i < arguments.length; _i++) {
|
480 | args[_i] = arguments[_i];
|
481 | }
|
482 | if (!vm.$scopedSlots[slotName]) {
|
483 | return warn("slots.".concat(slotName, "() got called outside of the \"render()\" scope"), vm);
|
484 | }
|
485 | return vm.$scopedSlots[slotName].apply(vm, args);
|
486 | });
|
487 | }
|
488 | function resolveSlots(slots, normalSlots) {
|
489 | var res;
|
490 | if (!slots) {
|
491 | res = {};
|
492 | }
|
493 | else if (slots._normalized) {
|
494 |
|
495 | return slots._normalized;
|
496 | }
|
497 | else {
|
498 | res = {};
|
499 | for (var key in slots) {
|
500 | if (slots[key] && key[0] !== '$') {
|
501 | res[key] = true;
|
502 | }
|
503 | }
|
504 | }
|
505 |
|
506 | for (var key in normalSlots) {
|
507 | if (!(key in res)) {
|
508 | res[key] = true;
|
509 | }
|
510 | }
|
511 | return res;
|
512 | }
|
513 | var vueInternalClasses;
|
514 | var getVueInternalClasses = function () {
|
515 | if (!vueInternalClasses) {
|
516 | var vm = defineComponentInstance(getVueConstructor(), {
|
517 | computed: {
|
518 | value: function () {
|
519 | return 0;
|
520 | },
|
521 | },
|
522 | });
|
523 |
|
524 | var Watcher = vm._computedWatchers.value.constructor;
|
525 |
|
526 | var Dep = vm._data.__ob__.dep.constructor;
|
527 | vueInternalClasses = {
|
528 | Watcher: Watcher,
|
529 | Dep: Dep,
|
530 | };
|
531 | vm.$destroy();
|
532 | }
|
533 | return vueInternalClasses;
|
534 | };
|
535 |
|
536 | function createSymbol(name) {
|
537 | return hasSymbol ? Symbol.for(name) : name;
|
538 | }
|
539 | var WatcherPreFlushQueueKey = createSymbol('composition-api.preFlushQueue');
|
540 | var WatcherPostFlushQueueKey = createSymbol('composition-api.postFlushQueue');
|
541 |
|
542 | var RefKey = 'composition-api.refKey';
|
543 |
|
544 | var accessModifiedSet = new WeakMap();
|
545 | var rawSet = new WeakMap();
|
546 | var readonlySet = new WeakMap();
|
547 |
|
548 | |
549 |
|
550 |
|
551 |
|
552 |
|
553 | function set$1(target, key, val) {
|
554 | var Vue = getVueConstructor();
|
555 |
|
556 | var _a = Vue.util, warn = _a.warn, defineReactive = _a.defineReactive;
|
557 | if ((isUndef(target) || isPrimitive(target))) {
|
558 | warn("Cannot set reactive property on undefined, null, or primitive value: ".concat(target));
|
559 | }
|
560 | var ob = target.__ob__;
|
561 | function ssrMockReactivity() {
|
562 |
|
563 | if (ob && isObject(val) && !hasOwn(val, '__ob__')) {
|
564 | mockReactivityDeep(val);
|
565 | }
|
566 | }
|
567 | if (isArray(target)) {
|
568 | if (isValidArrayIndex(key)) {
|
569 | target.length = Math.max(target.length, key);
|
570 | target.splice(key, 1, val);
|
571 | ssrMockReactivity();
|
572 | return val;
|
573 | }
|
574 | else if (key === 'length' && val !== target.length) {
|
575 | target.length = val;
|
576 | ob === null || ob === void 0 ? void 0 : ob.dep.notify();
|
577 | return val;
|
578 | }
|
579 | }
|
580 | if (key in target && !(key in Object.prototype)) {
|
581 | target[key] = val;
|
582 | ssrMockReactivity();
|
583 | return val;
|
584 | }
|
585 | if (target._isVue || (ob && ob.vmCount)) {
|
586 | warn('Avoid adding reactive properties to a Vue instance or its root $data ' +
|
587 | 'at runtime - declare it upfront in the data option.');
|
588 | return val;
|
589 | }
|
590 | if (!ob) {
|
591 | target[key] = val;
|
592 | return val;
|
593 | }
|
594 | defineReactive(ob.value, key, val);
|
595 |
|
596 | defineAccessControl(target, key, val);
|
597 | ssrMockReactivity();
|
598 | ob.dep.notify();
|
599 | return val;
|
600 | }
|
601 |
|
602 | var _isForceTrigger = false;
|
603 | function isForceTrigger() {
|
604 | return _isForceTrigger;
|
605 | }
|
606 | function setForceTrigger(v) {
|
607 | _isForceTrigger = v;
|
608 | }
|
609 |
|
610 | var RefImpl = (function () {
|
611 | function RefImpl(_a) {
|
612 | var get = _a.get, set = _a.set;
|
613 | proxy(this, 'value', {
|
614 | get: get,
|
615 | set: set,
|
616 | });
|
617 | }
|
618 | return RefImpl;
|
619 | }());
|
620 | function createRef(options, isReadonly, isComputed) {
|
621 | if (isReadonly === void 0) { isReadonly = false; }
|
622 | if (isComputed === void 0) { isComputed = false; }
|
623 | var r = new RefImpl(options);
|
624 |
|
625 | if (isComputed)
|
626 | r.effect = true;
|
627 |
|
628 |
|
629 |
|
630 | var sealed = Object.seal(r);
|
631 | if (isReadonly)
|
632 | readonlySet.set(sealed, true);
|
633 | return sealed;
|
634 | }
|
635 | function ref(raw) {
|
636 | var _a;
|
637 | if (isRef(raw)) {
|
638 | return raw;
|
639 | }
|
640 | var value = reactive((_a = {}, _a[RefKey] = raw, _a));
|
641 | return createRef({
|
642 | get: function () { return value[RefKey]; },
|
643 | set: function (v) { return (value[RefKey] = v); },
|
644 | });
|
645 | }
|
646 | function isRef(value) {
|
647 | return value instanceof RefImpl;
|
648 | }
|
649 | function unref(ref) {
|
650 | return isRef(ref) ? ref.value : ref;
|
651 | }
|
652 | function toRefs(obj) {
|
653 | if (!isReactive(obj)) {
|
654 | warn("toRefs() expects a reactive object but received a plain one.");
|
655 | }
|
656 | if (!isPlainObject(obj))
|
657 | return obj;
|
658 | var ret = {};
|
659 | for (var key in obj) {
|
660 | ret[key] = toRef(obj, key);
|
661 | }
|
662 | return ret;
|
663 | }
|
664 | function customRef(factory) {
|
665 | var version = ref(0);
|
666 | return createRef(factory(function () { return void version.value; }, function () {
|
667 | ++version.value;
|
668 | }));
|
669 | }
|
670 | function toRef(object, key) {
|
671 | if (!(key in object))
|
672 | set$1(object, key, undefined);
|
673 | var v = object[key];
|
674 | if (isRef(v))
|
675 | return v;
|
676 | return createRef({
|
677 | get: function () { return object[key]; },
|
678 | set: function (v) { return (object[key] = v); },
|
679 | });
|
680 | }
|
681 | function shallowRef(raw) {
|
682 | var _a;
|
683 | if (isRef(raw)) {
|
684 | return raw;
|
685 | }
|
686 | var value = shallowReactive((_a = {}, _a[RefKey] = raw, _a));
|
687 | return createRef({
|
688 | get: function () { return value[RefKey]; },
|
689 | set: function (v) { return (value[RefKey] = v); },
|
690 | });
|
691 | }
|
692 | function triggerRef(value) {
|
693 | if (!isRef(value))
|
694 | return;
|
695 | setForceTrigger(true);
|
696 | value.value = value.value;
|
697 | setForceTrigger(false);
|
698 | }
|
699 | function proxyRefs(objectWithRefs) {
|
700 | var _a, e_1, _b;
|
701 | if (isReactive(objectWithRefs)) {
|
702 | return objectWithRefs;
|
703 | }
|
704 | var value = reactive((_a = {}, _a[RefKey] = objectWithRefs, _a));
|
705 | def(value, RefKey, value[RefKey], false);
|
706 | var _loop_1 = function (key) {
|
707 | proxy(value, key, {
|
708 | get: function () {
|
709 | if (isRef(value[RefKey][key])) {
|
710 | return value[RefKey][key].value;
|
711 | }
|
712 | return value[RefKey][key];
|
713 | },
|
714 | set: function (v) {
|
715 | if (isRef(value[RefKey][key])) {
|
716 | return (value[RefKey][key].value = unref(v));
|
717 | }
|
718 | value[RefKey][key] = unref(v);
|
719 | },
|
720 | });
|
721 | };
|
722 | try {
|
723 | for (var _c = __values(Object.keys(objectWithRefs)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
724 | var key = _d.value;
|
725 | _loop_1(key);
|
726 | }
|
727 | }
|
728 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
729 | finally {
|
730 | try {
|
731 | if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
732 | }
|
733 | finally { if (e_1) throw e_1.error; }
|
734 | }
|
735 | return value;
|
736 | }
|
737 |
|
738 | var SKIPFLAG = '__v_skip';
|
739 | function isRaw(obj) {
|
740 | var _a;
|
741 | return Boolean(obj &&
|
742 | hasOwn(obj, '__ob__') &&
|
743 | typeof obj.__ob__ === 'object' &&
|
744 | ((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG]));
|
745 | }
|
746 | function isReactive(obj) {
|
747 | var _a;
|
748 | return Boolean(obj &&
|
749 | hasOwn(obj, '__ob__') &&
|
750 | typeof obj.__ob__ === 'object' &&
|
751 | !((_a = obj.__ob__) === null || _a === void 0 ? void 0 : _a[SKIPFLAG]));
|
752 | }
|
753 | |
754 |
|
755 |
|
756 |
|
757 | function setupAccessControl(target) {
|
758 | if (!isPlainObject(target) ||
|
759 | isRaw(target) ||
|
760 | isArray(target) ||
|
761 | isRef(target) ||
|
762 | isComponentInstance(target) ||
|
763 | accessModifiedSet.has(target))
|
764 | return;
|
765 | accessModifiedSet.set(target, true);
|
766 | var keys = Object.keys(target);
|
767 | for (var i = 0; i < keys.length; i++) {
|
768 | defineAccessControl(target, keys[i]);
|
769 | }
|
770 | }
|
771 | |
772 |
|
773 |
|
774 | function defineAccessControl(target, key, val) {
|
775 | if (key === '__ob__')
|
776 | return;
|
777 | if (isRaw(target[key]))
|
778 | return;
|
779 | var getter;
|
780 | var setter;
|
781 | var property = Object.getOwnPropertyDescriptor(target, key);
|
782 | if (property) {
|
783 | if (property.configurable === false) {
|
784 | return;
|
785 | }
|
786 | getter = property.get;
|
787 | setter = property.set;
|
788 | if ((!getter || setter) &&
|
789 | arguments.length === 2) {
|
790 | val = target[key];
|
791 | }
|
792 | }
|
793 | setupAccessControl(val);
|
794 | proxy(target, key, {
|
795 | get: function getterHandler() {
|
796 | var value = getter ? getter.call(target) : val;
|
797 |
|
798 | if (key !== RefKey && isRef(value)) {
|
799 | return value.value;
|
800 | }
|
801 | else {
|
802 | return value;
|
803 | }
|
804 | },
|
805 | set: function setterHandler(newVal) {
|
806 | if (getter && !setter)
|
807 | return;
|
808 |
|
809 |
|
810 |
|
811 | if (key !== RefKey && isRef(val) && !isRef(newVal)) {
|
812 | val.value = newVal;
|
813 | }
|
814 | else if (setter) {
|
815 | setter.call(target, newVal);
|
816 | val = newVal;
|
817 | }
|
818 | else {
|
819 | val = newVal;
|
820 | }
|
821 | setupAccessControl(newVal);
|
822 | },
|
823 | });
|
824 | }
|
825 | function observe(obj) {
|
826 | var Vue = getRegisteredVueOrDefault();
|
827 | var observed;
|
828 | if (Vue.observable) {
|
829 | observed = Vue.observable(obj);
|
830 | }
|
831 | else {
|
832 | var vm = defineComponentInstance(Vue, {
|
833 | data: {
|
834 | $$state: obj,
|
835 | },
|
836 | });
|
837 | observed = vm._data.$$state;
|
838 | }
|
839 |
|
840 | if (!hasOwn(observed, '__ob__')) {
|
841 | mockReactivityDeep(observed);
|
842 | }
|
843 | return observed;
|
844 | }
|
845 | |
846 |
|
847 |
|
848 | function mockReactivityDeep(obj, seen) {
|
849 | var e_1, _a;
|
850 | if (seen === void 0) { seen = new Set(); }
|
851 | if (seen.has(obj) || hasOwn(obj, '__ob__') || !Object.isExtensible(obj))
|
852 | return;
|
853 | def(obj, '__ob__', mockObserver(obj));
|
854 | seen.add(obj);
|
855 | try {
|
856 | for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
857 | var key = _c.value;
|
858 | var value = obj[key];
|
859 | if (!(isPlainObject(value) || isArray(value)) ||
|
860 | isRaw(value) ||
|
861 | !Object.isExtensible(value)) {
|
862 | continue;
|
863 | }
|
864 | mockReactivityDeep(value, seen);
|
865 | }
|
866 | }
|
867 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
868 | finally {
|
869 | try {
|
870 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
871 | }
|
872 | finally { if (e_1) throw e_1.error; }
|
873 | }
|
874 | }
|
875 | function mockObserver(value) {
|
876 | if (value === void 0) { value = {}; }
|
877 | return {
|
878 | value: value,
|
879 | dep: {
|
880 | notify: noopFn,
|
881 | depend: noopFn,
|
882 | addSub: noopFn,
|
883 | removeSub: noopFn,
|
884 | },
|
885 | };
|
886 | }
|
887 | function createObserver() {
|
888 | return observe({}).__ob__;
|
889 | }
|
890 | function shallowReactive(obj) {
|
891 | var e_2, _a;
|
892 | if (!isObject(obj)) {
|
893 | {
|
894 | warn('"shallowReactive()" must be called on an object.');
|
895 | }
|
896 | return obj;
|
897 | }
|
898 | if (!(isPlainObject(obj) || isArray(obj)) ||
|
899 | isRaw(obj) ||
|
900 | !Object.isExtensible(obj)) {
|
901 | return obj;
|
902 | }
|
903 | var observed = observe(isArray(obj) ? [] : {});
|
904 | var ob = observed.__ob__;
|
905 | var _loop_1 = function (key) {
|
906 | var val = obj[key];
|
907 | var getter;
|
908 | var setter;
|
909 | var property = Object.getOwnPropertyDescriptor(obj, key);
|
910 | if (property) {
|
911 | if (property.configurable === false) {
|
912 | return "continue";
|
913 | }
|
914 | getter = property.get;
|
915 | setter = property.set;
|
916 | }
|
917 | proxy(observed, key, {
|
918 | get: function getterHandler() {
|
919 | var _a;
|
920 | (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.depend();
|
921 | return val;
|
922 | },
|
923 | set: function setterHandler(newVal) {
|
924 | var _a;
|
925 | if (getter && !setter)
|
926 | return;
|
927 | if (!isForceTrigger() && val === newVal)
|
928 | return;
|
929 | if (setter) {
|
930 | setter.call(obj, newVal);
|
931 | }
|
932 | else {
|
933 | val = newVal;
|
934 | }
|
935 | (_a = ob.dep) === null || _a === void 0 ? void 0 : _a.notify();
|
936 | },
|
937 | });
|
938 | };
|
939 | try {
|
940 | for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
941 | var key = _c.value;
|
942 | _loop_1(key);
|
943 | }
|
944 | }
|
945 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
946 | finally {
|
947 | try {
|
948 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
949 | }
|
950 | finally { if (e_2) throw e_2.error; }
|
951 | }
|
952 | return observed;
|
953 | }
|
954 | |
955 |
|
956 |
|
957 | function reactive(obj) {
|
958 | if (!isObject(obj)) {
|
959 | {
|
960 | warn('"reactive()" must be called on an object.');
|
961 | }
|
962 | return obj;
|
963 | }
|
964 | if (!(isPlainObject(obj) || isArray(obj)) ||
|
965 | isRaw(obj) ||
|
966 | !Object.isExtensible(obj)) {
|
967 | return obj;
|
968 | }
|
969 | var observed = observe(obj);
|
970 | setupAccessControl(observed);
|
971 | return observed;
|
972 | }
|
973 | |
974 |
|
975 |
|
976 | function markRaw(obj) {
|
977 | if (!(isPlainObject(obj) || isArray(obj)) || !Object.isExtensible(obj)) {
|
978 | return obj;
|
979 | }
|
980 |
|
981 | var ob = createObserver();
|
982 | ob[SKIPFLAG] = true;
|
983 | def(obj, '__ob__', ob);
|
984 |
|
985 | rawSet.set(obj, true);
|
986 | return obj;
|
987 | }
|
988 | function toRaw(observed) {
|
989 | var _a;
|
990 | if (isRaw(observed) || !Object.isExtensible(observed)) {
|
991 | return observed;
|
992 | }
|
993 | return ((_a = observed === null || observed === void 0 ? void 0 : observed.__ob__) === null || _a === void 0 ? void 0 : _a.value) || observed;
|
994 | }
|
995 |
|
996 | function isReadonly(obj) {
|
997 | return readonlySet.has(obj);
|
998 | }
|
999 | |
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 | function readonly(target) {
|
1006 | if (!isObject(target)) {
|
1007 | warn("value cannot be made reactive: ".concat(String(target)));
|
1008 | }
|
1009 | else {
|
1010 | readonlySet.set(target, true);
|
1011 | }
|
1012 | return target;
|
1013 | }
|
1014 | function shallowReadonly(obj) {
|
1015 | var e_1, _a;
|
1016 | if (!isObject(obj)) {
|
1017 | {
|
1018 | warn("value cannot be made reactive: ".concat(String(obj)));
|
1019 | }
|
1020 | return obj;
|
1021 | }
|
1022 | if (!(isPlainObject(obj) || isArray(obj)) ||
|
1023 | (!Object.isExtensible(obj) && !isRef(obj))) {
|
1024 | return obj;
|
1025 | }
|
1026 | var readonlyObj = isRef(obj)
|
1027 | ? new RefImpl({})
|
1028 | : isReactive(obj)
|
1029 | ? observe({})
|
1030 | : {};
|
1031 | var source = reactive({});
|
1032 | var ob = source.__ob__;
|
1033 | var _loop_1 = function (key) {
|
1034 | var val = obj[key];
|
1035 | var getter;
|
1036 | var property = Object.getOwnPropertyDescriptor(obj, key);
|
1037 | if (property) {
|
1038 | if (property.configurable === false && !isRef(obj)) {
|
1039 | return "continue";
|
1040 | }
|
1041 | getter = property.get;
|
1042 | }
|
1043 | proxy(readonlyObj, key, {
|
1044 | get: function getterHandler() {
|
1045 | var value = getter ? getter.call(obj) : val;
|
1046 | ob.dep.depend();
|
1047 | return value;
|
1048 | },
|
1049 | set: function (v) {
|
1050 | {
|
1051 | warn("Set operation on key \"".concat(key, "\" failed: target is readonly."));
|
1052 | }
|
1053 | },
|
1054 | });
|
1055 | };
|
1056 | try {
|
1057 | for (var _b = __values(Object.keys(obj)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
1058 | var key = _c.value;
|
1059 | _loop_1(key);
|
1060 | }
|
1061 | }
|
1062 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
1063 | finally {
|
1064 | try {
|
1065 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
1066 | }
|
1067 | finally { if (e_1) throw e_1.error; }
|
1068 | }
|
1069 | readonlySet.set(readonlyObj, true);
|
1070 | return readonlyObj;
|
1071 | }
|
1072 |
|
1073 | |
1074 |
|
1075 |
|
1076 | function del(target, key) {
|
1077 | var Vue = getVueConstructor();
|
1078 | var warn = Vue.util.warn;
|
1079 | if ((isUndef(target) || isPrimitive(target))) {
|
1080 | warn("Cannot delete reactive property on undefined, null, or primitive value: ".concat(target));
|
1081 | }
|
1082 | if (isArray(target) && isValidArrayIndex(key)) {
|
1083 | target.splice(key, 1);
|
1084 | return;
|
1085 | }
|
1086 | var ob = target.__ob__;
|
1087 | if (target._isVue || (ob && ob.vmCount)) {
|
1088 | warn('Avoid deleting properties on a Vue instance or its root $data ' +
|
1089 | '- just set it to null.');
|
1090 | return;
|
1091 | }
|
1092 | if (!hasOwn(target, key)) {
|
1093 | return;
|
1094 | }
|
1095 | delete target[key];
|
1096 | if (!ob) {
|
1097 | return;
|
1098 | }
|
1099 | ob.dep.notify();
|
1100 | }
|
1101 |
|
1102 | var genName = function (name) { return "on".concat(name[0].toUpperCase() + name.slice(1)); };
|
1103 | function createLifeCycle(lifeCyclehook) {
|
1104 | return function (callback, target) {
|
1105 | var instance = getCurrentInstanceForFn(genName(lifeCyclehook), target);
|
1106 | return (instance &&
|
1107 | injectHookOption(getVueConstructor(), instance, lifeCyclehook, callback));
|
1108 | };
|
1109 | }
|
1110 | function injectHookOption(Vue, instance, hook, val) {
|
1111 | var options = instance.proxy.$options;
|
1112 | var mergeFn = Vue.config.optionMergeStrategies[hook];
|
1113 | var wrappedHook = wrapHookCall(instance, val);
|
1114 | options[hook] = mergeFn(options[hook], wrappedHook);
|
1115 | return wrappedHook;
|
1116 | }
|
1117 | function wrapHookCall(instance, fn) {
|
1118 | return function () {
|
1119 | var args = [];
|
1120 | for (var _i = 0; _i < arguments.length; _i++) {
|
1121 | args[_i] = arguments[_i];
|
1122 | }
|
1123 | var prev = getCurrentInstance();
|
1124 | setCurrentInstance(instance);
|
1125 | try {
|
1126 | return fn.apply(void 0, __spreadArray([], __read(args), false));
|
1127 | }
|
1128 | finally {
|
1129 | setCurrentInstance(prev);
|
1130 | }
|
1131 | };
|
1132 | }
|
1133 | var onBeforeMount = createLifeCycle('beforeMount');
|
1134 | var onMounted = createLifeCycle('mounted');
|
1135 | var onBeforeUpdate = createLifeCycle('beforeUpdate');
|
1136 | var onUpdated = createLifeCycle('updated');
|
1137 | var onBeforeUnmount = createLifeCycle('beforeDestroy');
|
1138 | var onUnmounted = createLifeCycle('destroyed');
|
1139 | var onErrorCaptured = createLifeCycle('errorCaptured');
|
1140 | var onActivated = createLifeCycle('activated');
|
1141 | var onDeactivated = createLifeCycle('deactivated');
|
1142 | var onServerPrefetch = createLifeCycle('serverPrefetch');
|
1143 |
|
1144 | var fallbackVM;
|
1145 | function flushPreQueue() {
|
1146 | flushQueue(this, WatcherPreFlushQueueKey);
|
1147 | }
|
1148 | function flushPostQueue() {
|
1149 | flushQueue(this, WatcherPostFlushQueueKey);
|
1150 | }
|
1151 | function hasWatchEnv(vm) {
|
1152 | return vm[WatcherPreFlushQueueKey] !== undefined;
|
1153 | }
|
1154 | function installWatchEnv(vm) {
|
1155 | vm[WatcherPreFlushQueueKey] = [];
|
1156 | vm[WatcherPostFlushQueueKey] = [];
|
1157 | vm.$on('hook:beforeUpdate', flushPreQueue);
|
1158 | vm.$on('hook:updated', flushPostQueue);
|
1159 | }
|
1160 | function getWatcherOption(options) {
|
1161 | return __assign({
|
1162 | immediate: false,
|
1163 | deep: false,
|
1164 | flush: 'pre',
|
1165 | }, options);
|
1166 | }
|
1167 | function getWatchEffectOption(options) {
|
1168 | return __assign({
|
1169 | flush: 'pre',
|
1170 | }, options);
|
1171 | }
|
1172 | function getWatcherVM() {
|
1173 | var vm = getCurrentScopeVM();
|
1174 | if (!vm) {
|
1175 | if (!fallbackVM) {
|
1176 | fallbackVM = defineComponentInstance(getVueConstructor());
|
1177 | }
|
1178 | vm = fallbackVM;
|
1179 | }
|
1180 | else if (!hasWatchEnv(vm)) {
|
1181 | installWatchEnv(vm);
|
1182 | }
|
1183 | return vm;
|
1184 | }
|
1185 | function flushQueue(vm, key) {
|
1186 | var queue = vm[key];
|
1187 | for (var index = 0; index < queue.length; index++) {
|
1188 | queue[index]();
|
1189 | }
|
1190 | queue.length = 0;
|
1191 | }
|
1192 | function queueFlushJob(vm, fn, mode) {
|
1193 |
|
1194 | var fallbackFlush = function () {
|
1195 | vm.$nextTick(function () {
|
1196 | if (vm[WatcherPreFlushQueueKey].length) {
|
1197 | flushQueue(vm, WatcherPreFlushQueueKey);
|
1198 | }
|
1199 | if (vm[WatcherPostFlushQueueKey].length) {
|
1200 | flushQueue(vm, WatcherPostFlushQueueKey);
|
1201 | }
|
1202 | });
|
1203 | };
|
1204 | switch (mode) {
|
1205 | case 'pre':
|
1206 | fallbackFlush();
|
1207 | vm[WatcherPreFlushQueueKey].push(fn);
|
1208 | break;
|
1209 | case 'post':
|
1210 | fallbackFlush();
|
1211 | vm[WatcherPostFlushQueueKey].push(fn);
|
1212 | break;
|
1213 | default:
|
1214 | assert(false, "flush must be one of [\"post\", \"pre\", \"sync\"], but got ".concat(mode));
|
1215 | break;
|
1216 | }
|
1217 | }
|
1218 | function createVueWatcher(vm, getter, callback, options) {
|
1219 | var index = vm._watchers.length;
|
1220 |
|
1221 | vm.$watch(getter, callback, {
|
1222 | immediate: options.immediateInvokeCallback,
|
1223 | deep: options.deep,
|
1224 | lazy: options.noRun,
|
1225 | sync: options.sync,
|
1226 | before: options.before,
|
1227 | });
|
1228 | return vm._watchers[index];
|
1229 | }
|
1230 |
|
1231 |
|
1232 | function patchWatcherTeardown(watcher, runCleanup) {
|
1233 | var _teardown = watcher.teardown;
|
1234 | watcher.teardown = function () {
|
1235 | var args = [];
|
1236 | for (var _i = 0; _i < arguments.length; _i++) {
|
1237 | args[_i] = arguments[_i];
|
1238 | }
|
1239 | _teardown.apply(watcher, args);
|
1240 | runCleanup();
|
1241 | };
|
1242 | }
|
1243 | function createWatcher(vm, source, cb, options) {
|
1244 | var _a;
|
1245 | if (!cb) {
|
1246 | if (options.immediate !== undefined) {
|
1247 | warn("watch() \"immediate\" option is only respected when using the " +
|
1248 | "watch(source, callback, options?) signature.");
|
1249 | }
|
1250 | if (options.deep !== undefined) {
|
1251 | warn("watch() \"deep\" option is only respected when using the " +
|
1252 | "watch(source, callback, options?) signature.");
|
1253 | }
|
1254 | }
|
1255 | var flushMode = options.flush;
|
1256 | var isSync = flushMode === 'sync';
|
1257 | var cleanup;
|
1258 | var registerCleanup = function (fn) {
|
1259 | cleanup = function () {
|
1260 | try {
|
1261 | fn();
|
1262 | }
|
1263 | catch (
|
1264 |
|
1265 | error) {
|
1266 | logError(error, vm, 'onCleanup()');
|
1267 | }
|
1268 | };
|
1269 | };
|
1270 |
|
1271 | var runCleanup = function () {
|
1272 | if (cleanup) {
|
1273 | cleanup();
|
1274 | cleanup = null;
|
1275 | }
|
1276 | };
|
1277 | var createScheduler = function (fn) {
|
1278 | if (isSync ||
|
1279 | vm ===
|
1280 | fallbackVM) {
|
1281 | return fn;
|
1282 | }
|
1283 | return (function () {
|
1284 | var args = [];
|
1285 | for (var _i = 0; _i < arguments.length; _i++) {
|
1286 | args[_i] = arguments[_i];
|
1287 | }
|
1288 | return queueFlushJob(vm, function () {
|
1289 | fn.apply(void 0, __spreadArray([], __read(args), false));
|
1290 | }, flushMode);
|
1291 | });
|
1292 | };
|
1293 |
|
1294 | if (cb === null) {
|
1295 | var running_1 = false;
|
1296 | var getter_1 = function () {
|
1297 |
|
1298 | if (running_1) {
|
1299 | return;
|
1300 | }
|
1301 | try {
|
1302 | running_1 = true;
|
1303 | source(registerCleanup);
|
1304 | }
|
1305 | finally {
|
1306 | running_1 = false;
|
1307 | }
|
1308 | };
|
1309 | var watcher_1 = createVueWatcher(vm, getter_1, noopFn, {
|
1310 | deep: options.deep || false,
|
1311 | sync: isSync,
|
1312 | before: runCleanup,
|
1313 | });
|
1314 | patchWatcherTeardown(watcher_1, runCleanup);
|
1315 |
|
1316 | watcher_1.lazy = false;
|
1317 | var originGet = watcher_1.get.bind(watcher_1);
|
1318 |
|
1319 | watcher_1.get = createScheduler(originGet);
|
1320 | return function () {
|
1321 | watcher_1.teardown();
|
1322 | };
|
1323 | }
|
1324 | var deep = options.deep;
|
1325 | var isMultiSource = false;
|
1326 | var getter;
|
1327 | if (isRef(source)) {
|
1328 | getter = function () { return source.value; };
|
1329 | }
|
1330 | else if (isReactive(source)) {
|
1331 | getter = function () { return source; };
|
1332 | deep = true;
|
1333 | }
|
1334 | else if (isArray(source)) {
|
1335 | isMultiSource = true;
|
1336 | getter = function () {
|
1337 | return source.map(function (s) {
|
1338 | if (isRef(s)) {
|
1339 | return s.value;
|
1340 | }
|
1341 | else if (isReactive(s)) {
|
1342 | return traverse(s);
|
1343 | }
|
1344 | else if (isFunction(s)) {
|
1345 | return s();
|
1346 | }
|
1347 | else {
|
1348 | warn("Invalid watch source: ".concat(JSON.stringify(s), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm);
|
1349 | return noopFn;
|
1350 | }
|
1351 | });
|
1352 | };
|
1353 | }
|
1354 | else if (isFunction(source)) {
|
1355 | getter = source;
|
1356 | }
|
1357 | else {
|
1358 | getter = noopFn;
|
1359 | warn("Invalid watch source: ".concat(JSON.stringify(source), ".\n A watch source can only be a getter/effect function, a ref, a reactive object, or an array of these types."), vm);
|
1360 | }
|
1361 | if (deep) {
|
1362 | var baseGetter_1 = getter;
|
1363 | getter = function () { return traverse(baseGetter_1()); };
|
1364 | }
|
1365 | var applyCb = function (n, o) {
|
1366 | if (!deep &&
|
1367 | isMultiSource &&
|
1368 | n.every(function (v, i) { return isSame(v, o[i]); }))
|
1369 | return;
|
1370 |
|
1371 | runCleanup();
|
1372 | return cb(n, o, registerCleanup);
|
1373 | };
|
1374 | var callback = createScheduler(applyCb);
|
1375 | if (options.immediate) {
|
1376 | var originalCallback_1 = callback;
|
1377 |
|
1378 |
|
1379 | var shiftCallback_1 = function (n, o) {
|
1380 | shiftCallback_1 = originalCallback_1;
|
1381 |
|
1382 | return applyCb(n, isArray(n) ? [] : o);
|
1383 | };
|
1384 | callback = function (n, o) {
|
1385 | return shiftCallback_1(n, o);
|
1386 | };
|
1387 | }
|
1388 |
|
1389 | var stop = vm.$watch(getter, callback, {
|
1390 | immediate: options.immediate,
|
1391 | deep: deep,
|
1392 | sync: isSync,
|
1393 | });
|
1394 |
|
1395 | var watcher = vm._watchers[vm._watchers.length - 1];
|
1396 |
|
1397 |
|
1398 | if (isReactive(watcher.value) && ((_a = watcher.value.__ob__) === null || _a === void 0 ? void 0 : _a.dep) && deep) {
|
1399 | watcher.value.__ob__.dep.addSub({
|
1400 | update: function () {
|
1401 |
|
1402 |
|
1403 | watcher.run();
|
1404 | },
|
1405 | });
|
1406 | }
|
1407 | patchWatcherTeardown(watcher, runCleanup);
|
1408 | return function () {
|
1409 | stop();
|
1410 | };
|
1411 | }
|
1412 | function watchEffect(effect, options) {
|
1413 | var opts = getWatchEffectOption(options);
|
1414 | var vm = getWatcherVM();
|
1415 | return createWatcher(vm, effect, null, opts);
|
1416 | }
|
1417 | function watchPostEffect(effect) {
|
1418 | return watchEffect(effect, { flush: 'post' });
|
1419 | }
|
1420 | function watchSyncEffect(effect) {
|
1421 | return watchEffect(effect, { flush: 'sync' });
|
1422 | }
|
1423 |
|
1424 | function watch(source, cb, options) {
|
1425 | var callback = null;
|
1426 | if (isFunction(cb)) {
|
1427 |
|
1428 | callback = cb;
|
1429 | }
|
1430 | else {
|
1431 |
|
1432 | {
|
1433 | warn("`watch(fn, options?)` signature has been moved to a separate API. " +
|
1434 | "Use `watchEffect(fn, options?)` instead. `watch` now only " +
|
1435 | "supports `watch(source, cb, options?) signature.");
|
1436 | }
|
1437 | options = cb;
|
1438 | callback = null;
|
1439 | }
|
1440 | var opts = getWatcherOption(options);
|
1441 | var vm = getWatcherVM();
|
1442 | return createWatcher(vm, source, callback, opts);
|
1443 | }
|
1444 | function traverse(value, seen) {
|
1445 | if (seen === void 0) { seen = new Set(); }
|
1446 | if (!isObject(value) || seen.has(value) || rawSet.has(value)) {
|
1447 | return value;
|
1448 | }
|
1449 | seen.add(value);
|
1450 | if (isRef(value)) {
|
1451 | traverse(value.value, seen);
|
1452 | }
|
1453 | else if (isArray(value)) {
|
1454 | for (var i = 0; i < value.length; i++) {
|
1455 | traverse(value[i], seen);
|
1456 | }
|
1457 | }
|
1458 | else if (isSet(value) || isMap(value)) {
|
1459 | value.forEach(function (v) {
|
1460 | traverse(v, seen);
|
1461 | });
|
1462 | }
|
1463 | else if (isPlainObject(value)) {
|
1464 | for (var key in value) {
|
1465 | traverse(value[key], seen);
|
1466 | }
|
1467 | }
|
1468 | return value;
|
1469 | }
|
1470 |
|
1471 |
|
1472 | function computed(getterOrOptions) {
|
1473 | var vm = getCurrentScopeVM();
|
1474 | var getter;
|
1475 | var setter;
|
1476 | if (isFunction(getterOrOptions)) {
|
1477 | getter = getterOrOptions;
|
1478 | }
|
1479 | else {
|
1480 | getter = getterOrOptions.get;
|
1481 | setter = getterOrOptions.set;
|
1482 | }
|
1483 | var computedSetter;
|
1484 | var computedGetter;
|
1485 | if (vm && !vm.$isServer) {
|
1486 | var _a = getVueInternalClasses(), Watcher_1 = _a.Watcher, Dep_1 = _a.Dep;
|
1487 | var watcher_1;
|
1488 | computedGetter = function () {
|
1489 | if (!watcher_1) {
|
1490 | watcher_1 = new Watcher_1(vm, getter, noopFn, { lazy: true });
|
1491 | }
|
1492 | if (watcher_1.dirty) {
|
1493 | watcher_1.evaluate();
|
1494 | }
|
1495 | if (Dep_1.target) {
|
1496 | watcher_1.depend();
|
1497 | }
|
1498 | return watcher_1.value;
|
1499 | };
|
1500 | computedSetter = function (v) {
|
1501 | if (!setter) {
|
1502 | warn('Write operation failed: computed value is readonly.', vm);
|
1503 | return;
|
1504 | }
|
1505 | if (setter) {
|
1506 | setter(v);
|
1507 | }
|
1508 | };
|
1509 | }
|
1510 | else {
|
1511 |
|
1512 | var computedHost_1 = defineComponentInstance(getVueConstructor(), {
|
1513 | computed: {
|
1514 | $$state: {
|
1515 | get: getter,
|
1516 | set: setter,
|
1517 | },
|
1518 | },
|
1519 | });
|
1520 | vm && vm.$on('hook:destroyed', function () { return computedHost_1.$destroy(); });
|
1521 | computedGetter = function () { return computedHost_1.$$state; };
|
1522 | computedSetter = function (v) {
|
1523 | if (!setter) {
|
1524 | warn('Write operation failed: computed value is readonly.', vm);
|
1525 | return;
|
1526 | }
|
1527 | computedHost_1.$$state = v;
|
1528 | };
|
1529 | }
|
1530 | return createRef({
|
1531 | get: computedGetter,
|
1532 | set: computedSetter,
|
1533 | }, !setter, true);
|
1534 | }
|
1535 |
|
1536 | var NOT_FOUND = {};
|
1537 | function resolveInject(provideKey, vm) {
|
1538 | var source = vm;
|
1539 | while (source) {
|
1540 | if (source._provided && hasOwn(source._provided, provideKey)) {
|
1541 | return source._provided[provideKey];
|
1542 | }
|
1543 | source = source.$parent;
|
1544 | }
|
1545 | return NOT_FOUND;
|
1546 | }
|
1547 | function provide(key, value) {
|
1548 | var _a;
|
1549 | var vm = (_a = getCurrentInstanceForFn('provide')) === null || _a === void 0 ? void 0 : _a.proxy;
|
1550 | if (!vm)
|
1551 | return;
|
1552 | if (!vm._provided) {
|
1553 | var provideCache_1 = {};
|
1554 | proxy(vm, '_provided', {
|
1555 | get: function () { return provideCache_1; },
|
1556 | set: function (v) { return Object.assign(provideCache_1, v); },
|
1557 | });
|
1558 | }
|
1559 | vm._provided[key] = value;
|
1560 | }
|
1561 | function inject(key, defaultValue, treatDefaultAsFactory) {
|
1562 | var _a;
|
1563 | if (treatDefaultAsFactory === void 0) { treatDefaultAsFactory = false; }
|
1564 | var vm = (_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy;
|
1565 | if (!vm) {
|
1566 | warn("inject() can only be used inside setup() or functional components.");
|
1567 | return;
|
1568 | }
|
1569 | if (!key) {
|
1570 | warn("injection \"".concat(String(key), "\" not found."), vm);
|
1571 | return defaultValue;
|
1572 | }
|
1573 | var val = resolveInject(key, vm);
|
1574 | if (val !== NOT_FOUND) {
|
1575 | return val;
|
1576 | }
|
1577 | else if (arguments.length > 1) {
|
1578 | return treatDefaultAsFactory && isFunction(defaultValue)
|
1579 | ? defaultValue()
|
1580 | : defaultValue;
|
1581 | }
|
1582 | else {
|
1583 | warn("Injection \"".concat(String(key), "\" not found."), vm);
|
1584 | }
|
1585 | }
|
1586 |
|
1587 | var EMPTY_OBJ = Object.freeze({})
|
1588 | ;
|
1589 | var useCssModule = function (name) {
|
1590 | var _a;
|
1591 | if (name === void 0) { name = '$style'; }
|
1592 | var instance = getCurrentInstance();
|
1593 | if (!instance) {
|
1594 | warn("useCssModule must be called inside setup()");
|
1595 | return EMPTY_OBJ;
|
1596 | }
|
1597 | var mod = (_a = instance.proxy) === null || _a === void 0 ? void 0 : _a[name];
|
1598 | if (!mod) {
|
1599 | warn("Current instance does not have CSS module named \"".concat(name, "\"."));
|
1600 | return EMPTY_OBJ;
|
1601 | }
|
1602 | return mod;
|
1603 | };
|
1604 | |
1605 |
|
1606 |
|
1607 | var useCSSModule = useCssModule;
|
1608 |
|
1609 | function createApp(rootComponent, rootProps) {
|
1610 | if (rootProps === void 0) { rootProps = undefined; }
|
1611 | var V = getVueConstructor();
|
1612 | var mountedVM = undefined;
|
1613 | var provide = {};
|
1614 | var app = {
|
1615 | config: V.config,
|
1616 | use: V.use.bind(V),
|
1617 | mixin: V.mixin.bind(V),
|
1618 | component: V.component.bind(V),
|
1619 | provide: function (key, value) {
|
1620 | provide[key] = value;
|
1621 | return this;
|
1622 | },
|
1623 | directive: function (name, dir) {
|
1624 | if (dir) {
|
1625 | V.directive(name, dir);
|
1626 | return app;
|
1627 | }
|
1628 | else {
|
1629 | return V.directive(name);
|
1630 | }
|
1631 | },
|
1632 | mount: function (el, hydrating) {
|
1633 | if (!mountedVM) {
|
1634 | mountedVM = new V(__assign(__assign({ propsData: rootProps }, rootComponent), { provide: __assign(__assign({}, provide), rootComponent.provide) }));
|
1635 | mountedVM.$mount(el, hydrating);
|
1636 | return mountedVM;
|
1637 | }
|
1638 | else {
|
1639 | {
|
1640 | warn("App has already been mounted.\n" +
|
1641 | "If you want to remount the same app, move your app creation logic " +
|
1642 | "into a factory function and create fresh app instances for each " +
|
1643 | "mount - e.g. `const createMyApp = () => createApp(App)`");
|
1644 | }
|
1645 | return mountedVM;
|
1646 | }
|
1647 | },
|
1648 | unmount: function () {
|
1649 | if (mountedVM) {
|
1650 | mountedVM.$destroy();
|
1651 | mountedVM = undefined;
|
1652 | }
|
1653 | else {
|
1654 | warn("Cannot unmount an app that is not mounted.");
|
1655 | }
|
1656 | },
|
1657 | };
|
1658 | return app;
|
1659 | }
|
1660 |
|
1661 | var nextTick = function nextTick() {
|
1662 | var _a;
|
1663 | var args = [];
|
1664 | for (var _i = 0; _i < arguments.length; _i++) {
|
1665 | args[_i] = arguments[_i];
|
1666 | }
|
1667 | return (_a = getVueConstructor()) === null || _a === void 0 ? void 0 : _a.nextTick.apply(this, args);
|
1668 | };
|
1669 |
|
1670 | var fallbackCreateElement;
|
1671 | var createElement = function createElement() {
|
1672 | var _a;
|
1673 | var args = [];
|
1674 | for (var _i = 0; _i < arguments.length; _i++) {
|
1675 | args[_i] = arguments[_i];
|
1676 | }
|
1677 | var instance = (this === null || this === void 0 ? void 0 : this.proxy) || ((_a = getCurrentInstance()) === null || _a === void 0 ? void 0 : _a.proxy);
|
1678 | if (!instance) {
|
1679 | warn('`createElement()` has been called outside of render function.');
|
1680 | if (!fallbackCreateElement) {
|
1681 | fallbackCreateElement = defineComponentInstance(getVueConstructor()).$createElement;
|
1682 | }
|
1683 | return fallbackCreateElement.apply(fallbackCreateElement, args);
|
1684 | }
|
1685 | return instance.$createElement.apply(instance, args);
|
1686 | };
|
1687 |
|
1688 | function useSlots() {
|
1689 | return getContext().slots;
|
1690 | }
|
1691 | function useAttrs() {
|
1692 | return getContext().attrs;
|
1693 | }
|
1694 | function getContext() {
|
1695 | var i = getCurrentInstance();
|
1696 | if (!i) {
|
1697 | warn("useContext() called without active instance.");
|
1698 | }
|
1699 | return i.setupContext;
|
1700 | }
|
1701 |
|
1702 | function set(vm, key, value) {
|
1703 | var state = (vm.__composition_api_state__ =
|
1704 | vm.__composition_api_state__ || {});
|
1705 | state[key] = value;
|
1706 | }
|
1707 | function get(vm, key) {
|
1708 | return (vm.__composition_api_state__ || {})[key];
|
1709 | }
|
1710 | var vmStateManager = {
|
1711 | set: set,
|
1712 | get: get,
|
1713 | };
|
1714 |
|
1715 | function asVmProperty(vm, propName, propValue) {
|
1716 | var props = vm.$options.props;
|
1717 | if (!(propName in vm) && !(props && hasOwn(props, propName))) {
|
1718 | if (isRef(propValue)) {
|
1719 | proxy(vm, propName, {
|
1720 | get: function () { return propValue.value; },
|
1721 | set: function (val) {
|
1722 | propValue.value = val;
|
1723 | },
|
1724 | });
|
1725 | }
|
1726 | else {
|
1727 | proxy(vm, propName, {
|
1728 | get: function () {
|
1729 | if (isReactive(propValue)) {
|
1730 | propValue.__ob__.dep.depend();
|
1731 | }
|
1732 | return propValue;
|
1733 | },
|
1734 | set: function (val) {
|
1735 | propValue = val;
|
1736 | },
|
1737 | });
|
1738 | }
|
1739 | {
|
1740 |
|
1741 |
|
1742 | vm.$nextTick(function () {
|
1743 | if (Object.keys(vm._data).indexOf(propName) !== -1) {
|
1744 | return;
|
1745 | }
|
1746 | if (isRef(propValue)) {
|
1747 | proxy(vm._data, propName, {
|
1748 | get: function () { return propValue.value; },
|
1749 | set: function (val) {
|
1750 | propValue.value = val;
|
1751 | },
|
1752 | });
|
1753 | }
|
1754 | else {
|
1755 | proxy(vm._data, propName, {
|
1756 | get: function () { return propValue; },
|
1757 | set: function (val) {
|
1758 | propValue = val;
|
1759 | },
|
1760 | });
|
1761 | }
|
1762 | });
|
1763 | }
|
1764 | }
|
1765 | else {
|
1766 | if (props && hasOwn(props, propName)) {
|
1767 | warn("The setup binding property \"".concat(propName, "\" is already declared as a prop."), vm);
|
1768 | }
|
1769 | else {
|
1770 | warn("The setup binding property \"".concat(propName, "\" is already declared."), vm);
|
1771 | }
|
1772 | }
|
1773 | }
|
1774 | function updateTemplateRef(vm) {
|
1775 | var rawBindings = vmStateManager.get(vm, 'rawBindings') || {};
|
1776 | if (!rawBindings || !Object.keys(rawBindings).length)
|
1777 | return;
|
1778 | var refs = vm.$refs;
|
1779 | var oldRefKeys = vmStateManager.get(vm, 'refs') || [];
|
1780 | for (var index = 0; index < oldRefKeys.length; index++) {
|
1781 | var key = oldRefKeys[index];
|
1782 | var setupValue = rawBindings[key];
|
1783 | if (!refs[key] && setupValue && isRef(setupValue)) {
|
1784 | setupValue.value = null;
|
1785 | }
|
1786 | }
|
1787 | var newKeys = Object.keys(refs);
|
1788 | var validNewKeys = [];
|
1789 | for (var index = 0; index < newKeys.length; index++) {
|
1790 | var key = newKeys[index];
|
1791 | var setupValue = rawBindings[key];
|
1792 | if (refs[key] && setupValue && isRef(setupValue)) {
|
1793 | setupValue.value = refs[key];
|
1794 | validNewKeys.push(key);
|
1795 | }
|
1796 | }
|
1797 | vmStateManager.set(vm, 'refs', validNewKeys);
|
1798 | }
|
1799 | function afterRender(vm) {
|
1800 | var stack = [vm._vnode];
|
1801 | while (stack.length) {
|
1802 | var vnode = stack.pop();
|
1803 | if (vnode) {
|
1804 | if (vnode.context)
|
1805 | updateTemplateRef(vnode.context);
|
1806 | if (vnode.children) {
|
1807 | for (var i = 0; i < vnode.children.length; ++i) {
|
1808 | stack.push(vnode.children[i]);
|
1809 | }
|
1810 | }
|
1811 | }
|
1812 | }
|
1813 | }
|
1814 | function updateVmAttrs(vm, ctx) {
|
1815 | var e_1, _a;
|
1816 | if (!vm) {
|
1817 | return;
|
1818 | }
|
1819 | var attrBindings = vmStateManager.get(vm, 'attrBindings');
|
1820 | if (!attrBindings && !ctx) {
|
1821 |
|
1822 | return;
|
1823 | }
|
1824 | if (!attrBindings) {
|
1825 | var observedData = reactive({});
|
1826 | attrBindings = { ctx: ctx, data: observedData };
|
1827 | vmStateManager.set(vm, 'attrBindings', attrBindings);
|
1828 | proxy(ctx, 'attrs', {
|
1829 | get: function () {
|
1830 | return attrBindings === null || attrBindings === void 0 ? void 0 : attrBindings.data;
|
1831 | },
|
1832 | set: function () {
|
1833 | warn("Cannot assign to '$attrs' because it is a read-only property", vm);
|
1834 | },
|
1835 | });
|
1836 | }
|
1837 | var source = vm.$attrs;
|
1838 | var _loop_1 = function (attr) {
|
1839 | if (!hasOwn(attrBindings.data, attr)) {
|
1840 | proxy(attrBindings.data, attr, {
|
1841 | get: function () {
|
1842 |
|
1843 | return vm.$attrs[attr];
|
1844 | },
|
1845 | });
|
1846 | }
|
1847 | };
|
1848 | try {
|
1849 | for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
1850 | var attr = _c.value;
|
1851 | _loop_1(attr);
|
1852 | }
|
1853 | }
|
1854 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
1855 | finally {
|
1856 | try {
|
1857 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
1858 | }
|
1859 | finally { if (e_1) throw e_1.error; }
|
1860 | }
|
1861 | }
|
1862 | function resolveScopedSlots(vm, slotsProxy) {
|
1863 | var parentVNode = vm.$options._parentVnode;
|
1864 | if (!parentVNode)
|
1865 | return;
|
1866 | var prevSlots = vmStateManager.get(vm, 'slots') || [];
|
1867 | var curSlots = resolveSlots(parentVNode.data.scopedSlots, vm.$slots);
|
1868 |
|
1869 | for (var index = 0; index < prevSlots.length; index++) {
|
1870 | var key = prevSlots[index];
|
1871 | if (!curSlots[key]) {
|
1872 | delete slotsProxy[key];
|
1873 | }
|
1874 | }
|
1875 |
|
1876 | var slotNames = Object.keys(curSlots);
|
1877 | for (var index = 0; index < slotNames.length; index++) {
|
1878 | var key = slotNames[index];
|
1879 | if (!slotsProxy[key]) {
|
1880 | slotsProxy[key] = createSlotProxy(vm, key);
|
1881 | }
|
1882 | }
|
1883 | vmStateManager.set(vm, 'slots', slotNames);
|
1884 | }
|
1885 | function activateCurrentInstance(instance, fn, onError) {
|
1886 | var preVm = getCurrentInstance();
|
1887 | setCurrentInstance(instance);
|
1888 | try {
|
1889 | return fn(instance);
|
1890 | }
|
1891 | catch (
|
1892 |
|
1893 | err) {
|
1894 | if (onError) {
|
1895 | onError(err);
|
1896 | }
|
1897 | else {
|
1898 | throw err;
|
1899 | }
|
1900 | }
|
1901 | finally {
|
1902 | setCurrentInstance(preVm);
|
1903 | }
|
1904 | }
|
1905 |
|
1906 | function mixin(Vue) {
|
1907 | Vue.mixin({
|
1908 | beforeCreate: functionApiInit,
|
1909 | mounted: function () {
|
1910 | afterRender(this);
|
1911 | },
|
1912 | beforeUpdate: function () {
|
1913 | updateVmAttrs(this);
|
1914 | },
|
1915 | updated: function () {
|
1916 | afterRender(this);
|
1917 | },
|
1918 | });
|
1919 | |
1920 |
|
1921 |
|
1922 | function functionApiInit() {
|
1923 | var vm = this;
|
1924 | var $options = vm.$options;
|
1925 | var setup = $options.setup, render = $options.render;
|
1926 | if (render) {
|
1927 |
|
1928 | $options.render = function () {
|
1929 | var _this = this;
|
1930 | var args = [];
|
1931 | for (var _i = 0; _i < arguments.length; _i++) {
|
1932 | args[_i] = arguments[_i];
|
1933 | }
|
1934 | return activateCurrentInstance(toVue3ComponentInstance(vm), function () {
|
1935 | return render.apply(_this, args);
|
1936 | });
|
1937 | };
|
1938 | }
|
1939 | if (!setup) {
|
1940 | return;
|
1941 | }
|
1942 | if (!isFunction(setup)) {
|
1943 | {
|
1944 | warn('The "setup" option should be a function that returns a object in component definitions.', vm);
|
1945 | }
|
1946 | return;
|
1947 | }
|
1948 | var data = $options.data;
|
1949 |
|
1950 | $options.data = function wrappedData() {
|
1951 | initSetup(vm, vm.$props);
|
1952 | return isFunction(data)
|
1953 | ? data.call(vm, vm)
|
1954 | : data || {};
|
1955 | };
|
1956 | }
|
1957 | function initSetup(vm, props) {
|
1958 | if (props === void 0) { props = {}; }
|
1959 | var setup = vm.$options.setup;
|
1960 | var ctx = createSetupContext(vm);
|
1961 | var instance = toVue3ComponentInstance(vm);
|
1962 | instance.setupContext = ctx;
|
1963 |
|
1964 | def(props, '__ob__', createObserver());
|
1965 |
|
1966 | resolveScopedSlots(vm, ctx.slots);
|
1967 | var binding;
|
1968 | activateCurrentInstance(instance, function () {
|
1969 |
|
1970 | binding = setup(props, ctx);
|
1971 | });
|
1972 | if (!binding)
|
1973 | return;
|
1974 | if (isFunction(binding)) {
|
1975 |
|
1976 | var bindingFunc_1 = binding;
|
1977 |
|
1978 | vm.$options.render = function () {
|
1979 | resolveScopedSlots(vm, ctx.slots);
|
1980 | return activateCurrentInstance(instance, function () { return bindingFunc_1(); });
|
1981 | };
|
1982 | return;
|
1983 | }
|
1984 | else if (isObject(binding)) {
|
1985 | if (isReactive(binding)) {
|
1986 | binding = toRefs(binding);
|
1987 | }
|
1988 | vmStateManager.set(vm, 'rawBindings', binding);
|
1989 | var bindingObj_1 = binding;
|
1990 | Object.keys(bindingObj_1).forEach(function (name) {
|
1991 | var bindingValue = bindingObj_1[name];
|
1992 | if (!isRef(bindingValue)) {
|
1993 | if (!isReactive(bindingValue)) {
|
1994 | if (isFunction(bindingValue)) {
|
1995 | var copy_1 = bindingValue;
|
1996 | bindingValue = bindingValue.bind(vm);
|
1997 | Object.keys(copy_1).forEach(function (ele) {
|
1998 | bindingValue[ele] = copy_1[ele];
|
1999 | });
|
2000 | }
|
2001 | else if (!isObject(bindingValue)) {
|
2002 | bindingValue = ref(bindingValue);
|
2003 | }
|
2004 | else if (hasReactiveArrayChild(bindingValue)) {
|
2005 |
|
2006 |
|
2007 | customReactive(bindingValue);
|
2008 | }
|
2009 | }
|
2010 | else if (isArray(bindingValue)) {
|
2011 | bindingValue = ref(bindingValue);
|
2012 | }
|
2013 | }
|
2014 | asVmProperty(vm, name, bindingValue);
|
2015 | });
|
2016 | return;
|
2017 | }
|
2018 | {
|
2019 | assert(false, "\"setup\" must return a \"Object\" or a \"Function\", got \"".concat(Object.prototype.toString
|
2020 | .call(binding)
|
2021 | .slice(8, -1), "\""));
|
2022 | }
|
2023 | }
|
2024 | function customReactive(target, seen) {
|
2025 | if (seen === void 0) { seen = new Set(); }
|
2026 | if (seen.has(target))
|
2027 | return;
|
2028 | if (!isPlainObject(target) ||
|
2029 | isRef(target) ||
|
2030 | isReactive(target) ||
|
2031 | isRaw(target))
|
2032 | return;
|
2033 | var Vue = getVueConstructor();
|
2034 |
|
2035 | var defineReactive = Vue.util.defineReactive;
|
2036 | Object.keys(target).forEach(function (k) {
|
2037 | var val = target[k];
|
2038 | defineReactive(target, k, val);
|
2039 | if (val) {
|
2040 | seen.add(val);
|
2041 | customReactive(val, seen);
|
2042 | }
|
2043 | return;
|
2044 | });
|
2045 | }
|
2046 | function hasReactiveArrayChild(target, visited) {
|
2047 | if (visited === void 0) { visited = new Map(); }
|
2048 | if (visited.has(target)) {
|
2049 | return visited.get(target);
|
2050 | }
|
2051 | visited.set(target, false);
|
2052 | if (isArray(target) && isReactive(target)) {
|
2053 | visited.set(target, true);
|
2054 | return true;
|
2055 | }
|
2056 | if (!isPlainObject(target) || isRaw(target) || isRef(target)) {
|
2057 | return false;
|
2058 | }
|
2059 | return Object.keys(target).some(function (x) {
|
2060 | return hasReactiveArrayChild(target[x], visited);
|
2061 | });
|
2062 | }
|
2063 | function createSetupContext(vm) {
|
2064 | var ctx = { slots: {} };
|
2065 | var propsPlain = [
|
2066 | 'root',
|
2067 | 'parent',
|
2068 | 'refs',
|
2069 | 'listeners',
|
2070 | 'isServer',
|
2071 | 'ssrContext',
|
2072 | ];
|
2073 | var methodReturnVoid = ['emit'];
|
2074 | propsPlain.forEach(function (key) {
|
2075 | var srcKey = "$".concat(key);
|
2076 | proxy(ctx, key, {
|
2077 | get: function () { return vm[srcKey]; },
|
2078 | set: function () {
|
2079 | warn("Cannot assign to '".concat(key, "' because it is a read-only property"), vm);
|
2080 | },
|
2081 | });
|
2082 | });
|
2083 | updateVmAttrs(vm, ctx);
|
2084 | methodReturnVoid.forEach(function (key) {
|
2085 | var srcKey = "$".concat(key);
|
2086 | proxy(ctx, key, {
|
2087 | get: function () {
|
2088 | return function () {
|
2089 | var args = [];
|
2090 | for (var _i = 0; _i < arguments.length; _i++) {
|
2091 | args[_i] = arguments[_i];
|
2092 | }
|
2093 | var fn = vm[srcKey];
|
2094 | fn.apply(vm, args);
|
2095 | };
|
2096 | },
|
2097 | });
|
2098 | });
|
2099 | return ctx;
|
2100 | }
|
2101 | }
|
2102 |
|
2103 | |
2104 |
|
2105 |
|
2106 | function mergeData(from, to) {
|
2107 | if (!from)
|
2108 | return to;
|
2109 | if (!to)
|
2110 | return from;
|
2111 | var key;
|
2112 | var toVal;
|
2113 | var fromVal;
|
2114 | var keys = hasSymbol ? Reflect.ownKeys(from) : Object.keys(from);
|
2115 | for (var i = 0; i < keys.length; i++) {
|
2116 | key = keys[i];
|
2117 |
|
2118 | if (key === '__ob__')
|
2119 | continue;
|
2120 | toVal = to[key];
|
2121 | fromVal = from[key];
|
2122 | if (!hasOwn(to, key)) {
|
2123 | to[key] = fromVal;
|
2124 | }
|
2125 | else if (toVal !== fromVal &&
|
2126 | isPlainObject(toVal) &&
|
2127 | !isRef(toVal) &&
|
2128 | isPlainObject(fromVal) &&
|
2129 | !isRef(fromVal)) {
|
2130 | mergeData(fromVal, toVal);
|
2131 | }
|
2132 | }
|
2133 | return to;
|
2134 | }
|
2135 | function install(Vue) {
|
2136 | if (isVueRegistered(Vue)) {
|
2137 | {
|
2138 | warn('[vue-composition-api] already installed. Vue.use(VueCompositionAPI) should be called only once.');
|
2139 | }
|
2140 | return;
|
2141 | }
|
2142 | {
|
2143 | if (Vue.version) {
|
2144 | if (Vue.version[0] !== '2' || Vue.version[1] !== '.') {
|
2145 | warn("[vue-composition-api] only works with Vue 2, v".concat(Vue.version, " found."));
|
2146 | }
|
2147 | }
|
2148 | else {
|
2149 | warn('[vue-composition-api] no Vue version found');
|
2150 | }
|
2151 | }
|
2152 | Vue.config.optionMergeStrategies.setup = function (parent, child) {
|
2153 | return function mergedSetupFn(props, context) {
|
2154 | return mergeData(isFunction(parent) ? parent(props, context) || {} : undefined, isFunction(child) ? child(props, context) || {} : undefined);
|
2155 | };
|
2156 | };
|
2157 | setVueConstructor(Vue);
|
2158 | mixin(Vue);
|
2159 | }
|
2160 | var Plugin = {
|
2161 | install: function (Vue) { return install(Vue); },
|
2162 | };
|
2163 |
|
2164 |
|
2165 | function defineComponent(options) {
|
2166 | return options;
|
2167 | }
|
2168 |
|
2169 | function defineAsyncComponent(source) {
|
2170 | if (isFunction(source)) {
|
2171 | source = { loader: source };
|
2172 | }
|
2173 | var loader = source.loader, loadingComponent = source.loadingComponent, errorComponent = source.errorComponent, _a = source.delay, delay = _a === void 0 ? 200 : _a, timeout = source.timeout,
|
2174 | _b = source.suspensible,
|
2175 | suspensible = _b === void 0 ? false : _b,
|
2176 | userOnError = source.onError;
|
2177 | if (suspensible) {
|
2178 | warn("The suspensiblbe option for async components is not supported in Vue2. It is ignored.");
|
2179 | }
|
2180 | var pendingRequest = null;
|
2181 | var retries = 0;
|
2182 | var retry = function () {
|
2183 | retries++;
|
2184 | pendingRequest = null;
|
2185 | return load();
|
2186 | };
|
2187 | var load = function () {
|
2188 | var thisRequest;
|
2189 | return (pendingRequest ||
|
2190 | (thisRequest = pendingRequest =
|
2191 | loader()
|
2192 | .catch(function (err) {
|
2193 | err = err instanceof Error ? err : new Error(String(err));
|
2194 | if (userOnError) {
|
2195 | return new Promise(function (resolve, reject) {
|
2196 | var userRetry = function () { return resolve(retry()); };
|
2197 | var userFail = function () { return reject(err); };
|
2198 | userOnError(err, userRetry, userFail, retries + 1);
|
2199 | });
|
2200 | }
|
2201 | else {
|
2202 | throw err;
|
2203 | }
|
2204 | })
|
2205 | .then(function (comp) {
|
2206 | if (thisRequest !== pendingRequest && pendingRequest) {
|
2207 | return pendingRequest;
|
2208 | }
|
2209 | if (!comp) {
|
2210 | warn("Async component loader resolved to undefined. " +
|
2211 | "If you are using retry(), make sure to return its return value.");
|
2212 | }
|
2213 |
|
2214 | if (comp &&
|
2215 | (comp.__esModule || comp[Symbol.toStringTag] === 'Module')) {
|
2216 | comp = comp.default;
|
2217 | }
|
2218 | if (comp && !isObject(comp) && !isFunction(comp)) {
|
2219 | throw new Error("Invalid async component load result: ".concat(comp));
|
2220 | }
|
2221 | return comp;
|
2222 | })));
|
2223 | };
|
2224 | return function () {
|
2225 | var component = load();
|
2226 | return {
|
2227 | component: component,
|
2228 | delay: delay,
|
2229 | timeout: timeout,
|
2230 | error: errorComponent,
|
2231 | loading: loadingComponent,
|
2232 | };
|
2233 | };
|
2234 | }
|
2235 |
|
2236 | var version = "1.7.2";
|
2237 |
|
2238 | if (typeof window !== 'undefined' && window.Vue) {
|
2239 | window.Vue.use(Plugin);
|
2240 | }
|
2241 |
|
2242 | exports.EffectScope = EffectScope;
|
2243 | exports.computed = computed;
|
2244 | exports.createApp = createApp;
|
2245 | exports.createRef = createRef;
|
2246 | exports.customRef = customRef;
|
2247 | exports["default"] = Plugin;
|
2248 | exports.defineAsyncComponent = defineAsyncComponent;
|
2249 | exports.defineComponent = defineComponent;
|
2250 | exports.del = del;
|
2251 | exports.effectScope = effectScope;
|
2252 | exports.getCurrentInstance = getCurrentInstance;
|
2253 | exports.getCurrentScope = getCurrentScope;
|
2254 | exports.h = createElement;
|
2255 | exports.inject = inject;
|
2256 | exports.isRaw = isRaw;
|
2257 | exports.isReactive = isReactive;
|
2258 | exports.isReadonly = isReadonly;
|
2259 | exports.isRef = isRef;
|
2260 | exports.markRaw = markRaw;
|
2261 | exports.nextTick = nextTick;
|
2262 | exports.onActivated = onActivated;
|
2263 | exports.onBeforeMount = onBeforeMount;
|
2264 | exports.onBeforeUnmount = onBeforeUnmount;
|
2265 | exports.onBeforeUpdate = onBeforeUpdate;
|
2266 | exports.onDeactivated = onDeactivated;
|
2267 | exports.onErrorCaptured = onErrorCaptured;
|
2268 | exports.onMounted = onMounted;
|
2269 | exports.onScopeDispose = onScopeDispose;
|
2270 | exports.onServerPrefetch = onServerPrefetch;
|
2271 | exports.onUnmounted = onUnmounted;
|
2272 | exports.onUpdated = onUpdated;
|
2273 | exports.provide = provide;
|
2274 | exports.proxyRefs = proxyRefs;
|
2275 | exports.reactive = reactive;
|
2276 | exports.readonly = readonly;
|
2277 | exports.ref = ref;
|
2278 | exports.set = set$1;
|
2279 | exports.shallowReactive = shallowReactive;
|
2280 | exports.shallowReadonly = shallowReadonly;
|
2281 | exports.shallowRef = shallowRef;
|
2282 | exports.toRaw = toRaw;
|
2283 | exports.toRef = toRef;
|
2284 | exports.toRefs = toRefs;
|
2285 | exports.triggerRef = triggerRef;
|
2286 | exports.unref = unref;
|
2287 | exports.useAttrs = useAttrs;
|
2288 | exports.useCSSModule = useCSSModule;
|
2289 | exports.useCssModule = useCssModule;
|
2290 | exports.useSlots = useSlots;
|
2291 | exports.version = version;
|
2292 | exports.warn = warn$1;
|
2293 | exports.watch = watch;
|
2294 | exports.watchEffect = watchEffect;
|
2295 | exports.watchPostEffect = watchPostEffect;
|
2296 | exports.watchSyncEffect = watchSyncEffect;
|
2297 |
|
2298 | Object.defineProperty(exports, '__esModule', { value: true });
|
2299 |
|
2300 | }));
|