@vandenberghinc/volt 1.1.6 → 1.1.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.
@@ -29,7 +29,7 @@ import { Endpoint, EndpointOptions } from "./endpoint.js";
29
29
  import { ImageEndpoint } from "./image_endpoint.js";
30
30
  import { Stream } from "./stream.js";
31
31
  import { Database, Collection, UIDCollection } from "./database.js";
32
- import { /*StaticFileWatcher,*/ FileWatcher } from "./file_watcher.js";
32
+ // import { /*StaticFileWatcher,*/ FileWatcher } from "./file_watcher.js";
33
33
  import { Users } from "./users.js";
34
34
  import { Paddle } from "./payments/paddle.js";
35
35
  import { RateLimits, RateLimitServer, RateLimitClient } from "./rate_limit.js";
@@ -794,7 +794,7 @@ export class Server {
794
794
  public additional_sitemap_endpoints: string[];
795
795
  public log_level: number;
796
796
  public tls?: TLSConfig;
797
- public file_watcher?: FileWatcher;
797
+ // public file_watcher?: FileWatcher;
798
798
  // public admin: AdminConfig;
799
799
  // public ts: TypeScriptConfig;
800
800
  public lightweight: boolean;
@@ -820,7 +820,7 @@ export class Server {
820
820
  private _on_stop: Array<() => void | Promise<void>>;
821
821
  // public browser_preview?: BrowserPreview;
822
822
  // public static_file_watcher: StaticFileWatcher;
823
- public is_file_watcher: boolean;
823
+ // public is_file_watcher: boolean;
824
824
  public daemon?: vlib.Daemon;
825
825
  private _stop_tscompiler_watcher?: () => void;
826
826
 
@@ -832,7 +832,7 @@ export class Server {
832
832
  public logger: typeof logger;
833
833
 
834
834
  constructor({
835
- ip = "127.0.0.1",
835
+ ip, // leave undefined for blank detection.
836
836
  port = 8000,
837
837
  domain,
838
838
  is_primary = true,
@@ -881,7 +881,7 @@ export class Server {
881
881
  localhost = true,
882
882
  multiprocessing = true,
883
883
  processes = null,
884
- file_watcher = false,
884
+ // file_watcher = false,
885
885
  offline = false,
886
886
  additional_sitemap_endpoints = [],
887
887
  log_level = 0,
@@ -923,7 +923,7 @@ export class Server {
923
923
  localhost?: boolean;
924
924
  multiprocessing?: boolean;
925
925
  processes?: number | null;
926
- file_watcher?: FileWatcher | Record<string, any> | boolean;
926
+ // file_watcher?: FileWatcher | Record<string, any> | boolean;
927
927
  offline?: boolean;
928
928
  additional_sitemap_endpoints?: string[];
929
929
  log_level?: number;
@@ -1060,7 +1060,7 @@ export class Server {
1060
1060
  localhost: { type: "boolean", required: false },
1061
1061
  multiprocessing: {type: "boolean", required: false, default: true},
1062
1062
  processes: {type: "number", required: false, default: null},
1063
- file_watcher: {type: ["null", "boolean", "object", FileWatcher], required: false},
1063
+ // file_watcher: {type: ["null", "boolean", "object", FileWatcher], required: false},
1064
1064
  offline: {type: "boolean", default: false},
1065
1065
  additional_sitemap_endpoints: {type: "array", default: []},
1066
1066
  log_level: {type: "number", default: 0},
@@ -1086,7 +1086,7 @@ export class Server {
1086
1086
 
1087
1087
  // Assign attributes directly.
1088
1088
  this.port = port;
1089
- this.ip = ip;
1089
+ this.ip = ip ?? "127.0.0.1";
1090
1090
  this.is_primary = is_primary && libcluster.isPrimary;
1091
1091
  this.source = new vlib.Path(source);
1092
1092
  this.favicon = favicon;
@@ -1118,6 +1118,9 @@ export class Server {
1118
1118
  if (localhost) {
1119
1119
  this.ip = "127.0.0.1";
1120
1120
  this.domain = this.ip + ":" + (port + (this.tls ? 1 : 0));
1121
+ } else if (!localhost && ip == null) { // use argument ip not attr since that already has a default.
1122
+ this.ip = vlib.Network.private_ip();
1123
+ this.domain = this.ip + ":" + (port + (this.tls ? 1 : 0));
1121
1124
  }
1122
1125
 
1123
1126
  /* @performance */ this.performance = new vlib.Performance("Server performance");
@@ -1239,47 +1242,47 @@ export class Server {
1239
1242
  // this.static_file_watcher = new StaticFileWatcher(this);
1240
1243
 
1241
1244
  // Initialize file watcher.
1242
- if (file_watcher !== false) {
1243
- console.warn("[Volt] Argument file_watcher is deprecated. This may be removed in future versions.");
1244
- if (file_watcher == null) {
1245
- // Null.
1246
- file_watcher = {};
1247
- }
1248
- if (!(file_watcher as Record<string, any>).source) {
1249
- // Source.
1250
- (file_watcher as Record<string, any>).source = this.source.str();
1251
- }
1252
- if (!(file_watcher instanceof FileWatcher)) {
1253
- // Initialize.
1254
- file_watcher = new FileWatcher(file_watcher as any);
1255
- }
1256
- this.file_watcher = file_watcher as FileWatcher;
1257
- }
1258
- else {
1259
- this.file_watcher = undefined;
1260
- }
1245
+ // if (file_watcher !== false) {
1246
+ // console.warn("[Volt] Argument file_watcher is deprecated. This may be removed in future versions.");
1247
+ // if (file_watcher == null) {
1248
+ // // Null.
1249
+ // file_watcher = {};
1250
+ // }
1251
+ // if (!(file_watcher as Record<string, any>).source) {
1252
+ // // Source.
1253
+ // (file_watcher as Record<string, any>).source = this.source.str();
1254
+ // }
1255
+ // if (!(file_watcher instanceof FileWatcher)) {
1256
+ // // Initialize.
1257
+ // file_watcher = new FileWatcher(file_watcher as any);
1258
+ // }
1259
+ // this.file_watcher = file_watcher as FileWatcher;
1260
+ // }
1261
+ // else {
1262
+ // this.file_watcher = undefined;
1263
+ // }
1261
1264
 
1262
1265
  // File watcher.
1263
- if (
1264
- process.env.VOLT_NO_FILE_WATCHER == null &&
1265
- !process.argv.includes("--no-file-watcher") &&
1266
- this.production === false &&
1267
- file_watcher !== false &&
1268
- process.env.VOLT_FILE_WATCHER !== '1'
1269
- ) {
1270
-
1271
- // Disable primary for when users access is_primary.
1272
- this.is_primary = false;
1273
-
1274
- // Enable file watcher.
1275
- this.is_file_watcher = true;
1276
- }
1266
+ // if (
1267
+ // process.env.VOLT_NO_FILE_WATCHER == null &&
1268
+ // !process.argv.includes("--no-file-watcher") &&
1269
+ // this.production === false &&
1270
+ // // file_watcher !== false &&
1271
+ // process.env.VOLT_FILE_WATCHER !== '1'
1272
+ // ) {
1273
+
1274
+ // // Disable primary for when users access is_primary.
1275
+ // this.is_primary = false;
1276
+
1277
+ // // Enable file watcher.
1278
+ // this.is_file_watcher = true;
1279
+ // }
1277
1280
 
1278
- // No file watcher.
1279
- else {
1281
+ // // No file watcher.
1282
+ // else {
1280
1283
 
1281
1284
  // Disable file watcher.
1282
- this.is_file_watcher = false;
1285
+ // this.is_file_watcher = false;
1283
1286
 
1284
1287
  // Set logger.
1285
1288
  logger.log_level = this.log_level;
@@ -1341,7 +1344,7 @@ export class Server {
1341
1344
  // this.blacklist = new Blacklist({api_key: this.honey_pot_key});
1342
1345
  // }
1343
1346
 
1344
- }
1347
+ // }
1345
1348
 
1346
1349
  // Other keys.
1347
1350
  this.keys = {};
@@ -1448,9 +1451,9 @@ export class Server {
1448
1451
  }
1449
1452
 
1450
1453
  // Create default endpoints.
1451
- private _create_default_endpoints(): string[] {
1454
+ private _create_default_endpoints() {
1452
1455
  // Vars.
1453
- const additional_file_watcher_paths: string[] = [];
1456
+ // const additional_file_watcher_paths: string[] = [];
1454
1457
 
1455
1458
  // Add favicon.
1456
1459
  if (this.favicon != null) {
@@ -1564,7 +1567,7 @@ export class Server {
1564
1567
  })
1565
1568
 
1566
1569
  // Handler.
1567
- return additional_file_watcher_paths;
1570
+ // return additional_file_watcher_paths;
1568
1571
  }
1569
1572
 
1570
1573
  // Create the sitemap endpoint.
@@ -1967,55 +1970,51 @@ export class Server {
1967
1970
  /* @performance */ this.performance.start()
1968
1971
 
1969
1972
  // File watcher.
1970
- if (this.is_file_watcher) {
1971
- // Disable primary for when users access is_primary.
1972
- this.is_primary = false;
1973
+ // if (this.is_file_watcher) {
1974
+ // // Disable primary for when users access is_primary.
1975
+ // this.is_primary = false;
1973
1976
 
1974
- // Create default endpoints for excluded static file watch paths.
1975
- this._create_default_endpoints();
1976
-
1977
- // Exclude the typescript output directory from the file watcher.
1978
- // if (this.ts.output) {
1979
- // this.file_watcher!.add_exclude(this.ts.output);
1980
- // }
1981
-
1982
- // Add the volt backend source files to the additional files.
1983
- this.file_watcher!.add_path(__dirname);
1984
- this.file_watcher!.add_exclude(`${__dirname}/frontend_globals.js`);
1985
-
1986
- // Excluded.
1987
- this.file_watcher!.add_exclude(this.source.join(".db"));
1988
- this.file_watcher!.add_exclude(this.source.join(".rate_limit"));
1989
- this.file_watcher!.add_exclude(this.source.join(".logs"));
1990
-
1991
- // Exclude static files.
1992
- this.statics.forEach(item => {
1993
- if (typeof item === "string" || item instanceof vlib.Path) {
1994
- this.file_watcher!.add_exclude(item);
1995
- }
1996
- else {
1997
- this.file_watcher!.add_exclude(item.path)
1998
- }
1999
- })
2000
-
2001
- if (!this.production) {
2002
- [
2003
- `${process.env.PERSISTANCE}/private/dev/vinc/vlib/js/vlib.js`,
2004
- `${process.env.PERSISTANCE}/private/dev/vinc/vhighlight/vhighlight.js`,
2005
- ].forEach(path => {
2006
- const vpath = new vlib.Path(path);
2007
- if (vpath.exists()) {
2008
- this.file_watcher!.add_exclude(vpath.str());
2009
- }
2010
- })
2011
- }
1977
+ // // Create default endpoints for excluded static file watch paths.
1978
+ // this._create_default_endpoints();
1979
+
1980
+ // // Exclude the typescript output directory from the file watcher.
1981
+ // // if (this.ts.output) {
1982
+ // // this.file_watcher!.add_exclude(this.ts.output);
1983
+ // // }
1984
+
1985
+ // // Add the volt backend source files to the additional files.
1986
+ // this.file_watcher!.add_path(__dirname);
1987
+ // this.file_watcher!.add_exclude(`${__dirname}/frontend_globals.js`);
1988
+
1989
+ // // Exclude static files.
1990
+ // this.statics.forEach(item => {
1991
+ // if (typeof item === "string" || item instanceof vlib.Path) {
1992
+ // this.file_watcher!.add_exclude(item);
1993
+ // }
1994
+ // else {
1995
+ // this.file_watcher!.add_exclude(item.path)
1996
+ // }
1997
+ // })
1998
+
1999
+ // if (!this.production) {
2000
+ // [
2001
+ // `${process.env.PERSISTANCE}/private/dev/vinc/vlib/js/vlib.js`,
2002
+ // `${process.env.PERSISTANCE}/private/dev/vinc/vhighlight/vhighlight.js`,
2003
+ // ].forEach(path => {
2004
+ // const vpath = new vlib.Path(path);
2005
+ // if (vpath.exists()) {
2006
+ // this.file_watcher!.add_exclude(vpath.str());
2007
+ // }
2008
+ // })
2009
+ // }
2010
+
2011
+ // // Stop.
2012
+ // return;
2013
+ // }
2012
2014
 
2013
- // Stop.
2014
- return;
2015
- }
2015
+ // // No file watcher.
2016
+ // else {
2016
2017
 
2017
- // No file watcher.
2018
- else {
2019
2018
  // Create HTTPS server.
2020
2019
  if (this.tls) {
2021
2020
  this.https = http2.createSecureServer(
@@ -2057,10 +2056,8 @@ export class Server {
2057
2056
  }
2058
2057
 
2059
2058
  /* @performance */ this.performance.end("create-http-server");
2060
- }
2061
-
2062
- // No file watcher.
2063
- const file_watcher_restart = process.argv.includes("--file-watcher-restart");
2059
+
2060
+ // }
2064
2061
 
2065
2062
  // Start the database.
2066
2063
  if (this.db) {
@@ -2440,11 +2437,11 @@ export class Server {
2440
2437
  await this.initialize();
2441
2438
 
2442
2439
  // Inside file watcher process.
2443
- if (this.is_file_watcher) {
2444
- this.file_watcher!.start();
2445
- await this.file_watcher!.promise;
2446
- return ;
2447
- }
2440
+ // if (this.is_file_watcher) {
2441
+ // this.file_watcher!.start();
2442
+ // await this.file_watcher!.promise;
2443
+ // return ;
2444
+ // }
2448
2445
 
2449
2446
  // Start static file watcher.
2450
2447
  // if (!this.production && this.file_watcher) {
@@ -2952,12 +2949,13 @@ export class Server {
2952
2949
 
2953
2950
  // Add endpoint.
2954
2951
  this.endpoints.set(`${endpoint.endpoint}:${endpoint.method}`, endpoint);
2955
- if (!this.production) {
2956
- if (endpoint._path && this.file_watcher?.add_exclude) {
2957
- this.file_watcher!.add_exclude(endpoint._path);
2958
- }
2959
- // this.static_file_watcher.add(endpoint);
2960
- }
2952
+
2953
+ // if (!this.production) {
2954
+ // if (endpoint._path && this.file_watcher?.add_exclude) {
2955
+ // this.file_watcher!.add_exclude(endpoint._path);
2956
+ // }
2957
+ // // this.static_file_watcher.add(endpoint);
2958
+ // }
2961
2959
  }
2962
2960
  return this;
2963
2961
  }
@@ -18,7 +18,7 @@ export * from "./server.js"
18
18
  export * from "./database.js"
19
19
  export * from "./rate_limit.js"
20
20
  export * from "./logger.js"
21
- export * from "./file_watcher.js"
21
+ // export * from "./file_watcher.js"
22
22
  export * as Mail from "./plugins/mail.js"
23
23
  // export * as PDF from "./plugins/pdf.js"
24
24
  export * as TypeScript from "./plugins/ts/compiler.js"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Daan van den Bergh",
3
3
  "name": "@vandenberghinc/volt",
4
- "version": "1.1.6",
4
+ "version": "1.1.8",
5
5
  "description": "",
6
6
  "type": "module",
7
7
  "types": "./backend/dist/esm/volt.d.ts",
@@ -49,8 +49,7 @@
49
49
  "pdfkit": "^0.14.0",
50
50
  "playwright": "^1.50.1",
51
51
  "rollup-plugin-typescript2": "^0.36.0",
52
- "sharp": "^0.33.5",
53
- "vhighlight": "file:../vhighlight"
52
+ "sharp": "^0.33.5"
54
53
  },
55
54
  "devDependencies": {
56
55
  "@types/node": "^22.13.8",