@backstage/core-compat-api 0.0.1-next.0 → 0.0.1-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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @backstage/core-compat-api
2
2
 
3
+ ## 0.0.1-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+ - @backstage/frontend-plugin-api@0.4.0-next.1
9
+ - @backstage/core-plugin-api@1.8.1-next.1
10
+ - @backstage/core-app-api@1.11.2-next.1
11
+
3
12
  ## 0.0.1-next.0
4
13
 
5
14
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  /// <reference types="react" />
2
- import { BackstagePlugin, ExtensionOverrides, RouteRef as RouteRef$1, SubRouteRef as SubRouteRef$1, ExternalRouteRef as ExternalRouteRef$1 } from '@backstage/frontend-plugin-api';
2
+ import { BackstagePlugin, Extension, ExtensionOverrides, RouteRef as RouteRef$1, SubRouteRef as SubRouteRef$1, ExternalRouteRef as ExternalRouteRef$1 } from '@backstage/frontend-plugin-api';
3
+ import { AppComponents, AnyRouteRefParams, RouteRef, SubRouteRef, ExternalRouteRef } from '@backstage/core-plugin-api';
3
4
  import React from 'react';
4
- import { AnyRouteRefParams, RouteRef, SubRouteRef, ExternalRouteRef } from '@backstage/core-plugin-api';
5
5
 
6
6
  /** @public */
7
7
  declare function collectLegacyRoutes(flatRoutesElement: JSX.Element): BackstagePlugin[];
8
8
 
9
+ /** @public */
10
+ declare function collectLegacyComponents(components: Partial<AppComponents>): Extension<unknown>[];
11
+
9
12
  /** @public */
10
13
  declare function convertLegacyApp(rootElement: React.JSX.Element): (ExtensionOverrides | BackstagePlugin)[];
11
14
 
@@ -37,4 +40,4 @@ declare function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(ref: S
37
40
  */
38
41
  declare function convertLegacyRouteRef<TParams extends AnyRouteRefParams, TOptional extends boolean>(ref: ExternalRouteRef<TParams, TOptional>): ExternalRouteRef$1<TParams, TOptional>;
39
42
 
40
- export { collectLegacyRoutes, convertLegacyApp, convertLegacyRouteRef };
43
+ export { collectLegacyComponents, collectLegacyRoutes, convertLegacyApp, convertLegacyRouteRef };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { Children, isValidElement, Fragment } from 'react';
2
- import { createRouteRef, createSubRouteRef, createExternalRouteRef, createPageExtension, createPlugin, createApiExtension, createExtension, createExtensionInput, coreExtensionData, createExtensionOverrides } from '@backstage/frontend-plugin-api';
2
+ import { createRouteRef, createSubRouteRef, createExternalRouteRef, createPageExtension, createPlugin, createApiExtension, coreComponentsRefs, createComponentExtension, createExtension, createExtensionInput, coreExtensionData, createExtensionOverrides } from '@backstage/frontend-plugin-api';
3
3
  import { Route, Routes } from 'react-router-dom';
4
4
  import { getComponentData } from '@backstage/core-plugin-api';
5
5
  import { getOrCreateGlobalSingleton } from '@backstage/version-bridge';
@@ -172,6 +172,27 @@ function collectLegacyRoutes(flatRoutesElement) {
172
172
  );
173
173
  }
174
174
 
