@absolutejs/absolute 0.20.0-beta.83 → 0.20.0-beta.85

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.
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-WzbAzY/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-UibQSn/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  var __require = import.meta.require;
3
3
 
4
- // .angular-partial-tmp-WzbAzY/src/core/streamingSlotRegistrar.ts
4
+ // .angular-partial-tmp-UibQSn/src/core/streamingSlotRegistrar.ts
5
5
  var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
6
6
  var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
7
7
  var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
@@ -48,7 +48,7 @@ var warnMissingStreamingSlotCollector = (primitiveName) => {
48
48
  getWarningController()?.maybeWarn(primitiveName);
49
49
  };
50
50
 
51
- // .angular-partial-tmp-WzbAzY/src/core/streamingSlotRegistry.ts
51
+ // .angular-partial-tmp-UibQSn/src/core/streamingSlotRegistry.ts
52
52
  var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
53
53
  var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
54
54
  var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
package/dist/build.js CHANGED
@@ -28647,6 +28647,7 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
28647
28647
  const releaseRoot = (manifest) => `${root(manifest.appId)}/releases/${manifest.releaseId}`;
28648
28648
  const manifestKey = (manifest) => `${releaseRoot(manifest)}/update.json`;
28649
28649
  const fileKey = (manifest, file5) => `${releaseRoot(manifest)}/files/${file5.path}`;
28650
+ const contentBlobKey = (appId, sha256) => `${root(appId)}/blobs/${sha256}`;
28650
28651
  const tombstoneKey = (appId, releaseId) => `${root(appId)}/gc/${releaseId}.json`;
28651
28652
  const channelKey = (appId, channel) => {
28652
28653
  if (!APP_ID.test(appId) || !NAME.test(channel))
@@ -28793,9 +28794,19 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
28793
28794
  const releasePrefix = `${appRoot}releases/`;
28794
28795
  const channelPrefix = `${appRoot}channels/`;
28795
28796
  const markerPrefix = `${appRoot}gc/`;
28797
+ const blobPrefix = `${appRoot}blobs/`;
28796
28798
  const objectKeysByRelease = new Map;
28797
28799
  const objectBytesByRelease = new Map;
28800
+ const objectKeysByDigest = new Map;
28801
+ const objectBytesByDigest = new Map;
28798
28802
  for (const blobObject of objects) {
28803
+ if (blobObject.key.startsWith(blobPrefix)) {
28804
+ const sha256 = blobObject.key.slice(blobPrefix.length);
28805
+ if (HASH.test(sha256)) {
28806
+ objectKeysByDigest.set(sha256, blobObject.key);
28807
+ objectBytesByDigest.set(sha256, blobObject.size);
28808
+ }
28809
+ }
28799
28810
  if (!blobObject.key.startsWith(releasePrefix))
28800
28811
  continue;
28801
28812
  const suffix = blobObject.key.slice(releasePrefix.length);
@@ -28874,20 +28885,28 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
28874
28885
  releaseId: manifest.releaseId
28875
28886
  };
28876
28887
  }).toSorted((left, right) => right.createdAt.localeCompare(left.createdAt));
28888
+ const protectedReleaseIds = new Set(releases.filter((release) => release.protectedBy.length > 0).map((release) => release.releaseId));
28889
+ const protectedDigests = new Set(manifests.filter((manifest) => protectedReleaseIds.has(manifest.releaseId)).flatMap((manifest) => manifest.files.map((file5) => file5.sha256)));
28890
+ const reclaimableContentBytes = [...objectBytesByDigest].filter(([sha256]) => !protectedDigests.has(sha256)).reduce((total, [, bytes]) => total + bytes, 0);
28891
+ const contentBlobBytes = [...objectBytesByDigest.values()].reduce((total, bytes) => total + bytes, 0);
28877
28892
  const releaseBytes = releases.reduce((total, release) => total + release.bytes, 0);
28878
28893
  const totalBytes = objects.reduce((total, object22) => total + object22.size, 0);
