cobrowse-sdk-react-native 2.13.0 → 2.15.0
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/.github/workflows/lint.yaml +22 -0
- package/.github/workflows/release.yml +23 -0
- package/.vscode/settings.json +7 -0
- package/DEPLOYMENT.md +7 -0
- package/README.md +6 -33
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/cobrowse/reactnative/CobrowseIOCommonDelegates.java +14 -0
- package/android/src/main/java/io/cobrowse/reactnative/CobrowseIOModule.java +210 -346
- package/android/src/main/java/io/cobrowse/reactnative/CommonDelegates.java +133 -0
- package/android/src/main/java/io/cobrowse/reactnative/Conversion.java +73 -42
- package/android/src/main/java/io/cobrowse/reactnative/DynamicSessionControlInvocationHandler.java +31 -0
- package/cobrowse-sdk-react-native.podspec +1 -1
- package/ios/CBIOBroadcastPickerView.h +5 -0
- package/ios/CBIOBroadcastPickerView.m +52 -0
- package/ios/CBIORCTUtil.h +1 -0
- package/ios/CBIORCTUtil.m +10 -0
- package/ios/CBIOSession+Bridging.m +1 -0
- package/ios/RCTCobrowseIO.m +32 -72
- package/js/CBIOBroadcastPickerView.js +11 -0
- package/js/CobrowseIO.js +22 -1
- package/js/CobrowseView.js +2 -1
- package/js/Session.js +4 -0
- package/js/Unredacted.js +2 -2
- package/js/index.js +2 -0
- package/js/useSession.js +33 -0
- package/package.json +18 -10
- package/ts/CBIOBroadcastPickerView.d.ts +8 -0
- package/ts/CobrowseView.d.ts +7 -7
- package/ts/Redacted.d.ts +3 -3
- package/ts/Session.d.ts +3 -1
- package/ts/Unredacted.d.ts +3 -2
- package/ts/index.d.ts +1 -0
- package/ts/useSession.d.ts +3 -0
package/js/useSession.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import CobrowseIO from './CobrowseIO'
|
|
3
|
+
|
|
4
|
+
export function useSession () {
|
|
5
|
+
const [session, setSession] = useState(null)
|
|
6
|
+
|
|
7
|
+
// initial value
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
let isMounted = true
|
|
10
|
+
const getSession = async () => {
|
|
11
|
+
const session = await CobrowseIO.currentSession()
|
|
12
|
+
|
|
13
|
+
if (isMounted) {
|
|
14
|
+
setSession(session)
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getSession()
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
isMounted = false
|
|
22
|
+
}
|
|
23
|
+
}, [])
|
|
24
|
+
|
|
25
|
+
// listen to session updates
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const subscription = CobrowseIO.addListener(CobrowseIO.SESSION_UPDATED, setSession)
|
|
28
|
+
|
|
29
|
+
return () => subscription.remove()
|
|
30
|
+
}, [])
|
|
31
|
+
|
|
32
|
+
return session
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cobrowse-sdk-react-native",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "Cobrowse SDK for React Native",
|
|
5
5
|
"main": "js/index.js",
|
|
6
6
|
"types": "ts/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"lint
|
|
9
|
-
"
|
|
8
|
+
"lint": "ts-standard",
|
|
9
|
+
"lint:fix": "npm run lint -- --fix",
|
|
10
|
+
"start:dev": "nodemon --exec ./scripts/copy.sh",
|
|
11
|
+
"test:types": "tsc -p tsconfig.eslint.json --noEmit"
|
|
10
12
|
},
|
|
11
13
|
"author": {
|
|
12
14
|
"name": "Andy Pritchard"
|
|
@@ -27,17 +29,23 @@
|
|
|
27
29
|
],
|
|
28
30
|
"license": "Apache-2.0",
|
|
29
31
|
"optionalDependencies": {
|
|
30
|
-
"@types/react": "^18.0.
|
|
31
|
-
"@types/react-native": "^0.
|
|
32
|
+
"@types/react": "^18.0.24",
|
|
33
|
+
"@types/react-native": "^0.70.6"
|
|
32
34
|
},
|
|
33
35
|
"dependencies": {
|
|
34
36
|
"lodash": "^4.17.21"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"@types/react": "^18.0.
|
|
38
|
-
"@types/react-native": "^0.
|
|
39
|
-
"nodemon": "^2.0.
|
|
40
|
-
"ts-standard": "^
|
|
41
|
-
"typescript": "^4.8.
|
|
39
|
+
"@types/react": "^18.0.24",
|
|
40
|
+
"@types/react-native": "^0.70.6",
|
|
41
|
+
"nodemon": "^2.0.20",
|
|
42
|
+
"ts-standard": "^12.0.2",
|
|
43
|
+
"typescript": "^4.8.4"
|
|
44
|
+
},
|
|
45
|
+
"ts-standard": {
|
|
46
|
+
"project": "tsconfig.eslint.json",
|
|
47
|
+
"env": [
|
|
48
|
+
"jest"
|
|
49
|
+
]
|
|
42
50
|
}
|
|
43
51
|
}
|
package/ts/CobrowseView.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Component } from 'react'
|
|
2
|
-
import type {
|
|
1
|
+
import type { Component, ReactElement } from 'react'
|
|
2
|
+
import type { ViewProps, TextProps } from 'react-native'
|
|
3
3
|
|
|
4
4
|
export default class CobrowseView extends Component {
|
|
5
5
|
componentDidMount (): Promise<void>
|
|
@@ -8,13 +8,13 @@ export default class CobrowseView extends Component {
|
|
|
8
8
|
|
|
9
9
|
endSession (): Promise<void>
|
|
10
10
|
|
|
11
|
-
renderError ():
|
|
11
|
+
renderError (): ReactElement<TextProps>
|
|
12
12
|
|
|
13
|
-
renderCode ():
|
|
13
|
+
renderCode (): ReactElement<ViewProps>
|
|
14
14
|
|
|
15
|
-
renderManageSession ():
|
|
15
|
+
renderManageSession (): ReactElement<ViewProps>
|
|
16
16
|
|
|
17
|
-
renderContent ():
|
|
17
|
+
renderContent (): ReactElement<TextProps | ViewProps>
|
|
18
18
|
|
|
19
|
-
render ():
|
|
19
|
+
render (): ReactElement<ViewProps>
|
|
20
20
|
}
|
package/ts/Redacted.d.ts
CHANGED
package/ts/Session.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export type SessionState = 'active' | 'authorizing' | 'ended' | 'pending'
|
|
|
7
7
|
|
|
8
8
|
export type RemoteControlState = 'on' | 'requested' | 'rejected' | 'off'
|
|
9
9
|
|
|
10
|
+
export type FullDeviceState = 'on' | 'requested' | 'rejected' | 'off'
|
|
11
|
+
|
|
10
12
|
export interface Agent {
|
|
11
13
|
id: string
|
|
12
14
|
name: string
|
|
@@ -50,7 +52,7 @@ export default class Session {
|
|
|
50
52
|
|
|
51
53
|
isEnded (): boolean
|
|
52
54
|
|
|
53
|
-
setFullDevice (state: boolean): Promise<void>
|
|
55
|
+
setFullDevice (state: boolean | FullDeviceState): Promise<void>
|
|
54
56
|
|
|
55
57
|
setRemoteControl (state: RemoteControlState): Promise<void>
|
|
56
58
|
}
|
package/ts/Unredacted.d.ts
CHANGED
|
@@ -3,12 +3,13 @@ import { View, ScrollView, Text, Image, FlatList, SectionList } from 'react-nati
|
|
|
3
3
|
|
|
4
4
|
export function useUnredaction<
|
|
5
5
|
T = View | ScrollView | Text | Image | FlatList | SectionList
|
|
6
|
-
>(shouldWarnUnhandledRefs?: boolean
|
|
6
|
+
> (shouldWarnUnhandledRefs?: boolean, componentName?: string): (elem: T) => void
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
8
9
|
type ForwardedRefType<T, P> = typeof React.forwardRef
|
|
9
10
|
|
|
10
11
|
// HOC for adding unredaction to a whole component class
|
|
11
|
-
export function unredact(Component: ReactElement): ForwardedRefType<View, Record<string, unknown>>
|
|
12
|
+
export function unredact (Component: ReactElement): ForwardedRefType<View, Record<string, unknown>>
|
|
12
13
|
|
|
13
14
|
// also expose a basic Component based on a View
|
|
14
15
|
declare const Unredacted: ForwardRefRenderFunction<View, Record<string, unknown>>
|
package/ts/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { default as Redacted } from './Redacted'
|
|
|
4
4
|
export { default as SessionControl } from './SessionControl'
|
|
5
5
|
export { default as Unredacted, unredact, useUnredaction } from './Unredacted'
|
|
6
6
|
export { default as CobrowseAccessibilityService } from './CobrowseAccessibilityService'
|
|
7
|
+
export { useSession } from './useSession'
|