@backstage/core-compat-api 0.5.0-next.2 → 0.5.0-next.3

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @backstage/core-compat-api
2
2
 
3
+ ## 0.5.0-next.3
4
+
5
+ ### Patch Changes
6
+
7
+ - fda1bbc: The `compatWrapper` has been switched to use the new `SwappableComponentsApi` instead of the old `ComponentsApi` in its bridging to the old frontend system.
8
+ - Updated dependencies
9
+ - @backstage/frontend-plugin-api@0.11.0-next.2
10
+
3
11
  ## 0.5.0-next.2
4
12
 
5
13
  ### Minor Changes
@@ -1,7 +1,7 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { useMemo } from 'react';
3
3
  import { AppContextProvider } from '../core-app-api/src/app/AppContext.esm.js';
4
- import { useApi, appTreeApiRef, componentsApiRef, iconsApiRef, coreComponentRefs, routeResolutionApiRef, createFrontendPlugin } from '@backstage/frontend-plugin-api';
4
+ import { useApi, appTreeApiRef, iconsApiRef, NotFoundErrorPage, Progress, routeResolutionApiRef, ErrorDisplay, createFrontendPlugin } from '@backstage/frontend-plugin-api';
5
5
  import { getOrCreateGlobalSingleton, createVersionedContext, createVersionedValueMap } from '@backstage/version-bridge';
6
6
  import { convertLegacyRouteRef } from '../convertLegacyRouteRef.esm.js';
7
7
 
@@ -42,21 +42,11 @@ function toNewPlugin(plugin) {
42
42
  }
