@backstage/frontend-defaults 0.5.0-next.1 → 0.5.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,21 @@
1
1
  # @backstage/frontend-defaults
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 92af1ae: **BREAKING**: Removed the `allowUnknownExtensionConfig` option from `createApp`. This flag had no effect and was a no-op, so no behavioral changes are expected.
8
+ - 33de79d: **BREAKING**: Removed the deprecated `createPublicSignInApp` function. Use `createApp` from `@backstage/frontend-defaults` with `appModulePublicSignIn` from `@backstage/plugin-app/alpha` instead.
9
+
10
+ ### Patch Changes
11
+
12
+ - 5b160f9: Updated `createApp` to use the phased `prepareSpecializedApp` flow, allowing apps to render a bootstrap tree before the full app is finalized.
13
+ - Updated dependencies
14
+ - @backstage/frontend-app-api@0.16.0
15
+ - @backstage/core-components@0.18.8
16
+ - @backstage/frontend-plugin-api@0.15.0
17
+ - @backstage/plugin-app@0.4.1
18
+
3
19
  ## 0.5.0-next.1
4
20
 
5
21
  ### Minor Changes
@@ -1,11 +1,10 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { lazy, Suspense } from 'react';
3
- import { coreExtensionData } from '@backstage/frontend-plugin-api';
2
+ import { lazy, Suspense, useState, useEffect } from 'react';
4
3
  import { Progress } from '@backstage/core-components';
5
4
  import { defaultConfigLoaderSync } from './core-app-api/src/app/defaultConfigLoader.esm.js';
6
5
  import { overrideBaseUrlConfigs } from './core-app-api/src/app/overrideBaseUrlConfigs.esm.js';
7
6
  import { ConfigReader } from '@backstage/config';
8
- import { createSpecializedApp } from '@backstage/frontend-app-api';
7
+ import { prepareSpecializedApp } from '@backstage/frontend-app-api';
9
8
  import appPlugin from '@backstage/plugin-app';
10
9
  import { discoverAvailableFeatures } from './discovery.esm.js';
11
10
  import { resolveAsyncFeatures } from './resolution.esm.js';
@@ -25,20 +24,15 @@ function createApp(options) {
25
24
  config,
26
25
  features: [...discoveredFeaturesAndLoaders, ...options?.features ?? []]
27
26
  });
28
- const app = createSpecializedApp({
27
+ const preparedApp = prepareSpecializedApp({
29
28
  features: [appPlugin, ...loadedFeatures],
30
29
  config,
31
30
  bindRoutes: options?.bindRoutes,
32
31
  advanced: options?.advanced
33
32
  });
34
- const errorPage = maybeCreateErrorPage(app);
35
- if (errorPage) {
36
- return { default: () => errorPage };
37
- }
38
- const rootEl = app.tree.root.instance.getData(
39
- coreExtensionData.reactElement
40
- );
41
- return { default: () => rootEl };
33
+ return {
34
+ default: () => /* @__PURE__ */ jsx(PreparedAppRoot, { preparedApp })
35
+ };
42
36
  }
43
37
  const LazyApp = lazy(appLoader);
44
38
  return {
@@ -47,6 +41,22 @@ function createApp(options) {
47
41
  }
48
42
  };
49
43
  }
44
+ function PreparedAppRoot(props) {
45
+ const bootstrapApp = props.preparedApp.getBootstrapApp();
46
+ const [finalizedApp, setFinalizedApp] = useState();
47
+ useEffect(
48
+ () => props.preparedApp.onFinalized(setFinalizedApp),
49
+ [props.preparedApp]
50
+ );
51
+ if (!finalizedApp) {
52
+ return bootstrapApp.element;
53
+ }
54
+ const errorPage = maybeCreateErrorPage(finalizedApp);
55
+ if (errorPage) {
56
+ return errorPage;
57
+ }
58
+ return finalizedApp.element;
59
+ }
50
60
 
51
61
  export { createApp };
