@ghostlytools/cli 1.3.9 → 1.3.10

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.
@@ -10233,6 +10233,8 @@ var BUNDLES_KEPT = {
10233
10233
  };
10234
10234
  /** The first bytes of a bundle: magic, the manifest's length and the largest manifest. */
10235
10235
  var PEEK_BYTES = APP_BUNDLE_MAGIC.length + 4 + APP_BUNDLE_LIMITS.manifestBytes;
10236
+ /** What a peek reads first: the magic, the length and any usual manifest (about 1 KiB). A longer one is read to its end after. */
10237
+ var PEEK_FIRST_BYTES = 4096;
10236
10238
  var bundleId = (digest) => `app-${digest}`;
10237
10239
  /**
10238
10240
  * The key of a scope's counter row (`AppScopeCount` as JSON in `value`, `size` 0): an app's key is never empty
@@ -10398,6 +10400,13 @@ function peekAppManifest(bytes) {
10398
10400
  return null;
10399
10401
  }
10400
10402
  }
10403
+ /** Where a bundle's manifest ends, from its first bytes, or null when they are not a bundle's or name a manifest too long. */
10404
+ function peekManifestEnd(bytes) {
10405
+ const magic = utf8Encode(APP_BUNDLE_MAGIC);
10406
+ if (bytes.length < magic.length + 4 || !magic.every((b, i) => bytes[i] === b)) return null;
10407
+ const end = magic.length + 4 + new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(magic.length);
10408
+ return end <= PEEK_BYTES ? end : null;
10409
+ }
10401
10410
  var Apps = class {
10402
10411
  host;
10403
10412
  staged = /* @__PURE__ */ new Map();
@@ -10856,6 +10865,23 @@ var Apps = class {
10856
10865
  return read;
10857
10866
  }
10858
10867
  /**
10868
+ * The manifest at the start of the bundle at `url`, unchecked (`peekAppManifest`): its first `PEEK_FIRST_BYTES`, and
10869
+ * only for a longer manifest a second read from the start to exactly its end (from the start: one file's bytes, even
10870
+ * when it changed between the two).
10871
+ */
10872
+ async peekAt(url) {
10873
+ const first = await this.host.fetch(url, {
10874
+ maxBytes: PEEK_FIRST_BYTES,
10875
+ peek: true
10876
+ });
10877
+ const end = peekManifestEnd(first);
10878
+ if (end === null || end <= first.length || first.length < PEEK_FIRST_BYTES) return peekAppManifest(first);
10879
+ return peekAppManifest(await this.host.fetch(url, {
10880
+ maxBytes: end,
10881
+ peek: true
10882
+ }));
10883
+ }
10884
+ /**
10859
10885
  * Reads the index at `url`. With the index held for this store, bytes equal to it (by digest) are the held index: its
10860
10886
  * signature and every revocation in it were checked when it was read, so only its expiry is taken again. Any other
10861
10887
  * index is read with a pause every few ms (the engine shares the page's thread, and an index holds up to 4096
@@ -11415,10 +11441,7 @@ var Apps = class {
11415
11441
  if (pinned === void 0) for (const url of (app.manifest.sources ?? []).filter(isAppFetchUrl)) {
11416
11442
  if (candidates.has(url)) continue;
11417
11443
  try {
11418
- const peek = peekAppManifest(await this.host.fetch(url, {
11419
- maxBytes: PEEK_BYTES,
11420
- peek: true
11421
- }));
11444
+ const peek = await this.peekAt(url);
11422
11445
  if (peek && newer(peek)) candidates.set(url, { holds: peek });
11423
11446
  } catch {}
11424
11447
  }
@@ -11430,10 +11453,7 @@ var Apps = class {
11430
11453
  if (want.peek) {
11431
11454
  let peek;
11432
11455
  try {
11433
- peek = peekAppManifest(await this.host.fetch(url, {
11434
- maxBytes: PEEK_BYTES,
11435
- peek: true
11436
- }));
11456
+ peek = await this.peekAt(url);
11437
11457
  } catch {
11438
11458
  continue;
11439
11459
  }
@@ -11589,10 +11609,7 @@ var Apps = class {
11589
11609
  if (app.store === void 0) urls.push(...app.manifest.sources ?? []);
11590
11610
  for (const url of new Set(urls.filter(isAppFetchUrl))) {
11591
11611
  try {
11592
- if (peekAppManifest(await this.host.fetch(url, {
11593
- maxBytes: PEEK_BYTES,
11594
- peek: true
11595
- }))?.digest !== app.digest) continue;
11612
+ if ((await this.peekAt(url))?.digest !== app.digest) continue;
11596
11613
  } catch {
11597
11614
  continue;
11598
11615
  }
@@ -43925,4 +43942,4 @@ function signalKind(signal) {
43925
43942
  //#endregion
43926
43943
  export { EngineServer };
43927
43944
 
43928
- //# sourceMappingURL=server-p5DJnN7T.js.map
43945
+ //# sourceMappingURL=server-C-EkLCCt.js.map