@atlassian/clientside-extensions-components 2.4.1 → 2.5.0-84fa90d-kwd5ix2w
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/dist/cjs/ExtensionPoint.js +4 -4
- package/dist/cjs/ExtensionPoint.js.map +1 -1
- package/dist/cjs/ExtensionPointInfo.js +8 -8
- package/dist/cjs/ExtensionPointInfo.js.map +1 -1
- package/dist/cjs/ExtensionsObservable.js +14 -12
- package/dist/cjs/ExtensionsObservable.js.map +1 -1
- package/dist/cjs/debug/useDebug.js +3 -3
- package/dist/cjs/debug/useDebug.js.map +1 -1
- package/dist/cjs/debug/useDiscovery.js +3 -3
- package/dist/cjs/debug/useDiscovery.js.map +1 -1
- package/dist/cjs/debug/useLogging.js +3 -3
- package/dist/cjs/debug/useLogging.js.map +1 -1
- package/dist/cjs/debug/useValidation.js +3 -3
- package/dist/cjs/debug/useValidation.js.map +1 -1
- package/dist/cjs/handlers/AsyncPanelHandler.js +10 -9
- package/dist/cjs/handlers/AsyncPanelHandler.js.map +1 -1
- package/dist/cjs/handlers/ButtonHandler.js +4 -3
- package/dist/cjs/handlers/ButtonHandler.js.map +1 -1
- package/dist/cjs/handlers/LinkHandler.js +4 -3
- package/dist/cjs/handlers/LinkHandler.js.map +1 -1
- package/dist/cjs/handlers/ModalHandler.js +16 -14
- package/dist/cjs/handlers/ModalHandler.js.map +1 -1
- package/dist/cjs/handlers/PanelHandler.js +6 -5
- package/dist/cjs/handlers/PanelHandler.js.map +1 -1
- package/dist/cjs/handlers/SectionHandler.js +3 -2
- package/dist/cjs/handlers/SectionHandler.js.map +1 -1
- package/dist/cjs/handlers/index.js +1 -0
- package/dist/cjs/handlers/index.js.map +1 -1
- package/dist/cjs/index.js +11 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/renderElementAsReact.js +3 -3
- package/dist/cjs/renderElementAsReact.js.map +1 -1
- package/dist/cjs/styled.js +13 -13
- package/dist/cjs/styled.js.map +1 -1
- package/dist/cjs/useExtensions.js +18 -14
- package/dist/cjs/useExtensions.js.map +1 -1
- package/dist/cjs/useWebPanelRenderer.js +4 -4
- package/dist/cjs/useWebPanelRenderer.js.map +1 -1
- package/dist/esm/ExtensionPointInfo.js.map +1 -1
- package/dist/esm/ExtensionsObservable.js.map +1 -1
- package/dist/esm/debug/types.js +1 -0
- package/dist/esm/handlers/types.js +1 -0
- package/dist/esm/renderElementAsReact.js +1 -1
- package/dist/esm/renderElementAsReact.js.map +1 -1
- package/dist/esm/useWebPanelRenderer.js.map +1 -1
- package/dist/types/ExtensionPointInfo.d.ts.map +1 -1
- package/dist/types/styled.d.ts +7 -7
- package/dist/types/styled.d.ts.map +1 -1
- package/lib/ExtensionPointInfo.tsx +1 -0
- package/lib/ExtensionsObservable.test.ts +2 -2
- package/package.json +12 -11
- package/dist/cjs/ExtensionPoint.test.js +0 -96
- package/dist/cjs/ExtensionPoint.test.js.map +0 -1
- package/dist/cjs/ExtensionPointInfo.test.js +0 -189
- package/dist/cjs/ExtensionPointInfo.test.js.map +0 -1
- package/dist/cjs/ExtensionsObservable.test.js +0 -349
- package/dist/cjs/ExtensionsObservable.test.js.map +0 -1
- package/dist/cjs/debug/useDebug.test.js +0 -49
- package/dist/cjs/debug/useDebug.test.js.map +0 -1
- package/dist/cjs/debug/useDiscovery.test.js +0 -49
- package/dist/cjs/debug/useDiscovery.test.js.map +0 -1
- package/dist/cjs/debug/useLogging.test.js +0 -49
- package/dist/cjs/debug/useLogging.test.js.map +0 -1
- package/dist/cjs/debug/useValidation.test.js +0 -49
- package/dist/cjs/debug/useValidation.test.js.map +0 -1
- package/dist/cjs/handlers/AsyncPanelHandler.test.js +0 -189
- package/dist/cjs/handlers/AsyncPanelHandler.test.js.map +0 -1
- package/dist/cjs/handlers/ButtonHandler.test.js +0 -40
- package/dist/cjs/handlers/ButtonHandler.test.js.map +0 -1
- package/dist/cjs/handlers/LinkHandler.test.js +0 -43
- package/dist/cjs/handlers/LinkHandler.test.js.map +0 -1
- package/dist/cjs/handlers/ModalHandler.test.js +0 -189
- package/dist/cjs/handlers/ModalHandler.test.js.map +0 -1
- package/dist/cjs/handlers/PanelHandler.test.js +0 -88
- package/dist/cjs/handlers/PanelHandler.test.js.map +0 -1
- package/dist/cjs/handlers/SectionHandler.test.js +0 -17
- package/dist/cjs/handlers/SectionHandler.test.js.map +0 -1
- package/dist/cjs/index.test.js +0 -7
- package/dist/cjs/index.test.js.map +0 -1
- package/dist/cjs/renderElementAsReact.test.js +0 -54
- package/dist/cjs/renderElementAsReact.test.js.map +0 -1
- package/dist/cjs/useExtensions.test.js +0 -647
- package/dist/cjs/useExtensions.test.js.map +0 -1
- package/dist/esm/ExtensionPoint.test.js +0 -93
- package/dist/esm/ExtensionPoint.test.js.map +0 -1
- package/dist/esm/ExtensionPointInfo.test.js +0 -186
- package/dist/esm/ExtensionPointInfo.test.js.map +0 -1
- package/dist/esm/ExtensionsObservable.test.js +0 -346
- package/dist/esm/ExtensionsObservable.test.js.map +0 -1
- package/dist/esm/debug/useDebug.test.js +0 -46
- package/dist/esm/debug/useDebug.test.js.map +0 -1
- package/dist/esm/debug/useDiscovery.test.js +0 -46
- package/dist/esm/debug/useDiscovery.test.js.map +0 -1
- package/dist/esm/debug/useLogging.test.js +0 -46
- package/dist/esm/debug/useLogging.test.js.map +0 -1
- package/dist/esm/debug/useValidation.test.js +0 -46
- package/dist/esm/debug/useValidation.test.js.map +0 -1
- package/dist/esm/handlers/AsyncPanelHandler.test.js +0 -186
- package/dist/esm/handlers/AsyncPanelHandler.test.js.map +0 -1
- package/dist/esm/handlers/ButtonHandler.test.js +0 -37
- package/dist/esm/handlers/ButtonHandler.test.js.map +0 -1
- package/dist/esm/handlers/LinkHandler.test.js +0 -40
- package/dist/esm/handlers/LinkHandler.test.js.map +0 -1
- package/dist/esm/handlers/ModalHandler.test.js +0 -186
- package/dist/esm/handlers/ModalHandler.test.js.map +0 -1
- package/dist/esm/handlers/PanelHandler.test.js +0 -85
- package/dist/esm/handlers/PanelHandler.test.js.map +0 -1
- package/dist/esm/handlers/SectionHandler.test.js +0 -14
- package/dist/esm/handlers/SectionHandler.test.js.map +0 -1
- package/dist/esm/index.test.js +0 -7
- package/dist/esm/index.test.js.map +0 -1
- package/dist/esm/renderElementAsReact.test.js +0 -51
- package/dist/esm/renderElementAsReact.test.js.map +0 -1
- package/dist/esm/useExtensions.test.js +0 -644
- package/dist/esm/useExtensions.test.js.map +0 -1
- package/dist/types/ExtensionPoint.test.d.ts +0 -2
- package/dist/types/ExtensionPoint.test.d.ts.map +0 -1
- package/dist/types/ExtensionPointInfo.test.d.ts +0 -2
- package/dist/types/ExtensionPointInfo.test.d.ts.map +0 -1
- package/dist/types/ExtensionsObservable.test.d.ts +0 -2
- package/dist/types/ExtensionsObservable.test.d.ts.map +0 -1
- package/dist/types/debug/useDebug.test.d.ts +0 -2
- package/dist/types/debug/useDebug.test.d.ts.map +0 -1
- package/dist/types/debug/useDiscovery.test.d.ts +0 -2
- package/dist/types/debug/useDiscovery.test.d.ts.map +0 -1
- package/dist/types/debug/useLogging.test.d.ts +0 -2
- package/dist/types/debug/useLogging.test.d.ts.map +0 -1
- package/dist/types/debug/useValidation.test.d.ts +0 -2
- package/dist/types/debug/useValidation.test.d.ts.map +0 -1
- package/dist/types/handlers/AsyncPanelHandler.test.d.ts +0 -2
- package/dist/types/handlers/AsyncPanelHandler.test.d.ts.map +0 -1
- package/dist/types/handlers/ButtonHandler.test.d.ts +0 -2
- package/dist/types/handlers/ButtonHandler.test.d.ts.map +0 -1
- package/dist/types/handlers/LinkHandler.test.d.ts +0 -2
- package/dist/types/handlers/LinkHandler.test.d.ts.map +0 -1
- package/dist/types/handlers/ModalHandler.test.d.ts +0 -2
- package/dist/types/handlers/ModalHandler.test.d.ts.map +0 -1
- package/dist/types/handlers/PanelHandler.test.d.ts +0 -2
- package/dist/types/handlers/PanelHandler.test.d.ts.map +0 -1
- package/dist/types/handlers/SectionHandler.test.d.ts +0 -2
- package/dist/types/handlers/SectionHandler.test.d.ts.map +0 -1
- package/dist/types/index.test.d.ts +0 -1
- package/dist/types/index.test.d.ts.map +0 -1
- package/dist/types/renderElementAsReact.test.d.ts +0 -2
- package/dist/types/renderElementAsReact.test.d.ts.map +0 -1
- package/dist/types/useExtensions.test.d.ts +0 -2
- package/dist/types/useExtensions.test.d.ts.map +0 -1
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const react_1 = (0, tslib_1.__importStar)(require("react"));
|
|
6
6
|
const useExtensions_1 = require("./useExtensions");
|
|
7
7
|
const ExtensionPoint = ({ name, context = null, options, children }) => {
|
|
8
|
-
const [supportedDescriptors, unsupportedDescriptors, isLoading] = useExtensions_1.useExtensionsAll(name, context, options);
|
|
8
|
+
const [supportedDescriptors, unsupportedDescriptors, isLoading] = (0, useExtensions_1.useExtensionsAll)(name, context, options);
|
|
9
9
|
if (typeof children !== 'function') {
|
|
10
|
-
clientside_extensions_debug_1.onDebug(({ error }) => {
|
|
10
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => {
|
|
11
11
|
return {
|
|
12
12
|
level: error,
|
|
13
13
|
message: `ExtensionPoint expects a render-child.\nThe "children"-property passed for extension point "${name}" is not a function.`,
|
|
@@ -23,5 +23,5 @@ const ExtensionPoint = ({ name, context = null, options, children }) => {
|
|
|
23
23
|
}
|
|
24
24
|
return react_1.default.createElement(react_1.default.Fragment, null, children(supportedDescriptors, unsupportedDescriptors, isLoading));
|
|
25
25
|
};
|
|
26
|
-
exports.default = react_1.memo(ExtensionPoint);
|
|
26
|
+
exports.default = (0, react_1.memo)(ExtensionPoint);
|
|
27
27
|
//# sourceMappingURL=ExtensionPoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionPoint.js","sourceRoot":"","sources":["../../lib/ExtensionPoint.tsx"],"names":[],"mappings":";;;AACA,wFAAiE;AACjE,
|
|
1
|
+
{"version":3,"file":"ExtensionPoint.js","sourceRoot":"","sources":["../../lib/ExtensionPoint.tsx"],"names":[],"mappings":";;;AACA,wFAAiE;AACjE,4DAAoC;AACpC,mDAAmD;AAUnD,MAAM,cAAc,GAAkC,CAAC,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;IAClG,MAAM,CAAC,oBAAoB,EAAE,sBAAsB,EAAE,SAAS,CAAC,GAAG,IAAA,gCAAgB,EAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAE3G,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE;QAChC,IAAA,qCAAO,EAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;YAClB,OAAO;gBACH,KAAK,EAAE,KAAK;gBAEZ,OAAO,EAAE,+FAA+F,IAAI,sBAAsB;gBAClI,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,EAAE;oBACF,IAAI;oBACJ,OAAO;oBACP,OAAO;iBACV;aACJ,CAAC;QACN,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;KACf;IAED,OAAO,8DAAG,QAAQ,CAAC,oBAAoB,EAAE,sBAAsB,EAAE,SAAS,CAAC,CAAI,CAAC;AACpF,CAAC,CAAC;AAEF,kBAAe,IAAA,YAAI,EAAC,cAAc,CAAC,CAAC","sourcesContent":["import type { Context, ExtensionDescriptor } from '@atlassian/clientside-extensions-registry';\nimport { onDebug } from '@atlassian/clientside-extensions-debug';\nimport React, { memo } from 'react';\nimport { useExtensionsAll } from './useExtensions';\nimport type { ExtensionPointCallback, Options } from './types';\n\nexport interface ExtensionPointProps {\n name: string;\n context?: Context<{}> | null;\n options: Options;\n children: ExtensionPointCallback<ExtensionDescriptor>;\n}\n\nconst ExtensionPoint: React.FC<ExtensionPointProps> = ({ name, context = null, options, children }) => {\n const [supportedDescriptors, unsupportedDescriptors, isLoading] = useExtensionsAll(name, context, options);\n\n if (typeof children !== 'function') {\n onDebug(({ error }) => {\n return {\n level: error,\n\n message: `ExtensionPoint expects a render-child.\\nThe \"children\"-property passed for extension point \"${name}\" is not a function.`,\n components: 'ExtensionPoint',\n meta: {\n name,\n context,\n options,\n },\n };\n });\n return null;\n }\n\n return <>{children(supportedDescriptors, unsupportedDescriptors, isLoading)}</>;\n};\n\nexport default memo(ExtensionPoint);\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
-
const standard_button_1 = tslib_1.__importDefault(require("@atlaskit/button/standard-button"));
|
|
6
|
-
const modal_dialog_1 = tslib_1.__importStar(require("@atlaskit/modal-dialog"));
|
|
4
|
+
const react_1 = (0, tslib_1.__importStar)(require("react"));
|
|
5
|
+
const standard_button_1 = (0, tslib_1.__importDefault)(require("@atlaskit/button/standard-button"));
|
|
6
|
+
const modal_dialog_1 = (0, tslib_1.__importStar)(require("@atlaskit/modal-dialog"));
|
|
7
7
|
const react_scroll_1 = require("react-scroll");
|
|
8
8
|
const constants_1 = require("@atlaskit/theme/constants");
|
|
9
|
-
const useDiscovery_1 = tslib_1.__importDefault(require("./debug/useDiscovery"));
|
|
9
|
+
const useDiscovery_1 = (0, tslib_1.__importDefault)(require("./debug/useDiscovery"));
|
|
10
10
|
const styled_1 = require("./styled");
|
|
11
11
|
const LinkToElement = ({ to }) => {
|
|
12
12
|
// TODO: is there a way to get the clean type from the schema?
|
|
@@ -83,15 +83,15 @@ const bodyStyles = {
|
|
|
83
83
|
overflowY: 'auto',
|
|
84
84
|
overflowX: 'hidden',
|
|
85
85
|
// The rest of the styles are copied from the @atlaskit/modal-dialog/dist/esm/modal-body.js
|
|
86
|
-
padding: constants_1.gridSize() * 3,
|
|
86
|
+
padding: (0, constants_1.gridSize)() * 3,
|
|
87
87
|
flex: '1 1 auto',
|
|
88
88
|
};
|
|
89
89
|
const CustomModalBody = ({ children }) => {
|
|
90
90
|
return (react_1.default.createElement("div", { id: "___cse_info_container", style: bodyStyles }, children));
|
|
91
91
|
};
|
|
92
92
|
const ExtensionPointInfo = ({ name, schemaDocuments }) => {
|
|
93
|
-
const [showExtensionPointInfo] = useDiscovery_1.default();
|
|
94
|
-
const [dialogOpen, setDialogState] = react_1.useState(false);
|
|
93
|
+
const [showExtensionPointInfo] = (0, useDiscovery_1.default)();
|
|
94
|
+
const [dialogOpen, setDialogState] = (0, react_1.useState)(false);
|
|
95
95
|
const closeDialog = () => setDialogState(false);
|
|
96
96
|
return !showExtensionPointInfo ? null : (react_1.default.createElement(styled_1.BlinkerContainer, null,
|
|
97
97
|
react_1.default.createElement(styled_1.Blinker, { type: "button", onClick: () => setDialogState(true) }),
|
|
@@ -103,5 +103,5 @@ const ExtensionPointInfo = ({ name, schemaDocuments }) => {
|
|
|
103
103
|
react_1.default.createElement(modal_dialog_1.ModalFooter, null,
|
|
104
104
|
react_1.default.createElement(standard_button_1.default, { appearance: "primary", autoFocus: true, onClick: closeDialog }, "Close")))))));
|
|
105
105
|
};
|
|
106
|
-
exports.default = react_1.memo(ExtensionPointInfo);
|
|
106
|
+
exports.default = (0, react_1.memo)(ExtensionPointInfo);
|
|
107
107
|
//# sourceMappingURL=ExtensionPointInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionPointInfo.js","sourceRoot":"","sources":["../../lib/ExtensionPointInfo.tsx"],"names":[],"mappings":";;;AACA,uDAA8C;AAC9C,+FAAsD;AACtD,+EAAsG;AACtG,+CAA6C;AAW7C,yDAAqD;AACrD,gFAAgD;AAChD,qCAAoG;AAOpG,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,E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C;AACN,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAsC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE;IACxF,MAAM,CAAC,sBAAsB,CAAC,GAAG,sBAAY,EAAE,CAAC;IAChD,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,gBAAQ,CAAC,KAAK,CAAC,CAAC;IAErD,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACpC,8BAAC,yBAAgB;QACb,8BAAC,gBAAO,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAI;QAC9D,8BAAC,8BAAe,QACX,UAAU,IAAI,CACX,8BAAC,sBAAK,IAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAC,SAAS;YACxC,8BAAC,0BAAW;gBACR,8BAAC,yBAAU,QAAE,oBAAoB,IAAI,EAAE,CAAc,CAC3C;YAEd,8BAAC,eAAe;gBACZ,8BAAC,eAAe,IAAC,eAAe,EAAE,eAAe,GAAI,CACvC;YAElB,8BAAC,0BAAW;gBACR,8BAAC,yBAAM,IAAC,UAAU,EAAC,SAAS,EAAC,SAAS,QAAC,OAAO,EAAE,WAAW,YAElD,CACC,CACV,CACX,CACa,CACH,CACtB,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,YAAI,CAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import type { FunctionComponent } from 'react';\nimport React, { memo, useState } from 'react';\nimport Button from '@atlaskit/button/standard-button';\nimport Modal, { ModalTransition, ModalTitle, ModalHeader, ModalFooter } from '@atlaskit/modal-dialog';\nimport { Link, Element } from 'react-scroll';\n\nimport type {\n SerializedDocument,\n SerializedEnumType,\n SerializedObjectType,\n SerializedScalar,\n SerializedUnionType,\n // We only import types here\n // eslint-disable-next-line node/no-unpublished-import\n} from '@atlassian/clientside-extensions-schema';\nimport { gridSize } from '@atlaskit/theme/constants';\nimport useDiscovery from './debug/useDiscovery';\nimport { Table, TableCell, TableRow, HeadRow, HeadCell, Blinker, BlinkerContainer } from './styled';\n\nexport type ExtensionPointInfoProps = {\n name: string;\n schemaDocuments: { schema: SerializedDocument; contextSchema: SerializedDocument };\n};\n\nconst LinkToElement = ({ to }: { to: string }) => {\n // TODO: is there a way to get the clean type from the schema?\n // We are removing the e.g. \"!\" required syntax that is a suffix of the schema type\n const cleanTo = to.replace(/[^a-zA-Z0-9]/g, '');\n\n return (\n // eslint-disable-next-line jsx-a11y/anchor-is-valid\n <Link to={cleanTo} href=\"\" containerId=\"___cse_info_container\" offset={-20} smooth>\n {to}\n </Link>\n );\n};\n\nconst TypeRenderer: FunctionComponent<{ objectType: SerializedObjectType }> = ({ objectType }) => (\n <>\n <p>{objectType.description}</p>\n <Table>\n <thead>\n <HeadRow>\n <HeadCell>Name</HeadCell>\n <HeadCell>Type</HeadCell>\n <HeadCell>Required</HeadCell>\n <HeadCell>Description</HeadCell>\n </HeadRow>\n </thead>\n <tbody>\n {objectType.descriptors.map((descriptor) => (\n <TableRow key={descriptor.name}>\n <TableCell width=\"15%\"> {descriptor.name}</TableCell>\n <TableCell width=\"15%\">\n <LinkToElement to={descriptor.type} />\n </TableCell>\n <TableCell width=\"10%\">{descriptor.required ? 'true' : 'false'}</TableCell>\n <TableCell>{descriptor.description}</TableCell>\n </TableRow>\n ))}\n </tbody>\n </Table>\n </>\n);\n\nconst EnumTypeRenderer = ({ enumType }: { enumType: SerializedEnumType }) => (\n <>\n <h3>\n <Element name={enumType.name}>{enumType.name}</Element>\n </h3>\n {enumType.description ? (\n <p>{enumType.description}</p>\n ) : (\n <p>\n Enum type with the following values: <b>{enumType.values.join(', ')}</b>\n </p>\n )}\n </>\n);\n\nconst UnionTypeRenderer = ({ unionType }: { unionType: SerializedUnionType }) => (\n <>\n <h3>\n <Element name={unionType.name}>{unionType.name}</Element>\n </h3>\n {unionType.description ? (\n <p>{unionType.description}</p>\n ) : (\n <p>\n Union of the following types:{' '}\n {unionType.types.map((_type, i) => (\n <React.Fragment key={`${_type}-link`}>\n {i === 0 ? '' : ', '}\n <LinkToElement to={_type} />\n </React.Fragment>\n ))}\n </p>\n )}\n </>\n);\n\nconst ScalarRenderer = ({ scalar }: { scalar: SerializedScalar }) => (\n <>\n <h3>\n <Element name={scalar.name}>{scalar.name}</Element>\n </h3>\n <p>{scalar.description}</p>\n </>\n);\n\nconst SchemasRenderer = ({ schemaDocuments: { schema, contextSchema } }: Omit<ExtensionPointInfoProps, 'name'>) => {\n const {\n objectTypes: { Schema: attributesDocument, ...attributeObjectTypes } = { Schema: null },\n scalars: attributeScalars,\n enumTypes: attributesEnumTypes,\n unionTypes: attributesUnionTypes,\n } = schema || {};\n\n const {\n objectTypes: { ContextSchema: contextDocument, ...contextObjectTypes } = { ContextSchema: null },\n scalars: contextScalars,\n enumTypes: contextEnumTypes,\n unionTypes: contextUnionTypes,\n } = contextSchema || {};\n\n const objectTypeEntries: SerializedObjectType[] = Object.values({ ...attributeObjectTypes, ...contextObjectTypes });\n const scalars: SerializedScalar[] = Object.values({ ...attributeScalars, ...contextScalars });\n const enumTypes: SerializedEnumType[] = Object.values({ ...attributesEnumTypes, ...contextEnumTypes });\n const unionTypes: SerializedUnionType[] = Object.values({ ...attributesUnionTypes, ...contextUnionTypes });\n\n return (\n <>\n <h2>Attributes</h2>\n {attributesDocument ? (\n <>\n <p>List of attributes supported by this extension point.</p>\n <TypeRenderer objectType={attributesDocument} />\n </>\n ) : (\n <p>No attributes information provided for this extension point.</p>\n )}\n\n <h2>Context</h2>\n {contextDocument ? (\n <>\n <p>List of values provided by this extension point as context.</p>\n <TypeRenderer objectType={contextDocument} />\n </>\n ) : (\n <p>No context information provided for this extension point.</p>\n )}\n\n <h2>Types reference</h2>\n {objectTypeEntries &&\n objectTypeEntries.map((objectType) => (\n <React.Fragment key={objectType.name}>\n <h3>\n <Element name={objectType.name}>{objectType.name}</Element>\n </h3>\n <TypeRenderer objectType={objectType} />\n </React.Fragment>\n ))}\n\n {enumTypes && enumTypes.map((enumType) => <EnumTypeRenderer key={enumType.name} enumType={enumType} />)}\n\n {unionTypes && unionTypes.map((unionType) => <UnionTypeRenderer key={unionType.name} unionType={unionType} />)}\n\n {scalars && scalars.map((scalar) => <ScalarRenderer key={scalar.name} scalar={scalar} />)}\n </>\n );\n};\n\nconst bodyStyles: React.CSSProperties = {\n // Styles required for the react-scroll to work when scrolling is animated\n overflowY: 'auto',\n overflowX: 'hidden',\n // The rest of the styles are copied from the @atlaskit/modal-dialog/dist/esm/modal-body.js\n padding: gridSize() * 3,\n flex: '1 1 auto',\n};\n\nconst CustomModalBody: React.FC = ({ children }) => {\n return (\n <div id=\"___cse_info_container\" style={bodyStyles}>\n {children}\n </div>\n );\n};\n\nconst ExtensionPointInfo: React.FC<ExtensionPointInfoProps> = ({ name, schemaDocuments }) => {\n const [showExtensionPointInfo] = useDiscovery();\n const [dialogOpen, setDialogState] = useState(false);\n\n const closeDialog = () => setDialogState(false);\n return !showExtensionPointInfo ? null : (\n <BlinkerContainer>\n <Blinker type=\"button\" onClick={() => setDialogState(true)} />\n <ModalTransition>\n {dialogOpen && (\n <Modal onClose={closeDialog} width=\"x-large\">\n <ModalHeader>\n <ModalTitle>{`Extension point: ${name}`}</ModalTitle>\n </ModalHeader>\n\n <CustomModalBody>\n <SchemasRenderer schemaDocuments={schemaDocuments} />\n </CustomModalBody>\n\n <ModalFooter>\n <Button appearance=\"primary\" autoFocus onClick={closeDialog}>\n Close\n </Button>\n </ModalFooter>\n </Modal>\n )}\n </ModalTransition>\n </BlinkerContainer>\n );\n};\n\nexport default memo(ExtensionPointInfo);\n"]}
|
|
1
|
+
{"version":3,"file":"ExtensionPointInfo.js","sourceRoot":"","sources":["../../lib/ExtensionPointInfo.tsx"],"names":[],"mappings":";;;AACA,4DAA8C;AAC9C,oGAAsD;AACt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AQ,EAAE,EAAE,EAAE;IAC/C,OAAO,CACH,uCAAK,EAAE,EAAC,uBAAuB,EAAC,KAAK,EAAE,UAAU,IAC5C,QAAQ,CACP,CACT,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAsC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,EAAE,EAAE;IACxF,MAAM,CAAC,sBAAsB,CAAC,GAAG,IAAA,sBAAY,GAAE,CAAC;IAChD,MAAM,CAAC,UAAU,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAErD,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAChD,OAAO,CAAC,sBAAsB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CACpC,8BAAC,yBAAgB;QACb,8BAAC,gBAAO,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAI;QAC9D,8BAAC,8BAAe,QACX,UAAU,IAAI,CACX,8BAAC,sBAAK,IAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAC,SAAS;YACxC,8BAAC,0BAAW;gBACR,8BAAC,yBAAU,QAAE,oBAAoB,IAAI,EAAE,CAAc,CAC3C;YAEd,8BAAC,eAAe;gBACZ,8BAAC,eAAe,IAAC,eAAe,EAAE,eAAe,GAAI,CACvC;YAElB,8BAAC,0BAAW;gBAER,8BAAC,yBAAM,IAAC,UAAU,EAAC,SAAS,EAAC,SAAS,QAAC,OAAO,EAAE,WAAW,YAElD,CACC,CACV,CACX,CACa,CACH,CACtB,CAAC;AACN,CAAC,CAAC;AAEF,kBAAe,IAAA,YAAI,EAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import type { FunctionComponent } from 'react';\nimport React, { memo, useState } from 'react';\nimport Button from '@atlaskit/button/standard-button';\nimport Modal, { ModalTransition, ModalTitle, ModalHeader, ModalFooter } from '@atlaskit/modal-dialog';\nimport { Link, Element } from 'react-scroll';\n\nimport type {\n SerializedDocument,\n SerializedEnumType,\n SerializedObjectType,\n SerializedScalar,\n SerializedUnionType,\n // We only import types here\n // eslint-disable-next-line node/no-unpublished-import\n} from '@atlassian/clientside-extensions-schema';\nimport { gridSize } from '@atlaskit/theme/constants';\nimport useDiscovery from './debug/useDiscovery';\nimport { Table, TableCell, TableRow, HeadRow, HeadCell, Blinker, BlinkerContainer } from './styled';\n\nexport type ExtensionPointInfoProps = {\n name: string;\n schemaDocuments: { schema: SerializedDocument; contextSchema: SerializedDocument };\n};\n\nconst LinkToElement = ({ to }: { to: string }) => {\n // TODO: is there a way to get the clean type from the schema?\n // We are removing the e.g. \"!\" required syntax that is a suffix of the schema type\n const cleanTo = to.replace(/[^a-zA-Z0-9]/g, '');\n\n return (\n // eslint-disable-next-line jsx-a11y/anchor-is-valid\n <Link to={cleanTo} href=\"\" containerId=\"___cse_info_container\" offset={-20} smooth>\n {to}\n </Link>\n );\n};\n\nconst TypeRenderer: FunctionComponent<{ objectType: SerializedObjectType }> = ({ objectType }) => (\n <>\n <p>{objectType.description}</p>\n <Table>\n <thead>\n <HeadRow>\n <HeadCell>Name</HeadCell>\n <HeadCell>Type</HeadCell>\n <HeadCell>Required</HeadCell>\n <HeadCell>Description</HeadCell>\n </HeadRow>\n </thead>\n <tbody>\n {objectType.descriptors.map((descriptor) => (\n <TableRow key={descriptor.name}>\n <TableCell width=\"15%\"> {descriptor.name}</TableCell>\n <TableCell width=\"15%\">\n <LinkToElement to={descriptor.type} />\n </TableCell>\n <TableCell width=\"10%\">{descriptor.required ? 'true' : 'false'}</TableCell>\n <TableCell>{descriptor.description}</TableCell>\n </TableRow>\n ))}\n </tbody>\n </Table>\n </>\n);\n\nconst EnumTypeRenderer = ({ enumType }: { enumType: SerializedEnumType }) => (\n <>\n <h3>\n <Element name={enumType.name}>{enumType.name}</Element>\n </h3>\n {enumType.description ? (\n <p>{enumType.description}</p>\n ) : (\n <p>\n Enum type with the following values: <b>{enumType.values.join(', ')}</b>\n </p>\n )}\n </>\n);\n\nconst UnionTypeRenderer = ({ unionType }: { unionType: SerializedUnionType }) => (\n <>\n <h3>\n <Element name={unionType.name}>{unionType.name}</Element>\n </h3>\n {unionType.description ? (\n <p>{unionType.description}</p>\n ) : (\n <p>\n Union of the following types:{' '}\n {unionType.types.map((_type, i) => (\n <React.Fragment key={`${_type}-link`}>\n {i === 0 ? '' : ', '}\n <LinkToElement to={_type} />\n </React.Fragment>\n ))}\n </p>\n )}\n </>\n);\n\nconst ScalarRenderer = ({ scalar }: { scalar: SerializedScalar }) => (\n <>\n <h3>\n <Element name={scalar.name}>{scalar.name}</Element>\n </h3>\n <p>{scalar.description}</p>\n </>\n);\n\nconst SchemasRenderer = ({ schemaDocuments: { schema, contextSchema } }: Omit<ExtensionPointInfoProps, 'name'>) => {\n const {\n objectTypes: { Schema: attributesDocument, ...attributeObjectTypes } = { Schema: null },\n scalars: attributeScalars,\n enumTypes: attributesEnumTypes,\n unionTypes: attributesUnionTypes,\n } = schema || {};\n\n const {\n objectTypes: { ContextSchema: contextDocument, ...contextObjectTypes } = { ContextSchema: null },\n scalars: contextScalars,\n enumTypes: contextEnumTypes,\n unionTypes: contextUnionTypes,\n } = contextSchema || {};\n\n const objectTypeEntries: SerializedObjectType[] = Object.values({ ...attributeObjectTypes, ...contextObjectTypes });\n const scalars: SerializedScalar[] = Object.values({ ...attributeScalars, ...contextScalars });\n const enumTypes: SerializedEnumType[] = Object.values({ ...attributesEnumTypes, ...contextEnumTypes });\n const unionTypes: SerializedUnionType[] = Object.values({ ...attributesUnionTypes, ...contextUnionTypes });\n\n return (\n <>\n <h2>Attributes</h2>\n {attributesDocument ? (\n <>\n <p>List of attributes supported by this extension point.</p>\n <TypeRenderer objectType={attributesDocument} />\n </>\n ) : (\n <p>No attributes information provided for this extension point.</p>\n )}\n\n <h2>Context</h2>\n {contextDocument ? (\n <>\n <p>List of values provided by this extension point as context.</p>\n <TypeRenderer objectType={contextDocument} />\n </>\n ) : (\n <p>No context information provided for this extension point.</p>\n )}\n\n <h2>Types reference</h2>\n {objectTypeEntries &&\n objectTypeEntries.map((objectType) => (\n <React.Fragment key={objectType.name}>\n <h3>\n <Element name={objectType.name}>{objectType.name}</Element>\n </h3>\n <TypeRenderer objectType={objectType} />\n </React.Fragment>\n ))}\n\n {enumTypes && enumTypes.map((enumType) => <EnumTypeRenderer key={enumType.name} enumType={enumType} />)}\n\n {unionTypes && unionTypes.map((unionType) => <UnionTypeRenderer key={unionType.name} unionType={unionType} />)}\n\n {scalars && scalars.map((scalar) => <ScalarRenderer key={scalar.name} scalar={scalar} />)}\n </>\n );\n};\n\nconst bodyStyles: React.CSSProperties = {\n // Styles required for the react-scroll to work when scrolling is animated\n overflowY: 'auto',\n overflowX: 'hidden',\n // The rest of the styles are copied from the @atlaskit/modal-dialog/dist/esm/modal-body.js\n padding: gridSize() * 3,\n flex: '1 1 auto',\n};\n\nconst CustomModalBody: React.FC = ({ children }) => {\n return (\n <div id=\"___cse_info_container\" style={bodyStyles}>\n {children}\n </div>\n );\n};\n\nconst ExtensionPointInfo: React.FC<ExtensionPointInfoProps> = ({ name, schemaDocuments }) => {\n const [showExtensionPointInfo] = useDiscovery();\n const [dialogOpen, setDialogState] = useState(false);\n\n const closeDialog = () => setDialogState(false);\n return !showExtensionPointInfo ? null : (\n <BlinkerContainer>\n <Blinker type=\"button\" onClick={() => setDialogState(true)} />\n <ModalTransition>\n {dialogOpen && (\n <Modal onClose={closeDialog} width=\"x-large\">\n <ModalHeader>\n <ModalTitle>{`Extension point: ${name}`}</ModalTitle>\n </ModalHeader>\n\n <CustomModalBody>\n <SchemasRenderer schemaDocuments={schemaDocuments} />\n </CustomModalBody>\n\n <ModalFooter>\n {/* eslint-disable-next-line jsx-a11y/no-autofocus */}\n <Button appearance=\"primary\" autoFocus onClick={closeDialog}>\n Close\n </Button>\n </ModalFooter>\n </Modal>\n )}\n </ModalTransition>\n </BlinkerContainer>\n );\n};\n\nexport default memo(ExtensionPointInfo);\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getValidatedExtensions = exports.getExtensionPointSubscription = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const clientside_extensions_registry_1 = tslib_1.__importDefault(require("@atlassian/clientside-extensions-registry"));
|
|
5
|
+
const clientside_extensions_registry_1 = (0, tslib_1.__importDefault)(require("@atlassian/clientside-extensions-registry"));
|
|
6
6
|
const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
|
|
7
7
|
const clientside_extensions_base_1 = require("@atlassian/clientside-extensions-base");
|
|
8
8
|
const types_1 = require("./types");
|
|
@@ -12,7 +12,7 @@ const safeguardAction = (action, descriptorKey, location) => {
|
|
|
12
12
|
return action(...args);
|
|
13
13
|
}
|
|
14
14
|
catch (e) {
|
|
15
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
15
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
16
16
|
level: error,
|
|
17
17
|
message: `Failed to execute onAction callback for extension "${descriptorKey}" at extension: ${location}.
|
|
18
18
|
Error: ${e}`,
|
|
@@ -62,7 +62,7 @@ const getExtensionApi = (key, extensionPoint, attributeMap, queueUpdate, cleanup
|
|
|
62
62
|
queueUpdate(key);
|
|
63
63
|
}
|
|
64
64
|
catch (e) {
|
|
65
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
65
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
66
66
|
level: error,
|
|
67
67
|
message: `Updating attributes for extension ${key} failed:
|
|
68
68
|
${e}`,
|
|
@@ -93,7 +93,7 @@ const getExtensionAttributes = (key, extensionPoint, attributesProvider, baseAtt
|
|
|
93
93
|
providedAttributes = rawProvidedAttributes;
|
|
94
94
|
}
|
|
95
95
|
catch (e) {
|
|
96
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
96
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
97
97
|
level: error,
|
|
98
98
|
message: `Calling the attributes provider for extension ${key} failed:
|
|
99
99
|
${e}`,
|
|
@@ -161,7 +161,7 @@ const createCleanupCallbackQueue = () => {
|
|
|
161
161
|
callback();
|
|
162
162
|
}
|
|
163
163
|
catch (e) {
|
|
164
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
164
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
165
165
|
level: error,
|
|
166
166
|
message: `Failed to execute cleanup callback registered for "${descriptorKey}".
|
|
167
167
|
See passed callback for reference: ${callback}`,
|
|
@@ -180,7 +180,7 @@ See passed callback for reference: ${callback}`,
|
|
|
180
180
|
};
|
|
181
181
|
const EMPTY_PAYLOAD = { state: { descriptors: [], loadingState: true }, update: [] };
|
|
182
182
|
// eslint-disable-next-line import/prefer-default-export
|
|
183
|
-
|
|
183
|
+
const getExtensionPointSubscription = (extensionPoint, context) => {
|
|
184
184
|
let singletonObserver;
|
|
185
185
|
let currentState = [];
|
|
186
186
|
let currentLoadingState = true;
|
|
@@ -243,6 +243,7 @@ exports.getExtensionPointSubscription = (extensionPoint, context) => {
|
|
|
243
243
|
},
|
|
244
244
|
};
|
|
245
245
|
};
|
|
246
|
+
exports.getExtensionPointSubscription = getExtensionPointSubscription;
|
|
246
247
|
const componentDebugName = 'Schema Validation';
|
|
247
248
|
const gerErrorMessages = (errors) => errors.map(({ error }) => error);
|
|
248
249
|
const getWarningMessages = (errors) => errors.map(({ warning }) => warning);
|
|
@@ -256,7 +257,7 @@ const runValidation = (validator, payload, extensionPoint, extensionKey) => {
|
|
|
256
257
|
const { errors, warnings } = validator(payload);
|
|
257
258
|
if (errors.length !== 0) {
|
|
258
259
|
const errorMessages = gerErrorMessages(errors);
|
|
259
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
260
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
260
261
|
level: error,
|
|
261
262
|
message: `Schema validation for extension "${extensionKey}" returned errors.`,
|
|
262
263
|
components: componentDebugName,
|
|
@@ -269,7 +270,7 @@ const runValidation = (validator, payload, extensionPoint, extensionKey) => {
|
|
|
269
270
|
}
|
|
270
271
|
if (warnings.length !== 0) {
|
|
271
272
|
const warningMessages = getWarningMessages(warnings);
|
|
272
|
-
clientside_extensions_debug_1.onDebug(({ warn }) => ({
|
|
273
|
+
(0, clientside_extensions_debug_1.onDebug)(({ warn }) => ({
|
|
273
274
|
level: warn,
|
|
274
275
|
message: `Schema validator for extension "${extensionKey}" returned warnings.`,
|
|
275
276
|
components: componentDebugName,
|
|
@@ -299,7 +300,7 @@ const runContextValidation = (extensionPoint, validator, context) => {
|
|
|
299
300
|
({ errors, warnings } = validator(context));
|
|
300
301
|
if (errors.length) {
|
|
301
302
|
const errorMessages = gerErrorMessages(errors);
|
|
302
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
303
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
303
304
|
level: error,
|
|
304
305
|
message: `The context validation for extension-location "${extensionPoint}" returned errors.`,
|
|
305
306
|
components: componentDebugName,
|
|
@@ -312,7 +313,7 @@ const runContextValidation = (extensionPoint, validator, context) => {
|
|
|
312
313
|
}
|
|
313
314
|
if (warnings.length) {
|
|
314
315
|
const warningMessages = getWarningMessages(warnings);
|
|
315
|
-
clientside_extensions_debug_1.onDebug(({ warn }) => ({
|
|
316
|
+
(0, clientside_extensions_debug_1.onDebug)(({ warn }) => ({
|
|
316
317
|
level: warn,
|
|
317
318
|
message: `The context validation for extension-location "${extensionPoint}" returned warnings.`,
|
|
318
319
|
components: componentDebugName,
|
|
@@ -332,7 +333,7 @@ const transferDescriptorBetweenMaps = (descriptor, addToMap, removeFromMap) => {
|
|
|
332
333
|
}
|
|
333
334
|
addToMap.set(descriptor.key, descriptor);
|
|
334
335
|
};
|
|
335
|
-
|
|
336
|
+
const getValidatedExtensions = (extensionPointName, context, options) => {
|
|
336
337
|
const { contextValidator, attributeValidator } = options;
|
|
337
338
|
const isContextValid = runContextValidation(extensionPointName, contextValidator, context);
|
|
338
339
|
if (!isContextValid) {
|
|
@@ -342,7 +343,7 @@ exports.getValidatedExtensions = (extensionPointName, context, options) => {
|
|
|
342
343
|
let singletonObserver;
|
|
343
344
|
const supportedDescriptors = new Map();
|
|
344
345
|
const unsupportedDescriptors = new Map();
|
|
345
|
-
const subscription = exports.getExtensionPointSubscription(extensionPointName, context).subscribe(({ state, update }) => {
|
|
346
|
+
const subscription = (0, exports.getExtensionPointSubscription)(extensionPointName, context).subscribe(({ state, update }) => {
|
|
346
347
|
const { loadingState } = state;
|
|
347
348
|
// only reevaluate the updated descriptors
|
|
348
349
|
update.forEach((descriptor) => {
|
|
@@ -375,4 +376,5 @@ exports.getValidatedExtensions = (extensionPointName, context, options) => {
|
|
|
375
376
|
},
|
|
376
377
|
};
|
|
377
378
|
};
|
|
379
|
+
exports.getValidatedExtensions = getValidatedExtensions;
|
|
378
380
|
//# sourceMappingURL=ExtensionsObservable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionsObservable.js","sourceRoot":"","sources":["../../lib/ExtensionsObservable.ts"],"names":[],"mappings":";;;;AAUA,uHAAiE;AACjE,wFAAiE;AAEjE,sFAAsE;AAKtE,mCAA+C;AAE/C,MAAM,eAAe,GAAG,CAAC,MAAgB,EAAE,aAAqB,EAAE,QAAgB,EAAY,EAAE;IAC5F,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE;QAC1B,IAAI;YACA,OAAO,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;SAC1B;QAAC,OAAO,CAAC,EAAE;YACR,qCAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;gBACpB,KAAK,EAAE,KAAK;gBACZ,OAAO,EAAE,sDAAsD,aAAa,mBAAmB,QAAQ;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ACjC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;aACxF;YAED,iBAAiB,GAAG,QAAQ,CAAC;YAC7B,0BAA0B,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC/C,OAAO;gBACH,WAAW,EAAE,GAAG,EAAE;oBACd,0BAA0B,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;oBAC1D,YAAY,CAAC,WAAW,EAAE,CAAC;gBAC/B,CAAC;aACJ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type {\n Context,\n ExtensionAPI,\n ExtensionAttributes,\n ExtensionAttributesProvider,\n ExtensionCleanupCallback,\n ExtensionDescriptor,\n MaybeOnAction,\n OnAction,\n} from '@atlassian/clientside-extensions-registry';\nimport registry from '@atlassian/clientside-extensions-registry';\nimport { onDebug } from '@atlassian/clientside-extensions-debug';\nimport type { Observable, Observer } from '@atlassian/clientside-extensions-base';\nimport { ReplaySubject } from '@atlassian/clientside-extensions-base';\n// We only import types here\n// eslint-disable-next-line node/no-unpublished-import\nimport type { Validator, ValidationError, ValidationWarning } from '@atlassian/clientside-extensions-schema';\nimport type { ExtensionPointUpdate, ExtensionState, Options } from './types';\nimport { isNotNullOrUndefined } from './types';\n\nconst safeguardAction = (action: OnAction, descriptorKey: string, location: string): OnAction => {\n return (...args: unknown[]) => {\n try {\n return action(...args);\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Failed to execute onAction callback for extension \"${descriptorKey}\" at extension: ${location}.\n Error: ${e}`,\n meta: {\n extension: descriptorKey,\n location,\n },\n }));\n return undefined;\n }\n };\n};\n\nconst actionsCache = new Map<OnAction, OnAction>();\nconst cachedSafeguardAction = (maybeAction: MaybeOnAction, descriptorKey: string, location: string): OnAction | undefined => {\n if (!maybeAction) {\n return undefined;\n }\n\n const action = maybeAction as OnAction;\n\n if (actionsCache.has(action)) {\n return actionsCache.get(action);\n }\n\n const guardedAction = safeguardAction(action, descriptorKey, location);\n\n actionsCache.set(action, guardedAction);\n\n return guardedAction;\n};\n\nconst mergeAttributes = (\n base: ExtensionAttributes,\n provided: ExtensionAttributes,\n onAction?: ExtensionAttributes['onAction'],\n): ExtensionAttributes => {\n if (!onAction) {\n return {\n ...base,\n ...provided,\n };\n }\n\n return {\n ...base,\n ...provided,\n onAction,\n };\n};\n\nconst getExtensionApi = (\n key: string,\n extensionPoint: string,\n attributeMap: Map<string, ExtensionAttributes>,\n queueUpdate: ReturnType<typeof createAnimationFrameQueue>,\n cleanupCallbackQueue: ReturnType<typeof createCleanupCallbackQueue>['queue'],\n) => {\n const extensionAPI: ExtensionAPI = {\n updateAttributes(fnOrAttributes) {\n const currentAttributes = (attributeMap.has(key) && attributeMap.get(key)) || {};\n\n try {\n const updatedAttributes = typeof fnOrAttributes === 'function' ? fnOrAttributes(currentAttributes) : fnOrAttributes;\n const attributes = { ...currentAttributes, ...updatedAttributes };\n attributeMap.set(key, attributes);\n queueUpdate(key);\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Updating attributes for extension ${key} failed:\n${e}`,\n meta: {\n extension: key,\n location: extensionPoint,\n },\n }));\n }\n },\n onCleanup(cleanupCallback) {\n cleanupCallbackQueue.push([key, cleanupCallback]);\n },\n };\n return extensionAPI;\n};\n\nconst getExtensionAttributes = (\n key: string,\n extensionPoint: string,\n attributesProvider: ExtensionAttributesProvider | undefined,\n baseAttributes: ExtensionDescriptor['attributes'],\n extensionAPI: ExtensionAPI,\n context: Context<{}> | null,\n): ExtensionAttributes | undefined => {\n if (!attributesProvider) {\n return baseAttributes;\n }\n\n // Try to get the attributes from the provider\n let providedAttributes: ExtensionAttributes = {};\n\n try {\n const rawProvidedAttributes = attributesProvider(extensionAPI, context);\n\n if (!rawProvidedAttributes || Object.getPrototypeOf(rawProvidedAttributes) !== Object.prototype) {\n throw new TypeError('The attributes provider functions should return attributes object');\n }\n\n providedAttributes = rawProvidedAttributes;\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Calling the attributes provider for extension ${key} failed:\n ${e}`,\n meta: {\n extension: key,\n location: extensionPoint,\n },\n }));\n\n return undefined;\n }\n\n // Cache the onAction if present\n const onAction = providedAttributes.onAction && cachedSafeguardAction(providedAttributes.onAction, key, extensionPoint);\n\n return mergeAttributes(baseAttributes, providedAttributes, onAction);\n};\n\nconst sortDescriptorsByWeight = <T extends ExtensionAttributes>(extensionDescriptors: ExtensionDescriptor<T>[]) => {\n return extensionDescriptors.sort((a: ExtensionDescriptor<T>, b: ExtensionDescriptor<T>) => {\n const aWeight = a?.attributes?.weight ?? Infinity;\n const bWeight = b?.attributes?.weight ?? Infinity;\n\n return aWeight - bWeight;\n });\n};\n\ntype DescriptorUpdateBatch<T extends ExtensionAttributes> = {\n descriptors: ExtensionDescriptor<T>[];\n updatedDescriptors: ExtensionDescriptor<T>[];\n};\nconst inlineUpdateAttributes = <T extends ExtensionAttributes>(\n keys: Set<string>,\n attributeMap: Map<string, ExtensionAttributes>,\n descriptors: ExtensionDescriptor<T>[],\n): DescriptorUpdateBatch<T> => {\n const updated: ExtensionDescriptor<T>[] = [];\n descriptors\n .filter((descriptor) => keys.has(descriptor.key))\n .forEach((descriptor) => {\n descriptor.attributes = {\n ...descriptor.attributes,\n ...attributeMap.get(descriptor.key),\n };\n updated.push(descriptor);\n });\n\n return {\n descriptors: sortDescriptorsByWeight<T>(descriptors),\n updatedDescriptors: updated,\n };\n};\n\nconst createAnimationFrameQueue = (callback: (params: Set<string>) => void) => {\n let queue = new Set<string>();\n let requestIsQueued = false;\n const flushUpdate = () => {\n requestIsQueued = false;\n callback(queue);\n queue = new Set();\n };\n\n return (key: string) => {\n queue.add(key);\n\n if (!requestIsQueued) {\n requestIsQueued = true;\n requestAnimationFrame(flushUpdate);\n }\n };\n};\n\nconst createCleanupCallbackQueue = () => {\n const queue: [string, ExtensionCleanupCallback][] = [];\n const cleanUp = () => {\n while (queue.length) {\n const result = queue.shift();\n\n if (!result) {\n break;\n }\n\n const [descriptorKey, callback] = result;\n\n try {\n callback();\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Failed to execute cleanup callback registered for \"${descriptorKey}\".\nSee passed callback for reference: ${callback}`,\n meta: {\n extension: descriptorKey,\n callback,\n },\n }));\n }\n }\n };\n\n return {\n queue,\n cleanUp,\n };\n};\n\nconst EMPTY_PAYLOAD: ExtensionPointUpdate = { state: { descriptors: [], loadingState: true }, update: [] };\n\n// eslint-disable-next-line import/prefer-default-export\nexport const getExtensionPointSubscription = <ContextT extends Context<{}> | null, AttributesT extends ExtensionAttributes>(\n extensionPoint: string,\n context: ContextT,\n): Observable<ExtensionPointUpdate<AttributesT>> => {\n let singletonObserver: Observer<ExtensionPointUpdate<AttributesT>>;\n let currentState: ExtensionDescriptor<AttributesT>[] = [];\n let currentLoadingState: boolean = true;\n\n const updateSubject = new ReplaySubject<ExtensionPointUpdate<AttributesT>>(1);\n const cleanupCallbackQueue = createCleanupCallbackQueue();\n const descriptorAttributeMap = new Map<string, ExtensionAttributes>();\n\n const animationFrameQueue = createAnimationFrameQueue((updatedKeys) => {\n const { descriptors, updatedDescriptors } = inlineUpdateAttributes(updatedKeys, descriptorAttributeMap, currentState);\n currentState = descriptors;\n updateSubject.notify({ state: { descriptors: currentState, loadingState: currentLoadingState }, update: updatedDescriptors });\n });\n\n const subscription = registry.getLocation(extensionPoint).subscribe(({ descriptors, loadingState }) => {\n // no need to validate while we are still loading.\n if (loadingState) {\n // @ts-expect-error Some issues with generics\n updateSubject.notify(EMPTY_PAYLOAD);\n return;\n }\n\n /*\n * TODO\n * - do we need to remove descriptors from the `descriptorMap` if they are no longer within the listed descriptors?\n * - do we need to override descriptors everytime they get \"re-registered\" or is that a `dev-mode` only feature?\n */\n const extensionDescriptors = descriptors\n .map((rawDescriptor): ExtensionDescriptor<AttributesT> | undefined => {\n const { attributesProvider, attributes: baseAttributes, key, ...descriptor } = rawDescriptor;\n\n const extensionAPI = getExtensionApi(\n key,\n extensionPoint,\n descriptorAttributeMap,\n animationFrameQueue,\n cleanupCallbackQueue.queue,\n );\n\n const maybeAttributes = getExtensionAttributes(\n key,\n extensionPoint,\n attributesProvider,\n baseAttributes,\n extensionAPI,\n context,\n );\n\n if (maybeAttributes === undefined) {\n return undefined;\n }\n\n const attributes: ExtensionAttributes = maybeAttributes;\n\n descriptorAttributeMap.set(key, attributes);\n\n const fullDescriptor: ExtensionDescriptor<AttributesT> = {\n ...descriptor,\n key,\n attributes: attributes as AttributesT,\n };\n\n return fullDescriptor;\n })\n .filter(isNotNullOrUndefined);\n\n currentState = sortDescriptorsByWeight<AttributesT>(extensionDescriptors);\n currentLoadingState = loadingState;\n\n updateSubject.notify({ state: { descriptors: currentState, loadingState }, update: currentState });\n });\n\n return {\n subscribe: (observer: Observer<ExtensionPointUpdate<AttributesT>>) => {\n if (singletonObserver !== undefined) {\n throw new Error('Only one observer is allowed to be registered on this Observable.');\n }\n\n singletonObserver = observer;\n updateSubject.subscribe(observer);\n return {\n unsubscribe: () => {\n updateSubject.unsubscribe(singletonObserver);\n subscription.unsubscribe();\n cleanupCallbackQueue.cleanUp();\n },\n };\n },\n };\n};\n\nconst componentDebugName = 'Schema Validation';\n\nconst gerErrorMessages = (errors: ValidationError[]): string[] => errors.map(({ error }) => error);\nconst getWarningMessages = (errors: ValidationWarning[]): string[] => errors.map(({ warning }) => warning);\n\n/**\n * Validates the attributes against the schema. Returns true if the attributes are valid.\n */\nconst runValidation = (validator: Validator, payload: unknown, extensionPoint: string, extensionKey: string): boolean => {\n if (!validator) {\n throw new Error(`No validator specified to validate extension point \"${extensionPoint}\"`);\n }\n\n const { errors, warnings } = validator(payload);\n\n if (errors.length !== 0) {\n const errorMessages = gerErrorMessages(errors);\n\n onDebug(({ error }) => ({\n level: error,\n message: `Schema validation for extension \"${extensionKey}\" returned errors.`,\n components: componentDebugName,\n meta: {\n location: extensionPoint,\n extension: extensionKey,\n errors: errorMessages,\n },\n }));\n }\n\n if (warnings.length !== 0) {\n const warningMessages = getWarningMessages(warnings);\n\n onDebug(({ warn }) => ({\n level: warn,\n message: `Schema validator for extension \"${extensionKey}\" returned warnings.`,\n components: componentDebugName,\n meta: {\n location: extensionPoint,\n extension: extensionKey,\n warnings: warningMessages,\n },\n }));\n }\n\n return errors.length === 0;\n};\n\n/**\n * Validates the context against the context schema. Returns true if the context is valid.\n */\nconst runContextValidation = (extensionPoint: string, validator: Validator | undefined, context: Context<{}> | null): boolean => {\n // This is a feedback for product developers and should not run in production\n if (process.env.NODE_ENV === 'production') {\n return true;\n }\n\n let errors: ValidationError[] = [];\n let warnings: ValidationWarning[] = [];\n\n if (context) {\n if (!validator) {\n throw new Error(`No context validator specified for extension point \"${extensionPoint}\"`);\n }\n\n ({ errors, warnings } = validator(context));\n\n if (errors.length) {\n const errorMessages = gerErrorMessages(errors);\n\n onDebug(({ error }) => ({\n level: error,\n message: `The context validation for extension-location \"${extensionPoint}\" returned errors.`,\n components: componentDebugName,\n meta: {\n extensionPoint,\n context,\n errors: errorMessages,\n },\n }));\n }\n if (warnings.length) {\n const warningMessages = getWarningMessages(warnings);\n\n onDebug(({ warn }) => ({\n level: warn,\n message: `The context validation for extension-location \"${extensionPoint}\" returned warnings.`,\n components: componentDebugName,\n meta: {\n extensionPoint,\n context,\n warnings: warningMessages,\n },\n }));\n }\n }\n\n return errors.length === 0;\n};\n\ntype DescriptorMap<T extends ExtensionAttributes = ExtensionAttributes> = Map<string, ExtensionDescriptor<T>>;\n\nconst transferDescriptorBetweenMaps = <T extends ExtensionAttributes>(\n descriptor: ExtensionDescriptor<T>,\n addToMap: DescriptorMap<T>,\n removeFromMap: DescriptorMap<T>,\n) => {\n if (removeFromMap.has(descriptor.key)) {\n removeFromMap.delete(descriptor.key);\n }\n addToMap.set(descriptor.key, descriptor);\n};\n\nexport const getValidatedExtensions = <ContextT extends Context<{}> | null, AttributesU extends ExtensionAttributes>(\n extensionPointName: string,\n context: ContextT,\n options: Options,\n): Observable<ExtensionState<AttributesU>> => {\n const { contextValidator, attributeValidator } = options;\n\n const isContextValid = runContextValidation(extensionPointName, contextValidator, context);\n\n if (!isContextValid) {\n throw new Error(`The context provided for extension-location \"${extensionPointName}\" does not match the schema`);\n }\n\n const validatedExtensionsSubject = new ReplaySubject<ExtensionState<AttributesU>>(1);\n let singletonObserver: Observer<ExtensionState<AttributesU>>;\n const supportedDescriptors: DescriptorMap<AttributesU> = new Map<string, ExtensionDescriptor<AttributesU>>();\n const unsupportedDescriptors: DescriptorMap<AttributesU> = new Map<string, ExtensionDescriptor<AttributesU>>();\n\n const subscription = getExtensionPointSubscription<ContextT, AttributesU>(extensionPointName, context).subscribe(\n ({ state, update }) => {\n const { loadingState } = state;\n\n // only reevaluate the updated descriptors\n update.forEach((descriptor) => {\n if (!runValidation(attributeValidator, descriptor.attributes, extensionPointName, descriptor.key)) {\n transferDescriptorBetweenMaps<AttributesU>(descriptor, unsupportedDescriptors, supportedDescriptors);\n } else {\n transferDescriptorBetweenMaps<AttributesU>(descriptor, supportedDescriptors, unsupportedDescriptors);\n }\n });\n\n validatedExtensionsSubject.notify([\n Array.from(supportedDescriptors.values()),\n Array.from(unsupportedDescriptors.values()),\n loadingState,\n ]);\n },\n );\n\n return {\n subscribe: (observer: Observer<ExtensionState<AttributesU>>) => {\n if (singletonObserver !== undefined) {\n throw new Error('Only one observer is allowed to be registered on this Observable.');\n }\n\n singletonObserver = observer;\n validatedExtensionsSubject.subscribe(observer);\n return {\n unsubscribe: () => {\n validatedExtensionsSubject.unsubscribe(singletonObserver);\n subscription.unsubscribe();\n },\n };\n },\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"ExtensionsObservable.js","sourceRoot":"","sources":["../../lib/ExtensionsObservable.ts"],"names":[],"mappings":";;;;AAUA,4HAAiE;AACjE,wFAAiE;AAEjE,sFAAsE;AAKtE,mCAA+C;AAE/C,MAAM,eAAe,GAAG,CAAC,MAAgB,EAAE,aAAqB,EAAE,QAAgB,EAAY,EAAE;IAC5F,OAAO,CAAC,GAAG,IA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BAAsB,CAAC,CAAC;aACxG;QACL,CAAC,CAAC,CAAC;QAEH,0BAA0B,CAAC,MAAM,CAAC;YAC9B,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;YACzC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,CAAC;YAC3C,YAAY;SACf,CAAC,CAAC;IACP,CAAC,CACJ,CAAC;IAEF,OAAO;QACH,SAAS,EAAE,CAAC,QAA+C,EAAE,EAAE;YAC3D,IAAI,iBAAiB,KAAK,SAAS,EAAE;gBACjC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;aACxF;YAED,iBAAiB,GAAG,QAAQ,CAAC;YAC7B,0BAA0B,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;YAC/C,OAAO;gBACH,WAAW,EAAE,GAAG,EAAE;oBACd,0BAA0B,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;oBAC1D,YAAY,CAAC,WAAW,EAAE,CAAC;gBAC/B,CAAC;aACJ,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC,CAAC;AAvDW,QAAA,sBAAsB,0BAuDjC","sourcesContent":["import type {\n Context,\n ExtensionAPI,\n ExtensionAttributes,\n ExtensionAttributesProvider,\n ExtensionCleanupCallback,\n ExtensionDescriptor,\n MaybeOnAction,\n OnAction,\n} from '@atlassian/clientside-extensions-registry';\nimport registry from '@atlassian/clientside-extensions-registry';\nimport { onDebug } from '@atlassian/clientside-extensions-debug';\nimport type { Observable, Observer } from '@atlassian/clientside-extensions-base';\nimport { ReplaySubject } from '@atlassian/clientside-extensions-base';\n// We only import types here\n// eslint-disable-next-line node/no-unpublished-import\nimport type { Validator, ValidationError, ValidationWarning } from '@atlassian/clientside-extensions-schema';\nimport type { ExtensionPointUpdate, ExtensionState, Options } from './types';\nimport { isNotNullOrUndefined } from './types';\n\nconst safeguardAction = (action: OnAction, descriptorKey: string, location: string): OnAction => {\n return (...args: unknown[]) => {\n try {\n return action(...args);\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Failed to execute onAction callback for extension \"${descriptorKey}\" at extension: ${location}.\n Error: ${e}`,\n meta: {\n extension: descriptorKey,\n location,\n },\n }));\n return undefined;\n }\n };\n};\n\nconst actionsCache = new Map<OnAction, OnAction>();\nconst cachedSafeguardAction = (maybeAction: MaybeOnAction, descriptorKey: string, location: string): OnAction | undefined => {\n if (!maybeAction) {\n return undefined;\n }\n\n const action = maybeAction as OnAction;\n\n if (actionsCache.has(action)) {\n return actionsCache.get(action);\n }\n\n const guardedAction = safeguardAction(action, descriptorKey, location);\n\n actionsCache.set(action, guardedAction);\n\n return guardedAction;\n};\n\nconst mergeAttributes = (\n base: ExtensionAttributes,\n provided: ExtensionAttributes,\n onAction?: ExtensionAttributes['onAction'],\n): ExtensionAttributes => {\n if (!onAction) {\n return {\n ...base,\n ...provided,\n };\n }\n\n return {\n ...base,\n ...provided,\n onAction,\n };\n};\n\nconst getExtensionApi = (\n key: string,\n extensionPoint: string,\n attributeMap: Map<string, ExtensionAttributes>,\n queueUpdate: ReturnType<typeof createAnimationFrameQueue>,\n cleanupCallbackQueue: ReturnType<typeof createCleanupCallbackQueue>['queue'],\n) => {\n const extensionAPI: ExtensionAPI = {\n updateAttributes(fnOrAttributes) {\n const currentAttributes = (attributeMap.has(key) && attributeMap.get(key)) || {};\n\n try {\n const updatedAttributes = typeof fnOrAttributes === 'function' ? fnOrAttributes(currentAttributes) : fnOrAttributes;\n const attributes = { ...currentAttributes, ...updatedAttributes };\n attributeMap.set(key, attributes);\n queueUpdate(key);\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Updating attributes for extension ${key} failed:\n${e}`,\n meta: {\n extension: key,\n location: extensionPoint,\n },\n }));\n }\n },\n onCleanup(cleanupCallback) {\n cleanupCallbackQueue.push([key, cleanupCallback]);\n },\n };\n return extensionAPI;\n};\n\nconst getExtensionAttributes = (\n key: string,\n extensionPoint: string,\n attributesProvider: ExtensionAttributesProvider | undefined,\n baseAttributes: ExtensionDescriptor['attributes'],\n extensionAPI: ExtensionAPI,\n context: Context<{}> | null,\n): ExtensionAttributes | undefined => {\n if (!attributesProvider) {\n return baseAttributes;\n }\n\n // Try to get the attributes from the provider\n let providedAttributes: ExtensionAttributes = {};\n\n try {\n const rawProvidedAttributes = attributesProvider(extensionAPI, context);\n\n if (!rawProvidedAttributes || Object.getPrototypeOf(rawProvidedAttributes) !== Object.prototype) {\n throw new TypeError('The attributes provider functions should return attributes object');\n }\n\n providedAttributes = rawProvidedAttributes;\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Calling the attributes provider for extension ${key} failed:\n ${e}`,\n meta: {\n extension: key,\n location: extensionPoint,\n },\n }));\n\n return undefined;\n }\n\n // Cache the onAction if present\n const onAction = providedAttributes.onAction && cachedSafeguardAction(providedAttributes.onAction, key, extensionPoint);\n\n return mergeAttributes(baseAttributes, providedAttributes, onAction);\n};\n\nconst sortDescriptorsByWeight = <T extends ExtensionAttributes>(extensionDescriptors: ExtensionDescriptor<T>[]) => {\n return extensionDescriptors.sort((a: ExtensionDescriptor<T>, b: ExtensionDescriptor<T>) => {\n const aWeight = a?.attributes?.weight ?? Infinity;\n const bWeight = b?.attributes?.weight ?? Infinity;\n\n return aWeight - bWeight;\n });\n};\n\ntype DescriptorUpdateBatch<T extends ExtensionAttributes> = {\n descriptors: ExtensionDescriptor<T>[];\n updatedDescriptors: ExtensionDescriptor<T>[];\n};\nconst inlineUpdateAttributes = <T extends ExtensionAttributes>(\n keys: Set<string>,\n attributeMap: Map<string, ExtensionAttributes>,\n descriptors: ExtensionDescriptor<T>[],\n): DescriptorUpdateBatch<T> => {\n const updated: ExtensionDescriptor<T>[] = [];\n descriptors\n .filter((descriptor) => keys.has(descriptor.key))\n .forEach((descriptor) => {\n descriptor.attributes = {\n ...descriptor.attributes,\n ...attributeMap.get(descriptor.key),\n };\n updated.push(descriptor);\n });\n\n return {\n descriptors: sortDescriptorsByWeight<T>(descriptors),\n updatedDescriptors: updated,\n };\n};\n\nconst createAnimationFrameQueue = (callback: (params: Set<string>) => void) => {\n let queue = new Set<string>();\n let requestIsQueued = false;\n const flushUpdate = () => {\n requestIsQueued = false;\n callback(queue);\n queue = new Set();\n };\n\n return (key: string) => {\n queue.add(key);\n\n if (!requestIsQueued) {\n requestIsQueued = true;\n requestAnimationFrame(flushUpdate);\n }\n };\n};\n\nconst createCleanupCallbackQueue = () => {\n const queue: [string, ExtensionCleanupCallback][] = [];\n const cleanUp = () => {\n while (queue.length) {\n const result = queue.shift();\n\n if (!result) {\n break;\n }\n\n const [descriptorKey, callback] = result;\n\n try {\n callback();\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Failed to execute cleanup callback registered for \"${descriptorKey}\".\nSee passed callback for reference: ${callback}`,\n meta: {\n extension: descriptorKey,\n callback,\n },\n }));\n }\n }\n };\n\n return {\n queue,\n cleanUp,\n };\n};\n\nconst EMPTY_PAYLOAD: ExtensionPointUpdate = { state: { descriptors: [], loadingState: true }, update: [] };\n\n// eslint-disable-next-line import/prefer-default-export\nexport const getExtensionPointSubscription = <ContextT extends Context<{}> | null, AttributesT extends ExtensionAttributes>(\n extensionPoint: string,\n context: ContextT,\n): Observable<ExtensionPointUpdate<AttributesT>> => {\n let singletonObserver: Observer<ExtensionPointUpdate<AttributesT>>;\n let currentState: ExtensionDescriptor<AttributesT>[] = [];\n let currentLoadingState: boolean = true;\n\n const updateSubject = new ReplaySubject<ExtensionPointUpdate<AttributesT>>(1);\n const cleanupCallbackQueue = createCleanupCallbackQueue();\n const descriptorAttributeMap = new Map<string, ExtensionAttributes>();\n\n const animationFrameQueue = createAnimationFrameQueue((updatedKeys) => {\n const { descriptors, updatedDescriptors } = inlineUpdateAttributes(updatedKeys, descriptorAttributeMap, currentState);\n currentState = descriptors;\n updateSubject.notify({ state: { descriptors: currentState, loadingState: currentLoadingState }, update: updatedDescriptors });\n });\n\n const subscription = registry.getLocation(extensionPoint).subscribe(({ descriptors, loadingState }) => {\n // no need to validate while we are still loading.\n if (loadingState) {\n // @ts-expect-error Some issues with generics\n updateSubject.notify(EMPTY_PAYLOAD);\n return;\n }\n\n /*\n * TODO\n * - do we need to remove descriptors from the `descriptorMap` if they are no longer within the listed descriptors?\n * - do we need to override descriptors everytime they get \"re-registered\" or is that a `dev-mode` only feature?\n */\n const extensionDescriptors = descriptors\n .map((rawDescriptor): ExtensionDescriptor<AttributesT> | undefined => {\n const { attributesProvider, attributes: baseAttributes, key, ...descriptor } = rawDescriptor;\n\n const extensionAPI = getExtensionApi(\n key,\n extensionPoint,\n descriptorAttributeMap,\n animationFrameQueue,\n cleanupCallbackQueue.queue,\n );\n\n const maybeAttributes = getExtensionAttributes(\n key,\n extensionPoint,\n attributesProvider,\n baseAttributes,\n extensionAPI,\n context,\n );\n\n if (maybeAttributes === undefined) {\n return undefined;\n }\n\n const attributes: ExtensionAttributes = maybeAttributes;\n\n descriptorAttributeMap.set(key, attributes);\n\n const fullDescriptor: ExtensionDescriptor<AttributesT> = {\n ...descriptor,\n key,\n attributes: attributes as AttributesT,\n };\n\n return fullDescriptor;\n })\n .filter(isNotNullOrUndefined);\n\n currentState = sortDescriptorsByWeight<AttributesT>(extensionDescriptors);\n currentLoadingState = loadingState;\n\n updateSubject.notify({ state: { descriptors: currentState, loadingState }, update: currentState });\n });\n\n return {\n subscribe: (observer: Observer<ExtensionPointUpdate<AttributesT>>) => {\n if (singletonObserver !== undefined) {\n throw new Error('Only one observer is allowed to be registered on this Observable.');\n }\n\n singletonObserver = observer;\n updateSubject.subscribe(observer);\n return {\n unsubscribe: () => {\n updateSubject.unsubscribe(singletonObserver);\n subscription.unsubscribe();\n cleanupCallbackQueue.cleanUp();\n },\n };\n },\n };\n};\n\nconst componentDebugName = 'Schema Validation';\n\nconst gerErrorMessages = (errors: ValidationError[]): string[] => errors.map(({ error }) => error);\nconst getWarningMessages = (errors: ValidationWarning[]): string[] => errors.map(({ warning }) => warning);\n\n/**\n * Validates the attributes against the schema. Returns true if the attributes are valid.\n */\nconst runValidation = (validator: Validator, payload: unknown, extensionPoint: string, extensionKey: string): boolean => {\n if (!validator) {\n throw new Error(`No validator specified to validate extension point \"${extensionPoint}\"`);\n }\n\n const { errors, warnings } = validator(payload);\n\n if (errors.length !== 0) {\n const errorMessages = gerErrorMessages(errors);\n\n onDebug(({ error }) => ({\n level: error,\n message: `Schema validation for extension \"${extensionKey}\" returned errors.`,\n components: componentDebugName,\n meta: {\n location: extensionPoint,\n extension: extensionKey,\n errors: errorMessages,\n },\n }));\n }\n\n if (warnings.length !== 0) {\n const warningMessages = getWarningMessages(warnings);\n\n onDebug(({ warn }) => ({\n level: warn,\n message: `Schema validator for extension \"${extensionKey}\" returned warnings.`,\n components: componentDebugName,\n meta: {\n location: extensionPoint,\n extension: extensionKey,\n warnings: warningMessages,\n },\n }));\n }\n\n return errors.length === 0;\n};\n\n/**\n * Validates the context against the context schema. Returns true if the context is valid.\n */\nconst runContextValidation = (extensionPoint: string, validator: Validator | undefined, context: Context<{}> | null): boolean => {\n // This is a feedback for product developers and should not run in production\n if (process.env.NODE_ENV === 'production') {\n return true;\n }\n\n let errors: ValidationError[] = [];\n let warnings: ValidationWarning[] = [];\n\n if (context) {\n if (!validator) {\n throw new Error(`No context validator specified for extension point \"${extensionPoint}\"`);\n }\n\n ({ errors, warnings } = validator(context));\n\n if (errors.length) {\n const errorMessages = gerErrorMessages(errors);\n\n onDebug(({ error }) => ({\n level: error,\n message: `The context validation for extension-location \"${extensionPoint}\" returned errors.`,\n components: componentDebugName,\n meta: {\n extensionPoint,\n context,\n errors: errorMessages,\n },\n }));\n }\n if (warnings.length) {\n const warningMessages = getWarningMessages(warnings);\n\n onDebug(({ warn }) => ({\n level: warn,\n message: `The context validation for extension-location \"${extensionPoint}\" returned warnings.`,\n components: componentDebugName,\n meta: {\n extensionPoint,\n context,\n warnings: warningMessages,\n },\n }));\n }\n }\n\n return errors.length === 0;\n};\n\ntype DescriptorMap<T extends ExtensionAttributes = ExtensionAttributes> = Map<string, ExtensionDescriptor<T>>;\n\nconst transferDescriptorBetweenMaps = <T extends ExtensionAttributes>(\n descriptor: ExtensionDescriptor<T>,\n addToMap: DescriptorMap<T>,\n removeFromMap: DescriptorMap<T>,\n) => {\n if (removeFromMap.has(descriptor.key)) {\n removeFromMap.delete(descriptor.key);\n }\n addToMap.set(descriptor.key, descriptor);\n};\n\nexport const getValidatedExtensions = <ContextT extends Context<{}> | null, AttributesU extends ExtensionAttributes>(\n extensionPointName: string,\n context: ContextT,\n options: Options,\n): Observable<ExtensionState<AttributesU>> => {\n const { contextValidator, attributeValidator } = options;\n\n const isContextValid = runContextValidation(extensionPointName, contextValidator, context);\n\n if (!isContextValid) {\n throw new Error(`The context provided for extension-location \"${extensionPointName}\" does not match the schema`);\n }\n\n const validatedExtensionsSubject = new ReplaySubject<ExtensionState<AttributesU>>(1);\n let singletonObserver: Observer<ExtensionState<AttributesU>>;\n const supportedDescriptors: DescriptorMap<AttributesU> = new Map<string, ExtensionDescriptor<AttributesU>>();\n const unsupportedDescriptors: DescriptorMap<AttributesU> = new Map<string, ExtensionDescriptor<AttributesU>>();\n\n const subscription = getExtensionPointSubscription<ContextT, AttributesU>(extensionPointName, context).subscribe(\n ({ state, update }) => {\n const { loadingState } = state;\n\n // only reevaluate the updated descriptors\n update.forEach((descriptor) => {\n if (!runValidation(attributeValidator, descriptor.attributes, extensionPointName, descriptor.key)) {\n transferDescriptorBetweenMaps<AttributesU>(descriptor, unsupportedDescriptors, supportedDescriptors);\n } else {\n transferDescriptorBetweenMaps<AttributesU>(descriptor, supportedDescriptors, unsupportedDescriptors);\n }\n });\n\n validatedExtensionsSubject.notify([\n Array.from(supportedDescriptors.values()),\n Array.from(unsupportedDescriptors.values()),\n loadingState,\n ]);\n },\n );\n\n return {\n subscribe: (observer: Observer<ExtensionState<AttributesU>>) => {\n if (singletonObserver !== undefined) {\n throw new Error('Only one observer is allowed to be registered on this Observable.');\n }\n\n singletonObserver = observer;\n validatedExtensionsSubject.subscribe(observer);\n return {\n unsubscribe: () => {\n validatedExtensionsSubject.unsubscribe(singletonObserver);\n subscription.unsubscribe();\n },\n };\n },\n };\n};\n"]}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
|
|
5
5
|
const useDebug = () => {
|
|
6
|
-
const [debugState, setDebugState] = react_1.useState(clientside_extensions_debug_1.isDebugEnabled());
|
|
7
|
-
react_1.useEffect(() => {
|
|
8
|
-
const subscription = clientside_extensions_debug_1.observeStateChange((newState) => {
|
|
6
|
+
const [debugState, setDebugState] = (0, react_1.useState)((0, clientside_extensions_debug_1.isDebugEnabled)());
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
const subscription = (0, clientside_extensions_debug_1.observeStateChange)((newState) => {
|
|
9
9
|
setDebugState(newState.debug);
|
|
10
10
|
});
|
|
11
11
|
return () => subscription.unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDebug.js","sourceRoot":"","sources":["../../../lib/debug/useDebug.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAA6G;AAG7G,MAAM,QAAQ,GAAG,GAAoB,EAAE;IACnC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"useDebug.js","sourceRoot":"","sources":["../../../lib/debug/useDebug.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAA6G;AAG7G,MAAM,QAAQ,GAAG,GAAoB,EAAE;IACnC,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,IAAA,gBAAQ,EAAU,IAAA,4CAAc,GAAE,CAAC,CAAC;IAExE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,MAAM,YAAY,GAAG,IAAA,gDAAkB,EAAC,CAAC,QAAQ,EAAE,EAAE;YACjD,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,UAAU,EAAE,6CAAe,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { isDebugEnabled, setDebugEnabled, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport type { DebugToggleHook } from './types';\n\nconst useDebug = (): DebugToggleHook => {\n const [debugState, setDebugState] = useState<boolean>(isDebugEnabled());\n\n useEffect(() => {\n const subscription = observeStateChange((newState) => {\n setDebugState(newState.debug);\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return [debugState, setDebugEnabled];\n};\n\nexport default useDebug;\n"]}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
|
|
5
5
|
const useDiscovery = () => {
|
|
6
|
-
const [discoveryState, setDiscoveryState] = react_1.useState(clientside_extensions_debug_1.isDiscoveryEnabled());
|
|
7
|
-
react_1.useEffect(() => {
|
|
8
|
-
const subscription = clientside_extensions_debug_1.observeStateChange((newState) => {
|
|
6
|
+
const [discoveryState, setDiscoveryState] = (0, react_1.useState)((0, clientside_extensions_debug_1.isDiscoveryEnabled)());
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
const subscription = (0, clientside_extensions_debug_1.observeStateChange)((newState) => {
|
|
9
9
|
setDiscoveryState(newState.discovery);
|
|
10
10
|
});
|
|
11
11
|
return () => subscription.unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDiscovery.js","sourceRoot":"","sources":["../../../lib/debug/useDiscovery.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAAqH;AAGrH,MAAM,YAAY,GAAG,GAAoB,EAAE;IACvC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"useDiscovery.js","sourceRoot":"","sources":["../../../lib/debug/useDiscovery.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAAqH;AAGrH,MAAM,YAAY,GAAG,GAAoB,EAAE;IACvC,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAU,IAAA,gDAAkB,GAAE,CAAC,CAAC;IAEpF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,MAAM,YAAY,GAAG,IAAA,gDAAkB,EAAC,CAAC,QAAQ,EAAE,EAAE;YACjD,iBAAiB,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,cAAc,EAAE,iDAAmB,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF,kBAAe,YAAY,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { isDiscoveryEnabled, setDiscoveryEnabled, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport type { DebugToggleHook } from './types';\n\nconst useDiscovery = (): DebugToggleHook => {\n const [discoveryState, setDiscoveryState] = useState<boolean>(isDiscoveryEnabled());\n\n useEffect(() => {\n const subscription = observeStateChange((newState) => {\n setDiscoveryState(newState.discovery);\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return [discoveryState, setDiscoveryEnabled];\n};\n\nexport default useDiscovery;\n"]}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
|
|
5
5
|
const useLogging = () => {
|
|
6
|
-
const [loggingState, setLoggingState] = react_1.useState(clientside_extensions_debug_1.isLoggingEnabled());
|
|
7
|
-
react_1.useEffect(() => {
|
|
8
|
-
const subscription = clientside_extensions_debug_1.observeStateChange((newState) => {
|
|
6
|
+
const [loggingState, setLoggingState] = (0, react_1.useState)((0, clientside_extensions_debug_1.isLoggingEnabled)());
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
const subscription = (0, clientside_extensions_debug_1.observeStateChange)((newState) => {
|
|
9
9
|
setLoggingState(newState.logging);
|
|
10
10
|
});
|
|
11
11
|
return () => subscription.unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLogging.js","sourceRoot":"","sources":["../../../lib/debug/useLogging.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAAiH;AAGjH,MAAM,UAAU,GAAG,GAAoB,EAAE;IACrC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"useLogging.js","sourceRoot":"","sources":["../../../lib/debug/useLogging.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAAiH;AAGjH,MAAM,UAAU,GAAG,GAAoB,EAAE;IACrC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAU,IAAA,8CAAgB,GAAE,CAAC,CAAC;IAE9E,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,MAAM,YAAY,GAAG,IAAA,gDAAkB,EAAC,CAAC,QAAQ,EAAE,EAAE;YACjD,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,YAAY,EAAE,+CAAiB,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,kBAAe,UAAU,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { isLoggingEnabled, setLoggingEnabled, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport type { DebugToggleHook } from './types';\n\nconst useLogging = (): DebugToggleHook => {\n const [loggingState, setLoggingState] = useState<boolean>(isLoggingEnabled());\n\n useEffect(() => {\n const subscription = observeStateChange((newState) => {\n setLoggingState(newState.logging);\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return [loggingState, setLoggingEnabled];\n};\n\nexport default useLogging;\n"]}
|
|
@@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const react_1 = require("react");
|
|
4
4
|
const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
|
|
5
5
|
const useValidation = () => {
|
|
6
|
-
const [validationState, setValidationState] = react_1.useState(clientside_extensions_debug_1.isValidationEnabled());
|
|
7
|
-
react_1.useEffect(() => {
|
|
8
|
-
const subscription = clientside_extensions_debug_1.observeStateChange((newState) => {
|
|
6
|
+
const [validationState, setValidationState] = (0, react_1.useState)((0, clientside_extensions_debug_1.isValidationEnabled)());
|
|
7
|
+
(0, react_1.useEffect)(() => {
|
|
8
|
+
const subscription = (0, clientside_extensions_debug_1.observeStateChange)((newState) => {
|
|
9
9
|
setValidationState(newState.validation);
|
|
10
10
|
});
|
|
11
11
|
return () => subscription.unsubscribe();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useValidation.js","sourceRoot":"","sources":["../../../lib/debug/useValidation.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAAuH;AAGvH,MAAM,aAAa,GAAG,GAAoB,EAAE;IACxC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,gBAAQ,
|
|
1
|
+
{"version":3,"file":"useValidation.js","sourceRoot":"","sources":["../../../lib/debug/useValidation.ts"],"names":[],"mappings":";;AAAA,iCAA4C;AAC5C,wFAAuH;AAGvH,MAAM,aAAa,GAAG,GAAoB,EAAE;IACxC,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,IAAA,gBAAQ,EAAU,IAAA,iDAAmB,GAAE,CAAC,CAAC;IAEvF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,MAAM,YAAY,GAAG,IAAA,gDAAkB,EAAC,CAAC,QAAQ,EAAE,EAAE;YACjD,kBAAkB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,WAAW,EAAE,CAAC;IAC5C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,eAAe,EAAE,kDAAoB,CAAC,CAAC;AACnD,CAAC,CAAC;AAEF,kBAAe,aAAa,CAAC","sourcesContent":["import { useEffect, useState } from 'react';\nimport { isValidationEnabled, setValidationEnabled, observeStateChange } from '@atlassian/clientside-extensions-debug';\nimport type { DebugToggleHook } from './types';\n\nconst useValidation = (): DebugToggleHook => {\n const [validationState, setValidationState] = useState<boolean>(isValidationEnabled());\n\n useEffect(() => {\n const subscription = observeStateChange((newState) => {\n setValidationState(newState.validation);\n });\n return () => subscription.unsubscribe();\n }, []);\n\n return [validationState, setValidationEnabled];\n};\n\nexport default useValidation;\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AsyncPanelHandler = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
|
+
const react_1 = (0, tslib_1.__importStar)(require("react"));
|
|
6
6
|
const clientside_extensions_debug_1 = require("@atlassian/clientside-extensions-debug");
|
|
7
7
|
const PanelHandler_1 = require("./PanelHandler");
|
|
8
8
|
const noop = () => { };
|
|
@@ -11,7 +11,7 @@ const loadModule = async (moduleProvider, extensionKey, location) => {
|
|
|
11
11
|
const resolvedModule = await moduleProvider();
|
|
12
12
|
// eslint-disable-next-line no-underscore-dangle
|
|
13
13
|
if (!resolvedModule || !resolvedModule.__esModule || typeof resolvedModule.default !== 'function') {
|
|
14
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
14
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
15
15
|
level: error,
|
|
16
16
|
message: `The provided dynamic import of extension "${extensionKey}" at location "${location}" does not look like a module that can be asynchronously loaded.`,
|
|
17
17
|
components: ['AsyncPanelHandler'],
|
|
@@ -25,7 +25,7 @@ const loadModule = async (moduleProvider, extensionKey, location) => {
|
|
|
25
25
|
return resolvedModule.default;
|
|
26
26
|
}
|
|
27
27
|
catch (e) {
|
|
28
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
28
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
29
29
|
level: error,
|
|
30
30
|
message: `Failed trying to execute the dynamic import from extension "${extensionKey}" for the async panel at location "${location}"`,
|
|
31
31
|
components: ['AsyncPanelHandler'],
|
|
@@ -38,17 +38,17 @@ const loadModule = async (moduleProvider, extensionKey, location) => {
|
|
|
38
38
|
return noop;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
const rendererRef = react_1.useRef();
|
|
43
|
-
const [isModuleLoaded, setIsModuleLoaded] = react_1.useState(false);
|
|
44
|
-
const context = react_1.useMemo(() => {
|
|
41
|
+
const AsyncPanelHandler = ({ contextProvider, fallback, location, pluginKey, extensionKey = pluginKey, renderProvider, RootType, }) => {
|
|
42
|
+
const rendererRef = (0, react_1.useRef)();
|
|
43
|
+
const [isModuleLoaded, setIsModuleLoaded] = (0, react_1.useState)(false);
|
|
44
|
+
const context = (0, react_1.useMemo)(() => {
|
|
45
45
|
let contextValue = {};
|
|
46
46
|
if (typeof contextProvider === 'function') {
|
|
47
47
|
try {
|
|
48
48
|
contextValue = contextProvider();
|
|
49
49
|
}
|
|
50
50
|
catch (e) {
|
|
51
|
-
clientside_extensions_debug_1.onDebug(({ error }) => ({
|
|
51
|
+
(0, clientside_extensions_debug_1.onDebug)(({ error }) => ({
|
|
52
52
|
level: error,
|
|
53
53
|
message: `Failed to invoke "contextProvider" function for extension "${extensionKey}" at location "${location}".\nError: ${e}`,
|
|
54
54
|
components: ['AsyncPanelHandler'],
|
|
@@ -61,7 +61,7 @@ exports.AsyncPanelHandler = ({ contextProvider, fallback, location, pluginKey, e
|
|
|
61
61
|
}
|
|
62
62
|
return contextValue;
|
|
63
63
|
}, [contextProvider, location, extensionKey]);
|
|
64
|
-
react_1.useEffect(function asyncLoadRendererModule() {
|
|
64
|
+
(0, react_1.useEffect)(function asyncLoadRendererModule() {
|
|
65
65
|
let didCancel = false;
|
|
66
66
|
async function loadRendererModule() {
|
|
67
67
|
setIsModuleLoaded(false);
|
|
@@ -83,4 +83,5 @@ exports.AsyncPanelHandler = ({ contextProvider, fallback, location, pluginKey, e
|
|
|
83
83
|
}
|
|
84
84
|
return react_1.default.createElement(PanelHandler_1.PanelHandler, { render: rendererRef.current, RootType: RootType, context: context });
|
|
85
85
|
};
|
|
86
|
+
exports.AsyncPanelHandler = AsyncPanelHandler;
|
|
86
87
|
//# sourceMappingURL=AsyncPanelHandler.js.map
|