43
43
  function LegacyAppContextProvider(props) {
44
44
  const appTreeApi = useApi(appTreeApiRef);
45
- const componentsApi = useApi(componentsApiRef);
46
45
  const iconsApi = useApi(iconsApiRef);
47
46
  const appContext = useMemo(() => {
48
47
  const { tree } = appTreeApi.getTree();
49
48
  let gatheredPlugins = void 0;
50
- const ErrorBoundaryFallback = componentsApi.getComponent(
51
- coreComponentRefs.errorBoundaryFallback
52
- );
53
- const ErrorBoundaryFallbackWrapper = ({ plugin, ...rest }) => /* @__PURE__ */ jsx(
54
- ErrorBoundaryFallback,
55
- {
56
- ...rest,
57
- plugin: plugin && toNewPlugin(plugin)
58
- }
59
- );
49
+ const ErrorBoundaryFallbackWrapper = ({ plugin, ...rest }) => /* @__PURE__ */ jsx(ErrorDisplay, { ...rest, plugin: plugin && toNewPlugin(plugin) });
60
50
  return {
61
51
  getPlugins() {
62
52
  if (gatheredPlugins) {
@@ -82,15 +72,13 @@ function LegacyAppContextProvider(props) {
82
72
  },
83
73
  getComponents() {
84
74
  return {
85
- NotFoundErrorPage: componentsApi.getComponent(
86
- coreComponentRefs.notFoundErrorPage
87
- ),
75
+ NotFoundErrorPage,
88
76
  BootErrorPage() {
89
77
  throw new Error(
90
78
  "The BootErrorPage app component should not be accessed by plugins"
91
79
  );
92
80
  },
93
- Progress: componentsApi.getComponent(coreComponentRefs.progress),
81
+ Progress,
94
82
  Router() {
95
83
  throw new Error(
96
84
  "The Router app component should not be accessed by plugins"
@@ -100,7 +88,7 @@ function LegacyAppContextProvider(props) {
100
88
  };
101
89
  }
102
90
  };
103
- }, [appTreeApi, componentsApi, iconsApi]);
91
+ }, [appTreeApi, iconsApi]);
104
92
  return /* @__PURE__ */ jsx(AppContextProvider, { appContext, children: props.children });
105
93
  }
106
94
  const RoutingContext = createVersionedContext(
@@ -1 +1 @@
1
- {"version":3,"file":"BackwardsCompatProvider.esm.js","sources":["../../src/compatWrapper/BackwardsCompatProvider.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo } from 'react';\nimport { ReactNode } from 'react';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppContextProvider } from '../../../core-app-api/src/app/AppContext';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { RouteResolver } from '../../../core-plugin-api/src/routing/useRouteRef';\nimport {\n createFrontendPlugin as createNewPlugin,\n FrontendPlugin as NewFrontendPlugin,\n appTreeApiRef,\n componentsApiRef,\n coreComponentRefs,\n iconsApiRef,\n useApi,\n routeResolutionApiRef,\n} from '@backstage/frontend-plugin-api';\nimport {\n AppComponents,\n IconComponent,\n BackstagePlugin as LegacyBackstagePlugin,\n RouteRef,\n} from '@backstage/core-plugin-api';\nimport {\n VersionedValue,\n createVersionedContext,\n createVersionedValueMap,\n getOrCreateGlobalSingleton,\n} from '@backstage/version-bridge';\nimport { convertLegacyRouteRef } from '../convertLegacyRouteRef';\n\n// Make sure that we only convert each new plugin instance to its legacy equivalent once\nconst legacyPluginStore = getOrCreateGlobalSingleton(\n 'legacy-plugin-compatibility-store',\n () => new WeakMap<NewFrontendPlugin, LegacyBackstagePlugin>(),\n);\n\nexport function toLegacyPlugin(\n plugin: NewFrontendPlugin,\n): LegacyBackstagePlugin {\n let legacy = legacyPluginStore.get(plugin);\n if (legacy) {\n return legacy;\n }\n\n const errorMsg = 'Not implemented in legacy plugin compatibility layer';\n const notImplemented = () => {\n throw new Error(errorMsg);\n };\n\n legacy = {\n getId(): string {\n return plugin.id;\n },\n get routes() {\n return {};\n },\n get externalRoutes() {\n return {};\n },\n getApis: notImplemented,\n getFeatureFlags: notImplemented,\n provide: notImplemented,\n };\n\n legacyPluginStore.set(plugin, legacy);\n return legacy;\n}\n\n// TODO: Currently a very naive implementation, may need some more work\nfunction toNewPlugin(plugin: LegacyBackstagePlugin): NewFrontendPlugin {\n return createNewPlugin({\n pluginId: plugin.getId(),\n });\n}\n\n// Recreates the old AppContext APIs using the various new APIs that replaced it\nfunction LegacyAppContextProvider(props: { children: ReactNode }) {\n const appTreeApi = useApi(appTreeApiRef);\n const componentsApi = useApi(componentsApiRef);\n const iconsApi = useApi(iconsApiRef);\n\n const appContext = useMemo(() => {\n const { tree } = appTreeApi.getTree();\n\n let gatheredPlugins: LegacyBackstagePlugin[] | undefined = undefined;\n\n const ErrorBoundaryFallback = componentsApi.getComponent(\n coreComponentRefs.errorBoundaryFallback,\n );\n const ErrorBoundaryFallbackWrapper: AppComponents['ErrorBoundaryFallback'] =\n ({ plugin, ...rest }) => (\n <ErrorBoundaryFallback\n {...rest}\n plugin={plugin && toNewPlugin(plugin)}\n />\n );\n\n return {\n getPlugins(): LegacyBackstagePlugin[] {\n if (gatheredPlugins) {\n return gatheredPlugins;\n }\n\n const pluginSet = new Set<LegacyBackstagePlugin>();\n for (const node of tree.nodes.values()) {\n const plugin = node.spec.plugin;\n if (plugin) {\n pluginSet.add(toLegacyPlugin(plugin));\n }\n }\n gatheredPlugins = Array.from(pluginSet);\n\n return gatheredPlugins;\n },\n\n getSystemIcon(key: string): IconComponent | undefined {\n return iconsApi.getIcon(key);\n },\n\n getSystemIcons(): Record<string, IconComponent> {\n return Object.fromEntries(\n iconsApi.listIconKeys().map(key => [key, iconsApi.getIcon(key)!]),\n );\n },\n\n getComponents(): AppComponents {\n return {\n NotFoundErrorPage: componentsApi.getComponent(\n coreComponentRefs.notFoundErrorPage,\n ),\n BootErrorPage() {\n throw new Error(\n 'The BootErrorPage app component should not be accessed by plugins',\n );\n },\n Progress: componentsApi.getComponent(coreComponentRefs.progress),\n Router() {\n throw new Error(\n 'The Router app component should not be accessed by plugins',\n );\n },\n ErrorBoundaryFallback: ErrorBoundaryFallbackWrapper,\n };\n },\n };\n }, [appTreeApi, componentsApi, iconsApi]);\n\n return (\n <AppContextProvider appContext={appContext}>\n {props.children}\n </AppContextProvider>\n );\n}\n\nconst RoutingContext = createVersionedContext<{ 1: RouteResolver }>(\n 'routing-context',\n);\n\nfunction LegacyRoutingProvider(props: { children: ReactNode }) {\n const routeResolutionApi = useApi(routeResolutionApiRef);\n\n const value = useMemo<VersionedValue<{ 1: RouteResolver }>>(() => {\n return createVersionedValueMap({\n 1: {\n resolve(anyRouteRef, location) {\n const sourcePath =\n typeof location === 'string' ? location : location.pathname ?? '';\n\n return routeResolutionApi.resolve(\n // This removes the requirement to use convertLegacyRouteRef inside plugins, but\n // they still need to converted when passed to the plugin instance\n convertLegacyRouteRef(anyRouteRef as RouteRef),\n { sourcePath },\n );\n },\n },\n });\n }, [routeResolutionApi]);\n\n return (\n <RoutingContext.Provider value={value}>\n {props.children}\n </RoutingContext.Provider>\n );\n}\n\nexport function BackwardsCompatProvider(props: { children: ReactNode }) {\n return (\n <LegacyRoutingProvider>\n <LegacyAppContextProvider>{props.children}</LegacyAppContextProvider>\n </LegacyRoutingProvider>\n );\n}\n"],"names":["createNewPlugin"],"mappings":";;;;;;;AA+CA,MAAM,iBAAoB,GAAA,0BAAA;AAAA,EACxB,mCAAA;AAAA,EACA,0BAAU,OAAkD;AAC9D,CAAA;AAEO,SAAS,eACd,MACuB,EAAA;AACvB,EAAI,IAAA,MAAA,GAAS,iBAAkB,CAAA,GAAA,CAAI,MAAM,CAAA;AACzC,EAAA,IAAI,MAAQ,EAAA;AACV,IAAO,OAAA,MAAA;AAAA;AAGT,EAAA,MAAM,QAAW,GAAA,sDAAA;AACjB,EAAA,MAAM,iBAAiB,MAAM;AAC3B,IAAM,MAAA,IAAI,MAAM,QAAQ,CAAA;AAAA,GAC1B;AAEA,EAAS,MAAA,GAAA;AAAA,IACP,KAAgB,GAAA;AACd,MAAA,OAAO,MAAO,CAAA,EAAA;AAAA,KAChB;AAAA,IACA,IAAI,MAAS,GAAA;AACX,MAAA,OAAO,EAAC;AAAA,KACV;AAAA,IACA,IAAI,cAAiB,GAAA;AACnB,MAAA,OAAO,EAAC;AAAA,KACV;AAAA,IACA,OAAS,EAAA,cAAA;AAAA,IACT,eAAiB,EAAA,cAAA;AAAA,IACjB,OAAS,EAAA;AAAA,GACX;AAEA,EAAkB,iBAAA,CAAA,GAAA,CAAI,QAAQ,MAAM,CAAA;AACpC,EA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AAA,MAAM,aACJ,OAAO,QAAA,KAAa,QAAW,GAAA,QAAA,GAAW,SAAS,QAAY,IAAA,EAAA;AAEjE,UAAA,OAAO,kBAAmB,CAAA,OAAA;AAAA;AAAA;AAAA,YAGxB,sBAAsB,WAAuB,CAAA;AAAA,YAC7C,EAAE,UAAW;AAAA,WACf;AAAA;AACF;AACF,KACD,CAAA;AAAA,GACH,EAAG,CAAC,kBAAkB,CAAC,CAAA;AAEvB,EAAA,2BACG,cAAe,CAAA,QAAA,EAAf,EAAwB,KAAA,EACtB,gBAAM,QACT,EAAA,CAAA;AAEJ;AAEO,SAAS,wBAAwB,KAAgC,EAAA;AACtE,EAAA,2BACG,qBACC,EAAA,EAAA,QAAA,kBAAA,GAAA,CAAC,wBAA0B,EAAA,EAAA,QAAA,EAAA,KAAA,CAAM,UAAS,CAC5C,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"BackwardsCompatProvider.esm.js","sources":["../../src/compatWrapper/BackwardsCompatProvider.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useMemo } from 'react';\nimport { ReactNode } from 'react';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppContextProvider } from '../../../core-app-api/src/app/AppContext';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { RouteResolver } from '../../../core-plugin-api/src/routing/useRouteRef';\nimport {\n createFrontendPlugin as createNewPlugin,\n FrontendPlugin as NewFrontendPlugin,\n appTreeApiRef,\n iconsApiRef,\n useApi,\n routeResolutionApiRef,\n ErrorDisplay,\n NotFoundErrorPage,\n Progress,\n} from '@backstage/frontend-plugin-api';\nimport {\n AppComponents,\n IconComponent,\n BackstagePlugin as LegacyBackstagePlugin,\n RouteRef,\n} from '@backstage/core-plugin-api';\nimport {\n VersionedValue,\n createVersionedContext,\n createVersionedValueMap,\n getOrCreateGlobalSingleton,\n} from '@backstage/version-bridge';\nimport { convertLegacyRouteRef } from '../convertLegacyRouteRef';\n\n// Make sure that we only convert each new plugin instance to its legacy equivalent once\nconst legacyPluginStore = getOrCreateGlobalSingleton(\n 'legacy-plugin-compatibility-store',\n () => new WeakMap<NewFrontendPlugin, LegacyBackstagePlugin>(),\n);\n\nexport function toLegacyPlugin(\n plugin: NewFrontendPlugin,\n): LegacyBackstagePlugin {\n let legacy = legacyPluginStore.get(plugin);\n if (legacy) {\n return legacy;\n }\n\n const errorMsg = 'Not implemented in legacy plugin compatibility layer';\n const notImplemented = () => {\n throw new Error(errorMsg);\n };\n\n legacy = {\n getId(): string {\n return plugin.id;\n },\n get routes() {\n return {};\n },\n get externalRoutes() {\n return {};\n },\n getApis: notImplemented,\n getFeatureFlags: notImplemented,\n provide: notImplemented,\n };\n\n legacyPluginStore.set(plugin, legacy);\n return legacy;\n}\n\n// TODO: Currently a very naive implementation, may need some more work\nfunction toNewPlugin(plugin: LegacyBackstagePlugin): NewFrontendPlugin {\n return createNewPlugin({\n pluginId: plugin.getId(),\n });\n}\n\n// Recreates the old AppContext APIs using the various new APIs that replaced it\nfunction LegacyAppContextProvider(props: { children: ReactNode }) {\n const appTreeApi = useApi(appTreeApiRef);\n const iconsApi = useApi(iconsApiRef);\n\n const appContext = useMemo(() => {\n const { tree } = appTreeApi.getTree();\n\n let gatheredPlugins: LegacyBackstagePlugin[] | undefined = undefined;\n\n const ErrorBoundaryFallbackWrapper: AppComponents['ErrorBoundaryFallback'] =\n ({ plugin, ...rest }) => (\n <ErrorDisplay {...rest} plugin={plugin && toNewPlugin(plugin)} />\n );\n\n return {\n getPlugins(): LegacyBackstagePlugin[] {\n if (gatheredPlugins) {\n return gatheredPlugins;\n }\n\n const pluginSet = new Set<LegacyBackstagePlugin>();\n for (const node of tree.nodes.values()) {\n const plugin = node.spec.plugin;\n if (plugin) {\n pluginSet.add(toLegacyPlugin(plugin));\n }\n }\n gatheredPlugins = Array.from(pluginSet);\n\n return gatheredPlugins;\n },\n\n getSystemIcon(key: string): IconComponent | undefined {\n return iconsApi.getIcon(key);\n },\n\n getSystemIcons(): Record<string, IconComponent> {\n return Object.fromEntries(\n iconsApi.listIconKeys().map(key => [key, iconsApi.getIcon(key)!]),\n );\n },\n\n getComponents(): AppComponents {\n return {\n NotFoundErrorPage: NotFoundErrorPage,\n BootErrorPage() {\n throw new Error(\n 'The BootErrorPage app component should not be accessed by plugins',\n );\n },\n Progress: Progress,\n Router() {\n throw new Error(\n 'The Router app component should not be accessed by plugins',\n );\n },\n ErrorBoundaryFallback: ErrorBoundaryFallbackWrapper,\n };\n },\n };\n }, [appTreeApi, iconsApi]);\n\n return (\n <AppContextProvider appContext={appContext}>\n {props.children}\n </AppContextProvider>\n );\n}\n\nconst RoutingContext = createVersionedContext<{ 1: RouteResolver }>(\n 'routing-context',\n);\n\nfunction LegacyRoutingProvider(props: { children: ReactNode }) {\n const routeResolutionApi = useApi(routeResolutionApiRef);\n\n const value = useMemo<VersionedValue<{ 1: RouteResolver }>>(() => {\n return createVersionedValueMap({\n 1: {\n resolve(anyRouteRef, location) {\n const sourcePath =\n typeof location === 'string' ? location : location.pathname ?? '';\n\n return routeResolutionApi.resolve(\n // This removes the requirement to use convertLegacyRouteRef inside plugins, but\n // they still need to converted when passed to the plugin instance\n convertLegacyRouteRef(anyRouteRef as RouteRef),\n { sourcePath },\n );\n },\n },\n });\n }, [routeResolutionApi]);\n\n return (\n <RoutingContext.Provider value={value}>\n {props.children}\n </RoutingContext.Provider>\n );\n}\n\nexport function BackwardsCompatProvider(props: { children: ReactNode }) {\n return (\n <LegacyRoutingProvider>\n <LegacyAppContextProvider>{props.children}</Legac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AAA;AAAA,cACR;AAAA,aACF;AAAA,WACF;AAAA,UACA,qBAAuB,EAAA;AAAA,SACzB;AAAA;AACF,KACF;AAAA,GACC,EAAA,CAAC,UAAY,EAAA,QAAQ,CAAC,CAAA;AAEzB,EAAA,uBACG,GAAA,CAAA,kBAAA,EAAA,EAAmB,UACjB,EAAA,QAAA,EAAA,KAAA,CAAM,QACT,EAAA,CAAA;AAEJ;AAEA,MAAM,cAAiB,GAAA,sBAAA;AAAA,EACrB;AACF,CAAA;AAEA,SAAS,sBAAsB,KAAgC,EAAA;AAC7D,EAAM,MAAA,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AAEvD,EAAM,MAAA,KAAA,GAAQ,QAA8C,MAAM;AAChE,IAAA,OAAO,uBAAwB,CAAA;AAAA,MAC7B,CAAG,EAAA;AAAA,QACD,OAAA,CAAQ,aAAa,QAAU,EAAA;AAC7B,UAAA,MAAM,aACJ,OAAO,QAAA,KAAa,QAAW,GAAA,QAAA,GAAW,SAAS,QAAY,IAAA,EAAA;AAEjE,UAAA,OAAO,kBAAmB,CAAA,OAAA;AAAA;AAAA;AAAA,YAGxB,sBAAsB,WAAuB,CAAA;AAAA,YAC7C,EAAE,UAAW;AAAA,WACf;AAAA;AACF;AACF,KACD,CAAA;AAAA,GACH,EAAG,CAAC,kBAAkB,CAAC,CAAA;AAEvB,EAAA,2BACG,cAAe,CAAA,QAAA,EAAf,EAAwB,KAAA,EACtB,gBAAM,QACT,EAAA,CAAA;AAEJ;AAEO,SAAS,wBAAwB,KAAgC,EAAA;AACtE,EAAA,2BACG,qBACC,EAAA,EAAA,QAAA,kBAAA,GAAA,CAAC,wBAA0B,EAAA,EAAA,QAAA,EAAA,KAAA,CAAM,UAAS,CAC5C,EAAA,CAAA;AAEJ;;;;"}
@@ -1,6 +1,6 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { useApp } from '@backstage/core-plugin-api';
3
- import { componentsApiRef, iconsApiRef, routeResolutionApiRef, coreComponentRefs } from '@backstage/frontend-plugin-api';
3
+ import { swappableComponentsApiRef, iconsApiRef, routeResolutionApiRef, ErrorDisplay, NotFoundErrorPage, Progress } from '@backstage/frontend-plugin-api';
4
4
  import { useMemo } from 'react';
5
5
  import { toLegacyPlugin } from './BackwardsCompatProvider.esm.js';
6
6
  import { ApiProvider } from '../core-app-api/src/apis/system/ApiProvider.esm.js';
@@ -26,11 +26,11 @@ class CompatComponentsApi {
26
26
  }
27
27
  getComponent(ref) {
28
28
  switch (ref.id) {
29
- case coreComponentRefs.progress.id:
29
+ case Progress.ref.id:
30
30
  return this.#Progress;
31
- case coreComponentRefs.notFoundErrorPage.id:
31
+ case NotFoundErrorPage.ref.id:
32
32
  return this.#NotFoundErrorPage;
33
- case coreComponentRefs.errorBoundaryFallback.id:
33
+ case ErrorDisplay.ref.id:
34
34
  return this.#ErrorBoundaryFallback;
35
35
  default:
36
36
  throw new Error(
@@ -71,7 +71,7 @@ class ForwardsCompatApis {
71
71
  this.#routeResolutionApi = new CompatRouteResolutionApi(routeResolver);
72
72
  }
73
73
  get(ref) {
74
- if (ref.id === componentsApiRef.id) {
74
+ if (ref.id === swappableComponentsApiRef.id) {
75
75
  return this.#componentsApi;
76
76
  } else if (ref.id === iconsApiRef.id) {
77
77
  return this.#iconsApi;
@@ -1 +1 @@
1
- {"version":3,"file":"ForwardsCompatProvider.esm.js","sources":["../../src/compatWrapper/ForwardsCompatProvider.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiHolder,\n ApiRef,\n AppContext,\n useApp,\n} from '@backstage/core-plugin-api';\nimport {\n AnyRouteRefParams,\n ComponentRef,\n ComponentsApi,\n CoreErrorBoundaryFallbackProps,\n CoreNotFoundErrorPageProps,\n CoreProgressProps,\n ExternalRouteRef,\n IconComponent,\n IconsApi,\n RouteFunc,\n RouteRef,\n RouteResolutionApi,\n SubRouteRef,\n componentsApiRef,\n coreComponentRefs,\n iconsApiRef,\n routeResolutionApiRef,\n} from '@backstage/frontend-plugin-api';\nimport { ComponentType, useMemo } from 'react';\nimport { ReactNode } from 'react';\nimport { toLegacyPlugin } from './BackwardsCompatProvider';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiProvider } from '../../../core-app-api/src/apis/system/ApiProvider';\nimport { useVersionedContext } from '@backstage/version-bridge';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { type RouteResolver } from '../../../core-plugin-api/src/routing/useRouteRef';\nimport { convertLegacyRouteRef } from '../convertLegacyRouteRef';\n\nclass CompatComponentsApi implements ComponentsApi {\n readonly #Progress: ComponentType<CoreProgressProps>;\n readonly #NotFoundErrorPage: ComponentType<CoreNotFoundErrorPageProps>;\n readonly #ErrorBoundaryFallback: ComponentType<CoreErrorBoundaryFallbackProps>;\n\n constructor(app: AppContext) {\n const components = app.getComponents();\n const ErrorBoundaryFallback = (props: CoreErrorBoundaryFallbackProps) => (\n <components.ErrorBoundaryFallback\n {...props}\n plugin={props.plugin && toLegacyPlugin(props.plugin)}\n />\n );\n this.#Progress = components.Progress;\n this.#NotFoundErrorPage = components.NotFoundErrorPage;\n this.#ErrorBoundaryFallback = ErrorBoundaryFallback;\n }\n\n getComponent<T extends {}>(ref: ComponentRef<T>): ComponentType<T> {\n switch (ref.id) {\n case coreComponentRefs.progress.id:\n return this.#Progress as ComponentType<any>;\n case coreComponentRefs.notFoundErrorPage.id:\n return this.#NotFoundErrorPage as ComponentType<any>;\n case coreComponentRefs.errorBoundaryFallback.id:\n return this.#ErrorBoundaryFallback as ComponentType<any>;\n default:\n throw new Error(\n `No backwards compatible component is available for ref '${ref.id}'`,\n );\n }\n }\n}\n\nclass CompatIconsApi implements IconsApi {\n readonly #app: AppContext;\n\n constructor(app: AppContext) {\n this.#app = app;\n }\n\n getIcon(key: string): IconComponent | undefined {\n return this.#app.getSystemIcon(key);\n }\n\n listIconKeys(): string[] {\n return Object.keys(this.#app.getSystemIcons());\n }\n}\n\nclass CompatRouteResolutionApi implements RouteResolutionApi {\n readonly #routeResolver: RouteResolver;\n\n constructor(routeResolver: RouteResolver) {\n this.#routeResolver = routeResolver;\n }\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: { sourcePath?: string },\n ): RouteFunc<TParams> | undefined {\n const legacyRef = convertLegacyRouteRef(anyRouteRef as RouteRef<TParams>);\n return this.#routeResolver.resolve(legacyRef, options?.sourcePath ?? '/');\n }\n}\n\nclass ForwardsCompatApis implements ApiHolder {\n readonly #componentsApi: ComponentsApi;\n readonly #iconsApi: IconsApi;\n readonly #routeResolutionApi: RouteResolutionApi;\n\n constructor(app: AppContext, routeResolver: RouteResolver) {\n this.#componentsApi = new CompatComponentsApi(app);\n this.#iconsApi = new CompatIconsApi(app);\n this.#routeResolutionApi = new CompatRouteResolutionApi(routeResolver);\n }\n\n get<T>(ref: ApiRef<any>): T | undefined {\n if (ref.id === componentsApiRef.id) {\n return this.#componentsApi as T;\n } else if (ref.id === iconsApiRef.id) {\n return this.#iconsApi as T;\n } else if (ref.id === routeResolutionApiRef.id) {\n return this.#routeResolutionApi as T;\n }\n return undefined;\n }\n}\n\nfunction NewAppApisProvider(props: { children: ReactNode }) {\n const app = useApp();\n const versionedRouteResolverContext = useVersionedContext<{\n 1: RouteResolver;\n }>('routing-context');\n if (!versionedRouteResolverContext) {\n throw new Error('Routing context is not available');\n }\n const routeResolver = versionedRouteResolverContext.atVersion(1);\n if (!routeResolver) {\n throw new Error('RoutingContext v1 not available');\n }\n\n const appFallbackApis = useMemo(\n () => new ForwardsCompatApis(app, routeResolver),\n [app, routeResolver],\n );\n\n return <ApiProvider apis={appFallbackApis}>{props.children}</ApiProvider>;\n}\n\nexport function ForwardsCompatProvider(props: { children: ReactNode }) {\n return <NewAppApisProvider>{props.children}</NewAppApisProvider>;\n}\n"],"names":[],"mappings":";;;;;;;;;AAmDA,MAAM,mBAA6C,CAAA;AAAA,EACxC,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,sBAAA;AAAA,EAET,YAAY,GAAiB,EAAA;AAC3B,IAAM,MAAA,UAAA,GAAa,IAAI,aAAc,EAAA;AACrC,IAAM,MAAA,qBAAA,GAAwB,CAAC,KAC7B,qBAAA,GAAA;AAAA,MAAC,UAAW,CAAA,qBAAA;AAAA,MAAX;AAAA,QACE,GAAG,KAAA;AAAA,QACJ,MAAQ,EAAA,KAAA,CAAM,MAAU,IAAA,cAAA,CAAe,MAAM,MAAM;AAAA;AAAA,KACrD;AAEF,IAAA,IAAA,CAAK,YAAY,UAAW,CAAA,QAAA;AAC5B,IAAA,IAAA,CAAK,qBAAqB,UAAW,CAAA,iBAAA;AACrC,IAAA,IAAA,CAAK,sBAAyB,GAAA,qBAAA;AAAA;AAChC,EAEA,aAA2B,GAAwC,EAAA;AACjE,IAAA,QAAQ,IAAI,EAAI;AAAA,MACd,KAAK,kBAAkB,QAAS,CAAA,EAAA;AAC9B,QAAA,OAAO,IAAK,CAAA,SAAA;AAAA,MACd,KAAK,kBAAkB,iBAAkB,CAAA,EAAA;AACvC,QAAA,OAAO,IAAK,CAAA,kBAAA;AAAA,MACd,KAAK,kBAAkB,qBAAsB,CAAA,EAAA;AAC3C,QAAA,OAAO,IAAK,CAAA,sBAAA;AAAA,MACd;AACE,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,wDAAA,EAA2D,IAAI,EAAE,CAAA,CAAA;AAAA,SACnE;AAAA;AACJ;AAEJ;AAEA,MAAM,cAAmC,CAAA;AAAA,EAC9B,IAAA;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CAAI,EAAO,KAAA,qBAAA,CAAsB,EAAI,EAAA;AAC9C,MAAA,OAAO,IAAK,CAAA,mBAAA;AAAA;AAEd,IAAO,OAAA,KAAA,CAAA;AAAA;AAEX;AAEA,SAAS,mBAAmB,KAAgC,EAAA;AAC1D,EAAA,MAAM,MAAM,MAAO,EAAA;AACnB,EAAM,MAAA,6BAAA,GAAgC,oBAEnC,iBAAiB,CAAA;AACpB,EAAA,IAAI,CAAC,6BAA+B,EAAA;AAClC,IAAM,MAAA,IAAI,MAAM,kCAAkC,CAAA;AAAA;AAEpD,EAAM,MAAA,aAAA,GAAgB,6BAA8B,CAAA,SAAA,CAAU,CAAC,CAAA;AAC/D,EAAA,IAAI,CAAC,aAAe,EAAA;AAClB,IAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA;AAAA;AAGnD,EAAA,MAAM,eAAkB,GAAA,OAAA;AAAA,IACtB,MAAM,IAAI,kBAAmB,CAAA,GAAA,EAAK,aAAa,CAAA;AAAA,IAC/C,CAAC,KAAK,aAAa;AAAA,GACrB;AAEA,EAAA,uBAAQ,GAAA,CAAA,WAAA,EAAA,EAAY,IAAM,EAAA,eAAA,EAAkB,gBAAM,QAAS,EAAA,CAAA;AAC7D;AAEO,SAAS,uBAAuB,KAAgC,EAAA;AACrE,EAAO,uBAAA,GAAA,CAAC,kBAAoB,EAAA,EAAA,QAAA,EAAA,KAAA,CAAM,QAAS,EAAA,CAAA;AAC7C;;;;"}
1
+ {"version":3,"file":"ForwardsCompatProvider.esm.js","sources":["../../src/compatWrapper/ForwardsCompatProvider.tsx"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ApiHolder,\n ApiRef,\n AppContext,\n useApp,\n} from '@backstage/core-plugin-api';\nimport {\n AnyRouteRefParams,\n SwappableComponentRef,\n SwappableComponentsApi,\n ErrorDisplayProps,\n NotFoundErrorPageProps,\n ProgressProps,\n ExternalRouteRef,\n IconComponent,\n IconsApi,\n RouteFunc,\n RouteRef,\n RouteResolutionApi,\n SubRouteRef,\n swappableComponentsApiRef,\n iconsApiRef,\n routeResolutionApiRef,\n Progress,\n NotFoundErrorPage,\n ErrorDisplay,\n} from '@backstage/frontend-plugin-api';\nimport { ComponentType, useMemo } from 'react';\nimport { ReactNode } from 'react';\nimport { toLegacyPlugin } from './BackwardsCompatProvider';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiProvider } from '../../../core-app-api/src/apis/system/ApiProvider';\nimport { useVersionedContext } from '@backstage/version-bridge';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { type RouteResolver } from '../../../core-plugin-api/src/routing/useRouteRef';\nimport { convertLegacyRouteRef } from '../convertLegacyRouteRef';\n\nclass CompatComponentsApi implements SwappableComponentsApi {\n readonly #Progress: ComponentType<ProgressProps>;\n readonly #NotFoundErrorPage: ComponentType<NotFoundErrorPageProps>;\n readonly #ErrorBoundaryFallback: ComponentType<ErrorDisplayProps>;\n\n constructor(app: AppContext) {\n const components = app.getComponents();\n const ErrorBoundaryFallback = (props: ErrorDisplayProps) => (\n <components.ErrorBoundaryFallback\n {...props}\n plugin={props.plugin && toLegacyPlugin(props.plugin)}\n />\n );\n this.#Progress = components.Progress;\n this.#NotFoundErrorPage = components.NotFoundErrorPage;\n this.#ErrorBoundaryFallback = ErrorBoundaryFallback;\n }\n\n getComponent<\n TInnerComponentProps extends {},\n TExternalComponentProps extends {} = TInnerComponentProps,\n >(\n ref: SwappableComponentRef<TInnerComponentProps, TExternalComponentProps>,\n ): (props: TInnerComponentProps) => JSX.Element | null {\n switch (ref.id) {\n case Progress.ref.id:\n return this.#Progress as (props: object) => JSX.Element | null;\n case NotFoundErrorPage.ref.id:\n return this.#NotFoundErrorPage as (props: object) => JSX.Element | null;\n case ErrorDisplay.ref.id:\n return this.#ErrorBoundaryFallback as (\n props: object,\n ) => JSX.Element | null;\n default:\n throw new Error(\n `No backwards compatible component is available for ref '${ref.id}'`,\n );\n }\n }\n}\n\nclass CompatIconsApi implements IconsApi {\n readonly #app: AppContext;\n\n constructor(app: AppContext) {\n this.#app = app;\n }\n\n getIcon(key: string): IconComponent | undefined {\n return this.#app.getSystemIcon(key);\n }\n\n listIconKeys(): string[] {\n return Object.keys(this.#app.getSystemIcons());\n }\n}\n\nclass CompatRouteResolutionApi implements RouteResolutionApi {\n readonly #routeResolver: RouteResolver;\n\n constructor(routeResolver: RouteResolver) {\n this.#routeResolver = routeResolver;\n }\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: { sourcePath?: string },\n ): RouteFunc<TParams> | undefined {\n const legacyRef = convertLegacyRouteRef(anyRouteRef as RouteRef<TParams>);\n return this.#routeResolver.resolve(legacyRef, options?.sourcePath ?? '/');\n }\n}\n\nclass ForwardsCompatApis implements ApiHolder {\n readonly #componentsApi: SwappableComponentsApi;\n readonly #iconsApi: IconsApi;\n readonly #routeResolutionApi: RouteResolutionApi;\n\n constructor(app: AppContext, routeResolver: RouteResolver) {\n this.#componentsApi = new CompatComponentsApi(app);\n this.#iconsApi = new CompatIconsApi(app);\n this.#routeResolutionApi = new CompatRouteResolutionApi(routeResolver);\n }\n\n get<T>(ref: ApiRef<any>): T | undefined {\n if (ref.id === swappableComponentsApiRef.id) {\n return this.#componentsApi as T;\n } else if (ref.id === iconsApiRef.id) {\n return this.#iconsApi as T;\n } else if (ref.id === routeResolutionApiRef.id) {\n return this.#routeResolutionApi as T;\n }\n return undefined;\n }\n}\n\nfunction NewAppApisProvider(props: { children: ReactNode }) {\n const app = useApp();\n const versionedRouteResolverContext = useVersionedContext<{\n 1: RouteResolver;\n }>('routing-context');\n if (!versionedRouteResolverContext) {\n throw new Error('Routing context is not available');\n }\n const routeResolver = versionedRouteResolverContext.atVersion(1);\n if (!routeResolver) {\n throw new Error('RoutingContext v1 not available');\n }\n\n const appFallbackApis = useMemo(\n () => new ForwardsCompatApis(app, routeResolver),\n [app, routeResolver],\n );\n\n return <ApiProvider apis={appFallbackApis}>{props.children}</ApiProvider>;\n}\n\nexport function ForwardsCompatProvider(props: { children: ReactNode }) {\n return <NewAppApisProvider>{props.children}</NewAppApisProvider>;\n}\n"],"names":[],"mappings":";;;;;;;;;AAqDA,MAAM,mBAAsD,CAAA;AAAA,EACjD,SAAA;AAAA,EACA,kBAAA;AAAA,EACA,sBAAA;AAAA,EAET,YAAY,GAAiB,EAAA;AAC3B,IAAM,MAAA,UAAA,GAAa,IAAI,aAAc,EAAA;AACrC,IAAM,MAAA,qBAAA,GAAwB,CAAC,KAC7B,qBAAA,GAAA;AAAA,MAAC,UAAW,CAAA,qBAAA;AAAA,MAAX;AAAA,QACE,GAAG,KAAA;AAAA,QACJ,MAAQ,EAAA,KAAA,CAAM,MAAU,IAAA,cAAA,CAAe,MAAM,MAAM;AAAA;AAAA,KACrD;AAEF,IAAA,IAAA,CAAK,YAAY,UAAW,CAAA,QAAA;AAC5B,IAAA,IAAA,CAAK,qBAAqB,UAAW,CAAA,iBAAA;AACrC,IAAA,IAAA,CAAK,sBAAyB,GAAA,qBAAA;AAAA;AAChC,EAEA,aAIE,GACqD,EAAA;AACrD,IAAA,QAAQ,IAAI,EAAI;AAAA,MACd,KAAK,SAAS,GAAI,CAAA,EAAA;AAChB,QAAA,OAAO,IAAK,CAAA,SAAA;AAAA,MACd,KAAK,kBAAkB,GAAI,CAAA,EAAA;AACzB,QAAA,OAAO,IAAK,CAAA,kBAAA;AAAA,MACd,KAAK,aAAa,GAAI,CAAA,EAAA;AACpB,QAAA,OAAO,I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AA0B,EAAI,EAAA;AAC3C,MAAA,OAAO,IAAK,CAAA,cAAA;AAAA,KACH,MAAA,IAAA,GAAA,CAAI,EAAO,KAAA,WAAA,CAAY,EAAI,EAAA;AACpC,MAAA,OAAO,IAAK,CAAA,SAAA;AAAA,KACH,MAAA,IAAA,GAAA,CAAI,EAAO,KAAA,qBAAA,CAAsB,EAAI,EAAA;AAC9C,MAAA,OAAO,IAAK,CAAA,mBAAA;AAAA;AAEd,IAAO,OAAA,KAAA,CAAA;AAAA;AAEX;AAEA,SAAS,mBAAmB,KAAgC,EAAA;AAC1D,EAAA,MAAM,MAAM,MAAO,EAAA;AACnB,EAAM,MAAA,6BAAA,GAAgC,oBAEnC,iBAAiB,CAAA;AACpB,EAAA,IAAI,CAAC,6BAA+B,EAAA;AAClC,IAAM,MAAA,IAAI,MAAM,kCAAkC,CAAA;AAAA;AAEpD,EAAM,MAAA,aAAA,GAAgB,6BAA8B,CAAA,SAAA,CAAU,CAAC,CAAA;AAC/D,EAAA,IAAI,CAAC,aAAe,EAAA;AAClB,IAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA;AAAA;AAGnD,EAAA,MAAM,eAAkB,GAAA,OAAA;AAAA,IACtB,MAAM,IAAI,kBAAmB,CAAA,GAAA,EAAK,aAAa,CAAA;AAAA,IAC/C,CAAC,KAAK,aAAa;AAAA,GACrB;AAEA,EAAA,uBAAQ,GAAA,CAAA,WAAA,EAAA,EAAY,IAAM,EAAA,eAAA,EAAkB,gBAAM,QAAS,EAAA,CAAA;AAC7D;AAEO,SAAS,uBAAuB,KAAgC,EAAA;AACrE,EAAO,uBAAA,GAAA,CAAC,kBAAoB,EAAA,EAAA,QAAA,EAAA,KAAA,CAAM,QAAS,EAAA,CAAA;AAC7C;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { ApiBlueprint, IconBundleBlueprint, createExtension, ThemeBlueprint, RouterBlueprint, SignInPageBlueprint, createComponentExtension, coreComponentRefs, createFrontendModule } from '@backstage/frontend-plugin-api';
2
+ import { ApiBlueprint, IconBundleBlueprint, createExtension, ThemeBlueprint, RouterBlueprint, SignInPageBlueprint, SwappableComponentBlueprint, Progress, NotFoundErrorPage, ErrorDisplay, createFrontendModule } from '@backstage/frontend-plugin-api';
3
3
  import { toLegacyPlugin } from './compatWrapper/BackwardsCompatProvider.esm.js';
4
4
  import { compatWrapper } from './compatWrapper/compatWrapper.esm.js';
5
5
 
@@ -57,8 +57,8 @@ function convertLegacyAppOptions(options = {}) {
57
57
  const {
58
58
  BootErrorPage,
59
59
  ErrorBoundaryFallback,
60
- NotFoundErrorPage,
61
- Progress,
60
+ NotFoundErrorPage: NotFoundErrorPage$1,
61
+ Progress: Progress$1,
62
62
  Router,
63
63
  SignInPage,
64
64
  ThemeProvider
@@ -89,19 +89,23 @@ function convertLegacyAppOptions(options = {}) {
89
89
  })
90
90
  );
91
91
  }
92
- if (Progress) {
92
+ if (Progress$1) {
93
93
  extensions.push(
94
- createComponentExtension({
95
- ref: coreComponentRefs.progress,
96
- loader: { sync: () => componentCompatWrapper(Progress) }
94
+ SwappableComponentBlueprint.make({
95
+ params: (define) => define({
96
+ component: Progress,
97
+ loader: () => componentCompatWrapper(Progress$1)
98
+ })
97
99
  })
98
100
  );
99
101
  }
100
- if (NotFoundErrorPage) {
102
+ if (NotFoundErrorPage$1) {
101
103
  extensions.push(
102
- createComponentExtension({
103
- ref: coreComponentRefs.notFoundErrorPage,
104
- loader: { sync: () => componentCompatWrapper(NotFoundErrorPage) }
104
+ SwappableComponentBlueprint.make({
105
+ params: (define) => define({
106
+ component: NotFoundErrorPage,
107
+ loader: () => componentCompatWrapper(NotFoundErrorPage$1)
108
+ })
105
109
  })
106
110
  );
107
111
  }
@@ -116,11 +120,11 @@ function convertLegacyAppOptions(options = {}) {
116
120
  )
117
121
  );
118
122
  extensions.push(
119
- createComponentExtension({
120
- ref: coreComponentRefs.errorBoundaryFallback,
121
- loader: {
122
- sync: () => componentCompatWrapper(WrappedErrorBoundaryFallback)
123
- }
123
+ SwappableComponentBlueprint.make({
124
+ params: (define) => define({
125
+ component: ErrorDisplay,
126
+ loader: () => componentCompatWrapper(WrappedErrorBoundaryFallback)
127
+ })
124
128
  })
125
129
  );
126
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"convertLegacyAppOptions.esm.js","sources":["../src/convertLegacyAppOptions.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentType } from 'react';\nimport {\n ApiBlueprint,\n coreComponentRefs,\n CoreErrorBoundaryFallbackProps,\n createComponentExtension,\n createExtension,\n createFrontendModule,\n ExtensionDefinition,\n FrontendModule,\n IconBundleBlueprint,\n RouterBlueprint,\n SignInPageBlueprint,\n ThemeBlueprint,\n} from '@backstage/frontend-plugin-api';\nimport {\n AnyApiFactory,\n AppComponents,\n AppTheme,\n BackstagePlugin,\n FeatureFlag,\n IconComponent,\n} from '@backstage/core-plugin-api';\nimport { toLegacyPlugin } from './compatWrapper/BackwardsCompatProvider';\nimport { compatWrapper } from './compatWrapper';\n\nfunction componentCompatWrapper<TProps extends {}>(\n Component: ComponentType<TProps>,\n) {\n return (props: TProps) => compatWrapper(<Component {...props} />);\n}\n\n/**\n * @public\n */\nexport function convertLegacyAppOptions(\n options: {\n apis?: Iterable<AnyApiFactory>;\n\n icons?: { [key in string]: IconComponent };\n\n plugins?: Array<BackstagePlugin>;\n\n components?: Partial<AppComponents>;\n\n themes?: AppTheme[];\n\n featureFlags?: (FeatureFlag & Omit<FeatureFlag, 'pluginId'>)[];\n } = {},\n): FrontendModule {\n const { apis, icons, plugins, components, themes, featureFlags } = options;\n\n const allApis = [\n ...(plugins?.flatMap(plugin => [...plugin.getApis()]) ?? []),\n ...(apis ?? []),\n ];\n const deduplicatedApis = Array.from(\n new Map(allApis.map(api => [api.api.id, api])).values(),\n );\n const extensions: ExtensionDefinition[] = deduplicatedApis.map(factory =>\n ApiBlueprint.make({\n name: factory.api.id,\n params: defineParams => defineParams(factory),\n }),\n );\n\n if (icons) {\n extensions.push(\n IconBundleBlueprint.make({\n name: 'app-options',\n params: { icons },\n }),\n );\n }\n\n if (themes) {\n // IF any themes are provided we need to disable the default ones, unless they are overridden\n for (const id of ['light', 'dark']) {\n if (!themes.some(theme => theme.id === id)) {\n extensions.push(\n createExtension({\n kind: 'theme',\n name: id,\n attachTo: { id: 'api:app/app-theme', input: 'themes' },\n disabled: true,\n output: [],\n factory: () => [],\n }),\n );\n }\n }\n extensions.push(\n ...themes.map(theme =>\n ThemeBlueprint.make({\n name: theme.id,\n params: { theme },\n }),\n ),\n );\n }\n\n if (components) {\n const {\n BootErrorPage,\n ErrorBoundaryFallback,\n NotFoundErrorPage,\n Progress,\n Router,\n SignInPage,\n ThemeProvider,\n } = components;\n\n if (BootErrorPage) {\n throw new Error(\n 'components.BootErrorPage is not supported by convertLegacyAppOptions',\n );\n }\n if (ThemeProvider) {\n throw new Error(\n 'components.ThemeProvider is not supported by convertLegacyAppOptions',\n );\n }\n if (Router) {\n extensions.push(\n RouterBlueprint.make({\n params: { component: componentCompatWrapper(Router) },\n }),\n );\n }\n if (SignInPage) {\n extensions.push(\n SignInPageBlueprint.make({\n params: {\n loader: () => Promise.resolve(componentCompatWrapper(SignInPage)),\n },\n }),\n );\n }\n if (Progress) {\n extensions.push(\n createComponentExtension({\n ref: coreComponentRefs.progress,\n loader: { sync: () => componentCompatWrapper(Progress) },\n }),\n );\n }\n if (NotFoundErrorPage) {\n extensions.push(\n createComponentExtension({\n ref: coreComponentRefs.notFoundErrorPage,\n loader: { sync: () => componentCompatWrapper(NotFoundErrorPage) },\n }),\n );\n }\n if (ErrorBoundaryFallback) {\n const WrappedErrorBoundaryFallback = (\n props: CoreErrorBoundaryFallbackProps,\n ) =>\n compatWrapper(\n <ErrorBoundaryFallback\n {...props}\n plugin={props.plugin && toLegacyPlugin(props.plugin)}\n />,\n );\n extensions.push(\n createComponentExtension({\n ref: coreComponentRefs.errorBoundaryFallback,\n loader: {\n sync: () => componentCompatWrapper(WrappedErrorBoundaryFallback),\n },\n }),\n );\n }\n }\n\n return createFrontendModule({\n pluginId: 'app',\n extensions,\n featureFlags,\n });\n}\n"],"names":[],"mappings":";;;;;AA0CA,SAAS,uBACP,SACA,EAAA;AACA,EAAA,OAAO,CAAC,KAAkB,KAAA,aAAA,qBAAe,SAAW,EAAA,EAAA,GAAG,OAAO,CAAE,CAAA;AAClE;AAKgB,SAAA,uBAAA,CACd,OAYI,GAAA,EACY,EAAA;AAChB,EAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,SAAS,UAAY,EAAA,MAAA,EAAQ,cAAiB,GAAA,OAAA;AAEnE,EAAA,MAAM,OAAU,GAAA;AAAA,IACd,GAAI,OAAS,EAAA,OAAA,CAAQ,CAAU,MAAA,KAAA,CAAC,GAAG,MAAA,CAAO,OAAQ,EAAC,CAAC,CAAA,IAAK,EAAC;AAAA,IAC1D,GAAI,QAAQ;AAAC,GACf;AACA,EAAA,MAAM,mBAAmB,KAAM,CAAA,IAAA;AAAA,IAC7B,IAAI,GAAA,CAAI,OAAQ,CAAA,GAAA,CAAI,CAAO,GAAA,KAAA,CAAC,GAAI,CAAA,GAAA,CAAI,EAAI,EAAA,GAAG,CAAC,CAAC,EAAE,MAAO;AAAA,GACxD;AACA,EAAA,MAAM,aAAoC,gBAAiB,CAAA,GAAA;AAAA,IAAI,CAAA,OAAA,KAC7D,aAAa,IAAK,CAAA;AAAA,MAChB,IAAA,EAAM,QAAQ,GAAI,CAAA,EAAA;AAAA,MAClB,MAAA,EAAQ,CAAg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UAAA,CAAA,IAAA;AAAA,QACT,wBAAyB,CAAA;AAAA,UACvB,KAAK,iBAAkB,CAAA,qBAAA;AAAA,UACvB,MAAQ,EAAA;AAAA,YACN,IAAA,EAAM,MAAM,sBAAA,CAAuB,4BAA4B;AAAA;AACjE,SACD;AAAA,OACH;AAAA;AACF;AAGF,EAAA,OAAO,oBAAqB,CAAA;AAAA,IAC1B,QAAU,EAAA,KAAA;AAAA,IACV,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
1
+ {"version":3,"file":"convertLegacyAppOptions.esm.js","sources":["../src/convertLegacyAppOptions.tsx"],"sourcesContent":["/*\n * Copyright 2025 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentType } from 'react';\nimport {\n SwappableComponentBlueprint,\n ApiBlueprint,\n ErrorDisplayProps,\n createExtension,\n createFrontendModule,\n ExtensionDefinition,\n FrontendModule,\n IconBundleBlueprint,\n RouterBlueprint,\n SignInPageBlueprint,\n ThemeBlueprint,\n ErrorDisplay as SwappableErrorDisplay,\n NotFoundErrorPage as SwappableNotFoundErrorPage,\n Progress as SwappableProgress,\n} from '@backstage/frontend-plugin-api';\nimport {\n AnyApiFactory,\n AppComponents,\n AppTheme,\n BackstagePlugin,\n FeatureFlag,\n IconComponent,\n} from '@backstage/core-plugin-api';\nimport { toLegacyPlugin } from './compatWrapper/BackwardsCompatProvider';\nimport { compatWrapper } from './compatWrapper';\n\nfunction componentCompatWrapper<TProps extends {}>(\n Component: ComponentType<TProps>,\n) {\n return (props: TProps) => compatWrapper(<Component {...props} />);\n}\n\n/**\n * @public\n */\nexport function convertLegacyAppOptions(\n options: {\n apis?: Iterable<AnyApiFactory>;\n\n icons?: { [key in string]: IconComponent };\n\n plugins?: Array<BackstagePlugin>;\n\n components?: Partial<AppComponents>;\n\n themes?: AppTheme[];\n\n featureFlags?: (FeatureFlag & Omit<FeatureFlag, 'pluginId'>)[];\n } = {},\n): FrontendModule {\n const { apis, icons, plugins, components, themes, featureFlags } = options;\n\n const allApis = [\n ...(plugins?.flatMap(plugin => [...plugin.getApis()]) ?? []),\n ...(apis ?? []),\n ];\n const deduplicatedApis = Array.from(\n new Map(allApis.map(api => [api.api.id, api])).values(),\n );\n const extensions: ExtensionDefinition[] = deduplicatedApis.map(factory =>\n ApiBlueprint.make({\n name: factory.api.id,\n params: defineParams => defineParams(factory),\n }),\n );\n\n if (icons) {\n extensions.push(\n IconBundleBlueprint.make({\n name: 'app-options',\n params: { icons },\n }),\n );\n }\n\n if (themes) {\n // IF any themes are provided we need to disable the default ones, unless they are overridden\n for (const id of ['light', 'dark']) {\n if (!themes.some(theme => theme.id === id)) {\n extensions.push(\n createExtension({\n kind: 'theme',\n name: id,\n attachTo: { id: 'api:app/app-theme', input: 'themes' },\n disabled: true,\n output: [],\n factory: () => [],\n }),\n );\n }\n }\n extensions.push(\n ...themes.map(theme =>\n ThemeBlueprint.make({\n name: theme.id,\n params: { theme },\n }),\n ),\n );\n }\n\n if (components) {\n const {\n BootErrorPage,\n ErrorBoundaryFallback,\n NotFoundErrorPage,\n Progress,\n Router,\n SignInPage,\n ThemeProvider,\n } = components;\n\n if (BootErrorPage) {\n throw new Error(\n 'components.BootErrorPage is not supported by convertLegacyAppOptions',\n );\n }\n if (ThemeProvider) {\n throw new Error(\n 'components.ThemeProvider is not supported by convertLegacyAppOptions',\n );\n }\n if (Router) {\n extensions.push(\n RouterBlueprint.make({\n params: { component: componentCompatWrapper(Router) },\n }),\n );\n }\n if (SignInPage) {\n extensions.push(\n SignInPageBlueprint.make({\n params: {\n loader: () => Promise.resolve(componentCompatWrapper(SignInPage)),\n },\n }),\n );\n }\n if (Progress) {\n extensions.push(\n SwappableComponentBlueprint.make({\n params: define =>\n define({\n component: SwappableProgress,\n loader: () => componentCompatWrapper(Progress),\n }),\n }),\n );\n }\n\n if (NotFoundErrorPage) {\n extensions.push(\n SwappableComponentBlueprint.make({\n params: define =>\n define({\n component: SwappableNotFoundErrorPage,\n loader: () => componentCompatWrapper(NotFoundErrorPage),\n }),\n }),\n );\n }\n\n if (ErrorBoundaryFallback) {\n const WrappedErrorBoundaryFallback = (props: ErrorDisplayProps) =>\n compatWrapper(\n <ErrorBoundaryFallback\n {...props}\n plugin={props.plugin && toLegacyPlugin(props.plugin)}\n />,\n );\n\n extensions.push(\n SwappableComponentBlueprint.make({\n params: define =>\n define({\n component: SwappableErrorDisplay,\n loader: () =>\n componentCompatWrapper(WrappedErrorBoundaryFallback),\n }),\n }),\n );\n }\n }\n\n return createFrontendModule({\n pluginId: 'app',\n extensions,\n featureFlags,\n });\n}\n"],"names":["NotFoundErrorPage","Progress","SwappableProgress","SwappableNotFoundErrorPage","SwappableErrorDisplay"],"mappings":";;;;;AA4CA,SAAS,uBACP,SACA,EAAA;AACA,EAAA,OAAO,CAAC,KAAkB,KAAA,aAAA,qBAAe,SAAW,EAAA,EAAA,GAAG,OAAO,CAAE,CAAA;AAClE;AAKgB,SAAA,uBAAA,CACd,OAYI,GAAA,EACY,EAAA;AAChB,EAAA,MAAM,EAAE,IAAM,EAAA,KAAA,EAAO,SAAS,UAAY,EAAA,MAAA,EAAQ,cAAiB,GAAA,OAAA;AAEnE,EAAA,MAAM,OAAU,GAAA;AAAA,IACd,GAAI,OAAS,EAAA,OAAA,CAAQ,CAAU,MAAA,KAAA,CAAC,GAAG,MAAA,CAAO,OAAQ,EAAC,CAAC,CAAA,IAAK,EAAC;AAAA,IAC1D,GAAI,QAAQ;AAAC,GACf;AACA,EAAA,MAAM,mBAAmB,KAAM,CAAA,IAAA;AAAA,IAC7B,IAAI,GAAA,CAAI,OAAQ,C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BAAA;AAAA,YACX,MAAA,EAAQ,MAAM,sBAAA,CAAuBH,mBAAiB;AAAA,WACvD;AAAA,SACJ;AAAA,OACH;AAAA;AAGF,IAAA,IAAI,qBAAuB,EAAA;AACzB,MAAM,MAAA,4BAAA,GAA+B,CAAC,KACpC,KAAA,aAAA;AAAA,wBACE,GAAA;AAAA,UAAC,qBAAA;AAAA,UAAA;AAAA,YACE,GAAG,KAAA;AAAA,YACJ,MAAQ,EAAA,KAAA,CAAM,MAAU,IAAA,cAAA,CAAe,MAAM,MAAM;AAAA;AAAA;AACrD,OACF;AAEF,MAAW,UAAA,CAAA,IAAA;AAAA,QACT,4BAA4B,IAAK,CAAA;AAAA,UAC/B,MAAA,EAAQ,YACN,MAAO,CAAA;AAAA,YACL,SAAW,EAAAI,YAAA;AAAA,YACX,MAAA,EAAQ,MACN,sBAAA,CAAuB,4BAA4B;AAAA,WACtD;AAAA,SACJ;AAAA,OACH;AAAA;AACF;AAGF,EAAA,OAAO,oBAAqB,CAAA;AAAA,IAC1B,QAAU,EAAA,KAAA;AAAA,IACV,UAAA;AAAA,IACA;AAAA,GACD,CAAA;AACH;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/core-compat-api",
3
- "version": "0.5.0-next.2",
3
+ "version": "0.5.0-next.3",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -32,15 +32,15 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@backstage/core-plugin-api": "1.10.9",
35
- "@backstage/frontend-plugin-api": "0.11.0-next.1",
35
+ "@backstage/frontend-plugin-api": "0.11.0-next.2",
36
36
  "@backstage/plugin-catalog-react": "1.20.0-next.2",
37
37
  "@backstage/version-bridge": "1.0.11",
38
38
  "lodash": "^4.17.21"
39
39
  },
40
40
  "devDependencies": {
41
- "@backstage/cli": "0.34.0-next.1",
41
+ "@backstage/cli": "0.34.0-next.2",
42
42
  "@backstage/core-app-api": "1.18.0",
43
- "@backstage/frontend-app-api": "0.12.0-next.2",
43
+ "@backstage/frontend-app-api": "0.12.0-next.3",
44
44
  "@backstage/frontend-test-utils": "0.3.5-next.2",
45
45
  "@backstage/plugin-catalog": "1.31.2-next.2",
46
46
  "@backstage/test-utils": "1.7.11-next.0",