diff --git a/dist/alpheios-embedded.js b/dist/alpheios-embedded.js index 19e1c24..d404b86 100644 --- a/dist/alpheios-embedded.js +++ b/dist/alpheios-embedded.js @@ -408,7 +408,7 @@ class Embedded { textQuerySelector: this.enabledSelector, triggerPreCallback: this.triggerPreCallback, enableMouseMoveOverride: this.enableMouseMoveOverride, - app: { version:`${packageVersion}`, buildBranch: "incr-3.4.x", buildNumber: "20211126119", buildName: "incr-3.4.x.20211126119", name: packageDescription }, + app: { version:`${packageVersion}`, buildBranch: "ext-323-embed-ext", buildNumber: "20211126428", buildName: "ext-323-embed-ext.20211126428", name: packageDescription }, appType: components.Platform.appTypes.EMBEDDED_LIBRARY, clientId: this.clientId, // Disable text selection on mobile devices @@ -485,6 +485,7 @@ class Embedded { }) } } + this.notifyExtension() } // TODO: Is it used by any external code? @@ -505,7 +506,6 @@ class Embedded { * than the extension will have no information about * the embedded library presence unless explicitly notified by us. */ - this.notifyExtension() // await this.app.init() // Activate will call `init()` if has not been initialized previously await this.app.activate() diff --git a/dist/alpheios-embedded.js.map b/dist/alpheios-embedded.js.map index acef91b..52328d8 100644 --- a/dist/alpheios-embedded.js.map +++ b/dist/alpheios-embedded.js.map @@ -1 +1 @@ -{"version":3,"file":"alpheios-embedded.js","mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA,cAAc,aAAa;AAC3B;AACe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,UAAU;AACvB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;UClJA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;;ACNA;AACA;AAC2B;AACM;AACjC,QAAQ,2DAA2D,EAAE,0CAAG;AACxE;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,iDAAiD;AAC5D;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,YAAY,SAAS;AACrB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL,GAAG;AACH;;AAEA;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC;AACA,sCAAsC;AACtC;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,aAAa;AACjD;AACA,wBAAwB;AACxB,0BAA0B;AAC1B,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,MAAM,IAAI;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,8CAAK;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,+CAA+C,wDAAwD;;AAEvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,WAAW,eAAe,gBAAgB,YAAY,eAAe,aAAY,aAAa,wBAAU,4BAA4B;AACjJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,yDAAyD,gDAAgD;AACzG,QAAQ;AACR,yDAAyD,oDAAoD;AAC7G;AACA,MAAM;AACN,uDAAuD,YAAY;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,8DAA8D,oCAAoC;AAClG,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,2EAA2E,6BAA6B;;AAExG;AACA;;AAEA,MAAM;AACN,6DAA6D,MAAM;AACnE;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oGAAoG,WAAW;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAiE;AACjE;AACA;AACA;AACA;AACA,iBAAiB,oDAAoD;;AAErE;AACA;AACA,iBAAiB;AACjB,SAAS;;AAET;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA,gCAAgC,iBAAiB;AACjD,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,gBAAgB;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,mBAAmB;AACzD;AACA","sources":["webpack://AlpheiosEmbed/./state.js","webpack://AlpheiosEmbed/webpack/bootstrap","webpack://AlpheiosEmbed/webpack/runtime/define property getters","webpack://AlpheiosEmbed/webpack/runtime/hasOwnProperty shorthand","webpack://AlpheiosEmbed/webpack/runtime/make namespace object","webpack://AlpheiosEmbed/./embedded.js"],"sourcesContent":["/**\n * Contains Alpheios state\n * @property {panelStatus} panelStatus\n */\nexport default class State {\n constructor (tabID) {\n this.panelStatus = undefined\n this.tab = undefined\n this.watchers = new Map()\n }\n\n static create (source) {\n let copy = new State()\n for (let key of Object.keys(source)) {\n copy[key] = source[key]\n }\n return copy\n }\n\n static get defaults () {\n return {\n panelStatus: State.statuses.panel.OPEN\n }\n }\n\n static get statuses () {\n return {\n embedLib: {\n PENDING: Symbol.for('Alpheios_Status_Pending'), // Has not been fully initialized yet\n ACTIVE: Symbol.for('Alpheios_Status_Active'), // Is loaded and active\n DEACTIVATED: Symbol.for('Alpheios_Status_Deactivated'), // Has been loaded, but is deactivated\n DISABLED: Symbol.for('Alpheios_Status_Disabled') // Has been loaded, but it is disabled\n },\n panel: {\n OPEN: Symbol.for('Alpheios_Status_PanelOpen'), // Panel is open\n CLOSED: Symbol.for('Alpheios_Status_PanelClosed'), // Panel is closed\n DEFAULT: Symbol.for('Alpheios_Status_PanelDefault') // Panel should set its state according to default values\n },\n tab: {\n DEFAULT: 'default' // A tab should be set according to default values\n }\n }\n }\n\n /**\n * Sets a watcher function that is called every time a property is changed using a setItem() method.\n * @param {String} property - A name of a property that should be monitored\n * @param {Function} watchFunc - A function that will be called every time a property changes\n * @return {State} Reference to self for chaining\n */\n setWatcher (property, watchFunc) {\n this.watchers.set(property, watchFunc)\n return this\n }\n\n /**\n * SetItem provides a monitored way to change state. If value is assigned to a data property directly\n * there is no way to know if a property was changed. However, if a property was changed using setItem() method,\n * and if there is a watcher function registered for a changed property name,\n * this function will be called on every property change, passing a changed property name as an argument.\n * @param key\n * @param value\n * @return {State}\n */\n setItem (key, value) {\n this[key] = value\n if (this.watchers && this.watchers.has(key)) {\n this.watchers.get(key)(key, this)\n }\n return this\n }\n\n isPanelOpen () {\n return this.panelStatus === State.statuses.panel.OPEN\n }\n\n isPanelClosed () {\n return this.panelStatus === State.statuses.panel.CLOSED\n }\n\n isPanelStateDefault () {\n return this.panelStatus === State.statuses.panel.DEFAULT\n }\n\n isPanelStateValid () {\n return (\n this.panelStatus === State.statuses.panel.OPEN ||\n this.panelStatus === State.statuses.panel.CLOSED\n )\n }\n\n setPanelOpen () {\n this.setItem('panelStatus', State.statuses.panel.OPEN)\n return this\n }\n\n setPanelClosed () {\n this.setItem('panelStatus', State.statuses.panel.CLOSED)\n return this\n }\n\n changeTab (tabName) {\n this.setItem('tab', tabName)\n return this\n }\n\n activateUI () {\n this.setItem('uiActive', true)\n return this\n }\n\n // TODO: A temporary solution for compatibility with TabScript.\n isActive () {\n return this.status === State.statuses.embedLib.ACTIVE\n }\n\n isDeactivated () {\n return this.status === State.statuses.embedLib.DEACTIVATED\n }\n\n isDisabled () {\n return this.status === State.statuses.embedLib.DISABLED\n }\n\n isTabStateDefault () {\n return this.tab === State.statuses.tab.DEFAULT\n }\n\n uiIsActive () {\n return this.uiActive\n }\n\n activate () {\n this.status = State.statuses.embedLib.ACTIVE\n return this\n }\n\n deactivate () {\n this.status = State.statuses.embedLib.DEACTIVATED\n return this\n }\n\n disable () {\n this.status = State.statuses.embedLib.DISABLED\n return this\n }\n}\n","// 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};","/* eslint-env jest */\n/* global Event, BUILD_BRANCH, BUILD_NUMBER, BUILD_NAME */\nimport State from './state'\nimport pkg from '../package.json'\nconst { version: packageVersion, description: packageDescription } = pkg\n// A variable that will store an instance of the imported components module\nlet components\n\n/**\n * Imports dynamic dependencies that are required for the embed-lib.\n * @param {object} options - A configuration object of the import function.\n * @param {'production' | 'development' | 'cdn' | 'custom'} options.mode - What type of libraries shall be imported.\n * 'production' - will load minified version of libraries from a `dist/lib` local directory;\n * 'development' - will load non-optimized libraries with source maps from a `dist/lib` local directory;\n * 'cdn' - will load the latest version of minified libraries from JSDelivr (this is a default value);\n * 'custom' - allows to specify your own paths for loading the libraries. The paths shall be specified\n * as values of keys of a `libs` object.\n * @param {object} options.libs - An object whose properties specify paths from where libraries to be loaded.\n * {string} options.libs.components - A path to a components library. Value for a default `production` mode\n * is `./lib/alpheios-components.min.js`.\n * @return {Promise} - A promise that is resolved when all dependencies are loaded\n * or rejected when there was an error during an import.\n */\nexport function importDependencies (options) {\n let libs = {}\n switch (options.mode) {\n case 'production':\n libs.components = './lib/alpheios-components.min.js'\n break\n case 'development':\n libs.components = './lib/alpheios-components.js'\n break\n case 'custom':\n libs = options.libs\n break\n case 'cdn':\n default:\n libs.components = 'https://cdn.jsdelivr.net/npm/alpheios-components@latest/dist/alpheios-components.min.js'\n break\n }\n return new Promise((resolve, reject) => {\n let imports = []\n let componentsImport = import(\n /* webpackIgnore: true */\n libs.components\n ).then(() => {\n components = window.AlpheiosComponents\n })\n imports.push(componentsImport)\n\n Promise.all(imports).then(() => {\n resolve (Embedded)\n }).catch((e) => {\n reject(e)\n })\n })\n}\n\n/**\n * Encapsulation of Alpheios functionality which can be embedded in a webpage\n */\nexport class Embedded {\n /**\n * @constructor\n * @param {Object} arguments - object with the following properties:\n * clientId: a string identifying the embedding client or site. Required.\n * authEnv: authentication environment object.(Optional)\n * documentObject: the parent document. Default: window.document\n * enabledSelector: a CSS Selector string identifying the page elements for which Alpheios should be activated\n * Default: \".alpheios-enabled\"\n * disabledSelector: a CSS Selector string identifying the page elements for which Alpheios should be deactivated\n * Default: [data-alpheios-ignore=\"all\"]\n * enabledClass: a CSS class to apply to alpheios/staten enabled elements\n * Default: \"\"\n * disabledClass: a CSS class to apply to alpheios disabled elements\n * Default: \"\"\n * mobileTriggerEvent: DOM Event to trigger word selection on mobile devices\n * Default: longTap\n * desktopTriggerEvent: DOM Event to trigger word selection on desktops\n * Default: \"dblclick\"\n * triggerPreCallback: a callback function which is called when the trigger event handler is invoked, prior to initiating\n * Alpheios functionality. It should return true to proceed with lookup or false to abort.\n * Default: no-op, returns true\n * enableMouseMoveOverride: override the desktop trigger with a mousemove handler\n * popupInitialPos: object containing initial css positioning properties for the popup\n * Default { top: 10vh, left: 10vw}\n * toolbarInitialPos: object containing initial css positioning properties for the toolbar\n * Default { top: 10px, right: 15px}\n * actionPanelInitialPos: object containing initial css positioning properties for the action panel (mobile)\n * Default { bottom: 120px, right: 20px}\n * layoutType: 'default' or 'readingTools' (readingTools is used for the Alpheios Reader UI)\n * Default: 'default'\n * disableTextSelection: set to true to disable default browser text selection behavior (not recommended)\n * Default: false\n * textLangCode: default language for lookups via the toolbar\n * Default: null (which will result in the user preferred page language being used)\n * overrideHelp: set to true to disable the default alpheios behavior for the help icon\n * (client code must attach their own handler to the \".alpheios-toolbar__help-control\" element)\n * Default: false\n * simpleMode: set to true to restrict the UI to the popup/morphology panel (with grammar links) and lookup but no other features\n * Default: false\n * arethusaTbRefreshRetryCount: number of times to retry retrieval of treebank data before disabling the\n * functionality for the treebank document\n * Default: 5\n * arethusaTbRefreshDelay: number of milliseconds to wait in between retrying treebank document requests\n * Default: 200,\n */\n constructor ({\n clientId = null,\n authEnv = null,\n documentObject = document,\n enabledSelector = '.alpheios-enabled',\n disabledSelector = '',\n enabledClass = '',\n disabledClass = '',\n mobileTriggerEvent = null,\n desktopTriggerEvent = null,\n triggerPreCallback = (evt) => { return true }, // Not used at the moment but can be set as a filter for `this.app.getSelectedText()` calls\n enableMouseMoveOverride = false,\n popupInitialPos = {},\n toolbarInitialPos = {},\n actionPanelInitialPos = {},\n layoutType = 'default', // The other option is 'readingTools'\n // Disable text selection on mobile devices\n disableTextSelection = false,\n textLangCode = null,\n overrideHelp = false,\n simpleMode = false,\n arethusaTbRefreshRetryCount = 5,\n arethusaTbRefreshDelay = 200,\n languageOptions = {},\n uiOptions = {}\n } = {}) {\n this.clientId = clientId\n\n if (this.clientId === null) {\n throw new Error('Please identify the site.')\n }\n // TODO at some point in the future we may add authentication of\n // clientId\n this.doc = documentObject\n this.authEnv = authEnv\n this.state = new State()\n this.enabledSelector = enabledSelector\n this.disabledSelector = disabledSelector\n this.enabledClass = enabledClass\n this.disabledClass = disabledClass\n this.desktopTriggerEvent = desktopTriggerEvent\n this.mobileTriggerEvent = mobileTriggerEvent\n this.triggerPreCallback = triggerPreCallback\n this.enableMouseMoveOverride = enableMouseMoveOverride\n this.simpleMode = simpleMode\n\n // Set an initial UI Controller state for activation\n this.state.setPanelClosed() // A default state of the panel is CLOSED\n this.state.tab = 'info' // A default tab is \"info\"\n\n this._platform = new components.Platform({ appType: components.Platform.appTypes.EMBEDDED_LIBRARY })\n\n this.app = components.AppController.create(this.state, {\n storageAdapter: components.LocalStorageArea,\n textQueryTriggerDesktop: this.desktopTriggerEvent,\n textQueryTriggerMobile: this.mobileTriggerEvent,\n textQuerySelector: this.enabledSelector,\n triggerPreCallback: this.triggerPreCallback,\n enableMouseMoveOverride: this.enableMouseMoveOverride,\n app: { version:`${packageVersion}`, buildBranch: BUILD_BRANCH, buildNumber: BUILD_NUMBER, buildName: BUILD_NAME, name: packageDescription },\n appType: components.Platform.appTypes.EMBEDDED_LIBRARY,\n clientId: this.clientId,\n // Disable text selection on mobile devices\n disableTextSelection: disableTextSelection,\n textLangCode: textLangCode,\n overrideHelp: overrideHelp,\n configServiceUrl: 'https://config.alpheios.net/v1/config',\n arethusaTbRefreshRetryCount: arethusaTbRefreshRetryCount,\n arethusaTbRefreshDelay: arethusaTbRefreshDelay,\n languageOptions,\n uiOptions\n })\n // Environment-specific initializations\n if (this.authEnv) {\n if (authEnv.CLIENT_ID) {\n // Register an authentication module only with authentication environment is loaded\n this.app.registerModule(components.AuthModule, { auth: new components.AppAuthenticator(authEnv) })\n } else if (authEnv.LOGIN_URL) {\n this.app.registerModule(components.AuthModule, { auth: new components.SessionAuthenticator(authEnv) })\n }\n } else {\n this.app.registerModule(components.AuthModule, { auth: null })\n }\n // Register UI modules\n let panelParams = {}\n if (this.simpleMode) {\n panelParams.showNav = false\n }\n this.app.registerModule(components.PanelModule, panelParams)\n\n let popupParams = {}\n if (popupInitialPos && Object.values(popupInitialPos).filter(value => Boolean(value)).length > 0) {\n popupParams.initialPos = popupInitialPos\n }\n if (this.simpleMode) {\n popupParams.showNav = false\n }\n this.app.registerModule(components.PopupModule, popupParams)\n\n let actionPanelParams = {}\n if (actionPanelInitialPos && Object.values(actionPanelInitialPos).filter(value => Boolean(value)).length > 0) {\n actionPanelParams.initialPos = actionPanelInitialPos\n }\n if (this.simpleMode) {\n actionPanelParams.showNav = false\n } else {\n actionPanelParams.showNav = true\n }\n\n let toolbarParams = {}\n if (this.simpleMode) {\n toolbarParams.showNav = false\n }\n if (layoutType === 'default') {\n if (toolbarInitialPos && Object.values(toolbarInitialPos).filter(value => Boolean(value)).length > 0) {\n toolbarParams.initialPos = toolbarInitialPos\n }\n\n this.app.registerModule(components.ToolbarModule, toolbarParams)\n this.app.registerModule(components.ActionPanelModule, { showNav: actionPanelParams.showNav })\n } else if (layoutType === 'readingTools') {\n // This is a special configuration for Alpheios Reading Tools\n if (this._platform.isDesktop) {\n if (toolbarInitialPos && Object.values(toolbarInitialPos).filter(value => Boolean(value)).length > 0) {\n toolbarParams.initialPos = toolbarInitialPos\n }\n\n this.app.registerModule(components.ToolbarModule, toolbarParams)\n } else if (this._platform.isMobile) {\n this.app.registerModule(components.ActionPanelModule, {\n lookupResultsIn: 'panel',\n initialPos: actionPanelParams.initialPos,\n showNav: actionPanelParams.showNav\n })\n }\n }\n }\n\n // TODO: Is it used by any external code?\n get platform () {\n return this._platform\n }\n\n notifyExtension () {\n this.doc.body.dispatchEvent(new Event('Alpheios_Embedded_Response'))\n }\n\n async activate () {\n try {\n /**\n * Notify extension that an embedded lib is present.\n * We need to do this right after an activation.\n * If webextension is loaded sooner than the embedded library\n * than the extension will have no information about\n * the embedded library presence unless explicitly notified by us.\n */\n this.notifyExtension()\n\n // await this.app.init() // Activate will call `init()` if has not been initialized previously\n await this.app.activate()\n\n // Set a body attribute so the content scrip will know if embedded library is active on a page\n this.doc.body.setAttribute('alpheios-embed-lib-status', 'active')\n this.doc.body.addEventListener('Alpheios_Embedded_Check', event => { this.notifyExtension(event) })\n\n // and set the state on the components\n this.app.setEmbedLibActive(true)\n\n } catch (error) {\n console.error(`Unexpected error activating Alpheios: ${error}`)\n return\n }\n\n let selector = this.enabledSelector\n\n if (!selector) {\n throw new Error('Configuration must define selector')\n }\n let activateOn = this.doc.querySelectorAll(selector)\n if (activateOn.length === 0) {\n // it could be that we want to activate Alpheios for lookups via the\n // tools even if there isn't any text on the page to activate to on\n // so just print a warning here.\n console.warn(`Alpheios was activated for the page but not any content (no elements matching ${activateOn}).`)\n }\n if (this.enabledClass) {\n for (let elem of activateOn) {\n elem.classList.add(this.enabledClass)\n }\n }\n if (this.disabledSelector) {\n let disableOn = this.doc.querySelectorAll(this.disabledSelector)\n for (let elem of disableOn) {\n elem.setAttribute('data-alpheios-ignore', 'all')\n if (this.disabledClass) {\n elem.classList.add(this.disabledClass)\n }\n }\n }\n\n let alignment = new components.AlignmentSelector(this.doc, {})\n alignment.activate()\n let alignmentTranslation = components.AppController.initAlignedTranslation(this.doc, '.aligned-translation',\n {\n // resize from all edges and corners\n edges: { left: true, right: true, bottom: false, top: false },\n\n // minimum size\n restrictSize: {\n min: { width: 200 }\n },\n\n // keep the edges inside the parent\n restrictEdges: {\n outer: this.doc.body,\n endOnly: true\n },\n inertia: true\n },\n event => {\n let target = event.target\n // update the element's style\n target.style.width = `${event.rect.width}px`\n })\n return this\n }\n\n openToolbar () {\n this.app.api.ui.openToolbar()\n }\n\n openActionPanel () {\n if (this._platform.isMobile) {\n this.app.api.ui.closePanel()\n }\n this.app.api.ui.openActionPanel()\n }\n\n closeActionPanel () {\n this.app.api.ui.closeActionPanel()\n }\n\n /**\n * Opens the action panel with toolbar buttons hidden and only the lookup visible.\n */\n openActionPanelLookup () {\n if (this._platform.isMobile) {\n this.app.api.ui.closePanel()\n }\n this.app.api.ui.openActionPanel({ showNav: false })\n }\n\n /**\n * Opens the action panel with only toolbar buttons visible.\n */\n openActionPanelToolbar () {\n if (this._platform.isMobile) {\n this.app.api.ui.closePanel()\n }\n this.app.api.ui.openActionPanel({ showLookup: false })\n }\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"alpheios-embedded.js","mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA,cAAc,aAAa;AAC3B;AACe;AACf;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA,OAAO;AACP;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA,aAAa,QAAQ;AACrB,aAAa,UAAU;AACvB,cAAc,OAAO;AACrB;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAc;AACd;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;UClJA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;;ACNA;AACA;AAC2B;AACM;AACjC,QAAQ,2DAA2D,EAAE,0CAAG;AACxE;AACA;;AAEA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,iDAAiD;AAC5D;AACA;AACA;AACA;AACA;AACA,WAAW,QAAQ;AACnB,WAAW,QAAQ;AACnB;AACA,YAAY,SAAS;AACrB;AACA;AACO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA,KAAK;AACL;AACA,KAAK;AACL,GAAG;AACH;;AAEA;AACA;AACA;AACO;AACP;AACA;AACA,aAAa,QAAQ;AACrB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC;AACpC;AACA,sCAAsC;AACtC;AACA,0CAA0C;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oCAAoC,aAAa;AACjD;AACA,wBAAwB;AACxB,0BAA0B;AAC1B,8BAA8B;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,wBAAwB;AACxB;AACA,MAAM,IAAI;AACV;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,qBAAqB,8CAAK;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA,+CAA+C,wDAAwD;;AAEvG;AACA;AACA;AACA;AACA;AACA;AACA;AACA,aAAa,WAAW,eAAe,gBAAgB,mBAAY,eAAe,aAAY,aAAa,+BAAU,4BAA4B;AACjJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA,yDAAyD,gDAAgD;AACzG,QAAQ;AACR,yDAAyD,oDAAoD;AAC7G;AACA,MAAM;AACN,uDAAuD,YAAY;AACnE;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAM;AACN;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,8DAA8D,oCAAoC;AAClG,MAAM;AACN;AACA;AACA;AACA;AACA;;AAEA;AACA,QAAQ;AACR;AACA;AACA;AACA;AACA,SAAS;AACT;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA,2EAA2E,6BAA6B;;AAExG;AACA;;AAEA,MAAM;AACN,6DAA6D,MAAM;AACnE;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,oGAAoG,WAAW;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,iEAAiE;AACjE;AACA;AACA;AACA;AACA,iBAAiB,oDAAoD;;AAErE;AACA;AACA,iBAAiB;AACjB,SAAS;;AAET;AACA;AACA;AACA;AACA,SAAS;AACT;AACA,OAAO;AACP;AACA;AACA;AACA,gCAAgC,iBAAiB;AACjD,OAAO;AACP;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,gBAAgB;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sCAAsC,mBAAmB;AACzD;AACA","sources":["webpack://AlpheiosEmbed/./state.js","webpack://AlpheiosEmbed/webpack/bootstrap","webpack://AlpheiosEmbed/webpack/runtime/define property getters","webpack://AlpheiosEmbed/webpack/runtime/hasOwnProperty shorthand","webpack://AlpheiosEmbed/webpack/runtime/make namespace object","webpack://AlpheiosEmbed/./embedded.js"],"sourcesContent":["/**\n * Contains Alpheios state\n * @property {panelStatus} panelStatus\n */\nexport default class State {\n constructor (tabID) {\n this.panelStatus = undefined\n this.tab = undefined\n this.watchers = new Map()\n }\n\n static create (source) {\n let copy = new State()\n for (let key of Object.keys(source)) {\n copy[key] = source[key]\n }\n return copy\n }\n\n static get defaults () {\n return {\n panelStatus: State.statuses.panel.OPEN\n }\n }\n\n static get statuses () {\n return {\n embedLib: {\n PENDING: Symbol.for('Alpheios_Status_Pending'), // Has not been fully initialized yet\n ACTIVE: Symbol.for('Alpheios_Status_Active'), // Is loaded and active\n DEACTIVATED: Symbol.for('Alpheios_Status_Deactivated'), // Has been loaded, but is deactivated\n DISABLED: Symbol.for('Alpheios_Status_Disabled') // Has been loaded, but it is disabled\n },\n panel: {\n OPEN: Symbol.for('Alpheios_Status_PanelOpen'), // Panel is open\n CLOSED: Symbol.for('Alpheios_Status_PanelClosed'), // Panel is closed\n DEFAULT: Symbol.for('Alpheios_Status_PanelDefault') // Panel should set its state according to default values\n },\n tab: {\n DEFAULT: 'default' // A tab should be set according to default values\n }\n }\n }\n\n /**\n * Sets a watcher function that is called every time a property is changed using a setItem() method.\n * @param {String} property - A name of a property that should be monitored\n * @param {Function} watchFunc - A function that will be called every time a property changes\n * @return {State} Reference to self for chaining\n */\n setWatcher (property, watchFunc) {\n this.watchers.set(property, watchFunc)\n return this\n }\n\n /**\n * SetItem provides a monitored way to change state. If value is assigned to a data property directly\n * there is no way to know if a property was changed. However, if a property was changed using setItem() method,\n * and if there is a watcher function registered for a changed property name,\n * this function will be called on every property change, passing a changed property name as an argument.\n * @param key\n * @param value\n * @return {State}\n */\n setItem (key, value) {\n this[key] = value\n if (this.watchers && this.watchers.has(key)) {\n this.watchers.get(key)(key, this)\n }\n return this\n }\n\n isPanelOpen () {\n return this.panelStatus === State.statuses.panel.OPEN\n }\n\n isPanelClosed () {\n return this.panelStatus === State.statuses.panel.CLOSED\n }\n\n isPanelStateDefault () {\n return this.panelStatus === State.statuses.panel.DEFAULT\n }\n\n isPanelStateValid () {\n return (\n this.panelStatus === State.statuses.panel.OPEN ||\n this.panelStatus === State.statuses.panel.CLOSED\n )\n }\n\n setPanelOpen () {\n this.setItem('panelStatus', State.statuses.panel.OPEN)\n return this\n }\n\n setPanelClosed () {\n this.setItem('panelStatus', State.statuses.panel.CLOSED)\n return this\n }\n\n changeTab (tabName) {\n this.setItem('tab', tabName)\n return this\n }\n\n activateUI () {\n this.setItem('uiActive', true)\n return this\n }\n\n // TODO: A temporary solution for compatibility with TabScript.\n isActive () {\n return this.status === State.statuses.embedLib.ACTIVE\n }\n\n isDeactivated () {\n return this.status === State.statuses.embedLib.DEACTIVATED\n }\n\n isDisabled () {\n return this.status === State.statuses.embedLib.DISABLED\n }\n\n isTabStateDefault () {\n return this.tab === State.statuses.tab.DEFAULT\n }\n\n uiIsActive () {\n return this.uiActive\n }\n\n activate () {\n this.status = State.statuses.embedLib.ACTIVE\n return this\n }\n\n deactivate () {\n this.status = State.statuses.embedLib.DEACTIVATED\n return this\n }\n\n disable () {\n this.status = State.statuses.embedLib.DISABLED\n return this\n }\n}\n","// 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};","/* eslint-env jest */\n/* global Event, BUILD_BRANCH, BUILD_NUMBER, BUILD_NAME */\nimport State from './state'\nimport pkg from '../package.json'\nconst { version: packageVersion, description: packageDescription } = pkg\n// A variable that will store an instance of the imported components module\nlet components\n\n/**\n * Imports dynamic dependencies that are required for the embed-lib.\n * @param {object} options - A configuration object of the import function.\n * @param {'production' | 'development' | 'cdn' | 'custom'} options.mode - What type of libraries shall be imported.\n * 'production' - will load minified version of libraries from a `dist/lib` local directory;\n * 'development' - will load non-optimized libraries with source maps from a `dist/lib` local directory;\n * 'cdn' - will load the latest version of minified libraries from JSDelivr (this is a default value);\n * 'custom' - allows to specify your own paths for loading the libraries. The paths shall be specified\n * as values of keys of a `libs` object.\n * @param {object} options.libs - An object whose properties specify paths from where libraries to be loaded.\n * {string} options.libs.components - A path to a components library. Value for a default `production` mode\n * is `./lib/alpheios-components.min.js`.\n * @return {Promise} - A promise that is resolved when all dependencies are loaded\n * or rejected when there was an error during an import.\n */\nexport function importDependencies (options) {\n let libs = {}\n switch (options.mode) {\n case 'production':\n libs.components = './lib/alpheios-components.min.js'\n break\n case 'development':\n libs.components = './lib/alpheios-components.js'\n break\n case 'custom':\n libs = options.libs\n break\n case 'cdn':\n default:\n libs.components = 'https://cdn.jsdelivr.net/npm/alpheios-components@latest/dist/alpheios-components.min.js'\n break\n }\n return new Promise((resolve, reject) => {\n let imports = []\n let componentsImport = import(\n /* webpackIgnore: true */\n libs.components\n ).then(() => {\n components = window.AlpheiosComponents\n })\n imports.push(componentsImport)\n\n Promise.all(imports).then(() => {\n resolve (Embedded)\n }).catch((e) => {\n reject(e)\n })\n })\n}\n\n/**\n * Encapsulation of Alpheios functionality which can be embedded in a webpage\n */\nexport class Embedded {\n /**\n * @constructor\n * @param {Object} arguments - object with the following properties:\n * clientId: a string identifying the embedding client or site. Required.\n * authEnv: authentication environment object.(Optional)\n * documentObject: the parent document. Default: window.document\n * enabledSelector: a CSS Selector string identifying the page elements for which Alpheios should be activated\n * Default: \".alpheios-enabled\"\n * disabledSelector: a CSS Selector string identifying the page elements for which Alpheios should be deactivated\n * Default: [data-alpheios-ignore=\"all\"]\n * enabledClass: a CSS class to apply to alpheios/staten enabled elements\n * Default: \"\"\n * disabledClass: a CSS class to apply to alpheios disabled elements\n * Default: \"\"\n * mobileTriggerEvent: DOM Event to trigger word selection on mobile devices\n * Default: longTap\n * desktopTriggerEvent: DOM Event to trigger word selection on desktops\n * Default: \"dblclick\"\n * triggerPreCallback: a callback function which is called when the trigger event handler is invoked, prior to initiating\n * Alpheios functionality. It should return true to proceed with lookup or false to abort.\n * Default: no-op, returns true\n * enableMouseMoveOverride: override the desktop trigger with a mousemove handler\n * popupInitialPos: object containing initial css positioning properties for the popup\n * Default { top: 10vh, left: 10vw}\n * toolbarInitialPos: object containing initial css positioning properties for the toolbar\n * Default { top: 10px, right: 15px}\n * actionPanelInitialPos: object containing initial css positioning properties for the action panel (mobile)\n * Default { bottom: 120px, right: 20px}\n * layoutType: 'default' or 'readingTools' (readingTools is used for the Alpheios Reader UI)\n * Default: 'default'\n * disableTextSelection: set to true to disable default browser text selection behavior (not recommended)\n * Default: false\n * textLangCode: default language for lookups via the toolbar\n * Default: null (which will result in the user preferred page language being used)\n * overrideHelp: set to true to disable the default alpheios behavior for the help icon\n * (client code must attach their own handler to the \".alpheios-toolbar__help-control\" element)\n * Default: false\n * simpleMode: set to true to restrict the UI to the popup/morphology panel (with grammar links) and lookup but no other features\n * Default: false\n * arethusaTbRefreshRetryCount: number of times to retry retrieval of treebank data before disabling the\n * functionality for the treebank document\n * Default: 5\n * arethusaTbRefreshDelay: number of milliseconds to wait in between retrying treebank document requests\n * Default: 200,\n */\n constructor ({\n clientId = null,\n authEnv = null,\n documentObject = document,\n enabledSelector = '.alpheios-enabled',\n disabledSelector = '',\n enabledClass = '',\n disabledClass = '',\n mobileTriggerEvent = null,\n desktopTriggerEvent = null,\n triggerPreCallback = (evt) => { return true }, // Not used at the moment but can be set as a filter for `this.app.getSelectedText()` calls\n enableMouseMoveOverride = false,\n popupInitialPos = {},\n toolbarInitialPos = {},\n actionPanelInitialPos = {},\n layoutType = 'default', // The other option is 'readingTools'\n // Disable text selection on mobile devices\n disableTextSelection = false,\n textLangCode = null,\n overrideHelp = false,\n simpleMode = false,\n arethusaTbRefreshRetryCount = 5,\n arethusaTbRefreshDelay = 200,\n languageOptions = {},\n uiOptions = {}\n } = {}) {\n this.clientId = clientId\n\n if (this.clientId === null) {\n throw new Error('Please identify the site.')\n }\n // TODO at some point in the future we may add authentication of\n // clientId\n this.doc = documentObject\n this.authEnv = authEnv\n this.state = new State()\n this.enabledSelector = enabledSelector\n this.disabledSelector = disabledSelector\n this.enabledClass = enabledClass\n this.disabledClass = disabledClass\n this.desktopTriggerEvent = desktopTriggerEvent\n this.mobileTriggerEvent = mobileTriggerEvent\n this.triggerPreCallback = triggerPreCallback\n this.enableMouseMoveOverride = enableMouseMoveOverride\n this.simpleMode = simpleMode\n\n // Set an initial UI Controller state for activation\n this.state.setPanelClosed() // A default state of the panel is CLOSED\n this.state.tab = 'info' // A default tab is \"info\"\n\n this._platform = new components.Platform({ appType: components.Platform.appTypes.EMBEDDED_LIBRARY })\n\n this.app = components.AppController.create(this.state, {\n storageAdapter: components.LocalStorageArea,\n textQueryTriggerDesktop: this.desktopTriggerEvent,\n textQueryTriggerMobile: this.mobileTriggerEvent,\n textQuerySelector: this.enabledSelector,\n triggerPreCallback: this.triggerPreCallback,\n enableMouseMoveOverride: this.enableMouseMoveOverride,\n app: { version:`${packageVersion}`, buildBranch: BUILD_BRANCH, buildNumber: BUILD_NUMBER, buildName: BUILD_NAME, name: packageDescription },\n appType: components.Platform.appTypes.EMBEDDED_LIBRARY,\n clientId: this.clientId,\n // Disable text selection on mobile devices\n disableTextSelection: disableTextSelection,\n textLangCode: textLangCode,\n overrideHelp: overrideHelp,\n configServiceUrl: 'https://config.alpheios.net/v1/config',\n arethusaTbRefreshRetryCount: arethusaTbRefreshRetryCount,\n arethusaTbRefreshDelay: arethusaTbRefreshDelay,\n languageOptions,\n uiOptions\n })\n // Environment-specific initializations\n if (this.authEnv) {\n if (authEnv.CLIENT_ID) {\n // Register an authentication module only with authentication environment is loaded\n this.app.registerModule(components.AuthModule, { auth: new components.AppAuthenticator(authEnv) })\n } else if (authEnv.LOGIN_URL) {\n this.app.registerModule(components.AuthModule, { auth: new components.SessionAuthenticator(authEnv) })\n }\n } else {\n this.app.registerModule(components.AuthModule, { auth: null })\n }\n // Register UI modules\n let panelParams = {}\n if (this.simpleMode) {\n panelParams.showNav = false\n }\n this.app.registerModule(components.PanelModule, panelParams)\n\n let popupParams = {}\n if (popupInitialPos && Object.values(popupInitialPos).filter(value => Boolean(value)).length > 0) {\n popupParams.initialPos = popupInitialPos\n }\n if (this.simpleMode) {\n popupParams.showNav = false\n }\n this.app.registerModule(components.PopupModule, popupParams)\n\n let actionPanelParams = {}\n if (actionPanelInitialPos && Object.values(actionPanelInitialPos).filter(value => Boolean(value)).length > 0) {\n actionPanelParams.initialPos = actionPanelInitialPos\n }\n if (this.simpleMode) {\n actionPanelParams.showNav = false\n } else {\n actionPanelParams.showNav = true\n }\n\n let toolbarParams = {}\n if (this.simpleMode) {\n toolbarParams.showNav = false\n }\n if (layoutType === 'default') {\n if (toolbarInitialPos && Object.values(toolbarInitialPos).filter(value => Boolean(value)).length > 0) {\n toolbarParams.initialPos = toolbarInitialPos\n }\n\n this.app.registerModule(components.ToolbarModule, toolbarParams)\n this.app.registerModule(components.ActionPanelModule, { showNav: actionPanelParams.showNav })\n } else if (layoutType === 'readingTools') {\n // This is a special configuration for Alpheios Reading Tools\n if (this._platform.isDesktop) {\n if (toolbarInitialPos && Object.values(toolbarInitialPos).filter(value => Boolean(value)).length > 0) {\n toolbarParams.initialPos = toolbarInitialPos\n }\n\n this.app.registerModule(components.ToolbarModule, toolbarParams)\n } else if (this._platform.isMobile) {\n this.app.registerModule(components.ActionPanelModule, {\n lookupResultsIn: 'panel',\n initialPos: actionPanelParams.initialPos,\n showNav: actionPanelParams.showNav\n })\n }\n }\n this.notifyExtension()\n }\n\n // TODO: Is it used by any external code?\n get platform () {\n return this._platform\n }\n\n notifyExtension () {\n this.doc.body.dispatchEvent(new Event('Alpheios_Embedded_Response'))\n }\n\n async activate () {\n try {\n /**\n * Notify extension that an embedded lib is present.\n * We need to do this right after an activation.\n * If webextension is loaded sooner than the embedded library\n * than the extension will have no information about\n * the embedded library presence unless explicitly notified by us.\n */\n\n // await this.app.init() // Activate will call `init()` if has not been initialized previously\n await this.app.activate()\n\n // Set a body attribute so the content scrip will know if embedded library is active on a page\n this.doc.body.setAttribute('alpheios-embed-lib-status', 'active')\n this.doc.body.addEventListener('Alpheios_Embedded_Check', event => { this.notifyExtension(event) })\n\n // and set the state on the components\n this.app.setEmbedLibActive(true)\n\n } catch (error) {\n console.error(`Unexpected error activating Alpheios: ${error}`)\n return\n }\n\n let selector = this.enabledSelector\n\n if (!selector) {\n throw new Error('Configuration must define selector')\n }\n let activateOn = this.doc.querySelectorAll(selector)\n if (activateOn.length === 0) {\n // it could be that we want to activate Alpheios for lookups via the\n // tools even if there isn't any text on the page to activate to on\n // so just print a warning here.\n console.warn(`Alpheios was activated for the page but not any content (no elements matching ${activateOn}).`)\n }\n if (this.enabledClass) {\n for (let elem of activateOn) {\n elem.classList.add(this.enabledClass)\n }\n }\n if (this.disabledSelector) {\n let disableOn = this.doc.querySelectorAll(this.disabledSelector)\n for (let elem of disableOn) {\n elem.setAttribute('data-alpheios-ignore', 'all')\n if (this.disabledClass) {\n elem.classList.add(this.disabledClass)\n }\n }\n }\n\n let alignment = new components.AlignmentSelector(this.doc, {})\n alignment.activate()\n let alignmentTranslation = components.AppController.initAlignedTranslation(this.doc, '.aligned-translation',\n {\n // resize from all edges and corners\n edges: { left: true, right: true, bottom: false, top: false },\n\n // minimum size\n restrictSize: {\n min: { width: 200 }\n },\n\n // keep the edges inside the parent\n restrictEdges: {\n outer: this.doc.body,\n endOnly: true\n },\n inertia: true\n },\n event => {\n let target = event.target\n // update the element's style\n target.style.width = `${event.rect.width}px`\n })\n return this\n }\n\n openToolbar () {\n this.app.api.ui.openToolbar()\n }\n\n openActionPanel () {\n if (this._platform.isMobile) {\n this.app.api.ui.closePanel()\n }\n this.app.api.ui.openActionPanel()\n }\n\n closeActionPanel () {\n this.app.api.ui.closeActionPanel()\n }\n\n /**\n * Opens the action panel with toolbar buttons hidden and only the lookup visible.\n */\n openActionPanelLookup () {\n if (this._platform.isMobile) {\n this.app.api.ui.closePanel()\n }\n this.app.api.ui.openActionPanel({ showNav: false })\n }\n\n /**\n * Opens the action panel with only toolbar buttons visible.\n */\n openActionPanelToolbar () {\n if (this._platform.isMobile) {\n this.app.api.ui.closePanel()\n }\n this.app.api.ui.openActionPanel({ showLookup: false })\n }\n}\n"],"names":[],"sourceRoot":""} \ No newline at end of file diff --git a/dist/alpheios-embedded.min.js b/dist/alpheios-embedded.min.js index f56d31c..f43f088 100644 --- a/dist/alpheios-embedded.min.js +++ b/dist/alpheios-embedded.min.js @@ -1 +1 @@ -(()=>{"use strict";var __webpack_modules___833=(e,t,s)=>{s.r(t),s.d(t,{Embedded:()=>Embedded,importDependencies:()=>importDependencies});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}}const i=JSON.parse('{"name":"alpheios-embedded","version":"3.4.1-incr-3.4.x.20211126119","description":"Alpheios Embedded Library","main":"dist/alpheios-embedded.js","directories":{"doc":"doc"},"scripts":{"set-node-build-deps":"npx install-peerdeps alpheios-node-build --dev --only-peers","test":"jest","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 -m all -M production -p app -c config.mjs","build-dev":"npm run lint && node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs -m all -M development -p app -c 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-core/packages/components/dist/ --t=dist/lib && node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=./node_modules/alpheios-core/packages/components/dist/style --t=dist/style","build-experimental":"node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs -m webpack -M development -p app -c config.mjs","dev":"npm run build-experimental && http-server -c-1 -p 8888 & onchange src -- npm run build-experimental","conventional-commit":"npx git-cz","version-set-major":"npm version major","version-set-minor":"npm version minor","version-set-patch":"npm version patch","tagged-commit":"node --experimental-modules --experimental-json-modules ./tagged-commit.mjs","github-build":"node --experimental-modules --experimental-json-modules ./github-build.mjs"},"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":{"@actions/core":"^1.6.0","@babel/core":"^7.16.0","@babel/plugin-proposal-object-rest-spread":"^7.16.0","@babel/plugin-transform-modules-commonjs":"^7.16.0","@babel/plugin-transform-runtime":"^7.16.4","@babel/preset-env":"^7.16.4","@babel/register":"^7.16.0","@babel/runtime":"^7.16.3","alpheios-core":"git+https://github.com/alpheios-project/alpheios-core.git#incr-3.4.x","alpheios-node-build":"github:alpheios-project/node-build#v4","archiver":"^4.0.2","babel-eslint":"^10.1.0","babel-loader":"^8.2.3","babel-plugin-dynamic-import-node":"^2.3.3","babel-plugin-module-resolver":"^4.1.0","chalk":"^4.1.2","command-line-args":"^5.2.0","copy-webpack-plugin":"^6.4.1","coveralls":"^3.1.1","css-loader":"^5.2.7","cz-conventional-changelog":"^3.3.0","eslint":"^7.32.0","eslint-config-standard":"^16.0.3","eslint-plugin-import":"^2.25.3","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.3.1","eslint-plugin-standard":"^4.1.0","eslint-plugin-vue":"^7.20.0","fibers":"^5.0.0","fs-extra":"^9.1.0","git-branch":"^2.0.1","http-server":"^0.12.3","imagemin":"^7.0.1","imagemin-jpegtran":"^7.0.0","imagemin-optipng":"^8.0.0","imagemin-svgo":"^8.0.0","inspectpack":"^4.7.1","interactjs":"^1.10.11","jest":"^26.6.3","jest-fetch-mock":"^3.0.3","mini-css-extract-plugin":"^1.6.2","onchange":"^7.1.0","optimize-css-assets-webpack-plugin":"^5.0.8","path":"^0.12.7","postcss-import":"^13.0.0","postcss-loader":"^4.3.0","postcss-safe-important":"^1.2.1","postcss-scss":"^3.0.5","raw-loader":"^4.0.2","sass":"^1.43.5","sass-loader":"^10.2.0","shx":"^0.3.3","source-map-loader":"^1.1.3","style-loader":"^2.0.0","url-loader":"^4.1.1","vue-loader":"^15.9.8","vue-style-loader":"^4.1.3","vue-svg-loader":"^0.16.0","vue-template-compiler":"^2.6.14","vue-template-loader":"^1.1.0","webpack":"^5.64.4","webpack-bundle-analyzer":"^4.5.0","webpack-cleanup-plugin":"^0.5.1","webpack-dev-server":"^3.11.3","webpack-merge":"^5.8.0"},"engines":{"node":">= 14.1.0","npm":">= 6.13.0"},"jest":{"verbose":true,"transform":{"^.+\\\\.jsx?$":"babel-jest"},"transformIgnorePatterns":["node_modules/alpheios-core/packages/components/"]},"eslintConfig":{"env":{"browser":true,"node":true},"parser":"babel-eslint","parserOptions":{"sourceType":"module","ecmaVersion":2019,"allowImportExportEverywhere":true}},"eslintIgnore":["**/dist"],"dependencies":{},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}}}'),{version:o,description:a}=i;let l;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;default:t.components="https://cdn.jsdelivr.net/npm/alpheios-components@latest/dist/alpheios-components.min.js"}return new Promise(((e,s)=>{let i=[],o=import(t.components).then((()=>{l=window.AlpheiosComponents}));i.push(o),Promise.all(i).then((()=>{e(Embedded)})).catch((e=>{s(e)}))}))}class Embedded{constructor({clientId:e=null,authEnv:t=null,documentObject:s=document,enabledSelector:i=".alpheios-enabled",disabledSelector:n="",enabledClass:r="",disabledClass:p="",mobileTriggerEvent:d=null,desktopTriggerEvent:u=null,triggerPreCallback:c=(e=>!0),enableMouseMoveOverride:h=!1,popupInitialPos:m={},toolbarInitialPos:b={},actionPanelInitialPos:g={},layoutType:v="default",disableTextSelection:f=!1,textLangCode:S=null,overrideHelp:A=!1,simpleMode:E=!1,arethusaTbRefreshRetryCount:y=5,arethusaTbRefreshDelay:P=200,languageOptions:w={},uiOptions:j={}}={}){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=i,this.disabledSelector=n,this.enabledClass=r,this.disabledClass=p,this.desktopTriggerEvent=u,this.mobileTriggerEvent=d,this.triggerPreCallback=c,this.enableMouseMoveOverride=h,this.simpleMode=E,this.state.setPanelClosed(),this.state.tab="info",this._platform=new l.Platform({appType:l.Platform.appTypes.EMBEDDED_LIBRARY}),this.app=l.AppController.create(this.state,{storageAdapter:l.LocalStorageArea,textQueryTriggerDesktop:this.desktopTriggerEvent,textQueryTriggerMobile:this.mobileTriggerEvent,textQuerySelector:this.enabledSelector,triggerPreCallback:this.triggerPreCallback,enableMouseMoveOverride:this.enableMouseMoveOverride,app:{version:`${o}`,buildBranch:"incr-3.4.x",buildNumber:"20211126119",buildName:"incr-3.4.x.20211126119",name:a},appType:l.Platform.appTypes.EMBEDDED_LIBRARY,clientId:this.clientId,disableTextSelection:f,textLangCode:S,overrideHelp:A,configServiceUrl:"https://config.alpheios.net/v1/config",arethusaTbRefreshRetryCount:y,arethusaTbRefreshDelay:P,languageOptions:w,uiOptions:j}),this.authEnv?t.CLIENT_ID?this.app.registerModule(l.AuthModule,{auth:new l.AppAuthenticator(t)}):t.LOGIN_URL&&this.app.registerModule(l.AuthModule,{auth:new l.SessionAuthenticator(t)}):this.app.registerModule(l.AuthModule,{auth:null});let T={};this.simpleMode&&(T.showNav=!1),this.app.registerModule(l.PanelModule,T);let M={};m&&Object.values(m).filter((e=>Boolean(e))).length>0&&(M.initialPos=m),this.simpleMode&&(M.showNav=!1),this.app.registerModule(l.PopupModule,M);let D={};g&&Object.values(g).filter((e=>Boolean(e))).length>0&&(D.initialPos=g),this.simpleMode?D.showNav=!1:D.showNav=!0;let _={};this.simpleMode&&(_.showNav=!1),"default"===v?(b&&Object.values(b).filter((e=>Boolean(e))).length>0&&(_.initialPos=b),this.app.registerModule(l.ToolbarModule,_),this.app.registerModule(l.ActionPanelModule,{showNav:D.showNav})):"readingTools"===v&&(this._platform.isDesktop?(b&&Object.values(b).filter((e=>Boolean(e))).length>0&&(_.initialPos=b),this.app.registerModule(l.ToolbarModule,_)):this._platform.isMobile&&this.app.registerModule(l.ActionPanelModule,{lookupResultsIn:"panel",initialPos:D.initialPos,showNav:D.showNav}))}get platform(){return this._platform}notifyExtension(){this.doc.body.dispatchEvent(new Event("Alpheios_Embedded_Response"))}async activate(){try{this.notifyExtension(),await this.app.activate(),this.doc.body.setAttribute("alpheios-embed-lib-status","active"),this.doc.body.addEventListener("Alpheios_Embedded_Check",(e=>{this.notifyExtension(e)})),this.app.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 l.AlignmentSelector(this.doc,{}).activate();l.AppController.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.app.api.ui.openToolbar()}openActionPanel(){this._platform.isMobile&&this.app.api.ui.closePanel(),this.app.api.ui.openActionPanel()}closeActionPanel(){this.app.api.ui.closeActionPanel()}openActionPanelLookup(){this._platform.isMobile&&this.app.api.ui.closePanel(),this.app.api.ui.openActionPanel({showNav:!1})}openActionPanelToolbar(){this._platform.isMobile&&this.app.api.ui.closePanel(),this.app.api.ui.openActionPanel({showLookup:!1})}}},e={d:(t,s)=>{for(var i in s)e.o(s,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:s[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};__webpack_modules___833(0,t,e),window.AlpheiosEmbed=t})(); \ No newline at end of file +(()=>{"use strict";var __webpack_modules___833=(e,t,s)=>{s.r(t),s.d(t,{Embedded:()=>Embedded,importDependencies:()=>importDependencies});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}}const i=JSON.parse('{"name":"alpheios-embedded","version":"3.4.1-incr-3.4.x.20211126119","description":"Alpheios Embedded Library","main":"dist/alpheios-embedded.js","directories":{"doc":"doc"},"scripts":{"set-node-build-deps":"npx install-peerdeps alpheios-node-build --dev --only-peers","test":"jest","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 -m all -M production -p app -c config.mjs","build-dev":"npm run lint && node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs -m all -M development -p app -c 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-core/packages/components/dist/ --t=dist/lib && node --experimental-modules ./node_modules/alpheios-node-build/dist/files.mjs replace --s=./node_modules/alpheios-core/packages/components/dist/style --t=dist/style","build-experimental":"node --experimental-modules ./node_modules/alpheios-node-build/dist/build.mjs -m webpack -M development -p app -c config.mjs","dev":"npm run build-experimental && http-server -c-1 -p 8888 & onchange src -- npm run build-experimental","conventional-commit":"npx git-cz","version-set-major":"npm version major","version-set-minor":"npm version minor","version-set-patch":"npm version patch","tagged-commit":"node --experimental-modules --experimental-json-modules ./tagged-commit.mjs","github-build":"node --experimental-modules --experimental-json-modules ./github-build.mjs"},"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":{"@actions/core":"^1.6.0","@babel/core":"^7.16.0","@babel/plugin-proposal-object-rest-spread":"^7.16.0","@babel/plugin-transform-modules-commonjs":"^7.16.0","@babel/plugin-transform-runtime":"^7.16.4","@babel/preset-env":"^7.16.4","@babel/register":"^7.16.0","@babel/runtime":"^7.16.3","alpheios-core":"git+https://github.com/alpheios-project/alpheios-core.git#incr-3.4.x","alpheios-node-build":"github:alpheios-project/node-build#v4","archiver":"^4.0.2","babel-eslint":"^10.1.0","babel-loader":"^8.2.3","babel-plugin-dynamic-import-node":"^2.3.3","babel-plugin-module-resolver":"^4.1.0","chalk":"^4.1.2","command-line-args":"^5.2.0","copy-webpack-plugin":"^6.4.1","coveralls":"^3.1.1","css-loader":"^5.2.7","cz-conventional-changelog":"^3.3.0","eslint":"^7.32.0","eslint-config-standard":"^16.0.3","eslint-plugin-import":"^2.25.3","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^4.3.1","eslint-plugin-standard":"^4.1.0","eslint-plugin-vue":"^7.20.0","fibers":"^5.0.0","fs-extra":"^9.1.0","git-branch":"^2.0.1","http-server":"^0.12.3","imagemin":"^7.0.1","imagemin-jpegtran":"^7.0.0","imagemin-optipng":"^8.0.0","imagemin-svgo":"^8.0.0","inspectpack":"^4.7.1","interactjs":"^1.10.11","jest":"^26.6.3","jest-fetch-mock":"^3.0.3","mini-css-extract-plugin":"^1.6.2","onchange":"^7.1.0","optimize-css-assets-webpack-plugin":"^5.0.8","path":"^0.12.7","postcss-import":"^13.0.0","postcss-loader":"^4.3.0","postcss-safe-important":"^1.2.1","postcss-scss":"^3.0.5","raw-loader":"^4.0.2","sass":"^1.43.5","sass-loader":"^10.2.0","shx":"^0.3.3","source-map-loader":"^1.1.3","style-loader":"^2.0.0","url-loader":"^4.1.1","vue-loader":"^15.9.8","vue-style-loader":"^4.1.3","vue-svg-loader":"^0.16.0","vue-template-compiler":"^2.6.14","vue-template-loader":"^1.1.0","webpack":"^5.64.4","webpack-bundle-analyzer":"^4.5.0","webpack-cleanup-plugin":"^0.5.1","webpack-dev-server":"^3.11.3","webpack-merge":"^5.8.0"},"engines":{"node":">= 14.1.0","npm":">= 6.13.0"},"jest":{"verbose":true,"transform":{"^.+\\\\.jsx?$":"babel-jest"},"transformIgnorePatterns":["node_modules/alpheios-core/packages/components/"]},"eslintConfig":{"env":{"browser":true,"node":true},"parser":"babel-eslint","parserOptions":{"sourceType":"module","ecmaVersion":2019,"allowImportExportEverywhere":true}},"eslintIgnore":["**/dist"],"dependencies":{},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}}}'),{version:o,description:a}=i;let l;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;default:t.components="https://cdn.jsdelivr.net/npm/alpheios-components@latest/dist/alpheios-components.min.js"}return new Promise(((e,s)=>{let i=[],o=import(t.components).then((()=>{l=window.AlpheiosComponents}));i.push(o),Promise.all(i).then((()=>{e(Embedded)})).catch((e=>{s(e)}))}))}class Embedded{constructor({clientId:e=null,authEnv:t=null,documentObject:s=document,enabledSelector:i=".alpheios-enabled",disabledSelector:n="",enabledClass:r="",disabledClass:p="",mobileTriggerEvent:d=null,desktopTriggerEvent:u=null,triggerPreCallback:c=(e=>!0),enableMouseMoveOverride:h=!1,popupInitialPos:m={},toolbarInitialPos:b={},actionPanelInitialPos:g={},layoutType:v="default",disableTextSelection:f=!1,textLangCode:S=null,overrideHelp:A=!1,simpleMode:E=!1,arethusaTbRefreshRetryCount:y=5,arethusaTbRefreshDelay:P=200,languageOptions:w={},uiOptions:j={}}={}){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=i,this.disabledSelector=n,this.enabledClass=r,this.disabledClass=p,this.desktopTriggerEvent=u,this.mobileTriggerEvent=d,this.triggerPreCallback=c,this.enableMouseMoveOverride=h,this.simpleMode=E,this.state.setPanelClosed(),this.state.tab="info",this._platform=new l.Platform({appType:l.Platform.appTypes.EMBEDDED_LIBRARY}),this.app=l.AppController.create(this.state,{storageAdapter:l.LocalStorageArea,textQueryTriggerDesktop:this.desktopTriggerEvent,textQueryTriggerMobile:this.mobileTriggerEvent,textQuerySelector:this.enabledSelector,triggerPreCallback:this.triggerPreCallback,enableMouseMoveOverride:this.enableMouseMoveOverride,app:{version:`${o}`,buildBranch:"ext-323-embed-ext",buildNumber:"20211126428",buildName:"ext-323-embed-ext.20211126428",name:a},appType:l.Platform.appTypes.EMBEDDED_LIBRARY,clientId:this.clientId,disableTextSelection:f,textLangCode:S,overrideHelp:A,configServiceUrl:"https://config.alpheios.net/v1/config",arethusaTbRefreshRetryCount:y,arethusaTbRefreshDelay:P,languageOptions:w,uiOptions:j}),this.authEnv?t.CLIENT_ID?this.app.registerModule(l.AuthModule,{auth:new l.AppAuthenticator(t)}):t.LOGIN_URL&&this.app.registerModule(l.AuthModule,{auth:new l.SessionAuthenticator(t)}):this.app.registerModule(l.AuthModule,{auth:null});let T={};this.simpleMode&&(T.showNav=!1),this.app.registerModule(l.PanelModule,T);let M={};m&&Object.values(m).filter((e=>Boolean(e))).length>0&&(M.initialPos=m),this.simpleMode&&(M.showNav=!1),this.app.registerModule(l.PopupModule,M);let D={};g&&Object.values(g).filter((e=>Boolean(e))).length>0&&(D.initialPos=g),this.simpleMode?D.showNav=!1:D.showNav=!0;let _={};this.simpleMode&&(_.showNav=!1),"default"===v?(b&&Object.values(b).filter((e=>Boolean(e))).length>0&&(_.initialPos=b),this.app.registerModule(l.ToolbarModule,_),this.app.registerModule(l.ActionPanelModule,{showNav:D.showNav})):"readingTools"===v&&(this._platform.isDesktop?(b&&Object.values(b).filter((e=>Boolean(e))).length>0&&(_.initialPos=b),this.app.registerModule(l.ToolbarModule,_)):this._platform.isMobile&&this.app.registerModule(l.ActionPanelModule,{lookupResultsIn:"panel",initialPos:D.initialPos,showNav:D.showNav})),this.notifyExtension()}get platform(){return this._platform}notifyExtension(){this.doc.body.dispatchEvent(new Event("Alpheios_Embedded_Response"))}async activate(){try{await this.app.activate(),this.doc.body.setAttribute("alpheios-embed-lib-status","active"),this.doc.body.addEventListener("Alpheios_Embedded_Check",(e=>{this.notifyExtension(e)})),this.app.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 l.AlignmentSelector(this.doc,{}).activate();l.AppController.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.app.api.ui.openToolbar()}openActionPanel(){this._platform.isMobile&&this.app.api.ui.closePanel(),this.app.api.ui.openActionPanel()}closeActionPanel(){this.app.api.ui.closeActionPanel()}openActionPanelLookup(){this._platform.isMobile&&this.app.api.ui.closePanel(),this.app.api.ui.openActionPanel({showNav:!1})}openActionPanelToolbar(){this._platform.isMobile&&this.app.api.ui.closePanel(),this.app.api.ui.openActionPanel({showLookup:!1})}}},e={d:(t,s)=>{for(var i in s)e.o(s,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:s[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};__webpack_modules___833(0,t,e),window.AlpheiosEmbed=t})(); \ No newline at end of file diff --git a/src/embedded.js b/src/embedded.js index 5fdf5e8..3c154bf 100644 --- a/src/embedded.js +++ b/src/embedded.js @@ -241,6 +241,7 @@ export class Embedded { }) } } + this.notifyExtension() } // TODO: Is it used by any external code? @@ -261,7 +262,6 @@ export class Embedded { * than the extension will have no information about * the embedded library presence unless explicitly notified by us. */ - this.notifyExtension() // await this.app.init() // Activate will call `init()` if has not been initialized previously await this.app.activate()