@backstage/frontend-plugin-api 0.10.1-next.0 → 0.10.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 +28 -0
- package/dist/analytics/AnalyticsContext.esm.js +3 -2
- package/dist/analytics/AnalyticsContext.esm.js.map +1 -1
- package/dist/blueprints/AppRootWrapperBlueprint.esm.js +2 -2
- package/dist/blueprints/AppRootWrapperBlueprint.esm.js.map +1 -1
- package/dist/blueprints/SignInPageBlueprint.esm.js +3 -2
- package/dist/blueprints/SignInPageBlueprint.esm.js.map +1 -1
- package/dist/components/ErrorBoundary.esm.js +3 -2
- package/dist/components/ErrorBoundary.esm.js.map +1 -1
- package/dist/components/ExtensionBoundary.esm.js +6 -5
- package/dist/components/ExtensionBoundary.esm.js.map +1 -1
- package/dist/index.d.ts +15 -14
- package/package.json +16 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @backstage/frontend-plugin-api
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- a47fd39: Removes instances of default React imports, a necessary update for the upcoming React 19 migration.
|
|
8
|
+
|
|
9
|
+
<https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
|
|
10
|
+
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
- @backstage/core-components@0.17.1
|
|
13
|
+
- @backstage/core-plugin-api@1.10.6
|
|
14
|
+
- @backstage/types@1.2.1
|
|
15
|
+
- @backstage/version-bridge@1.0.11
|
|
16
|
+
|
|
17
|
+
## 0.10.1-next.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- a47fd39: Removes instances of default React imports, a necessary update for the upcoming React 19 migration.
|
|
22
|
+
|
|
23
|
+
<https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html>
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @backstage/core-components@0.17.1-next.1
|
|
27
|
+
- @backstage/core-plugin-api@1.10.6-next.0
|
|
28
|
+
- @backstage/types@1.2.1
|
|
29
|
+
- @backstage/version-bridge@1.0.11
|
|
30
|
+
|
|
3
31
|
## 0.10.1-next.0
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
1
2
|
import { createVersionedContext, createVersionedValueMap } from '@backstage/version-bridge';
|
|
2
|
-
import
|
|
3
|
+
import { useContext } from 'react';
|
|
3
4
|
|
|
4
5
|
const AnalyticsReactContext = createVersionedContext("analytics-context");
|
|
5
6
|
const useAnalyticsContext = () => {
|
|
@@ -24,7 +25,7 @@ const AnalyticsContext = (options) => {
|
|
|
24
25
|
...attributes
|
|
25
26
|
};
|
|
26
27
|
const versionedCombinedValue = createVersionedValueMap({ 1: combinedValue });
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
+
return /* @__PURE__ */ jsx(AnalyticsReactContext.Provider, { value: versionedCombinedValue, children });
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
export { AnalyticsContext, useAnalyticsContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsContext.esm.js","sources":["../../src/analytics/AnalyticsContext.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport
|
|
1
|
+
{"version":3,"file":"AnalyticsContext.esm.js","sources":["../../src/analytics/AnalyticsContext.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 createVersionedContext,\n createVersionedValueMap,\n} from '@backstage/version-bridge';\nimport { ComponentType, ReactNode, useContext } from 'react';\nimport { AnalyticsContextValue } from './types';\n\nconst AnalyticsReactContext = createVersionedContext<{\n 1: AnalyticsContextValue;\n}>('analytics-context');\n\n/**\n * A \"private\" (to this package) hook that enables context inheritance and a\n * way to read Analytics Context values at event capture-time.\n *\n * @internal\n */\nexport const useAnalyticsContext = (): AnalyticsContextValue => {\n const theContext = useContext(AnalyticsReactContext);\n\n // Provide a default value if no value exists.\n if (theContext === undefined) {\n return {\n pluginId: 'app',\n extensionId: 'app',\n };\n }\n\n // This should probably never happen, but check for it.\n const theValue = theContext.atVersion(1);\n if (theValue === undefined) {\n throw new Error('No context found for version 1.');\n }\n\n return theValue;\n};\n\n/**\n * Provides components in the child react tree an Analytics Context, ensuring\n * all analytics events captured within the context have relevant attributes.\n *\n * @remarks\n *\n * Analytics contexts are additive, meaning the context ultimately emitted with\n * an event is the combination of all contexts in the parent tree.\n *\n * @public\n */\nexport const AnalyticsContext = (options: {\n attributes: Partial<AnalyticsContextValue>;\n children: ReactNode;\n}) => {\n const { attributes, children } = options;\n\n const parentValues = useAnalyticsContext();\n const combinedValue = {\n ...parentValues,\n ...attributes,\n };\n\n const versionedCombinedValue = createVersionedValueMap({ 1: combinedValue });\n return (\n <AnalyticsReactContext.Provider value={versionedCombinedValue}>\n {children}\n </AnalyticsReactContext.Provider>\n );\n};\n\n/**\n * Returns an HOC wrapping the provided component in an Analytics context with\n * the given values.\n *\n * @param Component - Component to be wrapped with analytics context attributes\n * @param values - Analytics context key/value pairs.\n * @internal\n */\nexport function withAnalyticsContext<TProps extends {}>(\n Component: ComponentType<TProps>,\n values: AnalyticsContextValue,\n) {\n const ComponentWithAnalyticsContext = (props: TProps) => {\n return (\n <AnalyticsContext attributes={values}>\n <Component {...props} />\n </AnalyticsContext>\n );\n };\n ComponentWithAnalyticsContext.displayName = `WithAnalyticsContext(${\n Component.displayName || Component.name || 'Component'\n })`;\n return ComponentWithAnalyticsContext;\n}\n"],"names":[],"mappings":";;;;AAuBA,MAAM,qBAAA,GAAwB,uBAE3B,mBAAmB,CAAA;AAQf,MAAM,sBAAsB,MAA6B;AAC9D,EAAM,MAAA,UAAA,GAAa,WAAW,qBAAqB,CAAA;AAGnD,EAAA,IAAI,eAAe,KAAW,CAAA,EAAA;AAC5B,IAAO,OAAA;AAAA,MACL,QAAU,EAAA,KAAA;AAAA,MACV,WAAa,EAAA;AAAA,KACf;AAAA;AAIF,EAAM,MAAA,QAAA,GAAW,UAAW,CAAA,SAAA,CAAU,CAAC,CAAA;AACvC,EAAA,IAAI,aAAa,KAAW,CAAA,EAAA;AAC1B,IAAM,MAAA,IAAI,MAAM,iCAAiC,CAAA;AAAA;AAGnD,EAAO,OAAA,QAAA;AACT;AAaa,MAAA,gBAAA,GAAmB,CAAC,OAG3B,KAAA;AACJ,EAAM,MAAA,EAAE,UAAY,EAAA,QAAA,EAAa,GAAA,OAAA;AAEjC,EAAA,MAAM,eAAe,mBAAoB,EAAA;AACzC,EAAA,MAAM,aAAgB,GAAA;AAAA,IACpB,GAAG,YAAA;AAAA,IACH,GAAG;AAAA,GACL;AAEA,EAAA,MAAM,sBAAyB,GAAA,uBAAA,CAAwB,EAAE,CAAA,EAAG,eAAe,CAAA;AAC3E,EAAA,2BACG,qBAAsB,CAAA,QAAA,EAAtB,EAA+B,KAAA,EAAO,wBACpC,QACH,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import '../wiring/coreExtensionData.esm.js';
|
|
3
3
|
import 'zod';
|
|
4
4
|
import 'zod-to-json-schema';
|
|
@@ -15,7 +15,7 @@ const AppRootWrapperBlueprint = createExtensionBlueprint({
|
|
|
15
15
|
},
|
|
16
16
|
*factory(params) {
|
|
17
17
|
const Component = (props) => {
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ jsx(params.Component, { children: props.children });
|
|
19
19
|
};
|
|
20
20
|
yield componentDataRef(Component);
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppRootWrapperBlueprint.esm.js","sources":["../../src/blueprints/AppRootWrapperBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"AppRootWrapperBlueprint.esm.js","sources":["../../src/blueprints/AppRootWrapperBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentType, PropsWithChildren } from 'react';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst componentDataRef = createExtensionDataRef<\n ComponentType<PropsWithChildren<{}>>\n>().with({ id: 'app.root.wrapper' });\n\n/**\n * Creates a extensions that render a React wrapper at the app root, enclosing\n * the app layout. This is useful for example for adding global React contexts\n * and similar.\n *\n * @public\n */\nexport const AppRootWrapperBlueprint = createExtensionBlueprint({\n kind: 'app-root-wrapper',\n attachTo: { id: 'app/root', input: 'wrappers' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n *factory(params: { Component: ComponentType<PropsWithChildren<{}>> }) {\n // todo(blam): not sure that this wrapping is even necessary anymore.\n const Component = (props: PropsWithChildren<{}>) => {\n return <params.Component>{props.children}</params.Component>;\n };\n\n yield componentDataRef(Component);\n },\n});\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,mBAAmB,sBAEvB,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,oBAAoB,CAAA;AAS5B,MAAM,0BAA0B,wBAAyB,CAAA;AAAA,EAC9D,IAAM,EAAA,kBAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,UAAA,EAAY,OAAO,UAAW,EAAA;AAAA,EAC9C,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAU,EAAA;AAAA,IACR,SAAW,EAAA;AAAA,GACb;AAAA,EACA,CAAC,QAAQ,MAA6D,EAAA;AAEpE,IAAM,MAAA,SAAA,GAAY,CAAC,KAAiC,KAAA;AAClD,MAAA,uBAAQ,GAAA,CAAA,MAAA,CAAO,SAAP,EAAA,EAAkB,gBAAM,QAAS,EAAA,CAAA;AAAA,KAC3C;AAEA,IAAA,MAAM,iBAAiB,SAAS,CAAA;AAAA;AAEpC,CAAC;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { lazy } from 'react';
|
|
2
3
|
import '../wiring/coreExtensionData.esm.js';
|
|
3
4
|
import 'zod';
|
|
4
5
|
import 'zod-to-json-schema';
|
|
@@ -20,7 +21,7 @@ const SignInPageBlueprint = createExtensionBlueprint({
|
|
|
20
21
|
const ExtensionComponent = lazy(
|
|
21
22
|
() => loader().then((component) => ({ default: component }))
|
|
22
23
|
);
|
|
23
|
-
yield componentDataRef((props) => /* @__PURE__ */
|
|
24
|
+
yield componentDataRef((props) => /* @__PURE__ */ jsx(ExtensionBoundary, { node, routable: true, children: /* @__PURE__ */ jsx(ExtensionComponent, { ...props }) }));
|
|
24
25
|
}
|
|
25
26
|
});
|
|
26
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInPageBlueprint.esm.js","sources":["../../src/blueprints/SignInPageBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport
|
|
1
|
+
{"version":3,"file":"SignInPageBlueprint.esm.js","sources":["../../src/blueprints/SignInPageBlueprint.tsx"],"sourcesContent":["/*\n * Copyright 2024 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ComponentType, lazy } from 'react';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\nimport { SignInPageProps } from '@backstage/core-plugin-api';\nimport { ExtensionBoundary } from '../components';\n\nconst componentDataRef = createExtensionDataRef<\n ComponentType<SignInPageProps>\n>().with({ id: 'core.sign-in-page.component' });\n\n/**\n * Creates an extension that replaces the sign in page.\n *\n * @public\n */\nexport const SignInPageBlueprint = createExtensionBlueprint({\n kind: 'sign-in-page',\n attachTo: { id: 'app/root', input: 'signInPage' },\n output: [componentDataRef],\n dataRefs: {\n component: componentDataRef,\n },\n *factory(\n {\n loader,\n }: {\n loader: () => Promise<ComponentType<SignInPageProps>>;\n },\n { node },\n ) {\n const ExtensionComponent = lazy(() =>\n loader().then(component => ({ default: component })),\n );\n\n yield componentDataRef(props => (\n <ExtensionBoundary node={node} routable>\n <ExtensionComponent {...props} />\n </ExtensionBoundary>\n ));\n },\n});\n"],"names":[],"mappings":";;;;;;;;;AAqBA,MAAM,mBAAmB,sBAEvB,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,+BAA+B,CAAA;AAOvC,MAAM,sBAAsB,wBAAyB,CAAA;AAAA,EAC1D,IAAM,EAAA,cAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,UAAA,EAAY,OAAO,YAAa,EAAA;AAAA,EAChD,MAAA,EAAQ,CAAC,gBAAgB,CAAA;AAAA,EACzB,QAAU,EAAA;AAAA,IACR,SAAW,EAAA;AAAA,GACb;AAAA,EACA,CAAC,OACC,CAAA;AAAA,IACE;AAAA,GACF,EAGA,EAAE,IAAA,EACF,EAAA;AACA,IAAA,MAAM,kBAAqB,GAAA,IAAA;AAAA,MAAK,MAC9B,QAAS,CAAA,IAAA,CAAK,gBAAc,EAAE,OAAA,EAAS,WAAY,CAAA;AAAA,KACrD;AAEA,IAAA,MAAM,gBAAiB,CAAA,CAAA,KAAA,qBACpB,GAAA,CAAA,iBAAA,EAAA,EAAkB,IAAY,EAAA,QAAA,EAAQ,IACrC,EAAA,QAAA,kBAAA,GAAA,CAAC,kBAAoB,EAAA,EAAA,GAAG,KAAO,EAAA,CAAA,EACjC,CACD,CAAA;AAAA;AAEL,CAAC;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Component } from 'react';
|
|
2
3
|
|
|
3
4
|
class ErrorBoundary extends Component {
|
|
4
5
|
static getDerivedStateFromError(error) {
|
|
@@ -12,7 +13,7 @@ class ErrorBoundary extends Component {
|
|
|
12
13
|
const { error } = this.state;
|
|
13
14
|
const { plugin, children, Fallback } = this.props;
|
|
14
15
|
if (error) {
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
+
return /* @__PURE__ */ jsx(
|
|
16
17
|
Fallback,
|
|
17
18
|
{
|
|
18
19
|
plugin,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.esm.js","sources":["../../src/components/ErrorBoundary.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
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.esm.js","sources":["../../src/components/ErrorBoundary.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 { Component, ComponentType, PropsWithChildren } from 'react';\nimport { FrontendPlugin } from '../wiring';\nimport { CoreErrorBoundaryFallbackProps } from '../types';\n\ntype ErrorBoundaryProps = PropsWithChildren<{\n plugin?: FrontendPlugin;\n Fallback: ComponentType<CoreErrorBoundaryFallbackProps>;\n}>;\ntype ErrorBoundaryState = { error?: Error };\n\n/** @internal */\nexport class ErrorBoundary extends Component<\n ErrorBoundaryProps,\n ErrorBoundaryState\n> {\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n state: ErrorBoundaryState = { error: undefined };\n\n handleErrorReset = () => {\n this.setState({ error: undefined });\n };\n\n render() {\n const { error } = this.state;\n const { plugin, children, Fallback } = this.props;\n\n if (error) {\n return (\n <Fallback\n plugin={plugin}\n error={error}\n resetError={this.handleErrorReset}\n />\n );\n }\n\n return children;\n }\n}\n"],"names":[],"mappings":";;;AA2BO,MAAM,sBAAsB,SAGjC,CAAA;AAAA,EACA,OAAO,yBAAyB,KAAc,EAAA;AAC5C,IAAA,OAAO,EAAE,KAAM,EAAA;AAAA;AACjB,EAEA,KAAA,GAA4B,EAAE,KAAA,EAAO,KAAU,CAAA,EAAA;AAAA,EAE/C,mBAAmB,MAAM;AACvB,IAAA,IAAA,CAAK,QAAS,CAAA,EAAE,KAAO,EAAA,KAAA,CAAA,EAAW,CAAA;AAAA,GACpC;AAAA,EAEA,MAAS,GAAA;AACP,IAAM,MAAA,EAAE,KAAM,EAAA,GAAI,IAAK,CAAA,KAAA;AACvB,IAAA,MAAM,EAAE,MAAA,EAAQ,QAAU,EAAA,QAAA,KAAa,IAAK,CAAA,KAAA;AAE5C,IAAA,IAAI,KAAO,EAAA;AACT,MACE,uBAAA,GAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,MAAA;AAAA,UACA,KAAA;AAAA,UACA,YAAY,IAAK,CAAA;AAAA;AAAA,OACnB;AAAA;AAIJ,IAAO,OAAA,QAAA;AAAA;AAEX;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { Suspense, lazy, useEffect } from 'react';
|
|
2
3
|
import { AnalyticsContext, useAnalytics } from '@backstage/core-plugin-api';
|
|
3
4
|
import { ErrorBoundary } from './ErrorBoundary.esm.js';
|
|
4
5
|
import { routableExtensionRenderedEvent } from '../core-plugin-api/src/analytics/Tracker.esm.js';
|
|
@@ -20,7 +21,7 @@ const RouteTracker = (props) => {
|
|
|
20
21
|
if (disableTracking) return;
|
|
21
22
|
analytics.captureEvent(routableExtensionRenderedEvent, "");
|
|
22
23
|
}, [analytics, disableTracking]);
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
24
25
|
};
|
|
25
26
|
function ExtensionBoundary(props) {
|
|
26
27
|
const { node, routable, children } = props;
|
|
@@ -34,21 +35,21 @@ function ExtensionBoundary(props) {
|
|
|
34
35
|
extensionId: node.spec.id,
|
|
35
36
|
pluginId: node.spec.source?.id ?? "app"
|
|
36
37
|
};
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
+
return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Progress, {}), children: /* @__PURE__ */ jsx(ErrorBoundary, { plugin, Fallback: fallback, children: /* @__PURE__ */ jsx(AnalyticsContext, { attributes, children: /* @__PURE__ */ jsx(RouteTracker, { disableTracking: !(routable ?? doesOutputRoutePath), children }) }) }) });
|
|
38
39
|
}
|
|
39
40
|
((ExtensionBoundary2) => {
|
|
40
41
|
function lazy$1(appNode, loader) {
|
|
41
42
|
const ExtensionComponent = lazy(
|
|
42
43
|
() => loader().then((element) => ({ default: () => element }))
|
|
43
44
|
);
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
+
return /* @__PURE__ */ jsx(ExtensionBoundary2, { node: appNode, children: /* @__PURE__ */ jsx(ExtensionComponent, {}) });
|
|
45
46
|
}
|
|
46
47
|
ExtensionBoundary2.lazy = lazy$1;
|
|
47
48
|
function lazyComponent(appNode, loader) {
|
|
48
49
|
const ExtensionComponent = lazy(
|
|
49
50
|
() => loader().then((Component) => ({ default: Component }))
|
|
50
51
|
);
|
|
51
|
-
return (props) => /* @__PURE__ */
|
|
52
|
+
return (props) => /* @__PURE__ */ jsx(ExtensionBoundary2, { node: appNode, children: /* @__PURE__ */ jsx(ExtensionComponent, { ...props }) });
|
|
52
53
|
}
|
|
53
54
|
ExtensionBoundary2.lazyComponent = lazyComponent;
|
|
54
55
|
})(ExtensionBoundary || (ExtensionBoundary = {}));
|
|
@@ -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
|
|
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 {\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 loader: () => Promise<JSX.Element>,\n ): JSX.Element {\n const ExtensionComponent = reactLazy(() =>\n loader().then(element => ({ default: () => element })),\n );\n return (\n <ExtensionBoundary node={appNode}>\n <ExtensionComponent />\n </ExtensionBoundary>\n );\n }\n\n export function lazyComponent<TProps extends {}>(\n appNode: AppNode,\n loader: () => Promise<(props: TProps) => JSX.Element>,\n ): (props: TProps) => JSX.Element {\n const ExtensionComponent = reactLazy(() =>\n loader().then(Component => ({ default: Component })),\n ) as unknown as React.ComponentType<TProps>;\n\n return (props: TProps) => (\n <ExtensionBoundary node={appNode}>\n <ExtensionComponent {...props} />\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;AACtC,EAAA,MAAM,YAAY,YAAa,EAAA;AAM/B,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,eAAiB,EAAA;AACrB,IAAU,SAAA,CAAA,YAAA,CAAa,gCAAgC,EAAE,CAAA;AAAA,GACxD,EAAA,CAAC,SAAW,EAAA,eAAe,CAAC,CAAA;AAE/B,EAAA,uCAAU,QAAS,EAAA,CAAA;AACrB,CAAA;AAeO,SAAS,kBAAkB,KAA+B,EAAA;AAC/D,EAAA,MAAM,EAAE,IAAA,EAAM,QAAU,EAAA,QAAA,EAAa,GAAA,KAAA;AAErC,EAAA,MAAM,mBAAsB,GAAA,OAAA;AAAA,IAC1B,IAAK,CAAA,QAAA,EAAU,OAAQ,CAAA,iBAAA,CAAkB,SAAS;AAAA,GACpD;AAEA,EAAM,MAAA,MAAA,GAAS,KAAK,IAAK,CAAA,MAAA;AACzB,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,QAAQ,CAAA;AAC3D,EAAM,MAAA,QAAA,GAAW,eAAgB,CAAA,iBAAA,CAAkB,qBAAqB,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;AAAA,GACpC;AAEA,EACE,uBAAA,GAAA,CAAC,YAAS,QAAU,kBAAA,GAAA,CAAC,YAAS,CAC5B,EAAA,QAAA,kBAAA,GAAA,CAAC,aAAc,EAAA,EAAA,MAAA,EAAgB,QAAU,EAAA,QAAA,EACvC,8BAAC,gBAAiB,EAAA,EAAA,UAAA,EAChB,QAAC,kBAAA,GAAA,CAAA,YAAA,EAAA,EAAa,eAAiB,EAAA,EAAE,YAAY,mBAC1C,CAAA,EAAA,QAAA,EACH,CACF,EAAA,CAAA,EACF,CACF,EAAA,CAAA;AAEJ;AAAA,CAGO,CAAUA,kBAAV,KAAA;AACE,EAAS,SAAAC,MAAA,CACd,SACA,MACa,EAAA;AACb,IAAA,MAAM,kBAAqB,GAAAC,IAAA;AAAA,MAAU,MACnC,QAAS,CAAA,IAAA,CAAK,cAAY,EAAE,OAAA,EAAS,MAAM,OAAA,EAAU,CAAA;AAAA,KACvD;AACA,IAAA,2BACGF,kBAAA,EAAA,EAAkB,MAAM,OACvB,EAAA,QAAA,kBAAA,GAAA,CAAC,sBAAmB,CACtB,EAAA,CAAA;AAAA;AAVG,EAAAA,kBAAS,CAAA,IAAA,GAAAC,MAAA;AAcT,EAAS,SAAA,aAAA,CACd,SACA,MACgC,EAAA;AAChC,IAAA,MAAM,kBAAqB,GAAAC,IAAA;AAAA,MAAU,MACnC,QAAS,CAAA,IAAA,CAAK,gBAAc,EAAE,OAAA,EAAS,WAAY,CAAA;AAAA,KACrD;AAEA,IAAO,OAAA,CAAC,KACN,qBAAA,GAAA,CAACF,kBAAA,EAAA,EAAkB,IAAM,EAAA,OAAA,EACvB,QAAC,kBAAA,GAAA,CAAA,kBAAA,EAAA,EAAoB,GAAG,KAAA,EAAO,CACjC,EAAA,CAAA;AAAA;AAXG,EAAAA,kBAAS,CAAA,aAAA,GAAA,aAAA;AAAA,CAfD,EAAA,iBAAA,KAAA,iBAAA,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import { ReactNode, JSX as JSX$1, ComponentType, PropsWithChildren } from 'react';
|
|
3
4
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
5
|
import { ApiHolder, ConfigApi, ApiRef, AnyApiFactory, IconComponent as IconComponent$1, SignInPageProps, AppTheme } from '@backstage/core-plugin-api';
|
|
5
6
|
export { AlertApi, AlertMessage, AnyApiFactory, AnyApiRef, ApiFactory, ApiHolder, ApiRef, ApiRefConfig, AppTheme, AppThemeApi, AuthProviderInfo, AuthRequestOptions, BackstageIdentityApi, BackstageIdentityResponse, BackstageUserIdentity, ConfigApi, DiscoveryApi, ErrorApi, ErrorApiError, ErrorApiErrorContext, FeatureFlag, FeatureFlagState, FeatureFlagsApi, FeatureFlagsSaveOptions, FetchApi, IdentityApi, OAuthApi, OAuthRequestApi, OAuthRequester, OAuthRequesterOptions, OAuthScope, OpenIdConnectApi, PendingOAuthRequest, ProfileInfo, ProfileInfoApi, SessionApi, SessionState, StorageApi, StorageValueSnapshot, TypesToApiRefs, alertApiRef, appThemeApiRef, atlassianAuthApiRef, bitbucketAuthApiRef, bitbucketServerAuthApiRef, configApiRef, createApiFactory, createApiRef, discoveryApiRef, errorApiRef, featureFlagsApiRef, fetchApiRef, githubAuthApiRef, gitlabAuthApiRef, googleAuthApiRef, identityApiRef, microsoftAuthApiRef, oauthRequestApiRef, oktaAuthApiRef, oneloginAuthApiRef, storageApiRef, useApi, useApiHolder, vmwareCloudAuthApiRef, withApis } from '@backstage/core-plugin-api';
|
|
@@ -46,7 +47,7 @@ type AnalyticsContextValue = CommonAnalyticsContext & {
|
|
|
46
47
|
declare const AnalyticsContext: (options: {
|
|
47
48
|
attributes: Partial<AnalyticsContextValue>;
|
|
48
49
|
children: ReactNode;
|
|
49
|
-
}) =>
|
|
50
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* Catch-all type for route params.
|
|
@@ -879,7 +880,7 @@ interface ExtensionBoundaryProps {
|
|
|
879
880
|
children: ReactNode;
|
|
880
881
|
}
|
|
881
882
|
/** @public */
|
|
882
|
-
declare function ExtensionBoundary(props: ExtensionBoundaryProps):
|
|
883
|
+
declare function ExtensionBoundary(props: ExtensionBoundaryProps): react_jsx_runtime.JSX.Element;
|
|
883
884
|
/** @public */
|
|
884
885
|
declare namespace ExtensionBoundary {
|
|
885
886
|
function lazy(appNode: AppNode, loader: () => Promise<JSX.Element>): JSX.Element;
|
|
@@ -1291,7 +1292,7 @@ declare const AppRootElementBlueprint: ExtensionBlueprint<{
|
|
|
1291
1292
|
params: {
|
|
1292
1293
|
element: JSX.Element | (() => JSX.Element);
|
|
1293
1294
|
};
|
|
1294
|
-
output: ConfigurableExtensionDataRef<
|
|
1295
|
+
output: ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}>;
|
|
1295
1296
|
inputs: {};
|
|
1296
1297
|
config: {};
|
|
1297
1298
|
configInput: {};
|
|
@@ -1311,15 +1312,15 @@ declare const AppRootWrapperBlueprint: ExtensionBlueprint<{
|
|
|
1311
1312
|
params: {
|
|
1312
1313
|
Component: ComponentType<PropsWithChildren<{}>>;
|
|
1313
1314
|
};
|
|
1314
|
-
output: ConfigurableExtensionDataRef<
|
|
1315
|
-
children?:
|
|
1315
|
+
output: ConfigurableExtensionDataRef<ComponentType<{
|
|
1316
|
+
children?: react.ReactNode | undefined;
|
|
1316
1317
|
}>, "app.root.wrapper", {}>;
|
|
1317
1318
|
inputs: {};
|
|
1318
1319
|
config: {};
|
|
1319
1320
|
configInput: {};
|
|
1320
1321
|
dataRefs: {
|
|
1321
|
-
component: ConfigurableExtensionDataRef<
|
|
1322
|
-
children?:
|
|
1322
|
+
component: ConfigurableExtensionDataRef<ComponentType<{
|
|
1323
|
+
children?: react.ReactNode | undefined;
|
|
1323
1324
|
}>, "app.root.wrapper", {}>;
|
|
1324
1325
|
};
|
|
1325
1326
|
}>;
|
|
@@ -1414,7 +1415,7 @@ declare const PageBlueprint: ExtensionBlueprint<{
|
|
|
1414
1415
|
loader: () => Promise<JSX.Element>;
|
|
1415
1416
|
routeRef?: RouteRef;
|
|
1416
1417
|
};
|
|
1417
|
-
output: ConfigurableExtensionDataRef<
|
|
1418
|
+
output: ConfigurableExtensionDataRef<react.JSX.Element, "core.reactElement", {}> | ConfigurableExtensionDataRef<string, "core.routing.path", {}> | ConfigurableExtensionDataRef<RouteRef<AnyRouteRefParams>, "core.routing.ref", {
|
|
1418
1419
|
optional: true;
|
|
1419
1420
|
}>;
|
|
1420
1421
|
inputs: {};
|
|
@@ -1435,14 +1436,14 @@ declare const RouterBlueprint: ExtensionBlueprint<{
|
|
|
1435
1436
|
Component: ComponentType<PropsWithChildren<{}>>;
|
|
1436
1437
|
};
|
|
1437
1438
|
output: ConfigurableExtensionDataRef<ComponentType<{
|
|
1438
|
-
children?:
|
|
1439
|
+
children?: react.ReactNode | undefined;
|
|
1439
1440
|
}>, "app.router.wrapper", {}>;
|
|
1440
1441
|
inputs: {};
|
|
1441
1442
|
config: {};
|
|
1442
1443
|
configInput: {};
|
|
1443
1444
|
dataRefs: {
|
|
1444
1445
|
component: ConfigurableExtensionDataRef<ComponentType<{
|
|
1445
|
-
children?:
|
|
1446
|
+
children?: react.ReactNode | undefined;
|
|
1446
1447
|
}>, "app.router.wrapper", {}>;
|
|
1447
1448
|
};
|
|
1448
1449
|
}>;
|
|
@@ -1458,12 +1459,12 @@ declare const SignInPageBlueprint: ExtensionBlueprint<{
|
|
|
1458
1459
|
params: {
|
|
1459
1460
|
loader: () => Promise<ComponentType<SignInPageProps>>;
|
|
1460
1461
|
};
|
|
1461
|
-
output: ConfigurableExtensionDataRef<
|
|
1462
|
+
output: ConfigurableExtensionDataRef<ComponentType<SignInPageProps>, "core.sign-in-page.component", {}>;
|
|
1462
1463
|
inputs: {};
|
|
1463
1464
|
config: {};
|
|
1464
1465
|
configInput: {};
|
|
1465
1466
|
dataRefs: {
|
|
1466
|
-
component: ConfigurableExtensionDataRef<
|
|
1467
|
+
component: ConfigurableExtensionDataRef<ComponentType<SignInPageProps>, "core.sign-in-page.component", {}>;
|
|
1467
1468
|
};
|
|
1468
1469
|
}>;
|
|
1469
1470
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/frontend-plugin-api",
|
|
3
|
-
"version": "0.10.1
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
"test": "backstage-cli package test"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@backstage/core-components": "0.17.1
|
|
35
|
-
"@backstage/core-plugin-api": "1.10.
|
|
36
|
-
"@backstage/types": "1.2.1",
|
|
37
|
-
"@backstage/version-bridge": "1.0.11",
|
|
34
|
+
"@backstage/core-components": "^0.17.1",
|
|
35
|
+
"@backstage/core-plugin-api": "^1.10.6",
|
|
36
|
+
"@backstage/types": "^1.2.1",
|
|
37
|
+
"@backstage/version-bridge": "^1.0.11",
|
|
38
38
|
"@material-ui/core": "^4.12.4",
|
|
39
39
|
"lodash": "^4.17.21",
|
|
40
40
|
"zod": "^3.22.4",
|
|
41
41
|
"zod-to-json-schema": "^3.21.4"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@backstage/cli": "0.32.0
|
|
45
|
-
"@backstage/frontend-app-api": "0.11.1
|
|
46
|
-
"@backstage/frontend-test-utils": "0.3.1
|
|
47
|
-
"@backstage/test-utils": "1.7.
|
|
44
|
+
"@backstage/cli": "^0.32.0",
|
|
45
|
+
"@backstage/frontend-app-api": "^0.11.1",
|
|
46
|
+
"@backstage/frontend-test-utils": "^0.3.1",
|
|
47
|
+
"@backstage/test-utils": "^1.7.7",
|
|
48
48
|
"@testing-library/jest-dom": "^6.0.0",
|
|
49
49
|
"@testing-library/react": "^16.0.0",
|
|
50
50
|
"@types/react": "^18.0.0",
|
|
@@ -64,5 +64,12 @@
|
|
|
64
64
|
"optional": true
|
|
65
65
|
}
|
|
66
66
|
},
|
|
67
|
+
"typesVersions": {
|
|
68
|
+
"*": {
|
|
69
|
+
"package.json": [
|
|
70
|
+
"package.json"
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
},
|
|
67
74
|
"module": "./dist/index.esm.js"
|
|
68
75
|
}
|