@hybridly/vite 0.3.0 → 0.4.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 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,173 @@ 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.architecture.root}/**/*`,
90
+ "./*"
91
+ ],
92
+ exclude: [
93
+ "../public/**/*",
94
+ "../node_modules",
95
+ "../vendor"
96
+ ]
97
+ };
98
+ write(JSON.stringify(tsconfig, null, 2), "tsconfig.json");
99
+ }
100
+ function generateLaravelIdeaHelper(config) {
101
+ const ideJson = {
102
+ $schema: "https://laravel-ide.com/schema/laravel-ide-v2.json",
103
+ completions: [
104
+ {
105
+ complete: "staticStrings",
106
+ options: {
107
+ strings: config.components.views.map(({ identifier }) => identifier)
108
+ },
109
+ condition: [
110
+ {
111
+ functionNames: ["hybridly"],
112
+ parameters: [1]
113
+ }
114
+ ]
115
+ }
116
+ ]
117
+ };
118
+ write(JSON.stringify(ideJson, null, 2), "ide.json");
119
+ }
120
+ async function generateRouteDefinitionFile(options, config) {
121
+ const routing = config?.routing;
122
+ if (!routing) {
123
+ return;
124
+ }
125
+ debug.config("Writing types for routing:", routing);
126
+ const routes = Object.fromEntries(Object.entries(routing.routes).map(([key, route]) => {
127
+ const bindings = route.bindings ? Object.fromEntries(Object.entries(route.bindings).map(([key2]) => [key2, "__key_placeholder__"])) : void 0;
128
+ return [key, {
129
+ ...route.uri ? { uri: route.uri } : {},
130
+ ...route.domain ? { domain: route.domain } : {},
131
+ ...route.wheres ? { wheres: route.wheres } : {},
132
+ ...route.bindings ? { bindings } : {}
133
+ }];
134
+ }));
135
+ const definitions = `
136
+ /* eslint-disable */
137
+ /* prettier-ignore */
138
+ // This file has been automatically generated by Hybridly
139
+ // Modifications will be discarded
140
+
141
+ declare module 'hybridly' {
142
+ export interface GlobalRouteCollection {
143
+ url: '__URL__'
144
+ routes: __ROUTES__
145
+ }
146
+ }
147
+
148
+ export {}
149
+ `.replace("__URL__", routing?.url ?? "").replace("__ROUTES__", JSON.stringify(routes).replaceAll('"__key_placeholder__"', "any"));
150
+ write(definitions, "routes.d.ts");
151
+ }
152
+ function write(data, filename) {
153
+ const hybridlyPath = path__default.resolve(process.cwd(), ".hybridly");
154
+ if (!fs__default.existsSync(hybridlyPath)) {
155
+ fs__default.mkdirSync(hybridlyPath);
156
+ }
157
+ fs__default.writeFileSync(path__default.resolve(hybridlyPath, filename), data, {
158
+ encoding: "utf-8"
159
+ });
160
+ }
161
+
162
+ const shell = node_util.promisify(node_child_process.exec);
163
+ async function loadConfiguration(options) {
164
+ try {
165
+ const php = options.php ?? process.env.PHP_EXECUTABLE_PATH ?? "php";
166
+ const { stdout } = await shell(`${php} artisan hybridly:config`);
167
+ return JSON.parse(stdout);
168
+ } catch (e) {
169
+ console.error("Could not load configuration from [php artisan].");
170
+ throw e;
171
+ }
172
+ }
173
+
174
+ function getClientCode(config) {
175
+ const paths = config.components.views.map(({ path }) => `"~/${path}"`).join(",");
176
+ return `
177
+ import { initializeHybridly as init } from 'hybridly/vue'
178
+
179
+ export function initializeHybridly(config) {
180
+ return init({
181
+ ...${JSON.stringify(config)},
182
+ imported: import.meta.glob([${paths}], { eager: ${config.components.eager ?? true} }),
183
+ ...config,
184
+ })
185
+ }
186
+ `;
187
+ }
188
+
50
189
  const initialize = (options, config) => {
190
+ generateTsConfig(options, config);
191
+ generateLaravelIdeaHelper(config);
192
+ generateRouteDefinitionFile(options, config);
51
193
  return {
52
194
  name: CONFIG_PLUGIN_NAME,
53
195
  enforce: "pre",
@@ -55,7 +197,7 @@ const initialize = (options, config) => {
55
197
  return {
56
198
  resolve: {
57
199
  alias: {
58
- "@": path__default.join(process.cwd(), config.root),
200
+ "@": path__default.join(process.cwd(), config.architecture.root),
59
201
  "#": path__default.join(process.cwd(), ".hybridly"),
60
202
  "~": path__default.join(process.cwd())
61
203
  }
@@ -63,19 +205,36 @@ const initialize = (options, config) => {
63
205
  };
64
206
  },
65
207
  configureServer(server) {
66
- const reloadServer = (file) => {
67
- if (!file.endsWith("hybridly.config.ts")) {
208
+ let restarting = false;
209
+ async function forceRestart(message) {
210
+ if (restarting) {
68
211
  return;
69
212
  }
70
- server.config.logger.info("Hybridly configuration file was changed: forcing a server restart.", {
213
+ restarting = true;
214
+ server.config.logger.info(`${message}: forcing a server restart.`, {
71
215
  clear: server.config.clearScreen,
72
216
  timestamp: true
73
217
  });
74
- server?.restart();
75
- };
76
- server.watcher.on("add", reloadServer);
77
- server.watcher.on("change", reloadServer);
78
- server.watcher.on("unlink", reloadServer);
218
+ return await server?.restart();
219
+ }
220
+ async function handleFileChange(file) {
221
+ if (file.endsWith("config/hybridly.php")) {
222
+ return await forceRestart("Configuration file changed");
223
+ }
224
+ if (/routes\/.*\.php/.test(file)) {
225
+ return await forceRestart("Routing changed");
226
+ }
227
+ if (/.*\.vue$/.test(file)) {
228
+ const updatedConfig = await loadConfiguration(options);
229
+ const pagesOrLayoutsChanged = didPagesOrLayoutsChange(updatedConfig, config);
230
+ if (pagesOrLayoutsChanged) {
231
+ return await forceRestart("Page or layout changed");
232
+ }
233
+ }
234
+ }
235
+ server.watcher.on("add", handleFileChange);
236
+ server.watcher.on("change", handleFileChange);
237
+ server.watcher.on("unlink", handleFileChange);
79
238
  },
80
239
  resolveId(id) {
81
240
  if (id === CONFIG_VIRTUAL_MODULE_ID) {
@@ -84,60 +243,30 @@ const initialize = (options, config) => {
84
243
  },
85
244
  async load(id) {
86
245
  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
- `;
246
+ return getClientCode(config);
247
+ }
248
+ },
249
+ async handleHotUpdate(ctx) {
250
+ if (ctx.file.includes(".hybridly")) {
251
+ return [];
99
252
  }
100
253
  }
