@hybridly/vite 0.3.1 → 0.4.1

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
@@ -2,23 +2,19 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const config = require('@hybridly/config');
6
5
  const laravel = require('laravel-vite-plugin');
7
6
  const path = require('node:path');
8
- const vite = require('vite');
7
+ const fs = require('node:fs');
9
8
  const makeDebugger = require('debug');
10
9
  const localPkg = require('local-pkg');
11
- const fs = require('node:fs');
12
- const throttleDebounce = require('throttle-debounce');
13
- const node_child_process = require('node:child_process');
14
10
  const node_util = require('node:util');
11
+ const node_child_process = require('node:child_process');
15
12
  const run = require('vite-plugin-run');
16
13
  const utils = require('@hybridly/utils');
17
14
  const autoimport = require('unplugin-auto-import/vite');
18
15
  const vueComponents = require('unplugin-vue-components/vite');
19
16
  const resolvers = require('unplugin-vue-components/resolvers');
20
17
  const iconsResolver = require('unplugin-icons/resolver');
21
- const glob = require('fast-glob');
22
18
  const icons = require('unplugin-icons/vite');
23
19
  const loaders = require('unplugin-icons/loaders');
24
20
  const vue = require('@vitejs/plugin-vue');
@@ -27,27 +23,174 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
27
23
 
28
24
  const laravel__default = /*#__PURE__*/_interopDefaultLegacy(laravel);
29
25
  const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
30
- const makeDebugger__default = /*#__PURE__*/_interopDefaultLegacy(makeDebugger);
31
26
  const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
27
+ const makeDebugger__default = /*#__PURE__*/_interopDefaultLegacy(makeDebugger);
32
28
  const run__default = /*#__PURE__*/_interopDefaultLegacy(run);
33
29
  const autoimport__default = /*#__PURE__*/_interopDefaultLegacy(autoimport);
34
30
  const vueComponents__default = /*#__PURE__*/_interopDefaultLegacy(vueComponents);
35
31
  const iconsResolver__default = /*#__PURE__*/_interopDefaultLegacy(iconsResolver);
36
- const glob__default = /*#__PURE__*/_interopDefaultLegacy(glob);
37
32
  const icons__default = /*#__PURE__*/_interopDefaultLegacy(icons);
38
33
  const vue__default = /*#__PURE__*/_interopDefaultLegacy(vue);
39
34
 
40
- const ROUTING_PLUGIN_NAME = "vite:hybridly:routing";
41
- const ROUTING_HMR_UPDATE_ROUTING = "hybridly:routing:update";
42
- const ROUTING_HMR_QUERY_UPDATE_ROUTING = "hybridly:routing:pls-update";
43
- const ROUTING_VIRTUAL_MODULE_ID = "virtual:hybridly/router";
44
- const RESOLVED_ROUTING_VIRTUAL_MODULE_ID = `\0${ROUTING_VIRTUAL_MODULE_ID}`;
45
35
  const LAYOUT_PLUGIN_NAME = "vite:hybridly:layout";
46
36
  const CONFIG_PLUGIN_NAME = "vite:hybridly:config";
47
37
  const CONFIG_VIRTUAL_MODULE_ID = "virtual:hybridly/config";
