@adonisjs/vite 2.0.2 → 3.0.0-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/LICENSE.md +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.js +2 -2
- package/build/providers/vite_provider.d.ts +4 -10
- package/build/providers/vite_provider.js +22 -53
- package/build/services/vite.d.ts +1 -1
- package/build/src/client/config.d.ts +13 -2
- package/build/src/client/config.js +36 -42
- package/build/src/client/main.d.ts +1 -1
- package/build/src/client/main.js +4 -6
- package/build/src/client/types.d.ts +12 -21
- package/build/src/define_config.d.ts +5 -0
- package/build/src/{backend/define_config.js → define_config.js} +1 -2
- package/build/src/hooks/build_hook.d.ts +8 -0
- package/build/src/hooks/build_hook.js +25 -0
- package/build/src/middlewares/vite_middleware.d.ts +17 -0
- package/build/src/middlewares/vite_middleware.js +31 -0
- package/build/src/{backend/plugins → plugins}/edge.js +2 -4
- package/build/src/{backend/types.d.ts → types.d.ts} +6 -22
- package/build/src/{backend/utils.d.ts → utils.d.ts} +4 -0
- package/build/src/{backend/utils.js → utils.js} +6 -0
- package/build/src/{backend/vite.d.ts → vite.d.ts} +27 -9
- package/build/src/{backend/vite.js → vite.js} +106 -104
- package/build/stubs/vite.config.stub +1 -1
- package/package.json +36 -56
- package/build/src/backend/debug.d.ts +0 -3
- package/build/src/backend/debug.js +0 -10
- package/build/src/backend/define_config.d.ts +0 -5
- package/build/src/client/config_resolver.d.ts +0 -20
- package/build/src/client/config_resolver.js +0 -46
- package/build/src/client/helpers/inertia.d.ts +0 -4
- package/build/src/client/helpers/inertia.js +0 -22
- package/build/src/client/hot_file.d.ts +0 -14
- package/build/src/client/hot_file.js +0 -49
- package/build/src/client/utils.d.ts +0 -11
- package/build/src/client/utils.js +0 -44
- /package/build/src/{backend/plugins → plugins}/edge.d.ts +0 -0
- /package/build/src/{backend/types.js → types.js} +0 -0
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
import { dirname, join } from 'node:path';
|
|
10
|
-
import { existsSync, rmSync } from 'node:fs';
|
|
11
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
12
|
-
import { ConfigResolver } from './config_resolver.js';
|
|
13
|
-
export class HotFile {
|
|
14
|
-
/**
|
|
15
|
-
* Path to the hot file
|
|
16
|
-
*/
|
|
17
|
-
#path;
|
|
18
|
-
/**
|
|
19
|
-
* Register hooks to clean the hot file on exit
|
|
20
|
-
*/
|
|
21
|
-
#cleanHotFileOnExit() {
|
|
22
|
-
const clean = this.clean.bind(this);
|
|
23
|
-
process.on('exit', clean);
|
|
24
|
-
process.on('SIGINT', process.exit);
|
|
25
|
-
process.on('SIGTERM', process.exit);
|
|
26
|
-
process.on('SIGHUP', process.exit);
|
|
27
|
-
process.on('SIGBREAK', process.exit);
|
|
28
|
-
}
|
|
29
|
-
constructor(path) {
|
|
30
|
-
this.#path = join(ConfigResolver.resolvedConfig.root, path);
|
|
31
|
-
this.#cleanHotFileOnExit();
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Write the hot file
|
|
35
|
-
*/
|
|
36
|
-
async write(data) {
|
|
37
|
-
await mkdir(dirname(this.#path), { recursive: true });
|
|
38
|
-
await writeFile(this.#path, JSON.stringify(data, null, 2));
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Delete the hot file
|
|
42
|
-
*/
|
|
43
|
-
clean() {
|
|
44
|
-
if (!existsSync(this.#path)) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
rmSync(this.#path);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import { ResolvedConfig } from 'vite';
|
|
3
|
-
import { AddressInfo } from 'node:net';
|
|
4
|
-
/**
|
|
5
|
-
* Resolve the dev server URL from the server address and configuration.
|
|
6
|
-
*/
|
|
7
|
-
export declare const resolveDevServerUrl: (address: AddressInfo, config: ResolvedConfig) => string;
|
|
8
|
-
/**
|
|
9
|
-
* Add a trailing slash if missing
|
|
10
|
-
*/
|
|
11
|
-
export declare const addTrailingSlash: (url: string) => string;
|
|
@@ -1,44 +0,0 @@
|
|
|
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
|
-
import { networkInterfaces } from 'node:os';
|
|
10
|
-
/**
|
|
11
|
-
* Resolve the dev server URL from the server address and configuration.
|
|
12
|
-
*/
|
|
13
|
-
export const resolveDevServerUrl = (address, config) => {
|
|
14
|
-
const configHmrProtocol = typeof config.server.hmr === 'object' ? config.server.hmr.protocol : null;
|
|
15
|
-
const clientProtocol = configHmrProtocol ? (configHmrProtocol === 'wss' ? 'https' : 'http') : null;
|
|
16
|
-
const serverProtocol = config.server.https ? 'https' : 'http';
|
|
17
|
-
const protocol = clientProtocol ?? serverProtocol;
|
|
18
|
-
const configHmrHost = typeof config.server.hmr === 'object' ? config.server.hmr.host : null;
|
|
19
|
-
const configHost = typeof config.server.host === 'string' ? config.server.host : null;
|
|
20
|
-
let host = configHmrHost ?? configHost ?? address.address;
|
|
21
|
-
if (host === '::1') {
|
|
22
|
-
host = 'localhost';
|
|
23
|
-
}
|
|
24
|
-
else if (host === '::') {
|
|
25
|
-
const networkAddress = Object.values(networkInterfaces())
|
|
26
|
-
.flatMap((nInterface) => nInterface ?? [])
|
|
27
|
-
.find((detail) => {
|
|
28
|
-
return (detail &&
|
|
29
|
-
detail.address &&
|
|
30
|
-
detail.family === 'IPv4' &&
|
|
31
|
-
!detail.address.includes('127.0.0.1'));
|
|
32
|
-
});
|
|
33
|
-
if (networkAddress) {
|
|
34
|
-
host = networkAddress.address;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return `${protocol}://${host}:${address.port}`;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Add a trailing slash if missing
|
|
41
|
-
*/
|
|
42
|
-
export const addTrailingSlash = (url) => {
|
|
43
|
-
return url.endsWith('/') ? url : url + '/';
|
|
44
|
-
};
|
|
File without changes
|
|
File without changes
|