@backstage/frontend-app-api 0.9.0-next.0 → 0.9.0-next.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.
Files changed (26) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/extensions/Root.esm.js +0 -1
  3. package/dist/extensions/Root.esm.js.map +1 -1
  4. package/dist/frontend-plugin-api/src/wiring/createExtension.esm.js.map +1 -1
  5. package/dist/frontend-plugin-api/src/wiring/createExtensionOverrides.esm.js.map +1 -1
  6. package/dist/frontend-plugin-api/src/wiring/createFrontendModule.esm.js +25 -0
  7. package/dist/frontend-plugin-api/src/wiring/createFrontendModule.esm.js.map +1 -0
  8. package/dist/frontend-plugin-api/src/wiring/createFrontendPlugin.esm.js +10 -3
  9. package/dist/frontend-plugin-api/src/wiring/createFrontendPlugin.esm.js.map +1 -1
  10. package/dist/frontend-plugin-api/src/wiring/resolveExtensionDefinition.esm.js.map +1 -1
  11. package/dist/index.d.ts +21 -40
  12. package/dist/index.esm.js +1 -1
  13. package/dist/routing/collectRouteIds.esm.js +2 -1
  14. package/dist/routing/collectRouteIds.esm.js.map +1 -1
  15. package/dist/tree/resolveAppNodeSpecs.esm.js +42 -5
  16. package/dist/tree/resolveAppNodeSpecs.esm.js.map +1 -1
  17. package/dist/wiring/{createApp.esm.js → createSpecializedApp.esm.js} +24 -60
  18. package/dist/wiring/createSpecializedApp.esm.js.map +1 -0
  19. package/package.json +5 -8
  20. package/dist/core-app-api/src/app/defaultConfigLoader.esm.js +0 -33
  21. package/dist/core-app-api/src/app/defaultConfigLoader.esm.js.map +0 -1
  22. package/dist/core-app-api/src/app/overrideBaseUrlConfigs.esm.js +0 -50
  23. package/dist/core-app-api/src/app/overrideBaseUrlConfigs.esm.js.map +0 -1
  24. package/dist/wiring/createApp.esm.js.map +0 -1
  25. package/dist/wiring/discovery.esm.js +0 -54
  26. package/dist/wiring/discovery.esm.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @backstage/frontend-app-api
2
2
 
3
+ ## 0.9.0-next.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 7c80650: **BREAKING**: The `createSpecializedApp` function now creates a bare-bones app without any of the default app structure or APIs. To re-introduce this functionality if you need to use `createSpecializedApp` you can install the `app` plugin from `@backstage/plugin-app`.
8
+
9
+ In addition, the `createApp` and `CreateAppFeatureLoader` exports are now deprecated as they are being moved to `@backstage/frontend-defaults`, which should be used instead.
10
+
11
+ ### Patch Changes
12
+
13
+ - c816e2d: Added support for new `FrontendPlugin` and `FrontendModule` types.
14
+ - 948d431: Removing deprecated `namespace` parameter in favour of `pluginId` instead
15
+ - Updated dependencies
16
+ - @backstage/frontend-defaults@0.1.0-next.0
17
+ - @backstage/frontend-plugin-api@0.8.0-next.1
18
+ - @backstage/config@1.2.0
19
+ - @backstage/core-app-api@1.14.2
20
+ - @backstage/core-plugin-api@1.9.3
21
+ - @backstage/errors@1.2.4
22
+ - @backstage/types@1.1.1
23
+ - @backstage/version-bridge@1.0.8
24
+
3
25
  ## 0.9.0-next.0
4
26
 
5
27
  ### Minor Changes
@@ -1,7 +1,6 @@
1
1
  import { createExtension, createExtensionInput, coreExtensionData, ApiBlueprint } from '@backstage/frontend-plugin-api';
2
2
 
3
3
  const Root = createExtension({
4
- namespace: "root",
5
4
  attachTo: { id: "ignored", input: "ignored" },
6
5
  inputs: {
7
6
  app: createExtensionInput([coreExtensionData.reactElement], {
@@ -1 +1 @@
1
- {"version":3,"file":"Root.esm.js","sources":["../../src/extensions/Root.ts"],"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 ApiBlueprint,\n coreExtensionData,\n createExtension,\n createExtensionInput,\n} from '@backstage/frontend-plugin-api';\n\nexport const Root = createExtension({\n namespace: 'root',\n attachTo: { id: 'ignored', input: 'ignored' },\n inputs: {\n app: createExtensionInput([coreExtensionData.reactElement], {\n singleton: true,\n }),\n apis: createExtensionInput([ApiBlueprint.dataRefs.factory], {\n replaces: [{ id: 'app', input: 'apis' }],\n }),\n },\n output: [coreExtensionData.reactElement],\n factory: ({ inputs }) => inputs.app,\n});\n"],"names":[],"mappings":";;AAuBO,MAAM,OAAO,eAAgB,CAAA;AAAA,EAClC,SAAW,EAAA,MAAA;AAAA,EACX,QAAU,EAAA,EAAE,EAAI,EAAA,SAAA,EAAW,OAAO,SAAU,EAAA;AAAA,EAC5C,MAAQ,EAAA;AAAA,IACN,GAAK,EAAA,oBAAA,CAAqB,CAAC,iBAAA,CAAkB,YAAY,CAAG,EAAA;AAAA,MAC1D,SAAW,EAAA,IAAA;AAAA,KACZ,CAAA;AAAA,IACD,MAAM,oBAAqB,CAAA,CAAC,YAAa,CAAA,QAAA,CAAS,OAAO,CAAG,EAAA;AAAA,MAC1D,UAAU,CAAC,EAAE,IAAI,KAAO,EAAA,KAAA,EAAO,QAAQ,CAAA;AAAA,KACxC,CAAA;AAAA,GACH;AAAA,EACA,MAAA,EAAQ,CAAC,iBAAA,CAAkB,YAAY,CAAA;AAAA,EACvC,OAAS,EAAA,CAAC,EAAE,MAAA,OAAa,MAAO,CAAA,GAAA;AAClC,CAAC;;;;"}
1
+ {"version":3,"file":"Root.esm.js","sources":["../../src/extensions/Root.ts"],"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 ApiBlueprint,\n coreExtensionData,\n createExtension,\n createExtensionInput,\n} from '@backstage/frontend-plugin-api';\n\nexport const Root = createExtension({\n attachTo: { id: 'ignored', input: 'ignored' },\n inputs: {\n app: createExtensionInput([coreExtensionData.reactElement], {\n singleton: true,\n }),\n apis: createExtensionInput([ApiBlueprint.dataRefs.factory], {\n replaces: [{ id: 'app', input: 'apis' }],\n }),\n },\n output: [coreExtensionData.reactElement],\n factory: ({ inputs }) => inputs.app,\n});\n"],"names":[],"mappings":";;AAuBO,MAAM,OAAO,eAAgB,CAAA;AAAA,EAClC,QAAU,EAAA,EAAE,EAAI,EAAA,SAAA,EAAW,OAAO,SAAU,EAAA;AAAA,EAC5C,MAAQ,EAAA;AAAA,IACN,GAAK,EAAA,oBAAA,CAAqB,CAAC,iBAAA,CAAkB,YAAY,CAAG,EAAA;AAAA,MAC1D,SAAW,EAAA,IAAA;AAAA,KACZ,CAAA;AAAA,IACD,MAAM,oBAAqB,CAAA,CAAC,YAAa,CAAA,QAAA,CAAS,OAAO,CAAG,EAAA;AAAA,MAC1D,UAAU,CAAC,EAAE,IAAI,KAAO,EAAA,KAAA,EAAO,QAAQ,CAAA;AAAA,KACxC,CAAA;AAAA,GACH;AAAA,EACA,MAAA,EAAQ,CAAC,iBAAA,CAAkB,YAAY,CAAA;AAAA,EACvC,OAAS,EAAA,CAAC,EAAE,MAAA,OAAa,MAAO,CAAA,GAAA;AAClC,CAAC;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createExtension.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createExtension.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 { ApiHolder, AppNode } from '../apis';\nimport { PortableSchema } from '../schema';\nimport { Expand } from '../types';\nimport {\n ResolveInputValueOverrides,\n resolveInputOverrides,\n} from './resolveInputOverrides';\nimport {\n ExtensionDataContainer,\n createExtensionDataContainer,\n} from './createExtensionDataContainer';\nimport {\n AnyExtensionDataRef,\n ExtensionDataValue,\n} from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport { z } from 'zod';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\n\n/**\n * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<\n TExtensionInput extends ExtensionInput<any, any>,\n> = TExtensionInput['extensionData'] extends Array<AnyExtensionDataRef>\n ? {\n node: AppNode;\n } & ExtensionDataContainer<TExtensionInput['extensionData'][number]>\n : never;\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends {\n [name in string]: ExtensionInput<any, any>;\n },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]>>\n : Expand<ResolvedExtensionInput<TInputs[InputName]> | undefined>;\n};\n\ntype ToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\ntype PopUnion<U> = ToIntersection<\n U extends any ? () => U : never\n> extends () => infer R\n ? [rest: Exclude<U, R>, next: R]\n : undefined;\n\n/** @ignore */\ntype JoinStringUnion<\n U,\n TDiv extends string = ', ',\n TResult extends string = '',\n> = PopUnion<U> extends [infer IRest extends string, infer INext extends string]\n ? TResult extends ''\n ? JoinStringUnion<IRest, TDiv, INext>\n : JoinStringUnion<IRest, TDiv, `${TResult}${TDiv}${INext}`>\n : TResult;\n\n/** @ignore */\nexport type VerifyExtensionFactoryOutput<\n UDeclaredOutput extends AnyExtensionDataRef,\n UFactoryOutput extends ExtensionDataValue<any, any>,\n> = (\n UDeclaredOutput extends any\n ? UDeclaredOutput['config']['optional'] extends true\n ? never\n : UDeclaredOutput['id']\n : never\n) extends infer IRequiredOutputIds\n ? [IRequiredOutputIds] extends [UFactoryOutput['id']]\n ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']]\n ? {}\n : `Error: The extension factory has undeclared output(s): ${JoinStringUnion<\n Exclude<UFactoryOutput['id'], UDeclaredOutput['id']>\n >}`\n : `Error: The extension factory is missing the following output(s): ${JoinStringUnion<\n Exclude<IRequiredOutputIds, UFactoryOutput['id']>\n >}`\n : never;\n\n/** @public */\nexport type CreateExtensionOptions<\n TKind extends string | undefined,\n TNamespace extends string | undefined,\n TName extends string | undefined,\n UOutput extends AnyExtensionDataRef,\n TInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n> = {\n kind?: TKind;\n namespace?: TNamespace;\n name?: TName;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: Array<UOutput>;\n config?: {\n schema: TConfigSchema;\n };\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }): Iterable<UFactoryOutput>;\n} & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;\n\n/** @public */\nexport type ExtensionDefinitionParameters = {\n kind?: string;\n namespace?: string;\n name?: string;\n configInput?: { [K in string]: any };\n config?: { [K in string]: any };\n output?: AnyExtensionDataRef;\n inputs?: {\n [KName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n };\n};\n\n/** @public */\nexport type ExtensionDefinition<\n T extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> = {\n $$type: '@backstage/ExtensionDefinition';\n readonly T: T;\n\n override<\n TExtensionConfigSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n UNewOutput extends AnyExtensionDataRef,\n TExtraInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n >(\n args: {\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TExtraInputs & {\n [KName in keyof T['inputs']]?: `Error: Input '${KName &\n string}' is already defined in parent definition`;\n };\n output?: Array<UNewOutput>;\n config?: {\n schema: TExtensionConfigSchema & {\n [KName in keyof T['config']]?: `Error: Config key '${KName &\n string}' is already defined in parent schema`;\n };\n };\n factory(\n originalFactory: (context?: {\n config?: T['config'];\n inputs?: ResolveInputValueOverrides<NonNullable<T['inputs']>>;\n }) => ExtensionDataContainer<NonNullable<T['output']>>,\n context: {\n node: AppNode;\n apis: ApiHolder;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n inputs: Expand<ResolvedExtensionInputs<T['inputs'] & TExtraInputs>>;\n },\n ): Iterable<UFactoryOutput>;\n } & VerifyExtensionFactoryOutput<\n AnyExtensionDataRef extends UNewOutput\n ? NonNullable<T['output']>\n : UNewOutput,\n UFactoryOutput\n >,\n ): ExtensionDefinition<{\n kind: T['kind'];\n namespace: T['namespace'];\n name: T['name'];\n output: AnyExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput;\n inputs: T['inputs'] & TExtraInputs;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n configInput: T['configInput'] &\n z.input<\n z.ZodObject<{\n [key in keyof TExtensionConfigSchema]: ReturnType<\n TExtensionConfigSchema[key]\n >;\n }>\n >;\n }>;\n};\n\n/** @internal */\nexport type InternalExtensionDefinition<\n T extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> = ExtensionDefinition<T> & {\n readonly kind?: string;\n readonly namespace?: string;\n readonly name?: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<T['config'], T['configInput']>;\n} & (\n | {\n readonly version: 'v1';\n readonly inputs: {\n [inputName in string]: {\n $$type: '@backstage/ExtensionInput';\n extensionData: {\n [name in string]: AnyExtensionDataRef;\n };\n config: { optional: boolean; singleton: boolean };\n };\n };\n readonly output: {\n [name in string]: AnyExtensionDataRef;\n };\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: object;\n inputs: {\n [inputName in string]: unknown;\n };\n }): {\n [inputName in string]: unknown;\n };\n }\n | {\n readonly version: 'v2';\n readonly inputs: {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n };\n readonly output: Array<AnyExtensionDataRef>;\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: object;\n inputs: ResolvedExtensionInputs<{\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n }>;\n }): Iterable<ExtensionDataValue<any, any>>;\n }\n );\n\n/** @internal */\nexport function toInternalExtensionDefinition<\n T extends ExtensionDefinitionParameters,\n>(overrides: ExtensionDefinition<T>): InternalExtensionDefinition<T> {\n const internal = overrides as InternalExtensionDefinition<T>;\n if (internal.$$type !== '@backstage/ExtensionDefinition') {\n throw new Error(\n `Invalid extension definition instance, bad type '${internal.$$type}'`,\n );\n }\n const version = internal.version;\n if (version !== 'v1' && version !== 'v2') {\n throw new Error(\n `Invalid extension definition instance, bad version '${version}'`,\n );\n }\n return internal;\n}\n\n/** @public */\nexport function createExtension<\n UOutput extends AnyExtensionDataRef,\n TInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n const TKind extends string | undefined = undefined,\n const TNamespace extends string | undefined = undefined,\n const TName extends string | undefined = undefined,\n>(\n options: CreateExtensionOptions<\n TKind,\n TNamespace,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput\n >,\n): ExtensionDefinition<{\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n namespace: string | undefined extends TNamespace ? undefined : TNamespace;\n name: string | undefined extends TName ? undefined : TName;\n}> {\n type T = {\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n namespace: string | undefined extends TNamespace ? undefined : TNamespace;\n name: string | undefined extends TName ? undefined : TName;\n };\n\n const schemaDeclaration = options.config?.schema;\n const configSchema =\n schemaDeclaration &&\n createSchemaFromZod(innerZ =>\n innerZ.object(\n Object.fromEntries(\n Object.entries(schemaDeclaration).map(([k, v]) => [k, v(innerZ)]),\n ),\n ),\n );\n\n return {\n $$type: '@backstage/ExtensionDefinition',\n version: 'v2',\n T: undefined as unknown as T,\n kind: options.kind,\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo,\n disabled: options.disabled ?? false,\n inputs: options.inputs ?? {},\n output: options.output,\n configSchema,\n factory: options.factory,\n toString() {\n const parts: string[] = [];\n if (options.kind) {\n parts.push(`kind=${options.kind}`);\n }\n if (options.namespace) {\n parts.push(`namespace=${options.namespace}`);\n }\n if (options.name) {\n parts.push(`name=${options.name}`);\n }\n parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`);\n return `ExtensionDefinition{${parts.join(',')}}`;\n },\n override(overrideOptions) {\n if (!Array.isArray(options.output)) {\n throw new Error(\n 'Cannot override an extension that is not declared using the new format with outputs as an array',\n );\n }\n const newOptions = options as CreateExtensionOptions<\n TKind,\n TNamespace,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput\n >;\n\n return createExtension({\n kind: newOptions.kind,\n namespace: newOptions.namespace,\n name: newOptions.name,\n attachTo: overrideOptions.attachTo ?? newOptions.attachTo,\n disabled: overrideOptions.disabled ?? newOptions.disabled,\n inputs: { ...overrideOptions.inputs, ...newOptions.inputs },\n output: (overrideOptions.output ??\n newOptions.output) as AnyExtensionDataRef[],\n config:\n newOptions.config || overrideOptions.config\n ? {\n schema: {\n ...newOptions.config?.schema,\n ...overrideOptions.config?.schema,\n },\n }\n : undefined,\n factory: ({ node, apis, config, inputs }) => {\n if (!overrideOptions.factory) {\n return newOptions.factory({\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n });\n }\n const parentResult = overrideOptions.factory(\n (innerContext): ExtensionDataContainer<UOutput> => {\n return createExtensionDataContainer<UOutput>(\n newOptions.factory({\n node,\n apis,\n config: (innerContext?.config ?? config) as any,\n inputs: resolveInputOverrides(\n newOptions.inputs,\n inputs,\n innerContext?.inputs,\n ) as any,\n }) as Iterable<any>,\n newOptions.output,\n );\n },\n {\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n },\n );\n\n const deduplicatedResult = new Map<\n string,\n ExtensionDataValue<any, any>\n >();\n for (const item of parentResult) {\n deduplicatedResult.set(item.id, item);\n }\n\n return deduplicatedResult.values();\n },\n }) as ExtensionDefinition<any>;\n },\n } as InternalExtensionDefinition<T>;\n}\n"],"names":[],"mappings":";;;AAySO,SAAS,8BAEd,SAAmE,EAAA;AACnE,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,gCAAkC,EAAA;AACxD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,iDAAA,EAAoD,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,KACrE,CAAA;AAAA,GACF;AACA,EAAA,MAAM,UAAU,QAAS,CAAA,OAAA,CAAA;AACzB,EAAI,IAAA,OAAA,KAAY,IAAQ,IAAA,OAAA,KAAY,IAAM,EAAA;AACxC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uDAAuD,OAAO,CAAA,CAAA,CAAA;AAAA,KAChE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"createExtension.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createExtension.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 { ApiHolder, AppNode } from '../apis';\nimport { PortableSchema } from '../schema';\nimport { Expand } from '../types';\nimport {\n ResolveInputValueOverrides,\n resolveInputOverrides,\n} from './resolveInputOverrides';\nimport {\n ExtensionDataContainer,\n createExtensionDataContainer,\n} from './createExtensionDataContainer';\nimport {\n AnyExtensionDataRef,\n ExtensionDataValue,\n} from './createExtensionDataRef';\nimport { ExtensionInput } from './createExtensionInput';\nimport { z } from 'zod';\nimport { createSchemaFromZod } from '../schema/createSchemaFromZod';\n\n/**\n * Convert a single extension input into a matching resolved input.\n * @public\n */\nexport type ResolvedExtensionInput<\n TExtensionInput extends ExtensionInput<any, any>,\n> = TExtensionInput['extensionData'] extends Array<AnyExtensionDataRef>\n ? {\n node: AppNode;\n } & ExtensionDataContainer<TExtensionInput['extensionData'][number]>\n : never;\n\n/**\n * Converts an extension input map into a matching collection of resolved inputs.\n * @public\n */\nexport type ResolvedExtensionInputs<\n TInputs extends {\n [name in string]: ExtensionInput<any, any>;\n },\n> = {\n [InputName in keyof TInputs]: false extends TInputs[InputName]['config']['singleton']\n ? Array<Expand<ResolvedExtensionInput<TInputs[InputName]>>>\n : false extends TInputs[InputName]['config']['optional']\n ? Expand<ResolvedExtensionInput<TInputs[InputName]>>\n : Expand<ResolvedExtensionInput<TInputs[InputName]> | undefined>;\n};\n\ntype ToIntersection<U> = (U extends any ? (k: U) => void : never) extends (\n k: infer I,\n) => void\n ? I\n : never;\n\ntype PopUnion<U> = ToIntersection<\n U extends any ? () => U : never\n> extends () => infer R\n ? [rest: Exclude<U, R>, next: R]\n : undefined;\n\n/** @ignore */\ntype JoinStringUnion<\n U,\n TDiv extends string = ', ',\n TResult extends string = '',\n> = PopUnion<U> extends [infer IRest extends string, infer INext extends string]\n ? TResult extends ''\n ? JoinStringUnion<IRest, TDiv, INext>\n : JoinStringUnion<IRest, TDiv, `${TResult}${TDiv}${INext}`>\n : TResult;\n\n/** @ignore */\nexport type VerifyExtensionFactoryOutput<\n UDeclaredOutput extends AnyExtensionDataRef,\n UFactoryOutput extends ExtensionDataValue<any, any>,\n> = (\n UDeclaredOutput extends any\n ? UDeclaredOutput['config']['optional'] extends true\n ? never\n : UDeclaredOutput['id']\n : never\n) extends infer IRequiredOutputIds\n ? [IRequiredOutputIds] extends [UFactoryOutput['id']]\n ? [UFactoryOutput['id']] extends [UDeclaredOutput['id']]\n ? {}\n : `Error: The extension factory has undeclared output(s): ${JoinStringUnion<\n Exclude<UFactoryOutput['id'], UDeclaredOutput['id']>\n >}`\n : `Error: The extension factory is missing the following output(s): ${JoinStringUnion<\n Exclude<IRequiredOutputIds, UFactoryOutput['id']>\n >}`\n : never;\n\n/** @public */\nexport type CreateExtensionOptions<\n TKind extends string | undefined,\n TNamespace extends string | undefined,\n TName extends string | undefined,\n UOutput extends AnyExtensionDataRef,\n TInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n> = {\n kind?: TKind;\n namespace?: TNamespace;\n name?: TName;\n attachTo: { id: string; input: string };\n disabled?: boolean;\n inputs?: TInputs;\n output: Array<UOutput>;\n config?: {\n schema: TConfigSchema;\n };\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }): Iterable<UFactoryOutput>;\n} & VerifyExtensionFactoryOutput<UOutput, UFactoryOutput>;\n\n/** @public */\nexport type ExtensionDefinitionParameters = {\n kind?: string;\n namespace?: string;\n name?: string;\n configInput?: { [K in string]: any };\n config?: { [K in string]: any };\n output?: AnyExtensionDataRef;\n inputs?: {\n [KName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n };\n};\n\n/** @public */\nexport type ExtensionDefinition<\n T extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> = {\n $$type: '@backstage/ExtensionDefinition';\n readonly T: T;\n\n override<\n TExtensionConfigSchema extends {\n [key in string]: (zImpl: typeof z) => z.ZodType;\n },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n UNewOutput extends AnyExtensionDataRef,\n TExtraInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n >(\n args: {\n attachTo?: { id: string; input: string };\n disabled?: boolean;\n inputs?: TExtraInputs & {\n [KName in keyof T['inputs']]?: `Error: Input '${KName &\n string}' is already defined in parent definition`;\n };\n output?: Array<UNewOutput>;\n config?: {\n schema: TExtensionConfigSchema & {\n [KName in keyof T['config']]?: `Error: Config key '${KName &\n string}' is already defined in parent schema`;\n };\n };\n factory(\n originalFactory: (context?: {\n config?: T['config'];\n inputs?: ResolveInputValueOverrides<NonNullable<T['inputs']>>;\n }) => ExtensionDataContainer<NonNullable<T['output']>>,\n context: {\n node: AppNode;\n apis: ApiHolder;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n inputs: Expand<ResolvedExtensionInputs<T['inputs'] & TExtraInputs>>;\n },\n ): Iterable<UFactoryOutput>;\n } & VerifyExtensionFactoryOutput<\n AnyExtensionDataRef extends UNewOutput\n ? NonNullable<T['output']>\n : UNewOutput,\n UFactoryOutput\n >,\n ): ExtensionDefinition<{\n kind: T['kind'];\n namespace: T['namespace'];\n name: T['name'];\n output: AnyExtensionDataRef extends UNewOutput ? T['output'] : UNewOutput;\n inputs: T['inputs'] & TExtraInputs;\n config: T['config'] & {\n [key in keyof TExtensionConfigSchema]: z.infer<\n ReturnType<TExtensionConfigSchema[key]>\n >;\n };\n configInput: T['configInput'] &\n z.input<\n z.ZodObject<{\n [key in keyof TExtensionConfigSchema]: ReturnType<\n TExtensionConfigSchema[key]\n >;\n }>\n >;\n }>;\n};\n\n/** @internal */\nexport type InternalExtensionDefinition<\n T extends ExtensionDefinitionParameters = ExtensionDefinitionParameters,\n> = ExtensionDefinition<T> & {\n readonly kind?: string;\n readonly namespace?: string;\n readonly name?: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<T['config'], T['configInput']>;\n} & (\n | {\n readonly version: 'v1';\n readonly inputs: {\n [inputName in string]: {\n $$type: '@backstage/ExtensionInput';\n extensionData: {\n [name in string]: AnyExtensionDataRef;\n };\n config: { optional: boolean; singleton: boolean };\n };\n };\n readonly output: {\n [name in string]: AnyExtensionDataRef;\n };\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: object;\n inputs: {\n [inputName in string]: unknown;\n };\n }): {\n [inputName in string]: unknown;\n };\n }\n | {\n readonly version: 'v2';\n readonly inputs: {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n };\n readonly output: Array<AnyExtensionDataRef>;\n factory(context: {\n node: AppNode;\n apis: ApiHolder;\n config: object;\n inputs: ResolvedExtensionInputs<{\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n }>;\n }): Iterable<ExtensionDataValue<any, any>>;\n }\n );\n\n/** @internal */\nexport function toInternalExtensionDefinition<\n T extends ExtensionDefinitionParameters,\n>(overrides: ExtensionDefinition<T>): InternalExtensionDefinition<T> {\n const internal = overrides as InternalExtensionDefinition<T>;\n if (internal.$$type !== '@backstage/ExtensionDefinition') {\n throw new Error(\n `Invalid extension definition instance, bad type '${internal.$$type}'`,\n );\n }\n const version = internal.version;\n if (version !== 'v1' && version !== 'v2') {\n throw new Error(\n `Invalid extension definition instance, bad version '${version}'`,\n );\n }\n return internal;\n}\n\n/** @public */\nexport function createExtension<\n UOutput extends AnyExtensionDataRef,\n TInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n const TKind extends string | undefined = undefined,\n const TNamespace extends string | undefined = undefined,\n const TName extends string | undefined = undefined,\n>(\n options: CreateExtensionOptions<\n TKind,\n undefined,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput\n >,\n): ExtensionDefinition<{\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n namespace: string | undefined extends TNamespace ? undefined : TNamespace;\n name: string | undefined extends TName ? undefined : TName;\n}>;\n/**\n * @public\n * @deprecated namespace is no longer required, you can safely remove this option and it will default to the `pluginId`. It will be removed in a future release.\n */\nexport function createExtension<\n UOutput extends AnyExtensionDataRef,\n TInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n const TKind extends string | undefined = undefined,\n const TNamespace extends string | undefined = undefined,\n const TName extends string | undefined = undefined,\n>(\n options: CreateExtensionOptions<\n TKind,\n TNamespace,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput\n >,\n): ExtensionDefinition<{\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n namespace: string | undefined extends TNamespace ? undefined : TNamespace;\n name: string | undefined extends TName ? undefined : TName;\n}>;\nexport function createExtension<\n UOutput extends AnyExtensionDataRef,\n TInputs extends {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n },\n TConfigSchema extends { [key: string]: (zImpl: typeof z) => z.ZodType },\n UFactoryOutput extends ExtensionDataValue<any, any>,\n const TKind extends string | undefined = undefined,\n const TNamespace extends string | undefined = undefined,\n const TName extends string | undefined = undefined,\n>(\n options: CreateExtensionOptions<\n TKind,\n TNamespace,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput\n >,\n): ExtensionDefinition<{\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n namespace: string | undefined extends TNamespace ? undefined : TNamespace;\n name: string | undefined extends TName ? undefined : TName;\n}> {\n type T = {\n config: string extends keyof TConfigSchema\n ? {}\n : {\n [key in keyof TConfigSchema]: z.infer<ReturnType<TConfigSchema[key]>>;\n };\n configInput: string extends keyof TConfigSchema\n ? {}\n : z.input<\n z.ZodObject<{\n [key in keyof TConfigSchema]: ReturnType<TConfigSchema[key]>;\n }>\n >;\n output: UOutput;\n inputs: TInputs;\n kind: string | undefined extends TKind ? undefined : TKind;\n namespace: string | undefined extends TNamespace ? undefined : TNamespace;\n name: string | undefined extends TName ? undefined : TName;\n };\n\n const schemaDeclaration = options.config?.schema;\n const configSchema =\n schemaDeclaration &&\n createSchemaFromZod(innerZ =>\n innerZ.object(\n Object.fromEntries(\n Object.entries(schemaDeclaration).map(([k, v]) => [k, v(innerZ)]),\n ),\n ),\n );\n\n return {\n $$type: '@backstage/ExtensionDefinition',\n version: 'v2',\n T: undefined as unknown as T,\n kind: options.kind,\n namespace: options.namespace,\n name: options.name,\n attachTo: options.attachTo,\n disabled: options.disabled ?? false,\n inputs: options.inputs ?? {},\n output: options.output,\n configSchema,\n factory: options.factory,\n toString() {\n const parts: string[] = [];\n if (options.kind) {\n parts.push(`kind=${options.kind}`);\n }\n if (options.namespace) {\n parts.push(`namespace=${options.namespace}`);\n }\n if (options.name) {\n parts.push(`name=${options.name}`);\n }\n parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`);\n return `ExtensionDefinition{${parts.join(',')}}`;\n },\n override(overrideOptions) {\n if (!Array.isArray(options.output)) {\n throw new Error(\n 'Cannot override an extension that is not declared using the new format with outputs as an array',\n );\n }\n const newOptions = options as CreateExtensionOptions<\n TKind,\n TNamespace,\n TName,\n UOutput,\n TInputs,\n TConfigSchema,\n UFactoryOutput\n >;\n\n return createExtension({\n kind: newOptions.kind,\n namespace: newOptions.namespace,\n name: newOptions.name,\n attachTo: overrideOptions.attachTo ?? newOptions.attachTo,\n disabled: overrideOptions.disabled ?? newOptions.disabled,\n inputs: { ...overrideOptions.inputs, ...newOptions.inputs },\n output: (overrideOptions.output ??\n newOptions.output) as AnyExtensionDataRef[],\n config:\n newOptions.config || overrideOptions.config\n ? {\n schema: {\n ...newOptions.config?.schema,\n ...overrideOptions.config?.schema,\n },\n }\n : undefined,\n factory: ({ node, apis, config, inputs }) => {\n if (!overrideOptions.factory) {\n return newOptions.factory({\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n });\n }\n const parentResult = overrideOptions.factory(\n (innerContext): ExtensionDataContainer<UOutput> => {\n return createExtensionDataContainer<UOutput>(\n newOptions.factory({\n node,\n apis,\n config: (innerContext?.config ?? config) as any,\n inputs: resolveInputOverrides(\n newOptions.inputs,\n inputs,\n innerContext?.inputs,\n ) as any,\n }) as Iterable<any>,\n newOptions.output,\n );\n },\n {\n node,\n apis,\n config: config as any,\n inputs: inputs as any,\n },\n );\n\n const deduplicatedResult = new Map<\n string,\n ExtensionDataValue<any, any>\n >();\n for (const item of parentResult) {\n deduplicatedResult.set(item.id, item);\n }\n\n return deduplicatedResult.values();\n },\n }) as ExtensionDefinition<any>;\n },\n } as InternalExtensionDefinition<T>;\n}\n"],"names":[],"mappings":";;;AAySO,SAAS,8BAEd,SAAmE,EAAA;AACnE,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,gCAAkC,EAAA;AACxD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,iDAAA,EAAoD,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,KACrE,CAAA;AAAA,GACF;AACA,EAAA,MAAM,UAAU,QAAS,CAAA,OAAA,CAAA;AACzB,EAAI,IAAA,OAAA,KAAY,IAAQ,IAAA,OAAA,KAAY,IAAM,EAAA;AACxC,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,uDAAuD,OAAO,CAAA,CAAA,CAAA;AAAA,KAChE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"createExtensionOverrides.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createExtensionOverrides.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 { ExtensionDefinition } from './createExtension';\nimport {\n Extension,\n resolveExtensionDefinition,\n} from './resolveExtensionDefinition';\nimport { ExtensionOverrides, FeatureFlagConfig } from './types';\n\n/** @public */\nexport interface ExtensionOverridesOptions {\n extensions: ExtensionDefinition[];\n featureFlags?: FeatureFlagConfig[];\n}\n\n/** @internal */\nexport interface InternalExtensionOverrides extends ExtensionOverrides {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n}\n\n/** @public */\nexport function createExtensionOverrides(\n options: ExtensionOverridesOptions,\n): ExtensionOverrides {\n const extensions = options.extensions.map(def =>\n resolveExtensionDefinition(def),\n );\n const featureFlags = options.featureFlags ?? [];\n return {\n $$type: '@backstage/ExtensionOverrides',\n version: 'v1',\n extensions,\n featureFlags,\n toString() {\n const ex = extensions.map(String).join(',');\n const ff = featureFlags.map(f => f.name).join(',');\n return `ExtensionOverrides{extensions=[${ex}],featureFlags=[${ff}]}`;\n },\n } as InternalExtensionOverrides;\n}\n\n/** @internal */\nexport function toInternalExtensionOverrides(\n overrides: ExtensionOverrides,\n): InternalExtensionOverrides {\n const internal = overrides as InternalExtensionOverrides;\n if (internal.$$type !== '@backstage/ExtensionOverrides') {\n throw new Error(\n `Invalid extension overrides instance, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid extension overrides instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n"],"names":[],"mappings":";;;AA0DO,SAAS,6BACd,SAC4B,EAAA;AAC5B,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,+BAAiC,EAAA;AACvD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,gDAAA,EAAmD,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,KACpE,CAAA;AAAA,GACF;AACA,EAAI,IAAA,QAAA,CAAS,YAAY,IAAM,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,mDAAA,EAAsD,SAAS,OAAO,CAAA,CAAA,CAAA;AAAA,KACxE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"createExtensionOverrides.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createExtensionOverrides.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 { ExtensionDefinition } from './createExtension';\nimport {\n Extension,\n resolveExtensionDefinition,\n} from './resolveExtensionDefinition';\nimport { ExtensionOverrides, FeatureFlagConfig } from './types';\n\n/**\n * @deprecated Use {@link createFrontendModule} instead.\n * @public\n */\nexport interface ExtensionOverridesOptions {\n extensions: ExtensionDefinition[];\n featureFlags?: FeatureFlagConfig[];\n}\n\n/** @internal */\nexport interface InternalExtensionOverrides extends ExtensionOverrides {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n}\n\n/**\n * @deprecated Use {@link createFrontendModule} instead.\n * @public\n */\nexport function createExtensionOverrides(\n options: ExtensionOverridesOptions,\n): ExtensionOverrides {\n const extensions = options.extensions.map(def =>\n resolveExtensionDefinition(def),\n );\n const featureFlags = options.featureFlags ?? [];\n return {\n $$type: '@backstage/ExtensionOverrides',\n version: 'v1',\n extensions,\n featureFlags,\n toString() {\n const ex = extensions.map(String).join(',');\n const ff = featureFlags.map(f => f.name).join(',');\n return `ExtensionOverrides{extensions=[${ex}],featureFlags=[${ff}]}`;\n },\n } as InternalExtensionOverrides;\n}\n\n/** @internal */\nexport function toInternalExtensionOverrides(\n overrides: ExtensionOverrides,\n): InternalExtensionOverrides {\n const internal = overrides as InternalExtensionOverrides;\n if (internal.$$type !== '@backstage/ExtensionOverrides') {\n throw new Error(\n `Invalid extension overrides instance, bad type '${internal.$$type}'`,\n );\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid extension overrides instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n"],"names":[],"mappings":";;;AAgEO,SAAS,6BACd,SAC4B,EAAA;AAC5B,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,+BAAiC,EAAA;AACvD,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,gDAAA,EAAmD,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,KACpE,CAAA;AAAA,GACF;AACA,EAAI,IAAA,QAAA,CAAS,YAAY,IAAM,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,mDAAA,EAAsD,SAAS,OAAO,CAAA,CAAA,CAAA;AAAA,KACxE,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
@@ -0,0 +1,25 @@
1
+ import 'zod';
2
+ import 'zod-to-json-schema';
3
+
4
+ function isInternalFrontendModule(opaque) {
5
+ if (opaque.$$type === "@backstage/FrontendModule") {
6
+ toInternalFrontendModule(opaque);
7
+ return true;
8
+ }
9
+ return false;
10
+ }
11
+ function toInternalFrontendModule(plugin) {
12
+ const internal = plugin;
13
+ if (internal.$$type !== "@backstage/FrontendModule") {
14
+ throw new Error(`Invalid plugin instance, bad type '${internal.$$type}'`);
15
+ }
16
+ if (internal.version !== "v1") {
17
+ throw new Error(
18
+ `Invalid plugin instance, bad version '${internal.version}'`
19
+ );
20
+ }
21
+ return internal;
22
+ }
23
+
24
+ export { isInternalFrontendModule, toInternalFrontendModule };
25
+ //# sourceMappingURL=createFrontendModule.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createFrontendModule.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createFrontendModule.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 {\n ExtensionDefinition,\n InternalExtensionDefinition,\n toInternalExtensionDefinition,\n} from './createExtension';\nimport {\n Extension,\n resolveExtensionDefinition,\n} from './resolveExtensionDefinition';\nimport { FeatureFlagConfig } from './types';\n\n/** @public */\nexport interface CreateFrontendModuleOptions<\n TPluginId extends string,\n TExtensions extends readonly ExtensionDefinition[],\n> {\n pluginId: TPluginId;\n extensions?: TExtensions;\n featureFlags?: FeatureFlagConfig[];\n}\n\n/** @public */\nexport interface FrontendModule {\n readonly $$type: '@backstage/FrontendModule';\n readonly pluginId: string;\n}\n\n/** @internal */\nexport interface InternalFrontendModule extends FrontendModule {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n}\n\n/** @public */\nexport function createFrontendModule<\n TId extends string,\n TExtensions extends readonly ExtensionDefinition[] = [],\n>(options: CreateFrontendModuleOptions<TId, TExtensions>): FrontendModule {\n const { pluginId } = options;\n\n const extensions = new Array<Extension<any>>();\n const extensionDefinitionsById = new Map<\n string,\n InternalExtensionDefinition\n >();\n\n for (const def of options.extensions ?? []) {\n const internal = toInternalExtensionDefinition(def);\n const ext = resolveExtensionDefinition(def, { namespace: pluginId });\n extensions.push(ext);\n extensionDefinitionsById.set(ext.id, {\n ...internal,\n namespace: pluginId,\n });\n }\n\n if (extensions.length !== extensionDefinitionsById.size) {\n const extensionIds = extensions.map(e => e.id);\n const duplicates = Array.from(\n new Set(\n extensionIds.filter((id, index) => extensionIds.indexOf(id) !== index),\n ),\n );\n // TODO(Rugvip): This could provide some more information about the kind + name of the extensions\n throw new Error(\n `Plugin '${pluginId}' provided duplicate extensions: ${duplicates.join(\n ', ',\n )}`,\n );\n }\n\n return {\n $$type: '@backstage/FrontendModule',\n version: 'v1',\n pluginId,\n featureFlags: options.featureFlags ?? [],\n extensions,\n toString() {\n return `Module{pluginId=${pluginId}}`;\n },\n } as InternalFrontendModule;\n}\n\n/** @internal */\nexport function isInternalFrontendModule(opaque: {\n $$type: string;\n}): opaque is InternalFrontendModule {\n if (opaque.$$type === '@backstage/FrontendModule') {\n // Make sure we throw if invalid\n toInternalFrontendModule(opaque as FrontendModule);\n return true;\n }\n return false;\n}\n\n/** @internal */\nexport function toInternalFrontendModule(\n plugin: FrontendModule,\n): InternalFrontendModule {\n const internal = plugin as InternalFrontendModule;\n if (internal.$$type !== '@backstage/FrontendModule') {\n throw new Error(`Invalid plugin instance, bad type '${internal.$$type}'`);\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid plugin instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n"],"names":[],"mappings":";;;AAqGO,SAAS,yBAAyB,MAEJ,EAAA;AACnC,EAAI,IAAA,MAAA,CAAO,WAAW,2BAA6B,EAAA;AAEjD,IAAA,wBAAA,CAAyB,MAAwB,CAAA,CAAA;AACjD,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,KAAA,CAAA;AACT,CAAA;AAGO,SAAS,yBACd,MACwB,EAAA;AACxB,EAAA,MAAM,QAAW,GAAA,MAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,2BAA6B,EAAA;AACnD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAsC,mCAAA,EAAA,QAAA,CAAS,MAAM,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,GAC1E;AACA,EAAI,IAAA,QAAA,CAAS,YAAY,IAAM,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,sCAAA,EAAyC,SAAS,OAAO,CAAA,CAAA,CAAA;AAAA,KAC3D,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
@@ -1,9 +1,16 @@
1
1
  import 'zod';
2
2
  import 'zod-to-json-schema';
3
3
 
4
- function toInternalBackstagePlugin(plugin) {
4
+ function isInternalFrontendPlugin(opaque) {
5
+ if (opaque.$$type === "@backstage/FrontendPlugin" || opaque.$$type === "@backstage/BackstagePlugin") {
6
+ toInternalFrontendPlugin(opaque);
7
+ return true;
8
+ }
9
+ return false;
10
+ }
11
+ function toInternalFrontendPlugin(plugin) {
5
12
  const internal = plugin;
6
- if (internal.$$type !== "@backstage/BackstagePlugin") {
13
+ if (internal.$$type !== "@backstage/FrontendPlugin" && internal.$$type !== "@backstage/BackstagePlugin") {
7
14
  throw new Error(`Invalid plugin instance, bad type '${internal.$$type}'`);
8
15
  }
9
16
  if (internal.version !== "v1") {
@@ -14,5 +21,5 @@ function toInternalBackstagePlugin(plugin) {
14
21
  return internal;
15
22
  }
16
23
 
17
- export { toInternalBackstagePlugin };
24
+ export { isInternalFrontendPlugin, toInternalFrontendPlugin };
18
25
  //# sourceMappingURL=createFrontendPlugin.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createFrontendPlugin.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createFrontendPlugin.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 {\n ExtensionDefinition,\n InternalExtensionDefinition,\n toInternalExtensionDefinition,\n} from './createExtension';\nimport {\n Extension,\n ResolveExtensionId,\n resolveExtensionDefinition,\n} from './resolveExtensionDefinition';\nimport {\n AnyExternalRoutes,\n AnyRoutes,\n BackstagePlugin,\n FeatureFlagConfig,\n} from './types';\n\n/** @public */\nexport interface PluginOptions<\n TId extends string,\n TRoutes extends AnyRoutes,\n TExternalRoutes extends AnyExternalRoutes,\n TExtensions extends readonly ExtensionDefinition[],\n> {\n id: TId;\n routes?: TRoutes;\n externalRoutes?: TExternalRoutes;\n extensions?: TExtensions;\n featureFlags?: FeatureFlagConfig[];\n}\n\n/** @public */\nexport interface InternalBackstagePlugin<\n TRoutes extends AnyRoutes = AnyRoutes,\n TExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,\n> extends BackstagePlugin<TRoutes, TExternalRoutes> {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n}\n\n/** @public */\nexport function createFrontendPlugin<\n TId extends string,\n TRoutes extends AnyRoutes = {},\n TExternalRoutes extends AnyExternalRoutes = {},\n TExtensions extends readonly ExtensionDefinition[] = [],\n>(\n options: PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>,\n): BackstagePlugin<\n TRoutes,\n TExternalRoutes,\n {\n [KExtension in TExtensions[number] as ResolveExtensionId<\n KExtension,\n TId\n >]: KExtension;\n }\n> {\n const extensions = new Array<Extension<any>>();\n const extensionDefinitionsById = new Map<\n string,\n InternalExtensionDefinition\n >();\n\n for (const def of options.extensions ?? []) {\n const internal = toInternalExtensionDefinition(def);\n const ext = resolveExtensionDefinition(def, { namespace: options.id });\n extensions.push(ext);\n extensionDefinitionsById.set(ext.id, {\n ...internal,\n namespace: options.id,\n });\n }\n\n if (extensions.length !== extensionDefinitionsById.size) {\n const extensionIds = extensions.map(e => e.id);\n const duplicates = Array.from(\n new Set(\n extensionIds.filter((id, index) => extensionIds.indexOf(id) !== index),\n ),\n );\n // TODO(Rugvip): This could provide some more information about the kind + name of the extensions\n throw new Error(\n `Plugin '${options.id}' provided duplicate extensions: ${duplicates.join(\n ', ',\n )}`,\n );\n }\n\n return {\n $$type: '@backstage/BackstagePlugin',\n version: 'v1',\n id: options.id,\n routes: options.routes ?? ({} as TRoutes),\n externalRoutes: options.externalRoutes ?? ({} as TExternalRoutes),\n featureFlags: options.featureFlags ?? [],\n extensions,\n getExtension(id) {\n return extensionDefinitionsById.get(id);\n },\n toString() {\n return `Plugin{id=${options.id}}`;\n },\n withOverrides(overrides) {\n const overriddenExtensionIds = new Set(\n overrides.extensions.map(\n e => resolveExtensionDefinition(e, { namespace: options.id }).id,\n ),\n );\n const nonOverriddenExtensions = (options.extensions ?? []).filter(\n e =>\n !overriddenExtensionIds.has(\n resolveExtensionDefinition(e, { namespace: options.id }).id,\n ),\n );\n return createFrontendPlugin({\n ...options,\n extensions: [...nonOverriddenExtensions, ...overrides.extensions],\n });\n },\n } as InternalBackstagePlugin<TRoutes, TExternalRoutes>;\n}\n\n/** @internal */\nexport function toInternalBackstagePlugin(\n plugin: BackstagePlugin,\n): InternalBackstagePlugin {\n const internal = plugin as InternalBackstagePlugin;\n if (internal.$$type !== '@backstage/BackstagePlugin') {\n throw new Error(`Invalid plugin instance, bad type '${internal.$$type}'`);\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid plugin instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\n/**\n * @public\n * @deprecated Use {@link createFrontendPlugin} instead.\n */\nexport const createPlugin = createFrontendPlugin;\n"],"names":[],"mappings":";;;AA6IO,SAAS,0BACd,MACyB,EAAA;AACzB,EAAA,MAAM,QAAW,GAAA,MAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,4BAA8B,EAAA;AACpD,IAAA,MAAM,IAAI,KAAA,CAAM,CAAsC,mCAAA,EAAA,QAAA,CAAS,MAAM,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,GAC1E;AACA,EAAI,IAAA,QAAA,CAAS,YAAY,IAAM,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,sCAAA,EAAyC,SAAS,OAAO,CAAA,CAAA,CAAA;AAAA,KAC3D,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
1
+ {"version":3,"file":"createFrontendPlugin.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/createFrontendPlugin.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 {\n ExtensionDefinition,\n InternalExtensionDefinition,\n toInternalExtensionDefinition,\n} from './createExtension';\nimport {\n Extension,\n ResolveExtensionId,\n resolveExtensionDefinition,\n} from './resolveExtensionDefinition';\nimport { AnyExternalRoutes, AnyRoutes, FeatureFlagConfig } from './types';\n\n/** @public */\nexport interface FrontendPlugin<\n TRoutes extends AnyRoutes = AnyRoutes,\n TExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,\n TExtensionMap extends { [id in string]: ExtensionDefinition } = {},\n> {\n readonly $$type: '@backstage/FrontendPlugin';\n readonly id: string;\n readonly routes: TRoutes;\n readonly externalRoutes: TExternalRoutes;\n getExtension<TId extends keyof TExtensionMap>(id: TId): TExtensionMap[TId];\n withOverrides(options: {\n extensions: Array<ExtensionDefinition>;\n }): FrontendPlugin<TRoutes, TExternalRoutes, TExtensionMap>;\n}\n\n/**\n * @public\n * @deprecated Use {@link FrontendPlugin} instead.\n */\nexport type BackstagePlugin<\n TRoutes extends AnyRoutes = AnyRoutes,\n TExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,\n TExtensionMap extends { [id in string]: ExtensionDefinition } = {},\n> = FrontendPlugin<TRoutes, TExternalRoutes, TExtensionMap>;\n/** @public */\nexport interface PluginOptions<\n TId extends string,\n TRoutes extends AnyRoutes,\n TExternalRoutes extends AnyExternalRoutes,\n TExtensions extends readonly ExtensionDefinition[],\n> {\n id: TId;\n routes?: TRoutes;\n externalRoutes?: TExternalRoutes;\n extensions?: TExtensions;\n featureFlags?: FeatureFlagConfig[];\n}\n\n/** @public */\nexport interface InternalFrontendPlugin<\n TRoutes extends AnyRoutes = AnyRoutes,\n TExternalRoutes extends AnyExternalRoutes = AnyExternalRoutes,\n> extends FrontendPlugin<TRoutes, TExternalRoutes> {\n readonly version: 'v1';\n readonly extensions: Extension<unknown>[];\n readonly featureFlags: FeatureFlagConfig[];\n}\n\n/** @public */\nexport function createFrontendPlugin<\n TId extends string,\n TRoutes extends AnyRoutes = {},\n TExternalRoutes extends AnyExternalRoutes = {},\n TExtensions extends readonly ExtensionDefinition[] = [],\n>(\n options: PluginOptions<TId, TRoutes, TExternalRoutes, TExtensions>,\n): FrontendPlugin<\n TRoutes,\n TExternalRoutes,\n {\n [KExtension in TExtensions[number] as ResolveExtensionId<\n KExtension,\n TId\n >]: KExtension;\n }\n> {\n const extensions = new Array<Extension<any>>();\n const extensionDefinitionsById = new Map<\n string,\n InternalExtensionDefinition\n >();\n\n for (const def of options.extensions ?? []) {\n const internal = toInternalExtensionDefinition(def);\n const ext = resolveExtensionDefinition(def, { namespace: options.id });\n extensions.push(ext);\n extensionDefinitionsById.set(ext.id, {\n ...internal,\n namespace: options.id,\n });\n }\n\n if (extensions.length !== extensionDefinitionsById.size) {\n const extensionIds = extensions.map(e => e.id);\n const duplicates = Array.from(\n new Set(\n extensionIds.filter((id, index) => extensionIds.indexOf(id) !== index),\n ),\n );\n // TODO(Rugvip): This could provide some more information about the kind + name of the extensions\n throw new Error(\n `Plugin '${options.id}' provided duplicate extensions: ${duplicates.join(\n ', ',\n )}`,\n );\n }\n\n return {\n $$type: '@backstage/FrontendPlugin',\n version: 'v1',\n id: options.id,\n routes: options.routes ?? ({} as TRoutes),\n externalRoutes: options.externalRoutes ?? ({} as TExternalRoutes),\n featureFlags: options.featureFlags ?? [],\n extensions,\n getExtension(id) {\n return extensionDefinitionsById.get(id);\n },\n toString() {\n return `Plugin{id=${options.id}}`;\n },\n withOverrides(overrides) {\n const overriddenExtensionIds = new Set(\n overrides.extensions.map(\n e => resolveExtensionDefinition(e, { namespace: options.id }).id,\n ),\n );\n const nonOverriddenExtensions = (options.extensions ?? []).filter(\n e =>\n !overriddenExtensionIds.has(\n resolveExtensionDefinition(e, { namespace: options.id }).id,\n ),\n );\n return createFrontendPlugin({\n ...options,\n extensions: [...nonOverriddenExtensions, ...overrides.extensions],\n });\n },\n } as InternalFrontendPlugin<TRoutes, TExternalRoutes>;\n}\n\n/** @internal */\nexport function isInternalFrontendPlugin(opaque: {\n $$type: string;\n}): opaque is InternalFrontendPlugin {\n if (\n opaque.$$type === '@backstage/FrontendPlugin' ||\n opaque.$$type === '@backstage/BackstagePlugin'\n ) {\n // Make sure we throw if invalid\n toInternalFrontendPlugin(opaque as FrontendPlugin);\n return true;\n }\n return false;\n}\n\n/** @internal */\nexport function toInternalFrontendPlugin(\n plugin: FrontendPlugin,\n): InternalFrontendPlugin {\n const internal = plugin as InternalFrontendPlugin;\n if (\n internal.$$type !== '@backstage/FrontendPlugin' &&\n internal.$$type !== '@backstage/BackstagePlugin'\n ) {\n throw new Error(`Invalid plugin instance, bad type '${internal.$$type}'`);\n }\n if (internal.version !== 'v1') {\n throw new Error(\n `Invalid plugin instance, bad version '${internal.version}'`,\n );\n }\n return internal;\n}\n\n/**\n * @public\n * @deprecated Use {@link createFrontendPlugin} instead.\n */\nexport const createPlugin = createFrontendPlugin;\n"],"names":[],"mappings":";;;AAiKO,SAAS,yBAAyB,MAEJ,EAAA;AACnC,EAAA,IACE,MAAO,CAAA,MAAA,KAAW,2BAClB,IAAA,MAAA,CAAO,WAAW,4BAClB,EAAA;AAEA,IAAA,wBAAA,CAAyB,MAAwB,CAAA,CAAA;AACjD,IAAO,OAAA,IAAA,CAAA;AAAA,GACT;AACA,EAAO,OAAA,KAAA,CAAA;AACT,CAAA;AAGO,SAAS,yBACd,MACwB,EAAA;AACxB,EAAA,MAAM,QAAW,GAAA,MAAA,CAAA;AACjB,EAAA,IACE,QAAS,CAAA,MAAA,KAAW,2BACpB,IAAA,QAAA,CAAS,WAAW,4BACpB,EAAA;AACA,IAAA,MAAM,IAAI,KAAA,CAAM,CAAsC,mCAAA,EAAA,QAAA,CAAS,MAAM,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,GAC1E;AACA,EAAI,IAAA,QAAA,CAAS,YAAY,IAAM,EAAA;AAC7B,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,sCAAA,EAAyC,SAAS,OAAO,CAAA,CAAA,CAAA;AAAA,KAC3D,CAAA;AAAA,GACF;AACA,EAAO,OAAA,QAAA,CAAA;AACT;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveExtensionDefinition.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition.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 { ApiHolder, AppNode } from '../apis';\nimport {\n ExtensionDefinition,\n ExtensionDefinitionParameters,\n ResolvedExtensionInputs,\n toInternalExtensionDefinition,\n} from './createExtension';\nimport { PortableSchema } from '../schema';\nimport { ExtensionInput } from './createExtensionInput';\nimport {\n AnyExtensionDataRef,\n ExtensionDataValue,\n} from './createExtensionDataRef';\n\n/** @public */\nexport interface Extension<TConfig, TConfigInput = TConfig> {\n $$type: '@backstage/Extension';\n readonly id: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<TConfig, TConfigInput>;\n}\n\n/** @internal */\nexport type InternalExtension<TConfig, TConfigInput> = Extension<\n TConfig,\n TConfigInput\n> &\n (\n | {\n readonly version: 'v1';\n readonly inputs: {\n [inputName in string]: {\n $$type: '@backstage/ExtensionInput';\n extensionData: {\n [name in string]: AnyExtensionDataRef;\n };\n config: { optional: boolean; singleton: boolean };\n };\n };\n readonly output: {\n [name in string]: AnyExtensionDataRef;\n };\n factory(context: {\n apis: ApiHolder;\n node: AppNode;\n config: TConfig;\n inputs: {\n [inputName in string]: unknown;\n };\n }): {\n [inputName in string]: unknown;\n };\n }\n | {\n readonly version: 'v2';\n readonly inputs: {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n };\n readonly output: Array<AnyExtensionDataRef>;\n factory(options: {\n apis: ApiHolder;\n node: AppNode;\n config: TConfig;\n inputs: ResolvedExtensionInputs<{\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n }>;\n }): Iterable<ExtensionDataValue<any, any>>;\n }\n );\n\n/** @internal */\nexport function toInternalExtension<TConfig, TConfigInput>(\n overrides: Extension<TConfig, TConfigInput>,\n): InternalExtension<TConfig, TConfigInput> {\n const internal = overrides as InternalExtension<TConfig, TConfigInput>;\n if (internal.$$type !== '@backstage/Extension') {\n throw new Error(\n `Invalid extension instance, bad type '${internal.$$type}'`,\n );\n }\n const version = internal.version;\n if (version !== 'v1' && version !== 'v2') {\n throw new Error(`Invalid extension instance, bad version '${version}'`);\n }\n return internal;\n}\n\n/** @ignore */\nexport type ResolveExtensionId<\n TExtension extends ExtensionDefinition,\n TDefaultNamespace extends string | undefined,\n> = TExtension extends ExtensionDefinition<{\n kind: infer IKind extends string | undefined;\n namespace: infer INamespace extends string | undefined;\n name: infer IName extends string | undefined;\n}>\n ? [string | undefined] extends [IKind | INamespace | IName]\n ? never\n : (\n (\n undefined extends TDefaultNamespace ? INamespace : TDefaultNamespace\n ) extends infer ISelectedNamespace extends string\n ? undefined extends IName\n ? ISelectedNamespace\n : `${ISelectedNamespace}/${IName}`\n : IName\n ) extends infer INamePart extends string\n ? IKind extends string\n ? `${IKind}:${INamePart}`\n : INamePart\n : never\n : never;\n\n/** @internal */\nexport function resolveExtensionDefinition<\n T extends ExtensionDefinitionParameters,\n>(\n definition: ExtensionDefinition<T>,\n context?: { namespace?: string },\n): Extension<T['config'], T['configInput']> {\n const internalDefinition = toInternalExtensionDefinition(definition);\n const {\n name,\n kind,\n namespace: _skip1,\n override: _skip2,\n ...rest\n } = internalDefinition;\n const namespace = internalDefinition.namespace ?? context?.namespace;\n\n const namePart =\n name && namespace ? `${namespace}/${name}` : namespace || name;\n if (!namePart) {\n throw new Error(\n `Extension must declare an explicit namespace or name as it could not be resolved from context, kind=${kind} namespace=${namespace} name=${name}`,\n );\n }\n\n const id = kind ? `${kind}:${namePart}` : namePart;\n\n return {\n ...rest,\n $$type: '@backstage/Extension',\n version: internalDefinition.version,\n id,\n toString() {\n return `Extension{id=${id}}`;\n },\n } as InternalExtension<T['config'], T['configInput']> & Object;\n}\n"],"names":[],"mappings":";;AA8FO,SAAS,oBACd,SAC0C,EAAA;AAC1C,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,sBAAwB,EAAA;AAC9C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,sCAAA,EAAyC,SAAS,MAAM,CAAA,CAAA,CAAA;AAAA,KAC1D,CAAA;AAAA,GACF;AACA,EAAA,MAAM,UAAU,QAAS,CAAA,OAAA,CAAA;AACzB,EAAI,IAAA,OAAA,KAAY,IAAQ,IAAA,OAAA,KAAY,IAAM,EAAA;AACxC,IAAA,MAAM,IAAI,KAAA,CAAM,CAA4C,yCAAA,EAAA,OAAO,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,GACxE;AACA,EAAO,OAAA,QAAA,CAAA;AACT,CAAA;AA6BgB,SAAA,0BAAA,CAGd,YACA,OAC0C,EAAA;AAC1C,EAAM,MAAA,kBAAA,GAAqB,8BAA8B,UAAU,CAAA,CAAA;AACnE,EAAM,MAAA;AAAA,IACJ,IAAA;AAAA,IACA,IAAA;AAAA,IACA,SAAW,EAAA,MAAA;AAAA,IACX,QAAU,EAAA,MAAA;AAAA,IACV,GAAG,IAAA;AAAA,GACD,GAAA,kBAAA,CAAA;AACJ,EAAM,MAAA,SAAA,GAAY,kBAAmB,CAAA,SAAA,IAAa,OAAS,EAAA,SAAA,CAAA;AAE3D,EAAM,MAAA,QAAA,GACJ,QAAQ,SAAY,GAAA,CAAA,EAAG,SAAS,CAAI,CAAA,EAAA,IAAI,KAAK,SAAa,IAAA,IAAA,CAAA;AAC5D,EAAA,IAAI,CAAC,QAAU,EAAA;AACb,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAuG,oGAAA,EAAA,IAAI,CAAc,WAAA,EAAA,SAAS,SAAS,IAAI,CAAA,CAAA;AAAA,KACjJ,CAAA;AAAA,GACF;AAEA,EAAA,MAAM,KAAK,IAAO,GAAA,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,QAAQ,CAAK,CAAA,GAAA,QAAA,CAAA;AAE1C,EAAO,OAAA;AAAA,IACL,GAAG,IAAA;AAAA,IACH,MAAQ,EAAA,sBAAA;AAAA,IACR,SAAS,kBAAmB,CAAA,OAAA;AAAA,IAC5B,EAAA;AAAA,IACA,QAAW,GAAA;AACT,MAAA,OAAO,gBAAgB,EAAE,CAAA,CAAA,CAAA,CAAA;AAAA,KAC3B;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"resolveExtensionDefinition.esm.js","sources":["../../../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition.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 { ApiHolder, AppNode } from '../apis';\nimport {\n ExtensionDefinition,\n ExtensionDefinitionParameters,\n ResolvedExtensionInputs,\n toInternalExtensionDefinition,\n} from './createExtension';\nimport { PortableSchema } from '../schema';\nimport { ExtensionInput } from './createExtensionInput';\nimport {\n AnyExtensionDataRef,\n ExtensionDataValue,\n} from './createExtensionDataRef';\n\n/** @public */\nexport interface Extension<TConfig, TConfigInput = TConfig> {\n $$type: '@backstage/Extension';\n readonly id: string;\n readonly attachTo: { id: string; input: string };\n readonly disabled: boolean;\n readonly configSchema?: PortableSchema<TConfig, TConfigInput>;\n}\n\n/** @internal */\nexport type InternalExtension<TConfig, TConfigInput> = Extension<\n TConfig,\n TConfigInput\n> &\n (\n | {\n readonly version: 'v1';\n readonly inputs: {\n [inputName in string]: {\n $$type: '@backstage/ExtensionInput';\n extensionData: {\n [name in string]: AnyExtensionDataRef;\n };\n config: { optional: boolean; singleton: boolean };\n };\n };\n readonly output: {\n [name in string]: AnyExtensionDataRef;\n };\n factory(context: {\n apis: ApiHolder;\n node: AppNode;\n config: TConfig;\n inputs: {\n [inputName in string]: unknown;\n };\n }): {\n [inputName in string]: unknown;\n };\n }\n | {\n readonly version: 'v2';\n readonly inputs: {\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n };\n readonly output: Array<AnyExtensionDataRef>;\n factory(options: {\n apis: ApiHolder;\n node: AppNode;\n config: TConfig;\n inputs: ResolvedExtensionInputs<{\n [inputName in string]: ExtensionInput<\n AnyExtensionDataRef,\n { optional: boolean; singleton: boolean }\n >;\n }>;\n }): Iterable<ExtensionDataValue<any, any>>;\n }\n );\n\n/** @internal */\nexport function toInternalExtension<TConfig, TConfigInput>(\n overrides: Extension<TConfig, TConfigInput>,\n): InternalExtension<TConfig, TConfigInput> {\n const internal = overrides as InternalExtension<TConfig, TConfigInput>;\n if (internal.$$type !== '@backstage/Extension') {\n throw new Error(\n `Invalid extension instance, bad type '${internal.$$type}'`,\n );\n }\n const version = internal.version;\n if (version !== 'v1' && version !== 'v2') {\n throw new Error(`Invalid extension instance, bad version '${version}'`);\n }\n return internal;\n}\n\n/** @ignore */\nexport type ResolveExtensionId<\n TExtension extends ExtensionDefinition,\n TDefaultNamespace extends string | undefined,\n> = TExtension extends ExtensionDefinition<{\n kind: infer IKind extends string | undefined;\n namespace: infer INamespace extends string | undefined;\n name: infer IName extends string | undefined;\n}>\n ? [string | undefined] extends [IKind | INamespace | IName]\n ? never\n : (\n (\n undefined extends TDefaultNamespace ? INamespace : TDefaultNamespace\n ) extends infer ISelectedNamespace extends string\n ? undefined extends IName\n ? ISelectedNamespace\n : `${ISelectedNamespace}/${IName}`\n : IName\n ) extends infer INamePart extends string\n ? IKind extends string\n ? `${IKind}:${INamePart}`\n : INamePart\n : never\n : never;\n\n/** @internal */\nexport function resolveExtensionDefinition<\n T extends ExtensionDefinitionParameters,\n>(\n definition: ExtensionDefinition<T>,\n context?: { namespace?: string },\n): Extension<T['config'], T['configInput']> {\n const internalDefinition = toInternalExtensionDefinition(definition);\n const {\n name,\n kind,\n namespace: _skip1,\n override: _skip2,\n ...rest\n } = internalDefinition;\n\n const namespace = internalDefinition.namespace ?? context?.namespace;\n\n const namePart =\n name && namespace ? `${namespace}/${name}` : namespace || name;\n if (!namePart) {\n throw new Error(\n `Extension must declare an explicit namespace or name as it could not be resolved from context, kind=${kind} namespace=${namespace} name=${name}`,\n );\n }\n\n const id = kind ? `${kind}:${namePart}` : namePart;\n\n return {\n ...rest,\n $$type: '@backstage/Extension',\n version: internalDefinition.version,\n id,\n toString() {\n return `Extension{id=${id}}`;\n },\n } as InternalExtension<T['config'], T['configInput']> & Object;\n}\n"],"names":[],"mappings":";;AA8FO,SAAS,oBACd,SAC0C,EAAA;AAC1C,EAAA,MAAM,QAAW,GAAA,SAAA,CAAA;AACjB,EAAI,IAAA,QAAA,CAAS,WAAW,sBAAwB,EAAA;AAC9C,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,CAAA,sCAAA,EAAy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,GAAA;AACT,MAAA,OAAO,gBAAgB,EAAE,CAAA,CAAA,CAAA,CAAA;AAAA,KAC3B;AAAA,GACF,CAAA;AACF;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { ReactNode, JSX } from 'react';
2
- import { ExternalRouteRef, RouteRef, SubRouteRef, FrontendFeature } from '@backstage/frontend-plugin-api';
1
+ import { JSX } from 'react';
3
2
  import { ConfigApi } from '@backstage/core-plugin-api';
3
+ import { createApp as createApp$1, CreateAppFeatureLoader as CreateAppFeatureLoader$1 } from '@backstage/frontend-defaults';
4
+ import { ExternalRouteRef, RouteRef, SubRouteRef, FrontendPlugin, FrontendModule } from '@backstage/frontend-plugin-api';
4
5
 
5
6
  /**
6
7
  * Extracts a union of the keys in a map whose value extends the given type
@@ -40,47 +41,27 @@ type CreateAppRouteBinder = <TExternalRoutes extends {
40
41
  [name: string]: ExternalRouteRef;
41
42
  }>(externalRoutes: TExternalRoutes, targetRoutes: PartialKeys<TargetRouteMap<TExternalRoutes>, KeysWithType<TExternalRoutes, ExternalRouteRef<any>>>) => void;
42
43
 
44
+ /** @public */
45
+ type FrontendFeature = FrontendPlugin | FrontendModule | {
46
+ $$type: '@backstage/ExtensionOverrides';
47
+ } | {
48
+ $$type: '@backstage/BackstagePlugin';
49
+ };
50
+
43
51
  /**
44
- * A source of dynamically loaded frontend features.
45
- *
46
52
  * @public
53
+ * @deprecated Import from `@backstage/frontend-defaults` instead.
47
54
  */
48
- interface CreateAppFeatureLoader {
49
- /**
50
- * Returns name of this loader. suitable for showing to users.
51
- */
52
- getLoaderName(): string;
53
- /**
54
- * Loads a number of features dynamically.
55
- */
56
- load(options: {
57
- config: ConfigApi;
58
- }): Promise<{
59
- features: FrontendFeature[];
60
- }>;
61
- }
62
- /** @public */
63
- declare function createApp(options?: {
64
- features?: (FrontendFeature | CreateAppFeatureLoader)[];
65
- configLoader?: () => Promise<{
66
- config: ConfigApi;
67
- }>;
68
- bindRoutes?(context: {
69
- bind: CreateAppRouteBinder;
70
- }): void;
71
- /**
72
- * The component to render while loading the app (waiting for config, features, etc)
73
- *
74
- * Is the text "Loading..." by default.
75
- * If set to "null" then no loading fallback component is rendered. *
76
- */
77
- loadingComponent?: ReactNode;
78
- }): {
79
- createRoot(): JSX.Element;
80
- };
55
+ declare const createApp: typeof createApp$1;
56
+ /**
57
+ * @public
58
+ * @deprecated Import from `@backstage/frontend-defaults` instead.
59
+ */
60
+ type CreateAppFeatureLoader = CreateAppFeatureLoader$1;
81
61
  /**
82
- * Synchronous version of {@link createApp}, expecting all features and
83
- * config to have been loaded already.
62
+ * Creates an empty app without any default features. This is a low-level API is
63
+ * intended for use in tests or specialized setups. Typically wou want to use
64
+ * `createApp` from `@backstage/frontend-defaults` instead.
84
65
  *
85
66
  * @public
86
67
  */
@@ -94,4 +75,4 @@ declare function createSpecializedApp(options?: {
94
75
  createRoot(): JSX.Element;
95
76
  };
96
77
 
97
- export { type CreateAppFeatureLoader, type CreateAppRouteBinder, createApp, createSpecializedApp };
78
+ export { type CreateAppFeatureLoader, type CreateAppRouteBinder, type FrontendFeature, createApp, createSpecializedApp };
package/dist/index.esm.js CHANGED
@@ -1,2 +1,2 @@
1
- export { createApp, createSpecializedApp } from './wiring/createApp.esm.js';
1
+ export { createApp, createSpecializedApp } from './wiring/createSpecializedApp.esm.js';
2
2
  //# sourceMappingURL=index.esm.js.map
@@ -1,12 +1,13 @@
1
1
  import { isRouteRef, toInternalRouteRef } from '../frontend-plugin-api/src/routing/RouteRef.esm.js';
2
2
  import { toInternalExternalRouteRef } from '../frontend-plugin-api/src/routing/ExternalRouteRef.esm.js';
3
3
  import { toInternalSubRouteRef } from '../frontend-plugin-api/src/routing/SubRouteRef.esm.js';
4
+ import { isInternalFrontendPlugin } from '../frontend-plugin-api/src/wiring/createFrontendPlugin.esm.js';
4
5
 
5
6
  function collectRouteIds(features) {
6
7
  const routesById = /* @__PURE__ */ new Map();
7
8
  const externalRoutesById = /* @__PURE__ */ new Map();
8
9
  for (const feature of features) {
9
- if (feature.$$type !== "@backstage/BackstagePlugin") {
10
+ if (!isInternalFrontendPlugin(feature)) {
10
11
  continue;
11
12
  }
12
13
  for (const [name, ref] of Object.entries(feature.routes)) {
@@ -1 +1 @@
1
- {"version":3,"file":"collectRouteIds.esm.js","sources":["../../src/routing/collectRouteIds.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 {\n RouteRef,\n SubRouteRef,\n ExternalRouteRef,\n FrontendFeature,\n} from '@backstage/frontend-plugin-api';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isRouteRef,\n toInternalRouteRef,\n} from '../../../frontend-plugin-api/src/routing/RouteRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExternalRouteRef } from '../../../frontend-plugin-api/src/routing/ExternalRouteRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalSubRouteRef } from '../../../frontend-plugin-api/src/routing/SubRouteRef';\n\n/** @internal */\nexport interface RouteRefsById {\n routes: Map<string, RouteRef | SubRouteRef>;\n externalRoutes: Map<string, ExternalRouteRef>;\n}\n\n/** @internal */\nexport function collectRouteIds(features: FrontendFeature[]): RouteRefsById {\n const routesById = new Map<string, RouteRef | SubRouteRef>();\n const externalRoutesById = new Map<string, ExternalRouteRef>();\n\n for (const feature of features) {\n if (feature.$$type !== '@backstage/BackstagePlugin') {\n continue;\n }\n\n for (const [name, ref] of Object.entries(feature.routes)) {\n const refId = `${feature.id}.${name}`;\n if (routesById.has(refId)) {\n throw new Error(`Unexpected duplicate route '${refId}'`);\n }\n\n if (isRouteRef(ref)) {\n const internalRef = toInternalRouteRef(ref);\n internalRef.setId(refId);\n routesById.set(refId, ref);\n } else {\n const internalRef = toInternalSubRouteRef(ref);\n routesById.set(refId, internalRef);\n }\n }\n for (const [name, ref] of Object.entries(feature.externalRoutes)) {\n const refId = `${feature.id}.${name}`;\n if (externalRoutesById.has(refId)) {\n throw new Error(`Unexpected duplicate external route '${refId}'`);\n }\n\n const internalRef = toInternalExternalRouteRef(ref);\n internalRef.setId(refId);\n externalRoutesById.set(refId, ref);\n }\n }\n\n return { routes: routesById, externalRoutes: externalRoutesById };\n}\n"],"names":[],"mappings":";;;;AAuCO,SAAS,gBAAgB,QAA4C,EAAA;AAC1E,EAAM,MAAA,UAAA,uBAAiB,GAAoC,EAAA,CAAA;AAC3D,EAAM,MAAA,kBAAA,uBAAyB,GAA8B,EAAA,CAAA;AAE7D,EAAA,KAAA,MAAW,WAAW,QAAU,EAAA;AAC9B,IAAI,IAAA,OAAA,CAAQ,WAAW,4BAA8B,EAAA;AACnD,MAAA,SAAA;AAAA,KACF;AAEA,IAAW,KAAA,MAAA,CAAC,MAAM,GAAG,CAAA,IAAK,OAAO,OAAQ,CAAA,OAAA,CAAQ,MAAM,CAAG,EAAA;AACxD,MAAA,MAAM,KAAQ,GAAA,CAAA,EAAG,OAAQ,CAAA,EAAE,IAAI,IAAI,CAAA,CAAA,CAAA;AACnC,MAAI,IAAA,UAAA,CAAW,GAAI,CAAA,KAAK,CAAG,EAAA;AACzB,QAAA,MAAM,IAAI,KAAA,CAAM,CAA+B,4BAAA,EAAA,KAAK,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,OACzD;AAEA,MAAI,IAAA,UAAA,CAAW,GAAG,CAAG,EAAA;AACnB,QAAM,MAAA,WAAA,GAAc,mBAAmB,GAAG,CAAA,CAAA;AAC1C,QAAA,WAAA,CAAY,MAAM,KAAK,CAAA,CAAA;AACvB,QAAW,UAAA,CAAA,GAAA,CAAI,OAAO,GAAG,CAAA,CAAA;AAAA,OACpB,MAAA;AACL,QAAM,MAAA,WAAA,GAAc,sBAAsB,GAAG,CAAA,CAAA;AAC7C,QAAW,UAAA,CAAA,GAAA,CAAI,OAAO,WAAW,CAAA,CAAA;AAAA,OACnC;AAAA,KACF;AACA,IAAW,KAAA,MAAA,CAAC,MAAM,GAAG,CAAA,IAAK,OAAO,OAAQ,CAAA,OAAA,CAAQ,cAAc,CAAG,EAAA;AAChE,MAAA,MAAM,KAAQ,GAAA,CAAA,EAAG,OAAQ,CAAA,EAAE,IAAI,IAAI,CAAA,CAAA,CAAA;AACnC,MAAI,IAAA,kBAAA,CAAmB,GAAI,CAAA,KAAK,CAAG,EAAA;AACjC,QAAA,MAAM,IAAI,KAAA,CAAM,CAAwC,qCAAA,EAAA,KAAK,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,OAClE;AAEA,MAAM,MAAA,WAAA,GAAc,2BAA2B,GAAG,CAAA,CAAA;AAClD,MAAA,WAAA,CAAY,MAAM,KAAK,CAAA,CAAA;AACvB,MAAmB,kBAAA,CAAA,GAAA,CAAI,OAAO,GAAG,CAAA,CAAA;AAAA,KACnC;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,MAAA,EAAQ,UAAY,EAAA,cAAA,EAAgB,kBAAmB,EAAA,CAAA;AAClE;;;;"}
1
+ {"version":3,"file":"collectRouteIds.esm.js","sources":["../../src/routing/collectRouteIds.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 {\n RouteRef,\n SubRouteRef,\n ExternalRouteRef,\n} from '@backstage/frontend-plugin-api';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isRouteRef,\n toInternalRouteRef,\n} from '../../../frontend-plugin-api/src/routing/RouteRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExternalRouteRef } from '../../../frontend-plugin-api/src/routing/ExternalRouteRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalSubRouteRef } from '../../../frontend-plugin-api/src/routing/SubRouteRef';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { isInternalFrontendPlugin } from '../../../frontend-plugin-api/src/wiring/createFrontendPlugin';\nimport { FrontendFeature } from '../wiring';\n\n/** @internal */\nexport interface RouteRefsById {\n routes: Map<string, RouteRef | SubRouteRef>;\n externalRoutes: Map<string, ExternalRouteRef>;\n}\n\n/** @internal */\nexport function collectRouteIds(features: FrontendFeature[]): RouteRefsById {\n const routesById = new Map<string, RouteRef | SubRouteRef>();\n const externalRoutesById = new Map<string, ExternalRouteRef>();\n\n for (const feature of features) {\n if (!isInternalFrontendPlugin(feature)) {\n continue;\n }\n\n for (const [name, ref] of Object.entries(feature.routes)) {\n const refId = `${feature.id}.${name}`;\n if (routesById.has(refId)) {\n throw new Error(`Unexpected duplicate route '${refId}'`);\n }\n\n if (isRouteRef(ref)) {\n const internalRef = toInternalRouteRef(ref);\n internalRef.setId(refId);\n routesById.set(refId, ref);\n } else {\n const internalRef = toInternalSubRouteRef(ref);\n routesById.set(refId, internalRef);\n }\n }\n for (const [name, ref] of Object.entries(feature.externalRoutes)) {\n const refId = `${feature.id}.${name}`;\n if (externalRoutesById.has(refId)) {\n throw new Error(`Unexpected duplicate external route '${refId}'`);\n }\n\n const internalRef = toInternalExternalRouteRef(ref);\n internalRef.setId(refId);\n externalRoutesById.set(refId, ref);\n }\n }\n\n return { routes: routesById, externalRoutes: externalRoutesById };\n}\n"],"names":[],"mappings":";;;;;AAyCO,SAAS,gBAAgB,QAA4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EAAA;AACjC,QAAA,MAAM,IAAI,KAAA,CAAM,CAAwC,qCAAA,EAAA,KAAK,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,OAClE;AAEA,MAAM,MAAA,WAAA,GAAc,2BAA2B,GAAG,CAAA,CAAA;AAClD,MAAA,WAAA,CAAY,MAAM,KAAK,CAAA,CAAA;AACvB,MAAmB,kBAAA,CAAA,GAAA,CAAI,OAAO,GAAG,CAAA,CAAA;AAAA,KACnC;AAAA,GACF;AAEA,EAAA,OAAO,EAAE,MAAA,EAAQ,UAAY,EAAA,cAAA,EAAgB,kBAAmB,EAAA,CAAA;AAClE;;;;"}
@@ -1,5 +1,6 @@
1
1
  import { toInternalExtensionOverrides } from '../frontend-plugin-api/src/wiring/createExtensionOverrides.esm.js';
2
- import { toInternalBackstagePlugin } from '../frontend-plugin-api/src/wiring/createFrontendPlugin.esm.js';
2
+ import { isInternalFrontendPlugin, toInternalFrontendPlugin } from '../frontend-plugin-api/src/wiring/createFrontendPlugin.esm.js';
3
+ import { isInternalFrontendModule, toInternalFrontendModule } from '../frontend-plugin-api/src/wiring/createFrontendModule.esm.js';
3
4
  import { toInternalExtension } from '../frontend-plugin-api/src/wiring/resolveExtensionDefinition.esm.js';
4
5
 
5
6
  function resolveAppNodeSpecs(options) {
@@ -9,18 +10,26 @@ function resolveAppNodeSpecs(options) {
9
10
  forbidden = /* @__PURE__ */ new Set(),
10
11
  features = []
11
12
  } = options;
12
- const plugins = features.filter(
13
- (f) => f.$$type === "@backstage/BackstagePlugin"
14
- );
13
+ const plugins = features.filter(isInternalFrontendPlugin);
15
14
  const overrides = features.filter(
16
15
  (f) => f.$$type === "@backstage/ExtensionOverrides"
17
16
  );
17
+ const modules = features.filter(isInternalFrontendModule);
18
18
  const pluginExtensions = plugins.flatMap((source) => {
19
- return toInternalBackstagePlugin(source).extensions.map((extension) => ({
19
+ return toInternalFrontendPlugin(source).extensions.map((extension) => ({
20
20
  ...extension,
21
21
  source
22
22
  }));
23
23
  });
24
+ const moduleExtensions = modules.flatMap(
25
+ (mod) => toInternalFrontendModule(mod).extensions.flatMap((extension) => {
26
+ const source = plugins.find((p) => p.id === mod.pluginId);
27
+ if (!source) {
28
+ return [];
29
+ }
30
+ return [{ ...extension, source }];
31
+ })
32
+ );
24
33
  const overrideExtensions = overrides.flatMap(
25
34
  (override) => toInternalExtensionOverrides(override).extensions
26
35
  );
@@ -31,6 +40,13 @@ function resolveAppNodeSpecs(options) {
31
40
  `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by the following plugin(s): ${pluginsStr}`
32
41
  );
33
42
  }
43
+ if (moduleExtensions.some(({ id }) => forbidden.has(id))) {
44
+ const pluginsStr = moduleExtensions.filter(({ id }) => forbidden.has(id)).map(({ source }) => `'${source.id}'`).join(", ");
45
+ const forbiddenStr = [...forbidden].map((id) => `'${id}'`).join(", ");
46
+ throw new Error(
47
+ `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by a module for the following plugin(s): ${pluginsStr}`
48
+ );
49
+ }
34
50
  if (overrideExtensions.some(({ id }) => forbidden.has(id))) {
35
51
  const forbiddenStr = [...forbidden].map((id) => `'${id}'`).join(", ");
36
52
  throw new Error(
@@ -97,6 +113,27 @@ function resolveAppNodeSpecs(options) {
97
113
  });
98
114
  }
99
115
  }
116
+ for (const extension of moduleExtensions) {
117
+ const internalExtension = toInternalExtension(extension);
118
+ const index = configuredExtensions.findIndex(
119
+ (e) => e.extension.id === extension.id
120
+ );
121
+ if (index !== -1) {
122
+ configuredExtensions[index].extension = internalExtension;
123
+ configuredExtensions[index].params.attachTo = internalExtension.attachTo;
124
+ configuredExtensions[index].params.disabled = internalExtension.disabled;
125
+ } else {
126
+ configuredExtensions.push({
127
+ extension: internalExtension,
128
+ params: {
129
+ source: extension.source,
130
+ attachTo: internalExtension.attachTo,
131
+ disabled: internalExtension.disabled,
132
+ config: void 0
133
+ }
134
+ });
135
+ }
136
+ }
100
137
  const duplicatedExtensionIds = /* @__PURE__ */ new Set();
101
138
  const duplicatedExtensionData = configuredExtensions.reduce((data, { extension, params }) => {
102
139
  const extensionId = extension.id;
@@ -1 +1 @@
1
- {"version":3,"file":"resolveAppNodeSpecs.esm.js","sources":["../../src/tree/resolveAppNodeSpecs.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 {\n BackstagePlugin,\n Extension,\n ExtensionOverrides,\n FrontendFeature,\n} from '@backstage/frontend-plugin-api';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtensionOverrides } from '../../../frontend-plugin-api/src/wiring/createExtensionOverrides';\nimport { ExtensionParameters } from './readAppExtensionsConfig';\nimport { AppNodeSpec } from '@backstage/frontend-plugin-api';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalBackstagePlugin } from '../../../frontend-plugin-api/src/wiring/createFrontendPlugin';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtension } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n\n/** @internal */\nexport function resolveAppNodeSpecs(options: {\n features?: FrontendFeature[];\n builtinExtensions?: Extension<any, any>[];\n parameters?: Array<ExtensionParameters>;\n forbidden?: Set<string>;\n}): AppNodeSpec[] {\n const {\n builtinExtensions = [],\n parameters = [],\n forbidden = new Set(),\n features = [],\n } = options;\n\n const plugins = features.filter(\n (f): f is BackstagePlugin => f.$$type === '@backstage/BackstagePlugin',\n );\n const overrides = features.filter(\n (f): f is ExtensionOverrides =>\n f.$$type === '@backstage/ExtensionOverrides',\n );\n\n const pluginExtensions = plugins.flatMap(source => {\n return toInternalBackstagePlugin(source).extensions.map(extension => ({\n ...extension,\n source,\n }));\n });\n const overrideExtensions = overrides.flatMap(\n override => toInternalExtensionOverrides(override).extensions,\n );\n\n // Prevent core override\n if (pluginExtensions.some(({ id }) => forbidden.has(id))) {\n const pluginsStr = pluginExtensions\n .filter(({ id }) => forbidden.has(id))\n .map(({ source }) => `'${source.id}'`)\n .join(', ');\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by the following plugin(s): ${pluginsStr}`,\n );\n }\n\n if (overrideExtensions.some(({ id }) => forbidden.has(id))) {\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by one or more extension overrides`,\n );\n }\n const overrideExtensionIds = overrideExtensions.map(({ id }) => id);\n if (overrideExtensionIds.length !== new Set(overrideExtensionIds).size) {\n const counts = new Map<string, number>();\n for (const id of overrideExtensionIds) {\n counts.set(id, (counts.get(id) ?? 0) + 1);\n }\n const duplicated = Array.from(counts.entries())\n .filter(([, count]) => count > 1)\n .map(([id]) => id);\n throw new Error(\n `The following extensions had duplicate overrides: ${duplicated.join(\n ', ',\n )}`,\n );\n }\n\n const configuredExtensions = [\n ...pluginExtensions.map(({ source, ...extension }) => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n source,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ...builtinExtensions.map(extension => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n source: undefined,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ];\n\n // Install all extension overrides\n for (const extension of overrideExtensions) {\n const internalExtension = toInternalExtension(extension);\n\n // Check if our override is overriding an extension that already exists\n const index = configuredExtensions.findIndex(\n e => e.extension.id === extension.id,\n );\n if (index !== -1) {\n // Only implementation, attachment point and default disabled status are overridden, the source is kept\n configuredExtensions[index].extension = internalExtension;\n configuredExtensions[index].params.attachTo = internalExtension.attachTo;\n configuredExtensions[index].params.disabled = internalExtension.disabled;\n } else {\n // Add the extension as a new one when not overriding an existing one\n configuredExtensions.push({\n extension: internalExtension,\n params: {\n source: undefined,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined,\n },\n });\n }\n }\n\n const duplicatedExtensionIds = new Set<string>();\n const duplicatedExtensionData = configuredExtensions.reduce<\n Record<string, Record<string, number>>\n >((data, { extension, params }) => {\n const extensionId = extension.id;\n const extensionData = data?.[extensionId];\n if (extensionData) duplicatedExtensionIds.add(extensionId);\n const pluginId = params.source?.id ?? 'internal';\n const pluginCount = extensionData?.[pluginId] ?? 0;\n return {\n ...data,\n [extensionId]: { ...extensionData, [pluginId]: pluginCount + 1 },\n };\n }, {});\n\n if (duplicatedExtensionIds.size > 0) {\n throw new Error(\n `The following extensions are duplicated: ${Array.from(\n duplicatedExtensionIds,\n )\n .map(\n extensionId =>\n `The extension '${extensionId}' was provided ${Object.keys(\n duplicatedExtensionData[extensionId],\n )\n .map(\n pluginId =>\n `${duplicatedExtensionData[extensionId][pluginId]} time(s) by the plugin '${pluginId}'`,\n )\n .join(' and ')}`,\n )\n .join(', ')}`,\n );\n }\n\n const order = new Map<string, (typeof configuredExtensions)[number]>();\n for (const overrideParam of parameters) {\n const extensionId = overrideParam.id;\n\n if (forbidden.has(extensionId)) {\n throw new Error(\n `Configuration of the '${extensionId}' extension is forbidden`,\n );\n }\n\n const existing = configuredExtensions.find(\n e => e.extension.id === extensionId,\n );\n if (existing) {\n if (overrideParam.attachTo) {\n existing.params.attachTo = overrideParam.attachTo;\n }\n if (overrideParam.config) {\n // TODO: merge config?\n existing.params.config = overrideParam.config;\n }\n if (\n Boolean(existing.params.disabled) !== Boolean(overrideParam.disabled)\n ) {\n existing.params.disabled = Boolean(overrideParam.disabled);\n }\n order.set(extensionId, existing);\n } else {\n throw new Error(`Extension ${extensionId} does not exist`);\n }\n }\n\n const orderedExtensions = [\n ...order.values(),\n ...configuredExtensions.filter(e => !order.has(e.extension.id)),\n ];\n\n return orderedExtensions.map(param => ({\n id: param.extension.id,\n attachTo: param.params.attachTo,\n extension: param.extension,\n disabled: param.params.disabled,\n source: param.params.source,\n config: param.params.config,\n }));\n}\n"],"names":[],"mappings":";;;;AAgCO,SAAS,oBAAoB,OAKlB,EAAA;AAChB,EAAM,MAAA;AAAA,IACJ,oBAAoB,EAAC;AAAA,IACrB,aAAa,EAAC;AAAA,IACd,SAAA,uBAAgB,GAAI,EAAA;AAAA,IACpB,WAAW,EAAC;AAAA,GACV,GAAA,OAAA,CAAA;AAEJ,EAAA,MAAM,UAAU,QAAS,CAAA,MAAA;AAAA,IACvB,CAAC,CAA4B,KAAA,CAAA,CAAE,MAAW,KAAA,4BAAA;AAAA,GAC5C,CAAA;AACA,EAAA,MAAM,YAAY,QAAS,CAAA,MAAA;AAAA,IACzB,CAAC,CACC,KAAA,CAAA,CAAE,MAAW,KAAA,+BAAA;AAAA,GACjB,CAAA;AAEA,EAAM,MAAA,gBAAA,GAAmB,OAAQ,CAAA,OAAA,CAAQ,CAAU,MAAA,KAAA;AACjD,IAAA,OAAO,yBAA0B,CAAA,MAAM,CAAE,CAAA,UAAA,CAAW,IAAI,CAAc,SAAA,MAAA;AAAA,MACpE,GAAG,SAAA;AAAA,MACH,MAAA;AAAA,KACA,CAAA,CAAA,CAAA;AAAA,GACH,CAAA,CAAA;AACD,EAAA,MAAM,qBAAqB,SAAU,CAAA,OAAA;AAAA,IACnC,CAAA,QAAA,KAAY,4BAA6B,CAAA,QAAQ,CAAE,CAAA,UAAA;AAAA,GACrD,CAAA;AAGA,EAAI,IAAA,gBAAA,CAAiB,IAAK,CAAA,CAAC,EAAE,EAAA,OAAS,SAAU,CAAA,GAAA,CAAI,EAAE,CAAC,CAAG,EAAA;AACxD,IAAM,M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AA,EAAQ,MAAM,MAAO,CAAA,MAAA;AAAA,IACrB,MAAA,EAAQ,MAAM,MAAO,CAAA,MAAA;AAAA,GACrB,CAAA,CAAA,CAAA;AACJ;;;;"}
1
+ {"version":3,"file":"resolveAppNodeSpecs.esm.js","sources":["../../src/tree/resolveAppNodeSpecs.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 { Extension, ExtensionOverrides } from '@backstage/frontend-plugin-api';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtensionOverrides } from '../../../frontend-plugin-api/src/wiring/createExtensionOverrides';\nimport { ExtensionParameters } from './readAppExtensionsConfig';\nimport { AppNodeSpec } from '@backstage/frontend-plugin-api';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isInternalFrontendPlugin,\n toInternalFrontendPlugin,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendPlugin';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n isInternalFrontendModule,\n toInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtension } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\nimport { FrontendFeature } from '../wiring';\n\n/** @internal */\nexport function resolveAppNodeSpecs(options: {\n features?: FrontendFeature[];\n builtinExtensions?: Extension<any, any>[];\n parameters?: Array<ExtensionParameters>;\n forbidden?: Set<string>;\n}): AppNodeSpec[] {\n const {\n builtinExtensions = [],\n parameters = [],\n forbidden = new Set(),\n features = [],\n } = options;\n\n const plugins = features.filter(isInternalFrontendPlugin);\n const overrides = features.filter(\n (f): f is ExtensionOverrides =>\n f.$$type === '@backstage/ExtensionOverrides',\n );\n const modules = features.filter(isInternalFrontendModule);\n\n const pluginExtensions = plugins.flatMap(source => {\n return toInternalFrontendPlugin(source).extensions.map(extension => ({\n ...extension,\n source,\n }));\n });\n const moduleExtensions = modules.flatMap(mod =>\n toInternalFrontendModule(mod).extensions.flatMap(extension => {\n // Modules for plugins that are not installed are ignored\n const source = plugins.find(p => p.id === mod.pluginId);\n if (!source) {\n return [];\n }\n\n return [{ ...extension, source }];\n }),\n );\n const overrideExtensions = overrides.flatMap(\n override => toInternalExtensionOverrides(override).extensions,\n );\n\n // Prevent core override\n if (pluginExtensions.some(({ id }) => forbidden.has(id))) {\n const pluginsStr = pluginExtensions\n .filter(({ id }) => forbidden.has(id))\n .map(({ source }) => `'${source.id}'`)\n .join(', ');\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by the following plugin(s): ${pluginsStr}`,\n );\n }\n if (moduleExtensions.some(({ id }) => forbidden.has(id))) {\n const pluginsStr = moduleExtensions\n .filter(({ id }) => forbidden.has(id))\n .map(({ source }) => `'${source.id}'`)\n .join(', ');\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by a module for the following plugin(s): ${pluginsStr}`,\n );\n }\n if (overrideExtensions.some(({ id }) => forbidden.has(id))) {\n const forbiddenStr = [...forbidden].map(id => `'${id}'`).join(', ');\n throw new Error(\n `It is forbidden to override the following extension(s): ${forbiddenStr}, which is done by one or more extension overrides`,\n );\n }\n\n const overrideExtensionIds = overrideExtensions.map(({ id }) => id);\n if (overrideExtensionIds.length !== new Set(overrideExtensionIds).size) {\n const counts = new Map<string, number>();\n for (const id of overrideExtensionIds) {\n counts.set(id, (counts.get(id) ?? 0) + 1);\n }\n const duplicated = Array.from(counts.entries())\n .filter(([, count]) => count > 1)\n .map(([id]) => id);\n throw new Error(\n `The following extensions had duplicate overrides: ${duplicated.join(\n ', ',\n )}`,\n );\n }\n\n const configuredExtensions = [\n ...pluginExtensions.map(({ source, ...extension }) => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n source,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ...builtinExtensions.map(extension => {\n const internalExtension = toInternalExtension(extension);\n return {\n extension: internalExtension,\n params: {\n source: undefined,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined as unknown,\n },\n };\n }),\n ];\n\n // Install all extension overrides\n for (const extension of overrideExtensions) {\n const internalExtension = toInternalExtension(extension);\n\n // Check if our override is overriding an extension that already exists\n const index = configuredExtensions.findIndex(\n e => e.extension.id === extension.id,\n );\n if (index !== -1) {\n // Only implementation, attachment point and default disabled status are overridden, the source is kept\n configuredExtensions[index].extension = internalExtension;\n configuredExtensions[index].params.attachTo = internalExtension.attachTo;\n configuredExtensions[index].params.disabled = internalExtension.disabled;\n } else {\n // Add the extension as a new one when not overriding an existing one\n configuredExtensions.push({\n extension: internalExtension,\n params: {\n source: undefined,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined,\n },\n });\n }\n }\n\n // Install all module overrides\n for (const extension of moduleExtensions) {\n const internalExtension = toInternalExtension(extension);\n\n // Check if our override is overriding an extension that already exists\n const index = configuredExtensions.findIndex(\n e => e.extension.id === extension.id,\n );\n if (index !== -1) {\n // Only implementation, attachment point and default disabled status are overridden, the source is kept\n configuredExtensions[index].extension = internalExtension;\n configuredExtensions[index].params.attachTo = internalExtension.attachTo;\n configuredExtensions[index].params.disabled = internalExtension.disabled;\n } else {\n // Add the extension as a new one when not overriding an existing one\n configuredExtensions.push({\n extension: internalExtension,\n params: {\n source: extension.source,\n attachTo: internalExtension.attachTo,\n disabled: internalExtension.disabled,\n config: undefined,\n },\n });\n }\n }\n\n const duplicatedExtensionIds = new Set<string>();\n const duplicatedExtensionData = configuredExtensions.reduce<\n Record<string, Record<string, number>>\n >((data, { extension, params }) => {\n const extensionId = extension.id;\n const extensionData = data?.[extensionId];\n if (extensionData) duplicatedExtensionIds.add(extensionId);\n const pluginId = params.source?.id ?? 'internal';\n const pluginCount = extensionData?.[pluginId] ?? 0;\n return {\n ...data,\n [extensionId]: { ...extensionData, [pluginId]: pluginCount + 1 },\n };\n }, {});\n\n if (duplicatedExtensionIds.size > 0) {\n throw new Error(\n `The following extensions are duplicated: ${Array.from(\n duplicatedExtensionIds,\n )\n .map(\n extensionId =>\n `The extension '${extensionId}' was provided ${Object.keys(\n duplicatedExtensionData[extensionId],\n )\n .map(\n pluginId =>\n `${duplicatedExtensionData[extensionId][pluginId]} time(s) by the plugin '${pluginId}'`,\n )\n .join(' and ')}`,\n )\n .join(', ')}`,\n );\n }\n\n const order = new Map<string, (typeof configuredExtensions)[number]>();\n for (const overrideParam of parameters) {\n const extensionId = overrideParam.id;\n\n if (forbidden.has(extensionId)) {\n throw new Error(\n `Configuration of the '${extensionId}' extension is forbidden`,\n );\n }\n\n const existing = configuredExtensions.find(\n e => e.extension.id === extensionId,\n );\n if (existing) {\n if (overrideParam.attachTo) {\n existing.params.attachTo = overrideParam.attachTo;\n }\n if (overrideParam.config) {\n // TODO: merge config?\n existing.params.config = overrideParam.config;\n }\n if (\n Boolean(existing.params.disabled) !== Boolean(overrideParam.disabled)\n ) {\n existing.params.disabled = Boolean(overrideParam.disabled);\n }\n order.set(extensionId, existing);\n } else {\n throw new Error(`Extension ${extensionId} does not exist`);\n }\n }\n\n const orderedExtensions = [\n ...order.values(),\n ...configuredExtensions.filter(e => !order.has(e.extension.id)),\n ];\n\n return orderedExtensions.map(param => ({\n id: param.extension.id,\n attachTo: param.params.attachTo,\n extension: param.extension,\n disabled: param.params.disabled,\n source: param.params.source,\n config: param.params.config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B,eAAA,CAAA,CAAA,CAAA;AAAA,KAC3D;AAAA,GACF;AAEA,EAAA,MAAM,iBAAoB,GAAA;AAAA,IACxB,GAAG,MAAM,MAAO,EAAA;AAAA,IAChB,GAAG,oBAAqB,CAAA,MAAA,CAAO,CAAK,CAAA,KAAA,CAAC,MAAM,GAAI,CAAA,CAAA,CAAE,SAAU,CAAA,EAAE,CAAC,CAAA;AAAA,GAChE,CAAA;AAEA,EAAO,OAAA,iBAAA,CAAkB,IAAI,CAAU,KAAA,MAAA;AAAA,IACrC,EAAA,EAAI,MAAM,SAAU,CAAA,EAAA;AAAA,IACpB,QAAA,EAAU,MAAM,MAAO,CAAA,QAAA;AAAA,IACvB,WAAW,KAAM,CAAA,SAAA;AAAA,IACjB,QAAA,EAAU,MAAM,MAAO,CAAA,QAAA;AAAA,IACvB,MAAA,EAAQ,MAAM,MAAO,CAAA,MAAA;AAAA,IACrB,MAAA,EAAQ,MAAM,MAAO,CAAA,MAAA;AAAA,GACrB,CAAA,CAAA,CAAA;AACJ;;;;"}
@@ -2,18 +2,16 @@ import React from 'react';
2
2
  import { ConfigReader } from '@backstage/config';
3
3
  import { createApiFactory, appTreeApiRef, routeResolutionApiRef, coreExtensionData, ApiBlueprint } from '@backstage/frontend-plugin-api';
4
4
  import { configApiRef, identityApiRef, featureFlagsApiRef } from '@backstage/core-plugin-api';
5
- import { getAvailableFeatures } from './discovery.esm.js';
6
5
  import { ApiFactoryRegistry, ApiResolver } from '@backstage/core-app-api';
7
- import { defaultConfigLoaderSync } from '../core-app-api/src/app/defaultConfigLoader.esm.js';
8
- import { overrideBaseUrlConfigs } from '../core-app-api/src/app/overrideBaseUrlConfigs.esm.js';
6
+ import { createApp as createApp$1 } from '@backstage/frontend-defaults';
9
7
  import { resolveExtensionDefinition } from '../frontend-plugin-api/src/wiring/resolveExtensionDefinition.esm.js';
10
8
  import { extractRouteInfoFromAppNode } from '../routing/extractRouteInfoFromAppNode.esm.js';
11
9
  import { RouteResolver } from '../routing/RouteResolver.esm.js';
12
10
  import { resolveRouteBindings } from '../routing/resolveRouteBindings.esm.js';
13
11
  import { collectRouteIds } from '../routing/collectRouteIds.esm.js';
14
- import { toInternalBackstagePlugin } from '../frontend-plugin-api/src/wiring/createFrontendPlugin.esm.js';
12
+ import { isInternalFrontendPlugin, toInternalFrontendPlugin } from '../frontend-plugin-api/src/wiring/createFrontendPlugin.esm.js';
13
+ import { isInternalFrontendModule, toInternalFrontendModule } from '../frontend-plugin-api/src/wiring/createFrontendModule.esm.js';
15
14
  import { toInternalExtensionOverrides } from '../frontend-plugin-api/src/wiring/createExtensionOverrides.esm.js';
16
- import { stringifyError } from '@backstage/errors';
17
15
  import { getBasePath } from '../routing/getBasePath.esm.js';
18
16
  import { Root } from '../extensions/Root.esm.js';
19
17
  import { resolveAppTree } from '../tree/resolveAppTree.esm.js';
@@ -22,13 +20,12 @@ import { readAppExtensionsConfig } from '../tree/readAppExtensionsConfig.esm.js'
22
20
  import { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree.esm.js';
23
21
  import { ApiRegistry } from '../core-app-api/src/apis/system/ApiRegistry.esm.js';
24
22
  import { AppIdentityProxy } from '../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy.esm.js';
25
- import appPlugin from '@backstage/plugin-app';
26
23
 
27
24
  function deduplicateFeatures(allFeatures) {
28
25
  const features = Array.from(new Set(allFeatures));
29
26
  const seenIds = /* @__PURE__ */ new Set();
30
27
  return features.reverse().filter((feature) => {
31
- if (feature.$$type !== "@backstage/BackstagePlugin") {
28
+ if (!isInternalFrontendPlugin(feature)) {
32
29
  return true;
33
30
  }
34
31
  if (seenIds.has(feature.id)) {
@@ -38,47 +35,6 @@ function deduplicateFeatures(allFeatures) {
38
35
  return true;
39
36
  }).reverse();
40
37
  }
41
- function createApp(options) {
42
- let suspenseFallback = options?.loadingComponent;
43
- if (suspenseFallback === void 0) {
44
- suspenseFallback = "Loading...";
45
- }
46
- async function appLoader() {
47
- const config = await options?.configLoader?.().then((c) => c.config) ?? ConfigReader.fromConfigs(
48
- overrideBaseUrlConfigs(defaultConfigLoaderSync())
49
- );
50
- const discoveredFeatures = getAvailableFeatures(config);
51
- const providedFeatures = [];
52
- for (const entry of options?.features ?? []) {
53
- if ("load" in entry) {
54
- try {
55
- const result = await entry.load({ config });
56
- providedFeatures.push(...result.features);
57
- } catch (e) {
58
- throw new Error(
59
- `Failed to read frontend features from loader '${entry.getLoaderName()}', ${stringifyError(
60
- e
61
- )}`
62
- );
63
- }
64
- } else {
65
- providedFeatures.push(entry);
66
- }
67
- }
68
- const app = createSpecializedApp({
69
- config,
70
- features: [...discoveredFeatures, ...providedFeatures],
71
- bindRoutes: options?.bindRoutes
72
- }).createRoot();
73
- return { default: () => app };
74
- }
75
- return {
76
- createRoot() {
77
- const LazyApp = React.lazy(appLoader);
78
- return /* @__PURE__ */ React.createElement(React.Suspense, { fallback: suspenseFallback }, /* @__PURE__ */ React.createElement(LazyApp, null));
79
- }
80
- };
81
- }
82
38
  class AppTreeApiProxy {
83
39
  constructor(tree) {
84
40
  this.tree = tree;
@@ -128,17 +84,17 @@ class RouteResolutionApiProxy {
128
84
  return this.#routeObjects;
129
85
  }
130
86
  }
87
+ const createApp = createApp$1;
131
88
  function createSpecializedApp(options) {
132
- const {
133
- features: featuresWithoutApp = [],
134
- config = new ConfigReader({}, "empty-config")
135
- } = options ?? {};
136
- const features = deduplicateFeatures([appPlugin, ...featuresWithoutApp]);
89
+ const config = options?.config ?? new ConfigReader({}, "empty-config");
90
+ const features = deduplicateFeatures(options?.features ?? []);
137
91
  const tree = resolveAppTree(
138
92
  "root",
139
93
  resolveAppNodeSpecs({
140
94
  features,
141
- builtinExtensions: [resolveExtensionDefinition(Root)],
95
+ builtinExtensions: [
96
+ resolveExtensionDefinition(Root, { namespace: "root" })
97
+ ],
142
98
  parameters: readAppExtensionsConfig(config),
143
99
  forbidden: /* @__PURE__ */ new Set(["root"])
144
100
  })
@@ -164,20 +120,25 @@ function createSpecializedApp(options) {
164
120
  createApiFactory(identityApiRef, appIdentityProxy)
165
121
  ]
166
122
  });
167
- instantiateAppNodeTree(tree.root, apiHolder);
168
- routeResolutionApi.initialize();
169
- appTreeApi.initialize();
170
123
  const featureFlagApi = apiHolder.get(featureFlagsApiRef);
171
124
  if (featureFlagApi) {
172
125
  for (const feature of features) {
173
- if (feature.$$type === "@backstage/BackstagePlugin") {
174
- toInternalBackstagePlugin(feature).featureFlags.forEach(
126
+ if (isInternalFrontendPlugin(feature)) {
127
+ toInternalFrontendPlugin(feature).featureFlags.forEach(
175
128
  (flag) => featureFlagApi.registerFlag({
176
129
  name: flag.name,
177
130
  pluginId: feature.id
178
131
  })
179
132
  );
180
133
  }
134
+ if (isInternalFrontendModule(feature)) {
135
+ toInternalFrontendModule(feature).featureFlags.forEach(
136
+ (flag) => featureFlagApi.registerFlag({
137
+ name: flag.name,
138
+ pluginId: feature.pluginId
139
+ })
140
+ );
141
+ }
181
142
  if (feature.$$type === "@backstage/ExtensionOverrides") {
182
143
  toInternalExtensionOverrides(feature).featureFlags.forEach(
183
144
  (flag) => featureFlagApi.registerFlag({ name: flag.name, pluginId: "" })
@@ -185,6 +146,9 @@ function createSpecializedApp(options) {
185
146
  }
186
147
  }
187
148
  }
149
+ instantiateAppNodeTree(tree.root, apiHolder);
150
+ routeResolutionApi.initialize();
151
+ appTreeApi.initialize();
188
152
  const rootEl = tree.root.instance.getData(coreExtensionData.reactElement);
189
153
  const AppComponent = () => rootEl;
190
154
  return {
@@ -221,4 +185,4 @@ function createApiHolder(options) {
221
185
  }
222
186
 
223
187
  export { createApp, createSpecializedApp };
224
- //# sourceMappingURL=createApp.esm.js.map
188
+ //# sourceMappingURL=createSpecializedApp.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createSpecializedApp.esm.js","sources":["../../src/wiring/createSpecializedApp.tsx"],"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 React, { JSX } from 'react';\nimport { ConfigReader } from '@backstage/config';\nimport {\n ApiBlueprint,\n AppTree,\n AppTreeApi,\n appTreeApiRef,\n coreExtensionData,\n RouteRef,\n ExternalRouteRef,\n SubRouteRef,\n AnyRouteRefParams,\n RouteFunc,\n RouteResolutionApiResolveOptions,\n RouteResolutionApi,\n createApiFactory,\n routeResolutionApiRef,\n} from '@backstage/frontend-plugin-api';\nimport {\n AnyApiFactory,\n ApiHolder,\n ConfigApi,\n configApiRef,\n featureFlagsApiRef,\n identityApiRef,\n} from '@backstage/core-plugin-api';\nimport { ApiFactoryRegistry, ApiResolver } from '@backstage/core-app-api';\n\n// TODO: Get rid of all of these\n\nimport {\n createApp as _createApp,\n CreateAppFeatureLoader as _CreateAppFeatureLoader,\n} from '@backstage/frontend-defaults';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { resolveExtensionDefinition } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n\nimport { extractRouteInfoFromAppNode } from '../routing/extractRouteInfoFromAppNode';\n\nimport { CreateAppRouteBinder } from '../routing';\nimport { RouteResolver } from '../routing/RouteResolver';\nimport { resolveRouteBindings } from '../routing/resolveRouteBindings';\nimport { collectRouteIds } from '../routing/collectRouteIds';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n toInternalFrontendPlugin,\n isInternalFrontendPlugin,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendPlugin';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport {\n toInternalFrontendModule,\n isInternalFrontendModule,\n} from '../../../frontend-plugin-api/src/wiring/createFrontendModule';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtensionOverrides } from '../../../frontend-plugin-api/src/wiring/createExtensionOverrides';\nimport { getBasePath } from '../routing/getBasePath';\nimport { Root } from '../extensions/Root';\nimport { resolveAppTree } from '../tree/resolveAppTree';\nimport { resolveAppNodeSpecs } from '../tree/resolveAppNodeSpecs';\nimport { readAppExtensionsConfig } from '../tree/readAppExtensionsConfig';\nimport { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiRegistry } from '../../../core-app-api/src/apis/system/ApiRegistry';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppIdentityProxy } from '../../../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy';\nimport { BackstageRouteObject } from '../routing/types';\nimport { FrontendFeature } from './types';\n\nfunction deduplicateFeatures(\n allFeatures: FrontendFeature[],\n): FrontendFeature[] {\n // Start by removing duplicates by reference\n const features = Array.from(new Set(allFeatures));\n\n // Plugins are deduplicated by ID, last one wins\n const seenIds = new Set<string>();\n return features\n .reverse()\n .filter(feature => {\n if (!isInternalFrontendPlugin(feature)) {\n return true;\n }\n if (seenIds.has(feature.id)) {\n return false;\n }\n seenIds.add(feature.id);\n return true;\n })\n .reverse();\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass AppTreeApiProxy implements AppTreeApi {\n #safeToUse: boolean = false;\n\n constructor(private readonly tree: AppTree) {}\n\n getTree() {\n if (!this.#safeToUse) {\n throw new Error(\n `You can't access the AppTreeApi during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n return { tree: this.tree };\n }\n\n initialize() {\n this.#safeToUse = true;\n }\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass RouteResolutionApiProxy implements RouteResolutionApi {\n #delegate: RouteResolutionApi | undefined;\n #routeObjects: BackstageRouteObject[] | undefined;\n\n constructor(\n private readonly tree: AppTree,\n private readonly routeBindings: Map<\n ExternalRouteRef,\n RouteRef | SubRouteRef\n >,\n private readonly basePath: string,\n ) {}\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: RouteResolutionApiResolveOptions,\n ): RouteFunc<TParams> | undefined {\n if (!this.#delegate) {\n throw new Error(\n `You can't access the RouteResolver during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n\n return this.#delegate.resolve(anyRouteRef, options);\n }\n\n initialize() {\n const routeInfo = extractRouteInfoFromAppNode(this.tree.root);\n\n this.#delegate = new RouteResolver(\n routeInfo.routePaths,\n routeInfo.routeParents,\n routeInfo.routeObjects,\n this.routeBindings,\n this.basePath,\n );\n this.#routeObjects = routeInfo.routeObjects;\n\n return routeInfo;\n }\n\n getRouteObjects() {\n return this.#routeObjects;\n }\n}\n\n/**\n * @public\n * @deprecated Import from `@backstage/frontend-defaults` instead.\n */\nexport const createApp = _createApp;\n\n/**\n * @public\n * @deprecated Import from `@backstage/frontend-defaults` instead.\n */\nexport type CreateAppFeatureLoader = _CreateAppFeatureLoader;\n\n/**\n * Creates an empty app without any default features. This is a low-level API is\n * intended for use in tests or specialized setups. Typically wou want to use\n * `createApp` from `@backstage/frontend-defaults` instead.\n *\n * @public\n */\nexport function createSpecializedApp(options?: {\n features?: FrontendFeature[];\n config?: ConfigApi;\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n}): { createRoot(): JSX.Element } {\n const config = options?.config ?? new ConfigReader({}, 'empty-config');\n const features = deduplicateFeatures(options?.features ?? []);\n\n const tree = resolveAppTree(\n 'root',\n resolveAppNodeSpecs({\n features,\n builtinExtensions: [\n resolveExtensionDefinition(Root, { namespace: 'root' }),\n ],\n parameters: readAppExtensionsConfig(config),\n forbidden: new Set(['root']),\n }),\n );\n\n const factories = createApiFactories({ tree });\n const appTreeApi = new AppTreeApiProxy(tree);\n const routeResolutionApi = new RouteResolutionApiProxy(\n tree,\n resolveRouteBindings(\n options?.bindRoutes,\n config,\n collectRouteIds(features),\n ),\n getBasePath(config),\n );\n\n const appIdentityProxy = new AppIdentityProxy();\n const apiHolder = createApiHolder({\n factories,\n staticFactories: [\n createApiFactory(appTreeApiRef, appTreeApi),\n createApiFactory(configApiRef, config),\n createApiFactory(routeResolutionApiRef, routeResolutionApi),\n createApiFactory(identityApiRef, appIdentityProxy),\n ],\n });\n\n const featureFlagApi = apiHolder.get(featureFlagsApiRef);\n if (featureFlagApi) {\n for (const feature of features) {\n if (isInternalFrontendPlugin(feature)) {\n toInternalFrontendPlugin(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n pluginId: feature.id,\n }),\n );\n }\n if (isInternalFrontendModule(feature)) {\n toInternalFrontendModule(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n pluginId: feature.pluginId,\n }),\n );\n }\n if (feature.$$type === '@backstage/ExtensionOverrides') {\n toInternalExtensionOverrides(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({ name: flag.name, pluginId: '' }),\n );\n }\n }\n }\n\n // Now instantiate the entire tree, which will skip anything that's already been instantiated\n instantiateAppNodeTree(tree.root, apiHolder);\n\n routeResolutionApi.initialize();\n appTreeApi.initialize();\n\n const rootEl = tree.root.instance!.getData(coreExtensionData.reactElement);\n\n const AppComponent = () => rootEl;\n\n return {\n createRoot() {\n return <AppComponent />;\n },\n };\n}\n\nfunction createApiFactories(options: { tree: AppTree }): AnyApiFactory[] {\n const emptyApiHolder = ApiRegistry.from([]);\n const factories = new Array<AnyApiFactory>();\n\n for (const apiNode of options.tree.root.edges.attachments.get('apis') ?? []) {\n instantiateAppNodeTree(apiNode, emptyApiHolder);\n const apiFactory = apiNode.instance?.getData(ApiBlueprint.dataRefs.factory);\n if (!apiFactory) {\n throw new Error(\n `No API factory found in for extension ${apiNode.spec.id}`,\n );\n }\n factories.push(apiFactory);\n }\n\n return factories;\n}\n\nfunction createApiHolder(options: {\n factories: AnyApiFactory[];\n staticFactories: AnyApiFactory[];\n}): ApiHolder {\n const factoryRegistry = new ApiFactoryRegistry();\n\n for (const factory of options.factories) {\n factoryRegistry.register('default', factory);\n }\n\n for (const factory of options.staticFactories) {\n factoryRegistry.register('static', factory);\n }\n\n ApiResolver.validateFactories(factoryRegistry, factoryRegistry.getAllApis());\n\n return new ApiResolver(factoryRegistry);\n}\n"],"names":["_createApp"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoFA,SAAS,oBACP,WACmB,EAAA;AAEnB,EAAA,MAAM,WAAW,KAAM,CAAA,IAAA,CAAK,IAAI,GAAA,CAAI,WAAW,CAAC,CAAA,CAAA;AAGhD,EAAM,MAAA,OAAA,uBAAc,GAAY,EAAA,CAAA;AAChC,EAAA,OAAO,QACJ,CAAA,OAAA,EACA,CAAA,MAAA,CAAO,CAAW,OAAA,KAAA;AACjB,IAAI,IAAA,CAAC,wBAAyB,CAAA,OAAO,CAAG,EAAA;AACtC,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AACA,IAAA,IAAI,OAAQ,CAAA,GAAA,CAAI,OAAQ,CAAA,EAAE,CAAG,EAAA;AAC3B,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AACA,IAAQ,OAAA,CAAA,GAAA,CAAI,QAAQ,EAAE,CAAA,CAAA;AACtB,IAAO,OAAA,IAAA,CAAA;AAAA,GACR,EACA,OAAQ,EAAA,CAAA;AACb,CAAA;AAGA,MAAM,eAAsC,CAAA;AAAA,EAG1C,YAA6B,IAAe,EAAA;AAAf,IAAA,IAAA,CAAA,IAAA,GAAA,IAAA,CAAA;AAAA,GAAgB;AAAA,EAF7C,UAAsB,GAAA,KAAA,CAAA;AAAA,EAItB,OAAU,GAAA;AACR,IAAI,IAAA,CAAC,KAAK,UAAY,EAAA;AACpB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,+IAAA,CAAA;AAAA,OACF,CAAA;AAAA,KACF;AACA,IA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AAiB,EAAA;AAC7C,IAAgB,eAAA,CAAA,QAAA,CAAS,UAAU,OAAO,CAAA,CAAA;AAAA,GAC5C;AAEA,EAAA,WAAA,CAAY,iBAAkB,CAAA,eAAA,EAAiB,eAAgB,CAAA,UAAA,EAAY,CAAA,CAAA;AAE3E,EAAO,OAAA,IAAI,YAAY,eAAe,CAAA,CAAA;AACxC;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/frontend-app-api",
3
- "version": "0.9.0-next.0",
3
+ "version": "0.9.0-next.1",
4
4
  "backstage": {
5
5
  "role": "web-library"
6
6
  },
@@ -34,21 +34,18 @@
34
34
  "dependencies": {
35
35
  "@backstage/config": "^1.2.0",
36
36
  "@backstage/core-app-api": "^1.14.2",
37
- "@backstage/core-components": "^0.14.10",
38
37
  "@backstage/core-plugin-api": "^1.9.3",
39
38
  "@backstage/errors": "^1.2.4",
40
- "@backstage/frontend-plugin-api": "^0.8.0-next.0",
41
- "@backstage/plugin-app": "^0.1.0-next.0",
42
- "@backstage/theme": "^0.5.6",
39
+ "@backstage/frontend-defaults": "^0.1.0-next.0",
40
+ "@backstage/frontend-plugin-api": "^0.8.0-next.1",
43
41
  "@backstage/types": "^1.1.1",
44
42
  "@backstage/version-bridge": "^1.0.8",
45
- "@material-ui/core": "^4.12.4",
46
- "@material-ui/icons": "^4.11.3",
47
43
  "@types/react": "^16.13.1 || ^17.0.0 || ^18.0.0",
48
44
  "lodash": "^4.17.21"
49
45
  },
50
46
  "devDependencies": {
51
- "@backstage/cli": "^0.27.1-next.0",
47
+ "@backstage/cli": "^0.27.1-next.1",
48
+ "@backstage/plugin-app": "^0.1.0-next.1",
52
49
  "@backstage/test-utils": "^1.6.0-next.0",
53
50
  "@testing-library/jest-dom": "^6.0.0",
54
51
  "@testing-library/react": "^15.0.0"
@@ -1,33 +0,0 @@
1
- function defaultConfigLoaderSync(runtimeConfigJson = "__APP_INJECTED_RUNTIME_CONFIG__") {
2
- const appConfig = process.env.APP_CONFIG;
3
- if (!appConfig) {
4
- throw new Error("No static configuration provided");
5
- }
6
- if (!Array.isArray(appConfig)) {
7
- throw new Error("Static configuration has invalid format");
8
- }
9
- const configs = appConfig.slice();
10
- if (runtimeConfigJson !== "__app_injected_runtime_config__".toLocaleUpperCase("en-US")) {
11
- try {
12
- const data = JSON.parse(runtimeConfigJson);
13
- if (Array.isArray(data)) {
14
- configs.push(...data);
15
- } else {
16
- configs.push({ data, context: "env" });
17
- }
18
- } catch (error) {
19
- throw new Error(`Failed to load runtime configuration, ${error}`);
20
- }
21
- }
22
- const windowAppConfig = window.__APP_CONFIG__;
23
- if (windowAppConfig) {
24
- configs.push({
25
- context: "window",
26
- data: windowAppConfig
27
- });
28
- }
29
- return configs;
30
- }
31
-
32
- export { defaultConfigLoaderSync };
33
- //# sourceMappingURL=defaultConfigLoader.esm.js.map
@@ -1 +0,0 @@
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 // Avoiding this string also being replaced at runtime\n if (\n runtimeConfigJson !==\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,CAAA;AAC9B,EAAA,IAAI,CAAC,SAAW,EAAA;AACd,IAAM,MAAA,IAAI,MAAM,kCAAkC,CAAA,CAAA;AAAA,GACpD;AACA,EAAA,IAAI,CAAC,KAAA,CAAM,OAAQ,CAAA,SAAS,CAAG,EAAA;AAC7B,IAAM,MAAA,IAAI,MAAM,yCAAyC,CAAA,CAAA;AAAA,GAC3D;AACA,EAAM,MAAA,OAAA,GAAU,UAAU,KAAM,EAAA,CAAA;AAGhC,EAAA,IACE,iBACA,KAAA,iCAAA,CAAkC,iBAAkB,CAAA,OAAO,CAC3D,EAAA;AACA,IAAI,IAAA;AACF,MAAM,MAAA,IAAA,GAAO,IAAK,CAAA,KAAA,CAAM,iBAAiB,CAAA,CAAA;AACzC,MAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,IAAI,CAAG,EAAA;AACvB,QAAQ,OAAA,CAAA,IAAA,CAAK,GAAG,IAAI,CAAA,CAAA;AAAA,OACf,MAAA;AACL,QAAA,OAAA,CAAQ,IAAK,CAAA,EAAE,IAAM,EAAA,OAAA,EAAS,OAAO,CAAA,CAAA;AAAA,OACvC;AAAA,aACO,KAAO,EAAA;AACd,MAAA,MAAM,IAAI,KAAA,CAAM,CAAyC,sCAAA,EAAA,KAAK,CAAE,CAAA,CAAA,CAAA;AAAA,KAClE;AAAA,GACF;AAEA,EAAA,MAAM,kBAAmB,MAAe,CAAA,cAAA,CAAA;AACxC,EAAA,IAAI,eAAiB,EAAA;AACnB,IAAA,OAAA,CAAQ,IAAK,CAAA;AAAA,MACX,OAAS,EAAA,QAAA;AAAA,MACT,IAAM,EAAA,eAAA;AAAA,KACP,CAAA,CAAA;AAAA,GACH;AACA,EAAO,OAAA,OAAA,CAAA;AACT;;;;"}
@@ -1,50 +0,0 @@
1
- import { ConfigReader } from '@backstage/config';
2
-
3
- function createLocalBaseUrl(fullUrl) {
4
- const url = new URL(fullUrl);
5
- url.protocol = document.location.protocol;
6
- url.hostname = document.location.hostname;
7
- url.port = document.location.port;
8
- return url.toString().replace(/\/$/, "");
9
- }
10
- function overrideBaseUrlConfigs(inputConfigs) {
11
- const urlConfigReader = ConfigReader.fromConfigs(inputConfigs);
12
- const appBaseUrl = urlConfigReader.getOptionalString("app.baseUrl");
13
- const backendBaseUrl = urlConfigReader.getOptionalString("backend.baseUrl");
14
- let configs = inputConfigs;
15
- let newBackendBaseUrl = void 0;
16
- let newAppBaseUrl = void 0;
17
- if (appBaseUrl && backendBaseUrl) {
18
- const appOrigin = new URL(appBaseUrl).origin;
19
- const backendOrigin = new URL(backendBaseUrl).origin;
20
- if (appOrigin === backendOrigin) {
21
- const maybeNewBackendBaseUrl = createLocalBaseUrl(backendBaseUrl);
22
- if (backendBaseUrl !== maybeNewBackendBaseUrl) {
23
- newBackendBaseUrl = maybeNewBackendBaseUrl;
24
- }
25
- }
26
- }
27
- if (appBaseUrl) {
28
- const maybeNewAppBaseUrl = createLocalBaseUrl(appBaseUrl);
29
- if (appBaseUrl !== maybeNewAppBaseUrl) {
30
- newAppBaseUrl = maybeNewAppBaseUrl;
31
- }
32
- }
33
- if (newAppBaseUrl || newBackendBaseUrl) {
34
- configs = configs.concat({
35
- data: {
36
- app: newAppBaseUrl && {
37
- baseUrl: newAppBaseUrl
38
- },
39
- backend: newBackendBaseUrl && {
40
- baseUrl: newBackendBaseUrl
41
- }
42
- },
43
- context: "relative-resolver"
44
- });
45
- }
46
- return configs;
47
- }
48
-
49
- export { overrideBaseUrlConfigs };
50
- //# sourceMappingURL=overrideBaseUrlConfigs.esm.js.map
@@ -1 +0,0 @@
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,CAAA;AAC3B,EAAI,GAAA,CAAA,QAAA,GAAW,SAAS,QAAS,CAAA,QAAA,CAAA;AACjC,EAAI,GAAA,CAAA,QAAA,GAAW,SAAS,QAAS,CAAA,QAAA,CAAA;AACjC,EAAI,GAAA,CAAA,IAAA,GAAO,SAAS,QAAS,CAAA,IAAA,CAAA;AAC7B,EAAA,OAAO,GAAI,CAAA,QAAA,EAAW,CAAA,OA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AAA,QACA,SAAS,iBAAqB,IAAA;AAAA,UAC5B,OAAS,EAAA,iBAAA;AAAA,SACX;AAAA,OACF;AAAA,MACA,OAAS,EAAA,mBAAA;AAAA,KACV,CAAA,CAAA;AAAA,GACH;AAEA,EAAO,OAAA,OAAA,CAAA;AACT;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createApp.esm.js","sources":["../../src/wiring/createApp.tsx"],"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 React, { JSX, ReactNode } from 'react';\nimport { ConfigReader } from '@backstage/config';\nimport {\n ApiBlueprint,\n AppTree,\n AppTreeApi,\n appTreeApiRef,\n coreExtensionData,\n FrontendFeature,\n RouteRef,\n ExternalRouteRef,\n SubRouteRef,\n AnyRouteRefParams,\n RouteFunc,\n RouteResolutionApiResolveOptions,\n RouteResolutionApi,\n createApiFactory,\n routeResolutionApiRef,\n} from '@backstage/frontend-plugin-api';\n\nimport {\n AnyApiFactory,\n ApiHolder,\n ConfigApi,\n configApiRef,\n featureFlagsApiRef,\n identityApiRef,\n} from '@backstage/core-plugin-api';\nimport { getAvailableFeatures } from './discovery';\nimport { ApiFactoryRegistry, ApiResolver } from '@backstage/core-app-api';\n\n// TODO: Get rid of all of these\n\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';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { resolveExtensionDefinition } from '../../../frontend-plugin-api/src/wiring/resolveExtensionDefinition';\n\nimport { extractRouteInfoFromAppNode } from '../routing/extractRouteInfoFromAppNode';\n\nimport { CreateAppRouteBinder } from '../routing';\nimport { RouteResolver } from '../routing/RouteResolver';\nimport { resolveRouteBindings } from '../routing/resolveRouteBindings';\nimport { collectRouteIds } from '../routing/collectRouteIds';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalBackstagePlugin } from '../../../frontend-plugin-api/src/wiring/createFrontendPlugin';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalExtensionOverrides } from '../../../frontend-plugin-api/src/wiring/createExtensionOverrides';\nimport { stringifyError } from '@backstage/errors';\nimport { getBasePath } from '../routing/getBasePath';\nimport { Root } from '../extensions/Root';\nimport { resolveAppTree } from '../tree/resolveAppTree';\nimport { resolveAppNodeSpecs } from '../tree/resolveAppNodeSpecs';\nimport { readAppExtensionsConfig } from '../tree/readAppExtensionsConfig';\nimport { instantiateAppNodeTree } from '../tree/instantiateAppNodeTree';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { ApiRegistry } from '../../../core-app-api/src/apis/system/ApiRegistry';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { AppIdentityProxy } from '../../../core-app-api/src/apis/implementations/IdentityApi/AppIdentityProxy';\nimport { BackstageRouteObject } from '../routing/types';\nimport appPlugin from '@backstage/plugin-app';\n\nfunction deduplicateFeatures(\n allFeatures: FrontendFeature[],\n): FrontendFeature[] {\n // Start by removing duplicates by reference\n const features = Array.from(new Set(allFeatures));\n\n // Plugins are deduplicated by ID, last one wins\n const seenIds = new Set<string>();\n return features\n .reverse()\n .filter(feature => {\n if (feature.$$type !== '@backstage/BackstagePlugin') {\n return true;\n }\n if (seenIds.has(feature.id)) {\n return false;\n }\n seenIds.add(feature.id);\n return true;\n })\n .reverse();\n}\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/** @public */\nexport function createApp(options?: {\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 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: [...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\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass AppTreeApiProxy implements AppTreeApi {\n #safeToUse: boolean = false;\n\n constructor(private readonly tree: AppTree) {}\n\n getTree() {\n if (!this.#safeToUse) {\n throw new Error(\n `You can't access the AppTreeApi during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n return { tree: this.tree };\n }\n\n initialize() {\n this.#safeToUse = true;\n }\n}\n\n// Helps delay callers from reaching out to the API before the app tree has been materialized\nclass RouteResolutionApiProxy implements RouteResolutionApi {\n #delegate: RouteResolutionApi | undefined;\n #routeObjects: BackstageRouteObject[] | undefined;\n\n constructor(\n private readonly tree: AppTree,\n private readonly routeBindings: Map<\n ExternalRouteRef,\n RouteRef | SubRouteRef\n >,\n private readonly basePath: string,\n ) {}\n\n resolve<TParams extends AnyRouteRefParams>(\n anyRouteRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n options?: RouteResolutionApiResolveOptions,\n ): RouteFunc<TParams> | undefined {\n if (!this.#delegate) {\n throw new Error(\n `You can't access the RouteResolver during initialization of the app tree. Please move occurrences of this out of the initialization of the factory`,\n );\n }\n\n return this.#delegate.resolve(anyRouteRef, options);\n }\n\n initialize() {\n const routeInfo = extractRouteInfoFromAppNode(this.tree.root);\n\n this.#delegate = new RouteResolver(\n routeInfo.routePaths,\n routeInfo.routeParents,\n routeInfo.routeObjects,\n this.routeBindings,\n this.basePath,\n );\n this.#routeObjects = routeInfo.routeObjects;\n\n return routeInfo;\n }\n\n getRouteObjects() {\n return this.#routeObjects;\n }\n}\n\n/**\n * Synchronous version of {@link createApp}, expecting all features and\n * config to have been loaded already.\n *\n * @public\n */\nexport function createSpecializedApp(options?: {\n features?: FrontendFeature[];\n config?: ConfigApi;\n bindRoutes?(context: { bind: CreateAppRouteBinder }): void;\n}): { createRoot(): JSX.Element } {\n const {\n features: featuresWithoutApp = [],\n config = new ConfigReader({}, 'empty-config'),\n } = options ?? {};\n\n const features = deduplicateFeatures([appPlugin, ...featuresWithoutApp]);\n\n const tree = resolveAppTree(\n 'root',\n resolveAppNodeSpecs({\n features,\n builtinExtensions: [resolveExtensionDefinition(Root)],\n parameters: readAppExtensionsConfig(config),\n forbidden: new Set(['root']),\n }),\n );\n\n const factories = createApiFactories({ tree });\n const appTreeApi = new AppTreeApiProxy(tree);\n const routeResolutionApi = new RouteResolutionApiProxy(\n tree,\n resolveRouteBindings(\n options?.bindRoutes,\n config,\n collectRouteIds(features),\n ),\n getBasePath(config),\n );\n\n const appIdentityProxy = new AppIdentityProxy();\n const apiHolder = createApiHolder({\n factories,\n staticFactories: [\n createApiFactory(appTreeApiRef, appTreeApi),\n createApiFactory(configApiRef, config),\n createApiFactory(routeResolutionApiRef, routeResolutionApi),\n createApiFactory(identityApiRef, appIdentityProxy),\n ],\n });\n\n // Now instantiate the entire tree, which will skip anything that's already been instantiated\n instantiateAppNodeTree(tree.root, apiHolder);\n\n routeResolutionApi.initialize();\n appTreeApi.initialize();\n\n const featureFlagApi = apiHolder.get(featureFlagsApiRef);\n if (featureFlagApi) {\n for (const feature of features) {\n if (feature.$$type === '@backstage/BackstagePlugin') {\n toInternalBackstagePlugin(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({\n name: flag.name,\n pluginId: feature.id,\n }),\n );\n }\n if (feature.$$type === '@backstage/ExtensionOverrides') {\n toInternalExtensionOverrides(feature).featureFlags.forEach(flag =>\n featureFlagApi.registerFlag({ name: flag.name, pluginId: '' }),\n );\n }\n }\n }\n\n const rootEl = tree.root.instance!.getData(coreExtensionData.reactElement);\n\n const AppComponent = () => rootEl;\n\n return {\n createRoot() {\n return <AppComponent />;\n },\n };\n}\n\nfunction createApiFactories(options: { tree: AppTree }): AnyApiFactory[] {\n const emptyApiHolder = ApiRegistry.from([]);\n const factories = new Array<AnyApiFactory>();\n\n for (const apiNode of options.tree.root.edges.attachments.get('apis') ?? []) {\n instantiateAppNodeTree(apiNode, emptyApiHolder);\n const apiFactory = apiNode.instance?.getData(ApiBlueprint.dataRefs.factory);\n if (!apiFactory) {\n throw new Error(\n `No API factory found in for extension ${apiNode.spec.id}`,\n );\n }\n factories.push(apiFactory);\n }\n\n return factories;\n}\n\nfunction createApiHolder(options: {\n factories: AnyApiFactory[];\n staticFactories: AnyApiFactory[];\n}): ApiHolder {\n const factoryRegistry = new ApiFactoryRegistry();\n\n for (const factory of options.factories) {\n factoryRegistry.register('default', factory);\n }\n\n for (const factory of options.staticFactories) {\n factoryRegistry.register('static', factory);\n }\n\n ApiResolver.validateFactories(factoryRegistry, factoryRegistry.getAllApis());\n\n return new ApiResolver(factoryRegistry);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,SAAS,oBACP,WACmB,EAAA;AAEnB,EAAA,MAAM,WAAW,KAAM,CAAA,IAAA,CAAK,IAAI,GAAA,CAAI,WAAW,CAAC,CAAA,CAAA;AAGhD,EAAM,MAAA,OAAA,uBAAc,GAAY,EAAA,CAAA;AAChC,EAAA,OAAO,QACJ,CAAA,OAAA,EACA,CAAA,MAAA,CAAO,CAAW,OAAA,KAAA;AACjB,IAAI,IAAA,OAAA,CAAQ,WAAW,4BAA8B,EAAA;AACnD,MAAO,OAAA,IAAA,CAAA;AAAA,KACT;AACA,IAAA,IAAI,OAAQ,CAAA,GAAA,CAAI,OAAQ,CAAA,EAAE,CAAG,EAAA;AAC3B,MAAO,OAAA,KAAA,CAAA;AAAA,KACT;AACA,IAAQ,OAAA,CAAA,GAAA,CAAI,QAAQ,EAAE,CAAA,CAAA;AACtB,IAAO,OAAA,IAAA,CAAA;AAAA,GACR,EACA,OAAQ,EAAA,CAAA;AACb,CAAA;AAsBO,SAAS,UAAU,OAaxB,EAAA;AACA,EAAA,IAAI,mBAAmB,OAAS,EAAA,gBAAA,CAAA;AAChC,EAAA,IAAI,qBAAqB,KAAW,CAAA,EAAA;AAClC,IAAmB,gBAAA,GAAA,YAAA,CAAA;AAAA,GACrB;AAEA,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,WA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AAgB,eAAA,CAAA,QAAA,CAAS,WAAW,OAAO,CAAA,CAAA;AAAA,GAC7C;AAEA,EAAW,KAAA,MAAA,OAAA,IAAW,QAAQ,eAAiB,EAAA;AAC7C,IAAgB,eAAA,CAAA,QAAA,CAAS,UAAU,OAAO,CAAA,CAAA;AAAA,GAC5C;AAEA,EAAA,WAAA,CAAY,iBAAkB,CAAA,eAAA,EAAiB,eAAgB,CAAA,UAAA,EAAY,CAAA,CAAA;AAE3E,EAAO,OAAA,IAAI,YAAY,eAAe,CAAA,CAAA;AACxC;;;;"}
@@ -1,54 +0,0 @@
1
- import { ConfigReader } from '@backstage/config';
2
-
3
- function readPackageDetectionConfig(config) {
4
- const packages = config.getOptional("app.experimental.packages");
5
- if (packages === void 0 || packages === null) {
6
- return void 0;
7
- }
8
- if (typeof packages === "string") {
9
- if (packages !== "all") {
10
- throw new Error(
11
- `Invalid app.experimental.packages mode, got '${packages}', expected 'all'`
12
- );
13
- }
14
- return {};
15
- }
16
- if (typeof packages !== "object" || Array.isArray(packages)) {
17
- throw new Error(
18
- "Invalid config at 'app.experimental.packages', expected object"
19
- );
20
- }
21
- const packagesConfig = new ConfigReader(
22
- packages,
23
- "app.experimental.packages"
24
- );
25
- return {
26
- include: packagesConfig.getOptionalStringArray("include"),
27
- exclude: packagesConfig.getOptionalStringArray("exclude")
28
- };
29
- }
30
- function getAvailableFeatures(config) {
31
- const discovered = window["__@backstage/discovered__"];
32
- const detection = readPackageDetectionConfig(config);
33
- if (!detection) {
34
- return [];
35
- }
36
- return discovered?.modules.filter(({ name }) => {
37
- if (detection.exclude?.includes(name)) {
38
- return false;
39
- }
40
- if (detection.include && !detection.include.includes(name)) {
41
- return false;
42
- }
43
- return true;
44
- }).map((m) => m.default).filter(isBackstageFeature) ?? [];
45
- }
46
- function isBackstageFeature(obj) {
47
- if (obj !== null && typeof obj === "object" && "$$type" in obj) {
48
- return obj.$$type === "@backstage/BackstagePlugin" || obj.$$type === "@backstage/ExtensionOverrides";
49
- }
50
- return false;
51
- }
52
-
53
- export { getAvailableFeatures };
54
- //# sourceMappingURL=discovery.esm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discovery.esm.js","sources":["../../src/wiring/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-plugin-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 * @public\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/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,CAAA;AAC/D,EAAI,IAAA,QAAA,KAAa,KAAa,CAAA,IAAA,QAAA,KAAa,IAAM,EAAA;AAC/C,IAAO,OAAA,KAAA,CAAA,CAAA;AAAA,GACT;AAEA,EAAI,IAAA,OAAO,aAAa,QAAU,EAAA;AAChC,IAAA,IAAI,aAAa,KAAO,EAAA;AACtB,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,gDAAgD,QAAQ,CAAA,iBAAA,CAAA;AAAA,OAC1D,CAAA;AAAA,KACF;AACA,IAAA,OAAO,EAAC,CAAA;AAAA,GACV;AAEA,EAAA,IAAI,OAAO,QAAa,KAAA,QAAA,IAAY,KAAM,CAAA,OAAA,CAAQ,QAAQ,CAAG,EAAA;AAC3D,IAAA,MAAM,IAAI,KAAA;AAAA,MACR,gEAAA;AAAA,KACF,CAAA;AAAA,GACF;AACA,EAAA,MAAM,iBAAiB,IAAI,YAAA;AAAA,IACzB,QAAA;AAAA,IACA,2BAAA;AAAA,GACF,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,OAAA,EAAS,cAAe,CAAA,sBAAA,CAAuB,SAAS,CAAA;AAAA,IACxD,OAAA,EAAS,cAAe,CAAA,sBAAA,CAAuB,SAAS,CAAA;AAAA,GAC1D,CAAA;AACF,CAAA;AAKO,SAAS,qBAAqB,MAAmC,EAAA;AACtE,EAAM,MAAA,UAAA,GACJ,OACA,2BAA2B,CAAA,CAAA;AAE7B,EAAM,MAAA,SAAA,GA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