@hot-updater/plugin-core 0.32.0 → 0.33.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.
@@ -1,5 +1,7 @@
1
1
  require("./_virtual/_rolldown/runtime.cjs");
2
2
  const require_calculatePagination = require("./calculatePagination.cjs");
3
+ const require_bundleUnitOfWork = require("./bundleUnitOfWork.cjs");
4
+ const require_bundleUnitOfWorkStore = require("./bundleUnitOfWorkStore.cjs");
3
5
  let es_toolkit = require("es-toolkit");
4
6
  //#region src/createDatabasePlugin.ts
5
7
  const REPLACE_ON_UPDATE_KEYS = ["patches", "targetCohorts"];
@@ -12,7 +14,7 @@ function normalizePage(value) {
12
14
  return value;
13
15
  }
14
16
  function mergeBundleUpdate(baseBundle, patch) {
15
- return (0, es_toolkit.mergeWith)(baseBundle, patch, (_targetValue, sourceValue, key) => {
17
+ return (0, es_toolkit.mergeWith)({ ...baseBundle }, patch, (_targetValue, sourceValue, key) => {
16
18
  if (REPLACE_ON_UPDATE_KEYS.includes(key)) return sourceValue;
17
19
  });
18
20
  }
@@ -68,6 +70,27 @@ function createPaginatedResult(total, limit, startIndex, data) {
68
70
  }
69
71
  };
70
72
  }
