@hot-updater/plugin-core 0.20.14 → 0.21.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.d.cts CHANGED
@@ -170,11 +170,17 @@ interface NativeBuildArgs {
170
170
  };
171
171
  }
172
172
  interface StoragePlugin {
173
- uploadBundle: (bundleId: string, bundlePath: string) => Promise<{
173
+ /**
174
+ * Protocol this storage plugin can resolve.
175
+ * @example "s3", "r2", "supabase-storage".
176
+ */
177
+ supportedProtocol: string;
178
+ upload: (key: string, filePath: string) => Promise<{
174
179
  storageUri: string;
175
180
  }>;
176
- deleteBundle: (bundleId: string) => Promise<{
177
- storageUri: string;
181
+ delete: (storageUri: string) => Promise<void>;
182
+ getDownloadUrl: (storageUri: string) => Promise<{
183
+ fileUrl: string;
178
184
  }>;
179
185
  name: string;
180
186
  }
@@ -200,6 +206,18 @@ type ConfigInput = {
200
206
  * @default "appVersion"
201
207
  */
202
208
  updateStrategy: "fingerprint" | "appVersion";
209
+ /**
210
+ * The compression strategy used for bundle deployment.
211
+ *
212
+ * - `zip`: Standard ZIP compression (default). Fast and widely supported.
213
+ * - `tar.br`: TAR archive with Brotli compression. Highest compression ratio, smaller bundle size.
214
+ * - `tar.gz`: TAR archive with Gzip compression. Balanced speed and compression ratio.
215
+ *
216
+ * The compression format is determined by the storage plugin used for bundle upload.
217
+ *
218
+ * @default "zip"
219
+ */
220
+ compressStrategy?: "zip" | "tar.br" | "tar.gz";
203
221
  /**
204
222
  * The fingerprint configuration.
205
223
  */
@@ -251,6 +269,38 @@ interface PaginatedResult {
251
269
  */
252
270
  declare function calculatePagination(total: number, options: PaginationOptions): PaginationInfo;
253
271
  //#endregion
272
+ //#region src/compressionFormat.d.ts
273
+ /**
274
+ * Compression format type definition
275
+ */
276
+ type CompressionFormat = "zip" | "tar.br" | "tar.gz";
277
+ /**
278
+ * Compression format metadata
279
+ */
280
+ interface CompressionFormatInfo {
281
+ format: CompressionFormat;
282
+ fileExtension: string;
283
+ mimeType?: string;
284
+ }
285
+ /**
286
+ * Detects compression format from filename
287
+ * @param filename The filename to detect format from
288
+ * @returns Compression format information
289
+ */
290
+ declare function detectCompressionFormat(filename: string): CompressionFormatInfo;
291
+ /**
292
+ * Gets MIME type for a filename
293
+ * @param filename The filename to get MIME type for
294
+ * @returns MIME type string
295
+ */
296
+ declare function getCompressionMimeType(filename: string): string | undefined;
297
+ /**
298
+ * Gets Content-Type for a bundle file with 3-tier fallback
299
+ * @param bundlePath The bundle file path
300
+ * @returns Content-Type string (never undefined, falls back to application/octet-stream)
301
+ */
302
+ declare function getContentType(bundlePath: string): string;
303
+ //#endregion
254
304
  //#region src/copyDirToTmp.d.ts
255
305
  declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
256
306
  tmpDir: string;
@@ -358,6 +408,48 @@ declare function createDatabasePlugin<TContext = object>(name: string, abstractP
358
408
  //#region src/createStorageKeyBuilder.d.ts
359
409
  declare const createStorageKeyBuilder: (basePath: string | undefined) => (...args: string[]) => string;
360
410
  //#endregion
411
+ //#region src/createTarBr.d.ts
412
+ declare const createTarBrTargetFiles: ({
413
+ outfile,
414
+ targetFiles
415
+ }: {
416
+ targetFiles: {
417
+ path: string;
418
+ name: string;
419
+ }[];
420
+ outfile: string;
421
+ }) => Promise<string>;
422
+ declare const createTarBr: ({
423
+ outfile,
424
+ targetDir,
425
+ excludeExts
426
+ }: {
427
+ targetDir: string;
428
+ outfile: string;
429
+ excludeExts?: string[];
430
+ }) => Promise<string>;
431
+ //#endregion
432
+ //#region src/createTarGz.d.ts
433
+ declare const createTarGzTargetFiles: ({
434
+ outfile,
435
+ targetFiles
436
+ }: {
437
+ targetFiles: {
438
+ path: string;
439
+ name: string;
440
+ }[];
441
+ outfile: string;
442
+ }) => Promise<string>;
443
+ declare const createTarGz: ({
444
+ outfile,
445
+ targetDir,
446
+ excludeExts
447
+ }: {
448
+ targetDir: string;
449
+ outfile: string;
450
+ excludeExts?: string[];
451
+ }) => Promise<string>;
452
+ //#endregion
361
453
  //#region src/createZip.d.ts
362
454
  declare const createZipTargetFiles: ({
363
455
  outfile,
@@ -382,6 +474,17 @@ declare const createZip: ({
382
474
  //#region src/cwd.d.ts
383
475
  declare const getCwd: () => string;
384
476
  //#endregion
477
+ //#region src/filterCompatibleAppVersions.d.ts
478
+ /**
479
+ * Filters target app versions that are compatible with the current app version.
480
+ * Returns only versions that are compatible with the current version according to semver rules.
481
+ *
482
+ * @param targetAppVersionList - List of target app versions to filter
483
+ * @param currentVersion - Current app version
484
+ * @returns Array of target app versions compatible with the current version
485
+ */
486
+ declare const filterCompatibleAppVersions: (targetAppVersionList: string[], currentVersion: string) => string[];
487
+ //#endregion
385
488
  //#region src/generateMinBundleId.d.ts
386
489
  declare const generateMinBundleId: () => string;
387
490
  //#endregion
@@ -411,6 +514,32 @@ type EnvVarValue = string | {
411
514
  };
412
515
  declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
413
516
  //#endregion
517
+ //#region src/parseStorageUri.d.ts
518
+ interface ParsedStorageUri {
519
+ protocol: string;
520
+ bucket: string;
521
+ key: string;
522
+ }
523
+ /**
524
+ * Parses a storage URI and validates the protocol.
525
+ *
526
+ * @param storageUri - The storage URI to parse (e.g., "s3://bucket/path/to/file")
527
+ * @param expectedProtocol - The expected protocol without colon (e.g., "s3", "r2", "gs")
528
+ * @returns Parsed storage URI components
529
+ * @throws Error if the URI is invalid or protocol doesn't match
530
+ *
531
+ * @example
532
+ * ```typescript
533
+ * const { bucket, key } = parseStorageUri("s3://my-bucket/path/to/file.zip", "s3");
534
+ * // bucket: "my-bucket"
535
+ * // key: "path/to/file.zip"
536
+ * ```
537
+ */
538
+ declare function parseStorageUri(storageUri: string, expectedProtocol: string): ParsedStorageUri;
539
+ //#endregion
540
+ //#region src/semverSatisfies.d.ts
541
+ declare const semverSatisfies: (targetAppVersion: string, currentVersion: string) => boolean;
542
+ //#endregion
414
543
  //#region src/transformEnv.d.ts
415
544
  declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
416
545
  //#endregion
@@ -428,4 +557,4 @@ type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]
428
557
  */
429
558
  declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
430
559
  //#endregion
431
- export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, BuiltIns, type Bundle, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HasMultipleCallSignatures, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, NativeBuildArgs, PaginatedResult, PaginationInfo, PaginationOptions, type Platform, PlatformConfig, Primitive, ProviderConfig, RequiredDeep, StoragePlugin, StoragePluginHooks, banner, calculatePagination, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createStorageKeyBuilder, createZip, createZipTargetFiles, generateMinBundleId, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, printBanner, transformEnv, transformTemplate };
560
+ export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, BuiltIns, type Bundle, CompressionFormat, CompressionFormatInfo, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HasMultipleCallSignatures, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, NativeBuildArgs, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, ProviderConfig, RequiredDeep, StoragePlugin, StoragePluginHooks, banner, calculatePagination, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createStorageKeyBuilder, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, detectCompressionFormat, filterCompatibleAppVersions, generateMinBundleId, getCompressionMimeType, getContentType, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, parseStorageUri, printBanner, semverSatisfies, transformEnv, transformTemplate };
package/dist/index.d.ts CHANGED
@@ -170,11 +170,17 @@ interface NativeBuildArgs {
170
170
  };
171
171
  }
172
172
  interface StoragePlugin {
173
- uploadBundle: (bundleId: string, bundlePath: string) => Promise<{
173
+ /**
174
+ * Protocol this storage plugin can resolve.
175
+ * @example "s3", "r2", "supabase-storage".
176
+ */
177
+ supportedProtocol: string;
178
+ upload: (key: string, filePath: string) => Promise<{
174
179
  storageUri: string;
175
180
  }>;
176
- deleteBundle: (bundleId: string) => Promise<{
177
- storageUri: string;
181
+ delete: (storageUri: string) => Promise<void>;
182
+ getDownloadUrl: (storageUri: string) => Promise<{
183
+ fileUrl: string;
178
184
  }>;
179
185
  name: string;
180
186
  }
@@ -200,6 +206,18 @@ type ConfigInput = {
200
206
  * @default "appVersion"
201
207
  */
202
208
  updateStrategy: "fingerprint" | "appVersion";
209
+ /**
210
+ * The compression strategy used for bundle deployment.
211
+ *
212
+ * - `zip`: Standard ZIP compression (default). Fast and widely supported.
213
+ * - `tar.br`: TAR archive with Brotli compression. Highest compression ratio, smaller bundle size.
214
+ * - `tar.gz`: TAR archive with Gzip compression. Balanced speed and compression ratio.
215
+ *
216
+ * The compression format is determined by the storage plugin used for bundle upload.
217
+ *
218
+ * @default "zip"
219
+ */
220
+ compressStrategy?: "zip" | "tar.br" | "tar.gz";
203
221
  /**
204
222
  * The fingerprint configuration.
205
223
  */
@@ -251,6 +269,38 @@ interface PaginatedResult {
251
269
  */
252
270
  declare function calculatePagination(total: number, options: PaginationOptions): PaginationInfo;
253
271
  //#endregion
272
+ //#region src/compressionFormat.d.ts
273
+ /**
274
+ * Compression format type definition
275
+ */
276
+ type CompressionFormat = "zip" | "tar.br" | "tar.gz";
277
+ /**
278
+ * Compression format metadata
279
+ */
280
+ interface CompressionFormatInfo {
281
+ format: CompressionFormat;
282
+ fileExtension: string;
283
+ mimeType?: string;
284
+ }
285
+ /**
286
+ * Detects compression format from filename
287
+ * @param filename The filename to detect format from
288
+ * @returns Compression format information
289
+ */
290
+ declare function detectCompressionFormat(filename: string): CompressionFormatInfo;
291
+ /**
292
+ * Gets MIME type for a filename
293
+ * @param filename The filename to get MIME type for
294
+ * @returns MIME type string
295
+ */
296
+ declare function getCompressionMimeType(filename: string): string | undefined;
297
+ /**
298
+ * Gets Content-Type for a bundle file with 3-tier fallback
299
+ * @param bundlePath The bundle file path
300
+ * @returns Content-Type string (never undefined, falls back to application/octet-stream)
301
+ */
302
+ declare function getContentType(bundlePath: string): string;
303
+ //#endregion
254
304
  //#region src/copyDirToTmp.d.ts
255
305
  declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
256
306
  tmpDir: string;
@@ -358,6 +408,48 @@ declare function createDatabasePlugin<TContext = object>(name: string, abstractP
358
408
  //#region src/createStorageKeyBuilder.d.ts
359
409
  declare const createStorageKeyBuilder: (basePath: string | undefined) => (...args: string[]) => string;
360
410
  //#endregion
411
+ //#region src/createTarBr.d.ts
412
+ declare const createTarBrTargetFiles: ({
413
+ outfile,
414
+ targetFiles
415
+ }: {
416
+ targetFiles: {
417
+ path: string;
418
+ name: string;
419
+ }[];
420
+ outfile: string;
421
+ }) => Promise<string>;
422
+ declare const createTarBr: ({
423
+ outfile,
424
+ targetDir,
425
+ excludeExts
426
+ }: {
427
+ targetDir: string;
428
+ outfile: string;
429
+ excludeExts?: string[];
430
+ }) => Promise<string>;
431
+ //#endregion
432
+ //#region src/createTarGz.d.ts
433
+ declare const createTarGzTargetFiles: ({
434
+ outfile,
435
+ targetFiles
436
+ }: {
437
+ targetFiles: {
438
+ path: string;
439
+ name: string;
440
+ }[];
441
+ outfile: string;
442
+ }) => Promise<string>;
443
+ declare const createTarGz: ({
444
+ outfile,
445
+ targetDir,
446
+ excludeExts
447
+ }: {
448
+ targetDir: string;
449
+ outfile: string;
450
+ excludeExts?: string[];
451
+ }) => Promise<string>;
452
+ //#endregion
361
453
  //#region src/createZip.d.ts
362
454
  declare const createZipTargetFiles: ({
363
455
  outfile,
@@ -382,6 +474,17 @@ declare const createZip: ({
382
474
  //#region src/cwd.d.ts
383
475
  declare const getCwd: () => string;
384
476
  //#endregion
477
+ //#region src/filterCompatibleAppVersions.d.ts
478
+ /**
479
+ * Filters target app versions that are compatible with the current app version.
480
+ * Returns only versions that are compatible with the current version according to semver rules.
481
+ *
482
+ * @param targetAppVersionList - List of target app versions to filter
483
+ * @param currentVersion - Current app version
484
+ * @returns Array of target app versions compatible with the current version
485
+ */
486
+ declare const filterCompatibleAppVersions: (targetAppVersionList: string[], currentVersion: string) => string[];
487
+ //#endregion
385
488
  //#region src/generateMinBundleId.d.ts
386
489
  declare const generateMinBundleId: () => string;
387
490
  //#endregion
@@ -411,6 +514,32 @@ type EnvVarValue = string | {
411
514
  };
412
515
  declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
413
516
  //#endregion
517
+ //#region src/parseStorageUri.d.ts
518
+ interface ParsedStorageUri {
519
+ protocol: string;
520
+ bucket: string;
521
+ key: string;
522
+ }
523
+ /**
524
+ * Parses a storage URI and validates the protocol.
525
+ *
526
+ * @param storageUri - The storage URI to parse (e.g., "s3://bucket/path/to/file")
527
+ * @param expectedProtocol - The expected protocol without colon (e.g., "s3", "r2", "gs")
528
+ * @returns Parsed storage URI components
529
+ * @throws Error if the URI is invalid or protocol doesn't match
530
+ *
531
+ * @example
532
+ * ```typescript
533
+ * const { bucket, key } = parseStorageUri("s3://my-bucket/path/to/file.zip", "s3");
534
+ * // bucket: "my-bucket"
535
+ * // key: "path/to/file.zip"
536
+ * ```
537
+ */
538
+ declare function parseStorageUri(storageUri: string, expectedProtocol: string): ParsedStorageUri;
539
+ //#endregion
540
+ //#region src/semverSatisfies.d.ts
541
+ declare const semverSatisfies: (targetAppVersion: string, currentVersion: string) => boolean;
542
+ //#endregion
414
543
  //#region src/transformEnv.d.ts
415
544
  declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
416
545
  //#endregion
@@ -428,4 +557,4 @@ type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]
428
557
  */
429
558
  declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
430
559
  //#endregion
431
- export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, BuiltIns, type Bundle, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HasMultipleCallSignatures, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, NativeBuildArgs, PaginatedResult, PaginationInfo, PaginationOptions, type Platform, PlatformConfig, Primitive, ProviderConfig, RequiredDeep, StoragePlugin, StoragePluginHooks, banner, calculatePagination, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createStorageKeyBuilder, createZip, createZipTargetFiles, generateMinBundleId, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, printBanner, transformEnv, transformTemplate };
560
+ export { AbstractDatabasePlugin, BaseDatabaseUtils, BasePluginArgs, BuildPlugin, BuildPluginConfig, BuildType, BuiltIns, type Bundle, CompressionFormat, CompressionFormatInfo, ConfigBuilder, ConfigInput, ConfigResponse, DatabasePlugin, DatabasePluginHooks, HasMultipleCallSignatures, HotUpdaterConfigOptions, IConfigBuilder, ImportInfo, NativeBuildArgs, PaginatedResult, PaginationInfo, PaginationOptions, ParsedStorageUri, type Platform, PlatformConfig, Primitive, ProviderConfig, RequiredDeep, StoragePlugin, StoragePluginHooks, banner, calculatePagination, copyDirToTmp, createBlobDatabasePlugin, createDatabasePlugin, createStorageKeyBuilder, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, detectCompressionFormat, filterCompatibleAppVersions, generateMinBundleId, getCompressionMimeType, getContentType, getCwd, link, loadConfig, loadConfigSync, log, makeEnv, parseStorageUri, printBanner, semverSatisfies, transformEnv, transformTemplate };