@archilogic/embed-api
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,1 @@ | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}var t=0;function r(e){return"__private_"+t+++"_"+e}function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},i=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,a=["file:","data:"];var s,c,d,l,u;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(s||(s={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(c||(c={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(d||(d={})),function(e){e.DataCloneError="DataCloneError"}(l||(l={})),function(e){e.Message="message"}(u||(u={}));const m=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let v=0;var h,f=0,p=function(e){return JSON.parse(JSON.stringify(e))};(h=exports.PresentationMode||(exports.PresentationMode={}))[h.none=0]="none",h[h.goToCameraDefault=1]="goToCameraDefault",h[h.goToFirstBookmark=2]="goToFirstBookmark",h[h.jumpToCameraDefault=3]="jumpToCameraDefault",h[h.jumpToFirstBookmark=4]="jumpToFirstBookmark",h[h.tourOnce=5]="tourOnce",h[h.tourOnceAndGoBack=6]="tourOnceAndGoBack",h[h.tourLoop=7]="tourLoop";var g={accessToken:void 0,transparentBackground:!0,presentationMode:exports.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},w=r("options"),y=r("listeners");exports.default=function(){function t(t,r){var h=this,f=this;void 0===r&&(r={}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),o(this,y)[y]=new Map,this.handleEvent=function(e,t){var r=o(f,y)[y].get(e);if(r)return r(t);console.warn("Listener not found")},o(this,w)[w]=p(e({},g,r)),this.containerEl=t,this.viewerEl=function(e,t){void 0===e&&(e=document.body);var r=document.createElement("iframe");return Object.assign(r,{src:"https://viewer.archilogic.com/v1_0_0?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(r),r}(t),this.viewerReadyPromise=(e=>{let{iframe:t,methods:r={},childOrigin:o,timeout:h,debug:f=!1}=e;const p=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(f),g=(()=>{const e=[];let t=!1;return{destroy(r){t=!0,e.forEach(e=>{e(r)})},onDestroy(r){t?r():e.push(r)}}})(),{onDestroy:w,destroy:y}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=d.NoIframeSrc,e}})(t),o=(e=>{if(e&&a.find(t=>e.startsWith(t)))return"null";const t=document.location,r=i.exec(e);let o,s,c;return r?(o=r[1]?r[1]:t.protocol,s=r[2],c=r[4]):(o=t.protocol,s=t.hostname,c=t.port),`${o}//${s}${c&&c!==n[o]?":"+c:""}`})(t.src));const k="null"===o?"*":o,E=((e,t,r,o)=>n=>{if(n.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:s.SynAck,methodNames:Object.keys(t)};n.source.postMessage(i,o)})(p,r,o,k),P=((e,t,r,o,n)=>{const{destroy:i,onDestroy:a}=o;let h,f;const p={};return o=>{if(o.origin!==t)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${t}`);n("Parent: Handshake - Received ACK");const g={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};h&&h(),h=((e,t,r)=>{const{localName:o,local:n,remote:i,originForSending:a,originForReceiving:d}=e;let v=!1;const h=e=>{if(e.source!==i||e.data.penpal!==s.Call)return;if(e.origin!==d)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:u,args:h,id:f}=n;r(`${o}: Received ${u}() call`);const p=e=>t=>{if(r(`${o}: Sending ${u}() reply`),v)return void r(`${o}: Unable to send ${u}() reply due to destroyed connection`);const n={penpal:s.Reply,id:f,resolution:e,returnValue:t};e===c.Rejected&&t instanceof Error&&(n.returnValue=m(t),n.returnValueIsError=!0);try{i.postMessage(n,a)}catch(e){if(e.name===l.DataCloneError){const t={penpal:s.Reply,id:f,resolution:c.Rejected,returnValue:m(e),returnValueIsError:!0};i.postMessage(t,a)}throw e}};new Promise(e=>e(t[u].apply(t,h))).then(p(c.Fulfilled),p(c.Rejected))};return n.addEventListener(u.Message,h),()=>{v=!0,n.removeEventListener(u.Message,h)}})(g,e,n),a(h),f&&f.forEach(e=>{delete p[e]}),f=o.data.methodNames;const w=((e,t,r,o,n)=>{const{localName:i,local:a,remote:l,originForSending:m,originForReceiving:h}=t;let f=!1;return n(i+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;n(`${i}: Sending ${e}() call`);try{l.closed&&(r=!0)}catch(e){r=!0}if(r&&o(),f){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=d.ConnectionDestroyed,t}return new Promise((r,o)=>{const d=++v,f=t=>{if(t.source!==l||t.data.penpal!==s.Reply||t.data.id!==d)return;if(t.origin!==h)return void n(`${i} received message from origin ${t.origin} which did not match expected origin ${h}`);const m=t.data;n(`${i}: Received ${e}() reply`),a.removeEventListener(u.Message,f);let v=m.returnValue;m.returnValueIsError&&(v=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(v)),(m.resolution===c.Fulfilled?r:o)(v)};a.addEventListener(u.Message,f),l.postMessage({penpal:s.Call,id:d,methodName:e,args:t},m)})})(t),e),e),()=>{f=!0}})(p,g,f,i,n);return a(w),p}})(r,o,k,g,p);return{promise:new Promise((e,r)=>{const o=((e,t)=>{let r;return void 0!==e&&(r=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=d.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(h,y),n=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==s.Syn)if(r.data.penpal!==s.Ack);else{const t=P(r);t&&(o(),e(t))}else E(r)};window.addEventListener(u.Message,n),p("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(t,g),w(e=>{window.removeEventListener(u.Message,n),e||((e=new Error("Connection destroyed")).code=d.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var t=e.token,r=e.origin,o=e.viewer;try{if(!t)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:t,origin:r})).then(function(e){if(!e.isValid)throw new Error(e.message?"Access token: "+(n={reason:e.message.name,token:t}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:r,token:t}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:o(h,w)[w].accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(o(h,w)[w]),!0})}catch(e){return Promise.reject(e)}})}var r=t.prototype;return r.loadScene=function(e){try{var t=this;return Promise.resolve(t.viewerReadyPromise).then(function(){return t.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},r.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},r.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},r.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},r.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},r.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},r.goToPersonMode=function(e){var t=void 0===e?{}:e,r=t.findSafeLanding,o=t.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===r||r,animate:void 0===o||o})},r.zoomExtents=function(e){var t=void 0===e?{}:e,r=t.spaceId,o=void 0===r?void 0:r,n=t.animate,i=void 0===n||n,a=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:a.width/a.height})},r.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},r.set=function(e){this.viewer.set(p(e))},r.on=function(e,t){return f++,o(this,y)[y].set(f,t),this.viewer.addListener(e,f),f},r.off=function(e){return this.viewer.removeListener(e)},t}(),exports.defaultEmbedOptions=g; | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}var t=0;function r(e){return"__private_"+t+++"_"+e}function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},i=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,s=["file:","data:"];var a,c,d,l,u;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(a||(a={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(c||(c={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(d||(d={})),function(e){e.DataCloneError="DataCloneError"}(l||(l={})),function(e){e.Message="message"}(u||(u={}));const m=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let v=0;var h,f=0,p=function(e){return JSON.parse(JSON.stringify(e))};(h=exports.PresentationMode||(exports.PresentationMode={}))[h.none=0]="none",h[h.goToCameraDefault=1]="goToCameraDefault",h[h.goToFirstBookmark=2]="goToFirstBookmark",h[h.jumpToCameraDefault=3]="jumpToCameraDefault",h[h.jumpToFirstBookmark=4]="jumpToFirstBookmark",h[h.tourOnce=5]="tourOnce",h[h.tourOnceAndGoBack=6]="tourOnceAndGoBack",h[h.tourLoop=7]="tourLoop";var g={accessToken:void 0,transparentBackground:!0,presentationMode:exports.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},w=r("options"),y=r("listeners");exports.default=function(){function t(t,r){var h=this,f=this;void 0===r&&(r={}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),o(this,y)[y]=new Map,this.handleEvent=function(e,t){var r=o(f,y)[y].get(e);if(r)return r(t);console.warn("Listener not found")},o(this,w)[w]=p(e({},g,r)),this.containerEl=t,this.viewerEl=function(e,t){void 0===e&&(e=document.body);var r=document.createElement("iframe");return Object.assign(r,{src:"https://viewer.archilogic.com/v1_0_2?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(r),r}(t),this.viewerReadyPromise=(e=>{let{iframe:t,methods:r={},childOrigin:o,timeout:h,debug:f=!1}=e;const p=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(f),g=(()=>{const e=[];let t=!1;return{destroy(r){t=!0,e.forEach(e=>{e(r)})},onDestroy(r){t?r():e.push(r)}}})(),{onDestroy:w,destroy:y}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=d.NoIframeSrc,e}})(t),o=(e=>{if(e&&s.find(t=>e.startsWith(t)))return"null";const t=document.location,r=i.exec(e);let o,a,c;return r?(o=r[1]?r[1]:t.protocol,a=r[2],c=r[4]):(o=t.protocol,a=t.hostname,c=t.port),`${o}//${a}${c&&c!==n[o]?":"+c:""}`})(t.src));const k="null"===o?"*":o,E=((e,t,r,o)=>n=>{if(n.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:a.SynAck,methodNames:Object.keys(t)};n.source.postMessage(i,o)})(p,r,o,k),P=((e,t,r,o,n)=>{const{destroy:i,onDestroy:s}=o;let h,f;const p={};return o=>{if(o.origin!==t)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${t}`);n("Parent: Handshake - Received ACK");const g={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};h&&h(),h=((e,t,r)=>{const{localName:o,local:n,remote:i,originForSending:s,originForReceiving:d}=e;let v=!1;const h=e=>{if(e.source!==i||e.data.penpal!==a.Call)return;if(e.origin!==d)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:u,args:h,id:f}=n;r(`${o}: Received ${u}() call`);const p=e=>t=>{if(r(`${o}: Sending ${u}() reply`),v)return void r(`${o}: Unable to send ${u}() reply due to destroyed connection`);const n={penpal:a.Reply,id:f,resolution:e,returnValue:t};e===c.Rejected&&t instanceof Error&&(n.returnValue=m(t),n.returnValueIsError=!0);try{i.postMessage(n,s)}catch(e){if(e.name===l.DataCloneError){const t={penpal:a.Reply,id:f,resolution:c.Rejected,returnValue:m(e),returnValueIsError:!0};i.postMessage(t,s)}throw e}};new Promise(e=>e(t[u].apply(t,h))).then(p(c.Fulfilled),p(c.Rejected))};return n.addEventListener(u.Message,h),()=>{v=!0,n.removeEventListener(u.Message,h)}})(g,e,n),s(h),f&&f.forEach(e=>{delete p[e]}),f=o.data.methodNames;const w=((e,t,r,o,n)=>{const{localName:i,local:s,remote:l,originForSending:m,originForReceiving:h}=t;let f=!1;return n(i+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;n(`${i}: Sending ${e}() call`);try{l.closed&&(r=!0)}catch(e){r=!0}if(r&&o(),f){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=d.ConnectionDestroyed,t}return new Promise((r,o)=>{const d=++v,f=t=>{if(t.source!==l||t.data.penpal!==a.Reply||t.data.id!==d)return;if(t.origin!==h)return void n(`${i} received message from origin ${t.origin} which did not match expected origin ${h}`);const m=t.data;n(`${i}: Received ${e}() reply`),s.removeEventListener(u.Message,f);let v=m.returnValue;m.returnValueIsError&&(v=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(v)),(m.resolution===c.Fulfilled?r:o)(v)};s.addEventListener(u.Message,f),l.postMessage({penpal:a.Call,id:d,methodName:e,args:t},m)})})(t),e),e),()=>{f=!0}})(p,g,f,i,n);return s(w),p}})(r,o,k,g,p);return{promise:new Promise((e,r)=>{const o=((e,t)=>{let r;return void 0!==e&&(r=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=d.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(h,y),n=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==a.Syn)if(r.data.penpal!==a.Ack);else{const t=P(r);t&&(o(),e(t))}else E(r)};window.addEventListener(u.Message,n),p("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(t,g),w(e=>{window.removeEventListener(u.Message,n),e||((e=new Error("Connection destroyed")).code=d.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var t=e.token,r=e.origin,o=e.viewer;try{if(!t)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:t,origin:r})).then(function(e){if(!e.isValid)throw new Error(e.message?"Access token: "+(n={reason:e.message,token:t}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:r,token:t}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:o(h,w)[w].accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(o(h,w)[w]),!0})}catch(e){return Promise.reject(e)}})}var r=t.prototype;return r.loadScene=function(e){try{var t=this;return Promise.resolve(t.viewerReadyPromise).then(function(){return t.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},r.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},r.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},r.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},r.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},r.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},r.goToPersonMode=function(e){var t=void 0===e?{}:e,r=t.findSafeLanding,o=t.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===r||r,animate:void 0===o||o})},r.zoomExtents=function(e){var t=void 0===e?{}:e,r=t.spaceId,o=void 0===r?void 0:r,n=t.animate,i=void 0===n||n,s=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:s.width/s.height})},r.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},r.set=function(e){this.viewer.set(p(e))},r.on=function(e,t){return f++,o(this,y)[y].set(f,t),this.viewer.addListener(e,f),f},r.off=function(e){return this.viewer.removeListener(e)},t}(),exports.defaultEmbedOptions=g; |
@@ -1,1 +0,1 @@ | ||
var e=0;function t(t){return"__private_"+e+++"_"+t}function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},r=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,i=["file:","data:"];var a,s,c,d,l;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(a||(a={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(s||(s={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(c||(c={})),function(e){e.DataCloneError="DataCloneError"}(d||(d={})),function(e){e.Message="message"}(l||(l={}));const u=({name:e,message:t,stack:o})=>({name:e,message:t,stack:o});let m=0,h=0;const g=e=>JSON.parse(JSON.stringify(e));var p;!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(p||(p={}));const f={accessToken:void 0,transparentBackground:!0,presentationMode:p.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};var v=t("options"),w=t("listeners");export default class{constructor(e,t={}){var h=this;Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,w,{writable:!0,value:void 0}),o(this,w)[w]=new Map,this.handleEvent=(e,t)=>{const n=o(this,w)[w].get(e);if(n)return n(t);console.warn("Listener not found")},o(this,v)[v]=g({...f,...t}),this.containerEl=e,this.viewerEl=function(e=document.body,t){const o=document.createElement("iframe");return Object.assign(o,{src:"https://viewer.archilogic.com/v1_0_0?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(o),o}(e),this.viewerReadyPromise=(e=>{let{iframe:t,methods:o={},childOrigin:h,timeout:g,debug:p=!1}=e;const f=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(p),v=(()=>{const e=[];let t=!1;return{destroy(o){t=!0,e.forEach(e=>{e(o)})},onDestroy(o){t?o():e.push(o)}}})(),{onDestroy:w,destroy:y}=v;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=c.NoIframeSrc,e}})(t),h=(e=>{if(e&&i.find(t=>e.startsWith(t)))return"null";const t=document.location,o=r.exec(e);let a,s,c;return o?(a=o[1]?o[1]:t.protocol,s=o[2],c=o[4]):(a=t.protocol,s=t.hostname,c=t.port),`${a}//${s}${c&&c!==n[a]?":"+c:""}`})(t.src));const k="null"===h?"*":h,E=((e,t,o,n)=>r=>{if(r.origin!==o)return void e(`Parent: Handshake - Received SYN message from origin ${r.origin} which did not match expected origin ${o}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:a.SynAck,methodNames:Object.keys(t)};r.source.postMessage(i,n)})(f,o,h,k),$=((e,t,o,n,r)=>{const{destroy:i,onDestroy:h}=n;let g,p;const f={};return n=>{if(n.origin!==t)return void r(`Parent: Handshake - Received ACK message from origin ${n.origin} which did not match expected origin ${t}`);r("Parent: Handshake - Received ACK");const v={localName:"Parent",local:window,remote:n.source,originForSending:o,originForReceiving:t};g&&g(),g=((e,t,o)=>{const{localName:n,local:r,remote:i,originForSending:c,originForReceiving:m}=e;let h=!1;const g=e=>{if(e.source!==i||e.data.penpal!==a.Call)return;if(e.origin!==m)return void o(`${n} received message from origin ${e.origin} which did not match expected origin ${m}`);const r=e.data,{methodName:l,args:g,id:p}=r;o(`${n}: Received ${l}() call`);const f=e=>t=>{if(o(`${n}: Sending ${l}() reply`),h)return void o(`${n}: Unable to send ${l}() reply due to destroyed connection`);const r={penpal:a.Reply,id:p,resolution:e,returnValue:t};e===s.Rejected&&t instanceof Error&&(r.returnValue=u(t),r.returnValueIsError=!0);try{i.postMessage(r,c)}catch(e){if(e.name===d.DataCloneError){const t={penpal:a.Reply,id:p,resolution:s.Rejected,returnValue:u(e),returnValueIsError:!0};i.postMessage(t,c)}throw e}};new Promise(e=>e(t[l].apply(t,g))).then(f(s.Fulfilled),f(s.Rejected))};return r.addEventListener(l.Message,g),()=>{h=!0,r.removeEventListener(l.Message,g)}})(v,e,r),h(g),p&&p.forEach(e=>{delete f[e]}),p=n.data.methodNames;const w=((e,t,o,n,r)=>{const{localName:i,local:d,remote:u,originForSending:h,originForReceiving:g}=t;let p=!1;return r(i+": Connecting call sender"),o.reduce((e,t)=>(e[t]=(e=>(...t)=>{let o;r(`${i}: Sending ${e}() call`);try{u.closed&&(o=!0)}catch(e){o=!0}if(o&&n(),p){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=c.ConnectionDestroyed,t}return new Promise((o,n)=>{const c=++m,p=t=>{if(t.source!==u||t.data.penpal!==a.Reply||t.data.id!==c)return;if(t.origin!==g)return void r(`${i} received message from origin ${t.origin} which did not match expected origin ${g}`);const m=t.data;r(`${i}: Received ${e}() reply`),d.removeEventListener(l.Message,p);let h=m.returnValue;m.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(o=>t[o]=e[o]),t})(h)),(m.resolution===s.Fulfilled?o:n)(h)};d.addEventListener(l.Message,p),u.postMessage({penpal:a.Call,id:c,methodName:e,args:t},h)})})(t),e),e),()=>{p=!0}})(f,v,p,i,r);return h(w),f}})(o,h,k,v,f);return{promise:new Promise((e,o)=>{const n=((e,t)=>{let o;return void 0!==e&&(o=window.setTimeout(()=>{const o=new Error(`Connection timed out after ${e}ms`);o.code=c.ConnectionTimeout,t(o)},e)),()=>{clearTimeout(o)}})(g,y),r=o=>{if(o.source===t.contentWindow&&o.data)if(o.data.penpal!==a.Syn)if(o.data.penpal!==a.Ack);else{const t=$(o);t&&(n(),e(t))}else E(o)};window.addEventListener(l.Message,r),f("Parent: Awaiting handshake"),((e,t)=>{const{destroy:o,onDestroy:n}=t,r=setInterval(()=>{document.contains(e)||(clearInterval(r),o())},6e4);n(()=>{clearInterval(r)})})(t,v),w(e=>{window.removeEventListener(l.Message,r),e||((e=new Error("Connection destroyed")).code=c.ConnectionDestroyed),o(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(async function(e){return await async function({token:e,origin:t,viewer:o}){if(!e)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");const n={token:e,origin:t},r=await o.validateAccessToken(n);if(!r.isValid)throw new Error(r.message?(({token:e,reason:t})=>`Access token: ${e} is not valid: ${t}`)({reason:r.message.name,token:e}):(({token:e,origin:t})=>`Access token: ${e} is not valid for origin ${t}`)({origin:t,token:e}));return!0}({token:o(h,v)[v].accessToken,origin:window.location.origin,viewer:e}),h.viewer=e,h.viewer.set(o(h,v)[v]),!0})}async loadScene(e){return await this.viewerReadyPromise,this.viewer.loadScene(e)}async listBookmarks(){return this.viewer.listBookmarks()}async listSpaces(){return this.viewer.listSpaces()}async startPresentation(){return await this.viewerReadyPromise,this.viewer.startPresentation()}goToBookmark({bookmarkId:e,animate:t=!0}){return this.viewer.goToBookmark({bookmarkId:e,animate:t})}goToBirdMode({animate:e=!0}={}){return this.viewer.goToBirdMode({animate:e})}goToPersonMode({findSafeLanding:e=!0,animate:t=!0}={}){return this.viewer.goToPersonMode({findSafeLanding:e,animate:t})}zoomExtents({spaceId:e,animate:t=!0}={}){const o=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:e,animate:t,aspect:o.width/o.height})}toggleFullscreen(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()}set(e){this.viewer.set(g(e))}on(e,t){return h++,o(this,w)[w].set(h,t),this.viewer.addListener(e,h),h}off(e){return this.viewer.removeListener(e)}}export{p as PresentationMode,f as defaultEmbedOptions}; | ||
var e=0;function t(t){return"__private_"+e+++"_"+t}function o(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},r=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,i=["file:","data:"];var a,s,c,d,l;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(a||(a={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(s||(s={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(c||(c={})),function(e){e.DataCloneError="DataCloneError"}(d||(d={})),function(e){e.Message="message"}(l||(l={}));const u=({name:e,message:t,stack:o})=>({name:e,message:t,stack:o});let m=0,h=0;const g=e=>JSON.parse(JSON.stringify(e));var p;!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(p||(p={}));const f={accessToken:void 0,transparentBackground:!0,presentationMode:p.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}};var v=t("options"),w=t("listeners");export default class{constructor(e,t={}){var h=this;Object.defineProperty(this,v,{writable:!0,value:void 0}),Object.defineProperty(this,w,{writable:!0,value:void 0}),o(this,w)[w]=new Map,this.handleEvent=(e,t)=>{const n=o(this,w)[w].get(e);if(n)return n(t);console.warn("Listener not found")},o(this,v)[v]=g({...f,...t}),this.containerEl=e,this.viewerEl=function(e=document.body,t){const o=document.createElement("iframe");return Object.assign(o,{src:"https://viewer.archilogic.com/v1_0_2?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(o),o}(e),this.viewerReadyPromise=(e=>{let{iframe:t,methods:o={},childOrigin:h,timeout:g,debug:p=!1}=e;const f=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(p),v=(()=>{const e=[];let t=!1;return{destroy(o){t=!0,e.forEach(e=>{e(o)})},onDestroy(o){t?o():e.push(o)}}})(),{onDestroy:w,destroy:y}=v;h||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=c.NoIframeSrc,e}})(t),h=(e=>{if(e&&i.find(t=>e.startsWith(t)))return"null";const t=document.location,o=r.exec(e);let a,s,c;return o?(a=o[1]?o[1]:t.protocol,s=o[2],c=o[4]):(a=t.protocol,s=t.hostname,c=t.port),`${a}//${s}${c&&c!==n[a]?":"+c:""}`})(t.src));const k="null"===h?"*":h,E=((e,t,o,n)=>r=>{if(r.origin!==o)return void e(`Parent: Handshake - Received SYN message from origin ${r.origin} which did not match expected origin ${o}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:a.SynAck,methodNames:Object.keys(t)};r.source.postMessage(i,n)})(f,o,h,k),$=((e,t,o,n,r)=>{const{destroy:i,onDestroy:h}=n;let g,p;const f={};return n=>{if(n.origin!==t)return void r(`Parent: Handshake - Received ACK message from origin ${n.origin} which did not match expected origin ${t}`);r("Parent: Handshake - Received ACK");const v={localName:"Parent",local:window,remote:n.source,originForSending:o,originForReceiving:t};g&&g(),g=((e,t,o)=>{const{localName:n,local:r,remote:i,originForSending:c,originForReceiving:m}=e;let h=!1;const g=e=>{if(e.source!==i||e.data.penpal!==a.Call)return;if(e.origin!==m)return void o(`${n} received message from origin ${e.origin} which did not match expected origin ${m}`);const r=e.data,{methodName:l,args:g,id:p}=r;o(`${n}: Received ${l}() call`);const f=e=>t=>{if(o(`${n}: Sending ${l}() reply`),h)return void o(`${n}: Unable to send ${l}() reply due to destroyed connection`);const r={penpal:a.Reply,id:p,resolution:e,returnValue:t};e===s.Rejected&&t instanceof Error&&(r.returnValue=u(t),r.returnValueIsError=!0);try{i.postMessage(r,c)}catch(e){if(e.name===d.DataCloneError){const t={penpal:a.Reply,id:p,resolution:s.Rejected,returnValue:u(e),returnValueIsError:!0};i.postMessage(t,c)}throw e}};new Promise(e=>e(t[l].apply(t,g))).then(f(s.Fulfilled),f(s.Rejected))};return r.addEventListener(l.Message,g),()=>{h=!0,r.removeEventListener(l.Message,g)}})(v,e,r),h(g),p&&p.forEach(e=>{delete f[e]}),p=n.data.methodNames;const w=((e,t,o,n,r)=>{const{localName:i,local:d,remote:u,originForSending:h,originForReceiving:g}=t;let p=!1;return r(i+": Connecting call sender"),o.reduce((e,t)=>(e[t]=(e=>(...t)=>{let o;r(`${i}: Sending ${e}() call`);try{u.closed&&(o=!0)}catch(e){o=!0}if(o&&n(),p){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=c.ConnectionDestroyed,t}return new Promise((o,n)=>{const c=++m,p=t=>{if(t.source!==u||t.data.penpal!==a.Reply||t.data.id!==c)return;if(t.origin!==g)return void r(`${i} received message from origin ${t.origin} which did not match expected origin ${g}`);const m=t.data;r(`${i}: Received ${e}() reply`),d.removeEventListener(l.Message,p);let h=m.returnValue;m.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(o=>t[o]=e[o]),t})(h)),(m.resolution===s.Fulfilled?o:n)(h)};d.addEventListener(l.Message,p),u.postMessage({penpal:a.Call,id:c,methodName:e,args:t},h)})})(t),e),e),()=>{p=!0}})(f,v,p,i,r);return h(w),f}})(o,h,k,v,f);return{promise:new Promise((e,o)=>{const n=((e,t)=>{let o;return void 0!==e&&(o=window.setTimeout(()=>{const o=new Error(`Connection timed out after ${e}ms`);o.code=c.ConnectionTimeout,t(o)},e)),()=>{clearTimeout(o)}})(g,y),r=o=>{if(o.source===t.contentWindow&&o.data)if(o.data.penpal!==a.Syn)if(o.data.penpal!==a.Ack);else{const t=$(o);t&&(n(),e(t))}else E(o)};window.addEventListener(l.Message,r),f("Parent: Awaiting handshake"),((e,t)=>{const{destroy:o,onDestroy:n}=t,r=setInterval(()=>{document.contains(e)||(clearInterval(r),o())},6e4);n(()=>{clearInterval(r)})})(t,v),w(e=>{window.removeEventListener(l.Message,r),e||((e=new Error("Connection destroyed")).code=c.ConnectionDestroyed),o(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(async function(e){return await async function({token:e,origin:t,viewer:o}){if(!e)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");const n={token:e,origin:t},r=await o.validateAccessToken(n);if(!r.isValid)throw new Error(r.message?(({token:e,reason:t})=>`Access token: ${e} is not valid: ${t}`)({reason:r.message,token:e}):(({token:e,origin:t})=>`Access token: ${e} is not valid for origin ${t}`)({origin:t,token:e}));return!0}({token:o(h,v)[v].accessToken,origin:window.location.origin,viewer:e}),h.viewer=e,h.viewer.set(o(h,v)[v]),!0})}async loadScene(e){return await this.viewerReadyPromise,this.viewer.loadScene(e)}async listBookmarks(){return this.viewer.listBookmarks()}async listSpaces(){return this.viewer.listSpaces()}async startPresentation(){return await this.viewerReadyPromise,this.viewer.startPresentation()}goToBookmark({bookmarkId:e,animate:t=!0}){return this.viewer.goToBookmark({bookmarkId:e,animate:t})}goToBirdMode({animate:e=!0}={}){return this.viewer.goToBirdMode({animate:e})}goToPersonMode({findSafeLanding:e=!0,animate:t=!0}={}){return this.viewer.goToPersonMode({findSafeLanding:e,animate:t})}zoomExtents({spaceId:e,animate:t=!0}={}){const o=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:e,animate:t,aspect:o.width/o.height})}toggleFullscreen(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()}set(e){this.viewer.set(g(e))}on(e,t){return h++,o(this,w)[w].set(h,t),this.viewer.addListener(e,h),h}off(e){return this.viewer.removeListener(e)}}export{p as PresentationMode,f as defaultEmbedOptions}; |
@@ -1,1 +0,1 @@ | ||
function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}var r=0;function t(e){return"__private_"+r+++"_"+e}function o(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},i=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,a=["file:","data:"];var s,c,d,l,u;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(s||(s={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(c||(c={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(d||(d={})),function(e){e.DataCloneError="DataCloneError"}(l||(l={})),function(e){e.Message="message"}(u||(u={}));const m=({name:e,message:r,stack:t})=>({name:e,message:r,stack:t});let v=0;var h,f=0,p=function(e){return JSON.parse(JSON.stringify(e))};!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(h||(h={}));var g={accessToken:void 0,transparentBackground:!0,presentationMode:h.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},w=t("options"),y=t("listeners"),k=function(){function r(r,t){var h=this,f=this;void 0===t&&(t={}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),o(this,y)[y]=new Map,this.handleEvent=function(e,r){var t=o(f,y)[y].get(e);if(t)return t(r);console.warn("Listener not found")},o(this,w)[w]=p(e({},g,t)),this.containerEl=r,this.viewerEl=function(e,r){void 0===e&&(e=document.body);var t=document.createElement("iframe");return Object.assign(t,{src:"https://viewer.archilogic.com/v1_0_0?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(t),t}(r),this.viewerReadyPromise=(e=>{let{iframe:r,methods:t={},childOrigin:o,timeout:h,debug:f=!1}=e;const p=(e=>(...r)=>{e&&console.log("[Penpal]",...r)})(f),g=(()=>{const e=[];let r=!1;return{destroy(t){r=!0,e.forEach(e=>{e(t)})},onDestroy(t){r?t():e.push(t)}}})(),{onDestroy:w,destroy:y}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=d.NoIframeSrc,e}})(r),o=(e=>{if(e&&a.find(r=>e.startsWith(r)))return"null";const r=document.location,t=i.exec(e);let o,s,c;return t?(o=t[1]?t[1]:r.protocol,s=t[2],c=t[4]):(o=r.protocol,s=r.hostname,c=r.port),`${o}//${s}${c&&c!==n[o]?":"+c:""}`})(r.src));const k="null"===o?"*":o,E=((e,r,t,o)=>n=>{if(n.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:s.SynAck,methodNames:Object.keys(r)};n.source.postMessage(i,o)})(p,t,o,k),P=((e,r,t,o,n)=>{const{destroy:i,onDestroy:a}=o;let h,f;const p={};return o=>{if(o.origin!==r)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${r}`);n("Parent: Handshake - Received ACK");const g={localName:"Parent",local:window,remote:o.source,originForSending:t,originForReceiving:r};h&&h(),h=((e,r,t)=>{const{localName:o,local:n,remote:i,originForSending:a,originForReceiving:d}=e;let v=!1;const h=e=>{if(e.source!==i||e.data.penpal!==s.Call)return;if(e.origin!==d)return void t(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:u,args:h,id:f}=n;t(`${o}: Received ${u}() call`);const p=e=>r=>{if(t(`${o}: Sending ${u}() reply`),v)return void t(`${o}: Unable to send ${u}() reply due to destroyed connection`);const n={penpal:s.Reply,id:f,resolution:e,returnValue:r};e===c.Rejected&&r instanceof Error&&(n.returnValue=m(r),n.returnValueIsError=!0);try{i.postMessage(n,a)}catch(e){if(e.name===l.DataCloneError){const r={penpal:s.Reply,id:f,resolution:c.Rejected,returnValue:m(e),returnValueIsError:!0};i.postMessage(r,a)}throw e}};new Promise(e=>e(r[u].apply(r,h))).then(p(c.Fulfilled),p(c.Rejected))};return n.addEventListener(u.Message,h),()=>{v=!0,n.removeEventListener(u.Message,h)}})(g,e,n),a(h),f&&f.forEach(e=>{delete p[e]}),f=o.data.methodNames;const w=((e,r,t,o,n)=>{const{localName:i,local:a,remote:l,originForSending:m,originForReceiving:h}=r;let f=!1;return n(i+": Connecting call sender"),t.reduce((e,r)=>(e[r]=(e=>(...r)=>{let t;n(`${i}: Sending ${e}() call`);try{l.closed&&(t=!0)}catch(e){t=!0}if(t&&o(),f){const r=new Error(`Unable to send ${e}() call due to destroyed connection`);throw r.code=d.ConnectionDestroyed,r}return new Promise((t,o)=>{const d=++v,f=r=>{if(r.source!==l||r.data.penpal!==s.Reply||r.data.id!==d)return;if(r.origin!==h)return void n(`${i} received message from origin ${r.origin} which did not match expected origin ${h}`);const m=r.data;n(`${i}: Received ${e}() reply`),a.removeEventListener(u.Message,f);let v=m.returnValue;m.returnValueIsError&&(v=(e=>{const r=new Error;return Object.keys(e).forEach(t=>r[t]=e[t]),r})(v)),(m.resolution===c.Fulfilled?t:o)(v)};a.addEventListener(u.Message,f),l.postMessage({penpal:s.Call,id:d,methodName:e,args:r},m)})})(r),e),e),()=>{f=!0}})(p,g,f,i,n);return a(w),p}})(t,o,k,g,p);return{promise:new Promise((e,t)=>{const o=((e,r)=>{let t;return void 0!==e&&(t=window.setTimeout(()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=d.ConnectionTimeout,r(t)},e)),()=>{clearTimeout(t)}})(h,y),n=t=>{if(t.source===r.contentWindow&&t.data)if(t.data.penpal!==s.Syn)if(t.data.penpal!==s.Ack);else{const r=P(t);r&&(o(),e(r))}else E(t)};window.addEventListener(u.Message,n),p("Parent: Awaiting handshake"),((e,r)=>{const{destroy:t,onDestroy:o}=r,n=setInterval(()=>{document.contains(e)||(clearInterval(n),t())},6e4);o(()=>{clearInterval(n)})})(r,g),w(e=>{window.removeEventListener(u.Message,n),e||((e=new Error("Connection destroyed")).code=d.ConnectionDestroyed),t(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var r=e.token,t=e.origin,o=e.viewer;try{if(!r)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:r,origin:t})).then(function(e){if(!e.isValid)throw new Error(e.message?"Access token: "+(n={reason:e.message.name,token:r}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:t,token:r}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:o(h,w)[w].accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(o(h,w)[w]),!0})}catch(e){return Promise.reject(e)}})}var t=r.prototype;return t.loadScene=function(e){try{var r=this;return Promise.resolve(r.viewerReadyPromise).then(function(){return r.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},t.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},t.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},t.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},t.goToBookmark=function(e){var r=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===r||r})},t.goToBirdMode=function(e){var r=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===r||r})},t.goToPersonMode=function(e){var r=void 0===e?{}:e,t=r.findSafeLanding,o=r.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===t||t,animate:void 0===o||o})},t.zoomExtents=function(e){var r=void 0===e?{}:e,t=r.spaceId,o=void 0===t?void 0:t,n=r.animate,i=void 0===n||n,a=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:a.width/a.height})},t.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},t.set=function(e){this.viewer.set(p(e))},t.on=function(e,r){return f++,o(this,y)[y].set(f,r),this.viewer.addListener(e,f),f},t.off=function(e){return this.viewer.removeListener(e)},r}();export default k;export{h as PresentationMode,g as defaultEmbedOptions}; | ||
function e(){return(e=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e}).apply(this,arguments)}var r=0;function t(e){return"__private_"+r+++"_"+e}function o(e,r){if(!Object.prototype.hasOwnProperty.call(e,r))throw new TypeError("attempted to use private field on non-instance");return e}const n={"http:":"80","https:":"443"},i=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,a=["file:","data:"];var s,c,d,l,u;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(s||(s={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(c||(c={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(d||(d={})),function(e){e.DataCloneError="DataCloneError"}(l||(l={})),function(e){e.Message="message"}(u||(u={}));const m=({name:e,message:r,stack:t})=>({name:e,message:r,stack:t});let v=0;var h,f=0,p=function(e){return JSON.parse(JSON.stringify(e))};!function(e){e[e.none=0]="none",e[e.goToCameraDefault=1]="goToCameraDefault",e[e.goToFirstBookmark=2]="goToFirstBookmark",e[e.jumpToCameraDefault=3]="jumpToCameraDefault",e[e.jumpToFirstBookmark=4]="jumpToFirstBookmark",e[e.tourOnce=5]="tourOnce",e[e.tourOnceAndGoBack=6]="tourOnceAndGoBack",e[e.tourLoop=7]="tourLoop"}(h||(h={}));var g={accessToken:void 0,transparentBackground:!0,presentationMode:h.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},w=t("options"),y=t("listeners"),k=function(){function r(r,t){var h=this,f=this;void 0===t&&(t={}),Object.defineProperty(this,w,{writable:!0,value:void 0}),Object.defineProperty(this,y,{writable:!0,value:void 0}),o(this,y)[y]=new Map,this.handleEvent=function(e,r){var t=o(f,y)[y].get(e);if(t)return t(r);console.warn("Listener not found")},o(this,w)[w]=p(e({},g,t)),this.containerEl=r,this.viewerEl=function(e,r){void 0===e&&(e=document.body);var t=document.createElement("iframe");return Object.assign(t,{src:"https://viewer.archilogic.com/v1_0_2?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(t),t}(r),this.viewerReadyPromise=(e=>{let{iframe:r,methods:t={},childOrigin:o,timeout:h,debug:f=!1}=e;const p=(e=>(...r)=>{e&&console.log("[Penpal]",...r)})(f),g=(()=>{const e=[];let r=!1;return{destroy(t){r=!0,e.forEach(e=>{e(t)})},onDestroy(t){r?t():e.push(t)}}})(),{onDestroy:w,destroy:y}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=d.NoIframeSrc,e}})(r),o=(e=>{if(e&&a.find(r=>e.startsWith(r)))return"null";const r=document.location,t=i.exec(e);let o,s,c;return t?(o=t[1]?t[1]:r.protocol,s=t[2],c=t[4]):(o=r.protocol,s=r.hostname,c=r.port),`${o}//${s}${c&&c!==n[o]?":"+c:""}`})(r.src));const k="null"===o?"*":o,E=((e,r,t,o)=>n=>{if(n.origin!==t)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${t}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:s.SynAck,methodNames:Object.keys(r)};n.source.postMessage(i,o)})(p,t,o,k),P=((e,r,t,o,n)=>{const{destroy:i,onDestroy:a}=o;let h,f;const p={};return o=>{if(o.origin!==r)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${r}`);n("Parent: Handshake - Received ACK");const g={localName:"Parent",local:window,remote:o.source,originForSending:t,originForReceiving:r};h&&h(),h=((e,r,t)=>{const{localName:o,local:n,remote:i,originForSending:a,originForReceiving:d}=e;let v=!1;const h=e=>{if(e.source!==i||e.data.penpal!==s.Call)return;if(e.origin!==d)return void t(`${o} received message from origin ${e.origin} which did not match expected origin ${d}`);const n=e.data,{methodName:u,args:h,id:f}=n;t(`${o}: Received ${u}() call`);const p=e=>r=>{if(t(`${o}: Sending ${u}() reply`),v)return void t(`${o}: Unable to send ${u}() reply due to destroyed connection`);const n={penpal:s.Reply,id:f,resolution:e,returnValue:r};e===c.Rejected&&r instanceof Error&&(n.returnValue=m(r),n.returnValueIsError=!0);try{i.postMessage(n,a)}catch(e){if(e.name===l.DataCloneError){const r={penpal:s.Reply,id:f,resolution:c.Rejected,returnValue:m(e),returnValueIsError:!0};i.postMessage(r,a)}throw e}};new Promise(e=>e(r[u].apply(r,h))).then(p(c.Fulfilled),p(c.Rejected))};return n.addEventListener(u.Message,h),()=>{v=!0,n.removeEventListener(u.Message,h)}})(g,e,n),a(h),f&&f.forEach(e=>{delete p[e]}),f=o.data.methodNames;const w=((e,r,t,o,n)=>{const{localName:i,local:a,remote:l,originForSending:m,originForReceiving:h}=r;let f=!1;return n(i+": Connecting call sender"),t.reduce((e,r)=>(e[r]=(e=>(...r)=>{let t;n(`${i}: Sending ${e}() call`);try{l.closed&&(t=!0)}catch(e){t=!0}if(t&&o(),f){const r=new Error(`Unable to send ${e}() call due to destroyed connection`);throw r.code=d.ConnectionDestroyed,r}return new Promise((t,o)=>{const d=++v,f=r=>{if(r.source!==l||r.data.penpal!==s.Reply||r.data.id!==d)return;if(r.origin!==h)return void n(`${i} received message from origin ${r.origin} which did not match expected origin ${h}`);const m=r.data;n(`${i}: Received ${e}() reply`),a.removeEventListener(u.Message,f);let v=m.returnValue;m.returnValueIsError&&(v=(e=>{const r=new Error;return Object.keys(e).forEach(t=>r[t]=e[t]),r})(v)),(m.resolution===c.Fulfilled?t:o)(v)};a.addEventListener(u.Message,f),l.postMessage({penpal:s.Call,id:d,methodName:e,args:r},m)})})(r),e),e),()=>{f=!0}})(p,g,f,i,n);return a(w),p}})(t,o,k,g,p);return{promise:new Promise((e,t)=>{const o=((e,r)=>{let t;return void 0!==e&&(t=window.setTimeout(()=>{const t=new Error(`Connection timed out after ${e}ms`);t.code=d.ConnectionTimeout,r(t)},e)),()=>{clearTimeout(t)}})(h,y),n=t=>{if(t.source===r.contentWindow&&t.data)if(t.data.penpal!==s.Syn)if(t.data.penpal!==s.Ack);else{const r=P(t);r&&(o(),e(r))}else E(t)};window.addEventListener(u.Message,n),p("Parent: Awaiting handshake"),((e,r)=>{const{destroy:t,onDestroy:o}=r,n=setInterval(()=>{document.contains(e)||(clearInterval(n),t())},6e4);o(()=>{clearInterval(n)})})(r,g),w(e=>{window.removeEventListener(u.Message,n),e||((e=new Error("Connection destroyed")).code=d.ConnectionDestroyed),t(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var r=e.token,t=e.origin,o=e.viewer;try{if(!r)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:r,origin:t})).then(function(e){if(!e.isValid)throw new Error(e.message?"Access token: "+(n={reason:e.message,token:r}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:t,token:r}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:o(h,w)[w].accessToken,origin:window.location.origin,viewer:e})).then(function(){return h.viewer=e,h.viewer.set(o(h,w)[w]),!0})}catch(e){return Promise.reject(e)}})}var t=r.prototype;return t.loadScene=function(e){try{var r=this;return Promise.resolve(r.viewerReadyPromise).then(function(){return r.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},t.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},t.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},t.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},t.goToBookmark=function(e){var r=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===r||r})},t.goToBirdMode=function(e){var r=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===r||r})},t.goToPersonMode=function(e){var r=void 0===e?{}:e,t=r.findSafeLanding,o=r.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===t||t,animate:void 0===o||o})},t.zoomExtents=function(e){var r=void 0===e?{}:e,t=r.spaceId,o=void 0===t?void 0:t,n=r.animate,i=void 0===n||n,a=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:a.width/a.height})},t.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},t.set=function(e){this.viewer.set(p(e))},t.on=function(e,r){return f++,o(this,y)[y].set(f,r),this.viewer.addListener(e,f),f},t.off=function(e){return this.viewer.removeListener(e)},r}();export default k;export{h as PresentationMode,g as defaultEmbedOptions}; |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).embedApi={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}var r=0;function o(e){return"__private_"+r+++"_"+e}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const i={"http:":"80","https:":"443"},a=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,s=["file:","data:"];var c,d,l,u,m;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(c||(c={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(d||(d={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(l||(l={})),function(e){e.DataCloneError="DataCloneError"}(u||(u={})),function(e){e.Message="message"}(m||(m={}));const f=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let h=0;var v,p=0,g=function(e){return JSON.parse(JSON.stringify(e))};(v=e.PresentationMode||(e.PresentationMode={}))[v.none=0]="none",v[v.goToCameraDefault=1]="goToCameraDefault",v[v.goToFirstBookmark=2]="goToFirstBookmark",v[v.jumpToCameraDefault=3]="jumpToCameraDefault",v[v.jumpToFirstBookmark=4]="jumpToFirstBookmark",v[v.tourOnce=5]="tourOnce",v[v.tourOnceAndGoBack=6]="tourOnceAndGoBack",v[v.tourLoop=7]="tourLoop";var w={accessToken:void 0,transparentBackground:!0,presentationMode:e.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},y=o("options"),k=o("listeners");e.default=function(){function e(e,r){var o=this,v=this;void 0===r&&(r={}),Object.defineProperty(this,y,{writable:!0,value:void 0}),Object.defineProperty(this,k,{writable:!0,value:void 0}),n(this,k)[k]=new Map,this.handleEvent=function(e,t){var r=n(v,k)[k].get(e);if(r)return r(t);console.warn("Listener not found")},n(this,y)[y]=g(t({},w,r)),this.containerEl=e,this.viewerEl=function(e,t){void 0===e&&(e=document.body);var r=document.createElement("iframe");return Object.assign(r,{src:"https://viewer.archilogic.com/v1_0_0?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(r),r}(e),this.viewerReadyPromise=(e=>{let{iframe:t,methods:r={},childOrigin:o,timeout:n,debug:v=!1}=e;const p=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(v),g=(()=>{const e=[];let t=!1;return{destroy(r){t=!0,e.forEach(e=>{e(r)})},onDestroy(r){t?r():e.push(r)}}})(),{onDestroy:w,destroy:y}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=l.NoIframeSrc,e}})(t),o=(e=>{if(e&&s.find(t=>e.startsWith(t)))return"null";const t=document.location,r=a.exec(e);let o,n,c;return r?(o=r[1]?r[1]:t.protocol,n=r[2],c=r[4]):(o=t.protocol,n=t.hostname,c=t.port),`${o}//${n}${c&&c!==i[o]?":"+c:""}`})(t.src));const k="null"===o?"*":o,E=((e,t,r,o)=>n=>{if(n.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:c.SynAck,methodNames:Object.keys(t)};n.source.postMessage(i,o)})(p,r,o,k),P=((e,t,r,o,n)=>{const{destroy:i,onDestroy:a}=o;let s,v;const p={};return o=>{if(o.origin!==t)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${t}`);n("Parent: Handshake - Received ACK");const g={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};s&&s(),s=((e,t,r)=>{const{localName:o,local:n,remote:i,originForSending:a,originForReceiving:s}=e;let l=!1;const h=e=>{if(e.source!==i||e.data.penpal!==c.Call)return;if(e.origin!==s)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${s}`);const n=e.data,{methodName:m,args:h,id:v}=n;r(`${o}: Received ${m}() call`);const p=e=>t=>{if(r(`${o}: Sending ${m}() reply`),l)return void r(`${o}: Unable to send ${m}() reply due to destroyed connection`);const n={penpal:c.Reply,id:v,resolution:e,returnValue:t};e===d.Rejected&&t instanceof Error&&(n.returnValue=f(t),n.returnValueIsError=!0);try{i.postMessage(n,a)}catch(e){if(e.name===u.DataCloneError){const t={penpal:c.Reply,id:v,resolution:d.Rejected,returnValue:f(e),returnValueIsError:!0};i.postMessage(t,a)}throw e}};new Promise(e=>e(t[m].apply(t,h))).then(p(d.Fulfilled),p(d.Rejected))};return n.addEventListener(m.Message,h),()=>{l=!0,n.removeEventListener(m.Message,h)}})(g,e,n),a(s),v&&v.forEach(e=>{delete p[e]}),v=o.data.methodNames;const w=((e,t,r,o,n)=>{const{localName:i,local:a,remote:s,originForSending:u,originForReceiving:f}=t;let v=!1;return n(i+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;n(`${i}: Sending ${e}() call`);try{s.closed&&(r=!0)}catch(e){r=!0}if(r&&o(),v){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=l.ConnectionDestroyed,t}return new Promise((r,o)=>{const l=++h,v=t=>{if(t.source!==s||t.data.penpal!==c.Reply||t.data.id!==l)return;if(t.origin!==f)return void n(`${i} received message from origin ${t.origin} which did not match expected origin ${f}`);const u=t.data;n(`${i}: Received ${e}() reply`),a.removeEventListener(m.Message,v);let h=u.returnValue;u.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(h)),(u.resolution===d.Fulfilled?r:o)(h)};a.addEventListener(m.Message,v),s.postMessage({penpal:c.Call,id:l,methodName:e,args:t},u)})})(t),e),e),()=>{v=!0}})(p,g,v,i,n);return a(w),p}})(r,o,k,g,p);return{promise:new Promise((e,r)=>{const o=((e,t)=>{let r;return void 0!==e&&(r=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=l.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(n,y),i=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==c.Syn)if(r.data.penpal!==c.Ack);else{const t=P(r);t&&(o(),e(t))}else E(r)};window.addEventListener(m.Message,i),p("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(t,g),w(e=>{window.removeEventListener(m.Message,i),e||((e=new Error("Connection destroyed")).code=l.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var t=e.token,r=e.origin,o=e.viewer;try{if(!t)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:t,origin:r})).then(function(e){if(!e.isValid)throw new Error(e.message?"Access token: "+(n={reason:e.message.name,token:t}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:r,token:t}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:n(o,y)[y].accessToken,origin:window.location.origin,viewer:e})).then(function(){return o.viewer=e,o.viewer.set(n(o,y)[y]),!0})}catch(e){return Promise.reject(e)}})}var r=e.prototype;return r.loadScene=function(e){try{var t=this;return Promise.resolve(t.viewerReadyPromise).then(function(){return t.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},r.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},r.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},r.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},r.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},r.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},r.goToPersonMode=function(e){var t=void 0===e?{}:e,r=t.findSafeLanding,o=t.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===r||r,animate:void 0===o||o})},r.zoomExtents=function(e){var t=void 0===e?{}:e,r=t.spaceId,o=void 0===r?void 0:r,n=t.animate,i=void 0===n||n,a=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:a.width/a.height})},r.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},r.set=function(e){this.viewer.set(g(e))},r.on=function(e,t){return p++,n(this,k)[k].set(p,t),this.viewer.addListener(e,p),p},r.off=function(e){return this.viewer.removeListener(e)},e}(),e.defaultEmbedOptions=w}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).embedApi={})}(this,function(e){function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(e[o]=r[o])}return e}).apply(this,arguments)}var r=0;function o(e){return"__private_"+r+++"_"+e}function n(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw new TypeError("attempted to use private field on non-instance");return e}const i={"http:":"80","https:":"443"},a=/^(https?:)?\/\/([^/:]+)?(:(\d+))?/,s=["file:","data:"];var c,d,l,u,m;!function(e){e.Call="call",e.Reply="reply",e.Syn="syn",e.SynAck="synAck",e.Ack="ack"}(c||(c={})),function(e){e.Fulfilled="fulfilled",e.Rejected="rejected"}(d||(d={})),function(e){e.ConnectionDestroyed="ConnectionDestroyed",e.ConnectionTimeout="ConnectionTimeout",e.NotInIframe="NotInIframe",e.NoIframeSrc="NoIframeSrc"}(l||(l={})),function(e){e.DataCloneError="DataCloneError"}(u||(u={})),function(e){e.Message="message"}(m||(m={}));const f=({name:e,message:t,stack:r})=>({name:e,message:t,stack:r});let h=0;var v,p=0,g=function(e){return JSON.parse(JSON.stringify(e))};(v=e.PresentationMode||(e.PresentationMode={}))[v.none=0]="none",v[v.goToCameraDefault=1]="goToCameraDefault",v[v.goToFirstBookmark=2]="goToFirstBookmark",v[v.jumpToCameraDefault=3]="jumpToCameraDefault",v[v.jumpToFirstBookmark=4]="jumpToFirstBookmark",v[v.tourOnce=5]="tourOnce",v[v.tourOnceAndGoBack=6]="tourOnceAndGoBack",v[v.tourLoop=7]="tourLoop";var w={accessToken:void 0,transparentBackground:!0,presentationMode:e.PresentationMode.jumpToCameraDefault,showTitle:!1,showLogo:!1,minimap:!1,uiButtons:{birdMode:!1,personMode:!1,fullscreen:!1,bookmarkStrip:!1,share:!1,help:!1,presentation:!1}},y=o("options"),k=o("listeners");e.default=function(){function e(e,r){var o=this,v=this;void 0===r&&(r={}),Object.defineProperty(this,y,{writable:!0,value:void 0}),Object.defineProperty(this,k,{writable:!0,value:void 0}),n(this,k)[k]=new Map,this.handleEvent=function(e,t){var r=n(v,k)[k].get(e);if(r)return r(t);console.warn("Listener not found")},n(this,y)[y]=g(t({},w,r)),this.containerEl=e,this.viewerEl=function(e,t){void 0===e&&(e=document.body);var r=document.createElement("iframe");return Object.assign(r,{src:"https://viewer.archilogic.com/v1_0_2?embedType=api",width:"100%",height:"100%",title:"Archilogic Embed",frameBorder:"0",scrolling:"no",allowTransparency:"true",allowFullscreen:"true",style:"border: 0;"}),e.appendChild(r),r}(e),this.viewerReadyPromise=(e=>{let{iframe:t,methods:r={},childOrigin:o,timeout:n,debug:v=!1}=e;const p=(e=>(...t)=>{e&&console.log("[Penpal]",...t)})(v),g=(()=>{const e=[];let t=!1;return{destroy(r){t=!0,e.forEach(e=>{e(r)})},onDestroy(r){t?r():e.push(r)}}})(),{onDestroy:w,destroy:y}=g;o||((e=>{if(!e.src&&!e.srcdoc){const e=new Error("Iframe must have src or srcdoc property defined.");throw e.code=l.NoIframeSrc,e}})(t),o=(e=>{if(e&&s.find(t=>e.startsWith(t)))return"null";const t=document.location,r=a.exec(e);let o,n,c;return r?(o=r[1]?r[1]:t.protocol,n=r[2],c=r[4]):(o=t.protocol,n=t.hostname,c=t.port),`${o}//${n}${c&&c!==i[o]?":"+c:""}`})(t.src));const k="null"===o?"*":o,E=((e,t,r,o)=>n=>{if(n.origin!==r)return void e(`Parent: Handshake - Received SYN message from origin ${n.origin} which did not match expected origin ${r}`);e("Parent: Handshake - Received SYN, responding with SYN-ACK");const i={penpal:c.SynAck,methodNames:Object.keys(t)};n.source.postMessage(i,o)})(p,r,o,k),P=((e,t,r,o,n)=>{const{destroy:i,onDestroy:a}=o;let s,v;const p={};return o=>{if(o.origin!==t)return void n(`Parent: Handshake - Received ACK message from origin ${o.origin} which did not match expected origin ${t}`);n("Parent: Handshake - Received ACK");const g={localName:"Parent",local:window,remote:o.source,originForSending:r,originForReceiving:t};s&&s(),s=((e,t,r)=>{const{localName:o,local:n,remote:i,originForSending:a,originForReceiving:s}=e;let l=!1;const h=e=>{if(e.source!==i||e.data.penpal!==c.Call)return;if(e.origin!==s)return void r(`${o} received message from origin ${e.origin} which did not match expected origin ${s}`);const n=e.data,{methodName:m,args:h,id:v}=n;r(`${o}: Received ${m}() call`);const p=e=>t=>{if(r(`${o}: Sending ${m}() reply`),l)return void r(`${o}: Unable to send ${m}() reply due to destroyed connection`);const n={penpal:c.Reply,id:v,resolution:e,returnValue:t};e===d.Rejected&&t instanceof Error&&(n.returnValue=f(t),n.returnValueIsError=!0);try{i.postMessage(n,a)}catch(e){if(e.name===u.DataCloneError){const t={penpal:c.Reply,id:v,resolution:d.Rejected,returnValue:f(e),returnValueIsError:!0};i.postMessage(t,a)}throw e}};new Promise(e=>e(t[m].apply(t,h))).then(p(d.Fulfilled),p(d.Rejected))};return n.addEventListener(m.Message,h),()=>{l=!0,n.removeEventListener(m.Message,h)}})(g,e,n),a(s),v&&v.forEach(e=>{delete p[e]}),v=o.data.methodNames;const w=((e,t,r,o,n)=>{const{localName:i,local:a,remote:s,originForSending:u,originForReceiving:f}=t;let v=!1;return n(i+": Connecting call sender"),r.reduce((e,t)=>(e[t]=(e=>(...t)=>{let r;n(`${i}: Sending ${e}() call`);try{s.closed&&(r=!0)}catch(e){r=!0}if(r&&o(),v){const t=new Error(`Unable to send ${e}() call due to destroyed connection`);throw t.code=l.ConnectionDestroyed,t}return new Promise((r,o)=>{const l=++h,v=t=>{if(t.source!==s||t.data.penpal!==c.Reply||t.data.id!==l)return;if(t.origin!==f)return void n(`${i} received message from origin ${t.origin} which did not match expected origin ${f}`);const u=t.data;n(`${i}: Received ${e}() reply`),a.removeEventListener(m.Message,v);let h=u.returnValue;u.returnValueIsError&&(h=(e=>{const t=new Error;return Object.keys(e).forEach(r=>t[r]=e[r]),t})(h)),(u.resolution===d.Fulfilled?r:o)(h)};a.addEventListener(m.Message,v),s.postMessage({penpal:c.Call,id:l,methodName:e,args:t},u)})})(t),e),e),()=>{v=!0}})(p,g,v,i,n);return a(w),p}})(r,o,k,g,p);return{promise:new Promise((e,r)=>{const o=((e,t)=>{let r;return void 0!==e&&(r=window.setTimeout(()=>{const r=new Error(`Connection timed out after ${e}ms`);r.code=l.ConnectionTimeout,t(r)},e)),()=>{clearTimeout(r)}})(n,y),i=r=>{if(r.source===t.contentWindow&&r.data)if(r.data.penpal!==c.Syn)if(r.data.penpal!==c.Ack);else{const t=P(r);t&&(o(),e(t))}else E(r)};window.addEventListener(m.Message,i),p("Parent: Awaiting handshake"),((e,t)=>{const{destroy:r,onDestroy:o}=t,n=setInterval(()=>{document.contains(e)||(clearInterval(n),r())},6e4);o(()=>{clearInterval(n)})})(t,g),w(e=>{window.removeEventListener(m.Message,i),e||((e=new Error("Connection destroyed")).code=l.ConnectionDestroyed),r(e)})}),destroy(){y()}}})({iframe:this.viewerEl,methods:{handleEvent:this.handleEvent}}).promise.then(function(e){try{return Promise.resolve(function(e){var t=e.token,r=e.origin,o=e.viewer;try{if(!t)throw new Error("Error: You need to include a valid access token, to create a new access token visit https://developers.archilogic.com");return Promise.resolve(o.validateAccessToken({token:t,origin:r})).then(function(e){if(!e.isValid)throw new Error(e.message?"Access token: "+(n={reason:e.message,token:t}).token+" is not valid: "+n.reason:"Access token: "+(o={origin:r,token:t}).token+" is not valid for origin "+o.origin);var o,n;return!0})}catch(e){return Promise.reject(e)}}({token:n(o,y)[y].accessToken,origin:window.location.origin,viewer:e})).then(function(){return o.viewer=e,o.viewer.set(n(o,y)[y]),!0})}catch(e){return Promise.reject(e)}})}var r=e.prototype;return r.loadScene=function(e){try{var t=this;return Promise.resolve(t.viewerReadyPromise).then(function(){return t.viewer.loadScene(e)})}catch(e){return Promise.reject(e)}},r.listBookmarks=function(){try{return Promise.resolve(this.viewer.listBookmarks())}catch(e){return Promise.reject(e)}},r.listSpaces=function(){try{return Promise.resolve(this.viewer.listSpaces())}catch(e){return Promise.reject(e)}},r.startPresentation=function(){try{var e=this;return Promise.resolve(e.viewerReadyPromise).then(function(){return e.viewer.startPresentation()})}catch(e){return Promise.reject(e)}},r.goToBookmark=function(e){var t=e.animate;return this.viewer.goToBookmark({bookmarkId:e.bookmarkId,animate:void 0===t||t})},r.goToBirdMode=function(e){var t=(void 0===e?{}:e).animate;return this.viewer.goToBirdMode({animate:void 0===t||t})},r.goToPersonMode=function(e){var t=void 0===e?{}:e,r=t.findSafeLanding,o=t.animate;return this.viewer.goToPersonMode({findSafeLanding:void 0===r||r,animate:void 0===o||o})},r.zoomExtents=function(e){var t=void 0===e?{}:e,r=t.spaceId,o=void 0===r?void 0:r,n=t.animate,i=void 0===n||n,a=this.viewerEl.getBoundingClientRect();return this.viewer.zoomExtents({spaceId:o,animate:i,aspect:a.width/a.height})},r.toggleFullscreen=function(){return document.fullscreenElement&&document.fullscreenElement===this.containerEl?document.exitFullscreen():this.containerEl.requestFullscreen()},r.set=function(e){this.viewer.set(g(e))},r.on=function(e,t){return p++,n(this,k)[k].set(p,t),this.viewer.addListener(e,p),p},r.off=function(e){return this.viewer.removeListener(e)},e}(),e.defaultEmbedOptions=w}); |
{ | ||
"name": "@archilogic/embed-api", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "source": "src/embed.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38005
1