@hot-updater/plugin-core 0.17.0 → 0.18.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hot-updater/plugin-core",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "type": "module",
5
5
  "description": "React Native OTA solution for self-hosted",
6
6
  "sideEffects": false,
@@ -40,18 +40,10 @@
40
40
  "dependencies": {
41
41
  "cosmiconfig": "9.0.0",
42
42
  "cosmiconfig-typescript-loader": "5.0.0",
43
- "ts-morph": "25.0.1",
44
- "@hot-updater/core": "0.17.0"
43
+ "oxc-transform": "0.72.0",
44
+ "@hot-updater/core": "0.18.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@babel/core": "7.26.0",
48
- "@babel/generator": "7.26.9",
49
- "@babel/parser": "7.26.9",
50
- "@babel/traverse": "7.25.9",
51
- "@babel/types": "7.26.0",
52
- "@types/babel__core": "7.20.5",
53
- "@types/babel__generator": "7.6.8",
54
- "@types/babel__traverse": "7.20.6",
55
47
  "@types/node": "^22.7.5",
56
48
  "boxen": "^8.0.1",
57
49
  "es-toolkit": "^1.32.0",
@@ -61,7 +53,7 @@
61
53
  "workspace-tools": "^0.36.4"
62
54
  },
63
55
  "scripts": {
64
- "build": "rslib build",
56
+ "build": "tsdown",
65
57
  "test:type": "tsc --noEmit"
66
58
  }
67
59
  }
