@openfin/cloud-api
Advanced tools
+1
-2
@@ -1,2 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var tt=Object.create;var En=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var at=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Kn=(t,i)=>{for(var r in i)En(t,r,{get:i[r],enumerable:!0})},ct=(t,i,r,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of rt(i))!st.call(t,d)&&d!==r&&En(t,d,{get:()=>i[d],enumerable:!(a=ot(i,d))||a.enumerable});return t};var vn=(t,i,r)=>(r=t!=null?tt(it(t)):{},ct(i||!t||!t.__esModule?En(r,"default",{value:t,enumerable:!0}):r,t));var on=at((no,Xn)=>{"use strict";(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},i={};t.r(i),t.d(i,{SearchTagBackground:()=>cn,create:()=>Vn,defaultTopic:()=>jn,subscribe:()=>qn});var r={};t.r(r),t.d(r,{B:()=>Oe});var a={};t.r(a),t.d(a,{v:()=>Ye});let d="deregistered or does not exist",h=new Error(`provider ${d}`),m=new Error("provider with name already exists"),w=new Error("bad payload"),C=new Error("subscription rejected"),S=new Error(`channel ${d}`),P;function b(){if(P)return P;throw S}function H(){return P}function In(n){P=n}var O,x,an,cn;(function(n){n[n.Initial=0]="Initial",n[n.Open=1]="Open",n[n.Close=2]="Close"})(O||(O={})),function(n){n.Fetching="fetching",n.Fetched="fetched",n.Complete="complete"}(x||(x={})),function(n){n.UserAction="user-action",n.FocusChange="focus-change",n.Reload="reload"}(an||(an={})),function(n){n.Active="active",n.Default="default"}(cn||(cn={}));let K="0",Pn="1",bn="2",Nn="3",Ln="4",z="5",X="6",ue=()=>{},ln=new Set;function de(n){ln.add(n)}function pe(n){ln.delete(n)}let un=new Set;function fe(n){un.add(n)}function he(n){un.delete(n)}let j=new Map;async function dn(n){j.set(n.id,n);let e=[...ln].map(o=>o());await Promise.all(e)}async function J(n){j.delete(n);let e=[...un].map(o=>o());await Promise.all(e)}function pn(){return[...j.values()]}function Fn(){j.clear()}function L(n){return j.get(n)}function _n(n,e,o){return{...n,action:o||{...n.actions[0],trigger:an.UserAction},dispatcherIdentity:e}}function fn(n,e,o="ascending"){let s=n||[];if(!_optionalChain([e, 'optionalAccess', _2 => _2.length]))return s;let c=[],l=new Map;e.forEach(p=>{if(p.key)return l.set(p.key,p);c.push(p)});let u=s.map(p=>{let{key:g}=p;if(g&&l.has(g)){let v=l.get(g);return l.delete(g),v}return p});return u.push(...l.values(),...c),u=o==="ascending"?u.sort((p,g)=>(_nullishCoalesce(_optionalChain([p, 'optionalAccess', _3 => _3.score]), () => (1/0)))-(_nullishCoalesce(_optionalChain([g, 'optionalAccess', _4 => _4.score]), () => (1/0)))):u.sort((p,g)=>(_nullishCoalesce(_optionalChain([g, 'optionalAccess', _5 => _5.score]), () => (1/0)))-(_nullishCoalesce(_optionalChain([p, 'optionalAccess', _6 => _6.score]), () => (1/0)))),u}function Tn(n){let e={},o=[],s=[],c=null,l=O.Initial;e.getStatus=()=>l,e.getResultBuffer=()=>o,e.setResultBuffer=p=>{o=p,_optionalChain([o, 'optionalAccess', _7 => _7.length])&&e.onChange()},e.getRevokedBuffer=()=>s,e.setRevokedBuffer=p=>{s=p,_optionalChain([s, 'optionalAccess', _8 => _8.length])&&e.onChange()},e.setUpdatedContext=p=>{c=p,e.onChange()},e.getUpdatedContext=()=>c,e.onChange=ue;let u={};return e.res=u,u.close=()=>{l!==O.Close&&(l=O.Close,e.onChange())},u.open=()=>{l!==O.Open&&(l=O.Open,e.onChange())},u.respond=p=>{let g=fn(e.getResultBuffer(),p,n);e.setResultBuffer(g)},u.revoke=(...p)=>{let g=new Set(p),v=e.getResultBuffer().filter(({key:f})=>{let R=g.has(f);return R&&g.delete(f),!R});e.setResultBuffer(v),g.size&&(e.getRevokedBuffer().forEach(f=>g.add(f)),e.setRevokedBuffer([...g]))},u.updateContext=p=>{e.setUpdatedContext(p)},e}function xn(n,e){let o=new Set,s=!1;return{close:()=>{s=!0;for(let c of o)c()},req:{id:n,...e,context:_optionalChain([e, 'optionalAccess', _9 => _9.context])||{},onClose:c=>{o.add(c),s&&c()},removeListener:c=>{o.delete(c)}}}}function Q(){return{name:fin.me.name,uuid:fin.me.uuid}}let kn=50,ge=1e3,we=new Map;function hn(){return we}let ye=100;function me(){return async n=>{if(!n||!n.id||!n.providerId){let f=w;return console.error(f),{error:f.message}}let{id:e,providerId:o}=n,s=L(o);if(!s){let f=h;return console.error(f),{error:f.message}}let c=hn(),l=c.get(n.id);l||(l=xn(e,n),c.set(n.id,l));let u=Tn(),p=()=>{let f=u.getResultBuffer();u.setResultBuffer([]);let R=u.getRevokedBuffer();u.setRevokedBuffer([]);let F=u.getUpdatedContext();u.setUpdatedContext(null);let $=u.getStatus();(async function(M){(await b()).dispatch(K,M)})({id:e,providerId:o,results:f,revoked:R,status:$,context:F})},g=!0,v=!1;u.onChange=()=>{if(g)return g=!1,void p();v||(v=!0,setTimeout(()=>{v=!1,p()},ye))};try{let{results:f,context:R}=await s.onUserInput(l.req,u.res),F=u.getStatus();return{id:e,providerId:o,status:F,results:f,context:R}}catch(f){return console.error(`OpenFin/Workspace/Home. Uncaught exception in search provider ${o} for search ${e}`,"This is likely a bug in the implementation of the search provider.",f),{id:e,providerId:o,error:_optionalChain([f, 'optionalAccess', _10 => _10.message])}}}}async function $n(n,e){let o=e||await b(),s=Q(),c={...n,identity:s,onResultDispatch:void 0},l=await o.dispatch(bn,c);return await dn({identity:s,...n}),l}async function Ce(n){return await(await b()).dispatch(Nn,n),J(n)}async function Se(n,e,o,s){let c=_n(e,_nullishCoalesce(s, () => (Q())),o),l=L(n);if(l){let{onResultDispatch:p}=l;return p?p(c):void 0}let u={providerId:n,result:c};return(await b()).dispatch(z,u)}async function Re(n){let e={...n,context:_optionalChain([n, 'optionalAccess', _11 => _11.context])||{}},o={},s=async function*(l,{setState:u}){let p=await b();for(;;){let g=await p.dispatch(Pn,l),v=g.error;if(v)throw new Error(v);let f=g;if(l.id=f.id,u(f.state),f.done)return f.value;yield f.value}}(e,{setState:l=>{o.state=l}}),c=await s.next();return o.id=e.id||"",o.close=()=>{(async function(l){(await b()).dispatch(X,{id:l})})(o.id)},o.next=()=>{if(c){let l=c;return c=void 0,l}return s.next()},o}async function Ee(){return(await b()).dispatch(Ln,null)}async function ve(){let n=await b();P=void 0,Fn(),await n.disconnect()}let Ae=async n=>{let e=await Un(n);for(let o of pn())await $n(o,e);return e};async function Un(n){let e=await async function(o){for(let s=0;s<kn;s++)try{return await fin.InterApplicationBus.Channel.connect(o,{wait:!1})}catch(c){if(s===kn-1)throw c;await new Promise(l=>setTimeout(l,ge))}}(n);return e.register(K,me()),e.register(X,o=>{let s=hn(),c=s.get(o.id);c&&(c.close(),s.delete(o.id))}),e.register(z,async(o,s)=>{if(!o||!o.providerId||!o.result)return void console.error(w);let c=L(o.providerId);if(!c)return void console.error(h);let{onResultDispatch:l}=c;return l?(o.result.dispatcherIdentity=_nullishCoalesce(o.result.dispatcherIdentity, () => (s)),l(o.result)):void 0}),e.onDisconnection(function(o){return async()=>{if(!H())return;let s=hn();for(let{req:c,close:l}of s.values())l(),s.delete(c.id);In(Ae(o))}}(n)),e}async function Oe(n){let e=H();e||(e=Un(n),In(e));let o=await e;return{getAllProviders:Ee.bind(null),register:$n.bind(null),search:Re.bind(null),deregister:Ce.bind(null),dispatch:Se.bind(null),disconnect:ve.bind(null),channel:o}}let G;function Y(){if(G)return G;throw S}function Ie(){return G}function Pe(n){G=n}function be(){G=void 0}let gn=new Set;function Ne(n){gn.add(n)}function Le(n){gn.delete(n)}var k;(function(n){n.Local="local",n.Dev="dev",n.Staging="staging",n.Prod="prod"})(k||(k={}));let wn=typeof window<"u"&&typeof fin<"u",Fe=(typeof process>"u"||process.env,typeof window<"u"),_e=Fe?window.origin:k.Local,Z=(wn&&fin.me.uuid,wn&&fin.me.name,wn&&fin.me.entityType,k.Local,k.Dev,k.Staging,k.Prod,n=>n.startsWith("http://")||n.startsWith("https://")?n:_e+n),Dn=(Z("http://localhost:4002"),Z("http://localhost:4002"),typeof WORKSPACE_DOCS_PLATFORM_URL<"u"&&Z(WORKSPACE_DOCS_PLATFORM_URL),typeof WORKSPACE_DOCS_CLIENT_URL<"u"&&Z(WORKSPACE_DOCS_CLIENT_URL),"20.3.6");typeof WORKSPACE_BUILD_SHA<"u"&&WORKSPACE_BUILD_SHA;async function Mn(){return[...pn()].map(n=>({...n,onUserInput:void 0,onResultDispatch:void 0}))}async function Te(n){if(L(n.id))throw new Error("provider with name already exists");let e=Q();return await dn({identity:e,...n}),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}async function xe(n){await J(n)}async function ke(n,e,o,s){let c=L(n);if(!c)throw h;let{onResultDispatch:l}=c;if(l)return l(_n(e,_nullishCoalesce(s, () => (Q())),o))}async function*$e(n,e){let o=function(R,F){let $=[],M=[],B=[],I=[];for(let E of R){let _=Tn(E.scoreOrder),T={results:[],provider:{id:E.id,identity:E.identity,title:E.title,scoreOrder:E.scoreOrder,icon:E.icon,dispatchFocusEvents:E.dispatchFocusEvents}};$.push(T),M.push(_);let W=(async()=>{try{let{results:V,context:en}=await E.onUserInput(F,_.res);T.results=fn(T.results||[],V,E.scoreOrder),T.context={...T.context,...en}}catch(V){T.error=V}})();W.finally(()=>{W.done=!0}),I.push(W),B.push(B.length)}return{providerResponses:$,listenerResponses:M,openListenerResponses:B,initialResponsePromises:I}}(n.targets?n.targets.map(R=>L(R)).filter(R=>!!R):[...pn().filter(R=>!R.hidden)],n),{providerResponses:s,listenerResponses:c}=o,{openListenerResponses:l,initialResponsePromises:u}=o,p=x.Fetching,g=R=>{p=R,e.setState(p)},v,f=!1;n.onClose(()=>{f=!0,v&&v()});do{let R=!1;if(u.length){let I=[];for(let E of u)E.done?R=!0:I.push(E);u=I,u.length||(g(x.Fetched),R=!0)}let F,$=!1,M=()=>{$=!0,F&&F()},B=[];for(let I of l){let E=c[I],_=s[I],T=E.getStatus();(T===O.Open||p===x.Fetching&&T===O.Initial)&&(B.push(I),E.onChange=M);let W=E.getResultBuffer();W.length&&(E.setResultBuffer([]),_.results=fn(_.results||[],W),R=!0);let V=E.getRevokedBuffer();if(V.length){E.setRevokedBuffer([]);let nt=new Set(V);_.results=(_.results||[]).filter(({key:et})=>!nt.has(et)),R=!0}let en=E.getUpdatedContext();en&&(E.setUpdatedContext(null),_.context={..._.context,...en},R=!0)}if(l=B,R&&(yield s),f)break;$||(l.length||u.length)&&await Promise.race([...u,new Promise(I=>{F=I}),new Promise(I=>{v=I})])}while(l.length||u.length);return g(x.Complete),s}let yn=0;async function Bn(n){yn+=1;let e=xn(yn.toString(),n),o=$e(e.req,{setState:s=>{o.state=s}});return o.id=yn.toString(),o.close=e.close,o.state=x.Fetching,o}let nn=new Map,Ue=1e4;function De(){return async n=>{if(!n)return console.error(w),{error:w.message};let e;if(n.id)e=n.id;else{let c=await Bn(n);e=c.id,n.id=c.id,nn.set(e,{generator:c})}let o=nn.get(e);clearTimeout(o.timeout);let s=await o.generator.next();return o.timeout=function(c){return window.setTimeout(()=>{nn.delete(c)},Ue)}(e),{...s,id:n.id,state:o.generator.state}}}function Me(n,e){return Y().dispatch(n,X,{id:e})}function Be(){return n=>function(e){let o=nn.get(e);o&&o.generator.close()}(n.id)}async function We(n,{id:e,query:o,context:s,targets:c=[]}){let l=Y(),u={id:e,query:o,context:s,targets:c,providerId:n.id},p=await l.dispatch(n.identity,K,u),g=p.error;if(g)throw new Error(g);return p}let mn=new Map;function Ve(n,e){return`${n.name}:${n.uuid}:${e}`}let Cn=new Map;function Wn(n,e){return`${n}:${e}`}function qe(n){let e=Ve.bind(null,n.identity),o=Me.bind(null,n.identity),s=We.bind(null,n);return async(c,l)=>{let u=e(c.id);if(!mn.has(u)){let f=()=>{o(c.id),mn.delete(u)};mn.set(u,f),c.onClose(f)}let p=Wn(n.id,c.id),g=()=>{Cn.delete(p),l.close()};c.onClose(g),Cn.set(p,f=>{_optionalChain([f, 'access', _12 => _12.results, 'optionalAccess', _13 => _13.length])&&l.respond(f.results),_optionalChain([f, 'access', _14 => _14.revoked, 'optionalAccess', _15 => _15.length])&&l.revoke(...f.revoked),f.context&&l.updateContext(f.context),f.status===O.Open&&l.open(),f.status===O.Close&&g()});let v=await s(c);return v.status===O.Open&&l.open(),v.status!==O.Close&&v.status!==O.Initial||g(),v}}function je(n){return async e=>{let o=Y(),s={providerId:n.id,result:e};return o.dispatch(n.identity,z,s)}}let D=new Map;function Sn(n){return`${n.name}-${n.uuid}`}function Ge(){return async(n,e)=>{if(!n||!n.id)return console.error(new Error(JSON.stringify(n))),void console.error(w);if(L(n.id))throw m;return n.identity=e,await async function(o){let s=Sn(o.identity);D.has(s)||D.set(s,[]),D.get(s).push(o.id),await dn({...o,onUserInput:qe(o),onResultDispatch:je(o)})}(n),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}}function He(){return(n,e)=>{n?function(o,s){let c=L(o);if(!c)return;if(c.identity.uuid!==s.uuid||c.identity.name!==s.name)throw h;let l=Sn(c.identity),u=D.get(l);if(u){let p=u.findIndex(g=>g===o);p!==-1&&(u.splice(p,1),J(o))}}(n,e):console.error(w)}}let Rn=new Set;function Ke(n){Rn.add(n)}function ze(n){Rn.delete(n)}function Xe(){return async n=>{(function(e){let o=Sn(e),s=D.get(o);if(s){for(let c of s)J(c);D.delete(o)}})(n),Rn.forEach(e=>e(n))}}async function Je(n){let e=await(o=n,fin.InterApplicationBus.Channel.create(o));var o;return e.onConnection(async s=>{for(let c of gn)if(!await c(s))throw C}),e.onDisconnection(Xe()),e.register(X,Be()),e.register(K,s=>{let c=Wn(s.providerId,s.id),l=Cn.get(c);l&&l(s)}),e.register(bn,Ge()),e.register(Nn,He()),e.register(Ln,async()=>Mn()),e.register(Pn,De()),e.register(z,async(s,c)=>{if(!s||!s.providerId||!s.result)return void console.error(w);let l=L(s.providerId);if(!l)throw h;let{onResultDispatch:u}=l;return u?(s.result.dispatcherIdentity=_nullishCoalesce(s.result.dispatcherIdentity, () => (c)),u(s.result)):void 0}),e}async function Qe(){let n=Y();be(),await n.destroy(),Fn()}async function Ye(n){let e=Ie();e||(e=await Je(n),Pe(e));let o=Le.bind(null),s=ze.bind(null),c=pe.bind(null),l=he.bind(null);return{getAllProviders:Mn.bind(null),search:Bn.bind(null),register:Te.bind(null),deregister:xe.bind(null),onSubscription:Ne.bind(null),onDisconnect:Ke.bind(null),onRegister:de.bind(null),onDeregister:fe.bind(null),dispatch:ke.bind(null),disconnect:Qe.bind(null),removeListener:u=>{o(u),s(u),c(u),l(u)},channel:e}}let{v:Vn}=a,{B:qn}=r,jn="all",Ze={create:Vn,subscribe:qn,defaultTopic:jn},Gn=()=>{window.search=Ze},Hn=n=>{let e=()=>{Gn(),window.removeEventListener(n,e)};return e};if(typeof window<"u"){Gn();let n="load",e=Hn(n);window.addEventListener(n,e);let o="DOMContentLoaded",s=Hn(o);window.addEventListener(o,s)}Xn.exports=i})()});var y="@openfin/cloud-api";async function N(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch (e2){return!1}}function zn(t){if(t.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(t.name)?t.name.split("/")[0]||"":t.name}var q="@openfin/cloud-api";function lt(){return`${window.fin.me.uuid}-cloud-api-notifications`}var An=null;async function qt(){return An||(An=ut()),An}async function ut(){if(!window.fin)throw new Error(`\`${q}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${q}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);zn(window.fin.me);let t=await dt();console.log(t),t.register("openfin-cloud-event",r=>{for(let a of _nullishCoalesce(i.get(r.type), () => ([])))typeof r.payload.timestamp=="string"&&(r.payload.timestamp=new Date(r.payload.timestamp)),a(r.payload)});let i=new Map;return{addEventListener:(r,a)=>{let d=i.get(r)||new Set;d.add(a),i.set(r,d)},removeEventListener:(r,a)=>{let d=i.get(r);if(!d){console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,r);return}d.delete(a)===!1&&console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,r)},update:async r=>(await t.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:r}})).payload.response,clear:async r=>(await t.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:r}})).payload.response,createNotification:async r=>(r.id&&console.warn(`\`${q}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await t.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...r,id:void 0}}})).payload.response)}}var tn=null;async function dt(){return tn||(tn=pt()),tn}async function pt(){let t=await window.fin.InterApplicationBus.Channel.connect(lt());return t.onDisconnection(i=>{console.warn(`\`${q}\`: Channel Disconnected from`,i,"Reconnecting..."),tn=null}),t}var On;function ft(){return`${window.fin.me.uuid}-client-api`}async function U(){return On||(On=window.fin.InterApplicationBus.Channel.connect(ft())),On}async function Ht(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-settings")}async function Kt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-settings")}async function zt(t){if(!window.fin)throw new Error(`\`${y}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("set-user-settings",t)}async function Xt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-permissions")}async function Jt(t,i){if(!window.fin)throw new Error(`\`${y}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let r=await U();try{await r.dispatch("launch-content",{id:t,options:i})}catch(a){switch(a instanceof Error?a.message:String(a)){case"UnableToLookup":throw new Error(`${y}: \`launchContent\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchContent\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchContent\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchContent\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Qt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-supertab",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchSupertab\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchSupertab\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchSupertab\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchSupertab\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Yt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-workspace",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchWorkspace\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchWorkspace\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchWorkspace\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchWorkspace\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}var ne={};Kn(ne,{getAgentConfiguration:()=>Yn,register:()=>Zn});var Qn=vn(on(),1),ht="[here-agent]",gt="log-message-",wt="open-url",yt="provider-status-",mt="registered-",Ct="1.0";function St(t,i){let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}}function Jn(t){return{...t,data:t.data.customData}}async function Yn(){let{customData:t}=await window.fin.me.getOptions();return t}function Rt(){return`${window.fin.me.identity.uuid}-cloud-api-search`}async function Et(t,i,r,a=!0){await i("info",`Setting status as ${a?"ready":"not ready"}`);try{await t.dispatch(`${yt}${r}`,{isReady:a})}catch(d){let h=["Error setting provider status",d];console.error(...h),i("error",...h)}}async function vt(t,i,r,...a){try{console.log(ht,...a),await t.dispatch(`${gt}${i}`,{level:r,message:a})}catch(d){console.error("Error logging message",d)}}async function At(t,i,r,a,d){let{action:h,dispatcherIdentity:m,...w}=d;await r("info","Handling action",{action:h,dispatcherIdentity:m,result:w});let C;try{let P=_optionalChain([Jn, 'call', _16 => _16(d), 'access', _17 => _17.actions, 'optionalAccess', _18 => _18.find, 'call', _19 => _19(({name:H})=>H===h.name)]);if(!P)throw new Error("Original action not found in search result");C=await _asyncOptionalChain([(await a(P,Jn(d))), 'optionalAccess', async _20 => _20.url])}catch(S){throw await r("error","Error handling dispatch",S),S}if(!C){await r("warn","OnActionListener did not return a URL");return}await It(t,r,i,C,m)}async function Ot(t,i,r,a){await i("info","Getting search results",{request:a});try{let d=new AbortController;a.onClose(()=>d.abort());let{context:h,query:m}=a,{results:w}=await r({context:h,query:m,signal:d.signal}),C=w.map(S=>St(S,t));return await i("info","Returning results",C),{results:C}}catch(d){let h=["Error handling search",d];throw console.error(...h),i("error",...h),d}}async function It(t,i,r,a,d){await i("info","Opening URL",{url:a,targetIdentity:d});try{await t.dispatch(wt,{url:a,targetIdentity:d,providerId:r})}catch(h){let m=["Error opening URL",h];console.error(...m),i("error",...m)}}async function Zn(t){let r=(await window.fin.me.getOptions()).customData,{id:a,title:d}=r,{onAction:h,onSearch:m}=t,w=await Qn.subscribe(Rt()),C=w.channel,S=vt.bind(null,C,a);return await w.register({icon:"",id:a,onResultDispatch:At.bind(null,C,a,S,h),onUserInput:Ot.bind(null,a,S,m),title:d}),await w.channel.dispatch(`${mt}${a}`,{version:Ct}),S("info","Registered search topic",{id:a,title:d}),{isReady:Et.bind(null,C,S,a)}}var le={};Kn(le,{getConfiguration:()=>ae,register:()=>ce});var se=vn(on(),1);var rn=class extends Error{constructor(){super("Interop feature is not supported by the agent")}};async function sn(t,i){try{let r=await window.fin.me.interop.getFDC3(t);i==="none"?(A("Leaving current channel"),await r.leaveCurrentChannel()):(A(`Joining interop channel: ${i}`),await("joinUserChannel"in r?r.joinUserChannel(i):r.joinChannel(i)))}catch(r){A(`Failed to join interop channel: ${i}`,r)}}var ro=vn(on(),1);var Nt=(t,i)=>{let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}},ee=t=>({...t,data:t.data.customData}),te=()=>`${window.fin.me.identity.uuid}-cloud-api-search`,Lt=async({channel:t,url:i,targetIdentity:r})=>{A("Opening URL",{url:i,targetIdentity:r});try{await t.dispatch(ie,{url:i,targetIdentity:r})}catch(a){console.error("Failed opening URL",a)}},oe=async(t,i,r,a)=>{let{action:d,dispatcherIdentity:h,...m}=a;A("Handling action...",{action:d,dispatcherIdentity:h,result:m});let w;try{let S=_optionalChain([ee, 'call', _21 => _21(a), 'access', _22 => _22.actions, 'optionalAccess', _23 => _23.find, 'call', _24 => _24(({name:b})=>b===d.name)]);if(!S)throw new Error("Original action not found in search result");w=await _asyncOptionalChain([(await r(S,ee(a))), 'optionalAccess', async _25 => _25.url])}catch(C){throw A("Error handling dispatch",C),C}if(!w){A("OnActionListener did not return a URL");return}await Lt({channel:t,url:w,targetIdentity:h})},re=async(t,i,r)=>{A("Getting search results...",{request:r});try{let a=new AbortController;r.onClose(()=>a.abort());let{context:d,query:h}=r,{results:m}=await i({context:d,query:h,signal:a.signal}),w=m.map(C=>Nt(C,t));return A("Returning results",w),{results:w}}catch(a){throw new Error("Error handling search request",{cause:a})}};var _t="[here-agent]",Tt="1.0",xt="-enterprise-component-bridge",ie="open-url",kt="set-agent-registered",$t="set-agent-status",ae=async()=>{let{customData:t}=await window.fin.me.getOptions(),i=t,{configurationFields:r}=i;return Object.fromEntries(_nullishCoalesce(_optionalChain([r, 'optionalAccess', _26 => _26.map, 'call', _27 => _27(a=>[a.name,a.value])]), () => ([])))};async function Ut(t,i){if(!t.interop)throw new rn;let{fdc3Version:r}=t.interop;await sn(r,i)}function A(...t){console.log(_t,...t)}var Dt=async(t,i,r=!0)=>{A(`Setting status to ${r?"ready":"not ready"}`);try{await t.dispatch($t,{id:i,isReady:r})}catch(a){throw new Error("Failed to set agent status",{cause:a})}};async function ce(t){let{customData:i}=await window.fin.me.getOptions(),r=i;A("Registering agent...",r);try{let a=`${window.fin.me.identity.uuid}${xt}`,d;try{d=await window.fin.InterApplicationBus.Channel.connect(a,{wait:!1})}catch(S){throw new Error("Failed to connect to enterprise component bridge channel",{cause:S})}let{id:h,features:m,title:w}=r,C={features:m,joinInteropChannel:Ut.bind(null,m),setIsReady:Dt.bind(null,d,h)};if(m.interop){A("Enabling interop features");let{defaultChannel:S,fdc3Version:P}=m.interop;S&&S!=="none"&&await sn(P,S),d.register("on-desktop-app-signals-changed",Mt.bind(null,r))}return m.search&&t.search&&(A("Enabling search features"),await(await se.subscribe(te())).register({icon:"",id:h,onResultDispatch:oe.bind(null,d,h,t.search.onAction),onUserInput:re.bind(null,h,t.search.onSearch),title:w})),await d.dispatch(kt,{id:h,apiVersion:Tt}),A("Registered successfully"),C}catch(a){throw new Error("Failed to register agent",{cause:a})}}function Mt(t,i){A("Desktop app signals changed",i);let r=i,{type:a,id:d,features:h}=t,{fdc3Version:m}=h.interop,w=r.find(C=>a==="agent"?C.appKey===t.name:a==="custom"?C.appKey===d:!1);w&&sn(m,w.selectedColorChannel)}exports.Agent = le; exports.Search = ne; exports.getAppSettings = Ht; exports.getAppUserPermissions = Xt; exports.getAppUserSettings = Kt; exports.getNotificationsClient = qt; exports.launchContent = Jt; exports.launchSupertab = Qt; exports.launchWorkspace = Yt; exports.setAppUserSettings = zt; | ||
| //# sourceMappingURL=index.cjs.map | ||
| "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } async function _asyncOptionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = await fn(value); } else if (op === 'call' || op === 'optionalCall') { value = await fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var tt=Object.create;var En=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var at=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Kn=(t,i)=>{for(var r in i)En(t,r,{get:i[r],enumerable:!0})},ct=(t,i,r,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of rt(i))!st.call(t,d)&&d!==r&&En(t,d,{get:()=>i[d],enumerable:!(a=ot(i,d))||a.enumerable});return t};var vn=(t,i,r)=>(r=t!=null?tt(it(t)):{},ct(i||!t||!t.__esModule?En(r,"default",{value:t,enumerable:!0}):r,t));var on=at((no,Xn)=>{"use strict";(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},i={};t.r(i),t.d(i,{SearchTagBackground:()=>cn,create:()=>Vn,defaultTopic:()=>jn,subscribe:()=>qn});var r={};t.r(r),t.d(r,{B:()=>Oe});var a={};t.r(a),t.d(a,{v:()=>Ye});let d="deregistered or does not exist",h=new Error(`provider ${d}`),m=new Error("provider with name already exists"),w=new Error("bad payload"),C=new Error("subscription rejected"),S=new Error(`channel ${d}`),P;function b(){if(P)return P;throw S}function H(){return P}function In(n){P=n}var O,x,an,cn;(function(n){n[n.Initial=0]="Initial",n[n.Open=1]="Open",n[n.Close=2]="Close"})(O||(O={})),(function(n){n.Fetching="fetching",n.Fetched="fetched",n.Complete="complete"})(x||(x={})),(function(n){n.UserAction="user-action",n.FocusChange="focus-change",n.Reload="reload"})(an||(an={})),(function(n){n.Active="active",n.Default="default"})(cn||(cn={}));let K="0",Pn="1",bn="2",Nn="3",Ln="4",z="5",X="6",ue=()=>{},ln=new Set;function de(n){ln.add(n)}function pe(n){ln.delete(n)}let un=new Set;function fe(n){un.add(n)}function he(n){un.delete(n)}let j=new Map;async function dn(n){j.set(n.id,n);let e=[...ln].map((o=>o()));await Promise.all(e)}async function J(n){j.delete(n);let e=[...un].map((o=>o()));await Promise.all(e)}function pn(){return[...j.values()]}function Fn(){j.clear()}function L(n){return j.get(n)}function _n(n,e,o){return{...n,action:o||{...n.actions[0],trigger:an.UserAction},dispatcherIdentity:e}}function fn(n,e,o="ascending"){let s=n||[];if(!_optionalChain([e, 'optionalAccess', _2 => _2.length]))return s;let c=[],l=new Map;e.forEach((p=>{if(p.key)return l.set(p.key,p);c.push(p)}));let u=s.map((p=>{let{key:g}=p;if(g&&l.has(g)){let v=l.get(g);return l.delete(g),v}return p}));return u.push(...l.values(),...c),u=o==="ascending"?u.sort(((p,g)=>(_nullishCoalesce(_optionalChain([p, 'optionalAccess', _3 => _3.score]), () => (1/0)))-(_nullishCoalesce(_optionalChain([g, 'optionalAccess', _4 => _4.score]), () => (1/0))))):u.sort(((p,g)=>(_nullishCoalesce(_optionalChain([g, 'optionalAccess', _5 => _5.score]), () => (1/0)))-(_nullishCoalesce(_optionalChain([p, 'optionalAccess', _6 => _6.score]), () => (1/0))))),u}function Tn(n){let e={},o=[],s=[],c=null,l=O.Initial;e.getStatus=()=>l,e.getResultBuffer=()=>o,e.setResultBuffer=p=>{o=p,_optionalChain([o, 'optionalAccess', _7 => _7.length])&&e.onChange()},e.getRevokedBuffer=()=>s,e.setRevokedBuffer=p=>{s=p,_optionalChain([s, 'optionalAccess', _8 => _8.length])&&e.onChange()},e.setUpdatedContext=p=>{c=p,e.onChange()},e.getUpdatedContext=()=>c,e.onChange=ue;let u={};return e.res=u,u.close=()=>{l!==O.Close&&(l=O.Close,e.onChange())},u.open=()=>{l!==O.Open&&(l=O.Open,e.onChange())},u.respond=p=>{let g=fn(e.getResultBuffer(),p,n);e.setResultBuffer(g)},u.revoke=(...p)=>{let g=new Set(p),v=e.getResultBuffer().filter((({key:f})=>{let R=g.has(f);return R&&g.delete(f),!R}));e.setResultBuffer(v),g.size&&(e.getRevokedBuffer().forEach((f=>g.add(f))),e.setRevokedBuffer([...g]))},u.updateContext=p=>{e.setUpdatedContext(p)},e}function xn(n,e){let o=new Set,s=!1;return{close:()=>{s=!0;for(let c of o)c()},req:{id:n,...e,context:_optionalChain([e, 'optionalAccess', _9 => _9.context])||{},onClose:c=>{o.add(c),s&&c()},removeListener:c=>{o.delete(c)}}}}function Q(){return{name:fin.me.name,uuid:fin.me.uuid}}let kn=50,ge=1e3,we=new Map;function hn(){return we}let ye=100;function me(){return async n=>{if(!n||!n.id||!n.providerId){let f=w;return console.error(f),{error:f.message}}let{id:e,providerId:o}=n,s=L(o);if(!s){let f=h;return console.error(f),{error:f.message}}let c=hn(),l=c.get(n.id);l||(l=xn(e,n),c.set(n.id,l));let u=Tn(),p=()=>{let f=u.getResultBuffer();u.setResultBuffer([]);let R=u.getRevokedBuffer();u.setRevokedBuffer([]);let F=u.getUpdatedContext();u.setUpdatedContext(null);let $=u.getStatus();(async function(M){(await b()).dispatch(K,M)})({id:e,providerId:o,results:f,revoked:R,status:$,context:F})},g=!0,v=!1;u.onChange=()=>{if(g)return g=!1,void p();v||(v=!0,setTimeout((()=>{v=!1,p()}),ye))};try{let{results:f,context:R}=await s.onUserInput(l.req,u.res),F=u.getStatus();return{id:e,providerId:o,status:F,results:f,context:R}}catch(f){return console.error(`OpenFin/Workspace/Home. Uncaught exception in search provider ${o} for search ${e}`,"This is likely a bug in the implementation of the search provider.",f),{id:e,providerId:o,error:_optionalChain([f, 'optionalAccess', _10 => _10.message])}}}}async function $n(n,e){let o=e||await b(),s=Q(),c={...n,identity:s,onResultDispatch:void 0},l=await o.dispatch(bn,c);return await dn({identity:s,...n}),l}async function Ce(n){return await(await b()).dispatch(Nn,n),J(n)}async function Se(n,e,o,s){let c=_n(e,_nullishCoalesce(s, () => (Q())),o),l=L(n);if(l){let{onResultDispatch:p}=l;return p?p(c):void 0}let u={providerId:n,result:c};return(await b()).dispatch(z,u)}async function Re(n){let e={...n,context:_optionalChain([n, 'optionalAccess', _11 => _11.context])||{}},o={},s=(async function*(l,{setState:u}){let p=await b();for(;;){let g=await p.dispatch(Pn,l),v=g.error;if(v)throw new Error(v);let f=g;if(l.id=f.id,u(f.state),f.done)return f.value;yield f.value}})(e,{setState:l=>{o.state=l}}),c=await s.next();return o.id=e.id||"",o.close=()=>{(async function(l){(await b()).dispatch(X,{id:l})})(o.id)},o.next=()=>{if(c){let l=c;return c=void 0,l}return s.next()},o}async function Ee(){return(await b()).dispatch(Ln,null)}async function ve(){let n=await b();P=void 0,Fn(),await n.disconnect()}let Ae=async n=>{let e=await Un(n);for(let o of pn())await $n(o,e);return e};async function Un(n){let e=await(async function(o){for(let s=0;s<kn;s++)try{return await fin.InterApplicationBus.Channel.connect(o,{wait:!1})}catch(c){if(s===kn-1)throw c;await new Promise((l=>setTimeout(l,ge)))}})(n);return e.register(K,me()),e.register(X,(o=>{let s=hn(),c=s.get(o.id);c&&(c.close(),s.delete(o.id))})),e.register(z,(async(o,s)=>{if(!o||!o.providerId||!o.result)return void console.error(w);let c=L(o.providerId);if(!c)return void console.error(h);let{onResultDispatch:l}=c;return l?(o.result.dispatcherIdentity=_nullishCoalesce(o.result.dispatcherIdentity, () => (s)),l(o.result)):void 0})),e.onDisconnection((function(o){return async()=>{if(!H())return;let s=hn();for(let{req:c,close:l}of s.values())l(),s.delete(c.id);In(Ae(o))}})(n)),e}async function Oe(n){let e=H();e||(e=Un(n),In(e));let o=await e;return{getAllProviders:Ee.bind(null),register:$n.bind(null),search:Re.bind(null),deregister:Ce.bind(null),dispatch:Se.bind(null),disconnect:ve.bind(null),channel:o}}let G;function Y(){if(G)return G;throw S}function Ie(){return G}function Pe(n){G=n}function be(){G=void 0}let gn=new Set;function Ne(n){gn.add(n)}function Le(n){gn.delete(n)}var k;(function(n){n.Local="local",n.Dev="dev",n.Staging="staging",n.Prod="prod"})(k||(k={}));let wn=typeof window<"u"&&typeof fin<"u",Fe=(typeof process>"u"||process.env,typeof window<"u"),_e=Fe?window.origin:k.Local,Z=(wn&&fin.me.uuid,wn&&fin.me.name,wn&&fin.me.entityType,k.Local,k.Dev,k.Staging,k.Prod,n=>n.startsWith("http://")||n.startsWith("https://")?n:_e+n),Dn=(Z("http://localhost:4002"),Z("http://localhost:4002"),typeof WORKSPACE_DOCS_PLATFORM_URL<"u"&&Z(WORKSPACE_DOCS_PLATFORM_URL),typeof WORKSPACE_DOCS_CLIENT_URL<"u"&&Z(WORKSPACE_DOCS_CLIENT_URL),"20.3.6");typeof WORKSPACE_BUILD_SHA<"u"&&WORKSPACE_BUILD_SHA;async function Mn(){return[...pn()].map((n=>({...n,onUserInput:void 0,onResultDispatch:void 0})))}async function Te(n){if(L(n.id))throw new Error("provider with name already exists");let e=Q();return await dn({identity:e,...n}),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}async function xe(n){await J(n)}async function ke(n,e,o,s){let c=L(n);if(!c)throw h;let{onResultDispatch:l}=c;if(l)return l(_n(e,_nullishCoalesce(s, () => (Q())),o))}async function*$e(n,e){let o=(function(R,F){let $=[],M=[],B=[],I=[];for(let E of R){let _=Tn(E.scoreOrder),T={results:[],provider:{id:E.id,identity:E.identity,title:E.title,scoreOrder:E.scoreOrder,icon:E.icon,dispatchFocusEvents:E.dispatchFocusEvents}};$.push(T),M.push(_);let W=(async()=>{try{let{results:V,context:en}=await E.onUserInput(F,_.res);T.results=fn(T.results||[],V,E.scoreOrder),T.context={...T.context,...en}}catch(V){T.error=V}})();W.finally((()=>{W.done=!0})),I.push(W),B.push(B.length)}return{providerResponses:$,listenerResponses:M,openListenerResponses:B,initialResponsePromises:I}})(n.targets?n.targets.map((R=>L(R))).filter((R=>!!R)):[...pn().filter((R=>!R.hidden))],n),{providerResponses:s,listenerResponses:c}=o,{openListenerResponses:l,initialResponsePromises:u}=o,p=x.Fetching,g=R=>{p=R,e.setState(p)},v,f=!1;n.onClose((()=>{f=!0,v&&v()}));do{let R=!1;if(u.length){let I=[];for(let E of u)E.done?R=!0:I.push(E);u=I,u.length||(g(x.Fetched),R=!0)}let F,$=!1,M=()=>{$=!0,F&&F()},B=[];for(let I of l){let E=c[I],_=s[I],T=E.getStatus();(T===O.Open||p===x.Fetching&&T===O.Initial)&&(B.push(I),E.onChange=M);let W=E.getResultBuffer();W.length&&(E.setResultBuffer([]),_.results=fn(_.results||[],W),R=!0);let V=E.getRevokedBuffer();if(V.length){E.setRevokedBuffer([]);let nt=new Set(V);_.results=(_.results||[]).filter((({key:et})=>!nt.has(et))),R=!0}let en=E.getUpdatedContext();en&&(E.setUpdatedContext(null),_.context={..._.context,...en},R=!0)}if(l=B,R&&(yield s),f)break;$||(l.length||u.length)&&await Promise.race([...u,new Promise((I=>{F=I})),new Promise((I=>{v=I}))])}while(l.length||u.length);return g(x.Complete),s}let yn=0;async function Bn(n){yn+=1;let e=xn(yn.toString(),n),o=$e(e.req,{setState:s=>{o.state=s}});return o.id=yn.toString(),o.close=e.close,o.state=x.Fetching,o}let nn=new Map,Ue=1e4;function De(){return async n=>{if(!n)return console.error(w),{error:w.message};let e;if(n.id)e=n.id;else{let c=await Bn(n);e=c.id,n.id=c.id,nn.set(e,{generator:c})}let o=nn.get(e);clearTimeout(o.timeout);let s=await o.generator.next();return o.timeout=(function(c){return window.setTimeout((()=>{nn.delete(c)}),Ue)})(e),{...s,id:n.id,state:o.generator.state}}}function Me(n,e){return Y().dispatch(n,X,{id:e})}function Be(){return n=>(function(e){let o=nn.get(e);o&&o.generator.close()})(n.id)}async function We(n,{id:e,query:o,context:s,targets:c=[]}){let l=Y(),u={id:e,query:o,context:s,targets:c,providerId:n.id},p=await l.dispatch(n.identity,K,u),g=p.error;if(g)throw new Error(g);return p}let mn=new Map;function Ve(n,e){return`${n.name}:${n.uuid}:${e}`}let Cn=new Map;function Wn(n,e){return`${n}:${e}`}function qe(n){let e=Ve.bind(null,n.identity),o=Me.bind(null,n.identity),s=We.bind(null,n);return async(c,l)=>{let u=e(c.id);if(!mn.has(u)){let f=()=>{o(c.id),mn.delete(u)};mn.set(u,f),c.onClose(f)}let p=Wn(n.id,c.id),g=()=>{Cn.delete(p),l.close()};c.onClose(g),Cn.set(p,(f=>{_optionalChain([f, 'access', _12 => _12.results, 'optionalAccess', _13 => _13.length])&&l.respond(f.results),_optionalChain([f, 'access', _14 => _14.revoked, 'optionalAccess', _15 => _15.length])&&l.revoke(...f.revoked),f.context&&l.updateContext(f.context),f.status===O.Open&&l.open(),f.status===O.Close&&g()}));let v=await s(c);return v.status===O.Open&&l.open(),v.status!==O.Close&&v.status!==O.Initial||g(),v}}function je(n){return async e=>{let o=Y(),s={providerId:n.id,result:e};return o.dispatch(n.identity,z,s)}}let D=new Map;function Sn(n){return`${n.name}-${n.uuid}`}function Ge(){return async(n,e)=>{if(!n||!n.id)return console.error(new Error(JSON.stringify(n))),void console.error(w);if(L(n.id))throw m;return n.identity=e,await(async function(o){let s=Sn(o.identity);D.has(s)||D.set(s,[]),D.get(s).push(o.id),await dn({...o,onUserInput:qe(o),onResultDispatch:je(o)})})(n),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}}function He(){return(n,e)=>{n?(function(o,s){let c=L(o);if(!c)return;if(c.identity.uuid!==s.uuid||c.identity.name!==s.name)throw h;let l=Sn(c.identity),u=D.get(l);if(u){let p=u.findIndex((g=>g===o));p!==-1&&(u.splice(p,1),J(o))}})(n,e):console.error(w)}}let Rn=new Set;function Ke(n){Rn.add(n)}function ze(n){Rn.delete(n)}function Xe(){return async n=>{(function(e){let o=Sn(e),s=D.get(o);if(s){for(let c of s)J(c);D.delete(o)}})(n),Rn.forEach((e=>e(n)))}}async function Je(n){let e=await(o=n,fin.InterApplicationBus.Channel.create(o));var o;return e.onConnection((async s=>{for(let c of gn)if(!await c(s))throw C})),e.onDisconnection(Xe()),e.register(X,Be()),e.register(K,(s=>{let c=Wn(s.providerId,s.id),l=Cn.get(c);l&&l(s)})),e.register(bn,Ge()),e.register(Nn,He()),e.register(Ln,(async()=>Mn())),e.register(Pn,De()),e.register(z,(async(s,c)=>{if(!s||!s.providerId||!s.result)return void console.error(w);let l=L(s.providerId);if(!l)throw h;let{onResultDispatch:u}=l;return u?(s.result.dispatcherIdentity=_nullishCoalesce(s.result.dispatcherIdentity, () => (c)),u(s.result)):void 0})),e}async function Qe(){let n=Y();be(),await n.destroy(),Fn()}async function Ye(n){let e=Ie();e||(e=await Je(n),Pe(e));let o=Le.bind(null),s=ze.bind(null),c=pe.bind(null),l=he.bind(null);return{getAllProviders:Mn.bind(null),search:Bn.bind(null),register:Te.bind(null),deregister:xe.bind(null),onSubscription:Ne.bind(null),onDisconnect:Ke.bind(null),onRegister:de.bind(null),onDeregister:fe.bind(null),dispatch:ke.bind(null),disconnect:Qe.bind(null),removeListener:u=>{o(u),s(u),c(u),l(u)},channel:e}}let{v:Vn}=a,{B:qn}=r,jn="all",Ze={create:Vn,subscribe:qn,defaultTopic:jn},Gn=()=>{window.search=Ze},Hn=n=>{let e=()=>{Gn(),window.removeEventListener(n,e)};return e};if(typeof window<"u"){Gn();let n="load",e=Hn(n);window.addEventListener(n,e);let o="DOMContentLoaded",s=Hn(o);window.addEventListener(o,s)}Xn.exports=i})()});var y="@openfin/cloud-api";async function N(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch (e2){return!1}}function zn(t){if(t.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(t.name)?t.name.split("/")[0]||"":t.name}var q="@openfin/cloud-api";function lt(){return`${window.fin.me.uuid}-cloud-api-notifications`}var An=null;async function qt(){return An||(An=ut()),An}async function ut(){if(!window.fin)throw new Error(`\`${q}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${q}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);zn(window.fin.me);let t=await dt();console.log(t),t.register("openfin-cloud-event",r=>{for(let a of _nullishCoalesce(i.get(r.type), () => ([])))typeof r.payload.timestamp=="string"&&(r.payload.timestamp=new Date(r.payload.timestamp)),a(r.payload)});let i=new Map;return{addEventListener:(r,a)=>{let d=i.get(r)||new Set;d.add(a),i.set(r,d)},removeEventListener:(r,a)=>{let d=i.get(r);if(!d){console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,r);return}d.delete(a)===!1&&console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,r)},update:async r=>(await t.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:r}})).payload.response,clear:async r=>(await t.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:r}})).payload.response,createNotification:async r=>(r.id&&console.warn(`\`${q}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await t.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...r,id:void 0}}})).payload.response)}}var tn=null;async function dt(){return tn||(tn=pt()),tn}async function pt(){let t=await window.fin.InterApplicationBus.Channel.connect(lt());return t.onDisconnection(i=>{console.warn(`\`${q}\`: Channel Disconnected from`,i,"Reconnecting..."),tn=null}),t}var On;function ft(){return`${window.fin.me.uuid}-client-api`}async function U(){return On||(On=window.fin.InterApplicationBus.Channel.connect(ft())),On}async function Ht(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-settings")}async function Kt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-settings")}async function zt(t){if(!window.fin)throw new Error(`\`${y}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("set-user-settings",t)}async function Xt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-permissions")}async function Jt(t,i){if(!window.fin)throw new Error(`\`${y}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let r=await U();try{await r.dispatch("launch-content",{id:t,options:i})}catch(a){switch(a instanceof Error?a.message:String(a)){case"UnableToLookup":throw new Error(`${y}: \`launchContent\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchContent\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchContent\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchContent\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Qt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-supertab",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchSupertab\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchSupertab\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchSupertab\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchSupertab\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Yt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-workspace",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchWorkspace\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchWorkspace\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchWorkspace\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchWorkspace\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}var ne={};Kn(ne,{getAgentConfiguration:()=>Yn,register:()=>Zn});var Qn=vn(on(),1),ht="[here-agent]",gt="log-message-",wt="open-url",yt="provider-status-",mt="registered-",Ct="1.0";function St(t,i){let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}}function Jn(t){return{...t,data:t.data.customData}}async function Yn(){let{customData:t}=await window.fin.me.getOptions();return t}function Rt(){return`${window.fin.me.identity.uuid}-cloud-api-search`}async function Et(t,i,r,a=!0){await i("info",`Setting status as ${a?"ready":"not ready"}`);try{await t.dispatch(`${yt}${r}`,{isReady:a})}catch(d){let h=["Error setting provider status",d];console.error(...h),i("error",...h)}}async function vt(t,i,r,...a){try{console.log(ht,...a),await t.dispatch(`${gt}${i}`,{level:r,message:a})}catch(d){console.error("Error logging message",d)}}async function At(t,i,r,a,d){let{action:h,dispatcherIdentity:m,...w}=d;await r("info","Handling action",{action:h,dispatcherIdentity:m,result:w});let C;try{let P=_optionalChain([Jn, 'call', _16 => _16(d), 'access', _17 => _17.actions, 'optionalAccess', _18 => _18.find, 'call', _19 => _19(({name:H})=>H===h.name)]);if(!P)throw new Error("Original action not found in search result");C=await _asyncOptionalChain([(await a(P,Jn(d))), 'optionalAccess', async _20 => _20.url])}catch(S){throw await r("error","Error handling dispatch",S),S}if(!C){await r("warn","OnActionListener did not return a URL");return}await It(t,r,i,C,m)}async function Ot(t,i,r,a){await i("info","Getting search results",{request:a});try{let d=new AbortController;a.onClose(()=>d.abort());let{context:h,query:m}=a,{results:w}=await r({context:h,query:m,signal:d.signal}),C=w.map(S=>St(S,t));return await i("info","Returning results",C),{results:C}}catch(d){let h=["Error handling search",d];throw console.error(...h),i("error",...h),d}}async function It(t,i,r,a,d){await i("info","Opening URL",{url:a,targetIdentity:d});try{await t.dispatch(wt,{url:a,targetIdentity:d,providerId:r})}catch(h){let m=["Error opening URL",h];console.error(...m),i("error",...m)}}async function Zn(t){let r=(await window.fin.me.getOptions()).customData,{id:a,title:d}=r,{onAction:h,onSearch:m}=t,w=await Qn.subscribe(Rt()),C=w.channel,S=vt.bind(null,C,a);return await w.register({icon:"",id:a,onResultDispatch:At.bind(null,C,a,S,h),onUserInput:Ot.bind(null,a,S,m),title:d}),await w.channel.dispatch(`${mt}${a}`,{version:Ct}),S("info","Registered search topic",{id:a,title:d}),{isReady:Et.bind(null,C,S,a)}}var le={};Kn(le,{getConfiguration:()=>ae,register:()=>ce});var se=vn(on(),1);var rn=class extends Error{constructor(){super("Interop feature is not supported by the agent")}};async function sn(t,i){try{let r=await window.fin.me.interop.getFDC3(t);i==="none"?(A("Leaving current channel"),await r.leaveCurrentChannel()):(A(`Joining interop channel: ${i}`),await("joinUserChannel"in r?r.joinUserChannel(i):r.joinChannel(i)))}catch(r){A(`Failed to join interop channel: ${i}`,r)}}var ro=vn(on(),1);var Nt=(t,i)=>{let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}},ee=t=>({...t,data:t.data.customData}),te=()=>`${window.fin.me.identity.uuid}-cloud-api-search`,Lt=async({channel:t,url:i,targetIdentity:r})=>{A("Opening URL",{url:i,targetIdentity:r});try{await t.dispatch(ie,{url:i,targetIdentity:r})}catch(a){console.error("Failed opening URL",a)}},oe=async(t,i,r,a)=>{let{action:d,dispatcherIdentity:h,...m}=a;A("Handling action...",{action:d,dispatcherIdentity:h,result:m});let w;try{let S=_optionalChain([ee, 'call', _21 => _21(a), 'access', _22 => _22.actions, 'optionalAccess', _23 => _23.find, 'call', _24 => _24(({name:b})=>b===d.name)]);if(!S)throw new Error("Original action not found in search result");w=await _asyncOptionalChain([(await r(S,ee(a))), 'optionalAccess', async _25 => _25.url])}catch(C){throw A("Error handling dispatch",C),C}if(!w){A("OnActionListener did not return a URL");return}await Lt({channel:t,url:w,targetIdentity:h})},re=async(t,i,r)=>{A("Getting search results...",{request:r});try{let a=new AbortController;r.onClose(()=>a.abort());let{context:d,query:h}=r,{results:m}=await i({context:d,query:h,signal:a.signal}),w=m.map(C=>Nt(C,t));return A("Returning results",w),{results:w}}catch(a){throw new Error("Error handling search request",{cause:a})}};var _t="[here-agent]",Tt="1.0",xt="-enterprise-component-bridge",ie="open-url",kt="set-agent-registered",$t="set-agent-status",ae=async()=>{let{customData:t}=await window.fin.me.getOptions(),i=t,{configurationFields:r}=i;return Object.fromEntries(_nullishCoalesce(_optionalChain([r, 'optionalAccess', _26 => _26.map, 'call', _27 => _27(a=>[a.name,a.value])]), () => ([])))};async function Ut(t,i){if(!t.interop)throw new rn;let{fdc3Version:r}=t.interop;await sn(r,i)}function A(...t){console.log(_t,...t)}var Dt=async(t,i,r=!0)=>{A(`Setting status to ${r?"ready":"not ready"}`);try{await t.dispatch($t,{id:i,isReady:r})}catch(a){throw new Error("Failed to set agent status",{cause:a})}};async function ce(t){let{customData:i}=await window.fin.me.getOptions(),r=i;A("Registering agent...",r);try{let a=`${window.fin.me.identity.uuid}${xt}`,d;try{d=await window.fin.InterApplicationBus.Channel.connect(a,{wait:!1})}catch(S){throw new Error("Failed to connect to enterprise component bridge channel",{cause:S})}let{id:h,features:m,title:w}=r,C={features:m,joinInteropChannel:Ut.bind(null,m),setIsReady:Dt.bind(null,d,h)};if(m.interop){A("Enabling interop features");let{defaultChannel:S,fdc3Version:P}=m.interop;S&&S!=="none"&&await sn(P,S),d.register("on-desktop-app-signals-changed",Mt.bind(null,r))}return m.search&&t.search&&(A("Enabling search features"),await(await se.subscribe(te())).register({icon:"",id:h,onResultDispatch:oe.bind(null,d,h,t.search.onAction),onUserInput:re.bind(null,h,t.search.onSearch),title:w})),await d.dispatch(kt,{id:h,apiVersion:Tt}),A("Registered successfully"),C}catch(a){throw new Error("Failed to register agent",{cause:a})}}function Mt(t,i){A("Desktop app signals changed",i);let r=i,{type:a,id:d,features:h}=t,{fdc3Version:m}=h.interop,w=r.find(C=>a==="agent"?C.appKey===t.name:a==="custom"?C.appKey===d:!1);w&&sn(m,w.selectedColorChannel)}exports.Agent = le; exports.Search = ne; exports.getAppSettings = Ht; exports.getAppUserPermissions = Xt; exports.getAppUserSettings = Kt; exports.getNotificationsClient = qt; exports.launchContent = Jt; exports.launchSupertab = Qt; exports.launchWorkspace = Yt; exports.setAppUserSettings = zt; |
+49
-37
@@ -301,3 +301,3 @@ import * as OpenFin from '@openfin/core'; | ||
| /** | ||
| * Function that is called when the Search Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * Function that is called when the Search Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
@@ -307,7 +307,7 @@ * @param action The action that was triggered. | ||
| * | ||
| * @returns Result that includes the URL that Here™ should navigate to, or `undefined` if no navigation is required. | ||
| * @returns Result that includes the URL that HERE should navigate to, or `undefined` if no navigation is required. | ||
| */ | ||
| type OnActionListener = (action: SearchAction$1, result: SearchResult$1) => SearchResultActionResponse$1 | Promise<SearchResultActionResponse$1>; | ||
| /** | ||
| * Function that is called when the Search Agent receives a query from Here™’s search UI | ||
| * Function that is called when the Search Agent receives a query from HERE's search UI | ||
| * | ||
@@ -322,15 +322,15 @@ * @param request Search request data that includes the query. | ||
| * | ||
| * Actions are displayed as buttons alongside search results in Here™’s search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| * Actions are displayed as buttons alongside search results in HERE's search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| */ | ||
| type SearchAction$1 = { | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Light mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Light mode. | ||
| */ | ||
| darkIcon?: string; | ||
| /** | ||
| * A fuller description of the action that will be displayed in Here™’s search UI when the user hovers over the action button. | ||
| * A fuller description of the action that will be displayed in HERE's search UI when the user hovers over the action button. | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Dark mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Dark mode. | ||
| */ | ||
@@ -348,3 +348,3 @@ lightIcon?: string; | ||
| /** | ||
| * A Search Agent returns search results to Here™’s search UI in response to user input, and acts on the user’s actions regarding those results. | ||
| * A Search Agent returns search results to HERE's search UI in response to user input, and acts on the user's actions regarding those results. | ||
| * | ||
@@ -366,3 +366,3 @@ * @deprecated Use {@link Agent} instead. | ||
| /** | ||
| * The Search Agent’s configuration data as configured in the Here™ Admin Console. | ||
| * The Search Agent's configuration data as configured in the HERE Admin Console. | ||
| * | ||
@@ -398,9 +398,9 @@ * @typeParam T Type definition for the `customData` property, containing any custom configuration data specific to the Search Agent. | ||
| /** | ||
| * This listener is called when the Search Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * This listener is called when the Search Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
| * The listener returns a response back to Here™ that includes a URL to navigate to. | ||
| * The listener returns a response back to HERE that includes a URL to navigate to. | ||
| */ | ||
| onAction: OnActionListener; | ||
| /** | ||
| * This listener is called when the Search Agent receives a query from Here™’s search UI and returns relevant search results. | ||
| * This listener is called when the Search Agent receives a query from HERE's search UI and returns relevant search results. | ||
| * | ||
@@ -420,3 +420,3 @@ * Note: When the Search Agent is not ready this listener will not be called. | ||
| /** | ||
| * The query entered by the user in Here™’s search UI. | ||
| * The query entered by the user in HERE's search UI. | ||
| */ | ||
@@ -451,3 +451,3 @@ query: string; | ||
| /** | ||
| * The search results to display in Here™’s search UI. | ||
| * The search results to display in HERE's search UI. | ||
| */ | ||
@@ -469,3 +469,3 @@ results: SearchResult$1[]; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed with the search result in Here™’s search UI. | ||
| * URL or data URI of an icon that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -478,7 +478,7 @@ icon?: string; | ||
| /** | ||
| * Secondary text that will be displayed with the search result in Here™’s search UI. | ||
| * Secondary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
| label?: string; | ||
| /** | ||
| * Primary text that will be displayed with the search result in Here™’s search UI. | ||
| * Primary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -492,3 +492,3 @@ title: string; | ||
| /** | ||
| * URL that Here™ should navigate to. | ||
| * URL that HERE should navigate to. | ||
| */ | ||
@@ -499,3 +499,3 @@ url: string; | ||
| /** | ||
| * Retrieves the Search Agent’s configuration data, as has been configured in the Here™ Admin Console. | ||
| * Retrieves the Search Agent's configuration data, as has been configured in the HERE Admin Console. | ||
| * | ||
@@ -522,3 +522,3 @@ * @returns A promise that resolves with an object containing properties that match the Search Agent’s configuration. | ||
| /** | ||
| * Registers a Search Agent that will provide search results to Here™’s search UI in response to user input and act on the user’s actions regarding those results. | ||
| * Registers a Search Agent that will provide search results to HERE's search UI in response to user input and act on the user's actions regarding those results. | ||
| * | ||
@@ -619,3 +619,3 @@ * @param config The configuration for the Search Agent. | ||
| /** | ||
| * Function that is called when the Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * Function that is called when the Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
@@ -625,7 +625,7 @@ * @param action The action that was triggered. | ||
| * | ||
| * @returns Result that includes the URL that Here™ should navigate to, or `undefined` if no navigation is required. | ||
| * @returns Result that includes the URL that HERE should navigate to, or `undefined` if no navigation is required. | ||
| */ | ||
| type OnSearchActionListener = (action: SearchAction, result: SearchResult) => SearchResultActionResponse | Promise<SearchResultActionResponse>; | ||
| /** | ||
| * Function that is called when the Agent receives a query from Here™’s search UI | ||
| * Function that is called when the Agent receives a query from HERE's search UI | ||
| * | ||
@@ -640,15 +640,15 @@ * @param request Search request data that includes the query. | ||
| * | ||
| * Actions are displayed as buttons alongside search results in Here™’s search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| * Actions are displayed as buttons alongside search results in HERE's search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| */ | ||
| type SearchAction = { | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Light mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Light mode. | ||
| */ | ||
| darkIcon?: string; | ||
| /** | ||
| * A fuller description of the action that will be displayed in Here™’s search UI when the user hovers over the action button. | ||
| * A fuller description of the action that will be displayed in HERE's search UI when the user hovers over the action button. | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Dark mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Dark mode. | ||
| */ | ||
@@ -674,3 +674,3 @@ lightIcon?: string; | ||
| /** | ||
| * The query entered by the user in Here™’s search UI. | ||
| * The query entered by the user in HERE's search UI. | ||
| */ | ||
@@ -688,2 +688,10 @@ query: string; | ||
| /** | ||
| * Filters to apply to the search results. | ||
| */ | ||
| filters: string[]; | ||
| /** | ||
| * The locale of the client. | ||
| */ | ||
| locale: string; | ||
| /** | ||
| * The page number of the search results to return. | ||
@@ -700,2 +708,6 @@ */ | ||
| queryId: string; | ||
| /** | ||
| * The timezone of the client. | ||
| */ | ||
| timeZone: string; | ||
| }; | ||
@@ -707,3 +719,3 @@ /** | ||
| /** | ||
| * The search results to display in Here™’s search UI. | ||
| * The search results to display in HERE's search UI. | ||
| */ | ||
@@ -725,3 +737,3 @@ results: SearchResult[]; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed with the search result in Here™’s search UI. | ||
| * URL or data URI of an icon that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -734,7 +746,7 @@ icon?: string; | ||
| /** | ||
| * Secondary text that will be displayed with the search result in Here™’s search UI. | ||
| * Secondary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
| label?: string; | ||
| /** | ||
| * Primary text that will be displayed with the search result in Here™’s search UI. | ||
| * Primary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -748,3 +760,3 @@ title: string; | ||
| /** | ||
| * URL that Here™ should navigate to. | ||
| * URL that HERE should navigate to. | ||
| */ | ||
@@ -794,9 +806,9 @@ url: string; | ||
| /** | ||
| * This listener is called when the Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * This listener is called when the Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
| * The listener returns a response back to Here™ that includes a URL to navigate to. | ||
| * The listener returns a response back to HERE that includes a URL to navigate to. | ||
| */ | ||
| onAction: OnSearchActionListener; | ||
| /** | ||
| * This listener is called when the Agent receives a query from Here™’s search UI and returns relevant search results. | ||
| * This listener is called when the Agent receives a query from HERE's search UI and returns relevant search results. | ||
| * | ||
@@ -822,3 +834,3 @@ * Note: When the Agent is not ready this listener will not be called. | ||
| /** | ||
| * Retrieves the Agent’s configuration data, as has been configured in the Here™ Admin Console. | ||
| * Retrieves the Agent's configuration data, as has been configured in the HERE Admin Console. | ||
| * | ||
@@ -825,0 +837,0 @@ * @returns A promise that resolves with an object containing properties that match the Agent’s configuration. |
+49
-37
@@ -301,3 +301,3 @@ import * as OpenFin from '@openfin/core'; | ||
| /** | ||
| * Function that is called when the Search Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * Function that is called when the Search Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
@@ -307,7 +307,7 @@ * @param action The action that was triggered. | ||
| * | ||
| * @returns Result that includes the URL that Here™ should navigate to, or `undefined` if no navigation is required. | ||
| * @returns Result that includes the URL that HERE should navigate to, or `undefined` if no navigation is required. | ||
| */ | ||
| type OnActionListener = (action: SearchAction$1, result: SearchResult$1) => SearchResultActionResponse$1 | Promise<SearchResultActionResponse$1>; | ||
| /** | ||
| * Function that is called when the Search Agent receives a query from Here™’s search UI | ||
| * Function that is called when the Search Agent receives a query from HERE's search UI | ||
| * | ||
@@ -322,15 +322,15 @@ * @param request Search request data that includes the query. | ||
| * | ||
| * Actions are displayed as buttons alongside search results in Here™’s search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| * Actions are displayed as buttons alongside search results in HERE's search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| */ | ||
| type SearchAction$1 = { | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Light mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Light mode. | ||
| */ | ||
| darkIcon?: string; | ||
| /** | ||
| * A fuller description of the action that will be displayed in Here™’s search UI when the user hovers over the action button. | ||
| * A fuller description of the action that will be displayed in HERE's search UI when the user hovers over the action button. | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Dark mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Dark mode. | ||
| */ | ||
@@ -348,3 +348,3 @@ lightIcon?: string; | ||
| /** | ||
| * A Search Agent returns search results to Here™’s search UI in response to user input, and acts on the user’s actions regarding those results. | ||
| * A Search Agent returns search results to HERE's search UI in response to user input, and acts on the user's actions regarding those results. | ||
| * | ||
@@ -366,3 +366,3 @@ * @deprecated Use {@link Agent} instead. | ||
| /** | ||
| * The Search Agent’s configuration data as configured in the Here™ Admin Console. | ||
| * The Search Agent's configuration data as configured in the HERE Admin Console. | ||
| * | ||
@@ -398,9 +398,9 @@ * @typeParam T Type definition for the `customData` property, containing any custom configuration data specific to the Search Agent. | ||
| /** | ||
| * This listener is called when the Search Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * This listener is called when the Search Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
| * The listener returns a response back to Here™ that includes a URL to navigate to. | ||
| * The listener returns a response back to HERE that includes a URL to navigate to. | ||
| */ | ||
| onAction: OnActionListener; | ||
| /** | ||
| * This listener is called when the Search Agent receives a query from Here™’s search UI and returns relevant search results. | ||
| * This listener is called when the Search Agent receives a query from HERE's search UI and returns relevant search results. | ||
| * | ||
@@ -420,3 +420,3 @@ * Note: When the Search Agent is not ready this listener will not be called. | ||
| /** | ||
| * The query entered by the user in Here™’s search UI. | ||
| * The query entered by the user in HERE's search UI. | ||
| */ | ||
@@ -451,3 +451,3 @@ query: string; | ||
| /** | ||
| * The search results to display in Here™’s search UI. | ||
| * The search results to display in HERE's search UI. | ||
| */ | ||
@@ -469,3 +469,3 @@ results: SearchResult$1[]; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed with the search result in Here™’s search UI. | ||
| * URL or data URI of an icon that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -478,7 +478,7 @@ icon?: string; | ||
| /** | ||
| * Secondary text that will be displayed with the search result in Here™’s search UI. | ||
| * Secondary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
| label?: string; | ||
| /** | ||
| * Primary text that will be displayed with the search result in Here™’s search UI. | ||
| * Primary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -492,3 +492,3 @@ title: string; | ||
| /** | ||
| * URL that Here™ should navigate to. | ||
| * URL that HERE should navigate to. | ||
| */ | ||
@@ -499,3 +499,3 @@ url: string; | ||
| /** | ||
| * Retrieves the Search Agent’s configuration data, as has been configured in the Here™ Admin Console. | ||
| * Retrieves the Search Agent's configuration data, as has been configured in the HERE Admin Console. | ||
| * | ||
@@ -522,3 +522,3 @@ * @returns A promise that resolves with an object containing properties that match the Search Agent’s configuration. | ||
| /** | ||
| * Registers a Search Agent that will provide search results to Here™’s search UI in response to user input and act on the user’s actions regarding those results. | ||
| * Registers a Search Agent that will provide search results to HERE's search UI in response to user input and act on the user's actions regarding those results. | ||
| * | ||
@@ -619,3 +619,3 @@ * @param config The configuration for the Search Agent. | ||
| /** | ||
| * Function that is called when the Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * Function that is called when the Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
@@ -625,7 +625,7 @@ * @param action The action that was triggered. | ||
| * | ||
| * @returns Result that includes the URL that Here™ should navigate to, or `undefined` if no navigation is required. | ||
| * @returns Result that includes the URL that HERE should navigate to, or `undefined` if no navigation is required. | ||
| */ | ||
| type OnSearchActionListener = (action: SearchAction, result: SearchResult) => SearchResultActionResponse | Promise<SearchResultActionResponse>; | ||
| /** | ||
| * Function that is called when the Agent receives a query from Here™’s search UI | ||
| * Function that is called when the Agent receives a query from HERE's search UI | ||
| * | ||
@@ -640,15 +640,15 @@ * @param request Search request data that includes the query. | ||
| * | ||
| * Actions are displayed as buttons alongside search results in Here™’s search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| * Actions are displayed as buttons alongside search results in HERE's search UI. That is, except for the first action, which is hidden as it is triggered automatically when the user selects the search result. | ||
| */ | ||
| type SearchAction = { | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Light mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Light mode. | ||
| */ | ||
| darkIcon?: string; | ||
| /** | ||
| * A fuller description of the action that will be displayed in Here™’s search UI when the user hovers over the action button. | ||
| * A fuller description of the action that will be displayed in HERE's search UI when the user hovers over the action button. | ||
| */ | ||
| description?: string; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed within the action button when Here™ is in Dark mode. | ||
| * URL or data URI of an icon that will be displayed within the action button when HERE is in Dark mode. | ||
| */ | ||
@@ -674,3 +674,3 @@ lightIcon?: string; | ||
| /** | ||
| * The query entered by the user in Here™’s search UI. | ||
| * The query entered by the user in HERE's search UI. | ||
| */ | ||
@@ -688,2 +688,10 @@ query: string; | ||
| /** | ||
| * Filters to apply to the search results. | ||
| */ | ||
| filters: string[]; | ||
| /** | ||
| * The locale of the client. | ||
| */ | ||
| locale: string; | ||
| /** | ||
| * The page number of the search results to return. | ||
@@ -700,2 +708,6 @@ */ | ||
| queryId: string; | ||
| /** | ||
| * The timezone of the client. | ||
| */ | ||
| timeZone: string; | ||
| }; | ||
@@ -707,3 +719,3 @@ /** | ||
| /** | ||
| * The search results to display in Here™’s search UI. | ||
| * The search results to display in HERE's search UI. | ||
| */ | ||
@@ -725,3 +737,3 @@ results: SearchResult[]; | ||
| /** | ||
| * URL or data URI of an icon that will be displayed with the search result in Here™’s search UI. | ||
| * URL or data URI of an icon that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -734,7 +746,7 @@ icon?: string; | ||
| /** | ||
| * Secondary text that will be displayed with the search result in Here™’s search UI. | ||
| * Secondary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
| label?: string; | ||
| /** | ||
| * Primary text that will be displayed with the search result in Here™’s search UI. | ||
| * Primary text that will be displayed with the search result in HERE's search UI. | ||
| */ | ||
@@ -748,3 +760,3 @@ title: string; | ||
| /** | ||
| * URL that Here™ should navigate to. | ||
| * URL that HERE should navigate to. | ||
| */ | ||
@@ -794,9 +806,9 @@ url: string; | ||
| /** | ||
| * This listener is called when the Agent receives an action from Here™’s search UI that has been triggered by the user on one of the Agent’s search results. | ||
| * This listener is called when the Agent receives an action from HERE's search UI that has been triggered by the user on one of the Agent's search results. | ||
| * | ||
| * The listener returns a response back to Here™ that includes a URL to navigate to. | ||
| * The listener returns a response back to HERE that includes a URL to navigate to. | ||
| */ | ||
| onAction: OnSearchActionListener; | ||
| /** | ||
| * This listener is called when the Agent receives a query from Here™’s search UI and returns relevant search results. | ||
| * This listener is called when the Agent receives a query from HERE's search UI and returns relevant search results. | ||
| * | ||
@@ -822,3 +834,3 @@ * Note: When the Agent is not ready this listener will not be called. | ||
| /** | ||
| * Retrieves the Agent’s configuration data, as has been configured in the Here™ Admin Console. | ||
| * Retrieves the Agent's configuration data, as has been configured in the HERE Admin Console. | ||
| * | ||
@@ -825,0 +837,0 @@ * @returns A promise that resolves with an object containing properties that match the Agent’s configuration. |
+1
-2
@@ -1,2 +0,1 @@ | ||
| var tt=Object.create;var En=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var at=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Kn=(t,i)=>{for(var r in i)En(t,r,{get:i[r],enumerable:!0})},ct=(t,i,r,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of rt(i))!st.call(t,d)&&d!==r&&En(t,d,{get:()=>i[d],enumerable:!(a=ot(i,d))||a.enumerable});return t};var vn=(t,i,r)=>(r=t!=null?tt(it(t)):{},ct(i||!t||!t.__esModule?En(r,"default",{value:t,enumerable:!0}):r,t));var on=at((no,Xn)=>{"use strict";(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},i={};t.r(i),t.d(i,{SearchTagBackground:()=>cn,create:()=>Vn,defaultTopic:()=>jn,subscribe:()=>qn});var r={};t.r(r),t.d(r,{B:()=>Oe});var a={};t.r(a),t.d(a,{v:()=>Ye});let d="deregistered or does not exist",h=new Error(`provider ${d}`),m=new Error("provider with name already exists"),w=new Error("bad payload"),C=new Error("subscription rejected"),S=new Error(`channel ${d}`),P;function b(){if(P)return P;throw S}function H(){return P}function In(n){P=n}var O,x,an,cn;(function(n){n[n.Initial=0]="Initial",n[n.Open=1]="Open",n[n.Close=2]="Close"})(O||(O={})),function(n){n.Fetching="fetching",n.Fetched="fetched",n.Complete="complete"}(x||(x={})),function(n){n.UserAction="user-action",n.FocusChange="focus-change",n.Reload="reload"}(an||(an={})),function(n){n.Active="active",n.Default="default"}(cn||(cn={}));let K="0",Pn="1",bn="2",Nn="3",Ln="4",z="5",X="6",ue=()=>{},ln=new Set;function de(n){ln.add(n)}function pe(n){ln.delete(n)}let un=new Set;function fe(n){un.add(n)}function he(n){un.delete(n)}let j=new Map;async function dn(n){j.set(n.id,n);let e=[...ln].map(o=>o());await Promise.all(e)}async function J(n){j.delete(n);let e=[...un].map(o=>o());await Promise.all(e)}function pn(){return[...j.values()]}function Fn(){j.clear()}function L(n){return j.get(n)}function _n(n,e,o){return{...n,action:o||{...n.actions[0],trigger:an.UserAction},dispatcherIdentity:e}}function fn(n,e,o="ascending"){let s=n||[];if(!e?.length)return s;let c=[],l=new Map;e.forEach(p=>{if(p.key)return l.set(p.key,p);c.push(p)});let u=s.map(p=>{let{key:g}=p;if(g&&l.has(g)){let v=l.get(g);return l.delete(g),v}return p});return u.push(...l.values(),...c),u=o==="ascending"?u.sort((p,g)=>(p?.score??1/0)-(g?.score??1/0)):u.sort((p,g)=>(g?.score??1/0)-(p?.score??1/0)),u}function Tn(n){let e={},o=[],s=[],c=null,l=O.Initial;e.getStatus=()=>l,e.getResultBuffer=()=>o,e.setResultBuffer=p=>{o=p,o?.length&&e.onChange()},e.getRevokedBuffer=()=>s,e.setRevokedBuffer=p=>{s=p,s?.length&&e.onChange()},e.setUpdatedContext=p=>{c=p,e.onChange()},e.getUpdatedContext=()=>c,e.onChange=ue;let u={};return e.res=u,u.close=()=>{l!==O.Close&&(l=O.Close,e.onChange())},u.open=()=>{l!==O.Open&&(l=O.Open,e.onChange())},u.respond=p=>{let g=fn(e.getResultBuffer(),p,n);e.setResultBuffer(g)},u.revoke=(...p)=>{let g=new Set(p),v=e.getResultBuffer().filter(({key:f})=>{let R=g.has(f);return R&&g.delete(f),!R});e.setResultBuffer(v),g.size&&(e.getRevokedBuffer().forEach(f=>g.add(f)),e.setRevokedBuffer([...g]))},u.updateContext=p=>{e.setUpdatedContext(p)},e}function xn(n,e){let o=new Set,s=!1;return{close:()=>{s=!0;for(let c of o)c()},req:{id:n,...e,context:e?.context||{},onClose:c=>{o.add(c),s&&c()},removeListener:c=>{o.delete(c)}}}}function Q(){return{name:fin.me.name,uuid:fin.me.uuid}}let kn=50,ge=1e3,we=new Map;function hn(){return we}let ye=100;function me(){return async n=>{if(!n||!n.id||!n.providerId){let f=w;return console.error(f),{error:f.message}}let{id:e,providerId:o}=n,s=L(o);if(!s){let f=h;return console.error(f),{error:f.message}}let c=hn(),l=c.get(n.id);l||(l=xn(e,n),c.set(n.id,l));let u=Tn(),p=()=>{let f=u.getResultBuffer();u.setResultBuffer([]);let R=u.getRevokedBuffer();u.setRevokedBuffer([]);let F=u.getUpdatedContext();u.setUpdatedContext(null);let $=u.getStatus();(async function(M){(await b()).dispatch(K,M)})({id:e,providerId:o,results:f,revoked:R,status:$,context:F})},g=!0,v=!1;u.onChange=()=>{if(g)return g=!1,void p();v||(v=!0,setTimeout(()=>{v=!1,p()},ye))};try{let{results:f,context:R}=await s.onUserInput(l.req,u.res),F=u.getStatus();return{id:e,providerId:o,status:F,results:f,context:R}}catch(f){return console.error(`OpenFin/Workspace/Home. Uncaught exception in search provider ${o} for search ${e}`,"This is likely a bug in the implementation of the search provider.",f),{id:e,providerId:o,error:f?.message}}}}async function $n(n,e){let o=e||await b(),s=Q(),c={...n,identity:s,onResultDispatch:void 0},l=await o.dispatch(bn,c);return await dn({identity:s,...n}),l}async function Ce(n){return await(await b()).dispatch(Nn,n),J(n)}async function Se(n,e,o,s){let c=_n(e,s??Q(),o),l=L(n);if(l){let{onResultDispatch:p}=l;return p?p(c):void 0}let u={providerId:n,result:c};return(await b()).dispatch(z,u)}async function Re(n){let e={...n,context:n?.context||{}},o={},s=async function*(l,{setState:u}){let p=await b();for(;;){let g=await p.dispatch(Pn,l),v=g.error;if(v)throw new Error(v);let f=g;if(l.id=f.id,u(f.state),f.done)return f.value;yield f.value}}(e,{setState:l=>{o.state=l}}),c=await s.next();return o.id=e.id||"",o.close=()=>{(async function(l){(await b()).dispatch(X,{id:l})})(o.id)},o.next=()=>{if(c){let l=c;return c=void 0,l}return s.next()},o}async function Ee(){return(await b()).dispatch(Ln,null)}async function ve(){let n=await b();P=void 0,Fn(),await n.disconnect()}let Ae=async n=>{let e=await Un(n);for(let o of pn())await $n(o,e);return e};async function Un(n){let e=await async function(o){for(let s=0;s<kn;s++)try{return await fin.InterApplicationBus.Channel.connect(o,{wait:!1})}catch(c){if(s===kn-1)throw c;await new Promise(l=>setTimeout(l,ge))}}(n);return e.register(K,me()),e.register(X,o=>{let s=hn(),c=s.get(o.id);c&&(c.close(),s.delete(o.id))}),e.register(z,async(o,s)=>{if(!o||!o.providerId||!o.result)return void console.error(w);let c=L(o.providerId);if(!c)return void console.error(h);let{onResultDispatch:l}=c;return l?(o.result.dispatcherIdentity=o.result.dispatcherIdentity??s,l(o.result)):void 0}),e.onDisconnection(function(o){return async()=>{if(!H())return;let s=hn();for(let{req:c,close:l}of s.values())l(),s.delete(c.id);In(Ae(o))}}(n)),e}async function Oe(n){let e=H();e||(e=Un(n),In(e));let o=await e;return{getAllProviders:Ee.bind(null),register:$n.bind(null),search:Re.bind(null),deregister:Ce.bind(null),dispatch:Se.bind(null),disconnect:ve.bind(null),channel:o}}let G;function Y(){if(G)return G;throw S}function Ie(){return G}function Pe(n){G=n}function be(){G=void 0}let gn=new Set;function Ne(n){gn.add(n)}function Le(n){gn.delete(n)}var k;(function(n){n.Local="local",n.Dev="dev",n.Staging="staging",n.Prod="prod"})(k||(k={}));let wn=typeof window<"u"&&typeof fin<"u",Fe=(typeof process>"u"||process.env,typeof window<"u"),_e=Fe?window.origin:k.Local,Z=(wn&&fin.me.uuid,wn&&fin.me.name,wn&&fin.me.entityType,k.Local,k.Dev,k.Staging,k.Prod,n=>n.startsWith("http://")||n.startsWith("https://")?n:_e+n),Dn=(Z("http://localhost:4002"),Z("http://localhost:4002"),typeof WORKSPACE_DOCS_PLATFORM_URL<"u"&&Z(WORKSPACE_DOCS_PLATFORM_URL),typeof WORKSPACE_DOCS_CLIENT_URL<"u"&&Z(WORKSPACE_DOCS_CLIENT_URL),"20.3.6");typeof WORKSPACE_BUILD_SHA<"u"&&WORKSPACE_BUILD_SHA;async function Mn(){return[...pn()].map(n=>({...n,onUserInput:void 0,onResultDispatch:void 0}))}async function Te(n){if(L(n.id))throw new Error("provider with name already exists");let e=Q();return await dn({identity:e,...n}),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}async function xe(n){await J(n)}async function ke(n,e,o,s){let c=L(n);if(!c)throw h;let{onResultDispatch:l}=c;if(l)return l(_n(e,s??Q(),o))}async function*$e(n,e){let o=function(R,F){let $=[],M=[],B=[],I=[];for(let E of R){let _=Tn(E.scoreOrder),T={results:[],provider:{id:E.id,identity:E.identity,title:E.title,scoreOrder:E.scoreOrder,icon:E.icon,dispatchFocusEvents:E.dispatchFocusEvents}};$.push(T),M.push(_);let W=(async()=>{try{let{results:V,context:en}=await E.onUserInput(F,_.res);T.results=fn(T.results||[],V,E.scoreOrder),T.context={...T.context,...en}}catch(V){T.error=V}})();W.finally(()=>{W.done=!0}),I.push(W),B.push(B.length)}return{providerResponses:$,listenerResponses:M,openListenerResponses:B,initialResponsePromises:I}}(n.targets?n.targets.map(R=>L(R)).filter(R=>!!R):[...pn().filter(R=>!R.hidden)],n),{providerResponses:s,listenerResponses:c}=o,{openListenerResponses:l,initialResponsePromises:u}=o,p=x.Fetching,g=R=>{p=R,e.setState(p)},v,f=!1;n.onClose(()=>{f=!0,v&&v()});do{let R=!1;if(u.length){let I=[];for(let E of u)E.done?R=!0:I.push(E);u=I,u.length||(g(x.Fetched),R=!0)}let F,$=!1,M=()=>{$=!0,F&&F()},B=[];for(let I of l){let E=c[I],_=s[I],T=E.getStatus();(T===O.Open||p===x.Fetching&&T===O.Initial)&&(B.push(I),E.onChange=M);let W=E.getResultBuffer();W.length&&(E.setResultBuffer([]),_.results=fn(_.results||[],W),R=!0);let V=E.getRevokedBuffer();if(V.length){E.setRevokedBuffer([]);let nt=new Set(V);_.results=(_.results||[]).filter(({key:et})=>!nt.has(et)),R=!0}let en=E.getUpdatedContext();en&&(E.setUpdatedContext(null),_.context={..._.context,...en},R=!0)}if(l=B,R&&(yield s),f)break;$||(l.length||u.length)&&await Promise.race([...u,new Promise(I=>{F=I}),new Promise(I=>{v=I})])}while(l.length||u.length);return g(x.Complete),s}let yn=0;async function Bn(n){yn+=1;let e=xn(yn.toString(),n),o=$e(e.req,{setState:s=>{o.state=s}});return o.id=yn.toString(),o.close=e.close,o.state=x.Fetching,o}let nn=new Map,Ue=1e4;function De(){return async n=>{if(!n)return console.error(w),{error:w.message};let e;if(n.id)e=n.id;else{let c=await Bn(n);e=c.id,n.id=c.id,nn.set(e,{generator:c})}let o=nn.get(e);clearTimeout(o.timeout);let s=await o.generator.next();return o.timeout=function(c){return window.setTimeout(()=>{nn.delete(c)},Ue)}(e),{...s,id:n.id,state:o.generator.state}}}function Me(n,e){return Y().dispatch(n,X,{id:e})}function Be(){return n=>function(e){let o=nn.get(e);o&&o.generator.close()}(n.id)}async function We(n,{id:e,query:o,context:s,targets:c=[]}){let l=Y(),u={id:e,query:o,context:s,targets:c,providerId:n.id},p=await l.dispatch(n.identity,K,u),g=p.error;if(g)throw new Error(g);return p}let mn=new Map;function Ve(n,e){return`${n.name}:${n.uuid}:${e}`}let Cn=new Map;function Wn(n,e){return`${n}:${e}`}function qe(n){let e=Ve.bind(null,n.identity),o=Me.bind(null,n.identity),s=We.bind(null,n);return async(c,l)=>{let u=e(c.id);if(!mn.has(u)){let f=()=>{o(c.id),mn.delete(u)};mn.set(u,f),c.onClose(f)}let p=Wn(n.id,c.id),g=()=>{Cn.delete(p),l.close()};c.onClose(g),Cn.set(p,f=>{f.results?.length&&l.respond(f.results),f.revoked?.length&&l.revoke(...f.revoked),f.context&&l.updateContext(f.context),f.status===O.Open&&l.open(),f.status===O.Close&&g()});let v=await s(c);return v.status===O.Open&&l.open(),v.status!==O.Close&&v.status!==O.Initial||g(),v}}function je(n){return async e=>{let o=Y(),s={providerId:n.id,result:e};return o.dispatch(n.identity,z,s)}}let D=new Map;function Sn(n){return`${n.name}-${n.uuid}`}function Ge(){return async(n,e)=>{if(!n||!n.id)return console.error(new Error(JSON.stringify(n))),void console.error(w);if(L(n.id))throw m;return n.identity=e,await async function(o){let s=Sn(o.identity);D.has(s)||D.set(s,[]),D.get(s).push(o.id),await dn({...o,onUserInput:qe(o),onResultDispatch:je(o)})}(n),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}}function He(){return(n,e)=>{n?function(o,s){let c=L(o);if(!c)return;if(c.identity.uuid!==s.uuid||c.identity.name!==s.name)throw h;let l=Sn(c.identity),u=D.get(l);if(u){let p=u.findIndex(g=>g===o);p!==-1&&(u.splice(p,1),J(o))}}(n,e):console.error(w)}}let Rn=new Set;function Ke(n){Rn.add(n)}function ze(n){Rn.delete(n)}function Xe(){return async n=>{(function(e){let o=Sn(e),s=D.get(o);if(s){for(let c of s)J(c);D.delete(o)}})(n),Rn.forEach(e=>e(n))}}async function Je(n){let e=await(o=n,fin.InterApplicationBus.Channel.create(o));var o;return e.onConnection(async s=>{for(let c of gn)if(!await c(s))throw C}),e.onDisconnection(Xe()),e.register(X,Be()),e.register(K,s=>{let c=Wn(s.providerId,s.id),l=Cn.get(c);l&&l(s)}),e.register(bn,Ge()),e.register(Nn,He()),e.register(Ln,async()=>Mn()),e.register(Pn,De()),e.register(z,async(s,c)=>{if(!s||!s.providerId||!s.result)return void console.error(w);let l=L(s.providerId);if(!l)throw h;let{onResultDispatch:u}=l;return u?(s.result.dispatcherIdentity=s.result.dispatcherIdentity??c,u(s.result)):void 0}),e}async function Qe(){let n=Y();be(),await n.destroy(),Fn()}async function Ye(n){let e=Ie();e||(e=await Je(n),Pe(e));let o=Le.bind(null),s=ze.bind(null),c=pe.bind(null),l=he.bind(null);return{getAllProviders:Mn.bind(null),search:Bn.bind(null),register:Te.bind(null),deregister:xe.bind(null),onSubscription:Ne.bind(null),onDisconnect:Ke.bind(null),onRegister:de.bind(null),onDeregister:fe.bind(null),dispatch:ke.bind(null),disconnect:Qe.bind(null),removeListener:u=>{o(u),s(u),c(u),l(u)},channel:e}}let{v:Vn}=a,{B:qn}=r,jn="all",Ze={create:Vn,subscribe:qn,defaultTopic:jn},Gn=()=>{window.search=Ze},Hn=n=>{let e=()=>{Gn(),window.removeEventListener(n,e)};return e};if(typeof window<"u"){Gn();let n="load",e=Hn(n);window.addEventListener(n,e);let o="DOMContentLoaded",s=Hn(o);window.addEventListener(o,s)}Xn.exports=i})()});var y="@openfin/cloud-api";async function N(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch{return!1}}function zn(t){if(t.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(t.name)?t.name.split("/")[0]||"":t.name}var q="@openfin/cloud-api";function lt(){return`${window.fin.me.uuid}-cloud-api-notifications`}var An=null;async function qt(){return An||(An=ut()),An}async function ut(){if(!window.fin)throw new Error(`\`${q}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${q}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);zn(window.fin.me);let t=await dt();console.log(t),t.register("openfin-cloud-event",r=>{for(let a of i.get(r.type)??[])typeof r.payload.timestamp=="string"&&(r.payload.timestamp=new Date(r.payload.timestamp)),a(r.payload)});let i=new Map;return{addEventListener:(r,a)=>{let d=i.get(r)||new Set;d.add(a),i.set(r,d)},removeEventListener:(r,a)=>{let d=i.get(r);if(!d){console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,r);return}d.delete(a)===!1&&console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,r)},update:async r=>(await t.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:r}})).payload.response,clear:async r=>(await t.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:r}})).payload.response,createNotification:async r=>(r.id&&console.warn(`\`${q}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await t.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...r,id:void 0}}})).payload.response)}}var tn=null;async function dt(){return tn||(tn=pt()),tn}async function pt(){let t=await window.fin.InterApplicationBus.Channel.connect(lt());return t.onDisconnection(i=>{console.warn(`\`${q}\`: Channel Disconnected from`,i,"Reconnecting..."),tn=null}),t}var On;function ft(){return`${window.fin.me.uuid}-client-api`}async function U(){return On||(On=window.fin.InterApplicationBus.Channel.connect(ft())),On}async function Ht(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-settings")}async function Kt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-settings")}async function zt(t){if(!window.fin)throw new Error(`\`${y}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("set-user-settings",t)}async function Xt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-permissions")}async function Jt(t,i){if(!window.fin)throw new Error(`\`${y}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let r=await U();try{await r.dispatch("launch-content",{id:t,options:i})}catch(a){switch(a instanceof Error?a.message:String(a)){case"UnableToLookup":throw new Error(`${y}: \`launchContent\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchContent\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchContent\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchContent\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Qt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-supertab",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchSupertab\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchSupertab\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchSupertab\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchSupertab\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Yt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-workspace",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchWorkspace\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchWorkspace\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchWorkspace\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchWorkspace\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}var ne={};Kn(ne,{getAgentConfiguration:()=>Yn,register:()=>Zn});var Qn=vn(on(),1),ht="[here-agent]",gt="log-message-",wt="open-url",yt="provider-status-",mt="registered-",Ct="1.0";function St(t,i){let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}}function Jn(t){return{...t,data:t.data.customData}}async function Yn(){let{customData:t}=await window.fin.me.getOptions();return t}function Rt(){return`${window.fin.me.identity.uuid}-cloud-api-search`}async function Et(t,i,r,a=!0){await i("info",`Setting status as ${a?"ready":"not ready"}`);try{await t.dispatch(`${yt}${r}`,{isReady:a})}catch(d){let h=["Error setting provider status",d];console.error(...h),i("error",...h)}}async function vt(t,i,r,...a){try{console.log(ht,...a),await t.dispatch(`${gt}${i}`,{level:r,message:a})}catch(d){console.error("Error logging message",d)}}async function At(t,i,r,a,d){let{action:h,dispatcherIdentity:m,...w}=d;await r("info","Handling action",{action:h,dispatcherIdentity:m,result:w});let C;try{let P=Jn(d).actions?.find(({name:H})=>H===h.name);if(!P)throw new Error("Original action not found in search result");C=(await a(P,Jn(d)))?.url}catch(S){throw await r("error","Error handling dispatch",S),S}if(!C){await r("warn","OnActionListener did not return a URL");return}await It(t,r,i,C,m)}async function Ot(t,i,r,a){await i("info","Getting search results",{request:a});try{let d=new AbortController;a.onClose(()=>d.abort());let{context:h,query:m}=a,{results:w}=await r({context:h,query:m,signal:d.signal}),C=w.map(S=>St(S,t));return await i("info","Returning results",C),{results:C}}catch(d){let h=["Error handling search",d];throw console.error(...h),i("error",...h),d}}async function It(t,i,r,a,d){await i("info","Opening URL",{url:a,targetIdentity:d});try{await t.dispatch(wt,{url:a,targetIdentity:d,providerId:r})}catch(h){let m=["Error opening URL",h];console.error(...m),i("error",...m)}}async function Zn(t){let r=(await window.fin.me.getOptions()).customData,{id:a,title:d}=r,{onAction:h,onSearch:m}=t,w=await Qn.subscribe(Rt()),C=w.channel,S=vt.bind(null,C,a);return await w.register({icon:"",id:a,onResultDispatch:At.bind(null,C,a,S,h),onUserInput:Ot.bind(null,a,S,m),title:d}),await w.channel.dispatch(`${mt}${a}`,{version:Ct}),S("info","Registered search topic",{id:a,title:d}),{isReady:Et.bind(null,C,S,a)}}var le={};Kn(le,{getConfiguration:()=>ae,register:()=>ce});var se=vn(on(),1);var rn=class extends Error{constructor(){super("Interop feature is not supported by the agent")}};async function sn(t,i){try{let r=await window.fin.me.interop.getFDC3(t);i==="none"?(A("Leaving current channel"),await r.leaveCurrentChannel()):(A(`Joining interop channel: ${i}`),await("joinUserChannel"in r?r.joinUserChannel(i):r.joinChannel(i)))}catch(r){A(`Failed to join interop channel: ${i}`,r)}}var ro=vn(on(),1);var Nt=(t,i)=>{let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}},ee=t=>({...t,data:t.data.customData}),te=()=>`${window.fin.me.identity.uuid}-cloud-api-search`,Lt=async({channel:t,url:i,targetIdentity:r})=>{A("Opening URL",{url:i,targetIdentity:r});try{await t.dispatch(ie,{url:i,targetIdentity:r})}catch(a){console.error("Failed opening URL",a)}},oe=async(t,i,r,a)=>{let{action:d,dispatcherIdentity:h,...m}=a;A("Handling action...",{action:d,dispatcherIdentity:h,result:m});let w;try{let S=ee(a).actions?.find(({name:b})=>b===d.name);if(!S)throw new Error("Original action not found in search result");w=(await r(S,ee(a)))?.url}catch(C){throw A("Error handling dispatch",C),C}if(!w){A("OnActionListener did not return a URL");return}await Lt({channel:t,url:w,targetIdentity:h})},re=async(t,i,r)=>{A("Getting search results...",{request:r});try{let a=new AbortController;r.onClose(()=>a.abort());let{context:d,query:h}=r,{results:m}=await i({context:d,query:h,signal:a.signal}),w=m.map(C=>Nt(C,t));return A("Returning results",w),{results:w}}catch(a){throw new Error("Error handling search request",{cause:a})}};var _t="[here-agent]",Tt="1.0",xt="-enterprise-component-bridge",ie="open-url",kt="set-agent-registered",$t="set-agent-status",ae=async()=>{let{customData:t}=await window.fin.me.getOptions(),i=t,{configurationFields:r}=i;return Object.fromEntries(r?.map(a=>[a.name,a.value])??[])};async function Ut(t,i){if(!t.interop)throw new rn;let{fdc3Version:r}=t.interop;await sn(r,i)}function A(...t){console.log(_t,...t)}var Dt=async(t,i,r=!0)=>{A(`Setting status to ${r?"ready":"not ready"}`);try{await t.dispatch($t,{id:i,isReady:r})}catch(a){throw new Error("Failed to set agent status",{cause:a})}};async function ce(t){let{customData:i}=await window.fin.me.getOptions(),r=i;A("Registering agent...",r);try{let a=`${window.fin.me.identity.uuid}${xt}`,d;try{d=await window.fin.InterApplicationBus.Channel.connect(a,{wait:!1})}catch(S){throw new Error("Failed to connect to enterprise component bridge channel",{cause:S})}let{id:h,features:m,title:w}=r,C={features:m,joinInteropChannel:Ut.bind(null,m),setIsReady:Dt.bind(null,d,h)};if(m.interop){A("Enabling interop features");let{defaultChannel:S,fdc3Version:P}=m.interop;S&&S!=="none"&&await sn(P,S),d.register("on-desktop-app-signals-changed",Mt.bind(null,r))}return m.search&&t.search&&(A("Enabling search features"),await(await se.subscribe(te())).register({icon:"",id:h,onResultDispatch:oe.bind(null,d,h,t.search.onAction),onUserInput:re.bind(null,h,t.search.onSearch),title:w})),await d.dispatch(kt,{id:h,apiVersion:Tt}),A("Registered successfully"),C}catch(a){throw new Error("Failed to register agent",{cause:a})}}function Mt(t,i){A("Desktop app signals changed",i);let r=i,{type:a,id:d,features:h}=t,{fdc3Version:m}=h.interop,w=r.find(C=>a==="agent"?C.appKey===t.name:a==="custom"?C.appKey===d:!1);w&&sn(m,w.selectedColorChannel)}export{le as Agent,ne as Search,Ht as getAppSettings,Xt as getAppUserPermissions,Kt as getAppUserSettings,qt as getNotificationsClient,Jt as launchContent,Qt as launchSupertab,Yt as launchWorkspace,zt as setAppUserSettings}; | ||
| //# sourceMappingURL=index.js.map | ||
| var tt=Object.create;var En=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var at=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports),Kn=(t,i)=>{for(var r in i)En(t,r,{get:i[r],enumerable:!0})},ct=(t,i,r,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let d of rt(i))!st.call(t,d)&&d!==r&&En(t,d,{get:()=>i[d],enumerable:!(a=ot(i,d))||a.enumerable});return t};var vn=(t,i,r)=>(r=t!=null?tt(it(t)):{},ct(i||!t||!t.__esModule?En(r,"default",{value:t,enumerable:!0}):r,t));var on=at((no,Xn)=>{"use strict";(()=>{"use strict";var t={d:(n,e)=>{for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},o:(n,e)=>Object.prototype.hasOwnProperty.call(n,e),r:n=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})}},i={};t.r(i),t.d(i,{SearchTagBackground:()=>cn,create:()=>Vn,defaultTopic:()=>jn,subscribe:()=>qn});var r={};t.r(r),t.d(r,{B:()=>Oe});var a={};t.r(a),t.d(a,{v:()=>Ye});let d="deregistered or does not exist",h=new Error(`provider ${d}`),m=new Error("provider with name already exists"),w=new Error("bad payload"),C=new Error("subscription rejected"),S=new Error(`channel ${d}`),P;function b(){if(P)return P;throw S}function H(){return P}function In(n){P=n}var O,x,an,cn;(function(n){n[n.Initial=0]="Initial",n[n.Open=1]="Open",n[n.Close=2]="Close"})(O||(O={})),(function(n){n.Fetching="fetching",n.Fetched="fetched",n.Complete="complete"})(x||(x={})),(function(n){n.UserAction="user-action",n.FocusChange="focus-change",n.Reload="reload"})(an||(an={})),(function(n){n.Active="active",n.Default="default"})(cn||(cn={}));let K="0",Pn="1",bn="2",Nn="3",Ln="4",z="5",X="6",ue=()=>{},ln=new Set;function de(n){ln.add(n)}function pe(n){ln.delete(n)}let un=new Set;function fe(n){un.add(n)}function he(n){un.delete(n)}let j=new Map;async function dn(n){j.set(n.id,n);let e=[...ln].map((o=>o()));await Promise.all(e)}async function J(n){j.delete(n);let e=[...un].map((o=>o()));await Promise.all(e)}function pn(){return[...j.values()]}function Fn(){j.clear()}function L(n){return j.get(n)}function _n(n,e,o){return{...n,action:o||{...n.actions[0],trigger:an.UserAction},dispatcherIdentity:e}}function fn(n,e,o="ascending"){let s=n||[];if(!e?.length)return s;let c=[],l=new Map;e.forEach((p=>{if(p.key)return l.set(p.key,p);c.push(p)}));let u=s.map((p=>{let{key:g}=p;if(g&&l.has(g)){let v=l.get(g);return l.delete(g),v}return p}));return u.push(...l.values(),...c),u=o==="ascending"?u.sort(((p,g)=>(p?.score??1/0)-(g?.score??1/0))):u.sort(((p,g)=>(g?.score??1/0)-(p?.score??1/0))),u}function Tn(n){let e={},o=[],s=[],c=null,l=O.Initial;e.getStatus=()=>l,e.getResultBuffer=()=>o,e.setResultBuffer=p=>{o=p,o?.length&&e.onChange()},e.getRevokedBuffer=()=>s,e.setRevokedBuffer=p=>{s=p,s?.length&&e.onChange()},e.setUpdatedContext=p=>{c=p,e.onChange()},e.getUpdatedContext=()=>c,e.onChange=ue;let u={};return e.res=u,u.close=()=>{l!==O.Close&&(l=O.Close,e.onChange())},u.open=()=>{l!==O.Open&&(l=O.Open,e.onChange())},u.respond=p=>{let g=fn(e.getResultBuffer(),p,n);e.setResultBuffer(g)},u.revoke=(...p)=>{let g=new Set(p),v=e.getResultBuffer().filter((({key:f})=>{let R=g.has(f);return R&&g.delete(f),!R}));e.setResultBuffer(v),g.size&&(e.getRevokedBuffer().forEach((f=>g.add(f))),e.setRevokedBuffer([...g]))},u.updateContext=p=>{e.setUpdatedContext(p)},e}function xn(n,e){let o=new Set,s=!1;return{close:()=>{s=!0;for(let c of o)c()},req:{id:n,...e,context:e?.context||{},onClose:c=>{o.add(c),s&&c()},removeListener:c=>{o.delete(c)}}}}function Q(){return{name:fin.me.name,uuid:fin.me.uuid}}let kn=50,ge=1e3,we=new Map;function hn(){return we}let ye=100;function me(){return async n=>{if(!n||!n.id||!n.providerId){let f=w;return console.error(f),{error:f.message}}let{id:e,providerId:o}=n,s=L(o);if(!s){let f=h;return console.error(f),{error:f.message}}let c=hn(),l=c.get(n.id);l||(l=xn(e,n),c.set(n.id,l));let u=Tn(),p=()=>{let f=u.getResultBuffer();u.setResultBuffer([]);let R=u.getRevokedBuffer();u.setRevokedBuffer([]);let F=u.getUpdatedContext();u.setUpdatedContext(null);let $=u.getStatus();(async function(M){(await b()).dispatch(K,M)})({id:e,providerId:o,results:f,revoked:R,status:$,context:F})},g=!0,v=!1;u.onChange=()=>{if(g)return g=!1,void p();v||(v=!0,setTimeout((()=>{v=!1,p()}),ye))};try{let{results:f,context:R}=await s.onUserInput(l.req,u.res),F=u.getStatus();return{id:e,providerId:o,status:F,results:f,context:R}}catch(f){return console.error(`OpenFin/Workspace/Home. Uncaught exception in search provider ${o} for search ${e}`,"This is likely a bug in the implementation of the search provider.",f),{id:e,providerId:o,error:f?.message}}}}async function $n(n,e){let o=e||await b(),s=Q(),c={...n,identity:s,onResultDispatch:void 0},l=await o.dispatch(bn,c);return await dn({identity:s,...n}),l}async function Ce(n){return await(await b()).dispatch(Nn,n),J(n)}async function Se(n,e,o,s){let c=_n(e,s??Q(),o),l=L(n);if(l){let{onResultDispatch:p}=l;return p?p(c):void 0}let u={providerId:n,result:c};return(await b()).dispatch(z,u)}async function Re(n){let e={...n,context:n?.context||{}},o={},s=(async function*(l,{setState:u}){let p=await b();for(;;){let g=await p.dispatch(Pn,l),v=g.error;if(v)throw new Error(v);let f=g;if(l.id=f.id,u(f.state),f.done)return f.value;yield f.value}})(e,{setState:l=>{o.state=l}}),c=await s.next();return o.id=e.id||"",o.close=()=>{(async function(l){(await b()).dispatch(X,{id:l})})(o.id)},o.next=()=>{if(c){let l=c;return c=void 0,l}return s.next()},o}async function Ee(){return(await b()).dispatch(Ln,null)}async function ve(){let n=await b();P=void 0,Fn(),await n.disconnect()}let Ae=async n=>{let e=await Un(n);for(let o of pn())await $n(o,e);return e};async function Un(n){let e=await(async function(o){for(let s=0;s<kn;s++)try{return await fin.InterApplicationBus.Channel.connect(o,{wait:!1})}catch(c){if(s===kn-1)throw c;await new Promise((l=>setTimeout(l,ge)))}})(n);return e.register(K,me()),e.register(X,(o=>{let s=hn(),c=s.get(o.id);c&&(c.close(),s.delete(o.id))})),e.register(z,(async(o,s)=>{if(!o||!o.providerId||!o.result)return void console.error(w);let c=L(o.providerId);if(!c)return void console.error(h);let{onResultDispatch:l}=c;return l?(o.result.dispatcherIdentity=o.result.dispatcherIdentity??s,l(o.result)):void 0})),e.onDisconnection((function(o){return async()=>{if(!H())return;let s=hn();for(let{req:c,close:l}of s.values())l(),s.delete(c.id);In(Ae(o))}})(n)),e}async function Oe(n){let e=H();e||(e=Un(n),In(e));let o=await e;return{getAllProviders:Ee.bind(null),register:$n.bind(null),search:Re.bind(null),deregister:Ce.bind(null),dispatch:Se.bind(null),disconnect:ve.bind(null),channel:o}}let G;function Y(){if(G)return G;throw S}function Ie(){return G}function Pe(n){G=n}function be(){G=void 0}let gn=new Set;function Ne(n){gn.add(n)}function Le(n){gn.delete(n)}var k;(function(n){n.Local="local",n.Dev="dev",n.Staging="staging",n.Prod="prod"})(k||(k={}));let wn=typeof window<"u"&&typeof fin<"u",Fe=(typeof process>"u"||process.env,typeof window<"u"),_e=Fe?window.origin:k.Local,Z=(wn&&fin.me.uuid,wn&&fin.me.name,wn&&fin.me.entityType,k.Local,k.Dev,k.Staging,k.Prod,n=>n.startsWith("http://")||n.startsWith("https://")?n:_e+n),Dn=(Z("http://localhost:4002"),Z("http://localhost:4002"),typeof WORKSPACE_DOCS_PLATFORM_URL<"u"&&Z(WORKSPACE_DOCS_PLATFORM_URL),typeof WORKSPACE_DOCS_CLIENT_URL<"u"&&Z(WORKSPACE_DOCS_CLIENT_URL),"20.3.6");typeof WORKSPACE_BUILD_SHA<"u"&&WORKSPACE_BUILD_SHA;async function Mn(){return[...pn()].map((n=>({...n,onUserInput:void 0,onResultDispatch:void 0})))}async function Te(n){if(L(n.id))throw new Error("provider with name already exists");let e=Q();return await dn({identity:e,...n}),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}async function xe(n){await J(n)}async function ke(n,e,o,s){let c=L(n);if(!c)throw h;let{onResultDispatch:l}=c;if(l)return l(_n(e,s??Q(),o))}async function*$e(n,e){let o=(function(R,F){let $=[],M=[],B=[],I=[];for(let E of R){let _=Tn(E.scoreOrder),T={results:[],provider:{id:E.id,identity:E.identity,title:E.title,scoreOrder:E.scoreOrder,icon:E.icon,dispatchFocusEvents:E.dispatchFocusEvents}};$.push(T),M.push(_);let W=(async()=>{try{let{results:V,context:en}=await E.onUserInput(F,_.res);T.results=fn(T.results||[],V,E.scoreOrder),T.context={...T.context,...en}}catch(V){T.error=V}})();W.finally((()=>{W.done=!0})),I.push(W),B.push(B.length)}return{providerResponses:$,listenerResponses:M,openListenerResponses:B,initialResponsePromises:I}})(n.targets?n.targets.map((R=>L(R))).filter((R=>!!R)):[...pn().filter((R=>!R.hidden))],n),{providerResponses:s,listenerResponses:c}=o,{openListenerResponses:l,initialResponsePromises:u}=o,p=x.Fetching,g=R=>{p=R,e.setState(p)},v,f=!1;n.onClose((()=>{f=!0,v&&v()}));do{let R=!1;if(u.length){let I=[];for(let E of u)E.done?R=!0:I.push(E);u=I,u.length||(g(x.Fetched),R=!0)}let F,$=!1,M=()=>{$=!0,F&&F()},B=[];for(let I of l){let E=c[I],_=s[I],T=E.getStatus();(T===O.Open||p===x.Fetching&&T===O.Initial)&&(B.push(I),E.onChange=M);let W=E.getResultBuffer();W.length&&(E.setResultBuffer([]),_.results=fn(_.results||[],W),R=!0);let V=E.getRevokedBuffer();if(V.length){E.setRevokedBuffer([]);let nt=new Set(V);_.results=(_.results||[]).filter((({key:et})=>!nt.has(et))),R=!0}let en=E.getUpdatedContext();en&&(E.setUpdatedContext(null),_.context={..._.context,...en},R=!0)}if(l=B,R&&(yield s),f)break;$||(l.length||u.length)&&await Promise.race([...u,new Promise((I=>{F=I})),new Promise((I=>{v=I}))])}while(l.length||u.length);return g(x.Complete),s}let yn=0;async function Bn(n){yn+=1;let e=xn(yn.toString(),n),o=$e(e.req,{setState:s=>{o.state=s}});return o.id=yn.toString(),o.close=e.close,o.state=x.Fetching,o}let nn=new Map,Ue=1e4;function De(){return async n=>{if(!n)return console.error(w),{error:w.message};let e;if(n.id)e=n.id;else{let c=await Bn(n);e=c.id,n.id=c.id,nn.set(e,{generator:c})}let o=nn.get(e);clearTimeout(o.timeout);let s=await o.generator.next();return o.timeout=(function(c){return window.setTimeout((()=>{nn.delete(c)}),Ue)})(e),{...s,id:n.id,state:o.generator.state}}}function Me(n,e){return Y().dispatch(n,X,{id:e})}function Be(){return n=>(function(e){let o=nn.get(e);o&&o.generator.close()})(n.id)}async function We(n,{id:e,query:o,context:s,targets:c=[]}){let l=Y(),u={id:e,query:o,context:s,targets:c,providerId:n.id},p=await l.dispatch(n.identity,K,u),g=p.error;if(g)throw new Error(g);return p}let mn=new Map;function Ve(n,e){return`${n.name}:${n.uuid}:${e}`}let Cn=new Map;function Wn(n,e){return`${n}:${e}`}function qe(n){let e=Ve.bind(null,n.identity),o=Me.bind(null,n.identity),s=We.bind(null,n);return async(c,l)=>{let u=e(c.id);if(!mn.has(u)){let f=()=>{o(c.id),mn.delete(u)};mn.set(u,f),c.onClose(f)}let p=Wn(n.id,c.id),g=()=>{Cn.delete(p),l.close()};c.onClose(g),Cn.set(p,(f=>{f.results?.length&&l.respond(f.results),f.revoked?.length&&l.revoke(...f.revoked),f.context&&l.updateContext(f.context),f.status===O.Open&&l.open(),f.status===O.Close&&g()}));let v=await s(c);return v.status===O.Open&&l.open(),v.status!==O.Close&&v.status!==O.Initial||g(),v}}function je(n){return async e=>{let o=Y(),s={providerId:n.id,result:e};return o.dispatch(n.identity,z,s)}}let D=new Map;function Sn(n){return`${n.name}-${n.uuid}`}function Ge(){return async(n,e)=>{if(!n||!n.id)return console.error(new Error(JSON.stringify(n))),void console.error(w);if(L(n.id))throw m;return n.identity=e,await(async function(o){let s=Sn(o.identity);D.has(s)||D.set(s,[]),D.get(s).push(o.id),await dn({...o,onUserInput:qe(o),onResultDispatch:je(o)})})(n),{workspaceVersion:Dn||"",clientAPIVersion:n.clientAPIVersion||""}}}function He(){return(n,e)=>{n?(function(o,s){let c=L(o);if(!c)return;if(c.identity.uuid!==s.uuid||c.identity.name!==s.name)throw h;let l=Sn(c.identity),u=D.get(l);if(u){let p=u.findIndex((g=>g===o));p!==-1&&(u.splice(p,1),J(o))}})(n,e):console.error(w)}}let Rn=new Set;function Ke(n){Rn.add(n)}function ze(n){Rn.delete(n)}function Xe(){return async n=>{(function(e){let o=Sn(e),s=D.get(o);if(s){for(let c of s)J(c);D.delete(o)}})(n),Rn.forEach((e=>e(n)))}}async function Je(n){let e=await(o=n,fin.InterApplicationBus.Channel.create(o));var o;return e.onConnection((async s=>{for(let c of gn)if(!await c(s))throw C})),e.onDisconnection(Xe()),e.register(X,Be()),e.register(K,(s=>{let c=Wn(s.providerId,s.id),l=Cn.get(c);l&&l(s)})),e.register(bn,Ge()),e.register(Nn,He()),e.register(Ln,(async()=>Mn())),e.register(Pn,De()),e.register(z,(async(s,c)=>{if(!s||!s.providerId||!s.result)return void console.error(w);let l=L(s.providerId);if(!l)throw h;let{onResultDispatch:u}=l;return u?(s.result.dispatcherIdentity=s.result.dispatcherIdentity??c,u(s.result)):void 0})),e}async function Qe(){let n=Y();be(),await n.destroy(),Fn()}async function Ye(n){let e=Ie();e||(e=await Je(n),Pe(e));let o=Le.bind(null),s=ze.bind(null),c=pe.bind(null),l=he.bind(null);return{getAllProviders:Mn.bind(null),search:Bn.bind(null),register:Te.bind(null),deregister:xe.bind(null),onSubscription:Ne.bind(null),onDisconnect:Ke.bind(null),onRegister:de.bind(null),onDeregister:fe.bind(null),dispatch:ke.bind(null),disconnect:Qe.bind(null),removeListener:u=>{o(u),s(u),c(u),l(u)},channel:e}}let{v:Vn}=a,{B:qn}=r,jn="all",Ze={create:Vn,subscribe:qn,defaultTopic:jn},Gn=()=>{window.search=Ze},Hn=n=>{let e=()=>{Gn(),window.removeEventListener(n,e)};return e};if(typeof window<"u"){Gn();let n="load",e=Hn(n);window.addEventListener(n,e);let o="DOMContentLoaded",s=Hn(o);window.addEventListener(o,s)}Xn.exports=i})()});var y="@openfin/cloud-api";async function N(){try{return await window.fin.View.getCurrentSync().getInfo(),!0}catch{return!1}}function zn(t){if(t.name.startsWith("internal-generated"))throw new Error("Cannot extract app UUID from identity");return/\/[\d,a-z-]{36}$/.test(t.name)?t.name.split("/")[0]||"":t.name}var q="@openfin/cloud-api";function lt(){return`${window.fin.me.uuid}-cloud-api-notifications`}var An=null;async function qt(){return An||(An=ut()),An}async function ut(){if(!window.fin)throw new Error(`\`${q}\`: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${q}: \`getNotificationsClient\` cannot be used in a non-OpenFin environment`);zn(window.fin.me);let t=await dt();console.log(t),t.register("openfin-cloud-event",r=>{for(let a of i.get(r.type)??[])typeof r.payload.timestamp=="string"&&(r.payload.timestamp=new Date(r.payload.timestamp)),a(r.payload)});let i=new Map;return{addEventListener:(r,a)=>{let d=i.get(r)||new Set;d.add(a),i.set(r,d)},removeEventListener:(r,a)=>{let d=i.get(r);if(!d){console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference or forget to add the listener?`,r);return}d.delete(a)===!1&&console.warn(`\`${q}\`: Listener was not found for event. Did you pass a function directly instead of a reference?`,r)},update:async r=>(await t.dispatch("openfin-cloud-update-notification",{version:1,payload:{notification:r}})).payload.response,clear:async r=>(await t.dispatch("openfin-cloud-clear-notification",{version:1,payload:{notificationId:r}})).payload.response,createNotification:async r=>(r.id&&console.warn(`\`${q}\`: The \`id\` property is not supported and will be ignored. If you need to use the \`id\` property, you should use the \`id\` property of the returned notification object.`),(await t.dispatch("openfin-cloud-create-notification",{version:1,payload:{notification:{...r,id:void 0}}})).payload.response)}}var tn=null;async function dt(){return tn||(tn=pt()),tn}async function pt(){let t=await window.fin.InterApplicationBus.Channel.connect(lt());return t.onDisconnection(i=>{console.warn(`\`${q}\`: Channel Disconnected from`,i,"Reconnecting..."),tn=null}),t}var On;function ft(){return`${window.fin.me.uuid}-client-api`}async function U(){return On||(On=window.fin.InterApplicationBus.Channel.connect(ft())),On}async function Ht(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-settings")}async function Kt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-settings")}async function zt(t){if(!window.fin)throw new Error(`\`${y}\`: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`setAppUserSettings\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("set-user-settings",t)}async function Xt(){if(!window.fin)throw new Error(`\`${y}\`: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`getAppUserPermissions\` cannot be used in a non-OpenFin environment`);return(await U()).dispatch("get-user-permissions")}async function Jt(t,i){if(!window.fin)throw new Error(`\`${y}\`: \`launchContent\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchContent\` cannot be used in a outside of an OpenFin View context`);let r=await U();try{await r.dispatch("launch-content",{id:t,options:i})}catch(a){switch(a instanceof Error?a.message:String(a)){case"UnableToLookup":throw new Error(`${y}: \`launchContent\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchContent\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchContent\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchContent\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Qt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchSupertab\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchSupertab\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-supertab",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchSupertab\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchSupertab\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchSupertab\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchSupertab\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}async function Yt(t){if(!window.fin)throw new Error(`\`${y}\`: \`launchWorkspace\` cannot be used in a non-OpenFin environment`);if(await N()===!1)throw new Error(`${y}: \`launchWorkspace\` cannot be used in a outside of an OpenFin View context`);let i=await U();try{await i.dispatch("launch-workspace",{id:t})}catch(r){switch(r instanceof Error?r.message:String(r)){case"UnableToLookup":throw new Error(`${y}: \`launchWorkspace\` was unable to lookup content with id: ${t}`);case"UnableToLaunch":throw new Error(`${y}: \`launchWorkspace\` was unable to launch content with id: ${t}`);case"NoContentFound":throw new Error(`${y}: \`launchWorkspace\` did not find content with id: ${t}`);default:throw new Error(`${y}: \`launchWorkspace\` was unable to look up or launch content with id: ${t} or the content did not exist.`)}}}var ne={};Kn(ne,{getAgentConfiguration:()=>Yn,register:()=>Zn});var Qn=vn(on(),1),ht="[here-agent]",gt="log-message-",wt="open-url",yt="provider-status-",mt="registered-",Ct="1.0";function St(t,i){let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}}function Jn(t){return{...t,data:t.data.customData}}async function Yn(){let{customData:t}=await window.fin.me.getOptions();return t}function Rt(){return`${window.fin.me.identity.uuid}-cloud-api-search`}async function Et(t,i,r,a=!0){await i("info",`Setting status as ${a?"ready":"not ready"}`);try{await t.dispatch(`${yt}${r}`,{isReady:a})}catch(d){let h=["Error setting provider status",d];console.error(...h),i("error",...h)}}async function vt(t,i,r,...a){try{console.log(ht,...a),await t.dispatch(`${gt}${i}`,{level:r,message:a})}catch(d){console.error("Error logging message",d)}}async function At(t,i,r,a,d){let{action:h,dispatcherIdentity:m,...w}=d;await r("info","Handling action",{action:h,dispatcherIdentity:m,result:w});let C;try{let P=Jn(d).actions?.find(({name:H})=>H===h.name);if(!P)throw new Error("Original action not found in search result");C=(await a(P,Jn(d)))?.url}catch(S){throw await r("error","Error handling dispatch",S),S}if(!C){await r("warn","OnActionListener did not return a URL");return}await It(t,r,i,C,m)}async function Ot(t,i,r,a){await i("info","Getting search results",{request:a});try{let d=new AbortController;a.onClose(()=>d.abort());let{context:h,query:m}=a,{results:w}=await r({context:h,query:m,signal:d.signal}),C=w.map(S=>St(S,t));return await i("info","Returning results",C),{results:C}}catch(d){let h=["Error handling search",d];throw console.error(...h),i("error",...h),d}}async function It(t,i,r,a,d){await i("info","Opening URL",{url:a,targetIdentity:d});try{await t.dispatch(wt,{url:a,targetIdentity:d,providerId:r})}catch(h){let m=["Error opening URL",h];console.error(...m),i("error",...m)}}async function Zn(t){let r=(await window.fin.me.getOptions()).customData,{id:a,title:d}=r,{onAction:h,onSearch:m}=t,w=await Qn.subscribe(Rt()),C=w.channel,S=vt.bind(null,C,a);return await w.register({icon:"",id:a,onResultDispatch:At.bind(null,C,a,S,h),onUserInput:Ot.bind(null,a,S,m),title:d}),await w.channel.dispatch(`${mt}${a}`,{version:Ct}),S("info","Registered search topic",{id:a,title:d}),{isReady:Et.bind(null,C,S,a)}}var le={};Kn(le,{getConfiguration:()=>ae,register:()=>ce});var se=vn(on(),1);var rn=class extends Error{constructor(){super("Interop feature is not supported by the agent")}};async function sn(t,i){try{let r=await window.fin.me.interop.getFDC3(t);i==="none"?(A("Leaving current channel"),await r.leaveCurrentChannel()):(A(`Joining interop channel: ${i}`),await("joinUserChannel"in r?r.joinUserChannel(i):r.joinChannel(i)))}catch(r){A(`Failed to join interop channel: ${i}`,r)}}var ro=vn(on(),1);var Nt=(t,i)=>{let{data:r,iconSize:a,rightSideIcon:d,...h}=t;return{...h,data:{customData:r,iconSize:a,providerId:i,resultType:"app",rightSideIcon:d}}},ee=t=>({...t,data:t.data.customData}),te=()=>`${window.fin.me.identity.uuid}-cloud-api-search`,Lt=async({channel:t,url:i,targetIdentity:r})=>{A("Opening URL",{url:i,targetIdentity:r});try{await t.dispatch(ie,{url:i,targetIdentity:r})}catch(a){console.error("Failed opening URL",a)}},oe=async(t,i,r,a)=>{let{action:d,dispatcherIdentity:h,...m}=a;A("Handling action...",{action:d,dispatcherIdentity:h,result:m});let w;try{let S=ee(a).actions?.find(({name:b})=>b===d.name);if(!S)throw new Error("Original action not found in search result");w=(await r(S,ee(a)))?.url}catch(C){throw A("Error handling dispatch",C),C}if(!w){A("OnActionListener did not return a URL");return}await Lt({channel:t,url:w,targetIdentity:h})},re=async(t,i,r)=>{A("Getting search results...",{request:r});try{let a=new AbortController;r.onClose(()=>a.abort());let{context:d,query:h}=r,{results:m}=await i({context:d,query:h,signal:a.signal}),w=m.map(C=>Nt(C,t));return A("Returning results",w),{results:w}}catch(a){throw new Error("Error handling search request",{cause:a})}};var _t="[here-agent]",Tt="1.0",xt="-enterprise-component-bridge",ie="open-url",kt="set-agent-registered",$t="set-agent-status",ae=async()=>{let{customData:t}=await window.fin.me.getOptions(),i=t,{configurationFields:r}=i;return Object.fromEntries(r?.map(a=>[a.name,a.value])??[])};async function Ut(t,i){if(!t.interop)throw new rn;let{fdc3Version:r}=t.interop;await sn(r,i)}function A(...t){console.log(_t,...t)}var Dt=async(t,i,r=!0)=>{A(`Setting status to ${r?"ready":"not ready"}`);try{await t.dispatch($t,{id:i,isReady:r})}catch(a){throw new Error("Failed to set agent status",{cause:a})}};async function ce(t){let{customData:i}=await window.fin.me.getOptions(),r=i;A("Registering agent...",r);try{let a=`${window.fin.me.identity.uuid}${xt}`,d;try{d=await window.fin.InterApplicationBus.Channel.connect(a,{wait:!1})}catch(S){throw new Error("Failed to connect to enterprise component bridge channel",{cause:S})}let{id:h,features:m,title:w}=r,C={features:m,joinInteropChannel:Ut.bind(null,m),setIsReady:Dt.bind(null,d,h)};if(m.interop){A("Enabling interop features");let{defaultChannel:S,fdc3Version:P}=m.interop;S&&S!=="none"&&await sn(P,S),d.register("on-desktop-app-signals-changed",Mt.bind(null,r))}return m.search&&t.search&&(A("Enabling search features"),await(await se.subscribe(te())).register({icon:"",id:h,onResultDispatch:oe.bind(null,d,h,t.search.onAction),onUserInput:re.bind(null,h,t.search.onSearch),title:w})),await d.dispatch(kt,{id:h,apiVersion:Tt}),A("Registered successfully"),C}catch(a){throw new Error("Failed to register agent",{cause:a})}}function Mt(t,i){A("Desktop app signals changed",i);let r=i,{type:a,id:d,features:h}=t,{fdc3Version:m}=h.interop,w=r.find(C=>a==="agent"?C.appKey===t.name:a==="custom"?C.appKey===d:!1);w&&sn(m,w.selectedColorChannel)}export{le as Agent,ne as Search,Ht as getAppSettings,Xt as getAppUserPermissions,Kt as getAppUserSettings,qt as getNotificationsClient,Jt as launchContent,Qt as launchSupertab,Yt as launchWorkspace,zt as setAppUserSettings}; |
+6
-4
| { | ||
| "name": "@openfin/cloud-api", | ||
| "version": "0.0.1-alpha.8e4fb3b", | ||
| "version": "0.0.1-alpha.8e5281d", | ||
| "sideEffects": false, | ||
@@ -17,3 +17,5 @@ "description": "", | ||
| "build": "tsup --config ./tsup.config.ts", | ||
| "dev": "tsup --watch --config ./tsup.config.ts", | ||
| "build:dev": "TSUP_DEV=true tsup --config ./tsup.config.ts", | ||
| "build:docker": "NODE_ENV=development npm run build:dev", | ||
| "dev": "TSUP_DEV=true tsup --watch --config ./tsup.config.ts", | ||
| "typecheck": "tsc --noEmit", | ||
@@ -29,6 +31,6 @@ "test": "echo \"Error: no test specified\" && exit 1", | ||
| "devDependencies": { | ||
| "@openfin/core": "42.100.102", | ||
| "@openfin/core": "43.101.4", | ||
| "@openfin/search-api": "^2.0.1", | ||
| "@openfin/typedoc-theme": "^2.0.2", | ||
| "@openfin/workspace": "22.3.12", | ||
| "@openfin/workspace": "23.2.6", | ||
| "@typescript-eslint/eslint-plugin": "^8.32.0", | ||
@@ -35,0 +37,0 @@ "@typescript-eslint/parser": "^8.32.0", |
| {"version":3,"sources":["/home/runner/work/openfin-direct/openfin-direct/packages/cloud-api/dist/index.cjs","../node_modules/@openfin/search-api/index.js"],"names":["require_search_api","__commonJSMin","exports","module","e","t","n","y","Je","Qe","Ge","oe","o","ze","r","i"],"mappings":"AAAA,gtCAAI,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CCAjlB,IAAAA,EAAAA,CAAAC,EAAAA,CAAA,CAAAC,EAAAA,CAAAC,EAAAA,CAAAA,EAAA,CAAA,YAAA,CAAA,CAAC,CAAA,CAAA,EAAI,CAAC,YAAA,CAAa,IAAIC,CAAAA,CAAE,CAAC,CAAA,CAAE,CAACC,CAAAA,CAAEC,CAAAA,CAAAA,EAAI,CAAC,GAAA,CAAA,IAAQ,EAAA,GAAKA,CAAAA,CAAEF,CAAAA,CAAE,CAAA,CAAEE,CAAAA,CAAE,CAAC,CAAA,EAAG,CAACF,CAAAA,CAAE,CAAA,CAAEC,CAAAA,CAAE,CAAC,CAAA,EAAG,MAAA,CAAO,cAAA,CAAeA,CAAAA,CAAE,CAAA,CAAE,CAAC,UAAA,CAAW,CAAA,CAAA,CAAG,GAAA,CAAIC,CAAAA,CAAE,CAAC,CAAC,CAAC,CAAC,CAAA,CAAE,CAAA,CAAE,CAACF,CAAAA,CAAEC,CAAAA,CAAAA,EAAI,MAAA,CAAO,SAAA,CAAU,cAAA,CAAe,IAAA,CAAKD,CAAAA,CAAEC,CAAC,CAAA,CAAE,CAAA,CAAED,CAAAA,EAAG,CAAc,OAAO,MAAA,CAApB,GAAA,EAA4B,MAAA,CAAO,WAAA,EAAa,MAAA,CAAO,cAAA,CAAeA,CAAAA,CAAE,MAAA,CAAO,WAAA,CAAY,CAAC,KAAA,CAAM,QAAQ,CAAC,CAAA,CAAE,MAAA,CAAO,cAAA,CAAeA,CAAAA,CAAE,YAAA,CAAa,CAAC,KAAA,CAAM,CAAA,CAAE,CAAC,CAAC,CAAC,CAAA,CAAEC,CAAAA,CAAE,CAAC,CAAA,CAAED,CAAAA,CAAE,CAAA,CAAEC,CAAC,CAAA,CAAED,CAAAA,CAAE,CAAA,CAAEC,CAAAA,CAAE,CAAC,mBAAA,CAAoB,CAAA,CAAA,EAAIE,EAAAA,CAAE,MAAA,CAAO,CAAA,CAAA,EAAIC,EAAAA,CAAG,YAAA,CAAa,CAAA,CAAA,EAAIC,EAAAA,CAAG,SAAA,CAAU,CAAA,CAAA,EAAIC,EAAE,CAAC,CAAA,CAAE,IAAIJ,CAAAA,CAAE,CAAC,CAAA,CAAEF,CAAAA,CAAE,CAAA,CAAEE,CAAC,CAAA,CAAEF,CAAAA,CAAE,CAAA,CAAEE,CAAAA,CAAE,CAAC,CAAA,CAAE,CAAA,CAAA,EAAIK,EAAE,CAAC,CAAA,CAAE,IAAIC,CAAAA,CAAE,CAAC,CAAA,CAAER,CAAAA,CAAE,CAAA,CAAEQ,CAAC,CAAA,CAAER,CAAAA,CAAE,CAAA,CAAEQ,CAAAA,CAAE,CAAC,CAAA,CAAE,CAAA,CAAA,EAAIC,EAAE,CAAC,CAAA,CAAE,IAAMC,CAAAA,CAAE,gCAAA,CAAiCC,CAAAA,CAAE,IAAI,KAAA,CAAM,CAAA,SAAA,EAAYD,CAAC,CAAA,CAAA","file":"/home/runner/work/openfin-direct/openfin-direct/packages/cloud-api/dist/index.cjs","sourcesContent":[null,"(()=>{\"use strict\";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{\"undefined\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\"Module\"}),Object.defineProperty(e,\"__esModule\",{value:!0})}},t={};e.r(t),e.d(t,{SearchTagBackground:()=>y,create:()=>Je,defaultTopic:()=>Qe,subscribe:()=>Ge});var n={};e.r(n),e.d(n,{B:()=>oe});var o={};e.r(o),e.d(o,{v:()=>ze});const r=\"deregistered or does not exist\",i=new Error(`provider ${r}`),s=new Error(\"provider with name already exists\"),c=new Error(\"bad payload\"),a=new Error(\"subscription rejected\"),u=new Error(`channel ${r}`);let d;function l(){if(d)return d;throw u}function f(){return d}function p(e){d=e}var h,g,w,y;!function(e){e[e.Initial=0]=\"Initial\",e[e.Open=1]=\"Open\",e[e.Close=2]=\"Close\"}(h||(h={})),function(e){e.Fetching=\"fetching\",e.Fetched=\"fetched\",e.Complete=\"complete\"}(g||(g={})),function(e){e.UserAction=\"user-action\",e.FocusChange=\"focus-change\",e.Reload=\"reload\"}(w||(w={})),function(e){e.Active=\"active\",e.Default=\"default\"}(y||(y={}));const v=\"0\",m=\"1\",R=\"2\",C=\"3\",b=\"4\",S=\"5\",I=\"6\",x=()=>{},O=new Set;function P(e){O.add(e)}function B(e){O.delete(e)}const E=new Set;function k(e){E.add(e)}function A(e){E.delete(e)}const D=new Map;async function L(e){D.set(e.id,e);const t=[...O].map((e=>e()));await Promise.all(t)}async function U(e){D.delete(e);const t=[...E].map((e=>e()));await Promise.all(t)}function _(){return[...D.values()]}function T(){D.clear()}function F(e){return D.get(e)}function M(e,t,n){return{...e,action:n||{...e.actions[0],trigger:w.UserAction},dispatcherIdentity:t}}function $(e,t,n=\"ascending\"){const o=e||[];if(!t?.length)return o;const r=[],i=new Map;t.forEach((e=>{if(e.key)return i.set(e.key,e);r.push(e)}));let s=o.map((e=>{const{key:t}=e;if(t&&i.has(t)){const e=i.get(t);return i.delete(t),e}return e}));return s.push(...i.values(),...r),s=\"ascending\"===n?s.sort(((e,t)=>(e?.score??1/0)-(t?.score??1/0))):s.sort(((e,t)=>(t?.score??1/0)-(e?.score??1/0))),s}function W(e){const t={};let n=[];let o=[];let r=null;let i=h.Initial;t.getStatus=()=>i,t.getResultBuffer=()=>n,t.setResultBuffer=e=>{n=e,n?.length&&t.onChange()},t.getRevokedBuffer=()=>o,t.setRevokedBuffer=e=>{o=e,o?.length&&t.onChange()},t.setUpdatedContext=e=>{r=e,t.onChange()},t.getUpdatedContext=()=>r,t.onChange=x;const s={};return t.res=s,s.close=()=>{i!==h.Close&&(i=h.Close,t.onChange())},s.open=()=>{i!==h.Open&&(i=h.Open,t.onChange())},s.respond=n=>{const o=$(t.getResultBuffer(),n,e);t.setResultBuffer(o)},s.revoke=(...e)=>{const n=new Set(e),o=t.getResultBuffer().filter((({key:e})=>{const t=n.has(e);return t&&n.delete(e),!t}));t.setResultBuffer(o),n.size&&(t.getRevokedBuffer().forEach((e=>n.add(e))),t.setRevokedBuffer([...n]))},s.updateContext=e=>{t.setUpdatedContext(e)},t}function q(e,t){const n=new Set;let o=!1;return{close:()=>{o=!0;for(const e of n)e()},req:{id:e,...t,context:t?.context||{},onClose:e=>{n.add(e),o&&e()},removeListener:e=>{n.delete(e)}}}}function K(){return{name:fin.me.name,uuid:fin.me.uuid}}const V=50,j=1e3;const H=new Map;function N(){return H}const z=100;function J(){return async e=>{if(!e||!e.id||!e.providerId){const e=c;return console.error(e),{error:e.message}}const{id:t,providerId:n}=e,o=F(n);if(!o){const e=i;return console.error(e),{error:e.message}}const r=N();let s=r.get(e.id);s||(s=q(t,e),r.set(e.id,s));const a=W(),u=()=>{const e=a.getResultBuffer();a.setResultBuffer([]);const o=a.getRevokedBuffer();a.setRevokedBuffer([]);const r=a.getUpdatedContext();a.setUpdatedContext(null);const i=a.getStatus();!async function(e){(await l()).dispatch(v,e)}({id:t,providerId:n,results:e,revoked:o,status:i,context:r})};let d=!0,f=!1;a.onChange=()=>{if(d)return d=!1,void u();f||(f=!0,setTimeout((()=>{f=!1,u()}),z))};try{const{results:e,context:r}=await o.onUserInput(s.req,a.res),i=a.getStatus();return{id:t,providerId:n,status:i,results:e,context:r}}catch(e){return console.error(`OpenFin/Workspace/Home. Uncaught exception in search provider ${n} for search ${t}`,\"This is likely a bug in the implementation of the search provider.\",e),{id:t,providerId:n,error:e?.message}}}}async function G(e,t){const n=t||await l(),o=K(),r={...e,identity:o,onResultDispatch:void 0},i=await n.dispatch(R,r);return await L({identity:o,...e}),i}async function Q(e){const t=await l();return await t.dispatch(C,e),U(e)}async function X(e,t,n,o){const r=M(t,o??K(),n),i=F(e);if(i){const{onResultDispatch:e}=i;if(!e)return;return e(r)}const s={providerId:e,result:r};return(await l()).dispatch(S,s)}async function Y(e){const t={...e,context:e?.context||{}},n={},o=async function*(e,{setState:t}){const n=await l();for(;;){const o=await n.dispatch(m,e),r=o.error;if(r)throw new Error(r);const i=o;if(e.id=i.id,t(i.state),i.done)return i.value;yield i.value}}(t,{setState:e=>{n.state=e}});let r=await o.next();return n.id=t.id||\"\",n.close=()=>{!async function(e){(await l()).dispatch(I,{id:e})}(n.id)},n.next=()=>{if(r){const e=r;return r=void 0,e}return o.next()},n}async function Z(){return(await l()).dispatch(b,null)}async function ee(){const e=await l();d=void 0,T(),await e.disconnect()}const te=async e=>{const t=await ne(e);for(const e of _())await G(e,t);return t};async function ne(e){const t=await async function(e){for(let t=0;t<V;t++)try{return await fin.InterApplicationBus.Channel.connect(e,{wait:!1})}catch(e){if(t===V-1)throw e;await new Promise((e=>setTimeout(e,j)))}}(e);return t.register(v,J()),t.register(I,(e=>{const t=N(),n=t.get(e.id);n&&(n.close(),t.delete(e.id))})),t.register(S,(async(e,t)=>{if(!e||!e.providerId||!e.result)return void console.error(c);const n=F(e.providerId);if(!n)return void console.error(i);const{onResultDispatch:o}=n;return o?(e.result.dispatcherIdentity=e.result.dispatcherIdentity??t,o(e.result)):void 0})),t.onDisconnection(function(e){return async()=>{if(!f())return;const t=N();for(const{req:e,close:n}of t.values())n(),t.delete(e.id);p(te(e))}}(e)),t}async function oe(e){let t=f();t||(t=ne(e),p(t));const n=await t;return{getAllProviders:Z.bind(null),register:G.bind(null),search:Y.bind(null),deregister:Q.bind(null),dispatch:X.bind(null),disconnect:ee.bind(null),channel:n}}let re;function ie(){if(re)return re;throw u}function se(){return re}function ce(e){re=e}function ae(){re=void 0}const ue=new Set;function de(e){ue.add(e)}function le(e){ue.delete(e)}var fe;!function(e){e.Local=\"local\",e.Dev=\"dev\",e.Staging=\"staging\",e.Prod=\"prod\"}(fe||(fe={}));const pe=\"undefined\"!=typeof window&&\"undefined\"!=typeof fin,he=(\"undefined\"==typeof process||process.env,\"undefined\"!=typeof window),ge=he?window.origin:fe.Local,we=(pe&&fin.me.uuid,pe&&fin.me.name,pe&&fin.me.entityType,fe.Local,fe.Dev,fe.Staging,fe.Prod,e=>e.startsWith(\"http://\")||e.startsWith(\"https://\")?e:ge+e),ye=(we(\"http://localhost:4002\"),we(\"http://localhost:4002\"),\"undefined\"!=typeof WORKSPACE_DOCS_PLATFORM_URL&&we(WORKSPACE_DOCS_PLATFORM_URL),\"undefined\"!=typeof WORKSPACE_DOCS_CLIENT_URL&&we(WORKSPACE_DOCS_CLIENT_URL),\"20.3.6\");\"undefined\"!=typeof WORKSPACE_BUILD_SHA&&WORKSPACE_BUILD_SHA;async function ve(){return[..._()].map((e=>({...e,onUserInput:void 0,onResultDispatch:void 0})))}async function me(e){if(F(e.id))throw new Error(\"provider with name already exists\");const t=K();return await L({identity:t,...e}),{workspaceVersion:ye||\"\",clientAPIVersion:e.clientAPIVersion||\"\"}}async function Re(e){await U(e)}async function Ce(e,t,n,o){const r=F(e);if(!r)throw i;const{onResultDispatch:s}=r;if(!s)return;return s(M(t,o??K(),n))}async function*be(e,t){const n=function(e,t){const n=[],o=[],r=[],i=[];for(const s of e){const e=W(s.scoreOrder),c={results:[],provider:{id:s.id,identity:s.identity,title:s.title,scoreOrder:s.scoreOrder,icon:s.icon,dispatchFocusEvents:s.dispatchFocusEvents}};n.push(c),o.push(e);const a=(async()=>{try{const{results:n,context:o}=await s.onUserInput(t,e.res);c.results=$(c.results||[],n,s.scoreOrder),c.context={...c.context,...o}}catch(e){c.error=e}})();a.finally((()=>{a.done=!0})),i.push(a),r.push(r.length)}return{providerResponses:n,listenerResponses:o,openListenerResponses:r,initialResponsePromises:i}}(e.targets?e.targets.map((e=>F(e))).filter((e=>!!e)):[..._().filter((e=>!e.hidden))],e),{providerResponses:o,listenerResponses:r}=n;let{openListenerResponses:i,initialResponsePromises:s}=n,c=g.Fetching;const a=e=>{c=e,t.setState(c)};let u,d=!1;e.onClose((()=>{d=!0,u&&u()}));do{let e=!1;if(s.length){const t=[];for(const n of s)n.done?e=!0:t.push(n);s=t,s.length||(a(g.Fetched),e=!0)}let t,n=!1;const l=()=>{n=!0,t&&t()},f=[];for(const t of i){const n=r[t],i=o[t],s=n.getStatus();(s===h.Open||c===g.Fetching&&s===h.Initial)&&(f.push(t),n.onChange=l);const a=n.getResultBuffer();a.length&&(n.setResultBuffer([]),i.results=$(i.results||[],a),e=!0);const u=n.getRevokedBuffer();if(u.length){n.setRevokedBuffer([]);const t=new Set(u);i.results=(i.results||[]).filter((({key:e})=>!t.has(e))),e=!0}const d=n.getUpdatedContext();d&&(n.setUpdatedContext(null),i.context={...i.context,...d},e=!0)}if(i=f,e&&(yield o),d)break;n||(i.length||s.length)&&await Promise.race([...s,new Promise((e=>{t=e})),new Promise((e=>{u=e}))])}while(i.length||s.length);return a(g.Complete),o}let Se=0;async function Ie(e){Se+=1;const t=q(Se.toString(),e),n=be(t.req,{setState:e=>{n.state=e}});return n.id=Se.toString(),n.close=t.close,n.state=g.Fetching,n}const xe=new Map,Oe=1e4;function Pe(){return async e=>{if(!e)return console.error(c),{error:c.message};let t;if(e.id)t=e.id;else{const n=await Ie(e);t=n.id,e.id=n.id,xe.set(t,{generator:n})}const n=xe.get(t);clearTimeout(n.timeout);const o=await n.generator.next();return n.timeout=function(e){return window.setTimeout((()=>{xe.delete(e)}),Oe)}(t),{...o,id:e.id,state:n.generator.state}}}function Be(e,t){return ie().dispatch(e,I,{id:t})}function Ee(){return e=>function(e){const t=xe.get(e);t&&t.generator.close()}(e.id)}async function ke(e,{id:t,query:n,context:o,targets:r=[]}){const i=ie(),s={id:t,query:n,context:o,targets:r,providerId:e.id},c=await i.dispatch(e.identity,v,s),a=c.error;if(a)throw new Error(a);return c}const Ae=new Map;function De(e,t){return`${e.name}:${e.uuid}:${t}`}const Le=new Map;function Ue(e,t){return`${e}:${t}`}function _e(e){const t=De.bind(null,e.identity),n=Be.bind(null,e.identity),o=ke.bind(null,e);return async(r,i)=>{const s=t(r.id);if(!Ae.has(s)){const e=()=>{n(r.id),Ae.delete(s)};Ae.set(s,e),r.onClose(e)}const c=Ue(e.id,r.id),a=()=>{Le.delete(c),i.close()};r.onClose(a),Le.set(c,(e=>{e.results?.length&&i.respond(e.results),e.revoked?.length&&i.revoke(...e.revoked),e.context&&i.updateContext(e.context),e.status===h.Open&&i.open(),e.status===h.Close&&a()}));const u=await o(r);return u.status===h.Open&&i.open(),u.status!==h.Close&&u.status!==h.Initial||a(),u}}function Te(e){return async t=>{const n=ie(),o={providerId:e.id,result:t};return n.dispatch(e.identity,S,o)}}const Fe=new Map;function Me(e){return`${e.name}-${e.uuid}`}function $e(){return async(e,t)=>{if(!e||!e.id)return console.error(new Error(JSON.stringify(e))),void console.error(c);if(F(e.id))throw s;return e.identity=t,await async function(e){const t=Me(e.identity);Fe.has(t)||Fe.set(t,[]),Fe.get(t).push(e.id),await L({...e,onUserInput:_e(e),onResultDispatch:Te(e)})}(e),{workspaceVersion:ye||\"\",clientAPIVersion:e.clientAPIVersion||\"\"}}}function We(){return(e,t)=>{e?function(e,t){const n=F(e);if(!n)return;if(n.identity.uuid!==t.uuid||n.identity.name!==t.name)throw i;const o=Me(n.identity),r=Fe.get(o);if(r){const t=r.findIndex((t=>t===e));-1!==t&&(r.splice(t,1),U(e))}}(e,t):console.error(c)}}const qe=new Set;function Ke(e){qe.add(e)}function Ve(e){qe.delete(e)}function je(){return async e=>{!function(e){const t=Me(e),n=Fe.get(t);if(n){for(const e of n)U(e);Fe.delete(t)}}(e),qe.forEach((t=>t(e)))}}async function He(e){const t=await(n=e,fin.InterApplicationBus.Channel.create(n));var n;return t.onConnection((async e=>{for(const t of ue)if(!await t(e))throw a})),t.onDisconnection(je()),t.register(I,Ee()),t.register(v,(e=>{const t=Ue(e.providerId,e.id),n=Le.get(t);n&&n(e)})),t.register(R,$e()),t.register(C,We()),t.register(b,(async()=>ve())),t.register(m,Pe()),t.register(S,(async(e,t)=>{if(!e||!e.providerId||!e.result)return void console.error(c);const n=F(e.providerId);if(!n)throw i;const{onResultDispatch:o}=n;return o?(e.result.dispatcherIdentity=e.result.dispatcherIdentity??t,o(e.result)):void 0})),t}async function Ne(){const e=ie();ae(),await e.destroy(),T()}async function ze(e){let t=se();t||(t=await He(e),ce(t));const n=le.bind(null),o=Ve.bind(null),r=B.bind(null),i=A.bind(null);return{getAllProviders:ve.bind(null),search:Ie.bind(null),register:me.bind(null),deregister:Re.bind(null),onSubscription:de.bind(null),onDisconnect:Ke.bind(null),onRegister:P.bind(null),onDeregister:k.bind(null),dispatch:Ce.bind(null),disconnect:Ne.bind(null),removeListener:e=>{n(e),o(e),r(e),i(e)},channel:t}}const{v:Je}=o,{B:Ge}=n,Qe=\"all\",Xe={create:Je,subscribe:Ge,defaultTopic:Qe},Ye=()=>{window.search=Xe},Ze=e=>{const t=()=>{Ye(),window.removeEventListener(e,t)};return t};if(\"undefined\"!=typeof window){Ye();const e=\"load\",t=Ze(e);window.addEventListener(e,t);const n=\"DOMContentLoaded\",o=Ze(n);window.addEventListener(n,o)}module.exports=t})();\n//# sourceMappingURL=index.js.map"]} |
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1133
1.16%5
-16.67%1
-50%131967
-45.47%6
-25%