@adonisjs/vite 0.0.1-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.
Files changed (67) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +36 -0
  3. package/build/configure.d.ts +3 -0
  4. package/build/configure.d.ts.map +1 -0
  5. package/build/configure.js +13 -0
  6. package/build/index.d.ts +5 -0
  7. package/build/index.d.ts.map +1 -0
  8. package/build/index.js +4 -0
  9. package/build/providers/vite_provider.d.ts +10 -0
  10. package/build/providers/vite_provider.d.ts.map +1 -0
  11. package/build/providers/vite_provider.js +48 -0
  12. package/build/services/vite.d.ts +4 -0
  13. package/build/services/vite.d.ts.map +1 -0
  14. package/build/services/vite.js +6 -0
  15. package/build/src/backend/types/extended.d.ts +7 -0
  16. package/build/src/backend/types/extended.d.ts.map +1 -0
  17. package/build/src/backend/types/extended.js +1 -0
  18. package/build/src/backend/types/main.d.ts +9 -0
  19. package/build/src/backend/types/main.d.ts.map +1 -0
  20. package/build/src/backend/types/main.js +1 -0
  21. package/build/src/backend/utils.d.ts +2 -0
  22. package/build/src/backend/utils.d.ts.map +1 -0
  23. package/build/src/backend/utils.js +7 -0
  24. package/build/src/backend/vite.d.ts +19 -0
  25. package/build/src/backend/vite.d.ts.map +1 -0
  26. package/build/src/backend/vite.js +182 -0
  27. package/build/src/vite_plugin/config.d.ts +5 -0
  28. package/build/src/vite_plugin/config.d.ts.map +1 -0
  29. package/build/src/vite_plugin/config.js +47 -0
  30. package/build/src/vite_plugin/config_resolver.d.ts +9 -0
  31. package/build/src/vite_plugin/config_resolver.d.ts.map +1 -0
  32. package/build/src/vite_plugin/config_resolver.js +27 -0
  33. package/build/src/vite_plugin/helpers/inertia.d.ts +2 -0
  34. package/build/src/vite_plugin/helpers/inertia.d.ts.map +1 -0
  35. package/build/src/vite_plugin/helpers/inertia.js +11 -0
  36. package/build/src/vite_plugin/hot_file.d.ts +9 -0
  37. package/build/src/vite_plugin/hot_file.d.ts.map +1 -0
  38. package/build/src/vite_plugin/hot_file.js +30 -0
  39. package/build/src/vite_plugin/index.d.ts +4 -0
  40. package/build/src/vite_plugin/index.d.ts.map +1 -0
  41. package/build/src/vite_plugin/index.js +16 -0
  42. package/build/src/vite_plugin/types/index.d.ts +10 -0
  43. package/build/src/vite_plugin/types/index.d.ts.map +1 -0
  44. package/build/src/vite_plugin/types/index.js +1 -0
  45. package/build/src/vite_plugin/utils.d.ts +5 -0
  46. package/build/src/vite_plugin/utils.d.ts.map +1 -0
  47. package/build/src/vite_plugin/utils.js +16 -0
  48. package/build/stubs/index.d.ts +2 -0
  49. package/build/stubs/index.d.ts.map +1 -0
  50. package/build/stubs/index.js +2 -0
  51. package/build/stubs/vite/vite_config.stub +14 -0
  52. package/configure.ts +30 -0
  53. package/index.ts +15 -0
  54. package/package.json +147 -0
  55. package/providers/vite_provider.ts +89 -0
  56. package/services/vite.ts +23 -0
  57. package/src/backend/types/extended.ts +19 -0
  58. package/src/backend/types/main.ts +31 -0
  59. package/src/backend/utils.ts +19 -0
  60. package/src/backend/vite.ts +367 -0
  61. package/src/vite_plugin/config.ts +97 -0
  62. package/src/vite_plugin/config_resolver.ts +62 -0
  63. package/src/vite_plugin/helpers/inertia.ts +27 -0
  64. package/src/vite_plugin/hot_file.ts +59 -0
  65. package/src/vite_plugin/index.ts +38 -0
  66. package/src/vite_plugin/types/index.ts +56 -0
  67. package/src/vite_plugin/utils.ts +40 -0
@@ -0,0 +1,40 @@
1
+ /*
2
+ * @adonisjs/vite
3
+ *
4
+ * (c) AdonisJS
5
+ *
6
+ * For the full copyright and license information, please view the LICENSE
7
+ * file that was distributed with this source code.
8
+ */
9
+
10
+ import { AddressInfo } from 'node:net'
11
+ import { ResolvedConfig } from 'vite'
12
+
13
+ /**
14
+ * Resolve the dev server URL from the server address and configuration.
15
+ */
16
+ export const resolveDevServerUrl = (address: AddressInfo, config: ResolvedConfig) => {
17
+ const configHmrProtocol =
18
+ typeof config.server.hmr === 'object' ? config.server.hmr.protocol : null
19
+
20
+ const clientProtocol = configHmrProtocol ? (configHmrProtocol === 'wss' ? 'https' : 'http') : null
21
+ const serverProtocol = config.server.https ? 'https' : 'http'
22
+ const protocol = clientProtocol ?? serverProtocol
23
+
24
+ const configHmrHost = typeof config.server.hmr === 'object' ? config.server.hmr.host : null
25
+ const configHost = typeof config.server.host === 'string' ? config.server.host : null
26
+
27
+ let host = configHmrHost ?? configHost ?? address.address
28
+ if (host === '::1') {
29
+ host = 'localhost'
30
+ }
31
+
32
+ return `${protocol}://${host}:${address.port}`
33
+ }
34
+
35
+ /**
36
+ * Add a trailing slash if missing
37
+ */
38
+ export const addTrailingSlash = (url: string) => {
39
+ return url.endsWith('/') ? url : url + '/'
40
+ }