| | |
| | | /** |
| | | * @vue/reactivity v3.5.25 |
| | | * @vue/reactivity v3.5.32 |
| | | * (c) 2018-present Yuxi (Evan) You and Vue contributors |
| | | * @license MIT |
| | | **/ |
| | |
| | | |
| | | let activeEffectScope; |
| | | class EffectScope { |
| | | // TODO isolatedDeclarations "__v_skip" |
| | | constructor(detached = false) { |
| | | this.detached = detached; |
| | | /** |
| | |
| | | */ |
| | | this.cleanups = []; |
| | | this._isPaused = false; |
| | | this.__v_skip = true; |
| | | this.parent = activeEffectScope; |
| | | if (!detached && activeEffectScope) { |
| | | this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push( |
| | |
| | | } |
| | | } |
| | | const targetMap = /* @__PURE__ */ new WeakMap(); |
| | | const ITERATE_KEY = Symbol( |
| | | const ITERATE_KEY = /* @__PURE__ */ Symbol( |
| | | "Object iterate" |
| | | ); |
| | | const MAP_KEY_ITERATE_KEY = Symbol( |
| | | const MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol( |
| | | "Map keys iterate" |
| | | ); |
| | | const ARRAY_ITERATE_KEY = Symbol( |
| | | const ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol( |
| | | "Array iterate" |
| | | ); |
| | | function track(target, type, key) { |
| | |
| | | } |
| | | function reduce(self, method, fn, args) { |
| | | const arr = shallowReadArray(self); |
| | | const needsWrap = arr !== self && !isShallow(self); |
| | | let wrappedFn = fn; |
| | | let wrapInitialAccumulator = false; |
| | | if (arr !== self) { |
| | | if (!isShallow(self)) { |
| | | if (needsWrap) { |
| | | wrapInitialAccumulator = args.length === 0; |
| | | wrappedFn = function(acc, item, index) { |
| | | if (wrapInitialAccumulator) { |
| | | wrapInitialAccumulator = false; |
| | | acc = toWrapped(self, acc); |
| | | } |
| | | return fn.call(this, acc, toWrapped(self, item), index, self); |
| | | }; |
| | | } else if (fn.length > 3) { |
| | |
| | | }; |
| | | } |
| | | } |
| | | return arr[method](wrappedFn, ...args); |
| | | const result = arr[method](wrappedFn, ...args); |
| | | return wrapInitialAccumulator ? toWrapped(self, result) : result; |
| | | } |
| | | function searchProxy(self, method, args) { |
| | | const arr = toRaw(self); |
| | |
| | | "iterate", |
| | | isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY |
| | | ); |
| | | return { |
| | | // iterator protocol |
| | | next() { |
| | | const { value, done } = innerIterator.next(); |
| | | return done ? { value, done } : { |
| | | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), |
| | | done |
| | | }; |
| | | }, |
| | | // iterable protocol |
| | | [Symbol.iterator]() { |
| | | return this; |
| | | return extend( |
| | | // inheriting all iterator properties |
| | | Object.create(innerIterator), |
| | | { |
| | | // iterator protocol |
| | | next() { |
| | | const { value, done } = innerIterator.next(); |
| | | return done ? { value, done } : { |
| | | value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value), |
| | | done |
| | | }; |
| | | } |
| | | } |
| | | }; |
| | | ); |
| | | }; |
| | | } |
| | | function createReadonlyMethod(type) { |
| | |
| | | clear: createReadonlyMethod("clear") |
| | | } : { |
| | | add(value) { |
| | | if (!shallow && !isShallow(value) && !isReadonly(value)) { |
| | | value = toRaw(value); |
| | | } |
| | | const target = toRaw(this); |
| | | const proto = getProto(target); |
| | | const hadKey = proto.has.call(target, value); |
| | | const rawValue = toRaw(value); |
| | | const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value; |
| | | const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue); |
| | | if (!hadKey) { |
| | | target.add(value); |
| | | trigger(target, "add", value, value); |
| | | target.add(valueToAdd); |
| | | trigger(target, "add", valueToAdd, valueToAdd); |
| | | } |
| | | return this; |
| | | }, |
| | |
| | | function getTargetType(value) { |
| | | return value["__v_skip"] || !Object.isExtensible(value) ? 0 /* INVALID */ : targetTypeMap(toRawType(value)); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function reactive(target) { |
| | | if (isReadonly(target)) { |
| | | if (/* @__PURE__ */ isReadonly(target)) { |
| | | return target; |
| | | } |
| | | return createReactiveObject( |
| | |
| | | reactiveMap |
| | | ); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function shallowReactive(target) { |
| | | return createReactiveObject( |
| | | target, |
| | |
| | | shallowReactiveMap |
| | | ); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function readonly(target) { |
| | | return createReactiveObject( |
| | | target, |
| | |
| | | readonlyMap |
| | | ); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function shallowReadonly(target) { |
| | | return createReactiveObject( |
| | | target, |
| | |
| | | proxyMap.set(target, proxy); |
| | | return proxy; |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function isReactive(value) { |
| | | if (isReadonly(value)) { |
| | | return isReactive(value["__v_raw"]); |
| | | if (/* @__PURE__ */ isReadonly(value)) { |
| | | return /* @__PURE__ */ isReactive(value["__v_raw"]); |
| | | } |
| | | return !!(value && value["__v_isReactive"]); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function isReadonly(value) { |
| | | return !!(value && value["__v_isReadonly"]); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function isShallow(value) { |
| | | return !!(value && value["__v_isShallow"]); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function isProxy(value) { |
| | | return value ? !!value["__v_raw"] : false; |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function toRaw(observed) { |
| | | const raw = observed && observed["__v_raw"]; |
| | | return raw ? toRaw(raw) : observed; |
| | | return raw ? /* @__PURE__ */ toRaw(raw) : observed; |
| | | } |
| | | function markRaw(value) { |
| | | if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) { |
| | |
| | | } |
| | | return value; |
| | | } |
| | | const toReactive = (value) => isObject(value) ? reactive(value) : value; |
| | | const toReadonly = (value) => isObject(value) ? readonly(value) : value; |
| | | const toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value; |
| | | const toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value; |
| | | |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function isRef(r) { |
| | | return r ? r["__v_isRef"] === true : false; |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function ref(value) { |
| | | return createRef(value, false); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function shallowRef(value) { |
| | | return createRef(value, true); |
| | | } |
| | | function createRef(rawValue, shallow) { |
| | | if (isRef(rawValue)) { |
| | | if (/* @__PURE__ */ isRef(rawValue)) { |
| | | return rawValue; |
| | | } |
| | | return new RefImpl(rawValue, shallow); |
| | |
| | | } |
| | | } |
| | | function unref(ref2) { |
| | | return isRef(ref2) ? ref2.value : ref2; |
| | | return /* @__PURE__ */ isRef(ref2) ? ref2.value : ref2; |
| | | } |
| | | function toValue(source) { |
| | | return isFunction(source) ? source() : unref(source); |
| | |
| | | get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)), |
| | | set: (target, key, value, receiver) => { |
| | | const oldValue = target[key]; |
| | | if (isRef(oldValue) && !isRef(value)) { |
| | | if (/* @__PURE__ */ isRef(oldValue) && !/* @__PURE__ */ isRef(value)) { |
| | | oldValue.value = value; |
| | | return true; |
| | | } else { |
| | |
| | | function customRef(factory) { |
| | | return new CustomRefImpl(factory); |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function toRefs(object) { |
| | | if (!isProxy(object)) { |
| | | warn(`toRefs() expects a reactive object but received a plain one.`); |
| | |
| | | return ret; |
| | | } |
| | | class ObjectRefImpl { |
| | | constructor(_object, _key, _defaultValue) { |
| | | constructor(_object, key, _defaultValue) { |
| | | this._object = _object; |
| | | this._key = _key; |
| | | this._defaultValue = _defaultValue; |
| | | this["__v_isRef"] = true; |
| | | this._value = void 0; |
| | | this._key = isSymbol(key) ? key : String(key); |
| | | this._raw = toRaw(_object); |
| | | let shallow = true; |
| | | let obj = _object; |
| | | if (!isArray(_object) || !isIntegerKey(String(_key))) { |
| | | if (!isArray(_object) || isSymbol(this._key) || !isIntegerKey(this._key)) { |
| | | do { |
| | | shallow = !isProxy(obj) || isShallow(obj); |
| | | } while (shallow && (obj = obj["__v_raw"])); |
| | |
| | | return this._value = val === void 0 ? this._defaultValue : val; |
| | | } |
| | | set value(newVal) { |
| | | if (this._shallow && isRef(this._raw[this._key])) { |
| | | if (this._shallow && /* @__PURE__ */ isRef(this._raw[this._key])) { |
| | | const nestedRef = this._object[this._key]; |
| | | if (isRef(nestedRef)) { |
| | | if (/* @__PURE__ */ isRef(nestedRef)) { |
| | | nestedRef.value = newVal; |
| | | return; |
| | | } |
| | |
| | | return this._value = this._getter(); |
| | | } |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function toRef(source, key, defaultValue) { |
| | | if (isRef(source)) { |
| | | if (/* @__PURE__ */ isRef(source)) { |
| | | return source; |
| | | } else if (isFunction(source)) { |
| | | return new GetterRefImpl(source); |
| | | } else if (isObject(source) && arguments.length > 1) { |
| | | return propertyToRef(source, key, defaultValue); |
| | | } else { |
| | | return ref(source); |
| | | return /* @__PURE__ */ ref(source); |
| | | } |
| | | } |
| | | function propertyToRef(source, key, defaultValue) { |
| | |
| | | } |
| | | } |
| | | } |
| | | // @__NO_SIDE_EFFECTS__ |
| | | function computed(getterOrOptions, debugOptions, isSSR = false) { |
| | | let getter; |
| | | let setter; |