@hot-updater/plugin-core 0.20.11 → 0.20.13
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 +19106 -19325
- package/dist/index.d.cts +136 -136
- package/dist/index.d.ts +136 -136
- package/dist/index.js +25770 -25989
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
import { Bundle, Bundle as Bundle$1, Platform, Platform as Platform$1 } from "@hot-updater/core";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
info: (message: string | number | null | undefined) => void;
|
|
8
|
-
error: (message: string | number | null | undefined) => void;
|
|
9
|
-
warn: (message: string | number | null | undefined) => void;
|
|
10
|
-
debug: (message: string | number | null | undefined) => void;
|
|
11
|
-
};
|
|
3
|
+
//#region src/banner.d.ts
|
|
4
|
+
declare const link: (url: string) => string;
|
|
5
|
+
declare const banner: (version?: string) => string;
|
|
6
|
+
declare const printBanner: (version?: string) => void;
|
|
12
7
|
//#endregion
|
|
13
|
-
//#region src/
|
|
14
|
-
|
|
8
|
+
//#region src/ConfigBuilder.d.ts
|
|
9
|
+
type BuildType = "bare" | "rock" | "expo";
|
|
10
|
+
type ImportInfo = {
|
|
11
|
+
pkg: string;
|
|
12
|
+
named?: string[];
|
|
13
|
+
defaultOrNamespace?: string;
|
|
14
|
+
sideEffect?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type ProviderConfig = {
|
|
17
|
+
imports: ImportInfo[];
|
|
18
|
+
configString: string;
|
|
19
|
+
};
|
|
20
|
+
interface IConfigBuilder {
|
|
21
|
+
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
22
|
+
setBuildType(buildType: BuildType): this;
|
|
23
|
+
/** Sets the storage configuration and adds its required imports. */
|
|
24
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
25
|
+
/** Sets the database configuration and adds its required imports. */
|
|
26
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
27
|
+
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
28
|
+
setIntermediateCode(code: string): this;
|
|
29
|
+
/** Assembles and returns the final configuration string. */
|
|
30
|
+
getResult(): string;
|
|
31
|
+
}
|
|
32
|
+
declare class ConfigBuilder implements IConfigBuilder {
|
|
33
|
+
private buildType;
|
|
34
|
+
private storageInfo;
|
|
35
|
+
private databaseInfo;
|
|
36
|
+
private intermediateCode;
|
|
37
|
+
private collectedImports;
|
|
38
|
+
constructor();
|
|
39
|
+
addImport(info: ImportInfo): this;
|
|
40
|
+
private addImports;
|
|
41
|
+
private generateImportStatements;
|
|
42
|
+
private generateBuildConfigString;
|
|
43
|
+
setBuildType(buildType: BuildType): this;
|
|
44
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
45
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
46
|
+
setIntermediateCode(code: string): this;
|
|
47
|
+
getResult(): string;
|
|
48
|
+
}
|
|
15
49
|
//#endregion
|
|
16
50
|
//#region src/types/utils.d.ts
|
|
17
51
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
@@ -203,14 +237,19 @@ type ConfigInput = {
|
|
|
203
237
|
database: (args: BasePluginArgs) => Promise<DatabasePlugin> | DatabasePlugin;
|
|
204
238
|
};
|
|
205
239
|
//#endregion
|
|
206
|
-
//#region src/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
240
|
+
//#region src/calculatePagination.d.ts
|
|
241
|
+
interface PaginationOptions {
|
|
242
|
+
limit: number;
|
|
243
|
+
offset: number;
|
|
244
|
+
}
|
|
245
|
+
interface PaginatedResult {
|
|
246
|
+
data: Bundle[];
|
|
247
|
+
pagination: PaginationInfo;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Calculate pagination information based on total count, limit, and offset
|
|
251
|
+
*/
|
|
252
|
+
declare function calculatePagination(total: number, options: PaginationOptions): PaginationInfo;
|
|
214
253
|
//#endregion
|
|
215
254
|
//#region src/copyDirToTmp.d.ts
|
|
216
255
|
declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
|
|
@@ -218,6 +257,40 @@ declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
|
|
|
218
257
|
removeTmpDir: () => Promise<void>;
|
|
219
258
|
}>;
|
|
220
259
|
//#endregion
|
|
260
|
+
//#region src/createBlobDatabasePlugin.d.ts
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
* @param name - The name of the database plugin
|
|
264
|
+
* @param listObjects - Function to list objects in the storage
|
|
265
|
+
* @param loadObject - Function to load an JSON object from the storage
|
|
266
|
+
* @param uploadObject - Function to upload an JSON object to the storage
|
|
267
|
+
* @param deleteObject - Function to delete an object from the storage
|
|
268
|
+
* @param invalidatePaths - Function to invalidate paths in the CDN
|
|
269
|
+
* @param hooks - Optional hooks for additional functionality - see createDatabasePlugin
|
|
270
|
+
* @returns
|
|
271
|
+
*/
|
|
272
|
+
declare const createBlobDatabasePlugin: <TContext = object>({
|
|
273
|
+
name,
|
|
274
|
+
getContext,
|
|
275
|
+
listObjects,
|
|
276
|
+
loadObject,
|
|
277
|
+
uploadObject,
|
|
278
|
+
deleteObject,
|
|
279
|
+
invalidatePaths,
|
|
280
|
+
hooks,
|
|
281
|
+
apiBasePath
|
|
282
|
+
}: {
|
|
283
|
+
name: string;
|
|
284
|
+
getContext: () => TContext;
|
|
285
|
+
listObjects: (context: TContext, prefix: string) => Promise<string[]>;
|
|
286
|
+
loadObject: <T>(context: TContext, key: string) => Promise<T | null>;
|
|
287
|
+
uploadObject: <T>(context: TContext, key: string, data: T) => Promise<void>;
|
|
288
|
+
deleteObject: (context: TContext, key: string) => Promise<void>;
|
|
289
|
+
invalidatePaths: (context: TContext, paths: string[]) => Promise<void>;
|
|
290
|
+
hooks?: DatabasePluginHooks;
|
|
291
|
+
apiBasePath: string;
|
|
292
|
+
}) => (options: BasePluginArgs) => DatabasePlugin;
|
|
293
|
+
//#endregion
|
|
221
294
|
//#region src/createDatabasePlugin.d.ts
|
|
222
295
|
interface BaseDatabaseUtils {
|
|
223
296
|
cwd: string;
|
|
@@ -282,34 +355,8 @@ interface AbstractDatabasePlugin<TContext = object> {
|
|
|
282
355
|
*/
|
|
283
356
|
declare function createDatabasePlugin<TContext = object>(name: string, abstractPlugin: AbstractDatabasePlugin<TContext>, hooks?: DatabasePluginHooks): (options: BasePluginArgs) => DatabasePlugin;
|
|
284
357
|
//#endregion
|
|
285
|
-
//#region src/
|
|
286
|
-
declare const
|
|
287
|
-
declare const banner: (version?: string) => string;
|
|
288
|
-
declare const printBanner: (version?: string) => void;
|
|
289
|
-
//#endregion
|
|
290
|
-
//#region src/transformTemplate.d.ts
|
|
291
|
-
type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
|
|
292
|
-
type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]: string };
|
|
293
|
-
/**
|
|
294
|
-
* Replaces placeholders in the format %%key%% in a template string with values from the values object.
|
|
295
|
-
* Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* const str = "Hello %%name%%, you are %%age%% years old."
|
|
299
|
-
* const result = transformTemplate(str, { name: "John", age: "20" })
|
|
300
|
-
* // Result: "Hello John, you are 20 years old."
|
|
301
|
-
*/
|
|
302
|
-
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
303
|
-
//#endregion
|
|
304
|
-
//#region src/transformEnv.d.ts
|
|
305
|
-
declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region src/makeEnv.d.ts
|
|
308
|
-
type EnvVarValue = string | {
|
|
309
|
-
comment: string;
|
|
310
|
-
value: string;
|
|
311
|
-
};
|
|
312
|
-
declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
|
|
358
|
+
//#region src/createStorageKeyBuilder.d.ts
|
|
359
|
+
declare const createStorageKeyBuilder: (basePath: string | undefined) => (...args: string[]) => string;
|
|
313
360
|
//#endregion
|
|
314
361
|
//#region src/createZip.d.ts
|
|
315
362
|
declare const createZipTargetFiles: ({
|
|
@@ -332,100 +379,53 @@ declare const createZip: ({
|
|
|
332
379
|
excludeExts?: string[];
|
|
333
380
|
}) => Promise<string>;
|
|
334
381
|
//#endregion
|
|
335
|
-
//#region src/
|
|
336
|
-
|
|
337
|
-
*
|
|
338
|
-
* @param name - The name of the database plugin
|
|
339
|
-
* @param listObjects - Function to list objects in the storage
|
|
340
|
-
* @param loadObject - Function to load an JSON object from the storage
|
|
341
|
-
* @param uploadObject - Function to upload an JSON object to the storage
|
|
342
|
-
* @param deleteObject - Function to delete an object from the storage
|
|
343
|
-
* @param invalidatePaths - Function to invalidate paths in the CDN
|
|
344
|
-
* @param hooks - Optional hooks for additional functionality - see createDatabasePlugin
|
|
345
|
-
* @returns
|
|
346
|
-
*/
|
|
347
|
-
declare const createBlobDatabasePlugin: <TContext = object>({
|
|
348
|
-
name,
|
|
349
|
-
getContext,
|
|
350
|
-
listObjects,
|
|
351
|
-
loadObject,
|
|
352
|
-
uploadObject,
|
|
353
|
-
deleteObject,
|
|
354
|
-
invalidatePaths,
|
|
355
|
-
hooks,
|
|
356
|
-
apiBasePath
|
|
357
|
-
}: {
|
|
358
|
-
name: string;
|
|
359
|
-
getContext: () => TContext;
|
|
360
|
-
listObjects: (context: TContext, prefix: string) => Promise<string[]>;
|
|
361
|
-
loadObject: <T>(context: TContext, key: string) => Promise<T | null>;
|
|
362
|
-
uploadObject: <T>(context: TContext, key: string, data: T) => Promise<void>;
|
|
363
|
-
deleteObject: (context: TContext, key: string) => Promise<void>;
|
|
364
|
-
invalidatePaths: (context: TContext, paths: string[]) => Promise<void>;
|
|
365
|
-
hooks?: DatabasePluginHooks;
|
|
366
|
-
apiBasePath: string;
|
|
367
|
-
}) => (options: BasePluginArgs) => DatabasePlugin;
|
|
382
|
+
//#region src/cwd.d.ts
|
|
383
|
+
declare const getCwd: () => string;
|
|
368
384
|
//#endregion
|
|
369
|
-
//#region src/
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
385
|
+
//#region src/generateMinBundleId.d.ts
|
|
386
|
+
declare const generateMinBundleId: () => string;
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/loadConfig.d.ts
|
|
389
|
+
type HotUpdaterConfigOptions = {
|
|
390
|
+
platform: Platform;
|
|
391
|
+
channel: string;
|
|
392
|
+
} | null;
|
|
393
|
+
type ConfigResponse = RequiredDeep<ConfigInput>;
|
|
394
|
+
declare const loadConfig: (options: HotUpdaterConfigOptions) => Promise<ConfigResponse>;
|
|
395
|
+
declare const loadConfigSync: (options: HotUpdaterConfigOptions) => ConfigResponse;
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/log.d.ts
|
|
398
|
+
declare const log: {
|
|
399
|
+
normal: (message: string | number | null | undefined) => void;
|
|
400
|
+
success: (message: string | number | null | undefined) => void;
|
|
401
|
+
info: (message: string | number | null | undefined) => void;
|
|
402
|
+
error: (message: string | number | null | undefined) => void;
|
|
403
|
+
warn: (message: string | number | null | undefined) => void;
|
|
404
|
+
debug: (message: string | number | null | undefined) => void;
|
|
376
405
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/makeEnv.d.ts
|
|
408
|
+
type EnvVarValue = string | {
|
|
409
|
+
comment: string;
|
|
410
|
+
value: string;
|
|
380
411
|
};
|
|
381
|
-
|
|
382
|
-
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
383
|
-
setBuildType(buildType: BuildType): this;
|
|
384
|
-
/** Sets the storage configuration and adds its required imports. */
|
|
385
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
386
|
-
/** Sets the database configuration and adds its required imports. */
|
|
387
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
388
|
-
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
389
|
-
setIntermediateCode(code: string): this;
|
|
390
|
-
/** Assembles and returns the final configuration string. */
|
|
391
|
-
getResult(): string;
|
|
392
|
-
}
|
|
393
|
-
declare class ConfigBuilder implements IConfigBuilder {
|
|
394
|
-
private buildType;
|
|
395
|
-
private storageInfo;
|
|
396
|
-
private databaseInfo;
|
|
397
|
-
private intermediateCode;
|
|
398
|
-
private collectedImports;
|
|
399
|
-
constructor();
|
|
400
|
-
addImport(info: ImportInfo): this;
|
|
401
|
-
private addImports;
|
|
402
|
-
private generateImportStatements;
|
|
403
|
-
private generateBuildConfigString;
|
|
404
|
-
setBuildType(buildType: BuildType): this;
|
|
405
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
406
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
407
|
-
setIntermediateCode(code: string): this;
|
|
408
|
-
getResult(): string;
|
|
409
|
-
}
|
|
412
|
+
declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
|
|
410
413
|
//#endregion
|
|
411
|
-
//#region src/
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
data: Bundle[];
|
|
418
|
-
pagination: PaginationInfo;
|
|
419
|
-
}
|
|
414
|
+
//#region src/transformEnv.d.ts
|
|
415
|
+
declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/transformTemplate.d.ts
|
|
418
|
+
type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
|
|
419
|
+
type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]: string };
|
|
420
420
|
/**
|
|
421
|
-
*
|
|
421
|
+
* Replaces placeholders in the format %%key%% in a template string with values from the values object.
|
|
422
|
+
* Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* const str = "Hello %%name%%, you are %%age%% years old."
|
|
426
|
+
* const result = transformTemplate(str, { name: "John", age: "20" })
|
|
427
|
+
* // Result: "Hello John, you are 20 years old."
|
|
422
428
|
*/
|
|
423
|
-
declare function
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/generateMinBundleId.d.ts
|
|
426
|
-
declare const generateMinBundleId: () => string;
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/createStorageKeyBuilder.d.ts
|
|
429
|
-
declare const createStorageKeyBuilder: (basePath: string | undefined) => (...args: string[]) => string;
|
|
429
|
+
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
430
430
|
//#endregion
|
|
431
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
import { Bundle, Bundle as Bundle$1, Platform, Platform as Platform$1 } from "@hot-updater/core";
|
|
2
2
|
|
|
3
|
-
//#region src/
|
|
4
|
-
declare const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
info: (message: string | number | null | undefined) => void;
|
|
8
|
-
error: (message: string | number | null | undefined) => void;
|
|
9
|
-
warn: (message: string | number | null | undefined) => void;
|
|
10
|
-
debug: (message: string | number | null | undefined) => void;
|
|
11
|
-
};
|
|
3
|
+
//#region src/banner.d.ts
|
|
4
|
+
declare const link: (url: string) => string;
|
|
5
|
+
declare const banner: (version?: string) => string;
|
|
6
|
+
declare const printBanner: (version?: string) => void;
|
|
12
7
|
//#endregion
|
|
13
|
-
//#region src/
|
|
14
|
-
|
|
8
|
+
//#region src/ConfigBuilder.d.ts
|
|
9
|
+
type BuildType = "bare" | "rock" | "expo";
|
|
10
|
+
type ImportInfo = {
|
|
11
|
+
pkg: string;
|
|
12
|
+
named?: string[];
|
|
13
|
+
defaultOrNamespace?: string;
|
|
14
|
+
sideEffect?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type ProviderConfig = {
|
|
17
|
+
imports: ImportInfo[];
|
|
18
|
+
configString: string;
|
|
19
|
+
};
|
|
20
|
+
interface IConfigBuilder {
|
|
21
|
+
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
22
|
+
setBuildType(buildType: BuildType): this;
|
|
23
|
+
/** Sets the storage configuration and adds its required imports. */
|
|
24
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
25
|
+
/** Sets the database configuration and adds its required imports. */
|
|
26
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
27
|
+
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
28
|
+
setIntermediateCode(code: string): this;
|
|
29
|
+
/** Assembles and returns the final configuration string. */
|
|
30
|
+
getResult(): string;
|
|
31
|
+
}
|
|
32
|
+
declare class ConfigBuilder implements IConfigBuilder {
|
|
33
|
+
private buildType;
|
|
34
|
+
private storageInfo;
|
|
35
|
+
private databaseInfo;
|
|
36
|
+
private intermediateCode;
|
|
37
|
+
private collectedImports;
|
|
38
|
+
constructor();
|
|
39
|
+
addImport(info: ImportInfo): this;
|
|
40
|
+
private addImports;
|
|
41
|
+
private generateImportStatements;
|
|
42
|
+
private generateBuildConfigString;
|
|
43
|
+
setBuildType(buildType: BuildType): this;
|
|
44
|
+
setStorage(storageConfig: ProviderConfig): this;
|
|
45
|
+
setDatabase(databaseConfig: ProviderConfig): this;
|
|
46
|
+
setIntermediateCode(code: string): this;
|
|
47
|
+
getResult(): string;
|
|
48
|
+
}
|
|
15
49
|
//#endregion
|
|
16
50
|
//#region src/types/utils.d.ts
|
|
17
51
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
@@ -203,14 +237,19 @@ type ConfigInput = {
|
|
|
203
237
|
database: (args: BasePluginArgs) => Promise<DatabasePlugin> | DatabasePlugin;
|
|
204
238
|
};
|
|
205
239
|
//#endregion
|
|
206
|
-
//#region src/
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
240
|
+
//#region src/calculatePagination.d.ts
|
|
241
|
+
interface PaginationOptions {
|
|
242
|
+
limit: number;
|
|
243
|
+
offset: number;
|
|
244
|
+
}
|
|
245
|
+
interface PaginatedResult {
|
|
246
|
+
data: Bundle[];
|
|
247
|
+
pagination: PaginationInfo;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Calculate pagination information based on total count, limit, and offset
|
|
251
|
+
*/
|
|
252
|
+
declare function calculatePagination(total: number, options: PaginationOptions): PaginationInfo;
|
|
214
253
|
//#endregion
|
|
215
254
|
//#region src/copyDirToTmp.d.ts
|
|
216
255
|
declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
|
|
@@ -218,6 +257,40 @@ declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
|
|
|
218
257
|
removeTmpDir: () => Promise<void>;
|
|
219
258
|
}>;
|
|
220
259
|
//#endregion
|
|
260
|
+
//#region src/createBlobDatabasePlugin.d.ts
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
* @param name - The name of the database plugin
|
|
264
|
+
* @param listObjects - Function to list objects in the storage
|
|
265
|
+
* @param loadObject - Function to load an JSON object from the storage
|
|
266
|
+
* @param uploadObject - Function to upload an JSON object to the storage
|
|
267
|
+
* @param deleteObject - Function to delete an object from the storage
|
|
268
|
+
* @param invalidatePaths - Function to invalidate paths in the CDN
|
|
269
|
+
* @param hooks - Optional hooks for additional functionality - see createDatabasePlugin
|
|
270
|
+
* @returns
|
|
271
|
+
*/
|
|
272
|
+
declare const createBlobDatabasePlugin: <TContext = object>({
|
|
273
|
+
name,
|
|
274
|
+
getContext,
|
|
275
|
+
listObjects,
|
|
276
|
+
loadObject,
|
|
277
|
+
uploadObject,
|
|
278
|
+
deleteObject,
|
|
279
|
+
invalidatePaths,
|
|
280
|
+
hooks,
|
|
281
|
+
apiBasePath
|
|
282
|
+
}: {
|
|
283
|
+
name: string;
|
|
284
|
+
getContext: () => TContext;
|
|
285
|
+
listObjects: (context: TContext, prefix: string) => Promise<string[]>;
|
|
286
|
+
loadObject: <T>(context: TContext, key: string) => Promise<T | null>;
|
|
287
|
+
uploadObject: <T>(context: TContext, key: string, data: T) => Promise<void>;
|
|
288
|
+
deleteObject: (context: TContext, key: string) => Promise<void>;
|
|
289
|
+
invalidatePaths: (context: TContext, paths: string[]) => Promise<void>;
|
|
290
|
+
hooks?: DatabasePluginHooks;
|
|
291
|
+
apiBasePath: string;
|
|
292
|
+
}) => (options: BasePluginArgs) => DatabasePlugin;
|
|
293
|
+
//#endregion
|
|
221
294
|
//#region src/createDatabasePlugin.d.ts
|
|
222
295
|
interface BaseDatabaseUtils {
|
|
223
296
|
cwd: string;
|
|
@@ -282,34 +355,8 @@ interface AbstractDatabasePlugin<TContext = object> {
|
|
|
282
355
|
*/
|
|
283
356
|
declare function createDatabasePlugin<TContext = object>(name: string, abstractPlugin: AbstractDatabasePlugin<TContext>, hooks?: DatabasePluginHooks): (options: BasePluginArgs) => DatabasePlugin;
|
|
284
357
|
//#endregion
|
|
285
|
-
//#region src/
|
|
286
|
-
declare const
|
|
287
|
-
declare const banner: (version?: string) => string;
|
|
288
|
-
declare const printBanner: (version?: string) => void;
|
|
289
|
-
//#endregion
|
|
290
|
-
//#region src/transformTemplate.d.ts
|
|
291
|
-
type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
|
|
292
|
-
type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]: string };
|
|
293
|
-
/**
|
|
294
|
-
* Replaces placeholders in the format %%key%% in a template string with values from the values object.
|
|
295
|
-
* Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
|
|
296
|
-
*
|
|
297
|
-
* @example
|
|
298
|
-
* const str = "Hello %%name%%, you are %%age%% years old."
|
|
299
|
-
* const result = transformTemplate(str, { name: "John", age: "20" })
|
|
300
|
-
* // Result: "Hello John, you are 20 years old."
|
|
301
|
-
*/
|
|
302
|
-
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
303
|
-
//#endregion
|
|
304
|
-
//#region src/transformEnv.d.ts
|
|
305
|
-
declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
|
|
306
|
-
//#endregion
|
|
307
|
-
//#region src/makeEnv.d.ts
|
|
308
|
-
type EnvVarValue = string | {
|
|
309
|
-
comment: string;
|
|
310
|
-
value: string;
|
|
311
|
-
};
|
|
312
|
-
declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
|
|
358
|
+
//#region src/createStorageKeyBuilder.d.ts
|
|
359
|
+
declare const createStorageKeyBuilder: (basePath: string | undefined) => (...args: string[]) => string;
|
|
313
360
|
//#endregion
|
|
314
361
|
//#region src/createZip.d.ts
|
|
315
362
|
declare const createZipTargetFiles: ({
|
|
@@ -332,100 +379,53 @@ declare const createZip: ({
|
|
|
332
379
|
excludeExts?: string[];
|
|
333
380
|
}) => Promise<string>;
|
|
334
381
|
//#endregion
|
|
335
|
-
//#region src/
|
|
336
|
-
|
|
337
|
-
*
|
|
338
|
-
* @param name - The name of the database plugin
|
|
339
|
-
* @param listObjects - Function to list objects in the storage
|
|
340
|
-
* @param loadObject - Function to load an JSON object from the storage
|
|
341
|
-
* @param uploadObject - Function to upload an JSON object to the storage
|
|
342
|
-
* @param deleteObject - Function to delete an object from the storage
|
|
343
|
-
* @param invalidatePaths - Function to invalidate paths in the CDN
|
|
344
|
-
* @param hooks - Optional hooks for additional functionality - see createDatabasePlugin
|
|
345
|
-
* @returns
|
|
346
|
-
*/
|
|
347
|
-
declare const createBlobDatabasePlugin: <TContext = object>({
|
|
348
|
-
name,
|
|
349
|
-
getContext,
|
|
350
|
-
listObjects,
|
|
351
|
-
loadObject,
|
|
352
|
-
uploadObject,
|
|
353
|
-
deleteObject,
|
|
354
|
-
invalidatePaths,
|
|
355
|
-
hooks,
|
|
356
|
-
apiBasePath
|
|
357
|
-
}: {
|
|
358
|
-
name: string;
|
|
359
|
-
getContext: () => TContext;
|
|
360
|
-
listObjects: (context: TContext, prefix: string) => Promise<string[]>;
|
|
361
|
-
loadObject: <T>(context: TContext, key: string) => Promise<T | null>;
|
|
362
|
-
uploadObject: <T>(context: TContext, key: string, data: T) => Promise<void>;
|
|
363
|
-
deleteObject: (context: TContext, key: string) => Promise<void>;
|
|
364
|
-
invalidatePaths: (context: TContext, paths: string[]) => Promise<void>;
|
|
365
|
-
hooks?: DatabasePluginHooks;
|
|
366
|
-
apiBasePath: string;
|
|
367
|
-
}) => (options: BasePluginArgs) => DatabasePlugin;
|
|
382
|
+
//#region src/cwd.d.ts
|
|
383
|
+
declare const getCwd: () => string;
|
|
368
384
|
//#endregion
|
|
369
|
-
//#region src/
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
385
|
+
//#region src/generateMinBundleId.d.ts
|
|
386
|
+
declare const generateMinBundleId: () => string;
|
|
387
|
+
//#endregion
|
|
388
|
+
//#region src/loadConfig.d.ts
|
|
389
|
+
type HotUpdaterConfigOptions = {
|
|
390
|
+
platform: Platform;
|
|
391
|
+
channel: string;
|
|
392
|
+
} | null;
|
|
393
|
+
type ConfigResponse = RequiredDeep<ConfigInput>;
|
|
394
|
+
declare const loadConfig: (options: HotUpdaterConfigOptions) => Promise<ConfigResponse>;
|
|
395
|
+
declare const loadConfigSync: (options: HotUpdaterConfigOptions) => ConfigResponse;
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/log.d.ts
|
|
398
|
+
declare const log: {
|
|
399
|
+
normal: (message: string | number | null | undefined) => void;
|
|
400
|
+
success: (message: string | number | null | undefined) => void;
|
|
401
|
+
info: (message: string | number | null | undefined) => void;
|
|
402
|
+
error: (message: string | number | null | undefined) => void;
|
|
403
|
+
warn: (message: string | number | null | undefined) => void;
|
|
404
|
+
debug: (message: string | number | null | undefined) => void;
|
|
376
405
|
};
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
406
|
+
//#endregion
|
|
407
|
+
//#region src/makeEnv.d.ts
|
|
408
|
+
type EnvVarValue = string | {
|
|
409
|
+
comment: string;
|
|
410
|
+
value: string;
|
|
380
411
|
};
|
|
381
|
-
|
|
382
|
-
/** Sets the build type ('bare' or 'rock' or 'expo') and adds necessary build imports. */
|
|
383
|
-
setBuildType(buildType: BuildType): this;
|
|
384
|
-
/** Sets the storage configuration and adds its required imports. */
|
|
385
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
386
|
-
/** Sets the database configuration and adds its required imports. */
|
|
387
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
388
|
-
/** Sets the intermediate code block to be placed between imports and defineConfig. */
|
|
389
|
-
setIntermediateCode(code: string): this;
|
|
390
|
-
/** Assembles and returns the final configuration string. */
|
|
391
|
-
getResult(): string;
|
|
392
|
-
}
|
|
393
|
-
declare class ConfigBuilder implements IConfigBuilder {
|
|
394
|
-
private buildType;
|
|
395
|
-
private storageInfo;
|
|
396
|
-
private databaseInfo;
|
|
397
|
-
private intermediateCode;
|
|
398
|
-
private collectedImports;
|
|
399
|
-
constructor();
|
|
400
|
-
addImport(info: ImportInfo): this;
|
|
401
|
-
private addImports;
|
|
402
|
-
private generateImportStatements;
|
|
403
|
-
private generateBuildConfigString;
|
|
404
|
-
setBuildType(buildType: BuildType): this;
|
|
405
|
-
setStorage(storageConfig: ProviderConfig): this;
|
|
406
|
-
setDatabase(databaseConfig: ProviderConfig): this;
|
|
407
|
-
setIntermediateCode(code: string): this;
|
|
408
|
-
getResult(): string;
|
|
409
|
-
}
|
|
412
|
+
declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
|
|
410
413
|
//#endregion
|
|
411
|
-
//#region src/
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
data: Bundle[];
|
|
418
|
-
pagination: PaginationInfo;
|
|
419
|
-
}
|
|
414
|
+
//#region src/transformEnv.d.ts
|
|
415
|
+
declare const transformEnv: <T extends Record<string, string>>(filename: string, env: T) => string;
|
|
416
|
+
//#endregion
|
|
417
|
+
//#region src/transformTemplate.d.ts
|
|
418
|
+
type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
|
|
419
|
+
type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]: string };
|
|
420
420
|
/**
|
|
421
|
-
*
|
|
421
|
+
* Replaces placeholders in the format %%key%% in a template string with values from the values object.
|
|
422
|
+
* Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
|
|
423
|
+
*
|
|
424
|
+
* @example
|
|
425
|
+
* const str = "Hello %%name%%, you are %%age%% years old."
|
|
426
|
+
* const result = transformTemplate(str, { name: "John", age: "20" })
|
|
427
|
+
* // Result: "Hello John, you are 20 years old."
|
|
422
428
|
*/
|
|
423
|
-
declare function
|
|
424
|
-
//#endregion
|
|
425
|
-
//#region src/generateMinBundleId.d.ts
|
|
426
|
-
declare const generateMinBundleId: () => string;
|
|
427
|
-
//#endregion
|
|
428
|
-
//#region src/createStorageKeyBuilder.d.ts
|
|
429
|
-
declare const createStorageKeyBuilder: (basePath: string | undefined) => (...args: string[]) => string;
|
|
429
|
+
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
430
430
|
//#endregion
|
|
431
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 };
|