@vercel/microfrontends 0.18.0 → 0.19.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 (47) hide show
  1. package/dist/bin/cli.cjs +151 -71
  2. package/dist/config.cjs +102 -56
  3. package/dist/config.cjs.map +1 -1
  4. package/dist/config.d.ts +4 -4
  5. package/dist/config.js +102 -56
  6. package/dist/config.js.map +1 -1
  7. package/dist/{index-24024799.d.ts → index-09b1ddf9.d.ts} +16 -19
  8. package/dist/{index-ef8657e6.d.ts → index-2f78c0ca.d.ts} +44 -7
  9. package/dist/microfrontends/server.cjs +147 -67
  10. package/dist/microfrontends/server.cjs.map +1 -1
  11. package/dist/microfrontends/server.d.ts +4 -4
  12. package/dist/microfrontends/server.js +147 -67
  13. package/dist/microfrontends/server.js.map +1 -1
  14. package/dist/microfrontends.cjs +103 -57
  15. package/dist/microfrontends.cjs.map +1 -1
  16. package/dist/microfrontends.d.ts +4 -4
  17. package/dist/microfrontends.js +103 -57
  18. package/dist/microfrontends.js.map +1 -1
  19. package/dist/next/config.cjs +164 -79
  20. package/dist/next/config.cjs.map +1 -1
  21. package/dist/next/config.js +164 -79
  22. package/dist/next/config.js.map +1 -1
  23. package/dist/next/endpoints.d.ts +2 -2
  24. package/dist/next/middleware.cjs +120 -75
  25. package/dist/next/middleware.cjs.map +1 -1
  26. package/dist/next/middleware.js +120 -75
  27. package/dist/next/middleware.js.map +1 -1
  28. package/dist/next/testing.cjs +109 -62
  29. package/dist/next/testing.cjs.map +1 -1
  30. package/dist/next/testing.d.ts +4 -4
  31. package/dist/next/testing.js +109 -62
  32. package/dist/next/testing.js.map +1 -1
  33. package/dist/overrides.d.ts +3 -3
  34. package/dist/schema.d.ts +1 -1
  35. package/dist/{types-089498fd.d.ts → types-4ef2bddb.d.ts} +1 -1
  36. package/dist/{types-9f161cec.d.ts → types-b6d38aea.d.ts} +1 -1
  37. package/dist/utils/mfe-port.cjs +148 -68
  38. package/dist/utils/mfe-port.cjs.map +1 -1
  39. package/dist/utils/mfe-port.js +148 -68
  40. package/dist/utils/mfe-port.js.map +1 -1
  41. package/dist/validation.cjs +43 -9
  42. package/dist/validation.cjs.map +1 -1
  43. package/dist/validation.d.ts +1 -1
  44. package/dist/validation.js +43 -9
  45. package/dist/validation.js.map +1 -1
  46. package/package.json +1 -1
  47. package/schema/schema.json +71 -40
