@hybridly/vite 0.5.6 → 0.5.7

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/dist/index.cjs CHANGED
@@ -45,6 +45,14 @@ const debug = {
45
45
  function isPackageInstalled(name, paths = [process.cwd()]) {
46
46
  return localPkg.isPackageExists(name, { paths });
47
47
  }
48
+ function importPackage(name, paths = [process.cwd()]) {
49
+ const mod = localPkg.resolveModule(name, { paths });
50
+ if (!mod) {
51
+ console.warn(`Could not resolve package [${name}]`);
52
+ return;
53
+ }
54
+ return localPkg.importModule(mod);
55
+ }
48
56
  function toKebabCase(key) {
49
57
  const result = key.replace(/([A-Z])/g, " $1").trim();
50
58
  return result.split(" ").join("-").toLowerCase();
@@ -419,21 +427,7 @@ function getAutoImportsOptions(options, config) {
419
427
  );
420
428
  }
421
429
 
422
- function HybridlyResolver(linkName = "RouterLink") {
423
- return {
424
- type: "component",
425
- resolve: (name) => {
426
- if (name === linkName) {
427
- return {
428
- from: "hybridly/vue",
429
- name: "RouterLink",
430
- as: linkName
431
- };
432
- }
433
- }
434
- };
435
- }
436
- function getVueComponentsOptions(options, config) {
430
+ async function getVueComponentsOptions(options, config) {
437
431
  if (options.vueComponents === false) {
438
432
  return {};
439
433
  }
@@ -441,6 +435,7 @@ function getVueComponentsOptions(options, config) {
441
435
  const customCollections = Array.isArray(options.customIcons) ? options.customIcons : options.customIcons?.collections ?? [];
442
436
  const overrideResolvers = options.overrideResolvers ? Array.isArray(options.overrideResolvers) ? options.overrideResolvers : [options.overrideResolvers] : false;
443
437
  const hasHeadlessUI = isPackageInstalled("@headlessui/vue");
438
+ const hasRadix = isPackageInstalled("radix-vue");
444
439
  return utils.merge(
445
440
  {
446
441
  dirs: [
@@ -451,6 +446,7 @@ function getVueComponentsOptions(options, config) {
451
446
  resolvers: overrideResolvers || [
452
447
  ...hasIcons ? [iconsResolver__default({ customCollections })] : [],
453
448
  ...hasHeadlessUI ? [resolvers.HeadlessUiResolver({ prefix: options?.vueComponents?.headlessUiPrefix ?? "Headless" })] : [],
449
+ ...hasRadix ? [await RadixResolver(options?.vueComponents?.radixPrefix)] : [],
454
450
  ProvidedComponentListResolver(config),
455
451
  HybridlyResolver(options.vueComponents?.linkName)
456
452
  ]
@@ -459,6 +455,24 @@ function getVueComponentsOptions(options, config) {
459
455
  { overwriteArray: false }
460
456
  );
461
457
  }
458
+ async function RadixResolver(prefix = "Radix") {
459
+ const radix = await importPackage("radix-vue/resolver");
460
+ return radix.default({ prefix });
461
+ }
462
+ function HybridlyResolver(linkName = "RouterLink") {
463
+ return {
464
+ type: "component",
465
+ resolve: (name) => {
466
+ if (name === linkName) {
467
+ return {
468
+ from: "hybridly/vue",
469
+ name: "RouterLink",
470
+ as: linkName
471
+ };
472
+ }
473
+ }
474
+ };
475
+ }
462
476
  function ProvidedComponentListResolver(config) {
463
477
  function resolveComponentPath(name) {
464
478
  const kebabName = toKebabCase(name);
@@ -555,7 +569,7 @@ async function plugin(options = {}) {
555
569
  layout(options, config),
556
570
  options.laravel !== false && laravel__default(getLaravelOptions(options, config)),
557
571
  options.run !== false && run__default(getRunOptions(options)),
558
- options.vueComponents !== false && vueComponents__default(getVueComponentsOptions(options, config)),
572
+ options.vueComponents !== false && vueComponents__default(await getVueComponentsOptions(options, config)),
559
573
  options.autoImports !== false && autoimport__default(getAutoImportsOptions(options, config)),
560
574
  options.icons !== false && icons__default(getIconsOptions(options, config)),
561
575
  options.vue !== false && vue__default(getVueOptions(options)),
package/dist/index.d.cts CHANGED
@@ -31,6 +31,8 @@ type VueComponentsOptions = Parameters<typeof vueComponents>[0] & {
31
31
  linkName?: string;
32
32
  /** Custom prefix for Headless UI components. */
33
33
  headlessUiPrefix?: string;
34
+ /** Custom prefix for Radix components. */
35
+ radixPrefix?: string;
34
36
  };
35
37
  type CustomResolvers = ComponentResolver | ComponentResolver[];
36
38
  type CustomComponentsOptions = VueComponentsOptions;
package/dist/index.d.mts CHANGED
@@ -31,6 +31,8 @@ type VueComponentsOptions = Parameters<typeof vueComponents>[0] & {
31
31
  linkName?: string;
32
32
  /** Custom prefix for Headless UI components. */
33
33
  headlessUiPrefix?: string;
34
+ /** Custom prefix for Radix components. */
35
+ radixPrefix?: string;
34
36
  };
35
37
  type CustomResolvers = ComponentResolver | ComponentResolver[];
36
38
  type CustomComponentsOptions = VueComponentsOptions;
package/dist/index.d.ts CHANGED
@@ -31,6 +31,8 @@ type VueComponentsOptions = Parameters<typeof vueComponents>[0] & {
31
31
  linkName?: string;
32
32
  /** Custom prefix for Headless UI components. */
33
33
  headlessUiPrefix?: string;
34
+ /** Custom prefix for Radix components. */
35
+ radixPrefix?: string;
34
36
  };
35
37
  type CustomResolvers = ComponentResolver | ComponentResolver[];
36
38
  type CustomComponentsOptions = VueComponentsOptions;
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import laravel from 'laravel-vite-plugin';
2
2
  import path from 'node:path';
3
3
  import fs from 'node:fs';
4
4
  import makeDebugger from 'debug';
5
- import { isPackageExists } from 'local-pkg';
5
+ import { isPackageExists, resolveModule, importModule } from 'local-pkg';
6
6
  import { execSync } from 'node:child_process';
7
7
  import MagicString from 'magic-string';
8
8
  import run from 'vite-plugin-run';
@@ -27,6 +27,14 @@ const debug = {
27
27
  function isPackageInstalled(name, paths = [process.cwd()]) {
28
28
  return isPackageExists(name, { paths });
29
29
  }
30
+ function importPackage(name, paths = [process.cwd()]) {
31
+ const mod = resolveModule(name, { paths });
32
+ if (!mod) {
33
+ console.warn(`Could not resolve package [${name}]`);
34
+ return;
35
+ }
36
+ return importModule(mod);
37
+ }
30
38
  function toKebabCase(key) {
31
39
  const result = key.replace(/([A-Z])/g, " $1").trim();
32
40
  return result.split(" ").join("-").toLowerCase();
@@ -401,21 +409,7 @@ function getAutoImportsOptions(options, config) {
401
409
  );
402
410
  }
403
411
 
404
- function HybridlyResolver(linkName = "RouterLink") {
405
- return {
406
- type: "component",
407
- resolve: (name) => {
408
- if (name === linkName) {
409
- return {
410
- from: "hybridly/vue",
411
- name: "RouterLink",
412
- as: linkName
413
- };
414
- }
415
- }
416
- };
417
- }
418
- function getVueComponentsOptions(options, config) {
412
+ async function getVueComponentsOptions(options, config) {
419
413
  if (options.vueComponents === false) {
420
414
  return {};
421
415
  }
@@ -423,6 +417,7 @@ function getVueComponentsOptions(options, config) {
423
417
  const customCollections = Array.isArray(options.customIcons) ? options.customIcons : options.customIcons?.collections ?? [];
424
418
  const overrideResolvers = options.overrideResolvers ? Array.isArray(options.overrideResolvers) ? options.overrideResolvers : [options.overrideResolvers] : false;
425
419
  const hasHeadlessUI = isPackageInstalled("@headlessui/vue");
420
+ const hasRadix = isPackageInstalled("radix-vue");
426
421
  return merge(
427
422
  {
428
423
  dirs: [
@@ -433,6 +428,7 @@ function getVueComponentsOptions(options, config) {
433
428
  resolvers: overrideResolvers || [
434
429
  ...hasIcons ? [iconsResolver({ customCollections })] : [],
435
430
  ...hasHeadlessUI ? [HeadlessUiResolver({ prefix: options?.vueComponents?.headlessUiPrefix ?? "Headless" })] : [],
431
+ ...hasRadix ? [await RadixResolver(options?.vueComponents?.radixPrefix)] : [],
436
432
  ProvidedComponentListResolver(config),
437
433
  HybridlyResolver(options.vueComponents?.linkName)
438
434
  ]
@@ -441,6 +437,24 @@ function getVueComponentsOptions(options, config) {
441
437
  { overwriteArray: false }
442
438
  );
443
439
  }
440
+ async function RadixResolver(prefix = "Radix") {
441
+ const radix = await importPackage("radix-vue/resolver");
442
+ return radix.default({ prefix });
443
+ }
444
+ function HybridlyResolver(linkName = "RouterLink") {
445
+ return {
446
+ type: "component",
447
+ resolve: (name) => {
448
+ if (name === linkName) {
449
+ return {
450
+ from: "hybridly/vue",
451
+ name: "RouterLink",
452
+ as: linkName
453
+ };
454
+ }
455
+ }
456
+ };
457
+ }
444
458
  function ProvidedComponentListResolver(config) {
445
459
  function resolveComponentPath(name) {
446
460
  const kebabName = toKebabCase(name);
@@ -537,7 +551,7 @@ async function plugin(options = {}) {
537
551
  layout(options, config),
538
552
  options.laravel !== false && laravel(getLaravelOptions(options, config)),
539
553
  options.run !== false && run(getRunOptions(options)),
540
- options.vueComponents !== false && vueComponents(getVueComponentsOptions(options, config)),
554
+ options.vueComponents !== false && vueComponents(await getVueComponentsOptions(options, config)),
541
555
  options.autoImports !== false && autoimport(getAutoImportsOptions(options, config)),
542
556
  options.icons !== false && icons(getIconsOptions(options, config)),
543
557
  options.vue !== false && vue(getVueOptions(options)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hybridly/vite",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "Vite plugin for Hybridly",
5
5
  "keywords": [
6
6
  "hybridly",
@@ -50,7 +50,7 @@
50
50
  "unplugin-icons": "^0.17.1",
51
51
  "unplugin-vue-components": "^0.25.2",
52
52
  "vite-plugin-run": "^0.5.1",
53
- "@hybridly/core": "0.5.6"
53
+ "@hybridly/core": "0.5.7"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@iconify/json": "^2.2.133",