@@ -1,40 +0,0 @@
1
- export type BuildType = "bare" | "rnef" | "expo";
2
- export type ImportInfo = {
3
- pkg: string;
4
- named?: string[];
5
- defaultOrNamespace?: string;
6
- sideEffect?: boolean;
7
- };
8
- export type ProviderConfig = {
9
- imports: ImportInfo[];
10
- configString: string;
11
- };
12
- export interface IConfigBuilder {
13
- /** Sets the build type ('bare' or 'rnef' or 'expo') and adds necessary build imports. */
14
- setBuildType(buildType: BuildType): this;
15
- /** Sets the storage configuration and adds its required imports. */
16
- setStorage(storageConfig: ProviderConfig): this;
17
- /** Sets the database configuration and adds its required imports. */
18
- setDatabase(databaseConfig: ProviderConfig): this;
19
- /** Sets the intermediate code block to be placed between imports and defineConfig. */
20
- setIntermediateCode(code: string): this;
21
- /** Assembles and returns the final configuration string. */
22
- getResult(): string;
23
- }
24
- export declare class ConfigBuilder implements IConfigBuilder {
25
- private buildType;
26
- private storageInfo;
27
- private databaseInfo;
28
- private intermediateCode;
29
- private collectedImports;
30
- constructor();
31
- addImport(info: ImportInfo): this;
32
- private addImports;
33
- private generateImportStatements;
34
- private generateBuildConfigString;
35
- setBuildType(buildType: BuildType): this;
36
- setStorage(storageConfig: ProviderConfig): this;
37
- setDatabase(databaseConfig: ProviderConfig): this;
38
- setIntermediateCode(code: string): this;
39
- getResult(): string;
40
- }
@@ -1 +0,0 @@
1
- export {};
package/dist/banner.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare const link: (url: string) => string;
2
- export declare const banner: (version?: string) => string;
3
- export declare const printBanner: (version?: string) => void;
@@ -1,4 +0,0 @@
1
- export declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
2
- tmpDir: string;
3
- removeTmpDir: () => Promise<void>;
4
- }>;
@@ -1,42 +0,0 @@
1
- import type { DatabasePluginHooks } from "./types";
2
- /**
3
- * @prefix {string} - The prefix to filter the objects in the storage.
4
- */
5
- export type ListObjectsFn = (prefix: string) => Promise<string[]>;
6
- /**
7
- * @key {string} - The key of the object to load.
8
- */
9
- export type LoadObjectFn = <T>(key: string) => Promise<T | null>;
10
- /**
11
- * @key {string} - The key of the object to upload.
12
- * @data {any} - The data to upload as a Javascript Object.
13
- */
14
- export type UploadObjectFn = (key: string, data: any) => Promise<void>;
15
- /**
16
- * @key {string} - The key of the object to delete.
17
- */
18
- export type DeleteObjectFn = (key: string) => Promise<void>;
19
- /**
20
- * @paths {string[]} - The paths to invalidate in the CDN.
21
- */
22
- export type InvalidatePathsFn = (paths: string[]) => Promise<void>;
23
- /**
24
- *
25
- * @param name - The name of the database plugin
26
- * @param listObjects - Function to list objects in the storage
27
- * @param loadObject - Function to load an JSON object from the storage
28
- * @param uploadObject - Function to upload an JSON object to the storage
29
- * @param deleteObject - Function to delete an object from the storage
30
- * @param invalidatePaths - Function to invalidate paths in the CDN
31
- * @param hooks - Optional hooks for additional functionality - see createDatabasePlugin
32
- * @returns
33
- */
34
- export declare const createBlobDatabasePlugin: ({ name, listObjects, loadObject, uploadObject, deleteObject, invalidatePaths, hooks, }: {
35
- name: string;
36
- listObjects: ListObjectsFn;
37
- loadObject: LoadObjectFn;
38
- uploadObject: UploadObjectFn;
39
- deleteObject: DeleteObjectFn;
40
- invalidatePaths: InvalidatePathsFn;
41
- hooks?: DatabasePluginHooks;
42
- }) => (options: import("./types").BasePluginArgs) => import("./types").DatabasePlugin;
@@ -1 +0,0 @@
1
- export {};
@@ -1,44 +0,0 @@
1
- import type { Bundle } from "@hot-updater/core";
2
- import type { BasePluginArgs, DatabasePlugin, DatabasePluginHooks } from "./types";
3
- export interface BaseDatabaseUtils {
4
- cwd: string;
5
- }
6
- export interface AbstractDatabasePlugin extends Pick<DatabasePlugin, "getBundleById" | "getBundles" | "getChannels" | "onUnmount"> {
7
- commitBundle: ({ changedSets, }: {
8
- changedSets: {
9
- operation: "insert" | "update" | "delete";
10
- data: Bundle;
11
- }[];
12
- }) => Promise<void>;
13
- }
14
- /**
15
- * Creates a database plugin with the given implementation.
16
- *
17
- * @example
18
- * ```ts
19
- * const myDatabasePlugin = createDatabasePlugin("myDatabase", (utils) => {
20
- * return {
21
- * async getBundleById(bundleId) {
22
- * // Implementation to get a bundle by ID
23
- * return bundle;
24
- * },
25
- * async getBundles(options) {
26
- * // Implementation to get bundles with options
27
- * return bundles;
28
- * },
29
- * async getChannels() {
30
- * // Implementation to get available channels
31
- * return channels;
32
- * },
33
- * async commitBundle({ changedMap }) {
34
- * // Implementation to commit changed bundles
35
- * }
36
- * };
37
- * });
38
- * ```
39
- *
40
- * @param name - The name of the database plugin
41
- * @param initializer - A function that initializes the database plugin implementation
42
- * @returns A function that creates a database plugin instance
43
- */
44
- export declare function createDatabasePlugin(name: string, abstractPlugin: AbstractDatabasePlugin, hooks?: DatabasePluginHooks): (options: BasePluginArgs) => DatabasePlugin;
@@ -1,12 +0,0 @@
1
- export declare const createZipTargetFiles: ({ outfile, targetFiles, }: {
2
- targetFiles: {
3
- path: string;
4
- name: string;
5
- }[];
6
- outfile: string;
7
- }) => Promise<string>;
8
- export declare const createZip: ({ outfile, targetDir, excludeExts, }: {
9
- targetDir: string;
10
- outfile: string;
11
- excludeExts?: string[];
12
- }) => Promise<string>;
package/dist/crypto.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const encryptJson: (jsonData: Record<string, any>, secretKey: string) => string;
2
- export declare const decryptJson: <T>(encryptedData: string, secretKey: string) => T;
package/dist/cwd.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const getCwd: () => string;
@@ -1,48 +0,0 @@
1
- /*!
2
- * buildToken
3
- * Builds OAuth token prefix (helper function)
4
- *
5
- * @name buildToken
6
- * @function
7
- * @param {GitUrl} obj The parsed Git url object.
8
- * @return {String} token prefix
9
- */
10
-
11
- /*!
12
- * fill-range <https://github.com/jonschlinkert/fill-range>
13
- *
14
- * Copyright (c) 2014-present, Jon Schlinkert.
15
- * Licensed under the MIT License.
16
- */
17
-
18
- /*!
19
- * is-extglob <https://github.com/jonschlinkert/is-extglob>
20
- *
21
- * Copyright (c) 2014-2016, Jon Schlinkert.
22
- * Licensed under the MIT License.
23
- */
24
-
25
- /*!
26
- * is-glob <https://github.com/jonschlinkert/is-glob>
27
- *
28
- * Copyright (c) 2014-2017, Jon Schlinkert.
29
- * Released under the MIT License.
30
- */
31
-
32
- /*!
33
- * is-number <https://github.com/jonschlinkert/is-number>
34
- *
35
- * Copyright (c) 2014-present, Jon Schlinkert.
36
- * Released under the MIT License.
37
- */
38
-
39
- /*!
40
- * to-regex-range <https://github.com/micromatch/to-regex-range>
41
- *
42
- * Copyright (c) 2015-present, Jon Schlinkert.
43
- * Released under the MIT License.
44
- */
45
-
46
- /*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
47
-
48
- /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -1,48 +0,0 @@
1
- /*!
2
- * buildToken
3
- * Builds OAuth token prefix (helper function)
4
- *
5
- * @name buildToken
6
- * @function
7
- * @param {GitUrl} obj The parsed Git url object.
8
- * @return {String} token prefix
9
- */
10
-
11
- /*!
12
- * fill-range <https://github.com/jonschlinkert/fill-range>
13
- *
14
- * Copyright (c) 2014-present, Jon Schlinkert.
15
- * Licensed under the MIT License.
16
- */
17
-
18
- /*!
19
- * is-extglob <https://github.com/jonschlinkert/is-extglob>
20
- *
21
- * Copyright (c) 2014-2016, Jon Schlinkert.
22
- * Licensed under the MIT License.
23
- */
24
-
25
- /*!
26
- * is-glob <https://github.com/jonschlinkert/is-glob>
27
- *
28
- * Copyright (c) 2014-2017, Jon Schlinkert.
29
- * Released under the MIT License.
30
- */
31
-
32
- /*!
33
- * is-number <https://github.com/jonschlinkert/is-number>
34
- *
35
- * Copyright (c) 2014-present, Jon Schlinkert.
36
- * Released under the MIT License.
37
- */
38
-
39
- /*!
40
- * to-regex-range <https://github.com/micromatch/to-regex-range>
41
- *
42
- * Copyright (c) 2015-present, Jon Schlinkert.
43
- * Released under the MIT License.
44
- */
45
-
46
- /*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
47
-
48
- /*! run-parallel. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
@@ -1 +0,0 @@
1
- export declare const isObject: (value: any) => value is object;
@@ -1,9 +0,0 @@
1
- import type { ConfigInput, Platform } from "./types/index.js";
2
- import type { RequiredDeep } from "./types/utils.js";
3
- export type HotUpdaterConfigOptions = {
4
- platform: Platform;
5
- channel: string;
6
- } | null;
7
- export type ConfigResponse = RequiredDeep<ConfigInput>;
8
- export declare const loadConfig: (options: HotUpdaterConfigOptions) => Promise<ConfigResponse>;
9
- export declare const loadConfigSync: (options: HotUpdaterConfigOptions) => ConfigResponse;
package/dist/log.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export declare const log: {
2
- normal: (message: string | number | null | undefined) => void;
3
- success: (message: string | number | null | undefined) => void;
4
- info: (message: string | number | null | undefined) => void;
5
- error: (message: string | number | null | undefined) => void;
6
- warn: (message: string | number | null | undefined) => void;
7
- debug: (message: string | number | null | undefined) => void;
8
- };
package/dist/makeEnv.d.ts DELETED
@@ -1,6 +0,0 @@
1
- type EnvVarValue = string | {
2
- comment: string;
3
- value: string;
4
- };
5
- export declare const makeEnv: (newEnvVars: Record<string, EnvVarValue>, filePath?: string) => Promise<string>;
6
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export declare const transformEnv: <T extends Record<string, string>>(code: string, env: T) => Promise<string>;
@@ -1 +0,0 @@
1
- export {};
@@ -1,15 +0,0 @@
1
- type ExtractPlaceholders<T extends string> = T extends `${infer _Start}%%${infer Key}%%${infer Rest}` ? Key | ExtractPlaceholders<Rest> : never;
2
- type TransformTemplateArgs<T extends string> = {
3
- [Key in ExtractPlaceholders<T>]: string;
4
- };
5
- /**
6
- * Replaces placeholders in the format %%key%% in a template string with values from the values object.
7
- * Uses generic type T to automatically infer placeholder keys from the template string to ensure type safety.
8
- *
9
- * @example
10
- * const str = "Hello %%name%%, you are %%age%% years old."
11
- * const result = transformTemplate(str, { name: "John", age: "20" })
12
- * // Result: "Hello John, you are 20 years old."
13
- */
14
- export declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
15
- export {};
@@ -1 +0,0 @@
1
- export declare const transformTsEnv: <T extends Record<string, string>>(code: string, env: T) => string;
@@ -1 +0,0 @@
1
- export {};
@@ -1,75 +0,0 @@
1
- import type { Bundle, Platform } from "@hot-updater/core";
2
- export type { Platform, Bundle } from "@hot-updater/core";
3
- export interface BasePluginArgs {
4
- cwd: string;
5
- }
6
- export interface BuildPluginConfig {
7
- outDir?: string;
8
- }
9
- export interface DatabasePlugin {
10
- getChannels: () => Promise<string[]>;
11
- getBundleById: (bundleId: string) => Promise<Bundle | null>;
12
- getBundles: (options?: {
13
- where?: {
14
- channel?: string;
15
- platform?: Platform;
16
- };
17
- limit?: number;
18
- offset?: number;
19
- }) => Promise<Bundle[]>;
20
- updateBundle: (targetBundleId: string, newBundle: Partial<Bundle>) => Promise<void>;
21
- appendBundle: (bundles: Bundle) => Promise<void>;
22
- commitBundle: () => Promise<void>;
23
- onUnmount?: () => Promise<void>;
24
- name: string;
25
- }
26
- export interface DatabasePluginHooks {
27
- onDatabaseUpdated?: () => Promise<void>;
28
- }
29
- export interface BuildPlugin {
30
- build: (args: {
31
- platform: Platform;
32
- channel: string;
33
- }) => Promise<{
34
- buildPath: string;
35
- bundleId: string;
36
- channel: string;
37
- stdout: string | null;
38
- }>;
39
- name: string;
40
- }
41
- export interface StoragePlugin {
42
- uploadBundle: (bundleId: string, bundlePath: string) => Promise<{
43
- bucketName: string;
44
- key: string;
45
- }>;
46
- deleteBundle: (bundleId: string) => Promise<string>;
47
- name: string;
48
- }
49
- export interface StoragePluginHooks {
50
- onStorageUploaded?: () => Promise<void>;
51
- }
52
- export type ConfigInput = {
53
- /**
54
- * The channel used when building the native app.
55
- * Used to replace __HOT_UPDATER_CHANNEL at build time.
56
- *
57
- * @default "production"
58
- */
59
- releaseChannel?: string;
60
- console?: {
61
- /**
62
- * Git repository URL
63
- * If git commit hash exists in console, it allows viewing commit history from the git repository
64
- */
65
- gitUrl?: string;
66
- /**
67
- * Console port
68
- * @default 1422
69
- */
70
- port?: number;
71
- };
72
- build: (args: BasePluginArgs) => Promise<BuildPlugin> | BuildPlugin;
73
- storage: (args: BasePluginArgs) => Promise<StoragePlugin> | StoragePlugin;
74
- database: (args: BasePluginArgs) => Promise<DatabasePlugin> | DatabasePlugin;
75
- };
@@ -1,12 +0,0 @@
1
- export type Primitive = null | undefined | string | number | boolean | symbol | bigint;
2
- export type BuiltIns = Primitive | void | Date | RegExp;
3
- type ExcludeUndefined<T> = Exclude<T, undefined>;
4
- export type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
5
- (...arguments_: infer A): unknown;
6
- (...arguments_: infer B): unknown;
7
- } ? B extends A ? A extends B ? false : true : true : false;
8
- export 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;
9
- type RequiredObjectDeep<ObjectType extends object> = {
10
- [KeyType in keyof ObjectType]-?: RequiredDeep<ObjectType[KeyType]>;
11
- };
12
- export {};