-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathplatform.ts
75 lines (65 loc) · 2.2 KB
/
platform.ts
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
// Always import platform-common first - because polyfills
import {
NativeScriptPlatformRef,
AppOptions,
PlatformFactory,
COMMON_PROVIDERS
} from "./platform-common";
import {
ElementSchemaRegistry,
ResourceLoader,
} from "@angular/compiler";
import {
ɵplatformCoreDynamic as platformCoreDynamic
} from "@angular/platform-browser-dynamic";
import {
ɵINTERNAL_BROWSER_PLATFORM_PROVIDERS as INTERNAL_BROWSER_PLATFORM_PROVIDERS
} from "@angular/platform-browser";
import {
COMPILER_OPTIONS,
PlatformRef,
InjectionToken,
ViewEncapsulation,
createPlatformFactory,
MissingTranslationStrategy,
StaticProvider,
} from "@angular/core";
// Work around a TS bug requiring an imports of
// InjectionToken, ViewEncapsulation and MissingTranslationStrategy
// without using them
if ((<any>global).___TS_UNUSED) {
(() => InjectionToken)();
(() => ViewEncapsulation)();
(() => MissingTranslationStrategy)();
}
// Register DOM adapter, if possible. Dynamic platform only!
import "./dom-adapter";
import { NativeScriptElementSchemaRegistry } from "./schema-registry";
import { FileSystemResourceLoader } from "./resource-loader";
export const NS_COMPILER_PROVIDERS: StaticProvider[] = [
INTERNAL_BROWSER_PLATFORM_PROVIDERS,
{
provide: COMPILER_OPTIONS,
useValue: {
providers: [
{ provide: ResourceLoader, useClass: FileSystemResourceLoader, deps: [] },
{ provide: ElementSchemaRegistry, useClass: NativeScriptElementSchemaRegistry, deps: [] },
]
},
multi: true
},
];
// Dynamic platform
const _platformNativeScriptDynamic: PlatformFactory = createPlatformFactory(
platformCoreDynamic, "nativeScriptDynamic", [...COMMON_PROVIDERS, ...NS_COMPILER_PROVIDERS]);
export function platformNativeScriptDynamic(
options?: AppOptions,
extraProviders?: any[]
): PlatformRef {
// Return raw platform to advanced users only if explicitly requested
if (options && options.bootInExistingPage === true) {
return _platformNativeScriptDynamic(extraProviders);
} else {
return new NativeScriptPlatformRef(_platformNativeScriptDynamic(extraProviders), options);
}
}