28879
28894
  return {
28880
28895
  objectKeysByRelease,
28896
+ objectKeysByDigest,
28881
28897
  report: {
28882
28898
  appId: input.appId,
28883
28899
  channelCount: channels.length,
28884
- reclaimableBytes: releases.filter((release) => release.protectedBy.length === 0).reduce((total, release) => total + release.bytes, 0),
28900
+ contentBlobBytes,
28901
+ contentBlobCount: objectKeysByDigest.size,
28902
+ reclaimableBytes: releases.filter((release) => release.protectedBy.length === 0).reduce((total, release) => total + release.bytes, 0) + reclaimableContentBytes,
28903
+ reclaimableContentBytes,
28885
28904
  releaseBytes,
28886
28905
  releaseCount: releases.length,
28887
28906
  releases,
28888
28907
  totalBytes,
28889
28908
  totalObjectCount: objects.length,
28890
- untrackedBytes: totalBytes - releaseBytes
28909
+ untrackedBytes: totalBytes - releaseBytes - contentBlobBytes
28891
28910
  }
28892
28911
  };
28893
28912
  };
@@ -28899,7 +28918,8 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
28899
28918
  marked: [],
28900
28919
  reclaimedBytes: 0,
28901
28920
  restored: [],
28902
- swept: []
28921
+ swept: [],
28922
+ sweptContentBlobs: []
28903
28923
  };
28904
28924
  if (input.apply !== true)
28905
28925
  return result;
@@ -28957,6 +28977,21 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
28957
28977
  result.reclaimedBytes += candidate.bytes;
28958
28978
  result.swept.push(release.releaseId);
28959
28979
  }
28980
+ const afterReleaseSweep = await inventory(input);
28981
+ const referencedDigests = new Set;
28982
+ for (const release of afterReleaseSweep.report.releases) {
28983
+ const manifest = await readManifest2(input.appId, release.releaseId);
28984
+ for (const file5 of manifest?.manifest.files ?? [])
28985
+ referencedDigests.add(file5.sha256);
28986
+ }
28987
+ for (const [sha256, key] of afterReleaseSweep.objectKeysByDigest) {
28988
+ if (referencedDigests.has(sha256))
28989
+ continue;
28990
+ const head = await options.store.head(key);
28991
+ await remove(key);
28992
+ result.reclaimedBytes += head?.size ?? 0;
28993
+ result.sweptContentBlobs.push(sha256);
28994
+ }
28960
28995
  return result;
28961
28996
  };
