@backstage/core-compat-api 0.5.0 → 0.5.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
|
@@ -2,13 +2,18 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useVersionedContext } from '@backstage/version-bridge';
|
|
3
3
|
import { BackwardsCompatProvider } from './BackwardsCompatProvider.esm.js';
|
|
4
4
|
import { ForwardsCompatProvider } from './ForwardsCompatProvider.esm.js';
|
|
5
|
+
import { useApiHolder, appTreeApiRef } from '@backstage/frontend-plugin-api';
|
|
5
6
|
|
|
6
7
|
function BidirectionalCompatProvider(props) {
|
|
7
|
-
const
|
|
8
|
-
|
|
8
|
+
const isInOldApp = useVersionedContext("app-context");
|
|
9
|
+
const isInNewApp = Boolean(useApiHolder().get(appTreeApiRef));
|
|
10
|
+
if (isInNewApp && !isInOldApp) {
|
|
9
11
|
return /* @__PURE__ */ jsx(BackwardsCompatProvider, { ...props });
|
|
10
12
|
}
|
|
11
|
-
|
|
13
|
+
if (isInOldApp && !isInNewApp) {
|
|
14
|
+
return /* @__PURE__ */ jsx(ForwardsCompatProvider, { ...props });
|
|
15
|
+
}
|
|
16
|
+
return props.children;
|
|
12
17
|
}
|
|
13
18
|
function compatWrapper(element) {
|
|
14
19
|
return /* @__PURE__ */ jsx(BidirectionalCompatProvider, { children: element });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compatWrapper.esm.js","sources":["../../src/compatWrapper/compatWrapper.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 { useVersionedContext } from '@backstage/version-bridge';\nimport { ReactNode } from 'react';\nimport { BackwardsCompatProvider } from './BackwardsCompatProvider';\nimport { ForwardsCompatProvider } from './ForwardsCompatProvider';\n\nfunction BidirectionalCompatProvider(props: { children: ReactNode }) {\n const
|
|
1
|
+
{"version":3,"file":"compatWrapper.esm.js","sources":["../../src/compatWrapper/compatWrapper.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 { useVersionedContext } from '@backstage/version-bridge';\nimport { ReactNode } from 'react';\nimport { BackwardsCompatProvider } from './BackwardsCompatProvider';\nimport { ForwardsCompatProvider } from './ForwardsCompatProvider';\nimport { appTreeApiRef, useApiHolder } from '@backstage/frontend-plugin-api';\n\nfunction BidirectionalCompatProvider(props: { children: ReactNode }) {\n const isInOldApp = useVersionedContext<{ 1: unknown }>('app-context');\n const isInNewApp = Boolean(useApiHolder().get(appTreeApiRef));\n\n if (isInNewApp && !isInOldApp) {\n return <BackwardsCompatProvider {...props} />;\n }\n\n if (isInOldApp && !isInNewApp) {\n return <ForwardsCompatProvider {...props} />;\n }\n\n return props.children;\n}\n\n/**\n * Wraps a React element in a bidirectional compatibility provider, allow APIs\n * from `@backstage/core-plugin-api` to be used in an app from `@backstage/frontend-app-api`,\n * and APIs from `@backstage/frontend-plugin-api` to be used in an app from `@backstage/core-app-api`.\n *\n * @public\n */\nexport function compatWrapper(element: ReactNode) {\n return <BidirectionalCompatProvider>{element}</BidirectionalCompatProvider>;\n}\n"],"names":[],"mappings":";;;;;;AAsBA,SAAS,4BAA4B,KAAA,EAAgC;AACnE,EAAA,MAAM,UAAA,GAAa,oBAAoC,aAAa,CAAA;AACpE,EAAA,MAAM,aAAa,OAAA,CAAQ,YAAA,EAAa,CAAE,GAAA,CAAI,aAAa,CAAC,CAAA;AAE5D,EAAA,IAAI,UAAA,IAAc,CAAC,UAAA,EAAY;AAC7B,IAAA,uBAAO,GAAA,CAAC,uBAAA,EAAA,EAAyB,GAAG,KAAA,EAAO,CAAA;AAAA,EAC7C;AAEA,EAAA,IAAI,UAAA,IAAc,CAAC,UAAA,EAAY;AAC7B,IAAA,uBAAO,GAAA,CAAC,sBAAA,EAAA,EAAwB,GAAG,KAAA,EAAO,CAAA;AAAA,EAC5C;AAEA,EAAA,OAAO,KAAA,CAAM,QAAA;AACf;AASO,SAAS,cAAc,OAAA,EAAoB;AAChD,EAAA,uBAAO,GAAA,CAAC,+BAA6B,QAAA,EAAA,OAAA,EAAQ,CAAA;AAC/C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/core-compat-api",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"backstage": {
|
|
5
5
|
"role": "web-library"
|
|
6
6
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@backstage/core-plugin-api": "^1.10.9",
|
|
35
35
|
"@backstage/frontend-plugin-api": "^0.11.0",
|
|
36
|
-
"@backstage/plugin-catalog-react": "^1.20.
|
|
36
|
+
"@backstage/plugin-catalog-react": "^1.20.1",
|
|
37
37
|
"@backstage/version-bridge": "^1.0.11",
|
|
38
38
|
"lodash": "^4.17.21"
|
|
39
39
|
},
|