FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
nativescript-angular/nativescript-angular/application.ts at master · TopDevOps/nativescript-angular · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
TopDevOps
/
nativescript-angular
Public
forked from
NativeScript/nativescript-angular
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
nativescript-angular
/
nativescript-angular
/
application.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
209 lines (173 loc) · 7.47 KB
Breadcrumbs
nativescript-angular
/
nativescript-angular
/
application.ts
Copy path
File metadata and controls
209 lines (173 loc) · 7.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import
'globals'
;
import
"zone.js/dist/zone-node"
;
import
'reflect-metadata'
;
import
'./polyfills/array'
;
import
'./polyfills/console'
;
import
{
rendererLog
,
rendererError
}
from
"./trace"
;
import
{
SanitizationService
}
from
'@angular/core/src/security'
;
import
{
isPresent
,
Type
,
print
}
from
'@angular/core/src/facade/lang'
;
import
{
ReflectiveInjector
,
coreLoadAndBootstrap
,
createPlatform
,
EventEmitter
,
getPlatform
,
ComponentRef
,
PLATFORM_DIRECTIVES
,
PLATFORM_PIPES
}
from
'@angular/core'
;
import
{
provide
,
Provider
}
from
'@angular/core/src/di'
;
import
{
RootRenderer
,
Renderer
}
from
'@angular/core/src/render/api'
;
import
{
NativeScriptRootRenderer
,
NativeScriptRenderer
}
from
'./renderer'
;
import
{
NativeScriptDomAdapter
,
NativeScriptElementSchemaRegistry
,
NativeScriptSanitizationService
}
from
'./dom-adapter'
;
import
{
ElementSchemaRegistry
,
XHR
,
COMPILER_PROVIDERS
,
CompilerConfig
}
from
'@angular/compiler'
;
import
{
FileSystemXHR
}
from
'./http/xhr'
;
import
{
ExceptionHandler
}
from
'@angular/core/src/facade/exception_handler'
;
import
{
APPLICATION_COMMON_PROVIDERS
}
from
'@angular/core/src/application_common_providers'
;
import
{
PLATFORM_COMMON_PROVIDERS
}
from
'@angular/core/src/platform_common_providers'
;
import
{
COMMON_DIRECTIVES
,
COMMON_PIPES
,
FORM_PROVIDERS
}
from
"@angular/common"
;
import
{
NS_DIRECTIVES
}
from
'./directives'
;
import
{
Page
}
from
'ui/page'
;
import
{
TextView
}
from
'ui/text-view'
;
import
application
=
require
(
'application'
)
;
import
{
topmost
,
NavigationEntry
}
from
"ui/frame"
;
export
type
ProviderArray
=
Array
<
Type
|
Provider
|
any
[
]
>
;
import
{
defaultPageProvider
,
defaultFrameProvider
,
defaultDeviceProvider
,
defaultAnimationDriverProvider
}
from
"./platform-providers"
;
import
*
as
nativescriptIntl
from
"nativescript-intl"
;
global
.
Intl
=
nativescriptIntl
;
export
interface
AppOptions
{
cssFile
?:
string
;
startPageActionBarHidden
?:
boolean
;
}
class
ConsoleLogger
{
log
=
print
;
logError
=
print
;
logGroup
=
print
;
logGroupEnd
(
)
{
}
}
interface
BootstrapParams
{
appComponentType
:
Type
,
customProviders
?:
ProviderArray
,
appOptions
?:
AppOptions
}
let
bootstrapCache
:
BootstrapParams
;
let
lastBootstrappedApp
:
WeakRef
<
ComponentRef
<
any
>
>
;
export
const
onBeforeLivesync
=
new
EventEmitter
<
ComponentRef
<
any
>
>
(
)
;
export
const
onAfterLivesync
=
new
EventEmitter
<
ComponentRef
<
any
>
>
(
)
;
// See: https://github.com/angular/angular/commit/1745366530266d298306b995ecd23dabd8569e28
export
const
NS_COMPILER_PROVIDERS
:
ProviderArray
=
[
COMPILER_PROVIDERS
,
provide
(
CompilerConfig
,
{
useFactory
:
(
platformDirectives
:
any
[
]
,
platformPipes
:
any
[
]
)
=>
{
return
new
CompilerConfig
(
{
platformDirectives
,
platformPipes
}
)
;
}
,
deps
:
[
PLATFORM_DIRECTIVES
,
PLATFORM_PIPES
]
}
)
,
provide
(
XHR
,
{
useClass
:
FileSystemXHR
}
)
,
provide
(
PLATFORM_PIPES
,
{
useValue
:
COMMON_PIPES
,
multi
:
true
}
)
,
provide
(
PLATFORM_DIRECTIVES
,
{
useValue
:
COMMON_DIRECTIVES
,
multi
:
true
}
)
,
provide
(
PLATFORM_DIRECTIVES
,
{
useValue
:
NS_DIRECTIVES
,
multi
:
true
}
)
]
;
export
function
bootstrap
(
appComponentType
:
any
,
customProviders
:
ProviderArray
=
null
)
:
Promise
<
ComponentRef
<
any
>
>
{
NativeScriptDomAdapter
.
makeCurrent
(
)
;
let
platformProviders
:
ProviderArray
=
[
PLATFORM_COMMON_PROVIDERS
,
]
;
let
defaultAppProviders
:
ProviderArray
=
[
APPLICATION_COMMON_PROVIDERS
,
FORM_PROVIDERS
,
provide
(
ExceptionHandler
,
{
useFactory
:
(
)
=>
{
return
new
ExceptionHandler
(
new
ConsoleLogger
(
)
,
true
)
}
,
deps
:
[
]
}
)
,
defaultFrameProvider
,
defaultPageProvider
,
defaultDeviceProvider
,
defaultAnimationDriverProvider
,
NativeScriptRootRenderer
,
provide
(
RootRenderer
,
{
useClass
:
NativeScriptRootRenderer
}
)
,
NativeScriptRenderer
,
provide
(
Renderer
,
{
useClass
:
NativeScriptRenderer
}
)
,
provide
(
SanitizationService
,
{
useClass
:
NativeScriptSanitizationService
}
)
,
provide
(
ElementSchemaRegistry
,
{
useClass
:
NativeScriptElementSchemaRegistry
}
)
,
NS_COMPILER_PROVIDERS
,
provide
(
ElementSchemaRegistry
,
{
useClass
:
NativeScriptElementSchemaRegistry
}
)
,
provide
(
XHR
,
{
useClass
:
FileSystemXHR
}
)
]
;
let
appProviders
=
[
defaultAppProviders
]
;
if
(
isPresent
(
customProviders
)
)
{
appProviders
.
push
(
customProviders
)
;
}
let
platform
=
getPlatform
(
)
;
if
(
!
isPresent
(
platform
)
)
{
platform
=
createPlatform
(
ReflectiveInjector
.
resolveAndCreate
(
platformProviders
)
)
;
}
let
appInjector
=
ReflectiveInjector
.
resolveAndCreate
(
appProviders
,
platform
.
injector
)
;
return
coreLoadAndBootstrap
(
appComponentType
,
appInjector
)
;
}
function
createNavigationEntry
(
params
:
BootstrapParams
,
resolve
?:
(
comp
:
ComponentRef
<
any
>
)
=>
void
,
reject
?:
(
e
:
Error
)
=>
void
,
isReboot
:
boolean
=
false
)
{
const
navEntry
:
NavigationEntry
=
{
create
:
(
)
:
Page
=>
{
let
page
=
new
Page
(
)
;
if
(
params
.
appOptions
)
{
page
.
actionBarHidden
=
params
.
appOptions
.
startPageActionBarHidden
;
}
let
onLoadedHandler
=
function
(
args
)
{
page
.
off
(
'loaded'
,
onLoadedHandler
)
;
//profiling.stop('application-start');
rendererLog
(
'Page loaded'
)
;
//profiling.start('ng-bootstrap');
rendererLog
(
'BOOTSTRAPPING...'
)
;
bootstrap
(
params
.
appComponentType
,
params
.
customProviders
)
.
then
(
(
compRef
)
=>
{
//profiling.stop('ng-bootstrap');
rendererLog
(
'ANGULAR BOOTSTRAP DONE.'
)
;
lastBootstrappedApp
=
new
WeakRef
(
compRef
)
;
if
(
resolve
)
{
resolve
(
compRef
)
;
}
}
,
(
err
)
=>
{
rendererError
(
'ERROR BOOTSTRAPPING ANGULAR'
)
;
let
errorMessage
=
err
.
message
+
"\n\n"
+
err
.
stack
;
rendererError
(
errorMessage
)
;
let
view
=
new
TextView
(
)
;
view
.
text
=
errorMessage
;
page
.
content
=
view
;
if
(
reject
)
{
reject
(
err
)
;
}
}
)
;
}
;
page
.
on
(
'loaded'
,
onLoadedHandler
)
;
return
page
;
}
}
;
if
(
isReboot
)
{
navEntry
.
animated
=
false
;
navEntry
.
clearHistory
=
true
;
}
return
navEntry
;
}
export
function
nativeScriptBootstrap
(
appComponentType
:
any
,
customProviders
?:
ProviderArray
,
appOptions
?:
AppOptions
)
:
void
{
bootstrapCache
=
{
appComponentType
,
customProviders
,
appOptions
}
;
if
(
appOptions
&&
appOptions
.
cssFile
)
{
application
.
cssFile
=
appOptions
.
cssFile
;
}
const
navEntry
=
createNavigationEntry
(
bootstrapCache
)
;
application
.
start
(
navEntry
)
;
}
// Patch livesync
const
_baseLiveSyncCore
=
global
.
__onLiveSyncCore
;
global
.
__onLiveSyncCore
=
function
(
)
{
rendererLog
(
"ANGULAR LiveSync Started"
)
;
if
(
bootstrapCache
)
{
onBeforeLivesync
.
next
(
lastBootstrappedApp
?
lastBootstrappedApp
.
get
(
)
:
null
)
;
const
frame
=
topmost
(
)
;
const
newEntry
=
createNavigationEntry
(
bootstrapCache
,
compRef
=>
onAfterLivesync
.
next
(
compRef
)
,
error
=>
onAfterLivesync
.
error
(
error
)
,
true
)
;
if
(
frame
)
{
if
(
frame
.
currentPage
&&
frame
.
currentPage
.
modal
)
{
frame
.
currentPage
.
modal
.
closeModal
(
)
;
}
frame
.
navigate
(
newEntry
)
;
}
}
else
{
_baseLiveSyncCore
(
)
;
}
}
;
Back
|
FazBrowse Home
|
New Git URL