@backstage/frontend-plugin-api 0.15.0-next.1 → 0.15.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/dist/alpha.d.ts +6 -71
  3. package/dist/alpha.esm.js +4 -0
  4. package/dist/alpha.esm.js.map +1 -1
  5. package/dist/analytics/useAnalytics.esm.js +2 -0
  6. package/dist/analytics/useAnalytics.esm.js.map +1 -1
  7. package/dist/apis/definitions/AlertApi.esm.js +3 -2
  8. package/dist/apis/definitions/AlertApi.esm.js.map +1 -1
  9. package/dist/apis/definitions/AnalyticsApi.esm.js +3 -2
  10. package/dist/apis/definitions/AnalyticsApi.esm.js.map +1 -1
  11. package/dist/apis/definitions/AppLanguageApi.esm.js +3 -2
  12. package/dist/apis/definitions/AppLanguageApi.esm.js.map +1 -1
  13. package/dist/apis/definitions/AppThemeApi.esm.js +3 -2
  14. package/dist/apis/definitions/AppThemeApi.esm.js.map +1 -1
  15. package/dist/apis/definitions/AppTreeApi.esm.js +4 -1
  16. package/dist/apis/definitions/AppTreeApi.esm.js.map +1 -1
  17. package/dist/apis/definitions/ConfigApi.esm.js +3 -2
  18. package/dist/apis/definitions/ConfigApi.esm.js.map +1 -1
  19. package/dist/apis/definitions/DialogApi.esm.js +3 -2
  20. package/dist/apis/definitions/DialogApi.esm.js.map +1 -1
  21. package/dist/apis/definitions/DiscoveryApi.esm.js +3 -2
  22. package/dist/apis/definitions/DiscoveryApi.esm.js.map +1 -1
  23. package/dist/apis/definitions/ErrorApi.esm.js +3 -2
  24. package/dist/apis/definitions/ErrorApi.esm.js.map +1 -1
  25. package/dist/apis/definitions/FeatureFlagsApi.esm.js +3 -2
  26. package/dist/apis/definitions/FeatureFlagsApi.esm.js.map +1 -1
  27. package/dist/apis/definitions/FetchApi.esm.js +3 -2
  28. package/dist/apis/definitions/FetchApi.esm.js.map +1 -1
  29. package/dist/apis/definitions/IconsApi.esm.js +3 -2
  30. package/dist/apis/definitions/IconsApi.esm.js.map +1 -1
  31. package/dist/apis/definitions/IdentityApi.esm.js +3 -2
  32. package/dist/apis/definitions/IdentityApi.esm.js.map +1 -1
  33. package/dist/apis/definitions/OAuthRequestApi.esm.js +3 -2
  34. package/dist/apis/definitions/OAuthRequestApi.esm.js.map +1 -1
  35. package/dist/apis/definitions/PluginHeaderActionsApi.esm.js +3 -2
  36. package/dist/apis/definitions/PluginHeaderActionsApi.esm.js.map +1 -1
  37. package/dist/apis/definitions/PluginWrapperApi.esm.js +7 -3
  38. package/dist/apis/definitions/PluginWrapperApi.esm.js.map +1 -1
  39. package/dist/apis/definitions/RouteResolutionApi.esm.js +3 -2
  40. package/dist/apis/definitions/RouteResolutionApi.esm.js.map +1 -1
  41. package/dist/apis/definitions/StorageApi.esm.js +3 -2
  42. package/dist/apis/definitions/StorageApi.esm.js.map +1 -1
  43. package/dist/apis/definitions/SwappableComponentsApi.esm.js +3 -2
  44. package/dist/apis/definitions/SwappableComponentsApi.esm.js.map +1 -1
  45. package/dist/apis/definitions/ToastApi.esm.js +11 -0
  46. package/dist/apis/definitions/ToastApi.esm.js.map +1 -0
  47. package/dist/apis/definitions/TranslationApi.esm.js +3 -2
  48. package/dist/apis/definitions/TranslationApi.esm.js.map +1 -1
  49. package/dist/apis/definitions/auth.esm.js +33 -22
  50. package/dist/apis/definitions/auth.esm.js.map +1 -1
  51. package/dist/apis/system/ApiRef.esm.js +28 -20
  52. package/dist/apis/system/ApiRef.esm.js.map +1 -1
  53. package/dist/blueprints/AnalyticsImplementationBlueprint.esm.js +1 -1
  54. package/dist/blueprints/ApiBlueprint.esm.js +1 -1
  55. package/dist/blueprints/AppRootElementBlueprint.esm.js +1 -1
  56. package/dist/blueprints/NavItemBlueprint.esm.js +1 -1
  57. package/dist/blueprints/PageBlueprint.esm.js +17 -6
  58. package/dist/blueprints/PageBlueprint.esm.js.map +1 -1
  59. package/dist/blueprints/PluginHeaderActionBlueprint.esm.js +3 -1
  60. package/dist/blueprints/PluginHeaderActionBlueprint.esm.js.map +1 -1
  61. package/dist/blueprints/PluginWrapperBlueprint.esm.js +4 -2
  62. package/dist/blueprints/PluginWrapperBlueprint.esm.js.map +1 -1
  63. package/dist/blueprints/SubPageBlueprint.esm.js +3 -1
  64. package/dist/blueprints/SubPageBlueprint.esm.js.map +1 -1
  65. package/dist/components/ExtensionBoundary.esm.js +3 -2
  66. package/dist/components/ExtensionBoundary.esm.js.map +1 -1
  67. package/dist/components/createSwappableComponent.esm.js +2 -0
  68. package/dist/components/createSwappableComponent.esm.js.map +1 -1
  69. package/dist/frontend-internal/src/apis/OpaqueApiRef.esm.js +9 -0
  70. package/dist/frontend-internal/src/apis/OpaqueApiRef.esm.js.map +1 -0
  71. package/dist/frontend-internal/src/wiring/InternalExtensionDefinition.esm.js.map +1 -1
  72. package/dist/frontend-internal/src/wiring/InternalFrontendPlugin.esm.js.map +1 -1
  73. package/dist/index.d.ts +363 -1442
  74. package/dist/index.esm.js +3 -0
  75. package/dist/index.esm.js.map +1 -1
  76. package/dist/routing/useRouteRef.esm.js +2 -0
  77. package/dist/routing/useRouteRef.esm.js.map +1 -1
  78. package/dist/schema/createSchemaFromZod.esm.js +1 -1
  79. package/dist/schema/createSchemaFromZod.esm.js.map +1 -1
  80. package/dist/translation/useTranslationRef.esm.js +2 -0
  81. package/dist/translation/useTranslationRef.esm.js.map +1 -1
  82. package/dist/types/alpha.d-DzeiOzxk.d.ts +1425 -0
  83. package/dist/wiring/createExtension.esm.js +6 -0
  84. package/dist/wiring/createExtension.esm.js.map +1 -1
  85. package/dist/wiring/createExtensionBlueprint.esm.js +2 -0
  86. package/dist/wiring/createExtensionBlueprint.esm.js.map +1 -1
  87. package/dist/wiring/createExtensionDataRef.esm.js.map +1 -1
  88. package/dist/wiring/createFrontendModule.esm.js +1 -0
  89. package/dist/wiring/createFrontendModule.esm.js.map +1 -1
  90. package/dist/wiring/createFrontendPlugin.esm.js +6 -0
  91. package/dist/wiring/createFrontendPlugin.esm.js.map +1 -1
  92. package/dist/wiring/resolveExtensionDefinition.esm.js.map +1 -1
  93. package/dist/wiring/resolveInputOverrides.esm.js.map +1 -1
  94. package/package.json +11 -10
