@backstage/core-app-api 1.16.0 → 1.16.1
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 +28 -0
- package/dist/apis/system/ApiProvider.esm.js +3 -2
- package/dist/apis/system/ApiProvider.esm.js.map +1 -1
- package/dist/app/AppContext.esm.js +2 -2
- package/dist/app/AppContext.esm.js.map +1 -1
- package/dist/app/AppManager.esm.js +19 -18
- package/dist/app/AppManager.esm.js.map +1 -1
- package/dist/app/AppRouter.esm.js +32 -19
- package/dist/app/AppRouter.esm.js.map +1 -1
- package/dist/app/AppThemeProvider.esm.js +3 -2
- package/dist/app/AppThemeProvider.esm.js.map +1 -1
- package/dist/app/isReactRouterBeta.esm.js +2 -2
- package/dist/app/isReactRouterBeta.esm.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/routing/FeatureFlagged.esm.js +2 -2
- package/dist/routing/FeatureFlagged.esm.js.map +1 -1
- package/dist/routing/FlatRoutes.esm.js +3 -2
- package/dist/routing/FlatRoutes.esm.js.map +1 -1
- package/dist/routing/RouteTracker.esm.js +4 -3
- package/dist/routing/RouteTracker.esm.js.map +1 -1
- package/dist/routing/RoutingProvider.esm.js +2 -2
- package/dist/routing/RoutingProvider.esm.js.map +1 -1
- package/package.json +11 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @backstage/core-app-api
|
|
2
2
|
|
|
3
|
+
## 1.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a47fd39: Removes instances of default React imports, a necessary update for the upcoming React 19 migration.
|
|
8
|
+
|
|
9
|
+
<https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/core-plugin-api@1.10.6
|
|
13
|
+
- @backstage/config@1.3.2
|
|
14
|
+
- @backstage/types@1.2.1
|
|
15
|
+
- @backstage/version-bridge@1.0.11
|
|
16
|
+
|
|
17
|
+
## 1.16.1-next.0
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- a47fd39: Removes instances of default React imports, a necessary update for the upcoming React 19 migration.
|
|
22
|
+
|
|
23
|
+
<https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/core-plugin-api@1.10.6-next.0
|
|
27
|
+
- @backstage/config@1.3.2
|
|
28
|
+
- @backstage/types@1.2.1
|
|
29
|
+
- @backstage/version-bridge@1.0.11
|
|
30
|
+
|
|
3
31
|
## 1.16.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import { ApiAggregator } from './ApiAggregator.esm.js';
|
|
4
5
|
import { createVersionedContext, createVersionedValueMap } from '@backstage/version-bridge';
|
|
@@ -8,7 +9,7 @@ const ApiProvider = (props) => {
|
|
|
8
9
|
const { apis, children } = props;
|
|
9
10
|
const parentHolder = useContext(ApiContext)?.atVersion(1);
|
|
10
11
|
const holder = parentHolder ? new ApiAggregator(apis, parentHolder) : apis;
|
|
11
|
-
return /* @__PURE__ */
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
12
13
|
ApiContext.Provider,
|
|
13
14
|
{
|
|
14
15
|
value: createVersionedValueMap({ 1: holder }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiProvider.esm.js","sources":["../../../src/apis/system/ApiProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 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
|
|
1
|
+
{"version":3,"file":"ApiProvider.esm.js","sources":["../../../src/apis/system/ApiProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { useContext, ReactNode, PropsWithChildren } from 'react';\nimport PropTypes from 'prop-types';\nimport { ApiHolder } from '@backstage/core-plugin-api';\nimport { ApiAggregator } from './ApiAggregator';\nimport {\n createVersionedValueMap,\n createVersionedContext,\n} from '@backstage/version-bridge';\n\n/**\n * Prop types for the ApiProvider component.\n * @public\n */\nexport type ApiProviderProps = {\n apis: ApiHolder;\n children: ReactNode;\n};\n\nconst ApiContext = createVersionedContext<{ 1: ApiHolder }>('api-context');\n\n/**\n * Provides an {@link @backstage/core-plugin-api#ApiHolder} for consumption in\n * the React tree.\n *\n * @public\n */\nexport const ApiProvider = (props: PropsWithChildren<ApiProviderProps>) => {\n const { apis, children } = props;\n const parentHolder = useContext(ApiContext)?.atVersion(1);\n const holder = parentHolder ? new ApiAggregator(apis, parentHolder) : apis;\n\n return (\n <ApiContext.Provider\n value={createVersionedValueMap({ 1: holder })}\n children={children}\n />\n );\n};\n\nApiProvider.propTypes = {\n apis: PropTypes.shape({ get: PropTypes.func.isRequired }).isRequired,\n children: PropTypes.node,\n};\n"],"names":[],"mappings":";;;;;;AAkCA,MAAM,UAAA,GAAa,uBAAyC,aAAa,CAAA;AAQ5D,MAAA,WAAA,GAAc,CAAC,KAA+C,KAAA;AACzE,EAAM,MAAA,EAAE,IAAM,EAAA,QAAA,EAAa,GAAA,KAAA;AAC3B,EAAA,MAAM,YAAe,GAAA,UAAA,CAAW,UAAU,CAAA,EAAG,UAAU,CAAC,CAAA;AACxD,EAAA,MAAM,SAAS,YAAe,GAAA,IAAI,aAAc,CAAA,IAAA,EAAM,YAAY,CAAI,GAAA,IAAA;AAEtE,EACE,uBAAA,GAAA;AAAA,IAAC,UAAW,CAAA,QAAA;AAAA,IAAX;AAAA,MACC,KAAO,EAAA,uBAAA,CAAwB,EAAE,CAAA,EAAG,QAAQ,CAAA;AAAA,MAC5C;AAAA;AAAA,GACF;AAEJ;AAEA,WAAA,CAAY,SAAY,GAAA;AAAA,EACtB,IAAA,EAAM,UAAU,KAAM,CAAA,EAAE,KAAK,SAAU,CAAA,IAAA,CAAK,UAAW,EAAC,CAAE,CAAA,UAAA;AAAA,EAC1D,UAAU,SAAU,CAAA;AACtB,CAAA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { createVersionedContext, createVersionedValueMap } from '@backstage/version-bridge';
|
|
3
3
|
|
|
4
4
|
const AppContext = createVersionedContext("app-context");
|
|
@@ -7,7 +7,7 @@ const AppContextProvider = ({
|
|
|
7
7
|
children
|
|
8
8
|
}) => {
|
|
9
9
|
const versionedValue = createVersionedValueMap({ 1: appContext });
|
|
10
|
-
return /* @__PURE__ */
|
|
10
|
+
return /* @__PURE__ */ jsx(AppContext.Provider, { value: versionedValue, children });
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export { AppContextProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppContext.esm.js","sources":["../../src/app/AppContext.tsx"],"sourcesContent":["/*\n * Copyright 2020 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
|
|
1
|
+
{"version":3,"file":"AppContext.esm.js","sources":["../../src/app/AppContext.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { PropsWithChildren } from 'react';\nimport {\n createVersionedValueMap,\n createVersionedContext,\n} from '@backstage/version-bridge';\nimport { AppContext as AppContextV1 } from './types';\n\nconst AppContext = createVersionedContext<{ 1: AppContextV1 }>('app-context');\n\ntype Props = {\n appContext: AppContextV1;\n};\n\nexport const AppContextProvider = ({\n appContext,\n children,\n}: PropsWithChildren<Props>) => {\n const versionedValue = createVersionedValueMap({ 1: appContext });\n\n return <AppContext.Provider value={versionedValue} children={children} />;\n};\n"],"names":[],"mappings":";;;AAuBA,MAAM,UAAA,GAAa,uBAA4C,aAAa,CAAA;AAMrE,MAAM,qBAAqB,CAAC;AAAA,EACjC,UAAA;AAAA,EACA;AACF,CAAgC,KAAA;AAC9B,EAAA,MAAM,cAAiB,GAAA,uBAAA,CAAwB,EAAE,CAAA,EAAG,YAAY,CAAA;AAEhE,EAAA,2BAAQ,UAAW,CAAA,QAAA,EAAX,EAAoB,KAAA,EAAO,gBAAgB,QAAoB,EAAA,CAAA;AACzE;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useMemo, Suspense } from 'react';
|
|
2
3
|
import useAsync from 'react-use/esm/useAsync';
|
|
3
4
|
import { ApiProvider } from '../apis/system/ApiProvider.esm.js';
|
|
4
5
|
import { ApiResolver } from '../apis/system/ApiResolver.esm.js';
|
|
@@ -35,15 +36,15 @@ function useConfigLoader(configLoader, components, appThemeApi) {
|
|
|
35
36
|
let noConfigNode = void 0;
|
|
36
37
|
if (hasConfig && config.loading) {
|
|
37
38
|
const { Progress } = components;
|
|
38
|
-
noConfigNode = /* @__PURE__ */
|
|
39
|
+
noConfigNode = /* @__PURE__ */ jsx(Progress, {});
|
|
39
40
|
} else if (config.error) {
|
|
40
41
|
const { BootErrorPage } = components;
|
|
41
|
-
noConfigNode = /* @__PURE__ */
|
|
42
|
+
noConfigNode = /* @__PURE__ */ jsx(BootErrorPage, { step: "load-config", error: config.error });
|
|
42
43
|
}
|
|
43
44
|
const { ThemeProvider = AppThemeProvider } = components;
|
|
44
45
|
if (noConfigNode) {
|
|
45
46
|
return {
|
|
46
|
-
node: /* @__PURE__ */
|
|
47
|
+
node: /* @__PURE__ */ jsx(ApiProvider, { apis: ApiRegistry.with(appThemeApiRef, appThemeApi), children: /* @__PURE__ */ jsx(ThemeProvider, { children: noConfigNode }) })
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
50
|
const configReader = ConfigReader.fromConfigs(
|
|
@@ -116,7 +117,7 @@ class AppManager {
|
|
|
116
117
|
createRoot(element) {
|
|
117
118
|
const AppProvider = this.getProvider();
|
|
118
119
|
const AppRoot = () => {
|
|
119
|
-
return /* @__PURE__ */
|
|
120
|
+
return /* @__PURE__ */ jsx(AppProvider, { children: element });
|
|
120
121
|
};
|
|
121
122
|
return AppRoot;
|
|
122
123
|
}
|
|
@@ -244,26 +245,26 @@ DEPRECATION WARNING: React Router Beta is deprecated and support for it will be
|
|
|
244
245
|
discoveryApi
|
|
245
246
|
});
|
|
246
247
|
}
|
|
247
|
-
return /* @__PURE__ */
|
|
248
|
+
return /* @__PURE__ */ jsx(ApiProvider, { apis, children: /* @__PURE__ */ jsx(AppContextProvider, { appContext, children: /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(
|
|
248
249
|
RoutingProvider,
|
|
249
250
|
{
|
|
250
251
|
routePaths: routing.paths,
|
|
251
252
|
routeParents: routing.parents,
|
|
252
253
|
routeObjects: routing.objects,
|
|
253
254
|
routeBindings,
|
|
254
|
-
basePath: getBasePath(loadedConfig.api)
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
255
|
+
basePath: getBasePath(loadedConfig.api),
|
|
256
|
+
children: /* @__PURE__ */ jsx(
|
|
257
|
+
InternalAppContext.Provider,
|
|
258
|
+
{
|
|
259
|
+
value: {
|
|
260
|
+
routeObjects: routing.objects,
|
|
261
|
+
appIdentityProxy: this.appIdentityProxy
|
|
262
|
+
},
|
|
263
|
+
children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Progress, {}), children })
|
|
262
264
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
))));
|
|
265
|
+
)
|
|
266
|
+
}
|
|
267
|
+
) }) }) });
|
|
267
268
|
};
|
|
268
269
|
return Provider;
|
|
269
270
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppManager.esm.js","sources":["../../src/app/AppManager.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\nimport React, {\n ComponentType,\n PropsWithChildren,\n Suspense,\n useMemo,\n useRef,\n} from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n ApiProvider,\n AppThemeSelector,\n ConfigReader,\n LocalStorageFeatureFlags,\n} from '../apis';\nimport {\n AnyApiFactory,\n ApiHolder,\n IconComponent,\n AppTheme,\n appThemeApiRef,\n configApiRef,\n AppThemeApi,\n ConfigApi,\n featureFlagsApiRef,\n identityApiRef,\n BackstagePlugin,\n FeatureFlag,\n fetchApiRef,\n discoveryApiRef,\n errorApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n AppLanguageApi,\n appLanguageApiRef,\n translationApiRef,\n TranslationMessages,\n TranslationResource,\n} from '@backstage/core-plugin-api/alpha';\nimport { ApiFactoryRegistry, ApiResolver } from '../apis/system';\nimport {\n childDiscoverer,\n routeElementDiscoverer,\n traverseElementTree,\n} from '../extensions/traversal';\nimport { pluginCollector } from '../plugins/collectors';\nimport {\n featureFlagCollector,\n routingV1Collector,\n routingV2Collector,\n} from '../routing/collectors';\nimport { RoutingProvider } from '../routing/RoutingProvider';\nimport {\n validateRouteParameters,\n validateRouteBindings,\n} from '../routing/validation';\nimport { AppContextProvider } from './AppContext';\nimport { AppIdentityProxy } from '../apis/implementations/IdentityApi/AppIdentityProxy';\nimport {\n AppComponents,\n AppConfigLoader,\n AppContext,\n AppOptions,\n BackstageApp,\n} from './types';\nimport { AppThemeProvider } from './AppThemeProvider';\nimport { defaultConfigLoader } from './defaultConfigLoader';\nimport { ApiRegistry } from '../apis/system/ApiRegistry';\nimport { resolveRouteBindings } from './resolveRouteBindings';\nimport { isReactRouterBeta } from './isReactRouterBeta';\nimport { InternalAppContext } from './InternalAppContext';\nimport { AppRouter, getBasePath } from './AppRouter';\nimport { AppLanguageSelector } from '../apis/implementations/AppLanguageApi';\nimport { I18nextTranslationApi } from '../apis/implementations/TranslationApi';\nimport { overrideBaseUrlConfigs } from './overrideBaseUrlConfigs';\nimport { isProtectedApp } from './isProtectedApp';\n\ntype CompatiblePlugin =\n | BackstagePlugin\n | (Omit<BackstagePlugin, 'getFeatureFlags'> & {\n output(): Array<{ type: 'feature-flag'; name: string }>;\n });\n\nfunction useConfigLoader(\n configLoader: AppConfigLoader | undefined,\n components: AppComponents,\n appThemeApi: AppThemeApi,\n): { api: ConfigApi } | { node: JSX.Element } {\n // Keeping this synchronous when a config loader isn't set simplifies tests a lot\n const hasConfig = Boolean(configLoader);\n const config = useAsync(configLoader || (() => Promise.resolve([])));\n\n let noConfigNode = undefined;\n\n if (hasConfig && config.loading) {\n const { Progress } = components;\n noConfigNode = <Progress />;\n } else if (config.error) {\n const { BootErrorPage } = components;\n noConfigNode = <BootErrorPage step=\"load-config\" error={config.error} />;\n }\n\n const { ThemeProvider = AppThemeProvider } = components;\n\n // Before the config is loaded we can't use a router, so exit early\n if (noConfigNode) {\n return {\n node: (\n <ApiProvider apis={ApiRegistry.with(appThemeApiRef, appThemeApi)}>\n <ThemeProvider>{noConfigNode}</ThemeProvider>\n </ApiProvider>\n ),\n };\n }\n\n const configReader = ConfigReader.fromConfigs(\n config.value?.length ? overrideBaseUrlConfigs(config.value) : [],\n );\n\n return { api: configReader };\n}\n\nclass AppContextImpl implements AppContext {\n constructor(private readonly app: AppManager) {}\n\n getPlugins(): BackstagePlugin[] {\n return this.app.getPlugins();\n }\n\n getSystemIcon(key: string): IconComponent | undefined {\n return this.app.getSystemIcon(key);\n }\n\n getSystemIcons(): Record<string, IconComponent> {\n return this.app.getSystemIcons();\n }\n\n getComponents(): AppComponents {\n return this.app.getComponents();\n }\n}\n\nexport class AppManager implements BackstageApp {\n private apiHolder?: ApiHolder;\n private configApi?: ConfigApi;\n\n private readonly apis: Iterable<AnyApiFactory>;\n private readonly icons: NonNullable<AppOptions['icons']>;\n private readonly plugins: Set<CompatiblePlugin>;\n private readonly featureFlags: (FeatureFlag &\n Omit<FeatureFlag, 'pluginId'>)[];\n private readonly components: AppComponents;\n private readonly themes: AppTheme[];\n private readonly configLoader?: AppConfigLoader;\n private readonly defaultApis: Iterable<AnyApiFactory>;\n private readonly bindRoutes: AppOptions['bindRoutes'];\n private readonly appLanguageApi: AppLanguageApi;\n private readonly translationResources: Array<\n TranslationResource | TranslationMessages\n >;\n\n private readonly appIdentityProxy = new AppIdentityProxy();\n private readonly apiFactoryRegistry: ApiFactoryRegistry;\n\n constructor(options: AppOptions) {\n this.apis = options.apis ?? [];\n this.icons = options.icons;\n this.plugins = new Set((options.plugins as CompatiblePlugin[]) ?? []);\n this.featureFlags = options.featureFlags ?? [];\n this.components = options.components;\n this.themes = options.themes as AppTheme[];\n this.configLoader = options.configLoader ?? defaultConfigLoader;\n this.defaultApis = options.defaultApis ?? [];\n this.bindRoutes = options.bindRoutes;\n this.apiFactoryRegistry = new ApiFactoryRegistry();\n this.appLanguageApi = AppLanguageSelector.createWithStorage({\n defaultLanguage: options.__experimentalTranslations?.defaultLanguage,\n availableLanguages:\n options.__experimentalTranslations?.availableLanguages,\n });\n this.translationResources =\n options.__experimentalTranslations?.resources ?? [];\n }\n\n getPlugins(): BackstagePlugin[] {\n return Array.from(this.plugins) as BackstagePlugin[];\n }\n\n getSystemIcon(key: string): IconComponent | undefined {\n return this.icons[key];\n }\n\n getSystemIcons(): Record<string, IconComponent> {\n return this.icons;\n }\n\n getComponents(): AppComponents {\n return this.components;\n }\n\n createRoot(element: JSX.Element): ComponentType<PropsWithChildren<{}>> {\n const AppProvider = this.getProvider();\n const AppRoot = () => {\n return <AppProvider>{element}</AppProvider>;\n };\n return AppRoot;\n }\n\n #getProviderCalled = false;\n getProvider(): ComponentType<PropsWithChildren<{}>> {\n if (this.#getProviderCalled) {\n throw new Error(\n 'app.getProvider() or app.createRoot() has already been called, and can only be called once',\n );\n }\n this.#getProviderCalled = true;\n\n const appContext = new AppContextImpl(this);\n\n // We only bind and validate routes once\n let routeBindings: ReturnType<typeof resolveRouteBindings>;\n // Store and keep throwing the same error if we encounter one\n let routeValidationError: Error | undefined = undefined;\n\n const Provider = ({ children }: PropsWithChildren<{}>) => {\n const needsFeatureFlagRegistrationRef = useRef(true);\n const appThemeApi = useMemo(\n () => AppThemeSelector.createWithStorage(this.themes),\n [],\n );\n\n const { routing, featureFlags } = useMemo(() => {\n const usesReactRouterBeta = isReactRouterBeta();\n if (usesReactRouterBeta) {\n // eslint-disable-next-line no-console\n console.warn(`\nDEPRECATION WARNING: React Router Beta is deprecated and support for it will be removed in a future release.\n Please migrate to use React Router v6 stable.\n See https://backstage.io/docs/tutorials/react-router-stable-migration\n`);\n }\n\n const result = traverseElementTree({\n root: children,\n discoverers: [childDiscoverer, routeElementDiscoverer],\n collectors: {\n routing: usesReactRouterBeta\n ? routingV1Collector\n : routingV2Collector,\n collectedPlugins: pluginCollector,\n featureFlags: featureFlagCollector,\n },\n });\n\n // TODO(Rugvip): Restructure the public API so that we can get an immediate view of\n // the app, rather than having to wait for the provider to render.\n // For now we need to push the additional plugins we find during\n // collection and then make sure we initialize things afterwards.\n result.collectedPlugins.forEach(plugin => this.plugins.add(plugin));\n this.verifyPlugins(this.plugins);\n\n // Initialize APIs once all plugins are available\n this.getApiHolder();\n return result;\n }, [children]);\n\n const loadedConfig = useConfigLoader(\n this.configLoader,\n this.components,\n appThemeApi,\n );\n\n const hasConfigApi = 'api' in loadedConfig;\n if (hasConfigApi) {\n const { api } = loadedConfig as { api: Config };\n this.configApi = api;\n }\n\n if ('node' in loadedConfig) {\n // Loading or error\n return loadedConfig.node;\n }\n\n if (routeValidationError) {\n throw routeValidationError;\n } else if (!routeBindings) {\n try {\n routeBindings = resolveRouteBindings(\n this.bindRoutes,\n loadedConfig.api,\n this.plugins,\n );\n\n validateRouteParameters(routing.paths, routing.parents);\n validateRouteBindings(routeBindings, this.plugins);\n } catch (error) {\n routeValidationError = error;\n throw error;\n }\n }\n\n // We can't register feature flags just after the element traversal, because the\n // config API isn't available yet and implementations frequently depend on it.\n // Instead we make it happen immediately, to make sure all flags are available\n // for the first render.\n if (hasConfigApi && needsFeatureFlagRegistrationRef.current) {\n needsFeatureFlagRegistrationRef.current = false;\n\n const featureFlagsApi = this.getApiHolder().get(featureFlagsApiRef)!;\n\n if (featureFlagsApi) {\n for (const flag of this.featureFlags) {\n featureFlagsApi.registerFlag({\n ...flag,\n pluginId: '',\n });\n }\n for (const plugin of this.plugins.values()) {\n if ('getFeatureFlags' in plugin) {\n for (const flag of plugin.getFeatureFlags()) {\n featureFlagsApi.registerFlag({\n name: flag.name,\n pluginId: plugin.getId(),\n });\n }\n } else {\n for (const output of plugin.output()) {\n if (output.type === 'feature-flag') {\n featureFlagsApi.registerFlag({\n name: output.name,\n pluginId: plugin.getId(),\n });\n }\n }\n }\n }\n\n // Go through the featureFlags returned from the traversal and\n // register those now the configApi has been loaded\n const registeredFlags = featureFlagsApi.getRegisteredFlags();\n const flagNames = new Set(registeredFlags.map(f => f.name));\n for (const name of featureFlags) {\n // Prevents adding duplicate feature flags\n if (!flagNames.has(name)) {\n featureFlagsApi.registerFlag({ name, pluginId: '' });\n }\n }\n }\n }\n\n const { ThemeProvider = AppThemeProvider, Progress } = this.components;\n\n const apis = this.getApiHolder();\n\n if (isProtectedApp()) {\n const errorApi = apis.get(errorApiRef);\n const fetchApi = apis.get(fetchApiRef);\n const discoveryApi = apis.get(discoveryApiRef);\n if (!errorApi || !fetchApi || !discoveryApi) {\n throw new Error(\n 'App is running in protected mode but missing required APIs',\n );\n }\n this.appIdentityProxy.enableCookieAuth({\n errorApi,\n fetchApi,\n discoveryApi,\n });\n }\n\n return (\n <ApiProvider apis={apis}>\n <AppContextProvider appContext={appContext}>\n <ThemeProvider>\n <RoutingProvider\n routePaths={routing.paths}\n routeParents={routing.parents}\n routeObjects={routing.objects}\n routeBindings={routeBindings}\n basePath={getBasePath(loadedConfig.api)}\n >\n <InternalAppContext.Provider\n value={{\n routeObjects: routing.objects,\n appIdentityProxy: this.appIdentityProxy,\n }}\n >\n <Suspense fallback={<Progress />}>{children}</Suspense>\n </InternalAppContext.Provider>\n </RoutingProvider>\n </ThemeProvider>\n </AppContextProvider>\n </ApiProvider>\n );\n };\n return Provider;\n }\n\n getRouter(): ComponentType<PropsWithChildren<{}>> {\n return AppRouter;\n }\n\n private getApiHolder(): ApiHolder {\n if (this.apiHolder) {\n // Register additional plugins if they have been added.\n // Routes paths, objects and others are already updated in the provider when children of it change\n for (const plugin of this.plugins) {\n for (const factory of plugin.getApis()) {\n if (!this.apiFactoryRegistry.get(factory.api)) {\n this.apiFactoryRegistry.register('default', factory);\n }\n }\n }\n ApiResolver.validateFactories(\n this.apiFactoryRegistry,\n this.apiFactoryRegistry.getAllApis(),\n );\n return this.apiHolder;\n }\n this.apiFactoryRegistry.register('static', {\n api: appThemeApiRef,\n deps: {},\n factory: () => AppThemeSelector.createWithStorage(this.themes),\n });\n this.apiFactoryRegistry.register('static', {\n api: configApiRef,\n deps: {},\n factory: () => {\n if (!this.configApi) {\n throw new Error(\n 'Tried to access config API before config was loaded',\n );\n }\n return this.configApi;\n },\n });\n this.apiFactoryRegistry.register('static', {\n api: identityApiRef,\n deps: {},\n factory: () => this.appIdentityProxy,\n });\n this.apiFactoryRegistry.register('static', {\n api: appLanguageApiRef,\n deps: {},\n factory: () => this.appLanguageApi,\n });\n\n // The translation API is registered as a default API so that it can be overridden.\n // It will be up to the implementer of the new API to register translation resources.\n this.apiFactoryRegistry.register('default', {\n api: translationApiRef,\n deps: { languageApi: appLanguageApiRef },\n factory: ({ languageApi }) =>\n I18nextTranslationApi.create({\n languageApi,\n resources: this.translationResources,\n }),\n });\n\n // It's possible to replace the feature flag API, but since we must have at least\n // one implementation we add it here directly instead of through the defaultApis.\n this.apiFactoryRegistry.register('default', {\n api: featureFlagsApiRef,\n deps: {},\n factory: () => new LocalStorageFeatureFlags(),\n });\n for (const factory of this.defaultApis) {\n this.apiFactoryRegistry.register('default', factory);\n }\n\n for (const plugin of this.plugins) {\n for (const factory of plugin.getApis()) {\n if (!this.apiFactoryRegistry.register('default', factory)) {\n throw new Error(\n `Plugin ${plugin.getId()} tried to register duplicate or forbidden API factory for ${\n factory.api\n }`,\n );\n }\n }\n }\n\n for (const factory of this.apis) {\n if (!this.apiFactoryRegistry.register('app', factory)) {\n throw new Error(\n `Duplicate or forbidden API factory for ${factory.api} in app`,\n );\n }\n }\n\n ApiResolver.validateFactories(\n this.apiFactoryRegistry,\n this.apiFactoryRegistry.getAllApis(),\n );\n\n this.apiHolder = new ApiResolver(this.apiFactoryRegistry);\n return this.apiHolder;\n }\n\n private verifyPlugins(plugins: Iterable<CompatiblePlugin>) {\n const pluginIds = new Set<string>();\n\n for (const plugin of plugins) {\n const id = plugin.getId();\n if (pluginIds.has(id)) {\n throw new Error(`Duplicate plugin found '${id}'`);\n }\n pluginIds.add(id);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGA,SAAS,eAAA,CACP,YACA,EAAA,UAAA,EACA,WAC4C,EAAA;AAE5C,EAAM,MAAA,SAAA,GAAY,QAAQ,YAAY,CAAA;AACtC,EAAM,MAAA,MAAA,GAAS,SAAS,YAAiB,KAAA,MAAM,QAAQ,OAAQ,CAAA,EAAE,CAAE,CAAA,CAAA;AAEnE,EAAA,IAAI,YAAe,GAAA,KAAA,CAAA;AAEnB,EAAI,IAAA,SAAA,IAAa,OAAO,OAAS,EAAA;AAC/B,IAAM,MAAA,EAAE,UAAa,GAAA,UAAA;AACrB,IAAA,YAAA,uCAAgB,QAAS,EAAA,IAAA,CAAA;AAAA,GAC3B,MAAA,IAAW,OAAO,KAAO,EAAA;AACvB,IAAM,MAAA,EAAE,eAAkB,GAAA,UAAA;AAC1B,IAAA,YAAA,uCAAgB,aAAc,EAAA,EAAA,IAAA,EAAK,aAAc,EAAA,KAAA,EAAO,OAAO,KAAO,EAAA,CAAA;AAAA;AAGxE,EAAM,MAAA,EAAE,aAAgB,GAAA,gBAAA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O,CAAA,0DAAA,EACtB,QAAQ,GACV,CAAA;AAAA,WACF;AAAA;AACF;AACF;AAGF,IAAW,KAAA,MAAA,OAAA,IAAW,KAAK,IAAM,EAAA;AAC/B,MAAA,IAAI,CAAC,IAAK,CAAA,kBAAA,CAAmB,QAAS,CAAA,KAAA,EAAO,OAAO,CAAG,EAAA;AACrD,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,uCAAA,EAA0C,QAAQ,GAAG,CAAA,OAAA;AAAA,SACvD;AAAA;AACF;AAGF,IAAY,WAAA,CAAA,iBAAA;AAAA,MACV,IAAK,CAAA,kBAAA;AAAA,MACL,IAAA,CAAK,mBAAmB,UAAW;AAAA,KACrC;AAEA,IAAA,IAAA,CAAK,SAAY,GAAA,IAAI,WAAY,CAAA,IAAA,CAAK,kBAAkB,CAAA;AACxD,IAAA,OAAO,IAAK,CAAA,SAAA;AAAA;AACd,EAEQ,cAAc,OAAqC,EAAA;AACzD,IAAM,MAAA,SAAA,uBAAgB,GAAY,EAAA;AAElC,IAAA,KAAA,MAAW,UAAU,OAAS,EAAA;AAC5B,MAAM,MAAA,EAAA,GAAK,OAAO,KAAM,EAAA;AACxB,MAAI,IAAA,SAAA,CAAU,GAAI,CAAA,EAAE,CAAG,EAAA;AACrB,QAAA,MAAM,IAAI,KAAA,CAAM,CAA2B,wBAAA,EAAA,EAAE,CAAG,CAAA,CAAA,CAAA;AAAA;AAElD,MAAA,SAAA,CAAU,IAAI,EAAE,CAAA;AAAA;AAClB;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"AppManager.esm.js","sources":["../../src/app/AppManager.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { Config } from '@backstage/config';\nimport {\n ComponentType,\n PropsWithChildren,\n Suspense,\n useMemo,\n useRef,\n} from 'react';\nimport useAsync from 'react-use/esm/useAsync';\nimport {\n ApiProvider,\n AppThemeSelector,\n ConfigReader,\n LocalStorageFeatureFlags,\n} from '../apis';\nimport {\n AnyApiFactory,\n ApiHolder,\n IconComponent,\n AppTheme,\n appThemeApiRef,\n configApiRef,\n AppThemeApi,\n ConfigApi,\n featureFlagsApiRef,\n identityApiRef,\n BackstagePlugin,\n FeatureFlag,\n fetchApiRef,\n discoveryApiRef,\n errorApiRef,\n} from '@backstage/core-plugin-api';\nimport {\n AppLanguageApi,\n appLanguageApiRef,\n translationApiRef,\n TranslationMessages,\n TranslationResource,\n} from '@backstage/core-plugin-api/alpha';\nimport { ApiFactoryRegistry, ApiResolver } from '../apis/system';\nimport {\n childDiscoverer,\n routeElementDiscoverer,\n traverseElementTree,\n} from '../extensions/traversal';\nimport { pluginCollector } from '../plugins/collectors';\nimport {\n featureFlagCollector,\n routingV1Collector,\n routingV2Collector,\n} from '../routing/collectors';\nimport { RoutingProvider } from '../routing/RoutingProvider';\nimport {\n validateRouteParameters,\n validateRouteBindings,\n} from '../routing/validation';\nimport { AppContextProvider } from './AppContext';\nimport { AppIdentityProxy } from '../apis/implementations/IdentityApi/AppIdentityProxy';\nimport {\n AppComponents,\n AppConfigLoader,\n AppContext,\n AppOptions,\n BackstageApp,\n} from './types';\nimport { AppThemeProvider } from './AppThemeProvider';\nimport { defaultConfigLoader } from './defaultConfigLoader';\nimport { ApiRegistry } from '../apis/system/ApiRegistry';\nimport { resolveRouteBindings } from './resolveRouteBindings';\nimport { isReactRouterBeta } from './isReactRouterBeta';\nimport { InternalAppContext } from './InternalAppContext';\nimport { AppRouter, getBasePath } from './AppRouter';\nimport { AppLanguageSelector } from '../apis/implementations/AppLanguageApi';\nimport { I18nextTranslationApi } from '../apis/implementations/TranslationApi';\nimport { overrideBaseUrlConfigs } from './overrideBaseUrlConfigs';\nimport { isProtectedApp } from './isProtectedApp';\n\ntype CompatiblePlugin =\n | BackstagePlugin\n | (Omit<BackstagePlugin, 'getFeatureFlags'> & {\n output(): Array<{ type: 'feature-flag'; name: string }>;\n });\n\nfunction useConfigLoader(\n configLoader: AppConfigLoader | undefined,\n components: AppComponents,\n appThemeApi: AppThemeApi,\n): { api: ConfigApi } | { node: JSX.Element } {\n // Keeping this synchronous when a config loader isn't set simplifies tests a lot\n const hasConfig = Boolean(configLoader);\n const config = useAsync(configLoader || (() => Promise.resolve([])));\n\n let noConfigNode = undefined;\n\n if (hasConfig && config.loading) {\n const { Progress } = components;\n noConfigNode = <Progress />;\n } else if (config.error) {\n const { BootErrorPage } = components;\n noConfigNode = <BootErrorPage step=\"load-config\" error={config.error} />;\n }\n\n const { ThemeProvider = AppThemeProvider } = components;\n\n // Before the config is loaded we can't use a router, so exit early\n if (noConfigNode) {\n return {\n node: (\n <ApiProvider apis={ApiRegistry.with(appThemeApiRef, appThemeApi)}>\n <ThemeProvider>{noConfigNode}</ThemeProvider>\n </ApiProvider>\n ),\n };\n }\n\n const configReader = ConfigReader.fromConfigs(\n config.value?.length ? overrideBaseUrlConfigs(config.value) : [],\n );\n\n return { api: configReader };\n}\n\nclass AppContextImpl implements AppContext {\n constructor(private readonly app: AppManager) {}\n\n getPlugins(): BackstagePlugin[] {\n return this.app.getPlugins();\n }\n\n getSystemIcon(key: string): IconComponent | undefined {\n return this.app.getSystemIcon(key);\n }\n\n getSystemIcons(): Record<string, IconComponent> {\n return this.app.getSystemIcons();\n }\n\n getComponents(): AppComponents {\n return this.app.getComponents();\n }\n}\n\nexport class AppManager implements BackstageApp {\n private apiHolder?: ApiHolder;\n private configApi?: ConfigApi;\n\n private readonly apis: Iterable<AnyApiFactory>;\n private readonly icons: NonNullable<AppOptions['icons']>;\n private readonly plugins: Set<CompatiblePlugin>;\n private readonly featureFlags: (FeatureFlag &\n Omit<FeatureFlag, 'pluginId'>)[];\n private readonly components: AppComponents;\n private readonly themes: AppTheme[];\n private readonly configLoader?: AppConfigLoader;\n private readonly defaultApis: Iterable<AnyApiFactory>;\n private readonly bindRoutes: AppOptions['bindRoutes'];\n private readonly appLanguageApi: AppLanguageApi;\n private readonly translationResources: Array<\n TranslationResource | TranslationMessages\n >;\n\n private readonly appIdentityProxy = new AppIdentityProxy();\n private readonly apiFactoryRegistry: ApiFactoryRegistry;\n\n constructor(options: AppOptions) {\n this.apis = options.apis ?? [];\n this.icons = options.icons;\n this.plugins = new Set((options.plugins as CompatiblePlugin[]) ?? []);\n this.featureFlags = options.featureFlags ?? [];\n this.components = options.components;\n this.themes = options.themes as AppTheme[];\n this.configLoader = options.configLoader ?? defaultConfigLoader;\n this.defaultApis = options.defaultApis ?? [];\n this.bindRoutes = options.bindRoutes;\n this.apiFactoryRegistry = new ApiFactoryRegistry();\n this.appLanguageApi = AppLanguageSelector.createWithStorage({\n defaultLanguage: options.__experimentalTranslations?.defaultLanguage,\n availableLanguages:\n options.__experimentalTranslations?.availableLanguages,\n });\n this.translationResources =\n options.__experimentalTranslations?.resources ?? [];\n }\n\n getPlugins(): BackstagePlugin[] {\n return Array.from(this.plugins) as BackstagePlugin[];\n }\n\n getSystemIcon(key: string): IconComponent | undefined {\n return this.icons[key];\n }\n\n getSystemIcons(): Record<string, IconComponent> {\n return this.icons;\n }\n\n getComponents(): AppComponents {\n return this.components;\n }\n\n createRoot(element: JSX.Element): ComponentType<PropsWithChildren<{}>> {\n const AppProvider = this.getProvider();\n const AppRoot = () => {\n return <AppProvider>{element}</AppProvider>;\n };\n return AppRoot;\n }\n\n #getProviderCalled = false;\n getProvider(): ComponentType<PropsWithChildren<{}>> {\n if (this.#getProviderCalled) {\n throw new Error(\n 'app.getProvider() or app.createRoot() has already been called, and can only be called once',\n );\n }\n this.#getProviderCalled = true;\n\n const appContext = new AppContextImpl(this);\n\n // We only bind and validate routes once\n let routeBindings: ReturnType<typeof resolveRouteBindings>;\n // Store and keep throwing the same error if we encounter one\n let routeValidationError: Error | undefined = undefined;\n\n const Provider = ({ children }: PropsWithChildren<{}>) => {\n const needsFeatureFlagRegistrationRef = useRef(true);\n const appThemeApi = useMemo(\n () => AppThemeSelector.createWithStorage(this.themes),\n [],\n );\n\n const { routing, featureFlags } = useMemo(() => {\n const usesReactRouterBeta = isReactRouterBeta();\n if (usesReactRouterBeta) {\n // eslint-disable-next-line no-console\n console.warn(`\nDEPRECATION WARNING: React Router Beta is deprecated and support for it will be removed in a future release.\n Please migrate to use React Router v6 stable.\n See https://backstage.io/docs/tutorials/react-router-stable-migration\n`);\n }\n\n const result = traverseElementTree({\n root: children,\n discoverers: [childDiscoverer, routeElementDiscoverer],\n collectors: {\n routing: usesReactRouterBeta\n ? routingV1Collector\n : routingV2Collector,\n collectedPlugins: pluginCollector,\n featureFlags: featureFlagCollector,\n },\n });\n\n // TODO(Rugvip): Restructure the public API so that we can get an immediate view of\n // the app, rather than having to wait for the provider to render.\n // For now we need to push the additional plugins we find during\n // collection and then make sure we initialize things afterwards.\n result.collectedPlugins.forEach(plugin => this.plugins.add(plugin));\n this.verifyPlugins(this.plugins);\n\n // Initialize APIs once all plugins are available\n this.getApiHolder();\n return result;\n }, [children]);\n\n const loadedConfig = useConfigLoader(\n this.configLoader,\n this.components,\n appThemeApi,\n );\n\n const hasConfigApi = 'api' in loadedConfig;\n if (hasConfigApi) {\n const { api } = loadedConfig as { api: Config };\n this.configApi = api;\n }\n\n if ('node' in loadedConfig) {\n // Loading or error\n return loadedConfig.node;\n }\n\n if (routeValidationError) {\n throw routeValidationError;\n } else if (!routeBindings) {\n try {\n routeBindings = resolveRouteBindings(\n this.bindRoutes,\n loadedConfig.api,\n this.plugins,\n );\n\n validateRouteParameters(routing.paths, routing.parents);\n validateRouteBindings(routeBindings, this.plugins);\n } catch (error) {\n routeValidationError = error;\n throw error;\n }\n }\n\n // We can't register feature flags just after the element traversal, because the\n // config API isn't available yet and implementations frequently depend on it.\n // Instead we make it happen immediately, to make sure all flags are available\n // for the first render.\n if (hasConfigApi && needsFeatureFlagRegistrationRef.current) {\n needsFeatureFlagRegistrationRef.current = false;\n\n const featureFlagsApi = this.getApiHolder().get(featureFlagsApiRef)!;\n\n if (featureFlagsApi) {\n for (const flag of this.featureFlags) {\n featureFlagsApi.registerFlag({\n ...flag,\n pluginId: '',\n });\n }\n for (const plugin of this.plugins.values()) {\n if ('getFeatureFlags' in plugin) {\n for (const flag of plugin.getFeatureFlags()) {\n featureFlagsApi.registerFlag({\n name: flag.name,\n pluginId: plugin.getId(),\n });\n }\n } else {\n for (const output of plugin.output()) {\n if (output.type === 'feature-flag') {\n featureFlagsApi.registerFlag({\n name: output.name,\n pluginId: plugin.getId(),\n });\n }\n }\n }\n }\n\n // Go through the featureFlags returned from the traversal and\n // register those now the configApi has been loaded\n const registeredFlags = featureFlagsApi.getRegisteredFlags();\n const flagNames = new Set(registeredFlags.map(f => f.name));\n for (const name of featureFlags) {\n // Prevents adding duplicate feature flags\n if (!flagNames.has(name)) {\n featureFlagsApi.registerFlag({ name, pluginId: '' });\n }\n }\n }\n }\n\n const { ThemeProvider = AppThemeProvider, Progress } = this.components;\n\n const apis = this.getApiHolder();\n\n if (isProtectedApp()) {\n const errorApi = apis.get(errorApiRef);\n const fetchApi = apis.get(fetchApiRef);\n const discoveryApi = apis.get(discoveryApiRef);\n if (!errorApi || !fetchApi || !discoveryApi) {\n throw new Error(\n 'App is running in protected mode but missing required APIs',\n );\n }\n this.appIdentityProxy.enableCookieAuth({\n errorApi,\n fetchApi,\n discoveryApi,\n });\n }\n\n return (\n <ApiProvider apis={apis}>\n <AppContextProvider appContext={appContext}>\n <ThemeProvider>\n <RoutingProvider\n routePaths={routing.paths}\n routeParents={routing.parents}\n routeObjects={routing.objects}\n routeBindings={routeBindings}\n basePath={getBasePath(loadedConfig.api)}\n >\n <InternalAppContext.Provider\n value={{\n routeObjects: routing.objects,\n appIdentityProxy: this.appIdentityProxy,\n }}\n >\n <Suspense fallback={<Progress />}>{children}</Suspense>\n </InternalAppContext.Provider>\n </RoutingProvider>\n </ThemeProvider>\n </AppContextProvider>\n </ApiProvider>\n );\n };\n return Provider;\n }\n\n getRouter(): ComponentType<PropsWithChildren<{}>> {\n return AppRouter;\n }\n\n private getApiHolder(): ApiHolder {\n if (this.apiHolder) {\n // Register additional plugins if they have been added.\n // Routes paths, objects and others are already updated in the provider when children of it change\n for (const plugin of this.plugins) {\n for (const factory of plugin.getApis()) {\n if (!this.apiFactoryRegistry.get(factory.api)) {\n this.apiFactoryRegistry.register('default', factory);\n }\n }\n }\n ApiResolver.validateFactories(\n this.apiFactoryRegistry,\n this.apiFactoryRegistry.getAllApis(),\n );\n return this.apiHolder;\n }\n this.apiFactoryRegistry.register('static', {\n api: appThemeApiRef,\n deps: {},\n factory: () => AppThemeSelector.createWithStorage(this.themes),\n });\n this.apiFactoryRegistry.register('static', {\n api: configApiRef,\n deps: {},\n factory: () => {\n if (!this.configApi) {\n throw new Error(\n 'Tried to access config API before config was loaded',\n );\n }\n return this.configApi;\n },\n });\n this.apiFactoryRegistry.register('static', {\n api: identityApiRef,\n deps: {},\n factory: () => this.appIdentityProxy,\n });\n this.apiFactoryRegistry.register('static', {\n api: appLanguageApiRef,\n deps: {},\n factory: () => this.appLanguageApi,\n });\n\n // The translation API is registered as a default API so that it can be overridden.\n // It will be up to the implementer of the new API to register translation resources.\n this.apiFactoryRegistry.register('default', {\n api: translationApiRef,\n deps: { languageApi: appLanguageApiRef },\n factory: ({ languageApi }) =>\n I18nextTranslationApi.create({\n languageApi,\n resources: this.translationResources,\n }),\n });\n\n // It's possible to replace the feature flag API, but since we must have at least\n // one implementation we add it here directly instead of through the defaultApis.\n this.apiFactoryRegistry.register('default', {\n api: featureFlagsApiRef,\n deps: {},\n factory: () => new LocalStorageFeatureFlags(),\n });\n for (const factory of this.defaultApis) {\n this.apiFactoryRegistry.register('default', factory);\n }\n\n for (const plugin of this.plugins) {\n for (const factory of plugin.getApis()) {\n if (!this.apiFactoryRegistry.register('default', factory)) {\n throw new Error(\n `Plugin ${plugin.getId()} tried to register duplicate or forbidden API factory for ${\n factory.api\n }`,\n );\n }\n }\n }\n\n for (const factory of this.apis) {\n if (!this.apiFactoryRegistry.register('app', factory)) {\n throw new Error(\n `Duplicate or forbidden API factory for ${factory.api} in app`,\n );\n }\n }\n\n ApiResolver.validateFactories(\n this.apiFactoryRegistry,\n this.apiFactoryRegistry.getAllApis(),\n );\n\n this.apiHolder = new ApiResolver(this.apiFactoryRegistry);\n return this.apiHolder;\n }\n\n private verifyPlugins(plugins: Iterable<CompatiblePlugin>) {\n const pluginIds = new Set<string>();\n\n for (const plugin of plugins) {\n const id = plugin.getId();\n if (pluginIds.has(id)) {\n throw new Error(`Duplicate plugin found '${id}'`);\n }\n pluginIds.add(id);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGA,SAAS,eAAA,CACP,YACA,EAAA,UAAA,EACA,WAC4C,EAAA;AAE5C,EAAM,MAAA,SAAA,GAAY,QAAQ,YAAY,CAAA;AACtC,EAAM,MAAA,MAAA,GAAS,SAAS,YAAiB,KAAA,MAAM,QAAQ,OAAQ,CAAA,EAAE,CAAE,CAAA,CAAA;AAEnE,EAAA,IAAI,YAAe,GAAA,KAAA,CAAA;AAEnB,EAAI,IAAA,SAAA,IAAa,OAAO,OAAS,EAAA;AAC/B,IAAM,MAAA,EAAE,UAAa,GAAA,UAAA;AACrB,IAAA,YAAA,uBAAgB,QAAS,EAAA,EAAA,CAAA;AAAA,GAC3B,MAAA,IAAW,OAAO,KAAO,EAAA;AACvB,IAAM,MAAA,EAAE,eAAkB,GAAA,UAAA;AAC1B,IAAA,YAAA,uBAAgB,aAAc,EAAA,EAAA,IAAA,EAAK,aAAc,EAAA,KAAA,EAAO,OAAO,KAAO,EAAA,CAAA;AAAA;AAGxE,EAAM,MAAA,EAAE,aAAgB,GAAA,g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AAA,KAAA,EAAO,CAAA,0DAAA,EACtB,QAAQ,GACV,CAAA;AAAA,WACF;AAAA;AACF;AACF;AAGF,IAAW,KAAA,MAAA,OAAA,IAAW,KAAK,IAAM,EAAA;AAC/B,MAAA,IAAI,CAAC,IAAK,CAAA,kBAAA,CAAmB,QAAS,CAAA,KAAA,EAAO,OAAO,CAAG,EAAA;AACrD,QAAA,MAAM,IAAI,KAAA;AAAA,UACR,CAAA,uCAAA,EAA0C,QAAQ,GAAG,CAAA,OAAA;AAAA,SACvD;AAAA;AACF;AAGF,IAAY,WAAA,CAAA,iBAAA;AAAA,MACV,IAAK,CAAA,kBAAA;AAAA,MACL,IAAA,CAAK,mBAAmB,UAAW;AAAA,KACrC;AAEA,IAAA,IAAA,CAAK,SAAY,GAAA,IAAI,WAAY,CAAA,IAAA,CAAK,kBAAkB,CAAA;AACxD,IAAA,OAAO,IAAK,CAAA,SAAA;AAAA;AACd,EAEQ,cAAc,OAAqC,EAAA;AACzD,IAAM,MAAA,SAAA,uBAAgB,GAAY,EAAA;AAElC,IAAA,KAAA,MAAW,UAAU,OAAS,EAAA;AAC5B,MAAM,MAAA,EAAA,GAAK,OAAO,KAAM,EAAA;AACxB,MAAI,IAAA,SAAA,CAAU,GAAI,CAAA,EAAE,CAAG,EAAA;AACrB,QAAA,MAAM,IAAI,KAAA,CAAM,CAA2B,wBAAA,EAAA,EAAE,CAAG,CAAA,CAAA,CAAA;AAAA;AAElD,MAAA,SAAA,CAAU,IAAI,EAAE,CAAA;AAAA;AAClB;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useContext, useState } from 'react';
|
|
2
3
|
import { attachComponentData, useApp, useApi, configApiRef } from '@backstage/core-plugin-api';
|
|
3
4
|
import { InternalAppContext } from './InternalAppContext.esm.js';
|
|
4
5
|
import { isReactRouterBeta } from './isReactRouterBeta.esm.js';
|
|
@@ -29,12 +30,12 @@ function SignInPageWrapper({
|
|
|
29
30
|
const configApi = useApi(configApiRef);
|
|
30
31
|
const basePath = readBasePath(configApi);
|
|
31
32
|
if (!identityApi) {
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
+
return /* @__PURE__ */ jsx(Component, { onSignInSuccess: setIdentityApi });
|
|
33
34
|
}
|
|
34
35
|
appIdentityProxy.setTarget(identityApi, {
|
|
35
36
|
signOutTargetUrl: basePath || "/"
|
|
36
37
|
});
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
38
39
|
}
|
|
39
40
|
function AppRouter(props) {
|
|
40
41
|
const { Router: RouterComponent, SignInPage: SignInPageComponent } = useApp().getComponents();
|
|
@@ -71,28 +72,40 @@ function AppRouter(props) {
|
|
|
71
72
|
{ signOutTargetUrl: basePath || "/" }
|
|
72
73
|
);
|
|
73
74
|
if (isReactRouterBeta()) {
|
|
74
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ jsxs(RouterComponent, { children: [
|
|
76
|
+
/* @__PURE__ */ jsx(RouteTracker, { routeObjects }),
|
|
77
|
+
/* @__PURE__ */ jsx(Routes, { children: /* @__PURE__ */ jsx(Route, { path: mountPath, element: /* @__PURE__ */ jsx(Fragment, { children: props.children }) }) })
|
|
78
|
+
] });
|
|
75
79
|
}
|
|
76
|
-
return /* @__PURE__ */
|
|
80
|
+
return /* @__PURE__ */ jsxs(RouterComponent, { basename: basePath, children: [
|
|
81
|
+
/* @__PURE__ */ jsx(RouteTracker, { routeObjects }),
|
|
82
|
+
props.children
|
|
83
|
+
] });
|
|
77
84
|
}
|
|
78
85
|
if (isReactRouterBeta()) {
|
|
79
|
-
return /* @__PURE__ */
|
|
86
|
+
return /* @__PURE__ */ jsxs(RouterComponent, { children: [
|
|
87
|
+
/* @__PURE__ */ jsx(RouteTracker, { routeObjects }),
|
|
88
|
+
/* @__PURE__ */ jsx(
|
|
89
|
+
SignInPageWrapper,
|
|
90
|
+
{
|
|
91
|
+
component: SignInPageComponent,
|
|
92
|
+
appIdentityProxy,
|
|
93
|
+
children: /* @__PURE__ */ jsx(Routes, { children: /* @__PURE__ */ jsx(Route, { path: mountPath, element: /* @__PURE__ */ jsx(Fragment, { children: props.children }) }) })
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] });
|
|
97
|
+
}
|
|
98
|
+
return /* @__PURE__ */ jsxs(RouterComponent, { basename: basePath, children: [
|
|
99
|
+
/* @__PURE__ */ jsx(RouteTracker, { routeObjects }),
|
|
100
|
+
/* @__PURE__ */ jsx(
|
|
80
101
|
SignInPageWrapper,
|
|
81
102
|
{
|
|
82
103
|
component: SignInPageComponent,
|
|
83
|
-
appIdentityProxy
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
)
|
|
87
|
-
}
|
|
88
|
-
return /* @__PURE__ */ React.createElement(RouterComponent, { basename: basePath }, /* @__PURE__ */ React.createElement(RouteTracker, { routeObjects }), /* @__PURE__ */ React.createElement(
|
|
89
|
-
SignInPageWrapper,
|
|
90
|
-
{
|
|
91
|
-
component: SignInPageComponent,
|
|
92
|
-
appIdentityProxy
|
|
93
|
-
},
|
|
94
|
-
props.children
|
|
95
|
-
));
|
|
104
|
+
appIdentityProxy,
|
|
105
|
+
children: props.children
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] });
|
|
96
109
|
}
|
|
97
110
|
attachComponentData(AppRouter, "core.type", "AppRouter");
|
|
98
111
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRouter.esm.js","sources":["../../src/app/AppRouter.tsx"],"sourcesContent":["/*\n * Copyright 2022 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
|
|
1
|
+
{"version":3,"file":"AppRouter.esm.js","sources":["../../src/app/AppRouter.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { useContext, ReactNode, ComponentType, useState } from 'react';\nimport {\n attachComponentData,\n ConfigApi,\n configApiRef,\n IdentityApi,\n SignInPageProps,\n useApi,\n useApp,\n} from '@backstage/core-plugin-api';\nimport { InternalAppContext } from './InternalAppContext';\nimport { isReactRouterBeta } from './isReactRouterBeta';\nimport { RouteTracker } from '../routing/RouteTracker';\nimport { Route, Routes } from 'react-router-dom';\nimport { AppIdentityProxy } from '../apis/implementations/IdentityApi/AppIdentityProxy';\n\n/**\n * Get the app base path from the configured app baseUrl.\n *\n * The returned path does not have a trailing slash.\n */\nexport function getBasePath(configApi: ConfigApi) {\n if (!isReactRouterBeta()) {\n // When using rr v6 stable the base path is handled through the\n // basename prop on the router component instead.\n return '';\n }\n\n return readBasePath(configApi);\n}\n\n/**\n * Read the configured base path.\n *\n * The returned path does not have a trailing slash.\n */\nfunction readBasePath(configApi: ConfigApi) {\n let { pathname } = new URL(\n configApi.getOptionalString('app.baseUrl') ?? '/',\n 'http://sample.dev', // baseUrl can be specified as just a path\n );\n pathname = pathname.replace(/\\/*$/, '');\n return pathname;\n}\n\n// This wraps the sign-in page and waits for sign-in to be completed before rendering the app\nfunction SignInPageWrapper({\n component: Component,\n appIdentityProxy,\n children,\n}: {\n component: ComponentType<SignInPageProps>;\n appIdentityProxy: AppIdentityProxy;\n children: ReactNode;\n}) {\n const [identityApi, setIdentityApi] = useState<IdentityApi>();\n const configApi = useApi(configApiRef);\n const basePath = readBasePath(configApi);\n\n if (!identityApi) {\n return <Component onSignInSuccess={setIdentityApi} />;\n }\n\n appIdentityProxy.setTarget(identityApi, {\n signOutTargetUrl: basePath || '/',\n });\n return <>{children}</>;\n}\n\n/**\n * Props for the {@link AppRouter} component.\n * @public\n */\nexport interface AppRouterProps {\n children?: ReactNode;\n}\n\n/**\n * App router and sign-in page wrapper.\n *\n * @public\n * @remarks\n *\n * The AppRouter provides the routing context and renders the sign-in page.\n * Until the user has successfully signed in, this component will render\n * the sign-in page. Once the user has signed-in, it will instead render\n * the app, while providing routing and route tracking for the app.\n */\nexport function AppRouter(props: AppRouterProps) {\n const { Router: RouterComponent, SignInPage: SignInPageComponent } =\n useApp().getComponents();\n\n const configApi = useApi(configApiRef);\n const basePath = readBasePath(configApi);\n const mountPath = `${basePath}/*`;\n const internalAppContext = useContext(InternalAppContext);\n if (!internalAppContext) {\n throw new Error('AppRouter must be rendered within the AppProvider');\n }\n const { routeObjects, appIdentityProxy } = internalAppContext;\n\n // If the app hasn't configured a sign-in page, we just continue as guest.\n if (!SignInPageComponent) {\n appIdentityProxy.setTarget(\n {\n getUserId: () => 'guest',\n getIdToken: async () => undefined,\n getProfile: () => ({\n email: 'guest@example.com',\n displayName: 'Guest',\n }),\n getProfileInfo: async () => ({\n email: 'guest@example.com',\n displayName: 'Guest',\n }),\n getBackstageIdentity: async () => ({\n type: 'user',\n userEntityRef: 'user:default/guest',\n ownershipEntityRefs: ['user:default/guest'],\n }),\n getCredentials: async () => ({}),\n signOut: async () => {},\n },\n { signOutTargetUrl: basePath || '/' },\n );\n\n if (isReactRouterBeta()) {\n return (\n <RouterComponent>\n <RouteTracker routeObjects={routeObjects} />\n <Routes>\n <Route path={mountPath} element={<>{props.children}</>} />\n </Routes>\n </RouterComponent>\n );\n }\n\n return (\n <RouterComponent basename={basePath}>\n <RouteTracker routeObjects={routeObjects} />\n {props.children}\n </RouterComponent>\n );\n }\n\n if (isReactRouterBeta()) {\n return (\n <RouterComponent>\n <RouteTracker routeObjects={routeObjects} />\n <SignInPageWrapper\n component={SignInPageComponent}\n appIdentityProxy={appIdentityProxy}\n >\n <Routes>\n <Route path={mountPath} element={<>{props.children}</>} />\n </Routes>\n </SignInPageWrapper>\n </RouterComponent>\n );\n }\n\n return (\n <RouterComponent basename={basePath}>\n <RouteTracker routeObjects={routeObjects} />\n <SignInPageWrapper\n component={SignInPageComponent}\n appIdentityProxy={appIdentityProxy}\n >\n {props.children}\n </SignInPageWrapper>\n </RouterComponent>\n );\n}\n\nattachComponentData(AppRouter, 'core.type', 'AppRouter');\n"],"names":[],"mappings":";;;;;;;;AAqCO,SAAS,YAAY,SAAsB,EAAA;AAChD,EAAI,IAAA,CAAC,mBAAqB,EAAA;AAGxB,IAAO,OAAA,EAAA;AAAA;AAGT,EAAA,OAAO,aAAa,SAAS,CAAA;AAC/B;AAOA,SAAS,aAAa,SAAsB,EAAA;AAC1C,EAAI,IAAA,EAAE,QAAS,EAAA,GAAI,IAAI,GAAA;AAAA,IACrB,SAAA,CAAU,iBAAkB,CAAA,aAAa,CAAK,IAAA,GAAA;AAAA,IAC9C;AAAA;AAAA,GACF;AACA,EAAW,QAAA,GAAA,QAAA,CAAS,OAAQ,CAAA,MAAA,EAAQ,EAAE,CAAA;AACtC,EAAO,OAAA,QAAA;AACT;AAGA,SAAS,iBAAkB,CAAA;AAAA,EACzB,SAAW,EAAA,SAAA;AAAA,EACX,gBAAA;AAAA,EACA;AACF,CAIG,EAAA;AACD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAsB,EAAA;AAC5D,EAAM,MAAA,SAAA,GAAY,OAAO,YAAY,CAAA;AACrC,EAAM,MAAA,QAAA,GAAW,aAAa,SAAS,CAAA;AAEvC,EAAA,IAAI,CAAC,WAAa,EAAA;AAChB,I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AA,EAAU,QACzB,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,gBAAa,YAA4B,EAAA,CAAA;AAAA,oBAC1C,GAAA;AAAA,MAAC,iBAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAA,mBAAA;AAAA,QACX,gBAAA;AAAA,QAEC,QAAM,EAAA,KAAA,CAAA;AAAA;AAAA;AACT,GACF,EAAA,CAAA;AAEJ;AAEA,mBAAoB,CAAA,SAAA,EAAW,aAAa,WAAW,CAAA;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo, useState, useEffect } from 'react';
|
|
2
3
|
import { useApi, appThemeApiRef } from '@backstage/core-plugin-api';
|
|
3
4
|
import useObservable from 'react-use/esm/useObservable';
|
|
4
5
|
|
|
@@ -53,7 +54,7 @@ function AppThemeProvider({ children }) {
|
|
|
53
54
|
if (!appTheme) {
|
|
54
55
|
throw new Error("App has no themes");
|
|
55
56
|
}
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ jsx(appTheme.Provider, { children });
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
export { AppThemeProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppThemeProvider.esm.js","sources":["../../src/app/AppThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 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
|
|
1
|
+
{"version":3,"file":"AppThemeProvider.esm.js","sources":["../../src/app/AppThemeProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 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, useEffect, useState, PropsWithChildren } from 'react';\nimport { useApi, appThemeApiRef, AppTheme } from '@backstage/core-plugin-api';\nimport useObservable from 'react-use/esm/useObservable';\n\n// This tries to find the most accurate match, but also falls back to less\n// accurate results in order to avoid errors.\nfunction resolveTheme(\n themeId: string | undefined,\n shouldPreferDark: boolean,\n themes: AppTheme[],\n) {\n if (themeId !== undefined) {\n const selectedTheme = themes.find(theme => theme.id === themeId);\n if (selectedTheme) {\n return selectedTheme;\n }\n }\n\n if (shouldPreferDark) {\n const darkTheme = themes.find(theme => theme.variant === 'dark');\n if (darkTheme) {\n return darkTheme;\n }\n }\n\n const lightTheme = themes.find(theme => theme.variant === 'light');\n if (lightTheme) {\n return lightTheme;\n }\n\n return themes[0];\n}\n\nconst useShouldPreferDarkTheme = () => {\n const mediaQuery = useMemo(\n () => window.matchMedia('(prefers-color-scheme: dark)'),\n [],\n );\n const [shouldPreferDark, setPrefersDark] = useState(mediaQuery.matches);\n\n useEffect(() => {\n const listener = (event: MediaQueryListEvent) => {\n setPrefersDark(event.matches);\n };\n mediaQuery.addListener(listener);\n return () => {\n mediaQuery.removeListener(listener);\n };\n }, [mediaQuery]);\n\n return shouldPreferDark;\n};\n\nexport function AppThemeProvider({ children }: PropsWithChildren<{}>) {\n const appThemeApi = useApi(appThemeApiRef);\n const themeId = useObservable(\n appThemeApi.activeThemeId$(),\n appThemeApi.getActiveThemeId(),\n );\n\n // Browser feature detection won't change over time, so ignore lint rule\n const shouldPreferDark = Boolean(window.matchMedia)\n ? useShouldPreferDarkTheme() // eslint-disable-line react-hooks/rules-of-hooks\n : false;\n\n const appTheme = resolveTheme(\n themeId,\n shouldPreferDark,\n appThemeApi.getInstalledThemes(),\n );\n if (!appTheme) {\n throw new Error('App has no themes');\n }\n\n return <appTheme.Provider children={children} />;\n}\n"],"names":[],"mappings":";;;;;AAsBA,SAAS,YAAA,CACP,OACA,EAAA,gBAAA,EACA,MACA,EAAA;AACA,EAAA,IAAI,YAAY,KAAW,CAAA,EAAA;AACzB,IAAA,MAAM,gBAAgB,MAAO,CAAA,IAAA,CAAK,CAAS,KAAA,KAAA,KAAA,CAAM,OAAO,OAAO,CAAA;AAC/D,IAAA,IAAI,aAAe,EAAA;AACjB,MAAO,OAAA,aAAA;AAAA;AACT;AAGF,EAAA,IAAI,gBAAkB,EAAA;AACpB,IAAA,MAAM,YAAY,MAAO,CAAA,IAAA,CAAK,CAAS,KAAA,KAAA,KAAA,CAAM,YAAY,MAAM,CAAA;AAC/D,IAAA,IAAI,SAAW,EAAA;AACb,MAAO,OAAA,SAAA;AAAA;AACT;AAGF,EAAA,MAAM,aAAa,MAAO,CAAA,IAAA,CAAK,CAAS,KAAA,KAAA,KAAA,CAAM,YAAY,OAAO,CAAA;AACjE,EAAA,IAAI,UAAY,EAAA;AACd,IAAO,OAAA,UAAA;AAAA;AAGT,EAAA,OAAO,OAAO,CAAC,CAAA;AACjB;AAEA,MAAM,2BAA2B,MAAM;AACrC,EAAA,MAAM,UAAa,GAAA,OAAA;AAAA,IACjB,MAAM,MAAO,CAAA,UAAA,CAAW,8BAA8B,CAAA;AAAA,IACtD;AAAC,GACH;AACA,EAAA,MAAM,CAAC,gBAAkB,EAAA,cAAc,CAAI,GAAA,QAAA,CAAS,WAAW,OAAO,CAAA;AAEtE,EAAA,SAAA,CAAU,MAAM;AACd,IAAM,MAAA,QAAA,GAAW,CAAC,KAA+B,KAAA;AAC/C,MAAA,cAAA,CAAe,MAAM,OAAO,CAAA;AAAA,KAC9B;AACA,IAAA,UAAA,CAAW,YAAY,QAAQ,CAAA;AAC/B,IAAA,OAAO,MAAM;AACX,MAAA,UAAA,CAAW,eAAe,QAAQ,CAAA;AAAA,KACpC;AAAA,GACF,EAAG,CAAC,UAAU,CAAC,CAAA;AAEf,EAAO,OAAA,gBAAA;AACT,CAAA;AAEgB,SAAA,gBAAA,CAAiB,EAAE,QAAA,EAAmC,EAAA;AACpE,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA;AACzC,EAAA,MAAM,OAAU,GAAA,aAAA;AAAA,IACd,YAAY,cAAe,EAAA;AAAA,IAC3B,YAAY,gBAAiB;AAAA,GAC/B;AAGA,EAAA,MAAM,mBAAmB,OAAQ,CAAA,MAAA,CAAO,UAAU,CAAA,GAC9C,0BACA,GAAA,KAAA;AAEJ,EAAA,MAAM,QAAW,GAAA,YAAA;AAAA,IACf,OAAA;AAAA,IACA,gBAAA;AAAA,IACA,YAAY,kBAAmB;AAAA,GACjC;AACA,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAM,MAAA,IAAI,MAAM,mBAAmB,CAAA;AAAA;AAGrC,EAAA,uBAAQ,GAAA,CAAA,QAAA,CAAS,QAAT,EAAA,EAAkB,QAAoB,EAAA,CAAA;AAChD;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { createRoutesFromChildren, Route } from 'react-router-dom';
|
|
3
3
|
|
|
4
4
|
function isReactRouterBeta() {
|
|
5
|
-
const [obj] = createRoutesFromChildren(/* @__PURE__ */
|
|
5
|
+
const [obj] = createRoutesFromChildren(/* @__PURE__ */ jsx(Route, { index: true, element: /* @__PURE__ */ jsx("div", {}) }));
|
|
6
6
|
return !obj.index;
|
|
7
7
|
}
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isReactRouterBeta.esm.js","sources":["../../src/app/isReactRouterBeta.tsx"],"sourcesContent":["/*\n * Copyright 2022 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
|
|
1
|
+
{"version":3,"file":"isReactRouterBeta.esm.js","sources":["../../src/app/isReactRouterBeta.tsx"],"sourcesContent":["/*\n * Copyright 2022 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 { createRoutesFromChildren, Route } from 'react-router-dom';\n\nexport function isReactRouterBeta(): boolean {\n const [obj] = createRoutesFromChildren(<Route index element={<div />} />);\n return !obj.index;\n}\n"],"names":[],"mappings":";;;AAkBO,SAAS,iBAA6B,GAAA;AAC3C,EAAA,MAAM,CAAC,GAAG,CAAI,GAAA,wBAAA,iBAA0B,GAAA,CAAA,KAAA,EAAA,EAAM,KAAK,EAAA,IAAA,EAAC,OAAS,kBAAA,GAAA,CAAC,KAAI,EAAA,EAAA,CAAA,EAAI,CAAE,CAAA;AACxE,EAAA,OAAO,CAAC,GAAI,CAAA,KAAA;AACd;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode, PropsWithChildren, ComponentType } from 'react';
|
|
2
3
|
import PropTypes from 'prop-types';
|
|
3
4
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
5
|
import { ApiHolder, ApiRef, ApiFactory, AnyApiRef, OAuthRequestApi, DiscoveryApi, AuthProviderInfo, ConfigApi, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, OAuthApi, OpenIdConnectApi, ProfileInfoApi, BackstageIdentityApi, SessionApi, SessionState, AuthRequestOptions, BackstageIdentityResponse, ProfileInfo, oktaAuthApiRef, microsoftAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, atlassianAuthApiRef, vmwareCloudAuthApiRef, AlertApi, AlertMessage, AnalyticsApi, AnalyticsEvent, AppThemeApi, AppTheme, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlagsApi, FeatureFlag, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthRequesterOptions, OAuthRequester, PendingOAuthRequest, StorageApi, StorageValueSnapshot, BackstagePlugin, IconComponent, ExternalRouteRef, AnyApiFactory, RouteRef, SubRouteRef } from '@backstage/core-plugin-api';
|
|
@@ -22,7 +23,7 @@ type ApiProviderProps = {
|
|
|
22
23
|
* @public
|
|
23
24
|
*/
|
|
24
25
|
declare const ApiProvider: {
|
|
25
|
-
(props: PropsWithChildren<ApiProviderProps>):
|
|
26
|
+
(props: PropsWithChildren<ApiProviderProps>): react_jsx_runtime.JSX.Element;
|
|
26
27
|
propTypes: {
|
|
27
28
|
apis: PropTypes.Validator<NonNullable<PropTypes.InferProps<{
|
|
28
29
|
get: PropTypes.Validator<(...args: any[]) => any>;
|
|
@@ -680,7 +681,7 @@ interface AppRouterProps {
|
|
|
680
681
|
* the sign-in page. Once the user has signed-in, it will instead render
|
|
681
682
|
* the app, while providing routing and route tracking for the app.
|
|
682
683
|
*/
|
|
683
|
-
declare function AppRouter(props: AppRouterProps):
|
|
684
|
+
declare function AppRouter(props: AppRouterProps): react_jsx_runtime.JSX.Element;
|
|
684
685
|
|
|
685
686
|
/**
|
|
686
687
|
* Props for the `BootErrorPage` component of {@link AppComponents}.
|
|
@@ -1074,6 +1075,6 @@ type FeatureFlaggedProps = {
|
|
|
1074
1075
|
*
|
|
1075
1076
|
* @public
|
|
1076
1077
|
*/
|
|
1077
|
-
declare const FeatureFlagged: (props: FeatureFlaggedProps) =>
|
|
1078
|
+
declare const FeatureFlagged: (props: FeatureFlaggedProps) => react_jsx_runtime.JSX.Element;
|
|
1078
1079
|
|
|
1079
1080
|
export { AlertApiForwarder, type ApiFactoryHolder, ApiFactoryRegistry, type ApiFactoryScope, ApiProvider, type ApiProviderProps, ApiResolver, type AppComponents, type AppConfigLoader, type AppContext, type AppIcons, type AppOptions, type AppRouteBinder, AppRouter, type AppRouterProps, AppThemeSelector, AtlassianAuth, type AuthApiCreateOptions, type BackstageApp, BitbucketAuth, BitbucketServerAuth, type BitbucketServerSession, type BitbucketSession, type BootErrorPageProps, ErrorAlerter, ErrorApiForwarder, type ErrorBoundaryFallbackProps, FeatureFlagged, type FeatureFlaggedProps, type FetchMiddleware, FetchMiddlewares, FlatRoutes, type FlatRoutesProps, FrontendHostDiscovery, GithubAuth, GitlabAuth, GoogleAuth, LocalStorageFeatureFlags, MicrosoftAuth, MultipleAnalyticsApi, NoOpAnalyticsApi, OAuth2, type OAuth2CreateOptions, type OAuth2Session, type OAuthApiCreateOptions, OAuthRequestManager, OktaAuth, OneLoginAuth, type OneLoginAuthCreateOptions, type PopupOptions, SamlAuth, type SignInPageProps, UnhandledErrorForwarder, UrlPatternDiscovery, VMwareCloudAuth, WebStorage, createFetchApi, createSpecializedApp, defaultConfigLoader };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
1
2
|
import { attachComponentData, useApi, featureFlagsApiRef } from '@backstage/core-plugin-api';
|
|
2
|
-
import React from 'react';
|
|
3
3
|
|
|
4
4
|
const FeatureFlagged = (props) => {
|
|
5
5
|
const { children } = props;
|
|
6
6
|
const featureFlagApi = useApi(featureFlagsApiRef);
|
|
7
7
|
const isEnabled = "with" in props ? featureFlagApi.isActive(props.with) : !featureFlagApi.isActive(props.without);
|
|
8
|
-
return /* @__PURE__ */
|
|
8
|
+
return /* @__PURE__ */ jsx(Fragment, { children: isEnabled ? children : null });
|
|
9
9
|
};
|
|
10
10
|
attachComponentData(FeatureFlagged, "core.featureFlagged", true);
|
|
11
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeatureFlagged.esm.js","sources":["../../src/routing/FeatureFlagged.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 featureFlagsApiRef,\n useApi,\n attachComponentData,\n} from '@backstage/core-plugin-api';\nimport
|
|
1
|
+
{"version":3,"file":"FeatureFlagged.esm.js","sources":["../../src/routing/FeatureFlagged.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 featureFlagsApiRef,\n useApi,\n attachComponentData,\n} from '@backstage/core-plugin-api';\nimport { ReactNode } from 'react';\n\n/**\n * Props for the {@link FeatureFlagged} component.\n *\n * @public\n */\nexport type FeatureFlaggedProps = { children: ReactNode } & (\n | { with: string }\n | { without: string }\n);\n\n/**\n * Enables or disables rendering of its children based on the state of a given\n * feature flag.\n *\n * @public\n */\nexport const FeatureFlagged = (props: FeatureFlaggedProps) => {\n const { children } = props;\n const featureFlagApi = useApi(featureFlagsApiRef);\n const isEnabled =\n 'with' in props\n ? featureFlagApi.isActive(props.with)\n : !featureFlagApi.isActive(props.without);\n return <>{isEnabled ? children : null}</>;\n};\n\nattachComponentData(FeatureFlagged, 'core.featureFlagged', true);\n"],"names":[],"mappings":";;;AAuCa,MAAA,cAAA,GAAiB,CAAC,KAA+B,KAAA;AAC5D,EAAM,MAAA,EAAE,UAAa,GAAA,KAAA;AACrB,EAAM,MAAA,cAAA,GAAiB,OAAO,kBAAkB,CAAA;AAChD,EAAA,MAAM,SACJ,GAAA,MAAA,IAAU,KACN,GAAA,cAAA,CAAe,QAAS,CAAA,KAAA,CAAM,IAAI,CAAA,GAClC,CAAC,cAAA,CAAe,QAAS,CAAA,KAAA,CAAM,OAAO,CAAA;AAC5C,EAAO,uBAAA,GAAA,CAAA,QAAA,EAAA,EAAG,QAAY,EAAA,SAAA,GAAA,QAAA,GAAW,IAAK,EAAA,CAAA;AACxC;AAEA,mBAAoB,CAAA,cAAA,EAAgB,uBAAuB,IAAI,CAAA;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'react';
|
|
2
3
|
import { useRoutes } from 'react-router-dom';
|
|
3
4
|
import { attachComponentData, useApp, useElementFilter } from '@backstage/core-plugin-api';
|
|
4
5
|
import { isReactRouterBeta } from '../app/isReactRouterBeta.esm.js';
|
|
@@ -48,7 +49,7 @@ const FlatRoutes = (props) => {
|
|
|
48
49
|
...routes,
|
|
49
50
|
{
|
|
50
51
|
path: "*",
|
|
51
|
-
element: /* @__PURE__ */
|
|
52
|
+
element: /* @__PURE__ */ jsx(NotFoundErrorPage, {})
|
|
52
53
|
}
|
|
53
54
|
];
|
|
54
55
|
return useRoutes(withNotFound);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FlatRoutes.esm.js","sources":["../../src/routing/FlatRoutes.tsx"],"sourcesContent":["/*\n * Copyright 2020 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
|
|
1
|
+
{"version":3,"file":"FlatRoutes.esm.js","sources":["../../src/routing/FlatRoutes.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { ReactNode, useMemo } from 'react';\nimport { useRoutes } from 'react-router-dom';\nimport {\n attachComponentData,\n useApp,\n useElementFilter,\n} from '@backstage/core-plugin-api';\nimport { isReactRouterBeta } from '../app/isReactRouterBeta';\n\nlet warned = false;\n\ntype RouteObject = {\n path: string;\n element: ReactNode;\n children?: RouteObject[];\n};\n\n/**\n * Props for the {@link FlatRoutes} component.\n *\n * @public\n */\nexport type FlatRoutesProps = {\n children: ReactNode;\n};\n\n/**\n * A wrapper around a set of routes.\n *\n * @remarks\n *\n * The root of the routing hierarchy in your app should use this component,\n * instead of the one from `react-router-dom`. This ensures that all of the\n * plugin route and utility API wiring happens under the hood.\n *\n * @public\n */\nexport const FlatRoutes = (props: FlatRoutesProps): JSX.Element | null => {\n const app = useApp();\n const { NotFoundErrorPage } = app.getComponents();\n const isBeta = useMemo(() => isReactRouterBeta(), []);\n const routes = useElementFilter(props.children, elements =>\n elements\n .getElements<{\n path?: string;\n element?: ReactNode;\n children?: ReactNode;\n }>()\n .flatMap<RouteObject>(child => {\n let path = child.props.path;\n\n // TODO(Rugvip): Work around plugins registering empty paths, remove once deprecated routes are gone\n if (path === '') {\n return [];\n }\n path = path?.replace(/\\/\\*$/, '') ?? '/';\n\n let element = isBeta ? child : child.props.element;\n if (!isBeta && !element) {\n element = child;\n if (!warned && process.env.NODE_ENV !== 'test') {\n // eslint-disable-next-line no-console\n console.warn(\n 'DEPRECATION WARNING: All elements within <FlatRoutes> must be of type <Route> with an element prop. ' +\n 'Existing usages of <Navigate key=[path] to=[to] /> should be replaced with <Route path=[path] element={<Navigate to=[to] />} />.',\n );\n warned = true;\n }\n }\n\n return [\n {\n // Each route matches any sub route, except for the explicit root path\n path,\n element,\n children: child.props.children\n ? [\n // These are the children of each route, which we all add in under a catch-all\n // subroute in order to make them available to `useOutlet`\n {\n path: path === '/' ? '/' : '*', // The root path must require an exact match\n element: child.props.children,\n },\n ]\n : undefined,\n },\n ];\n })\n // Routes are sorted to work around a bug where prefixes are unexpectedly matched\n // TODO(Rugvip): This can be removed once react-router v6 beta is no longer supported\n .sort((a, b) => b.path.localeCompare(a.path))\n .map(obj => ({ ...obj, path: obj.path === '/' ? '/' : `${obj.path}/*` })),\n );\n\n // TODO(Rugvip): Possibly add a way to skip this, like a noNotFoundPage prop\n const withNotFound = [\n ...routes,\n {\n path: '*',\n element: <NotFoundErrorPage />,\n },\n ];\n\n return useRoutes(withNotFound);\n};\n\nattachComponentData(FlatRoutes, 'core.type', 'FlatRoutes');\n"],"names":[],"mappings":";;;;;;AAyBA,IAAI,MAAS,GAAA,KAAA;AA4BA,MAAA,UAAA,GAAa,CAAC,KAA+C,KAAA;AACxE,EAAA,MAAM,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,CAAM,KAAA,CAAA,CAAE,IAAK,CAAA,aAAA,CAAc,CAAE,CAAA,IAAI,CAAC,CAAA,CAC3C,GAAI,CAAA,CAAA,GAAA,MAAQ,EAAE,GAAG,GAAK,EAAA,IAAA,EAAM,GAAI,CAAA,IAAA,KAAS,GAAM,GAAA,GAAA,GAAM,CAAG,EAAA,GAAA,CAAI,IAAI,CAAA,EAAA,CAAA,EAAO,CAAA;AAAA,GAC5E;AAGA,EAAA,MAAM,YAAe,GAAA;AAAA,IACnB,GAAG,MAAA;AAAA,IACH;AAAA,MACE,IAAM,EAAA,GAAA;AAAA,MACN,OAAA,sBAAU,iBAAkB,EAAA,EAAA;AAAA;AAC9B,GACF;AAEA,EAAA,OAAO,UAAU,YAAY,CAAA;AAC/B;AAEA,mBAAoB,CAAA,UAAA,EAAY,aAAa,YAAY,CAAA;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useEffect } from 'react';
|
|
2
3
|
import { useLocation, matchRoutes } from 'react-router-dom';
|
|
3
4
|
import { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';
|
|
4
5
|
|
|
@@ -62,7 +63,7 @@ const RouteTracker = ({
|
|
|
62
63
|
pathname,
|
|
63
64
|
routeObjects
|
|
64
65
|
) || { params: {} };
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
+
return /* @__PURE__ */ jsx(AnalyticsContext, { attributes, children: /* @__PURE__ */ jsx(
|
|
66
67
|
TrackNavigation,
|
|
67
68
|
{
|
|
68
69
|
pathname,
|
|
@@ -70,7 +71,7 @@ const RouteTracker = ({
|
|
|
70
71
|
hash,
|
|
71
72
|
attributes: params
|
|
72
73
|
}
|
|
73
|
-
));
|
|
74
|
+
) });
|
|
74
75
|
};
|
|
75
76
|
|
|
76
77
|
export { RouteTracker };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteTracker.esm.js","sources":["../../src/routing/RouteTracker.tsx"],"sourcesContent":["/*\n * Copyright 2021 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
|
|
1
|
+
{"version":3,"file":"RouteTracker.esm.js","sources":["../../src/routing/RouteTracker.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 { useEffect } from 'react';\nimport { matchRoutes, useLocation } from 'react-router-dom';\nimport {\n useAnalytics,\n AnalyticsContext,\n RouteRef,\n AnalyticsEventAttributes,\n BackstagePlugin,\n} from '@backstage/core-plugin-api';\nimport { BackstageRouteObject } from './types';\n\n/**\n * Returns an extension context given the current pathname and a list of\n * Backstage route objects.\n */\nconst getExtensionContext = (\n pathname: string,\n routes: BackstageRouteObject[],\n) => {\n try {\n // Find matching routes for the given path name.\n const matches = matchRoutes(routes, { pathname });\n\n // Of the matching routes, get the last (e.g. most specific) instance of\n // the BackstageRouteObject that contains a routeRef. Filtering by routeRef\n // ensures subRouteRefs are aligned to their parent routes' context.\n const routeMatch = matches\n ?.filter(match => match?.route.routeRefs?.size > 0)\n .pop();\n const routeObject = routeMatch?.route;\n\n // If there is no route object, then allow inheritance of default context.\n if (!routeObject) {\n return undefined;\n }\n\n // If the matched route is the root route (no path), and the pathname is\n // not the path of the homepage, then inherit from the default context.\n if (routeObject.path === '' && pathname !== '/') {\n return undefined;\n }\n\n // If there is a single route ref, use it.\n let routeRef: RouteRef | undefined;\n if (routeObject.routeRefs.size === 1) {\n routeRef = routeObject.routeRefs.values().next().value;\n }\n\n // If there is a single plugin, use it.\n let plugin: BackstagePlugin | undefined;\n if (routeObject.plugins.size === 1) {\n plugin = routeObject.plugins.values().next().value;\n }\n\n const params = Object.entries(\n routeMatch?.params || {},\n ).reduce<AnalyticsEventAttributes>((acc, [key, value]) => {\n if (value !== undefined && key !== '*') {\n acc[key] = value;\n }\n return acc;\n }, {});\n\n return {\n extension: 'App',\n pluginId: plugin?.getId() || 'root',\n ...(routeRef ? { routeRef: (routeRef as { id?: string }).id } : {}),\n _routeNodeType: routeObject.element as string,\n params,\n };\n } catch {\n return undefined;\n }\n};\n\n/**\n * Performs the actual event capture on render.\n */\nconst TrackNavigation = ({\n pathname,\n search,\n hash,\n attributes,\n}: {\n pathname: string;\n search: string;\n hash: string;\n attributes?: AnalyticsEventAttributes;\n}) => {\n const analytics = useAnalytics();\n useEffect(() => {\n analytics.captureEvent('navigate', `${pathname}${search}${hash}`, {\n attributes,\n });\n }, [analytics, pathname, search, hash, attributes]);\n\n return null;\n};\n\n/**\n * Logs a \"navigate\" event with appropriate plugin-level analytics context\n * attributes each time the user navigates to a page.\n */\nexport const RouteTracker = ({\n routeObjects,\n}: {\n routeObjects: BackstageRouteObject[];\n}) => {\n const { pathname, search, hash } = useLocation();\n\n const { params, ...attributes } = getExtensionContext(\n pathname,\n routeObjects,\n ) || { params: {} };\n\n return (\n <AnalyticsContext attributes={attributes}>\n <TrackNavigation\n pathname={pathname}\n search={search}\n hash={hash}\n attributes={params}\n />\n </AnalyticsContext>\n );\n};\n"],"names":[],"mappings":";;;;;AA+BA,MAAM,mBAAA,GAAsB,CAC1B,QAAA,EACA,MACG,KAAA;AACH,EAAI,IAAA;AAEF,IAAA,MAAM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} from '@backstage/version-bridge';
|
|
3
3
|
import { RouteResolver } from './RouteResolver.esm.js';
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ const RoutingProvider = ({
|
|
|
21
21
|
basePath
|
|
22
22
|
);
|
|
23
23
|
const versionedValue = createVersionedValueMap({ 1: resolver });
|
|
24
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ jsx(RoutingContext.Provider, { value: versionedValue, children });
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export { RoutingProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RoutingProvider.esm.js","sources":["../../src/routing/RoutingProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 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
|
|
1
|
+
{"version":3,"file":"RoutingProvider.esm.js","sources":["../../src/routing/RoutingProvider.tsx"],"sourcesContent":["/*\n * Copyright 2020 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 { ReactNode } from 'react';\nimport {\n ExternalRouteRef,\n RouteRef,\n SubRouteRef,\n} from '@backstage/core-plugin-api';\nimport {\n createVersionedValueMap,\n createVersionedContext,\n} from '@backstage/version-bridge';\nimport { RouteResolver } from './RouteResolver';\nimport { BackstageRouteObject } from './types';\n\nconst RoutingContext = createVersionedContext<{ 1: RouteResolver }>(\n 'routing-context',\n);\n\ntype ProviderProps = {\n routePaths: Map<RouteRef, string>;\n routeParents: Map<RouteRef, RouteRef | undefined>;\n routeObjects: BackstageRouteObject[];\n routeBindings: Map<ExternalRouteRef, RouteRef | SubRouteRef>;\n basePath?: string;\n children: ReactNode;\n};\n\nexport const RoutingProvider = ({\n routePaths,\n routeParents,\n routeObjects,\n routeBindings,\n basePath = '',\n children,\n}: ProviderProps) => {\n const resolver = new RouteResolver(\n routePaths,\n routeParents,\n routeObjects,\n routeBindings,\n basePath,\n );\n\n const versionedValue = createVersionedValueMap({ 1: resolver });\n return (\n <RoutingContext.Provider value={versionedValue}>\n {children}\n </RoutingContext.Provider>\n );\n};\n"],"names":[],"mappings":";;;;AA6BA,MAAM,cAAiB,GAAA,sBAAA;AAAA,EACrB;AACF,CAAA;AAWO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAW,GAAA,EAAA;AAAA,EACX;AACF,CAAqB,KAAA;AACnB,EAAA,MAAM,WAAW,IAAI,aAAA;AAAA,IACnB,UAAA;AAAA,IACA,YAAA;AAAA,IACA,YAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,cAAiB,GAAA,uBAAA,CAAwB,EAAE,CAAA,EAAG,UAAU,CAAA;AAC9D,EAAA,2BACG,cAAe,CAAA,QAAA,EAAf,EAAwB,KAAA,EAAO,gBAC7B,QACH,EAAA,CAAA;AAEJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/core-app-api",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Core app API used by Backstage apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library"
|
|
@@ -29,6 +29,13 @@
|
|
|
29
29
|
},
|
|
30
30
|
"main": "./dist/index.esm.js",
|
|
31
31
|
"types": "./dist/index.d.ts",
|
|
32
|
+
"typesVersions": {
|
|
33
|
+
"*": {
|
|
34
|
+
"package.json": [
|
|
35
|
+
"package.json"
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
},
|
|
32
39
|
"files": [
|
|
33
40
|
"dist",
|
|
34
41
|
"config.d.ts"
|
|
@@ -44,7 +51,7 @@
|
|
|
44
51
|
},
|
|
45
52
|
"dependencies": {
|
|
46
53
|
"@backstage/config": "^1.3.2",
|
|
47
|
-
"@backstage/core-plugin-api": "^1.10.
|
|
54
|
+
"@backstage/core-plugin-api": "^1.10.6",
|
|
48
55
|
"@backstage/types": "^1.2.1",
|
|
49
56
|
"@backstage/version-bridge": "^1.0.11",
|
|
50
57
|
"@types/prop-types": "^15.7.3",
|
|
@@ -57,8 +64,8 @@
|
|
|
57
64
|
"zod": "^3.22.4"
|
|
58
65
|
},
|
|
59
66
|
"devDependencies": {
|
|
60
|
-
"@backstage/cli": "^0.
|
|
61
|
-
"@backstage/test-utils": "^1.7.
|
|
67
|
+
"@backstage/cli": "^0.32.0",
|
|
68
|
+
"@backstage/test-utils": "^1.7.7",
|
|
62
69
|
"@testing-library/dom": "^10.0.0",
|
|
63
70
|
"@testing-library/jest-dom": "^6.0.0",
|
|
64
71
|
"@testing-library/react": "^16.0.0",
|