@hybridly/vite 0.6.0 → 0.7.0
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 +55 -33
- package/dist/index.d.cts +14 -17
- package/dist/index.d.mts +14 -17
- package/dist/index.d.ts +14 -17
- package/dist/index.mjs +54 -34
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -51,7 +51,7 @@ function determineDevelopmentEnvironmentConfigPath() {
|
|
|
51
51
|
function resolveDevelopmentEnvironmentHost(configPath) {
|
|
52
52
|
const configFile = path__default.resolve(configPath, "config.json");
|
|
53
53
|
if (!fs__default.existsSync(configFile)) {
|
|
54
|
-
|
|
54
|
+
return;
|
|
55
55
|
}
|
|
56
56
|
const config = JSON.parse(fs__default.readFileSync(configFile, "utf-8"));
|
|
57
57
|
return `${path__default.basename(process.cwd())}.${config.tld}`;
|
|
@@ -59,6 +59,9 @@ function resolveDevelopmentEnvironmentHost(configPath) {
|
|
|
59
59
|
function resolveDevelopmentEnvironmentServerConfig() {
|
|
60
60
|
const configPath = determineDevelopmentEnvironmentConfigPath();
|
|
61
61
|
const host = resolveDevelopmentEnvironmentHost(configPath);
|
|
62
|
+
if (!host) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
62
65
|
const keyPath = path__default.resolve(configPath, "Certificates", `${host}.key`);
|
|
63
66
|
const certPath = path__default.resolve(configPath, "Certificates", `${host}.crt`);
|
|
64
67
|
if (!fs__default.existsSync(keyPath) || !fs__default.existsSync(certPath)) {
|
|
@@ -172,7 +175,7 @@ function laravel(options, hybridlyConfig) {
|
|
|
172
175
|
let registered = `${colors__default.bold(hybridlyConfig.components.views.length)} ${colors__default.dim("views")}, `;
|
|
173
176
|
registered += `${colors__default.bold(hybridlyConfig.components.components.length)} ${colors__default.dim("components")}, `;
|
|
174
177
|
registered += `${colors__default.bold(hybridlyConfig.components.layouts.length)} ${colors__default.dim("layouts")}, `;
|
|
175
|
-
registered += `${colors__default.bold(hybridlyConfig.components.
|
|
178
|
+
registered += `${colors__default.bold(hybridlyConfig.components.files.length)} ${colors__default.dim("files")}`;
|
|
176
179
|
const latest = hybridlyConfig.versions.is_latest ? "" : colors__default.dim(`(${colors__default.yellow(`${hybridlyConfig.versions.latest} is available`)})`);
|
|
177
180
|
let version = `${colors__default.yellow(`v${hybridlyConfig.versions.composer}`)} ${colors__default.dim("(composer)")}, `;
|
|
178
181
|
version += `${colors__default.yellow(`v${hybridlyConfig.versions.npm}`)} ${colors__default.dim("(npm)")}`;
|
|
@@ -342,6 +345,16 @@ function generateLaravelIdeaHelper(config) {
|
|
|
342
345
|
parameters: [1]
|
|
343
346
|
}
|
|
344
347
|
]
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
complete: "routeName",
|
|
351
|
+
condition: [
|
|
352
|
+
{
|
|
353
|
+
classFqn: ["Hybridly\\Hybridly"],
|
|
354
|
+
methodNames: ["base"],
|
|
355
|
+
parameters: [1]
|
|
356
|
+
}
|
|
357
|
+
]
|
|
345
358
|
}
|
|
346
359
|
]
|
|
347
360
|
};
|
|
@@ -389,9 +402,9 @@ function write(data, filename) {
|
|
|
389
402
|
});
|
|
390
403
|
}
|
|
391
404
|
|
|
392
|
-
async function loadConfiguration(
|
|
405
|
+
async function loadConfiguration() {
|
|
393
406
|
try {
|
|
394
|
-
const php =
|
|
407
|
+
const php = process.env.PHP_EXECUTABLE_PATH ?? "php";
|
|
395
408
|
const stdout = node_child_process.execSync(`${php} artisan hybridly:config`);
|
|
396
409
|
return JSON.parse(stdout.toString("utf-8"));
|
|
397
410
|
} catch (e) {
|
|
@@ -454,7 +467,7 @@ const initialize = (options, config) => {
|
|
|
454
467
|
return await forceRestart("Routing changed");
|
|
455
468
|
}
|
|
456
469
|
if (/.*\.vue$/.test(file)) {
|
|
457
|
-
const updatedConfig = await loadConfiguration(
|
|
470
|
+
const updatedConfig = await loadConfiguration();
|
|
458
471
|
const viewsOrLayoutsChanged = didViewsOrLayoutsChange(updatedConfig, config);
|
|
459
472
|
if (viewsOrLayoutsChanged) {
|
|
460
473
|
return await forceRestart("View or layout changed");
|
|
@@ -491,7 +504,7 @@ function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
|
|
|
491
504
|
}
|
|
492
505
|
|
|
493
506
|
const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\ )?)+)['"] *)?>/;
|
|
494
|
-
const
|
|
507
|
+
const LANG_REGEX = /lang=['"](\w+)['"]/;
|
|
495
508
|
const layout = (options, config) => {
|
|
496
509
|
const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".vue", "") ?? "default";
|
|
497
510
|
const templateRegExp = options?.layout?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
|
|
@@ -507,7 +520,7 @@ const layout = (options, config) => {
|
|
|
507
520
|
}
|
|
508
521
|
const source = new MagicString__default(code);
|
|
509
522
|
const updatedCode = source.replace(templateRegExp, (_, layoutName) => {
|
|
510
|
-
const
|
|
523
|
+
const [hasLang, lang] = code.match(LANG_REGEX) ?? [];
|
|
511
524
|
const layouts = layoutName?.toString()?.replaceAll(" ", "").split(",") ?? [defaultLayoutName];
|
|
512
525
|
const importName = (i) => `__hybridly_layout_${i}`;
|
|
513
526
|
const exports = layouts.map((_2, i) => importName(i));
|
|
@@ -521,7 +534,7 @@ const layout = (options, config) => {
|
|
|
521
534
|
imports
|
|
522
535
|
});
|
|
523
536
|
return `
|
|
524
|
-
<script${
|
|
537
|
+
<script${hasLang ? ` lang="${lang}"` : ""}>
|
|
525
538
|
${imports}
|
|
526
539
|
export default { layout: [${exports.join(", ")}] }
|
|
527
540
|
<\/script>
|
|
@@ -547,10 +560,11 @@ function getRunOptions(options) {
|
|
|
547
560
|
if (options.run === false) {
|
|
548
561
|
return [];
|
|
549
562
|
}
|
|
563
|
+
const php = process.env.PHP_EXECUTABLE_PATH ?? "php";
|
|
550
564
|
return [
|
|
551
565
|
{
|
|
552
566
|
name: "Generate TypeScript types",
|
|
553
|
-
run: [
|
|
567
|
+
run: [php, "artisan", "hybridly:types"],
|
|
554
568
|
pattern: [
|
|
555
569
|
"+(app|src)/**/*Data.php",
|
|
556
570
|
"+(app|src)/**/Enums/*.php",
|
|
@@ -559,7 +573,7 @@ function getRunOptions(options) {
|
|
|
559
573
|
},
|
|
560
574
|
{
|
|
561
575
|
name: "Generate i18n",
|
|
562
|
-
run: [
|
|
576
|
+
run: [php, "artisan", "hybridly:i18n"],
|
|
563
577
|
pattern: "lang/**/*.php"
|
|
564
578
|
},
|
|
565
579
|
...options.run ?? []
|
|
@@ -580,8 +594,6 @@ const HybridlyImports = {
|
|
|
580
594
|
"useDialog",
|
|
581
595
|
"useHistoryState",
|
|
582
596
|
"usePaginator",
|
|
583
|
-
"defineLayout",
|
|
584
|
-
"defineLayoutProperties",
|
|
585
597
|
"registerHook",
|
|
586
598
|
"useRoute",
|
|
587
599
|
"useQueryParameters"
|
|
@@ -589,7 +601,8 @@ const HybridlyImports = {
|
|
|
589
601
|
"hybridly": [
|
|
590
602
|
"router",
|
|
591
603
|
"route",
|
|
592
|
-
"can"
|
|
604
|
+
"can",
|
|
605
|
+
"getRouterContext"
|
|
593
606
|
]
|
|
594
607
|
};
|
|
595
608
|
function getAutoImportsOptions(options, config) {
|
|
@@ -616,9 +629,9 @@ function getAutoImportsOptions(options, config) {
|
|
|
616
629
|
dirs: [
|
|
617
630
|
`${config.architecture.root_directory}/utils`,
|
|
618
631
|
`${config.architecture.root_directory}/composables`,
|
|
619
|
-
...config.components.
|
|
632
|
+
...config.components.files
|
|
620
633
|
],
|
|
621
|
-
imports: [
|
|
634
|
+
imports: options.autoImportsMap ?? [
|
|
622
635
|
"vue",
|
|
623
636
|
"vue/macros",
|
|
624
637
|
...presets.filter((pkg) => isPackageInstalled(pkg)),
|
|
@@ -638,8 +651,8 @@ async function getVueComponentsOptions(options, config) {
|
|
|
638
651
|
const hasIcons = options?.icons !== false;
|
|
639
652
|
const customCollections = Array.isArray(options.customIcons) ? options.customIcons : options.customIcons?.collections ?? [];
|
|
640
653
|
const overrideResolvers = options.overrideResolvers ? Array.isArray(options.overrideResolvers) ? options.overrideResolvers : [options.overrideResolvers] : false;
|
|
641
|
-
const
|
|
642
|
-
const
|
|
654
|
+
const shouldImportHeadlessUi = isPackageInstalled("@headlessui/vue") && options.vueComponents?.headlessUiPrefix !== false;
|
|
655
|
+
const shouldImportRadix = isPackageInstalled("radix-vue") && options.vueComponents?.radixPrefix !== false;
|
|
643
656
|
return utils.merge(
|
|
644
657
|
{
|
|
645
658
|
dirs: [
|
|
@@ -649,21 +662,27 @@ async function getVueComponentsOptions(options, config) {
|
|
|
649
662
|
dts: ".hybridly/components.d.ts",
|
|
650
663
|
resolvers: overrideResolvers || [
|
|
651
664
|
...hasIcons ? [iconsResolver__default({ customCollections })] : [],
|
|
652
|
-
...
|
|
653
|
-
...
|
|
665
|
+
...shouldImportHeadlessUi ? [resolvers.HeadlessUiResolver({ prefix: options?.vueComponents?.headlessUiPrefix || "Headless" })] : [],
|
|
666
|
+
...shouldImportRadix ? [await RadixResolver(options?.vueComponents?.radixPrefix || "Radix")] : [],
|
|
654
667
|
ProvidedComponentListResolver(config),
|
|
655
|
-
HybridlyResolver(options
|
|
668
|
+
HybridlyResolver(options, config)
|
|
656
669
|
]
|
|
657
670
|
},
|
|
658
671
|
options.vueComponents ?? {},
|
|
659
672
|
{ overwriteArray: false }
|
|
660
673
|
);
|
|
661
674
|
}
|
|
662
|
-
async function RadixResolver(prefix
|
|
675
|
+
async function RadixResolver(prefix) {
|
|
663
676
|
const radix = await importPackage("radix-vue/resolver");
|
|
664
677
|
return radix.default({ prefix });
|
|
665
678
|
}
|
|
666
|
-
function HybridlyResolver(
|
|
679
|
+
function HybridlyResolver(options, config) {
|
|
680
|
+
return [
|
|
681
|
+
HybridlyLinkResolver(options?.vueComponents === false ? void 0 : options?.vueComponents?.linkName),
|
|
682
|
+
ProvidedComponentListResolver(config)
|
|
683
|
+
];
|
|
684
|
+
}
|
|
685
|
+
function HybridlyLinkResolver(linkName = "RouterLink") {
|
|
667
686
|
return {
|
|
668
687
|
type: "component",
|
|
669
688
|
resolve: (name) => {
|
|
@@ -869,22 +888,25 @@ import '${LOCAL_BUILD_VIRTUAL_ID}'`;
|
|
|
869
888
|
}
|
|
870
889
|
|
|
871
890
|
async function plugin(options = {}) {
|
|
872
|
-
const config = await loadConfiguration(
|
|
891
|
+
const config = await loadConfiguration();
|
|
892
|
+
const resolvedOptions = typeof options === "function" ? await options(config) : options;
|
|
873
893
|
return [
|
|
874
|
-
initialize(
|
|
875
|
-
layout(
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
894
|
+
initialize(resolvedOptions, config),
|
|
895
|
+
layout(resolvedOptions, config),
|
|
896
|
+
resolvedOptions.laravel !== false && laravel(resolvedOptions, config),
|
|
897
|
+
resolvedOptions.run !== false && run__default(getRunOptions(resolvedOptions)),
|
|
898
|
+
resolvedOptions.vueComponents !== false && vueComponents__default(await getVueComponentsOptions(resolvedOptions, config)),
|
|
899
|
+
resolvedOptions.autoImports !== false && autoimport__default(getAutoImportsOptions(resolvedOptions, config)),
|
|
900
|
+
resolvedOptions.icons !== false && icons__default(getIconsOptions(resolvedOptions, config)),
|
|
901
|
+
resolvedOptions.vue !== false && vue__default(getVueOptions(resolvedOptions)),
|
|
902
|
+
resolvedOptions.killSwitch !== false && killSwitch(),
|
|
903
|
+
resolvedOptions.warnOnLocalBuilds !== false && warnOnLocalBuilds()
|
|
884
904
|
];
|
|
885
905
|
}
|
|
886
906
|
|
|
887
907
|
exports.HybridlyImports = HybridlyImports;
|
|
908
|
+
exports.HybridlyLinkResolver = HybridlyLinkResolver;
|
|
888
909
|
exports.HybridlyResolver = HybridlyResolver;
|
|
910
|
+
exports.ProvidedComponentListResolver = ProvidedComponentListResolver;
|
|
889
911
|
exports.default = plugin;
|
|
890
912
|
exports.layout = layout;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
1
|
import { DynamicConfiguration } from '@hybridly/core';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import { ImportsMap, PresetName } from 'unplugin-auto-import/types';
|
|
3
4
|
import autoimport from 'unplugin-auto-import/vite';
|
|
4
5
|
import icons from 'unplugin-icons/vite';
|
|
5
6
|
import { Runner } from 'vite-plugin-run';
|
|
@@ -26,25 +27,18 @@ type VueOptions = Parameters<typeof vue>[0];
|
|
|
26
27
|
type VueComponentsOptions = Parameters<typeof vueComponents>[0] & {
|
|
27
28
|
/** Name of the Link component. */
|
|
28
29
|
linkName?: string;
|
|
29
|
-
/**
|
|
30
|
-
headlessUiPrefix?: string;
|
|
31
|
-
/**
|
|
32
|
-
radixPrefix?: string;
|
|
30
|
+
/** Specify the prefix for the Headless UI integration, or disable it. */
|
|
31
|
+
headlessUiPrefix?: string | false;
|
|
32
|
+
/** Specify the prefix for the Radix integration, or disable it. */
|
|
33
|
+
radixPrefix?: string | false;
|
|
33
34
|
};
|
|
34
35
|
type CustomResolvers = ComponentResolver | ComponentResolver[];
|
|
35
36
|
type CustomComponentsOptions = VueComponentsOptions;
|
|
36
|
-
declare function HybridlyResolver(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
from: string;
|
|
40
|
-
name: string;
|
|
41
|
-
as: string;
|
|
42
|
-
} | undefined;
|
|
43
|
-
};
|
|
37
|
+
declare function HybridlyResolver(options: ViteOptions, config: DynamicConfiguration): ComponentResolver[];
|
|
38
|
+
declare function HybridlyLinkResolver(linkName?: string): ComponentResolver;
|
|
39
|
+
declare function ProvidedComponentListResolver(config: DynamicConfiguration): ComponentResolver;
|
|
44
40
|
|
|
45
41
|
interface ViteOptions {
|
|
46
|
-
/** Path to the PHP executable. */
|
|
47
|
-
php?: string;
|
|
48
42
|
/** Disables the Laravel integration. Useful if you prefer to use the official one. */
|
|
49
43
|
laravel?: false;
|
|
50
44
|
/** Options for the layout plugin. */
|
|
@@ -55,6 +49,8 @@ interface ViteOptions {
|
|
|
55
49
|
run?: false | Runner[];
|
|
56
50
|
/** Options for `unplugin-auto-import`. Set to `false` to disable. */
|
|
57
51
|
autoImports?: false | AutoImportOptions;
|
|
52
|
+
/** Import map for `unplugin-auto-import`. */
|
|
53
|
+
autoImportsMap?: Array<ImportsMap | PresetName>;
|
|
58
54
|
/** Options for `unplugin-vue-components`. Set to `false` to disable. */
|
|
59
55
|
vueComponents?: false | CustomComponentsOptions;
|
|
60
56
|
/** Options for `unplugin-icons`. Set to `false` to disable. */
|
|
@@ -89,6 +85,7 @@ interface TsConfigOptions {
|
|
|
89
85
|
|
|
90
86
|
declare const _default: (options: ViteOptions, config: DynamicConfiguration) => Plugin;
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
type Options = ViteOptions | ((config: DynamicConfiguration) => (ViteOptions | Promise<ViteOptions>));
|
|
89
|
+
declare function plugin(options?: Options): Promise<any[]>;
|
|
93
90
|
|
|
94
|
-
export { HybridlyImports, HybridlyResolver, type ViteOptions as Options, plugin as default, _default as layout };
|
|
91
|
+
export { HybridlyImports, HybridlyLinkResolver, HybridlyResolver, type ViteOptions as Options, ProvidedComponentListResolver, plugin as default, _default as layout };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
1
|
import { DynamicConfiguration } from '@hybridly/core';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import { ImportsMap, PresetName } from 'unplugin-auto-import/types';
|
|
3
4
|
import autoimport from 'unplugin-auto-import/vite';
|
|
4
5
|
import icons from 'unplugin-icons/vite';
|
|
5
6
|
import { Runner } from 'vite-plugin-run';
|
|
@@ -26,25 +27,18 @@ type VueOptions = Parameters<typeof vue>[0];
|
|
|
26
27
|
type VueComponentsOptions = Parameters<typeof vueComponents>[0] & {
|
|
27
28
|
/** Name of the Link component. */
|
|
28
29
|
linkName?: string;
|
|
29
|
-
/**
|
|
30
|
-
headlessUiPrefix?: string;
|
|
31
|
-
/**
|
|
32
|
-
radixPrefix?: string;
|
|
30
|
+
/** Specify the prefix for the Headless UI integration, or disable it. */
|
|
31
|
+
headlessUiPrefix?: string | false;
|
|
32
|
+
/** Specify the prefix for the Radix integration, or disable it. */
|
|
33
|
+
radixPrefix?: string | false;
|
|
33
34
|
};
|
|
34
35
|
type CustomResolvers = ComponentResolver | ComponentResolver[];
|
|
35
36
|
type CustomComponentsOptions = VueComponentsOptions;
|
|
36
|
-
declare function HybridlyResolver(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
from: string;
|
|
40
|
-
name: string;
|
|
41
|
-
as: string;
|
|
42
|
-
} | undefined;
|
|
43
|
-
};
|
|
37
|
+
declare function HybridlyResolver(options: ViteOptions, config: DynamicConfiguration): ComponentResolver[];
|
|
38
|
+
declare function HybridlyLinkResolver(linkName?: string): ComponentResolver;
|
|
39
|
+
declare function ProvidedComponentListResolver(config: DynamicConfiguration): ComponentResolver;
|
|
44
40
|
|
|
45
41
|
interface ViteOptions {
|
|
46
|
-
/** Path to the PHP executable. */
|
|
47
|
-
php?: string;
|
|
48
42
|
/** Disables the Laravel integration. Useful if you prefer to use the official one. */
|
|
49
43
|
laravel?: false;
|
|
50
44
|
/** Options for the layout plugin. */
|
|
@@ -55,6 +49,8 @@ interface ViteOptions {
|
|
|
55
49
|
run?: false | Runner[];
|
|
56
50
|
/** Options for `unplugin-auto-import`. Set to `false` to disable. */
|
|
57
51
|
autoImports?: false | AutoImportOptions;
|
|
52
|
+
/** Import map for `unplugin-auto-import`. */
|
|
53
|
+
autoImportsMap?: Array<ImportsMap | PresetName>;
|
|
58
54
|
/** Options for `unplugin-vue-components`. Set to `false` to disable. */
|
|
59
55
|
vueComponents?: false | CustomComponentsOptions;
|
|
60
56
|
/** Options for `unplugin-icons`. Set to `false` to disable. */
|
|
@@ -89,6 +85,7 @@ interface TsConfigOptions {
|
|
|
89
85
|
|
|
90
86
|
declare const _default: (options: ViteOptions, config: DynamicConfiguration) => Plugin;
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
type Options = ViteOptions | ((config: DynamicConfiguration) => (ViteOptions | Promise<ViteOptions>));
|
|
89
|
+
declare function plugin(options?: Options): Promise<any[]>;
|
|
93
90
|
|
|
94
|
-
export { HybridlyImports, HybridlyResolver, type ViteOptions as Options, plugin as default, _default as layout };
|
|
91
|
+
export { HybridlyImports, HybridlyLinkResolver, HybridlyResolver, type ViteOptions as Options, ProvidedComponentListResolver, plugin as default, _default as layout };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Plugin } from 'vite';
|
|
2
1
|
import { DynamicConfiguration } from '@hybridly/core';
|
|
2
|
+
import { Plugin } from 'vite';
|
|
3
|
+
import { ImportsMap, PresetName } from 'unplugin-auto-import/types';
|
|
3
4
|
import autoimport from 'unplugin-auto-import/vite';
|
|
4
5
|
import icons from 'unplugin-icons/vite';
|
|
5
6
|
import { Runner } from 'vite-plugin-run';
|
|
@@ -26,25 +27,18 @@ type VueOptions = Parameters<typeof vue>[0];
|
|
|
26
27
|
type VueComponentsOptions = Parameters<typeof vueComponents>[0] & {
|
|
27
28
|
/** Name of the Link component. */
|
|
28
29
|
linkName?: string;
|
|
29
|
-
/**
|
|
30
|
-
headlessUiPrefix?: string;
|
|
31
|
-
/**
|
|
32
|
-
radixPrefix?: string;
|
|
30
|
+
/** Specify the prefix for the Headless UI integration, or disable it. */
|
|
31
|
+
headlessUiPrefix?: string | false;
|
|
32
|
+
/** Specify the prefix for the Radix integration, or disable it. */
|
|
33
|
+
radixPrefix?: string | false;
|
|
33
34
|
};
|
|
34
35
|
type CustomResolvers = ComponentResolver | ComponentResolver[];
|
|
35
36
|
type CustomComponentsOptions = VueComponentsOptions;
|
|
36
|
-
declare function HybridlyResolver(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
from: string;
|
|
40
|
-
name: string;
|
|
41
|
-
as: string;
|
|
42
|
-
} | undefined;
|
|
43
|
-
};
|
|
37
|
+
declare function HybridlyResolver(options: ViteOptions, config: DynamicConfiguration): ComponentResolver[];
|
|
38
|
+
declare function HybridlyLinkResolver(linkName?: string): ComponentResolver;
|
|
39
|
+
declare function ProvidedComponentListResolver(config: DynamicConfiguration): ComponentResolver;
|
|
44
40
|
|
|
45
41
|
interface ViteOptions {
|
|
46
|
-
/** Path to the PHP executable. */
|
|
47
|
-
php?: string;
|
|
48
42
|
/** Disables the Laravel integration. Useful if you prefer to use the official one. */
|
|
49
43
|
laravel?: false;
|
|
50
44
|
/** Options for the layout plugin. */
|
|
@@ -55,6 +49,8 @@ interface ViteOptions {
|
|
|
55
49
|
run?: false | Runner[];
|
|
56
50
|
/** Options for `unplugin-auto-import`. Set to `false` to disable. */
|
|
57
51
|
autoImports?: false | AutoImportOptions;
|
|
52
|
+
/** Import map for `unplugin-auto-import`. */
|
|
53
|
+
autoImportsMap?: Array<ImportsMap | PresetName>;
|
|
58
54
|
/** Options for `unplugin-vue-components`. Set to `false` to disable. */
|
|
59
55
|
vueComponents?: false | CustomComponentsOptions;
|
|
60
56
|
/** Options for `unplugin-icons`. Set to `false` to disable. */
|
|
@@ -89,6 +85,7 @@ interface TsConfigOptions {
|
|
|
89
85
|
|
|
90
86
|
declare const _default: (options: ViteOptions, config: DynamicConfiguration) => Plugin;
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
type Options = ViteOptions | ((config: DynamicConfiguration) => (ViteOptions | Promise<ViteOptions>));
|
|
89
|
+
declare function plugin(options?: Options): Promise<any[]>;
|
|
93
90
|
|
|
94
|
-
export { HybridlyImports, HybridlyResolver, type ViteOptions as Options, plugin as default, _default as layout };
|
|
91
|
+
export { HybridlyImports, HybridlyLinkResolver, HybridlyResolver, type ViteOptions as Options, ProvidedComponentListResolver, plugin as default, _default as layout };
|
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,7 @@ function determineDevelopmentEnvironmentConfigPath() {
|
|
|
32
32
|
function resolveDevelopmentEnvironmentHost(configPath) {
|
|
33
33
|
const configFile = path.resolve(configPath, "config.json");
|
|
34
34
|
if (!fs.existsSync(configFile)) {
|
|
35
|
-
|
|
35
|
+
return;
|
|
36
36
|
}
|
|
37
37
|
const config = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
38
38
|
return `${path.basename(process.cwd())}.${config.tld}`;
|
|
@@ -40,6 +40,9 @@ function resolveDevelopmentEnvironmentHost(configPath) {
|
|
|
40
40
|
function resolveDevelopmentEnvironmentServerConfig() {
|
|
41
41
|
const configPath = determineDevelopmentEnvironmentConfigPath();
|
|
42
42
|
const host = resolveDevelopmentEnvironmentHost(configPath);
|
|
43
|
+
if (!host) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
43
46
|
const keyPath = path.resolve(configPath, "Certificates", `${host}.key`);
|
|
44
47
|
const certPath = path.resolve(configPath, "Certificates", `${host}.crt`);
|
|
45
48
|
if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
|
|
@@ -153,7 +156,7 @@ function laravel(options, hybridlyConfig) {
|
|
|
153
156
|
let registered = `${colors.bold(hybridlyConfig.components.views.length)} ${colors.dim("views")}, `;
|
|
154
157
|
registered += `${colors.bold(hybridlyConfig.components.components.length)} ${colors.dim("components")}, `;
|
|
155
158
|
registered += `${colors.bold(hybridlyConfig.components.layouts.length)} ${colors.dim("layouts")}, `;
|
|
156
|
-
registered += `${colors.bold(hybridlyConfig.components.
|
|
159
|
+
registered += `${colors.bold(hybridlyConfig.components.files.length)} ${colors.dim("files")}`;
|
|
157
160
|
const latest = hybridlyConfig.versions.is_latest ? "" : colors.dim(`(${colors.yellow(`${hybridlyConfig.versions.latest} is available`)})`);
|
|
158
161
|
let version = `${colors.yellow(`v${hybridlyConfig.versions.composer}`)} ${colors.dim("(composer)")}, `;
|
|
159
162
|
version += `${colors.yellow(`v${hybridlyConfig.versions.npm}`)} ${colors.dim("(npm)")}`;
|
|
@@ -323,6 +326,16 @@ function generateLaravelIdeaHelper(config) {
|
|
|
323
326
|
parameters: [1]
|
|
324
327
|
}
|
|
325
328
|
]
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
complete: "routeName",
|
|
332
|
+
condition: [
|
|
333
|
+
{
|
|
334
|
+
classFqn: ["Hybridly\\Hybridly"],
|
|
335
|
+
methodNames: ["base"],
|
|
336
|
+
parameters: [1]
|
|
337
|
+
}
|
|
338
|
+
]
|
|
326
339
|
}
|
|
327
340
|
]
|
|
328
341
|
};
|
|
@@ -370,9 +383,9 @@ function write(data, filename) {
|
|
|
370
383
|
});
|
|
371
384
|
}
|
|
372
385
|
|
|
373
|
-
async function loadConfiguration(
|
|
386
|
+
async function loadConfiguration() {
|
|
374
387
|
try {
|
|
375
|
-
const php =
|
|
388
|
+
const php = process.env.PHP_EXECUTABLE_PATH ?? "php";
|
|
376
389
|
const stdout = execSync(`${php} artisan hybridly:config`);
|
|
377
390
|
return JSON.parse(stdout.toString("utf-8"));
|
|
378
391
|
} catch (e) {
|
|
@@ -435,7 +448,7 @@ const initialize = (options, config) => {
|
|
|
435
448
|
return await forceRestart("Routing changed");
|
|
436
449
|
}
|
|
437
450
|
if (/.*\.vue$/.test(file)) {
|
|
438
|
-
const updatedConfig = await loadConfiguration(
|
|
451
|
+
const updatedConfig = await loadConfiguration();
|
|
439
452
|
const viewsOrLayoutsChanged = didViewsOrLayoutsChange(updatedConfig, config);
|
|
440
453
|
if (viewsOrLayoutsChanged) {
|
|
441
454
|
return await forceRestart("View or layout changed");
|
|
@@ -472,7 +485,7 @@ function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
|
|
|
472
485
|
}
|
|
473
486
|
|
|
474
487
|
const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\ )?)+)['"] *)?>/;
|
|
475
|
-
const
|
|
488
|
+
const LANG_REGEX = /lang=['"](\w+)['"]/;
|
|
476
489
|
const layout = (options, config) => {
|
|
477
490
|
const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".vue", "") ?? "default";
|
|
478
491
|
const templateRegExp = options?.layout?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
|
|
@@ -488,7 +501,7 @@ const layout = (options, config) => {
|
|
|
488
501
|
}
|
|
489
502
|
const source = new MagicString(code);
|
|
490
503
|
const updatedCode = source.replace(templateRegExp, (_, layoutName) => {
|
|
491
|
-
const
|
|
504
|
+
const [hasLang, lang] = code.match(LANG_REGEX) ?? [];
|
|
492
505
|
const layouts = layoutName?.toString()?.replaceAll(" ", "").split(",") ?? [defaultLayoutName];
|
|
493
506
|
const importName = (i) => `__hybridly_layout_${i}`;
|
|
494
507
|
const exports = layouts.map((_2, i) => importName(i));
|
|
@@ -502,7 +515,7 @@ const layout = (options, config) => {
|
|
|
502
515
|
imports
|
|
503
516
|
});
|
|
504
517
|
return `
|
|
505
|
-
<script${
|
|
518
|
+
<script${hasLang ? ` lang="${lang}"` : ""}>
|
|
506
519
|
${imports}
|
|
507
520
|
export default { layout: [${exports.join(", ")}] }
|
|
508
521
|
<\/script>
|
|
@@ -528,10 +541,11 @@ function getRunOptions(options) {
|
|
|
528
541
|
if (options.run === false) {
|
|
529
542
|
return [];
|
|
530
543
|
}
|
|
544
|
+
const php = process.env.PHP_EXECUTABLE_PATH ?? "php";
|
|
531
545
|
return [
|
|
532
546
|
{
|
|
533
547
|
name: "Generate TypeScript types",
|
|
534
|
-
run: [
|
|
548
|
+
run: [php, "artisan", "hybridly:types"],
|
|
535
549
|
pattern: [
|
|
536
550
|
"+(app|src)/**/*Data.php",
|
|
537
551
|
"+(app|src)/**/Enums/*.php",
|
|
@@ -540,7 +554,7 @@ function getRunOptions(options) {
|
|
|
540
554
|
},
|
|
541
555
|
{
|
|
542
556
|
name: "Generate i18n",
|
|
543
|
-
run: [
|
|
557
|
+
run: [php, "artisan", "hybridly:i18n"],
|
|
544
558
|
pattern: "lang/**/*.php"
|
|
545
559
|
},
|
|
546
560
|
...options.run ?? []
|
|
@@ -561,8 +575,6 @@ const HybridlyImports = {
|
|
|
561
575
|
"useDialog",
|
|
562
576
|
"useHistoryState",
|
|
563
577
|
"usePaginator",
|
|
564
|
-
"defineLayout",
|
|
565
|
-
"defineLayoutProperties",
|
|
566
578
|
"registerHook",
|
|
567
579
|
"useRoute",
|
|
568
580
|
"useQueryParameters"
|
|
@@ -570,7 +582,8 @@ const HybridlyImports = {
|
|
|
570
582
|
"hybridly": [
|
|
571
583
|
"router",
|
|
572
584
|
"route",
|
|
573
|
-
"can"
|
|
585
|
+
"can",
|
|
586
|
+
"getRouterContext"
|
|
574
587
|
]
|
|
575
588
|
};
|
|
576
589
|
function getAutoImportsOptions(options, config) {
|
|
@@ -597,9 +610,9 @@ function getAutoImportsOptions(options, config) {
|
|
|
597
610
|
dirs: [
|
|
598
611
|
`${config.architecture.root_directory}/utils`,
|
|
599
612
|
`${config.architecture.root_directory}/composables`,
|
|
600
|
-
...config.components.
|
|
613
|
+
...config.components.files
|
|
601
614
|
],
|
|
602
|
-
imports: [
|
|
615
|
+
imports: options.autoImportsMap ?? [
|
|
603
616
|
"vue",
|
|
604
617
|
"vue/macros",
|
|
605
618
|
...presets.filter((pkg) => isPackageInstalled(pkg)),
|
|
@@ -619,8 +632,8 @@ async function getVueComponentsOptions(options, config) {
|
|
|
619
632
|
const hasIcons = options?.icons !== false;
|
|
620
633
|
const customCollections = Array.isArray(options.customIcons) ? options.customIcons : options.customIcons?.collections ?? [];
|
|
621
634
|
const overrideResolvers = options.overrideResolvers ? Array.isArray(options.overrideResolvers) ? options.overrideResolvers : [options.overrideResolvers] : false;
|
|
622
|
-
const
|
|
623
|
-
const
|
|
635
|
+
const shouldImportHeadlessUi = isPackageInstalled("@headlessui/vue") && options.vueComponents?.headlessUiPrefix !== false;
|
|
636
|
+
const shouldImportRadix = isPackageInstalled("radix-vue") && options.vueComponents?.radixPrefix !== false;
|
|
624
637
|
return merge(
|
|
625
638
|
{
|
|
626
639
|
dirs: [
|
|
@@ -630,21 +643,27 @@ async function getVueComponentsOptions(options, config) {
|
|
|
630
643
|
dts: ".hybridly/components.d.ts",
|
|
631
644
|
resolvers: overrideResolvers || [
|
|
632
645
|
...hasIcons ? [iconsResolver({ customCollections })] : [],
|
|
633
|
-
...
|
|
634
|
-
...
|
|
646
|
+
...shouldImportHeadlessUi ? [HeadlessUiResolver({ prefix: options?.vueComponents?.headlessUiPrefix || "Headless" })] : [],
|
|
647
|
+
...shouldImportRadix ? [await RadixResolver(options?.vueComponents?.radixPrefix || "Radix")] : [],
|
|
635
648
|
ProvidedComponentListResolver(config),
|
|
636
|
-
HybridlyResolver(options
|
|
649
|
+
HybridlyResolver(options, config)
|
|
637
650
|
]
|
|
638
651
|
},
|
|
639
652
|
options.vueComponents ?? {},
|
|
640
653
|
{ overwriteArray: false }
|
|
641
654
|
);
|
|
642
655
|
}
|
|
643
|
-
async function RadixResolver(prefix
|
|
656
|
+
async function RadixResolver(prefix) {
|
|
644
657
|
const radix = await importPackage("radix-vue/resolver");
|
|
645
658
|
return radix.default({ prefix });
|
|
646
659
|
}
|
|
647
|
-
function HybridlyResolver(
|
|
660
|
+
function HybridlyResolver(options, config) {
|
|
661
|
+
return [
|
|
662
|
+
HybridlyLinkResolver(options?.vueComponents === false ? void 0 : options?.vueComponents?.linkName),
|
|
663
|
+
ProvidedComponentListResolver(config)
|
|
664
|
+
];
|
|
665
|
+
}
|
|
666
|
+
function HybridlyLinkResolver(linkName = "RouterLink") {
|
|
648
667
|
return {
|
|
649
668
|
type: "component",
|
|
650
669
|
resolve: (name) => {
|
|
@@ -850,19 +869,20 @@ import '${LOCAL_BUILD_VIRTUAL_ID}'`;
|
|
|
850
869
|
}
|
|
851
870
|
|
|
852
871
|
async function plugin(options = {}) {
|
|
853
|
-
const config = await loadConfiguration(
|
|
872
|
+
const config = await loadConfiguration();
|
|
873
|
+
const resolvedOptions = typeof options === "function" ? await options(config) : options;
|
|
854
874
|
return [
|
|
855
|
-
initialize(
|
|
856
|
-
layout(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
875
|
+
initialize(resolvedOptions, config),
|
|
876
|
+
layout(resolvedOptions, config),
|
|
877
|
+
resolvedOptions.laravel !== false && laravel(resolvedOptions, config),
|
|
878
|
+
resolvedOptions.run !== false && run(getRunOptions(resolvedOptions)),
|
|
879
|
+
resolvedOptions.vueComponents !== false && vueComponents(await getVueComponentsOptions(resolvedOptions, config)),
|
|
880
|
+
resolvedOptions.autoImports !== false && autoimport(getAutoImportsOptions(resolvedOptions, config)),
|
|
881
|
+
resolvedOptions.icons !== false && icons(getIconsOptions(resolvedOptions, config)),
|
|
882
|
+
resolvedOptions.vue !== false && vue(getVueOptions(resolvedOptions)),
|
|
883
|
+
resolvedOptions.killSwitch !== false && killSwitch(),
|
|
884
|
+
resolvedOptions.warnOnLocalBuilds !== false && warnOnLocalBuilds()
|
|
865
885
|
];
|
|
866
886
|
}
|
|
867
887
|
|
|
868
|
-
export { HybridlyImports, HybridlyResolver, plugin as default, layout };
|
|
888
|
+
export { HybridlyImports, HybridlyLinkResolver, HybridlyResolver, ProvidedComponentListResolver, plugin as default, layout };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hybridly/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Vite plugin for Hybridly",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hybridly",
|
|
@@ -41,23 +41,23 @@
|
|
|
41
41
|
"vue": "^3.2.45"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@vitejs/plugin-vue": "^
|
|
44
|
+
"@vitejs/plugin-vue": "^5.0.4",
|
|
45
45
|
"fast-glob": "^3.3.2",
|
|
46
46
|
"local-pkg": "^0.5.0",
|
|
47
|
-
"magic-string": "^0.30.
|
|
47
|
+
"magic-string": "^0.30.8",
|
|
48
48
|
"picocolors": "^1.0.0",
|
|
49
49
|
"throttle-debounce": "^5.0.0",
|
|
50
|
-
"unplugin-auto-import": "^0.17.
|
|
51
|
-
"unplugin-icons": "^0.18.
|
|
50
|
+
"unplugin-auto-import": "^0.17.5",
|
|
51
|
+
"unplugin-icons": "^0.18.5",
|
|
52
52
|
"unplugin-vue-components": "^0.26.0",
|
|
53
53
|
"vite-plugin-run": "^0.5.1",
|
|
54
|
-
"@hybridly/core": "0.
|
|
54
|
+
"@hybridly/core": "0.7.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@iconify/json": "^2.2.
|
|
58
|
-
"rollup": "^4.
|
|
59
|
-
"vite": "^5.
|
|
60
|
-
"vue": "^3.4.
|
|
57
|
+
"@iconify/json": "^2.2.191",
|
|
58
|
+
"rollup": "^4.13.0",
|
|
59
|
+
"vite": "^5.1.6",
|
|
60
|
+
"vue": "^3.4.21"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "unbuild",
|