@backstage/core-app-api 1.8.0 → 1.8.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @backstage/core-app-api
2
2
 
3
+ ## 1.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 12adfbc8fe2d: Fixed a bug that prevented accurate plugin and route data from being applied to `navigate` analytics events when users visited pages constructed with `<EntityLayout>`, `<TabbedLayout>`, and similar components that are used to gather one or more routable extensions under a given path.
8
+ - ac677bc30ae0: Expose discovery.endpoints configuration to use FrontendHostDiscovery
9
+ - 74b216ee4e50: Add `PropsWithChildren` to usages of `ComponentType`, in preparation for React 18 where the children are no longer implicit.
10
+ - Updated dependencies
11
+ - @backstage/core-plugin-api@1.5.2
12
+ - @backstage/types@1.1.0
13
+ - @backstage/config@1.0.8
14
+ - @backstage/version-bridge@1.0.4
15
+
16
+ ## 1.8.1-next.0
17
+
18
+ ### Patch Changes
19
+
20
+ - 74b216ee4e50: Add `PropsWithChildren` to usages of `ComponentType`, in preparation for React 18 where the children are no longer implicit.
21
+ - Updated dependencies
22
+ - @backstage/core-plugin-api@1.5.2-next.0
23
+ - @backstage/config@1.0.7
24
+ - @backstage/types@1.0.2
25
+ - @backstage/version-bridge@1.0.4
26
+
3
27
  ## 1.8.0
4
28
 
5
29
  ### Minor Changes
package/config.d.ts CHANGED
@@ -117,9 +117,48 @@ export interface Config {
117
117
  };
118
118
 
119
119
  /**
120
- $ Enable redirect authentication flow type, instead of a popup for authentication
121
- * default value: 'false'
120
+ * Enable redirect authentication flow type, instead of a popup for authentication.
121
+ * @defaultValue false
122
122
  * @visibility frontend
123
123
  */
124
124
  enableExperimentalRedirectFlow?: boolean;
125
+
126
+ /**
127
+ * Discovery options.
128
+ *
129
+ * @visibility frontend
130
+ */
131
+ discovery?: {
132
+ /**
133
+ * Endpoints
134
+ *
135
+ * A list of target baseUrls and the associated plugins.
136
+ *
137
+ * @visibility frontend
138
+ */
139
+ endpoints?: Array<{
140
+ /**
141
+ * The target baseUrl to use for the plugin
142
+ *
143
+ * Can be either a string or an object with internal and external keys. (Internal is used for the backend, external for the frontend)
144
+ * Targets with `{{pluginId}}` or `{{ pluginId }} in the url will be replaced with the pluginId.
145
+ *
146
+ * @visibility frontend
147
+ */
148
+ target:
149
+ | string
150
+ | {
151
+ /**
152
+ * @visibility frontend
153
+ */
154
+ external: string;
155
+ };
156
+ /**
157
+ * Array of plugins which use the target baseUrl.
158
+ *
159
+ * @visibility frontend
160
+ */
161
+ plugins: Array<string>;
162
+ }>;
163
+ };
125
164
  }
package/dist/index.d.ts CHANGED
@@ -661,45 +661,45 @@ declare function AppRouter(props: AppRouterProps): JSX.Element;
661
661
  *
662
662
  * @public
663
663
  */
664
- type BootErrorPageProps = {
664
+ type BootErrorPageProps = PropsWithChildren<{
665
665
  step: 'load-config' | 'load-chunk';
666
666
  error: Error;
667
- };
667
+ }>;
668
668
  /**
669
669
  * Props for the `SignInPage` component of {@link AppComponents}.
670
670
  *
671
671
  * @public
672
672
  */
673
- type SignInPageProps = {
673
+ type SignInPageProps = PropsWithChildren<{
674
674
  /**
675
675
  * Set the IdentityApi on successful sign-in. This should only be called once.
676
676
  */
677
677
  onSignInSuccess(identityApi: IdentityApi): void;
678
- };
678
+ }>;
679
679
  /**
680
680
  * Props for the fallback error boundary.
681
681
  *
682
682
  * @public
683
683
  */
684
- type ErrorBoundaryFallbackProps = {
684
+ type ErrorBoundaryFallbackProps = PropsWithChildren<{
685
685
  plugin?: BackstagePlugin;
686
686
  error: Error;
687
687
  resetError: () => void;
688
- };
688
+ }>;
689
689
  /**
690
690
  * A set of replaceable core components that are part of every Backstage app.
691
691
  *
692
692
  * @public
693
693
  */
