@backstage/frontend-defaults 0.1.2-next.0 → 0.1.2-next.2
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 +22 -0
- package/dist/core-app-api/src/app/defaultConfigLoader.esm.js.map +1 -1
- package/dist/core-app-api/src/app/overrideBaseUrlConfigs.esm.js.map +1 -1
- package/dist/createApp.esm.js.map +1 -1
- package/dist/createPublicSignInApp.esm.js.map +1 -1
- package/dist/discovery.esm.js.map +1 -1
- package/package.json +13 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @backstage/frontend-defaults
|
|
2
2
|
|
|
3
|
+
## 0.1.2-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/config@1.2.0
|
|
9
|
+
- @backstage/errors@1.2.4
|
|
10
|
+
- @backstage/frontend-app-api@0.10.1-next.2
|
|
11
|
+
- @backstage/frontend-plugin-api@0.9.1-next.2
|
|
12
|
+
- @backstage/plugin-app@0.1.2-next.2
|
|
13
|
+
|
|
14
|
+
## 0.1.2-next.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- @backstage/config@1.2.0
|
|
20
|
+
- @backstage/errors@1.2.4
|
|
21
|
+
- @backstage/frontend-app-api@0.10.1-next.1
|
|
22
|
+
- @backstage/frontend-plugin-api@0.9.1-next.1
|
|
23
|
+
- @backstage/plugin-app@0.1.2-next.1
|
|
24
|
+
|
|
3
25
|
## 0.1.2-next.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultConfigLoader.esm.js","sources":["../../../../../core-app-api/src/app/defaultConfigLoader.ts"],"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 { AppConfig } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport { AppConfigLoader } from './types';\n\n/**\n * The default config loader, which expects that config is available at compile-time\n * in `process.env.APP_CONFIG`. APP_CONFIG should be an array of config objects as\n * returned by the config loader.\n *\n * It will also load runtime config from the __APP_INJECTED_RUNTIME_CONFIG__ string,\n * which can be rewritten at runtime to contain an additional JSON config object.\n * If runtime config is present, it will be placed first in the config array, overriding\n * other config values.\n *\n * @public\n */\nexport const defaultConfigLoader: AppConfigLoader = async () =>\n defaultConfigLoaderSync();\n\n/** @internal */\nexport function defaultConfigLoaderSync(\n // This string may be replaced at runtime to provide additional config.\n // It should be replaced by a JSON-serialized config object.\n // It's a param so we can test it, but at runtime this will always fall back to default.\n runtimeConfigJson: string = '__APP_INJECTED_RUNTIME_CONFIG__',\n) {\n const appConfig = process.env.APP_CONFIG;\n if (!appConfig) {\n throw new Error('No static configuration provided');\n }\n if (!Array.isArray(appConfig)) {\n throw new Error('Static configuration has invalid format');\n }\n const configs = appConfig.slice() as unknown as AppConfig[];\n\n // Check if we have any config script tags, otherwise fall back to injected config\n const configScripts = document.querySelectorAll(\n 'script[type=\"backstage.io/config\"]',\n );\n if (configScripts.length > 0) {\n for (const el of configScripts) {\n try {\n const content = el.textContent;\n if (!content) {\n throw new Error('tag is empty');\n }\n let data;\n try {\n data = JSON.parse(content);\n } catch (error) {\n throw new Error(`failed to parse config; ${error}`);\n }\n if (!Array.isArray(data)) {\n throw new Error('data is not an array');\n }\n configs.push(...data);\n } catch (error) {\n throw new Error(\n `Failed to load config from script tag, ${error.message}`,\n );\n }\n }\n } else if (\n runtimeConfigJson !==\n // Avoiding this string also being replaced at runtime\n '__app_injected_runtime_config__'.toLocaleUpperCase('en-US')\n ) {\n try {\n const data = JSON.parse(runtimeConfigJson) as JsonObject;\n if (Array.isArray(data)) {\n configs.push(...data);\n } else {\n configs.push({ data, context: 'env' });\n }\n } catch (error) {\n throw new Error(`Failed to load runtime configuration, ${error}`);\n }\n }\n\n const windowAppConfig = (window as any).__APP_CONFIG__;\n if (windowAppConfig) {\n configs.push({\n context: 'window',\n data: windowAppConfig,\n });\n }\n return configs;\n}\n"],"names":[],"mappings":"AAoCgB,SAAA,uBAAA,CAId,oBAA4B,iCAC5B,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,UAAA
|
|
1
|
+
{"version":3,"file":"defaultConfigLoader.esm.js","sources":["../../../../../core-app-api/src/app/defaultConfigLoader.ts"],"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 { AppConfig } from '@backstage/config';\nimport { JsonObject } from '@backstage/types';\nimport { AppConfigLoader } from './types';\n\n/**\n * The default config loader, which expects that config is available at compile-time\n * in `process.env.APP_CONFIG`. APP_CONFIG should be an array of config objects as\n * returned by the config loader.\n *\n * It will also load runtime config from the __APP_INJECTED_RUNTIME_CONFIG__ string,\n * which can be rewritten at runtime to contain an additional JSON config object.\n * If runtime config is present, it will be placed first in the config array, overriding\n * other config values.\n *\n * @public\n */\nexport const defaultConfigLoader: AppConfigLoader = async () =>\n defaultConfigLoaderSync();\n\n/** @internal */\nexport function defaultConfigLoaderSync(\n // This string may be replaced at runtime to provide additional config.\n // It should be replaced by a JSON-serialized config object.\n // It's a param so we can test it, but at runtime this will always fall back to default.\n runtimeConfigJson: string = '__APP_INJECTED_RUNTIME_CONFIG__',\n) {\n const appConfig = process.env.APP_CONFIG;\n if (!appConfig) {\n throw new Error('No static configuration provided');\n }\n if (!Array.isArray(appConfig)) {\n throw new Error('Static configuration has invalid format');\n }\n const configs = appConfig.slice() as unknown as AppConfig[];\n\n // Check if we have any config script tags, otherwise fall back to injected config\n const configScripts = document.querySelectorAll(\n 'script[type=\"backstage.io/config\"]',\n );\n if (configScripts.length > 0) {\n for (const el of configScripts) {\n try {\n const content = el.textContent;\n if (!content) {\n throw new Error('tag is empty');\n }\n let data;\n try {\n data = JSON.parse(content);\n } catch (error) {\n throw new Error(`failed to parse config; ${error}`);\n }\n if (!Array.isArray(data)) {\n throw new Error('data is not an array');\n }\n configs.push(...data);\n } catch (error) {\n throw new Error(\n `Failed to load config from script tag, ${error.message}`,\n );\n }\n }\n } else if (\n runtimeConfigJson !==\n // Avoiding this string also being replaced at runtime\n '__app_injected_runtime_config__'.toLocaleUpperCase('en-US')\n ) {\n try {\n const data = JSON.parse(runtimeConfigJson) as JsonObject;\n if (Array.isArray(data)) {\n configs.push(...data);\n } else {\n configs.push({ data, context: 'env' });\n }\n } catch (error) {\n throw new Error(`Failed to load runtime configuration, ${error}`);\n }\n }\n\n const windowAppConfig = (window as any).__APP_CONFIG__;\n if (windowAppConfig) {\n configs.push({\n context: 'window',\n data: windowAppConfig,\n });\n }\n return configs;\n}\n"],"names":[],"mappings":"AAoCgB,SAAA,uBAAA,CAId,oBAA4B,iCAC5B,EAAA;AACA,EAAM,MAAA,SAAA,GAAY,QAAQ,GAAI,CAAA,UAAA;AAC9B,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,kCAAkC,CAAA;AAAA;AAEpD,EAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,SAAS,CAAG,EAAA;AAC7B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AAQ,IAAK,CAAA,EAAE,IAAM,EAAA,OAAA,EAAS,OAAO,CAAA;AAAA;AACvC,aACO,KAAO,EAAA;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAyC,sCAAA,EAAA,KAAK,CAAE,CAAA,CAAA;AAAA;AAClE;AAGF,EAAA,MAAM,kBAAmB,MAAe,CAAA,cAAA;AACxC,EAAA,IAAI,eAAiB,EAAA;AACnB,IAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,MACX,OAAS,EAAA,QAAA;AAAA,MACT,IAAM,EAAA;AAAA,KACP,CAAA;AAAA;AAEH,EAAO,OAAA,OAAA;AACT;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrideBaseUrlConfigs.esm.js","sources":["../../../../../core-app-api/src/app/overrideBaseUrlConfigs.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AppConfig, ConfigReader } from '@backstage/config';\n\n/**\n * Creates a base URL that uses to the current document origin.\n */\nfunction createLocalBaseUrl(fullUrl: string): string {\n const url = new URL(fullUrl);\n url.protocol = document.location.protocol;\n url.hostname = document.location.hostname;\n url.port = document.location.port;\n return url.toString().replace(/\\/$/, '');\n}\n\n/**\n * If we are able to override the app and backend base URLs to values that\n * match the origin of the current location, then this function returns a\n * new array of app configs that contain the overrides.\n *\n * @internal\n */\nexport function overrideBaseUrlConfigs(inputConfigs: AppConfig[]): AppConfig[] {\n const urlConfigReader = ConfigReader.fromConfigs(inputConfigs);\n\n // In tests we may not have `app.baseUrl` or `backend.baseUrl`, to keep them optional\n const appBaseUrl = urlConfigReader.getOptionalString('app.baseUrl');\n const backendBaseUrl = urlConfigReader.getOptionalString('backend.baseUrl');\n\n let configs = inputConfigs;\n\n let newBackendBaseUrl: string | undefined = undefined;\n let newAppBaseUrl: string | undefined = undefined;\n\n if (appBaseUrl && backendBaseUrl) {\n const appOrigin = new URL(appBaseUrl).origin;\n const backendOrigin = new URL(backendBaseUrl).origin;\n\n if (appOrigin === backendOrigin) {\n const maybeNewBackendBaseUrl = createLocalBaseUrl(backendBaseUrl);\n if (backendBaseUrl !== maybeNewBackendBaseUrl) {\n newBackendBaseUrl = maybeNewBackendBaseUrl;\n }\n }\n }\n\n if (appBaseUrl) {\n const maybeNewAppBaseUrl = createLocalBaseUrl(appBaseUrl);\n if (appBaseUrl !== maybeNewAppBaseUrl) {\n newAppBaseUrl = maybeNewAppBaseUrl;\n }\n }\n\n // Only add the relative config if there is actually data to add.\n if (newAppBaseUrl || newBackendBaseUrl) {\n configs = configs.concat({\n data: {\n app: newAppBaseUrl && {\n baseUrl: newAppBaseUrl,\n },\n backend: newBackendBaseUrl && {\n baseUrl: newBackendBaseUrl,\n },\n },\n context: 'relative-resolver',\n });\n }\n\n return configs;\n}\n"],"names":[],"mappings":";;AAqBA,SAAS,mBAAmB,OAAyB,EAAA;AACnD,EAAM,MAAA,GAAA,GAAM,IAAI,GAAA,CAAI,OAAO,CAAA
|
|
1
|
+
{"version":3,"file":"overrideBaseUrlConfigs.esm.js","sources":["../../../../../core-app-api/src/app/overrideBaseUrlConfigs.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AppConfig, ConfigReader } from '@backstage/config';\n\n/**\n * Creates a base URL that uses to the current document origin.\n */\nfunction createLocalBaseUrl(fullUrl: string): string {\n const url = new URL(fullUrl);\n url.protocol = document.location.protocol;\n url.hostname = document.location.hostname;\n url.port = document.location.port;\n return url.toString().replace(/\\/$/, '');\n}\n\n/**\n * If we are able to override the app and backend base URLs to values that\n * match the origin of the current location, then this function returns a\n * new array of app configs that contain the overrides.\n *\n * @internal\n */\nexport function overrideBaseUrlConfigs(inputConfigs: AppConfig[]): AppConfig[] {\n const urlConfigReader = ConfigReader.fromConfigs(inputConfigs);\n\n // In tests we may not have `app.baseUrl` or `backend.baseUrl`, to keep them optional\n const appBaseUrl = urlConfigReader.getOptionalString('app.baseUrl');\n const backendBaseUrl = urlConfigReader.getOptionalString('backend.baseUrl');\n\n let configs = inputConfigs;\n\n let newBackendBaseUrl: string | undefined = undefined;\n let newAppBaseUrl: string | undefined = undefined;\n\n if (appBaseUrl && backendBaseUrl) {\n const appOrigin = new URL(appBaseUrl).origin;\n const backendOrigin = new URL(backendBaseUrl).origin;\n\n if (appOrigin === backendOrigin) {\n const maybeNewBackendBaseUrl = createLocalBaseUrl(backendBaseUrl);\n if (backendBaseUrl !== maybeNewBackendBaseUrl) {\n newBackendBaseUrl = maybeNewBackendBaseUrl;\n }\n }\n }\n\n if (appBaseUrl) {\n const maybeNewAppBaseUrl = createLocalBaseUrl(appBaseUrl);\n if (appBaseUrl !== maybeNewAppBaseUrl) {\n newAppBaseUrl = maybeNewAppBaseUrl;\n }\n }\n\n // Only add the relative config if there is actually data to add.\n if (newAppBaseUrl || newBackendBaseUrl) {\n configs = configs.concat({\n data: {\n app: newAppBaseUrl && {\n baseUrl: newAppBaseUrl,\n },\n backend: newBackendBaseUrl && {\n baseUrl: newBackendBaseUrl,\n },\n },\n context: 'relative-resolver',\n });\n }\n\n return configs;\n}\n"],"names":[],"mappings":";;AAqBA,SAAS,mBAAmB,OAAyB,EAAA;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AAIF,EAAA,IAAI,iBAAiB,iBAAmB,EAAA;AACtC,IAAA,OAAA,GAAU,QAAQ,MAAO,CAAA;AAAA,MACvB,IAAM,EAAA;AAAA,QACJ,KAAK,aAAiB,IAAA;AAAA,UACpB,OAAS,EAAA;AAAA,SACX;AAAA,QACA,SAAS,iBAAqB,IAAA;AAAA,UAC5B,OAAS,EAAA;AAAA;AACX,OACF;AAAA,MACA,OAAS,EAAA;AAAA,KACV,CAAA;AAAA;AAGH,EAAO,OAAA,OAAA;AACT;;;;"}
|
|
@@ -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 React, { JSX, ReactNode } from 'react';\nimport { ConfigApi } from '@backstage/frontend-plugin-api';\nimport { stringifyError } from '@backstage/errors';\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 { getAvailableFeatures } from './discovery';\nimport { ConfigReader } from '@backstage/config';\nimport appPlugin from '@backstage/plugin-app';\nimport {\n CreateAppRouteBinder,\n FrontendFeature,\n createSpecializedApp,\n} from '@backstage/frontend-app-api';\n\n/**\n * A source of dynamically loaded frontend features.\n *\n * @public\n */\nexport interface CreateAppFeatureLoader {\n /**\n * Returns name of this loader. suitable for showing to users.\n */\n getLoaderName(): string;\n\n /**\n * Loads a number of features dynamically.\n */\n load(options: { config: ConfigApi }): Promise<{\n features: FrontendFeature[];\n }>;\n}\n\n/**\n * Options for {@link createApp}.\n *\n * @public\n */\nexport interface CreateAppOptions {\n features?: (FrontendFeature | CreateAppFeatureLoader)[];\n configLoader?: () => Promise<{ config: ConfigApi }>;\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n /**\n * The component to render while loading the app (waiting for config, features, etc)\n *\n * Is the text \"Loading...\" by default.\n * If set to \"null\" then no loading fallback component is rendered. *\n */\n loadingComponent?: ReactNode;\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?.loadingComponent;\n if (suspenseFallback === undefined) {\n suspenseFallback = 'Loading...';\n }\n\n async function appLoader() {\n const config =\n (await options?.configLoader?.().then(c => c.config)) ??\n ConfigReader.fromConfigs(\n overrideBaseUrlConfigs(defaultConfigLoaderSync()),\n );\n\n const discoveredFeatures = getAvailableFeatures(config);\n\n const providedFeatures: FrontendFeature[] = [];\n for (const entry of options?.features ?? []) {\n if ('load' in entry) {\n try {\n const result = await entry.load({ config });\n providedFeatures.push(...result.features);\n } catch (e) {\n throw new Error(\n `Failed to read frontend features from loader '${entry.getLoaderName()}', ${stringifyError(\n e,\n )}`,\n );\n }\n } else {\n providedFeatures.push(entry);\n }\n }\n\n const app = createSpecializedApp({\n config,\n features: [appPlugin, ...discoveredFeatures, ...providedFeatures],\n bindRoutes: options?.bindRoutes,\n }).createRoot();\n\n return { default: () => app };\n }\n\n return {\n createRoot() {\n const LazyApp = React.lazy(appLoader);\n return (\n <React.Suspense fallback={suspenseFallback}>\n <LazyApp />\n </React.Suspense>\n );\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AA0EO,SAAS,UAAU,OAExB,EAAA;AACA,EAAA,IAAI,mBAAmB,OAAS,EAAA,gBAAA
|
|
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 React, { JSX, ReactNode } from 'react';\nimport { ConfigApi } from '@backstage/frontend-plugin-api';\nimport { stringifyError } from '@backstage/errors';\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 { getAvailableFeatures } from './discovery';\nimport { ConfigReader } from '@backstage/config';\nimport appPlugin from '@backstage/plugin-app';\nimport {\n CreateAppRouteBinder,\n FrontendFeature,\n createSpecializedApp,\n} from '@backstage/frontend-app-api';\n\n/**\n * A source of dynamically loaded frontend features.\n *\n * @public\n */\nexport interface CreateAppFeatureLoader {\n /**\n * Returns name of this loader. suitable for showing to users.\n */\n getLoaderName(): string;\n\n /**\n * Loads a number of features dynamically.\n */\n load(options: { config: ConfigApi }): Promise<{\n features: FrontendFeature[];\n }>;\n}\n\n/**\n * Options for {@link createApp}.\n *\n * @public\n */\nexport interface CreateAppOptions {\n features?: (FrontendFeature | CreateAppFeatureLoader)[];\n configLoader?: () => Promise<{ config: ConfigApi }>;\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n /**\n * The component to render while loading the app (waiting for config, features, etc)\n *\n * Is the text \"Loading...\" by default.\n * If set to \"null\" then no loading fallback component is rendered. *\n */\n loadingComponent?: ReactNode;\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?.loadingComponent;\n if (suspenseFallback === undefined) {\n suspenseFallback = 'Loading...';\n }\n\n async function appLoader() {\n const config =\n (await options?.configLoader?.().then(c => c.config)) ??\n ConfigReader.fromConfigs(\n overrideBaseUrlConfigs(defaultConfigLoaderSync()),\n );\n\n const discoveredFeatures = getAvailableFeatures(config);\n\n const providedFeatures: FrontendFeature[] = [];\n for (const entry of options?.features ?? []) {\n if ('load' in entry) {\n try {\n const result = await entry.load({ config });\n providedFeatures.push(...result.features);\n } catch (e) {\n throw new Error(\n `Failed to read frontend features from loader '${entry.getLoaderName()}', ${stringifyError(\n e,\n )}`,\n );\n }\n } else {\n providedFeatures.push(entry);\n }\n }\n\n const app = createSpecializedApp({\n config,\n features: [appPlugin, ...discoveredFeatures, ...providedFeatures],\n bindRoutes: options?.bindRoutes,\n }).createRoot();\n\n return { default: () => app };\n }\n\n return {\n createRoot() {\n const LazyApp = React.lazy(appLoader);\n return (\n <React.Suspense fallback={suspenseFallback}>\n <LazyApp />\n </React.Suspense>\n );\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AA0EO,SAAS,UAAU,OAExB,EAAA;AACA,EAAA,IAAI,mBAAmB,OAAS,EAAA,gBAAA;AAChC,EAAA,IAAI,qBAAqB,KAAW,CAAA,EAAA;AAClC,IAAmB,gBAAA,GAAA,YAAA;AAAA;AAGrB,EAAA,eAAe,SAAY,GAAA;AACzB,IAAM,MAAA,MAAA,GACH,MAAM,OAAA,EAAS,YAAe,IAAA,CAAE,KAAK,CAAK,CAAA,KAAA,CAAA,CAAE,MAAM,CAAA,IACnD,YAAa,CAAA,WAAA;AAAA,MACX,sBAAA,CAAuB,yBAAyB;AAAA,KAClD;AAEF,IAAM,MAAA,kBAAA,GAAqB,qBAAqB,MAAM,CAAA;AAEtD,IAAA,MAAM,mBAAsC,EAAC;AAC7C,IAAA,KAAA,MAAW,KAAS,IAAA,OAAA,EAAS,QAAY,IAAA,EAAI,EAAA;AAC3C,MAAA,IAAI,UAAU,KAAO,EAAA;AACnB,QAAI,IAAA;AACF,UAAA,MAAM,SAAS,MAAM,KAAA,CAAM,IAAK,CAAA,EAAE,QAAQ,CAAA;AAC1C,UAAiB,gBAAA,CAAA,IAAA,CAAK,GAAG,MAAA,CAAO,QAAQ,CAAA;AAAA,iBACjC,CAAG,EAAA;AACV,UAAA,MAAM,IAAI,KAAA;AAAA,YACR,CAAiD,8CAAA,EAAA,KAAA,CAAM,aAAc,EAAC,CAAM,GAAA,EAAA,cAAA;AAAA,cAC1E;AAAA,aACD,CAAA;AAAA,WACH;AAAA;AACF,OACK,MAAA;AACL,QAAA,gBAAA,CAAiB,KAAK,KAAK,CAAA;AAAA;AAC7B;AAGF,IAAA,MAAM,MAAM,oBAAqB,CAAA;AAAA,MAC/B,MAAA;AAAA,MACA,UAAU,CAAC,SAAA,EAAW,GAAG,kBAAA,EAAoB,GAAG,gBAAgB,CAAA;AAAA,MAChE,YAAY,OAAS,EAAA;AAAA,KACtB,EAAE,UAAW,EAAA;AAEd,IAAO,OAAA,EAAE,OAAS,EAAA,MAAM,GAAI,EAAA;AAAA;AAG9B,EAAO,OAAA;AAAA,IACL,UAAa,GAAA;AACX,MAAM,MAAA,OAAA,GAAU,KAAM,CAAA,IAAA,CAAK,SAAS,CAAA;AACpC,MACE,uBAAA,KAAA,CAAA,aAAA,CAAC,MAAM,QAAN,EAAA,EAAe,UAAU,gBACxB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAQ,CACX,CAAA;AAAA;AAEJ,GACF;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPublicSignInApp.esm.js","sources":["../src/createPublicSignInApp.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 {\n coreExtensionData,\n createFrontendModule,\n identityApiRef,\n useApi,\n} from '@backstage/frontend-plugin-api';\nimport React from 'react';\nimport { useAsync, useMountEffect } from '@react-hookz/web';\nimport { CreateAppOptions, createApp } from './createApp';\nimport appPlugin from '@backstage/plugin-app';\n\n// This is a copy of the CookieAuthRedirect component from the auth-react\n// plugin, to avoid a dependency on that package. Long-term we want this to be\n// the only implementation and remove the one in auth-react once the old frontend system is gone.\n\n// TODO(Rugvip): Should this be part of the app plugin instead? since it owns the backend part of it.\n\n/** @internal */\nexport function InternalCookieAuthRedirect() {\n const identityApi = useApi(identityApiRef);\n\n const [state, actions] = useAsync(async () => {\n const { token } = await identityApi.getCredentials();\n if (!token) {\n throw new Error('Expected Backstage token in sign-in response');\n }\n return token;\n });\n\n useMountEffect(actions.execute);\n\n if (state.status === 'error' && state.error) {\n return <>An error occurred: {state.error.message}</>;\n }\n\n if (state.status === 'success' && state.result) {\n return (\n <form\n ref={form => form?.submit()}\n action={window.location.href}\n method=\"POST\"\n style={{ visibility: 'hidden' }}\n >\n <input type=\"hidden\" name=\"type\" value=\"sign-in\" />\n <input type=\"hidden\" name=\"token\" value={state.result} />\n <input type=\"submit\" value=\"Continue\" />\n </form>\n );\n }\n\n return null;\n}\n\n/**\n * Creates an app that is suitable for the public sign-in page, for use in the `index-public-experimental.tsx` file.\n *\n * @remarks\n *\n * This app has an override for the `app/layout` extension, which means that\n * most extension typically installed in an app will be ignored. However, you\n * can still for example install API and root element extensions.\n *\n * A typical setup of this app will only install a custom sign-in page.\n *\n * @example\n * ```ts\n * const app = createPublicSignInApp({\n * features: [signInPageModule],\n * });\n * ```\n *\n * @public\n */\nexport function createPublicSignInApp(options?: CreateAppOptions) {\n return createApp({\n ...options,\n features: [\n ...(options?.features ?? []),\n // This is a rather than app plugin override in order for it to take precedence over any supplied app plugin override\n createFrontendModule({\n pluginId: 'app',\n extensions: [\n appPlugin.getExtension('app/layout').override({\n factory: () => [\n coreExtensionData.reactElement(<InternalCookieAuthRedirect />),\n ],\n }),\n ],\n }),\n ],\n });\n}\n"],"names":[],"mappings":";;;;;;AAkCO,SAAS,0BAA6B,GAAA;AAC3C,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA
|
|
1
|
+
{"version":3,"file":"createPublicSignInApp.esm.js","sources":["../src/createPublicSignInApp.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 {\n coreExtensionData,\n createFrontendModule,\n identityApiRef,\n useApi,\n} from '@backstage/frontend-plugin-api';\nimport React from 'react';\nimport { useAsync, useMountEffect } from '@react-hookz/web';\nimport { CreateAppOptions, createApp } from './createApp';\nimport appPlugin from '@backstage/plugin-app';\n\n// This is a copy of the CookieAuthRedirect component from the auth-react\n// plugin, to avoid a dependency on that package. Long-term we want this to be\n// the only implementation and remove the one in auth-react once the old frontend system is gone.\n\n// TODO(Rugvip): Should this be part of the app plugin instead? since it owns the backend part of it.\n\n/** @internal */\nexport function InternalCookieAuthRedirect() {\n const identityApi = useApi(identityApiRef);\n\n const [state, actions] = useAsync(async () => {\n const { token } = await identityApi.getCredentials();\n if (!token) {\n throw new Error('Expected Backstage token in sign-in response');\n }\n return token;\n });\n\n useMountEffect(actions.execute);\n\n if (state.status === 'error' && state.error) {\n return <>An error occurred: {state.error.message}</>;\n }\n\n if (state.status === 'success' && state.result) {\n return (\n <form\n ref={form => form?.submit()}\n action={window.location.href}\n method=\"POST\"\n style={{ visibility: 'hidden' }}\n >\n <input type=\"hidden\" name=\"type\" value=\"sign-in\" />\n <input type=\"hidden\" name=\"token\" value={state.result} />\n <input type=\"submit\" value=\"Continue\" />\n </form>\n );\n }\n\n return null;\n}\n\n/**\n * Creates an app that is suitable for the public sign-in page, for use in the `index-public-experimental.tsx` file.\n *\n * @remarks\n *\n * This app has an override for the `app/layout` extension, which means that\n * most extension typically installed in an app will be ignored. However, you\n * can still for example install API and root element extensions.\n *\n * A typical setup of this app will only install a custom sign-in page.\n *\n * @example\n * ```ts\n * const app = createPublicSignInApp({\n * features: [signInPageModule],\n * });\n * ```\n *\n * @public\n */\nexport function createPublicSignInApp(options?: CreateAppOptions) {\n return createApp({\n ...options,\n features: [\n ...(options?.features ?? []),\n // This is a rather than app plugin override in order for it to take precedence over any supplied app plugin override\n createFrontendModule({\n pluginId: 'app',\n extensions: [\n appPlugin.getExtension('app/layout').override({\n factory: () => [\n coreExtensionData.reactElement(<InternalCookieAuthRedirect />),\n ],\n }),\n ],\n }),\n ],\n });\n}\n"],"names":[],"mappings":";;;;;;AAkCO,SAAS,0BAA6B,GAAA;AAC3C,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA;AAEzC,EAAA,MAAM,CAAC,KAAA,EAAO,OAAO,CAAA,GAAI,SAAS,YAAY;AAC5C,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAM,YAAY,cAAe,EAAA;AACnD,IAAA,IAAI,CAAC,KAAO,EAAA;AACV,MAAM,MAAA,IAAI,MAAM,8CAA8C,CAAA;AAAA;AAEhE,IAAO,OAAA,KAAA;AAAA,GACR,CAAA;AAED,EAAA,cAAA,CAAe,QAAQ,OAAO,CAAA;AAE9B,EAAA,IAAI,KAAM,CAAA,MA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S,MAAM;AAAA,cACb,iBAAkB,CAAA,YAAA,iBAAc,KAAA,CAAA,aAAA,CAAA,0BAAA,EAAA,IAA2B,CAAE;AAAA;AAC/D,WACD;AAAA;AACH,OACD;AAAA;AACH,GACD,CAAA;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.esm.js","sources":["../src/discovery.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config, ConfigReader } from '@backstage/config';\nimport { FrontendFeature } from '@backstage/frontend-app-api';\n\ninterface DiscoveryGlobal {\n modules: Array<{ name: string; export?: string; default: unknown }>;\n}\n\nfunction readPackageDetectionConfig(config: Config) {\n const packages = config.getOptional('app.experimental.packages');\n if (packages === undefined || packages === null) {\n return undefined;\n }\n\n if (typeof packages === 'string') {\n if (packages !== 'all') {\n throw new Error(\n `Invalid app.experimental.packages mode, got '${packages}', expected 'all'`,\n );\n }\n return {};\n }\n\n if (typeof packages !== 'object' || Array.isArray(packages)) {\n throw new Error(\n \"Invalid config at 'app.experimental.packages', expected object\",\n );\n }\n const packagesConfig = new ConfigReader(\n packages,\n 'app.experimental.packages',\n );\n\n return {\n include: packagesConfig.getOptionalStringArray('include'),\n exclude: packagesConfig.getOptionalStringArray('exclude'),\n };\n}\n\n/**\n * @internal\n */\nexport function getAvailableFeatures(config: Config): FrontendFeature[] {\n const discovered = (\n window as { '__@backstage/discovered__'?: DiscoveryGlobal }\n )['__@backstage/discovered__'];\n\n const detection = readPackageDetectionConfig(config);\n if (!detection) {\n return [];\n }\n\n return (\n discovered?.modules\n .filter(({ name }) => {\n if (detection.exclude?.includes(name)) {\n return false;\n }\n if (detection.include && !detection.include.includes(name)) {\n return false;\n }\n return true;\n })\n .map(m => m.default)\n .filter(isBackstageFeature) ?? []\n );\n}\n\nfunction isBackstageFeature(obj: unknown): obj is FrontendFeature {\n if (obj !== null && typeof obj === 'object' && '$$type' in obj) {\n return (\n obj.$$type === '@backstage/FrontendPlugin' ||\n obj.$$type === '@backstage/FrontendModule' ||\n // TODO: Remove this once the old plugin type and extension overrides\n // are no longer supported\n obj.$$type === '@backstage/BackstagePlugin' ||\n obj.$$type === '@backstage/ExtensionOverrides'\n );\n }\n return false;\n}\n"],"names":[],"mappings":";;AAuBA,SAAS,2BAA2B,MAAgB,EAAA;AAClD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,WAAA,CAAY,2BAA2B,CAAA
|
|
1
|
+
{"version":3,"file":"discovery.esm.js","sources":["../src/discovery.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Config, ConfigReader } from '@backstage/config';\nimport { FrontendFeature } from '@backstage/frontend-app-api';\n\ninterface DiscoveryGlobal {\n modules: Array<{ name: string; export?: string; default: unknown }>;\n}\n\nfunction readPackageDetectionConfig(config: Config) {\n const packages = config.getOptional('app.experimental.packages');\n if (packages === undefined || packages === null) {\n return undefined;\n }\n\n if (typeof packages === 'string') {\n if (packages !== 'all') {\n throw new Error(\n `Invalid app.experimental.packages mode, got '${packages}', expected 'all'`,\n );\n }\n return {};\n }\n\n if (typeof packages !== 'object' || Array.isArray(packages)) {\n throw new Error(\n \"Invalid config at 'app.experimental.packages', expected object\",\n );\n }\n const packagesConfig = new ConfigReader(\n packages,\n 'app.experimental.packages',\n );\n\n return {\n include: packagesConfig.getOptionalStringArray('include'),\n exclude: packagesConfig.getOptionalStringArray('exclude'),\n };\n}\n\n/**\n * @internal\n */\nexport function getAvailableFeatures(config: Config): FrontendFeature[] {\n const discovered = (\n window as { '__@backstage/discovered__'?: DiscoveryGlobal }\n )['__@backstage/discovered__'];\n\n const detection = readPackageDetectionConfig(config);\n if (!detection) {\n return [];\n }\n\n return (\n discovered?.modules\n .filter(({ name }) => {\n if (detection.exclude?.includes(name)) {\n return false;\n }\n if (detection.include && !detection.include.includes(name)) {\n return false;\n }\n return true;\n })\n .map(m => m.default)\n .filter(isBackstageFeature) ?? []\n );\n}\n\nfunction isBackstageFeature(obj: unknown): obj is FrontendFeature {\n if (obj !== null && typeof obj === 'object' && '$$type' in obj) {\n return (\n obj.$$type === '@backstage/FrontendPlugin' ||\n obj.$$type === '@backstage/FrontendModule' ||\n // TODO: Remove this once the old plugin type and extension overrides\n // are no longer supported\n obj.$$type === '@backstage/BackstagePlugin' ||\n obj.$$type === '@backstage/ExtensionOverrides'\n );\n }\n return false;\n}\n"],"names":[],"mappings":";;AAuBA,SAAS,2BAA2B,MAAgB,EAAA;AAClD,EAAM,MAAA,QAAA,GAAW,MAAO,CAAA,WAAA,CAAY,2BAA2B,CAAA;AAC/D,EAAI,IAAA,QAAA,KAAa,KAAa,CAAA,IAAA,QAAA,KAAa,IAAM,EAAA;AAC/C,IAAO,OAAA,KAAA,CAAA;AAAA;AAGT,EAAI,IAAA,OAAO,aAAa,QAAU,EAAA;AAChC,IAAA,IAAI,aAAa,KAAO,EAAA;AACtB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,gDAAgD,QAAQ,CAAA,iBAAA;AAAA,OAC1D;AAAA;AAEF,IAAA,OAAO,EAAC;AAAA;AAGV,EAAA,IAAI,OAAO,QAAa,KAAA,QAAA,IAAY,KAA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AAA,GAAA,CAAI,MAAW,KAAA,+BAAA;AAAA;AAGnB,EAAO,OAAA,KAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-defaults",
|
|
3
|
-
"version": "0.1.2-next.
|
|
3
|
+
"version": "0.1.2-next.2",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@backstage/config": "1.2.0",
|
|
35
35
|
"@backstage/errors": "1.2.4",
|
|
36
|
-
"@backstage/frontend-app-api": "0.10.1-next.
|
|
37
|
-
"@backstage/frontend-plugin-api": "0.9.1-next.
|
|
38
|
-
"@backstage/plugin-app": "0.1.2-next.
|
|
36
|
+
"@backstage/frontend-app-api": "0.10.1-next.2",
|
|
37
|
+
"@backstage/frontend-plugin-api": "0.9.1-next.2",
|
|
38
|
+
"@backstage/plugin-app": "0.1.2-next.2",
|
|
39
39
|
"@react-hookz/web": "^24.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@backstage/cli": "0.29.0-next.
|
|
42
|
+
"@backstage/cli": "0.29.0-next.3",
|
|
43
43
|
"@backstage/core-plugin-api": "1.10.0",
|
|
44
|
-
"@backstage/test-utils": "1.7.0",
|
|
44
|
+
"@backstage/test-utils": "1.7.1-next.0",
|
|
45
45
|
"@testing-library/jest-dom": "^6.0.0",
|
|
46
46
|
"@testing-library/react": "^16.0.0",
|
|
47
47
|
"@types/react": "^18.0.0",
|
|
@@ -60,5 +60,12 @@
|
|
|
60
60
|
"optional": true
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
+
"typesVersions": {
|
|
64
|
+
"*": {
|
|
65
|
+
"index": [
|
|
66
|
+
"dist/index.d.ts"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
},
|
|
63
70
|
"module": "./dist/index.esm.js"
|
|
64
71
|
}
|