bakit 2.0.0-alpha.29 → 2.0.0-alpha.30

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/index.d.ts CHANGED
@@ -508,12 +508,47 @@ declare function getDependencyChain(path: string): string[];
508
508
  * @param targets The list of the files to check.
509
509
  */
510
510
  declare function importsAny(path: string, targets: Set<string>): boolean;
511
+ /**
512
+ * Check if the file is imported by the others.
513
+ * @param path The path of the file to check.
514
+ * @returns `boolean`
515
+ */
511
516
  declare function isImported(path: string): boolean;
517
+ /**
518
+ * Check if the file is imported by a specific target.
519
+ * @param path The path of the file to check.
520
+ * @param matcher The target condition to match.
521
+ * @returns `boolean`
522
+ */
512
523
  declare function isImportedBy(path: string, matcher: string | RegExp | ((path: string) => boolean)): boolean;
513
- declare function isInHotDirectory(path: string): boolean;
524
+ /**
525
+ * Check if the file is under a hmr directory.
526
+ * @param path The path of the file to check.
527
+ * @returns `boolean`
528
+ */
529
+ declare function isInHotDirectory(path: string): boolean | undefined;
530
+ /**
531
+ * Check if the file is the entry file (e.g, index.ts)
532
+ * @param path The path of the file to check.
533
+ * @returns `boolean`
534
+ */
514
535
  declare function isEntryFile(path: string): boolean;
536
+ /**
537
+ * Check if the file chain includes the entry file (e.g, index.ts)
538
+ * @param path The chain of the files to check.
539
+ * @returns `boolean`
540
+ */
515
541
  declare function containsEntryFile(chain: string[]): boolean;
542
+ /**
543
+ * Check if the file chain includes hmr files (e.g, index.ts)
544
+ * @param path The chain of the files to check.
545
+ * @returns `boolean`
546
+ */
516
547
  declare function containsHotModule(chain: string[]): boolean;
548
+ /**
549
+ * Request to dev process manager to restart the process.
550
+ */
551
+ declare function restartProcess(): void;
517
552
 
518
553
  declare const loader_addHotReloader: typeof addHotReloader;
519
554
  declare const loader_containsEntryFile: typeof containsEntryFile;
@@ -528,9 +563,10 @@ declare const loader_isEntryFile: typeof isEntryFile;
528
563
  declare const loader_isImported: typeof isImported;
529
564
  declare const loader_isImportedBy: typeof isImportedBy;
530
565
  declare const loader_isInHotDirectory: typeof isInHotDirectory;
566
+ declare const loader_restartProcess: typeof restartProcess;
531
567
  declare const loader_unload: typeof unload;
532
568
  declare namespace loader {
533
- export { loader_addHotReloader as addHotReloader, loader_containsEntryFile as containsEntryFile, loader_containsHotModule as containsHotModule, loader_getDependencyChain as getDependencyChain, loader_getImporters as getImporters, loader_getImports as getImports, loader_hotReloaders as hotReloaders, loader_importsAny as importsAny, loader_init as init, loader_isEntryFile as isEntryFile, loader_isImported as isImported, loader_isImportedBy as isImportedBy, loader_isInHotDirectory as isInHotDirectory, loader_unload as unload };
569
+ export { loader_addHotReloader as addHotReloader, loader_containsEntryFile as containsEntryFile, loader_containsHotModule as containsHotModule, loader_getDependencyChain as getDependencyChain, loader_getImporters as getImporters, loader_getImports as getImports, loader_hotReloaders as hotReloaders, loader_importsAny as importsAny, loader_init as init, loader_isEntryFile as isEntryFile, loader_isImported as isImported, loader_isImportedBy as isImportedBy, loader_isInHotDirectory as isInHotDirectory, loader_restartProcess as restartProcess, loader_unload as unload };
534
570
  }
535
571
 
536
572
  declare const RPC_RESPONSE_MARK = "$DONE:";
package/dist/index.js CHANGED
@@ -248,6 +248,7 @@ __export(loader_exports, {
248
248
  isImported: () => isImported,
249
249
  isImportedBy: () => isImportedBy,
250
250
  isInHotDirectory: () => isInHotDirectory,
251
+ restartProcess: () => restartProcess,
251
252
  unload: () => unload
252
253
  });
253
254
  var RPC_RESPONSE_MARK = "$DONE:", RPC_RESPONSE_TIMEOUT = 5e3, RPC = class extends EventEmitter {
@@ -316,6 +317,8 @@ var RPC_RESPONSE_MARK = "$DONE:", RPC_RESPONSE_TIMEOUT = 5e3, RPC = class extend
316
317
  });
317
318
  }
318
319
  };
320
+
321
+ // src/lib/loader/loader.ts
319
322
  var hooksRPC, processRPC, hotReloaders = new Collection(), reverseDependencyGraph = new Collection(), forwardDependencyGraph = new Collection();
320
323
  function init() {
321
324
  initProcess(), initHooks();
@@ -381,7 +384,10 @@ function isImportedBy(path, matcher) {
381
384
  });
382
385
  }
383
386
  function onDependencyAdd(data) {
384
- let { url, parentURL } = data, path = fileURLToPath(url), parentPath = fileURLToPath(parentURL), reverseEntry = reverseDependencyGraph.get(path);
387
+ let { url, parentURL } = data, path = fileURLToPath(url), parentPath = fileURLToPath(parentURL);
388
+ if (parentPath.includes("/node_modules/"))
389
+ return;
390
+ let reverseEntry = reverseDependencyGraph.get(path);
385
391
  reverseEntry || (reverseEntry = /* @__PURE__ */ new Set(), reverseDependencyGraph.set(path, reverseEntry)), reverseEntry.add(parentPath);
386
392
  let forwardEntry = forwardDependencyGraph.get(parentPath);
387
393
  forwardEntry || (forwardEntry = /* @__PURE__ */ new Set(), forwardDependencyGraph.set(parentPath, forwardEntry)), forwardEntry.add(path);
@@ -391,7 +397,10 @@ function isInHotDirectory(path) {
391
397
  if (!path.startsWith(sourceRoot))
392
398
  return false;
393
399
  let topLevelDir = getTopLevelDirectory(path, sourceRoot);
394
- return !!topLevelDir && hotReloaders.some((m) => m.entryDirectory === topLevelDir);
400
+ if (!topLevelDir)
401
+ return;
402
+ let entryDirectory = join(sourceRoot, topLevelDir);
403
+ return hotReloaders.some((m) => m.entryDirectory === entryDirectory);
395
404
  }
396
405
  function isEntryFile(path) {
397
406
  return path === getEntryFile();
@@ -406,7 +415,7 @@ function restartProcess() {
406
415
  processRPC?.send("restart");
407
416
  }
408
417
  async function unloadModule(path, reload = false) {
409
- let topLevel = getTopLevelDirectory(path, getEntryFile());
418
+ let topLevel = getTopLevelDirectory(path, getEntryDirectory());
410
419
  if (!topLevel)
411
420
  return;
412
421
  let directory = resolve(getEntryDirectory(), topLevel), reloader = hotReloaders.get(directory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bakit",
3
- "version": "2.0.0-alpha.29",
3
+ "version": "2.0.0-alpha.30",
4
4
  "description": "A framework for discord.js",
5
5
  "type": "module",
6
6
  "exports": {