mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-11-22 23:46:10 +08:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33bc69c3fb | ||
|
|
5028ce31be | ||
|
|
d3a4007763 | ||
|
|
a4f3e3cc38 | ||
|
|
9d51128ed3 | ||
|
|
eddb072927 | ||
|
|
4f9417d620 | ||
|
|
6f2314d3c9 | ||
|
|
a6e9ece559 | ||
|
|
78430e2ec2 | ||
|
|
ec5b9e1938 | ||
|
|
53dfb45ca2 | ||
|
|
4a62e89c73 | ||
|
|
655f4c8cf5 | ||
|
|
3732c196a1 | ||
|
|
bfb520bd07 | ||
|
|
f7be8a4d71 | ||
|
|
4383a66274 | ||
|
|
a82b75f51f | ||
|
|
584f698329 | ||
|
|
e58903a634 | ||
|
|
41e1028b2d |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -51,4 +51,4 @@ android/bin
|
|||||||
Example/testHotUpdate/harmony
|
Example/testHotUpdate/harmony
|
||||||
Example/testHotUpdate/android/app/.cxx
|
Example/testHotUpdate/android/app/.cxx
|
||||||
Example/harmony_use_pushy/libs
|
Example/harmony_use_pushy/libs
|
||||||
.cursor/mcp.json
|
**/mcp.json
|
||||||
|
|||||||
@@ -4,11 +4,14 @@
|
|||||||
"": {
|
"": {
|
||||||
"name": "expousepushy",
|
"name": "expousepushy",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@expo/metro-runtime": "~4.0.1",
|
||||||
"expo": "~52.0.46",
|
"expo": "~52.0.46",
|
||||||
"expo-status-bar": "~2.0.1",
|
"expo-status-bar": "~2.0.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
|
"react-dom": "18.3.1",
|
||||||
"react-native": "0.76.9",
|
"react-native": "0.76.9",
|
||||||
"react-native-update": "^10.28.7",
|
"react-native-update": "^10.30.3",
|
||||||
|
"react-native-web": "~0.19.13",
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.25.2",
|
"@babel/core": "^7.25.2",
|
||||||
@@ -302,6 +305,8 @@
|
|||||||
|
|
||||||
"@expo/metro-config": ["@expo/metro-config@0.19.12", "", { "dependencies": { "@babel/core": "^7.20.0", "@babel/generator": "^7.20.5", "@babel/parser": "^7.20.0", "@babel/types": "^7.20.0", "@expo/config": "~10.0.11", "@expo/env": "~0.4.2", "@expo/json-file": "~9.0.2", "@expo/spawn-async": "^1.7.2", "chalk": "^4.1.0", "debug": "^4.3.2", "fs-extra": "^9.1.0", "getenv": "^1.0.0", "glob": "^10.4.2", "jsc-safe-url": "^0.2.4", "lightningcss": "~1.27.0", "minimatch": "^3.0.4", "postcss": "~8.4.32", "resolve-from": "^5.0.0" } }, "sha512-fhT3x1ikQWHpZgw7VrEghBdscFPz1laRYa8WcVRB18nTTqorF6S8qPYslkJu1faEziHZS7c2uyDzTYnrg/CKbg=="],
|
"@expo/metro-config": ["@expo/metro-config@0.19.12", "", { "dependencies": { "@babel/core": "^7.20.0", "@babel/generator": "^7.20.5", "@babel/parser": "^7.20.0", "@babel/types": "^7.20.0", "@expo/config": "~10.0.11", "@expo/env": "~0.4.2", "@expo/json-file": "~9.0.2", "@expo/spawn-async": "^1.7.2", "chalk": "^4.1.0", "debug": "^4.3.2", "fs-extra": "^9.1.0", "getenv": "^1.0.0", "glob": "^10.4.2", "jsc-safe-url": "^0.2.4", "lightningcss": "~1.27.0", "minimatch": "^3.0.4", "postcss": "~8.4.32", "resolve-from": "^5.0.0" } }, "sha512-fhT3x1ikQWHpZgw7VrEghBdscFPz1laRYa8WcVRB18nTTqorF6S8qPYslkJu1faEziHZS7c2uyDzTYnrg/CKbg=="],
|
||||||
|
|
||||||
|
"@expo/metro-runtime": ["@expo/metro-runtime@4.0.1", "", { "peerDependencies": { "react-native": "*" } }, "sha512-CRpbLvdJ1T42S+lrYa1iZp1KfDeBp4oeZOK3hdpiS5n0vR0nhD6sC1gGF0sTboCTp64tLteikz5Y3j53dvgOIw=="],
|
||||||
|
|
||||||
"@expo/osascript": ["@expo/osascript@2.1.6", "", { "dependencies": { "@expo/spawn-async": "^1.7.2", "exec-async": "^2.2.0" } }, "sha512-SbMp4BUwDAKiFF4zZEJf32rRYMeNnLK9u4FaPo0lQRer60F+SKd20NTSys0wgssiVeQyQz2OhGLRx3cxYowAGw=="],
|
"@expo/osascript": ["@expo/osascript@2.1.6", "", { "dependencies": { "@expo/spawn-async": "^1.7.2", "exec-async": "^2.2.0" } }, "sha512-SbMp4BUwDAKiFF4zZEJf32rRYMeNnLK9u4FaPo0lQRer60F+SKd20NTSys0wgssiVeQyQz2OhGLRx3cxYowAGw=="],
|
||||||
|
|
||||||
"@expo/package-manager": ["@expo/package-manager@1.7.2", "", { "dependencies": { "@expo/json-file": "^9.0.2", "@expo/spawn-async": "^1.7.2", "ansi-regex": "^5.0.0", "chalk": "^4.0.0", "find-up": "^5.0.0", "js-yaml": "^3.13.1", "micromatch": "^4.0.8", "npm-package-arg": "^11.0.0", "ora": "^3.4.0", "resolve-workspace-root": "^2.0.0", "split": "^1.0.1", "sudo-prompt": "9.1.1" } }, "sha512-wT/qh9ebNjl6xr00bYkSh93b6E/78J3JPlT6WzGbxbsnv5FIZKB/nr522oWqVe1E+ML7BpXs8WugErWDN9kOFg=="],
|
"@expo/package-manager": ["@expo/package-manager@1.7.2", "", { "dependencies": { "@expo/json-file": "^9.0.2", "@expo/spawn-async": "^1.7.2", "ansi-regex": "^5.0.0", "chalk": "^4.0.0", "find-up": "^5.0.0", "js-yaml": "^3.13.1", "micromatch": "^4.0.8", "npm-package-arg": "^11.0.0", "ora": "^3.4.0", "resolve-workspace-root": "^2.0.0", "split": "^1.0.1", "sudo-prompt": "9.1.1" } }, "sha512-wT/qh9ebNjl6xr00bYkSh93b6E/78J3JPlT6WzGbxbsnv5FIZKB/nr522oWqVe1E+ML7BpXs8WugErWDN9kOFg=="],
|
||||||
@@ -600,6 +605,8 @@
|
|||||||
|
|
||||||
"crypto-random-string": ["crypto-random-string@2.0.0", "", {}, "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA=="],
|
"crypto-random-string": ["crypto-random-string@2.0.0", "", {}, "sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA=="],
|
||||||
|
|
||||||
|
"css-in-js-utils": ["css-in-js-utils@3.1.0", "", { "dependencies": { "hyphenate-style-name": "^1.0.3" } }, "sha512-fJAcud6B3rRu+KHYk+Bwf+WFL2MDCJJ1XG9x137tJQ0xYxor7XziQtuGFbWNdqrvF4Tk26O3H73nfVqXt/fW1A=="],
|
||||||
|
|
||||||
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
|
"csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
|
||||||
|
|
||||||
"debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="],
|
"debug": ["debug@4.4.0", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA=="],
|
||||||
@@ -700,6 +707,8 @@
|
|||||||
|
|
||||||
"fast-json-stable-stringify": ["fast-json-stable-stringify@2.1.0", "", {}, "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="],
|
"fast-json-stable-stringify": ["fast-json-stable-stringify@2.1.0", "", {}, "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="],
|
||||||
|
|
||||||
|
"fast-loops": ["fast-loops@1.1.4", "", {}, "sha512-8dbd3XWoKCTms18ize6JmQF1SFnnfj5s0B7rRry22EofgMu7B6LKHVh+XfFqFGsqnbH54xgeO83PzpKI+ODhlg=="],
|
||||||
|
|
||||||
"fastq": ["fastq@1.19.1", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="],
|
"fastq": ["fastq@1.19.1", "", { "dependencies": { "reusify": "^1.0.4" } }, "sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ=="],
|
||||||
|
|
||||||
"fb-watchman": ["fb-watchman@2.0.2", "", { "dependencies": { "bser": "2.1.1" } }, "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA=="],
|
"fb-watchman": ["fb-watchman@2.0.2", "", { "dependencies": { "bser": "2.1.1" } }, "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA=="],
|
||||||
@@ -788,6 +797,8 @@
|
|||||||
|
|
||||||
"human-signals": ["human-signals@2.1.0", "", {}, "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="],
|
"human-signals": ["human-signals@2.1.0", "", {}, "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw=="],
|
||||||
|
|
||||||
|
"hyphenate-style-name": ["hyphenate-style-name@1.1.0", "", {}, "sha512-WDC/ui2VVRrz3jOVi+XtjqkDjiVjTtFaAGiW37k6b+ohyQ5wYDOGkvCZa8+H0nx3gyvv0+BST9xuOgIyGQ00gw=="],
|
||||||
|
|
||||||
"ieee754": ["ieee754@1.2.1", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
|
"ieee754": ["ieee754@1.2.1", "", {}, "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA=="],
|
||||||
|
|
||||||
"ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="],
|
"ignore": ["ignore@5.3.2", "", {}, "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g=="],
|
||||||
@@ -806,6 +817,8 @@
|
|||||||
|
|
||||||
"ini": ["ini@1.3.8", "", {}, "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="],
|
"ini": ["ini@1.3.8", "", {}, "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew=="],
|
||||||
|
|
||||||
|
"inline-style-prefixer": ["inline-style-prefixer@6.0.4", "", { "dependencies": { "css-in-js-utils": "^3.1.0", "fast-loops": "^1.1.3" } }, "sha512-FwXmZC2zbeeS7NzGjJ6pAiqRhXR0ugUShSNb6GApMl6da0/XGc4MOJsoWAywia52EEWbXNSy0pzkwz/+Y+swSg=="],
|
||||||
|
|
||||||
"internal-ip": ["internal-ip@4.3.0", "", { "dependencies": { "default-gateway": "^4.2.0", "ipaddr.js": "^1.9.0" } }, "sha512-S1zBo1D6zcsyuC6PMmY5+55YMILQ9av8lotMx447Bq6SAgo/sDK6y6uUKmuYhW7eacnIhFfsPmCNYdDzsnnDCg=="],
|
"internal-ip": ["internal-ip@4.3.0", "", { "dependencies": { "default-gateway": "^4.2.0", "ipaddr.js": "^1.9.0" } }, "sha512-S1zBo1D6zcsyuC6PMmY5+55YMILQ9av8lotMx447Bq6SAgo/sDK6y6uUKmuYhW7eacnIhFfsPmCNYdDzsnnDCg=="],
|
||||||
|
|
||||||
"invariant": ["invariant@2.2.4", "", { "dependencies": { "loose-envify": "^1.0.0" } }, "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA=="],
|
"invariant": ["invariant@2.2.4", "", { "dependencies": { "loose-envify": "^1.0.0" } }, "sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA=="],
|
||||||
@@ -1102,6 +1115,8 @@
|
|||||||
|
|
||||||
"postcss": ["postcss@8.4.49", "", { "dependencies": { "nanoid": "^3.3.7", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA=="],
|
"postcss": ["postcss@8.4.49", "", { "dependencies": { "nanoid": "^3.3.7", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA=="],
|
||||||
|
|
||||||
|
"postcss-value-parser": ["postcss-value-parser@4.2.0", "", {}, "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ=="],
|
||||||
|
|
||||||
"pretty-bytes": ["pretty-bytes@5.6.0", "", {}, "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg=="],
|
"pretty-bytes": ["pretty-bytes@5.6.0", "", {}, "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg=="],
|
||||||
|
|
||||||
"pretty-format": ["pretty-format@29.7.0", "", { "dependencies": { "@jest/schemas": "^29.6.3", "ansi-styles": "^5.0.0", "react-is": "^18.0.0" } }, "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ=="],
|
"pretty-format": ["pretty-format@29.7.0", "", { "dependencies": { "@jest/schemas": "^29.6.3", "ansi-styles": "^5.0.0", "react-is": "^18.0.0" } }, "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ=="],
|
||||||
@@ -1132,14 +1147,18 @@
|
|||||||
|
|
||||||
"react-devtools-core": ["react-devtools-core@5.3.2", "", { "dependencies": { "shell-quote": "^1.6.1", "ws": "^7" } }, "sha512-crr9HkVrDiJ0A4zot89oS0Cgv0Oa4OG1Em4jit3P3ZxZSKPMYyMjfwMqgcJna9o625g8oN87rBm8SWWrSTBZxg=="],
|
"react-devtools-core": ["react-devtools-core@5.3.2", "", { "dependencies": { "shell-quote": "^1.6.1", "ws": "^7" } }, "sha512-crr9HkVrDiJ0A4zot89oS0Cgv0Oa4OG1Em4jit3P3ZxZSKPMYyMjfwMqgcJna9o625g8oN87rBm8SWWrSTBZxg=="],
|
||||||
|
|
||||||
|
"react-dom": ["react-dom@18.3.1", "", { "dependencies": { "loose-envify": "^1.1.0", "scheduler": "^0.23.2" }, "peerDependencies": { "react": "^18.3.1" } }, "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw=="],
|
||||||
|
|
||||||
"react-is": ["react-is@18.3.1", "", {}, "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg=="],
|
"react-is": ["react-is@18.3.1", "", {}, "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg=="],
|
||||||
|
|
||||||
"react-native": ["react-native@0.76.9", "", { "dependencies": { "@jest/create-cache-key-function": "^29.6.3", "@react-native/assets-registry": "0.76.9", "@react-native/codegen": "0.76.9", "@react-native/community-cli-plugin": "0.76.9", "@react-native/gradle-plugin": "0.76.9", "@react-native/js-polyfills": "0.76.9", "@react-native/normalize-colors": "0.76.9", "@react-native/virtualized-lists": "0.76.9", "abort-controller": "^3.0.0", "anser": "^1.4.9", "ansi-regex": "^5.0.0", "babel-jest": "^29.7.0", "babel-plugin-syntax-hermes-parser": "^0.23.1", "base64-js": "^1.5.1", "chalk": "^4.0.0", "commander": "^12.0.0", "event-target-shim": "^5.0.1", "flow-enums-runtime": "^0.0.6", "glob": "^7.1.1", "invariant": "^2.2.4", "jest-environment-node": "^29.6.3", "jsc-android": "^250231.0.0", "memoize-one": "^5.0.0", "metro-runtime": "^0.81.0", "metro-source-map": "^0.81.0", "mkdirp": "^0.5.1", "nullthrows": "^1.1.1", "pretty-format": "^29.7.0", "promise": "^8.3.0", "react-devtools-core": "^5.3.1", "react-refresh": "^0.14.0", "regenerator-runtime": "^0.13.2", "scheduler": "0.24.0-canary-efb381bbf-20230505", "semver": "^7.1.3", "stacktrace-parser": "^0.1.10", "whatwg-fetch": "^3.0.0", "ws": "^6.2.3", "yargs": "^17.6.2" }, "peerDependencies": { "@types/react": "^18.2.6", "react": "^18.2.0" }, "optionalPeers": ["@types/react"], "bin": { "react-native": "cli.js" } }, "sha512-+LRwecWmTDco7OweGsrECIqJu0iyrREd6CTCgC/uLLYipiHvk+MH9nd6drFtCw/6Blz6eoKTcH9YTTJusNtrWg=="],
|
"react-native": ["react-native@0.76.9", "", { "dependencies": { "@jest/create-cache-key-function": "^29.6.3", "@react-native/assets-registry": "0.76.9", "@react-native/codegen": "0.76.9", "@react-native/community-cli-plugin": "0.76.9", "@react-native/gradle-plugin": "0.76.9", "@react-native/js-polyfills": "0.76.9", "@react-native/normalize-colors": "0.76.9", "@react-native/virtualized-lists": "0.76.9", "abort-controller": "^3.0.0", "anser": "^1.4.9", "ansi-regex": "^5.0.0", "babel-jest": "^29.7.0", "babel-plugin-syntax-hermes-parser": "^0.23.1", "base64-js": "^1.5.1", "chalk": "^4.0.0", "commander": "^12.0.0", "event-target-shim": "^5.0.1", "flow-enums-runtime": "^0.0.6", "glob": "^7.1.1", "invariant": "^2.2.4", "jest-environment-node": "^29.6.3", "jsc-android": "^250231.0.0", "memoize-one": "^5.0.0", "metro-runtime": "^0.81.0", "metro-source-map": "^0.81.0", "mkdirp": "^0.5.1", "nullthrows": "^1.1.1", "pretty-format": "^29.7.0", "promise": "^8.3.0", "react-devtools-core": "^5.3.1", "react-refresh": "^0.14.0", "regenerator-runtime": "^0.13.2", "scheduler": "0.24.0-canary-efb381bbf-20230505", "semver": "^7.1.3", "stacktrace-parser": "^0.1.10", "whatwg-fetch": "^3.0.0", "ws": "^6.2.3", "yargs": "^17.6.2" }, "peerDependencies": { "@types/react": "^18.2.6", "react": "^18.2.0" }, "optionalPeers": ["@types/react"], "bin": { "react-native": "cli.js" } }, "sha512-+LRwecWmTDco7OweGsrECIqJu0iyrREd6CTCgC/uLLYipiHvk+MH9nd6drFtCw/6Blz6eoKTcH9YTTJusNtrWg=="],
|
||||||
|
|
||||||
"react-native-update": ["react-native-update@10.28.7", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-/KeBMqNEKoCWs2sTE5hG/uJ8PtYp9cMts9OcotVBcTnkKZ/Ix4pNNoMzoxQmOGGMHykElk+3sDu0JWzLz7T1fw=="],
|
"react-native-update": ["react-native-update@10.30.3", "", { "dependencies": { "nanoid": "^3.3.3", "react-native-url-polyfill": "^2.0.0" }, "peerDependencies": { "react": ">=16.8.0", "react-native": ">=0.59.0" } }, "sha512-ImSWIqJZ8rvxotTxHC5/yc5KLDyYuRk3maNxmphh37A6hODPiTxL+ahPTu3ghrHK3vyJtS7xrIeTM5gnJWYFcA=="],
|
||||||
|
|
||||||
"react-native-url-polyfill": ["react-native-url-polyfill@2.0.0", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="],
|
"react-native-url-polyfill": ["react-native-url-polyfill@2.0.0", "", { "dependencies": { "whatwg-url-without-unicode": "8.0.0-3" }, "peerDependencies": { "react-native": "*" } }, "sha512-My330Do7/DvKnEvwQc0WdcBnFPploYKp9CYlefDXzIdEaA+PAhDYllkvGeEroEzvc4Kzzj2O4yVdz8v6fjRvhA=="],
|
||||||
|
|
||||||
|
"react-native-web": ["react-native-web@0.19.13", "", { "dependencies": { "@babel/runtime": "^7.18.6", "@react-native/normalize-colors": "^0.74.1", "fbjs": "^3.0.4", "inline-style-prefixer": "^6.0.1", "memoize-one": "^6.0.0", "nullthrows": "^1.1.1", "postcss-value-parser": "^4.2.0", "styleq": "^0.1.3" }, "peerDependencies": { "react": "^18.0.0", "react-dom": "^18.0.0" } }, "sha512-etv3bN8rJglrRCp/uL4p7l8QvUNUC++QwDbdZ8CB7BvZiMvsxfFIRM1j04vxNldG3uo2puRd6OSWR3ibtmc29A=="],
|
||||||
|
|
||||||
"react-refresh": ["react-refresh@0.14.2", "", {}, "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA=="],
|
"react-refresh": ["react-refresh@0.14.2", "", {}, "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA=="],
|
||||||
|
|
||||||
"readline": ["readline@1.3.0", "", {}, "sha512-k2d6ACCkiNYz222Fs/iNze30rRJ1iIicW7JuX/7/cozvih6YCkFZH+J6mAFDVgv0dRBaAyr4jDqC95R2y4IADg=="],
|
"readline": ["readline@1.3.0", "", {}, "sha512-k2d6ACCkiNYz222Fs/iNze30rRJ1iIicW7JuX/7/cozvih6YCkFZH+J6mAFDVgv0dRBaAyr4jDqC95R2y4IADg=="],
|
||||||
@@ -1188,7 +1207,7 @@
|
|||||||
|
|
||||||
"sax": ["sax@1.4.1", "", {}, "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg=="],
|
"sax": ["sax@1.4.1", "", {}, "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg=="],
|
||||||
|
|
||||||
"scheduler": ["scheduler@0.24.0-canary-efb381bbf-20230505", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-ABvovCDe/k9IluqSh4/ISoq8tIJnW8euVAWYt5j/bg6dRnqwQwiGO1F/V4AyK96NGF/FB04FhOUDuWj8IKfABA=="],
|
"scheduler": ["scheduler@0.23.2", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ=="],
|
||||||
|
|
||||||
"selfsigned": ["selfsigned@2.4.1", "", { "dependencies": { "@types/node-forge": "^1.3.0", "node-forge": "^1" } }, "sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q=="],
|
"selfsigned": ["selfsigned@2.4.1", "", { "dependencies": { "@types/node-forge": "^1.3.0", "node-forge": "^1" } }, "sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q=="],
|
||||||
|
|
||||||
@@ -1260,6 +1279,8 @@
|
|||||||
|
|
||||||
"structured-headers": ["structured-headers@0.4.1", "", {}, "sha512-0MP/Cxx5SzeeZ10p/bZI0S6MpgD+yxAhi1BOQ34jgnMXsCq3j1t6tQnZu+KdlL7dvJTLT3g9xN8tl10TqgFMcg=="],
|
"structured-headers": ["structured-headers@0.4.1", "", {}, "sha512-0MP/Cxx5SzeeZ10p/bZI0S6MpgD+yxAhi1BOQ34jgnMXsCq3j1t6tQnZu+KdlL7dvJTLT3g9xN8tl10TqgFMcg=="],
|
||||||
|
|
||||||
|
"styleq": ["styleq@0.1.3", "", {}, "sha512-3ZUifmCDCQanjeej1f6kyl/BeP/Vae5EYkQ9iJfUm/QwZvlgnZzyflqAsAWYURdtea8Vkvswu2GrC57h3qffcA=="],
|
||||||
|
|
||||||
"sucrase": ["sucrase@3.35.0", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.2", "commander": "^4.0.0", "glob": "^10.3.10", "lines-and-columns": "^1.1.6", "mz": "^2.7.0", "pirates": "^4.0.1", "ts-interface-checker": "^0.1.9" }, "bin": { "sucrase": "bin/sucrase", "sucrase-node": "bin/sucrase-node" } }, "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA=="],
|
"sucrase": ["sucrase@3.35.0", "", { "dependencies": { "@jridgewell/gen-mapping": "^0.3.2", "commander": "^4.0.0", "glob": "^10.3.10", "lines-and-columns": "^1.1.6", "mz": "^2.7.0", "pirates": "^4.0.1", "ts-interface-checker": "^0.1.9" }, "bin": { "sucrase": "bin/sucrase", "sucrase-node": "bin/sucrase-node" } }, "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA=="],
|
||||||
|
|
||||||
"sudo-prompt": ["sudo-prompt@9.1.1", "", {}, "sha512-es33J1g2HjMpyAhz8lOR+ICmXXAqTuKbuXuUWLhOLew20oN9oUCgCJx615U/v7aioZg7IX5lIh9x34vwneu4pA=="],
|
"sudo-prompt": ["sudo-prompt@9.1.1", "", {}, "sha512-es33J1g2HjMpyAhz8lOR+ICmXXAqTuKbuXuUWLhOLew20oN9oUCgCJx615U/v7aioZg7IX5lIh9x34vwneu4pA=="],
|
||||||
@@ -1544,8 +1565,14 @@
|
|||||||
|
|
||||||
"react-devtools-core/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="],
|
"react-devtools-core/ws": ["ws@7.5.10", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": "^5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ=="],
|
||||||
|
|
||||||
|
"react-native/scheduler": ["scheduler@0.24.0-canary-efb381bbf-20230505", "", { "dependencies": { "loose-envify": "^1.1.0" } }, "sha512-ABvovCDe/k9IluqSh4/ISoq8tIJnW8euVAWYt5j/bg6dRnqwQwiGO1F/V4AyK96NGF/FB04FhOUDuWj8IKfABA=="],
|
||||||
|
|
||||||
"react-native/semver": ["semver@7.7.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA=="],
|
"react-native/semver": ["semver@7.7.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA=="],
|
||||||
|
|
||||||
|
"react-native-web/@react-native/normalize-colors": ["@react-native/normalize-colors@0.74.89", "", {}, "sha512-qoMMXddVKVhZ8PA1AbUCk83trpd6N+1nF2A6k1i6LsQObyS92fELuk8kU/lQs6M7BsMHwqyLCpQJ1uFgNvIQXg=="],
|
||||||
|
|
||||||
|
"react-native-web/memoize-one": ["memoize-one@6.0.0", "", {}, "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw=="],
|
||||||
|
|
||||||
"recast/source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
|
"recast/source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="],
|
||||||
|
|
||||||
"regjsparser/jsesc": ["jsesc@3.0.2", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g=="],
|
"regjsparser/jsesc": ["jsesc@3.0.2", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g=="],
|
||||||
|
|||||||
@@ -9,11 +9,14 @@
|
|||||||
"web": "expo start --web"
|
"web": "expo start --web"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@expo/metro-runtime": "~4.0.1",
|
||||||
"expo": "~52.0.46",
|
"expo": "~52.0.46",
|
||||||
"expo-status-bar": "~2.0.1",
|
"expo-status-bar": "~2.0.1",
|
||||||
"react": "18.3.1",
|
"react": "18.3.1",
|
||||||
|
"react-dom": "18.3.1",
|
||||||
"react-native": "0.76.9",
|
"react-native": "0.76.9",
|
||||||
"react-native-update": "^10.28.7"
|
"react-native-update": "^10.30.3",
|
||||||
|
"react-native-web": "~0.19.13"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.25.2",
|
"@babel/core": "^7.25.2",
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
arrowParens: 'avoid',
|
arrowParens: 'avoid',
|
||||||
bracketSameLine: true,
|
|
||||||
bracketSpacing: false,
|
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
trailingComma: 'all',
|
trailingComma: 'all',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ android {
|
|||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.81.4"
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
debug {
|
debug {
|
||||||
|
|||||||
@@ -5,13 +5,11 @@ import cn.reactnative.modules.update.UpdateContext
|
|||||||
import com.facebook.react.PackageList
|
import com.facebook.react.PackageList
|
||||||
import com.facebook.react.ReactApplication
|
import com.facebook.react.ReactApplication
|
||||||
import com.facebook.react.ReactHost
|
import com.facebook.react.ReactHost
|
||||||
|
import com.facebook.react.ReactNativeApplicationEntryPoint.loadReactNative
|
||||||
import com.facebook.react.ReactNativeHost
|
import com.facebook.react.ReactNativeHost
|
||||||
import com.facebook.react.ReactPackage
|
import com.facebook.react.ReactPackage
|
||||||
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
|
|
||||||
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
|
||||||
import com.facebook.react.defaults.DefaultReactNativeHost
|
import com.facebook.react.defaults.DefaultReactNativeHost
|
||||||
import com.facebook.react.soloader.OpenSourceMergedSoMapping
|
|
||||||
import com.facebook.soloader.SoLoader
|
|
||||||
|
|
||||||
class MainApplication : Application(), ReactApplication {
|
class MainApplication : Application(), ReactApplication {
|
||||||
|
|
||||||
@@ -39,10 +37,6 @@ class MainApplication : Application(), ReactApplication {
|
|||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
SoLoader.init(this, OpenSourceMergedSoMapping)
|
loadReactNative(this)
|
||||||
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
||||||
// If you opted-in for the New Architecture, we load the native entry point for this app.
|
|
||||||
load()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
ext {
|
||||||
buildToolsVersion = "35.0.0"
|
buildToolsVersion = "36.0.0"
|
||||||
minSdkVersion = 24
|
minSdkVersion = 24
|
||||||
compileSdkVersion = 35
|
compileSdkVersion = 36
|
||||||
targetSdkVersion = 35
|
targetSdkVersion = 36
|
||||||
ndkVersion = "27.1.12297006"
|
ndkVersion = "27.1.12297006"
|
||||||
kotlinVersion = "2.0.21"
|
kotlinVersion = "2.1.20"
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ android.useAndroidX=true
|
|||||||
# Use this property to specify which architecture you want to build.
|
# Use this property to specify which architecture you want to build.
|
||||||
# You can also override it from the CLI using
|
# You can also override it from the CLI using
|
||||||
# ./gradlew <task> -PreactNativeArchitectures=x86_64
|
# ./gradlew <task> -PreactNativeArchitectures=x86_64
|
||||||
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
|
# reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
|
||||||
|
reactNativeArchitectures=arm64-v8a
|
||||||
|
|
||||||
# Use this property to enable support to the new architecture.
|
# Use this property to enable support to the new architecture.
|
||||||
# This will allow you to use TurboModules and the Fabric render in
|
# This will allow you to use TurboModules and the Fabric render in
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
6
Example/testHotUpdate/android/gradlew
vendored
6
Example/testHotUpdate/android/gradlew
vendored
@@ -114,7 +114,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -205,7 +205,7 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
@@ -213,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
|||||||
9
Example/testHotUpdate/android/gradlew.bat
vendored
9
Example/testHotUpdate/android/gradlew.bat
vendored
@@ -1,3 +1,8 @@
|
|||||||
|
@REM Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
@REM
|
||||||
|
@REM This source code is licensed under the MIT license found in the
|
||||||
|
@REM LICENSE file in the root directory of this source tree.
|
||||||
|
|
||||||
@rem
|
@rem
|
||||||
@rem Copyright 2015 the original author or authors.
|
@rem Copyright 2015 the original author or authors.
|
||||||
@rem
|
@rem
|
||||||
@@ -70,11 +75,11 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -37,8 +37,14 @@
|
|||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
</dict>
|
</dict>
|
||||||
|
<key>NSCameraUsageDescription</key>
|
||||||
|
<string>For taking photos</string>
|
||||||
<key>NSLocationWhenInUseUsageDescription</key>
|
<key>NSLocationWhenInUseUsageDescription</key>
|
||||||
<string></string>
|
<string></string>
|
||||||
|
<key>NSPhotoLibraryUsageDescription</key>
|
||||||
|
<string>For saving photos</string>
|
||||||
|
<key>RCTNewArchEnabled</key>
|
||||||
|
<true/>
|
||||||
<key>UILaunchStoryboardName</key>
|
<key>UILaunchStoryboardName</key>
|
||||||
<string>LaunchScreen</string>
|
<string>LaunchScreen</string>
|
||||||
<key>UIRequiredDeviceCapabilities</key>
|
<key>UIRequiredDeviceCapabilities</key>
|
||||||
@@ -53,10 +59,5 @@
|
|||||||
</array>
|
</array>
|
||||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>NSCameraUsageDescription</key>
|
|
||||||
<string>For taking photos</string>
|
|
||||||
|
|
||||||
<key>NSPhotoLibraryUsageDescription</key>
|
|
||||||
<string>For saving photos</string>
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -14,39 +14,39 @@
|
|||||||
"dev:harmony": "react-native bundle-harmony --dev"
|
"dev:harmony": "react-native bundle-harmony --dev"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"form-data": "^4.0.3",
|
"form-data": "^4.0.4",
|
||||||
"patch-package": "^8.0.0",
|
"patch-package": "^8.0.0",
|
||||||
"react": "19.0.0",
|
"react": "19.1.0",
|
||||||
"react-native": "0.79.2",
|
"react-native": "0.81.4",
|
||||||
"react-native-camera-kit": "^15.1.0",
|
"react-native-camera-kit": "^16.1.2",
|
||||||
"react-native-paper": "^5.14.5",
|
"react-native-paper": "^5.14.5",
|
||||||
"react-native-safe-area-context": "^5.5.0",
|
"react-native-safe-area-context": "^5.6.1",
|
||||||
"react-native-svg": "^15.12.0",
|
"react-native-svg": "^15.13.0",
|
||||||
"react-native-update": "^10.29.4",
|
"react-native-update": "^10.31.2",
|
||||||
"react-native-vector-icons": "^10.2.0"
|
"react-native-vector-icons": "^10.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.27.3",
|
"@babel/core": "^7.27.3",
|
||||||
"@babel/preset-env": "^7.27.2",
|
"@babel/preset-env": "^7.27.2",
|
||||||
"@babel/runtime": "^7.27.3",
|
"@babel/runtime": "^7.27.3",
|
||||||
"@react-native-community/cli": "18.0.0",
|
"@react-native-community/cli": "20.0.0",
|
||||||
"@react-native-community/cli-platform-android": "18.0.0",
|
"@react-native-community/cli-platform-android": "20.0.0",
|
||||||
"@react-native-community/cli-platform-ios": "18.0.0",
|
"@react-native-community/cli-platform-ios": "20.0.0",
|
||||||
"@react-native/babel-preset": "0.79.2",
|
"@react-native/babel-preset": "0.81.4",
|
||||||
"@react-native/eslint-config": "0.79.2",
|
"@react-native/eslint-config": "0.81.4",
|
||||||
"@react-native/metro-config": "0.79.2",
|
"@react-native/metro-config": "0.81.4",
|
||||||
"@react-native/typescript-config": "0.79.2",
|
"@react-native/typescript-config": "0.81.4",
|
||||||
"@types/react": "^19.0.0",
|
"@types/react": "^19.1.13",
|
||||||
"@types/react-test-renderer": "^19.0.0",
|
"@types/react-test-renderer": "^19.1.0",
|
||||||
"detox": "^20.39.0",
|
"detox": "^20.41.2",
|
||||||
"eslint": "^8.19.0",
|
"eslint": "^9.35.0",
|
||||||
"jest": "^29.6.3",
|
"jest": "^29.6.3",
|
||||||
"prettier": "2.8.8",
|
"prettier": "2.8.8",
|
||||||
"react-test-renderer": "19.0.0",
|
"react-test-renderer": "19.1.1",
|
||||||
"typescript": "5.8.3"
|
"typescript": "5.8.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=20"
|
||||||
},
|
},
|
||||||
"trustedDependencies": [
|
"trustedDependencies": [
|
||||||
"detox",
|
"detox",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable react/no-unstable-nested-components */
|
/* eslint-disable react/no-unstable-nested-components */
|
||||||
/* eslint-disable react-native/no-inline-styles */
|
/* eslint-disable react-native/no-inline-styles */
|
||||||
import React, {useRef, useState} from 'react';
|
import React, { useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
StyleSheet,
|
StyleSheet,
|
||||||
Platform,
|
Platform,
|
||||||
@@ -19,14 +19,14 @@ import {
|
|||||||
Modal,
|
Modal,
|
||||||
Portal,
|
Portal,
|
||||||
} from 'react-native-paper';
|
} from 'react-native-paper';
|
||||||
import {Camera} from 'react-native-camera-kit';
|
import { Camera } from 'react-native-camera-kit';
|
||||||
import {LocalSvg} from 'react-native-svg/css';
|
import { LocalSvg } from 'react-native-svg/css';
|
||||||
|
|
||||||
import TestConsole from './TestConsole';
|
import TestConsole from './TestConsole';
|
||||||
|
|
||||||
import _updateConfig from '../update.json';
|
import _updateConfig from '../update.json';
|
||||||
import {UpdateProvider, Pushy, Cresc, useUpdate} from 'react-native-update';
|
import { UpdateProvider, Pushy, Cresc, useUpdate } from 'react-native-update';
|
||||||
const {appKey} = _updateConfig[Platform.OS];
|
const { appKey } = _updateConfig[Platform.OS];
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const {
|
const {
|
||||||
@@ -39,7 +39,8 @@ function App() {
|
|||||||
packageVersion,
|
packageVersion,
|
||||||
currentHash,
|
currentHash,
|
||||||
parseTestQrCode,
|
parseTestQrCode,
|
||||||
progress: {received, total} = {},
|
progress: { received, total } = {},
|
||||||
|
currentVersionInfo,
|
||||||
} = useUpdate();
|
} = useUpdate();
|
||||||
const [useDefaultAlert, setUseDefaultAlert] = useState(true);
|
const [useDefaultAlert, setUseDefaultAlert] = useState(true);
|
||||||
const [showTestConsole, setShowTestConsole] = useState(false);
|
const [showTestConsole, setShowTestConsole] = useState(false);
|
||||||
@@ -52,8 +53,8 @@ function App() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Text style={styles.welcome}>欢迎xxx使用Pushy热更新服务</Text>
|
<Text style={styles.welcome}>欢迎22使用Pushy热更新服务</Text>
|
||||||
<View style={{flexDirection: 'row'}}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<Text>
|
<Text>
|
||||||
{useDefaultAlert ? '当前使用' : '当前不使用'}默认的alert更新提示
|
{useDefaultAlert ? '当前使用' : '当前不使用'}默认的alert更新提示
|
||||||
</Text>
|
</Text>
|
||||||
@@ -72,9 +73,9 @@ function App() {
|
|||||||
<Portal>
|
<Portal>
|
||||||
<Modal visible={showCamera} onDismiss={() => setShowCamera(false)}>
|
<Modal visible={showCamera} onDismiss={() => setShowCamera(false)}>
|
||||||
<Camera
|
<Camera
|
||||||
style={{minHeight: 320}}
|
style={{ minHeight: 320 }}
|
||||||
scanBarcode={true}
|
scanBarcode={true}
|
||||||
onReadCode={({nativeEvent: {codeStringValue}}) => {
|
onReadCode={({ nativeEvent: { codeStringValue } }) => {
|
||||||
// 防止重复扫码
|
// 防止重复扫码
|
||||||
if (lastParsedCode.current === codeStringValue) {
|
if (lastParsedCode.current === codeStringValue) {
|
||||||
return;
|
return;
|
||||||
@@ -92,7 +93,7 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
</Portal>
|
</Portal>
|
||||||
<View style={{flexDirection: 'row', alignItems: 'center', gap: 10}}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
|
||||||
<Text>png:</Text>
|
<Text>png:</Text>
|
||||||
<Image
|
<Image
|
||||||
resizeMode={'contain'}
|
resizeMode={'contain'}
|
||||||
@@ -100,11 +101,11 @@ function App() {
|
|||||||
style={styles.image}
|
style={styles.image}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={{flexDirection: 'row', alignItems: 'center', gap: 10}}>
|
<View style={{ flexDirection: 'row', alignItems: 'center', gap: 10 }}>
|
||||||
<Text>svg:</Text>
|
<Text>svg:</Text>
|
||||||
<LocalSvg
|
<LocalSvg
|
||||||
asset={require('./assets/react-logo.svg')}
|
asset={require('./assets/react-logo.svg')}
|
||||||
style={{width: 30, height: 30}}
|
style={{ width: 30, height: 30 }}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<Text style={styles.instructions}>
|
<Text style={styles.instructions}>
|
||||||
@@ -113,6 +114,7 @@ function App() {
|
|||||||
{'\n'}
|
{'\n'}
|
||||||
当前热更新版本Hash: {currentHash || '(空)'}
|
当前热更新版本Hash: {currentHash || '(空)'}
|
||||||
{'\n'}
|
{'\n'}
|
||||||
|
当前热更新版本信息: {JSON.stringify(currentVersionInfo) || '(空)'}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>
|
<Text>
|
||||||
下载进度:{received} / {total}
|
下载进度:{received} / {total}
|
||||||
@@ -121,16 +123,18 @@ function App() {
|
|||||||
onPress={() => {
|
onPress={() => {
|
||||||
checkUpdate();
|
checkUpdate();
|
||||||
setShowUpdateSnackbar(true);
|
setShowUpdateSnackbar(true);
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<Text style={styles.instructions}>点击这里检查更新</Text>
|
<Text style={styles.instructions}>点击这里检查更新</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
testID="testcase"
|
testID="testcase"
|
||||||
style={{marginTop: 15}}
|
style={{ marginTop: 15 }}
|
||||||
onLongPress={() => {
|
onLongPress={() => {
|
||||||
setShowTestConsole(true);
|
setShowTestConsole(true);
|
||||||
}}>
|
}}
|
||||||
|
>
|
||||||
<Text style={styles.instructions}>
|
<Text style={styles.instructions}>
|
||||||
react-native-update版本:{client?.version}
|
react-native-update版本:{client?.version}
|
||||||
</Text>
|
</Text>
|
||||||
@@ -152,14 +156,15 @@ function App() {
|
|||||||
await downloadUpdate();
|
await downloadUpdate();
|
||||||
setShowUpdateBanner(true);
|
setShowUpdateBanner(true);
|
||||||
},
|
},
|
||||||
}}>
|
}}
|
||||||
<Text style={{color: 'white'}}>
|
>
|
||||||
|
<Text style={{ color: 'white' }}>
|
||||||
有新版本({updateInfo.name})可用,是否更新?
|
有新版本({updateInfo.name})可用,是否更新?
|
||||||
</Text>
|
</Text>
|
||||||
</Snackbar>
|
</Snackbar>
|
||||||
)}
|
)}
|
||||||
<Banner
|
<Banner
|
||||||
style={{width: '100%', position: 'absolute', top: 0}}
|
style={{ width: '100%', position: 'absolute', top: 0 }}
|
||||||
visible={showUpdateBanner}
|
visible={showUpdateBanner}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
@@ -174,9 +179,10 @@ function App() {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
icon={({size}) => (
|
icon={({ size }) => (
|
||||||
<Icon name="checkcircleo" size={size} color="#00f" />
|
<Icon name="checkcircleo" size={size} color="#00f" />
|
||||||
)}>
|
)}
|
||||||
|
>
|
||||||
更新已完成,是否立即重启?
|
更新已完成,是否立即重启?
|
||||||
</Banner>
|
</Banner>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
5
Example/testHotUpdate/tsconfig.json
Normal file
5
Example/testHotUpdate/tsconfig.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"extends": "@react-native/typescript-config",
|
||||||
|
"include": ["**/*.ts", "**/*.tsx"],
|
||||||
|
"exclude": ["**/node_modules", "**/Pods"]
|
||||||
|
}
|
||||||
@@ -101,7 +101,7 @@ android {
|
|||||||
minSdkVersion safeExtGet('minSdkVersion', 16)
|
minSdkVersion safeExtGet('minSdkVersion', 16)
|
||||||
targetSdkVersion safeExtGet('targetSdkVersion', 27)
|
targetSdkVersion safeExtGet('targetSdkVersion', 27)
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.81.4"
|
||||||
consumerProguardFiles "proguard.pro"
|
consumerProguardFiles "proguard.pro"
|
||||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||||
}
|
}
|
||||||
|
|||||||
27
android/proguard.pro
vendored
27
android/proguard.pro
vendored
@@ -10,28 +10,9 @@
|
|||||||
-keepnames class com.facebook.react.devsupport.** { *; }
|
-keepnames class com.facebook.react.devsupport.** { *; }
|
||||||
|
|
||||||
# Keep fields used in reflection
|
# Keep fields used in reflection
|
||||||
-keepclassmembers class com.facebook.react.ReactInstanceManager {
|
-keepclassmembers class com.facebook.react.ReactActivity { *; }
|
||||||
private JSBundleLoader mBundleLoader;
|
-keepclassmembers class com.facebook.react.ReactInstanceManager { *; }
|
||||||
private String mJSBundleFile;
|
-keepclassmembers class com.facebook.react.ReactDelegate { *; }
|
||||||
}
|
-keepclassmembers class com.facebook.react.ReactHost { *; }
|
||||||
|
|
||||||
-keepclassmembers class com.facebook.react.ReactDelegate {
|
|
||||||
private ReactHost mReactHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
-keepclassmembers class com.facebook.react.ReactHost {
|
|
||||||
private boolean mUseDevSupport;
|
|
||||||
private ReactHostDelegate mReactHostDelegate;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Keep Expo related classes
|
|
||||||
-keepnames class expo.modules.ExpoReactHostFactory$ExpoReactHostDelegate { *; }
|
-keepnames class expo.modules.ExpoReactHostFactory$ExpoReactHostDelegate { *; }
|
||||||
|
|
||||||
# Keep methods used in reflection
|
|
||||||
-keepclassmembers class com.facebook.react.ReactActivity {
|
|
||||||
public ReactDelegate getReactDelegate();
|
|
||||||
}
|
|
||||||
|
|
||||||
-keepclassmembers class com.facebook.react.ReactHost {
|
|
||||||
public void reload(java.lang.String);
|
|
||||||
}
|
|
||||||
@@ -40,6 +40,16 @@ public class UpdateContext {
|
|||||||
String storedPackageVersion = this.sp.getString("packageVersion", null);
|
String storedPackageVersion = this.sp.getString("packageVersion", null);
|
||||||
String storedBuildTime = this.sp.getString("buildTime", null);
|
String storedBuildTime = this.sp.getString("buildTime", null);
|
||||||
|
|
||||||
|
// If stored versions don't exist, write current versions first
|
||||||
|
if (storedPackageVersion == null || storedBuildTime == null) {
|
||||||
|
SharedPreferences.Editor editor = sp.edit();
|
||||||
|
editor.putString("packageVersion", packageVersion);
|
||||||
|
editor.putString("buildTime", buildTime);
|
||||||
|
editor.apply();
|
||||||
|
storedPackageVersion = packageVersion;
|
||||||
|
storedBuildTime = buildTime;
|
||||||
|
}
|
||||||
|
|
||||||
boolean packageVersionChanged = !packageVersion.equals(storedPackageVersion);
|
boolean packageVersionChanged = !packageVersion.equals(storedPackageVersion);
|
||||||
boolean buildTimeChanged = !buildTime.equals(storedBuildTime);
|
boolean buildTimeChanged = !buildTime.equals(storedBuildTime);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,38 @@ public class UpdateModuleImpl {
|
|||||||
|
|
||||||
public static final String NAME = "Pushy";
|
public static final String NAME = "Pushy";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取字段的兼容性方法,尝试带m前缀和不带m前缀的字段名
|
||||||
|
* @param clazz 目标类
|
||||||
|
* @param fieldName 基础字段名(不带m前缀)
|
||||||
|
* @return 找到的字段对象
|
||||||
|
* @throws NoSuchFieldException 如果两种命名都找不到字段
|
||||||
|
*/
|
||||||
|
private static Field getCompatibleField(Class<?> clazz, String fieldName) throws NoSuchFieldException {
|
||||||
|
// 首先尝试带m前缀的字段名
|
||||||
|
try {
|
||||||
|
return clazz.getDeclaredField("m" + capitalize(fieldName));
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
// 如果找不到带m前缀的,尝试不带m前缀的
|
||||||
|
try {
|
||||||
|
return clazz.getDeclaredField(fieldName);
|
||||||
|
} catch (NoSuchFieldException e2) {
|
||||||
|
// 如果都找不到,抛出异常并包含两种尝试的信息
|
||||||
|
throw new NoSuchFieldException("Field not found with either name: m" + capitalize(fieldName) + " or " + fieldName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 首字母大写的辅助方法
|
||||||
|
*/
|
||||||
|
private static String capitalize(String str) {
|
||||||
|
if (str == null || str.length() == 0) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
public static void downloadFullUpdate(UpdateContext updateContext, final ReadableMap options, final Promise promise) {
|
public static void downloadFullUpdate(UpdateContext updateContext, final ReadableMap options, final Promise promise) {
|
||||||
String url = options.getString("updateUrl");
|
String url = options.getString("updateUrl");
|
||||||
String hash = options.getString("hash");
|
String hash = options.getString("hash");
|
||||||
@@ -143,16 +175,16 @@ public class UpdateModuleImpl {
|
|||||||
ReactDelegate reactDelegate = (ReactDelegate)
|
ReactDelegate reactDelegate = (ReactDelegate)
|
||||||
getReactDelegateMethod.invoke(currentActivity);
|
getReactDelegateMethod.invoke(currentActivity);
|
||||||
|
|
||||||
Field reactHostField = ReactDelegate.class.getDeclaredField("mReactHost");
|
Field reactHostField = getCompatibleField(ReactDelegate.class, "reactHost");
|
||||||
reactHostField.setAccessible(true);
|
reactHostField.setAccessible(true);
|
||||||
Object reactHost = reactHostField.get(reactDelegate);
|
Object reactHost = reactHostField.get(reactDelegate);
|
||||||
|
|
||||||
Field devSupport = reactHost.getClass().getDeclaredField("mUseDevSupport");
|
Field devSupport = getCompatibleField(reactHost.getClass(), "useDevSupport");
|
||||||
devSupport.setAccessible(true);
|
devSupport.setAccessible(true);
|
||||||
devSupport.set(reactHost, false);
|
devSupport.set(reactHost, false);
|
||||||
|
|
||||||
// Access the mReactHostDelegate field
|
// Access the ReactHostDelegate field (compatible with mReactHostDelegate/reactHostDelegate)
|
||||||
Field reactHostDelegateField = reactHost.getClass().getDeclaredField("mReactHostDelegate");
|
Field reactHostDelegateField = getCompatibleField(reactHost.getClass(), "reactHostDelegate");
|
||||||
reactHostDelegateField.setAccessible(true);
|
reactHostDelegateField.setAccessible(true);
|
||||||
Object reactHostDelegate = reactHostDelegateField.get(reactHost);
|
Object reactHostDelegate = reactHostDelegateField.get(reactHost);
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ public class UpdateModule extends NativePushySpec {
|
|||||||
final Map<String, Object> constants = new HashMap<>();
|
final Map<String, Object> constants = new HashMap<>();
|
||||||
constants.put("downloadRootDir", updateContext.getRootDir());
|
constants.put("downloadRootDir", updateContext.getRootDir());
|
||||||
constants.put("packageVersion", updateContext.getPackageVersion());
|
constants.put("packageVersion", updateContext.getPackageVersion());
|
||||||
constants.put("currentVersion", updateContext.getCurrentVersion());
|
String currentVersion = updateContext.getCurrentVersion();
|
||||||
|
constants.put("currentVersion", currentVersion);
|
||||||
|
constants.put("currentVersionInfo", updateContext.getKv("hash_" + currentVersion));
|
||||||
constants.put("buildTime", updateContext.getBuildTime());
|
constants.put("buildTime", updateContext.getBuildTime());
|
||||||
constants.put("isUsingBundleUrl", updateContext.getIsUsingBundleUrl());
|
constants.put("isUsingBundleUrl", updateContext.getIsUsingBundleUrl());
|
||||||
boolean isFirstTime = updateContext.isFirstTime();
|
boolean isFirstTime = updateContext.isFirstTime();
|
||||||
|
|||||||
@@ -48,7 +48,9 @@ public class UpdateModule extends ReactContextBaseJavaModule {
|
|||||||
final Map<String, Object> constants = new HashMap<>();
|
final Map<String, Object> constants = new HashMap<>();
|
||||||
constants.put("downloadRootDir", updateContext.getRootDir());
|
constants.put("downloadRootDir", updateContext.getRootDir());
|
||||||
constants.put("packageVersion", updateContext.getPackageVersion());
|
constants.put("packageVersion", updateContext.getPackageVersion());
|
||||||
constants.put("currentVersion", updateContext.getCurrentVersion());
|
String currentVersion = updateContext.getCurrentVersion();
|
||||||
|
constants.put("currentVersion", currentVersion);
|
||||||
|
constants.put("currentVersionInfo", updateContext.getKv("hash_" + currentVersion));
|
||||||
constants.put("buildTime", updateContext.getBuildTime());
|
constants.put("buildTime", updateContext.getBuildTime());
|
||||||
constants.put("isUsingBundleUrl", updateContext.getIsUsingBundleUrl());
|
constants.put("isUsingBundleUrl", updateContext.getIsUsingBundleUrl());
|
||||||
boolean isFirstTime = updateContext.isFirstTime();
|
boolean isFirstTime = updateContext.isFirstTime();
|
||||||
|
|||||||
@@ -60,13 +60,13 @@ export class DownloadTask {
|
|||||||
const exists = fileIo.accessSync(params.targetFile);
|
const exists = fileIo.accessSync(params.targetFile);
|
||||||
if (exists) {
|
if (exists) {
|
||||||
await fileIo.unlink(params.targetFile);
|
await fileIo.unlink(params.targetFile);
|
||||||
}else{
|
} else {
|
||||||
const targetDir = params.targetFile.substring(
|
const targetDir = params.targetFile.substring(
|
||||||
0,
|
0,
|
||||||
params.targetFile.lastIndexOf('/'),
|
params.targetFile.lastIndexOf('/'),
|
||||||
);
|
);
|
||||||
const exists = fileIo.accessSync(targetDir);
|
const exists = fileIo.accessSync(targetDir);
|
||||||
if(!exists){
|
if (!exists) {
|
||||||
await fileIo.mkdir(targetDir);
|
await fileIo.mkdir(targetDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ export class DownloadTask {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (response.responseCode > 299) {
|
if (response.responseCode > 299) {
|
||||||
throw new Error(`Server error: ${response.responseCode}`);
|
throw Error(`Server error: ${response.responseCode}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentLength = parseInt(response.header['content-length'] || '0');
|
const contentLength = parseInt(response.header['content-length'] || '0');
|
||||||
@@ -108,9 +108,10 @@ export class DownloadTask {
|
|||||||
const stats = await fileIo.stat(params.targetFile);
|
const stats = await fileIo.stat(params.targetFile);
|
||||||
const fileSize = stats.size;
|
const fileSize = stats.size;
|
||||||
if (fileSize !== contentLength) {
|
if (fileSize !== contentLength) {
|
||||||
throw new Error(`Download incomplete: expected ${contentLength} bytes but got ${stats.size} bytes`);
|
throw Error(
|
||||||
|
`Download incomplete: expected ${contentLength} bytes but got ${stats.size} bytes`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Download failed:', error);
|
console.error('Download failed:', error);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -142,7 +143,7 @@ export class DownloadTask {
|
|||||||
bytesRead = await fileIo
|
bytesRead = await fileIo
|
||||||
.read(reader.fd, arrayBuffer)
|
.read(reader.fd, arrayBuffer)
|
||||||
.catch((err: BusinessError) => {
|
.catch((err: BusinessError) => {
|
||||||
throw new Error(
|
throw Error(
|
||||||
`Error reading file: ${err.message}, code: ${err.code}`,
|
`Error reading file: ${err.message}, code: ${err.code}`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -154,7 +155,7 @@ export class DownloadTask {
|
|||||||
length: bytesRead,
|
length: bytesRead,
|
||||||
})
|
})
|
||||||
.catch((err: BusinessError) => {
|
.catch((err: BusinessError) => {
|
||||||
throw new Error(
|
throw Error(
|
||||||
`Error writing file: ${err.message}, code: ${err.code}`,
|
`Error writing file: ${err.message}, code: ${err.code}`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -295,16 +296,16 @@ export class DownloadTask {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fn !== '.DS_Store'){
|
if (fn !== '.DS_Store') {
|
||||||
await zip.decompressFile(fn, params.unzipDirectory);
|
await zip.decompressFile(fn, params.unzipDirectory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!foundDiff) {
|
if (!foundDiff) {
|
||||||
throw new Error('diff.json not found');
|
throw Error('diff.json not found');
|
||||||
}
|
}
|
||||||
if (!foundBundlePatch) {
|
if (!foundBundlePatch) {
|
||||||
throw new Error('bundle patch not found');
|
throw Error('bundle patch not found');
|
||||||
}
|
}
|
||||||
await this.copyFromResource(copyList);
|
await this.copyFromResource(copyList);
|
||||||
}
|
}
|
||||||
@@ -366,12 +367,18 @@ export class DownloadTask {
|
|||||||
new Uint8Array(entry.content),
|
new Uint8Array(entry.content),
|
||||||
);
|
);
|
||||||
const outputFile = `${params.unzipDirectory}/bundle.harmony.js`;
|
const outputFile = `${params.unzipDirectory}/bundle.harmony.js`;
|
||||||
const writer = await fileIo.open(outputFile, fileIo.OpenMode.CREATE | fileIo.OpenMode.WRITE_ONLY);
|
const writer = await fileIo.open(
|
||||||
|
outputFile,
|
||||||
|
fileIo.OpenMode.CREATE | fileIo.OpenMode.WRITE_ONLY,
|
||||||
|
);
|
||||||
const chunkSize = 4096;
|
const chunkSize = 4096;
|
||||||
let bytesWritten = 0;
|
let bytesWritten = 0;
|
||||||
const totalLength = patched.byteLength;
|
const totalLength = patched.byteLength;
|
||||||
while (bytesWritten < totalLength) {
|
while (bytesWritten < totalLength) {
|
||||||
const chunk = patched.slice(bytesWritten, bytesWritten + chunkSize);
|
const chunk = patched.slice(
|
||||||
|
bytesWritten,
|
||||||
|
bytesWritten + chunkSize,
|
||||||
|
);
|
||||||
await fileIo.write(writer.fd, chunk);
|
await fileIo.write(writer.fd, chunk);
|
||||||
bytesWritten += chunk.byteLength;
|
bytesWritten += chunk.byteLength;
|
||||||
}
|
}
|
||||||
@@ -387,10 +394,10 @@ export class DownloadTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!foundDiff) {
|
if (!foundDiff) {
|
||||||
throw new Error('diff.json not found');
|
throw Error('diff.json not found');
|
||||||
}
|
}
|
||||||
if (!foundBundlePatch) {
|
if (!foundBundlePatch) {
|
||||||
throw new Error('bundle patch not found');
|
throw Error('bundle patch not found');
|
||||||
}
|
}
|
||||||
console.info('Patch from PPK completed');
|
console.info('Patch from PPK completed');
|
||||||
}
|
}
|
||||||
@@ -478,7 +485,7 @@ export class DownloadTask {
|
|||||||
await this.downloadFile(params);
|
await this.downloadFile(params);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown task type: ${params.type}`);
|
throw Error(`Unknown task type: ${params.type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
params.listener?.onDownloadCompleted(params);
|
params.listener?.onDownloadCompleted(params);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ getConstants(): Object {
|
|||||||
const rolledBackVersion = preferencesManager.getSync("rolledBackVersion", "") as string;
|
const rolledBackVersion = preferencesManager.getSync("rolledBackVersion", "") as string;
|
||||||
const uuid = preferencesManager.getSync("uuid", "") as string;
|
const uuid = preferencesManager.getSync("uuid", "") as string;
|
||||||
const currentVersion = preferencesManager.getSync("currentVersion", "") as string;
|
const currentVersion = preferencesManager.getSync("currentVersion", "") as string;
|
||||||
|
const currentVersionInfo = this.context.getKv(`hash_${currentVersion}`);
|
||||||
const buildTime = preferencesManager.getSync("buildTime", "") as string;
|
const buildTime = preferencesManager.getSync("buildTime", "") as string;
|
||||||
const isUsingBundleUrl = this.context.getIsUsingBundleUrl();
|
const isUsingBundleUrl = this.context.getIsUsingBundleUrl();
|
||||||
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
|
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
|
||||||
@@ -53,6 +54,7 @@ getConstants(): Object {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
downloadRootDir: `${context.filesDir}/_update`,
|
downloadRootDir: `${context.filesDir}/_update`,
|
||||||
|
currentVersionInfo,
|
||||||
packageVersion,
|
packageVersion,
|
||||||
currentVersion,
|
currentVersion,
|
||||||
buildTime,
|
buildTime,
|
||||||
@@ -64,13 +66,13 @@ getConstants(): Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async setLocalHashInfo(hash: string, info: string): Promise<boolean> {
|
setLocalHashInfo(hash: string, info: string): boolean {
|
||||||
logger.debug(TAG, ",call setLocalHashInfo");
|
logger.debug(TAG, ",call setLocalHashInfo");
|
||||||
return UpdateModuleImpl.setLocalHashInfo(this.context,hash,info);
|
return UpdateModuleImpl.setLocalHashInfo(this.context, hash, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLocalHashInfo(hash: string): Promise<string> {
|
getLocalHashInfo(hash: string): string {
|
||||||
return UpdateModuleImpl.getLocalHashInfo(this.context,hash);
|
return UpdateModuleImpl.getLocalHashInfo(this.context, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setUuid(uuid: string): Promise<boolean> {
|
async setUuid(uuid: string): Promise<boolean> {
|
||||||
|
|||||||
@@ -6,249 +6,276 @@ import common from '@ohos.app.ability.common';
|
|||||||
import { DownloadTaskParams } from './DownloadTaskParams';
|
import { DownloadTaskParams } from './DownloadTaskParams';
|
||||||
|
|
||||||
export class UpdateContext {
|
export class UpdateContext {
|
||||||
private context: common.UIAbilityContext;
|
private context: common.UIAbilityContext;
|
||||||
private rootDir: string;
|
private rootDir: string;
|
||||||
private preferences: preferences.Preferences;
|
private preferences: preferences.Preferences;
|
||||||
private static DEBUG: boolean = false;
|
private static DEBUG: boolean = false;
|
||||||
private static isUsingBundleUrl: boolean = false;
|
private static isUsingBundleUrl: boolean = false;
|
||||||
|
|
||||||
constructor(context: common.UIAbilityContext) {
|
constructor(context: common.UIAbilityContext) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.rootDir = context.filesDir + '/_update';
|
this.rootDir = context.filesDir + '/_update';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!fileIo.accessSync(this.rootDir)) {
|
if (!fileIo.accessSync(this.rootDir)) {
|
||||||
fileIo.mkdirSync(this.rootDir);
|
fileIo.mkdirSync(this.rootDir);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('Failed to create root directory:', e);
|
console.error('Failed to create root directory:', e);
|
||||||
}
|
|
||||||
this.initPreferences();
|
|
||||||
}
|
}
|
||||||
|
this.initPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
private initPreferences() {
|
private initPreferences() {
|
||||||
try {
|
try {
|
||||||
this.preferences = preferences.getPreferencesSync(this.context, {name:'update'});
|
this.preferences = preferences.getPreferencesSync(this.context, {
|
||||||
const packageVersion = this.getPackageVersion();
|
name: 'update',
|
||||||
const storedVersion = this.preferences.getSync('packageVersion', '');
|
});
|
||||||
if(!storedVersion){
|
const packageVersion = this.getPackageVersion();
|
||||||
this.preferences.putSync('packageVersion', packageVersion);
|
const storedVersion = this.preferences.getSync('packageVersion', '');
|
||||||
this.preferences.flush();
|
if (!storedVersion) {
|
||||||
} else if (storedVersion && packageVersion !== storedVersion) {
|
this.preferences.putSync('packageVersion', packageVersion);
|
||||||
this.preferences.clear();
|
this.preferences.flush();
|
||||||
this.preferences.putSync('packageVersion', packageVersion);
|
} else if (storedVersion && packageVersion !== storedVersion) {
|
||||||
this.preferences.flush();
|
this.preferences.clear();
|
||||||
this.cleanUp();
|
this.preferences.putSync('packageVersion', packageVersion);
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to init preferences:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public setKv(key: string, value: string): void {
|
|
||||||
this.preferences.putSync(key, value);
|
|
||||||
this.preferences.flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
public getKv(key: string): string {
|
|
||||||
return this.preferences.getSync(key, '') as string;
|
|
||||||
}
|
|
||||||
|
|
||||||
public isFirstTime(): boolean {
|
|
||||||
return this.preferences.getSync('firstTime', false) as boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
public rolledBackVersion(): string {
|
|
||||||
return this.preferences.getSync('rolledBackVersion', '') as string;
|
|
||||||
}
|
|
||||||
|
|
||||||
public markSuccess(): void {
|
|
||||||
this.preferences.putSync('firstTimeOk', true);
|
|
||||||
const lastVersion = this.preferences.getSync('lastVersion', '') as string;
|
|
||||||
const curVersion = this.preferences.getSync('currentVersion', '') as string;
|
|
||||||
|
|
||||||
if (lastVersion && lastVersion !== curVersion) {
|
|
||||||
this.preferences.deleteSync('lastVersion');
|
|
||||||
this.preferences.deleteSync(`hash_${lastVersion}`);
|
|
||||||
}
|
|
||||||
this.preferences.flush();
|
this.preferences.flush();
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to init preferences:', e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public clearFirstTime(): void {
|
public setKv(key: string, value: string): void {
|
||||||
this.preferences.putSync('firstTime', false);
|
this.preferences.putSync(key, value);
|
||||||
this.preferences.flush();
|
this.preferences.flush();
|
||||||
this.cleanUp();
|
}
|
||||||
|
|
||||||
|
public getKv(key: string): string {
|
||||||
|
return this.preferences.getSync(key, '') as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
public isFirstTime(): boolean {
|
||||||
|
return this.preferences.getSync('firstTime', false) as boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
public rolledBackVersion(): string {
|
||||||
|
return this.preferences.getSync('rolledBackVersion', '') as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
public markSuccess(): void {
|
||||||
|
this.preferences.putSync('firstTimeOk', true);
|
||||||
|
const lastVersion = this.preferences.getSync('lastVersion', '') as string;
|
||||||
|
const curVersion = this.preferences.getSync('currentVersion', '') as string;
|
||||||
|
|
||||||
|
if (lastVersion && lastVersion !== curVersion) {
|
||||||
|
this.preferences.deleteSync('lastVersion');
|
||||||
|
this.preferences.deleteSync(`hash_${lastVersion}`);
|
||||||
}
|
}
|
||||||
|
this.preferences.flush();
|
||||||
|
this.cleanUp();
|
||||||
|
}
|
||||||
|
|
||||||
public clearRollbackMark(): void {
|
public clearFirstTime(): void {
|
||||||
this.preferences.putSync('rolledBackVersion', null);
|
this.preferences.putSync('firstTime', false);
|
||||||
this.preferences.flush();
|
this.preferences.flush();
|
||||||
this.cleanUp();
|
this.cleanUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
public clearRollbackMark(): void {
|
||||||
|
this.preferences.putSync('rolledBackVersion', null);
|
||||||
|
this.preferences.flush();
|
||||||
|
this.cleanUp();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async downloadFullUpdate(
|
||||||
|
url: string,
|
||||||
|
hash: string,
|
||||||
|
listener: DownloadFileListener,
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const params = new DownloadTaskParams();
|
||||||
|
params.type = DownloadTaskParams.TASK_TYPE_PATCH_FULL;
|
||||||
|
params.url = url;
|
||||||
|
params.hash = hash;
|
||||||
|
params.listener = listener;
|
||||||
|
params.targetFile = `${this.rootDir}/${hash}.ppk`;
|
||||||
|
const downloadTask = new DownloadTask(this.context);
|
||||||
|
await downloadTask.execute(params);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to download full update:', e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async downloadFullUpdate(url: string, hash: string, listener: DownloadFileListener): Promise<void> {
|
public async downloadFile(
|
||||||
try {
|
url: string,
|
||||||
const params = new DownloadTaskParams();
|
hash: string,
|
||||||
params.type = DownloadTaskParams.TASK_TYPE_PATCH_FULL;
|
fileName: string,
|
||||||
params.url = url;
|
listener: DownloadFileListener,
|
||||||
params.hash = hash;
|
): Promise<void> {
|
||||||
params.listener = listener;
|
const params = new DownloadTaskParams();
|
||||||
params.targetFile = `${this.rootDir}/${hash}.ppk`;
|
params.type = DownloadTaskParams.TASK_TYPE_PLAIN_DOWNLOAD;
|
||||||
const downloadTask = new DownloadTask(this.context);
|
params.url = url;
|
||||||
await downloadTask.execute(params);
|
params.hash = hash;
|
||||||
} catch (e) {
|
params.listener = listener;
|
||||||
console.error('Failed to download full update:', e);
|
params.targetFile = this.rootDir + '/' + fileName;
|
||||||
|
|
||||||
|
const downloadTask = new DownloadTask(this.context);
|
||||||
|
await downloadTask.execute(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async downloadPatchFromPpk(
|
||||||
|
url: string,
|
||||||
|
hash: string,
|
||||||
|
originHash: string,
|
||||||
|
listener: DownloadFileListener,
|
||||||
|
): Promise<void> {
|
||||||
|
const params = new DownloadTaskParams();
|
||||||
|
params.type = DownloadTaskParams.TASK_TYPE_PATCH_FROM_PPK;
|
||||||
|
params.url = url;
|
||||||
|
params.hash = hash;
|
||||||
|
params.originHash = originHash;
|
||||||
|
params.listener = listener;
|
||||||
|
params.targetFile = `${this.rootDir}/${originHash}_${hash}.ppk.patch`;
|
||||||
|
params.unzipDirectory = `${this.rootDir}/${hash}`;
|
||||||
|
params.originDirectory = `${this.rootDir}/${params.originHash}`;
|
||||||
|
|
||||||
|
const downloadTask = new DownloadTask(this.context);
|
||||||
|
await downloadTask.execute(params);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async downloadPatchFromPackage(
|
||||||
|
url: string,
|
||||||
|
hash: string,
|
||||||
|
listener: DownloadFileListener,
|
||||||
|
): Promise<void> {
|
||||||
|
try {
|
||||||
|
const params = new DownloadTaskParams();
|
||||||
|
params.type = DownloadTaskParams.TASK_TYPE_PATCH_FROM_APP;
|
||||||
|
params.url = url;
|
||||||
|
params.hash = hash;
|
||||||
|
params.listener = listener;
|
||||||
|
params.targetFile = `${this.rootDir}/${hash}.app.patch`;
|
||||||
|
params.unzipDirectory = `${this.rootDir}/${hash}`;
|
||||||
|
|
||||||
|
const downloadTask = new DownloadTask(this.context);
|
||||||
|
return await downloadTask.execute(params);
|
||||||
|
} catch (e) {
|
||||||
|
throw e;
|
||||||
|
console.error('Failed to download APK patch:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public switchVersion(hash: string): void {
|
||||||
|
try {
|
||||||
|
const bundlePath = `${this.rootDir}/${hash}/bundle.harmony.js`;
|
||||||
|
if (!fileIo.accessSync(bundlePath)) {
|
||||||
|
throw Error(`Bundle version ${hash} not found.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastVersion = this.getKv('currentVersion');
|
||||||
|
this.setKv('currentVersion', hash);
|
||||||
|
if (lastVersion && lastVersion !== hash) {
|
||||||
|
this.setKv('lastVersion', lastVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setKv('firstTime', 'true');
|
||||||
|
this.setKv('firstTimeOk', 'false');
|
||||||
|
this.setKv('rolledBackVersion', '');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to switch version:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static getBundleUrl(
|
||||||
|
context: common.UIAbilityContext,
|
||||||
|
defaultAssetsUrl?: string,
|
||||||
|
): string {
|
||||||
|
return new UpdateContext(context).getBundleUrl(defaultAssetsUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
public getBundleUrl(defaultAssetsUrl?: string): string {
|
||||||
|
UpdateContext.isUsingBundleUrl = true;
|
||||||
|
const currentVersion = this.getCurrentVersion();
|
||||||
|
if (!currentVersion) {
|
||||||
|
return defaultAssetsUrl;
|
||||||
|
}
|
||||||
|
if (!this.isFirstTime()) {
|
||||||
|
if (!this.preferences.getSync('firstTimeOk', true)) {
|
||||||
|
return this.rollBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let version = currentVersion;
|
||||||
|
while (version) {
|
||||||
|
const bundleFile = `${this.rootDir}/${version}/bundle.harmony.js`;
|
||||||
|
try {
|
||||||
|
if (!fileIo.accessSync(bundleFile)) {
|
||||||
|
console.error(`Bundle version ${version} not found.`);
|
||||||
|
version = this.rollBack();
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
return bundleFile;
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to access bundle file:', e);
|
||||||
|
version = this.rollBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return defaultAssetsUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public async downloadFile(url: string, hash: string, fileName: string, listener: DownloadFileListener): Promise<void> {
|
getPackageVersion(): string {
|
||||||
const params = new DownloadTaskParams();
|
let bundleFlags =
|
||||||
params.type = DownloadTaskParams.TASK_TYPE_PLAIN_DOWNLOAD;
|
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
|
||||||
params.url = url;
|
let packageVersion = '';
|
||||||
params.hash = hash;
|
try {
|
||||||
params.listener = listener;
|
const bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleFlags);
|
||||||
params.targetFile = this.rootDir + '/' + fileName;
|
packageVersion = bundleInfo?.versionName || 'Unknown';
|
||||||
|
} catch (error) {
|
||||||
const downloadTask = new DownloadTask(this.context);
|
console.error('获取包信息失败:', error);
|
||||||
await downloadTask.execute(params);
|
|
||||||
}
|
}
|
||||||
|
return packageVersion;
|
||||||
|
}
|
||||||
|
|
||||||
public async downloadPatchFromPpk(url: string, hash: string, originHash: string, listener: DownloadFileListener): Promise<void> {
|
public getCurrentVersion(): string {
|
||||||
const params = new DownloadTaskParams();
|
const currentVersion = this.getKv('currentVersion');
|
||||||
params.type = DownloadTaskParams.TASK_TYPE_PATCH_FROM_PPK;
|
return currentVersion;
|
||||||
params.url = url;
|
}
|
||||||
params.hash = hash;
|
|
||||||
params.originHash = originHash;
|
|
||||||
params.listener = listener;
|
|
||||||
params.targetFile = `${this.rootDir}/${originHash}_${hash}.ppk.patch`;
|
|
||||||
params.unzipDirectory = `${this.rootDir}/${hash}`;
|
|
||||||
params.originDirectory = `${this.rootDir}/${params.originHash}`;
|
|
||||||
|
|
||||||
const downloadTask = new DownloadTask(this.context);
|
private rollBack(): string {
|
||||||
await downloadTask.execute(params);
|
const lastVersion = this.preferences.getSync('lastVersion', '') as string;
|
||||||
|
const currentVersion = this.preferences.getSync(
|
||||||
|
'currentVersion',
|
||||||
|
'',
|
||||||
|
) as string;
|
||||||
|
if (!lastVersion) {
|
||||||
|
this.preferences.deleteSync('currentVersion');
|
||||||
|
} else {
|
||||||
|
this.preferences.putSync('currentVersion', lastVersion);
|
||||||
}
|
}
|
||||||
|
this.preferences.putSync('firstTimeOk', true);
|
||||||
|
this.preferences.putSync('firstTime', false);
|
||||||
|
this.preferences.putSync('rolledBackVersion', currentVersion);
|
||||||
|
this.preferences.flush();
|
||||||
|
return lastVersion;
|
||||||
|
}
|
||||||
|
|
||||||
public async downloadPatchFromPackage(url: string, hash: string, listener: DownloadFileListener): Promise<void> {
|
private cleanUp(): void {
|
||||||
try {
|
const params = new DownloadTaskParams();
|
||||||
const params = new DownloadTaskParams();
|
params.type = DownloadTaskParams.TASK_TYPE_CLEANUP;
|
||||||
params.type = DownloadTaskParams.TASK_TYPE_PATCH_FROM_APP;
|
params.hash = this.preferences.getSync('currentVersion', '') as string;
|
||||||
params.url = url;
|
params.originHash = this.preferences.getSync('lastVersion', '') as string;
|
||||||
params.hash = hash;
|
params.unzipDirectory = this.rootDir;
|
||||||
params.listener = listener;
|
const downloadTask = new DownloadTask(this.context);
|
||||||
params.targetFile = `${this.rootDir}/${hash}.app.patch`;
|
downloadTask.execute(params);
|
||||||
params.unzipDirectory = `${this.rootDir}/${hash}`;
|
}
|
||||||
|
|
||||||
const downloadTask = new DownloadTask(this.context);
|
public getIsUsingBundleUrl(): boolean {
|
||||||
return await downloadTask.execute(params);
|
return UpdateContext.isUsingBundleUrl;
|
||||||
} catch (e) {
|
}
|
||||||
throw e;
|
|
||||||
console.error('Failed to download APK patch:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public switchVersion(hash: string): void {
|
|
||||||
try {
|
|
||||||
const bundlePath = `${this.rootDir}/${hash}/bundle.harmony.js`;
|
|
||||||
if (!fileIo.accessSync(bundlePath)) {
|
|
||||||
throw new Error(`Bundle version ${hash} not found.`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const lastVersion = this.getKv('currentVersion');
|
|
||||||
this.setKv('currentVersion', hash);
|
|
||||||
if (lastVersion && lastVersion !== hash) {
|
|
||||||
this.setKv('lastVersion', lastVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setKv('firstTime', 'true');
|
|
||||||
this.setKv('firstTimeOk', 'false');
|
|
||||||
this.setKv('rolledBackVersion', "");
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to switch version:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static getBundleUrl(context: common.UIAbilityContext, defaultAssetsUrl?: string): string {
|
|
||||||
return new UpdateContext(context).getBundleUrl(defaultAssetsUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getBundleUrl(defaultAssetsUrl?: string): string {
|
|
||||||
UpdateContext.isUsingBundleUrl = true;
|
|
||||||
const currentVersion = this.getCurrentVersion();
|
|
||||||
if (!currentVersion) {
|
|
||||||
return defaultAssetsUrl;
|
|
||||||
}
|
|
||||||
if (!this.isFirstTime()) {
|
|
||||||
if (!this.preferences.getSync('firstTimeOk', true)) {
|
|
||||||
return this.rollBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let version = currentVersion;
|
|
||||||
while (version) {
|
|
||||||
const bundleFile = `${this.rootDir}/${version}/bundle.harmony.js`;
|
|
||||||
try {
|
|
||||||
if (!fileIo.accessSync(bundleFile)) {
|
|
||||||
console.error(`Bundle version ${version} not found.`);
|
|
||||||
version = this.rollBack();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return bundleFile;
|
|
||||||
} catch (e) {
|
|
||||||
console.error('Failed to access bundle file:', e);
|
|
||||||
version = this.rollBack();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defaultAssetsUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
getPackageVersion(): string {
|
|
||||||
let bundleFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION;
|
|
||||||
let packageVersion = '';
|
|
||||||
try {
|
|
||||||
const bundleInfo = bundleManager.getBundleInfoForSelfSync(bundleFlags);
|
|
||||||
packageVersion = bundleInfo?.versionName || "Unknown";
|
|
||||||
} catch (error) {
|
|
||||||
console.error("获取包信息失败:", error);
|
|
||||||
}
|
|
||||||
return packageVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public getCurrentVersion() : string {
|
|
||||||
const currentVersion = this.getKv('currentVersion');
|
|
||||||
return currentVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
private rollBack(): string {
|
|
||||||
const lastVersion = this.preferences.getSync('lastVersion', '') as string;
|
|
||||||
const currentVersion = this.preferences.getSync('currentVersion', '') as string;
|
|
||||||
if (!lastVersion) {
|
|
||||||
this.preferences.deleteSync('currentVersion');
|
|
||||||
} else {
|
|
||||||
this.preferences.putSync('currentVersion', lastVersion);
|
|
||||||
}
|
|
||||||
this.preferences.putSync('firstTimeOk', true);
|
|
||||||
this.preferences.putSync('firstTime', false);
|
|
||||||
this.preferences.putSync('rolledBackVersion', currentVersion);
|
|
||||||
this.preferences.flush();
|
|
||||||
return lastVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
private cleanUp(): void {
|
|
||||||
const params = new DownloadTaskParams();
|
|
||||||
params.type = DownloadTaskParams.TASK_TYPE_CLEANUP;
|
|
||||||
params.hash = this.preferences.getSync('currentVersion', '') as string;
|
|
||||||
params.originHash = this.preferences.getSync('lastVersion', '') as string;
|
|
||||||
params.unzipDirectory = this.rootDir;
|
|
||||||
const downloadTask = new DownloadTask(this.context);
|
|
||||||
downloadTask.execute(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public getIsUsingBundleUrl(): boolean {
|
|
||||||
return UpdateContext.isUsingBundleUrl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadFileListener {
|
export interface DownloadFileListener {
|
||||||
onDownloadCompleted(params: DownloadTaskParams): void;
|
onDownloadCompleted(params: DownloadTaskParams): void;
|
||||||
onDownloadFailed(error: Error): void;
|
onDownloadFailed(error: Error): void;
|
||||||
}
|
}
|
||||||
@@ -4,14 +4,14 @@ import { UpdateContext } from './UpdateContext';
|
|||||||
import { DownloadTaskParams } from './DownloadTaskParams';
|
import { DownloadTaskParams } from './DownloadTaskParams';
|
||||||
import logger from './Logger';
|
import logger from './Logger';
|
||||||
|
|
||||||
const TAG = "UpdateModuleImpl";
|
const TAG = 'UpdateModuleImpl';
|
||||||
|
|
||||||
export class UpdateModuleImpl {
|
export class UpdateModuleImpl {
|
||||||
static readonly NAME = "Pushy";
|
static readonly NAME = 'Pushy';
|
||||||
|
|
||||||
static async downloadFullUpdate(
|
static async downloadFullUpdate(
|
||||||
updateContext: UpdateContext,
|
updateContext: UpdateContext,
|
||||||
options: { updateUrl: string; hash: string }
|
options: { updateUrl: string; hash: string },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await updateContext.downloadFullUpdate(options.updateUrl, options.hash, {
|
await updateContext.downloadFullUpdate(options.updateUrl, options.hash, {
|
||||||
@@ -20,7 +20,7 @@ export class UpdateModuleImpl {
|
|||||||
},
|
},
|
||||||
onDownloadFailed: (error: Error) => {
|
onDownloadFailed: (error: Error) => {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(TAG, `downloadFullUpdate failed: ${error}`);
|
logger.error(TAG, `downloadFullUpdate failed: ${error}`);
|
||||||
@@ -30,18 +30,18 @@ export class UpdateModuleImpl {
|
|||||||
|
|
||||||
static async downloadAndInstallApk(
|
static async downloadAndInstallApk(
|
||||||
context: common.UIAbilityContext,
|
context: common.UIAbilityContext,
|
||||||
options: { url: string; hash: string; target: string }
|
options: { url: string; hash: string; target: string },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const want = {
|
const want = {
|
||||||
action: 'action.system.home',
|
action: 'action.system.home',
|
||||||
parameters: {
|
parameters: {
|
||||||
uri: 'appmarket://details'
|
uri: 'appmarket://details',
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!context) {
|
if (!context) {
|
||||||
throw new Error('获取context失败');
|
throw Error('获取context失败');
|
||||||
}
|
}
|
||||||
|
|
||||||
await context.startAbility(want);
|
await context.startAbility(want);
|
||||||
@@ -53,17 +53,21 @@ export class UpdateModuleImpl {
|
|||||||
|
|
||||||
static async downloadPatchFromPackage(
|
static async downloadPatchFromPackage(
|
||||||
updateContext: UpdateContext,
|
updateContext: UpdateContext,
|
||||||
options: { updateUrl: string; hash: string }
|
options: { updateUrl: string; hash: string },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
return await updateContext.downloadPatchFromPackage(options.updateUrl, options.hash, {
|
return await updateContext.downloadPatchFromPackage(
|
||||||
onDownloadCompleted: (params: DownloadTaskParams) => {
|
options.updateUrl,
|
||||||
return Promise.resolve();
|
options.hash,
|
||||||
|
{
|
||||||
|
onDownloadCompleted: (params: DownloadTaskParams) => {
|
||||||
|
return Promise.resolve();
|
||||||
|
},
|
||||||
|
onDownloadFailed: (error: Error) => {
|
||||||
|
return Promise.reject(error);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
onDownloadFailed: (error: Error) => {
|
);
|
||||||
return Promise.reject(error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(TAG, `downloadPatchFromPackage failed: ${error}`);
|
logger.error(TAG, `downloadPatchFromPackage failed: ${error}`);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -72,7 +76,7 @@ export class UpdateModuleImpl {
|
|||||||
|
|
||||||
static async downloadPatchFromPpk(
|
static async downloadPatchFromPpk(
|
||||||
updateContext: UpdateContext,
|
updateContext: UpdateContext,
|
||||||
options: { updateUrl: string; hash: string; originHash: string }
|
options: { updateUrl: string; hash: string; originHash: string },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
try {
|
try {
|
||||||
await updateContext.downloadPatchFromPpk(
|
await updateContext.downloadPatchFromPpk(
|
||||||
@@ -85,49 +89,49 @@ export class UpdateModuleImpl {
|
|||||||
},
|
},
|
||||||
onDownloadFailed: (error: Error) => {
|
onDownloadFailed: (error: Error) => {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(TAG, `downloadPatchFromPpk failed: ${error}`);
|
logger.error(TAG, `downloadPatchFromPpk failed: ${error}`);
|
||||||
throw new Error(`执行报错: ${error.message}`);
|
throw Error(`执行报错: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async reloadUpdate(
|
static async reloadUpdate(
|
||||||
updateContext: UpdateContext,
|
updateContext: UpdateContext,
|
||||||
context: common.UIAbilityContext,
|
context: common.UIAbilityContext,
|
||||||
options: { hash: string }
|
options: { hash: string },
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const hash = options.hash;
|
const hash = options.hash;
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
throw new Error('hash不能为空');
|
throw Error('hash不能为空');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await updateContext.switchVersion(hash);
|
await updateContext.switchVersion(hash);
|
||||||
const bundleInfo = await bundleManager.getBundleInfoForSelf(
|
const bundleInfo = await bundleManager.getBundleInfoForSelf(
|
||||||
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION
|
bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_REQUESTED_PERMISSION,
|
||||||
);
|
);
|
||||||
await context.terminateSelf();
|
await context.terminateSelf();
|
||||||
const want = {
|
const want = {
|
||||||
bundleName: bundleInfo.name,
|
bundleName: bundleInfo.name,
|
||||||
abilityName: context.abilityInfo?.name
|
abilityName: context.abilityInfo?.name,
|
||||||
};
|
};
|
||||||
await context.startAbility(want);
|
await context.startAbility(want);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(TAG, `reloadUpdate failed: ${error}`);
|
logger.error(TAG, `reloadUpdate failed: ${error}`);
|
||||||
throw new Error(`pushy:switchVersion failed ${error.message}`);
|
throw Error(`pushy:switchVersion failed ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setNeedUpdate(
|
static async setNeedUpdate(
|
||||||
updateContext: UpdateContext,
|
updateContext: UpdateContext,
|
||||||
options: { hash: string }
|
options: { hash: string },
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const hash = options.hash;
|
const hash = options.hash;
|
||||||
if (!hash) {
|
if (!hash) {
|
||||||
throw new Error('hash不能为空');
|
throw Error('hash不能为空');
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -135,7 +139,7 @@ export class UpdateModuleImpl {
|
|||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(TAG, `setNeedUpdate failed: ${error}`);
|
logger.error(TAG, `setNeedUpdate failed: ${error}`);
|
||||||
throw new Error(`switchVersionLater failed: ${error.message}`);
|
throw Error(`switchVersionLater failed: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,20 +149,20 @@ export class UpdateModuleImpl {
|
|||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(TAG, `markSuccess failed: ${error}`);
|
logger.error(TAG, `markSuccess failed: ${error}`);
|
||||||
throw new Error(`执行报错: ${error.message}`);
|
throw Error(`执行报错: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setUuid(
|
static async setUuid(
|
||||||
updateContext: UpdateContext,
|
updateContext: UpdateContext,
|
||||||
uuid: string
|
uuid: string,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
try {
|
try {
|
||||||
await updateContext.setKv('uuid', uuid);
|
await updateContext.setKv('uuid', uuid);
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(TAG, `setUuid failed: ${error}`);
|
logger.error(TAG, `setUuid failed: ${error}`);
|
||||||
throw new Error(`执行报错: ${error.message}`);
|
throw Error(`执行报错: ${error.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,27 +175,17 @@ export class UpdateModuleImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async setLocalHashInfo(
|
static setLocalHashInfo(
|
||||||
updateContext: UpdateContext,
|
updateContext: UpdateContext,
|
||||||
hash: string,
|
hash: string,
|
||||||
info: string
|
info: string,
|
||||||
): Promise<boolean> {
|
): boolean {
|
||||||
if (!this.checkJson(info)) {
|
updateContext.setKv(`hash_${hash}`, info);
|
||||||
await updateContext.setKv(`hash_${hash}`, info);
|
|
||||||
throw new Error('校验报错:json字符串格式错误');
|
|
||||||
}
|
|
||||||
await updateContext.setKv(`hash_${hash}`, info);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getLocalHashInfo(
|
static getLocalHashInfo(updateContext: UpdateContext, hash: string): string {
|
||||||
updateContext: UpdateContext,
|
const value = updateContext.getKv(`hash_${hash}`);
|
||||||
hash: string
|
|
||||||
): Promise<string> {
|
|
||||||
const value = await updateContext.getKv(`hash_${hash}`);
|
|
||||||
if (!this.checkJson(value)) {
|
|
||||||
throw new Error('校验报错:json字符串格式错误');
|
|
||||||
}
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,6 +77,14 @@ RCT_EXPORT_MODULE(RCTPushy);
|
|||||||
NSString *storedPackageVersion = [defaults stringForKey:paramPackageVersion];
|
NSString *storedPackageVersion = [defaults stringForKey:paramPackageVersion];
|
||||||
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
|
NSString *storedBuildTime = [defaults stringForKey:paramBuildTime];
|
||||||
|
|
||||||
|
// If stored versions don't exist, write current versions first
|
||||||
|
if (!storedPackageVersion || !storedBuildTime) {
|
||||||
|
[defaults setObject:curPackageVersion forKey:paramPackageVersion];
|
||||||
|
[defaults setObject:curBuildTime forKey:paramBuildTime];
|
||||||
|
storedPackageVersion = curPackageVersion;
|
||||||
|
storedBuildTime = curBuildTime;
|
||||||
|
}
|
||||||
|
|
||||||
BOOL packageVersionChanged = ![curPackageVersion isEqualToString:storedPackageVersion];
|
BOOL packageVersionChanged = ![curPackageVersion isEqualToString:storedPackageVersion];
|
||||||
BOOL buildTimeChanged = ![curBuildTime isEqualToString:storedBuildTime];
|
BOOL buildTimeChanged = ![curBuildTime isEqualToString:storedBuildTime];
|
||||||
|
|
||||||
@@ -168,7 +176,11 @@ RCT_EXPORT_MODULE(RCTPushy);
|
|||||||
ret[@"isFirstTime"] = [defaults objectForKey:keyFirstLoadMarked];
|
ret[@"isFirstTime"] = [defaults objectForKey:keyFirstLoadMarked];
|
||||||
ret[@"uuid"] = [defaults objectForKey:keyUuid];
|
ret[@"uuid"] = [defaults objectForKey:keyUuid];
|
||||||
NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
|
NSDictionary *pushyInfo = [defaults dictionaryForKey:keyPushyInfo];
|
||||||
ret[@"currentVersion"] = [pushyInfo objectForKey:paramCurrentVersion];
|
NSString *currentVersion = [pushyInfo objectForKey:paramCurrentVersion];
|
||||||
|
ret[@"currentVersion"] = currentVersion;
|
||||||
|
if (currentVersion != nil) {
|
||||||
|
ret[@"currentVersionInfo"] = [defaults objectForKey:[keyHashInfo stringByAppendingString:currentVersion]];
|
||||||
|
}
|
||||||
|
|
||||||
// clear isFirstTimemarked
|
// clear isFirstTimemarked
|
||||||
if (ret[@"isFirstTime"]) {
|
if (ret[@"isFirstTime"]) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "react-native-update",
|
"name": "react-native-update",
|
||||||
"version": "10.30.3",
|
"version": "10.32.0",
|
||||||
"description": "react-native hot update",
|
"description": "react-native hot update",
|
||||||
"main": "src/index",
|
"main": "src/index",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export interface Spec extends TurboModule {
|
|||||||
buildTime: string;
|
buildTime: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
isUsingBundleUrl: boolean;
|
isUsingBundleUrl: boolean;
|
||||||
|
currentVersionInfo: string;
|
||||||
};
|
};
|
||||||
setLocalHashInfo(hash: string, info: string): Promise<void>;
|
setLocalHashInfo(hash: string, info: string): Promise<void>;
|
||||||
getLocalHashInfo(hash: string): Promise<string>;
|
getLocalHashInfo(hash: string): Promise<string>;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
promiseAny,
|
promiseAny,
|
||||||
testUrls,
|
testUrls,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
import i18n from './i18n';
|
||||||
|
|
||||||
const SERVER_PRESETS = {
|
const SERVER_PRESETS = {
|
||||||
// cn
|
// cn
|
||||||
@@ -91,7 +92,7 @@ export class Pushy {
|
|||||||
options = defaultClientOptions;
|
options = defaultClientOptions;
|
||||||
clientType: 'Pushy' | 'Cresc' = 'Pushy';
|
clientType: 'Pushy' | 'Cresc' = 'Pushy';
|
||||||
lastChecking?: number;
|
lastChecking?: number;
|
||||||
lastRespJson?: Promise<any>;
|
lastRespJson?: Promise<CheckResult>;
|
||||||
|
|
||||||
version = cInfo.rnu;
|
version = cInfo.rnu;
|
||||||
loggerPromise = (() => {
|
loggerPromise = (() => {
|
||||||
@@ -106,13 +107,18 @@ export class Pushy {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
constructor(options: ClientOptions, clientType?: 'Pushy' | 'Cresc') {
|
constructor(options: ClientOptions, clientType?: 'Pushy' | 'Cresc') {
|
||||||
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
|
||||||
if (!options.appKey) {
|
|
||||||
throw new Error('appKey is required');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.clientType = clientType || 'Pushy';
|
this.clientType = clientType || 'Pushy';
|
||||||
this.options.server = SERVER_PRESETS[this.clientType];
|
this.options.server = SERVER_PRESETS[this.clientType];
|
||||||
|
|
||||||
|
// Initialize i18n based on clientType
|
||||||
|
i18n.setLocale(this.clientType === 'Pushy' ? 'zh' : 'en');
|
||||||
|
|
||||||
|
if (Platform.OS === 'ios' || Platform.OS === 'android') {
|
||||||
|
if (!options.appKey) {
|
||||||
|
throw Error(i18n.t('error_appkey_required'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.setOptions(options);
|
this.setOptions(options);
|
||||||
if (isRolledBack) {
|
if (isRolledBack) {
|
||||||
this.report({
|
this.report({
|
||||||
@@ -135,6 +141,16 @@ export class Pushy {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get translated text based on current clientType
|
||||||
|
* @param key - Translation key
|
||||||
|
* @param values - Values for interpolation (optional)
|
||||||
|
* @returns Translated string
|
||||||
|
*/
|
||||||
|
t = (key: string, values?: Record<string, string | number>) => {
|
||||||
|
return i18n.t(key as any, values);
|
||||||
|
};
|
||||||
|
|
||||||
report = async ({
|
report = async ({
|
||||||
type,
|
type,
|
||||||
message = '',
|
message = '',
|
||||||
@@ -174,11 +190,7 @@ export class Pushy {
|
|||||||
};
|
};
|
||||||
assertDebug = (matter: string) => {
|
assertDebug = (matter: string) => {
|
||||||
if (__DEV__ && !this.options.debug) {
|
if (__DEV__ && !this.options.debug) {
|
||||||
console.info(
|
console.info(this.t('dev_debug_disabled', { matter }));
|
||||||
`You are currently in the development environment and have not enabled debug mode.
|
|
||||||
${matter} will not be performed.
|
|
||||||
If you need to debug ${matter} in the development environment, please set debug to true in the client.`,
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -269,7 +281,7 @@ export class Pushy {
|
|||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
this.report({
|
this.report({
|
||||||
type: 'errorChecking',
|
type: 'errorChecking',
|
||||||
message: `Can not connect to update server: ${e.message}. Trying backup endpoints.`,
|
message: this.t('error_cannot_connect_backup', { message: e.message }),
|
||||||
});
|
});
|
||||||
const backupEndpoints = await this.getBackupEndpoints();
|
const backupEndpoints = await this.getBackupEndpoints();
|
||||||
if (backupEndpoints) {
|
if (backupEndpoints) {
|
||||||
@@ -280,18 +292,32 @@ export class Pushy {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this.throwIfEnabled(new Error('errorCheckingUseBackup'));
|
this.throwIfEnabled(Error('errorCheckingUseBackup'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.throwIfEnabled(new Error('errorCheckingGetBackup'));
|
this.throwIfEnabled(Error('errorCheckingGetBackup'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!resp) {
|
if (!resp) {
|
||||||
this.report({
|
this.report({
|
||||||
type: 'errorChecking',
|
type: 'errorChecking',
|
||||||
message: 'Can not connect to update server. Please check your network.',
|
message: this.t('error_cannot_connect_server'),
|
||||||
});
|
});
|
||||||
this.throwIfEnabled(new Error('errorChecking'));
|
this.throwIfEnabled(Error('errorChecking'));
|
||||||
|
return this.lastRespJson ? await this.lastRespJson : emptyObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!resp.ok) {
|
||||||
|
const respText = await resp.text();
|
||||||
|
const errorMessage = this.t('error_http_status', {
|
||||||
|
status: resp.status,
|
||||||
|
statusText: respText,
|
||||||
|
});
|
||||||
|
this.report({
|
||||||
|
type: 'errorChecking',
|
||||||
|
message: errorMessage,
|
||||||
|
});
|
||||||
|
this.throwIfEnabled(Error(errorMessage));
|
||||||
return this.lastRespJson ? await this.lastRespJson : emptyObj;
|
return this.lastRespJson ? await this.lastRespJson : emptyObj;
|
||||||
}
|
}
|
||||||
this.lastRespJson = resp.json();
|
this.lastRespJson = resp.json();
|
||||||
@@ -300,14 +326,6 @@ export class Pushy {
|
|||||||
|
|
||||||
log('checking result:', result);
|
log('checking result:', result);
|
||||||
|
|
||||||
if (resp.status !== 200) {
|
|
||||||
this.report({
|
|
||||||
type: 'errorChecking',
|
|
||||||
message: result.message,
|
|
||||||
});
|
|
||||||
this.throwIfEnabled(new Error(result.message));
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
getBackupEndpoints = async () => {
|
getBackupEndpoints = async () => {
|
||||||
@@ -412,9 +430,11 @@ export class Pushy {
|
|||||||
});
|
});
|
||||||
succeeded = 'diff';
|
succeeded = 'diff';
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
const errorMessage = `diff error: ${e.message}`;
|
const errorMessage = this.t('error_diff_failed', {
|
||||||
|
message: e.message,
|
||||||
|
});
|
||||||
errorMessages.push(errorMessage);
|
errorMessages.push(errorMessage);
|
||||||
lastError = new Error(errorMessage);
|
lastError = Error(errorMessage);
|
||||||
log(errorMessage);
|
log(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,9 +449,11 @@ export class Pushy {
|
|||||||
});
|
});
|
||||||
succeeded = 'pdiff';
|
succeeded = 'pdiff';
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
const errorMessage = `pdiff error: ${e.message}`;
|
const errorMessage = this.t('error_pdiff_failed', {
|
||||||
|
message: e.message,
|
||||||
|
});
|
||||||
errorMessages.push(errorMessage);
|
errorMessages.push(errorMessage);
|
||||||
lastError = new Error(errorMessage);
|
lastError = Error(errorMessage);
|
||||||
log(errorMessage);
|
log(errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -447,17 +469,15 @@ export class Pushy {
|
|||||||
});
|
});
|
||||||
succeeded = 'full';
|
succeeded = 'full';
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
const errorMessage = `full patch error: ${e.message}`;
|
const errorMessage = this.t('error_full_patch_failed', {
|
||||||
|
message: e.message,
|
||||||
|
});
|
||||||
errorMessages.push(errorMessage);
|
errorMessages.push(errorMessage);
|
||||||
lastError = new Error(errorMessage);
|
lastError = Error(errorMessage);
|
||||||
log(errorMessage);
|
log(errorMessage);
|
||||||
}
|
}
|
||||||
} else if (__DEV__) {
|
} else if (__DEV__) {
|
||||||
log(
|
log(this.t('dev_incremental_update_disabled'));
|
||||||
`当前是开发环境,无法执行增量式热更新,重启不会生效。
|
|
||||||
如果需要在开发环境中测试可生效的全量热更新(但也会在再次重启后重新连接 metro),
|
|
||||||
请打开“忽略时间戳”开关再重试。`,
|
|
||||||
);
|
|
||||||
succeeded = 'full';
|
succeeded = 'full';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -511,7 +531,7 @@ export class Pushy {
|
|||||||
}
|
}
|
||||||
if (sharedState.apkStatus === 'downloaded') {
|
if (sharedState.apkStatus === 'downloaded') {
|
||||||
this.report({ type: 'errorInstallApk' });
|
this.report({ type: 'errorInstallApk' });
|
||||||
this.throwIfEnabled(new Error('errorInstallApk'));
|
this.throwIfEnabled(Error('errorInstallApk'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Platform.Version <= 23) {
|
if (Platform.Version <= 23) {
|
||||||
@@ -521,7 +541,7 @@ export class Pushy {
|
|||||||
);
|
);
|
||||||
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
|
if (granted !== PermissionsAndroid.RESULTS.GRANTED) {
|
||||||
this.report({ type: 'rejectStoragePermission' });
|
this.report({ type: 'rejectStoragePermission' });
|
||||||
this.throwIfEnabled(new Error('rejectStoragePermission'));
|
this.throwIfEnabled(Error('rejectStoragePermission'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
@@ -554,7 +574,7 @@ export class Pushy {
|
|||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
sharedState.apkStatus = null;
|
sharedState.apkStatus = null;
|
||||||
this.report({ type: 'errorDownloadAndInstallApk' });
|
this.report({ type: 'errorDownloadAndInstallApk' });
|
||||||
this.throwIfEnabled(new Error('errorDownloadAndInstallApk'));
|
this.throwIfEnabled(Error('errorDownloadAndInstallApk'));
|
||||||
});
|
});
|
||||||
sharedState.apkStatus = 'downloaded';
|
sharedState.apkStatus = 'downloaded';
|
||||||
if (sharedState.progressHandlers[progressKey]) {
|
if (sharedState.progressHandlers[progressKey]) {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export const defaultContext = {
|
|||||||
parseTestQrCode: () => false,
|
parseTestQrCode: () => false,
|
||||||
currentHash: '',
|
currentHash: '',
|
||||||
packageVersion: '',
|
packageVersion: '',
|
||||||
|
currentVersionInfo: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const UpdateContext = createContext<{
|
export const UpdateContext = createContext<{
|
||||||
@@ -28,11 +29,17 @@ export const UpdateContext = createContext<{
|
|||||||
dismissError: () => void;
|
dismissError: () => void;
|
||||||
downloadUpdate: () => Promise<boolean | void>;
|
downloadUpdate: () => Promise<boolean | void>;
|
||||||
downloadAndInstallApk: (url: string) => Promise<void>;
|
downloadAndInstallApk: (url: string) => Promise<void>;
|
||||||
|
// @deprecated use currentVersionInfo instead
|
||||||
getCurrentVersionInfo: () => Promise<{
|
getCurrentVersionInfo: () => Promise<{
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
metaInfo?: string;
|
metaInfo?: string;
|
||||||
}>;
|
}>;
|
||||||
|
currentVersionInfo: {
|
||||||
|
name?: string;
|
||||||
|
description?: string;
|
||||||
|
metaInfo?: string;
|
||||||
|
} | null;
|
||||||
parseTestQrCode: (code: string) => boolean;
|
parseTestQrCode: (code: string) => boolean;
|
||||||
restartApp: () => Promise<void>;
|
restartApp: () => Promise<void>;
|
||||||
currentHash: string;
|
currentHash: string;
|
||||||
|
|||||||
18
src/core.ts
18
src/core.ts
@@ -18,7 +18,7 @@ export const PushyModule =
|
|||||||
export const UpdateModule = PushyModule;
|
export const UpdateModule = PushyModule;
|
||||||
|
|
||||||
if (!PushyModule) {
|
if (!PushyModule) {
|
||||||
throw new Error(
|
throw Error(
|
||||||
'Failed to load react-native-update native module, please try to recompile',
|
'Failed to load react-native-update native module, please try to recompile',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,21 @@ const PushyConstants = isTurboModuleEnabled
|
|||||||
export const downloadRootDir: string = PushyConstants.downloadRootDir;
|
export const downloadRootDir: string = PushyConstants.downloadRootDir;
|
||||||
export const packageVersion: string = PushyConstants.packageVersion;
|
export const packageVersion: string = PushyConstants.packageVersion;
|
||||||
export const currentVersion: string = PushyConstants.currentVersion;
|
export const currentVersion: string = PushyConstants.currentVersion;
|
||||||
|
|
||||||
|
const currentVersionInfoString: string = PushyConstants.currentVersionInfo;
|
||||||
|
let _currentVersionInfo = {};
|
||||||
|
if (currentVersionInfoString) {
|
||||||
|
try {
|
||||||
|
_currentVersionInfo = JSON.parse(currentVersionInfoString);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(
|
||||||
|
'Failed to parse currentVersionInfo:',
|
||||||
|
currentVersionInfoString,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const currentVersionInfo = _currentVersionInfo;
|
||||||
|
|
||||||
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
export const isFirstTime: boolean = PushyConstants.isFirstTime;
|
||||||
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
export const rolledBackVersion: string = PushyConstants.rolledBackVersion;
|
||||||
export const isRolledBack: boolean = typeof rolledBackVersion === 'string';
|
export const isRolledBack: boolean = typeof rolledBackVersion === 'string';
|
||||||
@@ -45,6 +60,7 @@ async function getLocalHashInfo(hash: string) {
|
|||||||
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
|
return JSON.parse(await PushyModule.getLocalHashInfo(hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @deprecated use currentVersionInfo instead
|
||||||
export async function getCurrentVersionInfo(): Promise<{
|
export async function getCurrentVersionInfo(): Promise<{
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
|
|||||||
108
src/i18n.ts
Normal file
108
src/i18n.ts
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
import zhTranslations from './locales/zh';
|
||||||
|
import enTranslations from './locales/en';
|
||||||
|
|
||||||
|
type TranslationKey = keyof typeof zhTranslations | keyof typeof enTranslations;
|
||||||
|
type TranslationValues = Record<string, string | number>;
|
||||||
|
|
||||||
|
class I18n {
|
||||||
|
private currentLocale: 'zh' | 'en' = 'en';
|
||||||
|
private translations = {
|
||||||
|
zh: zhTranslations,
|
||||||
|
en: enTranslations,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set locale directly
|
||||||
|
* @param locale - 'zh' or 'en'
|
||||||
|
*/
|
||||||
|
setLocale(locale: 'zh' | 'en') {
|
||||||
|
this.currentLocale = locale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get current locale
|
||||||
|
*/
|
||||||
|
getLocale(): 'zh' | 'en' {
|
||||||
|
return this.currentLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate a key with optional interpolation
|
||||||
|
* @param key - Translation key
|
||||||
|
* @param values - Values for interpolation (optional)
|
||||||
|
* @returns Translated string with interpolated values
|
||||||
|
*/
|
||||||
|
t(key: TranslationKey, values?: TranslationValues): string {
|
||||||
|
const translation =
|
||||||
|
this.translations[this.currentLocale][
|
||||||
|
key as keyof (typeof this.translations)[typeof this.currentLocale]
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!translation) {
|
||||||
|
// Fallback to the other locale if key not found
|
||||||
|
const fallbackLocale = this.currentLocale === 'zh' ? 'en' : 'zh';
|
||||||
|
const fallbackTranslation =
|
||||||
|
this.translations[fallbackLocale][
|
||||||
|
key as keyof (typeof this.translations)[typeof fallbackLocale]
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!fallbackTranslation) {
|
||||||
|
// If still not found, return the key itself
|
||||||
|
return String(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.interpolate(fallbackTranslation, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.interpolate(translation, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interpolate values into a string template
|
||||||
|
* Supports {{key}} syntax
|
||||||
|
* @param template - String template with {{key}} placeholders
|
||||||
|
* @param values - Values to interpolate
|
||||||
|
* @returns Interpolated string
|
||||||
|
*/
|
||||||
|
private interpolate(template: string, values?: TranslationValues): string {
|
||||||
|
if (!values) {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
return template.replace(/\{\{(\w+)\}\}/g, (match, key) => {
|
||||||
|
const value = values[key];
|
||||||
|
return value !== undefined ? String(value) : match;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add or update translations for a specific locale
|
||||||
|
* @param locale - Target locale
|
||||||
|
* @param translations - Translation object to merge
|
||||||
|
*/
|
||||||
|
addTranslations(locale: 'zh' | 'en', translations: Record<string, string>) {
|
||||||
|
this.translations[locale] = {
|
||||||
|
...this.translations[locale],
|
||||||
|
...translations,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create singleton instance
|
||||||
|
const i18n = new I18n();
|
||||||
|
|
||||||
|
// Export both the instance and the class for flexibility
|
||||||
|
export { i18n, I18n };
|
||||||
|
export default i18n;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Usage examples:
|
||||||
|
*
|
||||||
|
* // Direct locale setting (new preferred method)
|
||||||
|
* i18n.setLocale('zh'); // Chinese
|
||||||
|
* i18n.setLocale('en'); // English
|
||||||
|
*
|
||||||
|
* // Get translations
|
||||||
|
* i18n.t('checking_update'); // Based on current locale
|
||||||
|
* i18n.t('download_progress', { progress: 50 }); // With interpolation
|
||||||
|
*/
|
||||||
74
src/locales/en.ts
Normal file
74
src/locales/en.ts
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
export default {
|
||||||
|
// Common messages
|
||||||
|
checking_update: 'Checking for updates...',
|
||||||
|
downloading_update: 'Downloading update package...',
|
||||||
|
installing_update: 'Installing update...',
|
||||||
|
update_available: 'Update available',
|
||||||
|
update_downloaded: 'Update downloaded successfully',
|
||||||
|
update_installed: 'Update installed successfully',
|
||||||
|
no_update_available: 'You are up to date',
|
||||||
|
update_failed: 'Update failed',
|
||||||
|
network_error: 'Network connection error',
|
||||||
|
download_failed: 'Download failed',
|
||||||
|
install_failed: 'Installation failed',
|
||||||
|
|
||||||
|
// Progress messages with interpolation
|
||||||
|
download_progress: 'Download progress: {{progress}}%',
|
||||||
|
download_speed: 'Download speed: {{speed}}/s',
|
||||||
|
file_size: 'File size: {{size}}',
|
||||||
|
time_remaining: 'Time remaining: {{time}}',
|
||||||
|
|
||||||
|
// Error messages
|
||||||
|
error_code: 'Error code: {{code}}',
|
||||||
|
error_message: 'Error message: {{message}}',
|
||||||
|
retry_count: 'Retry attempt: {{count}}/{{max}}',
|
||||||
|
|
||||||
|
// Update info
|
||||||
|
version_info: 'Version {{version}} ({{build}})',
|
||||||
|
release_notes: 'Release notes: {{notes}}',
|
||||||
|
update_size: 'Update size: {{size}}MB',
|
||||||
|
|
||||||
|
// Alert messages
|
||||||
|
alert_title: 'Notice',
|
||||||
|
alert_update_ready: 'Download completed. Update now?',
|
||||||
|
alert_next_time: 'Later',
|
||||||
|
alert_update_now: 'Update Now',
|
||||||
|
alert_app_updated:
|
||||||
|
'Your app version has been updated. Click update to download and install the new version',
|
||||||
|
alert_update_button: 'Update',
|
||||||
|
alert_cancel: 'Cancel',
|
||||||
|
alert_confirm: 'OK',
|
||||||
|
alert_info: 'Info',
|
||||||
|
alert_no_update_wait:
|
||||||
|
'No update found, please wait 10s for the server to generate the patch package',
|
||||||
|
|
||||||
|
// Error messages
|
||||||
|
error_appkey_required: 'appKey is required',
|
||||||
|
error_update_check_failed: 'Update check failed',
|
||||||
|
error_cannot_connect_server:
|
||||||
|
'Can not connect to update server. Please check your network.',
|
||||||
|
error_cannot_connect_backup:
|
||||||
|
'Can not connect to update server: {{message}}. Trying backup endpoints.',
|
||||||
|
error_diff_failed: 'diff error: {{message}}',
|
||||||
|
error_pdiff_failed: 'pdiff error: {{message}}',
|
||||||
|
error_full_patch_failed: 'full patch error: {{message}}',
|
||||||
|
error_all_promises_rejected: 'All promises were rejected',
|
||||||
|
error_ping_failed: 'Ping failed',
|
||||||
|
error_ping_timeout: 'Ping timeout',
|
||||||
|
error_http_status: '{{status}} {{statusText}}',
|
||||||
|
|
||||||
|
// Development messages
|
||||||
|
dev_debug_disabled:
|
||||||
|
'You are currently in the development environment and have not enabled debug mode. {{matter}} will not be performed. If you need to debug {{matter}} in the development environment, please set debug to true in the client.',
|
||||||
|
dev_log_prefix: 'react-native-update: ',
|
||||||
|
dev_web_not_supported:
|
||||||
|
'react-native-update does not support the Web platform and will not perform any operations',
|
||||||
|
|
||||||
|
// More alert messages
|
||||||
|
alert_new_version_found:
|
||||||
|
'New version {{name}} found. Download now?\n{{description}}',
|
||||||
|
|
||||||
|
// Development environment messages
|
||||||
|
dev_incremental_update_disabled:
|
||||||
|
'Currently in development environment, incremental hot update cannot be executed and restart will not take effect. If you need to test effective full hot update in development environment (but will reconnect to metro after restart), please enable "ignore timestamp" switch and retry.',
|
||||||
|
};
|
||||||
71
src/locales/zh.ts
Normal file
71
src/locales/zh.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
export default {
|
||||||
|
// Common messages
|
||||||
|
checking_update: '正在检查更新...',
|
||||||
|
downloading_update: '正在下载更新包...',
|
||||||
|
installing_update: '正在安装更新...',
|
||||||
|
update_available: '发现新版本',
|
||||||
|
update_downloaded: '更新包下载完成',
|
||||||
|
update_installed: '更新安装完成',
|
||||||
|
no_update_available: '已是最新版本',
|
||||||
|
update_failed: '更新失败',
|
||||||
|
network_error: '网络连接错误',
|
||||||
|
download_failed: '下载失败',
|
||||||
|
install_failed: '安装失败',
|
||||||
|
|
||||||
|
// Progress messages with interpolation
|
||||||
|
download_progress: '下载进度: {{progress}}%',
|
||||||
|
download_speed: '下载速度: {{speed}}/s',
|
||||||
|
file_size: '文件大小: {{size}}',
|
||||||
|
time_remaining: '剩余时间: {{time}}',
|
||||||
|
|
||||||
|
// Error messages
|
||||||
|
error_code: '错误代码: {{code}}',
|
||||||
|
error_message: '错误信息: {{message}}',
|
||||||
|
retry_count: '重试次数: {{count}}/{{max}}',
|
||||||
|
|
||||||
|
// Update info
|
||||||
|
version_info: '版本 {{version}} ({{build}})',
|
||||||
|
release_notes: '更新说明: {{notes}}',
|
||||||
|
update_size: '更新包大小: {{size}}MB',
|
||||||
|
|
||||||
|
// Alert messages
|
||||||
|
alert_title: '提示',
|
||||||
|
alert_update_ready: '下载完毕,是否立即更新?',
|
||||||
|
alert_next_time: '下次再说',
|
||||||
|
alert_update_now: '立即更新',
|
||||||
|
alert_app_updated: '您的应用版本已更新,点击更新下载安装新版本',
|
||||||
|
alert_update_button: '更新',
|
||||||
|
alert_cancel: '取消',
|
||||||
|
alert_confirm: '确定',
|
||||||
|
alert_info: '信息',
|
||||||
|
alert_no_update_wait: '未发现更新,请等待10秒让服务器生成补丁包',
|
||||||
|
|
||||||
|
// Error messages
|
||||||
|
error_appkey_required: '需要提供 appKey',
|
||||||
|
error_update_check_failed: '更新检查失败',
|
||||||
|
error_cannot_connect_server: '无法连接到更新服务器。请检查网络连接。',
|
||||||
|
error_cannot_connect_backup:
|
||||||
|
'无法连接到更新服务器: {{message}}。正在尝试备用端点。',
|
||||||
|
error_diff_failed: 'diff 错误: {{message}}',
|
||||||
|
error_pdiff_failed: 'pdiff 错误: {{message}}',
|
||||||
|
error_full_patch_failed: '完整补丁错误: {{message}}',
|
||||||
|
error_all_promises_rejected: '所有请求都被拒绝',
|
||||||
|
error_ping_failed: 'Ping 失败',
|
||||||
|
error_ping_timeout: 'Ping 超时',
|
||||||
|
error_http_status: '{{status}} {{statusText}}',
|
||||||
|
|
||||||
|
// Development messages
|
||||||
|
dev_debug_disabled:
|
||||||
|
'您当前处于开发环境且未启用调试模式。{{matter}} 将不会执行。如需在开发环境中调试 {{matter}},请在客户端中将 debug 设为 true。',
|
||||||
|
dev_log_prefix: 'react-native-update: ',
|
||||||
|
dev_web_not_supported:
|
||||||
|
'react-native-update 不支持 Web 平台,不会执行任何操作',
|
||||||
|
|
||||||
|
// More alert messages
|
||||||
|
alert_new_version_found:
|
||||||
|
'检查到新的版本{{name}},是否下载?\n{{description}}',
|
||||||
|
|
||||||
|
// Development environment messages
|
||||||
|
dev_incremental_update_disabled:
|
||||||
|
'当前是开发环境,无法执行增量式热更新,重启不会生效。如果需要在开发环境中测试可生效的全量热更新(但也会在再次重启后重新连接 metro),请打开"忽略时间戳"开关再重试。',
|
||||||
|
};
|
||||||
178
src/provider.tsx
178
src/provider.tsx
@@ -13,12 +13,17 @@ import {
|
|||||||
Linking,
|
Linking,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { Pushy, Cresc, sharedState } from './client';
|
import { Pushy, Cresc, sharedState } from './client';
|
||||||
import { currentVersion, packageVersion, getCurrentVersionInfo } from './core';
|
import { currentVersion, packageVersion, getCurrentVersionInfo, currentVersionInfo } from './core';
|
||||||
import { CheckResult, ProgressData, UpdateTestPayload } from './type';
|
import {
|
||||||
|
CheckResult,
|
||||||
|
ProgressData,
|
||||||
|
UpdateTestPayload,
|
||||||
|
VersionInfo,
|
||||||
|
} from './type';
|
||||||
import { UpdateContext } from './context';
|
import { UpdateContext } from './context';
|
||||||
import { URL } from 'react-native-url-polyfill';
|
import { URL } from 'react-native-url-polyfill';
|
||||||
import { isInRollout } from './isInRollout';
|
import { isInRollout } from './isInRollout';
|
||||||
import { log } from './utils';
|
import { assertWeb, log } from './utils';
|
||||||
|
|
||||||
export const UpdateProvider = ({
|
export const UpdateProvider = ({
|
||||||
client,
|
client,
|
||||||
@@ -30,7 +35,7 @@ export const UpdateProvider = ({
|
|||||||
client = useRef(client).current;
|
client = useRef(client).current;
|
||||||
const { options } = client;
|
const { options } = client;
|
||||||
|
|
||||||
const stateListener = useRef<NativeEventSubscription>();
|
const stateListener = useRef<NativeEventSubscription>(undefined);
|
||||||
const [updateInfo, setUpdateInfo] = useState<CheckResult>();
|
const [updateInfo, setUpdateInfo] = useState<CheckResult>();
|
||||||
const updateInfoRef = useRef(updateInfo);
|
const updateInfoRef = useRef(updateInfo);
|
||||||
const [progress, setProgress] = useState<ProgressData>();
|
const [progress, setProgress] = useState<ProgressData>();
|
||||||
@@ -115,16 +120,16 @@ export const UpdateProvider = ({
|
|||||||
client.switchVersionLater(hash);
|
client.switchVersionLater(hash);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
alertUpdate('提示', '下载完毕,是否立即更新?', [
|
alertUpdate(client.t('alert_title'), client.t('alert_update_ready'), [
|
||||||
{
|
{
|
||||||
text: '下次再说',
|
text: client.t('alert_next_time'),
|
||||||
style: 'cancel',
|
style: 'cancel',
|
||||||
onPress: () => {
|
onPress: () => {
|
||||||
client.switchVersionLater(hash);
|
client.switchVersionLater(hash);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '立即更新',
|
text: client.t('alert_update_now'),
|
||||||
style: 'default',
|
style: 'default',
|
||||||
onPress: () => {
|
onPress: () => {
|
||||||
client.switchVersion(hash);
|
client.switchVersion(hash);
|
||||||
@@ -134,7 +139,7 @@ export const UpdateProvider = ({
|
|||||||
return true;
|
return true;
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setLastError(e);
|
setLastError(e);
|
||||||
alertError('更新失败', e.message);
|
alertError(client.t('update_failed'), e.message);
|
||||||
throwErrorIfEnabled(e);
|
throwErrorIfEnabled(e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -158,84 +163,102 @@ export const UpdateProvider = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastChecking.current = now;
|
lastChecking.current = now;
|
||||||
let info: CheckResult;
|
let rootInfo: CheckResult | undefined;
|
||||||
try {
|
try {
|
||||||
info = await client.checkUpdate(extra);
|
rootInfo = await client.checkUpdate(extra);
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
setLastError(e);
|
setLastError(e);
|
||||||
alertError('更新检查失败', e.message);
|
alertError(client.t('error_update_check_failed'), e.message);
|
||||||
throwErrorIfEnabled(e);
|
throwErrorIfEnabled(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!info) {
|
if (!rootInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rollout = info.config?.rollout?.[packageVersion];
|
const versions = [rootInfo.expVersion, rootInfo].filter(Boolean) as VersionInfo[];
|
||||||
if (info.update && rollout) {
|
delete rootInfo.expVersion;
|
||||||
if (!isInRollout(rollout)) {
|
for (const versionInfo of versions) {
|
||||||
log(`not in ${rollout}% rollout, ignored`);
|
const info: CheckResult = {
|
||||||
return;
|
...versionInfo,
|
||||||
|
...rootInfo,
|
||||||
|
};
|
||||||
|
const rollout = info.config?.rollout?.[packageVersion];
|
||||||
|
if (info.update && rollout) {
|
||||||
|
if (!isInRollout(rollout)) {
|
||||||
|
log(`${info.name} not in ${rollout}% rollout, ignored`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
log(`${info.name} in ${rollout}% rollout, continue`);
|
||||||
}
|
}
|
||||||
log(`in ${rollout}% rollout, continue`);
|
info.description = info.description ?? '';
|
||||||
}
|
updateInfoRef.current = info;
|
||||||
info.description = info.description ?? '';
|
setUpdateInfo(info);
|
||||||
updateInfoRef.current = info;
|
if (info.expired) {
|
||||||
setUpdateInfo(info);
|
if (
|
||||||
if (info.expired) {
|
options.onPackageExpired &&
|
||||||
if (
|
(await options.onPackageExpired(info)) === false
|
||||||
options.onPackageExpired &&
|
) {
|
||||||
(await options.onPackageExpired(info)) === false
|
log('onPackageExpired returned false, skipping');
|
||||||
) {
|
return;
|
||||||
log('onPackageExpired returned false, skipping');
|
}
|
||||||
return;
|
const { downloadUrl } = info;
|
||||||
}
|
if (downloadUrl && sharedState.apkStatus === null) {
|
||||||
const { downloadUrl } = info;
|
if (options.updateStrategy === 'silentAndNow') {
|
||||||
if (downloadUrl && sharedState.apkStatus === null) {
|
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
||||||
if (options.updateStrategy === 'silentAndNow') {
|
downloadAndInstallApk(downloadUrl);
|
||||||
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
} else {
|
||||||
downloadAndInstallApk(downloadUrl);
|
Linking.openURL(downloadUrl);
|
||||||
} else {
|
}
|
||||||
Linking.openURL(downloadUrl);
|
return info;
|
||||||
}
|
}
|
||||||
|
alertUpdate(
|
||||||
|
client.t('alert_title'),
|
||||||
|
client.t('alert_app_updated'),
|
||||||
|
[
|
||||||
|
{
|
||||||
|
text: client.t('alert_update_button'),
|
||||||
|
onPress: () => {
|
||||||
|
if (
|
||||||
|
Platform.OS === 'android' &&
|
||||||
|
downloadUrl.endsWith('.apk')
|
||||||
|
) {
|
||||||
|
downloadAndInstallApk(downloadUrl);
|
||||||
|
} else {
|
||||||
|
Linking.openURL(downloadUrl);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (info.update) {
|
||||||
|
if (
|
||||||
|
options.updateStrategy === 'silentAndNow' ||
|
||||||
|
options.updateStrategy === 'silentAndLater'
|
||||||
|
) {
|
||||||
|
downloadUpdate(info);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
alertUpdate('提示', '您的应用版本已更新,点击更新下载安装新版本', [
|
alertUpdate(
|
||||||
{
|
client.t('alert_title'),
|
||||||
text: '更新',
|
client.t('alert_new_version_found', {
|
||||||
onPress: () => {
|
name: info.name!,
|
||||||
if (Platform.OS === 'android' && downloadUrl.endsWith('.apk')) {
|
description: info.description,
|
||||||
downloadAndInstallApk(downloadUrl);
|
}),
|
||||||
} else {
|
[
|
||||||
Linking.openURL(downloadUrl);
|
{ text: client.t('alert_cancel'), style: 'cancel' },
|
||||||
}
|
{
|
||||||
|
text: client.t('alert_confirm'),
|
||||||
|
style: 'default',
|
||||||
|
onPress: () => {
|
||||||
|
downloadUpdate();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
],
|
||||||
]);
|
);
|
||||||
}
|
}
|
||||||
} else if (info.update) {
|
return info;
|
||||||
if (
|
|
||||||
options.updateStrategy === 'silentAndNow' ||
|
|
||||||
options.updateStrategy === 'silentAndLater'
|
|
||||||
) {
|
|
||||||
downloadUpdate(info);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
alertUpdate(
|
|
||||||
'提示',
|
|
||||||
'检查到新的版本' + info.name + ',是否下载?\n' + info.description,
|
|
||||||
[
|
|
||||||
{ text: '取消', style: 'cancel' },
|
|
||||||
{
|
|
||||||
text: '确定',
|
|
||||||
style: 'default',
|
|
||||||
onPress: () => {
|
|
||||||
downloadUpdate();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return info;
|
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
client,
|
client,
|
||||||
@@ -254,6 +277,9 @@ export const UpdateProvider = ({
|
|||||||
if (!client.assertDebug('checkUpdate()')) {
|
if (!client.assertDebug('checkUpdate()')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!assertWeb()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const { checkStrategy, dismissErrorAfter, autoMarkSuccess } = options;
|
const { checkStrategy, dismissErrorAfter, autoMarkSuccess } = options;
|
||||||
if (autoMarkSuccess) {
|
if (autoMarkSuccess) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -297,8 +323,8 @@ export const UpdateProvider = ({
|
|||||||
checkUpdate({ extra: { toHash: payload.data } }).then(() => {
|
checkUpdate({ extra: { toHash: payload.data } }).then(() => {
|
||||||
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
if (updateInfoRef.current && updateInfoRef.current.upToDate) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
'Info',
|
client.t('alert_info'),
|
||||||
'No update found, please wait 10s for the server to generate the patch package',
|
client.t('alert_no_update_wait'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
options.logger = logger;
|
options.logger = logger;
|
||||||
@@ -308,7 +334,7 @@ export const UpdateProvider = ({
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
[checkUpdate, options],
|
[checkUpdate, options, client],
|
||||||
);
|
);
|
||||||
|
|
||||||
const parseTestQrCode = useCallback(
|
const parseTestQrCode = useCallback(
|
||||||
@@ -328,6 +354,9 @@ export const UpdateProvider = ({
|
|||||||
}, [client]);
|
}, [client]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!assertWeb()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const parseLinking = (url: string | null) => {
|
const parseLinking = (url: string | null) => {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
return;
|
return;
|
||||||
@@ -371,6 +400,7 @@ export const UpdateProvider = ({
|
|||||||
progress,
|
progress,
|
||||||
downloadAndInstallApk,
|
downloadAndInstallApk,
|
||||||
getCurrentVersionInfo,
|
getCurrentVersionInfo,
|
||||||
|
currentVersionInfo,
|
||||||
parseTestQrCode,
|
parseTestQrCode,
|
||||||
restartApp,
|
restartApp,
|
||||||
}}>
|
}}>
|
||||||
|
|||||||
32
src/type.ts
32
src/type.ts
@@ -1,14 +1,10 @@
|
|||||||
export interface CheckResult {
|
export interface VersionInfo {
|
||||||
upToDate?: true;
|
name: string;
|
||||||
expired?: true;
|
hash: string;
|
||||||
downloadUrl?: string;
|
description: string;
|
||||||
update?: true;
|
metaInfo: string;
|
||||||
name?: string; // version name
|
config: {
|
||||||
hash?: string;
|
rollout: {
|
||||||
description?: string;
|
|
||||||
metaInfo?: string;
|
|
||||||
config?: {
|
|
||||||
rollout?: {
|
|
||||||
[packageVersion: string]: number;
|
[packageVersion: string]: number;
|
||||||
};
|
};
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
@@ -16,11 +12,23 @@ export interface CheckResult {
|
|||||||
pdiff?: string;
|
pdiff?: string;
|
||||||
diff?: string;
|
diff?: string;
|
||||||
full?: string;
|
full?: string;
|
||||||
paths?: string[];
|
}
|
||||||
|
|
||||||
|
interface RootResult {
|
||||||
|
upToDate?: true;
|
||||||
|
expired?: true;
|
||||||
|
downloadUrl?: string;
|
||||||
|
update?: true;
|
||||||
paused?: 'app' | 'package';
|
paused?: 'app' | 'package';
|
||||||
message?: string;
|
message?: string;
|
||||||
|
paths?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CheckResult = RootResult &
|
||||||
|
Partial<VersionInfo> & {
|
||||||
|
expVersion?: VersionInfo;
|
||||||
|
};
|
||||||
|
|
||||||
export interface ProgressData {
|
export interface ProgressData {
|
||||||
hash: string;
|
hash: string;
|
||||||
received: number;
|
received: number;
|
||||||
|
|||||||
81
src/utils.ts
81
src/utils.ts
@@ -1,9 +1,12 @@
|
|||||||
import { Platform } from 'react-native';
|
import { Platform } from 'react-native';
|
||||||
|
import i18n from './i18n';
|
||||||
|
|
||||||
export function log(...args: any[]) {
|
export function log(...args: any[]) {
|
||||||
console.log('react-native-update: ', ...args);
|
console.log(i18n.t('dev_log_prefix'), ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isWeb = Platform.OS === 'web';
|
||||||
|
|
||||||
export function promiseAny<T>(promises: Promise<T>[]) {
|
export function promiseAny<T>(promises: Promise<T>[]) {
|
||||||
return new Promise<T>((resolve, reject) => {
|
return new Promise<T>((resolve, reject) => {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
@@ -14,7 +17,7 @@ export function promiseAny<T>(promises: Promise<T>[]) {
|
|||||||
.catch(() => {
|
.catch(() => {
|
||||||
count++;
|
count++;
|
||||||
if (count === promises.length) {
|
if (count === promises.length) {
|
||||||
reject(new Error('All promises were rejected'));
|
reject(Error(i18n.t('error_all_promises_rejected')));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -34,38 +37,37 @@ class EmptyModule {
|
|||||||
}
|
}
|
||||||
export const emptyModule = new EmptyModule();
|
export const emptyModule = new EmptyModule();
|
||||||
|
|
||||||
const ping =
|
const ping = isWeb
|
||||||
Platform.OS === 'web'
|
? Promise.resolve
|
||||||
? Promise.resolve
|
: async (url: string) => {
|
||||||
: async (url: string) => {
|
let pingFinished = false;
|
||||||
let pingFinished = false;
|
return Promise.race([
|
||||||
return Promise.race([
|
enhancedFetch(url, {
|
||||||
enhancedFetch(url, {
|
method: 'HEAD',
|
||||||
method: 'HEAD',
|
})
|
||||||
|
.then(({ status, statusText, url: finalUrl }) => {
|
||||||
|
pingFinished = true;
|
||||||
|
if (status === 200) {
|
||||||
|
return finalUrl;
|
||||||
|
}
|
||||||
|
log('ping failed', url, status, statusText);
|
||||||
|
throw Error(i18n.t('error_ping_failed'));
|
||||||
})
|
})
|
||||||
.then(({ status, statusText, url: finalUrl }) => {
|
.catch(e => {
|
||||||
pingFinished = true;
|
pingFinished = true;
|
||||||
if (status === 200) {
|
log('ping error', url, e);
|
||||||
return finalUrl;
|
throw e;
|
||||||
}
|
}),
|
||||||
log('ping failed', url, status, statusText);
|
new Promise((_, reject) =>
|
||||||
throw new Error('Ping failed');
|
setTimeout(() => {
|
||||||
})
|
reject(Error(i18n.t('error_ping_timeout')));
|
||||||
.catch(e => {
|
if (!pingFinished) {
|
||||||
pingFinished = true;
|
log('ping timeout', url);
|
||||||
log('ping error', url, e);
|
}
|
||||||
throw e;
|
}, 5000),
|
||||||
}),
|
),
|
||||||
new Promise((_, reject) =>
|
]);
|
||||||
setTimeout(() => {
|
};
|
||||||
reject(new Error('Ping timeout'));
|
|
||||||
if (!pingFinished) {
|
|
||||||
log('ping timeout', url);
|
|
||||||
}
|
|
||||||
}, 5000),
|
|
||||||
),
|
|
||||||
]);
|
|
||||||
};
|
|
||||||
|
|
||||||
export function joinUrls(paths: string[], fileName?: string) {
|
export function joinUrls(paths: string[], fileName?: string) {
|
||||||
if (fileName) {
|
if (fileName) {
|
||||||
@@ -90,10 +92,8 @@ export const testUrls = async (urls?: string[]) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const assertWeb = () => {
|
export const assertWeb = () => {
|
||||||
if (Platform.OS === 'web') {
|
if (isWeb) {
|
||||||
console.warn(
|
console.warn(i18n.t('dev_web_not_supported'));
|
||||||
'react-native-update does not support the Web platform and will not perform any operations',
|
|
||||||
);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -115,7 +115,12 @@ export const enhancedFetch = async (
|
|||||||
if (r.ok) {
|
if (r.ok) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
throw new Error(`${r.status} ${r.statusText}`);
|
throw Error(
|
||||||
|
i18n.t('error_http_status', {
|
||||||
|
status: r.status,
|
||||||
|
statusText: r.statusText,
|
||||||
|
}),
|
||||||
|
);
|
||||||
})
|
})
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
log('fetch error', url, e);
|
log('fetch error', url, e);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{
|
{
|
||||||
"extends": "@react-native/typescript-config/tsconfig.json",
|
"extends": "@react-native/typescript-config",
|
||||||
"include": ["src/**/*"]
|
"include": ["**/*.ts", "**/*.tsx"],
|
||||||
|
"exclude": ["**/node_modules", "**/Pods", "**/harmony", "**/Example"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user