-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-devops-extension-sdk+2.0.11.patch
1545 lines (1545 loc) · 90.3 KB
/
azure-devops-extension-sdk+2.0.11.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff --git a/node_modules/azure-devops-extension-sdk/SDK.d.ts b/node_modules/azure-devops-extension-sdk/SDK.d.ts
index 32c096e..556dc50 100644
--- a/node_modules/azure-devops-extension-sdk/SDK.d.ts
+++ b/node_modules/azure-devops-extension-sdk/SDK.d.ts
@@ -81,6 +81,19 @@ export interface IHostContext {
*/
type: HostType;
}
+/**
+ * Information about the current DevOps teamz
+ */
+export interface ITeamContext {
+ /**
+ * Unique GUID for this team
+ */
+ id: string;
+ /**
+ * Name of team
+ */
+ name: string;
+}
/**
* Identifier for the current extension
*/
@@ -140,6 +153,10 @@ export declare function getUser(): IUserContext;
*/
export declare function getHost(): IHostContext;
/**
+* Gets information about the team that the page is targeting
+*/
+export declare function getTeam(): ITeamContext;
+/**
* Get the context about the extension that owns the content that is being hosted
*/
export declare function getExtensionContext(): IExtensionContext;
diff --git a/node_modules/azure-devops-extension-sdk/SDK.js b/node_modules/azure-devops-extension-sdk/SDK.js
index b2b7516..92cb863 100644
--- a/node_modules/azure-devops-extension-sdk/SDK.js
+++ b/node_modules/azure-devops-extension-sdk/SDK.js
@@ -1,302 +1,235 @@
-var __assign = (this && this.__assign) || Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
-};
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
-};
-define(["require", "exports", "./XDM"], function (require, exports, XDM_1) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- /**
- * Web SDK version number. Can be specified in an extension's set of demands like: vss-sdk-version/3.0
- */
- exports.sdkVersion = 3.0;
- var global = window;
- if (global._AzureDevOpsSDKVersion) {
- console.error("The AzureDevOps SDK is already loaded. Only one version of this module can be loaded in a given document.");
- }
- global._AzureDevOpsSDKVersion = exports.sdkVersion;
- /**
- * DevOps host level
+import { channelManager } from "./XDM";
+/**
+ * Web SDK version number. Can be specified in an extension's set of demands like: vss-sdk-version/3.0
+ */
+export const sdkVersion = 3.0;
+const global = window;
+if (global._AzureDevOpsSDKVersion) {
+ console.error("The AzureDevOps SDK is already loaded. Only one version of this module can be loaded in a given document.");
+}
+global._AzureDevOpsSDKVersion = sdkVersion;
+/**
+ * DevOps host level
+ */
+export var HostType;
+(function (HostType) {
+ /**
+ * The Deployment host
*/
- var HostType;
- (function (HostType) {
- /**
- * The Deployment host
- */
- HostType[HostType["Deployment"] = 1] = "Deployment";
- /**
- * The Enterprise host
- */
- HostType[HostType["Enterprise"] = 2] = "Enterprise";
- /**
- * The organization host
- */
- HostType[HostType["Organization"] = 4] = "Organization";
- })(HostType = exports.HostType || (exports.HostType = {}));
- var hostControlId = "DevOps.HostControl";
- var serviceManagerId = "DevOps.ServiceManager";
- var parentChannel = XDM_1.channelManager.addChannel(window.parent);
- var extensionContext;
- var initialConfiguration;
- var initialContributionId;
- var userContext;
- var hostContext;
- var themeElement;
- var resolveReady;
- var readyPromise = new Promise(function (resolve) {
- resolveReady = resolve;
- });
+ HostType[HostType["Deployment"] = 1] = "Deployment";
/**
- * Register a method so that the host frame can invoke events
+ * The Enterprise host
*/
- function dispatchEvent(eventName, params) {
- var global = window;
- var evt;
- if (typeof global.CustomEvent === "function") {
- evt = new global.CustomEvent(eventName, params);
- }
- else {
- params = params || { bubbles: false, cancelable: false };
- evt = document.createEvent('CustomEvent');
- evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
- }
- window.dispatchEvent(evt);
- }
- parentChannel.getObjectRegistry().register("DevOps.SdkClient", {
- dispatchEvent: dispatchEvent
- });
+ HostType[HostType["Enterprise"] = 2] = "Enterprise";
/**
- * Initiates the handshake with the host window.
- *
- * @param options - Initialization options for the extension.
+ * The organization host
*/
- function init(options) {
- return new Promise(function (resolve) {
- var initOptions = __assign({}, options, { sdkVersion: exports.sdkVersion });
- parentChannel.invokeRemoteMethod("initialHandshake", hostControlId, [initOptions]).then(function (handshakeData) {
- initialConfiguration = handshakeData.initialConfig || {};
- initialContributionId = handshakeData.contributionId;
- var context = handshakeData.context;
- extensionContext = context.extension;
- userContext = context.user;
- hostContext = context.host;
- if (handshakeData.themeData) {
- applyTheme(handshakeData.themeData);
- window.addEventListener("themeChanged", function (ev) {
- applyTheme(ev.detail.data);
- });
- }
- resolveReady();
- resolve();
- });
- });
- }
- exports.init = init;
- /**
- * Register a callback that gets called once the initial setup/handshake has completed.
- * If the initial setup is already completed, the callback is invoked at the end of the current call stack.
- */
- function ready() {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, readyPromise];
- });
- });
- }
- exports.ready = ready;
- /**
- * Notifies the host that the extension successfully loaded (stop showing the loading indicator)
- */
- function notifyLoadSucceeded() {
- return parentChannel.invokeRemoteMethod("notifyLoadSucceeded", hostControlId);
- }
- exports.notifyLoadSucceeded = notifyLoadSucceeded;
- /**
- * Notifies the host that the extension failed to load
- */
- function notifyLoadFailed(e) {
- return parentChannel.invokeRemoteMethod("notifyLoadFailed", hostControlId, [e]);
- }
- exports.notifyLoadFailed = notifyLoadFailed;
- function getWaitForReadyError(method) {
- return "Attempted to call " + method + "() before init() was complete. Wait for init to complete or place within a ready() callback.";
- }
- /**
- * Get the configuration data passed in the initial handshake from the parent frame
- */
- function getConfiguration() {
- if (!initialConfiguration) {
- throw new Error(getWaitForReadyError("getConfiguration"));
- }
- return initialConfiguration;
- }
- exports.getConfiguration = getConfiguration;
- /**
- * Gets the information about the contribution that first caused this extension to load.
- */
- function getContributionId() {
- if (!initialContributionId) {
- throw new Error(getWaitForReadyError("getContributionId"));
- }
- return initialContributionId;
- }
- exports.getContributionId = getContributionId;
- /**
- * Gets information about the current user
- */
- function getUser() {
- if (!userContext) {
- throw new Error(getWaitForReadyError("getUser"));
- }
- return userContext;
- }
- exports.getUser = getUser;
- /**
- * Gets information about the host (i.e. an Azure DevOps organization) that the page is targeting
- */
- function getHost() {
- if (!hostContext) {
- throw new Error(getWaitForReadyError("getHost"));
- }
- return hostContext;
- }
- exports.getHost = getHost;
- /**
- * Get the context about the extension that owns the content that is being hosted
- */
- function getExtensionContext() {
- if (!extensionContext) {
- throw new Error(getWaitForReadyError("getExtensionContext"));
- }
- return extensionContext;
- }
- exports.getExtensionContext = getExtensionContext;
- /**
- * Get the contribution with the given contribution id. The returned contribution has a method to get a registered object within that contribution.
- *
- * @param contributionId - Id of the contribution to get
- */
- function getService(contributionId) {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, ready().then(function () {
- return parentChannel.invokeRemoteMethod("getService", serviceManagerId, [contributionId]);
- })];
- });
- });
- }
- exports.getService = getService;
- /**
- * Register an object (instance or factory method) that this extension exposes to the host frame.
- *
- * @param instanceId - unique id of the registered object
- * @param instance - Either: (1) an object instance, or (2) a function that takes optional context data and returns an object instance.
- */
- function register(instanceId, instance) {
- parentChannel.getObjectRegistry().register(instanceId, instance);
- }
- exports.register = register;
- /**
- * Removes an object that this extension exposed to the host frame.
- *
- * @param instanceId - unique id of the registered object
- */
- function unregister(instanceId) {
- parentChannel.getObjectRegistry().unregister(instanceId);
- }
- exports.unregister = unregister;
- /**
- * Fetch an access token which will allow calls to be made to other DevOps services
- */
- function getAccessToken() {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, parentChannel.invokeRemoteMethod("getAccessToken", hostControlId).then(function (tokenObj) { return tokenObj.token; })];
- });
- });
- }
- exports.getAccessToken = getAccessToken;
- /**
- * Fetch an token which can be used to identify the current user
- */
- function getAppToken() {
- return __awaiter(this, void 0, void 0, function () {
- return __generator(this, function (_a) {
- return [2 /*return*/, parentChannel.invokeRemoteMethod("getAppToken", hostControlId).then(function (tokenObj) { return tokenObj.token; })];
- });
- });
- }
- exports.getAppToken = getAppToken;
- /**
- * Requests the parent window to resize the container for this extension based on the current extension size.
- *
- * @param width - Optional width, defaults to scrollWidth
- * @param height - Optional height, defaults to scrollHeight
- */
- function resize(width, height) {
- var body = document.body;
- if (body) {
- var newWidth = typeof width === "number" ? width : (body ? body.scrollWidth : undefined);
- var newHeight = typeof height === "number" ? height : (body ? body.scrollHeight : undefined);
- parentChannel.invokeRemoteMethod("resize", hostControlId, [newWidth, newHeight]);
- }
- }
- exports.resize = resize;
- /**
- * Applies theme variables to the current document
- */
- function applyTheme(themeData) {
- if (!themeElement) {
- themeElement = document.createElement("style");
- themeElement.type = "text/css";
- document.head.appendChild(themeElement);
- }
- var cssVariables = [];
- if (themeData) {
- for (var varName in themeData) {
- cssVariables.push("--" + varName + ": " + themeData[varName]);
+ HostType[HostType["Organization"] = 4] = "Organization";
+})(HostType || (HostType = {}));
+const hostControlId = "DevOps.HostControl";
+const serviceManagerId = "DevOps.ServiceManager";
+const parentChannel = channelManager.addChannel(window.parent);
+let extensionContext;
+let initialConfiguration;
+let initialContributionId;
+let userContext;
+let hostContext;
+let teamContext;
+let themeElement;
+let resolveReady;
+const readyPromise = new Promise((resolve) => {
+ resolveReady = resolve;
+});
+/**
+ * Register a method so that the host frame can invoke events
+ */
+function dispatchEvent(eventName, params) {
+ const global = window;
+ let evt;
+ if (typeof global.CustomEvent === "function") {
+ evt = new global.CustomEvent(eventName, params);
+ }
+ else {
+ params = params || { bubbles: false, cancelable: false };
+ evt = document.createEvent('CustomEvent');
+ evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
+ }
+ window.dispatchEvent(evt);
+}
+parentChannel.getObjectRegistry().register("DevOps.SdkClient", {
+ dispatchEvent: dispatchEvent
+});
+/**
+ * Initiates the handshake with the host window.
+ *
+ * @param options - Initialization options for the extension.
+ */
+export function init(options) {
+ return new Promise((resolve) => {
+ const initOptions = { ...options, sdkVersion };
+ parentChannel.invokeRemoteMethod("initialHandshake", hostControlId, [initOptions]).then((handshakeData) => {
+ initialConfiguration = handshakeData.initialConfig || {};
+ initialContributionId = handshakeData.contributionId;
+ const context = handshakeData.context;
+ extensionContext = context.extension;
+ userContext = context.user;
+ hostContext = context.host;
+ teamContext = handshakeData.pageContext && handshakeData.pageContext && handshakeData.pageContext.webContext && handshakeData.pageContext.webContext.team;
+ if (handshakeData.themeData) {
+ applyTheme(handshakeData.themeData);
+ window.addEventListener("themeChanged", (ev) => {
+ applyTheme(ev.detail.data);
+ });
}
+ resolveReady();
+ resolve();
+ });
+ });
+}
+/**
+* Register a callback that gets called once the initial setup/handshake has completed.
+* If the initial setup is already completed, the callback is invoked at the end of the current call stack.
+*/
+export async function ready() {
+ return readyPromise;
+}
+/**
+* Notifies the host that the extension successfully loaded (stop showing the loading indicator)
+*/
+export function notifyLoadSucceeded() {
+ return parentChannel.invokeRemoteMethod("notifyLoadSucceeded", hostControlId);
+}
+/**
+* Notifies the host that the extension failed to load
+*/
+export function notifyLoadFailed(e) {
+ return parentChannel.invokeRemoteMethod("notifyLoadFailed", hostControlId, [e]);
+}
+function getWaitForReadyError(method) {
+ return `Attempted to call ${method}() before init() was complete. Wait for init to complete or place within a ready() callback.`;
+}
+/**
+* Get the configuration data passed in the initial handshake from the parent frame
+*/
+export function getConfiguration() {
+ if (!initialConfiguration) {
+ throw new Error(getWaitForReadyError("getConfiguration"));
+ }
+ return initialConfiguration;
+}
+/**
+* Gets the information about the contribution that first caused this extension to load.
+*/
+export function getContributionId() {
+ if (!initialContributionId) {
+ throw new Error(getWaitForReadyError("getContributionId"));
+ }
+ return initialContributionId;
+}
+/**
+* Gets information about the current user
+*/
+export function getUser() {
+ if (!userContext) {
+ throw new Error(getWaitForReadyError("getUser"));
+ }
+ return userContext;
+}
+/**
+* Gets information about the host (i.e. an Azure DevOps organization) that the page is targeting
+*/
+export function getHost() {
+ if (!hostContext) {
+ throw new Error(getWaitForReadyError("getHost"));
+ }
+ return hostContext;
+}
+/**
+* Gets information about the team that the page is targeting
+*/
+export function getTeam() {
+ if (!teamContext) {
+ throw new Error(getWaitForReadyError("getTeam"));
+ }
+ return teamContext;
+}
+/**
+* Get the context about the extension that owns the content that is being hosted
+*/
+export function getExtensionContext() {
+ if (!extensionContext) {
+ throw new Error(getWaitForReadyError("getExtensionContext"));
+ }
+ return extensionContext;
+}
+/**
+* Get the contribution with the given contribution id. The returned contribution has a method to get a registered object within that contribution.
+*
+* @param contributionId - Id of the contribution to get
+*/
+export async function getService(contributionId) {
+ return ready().then(() => {
+ return parentChannel.invokeRemoteMethod("getService", serviceManagerId, [contributionId]);
+ });
+}
+/**
+* Register an object (instance or factory method) that this extension exposes to the host frame.
+*
+* @param instanceId - unique id of the registered object
+* @param instance - Either: (1) an object instance, or (2) a function that takes optional context data and returns an object instance.
+*/
+export function register(instanceId, instance) {
+ parentChannel.getObjectRegistry().register(instanceId, instance);
+}
+/**
+* Removes an object that this extension exposed to the host frame.
+*
+* @param instanceId - unique id of the registered object
+*/
+export function unregister(instanceId) {
+ parentChannel.getObjectRegistry().unregister(instanceId);
+}
+/**
+* Fetch an access token which will allow calls to be made to other DevOps services
+*/
+export async function getAccessToken() {
+ return parentChannel.invokeRemoteMethod("getAccessToken", hostControlId).then((tokenObj) => { return tokenObj.token; });
+}
+/**
+* Fetch an token which can be used to identify the current user
+*/
+export async function getAppToken() {
+ return parentChannel.invokeRemoteMethod("getAppToken", hostControlId).then((tokenObj) => { return tokenObj.token; });
+}
+/**
+* Requests the parent window to resize the container for this extension based on the current extension size.
+*
+* @param width - Optional width, defaults to scrollWidth
+* @param height - Optional height, defaults to scrollHeight
+*/
+export function resize(width, height) {
+ const body = document.body;
+ if (body) {
+ const newWidth = typeof width === "number" ? width : (body ? body.scrollWidth : undefined);
+ const newHeight = typeof height === "number" ? height : (body ? body.scrollHeight : undefined);
+ parentChannel.invokeRemoteMethod("resize", hostControlId, [newWidth, newHeight]);
+ }
+}
+/**
+ * Applies theme variables to the current document
+ */
+export function applyTheme(themeData) {
+ if (!themeElement) {
+ themeElement = document.createElement("style");
+ themeElement.type = "text/css";
+ document.head.appendChild(themeElement);
+ }
+ const cssVariables = [];
+ if (themeData) {
+ for (const varName in themeData) {
+ cssVariables.push("--" + varName + ": " + themeData[varName]);
}
- themeElement.innerText = ":root { " + cssVariables.join("; ") + " } body { color: var(--text-primary-color) }";
- dispatchEvent("themeApplied", { detail: themeData });
}
- exports.applyTheme = applyTheme;
-});
+ themeElement.innerText = ":root { " + cssVariables.join("; ") + " } body { color: var(--text-primary-color) }";
+ dispatchEvent("themeApplied", { detail: themeData });
+}
diff --git a/node_modules/azure-devops-extension-sdk/SDK.min.js b/node_modules/azure-devops-extension-sdk/SDK.min.js
index 224844d..6938ea0 100644
--- a/node_modules/azure-devops-extension-sdk/SDK.min.js
+++ b/node_modules/azure-devops-extension-sdk/SDK.min.js
@@ -1 +1 @@
-var __assign=this&&this.__assign||Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++){t=arguments[n];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},__awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function u(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){e.done?o(e.value):new n(function(t){t(e.value)}).then(a,u)}c((r=r.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){function n(n){return function(a){return function(n){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,o&&(i=2&n[0]?o.return:n[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,n[1])).done)return i;switch(o=0,i&&(n=[2&n[0],i.value]),n[0]){case 0:case 1:i=n;break;case 4:return u.label++,{value:n[1],done:!1};case 5:u.label++,o=n[1],n=[0];continue;case 7:n=u.ops.pop(),u.trys.pop();continue;default:if(i=u.trys,!(i=i.length>0&&i[i.length-1])&&(6===n[0]||2===n[0])){u=0;continue}if(3===n[0]&&(!i||n[1]>i[0]&&n[1]<i[3])){u.label=n[1];break}if(6===n[0]&&u.label<i[1]){u.label=i[1],i=n;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(n);break}i[2]&&u.ops.pop(),u.trys.pop();continue}n=t.call(e,u)}catch(e){n=[6,e],o=0}finally{r=i=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}var r,o,i,a,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:n(0),throw:n(1),return:n(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a};define(["require","exports","./XDM"],function(e,t,n){"use strict";function r(e,t){var n,r=window;"function"==typeof r.CustomEvent?n=new r.CustomEvent(e,t):(t=t||{bubbles:!1,cancelable:!1},(n=document.createEvent("CustomEvent")).initCustomEvent(e,t.bubbles,t.cancelable,t.detail)),window.dispatchEvent(n)}function o(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,y]})})}function i(e){return"Attempted to call "+e+"() before init() was complete. Wait for init to complete or place within a ready() callback."}function a(e){h||((h=document.createElement("style")).type="text/css",document.head.appendChild(h));var t=[];if(e)for(var n in e)t.push("--"+n+": "+e[n]);h.innerText=":root { "+t.join("; ")+" } body { color: var(--text-primary-color) }",r("themeApplied",{detail:e})}Object.defineProperty(t,"__esModule",{value:!0}),t.sdkVersion=3;var u=window;u._AzureDevOpsSDKVersion&&console.error("The AzureDevOps SDK is already loaded. Only one version of this module can be loaded in a given document."),u._AzureDevOpsSDKVersion=t.sdkVersion;!function(e){e[e.Deployment=1]="Deployment",e[e.Enterprise=2]="Enterprise",e[e.Organization=4]="Organization"}(t.HostType||(t.HostType={}));var c,s,f,l,d,h,p,v="DevOps.HostControl",g="DevOps.ServiceManager",w=n.channelManager.addChannel(window.parent),y=new Promise(function(e){p=e});w.getObjectRegistry().register("DevOps.SdkClient",{dispatchEvent:r}),t.init=function(e){return new Promise(function(n){var r=__assign({},e,{sdkVersion:t.sdkVersion});w.invokeRemoteMethod("initialHandshake",v,[r]).then(function(e){s=e.initialConfig||{},f=e.contributionId;var t=e.context;c=t.extension,l=t.user,d=t.host,e.themeData&&(a(e.themeData),window.addEventListener("themeChanged",function(e){a(e.detail.data)})),p(),n()})})},t.ready=o,t.notifyLoadSucceeded=function(){return w.invokeRemoteMethod("notifyLoadSucceeded",v)},t.notifyLoadFailed=function(e){return w.invokeRemoteMethod("notifyLoadFailed",v,[e])},t.getConfiguration=function(){if(!s)throw new Error(i("getConfiguration"));return s},t.getContributionId=function(){if(!f)throw new Error(i("getContributionId"));return f},t.getUser=function(){if(!l)throw new Error(i("getUser"));return l},t.getHost=function(){if(!d)throw new Error(i("getHost"));return d},t.getExtensionContext=function(){if(!c)throw new Error(i("getExtensionContext"));return c},t.getService=function(e){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2,o().then(function(){return w.invokeRemoteMethod("getService",g,[e])})]})})},t.register=function(e,t){w.getObjectRegistry().register(e,t)},t.unregister=function(e){w.getObjectRegistry().unregister(e)},t.getAccessToken=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,w.invokeRemoteMethod("getAccessToken",v).then(function(e){return e.token})]})})},t.getAppToken=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return[2,w.invokeRemoteMethod("getAppToken",v).then(function(e){return e.token})]})})},t.resize=function(e,t){var n=document.body;if(n){var r="number"==typeof e?e:n?n.scrollWidth:void 0,o="number"==typeof t?t:n?n.scrollHeight:void 0;w.invokeRemoteMethod("resize",v,[r,o])}},t.applyTheme=a});
\ No newline at end of file
+function dispatchEvent(e, t) { const n = window; let o; "function" == typeof n.CustomEvent ? o = new n.CustomEvent(e, t) : (t = t || { bubbles: !1, cancelable: !1 }, (o = document.createEvent("CustomEvent")).initCustomEvent(e, t.bubbles, t.cancelable, t.detail)), window.dispatchEvent(o) } function getWaitForReadyError(e) { return `Attempted to call ${e}() before init() was complete. Wait for init to complete or place within a ready() callback.` } import { channelManager } from "./XDM"; export const sdkVersion = 3; const global = window; global._AzureDevOpsSDKVersion && console.error("The AzureDevOps SDK is already loaded. Only one version of this module can be loaded in a given document."), global._AzureDevOpsSDKVersion = sdkVersion; export var HostType; !function (e) { e[e.Deployment = 1] = "Deployment", e[e.Enterprise = 2] = "Enterprise", e[e.Organization = 4] = "Organization" }(HostType || (HostType = {})); const hostControlId = "DevOps.HostControl", serviceManagerId = "DevOps.ServiceManager", parentChannel = channelManager.addChannel(window.parent); let extensionContext, initialConfiguration, initialContributionId, userContext, hostContext, teamContext, themeElement, resolveReady; const readyPromise = new Promise(e => { resolveReady = e }); parentChannel.getObjectRegistry().register("DevOps.SdkClient", { dispatchEvent: dispatchEvent }); export function init(e) { return new Promise(t => { const n = { ...e, sdkVersion: sdkVersion }; parentChannel.invokeRemoteMethod("initialHandshake", hostControlId, [n]).then(e => { initialConfiguration = e.initialConfig || {}, initialContributionId = e.contributionId; const n = e.context; extensionContext = n.extension, userContext = n.user, hostContext = n.host, teamContext = e.pageContext && e.pageContext && e.pageContext.webContext && e.pageContext.webContext.team, e.themeData && (applyTheme(e.themeData), window.addEventListener("themeChanged", e => { applyTheme(e.detail.data) })), resolveReady(), t() }) }) }; export async function ready() { return readyPromise }; export function notifyLoadSucceeded() { return parentChannel.invokeRemoteMethod("notifyLoadSucceeded", hostControlId) }; export function notifyLoadFailed(e) { return parentChannel.invokeRemoteMethod("notifyLoadFailed", hostControlId, [e]) }; export function getConfiguration() { if (!initialConfiguration) throw new Error(getWaitForReadyError("getConfiguration")); return initialConfiguration }; export function getContributionId() { if (!initialContributionId) throw new Error(getWaitForReadyError("getContributionId")); return initialContributionId }; export function getUser() { if (!userContext) throw new Error(getWaitForReadyError("getUser")); return userContext }; export function getHost() { if (!hostContext) throw new Error(getWaitForReadyError("getHost")); return hostContext }; export function getTeam() { if (!teamContext) throw new Error(getWaitForReadyError("getTeam")); return teamContext }; export function getExtensionContext() { if (!extensionContext) throw new Error(getWaitForReadyError("getExtensionContext")); return extensionContext }; export async function getService(e) { return ready().then(() => parentChannel.invokeRemoteMethod("getService", serviceManagerId, [e])) }; export function register(e, t) { parentChannel.getObjectRegistry().register(e, t) }; export function unregister(e) { parentChannel.getObjectRegistry().unregister(e) }; export async function getAccessToken() { return parentChannel.invokeRemoteMethod("getAccessToken", hostControlId).then(e => e.token) }; export async function getAppToken() { return parentChannel.invokeRemoteMethod("getAppToken", hostControlId).then(e => e.token) }; export function resize(e, t) { const n = document.body; if (n) { const o = "number" == typeof e ? e : n ? n.scrollWidth : void 0, r = "number" == typeof t ? t : n ? n.scrollHeight : void 0; parentChannel.invokeRemoteMethod("resize", hostControlId, [o, r]) } }; export function applyTheme(e) { themeElement || ((themeElement = document.createElement("style")).type = "text/css", document.head.appendChild(themeElement)); const t = []; if (e) for (const n in e) t.push("--" + n + ": " + e[n]); themeElement.innerText = ":root { " + t.join("; ") + " } body { color: var(--text-primary-color) }", dispatchEvent("themeApplied", { detail: e }) };
diff --git a/node_modules/azure-devops-extension-sdk/XDM.js b/node_modules/azure-devops-extension-sdk/XDM.js
index 7f586fd..0a01a78 100644
--- a/node_modules/azure-devops-extension-sdk/XDM.js
+++ b/node_modules/azure-devops-extension-sdk/XDM.js
@@ -1,537 +1,480 @@
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
+import "es6-promise/auto";
+import "es6-object-assign/auto";
+const smallestRandom = parseInt("10000000000", 36);
+const maxSafeInteger = Number.MAX_SAFE_INTEGER || 9007199254740991;
+/**
+ * Create a new random 22-character fingerprint.
+ * @return string fingerprint
+ */
+function newFingerprint() {
+ // smallestRandom ensures we will get a 11-character result from the base-36 conversion.
+ return Math.floor((Math.random() * (maxSafeInteger - smallestRandom)) + smallestRandom).toString(36) +
+ Math.floor((Math.random() * (maxSafeInteger - smallestRandom)) + smallestRandom).toString(36);
+}
+/**
+ * Gets all own and inherited property names of the given object, excluding
+ * those that are inherited from Object's prototype and "constructor".
+ * @param obj
+ */
+function getAllPropertyNames(obj) {
+ const properties = {};
+ while (obj && obj !== Object.prototype) {
+ const ownPropertyNames = Object.getOwnPropertyNames(obj);
+ for (const name of ownPropertyNames) {
+ if (name !== "constructor") {
+ properties[name] = true;
}
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
+ }
+ obj = Object.getPrototypeOf(obj);
+ }
+ return properties;
+}
+/**
+ * Catalog of objects exposed for XDM
+ */
+export class XDMObjectRegistry {
+ constructor() {
+ this.objects = {};
}
-};
-define(["require", "exports", "es6-promise/auto", "es6-object-assign/auto"], function (require, exports) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var smallestRandom = parseInt("10000000000", 36);
- var maxSafeInteger = Number.MAX_SAFE_INTEGER || 9007199254740991;
/**
- * Create a new random 22-character fingerprint.
- * @return string fingerprint
- */
- function newFingerprint() {
- // smallestRandom ensures we will get a 11-character result from the base-36 conversion.
- return Math.floor((Math.random() * (maxSafeInteger - smallestRandom)) + smallestRandom).toString(36) +
- Math.floor((Math.random() * (maxSafeInteger - smallestRandom)) + smallestRandom).toString(36);
+ * Register an object (instance or factory method) exposed by this frame to callers in a remote frame
+ *
+ * @param instanceId - unique id of the registered object
+ * @param instance - Either: (1) an object instance, or (2) a function that takes optional context data and returns an object instance.
+ */
+ register(instanceId, instance) {
+ this.objects[instanceId] = instance;
}
/**
- * Gets all own and inherited property names of the given object, excluding
- * those that are inherited from Object's prototype and "constructor".
- * @param obj
- */
- function getAllPropertyNames(obj) {
- var properties = {};
- while (obj && obj !== Object.prototype) {
- var ownPropertyNames = Object.getOwnPropertyNames(obj);
- for (var _i = 0, ownPropertyNames_1 = ownPropertyNames; _i < ownPropertyNames_1.length; _i++) {
- var name_1 = ownPropertyNames_1[_i];
- if (name_1 !== "constructor") {
- properties[name_1] = true;
- }
- }
- obj = Object.getPrototypeOf(obj);
- }
- return properties;
+ * Unregister an object (instance or factory method) that was previously registered by this frame
+ *
+ * @param instanceId - unique id of the registered object
+ */
+ unregister(instanceId) {
+ delete this.objects[instanceId];
}
/**
- * Catalog of objects exposed for XDM
- */
- var XDMObjectRegistry = /** @class */ (function () {
- function XDMObjectRegistry() {
- this.objects = {};
+ * Get an instance of an object registered with the given id
+ *
+ * @param instanceId - unique id of the registered object
+ * @param contextData - Optional context data to pass to a registered object's factory method
+ */
+ getInstance(instanceId, contextData) {
+ var instance = this.objects[instanceId];
+ if (!instance) {
+ return undefined;
}
- /**
- * Register an object (instance or factory method) exposed by this frame to callers in a remote frame
- *
- * @param instanceId - unique id of the registered object
- * @param instance - Either: (1) an object instance, or (2) a function that takes optional context data and returns an object instance.
- */
- XDMObjectRegistry.prototype.register = function (instanceId, instance) {
- this.objects[instanceId] = instance;
- };
- /**
- * Unregister an object (instance or factory method) that was previously registered by this frame
- *
- * @param instanceId - unique id of the registered object
- */
- XDMObjectRegistry.prototype.unregister = function (instanceId) {
- delete this.objects[instanceId];
+ if (typeof instance === "function") {
+ return instance(contextData);
+ }
+ else {
+ return instance;
+ }
+ }
+}
+const MAX_XDM_DEPTH = 100;
+let nextChannelId = 1;
+/**
+ * Represents a channel of communication between frames\document
+ * Stays "alive" across multiple funtion\method calls
+ */
+export class XDMChannel {
+ constructor(postToWindow, targetOrigin) {
+ this.promises = {};
+ this.nextMessageId = 1;
+ this.nextProxyId = 1;
+ this.proxyFunctions = {};
+ this.postToWindow = postToWindow;
+ this.targetOrigin = targetOrigin;
+ this.registry = new XDMObjectRegistry();
+ this.channelId = nextChannelId++;
+ if (!this.targetOrigin) {
+ this.handshakeToken = newFingerprint();
+ }
+ }
+ /**
+ * Get the object registry to handle messages from this specific channel.
+ * Upon receiving a message, this channel registry will be used first, then
+ * the global registry will be used if no handler is found here.
+ */
+ getObjectRegistry() {
+ return this.registry;
+ }
+ /**
+ * Invoke a method via RPC. Lookup the registered object on the remote end of the channel and invoke the specified method.
+ *
+ * @param method - Name of the method to invoke
+ * @param instanceId - unique id of the registered object
+ * @param params - Arguments to the method to invoke
+ * @param instanceContextData - Optional context data to pass to a registered object's factory method
+ * @param serializationSettings - Optional serialization settings
+ */
+ async invokeRemoteMethod(methodName, instanceId, params, instanceContextData, serializationSettings) {
+ const message = {
+ id: this.nextMessageId++,
+ methodName: methodName,
+ instanceId: instanceId,
+ instanceContext: instanceContextData,
+ params: this._customSerializeObject(params, serializationSettings),
+ serializationSettings: serializationSettings
};
- /**
- * Get an instance of an object registered with the given id
- *
- * @param instanceId - unique id of the registered object
- * @param contextData - Optional context data to pass to a registered object's factory method
- */
- XDMObjectRegistry.prototype.getInstance = function (instanceId, contextData) {
- var instance = this.objects[instanceId];
- if (!instance) {
- return undefined;
+ if (!this.targetOrigin) {
+ message.handshakeToken = this.handshakeToken;
+ }
+ const promise = new Promise((resolve, reject) => {
+ this.promises[message.id] = { resolve, reject };
+ });
+ this._sendRpcMessage(message);
+ return promise;
+ }
+ /**
+ * Get a proxied object that represents the object registered with the given instance id on the remote side of this channel.
+ *
+ * @param instanceId - unique id of the registered object
+ * @param contextData - Optional context data to pass to a registered object's factory method
+ */
+ getRemoteObjectProxy(instanceId, contextData) {
+ return this.invokeRemoteMethod("", instanceId, undefined, contextData);
+ }
+ invokeMethod(registeredInstance, rpcMessage) {
+ if (!rpcMessage.methodName) {
+ // Null/empty method name indicates to return the registered object itself.
+ this._success(rpcMessage, registeredInstance, rpcMessage.handshakeToken);
+ return;
+ }
+ var method = registeredInstance[rpcMessage.methodName];
+ if (typeof method !== "function") {
+ this.error(rpcMessage, new Error("RPC method not found: " + rpcMessage.methodName));
+ return;
+ }
+ try {
+ // Call specified method. Add nested success and error call backs with closure
+ // so we can post back a response as a result or error as appropriate
+ var methodArgs = [];
+ if (rpcMessage.params) {
+ methodArgs = this._customDeserializeObject(rpcMessage.params, {});
}
- if (typeof instance === "function") {
- return instance(contextData);
+ var result = method.apply(registeredInstance, methodArgs);
+ if (result && result.then && typeof result.then === "function") {
+ result.then((asyncResult) => {
+ this._success(rpcMessage, asyncResult, rpcMessage.handshakeToken);
+ }, (e) => {
+ this.error(rpcMessage, e);
+ });
}
else {
- return instance;
+ this._success(rpcMessage, result, rpcMessage.handshakeToken);
}
- };
- return XDMObjectRegistry;
- }());
- exports.XDMObjectRegistry = XDMObjectRegistry;
- var MAX_XDM_DEPTH = 100;
- var nextChannelId = 1;
+ }
+ catch (exception) {
+ // send back as error if an exception is thrown
+ this.error(rpcMessage, exception);
+ }
+ }
+ getRegisteredObject(instanceId, instanceContext) {
+ if (instanceId === "__proxyFunctions") {
+ // Special case for proxied functions of remote instances
+ return this.proxyFunctions;
+ }
+ // Look in the channel registry first
+ var registeredObject = this.registry.getInstance(instanceId, instanceContext);
+ if (!registeredObject) {
+ // Look in the global registry as a fallback
+ registeredObject = globalObjectRegistry.getInstance(instanceId, instanceContext);
+ }
+ return registeredObject;
+ }
/**
- * Represents a channel of communication between frames\document
- * Stays "alive" across multiple funtion\method calls
- */
- var XDMChannel = /** @class */ (function () {
- function XDMChannel(postToWindow, targetOrigin) {
- this.promises = {};
- this.nextMessageId = 1;
- this.nextProxyId = 1;
- this.proxyFunctions = {};
- this.postToWindow = postToWindow;
- this.targetOrigin = targetOrigin;
- this.registry = new XDMObjectRegistry();
- this.channelId = nextChannelId++;
- if (!this.targetOrigin) {
- this.handshakeToken = newFingerprint();
+ * Handle a received message on this channel. Dispatch to the appropriate object found via object registry
+ *
+ * @param rpcMessage - Message data
+ * @return True if the message was handled by this channel. Otherwise false.
+ */
+ onMessage(rpcMessage) {
+ if (rpcMessage.instanceId) {
+ // Find the object that handles this requestNeed to find implementation
+ // Look in the channel registry first
+ const registeredObject = this.getRegisteredObject(rpcMessage.instanceId, rpcMessage.instanceContext);
+ if (!registeredObject) {
+ // If not found return false to indicate that the message was not handled
+ return false;
}
- }
- /**
- * Get the object registry to handle messages from this specific channel.
- * Upon receiving a message, this channel registry will be used first, then
- * the global registry will be used if no handler is found here.
- */
- XDMChannel.prototype.getObjectRegistry = function () {
- return this.registry;
- };
- /**
- * Invoke a method via RPC. Lookup the registered object on the remote end of the channel and invoke the specified method.
- *
- * @param method - Name of the method to invoke
- * @param instanceId - unique id of the registered object
- * @param params - Arguments to the method to invoke
- * @param instanceContextData - Optional context data to pass to a registered object's factory method
- * @param serializationSettings - Optional serialization settings
- */
- XDMChannel.prototype.invokeRemoteMethod = function (methodName, instanceId, params, instanceContextData, serializationSettings) {
- return __awaiter(this, void 0, void 0, function () {
- var message, promise;
- var _this = this;
- return __generator(this, function (_a) {
- message = {
- id: this.nextMessageId++,
- methodName: methodName,
- instanceId: instanceId,
- instanceContext: instanceContextData,
- params: this._customSerializeObject(params, serializationSettings),
- serializationSettings: serializationSettings
- };
- if (!this.targetOrigin) {
- message.handshakeToken = this.handshakeToken;
- }
- promise = new Promise(function (resolve, reject) {
- _this.promises[message.id] = { resolve: resolve, reject: reject };
- });
- this._sendRpcMessage(message);
- return [2 /*return*/, promise];
+ if (typeof registeredObject["then"] === "function") {
+ registeredObject.then((resolvedInstance) => {
+ this.invokeMethod(resolvedInstance, rpcMessage);
+ }, (e) => {
+ this.error(rpcMessage, e);
});
- });
- };
- /**
- * Get a proxied object that represents the object registered with the given instance id on the remote side of this channel.
- *
- * @param instanceId - unique id of the registered object
- * @param contextData - Optional context data to pass to a registered object's factory method
- */
- XDMChannel.prototype.getRemoteObjectProxy = function (instanceId, contextData) {
- return this.invokeRemoteMethod("", instanceId, undefined, contextData);
- };
- XDMChannel.prototype.invokeMethod = function (registeredInstance, rpcMessage) {
- var _this = this;
- if (!rpcMessage.methodName) {
- // Null/empty method name indicates to return the registered object itself.
- this._success(rpcMessage, registeredInstance, rpcMessage.handshakeToken);
- return;
- }
- var method = registeredInstance[rpcMessage.methodName];
- if (typeof method !== "function") {
- this.error(rpcMessage, new Error("RPC method not found: " + rpcMessage.methodName));
- return;
}
- try {
- // Call specified method. Add nested success and error call backs with closure
- // so we can post back a response as a result or error as appropriate
- var methodArgs = [];
- if (rpcMessage.params) {
- methodArgs = this._customDeserializeObject(rpcMessage.params, {});
- }
- var result = method.apply(registeredInstance, methodArgs);
- if (result && result.then && typeof result.then === "function") {
- result.then(function (asyncResult) {
- _this._success(rpcMessage, asyncResult, rpcMessage.handshakeToken);
- }, function (e) {
- _this.error(rpcMessage, e);
- });
- }
- else {
- this._success(rpcMessage, result, rpcMessage.handshakeToken);
- }
+ else {
+ this.invokeMethod(registeredObject, rpcMessage);
}
- catch (exception) {
- // send back as error if an exception is thrown
- this.error(rpcMessage, exception);
+ }
+ else {
+ const promise = this.promises[rpcMessage.id];
+ if (!promise) {
+ // Message not handled by this channel.
+ return false;
}
- };