package/dist/index.esm.js CHANGED
@@ -18,8 +18,10 @@ export { oauthRequestApiRef } from './apis/definitions/OAuthRequestApi.esm.js';
18
18
  export { routeResolutionApiRef } from './apis/definitions/RouteResolutionApi.esm.js';
19
19
  export { storageApiRef } from './apis/definitions/StorageApi.esm.js';
20
20
  export { analyticsApiRef } from './apis/definitions/AnalyticsApi.esm.js';
21
+ export { toastApiRef } from './apis/definitions/ToastApi.esm.js';
21
22
  export { translationApiRef } from './apis/definitions/TranslationApi.esm.js';
22
23
  export { pluginHeaderActionsApiRef } from './apis/definitions/PluginHeaderActionsApi.esm.js';
24
+ export { pluginWrapperApiRef } from './apis/definitions/PluginWrapperApi.esm.js';
23
25
  export { useApi, useApiHolder, withApis } from './apis/system/useApi.esm.js';
24
26
  export { createApiRef } from './apis/system/ApiRef.esm.js';
25
27
  export { createApiFactory } from './apis/system/helpers.esm.js';
@@ -30,6 +32,7 @@ export { NavItemBlueprint } from './blueprints/NavItemBlueprint.esm.js';
30
32
  export { PageBlueprint } from './blueprints/PageBlueprint.esm.js';
