@vandenberghinc/volt 1.2.7 → 1.2.8
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/.libris/config.json +82 -0
- package/backend/old/file_watcher.ts +359 -0
- package/backend/old/request.deprc.js +626 -0
- package/backend/old/response.deprc.js +354 -0
- package/frontend/examples/theme/theme.ts +58 -0
- package/frontend/tools/bundle_d_ts.js +71 -0
- package/frontend/tools/convert_to_jsdoc_input.txt +9452 -0
- package/frontend/tools/convert_to_jsdoc_output.txt +7626 -0
- package/frontend/tools/convert_to_jsdoc_tmp.js +345 -0
- package/frontend/tools/scan_mixed_imports.js +69 -0
- package/package.json +1 -10
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"project": "volt",
|
|
4
|
+
"version": "1.1.1",
|
|
5
|
+
"entry": [
|
|
6
|
+
"backend/src/index.ts"
|
|
7
|
+
],
|
|
8
|
+
"exclude": [
|
|
9
|
+
"**/*.js"
|
|
10
|
+
],
|
|
11
|
+
"sort": "ascending",
|
|
12
|
+
"favicon": "https://raw.githubusercontent.com/vandenberghinc/volt/master/dev/media/icon/favicon.ico",
|
|
13
|
+
"icon": {
|
|
14
|
+
"dark": "https://raw.githubusercontent.com/vandenberghinc/volt/master/dev/media/icon/stroke.png",
|
|
15
|
+
"light": "https://raw.githubusercontent.com/vandenberghinc/volt/master/dev/media/icon/stroke.dark.png",
|
|
16
|
+
"height": 30
|
|
17
|
+
},
|
|
18
|
+
"theme": {
|
|
19
|
+
"dark": {
|
|
20
|
+
"extends": "dark",
|
|
21
|
+
"primary": "linear-gradient(70deg, #F9DB4A 0%, #EA682C 100%)",
|
|
22
|
+
"primary_base": "#EA682C",
|
|
23
|
+
"bg": "#1C232E"
|
|
24
|
+
},
|
|
25
|
+
"light": {
|
|
26
|
+
"extends": "light",
|
|
27
|
+
"primary": "linear-gradient(70deg, #F9DB4A 0%, #EA682C 100%)",
|
|
28
|
+
"primary_base": "#EA682C"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"sections": [
|
|
32
|
+
{
|
|
33
|
+
"text": "Node.js",
|
|
34
|
+
"url": "/docs/miF5fmUsvgaEcqLP/volt/latest"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"text": "Browser",
|
|
38
|
+
"url": "/docs/miF5fmUsvgaEcqLP/volt-web/latest"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"project": "volt-web",
|
|
44
|
+
"version": "1.1.1",
|
|
45
|
+
"entry": [
|
|
46
|
+
"frontend/src/index.ts"
|
|
47
|
+
],
|
|
48
|
+
"exclude": [
|
|
49
|
+
"**/*.js"
|
|
50
|
+
],
|
|
51
|
+
"sort": "ascending",
|
|
52
|
+
"favicon": "https://raw.githubusercontent.com/vandenberghinc/volt/master/dev/media/icon/favicon.ico",
|
|
53
|
+
"icon": {
|
|
54
|
+
"dark": "https://raw.githubusercontent.com/vandenberghinc/volt/master/dev/media/icon/stroke.png",
|
|
55
|
+
"light": "https://raw.githubusercontent.com/vandenberghinc/volt/master/dev/media/icon/stroke.dark.png",
|
|
56
|
+
"height": 30
|
|
57
|
+
},
|
|
58
|
+
"theme": {
|
|
59
|
+
"dark": {
|
|
60
|
+
"extends": "dark",
|
|
61
|
+
"primary": "linear-gradient(70deg, #F9DB4A 0%, #EA682C 100%)",
|
|
62
|
+
"primary_base": "#EA682C",
|
|
63
|
+
"bg": "#1C232E"
|
|
64
|
+
},
|
|
65
|
+
"light": {
|
|
66
|
+
"extends": "light",
|
|
67
|
+
"primary": "linear-gradient(70deg, #F9DB4A 0%, #EA682C 100%)",
|
|
68
|
+
"primary_base": "#EA682C"
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"sections": [
|
|
72
|
+
{
|
|
73
|
+
"text": "Node.js",
|
|
74
|
+
"url": "/docs/miF5fmUsvgaEcqLP/volt/latest"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"text": "Browser",
|
|
78
|
+
"url": "/docs/miF5fmUsvgaEcqLP/volt-web/latest"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
]
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Author: Daan van den Bergh
|
|
3
|
+
* Copyright: © 2022 - 2024 Daan van den Bergh.
|
|
4
|
+
* @deprecated use tsc & nodemon instead.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// // ---------------------------------------------------------
|
|
8
|
+
// // Libraries.
|
|
9
|
+
|
|
10
|
+
// import * as fs from "fs";
|
|
11
|
+
// import * as path from "path";
|
|
12
|
+
// import { spawn, type ChildProcess } from "child_process";
|
|
13
|
+
// import * as vlib from "@vandenberghinc/vlib";
|
|
14
|
+
// import { BrowserPreview } from "./plugins/browser.js";
|
|
15
|
+
// import { logger, LogSource } from "./logger.js";
|
|
16
|
+
|
|
17
|
+
// // ---------------------------------------------------------
|
|
18
|
+
// // Static endpoints file watcher watcher only used for checking static files with reloads.
|
|
19
|
+
|
|
20
|
+
// class StaticFileWatcher {
|
|
21
|
+
// private server: any;
|
|
22
|
+
// private mtimes: Map<string, number>;
|
|
23
|
+
// private endpoints: Map<string, any>;
|
|
24
|
+
// // @ts-ignore
|
|
25
|
+
// private log_source: LogSource;
|
|
26
|
+
// private interval: NodeJS.Timeout | undefined;
|
|
27
|
+
|
|
28
|
+
// constructor(server: any) {
|
|
29
|
+
// this.server = server;
|
|
30
|
+
// this.mtimes = new Map();
|
|
31
|
+
// this.endpoints = new Map();
|
|
32
|
+
// this.log_source = new LogSource("StaticFileWatcher");
|
|
33
|
+
// }
|
|
34
|
+
|
|
35
|
+
// async start(): Promise<void> {
|
|
36
|
+
// // Set interval.
|
|
37
|
+
// this.interval = setInterval(async () => {
|
|
38
|
+
// // Changed endpoints.
|
|
39
|
+
// const changed_endpoints: string[] = [];
|
|
40
|
+
// let changed_aspect_ratio = false;
|
|
41
|
+
|
|
42
|
+
// // Check file paths.
|
|
43
|
+
// for (const endpoint of this.endpoints.values()) {
|
|
44
|
+
// if (endpoint._path && !endpoint.view?.is_js_ts_view) {
|
|
45
|
+
// const path = new vlib.Path(endpoint._path);
|
|
46
|
+
// if (path.mtime !== this.mtimes.get(endpoint._path)) {
|
|
47
|
+
// if (this.mtimes.get(endpoint._path) != null) {
|
|
48
|
+
// logger.log(1, `Refreshing endpoint ${endpoint.method}:${endpoint.endpoint}.`)
|
|
49
|
+
|
|
50
|
+
// // Image.
|
|
51
|
+
// if (endpoint.is_image_endpoint) {
|
|
52
|
+
// endpoint._clear_cache();
|
|
53
|
+
// const aspect_ratio = await endpoint.get_aspect_ratio()
|
|
54
|
+
// if (aspect_ratio && this.server.statics_aspect_ratios.get(endpoint.endpoint) !== aspect_ratio) {
|
|
55
|
+
// changed_aspect_ratio = true;
|
|
56
|
+
// this.server.statics_aspect_ratios.set(endpoint.endpoint, aspect_ratio);
|
|
57
|
+
// }
|
|
58
|
+
// }
|
|
59
|
+
|
|
60
|
+
// // Static file.
|
|
61
|
+
// else if (endpoint.view == null) {
|
|
62
|
+
// endpoint._load_data_by_path(this.server);
|
|
63
|
+
// changed_endpoints.push(endpoint.endpoint);
|
|
64
|
+
// }
|
|
65
|
+
|
|
66
|
+
// // Refresh browser.
|
|
67
|
+
// if (this.server.browser_preview) {
|
|
68
|
+
// await this.server.browser_preview.refresh(endpoint.endpoint);
|
|
69
|
+
// }
|
|
70
|
+
// }
|
|
71
|
+
// this.mtimes.set(endpoint._path, path.mtime);
|
|
72
|
+
// }
|
|
73
|
+
// }
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
// // Iterate all endpoints using view to check if any included scripts have changed.
|
|
77
|
+
// for (const endpoint of this.endpoints.values()) {
|
|
78
|
+
// if (endpoint.view && !endpoint.view?.is_js_ts_view) {
|
|
79
|
+
// let changed = changed_aspect_ratio;
|
|
80
|
+
// if (!changed && changed_endpoints.length > 0) {
|
|
81
|
+
// changed = endpoint.view._embedded_sources.some(url => {
|
|
82
|
+
// return changed_endpoints.includes(url);
|
|
83
|
+
// });
|
|
84
|
+
// }
|
|
85
|
+
// if (changed) {
|
|
86
|
+
// logger.log(1, `Refreshing endpoint ${endpoint.method}:${endpoint.endpoint}.`)
|
|
87
|
+
// endpoint._refresh(this.server)
|
|
88
|
+
// if (this.server.browser_preview) {
|
|
89
|
+
// await this.server.browser_preview.refresh(endpoint.endpoint);
|
|
90
|
+
// }
|
|
91
|
+
// }
|
|
92
|
+
// }
|
|
93
|
+
// }
|
|
94
|
+
// }, 500)
|
|
95
|
+
// }
|
|
96
|
+
|
|
97
|
+
// add(endpoint: any): void {
|
|
98
|
+
// if (endpoint._path) {
|
|
99
|
+
// this.mtimes.set(endpoint._path, new vlib.Path(endpoint._path).mtime)
|
|
100
|
+
// }
|
|
101
|
+
// this.endpoints.set(endpoint.endpoint, endpoint);
|
|
102
|
+
// }
|
|
103
|
+
|
|
104
|
+
// has(endpoint: string): boolean {
|
|
105
|
+
// return this.endpoints.has(endpoint);
|
|
106
|
+
// }
|
|
107
|
+
|
|
108
|
+
// stop(): void {
|
|
109
|
+
// if (this.interval) {
|
|
110
|
+
// clearInterval(this.interval)
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
// // ---------------------------------------------------------
|
|
116
|
+
// // File watcher watching entire files and restarting when needed.
|
|
117
|
+
|
|
118
|
+
// /* @docs:
|
|
119
|
+
// @chapter: Server
|
|
120
|
+
// @title: FileWatcher
|
|
121
|
+
// @description:
|
|
122
|
+
// Used to watch all included files and restart the server when any changes have been made.
|
|
123
|
+
|
|
124
|
+
// @parameter:
|
|
125
|
+
// @name: source
|
|
126
|
+
// @description: The path to the source directory to watch.
|
|
127
|
+
// @type: string
|
|
128
|
+
// @parameter:
|
|
129
|
+
// @name: config
|
|
130
|
+
// @description: The path to the server's configuration file.
|
|
131
|
+
// @type: string
|
|
132
|
+
// @parameter:
|
|
133
|
+
// @name: interval
|
|
134
|
+
// @description: The interval in milliseconds between file change checks.
|
|
135
|
+
// @type: number
|
|
136
|
+
// @parameter:
|
|
137
|
+
// @name: start_file
|
|
138
|
+
// @description: The optional start js file to start the server.
|
|
139
|
+
// @type: string
|
|
140
|
+
// */
|
|
141
|
+
// class FileWatcher {
|
|
142
|
+
// private source: string;
|
|
143
|
+
// private config?: string;
|
|
144
|
+
// private interval: number;
|
|
145
|
+
// private excluded: string[];
|
|
146
|
+
// private additional_paths: string[];
|
|
147
|
+
// private start_file?: string;
|
|
148
|
+
// // @ts-ignore
|
|
149
|
+
// private log_source: LogSource;
|
|
150
|
+
// private args: string[];
|
|
151
|
+
// private mtimes: Record<string, number>;
|
|
152
|
+
// public promise: Promise<any>;
|
|
153
|
+
// private proc!: ChildProcess;
|
|
154
|
+
// private has_changed: boolean = false;
|
|
155
|
+
// private _com_file?: any;
|
|
156
|
+
|
|
157
|
+
// constructor({
|
|
158
|
+
// source,
|
|
159
|
+
// config = undefined,
|
|
160
|
+
// interval = 750,
|
|
161
|
+
// excluded = [],
|
|
162
|
+
// additional_paths = [],
|
|
163
|
+
// start_file = undefined,
|
|
164
|
+
// }: {
|
|
165
|
+
// source: vlib.Path | string,
|
|
166
|
+
// config?: string,
|
|
167
|
+
// interval?: number,
|
|
168
|
+
// excluded?: string[],
|
|
169
|
+
// additional_paths?: string[],
|
|
170
|
+
// start_file?: string,
|
|
171
|
+
// }) {
|
|
172
|
+
// // Arguments.
|
|
173
|
+
// // this.source = source == null ? source : new vlib.Path(source).abs().str();
|
|
174
|
+
// this.config = config;
|
|
175
|
+
// this.interval = interval;
|
|
176
|
+
// this.excluded = excluded ?? [];
|
|
177
|
+
// this.excluded = this.excluded.filter(Boolean).map(path => new vlib.Path(path).abs().str())
|
|
178
|
+
// this.start_file = start_file;
|
|
179
|
+
|
|
180
|
+
// // Check source.
|
|
181
|
+
// if (source) {
|
|
182
|
+
// source = new vlib.Path(source).abs().str();
|
|
183
|
+
// }
|
|
184
|
+
// if ((source as any) instanceof vlib.Path) {
|
|
185
|
+
// source = (source as any).str();
|
|
186
|
+
// }
|
|
187
|
+
// this.source = source as string;
|
|
188
|
+
// if (this.source == null) {
|
|
189
|
+
// throw Error("Define argument: source.");
|
|
190
|
+
// }
|
|
191
|
+
// this.log_source = new LogSource("FileWatcher");
|
|
192
|
+
|
|
193
|
+
// // Check if the excluded paths exist for user mistakes, these happen often.
|
|
194
|
+
// this.excluded.forEach(path => {
|
|
195
|
+
// if (!new vlib.Path(path).exists()) {
|
|
196
|
+
// logger.warn(1, `Excluded file watcher path ${path} does not exist.`);
|
|
197
|
+
// }
|
|
198
|
+
// })
|
|
199
|
+
|
|
200
|
+
// // Attributes.
|
|
201
|
+
// this.additional_paths = additional_paths.map(path => new vlib.Path(path).abs().str());
|
|
202
|
+
// this.args = [];
|
|
203
|
+
// this.mtimes = {};
|
|
204
|
+
// this.promise = new Promise(() => {});
|
|
205
|
+
// }
|
|
206
|
+
|
|
207
|
+
// // Add path.
|
|
208
|
+
// add_path(path: string | vlib.Path): void {
|
|
209
|
+
// try {
|
|
210
|
+
// const add = new vlib.Path(path).abs().str();
|
|
211
|
+
// logger.log(2, "Add file watcher exclude", add)
|
|
212
|
+
// this.additional_paths.push(add)
|
|
213
|
+
// } catch (e) {
|
|
214
|
+
// logger.warn(0, `Additional file watcher path ${path.toString()} does not exist.`);
|
|
215
|
+
// }
|
|
216
|
+
// }
|
|
217
|
+
|
|
218
|
+
// // Add exclude.
|
|
219
|
+
// add_exclude(path: string | vlib.Path): void {
|
|
220
|
+
// try {
|
|
221
|
+
// const add = new vlib.Path(path).abs().str();
|
|
222
|
+
// logger.log(2, "Add file watcher exclude", add)
|
|
223
|
+
// this.excluded.push(add)
|
|
224
|
+
// } catch (e) {
|
|
225
|
+
// logger.warn(1, `Excluded file watcher path ${path.toString()} does not exist.`);
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
228
|
+
|
|
229
|
+
// // Start.
|
|
230
|
+
// async start(): Promise<void> {
|
|
231
|
+
// process.on('SIGTERM', () => {
|
|
232
|
+
// this.proc.kill("SIGTERM");
|
|
233
|
+
// process.exit(0)
|
|
234
|
+
// });
|
|
235
|
+
// process.on('SIGINT', () => {
|
|
236
|
+
// this.proc.kill("SIGINT");
|
|
237
|
+
// process.exit(0)
|
|
238
|
+
// });
|
|
239
|
+
|
|
240
|
+
// // Spawn process.
|
|
241
|
+
// this.scan_files();
|
|
242
|
+
// this.has_changed = false;
|
|
243
|
+
// this.spawn_process();
|
|
244
|
+
// this.args.push("--file-watcher-restart")
|
|
245
|
+
|
|
246
|
+
// // Start scan loop.
|
|
247
|
+
// await this.scan();
|
|
248
|
+
// }
|
|
249
|
+
|
|
250
|
+
// // Scan.
|
|
251
|
+
// async scan(): Promise<void> {
|
|
252
|
+
// this.scan_files()
|
|
253
|
+
// let interval = this.interval;
|
|
254
|
+
// if (this.has_changed) {
|
|
255
|
+
// interval += 250;
|
|
256
|
+
// await new Promise((resolve) => {
|
|
257
|
+
// setTimeout(async () => {
|
|
258
|
+
// this.scan_files()
|
|
259
|
+
// this.has_changed = false;
|
|
260
|
+
// await this.restart_process();
|
|
261
|
+
// resolve(null);
|
|
262
|
+
// }, 250)
|
|
263
|
+
// })
|
|
264
|
+
// }
|
|
265
|
+
// setTimeout(() => this.scan(), interval);
|
|
266
|
+
// }
|
|
267
|
+
|
|
268
|
+
// // Scan files.
|
|
269
|
+
// scan_files(): void {
|
|
270
|
+
// const scan_files = (dir: string) => {
|
|
271
|
+
// fs.readdirSync(dir).forEach((name) => scan_file(path.join(dir, name)));
|
|
272
|
+
// }
|
|
273
|
+
// const scan_file = (path: string) => {
|
|
274
|
+
// if (this.excluded.includes(path)) {
|
|
275
|
+
// return null;
|
|
276
|
+
// }
|
|
277
|
+
// let stat;
|
|
278
|
+
// try {
|
|
279
|
+
// stat = fs.statSync(path);
|
|
280
|
+
// } catch (e) {
|
|
281
|
+
// delete this.mtimes[path]; // a file was deleted.
|
|
282
|
+
// return;
|
|
283
|
+
// }
|
|
284
|
+
// if (this.mtimes[path] != stat.mtimeMs) {
|
|
285
|
+
// if (this.mtimes[path] != null) {
|
|
286
|
+
// logger.log(1, `Source file ${path} changed.`);
|
|
287
|
+
// }
|
|
288
|
+
// this.has_changed = true;
|
|
289
|
+
// }
|
|
290
|
+
// this.mtimes[path] = stat.mtimeMs;
|
|
291
|
+
// if (stat.isDirectory()) {
|
|
292
|
+
// scan_files(path)
|
|
293
|
+
// }
|
|
294
|
+
// }
|
|
295
|
+
// scan_files(this.source);
|
|
296
|
+
// this.additional_paths.forEach((path) => scan_file(path));
|
|
297
|
+
// }
|
|
298
|
+
|
|
299
|
+
// // Spawn process.
|
|
300
|
+
// spawn_process(): void {
|
|
301
|
+
// if (this._com_file === undefined) {
|
|
302
|
+
// // @ts-ignore
|
|
303
|
+
// this._com_file = new vlib.Path(`/tmp/${String.random(12)}`);
|
|
304
|
+
// }
|
|
305
|
+
// if (this.config == null && this.start_file == null) {
|
|
306
|
+
// throw new Error("When 'Server.file_watcher.start_file' is undefined, the server must be started using `$ volt --start` in order to use the file watcher.");
|
|
307
|
+
// }
|
|
308
|
+
// this.proc = spawn(
|
|
309
|
+
// this.start_file ? "node" : "volt",
|
|
310
|
+
// this.start_file
|
|
311
|
+
// ? [this.start_file, ...this.args, ...process.argv]
|
|
312
|
+
// : ["--start", "--config", this.config || "", ...this.args, ...process.argv],
|
|
313
|
+
// {
|
|
314
|
+
// cwd: this.source,
|
|
315
|
+
// stdio: "inherit",
|
|
316
|
+
// env: {
|
|
317
|
+
// ...process.env,
|
|
318
|
+
// "VOLT_FILE_WATCHER": "1",
|
|
319
|
+
// "VOLT_STARTED_FILE": this._com_file.str(),
|
|
320
|
+
// },
|
|
321
|
+
// }
|
|
322
|
+
// );
|
|
323
|
+
// this.proc.on("exit", (code) => {
|
|
324
|
+
// if (code === 0) {
|
|
325
|
+
// this.scan_files(); // scan again so any subsequent file changes will be updated as well.
|
|
326
|
+
// this.has_changed = false;
|
|
327
|
+
// this.spawn_process();
|
|
328
|
+
// } else {
|
|
329
|
+
// process.exit(code || 1);
|
|
330
|
+
// }
|
|
331
|
+
// })
|
|
332
|
+
// this.proc.on("error", (e) => {
|
|
333
|
+
// console.error(e)
|
|
334
|
+
// process.exit(1);
|
|
335
|
+
// })
|
|
336
|
+
// }
|
|
337
|
+
|
|
338
|
+
// // Spawn process.
|
|
339
|
+
// async restart_process(): Promise<void> {
|
|
340
|
+
// logger.log(0, `Restarting server due to file changes.`);
|
|
341
|
+
// this._com_file.save_sync("0");
|
|
342
|
+
// this.has_changed = false;
|
|
343
|
+
// this.proc.kill("SIGINT");
|
|
344
|
+
// await new Promise<void>((resolve) => {
|
|
345
|
+
// const loop = () => {
|
|
346
|
+
// if (this._com_file.load_sync() === "1") {
|
|
347
|
+
// return resolve();
|
|
348
|
+
// }
|
|
349
|
+
// setTimeout(loop, 150)
|
|
350
|
+
// }
|
|
351
|
+
// loop();
|
|
352
|
+
// })
|
|
353
|
+
// }
|
|
354
|
+
// }
|
|
355
|
+
|
|
356
|
+
// // ---------------------------------------------------------
|
|
357
|
+
// // Exports.
|
|
358
|
+
|
|
359
|
+
// export { StaticFileWatcher, FileWatcher };
|