unplugin-vue-components 0.17.15 → 0.17.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -108,7 +108,7 @@ function parseDeclaration(code) {
108
108
  return {};
109
109
  return Object.fromEntries(Array.from(code.matchAll(/(?<!\/\/)\s+\s+['"]?(.+?)['"]?:\s(.+?)\n/g)).map((i) => [i[1], i[2]]));
110
110
  }
111
- async function generateDeclaration(ctx, root, filepath) {
111
+ async function generateDeclaration(ctx, root, filepath, removeUnused = false) {
112
112
  const imports = Object.fromEntries(Object.values(_chunkHIJQIC5Vjs.__spreadValues.call(void 0, _chunkHIJQIC5Vjs.__spreadValues.call(void 0, {}, ctx.componentNameMap), ctx.componentCustomMap)).map(({ path, name, importName }) => {
113
113
  if (!name)
114
114
  return void 0;
@@ -125,7 +125,7 @@ async function generateDeclaration(ctx, root, filepath) {
125
125
  return;
126
126
  const originalContent = _fs.existsSync.call(void 0, filepath) ? await _fs.promises.readFile(filepath, "utf-8") : "";
127
127
  const originalImports = parseDeclaration(originalContent);
128
- const lines = Object.entries(_chunkHIJQIC5Vjs.__spreadValues.call(void 0, _chunkHIJQIC5Vjs.__spreadValues.call(void 0, {}, originalImports), imports)).sort((a, b) => a[0].localeCompare(b[0])).filter(([name]) => ctx.componentCustomMap[name] || ctx.componentNameMap[name]).map(([name, v]) => {
128
+ const lines = Object.entries(_chunkHIJQIC5Vjs.__spreadValues.call(void 0, _chunkHIJQIC5Vjs.__spreadValues.call(void 0, {}, originalImports), imports)).sort((a, b) => a[0].localeCompare(b[0])).filter(([name]) => removeUnused ? ctx.componentCustomMap[name] || ctx.componentNameMap[name] : true).map(([name, v]) => {
129
129
  if (!/^\w+$/.test(name))
130
130
  name = `'${name}'`;
131
131
  return `${name}: ${v}`;
@@ -232,7 +232,7 @@ async function resolveVue22(code, s) {
232
232
  const results = [];
233
233
  for (const node of nodes) {
234
234
  const { callee, arguments: args } = node;
235
- if (callee.type !== "Identifier" || callee.name !== "_c" || args[1].type !== "ObjectExpression")
235
+ if (callee.type !== "Identifier" || callee.name !== "_c" || args[1] == null || args[1].type !== "ObjectExpression")
236
236
  continue;
237
237
  const directives = (_a = args[1].properties.find((property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives")) == null ? void 0 : _a.value;
238
238
  if (!directives || directives.type !== "ArrayExpression")
@@ -366,12 +366,14 @@ var Context = class {
366
366
  watcher.on("unlink", (path) => {
367
367
  if (!_chunk42OWKG5Wjs.matchGlobs.call(void 0, path, globs))
368
368
  return;
369
+ path = _utils.slash.call(void 0, path);
369
370
  this.removeComponents(path);
370
371
  this.onUpdate(path);
371
372
  });
372
373
  watcher.on("add", (path) => {
373
374
  if (!_chunk42OWKG5Wjs.matchGlobs.call(void 0, path, globs))
374
375
  return;
376
+ path = _utils.slash.call(void 0, path);
375
377
  this.addComponents(path);
376
378
  this.onUpdate(path);
377
379
  });
@@ -492,7 +494,7 @@ var Context = class {
492
494
  if (!this.options.dts)
493
495
  return;
494
496
  debug5.decleration("generating");
495
- generateDeclaration(this, this.options.root, this.options.dts);
497
+ generateDeclaration(this, this.options.root, this.options.dts, !this._server);
496
498
  }
497
499
  get componentNameMap() {
498
500
  return this._componentNameMap;
@@ -108,7 +108,7 @@ function parseDeclaration(code) {
108
108
  return {};
109
109
  return Object.fromEntries(Array.from(code.matchAll(/(?<!\/\/)\s+\s+['"]?(.+?)['"]?:\s(.+?)\n/g)).map((i) => [i[1], i[2]]));
110
110
  }
111
- async function generateDeclaration(ctx, root, filepath) {
111
+ async function generateDeclaration(ctx, root, filepath, removeUnused = false) {
112
112
  const imports = Object.fromEntries(Object.values(__spreadValues(__spreadValues({}, ctx.componentNameMap), ctx.componentCustomMap)).map(({ path, name, importName }) => {
113
113
  if (!name)
114
114
  return void 0;
@@ -125,7 +125,7 @@ async function generateDeclaration(ctx, root, filepath) {
125
125
  return;
126
126
  const originalContent = existsSync(filepath) ? await fs.readFile(filepath, "utf-8") : "";
127
127
  const originalImports = parseDeclaration(originalContent);
128
- const lines = Object.entries(__spreadValues(__spreadValues({}, originalImports), imports)).sort((a, b) => a[0].localeCompare(b[0])).filter(([name]) => ctx.componentCustomMap[name] || ctx.componentNameMap[name]).map(([name, v]) => {
128
+ const lines = Object.entries(__spreadValues(__spreadValues({}, originalImports), imports)).sort((a, b) => a[0].localeCompare(b[0])).filter(([name]) => removeUnused ? ctx.componentCustomMap[name] || ctx.componentNameMap[name] : true).map(([name, v]) => {
129
129
  if (!/^\w+$/.test(name))
130
130
  name = `'${name}'`;
131
131
  return `${name}: ${v}`;
@@ -232,7 +232,7 @@ async function resolveVue22(code, s) {
232
232
  const results = [];
233
233
  for (const node of nodes) {
234
234
  const { callee, arguments: args } = node;
235
- if (callee.type !== "Identifier" || callee.name !== "_c" || args[1].type !== "ObjectExpression")
235
+ if (callee.type !== "Identifier" || callee.name !== "_c" || args[1] == null || args[1].type !== "ObjectExpression")
236
236
  continue;
237
237
  const directives = (_a = args[1].properties.find((property) => property.type === "ObjectProperty" && property.key.type === "Identifier" && property.key.name === "directives")) == null ? void 0 : _a.value;
238
238
  if (!directives || directives.type !== "ArrayExpression")
@@ -366,12 +366,14 @@ var Context = class {
366
366
  watcher.on("unlink", (path) => {
367
367
  if (!matchGlobs(path, globs))
368
368
  return;
369
+ path = slash3(path);
369
370
  this.removeComponents(path);
370
371
  this.onUpdate(path);
371
372
  });
372
373
  watcher.on("add", (path) => {
373
374
  if (!matchGlobs(path, globs))
374
375
  return;
376
+ path = slash3(path);
375
377
  this.addComponents(path);
376
378
  this.onUpdate(path);
377
379
  });
@@ -492,7 +494,7 @@ var Context = class {
492
494
  if (!this.options.dts)
493
495
  return;
494
496
  debug5.decleration("generating");
495
- generateDeclaration(this, this.options.root, this.options.dts);
497
+ generateDeclaration(this, this.options.root, this.options.dts, !this._server);
496
498
  }
497
499
  get componentNameMap() {
498
500
  return this._componentNameMap;
package/dist/esbuild.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPBOKHWI5js = require('./chunk-PBOKHWI5.js');
3
+ var _chunk3EFXRPH2js = require('./chunk-3EFXRPH2.js');
4
4
  require('./chunk-42OWKG5W.js');
5
5
  require('./chunk-GGNOJ77I.js');
6
6
  require('./chunk-HIJQIC5V.js');
7
7
 
8
8
  // src/esbuild.ts
9
- var esbuild_default = _chunkPBOKHWI5js.unplugin_default.esbuild;
9
+ var esbuild_default = _chunk3EFXRPH2js.unplugin_default.esbuild;
10
10
 
11
11
 
12
12
  module.exports = esbuild_default;
package/dist/esbuild.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-KCFA67G3.mjs";
3
+ } from "./chunk-QJTINFQL.mjs";
4
4
  import "./chunk-V5TNASXD.mjs";
5
5
  import "./chunk-WBQAMGXK.mjs";
6
6
  import "./chunk-EKXJN6YJ.mjs";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPBOKHWI5js = require('./chunk-PBOKHWI5.js');
3
+ var _chunk3EFXRPH2js = require('./chunk-3EFXRPH2.js');
4
4
 
5
5
 
6
6
 
@@ -13,4 +13,4 @@ require('./chunk-HIJQIC5V.js');
13
13
 
14
14
 
15
15
 
16
- exports.camelCase = _chunk42OWKG5Wjs.camelCase; exports.default = _chunkPBOKHWI5js.unplugin_default; exports.kebabCase = _chunk42OWKG5Wjs.kebabCase; exports.pascalCase = _chunk42OWKG5Wjs.pascalCase;
16
+ exports.camelCase = _chunk42OWKG5Wjs.camelCase; exports.default = _chunk3EFXRPH2js.unplugin_default; exports.kebabCase = _chunk42OWKG5Wjs.kebabCase; exports.pascalCase = _chunk42OWKG5Wjs.pascalCase;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-KCFA67G3.mjs";
3
+ } from "./chunk-QJTINFQL.mjs";
4
4
  import {
5
5
  camelCase,
6
6
  kebabCase,
package/dist/nuxt.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPBOKHWI5js = require('./chunk-PBOKHWI5.js');
3
+ var _chunk3EFXRPH2js = require('./chunk-3EFXRPH2.js');
4
4
  require('./chunk-42OWKG5W.js');
5
5
  require('./chunk-GGNOJ77I.js');
6
6
  require('./chunk-HIJQIC5V.js');
@@ -9,11 +9,11 @@ require('./chunk-HIJQIC5V.js');
9
9
  function nuxt_default(options) {
10
10
  this.extendBuild((config) => {
11
11
  config.plugins = config.plugins || [];
12
- config.plugins.unshift(_chunkPBOKHWI5js.unplugin_default.webpack(options));
12
+ config.plugins.unshift(_chunk3EFXRPH2js.unplugin_default.webpack(options));
13
13
  });
14
14
  this.nuxt.hook("vite:extend", async (vite) => {
15
15
  vite.config.plugins = vite.config.plugins || [];
16
- vite.config.plugins.push(_chunkPBOKHWI5js.unplugin_default.vite(options));
16
+ vite.config.plugins.push(_chunk3EFXRPH2js.unplugin_default.vite(options));
17
17
  });
18
18
  }
19
19
 
package/dist/nuxt.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-KCFA67G3.mjs";
3
+ } from "./chunk-QJTINFQL.mjs";
4
4
  import "./chunk-V5TNASXD.mjs";
5
5
  import "./chunk-WBQAMGXK.mjs";
6
6
  import "./chunk-EKXJN6YJ.mjs";
package/dist/resolvers.js CHANGED
@@ -1582,7 +1582,7 @@ function ElementUiResolver(options = {}) {
1582
1582
  return {
1583
1583
  type: "component",
1584
1584
  resolve: (name) => {
1585
- if (name.startsWith("El")) {
1585
+ if (/^El[A-Z]/.test(name)) {
1586
1586
  const compName = name.slice(2);
1587
1587
  const partialName = _chunk42OWKG5Wjs.kebabCase.call(void 0, compName);
1588
1588
  if (partialName === "collapse-transition") {
@@ -2282,8 +2282,26 @@ function getSideEffects8(importName, options) {
2282
2282
  return;
2283
2283
  if (fileName === "config-provider")
2284
2284
  return;
2285
- if (fileName === "radio-group" || fileName === "radio-button")
2286
- fileName = "radio";
2285
+ if (fileName.includes("-") && fileName !== "input-number") {
2286
+ const prefix2 = fileName.slice(0, fileName.indexOf("-"));
2287
+ const container = ["anchor", "avatar", "breadcrumb", "checkbox", "dropdown", "form", "input", "list", "menu", "radio", "slider", "steps", "swiper"];
2288
+ if (container.includes(prefix2))
2289
+ fileName = prefix2;
2290
+ }
2291
+ if (["row", "col"].includes(fileName))
2292
+ fileName = "grid";
2293
+ if (fileName === "addon")
2294
+ fileName = "input";
2295
+ if (["aside", "layout", "header", "footer", "content"].includes(fileName))
2296
+ fileName = "layout";
2297
+ if (["option", "option-group"].includes(fileName))
2298
+ fileName = "select";
2299
+ if (["tab-nav", "tab-panel"].includes(fileName))
2300
+ fileName = "tabs";
2301
+ if (fileName === "check-tag")
2302
+ fileName = "tag";
2303
+ if (fileName === "time-range-picker")
2304
+ fileName = "time-picker";
2287
2305
  if (importStyle === "less")
2288
2306
  return `tdesign-${library}/esm/${fileName}/style`;
2289
2307
  return `tdesign-${library}/es/${fileName}/style`;
@@ -1582,7 +1582,7 @@ function ElementUiResolver(options = {}) {
1582
1582
  return {
1583
1583
  type: "component",
1584
1584
  resolve: (name) => {
1585
- if (name.startsWith("El")) {
1585
+ if (/^El[A-Z]/.test(name)) {
1586
1586
  const compName = name.slice(2);
1587
1587
  const partialName = kebabCase(compName);
1588
1588
  if (partialName === "collapse-transition") {
@@ -2282,8 +2282,26 @@ function getSideEffects8(importName, options) {
2282
2282
  return;
2283
2283
  if (fileName === "config-provider")
2284
2284
  return;
2285
- if (fileName === "radio-group" || fileName === "radio-button")
2286
- fileName = "radio";
2285
+ if (fileName.includes("-") && fileName !== "input-number") {
2286
+ const prefix2 = fileName.slice(0, fileName.indexOf("-"));
2287
+ const container = ["anchor", "avatar", "breadcrumb", "checkbox", "dropdown", "form", "input", "list", "menu", "radio", "slider", "steps", "swiper"];
2288
+ if (container.includes(prefix2))
2289
+ fileName = prefix2;
2290
+ }
2291
+ if (["row", "col"].includes(fileName))
2292
+ fileName = "grid";
2293
+ if (fileName === "addon")
2294
+ fileName = "input";
2295
+ if (["aside", "layout", "header", "footer", "content"].includes(fileName))
2296
+ fileName = "layout";
2297
+ if (["option", "option-group"].includes(fileName))
2298
+ fileName = "select";
2299
+ if (["tab-nav", "tab-panel"].includes(fileName))
2300
+ fileName = "tabs";
2301
+ if (fileName === "check-tag")
2302
+ fileName = "tag";
2303
+ if (fileName === "time-range-picker")
2304
+ fileName = "time-picker";
2287
2305
  if (importStyle === "less")
2288
2306
  return `tdesign-${library}/esm/${fileName}/style`;
2289
2307
  return `tdesign-${library}/es/${fileName}/style`;
package/dist/rollup.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPBOKHWI5js = require('./chunk-PBOKHWI5.js');
3
+ var _chunk3EFXRPH2js = require('./chunk-3EFXRPH2.js');
4
4
  require('./chunk-42OWKG5W.js');
5
5
  require('./chunk-GGNOJ77I.js');
6
6
  require('./chunk-HIJQIC5V.js');
7
7
 
8
8
  // src/rollup.ts
9
- var rollup_default = _chunkPBOKHWI5js.unplugin_default.rollup;
9
+ var rollup_default = _chunk3EFXRPH2js.unplugin_default.rollup;
10
10
 
11
11
 
12
12
  module.exports = rollup_default;
package/dist/rollup.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-KCFA67G3.mjs";
3
+ } from "./chunk-QJTINFQL.mjs";
4
4
  import "./chunk-V5TNASXD.mjs";
5
5
  import "./chunk-WBQAMGXK.mjs";
6
6
  import "./chunk-EKXJN6YJ.mjs";
package/dist/vite.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPBOKHWI5js = require('./chunk-PBOKHWI5.js');
3
+ var _chunk3EFXRPH2js = require('./chunk-3EFXRPH2.js');
4
4
  require('./chunk-42OWKG5W.js');
5
5
  require('./chunk-GGNOJ77I.js');
6
6
  require('./chunk-HIJQIC5V.js');
7
7
 
8
8
  // src/vite.ts
9
- var vite_default = _chunkPBOKHWI5js.unplugin_default.vite;
9
+ var vite_default = _chunk3EFXRPH2js.unplugin_default.vite;
10
10
 
11
11
 
12
12
  module.exports = vite_default;
package/dist/vite.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-KCFA67G3.mjs";
3
+ } from "./chunk-QJTINFQL.mjs";
4
4
  import "./chunk-V5TNASXD.mjs";
5
5
  import "./chunk-WBQAMGXK.mjs";
6
6
  import "./chunk-EKXJN6YJ.mjs";
package/dist/webpack.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPBOKHWI5js = require('./chunk-PBOKHWI5.js');
3
+ var _chunk3EFXRPH2js = require('./chunk-3EFXRPH2.js');
4
4
  require('./chunk-42OWKG5W.js');
5
5
  require('./chunk-GGNOJ77I.js');
6
6
  require('./chunk-HIJQIC5V.js');
7
7
 
8
8
  // src/webpack.ts
9
- var webpack_default = _chunkPBOKHWI5js.unplugin_default.webpack;
9
+ var webpack_default = _chunk3EFXRPH2js.unplugin_default.webpack;
10
10
 
11
11
 
12
12
  module.exports = webpack_default;
package/dist/webpack.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-KCFA67G3.mjs";
3
+ } from "./chunk-QJTINFQL.mjs";
4
4
  import "./chunk-V5TNASXD.mjs";
5
5
  import "./chunk-WBQAMGXK.mjs";
6
6
  import "./chunk-EKXJN6YJ.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-vue-components",
3
- "version": "0.17.15",
3
+ "version": "0.17.19",
4
4
  "description": "Components auto importing for Vue",
5
5
  "homepage": "https://github.com/antfu/unplugin-vue-components",
6
6
  "bugs": "https://github.com/antfu/unplugin-vue-components/issues",