@backstage/frontend-plugin-api 0.7.0 → 0.8.0-next.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 +106 -0
- package/dist/blueprints/ApiBlueprint.esm.js +1 -1
- package/dist/blueprints/ApiBlueprint.esm.js.map +1 -1
- package/dist/blueprints/IconBundleBlueprint.esm.js +1 -2
- package/dist/blueprints/IconBundleBlueprint.esm.js.map +1 -1
- package/dist/blueprints/ThemeBlueprint.esm.js +1 -2
- package/dist/blueprints/ThemeBlueprint.esm.js.map +1 -1
- package/dist/blueprints/TranslationBlueprint.esm.js +1 -1
- package/dist/blueprints/TranslationBlueprint.esm.js.map +1 -1
- package/dist/extensions/createComponentExtension.esm.js +14 -19
- package/dist/extensions/createComponentExtension.esm.js.map +1 -1
- package/dist/index.d.ts +466 -583
- package/dist/index.esm.js +1 -11
- 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/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/createFrontendModule.esm.js +43 -0
- package/dist/wiring/createFrontendModule.esm.js.map +1 -0
- package/dist/wiring/createFrontendPlugin.esm.js +7 -2
- package/dist/wiring/createFrontendPlugin.esm.js.map +1 -1
- package/dist/wiring/resolveExtensionDefinition.esm.js.map +1 -1
- package/package.json +6 -6
- package/dist/extensions/createApiExtension.esm.js +0 -32
- 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 -44
- package/dist/extensions/createSignInPageExtension.esm.js.map +0 -1
- package/dist/extensions/createThemeExtension.esm.js +0 -22
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,111 @@
|
|
|
1
1
|
# @backstage/frontend-plugin-api
|
|
2
2
|
|
|
3
|
+
## 0.8.0-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c816e2d: Added `createFrontendModule` as a replacement for `createExtensionOverrides`, which is now deprecated.
|
|
8
|
+
|
|
9
|
+
Deprecated the `BackstagePlugin` and `FrontendFeature` type in favor of `FrontendPlugin` and `FrontendFeature` from `@backstage/frontend-app-api` respectively.
|
|
10
|
+
|
|
11
|
+
- 52f9c5a: Deprecated the `namespace` option for `createExtensionBlueprint` and `createExtension`, these are no longer required and will default to the `pluginId` instead.
|
|
12
|
+
|
|
13
|
+
You can migrate some of your extensions that use `createExtensionOverrides` to using `createFrontendModule` instead and providing a `pluginId` there.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// Before
|
|
17
|
+
createExtensionOverrides({
|
|
18
|
+
extensions: [
|
|
19
|
+
createExtension({
|
|
20
|
+
name: 'my-extension',
|
|
21
|
+
namespace: 'my-namespace',
|
|
22
|
+
kind: 'test',
|
|
23
|
+
...
|
|
24
|
+
})
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// After
|
|
29
|
+
createFrontendModule({
|
|
30
|
+
pluginId: 'my-namespace',
|
|
31
|
+
extensions: [
|
|
32
|
+
createExtension({
|
|
33
|
+
name: 'my-extension',
|
|
34
|
+
kind: 'test',
|
|
35
|
+
...
|
|
36
|
+
})
|
|
37
|
+
],
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
- 948d431: Removing deprecated `namespace` parameter in favour of `pluginId` instead
|
|
42
|
+
- Updated dependencies
|
|
43
|
+
- @backstage/core-components@0.14.11-next.0
|
|
44
|
+
- @backstage/core-plugin-api@1.9.3
|
|
45
|
+
- @backstage/types@1.1.1
|
|
46
|
+
- @backstage/version-bridge@1.0.8
|
|
47
|
+
|
|
48
|
+
## 0.8.0-next.0
|
|
49
|
+
|
|
50
|
+
### Minor Changes
|
|
51
|
+
|
|
52
|
+
- 5446061: **BREAKING**: Removed support for "v1" extensions. This means that it is no longer possible to declare inputs and outputs as objects when using `createExtension`. In addition, all extension creators except for `createComponentExtension` have been removed, use the equivalent blueprint instead. See the [1.30 migration documentation](https://backstage.io/docs/frontend-system/architecture/migrations/#130) for more information on this change.
|
|
53
|
+
- fec8b57: **BREAKING**: Updated the type parameters for `ExtensionDefinition` and `ExtensionBlueprint` to only have a single object parameter. The base type parameter is exported as `ExtensionDefinitionParameters` and `ExtensionBlueprintParameters` respectively. This is shipped as an immediate breaking change as we expect usage of these types to be rare, and it does not affect the runtime behavior of the API.
|
|
54
|
+
|
|
55
|
+
This is a breaking change as it changes the type parameters. Existing usage can generally be updated as follows:
|
|
56
|
+
|
|
57
|
+
- `ExtensionDefinition<any>` -> `ExtensionDefinition`
|
|
58
|
+
- `ExtensionDefinition<any, any>` -> `ExtensionDefinition`
|
|
59
|
+
- `ExtensionDefinition<TConfig>` -> `ExtensionDefinition<{ config: TConfig }>`
|
|
60
|
+
- `ExtensionDefinition<TConfig, TConfigInput>` -> `ExtensionDefinition<{ config: TConfig, configInput: TConfigInput }>`
|
|
61
|
+
|
|
62
|
+
If you need to infer the parameter you can use `ExtensionDefinitionParameters`, for example:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import {
|
|
66
|
+
ExtensionDefinition,
|
|
67
|
+
ExtensionDefinitionParameters,
|
|
68
|
+
} from '@backstage/frontend-plugin-api';
|
|
69
|
+
|
|
70
|
+
function myUtility<T extends ExtensionDefinitionParameters>(
|
|
71
|
+
ext: ExtensionDefinition<T>,
|
|
72
|
+
): T['config'] {
|
|
73
|
+
// ...
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The same patterns apply to `ExtensionBlueprint`.
|
|
78
|
+
|
|
79
|
+
This change is made to improve the readability of API references and ability to evolve the type parameters in the future.
|
|
80
|
+
|
|
81
|
+
### Patch Changes
|
|
82
|
+
|
|
83
|
+
- 2bb9517: Introduce the `@backstage/plugin-app` package to hold all of the built-in extensions for easy consumption and overriding.
|
|
84
|
+
- f3a2b91: Moved several implementations of built-in APIs from being hardcoded in the app to instead be provided as API extensions. This moves all API-related inputs from the `app` extension to the respective API extensions. For example, extensions created with `ThemeBlueprint` are now attached to the `themes` input of `api:app-theme` rather than the `app` extension.
|
|
85
|
+
- 98850de: Added support for defining `replaces` in `createExtensionInput` which will allow extensions to redirect missing `attachTo` points to an input of the created extension.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
export const AppThemeApi = ApiBlueprint.makeWithOverrides({
|
|
89
|
+
name: 'app-theme',
|
|
90
|
+
inputs: {
|
|
91
|
+
themes: createExtensionInput([ThemeBlueprint.dataRefs.theme], {
|
|
92
|
+
// attachTo: { id: 'app', input: 'themes'} will be redirected to this input instead
|
|
93
|
+
replaces: [{ id: 'app', input: 'themes' }],
|
|
94
|
+
}),
|
|
95
|
+
},
|
|
96
|
+
factory: () {
|
|
97
|
+
...
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
- 4a66456: A new `apis` parameter has been added to `factory` for extensions. This is a way to access utility APIs without being coupled to the React context.
|
|
103
|
+
- Updated dependencies
|
|
104
|
+
- @backstage/core-components@0.14.10
|
|
105
|
+
- @backstage/core-plugin-api@1.9.3
|
|
106
|
+
- @backstage/types@1.1.1
|
|
107
|
+
- @backstage/version-bridge@1.0.8
|
|
108
|
+
|
|
3
109
|
## 0.7.0
|
|
4
110
|
|
|
5
111
|
### Minor Changes
|
|
@@ -9,7 +9,7 @@ const factoryDataRef = createExtensionDataRef().with({
|
|
|
9
9
|
});
|
|
10
10
|
const ApiBlueprint = createExtensionBlueprint({
|
|
11
11
|
kind: "api",
|
|
12
|
-
attachTo: { id: "
|
|
12
|
+
attachTo: { id: "root", input: "apis" },
|
|
13
13
|
output: [factoryDataRef],
|
|
14
14
|
dataRefs: {
|
|
15
15
|
factory: factoryDataRef
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiBlueprint.esm.js","sources":["../../src/blueprints/ApiBlueprint.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 { AnyApiFactory } from '@backstage/core-plugin-api';\n\nconst factoryDataRef = createExtensionDataRef<AnyApiFactory>().with({\n id: 'core.api.factory',\n});\n\n/**\n * Creates utility API extensions.\n *\n * @public\n */\nexport const ApiBlueprint = createExtensionBlueprint({\n kind: 'api',\n attachTo: { id: '
|
|
1
|
+
{"version":3,"file":"ApiBlueprint.esm.js","sources":["../../src/blueprints/ApiBlueprint.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 { AnyApiFactory } from '@backstage/core-plugin-api';\n\nconst factoryDataRef = createExtensionDataRef<AnyApiFactory>().with({\n id: 'core.api.factory',\n});\n\n/**\n * Creates utility API extensions.\n *\n * @public\n */\nexport const ApiBlueprint = createExtensionBlueprint({\n kind: 'api',\n attachTo: { id: 'root', input: 'apis' },\n output: [factoryDataRef],\n dataRefs: {\n factory: factoryDataRef,\n },\n *factory(params: { factory: AnyApiFactory }) {\n yield factoryDataRef(params.factory);\n },\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,cAAA,GAAiB,sBAAsC,EAAA,CAAE,IAAK,CAAA;AAAA,EAClE,EAAI,EAAA,kBAAA;AACN,CAAC,CAAA,CAAA;AAOM,MAAM,eAAe,wBAAyB,CAAA;AAAA,EACnD,IAAM,EAAA,KAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,MAAA,EAAQ,OAAO,MAAO,EAAA;AAAA,EACtC,MAAA,EAAQ,CAAC,cAAc,CAAA;AAAA,EACvB,QAAU,EAAA;AAAA,IACR,OAAS,EAAA,cAAA;AAAA,GACX;AAAA,EACA,CAAC,QAAQ,MAAoC,EAAA;AAC3C,IAAM,MAAA,cAAA,CAAe,OAAO,OAAO,CAAA,CAAA;AAAA,GACrC;AACF,CAAC;;;;"}
|
|
@@ -7,8 +7,7 @@ import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm
|
|
|
7
7
|
const iconsDataRef = createExtensionDataRef().with({ id: "core.icons" });
|
|
8
8
|
const IconBundleBlueprint = createExtensionBlueprint({
|
|
9
9
|
kind: "icon-bundle",
|
|
10
|
-
|
|
11
|
-
attachTo: { id: "app", input: "icons" },
|
|
10
|
+
attachTo: { id: "api:app/icons", input: "icons" },
|
|
12
11
|
output: [iconsDataRef],
|
|
13
12
|
config: {
|
|
14
13
|
schema: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconBundleBlueprint.esm.js","sources":["../../src/blueprints/IconBundleBlueprint.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 { IconComponent } from '../icons';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst iconsDataRef = createExtensionDataRef<{\n [key in string]: IconComponent;\n}>().with({ id: 'core.icons' });\n\n/** @public */\nexport const IconBundleBlueprint = createExtensionBlueprint({\n kind: 'icon-bundle',\n
|
|
1
|
+
{"version":3,"file":"IconBundleBlueprint.esm.js","sources":["../../src/blueprints/IconBundleBlueprint.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 { IconComponent } from '../icons';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst iconsDataRef = createExtensionDataRef<{\n [key in string]: IconComponent;\n}>().with({ id: 'core.icons' });\n\n/** @public */\nexport const IconBundleBlueprint = createExtensionBlueprint({\n kind: 'icon-bundle',\n attachTo: { id: 'api:app/icons', input: 'icons' },\n output: [iconsDataRef],\n config: {\n schema: {\n icons: z => z.string().default('blob'),\n test: z => z.string(),\n },\n },\n factory: (params: { icons: { [key in string]: IconComponent } }) => [\n iconsDataRef(params.icons),\n ],\n dataRefs: {\n icons: iconsDataRef,\n },\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,eAAe,sBAElB,EAAA,CAAE,KAAK,EAAE,EAAA,EAAI,cAAc,CAAA,CAAA;AAGvB,MAAM,sBAAsB,wBAAyB,CAAA;AAAA,EAC1D,IAAM,EAAA,aAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,eAAA,EAAiB,OAAO,OAAQ,EAAA;AAAA,EAChD,MAAA,EAAQ,CAAC,YAAY,CAAA;AAAA,EACrB,MAAQ,EAAA;AAAA,IACN,MAAQ,EAAA;AAAA,MACN,OAAO,CAAK,CAAA,KAAA,CAAA,CAAE,MAAO,EAAA,CAAE,QAAQ,MAAM,CAAA;AAAA,MACrC,IAAA,EAAM,CAAK,CAAA,KAAA,CAAA,CAAE,MAAO,EAAA;AAAA,KACtB;AAAA,GACF;AAAA,EACA,OAAA,EAAS,CAAC,MAA0D,KAAA;AAAA,IAClE,YAAA,CAAa,OAAO,KAAK,CAAA;AAAA,GAC3B;AAAA,EACA,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,YAAA;AAAA,GACT;AACF,CAAC;;;;"}
|
|
@@ -9,8 +9,7 @@ const themeDataRef = createExtensionDataRef().with({
|
|
|
9
9
|
});
|
|
10
10
|
const ThemeBlueprint = createExtensionBlueprint({
|
|
11
11
|
kind: "theme",
|
|
12
|
-
|
|
13
|
-
attachTo: { id: "app", input: "themes" },
|
|
12
|
+
attachTo: { id: "api:app/app-theme", input: "themes" },
|
|
14
13
|
output: [themeDataRef],
|
|
15
14
|
dataRefs: {
|
|
16
15
|
theme: themeDataRef
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeBlueprint.esm.js","sources":["../../src/blueprints/ThemeBlueprint.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 { AppTheme } from '@backstage/core-plugin-api';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst themeDataRef = createExtensionDataRef<AppTheme>().with({\n id: 'core.theme.theme',\n});\n\n/**\n * Creates an extension that adds/replaces an app theme.\n *\n * @public\n */\nexport const ThemeBlueprint = createExtensionBlueprint({\n kind: 'theme',\n
|
|
1
|
+
{"version":3,"file":"ThemeBlueprint.esm.js","sources":["../../src/blueprints/ThemeBlueprint.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 { AppTheme } from '@backstage/core-plugin-api';\nimport { createExtensionBlueprint, createExtensionDataRef } from '../wiring';\n\nconst themeDataRef = createExtensionDataRef<AppTheme>().with({\n id: 'core.theme.theme',\n});\n\n/**\n * Creates an extension that adds/replaces an app theme.\n *\n * @public\n */\nexport const ThemeBlueprint = createExtensionBlueprint({\n kind: 'theme',\n attachTo: { id: 'api:app/app-theme', input: 'themes' },\n output: [themeDataRef],\n dataRefs: {\n theme: themeDataRef,\n },\n factory: ({ theme }: { theme: AppTheme }) => [themeDataRef(theme)],\n});\n"],"names":[],"mappings":";;;;;;AAmBA,MAAM,YAAA,GAAe,sBAAiC,EAAA,CAAE,IAAK,CAAA;AAAA,EAC3D,EAAI,EAAA,kBAAA;AACN,CAAC,CAAA,CAAA;AAOM,MAAM,iBAAiB,wBAAyB,CAAA;AAAA,EACrD,IAAM,EAAA,OAAA;AAAA,EACN,QAAU,EAAA,EAAE,EAAI,EAAA,mBAAA,EAAqB,OAAO,QAAS,EAAA;AAAA,EACrD,MAAA,EAAQ,CAAC,YAAY,CAAA;AAAA,EACrB,QAAU,EAAA;AAAA,IACR,KAAO,EAAA,YAAA;AAAA,GACT;AAAA,EACA,OAAA,EAAS,CAAC,EAAE,KAAA,OAAiC,CAAC,YAAA,CAAa,KAAK,CAAC,CAAA;AACnE,CAAC;;;;"}
|
|
@@ -7,7 +7,7 @@ import { createExtensionBlueprint } from '../wiring/createExtensionBlueprint.esm
|
|
|
7
7
|
const translationDataRef = createExtensionDataRef().with({ id: "core.translation.translation" });
|
|
8
8
|
const TranslationBlueprint = createExtensionBlueprint({
|
|
9
9
|
kind: "translation",
|
|
10
|
-
attachTo: { id: "app", input: "translations" },
|
|
10
|
+
attachTo: { id: "api:app/translations", input: "translations" },
|
|
11
11
|
output: [translationDataRef],
|
|
12
12
|
dataRefs: {
|
|
13
13
|
translation: translationDataRef
|
|
@@ -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, 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: 'app', 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,
|
|
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;;;;"}
|
|
@@ -6,36 +6,31 @@ import { createExtensionDataRef } from '../wiring/createExtensionDataRef.esm.js'
|
|
|
6
6
|
function createComponentExtension(options) {
|
|
7
7
|
return createExtension({
|
|
8
8
|
kind: "component",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
attachTo: { id: "app", input: "components" },
|
|
12
|
-
inputs: options.inputs,
|
|
9
|
+
name: options.name ?? options.ref.id,
|
|
10
|
+
attachTo: { id: "api:app/components", input: "components" },
|
|
13
11
|
disabled: options.disabled,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
component: createComponentExtension.componentDataRef
|
|
17
|
-
},
|
|
18
|
-
factory({ config, inputs }) {
|
|
12
|
+
output: [createComponentExtension.componentDataRef],
|
|
13
|
+
factory() {
|
|
19
14
|
if ("sync" in options.loader) {
|
|
20
|
-
return
|
|
21
|
-
|
|
15
|
+
return [
|
|
16
|
+
createComponentExtension.componentDataRef({
|
|
22
17
|
ref: options.ref,
|
|
23
|
-
impl: options.loader.sync(
|
|
24
|
-
}
|
|
25
|
-
|
|
18
|
+
impl: options.loader.sync()
|
|
19
|
+
})
|
|
20
|
+
];
|
|
26
21
|
}
|
|
27
22
|
const lazyLoader = options.loader.lazy;
|
|
28
23
|
const ExtensionComponent = lazy(
|
|
29
|
-
() => lazyLoader(
|
|
24
|
+
() => lazyLoader().then((Component) => ({
|
|
30
25
|
default: Component
|
|
31
26
|
}))
|
|
32
27
|
);
|
|
33
|
-
return
|
|
34
|
-
|
|
28
|
+
return [
|
|
29
|
+
createComponentExtension.componentDataRef({
|
|
35
30
|
ref: options.ref,
|
|
36
31
|
impl: ExtensionComponent
|
|
37
|
-
}
|
|
38
|
-
|
|
32
|
+
})
|
|
33
|
+
];
|
|
39
34
|
}
|
|
40
35
|
});
|
|
41
36
|
}
|
|
@@ -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 name: options.name ?? options.ref.id,\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,IAAM,EAAA,OAAA,CAAQ,IAAQ,IAAA,OAAA,CAAQ,GAAI,CAAA,EAAA;AAAA,IAClC,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;;;;"}
|