48
38
  const RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\0${CONFIG_VIRTUAL_MODULE_ID}`;
49
39
 
40
+ const debug = {
41
+ config: makeDebugger__default(CONFIG_PLUGIN_NAME),
42
+ layout: makeDebugger__default(LAYOUT_PLUGIN_NAME)
43
+ };
44
+ function isPackageInstalled(name, paths = [process.cwd()]) {
45
+ return localPkg.isPackageExists(name, { paths });
46
+ }
47
+ function toKebabCase(key) {
48
+ const result = key.replace(/([A-Z])/g, " $1").trim();
49
+ return result.split(" ").join("-").toLowerCase();
50
+ }
51
+
52
+ function generateTsConfig(options, config) {
53
+ const tsconfig = {
54
+ compilerOptions: {
55
+ target: "esnext",
56
+ module: "esnext",
57
+ moduleResolution: "node",
58
+ strict: true,
59
+ jsx: "preserve",
60
+ sourceMap: true,
61
+ resolveJsonModule: true,
62
+ esModuleInterop: true,
63
+ allowSyntheticDefaultImports: true,
64
+ lib: [
65
+ "esnext",
66
+ "dom"
67
+ ],
68
+ types: [
69
+ "vite/client",
70
+ "hybridly/client",
71
+ ...options.icons !== false ? ["unplugin-icons/types/vue"] : []
72
+ ],
73
+ baseUrl: "..",
74
+ paths: {
75
+ "#/*": [
76
+ ".hybridly/*"
77
+ ],
78
+ "~/*": [
79
+ "./*"
80
+ ],
81
+ "@/*": [
82
+ `./${config.architecture.root}/*`
83
+ ]
84
+ }
85
+ },
86
+ include: [
87
+ ...config.components.views.map(({ path: path2 }) => `../${path2}`),
88
+ ...config.components.layouts.map(({ path: path2 }) => `../${path2}`),
89
+ ...config.components.components.map(({ path: path2 }) => `../${path2}`),
90
+ `../${config.architecture.root}/**/*`,
91
+ "./*"
92
+ ],
93
+ exclude: [
94
+ "../public/**/*",
95
+ "../node_modules",
96
+ "../vendor"
97
+ ]
98
+ };
99
+ write(JSON.stringify(tsconfig, null, 2), "tsconfig.json");
100
+ }
101
+ function generateLaravelIdeaHelper(config) {
102
+ const ideJson = {
103
+ $schema: "https://laravel-ide.com/schema/laravel-ide-v2.json",
104
+ completions: [
105
+ {
106
+ complete: "staticStrings",
107
+ options: {
108
+ strings: config.components.views.map(({ identifier }) => identifier)
109
+ },
110
+ condition: [
111
+ {
112
+ functionNames: ["hybridly"],
113
+ parameters: [1]
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ };
119
+ write(JSON.stringify(ideJson, null, 2), "ide.json");
120
+ }
121
+ async function generateRouteDefinitionFile(options, config) {
122
+ const routing = config?.routing;
123
+ if (!routing) {
124
+ return;
125
+ }
126
+ debug.config("Writing types for routing:", routing);
127
+ const routes = Object.fromEntries(Object.entries(routing.routes).map(([key, route]) => {
128
+ const bindings = route.bindings ? Object.fromEntries(Object.entries(route.bindings).map(([key2]) => [key2, "__key_placeholder__"])) : void 0;
129
+ return [key, {
130
+ ...route.uri ? { uri: route.uri } : {},
131
+ ...route.domain ? { domain: route.domain } : {},
132
+ ...route.wheres ? { wheres: route.wheres } : {},
133
+ ...route.bindings ? { bindings } : {}
134
+ }];
135
+ }));
136
+ const definitions = `
137
+ /* eslint-disable */
138
+ /* prettier-ignore */
139
+ // This file has been automatically generated by Hybridly
140
+ // Modifications will be discarded
141
+
142
+ declare module 'hybridly' {
143
+ export interface GlobalRouteCollection {
144
+ url: '__URL__'
145
+ routes: __ROUTES__
146
+ }
147
+ }
148
+
149
+ export {}
150
+ `.replace("__URL__", routing?.url ?? "").replace("__ROUTES__", JSON.stringify(routes).replaceAll('"__key_placeholder__"', "any"));
151
+ write(definitions, "routes.d.ts");
152
+ }
153
+ function write(data, filename) {
154
+ const hybridlyPath = path__default.resolve(process.cwd(), ".hybridly");
155
+ if (!fs__default.existsSync(hybridlyPath)) {
156
+ fs__default.mkdirSync(hybridlyPath);
157
+ }
158
+ fs__default.writeFileSync(path__default.resolve(hybridlyPath, filename), data, {
159
+ encoding: "utf-8"
160
+ });
161
+ }
162
+
163
+ const shell = node_util.promisify(node_child_process.exec);
164
+ async function loadConfiguration(options) {
165
+ try {
166
+ const php = options.php ?? process.env.PHP_EXECUTABLE_PATH ?? "php";
167
+ const { stdout } = await shell(`${php} artisan hybridly:config`);
168
+ return JSON.parse(stdout);
169
+ } catch (e) {
170
+ console.error("Could not load configuration from [php artisan].");
171
+ throw e;
172
+ }
173
+ }
174
+
175
+ function getClientCode(config) {
176
+ const paths = config.components.views.map(({ path }) => `"~/${path}"`).join(",");
177
+ return `
178
+ import { initializeHybridly as init } from 'hybridly/vue'
179
+
180
+ export function initializeHybridly(config) {
181
+ return init({
182
+ ...${JSON.stringify(config)},
183
+ imported: import.meta.glob([${paths}], { eager: ${config.components.eager ?? true} }),
184
+ ...config,
185
+ })
186
+ }
187
+ `;
188
+ }
189
+
50
190
  const initialize = (options, config) => {
191
+ generateTsConfig(options, config);
192
+ generateLaravelIdeaHelper(config);
193
+ generateRouteDefinitionFile(options, config);
51
194
  return {
52
195
  name: CONFIG_PLUGIN_NAME,
53
196
  enforce: "pre",
@@ -55,7 +198,7 @@ const initialize = (options, config) => {
55
198
  return {
56
199
  resolve: {
57
200
  alias: {
58
- "@": path__default.join(process.cwd(), config.root),
201
+ "@": path__default.join(process.cwd(), config.architecture.root),
59
202
  "#": path__default.join(process.cwd(), ".hybridly"),
60
203
  "~": path__default.join(process.cwd())
61
204
  }
@@ -63,19 +206,36 @@ const initialize = (options, config) => {
63
206
  };
64
207
  },
65
208
  configureServer(server) {
66
- const reloadServer = (file) => {
67
- if (!file.endsWith("hybridly.config.ts")) {
209
+ let restarting = false;
210
+ async function forceRestart(message) {
211
+ if (restarting) {
68
212
  return;
69
213
  }
70
- server.config.logger.info("Hybridly configuration file was changed: forcing a server restart.", {
214
+ restarting = true;
215
+ server.config.logger.info(`${message}: forcing a server restart.`, {
71
216
  clear: server.config.clearScreen,
72
217
  timestamp: true
73
218
  });
74
- server?.restart();
75
- };
76
- server.watcher.on("add", reloadServer);
77
- server.watcher.on("change", reloadServer);
78
- server.watcher.on("unlink", reloadServer);
219
+ return await server?.restart();
220
+ }
221
+ async function handleFileChange(file) {
222
+ if (file.endsWith("config/hybridly.php")) {
223
+ return await forceRestart("Configuration file changed");
224
+ }
225
+ if (/routes\/.*\.php/.test(file) || /routes\.php/.test(file)) {
226
+ return await forceRestart("Routing changed");
227
+ }
228
+ if (/.*\.vue$/.test(file)) {
229
+ const updatedConfig = await loadConfiguration(options);
230
+ const pagesOrLayoutsChanged = didPagesOrLayoutsChange(updatedConfig, config);
231
+ if (pagesOrLayoutsChanged) {
232
+ return await forceRestart("Page or layout changed");
233
+ }
234
+ }
235
+ }
236
+ server.watcher.on("add", handleFileChange);
237
+ server.watcher.on("change", handleFileChange);
238
+ server.watcher.on("unlink", handleFileChange);
79
239
  },
80
240
  resolveId(id) {
81
241
  if (id === CONFIG_VIRTUAL_MODULE_ID) {
@@ -84,60 +244,30 @@ const initialize = (options, config) => {
84
244
  },
85
245
  async load(id) {
86
246
  if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) {
87
- return `
88
- import { initializeHybridly as init } from 'hybridly/vue'
89
- import '${ROUTING_VIRTUAL_MODULE_ID}'
90
-
91
- export function initializeHybridly(config) {
92
- return init({
93
- ...${JSON.stringify(config)},
94
- components: import.meta.glob("${config.pagesGlob}", { eager: ${config.eager ?? true} }),
95
- ...config,
96
- })
97
- }
98
- `;
247
+ return getClientCode(config);
248
+ }
249
+ },
250
+ async handleHotUpdate(ctx) {
251
+ if (ctx.file.includes(".hybridly")) {
252
+ return [];
99
253
  }
100
254
  }
101
255
  };
102
256
  };
103
-
104
- const debug = {
105
- router: makeDebugger__default(ROUTING_PLUGIN_NAME),
106
- layout: makeDebugger__default(LAYOUT_PLUGIN_NAME)
107
- };
108
- function isPackageInstalled(name, paths = [process.cwd()]) {
109
- return localPkg.isPackageExists(name, { paths });
110
- }
111
- function toKebabCase(key) {
112
- const result = key.replace(/([A-Z])/g, " $1").trim();
113
- return result.split(" ").join("-").toLowerCase();
114
- }
115
- function getSubstringBetween(str, start, end) {
116
- const startIndex = str.indexOf(start);
117
- if (startIndex === -1) {
118
- return;
119
- }
120
- const endIndex = str.indexOf(end, startIndex + start.length);
121
- if (endIndex === -1) {
122
- return;
257
+ function didPagesOrLayoutsChange(updatedConfig, previousConfig) {
258
+ if (!previousConfig) {
259
+ return false;
123
260
  }
124
- return str.substring(startIndex + start.length, endIndex);
261
+ return JSON.stringify(updatedConfig.components.views) !== JSON.stringify(previousConfig.components.views) || JSON.stringify(updatedConfig.components.layouts) !== JSON.stringify(previousConfig.components.layouts);
125
262
  }
126
263
 
127
264
  const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\ )?)+)['"] *)?>/;
128
265
  const TYPESCRIPT_REGEX = /lang=['"]ts['"]/;
129
- const layout = (options, config$1) => {
266
+ const layout = (options, config) => {
130
267
  const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".vue", "") ?? "default";
131
- const layoutsDirectory = path__default.resolve(process.cwd(), config$1.root, config$1.layouts);
132
268
  const templateRegExp = options?.layout?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
133
- const resolveLayoutPath = (layoutName) => {
134
- const [domain, layout] = layoutName.includes(":") ? layoutName.split(":") : [void 0, layoutName];
135
- const layoutPath = path__default.resolve(config.resolveLayoutsDirectory(config$1, domain), `${layout}.vue`);
136
- return vite.normalizePath(layoutPath).replaceAll("\\", "/");
137
- };
138
269
  debug.layout("Resolved options:", {
139
- defaultLayoutName,
140
- layoutsDirectory
270
+ defaultLayoutName
141
271
  });
142
272
  return {
143
273
  name: LAYOUT_PLUGIN_NAME,
@@ -153,7 +283,7 @@ const layout = (options, config$1) => {
153
283
  const exports = layouts.map((_2, i) => importName(i));
154
284
  const imports = layouts.reduce((imports2, layoutName2, i) => `
