@backstage/frontend-plugin-api 0.6.4 → 0.6.5-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/dist/analytics/AnalyticsContext.esm.js +31 -0
- package/dist/analytics/AnalyticsContext.esm.js.map +1 -0
- package/dist/analytics/Tracker.esm.js +93 -0
- package/dist/analytics/Tracker.esm.js.map +1 -0
- package/dist/analytics/useAnalytics.esm.js +38 -0
- package/dist/analytics/useAnalytics.esm.js.map +1 -0
- package/dist/apis/definitions/AnalyticsApi.esm.js +8 -0
- package/dist/apis/definitions/AnalyticsApi.esm.js.map +1 -0
- package/dist/apis/definitions/AppTreeApi.esm.js +6 -0
- package/dist/apis/definitions/AppTreeApi.esm.js.map +1 -0
- package/dist/apis/definitions/ComponentsApi.esm.js +12 -0
- package/dist/apis/definitions/ComponentsApi.esm.js.map +1 -0
- package/dist/apis/definitions/IconsApi.esm.js +8 -0
- package/dist/apis/definitions/IconsApi.esm.js.map +1 -0
- package/dist/apis/definitions/RouteResolutionApi.esm.js +8 -0
- package/dist/apis/definitions/RouteResolutionApi.esm.js.map +1 -0
- package/dist/components/ErrorBoundary.esm.js +38 -0
- package/dist/components/ErrorBoundary.esm.js.map +1 -0
- package/dist/components/ExtensionBoundary.esm.js +36 -0
- package/dist/components/ExtensionBoundary.esm.js.map +1 -0
- package/dist/components/coreComponentRefs.esm.js +19 -0
- package/dist/components/coreComponentRefs.esm.js.map +1 -0
- package/dist/components/createComponentRef.esm.js +12 -0
- package/dist/components/createComponentRef.esm.js.map +1 -0
- package/dist/core-plugin-api/src/analytics/Tracker.esm.js +14 -0
- package/dist/core-plugin-api/src/analytics/Tracker.esm.js.map +1 -0
- package/dist/extensions/createApiExtension.esm.js +31 -0
- package/dist/extensions/createApiExtension.esm.js.map +1 -0
- package/dist/extensions/createAppRootElementExtension.esm.js +26 -0
- package/dist/extensions/createAppRootElementExtension.esm.js.map +1 -0
- package/dist/extensions/createAppRootWrapperExtension.esm.js +35 -0
- package/dist/extensions/createAppRootWrapperExtension.esm.js.map +1 -0
- package/dist/extensions/createComponentExtension.esm.js +46 -0
- package/dist/extensions/createComponentExtension.esm.js.map +1 -0
- package/dist/extensions/createNavItemExtension.esm.js +34 -0
- package/dist/extensions/createNavItemExtension.esm.js.map +1 -0
- package/dist/extensions/createNavLogoExtension.esm.js +29 -0
- package/dist/extensions/createNavLogoExtension.esm.js.map +1 -0
- package/dist/extensions/createPageExtension.esm.js +39 -0
- package/dist/extensions/createPageExtension.esm.js.map +1 -0
- package/dist/extensions/createRouterExtension.esm.js +35 -0
- package/dist/extensions/createRouterExtension.esm.js.map +1 -0
- package/dist/extensions/createSignInPageExtension.esm.js +34 -0
- package/dist/extensions/createSignInPageExtension.esm.js.map +1 -0
- package/dist/extensions/createThemeExtension.esm.js +21 -0
- package/dist/extensions/createThemeExtension.esm.js.map +1 -0
- package/dist/extensions/createTranslationExtension.esm.js +21 -0
- package/dist/extensions/createTranslationExtension.esm.js.map +1 -0
- package/dist/index.esm.js +33 -969
- package/dist/index.esm.js.map +1 -1
- package/dist/routing/ExternalRouteRef.esm.js +32 -0
- package/dist/routing/ExternalRouteRef.esm.js.map +1 -0
- package/dist/routing/RouteRef.esm.js +86 -0
- package/dist/routing/RouteRef.esm.js.map +1 -0
- package/dist/routing/SubRouteRef.esm.js +86 -0
- package/dist/routing/SubRouteRef.esm.js.map +1 -0
- package/dist/routing/describeParentCallSite.esm.js +24 -0
- package/dist/routing/describeParentCallSite.esm.js.map +1 -0
- package/dist/routing/useRouteRef.esm.js +25 -0
- package/dist/routing/useRouteRef.esm.js.map +1 -0
- package/dist/routing/useRouteRefParams.esm.js +8 -0
- package/dist/routing/useRouteRefParams.esm.js.map +1 -0
- package/dist/schema/createSchemaFromZod.esm.js +34 -0
- package/dist/schema/createSchemaFromZod.esm.js.map +1 -0
- package/dist/wiring/coreExtensionData.esm.js +10 -0
- package/dist/wiring/coreExtensionData.esm.js.map +1 -0
- package/dist/wiring/createExtension.esm.js +52 -0
- package/dist/wiring/createExtension.esm.js.map +1 -0
- package/dist/wiring/createExtensionDataRef.esm.js +20 -0
- package/dist/wiring/createExtensionDataRef.esm.js.map +1 -0
- package/dist/wiring/createExtensionInput.esm.js +13 -0
- package/dist/wiring/createExtensionInput.esm.js.map +1 -0
- package/dist/wiring/createExtensionOverrides.esm.js +23 -0
- package/dist/wiring/createExtensionOverrides.esm.js.map +1 -0
- package/dist/wiring/createPlugin.esm.js +36 -0
- package/dist/wiring/createPlugin.esm.js.map +1 -0
- package/dist/wiring/resolveExtensionDefinition.esm.js +27 -0
- package/dist/wiring/resolveExtensionDefinition.esm.js.map +1 -0
- package/package.json +6 -6
package/dist/index.esm.js
CHANGED
|
@@ -1,972 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { AnalyticsContext } from './analytics/AnalyticsContext.esm.js';
|
|
2
|
+
export { useAnalytics } from './analytics/useAnalytics.esm.js';
|
|
3
|
+
export { appTreeApiRef } from './apis/definitions/AppTreeApi.esm.js';
|
|
4
4
|
export { SessionState, 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';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export { componentsApiRef, useComponentRef } from './apis/definitions/ComponentsApi.esm.js';
|
|
6
|
+
export { iconsApiRef } from './apis/definitions/IconsApi.esm.js';
|
|
7
|
+
export { routeResolutionApiRef } from './apis/definitions/RouteResolutionApi.esm.js';
|
|
8
|
+
export { analyticsApiRef } from './apis/definitions/AnalyticsApi.esm.js';
|
|
9
|
+
export { ExtensionBoundary } from './components/ExtensionBoundary.esm.js';
|
|
10
|
+
export { coreComponentRefs } from './components/coreComponentRefs.esm.js';
|
|
11
|
+
export { createComponentRef } from './components/createComponentRef.esm.js';
|
|
12
|
+
export { createApiExtension } from './extensions/createApiExtension.esm.js';
|
|
13
|
+
export { createAppRootElementExtension } from './extensions/createAppRootElementExtension.esm.js';
|
|
14
|
+
export { createAppRootWrapperExtension } from './extensions/createAppRootWrapperExtension.esm.js';
|
|
15
|
+
export { createRouterExtension } from './extensions/createRouterExtension.esm.js';
|
|
16
|
+
export { createPageExtension } from './extensions/createPageExtension.esm.js';
|
|
17
|
+
export { createNavItemExtension } from './extensions/createNavItemExtension.esm.js';
|
|
18
|
+
export { createNavLogoExtension } from './extensions/createNavLogoExtension.esm.js';
|
|
19
|
+
export { createSignInPageExtension } from './extensions/createSignInPageExtension.esm.js';
|
|
20
|
+
export { createThemeExtension } from './extensions/createThemeExtension.esm.js';
|
|
21
|
+
export { createComponentExtension } from './extensions/createComponentExtension.esm.js';
|
|
22
|
+
export { createTranslationExtension } from './extensions/createTranslationExtension.esm.js';
|
|
23
|
+
export { createRouteRef } from './routing/RouteRef.esm.js';
|
|
24
|
+
export { createSubRouteRef } from './routing/SubRouteRef.esm.js';
|
|
25
|
+
export { createExternalRouteRef } from './routing/ExternalRouteRef.esm.js';
|
|
26
|
+
export { useRouteRef } from './routing/useRouteRef.esm.js';
|
|
27
|
+
export { useRouteRefParams } from './routing/useRouteRefParams.esm.js';
|
|
28
|
+
export { createSchemaFromZod } from './schema/createSchemaFromZod.esm.js';
|
|
8
29
|
export { createTranslationMessages, createTranslationRef, createTranslationResource, useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
pluginId: "app",
|
|
16
|
-
extensionId: "app"
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
const theValue = theContext.atVersion(1);
|
|
20
|
-
if (theValue === void 0) {
|
|
21
|
-
throw new Error("No context found for version 1.");
|
|
22
|
-
}
|
|
23
|
-
return theValue;
|
|
24
|
-
};
|
|
25
|
-
const AnalyticsContext = (options) => {
|
|
26
|
-
const { attributes, children } = options;
|
|
27
|
-
const parentValues = useAnalyticsContext();
|
|
28
|
-
const combinedValue = {
|
|
29
|
-
...parentValues,
|
|
30
|
-
...attributes
|
|
31
|
-
};
|
|
32
|
-
const versionedCombinedValue = createVersionedValueMap({ 1: combinedValue });
|
|
33
|
-
return /* @__PURE__ */ React.createElement(AnalyticsReactContext.Provider, { value: versionedCombinedValue }, children);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const appTreeApiRef = createApiRef({ id: "core.app-tree" });
|
|
37
|
-
|
|
38
|
-
const componentsApiRef = createApiRef({
|
|
39
|
-
id: "core.components"
|
|
40
|
-
});
|
|
41
|
-
function useComponentRef(ref) {
|
|
42
|
-
const componentsApi = useApi(componentsApiRef);
|
|
43
|
-
return componentsApi.getComponent(ref);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const iconsApiRef = createApiRef({
|
|
47
|
-
id: "core.icons"
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const routeResolutionApiRef = createApiRef({
|
|
51
|
-
id: "core.route-resolution"
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const analyticsApiRef = createApiRef({
|
|
55
|
-
id: "core.analytics"
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const globalEvents = getOrCreateGlobalSingleton(
|
|
59
|
-
"core-plugin-api:analytics-tracker-events",
|
|
60
|
-
() => ({
|
|
61
|
-
mostRecentGatheredNavigation: void 0,
|
|
62
|
-
mostRecentRoutableExtensionRender: void 0,
|
|
63
|
-
beforeUnloadRegistered: false
|
|
64
|
-
})
|
|
65
|
-
);
|
|
66
|
-
const routableExtensionRenderedEvent$1 = "_ROUTABLE-EXTENSION-RENDERED";
|
|
67
|
-
class Tracker {
|
|
68
|
-
constructor(analyticsApi, context = {
|
|
69
|
-
pluginId: "root",
|
|
70
|
-
extensionId: "App"
|
|
71
|
-
}) {
|
|
72
|
-
this.analyticsApi = analyticsApi;
|
|
73
|
-
this.context = context;
|
|
74
|
-
if (!globalEvents.beforeUnloadRegistered) {
|
|
75
|
-
addEventListener(
|
|
76
|
-
"beforeunload",
|
|
77
|
-
() => {
|
|
78
|
-
if (globalEvents.mostRecentGatheredNavigation) {
|
|
79
|
-
this.analyticsApi.captureEvent({
|
|
80
|
-
...globalEvents.mostRecentGatheredNavigation,
|
|
81
|
-
...globalEvents.mostRecentRoutableExtensionRender
|
|
82
|
-
});
|
|
83
|
-
globalEvents.mostRecentGatheredNavigation = void 0;
|
|
84
|
-
globalEvents.mostRecentRoutableExtensionRender = void 0;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
{ once: true, passive: true }
|
|
88
|
-
);
|
|
89
|
-
globalEvents.beforeUnloadRegistered = true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
setContext(context) {
|
|
93
|
-
this.context = context;
|
|
94
|
-
}
|
|
95
|
-
captureEvent(action, subject, {
|
|
96
|
-
value,
|
|
97
|
-
attributes
|
|
98
|
-
} = {}) {
|
|
99
|
-
const context = this.context;
|
|
100
|
-
if (action === routableExtensionRenderedEvent$1) {
|
|
101
|
-
if (globalEvents.mostRecentGatheredNavigation) {
|
|
102
|
-
globalEvents.mostRecentRoutableExtensionRender = {
|
|
103
|
-
context: {
|
|
104
|
-
...context,
|
|
105
|
-
extensionId: "App"
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (globalEvents.mostRecentGatheredNavigation) {
|
|
112
|
-
try {
|
|
113
|
-
this.analyticsApi.captureEvent({
|
|
114
|
-
...globalEvents.mostRecentGatheredNavigation,
|
|
115
|
-
...globalEvents.mostRecentRoutableExtensionRender
|
|
116
|
-
});
|
|
117
|
-
} catch (e) {
|
|
118
|
-
console.warn("Error during analytics event capture. %o", e);
|
|
119
|
-
}
|
|
120
|
-
globalEvents.mostRecentGatheredNavigation = void 0;
|
|
121
|
-
globalEvents.mostRecentRoutableExtensionRender = void 0;
|
|
122
|
-
}
|
|
123
|
-
if (action === "navigate" && context.pluginId === "root") {
|
|
124
|
-
globalEvents.mostRecentGatheredNavigation = {
|
|
125
|
-
action,
|
|
126
|
-
subject,
|
|
127
|
-
value,
|
|
128
|
-
attributes,
|
|
129
|
-
context
|
|
130
|
-
};
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
try {
|
|
134
|
-
this.analyticsApi.captureEvent({
|
|
135
|
-
action,
|
|
136
|
-
subject,
|
|
137
|
-
value,
|
|
138
|
-
attributes,
|
|
139
|
-
context
|
|
140
|
-
});
|
|
141
|
-
} catch (e) {
|
|
142
|
-
console.warn("Error during analytics event capture. %o", e);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function useAnalyticsApi() {
|
|
148
|
-
try {
|
|
149
|
-
return useApi(analyticsApiRef);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
if (error.name === "NotImplementedError") {
|
|
152
|
-
return { captureEvent: () => {
|
|
153
|
-
} };
|
|
154
|
-
}
|
|
155
|
-
throw error;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function useAnalytics() {
|
|
159
|
-
const trackerRef = useRef(null);
|
|
160
|
-
const context = useAnalyticsContext();
|
|
161
|
-
const analyticsApi = useAnalyticsApi();
|
|
162
|
-
function getTracker() {
|
|
163
|
-
if (trackerRef.current === null) {
|
|
164
|
-
trackerRef.current = new Tracker(analyticsApi);
|
|
165
|
-
}
|
|
166
|
-
return trackerRef.current;
|
|
167
|
-
}
|
|
168
|
-
const tracker = getTracker();
|
|
169
|
-
tracker.setContext(context);
|
|
170
|
-
return tracker;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
var __defProp$3 = Object.defineProperty;
|
|
174
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
175
|
-
var __publicField$3 = (obj, key, value) => {
|
|
176
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
177
|
-
return value;
|
|
178
|
-
};
|
|
179
|
-
class ErrorBoundary extends Component {
|
|
180
|
-
constructor() {
|
|
181
|
-
super(...arguments);
|
|
182
|
-
__publicField$3(this, "state", { error: void 0 });
|
|
183
|
-
__publicField$3(this, "handleErrorReset", () => {
|
|
184
|
-
this.setState({ error: void 0 });
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
static getDerivedStateFromError(error) {
|
|
188
|
-
return { error };
|
|
189
|
-
}
|
|
190
|
-
render() {
|
|
191
|
-
const { error } = this.state;
|
|
192
|
-
const { plugin, children, Fallback } = this.props;
|
|
193
|
-
if (error) {
|
|
194
|
-
return /* @__PURE__ */ React.createElement(
|
|
195
|
-
Fallback,
|
|
196
|
-
{
|
|
197
|
-
plugin,
|
|
198
|
-
error,
|
|
199
|
-
resetError: this.handleErrorReset
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
return children;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
getOrCreateGlobalSingleton(
|
|
208
|
-
"core-plugin-api:analytics-tracker-events",
|
|
209
|
-
() => ({
|
|
210
|
-
mostRecentGatheredNavigation: void 0,
|
|
211
|
-
mostRecentRoutableExtensionRender: void 0,
|
|
212
|
-
beforeUnloadRegistered: false
|
|
213
|
-
})
|
|
214
|
-
);
|
|
215
|
-
const routableExtensionRenderedEvent = "_ROUTABLE-EXTENSION-RENDERED";
|
|
216
|
-
|
|
217
|
-
function createComponentRef(options) {
|
|
218
|
-
const { id } = options;
|
|
219
|
-
return {
|
|
220
|
-
id,
|
|
221
|
-
toString() {
|
|
222
|
-
return `ComponentRef{id=${id}}`;
|
|
223
|
-
}
|
|
224
|
-
};
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
const coreProgressComponentRef = createComponentRef({
|
|
228
|
-
id: "core.components.progress"
|
|
229
|
-
});
|
|
230
|
-
const coreNotFoundErrorPageComponentRef = createComponentRef({
|
|
231
|
-
id: "core.components.notFoundErrorPage"
|
|
232
|
-
});
|
|
233
|
-
const coreErrorBoundaryFallbackComponentRef = createComponentRef({
|
|
234
|
-
id: "core.components.errorBoundaryFallback"
|
|
235
|
-
});
|
|
236
|
-
const coreComponentRefs = {
|
|
237
|
-
progress: coreProgressComponentRef,
|
|
238
|
-
notFoundErrorPage: coreNotFoundErrorPageComponentRef,
|
|
239
|
-
errorBoundaryFallback: coreErrorBoundaryFallbackComponentRef
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
const RouteTracker = (props) => {
|
|
243
|
-
const { disableTracking, children } = props;
|
|
244
|
-
const analytics = useAnalytics$1();
|
|
245
|
-
useEffect(() => {
|
|
246
|
-
if (disableTracking)
|
|
247
|
-
return;
|
|
248
|
-
analytics.captureEvent(routableExtensionRenderedEvent, "");
|
|
249
|
-
}, [analytics, disableTracking]);
|
|
250
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
|
|
251
|
-
};
|
|
252
|
-
function ExtensionBoundary(props) {
|
|
253
|
-
var _a, _b;
|
|
254
|
-
const { node, routable, children } = props;
|
|
255
|
-
const plugin = node.spec.source;
|
|
256
|
-
const Progress = useComponentRef(coreComponentRefs.progress);
|
|
257
|
-
const fallback = useComponentRef(coreComponentRefs.errorBoundaryFallback);
|
|
258
|
-
const attributes = {
|
|
259
|
-
extensionId: node.spec.id,
|
|
260
|
-
pluginId: (_b = (_a = node.spec.source) == null ? void 0 : _a.id) != null ? _b : "app"
|
|
261
|
-
};
|
|
262
|
-
return /* @__PURE__ */ React.createElement(Suspense, { fallback: /* @__PURE__ */ React.createElement(Progress, null) }, /* @__PURE__ */ React.createElement(ErrorBoundary, { plugin, Fallback: fallback }, /* @__PURE__ */ React.createElement(AnalyticsContext$1, { attributes }, /* @__PURE__ */ React.createElement(RouteTracker, { disableTracking: !routable }, children))));
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
function createExtensionDataRef(id) {
|
|
266
|
-
return {
|
|
267
|
-
id,
|
|
268
|
-
$$type: "@backstage/ExtensionDataRef",
|
|
269
|
-
config: {},
|
|
270
|
-
optional() {
|
|
271
|
-
return {
|
|
272
|
-
...this,
|
|
273
|
-
config: { ...this.config, optional: true }
|
|
274
|
-
};
|
|
275
|
-
},
|
|
276
|
-
toString() {
|
|
277
|
-
const optional = Boolean(this.config.optional);
|
|
278
|
-
return `ExtensionDataRef{id=${id},optional=${optional}}`;
|
|
279
|
-
}
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const coreExtensionData = {
|
|
284
|
-
reactElement: createExtensionDataRef("core.reactElement"),
|
|
285
|
-
routePath: createExtensionDataRef("core.routing.path"),
|
|
286
|
-
routeRef: createExtensionDataRef("core.routing.ref")
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
function toInternalExtensionDefinition(overrides) {
|
|
290
|
-
const internal = overrides;
|
|
291
|
-
if (internal.$$type !== "@backstage/ExtensionDefinition") {
|
|
292
|
-
throw new Error(
|
|
293
|
-
`Invalid extension definition instance, bad type '${internal.$$type}'`
|
|
294
|
-
);
|
|
295
|
-
}
|
|
296
|
-
if (internal.version !== "v1") {
|
|
297
|
-
throw new Error(
|
|
298
|
-
`Invalid extension definition instance, bad version '${internal.version}'`
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
return internal;
|
|
302
|
-
}
|
|
303
|
-
function createExtension(options) {
|
|
304
|
-
var _a, _b;
|
|
305
|
-
return {
|
|
306
|
-
$$type: "@backstage/ExtensionDefinition",
|
|
307
|
-
version: "v1",
|
|
308
|
-
kind: options.kind,
|
|
309
|
-
namespace: options.namespace,
|
|
310
|
-
name: options.name,
|
|
311
|
-
attachTo: options.attachTo,
|
|
312
|
-
disabled: (_a = options.disabled) != null ? _a : false,
|
|
313
|
-
inputs: (_b = options.inputs) != null ? _b : {},
|
|
314
|
-
output: options.output,
|
|
315
|
-
configSchema: options.configSchema,
|
|
316
|
-
factory({ inputs, ...rest }) {
|
|
317
|
-
return options.factory({
|
|
318
|
-
inputs,
|
|
319
|
-
...rest
|
|
320
|
-
});
|
|
321
|
-
},
|
|
322
|
-
toString() {
|
|
323
|
-
const parts = [];
|
|
324
|
-
if (options.kind) {
|
|
325
|
-
parts.push(`kind=${options.kind}`);
|
|
326
|
-
}
|
|
327
|
-
if (options.namespace) {
|
|
328
|
-
parts.push(`namespace=${options.namespace}`);
|
|
329
|
-
}
|
|
330
|
-
if (options.name) {
|
|
331
|
-
parts.push(`name=${options.name}`);
|
|
332
|
-
}
|
|
333
|
-
parts.push(`attachTo=${options.attachTo.id}@${options.attachTo.input}`);
|
|
334
|
-
return `ExtensionDefinition{${parts.join(",")}}`;
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function createExtensionInput(extensionData, config) {
|
|
340
|
-
return {
|
|
341
|
-
$$type: "@backstage/ExtensionInput",
|
|
342
|
-
extensionData,
|
|
343
|
-
config: {
|
|
344
|
-
singleton: Boolean(config == null ? void 0 : config.singleton),
|
|
345
|
-
optional: Boolean(config == null ? void 0 : config.optional)
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
function resolveExtensionDefinition(definition, context) {
|
|
351
|
-
var _a;
|
|
352
|
-
const internalDefinition = toInternalExtensionDefinition(definition);
|
|
353
|
-
const { name, kind, namespace: _, ...rest } = internalDefinition;
|
|
354
|
-
const namespace = (_a = internalDefinition.namespace) != null ? _a : context == null ? void 0 : context.namespace;
|
|
355
|
-
const namePart = name && namespace ? `${namespace}/${name}` : namespace || name;
|
|
356
|
-
if (!namePart) {
|
|
357
|
-
throw new Error(
|
|
358
|
-
`Extension must declare an explicit namespace or name as it could not be resolved from context, kind=${kind} namespace=${namespace} name=${name}`
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
const id = kind ? `${kind}:${namePart}` : namePart;
|
|
362
|
-
return {
|
|
363
|
-
...rest,
|
|
364
|
-
$$type: "@backstage/Extension",
|
|
365
|
-
version: "v1",
|
|
366
|
-
id,
|
|
367
|
-
toString() {
|
|
368
|
-
return `Extension{id=${id}}`;
|
|
369
|
-
}
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
function createPlugin(options) {
|
|
374
|
-
var _a, _b, _c, _d;
|
|
375
|
-
const extensions = ((_a = options.extensions) != null ? _a : []).map(
|
|
376
|
-
(def) => resolveExtensionDefinition(def, { namespace: options.id })
|
|
377
|
-
);
|
|
378
|
-
const extensionIds = extensions.map((e) => e.id);
|
|
379
|
-
if (extensionIds.length !== new Set(extensionIds).size) {
|
|
380
|
-
const duplicates = Array.from(
|
|
381
|
-
new Set(
|
|
382
|
-
extensionIds.filter((id, index) => extensionIds.indexOf(id) !== index)
|
|
383
|
-
)
|
|
384
|
-
);
|
|
385
|
-
throw new Error(
|
|
386
|
-
`Plugin '${options.id}' provided duplicate extensions: ${duplicates.join(
|
|
387
|
-
", "
|
|
388
|
-
)}`
|
|
389
|
-
);
|
|
390
|
-
}
|
|
391
|
-
return {
|
|
392
|
-
$$type: "@backstage/BackstagePlugin",
|
|
393
|
-
version: "v1",
|
|
394
|
-
id: options.id,
|
|
395
|
-
routes: (_b = options.routes) != null ? _b : {},
|
|
396
|
-
externalRoutes: (_c = options.externalRoutes) != null ? _c : {},
|
|
397
|
-
featureFlags: (_d = options.featureFlags) != null ? _d : [],
|
|
398
|
-
extensions,
|
|
399
|
-
toString() {
|
|
400
|
-
return `Plugin{id=${options.id}}`;
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
function createExtensionOverrides(options) {
|
|
406
|
-
var _a;
|
|
407
|
-
const extensions = options.extensions.map(
|
|
408
|
-
(def) => resolveExtensionDefinition(def)
|
|
409
|
-
);
|
|
410
|
-
const featureFlags = (_a = options.featureFlags) != null ? _a : [];
|
|
411
|
-
return {
|
|
412
|
-
$$type: "@backstage/ExtensionOverrides",
|
|
413
|
-
version: "v1",
|
|
414
|
-
extensions,
|
|
415
|
-
featureFlags,
|
|
416
|
-
toString() {
|
|
417
|
-
const ex = extensions.map(String).join(",");
|
|
418
|
-
const ff = featureFlags.map((f) => f.name).join(",");
|
|
419
|
-
return `ExtensionOverrides{extensions=[${ex}],featureFlags=[${ff}]}`;
|
|
420
|
-
}
|
|
421
|
-
};
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
function createApiExtension(options) {
|
|
425
|
-
const { factory, configSchema, inputs: extensionInputs } = options;
|
|
426
|
-
const apiRef = "api" in options ? options.api : factory.api;
|
|
427
|
-
return createExtension({
|
|
428
|
-
kind: "api",
|
|
429
|
-
// Since ApiRef IDs use a global namespace we use the namespace here in order to override
|
|
430
|
-
// potential plugin IDs and always end up with the format `api:<api-ref-id>`
|
|
431
|
-
namespace: apiRef.id,
|
|
432
|
-
attachTo: { id: "app", input: "apis" },
|
|
433
|
-
inputs: extensionInputs,
|
|
434
|
-
configSchema,
|
|
435
|
-
output: {
|
|
436
|
-
api: createApiExtension.factoryDataRef
|
|
437
|
-
},
|
|
438
|
-
factory({ config, inputs }) {
|
|
439
|
-
if (typeof factory === "function") {
|
|
440
|
-
return { api: factory({ config, inputs }) };
|
|
441
|
-
}
|
|
442
|
-
return { api: factory };
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
((createApiExtension2) => {
|
|
447
|
-
createApiExtension2.factoryDataRef = createExtensionDataRef("core.api.factory");
|
|
448
|
-
})(createApiExtension || (createApiExtension = {}));
|
|
449
|
-
|
|
450
|
-
function createAppRootElementExtension(options) {
|
|
451
|
-
var _a;
|
|
452
|
-
return createExtension({
|
|
453
|
-
kind: "app-root-element",
|
|
454
|
-
namespace: options.namespace,
|
|
455
|
-
name: options.name,
|
|
456
|
-
attachTo: (_a = options.attachTo) != null ? _a : { id: "app/root", input: "elements" },
|
|
457
|
-
configSchema: options.configSchema,
|
|
458
|
-
disabled: options.disabled,
|
|
459
|
-
inputs: options.inputs,
|
|
460
|
-
output: {
|
|
461
|
-
element: coreExtensionData.reactElement
|
|
462
|
-
},
|
|
463
|
-
factory({ inputs, config }) {
|
|
464
|
-
return {
|
|
465
|
-
element: typeof options.element === "function" ? options.element({ inputs, config }) : options.element
|
|
466
|
-
};
|
|
467
|
-
}
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
function createAppRootWrapperExtension(options) {
|
|
472
|
-
var _a;
|
|
473
|
-
return createExtension({
|
|
474
|
-
kind: "app-root-wrapper",
|
|
475
|
-
namespace: options.namespace,
|
|
476
|
-
name: options.name,
|
|
477
|
-
attachTo: (_a = options.attachTo) != null ? _a : { id: "app/root", input: "wrappers" },
|
|
478
|
-
configSchema: options.configSchema,
|
|
479
|
-
disabled: options.disabled,
|
|
480
|
-
inputs: options.inputs,
|
|
481
|
-
output: {
|
|
482
|
-
component: createAppRootWrapperExtension.componentDataRef
|
|
483
|
-
},
|
|
484
|
-
factory({ inputs, config }) {
|
|
485
|
-
const Component = (props) => {
|
|
486
|
-
return /* @__PURE__ */ React.createElement(options.Component, { inputs, config }, props.children);
|
|
487
|
-
};
|
|
488
|
-
return {
|
|
489
|
-
component: Component
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
});
|
|
493
|
-
}
|
|
494
|
-
((createAppRootWrapperExtension2) => {
|
|
495
|
-
createAppRootWrapperExtension2.componentDataRef = createExtensionDataRef(
|
|
496
|
-
"app.root.wrapper"
|
|
497
|
-
);
|
|
498
|
-
})(createAppRootWrapperExtension || (createAppRootWrapperExtension = {}));
|
|
499
|
-
|
|
500
|
-
function createRouterExtension(options) {
|
|
501
|
-
var _a;
|
|
502
|
-
return createExtension({
|
|
503
|
-
kind: "app-router-component",
|
|
504
|
-
namespace: options.namespace,
|
|
505
|
-
name: options.name,
|
|
506
|
-
attachTo: (_a = options.attachTo) != null ? _a : { id: "app/root", input: "router" },
|
|
507
|
-
configSchema: options.configSchema,
|
|
508
|
-
disabled: options.disabled,
|
|
509
|
-
inputs: options.inputs,
|
|
510
|
-
output: {
|
|
511
|
-
component: createRouterExtension.componentDataRef
|
|
512
|
-
},
|
|
513
|
-
factory({ inputs, config }) {
|
|
514
|
-
const Component = (props) => {
|
|
515
|
-
return /* @__PURE__ */ React.createElement(options.Component, { inputs, config }, props.children);
|
|
516
|
-
};
|
|
517
|
-
return {
|
|
518
|
-
component: Component
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
}
|
|
523
|
-
((createRouterExtension2) => {
|
|
524
|
-
createRouterExtension2.componentDataRef = createExtensionDataRef(
|
|
525
|
-
"app.router.wrapper"
|
|
526
|
-
);
|
|
527
|
-
})(createRouterExtension || (createRouterExtension = {}));
|
|
528
|
-
|
|
529
|
-
function createSchemaFromZod(schemaCreator) {
|
|
530
|
-
const schema = schemaCreator(z);
|
|
531
|
-
return {
|
|
532
|
-
// TODO: Types allow z.array etc here but it will break stuff
|
|
533
|
-
parse: (input) => {
|
|
534
|
-
const result = schema.safeParse(input);
|
|
535
|
-
if (result.success) {
|
|
536
|
-
return result.data;
|
|
537
|
-
}
|
|
538
|
-
throw new Error(result.error.issues.map(formatIssue).join("; "));
|
|
539
|
-
},
|
|
540
|
-
// TODO: Verify why we are not compatible with the latest zodToJsonSchema.
|
|
541
|
-
schema: zodToJsonSchema(schema)
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
function formatIssue(issue) {
|
|
545
|
-
if (issue.code === "invalid_union") {
|
|
546
|
-
return formatIssue(issue.unionErrors[0].issues[0]);
|
|
547
|
-
}
|
|
548
|
-
let message = issue.message;
|
|
549
|
-
if (message === "Required") {
|
|
550
|
-
message = `Missing required value`;
|
|
551
|
-
}
|
|
552
|
-
if (issue.path.length) {
|
|
553
|
-
message += ` at '${issue.path.join(".")}'`;
|
|
554
|
-
}
|
|
555
|
-
return message;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function createPageExtension(options) {
|
|
559
|
-
var _a;
|
|
560
|
-
const configSchema = "configSchema" in options ? options.configSchema : createSchemaFromZod(
|
|
561
|
-
(z) => z.object({ path: z.string().default(options.defaultPath) })
|
|
562
|
-
);
|
|
563
|
-
return createExtension({
|
|
564
|
-
kind: "page",
|
|
565
|
-
namespace: options.namespace,
|
|
566
|
-
name: options.name,
|
|
567
|
-
attachTo: (_a = options.attachTo) != null ? _a : { id: "app/routes", input: "routes" },
|
|
568
|
-
configSchema,
|
|
569
|
-
inputs: options.inputs,
|
|
570
|
-
disabled: options.disabled,
|
|
571
|
-
output: {
|
|
572
|
-
element: coreExtensionData.reactElement,
|
|
573
|
-
path: coreExtensionData.routePath,
|
|
574
|
-
routeRef: coreExtensionData.routeRef.optional()
|
|
575
|
-
},
|
|
576
|
-
factory({ config, inputs, node }) {
|
|
577
|
-
const ExtensionComponent = lazy(
|
|
578
|
-
() => options.loader({ config, inputs }).then((element) => ({ default: () => element }))
|
|
579
|
-
);
|
|
580
|
-
return {
|
|
581
|
-
path: config.path,
|
|
582
|
-
routeRef: options.routeRef,
|
|
583
|
-
element: /* @__PURE__ */ React.createElement(ExtensionBoundary, { node, routable: true }, /* @__PURE__ */ React.createElement(ExtensionComponent, null))
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
function createNavItemExtension(options) {
|
|
590
|
-
const { routeRef, title, icon, namespace, name } = options;
|
|
591
|
-
return createExtension({
|
|
592
|
-
namespace,
|
|
593
|
-
name,
|
|
594
|
-
kind: "nav-item",
|
|
595
|
-
attachTo: { id: "app/nav", input: "items" },
|
|
596
|
-
configSchema: createSchemaFromZod(
|
|
597
|
-
(z) => z.object({
|
|
598
|
-
title: z.string().default(title)
|
|
599
|
-
})
|
|
600
|
-
),
|
|
601
|
-
output: {
|
|
602
|
-
navTarget: createNavItemExtension.targetDataRef
|
|
603
|
-
},
|
|
604
|
-
factory: ({ config }) => ({
|
|
605
|
-
navTarget: {
|
|
606
|
-
title: config.title,
|
|
607
|
-
icon,
|
|
608
|
-
routeRef
|
|
609
|
-
}
|
|
610
|
-
})
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
((createNavItemExtension2) => {
|
|
614
|
-
createNavItemExtension2.targetDataRef = createExtensionDataRef("core.nav-item.target");
|
|
615
|
-
})(createNavItemExtension || (createNavItemExtension = {}));
|
|
616
|
-
|
|
617
|
-
function createNavLogoExtension(options) {
|
|
618
|
-
const { logoIcon, logoFull } = options;
|
|
619
|
-
return createExtension({
|
|
620
|
-
kind: "nav-logo",
|
|
621
|
-
name: options == null ? void 0 : options.name,
|
|
622
|
-
namespace: options == null ? void 0 : options.namespace,
|
|
623
|
-
attachTo: { id: "app/nav", input: "logos" },
|
|
624
|
-
output: {
|
|
625
|
-
logos: createNavLogoExtension.logoElementsDataRef
|
|
626
|
-
},
|
|
627
|
-
factory: () => {
|
|
628
|
-
return {
|
|
629
|
-
logos: {
|
|
630
|
-
logoIcon,
|
|
631
|
-
logoFull
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
((createNavLogoExtension2) => {
|
|
638
|
-
createNavLogoExtension2.logoElementsDataRef = createExtensionDataRef("core.nav-logo.logo-elements");
|
|
639
|
-
})(createNavLogoExtension || (createNavLogoExtension = {}));
|
|
640
|
-
|
|
641
|
-
function createSignInPageExtension(options) {
|
|
642
|
-
var _a;
|
|
643
|
-
return createExtension({
|
|
644
|
-
kind: "sign-in-page",
|
|
645
|
-
namespace: options == null ? void 0 : options.namespace,
|
|
646
|
-
name: options == null ? void 0 : options.name,
|
|
647
|
-
attachTo: (_a = options.attachTo) != null ? _a : { id: "app/root", input: "signInPage" },
|
|
648
|
-
configSchema: options.configSchema,
|
|
649
|
-
inputs: options.inputs,
|
|
650
|
-
disabled: options.disabled,
|
|
651
|
-
output: {
|
|
652
|
-
component: createSignInPageExtension.componentDataRef
|
|
653
|
-
},
|
|
654
|
-
factory({ config, inputs, node }) {
|
|
655
|
-
const ExtensionComponent = lazy(
|
|
656
|
-
() => options.loader({ config, inputs }).then((component) => ({ default: component }))
|
|
657
|
-
);
|
|
658
|
-
return {
|
|
659
|
-
component: (props) => /* @__PURE__ */ React.createElement(ExtensionBoundary, { node, routable: true }, /* @__PURE__ */ React.createElement(ExtensionComponent, { ...props }))
|
|
660
|
-
};
|
|
661
|
-
}
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
((createSignInPageExtension2) => {
|
|
665
|
-
createSignInPageExtension2.componentDataRef = createExtensionDataRef("core.sign-in-page.component");
|
|
666
|
-
})(createSignInPageExtension || (createSignInPageExtension = {}));
|
|
667
|
-
|
|
668
|
-
function createThemeExtension(theme) {
|
|
669
|
-
return createExtension({
|
|
670
|
-
kind: "theme",
|
|
671
|
-
namespace: "app",
|
|
672
|
-
name: theme.id,
|
|
673
|
-
attachTo: { id: "app", input: "themes" },
|
|
674
|
-
output: {
|
|
675
|
-
theme: createThemeExtension.themeDataRef
|
|
676
|
-
},
|
|
677
|
-
factory: () => ({ theme })
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
((createThemeExtension2) => {
|
|
681
|
-
createThemeExtension2.themeDataRef = createExtensionDataRef("core.theme.theme");
|
|
682
|
-
})(createThemeExtension || (createThemeExtension = {}));
|
|
683
|
-
|
|
684
|
-
function createComponentExtension(options) {
|
|
685
|
-
return createExtension({
|
|
686
|
-
kind: "component",
|
|
687
|
-
namespace: options.ref.id,
|
|
688
|
-
name: options.name,
|
|
689
|
-
attachTo: { id: "app", input: "components" },
|
|
690
|
-
inputs: options.inputs,
|
|
691
|
-
disabled: options.disabled,
|
|
692
|
-
configSchema: options.configSchema,
|
|
693
|
-
output: {
|
|
694
|
-
component: createComponentExtension.componentDataRef
|
|
695
|
-
},
|
|
696
|
-
factory({ config, inputs }) {
|
|
697
|
-
if ("sync" in options.loader) {
|
|
698
|
-
return {
|
|
699
|
-
component: {
|
|
700
|
-
ref: options.ref,
|
|
701
|
-
impl: options.loader.sync({ config, inputs })
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
const lazyLoader = options.loader.lazy;
|
|
706
|
-
const ExtensionComponent = lazy(
|
|
707
|
-
() => lazyLoader({ config, inputs }).then((Component) => ({
|
|
708
|
-
default: Component
|
|
709
|
-
}))
|
|
710
|
-
);
|
|
711
|
-
return {
|
|
712
|
-
component: {
|
|
713
|
-
ref: options.ref,
|
|
714
|
-
impl: ExtensionComponent
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
});
|
|
719
|
-
}
|
|
720
|
-
((createComponentExtension2) => {
|
|
721
|
-
createComponentExtension2.componentDataRef = createExtensionDataRef("core.component.component");
|
|
722
|
-
})(createComponentExtension || (createComponentExtension = {}));
|
|
723
|
-
|
|
724
|
-
function createTranslationExtension(options) {
|
|
725
|
-
return createExtension({
|
|
726
|
-
kind: "translation",
|
|
727
|
-
namespace: options.resource.id,
|
|
728
|
-
name: options.name,
|
|
729
|
-
attachTo: { id: "app", input: "translations" },
|
|
730
|
-
output: {
|
|
731
|
-
resource: createTranslationExtension.translationDataRef
|
|
732
|
-
},
|
|
733
|
-
factory: () => ({ resource: options.resource })
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
((createTranslationExtension2) => {
|
|
737
|
-
createTranslationExtension2.translationDataRef = createExtensionDataRef("core.translation.translation");
|
|
738
|
-
})(createTranslationExtension || (createTranslationExtension = {}));
|
|
739
|
-
|
|
740
|
-
const MESSAGE_MARKER = "eHgtF5hmbrXyiEvo";
|
|
741
|
-
function describeParentCallSite(ErrorConstructor = Error) {
|
|
742
|
-
const { stack } = new ErrorConstructor(MESSAGE_MARKER);
|
|
743
|
-
if (!stack) {
|
|
744
|
-
return "<unknown>";
|
|
745
|
-
}
|
|
746
|
-
const startIndex = stack.includes(MESSAGE_MARKER) ? stack.indexOf("\n") + 1 : 0;
|
|
747
|
-
const secondEntryStart = stack.indexOf("\n", stack.indexOf("\n", startIndex) + 1) + 1;
|
|
748
|
-
const secondEntryEnd = stack.indexOf("\n", secondEntryStart);
|
|
749
|
-
const line = stack.substring(secondEntryStart, secondEntryEnd).trim();
|
|
750
|
-
if (!line) {
|
|
751
|
-
return "unknown";
|
|
752
|
-
}
|
|
753
|
-
if (line.includes("(")) {
|
|
754
|
-
return line.substring(line.indexOf("(") + 1, line.indexOf(")"));
|
|
755
|
-
}
|
|
756
|
-
if (line.includes("@")) {
|
|
757
|
-
return line.substring(line.indexOf("@") + 1);
|
|
758
|
-
}
|
|
759
|
-
return line;
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
var __defProp$2 = Object.defineProperty;
|
|
763
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
764
|
-
var __publicField$2 = (obj, key, value) => {
|
|
765
|
-
__defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
766
|
-
return value;
|
|
767
|
-
};
|
|
768
|
-
var __accessCheck$1 = (obj, member, msg) => {
|
|
769
|
-
if (!member.has(obj))
|
|
770
|
-
throw TypeError("Cannot " + msg);
|
|
771
|
-
};
|
|
772
|
-
var __privateGet$1 = (obj, member, getter) => {
|
|
773
|
-
__accessCheck$1(obj, member, "read from private field");
|
|
774
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
775
|
-
};
|
|
776
|
-
var __privateAdd$1 = (obj, member, value) => {
|
|
777
|
-
if (member.has(obj))
|
|
778
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
779
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
780
|
-
};
|
|
781
|
-
var __privateSet$1 = (obj, member, value, setter) => {
|
|
782
|
-
__accessCheck$1(obj, member, "write to private field");
|
|
783
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
784
|
-
return value;
|
|
785
|
-
};
|
|
786
|
-
var _id, _params$1, _creationSite, _name, name_get;
|
|
787
|
-
function toInternalRouteRef(resource) {
|
|
788
|
-
const r = resource;
|
|
789
|
-
if (r.$$type !== "@backstage/RouteRef") {
|
|
790
|
-
throw new Error(`Invalid RouteRef, bad type '${r.$$type}'`);
|
|
791
|
-
}
|
|
792
|
-
return r;
|
|
793
|
-
}
|
|
794
|
-
class RouteRefImpl {
|
|
795
|
-
constructor(params = [], creationSite) {
|
|
796
|
-
this.params = params;
|
|
797
|
-
__privateAdd$1(this, _name);
|
|
798
|
-
__publicField$2(this, "$$type", "@backstage/RouteRef");
|
|
799
|
-
__publicField$2(this, "version", "v1");
|
|
800
|
-
__privateAdd$1(this, _id, void 0);
|
|
801
|
-
__privateAdd$1(this, _params$1, void 0);
|
|
802
|
-
__privateAdd$1(this, _creationSite, void 0);
|
|
803
|
-
__privateSet$1(this, _params$1, params);
|
|
804
|
-
__privateSet$1(this, _creationSite, creationSite);
|
|
805
|
-
}
|
|
806
|
-
getParams() {
|
|
807
|
-
return __privateGet$1(this, _params$1);
|
|
808
|
-
}
|
|
809
|
-
getDescription() {
|
|
810
|
-
if (__privateGet$1(this, _id)) {
|
|
811
|
-
return __privateGet$1(this, _id);
|
|
812
|
-
}
|
|
813
|
-
return `created at '${__privateGet$1(this, _creationSite)}'`;
|
|
814
|
-
}
|
|
815
|
-
setId(id) {
|
|
816
|
-
if (!id) {
|
|
817
|
-
throw new Error(`${__privateGet$1(this, _name, name_get)} id must be a non-empty string`);
|
|
818
|
-
}
|
|
819
|
-
if (__privateGet$1(this, _id)) {
|
|
820
|
-
throw new Error(
|
|
821
|
-
`${__privateGet$1(this, _name, name_get)} was referenced twice as both '${__privateGet$1(this, _id)}' and '${id}'`
|
|
822
|
-
);
|
|
823
|
-
}
|
|
824
|
-
__privateSet$1(this, _id, id);
|
|
825
|
-
}
|
|
826
|
-
toString() {
|
|
827
|
-
return `${__privateGet$1(this, _name, name_get)}{${this.getDescription()}}`;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
_id = new WeakMap();
|
|
831
|
-
_params$1 = new WeakMap();
|
|
832
|
-
_creationSite = new WeakMap();
|
|
833
|
-
_name = new WeakSet();
|
|
834
|
-
name_get = function() {
|
|
835
|
-
return this.$$type.slice("@backstage/".length);
|
|
836
|
-
};
|
|
837
|
-
function createRouteRef(config) {
|
|
838
|
-
return new RouteRefImpl(
|
|
839
|
-
config == null ? void 0 : config.params,
|
|
840
|
-
describeParentCallSite()
|
|
841
|
-
);
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
var __defProp$1 = Object.defineProperty;
|
|
845
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
846
|
-
var __publicField$1 = (obj, key, value) => {
|
|
847
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
848
|
-
return value;
|
|
849
|
-
};
|
|
850
|
-
var __accessCheck = (obj, member, msg) => {
|
|
851
|
-
if (!member.has(obj))
|
|
852
|
-
throw TypeError("Cannot " + msg);
|
|
853
|
-
};
|
|
854
|
-
var __privateGet = (obj, member, getter) => {
|
|
855
|
-
__accessCheck(obj, member, "read from private field");
|
|
856
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
857
|
-
};
|
|
858
|
-
var __privateAdd = (obj, member, value) => {
|
|
859
|
-
if (member.has(obj))
|
|
860
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
861
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
862
|
-
};
|
|
863
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
864
|
-
__accessCheck(obj, member, "write to private field");
|
|
865
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
866
|
-
return value;
|
|
867
|
-
};
|
|
868
|
-
var _params, _parent;
|
|
869
|
-
const PARAM_PATTERN = /^\w+$/;
|
|
870
|
-
class SubRouteRefImpl {
|
|
871
|
-
constructor(path, params, parent) {
|
|
872
|
-
this.path = path;
|
|
873
|
-
__publicField$1(this, "$$type", "@backstage/SubRouteRef");
|
|
874
|
-
__publicField$1(this, "version", "v1");
|
|
875
|
-
__privateAdd(this, _params, void 0);
|
|
876
|
-
__privateAdd(this, _parent, void 0);
|
|
877
|
-
__privateSet(this, _params, params);
|
|
878
|
-
__privateSet(this, _parent, parent);
|
|
879
|
-
}
|
|
880
|
-
getParams() {
|
|
881
|
-
return __privateGet(this, _params);
|
|
882
|
-
}
|
|
883
|
-
getParent() {
|
|
884
|
-
return __privateGet(this, _parent);
|
|
885
|
-
}
|
|
886
|
-
getDescription() {
|
|
887
|
-
const parent = toInternalRouteRef(__privateGet(this, _parent));
|
|
888
|
-
return `at ${this.path} with parent ${parent.getDescription()}`;
|
|
889
|
-
}
|
|
890
|
-
toString() {
|
|
891
|
-
return `SubRouteRef{${this.getDescription()}}`;
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
_params = new WeakMap();
|
|
895
|
-
_parent = new WeakMap();
|
|
896
|
-
function createSubRouteRef(config) {
|
|
897
|
-
const { path, parent } = config;
|
|
898
|
-
const internalParent = toInternalRouteRef(parent);
|
|
899
|
-
const parentParams = internalParent.getParams();
|
|
900
|
-
const pathParams = path.split("/").filter((p) => p.startsWith(":")).map((p) => p.substring(1));
|
|
901
|
-
const params = [...parentParams, ...pathParams];
|
|
902
|
-
if (parentParams.some((p) => pathParams.includes(p))) {
|
|
903
|
-
throw new Error(
|
|
904
|
-
"SubRouteRef may not have params that overlap with its parent"
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
if (!path.startsWith("/")) {
|
|
908
|
-
throw new Error(`SubRouteRef path must start with '/', got '${path}'`);
|
|
909
|
-
}
|
|
910
|
-
if (path.endsWith("/")) {
|
|
911
|
-
throw new Error(`SubRouteRef path must not end with '/', got '${path}'`);
|
|
912
|
-
}
|
|
913
|
-
for (const param of pathParams) {
|
|
914
|
-
if (!PARAM_PATTERN.test(param)) {
|
|
915
|
-
throw new Error(`SubRouteRef path has invalid param, got '${param}'`);
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
const subRouteRef = new SubRouteRefImpl(
|
|
919
|
-
path,
|
|
920
|
-
params,
|
|
921
|
-
parent
|
|
922
|
-
);
|
|
923
|
-
return subRouteRef;
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
var __defProp = Object.defineProperty;
|
|
927
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
928
|
-
var __publicField = (obj, key, value) => {
|
|
929
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
930
|
-
return value;
|
|
931
|
-
};
|
|
932
|
-
class ExternalRouteRefImpl extends RouteRefImpl {
|
|
933
|
-
constructor(optional, params = [], defaultTarget, creationSite) {
|
|
934
|
-
super(params, creationSite);
|
|
935
|
-
this.optional = optional;
|
|
936
|
-
this.params = params;
|
|
937
|
-
this.defaultTarget = defaultTarget;
|
|
938
|
-
__publicField(this, "$$type", "@backstage/ExternalRouteRef");
|
|
939
|
-
}
|
|
940
|
-
getDefaultTarget() {
|
|
941
|
-
return this.defaultTarget;
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
function createExternalRouteRef(options) {
|
|
945
|
-
return new ExternalRouteRefImpl(
|
|
946
|
-
Boolean(options == null ? void 0 : options.optional),
|
|
947
|
-
options == null ? void 0 : options.params,
|
|
948
|
-
options == null ? void 0 : options.defaultTarget,
|
|
949
|
-
describeParentCallSite()
|
|
950
|
-
);
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
function useRouteRef(routeRef) {
|
|
954
|
-
const { pathname } = useLocation();
|
|
955
|
-
const routeResolutionApi = useApi(routeResolutionApiRef);
|
|
956
|
-
const routeFunc = useMemo(
|
|
957
|
-
() => routeResolutionApi.resolve(routeRef, { sourcePath: pathname }),
|
|
958
|
-
[routeResolutionApi, routeRef, pathname]
|
|
959
|
-
);
|
|
960
|
-
const isOptional = "optional" in routeRef && routeRef.optional;
|
|
961
|
-
if (!routeFunc && !isOptional) {
|
|
962
|
-
throw new Error(`No path for ${routeRef}`);
|
|
963
|
-
}
|
|
964
|
-
return routeFunc;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
function useRouteRefParams(_routeRef) {
|
|
968
|
-
return useParams();
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
export { AnalyticsContext, ExtensionBoundary, analyticsApiRef, appTreeApiRef, componentsApiRef, coreComponentRefs, coreExtensionData, createApiExtension, createAppRootElementExtension, createAppRootWrapperExtension, createComponentExtension, createComponentRef, createExtension, createExtensionDataRef, createExtensionInput, createExtensionOverrides, createExternalRouteRef, createNavItemExtension, createNavLogoExtension, createPageExtension, createPlugin, createRouteRef, createRouterExtension, createSchemaFromZod, createSignInPageExtension, createSubRouteRef, createThemeExtension, createTranslationExtension, iconsApiRef, routeResolutionApiRef, useAnalytics, useComponentRef, useRouteRef, useRouteRefParams };
|
|
30
|
+
export { coreExtensionData } from './wiring/coreExtensionData.esm.js';
|
|
31
|
+
export { createExtension } from './wiring/createExtension.esm.js';
|
|
32
|
+
export { createExtensionInput } from './wiring/createExtensionInput.esm.js';
|
|
33
|
+
export { createExtensionDataRef } from './wiring/createExtensionDataRef.esm.js';
|
|
34
|
+
export { createPlugin } from './wiring/createPlugin.esm.js';
|
|
35
|
+
export { createExtensionOverrides } from './wiring/createExtensionOverrides.esm.js';
|
|
972
36
|
//# sourceMappingURL=index.esm.js.map
|