Compare commits
10 Commits
3929fc2f8e
...
6d980a4c04
Author | SHA1 | Date | |
---|---|---|---|
|
6d980a4c04 | ||
|
084fbf35ee | ||
|
d666e8c0f3 | ||
|
5e89fb4a25 | ||
|
ab01b6010a | ||
|
92bc830d98 | ||
|
7531e8ca3a | ||
|
b2305cff3f | ||
|
c5cdb6031b | ||
|
20ebf8979e |
@ -94,7 +94,7 @@ apply from: "../../node_modules/react-native/react.gradle"
|
||||
* Upload all the APKs to the Play Store and people will download
|
||||
* the correct one based on the CPU architecture of their device.
|
||||
*/
|
||||
def enableSeparateBuildPerCPUArchitecture = false
|
||||
def enableSeparateBuildPerCPUArchitecture = true
|
||||
|
||||
/**
|
||||
* Run Proguard to shrink the Java bytecode in release builds.
|
||||
|
@ -20,7 +20,7 @@
|
||||
"react-native-camera-kit": "^14.0.0-beta15",
|
||||
"react-native-paper": "^5.12.1",
|
||||
"react-native-safe-area-context": "^4.8.2",
|
||||
"react-native-update": "^10.11.0",
|
||||
"react-native-update": "^10.11.3",
|
||||
"react-native-vector-icons": "^10.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* eslint-disable react/no-unstable-nested-components */
|
||||
/* eslint-disable react-native/no-inline-styles */
|
||||
import React, {useState} from 'react';
|
||||
import React, {useRef, useState} from 'react';
|
||||
import {
|
||||
StyleSheet,
|
||||
Platform,
|
||||
@ -47,6 +47,7 @@ function App() {
|
||||
const snackbarVisible =
|
||||
!useDefaultAlert && showUpdateSnackbar && updateInfo?.update;
|
||||
const [showCamera, setShowCamera] = useState(false);
|
||||
const lastParsedCode = useRef('');
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
@ -73,9 +74,16 @@ function App() {
|
||||
style={{minHeight: 320}}
|
||||
scanBarcode={true}
|
||||
onReadCode={({nativeEvent: {codeStringValue}}) => {
|
||||
console.log(codeStringValue);
|
||||
parseTestQrCode(codeStringValue);
|
||||
// 防止重复扫码
|
||||
if (lastParsedCode.current === codeStringValue) {
|
||||
return;
|
||||
}
|
||||
lastParsedCode.current = codeStringValue;
|
||||
setTimeout(() => {
|
||||
lastParsedCode.current = '';
|
||||
}, 1000);
|
||||
setShowCamera(false);
|
||||
parseTestQrCode(codeStringValue);
|
||||
}} // optional
|
||||
showFrame={true} // (default false) optional, show frame with transparent layer (qr code or barcode will be read on this area ONLY), start animation for scanner, that stops when a code has been found. Frame always at center of the screen
|
||||
laserColor="red" // (default red) optional, color of laser in scanner frame
|
||||
|
@ -2123,7 +2123,7 @@ buffer-from@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
|
||||
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
|
||||
|
||||
buffer@^5.5.0:
|
||||
buffer@^5.4.3, buffer@^5.5.0:
|
||||
version "5.7.1"
|
||||
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
|
||||
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
|
||||
@ -6159,7 +6159,7 @@ pump@^3.0.0:
|
||||
end-of-stream "^1.1.0"
|
||||
once "^1.3.1"
|
||||
|
||||
punycode@^2.1.0:
|
||||
punycode@^2.1.0, punycode@^2.1.1:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.1.tgz#027422e2faec0b25e1549c3e1bd8309b9133b6e5"
|
||||
integrity sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==
|
||||
@ -6236,12 +6236,20 @@ react-native-safe-area-context@^4.8.2:
|
||||
resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.8.2.tgz#e6b3d8acf3c6afcb4b5db03a97f9c37df7668f65"
|
||||
integrity sha512-ffUOv8BJQ6RqO3nLml5gxJ6ab3EestPiyWekxdzO/1MQ7NF8fW1Mzh1C5QE9yq573Xefnc7FuzGXjtesZGv7cQ==
|
||||
|
||||
react-native-update@^10.11.0:
|
||||
version "10.11.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.11.0.tgz#29f7a4dd847d2b9b7dbc720ccfaa1eabae82616d"
|
||||
integrity sha512-YPnJPGN38LqZvNgDEeqyjJqHs6sRGL2vxUt9pW0jRUx8wrTjBSf29bGQ55EonKa2Dsl8cqikr/zefImWqTLoMg==
|
||||
react-native-update@^10.11.3:
|
||||
version "10.11.3"
|
||||
resolved "https://registry.yarnpkg.com/react-native-update/-/react-native-update-10.11.3.tgz#5fa44fdd12514eb5e7901a5d664f00fd082d6774"
|
||||
integrity sha512-adI3sly0yFt1DfaPqICJ9VwzUoa/XAngv/N7SnICkLxO3jgccBgy0OrXDBxRn43Zeumdq40Z+ADTE5qrY4BWAw==
|
||||
dependencies:
|
||||
nanoid "^3.3.3"
|
||||
react-native-url-polyfill "^2.0.0"
|
||||
|
||||
react-native-url-polyfill@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz#db714520a2985cff1d50ab2e66279b9f91ffd589"
|
||||
integrity sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA==
|
||||
dependencies:
|
||||
whatwg-url-without-unicode "8.0.0-3"
|
||||
|
||||
react-native-vector-icons@^10.0.3:
|
||||
version "10.0.3"
|
||||
@ -7490,11 +7498,25 @@ webidl-conversions@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
|
||||
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
|
||||
|
||||
webidl-conversions@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
|
||||
integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==
|
||||
|
||||
whatwg-fetch@^3.0.0:
|
||||
version "3.6.20"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz#580ce6d791facec91d37c72890995a0b48d31c70"
|
||||
integrity sha512-EqhiFU6daOA8kpjOWTL0olhVOF3i7OrFzSYiGsEMB8GcXS+RrzauAERX65xMeNWVqxA6HXH2m69Z9LaKKdisfg==
|
||||
|
||||
whatwg-url-without-unicode@8.0.0-3:
|
||||
version "8.0.0-3"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b"
|
||||
integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig==
|
||||
dependencies:
|
||||
buffer "^5.4.3"
|
||||
punycode "^2.1.1"
|
||||
webidl-conversions "^5.0.0"
|
||||
|
||||
whatwg-url@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
|
||||
|
@ -610,7 +610,7 @@ RCT_EXPORT_METHOD(markSuccess:
|
||||
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
||||
(const facebook::react::ObjCTurboModule::InitParams &)params
|
||||
{
|
||||
return std::make_shared<facebook::react::NativeUpdateSpecJSI>(params);
|
||||
return std::make_shared<facebook::react::NativePushySpecJSI>(params);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "10.11.0",
|
||||
"version": "10.11.6",
|
||||
"description": "react-native hot update",
|
||||
"main": "src/index",
|
||||
"scripts": {
|
||||
@ -45,7 +45,8 @@
|
||||
},
|
||||
"homepage": "https://github.com/reactnativecn/react-native-pushy#readme",
|
||||
"dependencies": {
|
||||
"nanoid": "^3.3.3"
|
||||
"nanoid": "^3.3.3",
|
||||
"react-native-url-polyfill": "^2.0.0"
|
||||
},
|
||||
"codegenConfig": {
|
||||
"name": "RCTPushySpec",
|
||||
|
@ -172,7 +172,6 @@ export class Pushy {
|
||||
return await this.lastRespJson;
|
||||
}
|
||||
this.lastChecking = now;
|
||||
this.report({ type: 'checking' });
|
||||
const fetchBody = {
|
||||
packageVersion,
|
||||
hash: currentVersion,
|
||||
@ -183,16 +182,21 @@ export class Pushy {
|
||||
if (__DEV__) {
|
||||
delete fetchBody.buildTime;
|
||||
}
|
||||
const body = JSON.stringify(fetchBody);
|
||||
const fetchPayload = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(fetchBody),
|
||||
body,
|
||||
};
|
||||
let resp;
|
||||
try {
|
||||
this.report({
|
||||
type: 'checking',
|
||||
message: this.options.appKey + ': ' + body,
|
||||
});
|
||||
resp = await fetch(this.getCheckUrl(), fetchPayload);
|
||||
} catch (e: any) {
|
||||
this.report({
|
||||
@ -221,6 +225,8 @@ export class Pushy {
|
||||
|
||||
const result: CheckResult = await this.lastRespJson;
|
||||
|
||||
log('checking result:', result);
|
||||
|
||||
if (resp.status !== 200) {
|
||||
this.report({
|
||||
type: 'errorChecking',
|
||||
@ -293,7 +299,7 @@ export class Pushy {
|
||||
},
|
||||
);
|
||||
}
|
||||
let succeeded = false;
|
||||
let succeeded = '';
|
||||
this.report({ type: 'downloading' });
|
||||
let lastError: any;
|
||||
const diffUrl = (await testUrls(diffUrls)) || _diffUrl;
|
||||
@ -305,11 +311,11 @@ export class Pushy {
|
||||
hash,
|
||||
originHash: currentVersion,
|
||||
});
|
||||
succeeded = true;
|
||||
succeeded = 'diff';
|
||||
} catch (e: any) {
|
||||
lastError = e;
|
||||
if (__DEV__) {
|
||||
succeeded = true;
|
||||
succeeded = 'diff';
|
||||
} else {
|
||||
log(`diff error: ${e.message}, try pdiff`);
|
||||
}
|
||||
@ -323,11 +329,11 @@ export class Pushy {
|
||||
updateUrl: pdiffUrl,
|
||||
hash,
|
||||
});
|
||||
succeeded = true;
|
||||
succeeded = 'pdiff';
|
||||
} catch (e: any) {
|
||||
lastError = e;
|
||||
if (__DEV__) {
|
||||
succeeded = true;
|
||||
succeeded = 'pdiff';
|
||||
} else {
|
||||
log(`pdiff error: ${e.message}, try full patch`);
|
||||
}
|
||||
@ -341,11 +347,11 @@ export class Pushy {
|
||||
updateUrl: updateUrl,
|
||||
hash,
|
||||
});
|
||||
succeeded = true;
|
||||
succeeded = 'full';
|
||||
} catch (e: any) {
|
||||
lastError = e;
|
||||
if (__DEV__) {
|
||||
succeeded = true;
|
||||
succeeded = 'full';
|
||||
} else {
|
||||
log(`full patch error: ${e.message}`);
|
||||
}
|
||||
@ -367,8 +373,13 @@ export class Pushy {
|
||||
throw lastError;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
this.report({
|
||||
type: 'downloadSuccess',
|
||||
data: { newVersion: hash, diff: succeeded },
|
||||
});
|
||||
}
|
||||
log('downloaded hash:', hash);
|
||||
log(`downloaded ${succeeded} hash:`, hash);
|
||||
setLocalHashInfo(hash, {
|
||||
name,
|
||||
description,
|
||||
|
@ -21,6 +21,7 @@ import {
|
||||
} from './core';
|
||||
import { CheckResult, ProgressData, PushyTestPayload } from './type';
|
||||
import { PushyContext } from './context';
|
||||
import { URL } from 'react-native-url-polyfill';
|
||||
|
||||
export const PushyProvider = ({
|
||||
client,
|
||||
@ -146,7 +147,7 @@ export const PushyProvider = ({
|
||||
);
|
||||
|
||||
const checkUpdate = useCallback(
|
||||
async (extra?: Record<string, any>) => {
|
||||
async ({ extra }: { extra?: Record<string, any> } | undefined = {}) => {
|
||||
const now = Date.now();
|
||||
if (lastChecking.current && now - lastChecking.current < 1000) {
|
||||
return;
|
||||
@ -271,7 +272,7 @@ export const PushyProvider = ({
|
||||
Alert.alert(type, JSON.stringify(data));
|
||||
};
|
||||
if (payload.type === '__rnPushyVersionHash') {
|
||||
checkUpdate({ toHash: payload.data }).then(() => {
|
||||
checkUpdate({ extra: { toHash: payload.data } }).then(() => {
|
||||
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
||||
Alert.alert(
|
||||
'提示',
|
||||
@ -289,10 +290,9 @@ export const PushyProvider = ({
|
||||
);
|
||||
|
||||
const parseTestQrCode = useCallback(
|
||||
(code: string) => {
|
||||
let payload: PushyTestPayload;
|
||||
(code: string | PushyTestPayload) => {
|
||||
try {
|
||||
payload = JSON.parse(code);
|
||||
const payload = typeof code === 'string' ? JSON.parse(code) : code;
|
||||
return parseTestPayload(payload);
|
||||
} catch {
|
||||
return false;
|
||||
@ -306,7 +306,7 @@ export const PushyProvider = ({
|
||||
if (!url) {
|
||||
return;
|
||||
}
|
||||
const params = new URLSearchParams(url);
|
||||
const params = new URL(url).searchParams;
|
||||
const payload = {
|
||||
type: params.get('type'),
|
||||
data: params.get('data'),
|
||||
|
@ -28,6 +28,7 @@ export type EventType =
|
||||
| 'errorChecking'
|
||||
| 'checking'
|
||||
| 'downloading'
|
||||
| 'downloadSuccess'
|
||||
| 'errorUpdate'
|
||||
| 'markSuccess'
|
||||
| 'downloadingApk'
|
||||
|
23
yarn.lock
23
yarn.lock
@ -3198,7 +3198,7 @@ buffer-indexof-polyfill@~1.0.0:
|
||||
resolved "https://registry.npmjs.org/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz#d2732135c5999c64b277fcf9b1abe3498254729c"
|
||||
integrity sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A==
|
||||
|
||||
buffer@^5.5.0:
|
||||
buffer@^5.4.3, buffer@^5.5.0:
|
||||
version "5.7.1"
|
||||
resolved "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
|
||||
integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==
|
||||
@ -8604,6 +8604,13 @@ react-is@^17.0.1:
|
||||
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
|
||||
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
|
||||
|
||||
react-native-url-polyfill@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/react-native-url-polyfill/-/react-native-url-polyfill-2.0.0.tgz#db714520a2985cff1d50ab2e66279b9f91ffd589"
|
||||
integrity sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA==
|
||||
dependencies:
|
||||
whatwg-url-without-unicode "8.0.0-3"
|
||||
|
||||
react-native@0.73:
|
||||
version "0.73.2"
|
||||
resolved "https://registry.yarnpkg.com/react-native/-/react-native-0.73.2.tgz#74ee163c8189660d41d1da6560411da7ce41a608"
|
||||
@ -10174,6 +10181,11 @@ webidl-conversions@^3.0.0:
|
||||
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
|
||||
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
|
||||
|
||||
webidl-conversions@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
|
||||
integrity sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==
|
||||
|
||||
whatwg-fetch@^3.0.0:
|
||||
version "3.6.19"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.6.19.tgz#caefd92ae630b91c07345537e67f8354db470973"
|
||||
@ -10184,6 +10196,15 @@ whatwg-fetch@^3.4.1:
|
||||
resolved "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.2.tgz#dced24f37f2624ed0281725d51d0e2e3fe677f8c"
|
||||
integrity sha512-bJlen0FcuU/0EMLrdbJ7zOnW6ITZLrZMIarMUVmdKtsGvZna8vxKYaexICWPfZ8qwf9fzNq+UEIZrnSaApt6RA==
|
||||
|
||||
whatwg-url-without-unicode@8.0.0-3:
|
||||
version "8.0.0-3"
|
||||
resolved "https://registry.yarnpkg.com/whatwg-url-without-unicode/-/whatwg-url-without-unicode-8.0.0-3.tgz#ab6df4bf6caaa6c85a59f6e82c026151d4bb376b"
|
||||
integrity sha512-HoKuzZrUlgpz35YO27XgD28uh/WJH4B0+3ttFqRo//lmq+9T/mIOJ6kqmINI9HpUpz1imRC/nR/lxKpJiv0uig==
|
||||
dependencies:
|
||||
buffer "^5.4.3"
|
||||
punycode "^2.1.1"
|
||||
webidl-conversions "^5.0.0"
|
||||
|
||||
whatwg-url@^5.0.0:
|
||||
version "5.0.0"
|
||||
resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
|
||||
|
Loading…
Reference in New Issue
Block a user