31
33
  export { SubPageBlueprint } from './blueprints/SubPageBlueprint.esm.js';
32
34
  export { PluginHeaderActionBlueprint } from './blueprints/PluginHeaderActionBlueprint.esm.js';
35
+ export { PluginWrapperBlueprint } from './blueprints/PluginWrapperBlueprint.esm.js';
33
36
  export { ExtensionBoundary } from './components/ExtensionBoundary.esm.js';
34
37
  export { createSwappableComponent } from './components/createSwappableComponent.esm.js';
35
38
  export { useAppNode } from './components/AppNodeProvider.esm.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -18,8 +18,10 @@ import '../apis/definitions/OAuthRequestApi.esm.js';
18
18
  import { routeResolutionApiRef } from '../apis/definitions/RouteResolutionApi.esm.js';
19
19
  import '../apis/definitions/StorageApi.esm.js';
20
20
  import '../apis/definitions/AnalyticsApi.esm.js';
21
+ import '../apis/definitions/ToastApi.esm.js';
21
22
  import '../apis/definitions/TranslationApi.esm.js';
22
23
  import '../apis/definitions/PluginHeaderActionsApi.esm.js';
24
+ import '../apis/definitions/PluginWrapperApi.esm.js';
23
25
  import { useApi } from '../apis/system/useApi.esm.js';
24
26
 
