UNPKG

70.3 kBTypeScriptView Raw
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
47declare module jsCommon {
48 /**
49 * DOM constants.
50 */
51 module DOMConstants {
52 /**
53 * Integer codes corresponding to individual keys on the keyboard.
54 */
55 const escKeyCode: number;
56 const enterKeyCode: number;
57 const tabKeyCode: number;
58 const upArrowKeyCode: number;
59 const downArrowKeyCode: number;
60 const leftArrowKeyCode: number;
61 const rightArrowKeyCode: number;
62 const homeKeyCode: number;
63 const endKeyCode: number;
64 const backSpaceKeyCode: number;
65 const deleteKeyCode: number;
66 const spaceKeyCode: number;
67 const shiftKeyCode: number;
68 const ctrlKeyCode: number;
69 const altKeyCode: number;
70 const aKeyCode: number;
71 const cKeyCode: number;
72 const sKeyCode: number;
73 const vKeyCode: number;
74 const wKeyCode: number;
75 const xKeyCode: number;
76 const yKeyCode: number;
77 const zKeyCode: number;
78 /**
79 * DOM Elements.
80 */
81 const DocumentBody: string;
82 const Anchor: string;
83 const EditableTextElements: string;
84 const EditableNumericElements: string;
85 /**
86 * DOM Attributes and values.
87 */
88 const disabledAttributeOrValue: string;
89 const readonlyAttributeOrValue: string;
90 const idAttribute: string;
91 const styleAttribute: string;
92 const hrefAttribute: string;
93 const targetAttribute: string;
94 const blankValue: string;
95 const selfValue: string;
96 const classAttribute: string;
97 const titleAttribute: string;
98 const srcAttribute: string;
99 /**
100 * DOM event names.
101 */
102 const contextmenuEventName: string;
103 const blurEventName: string;
104 const keyUpEventName: string;
105 const inputEventName: string;
106 const changeEventName: string;
107 const cutEventName: string;
108 const keyDownEventName: string;
109 const mouseMoveEventName: string;
110 const mouseDownEventName: string;
111 const mouseEnterEventName: string;
112 const mouseLeaveEventName: string;
113 const mouseOverEventName: string;
114 const mouseOutEventName: string;
115 const mouseClickEventName: string;
116 const pasteEventName: string;
117 const scrollEventName: string;
118 const dropEventName: string;
119 const focusEventName: string;
120 const focusInEventName: string;
121 const focusOutEventName: string;
122 const selectEventName: string;
123 const messageEventName: string;
124 const loadEventName: string;
125 const beforeUnload: string;
126 /**
127 * Common DOM event combination names.
128 */
129 const inputAndSelectEventNames: string;
130 }
131}
132
133declare module powerbi {
134 import IStringResourceProvider = jsCommon.IStringResourceProvider;
135 const RS_AccessDeniedDueToRLSGroup: string;
136 const RS_CannotRetrieveModel: string;
137 interface ServiceError {
138 statusCode: number;
139 /**
140 * This error code corresponds with a PowerBIServiceException that happened on the server.
141 */
142 errorCode?: string;
143 /**
144 * Message and stack trace should only be sent in non-production environments.
145 */
146 message?: string;
147 stackTrace?: string;
148 errorDetails?: PowerBIErrorDetail[];
149 parameters?: ErrorParameter[];
150 }
151 interface PowerBIErrorDetail {
152 code: string;
153 detail: PowerBIErrorDetailValue;
154 }
155 interface ErrorParameter {
156 Key: string;
157 Value: string;
158 }
159 interface PowerBIErrorDetailValue {
160 type: PowerBIErrorResourceType;
161 value: string;
162 }
163 enum PowerBIErrorResourceType {
164 ResourceCodeReference = 0,
165 EmbeddedString = 1,
166 }
167 const enum ServiceErrorStatusCode {
168 GeneralError = 0,
169 CsdlFetching = 1,
170 CsdlConvertXmlToConceptualSchema = 2,
171 CsdlCreateClientSchema = 3,
172 ExecuteSemanticQueryError = 4,
173 ExecuteSemanticQueryInvalidStreamFormat = 5,
174 ExecuteSemanticQueryTransformError = 6,
175 }
176 class ServiceErrorToClientError implements IClientError {
177 private m_serviceError;
178 private httpRequestId;
179 private static codeName;
180 code: string;
181 ignorable: boolean;
182 requestId: string;
183 constructor(serviceError: ServiceError);
184 getDetails(resourceProvider: IStringResourceProvider): ErrorDetails;
185 }
186 class PowerBIErrorDetailHelper {
187 private static serverErrorPrefix;
188 static addAdditionalInfo(errorDetails: ErrorDetails, pbiErrorDetails: PowerBIErrorDetail[], localize: IStringResourceProvider): ErrorDetails;
189 static addDebugErrorInfo(errorDetails: ErrorDetails, errorCode: string, message: string, stackTrace: string): ErrorDetails;
190 static GetDetailsFromTransformError(localize: IStringResourceProvider, serviceError: ServiceError): ErrorDetails;
191 static GetDetailsFromServerError(localize: IStringResourceProvider, serviceError: ServiceError): ErrorDetails;
192 }
193}
194
195declare module powerbi {
196 let build: any;
197 let buildDetails: any;
198 let customVisualsUrl: any;
199}
200
201declare module powerbi {
202 const CategoryTypes: {
203 Address: string;
204 City: string;
205 Continent: string;
206 CountryRegion: string;
207 County: string;
208 Longitude: string;
209 Latitude: string;
210 Place: string;
211 PostalCode: string;
212 StateOrProvince: string;
213 };
214 interface IGeoTaggingAnalyzerService {
215 isLongitudeOrLatitude(fieldRefName: string): boolean;
216 isGeographic(fieldRefName: string): boolean;
217 isGeocodable(fieldRefName: string): boolean;
218 getFieldType(fieldName: string): string;
219 isGeoshapable(fieldRefName: string): boolean;
220 }
221 function createGeoTaggingAnalyzerService(getLocalized: (string) => string): IGeoTaggingAnalyzerService;
222 class GeoTaggingAnalyzerService implements IGeoTaggingAnalyzerService {
223 private GeotaggingString_Continent;
224 private GeotaggingString_Continents;
225 private GeotaggingString_Country;
226 private GeotaggingString_Countries;
227 private GeotaggingString_State;
228 private GeotaggingString_States;
229 private GeotaggingString_City;
230 private GeotaggingString_Cities;
231 private GeotaggingString_Town;
232 private GeotaggingString_Towns;
233 private GeotaggingString_Province;
234 private GeotaggingString_Provinces;
235 private GeotaggingString_County;
236 private GeotaggingString_Counties;
237 private GeotaggingString_Village;
238 private GeotaggingString_Villages;
239 private GeotaggingString_Post;
240 private GeotaggingString_Zip;
241 private GeotaggingString_Code;
242 private GeotaggingString_Place;
243 private GeotaggingString_Places;
244 private GeotaggingString_Address;
245 private GeotaggingString_Addresses;
246 private GeotaggingString_Street;
247 private GeotaggingString_Streets;
248 private GeotaggingString_Longitude;
249 private GeotaggingString_Longitude_Short;
250 private GeotaggingString_Longitude_Short2;
251 private GeotaggingString_Latitude;
252 private GeotaggingString_Latitude_Short;
253 private GeotaggingString_PostalCode;
254 private GeotaggingString_PostalCodes;
255 private GeotaggingString_ZipCode;
256 private GeotaggingString_ZipCodes;
257 private GeotaggingString_Territory;
258 private GeotaggingString_Territories;
259 private GeotaggingString_VRMBackCompat_CountryRegion;
260 private GeotaggingString_VRMBackCompat_StateOrProvince;
261 constructor(getLocalized: (string) => string);
262 isLongitudeOrLatitude(fieldRefName: string): boolean;
263 isGeographic(fieldRefName: string): boolean;
264 isGeocodable(fieldRefName: string): boolean;
265 isGeoshapable(fieldRefName: string): boolean;
266 private isGeoshapableEnglish(fieldRefName);
267 private isAddress(fieldRefName);
268 private isPlace(fieldRefName);
269 private isCity(fieldRefName);
270 private isStateOrProvince(fieldRefName);
271 private isCountry(fieldRefName);
272 private isCounty(fieldRefName);
273 private isContinent(fieldRefName);
274 private isPostalCode(fieldRefName);
275 private isLongitude(fieldRefName);
276 private isLatitude(fieldRefName);
277 private isTerritory(fieldRefName);
278 private static hasMatches(fieldName, possibleMatches, useStrict?);
279 getFieldType(fieldName: string): string;
280 private isEnglishAddress(fieldRefName);
281 private isEnglishPlace(fieldRefName);
282 private isEnglishCity(fieldRefName);
283 private isEnglishStateOrProvince(fieldRefName);
284 private isEnglishCountry(fieldRefName);
285 private isEnglishCounty(fieldRefName);
286 private isEnglishContinent(fieldRefName);
287 private isEnglishPostalCode(fieldRefName);
288 private isEnglishLongitude(fieldRefName);
289 private isEnglishLatitude(fieldRefName);
290 protected isEnglishTerritory(fieldRefName: string): boolean;
291 private getEnglishFieldType(fieldName);
292 }
293}
294declare var DEBUG: boolean;
295
296declare module powerbi {
297 import IStringResourceProvider = jsCommon.IStringResourceProvider;
298 interface ILocalizableError {
299 getDetails(resourceProvider: IStringResourceProvider): ErrorDetails;
300 }
301 interface IClientError extends ILocalizableError {
302 code: string;
303 debugInfo?: string;
304 ignorable?: boolean;
305 requestId?: string;
306 }
307 interface IClientWarning extends ILocalizableError {
308 code: string;
309 columnNameFromIndex: (index: number) => string;
310 }
311 /**
312 * Unlocalized strings to be used for error reporting.
313 */
314 module ClientErrorStrings {
315 const ClientErrorCode: string;
316 const ErrorCode: string;
317 const ErrorDetails: string;
318 const HttpRequestId: string;
319 const JobId: string;
320 const ODataErrorMessage: string;
321 const StackTrace: string;
322 }
323 /**
324 this base class should be derived to give a generic error message but with a unique error code.
325 */
326 abstract class UnknownClientError implements IClientError {
327 private errorCode;
328 code: string;
329 ignorable: boolean;
330 constructor(code: string);
331 getDetails(resourceProvider: IStringResourceProvider): ErrorDetails;
332 }
333 class HttpClientError implements IClientError {
334 private httpRequestId;
335 private httpStatusCode;
336 constructor(httpStatusCode: number, requestId: string);
337 code: string;
338 ignorable: boolean;
339 requestId: string;
340 getDetails(resourceProvider: IStringResourceProvider): ErrorDetails;
341 }
342 class IgnorableClientError implements IClientError {
343 code: string;
344 ignorable: boolean;
345 getDetails(resourceProvider: IStringResourceProvider): ErrorDetails;
346 }
347}
348
349declare module jsCommon {
350 interface ArrayIdItems<T> extends Array<T> {
351 withId(id: number): T;
352 }
353 interface ArrayNamedItems<T> extends Array<T> {
354 withName(name: string): T;
355 }
356 /**
357 * Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
358 */
359 interface IComparer<T> {
360 /**
361 * Returns a signed number that indicates the relative values of x and y, as shown in the following table.
362 *
363 * Value | Meaning
364 * ------------------|--------------------
365 * Less than zero | a is less than b
366 * Zero | a equals b
367 * Greater than zero | a is greater than b
368 */
369 (a: T, b: T): number;
370 }
371 module ArrayExtensions {
372 /**
373 * Returns items that exist in target and other.
374 */
375 function intersect<T>(target: T[], other: T[]): T[];
376 /**
377 * Return elements exists in target but not exists in other.
378 */
379 function diff<T>(target: T[], other: T[]): T[];
380 /**
381 * Return an array with only the distinct items in the source.
382 */
383 function distinct<T>(source: T[]): T[];
384 /**
385 * Pushes content of source onto target,
386 * for parts of course that do not already exist in target.
387 */
388 function union<T>(target: T[], source: T[]): void;
389 /**
390 * Pushes value onto target, if value does not already exist in target.
391 */
392 function unionSingle<T>(target: T[], value: T): void;
393 /**
394 * Returns an array with a range of items from source,
395 * including the startIndex & endIndex.
396 */
397 function range<T>(source: T[], startIndex: number, endIndex: number): T[];
398 /**
399 * Returns an array that includes items from source, up to the specified count.
400 */
401 function take<T>(source: T[], count: number): T[];
402 function copy<T>(source: T[]): T[];
403 /**
404 * Returns a value indicating whether the arrays have the same values in the same sequence.
405 */
406 function sequenceEqual<T>(left: T[], right: T[], comparison: (x: T, y: T) => boolean): boolean;
407 /**
408 * Returns null if the specified array is empty.
409 * Otherwise returns the specified array.
410 */
411 function emptyToNull<T>(array: T[]): T[];
412 function indexOf<T>(array: T[], predicate: (T) => boolean): number;
413 /**
414 * Returns a copy of the array rotated by the specified offset.
415 */
416 function rotate<T>(array: T[], offset: number): T[];
417 function createWithId<T>(): ArrayIdItems<T>;
418 function extendWithId<T>(array: {
419 id: number;
420 }[]): ArrayIdItems<T>;
421 /**
422 * Finds and returns the first item with a matching ID.
423 */
424 function findWithId<T>(array: T[], id: number): T;
425 function createWithName<T>(): ArrayNamedItems<T>;
426 function extendWithName<T>(array: {
427 name: string;
428 }[]): ArrayNamedItems<T>;
429 function findItemWithName<T>(array: T[], name: string): T;
430 function indexWithName<T>(array: T[], name: string): number;
431 /**
432 * Inserts a number in sorted order into a list of numbers already in sorted order.
433 * @returns True if the item was added, false if it already existed.
434 */
435 function insertSorted(list: number[], value: number): boolean;
436 /**
437 * Removes the first occurrence of a value from a list if it exists.
438 * @returns True if the value was removed, false if it did not exist in the list.
439 */
440 function removeFirst<T>(list: T[], value: T): boolean;
441 /**
442 * Deletes all items from the array.
443 */
444 function clear(array: any[]): void;
445 function isUndefinedOrEmpty(array: any[]): boolean;
446 function swap<T>(array: T[], firstIndex: number, secondIndex: number): void;
447 function isInArray<T>(array: T[], lookupItem: T, compareCallback: (item1: T, item2: T) => boolean): boolean;
448 /** Checks if the given object is an Array, and looking all the way up the prototype chain. */
449 function isArrayOrInheritedArray(obj: {}): obj is Array<any>;
450 /**
451 * Returns true if the specified values array is sorted in an order as determined by the specified compareFunction.
452 */
453 function isSorted<T>(values: T[], compareFunction: IComparer<T>): boolean;
454 /**
455 * Returns true if the specified number values array is sorted in ascending order
456 * (or descending order if the specified descendingOrder is truthy).
457 */
458 function isSortedNumeric(values: number[], descendingOrder?: boolean): boolean;
459 }
460}
461
462declare module InJs {
463 module DomFactory {
464 function div(): JQuery;
465 function span(): JQuery;
466 function checkbox(): JQuery;
467 function ul(): JQuery;
468 function li(): JQuery;
469 function button(): JQuery;
470 function select(): JQuery;
471 function textBox(): JQuery;
472 function img(): JQuery;
473 function iframe(): JQuery;
474 }
475}
476
477declare module powerbi {
478 /**
479 * Module Double contains a set of constants and precision based utility methods
480 * for dealing with doubles and their decimal garbage in the javascript.
481 */
482 module Double {
483 const MIN_VALUE: number;
484 const MAX_VALUE: number;
485 const MIN_EXP: number;
486 const MAX_EXP: number;
487 const EPSILON: number;
488 const DEFAULT_PRECISION: number;
489 const DEFAULT_PRECISION_IN_DECIMAL_DIGITS: number;
490 const LOG_E_10: number;
491 const POSITIVE_POWERS: number[];
492 const NEGATIVE_POWERS: number[];
493 /**
494 * Returns powers of 10.
495 * Unlike the Math.pow this function produces no decimal garbage.
496 * @param exp Exponent.
497 */
498 function pow10(exp: number): number;
499 /**
500 * Returns the 10 base logarithm of the number.
501 * Unlike Math.log function this produces integer results with no decimal garbage.
502 * @param val Positive value or zero.
503 */
504 function log10(val: number): number;
505 /**
506 * Returns a power of 10 representing precision of the number based on the number of meaningful decimal digits.
507 * For example the precision of 56,263.3767 with the 6 meaningful decimal digit is 0.1.
508 * @param x Value.
509 * @param decimalDigits How many decimal digits are meaningfull.
510 */
511 function getPrecision(x: number, decimalDigits?: number): number;
512 /**
513 * Checks if a delta between 2 numbers is less than provided precision.
514 * @param x One value.
515 * @param y Another value.
516 * @param precision Precision value.
517 */
518 function equalWithPrecision(x: number, y: number, precision?: number): boolean;
519 /**
520 * Checks if a first value is less than another taking
521 * into account the loose precision based equality.
522 * @param x One value.
523 * @param y Another value.
524 * @param precision Precision value.
525 */
526 function lessWithPrecision(x: number, y: number, precision?: number): boolean;
527 /**
528 * Checks if a first value is less or equal than another taking
529 * into account the loose precision based equality.
530 * @param x One value.
531 * @param y Another value.
532 * @param precision Precision value.
533 */
534 function lessOrEqualWithPrecision(x: number, y: number, precision?: number): boolean;
535 /**
536 * Checks if a first value is greater than another taking
537 * into account the loose precision based equality.
538 * @param x One value.
539 * @param y Another value.
540 * @param precision Precision value.
541 */
542 function greaterWithPrecision(x: number, y: number, precision?: number): boolean;
543 /**
544 * Checks if a first value is greater or equal to another taking
545 * into account the loose precision based equality.
546 * @param x One value.
547 * @param y Another value.
548 * @param precision Precision value.
549 */
550 function greaterOrEqualWithPrecision(x: number, y: number, precision?: number): boolean;
551 /**
552 * Floors the number unless it's withing the precision distance from the higher int.
553 * @param x One value.
554 * @param precision Precision value.
555 */
556 function floorWithPrecision(x: number, precision?: number): number;
557 /**
558 * Ceils the number unless it's withing the precision distance from the lower int.
559 * @param x One value.
560 * @param precision Precision value.
561 */
562 function ceilWithPrecision(x: number, precision?: number): number;
563 /**
564 * Floors the number to the provided precision.
565 * For example 234,578 floored to 1,000 precision is 234,000.
566 * @param x One value.
567 * @param precision Precision value.
568 */
569 function floorToPrecision(x: number, precision?: number): number;
570 /**
571 * Ceils the number to the provided precision.
572 * For example 234,578 floored to 1,000 precision is 235,000.
573 * @param x One value.
574 * @param precision Precision value.
575 */
576 function ceilToPrecision(x: number, precision?: number): number;
577 /**
578 * Rounds the number to the provided precision.
579 * For example 234,578 floored to 1,000 precision is 235,000.
580 * @param x One value.
581 * @param precision Precision value.
582 */
583 function roundToPrecision(x: number, precision?: number): number;
584 /**
585 * Returns the value making sure that it's restricted to the provided range.
586 * @param x One value.
587 * @param min Range min boundary.
588 * @param max Range max boundary.
589 */
590 function ensureInRange(x: number, min: number, max: number): number;
591 /**
592 * Rounds the value - this method is actually faster than Math.round - used in the graphics utils.
593 * @param x Value to round.
594 */
595 function round(x: number): number;
596 /**
597 * Projects the value from the source range into the target range.
598 * @param value Value to project.
599 * @param fromMin Minimum of the source range.
600 * @param toMin Minimum of the target range.
601 * @param toMax Maximum of the target range.
602 */
603 function project(value: number, fromMin: number, fromSize: number, toMin: number, toSize: number): number;
604 /**
605 * Removes decimal noise.
606 * @param value Value to be processed.
607 */
608 function removeDecimalNoise(value: number): number;
609 /**
610 * Checks whether the number is integer.
611 * @param value Value to be checked.
612 */
613 function isInteger(value: number): boolean;
614 /**
615 * Dividing by increment will give us count of increments
616 * Round out the rough edges into even integer
617 * Multiply back by increment to get rounded value
618 * e.g. Rounder.toIncrement(0.647291, 0.05) => 0.65
619 * @param value - value to round to nearest increment
620 * @param increment - smallest increment to round toward
621 */
622 function toIncrement(value: number, increment: number): number;
623 }
624}
625
626declare module jsCommon {
627 module Color {
628 function rotate(rgbString: string, rotateFactor: number): string;
629 function normalizeToHexString(color: string): string;
630 function parseColorString(color: string): RgbColor;
631 function darken(color: RgbColor, diff: number): RgbColor;
632 function rgbString(color: RgbColor): string;
633 function hexString(color: RgbColor): string;
634 /**
635 * Overlays a color with opacity over a background color
636 * @param {string} foreColor Color to overlay
637 * @param {number} opacity number between 0 (transparent) to 1 (opaque)
638 * @param {string} backColor Background color
639 * @returns Result color
640 */
641 function hexBlend(foreColor: string, opacity: number, backColor: string): string;
642 /**
643 * Overlays a color with opacity over a background color. Any alpha-channel is ignored.
644 * @param {RgbColor} foreColor Color to overlay
645 * @param {number} opacity number between 0 (transparent) to 1 (opaque). Any value out of range will be corrected.
646 * @param {RgbColor} backColor Background color
647 * @returns
648 */
649 function rgbBlend(foreColor: RgbColor, opacity: number, backColor: RgbColor): RgbColor;
650 /**
651 * Blend a single channel for two colors
652 * @param {number} foreChannel Channel of foreground color. Will be enforced to be between 0 and 255.
653 * @param {number} opacity opacity of the foreground color. Will be enforced to be between 0 and 1.
654 * @param {number} backChannel channel of the background color. Will be enforced to be between 0 and 255.
655 * @returns result channel value
656 */
657 function channelBlend(foreChannel: number, opacity: number, backChannel: number): number;
658 interface RgbColor {
659 R: number;
660 G: number;
661 B: number;
662 A?: number;
663 }
664 }
665}
666
667declare module jsCommon {
668 /**
669 * CSS constants.
670 */
671 module CssConstants {
672 interface ClassAndSelector {
673 class: string;
674 selector: string;
675 }
676 function createClassAndSelector(className: string): ClassAndSelector;
677 const styleAttribute: string;
678 const pixelUnits: string;
679 const heightProperty: string;
680 const widthProperty: string;
681 const topProperty: string;
682 const bottomProperty: string;
683 const leftProperty: string;
684 const rightProperty: string;
685 const marginTopProperty: string;
686 const marginLeftProperty: string;
687 const displayProperty: string;
688 const backgroundProperty: string;
689 const backgroundColorProperty: string;
690 const backgroundRepeatProperty: string;
691 const backgroundSizeProperty: string;
692 const backgroundImageProperty: string;
693 const textShadowProperty: string;
694 const textAlignProperty: string;
695 const borderTopWidthProperty: string;
696 const borderBottomWidthProperty: string;
697 const borderLeftWidthProperty: string;
698 const borderRightWidthProperty: string;
699 const fontSizeProperty: string;
700 const fontWeightProperty: string;
701 const colorProperty: string;
702 const opacityProperty: string;
703 const paddingLeftProperty: string;
704 const paddingRightProperty: string;
705 const positionProperty: string;
706 const maxWidthProperty: string;
707 const minWidthProperty: string;
708 const overflowProperty: string;
709 const overflowXProperty: string;
710 const overflowYProperty: string;
711 const transformProperty: string;
712 const webkitTransformProperty: string;
713 const cursorProperty: string;
714 const visibilityProperty: string;
715 const absoluteValue: string;
716 const zeroPixelValue: string;
717 const autoValue: string;
718 const hiddenValue: string;
719 const noneValue: string;
720 const blockValue: string;
721 const inlineBlockValue: string;
722 const transparentValue: string;
723 const boldValue: string;
724 const visibleValue: string;
725 const tableRowValue: string;
726 const coverValue: string;
727 const pointerValue: string;
728 const scrollValue: string;
729 }
730 interface ExtendedCSSProperties extends CSSStyleDeclaration {
731 scrollbarShadowColor: string;
732 scrollbarHighlightColor: string;
733 layoutGridChar: string;
734 layoutGridType: string;
735 textAutospace: string;
736 textKashidaSpace: string;
737 writingMode: string;
738 scrollbarFaceColor: string;
739 backgroundPositionY: string;
740 lineBreak: string;
741 imeMode: string;
742 msBlockProgression: string;
743 layoutGridLine: string;
744 scrollbarBaseColor: string;
745 layoutGrid: string;
746 layoutFlow: string;
747 textKashida: string;
748 filter: string;
749 zoom: string;
750 scrollbarArrowColor: string;
751 behavior: string;
752 backgroundPositionX: string;
753 accelerator: string;
754 layoutGridMode: string;
755 textJustifyTrim: string;
756 scrollbar3dLightColor: string;
757 msInterpolationMode: string;
758 scrollbarTrackColor: string;
759 scrollbarDarkShadowColor: string;
760 styleFloat: string;
761 getAttribute(attributeName: string, flags?: number): any;
762 setAttribute(attributeName: string, AttributeValue: any, flags?: number): void;
763 removeAttribute(attributeName: string, flags?: number): boolean;
764 pixelWidth: number;
765 posHeight: number;
766 posLeft: number;
767 pixelTop: number;
768 pixelBottom: number;
769 textDecorationNone: boolean;
770 pixelLeft: number;
771 posTop: number;
772 posBottom: number;
773 textDecorationOverline: boolean;
774 posWidth: number;
775 textDecorationLineThrough: boolean;
776 pixelHeight: number;
777 textDecorationBlink: boolean;
778 posRight: number;
779 pixelRight: number;
780 textDecorationUnderline: boolean;
781 webkitTransform: string;
782 }
783}
784
785/**
786 * Defines a Debug object. Calls to any functions in this object removed by the minifier.
787 * The functions within this class are not minified away, so we use the preprocessor-style
788 * comments to have the minifier remove those as well.
789 */
790declare module debug {
791 let assertFailFunction: {
792 (message: string): void;
793 };
794 /**
795 * Asserts that the condition is true, fails otherwise.
796 */
797 function assert(condition: boolean, message: string): void;
798 /**
799 * Asserts that the value is neither null nor undefined, fails otherwise.
800 */
801 function assertValue<T>(value: T, message: string): void;
802 /**
803 * Asserts that the value is neither null nor undefined, and has a length property that returns greater than zero, fails otherwise.
804 */
805 function assertNonEmpty<T>(value: T[], message: string): void;
806 /**
807 * Makes no assertion on the given value.
808 * This is documentation/placeholder that a value is possibly null or undefined (unlike assertValue).
809 */
810 function assertAnyValue<T>(value: T, message: string): void;
811 function assertFail(message: string): void;
812}
813
814declare module jsCommon {
815 interface IError extends Error {
816 stack?: string;
817 argument?: string;
818 }
819 module Errors {
820 function infoNavAppAlreadyPresent(): IError;
821 function invalidOperation(message: string): IError;
822 function argument(argumentName: string, message: string): IError;
823 function argumentNull(argumentName: string): IError;
824 function argumentUndefined(argumentName: string): IError;
825 function argumentOutOfRange(argumentName: string): IError;
826 function pureVirtualMethodException(className: string, methodName: string): IError;
827 function notImplementedException(message: string): IError;
828 }
829 /**
830 * Captures the stack trace, if available.
831 * It optionally takes the number of frames to remove from the stack trace.
832 * By default, it removes the last frame to consider the calling type's
833 * constructor and the temporary error used to capture the stack trace (below).
834 * More levels can be requested as needed e..g. when an error is created
835 * from a helper method. <Min requirement: IE10, Chrome, Firefox, Opera>.
836 */
837 function getStackTrace(leadingFramesToRemove?: number): string;
838}
839declare module jsCommon {
840 /**
841 * Represents a promise that may be rejected by its consumer.
842 */
843 interface IRejectablePromise extends JQueryPromise<void> {
844 reject(...args: any[]): void;
845 }
846 module JQueryConstants {
847 const VisibleSelector: string;
848 }
849}
850
851declare module jsCommon {
852 /**
853 * Represents a lazily instantiated value.
854 */
855 class Lazy<T> {
856 private value;
857 private factoryMethod;
858 constructor(factoryMethod: () => T);
859 getValue(): T;
860 }
861}
862
863declare module powerbi {
864 module Prototype {
865 /**
866 * Returns a new object with the provided obj as its prototype.
867 */
868 function inherit<T>(obj: T, extension?: (inherited: T) => void): T;
869 /**
870 * Returns a new object with the provided obj as its prototype
871 * if, and only if, the prototype has not been previously set
872 */
873 function inheritSingle<T>(obj: T): T;
874 /**
875 * Uses the provided callback function to selectively replace contents in the provided array.
876 * @return A new array with those values overriden
877 * or undefined if no overrides are necessary.
878 */
879 function overrideArray<T, TArray>(prototype: TArray, override: (T) => T): TArray;
880 }
881}
882
883declare module powerbi {
884 interface ScriptErrorInfo {
885 message: string;
886 sourceUrl: string;
887 lineNumber: number;
888 columnNumber: number;
889 stack: string;
890 }
891 interface ErrorInfoKeyValuePair {
892 errorInfoKey: string;
893 errorInfoValue: string;
894 }
895 const enum ErrorType {
896 VisualNotSupported = 1,
897 }
898 interface ErrorDetails {
899 message: string;
900 displayableErrorInfo: ErrorInfoKeyValuePair[];
901 /**
902 * This is a collection of unlocalized properties that could be used for error reporting.
903 * These should not be displayed to the user.
904 */
905 debugErrorInfo?: ErrorInfoKeyValuePair[];
906 helpLink?: string;
907 errorType?: ErrorType;
908 }
909}
910
911declare module powerbi.visuals {
912 module shapes {
913 interface IPolygon {
914 absoluteCentroid: IPoint;
915 polygonPoints: IPoint[];
916 }
917 interface IPoint {
918 x: number;
919 y: number;
920 }
921 interface ISize {
922 width: number;
923 height: number;
924 }
925 interface IVector {
926 x: number;
927 y: number;
928 }
929 interface IThickness {
930 top: number;
931 left: number;
932 right: number;
933 bottom: number;
934 }
935 }
936}
937
938declare module jsCommon {
939 module Formatting {
940 /**
941 * Translate .NET format into something supported by jQuery.Globalize.
942 */
943 function findDateFormat(value: Date, format: string, cultureName: string): {
944 value: Date;
945 format: string;
946 };
947 /**
948 * Translates unsupported .NET custom format expressions to the custom expressions supported by JQuery.Globalize.
949 */
950 function fixDateTimeFormat(format: string): string;
951 }
952}
953
954declare module jsCommon {
955 /**
956 * Public API.
957 */
958 interface IJavaScriptDependency {
959 javascriptFile: string;
960 onLoadCallback?: () => JQueryPromise<void>;
961 }
962 interface IDependency {
963 javaScriptFiles?: string[];
964 cssFiles?: string[];
965 javaScriptFilesWithCallback?: IJavaScriptDependency[];
966 }
967 function requires(dependency: IDependency, to?: () => void): void;
968}
969
970declare module powerbi {
971 function createJQueryPromiseFactory(): IPromiseFactory;
972}
973
974declare module powerbi {
975 interface IStorageService {
976 getData(key: string): any;
977 setData(key: string, data: any): void;
978 }
979 class EphemeralStorageService implements IStorageService {
980 private cache;
981 private clearCacheTimerId;
982 private clearCacheInterval;
983 static defaultClearCacheInterval: number;
984 constructor(clearCacheInterval?: number);
985 getData(key: string): any;
986 setData(key: string, data: any): void;
987 private clearCache();
988 }
989 var localStorageService: IStorageService;
990 const ephemeralStorageService: IStorageService;
991}
992
993declare module jsCommon {
994 module WordBreaker {
995 import TextProperties = powerbi.TextProperties;
996 import ITextAsSVGMeasurer = powerbi.ITextAsSVGMeasurer;
997 import ITextTruncator = powerbi.ITextTruncator;
998 interface WordBreakerResult {
999 start: number;
1000 end: number;
1001 }
1002 /**
1003 * Find the word nearest the cursor specified within content
1004 * @param index - point within content to search forward/backward from
1005 * @param content - string to search
1006 */
1007 function find(index: number, content: string): WordBreakerResult;
1008 /**
1009 * Test for presence of breakers within content
1010 * @param content - string to test
1011 */
1012 function hasBreakers(content: string): boolean;
1013 /**
1014 * Count the number of pieces when broken by BREAKERS_REGEX
1015 * ~2.7x faster than WordBreaker.split(content).length
1016 * @param content - string to break and count
1017 */
1018 function wordCount(content: string): number;
1019 function getMaxWordWidth(content: string, textWidthMeasurer: ITextAsSVGMeasurer, properties: TextProperties): number;
1020 /**
1021 * Split content by breakers (words) and greedy fit as many words
1022 * into each index in the result based on max width and number of lines
1023 * e.g. Each index in result corresponds to a line of content
1024 * when used by AxisHelper.LabelLayoutStrategy.wordBreak
1025 * @param content - string to split
1026 * @param properties - text properties to be used by @param:textWidthMeasurer
1027 * @param textWidthMeasurer - function to calculate width of given text content
1028 * @param maxWidth - maximum allowed width of text content in each result
1029 * @param maxNumLines - maximum number of results we will allow, valid values must be greater than 0
1030 * @param truncator - (optional) if specified, used as a function to truncate content to a given width
1031 */
1032 function splitByWidth(content: string, properties: TextProperties, textWidthMeasurer: ITextAsSVGMeasurer, maxWidth: number, maxNumLines: number, truncator?: ITextTruncator): string[];
1033 }
1034}
1035
1036declare module powerbi {
1037 interface ITextMeasurer {
1038 (textElement: SVGTextElement): number;
1039 }
1040 interface ITextAsSVGMeasurer {
1041 (textProperties: TextProperties): number;
1042 }
1043 interface ITextTruncator {
1044 (properties: TextProperties, maxWidth: number): string;
1045 }
1046 interface TextProperties {
1047 text?: string;
1048 fontFamily: string;
1049 fontSize: string;
1050 fontWeight?: string;
1051 fontStyle?: string;
1052 fontVariant?: string;
1053 whiteSpace?: string;
1054 }
1055 module TextMeasurementService {
1056 /**
1057 * Removes spanElement from DOM.
1058 */
1059 function removeSpanElement(): void;
1060 /**
1061 * This method measures the width of the text with the given SVG text properties.
1062 * @param textProperties The text properties to use for text measurement.
1063 * @param text The text to measure.
1064 */
1065 function measureSvgTextWidth(textProperties: TextProperties, text?: string): number;
1066 /**
1067 * This method return the rect with the given SVG text properties.
1068 * @param textProperties The text properties to use for text measurement.
1069 * @param text The text to measure.
1070 */
1071 function measureSvgTextRect(textProperties: TextProperties, text?: string): SVGRect;
1072 /**
1073 * This method measures the height of the text with the given SVG text properties.
1074 * @param textProperties The text properties to use for text measurement.
1075 * @param text The text to measure.
1076 */
1077 function measureSvgTextHeight(textProperties: TextProperties, text?: string): number;
1078 /**
1079 * This method returns the text Rect with the given SVG text properties.
1080 * @param {TextProperties} textProperties - The text properties to use for text measurement
1081 */
1082 function estimateSvgTextBaselineDelta(textProperties: TextProperties): number;
1083 /**
1084 * This method estimates the height of the text with the given SVG text properties.
1085 * @param {TextProperties} textProperties - The text properties to use for text measurement
1086 */
1087 function estimateSvgTextHeight(textProperties: TextProperties, tightFightForNumeric?: boolean): number;
1088 /**
1089 * This method measures the width of the svgElement.
1090 * @param svgElement The SVGTextElement to be measured.
1091 */
1092 function measureSvgTextElementWidth(svgElement: SVGTextElement): number;
1093 /**
1094 * This method fetches the text measurement properties of the given DOM element.
1095 * @param element The selector for the DOM Element.
1096 */
1097 function getMeasurementProperties(element: JQuery): TextProperties;
1098 /**
1099 * This method fetches the text measurement properties of the given SVG text element.
1100 * @param svgElement The SVGTextElement to be measured.
1101 */
1102 function getSvgMeasurementProperties(svgElement: SVGTextElement): TextProperties;
1103 /**
1104 * This method returns the width of a div element.
1105 * @param element The div element.
1106 */
1107 function getDivElementWidth(element: JQuery): string;
1108 /**
1109 * Compares labels text size to the available size and renders ellipses when the available size is smaller.
1110 * @param textProperties The text properties (including text content) to use for text measurement.
1111 * @param maxWidth The maximum width available for rendering the text.
1112 */
1113 function getTailoredTextOrDefault(textProperties: TextProperties, maxWidth: number): string;
1114 /**
1115 * Compares labels text size to the available size and renders ellipses when the available size is smaller.
1116 * @param textElement The SVGTextElement containing the text to render.
1117 * @param maxWidth The maximum width available for rendering the text.
1118 */
1119 function svgEllipsis(textElement: SVGTextElement, maxWidth: number): void;
1120 /**
1121 * Word break textContent of <text> SVG element into <tspan>s
1122 * Each tspan will be the height of a single line of text
1123 * @param textElement - the SVGTextElement containing the text to wrap
1124 * @param maxWidth - the maximum width available
1125 * @param maxHeight - the maximum height available (defaults to single line)
1126 * @param linePadding - (optional) padding to add to line height
1127 */
1128 function wordBreak(textElement: SVGTextElement, maxWidth: number, maxHeight: number, linePadding?: number): void;
1129 /**
1130 * Word break textContent of span element into <span>s
1131 * Each span will be the height of a single line of text
1132 * @param textElement - the element containing the text to wrap
1133 * @param maxWidth - the maximum width available
1134 * @param maxHeight - the maximum height available (defaults to single line)
1135 * @param linePadding - (optional) padding to add to line height
1136 */
1137 function wordBreakOverflowingText(textElement: any, maxWidth: number, maxHeight: number, linePadding?: number): void;
1138 }
1139}
1140
1141declare module jsCommon {
1142 module KeyUtils {
1143 function isArrowKey(keyCode: number): boolean;
1144 function isCtrlDefaultKey(keyCode: number): boolean;
1145 function isNudgeModifierKey(keyCode: number): boolean;
1146 }
1147}
1148
1149declare module jsCommon {
1150 /**
1151 * Responsible for throttling input function.
1152 */
1153 class ThrottleUtility {
1154 private fn;
1155 private timerFactory;
1156 private delay;
1157 constructor(delay?: number);
1158 run(fn: () => void): void;
1159 /**
1160 * Note: Public for testing purpose.
1161 */
1162 timerComplete(fn: () => void): void;
1163 }
1164}
1165
1166declare module jsCommon {
1167 interface ITimerPromiseFactory {
1168 /**
1169 * Creates a promise that will be resolved after the specified delayInMs.
1170 * @return Promise.
1171 */
1172 create(delayInMs: number): IRejectablePromise;
1173 }
1174 /**
1175 * Responsible for creating timer promises.
1176 */
1177 class TimerPromiseFactory implements ITimerPromiseFactory {
1178 static instance: TimerPromiseFactory;
1179 /**
1180 * {@inheritDoc}
1181 */
1182 create(delayInMs: number): IRejectablePromise;
1183 }
1184}
1185/**
1186 * Defined in host.
1187 */
1188declare var clusterUri: string;
1189declare module jsCommon {
1190 /**
1191 * Http Status code we are interested.
1192 */
1193 enum HttpStatusCode {
1194 OK = 200,
1195 BadRequest = 400,
1196 Unauthorized = 401,
1197 Forbidden = 403,
1198 RequestEntityTooLarge = 413,
1199 }
1200 /**
1201 * Other HTTP Constants.
1202 */
1203 module HttpConstants {
1204 const ApplicationOctetStream: string;
1205 const MultiPartFormData: string;
1206 }
1207 /**
1208 * Extensions to String class.
1209 */
1210 module StringExtensions {
1211 function format(...args: string[]): string;
1212 /**
1213 * Compares two strings for equality, ignoring case.
1214 */
1215 function equalIgnoreCase(a: string, b: string): boolean;
1216 function startsWithIgnoreCase(a: string, b: string): boolean;
1217 function startsWith(a: string, b: string): boolean;
1218 /** Determines whether a string contains a specified substring (by case-sensitive comparison). */
1219 function contains(source: string, substring: string): boolean;
1220 /** Determines whether a string contains a specified substring (while ignoring case). */
1221 function containsIgnoreCase(source: string, substring: string): boolean;
1222 /**
1223 * Normalizes case for a string.
1224 * Used by equalIgnoreCase method.
1225 */
1226 function normalizeCase(value: string): string;
1227 /**
1228 * Is string null or empty or undefined?
1229 * @return True if the value is null or undefined or empty string,
1230 * otherwise false.
1231 */
1232 function isNullOrEmpty(value: string): boolean;
1233 /**
1234 * Returns true if the string is null, undefined, empty, or only includes white spaces.
1235 * @return True if the str is null, undefined, empty, or only includes white spaces,
1236 * otherwise false.
1237 */
1238 function isNullOrUndefinedOrWhiteSpaceString(str: string): boolean;
1239 /**
1240 * Returns a value indicating whether the str contains any whitespace.
1241 */
1242 function containsWhitespace(str: string): boolean;
1243 /**
1244 * Returns a value indicating whether the str is a whitespace string.
1245 */
1246 function isWhitespace(str: string): boolean;
1247 /**
1248 * Returns the string with any trailing whitespace from str removed.
1249 */
1250 function trimTrailingWhitespace(str: string): string;
1251 /**
1252 * Returns the string with any leading and trailing whitespace from str removed.
1253 */
1254 function trimWhitespace(str: string): string;
1255 /**
1256 * Returns length difference between the two provided strings.
1257 */
1258 function getLengthDifference(left: string, right: string): number;
1259 /**
1260 * Repeat char or string several times.
1261 * @param char The string to repeat.
1262 * @param count How many times to repeat the string.
1263 */
1264 function repeat(char: string, count: number): string;
1265 /**
1266 * Replace all the occurrences of the textToFind in the text with the textToReplace.
1267 * @param text The original string.
1268 * @param textToFind Text to find in the original string.
1269 * @param textToReplace New text replacing the textToFind.
1270 */
1271 function replaceAll(text: string, textToFind: string, textToReplace: string): string;
1272 function ensureUniqueNames(names: string[]): string[];
1273 /**
1274 * Returns a name that is not specified in the values.
1275 */
1276 function findUniqueName(usedNames: {
1277 [name: string]: boolean;
1278 }, baseName: string): string;
1279 function constructCommaSeparatedList(list: string[], resourceProvider: IStringResourceProvider, maxValue?: number): string;
1280 function escapeStringForRegex(s: string): string;
1281 /**
1282 * Remove file name reserved characters <>:"/\|?* from input string.
1283 */
1284 function normalizeFileName(fileName: string): string;
1285 /**
1286 * Similar to JSON.stringify, but strips away escape sequences so that the resulting
1287 * string is human-readable (and parsable by JSON formatting/validating tools).
1288 */
1289 function stringifyAsPrettyJSON(object: any): string;
1290 /**
1291 * Derive a CLS-compliant name from a specified string. If no allowed characters are present, return a fallback string instead.
1292 * TODO (6708134): this should have a fully Unicode-aware implementation
1293 */
1294 function deriveClsCompliantName(input: string, fallback: string): string;
1295 /** Performs cheap sanitization by stripping away HTML tag (<>) characters. */
1296 function stripTagDelimiters(s: string): string;
1297 }
1298 /**
1299 * Interface used for interacting with WCF typed objects.
1300 */
1301 interface TypedObject {
1302 __type: string;
1303 }
1304 interface TextMatch {
1305 start: number;
1306 end: number;
1307 text: string;
1308 }
1309 /**
1310 * The general utility class.
1311 */
1312 class Utility {
1313 private static TypeNamespace;
1314 static JsonContentType: string;
1315 static JpegContentType: string;
1316 static XJavascriptContentType: string;
1317 static JsonDataType: string;
1318 static BlobDataType: string;
1319 static HttpGetMethod: string;
1320 static HttpPostMethod: string;
1321 static HttpPutMethod: string;
1322 static HttpDeleteMethod: string;
1323 static HttpContentTypeHeader: string;
1324 static HttpAcceptHeader: string;
1325 static Undefined: string;
1326 private static staticContentLocation;
1327 /**
1328 * Ensures the specified value is not null or undefined. Throws a relevent exception if it is.
1329 * @param value The value to check.
1330 * @param context The context from which the check originated.
1331 * @param methodName The name of the method that initiated the check.
1332 * @param parameterName The parameter name of the value to check.
1333 */
1334 static throwIfNullOrUndefined(value: any, context: any, methodName: any, parameterName: any): void;
1335 /**
1336 * Ensures the specified value is not null, undefined or empty. Throws a relevent exception if it is.
1337 * @param value The value to check.
1338 * @param context The context from which the check originated.
1339 * @param methodName The name of the method that initiated the check.
1340 * @param parameterName The parameter name of the value to check.
1341 */
1342 static throwIfNullOrEmpty(value: any, context: any, methodName: string, parameterName: string): void;
1343 /**
1344 * Ensures the specified string is not null, undefined or empty. Throws a relevent exception if it is.
1345 * @param value The value to check.
1346 * @param context The context from which the check originated.
1347 * @param methodName The name of the method that initiated the check.
1348 * @param parameterName The parameter name of the value to check.
1349 */
1350 static throwIfNullOrEmptyString(value: string, context: any, methodName: string, parameterName: string): void;
1351 /**
1352 * Ensures the specified value is not null, undefined, whitespace or empty. Throws a relevent exception if it is.
1353 * @param value The value to check.
1354 * @param context The context from which the check originated.
1355 * @param methodName The name of the method that initiated the check.
1356 * @param parameterName The parameter name of the value to check.
1357 */
1358 static throwIfNullEmptyOrWhitespaceString(value: string, context: any, methodName: string, parameterName: string): void;
1359 /**
1360 * Ensures the specified condition is true. Throws relevant exception if it isn't.
1361 * @param condition The condition to check.
1362 * @param context The context from which the check originated.
1363 * @param methodName The name of the method that initiated the check.
1364 * @param parameterName The parameter name against which the condition is checked.
1365 */
1366 static throwIfNotTrue(condition: boolean, context: any, methodName: string, parameterName: string): void;
1367 /**
1368 * Checks whether the provided value is a 'string'.
1369 * @param value The value to test.
1370 */
1371 static isString(value: any): boolean;
1372 /**
1373 * Checks whether the provided value is a 'boolean'.
1374 * @param value The value to test.
1375 */
1376 static isBoolean(value: any): boolean;
1377 /**
1378 * Checks whether the provided value is a 'number'.
1379 * @param value The value to test.
1380 */
1381 static isNumber(value: any): boolean;
1382 /**
1383 * Checks whether the provided value is a Date instance.
1384 * @param value The value to test.
1385 */
1386 static isDate(value: any): boolean;
1387 /**
1388 * Checks whether the provided value is an 'object'.
1389 * @param value The value to test.
1390 */
1391 static isObject(value: any): boolean;
1392 /**
1393 * Checks whether the provided value is null or undefined.
1394 * @param value The value to test.
1395 */
1396 static isNullOrUndefined(value: any): boolean;
1397 /**
1398 * Checks if the value is defined and returns it, else, returns undefined
1399 * @param {T} value Value to check
1400 * @param {T} defaultValue Default value to return if value is undefined
1401 * @returns value if defined, else defaultValue
1402 */
1403 static valueOrDefault<T>(value: T, defaultValue: T): T;
1404 /**
1405 * Combine a base url and a path.
1406 * @param baseUrl The base url.
1407 * @param path The path to add on to the base url.
1408 * @returns The combined url.
1409 */
1410 static urlCombine(baseUrl: string, path: string): string;
1411 static getAbsoluteUri(path: string): string;
1412 static getStaticResourceUri(path: string): string;
1413 static getComponentName(context: any): string;
1414 static throwException(e: any): void;
1415 static createClassSelector(className: string): string;
1416 static createIdSelector(id: string): string;
1417 /**
1418 * Creates a client-side Guid string.
1419 * @returns A string representation of a Guid.
1420 */
1421 static generateGuid(): string;
1422 /**
1423 * Try extract a cookie from {@link document.cookie} identified by key.
1424 */
1425 static getCookieValue(key: string): string;
1426 /**
1427 * Extracts the protocol://hostname section of a url.
1428 * @param url The URL from which to extract the section.
1429 * @returns The protocol://hostname portion of the given URL.
1430 */
1431 static getDomainForUrl(url: string): string;
1432 /**
1433 * Extracts the hostname and absolute path sections of a url.
1434 * @param url The URL from which to extract the section.
1435 * @returns The hostname and absolute path portion of the given URL.
1436 */
1437 static getHostNameForUrl(url: string): string;
1438 /**
1439 * Return the original url with query string stripped.
1440 * @param url The URL from which to extract the section.
1441 * @returns the original url with query string stripped.
1442 */
1443 static getUrlWithoutQueryString(url: string): string;
1444 /**
1445 * Extracts the protocol section of a url.
1446 * @param url The URL from which to extract the section.
1447 * @returns The protocol for the current URL.
1448 */
1449 static getProtocolFromUrl(url: string): string;
1450 /**
1451 * Returns a formatted href object from a URL.
1452 * @param url The URL used to generate the object.
1453 * @returns A jQuery object with the url.
1454 */
1455 static getHrefObjectFromUrl(url: string): JQuery;
1456 /**
1457 * Converts a WCF representation of a dictionary to a JavaScript dictionary.
1458 * @param wcfDictionary The WCF dictionary to convert.
1459 * @returns The native JavaScript representation of this dictionary.
1460 */
1461 static convertWcfToJsDictionary(wcfDictionary: any[]): {
1462 [index: string]: any;
1463 };
1464 static getDateFromWcfJsonString(jsonDate: string, fromUtcMilliseconds: boolean): Date;
1465 /**
1466 * Get the outer html of the given jquery object.
1467 * @param content The jquery object.
1468 * @returns The entire html representation of the object.
1469 */
1470 static getOuterHtml(content: JQuery): string;
1471 /**
1472 * Comparison Method: Compares two integer numbers.
1473 * @param a An integer value.
1474 * @param b An integer value.
1475 * @returns The comparison result.
1476 */
1477 static compareInt(a: number, b: number): number;
1478 /**
1479 * Return the index of the smallest value in a numerical array.
1480 * @param a A numeric array.
1481 * @returns The index of the smallest value in the array.
1482 */
1483 static getIndexOfMinValue(a: number[]): number;
1484 /**
1485 * Extracts a url from a background image attribute in the format of: url('www.foobar.com/image.png').
1486 * @param input The value of the background-image attribute.
1487 * @returns The extracted url.
1488 */
1489 static extractUrlFromCssBackgroundImage(input: string): string;
1490 /**
1491 * Verifies image data url of images.
1492 */
1493 static isValidImageDataUrl(url: string): boolean;
1494 static isLocalUrl(url: string): boolean;
1495 /**
1496 * Downloads a content string as a file.
1497 * @param content Content stream.
1498 * @param fileName File name to use.
1499 */
1500 static saveAsFile(content: any, fileName: string): void;
1501 /**
1502 * Helper method to get the simple type name from a typed object.
1503 * @param obj The typed object.
1504 * @returns The simple type name for the object.
1505 */
1506 static getType(obj: TypedObject): string;
1507 /**
1508 * Check if an element supports a specific event type.
1509 * @param eventName The name of the event.
1510 * @param element The element to test for event support.
1511 * @returns Whether the even is supported on the provided element.
1512 */
1513 static isEventSupported(eventName: string, element: Element): boolean;
1514 static toPixel(pixelAmount: number): string;
1515 static getPropertyCount(object: any): number;
1516 /**
1517 * Check if an element supports a specific event type.
1518 * @param filePath File path.
1519 * @returns File extension.
1520 */
1521 static getFileExtension(filePath: string): string;
1522 /**
1523 * Extract the filename out of a full path delimited by '\' or '/'.
1524 * @param filePath File path.
1525 * @returns filename File name.
1526 */
1527 static extractFileNameFromPath(filePath: string): string;
1528 /**
1529 * This method indicates whether window.clipboardData is supported.
1530 * For example, clipboard support for Windows Store apps is currently disabled
1531 * since window.clipboardData is unsupported (it raises access denied error)
1532 * since clipboard in Windows Store is being
1533 * achieved through Windows.ApplicationModel.DataTransfer.Clipboard class.
1534 */
1535 static canUseClipboard(): boolean;
1536 static is64BitOperatingSystem(): boolean;
1537 static parseNumber(value: any, defaultValue?: number): number;
1538 static getURLParamValue(name: string): string | number;
1539 /**
1540 * Return local timezone.
1541 * This function uses summer and winter offset to determine local time zone.
1542 * The result localTimeZoneString must be a subset of the strings used by server,
1543 * as documented here: https://msdn.microsoft.com/en-us/library/gg154758.aspx (Dynamic Daylight Savings Time (Compact 2013)).
1544 * @return Local timezone string or UTC if timezone cannot be found.
1545 */
1546 static getLocalTimeZoneString(): string;
1547 }
1548 class VersionUtility {
1549 /**
1550 * Compares 2 version strings.
1551 * @param versionA The first version string.
1552 * @param versionB The second version string.
1553 * @returns A result for the comparison.
1554 */
1555 static compareVersions(versionA: string, versionB: string): number;
1556 }
1557 module PerformanceUtil {
1558 class PerfMarker {
1559 private _name;
1560 private _start;
1561 constructor(name: string);
1562 private static begin(name);
1563 end(): void;
1564 }
1565 function create(name: string): PerfMarker;
1566 }
1567 module DeferUtility {
1568 /**
1569 * Wraps a callback and returns a new function.
1570 * The function can be called many times but the callback
1571 * will only be executed once on the next frame.
1572 * Use this to throttle big UI updates and access to DOM.
1573 */
1574 function deferUntilNextFrame(callback: Function): Function;
1575 }
1576}
1577
1578declare module jsCommon {
1579 class TraceItem {
1580 type: TraceType;
1581 sessionId: string;
1582 requestId: string;
1583 text: string;
1584 timeStamp: Date;
1585 /**
1586 * Note: DO NOT USE for backward compability only.
1587 */
1588 _activityId: string;
1589 private static traceTypeStrings;
1590 constructor(text: string, type: TraceType, sessionId: string, requestId?: string);
1591 toString(): string;
1592 }
1593}
1594
1595declare module jsCommon {
1596 module UrlUtils {
1597 function isValidUrl(value: string): boolean;
1598 function isValidImageUrl(url: string): boolean;
1599 function findAllValidUrls(text: string): TextMatch[];
1600 function getBase64ContentFromDataUri(uri: string): string;
1601 }
1602}
1603
1604declare module jsCommon {
1605 module BrowserUtils {
1606 function isChrome(): boolean;
1607 function isInternetExplorerOrEdge(): boolean;
1608 /**
1609 * Get the current version of IE
1610 * @returns The version of Internet Explorer or a 0 (indicating the use of another browser).
1611 */
1612 function getInternetExplorerVersion(): number;
1613 function isFirefox(): boolean;
1614 }
1615}
1616
1617declare module jsCommon {
1618 /**
1619 * Interface to help define objects indexed by number to a particular type.
1620 */
1621 interface INumberDictionary<T> {
1622 [key: number]: T;
1623 }
1624 /**
1625 * Interface to help define objects indexed by name to a particular type.
1626 */
1627 interface IStringDictionary<T> {
1628 [key: string]: T;
1629 }
1630 /**
1631 * Extensions for Enumerations.
1632 */
1633 module EnumExtensions {
1634 /**
1635 * Gets a value indicating whether the value has the bit flags set.
1636 */
1637 function hasFlag(value: number, flag: number): boolean;
1638 /**
1639 * Sets a value of a flag without modifying any other flags.
1640 */
1641 function setFlag(value: number, flag: number): number;
1642 /**
1643 * Resets a value of a flag without modifying any other flags.
1644 */
1645 function resetFlag(value: number, flag: number): number;
1646 /**
1647 * According to the TypeScript Handbook, this is safe to do.
1648 */
1649 function toString(enumType: any, value: number): string;
1650 }
1651 /**
1652 * Extensions to String class.
1653 */
1654 module StringExtensions {
1655 /**
1656 * Checks if a string ends with a sub-string.
1657 */
1658 function endsWith(str: string, suffix: string): boolean;
1659 }
1660 module LogicExtensions {
1661 function XOR(a: boolean, b: boolean): boolean;
1662 }
1663 module JsonComparer {
1664 /**
1665 * Performs JSON-style comparison of two objects.
1666 */
1667 function equals<T>(x: T, y: T): boolean;
1668 }
1669 /**
1670 * Values are in terms of 'pt'
1671 * Convert to pixels using PixelConverter.fromPoint
1672 */
1673 module TextSizeDefaults {
1674 /**
1675 * Stored in terms of 'pt'
1676 * Convert to pixels using PixelConverter.fromPoint
1677 */
1678 const TextSizeMin: number;
1679 /**
1680 * Stored in terms of 'pt'
1681 * Convert to pixels using PixelConverter.fromPoint
1682 */
1683 const TextSizeMax: number;
1684 /**
1685 * Returns the percentage of this value relative to the TextSizeMax
1686 * @param textSize - should be given in terms of 'pt'
1687 */
1688 function getScale(textSize: number): number;
1689 }
1690 module PixelConverter {
1691 /**
1692 * Appends 'px' to the end of number value for use as pixel string in styles
1693 */
1694 function toString(px: number): string;
1695 /**
1696 * Converts point value (pt) to pixels
1697 * Returns a string for font-size property
1698 * e.g. fromPoint(8) => '24px'
1699 */
1700 function fromPoint(pt: number): string;
1701 /**
1702 * Converts point value (pt) to pixels
1703 * Returns a number for font-size property
1704 * e.g. fromPoint(8) => 24px
1705 */
1706 function fromPointToPixel(pt: number): number;
1707 /**
1708 * Converts pixel value (px) to pt
1709 * e.g. toPoint(24) => 8
1710 */
1711 function toPoint(px: number): number;
1712 }
1713 module RegExpExtensions {
1714 /**
1715 * Runs exec on regex starting from 0 index
1716 * This is the expected behavior but RegExp actually remember
1717 * the last index they stopped at (found match at) and will
1718 * return unexpected results when run in sequence.
1719 * @param regex - regular expression object
1720 * @param value - string to search wiht regex
1721 * @param start - index within value to start regex
1722 */
1723 function run(regex: RegExp, value: string, start?: number): RegExpExecArray;
1724 }
1725}
1726
1727declare module powerbi.visuals.utility {
1728 import IThickness = powerbi.visuals.shapes.IThickness;
1729 module StyleUtils {
1730 function getRotateAngleFromElement(element: JQuery): number;
1731 function getTranslateTransformFromElement(element: JQuery): IPoint;
1732 function getPadding(element: JQuery): IThickness;
1733 }
1734}
1735
1736declare module jsCommon {
1737 interface ITraceListener {
1738 logTrace(trace: TraceItem): void;
1739 }
1740 class ConsoleTracer implements ITraceListener {
1741 logTrace(trace: TraceItem): void;
1742 }
1743 module Trace {
1744 /**
1745 * Trace a warning. Please ensure that no PII is being logged.
1746 */
1747 function warning(text: string, requestId?: string): void;
1748 /**
1749 * Trace an error. Please ensure that no PII is being logged.
1750 */
1751 function error(text: string, includeStackTrace?: boolean, requestId?: string): void;
1752 /**
1753 * Trace an information. Please ensure that no PII is being logged.
1754 */
1755 function verbose(text: string, requestId?: string): void;
1756 function addListener(listener: ITraceListener): void;
1757 function removeListener(listener: ITraceListener): void;
1758 function resetListeners(): void;
1759 function reset(): void;
1760 function getTraces(): Array<TraceItem>;
1761 /**
1762 * Note: Used for unit-test only.
1763 */
1764 function disableDefaultListener(): void;
1765 function enableDefaultListener(): void;
1766 }
1767}
1768
1769declare module jsCommon {
1770 /**
1771 * The types of possible traces within the system, this aligns to the traces available in Cloud Platform.
1772 */
1773 enum TraceType {
1774 Information = 0,
1775 Verbose = 1,
1776 Warning = 2,
1777 Error = 3,
1778 ExpectedError = 4,
1779 UnexpectedError = 5,
1780 Fatal = 6,
1781 }
1782}
1783
1784declare module jsCommon {
1785 function ensurePowerView(action?: () => void): void;
1786 function ensureMap(locale: string, action: () => void): void;
1787 function mapControlLoaded(): void;
1788 function waitForMapControlLoaded(): JQueryPromise<void>;
1789}
1790declare let globalMapControlLoaded: Function;
1791
1792declare module InJs {
1793 /**
1794 * The types of possible traces within the system, this aligns to the traces available in Cloud Platform.
1795 */
1796 enum TraceType {
1797 information = 0,
1798 verbose = 1,
1799 warning = 2,
1800 error = 3,
1801 expectedError = 4,
1802 unexpectedError = 5,
1803 fatal = 6,
1804 }
1805}