@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.
- package/CHANGELOG.md +245 -0
- package/dist/blueprints/ApiBlueprint.esm.js +8 -5
- package/dist/blueprints/ApiBlueprint.esm.js.map +1 -1
- package/dist/blueprints/AppRootElementBlueprint.esm.js.map +1 -1
- package/dist/blueprints/AppRootWrapperBlueprint.esm.js +5 -4
- package/dist/blueprints/AppRootWrapperBlueprint.esm.js.map +1 -1
- package/dist/blueprints/IconBundleBlueprint.esm.js +1 -1
- package/dist/blueprints/IconBundleBlueprint.esm.js.map +1 -1
- package/dist/blueprints/NavItemBlueprint.esm.js +5 -4
- package/dist/blueprints/NavItemBlueprint.esm.js.map +1 -1
- package/dist/blueprints/NavLogoBlueprint.esm.js +5 -4
- package/dist/blueprints/NavLogoBlueprint.esm.js.map +1 -1
- package/dist/blueprints/PageBlueprint.esm.js +1 -7
- package/dist/blueprints/PageBlueprint.esm.js.map +1 -1
- package/dist/blueprints/RouterBlueprint.esm.js +5 -4
- package/dist/blueprints/RouterBlueprint.esm.js.map +1 -1
- package/dist/blueprints/SignInPageBlueprint.esm.js +5 -4
- package/dist/blueprints/SignInPageBlueprint.esm.js.map +1 -1
- package/dist/blueprints/ThemeBlueprint.esm.js +8 -7
- package/dist/blueprints/ThemeBlueprint.esm.js.map +1 -1
- package/dist/blueprints/TranslationBlueprint.esm.js +6 -5
- package/dist/blueprints/TranslationBlueprint.esm.js.map +1 -1
- package/dist/components/ExtensionBoundary.esm.js +10 -1
- package/dist/components/ExtensionBoundary.esm.js.map +1 -1
- package/dist/extensions/createComponentExtension.esm.js +13 -17
- package/dist/extensions/createComponentExtension.esm.js.map +1 -1
- package/dist/index.d.ts +378 -498
- package/dist/index.esm.js +1 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/schema/createSchemaFromZod.esm.js.map +1 -1
- package/dist/wiring/createExtension.esm.js +21 -27
- package/dist/wiring/createExtension.esm.js.map +1 -1
- package/dist/wiring/createExtensionBlueprint.esm.js +58 -61
- package/dist/wiring/createExtensionBlueprint.esm.js.map +1 -1
- package/dist/wiring/createExtensionDataRef.esm.js.map +1 -1
- package/dist/wiring/createExtensionInput.esm.js +2 -1
- package/dist/wiring/createExtensionInput.esm.js.map +1 -1
- package/dist/wiring/createExtensionOverrides.esm.js.map +1 -1
- package/dist/wiring/{createPlugin.esm.js → createFrontendPlugin.esm.js} +11 -5
- package/dist/wiring/createFrontendPlugin.esm.js.map +1 -0
- package/dist/wiring/resolveExtensionDefinition.esm.js.map +1 -1
- package/package.json +6 -6
- package/dist/extensions/createApiExtension.esm.js +0 -34
- package/dist/extensions/createApiExtension.esm.js.map +0 -1
- package/dist/extensions/createAppRootElementExtension.esm.js +0 -25
- package/dist/extensions/createAppRootElementExtension.esm.js.map +0 -1
- package/dist/extensions/createAppRootWrapperExtension.esm.js +0 -32
- package/dist/extensions/createAppRootWrapperExtension.esm.js.map +0 -1
- package/dist/extensions/createNavItemExtension.esm.js +0 -35
- package/dist/extensions/createNavItemExtension.esm.js.map +0 -1
- package/dist/extensions/createNavLogoExtension.esm.js +0 -30
- package/dist/extensions/createNavLogoExtension.esm.js.map +0 -1
- package/dist/extensions/createPageExtension.esm.js +0 -38
- package/dist/extensions/createPageExtension.esm.js.map +0 -1
- package/dist/extensions/createRouterExtension.esm.js +0 -32
- package/dist/extensions/createRouterExtension.esm.js.map +0 -1
- package/dist/extensions/createSignInPageExtension.esm.js +0 -34
- package/dist/extensions/createSignInPageExtension.esm.js.map +0 -1
- package/dist/extensions/createThemeExtension.esm.js +0 -24
- package/dist/extensions/createThemeExtension.esm.js.map +0 -1
- package/dist/extensions/createTranslationExtension.esm.js +0 -22
- package/dist/extensions/createTranslationExtension.esm.js.map +0 -1
- 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: [
|
|
10
|
+
attachTo: { id: "api:app/translations", input: "translations" },
|
|
11
|
+
output: [translationDataRef],
|
|
11
12
|
dataRefs: {
|
|
12
|
-
translation:
|
|
13
|
+
translation: translationDataRef
|
|
13
14
|
},
|
|
14
15
|
factory: ({
|
|
15
16
|
resource
|
|
16
|
-
}) => [
|
|
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 {
|
|
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":";;;;;;;;;;;;;;
|
|
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;AA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AA,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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
16
|
+
return [
|
|
17
|
+
createComponentExtension.componentDataRef({
|
|
22
18
|
ref: options.ref,
|
|
23
|
-
impl: options.loader.sync(
|
|
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(
|
|
25
|
+
() => lazyLoader().then((Component) => ({
|
|
30
26
|
default: Component
|
|
31
27
|
}))
|
|
32
28
|
);
|
|
33
|
-
return
|
|
34
|
-
|
|
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 {
|
|
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,y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