@neat.is/core 0.4.5 → 0.4.6

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.cjs CHANGED
@@ -6090,11 +6090,45 @@ async function startDaemon(opts = {}) {
6090
6090
  });
6091
6091
  };
6092
6092
  process.on("SIGHUP", sighupHandler);
6093
+ const REGISTRY_RELOAD_DEBOUNCE_MS = 500;
6094
+ let registryWatcher = null;
6095
+ let reloadTimer = null;
6096
+ try {
6097
+ const regDir = import_node_path37.default.dirname(regPath);
6098
+ const regBase = import_node_path37.default.basename(regPath);
6099
+ registryWatcher = (0, import_node_fs22.watch)(regDir, (_eventType, filename) => {
6100
+ if (filename !== null && filename !== regBase) return;
6101
+ if (reloadTimer) clearTimeout(reloadTimer);
6102
+ reloadTimer = setTimeout(() => {
6103
+ reloadTimer = null;
6104
+ void reload().catch((err) => {
6105
+ console.warn(
6106
+ `neatd: registry-watch reload failed \u2014 ${err.message}`
6107
+ );
6108
+ });
6109
+ }, REGISTRY_RELOAD_DEBOUNCE_MS);
6110
+ });
6111
+ } catch (err) {
6112
+ console.warn(
6113
+ `neatd: failed to watch registry at ${regPath} \u2014 ${err.message}. Run \`neatd reload\` (or send SIGHUP) after registering new projects.`
6114
+ );
6115
+ }
6093
6116
  let stopped = false;
6094
6117
  const stop = async () => {
6095
6118
  if (stopped) return;
6096
6119
  stopped = true;
6097
6120
  process.off("SIGHUP", sighupHandler);
6121
+ if (reloadTimer) {
6122
+ clearTimeout(reloadTimer);
6123
+ reloadTimer = null;
6124
+ }
6125
+ if (registryWatcher) {
6126
+ try {
6127
+ registryWatcher.close();
6128
+ } catch {
6129
+ }
6130
+ registryWatcher = null;
6131
+ }
6098
6132
  if (otlpApp) await otlpApp.close().catch(() => {
6099
6133
  });
6100
6134
  if (restApp) await restApp.close().catch(() => {