@akkadu/rsi-api-vue
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,45 +0,479 @@ | ||
var script = /*#__PURE__*/{ | ||
name: 'RsiApiVueSample', | ||
import events_1 from 'events'; | ||
// vue component name | ||
data() { | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
var Base = | ||
/** @class */ | ||
function () { | ||
function Base() { | ||
this.emitter = new events_1.EventEmitter(); | ||
} | ||
Base.prototype.gatewayRequest = function (apiKey, roomName) { | ||
if (!apiKey) { | ||
throw Error('base akadu-rsi: apiKey is undefined.'); | ||
} | ||
if (!roomName) { | ||
throw Error('base akkadu-rsi: roomname is undefined.'); | ||
} | ||
return 'test gateway'; | ||
}; | ||
Base.prototype.on = function (event, fn) { | ||
this.emitter.on(event, fn); | ||
}; | ||
return Base; | ||
}(); | ||
var _default$2 = Base; | ||
var lib = /*#__PURE__*/Object.defineProperty({ | ||
default: _default$2 | ||
}, '__esModule', { | ||
value: true | ||
}); | ||
var component = { | ||
html: "\n <body>\n <div class=\"select\">\n <div class=\"selectWrapper\" >\n <div class=\"selectCustom js-selectCustom\">\n <div id=\"interpretation-player-custom-value\" class=\"selectCustom-trigger\"> <img src=''/> <h3> </h3> </div>\n <div id=\"interpretation-player-options\" class=\"selectCustom-options\">\n </div>\n </div>\n </div>\n </body>\n ", | ||
css: "\n\n #akkadu-interpretation-player {\n display: inline-table;\n position: relative;\n font-family: \"Helvetica Neue\", Arial, sans-serif;\n }\n #akkadu-interpretation-player .select {\n position: relative;\n }\n #akkadu-interpretation-player .selectLabel {\n display: block;\n margin-bottom: 10px;\n }\n #akkadu-interpretation-player .selectWrapper {\n position: relative;\n }\n #akkadu-interpretation-player .selectCustom {\n position: relative;\n height: 100%;\n }\n #akkadu-interpretation-player .selectCustom-trigger {\n display: flex;\n position: relative;\n min-width: 150px;\n background-color: white;\n border: 1px solid #dbdbdb;\n border-radius: 5px;\n cursor: pointer;\n padding: 10px 15px;\n width: 100%;\n height: 100%;\n }\n #akkadu-interpretation-player h3{\n margin:0px;\n padding:0px;\n }\n #akkadu-interpretation-player img{\n margin:0px;\n padding:0px;\n max-width: 20px;\n margin-right:10px;\n }\n #akkadu-interpretation-player h3, #akkadu-interpretation-player .selectCustom-trigger{\n font-size: 16px;\n font-weight: 400;\n text-transform: capitalize;\n }\n #akkadu-interpretation-player .selectCustom-trigger::after {\n content: \"\u25BE\";\n color:#908f8f;\n position: absolute;\n top: 7px;\n line-height: 20px;\n right: 10px;\n }\n \n #akkadu-interpretation-player .selectCustom-trigger:hover {\n box-shadow: 0 0 4px #e9e1f8;\n }\n #akkadu-interpretation-player .selectCustom-options {\n position: absolute;\n top: 45px;\n left: 0;\n width: 100%;\n border: 1px solid #dbdbdb;\n border-radius: 5px;\n background-color: #fff;\n box-shadow: 0 0 4px #e9e1f8;\n z-index: 1;\n padding:0px;\n display: none;\n cursor: pointer;\n box-shadow: 3px 6px 7px 4px #e3e3e3;\n }\n \n #akkadu-interpretation-player .selectCustom.isActive .selectCustom-options {\n display: block;\n min-width: 260px;\n }\n \n #akkadu-interpretation-player .selectCustom-option {\n position: relative;\n padding: 10px 15px;\n display: flex;\n }\n \n #akkadu-interpretation-player .selectCustom-option:hover {\n background-color: #F2F2F2;\n }\n \n #akkadu-interpretation-player .selectCustom-option:not(:last-of-type)::after {\n content: \"\";\n position: absolute;\n bottom: 0;\n left: 5px;\n width: 95%;\n border-bottom: 1px solid #e0e7ef;\n }\n \n\n \n " | ||
}; | ||
var _default$1 = component; | ||
var widgetComponent = /*#__PURE__*/Object.defineProperty({ | ||
default: _default$1 | ||
}, '__esModule', { | ||
value: true | ||
}); | ||
var __extends = commonjsGlobal && commonjsGlobal.__extends || function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || { | ||
__proto__: [] | ||
} instanceof Array && function (d, b) { | ||
d.__proto__ = b; | ||
} || function (d, b) { | ||
for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; | ||
}; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
}(); | ||
var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P ? value : new P(function (resolve) { | ||
resolve(value); | ||
}); | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = commonjsGlobal && commonjsGlobal.__generator || function (thisArg, body) { | ||
var _ = { | ||
label: 0, | ||
sent: function () { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
f, | ||
y, | ||
t, | ||
g; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function (v) { | ||
return step([n, v]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [0]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [6, e]; | ||
y = 0; | ||
} finally { | ||
f = t = 0; | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
counter: 5, | ||
initCounter: 5, | ||
message: { | ||
action: null, | ||
amount: null | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
}; | ||
var defaultConsumerConfig = { | ||
languages: [], | ||
container: null | ||
}; | ||
var InterpretationPlayer = | ||
/** @class */ | ||
function (_super) { | ||
__extends(InterpretationPlayer, _super); | ||
function InterpretationPlayer(config) { | ||
var _this = _super.call(this) || this; | ||
var apiKey = config.apiKey, | ||
roomName = config.roomName, | ||
container = config.container, | ||
positionMenu = config.positionMenu; | ||
_this.apiKey = apiKey; | ||
_this.roomName = roomName; | ||
_this.positionMenu = positionMenu; | ||
_this.consumerConfig = defaultConsumerConfig; | ||
_this.consumerConfig.container = container; | ||
_this.consumerConfig.domContainer = document.querySelector("#" + _this.consumerConfig.container); | ||
if (!_this.apiKey) { | ||
throw Error('InterpretationPlayer: apiKey is undefined'); | ||
} | ||
if (!_this.roomName) { | ||
throw Error('InterpretationPlayer: roomName is undefined'); | ||
} | ||
if (!_this.consumerConfig.domContainer) { | ||
throw new Error("Unable to detect stream container " + _this.consumerConfig.container + " on the DOM"); | ||
} | ||
return _this; | ||
} | ||
InterpretationPlayer.prototype.init = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
this.gatewayRequest(this.apiKey, this.roomName); | ||
this.initListeners(); | ||
this.addInterpretationPlayer(); | ||
return [2 | ||
/*return*/ | ||
]; | ||
}); | ||
}); | ||
}; | ||
InterpretationPlayer.prototype.initListeners = function () {// | ||
}; | ||
/** | ||
* @description add the interpretation player to the dom "#akkadu-interpretation-player" | ||
* @private | ||
*/ | ||
InterpretationPlayer.prototype.addInterpretationPlayer = function () { | ||
this.emitter.emit('interpretation-player:on-ready', { | ||
isReady: true | ||
}); | ||
/** * @description widget: {html:string, css:string} */ | ||
var widget = widgetComponent.default; // Add Html to the DOM | ||
this.consumerConfig.domContainer.insertAdjacentHTML('beforeend', widget.html); // Add Styles to the DOM | ||
var style = document.createElement('style'); | ||
style.textContent = widget.css; | ||
document.head.appendChild(style); | ||
var styleStr = this.updateStylesWithProps(); | ||
if (styleStr) { | ||
var styleProp = document.createElement('style'); | ||
styleProp.textContent = styleStr; | ||
document.head.appendChild(styleProp); | ||
} // Add Script to the DOM | ||
// to update with the list of languages | ||
var languagesList = [{ | ||
iso: 'us', | ||
name: 'english' | ||
}, { | ||
iso: 'es', | ||
name: 'spanish' | ||
}, { | ||
iso: 'cn', | ||
name: 'chinese' | ||
}]; | ||
var languagesOptions = document.createDocumentFragment(); | ||
for (var i = 0; i < languagesList.length; i++) { | ||
var newOption = void 0; | ||
var newImage = void 0; | ||
var newText = void 0; | ||
newOption = document.createElement('div'); | ||
newOption.className = 'selectCustom-option'; | ||
newOption.id = i; | ||
newText = document.createElement('h3'); | ||
newText.textContent = languagesList[i].name; | ||
newImage = document.createElement('img'); | ||
newImage.src = this.getFlagUrl(languagesList[i].iso); | ||
newOption.appendChild(newImage); | ||
newOption.appendChild(newText); | ||
languagesOptions.appendChild(newOption); | ||
} | ||
document.getElementById('interpretation-player-options').appendChild(languagesOptions); | ||
var script = document.createElement('script'); | ||
script.textContent = widget.js; | ||
document.body.appendChild(script); // interpretation-player-custom-value | ||
var elSelectCustom = document.getElementsByClassName("js-selectCustom")[0]; | ||
var elSelectCustomValue = document.getElementById('interpretation-player-custom-value'); | ||
var elSelectCustomOptions = document.getElementById('interpretation-player-options'); | ||
elSelectCustomValue.getElementsByTagName("h3")[0].textContent = languagesList[0].name; | ||
elSelectCustomValue.getElementsByTagName("img")[0].src = this.getFlagUrl(languagesList[0].iso); // Listen for each custom language option selected | ||
var that = this; | ||
Array.from(elSelectCustomOptions.children).forEach(function (elOption) { | ||
elOption.addEventListener("click", function (e) { | ||
// Update custom select text | ||
var languageSelected; | ||
var idOption = e.target.id; | ||
languageSelected = languagesList[idOption]; | ||
elSelectCustomValue.getElementsByTagName("h3")[0].textContent = languageSelected.name; | ||
elSelectCustomValue.getElementsByTagName("img")[0].src = that.getFlagUrl(languageSelected.iso); | ||
that.emitter.emit('interpretation-player:on-language-selected', { | ||
languageSelected: languageSelected | ||
}); // Close select | ||
elSelectCustom.classList.remove("isActive"); | ||
}); | ||
}); // Toggle select on label click | ||
elSelectCustomValue.addEventListener("click", function (e) { | ||
elSelectCustom.classList.toggle("isActive"); | ||
}); // close the custom select when clicking outside. | ||
document.addEventListener("click", function (e) { | ||
var didClickedOutside = !elSelectCustom.contains(event.target); | ||
if (didClickedOutside) { | ||
elSelectCustom.classList.remove("isActive"); | ||
} | ||
}); // prop for position box - should do an auto one first ? | ||
// 6px -1px 8px 1px #e3e3e3 !important | ||
// bottom: 55px; top 0px for .selectCustom-options | ||
}; | ||
InterpretationPlayer.prototype.updateStylesWithProps = function () { | ||
var propsDefault = { | ||
'positionMenu': 'bottom' | ||
}; | ||
}, | ||
var stylesStr; | ||
var styles = []; | ||
computed: { | ||
changedBy() { | ||
const { | ||
message | ||
} = this; | ||
if (!message.action) return 'initialized'; | ||
return `${message.action} ${message.amount || ''}`.trim(); | ||
if (this.positionMenu !== propsDefault['positionMenu']) { | ||
var style = ".selectCustom-options{\n box-shadow:6px -1px 8px 1px #e3e3e3 !important;\n top: -130px !important;\n }"; | ||
styles.push(style); | ||
} | ||
stylesStr = styles.join(' '); | ||
return stylesStr; | ||
}; // Api to get the flags icons: https://www.countryflags.io/ | ||
InterpretationPlayer.prototype.getFlagUrl = function (iso) { | ||
return "https://www.countryflags.io/" + iso + "/flat/64.png"; | ||
}; | ||
return InterpretationPlayer; | ||
}(lib.default); | ||
var _default = InterpretationPlayer; | ||
// | ||
var script = { | ||
props: { | ||
apiKey: { | ||
required: true, | ||
type: String, | ||
default: null | ||
}, | ||
positionMenu: { | ||
required: false, | ||
type: String, | ||
default: 'bottom' | ||
} | ||
}, | ||
data() { | ||
return { | ||
stream: null | ||
}; | ||
}, | ||
mounted() { | ||
this.init(); | ||
}, | ||
methods: { | ||
increment(arg) { | ||
const amount = typeof arg !== 'number' ? 1 : arg; | ||
this.counter += amount; | ||
this.message.action = 'incremented by'; | ||
this.message.amount = amount; | ||
async init() { | ||
const roomName = this.getRoomname(); | ||
console.info(this.apiKey, 'api key'); | ||
if (!roomName) { | ||
throw Error('interpretation-player: roomname is not defined'); | ||
} | ||
if (!this.apiKey) { | ||
throw Error('interpretation-player: apiKey is not defined'); | ||
} | ||
/* const InterpretationPlayer = (await import('@/rsi-api-widget/modules/rsi-api-interpretation-player')).default */ | ||
//const InterpretationPlayer = (await import('@akkadu/rsi-api-interpretation-player')).default // @akkadu/rsi-api-interpretation-player //to update to @akkadu/rsi-api-interpretation-player | ||
const config = { | ||
apiKey: this.apiKey, | ||
roomName, | ||
container: 'akkadu-interpretation-player', | ||
positionMenu: this.positionMenu | ||
}; | ||
this.stream = new _default(config); | ||
this.initListeners(); | ||
this.stream.init(); | ||
}, | ||
decrement(arg) { | ||
const amount = typeof arg !== 'number' ? 1 : arg; | ||
this.counter -= amount; | ||
this.message.action = 'decremented by'; | ||
this.message.amount = amount; | ||
getRoomname() { | ||
return 'test'; | ||
}, | ||
reset() { | ||
this.counter = this.initCounter; | ||
this.message.action = 'reset'; | ||
this.message.amount = null; | ||
/** | ||
* @description Additionnal information about theses events in : /interpretation-player/events.html | ||
*/ | ||
initListeners() { | ||
this.stream.on('interpretation-player:on-ready', ({ | ||
isReady | ||
}) => { | ||
console.info('interpretation-player:on-ready', isReady); | ||
this.$emit("onReady", { | ||
isReady | ||
}); | ||
}); | ||
this.stream.on('interpretation-player:on-language-selected', ({ | ||
languageSelected | ||
}) => { | ||
console.info('interpretation-player:on-language-selected', languageSelected); | ||
this.$emit("onLanguageSelected", { | ||
languageSelected | ||
}); | ||
}); | ||
this.stream.on('interpretation-player:on-connection-status-updated', ({ | ||
connection | ||
}) => { | ||
console.info('interpretation-player:on-connection-status-updated', connection); | ||
this.$emit("onConnectionStatusUpdated", { | ||
connection | ||
}); | ||
}); | ||
} | ||
@@ -125,55 +559,2 @@ | ||
const isOldIE = typeof navigator !== 'undefined' && | ||
/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase()); | ||
function createInjector(context) { | ||
return (id, style) => addStyle(id, style); | ||
} | ||
let HEAD; | ||
const styles = {}; | ||
function addStyle(id, css) { | ||
const group = isOldIE ? css.media || 'default' : id; | ||
const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] }); | ||
if (!style.ids.has(id)) { | ||
style.ids.add(id); | ||
let code = css.source; | ||
if (css.map) { | ||
// https://developer.chrome.com/devtools/docs/javascript-debugging | ||
// this makes source maps inside style tags work properly in Chrome | ||
code += '\n/*# sourceURL=' + css.map.sources[0] + ' */'; | ||
// http://stackoverflow.com/a/26603875 | ||
code += | ||
'\n/*# sourceMappingURL=data:application/json;base64,' + | ||
btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) + | ||
' */'; | ||
} | ||
if (!style.element) { | ||
style.element = document.createElement('style'); | ||
style.element.type = 'text/css'; | ||
if (css.media) | ||
style.element.setAttribute('media', css.media); | ||
if (HEAD === undefined) { | ||
HEAD = document.head || document.getElementsByTagName('head')[0]; | ||
} | ||
HEAD.appendChild(style.element); | ||
} | ||
if ('styleSheet' in style.element) { | ||
style.styles.push(code); | ||
style.element.styleSheet.cssText = style.styles | ||
.filter(Boolean) | ||
.join('\n'); | ||
} | ||
else { | ||
const index = style.ids.size - 1; | ||
const textNode = document.createTextNode(code); | ||
const nodes = style.element.childNodes; | ||
if (nodes[index]) | ||
style.element.removeChild(nodes[index]); | ||
if (nodes.length) | ||
style.element.insertBefore(textNode, nodes[index]); | ||
else | ||
style.element.appendChild(textNode); | ||
} | ||
} | ||
} | ||
/* script */ | ||
@@ -191,28 +572,6 @@ const __vue_script__ = script; | ||
return _c('div', { | ||
staticClass: "rsi-api-vue-sample" | ||
}, [_c('p', [_vm._v("The counter was " + _vm._s(_vm.changedBy) + " to "), _c('b', [_vm._v(_vm._s(_vm.counter))]), _vm._v(".")]), _vm._v(" "), _c('button', { | ||
on: { | ||
"click": _vm.increment | ||
attrs: { | ||
"id": "akkadu-interpretation-player" | ||
} | ||
}, [_vm._v("\n Click +1\n ")]), _vm._v(" "), _c('button', { | ||
on: { | ||
"click": _vm.decrement | ||
} | ||
}, [_vm._v("\n Click -1\n ")]), _vm._v(" "), _c('button', { | ||
on: { | ||
"click": function ($event) { | ||
return _vm.increment(5); | ||
} | ||
} | ||
}, [_vm._v("\n Click +5\n ")]), _vm._v(" "), _c('button', { | ||
on: { | ||
"click": function ($event) { | ||
return _vm.decrement(5); | ||
} | ||
} | ||
}, [_vm._v("\n Click -5\n ")]), _vm._v(" "), _c('button', { | ||
on: { | ||
"click": _vm.reset | ||
} | ||
}, [_vm._v("\n Reset\n ")])]); | ||
}); | ||
}; | ||
@@ -223,14 +582,6 @@ | ||
const __vue_inject_styles__ = function (inject) { | ||
if (!inject) return; | ||
inject("data-v-0355cc53_0", { | ||
source: ".rsi-api-vue-sample[data-v-0355cc53]{display:block;width:400px;margin:25px auto;border:1px solid #ccc;background:#eaeaea;text-align:center;padding:25px}.rsi-api-vue-sample p[data-v-0355cc53]{margin:0 0 1em}", | ||
map: undefined, | ||
media: undefined | ||
}); | ||
}; | ||
const __vue_inject_styles__ = undefined; | ||
/* scoped */ | ||
const __vue_scope_id__ = "data-v-0355cc53"; | ||
const __vue_scope_id__ = undefined; | ||
/* module identifier */ | ||
@@ -242,2 +593,4 @@ | ||
const __vue_is_functional_template__ = false; | ||
/* style inject */ | ||
/* style inject SSR */ | ||
@@ -250,10 +603,9 @@ | ||
staticRenderFns: __vue_staticRenderFns__ | ||
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, createInjector, undefined, undefined); | ||
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined); | ||
/* eslint-disable import/prefer-default-export */ | ||
/* export { default as RsiApiInterpreterPlayer } from './rsi-api-interpreter-player.vue'; */ | ||
var components = /*#__PURE__*/Object.freeze({ | ||
__proto__: null, | ||
RsiApiVueSample: __vue_component__ | ||
__proto__: null, | ||
RsiApiInterpretationPlayer: __vue_component__ | ||
}); | ||
@@ -270,2 +622,2 @@ | ||
export default install; | ||
export { __vue_component__ as RsiApiVueSample }; | ||
export { __vue_component__ as RsiApiInterpretationPlayer }; |
@@ -1,1 +0,1 @@ | ||
var RsiApiVue=function(){"use strict";function e(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return t(e,n);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return t(e,n)}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function n(e,t,n,r,o,i,a,s,c,u){"boolean"!=typeof a&&(c=s,s=a,a=!1);const l="function"==typeof n?n.options:n;let d;if(e&&e.render&&(l.render=e.render,l.staticRenderFns=e.staticRenderFns,l._compiled=!0,o&&(l.functional=!0)),r&&(l._scopeId=r),i?(d=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,c(e)),e&&e._registeredComponents&&e._registeredComponents.add(i)},l._ssrRegister=d):t&&(d=a?function(e){t.call(this,u(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,s(e))}),d)if(l.functional){const e=l.render;l.render=function(t,n){return d.call(n),e(t,n)}}else{const e=l.beforeCreate;l.beforeCreate=e?[].concat(e,d):[d]}return n}const r="undefined"!=typeof navigator&&/msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());function o(e){return(e,t)=>function(e,t){const n=r?t.media||"default":e,o=a[n]||(a[n]={ids:new Set,styles:[]});if(!o.ids.has(e)){o.ids.add(e);let n=t.source;if(t.map&&(n+="\n/*# sourceURL="+t.map.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(t.map))))+" */"),o.element||(o.element=document.createElement("style"),o.element.type="text/css",t.media&&o.element.setAttribute("media",t.media),void 0===i&&(i=document.head||document.getElementsByTagName("head")[0]),i.appendChild(o.element)),"styleSheet"in o.element)o.styles.push(n),o.element.styleSheet.cssText=o.styles.filter(Boolean).join("\n");else{const e=o.ids.size-1,t=document.createTextNode(n),r=o.element.childNodes;r[e]&&o.element.removeChild(r[e]),r.length?o.element.insertBefore(t,r[e]):o.element.appendChild(t)}}}(e,t)}let i;const a={};var s=n({render:function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("div",{staticClass:"rsi-api-vue-sample"},[n("p",[e._v("The counter was "+e._s(e.changedBy)+" to "),n("b",[e._v(e._s(e.counter))]),e._v(".")]),e._v(" "),n("button",{on:{click:e.increment}},[e._v("\n Click +1\n ")]),e._v(" "),n("button",{on:{click:e.decrement}},[e._v("\n Click -1\n ")]),e._v(" "),n("button",{on:{click:function(t){return e.increment(5)}}},[e._v("\n Click +5\n ")]),e._v(" "),n("button",{on:{click:function(t){return e.decrement(5)}}},[e._v("\n Click -5\n ")]),e._v(" "),n("button",{on:{click:e.reset}},[e._v("\n Reset\n ")])])},staticRenderFns:[]},(function(e){e&&e("data-v-0355cc53_0",{source:".rsi-api-vue-sample[data-v-0355cc53]{display:block;width:400px;margin:25px auto;border:1px solid #ccc;background:#eaeaea;text-align:center;padding:25px}.rsi-api-vue-sample p[data-v-0355cc53]{margin:0 0 1em}",map:void 0,media:void 0})}),{name:"RsiApiVueSample",data:function(){return{counter:5,initCounter:5,message:{action:null,amount:null}}},computed:{changedBy:function(){var e=this.message;return e.action?"".concat(e.action," ").concat(e.amount||"").trim():"initialized"}},methods:{increment:function(e){var t="number"!=typeof e?1:e;this.counter+=t,this.message.action="incremented by",this.message.amount=t},decrement:function(e){var t="number"!=typeof e?1:e;this.counter-=t,this.message.action="decremented by",this.message.amount=t},reset:function(){this.counter=this.initCounter,this.message.action="reset",this.message.amount=null}}},"data-v-0355cc53",false,undefined,!1,o,void 0,void 0),c=Object.freeze({__proto__:null,RsiApiVueSample:s}),u=function(t){Object.entries(c).forEach((function(n){var r=e(n,2),o=r[0],i=r[1];t.component(o,i)}))},l=Object.freeze({__proto__:null,default:u,RsiApiVueSample:s});return Object.entries(l).forEach((function(t){var n=e(t,2),r=n[0],o=n[1];"default"!==r&&(u[r]=o)})),u}(); | ||
var RsiApiVue=function(e){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function r(e,t,n,r,o,i,a){try{var s=e[i](a),l=s.value}catch(e){return void n(e)}s.done?t(l):Promise.resolve(l).then(r,o)}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var a,s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},l=function(){function e(){this.emitter=new n.default.EventEmitter}return e.prototype.gatewayRequest=function(e,t){if(!e)throw Error("base akadu-rsi: apiKey is undefined.");if(!t)throw Error("base akkadu-rsi: roomname is undefined.");return"test gateway"},e.prototype.on=function(e,t){this.emitter.on(e,t)},e}(),u=Object.defineProperty({default:l},"__esModule",{value:!0}),p={html:'\n <body>\n <div class="select">\n <div class="selectWrapper" >\n <div class="selectCustom js-selectCustom">\n <div id="interpretation-player-custom-value" class="selectCustom-trigger"> <img src=\'\'/> <h3> </h3> </div>\n <div id="interpretation-player-options" class="selectCustom-options">\n </div>\n </div>\n </div>\n </body>\n ',css:'\n\n #akkadu-interpretation-player {\n display: inline-table;\n position: relative;\n font-family: "Helvetica Neue", Arial, sans-serif;\n }\n #akkadu-interpretation-player .select {\n position: relative;\n }\n #akkadu-interpretation-player .selectLabel {\n display: block;\n margin-bottom: 10px;\n }\n #akkadu-interpretation-player .selectWrapper {\n position: relative;\n }\n #akkadu-interpretation-player .selectCustom {\n position: relative;\n height: 100%;\n }\n #akkadu-interpretation-player .selectCustom-trigger {\n display: flex;\n position: relative;\n min-width: 150px;\n background-color: white;\n border: 1px solid #dbdbdb;\n border-radius: 5px;\n cursor: pointer;\n padding: 10px 15px;\n width: 100%;\n height: 100%;\n }\n #akkadu-interpretation-player h3{\n margin:0px;\n padding:0px;\n }\n #akkadu-interpretation-player img{\n margin:0px;\n padding:0px;\n max-width: 20px;\n margin-right:10px;\n }\n #akkadu-interpretation-player h3, #akkadu-interpretation-player .selectCustom-trigger{\n font-size: 16px;\n font-weight: 400;\n text-transform: capitalize;\n }\n #akkadu-interpretation-player .selectCustom-trigger::after {\n content: "▾";\n color:#908f8f;\n position: absolute;\n top: 7px;\n line-height: 20px;\n right: 10px;\n }\n \n #akkadu-interpretation-player .selectCustom-trigger:hover {\n box-shadow: 0 0 4px #e9e1f8;\n }\n #akkadu-interpretation-player .selectCustom-options {\n position: absolute;\n top: 45px;\n left: 0;\n width: 100%;\n border: 1px solid #dbdbdb;\n border-radius: 5px;\n background-color: #fff;\n box-shadow: 0 0 4px #e9e1f8;\n z-index: 1;\n padding:0px;\n display: none;\n cursor: pointer;\n box-shadow: 3px 6px 7px 4px #e3e3e3;\n }\n \n #akkadu-interpretation-player .selectCustom.isActive .selectCustom-options {\n display: block;\n min-width: 260px;\n }\n \n #akkadu-interpretation-player .selectCustom-option {\n position: relative;\n padding: 10px 15px;\n display: flex;\n }\n \n #akkadu-interpretation-player .selectCustom-option:hover {\n background-color: #F2F2F2;\n }\n \n #akkadu-interpretation-player .selectCustom-option:not(:last-of-type)::after {\n content: "";\n position: absolute;\n bottom: 0;\n left: 5px;\n width: 95%;\n border-bottom: 1px solid #e0e7ef;\n }\n \n\n \n '},c=Object.defineProperty({default:p},"__esModule",{value:!0}),d=s&&s.__extends||(a=function(e,t){return(a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=s&&s.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{l(r.next(e))}catch(e){i(e)}}function s(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}l((r=r.apply(e,t||[])).next())}))},m=s&&s.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}},y={languages:[],container:null},h=function(e){function t(t){var n=e.call(this)||this,r=t.apiKey,o=t.roomName,i=t.container,a=t.positionMenu;if(n.apiKey=r,n.roomName=o,n.positionMenu=a,n.consumerConfig=y,n.consumerConfig.container=i,n.consumerConfig.domContainer=document.querySelector("#"+n.consumerConfig.container),!n.apiKey)throw Error("InterpretationPlayer: apiKey is undefined");if(!n.roomName)throw Error("InterpretationPlayer: roomName is undefined");if(!n.consumerConfig.domContainer)throw new Error("Unable to detect stream container "+n.consumerConfig.container+" on the DOM");return n}return d(t,e),t.prototype.init=function(){return f(this,void 0,void 0,(function(){return m(this,(function(e){return this.gatewayRequest(this.apiKey,this.roomName),this.initListeners(),this.addInterpretationPlayer(),[2]}))}))},t.prototype.initListeners=function(){},t.prototype.addInterpretationPlayer=function(){this.emitter.emit("interpretation-player:on-ready",{isReady:!0});var e=c.default;this.consumerConfig.domContainer.insertAdjacentHTML("beforeend",e.html);var t=document.createElement("style");t.textContent=e.css,document.head.appendChild(t);var n=this.updateStylesWithProps();if(n){var r=document.createElement("style");r.textContent=n,document.head.appendChild(r)}for(var o=[{iso:"us",name:"english"},{iso:"es",name:"spanish"},{iso:"cn",name:"chinese"}],i=document.createDocumentFragment(),a=0;a<o.length;a++){var s=void 0,l=void 0,u=void 0;(s=document.createElement("div")).className="selectCustom-option",s.id=a,(u=document.createElement("h3")).textContent=o[a].name,(l=document.createElement("img")).src=this.getFlagUrl(o[a].iso),s.appendChild(l),s.appendChild(u),i.appendChild(s)}document.getElementById("interpretation-player-options").appendChild(i);var p=document.createElement("script");p.textContent=e.js,document.body.appendChild(p);var d=document.getElementsByClassName("js-selectCustom")[0],f=document.getElementById("interpretation-player-custom-value"),m=document.getElementById("interpretation-player-options");f.getElementsByTagName("h3")[0].textContent=o[0].name,f.getElementsByTagName("img")[0].src=this.getFlagUrl(o[0].iso);var y=this;Array.from(m.children).forEach((function(e){e.addEventListener("click",(function(e){var t,n=e.target.id;t=o[n],f.getElementsByTagName("h3")[0].textContent=t.name,f.getElementsByTagName("img")[0].src=y.getFlagUrl(t.iso),y.emitter.emit("interpretation-player:on-language-selected",{languageSelected:t}),d.classList.remove("isActive")}))})),f.addEventListener("click",(function(e){d.classList.toggle("isActive")})),document.addEventListener("click",(function(e){!d.contains(event.target)&&d.classList.remove("isActive")}))},t.prototype.updateStylesWithProps=function(){var e=[];if("bottom"!==this.positionMenu){e.push(".selectCustom-options{\n box-shadow:6px -1px 8px 1px #e3e3e3 !important;\n top: -130px !important;\n }")}return e.join(" ")},t.prototype.getFlagUrl=function(e){return"https://www.countryflags.io/"+e+"/flat/64.png"},t}(u.default);function g(e,t,n,r,o,i,a,s,l,u){"boolean"!=typeof a&&(l=s,s=a,a=!1);const p="function"==typeof n?n.options:n;let c;if(e&&e.render&&(p.render=e.render,p.staticRenderFns=e.staticRenderFns,p._compiled=!0,o&&(p.functional=!0)),r&&(p._scopeId=r),i?(c=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),t&&t.call(this,l(e)),e&&e._registeredComponents&&e._registeredComponents.add(i)},p._ssrRegister=c):t&&(c=a?function(e){t.call(this,u(e,this.$root.$options.shadowRoot))}:function(e){t.call(this,s(e))}),c)if(p.functional){const e=p.render;p.render=function(t,n){return c.call(n),e(t,n)}}else{const e=p.beforeCreate;p.beforeCreate=e?[].concat(e,c):[c]}return n}var v=g({render:function(){var e=this.$createElement;return(this._self._c||e)("div",{attrs:{id:"akkadu-interpretation-player"}})},staticRenderFns:[]},undefined,{props:{apiKey:{required:!0,type:String,default:null},positionMenu:{required:!1,type:String,default:"bottom"}},data:function(){return{stream:null}},mounted:function(){this.init()},methods:{init:function(){var e,t=this;return(e=regeneratorRuntime.mark((function e(){var n,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=t.getRoomname(),console.info(t.apiKey,"api key"),n){e.next=4;break}throw Error("interpretation-player: roomname is not defined");case 4:if(t.apiKey){e.next=6;break}throw Error("interpretation-player: apiKey is not defined");case 6:r={apiKey:t.apiKey,roomName:n,container:"akkadu-interpretation-player",positionMenu:t.positionMenu},t.stream=new h(r),t.initListeners(),t.stream.init();case 10:case"end":return e.stop()}}),e)})),function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function s(e){r(a,o,i,s,l,"next",e)}function l(e){r(a,o,i,s,l,"throw",e)}s(void 0)}))})()},getRoomname:function(){return"test"},initListeners:function(){var e=this;this.stream.on("interpretation-player:on-ready",(function(t){var n=t.isReady;console.info("interpretation-player:on-ready",n),e.$emit("onReady",{isReady:n})})),this.stream.on("interpretation-player:on-language-selected",(function(t){var n=t.languageSelected;console.info("interpretation-player:on-language-selected",n),e.$emit("onLanguageSelected",{languageSelected:n})})),this.stream.on("interpretation-player:on-connection-status-updated",(function(t){var n=t.connection;console.info("interpretation-player:on-connection-status-updated",n),e.$emit("onConnectionStatusUpdated",{connection:n})}))}}},undefined,false,undefined,!1,void 0,void 0,void 0),b=Object.freeze({__proto__:null,RsiApiInterpretationPlayer:v}),x=function(e){Object.entries(b).forEach((function(t){var n=o(t,2),r=n[0],i=n[1];e.component(r,i)}))},k=Object.freeze({__proto__:null,default:x,RsiApiInterpretationPlayer:v});return Object.entries(k).forEach((function(e){var t=o(e,2),n=t[0],r=t[1];"default"!==n&&(x[n]=r)})),x}(events_1); |
@@ -1,2 +0,38 @@ | ||
'use strict';function _slicedToArray(arr, i) { | ||
'use strict';var events_1=require('events');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var events_1__default=/*#__PURE__*/_interopDefaultLegacy(events_1);function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { | ||
try { | ||
var info = gen[key](arg); | ||
var value = info.value; | ||
} catch (error) { | ||
reject(error); | ||
return; | ||
} | ||
if (info.done) { | ||
resolve(value); | ||
} else { | ||
Promise.resolve(value).then(_next, _throw); | ||
} | ||
} | ||
function _asyncToGenerator(fn) { | ||
return function () { | ||
var self = this, | ||
args = arguments; | ||
return new Promise(function (resolve, reject) { | ||
var gen = fn.apply(self, args); | ||
function _next(value) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); | ||
} | ||
function _throw(err) { | ||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); | ||
} | ||
_next(undefined); | ||
}); | ||
}; | ||
} | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
@@ -58,39 +94,497 @@ } | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
}var script = /*#__PURE__*/{ | ||
name: 'RsiApiVueSample', | ||
// vue component name | ||
data: function data() { | ||
return { | ||
counter: 5, | ||
initCounter: 5, | ||
message: { | ||
action: null, | ||
amount: null | ||
}var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};var Base = | ||
/** @class */ | ||
function () { | ||
function Base() { | ||
this.emitter = new events_1__default['default'].EventEmitter(); | ||
} | ||
Base.prototype.gatewayRequest = function (apiKey, roomName) { | ||
if (!apiKey) { | ||
throw Error('base akadu-rsi: apiKey is undefined.'); | ||
} | ||
if (!roomName) { | ||
throw Error('base akkadu-rsi: roomname is undefined.'); | ||
} | ||
return 'test gateway'; | ||
}; | ||
Base.prototype.on = function (event, fn) { | ||
this.emitter.on(event, fn); | ||
}; | ||
return Base; | ||
}(); | ||
var _default$2 = Base; | ||
var lib = /*#__PURE__*/Object.defineProperty({ | ||
default: _default$2 | ||
}, '__esModule', { | ||
value: true | ||
});var component = { | ||
html: "\n <body>\n <div class=\"select\">\n <div class=\"selectWrapper\" >\n <div class=\"selectCustom js-selectCustom\">\n <div id=\"interpretation-player-custom-value\" class=\"selectCustom-trigger\"> <img src=''/> <h3> </h3> </div>\n <div id=\"interpretation-player-options\" class=\"selectCustom-options\">\n </div>\n </div>\n </div>\n </body>\n ", | ||
css: "\n\n #akkadu-interpretation-player {\n display: inline-table;\n position: relative;\n font-family: \"Helvetica Neue\", Arial, sans-serif;\n }\n #akkadu-interpretation-player .select {\n position: relative;\n }\n #akkadu-interpretation-player .selectLabel {\n display: block;\n margin-bottom: 10px;\n }\n #akkadu-interpretation-player .selectWrapper {\n position: relative;\n }\n #akkadu-interpretation-player .selectCustom {\n position: relative;\n height: 100%;\n }\n #akkadu-interpretation-player .selectCustom-trigger {\n display: flex;\n position: relative;\n min-width: 150px;\n background-color: white;\n border: 1px solid #dbdbdb;\n border-radius: 5px;\n cursor: pointer;\n padding: 10px 15px;\n width: 100%;\n height: 100%;\n }\n #akkadu-interpretation-player h3{\n margin:0px;\n padding:0px;\n }\n #akkadu-interpretation-player img{\n margin:0px;\n padding:0px;\n max-width: 20px;\n margin-right:10px;\n }\n #akkadu-interpretation-player h3, #akkadu-interpretation-player .selectCustom-trigger{\n font-size: 16px;\n font-weight: 400;\n text-transform: capitalize;\n }\n #akkadu-interpretation-player .selectCustom-trigger::after {\n content: \"\u25BE\";\n color:#908f8f;\n position: absolute;\n top: 7px;\n line-height: 20px;\n right: 10px;\n }\n \n #akkadu-interpretation-player .selectCustom-trigger:hover {\n box-shadow: 0 0 4px #e9e1f8;\n }\n #akkadu-interpretation-player .selectCustom-options {\n position: absolute;\n top: 45px;\n left: 0;\n width: 100%;\n border: 1px solid #dbdbdb;\n border-radius: 5px;\n background-color: #fff;\n box-shadow: 0 0 4px #e9e1f8;\n z-index: 1;\n padding:0px;\n display: none;\n cursor: pointer;\n box-shadow: 3px 6px 7px 4px #e3e3e3;\n }\n \n #akkadu-interpretation-player .selectCustom.isActive .selectCustom-options {\n display: block;\n min-width: 260px;\n }\n \n #akkadu-interpretation-player .selectCustom-option {\n position: relative;\n padding: 10px 15px;\n display: flex;\n }\n \n #akkadu-interpretation-player .selectCustom-option:hover {\n background-color: #F2F2F2;\n }\n \n #akkadu-interpretation-player .selectCustom-option:not(:last-of-type)::after {\n content: \"\";\n position: absolute;\n bottom: 0;\n left: 5px;\n width: 95%;\n border-bottom: 1px solid #e0e7ef;\n }\n \n\n \n " | ||
}; | ||
var _default$1 = component; | ||
var widgetComponent = /*#__PURE__*/Object.defineProperty({ | ||
default: _default$1 | ||
}, '__esModule', { | ||
value: true | ||
});var __extends = commonjsGlobal && commonjsGlobal.__extends || function () { | ||
var _extendStatics = function extendStatics(d, b) { | ||
_extendStatics = Object.setPrototypeOf || { | ||
__proto__: [] | ||
} instanceof Array && function (d, b) { | ||
d.__proto__ = b; | ||
} || function (d, b) { | ||
for (var p in b) { | ||
if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; | ||
} | ||
}; | ||
return _extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
_extendStatics(d, b); | ||
function __() { | ||
this.constructor = d; | ||
} | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
}(); | ||
var __awaiter = commonjsGlobal && commonjsGlobal.__awaiter || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { | ||
return value instanceof P ? value : new P(function (resolve) { | ||
resolve(value); | ||
}); | ||
} | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { | ||
try { | ||
step(generator.next(value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function rejected(value) { | ||
try { | ||
step(generator["throw"](value)); | ||
} catch (e) { | ||
reject(e); | ||
} | ||
} | ||
function step(result) { | ||
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); | ||
} | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = commonjsGlobal && commonjsGlobal.__generator || function (thisArg, body) { | ||
var _ = { | ||
label: 0, | ||
sent: function sent() { | ||
if (t[0] & 1) throw t[1]; | ||
return t[1]; | ||
}, | ||
trys: [], | ||
ops: [] | ||
}, | ||
computed: { | ||
changedBy: function changedBy() { | ||
var message = this.message; | ||
if (!message.action) return 'initialized'; | ||
return "".concat(message.action, " ").concat(message.amount || '').trim(); | ||
f, | ||
y, | ||
t, | ||
g; | ||
return g = { | ||
next: verb(0), | ||
"throw": verb(1), | ||
"return": verb(2) | ||
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () { | ||
return this; | ||
}), g; | ||
function verb(n) { | ||
return function (v) { | ||
return step([n, v]); | ||
}; | ||
} | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) { | ||
try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: | ||
case 1: | ||
t = op; | ||
break; | ||
case 4: | ||
_.label++; | ||
return { | ||
value: op[1], | ||
done: false | ||
}; | ||
case 5: | ||
_.label++; | ||
y = op[1]; | ||
op = [0]; | ||
continue; | ||
case 7: | ||
op = _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { | ||
_ = 0; | ||
continue; | ||
} | ||
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { | ||
_.label = op[1]; | ||
break; | ||
} | ||
if (op[0] === 6 && _.label < t[1]) { | ||
_.label = t[1]; | ||
t = op; | ||
break; | ||
} | ||
if (t && _.label < t[2]) { | ||
_.label = t[2]; | ||
_.ops.push(op); | ||
break; | ||
} | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); | ||
continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { | ||
op = [6, e]; | ||
y = 0; | ||
} finally { | ||
f = t = 0; | ||
} | ||
} | ||
if (op[0] & 5) throw op[1]; | ||
return { | ||
value: op[0] ? op[1] : void 0, | ||
done: true | ||
}; | ||
} | ||
}; | ||
var defaultConsumerConfig = { | ||
languages: [], | ||
container: null | ||
}; | ||
var InterpretationPlayer = | ||
/** @class */ | ||
function (_super) { | ||
__extends(InterpretationPlayer, _super); | ||
function InterpretationPlayer(config) { | ||
var _this = _super.call(this) || this; | ||
var apiKey = config.apiKey, | ||
roomName = config.roomName, | ||
container = config.container, | ||
positionMenu = config.positionMenu; | ||
_this.apiKey = apiKey; | ||
_this.roomName = roomName; | ||
_this.positionMenu = positionMenu; | ||
_this.consumerConfig = defaultConsumerConfig; | ||
_this.consumerConfig.container = container; | ||
_this.consumerConfig.domContainer = document.querySelector("#" + _this.consumerConfig.container); | ||
if (!_this.apiKey) { | ||
throw Error('InterpretationPlayer: apiKey is undefined'); | ||
} | ||
if (!_this.roomName) { | ||
throw Error('InterpretationPlayer: roomName is undefined'); | ||
} | ||
if (!_this.consumerConfig.domContainer) { | ||
throw new Error("Unable to detect stream container " + _this.consumerConfig.container + " on the DOM"); | ||
} | ||
return _this; | ||
} | ||
InterpretationPlayer.prototype.init = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
this.gatewayRequest(this.apiKey, this.roomName); | ||
this.initListeners(); | ||
this.addInterpretationPlayer(); | ||
return [2 | ||
/*return*/ | ||
]; | ||
}); | ||
}); | ||
}; | ||
InterpretationPlayer.prototype.initListeners = function () {// | ||
}; | ||
/** | ||
* @description add the interpretation player to the dom "#akkadu-interpretation-player" | ||
* @private | ||
*/ | ||
InterpretationPlayer.prototype.addInterpretationPlayer = function () { | ||
this.emitter.emit('interpretation-player:on-ready', { | ||
isReady: true | ||
}); | ||
/** * @description widget: {html:string, css:string} */ | ||
var widget = widgetComponent.default; // Add Html to the DOM | ||
this.consumerConfig.domContainer.insertAdjacentHTML('beforeend', widget.html); // Add Styles to the DOM | ||
var style = document.createElement('style'); | ||
style.textContent = widget.css; | ||
document.head.appendChild(style); | ||
var styleStr = this.updateStylesWithProps(); | ||
if (styleStr) { | ||
var styleProp = document.createElement('style'); | ||
styleProp.textContent = styleStr; | ||
document.head.appendChild(styleProp); | ||
} // Add Script to the DOM | ||
// to update with the list of languages | ||
var languagesList = [{ | ||
iso: 'us', | ||
name: 'english' | ||
}, { | ||
iso: 'es', | ||
name: 'spanish' | ||
}, { | ||
iso: 'cn', | ||
name: 'chinese' | ||
}]; | ||
var languagesOptions = document.createDocumentFragment(); | ||
for (var i = 0; i < languagesList.length; i++) { | ||
var newOption = void 0; | ||
var newImage = void 0; | ||
var newText = void 0; | ||
newOption = document.createElement('div'); | ||
newOption.className = 'selectCustom-option'; | ||
newOption.id = i; | ||
newText = document.createElement('h3'); | ||
newText.textContent = languagesList[i].name; | ||
newImage = document.createElement('img'); | ||
newImage.src = this.getFlagUrl(languagesList[i].iso); | ||
newOption.appendChild(newImage); | ||
newOption.appendChild(newText); | ||
languagesOptions.appendChild(newOption); | ||
} | ||
document.getElementById('interpretation-player-options').appendChild(languagesOptions); | ||
var script = document.createElement('script'); | ||
script.textContent = widget.js; | ||
document.body.appendChild(script); // interpretation-player-custom-value | ||
var elSelectCustom = document.getElementsByClassName("js-selectCustom")[0]; | ||
var elSelectCustomValue = document.getElementById('interpretation-player-custom-value'); | ||
var elSelectCustomOptions = document.getElementById('interpretation-player-options'); | ||
elSelectCustomValue.getElementsByTagName("h3")[0].textContent = languagesList[0].name; | ||
elSelectCustomValue.getElementsByTagName("img")[0].src = this.getFlagUrl(languagesList[0].iso); // Listen for each custom language option selected | ||
var that = this; | ||
Array.from(elSelectCustomOptions.children).forEach(function (elOption) { | ||
elOption.addEventListener("click", function (e) { | ||
// Update custom select text | ||
var languageSelected; | ||
var idOption = e.target.id; | ||
languageSelected = languagesList[idOption]; | ||
elSelectCustomValue.getElementsByTagName("h3")[0].textContent = languageSelected.name; | ||
elSelectCustomValue.getElementsByTagName("img")[0].src = that.getFlagUrl(languageSelected.iso); | ||
that.emitter.emit('interpretation-player:on-language-selected', { | ||
languageSelected: languageSelected | ||
}); // Close select | ||
elSelectCustom.classList.remove("isActive"); | ||
}); | ||
}); // Toggle select on label click | ||
elSelectCustomValue.addEventListener("click", function (e) { | ||
elSelectCustom.classList.toggle("isActive"); | ||
}); // close the custom select when clicking outside. | ||
document.addEventListener("click", function (e) { | ||
var didClickedOutside = !elSelectCustom.contains(event.target); | ||
if (didClickedOutside) { | ||
elSelectCustom.classList.remove("isActive"); | ||
} | ||
}); // prop for position box - should do an auto one first ? | ||
// 6px -1px 8px 1px #e3e3e3 !important | ||
// bottom: 55px; top 0px for .selectCustom-options | ||
}; | ||
InterpretationPlayer.prototype.updateStylesWithProps = function () { | ||
var propsDefault = { | ||
'positionMenu': 'bottom' | ||
}; | ||
var stylesStr; | ||
var styles = []; | ||
if (this.positionMenu !== propsDefault['positionMenu']) { | ||
var style = ".selectCustom-options{\n box-shadow:6px -1px 8px 1px #e3e3e3 !important;\n top: -130px !important;\n }"; | ||
styles.push(style); | ||
} | ||
stylesStr = styles.join(' '); | ||
return stylesStr; | ||
}; // Api to get the flags icons: https://www.countryflags.io/ | ||
InterpretationPlayer.prototype.getFlagUrl = function (iso) { | ||
return "https://www.countryflags.io/" + iso + "/flat/64.png"; | ||
}; | ||
return InterpretationPlayer; | ||
}(lib.default); | ||
var _default = InterpretationPlayer;var script = { | ||
props: { | ||
apiKey: { | ||
required: true, | ||
type: String, | ||
default: null | ||
}, | ||
positionMenu: { | ||
required: false, | ||
type: String, | ||
default: 'bottom' | ||
} | ||
}, | ||
data: function data() { | ||
return { | ||
stream: null | ||
}; | ||
}, | ||
mounted: function mounted() { | ||
this.init(); | ||
}, | ||
methods: { | ||
increment: function increment(arg) { | ||
var amount = typeof arg !== 'number' ? 1 : arg; | ||
this.counter += amount; | ||
this.message.action = 'incremented by'; | ||
this.message.amount = amount; | ||
init: function init() { | ||
var _this = this; | ||
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { | ||
var roomName, config; | ||
return regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
roomName = _this.getRoomname(); | ||
console.info(_this.apiKey, 'api key'); | ||
if (roomName) { | ||
_context.next = 4; | ||
break; | ||
} | ||
throw Error('interpretation-player: roomname is not defined'); | ||
case 4: | ||
if (_this.apiKey) { | ||
_context.next = 6; | ||
break; | ||
} | ||
throw Error('interpretation-player: apiKey is not defined'); | ||
case 6: | ||
/* const InterpretationPlayer = (await import('@/rsi-api-widget/modules/rsi-api-interpretation-player')).default */ | ||
//const InterpretationPlayer = (await import('@akkadu/rsi-api-interpretation-player')).default // @akkadu/rsi-api-interpretation-player //to update to @akkadu/rsi-api-interpretation-player | ||
config = { | ||
apiKey: _this.apiKey, | ||
roomName: roomName, | ||
container: 'akkadu-interpretation-player', | ||
positionMenu: _this.positionMenu | ||
}; | ||
_this.stream = new _default(config); | ||
_this.initListeners(); | ||
_this.stream.init(); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
}))(); | ||
}, | ||
decrement: function decrement(arg) { | ||
var amount = typeof arg !== 'number' ? 1 : arg; | ||
this.counter -= amount; | ||
this.message.action = 'decremented by'; | ||
this.message.amount = amount; | ||
getRoomname: function getRoomname() { | ||
return 'test'; | ||
}, | ||
reset: function reset() { | ||
this.counter = this.initCounter; | ||
this.message.action = 'reset'; | ||
this.message.amount = null; | ||
/** | ||
* @description Additionnal information about theses events in : /interpretation-player/events.html | ||
*/ | ||
initListeners: function initListeners() { | ||
var _this2 = this; | ||
this.stream.on('interpretation-player:on-ready', function (_ref) { | ||
var isReady = _ref.isReady; | ||
console.info('interpretation-player:on-ready', isReady); | ||
_this2.$emit("onReady", { | ||
isReady: isReady | ||
}); | ||
}); | ||
this.stream.on('interpretation-player:on-language-selected', function (_ref2) { | ||
var languageSelected = _ref2.languageSelected; | ||
console.info('interpretation-player:on-language-selected', languageSelected); | ||
_this2.$emit("onLanguageSelected", { | ||
languageSelected: languageSelected | ||
}); | ||
}); | ||
this.stream.on('interpretation-player:on-connection-status-updated', function (_ref3) { | ||
var connection = _ref3.connection; | ||
console.info('interpretation-player:on-connection-status-updated', connection); | ||
_this2.$emit("onConnectionStatusUpdated", { | ||
connection: connection | ||
}); | ||
}); | ||
} | ||
@@ -171,42 +665,2 @@ } | ||
return script; | ||
}function createInjectorSSR(context) { | ||
if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { | ||
context = __VUE_SSR_CONTEXT__; | ||
} | ||
if (!context) | ||
return () => { }; | ||
if (!('styles' in context)) { | ||
context._styles = context._styles || {}; | ||
Object.defineProperty(context, 'styles', { | ||
enumerable: true, | ||
get: () => context._renderStyles(context._styles) | ||
}); | ||
context._renderStyles = context._renderStyles || renderStyles; | ||
} | ||
return (id, style) => addStyle(id, style, context); | ||
} | ||
function addStyle(id, css, context) { | ||
const group = css.media || 'default' ; | ||
const style = context._styles[group] || (context._styles[group] = { ids: [], css: '' }); | ||
if (!style.ids.includes(id)) { | ||
style.media = css.media; | ||
style.ids.push(id); | ||
let code = css.source; | ||
style.css += code + '\n'; | ||
} | ||
} | ||
function renderStyles(styles) { | ||
let css = ''; | ||
for (const key in styles) { | ||
const style = styles[key]; | ||
css += | ||
'<style data-vue-ssr-id="' + | ||
Array.from(style.ids).join(' ') + | ||
'"' + | ||
(style.media ? ' media="' + style.media + '"' : '') + | ||
'>' + | ||
style.css + | ||
'</style>'; | ||
} | ||
return css; | ||
}/* script */ | ||
@@ -224,4 +678,6 @@ var __vue_script__ = script; | ||
return _c('div', { | ||
staticClass: "rsi-api-vue-sample" | ||
}, [_vm._ssrNode("<p data-v-0355cc53>" + _vm._ssrEscape("The counter was " + _vm._s(_vm.changedBy) + " to ") + "<b data-v-0355cc53>" + _vm._ssrEscape(_vm._s(_vm.counter)) + "</b>.</p> <button data-v-0355cc53>\n Click +1\n </button> <button data-v-0355cc53>\n Click -1\n </button> <button data-v-0355cc53>\n Click +5\n </button> <button data-v-0355cc53>\n Click -5\n </button> <button data-v-0355cc53>\n Reset\n </button>")]); | ||
attrs: { | ||
"id": "akkadu-interpretation-player" | ||
} | ||
}, []); | ||
}; | ||
@@ -232,20 +688,16 @@ | ||
var __vue_inject_styles__ = function __vue_inject_styles__(inject) { | ||
if (!inject) return; | ||
inject("data-v-0355cc53_0", { | ||
source: ".rsi-api-vue-sample[data-v-0355cc53]{display:block;width:400px;margin:25px auto;border:1px solid #ccc;background:#eaeaea;text-align:center;padding:25px}.rsi-api-vue-sample p[data-v-0355cc53]{margin:0 0 1em}", | ||
map: undefined, | ||
media: undefined | ||
}); | ||
}; | ||
var __vue_inject_styles__ = undefined; | ||
/* scoped */ | ||
var __vue_scope_id__ = "data-v-0355cc53"; | ||
var __vue_scope_id__ = undefined; | ||
/* module identifier */ | ||
var __vue_module_identifier__ = "data-v-0355cc53"; | ||
var __vue_module_identifier__ = "data-v-f5e1196a"; | ||
/* functional template */ | ||
var __vue_is_functional_template__ = false; | ||
/* style inject */ | ||
/* style inject SSR */ | ||
/* style inject shadow dom */ | ||
@@ -256,4 +708,3 @@ | ||
staticRenderFns: __vue_staticRenderFns__ | ||
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, createInjectorSSR, undefined);/* eslint-disable import/prefer-default-export */ | ||
/* export { default as RsiApiInterpreterPlayer } from './rsi-api-interpreter-player.vue'; */var components$1=/*#__PURE__*/Object.freeze({__proto__:null,RsiApiVueSample: __vue_component__});var install = function installRsiApiVue(Vue) { | ||
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined);/* eslint-disable import/prefer-default-export */var components$1=/*#__PURE__*/Object.freeze({__proto__:null,RsiApiInterpretationPlayer: __vue_component__});var install = function installRsiApiVue(Vue) { | ||
Object.entries(components$1).forEach(function (_ref) { | ||
@@ -267,3 +718,3 @@ var _ref2 = _slicedToArray(_ref, 2), | ||
}; // Create module definition for Vue.use() | ||
var components=/*#__PURE__*/Object.freeze({__proto__:null,'default': install,RsiApiVueSample: __vue_component__});// only expose one global var, with component exports exposed as properties of | ||
var components=/*#__PURE__*/Object.freeze({__proto__:null,'default': install,RsiApiInterpretationPlayer: __vue_component__});// only expose one global var, with component exports exposed as properties of | ||
// that global var (eg. plugin.component) | ||
@@ -270,0 +721,0 @@ |
{ | ||
"name": "@akkadu/rsi-api-vue", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -22,3 +22,3 @@ "main": "dist/rsi-api-vue.ssr.js", | ||
"dependencies": { | ||
"@akkadu/rsi-api-interpretation-player": "0.0.2" | ||
"@akkadu/rsi-api-interpretation-player": "0.0.4" | ||
}, | ||
@@ -25,0 +25,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
61357
1138
5
3
1
+ Added@akkadu/rsi-api-base@0.0.6(transitive)
+ Added@akkadu/rsi-api-interpretation-player@0.0.4(transitive)
- Removed@akkadu/rsi-api-base@0.0.5(transitive)
- Removed@akkadu/rsi-api-interpretation-player@0.0.2(transitive)