@hot-updater/protocol 1.0.0-rc.27 → 1.0.0-rc.29

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
@@ -199,7 +199,11 @@ const createPluginHost = (environment) => {
199
199
  const abortFromCaller = () => controller.abort();
200
200
  if (callerSignal?.aborted) controller.abort();
201
201
  callerSignal?.addEventListener("abort", abortFromCaller);
202
- const timeoutId = setTimeout(() => controller.abort(), requestTimeout ?? 5e3);
202
+ let timedOut = false;
203
+ const timeoutId = setTimeout(() => {
204
+ timedOut = true;
205
+ controller.abort();
206
+ }, requestTimeout ?? 5e3);
203
207
  try {
204
208
  return await environment.fetch(url, {
205
209
  ...init,
@@ -207,7 +211,7 @@ const createPluginHost = (environment) => {
207
211
  signal: controller.signal
208
212
  });
209
213
  } catch (error) {
210
- if (error instanceof Error && error.name === "AbortError" && !callerSignal?.aborted) throw new Error("Request timed out");
214
+ if (!callerSignal?.aborted && (timedOut || error instanceof Error && error.name === "AbortError")) throw new Error("Request timed out");
211
215
  throw error;
212
216
  } finally {
213
217
  clearTimeout(timeoutId);
package/dist/index.d.cts CHANGED
@@ -247,6 +247,16 @@ interface UpdateError {
247
247
  /** The error the SDK caught. */
248
248
  readonly cause: unknown;
249
249
  }
250
+ /** A response from the update server's catalog or artifact API. */
251
+ interface UpdateHttpResponse {
252
+ readonly resource: "catalog" | "artifact";
253
+ /** Request path only; authentication headers and query parameters are omitted. */
254
+ readonly path: string;
255
+ readonly status: number;
256
+ /** The response as text, or null if the body could not be read. */
257
+ readonly body: string | null;
258
+ readonly bodyTruncated: boolean;
259
+ }
250
260
  /**
251
261
  * Lifecycle hooks a plugin returns from `setup`. Hooks observe: the SDK
252
262
  * never waits for one and ignores what it returns, and a hook that throws or
@@ -262,6 +272,8 @@ interface HotUpdaterClientHooks {
262
272
  onBundleDownloaded?(info: BundleDownloadedInfo): void | Promise<void>;
263
273
  /** Called when an update check, download, or install fails. */
264
274
  onUpdateError?(error: UpdateError): void | Promise<void>;
275
+ /** Called for every catalog/artifact API response, including 200 and 304. */
276
+ onHttpResponse?(response: UpdateHttpResponse): void | Promise<void>;
265
277
  }
266
278
  /**
267
279
  * A plugin's persistent key-value store. Native keeps it on the device,
@@ -545,4 +557,4 @@ declare function isCohortEligibleForUpdate(bundleId: string, cohort: string | nu
545
557
  declare const NIL_UUID = "00000000-0000-0000-0000-000000000000";
546
558
  declare const isUUIDv7: (value: unknown) => value is string;
547
559
  //#endregion
548
- export { ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactInfo, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, resolveBaseURL, selectDesiredRelease, stripBundleArtifactMetadata };
560
+ export { ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactInfo, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateHttpResponse, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, resolveBaseURL, selectDesiredRelease, stripBundleArtifactMetadata };
package/dist/index.d.mts CHANGED
@@ -247,6 +247,16 @@ interface UpdateError {
247
247
  /** The error the SDK caught. */
248
248
  readonly cause: unknown;
249
249
  }
250
+ /** A response from the update server's catalog or artifact API. */
251
+ interface UpdateHttpResponse {
252
+ readonly resource: "catalog" | "artifact";
253
+ /** Request path only; authentication headers and query parameters are omitted. */
254
+ readonly path: string;
255
+ readonly status: number;
256
+ /** The response as text, or null if the body could not be read. */
257
+ readonly body: string | null;
258
+ readonly bodyTruncated: boolean;
259
+ }
250
260
  /**
251
261
  * Lifecycle hooks a plugin returns from `setup`. Hooks observe: the SDK
252
262
  * never waits for one and ignores what it returns, and a hook that throws or
@@ -262,6 +272,8 @@ interface HotUpdaterClientHooks {
262
272
  onBundleDownloaded?(info: BundleDownloadedInfo): void | Promise<void>;
263
273
  /** Called when an update check, download, or install fails. */
264
274
  onUpdateError?(error: UpdateError): void | Promise<void>;
275
+ /** Called for every catalog/artifact API response, including 200 and 304. */
276
+ onHttpResponse?(response: UpdateHttpResponse): void | Promise<void>;
265
277
  }