28962
28997
  return {
@@ -28973,8 +29008,16 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
28973
29008
  throw new MobileUpdateRegistryError("Local mobile update manifest changed");
28974
29009
  const existing = await readManifest2(manifest.appId, manifest.releaseId);
28975
29010
  let reused = existing !== null;
29011
+ let storedBytes = 0;
29012
+ let storedFiles = 0;
29013
+ let reusedBytes = 0;
29014
+ let reusedFiles = 0;
28976
29015
  if (existing && JSON.stringify(existing.manifest) !== JSON.stringify(manifest))
28977
29016
  throw new MobileUpdateRegistryError("Published mobile update is immutable");
29017
+ if (existing) {
29018
+ reusedBytes = manifest.files.reduce((total, file5) => total + file5.bytes, 0);
29019
+ reusedFiles = manifest.files.length;
29020
+ }
28978
29021
  if (!existing) {
28979
29022
  for (const file5 of manifest.files) {
28980
29023
  const local = path.join(localRoot, "files", file5.path);
@@ -28983,18 +29026,24 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
28983
29026
  throw new MobileUpdateRegistryError(`Mobile update file ${file5.path} size changed`);
28984
29027
  if (await fileDigest(Bun.file(local)) !== file5.sha256)
28985
29028
  throw new MobileUpdateRegistryError(`Mobile update file ${file5.path} integrity failed`);
28986
- const key = fileKey(manifest, file5);
29029
+ const key = contentBlobKey(manifest.appId, file5.sha256);
28987
29030
  const stored = await options.store.head(key);
28988
29031
  if (!stored) {
28989
29032
  await options.store.put(key, Bun.file(local).stream(), {
28990
29033
  cacheControl: "public, max-age=31536000, immutable",
28991
29034
  contentType: "application/octet-stream",
28992
29035
  maxBytes: file5.bytes,
28993
- metadata: { releaseid: manifest.releaseId, sha256: file5.sha256 },
29036
+ metadata: { sha256: file5.sha256 },
28994
29037
  signal: input.signal
28995
29038
  });
28996
- } else if (stored.size !== file5.bytes || stored.metadata?.sha256 !== file5.sha256 || (stored.metadata?.releaseid ?? stored.metadata?.releaseId) !== manifest.releaseId)
28997
- throw new MobileUpdateRegistryError("Stored mobile update file identity changed");
29039
+ storedBytes += file5.bytes;
29040
+ storedFiles += 1;
29041
+ } else if (stored.size !== file5.bytes || stored.metadata?.sha256 !== file5.sha256)
29042
+ throw new MobileUpdateRegistryError("Stored mobile update content identity changed");
29043
+ else {
29044
+ reusedBytes += file5.bytes;
29045
+ reusedFiles += 1;
29046
+ }
28998
29047
  }
28999
29048
  const bytes = json(manifest);
29000
29049
  await options.store.put(manifestKey(manifest), bytes, {
@@ -29018,8 +29067,12 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
29018
29067
  return {
29019
29068
  appId: manifest.appId,
29020
29069
  channel: manifest.channel,
29070
+ storedBytes,
29071
+ storedFiles,
29021
29072
  releaseId: manifest.releaseId,
29022
29073
  reused,
29074
+ reusedBytes,
29075
+ reusedFiles,
29023
29076
  rollout: input.rollout,
29024
29077
  stage: "published"
29025
29078
  };
@@ -29068,14 +29121,16 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
29068
29121
  const file5 = release.manifest.files.find((candidate) => candidate.path === requested);
29069
29122
  if (!file5)
29070
29123
  return null;
29071
- const key = fileKey(release.manifest, file5);
29124
+ const legacyKey = fileKey(release.manifest, file5);
29125
+ const legacyHead = await options.store.head(legacyKey);
29126
+ const key = legacyHead ? legacyKey : contentBlobKey(release.manifest.appId, file5.sha256);
29072
29127
  const [bytes, head] = await Promise.all([
29073
29128
  options.store.get(key),
29074
- options.store.head(key)
29129
+ legacyHead ? Promise.resolve(legacyHead) : options.store.head(key)
29075
29130
  ]);
29076
29131
  if (!bytes || !head)
29077
29132
  return null;
29078
- if (bytes.byteLength !== file5.bytes || head.size !== file5.bytes || head.metadata?.sha256 !== file5.sha256 || (head.metadata?.releaseid ?? head.metadata?.releaseId) !== release.manifest.releaseId || digest(bytes) !== file5.sha256)
29133
+ if (bytes.byteLength !== file5.bytes || head.size !== file5.bytes || head.metadata?.sha256 !== file5.sha256 || legacyHead && (head.metadata?.releaseid ?? head.metadata?.releaseId) !== release.manifest.releaseId || digest(bytes) !== file5.sha256)
29079
29134
  throw new MobileUpdateRegistryError("Stored mobile update file integrity failed");
29080
29135
  return { bytes, file: file5 };
29081
29136
  }
@@ -29215,14 +29270,18 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
29215
29270
  const expoCodeSigning = resolveExpoCodeSigning(options.expoCodeSigning);
29216
29271
  return async (request) => {
29217
29272
  const origin = request.headers.get("origin");
29218
- const cors = origin && allowedOrigins.has(origin) ? { "access-control-allow-origin": origin, vary: "Origin" } : {};
29273
+ const cors = origin && allowedOrigins.has(origin) ? {
29274
+ "access-control-allow-origin": origin,
29275
+ "access-control-expose-headers": "content-range,etag",
29276
+ vary: "Origin"
29277
+ } : {};
29219
29278
  if (request.method === "OPTIONS") {
29220
29279
  if (!origin || !allowedOrigins.has(origin))
29221
29280
  return new Response(null, { status: 403 });
29222
29281
  return new Response(null, {
29223
29282
  headers: {
29224
29283
  ...cors,
29225
- "access-control-allow-headers": "x-absolute-mobile-app,x-absolute-mobile-channel,x-absolute-mobile-installation,x-absolute-mobile-release,x-absolute-mobile-runtime",
29284
+ "access-control-allow-headers": "if-range,range,x-absolute-mobile-app,x-absolute-mobile-channel,x-absolute-mobile-installation,x-absolute-mobile-release,x-absolute-mobile-runtime",
29226
29285
  "access-control-allow-methods": "GET,OPTIONS",
29227
29286
  "access-control-max-age": "600"
29228
29287
  },
@@ -29350,14 +29409,42 @@ var MOBILE_UPDATE_REGISTRY_FORMAT = 1, DEFAULT_PREFIX = "absolutejs/mobile-updat
29350
29409
  });
29351
29410
  if (!file5)
29352
29411
  return new Response(null, { status: 404 });
29353
- return new Response(new Blob([new Uint8Array(file5.bytes).buffer]), {
29412
+ const etag = `"${file5.file.sha256}"`;
29413
+ const range = request.headers.get("range");
29414
+ const useRange = range !== null && (!request.headers.has("if-range") || request.headers.get("if-range") === etag);
29415
+ let contents = file5.bytes;
29416
+ let status = 200;
29417
+ let contentRange;
29418
+ if (useRange) {
29419
+ const parsed = /^bytes=(\d+)-(\d*)$/.exec(range);
29420
+ const start = parsed?.[1] === undefined ? NaN : Number(parsed[1]);
29421
+ const requestedEnd = parsed?.[2] === undefined || parsed[2] === "" ? file5.bytes.byteLength - 1 : Number(parsed[2]);
29422
+ if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd) || start < 0 || start >= file5.bytes.byteLength || requestedEnd < start)
29423
+ return new Response(null, {
29424
+ headers: {
29425
+ ...cors,
29426
+ "accept-ranges": "bytes",
29427
+ "content-range": `bytes */${file5.bytes.byteLength}`,
29428
+ etag
29429
+ },
29430
+ status: 416
29431
+ });
29432
+ const end = Math.min(requestedEnd, file5.bytes.byteLength - 1);
29433
+ contents = file5.bytes.slice(start, end + 1);
29434
+ status = 206;
29435
+ contentRange = `bytes ${start}-${end}/${file5.bytes.byteLength}`;
29436
+ }
29437
+ return new Response(new Blob([new Uint8Array(contents).buffer]), {
29354
29438
  headers: {
29355
29439
  ...cors,
29440
+ "accept-ranges": "bytes",
29356
29441
  "cache-control": "public, max-age=31536000, immutable",
29357
- "content-length": String(file5.file.bytes),
29442
+ "content-length": String(contents.byteLength),
29443
+ ...contentRange ? { "content-range": contentRange } : {},
29358
29444
  "content-type": expoContentType(file5.file.path.includes(".") ? file5.file.path.slice(file5.file.path.lastIndexOf(".") + 1) : undefined, false),
29359
- etag: `"${file5.file.sha256}"`
29360
- }
29445
+ etag
29446
+ },
29447
+ status
29361
29448
  });
29362
29449
  };
29363
29450
  };
@@ -37191,5 +37278,5 @@ export {
37191
37278
  devBuild
37192
37279
  };
37193
37280
 
37194
- //# debugId=4B8A1B549AE0AC2164756E2164756E21
37281
+ //# debugId=51C2CE65BFD2E24164756E2164756E21
37195
37282
  //# sourceMappingURL=build.js.map