cindel 1.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 +675 -0
- package/README.md +546 -0
- package/dist/client/file-loader.d.ts +24 -0
- package/dist/client/file-loader.d.ts.map +1 -0
- package/dist/client/hmr-client.d.ts +185 -0
- package/dist/client/hmr-client.d.ts.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.iife.js +2232 -0
- package/dist/client.iife.js.map +7 -0
- package/dist/client.iife.min.js +2 -0
- package/dist/client.iife.min.js.map +7 -0
- package/dist/client.js +2221 -0
- package/dist/client.js.map +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1142 -0
- package/dist/index.js.map +7 -0
- package/dist/server/file-watcher.d.ts +93 -0
- package/dist/server/file-watcher.d.ts.map +1 -0
- package/dist/server/hmr-server.d.ts +378 -0
- package/dist/server/hmr-server.d.ts.map +1 -0
- package/dist/server/routes.d.ts +2 -0
- package/dist/server/routes.d.ts.map +1 -0
- package/dist/server/ws-proxy.d.ts +5 -0
- package/dist/server/ws-proxy.d.ts.map +1 -0
- package/dist/shared/constants.d.ts +24 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/logger.d.ts +39 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/utils.d.ts +13 -0
- package/dist/shared/utils.d.ts.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} TLSConfig
|
|
3
|
+
* @property {string} key - Path to the private key file (PEM)
|
|
4
|
+
* @property {string} cert - Path to the certificate file (PEM)
|
|
5
|
+
* @property {string} [ca] - Path to a CA certificate file for mutual TLS
|
|
6
|
+
* @property {string} [passphrase] - Passphrase for an encrypted private key
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} CORSProxyConfig
|
|
10
|
+
* @property {string|RegExp} [path='/proxy'] - Path prefix or regex that triggers the proxy
|
|
11
|
+
* @property {function(string, Request): Object} [getHeaders] - Return custom headers for the outbound request. Receives `(targetUrl, incomingRequest)`.
|
|
12
|
+
* @property {function(Response): Promise<Response>} [transformResponse] - Transform the upstream response before returning it to the client
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {Object} WSProxyConfig
|
|
16
|
+
* @property {string} [path='/proxy'] - Path prefix that triggers the proxy. The remainder of the path must be the full upstream `ws://` or `wss://` URL.
|
|
17
|
+
* @property {Object} [headers] - Static headers sent to every upstream connection.
|
|
18
|
+
* @property {boolean|string[]} [forwardHeaders] - Forward incoming client headers to the upstream connection.
|
|
19
|
+
* `true` forwards all headers; an array of header name strings forwards only the listed ones (case-insensitive).
|
|
20
|
+
* Applied before `headers` and `getHeaders`, so explicit values always win.
|
|
21
|
+
* @property {function(string, Object): Object} [getHeaders] - Return dynamic headers per connection. Receives `(targetUrl, incomingHeaders)`. Merged on top of `headers`.
|
|
22
|
+
* @property {function(string): void} [onConnect] - Called when the upstream connection opens. Receives `targetUrl`.
|
|
23
|
+
* @property {function(*, WebSocket, WebSocket): void} [onClientMessage] - Intercept messages from the browser before forwarding upstream. Receives `(message, clientSocket, upstreamSocket)`.
|
|
24
|
+
* @property {function(*, WebSocket, WebSocket): void} [onUpstreamMessage] - Intercept messages from upstream before forwarding to the browser. Receives `(message, clientSocket, upstreamSocket)`.
|
|
25
|
+
* @property {Object} [options] - Extra options passed to the upstream `WebSocket` constructor (e.g. `options: { perMessageDeflate: true }`)
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* HMR server with optional HTTP features (static files, CORS proxy, WebSocket proxy).
|
|
29
|
+
* All features are opt-in via configuration.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Minimal HMR only
|
|
33
|
+
* const hmr = new HMRServer({
|
|
34
|
+
* port: 1338,
|
|
35
|
+
* watch: ['src']
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* // HMR + Development Server
|
|
40
|
+
* const dev = new HMRServer({
|
|
41
|
+
* port: 1338,
|
|
42
|
+
* watch: ['src'],
|
|
43
|
+
* static: '.',
|
|
44
|
+
* injectLoader: 'loader.js'
|
|
45
|
+
* });
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // HMR + Proxies
|
|
49
|
+
* const proxy = new HMRServer({
|
|
50
|
+
* port: 1338,
|
|
51
|
+
* watch: ['src'],
|
|
52
|
+
* corsProxy: { path: '/proxy' },
|
|
53
|
+
* wsProxy: {
|
|
54
|
+
* path: '/proxy',
|
|
55
|
+
* headers: {
|
|
56
|
+
* Origin: 'https://www.example.com',
|
|
57
|
+
* 'User-Agent': 'Mozilla/5.0'
|
|
58
|
+
* }
|
|
59
|
+
* }
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Full Stack
|
|
64
|
+
* const server = new HMRServer({
|
|
65
|
+
* port: 1338,
|
|
66
|
+
* watch: ['src'],
|
|
67
|
+
* static: '.',
|
|
68
|
+
* corsProxy: true,
|
|
69
|
+
* wsProxy: {
|
|
70
|
+
* path: '/proxy',
|
|
71
|
+
* headers: {
|
|
72
|
+
* Origin: 'https://www.example.com'
|
|
73
|
+
* },
|
|
74
|
+
* options: { perMessageDeflate: true }
|
|
75
|
+
* },
|
|
76
|
+
* injectLoader: 'loader.js',
|
|
77
|
+
* tls: {
|
|
78
|
+
* key: 'localhost-key.pem',
|
|
79
|
+
* cert: 'localhost.pem'
|
|
80
|
+
* }
|
|
81
|
+
* });
|
|
82
|
+
*/
|
|
83
|
+
export class HMRServer {
|
|
84
|
+
/**
|
|
85
|
+
* @param {Object} [options={}]
|
|
86
|
+
* @param {number} [options.port=1338] - Port to listen on.
|
|
87
|
+
* @param {string} [options.bindHost='localhost'] - Network interface to bind to. Use `'0.0.0.0'` to listen on all interfaces and expose the server on your local network.
|
|
88
|
+
* @param {boolean} [options.watchFiles=true] - Use chokidar to watch files. Set to `false` to scan once at startup for initial file loading only.
|
|
89
|
+
* @param {string} [options.wsPath='/hmr'] - WebSocket upgrade path. Clients must connect to this path.
|
|
90
|
+
* @param {string[]} [options.watch=[]] - Paths or glob patterns to watch (e.g. `['src', 'lib']`)
|
|
91
|
+
* @param {string[]} [options.ignore] - Glob patterns to ignore.
|
|
92
|
+
* @param {string[]} [options.cold] - Glob patterns for files that require a full page reload instead of HMR (e.g. `['**\/*.config.js']`)
|
|
93
|
+
* @param {string[]} [options.extensions] - File extensions to watch. Defaults to `.js .cjs .mjs .css`
|
|
94
|
+
* @param {function(WebSocket, {files: string[], config: Object}): void} [options.onConnect] - Called when an HMR client connects. Defaults to sending an `init` message with the file list.
|
|
95
|
+
* @param {function(WebSocket): void} [options.onDisconnect] - Called when an HMR client disconnects
|
|
96
|
+
* @param {boolean} [options.logFiles=false] - Log every watched file during watcher initialization
|
|
97
|
+
* @param {boolean|{cors?: boolean, ws?: boolean}} [options.logProxy=false] - Log proxy traffic.
|
|
98
|
+
* `true` enables both. Pass `{ cors: true, ws: false }` to enable only one.
|
|
99
|
+
* @param {string} [options.static] - Directory to serve static files from (e.g. `'.'` or `'public'`), Defaults to `'.'` for serving from project root.
|
|
100
|
+
* @param {string} [options.indexPath='index.html'] - Path to index.html, used as the `/` fallback and for loader injection
|
|
101
|
+
* @param {string} [options.injectLoader] - Path to a script that will be injected into index.html via `<script>` before `</head>`
|
|
102
|
+
* @param {boolean|string|CORSProxyConfig} [options.corsProxy] - Enable the HTTP CORS proxy. `true` mounts at `/proxy`. A string uses that as the path directly e.g. `'/cors'`.
|
|
103
|
+
* @param {WSProxyConfig} [options.wsProxy] - Proxy WebSocket connections to an upstream server
|
|
104
|
+
* @param {function(): string[]} [options.getFiles] - Override the file list sent to connecting clients. Called on every new connection.
|
|
105
|
+
* @param {boolean|string} [options.filesEndpoint] - Expose the watched file list as JSON. `true` mounts at `/files`, a string uses that as the path.
|
|
106
|
+
* @param {boolean|string} [options.configEndpoint] - Expose the server config as JSON. `true` mounts at `/config`, a string uses that as the path.
|
|
107
|
+
* @param {TLSConfig} [options.tls] - Enable HTTPS/WSS
|
|
108
|
+
* @param {boolean|string[]} [options.handleSignals=true] - Register signal handlers that call `stop()` and exit cleanly.
|
|
109
|
+
* Default `yes` adds `SIGINT`/`SIGTERM`; `false` disables; or pass an array (e.g. `['SIGINT','SIGTERM','SIGHUP']`).
|
|
110
|
+
*/
|
|
111
|
+
constructor(options?: {
|
|
112
|
+
port?: number;
|
|
113
|
+
bindHost?: string;
|
|
114
|
+
watchFiles?: boolean;
|
|
115
|
+
wsPath?: string;
|
|
116
|
+
watch?: string[];
|
|
117
|
+
ignore?: string[];
|
|
118
|
+
cold?: string[];
|
|
119
|
+
extensions?: string[];
|
|
120
|
+
onConnect?: (arg0: WebSocket, arg1: {
|
|
121
|
+
files: string[];
|
|
122
|
+
config: any;
|
|
123
|
+
}) => void;
|
|
124
|
+
onDisconnect?: (arg0: WebSocket) => void;
|
|
125
|
+
logFiles?: boolean;
|
|
126
|
+
logProxy?: boolean | {
|
|
127
|
+
cors?: boolean;
|
|
128
|
+
ws?: boolean;
|
|
129
|
+
};
|
|
130
|
+
static?: string;
|
|
131
|
+
indexPath?: string;
|
|
132
|
+
injectLoader?: string;
|
|
133
|
+
corsProxy?: boolean | string | CORSProxyConfig;
|
|
134
|
+
wsProxy?: WSProxyConfig;
|
|
135
|
+
getFiles?: () => string[];
|
|
136
|
+
filesEndpoint?: boolean | string;
|
|
137
|
+
configEndpoint?: boolean | string;
|
|
138
|
+
tls?: TLSConfig;
|
|
139
|
+
handleSignals?: boolean | string[];
|
|
140
|
+
});
|
|
141
|
+
port: number;
|
|
142
|
+
bindHost: string;
|
|
143
|
+
wsPath: string;
|
|
144
|
+
watchFiles: boolean;
|
|
145
|
+
watchPaths: string[];
|
|
146
|
+
ignorePaths: string[];
|
|
147
|
+
coldPatterns: string[];
|
|
148
|
+
extensions: string[];
|
|
149
|
+
onConnectCallback: any;
|
|
150
|
+
onDisconnectCallback: (arg0: WebSocket) => void;
|
|
151
|
+
logFiles: boolean;
|
|
152
|
+
logProxy: {
|
|
153
|
+
cors: boolean;
|
|
154
|
+
ws: boolean;
|
|
155
|
+
};
|
|
156
|
+
logger: Logger;
|
|
157
|
+
watcher: FileWatcher;
|
|
158
|
+
server: Bun.Server<undefined>;
|
|
159
|
+
/** @type {Set<WebSocket>} */
|
|
160
|
+
clients: Set<WebSocket>;
|
|
161
|
+
staticDir: string;
|
|
162
|
+
getFilesCallback: () => string[];
|
|
163
|
+
filesEndpoint: any;
|
|
164
|
+
configEndpoint: any;
|
|
165
|
+
corsProxy: {
|
|
166
|
+
path: any;
|
|
167
|
+
getHeaders?: undefined;
|
|
168
|
+
transformResponse?: undefined;
|
|
169
|
+
} | {
|
|
170
|
+
path: any;
|
|
171
|
+
getHeaders: (arg0: string, arg1: Request) => any;
|
|
172
|
+
transformResponse: (arg0: Response) => Promise<Response>;
|
|
173
|
+
};
|
|
174
|
+
wsProxy: {
|
|
175
|
+
path: any;
|
|
176
|
+
/**
|
|
177
|
+
* - Static headers sent to every upstream connection.
|
|
178
|
+
*/
|
|
179
|
+
headers?: any;
|
|
180
|
+
/**
|
|
181
|
+
* - Forward incoming client headers to the upstream connection.
|
|
182
|
+
* `true` forwards all headers; an array of header name strings forwards only the listed ones (case-insensitive).
|
|
183
|
+
* Applied before `headers` and `getHeaders`, so explicit values always win.
|
|
184
|
+
*/
|
|
185
|
+
forwardHeaders?: boolean | string[];
|
|
186
|
+
/**
|
|
187
|
+
* - Return dynamic headers per connection. Receives `(targetUrl, incomingHeaders)`. Merged on top of `headers`.
|
|
188
|
+
*/
|
|
189
|
+
getHeaders?: (arg0: string, arg1: any) => any;
|
|
190
|
+
/**
|
|
191
|
+
* - Called when the upstream connection opens. Receives `targetUrl`.
|
|
192
|
+
*/
|
|
193
|
+
onConnect?: (arg0: string) => void;
|
|
194
|
+
/**
|
|
195
|
+
* - Intercept messages from the browser before forwarding upstream. Receives `(message, clientSocket, upstreamSocket)`.
|
|
196
|
+
*/
|
|
197
|
+
onClientMessage?: (arg0: any, arg1: WebSocket, arg2: WebSocket) => void;
|
|
198
|
+
/**
|
|
199
|
+
* - Intercept messages from upstream before forwarding to the browser. Receives `(message, clientSocket, upstreamSocket)`.
|
|
200
|
+
*/
|
|
201
|
+
onUpstreamMessage?: (arg0: any, arg1: WebSocket, arg2: WebSocket) => void;
|
|
202
|
+
/**
|
|
203
|
+
* - Extra options passed to the upstream `WebSocket` constructor (e.g. `options: { perMessageDeflate: true }`)
|
|
204
|
+
*/
|
|
205
|
+
options?: any;
|
|
206
|
+
};
|
|
207
|
+
loaderPath: string;
|
|
208
|
+
injectLoader: boolean;
|
|
209
|
+
indexPath: string;
|
|
210
|
+
tls: TLSConfig;
|
|
211
|
+
handleSignals: boolean | string[];
|
|
212
|
+
isColdFile(file: any): any;
|
|
213
|
+
/**
|
|
214
|
+
* Send a message to a single HMR client
|
|
215
|
+
* @param {WebSocket} client - The client to send to
|
|
216
|
+
* @param {Object} payload - The payload to send, will be JSON serialized
|
|
217
|
+
* @returns {boolean} Whether the message was sent successfully
|
|
218
|
+
*/
|
|
219
|
+
send(client: WebSocket, payload: any): boolean;
|
|
220
|
+
defaultOnConnect(ws: any, data: any): void;
|
|
221
|
+
getConfig(): {
|
|
222
|
+
port: number;
|
|
223
|
+
bindHost: string;
|
|
224
|
+
wsPath: string;
|
|
225
|
+
watch: string[];
|
|
226
|
+
ignore: string[];
|
|
227
|
+
cold: string[];
|
|
228
|
+
watchFiles: boolean;
|
|
229
|
+
extensions: string[];
|
|
230
|
+
static: string;
|
|
231
|
+
corsProxy: {
|
|
232
|
+
path: any;
|
|
233
|
+
getHeaders?: undefined;
|
|
234
|
+
transformResponse?: undefined;
|
|
235
|
+
} | {
|
|
236
|
+
path: any;
|
|
237
|
+
getHeaders: (arg0: string, arg1: Request) => any;
|
|
238
|
+
transformResponse: (arg0: Response) => Promise<Response>;
|
|
239
|
+
};
|
|
240
|
+
wsProxy: {
|
|
241
|
+
path: any;
|
|
242
|
+
/**
|
|
243
|
+
* - Static headers sent to every upstream connection.
|
|
244
|
+
*/
|
|
245
|
+
headers?: any;
|
|
246
|
+
/**
|
|
247
|
+
* - Forward incoming client headers to the upstream connection.
|
|
248
|
+
* `true` forwards all headers; an array of header name strings forwards only the listed ones (case-insensitive).
|
|
249
|
+
* Applied before `headers` and `getHeaders`, so explicit values always win.
|
|
250
|
+
*/
|
|
251
|
+
forwardHeaders?: boolean | string[];
|
|
252
|
+
/**
|
|
253
|
+
* - Return dynamic headers per connection. Receives `(targetUrl, incomingHeaders)`. Merged on top of `headers`.
|
|
254
|
+
*/
|
|
255
|
+
getHeaders?: (arg0: string, arg1: any) => any;
|
|
256
|
+
/**
|
|
257
|
+
* - Called when the upstream connection opens. Receives `targetUrl`.
|
|
258
|
+
*/
|
|
259
|
+
onConnect?: (arg0: string) => void;
|
|
260
|
+
/**
|
|
261
|
+
* - Intercept messages from the browser before forwarding upstream. Receives `(message, clientSocket, upstreamSocket)`.
|
|
262
|
+
*/
|
|
263
|
+
onClientMessage?: (arg0: any, arg1: WebSocket, arg2: WebSocket) => void;
|
|
264
|
+
/**
|
|
265
|
+
* - Intercept messages from upstream before forwarding to the browser. Receives `(message, clientSocket, upstreamSocket)`.
|
|
266
|
+
*/
|
|
267
|
+
onUpstreamMessage?: (arg0: any, arg1: WebSocket, arg2: WebSocket) => void;
|
|
268
|
+
/**
|
|
269
|
+
* - Extra options passed to the upstream `WebSocket` constructor (e.g. `options: { perMessageDeflate: true }`)
|
|
270
|
+
*/
|
|
271
|
+
options?: any;
|
|
272
|
+
};
|
|
273
|
+
wsProxyHeaders: any;
|
|
274
|
+
wsProxyPrefix: any;
|
|
275
|
+
filesEndpoint: any;
|
|
276
|
+
injectLoader: boolean;
|
|
277
|
+
loaderPath: string;
|
|
278
|
+
indexPath: string;
|
|
279
|
+
tls: TLSConfig;
|
|
280
|
+
handleSignals: boolean | string[];
|
|
281
|
+
logProxy: {
|
|
282
|
+
cors: boolean;
|
|
283
|
+
ws: boolean;
|
|
284
|
+
};
|
|
285
|
+
logFiles: boolean;
|
|
286
|
+
};
|
|
287
|
+
setupWatcher(): Promise<void>;
|
|
288
|
+
staticFiles: string[];
|
|
289
|
+
broadcast(action: any, file: any, extra?: {}): void;
|
|
290
|
+
handleHMRConnection(client: any): void;
|
|
291
|
+
handleHMRDisconnect(client: any): void;
|
|
292
|
+
getWebSocketConfig(): {
|
|
293
|
+
open: (client: any) => void;
|
|
294
|
+
message: (client: any, message: any) => void;
|
|
295
|
+
close: (client: any) => void;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* Start the HMR server
|
|
299
|
+
* @returns {Promise<void>}
|
|
300
|
+
*/
|
|
301
|
+
start(): Promise<void>;
|
|
302
|
+
/**
|
|
303
|
+
* Stop the HMR server and clean up resources
|
|
304
|
+
* @returns {Promise<void>}
|
|
305
|
+
*/
|
|
306
|
+
stop(): Promise<void>;
|
|
307
|
+
}
|
|
308
|
+
export type TLSConfig = {
|
|
309
|
+
/**
|
|
310
|
+
* - Path to the private key file (PEM)
|
|
311
|
+
*/
|
|
312
|
+
key: string;
|
|
313
|
+
/**
|
|
314
|
+
* - Path to the certificate file (PEM)
|
|
315
|
+
*/
|
|
316
|
+
cert: string;
|
|
317
|
+
/**
|
|
318
|
+
* - Path to a CA certificate file for mutual TLS
|
|
319
|
+
*/
|
|
320
|
+
ca?: string;
|
|
321
|
+
/**
|
|
322
|
+
* - Passphrase for an encrypted private key
|
|
323
|
+
*/
|
|
324
|
+
passphrase?: string;
|
|
325
|
+
};
|
|
326
|
+
export type CORSProxyConfig = {
|
|
327
|
+
/**
|
|
328
|
+
* - Path prefix or regex that triggers the proxy
|
|
329
|
+
*/
|
|
330
|
+
path?: string | RegExp;
|
|
331
|
+
/**
|
|
332
|
+
* - Return custom headers for the outbound request. Receives `(targetUrl, incomingRequest)`.
|
|
333
|
+
*/
|
|
334
|
+
getHeaders?: (arg0: string, arg1: Request) => any;
|
|
335
|
+
/**
|
|
336
|
+
* - Transform the upstream response before returning it to the client
|
|
337
|
+
*/
|
|
338
|
+
transformResponse?: (arg0: Response) => Promise<Response>;
|
|
339
|
+
};
|
|
340
|
+
export type WSProxyConfig = {
|
|
341
|
+
/**
|
|
342
|
+
* - Path prefix that triggers the proxy. The remainder of the path must be the full upstream `ws://` or `wss://` URL.
|
|
343
|
+
*/
|
|
344
|
+
path?: string;
|
|
345
|
+
/**
|
|
346
|
+
* - Static headers sent to every upstream connection.
|
|
347
|
+
*/
|
|
348
|
+
headers?: any;
|
|
349
|
+
/**
|
|
350
|
+
* - Forward incoming client headers to the upstream connection.
|
|
351
|
+
* `true` forwards all headers; an array of header name strings forwards only the listed ones (case-insensitive).
|
|
352
|
+
* Applied before `headers` and `getHeaders`, so explicit values always win.
|
|
353
|
+
*/
|
|
354
|
+
forwardHeaders?: boolean | string[];
|
|
355
|
+
/**
|
|
356
|
+
* - Return dynamic headers per connection. Receives `(targetUrl, incomingHeaders)`. Merged on top of `headers`.
|
|
357
|
+
*/
|
|
358
|
+
getHeaders?: (arg0: string, arg1: any) => any;
|
|
359
|
+
/**
|
|
360
|
+
* - Called when the upstream connection opens. Receives `targetUrl`.
|
|
361
|
+
*/
|
|
362
|
+
onConnect?: (arg0: string) => void;
|
|
363
|
+
/**
|
|
364
|
+
* - Intercept messages from the browser before forwarding upstream. Receives `(message, clientSocket, upstreamSocket)`.
|
|
365
|
+
*/
|
|
366
|
+
onClientMessage?: (arg0: any, arg1: WebSocket, arg2: WebSocket) => void;
|
|
367
|
+
/**
|
|
368
|
+
* - Intercept messages from upstream before forwarding to the browser. Receives `(message, clientSocket, upstreamSocket)`.
|
|
369
|
+
*/
|
|
370
|
+
onUpstreamMessage?: (arg0: any, arg1: WebSocket, arg2: WebSocket) => void;
|
|
371
|
+
/**
|
|
372
|
+
* - Extra options passed to the upstream `WebSocket` constructor (e.g. `options: { perMessageDeflate: true }`)
|
|
373
|
+
*/
|
|
374
|
+
options?: any;
|
|
375
|
+
};
|
|
376
|
+
import { Logger } from '../shared/logger.js';
|
|
377
|
+
import { FileWatcher } from './file-watcher.js';
|
|
378
|
+
//# sourceMappingURL=hmr-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hmr-server.d.ts","sourceRoot":"","sources":["../../src/server/hmr-server.js"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AAEH;;;;;GAKG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH;IACE;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,sBAzBG;QAAyB,IAAI,GAArB,MAAM;QACW,QAAQ,GAAzB,MAAM;QACY,UAAU,GAA5B,OAAO;QACU,MAAM,GAAvB,MAAM;QACa,KAAK,GAAxB,MAAM,EAAE;QACW,MAAM,GAAzB,MAAM,EAAE;QACW,IAAI,GAAvB,MAAM,EAAE;QACW,UAAU,GAA7B,MAAM,EAAE;QAC+D,SAAS,GAAhF,CAAS,IAAS,EAAT,SAAS,EAAE,IAAiC,EAAjC;YAAC,KAAK,EAAE,MAAM,EAAE,CAAC;YAAC,MAAM,MAAQ;SAAC,KAAG,IAAI;QACxB,YAAY,GAAhD,CAAS,IAAS,EAAT,SAAS,KAAG,IAAI;QACP,QAAQ,GAA1B,OAAO;QAC0C,QAAQ,GAAzD,OAAO,GAAC;YAAC,IAAI,CAAC,EAAE,OAAO,CAAC;YAAC,EAAE,CAAC,EAAE,OAAO,CAAA;SAAC;QAErB,MAAM,GAAvB,MAAM;QACW,SAAS,GAA1B,MAAM;QACW,YAAY,GAA7B,MAAM;QACmC,SAAS,GAAlD,OAAO,GAAC,MAAM,GAAC,eAAe;QACN,OAAO,GAA/B,aAAa;QACkB,QAAQ,GAAvC,MAAY,MAAM,EAAE;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
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/server/routes.js"],"names":[],"mappings":"AAEA,uEAyBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ws-proxy.d.ts","sourceRoot":"","sources":["../../src/server/ws-proxy.js"],"names":[],"mappings":"AAAA;;;EA4JC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const DEFAULT_PORT: 1338;
|
|
2
|
+
export const WATCHABLE_EXTENSIONS: string[];
|
|
3
|
+
export const DEFAULT_FILES_ENDPOINT: "/files";
|
|
4
|
+
export const DEFAULT_CONFIG_ENDPOINT: "/config";
|
|
5
|
+
export const DEFAULT_CORS_PROXY_PATH: "/proxy";
|
|
6
|
+
export const DEFAULT_WS_PROXY_PATH: "/proxy";
|
|
7
|
+
export namespace WATCHER_CONFIG {
|
|
8
|
+
let persistent: boolean;
|
|
9
|
+
let ignoreInitial: boolean;
|
|
10
|
+
namespace awaitWriteFinish {
|
|
11
|
+
let stabilityThreshold: number;
|
|
12
|
+
let pollInterval: number;
|
|
13
|
+
}
|
|
14
|
+
let usePolling: boolean;
|
|
15
|
+
let alwaysStat: boolean;
|
|
16
|
+
let atomic: boolean;
|
|
17
|
+
}
|
|
18
|
+
export namespace HMR_ACTIONS {
|
|
19
|
+
let RELOAD: string;
|
|
20
|
+
let ADD: string;
|
|
21
|
+
let REMOVE: string;
|
|
22
|
+
let INIT: string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/shared/constants.js"],"names":[],"mappings":"AAAA,2BAA4B,IAAI,CAAC;AACjC,4CAAoE;AAEpE,qCAAsC,QAAQ,CAAA;AAC9C,sCAAuC,SAAS,CAAA;AAEhD,sCAAuC,QAAQ,CAAC;AAChD,oCAAqC,QAAQ,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
symbols: {
|
|
3
|
+
debug: string;
|
|
4
|
+
info: string;
|
|
5
|
+
success: string;
|
|
6
|
+
warning: string;
|
|
7
|
+
error: string;
|
|
8
|
+
config: string;
|
|
9
|
+
connect: string;
|
|
10
|
+
disconnect: string;
|
|
11
|
+
change: string;
|
|
12
|
+
add: string;
|
|
13
|
+
remove: string;
|
|
14
|
+
inject: string;
|
|
15
|
+
startup: string;
|
|
16
|
+
shutdown: string;
|
|
17
|
+
corsProxy: string;
|
|
18
|
+
wsProxy: string;
|
|
19
|
+
watch: string;
|
|
20
|
+
dirAdd: string;
|
|
21
|
+
dirRemove: string;
|
|
22
|
+
glob: string;
|
|
23
|
+
};
|
|
24
|
+
debug(message: any): void;
|
|
25
|
+
info(message: any): void;
|
|
26
|
+
success(message: any): void;
|
|
27
|
+
warning(message: any): void;
|
|
28
|
+
error(message: any): void;
|
|
29
|
+
custom(symbol: any, message: any, color?: string): void;
|
|
30
|
+
file(symbol: any, filePath: any, color?: string, prefix?: string): void;
|
|
31
|
+
banner(name: any, config: any): void;
|
|
32
|
+
corsProxyRequest(method: any, url: any, { reqBody, status, statusText, resBody }?: {}): void;
|
|
33
|
+
wsProxyConnect(id: any, url: any, headers: any): void;
|
|
34
|
+
shutdown(): void;
|
|
35
|
+
watcherStart(paths: any): void;
|
|
36
|
+
logInitFile(filePath: any, ignored: any, reason?: string): void;
|
|
37
|
+
watcherNoFiles(patterns: any, extensions: any): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/shared/logger.js"],"names":[],"mappings":"AAGA;IAEI;;;;;;;;;;;;;;;;;;;;;MAqBC;IAGH,0BAEC;IAED,yBAEC;IAED,4BAEC;IAED,4BAEC;IAED,0BAEC;IAED,wDAIC;IAED,wEASC;IAED,qCAiCC;IAGD,6FAgBC;IAGD,sDAYC;IAED,iBAEC;IAED,+BAIC;IAED,gEAOC;IAED,qDAOC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function matchGlob(file: any, patterns: any): any;
|
|
2
|
+
export function formatTime(): string;
|
|
3
|
+
export function getBrowserFromUA(userAgent: any): "Unknown" | "Chrome" | "Firefox" | "Safari" | "Edge" | "Opera";
|
|
4
|
+
export function getFileName(path: any): any;
|
|
5
|
+
export function getFilePath(path: any): any;
|
|
6
|
+
export function normalizeUrl(url: any): any;
|
|
7
|
+
export function normalizeProxyPath(path: any, defaultPath: any): any;
|
|
8
|
+
export function resolveEndpoint(value: any, defaultPath: any): any;
|
|
9
|
+
export function resolveConnectionUrls(options: any, wsPath?: string): {
|
|
10
|
+
wsUrl: any;
|
|
11
|
+
httpUrl: any;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/shared/utils.js"],"names":[],"mappings":"AAKA,yDAKC;AAED,qCAOC;AAED,iHAUC;AAED,4CAEC;AAED,4CAIC;AAED,4CAEC;AAED,qEAEC;AAED,mEAIC;AA6BD;;;EAuCC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "cindel",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Hot module replacement server and client with file watching, static file serving, CORS proxy and WebSocket proxy support",
|
|
5
|
+
"license": "GPL-3.0-or-later",
|
|
6
|
+
"author": "sneazy-ibo",
|
|
7
|
+
"homepage": "https://github.com/sneazy-ibo/cindel#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/sneazy-ibo/cindel"
|
|
11
|
+
},
|
|
12
|
+
"bugs": "https://github.com/sneazy-ibo/cindel/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts"
|
|
18
|
+
},
|
|
19
|
+
"./client": {
|
|
20
|
+
"import": "./dist/client.js",
|
|
21
|
+
"types": "./dist/client.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./server": {
|
|
24
|
+
"import": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"main": "dist/index.js",
|
|
29
|
+
"files": [
|
|
30
|
+
"dist"
|
|
31
|
+
],
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "bun build.js",
|
|
34
|
+
"prepublishOnly": "bun run build"
|
|
35
|
+
},
|
|
36
|
+
"types": "dist/index.d.ts",
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"chalk": "^5.0.0",
|
|
39
|
+
"chokidar": "^5.0.0",
|
|
40
|
+
"picomatch": "^4.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"bun-types": "latest",
|
|
44
|
+
"esbuild": "^0.27.3",
|
|
45
|
+
"typescript": "^5.0.0"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"cors",
|
|
49
|
+
"dev-server",
|
|
50
|
+
"file-watcher",
|
|
51
|
+
"game-modding",
|
|
52
|
+
"hmr",
|
|
53
|
+
"hot-module-reload",
|
|
54
|
+
"hot-module-replacement",
|
|
55
|
+
"hot-reload",
|
|
56
|
+
"websocket",
|
|
57
|
+
"ws-proxy"
|
|
58
|
+
],
|
|
59
|
+
"engines": {
|
|
60
|
+
"bun": ">=1.0.0"
|
|
61
|
+
},
|
|
62
|
+
"jsdelivr": "dist/client.iife.min.js",
|
|
63
|
+
"unpkg": "dist/client.iife.min.js"
|
|
64
|
+
}
|