@backstage/frontend-plugin-api 0.7.0-next.3 → 0.8.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/CHANGELOG.md +245 -0
  2. package/dist/blueprints/ApiBlueprint.esm.js +8 -5
  3. package/dist/blueprints/ApiBlueprint.esm.js.map +1 -1
  4. package/dist/blueprints/AppRootElementBlueprint.esm.js.map +1 -1
  5. package/dist/blueprints/AppRootWrapperBlueprint.esm.js +5 -4
  6. package/dist/blueprints/AppRootWrapperBlueprint.esm.js.map +1 -1
  7. package/dist/blueprints/IconBundleBlueprint.esm.js +1 -1
  8. package/dist/blueprints/IconBundleBlueprint.esm.js.map +1 -1
  9. package/dist/blueprints/NavItemBlueprint.esm.js +5 -4
  10. package/dist/blueprints/NavItemBlueprint.esm.js.map +1 -1
  11. package/dist/blueprints/NavLogoBlueprint.esm.js +5 -4
  12. package/dist/blueprints/NavLogoBlueprint.esm.js.map +1 -1
  13. package/dist/blueprints/PageBlueprint.esm.js +1 -7
  14. package/dist/blueprints/PageBlueprint.esm.js.map +1 -1
  15. package/dist/blueprints/RouterBlueprint.esm.js +5 -4
  16. package/dist/blueprints/RouterBlueprint.esm.js.map +1 -1
  17. package/dist/blueprints/SignInPageBlueprint.esm.js +5 -4
  18. package/dist/blueprints/SignInPageBlueprint.esm.js.map +1 -1
  19. package/dist/blueprints/ThemeBlueprint.esm.js +8 -7
  20. package/dist/blueprints/ThemeBlueprint.esm.js.map +1 -1
  21. package/dist/blueprints/TranslationBlueprint.esm.js +6 -5
  22. package/dist/blueprints/TranslationBlueprint.esm.js.map +1 -1
  23. package/dist/components/ExtensionBoundary.esm.js +10 -1
  24. package/dist/components/ExtensionBoundary.esm.js.map +1 -1
  25. package/dist/extensions/createComponentExtension.esm.js +13 -17
  26. package/dist/extensions/createComponentExtension.esm.js.map +1 -1
  27. package/dist/index.d.ts +378 -498
  28. package/dist/index.esm.js +1 -12
  29. package/dist/index.esm.js.map +1 -1
  30. package/dist/schema/createSchemaFromZod.esm.js.map +1 -1
  31. package/dist/wiring/createExtension.esm.js +21 -27
  32. package/dist/wiring/createExtension.esm.js.map +1 -1
  33. package/dist/wiring/createExtensionBlueprint.esm.js +58 -61
  34. package/dist/wiring/createExtensionBlueprint.esm.js.map +1 -1
  35. package/dist/wiring/createExtensionDataRef.esm.js.map +1 -1
  36. package/dist/wiring/createExtensionInput.esm.js +2 -1
  37. package/dist/wiring/createExtensionInput.esm.js.map +1 -1
  38. package/dist/wiring/createExtensionOverrides.esm.js.map +1 -1
  39. package/dist/wiring/{createPlugin.esm.js → createFrontendPlugin.esm.js} +11 -5
  40. package/dist/wiring/createFrontendPlugin.esm.js.map +1 -0
  41. package/dist/wiring/resolveExtensionDefinition.esm.js.map +1 -1
  42. package/package.json +6 -6
  43. package/dist/extensions/createApiExtension.esm.js +0 -34
  44. package/dist/extensions/createApiExtension.esm.js.map +0 -1
  45. package/dist/extensions/createAppRootElementExtension.esm.js +0 -25
  46. package/dist/extensions/createAppRootElementExtension.esm.js.map +0 -1
  47. package/dist/extensions/createAppRootWrapperExtension.esm.js +0 -32
  48. package/dist/extensions/createAppRootWrapperExtension.esm.js.map +0 -1
  49. package/dist/extensions/createNavItemExtension.esm.js +0 -35
  50. package/dist/extensions/createNavItemExtension.esm.js.map +0 -1
  51. package/dist/extensions/createNavLogoExtension.esm.js +0 -30
  52. package/dist/extensions/createNavLogoExtension.esm.js.map +0 -1
  53. package/dist/extensions/createPageExtension.esm.js +0 -38
  54. package/dist/extensions/createPageExtension.esm.js.map +0 -1
  55. package/dist/extensions/createRouterExtension.esm.js +0 -32
  56. package/dist/extensions/createRouterExtension.esm.js.map +0 -1
  57. package/dist/extensions/createSignInPageExtension.esm.js +0 -34
  58. package/dist/extensions/createSignInPageExtension.esm.js.map +0 -1
  59. package/dist/extensions/createThemeExtension.esm.js +0 -24
  60. package/dist/extensions/createThemeExtension.esm.js.map +0 -1
  61. package/dist/extensions/createTranslationExtension.esm.js +0 -22
  62. package/dist/extensions/createTranslationExtension.esm.js.map +0 -1
  63. package/dist/wiring/createPlugin.esm.js.map +0 -1
