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

@compdfkit_pdf_sdk/webviewer

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compdfkit_pdf_sdk/webviewer - npm Package Compare versions

Comparing version 2.2.2 to 2.5.0

dist/assets/colorful.c840ddf1.svg

2

package.json
{
"name": "@compdfkit_pdf_sdk/webviewer",
"version": "2.2.2",
"version": "2.5.0",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [

@@ -48,3 +48,4 @@ # ComPDFKit

WebViewer({
WebViewer.init({
path: '/', // the path of your webviewer
pdfUrl: 'URL of your PDF File' // the path of your document

@@ -51,0 +52,0 @@ license: 'Input your license here'

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).ComPDFKitViewer=t()}(this,(function(){"use strict";function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(r=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(r,"string"))?o:String(o)),n)}var r,o}var t={init:function(e,t,i){return new Promise((function(r){t.addEventListener("ready",(function e(){t.removeEventListener("ready",e);var i=t.querySelector("iframe").contentWindow;Promise.resolve().then((function(){r({docViewer:i.instance,Core:i.instances.Core,UI:i.instances.UI})}))})),new n(e,t,i)}))}},i=new Map,n=function(){function t(e,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i.get(n)||(i.set(n,!0),this.instance=null,this.options=e,this.initialDoc=e.pdfUrl||null,this.element=n,this.optionsUrl=r,n.addEventListener("ready",(function e(){n.removeEventListener("ready",e)})),this.create())}var n,r,o;return n=t,(r=[{key:"_createEvent",value:function(e,t){var i;try{i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0})}catch(n){(i=document.createEvent("Event")).initEvent(e,!0,!0),i.detail=t}return i}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this._trigger||(this._trigger=function(e,t){var i=this._createEvent(e,t);this.element.dispatchEvent(i)}),this.createViewer()}},{key:"createViewer",value:function(){var e,t,i=this,n="./webviewer/index.html";this.initialDoc&&(n+="#d=".concat(this.initialDoc));var r=document.createElement("iframe");r.id="webviewer",r.src=n,r.title="webviewer",r.frameBorder=0,r.width="100%",r.height="100%",r.setAttribute("allowfullscreen",!0),r.setAttribute("webkitallowfullscreen",!0),r.setAttribute("mozallowfullscreen",!0),this.iframe=r,null!==(e=this.options)&&void 0!==e&&e.backgroundColor&&r.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(t=this.options)&&void 0!==t&&t.assetPath&&r.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.loadListener=function(){var e=i.iframe;i.instance=e.contentWindow.instance,i.instance.initOptions(i.options),i._trigger("ready")},r.addEventListener("load",this.loadListener),this.element.appendChild(r)}}])&&e(n.prototype,r),o&&e(n,o),Object.defineProperty(n,"prototype",{writable:!1}),t}();return t}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).ComPDFKitViewer=e()}(this,(function(){"use strict";function t(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function e(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function c(e){t(a,o,i,c,s,"next",e)}function s(e){t(a,o,i,c,s,"throw",e)}c(void 0)}))}}function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,o(n.key),n)}}function n(){n=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),c=new T(n||[]);return i(a,"_invoke",{value:O(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=h;var d="suspendedStart",p="suspendedYield",v="executing",y="completed",m={};function w(){}function g(){}function b(){}var E={};l(E,c,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(N([])));x&&x!==r&&o.call(x,c)&&(E=x);var _=b.prototype=w.prototype=Object.create(E);function P(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function j(t,e){function r(n,i,a,c){var s=f(t[n],t,i);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&o.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(l).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new e((function(e,n){r(t,o,e,n)}))}return n=n?n.then(i,i):i()}})}function O(e,r,n){var o=d;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function N(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function r(){for(;++n<e.length;)if(o.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,i(_,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=l(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,l(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},P(j.prototype),l(j.prototype,s,(function(){return this})),e.AsyncIterator=j,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new j(h(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},P(_),l(_,u,"Generator"),l(_,c,(function(){return this})),l(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=N,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=o.call(a,"catchLoc"),u=o.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:N(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function o(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var i,a,c,s=new Map,u=function(){return t=function t(e,r){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!s.get(r)){this.docId=0,s.set(r,!0),this.instance=null,this.options=e,this.initialDoc=e.pdfUrl||null,this.element=r,this.options.path=this.options.path||t.config.path;var n=this.options.path.length-1;n>0&&"/"!==this.options.path[n]&&(this.options.path+="/"),this.options.webviewerPath=this.options.path+t.config.webviewerPath,r.addEventListener("ready",(function t(){r.removeEventListener("ready",t)})),this.create()}},o=[{key:"_createEvent",value:function(t,e){var r;try{r=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0})}catch(n){(r=document.createEvent("Event")).initEvent(t,!0,!0),r.detail=e}return r}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this.docId++,this._trigger||(this._trigger=function(t,e){var r=this._createEvent(t,e);this.element.dispatchEvent(r)}),this.createViewer()}},{key:"createViewer",value:function(){var t,r,o=this,i=this.options.webviewerPath;this.initialDoc?i+="#d=".concat(this.initialDoc):i+="#",i+="&docId=".concat(this.docId),void 0!==this.options.showToolbarControl&&(i+="&header=".concat(this.options.showToolbarControl?"true":"false"));var a=document.createElement("iframe");a.id="webviewer-"+this.docId,a.src=i,a.frameBorder=0,a.width="100%",a.height="100%",a.setAttribute("allowfullscreen",!0),a.setAttribute("webkitallowfullscreen",!0),a.setAttribute("mozallowfullscreen",!0),this.iframe=a,null!==(t=this.options)&&void 0!==t&&t.backgroundColor&&a.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(r=this.options)&&void 0!==r&&r.assetPath&&a.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.element.appendChild(a),this.loadListener=e(n().mark((function t(){var e;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=o.iframe,o.instance=e.contentWindow.instance,t.next=4,o.instance.initOptions(o.options);case 4:case"end":return t.stop()}}),t)}))),a.addEventListener("load",this.loadListener),this.messageHandler=function(t){if("documentViewerLoaded"===t.data.type&&t.data.docId===o.docId)try{o.instance=o.iframe.contentWindow.instance}catch(t){}finally{window.removeEventListener("message",this.messageHandler),o._documentViewerLoaded(o.iframe)}},window.addEventListener("message",this.messageHandler)}},{key:"_documentViewerLoaded",value:function(t){this._trigger("ready"),this.options.pdfUrl&&this.iframe.contentWindow.instances.UI.loadDocument(this.options.pdfUrl)}}],o&&r(t.prototype,o),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,o,i}();return i=u,c={path:"",webviewerPath:"./webviewer/index.html"},(a=o(a="config"))in i?Object.defineProperty(i,a,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[a]=c,{init:function(t,e){return new Promise((function(r){e.addEventListener("ready",(function t(){e.removeEventListener("ready",t);var n=e.querySelector("iframe").contentWindow;Promise.resolve().then((function(){r({docViewer:n.instance,Core:n.instances.Core,UI:n.instances.UI})}))})),new u(t,e)}))}}}));

@@ -1,1 +0,1 @@

function e(e,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(r=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var n=i.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(r,"string"))?o:String(o)),n)}var r,o}var t={init:function(e,t,i){return new Promise((function(r){t.addEventListener("ready",(function e(){t.removeEventListener("ready",e);var i=t.querySelector("iframe").contentWindow;Promise.resolve().then((function(){r({docViewer:i.instance,Core:i.instances.Core,UI:i.instances.UI})}))})),new n(e,t,i)}))}},i=new Map,n=function(){function t(e,n,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),i.get(n)||(i.set(n,!0),this.instance=null,this.options=e,this.initialDoc=e.pdfUrl||null,this.element=n,this.optionsUrl=r,n.addEventListener("ready",(function e(){n.removeEventListener("ready",e)})),this.create())}var n,r,o;return n=t,(r=[{key:"_createEvent",value:function(e,t){var i;try{i=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0})}catch(n){(i=document.createEvent("Event")).initEvent(e,!0,!0),i.detail=t}return i}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this._trigger||(this._trigger=function(e,t){var i=this._createEvent(e,t);this.element.dispatchEvent(i)}),this.createViewer()}},{key:"createViewer",value:function(){var e,t,i=this,n="./webviewer/index.html";this.initialDoc&&(n+="#d=".concat(this.initialDoc));var r=document.createElement("iframe");r.id="webviewer",r.src=n,r.title="webviewer",r.frameBorder=0,r.width="100%",r.height="100%",r.setAttribute("allowfullscreen",!0),r.setAttribute("webkitallowfullscreen",!0),r.setAttribute("mozallowfullscreen",!0),this.iframe=r,null!==(e=this.options)&&void 0!==e&&e.backgroundColor&&r.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(t=this.options)&&void 0!==t&&t.assetPath&&r.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.loadListener=function(){var e=i.iframe;i.instance=e.contentWindow.instance,i.instance.initOptions(i.options),i._trigger("ready")},r.addEventListener("load",this.loadListener),this.element.appendChild(r)}}])&&e(n.prototype,r),o&&e(n,o),Object.defineProperty(n,"prototype",{writable:!1}),t}();export{t as default};
function t(t,e,r,n,o,i,a){try{var c=t[i](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,o)}function e(e){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=e.apply(r,n);function c(e){t(a,o,i,c,s,"next",e)}function s(e){t(a,o,i,c,s,"throw",e)}c(void 0)}))}}function r(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,o(n.key),n)}}function n(){n=function(){return e};var t,e={},r=Object.prototype,o=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function h(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{h({},"")}catch(t){h=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof w?e:w,a=Object.create(o.prototype),c=new N(n||[]);return i(a,"_invoke",{value:j(t,r,c)}),a}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var d="suspendedStart",p="suspendedYield",v="executing",y="completed",m={};function w(){}function g(){}function b(){}var E={};h(E,c,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(S([])));x&&x!==r&&o.call(x,c)&&(E=x);var _=b.prototype=w.prototype=Object.create(E);function P(t){["next","throw","return"].forEach((function(e){h(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(n,i,a,c){var s=f(t[n],t,i);if("throw"!==s.type){var u=s.arg,h=u.value;return h&&"object"==typeof h&&o.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(h).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var n;i(this,"_invoke",{value:function(t,o){function i(){return new e((function(e,n){r(t,o,e,n)}))}return n=n?n.then(i,i):i()}})}function j(e,r,n){var o=d;return function(i,a){if(o===v)throw Error("Generator is already running");if(o===y){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var s=k(c,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===d)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var u=f(e,r,n);if("normal"===u.type){if(o=n.done?y:p,u.arg===m)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(o=y,n.method="throw",n.arg=u.arg)}}}function k(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,k(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),m;var i=f(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,m;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,m):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,m)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function C(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function N(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function S(e){if(e||""===e){var r=e[c];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function r(){for(;++n<e.length;)if(o.call(e,n))return r.value=e[n],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(typeof e+" is not iterable")}return g.prototype=b,i(_,"constructor",{value:b,configurable:!0}),i(b,"constructor",{value:g,configurable:!0}),g.displayName=h(b,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,h(t,u,"GeneratorFunction")),t.prototype=Object.create(_),t},e.awrap=function(t){return{__await:t}},P(O.prototype),h(O.prototype,s,(function(){return this})),e.AsyncIterator=O,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new O(l(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},P(_),h(_,u,"Generator"),h(_,c,(function(){return this})),h(_,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=S,N.prototype={constructor:N,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(C),!e)for(var r in this)"t"===r.charAt(0)&&o.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function n(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=o.call(a,"catchLoc"),u=o.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&o.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var i=n;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,m):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),m},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),C(r),m}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;C(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:S(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),m}},e}function o(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}var i,a,c,s=new Map,u=function(){return t=function t(e,r){if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!s.get(r)){this.docId=0,s.set(r,!0),this.instance=null,this.options=e,this.initialDoc=e.pdfUrl||null,this.element=r,this.options.path=this.options.path||t.config.path;var n=this.options.path.length-1;n>0&&"/"!==this.options.path[n]&&(this.options.path+="/"),this.options.webviewerPath=this.options.path+t.config.webviewerPath,r.addEventListener("ready",(function t(){r.removeEventListener("ready",t)})),this.create()}},o=[{key:"_createEvent",value:function(t,e){var r;try{r=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0})}catch(n){(r=document.createEvent("Event")).initEvent(t,!0,!0),r.detail=e}return r}},{key:"create",value:function(){this.initialDoc?(this.initialDoc=encodeURIComponent(JSON.stringify(this.initialDoc)),this._create()):this._create()}},{key:"_create",value:function(){this.docId++,this._trigger||(this._trigger=function(t,e){var r=this._createEvent(t,e);this.element.dispatchEvent(r)}),this.createViewer()}},{key:"createViewer",value:function(){var t,r,o=this,i=this.options.webviewerPath;this.initialDoc?i+="#d=".concat(this.initialDoc):i+="#",i+="&docId=".concat(this.docId),void 0!==this.options.showToolbarControl&&(i+="&header=".concat(this.options.showToolbarControl?"true":"false"));var a=document.createElement("iframe");a.id="webviewer-"+this.docId,a.src=i,a.frameBorder=0,a.width="100%",a.height="100%",a.setAttribute("allowfullscreen",!0),a.setAttribute("webkitallowfullscreen",!0),a.setAttribute("mozallowfullscreen",!0),this.iframe=a,null!==(t=this.options)&&void 0!==t&&t.backgroundColor&&a.setAttribute("data-bgcolor",this.options.backgroundColor),null!==(r=this.options)&&void 0!==r&&r.assetPath&&a.setAttribute("data-assetpath",encodeURIComponent(this.options.assetPath)),this.element.appendChild(a),this.loadListener=e(n().mark((function t(){var e;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=o.iframe,o.instance=e.contentWindow.instance,t.next=4,o.instance.initOptions(o.options);case 4:case"end":return t.stop()}}),t)}))),a.addEventListener("load",this.loadListener),this.messageHandler=function(t){if("documentViewerLoaded"===t.data.type&&t.data.docId===o.docId)try{o.instance=o.iframe.contentWindow.instance}catch(t){}finally{window.removeEventListener("message",this.messageHandler),o._documentViewerLoaded(o.iframe)}},window.addEventListener("message",this.messageHandler)}},{key:"_documentViewerLoaded",value:function(t){this._trigger("ready"),this.options.pdfUrl&&this.iframe.contentWindow.instances.UI.loadDocument(this.options.pdfUrl)}}],o&&r(t.prototype,o),i&&r(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,o,i}();i=u,c={path:"",webviewerPath:"./webviewer/index.html"},(a=o(a="config"))in i?Object.defineProperty(i,a,{value:c,enumerable:!0,configurable:!0,writable:!0}):i[a]=c;var h={init:function(t,e){return new Promise((function(r){e.addEventListener("ready",(function t(){e.removeEventListener("ready",t);var n=e.querySelector("iframe").contentWindow;Promise.resolve().then((function(){r({docViewer:n.instance,Core:n.instances.Core,UI:n.instances.UI})}))})),new u(t,e)}))}};export{h as default};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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