unplugin-auto-import
Advanced tools
| //#region rolldown:runtime | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| //#endregion | ||
| const node_path = __toESM(require("node:path")); | ||
| const local_pkg = __toESM(require("local-pkg")); | ||
| const picomatch = __toESM(require("picomatch")); | ||
| const unplugin = __toESM(require("unplugin")); | ||
| const node_fs = __toESM(require("node:fs")); | ||
| const node_process = __toESM(require("node:process")); | ||
| const magic_string = __toESM(require("magic-string")); | ||
| const unimport = __toESM(require("unimport")); | ||
| const unplugin_utils = __toESM(require("unplugin-utils")); | ||
| //#region node_modules/.pnpm/@antfu+utils@9.2.0/node_modules/@antfu/utils/dist/index.mjs | ||
| function toArray(array) { | ||
| array = array ?? []; | ||
| return Array.isArray(array) ? array : [array]; | ||
| } | ||
| function slash(str) { | ||
| return str.replace(/\\/g, "/"); | ||
| } | ||
| const VOID = Symbol("p-void"); | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) | ||
| * are most useful. | ||
| * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, | ||
| * as-is, to `callback` when the throttled-function is executed. | ||
| * @param {object} [options] - An object to configure options. | ||
| * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds | ||
| * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed | ||
| * one final time after the last throttled-function call. (After the throttled-function has not been called for | ||
| * `delay` milliseconds, the internal counter is reset). | ||
| * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback | ||
| * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that | ||
| * callback will never executed if both noLeading = true and noTrailing = true. | ||
| * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is | ||
| * false (at end), schedule `callback` to execute after `delay` ms. | ||
| * | ||
| * @returns {Function} A new, throttled, function. | ||
| */ | ||
| function throttle$1(delay, callback, options) { | ||
| var _ref = options || {}, _ref$noTrailing = _ref.noTrailing, noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing, _ref$noLeading = _ref.noLeading, noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading, _ref$debounceMode = _ref.debounceMode, debounceMode = _ref$debounceMode === void 0 ? void 0 : _ref$debounceMode; | ||
| var timeoutID; | ||
| var cancelled = false; | ||
| var lastExec = 0; | ||
| function clearExistingTimeout() { | ||
| if (timeoutID) clearTimeout(timeoutID); | ||
| } | ||
| function cancel(options$1) { | ||
| var _ref2 = options$1 || {}, _ref2$upcomingOnly = _ref2.upcomingOnly, upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly; | ||
| clearExistingTimeout(); | ||
| cancelled = !upcomingOnly; | ||
| } | ||
| function wrapper() { | ||
| for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) arguments_[_key] = arguments[_key]; | ||
| var self = this; | ||
| var elapsed = Date.now() - lastExec; | ||
| if (cancelled) return; | ||
| function exec() { | ||
| lastExec = Date.now(); | ||
| callback.apply(self, arguments_); | ||
| } | ||
| function clear() { | ||
| timeoutID = void 0; | ||
| } | ||
| if (!noLeading && debounceMode && !timeoutID) exec(); | ||
| clearExistingTimeout(); | ||
| if (debounceMode === void 0 && elapsed > delay) if (noLeading) { | ||
| lastExec = Date.now(); | ||
| if (!noTrailing) timeoutID = setTimeout(debounceMode ? clear : exec, delay); | ||
| } else exec(); | ||
| else if (noTrailing !== true) timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === void 0 ? delay - elapsed : delay); | ||
| } | ||
| wrapper.cancel = cancel; | ||
| return wrapper; | ||
| } | ||
| function throttle(...args) { | ||
| return throttle$1(...args); | ||
| } | ||
| //#endregion | ||
| //#region src/presets/ahooks.ts | ||
| let _cache$2; | ||
| var ahooks_default = () => { | ||
| if (!_cache$2) { | ||
| let indexesJson; | ||
| try { | ||
| const path$1 = (0, local_pkg.resolveModule)("ahooks/metadata.json"); | ||
| indexesJson = JSON.parse((0, node_fs.readFileSync)(path$1, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load ahooks, have you installed it?"); | ||
| } | ||
| if (indexesJson) _cache$2 = { ahooks: indexesJson.functions.flatMap((i) => [i.name, ...i.alias || []]) }; | ||
| } | ||
| return _cache$2 || {}; | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/jotai.ts | ||
| const jotai = { jotai: [ | ||
| "atom", | ||
| "useAtom", | ||
| "useAtomValue", | ||
| "useSetAtom" | ||
| ] }; | ||
| const jotaiUtils = { "jotai/utils": [ | ||
| "atomWithReset", | ||
| "useResetAtom", | ||
| "useReducerAtom", | ||
| "atomWithReducer", | ||
| "atomFamily", | ||
| "selectAtom", | ||
| "useAtomCallback", | ||
| "freezeAtom", | ||
| "freezeAtomCreator", | ||
| "splitAtom", | ||
| "atomWithDefault", | ||
| "waitForAll", | ||
| "atomWithStorage", | ||
| "atomWithHash", | ||
| "createJSONStorage", | ||
| "atomWithObservable", | ||
| "useHydrateAtoms", | ||
| "loadable" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/mobx.ts | ||
| const mobx = [ | ||
| "makeObservable", | ||
| "makeAutoObservable", | ||
| "extendObservable", | ||
| "observable", | ||
| "action", | ||
| "runInAction", | ||
| "flow", | ||
| "flowResult", | ||
| "computed", | ||
| "autorun", | ||
| "reaction", | ||
| "when", | ||
| "onReactionError", | ||
| "intercept", | ||
| "observe", | ||
| "onBecomeObserved", | ||
| "onBecomeUnobserved", | ||
| "toJS" | ||
| ]; | ||
| var mobx_default = { mobx: [...mobx] }; | ||
| //#endregion | ||
| //#region src/presets/mobx-react-lite.ts | ||
| var mobx_react_lite_default = { "mobx-react-lite": [ | ||
| "observer", | ||
| "Observer", | ||
| "useLocalObservable" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/preact.ts | ||
| var preact_default = { "preact/hooks": [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/quasar.ts | ||
| var quasar_default = { quasar: [ | ||
| "useQuasar", | ||
| "useDialogPluginComponent", | ||
| "useFormChild", | ||
| "useMeta" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/react.ts | ||
| const CommonReactAPI = [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer", | ||
| "useImperativeHandle", | ||
| "useDebugValue", | ||
| "useDeferredValue", | ||
| "useLayoutEffect", | ||
| "useTransition", | ||
| "startTransition", | ||
| "useSyncExternalStore", | ||
| "useInsertionEffect", | ||
| "useId", | ||
| "lazy", | ||
| "memo", | ||
| "createRef", | ||
| "forwardRef" | ||
| ]; | ||
| var react_default = { react: CommonReactAPI }; | ||
| //#endregion | ||
| //#region src/presets/react-i18next.ts | ||
| var react_i18next_default = { "react-i18next": ["useTranslation"] }; | ||
| //#endregion | ||
| //#region src/presets/react-router.ts | ||
| /** | ||
| * Only compatible with React Router v6. | ||
| */ | ||
| const ReactRouterHooks = [ | ||
| "useOutletContext", | ||
| "useHref", | ||
| "useInRouterContext", | ||
| "useLocation", | ||
| "useNavigationType", | ||
| "useNavigate", | ||
| "useOutlet", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRoutes" | ||
| ]; | ||
| var react_router_default = { "react-router": [...ReactRouterHooks] }; | ||
| //#endregion | ||
| //#region src/presets/react-router-dom.ts | ||
| /** | ||
| * Only compatible with React Router Dom v6. | ||
| */ | ||
| var react_router_dom_default = { "react-router-dom": [ | ||
| ...ReactRouterHooks, | ||
| "useLinkClickHandler", | ||
| "useSearchParams", | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Routes" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/recoil.ts | ||
| var recoil_default = { recoil: [ | ||
| "atom", | ||
| "selector", | ||
| "useRecoilState", | ||
| "useRecoilValue", | ||
| "useSetRecoilState", | ||
| "useResetRecoilState", | ||
| "useRecoilStateLoadable", | ||
| "useRecoilValueLoadable", | ||
| "isRecoilValue", | ||
| "useRecoilCallback" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/solid.ts | ||
| const solidCore = { "solid-js": [ | ||
| "createSignal", | ||
| "createEffect", | ||
| "createMemo", | ||
| "createResource", | ||
| "onMount", | ||
| "onCleanup", | ||
| "onError", | ||
| "untrack", | ||
| "batch", | ||
| "on", | ||
| "createRoot", | ||
| "mergeProps", | ||
| "splitProps", | ||
| "useTransition", | ||
| "observable", | ||
| "mapArray", | ||
| "indexArray", | ||
| "createContext", | ||
| "useContext", | ||
| "children", | ||
| "lazy", | ||
| "createDeferred", | ||
| "createRenderEffect", | ||
| "createSelector", | ||
| "For", | ||
| "Show", | ||
| "Switch", | ||
| "Match", | ||
| "Index", | ||
| "ErrorBoundary", | ||
| "Suspense", | ||
| "SuspenseList" | ||
| ] }; | ||
| const solidStore = { "solid-js/store": [ | ||
| "createStore", | ||
| "produce", | ||
| "reconcile", | ||
| "createMutable" | ||
| ] }; | ||
| const solidWeb = { "solid-js/web": [ | ||
| "Dynamic", | ||
| "hydrate", | ||
| "render", | ||
| "renderToString", | ||
| "renderToStringAsync", | ||
| "renderToStream", | ||
| "isServer", | ||
| "Portal" | ||
| ] }; | ||
| var solid_default = { | ||
| ...solidCore, | ||
| ...solidStore, | ||
| ...solidWeb | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/solid-app-router.ts | ||
| var solid_app_router_default = { "solid-app-router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/solid-router.ts | ||
| var solid_router_default = { "@solidjs/router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/svelte.ts | ||
| const svelteAnimate = { "svelte/animate": ["flip"] }; | ||
| const svelteEasing = { "svelte/easing": [ | ||
| "back", | ||
| "bounce", | ||
| "circ", | ||
| "cubic", | ||
| "elastic", | ||
| "expo", | ||
| "quad", | ||
| "quart", | ||
| "quint", | ||
| "sine" | ||
| ].reduce((acc, e) => { | ||
| acc.push(`${e}In`, `${e}Out`, `${e}InOut`); | ||
| return acc; | ||
| }, ["linear"]) }; | ||
| const svelteStore = { "svelte/store": [ | ||
| "writable", | ||
| "readable", | ||
| "derived", | ||
| "get" | ||
| ] }; | ||
| const svelteMotion = { "svelte/motion": ["tweened", "spring"] }; | ||
| const svelteTransition = { "svelte/transition": [ | ||
| "fade", | ||
| "blur", | ||
| "fly", | ||
| "slide", | ||
| "scale", | ||
| "draw", | ||
| "crossfade" | ||
| ] }; | ||
| const svelte = { svelte: [ | ||
| "onMount", | ||
| "beforeUpdate", | ||
| "afterUpdate", | ||
| "onDestroy", | ||
| "tick", | ||
| "setContext", | ||
| "getContext", | ||
| "hasContext", | ||
| "getAllContexts", | ||
| "createEventDispatcher" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/uni-app.ts | ||
| var uni_app_default = { "@dcloudio/uni-app": [ | ||
| "onAddToFavorites", | ||
| "onBackPress", | ||
| "onError", | ||
| "onHide", | ||
| "onLaunch", | ||
| "onLoad", | ||
| "onNavigationBarButtonTap", | ||
| "onNavigationBarSearchInputChanged", | ||
| "onNavigationBarSearchInputClicked", | ||
| "onNavigationBarSearchInputConfirmed", | ||
| "onNavigationBarSearchInputFocusChanged", | ||
| "onPageNotFound", | ||
| "onPageScroll", | ||
| "onPullDownRefresh", | ||
| "onReachBottom", | ||
| "onReady", | ||
| "onResize", | ||
| "onShareAppMessage", | ||
| "onShareTimeline", | ||
| "onShow", | ||
| "onTabItemTap", | ||
| "onThemeChange", | ||
| "onUnhandledRejection", | ||
| "onUnload" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vee-validate.ts | ||
| var vee_validate_default = { "vee-validate": [ | ||
| "validate", | ||
| "defineRule", | ||
| "configure", | ||
| "useField", | ||
| "useForm", | ||
| "useFieldArray", | ||
| "useResetForm", | ||
| "useIsFieldDirty", | ||
| "useIsFieldTouched", | ||
| "useIsFieldValid", | ||
| "useIsSubmitting", | ||
| "useValidateField", | ||
| "useIsFormDirty", | ||
| "useIsFormTouched", | ||
| "useIsFormValid", | ||
| "useValidateForm", | ||
| "useSubmitCount", | ||
| "useFieldValue", | ||
| "useFormValues", | ||
| "useFormErrors", | ||
| "useFieldError", | ||
| "useSubmitForm", | ||
| "FormContextKey", | ||
| "FieldContextKey" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vitepress.ts | ||
| var vitepress_default = { vitepress: [ | ||
| "useData", | ||
| "useRoute", | ||
| "useRouter", | ||
| "withBase" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vue-router.ts | ||
| var vue_router_default = { "vue-router": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vue-router-composables.ts | ||
| var vue_router_composables_default = { "vue-router/composables": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vueuse-core.ts | ||
| let _cache$1; | ||
| var vueuse_core_default = () => { | ||
| const excluded = [ | ||
| "toRefs", | ||
| "utils", | ||
| "toRef", | ||
| "toValue" | ||
| ]; | ||
| if (!_cache$1) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = (0, local_pkg.resolveModule)("@vueuse/core") || node_process.default.cwd(); | ||
| const path$1 = (0, local_pkg.resolveModule)("@vueuse/core/indexes.json") || (0, local_pkg.resolveModule)("@vueuse/metadata/index.json") || (0, local_pkg.resolveModule)("@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse((0, node_fs.readFileSync)(path$1, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?"); | ||
| } | ||
| if (indexesJson) _cache$1 = { "@vueuse/core": indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4 && !excluded.includes(i)) }; | ||
| } | ||
| return _cache$1 || {}; | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/vueuse-head.ts | ||
| var vueuse_head_default = { "@vueuse/head": ["useHead", "useSeoMeta"] }; | ||
| //#endregion | ||
| //#region src/presets/vueuse-math.ts | ||
| let _cache; | ||
| var vueuse_math_default = () => { | ||
| if (!_cache) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = (0, local_pkg.resolveModule)("@vueuse/core") || node_process.default.cwd(); | ||
| const path$1 = (0, local_pkg.resolveModule)("@vueuse/metadata/index.json") || (0, local_pkg.resolveModule)("@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse((0, node_fs.readFileSync)(path$1, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/math, have you installed it?"); | ||
| } | ||
| if (indexesJson) _cache = { "@vueuse/math": indexesJson.functions.filter((i) => ["math"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4) }; | ||
| } | ||
| return _cache || {}; | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/vuex.ts | ||
| var vuex_default = { vuex: [ | ||
| "createStore", | ||
| "createLogger", | ||
| "mapState", | ||
| "mapGetters", | ||
| "mapActions", | ||
| "mapMutations", | ||
| "createNamespacedHelpers", | ||
| "useStore" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/index.ts | ||
| const presets = { | ||
| ...unimport.builtinPresets, | ||
| "ahooks": ahooks_default, | ||
| "@vueuse/core": vueuse_core_default, | ||
| "@vueuse/math": vueuse_math_default, | ||
| "@vueuse/head": vueuse_head_default, | ||
| "mobx": mobx_default, | ||
| "mobx-react-lite": mobx_react_lite_default, | ||
| "preact": preact_default, | ||
| "quasar": quasar_default, | ||
| "react": react_default, | ||
| "react-router": react_router_default, | ||
| "react-router-dom": react_router_dom_default, | ||
| "react-i18next": react_i18next_default, | ||
| "svelte": svelte, | ||
| "svelte/animate": svelteAnimate, | ||
| "svelte/easing": svelteEasing, | ||
| "svelte/motion": svelteMotion, | ||
| "svelte/store": svelteStore, | ||
| "svelte/transition": svelteTransition, | ||
| "vee-validate": vee_validate_default, | ||
| "vitepress": vitepress_default, | ||
| "vue-router": vue_router_default, | ||
| "vue-router/composables": vue_router_composables_default, | ||
| "vuex": vuex_default, | ||
| "uni-app": uni_app_default, | ||
| "solid-js": solid_default, | ||
| "@solidjs/router": solid_router_default, | ||
| "solid-app-router": solid_app_router_default, | ||
| "jotai": jotai, | ||
| "jotai/utils": jotaiUtils, | ||
| "recoil": recoil_default | ||
| }; | ||
| //#endregion | ||
| //#region src/core/biomelintrc.ts | ||
| function generateBiomeLintConfigs(imports) { | ||
| const names = imports.map((i) => i.as ?? i.name).filter(Boolean).sort(); | ||
| const config = { javascript: { globals: names } }; | ||
| const jsonBody = JSON.stringify(config, null, 2); | ||
| return jsonBody; | ||
| } | ||
| //#endregion | ||
| //#region src/core/eslintrc.ts | ||
| function generateESLintConfigs(imports, eslintrc) { | ||
| const eslintConfigs = { globals: {} }; | ||
| imports.map((i) => i.as ?? i.name).filter(Boolean).sort().forEach((name) => { | ||
| eslintConfigs.globals[name] = eslintrc.globalsPropValue; | ||
| }); | ||
| const jsonBody = JSON.stringify(eslintConfigs, null, 2); | ||
| return jsonBody; | ||
| } | ||
| //#endregion | ||
| //#region src/core/resolvers.ts | ||
| function normalizeImport(info, name) { | ||
| if (typeof info === "string") return { | ||
| name: "default", | ||
| as: name, | ||
| from: info | ||
| }; | ||
| if ("path" in info) return { | ||
| from: info.path, | ||
| as: info.name, | ||
| name: info.importName, | ||
| sideEffects: info.sideEffects | ||
| }; | ||
| return { | ||
| name, | ||
| as: name, | ||
| ...info | ||
| }; | ||
| } | ||
| async function firstMatchedResolver(resolvers, fullname) { | ||
| let name = fullname; | ||
| for (const resolver of resolvers) { | ||
| if (typeof resolver === "object" && resolver.type === "directive") if (name.startsWith("v")) name = name.slice(1); | ||
| else continue; | ||
| const resolved = await (typeof resolver === "function" ? resolver(name) : resolver.resolve(name)); | ||
| if (resolved) return normalizeImport(resolved, fullname); | ||
| } | ||
| } | ||
| function resolversAddon(resolvers) { | ||
| return { | ||
| name: "unplugin-auto-import:resolvers", | ||
| async matchImports(names, matched) { | ||
| if (!resolvers.length) return; | ||
| const dynamic = []; | ||
| const sideEffects = []; | ||
| await Promise.all([...names].map(async (name) => { | ||
| const matchedImport = matched.find((i) => i.as === name); | ||
| if (matchedImport) { | ||
| if ("sideEffects" in matchedImport) sideEffects.push(...toArray(matchedImport.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| return; | ||
| } | ||
| const resolved = await firstMatchedResolver(resolvers, name); | ||
| if (resolved) dynamic.push(resolved); | ||
| if (resolved === null || resolved === void 0 ? void 0 : resolved.sideEffects) sideEffects.push(...toArray(resolved === null || resolved === void 0 ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| })); | ||
| if (dynamic.length) { | ||
| this.dynamicImports.push(...dynamic); | ||
| this.invalidate(); | ||
| } | ||
| if (dynamic.length || sideEffects.length) return [ | ||
| ...matched, | ||
| ...dynamic, | ||
| ...sideEffects | ||
| ]; | ||
| } | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/core/ctx.ts | ||
| const INCLUDE_RE_LIST = [ | ||
| /\.[jt]sx?$/, | ||
| /\.astro$/, | ||
| /\.vue$/, | ||
| /\.vue\?vue/, | ||
| /\.vue\.[tj]sx?\?vue/, | ||
| /\.svelte$/ | ||
| ]; | ||
| const EXCLUDE_RE_LIST = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]; | ||
| function createContext(options = {}, root = node_process.default.cwd()) { | ||
| var _options$packagePrese; | ||
| root = slash(root); | ||
| const { dts: preferDTS = (0, local_pkg.isPackageExists)("typescript"), dirsScanOptions, dirs, vueDirectives, vueTemplate } = options; | ||
| const eslintrc = options.eslintrc || {}; | ||
| eslintrc.enabled = eslintrc.enabled === void 0 ? false : eslintrc.enabled; | ||
| eslintrc.filepath = eslintrc.filepath || "./.eslintrc-auto-import.json"; | ||
| eslintrc.globalsPropValue = eslintrc.globalsPropValue === void 0 ? true : eslintrc.globalsPropValue; | ||
| const biomelintrc = options.biomelintrc || {}; | ||
| biomelintrc.enabled = biomelintrc.enabled !== void 0; | ||
| biomelintrc.filepath = biomelintrc.filepath || "./.biomelintrc-auto-import.json"; | ||
| const dumpUnimportItems = options.dumpUnimportItems === true ? "./.unimport-items.json" : options.dumpUnimportItems ?? false; | ||
| const resolvers = options.resolvers ? [options.resolvers].flat(2) : []; | ||
| const injectAtEnd = options.injectAtEnd !== false; | ||
| const unimport$1 = (0, unimport.createUnimport)({ | ||
| imports: [], | ||
| presets: ((_options$packagePrese = options.packagePresets) === null || _options$packagePrese === void 0 ? void 0 : _options$packagePrese.map((p) => typeof p === "string" ? { package: p } : p)) ?? [], | ||
| dirsScanOptions: { | ||
| ...dirsScanOptions, | ||
| cwd: root | ||
| }, | ||
| dirs, | ||
| injectAtEnd, | ||
| parser: options.parser, | ||
| addons: { | ||
| addons: [resolversAddon(resolvers), { | ||
| name: "unplugin-auto-import:dts", | ||
| declaration(dts$1) { | ||
| return `${` | ||
| /* eslint-disable */ | ||
| /* prettier-ignore */ | ||
| // @ts-nocheck | ||
| // noinspection JSUnusedGlobalSymbols | ||
| // Generated by unplugin-auto-import | ||
| // biome-ignore lint: disable | ||
| ${dts$1}`.trim()}\n`; | ||
| } | ||
| }], | ||
| vueDirectives, | ||
| vueTemplate | ||
| } | ||
| }); | ||
| const importsPromise = flattenImports(options.imports).then((imports) => { | ||
| var _options$ignore, _options$ignoreDts; | ||
| if (!imports.length && !resolvers.length && !(dirs === null || dirs === void 0 ? void 0 : dirs.length)) console.warn("[auto-import] plugin installed but no imports has defined, see https://github.com/antfu/unplugin-auto-import#configurations for configurations"); | ||
| const compare = (left, right) => { | ||
| return right instanceof RegExp ? right.test(left) : right === left; | ||
| }; | ||
| (_options$ignore = options.ignore) === null || _options$ignore === void 0 || _options$ignore.forEach((name) => { | ||
| const i = imports.find((i$1) => compare(i$1.as, name)); | ||
| if (i) i.disabled = true; | ||
| }); | ||
| (_options$ignoreDts = options.ignoreDts) === null || _options$ignoreDts === void 0 || _options$ignoreDts.forEach((name) => { | ||
| const i = imports.find((i$1) => compare(i$1.as, name)); | ||
| if (i) i.dtsDisabled = true; | ||
| }); | ||
| return unimport$1.getInternalContext().replaceImports(imports); | ||
| }); | ||
| const filter = (0, unplugin_utils.createFilter)(options.include || INCLUDE_RE_LIST, options.exclude || EXCLUDE_RE_LIST); | ||
| const dts = preferDTS === false ? false : preferDTS === true ? (0, node_path.resolve)(root, "auto-imports.d.ts") : (0, node_path.resolve)(root, preferDTS); | ||
| const multilineCommentsRE = /\/\*.*?\*\//gs; | ||
| const singlelineCommentsRE = /\/\/.*$/gm; | ||
| const dtsReg = /declare\s+global\s*\{(.*?)[\n\r]\}/s; | ||
| const componentCustomPropertiesReg = /interface\s+ComponentCustomProperties\s*\{(.*?)[\n\r]\}/gs; | ||
| function parseDTS(dts$1) { | ||
| var _dts$match; | ||
| dts$1 = dts$1.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, ""); | ||
| const code = (_dts$match = dts$1.match(dtsReg)) === null || _dts$match === void 0 ? void 0 : _dts$match[0]; | ||
| if (!code) return; | ||
| return Object.fromEntries(Array.from(code.matchAll(/['"]?(const\s*[^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]])); | ||
| } | ||
| async function generateDTS(file) { | ||
| await importsPromise; | ||
| const dir = (0, node_path.dirname)(file); | ||
| const originalContent = (0, node_fs.existsSync)(file) ? await node_fs.promises.readFile(file, "utf-8") : ""; | ||
| const originalDTS = parseDTS(originalContent); | ||
| let currentContent = await unimport$1.generateTypeDeclarations({ resolvePath: (i) => { | ||
| if (i.from.startsWith(".") || (0, node_path.isAbsolute)(i.from)) { | ||
| const related = slash((0, node_path.relative)(dir, i.from).replace(/\.ts(x)?$/, "")); | ||
| return !related.startsWith(".") ? `./${related}` : related; | ||
| } | ||
| return i.from; | ||
| } }); | ||
| const currentDTS = parseDTS(currentContent); | ||
| if (options.vueTemplate) currentContent = currentContent.replace(componentCustomPropertiesReg, ($1) => `interface GlobalComponents {}\n ${$1}`); | ||
| if (originalDTS) { | ||
| Object.keys(currentDTS).forEach((key) => { | ||
| originalDTS[key] = currentDTS[key]; | ||
| }); | ||
| const dtsList = Object.keys(originalDTS).sort().map((k) => ` ${k}: ${originalDTS[k]}`); | ||
| return currentContent.replace(dtsReg, () => `declare global {\n${dtsList.join("\n")}\n}`); | ||
| } | ||
| return currentContent; | ||
| } | ||
| async function generateESLint() { | ||
| return generateESLintConfigs(await unimport$1.getImports(), eslintrc); | ||
| } | ||
| async function generateBiomeLint() { | ||
| return generateBiomeLintConfigs(await unimport$1.getImports()); | ||
| } | ||
| const writeConfigFilesThrottled = throttle(500, writeConfigFiles, { noLeading: false }); | ||
| async function writeFile(filePath, content = "") { | ||
| await node_fs.promises.mkdir((0, node_path.dirname)(filePath), { recursive: true }); | ||
| return await node_fs.promises.writeFile(filePath, content, "utf-8"); | ||
| } | ||
| let lastDTS; | ||
| let lastESLint; | ||
| let lastBiomeLint; | ||
| let lastUnimportItems; | ||
| async function writeConfigFiles() { | ||
| const promises = []; | ||
| if (dts) promises.push(generateDTS(dts).then((content) => { | ||
| if (content !== lastDTS) { | ||
| lastDTS = content; | ||
| return writeFile(dts, content); | ||
| } | ||
| })); | ||
| if (eslintrc.enabled && eslintrc.filepath) { | ||
| const filepath = eslintrc.filepath; | ||
| promises.push(generateESLint().then(async (content) => { | ||
| if (filepath.endsWith(".cjs")) content = `module.exports = ${content}`; | ||
| else if (filepath.endsWith(".mjs") || filepath.endsWith(".js")) content = `export default ${content}`; | ||
| content = `${content}\n`; | ||
| if (content.trim() !== (lastESLint === null || lastESLint === void 0 ? void 0 : lastESLint.trim())) { | ||
| lastESLint = content; | ||
| return writeFile(eslintrc.filepath, content); | ||
| } | ||
| })); | ||
| } | ||
| if (biomelintrc.enabled) promises.push(generateBiomeLint().then((content) => { | ||
| if (content !== lastBiomeLint) { | ||
| lastBiomeLint = content; | ||
| return writeFile(biomelintrc.filepath, content); | ||
| } | ||
| })); | ||
| if (dumpUnimportItems) promises.push(unimport$1.getImports().then((items) => { | ||
| if (!dumpUnimportItems) return; | ||
| const content = JSON.stringify(items, null, 2); | ||
| if (content !== lastUnimportItems) { | ||
| lastUnimportItems = content; | ||
| return writeFile(dumpUnimportItems, content); | ||
| } | ||
| })); | ||
| return Promise.all(promises); | ||
| } | ||
| async function scanDirs() { | ||
| await unimport$1.modifyDynamicImports(async (imports) => { | ||
| const exports_ = await unimport$1.scanImportsFromDir(); | ||
| exports_.forEach((i) => i.__source = "dir"); | ||
| return modifyDefaultExportsAlias([...imports.filter((i) => i.__source !== "dir"), ...exports_], options); | ||
| }); | ||
| writeConfigFilesThrottled(); | ||
| } | ||
| async function transform(code, id) { | ||
| await importsPromise; | ||
| const s = new magic_string.default(code); | ||
| await unimport$1.injectImports(s, id); | ||
| if (!s.hasChanged()) return; | ||
| writeConfigFilesThrottled(); | ||
| return { | ||
| code: s.toString(), | ||
| map: s.generateMap({ | ||
| source: id, | ||
| includeContent: true, | ||
| hires: true | ||
| }) | ||
| }; | ||
| } | ||
| return { | ||
| root, | ||
| dirs, | ||
| filter, | ||
| scanDirs, | ||
| writeConfigFiles, | ||
| writeConfigFilesThrottled, | ||
| transform, | ||
| generateDTS, | ||
| generateESLint, | ||
| unimport: unimport$1 | ||
| }; | ||
| } | ||
| async function flattenImports(map) { | ||
| const promises = await Promise.all(toArray(map).map(async (definition) => { | ||
| if (typeof definition === "string") { | ||
| if (!presets[definition]) throw new Error(`[auto-import] preset ${definition} not found`); | ||
| const preset = presets[definition]; | ||
| definition = typeof preset === "function" ? preset() : preset; | ||
| } | ||
| if ("from" in definition && "imports" in definition) return await (0, unimport.resolvePreset)(definition); | ||
| else { | ||
| const resolved = []; | ||
| for (const mod of Object.keys(definition)) for (const id of definition[mod]) { | ||
| const meta = { from: mod }; | ||
| if (Array.isArray(id)) { | ||
| meta.name = id[0]; | ||
| meta.as = id[1]; | ||
| } else { | ||
| meta.name = id; | ||
| meta.as = id; | ||
| } | ||
| resolved.push(meta); | ||
| } | ||
| return resolved; | ||
| } | ||
| })); | ||
| return promises.flat(); | ||
| } | ||
| function modifyDefaultExportsAlias(imports, options) { | ||
| if (options.defaultExportByFilename) imports.forEach((i) => { | ||
| var _i$from$split$pop; | ||
| if (i.name === "default") i.as = ((_i$from$split$pop = i.from.split("/").pop()) === null || _i$from$split$pop === void 0 || (_i$from$split$pop = _i$from$split$pop.split(".")) === null || _i$from$split$pop === void 0 ? void 0 : _i$from$split$pop.shift()) ?? i.as; | ||
| }); | ||
| return imports; | ||
| } | ||
| //#endregion | ||
| //#region src/core/unplugin.ts | ||
| var unplugin_default = (0, unplugin.createUnplugin)((options) => { | ||
| let ctx = createContext(options); | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| enforce: "post", | ||
| transformInclude(id) { | ||
| return ctx.filter(id); | ||
| }, | ||
| transform: { | ||
| filter: { id: { | ||
| include: options.include || INCLUDE_RE_LIST, | ||
| exclude: options.exclude || EXCLUDE_RE_LIST | ||
| } }, | ||
| async handler(code, id) { | ||
| return ctx.transform(code, id); | ||
| } | ||
| }, | ||
| async buildStart() { | ||
| await ctx.scanDirs(); | ||
| }, | ||
| async buildEnd() { | ||
| await ctx.writeConfigFiles(); | ||
| }, | ||
| vite: { | ||
| async config(config) { | ||
| var _config$optimizeDeps; | ||
| if (options.viteOptimizeDeps === false) return; | ||
| const exclude = ((_config$optimizeDeps = config.optimizeDeps) === null || _config$optimizeDeps === void 0 ? void 0 : _config$optimizeDeps.exclude) || []; | ||
| const imports = new Set((await ctx.unimport.getImports()).map((i) => i.from).filter((i) => i.match(/^[a-z@]/) && !exclude.includes(i) && (0, local_pkg.isPackageExists)(i))); | ||
| if (!imports.size) return; | ||
| return { optimizeDeps: { include: [...imports] } }; | ||
| }, | ||
| async handleHotUpdate({ file }) { | ||
| var _ctx$dirs; | ||
| const relativeFile = node_path.default.relative(ctx.root, slash(file)); | ||
| if ((_ctx$dirs = ctx.dirs) === null || _ctx$dirs === void 0 ? void 0 : _ctx$dirs.some((dir) => picomatch.default.isMatch(slash(relativeFile), slash(typeof dir === "string" ? dir : dir.glob)))) await ctx.scanDirs(); | ||
| }, | ||
| async configResolved(config) { | ||
| if (ctx.root !== config.root) { | ||
| ctx = createContext(options, config.root); | ||
| await ctx.scanDirs(); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| }); | ||
| //#endregion | ||
| Object.defineProperty(exports, '__toESM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return __toESM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'unplugin_default', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return unplugin_default; | ||
| } | ||
| }); |
| import path, { dirname, isAbsolute, relative, resolve } from "node:path"; | ||
| import { isPackageExists, resolveModule } from "local-pkg"; | ||
| import pm from "picomatch"; | ||
| import { createUnplugin } from "unplugin"; | ||
| import { existsSync, promises, readFileSync } from "node:fs"; | ||
| import process from "node:process"; | ||
| import MagicString from "magic-string"; | ||
| import { builtinPresets, createUnimport, resolvePreset } from "unimport"; | ||
| import { createFilter } from "unplugin-utils"; | ||
| //#region node_modules/.pnpm/@antfu+utils@9.2.0/node_modules/@antfu/utils/dist/index.mjs | ||
| function toArray(array) { | ||
| array = array ?? []; | ||
| return Array.isArray(array) ? array : [array]; | ||
| } | ||
| function slash(str) { | ||
| return str.replace(/\\/g, "/"); | ||
| } | ||
| const VOID = Symbol("p-void"); | ||
| /** | ||
| * Throttle execution of a function. Especially useful for rate limiting | ||
| * execution of handlers on events like resize and scroll. | ||
| * | ||
| * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) | ||
| * are most useful. | ||
| * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, | ||
| * as-is, to `callback` when the throttled-function is executed. | ||
| * @param {object} [options] - An object to configure options. | ||
| * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds | ||
| * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed | ||
| * one final time after the last throttled-function call. (After the throttled-function has not been called for | ||
| * `delay` milliseconds, the internal counter is reset). | ||
| * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback | ||
| * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that | ||
| * callback will never executed if both noLeading = true and noTrailing = true. | ||
| * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is | ||
| * false (at end), schedule `callback` to execute after `delay` ms. | ||
| * | ||
| * @returns {Function} A new, throttled, function. | ||
| */ | ||
| function throttle$1(delay, callback, options) { | ||
| var _ref = options || {}, _ref$noTrailing = _ref.noTrailing, noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing, _ref$noLeading = _ref.noLeading, noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading, _ref$debounceMode = _ref.debounceMode, debounceMode = _ref$debounceMode === void 0 ? void 0 : _ref$debounceMode; | ||
| var timeoutID; | ||
| var cancelled = false; | ||
| var lastExec = 0; | ||
| function clearExistingTimeout() { | ||
| if (timeoutID) clearTimeout(timeoutID); | ||
| } | ||
| function cancel(options$1) { | ||
| var _ref2 = options$1 || {}, _ref2$upcomingOnly = _ref2.upcomingOnly, upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly; | ||
| clearExistingTimeout(); | ||
| cancelled = !upcomingOnly; | ||
| } | ||
| function wrapper() { | ||
| for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) arguments_[_key] = arguments[_key]; | ||
| var self = this; | ||
| var elapsed = Date.now() - lastExec; | ||
| if (cancelled) return; | ||
| function exec() { | ||
| lastExec = Date.now(); | ||
| callback.apply(self, arguments_); | ||
| } | ||
| function clear() { | ||
| timeoutID = void 0; | ||
| } | ||
| if (!noLeading && debounceMode && !timeoutID) exec(); | ||
| clearExistingTimeout(); | ||
| if (debounceMode === void 0 && elapsed > delay) if (noLeading) { | ||
| lastExec = Date.now(); | ||
| if (!noTrailing) timeoutID = setTimeout(debounceMode ? clear : exec, delay); | ||
| } else exec(); | ||
| else if (noTrailing !== true) timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === void 0 ? delay - elapsed : delay); | ||
| } | ||
| wrapper.cancel = cancel; | ||
| return wrapper; | ||
| } | ||
| function throttle(...args) { | ||
| return throttle$1(...args); | ||
| } | ||
| //#endregion | ||
| //#region src/presets/ahooks.ts | ||
| let _cache$2; | ||
| var ahooks_default = () => { | ||
| if (!_cache$2) { | ||
| let indexesJson; | ||
| try { | ||
| const path$1 = resolveModule("ahooks/metadata.json"); | ||
| indexesJson = JSON.parse(readFileSync(path$1, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load ahooks, have you installed it?"); | ||
| } | ||
| if (indexesJson) _cache$2 = { ahooks: indexesJson.functions.flatMap((i) => [i.name, ...i.alias || []]) }; | ||
| } | ||
| return _cache$2 || {}; | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/jotai.ts | ||
| const jotai = { jotai: [ | ||
| "atom", | ||
| "useAtom", | ||
| "useAtomValue", | ||
| "useSetAtom" | ||
| ] }; | ||
| const jotaiUtils = { "jotai/utils": [ | ||
| "atomWithReset", | ||
| "useResetAtom", | ||
| "useReducerAtom", | ||
| "atomWithReducer", | ||
| "atomFamily", | ||
| "selectAtom", | ||
| "useAtomCallback", | ||
| "freezeAtom", | ||
| "freezeAtomCreator", | ||
| "splitAtom", | ||
| "atomWithDefault", | ||
| "waitForAll", | ||
| "atomWithStorage", | ||
| "atomWithHash", | ||
| "createJSONStorage", | ||
| "atomWithObservable", | ||
| "useHydrateAtoms", | ||
| "loadable" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/mobx.ts | ||
| const mobx = [ | ||
| "makeObservable", | ||
| "makeAutoObservable", | ||
| "extendObservable", | ||
| "observable", | ||
| "action", | ||
| "runInAction", | ||
| "flow", | ||
| "flowResult", | ||
| "computed", | ||
| "autorun", | ||
| "reaction", | ||
| "when", | ||
| "onReactionError", | ||
| "intercept", | ||
| "observe", | ||
| "onBecomeObserved", | ||
| "onBecomeUnobserved", | ||
| "toJS" | ||
| ]; | ||
| var mobx_default = { mobx: [...mobx] }; | ||
| //#endregion | ||
| //#region src/presets/mobx-react-lite.ts | ||
| var mobx_react_lite_default = { "mobx-react-lite": [ | ||
| "observer", | ||
| "Observer", | ||
| "useLocalObservable" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/preact.ts | ||
| var preact_default = { "preact/hooks": [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/quasar.ts | ||
| var quasar_default = { quasar: [ | ||
| "useQuasar", | ||
| "useDialogPluginComponent", | ||
| "useFormChild", | ||
| "useMeta" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/react.ts | ||
| const CommonReactAPI = [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer", | ||
| "useImperativeHandle", | ||
| "useDebugValue", | ||
| "useDeferredValue", | ||
| "useLayoutEffect", | ||
| "useTransition", | ||
| "startTransition", | ||
| "useSyncExternalStore", | ||
| "useInsertionEffect", | ||
| "useId", | ||
| "lazy", | ||
| "memo", | ||
| "createRef", | ||
| "forwardRef" | ||
| ]; | ||
| var react_default = { react: CommonReactAPI }; | ||
| //#endregion | ||
| //#region src/presets/react-i18next.ts | ||
| var react_i18next_default = { "react-i18next": ["useTranslation"] }; | ||
| //#endregion | ||
| //#region src/presets/react-router.ts | ||
| /** | ||
| * Only compatible with React Router v6. | ||
| */ | ||
| const ReactRouterHooks = [ | ||
| "useOutletContext", | ||
| "useHref", | ||
| "useInRouterContext", | ||
| "useLocation", | ||
| "useNavigationType", | ||
| "useNavigate", | ||
| "useOutlet", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRoutes" | ||
| ]; | ||
| var react_router_default = { "react-router": [...ReactRouterHooks] }; | ||
| //#endregion | ||
| //#region src/presets/react-router-dom.ts | ||
| /** | ||
| * Only compatible with React Router Dom v6. | ||
| */ | ||
| var react_router_dom_default = { "react-router-dom": [ | ||
| ...ReactRouterHooks, | ||
| "useLinkClickHandler", | ||
| "useSearchParams", | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Routes" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/recoil.ts | ||
| var recoil_default = { recoil: [ | ||
| "atom", | ||
| "selector", | ||
| "useRecoilState", | ||
| "useRecoilValue", | ||
| "useSetRecoilState", | ||
| "useResetRecoilState", | ||
| "useRecoilStateLoadable", | ||
| "useRecoilValueLoadable", | ||
| "isRecoilValue", | ||
| "useRecoilCallback" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/solid.ts | ||
| const solidCore = { "solid-js": [ | ||
| "createSignal", | ||
| "createEffect", | ||
| "createMemo", | ||
| "createResource", | ||
| "onMount", | ||
| "onCleanup", | ||
| "onError", | ||
| "untrack", | ||
| "batch", | ||
| "on", | ||
| "createRoot", | ||
| "mergeProps", | ||
| "splitProps", | ||
| "useTransition", | ||
| "observable", | ||
| "mapArray", | ||
| "indexArray", | ||
| "createContext", | ||
| "useContext", | ||
| "children", | ||
| "lazy", | ||
| "createDeferred", | ||
| "createRenderEffect", | ||
| "createSelector", | ||
| "For", | ||
| "Show", | ||
| "Switch", | ||
| "Match", | ||
| "Index", | ||
| "ErrorBoundary", | ||
| "Suspense", | ||
| "SuspenseList" | ||
| ] }; | ||
| const solidStore = { "solid-js/store": [ | ||
| "createStore", | ||
| "produce", | ||
| "reconcile", | ||
| "createMutable" | ||
| ] }; | ||
| const solidWeb = { "solid-js/web": [ | ||
| "Dynamic", | ||
| "hydrate", | ||
| "render", | ||
| "renderToString", | ||
| "renderToStringAsync", | ||
| "renderToStream", | ||
| "isServer", | ||
| "Portal" | ||
| ] }; | ||
| var solid_default = { | ||
| ...solidCore, | ||
| ...solidStore, | ||
| ...solidWeb | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/solid-app-router.ts | ||
| var solid_app_router_default = { "solid-app-router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/solid-router.ts | ||
| var solid_router_default = { "@solidjs/router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/svelte.ts | ||
| const svelteAnimate = { "svelte/animate": ["flip"] }; | ||
| const svelteEasing = { "svelte/easing": [ | ||
| "back", | ||
| "bounce", | ||
| "circ", | ||
| "cubic", | ||
| "elastic", | ||
| "expo", | ||
| "quad", | ||
| "quart", | ||
| "quint", | ||
| "sine" | ||
| ].reduce((acc, e) => { | ||
| acc.push(`${e}In`, `${e}Out`, `${e}InOut`); | ||
| return acc; | ||
| }, ["linear"]) }; | ||
| const svelteStore = { "svelte/store": [ | ||
| "writable", | ||
| "readable", | ||
| "derived", | ||
| "get" | ||
| ] }; | ||
| const svelteMotion = { "svelte/motion": ["tweened", "spring"] }; | ||
| const svelteTransition = { "svelte/transition": [ | ||
| "fade", | ||
| "blur", | ||
| "fly", | ||
| "slide", | ||
| "scale", | ||
| "draw", | ||
| "crossfade" | ||
| ] }; | ||
| const svelte = { svelte: [ | ||
| "onMount", | ||
| "beforeUpdate", | ||
| "afterUpdate", | ||
| "onDestroy", | ||
| "tick", | ||
| "setContext", | ||
| "getContext", | ||
| "hasContext", | ||
| "getAllContexts", | ||
| "createEventDispatcher" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/uni-app.ts | ||
| var uni_app_default = { "@dcloudio/uni-app": [ | ||
| "onAddToFavorites", | ||
| "onBackPress", | ||
| "onError", | ||
| "onHide", | ||
| "onLaunch", | ||
| "onLoad", | ||
| "onNavigationBarButtonTap", | ||
| "onNavigationBarSearchInputChanged", | ||
| "onNavigationBarSearchInputClicked", | ||
| "onNavigationBarSearchInputConfirmed", | ||
| "onNavigationBarSearchInputFocusChanged", | ||
| "onPageNotFound", | ||
| "onPageScroll", | ||
| "onPullDownRefresh", | ||
| "onReachBottom", | ||
| "onReady", | ||
| "onResize", | ||
| "onShareAppMessage", | ||
| "onShareTimeline", | ||
| "onShow", | ||
| "onTabItemTap", | ||
| "onThemeChange", | ||
| "onUnhandledRejection", | ||
| "onUnload" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vee-validate.ts | ||
| var vee_validate_default = { "vee-validate": [ | ||
| "validate", | ||
| "defineRule", | ||
| "configure", | ||
| "useField", | ||
| "useForm", | ||
| "useFieldArray", | ||
| "useResetForm", | ||
| "useIsFieldDirty", | ||
| "useIsFieldTouched", | ||
| "useIsFieldValid", | ||
| "useIsSubmitting", | ||
| "useValidateField", | ||
| "useIsFormDirty", | ||
| "useIsFormTouched", | ||
| "useIsFormValid", | ||
| "useValidateForm", | ||
| "useSubmitCount", | ||
| "useFieldValue", | ||
| "useFormValues", | ||
| "useFormErrors", | ||
| "useFieldError", | ||
| "useSubmitForm", | ||
| "FormContextKey", | ||
| "FieldContextKey" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vitepress.ts | ||
| var vitepress_default = { vitepress: [ | ||
| "useData", | ||
| "useRoute", | ||
| "useRouter", | ||
| "withBase" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vue-router.ts | ||
| var vue_router_default = { "vue-router": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vue-router-composables.ts | ||
| var vue_router_composables_default = { "vue-router/composables": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/vueuse-core.ts | ||
| let _cache$1; | ||
| var vueuse_core_default = () => { | ||
| const excluded = [ | ||
| "toRefs", | ||
| "utils", | ||
| "toRef", | ||
| "toValue" | ||
| ]; | ||
| if (!_cache$1) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = resolveModule("@vueuse/core") || process.cwd(); | ||
| const path$1 = resolveModule("@vueuse/core/indexes.json") || resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse(readFileSync(path$1, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?"); | ||
| } | ||
| if (indexesJson) _cache$1 = { "@vueuse/core": indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4 && !excluded.includes(i)) }; | ||
| } | ||
| return _cache$1 || {}; | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/vueuse-head.ts | ||
| var vueuse_head_default = { "@vueuse/head": ["useHead", "useSeoMeta"] }; | ||
| //#endregion | ||
| //#region src/presets/vueuse-math.ts | ||
| let _cache; | ||
| var vueuse_math_default = () => { | ||
| if (!_cache) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = resolveModule("@vueuse/core") || process.cwd(); | ||
| const path$1 = resolveModule("@vueuse/metadata/index.json") || resolveModule("@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse(readFileSync(path$1, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/math, have you installed it?"); | ||
| } | ||
| if (indexesJson) _cache = { "@vueuse/math": indexesJson.functions.filter((i) => ["math"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4) }; | ||
| } | ||
| return _cache || {}; | ||
| }; | ||
| //#endregion | ||
| //#region src/presets/vuex.ts | ||
| var vuex_default = { vuex: [ | ||
| "createStore", | ||
| "createLogger", | ||
| "mapState", | ||
| "mapGetters", | ||
| "mapActions", | ||
| "mapMutations", | ||
| "createNamespacedHelpers", | ||
| "useStore" | ||
| ] }; | ||
| //#endregion | ||
| //#region src/presets/index.ts | ||
| const presets = { | ||
| ...builtinPresets, | ||
| "ahooks": ahooks_default, | ||
| "@vueuse/core": vueuse_core_default, | ||
| "@vueuse/math": vueuse_math_default, | ||
| "@vueuse/head": vueuse_head_default, | ||
| "mobx": mobx_default, | ||
| "mobx-react-lite": mobx_react_lite_default, | ||
| "preact": preact_default, | ||
| "quasar": quasar_default, | ||
| "react": react_default, | ||
| "react-router": react_router_default, | ||
| "react-router-dom": react_router_dom_default, | ||
| "react-i18next": react_i18next_default, | ||
| "svelte": svelte, | ||
| "svelte/animate": svelteAnimate, | ||
| "svelte/easing": svelteEasing, | ||
| "svelte/motion": svelteMotion, | ||
| "svelte/store": svelteStore, | ||
| "svelte/transition": svelteTransition, | ||
| "vee-validate": vee_validate_default, | ||
| "vitepress": vitepress_default, | ||
| "vue-router": vue_router_default, | ||
| "vue-router/composables": vue_router_composables_default, | ||
| "vuex": vuex_default, | ||
| "uni-app": uni_app_default, | ||
| "solid-js": solid_default, | ||
| "@solidjs/router": solid_router_default, | ||
| "solid-app-router": solid_app_router_default, | ||
| "jotai": jotai, | ||
| "jotai/utils": jotaiUtils, | ||
| "recoil": recoil_default | ||
| }; | ||
| //#endregion | ||
| //#region src/core/biomelintrc.ts | ||
| function generateBiomeLintConfigs(imports) { | ||
| const names = imports.map((i) => i.as ?? i.name).filter(Boolean).sort(); | ||
| const config = { javascript: { globals: names } }; | ||
| const jsonBody = JSON.stringify(config, null, 2); | ||
| return jsonBody; | ||
| } | ||
| //#endregion | ||
| //#region src/core/eslintrc.ts | ||
| function generateESLintConfigs(imports, eslintrc) { | ||
| const eslintConfigs = { globals: {} }; | ||
| imports.map((i) => i.as ?? i.name).filter(Boolean).sort().forEach((name) => { | ||
| eslintConfigs.globals[name] = eslintrc.globalsPropValue; | ||
| }); | ||
| const jsonBody = JSON.stringify(eslintConfigs, null, 2); | ||
| return jsonBody; | ||
| } | ||
| //#endregion | ||
| //#region src/core/resolvers.ts | ||
| function normalizeImport(info, name) { | ||
| if (typeof info === "string") return { | ||
| name: "default", | ||
| as: name, | ||
| from: info | ||
| }; | ||
| if ("path" in info) return { | ||
| from: info.path, | ||
| as: info.name, | ||
| name: info.importName, | ||
| sideEffects: info.sideEffects | ||
| }; | ||
| return { | ||
| name, | ||
| as: name, | ||
| ...info | ||
| }; | ||
| } | ||
| async function firstMatchedResolver(resolvers, fullname) { | ||
| let name = fullname; | ||
| for (const resolver of resolvers) { | ||
| if (typeof resolver === "object" && resolver.type === "directive") if (name.startsWith("v")) name = name.slice(1); | ||
| else continue; | ||
| const resolved = await (typeof resolver === "function" ? resolver(name) : resolver.resolve(name)); | ||
| if (resolved) return normalizeImport(resolved, fullname); | ||
| } | ||
| } | ||
| function resolversAddon(resolvers) { | ||
| return { | ||
| name: "unplugin-auto-import:resolvers", | ||
| async matchImports(names, matched) { | ||
| if (!resolvers.length) return; | ||
| const dynamic = []; | ||
| const sideEffects = []; | ||
| await Promise.all([...names].map(async (name) => { | ||
| const matchedImport = matched.find((i) => i.as === name); | ||
| if (matchedImport) { | ||
| if ("sideEffects" in matchedImport) sideEffects.push(...toArray(matchedImport.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| return; | ||
| } | ||
| const resolved = await firstMatchedResolver(resolvers, name); | ||
| if (resolved) dynamic.push(resolved); | ||
| if (resolved === null || resolved === void 0 ? void 0 : resolved.sideEffects) sideEffects.push(...toArray(resolved === null || resolved === void 0 ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| })); | ||
| if (dynamic.length) { | ||
| this.dynamicImports.push(...dynamic); | ||
| this.invalidate(); | ||
| } | ||
| if (dynamic.length || sideEffects.length) return [ | ||
| ...matched, | ||
| ...dynamic, | ||
| ...sideEffects | ||
| ]; | ||
| } | ||
| }; | ||
| } | ||
| //#endregion | ||
| //#region src/core/ctx.ts | ||
| const INCLUDE_RE_LIST = [ | ||
| /\.[jt]sx?$/, | ||
| /\.astro$/, | ||
| /\.vue$/, | ||
| /\.vue\?vue/, | ||
| /\.vue\.[tj]sx?\?vue/, | ||
| /\.svelte$/ | ||
| ]; | ||
| const EXCLUDE_RE_LIST = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]; | ||
| function createContext(options = {}, root = process.cwd()) { | ||
| var _options$packagePrese; | ||
| root = slash(root); | ||
| const { dts: preferDTS = isPackageExists("typescript"), dirsScanOptions, dirs, vueDirectives, vueTemplate } = options; | ||
| const eslintrc = options.eslintrc || {}; | ||
| eslintrc.enabled = eslintrc.enabled === void 0 ? false : eslintrc.enabled; | ||
| eslintrc.filepath = eslintrc.filepath || "./.eslintrc-auto-import.json"; | ||
| eslintrc.globalsPropValue = eslintrc.globalsPropValue === void 0 ? true : eslintrc.globalsPropValue; | ||
| const biomelintrc = options.biomelintrc || {}; | ||
| biomelintrc.enabled = biomelintrc.enabled !== void 0; | ||
| biomelintrc.filepath = biomelintrc.filepath || "./.biomelintrc-auto-import.json"; | ||
| const dumpUnimportItems = options.dumpUnimportItems === true ? "./.unimport-items.json" : options.dumpUnimportItems ?? false; | ||
| const resolvers = options.resolvers ? [options.resolvers].flat(2) : []; | ||
| const injectAtEnd = options.injectAtEnd !== false; | ||
| const unimport = createUnimport({ | ||
| imports: [], | ||
| presets: ((_options$packagePrese = options.packagePresets) === null || _options$packagePrese === void 0 ? void 0 : _options$packagePrese.map((p) => typeof p === "string" ? { package: p } : p)) ?? [], | ||
| dirsScanOptions: { | ||
| ...dirsScanOptions, | ||
| cwd: root | ||
| }, | ||
| dirs, | ||
| injectAtEnd, | ||
| parser: options.parser, | ||
| addons: { | ||
| addons: [resolversAddon(resolvers), { | ||
| name: "unplugin-auto-import:dts", | ||
| declaration(dts$1) { | ||
| return `${` | ||
| /* eslint-disable */ | ||
| /* prettier-ignore */ | ||
| // @ts-nocheck | ||
| // noinspection JSUnusedGlobalSymbols | ||
| // Generated by unplugin-auto-import | ||
| // biome-ignore lint: disable | ||
| ${dts$1}`.trim()}\n`; | ||
| } | ||
| }], | ||
| vueDirectives, | ||
| vueTemplate | ||
| } | ||
| }); | ||
| const importsPromise = flattenImports(options.imports).then((imports) => { | ||
| var _options$ignore, _options$ignoreDts; | ||
| if (!imports.length && !resolvers.length && !(dirs === null || dirs === void 0 ? void 0 : dirs.length)) console.warn("[auto-import] plugin installed but no imports has defined, see https://github.com/antfu/unplugin-auto-import#configurations for configurations"); | ||
| const compare = (left, right) => { | ||
| return right instanceof RegExp ? right.test(left) : right === left; | ||
| }; | ||
| (_options$ignore = options.ignore) === null || _options$ignore === void 0 || _options$ignore.forEach((name) => { | ||
| const i = imports.find((i$1) => compare(i$1.as, name)); | ||
| if (i) i.disabled = true; | ||
| }); | ||
| (_options$ignoreDts = options.ignoreDts) === null || _options$ignoreDts === void 0 || _options$ignoreDts.forEach((name) => { | ||
| const i = imports.find((i$1) => compare(i$1.as, name)); | ||
| if (i) i.dtsDisabled = true; | ||
| }); | ||
| return unimport.getInternalContext().replaceImports(imports); | ||
| }); | ||
| const filter = createFilter(options.include || INCLUDE_RE_LIST, options.exclude || EXCLUDE_RE_LIST); | ||
| const dts = preferDTS === false ? false : preferDTS === true ? resolve(root, "auto-imports.d.ts") : resolve(root, preferDTS); | ||
| const multilineCommentsRE = /\/\*.*?\*\//gs; | ||
| const singlelineCommentsRE = /\/\/.*$/gm; | ||
| const dtsReg = /declare\s+global\s*\{(.*?)[\n\r]\}/s; | ||
| const componentCustomPropertiesReg = /interface\s+ComponentCustomProperties\s*\{(.*?)[\n\r]\}/gs; | ||
| function parseDTS(dts$1) { | ||
| var _dts$match; | ||
| dts$1 = dts$1.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, ""); | ||
| const code = (_dts$match = dts$1.match(dtsReg)) === null || _dts$match === void 0 ? void 0 : _dts$match[0]; | ||
| if (!code) return; | ||
| return Object.fromEntries(Array.from(code.matchAll(/['"]?(const\s*[^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]])); | ||
| } | ||
| async function generateDTS(file) { | ||
| await importsPromise; | ||
| const dir = dirname(file); | ||
| const originalContent = existsSync(file) ? await promises.readFile(file, "utf-8") : ""; | ||
| const originalDTS = parseDTS(originalContent); | ||
| let currentContent = await unimport.generateTypeDeclarations({ resolvePath: (i) => { | ||
| if (i.from.startsWith(".") || isAbsolute(i.from)) { | ||
| const related = slash(relative(dir, i.from).replace(/\.ts(x)?$/, "")); | ||
| return !related.startsWith(".") ? `./${related}` : related; | ||
| } | ||
| return i.from; | ||
| } }); | ||
| const currentDTS = parseDTS(currentContent); | ||
| if (options.vueTemplate) currentContent = currentContent.replace(componentCustomPropertiesReg, ($1) => `interface GlobalComponents {}\n ${$1}`); | ||
| if (originalDTS) { | ||
| Object.keys(currentDTS).forEach((key) => { | ||
| originalDTS[key] = currentDTS[key]; | ||
| }); | ||
| const dtsList = Object.keys(originalDTS).sort().map((k) => ` ${k}: ${originalDTS[k]}`); | ||
| return currentContent.replace(dtsReg, () => `declare global {\n${dtsList.join("\n")}\n}`); | ||
| } | ||
| return currentContent; | ||
| } | ||
| async function generateESLint() { | ||
| return generateESLintConfigs(await unimport.getImports(), eslintrc); | ||
| } | ||
| async function generateBiomeLint() { | ||
| return generateBiomeLintConfigs(await unimport.getImports()); | ||
| } | ||
| const writeConfigFilesThrottled = throttle(500, writeConfigFiles, { noLeading: false }); | ||
| async function writeFile(filePath, content = "") { | ||
| await promises.mkdir(dirname(filePath), { recursive: true }); | ||
| return await promises.writeFile(filePath, content, "utf-8"); | ||
| } | ||
| let lastDTS; | ||
| let lastESLint; | ||
| let lastBiomeLint; | ||
| let lastUnimportItems; | ||
| async function writeConfigFiles() { | ||
| const promises$1 = []; | ||
| if (dts) promises$1.push(generateDTS(dts).then((content) => { | ||
| if (content !== lastDTS) { | ||
| lastDTS = content; | ||
| return writeFile(dts, content); | ||
| } | ||
| })); | ||
| if (eslintrc.enabled && eslintrc.filepath) { | ||
| const filepath = eslintrc.filepath; | ||
| promises$1.push(generateESLint().then(async (content) => { | ||
| if (filepath.endsWith(".cjs")) content = `module.exports = ${content}`; | ||
| else if (filepath.endsWith(".mjs") || filepath.endsWith(".js")) content = `export default ${content}`; | ||
| content = `${content}\n`; | ||
| if (content.trim() !== (lastESLint === null || lastESLint === void 0 ? void 0 : lastESLint.trim())) { | ||
| lastESLint = content; | ||
| return writeFile(eslintrc.filepath, content); | ||
| } | ||
| })); | ||
| } | ||
| if (biomelintrc.enabled) promises$1.push(generateBiomeLint().then((content) => { | ||
| if (content !== lastBiomeLint) { | ||
| lastBiomeLint = content; | ||
| return writeFile(biomelintrc.filepath, content); | ||
| } | ||
| })); | ||
| if (dumpUnimportItems) promises$1.push(unimport.getImports().then((items) => { | ||
| if (!dumpUnimportItems) return; | ||
| const content = JSON.stringify(items, null, 2); | ||
| if (content !== lastUnimportItems) { | ||
| lastUnimportItems = content; | ||
| return writeFile(dumpUnimportItems, content); | ||
| } | ||
| })); | ||
| return Promise.all(promises$1); | ||
| } | ||
| async function scanDirs() { | ||
| await unimport.modifyDynamicImports(async (imports) => { | ||
| const exports_ = await unimport.scanImportsFromDir(); | ||
| exports_.forEach((i) => i.__source = "dir"); | ||
| return modifyDefaultExportsAlias([...imports.filter((i) => i.__source !== "dir"), ...exports_], options); | ||
| }); | ||
| writeConfigFilesThrottled(); | ||
| } | ||
| async function transform(code, id) { | ||
| await importsPromise; | ||
| const s = new MagicString(code); | ||
| await unimport.injectImports(s, id); | ||
| if (!s.hasChanged()) return; | ||
| writeConfigFilesThrottled(); | ||
| return { | ||
| code: s.toString(), | ||
| map: s.generateMap({ | ||
| source: id, | ||
| includeContent: true, | ||
| hires: true | ||
| }) | ||
| }; | ||
| } | ||
| return { | ||
| root, | ||
| dirs, | ||
| filter, | ||
| scanDirs, | ||
| writeConfigFiles, | ||
| writeConfigFilesThrottled, | ||
| transform, | ||
| generateDTS, | ||
| generateESLint, | ||
| unimport | ||
| }; | ||
| } | ||
| async function flattenImports(map) { | ||
| const promises$1 = await Promise.all(toArray(map).map(async (definition) => { | ||
| if (typeof definition === "string") { | ||
| if (!presets[definition]) throw new Error(`[auto-import] preset ${definition} not found`); | ||
| const preset = presets[definition]; | ||
| definition = typeof preset === "function" ? preset() : preset; | ||
| } | ||
| if ("from" in definition && "imports" in definition) return await resolvePreset(definition); | ||
| else { | ||
| const resolved = []; | ||
| for (const mod of Object.keys(definition)) for (const id of definition[mod]) { | ||
| const meta = { from: mod }; | ||
| if (Array.isArray(id)) { | ||
| meta.name = id[0]; | ||
| meta.as = id[1]; | ||
| } else { | ||
| meta.name = id; | ||
| meta.as = id; | ||
| } | ||
| resolved.push(meta); | ||
| } | ||
| return resolved; | ||
| } | ||
| })); | ||
| return promises$1.flat(); | ||
| } | ||
| function modifyDefaultExportsAlias(imports, options) { | ||
| if (options.defaultExportByFilename) imports.forEach((i) => { | ||
| var _i$from$split$pop; | ||
| if (i.name === "default") i.as = ((_i$from$split$pop = i.from.split("/").pop()) === null || _i$from$split$pop === void 0 || (_i$from$split$pop = _i$from$split$pop.split(".")) === null || _i$from$split$pop === void 0 ? void 0 : _i$from$split$pop.shift()) ?? i.as; | ||
| }); | ||
| return imports; | ||
| } | ||
| //#endregion | ||
| //#region src/core/unplugin.ts | ||
| var unplugin_default = createUnplugin((options) => { | ||
| let ctx = createContext(options); | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| enforce: "post", | ||
| transformInclude(id) { | ||
| return ctx.filter(id); | ||
| }, | ||
| transform: { | ||
| filter: { id: { | ||
| include: options.include || INCLUDE_RE_LIST, | ||
| exclude: options.exclude || EXCLUDE_RE_LIST | ||
| } }, | ||
| async handler(code, id) { | ||
| return ctx.transform(code, id); | ||
| } | ||
| }, | ||
| async buildStart() { | ||
| await ctx.scanDirs(); | ||
| }, | ||
| async buildEnd() { | ||
| await ctx.writeConfigFiles(); | ||
| }, | ||
| vite: { | ||
| async config(config) { | ||
| var _config$optimizeDeps; | ||
| if (options.viteOptimizeDeps === false) return; | ||
| const exclude = ((_config$optimizeDeps = config.optimizeDeps) === null || _config$optimizeDeps === void 0 ? void 0 : _config$optimizeDeps.exclude) || []; | ||
| const imports = new Set((await ctx.unimport.getImports()).map((i) => i.from).filter((i) => i.match(/^[a-z@]/) && !exclude.includes(i) && isPackageExists(i))); | ||
| if (!imports.size) return; | ||
| return { optimizeDeps: { include: [...imports] } }; | ||
| }, | ||
| async handleHotUpdate({ file }) { | ||
| var _ctx$dirs; | ||
| const relativeFile = path.relative(ctx.root, slash(file)); | ||
| if ((_ctx$dirs = ctx.dirs) === null || _ctx$dirs === void 0 ? void 0 : _ctx$dirs.some((dir) => pm.isMatch(slash(relativeFile), slash(typeof dir === "string" ? dir : dir.glob)))) await ctx.scanDirs(); | ||
| }, | ||
| async configResolved(config) { | ||
| if (ctx.root !== config.root) { | ||
| ctx = createContext(options, config.root); | ||
| await ctx.scanDirs(); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| }); | ||
| //#endregion | ||
| export { unplugin_default }; |
| import * as unimport42 from "unimport"; | ||
| import { AddonVueDirectivesOptions, Import, InlinePreset, PackagePreset, ScanDirExportsOptions, UnimportOptions } from "unimport"; | ||
| import { FilterPattern } from "unplugin-utils"; | ||
| import { Arrayable, Awaitable } from "@antfu/utils"; | ||
| //#region src/presets/index.d.ts | ||
| declare const presets: { | ||
| ahooks: () => ImportsMap; | ||
| '@vueuse/core': () => ImportsMap; | ||
| '@vueuse/math': () => ImportsMap; | ||
| '@vueuse/head': ImportsMap; | ||
| mobx: ImportsMap; | ||
| 'mobx-react-lite': ImportsMap; | ||
| preact: ImportsMap; | ||
| quasar: ImportsMap; | ||
| react: ImportsMap; | ||
| 'react-router': ImportsMap; | ||
| 'react-router-dom': ImportsMap; | ||
| 'react-i18next': ImportsMap; | ||
| svelte: ImportsMap; | ||
| 'svelte/animate': ImportsMap; | ||
| 'svelte/easing': ImportsMap; | ||
| 'svelte/motion': ImportsMap; | ||
| 'svelte/store': ImportsMap; | ||
| 'svelte/transition': ImportsMap; | ||
| 'vee-validate': ImportsMap; | ||
| vitepress: ImportsMap; | ||
| 'vue-router': ImportsMap; | ||
| 'vue-router/composables': ImportsMap; | ||
| vuex: ImportsMap; | ||
| 'uni-app': ImportsMap; | ||
| 'solid-js': ImportsMap; | ||
| '@solidjs/router': ImportsMap; | ||
| 'solid-app-router': ImportsMap; | ||
| jotai: ImportsMap; | ||
| 'jotai/utils': ImportsMap; | ||
| recoil: ImportsMap; | ||
| '@vue/composition-api': unimport42.InlinePreset; | ||
| pinia: unimport42.InlinePreset; | ||
| 'vue-demi': unimport42.InlinePreset; | ||
| 'vue-i18n': unimport42.InlinePreset; | ||
| 'vue-router-composables': unimport42.InlinePreset; | ||
| vue: unimport42.InlinePreset; | ||
| 'vue/macros': unimport42.InlinePreset; | ||
| vitest: unimport42.InlinePreset; | ||
| rxjs: unimport42.InlinePreset; | ||
| 'date-fns': unimport42.InlinePreset; | ||
| }; | ||
| type PresetName = keyof typeof presets; | ||
| //#endregion | ||
| //#region src/types.d.ts | ||
| interface ImportLegacy { | ||
| /** | ||
| * @deprecated renamed to `as` | ||
| */ | ||
| name?: string; | ||
| /** | ||
| * @deprecated renamed to `name` | ||
| */ | ||
| importName?: string; | ||
| /** | ||
| * @deprecated renamed to `from` | ||
| */ | ||
| path: string; | ||
| sideEffects?: SideEffectsInfo; | ||
| } | ||
| interface ImportExtended extends Import { | ||
| sideEffects?: SideEffectsInfo; | ||
| __source?: 'dir' | 'resolver'; | ||
| } | ||
| type ImportNameAlias = [string, string]; | ||
| type SideEffectsInfo = Arrayable<ResolverResult | string> | undefined; | ||
| interface ResolverResult { | ||
| as?: string; | ||
| name?: string; | ||
| from: string; | ||
| } | ||
| type ResolverFunction = (name: string) => Awaitable<string | ResolverResult | ImportExtended | null | undefined | void>; | ||
| interface ResolverResultObject { | ||
| type: 'component' | 'directive'; | ||
| resolve: ResolverFunction; | ||
| } | ||
| /** | ||
| * Given a identifier name, returns the import path or an import object | ||
| */ | ||
| type Resolver = ResolverFunction | ResolverResultObject; | ||
| /** | ||
| * module, name, alias | ||
| */ | ||
| type ImportsMap = Record<string, (string | ImportNameAlias)[]>; | ||
| /** | ||
| * Directory to search for import | ||
| */ | ||
| interface ScanDir { | ||
| glob: string; | ||
| types?: boolean; | ||
| } | ||
| type NormalizedScanDir = Required<ScanDir>; | ||
| type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable'; | ||
| interface ESLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| /** | ||
| * @default true | ||
| */ | ||
| globalsPropValue?: ESLintGlobalsPropValue; | ||
| } | ||
| interface BiomeLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| } | ||
| interface Options { | ||
| /** | ||
| * Preset names or custom imports map | ||
| * | ||
| * @default [] | ||
| */ | ||
| imports?: Arrayable<ImportsMap | PresetName | InlinePreset>; | ||
| /** | ||
| * Local package presets. | ||
| * | ||
| * Register local installed packages as a preset. | ||
| * | ||
| * @default [] | ||
| * @see https://github.com/unplugin/unplugin-auto-import#package-presets | ||
| */ | ||
| packagePresets?: (PackagePreset | string)[]; | ||
| /** | ||
| * Identifiers to be ignored | ||
| */ | ||
| ignore?: (string | RegExp)[]; | ||
| /** | ||
| * These identifiers won't be put on the DTS file | ||
| */ | ||
| ignoreDts?: (string | RegExp)[]; | ||
| /** | ||
| * Inject the imports at the end of other imports | ||
| * | ||
| * @default true | ||
| */ | ||
| injectAtEnd?: boolean; | ||
| /** | ||
| * Options for scanning directories for auto import | ||
| */ | ||
| dirsScanOptions?: Omit<ScanDirExportsOptions, 'cwd'>; | ||
| /** | ||
| * Path for directories to be auto imported | ||
| */ | ||
| dirs?: (string | ScanDir)[]; | ||
| /** | ||
| * Pass a custom function to resolve the component importing path from the component name. | ||
| * | ||
| * The component names are always in PascalCase | ||
| */ | ||
| resolvers?: Arrayable<Arrayable<Resolver>>; | ||
| /** | ||
| * Parser to be used for parsing the source code. | ||
| * | ||
| * @see https://github.com/unjs/unimport#acorn-parser | ||
| * @default 'regex' | ||
| */ | ||
| parser?: UnimportOptions['parser']; | ||
| /** | ||
| * Filepath to generate corresponding .d.ts file. | ||
| * Default enabled when `typescript` is installed locally. | ||
| * Set `false` to disable. | ||
| * | ||
| * @default './auto-imports.d.ts' | ||
| */ | ||
| dts?: string | boolean; | ||
| /** | ||
| * Auto import inside Vue templates | ||
| * | ||
| * @see https://github.com/unjs/unimport/pull/15 | ||
| * @see https://github.com/unjs/unimport/pull/72 | ||
| * @default false | ||
| */ | ||
| vueTemplate?: boolean; | ||
| /** | ||
| * Enable auto import directives for Vue's SFC. | ||
| * | ||
| * Library authors should include `meta.vueDirective: true` in the import metadata. | ||
| * | ||
| * When using a local directives folder, provide the `isDirective` | ||
| * callback to check if the import is a Vue directive. | ||
| * | ||
| * @see https://github.com/unjs/unimport?tab=readme-ov-file#vue-directives-auto-import-and-typescript-declaration-generation | ||
| */ | ||
| vueDirectives?: true | AddonVueDirectivesOptions; | ||
| /** | ||
| * Set default export alias by file name | ||
| * | ||
| * @default false | ||
| */ | ||
| defaultExportByFilename?: boolean; | ||
| /** | ||
| * Rules to include transforming target. | ||
| * | ||
| * @default [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/, /\.svelte$/] | ||
| */ | ||
| include?: FilterPattern; | ||
| /** | ||
| * Rules to exclude transforming target. | ||
| * | ||
| * @default [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/] | ||
| */ | ||
| exclude?: FilterPattern; | ||
| /** | ||
| * Generate corresponding .eslintrc-auto-import.json file. | ||
| */ | ||
| eslintrc?: ESLintrc; | ||
| /** | ||
| * Generate corresponding .biomelintrc.json file. | ||
| */ | ||
| biomelintrc?: BiomeLintrc; | ||
| /** | ||
| * Save unimport items into a JSON file for other tools to consume. | ||
| * Provide a filepath to save the JSON file. | ||
| * | ||
| * When set to `true`, it will save to `./.unimport-items.json` | ||
| * | ||
| * @default false | ||
| */ | ||
| dumpUnimportItems?: boolean | string; | ||
| /** | ||
| * Include auto-imported packages in Vite's `optimizeDeps` option | ||
| * | ||
| * @default true | ||
| */ | ||
| viteOptimizeDeps?: boolean; | ||
| } //#endregion | ||
| export { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, SideEffectsInfo }; |
| import { Arrayable, Awaitable } from "@antfu/utils"; | ||
| import * as unimport43 from "unimport"; | ||
| import { AddonVueDirectivesOptions, Import, InlinePreset, PackagePreset, ScanDirExportsOptions, UnimportOptions } from "unimport"; | ||
| import { FilterPattern } from "unplugin-utils"; | ||
| //#region src/presets/index.d.ts | ||
| declare const presets: { | ||
| ahooks: () => ImportsMap; | ||
| '@vueuse/core': () => ImportsMap; | ||
| '@vueuse/math': () => ImportsMap; | ||
| '@vueuse/head': ImportsMap; | ||
| mobx: ImportsMap; | ||
| 'mobx-react-lite': ImportsMap; | ||
| preact: ImportsMap; | ||
| quasar: ImportsMap; | ||
| react: ImportsMap; | ||
| 'react-router': ImportsMap; | ||
| 'react-router-dom': ImportsMap; | ||
| 'react-i18next': ImportsMap; | ||
| svelte: ImportsMap; | ||
| 'svelte/animate': ImportsMap; | ||
| 'svelte/easing': ImportsMap; | ||
| 'svelte/motion': ImportsMap; | ||
| 'svelte/store': ImportsMap; | ||
| 'svelte/transition': ImportsMap; | ||
| 'vee-validate': ImportsMap; | ||
| vitepress: ImportsMap; | ||
| 'vue-router': ImportsMap; | ||
| 'vue-router/composables': ImportsMap; | ||
| vuex: ImportsMap; | ||
| 'uni-app': ImportsMap; | ||
| 'solid-js': ImportsMap; | ||
| '@solidjs/router': ImportsMap; | ||
| 'solid-app-router': ImportsMap; | ||
| jotai: ImportsMap; | ||
| 'jotai/utils': ImportsMap; | ||
| recoil: ImportsMap; | ||
| '@vue/composition-api': unimport43.InlinePreset; | ||
| pinia: unimport43.InlinePreset; | ||
| 'vue-demi': unimport43.InlinePreset; | ||
| 'vue-i18n': unimport43.InlinePreset; | ||
| 'vue-router-composables': unimport43.InlinePreset; | ||
| vue: unimport43.InlinePreset; | ||
| 'vue/macros': unimport43.InlinePreset; | ||
| vitest: unimport43.InlinePreset; | ||
| rxjs: unimport43.InlinePreset; | ||
| 'date-fns': unimport43.InlinePreset; | ||
| }; | ||
| type PresetName = keyof typeof presets; | ||
| //#endregion | ||
| //#region src/types.d.ts | ||
| interface ImportLegacy { | ||
| /** | ||
| * @deprecated renamed to `as` | ||
| */ | ||
| name?: string; | ||
| /** | ||
| * @deprecated renamed to `name` | ||
| */ | ||
| importName?: string; | ||
| /** | ||
| * @deprecated renamed to `from` | ||
| */ | ||
| path: string; | ||
| sideEffects?: SideEffectsInfo; | ||
| } | ||
| interface ImportExtended extends Import { | ||
| sideEffects?: SideEffectsInfo; | ||
| __source?: 'dir' | 'resolver'; | ||
| } | ||
| type ImportNameAlias = [string, string]; | ||
| type SideEffectsInfo = Arrayable<ResolverResult | string> | undefined; | ||
| interface ResolverResult { | ||
| as?: string; | ||
| name?: string; | ||
| from: string; | ||
| } | ||
| type ResolverFunction = (name: string) => Awaitable<string | ResolverResult | ImportExtended | null | undefined | void>; | ||
| interface ResolverResultObject { | ||
| type: 'component' | 'directive'; | ||
| resolve: ResolverFunction; | ||
| } | ||
| /** | ||
| * Given a identifier name, returns the import path or an import object | ||
| */ | ||
| type Resolver = ResolverFunction | ResolverResultObject; | ||
| /** | ||
| * module, name, alias | ||
| */ | ||
| type ImportsMap = Record<string, (string | ImportNameAlias)[]>; | ||
| /** | ||
| * Directory to search for import | ||
| */ | ||
| interface ScanDir { | ||
| glob: string; | ||
| types?: boolean; | ||
| } | ||
| type NormalizedScanDir = Required<ScanDir>; | ||
| type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable'; | ||
| interface ESLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| /** | ||
| * @default true | ||
| */ | ||
| globalsPropValue?: ESLintGlobalsPropValue; | ||
| } | ||
| interface BiomeLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| } | ||
| interface Options { | ||
| /** | ||
| * Preset names or custom imports map | ||
| * | ||
| * @default [] | ||
| */ | ||
| imports?: Arrayable<ImportsMap | PresetName | InlinePreset>; | ||
| /** | ||
| * Local package presets. | ||
| * | ||
| * Register local installed packages as a preset. | ||
| * | ||
| * @default [] | ||
| * @see https://github.com/unplugin/unplugin-auto-import#package-presets | ||
| */ | ||
| packagePresets?: (PackagePreset | string)[]; | ||
| /** | ||
| * Identifiers to be ignored | ||
| */ | ||
| ignore?: (string | RegExp)[]; | ||
| /** | ||
| * These identifiers won't be put on the DTS file | ||
| */ | ||
| ignoreDts?: (string | RegExp)[]; | ||
| /** | ||
| * Inject the imports at the end of other imports | ||
| * | ||
| * @default true | ||
| */ | ||
| injectAtEnd?: boolean; | ||
| /** | ||
| * Options for scanning directories for auto import | ||
| */ | ||
| dirsScanOptions?: Omit<ScanDirExportsOptions, 'cwd'>; | ||
| /** | ||
| * Path for directories to be auto imported | ||
| */ | ||
| dirs?: (string | ScanDir)[]; | ||
| /** | ||
| * Pass a custom function to resolve the component importing path from the component name. | ||
| * | ||
| * The component names are always in PascalCase | ||
| */ | ||
| resolvers?: Arrayable<Arrayable<Resolver>>; | ||
| /** | ||
| * Parser to be used for parsing the source code. | ||
| * | ||
| * @see https://github.com/unjs/unimport#acorn-parser | ||
| * @default 'regex' | ||
| */ | ||
| parser?: UnimportOptions['parser']; | ||
| /** | ||
| * Filepath to generate corresponding .d.ts file. | ||
| * Default enabled when `typescript` is installed locally. | ||
| * Set `false` to disable. | ||
| * | ||
| * @default './auto-imports.d.ts' | ||
| */ | ||
| dts?: string | boolean; | ||
| /** | ||
| * Auto import inside Vue templates | ||
| * | ||
| * @see https://github.com/unjs/unimport/pull/15 | ||
| * @see https://github.com/unjs/unimport/pull/72 | ||
| * @default false | ||
| */ | ||
| vueTemplate?: boolean; | ||
| /** | ||
| * Enable auto import directives for Vue's SFC. | ||
| * | ||
| * Library authors should include `meta.vueDirective: true` in the import metadata. | ||
| * | ||
| * When using a local directives folder, provide the `isDirective` | ||
| * callback to check if the import is a Vue directive. | ||
| * | ||
| * @see https://github.com/unjs/unimport?tab=readme-ov-file#vue-directives-auto-import-and-typescript-declaration-generation | ||
| */ | ||
| vueDirectives?: true | AddonVueDirectivesOptions; | ||
| /** | ||
| * Set default export alias by file name | ||
| * | ||
| * @default false | ||
| */ | ||
| defaultExportByFilename?: boolean; | ||
| /** | ||
| * Rules to include transforming target. | ||
| * | ||
| * @default [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/, /\.svelte$/] | ||
| */ | ||
| include?: FilterPattern; | ||
| /** | ||
| * Rules to exclude transforming target. | ||
| * | ||
| * @default [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/] | ||
| */ | ||
| exclude?: FilterPattern; | ||
| /** | ||
| * Generate corresponding .eslintrc-auto-import.json file. | ||
| */ | ||
| eslintrc?: ESLintrc; | ||
| /** | ||
| * Generate corresponding .biomelintrc.json file. | ||
| */ | ||
| biomelintrc?: BiomeLintrc; | ||
| /** | ||
| * Save unimport items into a JSON file for other tools to consume. | ||
| * Provide a filepath to save the JSON file. | ||
| * | ||
| * When set to `true`, it will save to `./.unimport-items.json` | ||
| * | ||
| * @default false | ||
| */ | ||
| dumpUnimportItems?: boolean | string; | ||
| /** | ||
| * Include auto-imported packages in Vite's `optimizeDeps` option | ||
| * | ||
| * @default true | ||
| */ | ||
| viteOptimizeDeps?: boolean; | ||
| } //#endregion | ||
| export { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, SideEffectsInfo }; |
+12
-17
@@ -1,21 +0,16 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| // src/astro.ts | ||
| //#region src/astro.ts | ||
| function astro_default(options) { | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| hooks: { | ||
| "astro:config:setup": async (astro) => { | ||
| var _a; | ||
| (_a = astro.config.vite).plugins || (_a.plugins = []); | ||
| astro.config.vite.plugins.push(_chunkFMLWYFD2cjs.unplugin_default.vite(options)); | ||
| } | ||
| } | ||
| }; | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| hooks: { "astro:config:setup": async (astro) => { | ||
| var _astro$config$vite; | ||
| (_astro$config$vite = astro.config.vite).plugins || (_astro$config$vite.plugins = []); | ||
| astro.config.vite.plugins.push(require_src.unplugin_default.vite(options)); | ||
| } } | ||
| }; | ||
| } | ||
| exports.default = astro_default; | ||
| //#endregion | ||
| module.exports = astro_default; |
+8
-9
@@ -1,13 +0,12 @@ | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| //#region src/astro.d.ts | ||
| declare function export_default(options: Options): { | ||
| name: string; | ||
| hooks: { | ||
| 'astro:config:setup': (astro: any) => Promise<void>; | ||
| }; | ||
| name: string; | ||
| hooks: { | ||
| 'astro:config:setup': (astro: any) => Promise<void>; | ||
| }; | ||
| }; | ||
| export { export_default as default }; | ||
| //#endregion | ||
| export { export_default as default }; |
+8
-9
@@ -1,13 +0,12 @@ | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| //#region src/astro.d.ts | ||
| declare function export_default(options: Options): { | ||
| name: string; | ||
| hooks: { | ||
| 'astro:config:setup': (astro: any) => Promise<void>; | ||
| }; | ||
| name: string; | ||
| hooks: { | ||
| 'astro:config:setup': (astro: any) => Promise<void>; | ||
| }; | ||
| }; | ||
| export { export_default as default }; | ||
| //#endregion | ||
| export { export_default as default }; |
+13
-18
@@ -1,21 +0,16 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| // src/astro.ts | ||
| //#region src/astro.ts | ||
| function astro_default(options) { | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| hooks: { | ||
| "astro:config:setup": async (astro) => { | ||
| var _a; | ||
| (_a = astro.config.vite).plugins || (_a.plugins = []); | ||
| astro.config.vite.plugins.push(unplugin_default.vite(options)); | ||
| } | ||
| } | ||
| }; | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| hooks: { "astro:config:setup": async (astro) => { | ||
| var _astro$config$vite; | ||
| (_astro$config$vite = astro.config.vite).plugins || (_astro$config$vite.plugins = []); | ||
| astro.config.vite.plugins.push(unplugin_default.vite(options)); | ||
| } } | ||
| }; | ||
| } | ||
| export { | ||
| astro_default as default | ||
| }; | ||
| //#endregion | ||
| export { astro_default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| //#region src/esbuild.ts | ||
| var esbuild_default = require_src.unplugin_default.esbuild; | ||
| // src/esbuild.ts | ||
| var esbuild_default = _chunkFMLWYFD2cjs.unplugin_default.esbuild; | ||
| exports.default = esbuild_default; | ||
| //#endregion | ||
| module.exports = esbuild_default; |
@@ -1,9 +0,8 @@ | ||
| import * as esbuild from 'esbuild'; | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| import * as esbuild1 from "esbuild"; | ||
| declare const _default: (options: Options) => esbuild.Plugin; | ||
| //#region src/esbuild.d.ts | ||
| declare const _default: (options: Options) => esbuild1.Plugin; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
@@ -1,9 +0,8 @@ | ||
| import * as esbuild from 'esbuild'; | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| import * as esbuild5 from "esbuild"; | ||
| declare const _default: (options: Options) => esbuild.Plugin; | ||
| //#region src/esbuild.d.ts | ||
| declare const _default: (options: Options) => esbuild5.Plugin; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| // src/esbuild.ts | ||
| //#region src/esbuild.ts | ||
| var esbuild_default = unplugin_default.esbuild; | ||
| export { | ||
| esbuild_default as default | ||
| }; | ||
| //#endregion | ||
| export { esbuild_default as default }; |
+2
-6
@@ -1,7 +0,3 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| exports.default = _chunkFMLWYFD2cjs.unplugin_default; | ||
| module.exports = require_src.unplugin_default; |
+6
-7
@@ -1,9 +0,8 @@ | ||
| import * as unplugin from 'unplugin'; | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| import * as unplugin12 from "unplugin"; | ||
| declare const _default: unplugin.UnpluginInstance<Options, boolean>; | ||
| //#region src/core/unplugin.d.ts | ||
| declare const _default: unplugin12.UnpluginInstance<Options, boolean>; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+6
-7
@@ -1,9 +0,8 @@ | ||
| import * as unplugin from 'unplugin'; | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| import * as unplugin52 from "unplugin"; | ||
| declare const _default: unplugin.UnpluginInstance<Options, boolean>; | ||
| //#region src/core/unplugin.d.ts | ||
| declare const _default: unplugin52.UnpluginInstance<Options, boolean>; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+3
-7
@@ -1,7 +0,3 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| export { | ||
| unplugin_default as default | ||
| }; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| export { unplugin_default as default }; |
+14
-15
@@ -1,17 +0,16 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| const __nuxt_kit = require_src.__toESM(require("@nuxt/kit")); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| //#region src/nuxt.ts | ||
| var nuxt_default = (0, __nuxt_kit.defineNuxtModule)({ setup(options) { | ||
| options.exclude = options.exclude || [ | ||
| /[\\/]node_modules[\\/]/, | ||
| /[\\/]\.git[\\/]/, | ||
| /[\\/]\.nuxt[\\/]/ | ||
| ]; | ||
| (0, __nuxt_kit.addWebpackPlugin)(require_src.unplugin_default.webpack(options)); | ||
| (0, __nuxt_kit.addVitePlugin)(require_src.unplugin_default.vite(options)); | ||
| } }); | ||
| // src/nuxt.ts | ||
| var _kit = require('@nuxt/kit'); | ||
| var nuxt_default = _kit.defineNuxtModule.call(void 0, { | ||
| setup(options) { | ||
| options.exclude = options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]; | ||
| _kit.addWebpackPlugin.call(void 0, _chunkFMLWYFD2cjs.unplugin_default.webpack(options)); | ||
| _kit.addVitePlugin.call(void 0, _chunkFMLWYFD2cjs.unplugin_default.vite(options)); | ||
| } | ||
| }); | ||
| exports.default = nuxt_default; | ||
| //#endregion | ||
| module.exports = nuxt_default; |
+6
-7
@@ -1,9 +0,8 @@ | ||
| import * as _nuxt_schema from '@nuxt/schema'; | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| import * as _nuxt_schema11 from "@nuxt/schema"; | ||
| declare const _default: _nuxt_schema.NuxtModule<Options, Options, false>; | ||
| //#region src/nuxt.d.ts | ||
| declare const _default: _nuxt_schema11.NuxtModule<Options, Options, false>; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+6
-7
@@ -1,9 +0,8 @@ | ||
| import * as _nuxt_schema from '@nuxt/schema'; | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| import * as _nuxt_schema0 from "@nuxt/schema"; | ||
| declare const _default: _nuxt_schema.NuxtModule<Options, Options, false>; | ||
| //#region src/nuxt.d.ts | ||
| declare const _default: _nuxt_schema0.NuxtModule<Options, Options, false>; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+15
-16
@@ -1,17 +0,16 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit"; | ||
| // src/nuxt.ts | ||
| import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit"; | ||
| var nuxt_default = defineNuxtModule({ | ||
| setup(options) { | ||
| options.exclude = options.exclude || [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/]; | ||
| addWebpackPlugin(unplugin_default.webpack(options)); | ||
| addVitePlugin(unplugin_default.vite(options)); | ||
| } | ||
| }); | ||
| export { | ||
| nuxt_default as default | ||
| }; | ||
| //#region src/nuxt.ts | ||
| var nuxt_default = defineNuxtModule({ setup(options) { | ||
| options.exclude = options.exclude || [ | ||
| /[\\/]node_modules[\\/]/, | ||
| /[\\/]\.git[\\/]/, | ||
| /[\\/]\.nuxt[\\/]/ | ||
| ]; | ||
| addWebpackPlugin(unplugin_default.webpack(options)); | ||
| addVitePlugin(unplugin_default.vite(options)); | ||
| } }); | ||
| //#endregion | ||
| export { nuxt_default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| //#region src/rollup.ts | ||
| var rollup_default = require_src.unplugin_default.rollup; | ||
| // src/rollup.ts | ||
| var rollup_default = _chunkFMLWYFD2cjs.unplugin_default.rollup; | ||
| exports.default = rollup_default; | ||
| //#endregion | ||
| module.exports = rollup_default; |
@@ -1,9 +0,8 @@ | ||
| import * as rollup from 'rollup'; | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| import * as rollup9 from "rollup"; | ||
| declare const _default: (options: Options) => rollup.Plugin<any> | rollup.Plugin<any>[]; | ||
| //#region src/rollup.d.ts | ||
| declare const _default: (options: Options) => rollup9.Plugin<any> | rollup9.Plugin<any>[]; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+6
-7
@@ -1,9 +0,8 @@ | ||
| import * as rollup from 'rollup'; | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| import * as rollup2 from "rollup"; | ||
| declare const _default: (options: Options) => rollup.Plugin<any> | rollup.Plugin<any>[]; | ||
| //#region src/rollup.d.ts | ||
| declare const _default: (options: Options) => rollup2.Plugin<any> | rollup2.Plugin<any>[]; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| // src/rollup.ts | ||
| //#region src/rollup.ts | ||
| var rollup_default = unplugin_default.rollup; | ||
| export { | ||
| rollup_default as default | ||
| }; | ||
| //#endregion | ||
| export { rollup_default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| //#region src/rspack.ts | ||
| var rspack_default = require_src.unplugin_default.rspack; | ||
| // src/rspack.ts | ||
| var rspack_default = _chunkFMLWYFD2cjs.unplugin_default.rspack; | ||
| exports.default = rspack_default; | ||
| //#endregion | ||
| module.exports = rspack_default; |
@@ -1,8 +0,7 @@ | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| //#region src/rspack.d.ts | ||
| declare const _default: (options: Options) => RspackPluginInstance; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+4
-5
@@ -1,8 +0,7 @@ | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| //#region src/rspack.d.ts | ||
| declare const _default: (options: Options) => RspackPluginInstance; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| // src/rspack.ts | ||
| //#region src/rspack.ts | ||
| var rspack_default = unplugin_default.rspack; | ||
| export { | ||
| rspack_default as default | ||
| }; | ||
| //#endregion | ||
| export { rspack_default as default }; |
+2
-255
@@ -1,255 +0,2 @@ | ||
| import { Arrayable, Awaitable } from '@antfu/utils'; | ||
| import * as unimport from 'unimport'; | ||
| import { InlinePreset, PackagePreset, Import, UnimportOptions, AddonVueDirectivesOptions } from 'unimport'; | ||
| import { FilterPattern } from 'unplugin-utils'; | ||
| declare const presets: { | ||
| ahooks: () => ImportsMap; | ||
| '@vueuse/core': () => ImportsMap; | ||
| '@vueuse/math': () => ImportsMap; | ||
| '@vueuse/head': ImportsMap; | ||
| mobx: ImportsMap; | ||
| 'mobx-react-lite': ImportsMap; | ||
| preact: ImportsMap; | ||
| quasar: ImportsMap; | ||
| react: ImportsMap; | ||
| 'react-router': ImportsMap; | ||
| 'react-router-dom': ImportsMap; | ||
| 'react-i18next': ImportsMap; | ||
| svelte: ImportsMap; | ||
| 'svelte/animate': ImportsMap; | ||
| 'svelte/easing': ImportsMap; | ||
| 'svelte/motion': ImportsMap; | ||
| 'svelte/store': ImportsMap; | ||
| 'svelte/transition': ImportsMap; | ||
| 'vee-validate': ImportsMap; | ||
| vitepress: ImportsMap; | ||
| 'vue-router': ImportsMap; | ||
| 'vue-router/composables': ImportsMap; | ||
| vuex: ImportsMap; | ||
| 'uni-app': ImportsMap; | ||
| 'solid-js': ImportsMap; | ||
| '@solidjs/router': ImportsMap; | ||
| 'solid-app-router': ImportsMap; | ||
| jotai: ImportsMap; | ||
| 'jotai/utils': ImportsMap; | ||
| recoil: ImportsMap; | ||
| '@vue/composition-api': unimport.InlinePreset; | ||
| pinia: unimport.InlinePreset; | ||
| 'vue-demi': unimport.InlinePreset; | ||
| 'vue-i18n': unimport.InlinePreset; | ||
| 'vue-router-composables': unimport.InlinePreset; | ||
| vue: unimport.InlinePreset; | ||
| 'vue/macros': unimport.InlinePreset; | ||
| vitest: unimport.InlinePreset; | ||
| rxjs: unimport.InlinePreset; | ||
| 'date-fns': unimport.InlinePreset; | ||
| }; | ||
| type PresetName = keyof typeof presets; | ||
| interface ImportLegacy { | ||
| /** | ||
| * @deprecated renamed to `as` | ||
| */ | ||
| name?: string; | ||
| /** | ||
| * @deprecated renamed to `name` | ||
| */ | ||
| importName?: string; | ||
| /** | ||
| * @deprecated renamed to `from` | ||
| */ | ||
| path: string; | ||
| sideEffects?: SideEffectsInfo; | ||
| } | ||
| interface ImportExtended extends Import { | ||
| sideEffects?: SideEffectsInfo; | ||
| __source?: 'dir' | 'resolver'; | ||
| } | ||
| type ImportNameAlias = [string, string]; | ||
| type SideEffectsInfo = Arrayable<ResolverResult | string> | undefined; | ||
| interface ResolverResult { | ||
| as?: string; | ||
| name?: string; | ||
| from: string; | ||
| } | ||
| type ResolverFunction = (name: string) => Awaitable<string | ResolverResult | ImportExtended | null | undefined | void>; | ||
| interface ResolverResultObject { | ||
| type: 'component' | 'directive'; | ||
| resolve: ResolverFunction; | ||
| } | ||
| /** | ||
| * Given a identifier name, returns the import path or an import object | ||
| */ | ||
| type Resolver = ResolverFunction | ResolverResultObject; | ||
| /** | ||
| * module, name, alias | ||
| */ | ||
| type ImportsMap = Record<string, (string | ImportNameAlias)[]>; | ||
| interface ScanDirExportsOptions { | ||
| /** | ||
| * Register type exports | ||
| * | ||
| * @default true | ||
| */ | ||
| types?: boolean; | ||
| } | ||
| /** | ||
| * Directory to search for import | ||
| */ | ||
| interface ScanDir { | ||
| glob: string; | ||
| types?: boolean; | ||
| } | ||
| type NormalizedScanDir = Required<ScanDir>; | ||
| type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable'; | ||
| interface ESLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| /** | ||
| * @default true | ||
| */ | ||
| globalsPropValue?: ESLintGlobalsPropValue; | ||
| } | ||
| interface BiomeLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| } | ||
| interface Options { | ||
| /** | ||
| * Preset names or custom imports map | ||
| * | ||
| * @default [] | ||
| */ | ||
| imports?: Arrayable<ImportsMap | PresetName | InlinePreset>; | ||
| /** | ||
| * Local package presets. | ||
| * | ||
| * Register local installed packages as a preset. | ||
| * | ||
| * @default [] | ||
| * @see https://github.com/unplugin/unplugin-auto-import#package-presets | ||
| */ | ||
| packagePresets?: (PackagePreset | string)[]; | ||
| /** | ||
| * Identifiers to be ignored | ||
| */ | ||
| ignore?: (string | RegExp)[]; | ||
| /** | ||
| * These identifiers won't be put on the DTS file | ||
| */ | ||
| ignoreDts?: (string | RegExp)[]; | ||
| /** | ||
| * Inject the imports at the end of other imports | ||
| * | ||
| * @default true | ||
| */ | ||
| injectAtEnd?: boolean; | ||
| /** | ||
| * Options for scanning directories for auto import | ||
| */ | ||
| dirsScanOptions?: ScanDirExportsOptions; | ||
| /** | ||
| * Path for directories to be auto imported | ||
| */ | ||
| dirs?: (string | ScanDir)[]; | ||
| /** | ||
| * Pass a custom function to resolve the component importing path from the component name. | ||
| * | ||
| * The component names are always in PascalCase | ||
| */ | ||
| resolvers?: Arrayable<Arrayable<Resolver>>; | ||
| /** | ||
| * Parser to be used for parsing the source code. | ||
| * | ||
| * @see https://github.com/unjs/unimport#acorn-parser | ||
| * @default 'regex' | ||
| */ | ||
| parser?: UnimportOptions['parser']; | ||
| /** | ||
| * Filepath to generate corresponding .d.ts file. | ||
| * Default enabled when `typescript` is installed locally. | ||
| * Set `false` to disable. | ||
| * | ||
| * @default './auto-imports.d.ts' | ||
| */ | ||
| dts?: string | boolean; | ||
| /** | ||
| * Auto import inside Vue templates | ||
| * | ||
| * @see https://github.com/unjs/unimport/pull/15 | ||
| * @see https://github.com/unjs/unimport/pull/72 | ||
| * @default false | ||
| */ | ||
| vueTemplate?: boolean; | ||
| /** | ||
| * Enable auto import directives for Vue's SFC. | ||
| * | ||
| * Library authors should include `meta.vueDirective: true` in the import metadata. | ||
| * | ||
| * When using a local directives folder, provide the `isDirective` | ||
| * callback to check if the import is a Vue directive. | ||
| * | ||
| * @see https://github.com/unjs/unimport?tab=readme-ov-file#vue-directives-auto-import-and-typescript-declaration-generation | ||
| */ | ||
| vueDirectives?: true | AddonVueDirectivesOptions; | ||
| /** | ||
| * Set default export alias by file name | ||
| * | ||
| * @default false | ||
| */ | ||
| defaultExportByFilename?: boolean; | ||
| /** | ||
| * Rules to include transforming target. | ||
| * | ||
| * @default [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/, /\.svelte$/] | ||
| */ | ||
| include?: FilterPattern; | ||
| /** | ||
| * Rules to exclude transforming target. | ||
| * | ||
| * @default [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/] | ||
| */ | ||
| exclude?: FilterPattern; | ||
| /** | ||
| * Generate corresponding .eslintrc-auto-import.json file. | ||
| */ | ||
| eslintrc?: ESLintrc; | ||
| /** | ||
| * Generate corresponding .biomelintrc.json file. | ||
| */ | ||
| biomelintrc?: BiomeLintrc; | ||
| /** | ||
| * Save unimport items into a JSON file for other tools to consume. | ||
| * Provide a filepath to save the JSON file. | ||
| * | ||
| * When set to `true`, it will save to `./.unimport-items.json` | ||
| * | ||
| * @default false | ||
| */ | ||
| dumpUnimportItems?: boolean | string; | ||
| /** | ||
| * Include auto-imported packages in Vite's `optimizeDeps` option | ||
| * | ||
| * @default true | ||
| */ | ||
| viteOptimizeDeps?: boolean; | ||
| } | ||
| export type { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, ScanDirExportsOptions, SideEffectsInfo }; | ||
| import { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, SideEffectsInfo } from "./types-jTI1vtTa.cjs"; | ||
| export { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, SideEffectsInfo }; |
+2
-255
@@ -1,255 +0,2 @@ | ||
| import { Arrayable, Awaitable } from '@antfu/utils'; | ||
| import * as unimport from 'unimport'; | ||
| import { InlinePreset, PackagePreset, Import, UnimportOptions, AddonVueDirectivesOptions } from 'unimport'; | ||
| import { FilterPattern } from 'unplugin-utils'; | ||
| declare const presets: { | ||
| ahooks: () => ImportsMap; | ||
| '@vueuse/core': () => ImportsMap; | ||
| '@vueuse/math': () => ImportsMap; | ||
| '@vueuse/head': ImportsMap; | ||
| mobx: ImportsMap; | ||
| 'mobx-react-lite': ImportsMap; | ||
| preact: ImportsMap; | ||
| quasar: ImportsMap; | ||
| react: ImportsMap; | ||
| 'react-router': ImportsMap; | ||
| 'react-router-dom': ImportsMap; | ||
| 'react-i18next': ImportsMap; | ||
| svelte: ImportsMap; | ||
| 'svelte/animate': ImportsMap; | ||
| 'svelte/easing': ImportsMap; | ||
| 'svelte/motion': ImportsMap; | ||
| 'svelte/store': ImportsMap; | ||
| 'svelte/transition': ImportsMap; | ||
| 'vee-validate': ImportsMap; | ||
| vitepress: ImportsMap; | ||
| 'vue-router': ImportsMap; | ||
| 'vue-router/composables': ImportsMap; | ||
| vuex: ImportsMap; | ||
| 'uni-app': ImportsMap; | ||
| 'solid-js': ImportsMap; | ||
| '@solidjs/router': ImportsMap; | ||
| 'solid-app-router': ImportsMap; | ||
| jotai: ImportsMap; | ||
| 'jotai/utils': ImportsMap; | ||
| recoil: ImportsMap; | ||
| '@vue/composition-api': unimport.InlinePreset; | ||
| pinia: unimport.InlinePreset; | ||
| 'vue-demi': unimport.InlinePreset; | ||
| 'vue-i18n': unimport.InlinePreset; | ||
| 'vue-router-composables': unimport.InlinePreset; | ||
| vue: unimport.InlinePreset; | ||
| 'vue/macros': unimport.InlinePreset; | ||
| vitest: unimport.InlinePreset; | ||
| rxjs: unimport.InlinePreset; | ||
| 'date-fns': unimport.InlinePreset; | ||
| }; | ||
| type PresetName = keyof typeof presets; | ||
| interface ImportLegacy { | ||
| /** | ||
| * @deprecated renamed to `as` | ||
| */ | ||
| name?: string; | ||
| /** | ||
| * @deprecated renamed to `name` | ||
| */ | ||
| importName?: string; | ||
| /** | ||
| * @deprecated renamed to `from` | ||
| */ | ||
| path: string; | ||
| sideEffects?: SideEffectsInfo; | ||
| } | ||
| interface ImportExtended extends Import { | ||
| sideEffects?: SideEffectsInfo; | ||
| __source?: 'dir' | 'resolver'; | ||
| } | ||
| type ImportNameAlias = [string, string]; | ||
| type SideEffectsInfo = Arrayable<ResolverResult | string> | undefined; | ||
| interface ResolverResult { | ||
| as?: string; | ||
| name?: string; | ||
| from: string; | ||
| } | ||
| type ResolverFunction = (name: string) => Awaitable<string | ResolverResult | ImportExtended | null | undefined | void>; | ||
| interface ResolverResultObject { | ||
| type: 'component' | 'directive'; | ||
| resolve: ResolverFunction; | ||
| } | ||
| /** | ||
| * Given a identifier name, returns the import path or an import object | ||
| */ | ||
| type Resolver = ResolverFunction | ResolverResultObject; | ||
| /** | ||
| * module, name, alias | ||
| */ | ||
| type ImportsMap = Record<string, (string | ImportNameAlias)[]>; | ||
| interface ScanDirExportsOptions { | ||
| /** | ||
| * Register type exports | ||
| * | ||
| * @default true | ||
| */ | ||
| types?: boolean; | ||
| } | ||
| /** | ||
| * Directory to search for import | ||
| */ | ||
| interface ScanDir { | ||
| glob: string; | ||
| types?: boolean; | ||
| } | ||
| type NormalizedScanDir = Required<ScanDir>; | ||
| type ESLintGlobalsPropValue = boolean | 'readonly' | 'readable' | 'writable' | 'writeable'; | ||
| interface ESLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| /** | ||
| * @default true | ||
| */ | ||
| globalsPropValue?: ESLintGlobalsPropValue; | ||
| } | ||
| interface BiomeLintrc { | ||
| /** | ||
| * @default false | ||
| */ | ||
| enabled?: boolean; | ||
| /** | ||
| * Filepath to save the generated eslint config | ||
| * | ||
| * @default './.eslintrc-auto-import.json' | ||
| */ | ||
| filepath?: string; | ||
| } | ||
| interface Options { | ||
| /** | ||
| * Preset names or custom imports map | ||
| * | ||
| * @default [] | ||
| */ | ||
| imports?: Arrayable<ImportsMap | PresetName | InlinePreset>; | ||
| /** | ||
| * Local package presets. | ||
| * | ||
| * Register local installed packages as a preset. | ||
| * | ||
| * @default [] | ||
| * @see https://github.com/unplugin/unplugin-auto-import#package-presets | ||
| */ | ||
| packagePresets?: (PackagePreset | string)[]; | ||
| /** | ||
| * Identifiers to be ignored | ||
| */ | ||
| ignore?: (string | RegExp)[]; | ||
| /** | ||
| * These identifiers won't be put on the DTS file | ||
| */ | ||
| ignoreDts?: (string | RegExp)[]; | ||
| /** | ||
| * Inject the imports at the end of other imports | ||
| * | ||
| * @default true | ||
| */ | ||
| injectAtEnd?: boolean; | ||
| /** | ||
| * Options for scanning directories for auto import | ||
| */ | ||
| dirsScanOptions?: ScanDirExportsOptions; | ||
| /** | ||
| * Path for directories to be auto imported | ||
| */ | ||
| dirs?: (string | ScanDir)[]; | ||
| /** | ||
| * Pass a custom function to resolve the component importing path from the component name. | ||
| * | ||
| * The component names are always in PascalCase | ||
| */ | ||
| resolvers?: Arrayable<Arrayable<Resolver>>; | ||
| /** | ||
| * Parser to be used for parsing the source code. | ||
| * | ||
| * @see https://github.com/unjs/unimport#acorn-parser | ||
| * @default 'regex' | ||
| */ | ||
| parser?: UnimportOptions['parser']; | ||
| /** | ||
| * Filepath to generate corresponding .d.ts file. | ||
| * Default enabled when `typescript` is installed locally. | ||
| * Set `false` to disable. | ||
| * | ||
| * @default './auto-imports.d.ts' | ||
| */ | ||
| dts?: string | boolean; | ||
| /** | ||
| * Auto import inside Vue templates | ||
| * | ||
| * @see https://github.com/unjs/unimport/pull/15 | ||
| * @see https://github.com/unjs/unimport/pull/72 | ||
| * @default false | ||
| */ | ||
| vueTemplate?: boolean; | ||
| /** | ||
| * Enable auto import directives for Vue's SFC. | ||
| * | ||
| * Library authors should include `meta.vueDirective: true` in the import metadata. | ||
| * | ||
| * When using a local directives folder, provide the `isDirective` | ||
| * callback to check if the import is a Vue directive. | ||
| * | ||
| * @see https://github.com/unjs/unimport?tab=readme-ov-file#vue-directives-auto-import-and-typescript-declaration-generation | ||
| */ | ||
| vueDirectives?: true | AddonVueDirectivesOptions; | ||
| /** | ||
| * Set default export alias by file name | ||
| * | ||
| * @default false | ||
| */ | ||
| defaultExportByFilename?: boolean; | ||
| /** | ||
| * Rules to include transforming target. | ||
| * | ||
| * @default [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/, /\.svelte$/] | ||
| */ | ||
| include?: FilterPattern; | ||
| /** | ||
| * Rules to exclude transforming target. | ||
| * | ||
| * @default [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/] | ||
| */ | ||
| exclude?: FilterPattern; | ||
| /** | ||
| * Generate corresponding .eslintrc-auto-import.json file. | ||
| */ | ||
| eslintrc?: ESLintrc; | ||
| /** | ||
| * Generate corresponding .biomelintrc.json file. | ||
| */ | ||
| biomelintrc?: BiomeLintrc; | ||
| /** | ||
| * Save unimport items into a JSON file for other tools to consume. | ||
| * Provide a filepath to save the JSON file. | ||
| * | ||
| * When set to `true`, it will save to `./.unimport-items.json` | ||
| * | ||
| * @default false | ||
| */ | ||
| dumpUnimportItems?: boolean | string; | ||
| /** | ||
| * Include auto-imported packages in Vite's `optimizeDeps` option | ||
| * | ||
| * @default true | ||
| */ | ||
| viteOptimizeDeps?: boolean; | ||
| } | ||
| export type { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, ScanDirExportsOptions, SideEffectsInfo }; | ||
| import { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, SideEffectsInfo } from "./types-BcH7f5UK.js"; | ||
| export { BiomeLintrc, ESLintGlobalsPropValue, ESLintrc, ImportExtended, ImportLegacy, ImportNameAlias, ImportsMap, NormalizedScanDir, Options, PresetName, Resolver, ResolverFunction, ResolverResult, ResolverResultObject, ScanDir, SideEffectsInfo }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| //#region src/vite.ts | ||
| var vite_default = require_src.unplugin_default.vite; | ||
| // src/vite.ts | ||
| var vite_default = _chunkFMLWYFD2cjs.unplugin_default.vite; | ||
| exports.default = vite_default; | ||
| //#endregion | ||
| module.exports = vite_default; |
+6
-7
@@ -1,9 +0,8 @@ | ||
| import * as vite from 'vite'; | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| import * as vite6 from "vite"; | ||
| declare const _default: (options: Options) => vite.Plugin<any> | vite.Plugin<any>[]; | ||
| //#region src/vite.d.ts | ||
| declare const _default: (options: Options) => vite6.Plugin<any> | vite6.Plugin<any>[]; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+6
-7
@@ -1,9 +0,8 @@ | ||
| import * as vite from 'vite'; | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| import * as vite7 from "vite"; | ||
| declare const _default: (options: Options) => vite.Plugin<any> | vite.Plugin<any>[]; | ||
| //#region src/vite.d.ts | ||
| declare const _default: (options: Options) => vite7.Plugin<any> | vite7.Plugin<any>[]; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| // src/vite.ts | ||
| //#region src/vite.ts | ||
| var vite_default = unplugin_default.vite; | ||
| export { | ||
| vite_default as default | ||
| }; | ||
| //#endregion | ||
| export { vite_default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); | ||
| const require_src = require('./src-DiCMpaQS.cjs'); | ||
| var _chunkFMLWYFD2cjs = require('./chunk-FMLWYFD2.cjs'); | ||
| require('./chunk-6BSQ6ZKC.cjs'); | ||
| //#region src/webpack.ts | ||
| var webpack_default = require_src.unplugin_default.webpack; | ||
| // src/webpack.ts | ||
| var webpack_default = _chunkFMLWYFD2cjs.unplugin_default.webpack; | ||
| exports.default = webpack_default; | ||
| //#endregion | ||
| module.exports = webpack_default; |
@@ -1,9 +0,8 @@ | ||
| import * as webpack from 'webpack'; | ||
| import { Options } from './types.cjs'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-jTI1vtTa.cjs"; | ||
| import * as webpack4 from "webpack"; | ||
| declare const _default: (options: Options) => webpack.WebpackPluginInstance; | ||
| //#region src/webpack.d.ts | ||
| declare const _default: (options: Options) => webpack4.WebpackPluginInstance; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
@@ -1,9 +0,8 @@ | ||
| import * as webpack from 'webpack'; | ||
| import { Options } from './types.js'; | ||
| import '@antfu/utils'; | ||
| import 'unimport'; | ||
| import 'unplugin-utils'; | ||
| import { Options } from "./types-BcH7f5UK.js"; | ||
| import * as webpack10 from "webpack"; | ||
| declare const _default: (options: Options) => webpack.WebpackPluginInstance; | ||
| //#region src/webpack.d.ts | ||
| declare const _default: (options: Options) => webpack10.WebpackPluginInstance; | ||
| export { _default as default }; | ||
| //#endregion | ||
| export { _default as default }; |
+5
-8
@@ -1,10 +0,7 @@ | ||
| import { | ||
| unplugin_default | ||
| } from "./chunk-KK6O3QBF.js"; | ||
| import "./chunk-DTT25XJ5.js"; | ||
| import { unplugin_default } from "./src-DOo-nqzQ.js"; | ||
| // src/webpack.ts | ||
| //#region src/webpack.ts | ||
| var webpack_default = unplugin_default.webpack; | ||
| export { | ||
| webpack_default as default | ||
| }; | ||
| //#endregion | ||
| export { webpack_default as default }; |
+19
-19
| { | ||
| "name": "unplugin-auto-import", | ||
| "type": "module", | ||
| "version": "19.2.0", | ||
| "version": "19.3.0", | ||
| "description": "Register global imports on demand for Vite and Webpack", | ||
@@ -121,5 +121,5 @@ "author": "Anthony Fu <anthonyfu117@hotmail.com>", | ||
| }, | ||
| "main": "dist/index.cjs", | ||
| "module": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "main": "./dist/index.cjs", | ||
| "module": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "typesVersions": { | ||
@@ -157,31 +157,31 @@ "*": { | ||
| "unimport": "^4.2.0", | ||
| "unplugin": "^2.3.2", | ||
| "unplugin": "^2.3.4", | ||
| "unplugin-utils": "^0.2.4" | ||
| }, | ||
| "devDependencies": { | ||
| "@antfu/eslint-config": "^4.12.1", | ||
| "@antfu/ni": "^24.3.0", | ||
| "@antfu/eslint-config": "^4.13.2", | ||
| "@antfu/ni": "^24.4.0", | ||
| "@antfu/utils": "^9.2.0", | ||
| "@nuxt/kit": "^3.17.2", | ||
| "@nuxt/schema": "^3.17.2", | ||
| "@nuxt/kit": "^3.17.4", | ||
| "@nuxt/schema": "^3.17.4", | ||
| "@svgr/plugin-jsx": "^8.1.0", | ||
| "@types/node": "^22.15.12", | ||
| "@types/node": "^22.15.21", | ||
| "@types/picomatch": "^3.0.2", | ||
| "@types/resolve": "^1.20.6", | ||
| "@vueuse/metadata": "^13.1.0", | ||
| "bumpp": "^10.1.0", | ||
| "eslint": "^9.26.0", | ||
| "@vueuse/metadata": "^13.2.0", | ||
| "bumpp": "^10.1.1", | ||
| "eslint": "^9.27.0", | ||
| "esno": "^4.8.0", | ||
| "fast-glob": "^3.3.3", | ||
| "publint": "^0.3.12", | ||
| "rollup": "^4.40.2", | ||
| "tsup": "^8.4.0", | ||
| "rollup": "^4.41.1", | ||
| "tsdown": "^0.12.3", | ||
| "typescript": "^5.8.3", | ||
| "vite": "^6.3.5", | ||
| "vitest": "^3.1.3", | ||
| "webpack": "^5.99.7" | ||
| "vitest": "^3.1.4", | ||
| "webpack": "^5.99.9" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsup src/*.ts --format cjs,esm --dts --splitting --clean", | ||
| "dev": "tsup src/*.ts --watch src", | ||
| "build": "tsdown", | ||
| "dev": "tsdown -w", | ||
| "lint": "eslint .", | ||
@@ -188,0 +188,0 @@ "lint:fix": "nr lint --fix", |
+2
-0
@@ -279,2 +279,4 @@ # unplugin-auto-import | ||
| dirsScanOptions: { | ||
| filePatterns: ['*.ts'], // Glob patterns for matching files | ||
| fileFilter: file => file.endsWith('.ts'), // Filter files | ||
| types: true // Enable auto import the types under the directories | ||
@@ -281,0 +283,0 @@ }, |
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/presets/index.ts | ||
| var _unimport = require('unimport'); | ||
| // src/presets/ahooks.ts | ||
| var _fs = require('fs'); | ||
| var _localpkg = require('local-pkg'); | ||
| var _cache; | ||
| var ahooks_default = () => { | ||
| if (!_cache) { | ||
| let indexesJson; | ||
| try { | ||
| const path = _localpkg.resolveModule.call(void 0, "ahooks/metadata.json"); | ||
| indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load ahooks, have you installed it?"); | ||
| } | ||
| if (indexesJson) { | ||
| _cache = { | ||
| ahooks: indexesJson.functions.flatMap((i) => [i.name, ...i.alias || []]) | ||
| }; | ||
| } | ||
| } | ||
| return _cache || {}; | ||
| }; | ||
| // src/presets/jotai.ts | ||
| var jotai = { | ||
| jotai: [ | ||
| "atom", | ||
| "useAtom", | ||
| "useAtomValue", | ||
| "useSetAtom" | ||
| ] | ||
| }; | ||
| var jotaiUtils = { | ||
| "jotai/utils": [ | ||
| "atomWithReset", | ||
| "useResetAtom", | ||
| "useReducerAtom", | ||
| "atomWithReducer", | ||
| "atomFamily", | ||
| "selectAtom", | ||
| "useAtomCallback", | ||
| "freezeAtom", | ||
| "freezeAtomCreator", | ||
| "splitAtom", | ||
| "atomWithDefault", | ||
| "waitForAll", | ||
| "atomWithStorage", | ||
| "atomWithHash", | ||
| "createJSONStorage", | ||
| "atomWithObservable", | ||
| "useHydrateAtoms", | ||
| "loadable" | ||
| ] | ||
| }; | ||
| // src/presets/mobx.ts | ||
| var mobx = [ | ||
| // https://mobx.js.org/api.html | ||
| "makeObservable", | ||
| "makeAutoObservable", | ||
| "extendObservable", | ||
| "observable", | ||
| "action", | ||
| "runInAction", | ||
| "flow", | ||
| "flowResult", | ||
| "computed", | ||
| "autorun", | ||
| "reaction", | ||
| "when", | ||
| "onReactionError", | ||
| "intercept", | ||
| "observe", | ||
| "onBecomeObserved", | ||
| "onBecomeUnobserved", | ||
| "toJS" | ||
| ]; | ||
| var mobx_default = { | ||
| mobx: [ | ||
| // https://mobx.js.org/api.html | ||
| ...mobx | ||
| ] | ||
| }; | ||
| // src/presets/mobx-react-lite.ts | ||
| var mobx_react_lite_default = { | ||
| // https://mobx.js.org/api.html | ||
| "mobx-react-lite": [ | ||
| "observer", | ||
| "Observer", | ||
| "useLocalObservable" | ||
| ] | ||
| }; | ||
| // src/presets/preact.ts | ||
| var preact_default = { | ||
| "preact/hooks": [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer" | ||
| ] | ||
| }; | ||
| // src/presets/quasar.ts | ||
| var quasar_default = { | ||
| quasar: [ | ||
| // https://quasar.dev/vue-composables | ||
| "useQuasar", | ||
| "useDialogPluginComponent", | ||
| "useFormChild", | ||
| "useMeta" | ||
| ] | ||
| }; | ||
| // src/presets/react.ts | ||
| var CommonReactAPI = [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer", | ||
| "useImperativeHandle", | ||
| "useDebugValue", | ||
| "useDeferredValue", | ||
| "useLayoutEffect", | ||
| "useTransition", | ||
| "startTransition", | ||
| "useSyncExternalStore", | ||
| "useInsertionEffect", | ||
| "useId", | ||
| "lazy", | ||
| "memo", | ||
| "createRef", | ||
| "forwardRef" | ||
| ]; | ||
| var react_default = { | ||
| react: CommonReactAPI | ||
| }; | ||
| // src/presets/react-i18next.ts | ||
| var react_i18next_default = { | ||
| "react-i18next": ["useTranslation"] | ||
| }; | ||
| // src/presets/react-router.ts | ||
| var ReactRouterHooks = [ | ||
| "useOutletContext", | ||
| "useHref", | ||
| "useInRouterContext", | ||
| "useLocation", | ||
| "useNavigationType", | ||
| "useNavigate", | ||
| "useOutlet", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRoutes" | ||
| ]; | ||
| var react_router_default = { | ||
| "react-router": [ | ||
| ...ReactRouterHooks | ||
| ] | ||
| }; | ||
| // src/presets/react-router-dom.ts | ||
| var react_router_dom_default = { | ||
| "react-router-dom": [ | ||
| ...ReactRouterHooks, | ||
| // react-router-dom only hooks | ||
| "useLinkClickHandler", | ||
| "useSearchParams", | ||
| // react-router-dom Component | ||
| // call once in general | ||
| // 'BrowserRouter', | ||
| // 'HashRouter', | ||
| // 'MemoryRouter', | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Routes" | ||
| ] | ||
| }; | ||
| // src/presets/recoil.ts | ||
| var recoil_default = { | ||
| // https://recoiljs.org/docs/api-reference/core/atom/ | ||
| recoil: [ | ||
| "atom", | ||
| "selector", | ||
| "useRecoilState", | ||
| "useRecoilValue", | ||
| "useSetRecoilState", | ||
| "useResetRecoilState", | ||
| "useRecoilStateLoadable", | ||
| "useRecoilValueLoadable", | ||
| "isRecoilValue", | ||
| "useRecoilCallback" | ||
| ] | ||
| }; | ||
| // src/presets/solid.ts | ||
| var solidCore = { | ||
| "solid-js": [ | ||
| "createSignal", | ||
| "createEffect", | ||
| "createMemo", | ||
| "createResource", | ||
| "onMount", | ||
| "onCleanup", | ||
| "onError", | ||
| "untrack", | ||
| "batch", | ||
| "on", | ||
| "createRoot", | ||
| "mergeProps", | ||
| "splitProps", | ||
| "useTransition", | ||
| "observable", | ||
| "mapArray", | ||
| "indexArray", | ||
| "createContext", | ||
| "useContext", | ||
| "children", | ||
| "lazy", | ||
| "createDeferred", | ||
| "createRenderEffect", | ||
| "createSelector", | ||
| "For", | ||
| "Show", | ||
| "Switch", | ||
| "Match", | ||
| "Index", | ||
| "ErrorBoundary", | ||
| "Suspense", | ||
| "SuspenseList" | ||
| ] | ||
| }; | ||
| var solidStore = { | ||
| "solid-js/store": [ | ||
| "createStore", | ||
| "produce", | ||
| "reconcile", | ||
| "createMutable" | ||
| ] | ||
| }; | ||
| var solidWeb = { | ||
| "solid-js/web": [ | ||
| "Dynamic", | ||
| "hydrate", | ||
| "render", | ||
| "renderToString", | ||
| "renderToStringAsync", | ||
| "renderToStream", | ||
| "isServer", | ||
| "Portal" | ||
| ] | ||
| }; | ||
| var solid_default = { | ||
| ...solidCore, | ||
| ...solidStore, | ||
| ...solidWeb | ||
| }; | ||
| // src/presets/solid-app-router.ts | ||
| var solid_app_router_default = { | ||
| "solid-app-router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] | ||
| }; | ||
| // src/presets/solid-router.ts | ||
| var solid_router_default = { | ||
| "@solidjs/router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] | ||
| }; | ||
| // src/presets/svelte.ts | ||
| var svelteAnimate = { | ||
| "svelte/animate": [ | ||
| "flip" | ||
| ] | ||
| }; | ||
| var svelteEasing = { | ||
| "svelte/easing": [ | ||
| "back", | ||
| "bounce", | ||
| "circ", | ||
| "cubic", | ||
| "elastic", | ||
| "expo", | ||
| "quad", | ||
| "quart", | ||
| "quint", | ||
| "sine" | ||
| ].reduce((acc, e) => { | ||
| acc.push(`${e}In`, `${e}Out`, `${e}InOut`); | ||
| return acc; | ||
| }, ["linear"]) | ||
| }; | ||
| var svelteStore = { | ||
| "svelte/store": [ | ||
| "writable", | ||
| "readable", | ||
| "derived", | ||
| "get" | ||
| ] | ||
| }; | ||
| var svelteMotion = { | ||
| "svelte/motion": [ | ||
| "tweened", | ||
| "spring" | ||
| ] | ||
| }; | ||
| var svelteTransition = { | ||
| "svelte/transition": [ | ||
| "fade", | ||
| "blur", | ||
| "fly", | ||
| "slide", | ||
| "scale", | ||
| "draw", | ||
| "crossfade" | ||
| ] | ||
| }; | ||
| var svelte = { | ||
| svelte: [ | ||
| // lifecycle | ||
| "onMount", | ||
| "beforeUpdate", | ||
| "afterUpdate", | ||
| "onDestroy", | ||
| // tick | ||
| "tick", | ||
| // context | ||
| "setContext", | ||
| "getContext", | ||
| "hasContext", | ||
| "getAllContexts", | ||
| // event dispatcher | ||
| "createEventDispatcher" | ||
| ] | ||
| }; | ||
| // src/presets/uni-app.ts | ||
| var uni_app_default = { | ||
| "@dcloudio/uni-app": [ | ||
| "onAddToFavorites", | ||
| "onBackPress", | ||
| "onError", | ||
| "onHide", | ||
| "onLaunch", | ||
| "onLoad", | ||
| "onNavigationBarButtonTap", | ||
| "onNavigationBarSearchInputChanged", | ||
| "onNavigationBarSearchInputClicked", | ||
| "onNavigationBarSearchInputConfirmed", | ||
| "onNavigationBarSearchInputFocusChanged", | ||
| "onPageNotFound", | ||
| "onPageScroll", | ||
| "onPullDownRefresh", | ||
| "onReachBottom", | ||
| "onReady", | ||
| "onResize", | ||
| "onShareAppMessage", | ||
| "onShareTimeline", | ||
| "onShow", | ||
| "onTabItemTap", | ||
| "onThemeChange", | ||
| "onUnhandledRejection", | ||
| "onUnload" | ||
| ] | ||
| }; | ||
| // src/presets/vee-validate.ts | ||
| var vee_validate_default = { | ||
| "vee-validate": [ | ||
| // https://vee-validate.logaretm.com/v4/guide/composition-api/api-review | ||
| // https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/index.ts | ||
| "validate", | ||
| "defineRule", | ||
| "configure", | ||
| "useField", | ||
| "useForm", | ||
| "useFieldArray", | ||
| "useResetForm", | ||
| "useIsFieldDirty", | ||
| "useIsFieldTouched", | ||
| "useIsFieldValid", | ||
| "useIsSubmitting", | ||
| "useValidateField", | ||
| "useIsFormDirty", | ||
| "useIsFormTouched", | ||
| "useIsFormValid", | ||
| "useValidateForm", | ||
| "useSubmitCount", | ||
| "useFieldValue", | ||
| "useFormValues", | ||
| "useFormErrors", | ||
| "useFieldError", | ||
| "useSubmitForm", | ||
| "FormContextKey", | ||
| "FieldContextKey" | ||
| ] | ||
| }; | ||
| // src/presets/vitepress.ts | ||
| var vitepress_default = { | ||
| vitepress: [ | ||
| // helper methods | ||
| "useData", | ||
| "useRoute", | ||
| "useRouter", | ||
| "withBase" | ||
| ] | ||
| }; | ||
| // src/presets/vue-router.ts | ||
| var vue_router_default = { | ||
| "vue-router": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] | ||
| }; | ||
| // src/presets/vue-router-composables.ts | ||
| var vue_router_composables_default = { | ||
| "vue-router/composables": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] | ||
| }; | ||
| // src/presets/vueuse-core.ts | ||
| var _process = require('process'); var _process2 = _interopRequireDefault(_process); | ||
| var _cache2; | ||
| var vueuse_core_default = () => { | ||
| const excluded = ["toRefs", "utils", "toRef", "toValue"]; | ||
| if (!_cache2) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = _localpkg.resolveModule.call(void 0, "@vueuse/core") || _process2.default.cwd(); | ||
| const path = _localpkg.resolveModule.call(void 0, "@vueuse/core/indexes.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?"); | ||
| } | ||
| if (indexesJson) { | ||
| _cache2 = { | ||
| "@vueuse/core": indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4 && !excluded.includes(i)) | ||
| }; | ||
| } | ||
| } | ||
| return _cache2 || {}; | ||
| }; | ||
| // src/presets/vueuse-head.ts | ||
| var vueuse_head_default = { | ||
| "@vueuse/head": [ | ||
| "useHead", | ||
| "useSeoMeta" | ||
| ] | ||
| }; | ||
| // src/presets/vueuse-math.ts | ||
| var _cache3; | ||
| var vueuse_math_default = () => { | ||
| if (!_cache3) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = _localpkg.resolveModule.call(void 0, "@vueuse/core") || _process2.default.cwd(); | ||
| const path = _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json") || _localpkg.resolveModule.call(void 0, "@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse(_fs.readFileSync.call(void 0, path, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/math, have you installed it?"); | ||
| } | ||
| if (indexesJson) { | ||
| _cache3 = { | ||
| "@vueuse/math": indexesJson.functions.filter((i) => ["math"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4) | ||
| }; | ||
| } | ||
| } | ||
| return _cache3 || {}; | ||
| }; | ||
| // src/presets/vuex.ts | ||
| var vuex_default = { | ||
| vuex: [ | ||
| // https://next.vuex.vuejs.org/api/#createstore | ||
| "createStore", | ||
| // https://github.com/vuejs/vuex/blob/4.0/types/logger.d.ts#L20 | ||
| "createLogger", | ||
| // https://next.vuex.vuejs.org/api/#component-binding-helpers | ||
| "mapState", | ||
| "mapGetters", | ||
| "mapActions", | ||
| "mapMutations", | ||
| "createNamespacedHelpers", | ||
| // https://next.vuex.vuejs.org/api/#composable-functions | ||
| "useStore" | ||
| ] | ||
| }; | ||
| // src/presets/index.ts | ||
| var presets = { | ||
| ..._unimport.builtinPresets, | ||
| "ahooks": ahooks_default, | ||
| "@vueuse/core": vueuse_core_default, | ||
| "@vueuse/math": vueuse_math_default, | ||
| "@vueuse/head": vueuse_head_default, | ||
| "mobx": mobx_default, | ||
| "mobx-react-lite": mobx_react_lite_default, | ||
| "preact": preact_default, | ||
| "quasar": quasar_default, | ||
| "react": react_default, | ||
| "react-router": react_router_default, | ||
| "react-router-dom": react_router_dom_default, | ||
| "react-i18next": react_i18next_default, | ||
| "svelte": svelte, | ||
| "svelte/animate": svelteAnimate, | ||
| "svelte/easing": svelteEasing, | ||
| "svelte/motion": svelteMotion, | ||
| "svelte/store": svelteStore, | ||
| "svelte/transition": svelteTransition, | ||
| "vee-validate": vee_validate_default, | ||
| "vitepress": vitepress_default, | ||
| "vue-router": vue_router_default, | ||
| "vue-router/composables": vue_router_composables_default, | ||
| "vuex": vuex_default, | ||
| "uni-app": uni_app_default, | ||
| "solid-js": solid_default, | ||
| "@solidjs/router": solid_router_default, | ||
| "solid-app-router": solid_app_router_default, | ||
| "jotai": jotai, | ||
| "jotai/utils": jotaiUtils, | ||
| "recoil": recoil_default | ||
| }; | ||
| exports.presets = presets; |
| // src/presets/index.ts | ||
| import { builtinPresets } from "unimport"; | ||
| // src/presets/ahooks.ts | ||
| import { readFileSync } from "node:fs"; | ||
| import { resolveModule } from "local-pkg"; | ||
| var _cache; | ||
| var ahooks_default = () => { | ||
| if (!_cache) { | ||
| let indexesJson; | ||
| try { | ||
| const path = resolveModule("ahooks/metadata.json"); | ||
| indexesJson = JSON.parse(readFileSync(path, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load ahooks, have you installed it?"); | ||
| } | ||
| if (indexesJson) { | ||
| _cache = { | ||
| ahooks: indexesJson.functions.flatMap((i) => [i.name, ...i.alias || []]) | ||
| }; | ||
| } | ||
| } | ||
| return _cache || {}; | ||
| }; | ||
| // src/presets/jotai.ts | ||
| var jotai = { | ||
| jotai: [ | ||
| "atom", | ||
| "useAtom", | ||
| "useAtomValue", | ||
| "useSetAtom" | ||
| ] | ||
| }; | ||
| var jotaiUtils = { | ||
| "jotai/utils": [ | ||
| "atomWithReset", | ||
| "useResetAtom", | ||
| "useReducerAtom", | ||
| "atomWithReducer", | ||
| "atomFamily", | ||
| "selectAtom", | ||
| "useAtomCallback", | ||
| "freezeAtom", | ||
| "freezeAtomCreator", | ||
| "splitAtom", | ||
| "atomWithDefault", | ||
| "waitForAll", | ||
| "atomWithStorage", | ||
| "atomWithHash", | ||
| "createJSONStorage", | ||
| "atomWithObservable", | ||
| "useHydrateAtoms", | ||
| "loadable" | ||
| ] | ||
| }; | ||
| // src/presets/mobx.ts | ||
| var mobx = [ | ||
| // https://mobx.js.org/api.html | ||
| "makeObservable", | ||
| "makeAutoObservable", | ||
| "extendObservable", | ||
| "observable", | ||
| "action", | ||
| "runInAction", | ||
| "flow", | ||
| "flowResult", | ||
| "computed", | ||
| "autorun", | ||
| "reaction", | ||
| "when", | ||
| "onReactionError", | ||
| "intercept", | ||
| "observe", | ||
| "onBecomeObserved", | ||
| "onBecomeUnobserved", | ||
| "toJS" | ||
| ]; | ||
| var mobx_default = { | ||
| mobx: [ | ||
| // https://mobx.js.org/api.html | ||
| ...mobx | ||
| ] | ||
| }; | ||
| // src/presets/mobx-react-lite.ts | ||
| var mobx_react_lite_default = { | ||
| // https://mobx.js.org/api.html | ||
| "mobx-react-lite": [ | ||
| "observer", | ||
| "Observer", | ||
| "useLocalObservable" | ||
| ] | ||
| }; | ||
| // src/presets/preact.ts | ||
| var preact_default = { | ||
| "preact/hooks": [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer" | ||
| ] | ||
| }; | ||
| // src/presets/quasar.ts | ||
| var quasar_default = { | ||
| quasar: [ | ||
| // https://quasar.dev/vue-composables | ||
| "useQuasar", | ||
| "useDialogPluginComponent", | ||
| "useFormChild", | ||
| "useMeta" | ||
| ] | ||
| }; | ||
| // src/presets/react.ts | ||
| var CommonReactAPI = [ | ||
| "useState", | ||
| "useCallback", | ||
| "useMemo", | ||
| "useEffect", | ||
| "useRef", | ||
| "useContext", | ||
| "useReducer", | ||
| "useImperativeHandle", | ||
| "useDebugValue", | ||
| "useDeferredValue", | ||
| "useLayoutEffect", | ||
| "useTransition", | ||
| "startTransition", | ||
| "useSyncExternalStore", | ||
| "useInsertionEffect", | ||
| "useId", | ||
| "lazy", | ||
| "memo", | ||
| "createRef", | ||
| "forwardRef" | ||
| ]; | ||
| var react_default = { | ||
| react: CommonReactAPI | ||
| }; | ||
| // src/presets/react-i18next.ts | ||
| var react_i18next_default = { | ||
| "react-i18next": ["useTranslation"] | ||
| }; | ||
| // src/presets/react-router.ts | ||
| var ReactRouterHooks = [ | ||
| "useOutletContext", | ||
| "useHref", | ||
| "useInRouterContext", | ||
| "useLocation", | ||
| "useNavigationType", | ||
| "useNavigate", | ||
| "useOutlet", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRoutes" | ||
| ]; | ||
| var react_router_default = { | ||
| "react-router": [ | ||
| ...ReactRouterHooks | ||
| ] | ||
| }; | ||
| // src/presets/react-router-dom.ts | ||
| var react_router_dom_default = { | ||
| "react-router-dom": [ | ||
| ...ReactRouterHooks, | ||
| // react-router-dom only hooks | ||
| "useLinkClickHandler", | ||
| "useSearchParams", | ||
| // react-router-dom Component | ||
| // call once in general | ||
| // 'BrowserRouter', | ||
| // 'HashRouter', | ||
| // 'MemoryRouter', | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Routes" | ||
| ] | ||
| }; | ||
| // src/presets/recoil.ts | ||
| var recoil_default = { | ||
| // https://recoiljs.org/docs/api-reference/core/atom/ | ||
| recoil: [ | ||
| "atom", | ||
| "selector", | ||
| "useRecoilState", | ||
| "useRecoilValue", | ||
| "useSetRecoilState", | ||
| "useResetRecoilState", | ||
| "useRecoilStateLoadable", | ||
| "useRecoilValueLoadable", | ||
| "isRecoilValue", | ||
| "useRecoilCallback" | ||
| ] | ||
| }; | ||
| // src/presets/solid.ts | ||
| var solidCore = { | ||
| "solid-js": [ | ||
| "createSignal", | ||
| "createEffect", | ||
| "createMemo", | ||
| "createResource", | ||
| "onMount", | ||
| "onCleanup", | ||
| "onError", | ||
| "untrack", | ||
| "batch", | ||
| "on", | ||
| "createRoot", | ||
| "mergeProps", | ||
| "splitProps", | ||
| "useTransition", | ||
| "observable", | ||
| "mapArray", | ||
| "indexArray", | ||
| "createContext", | ||
| "useContext", | ||
| "children", | ||
| "lazy", | ||
| "createDeferred", | ||
| "createRenderEffect", | ||
| "createSelector", | ||
| "For", | ||
| "Show", | ||
| "Switch", | ||
| "Match", | ||
| "Index", | ||
| "ErrorBoundary", | ||
| "Suspense", | ||
| "SuspenseList" | ||
| ] | ||
| }; | ||
| var solidStore = { | ||
| "solid-js/store": [ | ||
| "createStore", | ||
| "produce", | ||
| "reconcile", | ||
| "createMutable" | ||
| ] | ||
| }; | ||
| var solidWeb = { | ||
| "solid-js/web": [ | ||
| "Dynamic", | ||
| "hydrate", | ||
| "render", | ||
| "renderToString", | ||
| "renderToStringAsync", | ||
| "renderToStream", | ||
| "isServer", | ||
| "Portal" | ||
| ] | ||
| }; | ||
| var solid_default = { | ||
| ...solidCore, | ||
| ...solidStore, | ||
| ...solidWeb | ||
| }; | ||
| // src/presets/solid-app-router.ts | ||
| var solid_app_router_default = { | ||
| "solid-app-router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] | ||
| }; | ||
| // src/presets/solid-router.ts | ||
| var solid_router_default = { | ||
| "@solidjs/router": [ | ||
| "Link", | ||
| "NavLink", | ||
| "Navigate", | ||
| "Outlet", | ||
| "Route", | ||
| "Router", | ||
| "Routes", | ||
| "_mergeSearchString", | ||
| "createIntegration", | ||
| "hashIntegration", | ||
| "normalizeIntegration", | ||
| "pathIntegration", | ||
| "staticIntegration", | ||
| "useHref", | ||
| "useIsRouting", | ||
| "useLocation", | ||
| "useMatch", | ||
| "useNavigate", | ||
| "useParams", | ||
| "useResolvedPath", | ||
| "useRouteData", | ||
| "useRoutes", | ||
| "useSearchParams" | ||
| ] | ||
| }; | ||
| // src/presets/svelte.ts | ||
| var svelteAnimate = { | ||
| "svelte/animate": [ | ||
| "flip" | ||
| ] | ||
| }; | ||
| var svelteEasing = { | ||
| "svelte/easing": [ | ||
| "back", | ||
| "bounce", | ||
| "circ", | ||
| "cubic", | ||
| "elastic", | ||
| "expo", | ||
| "quad", | ||
| "quart", | ||
| "quint", | ||
| "sine" | ||
| ].reduce((acc, e) => { | ||
| acc.push(`${e}In`, `${e}Out`, `${e}InOut`); | ||
| return acc; | ||
| }, ["linear"]) | ||
| }; | ||
| var svelteStore = { | ||
| "svelte/store": [ | ||
| "writable", | ||
| "readable", | ||
| "derived", | ||
| "get" | ||
| ] | ||
| }; | ||
| var svelteMotion = { | ||
| "svelte/motion": [ | ||
| "tweened", | ||
| "spring" | ||
| ] | ||
| }; | ||
| var svelteTransition = { | ||
| "svelte/transition": [ | ||
| "fade", | ||
| "blur", | ||
| "fly", | ||
| "slide", | ||
| "scale", | ||
| "draw", | ||
| "crossfade" | ||
| ] | ||
| }; | ||
| var svelte = { | ||
| svelte: [ | ||
| // lifecycle | ||
| "onMount", | ||
| "beforeUpdate", | ||
| "afterUpdate", | ||
| "onDestroy", | ||
| // tick | ||
| "tick", | ||
| // context | ||
| "setContext", | ||
| "getContext", | ||
| "hasContext", | ||
| "getAllContexts", | ||
| // event dispatcher | ||
| "createEventDispatcher" | ||
| ] | ||
| }; | ||
| // src/presets/uni-app.ts | ||
| var uni_app_default = { | ||
| "@dcloudio/uni-app": [ | ||
| "onAddToFavorites", | ||
| "onBackPress", | ||
| "onError", | ||
| "onHide", | ||
| "onLaunch", | ||
| "onLoad", | ||
| "onNavigationBarButtonTap", | ||
| "onNavigationBarSearchInputChanged", | ||
| "onNavigationBarSearchInputClicked", | ||
| "onNavigationBarSearchInputConfirmed", | ||
| "onNavigationBarSearchInputFocusChanged", | ||
| "onPageNotFound", | ||
| "onPageScroll", | ||
| "onPullDownRefresh", | ||
| "onReachBottom", | ||
| "onReady", | ||
| "onResize", | ||
| "onShareAppMessage", | ||
| "onShareTimeline", | ||
| "onShow", | ||
| "onTabItemTap", | ||
| "onThemeChange", | ||
| "onUnhandledRejection", | ||
| "onUnload" | ||
| ] | ||
| }; | ||
| // src/presets/vee-validate.ts | ||
| var vee_validate_default = { | ||
| "vee-validate": [ | ||
| // https://vee-validate.logaretm.com/v4/guide/composition-api/api-review | ||
| // https://github.com/logaretm/vee-validate/blob/main/packages/vee-validate/src/index.ts | ||
| "validate", | ||
| "defineRule", | ||
| "configure", | ||
| "useField", | ||
| "useForm", | ||
| "useFieldArray", | ||
| "useResetForm", | ||
| "useIsFieldDirty", | ||
| "useIsFieldTouched", | ||
| "useIsFieldValid", | ||
| "useIsSubmitting", | ||
| "useValidateField", | ||
| "useIsFormDirty", | ||
| "useIsFormTouched", | ||
| "useIsFormValid", | ||
| "useValidateForm", | ||
| "useSubmitCount", | ||
| "useFieldValue", | ||
| "useFormValues", | ||
| "useFormErrors", | ||
| "useFieldError", | ||
| "useSubmitForm", | ||
| "FormContextKey", | ||
| "FieldContextKey" | ||
| ] | ||
| }; | ||
| // src/presets/vitepress.ts | ||
| var vitepress_default = { | ||
| vitepress: [ | ||
| // helper methods | ||
| "useData", | ||
| "useRoute", | ||
| "useRouter", | ||
| "withBase" | ||
| ] | ||
| }; | ||
| // src/presets/vue-router.ts | ||
| var vue_router_default = { | ||
| "vue-router": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] | ||
| }; | ||
| // src/presets/vue-router-composables.ts | ||
| var vue_router_composables_default = { | ||
| "vue-router/composables": [ | ||
| "useRouter", | ||
| "useRoute", | ||
| "useLink", | ||
| "onBeforeRouteLeave", | ||
| "onBeforeRouteUpdate" | ||
| ] | ||
| }; | ||
| // src/presets/vueuse-core.ts | ||
| import { readFileSync as readFileSync2 } from "node:fs"; | ||
| import process from "node:process"; | ||
| import { resolveModule as resolveModule2 } from "local-pkg"; | ||
| var _cache2; | ||
| var vueuse_core_default = () => { | ||
| const excluded = ["toRefs", "utils", "toRef", "toValue"]; | ||
| if (!_cache2) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = resolveModule2("@vueuse/core") || process.cwd(); | ||
| const path = resolveModule2("@vueuse/core/indexes.json") || resolveModule2("@vueuse/metadata/index.json") || resolveModule2("@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse(readFileSync2(path, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/core, have you installed it?"); | ||
| } | ||
| if (indexesJson) { | ||
| _cache2 = { | ||
| "@vueuse/core": indexesJson.functions.filter((i) => ["core", "shared"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4 && !excluded.includes(i)) | ||
| }; | ||
| } | ||
| } | ||
| return _cache2 || {}; | ||
| }; | ||
| // src/presets/vueuse-head.ts | ||
| var vueuse_head_default = { | ||
| "@vueuse/head": [ | ||
| "useHead", | ||
| "useSeoMeta" | ||
| ] | ||
| }; | ||
| // src/presets/vueuse-math.ts | ||
| import { readFileSync as readFileSync3 } from "node:fs"; | ||
| import process2 from "node:process"; | ||
| import { resolveModule as resolveModule3 } from "local-pkg"; | ||
| var _cache3; | ||
| var vueuse_math_default = () => { | ||
| if (!_cache3) { | ||
| let indexesJson; | ||
| try { | ||
| const corePath = resolveModule3("@vueuse/core") || process2.cwd(); | ||
| const path = resolveModule3("@vueuse/metadata/index.json") || resolveModule3("@vueuse/metadata/index.json", { paths: [corePath] }); | ||
| indexesJson = JSON.parse(readFileSync3(path, "utf-8")); | ||
| } catch (error) { | ||
| console.error(error); | ||
| throw new Error("[auto-import] failed to load @vueuse/math, have you installed it?"); | ||
| } | ||
| if (indexesJson) { | ||
| _cache3 = { | ||
| "@vueuse/math": indexesJson.functions.filter((i) => ["math"].includes(i.package)).flatMap((i) => [i.name, ...i.alias || []]).filter((i) => i && i.length >= 4) | ||
| }; | ||
| } | ||
| } | ||
| return _cache3 || {}; | ||
| }; | ||
| // src/presets/vuex.ts | ||
| var vuex_default = { | ||
| vuex: [ | ||
| // https://next.vuex.vuejs.org/api/#createstore | ||
| "createStore", | ||
| // https://github.com/vuejs/vuex/blob/4.0/types/logger.d.ts#L20 | ||
| "createLogger", | ||
| // https://next.vuex.vuejs.org/api/#component-binding-helpers | ||
| "mapState", | ||
| "mapGetters", | ||
| "mapActions", | ||
| "mapMutations", | ||
| "createNamespacedHelpers", | ||
| // https://next.vuex.vuejs.org/api/#composable-functions | ||
| "useStore" | ||
| ] | ||
| }; | ||
| // src/presets/index.ts | ||
| var presets = { | ||
| ...builtinPresets, | ||
| "ahooks": ahooks_default, | ||
| "@vueuse/core": vueuse_core_default, | ||
| "@vueuse/math": vueuse_math_default, | ||
| "@vueuse/head": vueuse_head_default, | ||
| "mobx": mobx_default, | ||
| "mobx-react-lite": mobx_react_lite_default, | ||
| "preact": preact_default, | ||
| "quasar": quasar_default, | ||
| "react": react_default, | ||
| "react-router": react_router_default, | ||
| "react-router-dom": react_router_dom_default, | ||
| "react-i18next": react_i18next_default, | ||
| "svelte": svelte, | ||
| "svelte/animate": svelteAnimate, | ||
| "svelte/easing": svelteEasing, | ||
| "svelte/motion": svelteMotion, | ||
| "svelte/store": svelteStore, | ||
| "svelte/transition": svelteTransition, | ||
| "vee-validate": vee_validate_default, | ||
| "vitepress": vitepress_default, | ||
| "vue-router": vue_router_default, | ||
| "vue-router/composables": vue_router_composables_default, | ||
| "vuex": vuex_default, | ||
| "uni-app": uni_app_default, | ||
| "solid-js": solid_default, | ||
| "@solidjs/router": solid_router_default, | ||
| "solid-app-router": solid_app_router_default, | ||
| "jotai": jotai, | ||
| "jotai/utils": jotaiUtils, | ||
| "recoil": recoil_default | ||
| }; | ||
| export { | ||
| presets | ||
| }; |
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
| var _chunk6BSQ6ZKCcjs = require('./chunk-6BSQ6ZKC.cjs'); | ||
| // src/core/unplugin.ts | ||
| var _path = require('path'); var _path2 = _interopRequireDefault(_path); | ||
| // node_modules/.pnpm/@antfu+utils@9.2.0/node_modules/@antfu/utils/dist/index.mjs | ||
| function toArray(array) { | ||
| array = array != null ? array : []; | ||
| return Array.isArray(array) ? array : [array]; | ||
| } | ||
| function slash(str) { | ||
| return str.replace(/\\/g, "/"); | ||
| } | ||
| var VOID = Symbol("p-void"); | ||
| function throttle$1(delay, callback, options) { | ||
| var _ref = options || {}, _ref$noTrailing = _ref.noTrailing, noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing, _ref$noLeading = _ref.noLeading, noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading, _ref$debounceMode = _ref.debounceMode, debounceMode = _ref$debounceMode === void 0 ? void 0 : _ref$debounceMode; | ||
| var timeoutID; | ||
| var cancelled = false; | ||
| var lastExec = 0; | ||
| function clearExistingTimeout() { | ||
| if (timeoutID) { | ||
| clearTimeout(timeoutID); | ||
| } | ||
| } | ||
| function cancel(options2) { | ||
| var _ref2 = options2 || {}, _ref2$upcomingOnly = _ref2.upcomingOnly, upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly; | ||
| clearExistingTimeout(); | ||
| cancelled = !upcomingOnly; | ||
| } | ||
| function wrapper() { | ||
| for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) { | ||
| arguments_[_key] = arguments[_key]; | ||
| } | ||
| var self = this; | ||
| var elapsed = Date.now() - lastExec; | ||
| if (cancelled) { | ||
| return; | ||
| } | ||
| function exec() { | ||
| lastExec = Date.now(); | ||
| callback.apply(self, arguments_); | ||
| } | ||
| function clear() { | ||
| timeoutID = void 0; | ||
| } | ||
| if (!noLeading && debounceMode && !timeoutID) { | ||
| exec(); | ||
| } | ||
| clearExistingTimeout(); | ||
| if (debounceMode === void 0 && elapsed > delay) { | ||
| if (noLeading) { | ||
| lastExec = Date.now(); | ||
| if (!noTrailing) { | ||
| timeoutID = setTimeout(debounceMode ? clear : exec, delay); | ||
| } | ||
| } else { | ||
| exec(); | ||
| } | ||
| } else if (noTrailing !== true) { | ||
| timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === void 0 ? delay - elapsed : delay); | ||
| } | ||
| } | ||
| wrapper.cancel = cancel; | ||
| return wrapper; | ||
| } | ||
| function throttle(...args) { | ||
| return throttle$1(...args); | ||
| } | ||
| // src/core/unplugin.ts | ||
| var _localpkg = require('local-pkg'); | ||
| var _picomatch = require('picomatch'); var _picomatch2 = _interopRequireDefault(_picomatch); | ||
| var _unplugin = require('unplugin'); | ||
| // src/core/ctx.ts | ||
| var _fs = require('fs'); | ||
| var _process = require('process'); var _process2 = _interopRequireDefault(_process); | ||
| var _magicstring = require('magic-string'); var _magicstring2 = _interopRequireDefault(_magicstring); | ||
| var _unimport = require('unimport'); | ||
| var _unpluginutils = require('unplugin-utils'); | ||
| // src/core/biomelintrc.ts | ||
| function generateBiomeLintConfigs(imports) { | ||
| const names = imports.map((i) => { | ||
| var _a; | ||
| return (_a = i.as) != null ? _a : i.name; | ||
| }).filter(Boolean).sort(); | ||
| const config = { javascript: { globals: names } }; | ||
| const jsonBody = JSON.stringify(config, null, 2); | ||
| return jsonBody; | ||
| } | ||
| // src/core/eslintrc.ts | ||
| function generateESLintConfigs(imports, eslintrc, globals = {}) { | ||
| const eslintConfigs = { globals }; | ||
| imports.map((i) => { | ||
| var _a; | ||
| return (_a = i.as) != null ? _a : i.name; | ||
| }).filter(Boolean).sort().forEach((name) => { | ||
| eslintConfigs.globals[name] = eslintrc.globalsPropValue; | ||
| }); | ||
| const jsonBody = JSON.stringify(eslintConfigs, null, 2); | ||
| return jsonBody; | ||
| } | ||
| // src/core/resolvers.ts | ||
| function normalizeImport(info, name) { | ||
| if (typeof info === "string") { | ||
| return { | ||
| name: "default", | ||
| as: name, | ||
| from: info | ||
| }; | ||
| } | ||
| if ("path" in info) { | ||
| return { | ||
| from: info.path, | ||
| as: info.name, | ||
| name: info.importName, | ||
| sideEffects: info.sideEffects | ||
| }; | ||
| } | ||
| return { | ||
| name, | ||
| as: name, | ||
| ...info | ||
| }; | ||
| } | ||
| async function firstMatchedResolver(resolvers, fullname) { | ||
| let name = fullname; | ||
| for (const resolver of resolvers) { | ||
| if (typeof resolver === "object" && resolver.type === "directive") { | ||
| if (name.startsWith("v")) | ||
| name = name.slice(1); | ||
| else | ||
| continue; | ||
| } | ||
| const resolved = await (typeof resolver === "function" ? resolver(name) : resolver.resolve(name)); | ||
| if (resolved) | ||
| return normalizeImport(resolved, fullname); | ||
| } | ||
| } | ||
| function resolversAddon(resolvers) { | ||
| return { | ||
| name: "unplugin-auto-import:resolvers", | ||
| async matchImports(names, matched) { | ||
| if (!resolvers.length) | ||
| return; | ||
| const dynamic = []; | ||
| const sideEffects = []; | ||
| await Promise.all([...names].map(async (name) => { | ||
| const matchedImport = matched.find((i) => i.as === name); | ||
| if (matchedImport) { | ||
| if ("sideEffects" in matchedImport) | ||
| sideEffects.push(...toArray(matchedImport.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| return; | ||
| } | ||
| const resolved = await firstMatchedResolver(resolvers, name); | ||
| if (resolved) | ||
| dynamic.push(resolved); | ||
| if (resolved == null ? void 0 : resolved.sideEffects) | ||
| sideEffects.push(...toArray(resolved == null ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| })); | ||
| if (dynamic.length) { | ||
| this.dynamicImports.push(...dynamic); | ||
| this.invalidate(); | ||
| } | ||
| if (dynamic.length || sideEffects.length) | ||
| return [...matched, ...dynamic, ...sideEffects]; | ||
| } | ||
| }; | ||
| } | ||
| // src/core/ctx.ts | ||
| var INCLUDE_RE_LIST = [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/, /\.svelte$/]; | ||
| var EXCLUDE_RE_LIST = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]; | ||
| function createContext(options = {}, root = _process2.default.cwd()) { | ||
| var _a, _b, _c; | ||
| root = slash(root); | ||
| const { | ||
| dts: preferDTS = _localpkg.isPackageExists.call(void 0, "typescript"), | ||
| dirsScanOptions, | ||
| dirs, | ||
| vueDirectives, | ||
| vueTemplate | ||
| } = options; | ||
| const eslintrc = options.eslintrc || {}; | ||
| eslintrc.enabled = eslintrc.enabled === void 0 ? false : eslintrc.enabled; | ||
| eslintrc.filepath = eslintrc.filepath || "./.eslintrc-auto-import.json"; | ||
| eslintrc.globalsPropValue = eslintrc.globalsPropValue === void 0 ? true : eslintrc.globalsPropValue; | ||
| const biomelintrc = options.biomelintrc || {}; | ||
| biomelintrc.enabled = biomelintrc.enabled !== void 0; | ||
| biomelintrc.filepath = biomelintrc.filepath || "./.biomelintrc-auto-import.json"; | ||
| const dumpUnimportItems = options.dumpUnimportItems === true ? "./.unimport-items.json" : (_a = options.dumpUnimportItems) != null ? _a : false; | ||
| const resolvers = options.resolvers ? [options.resolvers].flat(2) : []; | ||
| const injectAtEnd = options.injectAtEnd !== false; | ||
| const unimport = _unimport.createUnimport.call(void 0, { | ||
| imports: [], | ||
| presets: (_c = (_b = options.packagePresets) == null ? void 0 : _b.map((p) => typeof p === "string" ? { package: p } : p)) != null ? _c : [], | ||
| dirsScanOptions: { | ||
| ...dirsScanOptions, | ||
| cwd: root | ||
| }, | ||
| dirs, | ||
| injectAtEnd, | ||
| parser: options.parser, | ||
| addons: { | ||
| addons: [ | ||
| resolversAddon(resolvers), | ||
| { | ||
| name: "unplugin-auto-import:dts", | ||
| declaration(dts2) { | ||
| return `${` | ||
| /* eslint-disable */ | ||
| /* prettier-ignore */ | ||
| // @ts-nocheck | ||
| // noinspection JSUnusedGlobalSymbols | ||
| // Generated by unplugin-auto-import | ||
| // biome-ignore lint: disable | ||
| ${dts2}`.trim()} | ||
| `; | ||
| } | ||
| } | ||
| ], | ||
| vueDirectives, | ||
| vueTemplate | ||
| } | ||
| }); | ||
| const importsPromise = flattenImports(options.imports).then((imports) => { | ||
| var _a2, _b2; | ||
| if (!imports.length && !resolvers.length && !(dirs == null ? void 0 : dirs.length)) | ||
| console.warn("[auto-import] plugin installed but no imports has defined, see https://github.com/antfu/unplugin-auto-import#configurations for configurations"); | ||
| const compare = (left, right) => { | ||
| return right instanceof RegExp ? right.test(left) : right === left; | ||
| }; | ||
| (_a2 = options.ignore) == null ? void 0 : _a2.forEach((name) => { | ||
| const i = imports.find((i2) => compare(i2.as, name)); | ||
| if (i) | ||
| i.disabled = true; | ||
| }); | ||
| (_b2 = options.ignoreDts) == null ? void 0 : _b2.forEach((name) => { | ||
| const i = imports.find((i2) => compare(i2.as, name)); | ||
| if (i) | ||
| i.dtsDisabled = true; | ||
| }); | ||
| return unimport.getInternalContext().replaceImports(imports); | ||
| }); | ||
| const filter = _unpluginutils.createFilter.call(void 0, | ||
| options.include || INCLUDE_RE_LIST, | ||
| options.exclude || EXCLUDE_RE_LIST | ||
| ); | ||
| const dts = preferDTS === false ? false : preferDTS === true ? _path.resolve.call(void 0, root, "auto-imports.d.ts") : _path.resolve.call(void 0, root, preferDTS); | ||
| const multilineCommentsRE = /\/\*.*?\*\//gs; | ||
| const singlelineCommentsRE = /\/\/.*$/gm; | ||
| const dtsReg = /declare\s+global\s*\{(.*?)[\n\r]\}/s; | ||
| const componentCustomPropertiesReg = /interface\s+ComponentCustomProperties\s*\{(.*?)[\n\r]\}/gs; | ||
| function parseDTS(dts2) { | ||
| var _a2; | ||
| dts2 = dts2.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, ""); | ||
| const code = (_a2 = dts2.match(dtsReg)) == null ? void 0 : _a2[0]; | ||
| if (!code) | ||
| return; | ||
| return Object.fromEntries(Array.from(code.matchAll(/['"]?(const\s*[^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]])); | ||
| } | ||
| async function generateDTS(file) { | ||
| await importsPromise; | ||
| const dir = _path.dirname.call(void 0, file); | ||
| const originalContent = _fs.existsSync.call(void 0, file) ? await _fs.promises.readFile(file, "utf-8") : ""; | ||
| const originalDTS = parseDTS(originalContent); | ||
| let currentContent = await unimport.generateTypeDeclarations({ | ||
| resolvePath: (i) => { | ||
| if (i.from.startsWith(".") || _path.isAbsolute.call(void 0, i.from)) { | ||
| const related = slash(_path.relative.call(void 0, dir, i.from).replace(/\.ts(x)?$/, "")); | ||
| return !related.startsWith(".") ? `./${related}` : related; | ||
| } | ||
| return i.from; | ||
| } | ||
| }); | ||
| const currentDTS = parseDTS(currentContent); | ||
| if (options.vueTemplate) { | ||
| currentContent = currentContent.replace( | ||
| componentCustomPropertiesReg, | ||
| ($1) => `interface GlobalComponents {} | ||
| ${$1}` | ||
| ); | ||
| } | ||
| if (originalDTS) { | ||
| Object.keys(currentDTS).forEach((key) => { | ||
| originalDTS[key] = currentDTS[key]; | ||
| }); | ||
| const dtsList = Object.keys(originalDTS).sort().map((k) => ` ${k}: ${originalDTS[k]}`); | ||
| return currentContent.replace(dtsReg, () => `declare global { | ||
| ${dtsList.join("\n")} | ||
| }`); | ||
| } | ||
| return currentContent; | ||
| } | ||
| async function parseESLint() { | ||
| if (!eslintrc.filepath) | ||
| return {}; | ||
| if (eslintrc.filepath.match(/\.[cm]?[jt]sx?$/)) | ||
| return {}; | ||
| const configStr = _fs.existsSync.call(void 0, eslintrc.filepath) ? await _fs.promises.readFile(eslintrc.filepath, "utf-8") : ""; | ||
| const config = JSON.parse(configStr || '{ "globals": {} }'); | ||
| return config.globals; | ||
| } | ||
| async function generateESLint() { | ||
| return generateESLintConfigs(await unimport.getImports(), eslintrc, await parseESLint()); | ||
| } | ||
| async function generateBiomeLint() { | ||
| return generateBiomeLintConfigs(await unimport.getImports()); | ||
| } | ||
| const writeConfigFilesThrottled = throttle(500, writeConfigFiles, { noLeading: false }); | ||
| async function writeFile(filePath, content = "") { | ||
| await _fs.promises.mkdir(_path.dirname.call(void 0, filePath), { recursive: true }); | ||
| return await _fs.promises.writeFile(filePath, content, "utf-8"); | ||
| } | ||
| let lastDTS; | ||
| let lastESLint; | ||
| let lastBiomeLint; | ||
| let lastUnimportItems; | ||
| async function writeConfigFiles() { | ||
| const promises = []; | ||
| if (dts) { | ||
| promises.push( | ||
| generateDTS(dts).then((content) => { | ||
| if (content !== lastDTS) { | ||
| lastDTS = content; | ||
| return writeFile(dts, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| if (eslintrc.enabled && eslintrc.filepath) { | ||
| const filepath = eslintrc.filepath; | ||
| promises.push( | ||
| generateESLint().then(async (content) => { | ||
| if (filepath.endsWith(".cjs")) | ||
| content = `module.exports = ${content}`; | ||
| else if (filepath.endsWith(".mjs") || filepath.endsWith(".js")) | ||
| content = `export default ${content}`; | ||
| content = `${content} | ||
| `; | ||
| if (content.trim() !== (lastESLint == null ? void 0 : lastESLint.trim())) { | ||
| lastESLint = content; | ||
| return writeFile(eslintrc.filepath, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| if (biomelintrc.enabled) { | ||
| promises.push( | ||
| generateBiomeLint().then((content) => { | ||
| if (content !== lastBiomeLint) { | ||
| lastBiomeLint = content; | ||
| return writeFile(biomelintrc.filepath, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| if (dumpUnimportItems) { | ||
| promises.push( | ||
| unimport.getImports().then((items) => { | ||
| if (!dumpUnimportItems) | ||
| return; | ||
| const content = JSON.stringify(items, null, 2); | ||
| if (content !== lastUnimportItems) { | ||
| lastUnimportItems = content; | ||
| return writeFile(dumpUnimportItems, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| return Promise.all(promises); | ||
| } | ||
| async function scanDirs() { | ||
| await unimport.modifyDynamicImports(async (imports) => { | ||
| const exports_ = await unimport.scanImportsFromDir(); | ||
| exports_.forEach((i) => i.__source = "dir"); | ||
| return modifyDefaultExportsAlias([ | ||
| ...imports.filter((i) => i.__source !== "dir"), | ||
| ...exports_ | ||
| ], options); | ||
| }); | ||
| writeConfigFilesThrottled(); | ||
| } | ||
| async function transform(code, id) { | ||
| await importsPromise; | ||
| const s = new (0, _magicstring2.default)(code); | ||
| await unimport.injectImports(s, id); | ||
| if (!s.hasChanged()) | ||
| return; | ||
| writeConfigFilesThrottled(); | ||
| return { | ||
| code: s.toString(), | ||
| map: s.generateMap({ source: id, includeContent: true, hires: true }) | ||
| }; | ||
| } | ||
| return { | ||
| root, | ||
| dirs, | ||
| filter, | ||
| scanDirs, | ||
| writeConfigFiles, | ||
| writeConfigFilesThrottled, | ||
| transform, | ||
| generateDTS, | ||
| generateESLint, | ||
| unimport | ||
| }; | ||
| } | ||
| async function flattenImports(map) { | ||
| const promises = await Promise.all(toArray(map).map(async (definition) => { | ||
| if (typeof definition === "string") { | ||
| if (!_chunk6BSQ6ZKCcjs.presets[definition]) | ||
| throw new Error(`[auto-import] preset ${definition} not found`); | ||
| const preset = _chunk6BSQ6ZKCcjs.presets[definition]; | ||
| definition = typeof preset === "function" ? preset() : preset; | ||
| } | ||
| if ("from" in definition && "imports" in definition) { | ||
| return await _unimport.resolvePreset.call(void 0, definition); | ||
| } else { | ||
| const resolved = []; | ||
| for (const mod of Object.keys(definition)) { | ||
| for (const id of definition[mod]) { | ||
| const meta = { | ||
| from: mod | ||
| }; | ||
| if (Array.isArray(id)) { | ||
| meta.name = id[0]; | ||
| meta.as = id[1]; | ||
| } else { | ||
| meta.name = id; | ||
| meta.as = id; | ||
| } | ||
| resolved.push(meta); | ||
| } | ||
| } | ||
| return resolved; | ||
| } | ||
| })); | ||
| return promises.flat(); | ||
| } | ||
| function modifyDefaultExportsAlias(imports, options) { | ||
| if (options.defaultExportByFilename) { | ||
| imports.forEach((i) => { | ||
| var _a, _b, _c; | ||
| if (i.name === "default") | ||
| i.as = (_c = (_b = (_a = i.from.split("/").pop()) == null ? void 0 : _a.split(".")) == null ? void 0 : _b.shift()) != null ? _c : i.as; | ||
| }); | ||
| } | ||
| return imports; | ||
| } | ||
| // src/core/unplugin.ts | ||
| var unplugin_default = _unplugin.createUnplugin.call(void 0, (options) => { | ||
| let ctx = createContext(options); | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| enforce: "post", | ||
| transformInclude(id) { | ||
| return ctx.filter(id); | ||
| }, | ||
| transform: { | ||
| filter: { | ||
| id: { | ||
| include: options.include || INCLUDE_RE_LIST, | ||
| exclude: options.exclude || EXCLUDE_RE_LIST | ||
| } | ||
| }, | ||
| async handler(code, id) { | ||
| return ctx.transform(code, id); | ||
| } | ||
| }, | ||
| async buildStart() { | ||
| await ctx.scanDirs(); | ||
| }, | ||
| async buildEnd() { | ||
| await ctx.writeConfigFiles(); | ||
| }, | ||
| vite: { | ||
| async config(config) { | ||
| var _a; | ||
| if (options.viteOptimizeDeps === false) | ||
| return; | ||
| const exclude = ((_a = config.optimizeDeps) == null ? void 0 : _a.exclude) || []; | ||
| const imports = new Set((await ctx.unimport.getImports()).map((i) => i.from).filter((i) => i.match(/^[a-z@]/) && !exclude.includes(i) && _localpkg.isPackageExists.call(void 0, i))); | ||
| if (!imports.size) | ||
| return; | ||
| return { | ||
| optimizeDeps: { | ||
| include: [...imports] | ||
| } | ||
| }; | ||
| }, | ||
| async handleHotUpdate({ file }) { | ||
| var _a; | ||
| const relativeFile = _path2.default.relative(ctx.root, slash(file)); | ||
| if ((_a = ctx.dirs) == null ? void 0 : _a.some((dir) => _picomatch2.default.isMatch(slash(relativeFile), slash(typeof dir === "string" ? dir : dir.glob)))) | ||
| await ctx.scanDirs(); | ||
| }, | ||
| async configResolved(config) { | ||
| if (ctx.root !== config.root) { | ||
| ctx = createContext(options, config.root); | ||
| await ctx.scanDirs(); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| }); | ||
| exports.unplugin_default = unplugin_default; |
| import { | ||
| presets | ||
| } from "./chunk-DTT25XJ5.js"; | ||
| // src/core/unplugin.ts | ||
| import path from "node:path"; | ||
| // node_modules/.pnpm/@antfu+utils@9.2.0/node_modules/@antfu/utils/dist/index.mjs | ||
| function toArray(array) { | ||
| array = array != null ? array : []; | ||
| return Array.isArray(array) ? array : [array]; | ||
| } | ||
| function slash(str) { | ||
| return str.replace(/\\/g, "/"); | ||
| } | ||
| var VOID = Symbol("p-void"); | ||
| function throttle$1(delay, callback, options) { | ||
| var _ref = options || {}, _ref$noTrailing = _ref.noTrailing, noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing, _ref$noLeading = _ref.noLeading, noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading, _ref$debounceMode = _ref.debounceMode, debounceMode = _ref$debounceMode === void 0 ? void 0 : _ref$debounceMode; | ||
| var timeoutID; | ||
| var cancelled = false; | ||
| var lastExec = 0; | ||
| function clearExistingTimeout() { | ||
| if (timeoutID) { | ||
| clearTimeout(timeoutID); | ||
| } | ||
| } | ||
| function cancel(options2) { | ||
| var _ref2 = options2 || {}, _ref2$upcomingOnly = _ref2.upcomingOnly, upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly; | ||
| clearExistingTimeout(); | ||
| cancelled = !upcomingOnly; | ||
| } | ||
| function wrapper() { | ||
| for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) { | ||
| arguments_[_key] = arguments[_key]; | ||
| } | ||
| var self = this; | ||
| var elapsed = Date.now() - lastExec; | ||
| if (cancelled) { | ||
| return; | ||
| } | ||
| function exec() { | ||
| lastExec = Date.now(); | ||
| callback.apply(self, arguments_); | ||
| } | ||
| function clear() { | ||
| timeoutID = void 0; | ||
| } | ||
| if (!noLeading && debounceMode && !timeoutID) { | ||
| exec(); | ||
| } | ||
| clearExistingTimeout(); | ||
| if (debounceMode === void 0 && elapsed > delay) { | ||
| if (noLeading) { | ||
| lastExec = Date.now(); | ||
| if (!noTrailing) { | ||
| timeoutID = setTimeout(debounceMode ? clear : exec, delay); | ||
| } | ||
| } else { | ||
| exec(); | ||
| } | ||
| } else if (noTrailing !== true) { | ||
| timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === void 0 ? delay - elapsed : delay); | ||
| } | ||
| } | ||
| wrapper.cancel = cancel; | ||
| return wrapper; | ||
| } | ||
| function throttle(...args) { | ||
| return throttle$1(...args); | ||
| } | ||
| // src/core/unplugin.ts | ||
| import { isPackageExists as isPackageExists2 } from "local-pkg"; | ||
| import pm from "picomatch"; | ||
| import { createUnplugin } from "unplugin"; | ||
| // src/core/ctx.ts | ||
| import { existsSync, promises as fs } from "node:fs"; | ||
| import { dirname, isAbsolute, relative, resolve } from "node:path"; | ||
| import process from "node:process"; | ||
| import { isPackageExists } from "local-pkg"; | ||
| import MagicString from "magic-string"; | ||
| import { createUnimport, resolvePreset } from "unimport"; | ||
| import { createFilter } from "unplugin-utils"; | ||
| // src/core/biomelintrc.ts | ||
| function generateBiomeLintConfigs(imports) { | ||
| const names = imports.map((i) => { | ||
| var _a; | ||
| return (_a = i.as) != null ? _a : i.name; | ||
| }).filter(Boolean).sort(); | ||
| const config = { javascript: { globals: names } }; | ||
| const jsonBody = JSON.stringify(config, null, 2); | ||
| return jsonBody; | ||
| } | ||
| // src/core/eslintrc.ts | ||
| function generateESLintConfigs(imports, eslintrc, globals = {}) { | ||
| const eslintConfigs = { globals }; | ||
| imports.map((i) => { | ||
| var _a; | ||
| return (_a = i.as) != null ? _a : i.name; | ||
| }).filter(Boolean).sort().forEach((name) => { | ||
| eslintConfigs.globals[name] = eslintrc.globalsPropValue; | ||
| }); | ||
| const jsonBody = JSON.stringify(eslintConfigs, null, 2); | ||
| return jsonBody; | ||
| } | ||
| // src/core/resolvers.ts | ||
| function normalizeImport(info, name) { | ||
| if (typeof info === "string") { | ||
| return { | ||
| name: "default", | ||
| as: name, | ||
| from: info | ||
| }; | ||
| } | ||
| if ("path" in info) { | ||
| return { | ||
| from: info.path, | ||
| as: info.name, | ||
| name: info.importName, | ||
| sideEffects: info.sideEffects | ||
| }; | ||
| } | ||
| return { | ||
| name, | ||
| as: name, | ||
| ...info | ||
| }; | ||
| } | ||
| async function firstMatchedResolver(resolvers, fullname) { | ||
| let name = fullname; | ||
| for (const resolver of resolvers) { | ||
| if (typeof resolver === "object" && resolver.type === "directive") { | ||
| if (name.startsWith("v")) | ||
| name = name.slice(1); | ||
| else | ||
| continue; | ||
| } | ||
| const resolved = await (typeof resolver === "function" ? resolver(name) : resolver.resolve(name)); | ||
| if (resolved) | ||
| return normalizeImport(resolved, fullname); | ||
| } | ||
| } | ||
| function resolversAddon(resolvers) { | ||
| return { | ||
| name: "unplugin-auto-import:resolvers", | ||
| async matchImports(names, matched) { | ||
| if (!resolvers.length) | ||
| return; | ||
| const dynamic = []; | ||
| const sideEffects = []; | ||
| await Promise.all([...names].map(async (name) => { | ||
| const matchedImport = matched.find((i) => i.as === name); | ||
| if (matchedImport) { | ||
| if ("sideEffects" in matchedImport) | ||
| sideEffects.push(...toArray(matchedImport.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| return; | ||
| } | ||
| const resolved = await firstMatchedResolver(resolvers, name); | ||
| if (resolved) | ||
| dynamic.push(resolved); | ||
| if (resolved == null ? void 0 : resolved.sideEffects) | ||
| sideEffects.push(...toArray(resolved == null ? void 0 : resolved.sideEffects).map((i) => normalizeImport(i, ""))); | ||
| })); | ||
| if (dynamic.length) { | ||
| this.dynamicImports.push(...dynamic); | ||
| this.invalidate(); | ||
| } | ||
| if (dynamic.length || sideEffects.length) | ||
| return [...matched, ...dynamic, ...sideEffects]; | ||
| } | ||
| }; | ||
| } | ||
| // src/core/ctx.ts | ||
| var INCLUDE_RE_LIST = [/\.[jt]sx?$/, /\.astro$/, /\.vue$/, /\.vue\?vue/, /\.vue\.[tj]sx?\?vue/, /\.svelte$/]; | ||
| var EXCLUDE_RE_LIST = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/]; | ||
| function createContext(options = {}, root = process.cwd()) { | ||
| var _a, _b, _c; | ||
| root = slash(root); | ||
| const { | ||
| dts: preferDTS = isPackageExists("typescript"), | ||
| dirsScanOptions, | ||
| dirs, | ||
| vueDirectives, | ||
| vueTemplate | ||
| } = options; | ||
| const eslintrc = options.eslintrc || {}; | ||
| eslintrc.enabled = eslintrc.enabled === void 0 ? false : eslintrc.enabled; | ||
| eslintrc.filepath = eslintrc.filepath || "./.eslintrc-auto-import.json"; | ||
| eslintrc.globalsPropValue = eslintrc.globalsPropValue === void 0 ? true : eslintrc.globalsPropValue; | ||
| const biomelintrc = options.biomelintrc || {}; | ||
| biomelintrc.enabled = biomelintrc.enabled !== void 0; | ||
| biomelintrc.filepath = biomelintrc.filepath || "./.biomelintrc-auto-import.json"; | ||
| const dumpUnimportItems = options.dumpUnimportItems === true ? "./.unimport-items.json" : (_a = options.dumpUnimportItems) != null ? _a : false; | ||
| const resolvers = options.resolvers ? [options.resolvers].flat(2) : []; | ||
| const injectAtEnd = options.injectAtEnd !== false; | ||
| const unimport = createUnimport({ | ||
| imports: [], | ||
| presets: (_c = (_b = options.packagePresets) == null ? void 0 : _b.map((p) => typeof p === "string" ? { package: p } : p)) != null ? _c : [], | ||
| dirsScanOptions: { | ||
| ...dirsScanOptions, | ||
| cwd: root | ||
| }, | ||
| dirs, | ||
| injectAtEnd, | ||
| parser: options.parser, | ||
| addons: { | ||
| addons: [ | ||
| resolversAddon(resolvers), | ||
| { | ||
| name: "unplugin-auto-import:dts", | ||
| declaration(dts2) { | ||
| return `${` | ||
| /* eslint-disable */ | ||
| /* prettier-ignore */ | ||
| // @ts-nocheck | ||
| // noinspection JSUnusedGlobalSymbols | ||
| // Generated by unplugin-auto-import | ||
| // biome-ignore lint: disable | ||
| ${dts2}`.trim()} | ||
| `; | ||
| } | ||
| } | ||
| ], | ||
| vueDirectives, | ||
| vueTemplate | ||
| } | ||
| }); | ||
| const importsPromise = flattenImports(options.imports).then((imports) => { | ||
| var _a2, _b2; | ||
| if (!imports.length && !resolvers.length && !(dirs == null ? void 0 : dirs.length)) | ||
| console.warn("[auto-import] plugin installed but no imports has defined, see https://github.com/antfu/unplugin-auto-import#configurations for configurations"); | ||
| const compare = (left, right) => { | ||
| return right instanceof RegExp ? right.test(left) : right === left; | ||
| }; | ||
| (_a2 = options.ignore) == null ? void 0 : _a2.forEach((name) => { | ||
| const i = imports.find((i2) => compare(i2.as, name)); | ||
| if (i) | ||
| i.disabled = true; | ||
| }); | ||
| (_b2 = options.ignoreDts) == null ? void 0 : _b2.forEach((name) => { | ||
| const i = imports.find((i2) => compare(i2.as, name)); | ||
| if (i) | ||
| i.dtsDisabled = true; | ||
| }); | ||
| return unimport.getInternalContext().replaceImports(imports); | ||
| }); | ||
| const filter = createFilter( | ||
| options.include || INCLUDE_RE_LIST, | ||
| options.exclude || EXCLUDE_RE_LIST | ||
| ); | ||
| const dts = preferDTS === false ? false : preferDTS === true ? resolve(root, "auto-imports.d.ts") : resolve(root, preferDTS); | ||
| const multilineCommentsRE = /\/\*.*?\*\//gs; | ||
| const singlelineCommentsRE = /\/\/.*$/gm; | ||
| const dtsReg = /declare\s+global\s*\{(.*?)[\n\r]\}/s; | ||
| const componentCustomPropertiesReg = /interface\s+ComponentCustomProperties\s*\{(.*?)[\n\r]\}/gs; | ||
| function parseDTS(dts2) { | ||
| var _a2; | ||
| dts2 = dts2.replace(multilineCommentsRE, "").replace(singlelineCommentsRE, ""); | ||
| const code = (_a2 = dts2.match(dtsReg)) == null ? void 0 : _a2[0]; | ||
| if (!code) | ||
| return; | ||
| return Object.fromEntries(Array.from(code.matchAll(/['"]?(const\s*[^\s'"]+)['"]?\s*:\s*(.+?)[,;\r\n]/g)).map((i) => [i[1], i[2]])); | ||
| } | ||
| async function generateDTS(file) { | ||
| await importsPromise; | ||
| const dir = dirname(file); | ||
| const originalContent = existsSync(file) ? await fs.readFile(file, "utf-8") : ""; | ||
| const originalDTS = parseDTS(originalContent); | ||
| let currentContent = await unimport.generateTypeDeclarations({ | ||
| resolvePath: (i) => { | ||
| if (i.from.startsWith(".") || isAbsolute(i.from)) { | ||
| const related = slash(relative(dir, i.from).replace(/\.ts(x)?$/, "")); | ||
| return !related.startsWith(".") ? `./${related}` : related; | ||
| } | ||
| return i.from; | ||
| } | ||
| }); | ||
| const currentDTS = parseDTS(currentContent); | ||
| if (options.vueTemplate) { | ||
| currentContent = currentContent.replace( | ||
| componentCustomPropertiesReg, | ||
| ($1) => `interface GlobalComponents {} | ||
| ${$1}` | ||
| ); | ||
| } | ||
| if (originalDTS) { | ||
| Object.keys(currentDTS).forEach((key) => { | ||
| originalDTS[key] = currentDTS[key]; | ||
| }); | ||
| const dtsList = Object.keys(originalDTS).sort().map((k) => ` ${k}: ${originalDTS[k]}`); | ||
| return currentContent.replace(dtsReg, () => `declare global { | ||
| ${dtsList.join("\n")} | ||
| }`); | ||
| } | ||
| return currentContent; | ||
| } | ||
| async function parseESLint() { | ||
| if (!eslintrc.filepath) | ||
| return {}; | ||
| if (eslintrc.filepath.match(/\.[cm]?[jt]sx?$/)) | ||
| return {}; | ||
| const configStr = existsSync(eslintrc.filepath) ? await fs.readFile(eslintrc.filepath, "utf-8") : ""; | ||
| const config = JSON.parse(configStr || '{ "globals": {} }'); | ||
| return config.globals; | ||
| } | ||
| async function generateESLint() { | ||
| return generateESLintConfigs(await unimport.getImports(), eslintrc, await parseESLint()); | ||
| } | ||
| async function generateBiomeLint() { | ||
| return generateBiomeLintConfigs(await unimport.getImports()); | ||
| } | ||
| const writeConfigFilesThrottled = throttle(500, writeConfigFiles, { noLeading: false }); | ||
| async function writeFile(filePath, content = "") { | ||
| await fs.mkdir(dirname(filePath), { recursive: true }); | ||
| return await fs.writeFile(filePath, content, "utf-8"); | ||
| } | ||
| let lastDTS; | ||
| let lastESLint; | ||
| let lastBiomeLint; | ||
| let lastUnimportItems; | ||
| async function writeConfigFiles() { | ||
| const promises = []; | ||
| if (dts) { | ||
| promises.push( | ||
| generateDTS(dts).then((content) => { | ||
| if (content !== lastDTS) { | ||
| lastDTS = content; | ||
| return writeFile(dts, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| if (eslintrc.enabled && eslintrc.filepath) { | ||
| const filepath = eslintrc.filepath; | ||
| promises.push( | ||
| generateESLint().then(async (content) => { | ||
| if (filepath.endsWith(".cjs")) | ||
| content = `module.exports = ${content}`; | ||
| else if (filepath.endsWith(".mjs") || filepath.endsWith(".js")) | ||
| content = `export default ${content}`; | ||
| content = `${content} | ||
| `; | ||
| if (content.trim() !== (lastESLint == null ? void 0 : lastESLint.trim())) { | ||
| lastESLint = content; | ||
| return writeFile(eslintrc.filepath, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| if (biomelintrc.enabled) { | ||
| promises.push( | ||
| generateBiomeLint().then((content) => { | ||
| if (content !== lastBiomeLint) { | ||
| lastBiomeLint = content; | ||
| return writeFile(biomelintrc.filepath, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| if (dumpUnimportItems) { | ||
| promises.push( | ||
| unimport.getImports().then((items) => { | ||
| if (!dumpUnimportItems) | ||
| return; | ||
| const content = JSON.stringify(items, null, 2); | ||
| if (content !== lastUnimportItems) { | ||
| lastUnimportItems = content; | ||
| return writeFile(dumpUnimportItems, content); | ||
| } | ||
| }) | ||
| ); | ||
| } | ||
| return Promise.all(promises); | ||
| } | ||
| async function scanDirs() { | ||
| await unimport.modifyDynamicImports(async (imports) => { | ||
| const exports_ = await unimport.scanImportsFromDir(); | ||
| exports_.forEach((i) => i.__source = "dir"); | ||
| return modifyDefaultExportsAlias([ | ||
| ...imports.filter((i) => i.__source !== "dir"), | ||
| ...exports_ | ||
| ], options); | ||
| }); | ||
| writeConfigFilesThrottled(); | ||
| } | ||
| async function transform(code, id) { | ||
| await importsPromise; | ||
| const s = new MagicString(code); | ||
| await unimport.injectImports(s, id); | ||
| if (!s.hasChanged()) | ||
| return; | ||
| writeConfigFilesThrottled(); | ||
| return { | ||
| code: s.toString(), | ||
| map: s.generateMap({ source: id, includeContent: true, hires: true }) | ||
| }; | ||
| } | ||
| return { | ||
| root, | ||
| dirs, | ||
| filter, | ||
| scanDirs, | ||
| writeConfigFiles, | ||
| writeConfigFilesThrottled, | ||
| transform, | ||
| generateDTS, | ||
| generateESLint, | ||
| unimport | ||
| }; | ||
| } | ||
| async function flattenImports(map) { | ||
| const promises = await Promise.all(toArray(map).map(async (definition) => { | ||
| if (typeof definition === "string") { | ||
| if (!presets[definition]) | ||
| throw new Error(`[auto-import] preset ${definition} not found`); | ||
| const preset = presets[definition]; | ||
| definition = typeof preset === "function" ? preset() : preset; | ||
| } | ||
| if ("from" in definition && "imports" in definition) { | ||
| return await resolvePreset(definition); | ||
| } else { | ||
| const resolved = []; | ||
| for (const mod of Object.keys(definition)) { | ||
| for (const id of definition[mod]) { | ||
| const meta = { | ||
| from: mod | ||
| }; | ||
| if (Array.isArray(id)) { | ||
| meta.name = id[0]; | ||
| meta.as = id[1]; | ||
| } else { | ||
| meta.name = id; | ||
| meta.as = id; | ||
| } | ||
| resolved.push(meta); | ||
| } | ||
| } | ||
| return resolved; | ||
| } | ||
| })); | ||
| return promises.flat(); | ||
| } | ||
| function modifyDefaultExportsAlias(imports, options) { | ||
| if (options.defaultExportByFilename) { | ||
| imports.forEach((i) => { | ||
| var _a, _b, _c; | ||
| if (i.name === "default") | ||
| i.as = (_c = (_b = (_a = i.from.split("/").pop()) == null ? void 0 : _a.split(".")) == null ? void 0 : _b.shift()) != null ? _c : i.as; | ||
| }); | ||
| } | ||
| return imports; | ||
| } | ||
| // src/core/unplugin.ts | ||
| var unplugin_default = createUnplugin((options) => { | ||
| let ctx = createContext(options); | ||
| return { | ||
| name: "unplugin-auto-import", | ||
| enforce: "post", | ||
| transformInclude(id) { | ||
| return ctx.filter(id); | ||
| }, | ||
| transform: { | ||
| filter: { | ||
| id: { | ||
| include: options.include || INCLUDE_RE_LIST, | ||
| exclude: options.exclude || EXCLUDE_RE_LIST | ||
| } | ||
| }, | ||
| async handler(code, id) { | ||
| return ctx.transform(code, id); | ||
| } | ||
| }, | ||
| async buildStart() { | ||
| await ctx.scanDirs(); | ||
| }, | ||
| async buildEnd() { | ||
| await ctx.writeConfigFiles(); | ||
| }, | ||
| vite: { | ||
| async config(config) { | ||
| var _a; | ||
| if (options.viteOptimizeDeps === false) | ||
| return; | ||
| const exclude = ((_a = config.optimizeDeps) == null ? void 0 : _a.exclude) || []; | ||
| const imports = new Set((await ctx.unimport.getImports()).map((i) => i.from).filter((i) => i.match(/^[a-z@]/) && !exclude.includes(i) && isPackageExists2(i))); | ||
| if (!imports.size) | ||
| return; | ||
| return { | ||
| optimizeDeps: { | ||
| include: [...imports] | ||
| } | ||
| }; | ||
| }, | ||
| async handleHotUpdate({ file }) { | ||
| var _a; | ||
| const relativeFile = path.relative(ctx.root, slash(file)); | ||
| if ((_a = ctx.dirs) == null ? void 0 : _a.some((dir) => pm.isMatch(slash(relativeFile), slash(typeof dir === "string" ? dir : dir.glob)))) | ||
| await ctx.scanDirs(); | ||
| }, | ||
| async configResolved(config) { | ||
| if (ctx.root !== config.root) { | ||
| ctx = createContext(options, config.root); | ||
| await ctx.scanDirs(); | ||
| } | ||
| } | ||
| } | ||
| }; | ||
| }); | ||
| export { | ||
| unplugin_default | ||
| }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
480
0.42%4
-55.56%106943
-2.71%2456
-12.72%2
Infinity%1
Infinity%Updated