-
Notifications
You must be signed in to change notification settings - Fork 0
/
cb-client.js.map
1 lines (1 loc) · 22.8 KB
/
cb-client.js.map
1
{"version":3,"file":"index.js","mappings":";CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAqB,YAAID,IAEzBD,EAAkB,YAAIC,IARxB,CASGK,MAAM,WACT,8BCVS,MACC,aACA,IAAIC,EAAsB,CAE9B,oBAIA,CAAEC,EAAyBC,EAAqB,KAmBtD,IAAIC,EAUAC,EA3BJ,EAAoBC,EAAEH,GACD,EAAoBI,EAAEJ,EAAqB,CACzC,WAAc,IAAM,EACpB,cAAiB,IAAM,IAe9C,SAAWC,GACPA,EAA4B,aAAI,eAChCA,EAAsB,OAAI,SAC1BA,EAAiC,kBAAI,kBACrCA,EAA2B,YAAI,aAC/BA,EAA0B,WAAI,YAC9BA,EAA2B,YAAI,aANnC,CAOGA,IAAkBA,EAAgB,KAGrC,SAAWC,GACPA,EAAkC,sBAAI,sBAD1C,CAEGA,IAAeA,EAAa,MAKzB,uBAIA,CAAEH,EAAyBC,EAAqB,KAEtD,EAAoBG,EAAEH,IAiBhB,iBAIA,CAAED,EAAyBC,EAAqB,KAEtD,EAAoBG,EAAEH,KAoBRK,EAA2B,GAG/B,SAAS,EAAoBC,GAE5B,IAAIC,EAAeF,EAAyBC,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAad,QAGrB,IAAIC,EAASW,EAAyBC,GAAY,CAGjDb,QAAS,IAOV,OAHAK,EAAoBQ,GAAUZ,EAAQA,EAAOD,QAAS,GAG/CC,EAAOD,QAOd,EAAoBW,EAAI,CAACX,EAASgB,KACjC,IAAI,IAAIC,KAAOD,EACX,EAAoBE,EAAEF,EAAYC,KAAS,EAAoBC,EAAElB,EAASiB,IAC5EE,OAAOC,eAAepB,EAASiB,EAAK,CAAEI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J,EAAUlD,UAAUuD,gBAAkB,WAClC,OAAO1C,KAAKsC,OAAOjD,KAAK,4BAAiCZ,IAK7D4D,EAAUlD,UAAUwD,UAAY,WAC5B,OAAO3C,KAAKsC,OAAOjD,KAAK,qBAA0BZ,IAKtD4D,EAAUlD,UAAUyD,WAAa,SAAUC,GACvC,OAAO7C,KAAKsC,OAAOjD,KAAK,iBAA2BwD,IAKvDR,EAAUlD,UAAU2D,WAAa,WAC7B,OAAO9C,KAAKsC,OAAOjD,KAAK,sBAA2BZ,IAQvD4D,EAAUlD,UAAU4D,qBAAuB,SAAU1B,GACjD,OAAOrB,KAAKsC,OAAOlB,UAAU,4BAAkC,SAAUZ,GAAW,OAAOa,EAASb,EAAQwC,YAEzGX,EA3DmB","sources":["webpack://CbWidgetApi/webpack/universalModuleDefinition","webpack://CbWidgetApi/../cb-widget-shared/dist/index.js","webpack://CbWidgetApi/webpack/bootstrap","webpack://CbWidgetApi/webpack/runtime/define property getters","webpack://CbWidgetApi/webpack/runtime/hasOwnProperty shorthand","webpack://CbWidgetApi/webpack/runtime/make namespace object","webpack://CbWidgetApi/./src/widget-client.ts","webpack://CbWidgetApi/./src/widget-api.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"CbWidgetApi\"] = factory();\n\telse\n\t\troot[\"CbWidgetApi\"] = factory();\n})(self, function() {\nreturn ","/******/ (() => { // webpackBootstrap\n/******/ \t\"use strict\";\n/******/ \tvar __webpack_modules__ = ({\n\n/***/ \"./src/contract.ts\":\n/*!*************************!*\\\n !*** ./src/contract.ts ***!\n \\*************************/\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"EventNames\": () => (/* binding */ EventNames),\n/* harmony export */ \"FunctionNames\": () => (/* binding */ FunctionNames)\n/* harmony export */ });\n/*\r\n * Copyright by Intland Software\r\n *\r\n * All rights reserved.\r\n *\r\n * This software is the confidential and proprietary information\r\n * of Intland Software. (\"Confidential Information\"). You\r\n * shall not disclose such Confidential Information and shall use\r\n * it only in accordance with the terms of the license agreement\r\n * you entered into with Intland.\r\n */\r\n// Exchanges\r\nvar FunctionNames;\r\n(function (FunctionNames) {\r\n FunctionNames[\"AUTHENTICATE\"] = \"authenticate\";\r\n FunctionNames[\"RESIZE\"] = \"resize\";\r\n FunctionNames[\"GET_SELECTED_ITEM\"] = \"getSelectedItem\";\r\n FunctionNames[\"RELOAD_ITEM\"] = \"reloadItem\";\r\n FunctionNames[\"GET_CONFIG\"] = \"getConfig\";\r\n FunctionNames[\"GET_BASEURL\"] = \"getBaseURL\";\r\n})(FunctionNames || (FunctionNames = {}));\r\n// Events\r\nvar EventNames;\r\n(function (EventNames) {\r\n EventNames[\"SELECTED_ITEM_CHANGED\"] = \"selectedItemChanged\";\r\n})(EventNames || (EventNames = {}));\r\n\n\n/***/ }),\n\n/***/ \"./src/types-utils.ts\":\n/*!****************************!*\\\n !*** ./src/types-utils.ts ***!\n \\****************************/\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n__webpack_require__.r(__webpack_exports__);\n/*\r\n * Copyright by Intland Software\r\n *\r\n * All rights reserved.\r\n *\r\n * This software is the confidential and proprietary information\r\n * of Intland Software. (\"Confidential Information\"). You\r\n * shall not disclose such Confidential Information and shall use\r\n * it only in accordance with the terms of the license agreement\r\n * you entered into with Intland.\r\n */\r\n\r\n\n\n/***/ }),\n\n/***/ \"./src/types.ts\":\n/*!**********************!*\\\n !*** ./src/types.ts ***!\n \\**********************/\n/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {\n\n__webpack_require__.r(__webpack_exports__);\n/*\r\n * Copyright by Intland Software\r\n *\r\n * All rights reserved.\r\n *\r\n * This software is the confidential and proprietary information\r\n * of Intland Software. (\"Confidential Information\"). You\r\n * shall not disclose such Confidential Information and shall use\r\n * it only in accordance with the terms of the license agreement\r\n * you entered into with Intland.\r\n */\r\n\r\n\n\n/***/ })\n\n/******/ \t});\n/************************************************************************/\n/******/ \t// The module cache\n/******/ \tvar __webpack_module_cache__ = {};\n/******/ \t\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/ \t\t// Check if module is in cache\n/******/ \t\tvar cachedModule = __webpack_module_cache__[moduleId];\n/******/ \t\tif (cachedModule !== undefined) {\n/******/ \t\t\treturn cachedModule.exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = __webpack_module_cache__[moduleId] = {\n/******/ \t\t\t// no module.id needed\n/******/ \t\t\t// no module.loaded needed\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/ \t\n/******/ \t\t// Execute the module function\n/******/ \t\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n/******/ \t\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/ \t\n/************************************************************************/\n/******/ \t/* webpack/runtime/define property getters */\n/******/ \t(() => {\n/******/ \t\t// define getter functions for harmony exports\n/******/ \t\t__webpack_require__.d = (exports, definition) => {\n/******/ \t\t\tfor(var key in definition) {\n/******/ \t\t\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n/******/ \t\t\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n/******/ \t\t\t\t}\n/******/ \t\t\t}\n/******/ \t\t};\n/******/ \t})();\n/******/ \t\n/******/ \t/* webpack/runtime/hasOwnProperty shorthand */\n/******/ \t(() => {\n/******/ \t\t__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))\n/******/ \t})();\n/******/ \t\n/******/ \t/* webpack/runtime/make namespace object */\n/******/ \t(() => {\n/******/ \t\t// define __esModule on exports\n/******/ \t\t__webpack_require__.r = (exports) => {\n/******/ \t\t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n/******/ \t\t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n/******/ \t\t\t}\n/******/ \t\t\tObject.defineProperty(exports, '__esModule', { value: true });\n/******/ \t\t};\n/******/ \t})();\n/******/ \t\n/************************************************************************/\nvar __webpack_exports__ = {};\n// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.\n(() => {\n/*!**********************!*\\\n !*** ./src/index.ts ***!\n \\**********************/\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"EventNames\": () => (/* reexport safe */ _contract__WEBPACK_IMPORTED_MODULE_2__.EventNames),\n/* harmony export */ \"FunctionNames\": () => (/* reexport safe */ _contract__WEBPACK_IMPORTED_MODULE_2__.FunctionNames)\n/* harmony export */ });\n/* harmony import */ var _types_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./types-utils */ \"./src/types-utils.ts\");\n/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./types */ \"./src/types.ts\");\n/* harmony import */ var _contract__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./contract */ \"./src/contract.ts\");\n/*\r\n * Copyright by Intland Software\r\n *\r\n * All rights reserved.\r\n *\r\n * This software is the confidential and proprietary information\r\n * of Intland Software. (\"Confidential Information\"). You\r\n * shall not disclose such Confidential Information and shall use\r\n * it only in accordance with the terms of the license agreement\r\n * you entered into with Intland.\r\n */\r\n\r\n\r\n\r\n\n})();\n\nexports.EventNames = __webpack_exports__.EventNames;\nexports.FunctionNames = __webpack_exports__.FunctionNames;\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/******/ })()\n;\n//# sourceMappingURL=index.js.map","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/*\r\n * Copyright by Intland Software\r\n *\r\n * All rights reserved.\r\n *\r\n * This software is the confidential and proprietary information\r\n * of Intland Software. (\"Confidential Information\"). You\r\n * shall not disclose such Confidential Information and shall use\r\n * it only in accordance with the terms of the license agreement\r\n * you entered into with Intland.\r\n */\r\nvar WidgetClient = /** @class */ (function () {\r\n function WidgetClient(window, widgetId, origin) {\r\n var _this = this;\r\n this.window = window;\r\n this.widgetId = widgetId;\r\n this.origin = origin;\r\n this.nextExchangeId = 0;\r\n this.eventSubscriptions = {};\r\n this.conversationCallbacks = {};\r\n window.addEventListener('message', function (event) { return _this.consumeMessageEvent(event); });\r\n }\r\n WidgetClient.prototype.call = function (func, payload) {\r\n var _this = this;\r\n return new Promise(function (resolve, reject) {\r\n _this.nextExchangeId++;\r\n _this.conversationCallbacks[_this.nextExchangeId] = (function (exchangeId) {\r\n return function (response) {\r\n if (response.type === 'error') {\r\n return reject(response.payload);\r\n }\r\n if (message.func !== func) {\r\n throw new Error(\"Response type mismatch. Expected: \\\"\".concat(func, \"\\\". Actual: \\\"\").concat(response.type, \"\\\"\"));\r\n }\r\n resolve(response.payload);\r\n delete _this.conversationCallbacks[exchangeId];\r\n };\r\n })(_this.nextExchangeId);\r\n var message = {\r\n type: 'RPC',\r\n widgetId: _this.widgetId,\r\n exchangeId: _this.nextExchangeId,\r\n func: func,\r\n payload: payload\r\n };\r\n if (!_this.window.parent) {\r\n throw new Error('window must have a parent');\r\n }\r\n _this.window.parent.postMessage(message, _this.origin);\r\n });\r\n };\r\n WidgetClient.prototype.subscribe = function (event, callback) {\r\n var _this = this;\r\n var cloneCallback = function (x) { return callback(x); };\r\n this.eventSubscriptions[event] = this.eventSubscriptions[event] || [];\r\n this.eventSubscriptions[event].push(cloneCallback);\r\n return function () {\r\n var idx = _this.eventSubscriptions[event].indexOf(cloneCallback);\r\n _this.eventSubscriptions[event].splice(idx, 1);\r\n };\r\n };\r\n WidgetClient.prototype.consumeMessageEvent = function (event) {\r\n if (this.origin !== '*' && event.origin !== this.origin) {\r\n console.log(\"Ignoring message because of origin mismatch. Expected: \\\"\".concat(this.origin, \"\\\". Actual: \\\"\").concat(event.origin, \"\\\".\"));\r\n return;\r\n }\r\n var data = event.data;\r\n if (!isMessageBody(data)) {\r\n console.warn('Is not a message', data);\r\n return;\r\n }\r\n if (isEventResponse(data)) {\r\n return this.consumeEvent(data);\r\n }\r\n if (!isExchangeResponse(data)) {\r\n if (!isExchangeError(data)) {\r\n console.warn('Malformed message', data);\r\n return;\r\n }\r\n }\r\n else {\r\n if (data.widgetId !== this.widgetId)\r\n return;\r\n }\r\n var callback = this.conversationCallbacks[data.exchangeId];\r\n if (!callback) {\r\n throw new Error('Widget ' + this.widgetId + ' is missing callback for exchangeId ' + data.exchangeId);\r\n }\r\n callback(data);\r\n };\r\n WidgetClient.prototype.consumeEvent = function (event) {\r\n var callbacks = this.eventSubscriptions[event.event] || [];\r\n callbacks.forEach(function (callback) {\r\n callback(event.payload);\r\n });\r\n };\r\n return WidgetClient;\r\n}());\r\nexport { WidgetClient };\r\nfunction isMessageBody(response) {\r\n if (!('payload' in response))\r\n return false;\r\n return !!response.type;\r\n}\r\nfunction isExchangeResponse(response) {\r\n if (response.type !== 'RPC')\r\n return false;\r\n if (!response.func)\r\n return false;\r\n return !!response.exchangeId;\r\n}\r\nfunction isExchangeError(response) {\r\n return response.type === 'error';\r\n}\r\nfunction isEventResponse(response) {\r\n if (response.type !== 'event')\r\n return false;\r\n return !!response.event;\r\n}\r\n","/*\r\n * Copyright by Intland Software\r\n *\r\n * All rights reserved.\r\n *\r\n * This software is the confidential and proprietary information\r\n * of Intland Software. (\"Confidential Information\"). You\r\n * shall not disclose such Confidential Information and shall use\r\n * it only in accordance with the terms of the license agreement\r\n * you entered into with Intland.\r\n */\r\nimport { EventNames, FunctionNames } from \"@intland/cb-widget-shared\";\r\nimport { WidgetClient } from \"./widget-client\";\r\n/**\r\n * An API abstraction which provides an interface for a frontend application running inside an IFrame inside codeBeamer,\r\n * to communicate with the codeBeamer UI via the browser's `postMessage` API.\r\n *\r\n * @public\r\n */\r\nvar WidgetApi = /** @class */ (function () {\r\n /**\r\n * Initializes an API instance.\r\n *\r\n * @param window - A window-like instance which provides the `postMessage` interface. Usually just simply `window`.\r\n * @param widgetId - A unique string to represent this widget API instance.\r\n * @param origin - The origin of codeBeamer. Can be `\"*\"` if the host is unknown.\r\n */\r\n function WidgetApi(window, widgetId, origin) {\r\n this.client = new WidgetClient(window, widgetId, origin);\r\n }\r\n /**\r\n * Request a JWT token for the currently logged-in user. The token may expire.\r\n */\r\n WidgetApi.prototype.authenticate = function () {\r\n return this.client.call(FunctionNames.AUTHENTICATE, undefined);\r\n };\r\n /**\r\n * Asks codeBeamer to resize the IFrame window vertically inside the UI. Only works on the Tracker Item Details page.\r\n *\r\n * @param height - Preferred height in browser pixels.\r\n */\r\n WidgetApi.prototype.resize = function (height) {\r\n return this.client.call(FunctionNames.RESIZE, { height: height });\r\n };\r\n /**\r\n * Queries which tracker item is selected on the codeBeamer UI. May only work on certain pages.\r\n * It may return `undefined` if there is no tracker item selected.\r\n */\r\n WidgetApi.prototype.getSelectedItem = function () {\r\n return this.client.call(FunctionNames.GET_SELECTED_ITEM, undefined);\r\n };\r\n /**\r\n * Requests the user provided configuration for this particular widget instance.\r\n */\r\n WidgetApi.prototype.getConfig = function () {\r\n return this.client.call(FunctionNames.GET_CONFIG, undefined);\r\n };\r\n /**\r\n * Asks codeBeamer to reload a Tracker Item if it's present on the UI. May only work on certain pages.\r\n */\r\n WidgetApi.prototype.reloadItem = function (config) {\r\n return this.client.call(FunctionNames.RELOAD_ITEM, config);\r\n };\r\n /**\r\n * Requests the Swagger API's base URL, including the proper context. Ex.: https://codebeamer.com/cb/api\r\n */\r\n WidgetApi.prototype.getBaseURL = function () {\r\n return this.client.call(FunctionNames.GET_BASEURL, undefined);\r\n };\r\n /**\r\n * Registers a callback to be called whenever the user selects a tracker item on the codeBeamer UI. May only work on\r\n * certain pages.\r\n *\r\n * @param callback - A function to be called when the selection changes.\r\n */\r\n WidgetApi.prototype.onSelectedItemChange = function (callback) {\r\n return this.client.subscribe(EventNames.SELECTED_ITEM_CHANGED, function (payload) { return callback(payload.itemId); });\r\n };\r\n return WidgetApi;\r\n}());\r\nexport { WidgetApi };\r\n"],"names":["root","factory","exports","module","define","amd","self","__webpack_modules__","__unused_webpack_module","__webpack_exports__","FunctionNames","EventNames","r","d","__webpack_module_cache__","moduleId","cachedModule","undefined","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","_contract__WEBPACK_IMPORTED_MODULE_2__","__webpack_require__","WidgetClient","window","widgetId","origin","_this","this","nextExchangeId","eventSubscriptions","conversationCallbacks","addEventListener","event","consumeMessageEvent","func","payload","Promise","resolve","reject","exchangeId","response","type","message","Error","concat","parent","postMessage","subscribe","callback","cloneCallback","x","push","idx","indexOf","splice","data","isEventResponse","consumeEvent","isExchangeResponse","isExchangeError","console","warn","log","forEach","WidgetApi","client","authenticate","resize","height","getSelectedItem","getConfig","reloadItem","config","getBaseURL","onSelectedItemChange","itemId"],"sourceRoot":""}