@hybridly/vite 0.10.0-beta.3 → 0.10.0-beta.31

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.mjs CHANGED
@@ -1,316 +1,77 @@
1
1
  import { r as __toESM } from "./_chunks/rolldown-runtime.mjs";
2
- import { t as require_src } from "./_chunks/libs/debug.mjs";
3
2
  import { t as require_cjs } from "./_chunks/libs/deepmerge.mjs";
4
- import { t as isPlainObject } from "./_chunks/libs/is-plain-object.mjs";
5
- import { t as require_lodash } from "./_chunks/libs/lodash.clonedeep.mjs";
6
- import fs from "node:fs";
3
+ import { t as isPlainObject } from "./_chunks/libs/es-toolkit.mjs";
4
+ import "./_chunks/libs/@clickbar/dot-diver.mjs";
5
+ import { t as require_src } from "./_chunks/libs/debug.mjs";
7
6
  import path from "node:path";
8
- import colors from "picocolors";
9
- import { loadEnv } from "vite";
10
- import "node:url";
11
- import os from "node:os";
7
+ import fs from "node:fs";
12
8
  import { exec } from "node:child_process";
13
9
  import { promisify } from "node:util";
14
- import "local-pkg";
15
- import MagicString from "magic-string";
16
- import run from "vite-plugin-run";
10
+ import { loadEnv } from "vite";
11
+ import { run } from "vite-plugin-run";
17
12
  import vue from "@vitejs/plugin-vue";
