bakit 2.0.0-alpha.20 → 2.0.0-alpha.22

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
@@ -48,16 +48,16 @@ var DevProcessManager = class {
48
48
  stabilityThreshold: 200,
49
49
  pollInterval: 50
50
50
  }
51
- }).on("change", (file) => {
52
- this.onFileChanged(pathToFileURL(file).href);
51
+ }).on("change", (path2) => {
52
+ this.onFileChanged(path2);
53
53
  });
54
54
  }
55
- onFileChanged(file) {
55
+ onFileChanged(path2) {
56
56
  if (!this.child)
57
57
  return;
58
- let top = getTopLevelDirectory(file, this.options.rootDir);
58
+ let top = getTopLevelDirectory(path2, this.options.rootDir);
59
59
  if (top && this.options.hotDirs.includes(top)) {
60
- this.child.connected && this.child.send({ type: `hmr:${top}`, file });
60
+ this.child.connected && this.child.send({ type: `hmr:${top}`, url: pathToFileURL(path2).href });
61
61
  return;
62
62
  }
63
63
  this.scheduleRestart();
package/dist/index.js CHANGED
@@ -1,5 +1,3 @@
1
- import { register } from 'module';
2
- import { MessageChannel } from 'worker_threads';
3
1
  import { GatewayIntentBits, Events, Client, Collection, IntentsBitField, SlashCommandBuilder, SlashCommandStringOption, SlashCommandNumberOption, SlashCommandUserOption, ChatInputCommandInteraction, Message } from 'discord.js';
4
2
  import { inspect } from 'util';
5
3
  import { posix, relative, sep, join, dirname } from 'path';
@@ -10,33 +8,7 @@ import { existsSync, mkdirSync, rmSync } from 'fs';
10
8
  import { mkdir, writeFile, readFile, rm } from 'fs/promises';
11
9
  import { createHash } from 'crypto';
12
10
 
13
- var __defProp = Object.defineProperty;
14
- var __getOwnPropNames = Object.getOwnPropertyNames;
15
- var __esm = (fn, res) => function() {
16
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
17
- };
18
- var __export = (target, all) => {
19
- for (var name in all)
20
- __defProp(target, name, { get: all[name], enumerable: true });
21
- };
22
-
23
- // src/loader/register.ts
24
- var register_exports = {};
25
- __export(register_exports, {
26
- unload: () => unload
27
- });
28
- function unload(module) {
29
- port2.postMessage({ type: "unload", target: module });
30
- }
31
- var port1, port2, hookPath, init_register = __esm({
32
- "src/loader/register.ts"() {
33
- (({ port1, port2 } = new MessageChannel())), hookPath = new URL("./hooks.js", import.meta.url).href;
34
- register(hookPath, import.meta.url, {
35
- data: { port: port1 },
36
- transferList: [port1]
37
- });
38
- }
39
- });
11
+ // src/core/client/BakitClient.ts
40
12
  var ParamUserType = /* @__PURE__ */ ((ParamUserType2) => (ParamUserType2.Bot = "bot", ParamUserType2.Normal = "normal", ParamUserType2.Any = "any", ParamUserType2))(ParamUserType || {}), BaseParamSchema = z4.object({
41
13
  name: z4.string(),
42
14
  description: z4.string().optional(),
@@ -503,7 +475,7 @@ var CommandManager = class extends BaseClientManager {
503
475
  */
504
476
  async unload(path) {
505
477
  let command = this.entries.get(path);
506
- if (this.entries.delete(path), (await Promise.resolve().then(() => (init_register(), register_exports))).unload(path), !!command)
478
+ if (this.entries.delete(path), (await import('bakit/loader/register')).unload(path), !!command)
507
479
  return this.remove(command);
508
480
  }
509
481
  async reload(path) {
@@ -600,7 +572,7 @@ var ListenerManager = class extends BaseClientManager {
600
572
  */
601
573
  async unload(path) {
602
574
  let listener = this.entries.get(path);
603
- if (this.entries.delete(path), (await Promise.resolve().then(() => (init_register(), register_exports))).unload(path), !!listener)
575
+ if (this.entries.delete(path), (await import('bakit/loader/register')).unload(path), !!listener)
604
576
  return this.remove(listener)?.[0];
605
577
  }
606
578
  async reload(path) {
@@ -931,16 +903,16 @@ var Instance = class {
931
903
  }
932
904
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
933
905
  async onProcessMessage(message) {
934
- let { type, file } = message;
906
+ let { type, url } = message;
935
907
  if (!type.startsWith("hmr:"))
936
908
  return;
937
909
  let target = type.split(":")[1], { listeners, commands } = this.client.managers;
938
910
  switch (target) {
939
911
  case "listeners":
940
- await listeners.reload(file);
912
+ await listeners.reload(url);
941
913
  break;
942
914
  case "commands":
943
- await commands.reload(file);
915
+ await commands.reload(url);
944
916
  break;
945
917
  }
946
918
  }
@@ -60,7 +60,7 @@ function createVersion(filename) {
60
60
  return version || (version = Date.now().toString(), versions?.set(filename, version)), version;
61
61
  }
62
62
  function shouldSkip(specifier) {
63
- if (Module.isBuiltin(specifier))
63
+ if (Module.isBuiltin(specifier) || specifier.includes("/node_modules/"))
64
64
  return true;
65
65
  if (specifier.startsWith(".") || specifier.startsWith("file://")) {
66
66
  let filePath = specifier.startsWith("file://") ? fileURLToPath(specifier) : specifier, filename = basename(filePath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bakit",
3
- "version": "2.0.0-alpha.20",
3
+ "version": "2.0.0-alpha.22",
4
4
  "description": "A framework for discord.js",
5
5
  "type": "module",
6
6
  "exports": {