@kingstinct/react-native-healthkit 6.1.0 → 6.1.1

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.
Files changed (2) hide show
  1. package/app.plugin.js +69 -0
  2. package/package.json +3 -2
package/app.plugin.js ADDED
@@ -0,0 +1,69 @@
1
+ /* eslint-disable import/no-extraneous-dependencies, functional/immutable-data, no-param-reassign, @typescript-eslint/no-var-requires */
2
+ const {
3
+ withPlugins,
4
+ createRunOncePlugin,
5
+ withEntitlementsPlist,
6
+ withInfoPlist,
7
+ } = require('@expo/config-plugins')
8
+
9
+ /**
10
+ * @typedef ConfigPlugin
11
+ * @type {import('@expo/config-plugins').ConfigPlugin<T>}
12
+ * @template T = void
13
+ */
14
+
15
+ // please note that the BackgroundConfig currently doesn't actually enable background delivery for any types, but you
16
+ // can set it to false if you don't want the entitlement
17
+
18
+ /**
19
+ * @typedef BackgroundConfig
20
+ * @type {false | Partial<Record<
21
+ * import('./src/native-types').HKSampleTypeIdentifier,
22
+ * import('./src/native-types').HKUpdateFrequency
23
+ * >>}
24
+
25
+ /**
26
+ * @typedef InfoPlistConfig
27
+ * @type {{
28
+ * NSHealthShareUsageDescription?: string | false,
29
+ * NSHealthUpdateUsageDescription?: string | false
30
+ * }}
31
+ */
32
+
33
+ /**
34
+ * @typedef AppPluginConfig
35
+ * @type {InfoPlistConfig & { background?: BackgroundConfig }}
36
+ */
37
+
38
+ /**
39
+ * @type {ConfigPlugin<{background: BackgroundConfig}>}
40
+ */
41
+ const withEntitlementsPlugin = (config, { background }) => withEntitlementsPlist(config, (config) => {
42
+ config.modResults['com.apple.developer.healthkit'] = true
43
+ config.modResults['com.apple.developer.healthkit.background-delivery'] = background !== false
44
+ return config
45
+ })
46
+
47
+ /**
48
+ * @type {ConfigPlugin<InfoPlistConfig>}
49
+ */
50
+ const withInfoPlistPlugin = (config, { NSHealthShareUsageDescription, NSHealthUpdateUsageDescription }) => withInfoPlist(config, (config) => {
51
+ config.modResults.NSHealthShareUsageDescription = NSHealthShareUsageDescription || (NSHealthShareUsageDescription === false ? undefined : `${config.name} wants to read your health data`)
52
+ config.modResults.NSHealthUpdateUsageDescription = NSHealthUpdateUsageDescription || (NSHealthUpdateUsageDescription === false ? undefined : `${config.name} wants to update your health data`)
53
+ return config
54
+ })
55
+
56
+ const pkg = require('./package.json')
57
+
58
+ /**
59
+ * @type {ConfigPlugin<AppPluginConfig>}
60
+ */
61
+ const healthkitAppPlugin = (config, { NSHealthShareUsageDescription, NSHealthUpdateUsageDescription, background }) => withPlugins(config, [
62
+ [withEntitlementsPlugin, { background }],
63
+ [withInfoPlistPlugin, { NSHealthShareUsageDescription, NSHealthUpdateUsageDescription }],
64
+ ])
65
+
66
+ /**
67
+ * @type {ConfigPlugin<AppPluginConfig>}
68
+ */
69
+ module.exports = createRunOncePlugin(healthkitAppPlugin, pkg.name, pkg.version)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "6.1.0",
3
+ "version": "6.1.1",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -17,7 +17,8 @@
17
17
  "!lib/typescript/example",
18
18
  "!**/__tests__",
19
19
  "!**/__fixtures__",
20
- "!**/__mocks__"
20
+ "!**/__mocks__",
21
+ "app.plugin.js"
21
22
  ],
22
23
  "scripts": {
23
24
  "test-only": "jest",