@backstage/core-plugin-api 1.4.0 → 1.4.1-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 +10 -0
- package/alpha/package.json +4 -3
- package/dist/alpha.d.ts +27 -0
- package/dist/alpha.esm.js +35 -0
- package/dist/alpha.esm.js.map +1 -0
- package/dist/index.d.ts +997 -1098
- package/dist/index.esm.js +18 -31
- package/dist/index.esm.js.map +1 -1
- package/package.json +23 -12
- package/dist/index.alpha.d.ts +0 -1867
- package/dist/index.beta.d.ts +0 -1848
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @backstage/core-plugin-api
|
|
2
2
|
|
|
3
|
+
## 1.4.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 928a12a9b3: Internal refactor of `/alpha` exports.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/config@1.0.6
|
|
10
|
+
- @backstage/types@1.0.2
|
|
11
|
+
- @backstage/version-bridge@1.0.3
|
|
12
|
+
|
|
3
13
|
## 1.4.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
package/alpha/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/core-plugin-api",
|
|
3
|
-
"version": "1.4.0",
|
|
4
|
-
"main": "../dist/
|
|
5
|
-
"
|
|
3
|
+
"version": "1.4.1-next.0",
|
|
4
|
+
"main": "../dist/alpha.esm.js",
|
|
5
|
+
"module": "../dist/alpha.esm.js",
|
|
6
|
+
"types": "../dist/alpha.d.ts"
|
|
6
7
|
}
|
package/dist/alpha.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BackstagePlugin } from '@backstage/core-plugin-api';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the PluginProvider component.
|
|
6
|
+
*
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
interface PluginOptionsProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
plugin?: BackstagePlugin;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Contains the plugin configuration.
|
|
15
|
+
*
|
|
16
|
+
* @alpha
|
|
17
|
+
*/
|
|
18
|
+
declare const PluginProvider: (props: PluginOptionsProviderProps) => JSX.Element;
|
|
19
|
+
/**
|
|
20
|
+
* Grab the current entity from the context, throws if the entity has not yet been loaded
|
|
21
|
+
* or is not available.
|
|
22
|
+
*
|
|
23
|
+
* @alpha
|
|
24
|
+
*/
|
|
25
|
+
declare function usePluginOptions<TPluginOptions extends {} = {}>(): TPluginOptions;
|
|
26
|
+
|
|
27
|
+
export { PluginOptionsProviderProps, PluginProvider, usePluginOptions };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createVersionedContext, createVersionedValueMap, useVersionedContext } from '@backstage/version-bridge';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
const contextKey = "plugin-context";
|
|
5
|
+
const PluginProvider = (props) => {
|
|
6
|
+
const { children, plugin } = props;
|
|
7
|
+
const { Provider } = createVersionedContext(contextKey);
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
Provider,
|
|
10
|
+
{
|
|
11
|
+
value: createVersionedValueMap({
|
|
12
|
+
1: {
|
|
13
|
+
plugin
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
},
|
|
17
|
+
children
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
function usePluginOptions() {
|
|
21
|
+
const versionedHolder = useVersionedContext(
|
|
22
|
+
contextKey
|
|
23
|
+
);
|
|
24
|
+
if (!versionedHolder) {
|
|
25
|
+
throw new Error("Plugin Options context is not available");
|
|
26
|
+
}
|
|
27
|
+
const value = versionedHolder.atVersion(1);
|
|
28
|
+
if (!value) {
|
|
29
|
+
throw new Error("Plugin Options v1 is not available");
|
|
30
|
+
}
|
|
31
|
+
return value.plugin.getPluginOptions();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { PluginProvider, usePluginOptions };
|
|
35
|
+
//# sourceMappingURL=alpha.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/plugin-options/usePluginOptions.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n createVersionedContext,\n createVersionedValueMap,\n useVersionedContext,\n} from '@backstage/version-bridge';\nimport { BackstagePlugin } from '@backstage/core-plugin-api';\nimport React, { ReactNode } from 'react';\n\nconst contextKey: string = 'plugin-context';\n\n/**\n * Properties for the PluginProvider component.\n *\n * @alpha\n */\nexport interface PluginOptionsProviderProps {\n children: ReactNode;\n plugin?: BackstagePlugin;\n}\n\n/**\n * Contains the plugin configuration.\n *\n * @alpha\n */\nexport const PluginProvider = (\n props: PluginOptionsProviderProps,\n): JSX.Element => {\n const { children, plugin } = props;\n\n const { Provider } = createVersionedContext<{\n 1: { plugin: BackstagePlugin | undefined };\n }>(contextKey);\n\n return (\n <Provider\n value={createVersionedValueMap({\n 1: {\n plugin,\n },\n })}\n >\n {children}\n </Provider>\n );\n};\n\n/**\n * Grab the current entity from the context, throws if the entity has not yet been loaded\n * or is not available.\n *\n * @alpha\n */\nexport function usePluginOptions<\n TPluginOptions extends {} = {},\n>(): TPluginOptions {\n const versionedHolder = useVersionedContext<{ 1: TPluginOptions }>(\n contextKey,\n );\n\n if (!versionedHolder) {\n throw new Error('Plugin Options context is not available');\n }\n\n const value = versionedHolder.atVersion(1);\n if (!value) {\n throw new Error('Plugin Options v1 is not available');\n }\n\n return (\n value as unknown as {\n plugin: {\n getPluginOptions(): {};\n };\n }\n ).plugin.getPluginOptions() as TPluginOptions;\n}\n"],"names":[],"mappings":";;;AAwBA,MAAM,UAAqB,GAAA,gBAAA,CAAA;AAiBd,MAAA,cAAA,GAAiB,CAC5B,KACgB,KAAA;AAChB,EAAM,MAAA,EAAE,QAAU,EAAA,MAAA,EAAW,GAAA,KAAA,CAAA;AAE7B,EAAA,MAAM,EAAE,QAAA,EAAa,GAAA,sBAAA,CAElB,UAAU,CAAA,CAAA;AAEb,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,OAAO,uBAAwB,CAAA;AAAA,QAC7B,CAAG,EAAA;AAAA,UACD,MAAA;AAAA,SACF;AAAA,OACD,CAAA;AAAA,KAAA;AAAA,IAEA,QAAA;AAAA,GACH,CAAA;AAEJ,EAAA;AAQO,SAAS,gBAEI,GAAA;AAClB,EAAA,MAAM,eAAkB,GAAA,mBAAA;AAAA,IACtB,UAAA;AAAA,GACF,CAAA;AAEA,EAAA,IAAI,CAAC,eAAiB,EAAA;AACpB,IAAM,MAAA,IAAI,MAAM,yCAAyC,CAAA,CAAA;AAAA,GAC3D;AAEA,EAAM,MAAA,KAAA,GAAQ,eAAgB,CAAA,SAAA,CAAU,CAAC,CAAA,CAAA;AACzC,EAAA,IAAI,CAAC,KAAO,EAAA;AACV,IAAM,MAAA,IAAI,MAAM,oCAAoC,CAAA,CAAA;AAAA,GACtD;AAEA,EACE,OAAA,KAAA,CAKA,OAAO,gBAAiB,EAAA,CAAA;AAC5B;;;;"}
|