155
285
  ${imports2}
156
- import ${importName(i)} from '${resolveLayoutPath(layoutName2)}';
286
+ import ${importName(i)} from '${resolveLayoutImportPath(layoutName2, config)}';
157
287
  `, "").trim();
158
288
  debug.layout(`Resolved layouts "${layouts.join(", ")}":`, {
159
289
  sourceFile: id,
@@ -171,134 +301,14 @@ const layout = (options, config$1) => {
171
301
  }
172
302
  };
173
303
  };
174
-
175
- function getRouterClientCode(routing) {
176
- return `
177
- if (typeof window !== 'undefined') {
178
- window.hybridly = {
179
- routing: ${JSON.stringify(routing)}
180
- }
181
-
182
- if (import.meta.hot) {
183
- import.meta.hot.on('${ROUTING_HMR_UPDATE_ROUTING}', (routing) => {
184
- window.dispatchEvent(new CustomEvent('hybridly:routing', { detail: routing }))
185
- })
186
-
187
- import.meta.hot.send('${ROUTING_HMR_QUERY_UPDATE_ROUTING}')
188
- }
189
- }
190
- `;
191
- }
192
-
193
- const shell = node_util.promisify(node_child_process.exec);
194
- async function fetchRoutingFromArtisan(options) {
195
- try {
196
- const php = options.php ?? "php";
197
- const result = await shell(`${php} artisan hybridly:routes`);
198
- const routing = JSON.parse(result.stdout);
199
- write$1(options, routing);
200
- return routing;
201
- } catch {
304
+ function resolveLayoutImportPath(name, config) {
305
+ const { path } = config.components.layouts.find((layout) => layout.identifier === name) ?? {};
306
+ if (!path) {
307
+ throw new Error(`Layout [${name}] could not be found.`);
202
308
  }
309
+ return `~/${path}`;
203
310
  }
204
311
 
205
- const write$1 = throttleDebounce.debounce(1e3, writeDefinitions, { atBegin: true });
206
- async function writeDefinitions(options, routing) {
207
- routing ?? (routing = await fetchRoutingFromArtisan(options));
208
- if (options.dts === false || !routing) {
209
- return;
210
- }
211
- debug.router("Writing types for routing:", routing);
212
- const target = path__default.resolve(options.dts ?? ".hybridly/routes.d.ts");
213
- const routes = Object.fromEntries(Object.entries(routing.routes).map(([key, route]) => {
214
- const bindings = route.bindings ? Object.fromEntries(Object.entries(route.bindings).map(([key2]) => [key2, "__key_placeholder__"])) : void 0;
215
- return [key, {
216
- ...route.uri ? { uri: route.uri } : {},
217
- ...route.domain ? { domain: route.domain } : {},
218
- ...route.wheres ? { wheres: route.wheres } : {},
219
- ...route.bindings ? { bindings } : {}
220
- }];
221
- }));
222
- const definitions = generateDefinitions().replace("__URL__", routing?.url ?? "").replace("__ROUTES__", JSON.stringify(routes).replaceAll('"__key_placeholder__"', "any"));
223
- fs__default.mkdirSync(path__default.dirname(target), { recursive: true });
224
- fs__default.writeFileSync(target, definitions, { encoding: "utf-8" });
225
- }
226
- function generateDefinitions() {
227
- return `
228
- /* eslint-disable */
229
- /* prettier-ignore */
230
- // This file has been automatically generated by Hybridly
231
- // Modifications will be discarded
232
-
233
- declare module 'hybridly' {
234
- export interface GlobalRouteCollection {
235
- url: '__URL__'
236
- routes: __ROUTES__
237
- }
238
- }
239
-
240
- export {}`;
241
- }
242
-
243
- const router = (options, config) => {
244
- const resolved = {
245
- php: "php",
246
- dts: ".hybridly/routes.d.ts",
247
- watch: [
248
- /routes\/.*\.php/
249
- ],
250
- ...options
251
- };
252
- let routingBeforeUpdate;
253
- async function sendRoutingUpdate(server, force = false) {
254
- const routing = await fetchRoutingFromArtisan(resolved) ?? routingBeforeUpdate;
255
- if (force || JSON.stringify(routing) !== JSON.stringify(routingBeforeUpdate)) {
256
- debug.router("Updating routes via HMR:", routing);
257
- server.ws.send({
258
- type: "custom",
259
- event: ROUTING_HMR_UPDATE_ROUTING,
260
- data: routing
261
- });
262
- write$1(resolved);
263
- routingBeforeUpdate = routing;
264
- }
265
- }
266
- return {
267
- name: ROUTING_PLUGIN_NAME,
268
- configureServer(server) {
269
- write$1(resolved);
270
- server.ws.on(ROUTING_HMR_QUERY_UPDATE_ROUTING, () => {
271
- sendRoutingUpdate(server, true);
272
- });
273
- server.watcher.on("change", async (path) => {
274
- if (!resolved.watch.some((regex) => regex.test(path))) {
275
- return;
276
- }
277
- sendRoutingUpdate(server);
278
- });
279
- },
280
- resolveId(id) {
281
- if (id === ROUTING_VIRTUAL_MODULE_ID) {
282
- return RESOLVED_ROUTING_VIRTUAL_MODULE_ID;
283
- }
284
- },
285
- async load(id) {
286
- if (id === RESOLVED_ROUTING_VIRTUAL_MODULE_ID) {
287
- const routing = await fetchRoutingFromArtisan(resolved);
288
- return getRouterClientCode(routing);
289
- }
290
- },
291
- async handleHotUpdate(ctx) {
292
- if (typeof resolved.dts === "string" && ctx.file.endsWith(resolved.dts)) {
293
- return [];
294
- }
295
- },
296
- transform() {
297
- write$1(resolved);
298
- }
299
- };
300
- };
301
-
302
312
  function getRunOptions(options) {
303
313
  if (options.run === false) {
304
314
  return [];
@@ -324,7 +334,7 @@ function getRunOptions(options) {
324
334
 
325
335
  function getLaravelOptions(options, config) {
326
336
  return {
327
- input: `${config.root}/application/main.ts`,
337
+ input: `${config.architecture.root}/application/main.ts`,
328
338
  ...options.laravel ?? {}
329
339
  };
330
340
  }
@@ -361,12 +371,9 @@ function getAutoImportsOptions(options, config) {
361
371
  vueTemplate: true,
362
372
  dts: ".hybridly/auto-imports.d.ts",
363
373
  dirs: [
364
- `${config.root}/utils`,
365
- `${config.root}/composables`,
366
- ...config.domains ? [
367
- `${config.root}/${config.domains}/**/utils`,
368
- `${config.root}/${config.domains}/**/composables`
369
- ] : []
374
+ `${config.architecture.root}/utils`,
375
+ `${config.architecture.root}/composables`,
376
+ ...config.components.directories.map((directory) => `${directory}/**/*.ts`)
370
377
  ],
371
378
  imports: [
372
379
  "vue",
@@ -402,18 +409,17 @@ function getVueComponentsOptions(options, config) {
402
409
  const customCollections = Array.isArray(options.customIcons) ? options.customIcons : options.customIcons?.collections ?? [];
403
410
  const overrideResolvers = options.overrideResolvers ? Array.isArray(options.overrideResolvers) ? options.overrideResolvers : [options.overrideResolvers] : false;
404
411
  const hasHeadlessUI = isPackageInstalled("@headlessui/vue");
405
- const isUsingDomains = config.domains !== false;
406
412
  return utils.merge(
407
413
  {
408
414
  dirs: [
409
- `./${config.root}/components`
415
+ `./${config.architecture.root}/components`
410
416
  ],
411
417
  directoryAsNamespace: true,
412
418
  dts: ".hybridly/components.d.ts",
413
419
  resolvers: overrideResolvers || [
414
420
  ...hasIcons ? [iconsResolver__default({ customCollections })] : [],
415
421
  ...hasHeadlessUI ? [resolvers.HeadlessUiResolver({ prefix: options?.vueComponents?.headlessUiPrefix ?? "Headless" })] : [],
416
- ...isUsingDomains ? [DomainComponentsResolver(config)] : [],
422
+ ProvidedComponentListResolver(config),
417
423
  HybridlyResolver(options.vueComponents?.linkName)
418
424
  ]
419
425
  },
@@ -421,36 +427,21 @@ function getVueComponentsOptions(options, config) {
421
427
  { overwriteArray: false }
422
428
  );
423
429
  }
424
- function resolveComponentUsingPaths(config, paths, name, resolve) {
425
- if (!config.domains) {
426
- return;
427
- }
428
- const kebabName = `${toKebabCase(name)}.vue`;
429
- for (const possiblePath of paths) {
430
- const domain = getSubstringBetween(possiblePath, `${resolve(config.root, config.domains)}/`, "/components/");
431
- if (!domain) {
432
- continue;
433
- }
434
- const kebabPath = toKebabCase(possiblePath.replaceAll("/", "-")).replaceAll("--", "-").replace("components-", "");
435
- if (kebabPath.endsWith(kebabName) && kebabName.includes(domain)) {
436
- return possiblePath;
430
+ function ProvidedComponentListResolver(config) {
431
+ function resolveComponentPath(name) {
432
+ const kebabName = toKebabCase(name);
433
+ const path = config.components.components.find((view) => {
434
+ const identifierAsComponentName = view.identifier.replace("::", "-").replace(".", "-");
435
+ return identifierAsComponentName === kebabName;
436
+ })?.path;
437
+ if (!path) {
438
+ return;
437
439
  }
440
+ return `~/${path}`;
438
441
  }
439
- }
440
- function DomainComponentsResolver(config) {
441
442
  return {
442
443
  type: "component",
443
- resolve: (name) => {
444
- if (config.domains === false) {
445
- return;
446
- }
447
- return resolveComponentUsingPaths(
448
- config,
449
- glob__default.sync(`${path__default.resolve(process.cwd(), config.root, config.domains)}/**/*.vue`),
450
- name,
451
- path__default.resolve
452
- );
453
- }
444
+ resolve: (name) => resolveComponentPath(name)
454
445
  };
455
446
  }
456
447
 
@@ -462,7 +453,7 @@ function getIconsOptions(options, config) {
462
453
  const customIconDirectoryName = resolved?.icons ?? "icons";
463
454
  const customCollections = Object.fromEntries(resolved?.collections?.map((collection) => [
464
455
  collection,
465
- loaders.FileSystemIconLoader(`./${config.root}/${customIconDirectoryName}/${collection}`)
456
+ loaders.FileSystemIconLoader(`./${config.architecture.root}/${customIconDirectoryName}/${collection}`)
466
457
  ]) ?? []);
467
458
  return {
468
459
  autoInstall: true,
@@ -494,96 +485,16 @@ function getVueOptions(options) {
494
485
  );
495
486
  }
496
487
 
497
- function generateTsConfig(options, config) {
498
- const tsconfig = {
499
- compilerOptions: {
500
- target: "esnext",
501
- module: "esnext",
502
- moduleResolution: "node",
503
- strict: true,
504
- jsx: "preserve",
505
- sourceMap: true,
506
- resolveJsonModule: true,
507
- esModuleInterop: true,
508
- allowSyntheticDefaultImports: true,
509
- lib: [
510
- "esnext",
511
- "dom"
512
- ],
513
- types: [
514
- "vite/client",
515
- "hybridly/client",
516
- ...options.icons !== false ? ["unplugin-icons/types/vue"] : []
517
- ],
518
- baseUrl: "..",
519
- paths: {
520
- "#/*": [
521
- ".hybridly/*"
522
- ],
523
- "~/*": [
524
- "./*"
525
- ],
526
- "@/*": [
527
- `./${config.root}/*`
528
- ]
529
- }
530
- },
531
- include: [
532
- `../${config.root}/**/*`,
533
- "./*"
534
- ],
535
- exclude: [
536
- "../public/**/*",
537
- "../node_modules",
538
- "../vendor"
539
- ]
540
- };
541
- write(JSON.stringify(tsconfig, null, 2), "tsconfig.json");
542
- }
543
- function generateLaravelIdeaHelper(config) {
544
- const ideJson = {
545
- $schema: "https://laravel-ide.com/schema/laravel-ide-v2.json",
546
- completions: [
547
- ...config.domains ? [] : [{
548
- complete: "directoryFiles",
549
- options: {
550
- directory: `/${config.root}/${config.pages}`,
551
- suffixToClear: ".vue"
552
- },
553
- condition: [
554
- {
555
- functionNames: ["hybridly"],
556
- parameters: [1]
557
- }
558
- ]
559
- }]
560
- ]
561
- };
562
- write(JSON.stringify(ideJson, null, 2), "ide.json");
563
- }
564
- function write(data, filename) {
565
- const hybridlyPath = path__default.resolve(process.cwd(), ".hybridly");
566
- if (!fs__default.existsSync(hybridlyPath)) {
567
- fs__default.mkdirSync(hybridlyPath);
568
- }
569
- fs__default.writeFileSync(path__default.resolve(hybridlyPath, filename), data, {
570
- encoding: "utf-8"
571
- });
572
- }
573
-
574
488
  async function plugin(options = {}) {
575
- const config$1 = await config.loadHybridlyConfig();
576
- generateTsConfig(options, config$1);
577
- generateLaravelIdeaHelper(config$1);
489
+ const config = await loadConfiguration(options);
578
490
  return [
579
- initialize(options, config$1),
580
- layout(options, config$1),
581
- router(options),
582
- options.laravel !== false && laravel__default(getLaravelOptions(options, config$1)),
491
+ initialize(options, config),
492
+ layout(options, config),
493
+ options.laravel !== false && laravel__default(getLaravelOptions(options, config)),
583
494
  options.run !== false && run__default(getRunOptions(options)),
584
- options.vueComponents !== false && vueComponents__default(getVueComponentsOptions(options, config$1)),
585
- options.autoImports !== false && autoimport__default(getAutoImportsOptions(options, config$1)),
586
- options.icons !== false && icons__default(getIconsOptions(options, config$1)),
495
+ options.vueComponents !== false && vueComponents__default(getVueComponentsOptions(options, config)),
496
+ options.autoImports !== false && autoimport__default(getAutoImportsOptions(options, config)),
497
+ options.icons !== false && icons__default(getIconsOptions(options, config)),
587
498
  options.vue !== false && vue__default(getVueOptions(options))
588
499
  ];
589
500
  }
@@ -592,4 +503,3 @@ exports.HybridlyImports = HybridlyImports;
592
503
  exports.HybridlyResolver = HybridlyResolver;
593
504
  exports["default"] = plugin;
594
505
  exports.layout = layout;
595
- exports.router = router;