react-native-visit-rn-web-sdk 1.0.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.
Files changed (134) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +31 -0
  3. package/android/bin/build/generated/source/buildConfig/debug/com/visitrnsdk/BuildConfig.class +0 -0
  4. package/android/bin/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +7 -0
  5. package/android/bin/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
  6. package/android/bin/build/intermediates/aar_main_jar/debug/classes.jar +0 -0
  7. package/android/bin/build/intermediates/aar_metadata/debug/aar-metadata.properties +5 -0
  8. package/android/bin/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
  9. package/android/bin/build/intermediates/annotations_typedef_file/debug/typedefs.txt +0 -0
  10. package/android/bin/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
  11. package/android/bin/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
  12. package/android/bin/build/intermediates/compile_symbol_list/debug/R.txt +1954 -0
  13. package/android/bin/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -0
  14. package/android/bin/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
  15. package/android/bin/build/intermediates/incremental/debug-mergeJavaRes/merge-state +0 -0
  16. package/android/bin/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
  17. package/android/bin/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
  18. package/android/bin/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
  19. package/android/bin/build/intermediates/library_java_res/debug/res.jar +0 -0
  20. package/android/bin/build/intermediates/local_only_symbol_list/debug/R-def.txt +2 -0
  21. package/android/bin/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +8 -0
  22. package/android/bin/build/intermediates/merged_java_res/debug/feature-react-native-visit-rn-sdk.jar +0 -0
  23. package/android/bin/build/intermediates/merged_manifest/debug/AndroidManifest.xml +7 -0
  24. package/android/bin/build/intermediates/navigation_json/debug/navigation.json +1 -0
  25. package/android/bin/build/intermediates/packaged_manifests/debug/output-metadata.json +18 -0
  26. package/android/bin/build/intermediates/runtime_library_classes_jar/debug/classes.jar +0 -0
  27. package/android/bin/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +1447 -0
  28. package/android/bin/build/intermediates/variant_model/debug/variant_model.json +0 -0
  29. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  30. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  31. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  32. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  33. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  34. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  35. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  36. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  37. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  38. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  39. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  40. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  41. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  42. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  43. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  44. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  45. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  46. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  47. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  48. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  49. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  50. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  51. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  52. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  53. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  54. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  55. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  56. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  57. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  58. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  59. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  60. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  61. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  62. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  63. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  64. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  65. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  66. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  67. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  68. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  69. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  70. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  71. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  72. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  73. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  74. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  75. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  76. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  77. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  78. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  79. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  80. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  81. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  82. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  83. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  84. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  85. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +2 -0
  86. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  87. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  88. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  89. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  90. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  91. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  92. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  93. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  94. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  95. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  96. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  97. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  98. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  99. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  100. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  101. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  102. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  103. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  104. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  105. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  106. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
  107. package/android/bin/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  108. package/android/bin/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  109. package/android/bin/build/outputs/aar/react-native-visit-rn-sdk-debug.aar +0 -0
  110. package/android/bin/build/outputs/logs/manifest-merger-debug-report.txt +25 -0
  111. package/android/bin/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  112. package/android/bin/build/tmp/kotlin-classes/debug/META-INF/react-native-visit-rn-sdk_debug.kotlin_module +0 -0
  113. package/android/bin/local.properties +8 -0
  114. package/android/build.gradle +112 -0
  115. package/android/gradle.properties +5 -0
  116. package/android/src/main/AndroidManifest.xml +3 -0
  117. package/android/src/main/AndroidManifestNew.xml +2 -0
  118. package/android/src/main/java/com/visitrnsdk/VisitRnSdkPackage.kt +17 -0
  119. package/android/src/main/java/com/visitrnsdk/VisitRnSdkViewManager.kt +20 -0
  120. package/ios/VisitRnSdk.xcodeproj/project.pbxproj +274 -0
  121. package/ios/VisitRnSdkViewManager.h +6 -0
  122. package/ios/VisitRnSdkViewManager.m +7 -0
  123. package/lib/commonjs/index.android.js +128 -0
  124. package/lib/commonjs/index.android.js.map +1 -0
  125. package/lib/commonjs/index.ios.js +120 -0
  126. package/lib/commonjs/index.ios.js.map +1 -0
  127. package/lib/module/index.android.js +118 -0
  128. package/lib/module/index.android.js.map +1 -0
  129. package/lib/module/index.ios.js +111 -0
  130. package/lib/module/index.ios.js.map +1 -0
  131. package/package.json +169 -0
  132. package/react-native-visit-rn-sdk.podspec +42 -0
  133. package/src/index.android.js +135 -0
  134. package/src/index.ios.js +114 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useRef","useEffect","useState","useCallback","SafeAreaView","BackHandler","Linking","Alert","EventRegister","WebView","VisitRnSdkView","_ref","ssoURL","isLoggingEnabled","source","setSource","webviewRef","showLocationPermissionAlert","alert","text","onPress","console","log","openSettings","runBeforeFirst","handleMessage","event","_webviewRef$current","nativeEvent","data","parsedObject","JSON","parse","method","current","injectJavaScript","pdfUrl","url","openURL","emitEvent","visitEvent","message","exception","canGoBack","setCanGoBack","handleBack","_webviewRef$current2","goBack","backHandler","addEventListener","remove","createElement","style","flex","backgroundColor","ref","uri","headers","platform","onMessage","startInLoadingState","injectedJavaScriptBeforeContentLoaded","javaScriptEnabled","onLoadProgress","onError","errorMessage","warn"],"sourceRoot":"../../src","sources":["index.android.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AAEvE,SAASC,YAAY,EAAEC,WAAW,EAAEC,OAAO,EAAEC,KAAK,QAAQ,cAAc;AACxE,SAASC,aAAa,QAAQ,8BAA8B;AAE5D,OAAOC,OAAO,MAAM,sBAAsB;AAE1C,MAAMC,cAAc,GAAGC,IAAA,IAAkC;EAAA,IAAjC;IAAEC,MAAM;IAAEC;EAAiB,CAAC,GAAAF,IAAA;EAClD,MAAM,CAACG,MAAM,EAAEC,SAAS,CAAC,GAAGb,QAAQ,CAACU,MAAM,CAAC;EAE5C,MAAMI,UAAU,GAAGhB,MAAM,CAAC,IAAI,CAAC;EAE/B,MAAMiB,2BAA2B,GAAGA,CAAA,KAAM;IACxCV,KAAK,CAACW,KAAK,CACT,qBAAqB,EACrB,6CAA6C,EAC7C,CACE;MACEC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAEA,CAAA,KAAM;QACbC,OAAO,CAACC,GAAG,CAAC,gBAAgB,CAAC;MAC/B;IACF,CAAC,EACD;MACEH,IAAI,EAAE,gBAAgB;MACtBC,OAAO,EAAEA,CAAA,KAAM;QACbd,OAAO,CAACiB,YAAY,CAAC,CAAC;MACxB;IACF,CAAC,CAEL,CAAC;EACH,CAAC;EAED,MAAMC,cAAc,GAAI;AAC1B;AACA;AACA;A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,CAAC,CAAC;MACF,IAAIpD,gBAAgB,EAAE;QACpBQ,OAAO,CAAC6C,IAAI,CAAC,iBAAiB,EAAED,YAAY,CAAC;MAC/C;IACF;EAAE,CACH,CACW,CAAC;AAEnB,CAAC;AAED,eAAevD,cAAc"}
