@vercube/devkit 0.0.3 → 0.0.4

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.
@@ -0,0 +1,98 @@
1
+ import { Hookable } from "hookable";
2
+ import { ConfigTypes } from "@vercube/core";
3
+ import { Worker } from "node:worker_threads";
4
+
5
+ //#region src/Types/DevKitTypes.d.ts
6
+ declare namespace DevKitTypes {
7
+ export type BuildFunc = (ctx?: ConfigTypes.BuildOptions) => void | Promise<void>;
8
+ export type WatchFunc = (app?: App) => void | Promise<void>;
9
+ type HookResult = void | Promise<void>;
10
+ export interface Hooks {
11
+ 'dev:reload': () => HookResult;
12
+ 'bundler-watch:init': () => HookResult;
13
+ 'bundler-watch:start': () => HookResult;
14
+ 'bundler-watch:end': () => HookResult;
15
+ 'bundler-watch:error': (_error: Error) => HookResult;
16
+ }
17
+ /**
18
+ * Represents an application with hooks.
19
+ */
20
+ export interface App {
21
+ /**
22
+ * The hooks associated with the application.
23
+ */
24
+ hooks: Hookable<Hooks>;
25
+ /**
26
+ * The configuration object for the application.
27
+ */
28
+ config: ConfigTypes.Config;
29
+ }
30
+ /**
31
+ * Represents a development server.
32
+ */
33
+ export interface DevServer {
34
+ /**
35
+ * The application associated with the development server.
36
+ */
37
+ app: App;
38
+ /**
39
+ * Reloads the development server.
40
+ * @returns {Promise<void>} A promise that resolves when the server is reloaded.
41
+ */
42
+ reload: () => Promise<void>;
43
+ }
44
+ /**
45
+ * Represents a worker instance.
46
+ */
47
+ export interface Worker {
48
+ /**
49
+ * The worker thread instance.
50
+ */
51
+ worker: Worker | null;
52
+ /**
53
+ * The address information of the worker.
54
+ */
55
+ address: {
56
+ host: string;
57
+ port: number;
58
+ socketPath?: string;
59
+ };
60
+ }
61
+ export {};
62
+ }
63
+ //#endregion
64
+ //#region src/Common/App.d.ts
65
+ /**
66
+ * Creates a development server application.
67
+ * @returns {DevKitTypes.App} The development server application instance.
68
+ */
69
+ declare function createVercube(): Promise<DevKitTypes.App>;
70
+ //#endregion
71
+ //#region src/Build/Build.d.ts
72
+ /**
73
+ * Builds the application using the given application instance.
74
+ * @param {DevKitTypes.App} app - The application instance.
75
+ * @returns {Promise<void>} A promise that resolves when the build is complete.
76
+ */
77
+ declare function build(app: DevKitTypes.App): Promise<void>;
78
+ //#endregion
79
+ //#region src/Build/Watch.d.ts
80
+ /**
81
+ * Creates a watcher for the given application.
82
+ * @param {DevKitTypes.App} app - The application instance.
83
+ * This file is highly inspired by Nitro
84
+ * @see https://github.com/nitrojs/nitro/blob/v2/src/core/build/dev.ts
85
+ */
86
+ declare function watch(app: DevKitTypes.App): Promise<void>;
87
+ //#endregion
88
+ //#region src/Server/DevServer.d.ts
89
+ /**
90
+ * Creates a development server for the given application.
91
+ * @param {DevKitTypes.App} app - The application instance.
92
+ * @returns {DevKitTypes.DevServer} The development server instance.
93
+ * This file is highly inspired by Nitro
94
+ * @see https://github.com/nitrojs/nitro/blob/v2/src/core/dev-server/server.ts
95
+ */
96
+ declare function createDevServer(app: DevKitTypes.App): DevKitTypes.DevServer;
97
+ //#endregion
98
+ export { build, createDevServer, createVercube, watch };