From 67a5dbc181161eef715fced10e939e5a4c73c362 Mon Sep 17 00:00:00 2001 From: Bridget Almas Date: Wed, 18 Sep 2019 11:38:46 -0400 Subject: [PATCH] use rc in version --- dist/alpheios-embedded.js | 2 +- dist/alpheios-embedded.min.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/alpheios-embedded.js b/dist/alpheios-embedded.js index 050597c..462c248 100644 --- a/dist/alpheios-embedded.js +++ b/dist/alpheios-embedded.js @@ -94,7 +94,7 @@ window["AlpheiosEmbed"] = /*! exports provided: name, version, build, description, main, directories, scripts, repository, author, license, bugs, homepage, devDependencies, engines, jest, eslintConfig, eslintIgnore, dependencies, default */ /***/ (function(module) { -module.exports = JSON.parse("{\"name\":\"alpheios-embedded\",\"version\":\"3.0.0\",\"build\":\"39\",\"description\":\"Alpheios Embedded Library\",\"main\":\"dist/alpheios-embedded.js\",\"directories\":{\"doc\":\"doc\"},\"scripts\":{\"test\":\"npm run lint && jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js\",\"build\":\"npm run build-dev && npm run build-prod\",\"build-prod\":\"npm run lint && node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs all production app config.mjs\",\"build-dev\":\"npm run lint && node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs all development app config.mjs\",\"auth0-env-update\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=../protected-config/auth0/prod --t=dist/auth0 --f=env-embed.js\",\"auth0-env-dev-update\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=../protected-config/auth0/dev --t=dist/auth0 --f=env-embed.js\",\"lint\":\"eslint --fix src/**/*.js\",\"update-dependencies\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=./node_modules/alpheios-components/dist/ --t=dist/lib && node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=./node_modules/alpheios-components/dist/style --t=dist/style\",\"build-experimental\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs webpack development app config.mjs\",\"dev\":\"npm run build-experimental && http-server -c-1 -p 8888 & onchange src -- npm run build-experimental\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/alpheios-project/wordsvc.git\"},\"author\":\"The Alpheios Project, Ltd.\",\"license\":\"ISC\",\"bugs\":{\"url\":\"https://github.com/alpheios-project/wordsvc/issues\"},\"homepage\":\"https://github.com/alpheios-project/wordsvc#readme\",\"devDependencies\":{\"alpheios-components\":\"github:alpheios-project/components#v1.2.45\",\"alpheios-node-build\":\"github:alpheios-project/node-build#v0.6.3\",\"copy-webpack-plugin\":\"^5.0.4\",\"coveralls\":\"^3.0.6\",\"css-loader\":\"^3.2.0\",\"eslint\":\"^6.3.0\",\"eslint-config-standard\":\"^12.0.0\",\"eslint-plugin-import\":\"^2.18.2\",\"eslint-plugin-node\":\"^9.2.0\",\"eslint-plugin-promise\":\"^4.2.1\",\"eslint-plugin-standard\":\"^4.0.1\",\"eslint-plugin-vue\":\"^5.2.3\",\"html-loader\":\"^0.5.5\",\"html-loader-jest\":\"^0.2.1\",\"http-server\":\"^0.11.1\",\"interactjs\":\"^1.6.1\",\"intl-messageformat\":\"^2.2.0\",\"jest\":\"^24.9.0\",\"jest-fetch-mock\":\"^2.1.2\",\"onchange\":\"^6.1.0\",\"raw-loader\":\"^3.1.0\",\"sass-loader\":\"^7.3.1\",\"source-map-loader\":\"^0.2.4\",\"style-loader\":\"^0.23.1\",\"url-loader\":\"^2.1.0\",\"vue-loader\":\"^15.7.1\",\"vue-style-loader\":\"^4.1.2\",\"vue-svg-loader\":\"^0.12.0\",\"webpack-dev-server\":\"^3.8.0\"},\"engines\":{\"node\":\">= 9.10.1\",\"npm\":\">= 5.6.0\"},\"jest\":{\"verbose\":true,\"transform\":{\"^.+\\\\.htmlf$\":\"html-loader-jest\",\"^.+\\\\.jsx?$\":\"babel-jest\"},\"transformIgnorePatterns\":[\"node_modules/alpheios-components/\"]},\"eslintConfig\":{\"env\":{\"browser\":true,\"node\":true},\"parser\":\"babel-eslint\",\"parserOptions\":{\"sourceType\":\"module\",\"ecmaVersion\":2019,\"allowImportExportEverywhere\":true}},\"eslintIgnore\":[\"**/dist\"],\"dependencies\":{}}"); +module.exports = JSON.parse("{\"name\":\"alpheios-embedded\",\"version\":\"3.0.0-rc.2\",\"build\":\"39\",\"description\":\"Alpheios Embedded Library\",\"main\":\"dist/alpheios-embedded.js\",\"directories\":{\"doc\":\"doc\"},\"scripts\":{\"test\":\"npm run lint && jest --coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js\",\"build\":\"npm run build-dev && npm run build-prod\",\"build-prod\":\"npm run lint && node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs all production app config.mjs\",\"build-dev\":\"npm run lint && node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs all development app config.mjs\",\"auth0-env-update\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=../protected-config/auth0/prod --t=dist/auth0 --f=env-embed.js\",\"auth0-env-dev-update\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=../protected-config/auth0/dev --t=dist/auth0 --f=env-embed.js\",\"lint\":\"eslint --fix src/**/*.js\",\"update-dependencies\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=./node_modules/alpheios-components/dist/ --t=dist/lib && node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=./node_modules/alpheios-components/dist/style --t=dist/style\",\"build-experimental\":\"node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs webpack development app config.mjs\",\"dev\":\"npm run build-experimental && http-server -c-1 -p 8888 & onchange src -- npm run build-experimental\"},\"repository\":{\"type\":\"git\",\"url\":\"git+https://github.com/alpheios-project/wordsvc.git\"},\"author\":\"The Alpheios Project, Ltd.\",\"license\":\"ISC\",\"bugs\":{\"url\":\"https://github.com/alpheios-project/wordsvc/issues\"},\"homepage\":\"https://github.com/alpheios-project/wordsvc#readme\",\"devDependencies\":{\"alpheios-components\":\"github:alpheios-project/components#v1.2.45\",\"alpheios-node-build\":\"github:alpheios-project/node-build#v0.6.3\",\"copy-webpack-plugin\":\"^5.0.4\",\"coveralls\":\"^3.0.6\",\"css-loader\":\"^3.2.0\",\"eslint\":\"^6.3.0\",\"eslint-config-standard\":\"^12.0.0\",\"eslint-plugin-import\":\"^2.18.2\",\"eslint-plugin-node\":\"^9.2.0\",\"eslint-plugin-promise\":\"^4.2.1\",\"eslint-plugin-standard\":\"^4.0.1\",\"eslint-plugin-vue\":\"^5.2.3\",\"html-loader\":\"^0.5.5\",\"html-loader-jest\":\"^0.2.1\",\"http-server\":\"^0.11.1\",\"interactjs\":\"^1.6.1\",\"intl-messageformat\":\"^2.2.0\",\"jest\":\"^24.9.0\",\"jest-fetch-mock\":\"^2.1.2\",\"onchange\":\"^6.1.0\",\"raw-loader\":\"^3.1.0\",\"sass-loader\":\"^7.3.1\",\"source-map-loader\":\"^0.2.4\",\"style-loader\":\"^0.23.1\",\"url-loader\":\"^2.1.0\",\"vue-loader\":\"^15.7.1\",\"vue-style-loader\":\"^4.1.2\",\"vue-svg-loader\":\"^0.12.0\",\"webpack-dev-server\":\"^3.8.0\"},\"engines\":{\"node\":\">= 9.10.1\",\"npm\":\">= 5.6.0\"},\"jest\":{\"verbose\":true,\"transform\":{\"^.+\\\\.htmlf$\":\"html-loader-jest\",\"^.+\\\\.jsx?$\":\"babel-jest\"},\"transformIgnorePatterns\":[\"node_modules/alpheios-components/\"]},\"eslintConfig\":{\"env\":{\"browser\":true,\"node\":true},\"parser\":\"babel-eslint\",\"parserOptions\":{\"sourceType\":\"module\",\"ecmaVersion\":2019,\"allowImportExportEverywhere\":true}},\"eslintIgnore\":[\"**/dist\"],\"dependencies\":{}}"); /***/ }), diff --git a/dist/alpheios-embedded.min.js b/dist/alpheios-embedded.min.js index 21384bf..c786473 100644 --- a/dist/alpheios-embedded.min.js +++ b/dist/alpheios-embedded.min.js @@ -1 +1 @@ -window.AlpheiosEmbed=function(e){var t={};function __webpack_require__(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,__webpack_require__),i.l=!0,i.exports}return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,t,s){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,t){if(1&t&&(e=__webpack_require__(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(__webpack_require__.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)__webpack_require__.d(s,i,function(t){return e[t]}.bind(null,i));return s},__webpack_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=1)}([function(e){e.exports=JSON.parse('{"c":"3.0.0","a":"39","b":"Alpheios Embedded Library"}')},function(e,t,s){"use strict";s.r(t);class State{constructor(e){this.panelStatus=void 0,this.tab=void 0,this.watchers=new Map}static create(e){let t=new State;for(let s of Object.keys(e))t[s]=e[s];return t}static get defaults(){return{panelStatus:State.statuses.panel.OPEN}}static get statuses(){return{embedLib:{PENDING:Symbol.for("Alpheios_Status_Pending"),ACTIVE:Symbol.for("Alpheios_Status_Active"),DEACTIVATED:Symbol.for("Alpheios_Status_Deactivated"),DISABLED:Symbol.for("Alpheios_Status_Disabled")},panel:{OPEN:Symbol.for("Alpheios_Status_PanelOpen"),CLOSED:Symbol.for("Alpheios_Status_PanelClosed"),DEFAULT:Symbol.for("Alpheios_Status_PanelDefault")},tab:{DEFAULT:"default"}}}setWatcher(e,t){return this.watchers.set(e,t),this}setItem(e,t){return this[e]=t,this.watchers&&this.watchers.has(e)&&this.watchers.get(e)(e,this),this}isPanelOpen(){return this.panelStatus===State.statuses.panel.OPEN}isPanelClosed(){return this.panelStatus===State.statuses.panel.CLOSED}isPanelStateDefault(){return this.panelStatus===State.statuses.panel.DEFAULT}isPanelStateValid(){return this.panelStatus===State.statuses.panel.OPEN||this.panelStatus===State.statuses.panel.CLOSED}setPanelOpen(){return this.setItem("panelStatus",State.statuses.panel.OPEN),this}setPanelClosed(){return this.setItem("panelStatus",State.statuses.panel.CLOSED),this}changeTab(e){return this.setItem("tab",e),this}activateUI(){return this.setItem("uiActive",!0),this}isActive(){return this.status===State.statuses.embedLib.ACTIVE}isDeactivated(){return this.status===State.statuses.embedLib.DEACTIVATED}isDisabled(){return this.status===State.statuses.embedLib.DISABLED}isTabStateDefault(){return this.tab===State.statuses.tab.DEFAULT}uiIsActive(){return this.uiActive}activate(){return this.status=State.statuses.embedLib.ACTIVE,this}deactivate(){return this.status=State.statuses.embedLib.DEACTIVATED,this}disable(){return this.status=State.statuses.embedLib.DISABLED,this}}var i=s(0);class AppAuthenticator{constructor(e){this.auth0Lock=null,this._auth0profile=null,this.env=e}loginUrl(){return null}logoutUrl(){return null}session(){return new Promise((e,t)=>{t(new Error("Session request not supported"))})}authenticate(){return new Promise((e,t)=>{if(!this.auth0Lock){if(!this.env){let e="Unable to find Auth0 configuration. Auth0 functionality will be disabled";console.error(e),t(e)}this.env.TEST_ID?(localStorage.setItem("access_token",this.env.TEST_ID),localStorage.setItem("id_token",this.env.TEST_ID),localStorage.setItem("is_test_user",!0),e("Authenticated")):(this.auth0Lock=new Auth0Lock(this.env.CLIENT_ID,this.env.DOMAIN,{theme:{logo:"https://alpheios.net/logos/alpheios_32.png",labeledSubmitButton:!1,primaryColor:"#436476"},languageDictionary:{title:"Login",signUpTerms:'By signing up, you agree to our terms of service and privacy policy.'},mustAcceptTerms:!0,auth:{redirect:!1,params:{audience:this.env.AUDIENCE,scope:"openid profile email",prompt:"consent select_account"},responseType:"token id_token"}}),this.auth0Lock.on("authenticated",t=>{this.auth0Lock.hide(),localStorage.setItem("access_token",t.accessToken),localStorage.setItem("id_token",t.idToken),e("Authenticated")}),this.auth0Lock.on("unrecoverable_error",e=>{console.error("Auth0 Lock unrecoverable error: ",e),t("Auth0 Lock unrecoverable")}),this.auth0Lock.on("authorization_error",e=>{console.error("Auth0 Lock authorization error: ",e),t("Auth0Lock authorization error")}),this.auth0Lock.show())}})}getProfileData(){return new Promise((e,t)=>{const s=localStorage.getItem("access_token");if(s||(console.error("You must login to call this protected endpoint!"),t("Login required")),localStorage.getItem("is_test_user")){let t={name:"Alpheios Test User",nickname:"testuser",sub:"testuser"};localStorage.setItem("profile",JSON.stringify(t)),e(t)}else this.auth0Lock.getUserInfo(s,(s,i)=>{s?t(s):(localStorage.setItem("profile",JSON.stringify(i)),e(i))})})}getUserData(){return new Promise((e,t)=>{const s=localStorage.getItem("access_token");s||(console.error("You must login to call this protected endpoint!"),t("Not Authenticated")),e(s)})}getEndPoints(){return this.env.ENDPOINTS}logout(){localStorage.removeItem("id_token"),localStorage.removeItem("access_token"),localStorage.removeItem("profile"),this.auth0Lock.logout({returnTo:this.env.LOGOUT_URL})}}class SessionAuthenticator{constructor(e){this.sessionUrl=e.SESSION_URL,this.tokenUrl=e.TOKEN_URL,this.endpoints=e.ENDPOINTS,this._loginUrl=e.LOGIN_URL,this._logoutUrl=e.LOGOUT_URL}loginUrl(){return this._loginUrl}logoutUrl(){return this._logoutUrl}session(){return new Promise((e,t)=>{window.fetch(this.sessionUrl).then(s=>{s.ok?e(s.json()):t(s.code)}).catch(e=>{t(`Session request failed ${e}`)})})}authenticate(){return new Promise((e,t)=>{t("Server Side Authenticator")})}getUserData(){return new Promise((e,t)=>{window.fetch(this.tokenUrl).then(s=>{s.ok?e(s.json()):t(s.code)}).catch(e=>{t(`token request failed ${e}`)})})}getEndPoints(){return this.endpoints}logout(){}}let o;function importDependencies(e){let t={};switch(e.mode){case"production":t.components="./lib/alpheios-components.min.js";break;case"development":t.components="./lib/alpheios-components.js";break;case"custom":t=e.libs;break;case"cdn":default:t.components="https://cdn.jsdelivr.net/npm/alpheios-components@latest/dist/alpheios-components.min.js"}return new Promise((e,s)=>{let i=[],r=import(t.components).then(()=>{o=window.AlpheiosComponents});i.push(r),Promise.all(i).then(()=>{e(embedded_Embedded)}).catch(e=>{s(e)})})}s.d(t,"importDependencies",(function(){return importDependencies}));class embedded_Embedded{constructor({clientId:e=null,authEnv:t=null,documentObject:s=document,enabledSelector:r=".alpheios-enabled",disabledSelector:a="",enabledClass:n="",disabledClass:l="",mobileTriggerEvent:u=null,desktopTriggerEvent:c=null,triggerPreCallback:h=(e=>!0),popupInitialPos:d={},toolbarInitialPos:p={},actionPanelInitialPos:_={},layoutType:b="default",disableTextSelection:g=!1,textLangCode:m=null,overrideHelp:S=!1,simpleMode:f=!1}={}){if(this.clientId=e,null===this.clientId)throw new Error("Please identify the site.");this.doc=s,this.authEnv=t,this.state=new State,this.enabledSelector=r,this.disabledSelector=a,this.enabledClass=n,this.disabledClass=l,this.desktopTriggerEvent=c,this.mobileTriggerEvent=u,this.triggerPreCallback=h,this.simpleMode=f,this.state.setPanelClosed(),this.state.tab="info",this.ui=o.UIController.create(this.state,{storageAdapter:o.LocalStorageArea,textQueryTriggerDesktop:this.desktopTriggerEvent,textQueryTriggerMobile:this.mobileTriggerEvent,textQuerySelector:this.enabledSelector,triggerPreCallback:this.triggerPreCallback,app:{version:`${i.c}.${i.a}`,name:i.b},appType:o.Platform.appTypes.EMBEDDED_LIBRARY,clientId:this.clientId,disableTextSelection:g,textLangCode:m,overrideHelp:S}),this.authEnv?t.CLIENT_ID?this.ui.registerModule(o.AuthModule,{auth:new AppAuthenticator(t)}):t.LOGIN_URL&&this.ui.registerModule(o.AuthModule,{auth:new SessionAuthenticator(t)}):this.ui.registerModule(o.AuthModule,{auth:null});let v={};this.simpleMode&&(v.showNav=!1),this.ui.registerModule(o.PanelModule,v);let A={};d&&Object.values(d).filter(e=>Boolean(e)).length>0&&(A.initialPos=d),this.simpleMode&&(A.showNav=!1),this.ui.registerModule(o.PopupModule,A);let w={};_&&Object.values(_).filter(e=>Boolean(e)).length>0&&(w.initialPos=_),this.simpleMode?w.showNav=!1:w.showNav=!0;let E={};this.simpleMode&&(E.showNav=!1),"default"===b?(p&&Object.values(p).filter(e=>Boolean(e)).length>0&&(E.initialPos=p),this.ui.registerModule(o.ToolbarModule,E),this.ui.registerModule(o.ActionPanelModule,{showNav:w.showNav})):"readingTools"===b&&(this.ui.platform.isDesktop?(p&&Object.values(p).filter(e=>Boolean(e)).length>0&&(E.initialPos=p),this.ui.registerModule(o.ToolbarModule,E)):this.ui.platform.isMobile&&this.ui.registerModule(o.ActionPanelModule,{lookupResultsIn:"panel",initialPos:w.initialPos,showNav:w.showNav}))}get platform(){return this.ui.platform}notifyExtension(){this.doc.body.dispatchEvent(new Event("Alpheios_Embedded_Response"))}async activate(){try{this.notifyExtension(),await this.ui.activate(),this.doc.body.setAttribute("alpheios-embed-lib-status","active"),this.doc.body.addEventListener("Alpheios_Embedded_Check",e=>{this.notifyExtension(e)}),this.ui.setEmbedLibActive(!0)}catch(e){return void console.error(`Unexpected error activating Alpheios: ${e}`)}let e=this.enabledSelector;if(!e)throw new Error("Configuration must define selector");let t=this.doc.querySelectorAll(e);if(0===t.length&&console.warn(`Alpheios was activated for the page but not any content (no elements matching ${t}).`),this.enabledClass)for(let e of t)e.classList.add(this.enabledClass);if(this.disabledSelector){let e=this.doc.querySelectorAll(this.disabledSelector);for(let t of e)t.setAttribute("data-alpheios-ignore","all"),this.disabledClass&&t.classList.add(this.disabledClass)}new o.AlignmentSelector(this.doc,{}).activate();o.UIController.initAlignedTranslation(this.doc,".aligned-translation",{edges:{left:!0,right:!0,bottom:!1,top:!1},restrictSize:{min:{width:200}},restrictEdges:{outer:this.doc.body,endOnly:!0},inertia:!0},e=>{e.target.style.width=`${e.rect.width}px`});return this}openToolbar(){this.ui.openToolbar()}openActionPanel(){this.ui.platform.isMobile&&this.ui.closePanel(),this.ui.openActionPanel()}closeActionPanel(){this.ui.closeActionPanel()}openActionPanelLookup(){this.ui.platform.isMobile&&this.ui.closePanel(),this.ui.openActionPanel({showNav:!1})}openActionPanelToolbar(){this.ui.platform.isMobile&&this.ui.closePanel(),this.ui.openActionPanel({showLookup:!1})}}}]); \ No newline at end of file +window.AlpheiosEmbed=function(e){var t={};function __webpack_require__(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,__webpack_require__),i.l=!0,i.exports}return __webpack_require__.m=e,__webpack_require__.c=t,__webpack_require__.d=function(e,t,s){__webpack_require__.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__webpack_require__.t=function(e,t){if(1&t&&(e=__webpack_require__(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(__webpack_require__.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)__webpack_require__.d(s,i,function(t){return e[t]}.bind(null,i));return s},__webpack_require__.n=function(e){var t=e&&e.__esModule?function getDefault(){return e.default}:function getModuleExports(){return e};return __webpack_require__.d(t,"a",t),t},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=1)}([function(e){e.exports=JSON.parse('{"c":"3.0.0-rc.2","a":"39","b":"Alpheios Embedded Library"}')},function(e,t,s){"use strict";s.r(t);class State{constructor(e){this.panelStatus=void 0,this.tab=void 0,this.watchers=new Map}static create(e){let t=new State;for(let s of Object.keys(e))t[s]=e[s];return t}static get defaults(){return{panelStatus:State.statuses.panel.OPEN}}static get statuses(){return{embedLib:{PENDING:Symbol.for("Alpheios_Status_Pending"),ACTIVE:Symbol.for("Alpheios_Status_Active"),DEACTIVATED:Symbol.for("Alpheios_Status_Deactivated"),DISABLED:Symbol.for("Alpheios_Status_Disabled")},panel:{OPEN:Symbol.for("Alpheios_Status_PanelOpen"),CLOSED:Symbol.for("Alpheios_Status_PanelClosed"),DEFAULT:Symbol.for("Alpheios_Status_PanelDefault")},tab:{DEFAULT:"default"}}}setWatcher(e,t){return this.watchers.set(e,t),this}setItem(e,t){return this[e]=t,this.watchers&&this.watchers.has(e)&&this.watchers.get(e)(e,this),this}isPanelOpen(){return this.panelStatus===State.statuses.panel.OPEN}isPanelClosed(){return this.panelStatus===State.statuses.panel.CLOSED}isPanelStateDefault(){return this.panelStatus===State.statuses.panel.DEFAULT}isPanelStateValid(){return this.panelStatus===State.statuses.panel.OPEN||this.panelStatus===State.statuses.panel.CLOSED}setPanelOpen(){return this.setItem("panelStatus",State.statuses.panel.OPEN),this}setPanelClosed(){return this.setItem("panelStatus",State.statuses.panel.CLOSED),this}changeTab(e){return this.setItem("tab",e),this}activateUI(){return this.setItem("uiActive",!0),this}isActive(){return this.status===State.statuses.embedLib.ACTIVE}isDeactivated(){return this.status===State.statuses.embedLib.DEACTIVATED}isDisabled(){return this.status===State.statuses.embedLib.DISABLED}isTabStateDefault(){return this.tab===State.statuses.tab.DEFAULT}uiIsActive(){return this.uiActive}activate(){return this.status=State.statuses.embedLib.ACTIVE,this}deactivate(){return this.status=State.statuses.embedLib.DEACTIVATED,this}disable(){return this.status=State.statuses.embedLib.DISABLED,this}}var i=s(0);class AppAuthenticator{constructor(e){this.auth0Lock=null,this._auth0profile=null,this.env=e}loginUrl(){return null}logoutUrl(){return null}session(){return new Promise((e,t)=>{t(new Error("Session request not supported"))})}authenticate(){return new Promise((e,t)=>{if(!this.auth0Lock){if(!this.env){let e="Unable to find Auth0 configuration. Auth0 functionality will be disabled";console.error(e),t(e)}this.env.TEST_ID?(localStorage.setItem("access_token",this.env.TEST_ID),localStorage.setItem("id_token",this.env.TEST_ID),localStorage.setItem("is_test_user",!0),e("Authenticated")):(this.auth0Lock=new Auth0Lock(this.env.CLIENT_ID,this.env.DOMAIN,{theme:{logo:"https://alpheios.net/logos/alpheios_32.png",labeledSubmitButton:!1,primaryColor:"#436476"},languageDictionary:{title:"Login",signUpTerms:'By signing up, you agree to our terms of service and privacy policy.'},mustAcceptTerms:!0,auth:{redirect:!1,params:{audience:this.env.AUDIENCE,scope:"openid profile email",prompt:"consent select_account"},responseType:"token id_token"}}),this.auth0Lock.on("authenticated",t=>{this.auth0Lock.hide(),localStorage.setItem("access_token",t.accessToken),localStorage.setItem("id_token",t.idToken),e("Authenticated")}),this.auth0Lock.on("unrecoverable_error",e=>{console.error("Auth0 Lock unrecoverable error: ",e),t("Auth0 Lock unrecoverable")}),this.auth0Lock.on("authorization_error",e=>{console.error("Auth0 Lock authorization error: ",e),t("Auth0Lock authorization error")}),this.auth0Lock.show())}})}getProfileData(){return new Promise((e,t)=>{const s=localStorage.getItem("access_token");if(s||(console.error("You must login to call this protected endpoint!"),t("Login required")),localStorage.getItem("is_test_user")){let t={name:"Alpheios Test User",nickname:"testuser",sub:"testuser"};localStorage.setItem("profile",JSON.stringify(t)),e(t)}else this.auth0Lock.getUserInfo(s,(s,i)=>{s?t(s):(localStorage.setItem("profile",JSON.stringify(i)),e(i))})})}getUserData(){return new Promise((e,t)=>{const s=localStorage.getItem("access_token");s||(console.error("You must login to call this protected endpoint!"),t("Not Authenticated")),e(s)})}getEndPoints(){return this.env.ENDPOINTS}logout(){localStorage.removeItem("id_token"),localStorage.removeItem("access_token"),localStorage.removeItem("profile"),this.auth0Lock.logout({returnTo:this.env.LOGOUT_URL})}}class SessionAuthenticator{constructor(e){this.sessionUrl=e.SESSION_URL,this.tokenUrl=e.TOKEN_URL,this.endpoints=e.ENDPOINTS,this._loginUrl=e.LOGIN_URL,this._logoutUrl=e.LOGOUT_URL}loginUrl(){return this._loginUrl}logoutUrl(){return this._logoutUrl}session(){return new Promise((e,t)=>{window.fetch(this.sessionUrl).then(s=>{s.ok?e(s.json()):t(s.code)}).catch(e=>{t(`Session request failed ${e}`)})})}authenticate(){return new Promise((e,t)=>{t("Server Side Authenticator")})}getUserData(){return new Promise((e,t)=>{window.fetch(this.tokenUrl).then(s=>{s.ok?e(s.json()):t(s.code)}).catch(e=>{t(`token request failed ${e}`)})})}getEndPoints(){return this.endpoints}logout(){}}let o;function importDependencies(e){let t={};switch(e.mode){case"production":t.components="./lib/alpheios-components.min.js";break;case"development":t.components="./lib/alpheios-components.js";break;case"custom":t=e.libs;break;case"cdn":default:t.components="https://cdn.jsdelivr.net/npm/alpheios-components@latest/dist/alpheios-components.min.js"}return new Promise((e,s)=>{let i=[],r=import(t.components).then(()=>{o=window.AlpheiosComponents});i.push(r),Promise.all(i).then(()=>{e(embedded_Embedded)}).catch(e=>{s(e)})})}s.d(t,"importDependencies",(function(){return importDependencies}));class embedded_Embedded{constructor({clientId:e=null,authEnv:t=null,documentObject:s=document,enabledSelector:r=".alpheios-enabled",disabledSelector:a="",enabledClass:n="",disabledClass:l="",mobileTriggerEvent:u=null,desktopTriggerEvent:c=null,triggerPreCallback:h=(e=>!0),popupInitialPos:d={},toolbarInitialPos:p={},actionPanelInitialPos:_={},layoutType:b="default",disableTextSelection:g=!1,textLangCode:m=null,overrideHelp:S=!1,simpleMode:f=!1}={}){if(this.clientId=e,null===this.clientId)throw new Error("Please identify the site.");this.doc=s,this.authEnv=t,this.state=new State,this.enabledSelector=r,this.disabledSelector=a,this.enabledClass=n,this.disabledClass=l,this.desktopTriggerEvent=c,this.mobileTriggerEvent=u,this.triggerPreCallback=h,this.simpleMode=f,this.state.setPanelClosed(),this.state.tab="info",this.ui=o.UIController.create(this.state,{storageAdapter:o.LocalStorageArea,textQueryTriggerDesktop:this.desktopTriggerEvent,textQueryTriggerMobile:this.mobileTriggerEvent,textQuerySelector:this.enabledSelector,triggerPreCallback:this.triggerPreCallback,app:{version:`${i.c}.${i.a}`,name:i.b},appType:o.Platform.appTypes.EMBEDDED_LIBRARY,clientId:this.clientId,disableTextSelection:g,textLangCode:m,overrideHelp:S}),this.authEnv?t.CLIENT_ID?this.ui.registerModule(o.AuthModule,{auth:new AppAuthenticator(t)}):t.LOGIN_URL&&this.ui.registerModule(o.AuthModule,{auth:new SessionAuthenticator(t)}):this.ui.registerModule(o.AuthModule,{auth:null});let v={};this.simpleMode&&(v.showNav=!1),this.ui.registerModule(o.PanelModule,v);let A={};d&&Object.values(d).filter(e=>Boolean(e)).length>0&&(A.initialPos=d),this.simpleMode&&(A.showNav=!1),this.ui.registerModule(o.PopupModule,A);let w={};_&&Object.values(_).filter(e=>Boolean(e)).length>0&&(w.initialPos=_),this.simpleMode?w.showNav=!1:w.showNav=!0;let E={};this.simpleMode&&(E.showNav=!1),"default"===b?(p&&Object.values(p).filter(e=>Boolean(e)).length>0&&(E.initialPos=p),this.ui.registerModule(o.ToolbarModule,E),this.ui.registerModule(o.ActionPanelModule,{showNav:w.showNav})):"readingTools"===b&&(this.ui.platform.isDesktop?(p&&Object.values(p).filter(e=>Boolean(e)).length>0&&(E.initialPos=p),this.ui.registerModule(o.ToolbarModule,E)):this.ui.platform.isMobile&&this.ui.registerModule(o.ActionPanelModule,{lookupResultsIn:"panel",initialPos:w.initialPos,showNav:w.showNav}))}get platform(){return this.ui.platform}notifyExtension(){this.doc.body.dispatchEvent(new Event("Alpheios_Embedded_Response"))}async activate(){try{this.notifyExtension(),await this.ui.activate(),this.doc.body.setAttribute("alpheios-embed-lib-status","active"),this.doc.body.addEventListener("Alpheios_Embedded_Check",e=>{this.notifyExtension(e)}),this.ui.setEmbedLibActive(!0)}catch(e){return void console.error(`Unexpected error activating Alpheios: ${e}`)}let e=this.enabledSelector;if(!e)throw new Error("Configuration must define selector");let t=this.doc.querySelectorAll(e);if(0===t.length&&console.warn(`Alpheios was activated for the page but not any content (no elements matching ${t}).`),this.enabledClass)for(let e of t)e.classList.add(this.enabledClass);if(this.disabledSelector){let e=this.doc.querySelectorAll(this.disabledSelector);for(let t of e)t.setAttribute("data-alpheios-ignore","all"),this.disabledClass&&t.classList.add(this.disabledClass)}new o.AlignmentSelector(this.doc,{}).activate();o.UIController.initAlignedTranslation(this.doc,".aligned-translation",{edges:{left:!0,right:!0,bottom:!1,top:!1},restrictSize:{min:{width:200}},restrictEdges:{outer:this.doc.body,endOnly:!0},inertia:!0},e=>{e.target.style.width=`${e.rect.width}px`});return this}openToolbar(){this.ui.openToolbar()}openActionPanel(){this.ui.platform.isMobile&&this.ui.closePanel(),this.ui.openActionPanel()}closeActionPanel(){this.ui.closeActionPanel()}openActionPanelLookup(){this.ui.platform.isMobile&&this.ui.closePanel(),this.ui.openActionPanel({showNav:!1})}openActionPanelToolbar(){this.ui.platform.isMobile&&this.ui.closePanel(),this.ui.openActionPanel({showLookup:!1})}}}]); \ No newline at end of file diff --git a/package.json b/package.json index 45de59d..055c9bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "alpheios-embedded", - "version": "3.0.0", + "version": "3.0.0-rc.2", "build": "39", "description": "Alpheios Embedded Library", "main": "dist/alpheios-embedded.js",