@planningcenter/chat-react-native 3.13.0-rc.7 → 3.13.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.
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Linking } from 'react-native';
|
|
1
2
|
export class LinkingAdapter {
|
|
2
3
|
openURL;
|
|
3
4
|
canOpenURL;
|
|
4
5
|
constructor(methods) {
|
|
5
|
-
this.openURL = methods.openURL;
|
|
6
|
-
this.canOpenURL = methods.canOpenURL;
|
|
6
|
+
this.openURL = methods.openURL.bind(Linking);
|
|
7
|
+
this.canOpenURL = methods.canOpenURL.bind(Linking);
|
|
7
8
|
}
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=linking.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linking.js","sourceRoot":"","sources":["../../../src/utils/native_adapters/linking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linking.js","sourceRoot":"","sources":["../../../src/utils/native_adapters/linking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAEtC,MAAM,OAAO,cAAc;IACzB,OAAO,CAAoB;IAC3B,UAAU,CAAuB;IAEjC,YAAY,OAAgD;QAC1D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5C,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACpD,CAAC;CACF","sourcesContent":["import { Linking } from 'react-native'\n\nexport class LinkingAdapter {\n openURL: Linking['openURL']\n canOpenURL: Linking['canOpenURL']\n\n constructor(methods: Pick<Linking, 'openURL' | 'canOpenURL'>) {\n this.openURL = methods.openURL.bind(Linking)\n this.canOpenURL = methods.canOpenURL.bind(Linking)\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@planningcenter/chat-react-native",
|
|
3
|
-
"version": "3.13.0
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"react-native-url-polyfill": "^2.0.0",
|
|
56
56
|
"typescript": "<5.6.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "12d3ee2885635b9a4f1d4a81207c62b36a7b8eae"
|
|
59
59
|
}
|
|
@@ -1,21 +1,94 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Linking as RNLinking } from 'react-native'
|
|
3
|
+
import { ChatAdapters, Linking } from '../../../utils/native_adapters/configuration'
|
|
4
|
+
import {
|
|
5
|
+
AudioAdapter,
|
|
6
|
+
Clipboard,
|
|
7
|
+
ClipboardAdapter,
|
|
8
|
+
ImagePickerAdapter,
|
|
9
|
+
LinkingAdapter,
|
|
10
|
+
VideoAdapter,
|
|
11
|
+
} from '../../../utils/native_adapters'
|
|
12
|
+
import { VideoPlayerHandle, VideoPlayerProps } from '../../../utils/native_adapters/video'
|
|
3
13
|
|
|
4
14
|
describe('ChatAdapters', () => {
|
|
5
|
-
const getStringAsync = jest.fn()
|
|
6
|
-
const setStringAsync = jest.fn()
|
|
15
|
+
const getStringAsync = jest.fn(async () => '')
|
|
16
|
+
const setStringAsync = jest.fn(async (_: string) => {})
|
|
7
17
|
const clipboard = new ClipboardAdapter({
|
|
8
18
|
getStringAsync,
|
|
9
19
|
setStringAsync,
|
|
10
20
|
})
|
|
21
|
+
const audio = new AudioAdapter({
|
|
22
|
+
useAudio: (_: string) => ({
|
|
23
|
+
play: jest.fn(),
|
|
24
|
+
pause: jest.fn(),
|
|
25
|
+
isPlaying: false,
|
|
26
|
+
duration: 0,
|
|
27
|
+
position: 0,
|
|
28
|
+
AudioPlayer: null,
|
|
29
|
+
}),
|
|
30
|
+
})
|
|
31
|
+
const Player = React.forwardRef<VideoPlayerHandle, VideoPlayerProps>((_props, _ref) => null)
|
|
32
|
+
const video = new VideoAdapter({
|
|
33
|
+
Player,
|
|
34
|
+
})
|
|
35
|
+
const imagePicker = new ImagePickerAdapter({
|
|
36
|
+
openCameraAsync: async () => ({ canceled: true, assets: null }),
|
|
37
|
+
openImageLibraryAsync: async () => ({ canceled: true, assets: null }),
|
|
38
|
+
})
|
|
11
39
|
|
|
12
40
|
it('should be defined', () => {
|
|
13
41
|
expect(ChatAdapters).toBeDefined()
|
|
14
42
|
})
|
|
15
43
|
|
|
16
44
|
it('should configure the clipboard', () => {
|
|
17
|
-
ChatAdapters.configure({
|
|
45
|
+
ChatAdapters.configure({
|
|
46
|
+
clipboard,
|
|
47
|
+
audio,
|
|
48
|
+
video,
|
|
49
|
+
imagePicker,
|
|
50
|
+
})
|
|
18
51
|
|
|
19
52
|
expect(Clipboard).toEqual(clipboard)
|
|
20
53
|
})
|
|
54
|
+
|
|
55
|
+
describe('linking adapter', () => {
|
|
56
|
+
describe('defaults', () => {
|
|
57
|
+
it('should be configured', () => {
|
|
58
|
+
ChatAdapters.configure({
|
|
59
|
+
clipboard,
|
|
60
|
+
audio,
|
|
61
|
+
video,
|
|
62
|
+
imagePicker,
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
expect(Linking).toBeDefined()
|
|
66
|
+
expect(Linking.openURL).toBeDefined()
|
|
67
|
+
expect(Linking.canOpenURL).toBeDefined()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
describe('openUrl', () => {
|
|
71
|
+
Linking.openURL('https://www.google.com')
|
|
72
|
+
expect(RNLinking.openURL).toHaveBeenCalledWith('https://www.google.com')
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
describe('Adapter is bound to Linking context', () => {
|
|
77
|
+
const linking = new LinkingAdapter({
|
|
78
|
+
openURL: async function (url: string) {
|
|
79
|
+
expect(url).toBe('https://www.google.com')
|
|
80
|
+
expect(this).toBe(RNLinking)
|
|
81
|
+
},
|
|
82
|
+
canOpenURL: async function (url: string) {
|
|
83
|
+
expect(url).toBe('https://www.google.com')
|
|
84
|
+
expect(this).toBe(RNLinking)
|
|
85
|
+
|
|
86
|
+
return true
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
linking.openURL('https://www.google.com')
|
|
91
|
+
linking.canOpenURL('https://www.google.com')
|
|
92
|
+
})
|
|
93
|
+
})
|
|
21
94
|
})
|
|
@@ -5,7 +5,7 @@ export class LinkingAdapter {
|
|
|
5
5
|
canOpenURL: Linking['canOpenURL']
|
|
6
6
|
|
|
7
7
|
constructor(methods: Pick<Linking, 'openURL' | 'canOpenURL'>) {
|
|
8
|
-
this.openURL = methods.openURL
|
|
9
|
-
this.canOpenURL = methods.canOpenURL
|
|
8
|
+
this.openURL = methods.openURL.bind(Linking)
|
|
9
|
+
this.canOpenURL = methods.canOpenURL.bind(Linking)
|
|
10
10
|
}
|
|
11
11
|
}
|