@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebPanelRenderer.js","sourceRoot":"","sources":["../../lib/useWebPanelRenderer.tsx"],"names":[],"mappings":";;AAAA,wFAAiE;AACjE,iCAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AAErE,MAAM,eAAe,GAAG,CAAC,cAAiC,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;IAClC,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,6FAA6F;QAC7F,iFAAiF;QACjF,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE;YACtB,yEAAyE;YACzE,MAAM,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,IAAI,CAAE,CAAC;SACxC;IACL,CAAC,CAAC,CAAC;IAEH,IAAI;QACA,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;KACrC;IAAC,OAAO,CAAC,EAAE;QACR,qCAAO,
|
|
1
|
+
{"version":3,"file":"useWebPanelRenderer.js","sourceRoot":"","sources":["../../lib/useWebPanelRenderer.tsx"],"names":[],"mappings":";;AAAA,wFAAiE;AACjE,iCAA4C;AAE5C,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AAErE,MAAM,eAAe,GAAG,CAAC,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;IAC5D,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAE7C,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAEnC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;AACzD,CAAC,CAAC;AAIF,MAAM,mBAAmB,GAAG,CAAC,IAAY,EAAE,EAAE;IACzC,MAAM,GAAG,GAAG,IAAA,cAAM,EAAmB,IAAI,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,IAAA,mBAAW,EACtB,CAAC,IAAI,EAAE,EAAE;;QACL,gDAAgD;QAChD,IAAI,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,0CAAE,0BAA0B,EAAE;YAC1C,OAAO;SACV;QAED,iCAAiC;QACjC,IAAI,IAAI,EAAE;YACN,8BAA8B,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC3C,gDAAgD;YAC/C,IAAyB,CAAC,0BAA0B,GAAG,IAAI,CAAC;SAChE;QAED,uFAAuF;QACvF,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;IACvB,CAAC,EACD,CAAC,IAAI,CAAC,CACT,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,kBAAe,mBAAmB,CAAC","sourcesContent":["import { onDebug } from '@atlassian/clientside-extensions-debug';\nimport { useCallback, useRef } from 'react';\n\nconst copyAttributes = ['type', 'src', 'nonce', 'noModule'] as const;\n\nconst evaluateScripts = (originalScript: HTMLScriptElement) => {\n const script = document.createElement('script');\n script.text = originalScript.text;\n copyAttributes.forEach((attr) => {\n // we cant just check if an attribute exists, as some of them are enforced to be \"properties\"\n // see: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce\n if (originalScript[attr]) {\n // @ts-expect-error We want to assign whatever here, typescript be quiet!\n script[attr] = originalScript[attr]!;\n }\n });\n\n try {\n document.head.appendChild(script);\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `An inline script in a WebPanel failed to execute.`,\n meta: {\n error: e,\n },\n }));\n }\n\n try {\n script.remove();\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Failed to remove inline script associated with WebPanel.`,\n meta: {\n error: e,\n },\n }));\n }\n};\n\nconst injectAndEvaluateInlineScripts = (node: HTMLElement, html: string) => {\n const template = document.createElement('template');\n template.innerHTML = html;\n const scripts = template.content.querySelectorAll('script');\n scripts.forEach((script) => script.remove());\n\n node.appendChild(template.content);\n\n scripts.forEach((script) => evaluateScripts(script));\n};\n\ntype WebpanelRootNode = { __cse_webpanel_initialized: boolean } & HTMLElement;\n\nconst useWebPanelRenderer = (html: string) => {\n const ref = useRef<WebpanelRootNode>(null);\n const setRef = useCallback<(node: HTMLElement | null) => void>(\n (node) => {\n // eslint-disable-next-line no-underscore-dangle\n if (ref?.current?.__cse_webpanel_initialized) {\n return;\n }\n\n // where the actual work happens.\n if (node) {\n injectAndEvaluateInlineScripts(node, html);\n // eslint-disable-next-line no-underscore-dangle\n (node as WebpanelRootNode).__cse_webpanel_initialized = true;\n }\n\n // @ts-expect-error This is typed as a \"read-only\" property, but in fact it can be set.\n ref.current = node;\n },\n [html],\n );\n\n return setRef;\n};\n\nexport default useWebPanelRenderer;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionPointInfo.js","sourceRoot":"","sources":["../../lib/ExtensionPointInfo.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,KAAK,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,IAAI,EAA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AAC","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,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,MAAM,MAAM,kCAAkC,CAAC;AACtD,OAAO,KAAK,EAAE,EAAE,eAAe,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACtG,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAW7C,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAOpG,MAAM,aAAa,GAAG,CAAC,EAAE,EAAE,EAAkB,EAAE,EAAE;IAC7C,8DAA8D;IAC9D,mFAAmF;IACnF,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAEhD,OAAO;IACH,oDAAoD;IACpD,oBAAC,IAAI,IAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAC,EAAE,EAAC,WAAW,EAAC,uBAAuB,EAAC,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,UAC7E,EAAE,CACA,CACV,CAAC;AACN,CAAC,CAAC;AAEF,MAAM,YAAY,GAA4D,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAC9F;IACI,+BAAI,UAAU,CAAC,WAAW,CAAK;IAC/B,oBAAC,KAAK;QACF;Y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AAC,GAAI;QAC9D,oBAAC,eAAe,QACX,UAAU,IAAI,CACX,oBAAC,KAAK,IAAC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAC,SAAS;YACxC,oBAAC,WAAW;gBACR,oBAAC,UAAU,QAAE,oBAAoB,IAAI,EAAE,CAAc,CAC3C;YAEd,oBAAC,eAAe;gBACZ,oBAAC,eAAe,IAAC,eAAe,EAAE,eAAe,GAAI,CACvC;YAElB,oBAAC,WAAW;gBAER,oBAAC,MAAM,IAAC,UAAU,EAAC,SAAS,EAAC,SAAS,QAAC,OAAO,EAAE,WAAW,YAElD,CACC,CACV,CACX,CACa,CACH,CACtB,CAAC;AACN,CAAC,CAAC;AAEF,eAAe,IAAI,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 {/* 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionsObservable.js","sourceRoot":"","sources":["../../lib/ExtensionsObservable.ts"],"names":[],"mappings":"AAUA,OAAO,QAAQ,MAAM,2CAA2C,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAKtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;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,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;gBACpB,KAAK,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AAE,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","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,OAAO,QAAQ,MAAM,2CAA2C,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAEjE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C/F,6BAA6B,CAAc,UAAU,EAAE,sBAAsB,EAAE,oBAAoB,CAAC,CAAC;aACxG;iBAAM;gBACH,6BAA6B,CAAc,UAAU,EAAE,oBAAoB,EAAE,sBAAsB,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","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"]}
|
package/dist/esm/debug/types.js
CHANGED
|
@@ -4,7 +4,7 @@ function renderElementAsReact(renderApi, RenderElement, additionalProps) {
|
|
|
4
4
|
renderApi
|
|
5
5
|
.onMount((element) => {
|
|
6
6
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
7
|
-
ReactDOM.render(React.createElement(RenderElement,
|
|
7
|
+
ReactDOM.render(React.createElement(RenderElement, { ...additionalProps }), element);
|
|
8
8
|
})
|
|
9
9
|
.onUnmount((element) => {
|
|
10
10
|
ReactDOM.unmountComponentAtNode(element);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderElementAsReact.js","sourceRoot":"","sources":["../../lib/renderElementAsReact.tsx"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,SAAS,oBAAoB,CAAS,SAA6B,EAAE,aAAoC,EAAE,eAAwB;IAC/H,SAAS;SACJ,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACjB,wDAAwD;QACxD,QAAQ,CAAC,MAAM,CAAC,oBAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"renderElementAsReact.js","sourceRoot":"","sources":["../../lib/renderElementAsReact.tsx"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,SAAS,oBAAoB,CAAS,SAA6B,EAAE,aAAoC,EAAE,eAAwB;IAC/H,SAAS;SACJ,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QACjB,wDAAwD;QACxD,QAAQ,CAAC,MAAM,CAAC,oBAAC,aAAa,OAAM,eAA0B,GAAI,EAAE,OAAO,CAAC,CAAC;IACjF,CAAC,CAAC;SACD,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;QACnB,QAAQ,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACX,CAAC;AAED,eAAe,oBAAoB,CAAC","sourcesContent":["import ReactDOM from 'react-dom';\nimport type { ComponentType } from 'react';\nimport React from 'react';\nimport type { MountableExtension } from '@atlassian/clientside-extensions';\n\nfunction renderElementAsReact<PropsT>(renderApi: MountableExtension, RenderElement: ComponentType<PropsT>, additionalProps?: PropsT) {\n renderApi\n .onMount((element) => {\n // eslint-disable-next-line react/jsx-props-no-spreading\n ReactDOM.render(<RenderElement {...(additionalProps as PropsT)} />, element);\n })\n .onUnmount((element) => {\n ReactDOM.unmountComponentAtNode(element);\n });\n}\n\nexport default renderElementAsReact;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWebPanelRenderer.js","sourceRoot":"","sources":["../../lib/useWebPanelRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE5C,MAAM,cAAc,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,CAAU,CAAC;AAErE,MAAM,eAAe,GAAG,CAAC,cAAiC,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC;IAClC,cAAc,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC5B,6FAA6F;QAC7F,iFAAiF;QACjF,IAAI,cAAc,CAAC,IAAI,CAAC,EAAE;YACtB,yEAAyE;YACzE,M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C;IACvB,CAAC,EACD,CAAC,IAAI,CAAC,CACT,CAAC;IAEF,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC","sourcesContent":["import { onDebug } from '@atlassian/clientside-extensions-debug';\nimport { useCallback, useRef } from 'react';\n\nconst copyAttributes = ['type', 'src', 'nonce', 'noModule'] as const;\n\nconst evaluateScripts = (originalScript: HTMLScriptElement) => {\n const script = document.createElement('script');\n script.text = originalScript.text;\n copyAttributes.forEach((attr) => {\n // we cant just check if an attribute exists, as some of them are enforced to be \"properties\"\n // see: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/nonce\n if (originalScript[attr]) {\n // @ts-expect-error We want to assign whatever here, typescript be quiet!\n script[attr] = originalScript[attr]!;\n }\n });\n\n try {\n document.head.appendChild(script);\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `An inline script in a WebPanel failed to execute.`,\n meta: {\n error: e,\n },\n }));\n }\n\n try {\n script.remove();\n } catch (e) {\n onDebug(({ error }) => ({\n level: error,\n message: `Failed to remove inline script associated with WebPanel.`,\n meta: {\n error: e,\n },\n }));\n }\n};\n\nconst injectAndEvaluateInlineScripts = (node: HTMLElement, html: string) => {\n const template = document.createElement('template');\n template.innerHTML = html;\n const scripts = template.content.querySelectorAll('script');\n scripts.forEach((script) => script.remove());\n\n node.appendChild(template.content);\n\n scripts.forEach((script) => evaluateScripts(script));\n};\n\ntype WebpanelRootNode = { __cse_webpanel_initialized: boolean } & HTMLElement;\n\nconst useWebPanelRenderer = (html: string) => {\n const ref = useRef<WebpanelRootNode>(null);\n const setRef = useCallback<(node: HTMLElement | null) => void>(\n (node) => {\n // eslint-disable-next-line no-underscore-dangle\n if (ref?.current?.__cse_webpanel_initialized) {\n return;\n }\n\n // where the actual work happens.\n if (node) {\n injectAndEvaluateInlineScripts(node, html);\n // eslint-disable-next-line no-underscore-dangle\n (node as WebpanelRootNode).__cse_webpanel_initialized = true;\n }\n\n // @ts-expect-error This is typed as a \"read-only\" property, but in fact it can be set.\n ref.current = node;\n },\n [html],\n );\n\n return setRef;\n};\n\nexport default useWebPanelRenderer;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionPointInfo.d.ts","sourceRoot":"","sources":["../../lib/ExtensionPointInfo.tsx"],"names":[],"mappings":"AACA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAK9C,OAAO,KAAK,EACR,kBAAkB,EAOrB,MAAM,yCAAyC,CAAC;AAKjD,oBAAY,uBAAuB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE;QAAE,MAAM,EAAE,kBAAkB,CAAC;QAAC,aAAa,EAAE,kBAAkB,CAAA;KAAE,CAAC;CACtF,CAAC;;
|
|
1
|
+
{"version":3,"file":"ExtensionPointInfo.d.ts","sourceRoot":"","sources":["../../lib/ExtensionPointInfo.tsx"],"names":[],"mappings":"AACA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAK9C,OAAO,KAAK,EACR,kBAAkB,EAOrB,MAAM,yCAAyC,CAAC;AAKjD,oBAAY,uBAAuB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE;QAAE,MAAM,EAAE,kBAAkB,CAAC;QAAC,aAAa,EAAE,kBAAkB,CAAA;KAAE,CAAC;CACtF,CAAC;;AAuMF,wBAAwC"}
|
package/dist/types/styled.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export declare const BlinkerContainer: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, Pick<import("react").
|
|
3
|
-
export declare const Blinker: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, Pick<import("react").
|
|
4
|
-
export declare const Table: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, Pick<import("react").
|
|
5
|
-
export declare const HeadRow: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, Pick<
|
|
2
|
+
export declare const BlinkerContainer: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, Pick<import("react").ClassAttributes<HTMLSpanElement> & import("react").HTMLAttributes<HTMLSpanElement>, keyof import("react").HTMLAttributes<HTMLSpanElement>>, object>;
|
|
3
|
+
export declare const Blinker: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, Pick<import("react").ClassAttributes<HTMLButtonElement> & import("react").ButtonHTMLAttributes<HTMLButtonElement>, keyof import("react").ButtonHTMLAttributes<HTMLButtonElement>>, object>;
|
|
4
|
+
export declare const Table: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").TableHTMLAttributes<HTMLTableElement>, HTMLTableElement>, Pick<import("react").ClassAttributes<HTMLTableElement> & import("react").TableHTMLAttributes<HTMLTableElement>, keyof import("react").TableHTMLAttributes<HTMLTableElement>>, object>;
|
|
5
|
+
export declare const HeadRow: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, Pick<import("@emotion/styled-base/types/helper").Overwrapped<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, import("@atlaskit/theme/dist/types/types").ThemeProps | undefined>, never>, {
|
|
6
6
|
__ATLASKIT_THEME__: import("@atlaskit/theme/dist/types/types").Theme;
|
|
7
7
|
}>;
|
|
8
|
-
export declare const HeadCell: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, Pick<
|
|
8
|
+
export declare const HeadCell: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, Pick<import("@emotion/styled-base/types/helper").Overwrapped<import("react").DetailedHTMLProps<import("react").ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>, import("@atlaskit/theme/dist/types/types").ThemeProps | undefined>, never>, {
|
|
9
9
|
__ATLASKIT_THEME__: import("@atlaskit/theme/dist/types/types").Theme;
|
|
10
10
|
}>;
|
|
11
|
-
export declare const TableRow: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, Pick<
|
|
11
|
+
export declare const TableRow: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, Pick<import("@emotion/styled-base/types/helper").Overwrapped<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>, import("@atlaskit/theme/dist/types/types").ThemeProps | undefined>, never>, {
|
|
12
12
|
__ATLASKIT_THEME__: import("@atlaskit/theme/dist/types/types").Theme;
|
|
13
13
|
}>;
|
|
14
|
-
export declare const TableCell: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, Pick<import("react").
|
|
14
|
+
export declare const TableCell: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>, Pick<import("react").ClassAttributes<HTMLTableDataCellElement> & import("react").TdHTMLAttributes<HTMLTableDataCellElement>, keyof import("react").TdHTMLAttributes<HTMLTableDataCellElement>>, object>;
|
|
15
15
|
//# sourceMappingURL=styled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../lib/styled.ts"],"names":[],"mappings":";AAMA,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"styled.d.ts","sourceRoot":"","sources":["../../lib/styled.ts"],"names":[],"mappings":";AAMA,eAAO,MAAM,gBAAgB,8TAE5B,CAAC;AAYF,eAAO,MAAM,OAAO,0VAsBnB,CAAC;AAmBF,eAAO,MAAM,KAAK,kVAGjB,CAAC;AAEF,eAAO,MAAM,OAAO;;EAEnB,CAAC;AAEF,eAAO,MAAM,QAAQ;;EAmBpB,CAAC;AAIF,eAAO,MAAM,QAAQ;;EASpB,CAAC;AAEF,eAAO,MAAM,SAAS,iXAWrB,CAAC"}
|
|
@@ -207,6 +207,7 @@ const ExtensionPointInfo: React.FC<ExtensionPointInfoProps> = ({ name, schemaDoc
|
|
|
207
207
|
</CustomModalBody>
|
|
208
208
|
|
|
209
209
|
<ModalFooter>
|
|
210
|
+
{/* eslint-disable-next-line jsx-a11y/no-autofocus */}
|
|
210
211
|
<Button appearance="primary" autoFocus onClick={closeDialog}>
|
|
211
212
|
Close
|
|
212
213
|
</Button>
|
|
@@ -204,7 +204,7 @@ describe('getExtensionPointSubscription', () => {
|
|
|
204
204
|
(apiReference as ExtensionAPI).updateAttributes({ foo: 'bar' });
|
|
205
205
|
|
|
206
206
|
// wait for the update to go through which is a tick away
|
|
207
|
-
await new Promise((resolve) => {
|
|
207
|
+
await new Promise<void>((resolve) => {
|
|
208
208
|
setTimeout(() => {
|
|
209
209
|
expect(observerSpy).toBeCalled();
|
|
210
210
|
const { update } = observerSpy.mock.calls[0][0];
|
|
@@ -256,7 +256,7 @@ describe('getExtensionPointSubscription', () => {
|
|
|
256
256
|
(apiReference2 as ExtensionAPI).updateAttributes({ foo: 'foo of 2' });
|
|
257
257
|
|
|
258
258
|
// wait for the update to go through which is a tick away
|
|
259
|
-
await new Promise((resolve) => {
|
|
259
|
+
await new Promise<void>((resolve) => {
|
|
260
260
|
setTimeout(() => {
|
|
261
261
|
expect(observerSpy).toBeCalledTimes(1);
|
|
262
262
|
const { update } = observerSpy.mock.calls[0][0];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlassian/clientside-extensions-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0-84fa90d-kwd5ix2w",
|
|
4
4
|
"description": "React components to assist in the authoring of extension points that work at product runtime.",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"homepage": "https://bitbucket.org/atlassian/atlassian-clientside-extensions#readme",
|
|
@@ -60,18 +60,20 @@
|
|
|
60
60
|
"build": "yarn build:esm && yarn build:cjs",
|
|
61
61
|
"build:esm": "tsc -p tsconfig.json",
|
|
62
62
|
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
63
|
+
"verify": "tsc --noEmit -p tsconfig.all.json",
|
|
63
64
|
"watch": "tsc --watch",
|
|
64
65
|
"test": "jest",
|
|
65
66
|
"test:watch": "jest --watch"
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
69
|
"@atlaskit/button": "~16.1.2",
|
|
69
|
-
"@atlaskit/modal-dialog": "~12.0
|
|
70
|
+
"@atlaskit/modal-dialog": "~12.1.0",
|
|
70
71
|
"@atlaskit/theme": "~12.0.0",
|
|
71
|
-
"@atlassian/clientside-extensions": "^2.
|
|
72
|
-
"@atlassian/clientside-extensions-base": "^2.
|
|
73
|
-
"@atlassian/clientside-extensions-debug": "^2.
|
|
74
|
-
"@atlassian/clientside-extensions-registry": "^2.
|
|
72
|
+
"@atlassian/clientside-extensions": "^2.5.0-84fa90d-kwd5ix2w",
|
|
73
|
+
"@atlassian/clientside-extensions-base": "^2.5.0-84fa90d-kwd5ix2w",
|
|
74
|
+
"@atlassian/clientside-extensions-debug": "^2.5.0-84fa90d-kwd5ix2w",
|
|
75
|
+
"@atlassian/clientside-extensions-registry": "^2.5.0-84fa90d-kwd5ix2w",
|
|
76
|
+
"@atlassian/clientside-extensions-schema": "^2.5.0-84fa90d-kwd5ix2w",
|
|
75
77
|
"@emotion/core": "^10.1.1",
|
|
76
78
|
"@emotion/styled": "^10.0.27",
|
|
77
79
|
"lodash.isequal": "^4.5.0",
|
|
@@ -83,21 +85,20 @@
|
|
|
83
85
|
"react-dom": "^16.9"
|
|
84
86
|
},
|
|
85
87
|
"devDependencies": {
|
|
86
|
-
"@atlassian/clientside-extensions-schema": "^2.4.1",
|
|
87
88
|
"@testing-library/dom": "8.7.2",
|
|
88
89
|
"@testing-library/jest-dom": "5.14.1",
|
|
89
90
|
"@testing-library/react": "12.1.2",
|
|
90
91
|
"@testing-library/react-hooks": "7.0.2",
|
|
91
92
|
"@types/lodash.isequal": "4.5.5",
|
|
92
|
-
"@types/react": "16.14.
|
|
93
|
+
"@types/react": "16.14.21",
|
|
93
94
|
"@types/react-scroll": "1.8.3",
|
|
94
|
-
"jest": "27.2.
|
|
95
|
+
"jest": "27.2.5",
|
|
95
96
|
"react": "16.14.0",
|
|
96
97
|
"react-dom": "16.14.0",
|
|
97
|
-
"ts-jest": "27.0.
|
|
98
|
+
"ts-jest": "27.0.6"
|
|
98
99
|
},
|
|
99
100
|
"engines": {
|
|
100
101
|
"node": ">=12.19.0"
|
|
101
102
|
},
|
|
102
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "84fa90d805babbfd94e536dcc1bb4facd1dc4f59"
|
|
103
104
|
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const React = tslib_1.__importStar(require("react"));
|
|
5
|
-
const utils_1 = require("ts-jest/utils");
|
|
6
|
-
const react_1 = require("@testing-library/react");
|
|
7
|
-
const clientside_extensions_registry_1 = tslib_1.__importDefault(require("@atlassian/clientside-extensions-registry"));
|
|
8
|
-
const clientside_extensions_schema_1 = require("@atlassian/clientside-extensions-schema");
|
|
9
|
-
const debug = tslib_1.__importStar(require("@atlassian/clientside-extensions-debug"));
|
|
10
|
-
const ExtensionPoint_1 = tslib_1.__importDefault(require("./ExtensionPoint"));
|
|
11
|
-
jest.mock('@atlassian/clientside-extensions-registry');
|
|
12
|
-
debug.setLoggingEnabled(true);
|
|
13
|
-
debug.setDebugEnabled(true);
|
|
14
|
-
// avoid spamming the console with error/warn messages
|
|
15
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
16
|
-
debug._deregisterDefaultLogger();
|
|
17
|
-
const supportedExtension = {
|
|
18
|
-
key: 'fake-1',
|
|
19
|
-
location: 'fake-location',
|
|
20
|
-
weight: 10,
|
|
21
|
-
attributes: { label: 'a fake label', type: 'button' },
|
|
22
|
-
};
|
|
23
|
-
const unsupportedExtension = {
|
|
24
|
-
key: 'fake-2',
|
|
25
|
-
location: 'fake-location',
|
|
26
|
-
weight: 10,
|
|
27
|
-
attributes: { label: 'a fake label' },
|
|
28
|
-
};
|
|
29
|
-
const validate = (input) => {
|
|
30
|
-
const { type } = input;
|
|
31
|
-
return type
|
|
32
|
-
? {
|
|
33
|
-
errors: [],
|
|
34
|
-
warnings: [],
|
|
35
|
-
}
|
|
36
|
-
: {
|
|
37
|
-
errors: [
|
|
38
|
-
{
|
|
39
|
-
error: 'error',
|
|
40
|
-
severity: clientside_extensions_schema_1.ErrorLevels.ERROR,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
warnings: [],
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Only testing the runtime error of a wrong child provided and that the component is using the right hook.
|
|
48
|
-
* The rest of the tests are in useExtensions.tests.
|
|
49
|
-
*/
|
|
50
|
-
describe('ExtensionPoint component', () => {
|
|
51
|
-
it('should not render if the child provided is not a callback', async () => {
|
|
52
|
-
const onDebugSpy = jest.fn();
|
|
53
|
-
debug.observeLogger(onDebugSpy);
|
|
54
|
-
utils_1.mocked(clientside_extensions_registry_1.default.getLocation).mockImplementation(() => ({
|
|
55
|
-
subscribe: () => {
|
|
56
|
-
return {
|
|
57
|
-
unsubscribe: () => { },
|
|
58
|
-
};
|
|
59
|
-
},
|
|
60
|
-
}));
|
|
61
|
-
const TestComponent = () => {
|
|
62
|
-
return (
|
|
63
|
-
// @ts-expect-error - forcing ts to ignore assigning a wrong child type to execute JS runtime validation
|
|
64
|
-
React.createElement(ExtensionPoint_1.default, { name: "fake-extension", context: null, options: { attributeValidator: validate } },
|
|
65
|
-
React.createElement("p", { "data-testid": "test-text" }, "Wrong child"),
|
|
66
|
-
";"));
|
|
67
|
-
};
|
|
68
|
-
const { container } = react_1.render(React.createElement(TestComponent, null));
|
|
69
|
-
expect(container.firstChild).toBe(null); // nothing rendered by the component
|
|
70
|
-
expect(onDebugSpy).toHaveBeenCalledTimes(1);
|
|
71
|
-
});
|
|
72
|
-
it('should provide all the extensions information to the child callback', () => {
|
|
73
|
-
let locationObserver;
|
|
74
|
-
utils_1.mocked(clientside_extensions_registry_1.default.getLocation).mockImplementation(() => ({
|
|
75
|
-
subscribe: (observer) => {
|
|
76
|
-
locationObserver = observer;
|
|
77
|
-
return {
|
|
78
|
-
unsubscribe: () => { },
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
}));
|
|
82
|
-
const TestComponent = () => {
|
|
83
|
-
return (React.createElement(ExtensionPoint_1.default, { name: "fake-extension", context: null, options: { attributeValidator: validate } }, (supportedExtensions, unsupportedExtensions, isLoading) => (React.createElement(React.Fragment, null,
|
|
84
|
-
React.createElement("p", { "data-testid": "isLoading" }, JSON.stringify(isLoading)),
|
|
85
|
-
React.createElement("p", { "data-testid": "supportedExtensions" }, JSON.stringify(supportedExtensions)),
|
|
86
|
-
React.createElement("p", { "data-testid": "unsupportedExtensions" }, JSON.stringify(unsupportedExtensions))))));
|
|
87
|
-
};
|
|
88
|
-
const { asFragment } = react_1.render(React.createElement(TestComponent, null));
|
|
89
|
-
expect(asFragment()).toMatchSnapshot('loading state');
|
|
90
|
-
react_1.act(() => {
|
|
91
|
-
locationObserver({ descriptors: [supportedExtension, unsupportedExtension], loadingState: false });
|
|
92
|
-
});
|
|
93
|
-
expect(asFragment()).toMatchSnapshot('with extensions state');
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
//# sourceMappingURL=ExtensionPoint.test.js.map
|