You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
680 KiB

3 months ago
  1. {"ast":null,"code":"import { noop, resolveUnref, isClient, isString, tryOnScopeDispose, isIOS, tryOnMounted, computedWithControl, promiseTimeout, isFunction, resolveRef, increaseWithUnit, useTimeoutFn, pausableWatch, createEventHook, timestamp, pausableFilter, watchIgnorable, debounceFilter, createFilterWrapper, bypassFilter, createSingletonPromise, toRefs, containsProp, until, hasOwn, throttleFilter, useDebounceFn, useThrottleFn, isObject, isNumber, useIntervalFn, clamp, syncRef, objectPick, tryOnUnmounted, watchWithFilter, identity, isDef } from '@vueuse/shared';\nexport * from '@vueuse/shared';\nimport { isRef, ref, shallowRef, watchEffect, computed, inject, unref, watch, getCurrentInstance, customRef, onUpdated, reactive, nextTick, onMounted, markRaw, readonly, getCurrentScope, isVue2, set, del, isReadonly, onBeforeUpdate } from 'vue-demi';\nfunction computedAsync(evaluationCallback, initialState, optionsOrRef) {\n let options;\n if (isRef(optionsOrRef)) {\n options = {\n evaluating: optionsOrRef\n };\n } else {\n options = optionsOrRef || {};\n }\n const {\n lazy = false,\n evaluating = void 0,\n shallow = false,\n onError = noop\n } = options;\n const started = ref(!lazy);\n const current = shallow ? shallowRef(initialState) : ref(initialState);\n let counter = 0;\n watchEffect(async onInvalidate => {\n if (!started.value) return;\n counter++;\n const counterAtBeginning = counter;\n let hasFinished = false;\n if (evaluating) {\n Promise.resolve().then(() => {\n evaluating.value = true;\n });\n }\n try {\n const result = await evaluationCallback(cancelCallback => {\n onInvalidate(() => {\n if (evaluating) evaluating.value = false;\n if (!hasFinished) cancelCallback();\n });\n });\n if (counterAtBeginning === counter) current.value = result;\n } catch (e) {\n onError(e);\n } finally {\n if (evaluating && counterAtBeginning === counter) evaluating.value = false;\n hasFinished = true;\n }\n });\n if (lazy) {\n return computed(() => {\n started.value = true;\n return current.value;\n });\n } else {\n return current;\n }\n}\nfunction computedInject(key, options, defaultSource, treatDefaultAsFactory) {\n let source = inject(key);\n if (defaultSource) source = inject(key, defaultSource);\n if (treatDefaultAsFactory) source = inject(key, defaultSource, treatDefaultAsFactory);\n if (typeof options === \"function\") {\n return computed(ctx => options(source, ctx));\n } else {\n return computed({\n get: ctx => options.get(source, ctx),\n set: options.set\n });\n }\n}\nconst createUnrefFn = fn => {\n return function (...args) {\n return fn.apply(this, args.map(i => unref(i)));\n };\n};\nfunction unrefElement(elRef) {\n var _a;\n const plain = resolveUnref(elRef);\n return (_a = plain == null ? void 0 : plain.$el) != null ? _a : plain;\n}\nconst defaultWindow = isClient ? window : void 0;\nconst defaultDocument = isClient ? window.document : void 0;\nconst defaultNavigator = isClient ? window.navigator : void 0;\nconst defaultLocation = isClient ? window.location : void 0;\nfunction useEventListener(...args) {\n let target;\n let events;\n let listeners;\n let options;\n if (isString(args[0]) || Array.isArray(args[0])) {\n [events, listeners, options] = args;\n target = defaultWindow;\n } else {\n [target, events, listeners, options] = args;\n }\n if (!target) return noop;\n if (!Array.isArray(events)) events = [events];\n if (!Array.isArray(listeners)) listeners = [listeners];\n const cleanups = [];\n const cleanup = () => {\n cleanups.forEach(fn => fn());\n cleanups.length = 0;\n };\n const register = (el, event, listener, options2) => {\n el.addEventListener(event, listener, options2);\n return () => el.removeEventListener(event, listener, options2);\n };\n const stopWatch = watch(() => [unrefElement(target), resolveUnref(options)], ([el, options2]) => {\n cleanup();\n if (!el) return;