@@ -0,0 +1,111 @@
1
+ import React, { useRef, useEffect, useState } from 'react';
2
+ import { StyleSheet, SafeAreaView, Linking, Platform, Dimensions } from 'react-native';
3
+ import { EventRegister } from 'react-native-event-listeners';
4
+ import { WebView } from 'react-native-webview';
5
+ Platform.select({
6
+ ios: "- You have run 'pod install'\n",
7
+ default: ''
8
+ }) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo Go\n';
9
+ const escapeChars = {
10
+ lt: '<',
11
+ gt: '>',
12
+ quot: '"',
13
+ apos: "'",
14
+ amp: '&'
15
+ };
16
+ const unescapeHTML = str =>
17
+ // modified from underscore.string and string.js
18
+ // eslint-disable-next-line no-useless-escape
19
+ str.replace(/\&([^;]+);/g, (entity, entityCode) => {
20
+ let match;
21
+ if (entityCode in escapeChars) {
22
+ return escapeChars[entityCode];
23
+ } else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
24
+ return String.fromCharCode(parseInt(match[1], 16));
25
+ } else if (match = entityCode.match(/^#(\d+)$/)) {
26
+ return String.fromCharCode(match[1]);
27
+ } else {
28
+ return entity;
29
+ }
30
+ });
31
+ const visitEvent = 'visit-event';
32
+ const VisitRnSdkView = _ref => {
33
+ let {
34
+ ssoURL,
35
+ isLoggingEnabled
36
+ } = _ref;
37
+ const [source, setSource] = useState('');
38
+ useEffect(() => {
39
+ setSource(ssoURL);
40
+ }, [ssoURL, isLoggingEnabled]);
41
+ const webviewRef = useRef(null);
42
+ const handleMessage = async event => {
43
+ var _webviewRef$current, _webviewRef$current2;
44
+ const data = JSON.parse(unescapeHTML(event.nativeEvent.data));
45
+ const {
46
+ method,
47
+ url
48
+ } = data;
49
+ console.log('handleMessage data is', data);
50
+ console.log(unescapeHTML(event.nativeEvent.data));
51
+ switch (method) {
52
+ case 'UPDATE_PLATFORM':
53
+ (_webviewRef$current = webviewRef.current) === null || _webviewRef$current === void 0 || _webviewRef$current.injectJavaScript('window.setSdkPlatform("IOS")');
54
+ break;
55
+ case 'OPEN_PDF':
56
+ Linking.openURL(url);
57
+ break;
58
+ case 'closeView':
59
+ EventRegister.emitEvent(visitEvent, {
60
+ message: 'closeView'
61
+ });
62
+ break;
63
+ case 'GET_LOCATION_PERMISSIONS':
64
+ (_webviewRef$current2 = webviewRef.current) === null || _webviewRef$current2 === void 0 || _webviewRef$current2.injectJavaScript('window.checkTheGpsPermission(true)');
65
+ break;
66
+ default:
67
+ break;
68
+ }
69
+ };
70
+ const {
71
+ height,
72
+ width
73
+ } = Dimensions.get('screen');
74
+ return /*#__PURE__*/React.createElement(SafeAreaView, {
75
+ style: {
76
+ flex: 1,
77
+ backgroundColor: 'white',
78
+ height,
79
+ width
80
+ }
81
+ }, /*#__PURE__*/React.createElement(WebView, {
82
+ ref: webviewRef,
83
+ source: {
84
+ uri: source
85
+ },
86
+ style: styles.webView,
87
+ startInLoadingState: true,
88
+ javascriptEnabled: true,
89
+ onMessage: handleMessage,
90
+ onError: errorMessage => {
91
+ EventRegister.emitEvent(visitEvent, {
92
+ message: 'web-view-error',
93
+ errorMessage: errorMessage
94
+ });
95
+ if (isLoggingEnabled) {
96
+ console.warn('Webview error: ', errorMessage);
97
+ }
98
+ }
99
+ }));
100
+ };
101
+ const styles = StyleSheet.create({
102
+ webViewContainer: {
103
+ flex: 1,
104
+ backgroundColor: 'white'
105
+ },
106
+ webView: {
107
+ flex: 1
108
+ }
109
+ });
110
+ export default VisitRnSdkView;
111
+ //# sourceMappingURL=index.ios.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useRef","useEffect","useState","StyleSheet","SafeAreaView","Linking","Platform","Dimensions","EventRegister","WebView","select","ios","default","escapeChars","lt","gt","quot","apos","amp","unescapeHTML","str","replace","entity","entityCode","match","String","fromCharCode","parseInt","visitEvent","VisitRnSdkView","_ref","ssoURL","isLoggingEnabled","source","setSource","webviewRef","handleMessage","event","_webviewRef$current","_webviewRef$current2","data","JSON","parse","nativeEvent","method","url","console","log","current","injectJavaScript","openURL","emitEvent","message","height","width","get","createElement","style","flex","backgroundColor","ref","uri","styles","webView","startInLoadingState","javascriptEnabled","onMessage","onError","errorMessage","warn","create","webViewContainer"],"sourceRoot":"../../src","sources":["index.ios.js"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC1D,SACEC,UAAU,EACVC,YAAY,EACZC,OAAO,EACPC,QAAQ,EACRC,UAAU,QACL,cAAc;AACrB,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SAASC,OAAO,QAAQ,sBAAsB;AAE9CH,QAAQ,CAACI,MAAM,CAAC;EAAEC,GAAG,EAAE,gCAAgC;EAAEC,OAAO,EAAE;AAAG,CAAC,CAAC,GACrE,sDAAsD,GACtD,+BAA+B;AAEjC,MAAMC,WAAW,GAAG;EAClBC,EAAE,EAAE,GAAG;EACPC,EAAE,EAAE,GAAG;EACPC,IAAI,EAAE,GAAG;EACTC,IAAI,EAAE,GAAG;EACTC,GAAG,EAAE;AACP,CAAC;AAED,MAAMC,YAAY,GAAIC,GAAG;AACvB;AACA;AACAA,GAAG,CAACC,OAAO,CAAC,aAAa,EAAE,CAACC,MAAM,EAAEC,UAAU,KAAK;EACjD,IAAIC,KAAK;EAET,IAAID,UAAU,IAAIV,WAAW,EAAE;IAC7B,OAAOA,WAAW,CAACU,UAAU,CAAC;EAChC,CAAC,MAAM,IAAKC,KAAK,GAAGD,UAAU,CAACC,KAAK,CAAC,mBAAmB,CAAC,EAAG;IAC1D,OAAOC,MAAM,CAACC,YAAY,CAACC,QAAQ,CAACH,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;EACpD,CAAC,MAAM,IAAKA,KAAK,GAAGD,UAAU,CAACC,KA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dk",
3
+ "version": "1.0.0",
4
+ "description": "a package to inject data into visit health pwa",
5
+ "main": "lib/commonjs/index",
6
+ "module": "lib/module/index",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index",
9
+ "source": "src/index",
10
+ "files": [
11
+ "src",
12
+ "lib",
13
+ "android",
14
+ "ios",
15
+ "cpp",
16
+ "*.podspec",
17
+ "!lib/typescript/example",
18
+ "!ios/build",
19
+ "!android/build",
20
+ "!android/gradle",
21
+ "!android/gradlew",
22
+ "!android/gradlew.bat",
23
+ "!android/local.properties",
24
+ "!**/__tests__",
25
+ "!**/__fixtures__",
26
+ "!**/__mocks__",
27
+ "!**/.*"
28
+ ],
29
+ "scripts": {
30
+ "test": "jest",
31
+ "typecheck": "tsc --noEmit",
32
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "prepack": "bob build",
34
+ "release": "release-it",
35
+ "example": "yarn --cwd example",
36
+ "build:android": "cd example/android && ./gradlew assembleDebug --no-daemon --console=plain -PreactNativeArchitectures=arm64-v8a",
37
+ "build:ios": "cd example/ios && xcodebuild -workspace VisitRnSdkExample.xcworkspace -scheme VisitRnSdkExample -configuration Debug -sdk iphonesimulator CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ GCC_OPTIMIZATION_LEVEL=0 GCC_PRECOMPILE_PREFIX_HEADER=YES ASSETCATALOG_COMPILER_OPTIMIZATION=time DEBUG_INFORMATION_FORMAT=dwarf COMPILER_INDEX_STORE_ENABLE=NO",
38
+ "bootstrap": "yarn example && yarn install && yarn example pods",
39
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build"
40
+ },
41
+ "keywords": [
42
+ "react-native",
43
+ "ios",
44
+ "android"
45
+ ],
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/VisitApp/Visit-ReactNative.git"
49
+ },
50
+ "author": "Yash <yash-vardhan@hotmail.com> (https://github.com/yash-vardhan-mishra)",
51
+ "license": "MIT",
52
+ "bugs": {
53
+ "url": "https://github.com/VisitApp/Visit-ReactNative/issues"
54
+ },
55
+ "homepage": "https://github.com/VisitApp/Visit-ReactNative",
56
+ "publishConfig": {
57
+ "registry": "https://registry.npmjs.org/"
58
+ },
59
+ "devDependencies": {
60
+ "@commitlint/config-conventional": "^17.0.2",
61
+ "@evilmartians/lefthook": "^1.2.2",
62
+ "@react-native-community/eslint-config": "^3.0.2",
63
+ "@release-it/conventional-changelog": "^5.0.0",
64
+ "@types/jest": "^28.1.2",
65
+ "@types/react": "~17.0.21",
66
+ "@types/react-native": "0.70.0",
67
+ "commitlint": "^17.0.2",
68
+ "del-cli": "^5.0.0",
69
+ "eslint": "^8.4.1",
70
+ "eslint-config-prettier": "^8.5.0",
71
+ "eslint-plugin-prettier": "^4.0.0",
72
+ "jest": "^28.1.1",
73
+ "pod-install": "^0.1.0",
74
+ "prettier": "^2.0.5",
75
+ "react": "18.2.0",
76
+ "react-native": "0.72.4",
77
+ "react-native-builder-bob": "^0.20.0",
78
+ "release-it": "^15.0.0",
79
+ "turbo": "^1.10.7",
80
+ "typescript": "^5.0.2"
81
+ },
82
+ "resolutions": {
83
+ "@types/react": "17.0.21"
84
+ },
85
+ "peerDependencies": {
86
+ "react": "*",
87
+ "react-native": "*"
88
+ },
89
+ "engines": {
90
+ "node": ">= 16.0.0"
91
+ },
92
+ "packageManager": "^yarn@1.22.15",
93
+ "jest": {
94
+ "preset": "react-native",
95
+ "modulePathIgnorePatterns": [
96
+ "<rootDir>/example/node_modules",
97
+ "<rootDir>/lib/"
98
+ ]
99
+ },
100
+ "commitlint": {
101
+ "extends": [
102
+ "@commitlint/config-conventional"
103
+ ]
104
+ },
105
+ "release-it": {
106
+ "git": {
107
+ "commitMessage": "chore: release ${version}",
108
+ "tagName": "v${version}"
109
+ },
110
+ "npm": {
111
+ "publish": true
112
+ },
113
+ "github": {
114
+ "release": true
115
+ },
116
+ "plugins": {
117
+ "@release-it/conventional-changelog": {
118
+ "preset": "angular"
119
+ }
120
+ }
121
+ },
122
+ "eslintConfig": {
123
+ "root": true,
124
+ "extends": [
125
+ "@react-native-community",
126
+ "prettier"
127
+ ],
128
+ "rules": {
129
+ "prettier/prettier": [
130
+ "error",
131
+ {
132
+ "quoteProps": "consistent",
133
+ "singleQuote": true,
134
+ "tabWidth": 2,
135
+ "trailingComma": "es5",
136
+ "useTabs": false
137
+ }
138
+ ]
139
+ }
140
+ },
141
+ "eslintIgnore": [
142
+ "node_modules/",
143
+ "lib/"
144
+ ],
145
+ "prettier": {
146
+ "quoteProps": "consistent",
147
+ "singleQuote": true,
148
+ "tabWidth": 2,
149
+ "trailingComma": "es5",
150
+ "useTabs": false
151
+ },
152
+ "react-native-builder-bob": {
153
+ "source": "src",
154
+ "output": "lib",
155
+ "targets": [
156
+ "commonjs",
157
+ "module"
158
+ ]
159
+ },
160
+ "dependencies": {
161
+ "axios": "^1.5.0",
162
+ "moment": "^2.29.4",
163
+ "react-native-event-listeners": "^1.0.7",
164
+ "react-native-webview": "^13.12.1"
165
+ },
166
+ "directories": {
167
+ "example": "example"
168
+ }
169
+ }
@@ -0,0 +1,42 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = "react-native-visit-rn-web-sdk"
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.homepage = package["homepage"]
11
+ s.license = package["license"]
12
+ s.authors = package["author"]
13
+
14
+ s.platforms = { :ios => "11.0" }
15
+ s.source = { :git => "https://github.com/yash-vardhan-mishra/react-native-visit-rn-sdk.git", :tag => "#{s.version}" }
16
+
17
+ s.source_files = "ios/**/*.{h,m,mm}"
18
+
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+
26
+ # Don't install the dependencies when we run `pod install` in the old architecture.
27
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29
+ s.pod_target_xcconfig = {
30
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
+ }
34
+ s.dependency "React-RCTFabric"
35
+ s.dependency "React-Codegen"
36
+ s.dependency "RCT-Folly"
37
+ s.dependency "RCTRequired"
38
+ s.dependency "RCTTypeSafety"
39
+ s.dependency "ReactCommon/turbomodule/core"
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,135 @@
1
+ import React, { useRef, useEffect, useState, useCallback } from 'react';
2
+
3
+ import { SafeAreaView, BackHandler, Linking, Alert } from 'react-native';
4
+ import { EventRegister } from 'react-native-event-listeners';
5
+
6
+ import WebView from 'react-native-webview';
7
+
8
+ const VisitRnSdkView = ({ ssoURL, isLoggingEnabled }) => {
9
+ const [source, setSource] = useState(ssoURL);
10
+
11
+ const webviewRef = useRef(null);
12
+
13
+ const showLocationPermissionAlert = () => {
14
+ Alert.alert(
15
+ 'Permission Required',
16
+ 'Allow location permission from app settings',
17
+ [
18
+ {
19
+ text: 'Cancel',
20
+ onPress: () => {
21
+ console.log('Cancel clicked');
22
+ },
23
+ },
24
+ {
25
+ text: 'Go to Settings',
26
+ onPress: () => {
27
+ Linking.openSettings();
28
+ },
29
+ },
30
+ ]
31
+ );
32
+ };
33
+
34
+ const runBeforeFirst = `
35
+ window.isNativeApp = true;
36
+ window.platform = "ANDROID";
37
+ true; // note: this is required, or you'll sometimes get silent failures
38
+ `;
39
+
40
+ const handleMessage = (event) => {
41
+ if (event.nativeEvent.data != null) {
42
+ try {
43
+ if (isLoggingEnabled) {
44
+ console.log('Event :' + event.nativeEvent.data);
45
+ }
46
+ const parsedObject = JSON.parse(event.nativeEvent.data);
47
+ if (parsedObject.method != null) {
48
+ switch (parsedObject.method) {
49
+ case 'UPDATE_PLATFORM':
50
+ webviewRef.current?.injectJavaScript(
51
+ 'window.setSdkPlatform("ANDROID")'
52
+ );
53
+ break;
54
+
55
+ case 'GET_LOCATION_PERMISSIONS':
56
+ console.log('GET_LOCATION_PERMISSIONS');
57
+ showLocationPermissionAlert();
58
+ break;
59
+ case 'OPEN_PDF':
60
+ {
61
+ let pdfUrl = parsedObject.url;
62
+ // console.log("pdfUrl "+pdfUrl);
63
+
64
+ Linking.openURL(pdfUrl);
65
+ }
66
+ break;
67
+ case 'closeView':
68
+ EventRegister.emitEvent(visitEvent, {
69
+ message: 'closeView',
70
+ });
71
+ break;
72
+
73
+ default:
74
+ break;
75
+ }
76
+ }
77
+ } catch (exception) {
78
+ console.log('Exception occured:' + exception.message);
79
+ }
80
+ }
81
+ };
82
+
83
+ const [canGoBack, setCanGoBack] = useState(false);
84
+ const visitEvent = 'visit-event';
85
+
86
+ const handleBack = useCallback(() => {
87
+ if (isLoggingEnabled) {
88
+ console.log('handleBack called: ' + canGoBack + " webviewRef: " + webviewRef.current);
89
+ }
90
+
91
+ if (canGoBack && webviewRef.current) {
92
+ webviewRef.current?.goBack();
93
+ return true;
94
+ }
95
+ return false;
96
+ }, [canGoBack]);
97
+
98
+ useEffect(() => {
99
+ const backHandler = BackHandler.addEventListener('hardwareBackPress', handleBack);
100
+ return () => {
101
+ backHandler.remove();
102
+ };
103
+
104
+ }, [handleBack]);
105
+
106
+ return (
107
+ <SafeAreaView style={{ flex: 1, backgroundColor: 'white' }}>
108
+ <WebView
109
+ ref={webviewRef}
110
+ source={{
111
+ uri: source,
112
+ headers: {
113
+ platform: 'ANDROID',
114
+ },
115
+ }}
116
+ onMessage={handleMessage}
117
+ startInLoadingState={true}
118
+ injectedJavaScriptBeforeContentLoaded={runBeforeFirst}
119
+ javaScriptEnabled={true}
120
+ onLoadProgress={(event) => setCanGoBack(event.nativeEvent.canGoBack)}
121
+ onError={(errorMessage) => {
122
+ EventRegister.emitEvent(visitEvent, {
123
+ message: 'web-view-error',
124
+ errorMessage: errorMessage,
125
+ });
126
+ if (isLoggingEnabled) {
127
+ console.warn('Webview error: ', errorMessage);
128
+ }
129
+ }}
130
+ />
131
+ </SafeAreaView>
132
+ );
133
+ };
134
+
135
+ export default VisitRnSdkView;
@@ -0,0 +1,114 @@
1
+ import React, { useRef, useEffect, useState } from 'react';
2
+ import {
3
+ StyleSheet,
4
+ SafeAreaView,
5
+ Linking,
6
+ Platform,
7
+ Dimensions,
8
+ } from 'react-native';
9
+ import { EventRegister } from 'react-native-event-listeners';
10
+ import { WebView } from 'react-native-webview';
11
+
12
+ Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
13
+ '- You rebuilt the app after installing the package\n' +
14
+ '- You are not using Expo Go\n';
15
+
16
+ const escapeChars = {
17
+ lt: '<',
18
+ gt: '>',
19
+ quot: '"',
20
+ apos: "'",
21
+ amp: '&',
22
+ };
23
+
24
+ const unescapeHTML = (str) =>
25
+ // modified from underscore.string and string.js
26
+ // eslint-disable-next-line no-useless-escape
27
+ str.replace(/\&([^;]+);/g, (entity, entityCode) => {
28
+ let match;
29
+
30
+ if (entityCode in escapeChars) {
31
+ return escapeChars[entityCode];
32
+ } else if ((match = entityCode.match(/^#x([\da-fA-F]+)$/))) {
33
+ return String.fromCharCode(parseInt(match[1], 16));
34
+ } else if ((match = entityCode.match(/^#(\d+)$/))) {
35
+ return String.fromCharCode(match[1]);
36
+ } else {
37
+ return entity;
38
+ }
39
+ });
40
+
41
+ const visitEvent = 'visit-event';
42
+
43
+ const VisitRnSdkView = ({ ssoURL, isLoggingEnabled }) => {
44
+ const [source, setSource] = useState('');
45
+
46
+ useEffect(() => {
47
+ setSource(ssoURL);
48
+ }, [ssoURL, isLoggingEnabled]);
49
+
50
+ const webviewRef = useRef(null);
51
+
52
+ const handleMessage = async (event) => {
53
+ const data = JSON.parse(unescapeHTML(event.nativeEvent.data));
54
+ const { method, url } = data;
55
+ console.log('handleMessage data is', data);
56
+ console.log(unescapeHTML(event.nativeEvent.data));
57
+ switch (method) {
58
+ case 'UPDATE_PLATFORM':
59
+ webviewRef.current?.injectJavaScript('window.setSdkPlatform("IOS")');
60
+ break;
61
+ case 'OPEN_PDF':
62
+ Linking.openURL(url);
63
+ break;
64
+ case 'closeView':
65
+ EventRegister.emitEvent(visitEvent, {
66
+ message: 'closeView',
67
+ });
68
+ break;
69
+ case 'GET_LOCATION_PERMISSIONS':
70
+ webviewRef.current?.injectJavaScript(
71
+ 'window.checkTheGpsPermission(true)'
72
+ );
73
+ break;
74
+
75
+ default:
76
+ break;
77
+ }
78
+ };
79
+
80
+ const { height, width } = Dimensions.get('screen');
81
+ return (
82
+ <SafeAreaView style={{ flex: 1, backgroundColor: 'white', height, width }}>
83
+ <WebView
84
+ ref={webviewRef}
85
+ source={{ uri: source }}
86
+ style={styles.webView}
87
+ startInLoadingState={true}
88
+ javascriptEnabled
89
+ onMessage={handleMessage}
90
+ onError={(errorMessage) => {
91
+ EventRegister.emitEvent(visitEvent, {
92
+ message: 'web-view-error',
93
+ errorMessage: errorMessage,
94
+ });
95
+ if (isLoggingEnabled) {
96
+ console.warn('Webview error: ', errorMessage);
97
+ }
98
+ }}
99
+ />
100
+ </SafeAreaView>
101
+ );
102
+ };
103
+
104
+ const styles = StyleSheet.create({
105
+ webViewContainer: {
106
+ flex: 1,
107
+ backgroundColor: 'white',
108
+ },
109
+ webView: {
110
+ flex: 1,
111
+ },
112
+ });
113
+
114
+ export default VisitRnSdkView;