@hot-updater/cloudflare 0.31.4 → 0.33.0
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/iac/index.cjs +206 -92
- package/dist/iac/index.mjs +198 -84
- package/dist/index.cjs +223 -63
- package/dist/index.d.cts +46 -6
- package/dist/index.d.mts +46 -6
- package/dist/index.mjs +218 -59
- package/dist/worker/index.cjs +9 -12
- package/dist/worker/index.d.cts +4 -3
- package/dist/worker/index.d.mts +3 -2
- package/dist/worker/index.mjs +9 -12
- package/package.json +10 -7
- package/src/cloudflareWorkerDatabase.spec.ts +260 -0
- package/src/cloudflareWorkerDatabase.ts +23 -19
- package/src/d1Database.spec.ts +16 -2
- package/src/d1Database.ts +23 -19
- package/src/r2S3Storage.ts +197 -0
- package/src/r2Storage.spec.ts +316 -2
- package/src/r2Storage.ts +50 -110
- package/src/r2WranglerStorage.ts +193 -0
- package/worker/dist/README.md +1 -1
- package/worker/dist/index.js +249 -58
- package/worker/dist/index.js.map +4 -4
- package/worker/src/index.ts +0 -1
- package/worker/src/getUpdateInfo.ts +0 -194
package/worker/dist/index.js
CHANGED
|
@@ -5236,6 +5236,52 @@ function calculatePagination(total, options) {
|
|
|
5236
5236
|
}
|
|
5237
5237
|
__name(calculatePagination, "calculatePagination");
|
|
5238
5238
|
|
|
5239
|
+
// ../plugin-core/dist/contentAddressedAssets.mjs
|
|
5240
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
5241
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
5242
|
+
init_performance2();
|
|
5243
|
+
var getContentAddressedAssetStoragePath = /* @__PURE__ */ __name(({ assetPath, fileHash }) => {
|
|
5244
|
+
const extension = assetPath.endsWith(".br") ? ".br" : assetPath.includes(".") ? `.${assetPath.split(".").pop()}` : "";
|
|
5245
|
+
return `sha256/${fileHash.slice(0, 2)}/${fileHash}${extension}`;
|
|
5246
|
+
}, "getContentAddressedAssetStoragePath");
|
|
5247
|
+
|
|
5248
|
+
// ../plugin-core/dist/assetStorageLayout.mjs
|
|
5249
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
5250
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
5251
|
+
init_performance2();
|
|
5252
|
+
|
|
5253
|
+
// ../plugin-core/dist/legacyAssetStorageLayout.mjs
|
|
5254
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
5255
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
5256
|
+
init_performance2();
|
|
5257
|
+
var getLegacyManifestAssetStoragePath = /* @__PURE__ */ __name(({ assetPath }) => assetPath, "getLegacyManifestAssetStoragePath");
|
|
5258
|
+
|
|
5259
|
+
// ../plugin-core/dist/assetStorageLayout.mjs
|
|
5260
|
+
var createStorageUriWithRelativePath = /* @__PURE__ */ __name(({ baseStorageUri, relativePath }) => {
|
|
5261
|
+
const storageUrl = new URL(baseStorageUri);
|
|
5262
|
+
storageUrl.pathname = `${storageUrl.pathname.replace(/\/+$/, "")}/${relativePath.replace(/\\/g, "/").split("/").filter(Boolean).map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
5263
|
+
return storageUrl.toString();
|
|
5264
|
+
}, "createStorageUriWithRelativePath");
|
|
5265
|
+
var getAssetStorageLayout = /* @__PURE__ */ __name((assetBaseStorageUri) => {
|
|
5266
|
+
const pathname = new URL(assetBaseStorageUri).pathname.replace(/\/+$/, "");
|
|
5267
|
+
return pathname.endsWith("/assets") || pathname === "/assets" ? "content-addressed" : "legacy-files";
|
|
5268
|
+
}, "getAssetStorageLayout");
|
|
5269
|
+
var getManifestAssetStoragePath = /* @__PURE__ */ __name(({ assetBaseStorageUri, assetPath, fileHash }) => {
|
|
5270
|
+
if (getAssetStorageLayout(assetBaseStorageUri) === "content-addressed") return getContentAddressedAssetStoragePath({
|
|
5271
|
+
assetPath,
|
|
5272
|
+
fileHash
|
|
5273
|
+
});
|
|
5274
|
+
return getLegacyManifestAssetStoragePath({ assetPath });
|
|
5275
|
+
}, "getManifestAssetStoragePath");
|
|
5276
|
+
var resolveManifestAssetStorageUri = /* @__PURE__ */ __name(({ assetBaseStorageUri, assetPath, fileHash }) => createStorageUriWithRelativePath({
|
|
5277
|
+
baseStorageUri: assetBaseStorageUri,
|
|
5278
|
+
relativePath: getManifestAssetStoragePath({
|
|
5279
|
+
assetBaseStorageUri,
|
|
5280
|
+
assetPath,
|
|
5281
|
+
fileHash
|
|
5282
|
+
})
|
|
5283
|
+
}), "resolveManifestAssetStorageUri");
|
|
5284
|
+
|
|
5239
5285
|
// ../plugin-core/dist/createDatabasePlugin.mjs
|
|
5240
5286
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
5241
5287
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
@@ -5548,7 +5594,28 @@ var filterCompatibleAppVersions = /* @__PURE__ */ __name((targetAppVersionList,
|
|
|
5548
5594
|
return targetAppVersionList.filter((version2) => semverSatisfies(version2, currentVersion)).sort((a, b) => b.localeCompare(a));
|
|
5549
5595
|
}, "filterCompatibleAppVersions");
|
|
5550
5596
|
|
|
5551
|
-
// ../
|
|
5597
|
+
// ../plugin-core/dist/requestUpdateBundleState.mjs
|
|
5598
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
5599
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
5600
|
+
init_performance2();
|
|
5601
|
+
var requestUpdateBundleSeeds = /* @__PURE__ */ new WeakMap();
|
|
5602
|
+
var isWeakMapKey = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null || typeof value === "function", "isWeakMapKey");
|
|
5603
|
+
var toBundleSeeds = /* @__PURE__ */ __name((seeds) => seeds.filter((seed) => !!seed), "toBundleSeeds");
|
|
5604
|
+
var seedRequestUpdateBundles = /* @__PURE__ */ __name((context2, seeds) => {
|
|
5605
|
+
if (!isWeakMapKey(context2)) return;
|
|
5606
|
+
const nextSeeds = toBundleSeeds(seeds);
|
|
5607
|
+
if (nextSeeds.length === 0) return;
|
|
5608
|
+
const bundlesById = /* @__PURE__ */ new Map();
|
|
5609
|
+
for (const seed of requestUpdateBundleSeeds.get(context2) ?? []) bundlesById.set(seed.id, seed);
|
|
5610
|
+
for (const seed of nextSeeds) bundlesById.set(seed.id, seed);
|
|
5611
|
+
requestUpdateBundleSeeds.set(context2, [...bundlesById.values()]);
|
|
5612
|
+
}, "seedRequestUpdateBundles");
|
|
5613
|
+
var getRequestUpdateBundleSeeds = /* @__PURE__ */ __name((context2) => {
|
|
5614
|
+
if (!isWeakMapKey(context2)) return [];
|
|
5615
|
+
return requestUpdateBundleSeeds.get(context2) ?? [];
|
|
5616
|
+
}, "getRequestUpdateBundleSeeds");
|
|
5617
|
+
|
|
5618
|
+
// ../plugin-core/dist/resolveUpdateInfoFromBundles.mjs
|
|
5552
5619
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
5553
5620
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
5554
5621
|
init_performance2();
|
|
@@ -5701,13 +5768,16 @@ __name(isCohortEligibleForUpdate, "isCohortEligibleForUpdate");
|
|
|
5701
5768
|
var NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
5702
5769
|
|
|
5703
5770
|
// ../js/dist/index.mjs
|
|
5771
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
5772
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
5773
|
+
init_performance2();
|
|
5704
5774
|
var __create2 = Object.create;
|
|
5705
5775
|
var __defProp2 = Object.defineProperty;
|
|
5706
5776
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
5707
5777
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
5708
5778
|
var __getProtoOf2 = Object.getPrototypeOf;
|
|
5709
5779
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
5710
|
-
var __commonJSMin = /* @__PURE__ */ __name((cb, mod) => () => (mod ||
|
|
5780
|
+
var __commonJSMin = /* @__PURE__ */ __name((cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports), "__commonJSMin");
|
|
5711
5781
|
var __copyProps2 = /* @__PURE__ */ __name((to, from, except, desc) => {
|
|
5712
5782
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames2(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
5713
5783
|
key = keys[i];
|
|
@@ -6718,7 +6788,6 @@ var require_min_version2 = /* @__PURE__ */ __commonJSMin((exports, module) => {
|
|
|
6718
6788
|
case "<":
|
|
6719
6789
|
case "<=":
|
|
6720
6790
|
break;
|
|
6721
|
-
/* istanbul ignore next */
|
|
6722
6791
|
default:
|
|
6723
6792
|
throw new Error(`Unexpected operation: ${comparator.operator}`);
|
|
6724
6793
|
}
|
|
@@ -8234,6 +8303,15 @@ var signToken = /* @__PURE__ */ __name(async (key, jwtSecret) => {
|
|
|
8234
8303
|
return await new SignJWT({ key }).setProtectedHeader({ alg: "HS256" }).setExpirationTime("60s").sign(secretKey);
|
|
8235
8304
|
}, "signToken");
|
|
8236
8305
|
|
|
8306
|
+
// ../plugin-core/dist/resolveUpdateInfoFromBundles.mjs
|
|
8307
|
+
var findSeedBundle = /* @__PURE__ */ __name((bundles, bundleId) => bundles.find((bundle) => bundle.id === bundleId), "findSeedBundle");
|
|
8308
|
+
var resolveUpdateInfoFromBundles = /* @__PURE__ */ __name(async ({ args, bundles, context: context2 }) => {
|
|
8309
|
+
const info3 = await getUpdateInfo(bundles, args);
|
|
8310
|
+
if (!info3) return null;
|
|
8311
|
+
seedRequestUpdateBundles(context2, [findSeedBundle(bundles, info3.id), args.bundleId === NIL_UUID ? null : findSeedBundle(bundles, args.bundleId)]);
|
|
8312
|
+
return info3;
|
|
8313
|
+
}, "resolveUpdateInfoFromBundles");
|
|
8314
|
+
|
|
8237
8315
|
// ../plugin-core/dist/createDatabasePluginGetUpdateInfo.mjs
|
|
8238
8316
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
8239
8317
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
@@ -8253,10 +8331,18 @@ var createDatabasePluginGetUpdateInfo = /* @__PURE__ */ __name(({ getBundlesByFi
|
|
|
8253
8331
|
if (args._updateStrategy === "appVersion") {
|
|
8254
8332
|
const normalizedArgs2 = normalizeAppVersionArgs(args);
|
|
8255
8333
|
const compatibleAppVersions = filterCompatibleAppVersions(await listTargetAppVersions(normalizedArgs2, context2), normalizedArgs2.appVersion);
|
|
8256
|
-
return
|
|
8334
|
+
return resolveUpdateInfoFromBundles({
|
|
8335
|
+
args: normalizedArgs2,
|
|
8336
|
+
bundles: compatibleAppVersions.length > 0 ? await getBundlesByTargetAppVersions(normalizedArgs2, compatibleAppVersions, context2) : [],
|
|
8337
|
+
context: context2
|
|
8338
|
+
});
|
|
8257
8339
|
}
|
|
8258
8340
|
const normalizedArgs = normalizeFingerprintArgs(args);
|
|
8259
|
-
return
|
|
8341
|
+
return resolveUpdateInfoFromBundles({
|
|
8342
|
+
args: normalizedArgs,
|
|
8343
|
+
bundles: await getBundlesByFingerprint(normalizedArgs, context2),
|
|
8344
|
+
context: context2
|
|
8345
|
+
});
|
|
8260
8346
|
};
|
|
8261
8347
|
}, "createDatabasePluginGetUpdateInfo");
|
|
8262
8348
|
|
|
@@ -8310,6 +8396,9 @@ var createProfiledStoragePlugin = /* @__PURE__ */ __name(({ createProfiles, name
|
|
|
8310
8396
|
async downloadFile(storageUri, filePath) {
|
|
8311
8397
|
return requireNodeProfile().downloadFile(storageUri, filePath);
|
|
8312
8398
|
},
|
|
8399
|
+
async exists(storageUri) {
|
|
8400
|
+
return requireNodeProfile().exists(storageUri);
|
|
8401
|
+
},
|
|
8313
8402
|
async upload(key, filePath) {
|
|
8314
8403
|
return requireNodeProfile().upload(key, filePath);
|
|
8315
8404
|
}
|
|
@@ -8366,6 +8455,51 @@ init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
|
8366
8455
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
8367
8456
|
init_performance2();
|
|
8368
8457
|
|
|
8458
|
+
// ../../packages/server/src/db/requestBundleIdentityMap.ts
|
|
8459
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
8460
|
+
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
8461
|
+
init_performance2();
|
|
8462
|
+
var createRequestBundleIdentityMap = /* @__PURE__ */ __name(({
|
|
8463
|
+
context: context2,
|
|
8464
|
+
loadBundleById,
|
|
8465
|
+
seeds
|
|
8466
|
+
}) => {
|
|
8467
|
+
const bundles = /* @__PURE__ */ new Map();
|
|
8468
|
+
const pendingBundles = /* @__PURE__ */ new Map();
|
|
8469
|
+
for (const seed of seeds) {
|
|
8470
|
+
if (seed) {
|
|
8471
|
+
bundles.set(seed.id, seed);
|
|
8472
|
+
}
|
|
8473
|
+
}
|
|
8474
|
+
const get = /* @__PURE__ */ __name(async (bundleId) => {
|
|
8475
|
+
const cachedBundle = bundles.get(bundleId);
|
|
8476
|
+
if (cachedBundle) {
|
|
8477
|
+
return cachedBundle;
|
|
8478
|
+
}
|
|
8479
|
+
const pendingBundle = pendingBundles.get(bundleId);
|
|
8480
|
+
if (pendingBundle) {
|
|
8481
|
+
return pendingBundle;
|
|
8482
|
+
}
|
|
8483
|
+
const lookup = loadBundleById(bundleId, context2).then(
|
|
8484
|
+
(bundle) => {
|
|
8485
|
+
pendingBundles.delete(bundleId);
|
|
8486
|
+
if (bundle) {
|
|
8487
|
+
bundles.set(bundle.id, bundle);
|
|
8488
|
+
}
|
|
8489
|
+
return bundle;
|
|
8490
|
+
},
|
|
8491
|
+
(error3) => {
|
|
8492
|
+
pendingBundles.delete(bundleId);
|
|
8493
|
+
throw error3;
|
|
8494
|
+
}
|
|
8495
|
+
);
|
|
8496
|
+
pendingBundles.set(bundleId, lookup);
|
|
8497
|
+
return lookup;
|
|
8498
|
+
}, "get");
|
|
8499
|
+
const peek = /* @__PURE__ */ __name((bundleId) => bundles.get(bundleId) ?? null, "peek");
|
|
8500
|
+
return { get, peek };
|
|
8501
|
+
}, "createRequestBundleIdentityMap");
|
|
8502
|
+
|
|
8369
8503
|
// ../../packages/server/src/db/schemaEnhancements.ts
|
|
8370
8504
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
8371
8505
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
@@ -8434,13 +8568,6 @@ var isBundleManifest = /* @__PURE__ */ __name((value) => {
|
|
|
8434
8568
|
}
|
|
8435
8569
|
);
|
|
8436
8570
|
}, "isBundleManifest");
|
|
8437
|
-
var createChildStorageUri = /* @__PURE__ */ __name((baseStorageUri, relativePath) => {
|
|
8438
|
-
const baseUrl = new URL(baseStorageUri);
|
|
8439
|
-
const normalizedBasePath = baseUrl.pathname.replace(/\/+$/, "");
|
|
8440
|
-
const relativeSegments = relativePath.split("/").filter(Boolean).map((segment) => encodeURIComponent(segment));
|
|
8441
|
-
baseUrl.pathname = `${normalizedBasePath}/${relativeSegments.join("/")}`;
|
|
8442
|
-
return baseUrl.toString();
|
|
8443
|
-
}, "createChildStorageUri");
|
|
8444
8571
|
async function fetchBundleManifest(storageUri, readStorageText, resolveFileUrl, context2) {
|
|
8445
8572
|
const [storageText, fileUrl] = await Promise.all([
|
|
8446
8573
|
readStorageText(storageUri, context2),
|
|
@@ -8491,10 +8618,11 @@ async function resolveChangedAssets({
|
|
|
8491
8618
|
}
|
|
8492
8619
|
const usesBrotliAsset = BR_COMPRESSED_ASSET_PATH_RE.test(assetPath);
|
|
8493
8620
|
const downloadPath = usesBrotliAsset ? `${assetPath}.br` : assetPath;
|
|
8494
|
-
const storageUri =
|
|
8621
|
+
const storageUri = resolveManifestAssetStorageUri({
|
|
8495
8622
|
assetBaseStorageUri,
|
|
8496
|
-
downloadPath
|
|
8497
|
-
|
|
8623
|
+
assetPath: downloadPath,
|
|
8624
|
+
fileHash: asset.fileHash
|
|
8625
|
+
});
|
|
8498
8626
|
const patch = patchDescriptor?.assetPath === assetPath ? patchDescriptor.patch : null;
|
|
8499
8627
|
let fileUrl = null;
|
|
8500
8628
|
try {
|
|
@@ -8830,10 +8958,26 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
|
|
|
8830
8958
|
const baseResponse2 = { ...rest, fileUrl: fileUrl2 };
|
|
8831
8959
|
return baseResponse2;
|
|
8832
8960
|
}
|
|
8961
|
+
const requestBundleSeeds = getRequestUpdateBundleSeeds(context2);
|
|
8962
|
+
const requestBundles = createRequestBundleIdentityMap({
|
|
8963
|
+
context: context2,
|
|
8964
|
+
loadBundleById: /* @__PURE__ */ __name((bundleId, requestContext) => getPlugin().getBundleById(bundleId, requestContext), "loadBundleById"),
|
|
8965
|
+
seeds: requestBundleSeeds
|
|
8966
|
+
});
|
|
8967
|
+
const getCurrentBundle = /* @__PURE__ */ __name(() => {
|
|
8968
|
+
if (args.bundleId === NIL_UUID) {
|
|
8969
|
+
return null;
|
|
8970
|
+
}
|
|
8971
|
+
const seededCurrentBundle = requestBundles.peek(args.bundleId);
|
|
8972
|
+
if (seededCurrentBundle || requestBundleSeeds.length > 0) {
|
|
8973
|
+
return seededCurrentBundle;
|
|
8974
|
+
}
|
|
8975
|
+
return requestBundles.get(args.bundleId);
|
|
8976
|
+
}, "getCurrentBundle");
|
|
8833
8977
|
const [fileUrl, targetBundle, currentBundle] = await Promise.all([
|
|
8834
8978
|
resolveFileUrl(storageUri ?? null, context2),
|
|
8835
|
-
|
|
8836
|
-
|
|
8979
|
+
requestBundles.get(info3.id),
|
|
8980
|
+
getCurrentBundle()
|
|
8837
8981
|
]);
|
|
8838
8982
|
const baseResponse = { ...rest, fileUrl };
|
|
8839
8983
|
const manifestArtifacts = await resolveManifestArtifacts({
|
|
@@ -8886,6 +9030,36 @@ function createPluginDatabaseCore(getPlugin, resolveFileUrl, options) {
|
|
|
8886
9030
|
});
|
|
8887
9031
|
}
|
|
8888
9032
|
};
|
|
9033
|
+
Object.defineProperty(api, "diagnostics", {
|
|
9034
|
+
configurable: true,
|
|
9035
|
+
enumerable: true,
|
|
9036
|
+
get() {
|
|
9037
|
+
const diagnostics = getPlugin().diagnostics;
|
|
9038
|
+
if (!diagnostics) {
|
|
9039
|
+
Object.defineProperty(this, "diagnostics", {
|
|
9040
|
+
configurable: true,
|
|
9041
|
+
enumerable: true,
|
|
9042
|
+
value: void 0
|
|
9043
|
+
});
|
|
9044
|
+
return void 0;
|
|
9045
|
+
}
|
|
9046
|
+
const wrappedDiagnostics = {};
|
|
9047
|
+
if (diagnostics.bundleIndex) {
|
|
9048
|
+
wrappedDiagnostics.bundleIndex = {
|
|
9049
|
+
check: /* @__PURE__ */ __name((context2) => getPlugin().diagnostics.bundleIndex.check(context2), "check"),
|
|
9050
|
+
...diagnostics.bundleIndex.repair ? {
|
|
9051
|
+
repair: /* @__PURE__ */ __name((context2) => getPlugin().diagnostics.bundleIndex.repair(context2), "repair")
|
|
9052
|
+
} : {}
|
|
9053
|
+
};
|
|
9054
|
+
}
|
|
9055
|
+
Object.defineProperty(this, "diagnostics", {
|
|
9056
|
+
configurable: true,
|
|
9057
|
+
enumerable: true,
|
|
9058
|
+
value: wrappedDiagnostics
|
|
9059
|
+
});
|
|
9060
|
+
return wrappedDiagnostics;
|
|
9061
|
+
}
|
|
9062
|
+
});
|
|
8889
9063
|
return {
|
|
8890
9064
|
api,
|
|
8891
9065
|
adapterName: getPlugin().name,
|
|
@@ -9022,7 +9196,7 @@ init_performance2();
|
|
|
9022
9196
|
// ../../packages/server/package.json
|
|
9023
9197
|
var package_default = {
|
|
9024
9198
|
name: "@hot-updater/server",
|
|
9025
|
-
version: "0.
|
|
9199
|
+
version: "0.33.0",
|
|
9026
9200
|
type: "module",
|
|
9027
9201
|
description: "React Native OTA solution for self-hosted",
|
|
9028
9202
|
sideEffects: false,
|
|
@@ -9120,6 +9294,8 @@ var HandlerBadRequestError = class extends Error {
|
|
|
9120
9294
|
};
|
|
9121
9295
|
var SDK_VERSION_HEADER = "Hot-Updater-SDK-Version";
|
|
9122
9296
|
var EXPLICIT_NO_UPDATE_MIN_SDK_VERSION = "0.31.0";
|
|
9297
|
+
var DEFAULT_BUNDLE_LIST_LIMIT = 50;
|
|
9298
|
+
var MAX_BUNDLE_LIST_LIMIT = 100;
|
|
9123
9299
|
var supportsExplicitNoUpdateResponse = /* @__PURE__ */ __name((request) => {
|
|
9124
9300
|
const sdkVersion = request.headers.get(SDK_VERSION_HEADER)?.trim();
|
|
9125
9301
|
if (!sdkVersion) {
|
|
@@ -9187,6 +9363,19 @@ var parseStringArraySearchParam = /* @__PURE__ */ __name((url, key) => {
|
|
|
9187
9363
|
const values = url.searchParams.getAll(key);
|
|
9188
9364
|
return values.length > 0 ? values : void 0;
|
|
9189
9365
|
}, "parseStringArraySearchParam");
|
|
9366
|
+
var parsePositiveIntegerSearchParam = /* @__PURE__ */ __name((url, key, defaultValue, maxValue) => {
|
|
9367
|
+
const value = url.searchParams.get(key);
|
|
9368
|
+
if (value === null) {
|
|
9369
|
+
return defaultValue;
|
|
9370
|
+
}
|
|
9371
|
+
const parsed = Number(value);
|
|
9372
|
+
if (!Number.isInteger(parsed) || parsed < 1 || parsed > maxValue) {
|
|
9373
|
+
throw new HandlerBadRequestError(
|
|
9374
|
+
`The '${key}' query parameter must be a positive integer between 1 and ${maxValue}.`
|
|
9375
|
+
);
|
|
9376
|
+
}
|
|
9377
|
+
return parsed;
|
|
9378
|
+
}, "parsePositiveIntegerSearchParam");
|
|
9190
9379
|
var requirePlatformParam = /* @__PURE__ */ __name((params) => {
|
|
9191
9380
|
const platform2 = requireRouteParam(params, "platform");
|
|
9192
9381
|
if (!isPlatform(platform2)) {
|
|
@@ -9271,7 +9460,12 @@ var handleGetBundles = /* @__PURE__ */ __name(async (_params, request, api, cont
|
|
|
9271
9460
|
const url = new URL(request.url);
|
|
9272
9461
|
const channel2 = url.searchParams.get("channel") ?? void 0;
|
|
9273
9462
|
const platform2 = url.searchParams.get("platform");
|
|
9274
|
-
const limit =
|
|
9463
|
+
const limit = parsePositiveIntegerSearchParam(
|
|
9464
|
+
url,
|
|
9465
|
+
"limit",
|
|
9466
|
+
DEFAULT_BUNDLE_LIST_LIMIT,
|
|
9467
|
+
MAX_BUNDLE_LIST_LIMIT
|
|
9468
|
+
);
|
|
9275
9469
|
const pageParam = url.searchParams.get("page");
|
|
9276
9470
|
const offset = url.searchParams.get("offset");
|
|
9277
9471
|
const after = url.searchParams.get("after") ?? void 0;
|
|
@@ -9407,14 +9601,13 @@ var routes = {
|
|
|
9407
9601
|
};
|
|
9408
9602
|
function createHandler(api, options = {}) {
|
|
9409
9603
|
const basePath = options.basePath ?? "/api";
|
|
9410
|
-
const
|
|
9411
|
-
|
|
9412
|
-
|
|
9604
|
+
const routeOptions = {
|
|
9605
|
+
updateCheck: options.routes?.updateCheck ?? true,
|
|
9606
|
+
bundles: options.routes?.bundles ?? false
|
|
9607
|
+
};
|
|
9413
9608
|
const router = createRouter();
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
}
|
|
9417
|
-
if (updateCheckEnabled) {
|
|
9609
|
+
addRoute(router, "GET", "/version", "version");
|
|
9610
|
+
if (routeOptions.updateCheck) {
|
|
9418
9611
|
addRoute(
|
|
9419
9612
|
router,
|
|
9420
9613
|
"GET",
|
|
@@ -9440,7 +9633,7 @@ function createHandler(api, options = {}) {
|
|
|
9440
9633
|
"appVersionUpdateWithCohort"
|
|
9441
9634
|
);
|
|
9442
9635
|
}
|
|
9443
|
-
if (
|
|
9636
|
+
if (routeOptions.bundles) {
|
|
9444
9637
|
addRoute(router, "GET", "/api/bundles/channels", "getChannels");
|
|
9445
9638
|
addRoute(router, "GET", "/api/bundles/:id", "getBundle");
|
|
9446
9639
|
addRoute(router, "GET", "/api/bundles", "getBundles");
|
|
@@ -9461,7 +9654,8 @@ function createHandler(api, options = {}) {
|
|
|
9461
9654
|
headers: { "Content-Type": "application/json" }
|
|
9462
9655
|
});
|
|
9463
9656
|
}
|
|
9464
|
-
const
|
|
9657
|
+
const routeName = match2.data;
|
|
9658
|
+
const handler = routes[routeName];
|
|
9465
9659
|
if (!handler) {
|
|
9466
9660
|
return new Response(JSON.stringify({ error: "Handler not found" }), {
|
|
9467
9661
|
status: 500,
|
|
@@ -9594,25 +9788,23 @@ function createHotUpdater(options) {
|
|
|
9594
9788
|
readStorageText
|
|
9595
9789
|
} : { readStorageText }
|
|
9596
9790
|
);
|
|
9597
|
-
const
|
|
9598
|
-
|
|
9599
|
-
|
|
9600
|
-
|
|
9601
|
-
routes: options.routes
|
|
9602
|
-
}),
|
|
9603
|
-
adapterName: core.adapterName
|
|
9604
|
-
};
|
|
9791
|
+
const internalHandler = createHandler(core.api, {
|
|
9792
|
+
basePath,
|
|
9793
|
+
routes: options.routes
|
|
9794
|
+
});
|
|
9605
9795
|
const handler = /* @__PURE__ */ __name((request, context2, ...extraArgs) => {
|
|
9606
9796
|
if (extraArgs.length > 0) {
|
|
9607
|
-
return
|
|
9797
|
+
return internalHandler(request);
|
|
9608
9798
|
}
|
|
9609
|
-
return
|
|
9799
|
+
return internalHandler(request, context2);
|
|
9610
9800
|
}, "handler");
|
|
9611
|
-
|
|
9612
|
-
...api,
|
|
9801
|
+
const api = {
|
|
9613
9802
|
basePath,
|
|
9803
|
+
adapterName: core.adapterName,
|
|
9614
9804
|
handler
|
|
9615
9805
|
};
|
|
9806
|
+
Object.defineProperties(api, Object.getOwnPropertyDescriptors(core.api));
|
|
9807
|
+
return api;
|
|
9616
9808
|
}
|
|
9617
9809
|
__name(createHotUpdater, "createHotUpdater");
|
|
9618
9810
|
|
|
@@ -11816,6 +12008,13 @@ init_performance2();
|
|
|
11816
12008
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_process();
|
|
11817
12009
|
init_virtual_unenv_global_polyfill_cloudflare_unenv_preset_node_console();
|
|
11818
12010
|
init_performance2();
|
|
12011
|
+
var buildJsonEachInClause = /* @__PURE__ */ __name((columnName, values, params) => {
|
|
12012
|
+
if (values.length === 0) {
|
|
12013
|
+
return "1 = 0";
|
|
12014
|
+
}
|
|
12015
|
+
params.push(JSON.stringify(values));
|
|
12016
|
+
return `${columnName} IN (SELECT value FROM json_each(?))`;
|
|
12017
|
+
}, "buildJsonEachInClause");
|
|
11819
12018
|
function buildWhereClause(conditions) {
|
|
11820
12019
|
if (!conditions) {
|
|
11821
12020
|
return { sql: "", params: [] };
|
|
@@ -11835,12 +12034,7 @@ function buildWhereClause(conditions) {
|
|
|
11835
12034
|
params.push(conditions.enabled ? 1 : 0);
|
|
11836
12035
|
}
|
|
11837
12036
|
if (conditions.id?.in) {
|
|
11838
|
-
|
|
11839
|
-
clauses.push("1 = 0");
|
|
11840
|
-
} else {
|
|
11841
|
-
clauses.push(`id IN (${conditions.id.in.map(() => "?").join(", ")})`);
|
|
11842
|
-
params.push(...conditions.id.in);
|
|
11843
|
-
}
|
|
12037
|
+
clauses.push(buildJsonEachInClause("id", conditions.id.in, params));
|
|
11844
12038
|
}
|
|
11845
12039
|
if (conditions.id?.eq) {
|
|
11846
12040
|
clauses.push("id = ?");
|
|
@@ -11874,14 +12068,13 @@ function buildWhereClause(conditions) {
|
|
|
11874
12068
|
}
|
|
11875
12069
|
}
|
|
11876
12070
|
if (conditions.targetAppVersionIn) {
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
)
|
|
11883
|
-
|
|
11884
|
-
}
|
|
12071
|
+
clauses.push(
|
|
12072
|
+
buildJsonEachInClause(
|
|
12073
|
+
"target_app_version",
|
|
12074
|
+
conditions.targetAppVersionIn,
|
|
12075
|
+
params
|
|
12076
|
+
)
|
|
12077
|
+
);
|
|
11885
12078
|
}
|
|
11886
12079
|
if (conditions.fingerprintHash !== void 0) {
|
|
11887
12080
|
if (conditions.fingerprintHash === null) {
|
|
@@ -11998,15 +12191,14 @@ var d1WorkerDatabase = /* @__PURE__ */ __name(() => createDatabasePlugin({
|
|
|
11998
12191
|
if (bundleIds.length === 0) {
|
|
11999
12192
|
return patchMap;
|
|
12000
12193
|
}
|
|
12001
|
-
const placeholders = bundleIds.map(() => "?").join(", ");
|
|
12002
12194
|
const rows = await queryAll(
|
|
12003
12195
|
`
|
|
12004
12196
|
SELECT *
|
|
12005
12197
|
FROM bundle_patches
|
|
12006
|
-
WHERE bundle_id IN (
|
|
12198
|
+
WHERE bundle_id IN (SELECT value FROM json_each(?))
|
|
12007
12199
|
ORDER BY order_index ASC, base_bundle_id ASC
|
|
12008
12200
|
`,
|
|
12009
|
-
bundleIds,
|
|
12201
|
+
[JSON.stringify(bundleIds)],
|
|
12010
12202
|
context2
|
|
12011
12203
|
);
|
|
12012
12204
|
for (const row of rows) {
|
|
@@ -12318,7 +12510,6 @@ var hotUpdater = createHotUpdater({
|
|
|
12318
12510
|
basePath: HOT_UPDATER_BASE_PATH,
|
|
12319
12511
|
routes: {
|
|
12320
12512
|
updateCheck: true,
|
|
12321
|
-
version: true,
|
|
12322
12513
|
bundles: false
|
|
12323
12514
|
}
|
|
12324
12515
|
});
|