Skip to content

Commit ebbbcca

Browse files
devversionandrewseguin
authored andcommitted
docs: show platform service (#8148)
* No longer marks the `Platform` service from `@angular/cdk/platform` as `docs-private`. The platform service should be documented since it's useful and likely the only thing in the platform entry-point.
1 parent 44d61b2 commit ebbbcca

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

src/cdk/platform/platform.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,47 @@ const hasV8BreakIterator = (typeof(Intl) !== 'undefined' && (Intl as any).v8Brea
1515
/**
1616
* Service to detect the current platform by comparing the userAgent strings and
1717
* checking browser-specific global properties.
18-
* @docs-private
1918
*/
2019
@Injectable()
2120
export class Platform {
21+
/** Whether the Angular application is being rendered in the browser. */
2222
isBrowser: boolean = typeof document === 'object' && !!document;
2323

24-
/** Layout Engines */
25-
EDGE = this.isBrowser && /(edge)/i.test(navigator.userAgent);
26-
TRIDENT = this.isBrowser && /(msie|trident)/i.test(navigator.userAgent);
24+
/** Whether the current browser is Microsoft Edge. */
25+
EDGE: boolean = this.isBrowser && /(edge)/i.test(navigator.userAgent);
2726

27+
/** Whether the current rendering engine is Microsoft Trident. */
28+
TRIDENT: boolean = this.isBrowser && /(msie|trident)/i.test(navigator.userAgent);
29+
30+
/** Whether the current rendering engine is Blink. */
2831
// EdgeHTML and Trident mock Blink specific things and need to be excluded from this check.
29-
BLINK = this.isBrowser &&
32+
BLINK: boolean = this.isBrowser &&
3033
(!!((window as any).chrome || hasV8BreakIterator) && !!CSS && !this.EDGE && !this.TRIDENT);
3134

35+
/** Whether the current rendering engine is WebKit. */
3236
// Webkit is part of the userAgent in EdgeHTML, Blink and Trident. Therefore we need to
3337
// ensure that Webkit runs standalone and is not used as another engine's base.
34-
WEBKIT = this.isBrowser &&
38+
WEBKIT: boolean = this.isBrowser &&
3539
/AppleWebKit/i.test(navigator.userAgent) && !this.BLINK && !this.EDGE && !this.TRIDENT;
3640

37-
/** Browsers and Platform Types */
38-
IOS = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream;
41+
/** Whether the current platform is Apple iOS. */
42+
IOS: boolean = this.isBrowser && /iPad|iPhone|iPod/.test(navigator.userAgent) &&
43+
!(window as any).MSStream;
3944

45+
/** Whether the current browser is Firefox. */
4046
// It's difficult to detect the plain Gecko engine, because most of the browsers identify
4147
// them self as Gecko-like browsers and modify the userAgent's according to that.
4248
// Since we only cover one explicit Firefox case, we can simply check for Firefox
4349
// instead of having an unstable check for Gecko.
44-
FIREFOX = this.isBrowser && /(firefox|minefield)/i.test(navigator.userAgent);
50+
FIREFOX: boolean = this.isBrowser && /(firefox|minefield)/i.test(navigator.userAgent);
4551

52+
/** Whether the current platform is Android. */
4653
// Trident on mobile adds the android platform to the userAgent to trick detections.
47-
ANDROID = this.isBrowser && /android/i.test(navigator.userAgent) && !this.TRIDENT;
54+
ANDROID: boolean = this.isBrowser && /android/i.test(navigator.userAgent) && !this.TRIDENT;
4855

56+
/** Whether the current browser is Safari. */
4957
// Safari browsers will include the Safari keyword in their userAgent. Some browsers may fake
5058
// this and just place the Safari keyword in the userAgent. To be more safe about Safari every
5159
// Safari browser should also use Webkit as its layout engine.
52-
SAFARI = this.isBrowser && /safari/i.test(navigator.userAgent) && this.WEBKIT;
60+
SAFARI: boolean = this.isBrowser && /safari/i.test(navigator.userAgent) && this.WEBKIT;
5361
}

0 commit comments

Comments
 (0)