@openfin/cloud-api 0.0.1-alpha.e65a7a2 → 0.0.1-alpha.e6a1a71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +71 -46
- package/dist/index.d.ts +71 -46
- package/dist/index.js +1 -2
- package/package.json +6 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -298,16 +298,16 @@ declare function launchSupertab(id: string): Promise<void>;
|
|
|
298
298
|
declare function launchWorkspace(id: string): Promise<void>;
|
|
299
299
|
|
|
300
300
|
/**
|
|
301
|
-
* Function that is called when the Search Agent receives an action from
|
|
301
|
+
* 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.
|
|
302
302
|
*
|
|
303
303
|
* @param action The action that was triggered.
|
|
304
304
|
* @param result The search result that the action was triggered on.
|
|
305
305
|
*
|
|
306
|
-
* @returns Result that includes the URL that
|
|
306
|
+
* @returns Result that includes the URL that HERE should navigate to, or `undefined` if no navigation is required.
|
|
307
307
|
*/
|
|
308
308
|
type OnActionListener = (action: SearchAction$1, result: SearchResult$1) => SearchResultActionResponse$1 | Promise<SearchResultActionResponse$1>;
|
|
309
309
|
/**
|
|
310
|
-
* Function that is called when the Search Agent receives a query from
|
|
310
|
+
* Function that is called when the Search Agent receives a query from HERE's search UI
|
|
311
311
|
*
|
|
312
312
|
* @param request Search request data that includes the query.
|
|
313
313
|
*
|
|
@@ -317,21 +317,23 @@ type OnSearchListener = (request: SearchListenerRequest$1) => SearchResponse$1 |
|
|
|
317
317
|
/**
|
|
318
318
|
* An action that can be triggered by a user on a search result returned by a Search Agent.
|
|
319
319
|
*
|
|
320
|
-
* Actions are displayed as buttons alongside search results in
|
|
320
|
+
* 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.
|
|
321
321
|
*/
|
|
322
322
|
type SearchAction$1 = {
|
|
323
323
|
/**
|
|
324
|
-
*
|
|
325
|
-
*/
|
|
326
|
-
darkIcon?: string;
|
|
327
|
-
/**
|
|
328
|
-
* A fuller description of the action that will be displayed in Here™’s search UI when the user hovers over the action button.
|
|
324
|
+
* A fuller description of the action that will be displayed in HERE's search UI when the user hovers over the action button.
|
|
329
325
|
*/
|
|
330
326
|
description?: string;
|
|
331
327
|
/**
|
|
332
|
-
*
|
|
328
|
+
* Icon that will be displayed within the action button in HERE's search UI.
|
|
329
|
+
*
|
|
330
|
+
* This can be a URL/data URI string (used for both Light and Dark modes),
|
|
331
|
+
* or an object containing separate icons for Light and Dark modes.
|
|
333
332
|
*/
|
|
334
|
-
|
|
333
|
+
icon?: string | {
|
|
334
|
+
dark: string;
|
|
335
|
+
light: string;
|
|
336
|
+
};
|
|
335
337
|
/**
|
|
336
338
|
* Internal identifier for the action which is used to identify the action in the {@link OnActionListener}.
|
|
337
339
|
*/
|
|
@@ -342,7 +344,7 @@ type SearchAction$1 = {
|
|
|
342
344
|
title?: string;
|
|
343
345
|
};
|
|
344
346
|
/**
|
|
345
|
-
* A Search Agent returns search results to
|
|
347
|
+
* 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.
|
|
346
348
|
*
|
|
347
349
|
* @deprecated Use {@link Agent} instead.
|
|
348
350
|
*/
|
|
@@ -359,7 +361,7 @@ type SearchAgent = {
|
|
|
359
361
|
isReady: (ready?: boolean) => Promise<void>;
|
|
360
362
|
};
|
|
361
363
|
/**
|
|
362
|
-
* The Search Agent
|
|
364
|
+
* The Search Agent's configuration data as configured in the HERE Admin Console.
|
|
363
365
|
*
|
|
364
366
|
* @typeParam T Type definition for the `customData` property, containing any custom configuration data specific to the Search Agent.
|
|
365
367
|
*/
|
|
@@ -390,13 +392,13 @@ type SearchAgentConfigurationData<T> = {
|
|
|
390
392
|
*/
|
|
391
393
|
type SearchAgentRegistrationConfig = {
|
|
392
394
|
/**
|
|
393
|
-
* This listener is called when the Search Agent receives an action from
|
|
395
|
+
* 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.
|
|
394
396
|
*
|
|
395
|
-
* The listener returns a response back to
|
|
397
|
+
* The listener returns a response back to HERE that includes a URL to navigate to.
|
|
396
398
|
*/
|
|
397
399
|
onAction: OnActionListener;
|
|
398
400
|
/**
|
|
399
|
-
* This listener is called when the Search Agent receives a query from
|
|
401
|
+
* This listener is called when the Search Agent receives a query from HERE's search UI and returns relevant search results.
|
|
400
402
|
*
|
|
401
403
|
* Note: When the Search Agent is not ready this listener will not be called.
|
|
402
404
|
*/
|
|
@@ -411,7 +413,7 @@ type SearchListenerRequest$1 = {
|
|
|
411
413
|
*/
|
|
412
414
|
context: SearchRequestContext$1;
|
|
413
415
|
/**
|
|
414
|
-
* The query entered by the user in
|
|
416
|
+
* The query entered by the user in HERE's search UI.
|
|
415
417
|
*/
|
|
416
418
|
query: string;
|
|
417
419
|
/**
|
|
@@ -441,7 +443,7 @@ type SearchRequestContext$1 = {
|
|
|
441
443
|
*/
|
|
442
444
|
type SearchResponse$1 = {
|
|
443
445
|
/**
|
|
444
|
-
* The search results to display in
|
|
446
|
+
* The search results to display in HERE's search UI.
|
|
445
447
|
*/
|
|
446
448
|
results: SearchResult$1[];
|
|
447
449
|
};
|
|
@@ -458,7 +460,7 @@ type SearchResult$1 = {
|
|
|
458
460
|
*/
|
|
459
461
|
data?: Record<string, unknown>;
|
|
460
462
|
/**
|
|
461
|
-
* URL or data URI of an icon that will be displayed with the search result in
|
|
463
|
+
* URL or data URI of an icon that will be displayed with the search result in HERE's search UI.
|
|
462
464
|
*/
|
|
463
465
|
icon?: string;
|
|
464
466
|
/**
|
|
@@ -466,11 +468,11 @@ type SearchResult$1 = {
|
|
|
466
468
|
*/
|
|
467
469
|
key: string;
|
|
468
470
|
/**
|
|
469
|
-
* Secondary text that will be displayed with the search result in
|
|
471
|
+
* Secondary text that will be displayed with the search result in HERE's search UI.
|
|
470
472
|
*/
|
|
471
473
|
label?: string;
|
|
472
474
|
/**
|
|
473
|
-
* Primary text that will be displayed with the search result in
|
|
475
|
+
* Primary text that will be displayed with the search result in HERE's search UI.
|
|
474
476
|
*/
|
|
475
477
|
title: string;
|
|
476
478
|
};
|
|
@@ -479,13 +481,13 @@ type SearchResult$1 = {
|
|
|
479
481
|
*/
|
|
480
482
|
type SearchResultActionResponse$1 = {
|
|
481
483
|
/**
|
|
482
|
-
* URL that
|
|
484
|
+
* URL that HERE should navigate to.
|
|
483
485
|
*/
|
|
484
486
|
url: string;
|
|
485
487
|
} | undefined;
|
|
486
488
|
|
|
487
489
|
/**
|
|
488
|
-
* Retrieves the Search Agent
|
|
490
|
+
* Retrieves the Search Agent's configuration data, as has been configured in the HERE Admin Console.
|
|
489
491
|
*
|
|
490
492
|
* @returns A promise that resolves with an object containing properties that match the Search Agent’s configuration.
|
|
491
493
|
*
|
|
@@ -507,7 +509,7 @@ type SearchResultActionResponse$1 = {
|
|
|
507
509
|
*/
|
|
508
510
|
declare function getAgentConfiguration<T extends object>(): Promise<SearchAgentConfigurationData<T>>;
|
|
509
511
|
/**
|
|
510
|
-
* Registers a Search Agent that will provide search results to
|
|
512
|
+
* 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.
|
|
511
513
|
*
|
|
512
514
|
* @param config The configuration for the Search Agent.
|
|
513
515
|
*
|
|
@@ -558,6 +560,10 @@ declare function getAgentConfiguration<T extends object>(): Promise<SearchAgentC
|
|
|
558
560
|
* name: "view-owner",
|
|
559
561
|
* description: `Go to ${ownerName} in My Web App`,
|
|
560
562
|
* title: "View Owner",
|
|
563
|
+
* icon: {
|
|
564
|
+
* dark: "data:image/svg+xml,...",
|
|
565
|
+
* light: "data:image/svg+xml,...",
|
|
566
|
+
* },
|
|
561
567
|
* },
|
|
562
568
|
* ],
|
|
563
569
|
* data: {
|
|
@@ -603,16 +609,16 @@ declare namespace index$1 {
|
|
|
603
609
|
}
|
|
604
610
|
|
|
605
611
|
/**
|
|
606
|
-
* Function that is called when the Agent receives an action from
|
|
612
|
+
* 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.
|
|
607
613
|
*
|
|
608
614
|
* @param action The action that was triggered.
|
|
609
615
|
* @param result The search result that the action was triggered on.
|
|
610
616
|
*
|
|
611
|
-
* @returns Result that includes the URL that
|
|
617
|
+
* @returns Result that includes the URL that HERE should navigate to, or `undefined` if no navigation is required.
|
|
612
618
|
*/
|
|
613
619
|
type OnSearchActionListener = (action: SearchAction, result: SearchResult) => SearchResultActionResponse | Promise<SearchResultActionResponse>;
|
|
614
620
|
/**
|
|
615
|
-
* Function that is called when the Agent receives a query from
|
|
621
|
+
* Function that is called when the Agent receives a query from HERE's search UI
|
|
616
622
|
*
|
|
617
623
|
* @param request Search request data that includes the query.
|
|
618
624
|
*
|
|
@@ -622,21 +628,23 @@ type OnSearchRequestListener = (request: SearchListenerRequest) => SearchRespons
|
|
|
622
628
|
/**
|
|
623
629
|
* An action that can be triggered by a user on a search result returned by a Agent.
|
|
624
630
|
*
|
|
625
|
-
* Actions are displayed as buttons alongside search results in
|
|
631
|
+
* 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.
|
|
626
632
|
*/
|
|
627
633
|
type SearchAction = {
|
|
628
634
|
/**
|
|
629
|
-
*
|
|
630
|
-
*/
|
|
631
|
-
darkIcon?: string;
|
|
632
|
-
/**
|
|
633
|
-
* A fuller description of the action that will be displayed in Here™’s search UI when the user hovers over the action button.
|
|
635
|
+
* A fuller description of the action that will be displayed in HERE's search UI when the user hovers over the action button.
|
|
634
636
|
*/
|
|
635
637
|
description?: string;
|
|
636
638
|
/**
|
|
637
|
-
*
|
|
639
|
+
* Icon that will be displayed within the action button in HERE's search UI.
|
|
640
|
+
*
|
|
641
|
+
* This can be a URL/data URI string (used for both Light and Dark modes),
|
|
642
|
+
* or an object containing separate icons for Light and Dark modes.
|
|
638
643
|
*/
|
|
639
|
-
|
|
644
|
+
icon?: string | {
|
|
645
|
+
dark: string;
|
|
646
|
+
light: string;
|
|
647
|
+
};
|
|
640
648
|
/**
|
|
641
649
|
* Internal identifier for the action which is used to identify the action in the {@link OnSearchActionListener}.
|
|
642
650
|
*/
|
|
@@ -655,7 +663,7 @@ type SearchListenerRequest = {
|
|
|
655
663
|
*/
|
|
656
664
|
context: SearchRequestContext;
|
|
657
665
|
/**
|
|
658
|
-
* The query entered by the user in
|
|
666
|
+
* The query entered by the user in HERE's search UI.
|
|
659
667
|
*/
|
|
660
668
|
query: string;
|
|
661
669
|
/**
|
|
@@ -667,6 +675,14 @@ type SearchListenerRequest = {
|
|
|
667
675
|
* Context data included with a search request.
|
|
668
676
|
*/
|
|
669
677
|
type SearchRequestContext = {
|
|
678
|
+
/**
|
|
679
|
+
* Filters to apply to the search results.
|
|
680
|
+
*/
|
|
681
|
+
filters: string[];
|
|
682
|
+
/**
|
|
683
|
+
* The locale of the client.
|
|
684
|
+
*/
|
|
685
|
+
locale: string;
|
|
670
686
|
/**
|
|
671
687
|
* The page number of the search results to return.
|
|
672
688
|
*/
|
|
@@ -679,13 +695,17 @@ type SearchRequestContext = {
|
|
|
679
695
|
* The unique ID of the query.
|
|
680
696
|
*/
|
|
681
697
|
queryId: string;
|
|
698
|
+
/**
|
|
699
|
+
* The timezone of the client.
|
|
700
|
+
*/
|
|
701
|
+
timeZone: string;
|
|
682
702
|
};
|
|
683
703
|
/**
|
|
684
704
|
* Return type of the {@link OnSearchRequestListener}.
|
|
685
705
|
*/
|
|
686
706
|
type SearchResponse = {
|
|
687
707
|
/**
|
|
688
|
-
* The search results to display in
|
|
708
|
+
* The search results to display in HERE's search UI.
|
|
689
709
|
*/
|
|
690
710
|
results: SearchResult[];
|
|
691
711
|
};
|
|
@@ -702,7 +722,7 @@ type SearchResult = {
|
|
|
702
722
|
*/
|
|
703
723
|
data?: Record<string, unknown>;
|
|
704
724
|
/**
|
|
705
|
-
* URL or data URI of an icon that will be displayed with the search result in
|
|
725
|
+
* URL or data URI of an icon that will be displayed with the search result in HERE's search UI.
|
|
706
726
|
*/
|
|
707
727
|
icon?: string;
|
|
708
728
|
/**
|
|
@@ -710,11 +730,11 @@ type SearchResult = {
|
|
|
710
730
|
*/
|
|
711
731
|
key: string;
|
|
712
732
|
/**
|
|
713
|
-
* Secondary text that will be displayed with the search result in
|
|
733
|
+
* Secondary text that will be displayed with the search result in HERE's search UI.
|
|
714
734
|
*/
|
|
715
735
|
label?: string;
|
|
716
736
|
/**
|
|
717
|
-
* Primary text that will be displayed with the search result in
|
|
737
|
+
* Primary text that will be displayed with the search result in HERE's search UI.
|
|
718
738
|
*/
|
|
719
739
|
title: string;
|
|
720
740
|
};
|
|
@@ -723,7 +743,7 @@ type SearchResult = {
|
|
|
723
743
|
*/
|
|
724
744
|
type SearchResultActionResponse = {
|
|
725
745
|
/**
|
|
726
|
-
* URL that
|
|
746
|
+
* URL that HERE should navigate to.
|
|
727
747
|
*/
|
|
728
748
|
url: string;
|
|
729
749
|
} | undefined;
|
|
@@ -768,13 +788,13 @@ type AgentRegistrationConfig = {
|
|
|
768
788
|
*/
|
|
769
789
|
search?: {
|
|
770
790
|
/**
|
|
771
|
-
* This listener is called when the Agent receives an action from
|
|
791
|
+
* 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.
|
|
772
792
|
*
|
|
773
|
-
* The listener returns a response back to
|
|
793
|
+
* The listener returns a response back to HERE that includes a URL to navigate to.
|
|
774
794
|
*/
|
|
775
795
|
onAction: OnSearchActionListener;
|
|
776
796
|
/**
|
|
777
|
-
* This listener is called when the Agent receives a query from
|
|
797
|
+
* This listener is called when the Agent receives a query from HERE's search UI and returns relevant search results.
|
|
778
798
|
*
|
|
779
799
|
* Note: When the Agent is not ready this listener will not be called.
|
|
780
800
|
*/
|
|
@@ -795,7 +815,7 @@ type AgentSearchFilter = {
|
|
|
795
815
|
type InteropColorChannel = 'blue' | 'indigo' | 'pink' | 'teal' | 'green' | 'orange' | 'red' | 'yellow' | 'gray' | 'none';
|
|
796
816
|
|
|
797
817
|
/**
|
|
798
|
-
* Retrieves the Agent
|
|
818
|
+
* Retrieves the Agent's configuration data, as has been configured in the HERE Admin Console.
|
|
799
819
|
*
|
|
800
820
|
* @returns A promise that resolves with an object containing properties that match the Agent’s configuration.
|
|
801
821
|
*
|
|
@@ -870,6 +890,10 @@ declare const getConfiguration: <T extends Record<string, unknown>>() => Promise
|
|
|
870
890
|
* name: "view-owner",
|
|
871
891
|
* description: `Go to ${ownerName} in My Web App`,
|
|
872
892
|
* title: "View Owner",
|
|
893
|
+
* icon: {
|
|
894
|
+
* dark: "data:image/svg+xml,...",
|
|
895
|
+
* light: "data:image/svg+xml,...",
|
|
896
|
+
* },
|
|
873
897
|
* },
|
|
874
898
|
* ],
|
|
875
899
|
* data: {
|
|
@@ -910,10 +934,11 @@ type index_InteropColorChannel = InteropColorChannel;
|
|
|
910
934
|
type index_OnSearchActionListener = OnSearchActionListener;
|
|
911
935
|
type index_OnSearchRequestListener = OnSearchRequestListener;
|
|
912
936
|
type index_SearchListenerRequest = SearchListenerRequest;
|
|
937
|
+
type index_SearchResult = SearchResult;
|
|
913
938
|
declare const index_getConfiguration: typeof getConfiguration;
|
|
914
939
|
declare const index_register: typeof register;
|
|
915
940
|
declare namespace index {
|
|
916
|
-
export { type index_Agent as Agent, type index_AgentFeatures as AgentFeatures, type index_AgentRegistrationConfig as AgentRegistrationConfig, type index_AgentSearchFilter as AgentSearchFilter, type index_InteropColorChannel as InteropColorChannel, type index_OnSearchActionListener as OnSearchActionListener, type index_OnSearchRequestListener as OnSearchRequestListener, type index_SearchListenerRequest as SearchListenerRequest, index_getConfiguration as getConfiguration, index_register as register };
|
|
941
|
+
export { type index_Agent as Agent, type index_AgentFeatures as AgentFeatures, type index_AgentRegistrationConfig as AgentRegistrationConfig, type index_AgentSearchFilter as AgentSearchFilter, type index_InteropColorChannel as InteropColorChannel, type index_OnSearchActionListener as OnSearchActionListener, type index_OnSearchRequestListener as OnSearchRequestListener, type index_SearchListenerRequest as SearchListenerRequest, type index_SearchResult as SearchResult, index_getConfiguration as getConfiguration, index_register as register };
|
|
917
942
|
}
|
|
918
943
|
|
|
919
944
|
declare global {
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
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};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
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};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfin/cloud-api",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.e6a1a71",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"exports": {
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"module": "./dist/index.js",
|
|
15
15
|
"scripts": {
|
|
16
16
|
"build": "tsup --config ./tsup.config.ts",
|
|
17
|
-
"dev": "tsup --
|
|
17
|
+
"build:dev": "TSUP_DEV=true tsup --config ./tsup.config.ts",
|
|
18
|
+
"build:docker": "NODE_ENV=development npm run build:dev",
|
|
19
|
+
"dev": "TSUP_DEV=true tsup --watch --config ./tsup.config.ts",
|
|
18
20
|
"typecheck": "tsc --noEmit",
|
|
19
21
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
20
22
|
"lint": "eslint . --max-warnings 0",
|
|
@@ -25,10 +27,10 @@
|
|
|
25
27
|
"dist"
|
|
26
28
|
],
|
|
27
29
|
"devDependencies": {
|
|
28
|
-
"@openfin/core": "
|
|
30
|
+
"@openfin/core": "44.101.1",
|
|
29
31
|
"@openfin/search-api": "^2.0.1",
|
|
30
32
|
"@openfin/typedoc-theme": "^2.0.2",
|
|
31
|
-
"@openfin/workspace": "
|
|
33
|
+
"@openfin/workspace": "24.1.3",
|
|
32
34
|
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
33
35
|
"@typescript-eslint/parser": "^8.32.0",
|
|
34
36
|
"eslint": "^8.57.1",
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"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"]}
|