{"version":3,"sources":["../../src/vite/index.ts","../../src/bin/logger.ts","../../src/config/microfrontends/server/index.ts","../../src/config/errors.ts","../../src/config/microfrontends-config/isomorphic/index.ts","../../src/config/microfrontends/utils/hash-application-name.ts","../../src/config/overrides/constants.ts","../../src/config/overrides/is-override-cookie.ts","../../src/config/overrides/get-override-from-cookie.ts","../../src/config/overrides/parse-overrides.ts","../../src/config/schema/utils/is-default-app.ts","../../src/config/microfrontends-config/client/index.ts","../../src/config/microfrontends-config/utils/get-config-from-env.ts","../../src/config/microfrontends/utils/find-config.ts","../../src/config/microfrontends/utils/get-config-file-name.ts","../../src/config/microfrontends/utils/generate-default-asset-prefix.ts","../../src/config/microfrontends/utils/infer-microfrontends-location.ts","../../src/config/microfrontends-config/isomorphic/constants.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-port.ts","../../src/config/microfrontends-config/isomorphic/host.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-automation-bypass-env-var-name.ts","../../src/config/microfrontends-config/isomorphic/validation.ts","../../src/config/microfrontends-config/isomorphic/application.ts","../../src/config/microfrontends/utils/find-package-root.ts","../../src/config/microfrontends/utils/find-repository-root.ts","../../src/config/microfrontends/utils/get-application-context.ts","../../src/config/microfrontends/utils/is-monorepo.ts","../../src/config/microfrontends/server/utils/get-output-file-path.ts","../../src/config/microfrontends/server/constants.ts","../../src/config/microfrontends/server/validation.ts","../../schema/schema.json","../../src/config/schema/utils/load.ts","../../src/vite/detect-framework.ts"],"sourcesContent":["import type { Plugin, UserConfig } from 'vite';\nimport { logger } from '../bin/logger';\nimport { MicrofrontendsServer } from '../config/microfrontends/server';\nimport { getApplicationContext } from '../config/microfrontends/utils/get-application-context';\nimport { detectFramework } from './detect-framework';\n\ninterface MicrofrontendsViteOptions {\n  /**\n   * An optional base path to use instead of an asset prefix. This will prefix\n   * _all_ paths in an application with the provided string. This can be used\n   * when it is okay if every path has a common path prefix. If an application\n   * has URLs that don't share a common path prefix, omit this option.\n   *\n   * See https://vite.dev/guide/build#public-base-path for more information.\n   */\n  basePath?: string;\n}\n\n/**\n * Set up Vite with necessary configuration for microfrontends. This should be\n * used with any framework that uses Vite as the bundler.\n *\n * See the [Getting Started](https://vercel.com/docs/microfrontends/quickstart) guide for more information.\n *\n * @example Setting up Vite with microfrontends\n * ```ts filename=\"vite.config.ts\"\n * import { microfrontends } from '@vercel/microfrontends/experimental/vite';\n * export default defineConfig({\n *   plugins: [microfrontends()],\n * });\n * ```\n */\nexport function microfrontends(opts?: MicrofrontendsViteOptions): Plugin {\n  const { name: fromApp } = getApplicationContext();\n  const microfrontendsObj = MicrofrontendsServer.infer();\n  const app = microfrontendsObj.config.getApplication(fromApp);\n\n  if (app.isDefault() && opts?.basePath) {\n    throw new Error(\n      '`basePath` can not be set for the default microfrontends application.',\n    );\n  }\n  const framework = detectFramework();\n  if (framework === 'sveltekit' && opts?.basePath) {\n    throw new Error('`basePath` is not supported for SvelteKit applications.');\n  }\n  if (\n    opts?.basePath &&\n    (!opts.basePath.startsWith('/') || opts.basePath.endsWith('/'))\n  ) {\n    throw new Error('`basePath` must start with a `/` and not end with a `/`');\n  }\n\n  const additionalConfigOptions: UserConfig = {};\n\n  if (!app.isDefault()) {\n    if (opts?.basePath) {\n      const basePath = opts.basePath;\n      // The base path is not set for React Router on Vercel since it results\n      // in a double prefixing of the base path.\n      if (framework !== 'react-router' || !process.env.VERCEL_ENV) {\n        additionalConfigOptions.base = basePath;\n      }\n      if (framework === 'react-router') {\n        // React Router, used as a framework, overrides the Vite configuration when\n        // base path is set and ignores the `outDir` option. However, this causes\n        // assets to fail to load. Setting the `assetsDir` option to the base path\n        // fixes this issue.\n        additionalConfigOptions.build = {\n          assetsDir: `./${basePath}`,\n        };\n      } else {\n        // By setting `outDir`, we ensure that all output files are placed in\n        // the correct directory for serving under the base path prefix.\n        additionalConfigOptions.build = {\n          outDir: `dist${opts.basePath}`,\n        };\n      }\n    } else if (framework !== 'sveltekit') {\n      // Asset prefixing is handled automatically by changing the assetsDir\n      // to the correct path.\n      // SvelteKit assets are already prefixed using svelte.config.js.\n      additionalConfigOptions.build = {\n        assetsDir: `./${app.getAssetPrefix()}`,\n      };\n    }\n  }\n  if (app.development.local.port) {\n    additionalConfigOptions.server = {\n      port: app.development.local.port,\n    };\n    additionalConfigOptions.preview = {\n      port: app.development.local.port,\n    };\n  }\n  logger.debug(\n    '[@vercel/microfrontends] Updating Vite configuration with the following changes:',\n    additionalConfigOptions,\n  );\n  return {\n    name: 'vite-plugin-vercel-microfrontends',\n    config: () => {\n      return {\n        ...additionalConfigOptions,\n        define: {\n          'import.meta.env.MFE_CURRENT_APPLICATION': JSON.stringify(app.name),\n          'import.meta.env.MFE_CONFIG': JSON.stringify(\n            microfrontendsObj.config.getConfig(),\n          ),\n        },\n      };\n    },\n  };\n}\n","/* eslint-disable no-console */\n\nfunction debug(...args: unknown[]): void {\n  if (process.env.MFE_DEBUG) {\n    console.log(...args);\n  }\n}\n\nfunction info(...args: unknown[]): void {\n  console.log(...args);\n}\n\nfunction warn(...args: unknown[]): void {\n  console.warn(...args);\n}\n\nfunction error(...args: unknown[]): void {\n  console.error(...args);\n}\n\nexport const logger = {\n  debug,\n  info,\n  warn,\n  error,\n};\n","import fs from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport { logger } from '../../../bin/logger';\nimport { MicrofrontendError } from '../../errors';\nimport { MicrofrontendConfigIsomorphic } from '../../microfrontends-config/isomorphic';\nimport { getConfigStringFromEnv } from '../../microfrontends-config/utils/get-config-from-env';\nimport type { OverridesConfig } from '../../overrides';\nimport { parseOverrides } from '../../overrides';\nimport type { Config } from '../../schema/types';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\nimport { findConfig } from '../utils/find-config';\nimport { findPackageRoot } from '../utils/find-package-root';\nimport { findRepositoryRoot } from '../utils/find-repository-root';\nimport { getApplicationContext } from '../utils/get-application-context';\nimport { inferMicrofrontendsLocation } from '../utils/infer-microfrontends-location';\nimport { isMonorepo as isRepositoryMonorepo } from '../utils/is-monorepo';\nimport { getOutputFilePath } from './utils/get-output-file-path';\nimport { validateSchema } from './validation';\n\nclass MicrofrontendsServer {\n  config: MicrofrontendConfigIsomorphic;\n\n  constructor({\n    config,\n    overrides,\n  }: {\n    config: Config;\n    overrides?: OverridesConfig;\n  }) {\n    this.config = new MicrofrontendConfigIsomorphic({ config, overrides });\n  }\n\n  /**\n   * Writes the configuration to a file.\n   */\n  writeConfig(\n    opts: { pretty?: boolean } = {\n      pretty: true,\n    },\n  ): void {\n    const outputPath = getOutputFilePath();\n\n    // ensure the directory exists\n    fs.mkdirSync(dirname(outputPath), { recursive: true });\n    fs.writeFileSync(\n      outputPath,\n      JSON.stringify(\n        this.config.toSchemaJson(),\n        null,\n        (opts.pretty ?? true) ? 2 : undefined,\n      ),\n    );\n  }\n\n  // --------- Static Methods ---------\n\n  /**\n   * Generates a MicrofrontendsServer instance from an unknown object.\n   */\n  static fromUnknown({\n    config,\n    cookies,\n  }: {\n    config: unknown;\n    cookies?: { name: string; value: string }[];\n  }): MicrofrontendsServer {\n    const overrides = cookies ? parseOverrides(cookies) : undefined;\n    if (typeof config === 'string') {\n      return new MicrofrontendsServer({\n        config: MicrofrontendsServer.validate(config),\n        overrides,\n      });\n    }\n    if (typeof config === 'object') {\n      return new MicrofrontendsServer({\n        config: config as Config,\n        overrides,\n      });\n    }\n\n    throw new MicrofrontendError(\n      'Invalid config: must be a string or an object',\n      { type: 'config', subtype: 'does_not_match_schema' },\n    );\n  }\n\n  /**\n   * Generates a MicrofrontendsServer instance from the environment.\n   * Uses additional validation that is only available when in a node runtime\n   */\n  static fromEnv({\n    cookies,\n  }: {\n    cookies: { name: string; value: string }[];\n  }): MicrofrontendsServer {\n    return new MicrofrontendsServer({\n      config: MicrofrontendsServer.validate(getConfigStringFromEnv()),\n      overrides: parseOverrides(cookies),\n    });\n  }\n\n  /**\n   * Validates the configuration against the JSON schema\n   */\n  static validate(config: string | Config): Config {\n    if (typeof config === 'string') {\n      const c = validateSchema(config);\n      return c;\n    }\n    return config;\n  }\n\n  /**\n   * Looks up the configuration by inferring the package root and looking for a microfrontends config file. If a file is not found,\n   * it will look for a package in the repository with a microfrontends file that contains the current application\n   * and use that configuration.\n   *\n   * This can return either a Child or Main configuration.\n   */\n  static infer({\n    appName,\n    directory,\n    filePath,\n    cookies,\n  }: {\n    appName?: string;\n    directory?: string;\n    filePath?: string;\n    cookies?: { name: string; value: string }[];\n  } = {}): MicrofrontendsServer {\n    logger.debug('[MFE Config] Starting config inference', {\n      appName,\n      directory: directory || process.cwd(),\n      filePath,\n    });\n\n    if (filePath) {\n      logger.debug('[MFE Config] Using explicit filePath:', filePath);\n      return MicrofrontendsServer.fromFile({\n        filePath,\n        cookies,\n      });\n    }\n\n    try {\n      const packageRoot = findPackageRoot(directory);\n      logger.debug('[MFE Config] Package root:', packageRoot);\n\n      const applicationContext = getApplicationContext({\n        appName,\n        packageRoot,\n      });\n      logger.debug('[MFE Config] Application context:', applicationContext);\n\n      const customConfigFilename =\n        process.env.VC_MICROFRONTENDS_CONFIG_FILE_NAME;\n\n      if (customConfigFilename) {\n        logger.debug(\n          '[MFE Config] Custom config filename from VC_MICROFRONTENDS_CONFIG_FILE_NAME:',\n          customConfigFilename,\n        );\n      }\n\n      // see if we have a config file at the package root\n      const maybeConfig = findConfig({\n        dir: packageRoot,\n        customConfigFilename,\n      });\n      if (maybeConfig) {\n        logger.debug('[MFE Config] Config found at package root:', maybeConfig);\n        return MicrofrontendsServer.fromFile({\n          filePath: maybeConfig,\n          cookies,\n        });\n      }\n\n      // if we don't have a microfrontends configuration file, see if we have another package in the repo that references this one\n      const repositoryRoot = findRepositoryRoot();\n      const isMonorepo = isRepositoryMonorepo({ repositoryRoot });\n      logger.debug(\n        '[MFE Config] Repository root:',\n        repositoryRoot,\n        'Is monorepo:',\n        isMonorepo,\n      );\n\n      const configFromEnv = process.env.VC_MICROFRONTENDS_CONFIG;\n      // the environment variable, if specified, takes precedence over other inference methods\n      if (typeof configFromEnv === 'string') {\n        logger.debug(\n          '[MFE Config] Checking VC_MICROFRONTENDS_CONFIG:',\n          configFromEnv,\n        );\n        const maybeConfigFromEnv = resolve(packageRoot, configFromEnv);\n        if (maybeConfigFromEnv) {\n          logger.debug(\n            '[MFE Config] Config loaded from VC_MICROFRONTENDS_CONFIG:',\n            maybeConfigFromEnv,\n          );\n          return MicrofrontendsServer.fromFile({\n            filePath: maybeConfigFromEnv,\n            cookies,\n          });\n        }\n      } else {\n        // when the VC_MICROFRONTENDS_CONFIG environment variable is not set, try to find the config in the .vercel directory first\n        const vercelDir = join(packageRoot, '.vercel');\n        logger.debug(\n          '[MFE Config] Searching for config in .vercel directory:',\n          vercelDir,\n        );\n        const maybeConfigFromVercel = findConfig({\n          dir: vercelDir,\n          customConfigFilename,\n        });\n        if (maybeConfigFromVercel) {\n          logger.debug(\n            '[MFE Config] Config found in .vercel directory:',\n            maybeConfigFromVercel,\n          );\n          return MicrofrontendsServer.fromFile({\n            filePath: maybeConfigFromVercel,\n            cookies,\n          });\n        }\n\n        if (isMonorepo) {\n          logger.debug(\n            '[MFE Config] Inferring microfrontends location in monorepo for application:',\n            applicationContext.name,\n          );\n          // find the default package\n          const defaultPackage = inferMicrofrontendsLocation({\n            repositoryRoot,\n            applicationContext,\n            customConfigFilename,\n          });\n          logger.debug(\n            '[MFE Config] Inferred package location:',\n            defaultPackage,\n          );\n\n          // see if we have a config file at the package root\n          const maybeConfigFromDefault = findConfig({\n            dir: defaultPackage,\n            customConfigFilename,\n          });\n          if (maybeConfigFromDefault) {\n            logger.debug(\n              '[MFE Config] Config found in inferred package:',\n              maybeConfigFromDefault,\n            );\n            return MicrofrontendsServer.fromFile({\n              filePath: maybeConfigFromDefault,\n              cookies,\n            });\n          }\n          logger.debug('[MFE Config] No config found in inferred package');\n        }\n      }\n      // will be caught below\n      throw new MicrofrontendError(\n        'Unable to automatically infer the location of the `microfrontends.json` file. If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the \"vercel microfrontends pull\" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable. If you suspect this is thrown in error, please reach out to the Vercel team.',\n        { type: 'config', subtype: 'inference_failed' },\n      );\n    } catch (e) {\n      if (e instanceof MicrofrontendError) {\n        throw e;\n      }\n      const errorMessage = e instanceof Error ? e.message : String(e);\n      // we were unable to infer\n      throw new MicrofrontendError(\n        `Unable to locate and parse the \\`microfrontends.json\\` configuration file. Original error message: ${errorMessage}`,\n        { cause: e, type: 'config', subtype: 'inference_failed' },\n      );\n    }\n  }\n\n  /*\n   * Generates a MicrofrontendsServer instance from a file.\n   */\n  static fromFile({\n    filePath,\n    cookies,\n  }: {\n    filePath: string;\n    cookies?: { name: string; value: string }[];\n  }): MicrofrontendsServer {\n    try {\n      logger.debug('[MFE Config] Reading config from file:', filePath);\n      const configJson = fs.readFileSync(filePath, 'utf-8');\n      const config = MicrofrontendsServer.validate(configJson);\n      logger.debug(\n        '[MFE Config] Config loaded with applications:',\n        Object.keys(config.applications),\n      );\n\n      return new MicrofrontendsServer({\n        config,\n        overrides: cookies ? parseOverrides(cookies) : undefined,\n      });\n    } catch (e) {\n      throw MicrofrontendError.handle(e, {\n        fileName: filePath,\n      });\n    }\n  }\n\n  /*\n   * Generates a MicrofrontendsServer instance from a file.\n   */\n  static fromMainConfigFile({\n    filePath,\n    overrides,\n  }: {\n    filePath: string;\n    overrides?: OverridesConfig;\n  }): MicrofrontendsServer {\n    try {\n      const config = fs.readFileSync(filePath, 'utf-8');\n      const validatedConfig = MicrofrontendsServer.validate(config);\n      const [defaultApplication] = Object.entries(validatedConfig.applications)\n        .filter(([, app]) => isDefaultApp(app))\n        .map(([name]) => name);\n      // This should never get hit as MicrofrontendsServer.validate checks this if we're given a main config\n      if (!defaultApplication) {\n        throw new MicrofrontendError(\n          'No default application found. At least one application needs to be the default by omitting routing.',\n          { type: 'config', subtype: 'no_default_application' },\n        );\n      }\n      return new MicrofrontendsServer({\n        config: validatedConfig,\n        overrides,\n      });\n    } catch (e) {\n      throw MicrofrontendError.handle(e, {\n        fileName: filePath,\n      });\n    }\n  }\n}\n\nexport { MicrofrontendsServer, getApplicationContext };\n","export type MicrofrontendErrorType =\n  | 'config'\n  | 'packageJson'\n  | 'vercelJson'\n  | 'application'\n  | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n  | 'not_found'\n  | 'inference_failed'\n  | 'not_found_in_env'\n  | 'invalid_asset_prefix'\n  | 'invalid_main_path'\n  | 'does_not_match_schema'\n  | 'unable_to_read_file'\n  | 'unsupported_validation_env'\n  | 'unsupported_version'\n  | 'invalid_path'\n  | 'invalid_permissions'\n  | 'invalid_syntax'\n  | 'missing_microfrontend_config_path'\n  | 'unsupported_operation';\n\n// A mapping of error types to their subtypes.\ninterface TypeToSubtype {\n  application:\n    | 'invalid_asset_prefix'\n    | 'invalid_path'\n    | 'multiple_package_managers'\n    | 'not_found';\n  config:\n    | 'conflicting_paths'\n    | 'depcrecated_field'\n    | 'does_not_match_schema'\n    | 'invalid_main_path'\n    | 'invalid_preview_deployment_suffix'\n    | 'multiple_default_applications'\n    | 'no_default_application'\n    | 'not_found_in_env'\n    | 'not_found'\n    | 'inference_failed'\n    | 'unable_to_read_file'\n    | 'invalid_syntax'\n    | 'invalid_permissions'\n    | 'unsupported_operation'\n    | 'unsupported_validation_env'\n    | 'unsupported_version';\n  packageJson:\n    | 'missing_field_name'\n    | 'unable_to_read_file'\n    | 'invalid_permissions'\n    | 'invalid_syntax';\n  vercelJson:\n    | 'missing_field_microfrontend_config_path'\n    | 'unable_to_read_file'\n    | 'invalid_permissions'\n    | 'invalid_syntax';\n  unknown: never;\n}\n\nexport type MicrofrontendErrorSource =\n  | '@vercel/microfrontends'\n  | '@vercel/microfrontends/next'\n  | 'fs'\n  | 'ajv';\n\nexport interface MicrofrontendErrorOptions<T extends MicrofrontendErrorType> {\n  cause?: unknown;\n  source?: MicrofrontendErrorSource;\n  type?: T;\n  subtype?: TypeToSubtype[T];\n}\n\ninterface HandleOptions {\n  fileName?: string;\n}\n\nexport class MicrofrontendError<\n  T extends MicrofrontendErrorType = 'unknown',\n> extends Error {\n  public source: MicrofrontendErrorSource;\n  public type: T;\n  public subtype?: TypeToSubtype[T];\n\n  constructor(message: string, opts?: MicrofrontendErrorOptions<T>) {\n    super(message, { cause: opts?.cause });\n    this.name = 'MicrofrontendsError';\n    this.source = opts?.source ?? '@vercel/microfrontends';\n    this.type = opts?.type ?? ('unknown' as T);\n    this.subtype = opts?.subtype;\n    Error.captureStackTrace(this, MicrofrontendError);\n  }\n\n  isKnown(): boolean {\n    return this.type !== 'unknown';\n  }\n\n  isUnknown(): boolean {\n    return !this.isKnown();\n  }\n\n  /**\n   * Converts an error to a MicrofrontendsError.\n   * @param original - The original error to convert.\n   * @returns The converted MicrofrontendsError.\n   */\n  static convert(\n    original: Error,\n    opts?: HandleOptions,\n  ): MicrofrontendError<MicrofrontendErrorType> {\n    if (opts?.fileName) {\n      const err = MicrofrontendError.convertFSError(original, opts.fileName);\n      if (err) {\n        return err;\n      }\n    }\n\n    if (\n      original.message.includes(\n        'Code generation from strings disallowed for this context',\n      )\n    ) {\n      return new MicrofrontendError(original.message, {\n        type: 'config',\n        subtype: 'unsupported_validation_env',\n        source: 'ajv',\n      });\n    }\n\n    // unknown catch-all\n    return new MicrofrontendError(original.message);\n  }\n\n  static convertFSError(\n    original: Error,\n    fileName: string,\n  ): MicrofrontendError<MicrofrontendErrorType> | null {\n    if (original instanceof Error && 'code' in original) {\n      if (original.code === 'ENOENT') {\n        return new MicrofrontendError(`Could not find \"${fileName}\"`, {\n          type: 'config',\n          subtype: 'unable_to_read_file',\n          source: 'fs',\n        });\n      }\n      if (original.code === 'EACCES') {\n        return new MicrofrontendError(\n          `Permission denied while accessing \"${fileName}\"`,\n          {\n            type: 'config',\n            subtype: 'invalid_permissions',\n            source: 'fs',\n          },\n        );\n      }\n    }\n\n    if (original instanceof SyntaxError) {\n      return new MicrofrontendError(\n        `Failed to parse \"${fileName}\": Invalid JSON format.`,\n        {\n          type: 'config',\n          subtype: 'invalid_syntax',\n          source: 'fs',\n        },\n      );\n    }\n\n    return null;\n  }\n\n  /**\n   * Handles an unknown error and returns a MicrofrontendsError instance.\n   * @param err - The error to handle.\n   * @returns A MicrofrontendsError instance.\n   */\n  static handle(\n    err: unknown,\n    opts?: HandleOptions,\n  ): MicrofrontendError<MicrofrontendErrorType> {\n    if (err instanceof MicrofrontendError) {\n      return err as MicrofrontendError<MicrofrontendErrorType>;\n    }\n\n    // handle Error instances\n    if (err instanceof Error) {\n      return MicrofrontendError.convert(err, opts);\n    }\n\n    // handle object errors\n    if (typeof err === 'object' && err !== null) {\n      if ('message' in err && typeof err.message === 'string') {\n        return MicrofrontendError.convert(new Error(err.message), opts);\n      }\n    }\n\n    return new MicrofrontendError('An unknown error occurred');\n  }\n}\n","import { parse } from 'jsonc-parser';\nimport { MicrofrontendError } from '../../errors';\nimport { hashApplicationName } from '../../microfrontends/utils/hash-application-name';\nimport { type OverridesConfig, parseOverrides } from '../../overrides';\nimport type { Config } from '../../schema/types';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\nimport { MicrofrontendConfigClient } from '../client';\nimport type { ClientConfig } from '../client/types';\nimport { getConfigStringFromEnv } from '../utils/get-config-from-env';\nimport { ChildApplication, DefaultApplication } from './application';\nimport {\n  DEFAULT_LOCAL_PROXY_PORT,\n  MFE_LOCAL_PROXY_PORT_ENV,\n} from './constants';\nimport {\n  validateConfigDefaultApplication,\n  validateConfigPaths,\n} from './validation';\n\n/**\n * A class to manage the microfrontends configuration.\n */\nexport class MicrofrontendConfigIsomorphic {\n  config: Config;\n  defaultApplication: DefaultApplication;\n  childApplications: Record<string, ChildApplication> = {};\n  overrides?: OverridesConfig;\n  options?: Config['options'];\n\n  private readonly serialized: {\n    config: Config;\n    overrides?: OverridesConfig;\n  };\n\n  constructor({\n    config,\n    overrides,\n  }: {\n    config: Config;\n    overrides?: OverridesConfig;\n  }) {\n    // run validation on init\n    MicrofrontendConfigIsomorphic.validate(config);\n\n    const disableOverrides = config.options?.disableOverrides ?? false;\n    this.overrides = overrides && !disableOverrides ? overrides : undefined;\n\n    let defaultApplication: DefaultApplication | undefined;\n    // create applications\n    for (const [appId, appConfig] of Object.entries(config.applications)) {\n      const appOverrides = !disableOverrides\n        ? this.overrides?.applications[appId]\n        : undefined;\n\n      if (isDefaultApp(appConfig)) {\n        defaultApplication = new DefaultApplication(appId, {\n          app: appConfig,\n          overrides: appOverrides,\n        });\n      } else {\n        this.childApplications[appId] = new ChildApplication(appId, {\n          app: appConfig,\n          overrides: appOverrides,\n        });\n      }\n    }\n\n    // validate that this.defaultApplication is defined\n    if (!defaultApplication) {\n      throw new MicrofrontendError(\n        'Could not find default application in microfrontends configuration',\n        {\n          type: 'application',\n          subtype: 'not_found',\n        },\n      );\n    }\n    this.defaultApplication = defaultApplication;\n\n    this.config = config;\n    this.options = config.options;\n    this.serialized = {\n      config,\n      overrides,\n    };\n  }\n\n  static validate(config: string | Config): Config {\n    // let this throw if it's not valid JSON\n    const c = typeof config === 'string' ? (parse(config) as Config) : config;\n\n    validateConfigPaths(c.applications);\n    validateConfigDefaultApplication(c.applications);\n\n    return c;\n  }\n\n  static fromEnv({\n    cookies,\n  }: {\n    cookies?: { name: string; value: string }[];\n  }): MicrofrontendConfigIsomorphic {\n    return new MicrofrontendConfigIsomorphic({\n      config: parse(getConfigStringFromEnv()) as Config,\n      overrides: parseOverrides(cookies ?? []),\n    });\n  }\n\n  isOverridesDisabled(): boolean {\n    return this.options?.disableOverrides ?? false;\n  }\n\n  getConfig(): Config {\n    return this.config;\n  }\n\n  getApplicationsByType(): {\n    defaultApplication?: DefaultApplication;\n    applications: ChildApplication[];\n  } {\n    return {\n      defaultApplication: this.defaultApplication,\n      applications: Object.values(this.childApplications),\n    };\n  }\n\n  getChildApplications(): ChildApplication[] {\n    return Object.values(this.childApplications);\n  }\n\n  getAllApplications(): (DefaultApplication | ChildApplication)[] {\n    return [\n      this.defaultApplication,\n      ...Object.values(this.childApplications),\n    ].filter(Boolean);\n  }\n\n  getApplication(name: string): DefaultApplication | ChildApplication {\n    // check the default\n    if (\n      this.defaultApplication.name === name ||\n      this.defaultApplication.packageName === name\n    ) {\n      return this.defaultApplication;\n    }\n    const app =\n      this.childApplications[name] ||\n      Object.values(this.childApplications).find(\n        (child) => child.packageName === name,\n      );\n    if (!app) {\n      throw new MicrofrontendError(\n        `Could not find microfrontends configuration for application \"${name}\". If the name in package.json differs from your Vercel Project name, set the \\`packageName\\` field for the application in \\`microfrontends.json\\` to ensure that the configuration can be found locally.`,\n        {\n          type: 'application',\n          subtype: 'not_found',\n        },\n      );\n    }\n\n    return app;\n  }\n\n  hasApplication(name: string): boolean {\n    try {\n      this.getApplication(name);\n      return true;\n    } catch {\n      return false;\n    }\n  }\n\n  getApplicationByProjectName(\n    projectName: string,\n  ): DefaultApplication | ChildApplication | undefined {\n    // check the default\n    if (this.defaultApplication.name === projectName) {\n      return this.defaultApplication;\n    }\n\n    return Object.values(this.childApplications).find(\n      (app) => app.name === projectName,\n    );\n  }\n\n  /**\n   * Returns the default application.\n   */\n  getDefaultApplication(): DefaultApplication {\n    return this.defaultApplication;\n  }\n\n  /**\n   * Returns the configured port for the local proxy.\n   * Can be overridden via MFE_LOCAL_PROXY_PORT environment variable.\n   */\n  getLocalProxyPort(): number {\n    // Check for port override via environment variable\n    const portOverride = process.env[MFE_LOCAL_PROXY_PORT_ENV];\n    if (portOverride) {\n      const port = Number.parseInt(portOverride, 10);\n      if (!Number.isNaN(port) && port > 0 && port < 65536) {\n        return port;\n      }\n    }\n    return this.config.options?.localProxyPort ?? DEFAULT_LOCAL_PROXY_PORT;\n  }\n\n  toClientConfig(options?: {\n    removeFlaggedPaths?: boolean;\n  }): MicrofrontendConfigClient {\n    const applications: ClientConfig['applications'] = Object.fromEntries(\n      Object.entries(this.childApplications).map(([name, application]) => [\n        hashApplicationName(name),\n        {\n          default: false,\n          routing: application.routing,\n        },\n      ]),\n    );\n\n    applications[hashApplicationName(this.defaultApplication.name)] = {\n      default: true,\n    };\n\n    return new MicrofrontendConfigClient(\n      {\n        applications,\n      },\n      {\n        removeFlaggedPaths: options?.removeFlaggedPaths,\n      },\n    );\n  }\n\n  /**\n   * Serializes the class back to the Schema type.\n   *\n   * NOTE: This is used when writing the config to disk and must always match the input Schema\n   */\n  toSchemaJson(): Config {\n    return this.serialized.config;\n  }\n\n  serialize(): {\n    config: Config;\n    overrides?: OverridesConfig;\n  } {\n    return this.serialized;\n  }\n}\n","import md5 from 'md5';\n\nexport function hashApplicationName(name: string): string {\n  if (!name) {\n    throw new Error('Application name is required to generate hash');\n  }\n\n  return md5(name).substring(0, 6).padStart(6, '0');\n}\n","// cookie name needs to match proxy\n// https://github.com/vercel/proxy/blob/fb00d723136ad539a194e4a851dd272010527c35/lib/routing/micro_frontends_overrides.lua#L7\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\nexport const OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n","import { OVERRIDES_COOKIE_PREFIX } from './constants';\n\nexport function isOverrideCookie(cookie: { name?: string }): boolean {\n  return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n}\n","import { OVERRIDES_ENV_COOKIE_PREFIX } from './constants';\nimport { isOverrideCookie } from './is-override-cookie';\n\nexport function getOverrideFromCookie(cookie: {\n  name: string;\n  value?: string | null;\n}): { application: string; host: string } | undefined {\n  if (!isOverrideCookie(cookie) || !cookie.value) return;\n  return {\n    application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ''),\n    host: cookie.value,\n  };\n}\n","import { getOverrideFromCookie } from './get-override-from-cookie';\nimport type { OverridesConfig } from './types';\n\nexport function parseOverrides(\n  cookies: { name: string; value?: string | null }[],\n): OverridesConfig {\n  const overridesConfig: OverridesConfig = { applications: {} };\n\n  cookies.forEach((cookie) => {\n    const override = getOverrideFromCookie(cookie);\n    if (!override) return;\n    overridesConfig.applications[override.application] = {\n      environment: { host: override.host },\n    };\n  });\n\n  return overridesConfig;\n}\n","import type { Application, DefaultApplication } from '../types';\n\nexport function isDefaultApp(a: Application): a is DefaultApplication {\n  return !('routing' in a);\n}\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\nexport interface MicrofrontendConfigClientOptions {\n  removeFlaggedPaths?: boolean;\n}\n\nconst regexpCache = new Map<string, RegExp>();\nconst getRegexp = (path: string): RegExp => {\n  const existing = regexpCache.get(path);\n  if (existing) {\n    return existing;\n  }\n\n  const regexp = pathToRegexp(path);\n  regexpCache.set(path, regexp);\n  return regexp;\n};\n\nexport class MicrofrontendConfigClient {\n  applications: ClientConfig['applications'];\n  hasFlaggedPaths: boolean;\n  pathCache: Record<string, string> = {};\n  private readonly serialized: ClientConfig;\n\n  constructor(config: ClientConfig, opts?: MicrofrontendConfigClientOptions) {\n    this.hasFlaggedPaths = config.hasFlaggedPaths ?? false;\n    for (const app of Object.values(config.applications)) {\n      if (app.routing) {\n        if (app.routing.some((match) => match.flag)) {\n          this.hasFlaggedPaths = true;\n        }\n        const newRouting = [];\n        const pathsWithoutFlags = [];\n        for (const group of app.routing) {\n          if (group.flag) {\n            if (opts?.removeFlaggedPaths) {\n              continue;\n            }\n            if (group.group) {\n              delete group.group;\n            }\n            newRouting.push(group);\n          } else {\n            pathsWithoutFlags.push(...group.paths);\n          }\n        }\n        if (pathsWithoutFlags.length > 0) {\n          newRouting.push({ paths: pathsWithoutFlags });\n        }\n        app.routing = newRouting;\n      }\n    }\n    this.serialized = config;\n    if (this.hasFlaggedPaths) {\n      this.serialized.hasFlaggedPaths = this.hasFlaggedPaths;\n    }\n    this.applications = config.applications;\n  }\n\n  /**\n   * Create a new `MicrofrontendConfigClient` from a JSON string.\n   * Config must be passed in to remain framework agnostic\n   */\n  static fromEnv(config: string | undefined): MicrofrontendConfigClient {\n    if (!config) {\n      throw new Error(\n        'Could not construct MicrofrontendConfigClient: configuration is empty or undefined. Did you set up your application with `withMicrofrontends`? Is the local proxy running and this application is being accessed via the proxy port? See https://vercel.com/docs/microfrontends/local-development#setting-up-microfrontends-proxy',\n      );\n    }\n    return new MicrofrontendConfigClient(JSON.parse(config) as ClientConfig);\n  }\n\n  isEqual(other: MicrofrontendConfigClient): boolean {\n    return (\n      this === other ||\n      JSON.stringify(this.applications) === JSON.stringify(other.applications)\n    );\n  }\n\n  getApplicationNameForPath(path: string): string | null {\n    if (!path.startsWith('/')) {\n      throw new Error(`Path must start with a /`);\n    }\n\n    if (this.pathCache[path]) {\n      return this.pathCache[path];\n    }\n\n    const pathname = new URL(path, 'https://example.com').pathname;\n    for (const [name, application] of Object.entries(this.applications)) {\n      if (application.routing) {\n        for (const group of application.routing) {\n          for (const childPath of group.paths) {\n            const regexp = getRegexp(childPath);\n            if (regexp.test(pathname)) {\n              this.pathCache[path] = name;\n              return name;\n            }\n          }\n        }\n      }\n    }\n    const defaultApplication = Object.entries(this.applications).find(\n      ([, application]) => application.default,\n    );\n    if (!defaultApplication) {\n      return null;\n    }\n\n    this.pathCache[path] = defaultApplication[0];\n    return defaultApplication[0];\n  }\n\n  serialize(): ClientConfig {\n    return this.serialized;\n  }\n}\n","import { MicrofrontendError } from '../../errors';\n\n/**\n * Utility to fetch the microfrontend configuration string from the environment.\n */\nexport function getConfigStringFromEnv(): string {\n  const config = process.env.MFE_CONFIG;\n  if (!config) {\n    throw new MicrofrontendError(`Missing \"MFE_CONFIG\" in environment.`, {\n      type: 'config',\n      subtype: 'not_found_in_env',\n    });\n  }\n  return config;\n}\n","import fs from 'node:fs';\nimport { join } from 'node:path';\nimport { getPossibleConfigurationFilenames } from './get-config-file-name';\n\nexport function findConfig({\n  dir,\n  customConfigFilename,\n}: {\n  dir: string;\n  customConfigFilename: string | undefined;\n}): string | null {\n  for (const filename of getPossibleConfigurationFilenames({\n    customConfigFilename,\n  })) {\n    const maybeConfig = join(dir, filename);\n    if (fs.existsSync(maybeConfig)) {\n      return maybeConfig;\n    }\n  }\n\n  return null;\n}\n","// ordered by most likely to be the correct one\nconst DEFAULT_CONFIGURATION_FILENAMES = [\n  'microfrontends.json',\n  'microfrontends.jsonc',\n] as const;\n\nexport function getPossibleConfigurationFilenames({\n  customConfigFilename,\n}: {\n  // from env\n  customConfigFilename: string | undefined;\n}) {\n  if (customConfigFilename) {\n    if (\n      !customConfigFilename.endsWith('.json') &&\n      !customConfigFilename.endsWith('.jsonc')\n    ) {\n      throw new Error(\n        `Found VC_MICROFRONTENDS_CONFIG_FILE_NAME but the name is invalid. Received: ${customConfigFilename}.` +\n          ` The file name must end with '.json' or '.jsonc'.` +\n          ` It's also possible for the env var to include the path, eg microfrontends-dev.json or /path/to/microfrontends-dev.json.`,\n      );\n    }\n    return Array.from(\n      new Set([customConfigFilename, ...DEFAULT_CONFIGURATION_FILENAMES]),\n    );\n  }\n  return DEFAULT_CONFIGURATION_FILENAMES;\n}\n","import { hashApplicationName } from './hash-application-name';\n\nconst PREFIX = 'vc-ap';\n\nexport function generateDefaultAssetPrefixFromName({\n  name,\n}: {\n  name: string;\n}): string {\n  if (!name) {\n    throw new Error('Name is required to generate an asset prefix');\n  }\n\n  return `${PREFIX}-${hashApplicationName(name)}`;\n}\n","import { readFileSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport fg from 'fast-glob';\nimport { parse } from 'jsonc-parser';\nimport { logger } from '../../../bin/logger';\nimport { MicrofrontendError } from '../../errors';\nimport type { Config } from '../../schema/types';\nimport type { ApplicationContext } from './get-application-context';\nimport { getPossibleConfigurationFilenames } from './get-config-file-name';\n\n// cache the path to default configuration to avoid having to walk the file system multiple times\nconst configCache: Record<string, string> = {};\n\ninterface FindDefaultMicrofrontendPackageArgs {\n  repositoryRoot: string;\n  applicationContext: ApplicationContext;\n  customConfigFilename: string | undefined;\n}\n\n/**\n * Given a repository root and a package name, find the path to the package.json file with the\n * given name.\n *\n * This method uses globby to find all package.json files and then reads them in parallel\n */\nfunction findPackageWithMicrofrontendsConfig({\n  repositoryRoot,\n  applicationContext,\n  customConfigFilename,\n}: FindDefaultMicrofrontendPackageArgs): string | null {\n  const applicationName = applicationContext.name;\n  logger.debug(\n    '[MFE Config] Searching repository for configs containing application:',\n    applicationName,\n  );\n\n  try {\n    const microfrontendsJsonPaths = fg.globSync(\n      `**/{${getPossibleConfigurationFilenames({ customConfigFilename }).join(',')}}`,\n      {\n        cwd: repositoryRoot,\n        absolute: true,\n        onlyFiles: true,\n        followSymbolicLinks: false,\n        ignore: ['**/node_modules/**', '**/.git/**'],\n      },\n    );\n\n    logger.debug(\n      '[MFE Config] Found',\n      microfrontendsJsonPaths.length,\n      'config file(s) in repository',\n    );\n\n    const matchingPaths: string[] = [];\n    for (const microfrontendsJsonPath of microfrontendsJsonPaths) {\n      if (\n        doesApplicationExistInConfig(microfrontendsJsonPath, applicationName)\n      ) {\n        matchingPaths.push(microfrontendsJsonPath);\n      }\n    }\n\n    logger.debug(\n      '[MFE Config] Total matching config files:',\n      matchingPaths.length,\n    );\n\n    if (matchingPaths.length > 1) {\n      throw new MicrofrontendError(\n        `Found multiple \\`microfrontends.json\\` files in the repository referencing the application \"${applicationName}\", but only one is allowed.\\n${matchingPaths.join('\\n  • ')}`,\n        { type: 'config', subtype: 'inference_failed' },\n      );\n    }\n\n    if (matchingPaths.length === 0) {\n      if (\n        repositoryRoot &&\n        doesMisplacedConfigExist(\n          repositoryRoot,\n          applicationName,\n          customConfigFilename,\n        )\n      ) {\n        logger.debug(\n          '[MFE Config] Found misplaced config in wrong .vercel directory in repository',\n        );\n        const misplacedConfigPath = join(\n          repositoryRoot,\n          '.vercel',\n          customConfigFilename || 'microfrontends.json',\n        );\n        throw new MicrofrontendError(\n          `Unable to automatically infer the location of the \\`microfrontends.json\\` file.\\n\\n` +\n            `A microfrontends config was found in the \\`.vercel\\` directory at the repository root: ${misplacedConfigPath}\\n` +\n            `However, in a monorepo, the config file should be placed in the \\`.vercel\\` directory in your application directory instead.\\n\\n` +\n            `To fix this:\\n` +\n            `1. If using \\`vercel link\\`, run it with \\`vercel link --repo\\` to handle monorepos, or run \\`vercel microfrontends pull --cwd=<application-directory>\\` to make sure it pulls the \\`microfrontends.json\\` file to the correct location\\n` +\n            `2. If manually defined, move the config file to the \\`.vercel\\` directory in your application\\n` +\n            `3. Alternatively, set the VC_MICROFRONTENDS_CONFIG environment variable to the correct path\\n\\n` +\n            `For more information, see: https://vercel.com/docs/cli/project-linking`,\n          { type: 'config', subtype: 'inference_failed' },\n        );\n      }\n\n      let additionalErrorMessage = '';\n      if (microfrontendsJsonPaths.length > 0) {\n        if (!applicationContext.projectName) {\n          additionalErrorMessage = `\\n\\nIf the name in package.json (${applicationContext.packageJsonName}) differs from your Vercel Project name, set the \\`packageName\\` field for the application in \\`microfrontends.json\\` to ensure that the configuration can be found locally.`;\n        } else {\n          additionalErrorMessage = `\\n\\nNames of applications in \\`microfrontends.json\\` must match the Vercel Project name (${applicationContext.projectName}).`;\n        }\n      }\n      throw new MicrofrontendError(\n        `Could not find a \\`microfrontends.json\\` file in the repository that contains the \"${applicationName}\" application.${additionalErrorMessage}\\n\\n` +\n          `If your Vercel Microfrontends configuration is not in this repository, you can use the Vercel CLI to pull the Vercel Microfrontends configuration using the \"vercel microfrontends pull\" command, or you can specify the path manually using the VC_MICROFRONTENDS_CONFIG environment variable.\\n\\n` +\n          `If your Vercel Microfrontends configuration has a custom name, ensure the VC_MICROFRONTENDS_CONFIG_FILE_NAME environment variable is set, you can pull the vercel project environment variables using the \"vercel env pull\" command.\\n\\n` +\n          `If you suspect this is thrown in error, please reach out to the Vercel team.`,\n        { type: 'config', subtype: 'inference_failed' },\n      );\n    }\n\n    const [packageJsonPath] = matchingPaths as [string];\n    return dirname(packageJsonPath);\n  } catch (error) {\n    if (error instanceof MicrofrontendError) {\n      throw error;\n    }\n    return null;\n  }\n}\n\n/**\n * Given a repository root and a package name, find the path to the package directory with\n * a microfrontends config that contains the given name in its applications.\n */\nexport function inferMicrofrontendsLocation(\n  opts: FindDefaultMicrofrontendPackageArgs,\n): string {\n  // cache this with name to support multiple configurations in the same repository\n  const cacheKey = `${opts.repositoryRoot}-${opts.applicationContext.name}${opts.customConfigFilename ? `-${opts.customConfigFilename}` : ''}`;\n\n  // Check if we have a cached result\n  if (configCache[cacheKey]) {\n    return configCache[cacheKey];\n  }\n\n  const result = findPackageWithMicrofrontendsConfig(opts);\n\n  if (!result) {\n    throw new MicrofrontendError(\n      `Could not infer the location of the \\`microfrontends.json\\` file for application \"${opts.applicationContext.name}\" starting in directory \"${opts.repositoryRoot}\".`,\n      { type: 'config', subtype: 'inference_failed' },\n    );\n  }\n\n  // Cache the result\n  configCache[cacheKey] = result;\n  return result;\n}\n\nfunction existsSync(path: string): boolean {\n  try {\n    statSync(path);\n    return true;\n  } catch (_) {\n    return false;\n  }\n}\n\nfunction doesMisplacedConfigExist(\n  repositoryRoot: string,\n  applicationName: string,\n  customConfigFilename: string | undefined,\n): boolean {\n  logger.debug(\n    '[MFE Config] Looking for misplaced config in wrong .vercel directory',\n  );\n  const misplacedConfigPath = join(\n    repositoryRoot,\n    '.vercel',\n    customConfigFilename || 'microfrontends.json',\n  );\n  return (\n    existsSync(misplacedConfigPath) &&\n    doesApplicationExistInConfig(misplacedConfigPath, applicationName)\n  );\n}\n\nfunction doesApplicationExistInConfig(\n  microfrontendsJsonPath: string,\n  applicationName: string,\n): boolean {\n  try {\n    const microfrontendsJsonContent = readFileSync(\n      microfrontendsJsonPath,\n      'utf-8',\n    );\n    const microfrontendsJson = parse(microfrontendsJsonContent) as Config;\n\n    if (microfrontendsJson.applications[applicationName]) {\n      logger.debug(\n        '[MFE Config] Found application in config:',\n        microfrontendsJsonPath,\n      );\n      return true;\n    }\n\n    for (const [_, app] of Object.entries(microfrontendsJson.applications)) {\n      if (app.packageName === applicationName) {\n        logger.debug(\n          '[MFE Config] Found application via packageName in config:',\n          microfrontendsJsonPath,\n        );\n        return true;\n      }\n    }\n  } catch (error) {\n    logger.debug('[MFE Config] Error checking application in config:', error);\n    // malformed json most likely, skip this file\n  }\n  return false;\n}\n","export const DEFAULT_LOCAL_PROXY_PORT = 3024;\n\n/**\n * Environment variable to override the app port for development.\n * Useful when running multiple worktrees simultaneously.\n * Note: Only works when a single application is running locally.\n */\nexport const MFE_APP_PORT_ENV = 'MFE_APP_PORT';\n\n/**\n * Environment variable to override the local proxy port for development.\n * Useful when running multiple worktrees simultaneously.\n */\nexport const MFE_LOCAL_PROXY_PORT_ENV = 'MFE_LOCAL_PROXY_PORT';\n","export function generatePortFromName({\n  name,\n  minPort = 3000,\n  maxPort = 8000,\n}: {\n  name: string;\n  minPort?: number;\n  maxPort?: number;\n}): number {\n  if (!name) {\n    throw new Error('Name is required to generate a port');\n  }\n\n  // hash the name\n  let hash = 0;\n  for (let i = 0; i < name.length; i++) {\n    hash = (hash << 5) - hash + name.charCodeAt(i);\n    // Convert to 32-bit\n    hash |= 0;\n  }\n  hash = Math.abs(hash);\n\n  // Map the hash to the port range\n  const range = maxPort - minPort;\n  const port = minPort + (hash % range);\n\n  return port;\n}\n","import type {\n  LocalHostConfig as LocalHostConfigSchema,\n  HostConfig as RemoteHostConfigSchema,\n} from '../../../bin/types';\nimport { MFE_APP_PORT_ENV } from './constants';\nimport { generatePortFromName } from './utils/generate-port';\n\ninterface HostOptions {\n  isLocal?: boolean;\n}\n\nexport class Host {\n  protocol: 'http' | 'https';\n  host: string;\n  port?: number;\n  local: boolean | undefined;\n\n  constructor(\n    hostConfig: RemoteHostConfigSchema | string,\n    options?: HostOptions,\n  ) {\n    if (typeof hostConfig === 'string') {\n      ({\n        protocol: this.protocol,\n        host: this.host,\n        port: this.port,\n      } = Host.parseUrl(hostConfig));\n    } else {\n      const { protocol = 'https', host, port } = hostConfig;\n      this.protocol = protocol;\n      this.host = host;\n      this.port = port;\n    }\n    this.local = options?.isLocal;\n  }\n\n  protected static parseUrl(\n    url: string,\n    defaultProtocol = 'https',\n  ): {\n    protocol: Host['protocol'];\n    host: string;\n    port?: number;\n  } {\n    let hostToParse = url;\n    if (!/^https?:\\/\\//.exec(hostToParse)) {\n      hostToParse = `${defaultProtocol}://${hostToParse}`;\n    }\n    const parsed = new URL(hostToParse);\n    if (!parsed.hostname) {\n      throw new Error(Host.getMicrofrontendsError(url, 'requires a host'));\n    }\n    if (parsed.hash) {\n      throw new Error(\n        Host.getMicrofrontendsError(url, 'cannot have a fragment'),\n      );\n    }\n    if (parsed.username || parsed.password) {\n      throw new Error(\n        Host.getMicrofrontendsError(\n          url,\n          'cannot have authentication credentials (username and/or password)',\n        ),\n      );\n    }\n    if (parsed.pathname !== '/') {\n      throw new Error(Host.getMicrofrontendsError(url, 'cannot have a path'));\n    }\n    if (parsed.search) {\n      throw new Error(\n        Host.getMicrofrontendsError(url, 'cannot have query parameters'),\n      );\n    }\n    const protocol = parsed.protocol.slice(0, -1) as Host['protocol'];\n    return {\n      protocol,\n      host: parsed.hostname,\n      port: parsed.port ? Number.parseInt(parsed.port, 10) : undefined,\n    };\n  }\n\n  private static getMicrofrontendsError(url: string, message: string): string {\n    return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;\n  }\n\n  isLocal(): boolean {\n    return this.local || this.host === 'localhost' || this.host === '127.0.0.1';\n  }\n\n  toString(): string {\n    const url = this.toUrl();\n    // strip the trailing slash\n    return url.toString().replace(/\\/$/, '');\n  }\n\n  toUrl(): URL {\n    const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ''}`;\n    return new URL(url);\n  }\n}\n\n/**\n * A Host subclass with defaults for locally running applications\n */\nexport class LocalHost extends Host {\n  constructor({\n    appName,\n    local,\n  }: {\n    appName: string;\n    local?: string | number | LocalHostConfigSchema;\n  }) {\n    // Check for MFE_APP_PORT first - this allows multi-worktree setups\n    // to override the port for the local application\n    const portOverride = process.env[MFE_APP_PORT_ENV];\n    if (portOverride) {\n      const overridePort = Number.parseInt(portOverride, 10);\n      if (\n        !Number.isNaN(overridePort) &&\n        overridePort > 0 &&\n        overridePort < 65536\n      ) {\n        super({\n          protocol: 'http',\n          host: 'localhost',\n          port: overridePort,\n        });\n        return;\n      }\n    }\n\n    let protocol: RemoteHostConfigSchema['protocol'];\n    let host: string | undefined;\n    let port: number | undefined;\n    if (typeof local === 'number') {\n      port = local;\n    } else if (typeof local === 'string') {\n      if (/^\\d+$/.test(local)) {\n        port = Number.parseInt(local, 10);\n      } else {\n        const parsed = Host.parseUrl(local, 'http');\n        protocol = parsed.protocol;\n        host = parsed.host;\n        port = parsed.port;\n      }\n    } else if (local) {\n      protocol = local.protocol;\n      host = local.host;\n      port = local.port;\n    }\n    // set defaults for local\n    super({\n      protocol: protocol ?? 'http',\n      host: host ?? 'localhost',\n      port: port ?? generatePortFromName({ name: appName }),\n    });\n  }\n}\n","/**\n * Generates a per-application automation bypass env var name (e.g. `AUTOMATION_BYPASS_DOCS`).\n *\n * @deprecated Prefer using a single shared `VERCEL_AUTOMATION_BYPASS_SECRET` across all projects.\n * Use this only if each project needs its own distinct bypass secret.\n */\nexport function generateAutomationBypassEnvVarName({\n  name,\n}: {\n  name: string;\n}): string {\n  return `AUTOMATION_BYPASS_${name.toUpperCase().replace(/[^a-zA-Z0-9]/g, '_')}`;\n}\n","import { parse as parsePathRegexp, pathToRegexp } from 'path-to-regexp';\nimport { MicrofrontendError } from '../../errors';\nimport type {\n  ApplicationId,\n  ApplicationRouting,\n  ChildApplication as ChildApplicationConfig,\n  PathGroup,\n} from '../../schema/types';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\n\nconst LIST_FORMATTER = new Intl.ListFormat('en', {\n  style: 'long',\n  type: 'conjunction',\n});\n\nconst VALID_ASSET_PREFIX_REGEXP = /^[a-z](?:[a-z0-9-]*[a-z0-9])?$/;\n\n/**\n * Validate all paths in a configuration - ensures paths do not overlap\n */\nexport const validateConfigPaths = (\n  applicationConfigsById?: ApplicationRouting,\n): void => {\n  if (!applicationConfigsById) {\n    return;\n  }\n\n  const pathsByApplicationId = new Map<\n    PathGroup['paths'][number],\n    {\n      applications: ApplicationId[];\n      matcher: RegExp;\n      applicationId?: ApplicationId;\n    }\n  >();\n  const errors: string[] = [];\n\n  for (const [id, app] of Object.entries(applicationConfigsById)) {\n    if (isDefaultApp(app)) {\n      // default applications do not have routing\n      continue;\n    }\n\n    for (const pathMatch of app.routing) {\n      for (const path of pathMatch.paths) {\n        const maybeError = validatePathExpression(path);\n        if (maybeError) {\n          errors.push(maybeError);\n        } else {\n          const existing = pathsByApplicationId.get(path);\n          if (existing) {\n            existing.applications.push(id);\n          } else {\n            pathsByApplicationId.set(path, {\n              applications: [id],\n              matcher: pathToRegexp(path),\n              applicationId: id,\n            });\n          }\n        }\n      }\n    }\n  }\n  const entries = Array.from(pathsByApplicationId.entries());\n\n  for (const [path, { applications: ids, matcher, applicationId }] of entries) {\n    if (ids.length > 1) {\n      errors.push(\n        `Duplicate path \"${path}\" for applications \"${ids.join(', ')}\"`,\n      );\n    }\n\n    for (const [\n      matchPath,\n      { applications: matchIds, applicationId: matchApplicationId },\n    ] of entries) {\n      if (path === matchPath) {\n        // we're comparing to ourselves, so skip\n        continue;\n      }\n\n      if (applicationId === matchApplicationId) {\n        // we're comparing to paths within our own application, which are allowed to overlap, so skip\n        continue;\n      }\n\n      if (matcher.test(matchPath)) {\n        const source = `\"${path}\" of application${ids.length > 0 ? 's' : ''} ${ids.join(', ')}`;\n        const destination = `\"${matchPath}\" of application${matchIds.length > 0 ? 's' : ''} ${matchIds.join(', ')}`;\n\n        errors.push(\n          `Overlapping path detected between ${source} and ${destination}`,\n        );\n      }\n    }\n  }\n\n  if (errors.length) {\n    throw new MicrofrontendError(\n      `Invalid paths: ${errors.join(', ')}. See supported paths in the documentation https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.`,\n      {\n        type: 'config',\n        subtype: 'conflicting_paths',\n      },\n    );\n  }\n};\n\n// From https://github.com/pillarjs/path-to-regexp/blob/75a92c3d7c42159f459ab42f346899152906ea8c/src/index.ts#L183-L184\nconst PATH_DEFAULT_PATTERNS = ['[^\\\\/#\\\\?]+?', '(?:(?!\\\\.)[^\\\\/#\\\\?])+?'];\n\nfunction validatePathExpression(path: string): string | undefined {\n  try {\n    const tokens = parsePathRegexp(path);\n    if (/(?<!\\\\)\\{/.test(path)) {\n      return `Optional paths are not supported: ${path}`;\n    }\n    if (/(?<!\\\\|\\()\\?/.test(path)) {\n      return `Optional paths are not supported: ${path}`;\n    }\n    if (/\\/[^/]*(?<!\\\\):[^/]*(?<!\\\\):[^/]*/.test(path)) {\n      return `Only one wildcard is allowed per path segment: ${path}`;\n    }\n    for (let i = 0; i < tokens.length; i++) {\n      const token = tokens[i];\n      if (token === undefined) {\n        return `token ${i} in ${path} is undefined, this shouldn't happen`;\n      }\n      if (typeof token !== 'string') {\n        if (!token.name) {\n          return `Only named wildcards are allowed: ${path} (hint: add \":path\" to the wildcard)`;\n        }\n        if (\n          !PATH_DEFAULT_PATTERNS.includes(token.pattern) &&\n          // Allows (a|b|c) and ((?!a|b|c).*) regex\n          // Only limited regex is supported for now, due to performance considerations\n          // Allows all letters, numbers, and hyphens. Other characters must be escaped.\n          !/^(?<allowed>[\\w-~]+(?:\\|[^:|()]+)+)$|^\\(\\?!(?<disallowed>[\\w-~]+(?:\\|[^:|()]+)*)\\)\\.\\*$/.test(\n            token.pattern.replace(/\\\\./g, ''),\n          )\n        ) {\n          return `Path ${path} cannot use unsupported regular expression wildcard. If the path includes special characters, they must be escaped with backslash (e.g. '\\\\(')`;\n        }\n        if (token.modifier && i !== tokens.length - 1) {\n          return `Modifier ${token.modifier} is not allowed on wildcard :${token.name} in ${path}. Modifiers are only allowed in the last path component`;\n        }\n      }\n    }\n  } catch (e) {\n    const message = e instanceof Error ? e.message : String(e);\n    return `Path ${path} could not be parsed into regexp: ${message}`;\n  }\n  return undefined;\n}\n\n/**\n * Validate all paths in an application - ensures paths are the correct format\n */\nexport const validateAppPaths = (\n  name: string,\n  app: ChildApplicationConfig,\n): void => {\n  // validate routes\n  for (const group of app.routing) {\n    for (const p of group.paths) {\n      if (p === '/') {\n        continue;\n      }\n      if (p.endsWith('/')) {\n        throw new MicrofrontendError(\n          `Invalid path for application \"${name}\". ${p} must not end with a slash.`,\n          { type: 'application', subtype: 'invalid_path' },\n        );\n      }\n\n      if (!p.startsWith('/')) {\n        throw new MicrofrontendError(\n          `Invalid path for application \"${name}\". ${p} must start with a slash.`,\n          { type: 'application', subtype: 'invalid_path' },\n        );\n      }\n    }\n  }\n  if (app.assetPrefix) {\n    if (!VALID_ASSET_PREFIX_REGEXP.test(app.assetPrefix)) {\n      throw new MicrofrontendError(\n        `Invalid asset prefix for application \"${name}\". ${app.assetPrefix} must start with a lowercase letter and contain only lowercase letters, numbers, and hyphens.`,\n        { type: 'application', subtype: 'invalid_asset_prefix' },\n      );\n    }\n    if (\n      app.assetPrefix !== `vc-ap-${name}` &&\n      !app.routing.some(\n        (group) =>\n          group.paths.includes(`/${app.assetPrefix}/:path*`) && !group.flag,\n      )\n    ) {\n      throw new MicrofrontendError(\n        `When \\`assetPrefix\\` is specified, \\`/${app.assetPrefix}/:path*\\` must be added the routing paths for the application. Changing the asset prefix is not a forwards and backwards compatible change, and the custom asset prefix should be added to \\`paths\\` and deployed before setting the \\`assetPrefix\\` field.`,\n        { type: 'application', subtype: 'invalid_asset_prefix' },\n      );\n    }\n  }\n};\n\n/**\n * Make sure only one `Application` defines routing\n * */\nexport const validateConfigDefaultApplication = (\n  applicationConfigsById?: ApplicationRouting,\n): void => {\n  if (!applicationConfigsById) {\n    return;\n  }\n\n  const applicationsWithoutRouting = Object.entries(\n    applicationConfigsById,\n  ).filter(([, app]) => isDefaultApp(app));\n  const numApplicationsWithoutRouting = applicationsWithoutRouting.reduce(\n    (acc) => {\n      return acc + 1;\n    },\n    0,\n  );\n\n  if (numApplicationsWithoutRouting === 0) {\n    throw new MicrofrontendError(\n      'No default application found. At least one application needs to be the default by omitting routing.',\n      { type: 'config', subtype: 'no_default_application' },\n    );\n  }\n\n  if (numApplicationsWithoutRouting > 1) {\n    const applicationNamesMissingRouting = applicationsWithoutRouting.map(\n      ([name]) => name,\n    );\n    throw new MicrofrontendError(\n      `All applications except for the default app must contain the \"routing\" field. Applications that are missing routing: ${LIST_FORMATTER.format(applicationNamesMissingRouting)}.`,\n      { type: 'config', subtype: 'multiple_default_applications' },\n    );\n  }\n};\n","import { generateDefaultAssetPrefixFromName } from '../../microfrontends/utils';\nimport type { ApplicationOverrideConfig } from '../../overrides';\nimport type {\n  Application as ApplicationConfig,\n  ChildApplication as ChildApplicationConfig,\n  DefaultApplication as DefaultApplicationConfig,\n  PathGroup,\n} from '../../schema/types';\nimport { Host, LocalHost } from './host';\nimport { generateAutomationBypassEnvVarName } from './utils/generate-automation-bypass-env-var-name';\nimport { validateAppPaths } from './validation';\n\nexport class Application {\n  readonly default: boolean;\n  name: string;\n  development: {\n    local: LocalHost;\n    fallback?: Host;\n  };\n  fallback?: Host;\n  packageName?: string;\n  overrides?: {\n    environment?: Host;\n  };\n  readonly serialized: ApplicationConfig;\n\n  constructor(\n    name: string,\n    {\n      app,\n      overrides,\n      isDefault,\n    }: {\n      app: ApplicationConfig;\n      overrides?: ApplicationOverrideConfig;\n      isDefault?: boolean;\n    },\n  ) {\n    this.name = name;\n    this.development = {\n      local: new LocalHost({\n        appName: name,\n        local: app.development?.local,\n      }),\n      fallback: app.development?.fallback\n        ? new Host(app.development.fallback)\n        : undefined,\n    };\n    if (app.development?.fallback) {\n      this.fallback = new Host(app.development.fallback);\n    }\n    this.packageName = app.packageName;\n    this.overrides = overrides?.environment\n      ? {\n          environment: new Host(overrides.environment),\n        }\n      : undefined;\n    this.default = isDefault ?? false;\n    this.serialized = app;\n  }\n\n  isDefault(): boolean {\n    return this.default;\n  }\n\n  getAssetPrefix(): string {\n    const generatedAssetPrefix = generateDefaultAssetPrefixFromName({\n      name: this.name,\n    });\n    if ('assetPrefix' in this.serialized) {\n      return this.serialized.assetPrefix ?? generatedAssetPrefix;\n    }\n    return generatedAssetPrefix;\n  }\n\n  /** @deprecated Prefer `VERCEL_AUTOMATION_BYPASS_SECRET`. Use this only if each project needs its own distinct bypass secret. */\n  getAutomationBypassEnvVarName(): string {\n    return generateAutomationBypassEnvVarName({ name: this.name });\n  }\n\n  serialize(): ApplicationConfig {\n    return this.serialized;\n  }\n}\n\nexport class DefaultApplication extends Application {\n  readonly default = true;\n  fallback: Host;\n\n  constructor(\n    name: string,\n    {\n      app,\n      overrides,\n    }: {\n      app: DefaultApplicationConfig;\n      overrides?: ApplicationOverrideConfig;\n    },\n  ) {\n    super(name, {\n      app,\n      overrides,\n      isDefault: true,\n    });\n\n    this.fallback = new Host(app.development.fallback);\n  }\n\n  getAssetPrefix(): string {\n    return '';\n  }\n}\n\nexport class ChildApplication extends Application {\n  readonly default = false;\n  routing: PathGroup[];\n\n  constructor(\n    name: string,\n    {\n      app,\n      overrides,\n    }: {\n      app: ChildApplicationConfig;\n      overrides?: ApplicationOverrideConfig;\n    },\n  ) {\n    // validate\n    ChildApplication.validate(name, app);\n\n    super(name, {\n      app,\n      overrides,\n      isDefault: false,\n    });\n\n    this.routing = app.routing;\n  }\n\n  static validate(name: string, app: ChildApplicationConfig): void {\n    // validate routes\n    validateAppPaths(name, app);\n  }\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nconst PACKAGE_JSON = 'package.json';\n\n/**\n * Find the package root by looking for the closest package.json.\n *\n */\nexport function findPackageRoot(startDir?: string): string {\n  let currentDir = startDir || process.cwd();\n\n  while (currentDir !== path.parse(currentDir).root) {\n    const pkgJsonPath = path.join(currentDir, PACKAGE_JSON);\n\n    // Check for a .git directory (not a file)\n    if (fs.existsSync(pkgJsonPath)) {\n      return currentDir;\n    }\n\n    currentDir = path.dirname(currentDir);\n  }\n\n  throw new Error(\n    `The root of the package that contains the \\`package.json\\` file for the \\`${startDir}\\` directory could not be found.`,\n  );\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nconst GIT_DIRECTORY = '.git';\n\nfunction hasGitDirectory(dir: string): boolean {\n  const gitPath = path.join(dir, GIT_DIRECTORY);\n\n  // Check for a .git directory (not a file)\n  return fs.existsSync(gitPath) && fs.statSync(gitPath).isDirectory();\n}\n\nfunction hasPnpmWorkspaces(dir: string): boolean {\n  return fs.existsSync(path.join(dir, 'pnpm-workspace.yaml'));\n}\n\nfunction hasPackageJson(dir: string): boolean {\n  return fs.existsSync(path.join(dir, 'package.json'));\n}\n\n/**\n * Find the root of the repository by looking for a `.git` directory or pnpm workspace.\n * If neither is found, falls back to the topmost directory containing a package.json file.\n * This should work with submodules as well as it verifies that the `.git` directory is a\n * directory and not a file.\n */\nexport function findRepositoryRoot(startDir?: string): string {\n  if (process.env.NX_WORKSPACE_ROOT) {\n    // Trust NX's workspace root here so we don't have to rely on finding a .git\n    // directory. There are some places (like the `vercel deploy` CLI command)\n    // where the .git directory doesn't exist.\n    return process.env.NX_WORKSPACE_ROOT;\n  }\n\n  let currentDir = startDir || process.cwd();\n  let lastPackageJsonDir: string | null = null;\n\n  while (currentDir !== path.parse(currentDir).root) {\n    if (hasGitDirectory(currentDir) || hasPnpmWorkspaces(currentDir)) {\n      return currentDir;\n    }\n\n    if (hasPackageJson(currentDir)) {\n      lastPackageJsonDir = currentDir;\n    }\n\n    currentDir = path.dirname(currentDir);\n  }\n\n  // If we found a package.json directory, use that as the root\n  if (lastPackageJsonDir) {\n    return lastPackageJsonDir;\n  }\n\n  throw new Error(\n    `Could not find the root of the repository for ${startDir}. Please ensure that the directory is part of a Git repository. If you suspect that this should work, please file an issue to the Vercel team.`,\n  );\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../../../bin/logger';\nimport { MicrofrontendError } from '../../errors';\n\nexport interface ApplicationContext {\n  name: string;\n  projectName?: string;\n  packageJsonName?: string;\n}\n\n/**\n * Returns the application name and any additional context that we need.\n */\nexport function getApplicationContext(opts?: {\n  appName?: string;\n  packageRoot?: string;\n}): ApplicationContext {\n  if (opts?.appName) {\n    logger.debug(\n      '[MFE Config] Application name from appName parameter:',\n      opts.appName,\n    );\n    return { name: opts.appName };\n  }\n\n  if (process.env.VERCEL_PROJECT_NAME) {\n    logger.debug(\n      '[MFE Config] Application name from VERCEL_PROJECT_NAME:',\n      process.env.VERCEL_PROJECT_NAME,\n    );\n    return {\n      name: process.env.VERCEL_PROJECT_NAME,\n      projectName: process.env.VERCEL_PROJECT_NAME,\n    };\n  }\n\n  // If this is NX, there are many different places the name can be and they\n  // might not even have a package.json. Use the environment variable, which\n  // relies on NX's logic to find the name.\n  if (process.env.NX_TASK_TARGET_PROJECT) {\n    logger.debug(\n      '[MFE Config] Application name from NX_TASK_TARGET_PROJECT:',\n      process.env.NX_TASK_TARGET_PROJECT,\n    );\n    return {\n      name: process.env.NX_TASK_TARGET_PROJECT,\n      packageJsonName: process.env.NX_TASK_TARGET_PROJECT,\n    };\n  }\n\n  try {\n    const vercelProjectJsonPath = fs.readFileSync(\n      path.join(opts?.packageRoot || '.', '.vercel', 'project.json'),\n      'utf-8',\n    );\n    const projectJson = JSON.parse(vercelProjectJsonPath) as {\n      projectName?: string;\n    };\n    if (projectJson.projectName) {\n      logger.debug(\n        '[MFE Config] Application name from .vercel/project.json:',\n        projectJson.projectName,\n      );\n      return {\n        name: projectJson.projectName,\n        projectName: projectJson.projectName,\n      };\n    }\n  } catch (_) {\n    // If we couldn't read the .vercel/project.json file, fall back to the package.json\n  }\n\n  try {\n    // load the package.json for the application\n    const packageJsonString = fs.readFileSync(\n      path.join(opts?.packageRoot || '.', 'package.json'),\n      'utf-8',\n    );\n    const packageJson = JSON.parse(packageJsonString) as { name?: string };\n\n    if (!packageJson.name) {\n      throw new MicrofrontendError(\n        `package.json file missing required field \"name\"`,\n        {\n          type: 'packageJson',\n          subtype: 'missing_field_name',\n          source: '@vercel/microfrontends/next',\n        },\n      );\n    }\n\n    logger.debug(\n      '[MFE Config] Application name from package.json:',\n      packageJson.name,\n    );\n    return { name: packageJson.name, packageJsonName: packageJson.name };\n  } catch (err) {\n    throw MicrofrontendError.handle(err, {\n      fileName: 'package.json',\n    });\n  }\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport { logger } from '../../../bin/logger';\n\n/**\n * Given a repository root, determine if the repository is using the workspace feature of any package manager.\n *\n * Supports npm, yarn, pnpm, bun, and vlt\n */\nexport function isMonorepo({\n  repositoryRoot,\n}: {\n  repositoryRoot: string;\n}): boolean {\n  try {\n    // pnpm can be validated just by the existence of the pnpm-workspace.yaml file\n    if (fs.existsSync(path.join(repositoryRoot, 'pnpm-workspace.yaml'))) {\n      return true;\n    }\n\n    // vlt can be validated just by the existence of the vlt-workspaces.json file\n    if (fs.existsSync(path.join(repositoryRoot, 'vlt-workspaces.json'))) {\n      return true;\n    }\n\n    // NX can be validated by checking the environment variable.\n    if (process.env.NX_WORKSPACE_ROOT === path.resolve(repositoryRoot)) {\n      return true;\n    }\n\n    // all the rest need packages defined in root package.json\n    const packageJsonPath = path.join(repositoryRoot, 'package.json');\n    if (!fs.existsSync(packageJsonPath)) {\n      return false;\n    }\n\n    const packageJson = JSON.parse(\n      fs.readFileSync(packageJsonPath, 'utf-8'),\n    ) as {\n      workspaces?: string[] | Record<string, string>;\n    };\n\n    return packageJson.workspaces !== undefined;\n  } catch (error) {\n    logger.error('Error determining if repository is a monorepo', error);\n    return false;\n  }\n}\n","import path from 'node:path';\nimport {\n  MFE_CONFIG_DEFAULT_FILE_NAME,\n  MFE_CONFIG_DEFAULT_FILE_PATH,\n} from '../constants';\n\nexport function getOutputFilePath(): string {\n  return path.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);\n}\n","/**\n * Default path to use for the microfrontends configuration when output to a file.\n */\nexport const MFE_CONFIG_DEFAULT_FILE_PATH = 'microfrontends' as const;\n\n/**\n * Default name to use for the microfrontends configuration when output to a file.\n */\nexport const MFE_CONFIG_DEFAULT_FILE_NAME = 'microfrontends.json' as const;\n","import { Ajv, type ErrorObject } from 'ajv';\nimport { parse } from 'jsonc-parser';\nimport { MicrofrontendError } from '../../errors';\nimport type { Config } from '../../schema/types';\nimport { SCHEMA } from '../../schema/utils/load';\n\nconst LIST_FORMATTER = new Intl.ListFormat('en', {\n  style: 'long',\n  type: 'disjunction',\n});\n\nfunction formatAjvErrors(errors: ErrorObject[] | null | undefined): string[] {\n  if (!errors) {\n    return [];\n  }\n  const errorMessages: string[] = [];\n  for (const error of errors) {\n    // Ignore root errors that arise because AJV can't infer whether the config is a main config or a child config.\n    // These errors are confusing for the user.\n    if (\n      error.instancePath === '' &&\n      (error.keyword === 'anyOf' ||\n        (error.keyword === 'required' &&\n          error.params.missingProperty === 'partOf'))\n    ) {\n      continue;\n    }\n\n    // Ignore the first leading slash in the instance path to make the path more readable.\n    const instancePath = error.instancePath.slice(1);\n    const formattedInstancePath =\n      instancePath === '' ? 'at the root' : `in field ${instancePath}`;\n\n    // AJV errors are really cryptic, so this logic transforms them to nicer ones.\n    // It is based on heuristics from introducing errors and observing what AJV produces.\n    if (\n      error.keyword === 'required' &&\n      error.params.missingProperty === 'routing' &&\n      instancePath.split('/').length === 2\n    ) {\n      errorMessages.push(\n        `Unable to infer if ${instancePath} is the default app or a child app. This usually means that there is another error in the configuration.`,\n      );\n    } else if (\n      error.keyword === 'anyOf' &&\n      instancePath.split('/').length > 2\n    ) {\n      const anyOfErrors = errors.filter(\n        (e) => e.instancePath === error.instancePath && e.keyword !== 'anyOf',\n      );\n      if (anyOfErrors.every((e) => e.keyword === 'type')) {\n        const allowedTypes = LIST_FORMATTER.format(\n          anyOfErrors.map((e) => {\n            return e.keyword === 'type' ? String(e.params.type) : 'unknown';\n          }),\n        );\n        errorMessages.push(\n          `Incorrect type for ${instancePath}. Must be one of ${allowedTypes}`,\n        );\n      } else {\n        errorMessages.push(\n          `Invalid field for ${instancePath}. Possible error messages are ${LIST_FORMATTER.format(anyOfErrors.map((e) => e.message ?? ''))}`,\n        );\n      }\n    } else if (\n      error.keyword === 'additionalProperties' &&\n      !(\n        error.params.additionalProperty === 'routing' &&\n        instancePath.split('/').length === 2\n      )\n    ) {\n      errorMessages.push(\n        `Property '${error.params.additionalProperty}' is not allowed ${formattedInstancePath}`,\n      );\n    } else if (error.keyword === 'required') {\n      errorMessages.push(\n        `Property '${error.params.missingProperty}' is required ${formattedInstancePath}`,\n      );\n    }\n  }\n  return errorMessages;\n}\n\nexport function validateSchema(configString: string): Config {\n  const parsedConfig = parse(configString) as Config;\n\n  const ajv = new Ajv({ allowUnionTypes: true });\n  const validate = ajv.compile(SCHEMA);\n  const isValid = validate(parsedConfig);\n  if (!isValid) {\n    throw new MicrofrontendError(\n      `Invalid microfrontends config:${formatAjvErrors(validate.errors)\n        .map((error) => `\\n - ${error}`)\n        .join(\n          '',\n        )}\\n\\nSee https://openapi.vercel.sh/microfrontends.json for the schema.`,\n      { type: 'config', subtype: 'does_not_match_schema' },\n    );\n  }\n\n  return parsedConfig;\n}\n","{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"$ref\": \"#/definitions/Config\",\n  \"definitions\": {\n    \"Config\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"$schema\": {\n          \"type\": \"string\",\n          \"description\": \"See https://openapi.vercel.sh/microfrontends.json.\"\n        },\n        \"version\": {\n          \"type\": \"string\",\n          \"const\": \"1\",\n          \"description\": \"The version of the microfrontends config schema.\"\n        },\n        \"applications\": {\n          \"$ref\": \"#/definitions/ApplicationRouting\",\n          \"description\": \"Mapping of Vercel project names to their microfrontend configurations.\"\n        },\n        \"options\": {\n          \"$ref\": \"#/definitions/Options\",\n          \"description\": \"Optional configuration options for the microfrontend.\"\n        }\n      },\n      \"required\": [\"applications\"],\n      \"additionalProperties\": false,\n      \"description\": \"The microfrontends configuration schema. See https://vercel.com/docs/microfrontends/configuration.\"\n    },\n    \"ApplicationRouting\": {\n      \"type\": \"object\",\n      \"additionalProperties\": {\n        \"$ref\": \"#/definitions/Application\"\n      },\n      \"propertyNames\": {\n        \"description\": \"The Vercel project name of the microfrontend application.\\n\\nNote: If this name does not also match the name `name` from the `package.json`, set `packageName` with the name used in `package.json`.\\n\\nSee https://vercel.com/docs/microfrontends/configuration#application-naming.\"\n      },\n      \"description\": \"Mapping of Vercel project names to their microfrontend configurations.\"\n    },\n    \"Application\": {\n      \"anyOf\": [\n        {\n          \"$ref\": \"#/definitions/DefaultApplication\"\n        },\n        {\n          \"$ref\": \"#/definitions/ChildApplication\"\n        }\n      ],\n      \"description\": \"The configuration for a microfrontend application. There must always be one default application.\"\n    },\n    \"DefaultApplication\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"packageName\": {\n          \"type\": \"string\",\n          \"description\": \"The name used to run the application, e.g. the `name` field in the `package.json`.\\n\\nThis is used by the local proxy to map the application config to the locally running app.\\n\\nThis is only necessary when the application name does not match the `name` used in `package.json`.\\n\\nSee https://vercel.com/docs/microfrontends/configuration#application-naming.\"\n        },\n        \"development\": {\n          \"$ref\": \"#/definitions/DefaultDevelopment\",\n          \"description\": \"Development configuration for the default application.\"\n        }\n      },\n      \"required\": [\"development\"],\n      \"additionalProperties\": false\n    },\n    \"DefaultDevelopment\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"local\": {\n          \"type\": [\"number\", \"string\"],\n          \"description\": \"A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\\n\\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\\n\\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\\n\\nSee https://vercel.com/docs/microfrontends/local-development.\"\n        },\n        \"task\": {\n          \"type\": \"string\",\n          \"description\": \"The task to run when starting the development server. Should reference a script in the package.json of the application.\\n\\nThe default value is \\\"dev\\\".\\n\\nSee https://vercel.com/docs/microfrontends/local-development.\"\n        },\n        \"fallback\": {\n          \"type\": \"string\",\n          \"description\": \"Fallback for local development, could point to any environment. This is required for the default app. This value is used as the fallback for child apps as well if they do not have a fallback.\\n\\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\\n\\nSee https://vercel.com/docs/microfrontends/local-development.\"\n        }\n      },\n      \"required\": [\"fallback\"],\n      \"additionalProperties\": false\n    },\n    \"ChildApplication\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"packageName\": {\n          \"type\": \"string\",\n          \"description\": \"The name used to run the application, e.g. the `name` field in the `package.json`.\\n\\nThis is used by the local proxy to map the application config to the locally running app.\\n\\nThis is only necessary when the application name does not match the `name` used in `package.json`.\\n\\nSee https://vercel.com/docs/microfrontends/configuration#application-naming.\"\n        },\n        \"development\": {\n          \"$ref\": \"#/definitions/ChildDevelopment\",\n          \"description\": \"Development configuration for the child application.\"\n        },\n        \"routing\": {\n          \"$ref\": \"#/definitions/Routing\",\n          \"description\": \"Groups of path expressions that are routed to this application.\\n\\nSee https://vercel.com/docs/microfrontends/path-routing.\"\n        },\n        \"assetPrefix\": {\n          \"type\": \"string\",\n          \"description\": \"The name of the asset prefix to use instead of the auto-generated name.\\n\\nThe asset prefix is used to prefix all paths to static assets, such as JS, CSS, or images that are served by a specific application. It is necessary to ensure there are no conflicts with other applications on the same domain.\\n\\nAn auto-generated asset prefix of the form `vc-ap-<hash>` is used when this field is not provided.\\n\\nWhen this field is provided, `/${assetPrefix}/:path*` must also be added to the list of paths in the `routing` field. Changing the asset prefix after a microfrontend application has already been deployed is not a forwards and backwards compatible change, and the asset prefix should be added to the `routing` field and deployed before setting the `assetPrefix` field.\\n\\nThe default value is the auto-generated asset prefix of the form `vc-ap-<hash>`.\\n\\nSee https://vercel.com/docs/microfrontends/path-routing#asset-prefix.\"\n        }\n      },\n      \"required\": [\"routing\"],\n      \"additionalProperties\": false\n    },\n    \"ChildDevelopment\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"local\": {\n          \"type\": [\"number\", \"string\"],\n          \"description\": \"A local port number or host that this application runs on when it is running locally. If passing a string, include the protocol (optional), host (required) and port (optional).\\n\\nExamples of valid values: 8080, my.localhost.me, my.localhost.me:8080, https://my.localhost.me, https://my.localhost.me:8080.\\n\\nThe default value is http://localhost:<port> where port is a stable, unique port number (based on the application name).\\n\\nSee https://vercel.com/docs/microfrontends/local-development.\"\n        },\n        \"task\": {\n          \"type\": \"string\",\n          \"description\": \"The task to run when starting the development server. Should reference a script in the package.json of the application.\\n\\nThe default value is \\\"dev\\\".\\n\\nSee https://vercel.com/docs/microfrontends/local-development.\"\n        },\n        \"fallback\": {\n          \"type\": \"string\",\n          \"description\": \"Fallback for local development, could point to any environment. If not provided for child apps, the fallback of the default app will be used.\\n\\nIf passing a string, include the protocol (optional), host (required) and port (optional). For example: `https://this.ismyhost:8080`. If omitted, the protocol defaults to HTTPS. If omitted, the port defaults to `80` for HTTP and `443` for HTTPS.\\n\\nSee https://vercel.com/docs/microfrontends/local-development.\"\n        }\n      },\n      \"additionalProperties\": false\n    },\n    \"Routing\": {\n      \"type\": \"array\",\n      \"items\": {\n        \"$ref\": \"#/definitions/PathGroup\"\n      },\n      \"description\": \"A list of path groups that are routed to this application.\"\n    },\n    \"PathGroup\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"group\": {\n          \"type\": \"string\",\n          \"description\": \"Group name for the paths.\"\n        },\n        \"flag\": {\n          \"type\": \"string\",\n          \"description\": \"The name of the feature flag that controls routing for this group of paths. See https://vercel.com/docs/microfrontends/path-routing#routing-changes-safely-with-flags.\"\n        },\n        \"paths\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"description\": \"A list of path expressions that are routed to this application. See https://vercel.com/docs/microfrontends/path-routing#supported-path-expressions.\"\n        }\n      },\n      \"required\": [\"paths\"],\n      \"additionalProperties\": false,\n      \"description\": \"A group of paths that is routed to this application.\"\n    },\n    \"Options\": {\n      \"type\": \"object\",\n      \"properties\": {\n        \"disableOverrides\": {\n          \"type\": \"boolean\",\n          \"description\": \"If you want to disable the overrides for the site. For example, if you are managing rewrites between applications externally, you may wish to disable the overrides on the toolbar as they will have no effect.\\n\\nSee https://vercel.com/docs/microfrontends/managing-microfrontends/vercel-toolbar#routing-overrides.\"\n        },\n        \"localProxyPort\": {\n          \"type\": \"number\",\n          \"description\": \"The port number used by the local proxy server.\\n\\nThe default value is 3024.\\n\\nSee https://vercel.com/docs/microfrontends/local-development.\"\n        }\n      },\n      \"additionalProperties\": false\n    }\n  }\n}\n","import type { JSONSchema7 } from 'json-schema';\nimport jsonSchema from '../../../../schema/schema.json';\n\nexport const SCHEMA = jsonSchema as JSONSchema7;\n","import { existsSync } from 'node:fs';\nimport { join } from 'node:path';\nimport { cwd } from 'node:process';\n\nexport type Framework = 'sveltekit' | 'react-router' | 'unknown';\n\nexport function detectFramework(): Framework {\n  if (existsSync(join(cwd(), 'svelte.config.js'))) {\n    return 'sveltekit';\n  }\n  if (\n    existsSync(join(cwd(), 'react-router.config.js')) ||\n    existsSync(join(cwd(), 'react-router.config.ts'))\n  ) {\n    return 'react-router';\n  }\n  return 'unknown';\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEA,SAAS,SAAS,MAAuB;AACvC,MAAI,QAAQ,IAAI,WAAW;AACzB,YAAQ,IAAI,GAAG,IAAI;AAAA,EACrB;AACF;AAEA,SAAS,QAAQ,MAAuB;AACtC,UAAQ,IAAI,GAAG,IAAI;AACrB;AAEA,SAAS,QAAQ,MAAuB;AACtC,UAAQ,KAAK,GAAG,IAAI;AACtB;AAEA,SAAS,SAAS,MAAuB;AACvC,UAAQ,MAAM,GAAG,IAAI;AACvB;AAEO,IAAM,SAAS;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;;;ACzBA,IAAAA,kBAAe;AACf,IAAAC,oBAAuC;;;AC4EhC,IAAM,qBAAN,cAEG,MAAM;AAAA,EAKd,YAAY,SAAiB,MAAqC;AAChE,UAAM,SAAS,EAAE,OAAO,MAAM,MAAM,CAAC;AACrC,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AAkB,CAAC,QAAQ,IAAI,YAAY;AAC3D,gCAAwB,OAAO;AAAA,MACjC;AACA,UAAI,cAAc,gBAAgB;AAKhC,gCAAwB,QAAQ;AAAA,UAC9B,WAAW,KAAK;AAAA,QAClB;AAAA,MACF,OAAO;AAGL,gCAAwB,QAAQ;AAAA,UAC9B,QAAQ,OAAO,KAAK;AAAA,QACtB;AAAA,MACF;AAAA,IACF,WAAW,cAAc,aAAa;AAIpC,8BAAwB,QAAQ;AAAA,QAC9B,WAAW,KAAK,IAAI,eAAe;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACA,MAAI,IAAI,YAAY,MAAM,MAAM;AAC9B,4BAAwB,SAAS;AAAA,MAC/B,MAAM,IAAI,YAAY,MAAM;AAAA,IAC9B;AACA,4BAAwB,UAAU;AAAA,MAChC,MAAM,IAAI,YAAY,MAAM;AAAA,IAC9B;AAAA,EACF;AACA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACA,SAAO;AAAA,IACL,MAAM;AAAA,IACN,QAAQ,MAAM;AACZ,aAAO;AAAA,QACL,GAAG;AAAA,QACH,QAAQ;AAAA,UACN,2CAA2C,KAAK,UAAU,IAAI,IAAI;AAAA,UAClE,8BAA8B,KAAK;AAAA,YACjC,kBAAkB,OAAO,UAAU;AAAA,UACrC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["import_node_fs","import_node_path","import_jsonc_parser","md5","path","fs","import_node_fs","import_node_path","fg","error","path","import_path_to_regexp","path","parsePathRegexp","import_node_fs","import_node_path","path","fs","import_node_fs","import_node_path","path","fs","import_node_fs","import_node_path","fs","path","import_node_fs","import_node_path","fs","path","error","import_node_path","path","import_jsonc_parser","LIST_FORMATTER","error","fs","isMonorepo","import_node_fs","import_node_path"]}