52
62
  //# sourceMappingURL=createApp.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createApp.esm.js","sources":["../src/createApp.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { JSX, lazy, ReactNode, Suspense } from 'react';\nimport {\n ConfigApi,\n coreExtensionData,\n FrontendFeature,\n FrontendFeatureLoader,\n} from '@backstage/frontend-plugin-api';\nimport { Progress } from '@backstage/core-components';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { defaultConfigLoaderSync } from '../../core-app-api/src/app/defaultConfigLoader';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { overrideBaseUrlConfigs } from '../../core-app-api/src/app/overrideBaseUrlConfigs';\nimport { ConfigReader } from '@backstage/config';\nimport {\n CreateAppRouteBinder,\n createSpecializedApp,\n ExtensionFactoryMiddleware,\n FrontendPluginInfoResolver,\n} from '@backstage/frontend-app-api';\nimport appPlugin from '@backstage/plugin-app';\nimport { discoverAvailableFeatures } from './discovery';\nimport { resolveAsyncFeatures } from './resolution';\nimport { maybeCreateErrorPage } from './maybeCreateErrorPage';\n\n/**\n * Options for {@link createApp}.\n *\n * @public\n */\nexport interface CreateAppOptions {\n /**\n * The list of features to load.\n */\n features?: (FrontendFeature | FrontendFeatureLoader)[];\n\n /**\n * Allows for the binding of plugins' external route refs within the app.\n */\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n\n /**\n * Advanced, more rarely used options.\n */\n advanced?: {\n /**\n * Sets a custom config loader, replacing the builtin one.\n *\n * This can be used e.g. if you have the need to source config out of custom\n * storages.\n */\n configLoader?: () => Promise<{ config: ConfigApi }>;\n\n /**\n * Applies one or more middleware on every extension, as they are added to\n * the application.\n *\n * This is an advanced use case for modifying extension data on the fly as\n * it gets emitted by extensions being instantiated.\n */\n extensionFactoryMiddleware?:\n | ExtensionFactoryMiddleware\n | ExtensionFactoryMiddleware[];\n\n /**\n * The element to render while loading the app (waiting for config, features, etc).\n *\n * This is the `<Progress />` component from `@backstage/core-components` by default.\n * If set to `null` then no loading fallback element is rendered at all.\n */\n loadingElement?: ReactNode;\n\n /**\n * Allows for customizing how plugin info is retrieved.\n */\n pluginInfoResolver?: FrontendPluginInfoResolver;\n };\n}\n\n/**\n * Creates a new Backstage frontend app instance. See https://backstage.io/docs/frontend-system/building-apps/index\n *\n * @public\n */\nexport function createApp(options?: CreateAppOptions): {\n createRoot(): JSX.Element;\n} {\n let suspenseFallback = options?.advanced?.loadingElement;\n if (suspenseFallback === undefined) {\n suspenseFallback = <Progress />;\n }\n\n async function appLoader() {\n const config =\n (await options?.advanced?.configLoader?.().then(c => c.config)) ??\n ConfigReader.fromConfigs(\n overrideBaseUrlConfigs(defaultConfigLoaderSync()),\n );\n\n const { features: discoveredFeaturesAndLoaders } =\n discoverAvailableFeatures(config);\n const { features: loadedFeatures } = await resolveAsyncFeatures({\n config,\n features: [...discoveredFeaturesAndLoaders, ...(options?.features ?? [])],\n });\n\n const app = createSpecializedApp({\n features: [appPlugin, ...loadedFeatures],\n config,\n bindRoutes: options?.bindRoutes,\n advanced: options?.advanced,\n });\n\n const errorPage = maybeCreateErrorPage(app);\n if (errorPage) {\n return { default: () => errorPage };\n }\n\n const rootEl = app.tree.root.instance!.getData(\n coreExtensionData.reactElement,\n );\n\n return { default: () => rootEl };\n }\n\n const LazyApp = lazy(appLoader);\n\n return {\n createRoot() {\n return (\n <Suspense fallback={suspenseFallback}>\n <LazyApp />\n </Suspense>\n );\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAmGO,SAAS,UAAU,OAAA,EAExB;AACA,EAAA,IAAI,gBAAA,GAAmB,SAAS,QAAA,EAAU,cAAA;AAC1C,EAAA,IAAI,qBAAqB,MAAA,EAAW;AAClC,IAAA,gBAAA,uBAAoB,QAAA,EAAA,EAAS,CAAA;AAAA,EAC/B;AAEA,EAAA,eAAe,SAAA,GAAY;AACzB,IAAA,MAAM,MAAA,GACH,MAAM,OAAA,EAAS,QAAA,EAAU,YAAA,IAAe,CAAE,IAAA,CAAK,CAAA,CAAA,KAAK,CAAA,CAAE,MAAM,CAAA,IAC7D,YAAA,CAAa,WAAA;AAAA,MACX,sBAAA,CAAuB,yBAAyB;AAAA,KAClD;AAEF,IAAA,MAAM,EAAE,QAAA,EAAU,4BAAA,EAA6B,GAC7C,0BAA0B,MAAM,CAAA;AAClC,IAAA,MAAM,EAAE,QAAA,EAAU,cAAA,EAAe,GAAI,MAAM,oBAAA,CAAqB;AAAA,MAC9D,MAAA;AAAA,MACA,QAAA,EAAU,CAAC,GAAG,4BAAA,EAA8B,GAAI,OAAA,EAAS,QAAA,IAAY,EAAG;AAAA,KACzE,CAAA;AAED,IAAA,MAAM,MAAM,oBAAA,CAAqB;AAAA,MAC/B,QAAA,EAAU,CAAC,SAAA,EAAW,GAAG,cAAc,CAAA;AAAA,MACvC,MAAA;AAAA,MACA,YAAY,OAAA,EAAS,UAAA;AAAA,MACrB,UAAU,OAAA,EAAS;AAAA,KACpB,CAAA;AAED,IAAA,MAAM,SAAA,GAAY,qBAAqB,GAAG,CAAA;AAC1C,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,OAAO,EAAE,OAAA,EAAS,MAAM,SAAA,EAAU;AAAA,IACpC;AAEA,IAAA,MAAM,MAAA,GAAS,GAAA,CAAI,IAAA,CAAK,IAAA,CAAK,QAAA,CAAU,OAAA;AAAA,MACrC,iBAAA,CAAkB;AAAA,KACpB;AAEA,IAAA,OAAO,EAAE,OAAA,EAAS,MAAM,MAAA,EAAO;AAAA,EACjC;AAEA,EAAA,MAAM,OAAA,GAAU,KAAK,SAAS,CAAA;AAE9B,EAAA,OAAO;AAAA,IACL,UAAA,GAAa;AACX,MAAA,2BACG,QAAA,EAAA,EAAS,QAAA,EAAU,gBAAA,EAClB,QAAA,kBAAA,GAAA,CAAC,WAAQ,CAAA,EACX,CAAA;AAAA,IAEJ;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"createApp.esm.js","sources":["../src/createApp.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { JSX, lazy, ReactNode, Suspense, useEffect, useState } from 'react';\nimport {\n ConfigApi,\n ExtensionFactoryMiddleware,\n FrontendFeature,\n FrontendFeatureLoader,\n} from '@backstage/frontend-plugin-api';\nimport { Progress } from '@backstage/core-components';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { defaultConfigLoaderSync } from '../../core-app-api/src/app/defaultConfigLoader';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { overrideBaseUrlConfigs } from '../../core-app-api/src/app/overrideBaseUrlConfigs';\nimport { ConfigReader } from '@backstage/config';\nimport {\n CreateAppRouteBinder,\n FinalizedSpecializedApp,\n prepareSpecializedApp,\n PreparedSpecializedApp,\n FrontendPluginInfoResolver,\n} from '@backstage/frontend-app-api';\nimport appPlugin from '@backstage/plugin-app';\nimport { discoverAvailableFeatures } from './discovery';\nimport { resolveAsyncFeatures } from './resolution';\nimport { maybeCreateErrorPage } from './maybeCreateErrorPage';\n\n/**\n * Options for {@link createApp}.\n *\n * @public\n */\nexport interface CreateAppOptions {\n /**\n * The list of features to load.\n */\n features?: (FrontendFeature | FrontendFeatureLoader)[];\n\n /**\n * Allows for the binding of plugins' external route refs within the app.\n */\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n\n /**\n * Advanced, more rarely used options.\n */\n advanced?: {\n /**\n * Sets a custom config loader, replacing the builtin one.\n *\n * This can be used e.g. if you have the need to source config out of custom\n * storages.\n */\n configLoader?: () => Promise<{ config: ConfigApi }>;\n\n /**\n * Applies one or more middleware on every extension, as they are added to\n * the application.\n *\n * This is an advanced use case for modifying extension data on the fly as\n * it gets emitted by extensions being instantiated.\n */\n extensionFactoryMiddleware?:\n | ExtensionFactoryMiddleware\n | ExtensionFactoryMiddleware[];\n\n /**\n * The element to render while loading the app (waiting for config, features, etc).\n *\n * This is the `<Progress />` component from `@backstage/core-components` by default.\n * If set to `null` then no loading fallback element is rendered at all.\n */\n loadingElement?: ReactNode;\n\n /**\n * Allows for customizing how plugin info is retrieved.\n */\n pluginInfoResolver?: FrontendPluginInfoResolver;\n };\n}\n\n/**\n * Creates a new Backstage frontend app instance. See https://backstage.io/docs/frontend-system/building-apps/index\n *\n * @public\n */\nexport function createApp(options?: CreateAppOptions): {\n createRoot(): JSX.Element;\n} {\n let suspenseFallback = options?.advanced?.loadingElement;\n if (suspenseFallback === undefined) {\n suspenseFallback = <Progress />;\n }\n\n async function appLoader() {\n const config =\n (await options?.advanced?.configLoader?.().then(c => c.config)) ??\n ConfigReader.fromConfigs(\n overrideBaseUrlConfigs(defaultConfigLoaderSync()),\n );\n\n const { features: discoveredFeaturesAndLoaders } =\n discoverAvailableFeatures(config);\n const { features: loadedFeatures } = await resolveAsyncFeatures({\n config,\n features: [...discoveredFeaturesAndLoaders, ...(options?.features ?? [])],\n });\n\n const preparedApp = prepareSpecializedApp({\n features: [appPlugin, ...loadedFeatures],\n config,\n bindRoutes: options?.bindRoutes,\n advanced: options?.advanced,\n });\n\n return {\n default: () => <PreparedAppRoot preparedApp={preparedApp} />,\n };\n }\n\n const LazyApp = lazy(appLoader);\n\n return {\n createRoot() {\n return (\n <Suspense fallback={suspenseFallback}>\n <LazyApp />\n </Suspense>\n );\n },\n };\n}\n\nfunction PreparedAppRoot(props: {\n preparedApp: PreparedSpecializedApp;\n}): JSX.Element {\n const bootstrapApp = props.preparedApp.getBootstrapApp();\n const [finalizedApp, setFinalizedApp] = useState<\n FinalizedSpecializedApp | undefined\n >();\n\n useEffect(\n () => props.preparedApp.onFinalized(setFinalizedApp),\n [props.preparedApp],\n );\n\n if (!finalizedApp) {\n return bootstrapApp.element;\n }\n\n const errorPage = maybeCreateErrorPage(finalizedApp);\n if (errorP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QAAA,kBAAA,GAAA,CAAC,WAAQ,CAAA,EACX,CAAA;AAAA,IAEJ;AAAA,GACF;AACF;AAEA,SAAS,gBAAgB,KAAA,EAET;AACd,EAAA,MAAM,YAAA,GAAe,KAAA,CAAM,WAAA,CAAY,eAAA,EAAgB;AACvD,EAAA,MAAM,CAAC,YAAA,EAAc,eAAe,CAAA,GAAI,QAAA,EAEtC;AAEF,EAAA,SAAA;AAAA,IACE,MAAM,KAAA,CAAM,WAAA,CAAY,WAAA,CAAY,eAAe,CAAA;AAAA,IACnD,CAAC,MAAM,WAAW;AAAA,GACpB;AAEA,EAAA,IAAI,CAAC,YAAA,EAAc;AACjB,IAAA,OAAO,YAAA,CAAa,OAAA;AAAA,EACtB;AAEA,EAAA,MAAM,SAAA,GAAY,qBAAqB,YAAY,CAAA;AACnD,EAAA,IAAI,SAAA,EAAW;AACb,IAAA,OAAO,SAAA;AAAA,EACT;AAEA,EAAA,OAAO,YAAA,CAAa,OAAA;AACtB;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ReactNode, JSX } from 'react';