18
-
19
- //#region src/config/env.ts
20
- let phpExecutable;
21
- let devEnvironment;
22
- /**
23
- * Gets all environment variables, including `.env` ones.
24
- */
25
- function getEnv() {
26
- return {
27
- ...process.env,
28
- ...loadEnv("mock", process.cwd(), "")
29
- };
30
- }
31
- async function getPhpExecutable() {
32
- if (phpExecutable) return phpExecutable;
33
- const env = getEnv();
34
- const php = (env.PHP_EXECUTABLE_PATH ?? "php").split(" ");
35
- if (!env.PHP_EXECUTABLE_PATH) {
36
- const devEnvironment = await determineDevEnvironment();
37
- if (devEnvironment === "ddev") php.unshift("ddev");
38
- else if (devEnvironment === "lando") php.unshift("lando");
39
- }
40
- return phpExecutable = php;
41
- }
42
- async function determineDevEnvironment() {
43
- if (devEnvironment) return devEnvironment;
44
- if (fs.existsSync(`${process.cwd()}/.ddev`)) devEnvironment = "ddev";
45
- else if (fs.existsSync(`${process.cwd()}/.lando.yml`)) devEnvironment = "lando";
46
- else devEnvironment = "native";
47
- return devEnvironment;
48
- }
49
-
50
- //#endregion
51
- //#region src/laravel/utils.ts
52
- function isIpv6(address) {
53
- return address.family === "IPv6" || address.family === 6;
54
- }
55
-
56
- //#endregion
57
- //#region src/laravel/dev-env.ts
58
- /**
59
- * Resolves the path to the Herd or Valet configuration directory.
60
- */
61
- function determineDevelopmentEnvironmentConfigPath() {
62
- const herdConfigPath = path.resolve(os.homedir(), "Library", "Application Support", "Herd", "config", "valet");
63
- if (fs.existsSync(herdConfigPath)) return herdConfigPath;
64
- return path.resolve(os.homedir(), ".config", "valet");
65
- }
66
- /**
67
- * Resolves the Herd or Valet host for the current directory.
68
- */
69
- function resolveDevelopmentEnvironmentHost(configPath) {
70
- const configFile = path.resolve(configPath, "config.json");
71
- if (!fs.existsSync(configFile)) return;
72
- const config = JSON.parse(fs.readFileSync(configFile, "utf-8"));
73
- return `${path.basename(process.cwd())}.${config.tld}`;
74
- }
75
- /**
76
- * Resolves the Herd or Valet server config for the given host.
77
- */
78
- function resolveDevelopmentEnvironmentServerConfig() {
79
- const configPath = determineDevelopmentEnvironmentConfigPath();
80
- const host = resolveDevelopmentEnvironmentHost(configPath);
81
- if (!host) return;
82
- const keyPath = path.resolve(configPath, "Certificates", `${host}.key`);
83
- const certPath = path.resolve(configPath, "Certificates", `${host}.crt`);
84
- if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) return;
85
- return {
86
- hmr: { host },
87
- host,
88
- https: {
89
- key: fs.readFileSync(keyPath),
90
- cert: fs.readFileSync(certPath)
91
- }
92
- };
93
- }
94
- /**
95
- * Resolves the server config from the environment.
96
- */
97
- function resolveEnvironmentServerConfig(env) {
98
- if (!env.VITE_DEV_SERVER_KEY && !env.VITE_DEV_SERVER_CERT) return;
99
- if (!fs.existsSync(env.VITE_DEV_SERVER_KEY) || !fs.existsSync(env.VITE_DEV_SERVER_CERT)) throw new Error(`Unable to find the certificate files specified in your environment. Ensure you have correctly configured VITE_DEV_SERVER_KEY: [${env.VITE_DEV_SERVER_KEY}] and VITE_DEV_SERVER_CERT: [${env.VITE_DEV_SERVER_CERT}].`);
100
- const host = resolveHostFromEnv(env);
101
- return {
102
- hmr: { host },
103
- host,
104
- https: {
105
- key: fs.readFileSync(env.VITE_DEV_SERVER_KEY),
106
- cert: fs.readFileSync(env.VITE_DEV_SERVER_CERT)
107
- }
108
- };
109
- }
110
- /**
111
- * Resolve the host name from the environment.
112
- */
113
- function resolveHostFromEnv(env) {
114
- if (env.VITE_DEV_SERVER_KEY) return env.VITE_DEV_SERVER_KEY;
115
- try {
116
- return new URL(env.APP_URL).host;
117
- } catch {
118
- throw new Error(`Unable to determine the host from the environment's APP_URL: [${env.APP_URL}].`);
119
- }
120
- }
121
-
122
- //#endregion
123
- //#region src/laravel/index.ts
124
- let exitHandlersBound = false;
125
- function laravel(options, hybridlyConfig) {
126
- let viteDevServerUrl;
127
- let resolvedConfig;
128
- let userConfig;
129
- const publicDirectory = "public";
130
- const buildDirectory = "build";
131
- const hotFile = path.join(publicDirectory, "hot");
132
- return {
133
- name: "hybridly:laravel",
134
- enforce: "post",
135
- config: (config, { command, mode }) => {
136
- userConfig = config;
137
- const ssr = !!userConfig.build?.ssr;
138
- const env = loadEnv(mode, userConfig.envDir || process.cwd(), "");
139
- const assetUrl = env.ASSET_URL ?? "";
140
- const base = `${assetUrl + (!assetUrl.endsWith("/") ? "/" : "") + buildDirectory}/`;
141
- const serverConfig = command === "serve" ? resolveEnvironmentServerConfig(env) ?? resolveDevelopmentEnvironmentServerConfig() : void 0;
142
- ensureCommandShouldRunInEnvironment(command, env);
143
- return {
144
- base: userConfig.base ?? (command === "build" ? base : ""),
145
- publicDir: userConfig.publicDir ?? false,
146
- build: {
147
- manifest: ssr === true ? false : userConfig.build?.manifest ?? "manifest.json",
148
- outDir: userConfig.build?.outDir ?? path.join(publicDirectory, buildDirectory),
149
- rollupOptions: { input: resolveInput(config, hybridlyConfig, ssr) },
150
- assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0
151
- },
152
- server: {
153
- origin: userConfig.server?.origin ?? "http://__laravel_vite_placeholder__.test",
154
- cors: userConfig.server?.cors ?? { origin: userConfig.server?.origin ?? [
155
- /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/,
156
- ...env.APP_URL ? [env.APP_URL] : [],
157
- /^https?:\/\/.*\.test(:\d+)?$/
158
- ] },
159
- ...process.env.LARAVEL_SAIL ? {
160
- host: userConfig.server?.host ?? "0.0.0.0",
161
- port: userConfig.server?.port ?? (env.VITE_PORT ? Number.parseInt(env.VITE_PORT) : 5173),
162
- strictPort: userConfig.server?.strictPort ?? true
163
- } : void 0,
164
- ...serverConfig ? {
165
- host: userConfig.server?.host ?? serverConfig.host,
166
- hmr: userConfig.server?.hmr === false ? false : {
167
- ...serverConfig.hmr,
168
- ...userConfig.server?.hmr === true ? {} : userConfig.server?.hmr
169
- },
170
- https: userConfig.server?.https ?? serverConfig.https
171
- } : void 0
172
- }
173
- };
174
- },
175
- configResolved(config) {
176
- resolvedConfig = config;
177
- },
178
- transform(code) {
179
- if (resolvedConfig.command === "serve") return code.replace(/http:\/\/__laravel_vite_placeholder__\.test/g, viteDevServerUrl);
180
- },
181
- configureServer(server) {
182
- const envDir = resolvedConfig.envDir || process.cwd();
183
- const appUrl = loadEnv(resolvedConfig.mode, envDir, "APP_URL").APP_URL ?? "undefined";
184
- if (!["test", "ci"].includes(resolvedConfig.mode)) server.httpServer?.once("listening", async () => {
185
- const address = server.httpServer?.address();
186
- const isAddressInfo = (x) => typeof x === "object";
187
- if (isAddressInfo(address)) {
188
- viteDevServerUrl = resolveDevServerUrl(address, server.config, userConfig);
189
- fs.writeFileSync(hotFile, `${viteDevServerUrl}${server.config.base.replace(/\/$/, "")}`);
190
- if (!hybridlyConfig.versions) return;
191
- let registered = `${colors.bold(hybridlyConfig.components.views.length)} ${colors.dim("views")}, `;
192
- registered += `${colors.bold(hybridlyConfig.components.layouts.length)} ${colors.dim("layouts")}, `;
193
- const latest = hybridlyConfig.versions.is_latest ? "" : colors.dim(`(${colors.yellow(`${hybridlyConfig.versions.latest} is available`)})`);
194
- let version = `${colors.yellow(`v${hybridlyConfig.versions.composer}`)} ${colors.dim("(composer)")}, `;
195
- version += `${colors.yellow(`v${hybridlyConfig.versions.npm}`)} ${colors.dim("(npm)")}`;
196
- version += ` — ${colors.yellow("this may lead to undefined behavior")}`;
197
- const devEnvironment = await determineDevEnvironment();
198
- setTimeout(() => {
199
- server.config.logger.info(`\n ${colors.magenta(`${colors.bold("HYBRIDLY")} v${hybridlyConfig.versions.composer}`)} ${latest}`);
200
- server.config.logger.info("");
201
- server.config.logger.info(` ${colors.green("➜")} ${colors.bold("URL")}: ${colors.cyan(hybridlyConfig.routing.url)}`);
202
- server.config.logger.info(` ${colors.green("➜")} ${colors.bold("Registered")}: ${registered}`);
203
- if (devEnvironment !== "native") server.config.logger.info(` ${colors.green("➜")} ${colors.bold("Development environment")}: ${colors.cyan(devEnvironment)}`);
204
- if (hybridlyConfig.versions.composer !== hybridlyConfig.versions.npm) server.config.logger.info(` ${colors.yellow("➜")} ${colors.bold("Version mismatch")}: ${version}`);
205
- }, 100);
206
- }
207
- });
208
- if (!exitHandlersBound) {
209
- function clean() {
210
- if (fs.existsSync(hotFile)) fs.rmSync(hotFile);
211
- }
212
- process.on("exit", clean);
213
- process.on("SIGINT", () => process.exit());
214
- process.on("SIGTERM", () => process.exit());
215
- process.on("SIGHUP", () => process.exit());
216
- exitHandlersBound = true;
217
- }
218
- return () => server.middlewares.use((req, res, next) => {
219
- if (req.url === "/index.html") {
220
- res.writeHead(302, { Location: appUrl });
221
- res.end();
222
- }
223
- next();
224
- });
225
- }
226
- };
227
- }
228
- /**
229
- * Validates the command can run in the given environment.
230
- */
231
- function ensureCommandShouldRunInEnvironment(command, env) {
232
- if (command === "build" || env.LARAVEL_BYPASS_ENV_CHECK === "1" || !!env.TEST || !!env.VITEST) return;
233
- if (typeof env.LARAVEL_VAPOR !== "undefined") throw new TypeError("You should not run the Vite HMR server on Vapor. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
234
- if (typeof env.LARAVEL_FORGE !== "undefined") throw new TypeError("You should not run the Vite HMR server in your Forge deployment script. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
235
- if (typeof env.LARAVEL_ENVOYER !== "undefined") throw new TypeError("You should not run the Vite HMR server in your Envoyer hook. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
236
- if (typeof env.CI !== "undefined") throw new TypeError("You should not run the Vite HMR server in CI environments. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
237
- }
238
- /**
239
- * Resolves input files.
240
- */
241
- function resolveInput(userConfig, hybridlyConfig, _ssr) {
242
- return userConfig.build?.rollupOptions?.input ?? hybridlyConfig.architecture.application_main_path;
243
- }
244
- /**
245
- * Resolves the dev server URL from the server address and configuration.
246
- */
247
- function resolveDevServerUrl(address, config, userConfig) {
248
- const configHmrProtocol = typeof config.server.hmr === "object" ? config.server.hmr.protocol : null;
249
- const clientProtocol = configHmrProtocol ? configHmrProtocol === "wss" ? "https" : "http" : null;
250
- const serverProtocol = config.server.https ? "https" : "http";
251
- const protocol = clientProtocol ?? serverProtocol;
252
- const configHmrHost = typeof config.server.hmr === "object" ? config.server.hmr.host : null;
253
- const configHost = typeof config.server.host === "string" ? config.server.host : null;
254
- const sailHost = process.env.LARAVEL_SAIL && !userConfig.server?.host ? "localhost" : null;
255
- const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address;
256
- return `${protocol}://${configHmrHost ?? sailHost ?? configHost ?? serverAddress}:${(typeof config.server.hmr === "object" ? config.server.hmr.clientPort : null) ?? address.port}`;
257
- }
258
-
259
- //#endregion
13
+ import colors from "picocolors";
14
+ import os from "node:os";
15
+ import MagicString from "magic-string";
260
16
  //#region src/constants.ts
261
17
  const LAYOUT_PLUGIN_NAME = "vite:hybridly:layout";
262
18
  const CONFIG_PLUGIN_NAME = "vite:hybridly:config";
263
- const CONFIG_VIRTUAL_MODULE_ID = "virtual:hybridly/config";
264
- const RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\0${CONFIG_VIRTUAL_MODULE_ID}`;
265
-
266
- //#endregion
267
- //#region src/utils.ts
268
- var import_src = /* @__PURE__ */ __toESM(require_src(), 1);
269
- const execSync = promisify(exec);
270
- const debug = {
271
- config: (0, import_src.default)(CONFIG_PLUGIN_NAME),
272
- layout: (0, import_src.default)(LAYOUT_PLUGIN_NAME)
273
- };
274
-
19
+ const RESOLVED_CONFIG_VIRTUAL_MODULE_ID = `\0virtual:hybridly/config`;
275
20
  //#endregion
276
21
  //#region src/typegen/index.ts
277
- function generateTsConfig(options, config) {
22
+ const COMPILER_OPTIONS = {
23
+ target: "esnext",
24
+ module: "esnext",
25
+ moduleResolution: "bundler",
26
+ strict: true,
27
+ skipLibCheck: true,
28
+ sourceMap: true,
29
+ resolveJsonModule: true,
30
+ esModuleInterop: true,
31
+ rootDir: "../",
32
+ noImplicitThis: true,
33
+ noUncheckedIndexedAccess: true,
34
+ allowSyntheticDefaultImports: true
35
+ };
36
+ function generateAppTsConfig(options, config) {
278
37
  const tsconfig = {
279
38
  compilerOptions: {
280
- target: "esnext",
281
- module: "esnext",
282
- moduleResolution: "bundler",
283
- strict: true,
284
- skipLibCheck: true,
39
+ ...COMPILER_OPTIONS,
285
40
  jsx: "preserve",
286
- sourceMap: true,
287
- resolveJsonModule: true,
288
- esModuleInterop: true,
289
- allowSyntheticDefaultImports: true,
290
- lib: ["esnext", "dom"],
41
+ lib: [
42
+ "esnext",
43
+ "dom",
44
+ "dom.iterable"
45
+ ],
291
46
  types: [
292
47
  "vite/client",
293
48
  "hybridly/client",
294
49
  ...options.tsconfig?.types ?? []
295
50
  ],
296
- baseUrl: "..",
297
51
  paths: {
298
- "#/*": [".hybridly/*"],
299
- "~/*": ["./*"],
300
- "@/*": [`./${config.architecture.root_directory}/*`]
52
+ "#/*": ["./*"],
53
+ "~/*": ["../*"],
54
+ "@/*": [`../${config.architecture.root_directory}/*`]
301
55
  }
302
56
  },
303
57
  include: [
58
+ "./*.d.ts",
59
+ ...config.architecture.namespaces.flatMap((directory) => `../${directory}`),
304
60
  ...config.components.views.map(({ path }) => `../${path}`),
305
61
  ...config.components.layouts.map(({ path }) => `../${path}`),
306
- `../${config.architecture.root_directory}/**/*`,
307
- "./**/*.d.ts",
308
62
  ...options.tsconfig?.include ?? []
309
63
  ],
310
64
  exclude: ["../public/**/*", ...options.tsconfig?.exclude ?? []]
311
65
  };
312
66
  write(JSON.stringify(tsconfig, null, 2), "tsconfig.json");
313
67
  }
68
+ function generateNodeTsConfig(options, config) {
69
+ const tsconfig = {
70
+ compilerOptions: COMPILER_OPTIONS,
71
+ include: ["../*.config.ts"]
72
+ };
73
+ write(JSON.stringify(tsconfig, null, 2), "tsconfig.node.json");
74
+ }
314
75
  function generateLaravelIdeaHelper(config) {
315
76
  const ideJson = {
316
77
  $schema: "https://laravel-ide.com/schema/laravel-ide-v2.json",
@@ -348,58 +109,13 @@ declare module 'vue' {
348
109
  layout?: Component | Component[] | ((r: typeof h, view: VNode, dialog: VNode, properties: Record<string, any>) => VNode | VNode[])
349
110
  }
350
111
  }
351
- `, "vue-extension.d.ts");
352
- }
353
- async function generateRouteDefinitionFile(options, config) {
354
- const routing = config?.routing;
355
- if (!routing) return;
356
- debug.config("Writing types for routing:", routing);
357
- const routes = Object.fromEntries(Object.entries(routing.routes).map(([key, route]) => {
358
- const bindings = route.bindings ? Object.fromEntries(Object.entries(route.bindings).map(([key]) => [key, "__key_placeholder__"])) : void 0;
359
- return [key, {
360
- ...route.uri ? { uri: route.uri } : {},
361
- ...route.domain ? { domain: route.domain } : {},
362
- ...route.wheres ? { wheres: route.wheres } : {},
363
- ...route.bindings ? { bindings } : {}
364
- }];
365
- }));
366
- write(`
367
- /* eslint-disable */
368
- /* prettier-ignore */
369
- // This file has been automatically generated by Hybridly
370
- // Modifications will be discarded
371
-
372
- declare module 'hybridly' {
373
- export interface GlobalRouteCollection {
374
- url: '__URL__'
375
- routes: __ROUTES__
376
- }
377
- }
378
-
379
- export {}
380
- `.replace("__URL__", routing?.url ?? "").replace("__ROUTES__", JSON.stringify(routes).replaceAll("\"__key_placeholder__\"", "any")), "routes.d.ts");
381
- }
382
- function write(data, filename) {
383
- const hybridlyPath = path.resolve(process.cwd(), ".hybridly");
384
- if (!fs.existsSync(hybridlyPath)) fs.mkdirSync(hybridlyPath);
385
- fs.writeFileSync(path.resolve(hybridlyPath, filename), data, { encoding: "utf-8" });
386
- }
387
-
388
- //#endregion
389
- //#region src/config/load.ts
390
- async function loadConfiguration() {
391
- try {
392
- const { stdout } = await execSync(`${(await getPhpExecutable()).join(" ")} artisan hybridly:config`);
393
- return JSON.parse(stdout);
394
- } catch (e) {
395
- console.error("Could not load configuration from [php artisan hybridly:config].");
396
- if (e.stdout) console.error(e.stdout);
397
- if (await determineDevEnvironment() === "ddev") console.error("This is possibly caused by not starting ddev first.");
398
- else if (await determineDevEnvironment() === "lando") console.error("This is possibly caused by not starting lando first.");
399
- throw e;
400
- }
401
- }
402
-
112
+ `, "vue-extension.d.ts");
113
+ }
114
+ function write(data, filename) {
115
+ const hybridlyPath = path.resolve(process.cwd(), ".hybridly");
116
+ if (!fs.existsSync(hybridlyPath)) fs.mkdirSync(hybridlyPath);
117
+ fs.writeFileSync(path.resolve(hybridlyPath, filename), data, { encoding: "utf-8" });
118
+ }
403
119
  //#endregion
404
120
  //#region src/config/client.ts
405
121
  function getClientCode$1(config) {
@@ -416,13 +132,60 @@ function getClientCode$1(config) {
416
132
  }
417
133
  `;
418
134
  }
419
-
135
+ //#endregion
136
+ //#region src/utils.ts
137
+ const execSync = promisify(exec);
138
+ //#endregion
139
+ //#region src/config/env.ts
140
+ let phpExecutable;
141
+ let devEnvironment;
142
+ /**
143
+ * Gets all environment variables, including `.env` ones.
144
+ */
145
+ function getEnv() {
146
+ return {
147
+ ...process.env,
148
+ ...loadEnv("mock", process.cwd(), "")
149
+ };
150
+ }
151
+ async function getPhpExecutable() {
152
+ if (phpExecutable) return phpExecutable;
153
+ const env = getEnv();
154
+ const php = (env.PHP_EXECUTABLE_PATH ?? "php").split(" ");
155
+ if (!env.PHP_EXECUTABLE_PATH) {
156
+ const devEnvironment = await determineDevEnvironment();
157
+ if (devEnvironment === "ddev") php.unshift("ddev");
158
+ else if (devEnvironment === "lando") php.unshift("lando");
159
+ }
160
+ return phpExecutable = php;
161
+ }
162
+ async function determineDevEnvironment() {
163
+ if (devEnvironment) return devEnvironment;
164
+ if (fs.existsSync(`${process.cwd()}/.ddev`)) devEnvironment = "ddev";
165
+ else if (fs.existsSync(`${process.cwd()}/.lando.yml`)) devEnvironment = "lando";
166
+ else devEnvironment = "native";
167
+ return devEnvironment;
168
+ }
169
+ //#endregion
170
+ //#region src/config/load.ts
171
+ async function loadConfiguration() {
172
+ try {
173
+ const { stdout } = await execSync(`${(await getPhpExecutable()).join(" ")} artisan hybridly:config`);
174
+ return JSON.parse(stdout);
175
+ } catch (e) {
176
+ console.error("Could not load configuration from [php artisan hybridly:config].");
177
+ if (e.stdout) console.error(e.stdout);
178
+ if (await determineDevEnvironment() === "ddev") console.error("This is possibly caused by not starting ddev first.");
179
+ else if (await determineDevEnvironment() === "lando") console.error("This is possibly caused by not starting lando first.");
180
+ throw e;
181
+ }
182
+ }
420
183
  //#endregion
421
184
  //#region src/config/index.ts
422
185
  var config_default = (options, config) => {
423
- generateTsConfig(options, config);
186
+ generateAppTsConfig(options, config);
187
+ generateNodeTsConfig(options, config);
424
188
  generateLaravelIdeaHelper(config);
425
- generateRouteDefinitionFile(options, config);
426
189
  generateVueExtensionFile();
427
190
  return {
428
191
  name: CONFIG_PLUGIN_NAME,
@@ -447,7 +210,6 @@ var config_default = (options, config) => {
447
210
  }
448
211
  async function handleFileChange(file) {
449
212
  if (file.endsWith("config/hybridly.php")) return await forceRestart("Configuration file changed");
450
- if (/routes\/.*\.php/.test(file) || /routes\.php/.test(file)) return await forceRestart("Routing changed");
451
213
  if (/.*\.vue$/.test(file)) loadConfiguration().then((updatedConfig) => {
452
214
  if (didViewsOrLayoutsChange(updatedConfig, config)) forceRestart("View or layout changed");
453
215
  }).catch();
@@ -456,28 +218,360 @@ var config_default = (options, config) => {
456
218
  server.watcher.on("change", handleFileChange);
457
219
  server.watcher.on("unlink", handleFileChange);
458
220
  },
459
- resolveId(id) {
460
- if (id === CONFIG_VIRTUAL_MODULE_ID) return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;
221
+ resolveId(id) {
222
+ if (id === "virtual:hybridly/config") return RESOLVED_CONFIG_VIRTUAL_MODULE_ID;
223
+ },
224
+ async load(id) {
225
+ if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) return getClientCode$1(config);
226
+ },
227
+ async handleHotUpdate(ctx) {
228
+ if (ctx.file.includes(".hybridly")) return [];
229
+ }
230
+ };
231
+ };
232
+ function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
233
+ if (!previousConfig) return false;
234
+ return JSON.stringify(updatedConfig.components.views) !== JSON.stringify(previousConfig.components.views) || JSON.stringify(updatedConfig.components.layouts) !== JSON.stringify(previousConfig.components.layouts);
235
+ }
236
+ //#endregion
237
+ //#region src/integrations/run.ts
238
+ async function getRunOptions(options) {
239
+ if (options.run === false) return [];
240
+ const php = await getPhpExecutable();
241
+ return [
242
+ {
243
+ name: "Generate TypeScript definitions",
244
+ run: [
245
+ ...php,
246
+ "artisan",
247
+ "hybridly:types",
248
+ options.allowTypeGenerationFailures !== false ? "--allow-failures" : ""
249
+ ].filter(Boolean),
250
+ pattern: ["+(app|config|routes|src)/**/*.php"]
251
+ },
252
+ {
253
+ name: "Generate i18n",
254
+ run: [
255
+ ...php,
256
+ "artisan",
257
+ "hybridly:i18n"
258
+ ],
259
+ pattern: "lang/**/*.php"
260
+ },
261
+ ...options.run ?? []
262
+ ];
263
+ }
264
+ //#endregion
265
+ //#region src/integrations/unplugins.ts
266
+ /**
267
+ * Import map for auto-importing Hybridly utils.
268
+ */
269
+ const hybridlyImports = {
270
+ "hybridly/vue": [
271
+ "useProperty",
272
+ "setProperty",
273
+ "useRefinements",
274
+ "useTable",
275
+ "useBulkSelect",
276
+ "useProperties",
277
+ "useBackForward",
278
+ "useContext",
279
+ "useForm",
280
+ "useDialog",
281
+ "useHistoryState",
282
+ "createPaginator",
283
+ "registerHook",
284
+ "useRoute",
285
+ "useQueryParameter",
286
+ "useQueryParameters"
287
+ ],
288
+ "hybridly": [
289
+ "router",
290
+ "route",
291
+ "can",
292
+ "getRouterContext"
293
+ ]
294
+ };
295
+ //#endregion
296
+ //#region ../utils/src/utils.ts
297
+ var import_cjs = /* @__PURE__ */ __toESM(require_cjs(), 1);
298
+ function merge(x, y, options = {}) {
299
+ return (0, import_cjs.default)(x, y, {
300
+ arrayMerge: typeof options?.arrayMerge === "function" ? options.arrayMerge : options?.overwriteArray !== false ? (_, s) => s : void 0,
301
+ isMergeableObject: options?.mergePlainObjects ? isPlainObject : void 0
302
+ });
303
+ }
304
+ //#endregion
305
+ //#region ../utils/src/debug.ts
306
+ var import_src = /* @__PURE__ */ __toESM(require_src(), 1);
307
+ const debug = {
308
+ router: (0, import_src.default)("hybridly:core:router"),
309
+ queue: (0, import_src.default)("hybridly:core:router:queue"),
310
+ history: (0, import_src.default)("hybridly:core:history"),
311
+ url: (0, import_src.default)("hybridly:core:url"),
312
+ context: (0, import_src.default)("hybridly:core:context"),
313
+ external: (0, import_src.default)("hybridly:core:external"),
314
+ scroll: (0, import_src.default)("hybridly:core:scroll"),
315
+ hook: (0, import_src.default)("hybridly:core:hook"),
316
+ layout: (0, import_src.default)("hybridly:plugin:layout"),
317
+ config: (0, import_src.default)("hybridly:vite:config"),
318
+ plugin: (name, ...args) => (0, import_src.default)("hybridly:plugin").extend(name.replace("hybridly:", ""))(args.shift(), ...args),
319
+ adapter: (name, ...args) => (0, import_src.default)("hybridly:adapter").extend(name)(args.shift(), ...args)
320
+ };
321
+ //#endregion
322
+ //#region src/integrations/vue.ts
323
+ function getVueOptions(options) {
324
+ if (options.vue === false) return {};
325
+ return merge({
326
+ template: {
327
+ transformAssetUrls: {
328
+ base: null,
329
+ includeAbsolute: false
330
+ },
331
+ ...options.vue?.template
332
+ },
333
+ script: {
334
+ globalTypeFiles: [path.resolve(".hybridly/php-types.d.ts")],
335
+ defineModel: true,
336
+ ...options.vue?.script
337
+ }
338
+ }, options.vue ?? {}, { overwriteArray: false });
339
+ }
340
+ //#endregion
341
+ //#region src/kill-switch.ts
342
+ function killSwitch() {
343
+ let _enabled = false;
344
+ return {
345
+ name: "hybridly:build:kill-switch",
346
+ config: ({ mode }) => {
347
+ if (mode === "build") _enabled = true;
348
+ },
349
+ buildEnd: (error) => {
350
+ if (!_enabled) return;
351
+ if (error) {
352
+ console.error("Error when bundling");
353
+ console.error(error);
354
+ process.exit(1);
355
+ }
356
+ },
357
+ closeBundle: () => {
358
+ if (!_enabled) return;
359
+ process.exit(0);
360
+ }
361
+ };
362
+ }
363
+ //#endregion
364
+ //#region src/laravel/utils.ts
365
+ function isIpv6(address) {
366
+ return address.family === "IPv6" || address.family === 6;
367
+ }
368
+ //#endregion
369
+ //#region src/laravel/dev-env.ts
370
+ /**
371
+ * Resolves the path to the Herd or Valet configuration directory.
372
+ */
373
+ function determineDevelopmentEnvironmentConfigPath() {
374
+ const herdConfigPath = path.resolve(os.homedir(), "Library", "Application Support", "Herd", "config", "valet");
375
+ if (fs.existsSync(herdConfigPath)) return herdConfigPath;
376
+ return path.resolve(os.homedir(), ".config", "valet");
377
+ }
378
+ /**
379
+ * Resolves the Herd or Valet host for the current directory.
380
+ */
381
+ function resolveDevelopmentEnvironmentHost(configPath) {
382
+ const configFile = path.resolve(configPath, "config.json");
383
+ if (!fs.existsSync(configFile)) return;
384
+ const config = JSON.parse(fs.readFileSync(configFile, "utf-8"));
385
+ return `${path.basename(process.cwd())}.${config.tld}`;
386
+ }
387
+ /**
388
+ * Resolves the Herd or Valet server config for the given host.
389
+ */
390
+ function resolveDevelopmentEnvironmentServerConfig() {
391
+ const configPath = determineDevelopmentEnvironmentConfigPath();
392
+ const host = resolveDevelopmentEnvironmentHost(configPath);
393
+ if (!host) return;
394
+ const keyPath = path.resolve(configPath, "Certificates", `${host}.key`);
395
+ const certPath = path.resolve(configPath, "Certificates", `${host}.crt`);
396
+ if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) return;
397
+ return {
398
+ hmr: { host },
399
+ host,
400
+ https: {
401
+ key: fs.readFileSync(keyPath),
402
+ cert: fs.readFileSync(certPath)
403
+ }
404
+ };
405
+ }
406
+ /**
407
+ * Resolves the server config from the environment.
408
+ */
409
+ function resolveEnvironmentServerConfig(env) {
410
+ if (!env.VITE_DEV_SERVER_KEY && !env.VITE_DEV_SERVER_CERT) return;
411
+ if (!fs.existsSync(env.VITE_DEV_SERVER_KEY) || !fs.existsSync(env.VITE_DEV_SERVER_CERT)) throw new Error(`Unable to find the certificate files specified in your environment. Ensure you have correctly configured VITE_DEV_SERVER_KEY: [${env.VITE_DEV_SERVER_KEY}] and VITE_DEV_SERVER_CERT: [${env.VITE_DEV_SERVER_CERT}].`);
412
+ const host = resolveHostFromEnv(env);
413
+ return {
414
+ hmr: { host },
415
+ host,
416
+ https: {
417
+ key: fs.readFileSync(env.VITE_DEV_SERVER_KEY),
418
+ cert: fs.readFileSync(env.VITE_DEV_SERVER_CERT)
419
+ }
420
+ };
421
+ }
422
+ /**
423
+ * Resolve the host name from the environment.
424
+ */
425
+ function resolveHostFromEnv(env) {
426
+ if (env.VITE_DEV_SERVER_KEY) return env.VITE_DEV_SERVER_KEY;
427
+ try {
428
+ return new URL(env.APP_URL).host;
429
+ } catch {
430
+ throw new Error(`Unable to determine the host from the environment's APP_URL: [${env.APP_URL}].`);
431
+ }
432
+ }
433
+ //#endregion
434
+ //#region src/laravel/index.ts
435
+ let exitHandlersBound = false;
436
+ function laravel(options, hybridlyConfig) {
437
+ let viteDevServerUrl;
438
+ let resolvedConfig;
439
+ let userConfig;
440
+ const publicDirectory = "public";
441
+ const buildDirectory = "build";
442
+ const hotFile = path.join(publicDirectory, "hot");
443
+ return {
444
+ name: "hybridly:laravel",
445
+ enforce: "post",
446
+ config: (config, { command, mode }) => {
447
+ userConfig = config;
448
+ const ssr = !!userConfig.build?.ssr;
449
+ const env = loadEnv(mode, userConfig.envDir || process.cwd(), "");
450
+ const assetUrl = env.ASSET_URL ?? "";
451
+ const base = `${assetUrl + (!assetUrl.endsWith("/") ? "/" : "") + buildDirectory}/`;
452
+ const serverConfig = command === "serve" ? resolveEnvironmentServerConfig(env) ?? resolveDevelopmentEnvironmentServerConfig() : void 0;
453
+ ensureCommandShouldRunInEnvironment(command, env);
454
+ return {
455
+ base: userConfig.base ?? (command === "build" ? base : ""),
456
+ publicDir: userConfig.publicDir ?? false,
457
+ build: {
458
+ manifest: ssr === true ? false : userConfig.build?.manifest ?? "manifest.json",
459
+ outDir: userConfig.build?.outDir ?? path.join(publicDirectory, buildDirectory),
460
+ rollupOptions: { input: resolveInput(config, hybridlyConfig, ssr) },
461
+ assetsInlineLimit: userConfig.build?.assetsInlineLimit ?? 0
462
+ },
463
+ server: {
464
+ origin: userConfig.server?.origin ?? "http://__laravel_vite_placeholder__.test",
465
+ cors: userConfig.server?.cors ?? { origin: userConfig.server?.origin ?? [
466
+ /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/,
467
+ ...env.APP_URL ? [env.APP_URL] : [],
468
+ /^https?:\/\/.*\.test(:\d+)?$/
469
+ ] },
470
+ ...process.env.LARAVEL_SAIL ? {
471
+ host: userConfig.server?.host ?? "0.0.0.0",
472
+ port: userConfig.server?.port ?? (env.VITE_PORT ? Number.parseInt(env.VITE_PORT) : 5173),
473
+ strictPort: userConfig.server?.strictPort ?? true
474
+ } : void 0,
475
+ ...serverConfig ? {
476
+ host: userConfig.server?.host ?? serverConfig.host,
477
+ hmr: userConfig.server?.hmr === false ? false : {
478
+ ...serverConfig.hmr,
479
+ ...userConfig.server?.hmr === true ? {} : userConfig.server?.hmr
480
+ },
481
+ https: userConfig.server?.https ?? serverConfig.https
482
+ } : void 0
483
+ }
484
+ };
485
+ },
486
+ configResolved(config) {
487
+ resolvedConfig = config;
461
488
  },
462
- async load(id) {
463
- if (id === RESOLVED_CONFIG_VIRTUAL_MODULE_ID) return getClientCode$1(config);
489
+ transform(code) {
490
+ if (resolvedConfig.command === "serve") return code.replace(/http:\/\/__laravel_vite_placeholder__\.test/g, viteDevServerUrl);
464
491
  },
465
- async handleHotUpdate(ctx) {
466
- if (ctx.file.includes(".hybridly")) return [];
492
+ configureServer(server) {
493
+ const envDir = resolvedConfig.envDir || process.cwd();
494
+ const appUrl = loadEnv(resolvedConfig.mode, envDir, "APP_URL").APP_URL ?? "undefined";
495
+ if (!["test", "ci"].includes(resolvedConfig.mode)) server.httpServer?.once("listening", async () => {
496
+ const address = server.httpServer?.address();
497
+ const isAddressInfo = (x) => typeof x === "object";
498
+ if (isAddressInfo(address)) {
499
+ viteDevServerUrl = resolveDevServerUrl(address, server.config, userConfig);
500
+ fs.writeFileSync(hotFile, `${viteDevServerUrl}${server.config.base.replace(/\/$/, "")}`);
501
+ if (!hybridlyConfig.versions) return;
502
+ let registered = `${colors.bold(hybridlyConfig.components.views.length)} ${colors.dim("views")}, `;
503
+ registered += `${colors.bold(hybridlyConfig.components.layouts.length)} ${colors.dim("layouts")}, `;
504
+ const latest = hybridlyConfig.versions.is_latest ? "" : colors.dim(`(${colors.yellow(`${hybridlyConfig.versions.latest} is available`)})`);
505
+ let version = `${colors.yellow(`v${hybridlyConfig.versions.composer}`)} ${colors.dim("(composer)")}, `;
506
+ version += `${colors.yellow(`v${hybridlyConfig.versions.npm}`)} ${colors.dim("(npm)")}`;
507
+ version += ` — ${colors.yellow("this may lead to undefined behavior")}`;
508
+ const devEnvironment = await determineDevEnvironment();
509
+ setTimeout(() => {
510
+ server.config.logger.info(`\n ${colors.magenta(`${colors.bold("HYBRIDLY")} v${hybridlyConfig.versions.composer}`)} ${latest}`);
511
+ server.config.logger.info("");
512
+ server.config.logger.info(` ${colors.green("➜")} ${colors.bold("URL")}: ${colors.cyan(hybridlyConfig.routing.url)}`);
513
+ server.config.logger.info(` ${colors.green("➜")} ${colors.bold("Registered")}: ${registered}`);
514
+ if (devEnvironment !== "native") server.config.logger.info(` ${colors.green("➜")} ${colors.bold("Development environment")}: ${colors.cyan(devEnvironment)}`);
515
+ if (hybridlyConfig.versions.composer !== hybridlyConfig.versions.npm) server.config.logger.info(` ${colors.yellow("➜")} ${colors.bold("Version mismatch")}: ${version}`);
516
+ }, 100);
517
+ }
518
+ });
519
+ if (!exitHandlersBound) {
520
+ function clean() {
521
+ if (fs.existsSync(hotFile)) fs.rmSync(hotFile);
522
+ }
523
+ process.on("exit", clean);
524
+ process.on("SIGINT", () => process.exit());
525
+ process.on("SIGTERM", () => process.exit());
526
+ process.on("SIGHUP", () => process.exit());
527
+ exitHandlersBound = true;
528
+ }
529
+ return () => server.middlewares.use((req, res, next) => {
530
+ if (req.url === "/index.html") {
531
+ res.writeHead(302, { Location: appUrl });
532
+ res.end();
533
+ }
534
+ next();
535
+ });
467
536
  }
468
537
  };
469
- };
470
- function didViewsOrLayoutsChange(updatedConfig, previousConfig) {
471
- if (!previousConfig) return false;
472
- return JSON.stringify(updatedConfig.components.views) !== JSON.stringify(previousConfig.components.views) || JSON.stringify(updatedConfig.components.layouts) !== JSON.stringify(previousConfig.components.layouts);
473
538
  }
474
-
539
+ /**
540
+ * Validates the command can run in the given environment.
541
+ */
542
+ function ensureCommandShouldRunInEnvironment(command, env) {
543
+ if (command === "build" || env.LARAVEL_BYPASS_ENV_CHECK === "1" || !!env.TEST || !!env.VITEST) return;
544
+ if (typeof env.LARAVEL_VAPOR !== "undefined") throw new TypeError("You should not run the Vite HMR server on Vapor. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
545
+ if (typeof env.LARAVEL_FORGE !== "undefined") throw new TypeError("You should not run the Vite HMR server in your Forge deployment script. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
546
+ if (typeof env.LARAVEL_ENVOYER !== "undefined") throw new TypeError("You should not run the Vite HMR server in your Envoyer hook. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
547
+ if (typeof env.CI !== "undefined") throw new TypeError("You should not run the Vite HMR server in CI environments. You should build your assets for production instead. To disable this ENV check you may set LARAVEL_BYPASS_ENV_CHECK=1");
548
+ }
549
+ /**
550
+ * Resolves input files.
551
+ */
552
+ function resolveInput(userConfig, hybridlyConfig, _ssr) {
553
+ return userConfig.build?.rollupOptions?.input ?? hybridlyConfig.architecture.application_main_path;
554
+ }
555
+ /**
556
+ * Resolves the dev server URL from the server address and configuration.
557
+ */
558
+ function resolveDevServerUrl(address, config, userConfig) {
559
+ const configHmrProtocol = typeof config.server.hmr === "object" ? config.server.hmr.protocol : null;
560
+ const clientProtocol = configHmrProtocol ? configHmrProtocol === "wss" ? "https" : "http" : null;
561
+ const serverProtocol = config.server.https ? "https" : "http";
562
+ const protocol = clientProtocol ?? serverProtocol;
563
+ const configHmrHost = typeof config.server.hmr === "object" ? config.server.hmr.host : null;
564
+ const configHost = typeof config.server.host === "string" ? config.server.host : null;
565
+ const sailHost = process.env.LARAVEL_SAIL && !userConfig.server?.host ? "localhost" : null;
566
+ const serverAddress = isIpv6(address) ? `[${address.address}]` : address.address;
567
+ return `${protocol}://${configHmrHost ?? sailHost ?? configHost ?? serverAddress}:${(typeof config.server.hmr === "object" ? config.server.hmr.clientPort : null) ?? address.port}`;
568
+ }
475
569
  //#endregion
476
570
  //#region src/layout/index.ts
477
- const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:](?:,\ )?)+)['"] *)?>/;
571
+ const TEMPLATE_LAYOUT_REGEX = /<template +layout(?: *= *['"]((?:[\w\/\-_,:.](?:,\ )?)+)['"] *)?>/;
478
572
  const LANG_REGEX = /lang=['"](\w+)['"]/;
479
573
  var layout_default = (options, config) => {
480
- const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".vue", "") ?? "default";
574
+ const defaultLayoutName = options?.layout?.defaultLayoutName?.replace(".layout.vue", "")?.replace(".vue", "") ?? "default";
481
575
  const templateRegExp = options?.layout?.templateRegExp ?? TEMPLATE_LAYOUT_REGEX;
482
576
  debug.layout("Resolved options:", { defaultLayoutName });
483
577
  return {
@@ -488,6 +582,15 @@ var layout_default = (options, config) => {
488
582
  const updatedCode = new MagicString(code).replace(templateRegExp, (_, layoutName) => {
489
583
  const [hasLang, lang] = code.match(LANG_REGEX) ?? [];
490
584
  const layouts = layoutName?.toString()?.replaceAll(" ", "").split(",") ?? [defaultLayoutName];
585
+ if (layouts.length === 1 && layouts.at(0) === "false") {
586
+ debug.layout(`User opted out of layouts`, { layouts });
587
+ return `
588
+ <script${hasLang ? ` lang="${lang}"` : ""}>
589
+ export default { layout: [] }
590
+ <\/script>
591
+ <template>
592
+ `.replace(/^\s+/gm, "");
593
+ }
491
594
  const importName = (i) => `__hybridly_layout_${i}`;
492
595
  const exports = layouts.map((_, i) => importName(i));
493
596
  const imports = layouts.reduce((imports, layoutName, i) => `
@@ -505,7 +608,7 @@ var layout_default = (options, config) => {
505
608
  export default { layout: [${exports.join(", ")}] }
506
609
  <\/script>
507
610
  <template>
508
- `;
611
+ `.replace(/^\s+/gm, "");
509
612
  });
510
613
  return {
511
614
  map: updatedCode.generateMap(),
@@ -522,95 +625,6 @@ function resolveLayoutImportPath(name, config) {
522
625
  if (!path) throw new Error(`Layout [${name}] could not be found.`);
523
626
  return `~/${path}`;
524
627
  }
525
-
526
- //#endregion
527
- //#region src/integrations/run.ts
528
- async function getRunOptions(options) {
529
- if (options.run === false) return [];
530
- const php = await getPhpExecutable();
531
- return [
532
- {
533
- name: "Generate TypeScript types",
534
- run: [
535
- ...php,
536
- "artisan",
537
- "hybridly:types",
538
- options.allowTypeGenerationFailures !== false ? "--allow-failures" : ""
539
- ].filter(Boolean),
540
- pattern: [
541
- "+(app|src)/**/*Data.php",
542
- "+(app|src)/**/Enums/*.php",
543
- "+(app|src)/**/Middleware/HandleHybridRequests.php"
544
- ]
545
- },
546
- {
547
- name: "Generate i18n",
548
- run: [
549
- ...php,
550
- "artisan",
551
- "hybridly:i18n"
552
- ],
553
- pattern: "lang/**/*.php"
554
- },
555
- ...options.run ?? []
556
- ];
557
- }
558
-
559
- //#endregion
560
- //#region ../utils/src/utils.ts
561
- var import_cjs = /* @__PURE__ */ __toESM(require_cjs(), 1);
562
- var import_lodash = /* @__PURE__ */ __toESM(require_lodash(), 1);
563
- function merge(x, y, options = {}) {
564
- return (0, import_cjs.default)(x, y, {
565
- arrayMerge: typeof options?.arrayMerge === "function" ? options.arrayMerge : options?.overwriteArray !== false ? (_, s) => s : void 0,
566
- isMergeableObject: options?.mergePlainObjects ? isPlainObject : void 0
567
- });
568
- }
569
-
570
- //#endregion
571
- //#region src/integrations/vue.ts
572
- function getVueOptions(options) {
573
- if (options.vue === false) return {};
574
- return merge({
575
- template: {
576
- transformAssetUrls: {
577
- base: null,
578
- includeAbsolute: false
579
- },
580
- ...options.vue?.template
581
- },
582
- script: {
583
- globalTypeFiles: [path.resolve(".hybridly/php-types.d.ts")],
584
- defineModel: true,
585
- ...options.vue?.script
586
- }
587
- }, options.vue ?? {}, { overwriteArray: false });
588
- }
589
-
590
- //#endregion
591
- //#region src/kill-switch.ts
592
- function killSwitch() {
593
- let _enabled = false;
594
- return {
595
- name: "hybridly:build:kill-switch",
596
- config: ({ mode }) => {
597
- if (mode === "build") _enabled = true;
598
- },
599
- buildEnd: (error) => {
600
- if (!_enabled) return;
601
- if (error) {
602
- console.error("Error when bundling");
603
- console.error(error);
604
- process.exit(1);
605
- }
606
- },
607
- closeBundle: () => {
608
- if (!_enabled) return;
609
- process.exit(0);
610
- }
611
- };
612
- }
613
-
614
628
  //#endregion
615
629
  //#region src/local-build/client.ts
616
630
  function getClientCode() {
@@ -670,7 +684,6 @@ function getClientCode() {
670
684
  })()
671
685
  `;
672
686
  }
673
-
674
687
  //#endregion
675
688
  //#region src/local-build/index.ts
676
689
  const LOCAL_BUILD_VIRTUAL_ID = "virtual:hybridly/local-build";
@@ -694,45 +707,12 @@ function warnOnLocalBuilds() {
694
707
  },
695
708
  transform(code, id) {
696
709
  if (!shouldDisplayWarning) return;
697
- if (!id.endsWith(CONFIG_VIRTUAL_MODULE_ID)) return;
710
+ if (!id.endsWith("virtual:hybridly/config")) return;
698
711
  code = `${code}\nimport '${LOCAL_BUILD_VIRTUAL_ID}'`;
699
712
  return code;
700
713
  }
701
714
  };
702
715
  }
703
-
704
- //#endregion
705
- //#region src/integrations/unplugins.ts
706
- /**
707
- * Import map for auto-importing Hybridly utils.
708
- */
709
- const hybridlyImports = {
710
- "hybridly/vue": [
711
- "useProperty",
712
- "setProperty",
713
- "useRefinements",
714
- "useTable",
715
- "useBulkSelect",
716
- "useProperties",
717
- "useBackForward",
718
- "useContext",
719
- "useForm",
720
- "useDialog",
721
- "useHistoryState",
722
- "createPaginator",
723
- "registerHook",
724
- "useRoute",
725
- "useQueryParameter",
726
- "useQueryParameters"
727
- ],
728
- "hybridly": [
729
- "router",
730
- "route",
731
- "can",
732
- "getRouterContext"
733
- ]
734
- };
735
-
736
716
  //#endregion
737
717
  //#region src/index.ts
738
718
  async function plugin(options = {}) {
@@ -748,6 +728,5 @@ async function plugin(options = {}) {
748
728
  resolvedOptions.warnOnLocalBuilds !== false && warnOnLocalBuilds()
749
729
  ];
750
730
  }
751
-
752
731
  //#endregion
753
- export { plugin as default, hybridlyImports, layout_default as layout };
732
+ export { plugin as default, hybridlyImports, layout_default as layout };