Skip to content

Commit

Permalink
fix(app-vite&app-webpack): fix AE types regarding APIs accepting call…
Browse files Browse the repository at this point in the history
…backs
  • Loading branch information
yusufkandemir committed Aug 6, 2024
1 parent b430474 commit 0c5d0a5
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 60 deletions.
60 changes: 31 additions & 29 deletions app-vite/types/app-extension.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ type ExtractQuasarConfParameters<
? Parameters<MaybeFunction>
: never;

type extendVite = (
type ExtendViteConfHandler = (
fn: (
...args: [...ExtractQuasarConfParameters<"build", "extendViteConf">, IndexAPI]
) => void
) => void;

type getPersistentConf = () => Record<string, unknown>;
type hasExtension = (extId: string) => boolean;
type GetPersistentConfHandler = () => Record<string, unknown>;
type HasExtensionHandler = (extId: string) => boolean;

interface BaseAPI {
engine: '@quasar/app-vite';
Expand All @@ -40,58 +40,60 @@ interface BaseAPI {
}

interface SharedIndexInstallAPI {
getPersistentConf: getPersistentConf;
getPersistentConf: GetPersistentConfHandler;
setPersistentConf: (cfg: Record<string, unknown>) => void;
mergePersistentConf: (cfg: Record<string, unknown>) => void;
compatibleWith: (packageName: string, semverCondition?: string) => void;
hasPackage: (packageName: string, semverCondition?: string) => boolean;
hasExtension: hasExtension;
hasExtension: HasExtensionHandler;
getPackageVersion: (packageName: string) => string | undefined;
}

type Callback<T> = (callback: T) => void;

export interface IndexAPI extends BaseAPI, SharedIndexInstallAPI {
prompts: Record<string, unknown>;

extendQuasarConf: (cfg: QuasarConf, api: IndexAPI) => void;
extendQuasarConf: Callback<(cfg: QuasarConf, api: IndexAPI) => void>;

extendViteConf: extendVite;
extendViteConf: ExtendViteConfHandler;

extendBexScriptsConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendElectronMainConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendElectronPreloadConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendPWACustomSWConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendSSRWebserverConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendBexScriptsConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendElectronMainConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendElectronPreloadConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendPWACustomSWConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendSSRWebserverConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;

registerCommand: (
commandName: string,
fn: { args: string[]; params: Record<string, any> }
fn: (params: { args: string[]; params: Record<string, any> }) => Promise<void> | void
) => void;

registerDescribeApi: (name: string, relativePath: string) => void;

beforeDev: (
beforeDev: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
afterDev: (
) => Promise<void> | void>;
afterDev: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
beforeBuild: (
) => Promise<void> | void>;
beforeBuild: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
afterBuild: (
) => Promise<void> | void>;
afterBuild: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
onPublish: (
) => Promise<void> | void>;
onPublish: Callback<(
api: IndexAPI,
opts: { arg: string; distDir: string }
) => Promise<void> | void;
) => Promise<void> | void>;
}

type onExitLog = (msg: string) => void;
type ExitLogHandler = (msg: string) => void;
export interface InstallAPI extends BaseAPI, SharedIndexInstallAPI {
prompts: Record<string, unknown>;

Expand All @@ -103,21 +105,21 @@ export interface InstallAPI extends BaseAPI, SharedIndexInstallAPI {
relativeTargetPath: string,
scope?: object
) => void;
onExitLog: onExitLog;
onExitLog: ExitLogHandler;
}

export interface UninstallAPI extends BaseAPI {
prompts: Record<string, unknown>;

getPersistentConf: getPersistentConf;
hasExtension: hasExtension;
getPersistentConf: GetPersistentConfHandler;
hasExtension: HasExtensionHandler;
removePath: (__path: string) => void;
onExitLog: onExitLog;
onExitLog: ExitLogHandler;
}

export interface PromptsAPI extends BaseAPI {
compatibleWith: (packageName: string, semverCondition?: string) => void;
hasPackage: (packageName: string, semverCondition?: string) => boolean;
hasExtension: hasExtension;
hasExtension: HasExtensionHandler;
getPackageVersion: (packageName: string) => string | undefined;
}
64 changes: 33 additions & 31 deletions app-webpack/types/app-extension.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ type ExtractQuasarConfParameters<
? Parameters<MaybeFunction>
: never;

type chainWebpack = (
type ChainWebpackHandler = (
fn: (
...args: [...ExtractQuasarConfParameters<"build", "chainWebpack">, IndexAPI]
) => void
) => void;
type extendWebpack = (
type ExtendWebpackHandler = (
fn: (
...args: [
...ExtractQuasarConfParameters<"build", "extendWebpack">,
Expand All @@ -27,8 +27,8 @@ type extendWebpack = (
) => void
) => void;

type getPersistentConf = () => Record<string, unknown>;
type hasExtension = (extId: string) => boolean;
type GetPersistentConfHandler = () => Record<string, unknown>;
type HasExtensionHandler = (extId: string) => boolean;

interface BaseAPI {
engine: '@quasar/app-webpack';
Expand All @@ -48,59 +48,61 @@ interface BaseAPI {
}

interface SharedIndexInstallAPI {
getPersistentConf: getPersistentConf;
getPersistentConf: GetPersistentConfHandler;
setPersistentConf: (cfg: Record<string, unknown>) => void;
mergePersistentConf: (cfg: Record<string, unknown>) => void;
compatibleWith: (packageName: string, semverCondition?: string) => void;
hasPackage: (packageName: string, semverCondition?: string) => boolean;
hasExtension: hasExtension;
hasExtension: HasExtensionHandler;
getPackageVersion: (packageName: string) => string | undefined;
}

type Callback<T> = (callback: T) => void;

export interface IndexAPI extends BaseAPI, SharedIndexInstallAPI {
prompts: Record<string, unknown>;

extendQuasarConf: (cfg: QuasarConf, api: IndexAPI) => void;
extendQuasarConf: Callback<(cfg: QuasarConf, api: IndexAPI) => void>;

chainWebpack: chainWebpack;
extendWebpack: extendWebpack;
chainWebpack: ChainWebpackHandler;
extendWebpack: ExtendWebpackHandler;

extendBexScriptsConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendElectronMainConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendElectronPreloadConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendPWACustomSWConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendSSRWebserverConf: (cfg: EsbuildConfiguration, api: IndexAPI) => void;
extendBexScriptsConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendElectronMainConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendElectronPreloadConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendPWACustomSWConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;
extendSSRWebserverConf: Callback<(cfg: EsbuildConfiguration, api: IndexAPI) => void>;

registerCommand: (
commandName: string,
fn: { args: string[]; params: Record<string, any> }
fn: (params: { args: string[]; params: Record<string, any> }) => Promise<void> | void
) => void;

registerDescribeApi: (name: string, relativePath: string) => void;

beforeDev: (
beforeDev: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
afterDev: (
) => Promise<void> | void>;
afterDev: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
beforeBuild: (
) => Promise<void> | void>;
beforeBuild: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
afterBuild: (
) => Promise<void> | void>;
afterBuild: Callback<(
api: IndexAPI,
payload: { quasarConf: QuasarConf }
) => Promise<void> | void;
onPublish: (
) => Promise<void> | void>;
onPublish: Callback<(
api: IndexAPI,
opts: { arg: string; distDir: string }
) => Promise<void> | void;
) => Promise<void> | void>;
}

type onExitLog = (msg: string) => void;
type ExitLogHandler = (msg: string) => void;
export interface InstallAPI extends BaseAPI, SharedIndexInstallAPI {
prompts: Record<string, unknown>;

Expand All @@ -112,21 +114,21 @@ export interface InstallAPI extends BaseAPI, SharedIndexInstallAPI {
relativeTargetPath: string,
scope?: object
) => void;
onExitLog: onExitLog;
onExitLog: ExitLogHandler;
}

export interface UninstallAPI extends BaseAPI {
prompts: Record<string, unknown>;

getPersistentConf: getPersistentConf;
hasExtension: hasExtension;
getPersistentConf: GetPersistentConfHandler;
hasExtension: HasExtensionHandler;
removePath: (__path: string) => void;
onExitLog: onExitLog;
onExitLog: ExitLogHandler;
}

export interface PromptsAPI extends BaseAPI {
compatibleWith: (packageName: string, semverCondition?: string) => void;
hasPackage: (packageName: string, semverCondition?: string) => boolean;
hasExtension: hasExtension;
hasExtension: HasExtensionHandler;
getPackageVersion: (packageName: string) => string | undefined;
}

0 comments on commit 0c5d0a5

Please sign in to comment.