@anton.marusenko/pp-dev
Version:
Portal Page dev build tool
440 lines (429 loc) • 22.3 kB
TypeScript
import { InlineConfig } from 'vite';
import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
import next, { NextConfig } from 'next';
type RequiredSelection<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
interface DistZipOptions {
/**
* Output ZIP archive file name.
* You can use `[templateName]` placeholder to replace it with the template name.
* @default `${templateName}.zip`
*/
outFileName?: string;
/**
* Output directory for the build.
* @default 'dist-zip'
*/
outDir?: string;
/**
* Input directory for the build.
* @default 'dist'
*/
inDir?: string;
}
interface VitePPDevOptions {
/**
* Backend base URL to MI instance for the local proxy.
*/
backendBaseURL?: string;
/**
* Portal page ID on the MI instance.
* @deprecated Use appId instead
*/
portalPageId?: number;
/**
* Application ID on the MI instance.
* This is a synonym for portalPageId.
*/
appId?: number;
/**
* Template name or PP internal name that will be used for the asset generation.
* Equals to package.json name field value.
*/
templateName: string;
/**
* Enable or disable template variables loading from the backend.
*/
templateLess?: boolean;
/**
* Enable or disable MI top bar and scripts loading from the backend for local development.
*/
miHudLess?: boolean;
/**
* Integrate MI Top Bar and script into the App build.
*
* Depends on `miHudLess` option. Can be used only if `miHudLess` is enabled (true).
*
* @since 0.11.0
* @default false
*/
integrateMiTopBar?: boolean;
/**
* Enable or disable request caching to the backend by the local proxy.
* @default true
*/
enableProxyCache?: boolean;
/**
* Request caching time in milliseconds.
* @default 600000 (10 minutes)
*/
proxyCacheTTL?: number;
/**
* Disable SSL certificate validation for MI instances with self-signed certificates.
* @default false
*/
disableSSLValidation?: boolean;
/**
* Image optimizer options.
* @default true
*/
imageOptimizer?: boolean | Parameters<typeof ViteImageOptimizer>[0];
/**
* Output directory for the build.
* @default 'dist'
*/
outDir?: string;
/**
* Disable or enable packing the build output into a ZIP archive.
* @default true
*/
distZip?: boolean | DistZipOptions;
/**
* Backups an asset directory path for sync with the MI instance.
* @default backups
*/
syncBackupsDir?: string;
/**
* Enable Metric Insights v7 features.
* @default false
* @since 0.8.0
*/
v7Features?: boolean;
/**
* Personal Access Token for the MI instance.
* @default process.env.MI_ACCESS_TOKEN
* @since 0.10.0
* @example
* ```ts
* import vitePPDev from '@metricinsights/pp-dev';
*
* export default vitePPDev({
* personalAccessToken: process.env.MI_ACCESS_TOKEN,
* // other options...
* });
* ```
*/
personalAccessToken?: string;
}
type NormalizedVitePPDevOptions = RequiredSelection<VitePPDevOptions, 'templateName' | 'templateLess' | 'miHudLess' | 'integrateMiTopBar' | 'enableProxyCache' | 'proxyCacheTTL' | 'disableSSLValidation' | 'imageOptimizer' | 'outDir' | 'distZip' | 'syncBackupsDir' | 'v7Features' | 'personalAccessToken'>;
type PPDevConfig = Omit<VitePPDevOptions, 'templateName'>;
type PPWatchConfig = {
baseURL: string;
portalPageId: number;
};
// Keep in sync with the `.js` file.
declare const MODERN_BROWSERSLIST_TARGET: [
'chrome 64',
'edge 79',
'firefox 67',
'opera 51',
'safari 12',
]
type ValueOf<T> = Required<T>[keyof T];
declare const COMPILER_NAMES: {
readonly client: "client";
readonly server: "server";
readonly edgeServer: "edge-server";
};
type CompilerNameValues = ValueOf<typeof COMPILER_NAMES>;
declare const COMPILER_INDEXES: {
[compilerKey in CompilerNameValues]: number;
};
declare const UNDERSCORE_NOT_FOUND_ROUTE = "/_not-found";
declare const UNDERSCORE_NOT_FOUND_ROUTE_ENTRY = "/_not-found/page";
declare const PHASE_EXPORT = "phase-export";
declare const PHASE_PRODUCTION_BUILD = "phase-production-build";
declare const PHASE_PRODUCTION_SERVER = "phase-production-server";
declare const PHASE_DEVELOPMENT_SERVER = "phase-development-server";
declare const PHASE_TEST = "phase-test";
declare const PHASE_INFO = "phase-info";
declare const PAGES_MANIFEST = "pages-manifest.json";
declare const WEBPACK_STATS = "webpack-stats.json";
declare const APP_PATHS_MANIFEST = "app-paths-manifest.json";
declare const APP_PATH_ROUTES_MANIFEST = "app-path-routes-manifest.json";
declare const BUILD_MANIFEST = "build-manifest.json";
declare const APP_BUILD_MANIFEST = "app-build-manifest.json";
declare const FUNCTIONS_CONFIG_MANIFEST = "functions-config-manifest.json";
declare const SUBRESOURCE_INTEGRITY_MANIFEST = "subresource-integrity-manifest";
declare const NEXT_FONT_MANIFEST = "next-font-manifest";
declare const EXPORT_MARKER = "export-marker.json";
declare const EXPORT_DETAIL = "export-detail.json";
declare const PRERENDER_MANIFEST = "prerender-manifest.json";
declare const ROUTES_MANIFEST = "routes-manifest.json";
declare const IMAGES_MANIFEST = "images-manifest.json";
declare const SERVER_FILES_MANIFEST = "required-server-files.json";
declare const DEV_CLIENT_PAGES_MANIFEST = "_devPagesManifest.json";
declare const MIDDLEWARE_MANIFEST = "middleware-manifest.json";
declare const TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST = "_clientMiddlewareManifest.json";
declare const DEV_CLIENT_MIDDLEWARE_MANIFEST = "_devMiddlewareManifest.json";
declare const REACT_LOADABLE_MANIFEST = "react-loadable-manifest.json";
declare const SERVER_DIRECTORY = "server";
declare const CONFIG_FILES: string[];
declare const BUILD_ID_FILE = "BUILD_ID";
declare const BLOCKED_PAGES: string[];
declare const CLIENT_PUBLIC_FILES_PATH = "public";
declare const CLIENT_STATIC_FILES_PATH = "static";
declare const STRING_LITERAL_DROP_BUNDLE = "__NEXT_DROP_CLIENT_FILE__";
declare const NEXT_BUILTIN_DOCUMENT = "__NEXT_BUILTIN_DOCUMENT__";
declare const BARREL_OPTIMIZATION_PREFIX = "__barrel_optimize__";
declare const CLIENT_REFERENCE_MANIFEST = "client-reference-manifest";
declare const SERVER_REFERENCE_MANIFEST = "server-reference-manifest";
declare const MIDDLEWARE_BUILD_MANIFEST = "middleware-build-manifest";
declare const MIDDLEWARE_REACT_LOADABLE_MANIFEST = "middleware-react-loadable-manifest";
declare const INTERCEPTION_ROUTE_REWRITE_MANIFEST = "interception-route-rewrite-manifest";
declare const DYNAMIC_CSS_MANIFEST = "dynamic-css-manifest";
declare const CLIENT_STATIC_FILES_RUNTIME_MAIN = "main";
declare const CLIENT_STATIC_FILES_RUNTIME_MAIN_APP = "main-app";
declare const APP_CLIENT_INTERNALS = "app-pages-internals";
declare const CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH = "react-refresh";
declare const CLIENT_STATIC_FILES_RUNTIME_AMP = "amp";
declare const CLIENT_STATIC_FILES_RUNTIME_WEBPACK = "webpack";
declare const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS = "polyfills";
declare const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL: unique symbol;
declare const DEFAULT_RUNTIME_WEBPACK = "webpack-runtime";
declare const EDGE_RUNTIME_WEBPACK = "edge-runtime-webpack";
declare const STATIC_PROPS_ID = "__N_SSG";
declare const SERVER_PROPS_ID = "__N_SSP";
declare const DEFAULT_SERIF_FONT: {
name: string;
xAvgCharWidth: number;
azAvgWidth: number;
unitsPerEm: number;
};
declare const DEFAULT_SANS_SERIF_FONT: {
name: string;
xAvgCharWidth: number;
azAvgWidth: number;
unitsPerEm: number;
};
declare const STATIC_STATUS_PAGES: string[];
declare const TRACE_OUTPUT_VERSION = 1;
declare const TURBO_TRACE_DEFAULT_MEMORY_LIMIT = 6000;
declare const RSC_MODULE_TYPES: {
readonly client: "client";
readonly server: "server";
};
declare const EDGE_UNSUPPORTED_NODE_APIS: string[];
declare const SYSTEM_ENTRYPOINTS: Set<string>;
declare const nextConstants_APP_BUILD_MANIFEST: typeof APP_BUILD_MANIFEST;
declare const nextConstants_APP_CLIENT_INTERNALS: typeof APP_CLIENT_INTERNALS;
declare const nextConstants_APP_PATHS_MANIFEST: typeof APP_PATHS_MANIFEST;
declare const nextConstants_APP_PATH_ROUTES_MANIFEST: typeof APP_PATH_ROUTES_MANIFEST;
declare const nextConstants_BARREL_OPTIMIZATION_PREFIX: typeof BARREL_OPTIMIZATION_PREFIX;
declare const nextConstants_BLOCKED_PAGES: typeof BLOCKED_PAGES;
declare const nextConstants_BUILD_ID_FILE: typeof BUILD_ID_FILE;
declare const nextConstants_BUILD_MANIFEST: typeof BUILD_MANIFEST;
declare const nextConstants_CLIENT_PUBLIC_FILES_PATH: typeof CLIENT_PUBLIC_FILES_PATH;
declare const nextConstants_CLIENT_REFERENCE_MANIFEST: typeof CLIENT_REFERENCE_MANIFEST;
declare const nextConstants_CLIENT_STATIC_FILES_PATH: typeof CLIENT_STATIC_FILES_PATH;
declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_AMP: typeof CLIENT_STATIC_FILES_RUNTIME_AMP;
declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN: typeof CLIENT_STATIC_FILES_RUNTIME_MAIN;
declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN_APP: typeof CLIENT_STATIC_FILES_RUNTIME_MAIN_APP;
declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS: typeof CLIENT_STATIC_FILES_RUNTIME_POLYFILLS;
declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL: typeof CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL;
declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH: typeof CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH;
declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_WEBPACK: typeof CLIENT_STATIC_FILES_RUNTIME_WEBPACK;
declare const nextConstants_COMPILER_INDEXES: typeof COMPILER_INDEXES;
declare const nextConstants_COMPILER_NAMES: typeof COMPILER_NAMES;
declare const nextConstants_CONFIG_FILES: typeof CONFIG_FILES;
type nextConstants_CompilerNameValues = CompilerNameValues;
declare const nextConstants_DEFAULT_RUNTIME_WEBPACK: typeof DEFAULT_RUNTIME_WEBPACK;
declare const nextConstants_DEFAULT_SANS_SERIF_FONT: typeof DEFAULT_SANS_SERIF_FONT;
declare const nextConstants_DEFAULT_SERIF_FONT: typeof DEFAULT_SERIF_FONT;
declare const nextConstants_DEV_CLIENT_MIDDLEWARE_MANIFEST: typeof DEV_CLIENT_MIDDLEWARE_MANIFEST;
declare const nextConstants_DEV_CLIENT_PAGES_MANIFEST: typeof DEV_CLIENT_PAGES_MANIFEST;
declare const nextConstants_DYNAMIC_CSS_MANIFEST: typeof DYNAMIC_CSS_MANIFEST;
declare const nextConstants_EDGE_RUNTIME_WEBPACK: typeof EDGE_RUNTIME_WEBPACK;
declare const nextConstants_EDGE_UNSUPPORTED_NODE_APIS: typeof EDGE_UNSUPPORTED_NODE_APIS;
declare const nextConstants_EXPORT_DETAIL: typeof EXPORT_DETAIL;
declare const nextConstants_EXPORT_MARKER: typeof EXPORT_MARKER;
declare const nextConstants_FUNCTIONS_CONFIG_MANIFEST: typeof FUNCTIONS_CONFIG_MANIFEST;
declare const nextConstants_IMAGES_MANIFEST: typeof IMAGES_MANIFEST;
declare const nextConstants_INTERCEPTION_ROUTE_REWRITE_MANIFEST: typeof INTERCEPTION_ROUTE_REWRITE_MANIFEST;
declare const nextConstants_MIDDLEWARE_BUILD_MANIFEST: typeof MIDDLEWARE_BUILD_MANIFEST;
declare const nextConstants_MIDDLEWARE_MANIFEST: typeof MIDDLEWARE_MANIFEST;
declare const nextConstants_MIDDLEWARE_REACT_LOADABLE_MANIFEST: typeof MIDDLEWARE_REACT_LOADABLE_MANIFEST;
declare const nextConstants_MODERN_BROWSERSLIST_TARGET: typeof MODERN_BROWSERSLIST_TARGET;
declare const nextConstants_NEXT_BUILTIN_DOCUMENT: typeof NEXT_BUILTIN_DOCUMENT;
declare const nextConstants_NEXT_FONT_MANIFEST: typeof NEXT_FONT_MANIFEST;
declare const nextConstants_PAGES_MANIFEST: typeof PAGES_MANIFEST;
declare const nextConstants_PHASE_DEVELOPMENT_SERVER: typeof PHASE_DEVELOPMENT_SERVER;
declare const nextConstants_PHASE_EXPORT: typeof PHASE_EXPORT;
declare const nextConstants_PHASE_INFO: typeof PHASE_INFO;
declare const nextConstants_PHASE_PRODUCTION_BUILD: typeof PHASE_PRODUCTION_BUILD;
declare const nextConstants_PHASE_PRODUCTION_SERVER: typeof PHASE_PRODUCTION_SERVER;
declare const nextConstants_PHASE_TEST: typeof PHASE_TEST;
declare const nextConstants_PRERENDER_MANIFEST: typeof PRERENDER_MANIFEST;
declare const nextConstants_REACT_LOADABLE_MANIFEST: typeof REACT_LOADABLE_MANIFEST;
declare const nextConstants_ROUTES_MANIFEST: typeof ROUTES_MANIFEST;
declare const nextConstants_RSC_MODULE_TYPES: typeof RSC_MODULE_TYPES;
declare const nextConstants_SERVER_DIRECTORY: typeof SERVER_DIRECTORY;
declare const nextConstants_SERVER_FILES_MANIFEST: typeof SERVER_FILES_MANIFEST;
declare const nextConstants_SERVER_PROPS_ID: typeof SERVER_PROPS_ID;
declare const nextConstants_SERVER_REFERENCE_MANIFEST: typeof SERVER_REFERENCE_MANIFEST;
declare const nextConstants_STATIC_PROPS_ID: typeof STATIC_PROPS_ID;
declare const nextConstants_STATIC_STATUS_PAGES: typeof STATIC_STATUS_PAGES;
declare const nextConstants_STRING_LITERAL_DROP_BUNDLE: typeof STRING_LITERAL_DROP_BUNDLE;
declare const nextConstants_SUBRESOURCE_INTEGRITY_MANIFEST: typeof SUBRESOURCE_INTEGRITY_MANIFEST;
declare const nextConstants_SYSTEM_ENTRYPOINTS: typeof SYSTEM_ENTRYPOINTS;
declare const nextConstants_TRACE_OUTPUT_VERSION: typeof TRACE_OUTPUT_VERSION;
declare const nextConstants_TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST: typeof TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST;
declare const nextConstants_TURBO_TRACE_DEFAULT_MEMORY_LIMIT: typeof TURBO_TRACE_DEFAULT_MEMORY_LIMIT;
declare const nextConstants_UNDERSCORE_NOT_FOUND_ROUTE: typeof UNDERSCORE_NOT_FOUND_ROUTE;
declare const nextConstants_UNDERSCORE_NOT_FOUND_ROUTE_ENTRY: typeof UNDERSCORE_NOT_FOUND_ROUTE_ENTRY;
type nextConstants_ValueOf<T> = ValueOf<T>;
declare const nextConstants_WEBPACK_STATS: typeof WEBPACK_STATS;
declare namespace nextConstants {
export { nextConstants_APP_BUILD_MANIFEST as APP_BUILD_MANIFEST, nextConstants_APP_CLIENT_INTERNALS as APP_CLIENT_INTERNALS, nextConstants_APP_PATHS_MANIFEST as APP_PATHS_MANIFEST, nextConstants_APP_PATH_ROUTES_MANIFEST as APP_PATH_ROUTES_MANIFEST, nextConstants_BARREL_OPTIMIZATION_PREFIX as BARREL_OPTIMIZATION_PREFIX, nextConstants_BLOCKED_PAGES as BLOCKED_PAGES, nextConstants_BUILD_ID_FILE as BUILD_ID_FILE, nextConstants_BUILD_MANIFEST as BUILD_MANIFEST, nextConstants_CLIENT_PUBLIC_FILES_PATH as CLIENT_PUBLIC_FILES_PATH, nextConstants_CLIENT_REFERENCE_MANIFEST as CLIENT_REFERENCE_MANIFEST, nextConstants_CLIENT_STATIC_FILES_PATH as CLIENT_STATIC_FILES_PATH, nextConstants_CLIENT_STATIC_FILES_RUNTIME_AMP as CLIENT_STATIC_FILES_RUNTIME_AMP, nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN as CLIENT_STATIC_FILES_RUNTIME_MAIN, nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN_APP as CLIENT_STATIC_FILES_RUNTIME_MAIN_APP, nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS as CLIENT_STATIC_FILES_RUNTIME_POLYFILLS, nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL as CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL, nextConstants_CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH as CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH, nextConstants_CLIENT_STATIC_FILES_RUNTIME_WEBPACK as CLIENT_STATIC_FILES_RUNTIME_WEBPACK, nextConstants_COMPILER_INDEXES as COMPILER_INDEXES, nextConstants_COMPILER_NAMES as COMPILER_NAMES, nextConstants_CONFIG_FILES as CONFIG_FILES, nextConstants_DEFAULT_RUNTIME_WEBPACK as DEFAULT_RUNTIME_WEBPACK, nextConstants_DEFAULT_SANS_SERIF_FONT as DEFAULT_SANS_SERIF_FONT, nextConstants_DEFAULT_SERIF_FONT as DEFAULT_SERIF_FONT, nextConstants_DEV_CLIENT_MIDDLEWARE_MANIFEST as DEV_CLIENT_MIDDLEWARE_MANIFEST, nextConstants_DEV_CLIENT_PAGES_MANIFEST as DEV_CLIENT_PAGES_MANIFEST, nextConstants_DYNAMIC_CSS_MANIFEST as DYNAMIC_CSS_MANIFEST, nextConstants_EDGE_RUNTIME_WEBPACK as EDGE_RUNTIME_WEBPACK, nextConstants_EDGE_UNSUPPORTED_NODE_APIS as EDGE_UNSUPPORTED_NODE_APIS, nextConstants_EXPORT_DETAIL as EXPORT_DETAIL, nextConstants_EXPORT_MARKER as EXPORT_MARKER, nextConstants_FUNCTIONS_CONFIG_MANIFEST as FUNCTIONS_CONFIG_MANIFEST, nextConstants_IMAGES_MANIFEST as IMAGES_MANIFEST, nextConstants_INTERCEPTION_ROUTE_REWRITE_MANIFEST as INTERCEPTION_ROUTE_REWRITE_MANIFEST, nextConstants_MIDDLEWARE_BUILD_MANIFEST as MIDDLEWARE_BUILD_MANIFEST, nextConstants_MIDDLEWARE_MANIFEST as MIDDLEWARE_MANIFEST, nextConstants_MIDDLEWARE_REACT_LOADABLE_MANIFEST as MIDDLEWARE_REACT_LOADABLE_MANIFEST, nextConstants_MODERN_BROWSERSLIST_TARGET as MODERN_BROWSERSLIST_TARGET, nextConstants_NEXT_BUILTIN_DOCUMENT as NEXT_BUILTIN_DOCUMENT, nextConstants_NEXT_FONT_MANIFEST as NEXT_FONT_MANIFEST, nextConstants_PAGES_MANIFEST as PAGES_MANIFEST, nextConstants_PHASE_DEVELOPMENT_SERVER as PHASE_DEVELOPMENT_SERVER, nextConstants_PHASE_EXPORT as PHASE_EXPORT, nextConstants_PHASE_INFO as PHASE_INFO, nextConstants_PHASE_PRODUCTION_BUILD as PHASE_PRODUCTION_BUILD, nextConstants_PHASE_PRODUCTION_SERVER as PHASE_PRODUCTION_SERVER, nextConstants_PHASE_TEST as PHASE_TEST, nextConstants_PRERENDER_MANIFEST as PRERENDER_MANIFEST, nextConstants_REACT_LOADABLE_MANIFEST as REACT_LOADABLE_MANIFEST, nextConstants_ROUTES_MANIFEST as ROUTES_MANIFEST, nextConstants_RSC_MODULE_TYPES as RSC_MODULE_TYPES, nextConstants_SERVER_DIRECTORY as SERVER_DIRECTORY, nextConstants_SERVER_FILES_MANIFEST as SERVER_FILES_MANIFEST, nextConstants_SERVER_PROPS_ID as SERVER_PROPS_ID, nextConstants_SERVER_REFERENCE_MANIFEST as SERVER_REFERENCE_MANIFEST, nextConstants_STATIC_PROPS_ID as STATIC_PROPS_ID, nextConstants_STATIC_STATUS_PAGES as STATIC_STATUS_PAGES, nextConstants_STRING_LITERAL_DROP_BUNDLE as STRING_LITERAL_DROP_BUNDLE, nextConstants_SUBRESOURCE_INTEGRITY_MANIFEST as SUBRESOURCE_INTEGRITY_MANIFEST, nextConstants_SYSTEM_ENTRYPOINTS as SYSTEM_ENTRYPOINTS, nextConstants_TRACE_OUTPUT_VERSION as TRACE_OUTPUT_VERSION, nextConstants_TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST as TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST, nextConstants_TURBO_TRACE_DEFAULT_MEMORY_LIMIT as TURBO_TRACE_DEFAULT_MEMORY_LIMIT, nextConstants_UNDERSCORE_NOT_FOUND_ROUTE as UNDERSCORE_NOT_FOUND_ROUTE, nextConstants_UNDERSCORE_NOT_FOUND_ROUTE_ENTRY as UNDERSCORE_NOT_FOUND_ROUTE_ENTRY, nextConstants_WEBPACK_STATS as WEBPACK_STATS };
export type { nextConstants_CompilerNameValues as CompilerNameValues, nextConstants_ValueOf as ValueOf };
}
/**
* Safe Next.js import utility
* Handles peer dependency availability and provides helpful error messages
*/
interface NextJSImports {
next: typeof next;
constants: typeof nextConstants;
}
/**
* Safely imports Next.js modules
* @throws {Error} When Next.js is not available as a peer dependency
*/
declare function safeNextImport(): Promise<NextJSImports>;
/**
* Checks if Next.js is available without importing it
*/
declare function isNextAvailable(): Promise<boolean>;
/**
* Gets Next.js version if available
*/
declare function getNextVersion(): Promise<string | null>;
/**
* Global Authentication Provider
*
* This provider manages the global authentication state across the application.
* It provides a centralized way to track and manage authentication status.
*/
interface AuthState {
isAuthenticated: boolean;
isRedirected: boolean;
lastChecked: number;
}
declare class AuthProvider {
private state;
private listeners;
/**
* Get the current authentication state
*/
getState(): AuthState;
/**
* Check if user is authenticated
*/
isAuthenticated(): boolean;
/**
* Check if user has been redirected
*/
isRedirected(): boolean;
/**
* Set authentication status
*/
setAuthenticated(authenticated: boolean): void;
/**
* Set redirect status
*/
setRedirected(redirected: boolean): void;
/**
* Update both authentication and redirect status
*/
updateState(updates: Partial<Pick<AuthState, 'isAuthenticated' | 'isRedirected'>>): void;
/**
* Reset authentication state
*/
reset(): void;
/**
* Subscribe to state changes
*/
subscribe(listener: (state: AuthState) => void): () => void;
/**
* Notify all listeners of state changes
*/
private notifyListeners;
/**
* Get authentication info for debugging
*/
getDebugInfo(): AuthState & {
listenerCount: number;
};
}
declare const authProvider: AuthProvider;
declare module "vite" {
interface UserConfig {
ppDevConfig?: NormalizedVitePPDevOptions;
}
}
declare module "next" {
interface NextConfig {
ppDev?: PPDevConfig;
}
interface ExperimentalConfig {
ppDev?: PPDevConfig;
}
}
declare function getViteConfig(): Promise<InlineConfig>;
/**
* Gets pp-dev configuration from Next.js config
*
* This function extracts pp-dev configuration from Next.js configuration.
* It checks both `config.ppDev` and `config.experimental.ppDev` locations.
*
* @param nextConfig - Next.js configuration object
* @returns PP-Dev configuration or empty object if not found
*
* @example
* ```ts
* // In next.config.js or next.config.ts
* module.exports = {
* ppDev: {
* backendBaseURL: 'http://localhost:8080',
* portalPageId: 1
* }
* // OR
* experimental: {
* ppDev: {
* backendBaseURL: 'http://localhost:8080',
* portalPageId: 1
* }
* }
* }
* ```
*/
declare function getPPDevConfigFromNextConfig(nextConfig: any): PPDevConfig;
/**
* Higher-order function that wraps Next.js configuration with PP-Dev specific settings
*
* This function enhances Next.js configuration by:
* - Adding appropriate base paths for different environments
* - Injecting runtime configuration for PP-Dev
* - Handling development vs production configurations
* - Providing fallback behavior on errors
*
* @param nextjsConfig - Next.js configuration object or function
* @param ppDevConfig - Optional PP-Dev specific configuration
* @returns Function that returns enhanced Next.js configuration
*/
declare function withPPDev(nextjsConfig: NextConfig | ((phase: string, nextConfig?: {
defaultConfig?: any;
}) => NextConfig | Promise<NextConfig>), ppDevConfig?: PPDevConfig): (phase: string, nextConfig?: {
defaultConfig?: any;
}) => Promise<NextConfig>;
export { AuthProvider, authProvider, getNextVersion, getPPDevConfigFromNextConfig, getViteConfig, isNextAvailable, safeNextImport, withPPDev };
export type { AuthState, PPDevConfig, PPWatchConfig };