resolvers.d.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. import { ComponentResolver, ComponentResolveResult } from './types.js';
  2. import '@rollup/pluginutils';
  3. import 'unplugin';
  4. import '@antfu/utils';
  5. interface AntDesignVueResolverOptions {
  6. /**
  7. * exclude components that do not require automatic import
  8. *
  9. * @default []
  10. */
  11. exclude?: string[];
  12. /**
  13. * import style along with components
  14. *
  15. * @default 'css'
  16. */
  17. importStyle?: boolean | 'css' | 'less';
  18. /**
  19. * resolve `ant-design-vue' icons
  20. *
  21. * requires package `@ant-design/icons-vue`
  22. *
  23. * @default false
  24. */
  25. resolveIcons?: boolean;
  26. /**
  27. * @deprecated use `importStyle: 'css'` instead
  28. */
  29. importCss?: boolean;
  30. /**
  31. * @deprecated use `importStyle: 'less'` instead
  32. */
  33. importLess?: boolean;
  34. /**
  35. * use commonjs build default false
  36. */
  37. cjs?: boolean;
  38. /**
  39. * rename package
  40. *
  41. * @default 'ant-design-vue'
  42. */
  43. packageName?: string;
  44. /**
  45. * customize prefix of component
  46. * @default 'A'
  47. */
  48. prefix?: string;
  49. }
  50. /**
  51. * Resolver for Ant Design Vue
  52. *
  53. * Requires ant-design-vue@v2.2.0-beta.6 or later
  54. *
  55. * See https://github.com/antfu/unplugin-vue-components/issues/26#issuecomment-789767941 for more details
  56. *
  57. * @author @yangss3
  58. * @link https://antdv.com/
  59. */
  60. declare function AntDesignVueResolver(options?: AntDesignVueResolverOptions): ComponentResolver;
  61. interface ElementPlusResolverOptions {
  62. /**
  63. * import style css or sass with components
  64. *
  65. * @default 'css'
  66. */
  67. importStyle?: boolean | 'css' | 'sass';
  68. /**
  69. * use commonjs lib & source css or scss for ssr
  70. */
  71. ssr?: boolean;
  72. /**
  73. * specify element-plus version to load style
  74. *
  75. * @default installed version
  76. */
  77. version?: string;
  78. /**
  79. * auto import for directives
  80. *
  81. * @default true
  82. */
  83. directives?: boolean;
  84. /**
  85. * exclude component name, if match do not resolve the name
  86. */
  87. exclude?: RegExp;
  88. /**
  89. * a list of component names that have no styles, so resolving their styles file should be prevented
  90. */
  91. noStylesComponents?: string[];
  92. /**
  93. * nightly version
  94. */
  95. nightly?: boolean;
  96. }
  97. /**
  98. * Resolver for Element Plus
  99. *
  100. * See https://github.com/antfu/vite-plugin-components/pull/28 for more details
  101. * See https://github.com/antfu/vite-plugin-components/issues/117 for more details
  102. *
  103. * @author @develar @nabaonan @sxzz
  104. * @link https://element-plus.org/ for element-plus
  105. *
  106. */
  107. declare function ElementPlusResolver(options?: ElementPlusResolverOptions): ComponentResolver[];
  108. interface ElementUiResolverOptions {
  109. /**
  110. * import style css or sass with components
  111. *
  112. * @default 'css'
  113. */
  114. importStyle?: boolean | 'css' | 'sass';
  115. /**
  116. * exclude component name, if match do not resolve the name
  117. */
  118. exclude?: RegExp;
  119. }
  120. /**
  121. * Resolver for Element-UI
  122. * @link https://element.eleme.cn/#/zh-CN
  123. * @version @element-ui ^2.15.3, @vue ^2.6.14
  124. * @author @nabaonan
  125. */
  126. declare function ElementUiResolver(options?: ElementUiResolverOptions): ComponentResolver;
  127. interface HeadlessUiResolverOptions {
  128. /**
  129. * prefix for headless ui components used in templates
  130. *
  131. * @default ""
  132. */
  133. prefix?: string;
  134. }
  135. /**
  136. * Resolver for headlessui
  137. *
  138. * @link https://github.com/tailwindlabs/headlessui
  139. */
  140. declare function HeadlessUiResolver(options?: HeadlessUiResolverOptions): ComponentResolver;
  141. interface IduxResolverOptions {
  142. /**
  143. * exclude components that do not require automatic import
  144. *
  145. * @default []
  146. */
  147. exclude?: string[];
  148. /**
  149. * import style along with components
  150. */
  151. importStyle?: 'css' | 'less';
  152. /**
  153. * theme for import style
  154. *
  155. * @default 'default'
  156. */
  157. importStyleTheme?: string;
  158. /**
  159. * The scope of the packages.
  160. *
  161. * @default '@idux'
  162. */
  163. scope?: string;
  164. }
  165. /**
  166. * Resolver for `@idux/cdk`, `@idux/components` and ``@idux/pro``
  167. *
  168. * @link https://idux.site
  169. */
  170. declare function IduxResolver(options?: IduxResolverOptions): ComponentResolver;
  171. /**
  172. * Resolver for Inkline
  173. *
  174. * @author @alexgrozav
  175. * @link https://github.com/inkline/inkline
  176. */
  177. declare function InklineResolver(): ComponentResolver;
  178. /**
  179. * Resolver for Naive UI
  180. *
  181. * @author @antfu
  182. * @link https://www.naiveui.com/
  183. */
  184. declare function NaiveUiResolver(): ComponentResolver;
  185. interface PrimeVueResolverOptions {
  186. /**
  187. * import style along with components
  188. *
  189. * @default true
  190. */
  191. importStyle?: boolean;
  192. /**
  193. * import `primeicons' icons
  194. *
  195. * requires package `primeicons`
  196. *
  197. * @default true
  198. */
  199. importIcons?: boolean;
  200. /**
  201. * imports a free theme - set theme name here (e.g. saga-blue)
  202. *
  203. * @default ''
  204. */
  205. importTheme?: string;
  206. /**
  207. * prefix for components (e.g. 'P' to resolve Menu from PMenu)
  208. *
  209. * @default ''
  210. */
  211. prefix?: string;
  212. }
  213. /**
  214. * Resolver for PrimeVue - If you're using a component with the same tag as an native HTML element (e.g. button) the component must be in uppercase
  215. *
  216. * @link https://github.com/primefaces/primevue
  217. */
  218. declare function PrimeVueResolver(options?: PrimeVueResolverOptions): ComponentResolver;
  219. interface VantResolverOptions {
  220. /**
  221. * import style css or less along with components
  222. *
  223. * @default true
  224. */
  225. importStyle?: boolean | 'css' | 'less';
  226. }
  227. /**
  228. * Resolver for Vant
  229. *
  230. * @link https://github.com/youzan/vant
  231. */
  232. declare function VantResolver(options?: VantResolverOptions): ComponentResolver;
  233. interface VarletUIResolverOptions {
  234. /**
  235. * support vue version
  236. * vue3 use @varlet/ui, vue2 use @varlet-vue2/ui
  237. *
  238. * @default 'vue3'
  239. */
  240. version?: 'vue3' | 'vue2';
  241. /**
  242. * import style along with components
  243. *
  244. * @default 'css'
  245. */
  246. importStyle?: boolean | 'css' | 'less';
  247. /**
  248. * auto import for directives
  249. *
  250. * @default true
  251. */
  252. directives?: boolean;
  253. /**
  254. * compatible with unplugin-auto-import
  255. *
  256. * @default false
  257. */
  258. autoImport?: boolean;
  259. /**
  260. * @deprecated use `importStyle: 'css'` instead
  261. */
  262. importCss?: boolean;
  263. /**
  264. * @deprecated use `importStyle: 'less'` instead
  265. */
  266. importLess?: boolean;
  267. }
  268. declare function getResolved(name: string, options: VarletUIResolverOptions): ComponentResolveResult;
  269. /**
  270. * Resolver for VarletUI
  271. *
  272. * @link https://github.com/varletjs/varlet
  273. * @link https://github.com/varletjs/varlet-vue2
  274. */
  275. declare function VarletUIResolver(options?: VarletUIResolverOptions): ComponentResolver[];
  276. interface VeuiPeerConfig {
  277. /**
  278. * The package name of the peer module.
  279. */
  280. package: string;
  281. /**
  282. * The directory path of the peer module.
  283. * @default 'components'
  284. */
  285. path?: string;
  286. /**
  287. * The file name template for the peer module.
  288. * @default '{module}.css'
  289. */
  290. fileName?: `${string}{module}${string}`;
  291. /**
  292. * The text transform to be applied to the '{module}' part of the file name.
  293. * @default 'kebab-case'
  294. */
  295. transform?: 'kebab-case' | 'camelCase' | 'PascalCase' | false;
  296. }
  297. type SupportedLocale = 'en-US' | 'zh-Hans';
  298. interface VeuiResolverOptions {
  299. /**
  300. * The alias of 'veui` package.
  301. * @default 'veui'
  302. */
  303. alias?: string;
  304. /**
  305. * Peer modules to be injected.
  306. */
  307. modules?: VeuiPeerConfig[];
  308. /**
  309. * Locale modules to be injected.
  310. * @default 'zh-Hans'
  311. */
  312. locale?: SupportedLocale | SupportedLocale[] | false;
  313. /**
  314. * Global modules to be injected to all components.
  315. * @default []
  316. */
  317. global?: string[];
  318. }
  319. /**
  320. * Resolver for VEUI
  321. *
  322. * @link https://github.com/ecomfe/veui
  323. */
  324. declare function VeuiResolver(options?: VeuiResolverOptions): ComponentResolver;
  325. /**
  326. * Resolver for View UI
  327. * @requires @originjs/vite-plugin-commonjs
  328. * @author @nabaonan
  329. * @link https://www.iviewui.com/
  330. * @description has known problems list below
  331. * - select component render error PR: https://github.com/view-design/ViewUI/pull/944, choose can't display value,because click option trigger twice,at second time,select value turn into undefined.
  332. * - scroll component has a template syntax called lang='html',it is require html-loader,but vite plugin not support yet,remove it can run. relate pr: https://github.com/view-design/ViewUI/pull/985
  333. */
  334. declare function ViewUiResolver(): ComponentResolver;
  335. /**
  336. * Resolver for Vuetify
  337. *
  338. * @link https://github.com/vuetifyjs/vuetify
  339. */
  340. declare function VuetifyResolver(): ComponentResolver;
  341. /**
  342. * Resolver for Vuetify 3 Beta
  343. *
  344. * @link https://github.com/vuetifyjs/vuetify
  345. */
  346. declare function Vuetify3Resolver(): ComponentResolver;
  347. /**
  348. * Resolver for VueUse
  349. *
  350. * @link https://github.com/vueuse/vueuse
  351. */
  352. declare function VueUseComponentsResolver(): ComponentResolver;
  353. /**
  354. * Resolver for VueUse
  355. *
  356. * @link https://github.com/vueuse/vueuse
  357. */
  358. declare function VueUseDirectiveResolver(): ComponentResolver;
  359. /**
  360. * Resolver for Quasar
  361. *
  362. * @link https://github.com/quasarframework/quasar
  363. */
  364. declare function QuasarResolver(): ComponentResolver;
  365. interface DevResolverOptions {
  366. /**
  367. * bring in components and styles
  368. *
  369. * @default true
  370. */
  371. importStyle?: boolean;
  372. /**
  373. * auto import for directives
  374. *
  375. * @default true
  376. */
  377. directives?: boolean;
  378. /**
  379. * use umd lib file
  380. */
  381. ssr?: boolean;
  382. }
  383. declare function DevUiResolver(options?: DevResolverOptions): ComponentResolver[];
  384. type DisallowResolveIconOption = undefined | false | {
  385. enable: false;
  386. };
  387. type AllowResolveIconOption = true | {
  388. enable: true;
  389. iconPrefix?: string;
  390. };
  391. type ResolveIconsOption = DisallowResolveIconOption | AllowResolveIconOption;
  392. interface ArcoResolverOptions {
  393. /**
  394. * exclude components that do not require automatic import
  395. *
  396. * @default []
  397. */
  398. exclude?: string | RegExp | (string | RegExp)[];
  399. /**
  400. * import style css or less with components
  401. *
  402. * @default 'css'
  403. */
  404. importStyle?: boolean | 'css' | 'less';
  405. /**
  406. * resolve icons
  407. *
  408. * @default false
  409. */
  410. resolveIcons?: ResolveIconsOption;
  411. /**
  412. * Control style automatic import
  413. *
  414. * @default true
  415. */
  416. sideEffect?: boolean;
  417. }
  418. /**
  419. * Resolver for Arco Design Vue
  420. *
  421. * Requires arco-design/web-vue@2.11.0 or later
  422. *
  423. * @author @flsion
  424. * @link https://arco.design/ for arco-design
  425. *
  426. */
  427. declare function ArcoResolver(options?: ArcoResolverOptions): ComponentResolver;
  428. interface TDesignResolverOptions {
  429. /**
  430. * select the specified library
  431. * @default 'vue'
  432. */
  433. library?: 'vue' | 'vue-next' | 'react' | 'mobile-vue' | 'mobile-react';
  434. /**
  435. * resolve `tdesign-icons'
  436. * @default false
  437. */
  438. resolveIcons?: boolean;
  439. /**
  440. * whether to import ESM version
  441. * @default false
  442. */
  443. esm?: boolean;
  444. /**
  445. * exclude component name, if match do not resolve the name
  446. *
  447. */
  448. exclude?: string | RegExp | (string | RegExp)[];
  449. }
  450. declare function TDesignResolver(options?: TDesignResolverOptions): ComponentResolver;
  451. interface LayuiVueResolverOptions {
  452. /**
  453. * import style along with components
  454. *
  455. * @default 'css'
  456. */
  457. importStyle?: boolean | 'css';
  458. /**
  459. * resolve '@layui/layui-vue' icons
  460. * requires package `@layui/icons-vue`
  461. *
  462. * @default false
  463. */
  464. resolveIcons?: boolean;
  465. /**
  466. * exclude components that do not require automatic import
  467. *
  468. */
  469. exclude?: Array<string | RegExp>;
  470. }
  471. /**
  472. * Resolver for layui-vue
  473. *
  474. * @link http://www.layui-vue.com/ for layui-vue
  475. *
  476. */
  477. declare function LayuiVueResolver(options?: LayuiVueResolverOptions): ComponentResolver;
  478. interface BootstrapVueResolverOptions {
  479. /**
  480. * Auto import for directives.
  481. *
  482. * @default true
  483. */
  484. directives?: boolean;
  485. }
  486. /**
  487. * Resolver for BootstrapVue
  488. *
  489. * @link https://github.com/bootstrap-vue/bootstrap-vue
  490. */
  491. declare function BootstrapVueResolver(_options?: BootstrapVueResolverOptions): ComponentResolver[];
  492. /**
  493. * Resolver for BootstrapVueNext
  494. *
  495. * @link https://github.com/bootstrap-vue/bootstrap-vue-next
  496. */
  497. declare function BootstrapVueNextResolver(_options?: BootstrapVueResolverOptions): Array<ComponentResolver>;
  498. /**
  499. * Resolver for legacy BootstrapVue3 apps
  500. *
  501. * @deprecated use BootstrapVueNextResolver with https://github.com/bootstrap-vue/bootstrap-vue-next
  502. * @link https://www.npmjs.com/package/bootstrap-vue-3
  503. */
  504. declare function BootstrapVue3Resolver(_options?: BootstrapVueResolverOptions): Array<ComponentResolver>;
  505. /**
  506. * source: https://github.com/nuxt-modules/ionic/blob/main/src/imports.ts
  507. * @author @danielroe
  508. */
  509. declare const IonicBuiltInComponents: string[];
  510. /**
  511. * Resolver for ionic framework
  512. *
  513. * @author @mathsgod @reslear
  514. * @link https://ionicframework.com/
  515. */
  516. declare function IonicResolver(): ComponentResolver;
  517. export { AllowResolveIconOption, AntDesignVueResolver, AntDesignVueResolverOptions, ArcoResolver, ArcoResolverOptions, BootstrapVue3Resolver, BootstrapVueNextResolver, BootstrapVueResolver, BootstrapVueResolverOptions, DevResolverOptions, DevUiResolver, DisallowResolveIconOption, ElementPlusResolver, ElementPlusResolverOptions, ElementUiResolver, ElementUiResolverOptions, HeadlessUiResolver, HeadlessUiResolverOptions, IduxResolver, IduxResolverOptions, InklineResolver, IonicBuiltInComponents, IonicResolver, LayuiVueResolver, LayuiVueResolverOptions, NaiveUiResolver, PrimeVueResolver, PrimeVueResolverOptions, QuasarResolver, ResolveIconsOption, TDesignResolver, TDesignResolverOptions, VantResolver, VantResolverOptions, VarletUIResolver, VarletUIResolverOptions, VeuiResolver, VeuiResolverOptions, ViewUiResolver, VueUseComponentsResolver, VueUseDirectiveResolver, Vuetify3Resolver, VuetifyResolver, getResolved };