sparkling-navigation 2.0.0-rc.2
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.
- package/LICENSE +201 -0
- package/README.md +54 -0
- package/android/build.gradle.kts +87 -0
- package/android/consumer-rules.pro +0 -0
- package/android/proguard-rules.pro +21 -0
- package/android/src/androidTest/java/com/tiktok/sparkling/method/router/ExampleInstrumentedTest.kt +27 -0
- package/android/src/main/AndroidManifest.xml +4 -0
- package/android/src/main/java/com/tiktok/sparkling/method/router/close/AbsRouterCloseMethodIDL.kt +39 -0
- package/android/src/main/java/com/tiktok/sparkling/method/router/close/RouterCloseMethod.kt +62 -0
- package/android/src/main/java/com/tiktok/sparkling/method/router/open/AbsRouterOpenMethodIDL.kt +69 -0
- package/android/src/main/java/com/tiktok/sparkling/method/router/open/RouterOpenMethod.kt +157 -0
- package/android/src/main/java/com/tiktok/sparkling/method/router/utils/AbsRouteOpenHandler.kt +28 -0
- package/android/src/main/java/com/tiktok/sparkling/method/router/utils/IHostRouterDepend.kt +54 -0
- package/android/src/main/java/com/tiktok/sparkling/method/router/utils/RouterProvider.kt +9 -0
- package/android/src/test/java/com/tiktok/sparkling/method/router/RouterMethodUnitTest.kt +20 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/src/__tests__/test-utils.d.ts +25 -0
- package/dist/src/__tests__/test-utils.d.ts.map +1 -0
- package/dist/src/__tests__/test-utils.js +28 -0
- package/dist/src/__tests__/test-utils.js.map +1 -0
- package/dist/src/close/close.d.ts +8 -0
- package/dist/src/close/close.d.ts.map +1 -0
- package/dist/src/close/close.js +26 -0
- package/dist/src/close/close.js.map +1 -0
- package/dist/src/navigate/navigate.d.ts +3 -0
- package/dist/src/navigate/navigate.d.ts.map +1 -0
- package/dist/src/navigate/navigate.js +103 -0
- package/dist/src/navigate/navigate.js.map +1 -0
- package/dist/src/open/open.d.ts +8 -0
- package/dist/src/open/open.d.ts.map +1 -0
- package/dist/src/open/open.js +44 -0
- package/dist/src/open/open.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.ts +9 -0
- package/ios/Sources/Core/Methods/Close/CloseMethod+impl.swift +27 -0
- package/ios/Sources/Core/Methods/Close/CloseMethod.swift +45 -0
- package/ios/Sources/Core/Methods/Open/OpenMethod+impl.swift +31 -0
- package/ios/Sources/Core/Methods/Open/OpenMethod.swift +54 -0
- package/ios/Sources/Core/Protocols/RouterService.swift +12 -0
- package/ios/Sparkling-Router.podspec +36 -0
- package/ios/SparklingMethodTests/SPKRouterTest.swift +113 -0
- package/module.config.json +46 -0
- package/package.json +41 -0
- package/src/__tests__/__snapshots__/index.test.ts.snap +17 -0
- package/src/__tests__/close/__snapshots__/close.test.ts.snap +14 -0
- package/src/__tests__/close/close.test.ts +359 -0
- package/src/__tests__/index.test.ts +174 -0
- package/src/__tests__/navigate/navigate.test.ts +174 -0
- package/src/__tests__/open/__snapshots__/open.test.ts.snap +15 -0
- package/src/__tests__/open/open.test.ts +321 -0
- package/src/__tests__/test-utils.ts +41 -0
- package/src/close/close.d.ts +14 -0
- package/src/close/close.ts +29 -0
- package/src/navigate/navigate.d.ts +36 -0
- package/src/navigate/navigate.ts +111 -0
- package/src/open/open.d.ts +24 -0
- package/src/open/open.ts +50 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Copyright (c) 2023 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
package com.tiktok.sparkling.method.router.open
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
import android.util.Log
|
|
10
|
+
import com.tiktok.sparkling.method.registry.core.IDLBridgeMethod
|
|
11
|
+
import com.tiktok.sparkling.method.registry.core.BridgePlatformType
|
|
12
|
+
import com.tiktok.sparkling.method.registry.core.model.idl.CompletionBlock
|
|
13
|
+
import com.tiktok.sparkling.method.registry.core.utils.createXModel
|
|
14
|
+
import com.tiktok.sparkling.method.router.utils.IHostRouterDepend
|
|
15
|
+
import com.tiktok.sparkling.method.router.utils.RouterProvider
|
|
16
|
+
import java.net.URLDecoder
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Router open method implementation.
|
|
21
|
+
* Handles opening new pages/routes with various configuration options.
|
|
22
|
+
*/
|
|
23
|
+
class RouterOpenMethod : AbsRouterOpenMethodIDL() {
|
|
24
|
+
|
|
25
|
+
companion object {
|
|
26
|
+
const val KEY_POST_URL_CONFIG = "__post_url_config"
|
|
27
|
+
private const val TAG = "RouterOpenMethod"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private fun getRouterDependInstance(): IHostRouterDepend? {
|
|
31
|
+
return RouterProvider.hostRouterDepend
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun handle(
|
|
35
|
+
params: IDLMethodOpenParamModel,
|
|
36
|
+
callback: CompletionBlock<IDLMethodOpenResultModel>,
|
|
37
|
+
type: BridgePlatformType
|
|
38
|
+
) {
|
|
39
|
+
// Validate scheme is not null or empty
|
|
40
|
+
val scheme = params.scheme
|
|
41
|
+
if (scheme.isNullOrBlank()) {
|
|
42
|
+
Log.w(TAG, "Invalid params: scheme is null or empty")
|
|
43
|
+
callback.onFailure(IDLBridgeMethod.INVALID_PARAM, "Invalid params: scheme must be a non-empty string", null)
|
|
44
|
+
return
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Validate replaceType if provided
|
|
48
|
+
val replaceType: ReplaceType? = if (!params.replaceType.isNullOrBlank()) {
|
|
49
|
+
try {
|
|
50
|
+
ReplaceType.valueOf(params.replaceType!!)
|
|
51
|
+
} catch (e: IllegalArgumentException) {
|
|
52
|
+
Log.w(TAG, "Invalid replaceType: ${params.replaceType}")
|
|
53
|
+
callback.onFailure(
|
|
54
|
+
IDLBridgeMethod.INVALID_PARAM,
|
|
55
|
+
"Invalid replaceType: ${params.replaceType}. Valid values are: ${ReplaceType.values().joinToString()}",
|
|
56
|
+
null
|
|
57
|
+
)
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
ReplaceType.onlyCloseAfterOpenSucceed
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Get and validate context
|
|
65
|
+
val context = getSDKContext()?.context
|
|
66
|
+
if (context == null) {
|
|
67
|
+
Log.e(TAG, "Context not provided in host")
|
|
68
|
+
callback.onFailure(IDLBridgeMethod.FAIL, "Context not provided in host", null)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Check if router dependency is available
|
|
73
|
+
val routerDepend = getRouterDependInstance()
|
|
74
|
+
if (routerDepend == null) {
|
|
75
|
+
Log.e(TAG, "Router dependency not registered")
|
|
76
|
+
callback.onFailure(IDLBridgeMethod.FAIL, "Router service not available", null)
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
val replace = params.replace ?: false
|
|
81
|
+
val useSysBrowser = params.useSysBrowser ?: false
|
|
82
|
+
val extra = params.extra
|
|
83
|
+
|
|
84
|
+
val extraInfo = mutableMapOf<String, Any>(
|
|
85
|
+
"useSysBrowser" to useSysBrowser,
|
|
86
|
+
"extra" to (extra ?: emptyMap<Any, Any>())
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
// Handle POST request configuration
|
|
90
|
+
if (params.usePost == true) {
|
|
91
|
+
val decodeBody = try {
|
|
92
|
+
URLDecoder.decode(params.postBody ?: "", "UTF-8")
|
|
93
|
+
} catch (e: Exception) {
|
|
94
|
+
Log.w(TAG, "Failed to decode postBody: ${e.message}")
|
|
95
|
+
params.postBody ?: ""
|
|
96
|
+
}
|
|
97
|
+
extraInfo[KEY_POST_URL_CONFIG] = mutableMapOf<String, String>(
|
|
98
|
+
"postBody" to decodeBody,
|
|
99
|
+
"postHeader" to (params.postHeader?.toString() ?: ""),
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Handle non-replace open
|
|
104
|
+
if (!replace) {
|
|
105
|
+
val success = try {
|
|
106
|
+
routerDepend.openScheme(getSDKContext(), scheme, extraInfo, type, context = context)
|
|
107
|
+
} catch (e: Exception) {
|
|
108
|
+
Log.e(TAG, "Exception while opening scheme: ${e.message}")
|
|
109
|
+
false
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (success) {
|
|
113
|
+
callback.onSuccess(IDLMethodOpenResultModel::class.java.createXModel())
|
|
114
|
+
} else {
|
|
115
|
+
callback.onFailure(IDLBridgeMethod.FAIL, "Failed to open scheme: $scheme", null)
|
|
116
|
+
}
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Handle replace open with different replace types
|
|
121
|
+
val success: Boolean = try {
|
|
122
|
+
when (replaceType) {
|
|
123
|
+
ReplaceType.alwaysCloseBeforeOpen -> {
|
|
124
|
+
routerDepend.closeView(getSDKContext(), type)
|
|
125
|
+
routerDepend.openScheme(getSDKContext(), scheme, extraInfo, type, context = context)
|
|
126
|
+
}
|
|
127
|
+
ReplaceType.alwaysCloseAfterOpen -> {
|
|
128
|
+
val opened = routerDepend.openScheme(getSDKContext(), scheme, extraInfo, type, context = context)
|
|
129
|
+
routerDepend.closeView(getSDKContext(), type)
|
|
130
|
+
opened
|
|
131
|
+
}
|
|
132
|
+
ReplaceType.onlyCloseAfterOpenSucceed -> {
|
|
133
|
+
val opened = routerDepend.openScheme(getSDKContext(), scheme, extraInfo, type, context = context)
|
|
134
|
+
if (opened) {
|
|
135
|
+
routerDepend.closeView(getSDKContext(), type)
|
|
136
|
+
}
|
|
137
|
+
opened
|
|
138
|
+
}
|
|
139
|
+
null -> false
|
|
140
|
+
}
|
|
141
|
+
} catch (e: Exception) {
|
|
142
|
+
Log.e(TAG, "Exception during replace open: ${e.message}")
|
|
143
|
+
false
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (success) {
|
|
147
|
+
callback.onSuccess(IDLMethodOpenResultModel::class.java.createXModel())
|
|
148
|
+
} else {
|
|
149
|
+
callback.onFailure(IDLBridgeMethod.FAIL, "Failed to open scheme: $scheme", null)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
enum class ReplaceType {
|
|
154
|
+
alwaysCloseAfterOpen,
|
|
155
|
+
alwaysCloseBeforeOpen,
|
|
156
|
+
onlyCloseAfterOpenSucceed
|
|
157
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
package com.tiktok.sparkling.method.router.utils
|
|
5
|
+
|
|
6
|
+
import android.content.Context
|
|
7
|
+
import com.tiktok.sparkling.method.registry.core.BridgePlatformType
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Desc:
|
|
11
|
+
*/
|
|
12
|
+
abstract class AbsRouteOpenHandler {
|
|
13
|
+
var nextHandler: AbsRouteOpenHandler? = null
|
|
14
|
+
private set
|
|
15
|
+
var exceptionHandler: AbsRouteOpenHandler? = null
|
|
16
|
+
private set
|
|
17
|
+
|
|
18
|
+
fun setNextHandler(handler: AbsRouteOpenHandler?) {
|
|
19
|
+
this.nextHandler = handler
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
fun setExceptionHandler(handler: AbsRouteOpenHandler?) {
|
|
23
|
+
this.exceptionHandler = handler
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
abstract fun openScheme(scheme: String, extraInfo: Map<String, Any>, context: Context?): Boolean
|
|
27
|
+
abstract fun getSupportPlatformTypeList(): List<BridgePlatformType>
|
|
28
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
package com.tiktok.sparkling.method.router.utils
|
|
5
|
+
|
|
6
|
+
import android.content.Context
|
|
7
|
+
import com.tiktok.sparkling.method.registry.core.IBridgeContext
|
|
8
|
+
import com.tiktok.sparkling.method.registry.core.BridgePlatformType
|
|
9
|
+
import com.tiktok.sparkling.method.registry.core.model.context.ContextProviderFactory
|
|
10
|
+
|
|
11
|
+
interface IHostRouterDepend {
|
|
12
|
+
fun openScheme(bridgeContext: IBridgeContext?, scheme: String, extraParams: Map<String, Any>, platformType: BridgePlatformType, context: Context?): Boolean {
|
|
13
|
+
var handled = false
|
|
14
|
+
val contextProviderFactory = ContextProviderFactory()
|
|
15
|
+
val headHandlerNode = assembleHandlerChain(contextProviderFactory) ?: return false
|
|
16
|
+
var curHandlerNode: AbsRouteOpenHandler? = headHandlerNode
|
|
17
|
+
while (!handled && curHandlerNode != null) {
|
|
18
|
+
if (curHandlerNode.getSupportPlatformTypeList().contains(BridgePlatformType.ALL) || curHandlerNode.getSupportPlatformTypeList().contains(platformType)) {
|
|
19
|
+
try {
|
|
20
|
+
handled = curHandlerNode.openScheme(scheme, extraParams, contextProviderFactory?.provideInstance(Context::class.java))
|
|
21
|
+
if (handled) {
|
|
22
|
+
break
|
|
23
|
+
}
|
|
24
|
+
curHandlerNode = curHandlerNode.nextHandler
|
|
25
|
+
} catch (e: Throwable) {
|
|
26
|
+
curHandlerNode = curHandlerNode!!.exceptionHandler
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
curHandlerNode = curHandlerNode.nextHandler
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return handled
|
|
34
|
+
}
|
|
35
|
+
fun closeView(bridgeContext: IBridgeContext?, type: BridgePlatformType, containerID: String? = null, animated: Boolean? = false): Boolean
|
|
36
|
+
fun provideRouteOpenHandlerList(contextProviderFactory: ContextProviderFactory?): List<AbsRouteOpenHandler> = listOf()
|
|
37
|
+
fun provideRouteOpenExceptionHandler(contextProviderFactory: ContextProviderFactory?): AbsRouteOpenHandler? = null
|
|
38
|
+
private fun assembleHandlerChain(contextProviderFactory: ContextProviderFactory?): AbsRouteOpenHandler? {
|
|
39
|
+
val chainHandlerList = provideRouteOpenHandlerList(contextProviderFactory)
|
|
40
|
+
val exceptionHandlerNode = provideRouteOpenExceptionHandler(contextProviderFactory)
|
|
41
|
+
var prevChainNode: AbsRouteOpenHandler? = null
|
|
42
|
+
var headChainNode: AbsRouteOpenHandler? = null
|
|
43
|
+
chainHandlerList.forEach {
|
|
44
|
+
val curChainHandler = it
|
|
45
|
+
if (prevChainNode == null) {
|
|
46
|
+
headChainNode = curChainHandler
|
|
47
|
+
}
|
|
48
|
+
prevChainNode?.setNextHandler(curChainHandler)
|
|
49
|
+
curChainHandler.setExceptionHandler(exceptionHandlerNode)
|
|
50
|
+
prevChainNode = curChainHandler
|
|
51
|
+
}
|
|
52
|
+
return headChainNode
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
package com.tiktok.sparkling.method.router.utils
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
object RouterProvider {
|
|
8
|
+
var hostRouterDepend: IHostRouterDepend? = null
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
package com.tiktok.sparkling.method.router
|
|
5
|
+
|
|
6
|
+
import org.junit.Test
|
|
7
|
+
|
|
8
|
+
import org.junit.Assert.*
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Example local unit test, which will execute on the development machine (host).
|
|
12
|
+
*
|
|
13
|
+
* See [testing documentation](http://d.android.com/tools/testing).
|
|
14
|
+
*/
|
|
15
|
+
class RouterMethodUnitTest {
|
|
16
|
+
@Test
|
|
17
|
+
fun addition_isCorrect() {
|
|
18
|
+
assertEquals(4, 2 + 2)
|
|
19
|
+
}
|
|
20
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './src/open/open';
|
|
2
|
+
export * from './src/close/close';
|
|
3
|
+
export * from './src/navigate/navigate';
|
|
4
|
+
export type { OpenRequest, OpenResponse, OpenOptions } from './src/open/open.d';
|
|
5
|
+
export type { CloseRequest, CloseResponse } from './src/close/close.d';
|
|
6
|
+
export type { NavigateRequest, NavigateResponse, NavigateOptions } from './src/navigate/navigate.d';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAGA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChF,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvE,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export * from './src/open/open';
|
|
5
|
+
export * from './src/close/close';
|
|
6
|
+
export * from './src/navigate/navigate';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,0DAA0D;AAC1D,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createMockPipe, validateContract } from '../../../../common/test-utils';
|
|
2
|
+
export { createMockPipe, validateContract };
|
|
3
|
+
export type { MockPipe } from '../../../../common/test-utils';
|
|
4
|
+
/**
|
|
5
|
+
* Create a mock pipe response for successful operations
|
|
6
|
+
*/
|
|
7
|
+
export declare const createSuccessResponse: (extra?: any) => any;
|
|
8
|
+
/**
|
|
9
|
+
* Create a mock pipe response for failed operations
|
|
10
|
+
*/
|
|
11
|
+
export declare const createErrorResponse: (code?: number, msg?: string) => any;
|
|
12
|
+
/**
|
|
13
|
+
* Helper to validate method contract responses
|
|
14
|
+
*/
|
|
15
|
+
export declare const validateMethodContract: <T>(response: any, requiredFields: (keyof T)[]) => response is T;
|
|
16
|
+
/**
|
|
17
|
+
* Test constants for consistent testing
|
|
18
|
+
*/
|
|
19
|
+
export declare const TEST_CONSTANTS: {
|
|
20
|
+
readonly VALID_SCHEME: "https://example.com/page";
|
|
21
|
+
readonly INVALID_SCHEME_EMPTY: "";
|
|
22
|
+
readonly INVALID_SCHEME_WHITESPACE: " ";
|
|
23
|
+
readonly MOCK_CONTAINER_ID: "test-container-123";
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=test-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,cAAc,EAGd,gBAAgB,EACjB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAC5C,YAAY,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,qBAAqB,sBAA4B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAM,MAAW,EAAE,MAAK,MAAgB,QACxC,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,sBAAsB,kEAAmB,CAAC;AAEvD;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright (c) 2025 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import { createMockPipe, createSuccessResponseBase, createErrorResponseBase, validateContract, } from '../../../../common/test-utils';
|
|
5
|
+
// Re-export shared utilities
|
|
6
|
+
export { createMockPipe, validateContract };
|
|
7
|
+
/**
|
|
8
|
+
* Create a mock pipe response for successful operations
|
|
9
|
+
*/
|
|
10
|
+
export const createSuccessResponse = createSuccessResponseBase;
|
|
11
|
+
/**
|
|
12
|
+
* Create a mock pipe response for failed operations
|
|
13
|
+
*/
|
|
14
|
+
export const createErrorResponse = (code = -1, msg = 'Error') => createErrorResponseBase(code, msg);
|
|
15
|
+
/**
|
|
16
|
+
* Helper to validate method contract responses
|
|
17
|
+
*/
|
|
18
|
+
export const validateMethodContract = validateContract;
|
|
19
|
+
/**
|
|
20
|
+
* Test constants for consistent testing
|
|
21
|
+
*/
|
|
22
|
+
export const TEST_CONSTANTS = {
|
|
23
|
+
VALID_SCHEME: 'https://example.com/page',
|
|
24
|
+
INVALID_SCHEME_EMPTY: '',
|
|
25
|
+
INVALID_SCHEME_WHITESPACE: ' ',
|
|
26
|
+
MOCK_CONTAINER_ID: 'test-container-123',
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=test-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../../src/__tests__/test-utils.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,0DAA0D;AAE1D,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,+BAA+B,CAAC;AAEvC,6BAA6B;AAC7B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAG5C;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,CAAC,CAAC,EAAE,MAAc,OAAO,EAAE,EAAE,CAC9E,uBAAuB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,gBAAgB,CAAC;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,YAAY,EAAE,0BAA0B;IACxC,oBAAoB,EAAE,EAAE;IACxB,yBAAyB,EAAE,KAAK;IAChC,iBAAiB,EAAE,oBAAoB;CAC/B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CloseRequest, CloseResponse } from './close.d';
|
|
2
|
+
/**
|
|
3
|
+
* Close the current page
|
|
4
|
+
* @param params
|
|
5
|
+
* @param callback
|
|
6
|
+
*/
|
|
7
|
+
export declare function close(params?: CloseRequest, callback?: (result: CloseResponse) => void): void;
|
|
8
|
+
//# sourceMappingURL=close.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close.d.ts","sourceRoot":"","sources":["../../../src/close/close.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,IAAI,CAiB7F"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import pipe from 'sparkling-method';
|
|
5
|
+
/**
|
|
6
|
+
* Close the current page
|
|
7
|
+
* @param params
|
|
8
|
+
* @param callback
|
|
9
|
+
*/
|
|
10
|
+
export function close(params, callback) {
|
|
11
|
+
if (callback !== undefined && typeof callback !== 'function') {
|
|
12
|
+
console.error('[sparkling-navigation] close: callback must be a function');
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
pipe.call('router.close', Object.assign({}, (params !== null && params !== void 0 ? params : {})), (v) => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
if (typeof callback === 'function') {
|
|
18
|
+
const response = v;
|
|
19
|
+
callback({
|
|
20
|
+
code: (_a = response === null || response === void 0 ? void 0 : response.code) !== null && _a !== void 0 ? _a : -1,
|
|
21
|
+
msg: (_b = response === null || response === void 0 ? void 0 : response.msg) !== null && _b !== void 0 ? _b : 'Unknown error',
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=close.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"close.js","sourceRoot":"","sources":["../../../src/close/close.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAGpC;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,MAAqB,EAAE,QAA0C;IACnF,IAAI,QAAQ,KAAK,SAAS,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC3D,OAAO,CAAC,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC3E,OAAO;IACX,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,cAAc,oBACjB,CAAC,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,CAAC,GAClB,CAAC,CAAU,EAAE,EAAE;;QACd,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACjC,MAAM,QAAQ,GAAG,CAAkB,CAAC;YACpC,QAAQ,CAAC;gBACL,IAAI,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,mCAAI,CAAC,CAAC;gBAC1B,GAAG,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,mCAAI,eAAe;aACxC,CAAC,CAAC;QACP,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../../src/navigate/navigate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAqC,MAAM,cAAc,CAAC;AA2DzG,wBAAgB,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GAAG,IAAI,CA+CpG"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
13
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
14
|
+
// LICENSE file in the root directory of this source tree.
|
|
15
|
+
import { open } from '../open/open';
|
|
16
|
+
const DEFAULT_ROUTER_SCHEME = 'hybrid://lynxview_page';
|
|
17
|
+
const PROTOCOL_REGEX = /^[a-z][a-z0-9+.-]*:\/\//i;
|
|
18
|
+
const ALLOWED_SCHEME_PARAMS = new Set([
|
|
19
|
+
'bundle',
|
|
20
|
+
'title',
|
|
21
|
+
'fallback_url',
|
|
22
|
+
'title_color',
|
|
23
|
+
'hide_nav_bar',
|
|
24
|
+
'nav_bar_color',
|
|
25
|
+
'screen_orientation',
|
|
26
|
+
'hide_status_bar',
|
|
27
|
+
'trans_status_bar',
|
|
28
|
+
'hide_loading',
|
|
29
|
+
'loading_bg_color',
|
|
30
|
+
'container_bg_color',
|
|
31
|
+
'hide_error',
|
|
32
|
+
'force_theme_style',
|
|
33
|
+
]);
|
|
34
|
+
function createErrorResponse(msg) {
|
|
35
|
+
return {
|
|
36
|
+
code: -1,
|
|
37
|
+
msg,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function normalizePath(path) {
|
|
41
|
+
let normalized = path.trim();
|
|
42
|
+
// Remove leading "./" or "/" to keep the bundle path relative
|
|
43
|
+
normalized = normalized.replace(/^(?:\.\/|\/)+/, '');
|
|
44
|
+
return normalized;
|
|
45
|
+
}
|
|
46
|
+
function buildScheme(baseScheme, bundlePath, params) {
|
|
47
|
+
const sanitizedBase = (baseScheme || DEFAULT_ROUTER_SCHEME).trim().replace(/[?&]+$/, '') || DEFAULT_ROUTER_SCHEME;
|
|
48
|
+
const searchParams = new URLSearchParams();
|
|
49
|
+
searchParams.set('bundle', bundlePath);
|
|
50
|
+
if (params && typeof params === 'object') {
|
|
51
|
+
for (const key of Object.keys(params)) {
|
|
52
|
+
if (!ALLOWED_SCHEME_PARAMS.has(key)) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const value = params[key];
|
|
56
|
+
if (value === undefined || value === null) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
searchParams.append(key, String(value));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return `${sanitizedBase}?${searchParams.toString()}`;
|
|
63
|
+
}
|
|
64
|
+
export function navigate(params, callback) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
if (!params) {
|
|
67
|
+
const errorResponse = createErrorResponse('Invalid params: params cannot be null or undefined');
|
|
68
|
+
if (typeof callback === 'function') {
|
|
69
|
+
callback(errorResponse);
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!params.path || typeof params.path !== 'string' || !params.path.trim()) {
|
|
74
|
+
const errorResponse = createErrorResponse('Invalid params: path must be a non-empty string');
|
|
75
|
+
if (typeof callback === 'function') {
|
|
76
|
+
callback(errorResponse);
|
|
77
|
+
}
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (PROTOCOL_REGEX.test(params.path.trim())) {
|
|
81
|
+
const errorResponse = createErrorResponse('Invalid params: path must be a relative path, not a full scheme');
|
|
82
|
+
if (typeof callback === 'function') {
|
|
83
|
+
callback(errorResponse);
|
|
84
|
+
}
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (typeof callback !== 'function') {
|
|
88
|
+
console.error('[sparkling-navigation] navigate: callback must be a function');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const bundlePath = normalizePath(params.path);
|
|
92
|
+
const _c = (_a = params.options) !== null && _a !== void 0 ? _a : {}, { params: schemeParams } = _c, restOptions = __rest(_c, ["params"]);
|
|
93
|
+
if (!bundlePath) {
|
|
94
|
+
callback(createErrorResponse('Invalid params: path must resolve to a bundle name'));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const scheme = buildScheme((_b = params.baseScheme) !== null && _b !== void 0 ? _b : DEFAULT_ROUTER_SCHEME, bundlePath, schemeParams);
|
|
98
|
+
open({
|
|
99
|
+
scheme,
|
|
100
|
+
options: Object.keys(restOptions).length ? restOptions : undefined,
|
|
101
|
+
}, callback);
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=navigate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../../src/navigate/navigate.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OpenRequest, OpenResponse } from './open.d';
|
|
2
|
+
/**
|
|
3
|
+
* Open a new page or route
|
|
4
|
+
* @param params |
|
|
5
|
+
* @param callback
|
|
6
|
+
*/
|
|
7
|
+
export declare function open(params: OpenRequest, callback: (result: OpenResponse) => void): void;
|
|
8
|
+
//# sourceMappingURL=open.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.d.ts","sourceRoot":"","sources":["../../../src/open/open.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE1D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,IAAI,CAsCxF"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
import pipe from 'sparkling-method';
|
|
5
|
+
/**
|
|
6
|
+
* Open a new page or route
|
|
7
|
+
* @param params |
|
|
8
|
+
* @param callback
|
|
9
|
+
*/
|
|
10
|
+
export function open(params, callback) {
|
|
11
|
+
if (!params) {
|
|
12
|
+
const errorResponse = {
|
|
13
|
+
code: -1,
|
|
14
|
+
msg: 'Invalid params: params cannot be null or undefined',
|
|
15
|
+
};
|
|
16
|
+
if (typeof callback === 'function') {
|
|
17
|
+
callback(errorResponse);
|
|
18
|
+
}
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (!params.scheme || typeof params.scheme !== 'string' || !params.scheme.trim()) {
|
|
22
|
+
const errorResponse = {
|
|
23
|
+
code: -1,
|
|
24
|
+
msg: 'Invalid params: scheme must be a non-empty string',
|
|
25
|
+
};
|
|
26
|
+
if (typeof callback === 'function') {
|
|
27
|
+
callback(errorResponse);
|
|
28
|
+
}
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (typeof callback !== 'function') {
|
|
32
|
+
console.error('[sparkling-navigation] open: callback must be a function');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
pipe.call('router.open', Object.assign({ scheme: params.scheme.trim() }, params.options), (v) => {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
const response = v;
|
|
38
|
+
callback({
|
|
39
|
+
code: (_a = response === null || response === void 0 ? void 0 : response.code) !== null && _a !== void 0 ? _a : -1,
|
|
40
|
+
msg: (_b = response === null || response === void 0 ? void 0 : response.msg) !== null && _b !== void 0 ? _b : 'Unknown error',
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=open.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../../src/open/open.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,yEAAyE;AACzE,0DAA0D;AAC1D,OAAO,IAAI,MAAM,kBAAkB,CAAC;AAGpC;;;;GAIG;AACH,MAAM,UAAU,IAAI,CAAC,MAAmB,EAAE,QAAwC;IAC9E,IAAI,CAAC,MAAM,EAAE,CAAC;QACV,MAAM,aAAa,GAAiB;YAChC,IAAI,EAAE,CAAC,CAAC;YACR,GAAG,EAAE,oDAAoD;SAC5D,CAAC;QACF,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACjC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO;IACX,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC;QAC/E,MAAM,aAAa,GAAiB;YAChC,IAAI,EAAE,CAAC,CAAC;YACR,GAAG,EAAE,mDAAmD;SAC3D,CAAC;QACF,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACjC,QAAQ,CAAC,aAAa,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO;IACX,CAAC;IAED,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;QACjC,OAAO,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAC;QAC1E,OAAO;IACX,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,aAAa,kBACnB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IACzB,MAAM,CAAC,OAAO,GAClB,CAAC,CAAU,EAAE,EAAE;;QACd,MAAM,QAAQ,GAAG,CAAiB,CAAC;QACnC,QAAQ,CAAC;YACL,IAAI,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,mCAAI,CAAC,CAAC;YAC1B,GAAG,EAAE,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,mCAAI,eAAe;SACxC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es5.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.dom.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../../node_modules/.pnpm/typescript@5.8.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../sparkling-method/dist/types.d.ts","../../../sparkling-method/dist/index.d.ts","../src/close/close.d.ts","../src/close/close.ts","../src/open/open.d.ts","../src/open/open.ts","../src/navigate/navigate.d.ts","../src/navigate/navigate.ts","../index.ts","../../../../node_modules/.pnpm/@jest+expect-utils@29.7.0/node_modules/@jest/expect-utils/build/index.d.ts","../../../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/index.d.ts","../../../../node_modules/.pnpm/@sinclair+typebox@0.27.10/node_modules/@sinclair/typebox/typebox.d.ts","../../../../node_modules/.pnpm/@jest+schemas@29.6.3/node_modules/@jest/schemas/build/index.d.ts","../../../../node_modules/.pnpm/pretty-format@29.7.0/node_modules/pretty-format/build/index.d.ts","../../../../node_modules/.pnpm/jest-diff@29.7.0/node_modules/jest-diff/build/index.d.ts","../../../../node_modules/.pnpm/jest-matcher-utils@29.7.0/node_modules/jest-matcher-utils/build/index.d.ts","../../../../node_modules/.pnpm/expect@29.7.0/node_modules/expect/build/index.d.ts","../../../../node_modules/.pnpm/@types+jest@29.5.14/node_modules/@types/jest/index.d.ts"],"fileIdsList":[[26],[28,31],[24,30],[28],[25,29],[27],[17,18,19,20,21,22],[16,17],[19],[20,21],[16,19],[15]],"fileInfos":[{"version":"69684132aeb9b5642cbcd9e22dff7818ff0ee1aa831728af0ecf97d3364d5546","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"092c2bfe125ce69dbb1223c85d68d4d2397d7d8411867b5cc03cec902c233763","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},"f7633d7fe074d6a4f1d215bbc7a3b27fc0419a5a3bfbbe054ac07f3dbbc68487","bdddec6a06096ab2fc1460e59d0e8c1c954ffe72290bee32bc1ecce28ebe9393","582fe2e974682a46dcee0b08fac869d96c56ec3421ad48633f6289f497acc3fd",{"version":"9b0c2a8e5fd6520272a221f3cb839d2d86ad6007dc100e199ea8954faa0b9178","signature":"f421088758adc5b04e44c1548f2d7ac1cebbdda08458c8e493a490002c8e6f7c"},"b44b08502019a82cfd35f8126a5f4bc2f9384053c6397ad894efb67fbf754f0c",{"version":"70ded95040e639f51662007386a5ea18a258c62cd5071fc5c65bda8b5cf18d2c","signature":"dd1d64b74f46208aecdee3727641eff5c0262826752e37a19ca6b2eb474d45af"},"397fe95fdc9e268e0ca39b0cc9762dd6b6a689c274a8abb60ef68e8484b91bf2",{"version":"514b9ad2ca0453eb6b916a5d6631a8afece0c8cb66d54f57b11b005e4397910c","signature":"e902e6d4f2877e301fa4cf11b50a18c6a1c078bd34edecb15ae62459310004d0"},{"version":"f4ef2dc4d2182f03365773c1c488eb01ebd07186a7d7e3c51eea5eed6c0d5252","signature":"4acdb0a03d91ac0b94410f47337f1dba8f947a74300a305e1e6a14fef3933d07"},{"version":"cdcc132f207d097d7d3aa75615ab9a2e71d6a478162dde8b67f88ea19f3e54de","impliedFormat":1},{"version":"0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","impliedFormat":1},{"version":"e1028394c1cf96d5d057ecc647e31e457b919092f882ed0c7092152b077fed9d","impliedFormat":1},{"version":"f315e1e65a1f80992f0509e84e4ae2df15ecd9ef73df975f7c98813b71e4c8da","impliedFormat":1},{"version":"5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e","impliedFormat":1},{"version":"3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","impliedFormat":1},{"version":"ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","impliedFormat":1},{"version":"d96cc6598148bf1a98fb2e8dcf01c63a4b3558bdaec6ef35e087fd0562eb40ec","impliedFormat":1},{"version":"f8db4fea512ab759b2223b90ecbbe7dae919c02f8ce95ec03f7fb1cf757cfbeb","affectsGlobalScope":true,"impliedFormat":1}],"root":[18,20,22,23],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":false,"esModuleInterop":true,"module":5,"outDir":"./","skipLibCheck":true,"sourceMap":true,"strict":true,"target":2},"referencedMap":[[27,1],[32,2],[31,3],[29,4],[30,5],[28,6],[23,7],[18,8],[21,9],[22,10],[20,11],[16,12]],"latestChangedDtsFile":"../../../common/test-utils/contract.d.ts","version":"5.8.3"}
|
package/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) 2022 TikTok Pte. Ltd.
|
|
2
|
+
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
+
// LICENSE file in the root directory of this source tree.
|
|
4
|
+
export * from './src/open/open';
|
|
5
|
+
export * from './src/close/close';
|
|
6
|
+
export * from './src/navigate/navigate';
|
|
7
|
+
export type { OpenRequest, OpenResponse, OpenOptions } from './src/open/open.d';
|
|
8
|
+
export type { CloseRequest, CloseResponse } from './src/close/close.d';
|
|
9
|
+
export type { NavigateRequest, NavigateResponse, NavigateOptions } from './src/navigate/navigate.d';
|