266
278
  /**
267
279
  * A plugin's persistent key-value store. Native keeps it on the device,
@@ -545,4 +557,4 @@ declare function isCohortEligibleForUpdate(bundleId: string, cohort: string | nu
545
557
  declare const NIL_UUID = "00000000-0000-0000-0000-000000000000";
546
558
  declare const isUUIDv7: (value: unknown) => value is string;
547
559
  //#endregion
548
- export { ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactInfo, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, resolveBaseURL, selectDesiredRelease, stripBundleArtifactMetadata };
560
+ export { ARTIFACT_PROTOCOL_VERSION, AppReadyResult, ArtifactAsset, ArtifactAssetFile, ArtifactInfo, Bundle, BundleDownloadedInfo, BundleMetadata, BundlePatchArtifact, CatalogAcceptance, CatalogHighWater, ChangedAssetPatch, DEFAULT_ROLLOUT_COHORT_COUNT, DesiredRelease, ExpectedReleaseCatalogScope, HotUpdaterBaseURL, HotUpdaterClientContext, HotUpdaterClientHooks, HotUpdaterClientPlugin, HotUpdaterClientStorage, INVALID_COHORT_ERROR_MESSAGE, MAX_COHORT_LENGTH, MAX_COMPILED_CATALOG_BYTES, MAX_CRASHED_BUNDLES, MAX_DISTINCT_TARGET_COHORTS_PER_SCOPE, MAX_RELEASE_CATALOG_WIRE_BYTES, MAX_TARGET_COHORTS_PER_RELEASE, ManifestArchive, NIL_UUID, NUMERIC_COHORT_SIZE, PersistedSelectionReceipt, Platform, PluginHookName, PluginHookPayload, PluginHost, PluginHostConfig, PluginHostEnvironment, RELEASE_CATALOG_FALLBACK_POLICY, RELEASE_CATALOG_SCHEMA_VERSION, Release, ReleaseCatalog, ReleaseCatalogDescriptor, ReleaseCatalogScopeKeyInput, ReleaseKind, ReleaseOperation, ReleaseSelectionContextInput, ReleaseSelectionInput, ReleaseStrategy, ReleaseTransitionAuthorization, ReleaseTransitionKind, SelectionKind, UpdateCheckResult, UpdateError, UpdateErrorReason, UpdateErrorResource, UpdateErrorStage, UpdateErrorTransport, UpdateHttpResponse, UpdateStatus, UpdateStrategy, assertCanonicalChannelName, assessCatalogAcceptance, authorizeReleaseTransition, canonicalizeAppVersion, createPluginHost, createReleaseCatalogScopeKey, createReleaseSelectionContextHash, decodeChannelKey, defineClientPlugin, encodeChannelKey, getAssetBaseStorageUri, getBundlePatch, getBundlePatches, getDefaultNumericCohort, getManifestFileHash, getManifestStorageUri, getNumericCohortRolloutPosition, getNumericCohortValue, getPatchBaseBundleId, getPatchBaseFileHash, getPatchFileHash, getPatchStorageUri, getRolledOutNumericCohorts, getUtf8ByteLength, hasExpectedReleaseCatalogScope, isCohortEligibleForUpdate, isCustomCohort, isNumericCohort, isReleaseEligibleForCohort, isUUIDv7, isValidCohort, normalizeChannelName, normalizeCohortValue, normalizeRolloutCohortCount, parseReleaseCatalog, parseReleaseCatalogScopeKey, pluginStorageKey, resolveBaseURL, selectDesiredRelease, stripBundleArtifactMetadata };
package/dist/index.mjs CHANGED
@@ -198,7 +198,11 @@ const createPluginHost = (environment) => {
198
198
  const abortFromCaller = () => controller.abort();
199
199
  if (callerSignal?.aborted) controller.abort();
200
200
  callerSignal?.addEventListener("abort", abortFromCaller);
201
- const timeoutId = setTimeout(() => controller.abort(), requestTimeout ?? 5e3);
201
+ let timedOut = false;
202
+ const timeoutId = setTimeout(() => {
203
+ timedOut = true;
204
+ controller.abort();
205
+ }, requestTimeout ?? 5e3);
202
206
  try {
203
207
  return await environment.fetch(url, {
204
208
  ...init,
@@ -206,7 +210,7 @@ const createPluginHost = (environment) => {
206
210
  signal: controller.signal
207
211
  });
208
212
  } catch (error) {
209
- if (error instanceof Error && error.name === "AbortError" && !callerSignal?.aborted) throw new Error("Request timed out");
213
+ if (!callerSignal?.aborted && (timedOut || error instanceof Error && error.name === "AbortError")) throw new Error("Request timed out");
210
214
  throw error;
211
215
  } finally {
212
216
  clearTimeout(timeoutId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/protocol",
3
- "version": "1.0.0-rc.27",
3
+ "version": "1.0.0-rc.29",
4
4
  "type": "module",
5
5
  "description": "The data formats and pure computations that Hot Updater's app and server share",
6
6
  "sideEffects": false,