@hot-updater/plugin-core 0.21.6 → 0.21.8
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/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/calculatePagination.cjs +27 -0
- package/dist/calculatePagination.d.cts +17 -0
- package/dist/calculatePagination.d.ts +17 -0
- package/dist/calculatePagination.js +26 -0
- package/dist/compressionFormat.cjs +59 -0
- package/dist/compressionFormat.d.cts +33 -0
- package/dist/compressionFormat.d.ts +33 -0
- package/dist/compressionFormat.js +54 -0
- package/dist/createBlobDatabasePlugin.cjs +312 -0
- package/dist/createBlobDatabasePlugin.d.cts +38 -0
- package/dist/createBlobDatabasePlugin.d.ts +38 -0
- package/dist/createBlobDatabasePlugin.js +309 -0
- package/dist/createDatabasePlugin.cjs +97 -0
- package/dist/createDatabasePlugin.d.cts +68 -0
- package/dist/createDatabasePlugin.d.ts +68 -0
- package/dist/createDatabasePlugin.js +95 -0
- package/dist/createStorageKeyBuilder.cjs +8 -0
- package/dist/createStorageKeyBuilder.d.cts +4 -0
- package/dist/createStorageKeyBuilder.d.ts +4 -0
- package/dist/createStorageKeyBuilder.js +7 -0
- package/dist/filterCompatibleAppVersions.cjs +17 -0
- package/dist/filterCompatibleAppVersions.d.cts +12 -0
- package/dist/filterCompatibleAppVersions.d.ts +12 -0
- package/dist/filterCompatibleAppVersions.js +17 -0
- package/dist/generateMinBundleId.cjs +11 -0
- package/dist/generateMinBundleId.d.cts +4 -0
- package/dist/generateMinBundleId.d.ts +4 -0
- package/dist/generateMinBundleId.js +10 -0
- package/dist/index.cjs +21 -27391
- package/dist/index.d.cts +12 -560
- package/dist/index.d.ts +12 -560
- package/dist/index.js +11 -27351
- package/dist/parseStorageUri.cjs +35 -0
- package/dist/parseStorageUri.d.cts +24 -0
- package/dist/parseStorageUri.d.ts +24 -0
- package/dist/parseStorageUri.js +34 -0
- package/dist/semverSatisfies.cjs +13 -0
- package/dist/semverSatisfies.d.cts +4 -0
- package/dist/semverSatisfies.d.ts +4 -0
- package/dist/semverSatisfies.js +11 -0
- package/dist/types/index.d.cts +201 -0
- package/dist/types/index.d.ts +201 -0
- package/dist/types/utils.d.cts +12 -0
- package/dist/types/utils.d.ts +12 -0
- package/package.json +5 -14
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/parseStorageUri.ts
|
|
3
|
+
/**
|
|
4
|
+
* Parses a storage URI and validates the protocol.
|
|
5
|
+
*
|
|
6
|
+
* @param storageUri - The storage URI to parse (e.g., "s3://bucket/path/to/file")
|
|
7
|
+
* @param expectedProtocol - The expected protocol without colon (e.g., "s3", "r2", "gs")
|
|
8
|
+
* @returns Parsed storage URI components
|
|
9
|
+
* @throws Error if the URI is invalid or protocol doesn't match
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const { bucket, key } = parseStorageUri("s3://my-bucket/path/to/file.zip", "s3");
|
|
14
|
+
* // bucket: "my-bucket"
|
|
15
|
+
* // key: "path/to/file.zip"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function parseStorageUri(storageUri, expectedProtocol) {
|
|
19
|
+
try {
|
|
20
|
+
const url = new URL(storageUri);
|
|
21
|
+
const protocol = url.protocol.replace(":", "");
|
|
22
|
+
if (protocol !== expectedProtocol) throw new Error(`Invalid storage URI protocol. Expected ${expectedProtocol}, got ${protocol}`);
|
|
23
|
+
return {
|
|
24
|
+
protocol,
|
|
25
|
+
bucket: url.hostname,
|
|
26
|
+
key: url.pathname.slice(1)
|
|
27
|
+
};
|
|
28
|
+
} catch (error) {
|
|
29
|
+
if (error instanceof TypeError) throw new Error(`Invalid storage URI format: ${storageUri}`);
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.parseStorageUri = parseStorageUri;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/parseStorageUri.d.ts
|
|
2
|
+
interface ParsedStorageUri {
|
|
3
|
+
protocol: string;
|
|
4
|
+
bucket: string;
|
|
5
|
+
key: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parses a storage URI and validates the protocol.
|
|
9
|
+
*
|
|
10
|
+
* @param storageUri - The storage URI to parse (e.g., "s3://bucket/path/to/file")
|
|
11
|
+
* @param expectedProtocol - The expected protocol without colon (e.g., "s3", "r2", "gs")
|
|
12
|
+
* @returns Parsed storage URI components
|
|
13
|
+
* @throws Error if the URI is invalid or protocol doesn't match
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const { bucket, key } = parseStorageUri("s3://my-bucket/path/to/file.zip", "s3");
|
|
18
|
+
* // bucket: "my-bucket"
|
|
19
|
+
* // key: "path/to/file.zip"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function parseStorageUri(storageUri: string, expectedProtocol: string): ParsedStorageUri;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ParsedStorageUri, parseStorageUri };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/parseStorageUri.d.ts
|
|
2
|
+
interface ParsedStorageUri {
|
|
3
|
+
protocol: string;
|
|
4
|
+
bucket: string;
|
|
5
|
+
key: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Parses a storage URI and validates the protocol.
|
|
9
|
+
*
|
|
10
|
+
* @param storageUri - The storage URI to parse (e.g., "s3://bucket/path/to/file")
|
|
11
|
+
* @param expectedProtocol - The expected protocol without colon (e.g., "s3", "r2", "gs")
|
|
12
|
+
* @returns Parsed storage URI components
|
|
13
|
+
* @throws Error if the URI is invalid or protocol doesn't match
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const { bucket, key } = parseStorageUri("s3://my-bucket/path/to/file.zip", "s3");
|
|
18
|
+
* // bucket: "my-bucket"
|
|
19
|
+
* // key: "path/to/file.zip"
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
declare function parseStorageUri(storageUri: string, expectedProtocol: string): ParsedStorageUri;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { ParsedStorageUri, parseStorageUri };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/parseStorageUri.ts
|
|
2
|
+
/**
|
|
3
|
+
* Parses a storage URI and validates the protocol.
|
|
4
|
+
*
|
|
5
|
+
* @param storageUri - The storage URI to parse (e.g., "s3://bucket/path/to/file")
|
|
6
|
+
* @param expectedProtocol - The expected protocol without colon (e.g., "s3", "r2", "gs")
|
|
7
|
+
* @returns Parsed storage URI components
|
|
8
|
+
* @throws Error if the URI is invalid or protocol doesn't match
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const { bucket, key } = parseStorageUri("s3://my-bucket/path/to/file.zip", "s3");
|
|
13
|
+
* // bucket: "my-bucket"
|
|
14
|
+
* // key: "path/to/file.zip"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function parseStorageUri(storageUri, expectedProtocol) {
|
|
18
|
+
try {
|
|
19
|
+
const url = new URL(storageUri);
|
|
20
|
+
const protocol = url.protocol.replace(":", "");
|
|
21
|
+
if (protocol !== expectedProtocol) throw new Error(`Invalid storage URI protocol. Expected ${expectedProtocol}, got ${protocol}`);
|
|
22
|
+
return {
|
|
23
|
+
protocol,
|
|
24
|
+
bucket: url.hostname,
|
|
25
|
+
key: url.pathname.slice(1)
|
|
26
|
+
};
|
|
27
|
+
} catch (error) {
|
|
28
|
+
if (error instanceof TypeError) throw new Error(`Invalid storage URI format: ${storageUri}`);
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { parseStorageUri };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let semver = require("semver");
|
|
3
|
+
semver = require_rolldown_runtime.__toESM(semver);
|
|
4
|
+
|
|
5
|
+
//#region src/semverSatisfies.ts
|
|
6
|
+
const semverSatisfies = (targetAppVersion, currentVersion) => {
|
|
7
|
+
const currentCoerce = semver.default.coerce(currentVersion);
|
|
8
|
+
if (!currentCoerce) return false;
|
|
9
|
+
return semver.default.satisfies(currentCoerce.version, targetAppVersion);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
exports.semverSatisfies = semverSatisfies;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
|
|
3
|
+
//#region src/semverSatisfies.ts
|
|
4
|
+
const semverSatisfies = (targetAppVersion, currentVersion) => {
|
|
5
|
+
const currentCoerce = semver.coerce(currentVersion);
|
|
6
|
+
if (!currentCoerce) return false;
|
|
7
|
+
return semver.satisfies(currentCoerce.version, targetAppVersion);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { semverSatisfies };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.cjs";
|
|
2
|
+
import { Bundle, Bundle as Bundle$1, Platform, Platform as Platform$1 } from "@hot-updater/core";
|
|
3
|
+
|
|
4
|
+
//#region src/types/index.d.ts
|
|
5
|
+
interface BasePluginArgs {
|
|
6
|
+
cwd: string;
|
|
7
|
+
}
|
|
8
|
+
interface PaginationInfo {
|
|
9
|
+
total: number;
|
|
10
|
+
hasNextPage: boolean;
|
|
11
|
+
hasPreviousPage: boolean;
|
|
12
|
+
currentPage: number;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
}
|
|
15
|
+
interface BuildPluginConfig {
|
|
16
|
+
outDir?: string;
|
|
17
|
+
}
|
|
18
|
+
interface DatabasePlugin {
|
|
19
|
+
getChannels: () => Promise<string[]>;
|
|
20
|
+
getBundleById: (bundleId: string) => Promise<Bundle | null>;
|
|
21
|
+
getBundles: (options: {
|
|
22
|
+
where?: {
|
|
23
|
+
channel?: string;
|
|
24
|
+
platform?: string;
|
|
25
|
+
};
|
|
26
|
+
limit: number;
|
|
27
|
+
offset: number;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
data: Bundle[];
|
|
30
|
+
pagination: PaginationInfo;
|
|
31
|
+
}>;
|
|
32
|
+
updateBundle: (targetBundleId: string, newBundle: Partial<Bundle>) => Promise<void>;
|
|
33
|
+
appendBundle: (insertBundle: Bundle) => Promise<void>;
|
|
34
|
+
commitBundle: () => Promise<void>;
|
|
35
|
+
onUnmount?: () => Promise<void>;
|
|
36
|
+
name: string;
|
|
37
|
+
deleteBundle: (deleteBundle: Bundle) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
interface DatabasePluginHooks {
|
|
40
|
+
onDatabaseUpdated?: () => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
interface BuildPlugin {
|
|
43
|
+
nativeBuild?: {
|
|
44
|
+
prebuild?: (args: {
|
|
45
|
+
platform: Platform;
|
|
46
|
+
}) => Promise<void>;
|
|
47
|
+
postbuild?: (args: {
|
|
48
|
+
platform: Platform;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
build: (args: {
|
|
52
|
+
platform: Platform;
|
|
53
|
+
}) => Promise<{
|
|
54
|
+
buildPath: string;
|
|
55
|
+
bundleId: string;
|
|
56
|
+
stdout: string | null;
|
|
57
|
+
}>;
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
interface PlatformConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Android platform configuration.
|
|
63
|
+
*/
|
|
64
|
+
android?: {
|
|
65
|
+
/**
|
|
66
|
+
* Android string resource paths.
|
|
67
|
+
*
|
|
68
|
+
* @default all strings.xml files in the android directory
|
|
69
|
+
* @example ["android/app/src/main/res/values/strings.xml"]
|
|
70
|
+
*/
|
|
71
|
+
stringResourcePaths?: string[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* iOS platform configuration.
|
|
75
|
+
*/
|
|
76
|
+
ios?: {
|
|
77
|
+
/**
|
|
78
|
+
* iOS info.plist paths.
|
|
79
|
+
*
|
|
80
|
+
* @default all Info.plist files in the ios directory
|
|
81
|
+
* @example ["ios/HotUpdaterExample/Info.plist"]
|
|
82
|
+
*/
|
|
83
|
+
infoPlistPaths?: string[];
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
interface NativeBuildArgs {
|
|
87
|
+
/**
|
|
88
|
+
* Android specific configuration.
|
|
89
|
+
*/
|
|
90
|
+
android?: {
|
|
91
|
+
/**
|
|
92
|
+
* Android application module build variant.
|
|
93
|
+
*
|
|
94
|
+
* @example Debug, Release
|
|
95
|
+
* @default Release
|
|
96
|
+
*/
|
|
97
|
+
variant?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Artifact type.
|
|
100
|
+
*
|
|
101
|
+
* If `true`, the generated artifact type is `.aab`.
|
|
102
|
+
* If `flase`, the generated artifact type is `apk`.
|
|
103
|
+
*
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
aab?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Android application module name.
|
|
109
|
+
*
|
|
110
|
+
* @default app
|
|
111
|
+
*/
|
|
112
|
+
appModuleName?: string;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
interface StoragePlugin {
|
|
116
|
+
/**
|
|
117
|
+
* Protocol this storage plugin can resolve.
|
|
118
|
+
* @example "s3", "r2", "supabase-storage".
|
|
119
|
+
*/
|
|
120
|
+
supportedProtocol: string;
|
|
121
|
+
upload: (key: string, filePath: string) => Promise<{
|
|
122
|
+
storageUri: string;
|
|
123
|
+
}>;
|
|
124
|
+
delete: (storageUri: string) => Promise<void>;
|
|
125
|
+
getDownloadUrl: (storageUri: string) => Promise<{
|
|
126
|
+
fileUrl: string;
|
|
127
|
+
}>;
|
|
128
|
+
name: string;
|
|
129
|
+
}
|
|
130
|
+
interface StoragePluginHooks {
|
|
131
|
+
onStorageUploaded?: () => Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
type ConfigInput = {
|
|
134
|
+
/**
|
|
135
|
+
* The channel used when building the native app.
|
|
136
|
+
* Used to replace __HOT_UPDATER_CHANNEL at build time.
|
|
137
|
+
*
|
|
138
|
+
* @deprecated Use the `hot-updater channel create` command to create a channel.
|
|
139
|
+
*/
|
|
140
|
+
releaseChannel?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The strategy used to update the app.
|
|
143
|
+
*
|
|
144
|
+
* If `fingerprint`, the bundle will be updated if the fingerprint of the app is changed.
|
|
145
|
+
* @docs https://hot-updater.dev/docs/guides/update-strategies/fingerprint
|
|
146
|
+
* If `appVersion`, the bundle will be updated if the target app version is valid.
|
|
147
|
+
* @docs https://hot-updater.dev/docs/guides/update-strategies/app-version
|
|
148
|
+
*
|
|
149
|
+
* @default "appVersion"
|
|
150
|
+
*/
|
|
151
|
+
updateStrategy: "fingerprint" | "appVersion";
|
|
152
|
+
/**
|
|
153
|
+
* The compression strategy used for bundle deployment.
|
|
154
|
+
*
|
|
155
|
+
* - `zip`: Standard ZIP compression (default). Fast and widely supported.
|
|
156
|
+
* - `tar.br`: TAR archive with Brotli compression. Highest compression ratio, smaller bundle size.
|
|
157
|
+
* - `tar.gz`: TAR archive with Gzip compression. Balanced speed and compression ratio.
|
|
158
|
+
*
|
|
159
|
+
* The compression format is determined by the storage plugin used for bundle upload.
|
|
160
|
+
*
|
|
161
|
+
* @default "zip"
|
|
162
|
+
*/
|
|
163
|
+
compressStrategy?: "zip" | "tar.br" | "tar.gz";
|
|
164
|
+
/**
|
|
165
|
+
* The fingerprint configuration.
|
|
166
|
+
*/
|
|
167
|
+
fingerprint?: {
|
|
168
|
+
/**
|
|
169
|
+
* The extra sources to be included in the fingerprint.
|
|
170
|
+
* @example ["resources/**", ".gitignore"]
|
|
171
|
+
*/
|
|
172
|
+
extraSources?: string[];
|
|
173
|
+
/**
|
|
174
|
+
* The paths to be ignored in the fingerprint.
|
|
175
|
+
*/
|
|
176
|
+
ignorePaths?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* When debug mode is enabled, more detailed information will be exposed in fingerprint.json.
|
|
179
|
+
*/
|
|
180
|
+
debug?: boolean;
|
|
181
|
+
};
|
|
182
|
+
console?: {
|
|
183
|
+
/**
|
|
184
|
+
* Git repository URL
|
|
185
|
+
* If git commit hash exists in console, it allows viewing commit history from the git repository
|
|
186
|
+
*/
|
|
187
|
+
gitUrl?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Console port
|
|
190
|
+
* @default 1422
|
|
191
|
+
*/
|
|
192
|
+
port?: number;
|
|
193
|
+
};
|
|
194
|
+
platform?: PlatformConfig;
|
|
195
|
+
nativeBuild?: NativeBuildArgs;
|
|
196
|
+
build: (args: BasePluginArgs) => Promise<BuildPlugin> | BuildPlugin;
|
|
197
|
+
storage: (args: BasePluginArgs) => Promise<StoragePlugin> | StoragePlugin;
|
|
198
|
+
database: (args: BasePluginArgs) => Promise<DatabasePlugin> | DatabasePlugin;
|
|
199
|
+
};
|
|
200
|
+
//#endregion
|
|
201
|
+
export { BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabasePlugin, DatabasePluginHooks, NativeBuildArgs, PaginationInfo, type Platform$1 as Platform, PlatformConfig, StoragePlugin, StoragePluginHooks };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep } from "./utils.js";
|
|
2
|
+
import { Bundle, Bundle as Bundle$1, Platform, Platform as Platform$1 } from "@hot-updater/core";
|
|
3
|
+
|
|
4
|
+
//#region src/types/index.d.ts
|
|
5
|
+
interface BasePluginArgs {
|
|
6
|
+
cwd: string;
|
|
7
|
+
}
|
|
8
|
+
interface PaginationInfo {
|
|
9
|
+
total: number;
|
|
10
|
+
hasNextPage: boolean;
|
|
11
|
+
hasPreviousPage: boolean;
|
|
12
|
+
currentPage: number;
|
|
13
|
+
totalPages: number;
|
|
14
|
+
}
|
|
15
|
+
interface BuildPluginConfig {
|
|
16
|
+
outDir?: string;
|
|
17
|
+
}
|
|
18
|
+
interface DatabasePlugin {
|
|
19
|
+
getChannels: () => Promise<string[]>;
|
|
20
|
+
getBundleById: (bundleId: string) => Promise<Bundle | null>;
|
|
21
|
+
getBundles: (options: {
|
|
22
|
+
where?: {
|
|
23
|
+
channel?: string;
|
|
24
|
+
platform?: string;
|
|
25
|
+
};
|
|
26
|
+
limit: number;
|
|
27
|
+
offset: number;
|
|
28
|
+
}) => Promise<{
|
|
29
|
+
data: Bundle[];
|
|
30
|
+
pagination: PaginationInfo;
|
|
31
|
+
}>;
|
|
32
|
+
updateBundle: (targetBundleId: string, newBundle: Partial<Bundle>) => Promise<void>;
|
|
33
|
+
appendBundle: (insertBundle: Bundle) => Promise<void>;
|
|
34
|
+
commitBundle: () => Promise<void>;
|
|
35
|
+
onUnmount?: () => Promise<void>;
|
|
36
|
+
name: string;
|
|
37
|
+
deleteBundle: (deleteBundle: Bundle) => Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
interface DatabasePluginHooks {
|
|
40
|
+
onDatabaseUpdated?: () => Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
interface BuildPlugin {
|
|
43
|
+
nativeBuild?: {
|
|
44
|
+
prebuild?: (args: {
|
|
45
|
+
platform: Platform;
|
|
46
|
+
}) => Promise<void>;
|
|
47
|
+
postbuild?: (args: {
|
|
48
|
+
platform: Platform;
|
|
49
|
+
}) => Promise<void>;
|
|
50
|
+
};
|
|
51
|
+
build: (args: {
|
|
52
|
+
platform: Platform;
|
|
53
|
+
}) => Promise<{
|
|
54
|
+
buildPath: string;
|
|
55
|
+
bundleId: string;
|
|
56
|
+
stdout: string | null;
|
|
57
|
+
}>;
|
|
58
|
+
name: string;
|
|
59
|
+
}
|
|
60
|
+
interface PlatformConfig {
|
|
61
|
+
/**
|
|
62
|
+
* Android platform configuration.
|
|
63
|
+
*/
|
|
64
|
+
android?: {
|
|
65
|
+
/**
|
|
66
|
+
* Android string resource paths.
|
|
67
|
+
*
|
|
68
|
+
* @default all strings.xml files in the android directory
|
|
69
|
+
* @example ["android/app/src/main/res/values/strings.xml"]
|
|
70
|
+
*/
|
|
71
|
+
stringResourcePaths?: string[];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* iOS platform configuration.
|
|
75
|
+
*/
|
|
76
|
+
ios?: {
|
|
77
|
+
/**
|
|
78
|
+
* iOS info.plist paths.
|
|
79
|
+
*
|
|
80
|
+
* @default all Info.plist files in the ios directory
|
|
81
|
+
* @example ["ios/HotUpdaterExample/Info.plist"]
|
|
82
|
+
*/
|
|
83
|
+
infoPlistPaths?: string[];
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
interface NativeBuildArgs {
|
|
87
|
+
/**
|
|
88
|
+
* Android specific configuration.
|
|
89
|
+
*/
|
|
90
|
+
android?: {
|
|
91
|
+
/**
|
|
92
|
+
* Android application module build variant.
|
|
93
|
+
*
|
|
94
|
+
* @example Debug, Release
|
|
95
|
+
* @default Release
|
|
96
|
+
*/
|
|
97
|
+
variant?: string;
|
|
98
|
+
/**
|
|
99
|
+
* Artifact type.
|
|
100
|
+
*
|
|
101
|
+
* If `true`, the generated artifact type is `.aab`.
|
|
102
|
+
* If `flase`, the generated artifact type is `apk`.
|
|
103
|
+
*
|
|
104
|
+
* @default true
|
|
105
|
+
*/
|
|
106
|
+
aab?: boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Android application module name.
|
|
109
|
+
*
|
|
110
|
+
* @default app
|
|
111
|
+
*/
|
|
112
|
+
appModuleName?: string;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
interface StoragePlugin {
|
|
116
|
+
/**
|
|
117
|
+
* Protocol this storage plugin can resolve.
|
|
118
|
+
* @example "s3", "r2", "supabase-storage".
|
|
119
|
+
*/
|
|
120
|
+
supportedProtocol: string;
|
|
121
|
+
upload: (key: string, filePath: string) => Promise<{
|
|
122
|
+
storageUri: string;
|
|
123
|
+
}>;
|
|
124
|
+
delete: (storageUri: string) => Promise<void>;
|
|
125
|
+
getDownloadUrl: (storageUri: string) => Promise<{
|
|
126
|
+
fileUrl: string;
|
|
127
|
+
}>;
|
|
128
|
+
name: string;
|
|
129
|
+
}
|
|
130
|
+
interface StoragePluginHooks {
|
|
131
|
+
onStorageUploaded?: () => Promise<void>;
|
|
132
|
+
}
|
|
133
|
+
type ConfigInput = {
|
|
134
|
+
/**
|
|
135
|
+
* The channel used when building the native app.
|
|
136
|
+
* Used to replace __HOT_UPDATER_CHANNEL at build time.
|
|
137
|
+
*
|
|
138
|
+
* @deprecated Use the `hot-updater channel create` command to create a channel.
|
|
139
|
+
*/
|
|
140
|
+
releaseChannel?: string;
|
|
141
|
+
/**
|
|
142
|
+
* The strategy used to update the app.
|
|
143
|
+
*
|
|
144
|
+
* If `fingerprint`, the bundle will be updated if the fingerprint of the app is changed.
|
|
145
|
+
* @docs https://hot-updater.dev/docs/guides/update-strategies/fingerprint
|
|
146
|
+
* If `appVersion`, the bundle will be updated if the target app version is valid.
|
|
147
|
+
* @docs https://hot-updater.dev/docs/guides/update-strategies/app-version
|
|
148
|
+
*
|
|
149
|
+
* @default "appVersion"
|
|
150
|
+
*/
|
|
151
|
+
updateStrategy: "fingerprint" | "appVersion";
|
|
152
|
+
/**
|
|
153
|
+
* The compression strategy used for bundle deployment.
|
|
154
|
+
*
|
|
155
|
+
* - `zip`: Standard ZIP compression (default). Fast and widely supported.
|
|
156
|
+
* - `tar.br`: TAR archive with Brotli compression. Highest compression ratio, smaller bundle size.
|
|
157
|
+
* - `tar.gz`: TAR archive with Gzip compression. Balanced speed and compression ratio.
|
|
158
|
+
*
|
|
159
|
+
* The compression format is determined by the storage plugin used for bundle upload.
|
|
160
|
+
*
|
|
161
|
+
* @default "zip"
|
|
162
|
+
*/
|
|
163
|
+
compressStrategy?: "zip" | "tar.br" | "tar.gz";
|
|
164
|
+
/**
|
|
165
|
+
* The fingerprint configuration.
|
|
166
|
+
*/
|
|
167
|
+
fingerprint?: {
|
|
168
|
+
/**
|
|
169
|
+
* The extra sources to be included in the fingerprint.
|
|
170
|
+
* @example ["resources/**", ".gitignore"]
|
|
171
|
+
*/
|
|
172
|
+
extraSources?: string[];
|
|
173
|
+
/**
|
|
174
|
+
* The paths to be ignored in the fingerprint.
|
|
175
|
+
*/
|
|
176
|
+
ignorePaths?: string[];
|
|
177
|
+
/**
|
|
178
|
+
* When debug mode is enabled, more detailed information will be exposed in fingerprint.json.
|
|
179
|
+
*/
|
|
180
|
+
debug?: boolean;
|
|
181
|
+
};
|
|
182
|
+
console?: {
|
|
183
|
+
/**
|
|
184
|
+
* Git repository URL
|
|
185
|
+
* If git commit hash exists in console, it allows viewing commit history from the git repository
|
|
186
|
+
*/
|
|
187
|
+
gitUrl?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Console port
|
|
190
|
+
* @default 1422
|
|
191
|
+
*/
|
|
192
|
+
port?: number;
|
|
193
|
+
};
|
|
194
|
+
platform?: PlatformConfig;
|
|
195
|
+
nativeBuild?: NativeBuildArgs;
|
|
196
|
+
build: (args: BasePluginArgs) => Promise<BuildPlugin> | BuildPlugin;
|
|
197
|
+
storage: (args: BasePluginArgs) => Promise<StoragePlugin> | StoragePlugin;
|
|
198
|
+
database: (args: BasePluginArgs) => Promise<DatabasePlugin> | DatabasePlugin;
|
|
199
|
+
};
|
|
200
|
+
//#endregion
|
|
201
|
+
export { BasePluginArgs, BuildPlugin, BuildPluginConfig, type Bundle$1 as Bundle, ConfigInput, DatabasePlugin, DatabasePluginHooks, NativeBuildArgs, PaginationInfo, type Platform$1 as Platform, PlatformConfig, StoragePlugin, StoragePluginHooks };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/types/utils.d.ts
|
|
2
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
3
|
+
type BuiltIns = Primitive | void | Date | RegExp;
|
|
4
|
+
type ExcludeUndefined<T> = Exclude<T, undefined>;
|
|
5
|
+
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
6
|
+
(...arguments_: infer A): unknown;
|
|
7
|
+
(...arguments_: infer B): unknown;
|
|
8
|
+
} ? B extends A ? A extends B ? false : true : true : false;
|
|
9
|
+
type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E extends BuiltIns ? E : E extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : E extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : E extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : E extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : E extends ((...arguments_: any[]) => unknown) ? {} extends RequiredObjectDeep<E> ? E : HasMultipleCallSignatures<E> extends true ? E : ((...arguments_: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E> : E extends object ? E extends Array<infer ItemType> ? ItemType[] extends E ? Array<RequiredDeep<ItemType>> : RequiredObjectDeep<E> : RequiredObjectDeep<E> : unknown;
|
|
10
|
+
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/types/utils.d.ts
|
|
2
|
+
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
3
|
+
type BuiltIns = Primitive | void | Date | RegExp;
|
|
4
|
+
type ExcludeUndefined<T> = Exclude<T, undefined>;
|
|
5
|
+
type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
|
|
6
|
+
(...arguments_: infer A): unknown;
|
|
7
|
+
(...arguments_: infer B): unknown;
|
|
8
|
+
} ? B extends A ? A extends B ? false : true : true : false;
|
|
9
|
+
type RequiredDeep<T, E extends ExcludeUndefined<T> = ExcludeUndefined<T>> = E extends BuiltIns ? E : E extends Map<infer KeyType, infer ValueType> ? Map<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends Set<infer ItemType> ? Set<RequiredDeep<ItemType>> : E extends ReadonlyMap<infer KeyType, infer ValueType> ? ReadonlyMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends ReadonlySet<infer ItemType> ? ReadonlySet<RequiredDeep<ItemType>> : E extends WeakMap<infer KeyType, infer ValueType> ? WeakMap<RequiredDeep<KeyType>, RequiredDeep<ValueType>> : E extends WeakSet<infer ItemType> ? WeakSet<RequiredDeep<ItemType>> : E extends Promise<infer ValueType> ? Promise<RequiredDeep<ValueType>> : E extends ((...arguments_: any[]) => unknown) ? {} extends RequiredObjectDeep<E> ? E : HasMultipleCallSignatures<E> extends true ? E : ((...arguments_: Parameters<E>) => ReturnType<E>) & RequiredObjectDeep<E> : E extends object ? E extends Array<infer ItemType> ? ItemType[] extends E ? Array<RequiredDeep<ItemType>> : RequiredObjectDeep<E> : RequiredObjectDeep<E> : unknown;
|
|
10
|
+
type RequiredObjectDeep<ObjectType extends object> = { [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]> };
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BuiltIns, HasMultipleCallSignatures, Primitive, RequiredDeep };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/plugin-core",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React Native OTA solution for self-hosted",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -39,26 +39,17 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"cosmiconfig-typescript-loader": "5.0.0",
|
|
44
|
-
"fast-glob": "3.3.3",
|
|
42
|
+
"es-toolkit": "^1.32.0",
|
|
45
43
|
"mime": "^4.0.4",
|
|
46
|
-
"oxc-transform": "0.82.1",
|
|
47
44
|
"semver": "^7.7.2",
|
|
48
|
-
"
|
|
49
|
-
"@hot-updater/core": "0.21.6"
|
|
45
|
+
"@hot-updater/core": "0.21.8"
|
|
50
46
|
},
|
|
51
47
|
"devDependencies": {
|
|
52
48
|
"@types/node": "^20",
|
|
53
49
|
"@types/semver": "^7.5.8",
|
|
54
|
-
"boxen": "^8.0.1",
|
|
55
|
-
"es-toolkit": "^1.32.0",
|
|
56
|
-
"jszip": "^3.10.1",
|
|
57
|
-
"picocolors": "1.1.1",
|
|
58
50
|
"typescript": "5.8.2",
|
|
59
|
-
"
|
|
60
|
-
"@hot-updater/
|
|
61
|
-
"@hot-updater/test-utils": "0.21.6"
|
|
51
|
+
"@hot-updater/plugin-core": "0.21.8",
|
|
52
|
+
"@hot-updater/test-utils": "0.21.8"
|
|
62
53
|
},
|
|
63
54
|
"scripts": {
|
|
64
55
|
"build": "tsdown",
|