@nativescript/compiler-angular 0.0.0-stage → 9.2.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,431 @@
1
+ package org.nativescript.kit
2
+
3
+ import java.util.IdentityHashMap
4
+
5
+ // @angular/common/http value types
6
+
7
+ class HttpHeaders(headers: Any? = null) {
8
+ private val storage = LinkedHashMap<String, MutableList<String>>()
9
+ private val originalNames = LinkedHashMap<String, String>()
10
+
11
+ init {
12
+ val flat = jsBox(headers)
13
+ if (flat is String) {
14
+ for (line in flat.split("\n")) {
15
+ val colon = line.indexOf(':')
16
+ if (colon > 0) {
17
+ val name = line.substring(0, colon).trim()
18
+ val value = line.substring(colon + 1).trim()
19
+ appendInPlace(name, value)
20
+ }
21
+ }
22
+ } else if (flat != null) {
23
+ for (k in jsKeysOf(flat)) {
24
+ val v = jsGetOptional(flat, k)
25
+ if (jsIsNullish(v)) continue
26
+ val lower = k.lowercase()
27
+ if (!originalNames.containsKey(lower)) originalNames[lower] = k
28
+ val box = jsBox(v)
29
+ if (box is JSArray<*>) {
30
+ storage[lower] = box.storage.map { jsToString(it) }.toMutableList()
31
+ } else {
32
+ storage[lower] = mutableListOf(jsToString(v))
33
+ }
34
+ }
35
+ }
36
+ }
37
+
38
+ private fun appendInPlace(name: String, value: Any?) {
39
+ val lower = name.lowercase()
40
+ if (!originalNames.containsKey(lower)) originalNames[lower] = name
41
+ val list = storage.getOrPut(lower) { mutableListOf() }
42
+ val box = jsBox(value)
43
+ if (box is JSArray<*>) {
44
+ for (item in box.storage) list.add(jsToString(item))
45
+ } else {
46
+ list.add(jsToString(value))
47
+ }
48
+ }
49
+
50
+ private fun cloned(): HttpHeaders {
51
+ val copy = HttpHeaders()
52
+ for ((k, v) in storage) copy.storage[k] = v.toMutableList()
53
+ copy.originalNames.putAll(originalNames)
54
+ return copy
55
+ }
56
+
57
+ fun has(name: String): Boolean = storage.containsKey(name.lowercase())
58
+
59
+ fun get(name: String): String? = storage[name.lowercase()]?.firstOrNull()
60
+
61
+ fun keys(): JSArray<String> = JSArray(originalNames.values.toMutableList())
62
+
63
+ fun getAll(name: String): JSArray<String>? {
64
+ val vals = storage[name.lowercase()] ?: return null
65
+ return JSArray(vals.toMutableList())
66
+ }
67
+
68
+ fun append(name: String, value: Any?): HttpHeaders {
69
+ val next = cloned()
70
+ next.appendInPlace(name, value)
71
+ return next
72
+ }
73
+
74
+ fun set(name: String, value: Any?): HttpHeaders {
75
+ val next = cloned()
76
+ val lower = name.lowercase()
77
+ next.originalNames[lower] = name
78
+ val box = jsBox(value)
79
+ next.storage[lower] = if (box is JSArray<*>) {
80
+ box.storage.map { jsToString(it) }.toMutableList()
81
+ } else {
82
+ mutableListOf(jsToString(value))
83
+ }
84
+ return next
85
+ }
86
+
87
+ fun delete(name: String, value: Any? = null): HttpHeaders {
88
+ val next = cloned()
89
+ val lower = name.lowercase()
90
+ if (jsIsNullish(value)) {
91
+ next.storage.remove(lower)
92
+ next.originalNames.remove(lower)
93
+ } else {
94
+ val existing = next.storage[lower]
95
+ if (existing != null) {
96
+ val box = jsBox(value)
97
+ val removeSet = if (box is JSArray<*>) box.storage.map { jsToString(it) }.toSet() else setOf(jsToString(value))
98
+ val filtered = existing.filter { it !in removeSet }.toMutableList()
99
+ if (filtered.isEmpty()) {
100
+ next.storage.remove(lower)
101
+ next.originalNames.remove(lower)
102
+ } else {
103
+ next.storage[lower] = filtered
104
+ }
105
+ }
106
+ }
107
+ return next
108
+ }
109
+
110
+ fun toJSObject(): JSObject {
111
+ val pairs = mutableListOf<Pair<String, Any?>>()
112
+ for ((lower, vals) in storage) {
113
+ val orig = originalNames[lower] ?: lower
114
+ pairs.add(orig to vals.joinToString(", "))
115
+ }
116
+ return JSObject(pairs)
117
+ }
118
+ }
119
+
120
+ class HttpParams(options: Any? = null) : JSStringConvertible {
121
+ private val storage = LinkedHashMap<String, MutableList<String>>()
122
+
123
+ init {
124
+ val flat = jsBox(options)
125
+ if (flat != null) {
126
+ val fromString = jsGetOptional(flat, "fromString") as? String
127
+ if (fromString != null) {
128
+ val trimmed = if (fromString.startsWith("?")) fromString.substring(1) else fromString
129
+ if (trimmed.isNotEmpty()) {
130
+ for (part in trimmed.split("&")) {
131
+ if (part.isEmpty()) continue
132
+ val eq = part.indexOf('=')
133
+ if (eq >= 0) {
134
+ appendInPlace(jsDecodeURIComponent(part.substring(0, eq)), jsDecodeURIComponent(part.substring(eq + 1)))
135
+ } else {
136
+ appendInPlace(jsDecodeURIComponent(part), "")
137
+ }
138
+ }
139
+ }
140
+ } else {
141
+ val fromObj = jsGetOptional(flat, "fromObject")
142
+ val source: Any? = if (!jsIsNullish(fromObj)) fromObj else flat
143
+ for (k in jsKeysOf(source)) {
144
+ if (k == "fromString" || k == "fromObject" || k == "encoder") continue
145
+ val v = jsGetOptional(source, k)
146
+ if (jsIsNullish(v)) continue
147
+ val box = jsBox(v)
148
+ if (box is JSArray<*>) {
149
+ storage[k] = box.storage.map { jsToString(it) }.toMutableList()
150
+ } else {
151
+ storage[k] = mutableListOf(jsToString(v))
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+
158
+ private fun appendInPlace(param: String, value: Any?) {
159
+ storage.getOrPut(param) { mutableListOf() }.add(jsToString(value))
160
+ }
161
+
162
+ private fun cloned(): HttpParams {
163
+ val copy = HttpParams()
164
+ for ((k, v) in storage) copy.storage[k] = v.toMutableList()
165
+ return copy
166
+ }
167
+
168
+ fun has(param: String): Boolean = storage.containsKey(param)
169
+
170
+ fun get(param: String): String? = storage[param]?.firstOrNull()
171
+
172
+ fun getAll(param: String): JSArray<String>? {
173
+ val vals = storage[param] ?: return null
174
+ return JSArray(vals.toMutableList())
175
+ }
176
+
177
+ fun keys(): JSArray<String> = JSArray(storage.keys.toMutableList())
178
+
179
+ fun append(param: String, value: Any?): HttpParams {
180
+ val next = cloned()
181
+ next.appendInPlace(param, value)
182
+ return next
183
+ }
184
+
185
+ fun appendAll(params: Any?): HttpParams {
186
+ val next = cloned()
187
+ val flat = jsBox(params) ?: return next
188
+ for (k in jsKeysOf(flat)) {
189
+ val v = jsGetOptional(flat, k)
190
+ if (jsIsNullish(v)) continue
191
+ val box = jsBox(v)
192
+ if (box is JSArray<*>) {
193
+ for (item in box.storage) next.appendInPlace(k, item)
194
+ } else {
195
+ next.appendInPlace(k, v)
196
+ }
197
+ }
198
+ return next
199
+ }
200
+
201
+ fun set(param: String, value: Any?): HttpParams {
202
+ val next = cloned()
203
+ next.storage[param] = mutableListOf(jsToString(value))
204
+ return next
205
+ }
206
+
207
+ fun delete(param: String, value: Any? = null): HttpParams {
208
+ val next = cloned()
209
+ if (jsIsNullish(value)) {
210
+ next.storage.remove(param)
211
+ } else {
212
+ val existing = next.storage[param]
213
+ if (existing != null) {
214
+ val target = jsToString(value)
215
+ val filtered = existing.filter { it != target }.toMutableList()
216
+ if (filtered.isEmpty()) next.storage.remove(param)
217
+ else next.storage[param] = filtered
218
+ }
219
+ }
220
+ return next
221
+ }
222
+
223
+ override fun toString(): String {
224
+ val parts = mutableListOf<String>()
225
+ for ((k, vals) in storage) {
226
+ val ek = jsEncodeURIComponent(k)
227
+ for (v in vals) {
228
+ parts.add("$ek=${jsEncodeURIComponent(v)}")
229
+ }
230
+ }
231
+ return parts.joinToString("&")
232
+ }
233
+ }
234
+
235
+ class HttpContextToken(val defaultValue: () -> Any?)
236
+
237
+ class HttpContext {
238
+ private val map = IdentityHashMap<HttpContextToken, Any?>()
239
+ fun set(token: HttpContextToken, value: Any?): HttpContext {
240
+ map[token] = value
241
+ return this
242
+ }
243
+ fun get(token: HttpContextToken): Any? {
244
+ if (!map.containsKey(token)) map[token] = token.defaultValue()
245
+ return map[token]
246
+ }
247
+ fun delete(token: HttpContextToken): HttpContext {
248
+ map.remove(token)
249
+ return this
250
+ }
251
+ fun has(token: HttpContextToken): Boolean = map.containsKey(token)
252
+ }
253
+
254
+ class HttpResponse(options: Any? = null) {
255
+ val body: Any?
256
+ val headers: HttpHeaders
257
+ val status: Double
258
+ val statusText: String
259
+ val url: String?
260
+ val ok: Boolean
261
+ val type: Double = 4.0
262
+
263
+ init {
264
+ val flat = jsBox(options)
265
+ body = jsGetOptional(flat, "body")
266
+ val h = jsBox(jsGetOptional(flat, "headers"))
267
+ headers = (h as? HttpHeaders) ?: HttpHeaders(h)
268
+ val st = jsGetOptional(flat, "status").let { if (jsIsNullish(it)) 200.0 else jsToNumber(it) }
269
+ status = st
270
+ statusText = (jsGetOptional(flat, "statusText") as? String) ?: "OK"
271
+ url = jsGetOptional(flat, "url") as? String
272
+ ok = st >= 200.0 && st < 300.0
273
+ }
274
+
275
+ fun clone(update: Any? = null): HttpResponse {
276
+ val flat = jsBox(update)
277
+ val hasBody = flat is JSDynamic && "body" in flat.jsKeys
278
+ val nextBody = if (hasBody) jsGetOptional(flat, "body") else body
279
+ val nextHeaders = (jsBox(jsGetOptional(flat, "headers")) as? HttpHeaders) ?: headers
280
+ val nextStatus = jsGetOptional(flat, "status").let { if (jsIsNullish(it)) status else jsToNumber(it) }
281
+ val nextStatusText = (jsGetOptional(flat, "statusText") as? String) ?: statusText
282
+ val nextUrl = (jsGetOptional(flat, "url") as? String) ?: url
283
+ return HttpResponse(JSObject(
284
+ "body" to nextBody,
285
+ "headers" to nextHeaders,
286
+ "status" to nextStatus,
287
+ "statusText" to nextStatusText,
288
+ "url" to nextUrl,
289
+ ))
290
+ }
291
+ }
292
+
293
+ class HttpErrorResponse(options: Any? = null) : JSError(
294
+ run {
295
+ val flat = jsBox(options)
296
+ val st = jsGetOptional(flat, "status").let { if (jsIsNullish(it)) 0.0 else jsToNumber(it) }
297
+ val stText = (jsGetOptional(flat, "statusText") as? String) ?: "Unknown Error"
298
+ val u = (jsGetOptional(flat, "url") as? String) ?: "(unknown url)"
299
+ "Http failure response for $u: ${jsToString(st)} $stText"
300
+ }
301
+ ) {
302
+ val error: Any?
303
+ val headers: HttpHeaders
304
+ val status: Double
305
+ val statusText: String
306
+ val url: String?
307
+ val ok: Boolean = false
308
+
309
+ init {
310
+ name = "HttpErrorResponse"
311
+ val flat = jsBox(options)
312
+ error = jsGetOptional(flat, "error")
313
+ val h = jsBox(jsGetOptional(flat, "headers"))
314
+ headers = (h as? HttpHeaders) ?: HttpHeaders(h)
315
+ status = jsGetOptional(flat, "status").let { if (jsIsNullish(it)) 0.0 else jsToNumber(it) }
316
+ statusText = (jsGetOptional(flat, "statusText") as? String) ?: "Unknown Error"
317
+ url = jsGetOptional(flat, "url") as? String
318
+ }
319
+ }
320
+
321
+ class HttpRequest(
322
+ method: String,
323
+ val url: String,
324
+ third: Any? = null,
325
+ fourth: Any? = null,
326
+ ) {
327
+ val method: String = method.uppercase()
328
+ val body: Any?
329
+ val headers: HttpHeaders
330
+ val params: HttpParams
331
+ val context: HttpContext
332
+ val responseType: String
333
+ val withCredentials: Boolean
334
+ val reportProgress: Boolean
335
+
336
+ init {
337
+ val hasBody = fourth != null || this.method == "POST" || this.method == "PUT" || this.method == "PATCH" || this.method == "JSONP"
338
+ body = if (hasBody) third else null
339
+ val opt = jsBox(if (hasBody) fourth else third)
340
+ val h = jsBox(jsGetOptional(opt, "headers"))
341
+ headers = (h as? HttpHeaders) ?: HttpHeaders(h)
342
+ val p = jsBox(jsGetOptional(opt, "params"))
343
+ params = (p as? HttpParams) ?: HttpParams(p)
344
+ context = (jsBox(jsGetOptional(opt, "context")) as? HttpContext) ?: HttpContext()
345
+ responseType = (jsGetOptional(opt, "responseType") as? String) ?: "json"
346
+ withCredentials = jsTruthy(jsGetOptional(opt, "withCredentials") ?: false)
347
+ reportProgress = jsTruthy(jsGetOptional(opt, "reportProgress") ?: false)
348
+ }
349
+
350
+ val urlWithParams: String
351
+ get() {
352
+ val q = params.toString()
353
+ if (q.isEmpty()) return url
354
+ return if (url.contains("?")) "$url&$q" else "$url?$q"
355
+ }
356
+
357
+ fun clone(update: Any? = null): HttpRequest {
358
+ val flat = jsBox(update)
359
+ val nextMethod = (jsGetOptional(flat, "method") as? String) ?: method
360
+ val nextUrl = (jsGetOptional(flat, "url") as? String) ?: url
361
+ val hasBody = flat is JSDynamic && "body" in flat.jsKeys
362
+ val nextBody = if (hasBody) jsGetOptional(flat, "body") else body
363
+ var nextHeaders = (jsBox(jsGetOptional(flat, "headers")) as? HttpHeaders) ?: headers
364
+ val setHeaders = jsBox(jsGetOptional(flat, "setHeaders"))
365
+ if (setHeaders != null) {
366
+ for (k in jsKeysOf(setHeaders)) {
367
+ nextHeaders = nextHeaders.set(k, jsGetOptional(setHeaders, k))
368
+ }
369
+ }
370
+ var nextParams = (jsBox(jsGetOptional(flat, "params")) as? HttpParams) ?: params
371
+ val setParams = jsBox(jsGetOptional(flat, "setParams"))
372
+ if (setParams != null) {
373
+ for (k in jsKeysOf(setParams)) {
374
+ nextParams = nextParams.set(k, jsGetOptional(setParams, k))
375
+ }
376
+ }
377
+ val nextContext = (jsBox(jsGetOptional(flat, "context")) as? HttpContext) ?: context
378
+ val nextRespType = (jsGetOptional(flat, "responseType") as? String) ?: responseType
379
+ val nextCreds = jsGetOptional(flat, "withCredentials")?.let { jsTruthy(it) } ?: withCredentials
380
+ val nextProg = jsGetOptional(flat, "reportProgress")?.let { jsTruthy(it) } ?: reportProgress
381
+ return HttpRequest(nextMethod, nextUrl, nextBody, JSObject(
382
+ "headers" to nextHeaders,
383
+ "params" to nextParams,
384
+ "context" to nextContext,
385
+ "responseType" to nextRespType,
386
+ "withCredentials" to nextCreds,
387
+ "reportProgress" to nextProg,
388
+ ))
389
+ }
390
+ }
391
+
392
+ val HTTP_INTERCEPTORS = InjectionToken("HTTP_INTERCEPTORS")
393
+
394
+ val HttpStatusCode = JSObject(
395
+ "Continue" to 100.0,
396
+ "SwitchingProtocols" to 101.0,
397
+ "Ok" to 200.0,
398
+ "Created" to 201.0,
399
+ "Accepted" to 202.0,
400
+ "NoContent" to 204.0,
401
+ "MovedPermanently" to 301.0,
402
+ "Found" to 302.0,
403
+ "NotModified" to 304.0,
404
+ "BadRequest" to 400.0,
405
+ "Unauthorized" to 401.0,
406
+ "Forbidden" to 403.0,
407
+ "NotFound" to 404.0,
408
+ "MethodNotAllowed" to 405.0,
409
+ "Conflict" to 409.0,
410
+ "UnprocessableEntity" to 422.0,
411
+ "TooManyRequests" to 429.0,
412
+ "InternalServerError" to 500.0,
413
+ "BadGateway" to 502.0,
414
+ "ServiceUnavailable" to 503.0,
415
+ "GatewayTimeout" to 504.0,
416
+ )
417
+
418
+ fun withInterceptors(fns: Any?): Any? = JSObject("__kind" to "withInterceptors", "fns" to fns)
419
+ fun withInterceptorsFromDi(): Any? = JSObject("__kind" to "withInterceptorsFromDi")
420
+ fun withFetch(): Any? = JSObject("__kind" to "withFetch")
421
+ fun provideHttpClient(@Suppress("UNUSED_PARAMETER") vararg features: Any?): Any? = JSArray<Any?>()
422
+ fun provideNativeScriptHttpClient(@Suppress("UNUSED_PARAMETER") vararg features: Any?): Any? = JSArray<Any?>()
423
+ fun provideNativeScriptNgZone(@Suppress("UNUSED_PARAMETER") options: Any? = null): Any? = JSArray<Any?>()
424
+ fun provideRouter(@Suppress("UNUSED_PARAMETER") routes: Any? = null, @Suppress("UNUSED_PARAMETER") vararg features: Any?): Any? = JSArray<Any?>()
425
+ fun provideNativeScriptRouter(@Suppress("UNUSED_PARAMETER") routes: Any? = null, @Suppress("UNUSED_PARAMETER") vararg features: Any?): Any? = JSArray<Any?>()
426
+
427
+ class HttpClientModule {
428
+ companion object {
429
+ fun forRoot(): Any? = JSObject("ngModule" to HttpClientModule::class.java)
430
+ }
431
+ }
@@ -0,0 +1,154 @@
1
+ package org.nativescript.kit
2
+
3
+ // @angular/router value types
4
+
5
+ class ParamMap(params: Any? = null) {
6
+ private val storage = LinkedHashMap<String, List<String>>()
7
+
8
+ init {
9
+ val flat = jsBox(params)
10
+ if (flat is Map<*, *>) {
11
+ for ((k, v) in flat) {
12
+ if (k != null && v != null) storage[k.toString()] = listOf(v.toString())
13
+ }
14
+ } else if (flat != null) {
15
+ for (k in jsKeysOf(flat)) {
16
+ val v = jsGetOptional(flat, k)
17
+ if (jsIsNullish(v)) continue
18
+ val box = jsBox(v)
19
+ storage[k] = if (box is JSArray<*>) box.storage.map { jsToString(it) } else listOf(jsToString(v))
20
+ }
21
+ }
22
+ }
23
+
24
+ fun has(name: String): Boolean = storage.containsKey(name)
25
+ fun get(name: String): String? = storage[name]?.firstOrNull()
26
+ fun getAll(name: String): JSArray<String> = JSArray((storage[name] ?: emptyList()).toMutableList())
27
+ val keys: JSArray<String> get() = JSArray(storage.keys.toMutableList())
28
+ }
29
+
30
+ fun convertToParamMap(params: Any?): ParamMap = ParamMap(params)
31
+
32
+ class UrlSegment(val path: String, parameters: Any? = null) : JSStringConvertible {
33
+ val parameters: JSRecord<String>
34
+ val parameterMap: ParamMap
35
+
36
+ init {
37
+ val pairs = mutableListOf<Pair<String, String>>()
38
+ val flat = jsBox(parameters)
39
+ if (flat is Map<*, *>) {
40
+ for ((k, v) in flat) if (k != null && v != null) pairs.add(k.toString() to v.toString())
41
+ } else if (flat != null) {
42
+ for (k in jsKeysOf(flat)) {
43
+ val v = jsGetOptional(flat, k)
44
+ if (!jsIsNullish(v)) pairs.add(k to jsToString(v))
45
+ }
46
+ }
47
+ this.parameters = JSRecord(pairs)
48
+ this.parameterMap = ParamMap(this.parameters)
49
+ }
50
+
51
+ override fun toString(): String = path
52
+ }
53
+
54
+ class UrlTree(
55
+ path: String = "/",
56
+ queryParams: Any? = null,
57
+ var fragment: String? = null,
58
+ ) : JSStringConvertible {
59
+ private val path: String = path.ifEmpty { "/" }
60
+ var queryParams: JSObject = run {
61
+ val flat = jsBox(queryParams)
62
+ if (flat is JSObject) flat
63
+ else if (flat != null) {
64
+ val pairs = mutableListOf<Pair<String, Any?>>()
65
+ for (k in jsKeysOf(flat)) pairs.add(k to jsGetOptional(flat, k))
66
+ JSObject(pairs)
67
+ } else JSObject()
68
+ }
69
+
70
+ val queryParamMap: ParamMap get() = ParamMap(queryParams)
71
+
72
+ override fun toString(): String {
73
+ val qParts = mutableListOf<String>()
74
+ for (k in jsKeysOf(queryParams)) {
75
+ val v = jsGetOptional(queryParams, k)
76
+ if (!jsIsNullish(v)) {
77
+ qParts.add("${jsEncodeURIComponent(k)}=${jsEncodeURIComponent(jsToString(v))}")
78
+ }
79
+ }
80
+ val q = if (qParts.isEmpty()) "" else "?${qParts.joinToString("&")}"
81
+ val f = if (fragment != null) "#$fragment" else ""
82
+ return "$path$q$f"
83
+ }
84
+ }
85
+
86
+ class DefaultUrlSerializer {
87
+ fun parse(url: String): UrlTree {
88
+ var raw = url.ifEmpty { "/" }
89
+ var fragment: String? = null
90
+ val hashIdx = raw.indexOf('#')
91
+ if (hashIdx >= 0) {
92
+ fragment = raw.substring(hashIdx + 1)
93
+ raw = raw.substring(0, hashIdx)
94
+ }
95
+ val qPairs = mutableListOf<Pair<String, Any?>>()
96
+ val qIdx = raw.indexOf('?')
97
+ if (qIdx >= 0) {
98
+ val qStr = raw.substring(qIdx + 1)
99
+ raw = raw.substring(0, qIdx)
100
+ for (part in qStr.split("&")) {
101
+ if (part.isEmpty()) continue
102
+ val eq = part.indexOf('=')
103
+ if (eq >= 0) {
104
+ qPairs.add(jsDecodeURIComponent(part.substring(0, eq)) to jsDecodeURIComponent(part.substring(eq + 1)))
105
+ } else {
106
+ qPairs.add(jsDecodeURIComponent(part) to "")
107
+ }
108
+ }
109
+ }
110
+ return UrlTree(raw.ifEmpty { "/" }, JSObject(qPairs), fragment)
111
+ }
112
+
113
+ fun serialize(tree: UrlTree): String = tree.toString()
114
+ }
115
+
116
+ class ActivatedRouteSnapshot(
117
+ val params: JSRecord<String> = JSRecord(),
118
+ val queryParams: JSRecord<String> = JSRecord(),
119
+ val data: JSRecord<Any?> = JSRecord(),
120
+ val url: JSArray<UrlSegment> = JSArray(),
121
+ val fragment: String? = null,
122
+ val outlet: String = "primary",
123
+ val routeConfig: JSObject? = null,
124
+ ) {
125
+ var title: String? = null
126
+ val paramMap: ParamMap get() = ParamMap(params)
127
+ val queryParamMap: ParamMap get() = ParamMap(queryParams)
128
+ val root: ActivatedRouteSnapshot get() = this
129
+ val parent: ActivatedRouteSnapshot? get() = null
130
+ val firstChild: ActivatedRouteSnapshot? get() = null
131
+ val children: JSArray<ActivatedRouteSnapshot> get() = JSArray()
132
+ val pathFromRoot: JSArray<ActivatedRouteSnapshot> get() = JSArray(mutableListOf(this))
133
+ }
134
+
135
+ class NavigationStart(val id: Double, val url: String) {
136
+ val navigationTrigger: String = "imperative"
137
+ val restoredState: Any? = null
138
+ }
139
+
140
+ /** `NavigationEnd`, the router event each completed navigation emits. */
141
+ class NavigationEnd(val id: Double, val url: String, val urlAfterRedirects: String = url)
142
+
143
+ class NavigationCancel(val id: Double, val url: String, val reason: String = "")
144
+
145
+ class NavigationError(val id: Double, val url: String, val error: Any? = null)
146
+
147
+ class RoutesRecognized(val id: Double, val url: String, val urlAfterRedirects: String = url, val state: Any? = null)
148
+
149
+ class ResolveStart(val id: Double, val url: String, val urlAfterRedirects: String = url, val state: Any? = null)
150
+
151
+ class ResolveEnd(val id: Double, val url: String, val urlAfterRedirects: String = url, val state: Any? = null)
152
+
153
+ fun createRouterStateSnapshot(url: String = "/"): JSObject =
154
+ JSObject("url" to url, "root" to ActivatedRouteSnapshot())