@backstage/frontend-app-api 0.3.0-next.0 → 0.3.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @backstage/frontend-app-api
2
2
 
3
+ ## 0.3.0-next.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fe6d09953d: Fix for app node output IDs not being serialized correctly.
8
+ - 77f009b35d: Internal updates to match changes in the experimental `@backstage/frontend-plugin-api`.
9
+ - 4d6fa921db: Internal refactor to rename the app graph to app tree
10
+ - Updated dependencies
11
+ - @backstage/frontend-plugin-api@0.3.0-next.1
12
+ - @backstage/plugin-graphiql@0.3.0-next.1
13
+ - @backstage/core-components@0.13.8-next.1
14
+ - @backstage/config@1.1.1
15
+ - @backstage/core-app-api@1.11.1-next.0
16
+ - @backstage/core-plugin-api@1.8.0-next.0
17
+ - @backstage/theme@0.4.4-next.0
18
+ - @backstage/types@1.1.1
19
+ - @backstage/version-bridge@1.0.7-next.0
20
+
3
21
  ## 0.3.0-next.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.esm.js CHANGED
@@ -60,10 +60,10 @@ const Core = createExtension({
60
60
  output: {
61
61
  root: coreExtensionData.reactElement
62
62
  },
63
- factory({ bind, inputs }) {
64
- bind({
63
+ factory({ inputs }) {
64
+ return {
65
65
  root: inputs.root.element
66
- });
66
+ };
67
67
  }
68
68
  });
69
69
 
@@ -80,7 +80,7 @@ const CoreRoutes = createExtension({
80
80
  output: {
81
81
  element: coreExtensionData.reactElement
82
82
  },
83
- factory({ bind, inputs }) {
83
+ factory({ inputs }) {
84
84
  const Routes = () => {
85
85
  const element = useRoutes(
86
86
  inputs.routes.map((route) => ({
@@ -90,9 +90,9 @@ const CoreRoutes = createExtension({
90
90
  );
91
91
  return element;
92
92
  };
93
- bind({
93
+ return {
94
94
  element: /* @__PURE__ */ React.createElement(Routes, null)
95
- });
95
+ };
96
96
  }
97
97
  });
98
98
 
@@ -116,10 +116,10 @@ const CoreLayout = createExtension({
116
116
  output: {
117
117
  element: coreExtensionData.reactElement
118
118
  },
119
- factory({ bind, inputs }) {
120
- bind({
119
+ factory({ inputs }) {
120
+ return {
121
121
  element: /* @__PURE__ */ React.createElement(SidebarPage, null, inputs.nav.element, inputs.content.element)
122
- });
122
+ };
123
123
  }
124
124
  });
125
125
 
@@ -214,10 +214,10 @@ const CoreNav = createExtension({
214
214
  output: {
215
215
  element: coreExtensionData.reactElement
216
216
  },
217
- factory({ bind, inputs }) {
218
- bind({
217
+ factory({ inputs }) {
218
+ return {
219
219
  element: /* @__PURE__ */ React.createElement(Sidebar, null, /* @__PURE__ */ React.createElement(SidebarLogo, null), /* @__PURE__ */ React.createElement(SidebarDivider, null), inputs.items.map((item, index) => /* @__PURE__ */ React.createElement(SidebarNavItem, { ...item.target, key: index })))
220
- });
220
+ };
221
221
  }
222
222
  });
223
223
 
@@ -1827,7 +1827,7 @@ class SerializableAppNode {
1827
1827
  }
1828
1828
  toString() {
1829
1829
  const dataRefs = this.instance && [...this.instance.getDataRefs()];
1830
- const out = dataRefs && dataRefs.length > 0 ? ` out=[${[...dataRefs.keys()].join(", ")}]` : "";
1830
+ const out = dataRefs && dataRefs.length > 0 ? ` out=[${[...dataRefs].map((r) => r.id).join(", ")}]` : "";
1831
1831
  if (this.edges.attachments.size === 0) {
1832
1832
  return `<${this.spec.id}${out} />`;
1833
1833
  }
@@ -1840,7 +1840,7 @@ class SerializableAppNode {
1840
1840
  ].join("\n");
1841
1841
  }
1842
1842
  }
1843
- function resolveAppGraph(rootNodeId, specs) {
1843
+ function resolveAppTree(rootNodeId, specs) {
1844
1844
  const nodes = /* @__PURE__ */ new Map();
1845
1845
  let rootNode = void 0;
1846
1846
  const orphansByParent = /* @__PURE__ */ new Map();
@@ -1874,7 +1874,7 @@ function resolveAppGraph(rootNodeId, specs) {
1874
1874
  }
1875
1875
  }
1876
1876
  if (!rootNode) {
1877
- throw new Error(`No root node with id '${rootNodeId}' found in app graph`);
1877
+ throw new Error(`No root node with id '${rootNodeId}' found in app tree`);
1878
1878
  }
1879
1879
  return {
1880
1880
  root: rootNode,
@@ -2035,7 +2035,7 @@ function resolveAppNodeSpecs(options) {
2035
2035
  throw new Error(`Extension ${extensionId} does not exist`);
2036
2036
  }
2037
2037
  }
2038
- return configuredExtensions.filter((override) => !override.params.disabled).map((param) => ({
2038
+ return configuredExtensions.map((param) => ({
2039
2039
  id: param.extension.id,
2040
2040
  attachTo: param.params.attachTo,
2041
2041
  extension: param.extension,
@@ -2106,26 +2106,24 @@ function createAppNodeInstance(options) {
2106
2106
  );
2107
2107
  }
2108
2108
  try {
2109
- extension.factory({
2109
+ const namedOutputs = extension.factory({
2110
2110
  source,
2111
2111
  config: parsedConfig,
2112
- bind: (namedOutputs) => {
2113
- for (const [name, output] of Object.entries(namedOutputs)) {
2114
- const ref = extension.output[name];
2115
- if (!ref) {
2116
- throw new Error(`unknown output provided via '${name}'`);
2117
- }
2118
- if (extensionData.has(ref.id)) {
2119
- throw new Error(
2120
- `duplicate extension data '${ref.id}' received via output '${name}'`
2121
- );
2122
- }
2123
- extensionData.set(ref.id, output);
2124
- extensionDataRefs.add(ref);
2125
- }
2126
- },
2127
2112
  inputs: resolveInputs(extension.inputs, attachments)
2128
2113
  });
2114
+ for (const [name, output] of Object.entries(namedOutputs)) {
2115
+ const ref = extension.output[name];
2116
+ if (!ref) {
2117
+ throw new Error(`unknown output provided via '${name}'`);
2118
+ }
2119
+ if (extensionData.has(ref.id)) {
2120
+ throw new Error(
2121
+ `duplicate extension data '${ref.id}' received via output '${name}'`
2122
+ );
2123
+ }
2124
+ extensionData.set(ref.id, output);
2125
+ extensionDataRefs.add(ref);
2126
+ }
2129
2127
  } catch (e) {
2130
2128
  throw new Error(
2131
2129
  `Failed to instantiate extension '${id}'${e.name === "Error" ? `, ${e.message}` : `; caused by ${e}`}`
@@ -2168,8 +2166,8 @@ function instantiateAppNodeTree(rootNode) {
2168
2166
  createInstance(rootNode);
2169
2167
  }
2170
2168
 
2171
- function createAppGraph(options) {
2172
- const appGraph = resolveAppGraph(
2169
+ function createAppTree(options) {
2170
+ const tree = resolveAppTree(
2173
2171
  "core",
2174
2172
  resolveAppNodeSpecs({
2175
2173
  features: options.features,
@@ -2178,8 +2176,8 @@ function createAppGraph(options) {
2178
2176
  forbidden: /* @__PURE__ */ new Set(["core"])
2179
2177
  })
2180
2178
  );
2181
- instantiateAppNodeTree(appGraph.root);
2182
- return appGraph;
2179
+ instantiateAppNodeTree(tree.root);
2180
+ return tree;
2183
2181
  }
2184
2182
 
2185
2183
  const builtinExtensions = [
@@ -2192,7 +2190,7 @@ const builtinExtensions = [
2192
2190
  ];
2193
2191
  function createExtensionTree(options) {
2194
2192
  const features = getAvailableFeatures(options.config);
2195
- const graph = createAppGraph({
2193
+ const tree = createAppTree({
2196
2194
  features,
2197
2195
  builtinExtensions,
2198
2196
  config: options.config
@@ -2208,11 +2206,11 @@ function createExtensionTree(options) {
2208
2206
  }
2209
2207
  return {
2210
2208
  getExtension(id) {
2211
- return convertNode(graph.nodes.get(id));
2209
+ return convertNode(tree.nodes.get(id));
2212
2210
  },
2213
2211
  getExtensionAttachments(id, inputName) {
2214
2212
  var _a, _b, _c;
2215
- return (_c = (_b = (_a = graph.nodes.get(id)) == null ? void 0 : _a.edges.attachments.get(inputName)) == null ? void 0 : _b.map(convertNode).filter((node) => Boolean(node))) != null ? _c : [];
2213
+ return (_c = (_b = (_a = tree.nodes.get(id)) == null ? void 0 : _a.edges.attachments.get(inputName)) == null ? void 0 : _b.map(convertNode).filter((node) => Boolean(node))) != null ? _c : [];
2216
2214
  },
2217
2215
  getRootRoutes() {
2218
2216
  return this.getExtensionAttachments("core.routes", "routes").map((node) => {
@@ -2279,7 +2277,7 @@ function createApp(options) {
2279
2277
  ...loadedFeatures,
2280
2278
  ...(_e = options.features) != null ? _e : []
2281
2279
  ]);
2282
- const appGraph = createAppGraph({
2280
+ const tree = createAppTree({
2283
2281
  features: allFeatures,
2284
2282
  builtinExtensions,
2285
2283
  config
@@ -2290,19 +2288,17 @@ function createApp(options) {
2290
2288
  )
2291
2289
  );
2292
2290
  const routeIds = collectRouteIds(allFeatures);
2293
- const App = () => /* @__PURE__ */ React.createElement(ApiProvider, { apis: createApiHolder(appGraph.root, config) }, /* @__PURE__ */ React.createElement(AppContextProvider, { appContext }, /* @__PURE__ */ React.createElement(AppThemeProvider, null, /* @__PURE__ */ React.createElement(
2291
+ const App = () => /* @__PURE__ */ React.createElement(ApiProvider, { apis: createApiHolder(tree.root, config) }, /* @__PURE__ */ React.createElement(AppContextProvider, { appContext }, /* @__PURE__ */ React.createElement(AppThemeProvider, null, /* @__PURE__ */ React.createElement(
2294
2292
  RoutingProvider,
2295
2293
  {
2296
- ...extractRouteInfoFromAppNode(appGraph.root),
2294
+ ...extractRouteInfoFromAppNode(tree.root),
2297
2295
  routeBindings: resolveRouteBindings(
2298
2296
  options.bindRoutes,
2299
2297
  config,
2300
2298
  routeIds
2301
2299
  )
2302
2300
  },
2303
- /* @__PURE__ */ React.createElement(BrowserRouter, null, appGraph.root.instance.getData(
2304
- coreExtensionData.reactElement
2305
- ))
2301
+ /* @__PURE__ */ React.createElement(BrowserRouter, null, tree.root.instance.getData(coreExtensionData.reactElement))
2306
2302
  ))));
2307
2303
  return { default: App };
2308
2304
  }