rn-erxes-sdk 0.1.1 → 0.1.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/lib/commonjs/index.js +52 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +51 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +7 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +57 -1
- package/lib/commonjs/App.js +0 -61
- package/lib/commonjs/App.js.map +0 -1
- package/lib/module/App.js +0 -53
- package/lib/module/App.js.map +0 -1
- package/lib/typescript/App.d.ts +0 -9
- package/lib/typescript/App.d.ts.map +0 -1
- package/src/App.tsx +0 -55
package/lib/commonjs/index.js
CHANGED
|
@@ -4,8 +4,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _reactNativeWebview = require("react-native-webview");
|
|
9
|
+
var _reactNative = require("react-native");
|
|
8
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
|
|
11
|
+
const ErxesSDK = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
brandId,
|
|
14
|
+
src,
|
|
15
|
+
pollInterval = 6000
|
|
16
|
+
} = _ref;
|
|
17
|
+
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
18
|
+
const onMessage = data => {
|
|
19
|
+
const {
|
|
20
|
+
notificationCount
|
|
21
|
+
} = JSON.parse(data.nativeEvent.data);
|
|
22
|
+
console.log('****************** ', notificationCount);
|
|
23
|
+
};
|
|
24
|
+
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.WebView, {
|
|
25
|
+
source: _reactNative.Platform.OS === 'ios' ? require('./index.html') : {
|
|
26
|
+
uri: 'file:///android_asset/index.html'
|
|
27
|
+
},
|
|
28
|
+
originWhitelist: ['*'],
|
|
29
|
+
sharedCookiesEnabled: true,
|
|
30
|
+
cacheEnabled: true,
|
|
31
|
+
allowFileAccess: true,
|
|
32
|
+
domStorageEnabled: true,
|
|
33
|
+
thirdPartyCookiesEnabled: true
|
|
34
|
+
// allowingReadAccessToURL
|
|
35
|
+
// style={{ width: 200 }}
|
|
36
|
+
,
|
|
37
|
+
onLoadEnd: syntheticEvent => {
|
|
38
|
+
// update component to be aware of loading status
|
|
39
|
+
const {
|
|
40
|
+
nativeEvent
|
|
41
|
+
} = syntheticEvent;
|
|
42
|
+
console.log(nativeEvent.loading);
|
|
43
|
+
},
|
|
44
|
+
javaScriptEnabled: true,
|
|
45
|
+
onError: er => {
|
|
46
|
+
console.log(er);
|
|
47
|
+
},
|
|
48
|
+
startInLoadingState: true
|
|
49
|
+
// renderLoading={() => <Loader />}
|
|
50
|
+
,
|
|
51
|
+
injectedJavaScript: runFirst
|
|
52
|
+
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
53
|
+
|
|
54
|
+
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
55
|
+
,
|
|
56
|
+
onMessage: onMessage
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
var _default = ErxesSDK;
|
|
10
60
|
exports.default = _default;
|
|
11
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNativeWebview","_reactNative","obj","__esModule","default","ErxesSDK","_ref","brandId","src","pollInterval","runFirst","onMessage","data","notificationCount","JSON","parse","nativeEvent","console","log","createElement","WebView","source","Platform","OS","uri","originWhitelist","sharedCookiesEnabled","cacheEnabled","allowFileAccess","domStorageEnabled","thirdPartyCookiesEnabled","onLoadEnd","syntheticEvent","loading","javaScriptEnabled","onError","er","startInLoadingState","injectedJavaScript","_default","exports"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAAwC,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAQxC,MAAMG,QAA6B,GAAGC,IAAA,IAIhC;EAAA,IAJiC;IACrCC,OAAO;IACPC,GAAG;IACHC,YAAY,GAAG;EACjB,CAAC,GAAAH,IAAA;EACC,MAAMI,QAAQ,GAAI,oDAAmDH,OAAQ,oBAAmBE,YAAa,iLAAgLD,GAAI,2IAA0I;EAE3a,MAAMG,SAAS,GAAIC,IAAS,IAAK;IAC/B,MAAM;MAAEC;IAAkB,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,WAAW,CAACJ,IAAI,CAAC;IAE/DK,OAAO,CAACC,GAAG,CAAC,qBAAqB,EAAEL,iBAAiB,CAAC;EACvD,CAAC;EAED,oBACEhB,MAAA,CAAAO,OAAA,CAAAe,aAAA,CAACnB,mBAAA,CAAAoB,OAAO;IACNC,MAAM,EACJC,qBAAQ,CAACC,EAAE,KAAK,KAAK,GACjBxB,OAAO,CAAC,cAAc,CAAC,GACvB;MAAEyB,GAAG,EAAE;IAAmC,CAC/C;IACDC,eAAe,EAAE,CAAC,GAAG,CAAE;IACvBC,oBAAoB,EAAE,IAAK;IAC3BC,YAAY,EAAE,IAAK;IACnBC,eAAe,EAAE,IAAK;IACtBC,iBAAiB,EAAE,IAAK;IACxBC,wBAAwB,EAAE;IAC1B;IACA;IAAA;IACAC,SAAS,EAAGC,cAAc,IAAK;MAC7B;MACA,MAAM;QAAEhB;MAAY,CAAC,GAAGgB,cAAc;MACtCf,OAAO,CAACC,GAAG,CAACF,WAAW,CAACiB,OAAO,CAAC;IAClC,CAAE;IACFC,iBAAiB,EAAE,IAAK;IACxBC,OAAO,EAAGC,EAAE,IAAK;MACfnB,OAAO,CAACC,GAAG,CAACkB,EAAE,CAAC;IACjB,CAAE;IACFC,mBAAmB,EAAE;IACrB;IAAA;IACAC,kBAAkB,EAAE5B;IACpB;;IAEA;IAAA;IACAC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAAC,IAAA4B,QAAA,GAEalC,QAAQ;AAAAmC,OAAA,CAAApC,OAAA,GAAAmC,QAAA"}
|
package/lib/module/index.js
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WebView } from 'react-native-webview';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
const ErxesSDK = _ref => {
|
|
5
|
+
let {
|
|
6
|
+
brandId,
|
|
7
|
+
src,
|
|
8
|
+
pollInterval = 6000
|
|
9
|
+
} = _ref;
|
|
10
|
+
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
11
|
+
const onMessage = data => {
|
|
12
|
+
const {
|
|
13
|
+
notificationCount
|
|
14
|
+
} = JSON.parse(data.nativeEvent.data);
|
|
15
|
+
console.log('****************** ', notificationCount);
|
|
16
|
+
};
|
|
17
|
+
return /*#__PURE__*/React.createElement(WebView, {
|
|
18
|
+
source: Platform.OS === 'ios' ? require('./index.html') : {
|
|
19
|
+
uri: 'file:///android_asset/index.html'
|
|
20
|
+
},
|
|
21
|
+
originWhitelist: ['*'],
|
|
22
|
+
sharedCookiesEnabled: true,
|
|
23
|
+
cacheEnabled: true,
|
|
24
|
+
allowFileAccess: true,
|
|
25
|
+
domStorageEnabled: true,
|
|
26
|
+
thirdPartyCookiesEnabled: true
|
|
27
|
+
// allowingReadAccessToURL
|
|
28
|
+
// style={{ width: 200 }}
|
|
29
|
+
,
|
|
30
|
+
onLoadEnd: syntheticEvent => {
|
|
31
|
+
// update component to be aware of loading status
|
|
32
|
+
const {
|
|
33
|
+
nativeEvent
|
|
34
|
+
} = syntheticEvent;
|
|
35
|
+
console.log(nativeEvent.loading);
|
|
36
|
+
},
|
|
37
|
+
javaScriptEnabled: true,
|
|
38
|
+
onError: er => {
|
|
39
|
+
console.log(er);
|
|
40
|
+
},
|
|
41
|
+
startInLoadingState: true
|
|
42
|
+
// renderLoading={() => <Loader />}
|
|
43
|
+
,
|
|
44
|
+
injectedJavaScript: runFirst
|
|
45
|
+
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
46
|
+
|
|
47
|
+
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
48
|
+
,
|
|
49
|
+
onMessage: onMessage
|
|
50
|
+
});
|
|
51
|
+
};
|
|
2
52
|
export default ErxesSDK;
|
|
3
53
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ErxesSDK"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,OAAOA,QAAQ,MAAM,OAAO;
|
|
1
|
+
{"version":3,"names":["React","WebView","Platform","ErxesSDK","_ref","brandId","src","pollInterval","runFirst","onMessage","data","notificationCount","JSON","parse","nativeEvent","console","log","createElement","source","OS","require","uri","originWhitelist","sharedCookiesEnabled","cacheEnabled","allowFileAccess","domStorageEnabled","thirdPartyCookiesEnabled","onLoadEnd","syntheticEvent","loading","javaScriptEnabled","onError","er","startInLoadingState","injectedJavaScript"],"sourceRoot":"../../src","sources":["index.t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AAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAED,eAAeN,QAAQ"}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type PropTypes = {
|
|
3
|
+
brandId: string;
|
|
4
|
+
src: string;
|
|
5
|
+
pollInterval?: number;
|
|
6
|
+
};
|
|
7
|
+
declare const ErxesSDK: React.FC<PropTypes>;
|
|
2
8
|
export default ErxesSDK;
|
|
3
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CA8CjC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WebView } from 'react-native-webview';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
|
|
5
|
+
export type PropTypes = {
|
|
6
|
+
brandId: string;
|
|
7
|
+
src: string;
|
|
8
|
+
pollInterval?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const ErxesSDK: React.FC<PropTypes> = ({
|
|
12
|
+
brandId,
|
|
13
|
+
src,
|
|
14
|
+
pollInterval = 6000,
|
|
15
|
+
}) => {
|
|
16
|
+
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
17
|
+
|
|
18
|
+
const onMessage = (data: any) => {
|
|
19
|
+
const { notificationCount } = JSON.parse(data.nativeEvent.data);
|
|
20
|
+
|
|
21
|
+
console.log('****************** ', notificationCount);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<WebView
|
|
26
|
+
source={
|
|
27
|
+
Platform.OS === 'ios'
|
|
28
|
+
? require('./index.html')
|
|
29
|
+
: { uri: 'file:///android_asset/index.html' }
|
|
30
|
+
}
|
|
31
|
+
originWhitelist={['*']}
|
|
32
|
+
sharedCookiesEnabled={true}
|
|
33
|
+
cacheEnabled={true}
|
|
34
|
+
allowFileAccess={true}
|
|
35
|
+
domStorageEnabled={true}
|
|
36
|
+
thirdPartyCookiesEnabled={true}
|
|
37
|
+
// allowingReadAccessToURL
|
|
38
|
+
// style={{ width: 200 }}
|
|
39
|
+
onLoadEnd={(syntheticEvent) => {
|
|
40
|
+
// update component to be aware of loading status
|
|
41
|
+
const { nativeEvent } = syntheticEvent;
|
|
42
|
+
console.log(nativeEvent.loading);
|
|
43
|
+
}}
|
|
44
|
+
javaScriptEnabled={true}
|
|
45
|
+
onError={(er) => {
|
|
46
|
+
console.log(er);
|
|
47
|
+
}}
|
|
48
|
+
startInLoadingState={true}
|
|
49
|
+
// renderLoading={() => <Loader />}
|
|
50
|
+
injectedJavaScript={runFirst}
|
|
51
|
+
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
52
|
+
|
|
53
|
+
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
54
|
+
onMessage={onMessage}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
2
58
|
|
|
3
59
|
export default ErxesSDK;
|
package/lib/commonjs/App.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _reactNativeWebview = _interopRequireDefault(require("react-native-webview"));
|
|
9
|
-
var _reactNative = require("react-native");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
const ErxesSDK = _ref => {
|
|
12
|
-
let {
|
|
13
|
-
brandId,
|
|
14
|
-
src,
|
|
15
|
-
pollInterval
|
|
16
|
-
} = _ref;
|
|
17
|
-
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}/build/messengerWidget.bundle.js"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
18
|
-
const onMessage = data => {
|
|
19
|
-
const {
|
|
20
|
-
notificationCount
|
|
21
|
-
} = JSON.parse(data.nativeEvent.data);
|
|
22
|
-
console.log('****************** ', notificationCount);
|
|
23
|
-
};
|
|
24
|
-
return /*#__PURE__*/_react.default.createElement(_reactNativeWebview.default, {
|
|
25
|
-
source: _reactNative.Platform.OS === 'ios' ? require('./index.html') : {
|
|
26
|
-
uri: 'file:///android_asset/index.html'
|
|
27
|
-
},
|
|
28
|
-
originWhitelist: ['*'],
|
|
29
|
-
sharedCookiesEnabled: true,
|
|
30
|
-
cacheEnabled: true,
|
|
31
|
-
allowFileAccess: true,
|
|
32
|
-
domStorageEnabled: true,
|
|
33
|
-
thirdPartyCookiesEnabled: true
|
|
34
|
-
// allowingReadAccessToURL
|
|
35
|
-
// style={{ width: 200 }}
|
|
36
|
-
,
|
|
37
|
-
onLoadEnd: syntheticEvent => {
|
|
38
|
-
// update component to be aware of loading status
|
|
39
|
-
const {
|
|
40
|
-
nativeEvent
|
|
41
|
-
} = syntheticEvent;
|
|
42
|
-
console.log(nativeEvent.loading);
|
|
43
|
-
},
|
|
44
|
-
javaScriptEnabled: true,
|
|
45
|
-
onError: er => {
|
|
46
|
-
console.log(er);
|
|
47
|
-
},
|
|
48
|
-
startInLoadingState: true
|
|
49
|
-
// renderLoading={() => <Loader />}
|
|
50
|
-
,
|
|
51
|
-
injectedJavaScript: runFirst
|
|
52
|
-
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
53
|
-
|
|
54
|
-
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
55
|
-
,
|
|
56
|
-
onMessage: onMessage
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
var _default = ErxesSDK;
|
|
60
|
-
exports.default = _default;
|
|
61
|
-
//# sourceMappingURL=App.js.map
|
package/lib/commonjs/App.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireDefault","require","_reactNativeWebview","_reactNative","obj","__esModule","default","ErxesSDK","_ref","brandId","src","pollInterval","runFirst","onMessage","data","notificationCount","JSON","parse","nativeEvent","console","log","createElement","source","Platform","OS","uri","originWhitelist","sharedCookiesEnabled","cacheEnabled","allowFileAccess","domStorageEnabled","thirdPartyCookiesEnabled","onLoadEnd","syntheticEvent","loading","javaScriptEnabled","onError","er","startInLoadingState","injectedJavaScript","_default","exports"],"sourceRoot":"../../src","sources":["App.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAAwC,SAAAD,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EA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AAkC,OAAA,CAAAnC,OAAA,GAAAkC,QAAA"}
|
package/lib/module/App.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import WebView from 'react-native-webview';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
const ErxesSDK = _ref => {
|
|
5
|
-
let {
|
|
6
|
-
brandId,
|
|
7
|
-
src,
|
|
8
|
-
pollInterval
|
|
9
|
-
} = _ref;
|
|
10
|
-
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}/build/messengerWidget.bundle.js"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
11
|
-
const onMessage = data => {
|
|
12
|
-
const {
|
|
13
|
-
notificationCount
|
|
14
|
-
} = JSON.parse(data.nativeEvent.data);
|
|
15
|
-
console.log('****************** ', notificationCount);
|
|
16
|
-
};
|
|
17
|
-
return /*#__PURE__*/React.createElement(WebView, {
|
|
18
|
-
source: Platform.OS === 'ios' ? require('./index.html') : {
|
|
19
|
-
uri: 'file:///android_asset/index.html'
|
|
20
|
-
},
|
|
21
|
-
originWhitelist: ['*'],
|
|
22
|
-
sharedCookiesEnabled: true,
|
|
23
|
-
cacheEnabled: true,
|
|
24
|
-
allowFileAccess: true,
|
|
25
|
-
domStorageEnabled: true,
|
|
26
|
-
thirdPartyCookiesEnabled: true
|
|
27
|
-
// allowingReadAccessToURL
|
|
28
|
-
// style={{ width: 200 }}
|
|
29
|
-
,
|
|
30
|
-
onLoadEnd: syntheticEvent => {
|
|
31
|
-
// update component to be aware of loading status
|
|
32
|
-
const {
|
|
33
|
-
nativeEvent
|
|
34
|
-
} = syntheticEvent;
|
|
35
|
-
console.log(nativeEvent.loading);
|
|
36
|
-
},
|
|
37
|
-
javaScriptEnabled: true,
|
|
38
|
-
onError: er => {
|
|
39
|
-
console.log(er);
|
|
40
|
-
},
|
|
41
|
-
startInLoadingState: true
|
|
42
|
-
// renderLoading={() => <Loader />}
|
|
43
|
-
,
|
|
44
|
-
injectedJavaScript: runFirst
|
|
45
|
-
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
46
|
-
|
|
47
|
-
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
48
|
-
,
|
|
49
|
-
onMessage: onMessage
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
export default ErxesSDK;
|
|
53
|
-
//# sourceMappingURL=App.js.map
|
package/lib/module/App.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["React","WebView","Platform","ErxesSDK","_ref","brandId","src","pollInterval","runFirst","onMessage","data","notificationCount","JSON","parse","nativeEvent","console","log","createElement","source","OS","require","uri","originWhitelist","sharedCookiesEnabled","cacheEnabled","allowFileAccess","domStorageEnabled","thirdPartyCookiesEnabled","onLoadEnd","syntheticEvent","loading","javaScriptEnabled","onError","er","startInLoadingState","injectedJavaScript"],"sourceRoot":"../../src","sources":["App.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,sBAAsB;AAC1C,SAASC,QAAQ,QAAQ,cAAc;AAQvC,MAAMC,QAA6B,GAAGC,IAAA,IAAoC;EAAA,IAAnC;IAAEC,OAAO;IAAEC,GAAG;IAAEC;EAAa,CAAC,GAAAH,IAAA;EACnE,MAAMI,QAAQ,GAAI,oDAAmDH,OAAQ,oBAAmBE,YAAa,iLAAgLD,GAAI,2KAA0K;EAE3c,MAAMG,SAAS,GAAIC,IAAS,IAAK;IAC/B,MAAM;MAAEC;IAAkB,CAAC,GAAGC,IAAI,CAACC,KAAK,CAACH,IAAI,CAACI,WAAW,CAACJ,IAAI,CAAC;IAE/DK,OAAO,CAACC,GAAG,CAAC,qBAAqB,EAAEL,iBAAiB,CAAC;EACvD,CAAC;EAED,oBACEX,KAAA,CAAAiB,aAAA,CAAChB,OAAO;IACNiB,MAAM,EACJhB,QAAQ,CAACiB,EAAE,KAAK,KAAK,GACjBC,OAAO,CAAC,cAAc,CAAC,GACvB;MAAEC,GAAG,EAAE;IAAmC,CAC/C;IACDC,eAAe,EAAE,CAAC,GAAG,CAAE;IACvBC,oBAAoB,EAAE,IAAK;IAC3BC,YAAY,EAAE,IAAK;IACnBC,eAAe,EAAE,IAAK;IACtBC,iBAAiB,EAAE,IAAK;IACxBC,wBAAwB,EAAE;IAC1B;IACA;IAAA;IACAC,SAAS,EAAGC,cAAc,IAAK;MAC7B;MACA,MAAM;QAAEf;MAAY,CAAC,GAAGe,cAAc;MACtCd,OAAO,CAACC,GAAG,CAACF,WAAW,CAACgB,OAAO,CAAC;IAClC,CAAE;IACFC,iBAAiB,EAAE,IAAK;IACxBC,OAAO,EAAGC,EAAE,IAAK;MACflB,OAAO,CAACC,GAAG,CAACiB,EAAE,CAAC;IACjB,CAAE;IACFC,mBAAmB,EAAE;IACrB;IAAA;IACAC,kBAAkB,EAAE3B;IACpB;;IAEA;IAAA;IACAC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN,CAAC;AAED,eAAeN,QAAQ"}
|
package/lib/typescript/App.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../../src/App.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,SAAS,CA0CjC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/src/App.tsx
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import WebView from 'react-native-webview';
|
|
3
|
-
import { Platform } from 'react-native';
|
|
4
|
-
|
|
5
|
-
export type PropTypes = {
|
|
6
|
-
brandId: string;
|
|
7
|
-
src: string;
|
|
8
|
-
pollInterval: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const ErxesSDK: React.FC<PropTypes> = ({ brandId, src, pollInterval }) => {
|
|
12
|
-
const runFirst = `window.erxesSettings = { messenger: { brand_id: "${brandId}", pollInterval: ${pollInterval}, css: ".topbar-button.right { visibility: hidden;} .erxes-launcher { visibility: hidden; }"}, }; (function () { var script = document.createElement('script'); script.src = "${src}/build/messengerWidget.bundle.js"; script.async = true; var entry = document.getElementsByTagName('script')[0]; entry.parentNode.insertBefore(script, entry); })(); true;`;
|
|
13
|
-
|
|
14
|
-
const onMessage = (data: any) => {
|
|
15
|
-
const { notificationCount } = JSON.parse(data.nativeEvent.data);
|
|
16
|
-
|
|
17
|
-
console.log('****************** ', notificationCount);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<WebView
|
|
22
|
-
source={
|
|
23
|
-
Platform.OS === 'ios'
|
|
24
|
-
? require('./index.html')
|
|
25
|
-
: { uri: 'file:///android_asset/index.html' }
|
|
26
|
-
}
|
|
27
|
-
originWhitelist={['*']}
|
|
28
|
-
sharedCookiesEnabled={true}
|
|
29
|
-
cacheEnabled={true}
|
|
30
|
-
allowFileAccess={true}
|
|
31
|
-
domStorageEnabled={true}
|
|
32
|
-
thirdPartyCookiesEnabled={true}
|
|
33
|
-
// allowingReadAccessToURL
|
|
34
|
-
// style={{ width: 200 }}
|
|
35
|
-
onLoadEnd={(syntheticEvent) => {
|
|
36
|
-
// update component to be aware of loading status
|
|
37
|
-
const { nativeEvent } = syntheticEvent;
|
|
38
|
-
console.log(nativeEvent.loading);
|
|
39
|
-
}}
|
|
40
|
-
javaScriptEnabled={true}
|
|
41
|
-
onError={(er) => {
|
|
42
|
-
console.log(er);
|
|
43
|
-
}}
|
|
44
|
-
startInLoadingState={true}
|
|
45
|
-
// renderLoading={() => <Loader />}
|
|
46
|
-
injectedJavaScript={runFirst}
|
|
47
|
-
// injectedJavaScriptBeforeContentLoaded={runFirst}
|
|
48
|
-
|
|
49
|
-
// onNavigationStateChange={this.handleWebViewNavigationStateChange}
|
|
50
|
-
onMessage={onMessage}
|
|
51
|
-
/>
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default ErxesSDK;
|