@datadog/ui-extensions-react
Advanced tools
Comparing version 0.25.1-canary.94.bb85f91.0 to 0.25.1-canary.94.f7b5b45.0
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@datadog/ui-extensions-sdk"),require("react")):"function"==typeof define&&define.amd?define(["@datadog/ui-extensions-sdk","react"],t):"object"==typeof exports?exports.DD_REACT=t(require("@datadog/ui-extensions-sdk"),require("react")):e.DD_REACT=t(e["@datadog/ui-extensions-sdk"],e.react)}(self,(function(e,t){return function(){"use strict";var n={920:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),i(n(54),t)},54:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useContext=void 0;var u=o(n(669)),a=o(n(156));t.useContext=function(e){var t=a.useState({type:"initializing"}),n=t[0],r=t[1];return a.useEffect((function(){var t=!1;e.getContext().then((function(e){t||r({type:"initialized",context:e})})).catch((function(e){t||r({type:"handshake failure",error:e})}));var n=e.events.on(u.EventType.CONTEXT_CHANGE,(function(e){r({type:"initialized",context:e})}));return function(){t=!0,n()}}),[e]),n}},669:function(t){t.exports=e},156:function(e){e.exports=t}},r={};return function e(t){var i=r[t];if(void 0!==i)return i.exports;var o=r[t]={exports:{}};return n[t].call(o.exports,o,o.exports,e),o.exports}(920)}()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@datadog/ui-extensions-sdk"),require("react")):"function"==typeof define&&define.amd?define(["@datadog/ui-extensions-sdk","react"],t):"object"==typeof exports?exports.DD_REACT=t(require("@datadog/ui-extensions-sdk"),require("react")):e.DD_REACT=t(e["@datadog/ui-extensions-sdk"],e.react)}(self,(function(e,t){return function(){"use strict";var n={920:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||i(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),r(n(54),t)},54:function(e,t,n){var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n),Object.defineProperty(e,i,{enumerable:!0,get:function(){return t[n]}})}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&i(t,e,n);return r(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useContext=void 0;var u=o(n(669)),a=o(n(156));t.useContext=function(e){var t=function(e){var t=a.useState({type:"initializing"}),n=t[0],i=t[1];return a.useEffect((function(){var t=!1;e.getContext().then((function(e){t||i({type:"initialized",context:e})})).catch((function(e){t||i({type:"handshake failure",error:e})}));var n=e.events.on(u.EventType.CONTEXT_CHANGE,(function(e){i({type:"initialized",context:e})}));return function(){t=!0,n()}}),[e]),n}(e);switch(t.type){case"handshake failure":case"initializing":return;case"initialized":return t.context}}},669:function(t){t.exports=e},156:function(e){e.exports=t}},i={};return function e(t){var r=i[t];if(void 0!==r)return r.exports;var o=i[t]={exports:{}};return n[t].call(o.exports,o,o.exports,e),o.exports}(920)}()})); | ||
//# sourceMappingURL=ui-extensions-react.min.js.map |
import * as uiExtensionsSDK from '@datadog/ui-extensions-sdk'; | ||
/** | ||
* This represents the different states the {@link uiExtensionsSDK.Context} can be in. | ||
*/ | ||
declare type Context = ContextHandshakeFailure | ContextInitialized | ContextInitializing; | ||
/** | ||
* There was some kind of failure with the handshake. | ||
* There's no useful {@link uiExtensionsSDK.Context}, but there is an error. | ||
*/ | ||
declare type ContextHandshakeFailure = { | ||
type: 'handshake failure'; | ||
error: unknown; | ||
}; | ||
/** | ||
* The handshake is still being preformed. | ||
* There's no useful {@link uiExtensionsSDK.Context} yet. | ||
*/ | ||
declare type ContextInitializing = { | ||
type: 'initializing'; | ||
}; | ||
/** | ||
* The handshake has succeeded and there is a {@link uiExtensionsSDK.Context} that can be used. | ||
*/ | ||
declare type ContextInitialized = { | ||
type: 'initialized'; | ||
context: uiExtensionsSDK.Context; | ||
}; | ||
/** | ||
* Returns a {@link Context} describing the state of the underlying {@link uiExtensionsSDK.Context}. | ||
* Returns a {@link uiExtensionsSDK.Context}. | ||
* Will be updated whenever the {@link uiExtensionsSDK.Context} changes. | ||
@@ -36,3 +10,3 @@ * | ||
* This should be the result of invoking {@link uiExtensionsSDK.init}. | ||
* @returns The state of the {@link uiExtensionsSDK.Context}. | ||
* @returns The {@link uiExtensionsSDK.Context}, if it exists. | ||
* | ||
@@ -49,12 +23,8 @@ * @example | ||
* const Widget: React.FunctionComponent = () => { | ||
* const result = uiExtensionsReact.useContext(client) | ||
* if (result.type === 'initializing') { | ||
* const context = uiExtensionsReact.useContext(client) | ||
* if (context == null) { | ||
* return <p>Initializing</p>; | ||
* } | ||
* | ||
* if (result.type === 'handshake failure') { | ||
* return <p>Error</p>; | ||
* } | ||
* | ||
* const colorTheme: uiExtensionsSDK.ColorTheme = result.context.app.currentUser.colorTheme; | ||
* const colorTheme: uiExtensionsSDK.ColorTheme = context.app.currentUser.colorTheme; | ||
* return <p>Widget is ready! Color theme: {colorTheme}</p>; | ||
@@ -64,3 +34,3 @@ * } | ||
*/ | ||
declare function useContext(client: uiExtensionsSDK.DDClient): Context; | ||
export { Context, ContextHandshakeFailure, ContextInitialized, ContextInitializing, useContext }; | ||
declare function useContext(client: uiExtensionsSDK.DDClient): uiExtensionsSDK.Context | undefined; | ||
export { useContext }; |
{ | ||
"name": "@datadog/ui-extensions-react", | ||
"version": "0.25.1-canary.94.bb85f91.0", | ||
"version": "0.25.1-canary.94.f7b5b45.0", | ||
"description": "Datadog UI Extensions - React helpers", | ||
@@ -44,3 +44,3 @@ "homepage": "https://github.com/DataDog/apps/tree/master/packages/ui-extensions-react", | ||
"typedocMain": "src/index.ts", | ||
"gitHead": "bb85f919e7e1ddebaab1ed1a40f93ec523f52b1c" | ||
"gitHead": "f7b5b45ea4c4888ab17c344de0ca2fd824cec505" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25457
55