-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathplatform.ts
64 lines (56 loc) · 1.78 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
// Always import platform-common first - because polyfills
import {
NativeScriptPlatformRef,
AppOptions,
PlatformFactory,
COMMON_PROVIDERS
} from "./platform-common";
import {
ElementSchemaRegistry,
ResourceLoader,
COMPILER_PROVIDERS,
platformCoreDynamic
} from "@angular/compiler";
import {
COMPILER_OPTIONS,
PlatformRef,
OpaqueToken,
createPlatformFactory
} from "@angular/core";
// Work around a TS bug requiring an import of OpaqueToken without using it
if ((<any>global).___TS_UNUSED) {
(() => {
return OpaqueToken;
})();
}
// 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 = [
COMPILER_PROVIDERS,
{
provide: COMPILER_OPTIONS,
useValue: {
providers: [
{ provide: ResourceLoader, useClass: FileSystemResourceLoader },
{ provide: ElementSchemaRegistry, useClass: NativeScriptElementSchemaRegistry },
]
},
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);
}
}