Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@acrolinx/app-sdk

Package Overview
Dependencies
Maintainers
3
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@acrolinx/app-sdk - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

4

dist/acrolinx-app-sdk-auto-form.min.js

@@ -10,4 +10,4 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"//Qm":[function(require,module,exports) {

},{"./event-emitter":"//Qm","./raw":"/eMv","./utils":"UnXq"}],"M10p":[function(require,module,exports) {
"use strict";var t=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}};Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./index"),r=require("./raw");function n(t){var e=document.querySelector("meta[name="+t+"]");return e&&e.getAttribute("value")}function o(){var e,r,n=document.querySelectorAll('[data-acrolinx="hide"]');try{for(var o=t(n),i=o.next();!i.done;i=o.next()){i.value.style.display="none"}}catch(a){e={error:a}}finally{try{i&&!i.done&&(r=o.return)&&r.call(o)}finally{if(e)throw e.error}}}function i(){if(r.hasParentWindow()){o();var t=document.querySelector("title"),i=n("acrolinx-app-title")||t&&t.innerText,a=document.querySelector('[data-acrolinx="extractedText"]'),l=e.initApi({title:i||window.location.href,button:{text:n("acrolinx-app-button-text")||"Check",tooltip:n("acrolinx-app-button-tooltip")||""},requiredCommands:[],requiredEvents:a?[e.ApiEvents.textExtracted]:[]});a&&l.events.textExtracted.addEventListener(function(t){a.value=t.text,a.form.submit()})}}window.addEventListener("DOMContentLoaded",i);
},{"./index":"7QCb","./raw":"/eMv"}]},{},["M10p"], null)
"use strict";var e=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},t=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(a)throw a.error}}return o},r=this&&this.__spread||function(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(t(arguments[r]));return e};Object.defineProperty(exports,"__esModule",{value:!0});var n=require("./index"),a=require("./raw"),i=require("./utils");function o(e){var t=document.querySelector("meta[name="+e+"]");return t&&t.getAttribute("value")}function l(){var t,r,n=document.querySelectorAll('[data-acrolinx="hide"]');try{for(var a=e(n),i=a.next();!i.done;i=a.next()){i.value.style.display="none"}}catch(o){t={error:o}}finally{try{i&&!i.done&&(r=a.return)&&r.call(a)}finally{if(t)throw t.error}}}function c(e,t){for(var r=e;r&&r!==document.body;){if(r.dataset[t])return r;r=r.parentElement}}function u(t){var r,n;try{for(var a=e(document.getElementsByClassName(t)),i=a.next();!i.done;i=a.next()){i.value.classList.remove(t)}}catch(o){r={error:o}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}}function d(e){return e.filter(function(e){return e})}var s="acrolinx-invalid-range";function v(t){var r=o("acrolinx-app-invalid-range-tooltip");t.events.invalidRanges.addEventListener(function(t){var a,i,o=document.querySelectorAll("[data-acrolinx-select-range]");try{for(var l=e(o),c=l.next();!c.done;c=l.next()){var u=c.value,d=JSON.parse(u.dataset.acrolinxSelectRange);n.isInvalid(t,d)&&(u.classList.add(s),r&&(u.title=r))}}catch(v){a={error:v}}finally{try{c&&!c.done&&(i=l.return)&&i.call(l)}finally{if(a)throw a.error}}})}function f(e){document.addEventListener("click",function(t){var r=c(t.target,"acrolinxSelectRange");if(r&&!r.classList.contains(s)){var n=r.dataset.acrolinxSelectRange,a=JSON.parse(n);u("acrolinx-selected-range"),r.classList.add("acrolinx-selected-range"),e.commands.selectRanges([a])}})}function x(){a.hasParentWindow()&&l();var e=document.querySelector("title"),t=o("acrolinx-app-title")||e&&e.innerText,c=document.querySelector('[data-acrolinx="extractedText"]'),u=(o("acrolinx-app-required-commands")||"").split(/, ?/),s=(o("acrolinx-app-required-events")||"").split(/, ?/),x=n.initApi({title:t||window.location.href,button:{text:o("acrolinx-app-button-text")||"Check",tooltip:o("acrolinx-app-button-tooltip")||""},requiredCommands:u,requiredEvents:d(r([c&&n.ApiEvents.textExtracted],s))});c&&x.events.textExtracted.addEventListener(function(e){c.value=e.text,c.form.submit()}),i.includes(s,n.ApiEvents.invalidRanges)&&v(x),i.includes(u,n.ApiCommands.selectRanges)&&f(x)}window.addEventListener("DOMContentLoaded",x);
},{"./index":"7QCb","./raw":"/eMv","./utils":"UnXq"}]},{},["M10p"], null)
//# sourceMappingURL=/acrolinx-app-sdk-auto-form.min.js.map
"use strict";
/*
* Copyright 2019-present Acrolinx GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, softwareq
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var __values = (this && this.__values) || function (o) {

@@ -12,5 +27,29 @@ var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;

};
var __read = (this && this.__read) || function (o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
};
var __spread = (this && this.__spread) || function () {
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
return ar;
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This module is highly experimental.
*/
var index_1 = require("./index");
var raw_1 = require("./raw");
var utils_1 = require("./utils");
function getMetaValue(name) {

@@ -37,10 +76,80 @@ var metaEl = document.querySelector("meta[name=" + name + "]");

}
function findInPathToDocument(startElement, dataAttribute) {
var el = startElement;
while (el && el !== document.body) {
if (el.dataset[dataAttribute]) {
return el;
}
el = el.parentElement;
}
return undefined;
}
function removeClassName(className) {
var e_2, _a;
try {
for (var _b = __values(document.getElementsByClassName(className)), _c = _b.next(); !_c.done; _c = _b.next()) {
var el = _c.value;
el.classList.remove(className);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_2) throw e_2.error; }
}
}
function compact(array) {
return array.filter(function (el) { return el; });
}
var INVALID_RANGE_CLASS_NAME = 'acrolinx-invalid-range';
function addInvalidRangesListener(appApi) {
var invalidRangeTooltip = getMetaValue('acrolinx-app-invalid-range-tooltip');
appApi.events.invalidRanges.addEventListener(function (invalidRangesEvent) {
var e_3, _a;
var selectRangesElements = document.querySelectorAll('[data-acrolinx-select-range]');
try {
for (var selectRangesElements_1 = __values(selectRangesElements), selectRangesElements_1_1 = selectRangesElements_1.next(); !selectRangesElements_1_1.done; selectRangesElements_1_1 = selectRangesElements_1.next()) {
var el = selectRangesElements_1_1.value;
var offsetRange = JSON.parse(el.dataset.acrolinxSelectRange);
if (index_1.isInvalid(invalidRangesEvent, offsetRange)) {
el.classList.add(INVALID_RANGE_CLASS_NAME);
if (invalidRangeTooltip) {
el.title = invalidRangeTooltip;
}
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (selectRangesElements_1_1 && !selectRangesElements_1_1.done && (_a = selectRangesElements_1.return)) _a.call(selectRangesElements_1);
}
finally { if (e_3) throw e_3.error; }
}
});
}
function addClickSelectRangeListener(appApi) {
document.addEventListener('click', function (ev) {
var elementWithSelectRange = findInPathToDocument(ev.target, 'acrolinxSelectRange');
if (!elementWithSelectRange || elementWithSelectRange.classList.contains(INVALID_RANGE_CLASS_NAME)) {
return;
}
var offsetRangeString = elementWithSelectRange.dataset.acrolinxSelectRange;
var offsetRange = JSON.parse(offsetRangeString);
removeClassName('acrolinx-selected-range');
elementWithSelectRange.classList.add('acrolinx-selected-range');
appApi.commands.selectRanges([offsetRange]);
});
}
function initAcrolinxAppAutoForm() {
if (!raw_1.hasParentWindow()) {
return;
if (raw_1.hasParentWindow()) {
hideElements();
}
hideElements();
var title = document.querySelector('title');
var appTitle = getMetaValue('acrolinx-app-title') || (title && title.innerText);
var acrolinxExtractedTextField = document.querySelector('[data-acrolinx="extractedText"]');
var requiredCommands = (getMetaValue('acrolinx-app-required-commands') || '').split(/, ?/);
var requiredEvents = (getMetaValue('acrolinx-app-required-events') || '').split(/, ?/);
var appApi = index_1.initApi({

@@ -52,4 +161,6 @@ title: appTitle || window.location.href,

},
requiredCommands: [],
requiredEvents: acrolinxExtractedTextField ? [index_1.ApiEvents.textExtracted] : [],
requiredCommands: requiredCommands,
requiredEvents: compact(__spread([
acrolinxExtractedTextField && index_1.ApiEvents.textExtracted
], requiredEvents)),
});

@@ -62,4 +173,10 @@ if (acrolinxExtractedTextField) {

}
if (utils_1.includes(requiredEvents, index_1.ApiEvents.invalidRanges)) {
addInvalidRangesListener(appApi);
}
if (utils_1.includes(requiredCommands, index_1.ApiCommands.selectRanges)) {
addClickSelectRangeListener(appApi);
}
}
window.addEventListener('DOMContentLoaded', initAcrolinxAppAutoForm);
//# sourceMappingURL=auto-form.js.map
{
"name": "@acrolinx/app-sdk",
"version": "0.0.8",
"version": "0.0.9",
"description": "Acrolinx App SDK",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc