@backstage/frontend-app-api 0.3.0 → 0.3.1-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @backstage/frontend-app-api
2
2
 
3
+ ## 0.3.1-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 60d6eb544e: Removed `@backstage/plugin-graphiql` dependency.
8
+ - 9ad4039efa: Bringing over apis from core-plugin-api
9
+ - b8cb7804c8: Added `createSpecializedApp`, which is a synchronous version of `createApp` where config and features already need to be loaded.
10
+ - Updated dependencies
11
+ - @backstage/core-plugin-api@1.8.1-next.0
12
+ - @backstage/core-components@0.13.9-next.0
13
+ - @backstage/theme@0.5.0-next.0
14
+ - @backstage/frontend-plugin-api@0.3.1-next.0
15
+ - @backstage/core-app-api@1.11.2-next.0
16
+ - @backstage/config@1.1.1
17
+ - @backstage/types@1.1.1
18
+ - @backstage/version-bridge@1.0.7
19
+
3
20
  ## 0.3.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -70,5 +70,19 @@ declare function createApp(options?: {
70
70
  }): {
71
71
  createRoot(): JSX.Element;
72
72
  };
73
+ /**
74
+ * Synchronous version of {@link createApp}, expecting all features and
75
+ * config to have been loaded already.
76
+ * @public
77
+ */
78
+ declare function createSpecializedApp(options?: {
79
+ features?: (BackstagePlugin | ExtensionOverrides)[];
80
+ config?: ConfigApi;
81
+ bindRoutes?(context: {
82
+ bind: AppRouteBinder;
83
+ }): void;
84
+ }): {
85
+ createRoot(): JSX.Element;
86
+ };
73
87
 
