@norcy/react-native-toolkit 0.1.4 → 0.1.6
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/AppleLoginUtil.js +138 -0
- package/lib/commonjs/AppleLoginUtil.js.map +1 -0
- package/lib/commonjs/Notification.js +41 -0
- package/lib/commonjs/Notification.js.map +1 -0
- package/lib/commonjs/PrefData.js +122 -0
- package/lib/commonjs/PrefData.js.map +1 -0
- package/lib/commonjs/ReportUtil.js +116 -0
- package/lib/commonjs/ReportUtil.js.map +1 -0
- package/lib/commonjs/SentryManager.js +55 -0
- package/lib/commonjs/SentryManager.js.map +1 -0
- package/lib/commonjs/constant.js +18 -0
- package/lib/commonjs/constant.js.map +1 -0
- package/lib/commonjs/index.js +72 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/AppleLoginUtil.js +132 -0
- package/lib/module/AppleLoginUtil.js.map +1 -0
- package/lib/module/Notification.js +35 -0
- package/lib/module/Notification.js.map +1 -0
- package/lib/module/PrefData.js +115 -0
- package/lib/module/PrefData.js.map +1 -0
- package/lib/module/ReportUtil.js +110 -0
- package/lib/module/ReportUtil.js.map +1 -0
- package/lib/module/SentryManager.js +47 -0
- package/lib/module/SentryManager.js.map +1 -0
- package/lib/module/constant.js +12 -0
- package/lib/module/constant.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/AppleLoginUtil.d.ts +27 -0
- package/lib/typescript/Notification.d.ts +7 -0
- package/lib/typescript/PrefData.d.ts +15 -0
- package/lib/typescript/ReportUtil.d.ts +12 -0
- package/lib/typescript/SentryManager.d.ts +5 -0
- package/lib/typescript/constant.d.ts +17 -0
- package/lib/typescript/index.d.ts +6 -0
- package/package.json +13 -3
- package/src/AppleLoginUtil.ts +107 -0
- package/src/Notification.ts +44 -0
- package/src/PrefData.ts +134 -0
- package/src/ReportUtil.ts +138 -0
- package/src/SentryManager.ts +49 -0
- package/src/constant.ts +20 -0
- package/src/index.tsx +6 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNativeAppleAuthentication = require("@invertase/react-native-apple-authentication");
|
|
8
|
+
var _reactNativeDeviceInfo = require("react-native-device-info");
|
|
9
|
+
var _constant = require("./constant");
|
|
10
|
+
const AV = require('leancloud-storage');
|
|
11
|
+
const AppleLoginUtil = {
|
|
12
|
+
// 这是监听苹果取消授权的回调,目前不需要
|
|
13
|
+
// appleAuth.onCredentialRevoked(async () => {
|
|
14
|
+
// fetchAndUpdateCredentialState(loginUser).catch(error => {
|
|
15
|
+
// updateCredentialStateForUser(`Error: ${error.code}`)
|
|
16
|
+
// });
|
|
17
|
+
// });
|
|
18
|
+
|
|
19
|
+
fetchAndUpdateCredentialState: async (user, callback) => {
|
|
20
|
+
console.log('User 正在登录鉴权:', user);
|
|
21
|
+
if (user === null) {
|
|
22
|
+
callback({
|
|
23
|
+
result: _constant.LoginState.NOTLOGIN
|
|
24
|
+
}, {
|
|
25
|
+
error: 'USER EMPTY'
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
const credentialState = await _reactNativeAppleAuthentication.appleAuth.getCredentialStateForUser(user);
|
|
29
|
+
if (credentialState === _reactNativeAppleAuthentication.appleAuth.State.AUTHORIZED) {
|
|
30
|
+
console.log('登录鉴权成功');
|
|
31
|
+
callback({
|
|
32
|
+
result: _constant.LoginState.AUTHORIZED
|
|
33
|
+
});
|
|
34
|
+
} else {
|
|
35
|
+
console.warn('登录鉴权失败');
|
|
36
|
+
callback({
|
|
37
|
+
result: _constant.LoginState.NOTLOGIN
|
|
38
|
+
}, {
|
|
39
|
+
error: 'Authorized Failed'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
requestAppleUserForLogin: async () => {
|
|
45
|
+
if (!_reactNativeAppleAuthentication.appleAuth.isSupported) {
|
|
46
|
+
return {
|
|
47
|
+
error: 'Apple Auth Not Supported'
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// start a login request
|
|
52
|
+
try {
|
|
53
|
+
const appleAuthRequestResponse = await _reactNativeAppleAuthentication.appleAuth.performRequest({
|
|
54
|
+
requestedOperation: _reactNativeAppleAuthentication.appleAuth.Operation.LOGIN,
|
|
55
|
+
requestedScopes: [_reactNativeAppleAuthentication.appleAuth.Scope.EMAIL, _reactNativeAppleAuthentication.appleAuth.Scope.FULL_NAME]
|
|
56
|
+
});
|
|
57
|
+
console.log('appleAuthRequestResponse login', appleAuthRequestResponse);
|
|
58
|
+
const {
|
|
59
|
+
user: newUser,
|
|
60
|
+
email,
|
|
61
|
+
identityToken
|
|
62
|
+
} = appleAuthRequestResponse;
|
|
63
|
+
console.log(`Apple Authentication Completed, ${newUser}, ${email}`);
|
|
64
|
+
return {
|
|
65
|
+
user: newUser,
|
|
66
|
+
email: email,
|
|
67
|
+
identityToken: identityToken
|
|
68
|
+
};
|
|
69
|
+
} catch (error) {
|
|
70
|
+
if (error.code === _reactNativeAppleAuthentication.appleAuth.Error.CANCELED) {
|
|
71
|
+
// console.warn('User canceled Apple Sign in.');
|
|
72
|
+
return {
|
|
73
|
+
error: 'User Cancel Login',
|
|
74
|
+
code: error.code
|
|
75
|
+
};
|
|
76
|
+
} else {
|
|
77
|
+
// console.warn('登录鉴权出错: ', error);
|
|
78
|
+
return {
|
|
79
|
+
error: 'Login Request Fail',
|
|
80
|
+
code: error.code
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
requestAppleUserForLogout: async () => {
|
|
86
|
+
if (!_reactNativeAppleAuthentication.appleAuth.isSupported) {
|
|
87
|
+
throw {
|
|
88
|
+
error: 'Apple Auth Not Supported',
|
|
89
|
+
code: -1
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// start a login request
|
|
94
|
+
try {
|
|
95
|
+
const appleAuthRequestResponse = await _reactNativeAppleAuthentication.appleAuth.performRequest({
|
|
96
|
+
requestedOperation: _reactNativeAppleAuthentication.appleAuth.Operation.LOGOUT
|
|
97
|
+
});
|
|
98
|
+
console.log('appleAuthRequestResponse logout', appleAuthRequestResponse);
|
|
99
|
+
return {
|
|
100
|
+
authorizationCode: appleAuthRequestResponse.authorizationCode
|
|
101
|
+
};
|
|
102
|
+
} catch (error) {
|
|
103
|
+
if (error.code === _reactNativeAppleAuthentication.appleAuth.Error.CANCELED) {
|
|
104
|
+
throw {
|
|
105
|
+
error: 'User Cancel Logout',
|
|
106
|
+
code: error.code
|
|
107
|
+
};
|
|
108
|
+
} else {
|
|
109
|
+
throw {
|
|
110
|
+
error: 'Logout Request Fail',
|
|
111
|
+
code: error.code
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
requestDeleteAccount: async () => {
|
|
117
|
+
if (_reactNativeAppleAuthentication.appleAuth.isSupported) {
|
|
118
|
+
const {
|
|
119
|
+
authorizationCode
|
|
120
|
+
} = await AppleLoginUtil.requestAppleUserForLogout();
|
|
121
|
+
console.log('get authorizationCode success', authorizationCode);
|
|
122
|
+
const {
|
|
123
|
+
token
|
|
124
|
+
} = await AV.Cloud.run('getToken', {
|
|
125
|
+
authorizationCode,
|
|
126
|
+
bundleId: (0, _reactNativeDeviceInfo.getBundleId)()
|
|
127
|
+
});
|
|
128
|
+
console.log('get token success', token);
|
|
129
|
+
await AV.Cloud.run('revokeAppleAccount', {
|
|
130
|
+
token,
|
|
131
|
+
bundleId: (0, _reactNativeDeviceInfo.getBundleId)()
|
|
132
|
+
});
|
|
133
|
+
console.log('revoke account success');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
var _default = exports.default = AppleLoginUtil;
|
|
138
|
+
//# sourceMappingURL=AppleLoginUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeAppleAuthentication","require","_reactNativeDeviceInfo","_constant","AV","AppleLoginUtil","fetchAndUpdateCredentialState","user","callback","console","log","result","LoginState","NOTLOGIN","error","credentialState","appleAuth","getCredentialStateForUser","State","AUTHORIZED","warn","requestAppleUserForLogin","isSupported","appleAuthRequestResponse","performRequest","requestedOperation","Operation","LOGIN","requestedScopes","Scope","EMAIL","FULL_NAME","newUser","email","identityToken","code","Error","CANCELED","requestAppleUserForLogout","LOGOUT","authorizationCode","requestDeleteAccount","token","Cloud","run","bundleId","getBundleId","_default","exports","default"],"sources":["AppleLoginUtil.ts"],"sourcesContent":["import { appleAuth } from '@invertase/react-native-apple-authentication';\nimport { getBundleId } from 'react-native-device-info';\nimport { LoginState } from './constant';\n\nconst AV = require('leancloud-storage');\n\nconst AppleLoginUtil = {\n // 这是监听苹果取消授权的回调,目前不需要\n // appleAuth.onCredentialRevoked(async () => {\n // fetchAndUpdateCredentialState(loginUser).catch(error => {\n // updateCredentialStateForUser(`Error: ${error.code}`)\n // });\n // });\n\n fetchAndUpdateCredentialState: async (user: string, callback: Function) => {\n console.log('User 正在登录鉴权:', user);\n\n if (user === null) {\n callback({ result: LoginState.NOTLOGIN }, { error: 'USER EMPTY' });\n } else {\n const credentialState = await appleAuth.getCredentialStateForUser(user);\n if (credentialState === appleAuth.State.AUTHORIZED) {\n console.log('登录鉴权成功');\n callback({ result: LoginState.AUTHORIZED });\n } else {\n console.warn('登录鉴权失败');\n callback(\n { result: LoginState.NOTLOGIN },\n { error: 'Authorized Failed' }\n );\n }\n }\n },\n\n requestAppleUserForLogin: async () => {\n if (!appleAuth.isSupported) {\n return { error: 'Apple Auth Not Supported' };\n }\n\n // start a login request\n try {\n const appleAuthRequestResponse = await appleAuth.performRequest({\n requestedOperation: appleAuth.Operation.LOGIN,\n requestedScopes: [appleAuth.Scope.EMAIL, appleAuth.Scope.FULL_NAME],\n });\n\n console.log('appleAuthRequestResponse login', appleAuthRequestResponse);\n\n const { user: newUser, email, identityToken } = appleAuthRequestResponse;\n\n console.log(`Apple Authentication Completed, ${newUser}, ${email}`);\n\n return { user: newUser, email: email, identityToken: identityToken };\n } catch (error: any) {\n if (error.code === appleAuth.Error.CANCELED) {\n // console.warn('User canceled Apple Sign in.');\n return { error: 'User Cancel Login', code: error.code };\n } else {\n // console.warn('登录鉴权出错: ', error);\n return { error: 'Login Request Fail', code: error.code };\n }\n }\n },\n\n requestAppleUserForLogout: async () => {\n if (!appleAuth.isSupported) {\n throw { error: 'Apple Auth Not Supported', code: -1 };\n }\n\n // start a login request\n try {\n const appleAuthRequestResponse = await appleAuth.performRequest({\n requestedOperation: appleAuth.Operation.LOGOUT,\n });\n\n console.log('appleAuthRequestResponse logout', appleAuthRequestResponse);\n\n return { authorizationCode: appleAuthRequestResponse.authorizationCode };\n } catch (error: any) {\n if (error.code === appleAuth.Error.CANCELED) {\n throw { error: 'User Cancel Logout', code: error.code };\n } else {\n throw { error: 'Logout Request Fail', code: error.code };\n }\n }\n },\n\n requestDeleteAccount: async () => {\n if (appleAuth.isSupported) {\n const { authorizationCode } =\n await AppleLoginUtil.requestAppleUserForLogout();\n console.log('get authorizationCode success', authorizationCode);\n const { token } = await AV.Cloud.run('getToken', {\n authorizationCode,\n bundleId: getBundleId(),\n });\n console.log('get token success', token);\n await AV.Cloud.run('revokeAppleAccount', {\n token,\n bundleId: getBundleId(),\n });\n console.log('revoke account success');\n }\n },\n};\n\nexport default AppleLoginUtil;\n"],"mappings":";;;;;;AAAA,IAAAA,+BAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,MAAMG,EAAE,GAAGH,OAAO,CAAC,mBAAmB,CAAC;AAEvC,MAAMI,cAAc,GAAG;EACrB;EACA;EACA;EACA;EACA;EACA;;EAEAC,6BAA6B,EAAE,MAAAA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,qBAAqB;UAAEqB,IAAI,EAAErB,KAAK,CAACqB;QAAK,CAAC;MAC1D;IACF;EACF,CAAC;EAEDM,oBAAoB,EAAE,MAAAA,CAAA,KAAY;IAChC,IAAIzB,yCAAS,CAACM,WAAW,EAAE;MACzB,MAAM;QAAEkB;MAAkB,CAAC,GACzB,MAAMnC,cAAc,CAACiC,yBAAyB,CAAC,CAAC;MAClD7B,OAAO,CAACC,GAAG,CAAC,+BAA+B,EAAE8B,iBAAiB,CAAC;MAC/D,MAAM;QAAEE;MAAM,CAAC,GAAG,MAAMtC,EAAE,CAACuC,KAAK,CAACC,GAAG,CAAC,UAAU,EAAE;QAC/CJ,iBAAiB;QACjBK,QAAQ,EAAE,IAAAC,kCAAW,EAAC;MACxB,CAAC,CAAC;MACFrC,OAAO,CAACC,GAAG,CAAC,mBAAmB,EAAEgC,KAAK,CAAC;MACvC,MAAMtC,EAAE,CAACuC,KAAK,CAACC,GAAG,CAAC,oBAAoB,EAAE;QACvCF,KAAK;QACLG,QAAQ,EAAE,IAAAC,kCAAW,EAAC;MACxB,CAAC,CAAC;MACFrC,OAAO,CAACC,GAAG,CAAC,wBAAwB,CAAC;IACvC;EACF;AACF,CAAC;AAAC,IAAAqC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa5C,cAAc"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Notification = void 0;
|
|
7
|
+
const EventEmitter = require('events').EventEmitter;
|
|
8
|
+
const eventEmitter = new EventEmitter();
|
|
9
|
+
const ListenerToEvent = {};
|
|
10
|
+
const Notification = exports.Notification = {
|
|
11
|
+
addListener: (event, callback) => {
|
|
12
|
+
const key = callback.toString();
|
|
13
|
+
if (!ListenerToEvent[key]) {
|
|
14
|
+
eventEmitter.on(event, callback);
|
|
15
|
+
ListenerToEvent[key] = event;
|
|
16
|
+
}
|
|
17
|
+
return callback;
|
|
18
|
+
},
|
|
19
|
+
addListenerOnce: (event, callback) => {
|
|
20
|
+
eventEmitter.once(event, callback);
|
|
21
|
+
},
|
|
22
|
+
removeListener: callback => {
|
|
23
|
+
const key = callback.toString();
|
|
24
|
+
const event = ListenerToEvent[key];
|
|
25
|
+
delete ListenerToEvent[key];
|
|
26
|
+
eventEmitter.removeListener(event, callback);
|
|
27
|
+
},
|
|
28
|
+
removeAllListeners: event => {
|
|
29
|
+
const keys = Object.keys(ListenerToEvent);
|
|
30
|
+
for (const key of keys) {
|
|
31
|
+
if (ListenerToEvent[key] === event) {
|
|
32
|
+
delete ListenerToEvent[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
eventEmitter.removeAllListeners(event);
|
|
36
|
+
},
|
|
37
|
+
postNotification: (event, args) => {
|
|
38
|
+
eventEmitter.emit(event, args);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=Notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["EventEmitter","require","eventEmitter","ListenerToEvent","Notification","exports","addListener","event","callback","key","toString","on","addListenerOnce","once","removeListener","removeAllListeners","keys","Object","postNotification","args","emit"],"sources":["Notification.ts"],"sourcesContent":["const EventEmitter = require('events').EventEmitter;\nconst eventEmitter = new EventEmitter();\n\ninterface ListenerType {\n [key: string]: string;\n}\n\nconst ListenerToEvent: ListenerType = {};\n\nexport const Notification = {\n addListener: (event: string, callback: Function) => {\n const key = callback.toString();\n if (!ListenerToEvent[key]) {\n eventEmitter.on(event, callback);\n ListenerToEvent[key] = event;\n }\n return callback;\n },\n\n addListenerOnce: (event: string, callback: Function) => {\n eventEmitter.once(event, callback);\n },\n\n removeListener: (callback: Function) => {\n const key = callback.toString();\n const event = ListenerToEvent[key];\n delete ListenerToEvent[key];\n eventEmitter.removeListener(event, callback);\n },\n\n removeAllListeners: (event: string) => {\n const keys = Object.keys(ListenerToEvent);\n for (const key of keys) {\n if (ListenerToEvent[key] === event) {\n delete ListenerToEvent[key];\n }\n }\n eventEmitter.removeAllListeners(event);\n },\n\n postNotification: (event: string, args: object) => {\n eventEmitter.emit(event, args);\n },\n};\n"],"mappings":";;;;;;AAAA,MAAMA,YAAY,GAAGC,OAAO,CAAC,QAAQ,CAAC,CAACD,YAAY;AACnD,MAAME,YAAY,GAAG,IAAIF,YAAY,CAAC,CAAC;AAMvC,MAAMG,eAA6B,GAAG,CAAC,CAAC;AAEjC,MAAMC,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG;EAC1BE,WAAW,EAAEA,CAACC,KAAa,EAAEC,QAAkB,KAAK;IAClD,MAAMC,GAAG,GAAGD,QAAQ,CAACE,QAAQ,CAAC,CAAC;IAC/B,IAAI,CAACP,eAAe,CAACM,GAAG,CAAC,EAAE;MACzBP,YAAY,CAACS,EAAE,CAACJ,KAAK,EAAEC,QAAQ,CAAC;MAChCL,eAAe,CAACM,GAAG,CAAC,GAAGF,KAAK;IAC9B;IACA,OAAOC,QAAQ;EACjB,CAAC;EAEDI,eAAe,EAAEA,CAACL,KAAa,EAAEC,QAAkB,KAAK;IACtDN,YAAY,CAACW,IAAI,CAACN,KAAK,EAAEC,QAAQ,CAAC;EACpC,CAAC;EAEDM,cAAc,EAAGN,QAAkB,IAAK;IACtC,MAAMC,GAAG,GAAGD,QAAQ,CAACE,QAAQ,CAAC,CAAC;IAC/B,MAAMH,KAAK,GAAGJ,eAAe,CAACM,GAAG,CAAC;IAClC,OAAON,eAAe,CAACM,GAAG,CAAC;IAC3BP,YAAY,CAACY,cAAc,CAACP,KAAK,EAAEC,QAAQ,CAAC;EAC9C,CAAC;EAEDO,kBAAkB,EAAGR,KAAa,IAAK;IACrC,MAAMS,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACb,eAAe,CAAC;IACzC,KAAK,MAAMM,GAAG,IAAIO,IAAI,EAAE;MACtB,IAAIb,eAAe,CAACM,GAAG,CAAC,KAAKF,KAAK,EAAE;QAClC,OAAOJ,eAAe,CAACM,GAAG,CAAC;MAC7B;IACF;IACAP,YAAY,CAACa,kBAAkB,CAACR,KAAK,CAAC;EACxC,CAAC;EAEDW,gBAAgB,EAAEA,CAACX,KAAa,EAAEY,IAAY,KAAK;IACjDjB,YAAY,CAACkB,IAAI,CAACb,KAAK,EAAEY,IAAI,CAAC;EAChC;AACF,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PrefData = exports.BuildInPrefs = void 0;
|
|
7
|
+
var _asyncStorage = _interopRequireDefault(require("@react-native-community/async-storage"));
|
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
+
const EventEmitter = require('events').EventEmitter;
|
|
10
|
+
const eventEmitter = new EventEmitter();
|
|
11
|
+
let isDataLoaded = false;
|
|
12
|
+
const _PrefDatas = {};
|
|
13
|
+
const BuildInPrefs = exports.BuildInPrefs = {
|
|
14
|
+
LastLoginType: {
|
|
15
|
+
key: 'LastLoginType_Key',
|
|
16
|
+
type: 'int',
|
|
17
|
+
default: -1
|
|
18
|
+
},
|
|
19
|
+
isFirstLaunch: {
|
|
20
|
+
key: 'isFirstLaunch_Key2',
|
|
21
|
+
type: 'bool',
|
|
22
|
+
default: true
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const getPrefByKey = (Prefs, key) => {
|
|
26
|
+
for (const keyOfPref in Prefs) {
|
|
27
|
+
if (Prefs[keyOfPref].key === key) {
|
|
28
|
+
return Prefs[keyOfPref];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
const PrefData = exports.PrefData = {
|
|
34
|
+
load: async initPrefs => {
|
|
35
|
+
console.log('读取配置');
|
|
36
|
+
let keys = [];
|
|
37
|
+
const Prefs = {
|
|
38
|
+
...BuildInPrefs,
|
|
39
|
+
...initPrefs
|
|
40
|
+
};
|
|
41
|
+
for (const pref in Prefs) {
|
|
42
|
+
keys.push(Prefs[pref].key);
|
|
43
|
+
}
|
|
44
|
+
const values = await getMultiDatas(keys);
|
|
45
|
+
for (let i = 0; i < values.length; i++) {
|
|
46
|
+
const key = values[i][0];
|
|
47
|
+
const value = values[i][1];
|
|
48
|
+
const pref = getPrefByKey(Prefs, key);
|
|
49
|
+
if (!pref) {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// console.log(key, value, pref);
|
|
53
|
+
if (!value) {
|
|
54
|
+
_PrefDatas[key] = pref.default;
|
|
55
|
+
} else if (pref.type === 'object' || pref.type === 'array') {
|
|
56
|
+
_PrefDatas[key] = JSON.parse(value);
|
|
57
|
+
} else if (pref.type === 'int') {
|
|
58
|
+
_PrefDatas[key] = parseInt(value, 10);
|
|
59
|
+
} else if (pref.type === 'bool') {
|
|
60
|
+
_PrefDatas[key] = JSON.parse(value);
|
|
61
|
+
} else {
|
|
62
|
+
_PrefDatas[key] = value;
|
|
63
|
+
}
|
|
64
|
+
// console.log(
|
|
65
|
+
// '配置读取结果:',
|
|
66
|
+
// key,
|
|
67
|
+
// _PrefDatas[key],
|
|
68
|
+
// typeof _PrefDatas[key],
|
|
69
|
+
// );
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
eventEmitter.emit('load');
|
|
73
|
+
isDataLoaded = true;
|
|
74
|
+
},
|
|
75
|
+
getValue: pref => {
|
|
76
|
+
return _PrefDatas[pref.key];
|
|
77
|
+
},
|
|
78
|
+
setValue: async (pref, value) => {
|
|
79
|
+
const key = pref.key;
|
|
80
|
+
let finalValue;
|
|
81
|
+
_PrefDatas[key] = value;
|
|
82
|
+
if (pref.type === 'object' || pref.type === 'array') {
|
|
83
|
+
finalValue = JSON.stringify(value);
|
|
84
|
+
} else if (pref.type === 'int') {
|
|
85
|
+
finalValue = value.toString();
|
|
86
|
+
} else if (pref.type === 'bool') {
|
|
87
|
+
finalValue = value.toString();
|
|
88
|
+
} else {
|
|
89
|
+
finalValue = value;
|
|
90
|
+
}
|
|
91
|
+
await storeData(key, finalValue);
|
|
92
|
+
},
|
|
93
|
+
addListener: callback => {
|
|
94
|
+
if (isDataLoaded) {
|
|
95
|
+
callback && callback();
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
eventEmitter.on('load', callback);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const storeData = async (key, value) => {
|
|
102
|
+
try {
|
|
103
|
+
if (typeof value !== 'string') {
|
|
104
|
+
console.error('只接受 String');
|
|
105
|
+
}
|
|
106
|
+
// console.log('save to storage ' + value);
|
|
107
|
+
await _asyncStorage.default.setItem(key, value);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
console.error(e);
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const getMultiDatas = async keys => {
|
|
113
|
+
try {
|
|
114
|
+
const values = await _asyncStorage.default.multiGet(keys);
|
|
115
|
+
// console.log('read from storage ' + values);
|
|
116
|
+
return values;
|
|
117
|
+
} catch (e) {
|
|
118
|
+
console.error(e);
|
|
119
|
+
return [];
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
//# sourceMappingURL=PrefData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_asyncStorage","_interopRequireDefault","require","obj","__esModule","default","EventEmitter","eventEmitter","isDataLoaded","_PrefDatas","BuildInPrefs","exports","LastLoginType","key","type","isFirstLaunch","getPrefByKey","Prefs","keyOfPref","PrefData","load","initPrefs","console","log","keys","pref","push","values","getMultiDatas","i","length","value","JSON","parse","parseInt","emit","getValue","setValue","finalValue","stringify","toString","storeData","addListener","callback","on","error","AsyncStorage","setItem","e","multiGet"],"sources":["PrefData.ts"],"sourcesContent":["import AsyncStorage from '@react-native-community/async-storage';\n\nconst EventEmitter = require('events').EventEmitter;\nconst eventEmitter = new EventEmitter();\n\nlet isDataLoaded = false;\n\nexport interface PrefType {\n key: string;\n type: string;\n default: any;\n}\n\nexport interface PrefsType {\n [key: string]: PrefType;\n}\n\nconst _PrefDatas: { [key: string]: any } = {};\n\nexport const BuildInPrefs: PrefsType = {\n LastLoginType: {\n key: 'LastLoginType_Key',\n type: 'int',\n default: -1,\n },\n isFirstLaunch: {\n key: 'isFirstLaunch_Key2',\n type: 'bool',\n default: true,\n },\n};\n\nconst getPrefByKey = (Prefs: PrefsType, key: string) => {\n for (const keyOfPref in Prefs) {\n if (Prefs[keyOfPref].key === key) {\n return Prefs[keyOfPref];\n }\n }\n return null;\n};\n\nexport const PrefData = {\n load: async (initPrefs: PrefsType) => {\n console.log('读取配置');\n let keys = [];\n const Prefs = { ...BuildInPrefs, ...initPrefs };\n for (const pref in Prefs) {\n keys.push(Prefs[pref].key);\n }\n const values = await getMultiDatas(keys);\n\n for (let i = 0; i < values.length; i++) {\n const key = values[i][0];\n const value = values[i][1];\n const pref = getPrefByKey(Prefs, key);\n if (!pref) {\n continue;\n }\n // console.log(key, value, pref);\n if (!value) {\n _PrefDatas[key] = pref.default;\n } else if (pref.type === 'object' || pref.type === 'array') {\n _PrefDatas[key] = JSON.parse(value);\n } else if (pref.type === 'int') {\n _PrefDatas[key] = parseInt(value, 10);\n } else if (pref.type === 'bool') {\n _PrefDatas[key] = JSON.parse(value);\n } else {\n _PrefDatas[key] = value;\n }\n // console.log(\n // '配置读取结果:',\n // key,\n // _PrefDatas[key],\n // typeof _PrefDatas[key],\n // );\n }\n\n eventEmitter.emit('load');\n isDataLoaded = true;\n },\n\n getValue: (pref: PrefType) => {\n return _PrefDatas[pref.key];\n },\n\n setValue: async (pref: PrefType, value: any) => {\n const key = pref.key;\n let finalValue: string;\n _PrefDatas[key] = value;\n if (pref.type === 'object' || pref.type === 'array') {\n finalValue = JSON.stringify(value);\n } else if (pref.type === 'int') {\n finalValue = value.toString();\n } else if (pref.type === 'bool') {\n finalValue = value.toString();\n } else {\n finalValue = value;\n }\n\n await storeData(key, finalValue);\n },\n\n addListener: (callback: Function) => {\n if (isDataLoaded) {\n callback && callback();\n return;\n }\n eventEmitter.on('load', callback);\n },\n};\n\nconst storeData = async (key: string, value: string) => {\n try {\n if (typeof value !== 'string') {\n console.error('只接受 String');\n }\n // console.log('save to storage ' + value);\n await AsyncStorage.setItem(key, value);\n } catch (e) {\n console.error(e);\n }\n};\n\nconst getMultiDatas = async (keys: string[]) => {\n try {\n const values = await AsyncStorage.multiGet(keys);\n // console.log('read from storage ' + values);\n return values;\n } catch (e) {\n console.error(e);\n return [];\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiE,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjE,MAAMG,YAAY,GAAGJ,OAAO,CAAC,QAAQ,CAAC,CAACI,YAAY;AACnD,MAAMC,YAAY,GAAG,IAAID,YAAY,CAAC,CAAC;AAEvC,IAAIE,YAAY,GAAG,KAAK;AAYxB,MAAMC,UAAkC,GAAG,CAAC,CAAC;AAEtC,MAAMC,YAAuB,GAAAC,OAAA,CAAAD,YAAA,GAAG;EACrCE,aAAa,EAAE;IACbC,GAAG,EAAE,mBAAmB;IACxBC,IAAI,EAAE,KAAK;IACXT,OAAO,EAAE,CAAC;EACZ,CAAC;EACDU,aAAa,EAAE;IACbF,GAAG,EAAE,oBAAoB;IACzBC,IAAI,EAAE,MAAM;IACZT,OAAO,EAAE;EACX;AACF,CAAC;AAED,MAAMW,YAAY,GAAGA,CAACC,KAAgB,EAAEJ,GAAW,KAAK;EACtD,KAAK,MAAMK,SAAS,IAAID,KAAK,EAAE;IAC7B,IAAIA,KAAK,CAACC,SAAS,CAAC,CAACL,GAAG,KAAKA,GAAG,EAAE;MAChC,OAAOI,KAAK,CAACC,SAAS,CAAC;IACzB;EACF;EACA,OAAO,IAAI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C;AACF,CAAC;AAED,MAAMF,SAAS,GAAG,MAAAA,CAAO5B,GAAW,EAAEkB,KAAa,KAAK;EACtD,IAAI;IACF,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7BT,OAAO,CAACuB,KAAK,CAAC,YAAY,CAAC;IAC7B;IACA;IACA,MAAMC,qBAAY,CAACC,OAAO,CAAClC,GAAG,EAAEkB,KAAK,CAAC;EACxC,CAAC,CAAC,OAAOiB,CAAC,EAAE;IACV1B,OAAO,CAACuB,KAAK,CAACG,CAAC,CAAC;EAClB;AACF,CAAC;AAED,MAAMpB,aAAa,GAAG,MAAOJ,IAAc,IAAK;EAC9C,IAAI;IACF,MAAMG,MAAM,GAAG,MAAMmB,qBAAY,CAACG,QAAQ,CAACzB,IAAI,CAAC;IAChD;IACA,OAAOG,MAAM;EACf,CAAC,CAAC,OAAOqB,CAAC,EAAE;IACV1B,OAAO,CAACuB,KAAK,CAACG,CAAC,CAAC;IAChB,OAAO,EAAE;EACX;AACF,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
var _reactNativeDeviceInfo = require("react-native-device-info");
|
|
9
|
+
var _Notification = require("./Notification");
|
|
10
|
+
const CommonInfo = {
|
|
11
|
+
appVer: (0, _reactNativeDeviceInfo.getReadableVersion)(),
|
|
12
|
+
platform: _reactNative.Platform.OS,
|
|
13
|
+
sysVer: _reactNative.Platform.Version,
|
|
14
|
+
model: (0, _reactNativeDeviceInfo.getModel)(),
|
|
15
|
+
brand: (0, _reactNativeDeviceInfo.getBrand)(),
|
|
16
|
+
device: (0, _reactNativeDeviceInfo.getDeviceId)()
|
|
17
|
+
};
|
|
18
|
+
const enable = () => {
|
|
19
|
+
if (__DEV__) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (!_reactNative.NativeModules.NCYReport) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
const isValidReport = (eventId, params) => {
|
|
28
|
+
if (typeof eventId !== 'string' || (eventId === null || eventId === void 0 ? void 0 : eventId.length) === 0) {
|
|
29
|
+
console.error('Report 数据非法 1');
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (params == null) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (typeof params !== 'object' || Array.isArray(params)) {
|
|
36
|
+
console.error('Report 数据非法 2');
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
for (const key in params) {
|
|
40
|
+
if (typeof key !== 'string') {
|
|
41
|
+
console.error('Report 数据非法 3');
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
const convertToValidParams = params => {
|
|
48
|
+
const ret = {};
|
|
49
|
+
for (const key in params) {
|
|
50
|
+
const value = JSON.stringify(params[key]);
|
|
51
|
+
ret[key] = value;
|
|
52
|
+
}
|
|
53
|
+
return ret;
|
|
54
|
+
};
|
|
55
|
+
const ReportUtil = {
|
|
56
|
+
init: () => {
|
|
57
|
+
if (!enable()) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
_Notification.Notification.addListener('onLogin', _ref => {
|
|
61
|
+
let {
|
|
62
|
+
error,
|
|
63
|
+
user
|
|
64
|
+
} = _ref;
|
|
65
|
+
if (!error && user) {
|
|
66
|
+
_reactNative.NativeModules.NCYReport.signIn(user.AVUser.get('objectId'));
|
|
67
|
+
ReportUtil.setCommonInfo('user', user.AVUser.get('objectId'));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
_Notification.Notification.addListener('onLogout', () => {
|
|
71
|
+
_reactNative.NativeModules.NCYReport.signOut();
|
|
72
|
+
ReportUtil.setCommonInfo('user', '');
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
report: (eventId, params) => {
|
|
76
|
+
if (!enable()) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!isValidReport(eventId, params)) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const validParams = convertToValidParams(params);
|
|
83
|
+
const realParams = {
|
|
84
|
+
...validParams,
|
|
85
|
+
...ReportUtil.getCommonInfo()
|
|
86
|
+
};
|
|
87
|
+
console.log(realParams);
|
|
88
|
+
_reactNative.NativeModules.NCYReport.report(eventId, realParams);
|
|
89
|
+
},
|
|
90
|
+
setCommonInfo: (key, value) => {
|
|
91
|
+
CommonInfo[key] = value;
|
|
92
|
+
},
|
|
93
|
+
getCommonInfo: () => {
|
|
94
|
+
return CommonInfo;
|
|
95
|
+
},
|
|
96
|
+
viewAppear: page => {
|
|
97
|
+
if (!__DEV__) {
|
|
98
|
+
console.log(page, 'viewWillAppear');
|
|
99
|
+
}
|
|
100
|
+
if (!enable()) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
_reactNative.NativeModules.NCYReport.enterPage(page);
|
|
104
|
+
},
|
|
105
|
+
viewDisappear: page => {
|
|
106
|
+
if (!__DEV__) {
|
|
107
|
+
console.log(page, 'viewWillDisappear');
|
|
108
|
+
}
|
|
109
|
+
if (!enable()) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
_reactNative.NativeModules.NCYReport.leavePage(page);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var _default = exports.default = ReportUtil;
|
|
116
|
+
//# sourceMappingURL=ReportUtil.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_reactNativeDeviceInfo","_Notification","CommonInfo","appVer","getReadableVersion","platform","Platform","OS","sysVer","Version","model","getModel","brand","getBrand","device","getDeviceId","enable","__DEV__","NativeModules","NCYReport","isValidReport","eventId","params","length","console","error","Array","isArray","key","convertToValidParams","ret","value","JSON","stringify","ReportUtil","init","Notification","addListener","_ref","user","signIn","AVUser","get","setCommonInfo","signOut","report","validParams","realParams","getCommonInfo","log","viewAppear","page","enterPage","viewDisappear","leavePage","_default","exports","default"],"sources":["ReportUtil.ts"],"sourcesContent":["import { NativeModules, Platform } from 'react-native';\nimport {\n getBrand,\n getDeviceId,\n getModel,\n getReadableVersion,\n} from 'react-native-device-info';\nimport { Notification } from './Notification';\nimport { UserType } from './constant';\n\nexport interface ReportItemType {\n [key: string]: number | string;\n}\n\nconst CommonInfo: ReportItemType = {\n appVer: getReadableVersion(),\n platform: Platform.OS,\n sysVer: Platform.Version,\n model: getModel(),\n brand: getBrand(),\n device: getDeviceId(),\n};\n\nconst enable = () => {\n if (__DEV__) {\n return false;\n }\n if (!NativeModules.NCYReport) {\n return false;\n }\n return true;\n};\n\nconst isValidReport = (eventId: string, params?: ReportItemType) => {\n if (typeof eventId !== 'string' || eventId?.length === 0) {\n console.error('Report 数据非法 1');\n return false;\n }\n\n if (params == null) {\n return true;\n }\n\n if (typeof params !== 'object' || Array.isArray(params)) {\n console.error('Report 数据非法 2');\n return false;\n }\n\n for (const key in params) {\n if (typeof key !== 'string') {\n console.error('Report 数据非法 3');\n return false;\n }\n }\n\n return true;\n};\n\nconst convertToValidParams = (params?: ReportItemType) => {\n const ret: ReportItemType = {};\n for (const key in params) {\n const value = JSON.stringify(params[key]);\n ret[key] = value;\n }\n return ret;\n};\n\nconst ReportUtil = {\n init: () => {\n if (!enable()) {\n return;\n }\n\n Notification.addListener(\n 'onLogin',\n ({ error, user }: { error: any; user: UserType }) => {\n if (!error && user) {\n NativeModules.NCYReport.signIn(user.AVUser.get('objectId'));\n ReportUtil.setCommonInfo('user', user.AVUser.get('objectId'));\n }\n }\n );\n\n Notification.addListener('onLogout', () => {\n NativeModules.NCYReport.signOut();\n ReportUtil.setCommonInfo('user', '');\n });\n },\n\n report: (eventId: string, params?: ReportItemType) => {\n if (!enable()) {\n return;\n }\n\n if (!isValidReport(eventId, params)) {\n return;\n }\n\n const validParams = convertToValidParams(params);\n const realParams = { ...validParams, ...ReportUtil.getCommonInfo() };\n console.log(realParams);\n NativeModules.NCYReport.report(eventId, realParams);\n },\n\n setCommonInfo: (key: string, value: string) => {\n CommonInfo[key] = value;\n },\n\n getCommonInfo: () => {\n return CommonInfo;\n },\n\n viewAppear: (page: string) => {\n if (!__DEV__) {\n console.log(page, 'viewWillAppear');\n }\n\n if (!enable()) {\n return;\n }\n\n NativeModules.NCYReport.enterPage(page);\n },\n\n viewDisappear: (page: string) => {\n if (!__DEV__) {\n console.log(page, 'viewWillDisappear');\n }\n\n if (!enable()) {\n return;\n }\n\n NativeModules.NCYReport.leavePage(page);\n },\n};\n\nexport default ReportUtil;\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA;AAMA,IAAAE,aAAA,GAAAF,OAAA;AAOA,MAAMG,UAA0B,GAAG;EACjCC,MAAM,EAAE,IAAAC,yCAAkB,EAAC,CAAC;EAC5BC,QAAQ,EAAEC,qBAAQ,CAACC,EAAE;EACrBC,MAAM,EAAEF,qBAAQ,CAACG,OAAO;EACxBC,KAAK,EAAE,IAAAC,+BAAQ,EAAC,CAAC;EACjBC,KAAK,EAAE,IAAAC,+BAAQ,EAAC,CAAC;EACjBC,MAAM,EAAE,IAAAC,kCAAW,EAAC;AACtB,CAAC;AAED,MAAMC,MAAM,GAAGA,CAAA,KAAM;EACnB,IAAIC,OAAO,EAAE;IACX,OAAO,KAAK;EACd;EACA,IAAI,CAACC,0BAAa,CAACC,SAAS,EAAE;IAC5B,OAAO,KAAK;EACd;EACA,OAAO,IAAI;AACb,CAAC;AAED,MAAMC,aAAa,GAAGA,CAACC,OAAe,EAAEC,MAAuB,KAAK;EAClE,IAAI,OAAOD,OAAO,KAAK,QAAQ,IAAI,CAAAA,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,MAAM,M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E,mBAAmB,CAAC;IACxC;IAEA,IAAI,CAACnC,MAAM,CAAC,CAAC,EAAE;MACb;IACF;IAEAE,0BAAa,CAACC,SAAS,CAACmC,SAAS,CAACH,IAAI,CAAC;EACzC;AACF,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEavB,UAAU"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNativeToolkit = require("@norcy/react-native-toolkit");
|
|
8
|
+
var Sentry = _interopRequireWildcard(require("@sentry/react-native"));
|
|
9
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
10
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
|
+
const SentryManager = {
|
|
12
|
+
init: () => {
|
|
13
|
+
if (__DEV__) {
|
|
14
|
+
console.log('__DEV__ 下不使用 Sentry');
|
|
15
|
+
} else {
|
|
16
|
+
// DEV 下不打开 Sentry
|
|
17
|
+
console.log('__RELEASE__ 下使用 Sentry');
|
|
18
|
+
Sentry.init({
|
|
19
|
+
dsn: 'https://a67f2741a16c45c4a66527b8f8b046a2@o473216.ingest.sentry.io/6509175',
|
|
20
|
+
tracesSampleRate: 1.0
|
|
21
|
+
});
|
|
22
|
+
_reactNativeToolkit.Notification.addListener('onLogin', _ref => {
|
|
23
|
+
let {
|
|
24
|
+
error,
|
|
25
|
+
user
|
|
26
|
+
} = _ref;
|
|
27
|
+
if (!error && user) {
|
|
28
|
+
const sentryUser = {
|
|
29
|
+
id: user.AVUser.get('objectId'),
|
|
30
|
+
email: user.email,
|
|
31
|
+
username: user.nickname
|
|
32
|
+
};
|
|
33
|
+
Sentry.setUser(sentryUser);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
_reactNativeToolkit.Notification.addListener('onLogout', () => {
|
|
37
|
+
Sentry.setUser(null);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Sentry.nativeCrash();
|
|
41
|
+
// Sentry.captureException(new Error('测试77!'));
|
|
42
|
+
// throw new Error('My first Sentry error!');
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
setTag: (key, value) => {
|
|
47
|
+
if (!__DEV__) {
|
|
48
|
+
if (key.length) {
|
|
49
|
+
Sentry.setTag(key, value);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var _default = exports.default = SentryManager;
|
|
55
|
+
//# sourceMappingURL=SentryManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNativeToolkit","require","Sentry","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","SentryManager","init","__DEV__","console","log","dsn","tracesSampleRate","Notification","addListener","_ref","error","user","sentryUser","id","AVUser","email","username","nickname","setUser","setTag","value","length","_default","exports"],"sources":["SentryManager.ts"],"sourcesContent":["import { Notification, UserType } from '@norcy/react-native-toolkit';\nimport * as Sentry from '@sentry/react-native';\n\nconst SentryManager = {\n init: () => {\n if (__DEV__) {\n console.log('__DEV__ 下不使用 Sentry');\n } else {\n // DEV 下不打开 Sentry\n console.log('__RELEASE__ 下使用 Sentry');\n Sentry.init({\n dsn: 'https://a67f2741a16c45c4a66527b8f8b046a2@o473216.ingest.sentry.io/6509175',\n tracesSampleRate: 1.0,\n });\n\n Notification.addListener(\n 'onLogin',\n ({ error, user }: { error: any; user: UserType }) => {\n if (!error && user) {\n const sentryUser: Sentry.User = {\n id: user.AVUser.get('objectId'),\n email: user.email,\n username: user.nickname,\n };\n Sentry.setUser(sentryUser);\n }\n }\n );\n\n Notification.addListener('onLogout', () => {\n Sentry.setUser(null);\n });\n\n // Sentry.nativeCrash();\n // Sentry.captureException(new Error('测试77!'));\n // throw new Error('My first Sentry error!');\n }\n },\n\n setTag: (key: string, value: any) => {\n if (!__DEV__) {\n if (key.length) {\n Sentry.setTag(key, value);\n }\n }\n },\n};\n\nexport default SentryManager;\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAF,OAAA;AAA+C,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAA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AAC,UAAU,CAAC;YAC/B2B,KAAK,EAAEJ,IAAI,CAACI,KAAK;YACjBC,QAAQ,EAAEL,IAAI,CAACM;UACjB,CAAC;UACDzC,MAAM,CAAC0C,OAAO,CAACN,UAAU,CAAC;QAC5B;MACF,CACF,CAAC;MAEDL,gCAAY,CAACC,WAAW,CAAC,UAAU,EAAE,MAAM;QACzChC,MAAM,CAAC0C,OAAO,CAAC,IAAI,CAAC;MACtB,CAAC,CAAC;;MAEF;MACA;MACA;IACF;EACF,CAAC;;EAEDC,MAAM,EAAEA,CAACzB,GAAW,EAAE0B,KAAU,KAAK;IACnC,IAAI,CAAClB,OAAO,EAAE;MACZ,IAAIR,GAAG,CAAC2B,MAAM,EAAE;QACd7C,MAAM,CAAC2C,MAAM,CAACzB,GAAG,EAAE0B,KAAK,CAAC;MAC3B;IACF;EACF;AACF,CAAC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAtC,OAAA,GAEae,aAAa"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LoginType = exports.LoginState = void 0;
|
|
7
|
+
let LoginState = exports.LoginState = /*#__PURE__*/function (LoginState) {
|
|
8
|
+
LoginState[LoginState["NOTLOGIN"] = 0] = "NOTLOGIN";
|
|
9
|
+
LoginState[LoginState["AUTHORIZED"] = 1] = "AUTHORIZED";
|
|
10
|
+
return LoginState;
|
|
11
|
+
}({});
|
|
12
|
+
let LoginType = exports.LoginType = /*#__PURE__*/function (LoginType) {
|
|
13
|
+
LoginType[LoginType["LoginTypeApple"] = 0] = "LoginTypeApple";
|
|
14
|
+
LoginType[LoginType["LoginTypeWeChat"] = 1] = "LoginTypeWeChat";
|
|
15
|
+
LoginType[LoginType["LoginTypeVisitor"] = 2] = "LoginTypeVisitor";
|
|
16
|
+
return LoginType;
|
|
17
|
+
}({});
|
|
18
|
+
//# sourceMappingURL=constant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LoginState","exports","LoginType"],"sources":["constant.ts"],"sourcesContent":["import { User } from 'leancloud-storage';\n\nexport interface UserType {\n nickname: string;\n email: string;\n headimgurl: string;\n type: number;\n AVUser: User;\n}\n\nexport enum LoginState {\n NOTLOGIN,\n AUTHORIZED,\n}\n\nexport enum LoginType {\n LoginTypeApple,\n LoginTypeWeChat,\n LoginTypeVisitor,\n}\n"],"mappings":";;;;;;IAUYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAAA,IAKVE,SAAS,GAAAD,OAAA,CAAAC,SAAA,0BAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAATA,SAAS,CAATA,SAAS;EAAA,OAATA,SAAS;AAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -18,6 +18,78 @@ Object.keys(_SyncPrefData).forEach(function (key) {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
|
+
var _Notification = require("./Notification");
|
|
22
|
+
Object.keys(_Notification).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
25
|
+
if (key in exports && exports[key] === _Notification[key]) return;
|
|
26
|
+
Object.defineProperty(exports, key, {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () {
|
|
29
|
+
return _Notification[key];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
var _ReportUtil = require("./ReportUtil");
|
|
34
|
+
Object.keys(_ReportUtil).forEach(function (key) {
|
|
35
|
+
if (key === "default" || key === "__esModule") return;
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
37
|
+
if (key in exports && exports[key] === _ReportUtil[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _ReportUtil[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
var _SentryManager = require("./SentryManager");
|
|
46
|
+
Object.keys(_SentryManager).forEach(function (key) {
|
|
47
|
+
if (key === "default" || key === "__esModule") return;
|
|
48
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
49
|
+
if (key in exports && exports[key] === _SentryManager[key]) return;
|
|
50
|
+
Object.defineProperty(exports, key, {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
get: function () {
|
|
53
|
+
return _SentryManager[key];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
var _AppleLoginUtil = require("./AppleLoginUtil");
|
|
58
|
+
Object.keys(_AppleLoginUtil).forEach(function (key) {
|
|
59
|
+
if (key === "default" || key === "__esModule") return;
|
|
60
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
61
|
+
if (key in exports && exports[key] === _AppleLoginUtil[key]) return;
|
|
62
|
+
Object.defineProperty(exports, key, {
|
|
63
|
+
enumerable: true,
|
|
64
|
+
get: function () {
|
|
65
|
+
return _AppleLoginUtil[key];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
var _constant = require("./constant");
|
|
70
|
+
Object.keys(_constant).forEach(function (key) {
|
|
71
|
+
if (key === "default" || key === "__esModule") return;
|
|
72
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
73
|
+
if (key in exports && exports[key] === _constant[key]) return;
|
|
74
|
+
Object.defineProperty(exports, key, {
|
|
75
|
+
enumerable: true,
|
|
76
|
+
get: function () {
|
|
77
|
+
return _constant[key];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
var _PrefData = require("./PrefData");
|
|
82
|
+
Object.keys(_PrefData).forEach(function (key) {
|
|
83
|
+
if (key === "default" || key === "__esModule") return;
|
|
84
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
85
|
+
if (key in exports && exports[key] === _PrefData[key]) return;
|
|
86
|
+
Object.defineProperty(exports, key, {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () {
|
|
89
|
+
return _PrefData[key];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
21
93
|
const {
|
|
22
94
|
ReactNativeToolkit
|
|
23
95
|
} = _reactNative.NativeModules;
|