@web-applets/inspector 0.2.3 → 0.2.4

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.
@@ -77,7 +77,7 @@ var rs=t=>{throw TypeError(t)};var Qr=(t,e,r)=>e.has(t)||rs("Cannot "+r);var A=(
77
77
  </svg>'
78
78
  >
79
79
  </toggle-css-variable-button>
80
- `}};ms=xo([je("app-header")],ms);(()=>{var g,S,_,h,v,k,E,I,j,C,_n,Gs,bn,wn,Ne,ce,ge,re,ne,ie,W,Ae,V,F,Ks,Xs,Qs,ea,ta,ra,ye,X,ue,pe,Te,xe,Ee,na,sa,G;var t=class extends Error{constructor(L){super(L),this.name="AppletExecutionError"}},e=class extends Error{constructor(L){super(L),this.name="AppletConnectionError"}};function r(L){typeof this[`on${L.type}`]=="function"&&this[`on${L.type}`](L),this.dispatchEvent(L)}var n=class extends Event{constructor(L,w){super(L,{bubbles:w==null?void 0:w.bubbles,composed:w==null?void 0:w.composed,cancelable:w==null?void 0:w.cancelable}),this.data=w==null?void 0:w.data,this.actions=w==null?void 0:w.actions}};function s(L,...w){}var a={log:s},i=(Ne=class extends EventTarget{constructor(w){super();H(this,C);H(this,g);H(this,S,{});H(this,_);H(this,h);H(this,v);H(this,k);H(this,E);H(this,I);H(this,j);q(this,g,w),q(this,v,r.bind(this)),he(this,C,_n).call(this);let y=O=>{O.source===A(this,g)&&"type"in O.data&&O.data.type==="appletconnect"&&(a.log("Applet","Recieved message",O.data),he(this,C,_n).call(this),this.removeEventListener("message",y))};window.addEventListener("message",y)}async sendAction(w,y){let O={id:crypto.randomUUID(),type:"action",actionId:w,arguments:y};return new Promise((N,de)=>{A(this,E).call(this,O);let pt=setTimeout(()=>{de(new t("Applet action handler failed to complete before timeout (10000ms)"))},1e4),gr=yr=>{let It=yr.data;if(["actioncomplete","actionerror"].includes(It.type)&&"id"in It&&It.id===O.id)if(A(this,k).removeEventListener("message",gr),clearTimeout(pt),It.type==="actionerror"){let Ui=It;de(new t(Ui.message))}else N()};A(this,k).addEventListener("message",gr)})}get data(){return A(this,h)}set data(w){q(this,h,w);let y={type:"data",data:w};A(this,E).call(this,y)}get window(){return A(this,g)}get manifest(){return A(this,_)}get actions(){return A(this,S)}get width(){return A(this,I)}get height(){return A(this,j)}},g=new WeakMap,S=new WeakMap,_=new WeakMap,h=new WeakMap,v=new WeakMap,k=new WeakMap,E=new WeakMap,I=new WeakMap,j=new WeakMap,C=new WeakSet,_n=function(){A(this,k)&&A(this,k).close();let w=new MessageChannel,y={type:"appletconnect"};q(this,k,w.port1),A(this,k).onmessage=he(this,C,Gs).bind(this),A(this,g).postMessage(y,"*",[w.port2]),q(this,E,A(this,k).postMessage.bind(A(this,k)))},Gs=function(w){let y=w.data;switch(y.type){case"register":let O=y;q(this,_,O.manifest);let N=new n("connect");A(this,v).call(this,N),q(this,S,O.actions),he(this,C,wn).call(this,O.actions),q(this,h,O.data),he(this,C,bn).call(this,O.data);break;case"data":let de=y;q(this,h,de.data),he(this,C,bn).call(this,de.data);break;case"resize":let pt=y;q(this,I,pt.width),q(this,j,pt.height);let gr=new n("resize");A(this,v).call(this,gr);break;case"actions":let yr=y;q(this,S,yr.actions),he(this,C,wn).call(this,yr.actions);break}},bn=function(w){let y=new n("data",{data:w});A(this,v).call(this,y)},wn=function(w){let y=new n("actions",{actions:w});A(this,v).call(this,y)},Ne);function o(L){return Object.keys(L).length===0}var l=(ye=class extends EventTarget{constructor(w){super();H(this,F);H(this,ce,{});H(this,ge);H(this,re);H(this,ne);H(this,ie);H(this,W);H(this,Ae);H(this,V);q(this,ie,r.bind(this)),w&&q(this,ge,w);let y=N=>{if(N.source===window.parent&&N.data.type==="appletconnect"&&N.ports&&N.ports.length>0){a.log("AppletScope","Recieved message",N.data);let de=N.ports[0];q(this,W,de.postMessage.bind(de)),de.onmessage=he(this,F,Xs).bind(this),this.removeEventListener("message",y),he(this,F,Ks).call(this)}};window.addEventListener("message",y);let O={type:"appletconnect"};window.parent.postMessage(O,"*")}setActionHandler(w,y){A(this,ce)[w]=y}defineAction(w,y){let{handler:O,...N}=y;O&&(A(this,ce)[w]=O),this.actions={...this.actions,[w]:N}}set actions(w){if(!w)return;q(this,re,w);let y={type:"actions",actions:A(this,re)};A(this,W)&&A(this,W).call(this,y);let O=new n("actions",{actions:w});setTimeout(()=>A(this,ie).call(this,O),1)}get actions(){return A(this,re)}get manifest(){return A(this,ge)}get actionHandlers(){return A(this,ce)}set actionHandlers(w){q(this,ce,w)}set data(w){q(this,ne,w);let y={type:"data",data:w};A(this,W)&&A(this,W).call(this,y);let O=new n("data",{data:w});setTimeout(()=>A(this,ie).call(this,O),1)}get data(){return A(this,ne)}get width(){return A(this,Ae)}get height(){return A(this,V)}},ce=new WeakMap,ge=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakMap,W=new WeakMap,Ae=new WeakMap,V=new WeakMap,F=new WeakSet,Ks=async function(){let w=this.manifest??await he(this,F,ra).call(this);q(this,ge,w||{}),q(this,re,A(this,re)||(w==null?void 0:w.actions)||{});let y={type:"register",manifest:A(this,ge),actions:A(this,re),data:A(this,ne)};A(this,W).call(this,y);let O=new n("connect");A(this,ie).call(this,O),he(this,F,ea).call(this)},Xs=function(w){let y=w.data;switch(y.type){case"data":"data"in y&&(this.data=y.data);break;case"action":"type"in y&&y.type==="action"&&"id"in y&&typeof y.id=="string"&&"actionId"in y&&typeof y.actionId=="string"&&"arguments"in y&&he(this,F,Qs).call(this,y);break}},Qs=async function(w){let{actionId:y,arguments:O,id:N}=w;if(Object.keys(A(this,ce)).includes(y))try{await A(this,ce)[y](O);let de={type:"actioncomplete",id:N};A(this,W).call(this,de)}catch(de){let pt={type:"actionerror",id:N,message:de.message};A(this,W).call(this,pt),console.error(de)}},ea=function(){new ResizeObserver(w=>{for(let y of w)he(this,F,ta).call(this,{width:y.contentRect.width,height:y.contentRect.height})}).observe(document.querySelector("html"))},ta=function({width:w,height:y}){q(this,Ae,w),q(this,V,y);let O={type:"resize",width:w,height:y};A(this,W).call(this,O)},ra=async function(){let w=document.querySelector('link[rel="manifest"]');if(!w){console.warn("No manifest link found");return}try{let y=await(await fetch(w.href)).json();for(let O in y.actions){let N=y.actions[O];N.params_schema&&!o(A(this,re).params_schema)&&(N.params_schema=void 0)}return y}catch{return}},ye),c=class{async connect(L){return new Promise((w,y)=>{let O=new i(L),N=setTimeout(()=>{y(new e("Applet failed to connect before the timeout was reached (10000ms)"))},1e4),de=()=>{w(O),O.removeEventListener("connect",de),clearTimeout(N)};O.addEventListener("connect",de)})}register(L){return new l(L)}},d=new c,p=(G=class extends HTMLElement{constructor(){super(...arguments);H(this,Ee);H(this,X);H(this,ue);H(this,pe);H(this,Te,r.bind(this));H(this,xe,document.createElement("iframe"))}connectedCallback(){q(this,X,this.attachShadow({mode:"closed"})),A(this,X).appendChild(A(this,xe));let y=document.createElement("style");y.textContent=this.styles,A(this,X).appendChild(y),this.src=this.getAttribute("src")}get contentWindow(){return A(this,xe).contentWindow}set src(y){q(this,ue,y),q(this,pe,void 0),he(this,Ee,na).call(this,y)}get src(){return A(this,ue)||""}attributeChangedCallback(y,O,N){y==="src"&&(this.src=N)}get applet(){return A(this,pe)}set data(y){if(this.applet)this.applet.data=y;else{let O=()=>{this.applet&&(this.applet.data=y),this.removeEventListener("load",O)};this.addEventListener("load",O)}}get styles(){return`
80
+ `}};ms=xo([je("app-header")],ms);(()=>{var g,S,_,h,v,k,E,I,j,C,_n,Gs,bn,wn,Ne,ce,ge,re,ne,ie,W,Ae,V,F,Ks,Xs,Qs,ea,ta,ra,ye,X,ue,pe,Te,xe,Ee,na,sa,G;var t=class extends Error{constructor(L){super(L),this.name="AppletExecutionError"}},e=class extends Error{constructor(L){super(L),this.name="AppletConnectionError"}};function r(L){typeof this[`on${L.type}`]=="function"&&this[`on${L.type}`](L),this.dispatchEvent(L)}function n(L){return Object.keys(L).length===0}var s=class extends Event{constructor(L,w){super(L,{bubbles:w==null?void 0:w.bubbles,composed:w==null?void 0:w.composed,cancelable:w==null?void 0:w.cancelable}),this.data=w==null?void 0:w.data,this.actions=w==null?void 0:w.actions}};function a(L,...w){}var i={log:a},o=(Ne=class extends EventTarget{constructor(w){super();H(this,C);H(this,g);H(this,S,{});H(this,_);H(this,h);H(this,v);H(this,k);H(this,E);H(this,I);H(this,j);q(this,g,w),q(this,v,r.bind(this)),he(this,C,_n).call(this);let y=O=>{O.source===A(this,g)&&"type"in O.data&&O.data.type==="appletconnect"&&(i.log("Applet","Recieved message",O.data),he(this,C,_n).call(this),this.removeEventListener("message",y))};window.addEventListener("message",y)}async sendAction(w,y){let O={id:crypto.randomUUID(),type:"action",actionId:w,arguments:y};return new Promise((N,de)=>{A(this,E).call(this,O);let pt=setTimeout(()=>{de(new t("Applet action handler failed to complete before timeout (10000ms)"))},1e4),gr=yr=>{let It=yr.data;if(["actioncomplete","actionerror"].includes(It.type)&&"id"in It&&It.id===O.id)if(A(this,k).removeEventListener("message",gr),clearTimeout(pt),It.type==="actionerror"){let Ui=It;de(new t(Ui.message))}else N()};A(this,k).addEventListener("message",gr)})}get data(){return A(this,h)}set data(w){q(this,h,w);let y={type:"data",data:w};A(this,E).call(this,y)}get window(){return A(this,g)}get manifest(){return A(this,_)}get actions(){return A(this,S)}get width(){return A(this,I)}get height(){return A(this,j)}},g=new WeakMap,S=new WeakMap,_=new WeakMap,h=new WeakMap,v=new WeakMap,k=new WeakMap,E=new WeakMap,I=new WeakMap,j=new WeakMap,C=new WeakSet,_n=function(){A(this,k)&&A(this,k).close();let w=new MessageChannel,y={type:"appletconnect"};q(this,k,w.port1),A(this,k).onmessage=he(this,C,Gs).bind(this),A(this,g).postMessage(y,"*",[w.port2]),q(this,E,A(this,k).postMessage.bind(A(this,k)))},Gs=function(w){let y=w.data;switch(y.type){case"register":let O=y;q(this,_,O.manifest);let N=new s("connect");A(this,v).call(this,N),q(this,S,O.actions),he(this,C,wn).call(this,O.actions),q(this,h,O.data),he(this,C,bn).call(this,O.data);break;case"data":let de=y;q(this,h,de.data),he(this,C,bn).call(this,de.data);break;case"resize":let pt=y;q(this,I,pt.width),q(this,j,pt.height);let gr=new s("resize");A(this,v).call(this,gr);break;case"actions":let yr=y;q(this,S,yr.actions),he(this,C,wn).call(this,yr.actions);break}},bn=function(w){let y=new s("data",{data:w});A(this,v).call(this,y)},wn=function(w){let y=new s("actions",{actions:w});A(this,v).call(this,y)},Ne),l=(ye=class extends EventTarget{constructor(w){super();H(this,F);H(this,ce,{});H(this,ge);H(this,re);H(this,ne);H(this,ie);H(this,W);H(this,Ae);H(this,V);q(this,ie,r.bind(this)),w&&q(this,ge,w);let y=N=>{if(N.source===window.parent&&N.data.type==="appletconnect"&&N.ports&&N.ports.length>0){i.log("AppletScope","Recieved message",N.data);let de=N.ports[0];q(this,W,de.postMessage.bind(de)),de.onmessage=he(this,F,Xs).bind(this),this.removeEventListener("message",y),he(this,F,Ks).call(this)}};window.addEventListener("message",y);let O={type:"appletconnect"};window.parent.postMessage(O,"*")}setActionHandler(w,y){A(this,ce)[w]=y}defineAction(w,y){let{handler:O,...N}=y;O&&(A(this,ce)[w]=O),this.actions={...this.actions,[w]:N}}set actions(w){if(!w)return;q(this,re,w);let y={type:"actions",actions:A(this,re)};A(this,W)&&A(this,W).call(this,y);let O=new s("actions",{actions:w});setTimeout(()=>A(this,ie).call(this,O),1)}get actions(){return A(this,re)}get manifest(){return A(this,ge)}get actionHandlers(){return A(this,ce)}set actionHandlers(w){q(this,ce,w)}set data(w){q(this,ne,w);let y={type:"data",data:w};A(this,W)&&A(this,W).call(this,y);let O=new s("data",{data:w});setTimeout(()=>A(this,ie).call(this,O),1)}get data(){return A(this,ne)}get width(){return A(this,Ae)}get height(){return A(this,V)}},ce=new WeakMap,ge=new WeakMap,re=new WeakMap,ne=new WeakMap,ie=new WeakMap,W=new WeakMap,Ae=new WeakMap,V=new WeakMap,F=new WeakSet,Ks=async function(){let w=this.manifest??await he(this,F,ra).call(this);q(this,ge,w||{}),q(this,re,A(this,re)||(w==null?void 0:w.actions)||{});let y={type:"register",manifest:A(this,ge),actions:A(this,re),data:A(this,ne)};A(this,W).call(this,y);let O=new s("connect");A(this,ie).call(this,O),he(this,F,ea).call(this)},Xs=function(w){let y=w.data;switch(y.type){case"data":"data"in y&&(this.data=y.data);break;case"action":"type"in y&&y.type==="action"&&"id"in y&&typeof y.id=="string"&&"actionId"in y&&typeof y.actionId=="string"&&"arguments"in y&&he(this,F,Qs).call(this,y);break}},Qs=async function(w){let{actionId:y,arguments:O,id:N}=w;if(Object.keys(A(this,ce)).includes(y))try{await A(this,ce)[y](O);let de={type:"actioncomplete",id:N};A(this,W).call(this,de)}catch(de){let pt={type:"actionerror",id:N,message:de.message};A(this,W).call(this,pt),console.error(de)}},ea=function(){new ResizeObserver(w=>{for(let y of w)he(this,F,ta).call(this,{width:y.contentRect.width,height:y.contentRect.height})}).observe(document.querySelector("html"))},ta=function({width:w,height:y}){q(this,Ae,w),q(this,V,y);let O={type:"resize",width:w,height:y};A(this,W).call(this,O)},ra=async function(){let w=document.querySelector('link[rel="manifest"]');if(!w){console.warn("No manifest link found");return}try{let y=await(await fetch(w.href)).json();for(let O in y.actions){let N=y.actions[O];N.params_schema&&!n(A(this,re).params_schema)&&(N.params_schema=void 0)}return y}catch{return}},ye),c=class{async connect(L){return new Promise((w,y)=>{let O=new o(L),N=setTimeout(()=>{y(new e("Applet failed to connect before the timeout was reached (10000ms)"))},1e4),de=()=>{w(O),O.removeEventListener("connect",de),clearTimeout(N)};O.addEventListener("connect",de)})}register(L){return new l(L)}},d=new c,p=(G=class extends HTMLElement{constructor(){super(...arguments);H(this,Ee);H(this,X);H(this,ue);H(this,pe);H(this,Te,r.bind(this));H(this,xe,document.createElement("iframe"))}connectedCallback(){q(this,X,this.attachShadow({mode:"closed"})),A(this,X).appendChild(A(this,xe));let y=document.createElement("style");y.textContent=this.styles,A(this,X).appendChild(y),this.src=this.getAttribute("src")}get contentWindow(){return A(this,xe).contentWindow}set src(y){q(this,ue,y),q(this,pe,void 0),he(this,Ee,na).call(this,y)}get src(){return A(this,ue)||""}attributeChangedCallback(y,O,N){y==="src"&&(this.src=N)}get applet(){return A(this,pe)}set data(y){if(this.applet)this.applet.data=y;else{let O=()=>{this.applet&&(this.applet.data=y),this.removeEventListener("load",O)};this.addEventListener("load",O)}}get styles(){return`
81
81
  :host {
82
82
  background: white;
83
83
  display: flex;
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Web Applets Inspector</title>
7
- <script type="module" crossorigin src="/assets/index-AMdeMxa5.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-COcILV0O.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-DGr96Ien.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -38,5 +38,5 @@
38
38
  "optionalDependencies": {
39
39
  "@rollup/rollup-linux-x64-gnu": "4.9.5"
40
40
  },
41
- "version": "0.2.3"
41
+ "version": "0.2.4"
42
42
  }