175
+ const refs = {
176
+ Progress: coreComponentsRefs.progress,
177
+ BootErrorPage: coreComponentsRefs.bootErrorPage,
178
+ NotFoundErrorPage: coreComponentsRefs.notFoundErrorPage,
179
+ ErrorBoundaryFallback: coreComponentsRefs.errorBoundaryFallback
180
+ };
181
+ function collectLegacyComponents(components) {
182
+ return Object.entries(components).reduce(
183
+ (extensions, [name, component]) => {
184
+ const ref = refs[name];
185
+ return ref ? extensions.concat(
186
+ createComponentExtension({
187
+ ref,
188
+ component: { sync: () => component }
189
+ })
190
+ ) : extensions;
191
+ },
192
+ []
193
+ );
194
+ }
195
+
175
196
  function selectChildren(rootNode, selector, strictError) {
176
197
  return Children.toArray(rootNode).flatMap((node) => {
177
198
  if (!isValidElement(node)) {
@@ -258,5 +279,5 @@ function convertLegacyApp(rootElement) {
258
279
  ];
259
280
  }
260
281
 
261
- export { collectLegacyRoutes, convertLegacyApp, convertLegacyRouteRef };
282
+ export { collectLegacyComponents, collectLegacyRoutes, convertLegacyApp, convertLegacyRouteRef };
262
283
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../../core-plugin-api/src/routing/types.ts","../../frontend-plugin-api/src/routing/RouteRef.ts","../../frontend-plugin-api/src/routing/SubRouteRef.ts","../../frontend-plugin-api/src/routing/ExternalRouteRef.ts","../src/convertLegacyRouteRef.ts","../src/collectLegacyRoutes.tsx","../src/convertLegacyApp.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 { getOrCreateGlobalSingleton } from '@backstage/version-bridge';\n\n/**\n * Catch-all type for route params.\n *\n * @public\n */\nexport type AnyRouteRefParams = { [param in string]: string } | undefined;\n\n/**\n * @deprecated use {@link AnyRouteRefParams} instead\n * @public\n */\nexport type AnyParams = AnyRouteRefParams;\n\n/**\n * Type describing the key type of a route parameter mapping.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamKeys<Params extends AnyParams> = keyof Params extends never\n ? []\n : (keyof Params)[];\n\n/**\n * Optional route params.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type OptionalParams<Params extends { [param in string]: string }> =\n Params[keyof Params] extends never ? undefined : Params;\n\n/**\n * TS magic for handling route parameters.\n *\n * @remarks\n *\n * The extra TS magic here is to require a single params argument if the RouteRef\n * had at least one param defined, but require 0 arguments if there are no params defined.\n * Without this we'd have to pass in empty object to all parameter-less RouteRefs\n * just to make TypeScript happy, or we would have to make the argument optional in\n * which case you might forget to pass it in when it is actually required.\n *\n * @public\n */\nexport type RouteFunc<Params extends AnyParams> = (\n ...[params]: Params extends undefined ? readonly [] : readonly [Params]\n) => string;\n\n/**\n * This symbol is what we use at runtime to determine whether a given object\n * is a type of RouteRef or not. It doesn't work well in TypeScript though since\n * the `unique symbol` will refer to different values between package versions.\n * For that reason we use the marker $$routeRefType to represent the symbol at\n * compile-time instead of using the symbol directly.\n *\n * @internal\n */\nexport const routeRefType: unique symbol = getOrCreateGlobalSingleton<any>(\n 'route-ref-type',\n () => Symbol('route-ref-type'),\n);\n\n/**\n * Absolute route reference.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type RouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'absolute'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n};\n\n/**\n * Descriptor of a route relative to an absolute {@link RouteRef}.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type SubRouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'sub'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n parent: RouteRef;\n\n path: string;\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n};\n\n/**\n * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type ExternalRouteRef<\n Params extends AnyParams = any,\n Optional extends boolean = any,\n> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'external'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n\n optional?: Optional;\n};\n\n/**\n * @internal\n */\nexport type AnyRouteRef =\n | RouteRef<any>\n | SubRouteRef<any>\n | ExternalRouteRef<any, any>;\n\n/**\n * A duplicate of the react-router RouteObject, but with routeRef added\n * @internal\n */\nexport interface BackstageRouteObject {\n caseSensitive: boolean;\n children?: BackstageRouteObject[];\n element: React.ReactNode;\n path: string;\n routeRefs: Set<RouteRef>;\n}\n","/*\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 { describeParentCallSite } from './describeParentCallSite';\nimport { AnyRouteRefParams } from './types';\n\n/**\n * Absolute route reference.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface RouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> {\n readonly $$type: '@backstage/RouteRef';\n readonly T: TParams;\n}\n\n/** @internal */\nexport interface InternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> extends RouteRef<TParams> {\n readonly version: 'v1';\n getParams(): string[];\n getDescription(): string;\n\n setId(id: string): void;\n}\n\n/** @internal */\nexport function toInternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n>(resource: RouteRef<TParams>): InternalRouteRef<TParams> {\n const r = resource as InternalRouteRef<TParams>;\n if (r.$$type !== '@backstage/RouteRef') {\n throw new Error(`Invalid RouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isRouteRef(opaque: { $$type: string }): opaque is RouteRef {\n return opaque.$$type === '@backstage/RouteRef';\n}\n\n/** @internal */\nexport class RouteRefImpl implements InternalRouteRef {\n readonly $$type = '@backstage/RouteRef';\n readonly version = 'v1';\n declare readonly T: never;\n\n #id?: string;\n #params: string[];\n #creationSite: string;\n\n constructor(readonly params: string[] = [], creationSite: string) {\n this.#params = params;\n this.#creationSite = creationSite;\n }\n\n getParams(): string[] {\n return this.#params;\n }\n\n getDescription(): string {\n if (this.#id) {\n return this.#id;\n }\n return `created at '${this.#creationSite}'`;\n }\n\n get #name() {\n return this.$$type.slice('@backstage/'.length);\n }\n\n setId(id: string): void {\n if (!id) {\n throw new Error(`${this.#name} id must be a non-empty string`);\n }\n if (this.#id) {\n throw new Error(\n `${this.#name} was referenced twice as both '${this.#id}' and '${id}'`,\n );\n }\n this.#id = id;\n }\n\n toString(): string {\n return `${this.#name}{${this.getDescription()}}`;\n }\n}\n\n/**\n * Create a {@link RouteRef} from a route descriptor.\n *\n * @param config - Description of the route reference to be created.\n * @public\n */\nexport function createRouteRef<\n // Params is the type that we care about and the one to be embedded in the route ref.\n // For example, given the params ['name', 'kind'], Params will be {name: string, kind: string}\n TParams extends { [param in TParamKeys]: string } | undefined = undefined,\n TParamKeys extends string = string,\n>(config?: {\n /** A list of parameter names that the path that this route ref is bound to must contain */\n readonly params: string extends TParamKeys ? (keyof TParams)[] : TParamKeys[];\n}): RouteRef<\n keyof TParams extends never\n ? undefined\n : string extends TParamKeys\n ? TParams\n : { [param in TParamKeys]: string }\n> {\n return new RouteRefImpl(\n config?.params as string[] | undefined,\n describeParentCallSite(),\n ) as RouteRef<any>;\n}\n","/*\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 { RouteRef, toInternalRouteRef } from './RouteRef';\nimport { AnyRouteRefParams } from './types';\n\n// Should match the pattern in react-router\nconst PARAM_PATTERN = /^\\w+$/;\n\n/**\n * Descriptor of a route relative to an absolute {@link RouteRef}.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface SubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> {\n readonly $$type: '@backstage/SubRouteRef';\n\n readonly T: TParams;\n\n readonly path: string;\n}\n\n/** @internal */\nexport interface InternalSubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> extends SubRouteRef<TParams> {\n readonly version: 'v1';\n\n getParams(): string[];\n getParent(): RouteRef;\n getDescription(): string;\n}\n\n/** @internal */\nexport function toInternalSubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n>(resource: SubRouteRef<TParams>): InternalSubRouteRef<TParams> {\n const r = resource as InternalSubRouteRef<TParams>;\n if (r.$$type !== '@backstage/SubRouteRef') {\n throw new Error(`Invalid SubRouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isSubRouteRef(opaque: {\n $$type: string;\n}): opaque is SubRouteRef {\n return opaque.$$type === '@backstage/SubRouteRef';\n}\n\n/** @internal */\nexport class SubRouteRefImpl<TParams extends AnyRouteRefParams>\n implements SubRouteRef<TParams>\n{\n readonly $$type = '@backstage/SubRouteRef';\n readonly version = 'v1';\n declare readonly T: never;\n\n #params: string[];\n #parent: RouteRef;\n\n constructor(readonly path: string, params: string[], parent: RouteRef) {\n this.#params = params;\n this.#parent = parent;\n }\n\n getParams(): string[] {\n return this.#params;\n }\n\n getParent(): RouteRef {\n return this.#parent;\n }\n\n getDescription(): string {\n const parent = toInternalRouteRef(this.#parent);\n return `at ${this.path} with parent ${parent.getDescription()}`;\n }\n\n toString(): string {\n return `SubRouteRef{${this.getDescription()}}`;\n }\n}\n\n/**\n * Used in {@link PathParams} type declaration.\n * @ignore\n */\ntype ParamPart<S extends string> = S extends `:${infer Param}` ? Param : never;\n\n/**\n * Used in {@link PathParams} type declaration.\n * @ignore\n */\ntype ParamNames<S extends string> = S extends `${infer Part}/${infer Rest}`\n ? ParamPart<Part> | ParamNames<Rest>\n : ParamPart<S>;\n/**\n * This utility type helps us infer a Param object type from a string path\n * For example, `/foo/:bar/:baz` inferred to `{ bar: string, baz: string }`\n * @ignore\n */\ntype PathParams<S extends string> = { [name in ParamNames<S>]: string };\n\n/**\n * Merges a param object type with an optional params type into a params object.\n * @ignore\n */\ntype MergeParams<\n P1 extends { [param in string]: string },\n P2 extends AnyRouteRefParams,\n> = (P1[keyof P1] extends never ? {} : P1) & (P2 extends undefined ? {} : P2);\n\n/**\n * Convert empty params to undefined.\n * @ignore\n */\ntype TrimEmptyParams<Params extends { [param in string]: string }> =\n keyof Params extends never ? undefined : Params;\n\n/**\n * Creates a SubRouteRef type given the desired parameters and parent route parameters.\n * The parameters types are merged together while ensuring that there is no overlap between the two.\n *\n * @ignore\n */\ntype MakeSubRouteRef<\n Params extends { [param in string]: string },\n ParentParams extends AnyRouteRefParams,\n> = keyof Params & keyof ParentParams extends never\n ? SubRouteRef<TrimEmptyParams<MergeParams<Params, ParentParams>>>\n : never;\n\n/**\n * Create a {@link SubRouteRef} from a route descriptor.\n *\n * @param config - Description of the route reference to be created.\n * @public\n */\nexport function createSubRouteRef<\n Path extends string,\n ParentParams extends AnyRouteRefParams = never,\n>(config: {\n path: Path;\n parent: RouteRef<ParentParams>;\n}): MakeSubRouteRef<PathParams<Path>, ParentParams> {\n const { path, parent } = config;\n type Params = PathParams<Path>;\n\n const internalParent = toInternalRouteRef(parent);\n const parentParams = internalParent.getParams();\n\n // Collect runtime parameters from the path, e.g. ['bar', 'baz'] from '/foo/:bar/:baz'\n const pathParams = path\n .split('/')\n .filter(p => p.startsWith(':'))\n .map(p => p.substring(1));\n const params = [...parentParams, ...pathParams];\n\n if (parentParams.some(p => pathParams.includes(p as string))) {\n throw new Error(\n 'SubRouteRef may not have params that overlap with its parent',\n );\n }\n if (!path.startsWith('/')) {\n throw new Error(`SubRouteRef path must start with '/', got '${path}'`);\n }\n if (path.endsWith('/')) {\n throw new Error(`SubRouteRef path must not end with '/', got '${path}'`);\n }\n for (const param of pathParams) {\n if (!PARAM_PATTERN.test(param)) {\n throw new Error(`SubRouteRef path has invalid param, got '${param}'`);\n }\n }\n\n // We ensure that the type of the return type is sane here\n const subRouteRef = new SubRouteRefImpl(\n path,\n params as string[],\n parent,\n ) as SubRouteRef<TrimEmptyParams<MergeParams<Params, ParentParams>>>;\n\n // But skip type checking of the return value itself, because the conditional\n // type checking of the parent parameter overlap is tricky to express.\n return subRouteRef as any;\n}\n","/*\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 { RouteRefImpl } from './RouteRef';\nimport { describeParentCallSite } from './describeParentCallSite';\nimport { AnyRouteRefParams } from './types';\n\n/**\n * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface ExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n TOptional extends boolean = boolean,\n> {\n readonly $$type: '@backstage/ExternalRouteRef';\n readonly T: TParams;\n readonly optional: TOptional;\n}\n\n/** @internal */\nexport interface InternalExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n TOptional extends boolean = boolean,\n> extends ExternalRouteRef<TParams, TOptional> {\n readonly version: 'v1';\n getParams(): string[];\n getDescription(): string;\n\n setId(id: string): void;\n}\n\n/** @internal */\nexport function toInternalExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n TOptional extends boolean = boolean,\n>(\n resource: ExternalRouteRef<TParams, TOptional>,\n): InternalExternalRouteRef<TParams, TOptional> {\n const r = resource as InternalExternalRouteRef<TParams, TOptional>;\n if (r.$$type !== '@backstage/ExternalRouteRef') {\n throw new Error(`Invalid ExternalRouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isExternalRouteRef(opaque: {\n $$type: string;\n}): opaque is ExternalRouteRef {\n return opaque.$$type === '@backstage/ExternalRouteRef';\n}\n\n/** @internal */\nclass ExternalRouteRefImpl\n extends RouteRefImpl\n implements InternalExternalRouteRef\n{\n readonly $$type = '@backstage/ExternalRouteRef' as any;\n\n constructor(\n readonly optional: boolean,\n readonly params: string[] = [],\n creationSite: string,\n ) {\n super(params, creationSite);\n }\n}\n\n/**\n * Creates a route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @param options - Description of the route reference to be created.\n * @public\n */\nexport function createExternalRouteRef<\n TParams extends { [param in TParamKeys]: string } | undefined = undefined,\n TOptional extends boolean = false,\n TParamKeys extends string = string,\n>(options?: {\n /**\n * The parameters that will be provided to the external route reference.\n */\n readonly params?: string extends TParamKeys\n ? (keyof TParams)[]\n : TParamKeys[];\n\n /**\n * Whether or not this route is optional, defaults to false.\n *\n * Optional external routes are not required to be bound in the app, and\n * if they aren't, `useExternalRouteRef` will return `undefined`.\n */\n optional?: TOptional;\n}): ExternalRouteRef<\n keyof TParams extends never\n ? undefined\n : string extends TParamKeys\n ? TParams\n : { [param in TParamKeys]: string },\n TOptional\n> {\n return new ExternalRouteRefImpl(\n Boolean(options?.optional),\n options?.params as string[] | undefined,\n describeParentCallSite(),\n ) as ExternalRouteRef<any, any>;\n}\n","/*\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 as LegacyRouteRef,\n SubRouteRef as LegacySubRouteRef,\n ExternalRouteRef as LegacyExternalRouteRef,\n AnyRouteRefParams,\n} from '@backstage/core-plugin-api';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routeRefType } from '../../core-plugin-api/src/routing/types';\n\nimport {\n RouteRef,\n SubRouteRef,\n ExternalRouteRef,\n createRouteRef,\n createSubRouteRef,\n createExternalRouteRef,\n} from '@backstage/frontend-plugin-api';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalRouteRef } from '../../frontend-plugin-api/src/routing/RouteRef';\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 { toInternalExternalRouteRef } from '../../frontend-plugin-api/src/routing/ExternalRouteRef';\n\n/**\n * A temporary helper to convert a legacy route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacyRouteRef<TParams>,\n): RouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy sub route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createSubRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacySubRouteRef<TParams>,\n): SubRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy external route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<\n TParams extends AnyRouteRefParams,\n TOptional extends boolean,\n>(\n ref: LegacyExternalRouteRef<TParams, TOptional>,\n): ExternalRouteRef<TParams, TOptional>;\n\nexport function convertLegacyRouteRef(\n ref: LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef,\n): RouteRef | SubRouteRef | ExternalRouteRef {\n // Ref has already been converted\n if ('$$type' in ref) {\n return ref as unknown as RouteRef | SubRouteRef | ExternalRouteRef;\n }\n\n const type = (ref as unknown as { [routeRefType]: unknown })[routeRefType];\n\n if (type === 'absolute') {\n const legacyRef = ref as LegacyRouteRef;\n const newRef = toInternalRouteRef(\n createRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/RouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return newRef.getDescription();\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return newRef.toString();\n },\n });\n }\n if (type === 'sub') {\n const legacyRef = ref as LegacySubRouteRef;\n const newRef = toInternalSubRouteRef(\n createSubRouteRef({\n path: legacyRef.path,\n parent: convertLegacyRouteRef(legacyRef.parent),\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/SubRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getParent() {\n return newRef.getParent();\n },\n getDescription() {\n return newRef.getDescription();\n },\n toString() {\n return newRef.toString();\n },\n });\n }\n if (type === 'external') {\n const legacyRef = ref as LegacyExternalRouteRef;\n const newRef = toInternalExternalRouteRef(\n createExternalRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n optional: legacyRef.optional,\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/ExternalRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n optional: newRef.optional,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return newRef.getDescription();\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return newRef.toString();\n },\n });\n }\n\n throw new Error(`Failed to convert legacy route ref, unknown type '${type}'`);\n}\n","/*\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, { ReactNode } from 'react';\nimport {\n Extension,\n createApiExtension,\n createPageExtension,\n createPlugin,\n BackstagePlugin,\n} from '@backstage/frontend-plugin-api';\nimport { Route, Routes } from 'react-router-dom';\nimport {\n BackstagePlugin as LegacyBackstagePlugin,\n RouteRef,\n getComponentData,\n} from '@backstage/core-plugin-api';\nimport { convertLegacyRouteRef } from './convertLegacyRouteRef';\n\n/*\n\n# Legacy interoperability\n\nUse-cases (prioritized):\n 1. Slowly migrate over an existing app to DI, piece by piece\n 2. Use a legacy plugin in a new DI app\n 3. Use DI in an existing legacy app\n\nStarting point: use-case #1\n\nPotential solutions:\n 1. Codemods (we're not considering this for now)\n 2. Legacy apps are migrated bottom-up, i.e. keep legacy root, replace pages with DI\n 3. Legacy apps are migrated top-down i.e. switch out base to DI, legacy adapter allows for usage of existing app structure\n\nChosen path: #3\n\nExisting tasks:\n - Adopters can migrate their existing app gradually (~4)\n - Example-app uses legacy base with DI adapters\n - Create an API that lets you inject DI into existing apps - working assumption is that this is enough\n - Adopters can use legacy plugins in DI through adapters (~8)\n - App-next uses DI base with legacy adapters\n - Create a legacy adapter that is able to take an existing extension tree\n\n*/\n\n/** @public */\nexport function collectLegacyRoutes(\n flatRoutesElement: JSX.Element,\n): BackstagePlugin[] {\n const createdPluginIds = new Map<\n LegacyBackstagePlugin,\n Extension<unknown>[]\n >();\n\n React.Children.forEach(\n flatRoutesElement.props.children,\n (route: ReactNode) => {\n if (!React.isValidElement(route)) {\n return;\n }\n\n // TODO(freben): Handle feature flag and permissions framework wrapper elements\n if (route.type !== Route) {\n return;\n }\n\n const routeElement = route.props.element;\n\n // TODO: to support deeper extension component, e.g. hidden within <RequirePermission>, use https://github.com/backstage/backstage/blob/518a34646b79ec2028cc0ed6bc67d4366c51c4d6/packages/core-app-api/src/routing/collectors.tsx#L69\n const plugin = getComponentData<LegacyBackstagePlugin>(\n routeElement,\n 'core.plugin',\n );\n if (!plugin) {\n return;\n }\n\n const routeRef = getComponentData<RouteRef>(\n routeElement,\n 'core.mountPoint',\n );\n\n const pluginId = plugin.getId();\n\n const detectedExtensions =\n createdPluginIds.get(plugin) ?? new Array<Extension<unknown>>();\n createdPluginIds.set(plugin, detectedExtensions);\n\n const path: string = route.props.path;\n\n detectedExtensions.push(\n createPageExtension({\n id: `plugin.${pluginId}.page${\n detectedExtensions.length ? detectedExtensions.length + 1 : ''\n }`,\n defaultPath: path[0] === '/' ? path.slice(1) : path,\n routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined,\n\n loader: async () =>\n route.props.children ? (\n <Routes>\n <Route path=\"*\" element={routeElement}>\n <Route path=\"*\" element={route.props.children} />\n </Route>\n </Routes>\n ) : (\n routeElement\n ),\n }),\n );\n },\n );\n\n return Array.from(createdPluginIds).map(([plugin, extensions]) =>\n createPlugin({\n id: plugin.getId(),\n extensions: [\n ...extensions,\n ...Array.from(plugin.getApis()).map(factory =>\n createApiExtension({\n factory,\n }),\n ),\n ],\n }),\n );\n}\n","/*\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, {\n Children,\n Fragment,\n ReactElement,\n ReactNode,\n isValidElement,\n} from 'react';\nimport {\n BackstagePlugin,\n ExtensionOverrides,\n coreExtensionData,\n createExtension,\n createExtensionInput,\n createExtensionOverrides,\n} from '@backstage/frontend-plugin-api';\nimport { getComponentData } from '@backstage/core-plugin-api';\nimport { collectLegacyRoutes } from './collectLegacyRoutes';\n\nfunction selectChildren(\n rootNode: ReactNode,\n selector?: (element: ReactElement<{ children?: ReactNode }>) => boolean,\n strictError?: string,\n): Array<ReactElement<{ children?: ReactNode }>> {\n return Children.toArray(rootNode).flatMap(node => {\n if (!isValidElement<{ children?: ReactNode }>(node)) {\n return [];\n }\n\n if (node.type === Fragment) {\n return selectChildren(node.props.children, selector, strictError);\n }\n\n if (selector === undefined || selector(node)) {\n return [node];\n }\n\n if (strictError) {\n throw new Error(strictError);\n }\n\n return selectChildren(node.props.children, selector, strictError);\n });\n}\n\n/** @public */\nexport function convertLegacyApp(\n rootElement: React.JSX.Element,\n): (ExtensionOverrides | BackstagePlugin)[] {\n const appRouterEls = selectChildren(\n rootElement,\n el => getComponentData(el, 'core.type') === 'AppRouter',\n );\n if (appRouterEls.length !== 1) {\n throw new Error(\n \"Failed to convert legacy app, AppRouter element could not been found. Make sure it's at the top level of the App element tree\",\n );\n }\n\n const rootEls = selectChildren(\n appRouterEls[0].props.children,\n el =>\n Boolean(el.props.children) &&\n selectChildren(\n el.props.children,\n innerEl => getComponentData(innerEl, 'core.type') === 'FlatRoutes',\n ).length === 1,\n );\n if (rootEls.length !== 1) {\n throw new Error(\n \"Failed to convert legacy app, Root element containing FlatRoutes could not been found. Make sure it's within the AppRouter element of the App element tree\",\n );\n }\n const [rootEl] = rootEls;\n\n const routesEls = selectChildren(\n rootEls[0].props.children,\n el => getComponentData(el, 'core.type') === 'FlatRoutes',\n );\n if (routesEls.length !== 1) {\n throw new Error(\n 'Unexpectedly failed to find FlatRoutes in app element tree',\n );\n }\n const [routesEl] = routesEls;\n\n const CoreLayoutOverride = createExtension({\n id: 'core.layout',\n attachTo: { id: 'core', input: 'root' },\n inputs: {\n content: createExtensionInput(\n {\n element: coreExtensionData.reactElement,\n },\n { singleton: true },\n ),\n },\n output: {\n element: coreExtensionData.reactElement,\n },\n factory({ inputs }) {\n // Clone the root element, this replaces the FlatRoutes declared in the app with out content input\n return {\n element: React.cloneElement(rootEl, undefined, inputs.content.element),\n };\n },\n });\n const CoreNavOverride = createExtension({\n id: 'core.nav',\n attachTo: { id: 'core.layout', input: 'nav' },\n output: {},\n factory: () => ({}),\n disabled: true,\n });\n\n const collectedRoutes = collectLegacyRoutes(routesEl);\n\n return [\n ...collectedRoutes,\n createExtensionOverrides({\n extensions: [CoreLayoutOverride, CoreNavOverride],\n }),\n ];\n}\n"],"names":[],"mappings":";;;;;;AA4EO,MAAM,YAA8B,GAAA,0BAAA;AAAA,EACzC,gBAAA;AAAA,EACA,MAAM,OAAO,gBAAgB,CAAA;AAC/B,CAAA;;AChCO,SAAS,mBAEd,QAAwD,EAAA;AACxD,EAAA,MAAM,CAAI,GAAA,QAAA,CAAA;AACV,EAAI,IAAA,CAAA,CAAE,WAAW,qBAAuB,EAAA;AACtC,IAAA,MAAM,IAAI,KAAA,CAAM,CAA+B,4BAAA,EAAA,CAAA,CAAE,MAAM,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,GAC5D;AAEA,EAAO,OAAA,CAAA,CAAA;AACT;;ACHO,SAAS,sBAEd,QAA8D,EAAA;AAC9D,EAAA,MAAM,CAAI,GAAA,QAAA,CAAA;AACV,EAAI,IAAA,CAAA,CAAE,WAAW,wBAA0B,EAAA;AACzC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAkC,+BAAA,EAAA,CAAA,CAAE,MAAM,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,GAC/D;AAEA,EAAO,OAAA,CAAA,CAAA;AACT;;ACXO,S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AAQ,EAAE,MAAA,EAAU,EAAA;AAElB,MAAO,OAAA;AAAA,QACL,SAAS,KAAM,CAAA,YAAA,CAAa,QAAQ,KAAW,CAAA,EAAA,MAAA,CAAO,QAAQ,OAAO,CAAA;AAAA,OACvE,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACD,EAAA,MAAM,kBAAkB,eAAgB,CAAA;AAAA,IACtC,EAAI,EAAA,UAAA;AAAA,IACJ,QAAU,EAAA,EAAE,EAAI,EAAA,aAAA,EAAe,OAAO,KAAM,EAAA;AAAA,IAC5C,QAAQ,EAAC;AAAA,IACT,OAAA,EAAS,OAAO,EAAC,CAAA;AAAA,IACjB,QAAU,EAAA,IAAA;AAAA,GACX,CAAA,CAAA;AAED,EAAM,MAAA,eAAA,GAAkB,oBAAoB,QAAQ,CAAA,CAAA;AAEpD,EAAO,OAAA;AAAA,IACL,GAAG,eAAA;AAAA,IACH,wBAAyB,CAAA;AAAA,MACvB,UAAA,EAAY,CAAC,kBAAA,EAAoB,eAAe,CAAA;AAAA,KACjD,CAAA;AAAA,GACH,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../../core-plugin-api/src/routing/types.ts","../../frontend-plugin-api/src/routing/RouteRef.ts","../../frontend-plugin-api/src/routing/SubRouteRef.ts","../../frontend-plugin-api/src/routing/ExternalRouteRef.ts","../src/convertLegacyRouteRef.ts","../src/collectLegacyRoutes.tsx","../src/collectLegacyComponents.tsx","../src/convertLegacyApp.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 { getOrCreateGlobalSingleton } from '@backstage/version-bridge';\n\n/**\n * Catch-all type for route params.\n *\n * @public\n */\nexport type AnyRouteRefParams = { [param in string]: string } | undefined;\n\n/**\n * @deprecated use {@link AnyRouteRefParams} instead\n * @public\n */\nexport type AnyParams = AnyRouteRefParams;\n\n/**\n * Type describing the key type of a route parameter mapping.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type ParamKeys<Params extends AnyParams> = keyof Params extends never\n ? []\n : (keyof Params)[];\n\n/**\n * Optional route params.\n *\n * @public\n * @deprecated this type is deprecated and will be removed in the future\n */\nexport type OptionalParams<Params extends { [param in string]: string }> =\n Params[keyof Params] extends never ? undefined : Params;\n\n/**\n * TS magic for handling route parameters.\n *\n * @remarks\n *\n * The extra TS magic here is to require a single params argument if the RouteRef\n * had at least one param defined, but require 0 arguments if there are no params defined.\n * Without this we'd have to pass in empty object to all parameter-less RouteRefs\n * just to make TypeScript happy, or we would have to make the argument optional in\n * which case you might forget to pass it in when it is actually required.\n *\n * @public\n */\nexport type RouteFunc<Params extends AnyParams> = (\n ...[params]: Params extends undefined ? readonly [] : readonly [Params]\n) => string;\n\n/**\n * This symbol is what we use at runtime to determine whether a given object\n * is a type of RouteRef or not. It doesn't work well in TypeScript though since\n * the `unique symbol` will refer to different values between package versions.\n * For that reason we use the marker $$routeRefType to represent the symbol at\n * compile-time instead of using the symbol directly.\n *\n * @internal\n */\nexport const routeRefType: unique symbol = getOrCreateGlobalSingleton<any>(\n 'route-ref-type',\n () => Symbol('route-ref-type'),\n);\n\n/**\n * Absolute route reference.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type RouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'absolute'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n};\n\n/**\n * Descriptor of a route relative to an absolute {@link RouteRef}.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type SubRouteRef<Params extends AnyParams = any> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'sub'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n parent: RouteRef;\n\n path: string;\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n};\n\n/**\n * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport type ExternalRouteRef<\n Params extends AnyParams = any,\n Optional extends boolean = any,\n> = {\n /** @deprecated access to this property will be removed in the future */\n $$routeRefType: 'external'; // See routeRefType above\n\n /** @deprecated access to this property will be removed in the future */\n params: ParamKeys<Params>;\n\n optional?: Optional;\n};\n\n/**\n * @internal\n */\nexport type AnyRouteRef =\n | RouteRef<any>\n | SubRouteRef<any>\n | ExternalRouteRef<any, any>;\n\n/**\n * A duplicate of the react-router RouteObject, but with routeRef added\n * @internal\n */\nexport interface BackstageRouteObject {\n caseSensitive: boolean;\n children?: BackstageRouteObject[];\n element: React.ReactNode;\n path: string;\n routeRefs: Set<RouteRef>;\n}\n","/*\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 { describeParentCallSite } from './describeParentCallSite';\nimport { AnyRouteRefParams } from './types';\n\n/**\n * Absolute route reference.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface RouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> {\n readonly $$type: '@backstage/RouteRef';\n readonly T: TParams;\n}\n\n/** @internal */\nexport interface InternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> extends RouteRef<TParams> {\n readonly version: 'v1';\n getParams(): string[];\n getDescription(): string;\n\n setId(id: string): void;\n}\n\n/** @internal */\nexport function toInternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n>(resource: RouteRef<TParams>): InternalRouteRef<TParams> {\n const r = resource as InternalRouteRef<TParams>;\n if (r.$$type !== '@backstage/RouteRef') {\n throw new Error(`Invalid RouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isRouteRef(opaque: { $$type: string }): opaque is RouteRef {\n return opaque.$$type === '@backstage/RouteRef';\n}\n\n/** @internal */\nexport class RouteRefImpl implements InternalRouteRef {\n readonly $$type = '@backstage/RouteRef';\n readonly version = 'v1';\n declare readonly T: never;\n\n #id?: string;\n #params: string[];\n #creationSite: string;\n\n constructor(readonly params: string[] = [], creationSite: string) {\n this.#params = params;\n this.#creationSite = creationSite;\n }\n\n getParams(): string[] {\n return this.#params;\n }\n\n getDescription(): string {\n if (this.#id) {\n return this.#id;\n }\n return `created at '${this.#creationSite}'`;\n }\n\n get #name() {\n return this.$$type.slice('@backstage/'.length);\n }\n\n setId(id: string): void {\n if (!id) {\n throw new Error(`${this.#name} id must be a non-empty string`);\n }\n if (this.#id) {\n throw new Error(\n `${this.#name} was referenced twice as both '${this.#id}' and '${id}'`,\n );\n }\n this.#id = id;\n }\n\n toString(): string {\n return `${this.#name}{${this.getDescription()}}`;\n }\n}\n\n/**\n * Create a {@link RouteRef} from a route descriptor.\n *\n * @param config - Description of the route reference to be created.\n * @public\n */\nexport function createRouteRef<\n // Params is the type that we care about and the one to be embedded in the route ref.\n // For example, given the params ['name', 'kind'], Params will be {name: string, kind: string}\n TParams extends { [param in TParamKeys]: string } | undefined = undefined,\n TParamKeys extends string = string,\n>(config?: {\n /** A list of parameter names that the path that this route ref is bound to must contain */\n readonly params: string extends TParamKeys ? (keyof TParams)[] : TParamKeys[];\n}): RouteRef<\n keyof TParams extends never\n ? undefined\n : string extends TParamKeys\n ? TParams\n : { [param in TParamKeys]: string }\n> {\n return new RouteRefImpl(\n config?.params as string[] | undefined,\n describeParentCallSite(),\n ) as RouteRef<any>;\n}\n","/*\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 { RouteRef, toInternalRouteRef } from './RouteRef';\nimport { AnyRouteRefParams } from './types';\n\n// Should match the pattern in react-router\nconst PARAM_PATTERN = /^\\w+$/;\n\n/**\n * Descriptor of a route relative to an absolute {@link RouteRef}.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface SubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> {\n readonly $$type: '@backstage/SubRouteRef';\n\n readonly T: TParams;\n\n readonly path: string;\n}\n\n/** @internal */\nexport interface InternalSubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n> extends SubRouteRef<TParams> {\n readonly version: 'v1';\n\n getParams(): string[];\n getParent(): RouteRef;\n getDescription(): string;\n}\n\n/** @internal */\nexport function toInternalSubRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n>(resource: SubRouteRef<TParams>): InternalSubRouteRef<TParams> {\n const r = resource as InternalSubRouteRef<TParams>;\n if (r.$$type !== '@backstage/SubRouteRef') {\n throw new Error(`Invalid SubRouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isSubRouteRef(opaque: {\n $$type: string;\n}): opaque is SubRouteRef {\n return opaque.$$type === '@backstage/SubRouteRef';\n}\n\n/** @internal */\nexport class SubRouteRefImpl<TParams extends AnyRouteRefParams>\n implements SubRouteRef<TParams>\n{\n readonly $$type = '@backstage/SubRouteRef';\n readonly version = 'v1';\n declare readonly T: never;\n\n #params: string[];\n #parent: RouteRef;\n\n constructor(readonly path: string, params: string[], parent: RouteRef) {\n this.#params = params;\n this.#parent = parent;\n }\n\n getParams(): string[] {\n return this.#params;\n }\n\n getParent(): RouteRef {\n return this.#parent;\n }\n\n getDescription(): string {\n const parent = toInternalRouteRef(this.#parent);\n return `at ${this.path} with parent ${parent.getDescription()}`;\n }\n\n toString(): string {\n return `SubRouteRef{${this.getDescription()}}`;\n }\n}\n\n/**\n * Used in {@link PathParams} type declaration.\n * @ignore\n */\ntype ParamPart<S extends string> = S extends `:${infer Param}` ? Param : never;\n\n/**\n * Used in {@link PathParams} type declaration.\n * @ignore\n */\ntype ParamNames<S extends string> = S extends `${infer Part}/${infer Rest}`\n ? ParamPart<Part> | ParamNames<Rest>\n : ParamPart<S>;\n/**\n * This utility type helps us infer a Param object type from a string path\n * For example, `/foo/:bar/:baz` inferred to `{ bar: string, baz: string }`\n * @ignore\n */\ntype PathParams<S extends string> = { [name in ParamNames<S>]: string };\n\n/**\n * Merges a param object type with an optional params type into a params object.\n * @ignore\n */\ntype MergeParams<\n P1 extends { [param in string]: string },\n P2 extends AnyRouteRefParams,\n> = (P1[keyof P1] extends never ? {} : P1) & (P2 extends undefined ? {} : P2);\n\n/**\n * Convert empty params to undefined.\n * @ignore\n */\ntype TrimEmptyParams<Params extends { [param in string]: string }> =\n keyof Params extends never ? undefined : Params;\n\n/**\n * Creates a SubRouteRef type given the desired parameters and parent route parameters.\n * The parameters types are merged together while ensuring that there is no overlap between the two.\n *\n * @ignore\n */\ntype MakeSubRouteRef<\n Params extends { [param in string]: string },\n ParentParams extends AnyRouteRefParams,\n> = keyof Params & keyof ParentParams extends never\n ? SubRouteRef<TrimEmptyParams<MergeParams<Params, ParentParams>>>\n : never;\n\n/**\n * Create a {@link SubRouteRef} from a route descriptor.\n *\n * @param config - Description of the route reference to be created.\n * @public\n */\nexport function createSubRouteRef<\n Path extends string,\n ParentParams extends AnyRouteRefParams = never,\n>(config: {\n path: Path;\n parent: RouteRef<ParentParams>;\n}): MakeSubRouteRef<PathParams<Path>, ParentParams> {\n const { path, parent } = config;\n type Params = PathParams<Path>;\n\n const internalParent = toInternalRouteRef(parent);\n const parentParams = internalParent.getParams();\n\n // Collect runtime parameters from the path, e.g. ['bar', 'baz'] from '/foo/:bar/:baz'\n const pathParams = path\n .split('/')\n .filter(p => p.startsWith(':'))\n .map(p => p.substring(1));\n const params = [...parentParams, ...pathParams];\n\n if (parentParams.some(p => pathParams.includes(p as string))) {\n throw new Error(\n 'SubRouteRef may not have params that overlap with its parent',\n );\n }\n if (!path.startsWith('/')) {\n throw new Error(`SubRouteRef path must start with '/', got '${path}'`);\n }\n if (path.endsWith('/')) {\n throw new Error(`SubRouteRef path must not end with '/', got '${path}'`);\n }\n for (const param of pathParams) {\n if (!PARAM_PATTERN.test(param)) {\n throw new Error(`SubRouteRef path has invalid param, got '${param}'`);\n }\n }\n\n // We ensure that the type of the return type is sane here\n const subRouteRef = new SubRouteRefImpl(\n path,\n params as string[],\n parent,\n ) as SubRouteRef<TrimEmptyParams<MergeParams<Params, ParentParams>>>;\n\n // But skip type checking of the return value itself, because the conditional\n // type checking of the parent parameter overlap is tricky to express.\n return subRouteRef as any;\n}\n","/*\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 { RouteRefImpl } from './RouteRef';\nimport { describeParentCallSite } from './describeParentCallSite';\nimport { AnyRouteRefParams } from './types';\n\n/**\n * Route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @public\n */\nexport interface ExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n TOptional extends boolean = boolean,\n> {\n readonly $$type: '@backstage/ExternalRouteRef';\n readonly T: TParams;\n readonly optional: TOptional;\n}\n\n/** @internal */\nexport interface InternalExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n TOptional extends boolean = boolean,\n> extends ExternalRouteRef<TParams, TOptional> {\n readonly version: 'v1';\n getParams(): string[];\n getDescription(): string;\n\n setId(id: string): void;\n}\n\n/** @internal */\nexport function toInternalExternalRouteRef<\n TParams extends AnyRouteRefParams = AnyRouteRefParams,\n TOptional extends boolean = boolean,\n>(\n resource: ExternalRouteRef<TParams, TOptional>,\n): InternalExternalRouteRef<TParams, TOptional> {\n const r = resource as InternalExternalRouteRef<TParams, TOptional>;\n if (r.$$type !== '@backstage/ExternalRouteRef') {\n throw new Error(`Invalid ExternalRouteRef, bad type '${r.$$type}'`);\n }\n\n return r;\n}\n\n/** @internal */\nexport function isExternalRouteRef(opaque: {\n $$type: string;\n}): opaque is ExternalRouteRef {\n return opaque.$$type === '@backstage/ExternalRouteRef';\n}\n\n/** @internal */\nclass ExternalRouteRefImpl\n extends RouteRefImpl\n implements InternalExternalRouteRef\n{\n readonly $$type = '@backstage/ExternalRouteRef' as any;\n\n constructor(\n readonly optional: boolean,\n readonly params: string[] = [],\n creationSite: string,\n ) {\n super(params, creationSite);\n }\n}\n\n/**\n * Creates a route descriptor, to be later bound to a concrete route by the app. Used to implement cross-plugin route references.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}.\n *\n * @param options - Description of the route reference to be created.\n * @public\n */\nexport function createExternalRouteRef<\n TParams extends { [param in TParamKeys]: string } | undefined = undefined,\n TOptional extends boolean = false,\n TParamKeys extends string = string,\n>(options?: {\n /**\n * The parameters that will be provided to the external route reference.\n */\n readonly params?: string extends TParamKeys\n ? (keyof TParams)[]\n : TParamKeys[];\n\n /**\n * Whether or not this route is optional, defaults to false.\n *\n * Optional external routes are not required to be bound in the app, and\n * if they aren't, `useExternalRouteRef` will return `undefined`.\n */\n optional?: TOptional;\n}): ExternalRouteRef<\n keyof TParams extends never\n ? undefined\n : string extends TParamKeys\n ? TParams\n : { [param in TParamKeys]: string },\n TOptional\n> {\n return new ExternalRouteRefImpl(\n Boolean(options?.optional),\n options?.params as string[] | undefined,\n describeParentCallSite(),\n ) as ExternalRouteRef<any, any>;\n}\n","/*\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 as LegacyRouteRef,\n SubRouteRef as LegacySubRouteRef,\n ExternalRouteRef as LegacyExternalRouteRef,\n AnyRouteRefParams,\n} from '@backstage/core-plugin-api';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routeRefType } from '../../core-plugin-api/src/routing/types';\n\nimport {\n RouteRef,\n SubRouteRef,\n ExternalRouteRef,\n createRouteRef,\n createSubRouteRef,\n createExternalRouteRef,\n} from '@backstage/frontend-plugin-api';\n\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { toInternalRouteRef } from '../../frontend-plugin-api/src/routing/RouteRef';\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 { toInternalExternalRouteRef } from '../../frontend-plugin-api/src/routing/ExternalRouteRef';\n\n/**\n * A temporary helper to convert a legacy route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacyRouteRef<TParams>,\n): RouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy sub route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createSubRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<TParams extends AnyRouteRefParams>(\n ref: LegacySubRouteRef<TParams>,\n): SubRouteRef<TParams>;\n\n/**\n * A temporary helper to convert a legacy external route ref to the new system.\n *\n * @public\n * @remarks\n *\n * In the future the legacy createExternalRouteRef will instead create refs compatible with both systems.\n */\nexport function convertLegacyRouteRef<\n TParams extends AnyRouteRefParams,\n TOptional extends boolean,\n>(\n ref: LegacyExternalRouteRef<TParams, TOptional>,\n): ExternalRouteRef<TParams, TOptional>;\n\nexport function convertLegacyRouteRef(\n ref: LegacyRouteRef | LegacySubRouteRef | LegacyExternalRouteRef,\n): RouteRef | SubRouteRef | ExternalRouteRef {\n // Ref has already been converted\n if ('$$type' in ref) {\n return ref as unknown as RouteRef | SubRouteRef | ExternalRouteRef;\n }\n\n const type = (ref as unknown as { [routeRefType]: unknown })[routeRefType];\n\n if (type === 'absolute') {\n const legacyRef = ref as LegacyRouteRef;\n const newRef = toInternalRouteRef(\n createRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/RouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return newRef.getDescription();\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return newRef.toString();\n },\n });\n }\n if (type === 'sub') {\n const legacyRef = ref as LegacySubRouteRef;\n const newRef = toInternalSubRouteRef(\n createSubRouteRef({\n path: legacyRef.path,\n parent: convertLegacyRouteRef(legacyRef.parent),\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/SubRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n getParams() {\n return newRef.getParams();\n },\n getParent() {\n return newRef.getParent();\n },\n getDescription() {\n return newRef.getDescription();\n },\n toString() {\n return newRef.toString();\n },\n });\n }\n if (type === 'external') {\n const legacyRef = ref as LegacyExternalRouteRef;\n const newRef = toInternalExternalRouteRef(\n createExternalRouteRef<{ [key in string]: string }>({\n params: legacyRef.params as string[],\n optional: legacyRef.optional,\n }),\n );\n return Object.assign(legacyRef, {\n $$type: '@backstage/ExternalRouteRef' as const,\n version: 'v1',\n T: newRef.T,\n optional: newRef.optional,\n getParams() {\n return newRef.getParams();\n },\n getDescription() {\n return newRef.getDescription();\n },\n setId(id: string) {\n newRef.setId(id);\n },\n toString() {\n return newRef.toString();\n },\n });\n }\n\n throw new Error(`Failed to convert legacy route ref, unknown type '${type}'`);\n}\n","/*\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, { ReactNode } from 'react';\nimport {\n Extension,\n createApiExtension,\n createPageExtension,\n createPlugin,\n BackstagePlugin,\n} from '@backstage/frontend-plugin-api';\nimport { Route, Routes } from 'react-router-dom';\nimport {\n BackstagePlugin as LegacyBackstagePlugin,\n RouteRef,\n getComponentData,\n} from '@backstage/core-plugin-api';\nimport { convertLegacyRouteRef } from './convertLegacyRouteRef';\n\n/*\n\n# Legacy interoperability\n\nUse-cases (prioritized):\n 1. Slowly migrate over an existing app to DI, piece by piece\n 2. Use a legacy plugin in a new DI app\n 3. Use DI in an existing legacy app\n\nStarting point: use-case #1\n\nPotential solutions:\n 1. Codemods (we're not considering this for now)\n 2. Legacy apps are migrated bottom-up, i.e. keep legacy root, replace pages with DI\n 3. Legacy apps are migrated top-down i.e. switch out base to DI, legacy adapter allows for usage of existing app structure\n\nChosen path: #3\n\nExisting tasks:\n - Adopters can migrate their existing app gradually (~4)\n - Example-app uses legacy base with DI adapters\n - Create an API that lets you inject DI into existing apps - working assumption is that this is enough\n - Adopters can use legacy plugins in DI through adapters (~8)\n - App-next uses DI base with legacy adapters\n - Create a legacy adapter that is able to take an existing extension tree\n\n*/\n\n/** @public */\nexport function collectLegacyRoutes(\n flatRoutesElement: JSX.Element,\n): BackstagePlugin[] {\n const createdPluginIds = new Map<\n LegacyBackstagePlugin,\n Extension<unknown>[]\n >();\n\n React.Children.forEach(\n flatRoutesElement.props.children,\n (route: ReactNode) => {\n if (!React.isValidElement(route)) {\n return;\n }\n\n // TODO(freben): Handle feature flag and permissions framework wrapper elements\n if (route.type !== Route) {\n return;\n }\n\n const routeElement = route.props.element;\n\n // TODO: to support deeper extension component, e.g. hidden within <RequirePermission>, use https://github.com/backstage/backstage/blob/518a34646b79ec2028cc0ed6bc67d4366c51c4d6/packages/core-app-api/src/routing/collectors.tsx#L69\n const plugin = getComponentData<LegacyBackstagePlugin>(\n routeElement,\n 'core.plugin',\n );\n if (!plugin) {\n return;\n }\n\n const routeRef = getComponentData<RouteRef>(\n routeElement,\n 'core.mountPoint',\n );\n\n const pluginId = plugin.getId();\n\n const detectedExtensions =\n createdPluginIds.get(plugin) ?? new Array<Extension<unknown>>();\n createdPluginIds.set(plugin, detectedExtensions);\n\n const path: string = route.props.path;\n\n detectedExtensions.push(\n createPageExtension({\n id: `plugin.${pluginId}.page${\n detectedExtensions.length ? detectedExtensions.length + 1 : ''\n }`,\n defaultPath: path[0] === '/' ? path.slice(1) : path,\n routeRef: routeRef ? convertLegacyRouteRef(routeRef) : undefined,\n\n loader: async () =>\n route.props.children ? (\n <Routes>\n <Route path=\"*\" element={routeElement}>\n <Route path=\"*\" element={route.props.children} />\n </Route>\n </Routes>\n ) : (\n routeElement\n ),\n }),\n );\n },\n );\n\n return Array.from(createdPluginIds).map(([plugin, extensions]) =>\n createPlugin({\n id: plugin.getId(),\n extensions: [\n ...extensions,\n ...Array.from(plugin.getApis()).map(factory =>\n createApiExtension({\n factory,\n }),\n ),\n ],\n }),\n );\n}\n","/*\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 Extension,\n ComponentRef,\n createComponentExtension,\n coreComponentsRefs,\n} from '@backstage/frontend-plugin-api';\nimport { AppComponents } from '@backstage/core-plugin-api';\n\ntype ComponentTypes<T = AppComponents> = T[keyof T];\n\nconst refs: Record<string, ComponentRef<ComponentTypes>> = {\n Progress: coreComponentsRefs.progress,\n BootErrorPage: coreComponentsRefs.bootErrorPage,\n NotFoundErrorPage: coreComponentsRefs.notFoundErrorPage,\n ErrorBoundaryFallback: coreComponentsRefs.errorBoundaryFallback,\n};\n\n/** @public */\nexport function collectLegacyComponents(components: Partial<AppComponents>) {\n return Object.entries(components).reduce<Extension<unknown>[]>(\n (extensions, [name, component]) => {\n const ref = refs[name];\n return ref\n ? extensions.concat(\n createComponentExtension({\n ref,\n component: { sync: () => component },\n }),\n )\n : extensions;\n },\n [],\n );\n}\n","/*\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, {\n Children,\n Fragment,\n ReactElement,\n ReactNode,\n isValidElement,\n} from 'react';\nimport {\n BackstagePlugin,\n ExtensionOverrides,\n coreExtensionData,\n createExtension,\n createExtensionInput,\n createExtensionOverrides,\n} from '@backstage/frontend-plugin-api';\nimport { getComponentData } from '@backstage/core-plugin-api';\nimport { collectLegacyRoutes } from './collectLegacyRoutes';\n\nfunction selectChildren(\n rootNode: ReactNode,\n selector?: (element: ReactElement<{ children?: ReactNode }>) => boolean,\n strictError?: string,\n): Array<ReactElement<{ children?: ReactNode }>> {\n return Children.toArray(rootNode).flatMap(node => {\n if (!isValidElement<{ children?: ReactNode }>(node)) {\n return [];\n }\n\n if (node.type === Fragment) {\n return selectChildren(node.props.children, selector, strictError);\n }\n\n if (selector === undefined || selector(node)) {\n return [node];\n }\n\n if (strictError) {\n throw new Error(strictError);\n }\n\n return selectChildren(node.props.children, selector, strictError);\n });\n}\n\n/** @public */\nexport function convertLegacyApp(\n rootElement: React.JSX.Element,\n): (ExtensionOverrides | BackstagePlugin)[] {\n const appRouterEls = selectChildren(\n rootElement,\n el => getComponentData(el, 'core.type') === 'AppRouter',\n );\n if (appRouterEls.length !== 1) {\n throw new Error(\n \"Failed to convert legacy app, AppRouter element could not been found. Make sure it's at the top level of the App element tree\",\n );\n }\n\n const rootEls = selectChildren(\n appRouterEls[0].props.children,\n el =>\n Boolean(el.props.children) &&\n selectChildren(\n el.props.children,\n innerEl => getComponentData(innerEl, 'core.type') === 'FlatRoutes',\n ).length === 1,\n );\n if (rootEls.length !== 1) {\n throw new Error(\n \"Failed to convert legacy app, Root element containing FlatRoutes could not been found. Make sure it's within the AppRouter element of the App element tree\",\n );\n }\n const [rootEl] = rootEls;\n\n const routesEls = selectChildren(\n rootEls[0].props.children,\n el => getComponentData(el, 'core.type') === 'FlatRoutes',\n );\n if (routesEls.length !== 1) {\n throw new Error(\n 'Unexpectedly failed to find FlatRoutes in app element tree',\n );\n }\n const [routesEl] = routesEls;\n\n const CoreLayoutOverride = createExtension({\n id: 'core.layout',\n attachTo: { id: 'core', input: 'root' },\n inputs: {\n content: createExtensionInput(\n {\n element: coreExtensionData.reactElement,\n },\n { singleton: true },\n ),\n },\n output: {\n element: coreExtensionData.reactElement,\n },\n factory({ inputs }) {\n // Clone the root element, this replaces the FlatRoutes declared in the app with out content input\n return {\n element: React.cloneElement(rootEl, undefined, inputs.content.element),\n };\n },\n });\n const CoreNavOverride = createExtension({\n id: 'core.nav',\n attachTo: { id: 'core.layout', input: 'nav' },\n output: {},\n factory: () => ({}),\n disabled: true,\n });\n\n const collectedRoutes = collectLegacyRoutes(routesEl);\n\n return [\n ...collectedRoutes,\n createExtensionOverrides({\n extensions: [CoreLayoutOverride, CoreNavOverride],\n }),\n ];\n}\n"],"names":[],"mappings":";;;;;;AA4EO,MAAM,YAA8B,GAAA,0BAAA;AAAA,EACzC,gBAAA;AAAA,EACA,MAAM,OAAO,gBAAgB,CAAA;AAC/B,CAAA;;AChCO,SAAS,mBAEd,QAAwD,EAAA;AACxD,EAAA,MAAM,CAAI,GAAA,QAAA,CAAA;AACV,EAAI,IAAA,CAAA,CAAE,WAAW,qBAAuB,EAAA;AACtC,IAAA,MAAM,IAAI,KAAA,CAAM,CAA+B,4BAAA,EAAA,CAAA,CAAE,MAAM,CAAG,CAAA,CAAA,CAAA,CAAA;AAAA,GAC5D;AAEA,EAAO,OAAA,CAAA,CAAA;AACT;;ACHO,SAAS,sBAEd,QAA8D,EAAA;AAC9D,EAAA,MAAM,CAAI,GAAA,QAAA,CAAA;AACV,EAAI,IAAA,CAAA,CAAE,WAAW,wBAA0B,EAAA;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CAAA;AAAA,IACjB,QAAU,EAAA,IAAA;AAAA,GACX,CAAA,CAAA;AAED,EAAM,MAAA,eAAA,GAAkB,oBAAoB,QAAQ,CAAA,CAAA;AAEpD,EAAO,OAAA;AAAA,IACL,GAAG,eAAA;AAAA,IACH,wBAAyB,CAAA;AAAA,MACvB,UAAA,EAAY,CAAC,kBAAA,EAAoB,eAAe,CAAA;AAAA,KACjD,CAAA;AAAA,GACH,CAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/core-compat-api",
3
- "version": "0.0.1-next.0",
3
+ "version": "0.0.1-next.1",
4
4
  "main": "dist/index.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -23,9 +23,9 @@
23
23
  "postpack": "backstage-cli package postpack"
24
24
  },
25
25
  "devDependencies": {
26
- "@backstage/cli": "^0.24.1-next.0",
27
- "@backstage/plugin-puppetdb": "^0.1.11-next.0",
28
- "@backstage/plugin-stackstorm": "^0.1.9-next.0",
26
+ "@backstage/cli": "^0.25.0-next.1",
27
+ "@backstage/plugin-puppetdb": "^0.1.11-next.1",
28
+ "@backstage/plugin-stackstorm": "^0.1.9-next.1",
29
29
  "@oriflame/backstage-plugin-score-card": "^0.7.0",
30
30
  "@testing-library/jest-dom": "^6.0.0"
31
31
  },
@@ -37,9 +37,9 @@
37
37
  "react-router-dom": "6.0.0-beta.0 || ^6.3.0"
38
38
  },
39
39
  "dependencies": {
40
- "@backstage/core-app-api": "^1.11.2-next.0",
41
- "@backstage/core-plugin-api": "^1.8.1-next.0",
42
- "@backstage/frontend-plugin-api": "^0.3.1-next.0",
40
+ "@backstage/core-app-api": "^1.11.2-next.1",
41
+ "@backstage/core-plugin-api": "^1.8.1-next.1",
42
+ "@backstage/frontend-plugin-api": "^0.4.0-next.1",
43
43
  "@types/react": "^16.13.1 || ^17.0.0"
44
44
  },
45
45
  "module": "./dist/index.esm.js"