@londondynamics/pericles-webcomponent 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configurator.cjs +2 -2
- package/dist/configurator.js +19 -16
- package/package.json +1 -1
package/dist/configurator.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2019 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
-
*/const
|
|
5
|
+
*/const T=globalThis,q=T.ShadowRoot&&(T.ShadyCSS===void 0||T.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,J=Symbol(),F=new WeakMap;let it=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==J)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(q&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=F.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&F.set(e,t))}return t}toString(){return this.cssText}};const pt=i=>new it(typeof i=="string"?i:i+"",void 0,J),ct=(i,...t)=>{const e=i.length===1?i[0]:t.reduce((s,r,n)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+i[n+1],i[0]);return new it(e,i,J)},ut=(i,t)=>{if(q)i.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),r=T.litNonce;r!==void 0&&s.setAttribute("nonce",r),s.textContent=e.cssText,i.appendChild(s)}},V=q?i=>i:i=>i instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return pt(e)})(i):i;/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2017 Google LLC
|
|
26
26
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
-
*/const Ot={attribute:!0,type:String,converter:H,reflect:!1,hasChanged:W},Rt=(i=Ot,t,e)=>{const{kind:s,metadata:r}=e;let n=globalThis.litPropertyMetadata.get(r);if(n===void 0&&globalThis.litPropertyMetadata.set(r,n=new Map),n.set(e.name,i),s==="accessor"){const{name:o}=e;return{set(p){const a=t.get.call(this);t.set.call(this,p),this.requestUpdate(o,a,i)},init(p){return p!==void 0&&this.P(o,void 0,i),p}}}if(s==="setter"){const{name:o}=e;return function(p){const a=this[o];t.call(this,p),this.requestUpdate(o,a,i)}}throw Error("Unsupported decorator location: "+s)};function l(i){return(t,e)=>typeof e=="object"?Rt(i,t,e):((s,r,n)=>{const o=r.hasOwnProperty(n);return r.constructor.createProperty(n,o?{...s,wrapped:!0}:s),o?Object.getOwnPropertyDescriptor(r,n):void 0})(i,t,e)}const Nt=["allow-partial-match","ar-placement","background-color","camera-orbit-sensitivity","camera-transition-duration","disable-retries","disable-scroll-wheel","enable-dark-mode","highlight-color","interaction-prompt-style","lights","list-bullet-alignment","list-bullet-leading-zeros","list-bullet-style","qr-url-pattern","rotation","ruler-unit","shadow-intensity","shadow-softness","show-ar-button","show-ar-button-label","show-configurator","show-contexts","show-configurator-mobile","show-hotspots","show-interaction-prompt","show-light-switch","show-ruler-button","show-pivot-button","show-presets","start-frame","tone-mapping","zoom-type"],
|
|
27
|
+
*/const Ot={attribute:!0,type:String,converter:H,reflect:!1,hasChanged:W},Rt=(i=Ot,t,e)=>{const{kind:s,metadata:r}=e;let n=globalThis.litPropertyMetadata.get(r);if(n===void 0&&globalThis.litPropertyMetadata.set(r,n=new Map),n.set(e.name,i),s==="accessor"){const{name:o}=e;return{set(p){const a=t.get.call(this);t.set.call(this,p),this.requestUpdate(o,a,i)},init(p){return p!==void 0&&this.P(o,void 0,i),p}}}if(s==="setter"){const{name:o}=e;return function(p){const a=this[o];t.call(this,p),this.requestUpdate(o,a,i)}}throw Error("Unsupported decorator location: "+s)};function l(i){return(t,e)=>typeof e=="object"?Rt(i,t,e):((s,r,n)=>{const o=r.hasOwnProperty(n);return r.constructor.createProperty(n,o?{...s,wrapped:!0}:s),o?Object.getOwnPropertyDescriptor(r,n):void 0})(i,t,e)}const Nt=["allow-partial-match","ar-placement","background-color","camera-orbit-sensitivity","camera-transition-duration","disable-retries","disable-scroll-wheel","enable-dark-mode","highlight-color","interaction-prompt-style","lights","list-bullet-alignment","list-bullet-leading-zeros","list-bullet-style","qr-url-pattern","rotation","ruler-unit","shadow-intensity","shadow-softness","show-ar-button","show-ar-button-label","show-configurator","show-contexts","show-configurator-mobile","show-hotspots","show-interaction-prompt","show-light-switch","show-ruler-button","show-pivot-button","show-presets","start-frame","tone-mapping","zoom-type"],kt=i=>i.replace(/([-_]\w)/g,t=>t[1].toUpperCase()),Tt=i=>{const t=kt(i);return t.includes("showAr")?t.replace("showAr","showAR"):t},Ht=i=>{let t=new URLSearchParams;return Nt.forEach(e=>{if(i.hasAttribute(e)){let s=i.getAttribute(e);if(!s)return;s==="yes"&&(s="true"),s==="no"&&(s="false"),t.append(Tt(e),s)}}),t};var It=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,h=(i,t,e,s)=>{for(var r=s>1?void 0:s?Lt(t,e):t,n=i.length-1,o;n>=0;n--)(o=i[n])&&(r=(s?o(t,e,r):o(r))||r);return s&&r&&It(t,e,r),r};const jt="{host}{viewer}/by_scene_id/{scene_id}",Dt="{host}{viewer}/by_product_id/{customer_id}/{product_id}",zt="{host}{viewer}/by_product_id/{customer_id}/{sku}",Bt="{host}{viewer}/by_hash/{customer_id}/{hash}";function k(i,t){var e=new RegExp(Object.keys(t).join("|"),"gi");return i.replace(e,function(s){return t[s.toLowerCase()]})}exports.Configurator=class extends M{constructor(){super(...arguments),this.customerId=void 0,this.viewer="realtime",this.host="https://configurator.v2.londondynamics.com",this.defaultSelection={},this.getCurrentSelection=t=>this._pingpongPostMessage({type:"currentValues"},t),this._emit=(t,e)=>{this.dispatchEvent(new CustomEvent(t,{detail:e,bubbles:!0,composed:!0}))},this._pingpongPostMessage=(t,e)=>new Promise((s,r)=>{var a,d;const n={...t,messageId:Date.now()},o=u=>{if(u.origin===this.host&&u.data.messageId===n.messageId&&u.data.type===n.type){try{e?e(JSON.parse(u.data.result)):s(JSON.parse(u.data.result))}catch(c){c instanceof Error?e?e({},c.message):r(c.message):e?e({},"Unknown error"):r("Unknown error")}window.removeEventListener("message",o)}},p=(a=this.shadowRoot)==null?void 0:a.querySelector("iframe");p&&(window.addEventListener("message",o),(d=p.contentWindow)==null||d.postMessage(n,"*"))}),this._handleMessage=t=>{var e;if(t.origin===this.host&&(e=t==null?void 0:t.data)!=null&&e.type)switch(t.data.type){case"ready":this._emit("ready",{options:JSON.parse(t.data.options),presets:JSON.parse(t.data.presets),scene:JSON.parse(t.data.scene)});break;case"load":this._emit("load",JSON.parse(t.data.values));break;case"error":this._emit("error",JSON.parse(t.data.values));break;case"change":this._emit("change",JSON.parse(t.data.values));break;case"cameraChange":this._emit("camerachange",JSON.parse(t.data.values));break;case"log":const{logType:s,logData:r}=t.data;this._emit(s,JSON.parse(r));break}}}getCurrentConfiguration(t){return this._pingpongPostMessage({type:"currentConfig"},t)}getCurrentScene(t){return this._pingpongPostMessage({type:"currentScene"},t)}getCurrentHash(t){return this._pingpongPostMessage({type:"currentHash"},t)}getCurrentSource(t){return this._pingpongPostMessage({type:"currentSource"},t)}getCurrentARSource(t){return this._pingpongPostMessage({type:"currentARSource"},t)}getDataURL(t){return this._pingpongPostMessage({type:"dataURL"},t)}getFrame(t,e,s){return this._pingpongPostMessage({type:"getFrame",index:t,options:e},s)}setFeature(t,e){this._postMessage({type:"setFeature",featureId:t,variantId:e,allowPartialMatch:this.allowPartialMatch})}setSelection(t,e){this._postMessage({type:"setSelection",selection:t,resetBeforeUpdate:e,allowPartialMatch:this.allowPartialMatch})}setContext(t){this._postMessage({type:"setPreset",presetId:t})}resetCamera(){this._postMessage({type:"resetCamera"})}toggleLights(t){this._postMessage({type:"toggleLights",value:t})}toggleGroup(t){this._postMessage({type:"toggleGroup",value:t})}toggleHotspot(t){this._postMessage({type:"toggleGroup",groupId:t})}setRotation(t=[0,0,0],e="deg"){this._postMessage({type:"setRotation",rotation:t,angularUnit:e})}setCamera(t={},e={}){this._postMessage({type:"setCamera",...t,...e})}_postMessage(t){var s,r;const e=(s=this.shadowRoot)==null?void 0:s.querySelector("iframe");e&&((r=e.contentWindow)==null||r.postMessage(t,"*"))}connectedCallback(){super.connectedCallback();const t=this.querySelector('script[type="application/json"]');if(t&&t.textContent)try{this.defaultSelection=JSON.parse(t.textContent)}catch(e){typeof e=="object"&&e instanceof Error?console.warn(`Error parsing selection: ${e.message}. Using default selection instead.`):console.warn("Error parsing selection. Using default selection instead.")}window.addEventListener("message",this._handleMessage)}disconnectedCallback(){window.removeEventListener("message",this._handleMessage),super.disconnectedCallback()}render(){let t=null,e=null;if(console.log("this.defaultSelection?",this.defaultSelection),this.host?this.customerId?this.hash?e=k(Bt,{"{viewer}":"","{host}":this.host,"{customer_id}":this.customerId,"{hash}":this.hash}):this.sceneId?e=k(jt,{"{viewer}":this.viewer==="360"?"/360":"","{host}":this.host,"{customer_id}":this.customerId,"{scene_id}":this.sceneId}):this.sku?e=k(zt,{"{viewer}":this.viewer==="360"?"/360":"","{host}":this.host,"{customer_id}":this.customerId,"{sku}":this.sku}):this.productId?e=k(Dt,{"{viewer}":this.viewer==="360"?"/360":"","{host}":this.host,"{customer_id}":this.customerId,"{product_id}":this.productId}):t="Missing property: sku, scene-id, or hash":t="Missing property: customer-id":t="Missing property: host",t)return et`<div>${t}</div>`;let s="";return Object.keys(this.defaultSelection).length>0&&(s+=new URLSearchParams(this.defaultSelection).toString()),this.hasAttributes()&&(Object.keys(this.defaultSelection).length>0&&(s+="&"),s+=Ht(this)),s.length&&(e+="?"+s),et`<iframe
|
|
28
28
|
src="${e}"
|
|
29
29
|
width="100%"
|
|
30
30
|
height="100%"
|
package/dist/configurator.js
CHANGED
|
@@ -51,7 +51,7 @@ const ct = (s) => new ot(typeof s == "string" ? s : s + "", void 0, W), dt = (s,
|
|
|
51
51
|
* Copyright 2017 Google LLC
|
|
52
52
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
53
53
|
*/
|
|
54
|
-
const { is: gt, defineProperty: yt, getOwnPropertyDescriptor: _t, getOwnPropertyNames: ft, getOwnPropertySymbols: mt, getPrototypeOf: $t } = Object, $ = globalThis, K = $.trustedTypes, wt = K ? K.emptyScript : "",
|
|
54
|
+
const { is: gt, defineProperty: yt, getOwnPropertyDescriptor: _t, getOwnPropertyNames: ft, getOwnPropertySymbols: mt, getPrototypeOf: $t } = Object, $ = globalThis, K = $.trustedTypes, wt = K ? K.emptyScript : "", D = $.reactiveElementPolyfillSupport, C = (s, t) => s, I = { toAttribute(s, t) {
|
|
55
55
|
switch (t) {
|
|
56
56
|
case Boolean:
|
|
57
57
|
s = s ? wt : null;
|
|
@@ -292,7 +292,7 @@ class A extends HTMLElement {
|
|
|
292
292
|
firstUpdated(t) {
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
|
-
A.elementStyles = [], A.shadowRootOptions = { mode: "open" }, A[C("elementProperties")] = /* @__PURE__ */ new Map(), A[C("finalized")] = /* @__PURE__ */ new Map(),
|
|
295
|
+
A.elementStyles = [], A.shadowRootOptions = { mode: "open" }, A[C("elementProperties")] = /* @__PURE__ */ new Map(), A[C("finalized")] = /* @__PURE__ */ new Map(), D == null || D({ ReactiveElement: A }), ($.reactiveElementVersions ?? ($.reactiveElementVersions = [])).push("2.0.4");
|
|
296
296
|
/**
|
|
297
297
|
* @license
|
|
298
298
|
* Copyright 2017 Google LLC
|
|
@@ -335,7 +335,7 @@ class R {
|
|
|
335
335
|
for (const u of r.getAttributeNames())
|
|
336
336
|
if (u.endsWith(nt)) {
|
|
337
337
|
const _ = g[o++], f = r.getAttribute(u).split(m), k = /([.?@])?(.*)/.exec(_);
|
|
338
|
-
a.push({ type: 1, index: n, name: k[2], strings: f, ctor: k[1] === "." ? Pt : k[1] === "?" ? Ct : k[1] === "@" ? Mt :
|
|
338
|
+
a.push({ type: 1, index: n, name: k[2], strings: f, ctor: k[1] === "." ? Pt : k[1] === "?" ? Ct : k[1] === "@" ? Mt : j }), r.removeAttribute(u);
|
|
339
339
|
} else
|
|
340
340
|
u.startsWith(m) && (a.push({ type: 6, index: n }), r.removeAttribute(u));
|
|
341
341
|
if (lt.test(r.tagName)) {
|
|
@@ -465,7 +465,7 @@ class N {
|
|
|
465
465
|
this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
class
|
|
468
|
+
class j {
|
|
469
469
|
get tagName() {
|
|
470
470
|
return this.element.tagName;
|
|
471
471
|
}
|
|
@@ -492,7 +492,7 @@ class D {
|
|
|
492
492
|
t === y ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
-
class Pt extends
|
|
495
|
+
class Pt extends j {
|
|
496
496
|
constructor() {
|
|
497
497
|
super(...arguments), this.type = 3;
|
|
498
498
|
}
|
|
@@ -500,7 +500,7 @@ class Pt extends D {
|
|
|
500
500
|
this.element[this.name] = t === y ? void 0 : t;
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
-
class Ct extends
|
|
503
|
+
class Ct extends j {
|
|
504
504
|
constructor() {
|
|
505
505
|
super(...arguments), this.type = 4;
|
|
506
506
|
}
|
|
@@ -508,7 +508,7 @@ class Ct extends D {
|
|
|
508
508
|
this.element.toggleAttribute(this.name, !!t && t !== y);
|
|
509
509
|
}
|
|
510
510
|
}
|
|
511
|
-
class Mt extends
|
|
511
|
+
class Mt extends j {
|
|
512
512
|
constructor(t, e, i, r, n) {
|
|
513
513
|
super(t, e, i, r, n), this.type = 5;
|
|
514
514
|
}
|
|
@@ -657,22 +657,25 @@ const kt = [
|
|
|
657
657
|
"tone-mapping",
|
|
658
658
|
"zoom-type"
|
|
659
659
|
], Tt = (s) => s.replace(/([-_]\w)/g, (t) => t[1].toUpperCase()), Ht = (s) => {
|
|
660
|
+
const t = Tt(s);
|
|
661
|
+
return t.includes("showAr") ? t.replace("showAr", "showAR") : t;
|
|
662
|
+
}, It = (s) => {
|
|
660
663
|
let t = new URLSearchParams();
|
|
661
664
|
return kt.forEach((e) => {
|
|
662
665
|
if (s.hasAttribute(e)) {
|
|
663
666
|
let i = s.getAttribute(e);
|
|
664
667
|
if (!i)
|
|
665
668
|
return;
|
|
666
|
-
i === "yes" && (i = "true"), i === "no" && (i = "false"), t.append(
|
|
669
|
+
i === "yes" && (i = "true"), i === "no" && (i = "false"), t.append(Ht(e), i);
|
|
667
670
|
}
|
|
668
671
|
}), t;
|
|
669
672
|
};
|
|
670
|
-
var
|
|
671
|
-
for (var r = i > 1 ? void 0 : i ?
|
|
673
|
+
var Lt = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, l = (s, t, e, i) => {
|
|
674
|
+
for (var r = i > 1 ? void 0 : i ? jt(t, e) : t, n = s.length - 1, o; n >= 0; n--)
|
|
672
675
|
(o = s[n]) && (r = (i ? o(t, e, r) : o(r)) || r);
|
|
673
|
-
return i && r &&
|
|
676
|
+
return i && r && Lt(t, e, r), r;
|
|
674
677
|
};
|
|
675
|
-
const Dt = "{host}{viewer}/by_scene_id/{scene_id}",
|
|
678
|
+
const Dt = "{host}{viewer}/by_scene_id/{scene_id}", zt = "{host}{viewer}/by_product_id/{customer_id}/{product_id}", Bt = "{host}{viewer}/by_product_id/{customer_id}/{sku}", qt = "{host}{viewer}/by_hash/{customer_id}/{hash}";
|
|
676
679
|
function T(s, t) {
|
|
677
680
|
var e = new RegExp(Object.keys(t).join("|"), "gi");
|
|
678
681
|
return s.replace(e, function(i) {
|
|
@@ -992,7 +995,7 @@ let h = class extends U {
|
|
|
992
995
|
}
|
|
993
996
|
render() {
|
|
994
997
|
let s = null, t = null;
|
|
995
|
-
if (console.log("this.defaultSelection?", this.defaultSelection), this.host ? this.customerId ? this.hash ? t = T(
|
|
998
|
+
if (console.log("this.defaultSelection?", this.defaultSelection), this.host ? this.customerId ? this.hash ? t = T(qt, {
|
|
996
999
|
"{viewer}": "",
|
|
997
1000
|
"{host}": this.host,
|
|
998
1001
|
"{customer_id}": this.customerId,
|
|
@@ -1002,12 +1005,12 @@ let h = class extends U {
|
|
|
1002
1005
|
"{host}": this.host,
|
|
1003
1006
|
"{customer_id}": this.customerId,
|
|
1004
1007
|
"{scene_id}": this.sceneId
|
|
1005
|
-
}) : this.sku ? t = T(
|
|
1008
|
+
}) : this.sku ? t = T(Bt, {
|
|
1006
1009
|
"{viewer}": this.viewer === "360" ? "/360" : "",
|
|
1007
1010
|
"{host}": this.host,
|
|
1008
1011
|
"{customer_id}": this.customerId,
|
|
1009
1012
|
"{sku}": this.sku
|
|
1010
|
-
}) : this.productId ? t = T(
|
|
1013
|
+
}) : this.productId ? t = T(zt, {
|
|
1011
1014
|
"{viewer}": this.viewer === "360" ? "/360" : "",
|
|
1012
1015
|
"{host}": this.host,
|
|
1013
1016
|
"{customer_id}": this.customerId,
|
|
@@ -1015,7 +1018,7 @@ let h = class extends U {
|
|
|
1015
1018
|
}) : s = "Missing property: sku, scene-id, or hash" : s = "Missing property: customer-id" : s = "Missing property: host", s)
|
|
1016
1019
|
return st`<div>${s}</div>`;
|
|
1017
1020
|
let e = "";
|
|
1018
|
-
return this.
|
|
1021
|
+
return Object.keys(this.defaultSelection).length > 0 && (e += new URLSearchParams(this.defaultSelection).toString()), this.hasAttributes() && (Object.keys(this.defaultSelection).length > 0 && (e += "&"), e += It(this)), e.length && (t += "?" + e), st`<iframe
|
|
1019
1022
|
src="${t}"
|
|
1020
1023
|
width="100%"
|
|
1021
1024
|
height="100%"
|