bakit 2.0.0-alpha.23 → 2.0.0-alpha.24

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/dist/cli.js CHANGED
@@ -1,14 +1,15 @@
1
1
  import { config } from 'dotenv';
2
2
  import { program } from 'commander';
3
3
  import { fork } from 'child_process';
4
+ import path, { resolve, relative, sep } from 'path';
4
5
  import chokidar from 'chokidar';
5
- import path, { relative, sep } from 'path';
6
- import { pathToFileURL } from 'url';
7
6
 
8
7
  // src/cli/bin.ts
9
8
  function getTopLevelDirectory(path2, entryDir) {
10
9
  return relative(entryDir, path2).split(sep)[0] ?? null;
11
10
  }
11
+
12
+ // src/cli/process/DevProcessManager.ts
12
13
  var DevProcessManager = class {
13
14
  constructor(options) {
14
15
  this.options = options;
@@ -57,7 +58,7 @@ var DevProcessManager = class {
57
58
  return;
58
59
  let top = getTopLevelDirectory(path2, this.options.rootDir);
59
60
  if (top && this.options.hotDirs.includes(top)) {
60
- this.child.connected && this.child.send({ type: `hmr:${top}`, url: pathToFileURL(path2).href });
61
+ this.child.connected && this.child.send({ type: `hmr:${top}`, path: resolve(path2) });
61
62
  return;
62
63
  }
63
64
  this.scheduleRestart();
package/dist/hooks.js CHANGED
@@ -5,9 +5,12 @@ import { dirname, resolve as resolve$1, basename } from 'path';
5
5
  import { fileURLToPath, pathToFileURL } from 'url';
6
6
 
7
7
  // src/lib/loader/hooks.ts
8
- var EXTENSIONS = [".js", ".ts"], inDev = false, parentPort, versions, esbuild;
8
+ var EXTENSIONS = [".js", ".ts"], parentPort, versions, esbuild;
9
+ function isDevelopment() {
10
+ return process.env.NODE_ENV === "development";
11
+ }
9
12
  async function initialize({ port }) {
10
- inDev = process.env.NODE_ENV === "development", inDev && (parentPort = port, parentPort.on("message", onMessage), versions = /* @__PURE__ */ new Map(), esbuild = await import('esbuild'));
13
+ isDevelopment() && (parentPort = port, parentPort.on("message", onMessage), versions = /* @__PURE__ */ new Map(), esbuild = await import('esbuild'));
11
14
  }
12
15
  async function resolve(specifier, context, nextResolve) {
13
16
  if (shouldSkip(specifier))
@@ -22,7 +25,7 @@ async function resolve(specifier, context, nextResolve) {
22
25
  url = pathToFileURL(absPath).href;
23
26
  }
24
27
  let urlObj = new URL(url);
25
- if (inDev) {
28
+ if (isDevelopment()) {
26
29
  let filePath = fileURLToPath(urlObj), version = createVersion(filePath);
27
30
  urlObj.searchParams.set("hmr", version), parentURL && parentPort && parentPort.postMessage({
28
31
  type: "dependency",
package/dist/index.js CHANGED
@@ -184,10 +184,10 @@ function $postLoaderMessage(type, data, wait = false) {
184
184
  port2?.postMessage(message);
185
185
  return;
186
186
  }
187
- return new Promise((resolve2, reject) => {
187
+ return new Promise((resolve4, reject) => {
188
188
  if (!port2)
189
189
  return reject(new Error("Loader is not initialized"));
190
- pending.set(id, { resolve: resolve2, reject }), port2.postMessage(message);
190
+ pending.set(id, { resolve: resolve4, reject }), port2.postMessage(message);
191
191
  });
192
192
  }
193
193
  function $unloadFile(path) {
@@ -488,6 +488,7 @@ var CommandManager = class extends BaseClientManager {
488
488
  * @returns The command object if added successfully.
489
489
  */
490
490
  async load(path) {
491
+ path = resolve(path);
491
492
  let command = (await import(pathToFileURL(path).href)).default;
492
493
  if (!command) {
493
494
  console.warn(`[Loader] File has no default export: ${path}`);
@@ -505,12 +506,13 @@ var CommandManager = class extends BaseClientManager {
505
506
  * @returns The command object if unloaded successfully.
506
507
  */
507
508
  async unload(path) {
509
+ path = resolve(path);
508
510
  let command = this.entries.get(path);
509
511
  if (this.entries.delete(path), await $unloadFile(path), !!command)
510
512
  return this.remove(command);
511
513
  }
512
514
  async reload(path) {
513
- await this.unload(path);
515
+ path = resolve(path), await this.unload(path);
514
516
  let command = await this.load(path);
515
517
  if (command)
516
518
  return console.log(`[Loader] Reloaded command '${command.options.name}' at '${path}'`), command;
@@ -585,6 +587,7 @@ var ListenerManager = class extends BaseClientManager {
585
587
  * @returns The listener object if added successfully.
586
588
  */
587
589
  async load(path) {
590
+ path = resolve(path);
588
591
  let listener = (await import(pathToFileURL(path).href)).default;
589
592
  if (!listener) {
590
593
  console.warn(`[Loader] File has no default export: ${path}`);
@@ -602,12 +605,13 @@ var ListenerManager = class extends BaseClientManager {
602
605
  * @returns The listener object if unloaded successfully.
603
606
  */
604
607
  async unload(path) {
608
+ path = resolve(path);
605
609
  let listener = this.entries.get(path);
606
610
  if (this.entries.delete(path), await $unloadFile(path), !!listener)
607
611
  return this.remove(listener)?.[0];
608
612
  }
609
613
  async reload(path) {
610
- await this.unload(path);
614
+ path = resolve(path), await this.unload(path);
611
615
  let listener = await this.load(path);
612
616
  if (listener)
613
617
  return console.log(`[Loader] Reloaded listener '${listener.options.name}' at '${path}'`), listener;
@@ -934,16 +938,16 @@ var Instance = class {
934
938
  }
935
939
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
936
940
  async onProcessMessage(message) {
937
- let { type, url } = message;
941
+ let { type, path } = message;
938
942
  if (!type.startsWith("hmr:"))
939
943
  return;
940
944
  let target = type.split(":")[1], { listeners, commands } = this.client.managers;
941
945
  switch (target) {
942
946
  case "listeners":
943
- await listeners.reload(url);
947
+ await listeners.reload(path);
944
948
  break;
945
949
  case "commands":
946
- await commands.reload(url);
950
+ await commands.reload(path);
947
951
  break;
948
952
  }
949
953
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bakit",
3
- "version": "2.0.0-alpha.23",
3
+ "version": "2.0.0-alpha.24",
4
4
  "description": "A framework for discord.js",
5
5
  "type": "module",
6
6
  "exports": {