@@ -267,7 +267,8 @@ var validateConfigPaths = (applicationConfigsById) => {
267
267
  if (isDefaultApp(app)) {
268
268
  continue;
269
269
  }
270
- for (const pathMatch of app.routing) {
270
+ const childApp = app;
271
+ for (const pathMatch of childApp.routing) {
271
272
  for (const path of pathMatch.paths) {
272
273
  const maybeError = validatePathExpression(path);
273
274
  if (maybeError) {
@@ -287,33 +288,31 @@ var validateConfigPaths = (applicationConfigsById) => {
287
288
  }
288
289
  }
289
290
  const entries = Array.from(pathsByApplicationId.entries());
290
- entries.forEach(([path, { applications: ids, matcher, applicationId }]) => {
291
+ for (const [path, { applications: ids, matcher, applicationId }] of entries) {
291
292
  if (ids.length > 1) {
292
293
  errors.push(
293
294
  `Duplicate path "${path}" for applications "${ids.join(", ")}"`
294
295
  );
295
296
  }
296
- entries.forEach(
297
- ([
298
- matchPath,
299
- { applications: matchIds, applicationId: matchApplicationId }
300
- ]) => {
301
- if (path === matchPath) {
302
- return;
303
- }
304
- if (applicationId === matchApplicationId) {
305
- return;
306
- }
307
- if (matcher.test(matchPath)) {
308
- const source = `"${path}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
309
- const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
310
- errors.push(
311
- `Overlapping path detected between ${source} and ${destination}`
312
- );
313
- }
297
+ for (const [
298
+ matchPath,
299
+ { applications: matchIds, applicationId: matchApplicationId }
300
+ ] of entries) {
301
+ if (path === matchPath) {
302
+ continue;
314
303
  }
315
- );
316
- });
304
+ if (applicationId === matchApplicationId) {
305
+ continue;
306
+ }
307
+ if (matcher.test(matchPath)) {
308
+ const source = `"${path}" of application${ids.length > 0 ? "s" : ""} ${ids.join(", ")}`;
309
+ const destination = `"${matchPath}" of application${matchIds.length > 0 ? "s" : ""} ${matchIds.join(", ")}`;
310
+ errors.push(
311
+ `Overlapping path detected between ${source} and ${destination}`
312
+ );
313
+ }
314
+ }
315
+ }
317
316
  if (errors.length) {
318
317
  throw new MicrofrontendError(`Invalid paths: ${errors.join(", ")}`, {
319
318
  type: "config",
@@ -382,7 +381,7 @@ var validateConfigDefaultApplication = (applicationConfigsById) => {
382
381
  const numApplicationsWithoutRouting = numApplications - numApplicationsWithRouting;
383
382
  if (numApplicationsWithoutRouting === 0) {
384
383
  throw new MicrofrontendError(
385
- `No default application found. At least one application needs to be the default by omitting routing.`,
384
+ "No default application found. At least one application needs to be the default by omitting routing.",
386
385
  { type: "config", subtype: "no_default_application" }
387
386
  );
388
387
  }
@@ -428,47 +427,80 @@ function generatePortFromName({
428
427
  // src/config/microfrontends-config/isomorphic/host.ts
429
428
  var Host = class {
430
429
  constructor(hostConfig, options) {
431
- const { protocol = "https", host, port } = hostConfig;
432
- this.protocol = protocol;
433
- this.host = host;
434
- this.port = Host.getPort({ port, protocol: this.protocol });
430
+ if (typeof hostConfig === "string") {
431
+ ({
432
+ protocol: this.protocol,
433
+ host: this.host,
434
+ port: this.port
435
+ } = Host.parseUrl(hostConfig));
436
+ } else {
437
+ const { protocol = "https", host, port } = hostConfig;
438
+ this.protocol = protocol;
439
+ this.host = host;
440
+ this.port = port;
441
+ }
435
442
  this.local = options?.isLocal;
436
443
  }
437
- isLocal() {
438
- return this.local || this.host === "localhost" || this.host === "127.0.0.1";
439
- }
440
- static getPort({
441
- protocol,
442
- port
443
- }) {
444
- if (!port) {
445
- if (protocol === "http") {
446
- return 80;
447
- }
448
- return 443;
444
+ static parseUrl(url) {
445
+ let hostToParse = url;
446
+ if (!/^https?:\/\//.exec(hostToParse)) {
447
+ hostToParse = `https://${hostToParse}`;
449
448
  }
450
- return port;
449
+ const parsed = new URL(hostToParse);
450
+ if (!parsed.hostname) {
451
+ throw new Error(Host.getMicrofrontendsError(url, "requires a host"));
452
+ }
453
+ if (parsed.hash) {
454
+ throw new Error(
455
+ Host.getMicrofrontendsError(url, "cannot have a fragment")
456
+ );
457
+ }
458
+ if (parsed.username || parsed.password) {
459
+ throw new Error(
460
+ Host.getMicrofrontendsError(
461
+ url,
462
+ "cannot have authentication credentials (username and/or password)"
463
+ )
464
+ );
465
+ }
466
+ if (parsed.pathname !== "/") {
467
+ throw new Error(Host.getMicrofrontendsError(url, "cannot have a path"));
468
+ }
469
+ if (parsed.search) {
470
+ throw new Error(
471
+ Host.getMicrofrontendsError(url, "cannot have query parameters")
472
+ );
473
+ }
474
+ const protocol = parsed.protocol.slice(0, -1);
475
+ return {
476
+ protocol,
477
+ host: parsed.hostname,
478
+ port: parsed.port ? Number.parseInt(parsed.port) : void 0
479
+ };
451
480
  }
452
- isDefaultPort() {
453
- return this.port === Host.getPort({ protocol: this.protocol });
481
+ static getMicrofrontendsError(url, message) {
482
+ return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;
454
483
  }
455
- toString(opts = {}) {
456
- const url = this.toUrl(opts);
484
+ isLocal() {
485
+ return this.local || this.host === "localhost" || this.host === "127.0.0.1";
486
+ }
487
+ toString() {
488
+ const url = this.toUrl();
457
489
  return url.toString().replace(/\/$/, "");
458
490
  }
459
- toUrl(opts = {}) {
460
- const { includeDefaultPort } = opts;
461
- const url = `${this.protocol}://${this.host}${this.isDefaultPort() && !includeDefaultPort ? "" : `:${this.port}`}`;
491
+ toUrl() {
492
+ const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ""}`;
462
493
  return new URL(url);
463
494
  }
464
495
  };
465
496
  var LocalHost = class extends Host {
466
497
  constructor({
467
498
  appName,
499
+ localPort,
468
500
  ...hostConfig
469
501
  }) {
470
502
  const host = hostConfig.host ?? "localhost";
471
- const port = hostConfig.port ?? generatePortFromName({ name: appName });
503
+ const port = localPort ?? hostConfig.port ?? generatePortFromName({ name: appName });
472
504
  const protocol = hostConfig.protocol ?? "http";
473
505
  super({ protocol, host, port });
474
506
  }
@@ -485,12 +517,17 @@ var Application = class {
485
517
  this.development = {
486
518
  local: new LocalHost({
487
519
  appName: name,
520
+ localPort: app.development?.localPort,
488
521
  ...app.development?.local
489
522
  }),
490
523
  fallback: app.development?.fallback ? new Host(app.development.fallback) : void 0
491
524
  };
492
- this.production = app.production ? new Host(app.production) : void 0;
493
- this.vercel = app.vercel;
525
+ if (app.development?.fallback) {
526
+ this.fallback = new Host(app.development.fallback);
527
+ } else if (app.production) {
528
+ this.fallback = new Host(app.production);
529
+ }
530
+ this.projectId = app.projectId ?? app.vercel?.projectId;
494
531
  this.overrides = overrides?.environment ? {
495
532
  environment: new Host(overrides.environment)
496
533
  } : void 0;
@@ -518,7 +555,16 @@ var DefaultApplication = class extends Application {
518
555
  isDefault: true
519
556
  });
520
557
  this.default = true;
521
- this.production = new Host(app.production);
558
+ const fallbackHost = app.development?.fallback ?? app.production;
559
+ if (fallbackHost === void 0) {
560
+ throw new Error(
561
+ "`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json."
562
+ );
563
+ }
564
+ this.fallback = new Host(fallbackHost);
565
+ if (app.production) {
566
+ this.production = new Host(app.production);
567
+ }
522
568
  }
523
569
  getAssetPrefix() {
524
570
  return "";
@@ -588,7 +634,7 @@ var MicrofrontendConfigIsomorphic = class {
588
634
  }
589
635
  if (isMainConfig(config) && !this.defaultApplication) {
590
636
  throw new MicrofrontendError(
591
- `Could not find default application in microfrontends configuration`,
637
+ "Could not find default application in microfrontends configuration",
592
638
  {
593
639
  type: "application",
594
640
  subtype: "not_found"
@@ -664,11 +710,11 @@ var MicrofrontendConfigIsomorphic = class {
664
710
  return app;
665
711
  }
666
712
  getApplicationByProjectId(projectId) {
667
- if (this.defaultApplication?.vercel?.projectId === projectId) {
713
+ if (this.defaultApplication?.projectId === projectId) {
668
714
  return this.defaultApplication;
669
715
  }
670
716
  return Object.values(this.childApplications).find(
671
- (app) => app.vercel?.projectId === projectId
717
+ (app) => app.projectId === projectId
672
718
  );
673
719
  }
674
720
  /**
@@ -678,7 +724,7 @@ var MicrofrontendConfigIsomorphic = class {
678
724
  getDefaultApplication() {
679
725
  if (!this.defaultApplication) {
680
726
  throw new MicrofrontendError(
681
- `Could not find default application in microfrontends configuration`,
727
+ "Could not find default application in microfrontends configuration",
682
728
  {
683
729
  type: "application",
684
730
  subtype: "not_found"
@@ -691,7 +737,7 @@ var MicrofrontendConfigIsomorphic = class {
691
737
  * Returns the configured port for the local proxy
692
738
  */
693
739
  getLocalProxyPort() {
694
- return this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
740
+ return this.config.options?.localProxyPort ?? this.config.options?.localProxy?.port ?? DEFAULT_LOCAL_PROXY_PORT;
695
741
  }
696
742
  /**
697
743
  * Serializes the class back to the Schema type.
@@ -736,12 +782,10 @@ function getDomainFromEnvironment({
736
782
  if (mfeProjects.length === 0) {
737
783
  throw new Error("Missing related microfrontends project information");
738
784
  }
739
- if (!app.vercel?.projectId) {
785
+ if (!app.projectId) {
740
786
  throw new Error(`Missing applications[${app.name}].vercel.projectId`);
741
787
  }
742
- const vercelProject = mfeProjects.find(
743
- (p) => p.project.id === app.vercel?.projectId
744
- );
788
+ const vercelProject = mfeProjects.find((p) => p.project.id === app.projectId);
745
789
  if (!vercelProject) {
746
790
  throw new Error(
747
791
  `Missing related microfrontends project information for application "${app.name}"`
@@ -813,7 +857,7 @@ function getExpectedDomainForApp(mfConfig, appName, env) {
813
857
  const target = env;
814
858
  return getDomainFromEnvironment({ app, target });
815
859
  }
816
- return defaultApp.production.toString();
860
+ return defaultApp.fallback.toString();
817
861
  }
818
862
  function getAllMultiZonesPaths(mfConfig) {
819
863
  return mfConfig.getChildApplications().flatMap((app) => {
@@ -860,8 +904,11 @@ function validateMiddlewareConfig(middlewareConfig, microfrontendConfigOrPath, e
860
904
  for (const path of aMatch.paths) {
861
905
  const pathsToTest = expandWildcards(path);
862
906
  for (const testPath of pathsToTest) {
863
- const productionHost = microfrontendConfig.getDefaultApplication().production.host;
907
+ const productionHost = microfrontendConfig.getDefaultApplication().production?.host;
864
908
  const pathForDisplay = `${testPath}${path === testPath ? "" : ` (synthesized from ${path})`}`;
909
+ if (!productionHost) {
910
+ continue;
911
+ }
865
912
  if (!urlMatches(middlewareConfig, testPath, "test.nonproduction.host")) {
866
913
  errors.push(
867
914
  `Matcher misconfigured for ${pathForDisplay}. This path should have matched the middleware config on a non-production host, but did not. Microfrontends require a middleware config matcher that matches on this host everywhere but in production. That can be configured with a configuration like this:
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/next/testing/index.ts","../../src/config/microfrontends-config/isomorphic/index.ts","../../src/config/errors.ts","../../src/config/microfrontends-config/utils/get-config-from-env.ts","../../src/config/schema/utils/is-main-config.ts","../../src/config/schema/utils/is-default-app.ts","../../src/config/microfrontends-config/client/index.ts","../../src/config/overrides/constants.ts","../../src/config/overrides/is-override-cookie.ts","../../src/config/overrides/get-override-from-cookie.ts","../../src/config/overrides/parse-overrides.ts","../../src/config/microfrontends-config/isomorphic/validation.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-port.ts","../../src/config/microfrontends-config/isomorphic/host.ts","../../src/config/microfrontends-config/isomorphic/application.ts","../../src/config/microfrontends-config/isomorphic/constants.ts","../../src/routing/get-domain-from-environment.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport {\n type NextFetchEvent,\n NextRequest,\n type MiddlewareConfig,\n} from 'next/server';\nimport { match } from 'path-to-regexp';\nimport { parse } from 'jsonc-parser';\nimport { matchHas } from 'next/dist/shared/lib/router/utils/prepare-destination';\nimport { NextRequestHint } from 'next/dist/server/web/adapter';\nimport { WebNextRequest } from 'next/dist/server/base-http/web';\nimport { MicrofrontendConfigIsomorphic } from '../../config/microfrontends-config/isomorphic';\nimport { DefaultApplication } from '../../config/microfrontends-config/isomorphic/application';\nimport { getDomainFromEnvironment } from '../../routing/get-domain-from-environment';\nimport type { Config } from '../../config/schema/types';\n\n/** Replaces path wildcards (if they exist) with synthesized paths. */\nexport function expandWildcards(path: string): string[] {\n if (path.includes('/:path*') || path.includes('/:slug*')) {\n return [\n path === '/:path*' || path === '/:slug*'\n ? '/'\n : path.replace('/:path*', '').replace('/:slug*', ''),\n path.replace('/:path*', '/foo').replace('/:slug*', '/foo'),\n path.replace('/:path*', '/foo/bar').replace('/:slug*', '/foo/bar'),\n ];\n }\n if (path.includes('/:path+') || path.includes('/:slug+')) {\n return [\n path.replace('/:path+', '/foo').replace('/:slug+', '/foo'),\n path.replace('/:path+', '/foo/bar').replace('/:slug+', '/foo/bar'),\n ];\n }\n if (path.includes('/:path') || path.includes('/:slug')) {\n return [path.replace('/:path', '/foo').replace('/:slug', '/foo')];\n }\n return [path];\n}\n\nexport function loadMicrofrontendConfigForEdge(\n path: string,\n): MicrofrontendConfigIsomorphic {\n // NOTE: It's necessary to read and parse this file manually because tests that\n // run in `@edge-runtime/jest-environment` will fail since the AJV validation\n // from the @vercel/microfrontends package violates the rules by\n // using eval.\n const rawMfConfig = parse(readFileSync(path, 'utf-8')) as Config;\n return new MicrofrontendConfigIsomorphic({\n config: rawMfConfig,\n meta: { fromApp: 'test' },\n });\n}\n\nexport function getAllChildApplicationNames(\n mfConfig: MicrofrontendConfigIsomorphic,\n): string[] {\n return mfConfig.getChildApplications().map((app) => app.name);\n}\n\nexport function getLaunchedPathsForApp(\n mfConfig: MicrofrontendConfigIsomorphic,\n appName: string,\n): string[] {\n const app = mfConfig.getApplication(appName);\n if (app instanceof DefaultApplication) {\n return [];\n }\n\n return [\n `/${app.getAssetPrefix()}/_next/static`,\n ...app.routing\n .filter((group) => !group.flag)\n .flatMap((group) => group.paths.flatMap(expandWildcards)),\n ];\n}\n\nexport function getFlaggedPathsForApp(\n mfConfig: MicrofrontendConfigIsomorphic,\n appName: string,\n): string[] {\n const app = mfConfig.getApplication(appName);\n if (app instanceof DefaultApplication) {\n return [];\n }\n\n return app.routing\n .filter((group) => Boolean(group.flag))\n .flatMap((group) => group.paths.flatMap(expandWildcards));\n}\n\nexport function getExpectedDomainForApp(\n mfConfig: MicrofrontendConfigIsomorphic,\n appName: string,\n env: string,\n): string {\n const app = mfConfig.getApplication(appName);\n const defaultApp = mfConfig.getDefaultApplication();\n if (env === 'development') {\n return app.development.local.toString();\n }\n\n if (['preview', 'production'].includes(env)) {\n const target = env as 'preview' | 'production';\n return getDomainFromEnvironment({ app, target });\n }\n\n return defaultApp.production.toString();\n}\n\n/**\n * Returns a list of examples for all paths in microfrontends.json.\n */\nexport function getAllMultiZonesPaths(\n mfConfig: MicrofrontendConfigIsomorphic,\n): string[] {\n return mfConfig.getChildApplications().flatMap((app) => {\n return app.routing.flatMap((group) => group.paths.flatMap(expandWildcards));\n });\n}\n\nfunction urlMatches(\n middlewareConfig: MiddlewareConfig,\n path: string,\n host: string,\n): boolean {\n if (!middlewareConfig.matcher) {\n return false;\n }\n // This is based off\n // https://github.com/vercel/next.js/blob/4835be182b88f67f282c30db4278c30fe9e5b483/packages/next/src/build/analysis/get-page-static-info.ts#L324\n const matchers = Array.isArray(middlewareConfig.matcher)\n ? middlewareConfig.matcher\n : [middlewareConfig.matcher];\n for (let matcher of matchers) {\n matcher = typeof matcher === 'string' ? { source: matcher } : matcher;\n if (match(matcher.source)(path)) {\n if (\n matchHas(\n new WebNextRequest(\n new NextRequestHint({\n init: { headers: { host } },\n input: `https://${host}${path}`,\n page: 'unused_placeholder',\n }),\n ),\n {},\n matcher.has,\n matcher.missing,\n )\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * A test to ensure that middleware is configured to work correctly with\n * microfrontends. Passing this test does NOT guarentee middleware is set up\n * correctly, but this should find many common problems. This should only be run\n * on the application marked as \"default\" in the microfrontend config. If a\n * configuration issue is found, this will throw an exception (this ensures it\n * works with any test framework).\n *\n * For example, if a microfrontend is configured to serve \"/my/path\" then the\n * default application should have an entry like this in its middleware config:\n *\n * export const config = `{`\n * matcher: [\n * `{`\n * source: '/my/path', // Or a regular expression that matches /my/path\n * missing: [\n * `{`\n * type: 'header',\n * key: 'host',\n * value: 'your.production.host.from.the.default.application.com',\n * `}`,\n * ],\n * `}`,\n * ...\n * ],\n * `}`\n *\n * If a path should match middleware in production for non-microfrontend\n * reasons, you can pass that path in the extraProductionMatches parameter.\n */\nexport function validateMiddlewareConfig(\n middlewareConfig: MiddlewareConfig,\n microfrontendConfigOrPath: string | MicrofrontendConfigIsomorphic,\n extraProductionMatches?: string[],\n): void {\n const microfrontendConfig =\n typeof microfrontendConfigOrPath === 'string'\n ? loadMicrofrontendConfigForEdge(microfrontendConfigOrPath)\n : microfrontendConfigOrPath;\n\n const errors: string[] = [];\n const usedExtraProductionMatches = new Set<string>();\n for (const application of microfrontendConfig.getChildApplications()) {\n const matches = [...application.routing];\n matches.push({\n paths: [`/${application.getAssetPrefix()}/_next/:path+`],\n });\n\n for (const aMatch of matches) {\n const isFlagged = Boolean(aMatch.flag);\n\n for (const path of aMatch.paths) {\n const pathsToTest = expandWildcards(path);\n for (const testPath of pathsToTest) {\n const productionHost =\n microfrontendConfig.getDefaultApplication().production.host;\n const pathForDisplay = `${testPath}${path === testPath ? '' : ` (synthesized from ${path})`}`;\n if (\n !urlMatches(middlewareConfig, testPath, 'test.nonproduction.host')\n ) {\n errors.push(\n `Matcher misconfigured for ${pathForDisplay}. This path should have matched the middleware config on a non-production host, but did not. Microfrontends require a middleware config matcher that matches on this host everywhere but in production. That can be configured with a configuration like this:\\n${getSampleMatcher(path, productionHost)}`,\n );\n // Skip the remaining expanded wildcard paths (if there are any)\n // to only report a single error per wildcard.\n break;\n }\n\n const productionUrlMatches = urlMatches(\n middlewareConfig,\n testPath,\n productionHost,\n );\n if (isFlagged) {\n if (!productionUrlMatches) {\n errors.push(\n `Matcher misconfigured for ${pathForDisplay}. Middleware config matchers for flagged paths should ALWAYS match.`,\n );\n // Skip the remaining expanded wildcard paths (if there are any)\n // to only report a single error per wildcard.\n break;\n }\n } else if (productionUrlMatches) {\n if (extraProductionMatches?.includes(path)) {\n usedExtraProductionMatches.add(path);\n } else {\n errors.push(\n `Matcher misconfigured for ${pathForDisplay}. This path matched the middleware config on a production host, but should not have. Microfrontends require a middleware config matcher that matches on this host everywhere but in production. If this is desired, you can add the path the to extraProductionMatches parameter. Otherwise, you can set up a configuration like this:\\n${getSampleMatcher(path, productionHost)}`,\n );\n }\n // Skip the remaining expanded wildcard paths (if there are any)\n // to only report a single error per wildcard.\n break;\n }\n }\n }\n }\n }\n\n const unusedExtraProductionMatches = extraProductionMatches?.filter(\n (x) => !usedExtraProductionMatches.has(x),\n );\n if (unusedExtraProductionMatches?.length) {\n errors.push(\n `The following paths were passed to the extraProductionMatches parameter but were unused. You probably want to remove them from the extraProductionMatches parameter: ${unusedExtraProductionMatches.join(', ')}`,\n );\n }\n\n if (errors.length > 0) {\n const message = `Found the following inconsistencies between your microfrontend config ${\n typeof microfrontendConfigOrPath === 'string'\n ? `(at ${microfrontendConfigOrPath}) `\n : ''\n }and middleware config:\\n\\n- `;\n throw new Error(message + errors.join('\\n\\n- '));\n }\n}\n\nfunction getSampleMatcher(path: string, host: string): string {\n return ` {\n source: '${path}', // This can also be a broader regular expression.\n missing: [\n type: 'header',\n key: 'host',\n value '${host}',\n ],\n }`;\n}\n\n/**\n * Ensures that middleware rewrites to the correct path for flagged paths.\n * IMPORTANT: you must enable the necessary flags before calling this function.\n */\nexport async function validateMiddlewareOnFlaggedPaths(\n microfrontendConfigOrPath: string | MicrofrontendConfigIsomorphic,\n middleware: (\n request: NextRequest,\n event: NextFetchEvent,\n ) => Promise<Response | undefined>,\n): Promise<void> {\n const initialEnv = process.env.VERCEL_ENV;\n const initialMfePreviewDomains = process.env.MFE_PREVIEW_DOMAINS;\n try {\n const microfrontendConfig =\n typeof microfrontendConfigOrPath === 'string'\n ? loadMicrofrontendConfigForEdge(microfrontendConfigOrPath)\n : microfrontendConfigOrPath;\n const allAppNames = getAllChildApplicationNames(microfrontendConfig);\n\n const errors: string[] = [];\n for (const appName of allAppNames) {\n const flaggedPaths = getFlaggedPathsForApp(microfrontendConfig, appName);\n if (flaggedPaths.length) {\n for (const env of ['preview', 'production']) {\n process.env.VERCEL_ENV = env;\n for (const path of flaggedPaths) {\n const expectedHost = getExpectedDomainForApp(\n microfrontendConfig,\n appName,\n env,\n );\n const expectedDefaultHost = getExpectedDomainForApp(\n microfrontendConfig,\n microfrontendConfig.getDefaultApplication().name,\n env,\n );\n const requestPath = `${expectedDefaultHost}${path}`;\n const request = new NextRequest(requestPath, {\n headers: { 'x-vercel-skip-deployment-existence-check': '1' },\n });\n\n // eslint-disable-next-line no-await-in-loop\n const response = await middleware(\n request,\n {} as unknown as NextFetchEvent,\n );\n const expectedUrl = `${expectedHost}${path}`;\n if (!response) {\n errors.push(\n `middleware did not action for ${requestPath} in ${env}. Expected a rewrite to ${expectedUrl}`,\n );\n } else if (response.status !== 200) {\n errors.push(\n `expected 200 status for ${requestPath} in ${env} but got ${response.status}`,\n );\n } else if (\n response.headers.get('x-middleware-rewrite') !== expectedUrl\n ) {\n errors.push(\n `expected rewrite from ${requestPath} to ${expectedUrl} in ${env}, but got ${response.headers.get('x-middleware-rewrite')}`,\n );\n }\n }\n }\n }\n }\n if (errors.length) {\n throw new Error(errors.join('\\n'));\n }\n } finally {\n process.env.VERCEL_ENV = initialEnv;\n process.env.MFE_PREVIEW_DOMAINS = initialMfePreviewDomains;\n }\n}\n","import { parse } from 'jsonc-parser';\nimport { getConfigStringFromEnv } from '../utils/get-config-from-env';\nimport { isMainConfig } from '../../schema/utils/is-main-config';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\nimport type { Config } from '../../schema/types';\nimport type { ClientConfig } from '../client/types';\nimport { MicrofrontendError } from '../../errors';\nimport { MicrofrontendConfigClient } from '../client';\nimport { type OverridesConfig, parseOverrides } from '../../overrides';\nimport { DefaultApplication, ChildApplication } from './application';\nimport { DEFAULT_LOCAL_PROXY_PORT } from './constants';\nimport {\n validateConfigDefaultApplication,\n validateConfigPaths,\n} from './validation';\n\nexport interface ConfigMeta {\n /**\n * The application name that the configuration is being loaded from.\n */\n fromApp: string;\n}\n\ninterface ValidationOptions {\n skipValidation?: ('version' | 'paths' | 'defaultApplication')[];\n}\n\n/**\n * A class to manage the microfrontends configuration.\n */\nexport class MicrofrontendConfigIsomorphic {\n config: Config;\n isMainConfig: boolean;\n partOf?: string;\n defaultApplication?: DefaultApplication;\n childApplications: Record<string, ChildApplication> = {};\n overrides?: OverridesConfig;\n options?: Config['options'];\n\n private readonly serialized: {\n config: Config;\n overrides?: OverridesConfig;\n meta: ConfigMeta;\n };\n\n constructor({\n config,\n overrides,\n meta,\n opts,\n }: {\n config: Config;\n overrides?: OverridesConfig;\n meta: ConfigMeta;\n opts?: ValidationOptions;\n }) {\n // run validation on init\n MicrofrontendConfigIsomorphic.validate(config, opts);\n\n const disableOverrides = config.options?.vercel?.disableOverrides ?? false;\n this.overrides = overrides && !disableOverrides ? overrides : undefined;\n this.isMainConfig = isMainConfig(config);\n\n if (isMainConfig(config)) {\n // create applications\n for (const [appId, appConfig] of Object.entries(config.applications)) {\n const appOverrides = !disableOverrides\n ? this.overrides?.applications[appId]\n : undefined;\n\n if (isDefaultApp(appConfig)) {\n this.defaultApplication = new DefaultApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n } else {\n this.childApplications[appId] = new ChildApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n }\n }\n } else {\n this.partOf = config.partOf;\n const appOverrides = !disableOverrides\n ? this.overrides?.applications[meta.fromApp]\n : undefined;\n this.childApplications[meta.fromApp] = new ChildApplication(\n meta.fromApp,\n {\n // we don't know routing because we're not in the main config\n app: { routing: [] },\n overrides: appOverrides,\n },\n );\n }\n\n // the main configuration file should ALWAYS have the default\n if (isMainConfig(config) && !this.defaultApplication) {\n throw new MicrofrontendError(\n `Could not find default application in microfrontends configuration`,\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n this.config = config;\n this.options = config.options;\n this.serialized = {\n config,\n overrides,\n meta,\n };\n }\n\n static validate(config: string | Config, opts?: ValidationOptions): Config {\n const skipValidation: ValidationOptions['skipValidation'] =\n opts?.skipValidation ?? [];\n // let this throw if it's not valid JSON\n const c = typeof config === 'string' ? (parse(config) as Config) : config;\n\n if (isMainConfig(c)) {\n if (!skipValidation.includes('paths')) {\n validateConfigPaths(c.applications);\n }\n if (!skipValidation.includes('defaultApplication')) {\n validateConfigDefaultApplication(c.applications);\n }\n }\n\n return c;\n }\n\n static fromEnv({\n meta,\n cookies,\n }: {\n meta: ConfigMeta;\n cookies?: { name: string; value: string }[];\n }): MicrofrontendConfigIsomorphic {\n return new MicrofrontendConfigIsomorphic({\n config: parse(getConfigStringFromEnv()) as Config,\n overrides: parseOverrides(cookies ?? []),\n meta,\n });\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.vercel?.disableOverrides ?? false;\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getApplicationsByType(): {\n defaultApplication?: DefaultApplication;\n applications: ChildApplication[];\n } {\n return {\n defaultApplication: this.defaultApplication,\n applications: Object.values(this.childApplications),\n };\n }\n\n getChildApplications(): ChildApplication[] {\n return Object.values(this.childApplications);\n }\n\n getAllApplications(): (DefaultApplication | ChildApplication)[] {\n return [\n this.defaultApplication,\n ...Object.values(this.childApplications),\n ].filter(Boolean) as (DefaultApplication | ChildApplication)[];\n }\n\n getApplication(name: string): DefaultApplication | ChildApplication {\n // check the default\n if (this.defaultApplication?.name === name) {\n return this.defaultApplication;\n }\n const app = this.childApplications[name];\n if (!app) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n return app;\n }\n\n getApplicationByProjectId(\n projectId: string,\n ): DefaultApplication | ChildApplication | undefined {\n // check the default\n if (this.defaultApplication?.vercel?.projectId === projectId) {\n return this.defaultApplication;\n }\n\n return Object.values(this.childApplications).find(\n (app) => app.vercel?.projectId === projectId,\n );\n }\n\n /**\n * Returns the default application. This can throw if the default application\n * is undefined ( )\n */\n getDefaultApplication(): DefaultApplication {\n if (!this.defaultApplication) {\n throw new MicrofrontendError(\n `Could not find default application in microfrontends configuration`,\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n return this.defaultApplication;\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 return this.serialized.config;\n }\n\n toClientConfig(): MicrofrontendConfigClient {\n const applications: ClientConfig['applications'] = Object.fromEntries(\n Object.entries(this.childApplications).map(([name, application]) => [\n name,\n {\n default: false,\n routing: application.routing,\n },\n ]),\n );\n\n // add the default application\n if (this.defaultApplication) {\n applications[this.defaultApplication.name] = {\n default: true,\n };\n }\n\n return new MicrofrontendConfigClient({\n applications,\n });\n }\n\n serialize(): {\n config: Config;\n overrides?: OverridesConfig;\n meta: ConfigMeta;\n } {\n return this.serialized;\n }\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'application'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\n | 'inference_failed'\n | 'not_found_in_env'\n | 'invalid_asset_prefix'\n | 'invalid_main_path'\n | 'does_not_match_schema'\n | 'unable_to_read_file'\n | 'unsupported_validation_env'\n | 'unsupported_version'\n | 'invalid_path'\n | 'invalid_permissions'\n | 'invalid_syntax'\n | 'missing_microfrontend_config_path'\n | 'unsupported_operation';\n\n// A mapping of error types to their subtypes.\ninterface TypeToSubtype {\n application:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\n | 'does_not_match_schema'\n | 'invalid_main_path'\n | 'invalid_preview_deployment_suffix'\n | 'multiple_default_applications'\n | 'no_default_application'\n | 'not_found_in_env'\n | 'not_found'\n | 'inference_failed'\n | 'unable_to_read_file'\n | 'invalid_syntax'\n | 'invalid_permissions'\n | 'unsupported_operation'\n | 'unsupported_validation_env'\n | 'unsupported_version';\n packageJson:\n | 'missing_field_name'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n vercelJson:\n | 'missing_field_microfrontend_config_path'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n unknown: never;\n}\n\nexport type MicrofrontendErrorSource =\n | '@vercel/microfrontends'\n | '@vercel/microfrontends/next'\n | 'fs'\n | 'ajv';\n\nexport interface MicrofrontendErrorOptions<T extends MicrofrontendErrorType> {\n cause?: unknown;\n source?: MicrofrontendErrorSource;\n type?: T;\n subtype?: TypeToSubtype[T];\n}\n\ninterface HandleOptions {\n fileName?: string;\n}\n\nexport class MicrofrontendError<\n T extends MicrofrontendErrorType = 'unknown',\n> extends Error {\n public source: MicrofrontendErrorSource;\n public type: T;\n public subtype?: TypeToSubtype[T];\n\n constructor(message: string, opts?: MicrofrontendErrorOptions<T>) {\n super(message, { cause: opts?.cause });\n this.name = 'MicrofrontendsError';\n this.source = opts?.source ?? '@vercel/microfrontends';\n this.type = opts?.type ?? ('unknown' as T);\n this.subtype = opts?.subtype;\n Error.captureStackTrace(this, MicrofrontendError);\n }\n\n isKnown(): boolean {\n return this.type !== 'unknown';\n }\n\n isUnknown(): boolean {\n return !this.isKnown();\n }\n\n /**\n * Converts an error to a MicrofrontendsError.\n * @param original - The original error to convert.\n * @returns The converted MicrofrontendsError.\n */\n static convert(\n original: Error,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (opts?.fileName) {\n const err = MicrofrontendError.convertFSError(original, opts.fileName);\n if (err) {\n return err;\n }\n }\n\n if (\n original.message.includes(\n 'Code generation from strings disallowed for this context',\n )\n ) {\n return new MicrofrontendError(original.message, {\n type: 'config',\n subtype: 'unsupported_validation_env',\n source: 'ajv',\n });\n }\n\n // unknown catch-all\n return new MicrofrontendError(original.message);\n }\n\n static convertFSError(\n original: Error,\n fileName: string,\n ): MicrofrontendError<MicrofrontendErrorType> | null {\n if (original instanceof Error && 'code' in original) {\n if (original.code === 'ENOENT') {\n return new MicrofrontendError(`Could not find \"${fileName}\"`, {\n type: 'config',\n subtype: 'unable_to_read_file',\n source: 'fs',\n });\n }\n if (original.code === 'EACCES') {\n return new MicrofrontendError(\n `Permission denied while accessing \"${fileName}\"`,\n {\n type: 'config',\n subtype: 'invalid_permissions',\n source: 'fs',\n },\n );\n }\n }\n\n if (original instanceof SyntaxError) {\n return new MicrofrontendError(\n `Failed to parse \"${fileName}\": Invalid JSON format.`,\n {\n type: 'config',\n subtype: 'invalid_syntax',\n source: 'fs',\n },\n );\n }\n\n return null;\n }\n\n /**\n * Handles an unknown error and returns a MicrofrontendsError instance.\n * @param err - The error to handle.\n * @returns A MicrofrontendsError instance.\n */\n static handle(\n err: unknown,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (err instanceof MicrofrontendError) {\n return err as MicrofrontendError<MicrofrontendErrorType>;\n }\n\n // handle Error instances\n if (err instanceof Error) {\n return MicrofrontendError.convert(err, opts);\n }\n\n // handle object errors\n if (typeof err === 'object' && err !== null) {\n if ('message' in err && typeof err.message === 'string') {\n return MicrofrontendError.convert(new Error(err.message), opts);\n }\n }\n\n return new MicrofrontendError('An unknown error occurred');\n }\n}\n","import { MicrofrontendError } from '../../errors';\n\n/**\n * Utility to fetch the microfrontend configuration string from the environment.\n */\nexport function getConfigStringFromEnv(): string {\n const config = process.env.MFE_CONFIG;\n if (!config) {\n throw new MicrofrontendError(`Missing \"MFE_CONFIG\" in environment.`, {\n type: 'config',\n subtype: 'not_found_in_env',\n });\n }\n return config;\n}\n","import type { Config, MainConfig } from '../types';\n\nexport function isMainConfig(c: Config): c is MainConfig {\n return !('partOf' in c);\n}\n","import type { Application, DefaultApplication } from '../types';\n\nexport function isDefaultApp(a: Application): a is DefaultApplication {\n return !('routing' in a);\n}\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\ninterface MicrofrontendConfigClientOptions {\n removeFlaggedPaths?: boolean;\n}\n\nexport class MicrofrontendConfigClient {\n applications: ClientConfig['applications'];\n pathCache: Record<string, string> = {};\n private readonly serialized: ClientConfig;\n\n constructor(config: ClientConfig, opts?: MicrofrontendConfigClientOptions) {\n this.serialized = config;\n if (opts?.removeFlaggedPaths) {\n for (const app of Object.values(config.applications)) {\n if (app.routing) {\n app.routing = app.routing.filter((match) => !match.flag);\n }\n }\n }\n this.applications = config.applications;\n }\n\n /**\n * Create a new `MicrofrontendConfigClient` from a JSON string.\n * Config must be passed in to remain framework agnostic\n */\n static fromEnv(\n config: string | undefined,\n opts?: MicrofrontendConfigClientOptions,\n ): MicrofrontendConfigClient {\n if (!config) {\n throw new Error('No microfrontends configuration found');\n }\n return new MicrofrontendConfigClient(\n JSON.parse(config) as ClientConfig,\n opts,\n );\n }\n\n isEqual(other: MicrofrontendConfigClient): boolean {\n return (\n JSON.stringify(this.applications) === JSON.stringify(other.applications)\n );\n }\n\n getApplicationNameForPath(path: string): string | null {\n if (!path.startsWith('/')) {\n throw new Error(`Path must start with a /`);\n }\n\n if (this.pathCache[path]) {\n return this.pathCache[path];\n }\n\n const pathname = new URL(path, 'https://example.com').pathname;\n for (const [name, application] of Object.entries(this.applications)) {\n if (application.routing) {\n for (const group of application.routing) {\n for (const childPath of group.paths) {\n const regexp = pathToRegexp(childPath);\n if (regexp.test(pathname)) {\n this.pathCache[path] = name;\n return name;\n }\n }\n }\n }\n }\n const defaultApplication = Object.entries(this.applications).find(\n ([, application]) => application.default,\n );\n if (!defaultApplication) {\n return null;\n }\n\n this.pathCache[path] = defaultApplication[0];\n return defaultApplication[0];\n }\n\n serialize(): ClientConfig {\n return this.serialized;\n }\n}\n","// cookie name needs to match proxy\n// https://github.com/vercel/proxy/blob/fb00d723136ad539a194e4a851dd272010527c35/lib/routing/micro_frontends_overrides.lua#L7\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\nexport const OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n","import { OVERRIDES_COOKIE_PREFIX } from './constants';\n\nexport function isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n}\n","import { isOverrideCookie } from './is-override-cookie';\nimport { OVERRIDES_ENV_COOKIE_PREFIX } from './constants';\n\nexport function getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n}): { application: string; host: string } | undefined {\n if (!isOverrideCookie(cookie) || !cookie.value) return;\n return {\n application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ''),\n host: cookie.value,\n };\n}\n","import type { OverridesConfig } from './types';\nimport { getOverrideFromCookie } from './get-override-from-cookie';\n\nexport function parseOverrides(\n cookies: { name: string; value?: string | null }[],\n): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.application] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n}\n","import { pathToRegexp, parse as parsePathRegexp } from 'path-to-regexp';\nimport type {\n ApplicationId,\n PathGroup,\n ApplicationRouting,\n ChildApplication as ChildApplicationConfig,\n} from '../../schema/types';\nimport { MicrofrontendError } from '../../errors';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\n\n/**\n * Validate all paths in a configuration - ensures paths do not overlap\n */\nexport const validateConfigPaths = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n const pathsByApplicationId = new Map<\n PathGroup['paths'][number],\n {\n applications: ApplicationId[];\n matcher: RegExp;\n applicationId?: ApplicationId;\n }\n >();\n const errors: string[] = [];\n\n for (const [id, app] of Object.entries(applicationConfigsById)) {\n if (isDefaultApp(app)) {\n // default applications do not have routing\n continue;\n }\n\n for (const pathMatch of app.routing) {\n for (const path of pathMatch.paths) {\n const maybeError = validatePathExpression(path);\n if (maybeError) {\n errors.push(maybeError);\n }\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\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/**\n * Validate all paths in an application - ensures paths are the correct format\n */\nexport const validateAppPaths = (\n name: string,\n app: ChildApplicationConfig,\n): void => {\n // validate routes\n for (const group of app.routing) {\n for (const p of group.paths) {\n if (p === '/') {\n continue;\n }\n if (p.endsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must not end with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n\n if (!p.startsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must start with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n }\n }\n};\n\n/**\n * Make sure only one `Application` defines routing\n * */\nexport const validateConfigDefaultApplication = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n // find all applications that have routing\n const applicationsWithRouting = Object.entries(applicationConfigsById).filter(\n ([, app]) => !isDefaultApp(app),\n );\n // get all the application names\n const applicationsWithRoutingNames = applicationsWithRouting.map(\n ([key]) => key,\n );\n const numApplications = Object.keys(applicationConfigsById).length;\n const numApplicationsWithRouting = applicationsWithRoutingNames.length;\n const numApplicationsWithoutRouting =\n numApplications - numApplicationsWithRouting;\n\n if (numApplicationsWithoutRouting === 0) {\n throw new MicrofrontendError(\n `No default application found. At least one application needs to be the default by omitting routing.`,\n { type: 'config', subtype: 'no_default_application' },\n );\n }\n\n if (numApplicationsWithoutRouting > 1) {\n throw new MicrofrontendError(\n `Only one application can omit \"routing\". Found ${applicationsWithRoutingNames.length - Object.keys(applicationConfigsById).length > 1}.`,\n { type: 'config', subtype: 'multiple_default_applications' },\n );\n }\n};\n","const PREFIX = 'vc-ap';\n\nexport function generateAssetPrefixFromName({\n name,\n}: {\n name: string;\n}): string {\n if (!name) {\n throw new Error('Name is required to generate an asset prefix');\n }\n\n return `${PREFIX}-${name}`;\n}\n","export function generatePortFromName({\n name,\n minPort = 3000,\n maxPort = 8000,\n}: {\n name: string;\n minPort?: number;\n maxPort?: number;\n}): number {\n if (!name) {\n throw new Error('Name is required to generate a port');\n }\n\n // hash the name\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n // eslint-disable-next-line no-bitwise\n hash = (hash << 5) - hash + name.charCodeAt(i);\n // Convert to 32-bit\n // eslint-disable-next-line no-bitwise\n hash |= 0;\n }\n hash = Math.abs(hash);\n\n // Map the hash to the port range\n const range = maxPort - minPort;\n const port = minPort + (hash % range);\n\n return port;\n}\n","import type {\n HostConfig as RemoteHostConfigSchema,\n LocalHostConfig as LocalHostConfigSchema,\n} from '../../schema/types';\nimport { generatePortFromName } from './utils/generate-port';\n\ninterface HostDisplayOptions {\n includeDefaultPort?: boolean;\n}\n\ninterface HostOptions {\n isLocal?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: string;\n port: number;\n local: boolean | undefined;\n\n constructor(hostConfig: RemoteHostConfigSchema, options?: HostOptions) {\n const { protocol = 'https', host, port } = hostConfig;\n this.protocol = protocol;\n this.host = host;\n this.port = Host.getPort({ port, protocol: this.protocol });\n this.local = options?.isLocal;\n }\n\n isLocal(): boolean {\n return this.local || this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n static getPort({\n protocol,\n port,\n }: {\n protocol: RemoteHostConfigSchema['protocol'];\n port?: RemoteHostConfigSchema['port'];\n }): 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\n/**\n * A Host subclass with defaults for locally running applications\n */\nexport class LocalHost extends Host {\n constructor({\n appName,\n ...hostConfig\n }: LocalHostConfigSchema & { appName: string }) {\n // set defaults for local\n const host = hostConfig.host ?? 'localhost';\n const port = hostConfig.port ?? generatePortFromName({ name: appName });\n const protocol = hostConfig.protocol ?? 'http';\n\n super({ protocol, host, port });\n }\n}\n","import type {\n Application as ApplicationConfig,\n DefaultApplication as DefaultApplicationConfig,\n ChildApplication as ChildApplicationConfig,\n PathGroup,\n Vercel,\n} from '../../schema/types';\nimport type { ApplicationOverrideConfig } from '../../overrides';\nimport { validateAppPaths } from './validation';\nimport { generateAssetPrefixFromName } from './utils/generate-asset-prefix';\nimport { Host, LocalHost } from './host';\n\nexport class Application {\n readonly default: boolean;\n name: string;\n development: {\n local: LocalHost;\n fallback?: Host;\n };\n production?: Host;\n vercel?: Vercel;\n overrides?: {\n environment?: Host;\n };\n readonly serialized: ApplicationConfig;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n isDefault,\n }: {\n app: ApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n isDefault?: boolean;\n },\n ) {\n this.name = name;\n this.development = {\n local: new LocalHost({\n appName: name,\n ...app.development?.local,\n }),\n fallback: app.development?.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n this.production = app.production ? new Host(app.production) : undefined;\n this.vercel = app.vercel;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n this.default = isDefault ?? false;\n this.serialized = app;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n getAssetPrefix(): string {\n return generateAssetPrefixFromName({ name: this.name });\n }\n\n serialize(): ApplicationConfig {\n return this.serialized;\n }\n}\n\nexport class DefaultApplication extends Application {\n readonly default = true;\n production: Host;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: DefaultApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n super(name, {\n app,\n overrides,\n isDefault: true,\n });\n\n this.production = new Host(app.production);\n }\n\n getAssetPrefix(): string {\n return '';\n }\n}\n\nexport class ChildApplication extends Application {\n readonly default = false;\n routing: PathGroup[];\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: ChildApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n // validate\n ChildApplication.validate(name, app);\n\n super(name, {\n app,\n overrides,\n isDefault: false,\n });\n\n this.routing = app.routing;\n }\n\n static validate(name: string, app: ChildApplicationConfig): void {\n // validate routes\n validateAppPaths(name, app);\n }\n}\n","export const DEFAULT_LOCAL_PROXY_PORT = 3024;\n","/// <reference types=\"@edge-runtime/types\" />\n\nimport type { Application } from '../config/microfrontends-config/isomorphic/application';\nimport type { VercelRelatedProject } from './types';\n\n/**\n * Gets the domain for a related project from the environment.\n *\n * This is used for preview, and production, and requires project linking in Vercel\n */\nexport function getDomainFromEnvironment({\n app,\n target,\n}: {\n app: Application;\n target: 'production' | 'preview';\n}): string {\n const mfeProjects = JSON.parse(\n process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? '[]',\n ) as VercelRelatedProject[];\n\n if (mfeProjects.length === 0) {\n throw new Error('Missing related microfrontends project information');\n }\n\n if (!app.vercel?.projectId) {\n throw new Error(`Missing applications[${app.name}].vercel.projectId`);\n }\n\n const vercelProject = mfeProjects.find(\n (p) => p.project.id === app.vercel?.projectId,\n );\n\n if (!vercelProject) {\n throw new Error(\n `Missing related microfrontends project information for application \"${app.name}\"`,\n );\n }\n\n const domain =\n target === 'preview' && vercelProject.preview.branch\n ? vercelProject.preview.branch\n : (vercelProject.production.alias ?? vercelProject.production.url);\n\n if (!domain) {\n throw new Error(\n `Missing domain for target \"${target}\" in application \"${app.name}\"`,\n );\n }\n\n return domain.startsWith('https://') ? domain : `https://${domain}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,oBAIO;AACP,IAAAA,yBAAsB;AACtB,IAAAC,uBAAsB;AACtB,iCAAyB;AACzB,qBAAgC;AAChC,iBAA+B;;;ACV/B,0BAAsB;;;AC4Ef,IAAM,qBAAN,cAEG,MAAM;AAAA,EAKd,YAAY,SAAiB,MAAqC;AAChE,UAAM,SAAS,EAAE,OAAO,MAAM,MAAM,CAAC;AACrC,SAAK,OAAO;AACZ,SAAK,SAAS,MAAM,UAAU;AAC9B,SAAK,OAAO,MAAM,QAAS;AAC3B,SAAK,UAAU,MAAM;AACrB,UAAM,kBAAkB,MAAM,kBAAkB;AAAA,EAClD;AAAA,EAEA,UAAmB;AACjB,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA,EAEA,YAAqB;AACnB,WAAO,CAAC,KAAK,QAAQ;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,OAAO,QACL,UACA,MAC4C;AAC5C,QAAI,MAAM,UAAU;AAClB,YAAM,MAAM,mBAAmB,eAAe,UAAU,KAAK,QAAQ;AACrE,UAAI,KAAK;AACP,eAAO;AAAA,MACT;AAAA,IACF;AAEA,QACE,SAAS,QAAQ;AAAA,MACf;AAAA,IACF,GACA;AACA,aAAO,IAAI,mBAAmB,SAAS,SAAS;AAAA,QAC9C,MAAM;AAAA,QACN,SAAS;AAAA,QACT,QAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAGA,WAAO,IAAI,mBAAmB,SAAS,OAAO;AAAA,EAChD;AAAA,EAEA,OAAO,eACL,UACA,UACmD;AACnD,QAAI,oBAAoB,SAAS,UAAU,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jD;AACA,qBAAO;AAAA,gBACL,yBAAyB,kBAAkB,kBAAkB,gBAAgB,SAAS,QAAQ,IAAI,sBAAsB;AAAA,cAC1H;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AACA,QAAI,OAAO,QAAQ;AACjB,YAAM,IAAI,MAAM,OAAO,KAAK,IAAI,CAAC;AAAA,IACnC;AAAA,EACF,UAAE;AACA,YAAQ,IAAI,aAAa;AACzB,YAAQ,IAAI,sBAAsB;AAAA,EACpC;AACF;","names":["import_path_to_regexp","import_jsonc_parser","match","import_path_to_regexp","parsePathRegexp"]}
1
+ {"version":3,"sources":["../../src/next/testing/index.ts","../../src/config/microfrontends-config/isomorphic/index.ts","../../src/config/errors.ts","../../src/config/microfrontends-config/utils/get-config-from-env.ts","../../src/config/schema/utils/is-main-config.ts","../../src/config/schema/utils/is-default-app.ts","../../src/config/microfrontends-config/client/index.ts","../../src/config/overrides/constants.ts","../../src/config/overrides/is-override-cookie.ts","../../src/config/overrides/get-override-from-cookie.ts","../../src/config/overrides/parse-overrides.ts","../../src/config/microfrontends-config/isomorphic/validation.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-asset-prefix.ts","../../src/config/microfrontends-config/isomorphic/utils/generate-port.ts","../../src/config/microfrontends-config/isomorphic/host.ts","../../src/config/microfrontends-config/isomorphic/application.ts","../../src/config/microfrontends-config/isomorphic/constants.ts","../../src/routing/get-domain-from-environment.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport {\n type NextFetchEvent,\n NextRequest,\n type MiddlewareConfig,\n} from 'next/server';\nimport { match } from 'path-to-regexp';\nimport { parse } from 'jsonc-parser';\nimport { matchHas } from 'next/dist/shared/lib/router/utils/prepare-destination';\nimport { NextRequestHint } from 'next/dist/server/web/adapter';\nimport { WebNextRequest } from 'next/dist/server/base-http/web';\nimport { MicrofrontendConfigIsomorphic } from '../../config/microfrontends-config/isomorphic';\nimport { DefaultApplication } from '../../config/microfrontends-config/isomorphic/application';\nimport { getDomainFromEnvironment } from '../../routing/get-domain-from-environment';\nimport type { Config } from '../../config/schema/types';\n\n/** Replaces path wildcards (if they exist) with synthesized paths. */\nexport function expandWildcards(path: string): string[] {\n if (path.includes('/:path*') || path.includes('/:slug*')) {\n return [\n path === '/:path*' || path === '/:slug*'\n ? '/'\n : path.replace('/:path*', '').replace('/:slug*', ''),\n path.replace('/:path*', '/foo').replace('/:slug*', '/foo'),\n path.replace('/:path*', '/foo/bar').replace('/:slug*', '/foo/bar'),\n ];\n }\n if (path.includes('/:path+') || path.includes('/:slug+')) {\n return [\n path.replace('/:path+', '/foo').replace('/:slug+', '/foo'),\n path.replace('/:path+', '/foo/bar').replace('/:slug+', '/foo/bar'),\n ];\n }\n if (path.includes('/:path') || path.includes('/:slug')) {\n return [path.replace('/:path', '/foo').replace('/:slug', '/foo')];\n }\n return [path];\n}\n\nexport function loadMicrofrontendConfigForEdge(\n path: string,\n): MicrofrontendConfigIsomorphic {\n // NOTE: It's necessary to read and parse this file manually because tests that\n // run in `@edge-runtime/jest-environment` will fail since the AJV validation\n // from the @vercel/microfrontends package violates the rules by\n // using eval.\n const rawMfConfig = parse(readFileSync(path, 'utf-8')) as Config;\n return new MicrofrontendConfigIsomorphic({\n config: rawMfConfig,\n meta: { fromApp: 'test' },\n });\n}\n\nexport function getAllChildApplicationNames(\n mfConfig: MicrofrontendConfigIsomorphic,\n): string[] {\n return mfConfig.getChildApplications().map((app) => app.name);\n}\n\nexport function getLaunchedPathsForApp(\n mfConfig: MicrofrontendConfigIsomorphic,\n appName: string,\n): string[] {\n const app = mfConfig.getApplication(appName);\n if (app instanceof DefaultApplication) {\n return [];\n }\n\n return [\n `/${app.getAssetPrefix()}/_next/static`,\n ...app.routing\n .filter((group) => !group.flag)\n .flatMap((group) => group.paths.flatMap(expandWildcards)),\n ];\n}\n\nexport function getFlaggedPathsForApp(\n mfConfig: MicrofrontendConfigIsomorphic,\n appName: string,\n): string[] {\n const app = mfConfig.getApplication(appName);\n if (app instanceof DefaultApplication) {\n return [];\n }\n\n return app.routing\n .filter((group) => Boolean(group.flag))\n .flatMap((group) => group.paths.flatMap(expandWildcards));\n}\n\nexport function getExpectedDomainForApp(\n mfConfig: MicrofrontendConfigIsomorphic,\n appName: string,\n env: string,\n): string {\n const app = mfConfig.getApplication(appName);\n const defaultApp = mfConfig.getDefaultApplication();\n if (env === 'development') {\n return app.development.local.toString();\n }\n\n if (['preview', 'production'].includes(env)) {\n const target = env as 'preview' | 'production';\n return getDomainFromEnvironment({ app, target });\n }\n\n return defaultApp.fallback.toString();\n}\n\n/**\n * Returns a list of examples for all paths in microfrontends.json.\n */\nexport function getAllMultiZonesPaths(\n mfConfig: MicrofrontendConfigIsomorphic,\n): string[] {\n return mfConfig.getChildApplications().flatMap((app) => {\n return app.routing.flatMap((group) => group.paths.flatMap(expandWildcards));\n });\n}\n\nfunction urlMatches(\n middlewareConfig: MiddlewareConfig,\n path: string,\n host: string,\n): boolean {\n if (!middlewareConfig.matcher) {\n return false;\n }\n // This is based off\n // https://github.com/vercel/next.js/blob/4835be182b88f67f282c30db4278c30fe9e5b483/packages/next/src/build/analysis/get-page-static-info.ts#L324\n const matchers = Array.isArray(middlewareConfig.matcher)\n ? middlewareConfig.matcher\n : [middlewareConfig.matcher];\n for (let matcher of matchers) {\n matcher = typeof matcher === 'string' ? { source: matcher } : matcher;\n if (match(matcher.source)(path)) {\n if (\n matchHas(\n new WebNextRequest(\n new NextRequestHint({\n init: { headers: { host } },\n input: `https://${host}${path}`,\n page: 'unused_placeholder',\n }),\n ),\n {},\n matcher.has,\n matcher.missing,\n )\n ) {\n return true;\n }\n }\n }\n return false;\n}\n\n/**\n * A test to ensure that middleware is configured to work correctly with\n * microfrontends. Passing this test does NOT guarentee middleware is set up\n * correctly, but this should find many common problems. This should only be run\n * on the application marked as \"default\" in the microfrontend config. If a\n * configuration issue is found, this will throw an exception (this ensures it\n * works with any test framework).\n *\n * For example, if a microfrontend is configured to serve \"/my/path\" then the\n * default application should have an entry like this in its middleware config:\n *\n * export const config = `{`\n * matcher: [\n * `{`\n * source: '/my/path', // Or a regular expression that matches /my/path\n * missing: [\n * `{`\n * type: 'header',\n * key: 'host',\n * value: 'your.production.host.from.the.default.application.com',\n * `}`,\n * ],\n * `}`,\n * ...\n * ],\n * `}`\n *\n * If a path should match middleware in production for non-microfrontend\n * reasons, you can pass that path in the extraProductionMatches parameter.\n */\nexport function validateMiddlewareConfig(\n middlewareConfig: MiddlewareConfig,\n microfrontendConfigOrPath: string | MicrofrontendConfigIsomorphic,\n extraProductionMatches?: string[],\n): void {\n const microfrontendConfig =\n typeof microfrontendConfigOrPath === 'string'\n ? loadMicrofrontendConfigForEdge(microfrontendConfigOrPath)\n : microfrontendConfigOrPath;\n\n const errors: string[] = [];\n const usedExtraProductionMatches = new Set<string>();\n for (const application of microfrontendConfig.getChildApplications()) {\n const matches = [...application.routing];\n matches.push({\n paths: [`/${application.getAssetPrefix()}/_next/:path+`],\n });\n\n for (const aMatch of matches) {\n const isFlagged = Boolean(aMatch.flag);\n\n for (const path of aMatch.paths) {\n const pathsToTest = expandWildcards(path);\n for (const testPath of pathsToTest) {\n const productionHost =\n microfrontendConfig.getDefaultApplication().production?.host;\n const pathForDisplay = `${testPath}${path === testPath ? '' : ` (synthesized from ${path})`}`;\n if (!productionHost) {\n continue;\n }\n if (\n !urlMatches(middlewareConfig, testPath, 'test.nonproduction.host')\n ) {\n errors.push(\n `Matcher misconfigured for ${pathForDisplay}. This path should have matched the middleware config on a non-production host, but did not. Microfrontends require a middleware config matcher that matches on this host everywhere but in production. That can be configured with a configuration like this:\\n${getSampleMatcher(path, productionHost)}`,\n );\n // Skip the remaining expanded wildcard paths (if there are any)\n // to only report a single error per wildcard.\n break;\n }\n\n const productionUrlMatches = urlMatches(\n middlewareConfig,\n testPath,\n productionHost,\n );\n if (isFlagged) {\n if (!productionUrlMatches) {\n errors.push(\n `Matcher misconfigured for ${pathForDisplay}. Middleware config matchers for flagged paths should ALWAYS match.`,\n );\n // Skip the remaining expanded wildcard paths (if there are any)\n // to only report a single error per wildcard.\n break;\n }\n } else if (productionUrlMatches) {\n if (extraProductionMatches?.includes(path)) {\n usedExtraProductionMatches.add(path);\n } else {\n errors.push(\n `Matcher misconfigured for ${pathForDisplay}. This path matched the middleware config on a production host, but should not have. Microfrontends require a middleware config matcher that matches on this host everywhere but in production. If this is desired, you can add the path the to extraProductionMatches parameter. Otherwise, you can set up a configuration like this:\\n${getSampleMatcher(path, productionHost)}`,\n );\n }\n // Skip the remaining expanded wildcard paths (if there are any)\n // to only report a single error per wildcard.\n break;\n }\n }\n }\n }\n }\n\n const unusedExtraProductionMatches = extraProductionMatches?.filter(\n (x) => !usedExtraProductionMatches.has(x),\n );\n if (unusedExtraProductionMatches?.length) {\n errors.push(\n `The following paths were passed to the extraProductionMatches parameter but were unused. You probably want to remove them from the extraProductionMatches parameter: ${unusedExtraProductionMatches.join(', ')}`,\n );\n }\n\n if (errors.length > 0) {\n const message = `Found the following inconsistencies between your microfrontend config ${\n typeof microfrontendConfigOrPath === 'string'\n ? `(at ${microfrontendConfigOrPath}) `\n : ''\n }and middleware config:\\n\\n- `;\n throw new Error(message + errors.join('\\n\\n- '));\n }\n}\n\nfunction getSampleMatcher(path: string, host: string): string {\n return ` {\n source: '${path}', // This can also be a broader regular expression.\n missing: [\n type: 'header',\n key: 'host',\n value '${host}',\n ],\n }`;\n}\n\n/**\n * Ensures that middleware rewrites to the correct path for flagged paths.\n * IMPORTANT: you must enable the necessary flags before calling this function.\n */\nexport async function validateMiddlewareOnFlaggedPaths(\n microfrontendConfigOrPath: string | MicrofrontendConfigIsomorphic,\n middleware: (\n request: NextRequest,\n event: NextFetchEvent,\n ) => Promise<Response | undefined>,\n): Promise<void> {\n const initialEnv = process.env.VERCEL_ENV;\n const initialMfePreviewDomains = process.env.MFE_PREVIEW_DOMAINS;\n try {\n const microfrontendConfig =\n typeof microfrontendConfigOrPath === 'string'\n ? loadMicrofrontendConfigForEdge(microfrontendConfigOrPath)\n : microfrontendConfigOrPath;\n const allAppNames = getAllChildApplicationNames(microfrontendConfig);\n\n const errors: string[] = [];\n for (const appName of allAppNames) {\n const flaggedPaths = getFlaggedPathsForApp(microfrontendConfig, appName);\n if (flaggedPaths.length) {\n for (const env of ['preview', 'production']) {\n process.env.VERCEL_ENV = env;\n for (const path of flaggedPaths) {\n const expectedHost = getExpectedDomainForApp(\n microfrontendConfig,\n appName,\n env,\n );\n const expectedDefaultHost = getExpectedDomainForApp(\n microfrontendConfig,\n microfrontendConfig.getDefaultApplication().name,\n env,\n );\n const requestPath = `${expectedDefaultHost}${path}`;\n const request = new NextRequest(requestPath, {\n headers: { 'x-vercel-skip-deployment-existence-check': '1' },\n });\n\n // eslint-disable-next-line no-await-in-loop\n const response = await middleware(\n request,\n {} as unknown as NextFetchEvent,\n );\n const expectedUrl = `${expectedHost}${path}`;\n if (!response) {\n errors.push(\n `middleware did not action for ${requestPath} in ${env}. Expected a rewrite to ${expectedUrl}`,\n );\n } else if (response.status !== 200) {\n errors.push(\n `expected 200 status for ${requestPath} in ${env} but got ${response.status}`,\n );\n } else if (\n response.headers.get('x-middleware-rewrite') !== expectedUrl\n ) {\n errors.push(\n `expected rewrite from ${requestPath} to ${expectedUrl} in ${env}, but got ${response.headers.get('x-middleware-rewrite')}`,\n );\n }\n }\n }\n }\n }\n if (errors.length) {\n throw new Error(errors.join('\\n'));\n }\n } finally {\n process.env.VERCEL_ENV = initialEnv;\n process.env.MFE_PREVIEW_DOMAINS = initialMfePreviewDomains;\n }\n}\n","import { parse } from 'jsonc-parser';\nimport { getConfigStringFromEnv } from '../utils/get-config-from-env';\nimport { isMainConfig } from '../../schema/utils/is-main-config';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\nimport type { Config } from '../../schema/types';\nimport type { ClientConfig } from '../client/types';\nimport { MicrofrontendError } from '../../errors';\nimport { MicrofrontendConfigClient } from '../client';\nimport { type OverridesConfig, parseOverrides } from '../../overrides';\nimport { DefaultApplication, ChildApplication } from './application';\nimport { DEFAULT_LOCAL_PROXY_PORT } from './constants';\nimport {\n validateConfigDefaultApplication,\n validateConfigPaths,\n} from './validation';\n\nexport interface ConfigMeta {\n /**\n * The application name that the configuration is being loaded from.\n */\n fromApp: string;\n}\n\ninterface ValidationOptions {\n skipValidation?: ('version' | 'paths' | 'defaultApplication')[];\n}\n\n/**\n * A class to manage the microfrontends configuration.\n */\nexport class MicrofrontendConfigIsomorphic {\n config: Config;\n isMainConfig: boolean;\n partOf?: string;\n defaultApplication?: DefaultApplication;\n childApplications: Record<string, ChildApplication> = {};\n overrides?: OverridesConfig;\n options?: Config['options'];\n\n private readonly serialized: {\n config: Config;\n overrides?: OverridesConfig;\n meta: ConfigMeta;\n };\n\n constructor({\n config,\n overrides,\n meta,\n opts,\n }: {\n config: Config;\n overrides?: OverridesConfig;\n meta: ConfigMeta;\n opts?: ValidationOptions;\n }) {\n // run validation on init\n MicrofrontendConfigIsomorphic.validate(config, opts);\n\n const disableOverrides = config.options?.vercel?.disableOverrides ?? false;\n this.overrides = overrides && !disableOverrides ? overrides : undefined;\n this.isMainConfig = isMainConfig(config);\n\n if (isMainConfig(config)) {\n // create applications\n for (const [appId, appConfig] of Object.entries(config.applications)) {\n const appOverrides = !disableOverrides\n ? this.overrides?.applications[appId]\n : undefined;\n\n if (isDefaultApp(appConfig)) {\n this.defaultApplication = new DefaultApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n } else {\n this.childApplications[appId] = new ChildApplication(appId, {\n app: appConfig,\n overrides: appOverrides,\n });\n }\n }\n } else {\n this.partOf = config.partOf;\n const appOverrides = !disableOverrides\n ? this.overrides?.applications[meta.fromApp]\n : undefined;\n this.childApplications[meta.fromApp] = new ChildApplication(\n meta.fromApp,\n {\n // we don't know routing because we're not in the main config\n app: { routing: [] },\n overrides: appOverrides,\n },\n );\n }\n\n // the main configuration file should ALWAYS have the default\n if (isMainConfig(config) && !this.defaultApplication) {\n throw new MicrofrontendError(\n 'Could not find default application in microfrontends configuration',\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n this.config = config;\n this.options = config.options;\n this.serialized = {\n config,\n overrides,\n meta,\n };\n }\n\n static validate(config: string | Config, opts?: ValidationOptions): Config {\n const skipValidation: ValidationOptions['skipValidation'] =\n opts?.skipValidation ?? [];\n // let this throw if it's not valid JSON\n const c = typeof config === 'string' ? (parse(config) as Config) : config;\n\n if (isMainConfig(c)) {\n if (!skipValidation.includes('paths')) {\n validateConfigPaths(c.applications);\n }\n if (!skipValidation.includes('defaultApplication')) {\n validateConfigDefaultApplication(c.applications);\n }\n }\n\n return c;\n }\n\n static fromEnv({\n meta,\n cookies,\n }: {\n meta: ConfigMeta;\n cookies?: { name: string; value: string }[];\n }): MicrofrontendConfigIsomorphic {\n return new MicrofrontendConfigIsomorphic({\n config: parse(getConfigStringFromEnv()) as Config,\n overrides: parseOverrides(cookies ?? []),\n meta,\n });\n }\n\n isOverridesDisabled(): boolean {\n return this.options?.vercel?.disableOverrides ?? false;\n }\n\n getConfig(): Config {\n return this.config;\n }\n\n getApplicationsByType(): {\n defaultApplication?: DefaultApplication;\n applications: ChildApplication[];\n } {\n return {\n defaultApplication: this.defaultApplication,\n applications: Object.values(this.childApplications),\n };\n }\n\n getChildApplications(): ChildApplication[] {\n return Object.values(this.childApplications);\n }\n\n getAllApplications(): (DefaultApplication | ChildApplication)[] {\n return [\n this.defaultApplication,\n ...Object.values(this.childApplications),\n ].filter(Boolean) as (DefaultApplication | ChildApplication)[];\n }\n\n getApplication(name: string): DefaultApplication | ChildApplication {\n // check the default\n if (this.defaultApplication?.name === name) {\n return this.defaultApplication;\n }\n const app = this.childApplications[name];\n if (!app) {\n throw new MicrofrontendError(\n `Could not find microfrontends configuration for application \"${name}\"`,\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n return app;\n }\n\n getApplicationByProjectId(\n projectId: string,\n ): DefaultApplication | ChildApplication | undefined {\n // check the default\n if (this.defaultApplication?.projectId === projectId) {\n return this.defaultApplication;\n }\n\n return Object.values(this.childApplications).find(\n (app) => app.projectId === projectId,\n );\n }\n\n /**\n * Returns the default application. This can throw if the default application\n * is undefined ( )\n */\n getDefaultApplication(): DefaultApplication {\n if (!this.defaultApplication) {\n throw new MicrofrontendError(\n 'Could not find default application in microfrontends configuration',\n {\n type: 'application',\n subtype: 'not_found',\n },\n );\n }\n\n return this.defaultApplication;\n }\n\n /**\n * Returns the configured port for the local proxy\n */\n getLocalProxyPort(): number {\n return (\n this.config.options?.localProxyPort ??\n this.config.options?.localProxy?.port ??\n DEFAULT_LOCAL_PROXY_PORT\n );\n }\n\n /**\n * Serializes the class back to the Schema type.\n *\n * NOTE: This is used when writing the config to disk and must always match the input Schema\n */\n toSchemaJson(): Config {\n return this.serialized.config;\n }\n\n toClientConfig(): MicrofrontendConfigClient {\n const applications: ClientConfig['applications'] = Object.fromEntries(\n Object.entries(this.childApplications).map(([name, application]) => [\n name,\n {\n default: false,\n routing: application.routing,\n },\n ]),\n );\n\n // add the default application\n if (this.defaultApplication) {\n applications[this.defaultApplication.name] = {\n default: true,\n };\n }\n\n return new MicrofrontendConfigClient({\n applications,\n });\n }\n\n serialize(): {\n config: Config;\n overrides?: OverridesConfig;\n meta: ConfigMeta;\n } {\n return this.serialized;\n }\n}\n","export type MicrofrontendErrorType =\n | 'config'\n | 'packageJson'\n | 'vercelJson'\n | 'application'\n | 'unknown';\n\nexport type MicrofrontendErrorSubtype =\n | 'not_found'\n | 'inference_failed'\n | 'not_found_in_env'\n | 'invalid_asset_prefix'\n | 'invalid_main_path'\n | 'does_not_match_schema'\n | 'unable_to_read_file'\n | 'unsupported_validation_env'\n | 'unsupported_version'\n | 'invalid_path'\n | 'invalid_permissions'\n | 'invalid_syntax'\n | 'missing_microfrontend_config_path'\n | 'unsupported_operation';\n\n// A mapping of error types to their subtypes.\ninterface TypeToSubtype {\n application:\n | 'invalid_asset_prefix'\n | 'invalid_path'\n | 'multiple_package_managers'\n | 'not_found';\n config:\n | 'conflicting_paths'\n | 'does_not_match_schema'\n | 'invalid_main_path'\n | 'invalid_preview_deployment_suffix'\n | 'multiple_default_applications'\n | 'no_default_application'\n | 'not_found_in_env'\n | 'not_found'\n | 'inference_failed'\n | 'unable_to_read_file'\n | 'invalid_syntax'\n | 'invalid_permissions'\n | 'unsupported_operation'\n | 'unsupported_validation_env'\n | 'unsupported_version';\n packageJson:\n | 'missing_field_name'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n vercelJson:\n | 'missing_field_microfrontend_config_path'\n | 'unable_to_read_file'\n | 'invalid_permissions'\n | 'invalid_syntax';\n unknown: never;\n}\n\nexport type MicrofrontendErrorSource =\n | '@vercel/microfrontends'\n | '@vercel/microfrontends/next'\n | 'fs'\n | 'ajv';\n\nexport interface MicrofrontendErrorOptions<T extends MicrofrontendErrorType> {\n cause?: unknown;\n source?: MicrofrontendErrorSource;\n type?: T;\n subtype?: TypeToSubtype[T];\n}\n\ninterface HandleOptions {\n fileName?: string;\n}\n\nexport class MicrofrontendError<\n T extends MicrofrontendErrorType = 'unknown',\n> extends Error {\n public source: MicrofrontendErrorSource;\n public type: T;\n public subtype?: TypeToSubtype[T];\n\n constructor(message: string, opts?: MicrofrontendErrorOptions<T>) {\n super(message, { cause: opts?.cause });\n this.name = 'MicrofrontendsError';\n this.source = opts?.source ?? '@vercel/microfrontends';\n this.type = opts?.type ?? ('unknown' as T);\n this.subtype = opts?.subtype;\n Error.captureStackTrace(this, MicrofrontendError);\n }\n\n isKnown(): boolean {\n return this.type !== 'unknown';\n }\n\n isUnknown(): boolean {\n return !this.isKnown();\n }\n\n /**\n * Converts an error to a MicrofrontendsError.\n * @param original - The original error to convert.\n * @returns The converted MicrofrontendsError.\n */\n static convert(\n original: Error,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (opts?.fileName) {\n const err = MicrofrontendError.convertFSError(original, opts.fileName);\n if (err) {\n return err;\n }\n }\n\n if (\n original.message.includes(\n 'Code generation from strings disallowed for this context',\n )\n ) {\n return new MicrofrontendError(original.message, {\n type: 'config',\n subtype: 'unsupported_validation_env',\n source: 'ajv',\n });\n }\n\n // unknown catch-all\n return new MicrofrontendError(original.message);\n }\n\n static convertFSError(\n original: Error,\n fileName: string,\n ): MicrofrontendError<MicrofrontendErrorType> | null {\n if (original instanceof Error && 'code' in original) {\n if (original.code === 'ENOENT') {\n return new MicrofrontendError(`Could not find \"${fileName}\"`, {\n type: 'config',\n subtype: 'unable_to_read_file',\n source: 'fs',\n });\n }\n if (original.code === 'EACCES') {\n return new MicrofrontendError(\n `Permission denied while accessing \"${fileName}\"`,\n {\n type: 'config',\n subtype: 'invalid_permissions',\n source: 'fs',\n },\n );\n }\n }\n\n if (original instanceof SyntaxError) {\n return new MicrofrontendError(\n `Failed to parse \"${fileName}\": Invalid JSON format.`,\n {\n type: 'config',\n subtype: 'invalid_syntax',\n source: 'fs',\n },\n );\n }\n\n return null;\n }\n\n /**\n * Handles an unknown error and returns a MicrofrontendsError instance.\n * @param err - The error to handle.\n * @returns A MicrofrontendsError instance.\n */\n static handle(\n err: unknown,\n opts?: HandleOptions,\n ): MicrofrontendError<MicrofrontendErrorType> {\n if (err instanceof MicrofrontendError) {\n return err as MicrofrontendError<MicrofrontendErrorType>;\n }\n\n // handle Error instances\n if (err instanceof Error) {\n return MicrofrontendError.convert(err, opts);\n }\n\n // handle object errors\n if (typeof err === 'object' && err !== null) {\n if ('message' in err && typeof err.message === 'string') {\n return MicrofrontendError.convert(new Error(err.message), opts);\n }\n }\n\n return new MicrofrontendError('An unknown error occurred');\n }\n}\n","import { MicrofrontendError } from '../../errors';\n\n/**\n * Utility to fetch the microfrontend configuration string from the environment.\n */\nexport function getConfigStringFromEnv(): string {\n const config = process.env.MFE_CONFIG;\n if (!config) {\n throw new MicrofrontendError(`Missing \"MFE_CONFIG\" in environment.`, {\n type: 'config',\n subtype: 'not_found_in_env',\n });\n }\n return config;\n}\n","import type { Config, MainConfig } from '../types';\n\nexport function isMainConfig(c: Config): c is MainConfig {\n return !('partOf' in c);\n}\n","import type { Application, DefaultApplication } from '../types';\n\nexport function isDefaultApp(a: Application): a is DefaultApplication {\n return !('routing' in a);\n}\n","import { pathToRegexp } from 'path-to-regexp';\nimport type { ClientConfig } from './types';\n\ninterface MicrofrontendConfigClientOptions {\n removeFlaggedPaths?: boolean;\n}\n\nexport class MicrofrontendConfigClient {\n applications: ClientConfig['applications'];\n pathCache: Record<string, string> = {};\n private readonly serialized: ClientConfig;\n\n constructor(config: ClientConfig, opts?: MicrofrontendConfigClientOptions) {\n this.serialized = config;\n if (opts?.removeFlaggedPaths) {\n for (const app of Object.values(config.applications)) {\n if (app.routing) {\n app.routing = app.routing.filter((match) => !match.flag);\n }\n }\n }\n this.applications = config.applications;\n }\n\n /**\n * Create a new `MicrofrontendConfigClient` from a JSON string.\n * Config must be passed in to remain framework agnostic\n */\n static fromEnv(\n config: string | undefined,\n opts?: MicrofrontendConfigClientOptions,\n ): MicrofrontendConfigClient {\n if (!config) {\n throw new Error('No microfrontends configuration found');\n }\n return new MicrofrontendConfigClient(\n JSON.parse(config) as ClientConfig,\n opts,\n );\n }\n\n isEqual(other: MicrofrontendConfigClient): boolean {\n return (\n JSON.stringify(this.applications) === JSON.stringify(other.applications)\n );\n }\n\n getApplicationNameForPath(path: string): string | null {\n if (!path.startsWith('/')) {\n throw new Error(`Path must start with a /`);\n }\n\n if (this.pathCache[path]) {\n return this.pathCache[path];\n }\n\n const pathname = new URL(path, 'https://example.com').pathname;\n for (const [name, application] of Object.entries(this.applications)) {\n if (application.routing) {\n for (const group of application.routing) {\n for (const childPath of group.paths) {\n const regexp = pathToRegexp(childPath);\n if (regexp.test(pathname)) {\n this.pathCache[path] = name;\n return name;\n }\n }\n }\n }\n }\n const defaultApplication = Object.entries(this.applications).find(\n ([, application]) => application.default,\n );\n if (!defaultApplication) {\n return null;\n }\n\n this.pathCache[path] = defaultApplication[0];\n return defaultApplication[0];\n }\n\n serialize(): ClientConfig {\n return this.serialized;\n }\n}\n","// cookie name needs to match proxy\n// https://github.com/vercel/proxy/blob/fb00d723136ad539a194e4a851dd272010527c35/lib/routing/micro_frontends_overrides.lua#L7\nexport const OVERRIDES_COOKIE_PREFIX = 'vercel-micro-frontends-override';\nexport const OVERRIDES_ENV_COOKIE_PREFIX = `${OVERRIDES_COOKIE_PREFIX}:env:`;\n","import { OVERRIDES_COOKIE_PREFIX } from './constants';\n\nexport function isOverrideCookie(cookie: { name?: string }): boolean {\n return Boolean(cookie.name?.startsWith(OVERRIDES_COOKIE_PREFIX));\n}\n","import { isOverrideCookie } from './is-override-cookie';\nimport { OVERRIDES_ENV_COOKIE_PREFIX } from './constants';\n\nexport function getOverrideFromCookie(cookie: {\n name: string;\n value?: string | null;\n}): { application: string; host: string } | undefined {\n if (!isOverrideCookie(cookie) || !cookie.value) return;\n return {\n application: cookie.name.replace(OVERRIDES_ENV_COOKIE_PREFIX, ''),\n host: cookie.value,\n };\n}\n","import type { OverridesConfig } from './types';\nimport { getOverrideFromCookie } from './get-override-from-cookie';\n\nexport function parseOverrides(\n cookies: { name: string; value?: string | null }[],\n): OverridesConfig {\n const overridesConfig: OverridesConfig = { applications: {} };\n\n cookies.forEach((cookie) => {\n const override = getOverrideFromCookie(cookie);\n if (!override) return;\n overridesConfig.applications[override.application] = {\n environment: { host: override.host },\n };\n });\n\n return overridesConfig;\n}\n","import { pathToRegexp, parse as parsePathRegexp } from 'path-to-regexp';\nimport type {\n ApplicationId,\n PathGroup,\n ApplicationRouting,\n ChildApplication as ChildApplicationConfig,\n} from '../../schema/types';\nimport { MicrofrontendError } from '../../errors';\nimport { isDefaultApp } from '../../schema/utils/is-default-app';\n\n/**\n * Validate all paths in a configuration - ensures paths do not overlap\n */\nexport const validateConfigPaths = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n const pathsByApplicationId = new Map<\n PathGroup['paths'][number],\n {\n applications: ApplicationId[];\n matcher: RegExp;\n applicationId?: ApplicationId;\n }\n >();\n const errors: string[] = [];\n\n for (const [id, app] of Object.entries(applicationConfigsById)) {\n if (isDefaultApp(app)) {\n // default applications do not have routing\n continue;\n }\n // TODO: remove this once DefaultApplication.development is required (after the migration)\n const childApp = app as ChildApplicationConfig;\n\n for (const pathMatch of childApp.routing) {\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 for (const [path, { applications: ids, matcher, applicationId }] of entries) {\n if (ids.length > 1) {\n errors.push(\n `Duplicate path \"${path}\" for applications \"${ids.join(', ')}\"`,\n );\n }\n\n for (const [\n matchPath,\n { applications: matchIds, applicationId: matchApplicationId },\n ] of entries) {\n if (path === matchPath) {\n // we're comparing to ourselves, so skip\n continue;\n }\n\n if (applicationId === matchApplicationId) {\n // we're comparing to paths within our own application, which are allowed to overlap, so skip\n continue;\n }\n\n if (matcher.test(matchPath)) {\n const source = `\"${path}\" of application${ids.length > 0 ? 's' : ''} ${ids.join(', ')}`;\n const destination = `\"${matchPath}\" of application${matchIds.length > 0 ? 's' : ''} ${matchIds.join(', ')}`;\n\n errors.push(\n `Overlapping path detected between ${source} and ${destination}`,\n );\n }\n }\n }\n\n if (errors.length) {\n throw new MicrofrontendError(`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\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/**\n * Validate all paths in an application - ensures paths are the correct format\n */\nexport const validateAppPaths = (\n name: string,\n app: ChildApplicationConfig,\n): void => {\n // validate routes\n for (const group of app.routing) {\n for (const p of group.paths) {\n if (p === '/') {\n continue;\n }\n if (p.endsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must not end with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n\n if (!p.startsWith('/')) {\n throw new MicrofrontendError(\n `Invalid path for application \"${name}\". ${p} must start with a slash.`,\n { type: 'application', subtype: 'invalid_path' },\n );\n }\n }\n }\n};\n\n/**\n * Make sure only one `Application` defines routing\n * */\nexport const validateConfigDefaultApplication = (\n applicationConfigsById?: ApplicationRouting,\n): void => {\n if (!applicationConfigsById) {\n return;\n }\n\n // find all applications that have routing\n const applicationsWithRouting = Object.entries(applicationConfigsById).filter(\n ([, app]) => !isDefaultApp(app),\n );\n // get all the application names\n const applicationsWithRoutingNames = applicationsWithRouting.map(\n ([key]) => key,\n );\n const numApplications = Object.keys(applicationConfigsById).length;\n const numApplicationsWithRouting = applicationsWithRoutingNames.length;\n const numApplicationsWithoutRouting =\n numApplications - numApplicationsWithRouting;\n\n if (numApplicationsWithoutRouting === 0) {\n throw new MicrofrontendError(\n 'No default application found. At least one application needs to be the default by omitting routing.',\n { type: 'config', subtype: 'no_default_application' },\n );\n }\n\n if (numApplicationsWithoutRouting > 1) {\n throw new MicrofrontendError(\n `Only one application can omit \"routing\". Found ${applicationsWithRoutingNames.length - Object.keys(applicationConfigsById).length > 1}.`,\n { type: 'config', subtype: 'multiple_default_applications' },\n );\n }\n};\n","const PREFIX = 'vc-ap';\n\nexport function generateAssetPrefixFromName({\n name,\n}: {\n name: string;\n}): string {\n if (!name) {\n throw new Error('Name is required to generate an asset prefix');\n }\n\n return `${PREFIX}-${name}`;\n}\n","export function generatePortFromName({\n name,\n minPort = 3000,\n maxPort = 8000,\n}: {\n name: string;\n minPort?: number;\n maxPort?: number;\n}): number {\n if (!name) {\n throw new Error('Name is required to generate a port');\n }\n\n // hash the name\n let hash = 0;\n for (let i = 0; i < name.length; i++) {\n // eslint-disable-next-line no-bitwise\n hash = (hash << 5) - hash + name.charCodeAt(i);\n // Convert to 32-bit\n // eslint-disable-next-line no-bitwise\n hash |= 0;\n }\n hash = Math.abs(hash);\n\n // Map the hash to the port range\n const range = maxPort - minPort;\n const port = minPort + (hash % range);\n\n return port;\n}\n","import type {\n HostConfig as RemoteHostConfigSchema,\n LocalHostConfig as LocalHostConfigSchema,\n} from '../../schema/types';\nimport { generatePortFromName } from './utils/generate-port';\n\ninterface HostOptions {\n isLocal?: boolean;\n}\n\nexport class Host {\n protocol: 'http' | 'https';\n host: string;\n port?: number;\n local: boolean | undefined;\n\n constructor(\n hostConfig: RemoteHostConfigSchema | string,\n options?: HostOptions,\n ) {\n if (typeof hostConfig === 'string') {\n ({\n protocol: this.protocol,\n host: this.host,\n port: this.port,\n } = Host.parseUrl(hostConfig));\n } else {\n const { protocol = 'https', host, port } = hostConfig;\n this.protocol = protocol;\n this.host = host;\n this.port = port;\n }\n this.local = options?.isLocal;\n }\n\n private static parseUrl(url: string): {\n protocol: Host['protocol'];\n host: string;\n port?: number;\n } {\n let hostToParse = url;\n if (!/^https?:\\/\\//.exec(hostToParse)) {\n hostToParse = `https://${hostToParse}`;\n }\n const parsed = new URL(hostToParse);\n if (!parsed.hostname) {\n throw new Error(Host.getMicrofrontendsError(url, 'requires a host'));\n }\n if (parsed.hash) {\n throw new Error(\n Host.getMicrofrontendsError(url, 'cannot have a fragment'),\n );\n }\n if (parsed.username || parsed.password) {\n throw new Error(\n Host.getMicrofrontendsError(\n url,\n 'cannot have authentication credentials (username and/or password)',\n ),\n );\n }\n if (parsed.pathname !== '/') {\n throw new Error(Host.getMicrofrontendsError(url, 'cannot have a path'));\n }\n if (parsed.search) {\n throw new Error(\n Host.getMicrofrontendsError(url, 'cannot have query parameters'),\n );\n }\n const protocol = parsed.protocol.slice(0, -1) as Host['protocol'];\n return {\n protocol,\n host: parsed.hostname,\n port: parsed.port ? Number.parseInt(parsed.port) : undefined,\n };\n }\n\n private static getMicrofrontendsError(url: string, message: string): string {\n return `Microfrontends configuration error: the URL ${url} in your microfrontends.json ${message}.`;\n }\n\n isLocal(): boolean {\n return this.local || this.host === 'localhost' || this.host === '127.0.0.1';\n }\n\n toString(): string {\n const url = this.toUrl();\n // strip the trailing slash\n return url.toString().replace(/\\/$/, '');\n }\n\n toUrl(): URL {\n const url = `${this.protocol}://${this.host}${this.port ? `:${this.port}` : ''}`;\n return new URL(url);\n }\n}\n\n/**\n * A Host subclass with defaults for locally running applications\n */\nexport class LocalHost extends Host {\n constructor({\n appName,\n localPort,\n ...hostConfig\n }: LocalHostConfigSchema & { appName: string; localPort?: number }) {\n // set defaults for local\n const host = hostConfig.host ?? 'localhost';\n const port =\n localPort ?? hostConfig.port ?? generatePortFromName({ name: appName });\n const protocol = hostConfig.protocol ?? 'http';\n\n super({ protocol, host, port });\n }\n}\n","import type {\n Application as ApplicationConfig,\n DefaultApplication as DefaultApplicationConfig,\n ChildApplication as ChildApplicationConfig,\n PathGroup,\n} from '../../schema/types';\nimport type { ApplicationOverrideConfig } from '../../overrides';\nimport { validateAppPaths } from './validation';\nimport { generateAssetPrefixFromName } from './utils/generate-asset-prefix';\nimport { Host, LocalHost } from './host';\n\nexport class Application {\n readonly default: boolean;\n name: string;\n development: {\n local: LocalHost;\n fallback?: Host;\n };\n fallback?: Host;\n projectId?: string;\n overrides?: {\n environment?: Host;\n };\n readonly serialized: ApplicationConfig;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n isDefault,\n }: {\n app: ApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n isDefault?: boolean;\n },\n ) {\n this.name = name;\n this.development = {\n local: new LocalHost({\n appName: name,\n localPort: app.development?.localPort,\n ...app.development?.local,\n }),\n fallback: app.development?.fallback\n ? new Host(app.development.fallback)\n : undefined,\n };\n if (app.development?.fallback) {\n this.fallback = new Host(app.development.fallback);\n } else if (app.production) {\n this.fallback = new Host(app.production);\n }\n this.projectId = app.projectId ?? app.vercel?.projectId;\n this.overrides = overrides?.environment\n ? {\n environment: new Host(overrides.environment),\n }\n : undefined;\n this.default = isDefault ?? false;\n this.serialized = app;\n }\n\n isDefault(): boolean {\n return this.default;\n }\n\n getAssetPrefix(): string {\n return generateAssetPrefixFromName({ name: this.name });\n }\n\n serialize(): ApplicationConfig {\n return this.serialized;\n }\n}\n\nexport class DefaultApplication extends Application {\n readonly default = true;\n // TODO: remove this once the config simplification migration is complete.\n /** @deprecated use fallback instead. */\n production?: Host;\n fallback: Host;\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: DefaultApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n super(name, {\n app,\n overrides,\n isDefault: true,\n });\n\n const fallbackHost = app.development?.fallback ?? app.production;\n if (fallbackHost === undefined) {\n // TODO: remove this one app.developement.fallback is required after the migration.\n throw new Error(\n '`app.production` or `app.development.fallback` must be set in the default application in microfrontends.json.',\n );\n }\n this.fallback = new Host(fallbackHost);\n if (app.production) {\n this.production = new Host(app.production);\n }\n }\n\n getAssetPrefix(): string {\n return '';\n }\n}\n\nexport class ChildApplication extends Application {\n readonly default = false;\n routing: PathGroup[];\n\n constructor(\n name: string,\n {\n app,\n overrides,\n }: {\n app: ChildApplicationConfig;\n overrides?: ApplicationOverrideConfig;\n },\n ) {\n // validate\n ChildApplication.validate(name, app);\n\n super(name, {\n app,\n overrides,\n isDefault: false,\n });\n\n this.routing = app.routing;\n }\n\n static validate(name: string, app: ChildApplicationConfig): void {\n // validate routes\n validateAppPaths(name, app);\n }\n}\n","export const DEFAULT_LOCAL_PROXY_PORT = 3024;\n","/// <reference types=\"@edge-runtime/types\" />\n\nimport type { Application } from '../config/microfrontends-config/isomorphic/application';\nimport type { VercelRelatedProject } from './types';\n\n/**\n * Gets the domain for a related project from the environment.\n *\n * This is used for preview, and production, and requires project linking in Vercel\n */\nexport function getDomainFromEnvironment({\n app,\n target,\n}: {\n app: Application;\n target: 'production' | 'preview';\n}): string {\n const mfeProjects = JSON.parse(\n process.env.VERCEL_MICROFRONTENDS_PROJECTS ?? '[]',\n ) as VercelRelatedProject[];\n\n if (mfeProjects.length === 0) {\n throw new Error('Missing related microfrontends project information');\n }\n\n if (!app.projectId) {\n throw new Error(`Missing applications[${app.name}].vercel.projectId`);\n }\n\n const vercelProject = mfeProjects.find((p) => p.project.id === app.projectId);\n\n if (!vercelProject) {\n throw new Error(\n `Missing related microfrontends project information for application \"${app.name}\"`,\n );\n }\n\n const domain =\n target === 'preview' && vercelProject.preview.branch\n ? vercelProject.preview.branch\n : (vercelProject.production.alias ?? vercelProject.production.url);\n\n if (!domain) {\n throw new Error(\n `Missing domain for target \"${target}\" in application \"${app.name}\"`,\n );\n }\n\n return domain.startsWith('https://') ? domain : `https://${domain}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA6B;AAC7B,oBAIO;AACP,IAAAA,yBAAsB;AACtB,IAAAC,uBAAsB;AACtB,iCAAyB;AACzB,qBAAgC;AAChC,iBAA+B;;;ACV/B,0BAAsB;;;AC4Ef,IAAM,qBAAN,cAEG,MAAM;AAAA,EAKd,YAA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