@@ -1,19 +1,20 @@
1
1
  import '../wiring/coreExtensionData.esm.js';
2
2
  import 'zod';
3
3
  import 'zod-to-json-schema';
4
+ import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js';
4
5
  import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm.js';
5
- import { createTranslationExtension } from '../extensions/createTranslationExtension.esm.js';
6
6
 
7
+ const translationDataRef = createExtensionDataRef().with({ id: "core.translation.translation" });
7
8
  const TranslationBlueprint = createExtensionBlueprint({
8
9
  kind: "translation",
9
- attachTo: { id: "app", input: "translations" },
10
- output: [createTranslationExtension.translationDataRef],
10
+ attachTo: { id: "api:app/translations", input: "translations" },
11
+ output: [translationDataRef],
11
12
  dataRefs: {
12
- translation: createTranslationExtension.translationDataRef
13
+ translation: translationDataRef
13
14
  },
14
15
  factory: ({
15
16
  resource
16
- }) => [createTranslationExtension.translationDataRef(resource)]
17
+ }) => [translationDataRef(resource)]
17
18
  });
18
19
 
19
20
  export { TranslationBlueprint };
@@ -1 +1 @@
1
- {"version":3,"file":"TranslationBlueprint.esm.js","sources":["../../src/blueprints/TranslationBlueprint.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 { createExtensionBlueprint } from '../wiring';\nimport { createTranslationExtension } from '../extensions/createTranslationExtension';\nimport { TranslationMessages, TranslationResource } from '../translation';\n\n/**\n * Creates an extension that adds translations to your app.\n *\n * @public\n */\nexport const TranslationBlueprint = createExtensionBlueprint({\n kind: 'translation',\n attachTo: { id: 'app', input: 'translations' },\n output: [createTranslationExtension.translationDataRef],\n dataRefs: {\n translation: createTranslationExtension.translationDataRef,\n },\n factory: ({\n resource,\n }: {\n resource: TranslationResource | TranslationMessages;\n }) => [createTranslationExtension.translationDataRef(resource)],\n});\n"],"names":[],"mappings":";;;;;;AAyBO,MAAM,uBAAuB,wBAAyB,CAAA;AAAA,EAC3D,IAAM,EAAA,aAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,cAAe,EAAA;AAAA,EAC7C,MAAA,EAAQ,CAAC,0BAAA,CAA2B,kBAAkB,CAAA;AAAA,EACtD,QAAU,EAAA;AAAA,IACR,aAAa,0BAA2B,CAAA,kBAAA;AAAA,GAC1C;AAAA,EACA,SAAS,CAAC;AAAA,IACR,QAAA;AAAA,GAGI,KAAA,CAAC,0BAA2B,CAAA,kBAAA,CAAmB,QAAQ,CAAC,CAAA;AAChE,CAAC;;;;"}
1
+ {"version":3,"file":"TranslationBlueprint.esm.js","sources":["../../src/blueprints/TranslationBlueprint.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 { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\nimport { TranslationMessages, TranslationResource } from '../translation';\n\nconst translationDataRef = createExtensionDataRef<\n TranslationResource | TranslationMessages\n>().with({ id: 'core.translation.translation' });\n\n/**\n * Creates an extension that adds translations to your app.\n *\n * @public\n */\nexport const TranslationBlueprint = createExtensionBlueprint({\n kind: 'translation',\n attachTo: { id: 'api:app/translations', input: 'translations' },\n output: [translationDataRef],\n dataRefs: {\n translation: translationDataRef,\n },\n factory: ({\n resource,\n }: {\n resource: TranslationResource | TranslationMessages;\n }) => [translationDataRef(resource)],\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,qBAAqB,sBAEzB,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,gCAAgC,CAAA,CAAA;AAOxC,MAAM,uBAAuB,wBAAyB,CAAA;AAAA,EAC3D,IAAM,EAAA,aAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,sBAAA,EAAwB,OAAO,cAAe,EAAA;AAAA,EAC9D,MAAA,EAAQ,CAAC,kBAAkB,CAAA;AAAA,EAC3B,QAAU,EAAA;AAAA,IACR,WAAa,EAAA,kBAAA;AAAA,GACf;AAAA,EACA,SAAS,CAAC;AAAA,IACR,QAAA;AAAA,GAGI,KAAA,CAAC,kBAAmB,CAAA,QAAQ,CAAC,CAAA;AACrC,CAAC;;;;"}
@@ -1,4 +1,4 @@
1
- import React, { Suspense, useEffect } from 'react';
1
+ import React, { Suspense, lazy, useEffect } from 'react';
2
2
  import { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';
3
3
  import { ErrorBoundary } from './ErrorBoundary.esm.js';
4
4
  import { routableExtensionRenderedEvent } from '../core-plugin-api/src/analytics/Tracker.esm.js';
@@ -35,6 +35,15 @@ function ExtensionBoundary(props) {
35
35
  };
36
36
  return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Progress, null) }, /* @__PURE__ */ React.createElement(ErrorBoundary, { plugin, Fallback: fallback }, /* @__PURE__ */ React.createElement(AnalyticsContext, { attributes }, /* @__PURE__ */ React.createElement(RouteTracker, { disableTracking: !(routable ?? doesOutputRoutePath) }, children))));