2
- import { FrontendFeature, FrontendFeatureLoader, ConfigApi } from '@backstage/frontend-plugin-api';
3
- import { CreateAppRouteBinder, ExtensionFactoryMiddleware, FrontendPluginInfoResolver, AppError, AppErrorTypes } from '@backstage/frontend-app-api';
2
+ import { FrontendFeature, FrontendFeatureLoader, ConfigApi, ExtensionFactoryMiddleware } from '@backstage/frontend-plugin-api';
3
+ import { CreateAppRouteBinder, FrontendPluginInfoResolver, AppError, AppErrorTypes } from '@backstage/frontend-app-api';
4
4
  import { Config } from '@backstage/config';
5
5
 
6
6
  /**
@@ -6,7 +6,9 @@ const DEFAULT_WARNING_CODES = [
6
6
  "INVALID_EXTENSION_CONFIG_KEY",
7
7
  "EXTENSION_INPUT_DATA_IGNORED",
8
8
  "EXTENSION_INPUT_INTERNAL_IGNORED",
9
- "EXTENSION_OUTPUT_IGNORED"
9
+ "EXTENSION_OUTPUT_IGNORED",
10
+ "EXTENSION_BOOTSTRAP_PREDICATE_IGNORED",
11
+ "EXTENSION_BOOTSTRAP_API_UNAVAILABLE"
10
12
  ];
11
13
  function AppErrorItem(props) {
12
14
  const { context } = props.error;
@@ -1 +1 @@
1
- {"version":3,"file":"maybeCreateErrorPage.esm.js","sources":["../src/maybeCreateErrorPage.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { FrontendPluginInfo } from '@backstage/frontend-plugin-api';\nimport { JSX, useEffect, useState } from 'react';\nimport { AppError, AppErrorTypes } from '@backstage/frontend-app-api';\n\nconst DEFAULT_WARNING_CODES: Array<keyof AppErrorTypes> = [\n 'EXTENSION_IGNORED',\n 'INVALID_EXTENSION_CONFIG_KEY',\n 'EXTENSION_INPUT_DATA_IGNORED',\n 'EXTENSION_INPUT_INTERNAL_IGNORED',\n 'EXTENSION_OUTPUT_IGNORED',\n];\n\nfunction AppErrorItem(props: { error: AppError }): JSX.Element {\n const { context } = props.error;\n\n const node = 'node' in context ? context.node : undefined;\n const extensionId =\n 'extensionId' in context ? context.extensionId : node?.spec.id;\n const routeId = 'routeId' in context ? context.routeId : undefined;\n const plugin = 'plugin' in context ? context.plugin : node?.spec.plugin;\n const pluginId = plugin?.pluginId ?? 'N/A';\n\n const [info, setInfo] = useState<FrontendPluginInfo | undefined>(undefined);\n useEffect(() => {\n plugin?.info().then(setInfo, error => {\n // eslint-disable-next-line no-console\n console.error(\n `Failed to load info for plugin ${plugin.pluginId}: ${error}`,\n );\n });\n }, [plugin]);\n\n return (\n <div>\n <b>{props.error.code}</b>: {props.error.message}\n <pre style={{ marginLeft: '1rem' }}>\n {extensionId && <div>extensionId: {extensionId}</div>}\n {routeId && <div>routeId: {routeId}</div>}\n {pluginId && <div>pluginId: {pluginId}</div>}\n {info && (\n <div>\n package: {info.packageName}@{info.version}\n </div>\n )}\n </pre>\n </div>\n );\n}\n\nfunction AppErrorPage(props: { errors: AppError[] }): JSX.Element {\n return (\n <div style={{ margin: '1rem' }}>\n <h2>App startup failed</h2>\n {props.errors.map((error, index) => (\n <AppErrorItem error={error} key={index} />\n ))}\n </div>\n );\n}\n\n/**\n * If there are any unrecoverable errors in the app, this will return an error page in the form of a JSX element.\n *\n * If there are any recoverable errors, they will always be logged as warnings in the console.\n * @public\n */\nexport function maybeCreateErrorPage(\n app: { errors?: AppError[] },\n options?: {\n warningCodes?: Array<keyof AppErrorTypes>;\n },\n): JSX.Element | undefined {\n if (!app.errors) {\n return undefined;\n }\n\n const errors = new Array<AppError>();\n const warnings = new Array<AppError>();\n\n const warningCodes = new Set(options?.warningCodes ?? DEFAULT_WARNING_CODES);\n for (const error of app.errors) {\n if (warningCodes.has(error.code)) {\n warnings.push(error);\n } else {\n errors.push(error);\n }\n }\n\n if (warnings.length > 0) {\n // eslint-disable-next-line no-console\n console.warn('App startup encountered warnings:');\n for (const warning of warnings) {\n // eslint-disable-next-line no-console\n console.warn(`${warning.code}: ${warning.message}`);\n }\n }\n\n if (errors.length === 0) {\n return undefined;\n }\n\n return <AppErrorPage errors={errors} />;\n}\n"],"names":[],"mappings":";;;AAoBA,MAAM,qBAAA,GAAoD;AAAA,EACxD,mBAAA;AAAA,EACA,8BAAA;AAAA,EACA,8BAAA;AAAA,EACA,kCAAA;AAAA,EACA;AACF,CAAA;AAEA,SAAS,aAAa,KAAA,EAAyC;AAC7D,EAAA,MAAM,EAAE,OAAA,EAAQ,GAAI,KAAA,CAAM,KAAA;AAE1B,EAAA,MAAM,IAAA,GAAO,MAAA,IAAU,OAAA,GAAU,OAAA,CAAQ,IAA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nB;AAAA,EACF;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AAEvB,IAAA,OAAA,CAAQ,KAAK,mCAAmC,CAAA;AAChD,IAAA,KAAA,MAAW,WAAW,QAAA,EAAU;AAE9B,MAAA,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAA,CAAQ,IAAI,CAAA,EAAA,EAAK,OAAA,CAAQ,OAAO,CAAA,CAAE,CAAA;AAAA,IACpD;AAAA,EACF;AAEA,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,uBAAO,GAAA,CAAC,gBAAa,MAAA,EAAgB,CAAA;AACvC;;;;"}
1
+ {"version":3,"file":"maybeCreateErrorPage.esm.js","sources":["../src/maybeCreateErrorPage.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 { FrontendPluginInfo } from '@backstage/frontend-plugin-api';\nimport { JSX, useEffect, useState } from 'react';\nimport { AppError, AppErrorTypes } from '@backstage/frontend-app-api';\n\nconst DEFAULT_WARNING_CODES: Array<keyof AppErrorTypes> = [\n 'EXTENSION_IGNORED',\n 'INVALID_EXTENSION_CONFIG_KEY',\n 'EXTENSION_INPUT_DATA_IGNORED',\n 'EXTENSION_INPUT_INTERNAL_IGNORED',\n 'EXTENSION_OUTPUT_IGNORED',\n 'EXTENSION_BOOTSTRAP_PREDICATE_IGNORED',\n 'EXTENSION_BOOTSTRAP_API_UNAVAILABLE',\n];\n\nfunction AppErrorItem(props: { error: AppError }): JSX.Element {\n const { context } = props.error;\n\n const node = 'node' in context ? context.node : undefined;\n const extensionId =\n 'extensionId' in context ? context.extensionId : node?.spec.id;\n const routeId = 'routeId' in context ? context.routeId : undefined;\n const plugin = 'plugin' in context ? context.plugin : node?.spec.plugin;\n const pluginId = plugin?.pluginId ?? 'N/A';\n\n const [info, setInfo] = useState<FrontendPluginInfo | undefined>(undefined);\n useEffect(() => {\n plugin?.info().then(setInfo, error => {\n // eslint-disable-next-line no-console\n console.error(\n `Failed to load info for plugin ${plugin.pluginId}: ${error}`,\n );\n });\n }, [plugin]);\n\n return (\n <div>\n <b>{props.error.code}</b>: {props.error.message}\n <pre style={{ marginLeft: '1rem' }}>\n {extensionId && <div>extensionId: {extensionId}</div>}\n {routeId && <div>routeId: {routeId}</div>}\n {pluginId && <div>pluginId: {pluginId}</div>}\n {info && (\n <div>\n package: {info.packageName}@{info.version}\n </div>\n )}\n </pre>\n </div>\n );\n}\n\nfunction AppErrorPage(props: { errors: AppError[] }): JSX.Element {\n return (\n <div style={{ margin: '1rem' }}>\n <h2>App startup failed</h2>\n {props.errors.map((error, index) => (\n <AppErrorItem error={error} key={index} />\n ))}\n </div>\n );\n}\n\n/**\n * If there are any unrecoverable errors in the app, this will return an error page in the form of a JSX element.\n *\n * If there are any recoverable errors, they will always be logged as warnings in the console.\n * @public\n */\nexport function maybeCreateErrorPage(\n app: { errors?: AppError[] },\n options?: {\n warningCodes?: Array<keyof AppErrorTypes>;\n },\n): JSX.Element | undefined {\n if (!app.errors) {\n return undefined;\n }\n\n const errors = new Array<AppError>();\n const warnings = new Array<AppError>();\n\n const warningCodes = new Set(options?.warningCodes ?? DEFAULT_WARNING_CODES);\n for (const error of app.errors) {\n if (warningCodes.has(error.code)) {\n warnings.push(error);\n } else {\n errors.push(error);\n }\n }\n\n if (warnings.length > 0) {\n // eslint-disable-next-line no-console\n console.warn('App startup encountered warnings:');\n for (const warning of warnings) {\n // eslint-disable-next-line no-console\n console.warn(`${warning.code}: ${warning.message}`);\n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MAAA,GAAS,IAAI,KAAA,EAAgB;AACnC,EAAA,MAAM,QAAA,GAAW,IAAI,KAAA,EAAgB;AAErC,EAAA,MAAM,YAAA,GAAe,IAAI,GAAA,CAAI,OAAA,EAAS,gBAAgB,qBAAqB,CAAA;AAC3E,EAAA,KAAA,MAAW,KAAA,IAAS,IAAI,MAAA,EAAQ;AAC9B,IAAA,IAAI,YAAA,CAAa,GAAA,CAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AAChC,MAAA,QAAA,CAAS,KAAK,KAAK,CAAA;AAAA,IACrB,CAAA,MAAO;AACL,MAAA,MAAA,CAAO,KAAK,KAAK,CAAA;AAAA,IACnB;AAAA,EACF;AAEA,EAAA,IAAI,QAAA,CAAS,SAAS,CAAA,EAAG;AAEvB,IAAA,OAAA,CAAQ,KAAK,mCAAmC,CAAA;AAChD,IAAA,KAAA,MAAW,WAAW,QAAA,EAAU;AAE9B,MAAA,OAAA,CAAQ,KAAK,CAAA,EAAG,OAAA,CAAQ,IAAI,CAAA,EAAA,EAAK,OAAA,CAAQ,OAAO,CAAA,CAAE,CAAA;AAAA,IACpD;AAAA,EACF;AAEA,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,OAAO,MAAA;AAAA,EACT;AAEA,EAAA,uBAAO,GAAA,CAAC,gBAAa,MAAA,EAAgB,CAAA;AACvC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/frontend-defaults",
3
- "version": "0.5.0-next.1",
3
+ "version": "0.5.0",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -31,19 +31,21 @@
31
31
  "test": "backstage-cli package test"
32
32
  },
33
33
  "dependencies": {
34
- "@backstage/config": "1.3.6",
35
- "@backstage/core-components": "0.18.8-next.1",
36
- "@backstage/errors": "1.2.7",
37
- "@backstage/frontend-app-api": "0.16.0-next.1",
38
- "@backstage/frontend-plugin-api": "0.15.0-next.1",
39
- "@backstage/plugin-app": "0.4.1-next.2",
34
+ "@backstage/config": "^1.3.6",
35
+ "@backstage/core-components": "^0.18.8",
36
+ "@backstage/errors": "^1.2.7",
37
+ "@backstage/frontend-app-api": "^0.16.0",
38
+ "@backstage/frontend-plugin-api": "^0.15.0",
39
+ "@backstage/plugin-app": "^0.4.1",
40
40
  "@react-hookz/web": "^24.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@backstage/cli": "0.36.0-next.2",
44
- "@backstage/core-plugin-api": "1.12.4-next.1",
45
- "@backstage/plugin-app-react": "0.2.1-next.1",
46
- "@backstage/test-utils": "1.7.16-next.0",
43
+ "@backstage/cli": "^0.36.0",
44
+ "@backstage/core-plugin-api": "^1.12.4",
45
+ "@backstage/plugin-app-react": "^0.2.1",
46
+ "@backstage/plugin-permission-common": "^0.9.7",
47
+ "@backstage/plugin-permission-react": "^0.4.41",
48
+ "@backstage/test-utils": "^1.7.16",
47
49
  "@testing-library/jest-dom": "^6.0.0",
48
50
  "@testing-library/react": "^16.0.0",
49
51
  "@types/react": "^18.0.0",