73
+ function expandLimitForUnitOfWork(options, unitOfWork) {
74
+ const extraLimit = unitOfWork.listFetchExtraCount();
75
+ if (extraLimit === 0) return options;
76
+ return {
77
+ ...options,
78
+ limit: options.limit + extraLimit
79
+ };
80
+ }
81
+ function adjustPaginationTotal(pagination, options) {
82
+ if (options.totalDelta === 0) return pagination;
83
+ const total = Math.max(0, pagination.total + options.totalDelta);
84
+ const hasPreviousPage = pagination.currentPage > 1;
85
+ const hasNextPage = pagination.currentPage * options.limit < total;
86
+ return {
87
+ ...pagination,
88
+ total,
89
+ hasNextPage,
90
+ hasPreviousPage,
91
+ totalPages: total === 0 ? 0 : Math.ceil(total / options.limit)
92
+ };
93
+ }
71
94
  /**
72
95
  * Creates a database plugin with lazy initialization and automatic hook execution.
73
96
  *
@@ -102,12 +125,12 @@ function createDatabasePlugin(options) {
102
125
  return cachedMethods;
103
126
  };
104
127
  return () => {
105
- const changedMap = /* @__PURE__ */ new Map();
106
- const markChanged = (operation, data) => {
107
- changedMap.set(data.id, {
108
- operation,
109
- data
110
- });
128
+ const instanceMutationUnitOfWork = new require_bundleUnitOfWork.BundleUnitOfWork();
129
+ const getRequestUnitOfWork = (context) => {
130
+ return require_bundleUnitOfWorkStore.getRequestBundleUnitOfWork(context);
131
+ };
132
+ const getMutationUnitOfWork = (context) => {
133
+ return getRequestUnitOfWork(context) ?? instanceMutationUnitOfWork;
111
134
  };
112
135
  const runGetBundles = async (options, context) => {
113
136
  if (context === void 0) return getMethods().getBundles(options);
@@ -165,22 +188,41 @@ function createDatabasePlugin(options) {
165
188
  const plugin = {
166
189
  name: options.name,
167
190
  async getBundleById(bundleId, context) {
168
- if (context === void 0) return getMethods().getBundleById(bundleId);
169
- return getMethods().getBundleById(bundleId, context);
191
+ const requestUnitOfWork = getRequestUnitOfWork(context);
192
+ if (requestUnitOfWork) return requestUnitOfWork.getById(bundleId, () => getMethods().getBundleById(bundleId, context));
193
+ const pendingMutation = instanceMutationUnitOfWork.peekChanged(bundleId);
194
+ if (pendingMutation.found) return pendingMutation.value;
195
+ return getMethods().getBundleById(bundleId);
170
196
  },
171
197
  async getBundles(options, context) {
172
198
  if (typeof options === "object" && options !== null && "offset" in options && options.offset !== void 0) throw new Error("Bundle offset pagination has been removed. Use cursor.after or cursor.before instead.");
173
199
  const methods = getMethods();
200
+ const requestUnitOfWork = getRequestUnitOfWork(context);
201
+ const unitOfWork = requestUnitOfWork ?? instanceMutationUnitOfWork;
202
+ const shouldOverlay = requestUnitOfWork !== null || instanceMutationUnitOfWork.hasChanges();
174
203
  const normalizedOptions = {
175
204
  ...options,
176
205
  page: normalizePage(options.page),
177
206
  orderBy: options.orderBy ?? DEFAULT_DESC_ORDER
178
207
  };
208
+ const overlayResult = (result) => ({
209
+ ...result,
210
+ data: unitOfWork.overlayList(result.data, {
211
+ limit: normalizedOptions.limit,
212
+ orderBy: normalizedOptions.orderBy,
213
+ where: normalizedOptions.where
214
+ }),
215
+ pagination: adjustPaginationTotal(result.pagination, {
216
+ limit: normalizedOptions.limit,
217
+ totalDelta: unitOfWork.totalDelta(normalizedOptions.where)
218
+ })
219
+ });
179
220
  if (normalizedOptions.page !== void 0) {
180
221
  const { page, ...pageOptions } = normalizedOptions;
181
222
  const requestedOffset = (page - 1) * normalizedOptions.limit;
223
+ const fetchPageOptions = expandLimitForUnitOfWork(pageOptions, unitOfWork);
182
224
  let pageResult = await runGetBundles({
183
- ...pageOptions,
225
+ ...fetchPageOptions,
184
226
  offset: requestedOffset
185
227
  }, context);
186
228
  const total = pageResult.pagination.total;
@@ -188,16 +230,19 @@ function createDatabasePlugin(options) {
188
230
  const maxOffset = totalPages === 0 ? 0 : (Math.max(1, totalPages) - 1) * normalizedOptions.limit;
189
231
  const resolvedOffset = Math.min(requestedOffset, maxOffset);
190
232
  if (resolvedOffset !== requestedOffset) pageResult = await runGetBundles({
191
- ...pageOptions,
233
+ ...fetchPageOptions,
192
234
  offset: resolvedOffset
193
235
  }, context);
194
- return createPaginatedResult(total, normalizedOptions.limit, resolvedOffset, pageResult.data);
236
+ const result = { ...createPaginatedResult(total, normalizedOptions.limit, resolvedOffset, pageResult.data) };
237
+ return shouldOverlay ? overlayResult(result) : result;
195
238
  }
196
239
  if (methods.supportsCursorPagination) {
197
- if (context === void 0) return methods.getBundles(normalizedOptions);
198
- return methods.getBundles(normalizedOptions, context);
240
+ const fetchOptions = expandLimitForUnitOfWork(normalizedOptions, unitOfWork);
241
+ const result = context === void 0 ? await methods.getBundles(fetchOptions) : await methods.getBundles(fetchOptions, context);
242
+ return shouldOverlay ? overlayResult(result) : result;
199
243
  }
200
- return getBundlesWithLegacyCursorFallback(normalizedOptions, context);
244
+ const result = await getBundlesWithLegacyCursorFallback(shouldOverlay ? expandLimitForUnitOfWork(normalizedOptions, unitOfWork) : normalizedOptions, context);
245
+ return shouldOverlay ? overlayResult(result) : result;
201
246
  },
202
247
  async getChannels(context) {
203
248
  if (context === void 0) return getMethods().getChannels();
@@ -209,31 +254,25 @@ function createDatabasePlugin(options) {
209
254
  },
210
255
  async commitBundle(context) {
211
256
  const methods = getMethods();
212
- const params = { changedSets: Array.from(changedMap.values()) };
257
+ const unitOfWork = getMutationUnitOfWork(context);
258
+ const params = { changedSets: unitOfWork.changedSets() };
213
259
  if (context === void 0) await methods.commitBundle(params);
214
260
  else await methods.commitBundle(params, context);
215
- changedMap.clear();
261
+ unitOfWork.clear();
216
262
  await hooks?.onDatabaseUpdated?.();
217
263
  },
218
264
  async updateBundle(targetBundleId, newBundle, context) {
219
- const pendingChange = changedMap.get(targetBundleId);
220
- if (pendingChange) {
221
- const updatedData = mergeBundleUpdate(pendingChange.data, newBundle);
222
- changedMap.set(targetBundleId, {
223
- operation: pendingChange.operation,
224
- data: updatedData
225
- });
226
- return;
227
- }
228
- const currentBundle = context === void 0 ? await getMethods().getBundleById(targetBundleId) : await getMethods().getBundleById(targetBundleId, context);
265
+ const unitOfWork = getMutationUnitOfWork(context);
266
+ const currentBundle = await unitOfWork.getById(targetBundleId, () => context === void 0 ? getMethods().getBundleById(targetBundleId) : getMethods().getBundleById(targetBundleId, context));
229
267
  if (!currentBundle) throw new Error("targetBundleId not found");
230
- markChanged("update", mergeBundleUpdate(currentBundle, newBundle));
268
+ const updatedBundle = mergeBundleUpdate(currentBundle, newBundle);
269
+ unitOfWork.markUpdate(updatedBundle);
231
270
  },
232
- async appendBundle(inputBundle) {
233
- markChanged("insert", inputBundle);
271
+ async appendBundle(inputBundle, context) {
272
+ getMutationUnitOfWork(context).markInsert(inputBundle);
234
273
  },
235
- async deleteBundle(deleteBundle) {
236
- markChanged("delete", deleteBundle);
274
+ async deleteBundle(deleteBundle, context) {
275
+ getMutationUnitOfWork(context).markDelete(deleteBundle);
237
276
  }
238
277
  };
239
278
  Object.defineProperty(plugin, "getUpdateInfo", {
@@ -1,4 +1,6 @@
1
1
  import { calculatePagination } from "./calculatePagination.mjs";
2
+ import { BundleUnitOfWork } from "./bundleUnitOfWork.mjs";
3
+ import { getRequestBundleUnitOfWork } from "./bundleUnitOfWorkStore.mjs";
2
4
  import { mergeWith } from "es-toolkit";
3
5
  //#region src/createDatabasePlugin.ts
4
6
  const REPLACE_ON_UPDATE_KEYS = ["patches", "targetCohorts"];
@@ -11,7 +13,7 @@ function normalizePage(value) {
11
13
  return value;
12
14
  }
13
15
  function mergeBundleUpdate(baseBundle, patch) {
14
- return mergeWith(baseBundle, patch, (_targetValue, sourceValue, key) => {
16
+ return mergeWith({ ...baseBundle }, patch, (_targetValue, sourceValue, key) => {
15
17
  if (REPLACE_ON_UPDATE_KEYS.includes(key)) return sourceValue;
16
18
  });
17
19
  }
@@ -67,6 +69,27 @@ function createPaginatedResult(total, limit, startIndex, data) {
67
69
  }
68
70
  };
69
71
  }
72
+ function expandLimitForUnitOfWork(options, unitOfWork) {
73
+ const extraLimit = unitOfWork.listFetchExtraCount();
74
+ if (extraLimit === 0) return options;
75
+ return {
76
+ ...options,
77
+ limit: options.limit + extraLimit
78
+ };
79
+ }
80
+ function adjustPaginationTotal(pagination, options) {
81
+ if (options.totalDelta === 0) return pagination;
82
+ const total = Math.max(0, pagination.total + options.totalDelta);
83
+ const hasPreviousPage = pagination.currentPage > 1;
84
+ const hasNextPage = pagination.currentPage * options.limit < total;
85
+ return {
86
+ ...pagination,
87
+ total,
88
+ hasNextPage,
89
+ hasPreviousPage,
90
+ totalPages: total === 0 ? 0 : Math.ceil(total / options.limit)
91
+ };
92
+ }
70
93
  /**
71
94
  * Creates a database plugin with lazy initialization and automatic hook execution.
72
95
  *
@@ -101,12 +124,12 @@ function createDatabasePlugin(options) {
101
124
  return cachedMethods;
102
125
  };
103
126
  return () => {
104
- const changedMap = /* @__PURE__ */ new Map();
105
- const markChanged = (operation, data) => {
106
- changedMap.set(data.id, {
107
- operation,
108
- data
109
- });
127
+ const instanceMutationUnitOfWork = new BundleUnitOfWork();
128
+ const getRequestUnitOfWork = (context) => {
129
+ return getRequestBundleUnitOfWork(context);
130
+ };
131
+ const getMutationUnitOfWork = (context) => {
132
+ return getRequestUnitOfWork(context) ?? instanceMutationUnitOfWork;
110
133
  };
111
134
  const runGetBundles = async (options, context) => {
112
135
  if (context === void 0) return getMethods().getBundles(options);
@@ -164,22 +187,41 @@ function createDatabasePlugin(options) {
164
187
  const plugin = {
165
188
  name: options.name,
166
189
  async getBundleById(bundleId, context) {
167
- if (context === void 0) return getMethods().getBundleById(bundleId);
168
- return getMethods().getBundleById(bundleId, context);
190
+ const requestUnitOfWork = getRequestUnitOfWork(context);
191
+ if (requestUnitOfWork) return requestUnitOfWork.getById(bundleId, () => getMethods().getBundleById(bundleId, context));
192
+ const pendingMutation = instanceMutationUnitOfWork.peekChanged(bundleId);
193
+ if (pendingMutation.found) return pendingMutation.value;
194
+ return getMethods().getBundleById(bundleId);
169
195
  },
170
196
  async getBundles(options, context) {
171
197
  if (typeof options === "object" && options !== null && "offset" in options && options.offset !== void 0) throw new Error("Bundle offset pagination has been removed. Use cursor.after or cursor.before instead.");
172
198
  const methods = getMethods();
199
+ const requestUnitOfWork = getRequestUnitOfWork(context);
200
+ const unitOfWork = requestUnitOfWork ?? instanceMutationUnitOfWork;
201
+ const shouldOverlay = requestUnitOfWork !== null || instanceMutationUnitOfWork.hasChanges();
173
202
  const normalizedOptions = {
174
203
  ...options,
175
204
  page: normalizePage(options.page),
176
205
  orderBy: options.orderBy ?? DEFAULT_DESC_ORDER
177
206
  };
207
+ const overlayResult = (result) => ({
208
+ ...result,
209
+ data: unitOfWork.overlayList(result.data, {
210
+ limit: normalizedOptions.limit,
211
+ orderBy: normalizedOptions.orderBy,
212
+ where: normalizedOptions.where
213
+ }),
214
+ pagination: adjustPaginationTotal(result.pagination, {
215
+ limit: normalizedOptions.limit,
216
+ totalDelta: unitOfWork.totalDelta(normalizedOptions.where)
217
+ })
218
+ });
178
219
  if (normalizedOptions.page !== void 0) {
179
220
  const { page, ...pageOptions } = normalizedOptions;
180
221
  const requestedOffset = (page - 1) * normalizedOptions.limit;
222
+ const fetchPageOptions = expandLimitForUnitOfWork(pageOptions, unitOfWork);
181
223
  let pageResult = await runGetBundles({
182
- ...pageOptions,
224
+ ...fetchPageOptions,
183
225
  offset: requestedOffset
184
226
  }, context);
185
227
  const total = pageResult.pagination.total;
@@ -187,16 +229,19 @@ function createDatabasePlugin(options) {
187
229
  const maxOffset = totalPages === 0 ? 0 : (Math.max(1, totalPages) - 1) * normalizedOptions.limit;
188
230
  const resolvedOffset = Math.min(requestedOffset, maxOffset);
189
231
  if (resolvedOffset !== requestedOffset) pageResult = await runGetBundles({
190
- ...pageOptions,
232
+ ...fetchPageOptions,
191
233
  offset: resolvedOffset
192
234
  }, context);
193
- return createPaginatedResult(total, normalizedOptions.limit, resolvedOffset, pageResult.data);
235
+ const result = { ...createPaginatedResult(total, normalizedOptions.limit, resolvedOffset, pageResult.data) };
236
+ return shouldOverlay ? overlayResult(result) : result;
194
237
  }
195
238
  if (methods.supportsCursorPagination) {
196
- if (context === void 0) return methods.getBundles(normalizedOptions);
197
- return methods.getBundles(normalizedOptions, context);
239
+ const fetchOptions = expandLimitForUnitOfWork(normalizedOptions, unitOfWork);
240
+ const result = context === void 0 ? await methods.getBundles(fetchOptions) : await methods.getBundles(fetchOptions, context);
241
+ return shouldOverlay ? overlayResult(result) : result;
198
242
  }
199
- return getBundlesWithLegacyCursorFallback(normalizedOptions, context);
243
+ const result = await getBundlesWithLegacyCursorFallback(shouldOverlay ? expandLimitForUnitOfWork(normalizedOptions, unitOfWork) : normalizedOptions, context);
244
+ return shouldOverlay ? overlayResult(result) : result;
200
245
  },
201
246
  async getChannels(context) {
202
247
  if (context === void 0) return getMethods().getChannels();
@@ -208,31 +253,25 @@ function createDatabasePlugin(options) {
208
253
  },
209
254
  async commitBundle(context) {
210
255
  const methods = getMethods();
211
- const params = { changedSets: Array.from(changedMap.values()) };
256
+ const unitOfWork = getMutationUnitOfWork(context);
257
+ const params = { changedSets: unitOfWork.changedSets() };
212
258
  if (context === void 0) await methods.commitBundle(params);
213
259
  else await methods.commitBundle(params, context);
214
- changedMap.clear();
260
+ unitOfWork.clear();
215
261
  await hooks?.onDatabaseUpdated?.();
216
262
  },
217
263
  async updateBundle(targetBundleId, newBundle, context) {
218
- const pendingChange = changedMap.get(targetBundleId);
219
- if (pendingChange) {
220
- const updatedData = mergeBundleUpdate(pendingChange.data, newBundle);
221
- changedMap.set(targetBundleId, {
222
- operation: pendingChange.operation,
223
- data: updatedData
224
- });
225
- return;
226
- }
227
- const currentBundle = context === void 0 ? await getMethods().getBundleById(targetBundleId) : await getMethods().getBundleById(targetBundleId, context);
264
+ const unitOfWork = getMutationUnitOfWork(context);
265
+ const currentBundle = await unitOfWork.getById(targetBundleId, () => context === void 0 ? getMethods().getBundleById(targetBundleId) : getMethods().getBundleById(targetBundleId, context));
228
266
  if (!currentBundle) throw new Error("targetBundleId not found");
229
- markChanged("update", mergeBundleUpdate(currentBundle, newBundle));
267
+ const updatedBundle = mergeBundleUpdate(currentBundle, newBundle);
268
+ unitOfWork.markUpdate(updatedBundle);
230
269
  },
231
- async appendBundle(inputBundle) {
232
- markChanged("insert", inputBundle);
270
+ async appendBundle(inputBundle, context) {
271
+ getMutationUnitOfWork(context).markInsert(inputBundle);
233
272
  },
234
- async deleteBundle(deleteBundle) {
235
- markChanged("delete", deleteBundle);
273
+ async deleteBundle(deleteBundle, context) {
274
+ getMutationUnitOfWork(context).markDelete(deleteBundle);
236
275
  }
237
276
  };
238
277
  Object.defineProperty(plugin, "getUpdateInfo", {
@@ -1,6 +1,6 @@
1
1
  require("./_virtual/_rolldown/runtime.cjs");
2
2
  const require_filterCompatibleAppVersions = require("./filterCompatibleAppVersions.cjs");
3
- let _hot_updater_js = require("@hot-updater/js");
3
+ const require_resolveUpdateInfoFromBundles = require("./resolveUpdateInfoFromBundles.cjs");
4
4
  let _hot_updater_core = require("@hot-updater/core");
5
5
  //#region src/createDatabasePluginGetUpdateInfo.ts
6
6
  const normalizeAppVersionArgs = (args) => ({
@@ -18,10 +18,18 @@ const createDatabasePluginGetUpdateInfo = ({ getBundlesByFingerprint, getBundles
18
18
  if (args._updateStrategy === "appVersion") {
19
19
  const normalizedArgs = normalizeAppVersionArgs(args);
20
20
  const compatibleAppVersions = require_filterCompatibleAppVersions.filterCompatibleAppVersions(await listTargetAppVersions(normalizedArgs, context), normalizedArgs.appVersion);
21
- return (0, _hot_updater_js.getUpdateInfo)(compatibleAppVersions.length > 0 ? await getBundlesByTargetAppVersions(normalizedArgs, compatibleAppVersions, context) : [], normalizedArgs);
21
+ return require_resolveUpdateInfoFromBundles.resolveUpdateInfoFromBundles({
22
+ args: normalizedArgs,
23
+ bundles: compatibleAppVersions.length > 0 ? await getBundlesByTargetAppVersions(normalizedArgs, compatibleAppVersions, context) : [],
24
+ context
25
+ });
22
26
  }
23
27
  const normalizedArgs = normalizeFingerprintArgs(args);
24
- return (0, _hot_updater_js.getUpdateInfo)(await getBundlesByFingerprint(normalizedArgs, context), normalizedArgs);
28
+ return require_resolveUpdateInfoFromBundles.resolveUpdateInfoFromBundles({
29
+ args: normalizedArgs,
30
+ bundles: await getBundlesByFingerprint(normalizedArgs, context),
31
+ context
32
+ });
25
33
  };
26
34
  };
27
35
  //#endregion
@@ -1,5 +1,5 @@
1
1
  import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.mjs";
2
- import { getUpdateInfo } from "@hot-updater/js";
2
+ import { resolveUpdateInfoFromBundles } from "./resolveUpdateInfoFromBundles.mjs";
3
3
  import { NIL_UUID } from "@hot-updater/core";
4
4
  //#region src/createDatabasePluginGetUpdateInfo.ts
5
5
  const normalizeAppVersionArgs = (args) => ({
@@ -17,10 +17,18 @@ const createDatabasePluginGetUpdateInfo = ({ getBundlesByFingerprint, getBundles
17
17
  if (args._updateStrategy === "appVersion") {
18
18
  const normalizedArgs = normalizeAppVersionArgs(args);
19
19
  const compatibleAppVersions = filterCompatibleAppVersions(await listTargetAppVersions(normalizedArgs, context), normalizedArgs.appVersion);
20
- return getUpdateInfo(compatibleAppVersions.length > 0 ? await getBundlesByTargetAppVersions(normalizedArgs, compatibleAppVersions, context) : [], normalizedArgs);
20
+ return resolveUpdateInfoFromBundles({
21
+ args: normalizedArgs,
22
+ bundles: compatibleAppVersions.length > 0 ? await getBundlesByTargetAppVersions(normalizedArgs, compatibleAppVersions, context) : [],
23
+ context
24
+ });
21
25
  }
22
26
  const normalizedArgs = normalizeFingerprintArgs(args);
23
- return getUpdateInfo(await getBundlesByFingerprint(normalizedArgs, context), normalizedArgs);
27
+ return resolveUpdateInfoFromBundles({
28
+ args: normalizedArgs,
29
+ bundles: await getBundlesByFingerprint(normalizedArgs, context),
30
+ context
31
+ });
24
32
  };
25
33
  };
26
34
  //#endregion
package/dist/index.cjs CHANGED
@@ -3,11 +3,13 @@ const require_calculatePagination = require("./calculatePagination.cjs");
3
3
  const require_compressionFormat = require("./compressionFormat.cjs");
4
4
  const require_contentAddressedAssets = require("./contentAddressedAssets.cjs");
5
5
  const require_assetStorageLayout = require("./assetStorageLayout.cjs");
6
+ const require_queryBundles = require("./queryBundles.cjs");
6
7
  const require_createDatabasePlugin = require("./createDatabasePlugin.cjs");
7
8
  const require_semverSatisfies = require("./semverSatisfies.cjs");
8
9
  const require_filterCompatibleAppVersions = require("./filterCompatibleAppVersions.cjs");
9
- const require_queryBundles = require("./queryBundles.cjs");
10
10
  const require_paginateBundles = require("./paginateBundles.cjs");
11
+ const require_requestUpdateBundleState = require("./requestUpdateBundleState.cjs");
12
+ const require_resolveUpdateInfoFromBundles = require("./resolveUpdateInfoFromBundles.cjs");
11
13
  const require_createBlobDatabasePlugin = require("./createBlobDatabasePlugin.cjs");
12
14
  const require_createDatabasePluginGetUpdateInfo = require("./createDatabasePluginGetUpdateInfo.cjs");
13
15
  const require_createStorageKeyBuilder = require("./createStorageKeyBuilder.cjs");
@@ -26,6 +28,7 @@ exports.createBlobDatabasePlugin = require_createBlobDatabasePlugin.createBlobDa
26
28
  exports.createDatabasePlugin = require_createDatabasePlugin.createDatabasePlugin;
27
29
  exports.createDatabasePluginGetUpdateInfo = require_createDatabasePluginGetUpdateInfo.createDatabasePluginGetUpdateInfo;
28
30
  exports.createNodeStoragePlugin = require_createStoragePlugin.createNodeStoragePlugin;
31
+ exports.createRequestUpdateBundleResolver = require_requestUpdateBundleState.createRequestUpdateBundleResolver;
29
32
  exports.createRuntimeStoragePlugin = require_createStoragePlugin.createRuntimeStoragePlugin;
30
33
  exports.createStorageKeyBuilder = require_createStorageKeyBuilder.createStorageKeyBuilder;
31
34
  exports.createStorageUriWithRelativePath = require_assetStorageLayout.createStorageUriWithRelativePath;
@@ -41,12 +44,14 @@ exports.getCompressionMimeType = require_compressionFormat.getCompressionMimeTyp
41
44
  exports.getContentAddressedAssetStoragePath = require_contentAddressedAssets.getContentAddressedAssetStoragePath;
42
45
  exports.getContentType = require_compressionFormat.getContentType;
43
46
  exports.getManifestAssetStoragePath = require_assetStorageLayout.getManifestAssetStoragePath;
47
+ exports.getRequestUpdateBundleSeeds = require_requestUpdateBundleState.getRequestUpdateBundleSeeds;
44
48
  exports.isContentAddressedAssetBaseStorageUri = require_assetStorageLayout.isContentAddressedAssetBaseStorageUri;
45
49
  exports.isNodeStoragePlugin = require_storageProfile.isNodeStoragePlugin;
46
50
  exports.isRuntimeStoragePlugin = require_storageProfile.isRuntimeStoragePlugin;
47
51
  exports.paginateBundles = require_paginateBundles.paginateBundles;
48
52
  exports.parseStorageUri = require_parseStorageUri.parseStorageUri;
49
53
  exports.resolveManifestAssetStorageUri = require_assetStorageLayout.resolveManifestAssetStorageUri;
54
+ exports.resolveUpdateInfoFromBundles = require_resolveUpdateInfoFromBundles.resolveUpdateInfoFromBundles;
50
55
  exports.semverSatisfies = require_semverSatisfies.semverSatisfies;
51
56
  exports.sortBundles = require_queryBundles.sortBundles;
52
57
  exports.supportedIosPlatforms = require_index.supportedIosPlatforms;
package/dist/index.d.cts CHANGED
@@ -4,7 +4,7 @@ import { PaginationOptions, calculatePagination } from "./calculatePagination.cj
4
4
  import { CompressionFormat, CompressionFormatInfo, detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.cjs";
5
5
  import { AssetStorageLayout, createStorageUriWithRelativePath, getAssetStorageLayout, getManifestAssetStoragePath, isContentAddressedAssetBaseStorageUri, resolveManifestAssetStorageUri } from "./assetStorageLayout.cjs";
6
6
  import { getContentAddressedAssetStoragePath } from "./contentAddressedAssets.cjs";
7
- import { BlobDatabasePluginConfig, BlobOperations, createBlobDatabasePlugin } from "./createBlobDatabasePlugin.cjs";
7
+ import { BlobOperations, createBlobDatabasePlugin } from "./createBlobDatabasePlugin.cjs";
8
8
  import { AbstractDatabasePlugin, CreateDatabasePluginOptions, createDatabasePlugin } from "./createDatabasePlugin.cjs";
9
9
  import { CreateDatabasePluginGetUpdateInfoOptions, createDatabasePluginGetUpdateInfo } from "./createDatabasePluginGetUpdateInfo.cjs";
10
10
  import { createStorageKeyBuilder } from "./createStorageKeyBuilder.cjs";
@@ -14,7 +14,9 @@ import { generateMinBundleId } from "./generateMinBundleId.cjs";
14
14
  import { ParsedStorageUri, parseStorageUri } from "./parseStorageUri.cjs";
15
15
  import { paginateBundles } from "./paginateBundles.cjs";
16
16
  import { bundleIdMatchesFilter, bundleMatchesQueryWhere, sortBundles } from "./queryBundles.cjs";
17
+ import { createRequestUpdateBundleResolver, getRequestUpdateBundleSeeds } from "./requestUpdateBundleState.cjs";
18
+ import { ResolveUpdateInfoFromBundlesOptions, resolveUpdateInfoFromBundles } from "./resolveUpdateInfoFromBundles.cjs";
17
19
  import { semverSatisfies } from "./semverSatisfies.cjs";
18
20
  import { assertNodeStoragePlugin, assertRuntimeStoragePlugin, isNodeStoragePlugin, isRuntimeStoragePlugin } from "./storageProfile.cjs";
19
21
  import { createUUIDv7, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7 } from "./uuidv7.cjs";
20
- export { AbstractDatabasePlugin, AppVersionGetBundlesArgs, ApplePlatform, AssetStorageLayout, BasePluginArgs, BlobDatabasePluginConfig, BlobOperations, BuildPlugin, BuildPluginConfig, BuiltIns, Bundle, CompressionFormat, CompressionFormatInfo, ConfigInput, CreateDatabasePluginGetUpdateInfoOptions, CreateDatabasePluginOptions, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, FingerprintGetBundlesArgs, GetBundlesArgs, HasMultipleCallSignatures, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NodeStoragePlugin, NodeStorageProfile, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, Platform, PlatformConfig, Primitive, RequestEnvContext, RequiredDeep, RuntimeStoragePlugin, RuntimeStorageProfile, SigningConfig, StoragePlugin, StoragePluginHooks, StoragePluginProfiles, StorageResolveContext, UniversalStoragePlugin, UpdateInfo, assertNodeStoragePlugin, assertRuntimeStoragePlugin, bundleIdMatchesFilter, bundleMatchesQueryWhere, calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createNodeStoragePlugin, createRuntimeStoragePlugin, createStorageKeyBuilder, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7WithSameTimestamp, createUniversalStoragePlugin, detectCompressionFormat, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getAssetStorageLayout, getCompressionMimeType, getContentAddressedAssetStoragePath, getContentType, getManifestAssetStoragePath, isContentAddressedAssetBaseStorageUri, isNodeStoragePlugin, isRuntimeStoragePlugin, paginateBundles, parseStorageUri, resolveManifestAssetStorageUri, semverSatisfies, sortBundles, supportedIosPlatforms };
22
+ export { AbstractDatabasePlugin, AppVersionGetBundlesArgs, ApplePlatform, AssetStorageLayout, BasePluginArgs, BlobOperations, BuildPlugin, BuildPluginConfig, BuiltIns, Bundle, CompressionFormat, CompressionFormatInfo, ConfigInput, CreateDatabasePluginGetUpdateInfoOptions, CreateDatabasePluginOptions, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, FingerprintGetBundlesArgs, GetBundlesArgs, HasMultipleCallSignatures, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NodeStoragePlugin, NodeStorageProfile, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, Platform, PlatformConfig, Primitive, RequestEnvContext, RequiredDeep, ResolveUpdateInfoFromBundlesOptions, RuntimeStoragePlugin, RuntimeStorageProfile, SigningConfig, StoragePlugin, StoragePluginHooks, StoragePluginProfiles, StorageResolveContext, UniversalStoragePlugin, UpdateInfo, assertNodeStoragePlugin, assertRuntimeStoragePlugin, bundleIdMatchesFilter, bundleMatchesQueryWhere, calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createNodeStoragePlugin, createRequestUpdateBundleResolver, createRuntimeStoragePlugin, createStorageKeyBuilder, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7WithSameTimestamp, createUniversalStoragePlugin, detectCompressionFormat, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getAssetStorageLayout, getCompressionMimeType, getContentAddressedAssetStoragePath, getContentType, getManifestAssetStoragePath, getRequestUpdateBundleSeeds, isContentAddressedAssetBaseStorageUri, isNodeStoragePlugin, isRuntimeStoragePlugin, paginateBundles, parseStorageUri, resolveManifestAssetStorageUri, resolveUpdateInfoFromBundles, semverSatisfies, sortBundles, supportedIosPlatforms };
package/dist/index.d.mts CHANGED
@@ -4,7 +4,7 @@ import { PaginationOptions, calculatePagination } from "./calculatePagination.mj
4
4
  import { CompressionFormat, CompressionFormatInfo, detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.mjs";
5
5
  import { AssetStorageLayout, createStorageUriWithRelativePath, getAssetStorageLayout, getManifestAssetStoragePath, isContentAddressedAssetBaseStorageUri, resolveManifestAssetStorageUri } from "./assetStorageLayout.mjs";
6
6
  import { getContentAddressedAssetStoragePath } from "./contentAddressedAssets.mjs";
7
- import { BlobDatabasePluginConfig, BlobOperations, createBlobDatabasePlugin } from "./createBlobDatabasePlugin.mjs";
7
+ import { BlobOperations, createBlobDatabasePlugin } from "./createBlobDatabasePlugin.mjs";
8
8
  import { AbstractDatabasePlugin, CreateDatabasePluginOptions, createDatabasePlugin } from "./createDatabasePlugin.mjs";
9
9
  import { CreateDatabasePluginGetUpdateInfoOptions, createDatabasePluginGetUpdateInfo } from "./createDatabasePluginGetUpdateInfo.mjs";
10
10
  import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
@@ -14,7 +14,9 @@ import { generateMinBundleId } from "./generateMinBundleId.mjs";
14
14
  import { ParsedStorageUri, parseStorageUri } from "./parseStorageUri.mjs";
15
15
  import { paginateBundles } from "./paginateBundles.mjs";
16
16
  import { bundleIdMatchesFilter, bundleMatchesQueryWhere, sortBundles } from "./queryBundles.mjs";
17
+ import { createRequestUpdateBundleResolver, getRequestUpdateBundleSeeds } from "./requestUpdateBundleState.mjs";
18
+ import { ResolveUpdateInfoFromBundlesOptions, resolveUpdateInfoFromBundles } from "./resolveUpdateInfoFromBundles.mjs";
17
19
  import { semverSatisfies } from "./semverSatisfies.mjs";
18
20
  import { assertNodeStoragePlugin, assertRuntimeStoragePlugin, isNodeStoragePlugin, isRuntimeStoragePlugin } from "./storageProfile.mjs";
19
21
  import { createUUIDv7, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7 } from "./uuidv7.mjs";
20
- export { AbstractDatabasePlugin, AppVersionGetBundlesArgs, ApplePlatform, AssetStorageLayout, BasePluginArgs, BlobDatabasePluginConfig, BlobOperations, BuildPlugin, BuildPluginConfig, BuiltIns, Bundle, CompressionFormat, CompressionFormatInfo, ConfigInput, CreateDatabasePluginGetUpdateInfoOptions, CreateDatabasePluginOptions, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, FingerprintGetBundlesArgs, GetBundlesArgs, HasMultipleCallSignatures, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NodeStoragePlugin, NodeStorageProfile, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, Platform, PlatformConfig, Primitive, RequestEnvContext, RequiredDeep, RuntimeStoragePlugin, RuntimeStorageProfile, SigningConfig, StoragePlugin, StoragePluginHooks, StoragePluginProfiles, StorageResolveContext, UniversalStoragePlugin, UpdateInfo, assertNodeStoragePlugin, assertRuntimeStoragePlugin, bundleIdMatchesFilter, bundleMatchesQueryWhere, calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createNodeStoragePlugin, createRuntimeStoragePlugin, createStorageKeyBuilder, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7WithSameTimestamp, createUniversalStoragePlugin, detectCompressionFormat, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getAssetStorageLayout, getCompressionMimeType, getContentAddressedAssetStoragePath, getContentType, getManifestAssetStoragePath, isContentAddressedAssetBaseStorageUri, isNodeStoragePlugin, isRuntimeStoragePlugin, paginateBundles, parseStorageUri, resolveManifestAssetStorageUri, semverSatisfies, sortBundles, supportedIosPlatforms };
22
+ export { AbstractDatabasePlugin, AppVersionGetBundlesArgs, ApplePlatform, AssetStorageLayout, BasePluginArgs, BlobOperations, BuildPlugin, BuildPluginConfig, BuiltIns, Bundle, CompressionFormat, CompressionFormatInfo, ConfigInput, CreateDatabasePluginGetUpdateInfoOptions, CreateDatabasePluginOptions, DatabaseBundleCursor, DatabaseBundleIdFilter, DatabaseBundleQueryOptions, DatabaseBundleQueryOrder, DatabaseBundleQueryWhere, DatabasePlugin, DatabasePluginHooks, FingerprintGetBundlesArgs, GetBundlesArgs, HasMultipleCallSignatures, HotUpdaterContext, IosBuildDestination, NativeBuildAndroidScheme, NativeBuildArgs, NativeBuildIosScheme, NativeBuildOptions, NodeStoragePlugin, NodeStorageProfile, Paginated, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, Platform, PlatformConfig, Primitive, RequestEnvContext, RequiredDeep, ResolveUpdateInfoFromBundlesOptions, RuntimeStoragePlugin, RuntimeStorageProfile, SigningConfig, StoragePlugin, StoragePluginHooks, StoragePluginProfiles, StorageResolveContext, UniversalStoragePlugin, UpdateInfo, assertNodeStoragePlugin, assertRuntimeStoragePlugin, bundleIdMatchesFilter, bundleMatchesQueryWhere, calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createNodeStoragePlugin, createRequestUpdateBundleResolver, createRuntimeStoragePlugin, createStorageKeyBuilder, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7WithSameTimestamp, createUniversalStoragePlugin, detectCompressionFormat, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getAssetStorageLayout, getCompressionMimeType, getContentAddressedAssetStoragePath, getContentType, getManifestAssetStoragePath, getRequestUpdateBundleSeeds, isContentAddressedAssetBaseStorageUri, isNodeStoragePlugin, isRuntimeStoragePlugin, paginateBundles, parseStorageUri, resolveManifestAssetStorageUri, resolveUpdateInfoFromBundles, semverSatisfies, sortBundles, supportedIosPlatforms };
package/dist/index.mjs CHANGED
@@ -2,11 +2,13 @@ import { calculatePagination } from "./calculatePagination.mjs";
2
2
  import { detectCompressionFormat, getCompressionMimeType, getContentType } from "./compressionFormat.mjs";
3
3
  import { getContentAddressedAssetStoragePath } from "./contentAddressedAssets.mjs";
4
4
  import { createStorageUriWithRelativePath, getAssetStorageLayout, getManifestAssetStoragePath, isContentAddressedAssetBaseStorageUri, resolveManifestAssetStorageUri } from "./assetStorageLayout.mjs";
5
+ import { bundleIdMatchesFilter, bundleMatchesQueryWhere, sortBundles } from "./queryBundles.mjs";
5
6
  import { createDatabasePlugin } from "./createDatabasePlugin.mjs";
6
7
  import { semverSatisfies } from "./semverSatisfies.mjs";
7
8
  import { filterCompatibleAppVersions } from "./filterCompatibleAppVersions.mjs";
8
- import { bundleIdMatchesFilter, bundleMatchesQueryWhere, sortBundles } from "./queryBundles.mjs";
9
9
  import { paginateBundles } from "./paginateBundles.mjs";
10
+ import { createRequestUpdateBundleResolver, getRequestUpdateBundleSeeds } from "./requestUpdateBundleState.mjs";
11
+ import { resolveUpdateInfoFromBundles } from "./resolveUpdateInfoFromBundles.mjs";
10
12
  import { createBlobDatabasePlugin } from "./createBlobDatabasePlugin.mjs";
11
13
  import { createDatabasePluginGetUpdateInfo } from "./createDatabasePluginGetUpdateInfo.mjs";
12
14
  import { createStorageKeyBuilder } from "./createStorageKeyBuilder.mjs";
@@ -16,4 +18,4 @@ import { parseStorageUri } from "./parseStorageUri.mjs";
16
18
  import { assertNodeStoragePlugin, assertRuntimeStoragePlugin, isNodeStoragePlugin, isRuntimeStoragePlugin } from "./storageProfile.mjs";
17
19
  import { supportedIosPlatforms } from "./types/index.mjs";
18
20
  import { createUUIDv7, createUUIDv7WithSameTimestamp, extractTimestampFromUUIDv7 } from "./uuidv7.mjs";
19
- export { assertNodeStoragePlugin, assertRuntimeStoragePlugin, bundleIdMatchesFilter, bundleMatchesQueryWhere, calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createNodeStoragePlugin, createRuntimeStoragePlugin, createStorageKeyBuilder, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7WithSameTimestamp, createUniversalStoragePlugin, detectCompressionFormat, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getAssetStorageLayout, getCompressionMimeType, getContentAddressedAssetStoragePath, getContentType, getManifestAssetStoragePath, isContentAddressedAssetBaseStorageUri, isNodeStoragePlugin, isRuntimeStoragePlugin, paginateBundles, parseStorageUri, resolveManifestAssetStorageUri, semverSatisfies, sortBundles, supportedIosPlatforms };
21
+ export { assertNodeStoragePlugin, assertRuntimeStoragePlugin, bundleIdMatchesFilter, bundleMatchesQueryWhere, calculatePagination, createBlobDatabasePlugin, createDatabasePlugin, createDatabasePluginGetUpdateInfo, createNodeStoragePlugin, createRequestUpdateBundleResolver, createRuntimeStoragePlugin, createStorageKeyBuilder, createStorageUriWithRelativePath, createUUIDv7, createUUIDv7WithSameTimestamp, createUniversalStoragePlugin, detectCompressionFormat, extractTimestampFromUUIDv7, filterCompatibleAppVersions, generateMinBundleId, getAssetStorageLayout, getCompressionMimeType, getContentAddressedAssetStoragePath, getContentType, getManifestAssetStoragePath, getRequestUpdateBundleSeeds, isContentAddressedAssetBaseStorageUri, isNodeStoragePlugin, isRuntimeStoragePlugin, paginateBundles, parseStorageUri, resolveManifestAssetStorageUri, resolveUpdateInfoFromBundles, semverSatisfies, sortBundles, supportedIosPlatforms };
@@ -0,0 +1,26 @@
1
+ const require_bundleUnitOfWork = require("./bundleUnitOfWork.cjs");
2
+ const require_bundleUnitOfWorkStore = require("./bundleUnitOfWorkStore.cjs");
3
+ //#region src/requestUpdateBundleState.ts
4
+ const toBundleSeeds = (seeds) => seeds.filter((seed) => !!seed);
5
+ const seedRequestUpdateBundles = (context, seeds) => {
6
+ const unitOfWork = require_bundleUnitOfWorkStore.getRequestBundleUnitOfWork(context);
7
+ if (!unitOfWork) return;
8
+ const nextSeeds = toBundleSeeds(seeds);
9
+ if (nextSeeds.length === 0) return;
10
+ unitOfWork.seed(nextSeeds);
11
+ };
12
+ const getRequestUpdateBundleSeeds = (context) => {
13
+ return require_bundleUnitOfWorkStore.getRequestBundleUnitOfWork(context)?.seededBundles() ?? [];
14
+ };
15
+ const createRequestUpdateBundleResolver = (context) => {
16
+ const unitOfWork = require_bundleUnitOfWorkStore.getRequestBundleUnitOfWork(context) ?? new require_bundleUnitOfWork.BundleUnitOfWork();
17
+ return {
18
+ hasSeededBundles: () => unitOfWork.hasSeeds(),
19
+ peek: (bundleId) => unitOfWork.peek(bundleId),
20
+ getById: (bundleId, loadBundleById) => unitOfWork.getById(bundleId, loadBundleById)
21
+ };
22
+ };
23
+ //#endregion
24
+ exports.createRequestUpdateBundleResolver = createRequestUpdateBundleResolver;
25
+ exports.getRequestUpdateBundleSeeds = getRequestUpdateBundleSeeds;
26
+ exports.seedRequestUpdateBundles = seedRequestUpdateBundles;
@@ -0,0 +1,12 @@
1
+ import { Bundle, HotUpdaterContext } from "./types/index.cjs";
2
+
3
+ //#region src/requestUpdateBundleState.d.ts
4
+ interface RequestUpdateBundleResolver {
5
+ readonly hasSeededBundles: () => boolean;
6
+ readonly peek: (bundleId: string) => Bundle | null;
7
+ readonly getById: (bundleId: string, loadBundleById: () => Promise<Bundle | null>) => Promise<Bundle | null>;
8
+ }
9
+ declare const getRequestUpdateBundleSeeds: <TContext = unknown>(context: HotUpdaterContext<TContext> | undefined) => readonly Bundle[];
10
+ declare const createRequestUpdateBundleResolver: <TContext = unknown>(context: HotUpdaterContext<TContext> | undefined) => RequestUpdateBundleResolver;
11
+ //#endregion
12
+ export { createRequestUpdateBundleResolver, getRequestUpdateBundleSeeds };
@@ -0,0 +1,12 @@
1
+ import { Bundle, HotUpdaterContext } from "./types/index.mjs";
2
+
3
+ //#region src/requestUpdateBundleState.d.ts
4
+ interface RequestUpdateBundleResolver {
5
+ readonly hasSeededBundles: () => boolean;
6
+ readonly peek: (bundleId: string) => Bundle | null;
7
+ readonly getById: (bundleId: string, loadBundleById: () => Promise<Bundle | null>) => Promise<Bundle | null>;
8
+ }
9
+ declare const getRequestUpdateBundleSeeds: <TContext = unknown>(context: HotUpdaterContext<TContext> | undefined) => readonly Bundle[];
10
+ declare const createRequestUpdateBundleResolver: <TContext = unknown>(context: HotUpdaterContext<TContext> | undefined) => RequestUpdateBundleResolver;
11
+ //#endregion
12
+ export { createRequestUpdateBundleResolver, getRequestUpdateBundleSeeds };
@@ -0,0 +1,24 @@
1
+ import { BundleUnitOfWork } from "./bundleUnitOfWork.mjs";
2
+ import { getRequestBundleUnitOfWork } from "./bundleUnitOfWorkStore.mjs";
3
+ //#region src/requestUpdateBundleState.ts
4
+ const toBundleSeeds = (seeds) => seeds.filter((seed) => !!seed);
5
+ const seedRequestUpdateBundles = (context, seeds) => {
6
+ const unitOfWork = getRequestBundleUnitOfWork(context);
7
+ if (!unitOfWork) return;
8
+ const nextSeeds = toBundleSeeds(seeds);
9
+ if (nextSeeds.length === 0) return;
10
+ unitOfWork.seed(nextSeeds);
11
+ };
12
+ const getRequestUpdateBundleSeeds = (context) => {
13
+ return getRequestBundleUnitOfWork(context)?.seededBundles() ?? [];
14
+ };
15
+ const createRequestUpdateBundleResolver = (context) => {
16
+ const unitOfWork = getRequestBundleUnitOfWork(context) ?? new BundleUnitOfWork();
17
+ return {
18
+ hasSeededBundles: () => unitOfWork.hasSeeds(),
19
+ peek: (bundleId) => unitOfWork.peek(bundleId),
20
+ getById: (bundleId, loadBundleById) => unitOfWork.getById(bundleId, loadBundleById)
21
+ };
22
+ };
23
+ //#endregion
24
+ export { createRequestUpdateBundleResolver, getRequestUpdateBundleSeeds, seedRequestUpdateBundles };
@@ -0,0 +1,14 @@
1
+ require("./_virtual/_rolldown/runtime.cjs");
2
+ const require_requestUpdateBundleState = require("./requestUpdateBundleState.cjs");
3
+ let _hot_updater_core = require("@hot-updater/core");
4
+ let _hot_updater_js = require("@hot-updater/js");
5
+ //#region src/resolveUpdateInfoFromBundles.ts
6
+ const findSeedBundle = (bundles, bundleId) => bundles.find((bundle) => bundle.id === bundleId);
7
+ const resolveUpdateInfoFromBundles = async ({ args, bundles, context }) => {
8
+ const info = await (0, _hot_updater_js.getUpdateInfo)(bundles, args);
9
+ if (!info) return null;
10
+ require_requestUpdateBundleState.seedRequestUpdateBundles(context, [findSeedBundle(bundles, info.id), args.bundleId === _hot_updater_core.NIL_UUID ? null : findSeedBundle(bundles, args.bundleId)]);
11
+ return info;
12
+ };
13
+ //#endregion
14
+ exports.resolveUpdateInfoFromBundles = resolveUpdateInfoFromBundles;