74
- export { AppRouteBinder, ExtensionTree, ExtensionTreeNode, createApp, createExtensionTree };
88
+ export { AppRouteBinder, ExtensionTree, ExtensionTreeNode, createApp, createExtensionTree, createSpecializedApp };
package/dist/index.esm.js CHANGED
@@ -5,7 +5,7 @@ import { useRoutes, BrowserRouter, useInRouterContext, MemoryRouter, matchRoutes
5
5
  import { SidebarPage, sidebarConfig, Sidebar, SidebarDivider, useSidebarOpenState, Link, SidebarItem, Progress, ErrorPage, ErrorPanel } from '@backstage/core-components';
6
6
  import { makeStyles } from '@material-ui/core';
7
7
  import { useApi, appThemeApiRef, FeatureFlagState, createApiFactory, discoveryApiRef, configApiRef, alertApiRef, analyticsApiRef, errorApiRef, storageApiRef, fetchApiRef, identityApiRef, oauthRequestApiRef, googleAuthApiRef, microsoftAuthApiRef, githubAuthApiRef, oktaAuthApiRef, gitlabAuthApiRef, oneloginAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, atlassianAuthApiRef, attachComponentData, featureFlagsApiRef } from '@backstage/core-plugin-api';
8
- import { UrlPatternDiscovery, AlertApiForwarder, NoOpAnalyticsApi, ErrorAlerter, ErrorApiForwarder, UnhandledErrorForwarder, WebStorage, createFetchApi, FetchMiddlewares, OAuthRequestManager, GoogleAuth, MicrosoftAuth, GithubAuth, OktaAuth, GitlabAuth, OneLoginAuth, BitbucketAuth, BitbucketServerAuth, AtlassianAuth, ApiProvider, ApiFactoryRegistry, AppThemeSelector, ApiResolver } from '@backstage/core-app-api';
8
+ import { UrlPatternDiscovery, AlertApiForwarder, NoOpAnalyticsApi, ErrorAlerter, ErrorApiForwarder, UnhandledErrorForwarder, WebStorage, createFetchApi, FetchMiddlewares, OAuthRequestManager, GoogleAuth, MicrosoftAuth, GithubAuth, OktaAuth, GitlabAuth, OneLoginAuth, BitbucketAuth, BitbucketServerAuth, AtlassianAuth, ApiFactoryRegistry, AppThemeSelector, ApiResolver, ApiProvider } from '@backstage/core-app-api';
9
9
  import useObservable from 'react-use/lib/useObservable';
10
10
  import { createVersionedContext, createVersionedValueMap, getOrCreateGlobalSingleton } from '@backstage/version-bridge';
11
11
  import ObservableImpl from 'zen-observable';
@@ -1327,6 +1327,37 @@ const DarkTheme = createThemeExtension({
1327
1327
  Provider: ({ children }) => /* @__PURE__ */ React.createElement(UnifiedThemeProvider, { theme: themes.dark, children })
1328
1328
  });
1329
1329
 
1330
+ const legacyPluginStore = getOrCreateGlobalSingleton(
1331
+ "legacy-plugin-compatibility-store",
1332
+ () => /* @__PURE__ */ new WeakMap()
1333
+ );
1334
+ function toLegacyPlugin(plugin) {
1335
+ let legacy = legacyPluginStore.get(plugin);
1336
+ if (legacy) {
1337
+ return legacy;
1338
+ }
1339
+ const errorMsg = "Not implemented in legacy plugin compatibility layer";
1340
+ const notImplemented = () => {
1341
+ throw new Error(errorMsg);
1342
+ };
1343
+ legacy = {
1344
+ getId() {
1345
+ return plugin.id;
1346
+ },
1347
+ get routes() {
1348
+ return {};
1349
+ },
1350
+ get externalRoutes() {
1351
+ return {};
1352
+ },
1353
+ getApis: notImplemented,
1354
+ getFeatureFlags: notImplemented,
1355
+ provide: notImplemented
1356
+ };
1357
+ legacyPluginStore.set(plugin, legacy);
1358
+ return legacy;
1359
+ }
1360
+
1330
1361
  const MATCH_ALL_ROUTE = {
1331
1362
  caseSensitive: false,
1332
1363
  path: "*",
@@ -2274,35 +2305,16 @@ function createApp(options) {
2274
2305
  );
2275
2306
  const discoveredFeatures = getAvailableFeatures(config);
2276
2307
  const loadedFeatures = (_d = await ((_c = options == null ? void 0 : options.featureLoader) == null ? void 0 : _c.call(options, { config }))) != null ? _d : [];
2277
- const allFeatures = deduplicateFeatures([
2278
- ...discoveredFeatures,
2279
- ...loadedFeatures,
2280
- ...(_e = options == null ? void 0 : options.features) != null ? _e : []
2281
- ]);
2282
- const tree = createAppTree({
2283
- features: allFeatures,
2284
- builtinExtensions,
2285
- config
2286
- });
2287
- const appContext = createLegacyAppContext(
2288
- allFeatures.filter(
2289
- (f) => f.$$type === "@backstage/BackstagePlugin"
2290
- )
2291
- );
2292
- const routeIds = collectRouteIds(allFeatures);
2293
- const App = () => /* @__PURE__ */ React.createElement(ApiProvider, { apis: createApiHolder(tree, config) }, /* @__PURE__ */ React.createElement(AppContextProvider, { appContext }, /* @__PURE__ */ React.createElement(AppThemeProvider, null, /* @__PURE__ */ React.createElement(
2294
- RoutingProvider,
2295
- {
2296
- ...extractRouteInfoFromAppNode(tree.root),
2297
- routeBindings: resolveRouteBindings(
2298
- options == null ? void 0 : options.bindRoutes,
2299
- config,
2300
- routeIds
2301
- )
2302
- },
2303
- /* @__PURE__ */ React.createElement(BrowserRouter, null, tree.root.instance.getData(coreExtensionData.reactElement))
2304
- ))));
2305
- return { default: App };
2308
+ const app = createSpecializedApp({
2309
+ config,
2310
+ features: [
2311
+ ...discoveredFeatures,
2312
+ ...loadedFeatures,
2313
+ ...(_e = options == null ? void 0 : options.features) != null ? _e : []
2314
+ ],
2315
+ bindRoutes: options == null ? void 0 : options.bindRoutes
2316
+ }).createRoot();
2317
+ return { default: () => app };
2306
2318
  }
2307
2319
  return {
2308
2320
  createRoot() {
@@ -2311,35 +2323,36 @@ function createApp(options) {
2311
2323
  }
2312
2324
  };
2313
2325
  }
2314
- const legacyPluginStore = getOrCreateGlobalSingleton(
2315
- "legacy-plugin-compatibility-store",
2316
- () => /* @__PURE__ */ new WeakMap()
2317
- );
2318
- function toLegacyPlugin(plugin) {
2319
- let legacy = legacyPluginStore.get(plugin);
2320
- if (legacy) {
2321
- return legacy;
2322
- }
2323
- const errorMsg = "Not implemented in legacy plugin compatibility layer";
2324
- const notImplemented = () => {
2325
- throw new Error(errorMsg);
2326
- };
2327
- legacy = {
2328
- getId() {
2329
- return plugin.id;
2330
- },
2331
- get routes() {
2332
- return {};
2333
- },
2334
- get externalRoutes() {
2335
- return {};
2336
- },
2337
- getApis: notImplemented,
2338
- getFeatureFlags: notImplemented,
2339
- provide: notImplemented
2326
+ function createSpecializedApp(options) {
2327
+ const {
2328
+ features: duplicatedFeatures = [],
2329
+ config = new ConfigReader({}, "empty-config")
2330
+ } = options != null ? options : {};
2331
+ const features = deduplicateFeatures(duplicatedFeatures);
2332
+ const tree = createAppTree({
2333
+ features,
2334
+ builtinExtensions,
2335
+ config
2336
+ });
2337
+ const appContext = createLegacyAppContext(
2338
+ features.filter(
2339
+ (f) => f.$$type === "@backstage/BackstagePlugin"
2340
+ )
2341
+ );
2342
+ const apiHolder = createApiHolder(tree, config);
2343
+ const routeInfo = extractRouteInfoFromAppNode(tree.root);
2344
+ const routeBindings = resolveRouteBindings(
2345
+ options == null ? void 0 : options.bindRoutes,
2346
+ config,
2347
+ collectRouteIds(features)
2348
+ );
2349
+ const rootEl = tree.root.instance.getData(coreExtensionData.reactElement);
2350
+ const App = () => /* @__PURE__ */ React.createElement(ApiProvider, { apis: apiHolder }, /* @__PURE__ */ React.createElement(AppContextProvider, { appContext }, /* @__PURE__ */ React.createElement(AppThemeProvider, null, /* @__PURE__ */ React.createElement(RoutingProvider, { ...routeInfo, routeBindings }, /* @__PURE__ */ React.createElement(BrowserRouter, null, rootEl)))));
2351
+ return {
2352
+ createRoot() {
2353
+ return /* @__PURE__ */ React.createElement(App, null);
2354
+ }
2340
2355
  };
2341
- legacyPluginStore.set(plugin, legacy);
2342
- return legacy;
2343
2356
  }
2344
2357
  function createLegacyAppContext(plugins) {
2345
2358
  return {
@@ -2460,5 +2473,5 @@ function createApiHolder(tree, configApi) {
2460
2473
  return new ApiResolver(factoryRegistry);
2461
2474
  }
2462
2475
 
2463
- export { createApp, createExtensionTree };
2476
+ export { createApp, createExtensionTree, createSpecializedApp };
2464
2477
  //# sourceMappingURL=index.esm.js.map