694
694
  type AppComponents = {
695
- NotFoundErrorPage: ComponentType<{}>;
695
+ NotFoundErrorPage: ComponentType<PropsWithChildren<{}>>;
696
696
  BootErrorPage: ComponentType<BootErrorPageProps>;
697
- Progress: ComponentType<{}>;
698
- Router: ComponentType<{
697
+ Progress: ComponentType<PropsWithChildren<{}>>;
698
+ Router: ComponentType<PropsWithChildren<{
699
699
  basename?: string;
700
- }>;
700
+ }>>;
701
701
  ErrorBoundaryFallback: ComponentType<ErrorBoundaryFallbackProps>;
702
- ThemeProvider?: ComponentType<{}>;
702
+ ThemeProvider?: ComponentType<PropsWithChildren<{}>>;
703
703
  /**
704
704
  * An optional sign-in page that will be rendered instead of the AppRouter at startup.
705
705
  *
@@ -841,21 +841,13 @@ type AppOptions = {
841
841
  * title: 'Light Theme',
842
842
  * variant: 'light',
843
843
  * icon: <LightIcon />,
844
- * Provider: ({ children }) => (
845
- * <ThemeProvider theme={lightTheme}>
846
- * <CssBaseline>{children}</CssBaseline>
847
- * </ThemeProvider>
848
- * ),
844
+ * Provider: ({ children }) => <UnifiedThemeProvider theme={themes.light} />,
849
845
  * }, {
850
846
  * id: 'dark',
851
847
  * title: 'Dark Theme',
852
848
  * variant: 'dark',
853
849
  * icon: <DarkIcon />,
854
- * Provider: ({ children }) => (
855
- * <ThemeProvider theme={darkTheme}>
856
- * <CssBaseline>{children}</CssBaseline>
857
- * </ThemeProvider>
858
- * ),
850
+ * Provider: ({ children }) => <UnifiedThemeProvider theme={themes.dark} />,
859
851
  * }]
860
852
  * ```
861
853
  */
@@ -929,21 +921,21 @@ type BackstageApp = {
929
921
  * );
930
922
  * ```
931
923
  */
932
- createRoot(element: JSX.Element): ComponentType<{}>;
924
+ createRoot(element: JSX.Element): ComponentType<PropsWithChildren<{}>>;
933
925
  /**
934
926
  * Provider component that should wrap the Router created with getRouter()
935
927
  * and any other components that need to be within the app context.
936
928
  *
937
929
  * @deprecated Use {@link BackstageApp.createRoot} instead.
938
930
  */
939
- getProvider(): ComponentType<{}>;
931
+ getProvider(): ComponentType<PropsWithChildren<{}>>;
940
932
  /**
941
933
  * Router component that should wrap the App Routes create with getRoutes()
942
934
  * and any other components that should only be available while signed in.
943
935
  *
944
936
  * @deprecated Import and use the {@link AppRouter} component from `@backstage/core-app-api` instead
945
937
  */
946
- getRouter(): ComponentType<{}>;
938
+ getRouter(): ComponentType<PropsWithChildren<{}>>;
947
939
  };
948
940
  /**
949
941
  * The central context providing runtime app specific state that plugin views
package/dist/index.esm.js CHANGED
@@ -2009,12 +2009,11 @@ function isReactRouterBeta() {
2009
2009
  }
2010
2010
 
2011
2011
  const getExtensionContext = (pathname, routes) => {
2012
- var _a;
2013
2012
  try {
2014
2013
  const matches = matchRoutes(routes, { pathname });
2015
2014
  const routeMatch = matches == null ? void 0 : matches.filter((match) => {
2016
- var _a2;
2017
- return ((_a2 = match == null ? void 0 : match.route.routeRefs) == null ? void 0 : _a2.size) > 0;
2015
+ var _a;
2016
+ return ((_a = match == null ? void 0 : match.route.routeRefs) == null ? void 0 : _a.size) > 0;
2018
2017
  }).pop();
2019
2018
  const routeObject = routeMatch == null ? void 0 : routeMatch.route;
2020
2019
  if (!routeObject) {
@@ -2024,6 +2023,10 @@ const getExtensionContext = (pathname, routes) => {
2024
2023
  if (routeObject.routeRefs.size === 1) {
2025
2024
  routeRef = routeObject.routeRefs.values().next().value;
2026
2025
  }
2026
+ let plugin;
2027
+ if (routeObject.plugins.size === 1) {
2028
+ plugin = routeObject.plugins.values().next().value;
2029
+ }
2027
2030
  const params = Object.entries(
2028
2031
  (routeMatch == null ? void 0 : routeMatch.params) || {}
2029
2032
  ).reduce((acc, [key, value]) => {
@@ -2034,8 +2037,9 @@ const getExtensionContext = (pathname, routes) => {
2034
2037
  }, {});
2035
2038
  return {
2036
2039
  extension: "App",
2037
- pluginId: ((_a = routeObject.plugin) == null ? void 0 : _a.getId()) || "root",
2040
+ pluginId: (plugin == null ? void 0 : plugin.getId()) || "root",
2038
2041
  ...routeRef ? { routeRef: routeRef.id } : {},
2042
+ _routeNodeType: routeObject.element,
2039
2043
  params
2040
2044
  };
2041
2045
  } catch {
@@ -2252,7 +2256,8 @@ const MATCH_ALL_ROUTE = {
2252
2256
  path: "*",
2253
2257
  element: "match-all",
2254
2258
  // These elements aren't used, so we add in a bit of debug information
2255
- routeRefs: /* @__PURE__ */ new Set()
2259
+ routeRefs: /* @__PURE__ */ new Set(),
2260
+ plugins: /* @__PURE__ */ new Set()
2256
2261
  };
2257
2262
  function stringifyNode(node) {
2258
2263
  var _a, _b;
@@ -2262,6 +2267,13 @@ function stringifyNode(node) {
2262
2267
  }
2263
2268
  return String(anyNode);
2264
2269
  }
2270
+ const pluginSet = (plugin) => {
2271
+ const set = /* @__PURE__ */ new Set();
2272
+ if (plugin) {
2273
+ set.add(plugin);
2274
+ }
2275
+ return set;
2276
+ };
2265
2277
  function collectSubTree(node, entries = new Array()) {
2266
2278
  Children.forEach(node, (element) => {
2267
2279
  if (!isValidElement(element)) {
@@ -2283,7 +2295,7 @@ const routingV2Collector = createCollector(
2283
2295
  objects: new Array()
2284
2296
  }),
2285
2297
  (acc, node, parent, ctx) => {
2286
- var _a, _b, _c, _d, _e, _f;
2298
+ var _a, _b, _c, _d, _e, _f, _g;
2287
2299
  if (ctx == null ? void 0 : ctx.isElementAncestor) {
2288
2300
  return ctx;
2289
2301
  }
@@ -2322,7 +2334,7 @@ const routingV2Collector = createCollector(
2322
2334
  routeRefs: /* @__PURE__ */ new Set(),
2323
2335
  caseSensitive: Boolean((_d = node.props) == null ? void 0 : _d.caseSensitive),
2324
2336
  children: [MATCH_ALL_ROUTE],
2325
- plugin: void 0
2337
+ plugins: /* @__PURE__ */ new Set()
2326
2338
  };
2327
2339
  parentChildren.push(newObj);
2328
2340
  return {
@@ -2349,7 +2361,7 @@ const routingV2Collector = createCollector(
2349
2361
  routeRefs: /* @__PURE__ */ new Set([routeRef]),
2350
2362
  caseSensitive: Boolean((_e = node.props) == null ? void 0 : _e.caseSensitive),
2351
2363
  children: [MATCH_ALL_ROUTE],
2352
- plugin
2364
+ plugins: pluginSet(plugin)
2353
2365
  };
2354
2366
  parentChildren.push(newObj);
2355
2367
  acc.paths.set(routeRef, path);
@@ -2371,6 +2383,13 @@ const routingV2Collector = createCollector(
2371
2383
  );
2372
2384
  }
2373
2385
  (_f = ctx == null ? void 0 : ctx.obj) == null ? void 0 : _f.routeRefs.add(mountPoint);
2386
+ const mountPointPlugin = getComponentData(
2387
+ node,
2388
+ "core.plugin"
2389
+ );
2390
+ if (mountPointPlugin) {
2391
+ (_g = ctx == null ? void 0 : ctx.obj) == null ? void 0 : _g.plugins.add(mountPointPlugin);
2392
+ }
2374
2393
  acc.paths.set(mountPoint, ctx.gatherPath);
2375
2394
  acc.parents.set(mountPoint, ctx == null ? void 0 : ctx.gatherRouteRef);
2376
2395
  return {
@@ -2440,9 +2459,11 @@ const routingV1Collector = createCollector(
2440
2459
  element: "mounted",
2441
2460
  routeRefs: /* @__PURE__ */ new Set([routeRef]),
2442
2461
  children: [MATCH_ALL_ROUTE],
2443
- plugin: getComponentData(
2444
- node.props.element,
2445
- "core.plugin"
2462
+ plugins: pluginSet(
2463
+ getComponentData(
2464
+ node.props.element,
2465
+ "core.plugin"
2466
+ )
2446
2467
  )
2447
2468
  };
2448
2469
  parentChildren.push(currentObj);
@@ -2468,7 +2489,7 @@ const routingV1Collector = createCollector(
2468
2489
  element: "gathered",
2469
2490
  routeRefs: /* @__PURE__ */ new Set(),
2470
2491
  children: [MATCH_ALL_ROUTE],
2471
- plugin: (_e = ctx == null ? void 0 : ctx.obj) == null ? void 0 : _e.plugin
2492
+ plugins: ((_e = ctx == null ? void 0 : ctx.obj) == null ? void 0 : _e.plugins) || /* @__PURE__ */ new Set()
2472
2493
  };
2473
2494
  parentChildren.push(currentObj);
2474
2495
  }