@blastlauncher/engine 3.0.0-alpha.0 → 3.0.0-alpha.1

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/engine.d.ts CHANGED
@@ -6,6 +6,8 @@ export declare function createEngine(options?: {
6
6
  timeoutMs?: number;
7
7
  dataDir?: string;
8
8
  installer?: DependencyInstaller;
9
+ watcher?: OpenExtensionOptions["watcher"];
10
+ debounce?: OpenExtensionOptions["debounce"];
9
11
  dependencies?: "manual" | "auto";
10
12
  handlers?: Record<string, CapabilityHandler>;
11
13
  }): {
package/dist/engine.js CHANGED
@@ -27,6 +27,8 @@ export function createEngine(options = {}) {
27
27
  ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
28
28
  ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),
29
29
  ...(options.installer === undefined ? {} : { installer: options.installer }),
30
+ ...(options.watcher === undefined ? {} : { watcher: options.watcher }),
31
+ ...(options.debounce === undefined ? {} : { debounce: options.debounce }),
30
32
  ...extensionOptions,
31
33
  }, registeredHandlers, options.dependencies === "auto");
32
34
  const close = extension.close;
@@ -32,6 +32,17 @@ export type OpenExtensionOptions = {
32
32
  dataDir?: string;
33
33
  installer?: DependencyInstaller;
34
34
  handlers?: Record<string, CapabilityHandler>;
35
+ watcher?: ExtensionWatcherFactory;
36
+ debounce?: DebounceScheduler;
37
+ };
38
+ export type ExtensionWatcher = {
39
+ on(event: "error", listener: (error: Error) => void): ExtensionWatcher;
40
+ close(): void;
41
+ };
42
+ export type ExtensionWatcherFactory = (path: string, listener: (event: string, filename: string | Buffer | null) => void) => ExtensionWatcher;
43
+ export type DebounceScheduler = {
44
+ schedule(callback: () => void, delayMs: number): unknown;
45
+ cancel(handle: unknown): void;
35
46
  };
36
47
  /** Opens an extension without starting a command or installing dependencies. */
37
48
  export declare function openExtension(options: OpenExtensionOptions): {
package/dist/extension.js CHANGED
@@ -42,6 +42,12 @@ export function createExtensionHandle(options, engineHandlers = () => ({}), defa
42
42
  const extensionDir = resolve(options.extensionDir);
43
43
  const dataDir = options.dataDir ?? defaultDataDir();
44
44
  const dependencyOptions = { extensionDir, dataDir };
45
+ const watcherFactory = options.watcher ?? ((path, listener) => watchDirectory(path, listener));
46
+ const debounce = options.debounce ??
47
+ {
48
+ schedule: (callback, delayMs) => setTimeout(callback, delayMs),
49
+ cancel: (handle) => clearTimeout(handle),
50
+ };
45
51
  let closed = false;
46
52
  let closing;
47
53
  let queue = Promise.resolve();
@@ -231,11 +237,12 @@ export function createExtensionHandle(options, engineHandlers = () => ({}), defa
231
237
  listener(update);
232
238
  };
233
239
  // Directory watching also observes manifests replaced via atomic rename.
234
- const watcher = watchDirectory(extensionDir, (_event, file) => {
240
+ const watcher = watcherFactory(extensionDir, (_event, file) => {
235
241
  if (file && file !== "package.json" && file !== "package-lock.json")
236
242
  return;
237
- clearTimeout(timer);
238
- timer = setTimeout(() => {
243
+ if (timer !== undefined)
244
+ debounce.cancel(timer);
245
+ timer = debounce.schedule(() => {
239
246
  void reload();
240
247
  }, 100);
241
248
  });
@@ -245,7 +252,8 @@ export function createExtensionHandle(options, engineHandlers = () => ({}), defa
245
252
  });
246
253
  const unsubscribe = () => {
247
254
  active = false;
248
- clearTimeout(timer);
255
+ if (timer !== undefined)
256
+ debounce.cancel(timer);
249
257
  watcher.close();
250
258
  subscriptions.delete(unsubscribe);
251
259
  };
package/dist/index.d.ts CHANGED
@@ -8,6 +8,6 @@ export * from "./dependencies.js";
8
8
  export * from "./client.js";
9
9
  export * from "./install-dependencies.js";
10
10
  export * from "./preferences.js";
11
- export { openExtension, MissingLaunchValuesError, DependenciesRequiredError, type OpenExtensionOptions, type ExtensionHandle, type ExtensionLaunchOptions, } from "./extension.js";
11
+ export { openExtension, MissingLaunchValuesError, DependenciesRequiredError, type OpenExtensionOptions, type ExtensionHandle, type ExtensionLaunchOptions, type DebounceScheduler, type ExtensionWatcher, type ExtensionWatcherFactory, } from "./extension.js";
12
12
  export * from "./extension-manifest.js";
13
13
  export * from "./engine.js";
package/package.json CHANGED
@@ -9,13 +9,19 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@blastlauncher/protocol": "3.0.0-alpha.0",
13
- "@blastlauncher/runtime": "3.0.0-alpha.0",
12
+ "@blastlauncher/protocol": "3.0.0-alpha.1",
13
+ "@blastlauncher/runtime": "3.0.0-alpha.1",
14
14
  "esbuild": "0.28.2",
15
15
  "semver": "7.8.5"
16
16
  },
17
- "version": "3.0.0-alpha.0",
17
+ "version": "3.0.0-alpha.1",
18
18
  "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/BlastLauncher/blast.git",
22
+ "directory": "packages/host"
23
+ },
24
+ "homepage": "https://github.com/BlastLauncher/blast#readme",
19
25
  "engines": {
20
26
  "node": ">=24.20.0"
21
27
  },