37
37
  }
38
+ ((ExtensionBoundary2) => {
39
+ function lazy$1(appNode, lazyElement) {
40
+ const ExtensionComponent = lazy(
41
+ () => lazyElement().then((element) => ({ default: () => element }))
42
+ );
43
+ return /* @__PURE__ */ React.createElement(ExtensionBoundary2, { node: appNode }, /* @__PURE__ */ React.createElement(ExtensionComponent, null));
44
+ }
45
+ ExtensionBoundary2.lazy = lazy$1;
46
+ })(ExtensionBoundary || (ExtensionBoundary = {}));
38
47
 
39
48
  export { ExtensionBoundary };
40
49
  //# sourceMappingURL=ExtensionBoundary.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionBoundary.esm.js","sources":["../../src/components/ExtensionBoundary.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, {\n PropsWithChildren,\n ReactNode,\n Suspense,\n useEffect,\n} from 'react';\nimport { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';\nimport { ErrorBoundary } from './ErrorBoundary';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routableExtensionRenderedEvent } from '../../../core-plugin-api/src/analytics/Tracker';\nimport { AppNode, useComponentRef } from '../apis';\nimport { coreComponentRefs } from './coreComponentRefs';\nimport { coreExtensionData } from '../wiring';\n\ntype RouteTrackerProps = PropsWithChildren<{\n disableTracking?: boolean;\n}>;\n\nconst RouteTracker = (props: RouteTrackerProps) => {\n const { disableTracking, children } = props;\n const analytics = useAnalytics();\n\n // This event, never exposed to end-users of the analytics API,\n // helps inform which extension metadata gets associated with a\n // navigation event when the route navigated to is a gathered\n // mountpoint.\n useEffect(() => {\n if (disableTracking) return;\n analytics.captureEvent(routableExtensionRenderedEvent, '');\n }, [analytics, disableTracking]);\n\n return <>{children}</>;\n};\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n node: AppNode;\n /**\n * This explicitly marks the extension as routable for the purpose of\n * capturing analytics events. If not provided, the extension boundary will be\n * marked as routable if it outputs a routePath.\n */\n routable?: boolean;\n children: ReactNode;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n const { node, routable, children } = props;\n\n const doesOutputRoutePath = Boolean(\n node.instance?.getData(coreExtensionData.routePath),\n );\n\n const plugin = node.spec.source;\n const Progress = useComponentRef(coreComponentRefs.progress);\n const fallback = useComponentRef(coreComponentRefs.errorBoundaryFallback);\n\n // Skipping \"routeRef\" attribute in the new system, the extension \"id\" should provide more insight\n const attributes = {\n extensionId: node.spec.id,\n pluginId: node.spec.source?.id ?? 'app',\n };\n\n return (\n <Suspense fallback={<Progress />}>\n <ErrorBoundary plugin={plugin} Fallback={fallback}>\n <AnalyticsContext attributes={attributes}>\n <RouteTracker disableTracking={!(routable ?? doesOutputRoutePath)}>\n {children}\n </RouteTracker>\n </AnalyticsContext>\n </ErrorBoundary>\n </Suspense>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkCA,MAAM,YAAA,GAAe,CAAC,KAA6B,KAAA;AACjD,EAAM,MAAA,EAAE,eAAiB,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AACtC,EAAA,MAAM,YAAY,YAAa,EAAA,CAAA;AAM/B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,eAAiB,EAAA,OAAA;AACrB,IAAU,SAAA,CAAA,YAAA,CAAa,gCAAgC,EAAE,CAAA,CAAA;AAAA,GACxD,EAAA,CAAC,SAAW,EAAA,eAAe,CAAC,CAAA,CAAA;AAE/B,EAAA,iEAAU,QAAS,CAAA,CAAA;AACrB,CAAA,CAAA;AAeO,SAAS,kBAAkB,KAA+B,EAAA;AAC/D,EAAA,MAAM,EAAE,IAAA,EAAM,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AAErC,EAAA,MAAM,mBAAsB,GAAA,OAAA;AAAA,IAC1B,IAAK,CAAA,QAAA,EAAU,OAAQ,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAAA,GACpD,CAAA;AAEA,EAAM,MAAA,MAAA,GAAS,KAAK,IAAK,CAAA,MAAA,CAAA;AACzB,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,QAAQ,CAAA,CAAA;AAC3D,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,qBAAqB,CAAA,CAAA;AAGxE,EAAA,MAAM,UAAa,GAAA;AAAA,IACjB,WAAA,EAAa,KAAK,IAAK,CAAA,EAAA;AAAA,IACvB,QAAU,EAAA,IAAA,CAAK,IAAK,CAAA,MAAA,EAAQ,EAAM,IAAA,KAAA;AAAA,GACpC,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,YAAS,QAAU,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAS,CAC5B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,MAAA,EAAgB,QAAU,EAAA,QAAA,EAAA,sCACtC,gBAAiB,EAAA,EAAA,UAAA,EAAA,kBACf,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,eAAiB,EAAA,EAAE,YAAY,mBAC1C,CAAA,EAAA,EAAA,QACH,CACF,CACF,CACF,CAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"ExtensionBoundary.esm.js","sources":["../../src/components/ExtensionBoundary.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, {\n PropsWithChildren,\n ReactNode,\n Suspense,\n useEffect,\n lazy as reactLazy,\n} from 'react';\nimport { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';\nimport { ErrorBoundary } from './ErrorBoundary';\n// eslint-disable-next-line @backstage/no-relative-monorepo-imports\nimport { routableExtensionRenderedEvent } from '../../../core-plugin-api/src/analytics/Tracker';\nimport { AppNode, useComponentRef } from '../apis';\nimport { coreComponentRefs } from './coreComponentRefs';\nimport { coreExtensionData } from '../wiring';\n\ntype RouteTrackerProps = PropsWithChildren<{\n disableTracking?: boolean;\n}>;\n\nconst RouteTracker = (props: RouteTrackerProps) => {\n const { disableTracking, children } = props;\n const analytics = useAnalytics();\n\n // This event, never exposed to end-users of the analytics API,\n // helps inform which extension metadata gets associated with a\n // navigation event when the route navigated to is a gathered\n // mountpoint.\n useEffect(() => {\n if (disableTracking) return;\n analytics.captureEvent(routableExtensionRenderedEvent, '');\n }, [analytics, disableTracking]);\n\n return <>{children}</>;\n};\n\n/** @public */\nexport interface ExtensionBoundaryProps {\n node: AppNode;\n /**\n * This explicitly marks the extension as routable for the purpose of\n * capturing analytics events. If not provided, the extension boundary will be\n * marked as routable if it outputs a routePath.\n */\n routable?: boolean;\n children: ReactNode;\n}\n\n/** @public */\nexport function ExtensionBoundary(props: ExtensionBoundaryProps) {\n const { node, routable, children } = props;\n\n const doesOutputRoutePath = Boolean(\n node.instance?.getData(coreExtensionData.routePath),\n );\n\n const plugin = node.spec.source;\n const Progress = useComponentRef(coreComponentRefs.progress);\n const fallback = useComponentRef(coreComponentRefs.errorBoundaryFallback);\n\n // Skipping \"routeRef\" attribute in the new system, the extension \"id\" should provide more insight\n const attributes = {\n extensionId: node.spec.id,\n pluginId: node.spec.source?.id ?? 'app',\n };\n\n return (\n <Suspense fallback={<Progress />}>\n <ErrorBoundary plugin={plugin} Fallback={fallback}>\n <AnalyticsContext attributes={attributes}>\n <RouteTracker disableTracking={!(routable ?? doesOutputRoutePath)}>\n {children}\n </RouteTracker>\n </AnalyticsContext>\n </ErrorBoundary>\n </Suspense>\n );\n}\n\n/** @public */\nexport namespace ExtensionBoundary {\n export function lazy(\n appNode: AppNode,\n lazyElement: () => Promise<JSX.Element>,\n ): JSX.Element {\n const ExtensionComponent = reactLazy(() =>\n lazyElement().then(element => ({ default: () => element })),\n );\n return (\n <ExtensionBoundary node={appNode}>\n <ExtensionComponent />\n </ExtensionBoundary>\n );\n }\n}\n"],"names":["ExtensionBoundary","lazy","reactLazy"],"mappings":";;;;;;;;;;;;;;AAmCA,MAAM,YAAA,GAAe,CAAC,KAA6B,KAAA;AACjD,EAAM,MAAA,EAAE,eAAiB,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AACtC,EAAA,MAAM,YAAY,YAAa,EAAA,CAAA;AAM/B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,eAAiB,EAAA,OAAA;AACrB,IAAU,SAAA,CAAA,YAAA,CAAa,gCAAgC,EAAE,CAAA,CAAA;AAAA,GACxD,EAAA,CAAC,SAAW,EAAA,eAAe,CAAC,CAAA,CAAA;AAE/B,EAAA,iEAAU,QAAS,CAAA,CAAA;AACrB,CAAA,CAAA;AAeO,SAAS,kBAAkB,KAA+B,EAAA;AAC/D,EAAA,MAAM,EAAE,IAAA,EAAM,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA,CAAA;AAErC,EAAA,MAAM,mBAAsB,GAAA,OAAA;AAAA,IAC1B,IAAK,CAAA,QAAA,EAAU,OAAQ,CAAA,iBAAA,CAAkB,SAAS,CAAA;AAAA,GACpD,CAAA;AAEA,EAAM,MAAA,MAAA,GAAS,KAAK,IAAK,CAAA,MAAA,CAAA;AACzB,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,QAAQ,CAAA,CAAA;AAC3D,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,qBAAqB,CAAA,CAAA;AAGxE,EAAA,MAAM,UAAa,GAAA;AAAA,IACjB,WAAA,EAAa,KAAK,IAAK,CAAA,EAAA;AAAA,IACvB,QAAU,EAAA,IAAA,CAAK,IAAK,CAAA,MAAA,EAAQ,EAAM,IAAA,KAAA;AAAA,GACpC,CAAA;AAEA,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,YAAS,QAAU,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAS,CAC5B,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,MAAA,EAAgB,QAAU,EAAA,QAAA,EAAA,sCACtC,gBAAiB,EAAA,EAAA,UAAA,EAAA,kBACf,KAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAa,eAAiB,EAAA,EAAE,YAAY,mBAC1C,CAAA,EAAA,EAAA,QACH,CACF,CACF,CACF,CAAA,CAAA;AAEJ,CAAA;AAAA,CAGO,CAAUA,kBAAV,KAAA;AACE,EAAS,SAAAC,MAAA,CACd,SACA,WACa,EAAA;AACb,IAAA,MAAM,kBAAqB,GAAAC,IAAA;AAAA,MAAU,MACnC,aAAc,CAAA,IAAA,CAAK,cAAY,EAAE,OAAA,EAAS,MAAM,OAAA,EAAU,CAAA,CAAA;AAAA,KAC5D,CAAA;AACA,IAAA,2CACGF,kBAAA,EAAA,EAAkB,MAAM,OACvB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,wBAAmB,CACtB,CAAA,CAAA;AAAA,GAEJ;AAZO,EAAAA,kBAAS,CAAA,IAAA,GAAAC,MAAA,CAAA;AAAA,CADD,EAAA,iBAAA,KAAA,iBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -8,34 +8,30 @@ function createComponentExtension(options) {
