react-native-qrcode-svg 6.3.12 → 6.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Example/Gemfile +3 -4
- package/Example/Gemfile.lock +2 -2
- package/Example/README.md +2 -2
- package/Example/android/app/build.gradle +3 -3
- package/Example/android/app/src/main/AndroidManifest.xml +2 -1
- package/Example/android/app/src/main/java/com/example/MainApplication.kt +1 -3
- package/Example/android/build.gradle +3 -3
- package/Example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/Example/android/gradle.properties +0 -2
- package/Example/android/settings.gradle +3 -1
- package/Example/ios/Example/Info.plist +1 -1
- package/Example/ios/Example.xcodeproj/project.pbxproj +23 -0
- package/Example/ios/Podfile +2 -2
- package/Example/ios/Podfile.lock +905 -510
- package/Example/package.json +8 -8
- package/Example/yarn.lock +2189 -2542
- package/README.md +47 -3
- package/babel.config.js +7 -1
- package/package.json +5 -4
- package/src/index.js +0 -2
- package/textEncodingTransformation.js +41 -0
- package/Example/macos/.xcode.env.local +0 -2
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
# Looking for maintainers
|
|
2
|
-
I'm not working on any React Native projects anymore. Feel free to take over this project if you feel good about it!
|
|
3
1
|
|
|
4
2
|
[](https://npmjs.org/package/react-native-qrcode-svg)
|
|
5
|
-

|
|
6
3
|
|
|
7
4
|
# react-native-qrcode-svg
|
|
8
5
|
|
|
@@ -153,7 +150,11 @@ import RNFS from "react-native-fs"
|
|
|
153
150
|
})
|
|
154
151
|
}
|
|
155
152
|
```
|
|
153
|
+
## Development and testing
|
|
154
|
+
This library comes with an Example App. You can find it in the directory `./Example`.
|
|
155
|
+
Use the app to easily test your changes to `react-native-qrcode-svg` and when developing new features.
|
|
156
156
|
|
|
157
|
+
Read more details in the dedicated [README](/Example/README.md).
|
|
157
158
|
|
|
158
159
|
## Dependencies
|
|
159
160
|
|
|
@@ -164,3 +165,46 @@ import RNFS from "react-native-fs"
|
|
|
164
165
|
### Dependencies
|
|
165
166
|
|
|
166
167
|
* [node-qrcode](https://github.com/soldair/node-qrcode)
|
|
168
|
+
|
|
169
|
+
### Integrating react-native-qrcode-svg with React Native versions below 0.75
|
|
170
|
+
This library works seamlessly with React Native versions 0.75 and above. However, if you're using an older version of React Native (below 0.75), you might need to apply a custom transformation to your project's metro.config.js file to ensure compatibility with the TextEncoder API.
|
|
171
|
+
|
|
172
|
+
Here's how to configure the transformer for both Expo and React Native projects:
|
|
173
|
+
|
|
174
|
+
#### Setting Up the Transformer:
|
|
175
|
+
Make sure your project has a `metro.config.js` file. If not, create one at the root of your project.
|
|
176
|
+
|
|
177
|
+
#### Expo Projects:
|
|
178
|
+
```js
|
|
179
|
+
const { getDefaultConfig } = require("expo/metro-config");
|
|
180
|
+
|
|
181
|
+
module.exports = (() => {
|
|
182
|
+
const config = getDefaultConfig(__dirname);
|
|
183
|
+
|
|
184
|
+
const { transformer } = config;
|
|
185
|
+
|
|
186
|
+
config.transformer = {
|
|
187
|
+
...transformer,
|
|
188
|
+
babelTransformerPath: require.resolve("react-native-qrcode-svg/textEncodingTransformation")
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
return config;
|
|
192
|
+
})();
|
|
193
|
+
```
|
|
194
|
+
Merge the contents from your project's metro.config.js file with this config.
|
|
195
|
+
|
|
196
|
+
#### React Native Projects:
|
|
197
|
+
```js
|
|
198
|
+
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
|
|
199
|
+
|
|
200
|
+
const defaultConfig = getDefaultConfig(__dirname);
|
|
201
|
+
|
|
202
|
+
const config = {
|
|
203
|
+
transformer: {
|
|
204
|
+
babelTransformerPath: require.resolve("react-native-qrcode-svg/textEncodingTransformation"),
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
module.exports = mergeConfig(defaultConfig, config);
|
|
209
|
+
```
|
|
210
|
+
|
package/babel.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-qrcode-svg",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.14",
|
|
4
4
|
"description": "A QR Code generator for React Native based on react-native-svg and javascript-qrcode.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"src",
|
|
37
37
|
"babel.config.js",
|
|
38
38
|
"index.d.ts",
|
|
39
|
-
"index.js"
|
|
39
|
+
"index.js",
|
|
40
|
+
"textEncodingTransformation.js"
|
|
40
41
|
],
|
|
41
42
|
"keywords": [
|
|
42
43
|
"react-native",
|
|
@@ -52,11 +53,11 @@
|
|
|
52
53
|
"peerDependencies": {
|
|
53
54
|
"react": "*",
|
|
54
55
|
"react-native": ">=0.63.4",
|
|
55
|
-
"react-native-svg": ">=
|
|
56
|
+
"react-native-svg": ">=14.0.0"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
59
|
"prop-types": "^15.8.0",
|
|
59
|
-
"qrcode": "^1.5.
|
|
60
|
+
"qrcode": "^1.5.4",
|
|
60
61
|
"text-encoding": "^0.7.0"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const { readFileSync } = require('fs');
|
|
2
|
+
const semver = require('semver');
|
|
3
|
+
|
|
4
|
+
const fileToTransform = 'node_modules/react-native-qrcode-svg/src/index.js';
|
|
5
|
+
|
|
6
|
+
const upstreamTransformer = (() => {
|
|
7
|
+
try {
|
|
8
|
+
return require("@expo/metro-config/babel-transformer");
|
|
9
|
+
} catch (error) {
|
|
10
|
+
try {
|
|
11
|
+
return require("@react-native/metro-babel-transformer");
|
|
12
|
+
} catch (error) {
|
|
13
|
+
return require("metro-react-native-babel-transformer");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
})();
|
|
17
|
+
|
|
18
|
+
function createTransformer(transformer) {
|
|
19
|
+
return async ({src, filename, ...rest}) => {
|
|
20
|
+
if (filename === fileToTransform) {
|
|
21
|
+
const packageJsonPath = require.resolve('react-native/package.json');
|
|
22
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
23
|
+
const ReactNativeVersion = packageJson.version;
|
|
24
|
+
|
|
25
|
+
// React Native versions below 0.75 do not include a global TextEncoder implementation.
|
|
26
|
+
// To ensure compatibility with these older versions, we add a polyfill using the 'text-encoding' library.
|
|
27
|
+
if (semver.lt(ReactNativeVersion, '0.75.0')) {
|
|
28
|
+
return transformer.transform({
|
|
29
|
+
src: `global.TextEncoder = require('text-encoding').TextEncoder;\n${src}`,
|
|
30
|
+
filename,
|
|
31
|
+
...rest
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return transformer.transform({src, filename, ...rest});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = {
|
|
40
|
+
transform: createTransformer(upstreamTransformer),
|
|
41
|
+
};
|