@hot-updater/standalone 0.30.11 → 0.31.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/index.cjs +102 -52
- package/dist/index.d.cts +3 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +102 -52
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -57,6 +57,24 @@ const isRecord = (value) => typeof value === "object" && value !== null;
|
|
|
57
57
|
const isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
58
58
|
const isPaginatedResult = (value) => isRecord(value) && Array.isArray(value.data) && isRecord(value.pagination);
|
|
59
59
|
const hasDataChannels = (value) => isRecord(value) && isRecord(value.data) && isStringArray(value.data.channels);
|
|
60
|
+
const setBooleanSearchParam = (url, key, value) => {
|
|
61
|
+
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
62
|
+
};
|
|
63
|
+
const setNullableStringSearchParam = (url, key, value) => {
|
|
64
|
+
if (value !== void 0) url.searchParams.set(key, value === null ? "null" : value);
|
|
65
|
+
};
|
|
66
|
+
const appendStringArraySearchParams = (url, key, values) => {
|
|
67
|
+
for (const value of values ?? []) url.searchParams.append(key, value);
|
|
68
|
+
};
|
|
69
|
+
const setBundleIdFilterSearchParams = (url, filter) => {
|
|
70
|
+
if (!filter) return;
|
|
71
|
+
if (filter.eq !== void 0) url.searchParams.set("idEq", filter.eq);
|
|
72
|
+
if (filter.gt !== void 0) url.searchParams.set("idGt", filter.gt);
|
|
73
|
+
if (filter.gte !== void 0) url.searchParams.set("idGte", filter.gte);
|
|
74
|
+
if (filter.lt !== void 0) url.searchParams.set("idLt", filter.lt);
|
|
75
|
+
if (filter.lte !== void 0) url.searchParams.set("idLte", filter.lte);
|
|
76
|
+
appendStringArraySearchParams(url, "idIn", filter.in);
|
|
77
|
+
};
|
|
60
78
|
const standaloneRepository = (0, _hot_updater_plugin_core.createDatabasePlugin)({
|
|
61
79
|
name: "standalone-repository",
|
|
62
80
|
factory: (config) => {
|
|
@@ -106,6 +124,12 @@ const standaloneRepository = (0, _hot_updater_plugin_core.createDatabasePlugin)(
|
|
|
106
124
|
const resolvedPage = page ?? (internalOffset !== void 0 && limit > 0 ? Math.floor(internalOffset / limit) + 1 : void 0);
|
|
107
125
|
if (where?.channel !== void 0) url.searchParams.set("channel", where.channel);
|
|
108
126
|
if (where?.platform !== void 0) url.searchParams.set("platform", where.platform);
|
|
127
|
+
setBooleanSearchParam(url, "enabled", where?.enabled);
|
|
128
|
+
setBundleIdFilterSearchParams(url, where?.id);
|
|
129
|
+
setNullableStringSearchParam(url, "targetAppVersion", where?.targetAppVersion);
|
|
130
|
+
appendStringArraySearchParams(url, "targetAppVersionIn", where?.targetAppVersionIn);
|
|
131
|
+
setBooleanSearchParam(url, "targetAppVersionNotNull", where?.targetAppVersionNotNull);
|
|
132
|
+
setNullableStringSearchParam(url, "fingerprintHash", where?.fingerprintHash);
|
|
109
133
|
if (limit !== void 0) url.searchParams.set("limit", String(limit));
|
|
110
134
|
if (resolvedPage !== void 0) url.searchParams.set("page", String(resolvedPage));
|
|
111
135
|
if (cursor?.after !== void 0) url.searchParams.set("after", cursor.after);
|
|
@@ -1473,6 +1497,7 @@ var import_mime = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expor
|
|
|
1473
1497
|
const defaultRoutes = {
|
|
1474
1498
|
upload: (_key, _filePath) => ({ path: "/upload" }),
|
|
1475
1499
|
delete: (_storageUri) => ({ path: "/delete" }),
|
|
1500
|
+
readText: (_storageUri) => ({ path: "/readText" }),
|
|
1476
1501
|
getDownloadUrl: (_storageUri) => ({ path: "/getDownloadUrl" })
|
|
1477
1502
|
};
|
|
1478
1503
|
const createRoute = (defaultRoute, customRoute) => ({
|
|
@@ -1486,6 +1511,7 @@ const standaloneStorage = (config, hooks) => () => {
|
|
|
1486
1511
|
const routes = {
|
|
1487
1512
|
upload: (key, filePath) => createRoute(defaultRoutes.upload(key, filePath), config.routes?.upload?.(key, filePath)),
|
|
1488
1513
|
delete: (storageUri) => createRoute(defaultRoutes.delete(storageUri), config.routes?.delete?.(storageUri)),
|
|
1514
|
+
readText: (storageUri) => createRoute(defaultRoutes.readText(storageUri), config.routes?.readText?.(storageUri)),
|
|
1489
1515
|
getDownloadUrl: (storageUri) => createRoute(defaultRoutes.getDownloadUrl(storageUri), config.routes?.getDownloadUrl?.(storageUri))
|
|
1490
1516
|
};
|
|
1491
1517
|
const getHeaders = (routeHeaders) => ({
|
|
@@ -1495,61 +1521,85 @@ const standaloneStorage = (config, hooks) => () => {
|
|
|
1495
1521
|
return {
|
|
1496
1522
|
name: "standaloneStorage",
|
|
1497
1523
|
supportedProtocol: "http",
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1524
|
+
profiles: {
|
|
1525
|
+
node: {
|
|
1526
|
+
async delete(storageUri) {
|
|
1527
|
+
const { path: routePath, headers: routeHeaders } = routes.delete(storageUri);
|
|
1528
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1529
|
+
method: "DELETE",
|
|
1530
|
+
headers: getHeaders(routeHeaders),
|
|
1531
|
+
body: JSON.stringify({ storageUri })
|
|
1532
|
+
});
|
|
1533
|
+
if (!response.ok) {
|
|
1534
|
+
const error = /* @__PURE__ */ new Error(`Failed to delete bundle: ${response.statusText}`);
|
|
1535
|
+
console.error(error);
|
|
1536
|
+
throw error;
|
|
1537
|
+
}
|
|
1538
|
+
},
|
|
1539
|
+
async upload(key, filePath) {
|
|
1540
|
+
const fileContent = await fs_promises.default.readFile(filePath);
|
|
1541
|
+
const contentType = import_mime.default.getType(filePath) ?? "application/octet-stream";
|
|
1542
|
+
const filename = path.default.basename(filePath);
|
|
1543
|
+
const { path: routePath, headers: routeHeaders } = routes.upload(key, filePath);
|
|
1544
|
+
const formData = new FormData();
|
|
1545
|
+
formData.append("file", new Blob([fileContent], { type: contentType }), filename);
|
|
1546
|
+
formData.append("key", key);
|
|
1547
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1548
|
+
method: "POST",
|
|
1549
|
+
headers: getHeaders(routeHeaders),
|
|
1550
|
+
body: formData
|
|
1551
|
+
});
|
|
1552
|
+
if (!response.ok) {
|
|
1553
|
+
const error = `Failed to upload bundle: ${response.statusText}`;
|
|
1554
|
+
console.error(`[upload] ${error}`);
|
|
1555
|
+
throw new Error(error);
|
|
1556
|
+
}
|
|
1557
|
+
const result = await response.json();
|
|
1558
|
+
if (!result.storageUri) {
|
|
1559
|
+
const error = "Failed to upload bundle - no storageUri in response";
|
|
1560
|
+
console.error(`[upload] ${error}`);
|
|
1561
|
+
throw new Error(error);
|
|
1562
|
+
}
|
|
1563
|
+
await hooks?.onStorageUploaded?.();
|
|
1564
|
+
return { storageUri: result.storageUri };
|
|
1565
|
+
},
|
|
1566
|
+
async downloadFile(storageUri, filePath) {
|
|
1567
|
+
const { fileUrl } = await getDownloadUrl(storageUri);
|
|
1568
|
+
const response = await fetch(fileUrl);
|
|
1569
|
+
if (!response.ok) throw new Error(`Failed to download bundle: ${response.statusText}`);
|
|
1570
|
+
await fs_promises.default.mkdir(path.default.dirname(filePath), { recursive: true });
|
|
1571
|
+
await fs_promises.default.writeFile(filePath, new Uint8Array(await response.arrayBuffer()));
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
runtime: {
|
|
1575
|
+
async readText(storageUri) {
|
|
1576
|
+
const { path: routePath, headers: routeHeaders } = routes.readText(storageUri);
|
|
1577
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1578
|
+
method: "POST",
|
|
1579
|
+
headers: getHeaders(routeHeaders),
|
|
1580
|
+
body: JSON.stringify({ storageUri })
|
|
1581
|
+
});
|
|
1582
|
+
if (!response.ok) return null;
|
|
1583
|
+
return response.text();
|
|
1584
|
+
},
|
|
1585
|
+
getDownloadUrl
|
|
1549
1586
|
}
|
|
1550
|
-
return { fileUrl: (await response.json()).fileUrl };
|
|
1551
1587
|
}
|
|
1552
1588
|
};
|
|
1589
|
+
async function getDownloadUrl(storageUri) {
|
|
1590
|
+
const { path: routePath, headers: routeHeaders } = routes.getDownloadUrl(storageUri);
|
|
1591
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1592
|
+
method: "POST",
|
|
1593
|
+
headers: getHeaders(routeHeaders),
|
|
1594
|
+
body: JSON.stringify({ storageUri })
|
|
1595
|
+
});
|
|
1596
|
+
if (!response.ok) {
|
|
1597
|
+
const error = /* @__PURE__ */ new Error(`Failed to get download URL: ${response.statusText}`);
|
|
1598
|
+
console.error(error);
|
|
1599
|
+
throw error;
|
|
1600
|
+
}
|
|
1601
|
+
return { fileUrl: (await response.json()).fileUrl };
|
|
1602
|
+
}
|
|
1553
1603
|
};
|
|
1554
1604
|
//#endregion
|
|
1555
1605
|
exports.standaloneRepository = standaloneRepository;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
|
|
2
|
-
import {
|
|
2
|
+
import { StoragePluginHooks, UniversalStoragePlugin } from "@hot-updater/plugin-core";
|
|
3
3
|
|
|
4
4
|
//#region src/standaloneRepository.d.ts
|
|
5
5
|
interface RouteConfig {
|
|
@@ -25,6 +25,7 @@ declare const standaloneRepository: (config: StandaloneRepositoryConfig, hooks?:
|
|
|
25
25
|
interface StorageRoutes {
|
|
26
26
|
upload: (key: string, filePath: string) => RouteConfig;
|
|
27
27
|
delete: (storageUri: string) => RouteConfig;
|
|
28
|
+
readText: (storageUri: string) => RouteConfig;
|
|
28
29
|
getDownloadUrl: (storageUri: string) => RouteConfig;
|
|
29
30
|
}
|
|
30
31
|
interface StandaloneStorageConfig {
|
|
@@ -32,6 +33,6 @@ interface StandaloneStorageConfig {
|
|
|
32
33
|
commonHeaders?: Record<string, string>;
|
|
33
34
|
routes?: StorageRoutes;
|
|
34
35
|
}
|
|
35
|
-
declare const standaloneStorage: (config: StandaloneStorageConfig, hooks?: StoragePluginHooks) => () =>
|
|
36
|
+
declare const standaloneStorage: (config: StandaloneStorageConfig, hooks?: StoragePluginHooks) => () => UniversalStoragePlugin;
|
|
36
37
|
//#endregion
|
|
37
38
|
export { RouteConfig, Routes, StandaloneRepositoryConfig, StandaloneStorageConfig, StorageRoutes, standaloneRepository, standaloneStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _$_hot_updater_plugin_core0 from "@hot-updater/plugin-core";
|
|
2
|
-
import {
|
|
2
|
+
import { StoragePluginHooks, UniversalStoragePlugin } from "@hot-updater/plugin-core";
|
|
3
3
|
|
|
4
4
|
//#region src/standaloneRepository.d.ts
|
|
5
5
|
interface RouteConfig {
|
|
@@ -25,6 +25,7 @@ declare const standaloneRepository: (config: StandaloneRepositoryConfig, hooks?:
|
|
|
25
25
|
interface StorageRoutes {
|
|
26
26
|
upload: (key: string, filePath: string) => RouteConfig;
|
|
27
27
|
delete: (storageUri: string) => RouteConfig;
|
|
28
|
+
readText: (storageUri: string) => RouteConfig;
|
|
28
29
|
getDownloadUrl: (storageUri: string) => RouteConfig;
|
|
29
30
|
}
|
|
30
31
|
interface StandaloneStorageConfig {
|
|
@@ -32,6 +33,6 @@ interface StandaloneStorageConfig {
|
|
|
32
33
|
commonHeaders?: Record<string, string>;
|
|
33
34
|
routes?: StorageRoutes;
|
|
34
35
|
}
|
|
35
|
-
declare const standaloneStorage: (config: StandaloneStorageConfig, hooks?: StoragePluginHooks) => () =>
|
|
36
|
+
declare const standaloneStorage: (config: StandaloneStorageConfig, hooks?: StoragePluginHooks) => () => UniversalStoragePlugin;
|
|
36
37
|
//#endregion
|
|
37
38
|
export { RouteConfig, Routes, StandaloneRepositoryConfig, StandaloneStorageConfig, StorageRoutes, standaloneRepository, standaloneStorage };
|
package/dist/index.mjs
CHANGED
|
@@ -54,6 +54,24 @@ const isRecord = (value) => typeof value === "object" && value !== null;
|
|
|
54
54
|
const isStringArray = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
55
55
|
const isPaginatedResult = (value) => isRecord(value) && Array.isArray(value.data) && isRecord(value.pagination);
|
|
56
56
|
const hasDataChannels = (value) => isRecord(value) && isRecord(value.data) && isStringArray(value.data.channels);
|
|
57
|
+
const setBooleanSearchParam = (url, key, value) => {
|
|
58
|
+
if (value !== void 0) url.searchParams.set(key, String(value));
|
|
59
|
+
};
|
|
60
|
+
const setNullableStringSearchParam = (url, key, value) => {
|
|
61
|
+
if (value !== void 0) url.searchParams.set(key, value === null ? "null" : value);
|
|
62
|
+
};
|
|
63
|
+
const appendStringArraySearchParams = (url, key, values) => {
|
|
64
|
+
for (const value of values ?? []) url.searchParams.append(key, value);
|
|
65
|
+
};
|
|
66
|
+
const setBundleIdFilterSearchParams = (url, filter) => {
|
|
67
|
+
if (!filter) return;
|
|
68
|
+
if (filter.eq !== void 0) url.searchParams.set("idEq", filter.eq);
|
|
69
|
+
if (filter.gt !== void 0) url.searchParams.set("idGt", filter.gt);
|
|
70
|
+
if (filter.gte !== void 0) url.searchParams.set("idGte", filter.gte);
|
|
71
|
+
if (filter.lt !== void 0) url.searchParams.set("idLt", filter.lt);
|
|
72
|
+
if (filter.lte !== void 0) url.searchParams.set("idLte", filter.lte);
|
|
73
|
+
appendStringArraySearchParams(url, "idIn", filter.in);
|
|
74
|
+
};
|
|
57
75
|
const standaloneRepository = createDatabasePlugin({
|
|
58
76
|
name: "standalone-repository",
|
|
59
77
|
factory: (config) => {
|
|
@@ -103,6 +121,12 @@ const standaloneRepository = createDatabasePlugin({
|
|
|
103
121
|
const resolvedPage = page ?? (internalOffset !== void 0 && limit > 0 ? Math.floor(internalOffset / limit) + 1 : void 0);
|
|
104
122
|
if (where?.channel !== void 0) url.searchParams.set("channel", where.channel);
|
|
105
123
|
if (where?.platform !== void 0) url.searchParams.set("platform", where.platform);
|
|
124
|
+
setBooleanSearchParam(url, "enabled", where?.enabled);
|
|
125
|
+
setBundleIdFilterSearchParams(url, where?.id);
|
|
126
|
+
setNullableStringSearchParam(url, "targetAppVersion", where?.targetAppVersion);
|
|
127
|
+
appendStringArraySearchParams(url, "targetAppVersionIn", where?.targetAppVersionIn);
|
|
128
|
+
setBooleanSearchParam(url, "targetAppVersionNotNull", where?.targetAppVersionNotNull);
|
|
129
|
+
setNullableStringSearchParam(url, "fingerprintHash", where?.fingerprintHash);
|
|
106
130
|
if (limit !== void 0) url.searchParams.set("limit", String(limit));
|
|
107
131
|
if (resolvedPage !== void 0) url.searchParams.set("page", String(resolvedPage));
|
|
108
132
|
if (cursor?.after !== void 0) url.searchParams.set("after", cursor.after);
|
|
@@ -1470,6 +1494,7 @@ var import_mime = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expor
|
|
|
1470
1494
|
const defaultRoutes = {
|
|
1471
1495
|
upload: (_key, _filePath) => ({ path: "/upload" }),
|
|
1472
1496
|
delete: (_storageUri) => ({ path: "/delete" }),
|
|
1497
|
+
readText: (_storageUri) => ({ path: "/readText" }),
|
|
1473
1498
|
getDownloadUrl: (_storageUri) => ({ path: "/getDownloadUrl" })
|
|
1474
1499
|
};
|
|
1475
1500
|
const createRoute = (defaultRoute, customRoute) => ({
|
|
@@ -1483,6 +1508,7 @@ const standaloneStorage = (config, hooks) => () => {
|
|
|
1483
1508
|
const routes = {
|
|
1484
1509
|
upload: (key, filePath) => createRoute(defaultRoutes.upload(key, filePath), config.routes?.upload?.(key, filePath)),
|
|
1485
1510
|
delete: (storageUri) => createRoute(defaultRoutes.delete(storageUri), config.routes?.delete?.(storageUri)),
|
|
1511
|
+
readText: (storageUri) => createRoute(defaultRoutes.readText(storageUri), config.routes?.readText?.(storageUri)),
|
|
1486
1512
|
getDownloadUrl: (storageUri) => createRoute(defaultRoutes.getDownloadUrl(storageUri), config.routes?.getDownloadUrl?.(storageUri))
|
|
1487
1513
|
};
|
|
1488
1514
|
const getHeaders = (routeHeaders) => ({
|
|
@@ -1492,61 +1518,85 @@ const standaloneStorage = (config, hooks) => () => {
|
|
|
1492
1518
|
return {
|
|
1493
1519
|
name: "standaloneStorage",
|
|
1494
1520
|
supportedProtocol: "http",
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1521
|
+
profiles: {
|
|
1522
|
+
node: {
|
|
1523
|
+
async delete(storageUri) {
|
|
1524
|
+
const { path: routePath, headers: routeHeaders } = routes.delete(storageUri);
|
|
1525
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1526
|
+
method: "DELETE",
|
|
1527
|
+
headers: getHeaders(routeHeaders),
|
|
1528
|
+
body: JSON.stringify({ storageUri })
|
|
1529
|
+
});
|
|
1530
|
+
if (!response.ok) {
|
|
1531
|
+
const error = /* @__PURE__ */ new Error(`Failed to delete bundle: ${response.statusText}`);
|
|
1532
|
+
console.error(error);
|
|
1533
|
+
throw error;
|
|
1534
|
+
}
|
|
1535
|
+
},
|
|
1536
|
+
async upload(key, filePath) {
|
|
1537
|
+
const fileContent = await fs.readFile(filePath);
|
|
1538
|
+
const contentType = import_mime.default.getType(filePath) ?? "application/octet-stream";
|
|
1539
|
+
const filename = path.basename(filePath);
|
|
1540
|
+
const { path: routePath, headers: routeHeaders } = routes.upload(key, filePath);
|
|
1541
|
+
const formData = new FormData();
|
|
1542
|
+
formData.append("file", new Blob([fileContent], { type: contentType }), filename);
|
|
1543
|
+
formData.append("key", key);
|
|
1544
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1545
|
+
method: "POST",
|
|
1546
|
+
headers: getHeaders(routeHeaders),
|
|
1547
|
+
body: formData
|
|
1548
|
+
});
|
|
1549
|
+
if (!response.ok) {
|
|
1550
|
+
const error = `Failed to upload bundle: ${response.statusText}`;
|
|
1551
|
+
console.error(`[upload] ${error}`);
|
|
1552
|
+
throw new Error(error);
|
|
1553
|
+
}
|
|
1554
|
+
const result = await response.json();
|
|
1555
|
+
if (!result.storageUri) {
|
|
1556
|
+
const error = "Failed to upload bundle - no storageUri in response";
|
|
1557
|
+
console.error(`[upload] ${error}`);
|
|
1558
|
+
throw new Error(error);
|
|
1559
|
+
}
|
|
1560
|
+
await hooks?.onStorageUploaded?.();
|
|
1561
|
+
return { storageUri: result.storageUri };
|
|
1562
|
+
},
|
|
1563
|
+
async downloadFile(storageUri, filePath) {
|
|
1564
|
+
const { fileUrl } = await getDownloadUrl(storageUri);
|
|
1565
|
+
const response = await fetch(fileUrl);
|
|
1566
|
+
if (!response.ok) throw new Error(`Failed to download bundle: ${response.statusText}`);
|
|
1567
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
1568
|
+
await fs.writeFile(filePath, new Uint8Array(await response.arrayBuffer()));
|
|
1569
|
+
}
|
|
1570
|
+
},
|
|
1571
|
+
runtime: {
|
|
1572
|
+
async readText(storageUri) {
|
|
1573
|
+
const { path: routePath, headers: routeHeaders } = routes.readText(storageUri);
|
|
1574
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1575
|
+
method: "POST",
|
|
1576
|
+
headers: getHeaders(routeHeaders),
|
|
1577
|
+
body: JSON.stringify({ storageUri })
|
|
1578
|
+
});
|
|
1579
|
+
if (!response.ok) return null;
|
|
1580
|
+
return response.text();
|
|
1581
|
+
},
|
|
1582
|
+
getDownloadUrl
|
|
1546
1583
|
}
|
|
1547
|
-
return { fileUrl: (await response.json()).fileUrl };
|
|
1548
1584
|
}
|
|
1549
1585
|
};
|
|
1586
|
+
async function getDownloadUrl(storageUri) {
|
|
1587
|
+
const { path: routePath, headers: routeHeaders } = routes.getDownloadUrl(storageUri);
|
|
1588
|
+
const response = await fetch(`${config.baseUrl}${routePath}`, {
|
|
1589
|
+
method: "POST",
|
|
1590
|
+
headers: getHeaders(routeHeaders),
|
|
1591
|
+
body: JSON.stringify({ storageUri })
|
|
1592
|
+
});
|
|
1593
|
+
if (!response.ok) {
|
|
1594
|
+
const error = /* @__PURE__ */ new Error(`Failed to get download URL: ${response.statusText}`);
|
|
1595
|
+
console.error(error);
|
|
1596
|
+
throw error;
|
|
1597
|
+
}
|
|
1598
|
+
return { fileUrl: (await response.json()).fileUrl };
|
|
1599
|
+
}
|
|
1550
1600
|
};
|
|
1551
1601
|
//#endregion
|
|
1552
1602
|
export { standaloneRepository, standaloneStorage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/standalone",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@hot-updater/core": "0.
|
|
43
|
-
"@hot-updater/plugin-core": "0.
|
|
42
|
+
"@hot-updater/core": "0.31.0",
|
|
43
|
+
"@hot-updater/plugin-core": "0.31.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"mime": "2.6.0",
|