8
8
  kind: "component",
9
9
  namespace: options.ref.id,
10
10
  name: options.name,
11
- attachTo: { id: "app", input: "components" },
12
- inputs: options.inputs,
11
+ attachTo: { id: "api:app/components", input: "components" },
13
12
  disabled: options.disabled,
14
- configSchema: options.configSchema,
15
- output: {
16
- component: createComponentExtension.componentDataRef
17
- },
18
- factory({ config, inputs }) {
13
+ output: [createComponentExtension.componentDataRef],
14
+ factory() {
19
15
  if ("sync" in options.loader) {
20
- return {
21
- component: {
16
+ return [
17
+ createComponentExtension.componentDataRef({
22
18
  ref: options.ref,
23
- impl: options.loader.sync({ config, inputs })
24
- }
25
- };
19
+ impl: options.loader.sync()
20
+ })
21
+ ];
26
22
  }
27
23
  const lazyLoader = options.loader.lazy;
28
24
  const ExtensionComponent = lazy(
29
- () => lazyLoader({ config, inputs }).then((Component) => ({
25
+ () => lazyLoader().then((Component) => ({
30
26
  default: Component
31
27
  }))
32
28
  );
33
- return {
34
- component: {
29
+ return [
30
+ createComponentExtension.componentDataRef({
35
31
  ref: options.ref,
36
32
  impl: ExtensionComponent
37
- }
38
- };
33
+ })
34
+ ];
39
35
  }
40
36
  });
41
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"createComponentExtension.esm.js","sources":["../../src/extensions/createComponentExtension.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 { lazy, ComponentType } from 'react';\nimport {\n AnyExtensionInputMap,\n ResolvedExtensionInputs,\n createExtension,\n createExtensionDataRef,\n} from '../wiring';\nimport { Expand } from '../types';\nimport { PortableSchema } from '../schema';\nimport { ComponentRef } from '../components';\n\n/** @public */\nexport function createComponentExtension<\n TProps extends {},\n TConfig extends {},\n TInputs extends AnyExtensionInputMap,\n>(options: {\n ref: ComponentRef<TProps>;\n name?: string;\n disabled?: boolean;\n inputs?: TInputs;\n configSchema?: PortableSchema<TConfig>;\n loader:\n | {\n lazy: (values: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => Promise<ComponentType<TProps>>;\n }\n | {\n sync: (values: {\n config: TConfig;\n inputs: Expand<ResolvedExtensionInputs<TInputs>>;\n }) => ComponentType<TProps>;\n };\n}) {\n return createExtension({\n kind: 'component',\n namespace: options.ref.id,\n name: options.name,\n attachTo: { id: 'app', input: 'components' },\n inputs: options.inputs,\n disabled: options.disabled,\n configSchema: options.configSchema,\n output: {\n component: createComponentExtension.componentDataRef,\n },\n factory({ config, inputs }) {\n if ('sync' in options.loader) {\n return {\n component: {\n ref: options.ref,\n impl: options.loader.sync({ config, inputs }) as ComponentType,\n },\n };\n }\n const lazyLoader = options.loader.lazy;\n const ExtensionComponent = lazy(() =>\n lazyLoader({ config, inputs }).then(Component => ({\n default: Component,\n })),\n ) as unknown as ComponentType;\n\n return {\n component: {\n ref: options.ref,\n impl: ExtensionComponent,\n },\n };\n },\n });\n}\n\n/** @public */\nexport namespace createComponentExtension {\n export const componentDataRef = createExtensionDataRef<{\n ref: ComponentRef;\n impl: ComponentType;\n }>().with({ id: 'core.component.component' });\n}\n"],"names":["createComponentExtension"],"mappings":";;;;;AA4BO,SAAS,yBAId,OAmBC,EAAA;AACD,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,WAAA;AAAA,IACN,SAAA,EAAW,QAAQ,GAAI,CAAA,EAAA;AAAA,IACvB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,QAAU,EAAA,EAAE,EAAI,EAAA,KAAA,EAAO,OAAO,YAAa,EAAA;AAAA,IAC3C,QAAQ,OAAQ,CAAA,MAAA;AAAA,IAChB,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,cAAc,OAAQ,CAAA,YAAA;AAAA,IACtB,MAAQ,EAAA;AAAA,MACN,WAAW,wBAAyB,CAAA,gBAAA;AAAA,KACtC;AAAA,IACA,OAAQ,CAAA,EAAE,MAAQ,EAAA,MAAA,EAAU,EAAA;AAC1B,MAAI,IAAA,MAAA,IAAU,QAAQ,MAAQ,EAAA;AAC5B,QAAO,OAAA;AAAA,UACL,SAAW,EAAA;AAAA,YACT,KAAK,OAAQ,CAAA,GAAA;AAAA,YACb,MAAM,OAAQ,CAAA,MAAA,CAAO,KAAK,EAAE,MAAA,EAAQ,QAAQ,CAAA;AAAA,WAC9C;AAAA,SACF,CAAA;AAAA,OACF;AACA,MAAM,MAAA,UAAA,GAAa,QAAQ,MAAO,CAAA,IAAA,CAAA;AAClC,MAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,QAAK,MAC9B,WAAW,EAAE,MAAA,EAAQ,QAAQ,CAAA,CAAE,KAAK,CAAc,SAAA,MAAA;AAAA,UAChD,OAAS,EAAA,SAAA;AAAA,SACT,CAAA,CAAA;AAAA,OACJ,CAAA;AAEA,MAAO,OAAA;AAAA,QACL,SAAW,EAAA;AAAA,UACT,KAAK,OAAQ,CAAA,GAAA;AAAA,UACb,IAAM,EAAA,kBAAA;AAAA,SACR;AAAA,OACF,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,yBAAV,KAAA;AACE,EAAMA,yBAAAA,CAAA,mBAAmB,sBAG7B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,4BAA4B,CAAA,CAAA;AAAA,CAJ7B,EAAA,wBAAA,KAAA,wBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"createComponentExtension.esm.js","sources":["../../src/extensions/createComponentExtension.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 { lazy, ComponentType } from 'react';\nimport { createExtension, createExtensionDataRef } from '../wiring';\nimport { ComponentRef } from '../components';\n\n/** @public */\nexport function createComponentExtension<TProps extends {}>(options: {\n ref: ComponentRef<TProps>;\n name?: string;\n disabled?: boolean;\n loader:\n | {\n lazy: () => Promise<ComponentType<TProps>>;\n }\n | {\n sync: () => ComponentType<TProps>;\n };\n}) {\n return createExtension({\n kind: 'component',\n namespace: options.ref.id,\n name: options.name,\n attachTo: { id: 'api:app/components', input: 'components' },\n disabled: options.disabled,\n output: [createComponentExtension.componentDataRef],\n factory() {\n if ('sync' in options.loader) {\n return [\n createComponentExtension.componentDataRef({\n ref: options.ref,\n impl: options.loader.sync() as ComponentType,\n }),\n ];\n }\n const lazyLoader = options.loader.lazy;\n const ExtensionComponent = lazy(() =>\n lazyLoader().then(Component => ({\n default: Component,\n })),\n ) as unknown as ComponentType;\n\n return [\n createComponentExtension.componentDataRef({\n ref: options.ref,\n impl: ExtensionComponent,\n }),\n ];\n },\n });\n}\n\n/** @public */\nexport namespace createComponentExtension {\n export const componentDataRef = createExtensionDataRef<{\n ref: ComponentRef;\n impl: ComponentType;\n }>().with({ id: 'core.component.component' });\n}\n"],"names":["createComponentExtension"],"mappings":";;;;;AAqBO,SAAS,yBAA4C,OAWzD,EAAA;AACD,EAAA,OAAO,eAAgB,CAAA;AAAA,IACrB,IAAM,EAAA,WAAA;AAAA,IACN,SAAA,EAAW,QAAQ,GAAI,CAAA,EAAA;AAAA,IACvB,MAAM,OAAQ,CAAA,IAAA;AAAA,IACd,QAAU,EAAA,EAAE,EAAI,EAAA,oBAAA,EAAsB,OAAO,YAAa,EAAA;AAAA,IAC1D,UAAU,OAAQ,CAAA,QAAA;AAAA,IAClB,MAAA,EAAQ,CAAC,wBAAA,CAAyB,gBAAgB,CAAA;AAAA,IAClD,OAAU,GAAA;AACR,MAAI,IAAA,MAAA,IAAU,QAAQ,MAAQ,EAAA;AAC5B,QAAO,OAAA;AAAA,UACL,yBAAyB,gBAAiB,CAAA;AAAA,YACxC,KAAK,OAAQ,CAAA,GAAA;AAAA,YACb,IAAA,EAAM,OAAQ,CAAA,MAAA,CAAO,IAAK,EAAA;AAAA,WAC3B,CAAA;AAAA,SACH,CAAA;AAAA,OACF;AACA,MAAM,MAAA,UAAA,GAAa,QAAQ,MAAO,CAAA,IAAA,CAAA;AAClC,MAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,QAAK,MAC9B,UAAA,EAAa,CAAA,IAAA,CAAK,CAAc,SAAA,MAAA;AAAA,UAC9B,OAAS,EAAA,SAAA;AAAA,SACT,CAAA,CAAA;AAAA,OACJ,CAAA;AAEA,MAAO,OAAA;AAAA,QACL,yBAAyB,gBAAiB,CAAA;AAAA,UACxC,KAAK,OAAQ,CAAA,GAAA;AAAA,UACb,IAAM,EAAA,kBAAA;AAAA,SACP,CAAA;AAAA,OACH,CAAA;AAAA,KACF;AAAA,GACD,CAAA,CAAA;AACH,CAAA;AAAA,CAGO,CAAUA,yBAAV,KAAA;AACE,EAAMA,yBAAAA,CAAA,mBAAmB,sBAG7B,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,4BAA4B,CAAA,CAAA;AAAA,CAJ7B,EAAA,wBAAA,KAAA,wBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}