@vercel/microfrontends 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +5 -5
  2. package/dist/bin/cli.cjs +346 -90
  3. package/dist/config/client.d.ts +1 -1
  4. package/dist/config/edge.d.ts +2 -2
  5. package/dist/config.cjs +1 -6
  6. package/dist/config.cjs.map +1 -1
  7. package/dist/config.d.ts +3 -3
  8. package/dist/config.js +1 -6
  9. package/dist/config.js.map +1 -1
  10. package/dist/{index-05742bef.d.ts → index-a99d5459.d.ts} +2 -2
  11. package/dist/{microfrontend-config-2425db74.d.ts → microfrontend-config-983a5139.d.ts} +1 -1
  12. package/dist/next/client.cjs +1 -1
  13. package/dist/next/client.cjs.map +1 -1
  14. package/dist/next/client.js +1 -1
  15. package/dist/next/client.js.map +1 -1
  16. package/dist/next/config.cjs +13 -11
  17. package/dist/next/config.cjs.map +1 -1
  18. package/dist/next/config.js +13 -11
  19. package/dist/next/config.js.map +1 -1
  20. package/dist/next/middleware.cjs +22 -8
  21. package/dist/next/middleware.cjs.map +1 -1
  22. package/dist/next/middleware.js +22 -8
  23. package/dist/next/middleware.js.map +1 -1
  24. package/dist/next/testing.cjs +1 -6
  25. package/dist/next/testing.cjs.map +1 -1
  26. package/dist/next/testing.d.ts +2 -2
  27. package/dist/next/testing.js +1 -6
  28. package/dist/next/testing.js.map +1 -1
  29. package/dist/overrides.d.ts +2 -2
  30. package/dist/{schema-83a75e61.d.ts → schema-2922d49e.d.ts} +1 -7
  31. package/dist/{types-4fd1c7c6.d.ts → types-0030abae.d.ts} +1 -8
  32. package/dist/{types-13f3e535.d.ts → types-c777c2f5.d.ts} +1 -1
  33. package/dist/v2/config.cjs +1 -1
  34. package/dist/v2/config.cjs.map +1 -1
  35. package/dist/v2/config.d.ts +3 -3
  36. package/dist/v2/config.js +1 -1
  37. package/dist/v2/config.js.map +1 -1
  38. package/dist/v2/microfrontends/server.cjs +296 -36
  39. package/dist/v2/microfrontends/server.cjs.map +1 -1
  40. package/dist/v2/microfrontends/server.d.ts +26 -4
  41. package/dist/v2/microfrontends/server.js +296 -36
  42. package/dist/v2/microfrontends/server.js.map +1 -1
  43. package/dist/v2/microfrontends.cjs +1 -1
  44. package/dist/v2/microfrontends.cjs.map +1 -1
  45. package/dist/v2/microfrontends.d.ts +3 -3
  46. package/dist/v2/microfrontends.js +1 -1
  47. package/dist/v2/microfrontends.js.map +1 -1
  48. package/dist/v2/next/client.cjs +1 -1
  49. package/dist/v2/next/client.cjs.map +1 -1
  50. package/dist/v2/next/client.js +1 -1
  51. package/dist/v2/next/client.js.map +1 -1
  52. package/dist/v2/next/config.cjs +331 -68
  53. package/dist/v2/next/config.cjs.map +1 -1
  54. package/dist/v2/next/config.js +331 -68
  55. package/dist/v2/next/config.js.map +1 -1
  56. package/dist/v2/next/endpoints.cjs +5 -2
  57. package/dist/v2/next/endpoints.cjs.map +1 -1
  58. package/dist/v2/next/endpoints.d.ts +1 -1
  59. package/dist/v2/next/endpoints.js +5 -2
  60. package/dist/v2/next/endpoints.js.map +1 -1
  61. package/dist/v2/next/middleware.cjs +108 -88
  62. package/dist/v2/next/middleware.cjs.map +1 -1
  63. package/dist/v2/next/middleware.js +108 -88
  64. package/dist/v2/next/middleware.js.map +1 -1
  65. package/dist/v2/overrides.cjs +1 -1
  66. package/dist/v2/overrides.cjs.map +1 -1
  67. package/dist/v2/overrides.d.ts +3 -3
  68. package/dist/v2/overrides.js +1 -1
  69. package/dist/v2/overrides.js.map +1 -1
  70. package/dist/v2/schema.cjs.map +1 -1
  71. package/dist/v2/schema.d.ts +1 -1
  72. package/dist/validation.cjs +0 -11
  73. package/dist/validation.cjs.map +1 -1
  74. package/dist/validation.d.ts +2 -9
  75. package/dist/validation.js +0 -11
  76. package/dist/validation.js.map +1 -1
  77. package/package.json +8 -7
  78. package/schema/schema-v2.json +0 -7
  79. package/schema/schema.json +0 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config/client/client-config.ts","../src/config/well-known/endpoints.ts","../src/config/types.ts","../src/config/microfrontend-config.ts","../src/config-v2/microfrontends/server/utils/get-output-file-path.ts","../src/config-v2/microfrontends/server/constants.ts","../src/utils/is-vercel.ts","../src/config/errors.ts","../src/routing/url.ts","../src/config/overrides/config.ts","../src/config/common/host.ts","../src/config/common/application.ts","../src/config/common/microfrontend-config.ts","../src/config/utils/get-output-file-path.ts","../src/config/constants.ts","../src/config/validation.ts","../schema/schema.json","../src/config/utils/load-schema.ts","../src/config/utils/convert.ts","../src/config/utils/write-file.ts"],"sourcesContent":["import type { Config } from '../schema';\nimport type { ClientConfig, WellKnownClientData } from './types';\n\n/**\n * Given a micro-frontends configuration, this returns a version that is\n * acceptable to be used client-side without leaking any information.\n */\nexport function getConfigForClient(config: Config): ClientConfig {\n return {\n applications: Object.fromEntries(\n Object.entries(config.applications).map(([name, application]) => [\n name,\n {\n default: application.default,\n routing: application.routing,\n },\n ]),\n ),\n };\n}\n\nexport function getClientConfigFromEnv(): ClientConfig {\n // This has to use the actual name rather than the constant variable in order\n // for the env var to be replaced during the build correctly.\n const clientConfigJson = process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;\n if (!clientConfigJson) {\n throw new Error(\n 'Could not find client micro-frontends config in the environment',\n );\n }\n return JSON.parse(clientConfigJson) as ClientConfig;\n}\n\nexport type { ClientConfig, WellKnownClientData };\n","import { getClientConfigFromEnv } from '../client/client-config';\nimport type { WellKnownClientData } from '../client/types';\n\n/**\n * Returns data used by the client to ensure that navigations across\n * micro-frontend boundaries are routed and prefetched correctly. The client\n * configuration is safe to expose to users.\n *\n * This data should be exposed in a `.well-known/vercel/micro-frontends/client-config`\n * endpoint.\n */\nexport async function getWellKnownClientData(\n flagValues: Record<string, () => Promise<boolean>> = {},\n): Promise<WellKnownClientData> {\n const config = getClientConfigFromEnv();\n for (const [applicationName, application] of Object.entries(\n config.applications,\n )) {\n if (!application.routing) {\n continue;\n }\n const newRoutingMatches = [];\n for (const pathGroup of application.routing.matches) {\n if (pathGroup.options?.flag) {\n const flagName = pathGroup.options.flag;\n const flagFn = flagValues[flagName];\n if (!flagFn) {\n throw new Error(\n `Flag \"${flagName}\" was specified to control routing for path group \"${pathGroup.group}\" in application ${applicationName} but not found in provided flag values.`,\n );\n }\n // eslint-disable-next-line no-await-in-loop\n const flagEnabled = await flagFn();\n if (flagEnabled) {\n newRoutingMatches.push(pathGroup);\n }\n } else {\n newRoutingMatches.push(pathGroup);\n }\n }\n application.routing.matches = newRoutingMatches;\n }\n\n return {\n config,\n };\n}\n","import type {\n ApplicationConfig,\n CommonApplicationConfig,\n DefaultApplicationConfig,\n} from './schema';\n\nexport const isCommonApplicationConfig = (\n app: ApplicationConfig,\n): app is CommonApplicationConfig =>\n !app.default && typeof app.routing === 'object';\n\nexport const isDefaultApplicationConfig = (\n app: ApplicationConfig,\n): app is DefaultApplicationConfig =>\n app.default && typeof app.routing === 'undefined';\n\nexport interface VercelJsonSchema {\n microFrontends?: {\n config?: string;\n };\n}\n","import fs from 'node:fs';\nimport { getOutputFilePath as getV2OutputFilePath } from '../config-v2/microfrontends/server/utils/get-output-file-path';\nimport { MicrofrontendConfigCommon } from './common/microfrontend-config';\nimport type { Config } from './schema';\nimport { MicrofrontendError } from './errors';\nimport { getOutputFilePath } from './utils/get-output-file-path';\nimport {\n validateSchema,\n validateDefaults,\n validatePaths,\n validateMainPath,\n validateVersion,\n validateOptions,\n} from './validation';\nimport { Overrides } from './overrides';\nimport { convertV1ConfigToV2Config } from './utils/convert';\nimport { writeFile } from './utils/write-file';\n\n/**\n * A class to manage the microfrontends configuration with config validation.\n *\n * Cannot be used by the middleware which runs in the Edge Runtime. For middleware use `MicrofrontendConfigEdgeRuntime`.\n */\nexport class MicrofrontendConfig extends MicrofrontendConfigCommon {\n static validate(configString: string): Config {\n const config = validateSchema(configString);\n validateVersion(config.version);\n validatePaths(config.applications);\n validateMainPath(config.applications);\n validateDefaults(config.applications);\n validateOptions(config.options);\n return config;\n }\n\n static fromEnv({\n cookies,\n }: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfig {\n return new MicrofrontendConfigCommon({\n config: MicrofrontendConfig.validate(\n MicrofrontendConfigCommon.getConfigFromEnv(),\n ),\n overrides: Overrides.parseOverrides(cookies),\n });\n }\n\n static fromFile({\n filePath,\n }: {\n filePath: string;\n }): MicrofrontendConfig {\n try {\n const config = fs.readFileSync(filePath, 'utf-8');\n return new MicrofrontendConfig({\n config: MicrofrontendConfig.validate(config),\n });\n } catch (e) {\n throw MicrofrontendError.handle(e, {\n fileName: filePath,\n });\n }\n }\n\n /**\n * Writes the configuration to a file.\n */\n write(\n fromApp: string,\n opts: {\n pretty?: boolean;\n versions?: ('v1' | 'v2')[];\n } = {},\n ): void {\n const { pretty = true, versions = ['v1', 'v2'] } = opts;\n\n const config = this.toSchemaJson();\n if (versions.includes('v1')) {\n const outputPath = getOutputFilePath();\n writeFile(outputPath, config, pretty);\n }\n if (versions.includes('v2')) {\n const outputPath = getV2OutputFilePath();\n const v2Config = convertV1ConfigToV2Config(config, fromApp);\n writeFile(outputPath, v2Config, pretty);\n }\n }\n}\n","import path from 'node:path';\nimport {\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n} from '../constants';\nimport { isVercel } from '../../../../utils/is-vercel';\n\nexport function getOutputFilePath(): string {\n if (isVercel()) {\n return path.join(\n '.vercel',\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n );\n }\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","export function isVercel(): boolean {\n return process.env.VERCEL === '1';\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'zone'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\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 zone:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\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 | '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 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);\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","// NOTE: This is copied from https://github.com/vercel/api/blob/main/packages/util-func/src/url-safe-string.ts.\n// See https://linear.app/vercel/issue/FDRTN-199/spike-move-preview-domain-generation-logic-into-build-and-deploy\n// for cleaning this up before release.\n\ninterface Options {\n joinString?: string;\n lowercaseOnly?: boolean;\n maxLen?: number;\n regexRemovePattern?: RegExp;\n trimWhitespace?: boolean;\n}\n\n/**\n * This function allows to convert single string to URL-safe tags to use for routing,\n * SEO purposes, etc. It is taken from https://www.npmjs.com/package/url-safe-string\n * and implemented here to be typed and skip the dependency.\n */\nfunction buildUrlSafeString(givenOpts: Options = {}): {\n generate: (...args: string[]) => string;\n} {\n const options = {\n joinString: '-',\n lowercaseOnly: true,\n maxLen: 100,\n regexRemovePattern: /(?:(?!(?:[a-z0-9])).)/gi,\n trimWhitespace: true,\n ...givenOpts,\n };\n\n return {\n generate: (...args: string[]) => {\n const reJoinString = new RegExp(`${options.joinString}+`, 'g');\n\n // biome-ignore lint/suspicious/noImplicitAnyLet: Ignored using `--suppress`\n let tag;\n\n if (args.length === 0) {\n throw new Error('generate method must be passed at least one argument');\n }\n\n // Validate, trim all arguments:\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (typeof arg !== 'string')\n throw new Error('all supplied arguments must be Strings');\n\n if (options.trimWhitespace) {\n args[i] = arg.trim();\n }\n }\n\n // Join strings and convert whitespace between words to join string\n tag = args.join(options.joinString);\n tag = tag.replace(/\\s/g, options.joinString);\n if (options.lowercaseOnly) tag = tag.toLowerCase();\n // Regex away anything \"unsafe\", but ignore the join string!\n tag = tag.replace(options.regexRemovePattern, (match) => {\n if (match === options.joinString) return match;\n\n return '';\n });\n\n // Truncate in excess of maxLen\n if (tag.length > options.maxLen) tag = tag.substring(0, options.maxLen);\n\n // Remove any duplicates of the join string using this pattern: /<join string>+/g\n tag = tag.replace(reJoinString, options.joinString);\n\n return tag;\n },\n };\n}\n\n/**\n * Export a preconfigured version for convenience.\n */\nexport const urlSafeString = buildUrlSafeString().generate;\n\nexport function makeUrlSafe(name: string): string {\n return urlSafeString(name.replace(/\\//g, '-'))\n .replace(/^-*/g, '')\n .replace(/-*$/g, '');\n}\n","import { makeUrlSafe } from '../../routing/url';\nimport type { MicrofrontendConfig } from '../microfrontend-config';\nimport type { OverridesConfig } from './types';\n\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\n\nexport class Overrides {\n config: OverridesConfig;\n\n constructor(config: OverridesConfig) {\n this.config = config;\n }\n\n static overrideEnvCookiePrefix = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n\n static getAppEnvOverrideCookieName(zone: string): string {\n return `${Overrides.overrideEnvCookiePrefix}${zone}`;\n }\n\n static isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n }\n\n static getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n }): { zone: string; host: string } | undefined {\n if (!Overrides.isOverrideCookie(cookie) || !cookie.value) return;\n return {\n zone: cookie.name.replace(Overrides.overrideEnvCookiePrefix, ''),\n host: cookie.value,\n };\n }\n\n static parseOverrides(\n cookies: { name: string; value?: string | null }[],\n ): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = Overrides.getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.zone] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n }\n\n static validOverrideDomainsForZone(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n ): string[] {\n const projectName = microfrontendConfig.getZone(zone).vercel?.projectName;\n if (!projectName) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n const parsedProjectName = makeUrlSafe(projectName);\n const previewDeploymentSuffix =\n microfrontendConfig.options?.vercel?.previewDeploymentSuffix;\n const teamSlug = microfrontendConfig.options?.vercel?.teamSlug;\n if (!teamSlug && !previewDeploymentSuffix) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n\n const suffix = previewDeploymentSuffix\n ? `.${previewDeploymentSuffix}`\n : `-${teamSlug}.vercel.app`;\n\n // <project-name>-git-<branch-name>-<scope-slug>.vercel.app\n // <project-name>-git-<branch-name>.<custom-suffix>\n return [\n `${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,\n microfrontendConfig.getZone(zone).production.host,\n ];\n }\n\n static validateOverrideDomain(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n domain: string,\n ): boolean {\n return new RegExp(\n `^${Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(\n '|',\n )}$`,\n ).test(domain);\n }\n\n serialize(): OverridesConfig {\n return this.config;\n }\n}\n","import type { HostConfig } from '../schema';\n\ninterface HostDisplayOptions {\n includeDefaultPort?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: HostConfig['host'];\n port: number;\n serialized: HostConfig;\n\n constructor({ protocol, host, port }: HostConfig) {\n this.protocol = protocol || 'https';\n this.host = host;\n this.port = Host.getPort({ port, protocol: this.protocol });\n this.serialized = {\n protocol,\n host,\n ...(port ? { port } : undefined),\n };\n }\n\n isLocal(): boolean {\n return this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n static getPort({\n protocol,\n port,\n }: { protocol: HostConfig['protocol']; port?: HostConfig['port'] }): number {\n if (!port) {\n if (protocol === 'http') {\n return 80;\n }\n return 443;\n }\n\n return port;\n }\n\n isDefaultPort(): boolean {\n return this.port === Host.getPort({ protocol: this.protocol });\n }\n\n toString(opts: HostDisplayOptions = {}): string {\n const url = this.toUrl(opts);\n // strip the trailing slash\n return url.toString().replace(/\\/$/, '');\n }\n\n toUrl(opts: HostDisplayOptions = {}): URL {\n const { includeDefaultPort } = opts;\n const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? '' : `:${this.port}`}`;\n\n return new URL(url);\n }\n\n serialize(): HostConfig {\n return this.serialized;\n }\n}\n","import type { ApplicationConfig, Routing, Vercel } from '../schema';\nimport type { ApplicationOverrideConfig } from '../overrides';\nimport { MicrofrontendError } from '../errors';\nimport { Host } from './host';\n\nexport class Application {\n default: boolean;\n routing?: Routing;\n name: string;\n development: {\n local: Host;\n fallback?: Host;\n };\n production: Host;\n vercel?: Vercel;\n overrides?: {\n environment?: Host;\n };\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: { app: ApplicationConfig; overrides?: ApplicationOverrideConfig },\n ) {\n // validate\n Application.validate(name, app);\n\n this.name = name;\n this.default = app.default;\n this.routing = app.routing;\n this.development = {\n local: new Host(app.development.local),\n fallback: app.development.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n this.production = new Host(app.production);\n this.vercel = app.vercel;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n static validate(name: string, app: ApplicationConfig): void {\n // validate assetPrefix\n if (\n app.routing?.assetPrefix?.startsWith('/') ||\n app.routing?.assetPrefix?.endsWith('/')\n ) {\n throw new MicrofrontendError(\n `Invalid assetPrefix for application \"${name}\". Must not start or end with a slash.`,\n { type: 'zone', subtype: 'invalid_asset_prefix' },\n );\n }\n\n // validate routes\n for (const group of app.routing?.matches ?? []) {\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: 'zone', 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: 'zone', subtype: 'invalid_path' },\n );\n }\n }\n }\n }\n\n serialize(): ApplicationConfig {\n if (this.routing === undefined || this.default) {\n return {\n default: true,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n\n return {\n default: false,\n routing: this.routing,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n}\n","import type { ApplicationConfig, Config, Options } from '../schema';\nimport { MicrofrontendError } from '../errors';\nimport type { OverridesConfig } from '../overrides';\nimport { Overrides } from '../overrides/config';\nimport { Application } from './application';\n\nconst SUPPORTED_VERSIONS = ['1'];\nconst DEFAULT_LOCAL_PROXY_PORT = 3024;\n\n/**\n * A class to manage the microfrontends configuration.\n *\n * This class should not be used directly. Instead, use the `MicrofrontendConfig` or `MicrofrontendConfigEdgeRuntime` classes.\n */\nexport class MicrofrontendConfigCommon {\n config: Config;\n name?: string;\n zones: Record<string, Application> = {};\n version: string;\n overrides?: Overrides;\n options?: Options;\n $schema: string | undefined;\n\n constructor({\n config,\n overrides,\n }: { config: Config; overrides?: OverridesConfig }) {\n if (!SUPPORTED_VERSIONS.includes(config.version)) {\n throw new MicrofrontendError(\n `Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(\n ', ',\n )}`,\n { type: 'config', subtype: 'unsupported_version' },\n );\n }\n const disableOverrides = config.options?.vercel?.disableOverrides ?? false;\n\n this.overrides =\n overrides && !disableOverrides ? new Overrides(overrides) : undefined;\n\n // create zones\n for (const [zoneName, zoneConfig] of Object.entries(config.applications)) {\n this.zones[zoneName] = new Application(zoneName, {\n app: zoneConfig,\n overrides: !disableOverrides\n ? this.overrides?.config.applications[zoneName]\n : undefined,\n });\n }\n\n this.config = config;\n this.name = config.name;\n this.version = config.version;\n this.options = config.options;\n this.$schema = config.$schema;\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.vercel?.disableOverrides ?? false;\n }\n\n protected static getConfigFromEnv(): 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\n static fromEnv(_: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfigCommon | Promise<MicrofrontendConfigCommon> {\n throw new Error('Not implemented');\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getAllApplications(): Application[] {\n return Object.values(this.zones);\n }\n\n getZone(name: string): Application {\n const zone = this.zones[name];\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n getApplicationByProjectId(projectId: string): Application | undefined {\n return Object.values(this.zones).find(\n (zone) => zone.vercel?.projectId === projectId,\n );\n }\n\n getDefaultZone(): Application {\n const zone = Object.values(this.zones).find((z) => z.default);\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find default zone in microfrontends configuration`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n /**\n * Returns the configured port for the local proxy\n */\n getLocalProxyPort(): number {\n return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;\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 const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n $schema: this.$schema,\n name: this.name,\n version: this.version,\n options: this.options,\n applications,\n };\n }\n\n serialize(): { config: Config; overrides?: OverridesConfig } {\n const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n config: {\n name: this.name,\n version: this.version,\n applications,\n options: this.options,\n $schema: this.$schema,\n },\n overrides: this.overrides?.serialize(),\n };\n }\n\n write(_: string): void {\n throw new MicrofrontendError(\n `Writing to file to disk requires using an instance of \"MicrofrontendConfig\".`,\n { type: 'config', subtype: 'unsupported_operation' },\n );\n }\n}\n","import path from 'node:path';\nimport {\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n} from '../constants';\nimport { isVercel } from '../../utils/is-vercel';\n\nexport function getOutputFilePath(): string {\n if (isVercel()) {\n return path.join(\n '.vercel',\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n );\n }\n return path.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);\n}\n","/**\n * Default path to use for the micro-frontends configuration when output to a file.\n */\nexport const MFE_CONFIG_DEFAULT_FILE_PATH = 'micro-frontends' as const;\n\n/**\n * Default name to use for the micro-frontends configuration when output to a file.\n */\nexport const MFE_CONFIG_DEFAULT_FILE_NAME =\n 'micro-frontends.config.json' as const;\n","import { parse } from 'jsonc-parser';\nimport { pathToRegexp, parse as parsePathRegexp } from 'path-to-regexp';\nimport { Ajv } from 'ajv';\nimport type {\n Config,\n ApplicationId,\n PathGroup,\n ApplicationConfigsById,\n Options,\n} from './schema';\nimport { isDefaultApplicationConfig } from './types';\nimport { MicrofrontendError } from './errors';\nimport { SCHEMA } from './utils/load-schema';\n\nexport const validateSchema = (configString: string): Config => {\n const parsedConfig = parse(configString) as Config;\n const ajv = new Ajv();\n const validate = ajv.compile(SCHEMA);\n const isValid = validate(parsedConfig);\n if (!isValid) {\n throw new MicrofrontendError(\n `Invalid config: ${ajv.errorsText(validate.errors)}`,\n { type: 'config', subtype: 'does_not_match_schema' },\n );\n }\n return parsedConfig;\n};\n\nconst SUPPORTED_VERSIONS = ['1'];\n\nexport const validateVersion = (version: string): void => {\n if (!SUPPORTED_VERSIONS.includes(version)) {\n throw new MicrofrontendError(\n `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(\n ', ',\n )}`,\n { type: 'config', subtype: 'unsupported_version' },\n );\n }\n};\n\nexport function validateMainPath(\n applicationConfigsById: ApplicationConfigsById,\n): void {\n for (const [id, app] of Object.entries(applicationConfigsById)) {\n const { defaultRoute } = app.vercel ?? {};\n if (!defaultRoute) {\n continue;\n }\n\n if (isDefaultApplicationConfig(app)) {\n // the defaultRoute for the default application can't match any other applications routes\n const pathsWithApp = [];\n for (const [otherId, otherApp] of Object.entries(\n applicationConfigsById,\n )) {\n if (isDefaultApplicationConfig(otherApp)) {\n continue;\n }\n pathsWithApp.push({\n id: otherId,\n paths: otherApp.routing.matches.flatMap((match) => match.paths),\n });\n }\n\n for (const { id: otherId, paths } of pathsWithApp) {\n const isValid = paths.every((path) => {\n const matcher = pathToRegexp(path);\n return !matcher.test(defaultRoute);\n });\n\n if (!isValid) {\n throw new MicrofrontendError(\n `default route \"${defaultRoute}\" cannot be used for \"${id}\" because it is matched by \"${otherId}\"`,\n { type: 'config', subtype: 'invalid_main_path' },\n );\n }\n }\n // the defaultRoute for a non-default application has to match one of its own paths\n } else {\n const allPaths = app.routing.matches.flatMap((match) => match.paths);\n const isValid = allPaths.some((path) => {\n const matcher = pathToRegexp(path);\n return matcher.test(defaultRoute);\n });\n\n if (!isValid) {\n throw new MicrofrontendError(\n `default route \"${defaultRoute}\" is not included by the routing config for application \"${id}\"`,\n { type: 'config', subtype: 'invalid_main_path' },\n );\n }\n }\n }\n}\n\nexport const validatePaths = (\n applicationConfigsById: ApplicationConfigsById,\n): void => {\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 (isDefaultApplicationConfig(app)) {\n // default applications do not have routing\n continue;\n }\n\n for (const pathMatch of app.routing.matches) {\n for (const path of pathMatch.paths) {\n const maybeError = validatePathExpression(path);\n if (maybeError) {\n errors.push(maybeError);\n }\n\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 const entries = Array.from(pathsByApplicationId.entries());\n\n entries.forEach(([path, { applications: ids, matcher, applicationId }]) => {\n if (ids.length > 1) {\n errors.push(\n `Duplicate path \"${path}\" for applications \"${ids.join(', ')}\"`,\n );\n }\n\n entries.forEach(\n ([\n matchPath,\n { applications: matchIds, applicationId: matchApplicationId },\n ]) => {\n if (path === matchPath) {\n // we're comparing to ourselves, so skip\n return;\n }\n\n if (applicationId === matchApplicationId) {\n // we're comparing to paths within our own application, which are allowed to overlap, so skip\n return;\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\n if (errors.length) {\n throw new MicrofrontendError(`Invalid paths: ${errors.join(', ')}`, {\n type: 'config',\n subtype: 'conflicting_paths',\n });\n }\n};\n\n// From https://github.com/pillarjs/path-to-regexp/blob/b0778f5e8e6c6e9ee4e2f5b34e877cc5229f8036/src/index.ts#L143\nconst PATH_DEFAULT_PATTERN = '[^\\\\/#\\\\?]+?';\n\n// This is a copy of https://github.com/vercel/api/blob/main/scripts/build-container/src/utils/upload-micro-frontend-configuration.ts\n// and should be kept in sync.\nfunction validatePathExpression(path: string): string | undefined {\n const tokens = parsePathRegexp(path);\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.pattern !== PATH_DEFAULT_PATTERN) {\n return `Path ${path} cannot use a regular expression wildcard`;\n }\n if (token.prefix !== '/') {\n return `Wildcard :${token.name} must be immediately after a / in ${path}`;\n }\n if (token.suffix) {\n return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;\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 return undefined;\n}\n\n/** make sure there is exactly one default `Application` */\nexport const validateDefaults = (\n applicationConfigsById: ApplicationConfigsById,\n): void => {\n const defaultApplicationIds = Object.entries(applicationConfigsById).reduce<\n string[]\n // biome-ignore lint/performance/noAccumulatingSpread: Ignored using `--suppress`\n >((acc, [id, app]) => (app.default ? [...acc, id] : acc), []);\n\n if (defaultApplicationIds.length === 0) {\n throw new MicrofrontendError(\n `No default application found. At least one application must be marked as default.`,\n { type: 'config', subtype: 'no_default_application' },\n );\n }\n\n if (defaultApplicationIds.length > 1) {\n throw new MicrofrontendError(\n `Only one default application is allowed. Found ${defaultApplicationIds.join(', ')}.`,\n { type: 'config', subtype: 'multiple_default_applications' },\n );\n }\n};\n\nexport const validateOptions = (options?: Options): void => {\n if (options?.vercel?.previewDeploymentSuffix) {\n if (\n !/^[a-zA-Z]{2,}\\.[a-zA-Z]{2,}$/.test(\n options.vercel.previewDeploymentSuffix,\n )\n ) {\n throw new MicrofrontendError(\n `Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like \"vercel.app\".`,\n { type: 'config', subtype: 'invalid_preview_deployment_suffix' },\n );\n }\n }\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 \"version\": {\n \"type\": \"string\"\n },\n \"$schema\": {\n \"type\": \"string\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Name for the micro-frontend site (eg. \\\"vercel.com\\\", \\\"vercel-site\\\" etc.).\"\n },\n \"applications\": {\n \"$ref\": \"#/definitions/ApplicationConfigsById\"\n },\n \"options\": {\n \"$ref\": \"#/definitions/Options\",\n \"description\": \"Optional configuration for the entire micro-frontends setup.\"\n }\n },\n \"required\": [\"version\", \"applications\"],\n \"description\": \"Configuration for micro-frontend applications\\n\\nTODO: Add proxy configuration\"\n },\n \"ApplicationConfigsById\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"$ref\": \"#/definitions/ApplicationConfig\"\n }\n },\n \"ApplicationConfig\": {\n \"anyOf\": [\n {\n \"$ref\": \"#/definitions/DefaultApplicationConfig\"\n },\n {\n \"$ref\": \"#/definitions/CommonApplicationConfig\"\n }\n ],\n \"description\": \"A Micro-Frontend Deployment Target\"\n },\n \"DefaultApplicationConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"default\": {\n \"type\": \"boolean\",\n \"const\": true,\n \"description\": \"The default application is used no other application is matched via the routing config\"\n },\n \"routing\": {\n \"$ref\": \"#/definitions/Routing\"\n },\n \"development\": {\n \"type\": \"object\",\n \"properties\": {\n \"local\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"fallback\": {\n \"$ref\": \"#/definitions/HostConfig\",\n \"description\": \"Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\"\n },\n \"task\": {\n \"type\": \"string\",\n \"description\": \"Optional task to run when starting the development server. Should reference a script in the package.json of the application.\"\n }\n },\n \"required\": [\"local\"]\n },\n \"production\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"federation\": {\n \"type\": \"object\",\n \"properties\": {\n \"exposes\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"The name of the module - should be used when importing the module from another application\"\n },\n \"path\": {\n \"type\": \"string\",\n \"description\": \"Relative path to the module within its `application`\"\n }\n },\n \"required\": [\"name\", \"path\"]\n },\n \"description\": \"Modules that are exposed by this application\"\n },\n \"uses\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"Modules that are used by this application. Only the name of the module is required.\"\n }\n }\n },\n \"vercel\": {\n \"$ref\": \"#/definitions/Vercel\"\n }\n },\n \"required\": [\"default\", \"development\", \"production\"]\n },\n \"Routing\": {\n \"type\": \"object\",\n \"properties\": {\n \"assetPrefix\": {\n \"type\": \"string\",\n \"description\": \"[assetPrefix] for the application\"\n },\n \"matches\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/PathGroup\"\n },\n \"description\": \"Path expressions that are routed to this application.\"\n }\n },\n \"required\": [\"matches\"]\n },\n \"PathGroup\": {\n \"type\": \"object\",\n \"properties\": {\n \"group\": {\n \"type\": \"string\",\n \"description\": \"Optional group name for the paths\"\n },\n \"options\": {\n \"type\": \"object\",\n \"properties\": {\n \"flag\": {\n \"type\": \"string\",\n \"description\": \"flag name that can be used to enable/disable all paths in the group\"\n },\n \"routeToDefaultApplication\": {\n \"type\": \"boolean\",\n \"description\": \"True to route the request to the default application for this micro-frontends set-up. This must be `true` when using `flag` or when you want to use custom logic to make the routing decision for this group of paths.\"\n }\n }\n },\n \"paths\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\"paths\"]\n },\n \"HostConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"protocol\": {\n \"type\": \"string\",\n \"enum\": [\"http\", \"https\"],\n \"description\": \"The protocol to be used for the connection.\\n- `http`: Hypertext Transfer Protocol (HTTP).\\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\\n\\n* @defaultValue \\\"https\\\"\"\n },\n \"host\": {\n \"type\": \"string\",\n \"description\": \"The hostname or IP address of the server. This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`).\"\n },\n \"port\": {\n \"type\": \"number\",\n \"description\": \"The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS.\\n\\nThis field is optional and can be omitted if the default ports for the specified protocol are used\"\n }\n },\n \"required\": [\"host\"]\n },\n \"Vercel\": {\n \"type\": \"object\",\n \"properties\": {\n \"projectId\": {\n \"type\": \"string\",\n \"description\": \"Vercel project ID\"\n },\n \"projectName\": {\n \"type\": \"string\",\n \"description\": \"Vercel project name (temporary until we can use project ID)\"\n },\n \"defaultRoute\": {\n \"type\": \"string\",\n \"description\": \"The default route for the application. Used to render screenshots, favicons, and provide direct zone links\"\n },\n \"routeSpeedInsightsToDefaultZone\": {\n \"type\": \"boolean\",\n \"description\": \"Whether to route Speed Insights to the default zone or each individual microfrontend.\"\n }\n },\n \"required\": [\"projectId\"]\n },\n \"CommonApplicationConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"default\": {\n \"type\": \"boolean\",\n \"const\": false,\n \"description\": \"The default application is used no other application is matched via the routing config\"\n },\n \"routing\": {\n \"$ref\": \"#/definitions/Routing\"\n },\n \"development\": {\n \"type\": \"object\",\n \"properties\": {\n \"local\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"fallback\": {\n \"$ref\": \"#/definitions/HostConfig\",\n \"description\": \"Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\"\n },\n \"task\": {\n \"type\": \"string\",\n \"description\": \"Optional task to run when starting the development server. Should reference a script in the package.json of the application.\"\n }\n },\n \"required\": [\"local\"]\n },\n \"production\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"federation\": {\n \"type\": \"object\",\n \"properties\": {\n \"exposes\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"The name of the module - should be used when importing the module from another application\"\n },\n \"path\": {\n \"type\": \"string\",\n \"description\": \"Relative path to the module within its `application`\"\n }\n },\n \"required\": [\"name\", \"path\"]\n },\n \"description\": \"Modules that are exposed by this application\"\n },\n \"uses\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"Modules that are used by this application. Only the name of the module is required.\"\n }\n }\n },\n \"vercel\": {\n \"$ref\": \"#/definitions/Vercel\"\n }\n },\n \"required\": [\"default\", \"development\", \"production\", \"routing\"]\n },\n \"Options\": {\n \"type\": \"object\",\n \"properties\": {\n \"vercel\": {\n \"$ref\": \"#/definitions/VercelOptions\",\n \"description\": \"Micro-Frontends wide options for Vercel.\"\n },\n \"localProxy\": {\n \"$ref\": \"#/definitions/LocalProxyOptions\",\n \"description\": \"Options for local proxy.\"\n }\n }\n },\n \"VercelOptions\": {\n \"type\": \"object\",\n \"properties\": {\n \"previewDeploymentSuffix\": {\n \"type\": \"string\",\n \"description\": \"If your team uses a custom Preview Deployment Suffix, please specify it here. See https://vercel.com/docs/deployments/preview-deployment-suffix. The default is `vercel.app`.\"\n },\n \"teamSlug\": {\n \"type\": \"string\",\n \"description\": \"Team slug for the Vercel team\"\n },\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 }\n }\n },\n \"LocalProxyOptions\": {\n \"type\": \"object\",\n \"properties\": {\n \"port\": {\n \"type\": \"number\",\n \"description\": \"The port number used by the local proxy server.\\n\\nThe default is `3024`.\"\n }\n }\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 type {\n Config as ConfigV1,\n ApplicationConfig as ApplicationV1,\n Routing as RoutingV1,\n} from '../schema';\nimport type {\n CommonConfig as CommonConfigV2,\n Config as ConfigV2,\n Application as ApplicationV2,\n Routing as RoutingV2,\n} from '../../config-v2/schema/types';\n\nexport function convertV1RoutingToV2Routing(routing: RoutingV1): RoutingV2 {\n return routing.matches.map((group) => {\n return {\n group: group.group,\n flag: group.options?.flag,\n routeToDefaultApplication: group.options?.routeToDefaultApplication,\n paths: group.paths,\n };\n });\n}\n\nexport function convertV1ApplicationToV2Application(\n application: ApplicationV1,\n): ApplicationV2 {\n const common = {\n production: application.production,\n development: application.development,\n vercel: application.vercel,\n };\n\n if (application.default) {\n return common;\n }\n\n return {\n ...common,\n routing: convertV1RoutingToV2Routing(application.routing),\n };\n}\n\nexport function convertV1ConfigToV2Config(\n config: ConfigV1,\n fromApp: string,\n): ConfigV2 {\n if (!config.applications[fromApp]) {\n throw new Error(`Application \"${fromApp}\" not found in the config`);\n }\n\n const common: CommonConfigV2 = {\n version: '2',\n options: config.options,\n };\n\n if (config.applications[fromApp].default) {\n return {\n ...common,\n // this is assumed for now, and by the time this is released we won't need this conversion\n provider: 'vercel',\n applications: Object.fromEntries(\n Object.entries(config.applications).map(([id, application]) => [\n id,\n convertV1ApplicationToV2Application(application),\n ]),\n ),\n };\n }\n\n // find the default\n const defaultApplication = Object.entries(config.applications).find(\n ([, application]) => application.default,\n );\n\n if (!defaultApplication) {\n throw new Error('No default application found in the config');\n }\n\n return {\n ...common,\n partOf: defaultApplication[0],\n };\n}\n","import fs from 'node:fs';\nimport { dirname } from 'node:path';\nimport type { Config as ConfigV1 } from '../schema';\nimport type { Config as ConfigV2 } from '../../config-v2/schema/types';\n\nexport function writeFile(\n outputPath: string,\n config: ConfigV1 | ConfigV2,\n prettify?: boolean,\n): void {\n // ensure the directory exists\n fs.mkdirSync(dirname(outputPath), { recursive: true });\n fs.writeFileSync(\n outputPath,\n JSON.stringify(config, null, prettify ? 2 : undefined),\n );\n}\n"],"mappings":";AAOO,SAAS,mBAAmB,QAA8B;AAC/D,SAAO;AAAA,IACL,cAAc,OAAO;AAAA,MACnB,OAAO,QAAQ,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,MAAM,WAAW,MAAM;AAAA,QAC/D;AAAA,QACA;AAAA,UACE,SAAS,YAAY;AAAA,UACrB,SAAS,YAAY;AAAA,QACvB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;AAEO,SAAS,yBAAuC;AAGrD,QA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;AACvC,YAAM,WAAW,0BAA0B,QAAQ,OAAO;AAC1D,gBAAU,YAAY,UAAU,MAAM;AAAA,IACxC;AAAA,EACF;AACF;","names":["fs","path","MFE_CONFIG_DEFAULT_FILE_PATH","MFE_CONFIG_DEFAULT_FILE_NAME","getOutputFilePath","path","MFE_CONFIG_DEFAULT_FILE_PATH","MFE_CONFIG_DEFAULT_FILE_NAME","SUPPORTED_VERSIONS","path","fs","getOutputFilePath"]}
1
+ {"version":3,"sources":["../src/config/client/client-config.ts","../src/config/well-known/endpoints.ts","../src/config/types.ts","../src/config/microfrontend-config.ts","../src/config-v2/microfrontends/server/utils/get-output-file-path.ts","../src/config-v2/microfrontends/server/constants.ts","../src/utils/is-vercel.ts","../src/config/errors.ts","../src/routing/url.ts","../src/config/overrides/config.ts","../src/config/common/host.ts","../src/config/common/application.ts","../src/config/common/microfrontend-config.ts","../src/config/utils/get-output-file-path.ts","../src/config/constants.ts","../src/config/validation.ts","../schema/schema.json","../src/config/utils/load-schema.ts","../src/config/utils/convert.ts","../src/config/utils/write-file.ts"],"sourcesContent":["import type { Config } from '../schema';\nimport type { ClientConfig, WellKnownClientData } from './types';\n\n/**\n * Given a micro-frontends configuration, this returns a version that is\n * acceptable to be used client-side without leaking any information.\n */\nexport function getConfigForClient(config: Config): ClientConfig {\n return {\n applications: Object.fromEntries(\n Object.entries(config.applications).map(([name, application]) => [\n name,\n {\n default: application.default,\n routing: application.routing,\n },\n ]),\n ),\n };\n}\n\nexport function getClientConfigFromEnv(): ClientConfig {\n // This has to use the actual name rather than the constant variable in order\n // for the env var to be replaced during the build correctly.\n const clientConfigJson = process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;\n if (!clientConfigJson) {\n throw new Error(\n 'Could not find client micro-frontends config in the environment',\n );\n }\n return JSON.parse(clientConfigJson) as ClientConfig;\n}\n\nexport type { ClientConfig, WellKnownClientData };\n","import { getClientConfigFromEnv } from '../client/client-config';\nimport type { WellKnownClientData } from '../client/types';\n\n/**\n * Returns data used by the client to ensure that navigations across\n * micro-frontend boundaries are routed and prefetched correctly. The client\n * configuration is safe to expose to users.\n *\n * This data should be exposed in a `.well-known/vercel/micro-frontends/client-config`\n * endpoint.\n */\nexport async function getWellKnownClientData(\n flagValues: Record<string, () => Promise<boolean>> = {},\n): Promise<WellKnownClientData> {\n const config = getClientConfigFromEnv();\n for (const [applicationName, application] of Object.entries(\n config.applications,\n )) {\n if (!application.routing) {\n continue;\n }\n const newRoutingMatches = [];\n for (const pathGroup of application.routing.matches) {\n if (pathGroup.options?.flag) {\n const flagName = pathGroup.options.flag;\n const flagFn = flagValues[flagName];\n if (!flagFn) {\n throw new Error(\n `Flag \"${flagName}\" was specified to control routing for path group \"${pathGroup.group}\" in application ${applicationName} but not found in provided flag values.`,\n );\n }\n // eslint-disable-next-line no-await-in-loop\n const flagEnabled = await flagFn();\n if (flagEnabled) {\n newRoutingMatches.push(pathGroup);\n }\n } else {\n newRoutingMatches.push(pathGroup);\n }\n }\n application.routing.matches = newRoutingMatches;\n }\n\n return {\n config,\n };\n}\n","import type {\n ApplicationConfig,\n CommonApplicationConfig,\n DefaultApplicationConfig,\n} from './schema';\n\nexport const isCommonApplicationConfig = (\n app: ApplicationConfig,\n): app is CommonApplicationConfig =>\n !app.default && typeof app.routing === 'object';\n\nexport const isDefaultApplicationConfig = (\n app: ApplicationConfig,\n): app is DefaultApplicationConfig =>\n app.default && typeof app.routing === 'undefined';\n\nexport interface VercelJsonSchema {\n microFrontends?: {\n config?: string;\n };\n}\n","import fs from 'node:fs';\nimport { getOutputFilePath as getV2OutputFilePath } from '../config-v2/microfrontends/server/utils/get-output-file-path';\nimport { MicrofrontendConfigCommon } from './common/microfrontend-config';\nimport type { Config } from './schema';\nimport { MicrofrontendError } from './errors';\nimport { getOutputFilePath } from './utils/get-output-file-path';\nimport {\n validateSchema,\n validateDefaults,\n validatePaths,\n validateMainPath,\n validateVersion,\n validateOptions,\n} from './validation';\nimport { Overrides } from './overrides';\nimport { convertV1ConfigToV2Config } from './utils/convert';\nimport { writeFile } from './utils/write-file';\n\n/**\n * A class to manage the microfrontends configuration with config validation.\n *\n * Cannot be used by the middleware which runs in the Edge Runtime. For middleware use `MicrofrontendConfigEdgeRuntime`.\n */\nexport class MicrofrontendConfig extends MicrofrontendConfigCommon {\n static validate(configString: string): Config {\n const config = validateSchema(configString);\n validateVersion(config.version);\n validatePaths(config.applications);\n validateMainPath(config.applications);\n validateDefaults(config.applications);\n validateOptions(config.options);\n return config;\n }\n\n static fromEnv({\n cookies,\n }: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfig {\n return new MicrofrontendConfigCommon({\n config: MicrofrontendConfig.validate(\n MicrofrontendConfigCommon.getConfigFromEnv(),\n ),\n overrides: Overrides.parseOverrides(cookies),\n });\n }\n\n static fromFile({\n filePath,\n }: {\n filePath: string;\n }): MicrofrontendConfig {\n try {\n const config = fs.readFileSync(filePath, 'utf-8');\n return new MicrofrontendConfig({\n config: MicrofrontendConfig.validate(config),\n });\n } catch (e) {\n throw MicrofrontendError.handle(e, {\n fileName: filePath,\n });\n }\n }\n\n /**\n * Writes the configuration to a file.\n */\n write(\n fromApp: string,\n opts: {\n pretty?: boolean;\n versions?: ('v1' | 'v2')[];\n } = {},\n ): void {\n const { pretty = true, versions = ['v1', 'v2'] } = opts;\n\n const config = this.toSchemaJson();\n if (versions.includes('v1')) {\n const outputPath = getOutputFilePath();\n writeFile(outputPath, config, pretty);\n }\n if (versions.includes('v2')) {\n const outputPath = getV2OutputFilePath();\n const v2Config = convertV1ConfigToV2Config(config, fromApp);\n writeFile(outputPath, v2Config, pretty);\n }\n }\n}\n","import path from 'node:path';\nimport {\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n} from '../constants';\nimport { isVercel } from '../../../../utils/is-vercel';\n\nexport function getOutputFilePath(): string {\n if (isVercel()) {\n return path.join(\n '.vercel',\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n );\n }\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","export function isVercel(): boolean {\n return process.env.VERCEL === '1';\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'zone'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\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 zone:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\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 | '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 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);\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","// NOTE: This is copied from https://github.com/vercel/api/blob/main/packages/util-func/src/url-safe-string.ts.\n// See https://linear.app/vercel/issue/FDRTN-199/spike-move-preview-domain-generation-logic-into-build-and-deploy\n// for cleaning this up before release.\n\ninterface Options {\n joinString?: string;\n lowercaseOnly?: boolean;\n maxLen?: number;\n regexRemovePattern?: RegExp;\n trimWhitespace?: boolean;\n}\n\n/**\n * This function allows to convert single string to URL-safe tags to use for routing,\n * SEO purposes, etc. It is taken from https://www.npmjs.com/package/url-safe-string\n * and implemented here to be typed and skip the dependency.\n */\nfunction buildUrlSafeString(givenOpts: Options = {}): {\n generate: (...args: string[]) => string;\n} {\n const options = {\n joinString: '-',\n lowercaseOnly: true,\n maxLen: 100,\n regexRemovePattern: /(?:(?!(?:[a-z0-9])).)/gi,\n trimWhitespace: true,\n ...givenOpts,\n };\n\n return {\n generate: (...args: string[]) => {\n const reJoinString = new RegExp(`${options.joinString}+`, 'g');\n\n // biome-ignore lint/suspicious/noImplicitAnyLet: Ignored using `--suppress`\n let tag;\n\n if (args.length === 0) {\n throw new Error('generate method must be passed at least one argument');\n }\n\n // Validate, trim all arguments:\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (typeof arg !== 'string')\n throw new Error('all supplied arguments must be Strings');\n\n if (options.trimWhitespace) {\n args[i] = arg.trim();\n }\n }\n\n // Join strings and convert whitespace between words to join string\n tag = args.join(options.joinString);\n tag = tag.replace(/\\s/g, options.joinString);\n if (options.lowercaseOnly) tag = tag.toLowerCase();\n // Regex away anything \"unsafe\", but ignore the join string!\n tag = tag.replace(options.regexRemovePattern, (match) => {\n if (match === options.joinString) return match;\n\n return '';\n });\n\n // Truncate in excess of maxLen\n if (tag.length > options.maxLen) tag = tag.substring(0, options.maxLen);\n\n // Remove any duplicates of the join string using this pattern: /<join string>+/g\n tag = tag.replace(reJoinString, options.joinString);\n\n return tag;\n },\n };\n}\n\n/**\n * Export a preconfigured version for convenience.\n */\nexport const urlSafeString = buildUrlSafeString().generate;\n\nexport function makeUrlSafe(name: string): string {\n return urlSafeString(name.replace(/\\//g, '-'))\n .replace(/^-*/g, '')\n .replace(/-*$/g, '');\n}\n","import { makeUrlSafe } from '../../routing/url';\nimport type { MicrofrontendConfig } from '../microfrontend-config';\nimport type { OverridesConfig } from './types';\n\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\n\nexport class Overrides {\n config: OverridesConfig;\n\n constructor(config: OverridesConfig) {\n this.config = config;\n }\n\n static overrideEnvCookiePrefix = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n\n static getAppEnvOverrideCookieName(zone: string): string {\n return `${Overrides.overrideEnvCookiePrefix}${zone}`;\n }\n\n static isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n }\n\n static getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n }): { zone: string; host: string } | undefined {\n if (!Overrides.isOverrideCookie(cookie) || !cookie.value) return;\n return {\n zone: cookie.name.replace(Overrides.overrideEnvCookiePrefix, ''),\n host: cookie.value,\n };\n }\n\n static parseOverrides(\n cookies: { name: string; value?: string | null }[],\n ): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = Overrides.getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.zone] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n }\n\n static validOverrideDomainsForZone(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n ): string[] {\n const projectName = microfrontendConfig.getZone(zone).vercel?.projectName;\n if (!projectName) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n const parsedProjectName = makeUrlSafe(projectName);\n const previewDeploymentSuffix =\n microfrontendConfig.options?.vercel?.previewDeploymentSuffix;\n const teamSlug = microfrontendConfig.options?.vercel?.teamSlug;\n if (!teamSlug && !previewDeploymentSuffix) {\n return [microfrontendConfig.getZone(zone).production.host];\n }\n\n const suffix = previewDeploymentSuffix\n ? `.${previewDeploymentSuffix}`\n : `-${teamSlug}.vercel.app`;\n\n // <project-name>-git-<branch-name>-<scope-slug>.vercel.app\n // <project-name>-git-<branch-name>.<custom-suffix>\n return [\n `${parsedProjectName}-git-([a-zA-Z0-9-]+)${suffix}`,\n microfrontendConfig.getZone(zone).production.host,\n ];\n }\n\n static validateOverrideDomain(\n microfrontendConfig: MicrofrontendConfig,\n zone: string,\n domain: string,\n ): boolean {\n return new RegExp(\n `^${Overrides.validOverrideDomainsForZone(microfrontendConfig, zone).join(\n '|',\n )}$`,\n ).test(domain);\n }\n\n serialize(): OverridesConfig {\n return this.config;\n }\n}\n","import type { HostConfig } from '../schema';\n\ninterface HostDisplayOptions {\n includeDefaultPort?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: HostConfig['host'];\n port: number;\n serialized: HostConfig;\n\n constructor({ protocol, host, port }: HostConfig) {\n this.protocol = protocol || 'https';\n this.host = host;\n this.port = Host.getPort({ port, protocol: this.protocol });\n this.serialized = {\n protocol,\n host,\n ...(port ? { port } : undefined),\n };\n }\n\n isLocal(): boolean {\n return this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n static getPort({\n protocol,\n port,\n }: { protocol: HostConfig['protocol']; port?: HostConfig['port'] }): number {\n if (!port) {\n if (protocol === 'http') {\n return 80;\n }\n return 443;\n }\n\n return port;\n }\n\n isDefaultPort(): boolean {\n return this.port === Host.getPort({ protocol: this.protocol });\n }\n\n toString(opts: HostDisplayOptions = {}): string {\n const url = this.toUrl(opts);\n // strip the trailing slash\n return url.toString().replace(/\\/$/, '');\n }\n\n toUrl(opts: HostDisplayOptions = {}): URL {\n const { includeDefaultPort } = opts;\n const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? '' : `:${this.port}`}`;\n\n return new URL(url);\n }\n\n serialize(): HostConfig {\n return this.serialized;\n }\n}\n","import type { ApplicationConfig, Routing, Vercel } from '../schema';\nimport type { ApplicationOverrideConfig } from '../overrides';\nimport { MicrofrontendError } from '../errors';\nimport { Host } from './host';\n\nexport class Application {\n default: boolean;\n routing?: Routing;\n name: string;\n development: {\n local: Host;\n fallback?: Host;\n };\n production: Host;\n vercel?: Vercel;\n overrides?: {\n environment?: Host;\n };\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: { app: ApplicationConfig; overrides?: ApplicationOverrideConfig },\n ) {\n // validate\n Application.validate(name, app);\n\n this.name = name;\n this.default = app.default;\n this.routing = app.routing;\n this.development = {\n local: new Host(app.development.local),\n fallback: app.development.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n this.production = new Host(app.production);\n this.vercel = app.vercel;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n static validate(name: string, app: ApplicationConfig): void {\n // validate assetPrefix\n if (\n app.routing?.assetPrefix?.startsWith('/') ||\n app.routing?.assetPrefix?.endsWith('/')\n ) {\n throw new MicrofrontendError(\n `Invalid assetPrefix for application \"${name}\". Must not start or end with a slash.`,\n { type: 'zone', subtype: 'invalid_asset_prefix' },\n );\n }\n\n // validate routes\n for (const group of app.routing?.matches ?? []) {\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: 'zone', 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: 'zone', subtype: 'invalid_path' },\n );\n }\n }\n }\n }\n\n serialize(): ApplicationConfig {\n if (this.routing === undefined || this.default) {\n return {\n default: true,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n\n return {\n default: false,\n routing: this.routing,\n development: {\n local: this.development.local.serialize(),\n fallback: this.development.fallback?.serialize(),\n },\n production: this.production.serialize(),\n vercel: this.vercel,\n };\n }\n}\n","import type { ApplicationConfig, Config, Options } from '../schema';\nimport { MicrofrontendError } from '../errors';\nimport type { OverridesConfig } from '../overrides';\nimport { Overrides } from '../overrides/config';\nimport { Application } from './application';\n\nconst SUPPORTED_VERSIONS = ['1'];\nconst DEFAULT_LOCAL_PROXY_PORT = 3024;\n\n/**\n * A class to manage the microfrontends configuration.\n *\n * This class should not be used directly. Instead, use the `MicrofrontendConfig` or `MicrofrontendConfigEdgeRuntime` classes.\n */\nexport class MicrofrontendConfigCommon {\n config: Config;\n name?: string;\n zones: Record<string, Application> = {};\n version: string;\n overrides?: Overrides;\n options?: Options;\n $schema: string | undefined;\n\n constructor({\n config,\n overrides,\n }: { config: Config; overrides?: OverridesConfig }) {\n if (!SUPPORTED_VERSIONS.includes(config.version)) {\n throw new MicrofrontendError(\n `Unsupported version: ${config.version}. Supported versions are: ${SUPPORTED_VERSIONS.join(\n ', ',\n )}`,\n { type: 'config', subtype: 'unsupported_version' },\n );\n }\n const disableOverrides = config.options?.vercel?.disableOverrides ?? false;\n\n this.overrides =\n overrides && !disableOverrides ? new Overrides(overrides) : undefined;\n\n // create zones\n for (const [zoneName, zoneConfig] of Object.entries(config.applications)) {\n this.zones[zoneName] = new Application(zoneName, {\n app: zoneConfig,\n overrides: !disableOverrides\n ? this.overrides?.config.applications[zoneName]\n : undefined,\n });\n }\n\n this.config = config;\n this.name = config.name;\n this.version = config.version;\n this.options = config.options;\n this.$schema = config.$schema;\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.vercel?.disableOverrides ?? false;\n }\n\n protected static getConfigFromEnv(): 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\n static fromEnv(_: {\n cookies: { name: string; value: string }[];\n }): MicrofrontendConfigCommon | Promise<MicrofrontendConfigCommon> {\n throw new Error('Not implemented');\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getAllApplications(): Application[] {\n return Object.values(this.zones);\n }\n\n getZone(name: string): Application {\n const zone = this.zones[name];\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n getApplicationByProjectId(projectId: string): Application | undefined {\n return Object.values(this.zones).find(\n (zone) => zone.vercel?.projectId === projectId,\n );\n }\n\n getDefaultZone(): Application {\n const zone = Object.values(this.zones).find((z) => z.default);\n if (!zone) {\n throw new MicrofrontendError(\n `Could not find default zone in microfrontends configuration`,\n {\n type: 'zone',\n subtype: 'not_found',\n },\n );\n }\n\n return zone;\n }\n\n /**\n * Returns the configured port for the local proxy\n */\n getLocalProxyPort(): number {\n return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;\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 const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n $schema: this.$schema,\n name: this.name,\n version: this.version,\n options: this.options,\n applications,\n };\n }\n\n serialize(): { config: Config; overrides?: OverridesConfig } {\n const applications: Record<string, ApplicationConfig> = {};\n for (const [name, zone] of Object.entries(this.zones)) {\n applications[name] = zone.serialize();\n }\n\n return {\n config: {\n name: this.name,\n version: this.version,\n applications,\n options: this.options,\n $schema: this.$schema,\n },\n overrides: this.overrides?.serialize(),\n };\n }\n\n write(_: string): void {\n throw new MicrofrontendError(\n `Writing to file to disk requires using an instance of \"MicrofrontendConfig\".`,\n { type: 'config', subtype: 'unsupported_operation' },\n );\n }\n}\n","import path from 'node:path';\nimport {\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n} from '../constants';\nimport { isVercel } from '../../utils/is-vercel';\n\nexport function getOutputFilePath(): string {\n if (isVercel()) {\n return path.join(\n '.vercel',\n MFE_CONFIG_DEFAULT_FILE_PATH,\n MFE_CONFIG_DEFAULT_FILE_NAME,\n );\n }\n return path.join(MFE_CONFIG_DEFAULT_FILE_PATH, MFE_CONFIG_DEFAULT_FILE_NAME);\n}\n","/**\n * Default path to use for the micro-frontends configuration when output to a file.\n */\nexport const MFE_CONFIG_DEFAULT_FILE_PATH = 'micro-frontends' as const;\n\n/**\n * Default name to use for the micro-frontends configuration when output to a file.\n */\nexport const MFE_CONFIG_DEFAULT_FILE_NAME =\n 'micro-frontends.config.json' as const;\n","import { parse } from 'jsonc-parser';\nimport { pathToRegexp, parse as parsePathRegexp } from 'path-to-regexp';\nimport { Ajv } from 'ajv';\nimport type {\n Config,\n ApplicationId,\n PathGroup,\n ApplicationConfigsById,\n Options,\n} from './schema';\nimport { isDefaultApplicationConfig } from './types';\nimport { MicrofrontendError } from './errors';\nimport { SCHEMA } from './utils/load-schema';\n\nexport const validateSchema = (configString: string): Config => {\n const parsedConfig = parse(configString) as Config;\n const ajv = new Ajv();\n const validate = ajv.compile(SCHEMA);\n const isValid = validate(parsedConfig);\n if (!isValid) {\n throw new MicrofrontendError(\n `Invalid config: ${ajv.errorsText(validate.errors)}`,\n { type: 'config', subtype: 'does_not_match_schema' },\n );\n }\n return parsedConfig;\n};\n\nconst SUPPORTED_VERSIONS = ['1'];\n\nexport const validateVersion = (version: string): void => {\n if (!SUPPORTED_VERSIONS.includes(version)) {\n throw new MicrofrontendError(\n `Unsupported version: ${version}. Supported versions are: ${SUPPORTED_VERSIONS.join(\n ', ',\n )}`,\n { type: 'config', subtype: 'unsupported_version' },\n );\n }\n};\n\nexport function validateMainPath(\n applicationConfigsById: ApplicationConfigsById,\n): void {\n for (const [id, app] of Object.entries(applicationConfigsById)) {\n const { defaultRoute } = app.vercel ?? {};\n if (!defaultRoute) {\n continue;\n }\n\n if (isDefaultApplicationConfig(app)) {\n // the defaultRoute for the default application can't match any other applications routes\n const pathsWithApp = [];\n for (const [otherId, otherApp] of Object.entries(\n applicationConfigsById,\n )) {\n if (isDefaultApplicationConfig(otherApp)) {\n continue;\n }\n pathsWithApp.push({\n id: otherId,\n paths: otherApp.routing.matches.flatMap((match) => match.paths),\n });\n }\n\n for (const { id: otherId, paths } of pathsWithApp) {\n const isValid = paths.every((path) => {\n const matcher = pathToRegexp(path);\n return !matcher.test(defaultRoute);\n });\n\n if (!isValid) {\n throw new MicrofrontendError(\n `default route \"${defaultRoute}\" cannot be used for \"${id}\" because it is matched by \"${otherId}\"`,\n { type: 'config', subtype: 'invalid_main_path' },\n );\n }\n }\n // the defaultRoute for a non-default application has to match one of its own paths\n } else {\n const allPaths = app.routing.matches.flatMap((match) => match.paths);\n const isValid = allPaths.some((path) => {\n const matcher = pathToRegexp(path);\n return matcher.test(defaultRoute);\n });\n\n if (!isValid) {\n throw new MicrofrontendError(\n `default route \"${defaultRoute}\" is not included by the routing config for application \"${id}\"`,\n { type: 'config', subtype: 'invalid_main_path' },\n );\n }\n }\n }\n}\n\nexport const validatePaths = (\n applicationConfigsById: ApplicationConfigsById,\n): void => {\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 (isDefaultApplicationConfig(app)) {\n // default applications do not have routing\n continue;\n }\n\n for (const pathMatch of app.routing.matches) {\n for (const path of pathMatch.paths) {\n const maybeError = validatePathExpression(path);\n if (maybeError) {\n errors.push(maybeError);\n }\n\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 const entries = Array.from(pathsByApplicationId.entries());\n\n entries.forEach(([path, { applications: ids, matcher, applicationId }]) => {\n if (ids.length > 1) {\n errors.push(\n `Duplicate path \"${path}\" for applications \"${ids.join(', ')}\"`,\n );\n }\n\n entries.forEach(\n ([\n matchPath,\n { applications: matchIds, applicationId: matchApplicationId },\n ]) => {\n if (path === matchPath) {\n // we're comparing to ourselves, so skip\n return;\n }\n\n if (applicationId === matchApplicationId) {\n // we're comparing to paths within our own application, which are allowed to overlap, so skip\n return;\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\n if (errors.length) {\n throw new MicrofrontendError(`Invalid paths: ${errors.join(', ')}`, {\n type: 'config',\n subtype: 'conflicting_paths',\n });\n }\n};\n\n// From https://github.com/pillarjs/path-to-regexp/blob/b0778f5e8e6c6e9ee4e2f5b34e877cc5229f8036/src/index.ts#L143\nconst PATH_DEFAULT_PATTERN = '[^\\\\/#\\\\?]+?';\n\n// This is a copy of https://github.com/vercel/api/blob/main/scripts/build-container/src/utils/upload-micro-frontend-configuration.ts\n// and should be kept in sync.\nfunction validatePathExpression(path: string): string | undefined {\n const tokens = parsePathRegexp(path);\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.pattern !== PATH_DEFAULT_PATTERN) {\n return `Path ${path} cannot use a regular expression wildcard`;\n }\n if (token.prefix !== '/') {\n return `Wildcard :${token.name} must be immediately after a / in ${path}`;\n }\n if (token.suffix) {\n return `Wildcard suffix on :${token.name} is not allowed. Suffixes are not supported`;\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 return undefined;\n}\n\n/** make sure there is exactly one default `Application` */\nexport const validateDefaults = (\n applicationConfigsById: ApplicationConfigsById,\n): void => {\n const defaultApplicationIds = Object.entries(applicationConfigsById).reduce<\n string[]\n // biome-ignore lint/performance/noAccumulatingSpread: Ignored using `--suppress`\n >((acc, [id, app]) => (app.default ? [...acc, id] : acc), []);\n\n if (defaultApplicationIds.length === 0) {\n throw new MicrofrontendError(\n `No default application found. At least one application must be marked as default.`,\n { type: 'config', subtype: 'no_default_application' },\n );\n }\n\n if (defaultApplicationIds.length > 1) {\n throw new MicrofrontendError(\n `Only one default application is allowed. Found ${defaultApplicationIds.join(', ')}.`,\n { type: 'config', subtype: 'multiple_default_applications' },\n );\n }\n};\n\nexport const validateOptions = (options?: Options): void => {\n if (options?.vercel?.previewDeploymentSuffix) {\n if (\n !/^[a-zA-Z]{2,}\\.[a-zA-Z]{2,}$/.test(\n options.vercel.previewDeploymentSuffix,\n )\n ) {\n throw new MicrofrontendError(\n `Invalid preview deployment suffix: ${options.vercel.previewDeploymentSuffix}. Should have be formatted like \"vercel.app\".`,\n { type: 'config', subtype: 'invalid_preview_deployment_suffix' },\n );\n }\n }\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 \"version\": {\n \"type\": \"string\"\n },\n \"$schema\": {\n \"type\": \"string\"\n },\n \"name\": {\n \"type\": \"string\",\n \"description\": \"Name for the micro-frontend site (eg. \\\"vercel.com\\\", \\\"vercel-site\\\" etc.).\"\n },\n \"applications\": {\n \"$ref\": \"#/definitions/ApplicationConfigsById\"\n },\n \"options\": {\n \"$ref\": \"#/definitions/Options\",\n \"description\": \"Optional configuration for the entire micro-frontends setup.\"\n }\n },\n \"required\": [\"version\", \"applications\"],\n \"description\": \"Configuration for micro-frontend applications\\n\\nTODO: Add proxy configuration\"\n },\n \"ApplicationConfigsById\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"$ref\": \"#/definitions/ApplicationConfig\"\n }\n },\n \"ApplicationConfig\": {\n \"anyOf\": [\n {\n \"$ref\": \"#/definitions/DefaultApplicationConfig\"\n },\n {\n \"$ref\": \"#/definitions/CommonApplicationConfig\"\n }\n ],\n \"description\": \"A Micro-Frontend Deployment Target\"\n },\n \"DefaultApplicationConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"default\": {\n \"type\": \"boolean\",\n \"const\": true,\n \"description\": \"The default application is used no other application is matched via the routing config\"\n },\n \"routing\": {\n \"$ref\": \"#/definitions/Routing\"\n },\n \"development\": {\n \"type\": \"object\",\n \"properties\": {\n \"local\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"fallback\": {\n \"$ref\": \"#/definitions/HostConfig\",\n \"description\": \"Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\"\n },\n \"task\": {\n \"type\": \"string\",\n \"description\": \"Optional task to run when starting the development server. Should reference a script in the package.json of the application.\"\n }\n },\n \"required\": [\"local\"]\n },\n \"production\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"federation\": {\n \"type\": \"object\",\n \"properties\": {\n \"exposes\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"The name of the module - should be used when importing the module from another application\"\n },\n \"path\": {\n \"type\": \"string\",\n \"description\": \"Relative path to the module within its `application`\"\n }\n },\n \"required\": [\"name\", \"path\"]\n },\n \"description\": \"Modules that are exposed by this application\"\n },\n \"uses\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"Modules that are used by this application. Only the name of the module is required.\"\n }\n }\n },\n \"vercel\": {\n \"$ref\": \"#/definitions/Vercel\"\n }\n },\n \"required\": [\"default\", \"development\", \"production\"]\n },\n \"Routing\": {\n \"type\": \"object\",\n \"properties\": {\n \"assetPrefix\": {\n \"type\": \"string\",\n \"description\": \"[assetPrefix] for the application\"\n },\n \"matches\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/definitions/PathGroup\"\n },\n \"description\": \"Path expressions that are routed to this application.\"\n }\n },\n \"required\": [\"matches\"]\n },\n \"PathGroup\": {\n \"type\": \"object\",\n \"properties\": {\n \"group\": {\n \"type\": \"string\",\n \"description\": \"Optional group name for the paths\"\n },\n \"options\": {\n \"type\": \"object\",\n \"properties\": {\n \"flag\": {\n \"type\": \"string\",\n \"description\": \"flag name that can be used to enable/disable all paths in the group\"\n }\n }\n },\n \"paths\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\"paths\"]\n },\n \"HostConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"protocol\": {\n \"type\": \"string\",\n \"enum\": [\"http\", \"https\"],\n \"description\": \"The protocol to be used for the connection.\\n- `http`: Hypertext Transfer Protocol (HTTP).\\n- `https`: Secure Hypertext Transfer Protocol (HTTPS).\\n\\n* @defaultValue \\\"https\\\"\"\n },\n \"host\": {\n \"type\": \"string\",\n \"description\": \"The hostname or IP address of the server. This can be a domain name (e.g., `example.com`) or an IP address (e.g., `192.168.1.1`).\"\n },\n \"port\": {\n \"type\": \"number\",\n \"description\": \"The port number to be used for the connection. Common values include `80` for HTTP and `443` for HTTPS.\\n\\nThis field is optional and can be omitted if the default ports for the specified protocol are used\"\n }\n },\n \"required\": [\"host\"]\n },\n \"Vercel\": {\n \"type\": \"object\",\n \"properties\": {\n \"projectId\": {\n \"type\": \"string\",\n \"description\": \"Vercel project ID\"\n },\n \"projectName\": {\n \"type\": \"string\",\n \"description\": \"Vercel project name (temporary until we can use project ID)\"\n },\n \"defaultRoute\": {\n \"type\": \"string\",\n \"description\": \"The default route for the application. Used to render screenshots, favicons, and provide direct zone links\"\n },\n \"routeSpeedInsightsToDefaultZone\": {\n \"type\": \"boolean\",\n \"description\": \"Whether to route Speed Insights to the default zone or each individual microfrontend.\"\n }\n },\n \"required\": [\"projectId\"]\n },\n \"CommonApplicationConfig\": {\n \"type\": \"object\",\n \"properties\": {\n \"default\": {\n \"type\": \"boolean\",\n \"const\": false,\n \"description\": \"The default application is used no other application is matched via the routing config\"\n },\n \"routing\": {\n \"$ref\": \"#/definitions/Routing\"\n },\n \"development\": {\n \"type\": \"object\",\n \"properties\": {\n \"local\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"fallback\": {\n \"$ref\": \"#/definitions/HostConfig\",\n \"description\": \"Fallback for local development, could be a host config that points to any environment. If this is not provided, or the application is not running - requests to the application in local development will error.\"\n },\n \"task\": {\n \"type\": \"string\",\n \"description\": \"Optional task to run when starting the development server. Should reference a script in the package.json of the application.\"\n }\n },\n \"required\": [\"local\"]\n },\n \"production\": {\n \"$ref\": \"#/definitions/HostConfig\"\n },\n \"metadata\": {\n \"type\": \"object\",\n \"additionalProperties\": {\n \"type\": \"string\"\n }\n },\n \"federation\": {\n \"type\": \"object\",\n \"properties\": {\n \"exposes\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\",\n \"description\": \"The name of the module - should be used when importing the module from another application\"\n },\n \"path\": {\n \"type\": \"string\",\n \"description\": \"Relative path to the module within its `application`\"\n }\n },\n \"required\": [\"name\", \"path\"]\n },\n \"description\": \"Modules that are exposed by this application\"\n },\n \"uses\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"Modules that are used by this application. Only the name of the module is required.\"\n }\n }\n },\n \"vercel\": {\n \"$ref\": \"#/definitions/Vercel\"\n }\n },\n \"required\": [\"default\", \"development\", \"production\", \"routing\"]\n },\n \"Options\": {\n \"type\": \"object\",\n \"properties\": {\n \"vercel\": {\n \"$ref\": \"#/definitions/VercelOptions\",\n \"description\": \"Micro-Frontends wide options for Vercel.\"\n },\n \"localProxy\": {\n \"$ref\": \"#/definitions/LocalProxyOptions\",\n \"description\": \"Options for local proxy.\"\n }\n }\n },\n \"VercelOptions\": {\n \"type\": \"object\",\n \"properties\": {\n \"previewDeploymentSuffix\": {\n \"type\": \"string\",\n \"description\": \"If your team uses a custom Preview Deployment Suffix, please specify it here. See https://vercel.com/docs/deployments/preview-deployment-suffix. The default is `vercel.app`.\"\n },\n \"teamSlug\": {\n \"type\": \"string\",\n \"description\": \"Team slug for the Vercel team\"\n },\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 }\n }\n },\n \"LocalProxyOptions\": {\n \"type\": \"object\",\n \"properties\": {\n \"port\": {\n \"type\": \"number\",\n \"description\": \"The port number used by the local proxy server.\\n\\nThe default is `3024`.\"\n }\n }\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 type {\n Config as ConfigV1,\n ApplicationConfig as ApplicationV1,\n Routing as RoutingV1,\n} from '../schema';\nimport type {\n CommonConfig as CommonConfigV2,\n Config as ConfigV2,\n Application as ApplicationV2,\n Routing as RoutingV2,\n} from '../../config-v2/schema/types';\n\nexport function convertV1RoutingToV2Routing(routing: RoutingV1): RoutingV2 {\n return routing.matches.map((group) => {\n return {\n group: group.group,\n flag: group.options?.flag,\n paths: group.paths,\n };\n });\n}\n\nexport function convertV1ApplicationToV2Application(\n application: ApplicationV1,\n): ApplicationV2 {\n const common = {\n production: application.production,\n development: application.development,\n vercel: application.vercel,\n };\n\n if (application.default) {\n return common;\n }\n\n return {\n ...common,\n routing: convertV1RoutingToV2Routing(application.routing),\n };\n}\n\nexport function convertV1ConfigToV2Config(\n config: ConfigV1,\n fromApp: string,\n): ConfigV2 {\n if (!config.applications[fromApp]) {\n throw new Error(`Application \"${fromApp}\" not found in the config`);\n }\n\n const common: CommonConfigV2 = {\n version: '2',\n options: config.options,\n };\n\n if (config.applications[fromApp].default) {\n return {\n ...common,\n // this is assumed for now, and by the time this is released we won't need this conversion\n provider: 'vercel',\n applications: Object.fromEntries(\n Object.entries(config.applications).map(([id, application]) => [\n id,\n convertV1ApplicationToV2Application(application),\n ]),\n ),\n };\n }\n\n // find the default\n const defaultApplication = Object.entries(config.applications).find(\n ([, application]) => application.default,\n );\n\n if (!defaultApplication) {\n throw new Error('No default application found in the config');\n }\n\n return {\n ...common,\n partOf: defaultApplication[0],\n };\n}\n","import fs from 'node:fs';\nimport { dirname } from 'node:path';\nimport type { Config as ConfigV1 } from '../schema';\nimport type { Config as ConfigV2 } from '../../config-v2/schema/types';\n\nexport function writeFile(\n outputPath: string,\n config: ConfigV1 | ConfigV2,\n prettify?: boolean,\n): void {\n // ensure the directory exists\n fs.mkdirSync(dirname(outputPath), { recursive: true });\n fs.writeFileSync(\n outputPath,\n JSON.stringify(config, null, prettify ? 2 : undefined),\n );\n}\n"],"mappings":";AAOO,SAAS,mBAAmB,QAA8B;AAC/D,SAAO;AAAA,IACL,cAAc,OAAO;AAAA,MACnB,OAAO,QAAQ,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,MAAM,WAAW,MAAM;AAAA,QAC/D;AAAA,QACA;AA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B,YAAM,aAAa,kBAAoB;AACvC,YAAM,WAAW,0BAA0B,QAAQ,OAAO;AAC1D,gBAAU,YAAY,UAAU,MAAM;AAAA,IACxC;AAAA,EACF;AACF;","names":["fs","path","MFE_CONFIG_DEFAULT_FILE_PATH","MFE_CONFIG_DEFAULT_FILE_NAME","getOutputFilePath","path","MFE_CONFIG_DEFAULT_FILE_PATH","MFE_CONFIG_DEFAULT_FILE_NAME","SUPPORTED_VERSIONS","path","fs","getOutputFilePath"]}
@@ -1,5 +1,5 @@
1
- import { A as ApplicationId, b as PathGroup, H as HostConfig, L as LocalHostConfig, D as DefaultApplication$1, c as ChildApplication$1, V as Vercel, d as Application$1, C as Config } from './types-4fd1c7c6.js';
2
- import { A as ApplicationOverrideConfig, O as OverridesConfig } from './types-13f3e535.js';
1
+ import { A as ApplicationId, b as PathGroup, H as HostConfig, L as LocalHostConfig, D as DefaultApplication$1, c as ChildApplication$1, V as Vercel, d as Application$1, C as Config } from './types-0030abae.js';
2
+ import { A as ApplicationOverrideConfig, O as OverridesConfig } from './types-c777c2f5.js';
3
3
 
4
4
  interface ClientApplication {
5
5
  routing?: PathGroup[];
@@ -1,4 +1,4 @@
1
- import { H as HostConfig, C as Config, R as Routing, V as Vercel, A as ApplicationConfig, O as Options } from './schema-83a75e61.js';
1
+ import { H as HostConfig, C as Config, R as Routing, V as Vercel, A as ApplicationConfig, O as Options } from './schema-2922d49e.js';
2
2
 
3
3
  interface ApplicationOverrideConfig {
4
4
  environment?: HostConfig;
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use strict";var D=Object.create;var h=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var W=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},k=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of M(t))!z.call(e,o)&&o!==n&&h(e,o,{get:()=>t[o],enumerable:!(s=I(t,o))||s.enumerable});return e};var N=(e,t,n)=>(n=e!=null?D(J(e)):{},k(t||!e||!e.__esModule?h(n,"default",{value:e,enumerable:!0}):n,e)),B=e=>k(h({},"__esModule",{value:!0}),e);var G={};W(G,{Link:()=>Z,PrefetchCrossZoneLinks:()=>K,PrefetchCrossZoneLinksContext:()=>C,PrefetchCrossZoneLinksProvider:()=>V,useZoneForHref:()=>H});module.exports=B(G);var E=require("react"),F=N(require("next/link"),1);var f=require("react"),u=require("react/jsx-runtime"),C=(0,f.createContext)({prefetchHref:()=>{}});function V({children:e}){let[t,n]=(0,f.useState)(new Set),[s,o]=(0,f.useState)(!1);(0,f.useEffect)(()=>{o(typeof navigator<"u"&&(navigator.userAgent.includes("Firefox")||navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")))},[]);let i=(0,f.useCallback)(r=>{t.has(r)||n(new Set(t).add(r))},[t]),a=(0,f.useMemo)(()=>({prefetchHref:i}),[i]);return s?(0,u.jsxs)(C.Provider,{value:a,children:[e,[...t].map(r=>(0,u.jsx)("link",{as:"fetch",href:r,rel:"preload"},r))]}):(0,u.jsx)(u.Fragment,{children:e})}var m=require("react"),R=N(require("next/script"),1);var p=require("react");function g(){let e=process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;if(!e)throw new Error("Could not find client micro-frontends config in the environment");return JSON.parse(e)}var y=null;async function $(){try{let e=await fetch("/.well-known/vercel/micro-frontends/client-config");return e.status!==200?null:(await e.json()).config}catch{return null}}function U(e,t){return JSON.stringify(e)===JSON.stringify(t)}function X(e){for(let t of Object.values(e.applications))t.routing&&(t.routing.matches=t.routing.matches.filter(n=>{var s;return!((s=n.options)!=null&&s.flag)}));return e}function d({removeFlaggedPathsFromDefault:e}={}){let[t,n]=(0,p.useState)(e?X(g()):g()),[s,o]=(0,p.useState)(!0);return(0,p.useEffect)(()=>{if(process.env.NODE_ENV==="test"&&process.env.MFE_FORCE_CLIENT_CONFIG_FROM_SERVER!=="1"){o(!1);return}let i=g();if(!Object.values(i.applications).some(r=>{var l;return(l=r.routing)==null?void 0:l.matches.some(P=>{var _,b;return((_=P.options)==null?void 0:_.flag)||((b=P.options)==null?void 0:b.routeToDefaultApplication)})})){o(!1);return}y||(y=$()),y.then(r=>{r&&n(l=>U(l,r)?l:r)}).finally(()=>{o(!1)})},[t.applications]),{clientConfig:t,isLoading:s}}var A=require("react/jsx-runtime"),L="data-prefetch",c={anyZone:"[data-zone]",external:'[data-zone="null"]',sameZone:'[data-zone="same"]',prefetch:`[${L}]`},O={and:[{href_matches:"/*"},{selector_matches:c.anyZone},{not:{selector_matches:c.sameZone}},{not:{selector_matches:c.external}}]},j={and:[{href_matches:"/*"},{selector_matches:c.anyZone},{not:{selector_matches:c.sameZone}},{not:{selector_matches:c.external}},{selector_matches:c.prefetch}]};function S(e){if(!e)return!0;if("checkVisibility"in e)return e.checkVisibility({opacityProperty:!0});let t=e,n=window.getComputedStyle(t);return n.display==="none"||n.visibility==="hidden"||n.opacity==="0"?!1:S(t.parentElement)}function K(){let{isLoading:e}=d(),[t,n]=(0,m.useState)([]);return(0,m.useEffect)(()=>{if(e)return;let o=new IntersectionObserver(i=>{i.forEach(a=>{a.isIntersecting&&!a.target.hasAttribute(L)&&S(a.target)&&a.target.setAttribute(L,"true")})},{root:null,rootMargin:"0px",threshold:.1});return t.forEach(i=>o.observe(i)),()=>{o.disconnect()}},[e,t]),(0,m.useEffect)(()=>{if(e)return;let o=new MutationObserver(i=>{i.some(r=>r.type==="childList"&&r.addedNodes.length>0||r.type==="attributes"&&r.attributeName==="href")&&n(Array.from(document.querySelectorAll(`a${c.anyZone}:not(${c.prefetch}):not(${c.sameZone}):not(${c.external})`)))});return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["href"]}),()=>{o.disconnect()}},[e]),e?null:(0,A.jsx)(R.default,{dangerouslySetInnerHTML:{__html:`${JSON.stringify({prefetch:[{eagerness:"moderate",where:O},{eagerness:"immediate",where:j}],prerender:[{eagerness:"conservative",where:O}]})}`},id:"prefetch-zones-links",type:"speculationrules"})}var T=require("path-to-regexp"),v=new WeakMap;function w(e,t){if(!t.startsWith("/"))throw new Error("Path must start with a /");let n=v.get(e)??{};if(n[t])return n[t];v.has(e)||v.set(e,n);let s=new URL(t,"https://example.com").pathname;for(let[i,a]of Object.entries(e.applications))if(a.routing){for(let r of a.routing.matches)for(let l of r.paths)if((0,T.pathToRegexp)(l).test(s))return n[t]=i,i}let o=Object.entries(e.applications).find(([,i])=>i.default);if(!o)throw new Error("No default application found. A default application must be configured in the micro-frontends configuration.");return n[t]=o[0],o[0]}var x=require("react/jsx-runtime"),q=process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION;function H(e){let{clientConfig:t,isLoading:n}=d({removeFlaggedPathsFromDefault:!0}),s=typeof e=="string"&&e.startsWith("/"),o=s?w(t,e):null;return{zoneOfHref:o,isDifferentZone:!s||(o?q!==o:!1),isLoading:n}}var Z=(0,E.forwardRef)(({children:e,...t},n)=>{let{prefetchHref:s}=(0,E.useContext)(C),{zoneOfHref:o,isDifferentZone:i,isLoading:a}=H(t.href);function r(){t.href&&s(t.href)}return i&&o!==null?(0,x.jsx)("a",{...t,"data-zone":o,onMouseOver:t.prefetch!==!1?r:void 0,children:e}):(0,x.jsx)(F.default,{...t,"data-zone":o?"same":"null",prefetch:t.prefetch??(a?!1:void 0),ref:n,children:e})});Z.displayName="MultiZonesLink";0&&(module.exports={Link,PrefetchCrossZoneLinks,PrefetchCrossZoneLinksContext,PrefetchCrossZoneLinksProvider,useZoneForHref});
2
+ "use strict";var Z=Object.create;var C=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var D=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var z=(e,t)=>{for(var n in t)C(e,n,{get:t[n],enumerable:!0})},b=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of M(t))!J.call(e,o)&&o!==n&&C(e,o,{get:()=>t[o],enumerable:!(s=I(t,o))||s.enumerable});return e};var k=(e,t,n)=>(n=e!=null?Z(D(e)):{},b(t||!e||!e.__esModule?C(n,"default",{value:e,enumerable:!0}):n,e)),W=e=>b(C({},"__esModule",{value:!0}),e);var q={};z(q,{Link:()=>H,PrefetchCrossZoneLinks:()=>j,PrefetchCrossZoneLinksContext:()=>g,PrefetchCrossZoneLinksProvider:()=>B,useZoneForHref:()=>T});module.exports=W(q);var P=require("react"),F=k(require("next/link"),1);var f=require("react"),u=require("react/jsx-runtime"),g=(0,f.createContext)({prefetchHref:()=>{}});function B({children:e}){let[t,n]=(0,f.useState)(new Set),[s,o]=(0,f.useState)(!1);(0,f.useEffect)(()=>{o(typeof navigator<"u"&&(navigator.userAgent.includes("Firefox")||navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")))},[]);let i=(0,f.useCallback)(r=>{t.has(r)||n(new Set(t).add(r))},[t]),a=(0,f.useMemo)(()=>({prefetchHref:i}),[i]);return s?(0,u.jsxs)(g.Provider,{value:a,children:[e,[...t].map(r=>(0,u.jsx)("link",{as:"fetch",href:r,rel:"preload"},r))]}):(0,u.jsx)(u.Fragment,{children:e})}var m=require("react"),O=k(require("next/script"),1);var p=require("react");function d(){let e=process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;if(!e)throw new Error("Could not find client micro-frontends config in the environment");return JSON.parse(e)}var y=null;async function V(){try{let e=await fetch("/.well-known/vercel/micro-frontends/client-config");return e.status!==200?null:(await e.json()).config}catch{return null}}function $(e,t){return JSON.stringify(e)===JSON.stringify(t)}function U(e){for(let t of Object.values(e.applications))t.routing&&(t.routing.matches=t.routing.matches.filter(n=>{var s;return!((s=n.options)!=null&&s.flag)}));return e}function E({removeFlaggedPathsFromDefault:e}={}){let[t,n]=(0,p.useState)(e?U(d()):d()),[s,o]=(0,p.useState)(!0);return(0,p.useEffect)(()=>{if(process.env.NODE_ENV==="test"&&process.env.MFE_FORCE_CLIENT_CONFIG_FROM_SERVER!=="1"){o(!1);return}let i=d();if(!Object.values(i.applications).some(r=>{var l;return(l=r.routing)==null?void 0:l.matches.some(h=>{var x;return(x=h.options)==null?void 0:x.flag})})){o(!1);return}y||(y=V()),y.then(r=>{r&&n(l=>$(l,r)?l:r)}).finally(()=>{o(!1)})},[t.applications]),{clientConfig:t,isLoading:s}}var S=require("react/jsx-runtime"),L="data-prefetch",c={anyZone:"[data-zone]",external:'[data-zone="null"]',sameZone:'[data-zone="same"]',prefetch:`[${L}]`},N={and:[{href_matches:"/*"},{selector_matches:c.anyZone},{not:{selector_matches:c.sameZone}},{not:{selector_matches:c.external}}]},X={and:[{href_matches:"/*"},{selector_matches:c.anyZone},{not:{selector_matches:c.sameZone}},{not:{selector_matches:c.external}},{selector_matches:c.prefetch}]};function R(e){if(!e)return!0;if("checkVisibility"in e)return e.checkVisibility({opacityProperty:!0});let t=e,n=window.getComputedStyle(t);return n.display==="none"||n.visibility==="hidden"||n.opacity==="0"?!1:R(t.parentElement)}function j(){let{isLoading:e}=E(),[t,n]=(0,m.useState)([]);return(0,m.useEffect)(()=>{if(e)return;let o=new IntersectionObserver(i=>{i.forEach(a=>{a.isIntersecting&&!a.target.hasAttribute(L)&&R(a.target)&&a.target.setAttribute(L,"true")})},{root:null,rootMargin:"0px",threshold:.1});return t.forEach(i=>o.observe(i)),()=>{o.disconnect()}},[e,t]),(0,m.useEffect)(()=>{if(e)return;let o=new MutationObserver(i=>{i.some(r=>r.type==="childList"&&r.addedNodes.length>0||r.type==="attributes"&&r.attributeName==="href")&&n(Array.from(document.querySelectorAll(`a${c.anyZone}:not(${c.prefetch}):not(${c.sameZone}):not(${c.external})`)))});return o.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["href"]}),()=>{o.disconnect()}},[e]),e?null:(0,S.jsx)(O.default,{dangerouslySetInnerHTML:{__html:`${JSON.stringify({prefetch:[{eagerness:"moderate",where:N},{eagerness:"immediate",where:X}],prerender:[{eagerness:"conservative",where:N}]})}`},id:"prefetch-zones-links",type:"speculationrules"})}var A=require("path-to-regexp"),v=new WeakMap;function w(e,t){if(!t.startsWith("/"))throw new Error("Path must start with a /");let n=v.get(e)??{};if(n[t])return n[t];v.has(e)||v.set(e,n);let s=new URL(t,"https://example.com").pathname;for(let[i,a]of Object.entries(e.applications))if(a.routing){for(let r of a.routing.matches)for(let l of r.paths)if((0,A.pathToRegexp)(l).test(s))return n[t]=i,i}let o=Object.entries(e.applications).find(([,i])=>i.default);if(!o)throw new Error("No default application found. A default application must be configured in the micro-frontends configuration.");return n[t]=o[0],o[0]}var _=require("react/jsx-runtime"),K=process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION;function T(e){let{clientConfig:t,isLoading:n}=E({removeFlaggedPathsFromDefault:!0}),s=typeof e=="string"&&e.startsWith("/"),o=s?w(t,e):null;return{zoneOfHref:o,isDifferentZone:!s||(o?K!==o:!1),isLoading:n}}var H=(0,P.forwardRef)(({children:e,...t},n)=>{let{prefetchHref:s}=(0,P.useContext)(g),{zoneOfHref:o,isDifferentZone:i,isLoading:a}=T(t.href);function r(){t.href&&s(t.href)}if(i&&o!==null){let{prefetch:l,...h}=t;return(0,_.jsx)("a",{...h,"data-zone":o,onMouseOver:t.prefetch!==!1?r:void 0,children:e})}return(0,_.jsx)(F.default,{...t,"data-zone":o?"same":"null",prefetch:t.prefetch??(a?!1:void 0),ref:n,children:e})});H.displayName="MultiZonesLink";0&&(module.exports={Link,PrefetchCrossZoneLinks,PrefetchCrossZoneLinksContext,PrefetchCrossZoneLinksProvider,useZoneForHref});
3
3
  //# sourceMappingURL=client.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/next/client/index.ts","../../src/next/client/link/multi-zones-link.tsx","../../src/next/client/prefetch/prefetch-cross-zone-links-context.tsx","../../src/next/client/prefetch/prefetch-cross-zone-links.tsx","../../src/config/client/use-client-config.ts","../../src/config/client/client-config.ts","../../src/config/client/paths.ts"],"sourcesContent":["export * from './link';\nexport * from './prefetch';\n","import type { AnchorHTMLAttributes } from 'react';\nimport { forwardRef, useContext } from 'react';\nimport NextLink, { type LinkProps as NextLinkProps } from 'next/link';\nimport { PrefetchCrossZoneLinksContext } from '../prefetch';\nimport { getApplicationNameForPath } from '../../../config/client/paths';\nimport { useClientConfig } from '../../../config/client/use-client-config';\n\ninterface BaseProps {\n children: React.ReactNode;\n href: string;\n}\nexport type LinkProps = BaseProps &\n Omit<NextLinkProps, keyof BaseProps> &\n Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseProps>;\n\nconst CURRENT_ZONE = process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION;\n\nexport function useZoneForHref(href: LinkProps['href'] | undefined): {\n zoneOfHref: string | null;\n isDifferentZone: boolean;\n isLoading: boolean;\n} {\n const { clientConfig, isLoading } = useClientConfig({\n removeFlaggedPathsFromDefault: true,\n });\n const isRelativePath =\n typeof href === 'string' && (href as string).startsWith('/');\n const zoneOfHref = isRelativePath\n ? getApplicationNameForPath(clientConfig, href as string)\n : null;\n const isDifferentZone =\n !isRelativePath || (zoneOfHref ? CURRENT_ZONE !== zoneOfHref : false);\n return { zoneOfHref, isDifferentZone, isLoading };\n}\n\n/**\n * A Link component that works with Multi-Zones set-ups and will prefetch the\n * cross zone links automatically.\n */\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ children, ...props }, ref): JSX.Element => {\n const { prefetchHref } = useContext(PrefetchCrossZoneLinksContext);\n const { zoneOfHref, isDifferentZone, isLoading } = useZoneForHref(\n props.href,\n );\n\n function onHoverPrefetch(): void {\n if (!props.href) {\n return;\n }\n prefetchHref(props.href);\n }\n\n if (isDifferentZone && zoneOfHref !== null) {\n return (\n // biome-ignore lint/a11y/useKeyWithMouseEvents: Only used for prefetching.\n // biome-ignore lint/nursery/noStaticElementInteractions: Ignored using `--suppress`\n <a\n {...props}\n data-zone={zoneOfHref}\n onMouseOver={props.prefetch !== false ? onHoverPrefetch : undefined}\n >\n {children}\n </a>\n );\n }\n\n return (\n <NextLink\n {...props}\n data-zone={!zoneOfHref ? 'null' : 'same'}\n prefetch={props.prefetch ?? (isLoading ? false : undefined)}\n ref={ref}\n >\n {children}\n </NextLink>\n );\n },\n);\nLink.displayName = 'MultiZonesLink';\n","import React, {\n createContext,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nexport interface PrefetchCrossZoneLinksContext {\n prefetchHref: (href: string) => void;\n}\n\nexport const PrefetchCrossZoneLinksContext =\n createContext<PrefetchCrossZoneLinksContext>({\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n prefetchHref: () => {},\n });\n\nexport function PrefetchCrossZoneLinksProvider({\n children,\n}: { children: React.ReactNode }): JSX.Element | null {\n const [seenHrefs, setSeenHrefs] = useState(new Set<string>());\n const [isSafariOrFirefox, setIsSafariOrFirefox] = useState(false);\n\n useEffect(() => {\n setIsSafariOrFirefox(\n typeof navigator !== 'undefined' &&\n (navigator.userAgent.includes('Firefox') ||\n (navigator.userAgent.includes('Safari') &&\n !navigator.userAgent.includes('Chrome'))),\n );\n }, []);\n\n const prefetchHref = useCallback(\n (href: string): void => {\n if (!seenHrefs.has(href)) {\n setSeenHrefs(new Set(seenHrefs).add(href));\n }\n },\n [seenHrefs],\n );\n\n const value = useMemo(() => ({ prefetchHref }), [prefetchHref]);\n\n if (!isSafariOrFirefox) {\n return <>{children}</>;\n }\n\n return (\n <PrefetchCrossZoneLinksContext.Provider value={value}>\n {children}\n {[...seenHrefs].map((href) => (\n <link as=\"fetch\" href={href} key={href} rel=\"preload\" />\n ))}\n </PrefetchCrossZoneLinksContext.Provider>\n );\n}\n","import { useEffect, useState } from 'react';\nimport Script from 'next/script';\nimport { useClientConfig } from '../../../config/client/use-client-config';\n\nconst PREFETCH_ATTR = 'data-prefetch';\nconst DATA_ATTR_SELECTORS = {\n anyZone: '[data-zone]',\n external: '[data-zone=\"null\"]',\n sameZone: '[data-zone=\"same\"]',\n prefetch: `[${PREFETCH_ATTR}]`,\n} as const;\n\nconst PREFETCH_ON_HOVER_PREDICATES = {\n and: [\n { href_matches: '/*' },\n { selector_matches: DATA_ATTR_SELECTORS.anyZone },\n { not: { selector_matches: DATA_ATTR_SELECTORS.sameZone } },\n { not: { selector_matches: DATA_ATTR_SELECTORS.external } },\n ],\n};\n\nconst PREFETCH_WHEN_VISIBLE_PREDICATES = {\n and: [\n { href_matches: '/*' },\n { selector_matches: DATA_ATTR_SELECTORS.anyZone },\n { not: { selector_matches: DATA_ATTR_SELECTORS.sameZone } },\n { not: { selector_matches: DATA_ATTR_SELECTORS.external } },\n { selector_matches: DATA_ATTR_SELECTORS.prefetch },\n ],\n};\n\nfunction checkVisibility(element: Element | null): boolean {\n if (!element) return true;\n\n if ('checkVisibility' in element) {\n return element.checkVisibility({ opacityProperty: true });\n }\n\n // hack to get around TS thinking element is never;\n const el = element as Element;\n const style = window.getComputedStyle(el);\n\n if (\n style.display === 'none' ||\n style.visibility === 'hidden' ||\n style.opacity === '0'\n ) {\n return false;\n }\n\n return checkVisibility(el.parentElement);\n}\n\nexport function PrefetchCrossZoneLinks(): JSX.Element | null {\n const { isLoading } = useClientConfig();\n const [links, setLinks] = useState<HTMLAnchorElement[]>([]);\n\n useEffect(() => {\n if (isLoading) {\n return;\n }\n\n /**\n * Intersection observer to add the data-prefetch attribute to cross-zone\n * links that have yet to be prefetched and are visible.\n */\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (\n entry.isIntersecting &&\n !entry.target.hasAttribute(PREFETCH_ATTR) &&\n // lazy perform the visibility check for nodes that are intersecting the viewport\n // and have not been prefetched.\n checkVisibility(entry.target)\n ) {\n entry.target.setAttribute(PREFETCH_ATTR, 'true');\n }\n });\n },\n {\n root: null,\n rootMargin: '0px',\n threshold: 0.1,\n },\n );\n\n links.forEach((link) => observer.observe(link));\n\n return () => {\n observer.disconnect();\n };\n }, [isLoading, links]);\n\n useEffect(() => {\n if (isLoading) {\n return;\n }\n\n /**\n * Mutation observer to notify when new nodes have entered/exited the document\n * or an href has changed.\n */\n const observer = new MutationObserver((mutations) => {\n const hasChanged = mutations.some((mutation) => {\n return (\n (mutation.type === 'childList' && mutation.addedNodes.length > 0) ||\n (mutation.type === 'attributes' && mutation.attributeName === 'href')\n );\n });\n\n if (hasChanged) {\n // Whenever there's a change, add all cross-zone links that haven't been\n // prefetched.\n setLinks(\n Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n `a${DATA_ATTR_SELECTORS.anyZone}:not(${DATA_ATTR_SELECTORS.prefetch}):not(${DATA_ATTR_SELECTORS.sameZone}):not(${DATA_ATTR_SELECTORS.external})`,\n ),\n ),\n );\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['href'],\n });\n\n return () => {\n observer.disconnect();\n };\n }, [isLoading]);\n\n // Wait till the zone-config loads to take into consideration any\n // flagged routes.\n if (isLoading) {\n return null;\n }\n\n // Prefetch links with moderate eagerness by default, immediately when marked \"data-prefetch\".\n // Prerender links with conservative eagerness by default, immediately when marked \"data-prefetch\".\n const speculationRules = {\n prefetch: [\n {\n eagerness: 'moderate',\n where: PREFETCH_ON_HOVER_PREDICATES,\n },\n {\n eagerness: 'immediate',\n where: PREFETCH_WHEN_VISIBLE_PREDICATES,\n },\n ],\n prerender: [\n {\n eagerness: 'conservative',\n where: PREFETCH_ON_HOVER_PREDICATES,\n },\n ],\n };\n\n return (\n <Script\n dangerouslySetInnerHTML={{\n __html: `${JSON.stringify(speculationRules)}`,\n }}\n id=\"prefetch-zones-links\"\n type=\"speculationrules\"\n />\n );\n}\n","'use client';\n\nimport { useState, useEffect } from 'react';\nimport type { ClientConfig, WellKnownClientData } from './types';\nimport { getClientConfigFromEnv } from './client-config';\n\nlet cachedServerClientConfigPromise: Promise<ClientConfig | null> | null = null;\n\nasync function fetchClientConfigFromServer(): Promise<ClientConfig | null> {\n try {\n const response = await fetch(\n '/.well-known/vercel/micro-frontends/client-config',\n );\n if (response.status !== 200) {\n return null;\n }\n const responseJson = (await response.json()) as WellKnownClientData;\n return responseJson.config;\n } catch (err) {\n return null;\n }\n}\n\nfunction isEqual(config1: ClientConfig, config2: ClientConfig): boolean {\n return JSON.stringify(config1) === JSON.stringify(config2);\n}\n\nfunction removeFlaggedPaths(config: ClientConfig): ClientConfig {\n for (const app of Object.values(config.applications)) {\n if (app.routing) {\n app.routing.matches = app.routing.matches.filter(\n (match) => !match.options?.flag,\n );\n }\n }\n return config;\n}\n\n/**\n * Hook to use the client micro-frontends configuration. This hook will resolve\n * dynamic paths by fetching the configuration from the server if necessary,\n * allowing the server to specify the values for dynamic paths.\n */\nexport function useClientConfig({\n removeFlaggedPathsFromDefault,\n}: {\n removeFlaggedPathsFromDefault?: boolean;\n} = {}): {\n clientConfig: ClientConfig;\n isLoading: boolean;\n} {\n const [clientConfig, setClientConfig] = useState<ClientConfig>(\n removeFlaggedPathsFromDefault\n ? removeFlaggedPaths(getClientConfigFromEnv())\n : getClientConfigFromEnv(),\n );\n const [isLoading, setIsLoading] = useState(true);\n useEffect(() => {\n if (\n process.env.NODE_ENV === 'test' &&\n process.env.MFE_FORCE_CLIENT_CONFIG_FROM_SERVER !== '1'\n ) {\n setIsLoading(false);\n return;\n }\n // Since we may remove flagged paths from the client config above, we need\n // to use the original client config to determine if the config has any\n // dynamic paths.\n const originalClientConfig = getClientConfigFromEnv();\n // As an optimization, only fetch the config from the server if the\n // micro-frontends configuration has any dynamic paths. If it doesn't,\n // then the server won't return any different values.\n const hasDynamicPaths = Object.values(\n originalClientConfig.applications,\n ).some((app) =>\n app.routing?.matches.some(\n (group) =>\n group.options?.flag || group.options?.routeToDefaultApplication,\n ),\n );\n if (!hasDynamicPaths) {\n setIsLoading(false);\n return;\n }\n if (!cachedServerClientConfigPromise) {\n cachedServerClientConfigPromise = fetchClientConfigFromServer();\n }\n void cachedServerClientConfigPromise\n .then((newConfig) => {\n if (newConfig) {\n setClientConfig((prevConfig) => {\n return isEqual(prevConfig, newConfig) ? prevConfig : newConfig;\n });\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [clientConfig.applications]);\n\n return { clientConfig, isLoading };\n}\n\nexport function resetCachedServerClientConfigPromise(): void {\n cachedServerClientConfigPromise = null;\n}\n","import type { Config } from '../schema';\nimport type { ClientConfig, WellKnownClientData } from './types';\n\n/**\n * Given a micro-frontends configuration, this returns a version that is\n * acceptable to be used client-side without leaking any information.\n */\nexport function getConfigForClient(config: Config): ClientConfig {\n return {\n applications: Object.fromEntries(\n Object.entries(config.applications).map(([name, application]) => [\n name,\n {\n default: application.default,\n routing: application.routing,\n },\n ]),\n ),\n };\n}\n\nexport function getClientConfigFromEnv(): ClientConfig {\n // This has to use the actual name rather than the constant variable in order\n // for the env var to be replaced during the build correctly.\n const clientConfigJson = process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;\n if (!clientConfigJson) {\n throw new Error(\n 'Could not find client micro-frontends config in the environment',\n );\n }\n return JSON.parse(clientConfigJson) as ClientConfig;\n}\n\nexport type { ClientConfig, WellKnownClientData };\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\nconst weakCache = new WeakMap<ClientConfig, Record<string, string>>();\n/**\n * Given a relative path, this function returns the name of the micro-frontend\n * that serves the path.\n */\nexport function getApplicationNameForPath(\n config: ClientConfig,\n path: string,\n): string {\n if (!path.startsWith('/')) {\n throw new Error(`Path must start with a /`);\n }\n const cache = weakCache.get(config) ?? {};\n if (cache[path]) {\n return cache[path];\n }\n if (!weakCache.has(config)) {\n weakCache.set(config, cache);\n }\n const pathname = new URL(path, 'https://example.com').pathname;\n\n for (const [name, application] of Object.entries(config.applications)) {\n if (application.routing) {\n for (const group of application.routing.matches) {\n for (const childPath of group.paths) {\n const regexp = pathToRegexp(childPath);\n if (regexp.test(pathname)) {\n cache[path] = name;\n return name;\n }\n }\n }\n }\n }\n const defaultApplication = Object.entries(config.applications).find(\n ([, application]) => application.default,\n );\n if (!defaultApplication) {\n throw new Error(\n 'No default application found. A default application must be configured in the micro-frontends configuration.',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,cAAWC,CAA6B,EAC3D,CAAE,WAAAP,EAAY,gBAAAQ,EAAiB,UAAAX,CAAU,EAAIH,EACjDU,EAAM,IACR,EAEA,SAASK,GAAwB,CAC1BL,EAAM,MAGXE,EAAaF,EAAM,IAAI,CACzB,CAEA,OAAII,GAAmBR,IAAe,QAIlC,OAAC,KACE,GAAGI,EACJ,YAAWJ,EACX,YAAaI,EAAM,WAAa,GAAQK,EAAkB,OAEzD,SAAAN,EACH,KAKF,OAAC,EAAAO,QAAA,CACE,GAAGN,EACJ,YAAYJ,EAAsB,OAAT,OACzB,SAAUI,EAAM,WAAaP,EAAY,GAAQ,QACjD,IAAKQ,EAEJ,SAAAF,EACH,CAEJ,CACF,EACAD,EAAK,YAAc","names":["client_exports","__export","Link","PrefetchCrossZoneLinks","PrefetchCrossZoneLinksContext","PrefetchCrossZoneLinksProvider","useZoneForHref","__toCommonJS","import_react","import_link","import_react","import_jsx_runtime","PrefetchCrossZoneLinksContext","PrefetchCrossZoneLinksProvider","children","seenHrefs","setSeenHrefs","isSafariOrFirefox","setIsSafariOrFirefox","prefetchHref","href","value","import_react","import_script","import_react","getClientConfigFromEnv","clientConfigJson","cachedServerClientConfigPromise","fetchClientConfigFromServer","response","isEqual","config1","config2","removeFlaggedPaths","config","app","match","_a","useClientConfig","removeFlaggedPathsFromDefault","clientConfig","setClientConfig","getClientConfigFromEnv","isLoading","setIsLoading","originalClientConfig","group","_b","newConfig","prevConfig","import_jsx_runtime","PREFETCH_ATTR","DATA_ATTR_SELECTORS","PREFETCH_ON_HOVER_PREDICATES","PREFETCH_WHEN_VISIBLE_PREDICATES","checkVisibility","element","el","style","PrefetchCrossZoneLinks","isLoading","useClientConfig","links","setLinks","observer","entries","entry","link","mutations","mutation","Script","import_path_to_regexp","weakCache","getApplicationNameForPath","config","path","cache","pathname","name","application","group","childPath","defaultApplication","import_jsx_runtime","CURRENT_ZONE","useZoneForHref","href","clientConfig","isLoading","useClientConfig","isRelativePath","zoneOfHref","getApplicationNameForPath","Link","children","props","ref","prefetchHref","PrefetchCrossZoneLinksContext","isDifferentZone","onHoverPrefetch","NextLink"]}
1
+ {"version":3,"sources":["../../src/next/client/index.ts","../../src/next/client/link/multi-zones-link.tsx","../../src/next/client/prefetch/prefetch-cross-zone-links-context.tsx","../../src/next/client/prefetch/prefetch-cross-zone-links.tsx","../../src/config/client/use-client-config.ts","../../src/config/client/client-config.ts","../../src/config/client/paths.ts"],"sourcesContent":["export * from './link';\nexport * from './prefetch';\n","import type { AnchorHTMLAttributes } from 'react';\nimport { forwardRef, useContext } from 'react';\nimport NextLink, { type LinkProps as NextLinkProps } from 'next/link';\nimport { PrefetchCrossZoneLinksContext } from '../prefetch';\nimport { getApplicationNameForPath } from '../../../config/client/paths';\nimport { useClientConfig } from '../../../config/client/use-client-config';\n\ninterface BaseProps {\n children: React.ReactNode;\n href: string;\n}\nexport type LinkProps = BaseProps &\n Omit<NextLinkProps, keyof BaseProps> &\n Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof BaseProps>;\n\nconst CURRENT_ZONE = process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION;\n\nexport function useZoneForHref(href: LinkProps['href'] | undefined): {\n zoneOfHref: string | null;\n isDifferentZone: boolean;\n isLoading: boolean;\n} {\n const { clientConfig, isLoading } = useClientConfig({\n removeFlaggedPathsFromDefault: true,\n });\n const isRelativePath =\n typeof href === 'string' && (href as string).startsWith('/');\n const zoneOfHref = isRelativePath\n ? getApplicationNameForPath(clientConfig, href as string)\n : null;\n const isDifferentZone =\n !isRelativePath || (zoneOfHref ? CURRENT_ZONE !== zoneOfHref : false);\n return { zoneOfHref, isDifferentZone, isLoading };\n}\n\n/**\n * A Link component that works with Multi-Zones set-ups and will prefetch the\n * cross zone links automatically.\n */\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n ({ children, ...props }, ref): JSX.Element => {\n const { prefetchHref } = useContext(PrefetchCrossZoneLinksContext);\n const { zoneOfHref, isDifferentZone, isLoading } = useZoneForHref(\n props.href,\n );\n\n function onHoverPrefetch(): void {\n if (!props.href) {\n return;\n }\n prefetchHref(props.href);\n }\n\n if (isDifferentZone && zoneOfHref !== null) {\n const { prefetch: _, ...rest } = props;\n return (\n // biome-ignore lint/a11y/useKeyWithMouseEvents: Only used for prefetching.\n // biome-ignore lint/nursery/noStaticElementInteractions: Ignored using `--suppress`\n <a\n {...rest}\n data-zone={zoneOfHref}\n onMouseOver={props.prefetch !== false ? onHoverPrefetch : undefined}\n >\n {children}\n </a>\n );\n }\n\n return (\n <NextLink\n {...props}\n data-zone={!zoneOfHref ? 'null' : 'same'}\n prefetch={props.prefetch ?? (isLoading ? false : undefined)}\n ref={ref}\n >\n {children}\n </NextLink>\n );\n },\n);\nLink.displayName = 'MultiZonesLink';\n","import React, {\n createContext,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\n\nexport interface PrefetchCrossZoneLinksContext {\n prefetchHref: (href: string) => void;\n}\n\nexport const PrefetchCrossZoneLinksContext =\n createContext<PrefetchCrossZoneLinksContext>({\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n prefetchHref: () => {},\n });\n\nexport function PrefetchCrossZoneLinksProvider({\n children,\n}: { children: React.ReactNode }): JSX.Element | null {\n const [seenHrefs, setSeenHrefs] = useState(new Set<string>());\n const [isSafariOrFirefox, setIsSafariOrFirefox] = useState(false);\n\n useEffect(() => {\n setIsSafariOrFirefox(\n typeof navigator !== 'undefined' &&\n (navigator.userAgent.includes('Firefox') ||\n (navigator.userAgent.includes('Safari') &&\n !navigator.userAgent.includes('Chrome'))),\n );\n }, []);\n\n const prefetchHref = useCallback(\n (href: string): void => {\n if (!seenHrefs.has(href)) {\n setSeenHrefs(new Set(seenHrefs).add(href));\n }\n },\n [seenHrefs],\n );\n\n const value = useMemo(() => ({ prefetchHref }), [prefetchHref]);\n\n if (!isSafariOrFirefox) {\n return <>{children}</>;\n }\n\n return (\n <PrefetchCrossZoneLinksContext.Provider value={value}>\n {children}\n {[...seenHrefs].map((href) => (\n <link as=\"fetch\" href={href} key={href} rel=\"preload\" />\n ))}\n </PrefetchCrossZoneLinksContext.Provider>\n );\n}\n","import { useEffect, useState } from 'react';\nimport Script from 'next/script';\nimport { useClientConfig } from '../../../config/client/use-client-config';\n\nconst PREFETCH_ATTR = 'data-prefetch';\nconst DATA_ATTR_SELECTORS = {\n anyZone: '[data-zone]',\n external: '[data-zone=\"null\"]',\n sameZone: '[data-zone=\"same\"]',\n prefetch: `[${PREFETCH_ATTR}]`,\n} as const;\n\nconst PREFETCH_ON_HOVER_PREDICATES = {\n and: [\n { href_matches: '/*' },\n { selector_matches: DATA_ATTR_SELECTORS.anyZone },\n { not: { selector_matches: DATA_ATTR_SELECTORS.sameZone } },\n { not: { selector_matches: DATA_ATTR_SELECTORS.external } },\n ],\n};\n\nconst PREFETCH_WHEN_VISIBLE_PREDICATES = {\n and: [\n { href_matches: '/*' },\n { selector_matches: DATA_ATTR_SELECTORS.anyZone },\n { not: { selector_matches: DATA_ATTR_SELECTORS.sameZone } },\n { not: { selector_matches: DATA_ATTR_SELECTORS.external } },\n { selector_matches: DATA_ATTR_SELECTORS.prefetch },\n ],\n};\n\nfunction checkVisibility(element: Element | null): boolean {\n if (!element) return true;\n\n if ('checkVisibility' in element) {\n return element.checkVisibility({ opacityProperty: true });\n }\n\n // hack to get around TS thinking element is never;\n const el = element as Element;\n const style = window.getComputedStyle(el);\n\n if (\n style.display === 'none' ||\n style.visibility === 'hidden' ||\n style.opacity === '0'\n ) {\n return false;\n }\n\n return checkVisibility(el.parentElement);\n}\n\nexport function PrefetchCrossZoneLinks(): JSX.Element | null {\n const { isLoading } = useClientConfig();\n const [links, setLinks] = useState<HTMLAnchorElement[]>([]);\n\n useEffect(() => {\n if (isLoading) {\n return;\n }\n\n /**\n * Intersection observer to add the data-prefetch attribute to cross-zone\n * links that have yet to be prefetched and are visible.\n */\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (\n entry.isIntersecting &&\n !entry.target.hasAttribute(PREFETCH_ATTR) &&\n // lazy perform the visibility check for nodes that are intersecting the viewport\n // and have not been prefetched.\n checkVisibility(entry.target)\n ) {\n entry.target.setAttribute(PREFETCH_ATTR, 'true');\n }\n });\n },\n {\n root: null,\n rootMargin: '0px',\n threshold: 0.1,\n },\n );\n\n links.forEach((link) => observer.observe(link));\n\n return () => {\n observer.disconnect();\n };\n }, [isLoading, links]);\n\n useEffect(() => {\n if (isLoading) {\n return;\n }\n\n /**\n * Mutation observer to notify when new nodes have entered/exited the document\n * or an href has changed.\n */\n const observer = new MutationObserver((mutations) => {\n const hasChanged = mutations.some((mutation) => {\n return (\n (mutation.type === 'childList' && mutation.addedNodes.length > 0) ||\n (mutation.type === 'attributes' && mutation.attributeName === 'href')\n );\n });\n\n if (hasChanged) {\n // Whenever there's a change, add all cross-zone links that haven't been\n // prefetched.\n setLinks(\n Array.from(\n document.querySelectorAll<HTMLAnchorElement>(\n `a${DATA_ATTR_SELECTORS.anyZone}:not(${DATA_ATTR_SELECTORS.prefetch}):not(${DATA_ATTR_SELECTORS.sameZone}):not(${DATA_ATTR_SELECTORS.external})`,\n ),\n ),\n );\n }\n });\n\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n attributeFilter: ['href'],\n });\n\n return () => {\n observer.disconnect();\n };\n }, [isLoading]);\n\n // Wait till the zone-config loads to take into consideration any\n // flagged routes.\n if (isLoading) {\n return null;\n }\n\n // Prefetch links with moderate eagerness by default, immediately when marked \"data-prefetch\".\n // Prerender links with conservative eagerness by default, immediately when marked \"data-prefetch\".\n const speculationRules = {\n prefetch: [\n {\n eagerness: 'moderate',\n where: PREFETCH_ON_HOVER_PREDICATES,\n },\n {\n eagerness: 'immediate',\n where: PREFETCH_WHEN_VISIBLE_PREDICATES,\n },\n ],\n prerender: [\n {\n eagerness: 'conservative',\n where: PREFETCH_ON_HOVER_PREDICATES,\n },\n ],\n };\n\n return (\n <Script\n dangerouslySetInnerHTML={{\n __html: `${JSON.stringify(speculationRules)}`,\n }}\n id=\"prefetch-zones-links\"\n type=\"speculationrules\"\n />\n );\n}\n","'use client';\n\nimport { useState, useEffect } from 'react';\nimport type { ClientConfig, WellKnownClientData } from './types';\nimport { getClientConfigFromEnv } from './client-config';\n\nlet cachedServerClientConfigPromise: Promise<ClientConfig | null> | null = null;\n\nasync function fetchClientConfigFromServer(): Promise<ClientConfig | null> {\n try {\n const response = await fetch(\n '/.well-known/vercel/micro-frontends/client-config',\n );\n if (response.status !== 200) {\n return null;\n }\n const responseJson = (await response.json()) as WellKnownClientData;\n return responseJson.config;\n } catch (err) {\n return null;\n }\n}\n\nfunction isEqual(config1: ClientConfig, config2: ClientConfig): boolean {\n return JSON.stringify(config1) === JSON.stringify(config2);\n}\n\nfunction removeFlaggedPaths(config: ClientConfig): ClientConfig {\n for (const app of Object.values(config.applications)) {\n if (app.routing) {\n app.routing.matches = app.routing.matches.filter(\n (match) => !match.options?.flag,\n );\n }\n }\n return config;\n}\n\n/**\n * Hook to use the client micro-frontends configuration. This hook will resolve\n * dynamic paths by fetching the configuration from the server if necessary,\n * allowing the server to specify the values for dynamic paths.\n */\nexport function useClientConfig({\n removeFlaggedPathsFromDefault,\n}: {\n removeFlaggedPathsFromDefault?: boolean;\n} = {}): {\n clientConfig: ClientConfig;\n isLoading: boolean;\n} {\n const [clientConfig, setClientConfig] = useState<ClientConfig>(\n removeFlaggedPathsFromDefault\n ? removeFlaggedPaths(getClientConfigFromEnv())\n : getClientConfigFromEnv(),\n );\n const [isLoading, setIsLoading] = useState(true);\n useEffect(() => {\n if (\n process.env.NODE_ENV === 'test' &&\n process.env.MFE_FORCE_CLIENT_CONFIG_FROM_SERVER !== '1'\n ) {\n setIsLoading(false);\n return;\n }\n // Since we may remove flagged paths from the client config above, we need\n // to use the original client config to determine if the config has any\n // dynamic paths.\n const originalClientConfig = getClientConfigFromEnv();\n // As an optimization, only fetch the config from the server if the\n // micro-frontends configuration has any dynamic paths. If it doesn't,\n // then the server won't return any different values.\n const hasDynamicPaths = Object.values(\n originalClientConfig.applications,\n ).some((app) => app.routing?.matches.some((group) => group.options?.flag));\n if (!hasDynamicPaths) {\n setIsLoading(false);\n return;\n }\n if (!cachedServerClientConfigPromise) {\n cachedServerClientConfigPromise = fetchClientConfigFromServer();\n }\n void cachedServerClientConfigPromise\n .then((newConfig) => {\n if (newConfig) {\n setClientConfig((prevConfig) => {\n return isEqual(prevConfig, newConfig) ? prevConfig : newConfig;\n });\n }\n })\n .finally(() => {\n setIsLoading(false);\n });\n }, [clientConfig.applications]);\n\n return { clientConfig, isLoading };\n}\n\nexport function resetCachedServerClientConfigPromise(): void {\n cachedServerClientConfigPromise = null;\n}\n","import type { Config } from '../schema';\nimport type { ClientConfig, WellKnownClientData } from './types';\n\n/**\n * Given a micro-frontends configuration, this returns a version that is\n * acceptable to be used client-side without leaking any information.\n */\nexport function getConfigForClient(config: Config): ClientConfig {\n return {\n applications: Object.fromEntries(\n Object.entries(config.applications).map(([name, application]) => [\n name,\n {\n default: application.default,\n routing: application.routing,\n },\n ]),\n ),\n };\n}\n\nexport function getClientConfigFromEnv(): ClientConfig {\n // This has to use the actual name rather than the constant variable in order\n // for the env var to be replaced during the build correctly.\n const clientConfigJson = process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;\n if (!clientConfigJson) {\n throw new Error(\n 'Could not find client micro-frontends config in the environment',\n );\n }\n return JSON.parse(clientConfigJson) as ClientConfig;\n}\n\nexport type { ClientConfig, WellKnownClientData };\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\nconst weakCache = new WeakMap<ClientConfig, Record<string, string>>();\n/**\n * Given a relative path, this function returns the name of the micro-frontend\n * that serves the path.\n */\nexport function getApplicationNameForPath(\n config: ClientConfig,\n path: string,\n): string {\n if (!path.startsWith('/')) {\n throw new Error(`Path must start with a /`);\n }\n const cache = weakCache.get(config) ?? {};\n if (cache[path]) {\n return cache[path];\n }\n if (!weakCache.has(config)) {\n weakCache.set(config, cache);\n }\n const pathname = new URL(path, 'https://example.com').pathname;\n\n for (const [name, application] of Object.entries(config.applications)) {\n if (application.routing) {\n for (const group of application.routing.matches) {\n for (const childPath of group.paths) {\n const regexp = pathToRegexp(childPath);\n if (regexp.test(pathname)) {\n cache[path] = name;\n return name;\n }\n }\n }\n }\n }\n const defaultApplication = Object.entries(config.applications).find(\n ([, application]) => application.default,\n );\n if (!defaultApplication) {\n throw new Error(\n 'No default application found. A default application must be configured in the micro-frontends configuration.',\n );\n }\n cache[path] = defaultApplication[0];\n return defaultApplication[0];\n}\n"],"mappings":";0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,EAAA,2BAAAC,EAAA,kCAAAC,EAAA,mCAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAP,GCCA,IAAAQ,EAAuC,iBACvCC,EAA0D,0BCF1D,IAAAC,EAMO,iBAuCIC,EAAA,6BAjCEC,KACX,iBAA6C,CAE3C,aAAc,IAAM,CAAC,CACvB,CAAC,EAEI,SAASC,EAA+B,CAC7C,SAAAC,CACF,EAAsD,CACpD,GAAM,CAACC,EAAWC,CAAY,KAAI,YAAS,IAAI,GAAa,EACtD,CAACC,EAAmBC,CAAoB,KAAI,YAAS,EAAK,KAEhE,aAAU,IAAM,CACdA,EACE,OAAO,UAAc,MAClB,UAAU,UAAU,SAAS,SAAS,GACpC,UAAU,UAAU,SAAS,QAAQ,GACpC,CAAC,UAAU,UAAU,SAAS,QAAQ,EAC9C,CACF,EAAG,CAAC,CAAC,EAEL,IAAMC,KAAe,eAClBC,GAAuB,CACjBL,EAAU,IAAIK,CAAI,GACrBJ,EAAa,IAAI,IAAID,CAAS,EAAE,IAAIK,CAAI,CAAC,CAE7C,EACA,CAACL,CAAS,CACZ,EAEMM,KAAQ,WAAQ,KAAO,CAAE,aAAAF,CAAa,GAAI,CAACA,CAAY,CAAC,EAE9D,OAAKF,KAKH,QAACL,EAA8B,SAA9B,CAAuC,MAAOS,EAC5C,UAAA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,EAAaD,EACfE,EAA0BL,EAAcD,CAAc,EACtD,KAGJ,MAAO,CAAE,WAAAK,EAAY,gBADnB,CAACD,IAAmBC,EAAaP,IAAiBO,EAAa,IAC3B,UAAAH,CAAU,CAClD,CAMO,IAAMK,KAAO,cAClB,CAAC,CAAE,SAAAC,EAAU,GAAGC,CAAM,EAAGC,IAAqB,CAC5C,GAAM,CAAE,aAAAC,CAAa,KAAI,cAAWC,CAA6B,EAC3D,CAAE,WAAAP,EAAY,gBAAAQ,EAAiB,UAAAX,CAAU,EAAIH,EACjDU,EAAM,IACR,EAEA,SAASK,GAAwB,CAC1BL,EAAM,MAGXE,EAAaF,EAAM,IAAI,CACzB,CAEA,GAAII,GAAmBR,IAAe,KAAM,CAC1C,GAAM,CAAE,SAAUU,EAAG,GAAGC,CAAK,EAAIP,EACjC,SAGE,OAAC,KACE,GAAGO,EACJ,YAAWX,EACX,YAAaI,EAAM,WAAa,GAAQK,EAAkB,OAEzD,SAAAN,EACH,EAIJ,SACE,OAAC,EAAAS,QAAA,CACE,GAAGR,EACJ,YAAYJ,EAAsB,OAAT,OACzB,SAAUI,EAAM,WAAaP,EAAY,GAAQ,QACjD,IAAKQ,EAEJ,SAAAF,EACH,CAEJ,CACF,EACAD,EAAK,YAAc","names":["client_exports","__export","Link","PrefetchCrossZoneLinks","PrefetchCrossZoneLinksContext","PrefetchCrossZoneLinksProvider","useZoneForHref","__toCommonJS","import_react","import_link","import_react","import_jsx_runtime","PrefetchCrossZoneLinksContext","PrefetchCrossZoneLinksProvider","children","seenHrefs","setSeenHrefs","isSafariOrFirefox","setIsSafariOrFirefox","prefetchHref","href","value","import_react","import_script","import_react","getClientConfigFromEnv","clientConfigJson","cachedServerClientConfigPromise","fetchClientConfigFromServer","response","isEqual","config1","config2","removeFlaggedPaths","config","app","match","_a","useClientConfig","removeFlaggedPathsFromDefault","clientConfig","setClientConfig","getClientConfigFromEnv","isLoading","setIsLoading","originalClientConfig","group","newConfig","prevConfig","import_jsx_runtime","PREFETCH_ATTR","DATA_ATTR_SELECTORS","PREFETCH_ON_HOVER_PREDICATES","PREFETCH_WHEN_VISIBLE_PREDICATES","checkVisibility","element","el","style","PrefetchCrossZoneLinks","isLoading","useClientConfig","links","setLinks","observer","entries","entry","link","mutations","mutation","Script","import_path_to_regexp","weakCache","getApplicationNameForPath","config","path","cache","pathname","name","application","group","childPath","defaultApplication","import_jsx_runtime","CURRENT_ZONE","useZoneForHref","href","clientConfig","isLoading","useClientConfig","isRelativePath","zoneOfHref","getApplicationNameForPath","Link","children","props","ref","prefetchHref","PrefetchCrossZoneLinksContext","isDifferentZone","onHoverPrefetch","_","rest","NextLink"]}
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- import{forwardRef as W,useContext as B}from"react";import V from"next/link";import{createContext as N,useCallback as O,useEffect as R,useMemo as S,useState as P}from"react";import{Fragment as A,jsx as y,jsxs as T}from"react/jsx-runtime";var m=N({prefetchHref:()=>{}});function q({children:e}){let[t,o]=P(new Set),[s,n]=P(!1);R(()=>{n(typeof navigator<"u"&&(navigator.userAgent.includes("Firefox")||navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")))},[]);let i=O(r=>{t.has(r)||o(new Set(t).add(r))},[t]),a=S(()=>({prefetchHref:i}),[i]);return s?T(m.Provider,{value:a,children:[e,[...t].map(r=>y("link",{as:"fetch",href:r,rel:"preload"},r))]}):y(A,{children:e})}import{useEffect as v,useState as D}from"react";import I from"next/script";import{useState as L,useEffect as w}from"react";function l(){let e=process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;if(!e)throw new Error("Could not find client micro-frontends config in the environment");return JSON.parse(e)}var h=null;async function F(){try{let e=await fetch("/.well-known/vercel/micro-frontends/client-config");return e.status!==200?null:(await e.json()).config}catch{return null}}function H(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Z(e){for(let t of Object.values(e.applications))t.routing&&(t.routing.matches=t.routing.matches.filter(o=>{var s;return!((s=o.options)!=null&&s.flag)}));return e}function u({removeFlaggedPathsFromDefault:e}={}){let[t,o]=L(e?Z(l()):l()),[s,n]=L(!0);return w(()=>{if(process.env.NODE_ENV==="test"&&process.env.MFE_FORCE_CLIENT_CONFIG_FROM_SERVER!=="1"){n(!1);return}let i=l();if(!Object.values(i.applications).some(r=>{var c;return(c=r.routing)==null?void 0:c.matches.some(p=>{var d,E;return((d=p.options)==null?void 0:d.flag)||((E=p.options)==null?void 0:E.routeToDefaultApplication)})})){n(!1);return}h||(h=F()),h.then(r=>{r&&o(c=>H(c,r)?c:r)}).finally(()=>{n(!1)})},[t.applications]),{clientConfig:t,isLoading:s}}import{jsx as J}from"react/jsx-runtime";var C="data-prefetch",f={anyZone:"[data-zone]",external:'[data-zone="null"]',sameZone:'[data-zone="same"]',prefetch:`[${C}]`},x={and:[{href_matches:"/*"},{selector_matches:f.anyZone},{not:{selector_matches:f.sameZone}},{not:{selector_matches:f.external}}]},M={and:[{href_matches:"/*"},{selector_matches:f.anyZone},{not:{selector_matches:f.sameZone}},{not:{selector_matches:f.external}},{selector_matches:f.prefetch}]};function _(e){if(!e)return!0;if("checkVisibility"in e)return e.checkVisibility({opacityProperty:!0});let t=e,o=window.getComputedStyle(t);return o.display==="none"||o.visibility==="hidden"||o.opacity==="0"?!1:_(t.parentElement)}function se(){let{isLoading:e}=u(),[t,o]=D([]);return v(()=>{if(e)return;let n=new IntersectionObserver(i=>{i.forEach(a=>{a.isIntersecting&&!a.target.hasAttribute(C)&&_(a.target)&&a.target.setAttribute(C,"true")})},{root:null,rootMargin:"0px",threshold:.1});return t.forEach(i=>n.observe(i)),()=>{n.disconnect()}},[e,t]),v(()=>{if(e)return;let n=new MutationObserver(i=>{i.some(r=>r.type==="childList"&&r.addedNodes.length>0||r.type==="attributes"&&r.attributeName==="href")&&o(Array.from(document.querySelectorAll(`a${f.anyZone}:not(${f.prefetch}):not(${f.sameZone}):not(${f.external})`)))});return n.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["href"]}),()=>{n.disconnect()}},[e]),e?null:J(I,{dangerouslySetInnerHTML:{__html:`${JSON.stringify({prefetch:[{eagerness:"moderate",where:x},{eagerness:"immediate",where:M}],prerender:[{eagerness:"conservative",where:x}]})}`},id:"prefetch-zones-links",type:"speculationrules"})}import{pathToRegexp as z}from"path-to-regexp";var g=new WeakMap;function b(e,t){if(!t.startsWith("/"))throw new Error("Path must start with a /");let o=g.get(e)??{};if(o[t])return o[t];g.has(e)||g.set(e,o);let s=new URL(t,"https://example.com").pathname;for(let[i,a]of Object.entries(e.applications))if(a.routing){for(let r of a.routing.matches)for(let c of r.paths)if(z(c).test(s))return o[t]=i,i}let n=Object.entries(e.applications).find(([,i])=>i.default);if(!n)throw new Error("No default application found. A default application must be configured in the micro-frontends configuration.");return o[t]=n[0],n[0]}import{jsx as k}from"react/jsx-runtime";var $=process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION;function U(e){let{clientConfig:t,isLoading:o}=u({removeFlaggedPathsFromDefault:!0}),s=typeof e=="string"&&e.startsWith("/"),n=s?b(t,e):null;return{zoneOfHref:n,isDifferentZone:!s||(n?$!==n:!1),isLoading:o}}var X=W(({children:e,...t},o)=>{let{prefetchHref:s}=B(m),{zoneOfHref:n,isDifferentZone:i,isLoading:a}=U(t.href);function r(){t.href&&s(t.href)}return i&&n!==null?k("a",{...t,"data-zone":n,onMouseOver:t.prefetch!==!1?r:void 0,children:e}):k(V,{...t,"data-zone":n?"same":"null",prefetch:t.prefetch??(a?!1:void 0),ref:o,children:e})});X.displayName="MultiZonesLink";export{X as Link,se as PrefetchCrossZoneLinks,m as PrefetchCrossZoneLinksContext,q as PrefetchCrossZoneLinksProvider,U as useZoneForHref};
2
+ import{forwardRef as z,useContext as W}from"react";import B from"next/link";import{createContext as k,useCallback as N,useEffect as O,useMemo as R,useState as E}from"react";import{Fragment as S,jsx as P,jsxs as A}from"react/jsx-runtime";var m=k({prefetchHref:()=>{}});function K({children:e}){let[t,o]=E(new Set),[s,n]=E(!1);O(()=>{n(typeof navigator<"u"&&(navigator.userAgent.includes("Firefox")||navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")))},[]);let i=N(r=>{t.has(r)||o(new Set(t).add(r))},[t]),a=R(()=>({prefetchHref:i}),[i]);return s?A(m.Provider,{value:a,children:[e,[...t].map(r=>P("link",{as:"fetch",href:r,rel:"preload"},r))]}):P(S,{children:e})}import{useEffect as L,useState as Z}from"react";import I from"next/script";import{useState as y,useEffect as w}from"react";function u(){let e=process.env.NEXT_PUBLIC_MFE_CLIENT_CONFIG;if(!e)throw new Error("Could not find client micro-frontends config in the environment");return JSON.parse(e)}var h=null;async function F(){try{let e=await fetch("/.well-known/vercel/micro-frontends/client-config");return e.status!==200?null:(await e.json()).config}catch{return null}}function T(e,t){return JSON.stringify(e)===JSON.stringify(t)}function H(e){for(let t of Object.values(e.applications))t.routing&&(t.routing.matches=t.routing.matches.filter(o=>{var s;return!((s=o.options)!=null&&s.flag)}));return e}function p({removeFlaggedPathsFromDefault:e}={}){let[t,o]=y(e?H(u()):u()),[s,n]=y(!0);return w(()=>{if(process.env.NODE_ENV==="test"&&process.env.MFE_FORCE_CLIENT_CONFIG_FROM_SERVER!=="1"){n(!1);return}let i=u();if(!Object.values(i.applications).some(r=>{var c;return(c=r.routing)==null?void 0:c.matches.some(l=>{var d;return(d=l.options)==null?void 0:d.flag})})){n(!1);return}h||(h=F()),h.then(r=>{r&&o(c=>T(c,r)?c:r)}).finally(()=>{n(!1)})},[t.applications]),{clientConfig:t,isLoading:s}}import{jsx as D}from"react/jsx-runtime";var C="data-prefetch",f={anyZone:"[data-zone]",external:'[data-zone="null"]',sameZone:'[data-zone="same"]',prefetch:`[${C}]`},v={and:[{href_matches:"/*"},{selector_matches:f.anyZone},{not:{selector_matches:f.sameZone}},{not:{selector_matches:f.external}}]},M={and:[{href_matches:"/*"},{selector_matches:f.anyZone},{not:{selector_matches:f.sameZone}},{not:{selector_matches:f.external}},{selector_matches:f.prefetch}]};function _(e){if(!e)return!0;if("checkVisibility"in e)return e.checkVisibility({opacityProperty:!0});let t=e,o=window.getComputedStyle(t);return o.display==="none"||o.visibility==="hidden"||o.opacity==="0"?!1:_(t.parentElement)}function ie(){let{isLoading:e}=p(),[t,o]=Z([]);return L(()=>{if(e)return;let n=new IntersectionObserver(i=>{i.forEach(a=>{a.isIntersecting&&!a.target.hasAttribute(C)&&_(a.target)&&a.target.setAttribute(C,"true")})},{root:null,rootMargin:"0px",threshold:.1});return t.forEach(i=>n.observe(i)),()=>{n.disconnect()}},[e,t]),L(()=>{if(e)return;let n=new MutationObserver(i=>{i.some(r=>r.type==="childList"&&r.addedNodes.length>0||r.type==="attributes"&&r.attributeName==="href")&&o(Array.from(document.querySelectorAll(`a${f.anyZone}:not(${f.prefetch}):not(${f.sameZone}):not(${f.external})`)))});return n.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["href"]}),()=>{n.disconnect()}},[e]),e?null:D(I,{dangerouslySetInnerHTML:{__html:`${JSON.stringify({prefetch:[{eagerness:"moderate",where:v},{eagerness:"immediate",where:M}],prerender:[{eagerness:"conservative",where:v}]})}`},id:"prefetch-zones-links",type:"speculationrules"})}import{pathToRegexp as J}from"path-to-regexp";var g=new WeakMap;function x(e,t){if(!t.startsWith("/"))throw new Error("Path must start with a /");let o=g.get(e)??{};if(o[t])return o[t];g.has(e)||g.set(e,o);let s=new URL(t,"https://example.com").pathname;for(let[i,a]of Object.entries(e.applications))if(a.routing){for(let r of a.routing.matches)for(let c of r.paths)if(J(c).test(s))return o[t]=i,i}let n=Object.entries(e.applications).find(([,i])=>i.default);if(!n)throw new Error("No default application found. A default application must be configured in the micro-frontends configuration.");return o[t]=n[0],n[0]}import{jsx as b}from"react/jsx-runtime";var V=process.env.NEXT_PUBLIC_MFE_CURRENT_APPLICATION;function $(e){let{clientConfig:t,isLoading:o}=p({removeFlaggedPathsFromDefault:!0}),s=typeof e=="string"&&e.startsWith("/"),n=s?x(t,e):null;return{zoneOfHref:n,isDifferentZone:!s||(n?V!==n:!1),isLoading:o}}var U=z(({children:e,...t},o)=>{let{prefetchHref:s}=W(m),{zoneOfHref:n,isDifferentZone:i,isLoading:a}=$(t.href);function r(){t.href&&s(t.href)}if(i&&n!==null){let{prefetch:c,...l}=t;return b("a",{...l,"data-zone":n,onMouseOver:t.prefetch!==!1?r:void 0,children:e})}return b(B,{...t,"data-zone":n?"same":"null",prefetch:t.prefetch??(a?!1:void 0),ref:o,children:e})});U.displayName="MultiZonesLink";export{U as Link,ie as PrefetchCrossZoneLinks,m as PrefetchCrossZoneLinksContext,K as PrefetchCrossZoneLinksProvider,$ as useZoneForHref};
3
3
  //# sourceMappingURL=client.js.map