@apilift/cli 1.4.33 → 1.4.35

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.
@@ -29884,12 +29884,19 @@ var CaptureServerClient = class {
29884
29884
  scopes() {
29885
29885
  return this.call("GET", "/scopes");
29886
29886
  }
29887
+ async bridgeDemand() {
29888
+ try {
29889
+ await this.call("POST", "/bridge/demand", {});
29890
+ } catch (error62) {
29891
+ if (error62.code !== "not-found") throw error62;
29892
+ }
29893
+ }
29887
29894
  bridgeReady(version2, capabilities = []) {
29888
29895
  return this.call("POST", "/bridge/ready", { version: version2, capabilities }).then(() => {
29889
29896
  });
29890
29897
  }
29891
- candidates(id2) {
29892
- return this.call("GET", `/scope/candidates?id=${encodeURIComponent(id2)}`);
29898
+ candidates(id2, waitMs = 0) {
29899
+ return this.call("GET", `/scope/candidates?id=${encodeURIComponent(id2)}&waitMs=${waitMs}`);
29893
29900
  }
29894
29901
  entries(id2, after = 0, limit = 100) {
29895
29902
  return this.call("GET", `/scope/entries?id=${encodeURIComponent(id2)}&after=${after}&limit=${limit}`);
@@ -29922,8 +29929,8 @@ var CaptureServerClient = class {
29922
29929
  enqueueJob(scopeId, envelope) {
29923
29930
  return this.call("POST", "/job/enqueue", { scopeId, envelope });
29924
29931
  }
29925
- jobResult(id2) {
29926
- return this.call("GET", `/job/result?id=${encodeURIComponent(id2)}`);
29932
+ jobResult(id2, waitMs = 0) {
29933
+ return this.call("GET", `/job/result?id=${encodeURIComponent(id2)}&waitMs=${waitMs}`);
29927
29934
  }
29928
29935
  acknowledgeJob(id2) {
29929
29936
  return this.call("POST", "/job/ack", { id: id2 }).then(() => {
@@ -31424,6 +31431,9 @@ var NativeHost = class {
31424
31431
  reportedReady = false;
31425
31432
  stopped = false;
31426
31433
  client;
31434
+ registryPending;
31435
+ readinessPending;
31436
+ readinessReported;
31427
31437
  registryCache;
31428
31438
  installationKey() {
31429
31439
  return createHash4("sha256").update(JSON.stringify(this.state.installation())).digest("hex");
@@ -31462,6 +31472,18 @@ var NativeHost = class {
31462
31472
  }
31463
31473
  }
31464
31474
  async registry() {
31475
+ if (this.options.registry) return this.options.registry();
31476
+ const key = this.installationKey();
31477
+ if (this.registryPending?.key === key) return this.registryPending.value;
31478
+ const pending = { key, value: this.readRegistry() };
31479
+ this.registryPending = pending;
31480
+ try {
31481
+ return await pending.value;
31482
+ } finally {
31483
+ if (this.registryPending === pending) this.registryPending = void 0;
31484
+ }
31485
+ }
31486
+ async readRegistry() {
31465
31487
  if (this.options.registry) return this.options.registry();
31466
31488
  const installationKey = this.installationKey();
31467
31489
  if (this.registryCache?.installationKey !== installationKey) {
@@ -31506,6 +31528,18 @@ var NativeHost = class {
31506
31528
  });
31507
31529
  }
31508
31530
  async publishReadiness(initial) {
31531
+ const key = this.installationKey();
31532
+ if (this.readinessReported?.key === key && Date.now() - this.readinessReported.at < 3e5) return;
31533
+ if (this.readinessPending?.key === key) return this.readinessPending.value;
31534
+ const pending = { key, value: this.reportReadiness(initial) };
31535
+ this.readinessPending = pending;
31536
+ try {
31537
+ await pending.value;
31538
+ } finally {
31539
+ if (this.readinessPending === pending) this.readinessPending = void 0;
31540
+ }
31541
+ }
31542
+ async reportReadiness(initial) {
31509
31543
  const installation = this.state.installation();
31510
31544
  if (!installation) return;
31511
31545
  const installationKey = this.installationKey();
@@ -31522,6 +31556,7 @@ var NativeHost = class {
31522
31556
  const fetcher = this.options.fetcher ?? fetch;
31523
31557
  const api = createCliApi(this.options.siteUrl, (input2, init) => fetcher(input2, { ...init, signal: AbortSignal.timeout(2e3) }), installation.token);
31524
31558
  await api.call("updateReadiness", { body: { machine: { nativeHostReady: true, extensionReady: true } } });
31559
+ if (!this.stopped && this.installationKey() === installationKey) this.readinessReported = { key: installationKey, at: Date.now() };
31525
31560
  return;
31526
31561
  } catch {
31527
31562
  }
@@ -4,7 +4,7 @@ import { createRequire } from "node:module"; const require = createRequire(impor
4
4
  // src/bin/register-native-host.ts
5
5
  import { createHash as createHash2 } from "node:crypto";
6
6
  import { existsSync, readFileSync, realpathSync } from "node:fs";
7
- import { basename, dirname as dirname2, isAbsolute as isAbsolute2, join as join2, resolve as resolve2 } from "node:path";
7
+ import { basename, dirname as dirname2, join as join2, resolve as resolve2 } from "node:path";
8
8
 
9
9
  // src/native-host/registration.ts
10
10
  import { createHash, randomUUID } from "node:crypto";
@@ -172,7 +172,7 @@ function options(argv) {
172
172
  values.set(flag, value);
173
173
  }
174
174
  const root = values.get("--root"), hostScript = values.get("--host-script"), extensionId = values.get("--extension-id");
175
- if (!root || !hostScript || !extensionId || !isAbsolute2(root) || !isAbsolute2(hostScript)) throw new Error("Use absolute --root and --host-script paths and pass --extension-id");
175
+ if (!root || !hostScript || !extensionId) throw new Error("Pass --root, --host-script and --extension-id");
176
176
  return { root: resolve2(root), hostScript: resolve2(hostScript), extensionId, hostName: values.get("--host-name") ?? "com.apilift.browser.dev", siteUrl: values.get("--site-url"), replaceStaleOwned };
177
177
  }
178
178
  function staleOwnedByThisWorktree(input) {