101
254
  };
102
255
  };
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;
256
+ function didPagesOrLayoutsChange(updatedConfig, previousConfig) {
257
+ if (!previousConfig) {
258
+ return false;
123
259
  }
124
- return str.substring(startIndex + start.length, endIndex);
260
+ return JSON.stringify(updatedConfig.components.views) !== JSON.stringify(previousConfig.components.views) || JSON.stringify(updatedConfig.components.layouts) !== JSON.stringify(previousConfig.components.layouts);
125
261
  }
126
262
 
127
263
  const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\ )?)+)['"] *)?>/;
128
264
  const TYPESCRIPT_REGEX = /lang=['"]ts['"]/;
129
- const layout = (options, config$1) => {
265
+ const layout = (options, config) => {
130
266
  const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".vue", "") ?? "default";
131
- const layoutsDirectory = path__default.resolve(process.cwd(), config$1.root, config$1.layouts);
132
267
  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
268
  debug.layout("Resolved options:", {
139
- defaultLayoutName,
140
- layoutsDirectory
269
+ defaultLayoutName
141
270
  });
142
271
  return {
143
272
  name: LAYOUT_PLUGIN_NAME,
@@ -153,7 +282,7 @@ const layout = (options, config$1) => {
153
282
  const exports = layouts.map((_2, i) => importName(i));
154
283
  const imports = layouts.reduce((imports2, layoutName2, i) => `
155
284
  ${imports2}
156
- import ${importName(i)} from '${resolveLayoutPath(layoutName2)}';
285
+ import ${importName(i)} from '${resolveLayoutImportPath(layoutName2, config)}';
157
286
  `, "").trim();
158
287
  debug.layout(`Resolved layouts "${layouts.join(", ")}":`, {
159
288
  sourceFile: id,
@@ -171,134 +300,14 @@ const layout = (options, config$1) => {
171
300
  }
172
301
  };
173
302
  };
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 {
303
+ function resolveLayoutImportPath(name, config) {
304
+ const { path } = config.components.layouts.find((layout) => layout.identifier === name) ?? {};
305
+ if (!path) {
306
+ throw new Error(`Layout [${name}] could not be found.`);
202
307
  }
308
+ return `~/${path}`;
203
309
  }
204
310
 
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
311
  function getRunOptions(options) {
303
312
  if (options.run === false) {
304
313
  return [];
@@ -324,7 +333,7 @@ function getRunOptions(options) {
324
333
 
325
334
  function getLaravelOptions(options, config) {
326
335
  return {
327
- input: `${config.root}/application/main.ts`,
336
+ input: `${config.architecture.root}/application/main.ts`,
328
337
  ...options.laravel ?? {}
329
338
  };
330
339
  }
@@ -361,12 +370,9 @@ function getAutoImportsOptions(options, config) {
361
370
  vueTemplate: true,
362
371
  dts: ".hybridly/auto-imports.d.ts",
363
372
  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
- ] : []
373
+ `${config.architecture.root}/utils`,
374
+ `${config.architecture.root}/composables`,
375
+ ...config.components.directories.map((directory) => `${directory}/**/*.ts`)
370
376
  ],
371
377
  imports: [
372
378
  "vue",
@@ -402,18 +408,17 @@ function getVueComponentsOptions(options, config) {
402
408
  const customCollections = Array.isArray(options.customIcons) ? options.customIcons : options.customIcons?.collections ?? [];
403
409
  const overrideResolvers = options.overrideResolvers ? Array.isArray(options.overrideResolvers) ? options.overrideResolvers : [options.overrideResolvers] : false;
404
410
  const hasHeadlessUI = isPackageInstalled("@headlessui/vue");
405
- const isUsingDomains = config.domains !== false;
406
411
  return utils.merge(
407
412
  {
408
413
  dirs: [
409
- `./${config.root}/components`
414
+ `./${config.architecture.root}/components`
410
415
  ],
411
416
  directoryAsNamespace: true,
412
417
  dts: ".hybridly/components.d.ts",
413
418
  resolvers: overrideResolvers || [
414
419
  ...hasIcons ? [iconsResolver__default({ customCollections })] : [],
415
420
  ...hasHeadlessUI ? [resolvers.HeadlessUiResolver({ prefix: options?.vueComponents?.headlessUiPrefix ?? "Headless" })] : [],
416
- ...isUsingDomains ? [DomainComponentsResolver(config)] : [],
421
+ ProvidedComponentListResolver(config),
417
422
  HybridlyResolver(options.vueComponents?.linkName)
418
423
  ]
419
424
  },
@@ -421,36 +426,21 @@ function getVueComponentsOptions(options, config) {
421
426
  { overwriteArray: false }
422
427
  );
423
428
  }
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;
429
+ function ProvidedComponentListResolver(config) {
430
+ function resolveComponentPath(name) {
431
+ const kebabName = toKebabCase(name);
432
+ const path = config.components.components.find((view) => {
433
+ const identifierAsComponentName = view.identifier.replace("::", "-").replace(".", "-");
434
+ return identifierAsComponentName === kebabName;
435
+ })?.path;
436
+ if (!path) {
437
+ return;
437
438
  }
439
+ return `~/${path}`;
438
440
  }
439
- }
440
- function DomainComponentsResolver(config) {
441
441
  return {
442
442
  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
- }
443
+ resolve: (name) => resolveComponentPath(name)
454
444
  };
455
445
  }
456
446
 
@@ -462,7 +452,7 @@ function getIconsOptions(options, config) {
462
452
  const customIconDirectoryName = resolved?.icons ?? "icons";
463
453
  const customCollections = Object.fromEntries(resolved?.collections?.map((collection) => [
464
454
  collection,
465
- loaders.FileSystemIconLoader(`./${config.root}/${customIconDirectoryName}/${collection}`)
455
+ loaders.FileSystemIconLoader(`./${config.architecture.root}/${customIconDirectoryName}/${collection}`)
466
456
  ]) ?? []);
467
457
  return {
468
458
  autoInstall: true,
@@ -494,96 +484,16 @@ function getVueOptions(options) {
494
484
  );
495
485
  }
496
486
 
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
487
  async function plugin(options = {}) {
575
- const config$1 = await config.loadHybridlyConfig();
576
- generateTsConfig(options, config$1);
577
- generateLaravelIdeaHelper(config$1);
488
+ const config = await loadConfiguration(options);
578
489
  return [
579
- initialize(options, config$1),
580
- layout(options, config$1),
581
- router(options),
582
- options.laravel !== false && laravel__default(getLaravelOptions(options, config$1)),
490
+ initialize(options, config),
491
+ layout(options, config),
492
+ options.laravel !== false && laravel__default(getLaravelOptions(options, config)),
583
493
  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)),
494
+ options.vueComponents !== false && vueComponents__default(getVueComponentsOptions(options, config)),
495
+ options.autoImports !== false && autoimport__default(getAutoImportsOptions(options, config)),
496
+ options.icons !== false && icons__default(getIconsOptions(options, config)),
587
497
  options.vue !== false && vue__default(getVueOptions(options))
588
498
  ];
589
499
  }
@@ -592,4 +502,3 @@ exports.HybridlyImports = HybridlyImports;
592
502
  exports.HybridlyResolver = HybridlyResolver;
593
503
  exports["default"] = plugin;
594
504
  exports.layout = layout;
595
- exports.router = router;