25
27
  function useRouteRef(routeRef) {
@@ -1 +1 @@
1
- {"version":3,"file":"useRouteRef.esm.js","sources":["../../src/routing/useRouteRef.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 { useMemo } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport { AnyRouteRefParams } from './types';\nimport { RouteRef } from './RouteRef';\nimport { SubRouteRef } from './SubRouteRef';\nimport { ExternalRouteRef } from './ExternalRouteRef';\nimport { RouteFunc, routeResolutionApiRef, useApi } from '../apis';\n\n/**\n * React hook for constructing URLs to routes.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}\n *\n * @param routeRef - The ref to route that should be converted to URL.\n * @returns A function that will in turn return the concrete URL of the `routeRef`, or `undefined` if the route is not available.\n * @public\n */\nexport function useRouteRef<TParams extends AnyRouteRefParams>(\n routeRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n): RouteFunc<TParams> | undefined {\n const { pathname } = useLocation();\n const routeResolutionApi = useApi(routeResolutionApiRef);\n\n const routeFunc = useMemo(\n () => routeResolutionApi.resolve(routeRef, { sourcePath: pathname }),\n [routeResolutionApi, routeRef, pathname],\n );\n\n return routeFunc;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCO,SAAS,YACd,QAAA,EAIgC;AAChC,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,WAAA,EAAY;AACjC,EAAA,MAAM,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AAEvD,EAAA,MAAM,SAAA,GAAY,OAAA;AAAA,IAChB,MAAM,kBAAA,CAAmB,OAAA,CAAQ,UAAU,EAAE,UAAA,EAAY,UAAU,CAAA;AAAA,IACnE,CAAC,kBAAA,EAAoB,QAAA,EAAU,QAAQ;AAAA,GACzC;AAEA,EAAA,OAAO,SAAA;AACT;;;;"}
1
+ {"version":3,"file":"useRouteRef.esm.js","sources":["../../src/routing/useRouteRef.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 { useMemo } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport { AnyRouteRefParams } from './types';\nimport { RouteRef } from './RouteRef';\nimport { SubRouteRef } from './SubRouteRef';\nimport { ExternalRouteRef } from './ExternalRouteRef';\nimport { RouteFunc, routeResolutionApiRef, useApi } from '../apis';\n\n/**\n * React hook for constructing URLs to routes.\n *\n * @remarks\n *\n * See {@link https://backstage.io/docs/plugins/composability#routing-system}\n *\n * @param routeRef - The ref to route that should be converted to URL.\n * @returns A function that will in turn return the concrete URL of the `routeRef`, or `undefined` if the route is not available.\n * @public\n */\nexport function useRouteRef<TParams extends AnyRouteRefParams>(\n routeRef:\n | RouteRef<TParams>\n | SubRouteRef<TParams>\n | ExternalRouteRef<TParams>,\n): RouteFunc<TParams> | undefined {\n const { pathname } = useLocation();\n const routeResolutionApi = useApi(routeResolutionApiRef);\n\n const routeFunc = useMemo(\n () => routeResolutionApi.resolve(routeRef, { sourcePath: pathname }),\n [routeResolutionApi, routeRef, pathname],\n );\n\n return routeFunc;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAmCO,SAAS,YACd,QAAA,EAIgC;AAChC,EAAA,MAAM,EAAE,QAAA,EAAS,GAAI,WAAA,EAAY;AACjC,EAAA,MAAM,kBAAA,GAAqB,OAAO,qBAAqB,CAAA;AAEvD,EAAA,MAAM,SAAA,GAAY,OAAA;AAAA,IAChB,MAAM,kBAAA,CAAmB,OAAA,CAAQ,UAAU,EAAE,UAAA,EAAY,UAAU,CAAA;AAAA,IACnE,CAAC,kBAAA,EAAoB,QAAA,EAAU,QAAQ;AAAA,GACzC;AAEA,EAAA,OAAO,SAAA;AACT;;;;"}
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from 'zod/v3';
2
2
  import zodToJsonSchema from 'zod-to-json-schema';
3
3
 
4
4
  function createSchemaFromZod(schemaCreator) {
@@ -1 +1 @@
1
- {"version":3,"file":"createSchemaFromZod.esm.js","sources":["../../src/schema/createSchemaFromZod.ts"],"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 { JsonObject } from '@backstage/types';\nimport { z, type ZodSchema, type ZodTypeDef } from 'zod';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { PortableSchema } from './types';\n\n/**\n * @internal\n */\nexport function createSchemaFromZod<TOutput, TInput>(\n schemaCreator: (zImpl: typeof z) => ZodSchema<TOutput, ZodTypeDef, TInput>,\n): PortableSchema<TOutput, TInput> {\n const schema = schemaCreator(z);\n return {\n // TODO: Types allow z.array etc here but it will break stuff\n parse: input => {\n const result = schema.safeParse(input);\n if (result.success) {\n return result.data;\n }\n\n throw new Error(result.error.issues.map(formatIssue).join('; '));\n },\n // TODO: Verify why we are not compatible with the latest zodToJsonSchema.\n schema: zodToJsonSchema(schema) as JsonObject,\n };\n}\n\nfunction formatIssue(issue: z.ZodIssue): string {\n if (issue.code === 'invalid_union') {\n return formatIssue(issue.unionErrors[0].issues[0]);\n }\n let message = issue.message;\n if (message === 'Required') {\n message = `Missing required value`;\n }\n if (issue.path.length) {\n message += ` at '${issue.path.join('.')}'`;\n }\n return message;\n}\n"],"names":[],"mappings":";;;AAwBO,SAAS,oBACd,aAAA,EACiC;AACjC,EAAA,MAAM,MAAA,GAAS,cAAc,CAAC,CAAA;AAC9B,EAAA,OAAO;AAAA;AAAA,IAEL,OAAO,CAAA,KAAA,KAAS;AACd,MAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA;AACrC,MAAA,IAAI,OAAO,OAAA,EAAS;AAClB,QAAA,OAAO,MAAA,CAAO,IAAA;AAAA,MAChB;AAEA,MAAA,MAAM,IAAI,KAAA,CAAM,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,IAAI,WAAW,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,IACjE,CAAA;AAAA;AAAA,IAEA,MAAA,EAAQ,gBAAgB,MAAM;AAAA,GAChC;AACF;AAEA,SAAS,YAAY,KAAA,EAA2B;AAC9C,EAAA,IAAI,KAAA,CAAM,SAAS,eAAA,EAAiB;AAClC,IAAA,OAAO,YAAY,KAAA,CAAM,WAAA,CAAY,CAAC,CAAA,CAAE,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,UAAU,KAAA,CAAM,OAAA;AACpB,EAAA,IAAI,YAAY,UAAA,EAAY;AAC1B,IAAA,OAAA,GAAU,CAAA,sBAAA,CAAA;AAAA,EACZ;AACA,EAAA,IAAI,KAAA,CAAM,KAAK,MAAA,EAAQ;AACrB,IAAA,OAAA,IAAW,CAAA,KAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,EACzC;AACA,EAAA,OAAO,OAAA;AACT;;;;"}
1
+ {"version":3,"file":"createSchemaFromZod.esm.js","sources":["../../src/schema/createSchemaFromZod.ts"],"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 { JsonObject } from '@backstage/types';\nimport { z, type ZodSchema, type ZodTypeDef } from 'zod/v3';\nimport zodToJsonSchema from 'zod-to-json-schema';\nimport { PortableSchema } from './types';\n\n/**\n * @internal\n */\nexport function createSchemaFromZod<TOutput, TInput>(\n schemaCreator: (zImpl: typeof z) => ZodSchema<TOutput, ZodTypeDef, TInput>,\n): PortableSchema<TOutput, TInput> {\n const schema = schemaCreator(z);\n return {\n // TODO: Types allow z.array etc here but it will break stuff\n parse: input => {\n const result = schema.safeParse(input);\n if (result.success) {\n return result.data;\n }\n\n throw new Error(result.error.issues.map(formatIssue).join('; '));\n },\n // TODO: Verify why we are not compatible with the latest zodToJsonSchema.\n schema: zodToJsonSchema(schema) as JsonObject,\n };\n}\n\nfunction formatIssue(issue: z.ZodIssue): string {\n if (issue.code === 'invalid_union') {\n return formatIssue(issue.unionErrors[0].issues[0]);\n }\n let message = issue.message;\n if (message === 'Required') {\n message = `Missing required value`;\n }\n if (issue.path.length) {\n message += ` at '${issue.path.join('.')}'`;\n }\n return message;\n}\n"],"names":[],"mappings":";;;AAwBO,SAAS,oBACd,aAAA,EACiC;AACjC,EAAA,MAAM,MAAA,GAAS,cAAc,CAAC,CAAA;AAC9B,EAAA,OAAO;AAAA;AAAA,IAEL,OAAO,CAAA,KAAA,KAAS;AACd,MAAA,MAAM,MAAA,GAAS,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA;AACrC,MAAA,IAAI,OAAO,OAAA,EAAS;AAClB,QAAA,OAAO,MAAA,CAAO,IAAA;AAAA,MAChB;AAEA,MAAA,MAAM,IAAI,KAAA,CAAM,MAAA,CAAO,KAAA,CAAM,MAAA,CAAO,IAAI,WAAW,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA;AAAA,IACjE,CAAA;AAAA;AAAA,IAEA,MAAA,EAAQ,gBAAgB,MAAM;AAAA,GAChC;AACF;AAEA,SAAS,YAAY,KAAA,EAA2B;AAC9C,EAAA,IAAI,KAAA,CAAM,SAAS,eAAA,EAAiB;AAClC,IAAA,OAAO,YAAY,KAAA,CAAM,WAAA,CAAY,CAAC,CAAA,CAAE,MAAA,CAAO,CAAC,CAAC,CAAA;AAAA,EACnD;AACA,EAAA,IAAI,UAAU,KAAA,CAAM,OAAA;AACpB,EAAA,IAAI,YAAY,UAAA,EAAY;AAC1B,IAAA,OAAA,GAAU,CAAA,sBAAA,CAAA;AAAA,EACZ;AACA,EAAA,IAAI,KAAA,CAAM,KAAK,MAAA,EAAQ;AACrB,IAAA,OAAA,IAAW,CAAA,KAAA,EAAQ,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA,CAAA;AAAA,EACzC;AACA,EAAA,OAAO,OAAA;AACT;;;;"}
@@ -17,8 +17,10 @@ import '../apis/definitions/OAuthRequestApi.esm.js';
17
17
  import '../apis/definitions/RouteResolutionApi.esm.js';
18
18
  import '../apis/definitions/StorageApi.esm.js';
19
19
  import '../apis/definitions/AnalyticsApi.esm.js';
20
+ import '../apis/definitions/ToastApi.esm.js';
20
21
  import { translationApiRef } from '../apis/definitions/TranslationApi.esm.js';
21
22
  import '../apis/definitions/PluginHeaderActionsApi.esm.js';
23
+ import '../apis/definitions/PluginWrapperApi.esm.js';
22
24
  import { useApi } from '../apis/system/useApi.esm.js';
23
25
 
24
26
  const loggedRefs = /* @__PURE__ */ new WeakSet();
@@ -1 +1 @@
1
- {"version":3,"file":"useTranslationRef.esm.js","sources":["../../src/translation/useTranslationRef.ts"],"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 { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { errorApiRef, useApi } from '../apis';\nimport {\n translationApiRef,\n TranslationFunction,\n TranslationSnapshot,\n} from '../apis/definitions/TranslationApi';\nimport { TranslationRef } from './TranslationRef';\n\n// Make sure we don't fill the logs with loading errors for the same ref\nconst loggedRefs = new WeakSet<TranslationRef<string, {}>>();\n\n/** @public */\nexport const useTranslationRef = <\n TMessages extends { [key in string]: string },\n>(\n translationRef: TranslationRef<string, TMessages>,\n): { t: TranslationFunction<TMessages> } => {\n const errorApi = useApi(errorApiRef);\n const translationApi = useApi(translationApiRef);\n\n const [snapshot, setSnapshot] = useState<TranslationSnapshot<TMessages>>(() =>\n translationApi.getTranslation(translationRef),\n );\n const observable = useMemo(\n () => translationApi.translation$(translationRef),\n [translationApi, translationRef],\n );\n\n const onError = useCallback(\n (error: Error) => {\n if (!loggedRefs.has(translationRef)) {\n const errMsg = `Failed to load translation resource '${translationRef.id}'; caused by ${error}`;\n // eslint-disable-next-line no-console\n console.error(errMsg);\n errorApi.post(new Error(errMsg));\n loggedRefs.add(translationRef);\n }\n },\n [errorApi, translationRef],\n );\n\n useEffect(() => {\n const subscription = observable.subscribe({\n next(next) {\n if (next.ready) {\n setSnapshot(next);\n }\n },\n error(error) {\n onError(error);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [observable, onError]);\n\n // Keep track of if the provided translation ref changes, and in that case update the snapshot\n const initialRenderRef = useRef(true);\n useEffect(() => {\n if (initialRenderRef.current) {\n initialRenderRef.current = false;\n } else {\n setSnapshot(translationApi.getTranslation(translationRef));\n }\n }, [translationApi, translationRef]);\n\n if (!snapshot.ready) {\n throw new Promise<void>(resolve => {\n const subscription = observable.subscribe({\n next(next) {\n if (next.ready) {\n subscription.unsubscribe();\n resolve();\n }\n },\n error(error) {\n subscription.unsubscribe();\n onError(error);\n resolve();\n },\n });\n });\n }\n\n return { t: snapshot.t };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,UAAA,uBAAiB,OAAA,EAAoC;AAGpD,MAAM,iBAAA,GAAoB,CAG/B,cAAA,KAC0C;AAC1C,EAAA,MAAM,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAA,MAAM,cAAA,GAAiB,OAAO,iBAAiB,CAAA;AAE/C,EAAA,MAAM,CAAC,QAAA,EAAU,WAAW,CAAA,GAAI,QAAA;AAAA,IAAyC,MACvE,cAAA,CAAe,cAAA,CAAe,cAAc;AAAA,GAC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WAAA,CAAY,cAAA,CAAe,cAAA,CAAe,cAAc,CAAC,CAAA;AAAA,IAC3D;AAAA,EACF,CAAA,EAAG,CAAC,cAAA,EAAgB,cAAc,CAAC,CAAA;AAEnC,EAAA,IAAI,CAAC,SAAS,KAAA,EAAO;AACnB,IAAA,MAAM,IAAI,QAAc,CAAA,OAAA,KAAW;AACjC,MAAA,MAAM,YAAA,GAAe,WAAW,SAAA,CAAU;AAAA,QACxC,KAAK,IAAA,EAAM;AACT,UAAA,IAAI,KAAK,KAAA,EAAO;AACd,YAAA,YAAA,CAAa,WAAA,EAAY;AACzB,YAAA,OAAA,EAAQ;AAAA,UACV;AAAA,QACF,CAAA;AAAA,QACA,MAAM,KAAA,EAAO;AACX,UAAA,YAAA,CAAa,WAAA,EAAY;AACzB,UAAA,OAAA,CAAQ,KAAK,CAAA;AACb,UAAA,OAAA,EAAQ;AAAA,QACV;AAAA,OACD,CAAA;AAAA,IACH,CAAC,CAAA;AAAA,EACH;AAEA,EAAA,OAAO,EAAE,CAAA,EAAG,QAAA,CAAS,CAAA,EAAE;AACzB;;;;"}
1
+ {"version":3,"file":"useTranslationRef.esm.js","sources":["../../src/translation/useTranslationRef.ts"],"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 { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { errorApiRef, useApi } from '../apis';\nimport {\n translationApiRef,\n TranslationFunction,\n TranslationSnapshot,\n} from '../apis/definitions/TranslationApi';\nimport { TranslationRef } from './TranslationRef';\n\n// Make sure we don't fill the logs with loading errors for the same ref\nconst loggedRefs = new WeakSet<TranslationRef<string, {}>>();\n\n/** @public */\nexport const useTranslationRef = <\n TMessages extends { [key in string]: string },\n>(\n translationRef: TranslationRef<string, TMessages>,\n): { t: TranslationFunction<TMessages> } => {\n const errorApi = useApi(errorApiRef);\n const translationApi = useApi(translationApiRef);\n\n const [snapshot, setSnapshot] = useState<TranslationSnapshot<TMessages>>(() =>\n translationApi.getTranslation(translationRef),\n );\n const observable = useMemo(\n () => translationApi.translation$(translationRef),\n [translationApi, translationRef],\n );\n\n const onError = useCallback(\n (error: Error) => {\n if (!loggedRefs.has(translationRef)) {\n const errMsg = `Failed to load translation resource '${translationRef.id}'; caused by ${error}`;\n // eslint-disable-next-line no-console\n console.error(errMsg);\n errorApi.post(new Error(errMsg));\n loggedRefs.add(translationRef);\n }\n },\n [errorApi, translationRef],\n );\n\n useEffect(() => {\n const subscription = observable.subscribe({\n next(next) {\n if (next.ready) {\n setSnapshot(next);\n }\n },\n error(error) {\n onError(error);\n },\n });\n\n return () => {\n subscription.unsubscribe();\n };\n }, [observable, onError]);\n\n // Keep track of if the provided translation ref changes, and in that case update the snapshot\n const initialRenderRef = useRef(true);\n useEffect(() => {\n if (initialRenderRef.current) {\n initialRenderRef.current = false;\n } else {\n setSnapshot(translationApi.getTranslation(translationRef));\n }\n }, [translationApi, translationRef]);\n\n if (!snapshot.ready) {\n throw new Promise<void>(resolve => {\n const subscription = observable.subscribe({\n next(next) {\n if (next.ready) {\n subscription.unsubscribe();\n resolve();\n }\n },\n error(error) {\n subscription.unsubscribe();\n onError(error);\n resolve();\n },\n });\n });\n }\n\n return { t: snapshot.t };\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,UAAA,uBAAiB,OAAA,EAAoC;AAGpD,MAAM,iBAAA,GAAoB,CAG/B,cAAA,KAC0C;AAC1C,EAAA,MAAM,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAA,MAAM,cAAA,GAAiB,OAAO,iBAAiB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