resolvers.d.ts 13 KB

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