unplugin-vue-components 0.22.8 → 0.22.11

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.
package/README.md CHANGED
@@ -284,7 +284,7 @@ Components({
284
284
  }
285
285
  ```
286
286
 
287
- `vite.config.json`
287
+ `vite.config.js`
288
288
 
289
289
  ```diff
290
290
  - import Components, { ElementPlusResolver } from 'vite-plugin-components'
@@ -357,6 +357,10 @@ Components({
357
357
  // filters for transforming targets
358
358
  include: [/\.vue$/, /\.vue\?vue/],
359
359
  exclude: [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/],
360
+
361
+ // Vue version of project. It will detect automatically if not specified.
362
+ // Acceptable value: 2 | 2.7 | 3
363
+ version: 2.7
360
364
  })
361
365
  ```
362
366
 
@@ -0,0 +1,32 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
21
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
22
+ }) : x)(function(x) {
23
+ if (typeof require !== "undefined")
24
+ return require.apply(this, arguments);
25
+ throw new Error('Dynamic require of "' + x + '" is not supported');
26
+ });
27
+
28
+
29
+
30
+
31
+
32
+ exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__require = __require;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/core/utils.ts
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/core/utils.ts
2
2
  var _path = require('path');
3
3
  var _minimatch = require('minimatch'); var _minimatch2 = _interopRequireDefault(_minimatch);
4
4
  var _resolve = require('resolve'); var _resolve2 = _interopRequireDefault(_resolve);
@@ -109,7 +109,7 @@ function getNameFromFilePath(filePath, options) {
109
109
  if (directoryAsNamespace) {
110
110
  if (globalNamespaces.some((name) => folders.includes(name)))
111
111
  folders = folders.filter((f) => !globalNamespaces.includes(f));
112
- folders = folders.map((f) => f.replace(/[^a-zA-Z0-9]/g, ""));
112
+ folders = folders.map((f) => f.replace(/[^a-zA-Z0-9\-]/g, ""));
113
113
  if (filename.toLowerCase() === "index")
114
114
  filename = "";
115
115
  if (!isEmpty(folders)) {
@@ -142,11 +142,12 @@ function resolveAlias(filepath, alias) {
142
142
  return result;
143
143
  }
144
144
  async function getPkgVersion(pkgName, defaultVersion) {
145
+ var _a;
145
146
  try {
146
147
  const isExist = _localpkg.isPackageExists.call(void 0, pkgName);
147
148
  if (isExist) {
148
149
  const pkg = await _localpkg.getPackageInfo.call(void 0, pkgName);
149
- return _nullishCoalesce((pkg == null ? void 0 : pkg.version), () => ( defaultVersion));
150
+ return (_a = pkg == null ? void 0 : pkg.version) != null ? _a : defaultVersion;
150
151
  } else {
151
152
  return defaultVersion;
152
153
  }
@@ -10,7 +10,11 @@ import {
10
10
  resolveAlias,
11
11
  shouldTransform,
12
12
  stringifyComponentImport
13
- } from "./chunk-T47CWWYC.mjs";
13
+ } from "./chunk-KWXXDT62.mjs";
14
+ import {
15
+ __spreadProps,
16
+ __spreadValues
17
+ } from "./chunk-ZKNUHGJ4.mjs";
14
18
 
15
19
  // src/core/unplugin.ts
16
20
  import { existsSync as existsSync2 } from "fs";
@@ -75,6 +79,7 @@ function normalizeResolvers(resolvers) {
75
79
  return toArray(resolvers).flat().map((r) => typeof r === "function" ? { resolve: r, type: "component" } : r);
76
80
  }
77
81
  function resolveOptions(options, root) {
82
+ var _a;
78
83
  const resolved = Object.assign({}, defaultOptions, options);
79
84
  resolved.resolvers = normalizeResolvers(resolved.resolvers);
80
85
  resolved.extensions = toArray(resolved.extensions);
@@ -99,14 +104,22 @@ function resolveOptions(options, root) {
99
104
  resolved.types = detectTypeImports();
100
105
  resolved.types = resolved.types || [];
101
106
  resolved.root = root;
102
- resolved.transformer = options.transformer || getVueVersion(root) || "vue3";
103
- resolved.directives = typeof options.directives === "boolean" ? options.directives : !resolved.resolvers.some((i) => i.type === "directive") ? false : getVueVersion(root) === "vue3";
107
+ resolved.version = (_a = resolved.version) != null ? _a : getVueVersion(root);
108
+ if (resolved.version < 2 || resolved.version >= 4)
109
+ throw new Error(`[unplugin-vue-components] unsupported version: ${resolved.version}`);
110
+ resolved.transformer = options.transformer || `vue${Math.trunc(resolved.version)}`;
111
+ resolved.directives = typeof options.directives === "boolean" ? options.directives : !resolved.resolvers.some((i) => i.type === "directive") ? false : resolved.version >= 3;
104
112
  return resolved;
105
113
  }
106
114
  function getVueVersion(root) {
107
115
  var _a;
108
- const version = ((_a = getPackageInfoSync("vue", { paths: [root] })) == null ? void 0 : _a.version) || "3";
109
- return version.startsWith("2.") ? "vue2" : "vue3";
116
+ const raw = ((_a = getPackageInfoSync("vue", { paths: [root] })) == null ? void 0 : _a.version) || "3";
117
+ const version = +raw.split(".").slice(0, 2).join(".");
118
+ if (version === 2.7)
119
+ return 2.7;
120
+ else if (version < 2.7)
121
+ return 2;
122
+ return 3;
110
123
  }
111
124
 
112
125
  // src/core/fs/glob.ts
@@ -134,7 +147,7 @@ import { dirname, isAbsolute, relative } from "path";
134
147
  import { existsSync } from "fs";
135
148
  import { readFile, writeFile } from "fs/promises";
136
149
  import { notNullish as notNullish2, slash as slash2 } from "@antfu/utils";
137
- var multilineCommentsRE = /\/\*.*?\*\//gms;
150
+ var multilineCommentsRE = new RegExp("\\/\\*.*?\\*\\/", "gms");
138
151
  var singlelineCommentsRE = /\/\/.*$/gm;
139
152
  function extractImports(code) {
140
153
  return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\n]/g)).map((i) => [i[1], i[2]]));
@@ -148,10 +161,10 @@ function parseDeclaration(code) {
148
161
  component: {},
149
162
  directive: {}
150
163
  };
151
- const componentDeclaration = (_a = /export\s+interface\s+GlobalComponents\s*{(.*?)}/s.exec(code)) == null ? void 0 : _a[0];
164
+ const componentDeclaration = (_a = new RegExp("export\\s+interface\\s+GlobalComponents\\s*{(.*?)}", "s").exec(code)) == null ? void 0 : _a[0];
152
165
  if (componentDeclaration)
153
166
  imports.component = extractImports(componentDeclaration);
154
- const directiveDeclaration = (_b = /export\s+interface\s+ComponentCustomProperties\s*{(.*?)}/s.exec(code)) == null ? void 0 : _b[0];
167
+ const directiveDeclaration = (_b = new RegExp("export\\s+interface\\s+ComponentCustomProperties\\s*{(.*?)}", "s").exec(code)) == null ? void 0 : _b[0];
155
168
  if (directiveDeclaration)
156
169
  imports.directive = extractImports(directiveDeclaration);
157
170
  return imports;
@@ -171,10 +184,7 @@ function stringifyComponentsInfo(filepath, components, importPathTransform) {
171
184
  }
172
185
  function getDeclarationImports(ctx, filepath) {
173
186
  const component = stringifyComponentsInfo(filepath, [
174
- ...Object.values({
175
- ...ctx.componentNameMap,
176
- ...ctx.componentCustomMap
177
- }),
187
+ ...Object.values(__spreadValues(__spreadValues({}, ctx.componentNameMap), ctx.componentCustomMap)),
178
188
  ...resolveTypeImports(ctx.options.types)
179
189
  ], ctx.options.importPathTransform);
180
190
  const directive = stringifyComponentsInfo(
@@ -198,17 +208,20 @@ function getDeclaration(ctx, filepath, originalImports) {
198
208
  if (!imports)
199
209
  return;
200
210
  const declarations = {
201
- component: stringifyDeclarationImports({ ...originalImports == null ? void 0 : originalImports.component, ...imports.component }),
202
- directive: stringifyDeclarationImports({ ...originalImports == null ? void 0 : originalImports.directive, ...imports.directive })
211
+ component: stringifyDeclarationImports(__spreadValues(__spreadValues({}, originalImports == null ? void 0 : originalImports.component), imports.component)),
212
+ directive: stringifyDeclarationImports(__spreadValues(__spreadValues({}, originalImports == null ? void 0 : originalImports.directive), imports.directive))
203
213
  };
204
- let code = `// generated by unplugin-vue-components
205
- // We suggest you to commit this file into source control
206
- // Read more: https://github.com/vuejs/core/pull/3399
207
- import '@vue/runtime-core'
214
+ const head = ctx.options.version === 2.7 ? `export {}
215
+
216
+ declare module 'vue' {` : `import '@vue/runtime-core'
208
217
 
209
218
  export {}
210
219
 
211
220
  declare module '@vue/runtime-core' {`;
221
+ let code = `// generated by unplugin-vue-components
222
+ // We suggest you to commit this file into source control
223
+ // Read more: https://github.com/vuejs/core/pull/3399
224
+ ${head}`;
212
225
  if (Object.keys(declarations.component).length > 0) {
213
226
  code += `
214
227
  export interface GlobalComponents {
@@ -281,7 +294,7 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
281
294
  const component = await ctx.findComponent(name, "component", [sfcPath]);
282
295
  if (component) {
283
296
  const varName = `__unplugin_components_${no}`;
284
- s.prepend(`${stringifyComponentImport({ ...component, as: varName }, ctx)};
297
+ s.prepend(`${stringifyComponentImport(__spreadProps(__spreadValues({}, component), { as: varName }), ctx)};
285
298
  `);
286
299
  no += 1;
287
300
  replace(varName);
@@ -314,7 +327,7 @@ async function resolveVue22(code, s) {
314
327
  sourceType: "module"
315
328
  });
316
329
  const nodes = [];
317
- const { walk } = await import("./src-Z5BCFXFD.mjs");
330
+ const { walk } = await import("./src-WRIQ2NEL.mjs");
318
331
  walk(program, {
319
332
  enter(node) {
320
333
  if (node.type === "CallExpression")
@@ -392,7 +405,7 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
392
405
  if (!directive)
393
406
  continue;
394
407
  const varName = `__unplugin_directives_${no}`;
395
- s.prepend(`${stringifyComponentImport({ ...directive, as: varName }, ctx)};
408
+ s.prepend(`${stringifyComponentImport(__spreadProps(__spreadValues({}, directive), { as: varName }), ctx)};
396
409
  `);
397
410
  no += 1;
398
411
  replace(varName);
@@ -441,7 +454,7 @@ var Context = class {
441
454
  this.alias = {};
442
455
  this._searched = false;
443
456
  this.options = resolveOptions(rawOptions, this.root);
444
- this.generateDeclaration = throttle(500, false, this._generateDeclaration.bind(this));
457
+ this.generateDeclaration = throttle(500, this._generateDeclaration.bind(this), { noLeading: false });
445
458
  this.setTransformer(this.options.transformer);
446
459
  }
447
460
  setRoot(root) {
@@ -588,10 +601,9 @@ var Context = class {
588
601
  from: result
589
602
  };
590
603
  } else {
591
- info = {
592
- as: name,
593
- ...normalizeComponetInfo(result)
594
- };
604
+ info = __spreadValues({
605
+ as: name
606
+ }, normalizeComponetInfo(result));
595
607
  }
596
608
  if (type === "component")
597
609
  this.addCustomComponents(info);
@@ -10,7 +10,11 @@
10
10
 
11
11
 
12
12
 
13
- var _chunk5HMJAJIKjs = require('./chunk-5HMJAJIK.js');
13
+ var _chunkDLADAJMIjs = require('./chunk-DLADAJMI.js');
14
+
15
+
16
+
17
+ var _chunkBTQOTIPQjs = require('./chunk-BTQOTIPQ.js');
14
18
 
15
19
  // src/core/unplugin.ts
16
20
  var _fs = require('fs');
@@ -75,6 +79,7 @@ function normalizeResolvers(resolvers) {
75
79
  return _utils.toArray.call(void 0, resolvers).flat().map((r) => typeof r === "function" ? { resolve: r, type: "component" } : r);
76
80
  }
77
81
  function resolveOptions(options, root) {
82
+ var _a;
78
83
  const resolved = Object.assign({}, defaultOptions, options);
79
84
  resolved.resolvers = normalizeResolvers(resolved.resolvers);
80
85
  resolved.extensions = _utils.toArray.call(void 0, resolved.extensions);
@@ -99,14 +104,22 @@ function resolveOptions(options, root) {
99
104
  resolved.types = detectTypeImports();
100
105
  resolved.types = resolved.types || [];
101
106
  resolved.root = root;
102
- resolved.transformer = options.transformer || getVueVersion(root) || "vue3";
103
- resolved.directives = typeof options.directives === "boolean" ? options.directives : !resolved.resolvers.some((i) => i.type === "directive") ? false : getVueVersion(root) === "vue3";
107
+ resolved.version = (_a = resolved.version) != null ? _a : getVueVersion(root);
108
+ if (resolved.version < 2 || resolved.version >= 4)
109
+ throw new Error(`[unplugin-vue-components] unsupported version: ${resolved.version}`);
110
+ resolved.transformer = options.transformer || `vue${Math.trunc(resolved.version)}`;
111
+ resolved.directives = typeof options.directives === "boolean" ? options.directives : !resolved.resolvers.some((i) => i.type === "directive") ? false : resolved.version >= 3;
104
112
  return resolved;
105
113
  }
106
114
  function getVueVersion(root) {
107
115
  var _a;
108
- const version = ((_a = _localpkg.getPackageInfoSync.call(void 0, "vue", { paths: [root] })) == null ? void 0 : _a.version) || "3";
109
- return version.startsWith("2.") ? "vue2" : "vue3";
116
+ const raw = ((_a = _localpkg.getPackageInfoSync.call(void 0, "vue", { paths: [root] })) == null ? void 0 : _a.version) || "3";
117
+ const version = +raw.split(".").slice(0, 2).join(".");
118
+ if (version === 2.7)
119
+ return 2.7;
120
+ else if (version < 2.7)
121
+ return 2;
122
+ return 3;
110
123
  }
111
124
 
112
125
  // src/core/fs/glob.ts
@@ -134,7 +147,7 @@ function searchComponents(ctx) {
134
147
 
135
148
  var _promises = require('fs/promises');
136
149
 
137
- var multilineCommentsRE = /\/\*.*?\*\//gms;
150
+ var multilineCommentsRE = new RegExp("\\/\\*.*?\\*\\/", "gms");
138
151
  var singlelineCommentsRE = /\/\/.*$/gm;
139
152
  function extractImports(code) {
140
153
  return Object.fromEntries(Array.from(code.matchAll(/['"]?([^\s'"]+)['"]?\s*:\s*(.+?)[,;\n]/g)).map((i) => [i[1], i[2]]));
@@ -148,10 +161,10 @@ function parseDeclaration(code) {
148
161
  component: {},
149
162
  directive: {}
150
163
  };
151
- const componentDeclaration = (_a = /export\s+interface\s+GlobalComponents\s*{(.*?)}/s.exec(code)) == null ? void 0 : _a[0];
164
+ const componentDeclaration = (_a = new RegExp("export\\s+interface\\s+GlobalComponents\\s*{(.*?)}", "s").exec(code)) == null ? void 0 : _a[0];
152
165
  if (componentDeclaration)
153
166
  imports.component = extractImports(componentDeclaration);
154
- const directiveDeclaration = (_b = /export\s+interface\s+ComponentCustomProperties\s*{(.*?)}/s.exec(code)) == null ? void 0 : _b[0];
167
+ const directiveDeclaration = (_b = new RegExp("export\\s+interface\\s+ComponentCustomProperties\\s*{(.*?)}", "s").exec(code)) == null ? void 0 : _b[0];
155
168
  if (directiveDeclaration)
156
169
  imports.directive = extractImports(directiveDeclaration);
157
170
  return imports;
@@ -159,7 +172,7 @@ function parseDeclaration(code) {
159
172
  function stringifyComponentInfo(filepath, { from: path, as: name, name: importName }, importPathTransform) {
160
173
  if (!name)
161
174
  return void 0;
162
- path = _chunk5HMJAJIKjs.getTransformedPath.call(void 0, path, importPathTransform);
175
+ path = _chunkDLADAJMIjs.getTransformedPath.call(void 0, path, importPathTransform);
163
176
  const related = _path.isAbsolute.call(void 0, path) ? `./${_path.relative.call(void 0, _path.dirname.call(void 0, filepath), path)}` : path;
164
177
  const entry = `typeof import('${_utils.slash.call(void 0, related)}')['${importName || "default"}']`;
165
178
  return [name, entry];
@@ -171,10 +184,7 @@ function stringifyComponentsInfo(filepath, components, importPathTransform) {
171
184
  }
172
185
  function getDeclarationImports(ctx, filepath) {
173
186
  const component = stringifyComponentsInfo(filepath, [
174
- ...Object.values({
175
- ...ctx.componentNameMap,
176
- ...ctx.componentCustomMap
177
- }),
187
+ ...Object.values(_chunkBTQOTIPQjs.__spreadValues.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, ctx.componentNameMap), ctx.componentCustomMap)),
178
188
  ...resolveTypeImports(ctx.options.types)
179
189
  ], ctx.options.importPathTransform);
180
190
  const directive = stringifyComponentsInfo(
@@ -198,17 +208,20 @@ function getDeclaration(ctx, filepath, originalImports) {
198
208
  if (!imports)
199
209
  return;
200
210
  const declarations = {
201
- component: stringifyDeclarationImports({ ...originalImports == null ? void 0 : originalImports.component, ...imports.component }),
202
- directive: stringifyDeclarationImports({ ...originalImports == null ? void 0 : originalImports.directive, ...imports.directive })
211
+ component: stringifyDeclarationImports(_chunkBTQOTIPQjs.__spreadValues.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, originalImports == null ? void 0 : originalImports.component), imports.component)),
212
+ directive: stringifyDeclarationImports(_chunkBTQOTIPQjs.__spreadValues.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, originalImports == null ? void 0 : originalImports.directive), imports.directive))
203
213
  };
204
- let code = `// generated by unplugin-vue-components
205
- // We suggest you to commit this file into source control
206
- // Read more: https://github.com/vuejs/core/pull/3399
207
- import '@vue/runtime-core'
214
+ const head = ctx.options.version === 2.7 ? `export {}
215
+
216
+ declare module 'vue' {` : `import '@vue/runtime-core'
208
217
 
209
218
  export {}
210
219
 
211
220
  declare module '@vue/runtime-core' {`;
221
+ let code = `// generated by unplugin-vue-components
222
+ // We suggest you to commit this file into source control
223
+ // Read more: https://github.com/vuejs/core/pull/3399
224
+ ${head}`;
212
225
  if (Object.keys(declarations.component).length > 0) {
213
226
  code += `
214
227
  export interface GlobalComponents {
@@ -276,12 +289,12 @@ async function transformComponent(code, transformer2, s, ctx, sfcPath) {
276
289
  const results = transformer2 === "vue2" ? resolveVue2(code, s) : resolveVue3(code, s);
277
290
  for (const { rawName, replace } of results) {
278
291
  debug2(`| ${rawName}`);
279
- const name = _chunk5HMJAJIKjs.pascalCase.call(void 0, rawName);
292
+ const name = _chunkDLADAJMIjs.pascalCase.call(void 0, rawName);
280
293
  ctx.updateUsageMap(sfcPath, [name]);
281
294
  const component = await ctx.findComponent(name, "component", [sfcPath]);
282
295
  if (component) {
283
296
  const varName = `__unplugin_components_${no}`;
284
- s.prepend(`${_chunk5HMJAJIKjs.stringifyComponentImport.call(void 0, { ...component, as: varName }, ctx)};
297
+ s.prepend(`${_chunkDLADAJMIjs.stringifyComponentImport.call(void 0, _chunkBTQOTIPQjs.__spreadProps.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, component), { as: varName }), ctx)};
285
298
  `);
286
299
  no += 1;
287
300
  replace(varName);
@@ -314,7 +327,7 @@ async function resolveVue22(code, s) {
314
327
  sourceType: "module"
315
328
  });
316
329
  const nodes = [];
317
- const { walk } = await Promise.resolve().then(() => require("./src-KKLCUN63.js"));
330
+ const { walk } = await Promise.resolve().then(() => require("./src-4OAWGTJE.js"));
318
331
  walk(program, {
319
332
  enter(node) {
320
333
  if (node.type === "CallExpression")
@@ -386,13 +399,13 @@ async function transformDirective(code, transformer2, s, ctx, sfcPath) {
386
399
  const results = await (transformer2 === "vue2" ? resolveVue22(code, s) : resolveVue32(code, s));
387
400
  for (const { rawName, replace } of results) {
388
401
  debug3(`| ${rawName}`);
389
- const name = `${_chunk5HMJAJIKjs.DIRECTIVE_IMPORT_PREFIX}${_chunk5HMJAJIKjs.pascalCase.call(void 0, rawName)}`;
402
+ const name = `${_chunkDLADAJMIjs.DIRECTIVE_IMPORT_PREFIX}${_chunkDLADAJMIjs.pascalCase.call(void 0, rawName)}`;
390
403
  ctx.updateUsageMap(sfcPath, [name]);
391
404
  const directive = await ctx.findComponent(name, "directive", [sfcPath]);
392
405
  if (!directive)
393
406
  continue;
394
407
  const varName = `__unplugin_directives_${no}`;
395
- s.prepend(`${_chunk5HMJAJIKjs.stringifyComponentImport.call(void 0, { ...directive, as: varName }, ctx)};
408
+ s.prepend(`${_chunkDLADAJMIjs.stringifyComponentImport.call(void 0, _chunkBTQOTIPQjs.__spreadProps.call(void 0, _chunkBTQOTIPQjs.__spreadValues.call(void 0, {}, directive), { as: varName }), ctx)};
396
409
  `);
397
410
  no += 1;
398
411
  replace(varName);
@@ -411,7 +424,7 @@ function transformer(ctx, transformer2) {
411
424
  await transformComponent(code, transformer2, s, ctx, sfcPath);
412
425
  if (ctx.options.directives)
413
426
  await transformDirective(code, transformer2, s, ctx, sfcPath);
414
- s.prepend(_chunk5HMJAJIKjs.DISABLE_COMMENT);
427
+ s.prepend(_chunkDLADAJMIjs.DISABLE_COMMENT);
415
428
  const result = { code: s.toString() };
416
429
  if (ctx.sourcemap)
417
430
  result.map = s.generateMap({ source: id, includeContent: true });
@@ -441,7 +454,7 @@ var Context = class {
441
454
  this.alias = {};
442
455
  this._searched = false;
443
456
  this.options = resolveOptions(rawOptions, this.root);
444
- this.generateDeclaration = _utils.throttle.call(void 0, 500, false, this._generateDeclaration.bind(this));
457
+ this.generateDeclaration = _utils.throttle.call(void 0, 500, this._generateDeclaration.bind(this), { noLeading: false });
445
458
  this.setTransformer(this.options.transformer);
446
459
  }
447
460
  setRoot(root) {
@@ -456,7 +469,7 @@ var Context = class {
456
469
  this.transformer = transformer(this, name || "vue3");
457
470
  }
458
471
  transform(code, id) {
459
- const { path, query } = _chunk5HMJAJIKjs.parseId.call(void 0, id);
472
+ const { path, query } = _chunkDLADAJMIjs.parseId.call(void 0, id);
460
473
  return this.transformer(code, id, path, query);
461
474
  }
462
475
  setupViteServer(server) {
@@ -468,14 +481,14 @@ var Context = class {
468
481
  setupWatcher(watcher) {
469
482
  const { globs } = this.options;
470
483
  watcher.on("unlink", (path) => {
471
- if (!_chunk5HMJAJIKjs.matchGlobs.call(void 0, path, globs))
484
+ if (!_chunkDLADAJMIjs.matchGlobs.call(void 0, path, globs))
472
485
  return;
473
486
  path = _utils.slash.call(void 0, path);
474
487
  this.removeComponents(path);
475
488
  this.onUpdate(path);
476
489
  });
477
490
  watcher.on("add", (path) => {
478
- if (!_chunk5HMJAJIKjs.matchGlobs.call(void 0, path, globs))
491
+ if (!_chunkDLADAJMIjs.matchGlobs.call(void 0, path, globs))
479
492
  return;
480
493
  path = _utils.slash.call(void 0, path);
481
494
  this.addComponents(path);
@@ -485,14 +498,14 @@ var Context = class {
485
498
  setupWatcherWebpack(watcher, emitUpdate) {
486
499
  const { globs } = this.options;
487
500
  watcher.on("unlink", (path) => {
488
- if (!_chunk5HMJAJIKjs.matchGlobs.call(void 0, path, globs))
501
+ if (!_chunkDLADAJMIjs.matchGlobs.call(void 0, path, globs))
489
502
  return;
490
503
  path = _utils.slash.call(void 0, path);
491
504
  this.removeComponents(path);
492
505
  emitUpdate(path, "unlink");
493
506
  });
494
507
  watcher.on("add", (path) => {
495
- if (!_chunk5HMJAJIKjs.matchGlobs.call(void 0, path, globs))
508
+ if (!_chunkDLADAJMIjs.matchGlobs.call(void 0, path, globs))
496
509
  return;
497
510
  path = _utils.slash.call(void 0, path);
498
511
  this.addComponents(path);
@@ -543,7 +556,7 @@ var Context = class {
543
556
  updates: []
544
557
  };
545
558
  const timestamp = +new Date();
546
- const name = _chunk5HMJAJIKjs.pascalCase.call(void 0, _chunk5HMJAJIKjs.getNameFromFilePath.call(void 0, path, this.options));
559
+ const name = _chunkDLADAJMIjs.pascalCase.call(void 0, _chunkDLADAJMIjs.getNameFromFilePath.call(void 0, path, this.options));
547
560
  Object.entries(this._componentUsageMap).forEach(([key, values]) => {
548
561
  if (values.has(name)) {
549
562
  const r = `/${_utils.slash.call(void 0, _path.relative.call(void 0, this.root, key))}`;
@@ -561,7 +574,7 @@ var Context = class {
561
574
  updateComponentNameMap() {
562
575
  this._componentNameMap = {};
563
576
  Array.from(this._componentPaths).forEach((path) => {
564
- const name = _chunk5HMJAJIKjs.pascalCase.call(void 0, _chunk5HMJAJIKjs.getNameFromFilePath.call(void 0, path, this.options));
577
+ const name = _chunkDLADAJMIjs.pascalCase.call(void 0, _chunkDLADAJMIjs.getNameFromFilePath.call(void 0, path, this.options));
565
578
  if (this._componentNameMap[name] && !this.options.allowOverrides) {
566
579
  console.warn(`[unplugin-vue-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`);
567
580
  return;
@@ -579,7 +592,7 @@ var Context = class {
579
592
  for (const resolver of this.options.resolvers) {
580
593
  if (resolver.type !== type)
581
594
  continue;
582
- const result = await resolver.resolve(type === "directive" ? name.slice(_chunk5HMJAJIKjs.DIRECTIVE_IMPORT_PREFIX.length) : name);
595
+ const result = await resolver.resolve(type === "directive" ? name.slice(_chunkDLADAJMIjs.DIRECTIVE_IMPORT_PREFIX.length) : name);
583
596
  if (!result)
584
597
  continue;
585
598
  if (typeof result === "string") {
@@ -588,10 +601,9 @@ var Context = class {
588
601
  from: result
589
602
  };
590
603
  } else {
591
- info = {
592
- as: name,
593
- ..._chunk5HMJAJIKjs.normalizeComponetInfo.call(void 0, result)
594
- };
604
+ info = _chunkBTQOTIPQjs.__spreadValues.call(void 0, {
605
+ as: name
606
+ }, _chunkDLADAJMIjs.normalizeComponetInfo.call(void 0, result));
595
607
  }
596
608
  if (type === "component")
597
609
  this.addCustomComponents(info);
@@ -603,7 +615,7 @@ var Context = class {
603
615
  }
604
616
  normalizePath(path) {
605
617
  var _a, _b, _c;
606
- return _chunk5HMJAJIKjs.resolveAlias.call(void 0, path, ((_b = (_a = this.viteConfig) == null ? void 0 : _a.resolve) == null ? void 0 : _b.alias) || ((_c = this.viteConfig) == null ? void 0 : _c.alias) || []);
618
+ return _chunkDLADAJMIjs.resolveAlias.call(void 0, path, ((_b = (_a = this.viteConfig) == null ? void 0 : _a.resolve) == null ? void 0 : _b.alias) || ((_c = this.viteConfig) == null ? void 0 : _c.alias) || []);
607
619
  }
608
620
  relative(path) {
609
621
  if (path.startsWith("/") && !path.startsWith(this.root))
@@ -647,7 +659,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
647
659
  return await ctx.findComponent(name, "component", filename ? [filename] : []);
648
660
  },
649
661
  stringifyImport(info) {
650
- return _chunk5HMJAJIKjs.stringifyComponentImport.call(void 0, info, ctx);
662
+ return _chunkDLADAJMIjs.stringifyComponentImport.call(void 0, info, ctx);
651
663
  }
652
664
  };
653
665
  return {
@@ -658,7 +670,7 @@ var unplugin_default = _unplugin.createUnplugin.call(void 0, (options = {}) => {
658
670
  return filter(id);
659
671
  },
660
672
  async transform(code, id) {
661
- if (!_chunk5HMJAJIKjs.shouldTransform.call(void 0, code))
673
+ if (!_chunkDLADAJMIjs.shouldTransform.call(void 0, code))
662
674
  return null;
663
675
  try {
664
676
  const result = await ctx.transform(code, id);
@@ -109,7 +109,7 @@ function getNameFromFilePath(filePath, options) {
109
109
  if (directoryAsNamespace) {
110
110
  if (globalNamespaces.some((name) => folders.includes(name)))
111
111
  folders = folders.filter((f) => !globalNamespaces.includes(f));
112
- folders = folders.map((f) => f.replace(/[^a-zA-Z0-9]/g, ""));
112
+ folders = folders.map((f) => f.replace(/[^a-zA-Z0-9\-]/g, ""));
113
113
  if (filename.toLowerCase() === "index")
114
114
  filename = "";
115
115
  if (!isEmpty(folders)) {
@@ -142,11 +142,12 @@ function resolveAlias(filepath, alias) {
142
142
  return result;
143
143
  }
144
144
  async function getPkgVersion(pkgName, defaultVersion) {
145
+ var _a;
145
146
  try {
146
147
  const isExist = isPackageExists(pkgName);
147
148
  if (isExist) {
148
149
  const pkg = await getPackageInfo(pkgName);
149
- return (pkg == null ? void 0 : pkg.version) ?? defaultVersion;
150
+ return (_a = pkg == null ? void 0 : pkg.version) != null ? _a : defaultVersion;
150
151
  } else {
151
152
  return defaultVersion;
152
153
  }
@@ -0,0 +1,32 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
21
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
22
+ }) : x)(function(x) {
23
+ if (typeof require !== "undefined")
24
+ return require.apply(this, arguments);
25
+ throw new Error('Dynamic require of "' + x + '" is not supported');
26
+ });
27
+
28
+ export {
29
+ __spreadValues,
30
+ __spreadProps,
31
+ __require
32
+ };
package/dist/esbuild.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkALMYXVCOjs = require('./chunk-ALMYXVCO.js');
4
- require('./chunk-5HMJAJIK.js');
5
- require('./chunk-EZUCZHGV.js');
3
+ var _chunkIBVXRXR4js = require('./chunk-IBVXRXR4.js');
4
+ require('./chunk-DLADAJMI.js');
5
+ require('./chunk-BTQOTIPQ.js');
6
6
  require('./chunk-6F4PWJZI.js');
7
7
 
8
8
  // src/esbuild.ts
9
- var esbuild_default = _chunkALMYXVCOjs.unplugin_default.esbuild;
9
+ var esbuild_default = _chunkIBVXRXR4js.unplugin_default.esbuild;
10
10
 
11
11
 
12
12
  module.exports = esbuild_default;
package/dist/esbuild.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-VNVY5OWA.mjs";
4
- import "./chunk-T47CWWYC.mjs";
5
- import "./chunk-AKU6F3WT.mjs";
3
+ } from "./chunk-G3647JPL.mjs";
4
+ import "./chunk-KWXXDT62.mjs";
5
+ import "./chunk-ZKNUHGJ4.mjs";
6
6
  import "./chunk-WBQAMGXK.mjs";
7
7
 
8
8
  // src/esbuild.ts
package/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as unplugin from 'unplugin';
4
4
  import '@rollup/pluginutils';
5
5
  import '@antfu/utils';
6
6
 
7
- declare const _default: unplugin.UnpluginInstance<Options>;
7
+ declare const _default: unplugin.UnpluginInstance<Options, false>;
8
8
 
9
9
  declare function pascalCase(str: string): string;
10
10
  declare function camelCase(str: string): string;
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkALMYXVCOjs = require('./chunk-ALMYXVCO.js');
3
+ var _chunkIBVXRXR4js = require('./chunk-IBVXRXR4.js');
4
4
 
5
5
 
6
6
 
7
7
 
8
- var _chunk5HMJAJIKjs = require('./chunk-5HMJAJIK.js');
9
- require('./chunk-EZUCZHGV.js');
8
+ var _chunkDLADAJMIjs = require('./chunk-DLADAJMI.js');
9
+ require('./chunk-BTQOTIPQ.js');
10
10
  require('./chunk-6F4PWJZI.js');
11
11
 
12
12
 
13
13
 
14
14
 
15
15
 
16
- exports.camelCase = _chunk5HMJAJIKjs.camelCase; exports.default = _chunkALMYXVCOjs.unplugin_default; exports.kebabCase = _chunk5HMJAJIKjs.kebabCase; exports.pascalCase = _chunk5HMJAJIKjs.pascalCase;
16
+ exports.camelCase = _chunkDLADAJMIjs.camelCase; exports.default = _chunkIBVXRXR4js.unplugin_default; exports.kebabCase = _chunkDLADAJMIjs.kebabCase; exports.pascalCase = _chunkDLADAJMIjs.pascalCase;
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  unplugin_default
3
- } from "./chunk-VNVY5OWA.mjs";
3
+ } from "./chunk-G3647JPL.mjs";
4
4
  import {
5
5
  camelCase,
6
6
  kebabCase,
7
7
  pascalCase
8
- } from "./chunk-T47CWWYC.mjs";
9
- import "./chunk-AKU6F3WT.mjs";
8
+ } from "./chunk-KWXXDT62.mjs";
9
+ import "./chunk-ZKNUHGJ4.mjs";
10
10
  import "./chunk-WBQAMGXK.mjs";
11
11
  export {
12
12
  camelCase,