@hot-updater/firebase 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.
@@ -6,7 +6,7 @@ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames$1 = Object.getOwnPropertyNames;
7
7
  var __getProtoOf$1 = Object.getPrototypeOf;
8
8
  var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
9
- var __commonJSMin$1 = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ var __commonJSMin$1 = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
10
  var __copyProps$1 = (to, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$1(from), i = 0, n = keys.length, key; i < n; i++) {
12
12
  key = keys[i];
@@ -24,15 +24,15 @@ var __toESM$1 = (mod, isNodeMode, target) => (target = mod != null ? __create$1(
24
24
  //#endregion
25
25
  let _hot_updater_server_runtime = require("@hot-updater/server/runtime");
26
26
  let firebase_admin = require("firebase-admin");
27
- firebase_admin = __toESM$1(firebase_admin, 1);
27
+ firebase_admin = __toESM$1(firebase_admin);
28
28
  let firebase_functions_v2_https = require("firebase-functions/v2/https");
29
29
  let hono = require("hono");
30
30
  let node_path = require("node:path");
31
- node_path = __toESM$1(node_path, 1);
31
+ node_path = __toESM$1(node_path);
32
32
  let fs_promises = require("fs/promises");
33
- fs_promises = __toESM$1(fs_promises, 1);
33
+ fs_promises = __toESM$1(fs_promises);
34
34
  let path = require("path");
35
- path = __toESM$1(path, 1);
35
+ path = __toESM$1(path);
36
36
  //#region ../../packages/core/dist/index.mjs
37
37
  const stripBundleArtifactMetadata = (metadata) => metadata;
38
38
  const getManifestStorageUri = (bundle) => bundle.manifestStorageUri ?? null;
@@ -2891,7 +2891,6 @@ var require_min_version$1 = /* @__PURE__ */ __commonJSMin$1(((exports, module) =
2891
2891
  break;
2892
2892
  case "<":
2893
2893
  case "<=": break;
2894
- /* istanbul ignore next */
2895
2894
  default: throw new Error(`Unexpected operation: ${comparator.operator}`);
2896
2895
  }
2897
2896
  });
@@ -3192,6 +3191,20 @@ const filterCompatibleAppVersions = (targetAppVersionList, currentVersion) => {
3192
3191
  return targetAppVersionList.filter((version) => semverSatisfies$1(version, currentVersion)).sort((a, b) => b.localeCompare(a));
3193
3192
  };
3194
3193
  //#endregion
3194
+ //#region ../plugin-core/dist/requestUpdateBundleState.mjs
3195
+ const requestUpdateBundleSeeds = /* @__PURE__ */ new WeakMap();
3196
+ const isWeakMapKey = (value) => typeof value === "object" && value !== null || typeof value === "function";
3197
+ const toBundleSeeds = (seeds) => seeds.filter((seed) => !!seed);
3198
+ const seedRequestUpdateBundles = (context, seeds) => {
3199
+ if (!isWeakMapKey(context)) return;
3200
+ const nextSeeds = toBundleSeeds(seeds);
3201
+ if (nextSeeds.length === 0) return;
3202
+ const bundlesById = /* @__PURE__ */ new Map();
3203
+ for (const seed of requestUpdateBundleSeeds.get(context) ?? []) bundlesById.set(seed.id, seed);
3204
+ for (const seed of nextSeeds) bundlesById.set(seed.id, seed);
3205
+ requestUpdateBundleSeeds.set(context, [...bundlesById.values()]);
3206
+ };
3207
+ //#endregion
3195
3208
  //#region ../js/dist/index.mjs
3196
3209
  var __create = Object.create;
3197
3210
  var __defProp = Object.defineProperty;
@@ -3199,7 +3212,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3199
3212
  var __getOwnPropNames = Object.getOwnPropertyNames;
3200
3213
  var __getProtoOf = Object.getPrototypeOf;
3201
3214
  var __hasOwnProp = Object.prototype.hasOwnProperty;
3202
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
3215
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
3203
3216
  var __copyProps = (to, from, except, desc) => {
3204
3217
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
3205
3218
  key = keys[i];
@@ -4188,7 +4201,6 @@ var require_min_version = /* @__PURE__ */ __commonJSMin(((exports, module) => {
4188
4201
  break;
4189
4202
  case "<":
4190
4203
  case "<=": break;
4191
- /* istanbul ignore next */
4192
4204
  default: throw new Error(`Unexpected operation: ${comparator.operator}`);
4193
4205
  }
4194
4206
  });
@@ -4558,6 +4570,15 @@ const day = 3600 * 24;
4558
4570
  day * 7;
4559
4571
  day * 365.25;
4560
4572
  //#endregion
4573
+ //#region ../plugin-core/dist/resolveUpdateInfoFromBundles.mjs
4574
+ const findSeedBundle = (bundles, bundleId) => bundles.find((bundle) => bundle.id === bundleId);
4575
+ const resolveUpdateInfoFromBundles = async ({ args, bundles, context }) => {
4576
+ const info = await getUpdateInfo(bundles, args);
4577
+ if (!info) return null;
4578
+ seedRequestUpdateBundles(context, [findSeedBundle(bundles, info.id), args.bundleId === "00000000-0000-0000-0000-000000000000" ? null : findSeedBundle(bundles, args.bundleId)]);
4579
+ return info;
4580
+ };
4581
+ //#endregion
4561
4582
  //#region ../plugin-core/dist/createDatabasePluginGetUpdateInfo.mjs
4562
4583
  const normalizeAppVersionArgs = (args) => ({
4563
4584
  ...args,
@@ -4574,10 +4595,18 @@ const createDatabasePluginGetUpdateInfo = ({ getBundlesByFingerprint, getBundles
4574
4595
  if (args._updateStrategy === "appVersion") {
4575
4596
  const normalizedArgs = normalizeAppVersionArgs(args);
4576
4597
  const compatibleAppVersions = filterCompatibleAppVersions(await listTargetAppVersions(normalizedArgs, context), normalizedArgs.appVersion);
4577
- return getUpdateInfo(compatibleAppVersions.length > 0 ? await getBundlesByTargetAppVersions(normalizedArgs, compatibleAppVersions, context) : [], normalizedArgs);
4598
+ return resolveUpdateInfoFromBundles({
4599
+ args: normalizedArgs,
4600
+ bundles: compatibleAppVersions.length > 0 ? await getBundlesByTargetAppVersions(normalizedArgs, compatibleAppVersions, context) : [],
4601
+ context
4602
+ });
4578
4603
  }
4579
4604
  const normalizedArgs = normalizeFingerprintArgs(args);
4580
- return getUpdateInfo(await getBundlesByFingerprint(normalizedArgs, context), normalizedArgs);
4605
+ return resolveUpdateInfoFromBundles({
4606
+ args: normalizedArgs,
4607
+ bundles: await getBundlesByFingerprint(normalizedArgs, context),
4608
+ context
4609
+ });
4581
4610
  };
4582
4611
  };
4583
4612
  //#endregion
@@ -4633,6 +4662,9 @@ const createProfiledStoragePlugin = ({ createProfiles, name, profileShape, suppo
4633
4662
  async downloadFile(storageUri, filePath) {
4634
4663
  return requireNodeProfile().downloadFile(storageUri, filePath);
4635
4664
  },
4665
+ async exists(storageUri) {
4666
+ return requireNodeProfile().exists(storageUri);
4667
+ },
4636
4668
  async upload(key, filePath) {
4637
4669
  return requireNodeProfile().upload(key, filePath);
4638
4670
  }
@@ -5018,6 +5050,12 @@ const firebaseStorage = createUniversalStoragePlugin({
5018
5050
  throw error;
5019
5051
  }
5020
5052
  },
5053
+ async exists(storageUri) {
5054
+ const { bucket: bucketName, key } = parseStorageUri(storageUri, "gs");
5055
+ if (bucketName !== config.storageBucket) throw new Error(`Bucket name mismatch: expected "${config.storageBucket}", but found "${bucketName}".`);
5056
+ const [exists] = await bucket.file(key).exists();
5057
+ return exists;
5058
+ },
5021
5059
  async downloadFile(storageUri, filePath) {
5022
5060
  const { bucket: bucketName, key } = parseStorageUri(storageUri, "gs");
5023
5061
  if (bucketName !== config.storageBucket) throw new Error(`Bucket name mismatch: expected "${config.storageBucket}", but found "${bucketName}".`);
@@ -5102,7 +5140,6 @@ const hotUpdater = (0, _hot_updater_server_runtime.createHotUpdater)({
5102
5140
  basePath: HOT_UPDATER_BASE_PATH,
5103
5141
  routes: {
5104
5142
  updateCheck: true,
5105
- version: true,
5106
5143
  bundles: false
5107
5144
  }
5108
5145
  });
@@ -6,7 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
9
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
10
10
  var __copyProps = (to, from, except, desc) => {
11
11
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
12
  key = keys[i];
@@ -23,20 +23,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
23
  }) : target, mod));
24
24
  //#endregion
25
25
  let fs = require("fs");
26
- fs = __toESM(fs, 1);
26
+ fs = __toESM(fs);
27
27
  let path = require("path");
28
- path = __toESM(path, 1);
28
+ path = __toESM(path);
29
29
  let _hot_updater_cli_tools = require("@hot-updater/cli-tools");
30
30
  let node_url = require("node:url");
31
31
  let node_child_process = require("node:child_process");
32
32
  let node_string_decoder = require("node:string_decoder");
33
33
  let node_util = require("node:util");
34
34
  let node_process = require("node:process");
35
- node_process = __toESM(node_process, 1);
35
+ node_process = __toESM(node_process);
36
36
  let node_tty = require("node:tty");
37
- node_tty = __toESM(node_tty, 1);
37
+ node_tty = __toESM(node_tty);
38
38
  let node_path = require("node:path");
39
- node_path = __toESM(node_path, 1);
39
+ node_path = __toESM(node_path);
40
40
  let node_timers_promises = require("node:timers/promises");
41
41
  let node_os = require("node:os");
42
42
  let node_events = require("node:events");
@@ -46,7 +46,7 @@ let node_stream_promises = require("node:stream/promises");
46
46
  let node_stream = require("node:stream");
47
47
  let node_buffer = require("node:buffer");
48
48
  let node_fs_promises = require("node:fs/promises");
49
- node_fs_promises = __toESM(node_fs_promises, 1);
49
+ node_fs_promises = __toESM(node_fs_promises);
50
50
  //#region ../../node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/_internal/compareValues.mjs
51
51
  function compareValues(a, b, order) {
52
52
  if (a < b) return order === "asc" ? -1 : 1;
@@ -6622,10 +6622,6 @@ const initFirebaseUser = async (cwd) => {
6622
6622
  "--format=json"
6623
6623
  ], {
6624
6624
  shell: true,
6625
- /**
6626
- * API [firestore.googleapis.com] not enabled on project [xxx]. Would you
6627
- like to enable and retry (this will take a few minutes)? (y/N)?
6628
- */
6629
6625
  input: "N\n"
6630
6626
  });
6631
6627
  if (JSON.parse(databases.stdout).length === 0) {
@@ -25,7 +25,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
25
25
  var __getOwnPropNames = Object.getOwnPropertyNames;
26
26
  var __getProtoOf = Object.getPrototypeOf;
27
27
  var __hasOwnProp = Object.prototype.hasOwnProperty;
28
- var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
28
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
29
29
  var __copyProps = (to, from, except, desc) => {
30
30
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
31
31
  key = keys[i];
@@ -6617,10 +6617,6 @@ const initFirebaseUser = async (cwd) => {
6617
6617
  "--format=json"
6618
6618
  ], {
6619
6619
  shell: true,
6620
- /**
6621
- * API [firestore.googleapis.com] not enabled on project [xxx]. Would you
6622
- like to enable and retry (this will take a few minutes)? (y/N)?
6623
- */
6624
6620
  input: "N\n"
6625
6621
  });
6626
6622
  if (JSON.parse(databases.stdout).length === 0) {
package/dist/index.cjs CHANGED
@@ -24,11 +24,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  let _hot_updater_core = require("@hot-updater/core");
25
25
  let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
26
26
  let firebase_admin = require("firebase-admin");
27
- firebase_admin = __toESM(firebase_admin, 1);
27
+ firebase_admin = __toESM(firebase_admin);
28
28
  let fs_promises = require("fs/promises");
29
- fs_promises = __toESM(fs_promises, 1);
29
+ fs_promises = __toESM(fs_promises);
30
30
  let path = require("path");
31
- path = __toESM(path, 1);
31
+ path = __toESM(path);
32
32
  //#region src/firebaseDatabase.ts
33
33
  const bundleMatchesQueryWhere = (bundle, where) => {
34
34
  if (!where) return true;
@@ -322,6 +322,12 @@ const firebaseStorage = (0, _hot_updater_plugin_core.createUniversalStoragePlugi
322
322
  throw error;
323
323
  }
324
324
  },
325
+ async exists(storageUri) {
326
+ const { bucket: bucketName, key } = (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, "gs");
327
+ if (bucketName !== config.storageBucket) throw new Error(`Bucket name mismatch: expected "${config.storageBucket}", but found "${bucketName}".`);
328
+ const [exists] = await bucket.file(key).exists();
329
+ return exists;
330
+ },
325
331
  async downloadFile(storageUri, filePath) {
326
332
  const { bucket: bucketName, key } = (0, _hot_updater_plugin_core.parseStorageUri)(storageUri, "gs");
327
333
  if (bucketName !== config.storageBucket) throw new Error(`Bucket name mismatch: expected "${config.storageBucket}", but found "${bucketName}".`);
package/dist/index.d.cts CHANGED
@@ -1,7 +1,8 @@
1
+ import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
1
2
  import admin from "firebase-admin";
2
3
 
3
4
  //#region src/firebaseDatabase.d.ts
4
- declare const firebaseDatabase: (config: admin.AppOptions, hooks?: import("@hot-updater/plugin-core").DatabasePluginHooks) => () => import("@hot-updater/plugin-core").DatabasePlugin<unknown>;
5
+ declare const firebaseDatabase: (config: admin.AppOptions, hooks?: _$_hot_updater_plugin_core0.DatabasePluginHooks) => () => _$_hot_updater_plugin_core0.DatabasePlugin<unknown>;
5
6
  //#endregion
6
7
  //#region src/firebaseStorage.d.ts
7
8
  interface FirebaseStorageConfig extends admin.AppOptions {
@@ -11,6 +12,6 @@ interface FirebaseStorageConfig extends admin.AppOptions {
11
12
  */
12
13
  basePath?: string;
13
14
  }
14
- declare const firebaseStorage: (config: FirebaseStorageConfig, hooks?: import("@hot-updater/plugin-core").StoragePluginHooks) => () => import("@hot-updater/plugin-core").UniversalStoragePlugin<unknown>;
15
+ declare const firebaseStorage: (config: FirebaseStorageConfig, hooks?: _$_hot_updater_plugin_core0.StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
15
16
  //#endregion
16
17
  export { FirebaseStorageConfig, firebaseDatabase, firebaseStorage };
package/dist/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
+ import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
1
2
  import admin from "firebase-admin";
2
3
 
3
4
  //#region src/firebaseDatabase.d.ts
4
- declare const firebaseDatabase: (config: admin.AppOptions, hooks?: import("@hot-updater/plugin-core").DatabasePluginHooks) => () => import("@hot-updater/plugin-core").DatabasePlugin<unknown>;
5
+ declare const firebaseDatabase: (config: admin.AppOptions, hooks?: _$_hot_updater_plugin_core0.DatabasePluginHooks) => () => _$_hot_updater_plugin_core0.DatabasePlugin<unknown>;
5
6
  //#endregion
6
7
  //#region src/firebaseStorage.d.ts
7
8
  interface FirebaseStorageConfig extends admin.AppOptions {
@@ -11,6 +12,6 @@ interface FirebaseStorageConfig extends admin.AppOptions {
11
12
  */
12
13
  basePath?: string;
13
14
  }
14
- declare const firebaseStorage: (config: FirebaseStorageConfig, hooks?: import("@hot-updater/plugin-core").StoragePluginHooks) => () => import("@hot-updater/plugin-core").UniversalStoragePlugin<unknown>;
15
+ declare const firebaseStorage: (config: FirebaseStorageConfig, hooks?: _$_hot_updater_plugin_core0.StoragePluginHooks) => () => _$_hot_updater_plugin_core0.UniversalStoragePlugin<unknown>;
15
16
  //#endregion
16
17
  export { FirebaseStorageConfig, firebaseDatabase, firebaseStorage };
package/dist/index.mjs CHANGED
@@ -296,6 +296,12 @@ const firebaseStorage = createUniversalStoragePlugin({
296
296
  throw error;
297
297
  }
298
298
  },
299
+ async exists(storageUri) {
300
+ const { bucket: bucketName, key } = parseStorageUri(storageUri, "gs");
301
+ if (bucketName !== config.storageBucket) throw new Error(`Bucket name mismatch: expected "${config.storageBucket}", but found "${bucketName}".`);
302
+ const [exists] = await bucket.file(key).exists();
303
+ return exists;
304
+ },
299
305
  async downloadFile(storageUri, filePath) {
300
306
  const { bucket: bucketName, key } = parseStorageUri(storageUri, "gs");
301
307
  if (bucketName !== config.storageBucket) throw new Error(`Bucket name mismatch: expected "${config.storageBucket}", but found "${bucketName}".`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/firebase",
3
3
  "type": "module",
4
- "version": "0.31.4",
4
+ "version": "0.33.0",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "main": "dist/index.cjs",
7
7
  "types": "dist/index.d.cts",
@@ -36,10 +36,10 @@
36
36
  "dependencies": {
37
37
  "firebase": "^11.3.1",
38
38
  "hono": "4.12.9",
39
- "@hot-updater/plugin-core": "0.31.4",
40
- "@hot-updater/core": "0.31.4",
41
- "@hot-updater/server": "0.31.4",
42
- "@hot-updater/cli-tools": "0.31.4"
39
+ "@hot-updater/cli-tools": "0.33.0",
40
+ "@hot-updater/core": "0.33.0",
41
+ "@hot-updater/plugin-core": "0.33.0",
42
+ "@hot-updater/server": "0.33.0"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"
@@ -54,9 +54,9 @@
54
54
  "firebase-tools": "^13.32.0",
55
55
  "fkill": "^9.0.0",
56
56
  "mime": "^4.0.4",
57
- "@hot-updater/js": "0.31.4",
58
- "@hot-updater/mock": "0.31.4",
59
- "@hot-updater/test-utils": "0.31.4"
57
+ "@hot-updater/js": "0.33.0",
58
+ "@hot-updater/mock": "0.33.0",
59
+ "@hot-updater/test-utils": "0.33.0"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "firebase-admin": "*",