mirror of
https://github.com/expo/config-plugins.git
synced 2026-11-13 20:28:07 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a570fb05a | ||
|
|
aed09045d6 | ||
|
|
ad810c8b11 | ||
|
|
e445cb4bc8 | ||
|
|
9b22a71343 | ||
|
|
e49a241243 | ||
|
|
2e06dcae54 | ||
|
|
a24ea1df58 | ||
|
|
50646306c5 | ||
|
|
6fbb2192ad | ||
|
|
7c3cda4f79 | ||
|
|
a78e569f54 | ||
|
|
3fee1c0e6e | ||
|
|
31aee40ee3 | ||
|
|
21c49280d4 | ||
|
|
ce1a818564 | ||
|
|
241d378a54 | ||
|
|
d1bf616248 | ||
|
|
a99c60efd5 | ||
|
|
331ecb163f | ||
|
|
1003ddb2ec | ||
|
|
5ca4e44a49 | ||
|
|
4103b4eb7d | ||
|
|
f8023bf04c | ||
|
|
1b3e87f930 | ||
|
|
5e3ed6d5e4 | ||
|
|
f46f340623 | ||
|
|
99f18da4ed | ||
|
|
999cc00275 | ||
|
|
363d36b0bb | ||
|
|
37d11f1867 | ||
|
|
7ecaaf5bd9 | ||
|
|
9ff7299176 | ||
|
|
f1bd9a7e27 | ||
|
|
83b52a3b61 | ||
|
|
16dfad4dc8 | ||
|
|
0f6493e28d |
No files matched your search
@@ -0,0 +1,91 @@
|
||||
# AUTO GENERATED:
|
||||
# This file was generated by running the following in the root directory:
|
||||
#
|
||||
# yarn update-dependabot-config
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: npm
|
||||
directory: packages/android-jsc-intl
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/detox
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/ffmpeg-kit-react-native
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/ios-stickers
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-adjust
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-ble-plx
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-blob-util
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-branch
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-callkeep
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-dynamic-app-icon
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-google-cast
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-pdf
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-quick-actions
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
- package-ecosystem: npm
|
||||
directory: packages/react-native-webrtc
|
||||
schedule:
|
||||
interval: daily
|
||||
time: '09:00'
|
||||
timezone: America/Los_Angeles
|
||||
@@ -40,6 +40,7 @@ jobs:
|
||||
ios-stickers,
|
||||
react-native-ble-plx,
|
||||
react-native-blob-util,
|
||||
react-native-branch,
|
||||
react-native-google-cast,
|
||||
react-native-pdf,
|
||||
# react-native-quick-actions,
|
||||
@@ -54,8 +55,12 @@ jobs:
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- name: Lint ${{ matrix.package }}
|
||||
run: yarn lint --max-warnings 0
|
||||
working-directory: packages/${{ matrix.package }}
|
||||
- name: Test ${{ matrix.package }}
|
||||
run: cd packages/${{ matrix.package }} && yarn test
|
||||
run: yarn test
|
||||
working-directory: packages/${{ matrix.package }}
|
||||
env:
|
||||
CI: true
|
||||
EXPO_DEBUG: true
|
||||
+16
-4
@@ -5,10 +5,22 @@
|
||||
To submit a pull request:
|
||||
|
||||
1. Fork the [repository](https://github.com/expo/config-plugins) and create a feature branch. (Existing contributors can create feature branches without forking. Prefix the branch name with `@your-github-username/`.)
|
||||
2. Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) including in the PR tile.
|
||||
3. Fill out the entire PR template. Ensure your code is tested locally and has continuous tests in CI.
|
||||
4. Make sure all tests pass on GitHub Actions.
|
||||
5. Wait for a review and adjust the code if necessary.
|
||||
2. Run `yarn` in the root directory to generate the build files.
|
||||
3. Use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) including in the PR tile.
|
||||
4. Fill out the entire PR template. Ensure your code is tested locally and has continuous tests in CI.
|
||||
5. Make sure all tests pass on GitHub Actions.
|
||||
6. Wait for a review and adjust the code if necessary.
|
||||
|
||||
## Creating a plugin
|
||||
|
||||
- Plugins can be generated by running `yarn gen`.
|
||||
- Add plugins to the example in [`apps/app`](/apps/app/package.json) to test them.
|
||||
- The example app should always stay in a state of regeneration.
|
||||
|
||||
Be sure to run the following scripts in the **root directory** to update automation tools:
|
||||
|
||||
- Update dependabot: `yarn update-dependabot-config`
|
||||
- Update the issue template: `yarn update-issue-template`
|
||||
|
||||
## Publishing a release
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
# Expo Config Plugins
|
||||
|
||||
A collection of custom WIP config plugins for Expo dev clients. Use at your own discretion.
|
||||
- A collection of [Expo config plugins](https://docs.expo.dev/guides/config-plugins/) for configuring the `expo prebuild` command.
|
||||
- This repo is to Expo config plugins as [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) is to TypeScript.
|
||||
- We prefer packages ship their own Expo config plugin (to ensure versioning is aligned), but if they haven't adopted the system yet, the community can add a package here.
|
||||
- All packages here are community maintained. Feel free to improve docs, packages, tests, etc.
|
||||
- We maintain a 1-1 mapping of **native packages** ⇔ `@config-plugins/*`. This means there should be no general utility packages here -- those are better suited for a different repo / NPM namespace.
|
||||
|
||||
## Contributing!
|
||||
|
||||
## Creating a plugin
|
||||
|
||||
- Plugins can be generated by running `yarn gen`.
|
||||
- Add plugins to the example in [`apps/app`](/apps/app/package.json) to test them.
|
||||
- The example app should always stay in a state of regeneration.
|
||||
See the [contributing guide](/CONTRIBUTING.md).
|
||||
@@ -6,6 +6,7 @@
|
||||
"postinstall": "expo-yarn-workspaces check-workspace-dependencies",
|
||||
"gen": "ts-node ./scripts/generate-plugin.ts",
|
||||
"update-issue-template": "ts-node ./scripts/gh-issues-config.ts",
|
||||
"update-dependabot-config": "ts-node ./scripts/update-dependabot-config.ts",
|
||||
"start": "lerna run build --parallel -- --watch",
|
||||
"prepare": "lerna run prepare --parallel"
|
||||
},
|
||||
@@ -28,6 +29,7 @@
|
||||
"semantic-release": "^19.0.2",
|
||||
"@types/js-yaml": "^4.0.5",
|
||||
"@types/prompts": "^2.0.13",
|
||||
"eslint": "^7.25.0",
|
||||
"expo-yarn-workspaces": "^1.5.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"lerna": "3.4.1",
|
||||
|
||||
@@ -1,3 +1,21 @@
|
||||
## @config-plugins/android-jsc-intl [2.0.0](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-05-10)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **android-jsc-intl:** add SDK 45 support (#77)
|
||||
|
||||
### Features
|
||||
|
||||
* **android-jsc-intl:** add SDK 45 support ([#77](https://github.com/expo/config-plugins/issues/77)) ([aed0904](https://github.com/expo/config-plugins/commit/aed09045d61bc67b375a277b96bdc90ed5245d0f))
|
||||
|
||||
### @config-plugins/android-jsc-intl [1.0.4](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-23)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* **android-jsc-intl:** lint fix ([5ca4e44](https://github.com/expo/config-plugins/commit/5ca4e44a49ad5c3153b4a2b15acf69db594d76b8))
|
||||
|
||||
### @config-plugins/android-jsc-intl [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ Adding this plugin lets you use `Intl` in your Android app, without using Hermes
|
||||
|
||||
## Expo installation
|
||||
|
||||
> Tested against Expo SDK 44
|
||||
> Tested against Expo SDK 45
|
||||
|
||||
This package cannot be used in the "Expo Go" app because [it requires custom native code](https://docs.expo.io/workflow/customizing/).
|
||||
|
||||
|
||||
+4
-6
@@ -8,13 +8,11 @@ const config_plugins_1 = require("@expo/config-plugins");
|
||||
*/
|
||||
const withAndroidJscIntl = (config) => {
|
||||
// Return the modified config.
|
||||
return config_plugins_1.withAppBuildGradle(config, config => {
|
||||
if (config.modResults.language === 'groovy') {
|
||||
config.modResults.contents = config.modResults.contents.replace('org.webkit:android-jsc:+', 'org.webkit:android-jsc-intl:+');
|
||||
}
|
||||
else {
|
||||
throw new Error('[@expo/config-plugins][withAndroidJscIntl] Cannot enable Intl in Android JSC app gradle because the build.gradle is not groovy.');
|
||||
return config_plugins_1.withAppBuildGradle(config, (config) => {
|
||||
if (config.modResults.language !== "groovy") {
|
||||
throw new Error("[@expo/config-plugins][withAndroidJscIntl] Cannot enable Intl in Android JSC app gradle because the build.gradle is not groovy.");
|
||||
}
|
||||
config.modResults.contents = config.modResults.contents.replace("org.webkit:android-jsc:+", "org.webkit:android-jsc-intl:+");
|
||||
return config;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/android-jsc-intl",
|
||||
"version": "1.0.3",
|
||||
"version": "2.0.0",
|
||||
"description": "Config plugin for android-jsc-intl package",
|
||||
"main": "build/withAndroidJscIntl.js",
|
||||
"types": "build/withAndroidJscIntl.d.ts",
|
||||
@@ -31,7 +31,7 @@
|
||||
"preset": "expo-module-scripts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/config-plugins": "^4.1.0"
|
||||
"@expo/config-plugins": "~4.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"expo-module-scripts": "^2.0.0"
|
||||
|
||||
@@ -2,22 +2,25 @@ import { ConfigPlugin, withAppBuildGradle } from "@expo/config-plugins";
|
||||
|
||||
/**
|
||||
* Apply android-jsc-intl configuration for Expo SDK 42 projects.
|
||||
*
|
||||
*
|
||||
* This plugin lets you access the `Intl` API in Android apps (without Hermes).
|
||||
*/
|
||||
const withAndroidJscIntl: ConfigPlugin = (config) => {
|
||||
// Return the modified config.
|
||||
return withAppBuildGradle(config, config => {
|
||||
if (config.modResults.language === 'groovy') {
|
||||
config.modResults.contents = config.modResults.contents.replace(
|
||||
'org.webkit:android-jsc:+',
|
||||
'org.webkit:android-jsc-intl:+'
|
||||
)
|
||||
} else {
|
||||
throw new Error('[@expo/config-plugins][withAndroidJscIntl] Cannot enable Intl in Android JSC app gradle because the build.gradle is not groovy.')
|
||||
return withAppBuildGradle(config, (config) => {
|
||||
if (config.modResults.language !== "groovy") {
|
||||
throw new Error(
|
||||
"[@expo/config-plugins][withAndroidJscIntl] Cannot enable Intl in Android JSC app gradle because the build.gradle is not groovy."
|
||||
);
|
||||
}
|
||||
return config
|
||||
|
||||
config.modResults.contents = config.modResults.contents.replace(
|
||||
"org.webkit:android-jsc:+",
|
||||
"org.webkit:android-jsc-intl:+"
|
||||
);
|
||||
|
||||
return config;
|
||||
});
|
||||
};
|
||||
|
||||
export default withAndroidJscIntl
|
||||
export default withAndroidJscIntl;
|
||||
@@ -7,13 +7,13 @@ describe(getTemplateFile, () => {
|
||||
it(`returns only base-config when subdomains is '*'`, () => {
|
||||
const content = getTemplateFile("*");
|
||||
expect(content).toMatchSnapshot();
|
||||
expect(content).toMatch(/base\-config/);
|
||||
expect(content).not.toMatch(/domain\-config/);
|
||||
expect(content).toMatch(/base-config/);
|
||||
expect(content).not.toMatch(/domain-config/);
|
||||
});
|
||||
it(`returns domain-config when subdomains is an array`, () => {
|
||||
const content = getTemplateFile(["localhost"]);
|
||||
expect(content).toMatchSnapshot();
|
||||
expect(content).toMatch(/domain\-config/);
|
||||
expect(content).toMatch(/domain-config/);
|
||||
expect(content).toMatch(/localhost/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,7 +8,10 @@ import withDetoxProjectGradle from "./withDetoxProjectGradle";
|
||||
import withDetoxTestAppGradle from "./withDetoxTestAppGradle";
|
||||
import { withDetoxTestClass } from "./withDetoxTestClass";
|
||||
import withKotlinGradle from "./withKotlinGradle";
|
||||
import { withNetworkSecurityConfigManifest, SubdomainsType } from "./withNetworkSecurityConfig";
|
||||
import {
|
||||
withNetworkSecurityConfigManifest,
|
||||
SubdomainsType,
|
||||
} from "./withNetworkSecurityConfig";
|
||||
import withProguardGradle from "./withProguardGradle";
|
||||
|
||||
const withDetox: ConfigPlugin<{
|
||||
|
||||
@@ -28,7 +28,7 @@ const withDetoxTestAppGradle: ConfigPlugin = (config) => {
|
||||
export function setGradleAndroidTestImplementation(
|
||||
buildGradle: string
|
||||
): string {
|
||||
const pattern = /androidTestImplementation\(\'com.wix:detox:\+\'\)/g;
|
||||
const pattern = /androidTestImplementation\('com.wix:detox:\+'\)/g;
|
||||
if (buildGradle.match(pattern)) {
|
||||
return buildGradle;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ConfigPlugin, withDangerousMod } from "@expo/config-plugins";
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
import assert from "assert";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
/**
|
||||
* Copied from the [official template file](https://github.com/wix/Detox/blob/master/examples/demo-react-native/android/app/src/androidTest/java/com/example/DetoxTest.java).
|
||||
|
||||
@@ -4,9 +4,9 @@ import {
|
||||
withAndroidManifest,
|
||||
withDangerousMod,
|
||||
} from "@expo/config-plugins";
|
||||
import * as path from "path";
|
||||
import * as fs from "fs";
|
||||
import assert from "assert";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export type SubdomainsType = string[] | "*";
|
||||
|
||||
@@ -31,7 +31,7 @@ export function getTemplateFile(subdomains: SubdomainsType): string {
|
||||
const content = getTemplateConfigContent(subdomains);
|
||||
/**
|
||||
* May not have new lines or spaces in the beginning.
|
||||
* Otherwise build fails with:
|
||||
* Otherwise build fails with:
|
||||
* "AAPT: error: XML or text declaration not at start of entity"
|
||||
*/
|
||||
return `<?xml version="1.0" encoding="utf-8"?>
|
||||
@@ -69,11 +69,9 @@ const withNetworkSecurityConfigFile: ConfigPlugin<{
|
||||
/**
|
||||
* [Step 6](https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#6-enable-clear-text-unencrypted-traffic-for-detox). Link the `network_security_config.xml` file to the `AndroidManifest.xml`.
|
||||
*/
|
||||
export const withNetworkSecurityConfigManifest: ConfigPlugin<
|
||||
{
|
||||
subdomains: SubdomainsType;
|
||||
} | void
|
||||
> = (config, props) => {
|
||||
export const withNetworkSecurityConfigManifest: ConfigPlugin<{
|
||||
subdomains: SubdomainsType;
|
||||
} | void> = (config, props) => {
|
||||
if (!props || !props.subdomains) {
|
||||
// (*) 10.0.2.2 for Google emulators, 10.0.3.2 for Genymotion emulators.
|
||||
// https://developer.android.com/training/articles/security-config
|
||||
|
||||
@@ -23,7 +23,7 @@ const withProguardGradle: ConfigPlugin = (config) => {
|
||||
};
|
||||
|
||||
export function addDetoxProguardRules(buildGradle: string): string {
|
||||
const pattern = /detox\/proguard\-rules\-app\.pro/g;
|
||||
const pattern = /detox\/proguard-rules-app\.pro/g;
|
||||
if (buildGradle.match(pattern)) {
|
||||
return buildGradle;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/ffmpeg-kit-react-native [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/ffmpeg-kit-react-native [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withAndroidFFMPEGPackage: ConfigPlugin<string | undefined>;
|
||||
export declare function addPackageName(src: string, packageName?: string): string;
|
||||
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addPackageName = exports.withAndroidFFMPEGPackage = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
const withAndroidFFMPEGPackage = (config, packageName) => {
|
||||
return config_plugins_1.withProjectBuildGradle(config, (config) => {
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = addPackageName(config.modResults.contents, packageName);
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot add camera maven gradle because the build.gradle is not groovy");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withAndroidFFMPEGPackage = withAndroidFFMPEGPackage;
|
||||
function addPackageName(src, packageName) {
|
||||
const tag = "ffmpeg-kit-react-native-package";
|
||||
const gradleMaven = packageName
|
||||
? `ext { ffmpegKitPackage = "${packageName}" }`
|
||||
: "";
|
||||
return appendContents({
|
||||
tag,
|
||||
src,
|
||||
newSrc: gradleMaven,
|
||||
comment: "//",
|
||||
}).contents;
|
||||
}
|
||||
exports.addPackageName = addPackageName;
|
||||
// Fork of config-plugins mergeContents, but appends the contents to the end of the file.
|
||||
function appendContents({ src, newSrc, tag, comment, }) {
|
||||
const header = generateCode_1.createGeneratedHeaderComment(newSrc, tag, comment);
|
||||
if (!src.includes(header)) {
|
||||
// Ensure the old generated contents are removed.
|
||||
let sanitizedTarget = generateCode_1.removeGeneratedContents(src, tag);
|
||||
if (sanitizedTarget)
|
||||
sanitizedTarget += "\n";
|
||||
const contentsToAdd = [
|
||||
// @something
|
||||
header,
|
||||
// contents
|
||||
newSrc,
|
||||
// @end
|
||||
`${comment} @generated end ${tag}`,
|
||||
].join("\n");
|
||||
return {
|
||||
contents: (sanitizedTarget !== null && sanitizedTarget !== void 0 ? sanitizedTarget : src) + contentsToAdd,
|
||||
didMerge: true,
|
||||
didClear: !!sanitizedTarget,
|
||||
};
|
||||
}
|
||||
return { contents: src, didClear: false, didMerge: false };
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withPodfilePropertiesPackage: ConfigPlugin<string>;
|
||||
/** Dangerously adds the custom import to the CocoaPods. */
|
||||
export declare const withCocoaPodsImport: ConfigPlugin;
|
||||
export declare function addCocoaPodsImport(src: string): string;
|
||||
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addCocoaPodsImport = exports.withCocoaPodsImport = exports.withPodfilePropertiesPackage = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const ios_plugins_1 = require("@expo/config-plugins/build/plugins/ios-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
const fs_1 = require("fs");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const withPodfilePropertiesPackage = (config, packageName) => {
|
||||
return ios_plugins_1.withPodfileProperties(config, (config) => {
|
||||
// @ts-ignore: wrong type
|
||||
config.modResults["ffmpeg-kit-react-native.subspecs"] = [
|
||||
packageName,
|
||||
].filter(Boolean);
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withPodfilePropertiesPackage = withPodfilePropertiesPackage;
|
||||
/** Dangerously adds the custom import to the CocoaPods. */
|
||||
const withCocoaPodsImport = (c) => {
|
||||
return config_plugins_1.withDangerousMod(c, [
|
||||
"ios",
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
async (config) => {
|
||||
const file = path_1.default.join(config.modRequest.platformProjectRoot, "Podfile");
|
||||
const contents = await fs_1.promises.readFile(file, "utf8");
|
||||
await fs_1.promises.writeFile(file, addCocoaPodsImport(contents), "utf-8");
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
};
|
||||
exports.withCocoaPodsImport = withCocoaPodsImport;
|
||||
function addCocoaPodsImport(src) {
|
||||
return generateCode_1.mergeContents({
|
||||
tag: `ffmpeg-kit-react-native-import`,
|
||||
src,
|
||||
newSrc: ` pod 'ffmpeg-kit-react-native', :subspecs => podfile_properties['ffmpeg-kit-react-native.subspecs'] || [], :podspec => File.join(File.dirname(\`node --print "require.resolve('ffmpeg-kit-react-native/package.json')"\`), "ffmpeg-kit-react-native.podspec")`,
|
||||
anchor: /use_native_modules/,
|
||||
// We can't go after the use_native_modules block because it might have parameters, causing it to be multi-line (see react-native template).
|
||||
offset: 0,
|
||||
comment: "#",
|
||||
}).contents;
|
||||
}
|
||||
exports.addCocoaPodsImport = addCocoaPodsImport;
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
declare type Package = "min" | "min-gpl" | "https" | "https-gpl" | "audio" | "video" | "full" | "full-gpl";
|
||||
export declare type Props = {
|
||||
package?: Package;
|
||||
ios?: {
|
||||
package?: Package;
|
||||
};
|
||||
android?: {
|
||||
package?: Package;
|
||||
};
|
||||
};
|
||||
export {};
|
||||
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withAndroidFFMPEGPackage_1 = require("./withAndroidFFMPEGPackage");
|
||||
const withCocoaPodsImport_1 = require("./withCocoaPodsImport");
|
||||
const withIosDeploymentTarget_1 = require("./withIosDeploymentTarget");
|
||||
let pkg = {
|
||||
name: "ffmpeg-kit-react-native",
|
||||
};
|
||||
try {
|
||||
pkg = require("ffmpeg-kit-react-native/package.json");
|
||||
}
|
||||
catch (_a) {
|
||||
// empty catch block
|
||||
}
|
||||
const withFFMPEG = (config, _props) => {
|
||||
var _a, _b;
|
||||
const props = _props || {};
|
||||
const iosPackage = ((_a = props.ios) === null || _a === void 0 ? void 0 : _a.package) || props.package;
|
||||
const androidPackage = ((_b = props.android) === null || _b === void 0 ? void 0 : _b.package) || props.package;
|
||||
return config_plugins_1.withPlugins(config, [
|
||||
// iOS
|
||||
[withCocoaPodsImport_1.withPodfilePropertiesPackage, iosPackage],
|
||||
[
|
||||
withIosDeploymentTarget_1.withIosDeploymentTarget,
|
||||
// https://github.com/tanersener/ffmpeg-kit/tree/main/react-native#211-package-names
|
||||
{ deploymentTarget: "12.1" },
|
||||
],
|
||||
withCocoaPodsImport_1.withCocoaPodsImport,
|
||||
// Android
|
||||
// Set min SDK Version to 24.
|
||||
[
|
||||
config_plugins_1.AndroidConfig.Version.withBuildScriptExtMinimumVersion,
|
||||
{
|
||||
name: "minSdkVersion",
|
||||
minVersion: 24,
|
||||
},
|
||||
],
|
||||
[withAndroidFFMPEGPackage_1.withAndroidFFMPEGPackage, androidPackage],
|
||||
]);
|
||||
};
|
||||
module.exports = config_plugins_1.createRunOncePlugin(withFFMPEG, pkg.name, pkg.version);
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { ConfigPlugin, XcodeProject } from "@expo/config-plugins";
|
||||
declare type IosDeploymentTargetConfigPlugin = ConfigPlugin<{
|
||||
deploymentTarget: string;
|
||||
}>;
|
||||
export declare const withIosDeploymentTarget: IosDeploymentTargetConfigPlugin;
|
||||
export declare function updateDeploymentTargetPodfile(contents: string, deploymentTarget: string): string;
|
||||
export declare function updateDeploymentTargetXcodeProject(project: XcodeProject, deploymentTarget: string): XcodeProject;
|
||||
export {};
|
||||
@@ -0,0 +1,61 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.updateDeploymentTargetXcodeProject = exports.updateDeploymentTargetPodfile = exports.withIosDeploymentTarget = void 0;
|
||||
// Copied from https://github.com/expo/expo-cli/blob/main/packages/install-expo-modules/src/plugins/ios/withIosDeploymentTarget.ts
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const semver_1 = __importDefault(require("semver"));
|
||||
const withIosDeploymentTarget = (config, props) => {
|
||||
config = withIosDeploymentTargetPodfile(config, props);
|
||||
config = withIosDeploymentTargetXcodeProject(config, props);
|
||||
return config;
|
||||
};
|
||||
exports.withIosDeploymentTarget = withIosDeploymentTarget;
|
||||
const withIosDeploymentTargetPodfile = (config, props) => {
|
||||
return config_plugins_1.withDangerousMod(config, [
|
||||
"ios",
|
||||
async (config) => {
|
||||
const podfile = path_1.default.join(config.modRequest.platformProjectRoot, "Podfile");
|
||||
let contents = await fs_1.default.promises.readFile(podfile, "utf8");
|
||||
contents = updateDeploymentTargetPodfile(contents, props.deploymentTarget);
|
||||
await fs_1.default.promises.writeFile(podfile, contents);
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
};
|
||||
function updateDeploymentTargetPodfile(contents, deploymentTarget) {
|
||||
return contents.replace(/^(\s*platform :ios, ['"])([\d.]+)(['"])/gm, (match, prefix, version, suffix) => {
|
||||
if (semver_1.default.lt(toSemVer(version), toSemVer(deploymentTarget))) {
|
||||
return `${prefix}${deploymentTarget}${suffix}`;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
}
|
||||
exports.updateDeploymentTargetPodfile = updateDeploymentTargetPodfile;
|
||||
const withIosDeploymentTargetXcodeProject = (config, props) => {
|
||||
return config_plugins_1.withXcodeProject(config, (config) => {
|
||||
config.modResults = updateDeploymentTargetXcodeProject(config.modResults, props.deploymentTarget);
|
||||
return config;
|
||||
});
|
||||
};
|
||||
function updateDeploymentTargetXcodeProject(project, deploymentTarget) {
|
||||
const configurations = project.pbxXCBuildConfigurationSection();
|
||||
// @ts-ignore
|
||||
for (const { buildSettings } of Object.values(configurations !== null && configurations !== void 0 ? configurations : {})) {
|
||||
const currDeploymentTarget = buildSettings === null || buildSettings === void 0 ? void 0 : buildSettings.IPHONEOS_DEPLOYMENT_TARGET;
|
||||
if (currDeploymentTarget &&
|
||||
semver_1.default.lt(toSemVer(currDeploymentTarget), toSemVer(deploymentTarget))) {
|
||||
buildSettings.IPHONEOS_DEPLOYMENT_TARGET = deploymentTarget;
|
||||
}
|
||||
}
|
||||
return project;
|
||||
}
|
||||
exports.updateDeploymentTargetXcodeProject = updateDeploymentTargetXcodeProject;
|
||||
function toSemVer(version) {
|
||||
var _a;
|
||||
return (_a = semver_1.default.coerce(version)) !== null && _a !== void 0 ? _a : new semver_1.default.SemVer("0.0.0");
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/ffmpeg-kit-react-native",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure FFMPEG on prebuild",
|
||||
"main": "build/withFFMPEG.js",
|
||||
"types": "build/withFFMPEG.d.ts",
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/ios-stickers [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* **ios-stickers:** lint fix ([331ecb1](https://github.com/expo/config-plugins/commit/331ecb163f000578bc519ebe94f90d62374095d1))
|
||||
|
||||
### @config-plugins/ios-stickers [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -4,12 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.normalizeStickersProps = void 0;
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const schema_utils_1 = require("schema-utils");
|
||||
const options_json_1 = __importDefault(require("./options.json"));
|
||||
const withStickerAssets_1 = require("./withStickerAssets");
|
||||
const withStickerInfoPlist_1 = require("./withStickerInfoPlist");
|
||||
const withStickerXcodeTarget_1 = require("./withStickerXcodeTarget");
|
||||
const path_1 = __importDefault(require("path"));
|
||||
// TODO: Maybe the name is better to use as a prop...
|
||||
const sizeColumnMap = {
|
||||
4: "small",
|
||||
|
||||
+3
-3
@@ -70,9 +70,9 @@ const pbxTargetDependency = "PBXTargetDependency";
|
||||
const pbxContainerItemProxy = "PBXContainerItemProxy";
|
||||
function addStickersTarget(proj, name, bundleId, subfolder) {
|
||||
// Setup uuid and name of new target
|
||||
let targetUuid = proj.generateUuid();
|
||||
let targetType = "app_extension_messages_sticker_pack";
|
||||
let targetName = name.trim();
|
||||
const targetUuid = proj.generateUuid();
|
||||
const targetType = "app_extension_messages_sticker_pack";
|
||||
const targetName = name.trim();
|
||||
const bundleName = subfolder.trim().split(" ").join("-");
|
||||
// Check type against list of allowed target types
|
||||
if (!targetName) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/ios-stickers",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure iOS iMessage stickers",
|
||||
"main": "build/withStickerPack.js",
|
||||
"types": "build/withStickerPack.d.ts",
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
import path from "path";
|
||||
import { validate } from "schema-utils";
|
||||
|
||||
import schema from "./options.json";
|
||||
import { Props, Sticker, withStickerAssets } from "./withStickerAssets";
|
||||
import { withStickersPlist } from "./withStickerInfoPlist";
|
||||
import { withStickerXcodeTarget } from "./withStickerXcodeTarget";
|
||||
import path from "path";
|
||||
|
||||
// TODO: Maybe the name is better to use as a prop...
|
||||
const sizeColumnMap: Record<number, string> = {
|
||||
|
||||
@@ -91,9 +91,9 @@ export function addStickersTarget(
|
||||
subfolder: string
|
||||
) {
|
||||
// Setup uuid and name of new target
|
||||
let targetUuid = proj.generateUuid();
|
||||
let targetType = "app_extension_messages_sticker_pack";
|
||||
let targetName = name.trim();
|
||||
const targetUuid = proj.generateUuid();
|
||||
const targetType = "app_extension_messages_sticker_pack";
|
||||
const targetName = name.trim();
|
||||
const bundleName = subfolder.trim().split(" ").join("-");
|
||||
|
||||
// Check type against list of allowed target types
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
### @config-plugins/react-native-adjust [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-23)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* upgrade google play-services-analytics to v18.0.1 ([a24ea1d](https://github.com/expo/config-plugins/commit/a24ea1df58e9d0639dc4fa016aae8a4e15d53529))
|
||||
|
||||
### @config-plugins/react-native-adjust [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-adjust [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-adjust",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure Adjust SDK on prebuild",
|
||||
"main": "build/withReactNativeAdjust.js",
|
||||
"types": "build/withReactNativeAdjust.d.ts",
|
||||
|
||||
@@ -34,7 +34,7 @@ const addAndroidPackagingOptions = (src: string) => {
|
||||
tag: "react-native-play-services-analytics",
|
||||
src,
|
||||
newSrc: `
|
||||
implementation 'com.google.android.gms:play-services-analytics:18.0.0'
|
||||
implementation 'com.google.android.gms:play-services-analytics:18.0.1'
|
||||
implementation 'com.android.installreferrer:installreferrer:2.2'
|
||||
`,
|
||||
anchor: /dependencies(?:\s+)?\{/,
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
### @config-plugins/react-native-ble-plx [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-05-09)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* **react-native-ble-plx:** lint fix ([a99c60e](https://github.com/expo/config-plugins/commit/a99c60efd5fe53d369551c9a1323701ab14e935b))
|
||||
|
||||
### @config-plugins/react-native-ble-plx [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-ble-plx [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
import { BackgroundMode } from "./withBLEBackgroundModes";
|
||||
export { BackgroundMode };
|
||||
declare const _default: ConfigPlugin<void | {
|
||||
isBackgroundEnabled?: boolean | undefined;
|
||||
modes?: BackgroundMode[] | undefined;
|
||||
bluetoothAlwaysPermission?: string | false | undefined;
|
||||
bluetoothPeripheralPermission?: string | false | undefined;
|
||||
}>;
|
||||
export default _default;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.BackgroundMode = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withBLEAndroidManifest_1 = require("./withBLEAndroidManifest");
|
||||
const withBLEBackgroundModes_1 = require("./withBLEBackgroundModes");
|
||||
Object.defineProperty(exports, "BackgroundMode", { enumerable: true, get: function () { return withBLEBackgroundModes_1.BackgroundMode; } });
|
||||
const withBluetoothPermissions_1 = require("./withBluetoothPermissions");
|
||||
const pkg = { name: "react-native-ble-plx", version: "UNVERSIONED" }; //require('react-native-ble-plx/package.json')
|
||||
/**
|
||||
* Apply BLE configuration for Expo SDK 42 projects.
|
||||
*/
|
||||
const withBLE = (config, props = {}) => {
|
||||
var _a;
|
||||
const _props = props || {};
|
||||
const isBackgroundEnabled = (_a = _props.isBackgroundEnabled) !== null && _a !== void 0 ? _a : false;
|
||||
// iOS
|
||||
config = withBluetoothPermissions_1.withBluetoothPermissions(config, _props);
|
||||
config = withBLEBackgroundModes_1.withBLEBackgroundModes(config, _props.modes || []);
|
||||
// Android
|
||||
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
||||
"android.permission.BLUETOOTH",
|
||||
"android.permission.BLUETOOTH_ADMIN",
|
||||
]);
|
||||
config = withBLEAndroidManifest_1.withBLEAndroidManifest(config, { isBackgroundEnabled });
|
||||
return config;
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withBLE, pkg.name, pkg.version);
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { ConfigPlugin, AndroidConfig } from "@expo/config-plugins";
|
||||
declare type InnerManifest = AndroidConfig.Manifest.AndroidManifest["manifest"];
|
||||
declare type ManifestPermission = InnerManifest["permission"];
|
||||
declare type AndroidManifest = {
|
||||
manifest: InnerManifest & {
|
||||
permission?: ManifestPermission;
|
||||
"uses-permission"?: InnerManifest["uses-permission"];
|
||||
"uses-permission-sdk-23"?: InnerManifest["uses-permission"];
|
||||
"uses-feature"?: InnerManifest["uses-feature"];
|
||||
};
|
||||
};
|
||||
export declare const withBLEAndroidManifest: ConfigPlugin<{
|
||||
isBackgroundEnabled: boolean;
|
||||
}>;
|
||||
export declare function addFineControlPermissionToManifest(androidManifest: AndroidManifest): AndroidManifest;
|
||||
export declare function addBLEHardwareFeatureToManifest(androidManifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
||||
export {};
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addBLEHardwareFeatureToManifest = exports.addFineControlPermissionToManifest = exports.withBLEAndroidManifest = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withBLEAndroidManifest = (config, { isBackgroundEnabled }) => {
|
||||
return config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
config.modResults = addFineControlPermissionToManifest(config.modResults);
|
||||
if (isBackgroundEnabled) {
|
||||
config.modResults = addBLEHardwareFeatureToManifest(config.modResults);
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withBLEAndroidManifest = withBLEAndroidManifest;
|
||||
function addFineControlPermissionToManifest(androidManifest) {
|
||||
var _a;
|
||||
// Add `<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION"/>` to the AndroidManifest.xml
|
||||
if (!Array.isArray(androidManifest.manifest["uses-permission-sdk-23"])) {
|
||||
androidManifest.manifest["uses-permission-sdk-23"] = [];
|
||||
}
|
||||
if (!androidManifest.manifest["uses-permission-sdk-23"].find((item) => item.$["android:name"] === "android.permission.ACCESS_FINE_LOCATION")) {
|
||||
(_a = androidManifest.manifest["uses-permission-sdk-23"]) === null || _a === void 0 ? void 0 : _a.push({
|
||||
$: {
|
||||
"android:name": "android.permission.ACCESS_FINE_LOCATION",
|
||||
},
|
||||
});
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.addFineControlPermissionToManifest = addFineControlPermissionToManifest;
|
||||
// Add this line if your application always requires BLE. More info can be found on: https://developer.android.com/guide/topics/connectivity/bluetooth-le.html#permissions
|
||||
function addBLEHardwareFeatureToManifest(androidManifest) {
|
||||
var _a;
|
||||
// Add `<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>` to the AndroidManifest.xml
|
||||
if (!Array.isArray(androidManifest.manifest["uses-feature"])) {
|
||||
androidManifest.manifest["uses-feature"] = [];
|
||||
}
|
||||
if (!androidManifest.manifest["uses-feature"].find((item) => item.$["android:name"] === "android.hardware.bluetooth_le")) {
|
||||
(_a = androidManifest.manifest["uses-feature"]) === null || _a === void 0 ? void 0 : _a.push({
|
||||
$: {
|
||||
"android:name": "android.hardware.bluetooth_le",
|
||||
"android:required": "true",
|
||||
},
|
||||
});
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.addBLEHardwareFeatureToManifest = addBLEHardwareFeatureToManifest;
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare enum BackgroundMode {
|
||||
Central = "central",
|
||||
Peripheral = "peripheral"
|
||||
}
|
||||
/**
|
||||
* Append `UIBackgroundModes` to the `Info.plist`.
|
||||
*/
|
||||
export declare const withBLEBackgroundModes: ConfigPlugin<BackgroundMode[]>;
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBLEBackgroundModes = exports.BackgroundMode = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
var BackgroundMode;
|
||||
(function (BackgroundMode) {
|
||||
BackgroundMode["Central"] = "central";
|
||||
BackgroundMode["Peripheral"] = "peripheral";
|
||||
})(BackgroundMode = exports.BackgroundMode || (exports.BackgroundMode = {}));
|
||||
function ensureKey(arr, key) {
|
||||
if (!arr.find((mode) => mode === key)) {
|
||||
arr.push(key);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
const centralKey = "bluetooth-central";
|
||||
const peripheralKey = "bluetooth-peripheral";
|
||||
/**
|
||||
* Append `UIBackgroundModes` to the `Info.plist`.
|
||||
*/
|
||||
const withBLEBackgroundModes = (c, modes) => {
|
||||
return config_plugins_1.withInfoPlist(c, (config) => {
|
||||
if (!Array.isArray(config.modResults.UIBackgroundModes)) {
|
||||
config.modResults.UIBackgroundModes = [];
|
||||
}
|
||||
if (modes.includes(BackgroundMode.Central)) {
|
||||
config.modResults.UIBackgroundModes = ensureKey(config.modResults.UIBackgroundModes, centralKey);
|
||||
}
|
||||
if (modes.includes(BackgroundMode.Peripheral)) {
|
||||
config.modResults.UIBackgroundModes = ensureKey(config.modResults.UIBackgroundModes, peripheralKey);
|
||||
}
|
||||
// Prevent empty array
|
||||
if (!config.modResults.UIBackgroundModes.length) {
|
||||
delete config.modResults.UIBackgroundModes;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withBLEBackgroundModes = withBLEBackgroundModes;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withBluetoothPermissions: ConfigPlugin<{
|
||||
bluetoothAlwaysPermission?: string | false;
|
||||
bluetoothPeripheralPermission?: string | false;
|
||||
}>;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBluetoothPermissions = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const BLUETOOTH_ALWAYS = "Allow $(PRODUCT_NAME) to connect to bluetooth devices";
|
||||
const BLUETOOTH_PERIPHERAL_USAGE = "Allow $(PRODUCT_NAME) to connect to bluetooth devices";
|
||||
const withBluetoothPermissions = (c, { bluetoothAlwaysPermission, bluetoothPeripheralPermission } = {}) => {
|
||||
return config_plugins_1.withInfoPlist(c, (config) => {
|
||||
if (bluetoothAlwaysPermission !== false) {
|
||||
config.modResults.NSBluetoothAlwaysUsageDescription =
|
||||
bluetoothAlwaysPermission ||
|
||||
config.modResults.NSBluetoothAlwaysUsageDescription ||
|
||||
BLUETOOTH_ALWAYS;
|
||||
}
|
||||
if (bluetoothPeripheralPermission !== false) {
|
||||
config.modResults.NSBluetoothPeripheralUsageDescription =
|
||||
bluetoothPeripheralPermission ||
|
||||
config.modResults.NSBluetoothPeripheralUsageDescription ||
|
||||
BLUETOOTH_PERIPHERAL_USAGE;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withBluetoothPermissions = withBluetoothPermissions;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-ble-plx",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure react-native-ble-plx on prebuild",
|
||||
"main": "build/withBLE.js",
|
||||
"types": "build/withBLE.d.ts",
|
||||
|
||||
@@ -1,42 +1,44 @@
|
||||
import { AndroidConfig, XML } from '@expo/config-plugins'
|
||||
import { AndroidConfig, XML } from "@expo/config-plugins";
|
||||
import { resolve } from "path";
|
||||
|
||||
import { resolve } from 'path'
|
||||
import {
|
||||
addBLEHardwareFeatureToManifest,
|
||||
addFineControlPermissionToManifest,
|
||||
} from "../withBLEAndroidManifest";
|
||||
|
||||
import { addBLEHardwareFeatureToManifest, addFineControlPermissionToManifest } from '../withBLEAndroidManifest'
|
||||
const { readAndroidManifestAsync } = AndroidConfig.Manifest;
|
||||
|
||||
const { readAndroidManifestAsync } = AndroidConfig.Manifest
|
||||
const sampleManifestPath = resolve(__dirname, "fixtures/AndroidManifest.xml");
|
||||
|
||||
const sampleManifestPath = resolve(__dirname, 'fixtures/AndroidManifest.xml')
|
||||
|
||||
describe('addFineControlPermissionToManifest', () => {
|
||||
describe("addFineControlPermissionToManifest", () => {
|
||||
it(`adds element`, async () => {
|
||||
let androidManifest = await readAndroidManifestAsync(sampleManifestPath)
|
||||
androidManifest = await addFineControlPermissionToManifest(androidManifest)
|
||||
expect(androidManifest.manifest['uses-permission-sdk-23']).toStrictEqual([
|
||||
{ $: { 'android:name': 'android.permission.ACCESS_FINE_LOCATION' } }
|
||||
])
|
||||
let androidManifest = await readAndroidManifestAsync(sampleManifestPath);
|
||||
androidManifest = await addFineControlPermissionToManifest(androidManifest);
|
||||
expect(androidManifest.manifest["uses-permission-sdk-23"]).toStrictEqual([
|
||||
{ $: { "android:name": "android.permission.ACCESS_FINE_LOCATION" } },
|
||||
]);
|
||||
// Sanity
|
||||
expect(XML.format(androidManifest)).toMatch(
|
||||
/<uses-permission-sdk-23 android:name="android\.permission\.ACCESS_FINE_LOCATION"\/>/
|
||||
)
|
||||
})
|
||||
})
|
||||
describe('addBLEHardwareFeatureToManifest', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
describe("addBLEHardwareFeatureToManifest", () => {
|
||||
it(`adds element`, async () => {
|
||||
let androidManifest = await readAndroidManifestAsync(sampleManifestPath)
|
||||
androidManifest = await addBLEHardwareFeatureToManifest(androidManifest)
|
||||
let androidManifest = await readAndroidManifestAsync(sampleManifestPath);
|
||||
androidManifest = await addBLEHardwareFeatureToManifest(androidManifest);
|
||||
|
||||
expect(androidManifest.manifest['uses-feature']).toStrictEqual([
|
||||
expect(androidManifest.manifest["uses-feature"]).toStrictEqual([
|
||||
{
|
||||
$: {
|
||||
'android:name': 'android.hardware.bluetooth_le',
|
||||
'android:required': 'true'
|
||||
}
|
||||
}
|
||||
])
|
||||
"android:name": "android.hardware.bluetooth_le",
|
||||
"android:required": "true",
|
||||
},
|
||||
},
|
||||
]);
|
||||
// Sanity
|
||||
expect(XML.format(androidManifest)).toMatch(
|
||||
/<uses-feature android:name="android\.hardware\.bluetooth_le" android:required="true"\/>/
|
||||
)
|
||||
})
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,5 +1,3 @@
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
|
||||
import {
|
||||
AndroidConfig,
|
||||
ConfigPlugin,
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
|
||||
import {
|
||||
ConfigPlugin,
|
||||
withAndroidManifest,
|
||||
AndroidConfig,
|
||||
} from "@expo/config-plugins";
|
||||
|
||||
type InnerManifest = AndroidConfig.Manifest.AndroidManifest['manifest'];
|
||||
type InnerManifest = AndroidConfig.Manifest.AndroidManifest["manifest"];
|
||||
|
||||
type ManifestPermission = InnerManifest["permission"];
|
||||
|
||||
|
||||
@@ -1,42 +1,50 @@
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
import { ConfigPlugin, withInfoPlist } from '@expo/config-plugins'
|
||||
import { ConfigPlugin, withInfoPlist } from "@expo/config-plugins";
|
||||
|
||||
export enum BackgroundMode {
|
||||
Central = 'central',
|
||||
Peripheral = 'peripheral'
|
||||
Central = "central",
|
||||
Peripheral = "peripheral",
|
||||
}
|
||||
|
||||
function ensureKey(arr: string[], key: string) {
|
||||
if (!arr.find(mode => mode === key)) {
|
||||
arr.push(key)
|
||||
if (!arr.find((mode) => mode === key)) {
|
||||
arr.push(key);
|
||||
}
|
||||
return arr
|
||||
return arr;
|
||||
}
|
||||
|
||||
const centralKey = 'bluetooth-central'
|
||||
const peripheralKey = 'bluetooth-peripheral'
|
||||
const centralKey = "bluetooth-central";
|
||||
const peripheralKey = "bluetooth-peripheral";
|
||||
|
||||
/**
|
||||
* Append `UIBackgroundModes` to the `Info.plist`.
|
||||
*/
|
||||
export const withBLEBackgroundModes: ConfigPlugin<BackgroundMode[]> = (c, modes) => {
|
||||
return withInfoPlist(c, config => {
|
||||
export const withBLEBackgroundModes: ConfigPlugin<BackgroundMode[]> = (
|
||||
c,
|
||||
modes
|
||||
) => {
|
||||
return withInfoPlist(c, (config) => {
|
||||
if (!Array.isArray(config.modResults.UIBackgroundModes)) {
|
||||
config.modResults.UIBackgroundModes = []
|
||||
config.modResults.UIBackgroundModes = [];
|
||||
}
|
||||
|
||||
if (modes.includes(BackgroundMode.Central)) {
|
||||
config.modResults.UIBackgroundModes = ensureKey(config.modResults.UIBackgroundModes, centralKey)
|
||||
config.modResults.UIBackgroundModes = ensureKey(
|
||||
config.modResults.UIBackgroundModes,
|
||||
centralKey
|
||||
);
|
||||
}
|
||||
if (modes.includes(BackgroundMode.Peripheral)) {
|
||||
config.modResults.UIBackgroundModes = ensureKey(config.modResults.UIBackgroundModes, peripheralKey)
|
||||
config.modResults.UIBackgroundModes = ensureKey(
|
||||
config.modResults.UIBackgroundModes,
|
||||
peripheralKey
|
||||
);
|
||||
}
|
||||
|
||||
// Prevent empty array
|
||||
if (!config.modResults.UIBackgroundModes.length) {
|
||||
delete config.modResults.UIBackgroundModes
|
||||
delete config.modResults.UIBackgroundModes;
|
||||
}
|
||||
|
||||
return config
|
||||
})
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable flowtype/no-types-missing-file-annotation */
|
||||
import { ConfigPlugin, withInfoPlist } from "@expo/config-plugins";
|
||||
|
||||
const BLUETOOTH_ALWAYS =
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-blob-util [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-blob-util [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import { AndroidConfig, ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare function appendDownloadCompleteAction(androidManifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
||||
declare const _default: ConfigPlugin<void>;
|
||||
export default _default;
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.appendDownloadCompleteAction = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
let pkg = {
|
||||
name: "react-native-blob-util",
|
||||
};
|
||||
try {
|
||||
pkg = require("react-native-blob-util/package.json");
|
||||
}
|
||||
catch (_a) {
|
||||
// empty catch block
|
||||
}
|
||||
function appendDownloadCompleteAction(androidManifest) {
|
||||
var _a, _b;
|
||||
if (!Array.isArray(androidManifest.manifest.application)) {
|
||||
return androidManifest;
|
||||
}
|
||||
for (const application of androidManifest.manifest.application) {
|
||||
for (const activity of application.activity || []) {
|
||||
if (((_a = activity === null || activity === void 0 ? void 0 : activity.$) === null || _a === void 0 ? void 0 : _a["android:launchMode"]) === "singleTask") {
|
||||
for (const intentFilter of activity["intent-filter"] || []) {
|
||||
const isLauncher = (_b = intentFilter.category) === null || _b === void 0 ? void 0 : _b.some((action) => action.$["android:name"] === "android.intent.category.LAUNCHER");
|
||||
if (!isLauncher)
|
||||
continue;
|
||||
intentFilter.action = intentFilter.action || [];
|
||||
const hasDownloadCompleteAction = intentFilter.action.some((action) => action.$["android:name"] ===
|
||||
"android.intent.action.DOWNLOAD_COMPLETE");
|
||||
if (!hasDownloadCompleteAction) {
|
||||
intentFilter.action.push({
|
||||
$: {
|
||||
"android:name": "android.intent.action.DOWNLOAD_COMPLETE",
|
||||
},
|
||||
});
|
||||
return androidManifest;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.appendDownloadCompleteAction = appendDownloadCompleteAction;
|
||||
const withReactNativeBlobUtil = (config) => {
|
||||
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
||||
"android.permission.READ_EXTERNAL_STORAGE",
|
||||
"android.permission.WRITE_EXTERNAL_STORAGE",
|
||||
"android.permission.DOWNLOAD_WITHOUT_NOTIFICATION",
|
||||
// Wifi-only mode.
|
||||
"android.permission.ACCESS_NETWORK_STATE",
|
||||
]);
|
||||
config = config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
config.modResults = appendDownloadCompleteAction(config.modResults);
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withReactNativeBlobUtil, pkg.name, pkg.version);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-blob-util",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure react-native-blob-util on prebuild",
|
||||
"main": "build/withReactNativeBlobUtil.js",
|
||||
"types": "build/withReactNativeBlobUtil.d.ts",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { AndroidConfig, XML } from "@expo/config-plugins";
|
||||
import { XML } from "@expo/config-plugins";
|
||||
|
||||
import { appendDownloadCompleteAction } from "../withReactNativeBlobUtil";
|
||||
|
||||
const fixture = `
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-branch [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-branch [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export declare type ConfigData = {
|
||||
apiKey?: string;
|
||||
iosAppDomain?: string;
|
||||
iosUniversalLinkDomains?: string[];
|
||||
};
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
import type { ConfigPlugin } from "@expo/config-plugins";
|
||||
import type { ConfigData } from "./types";
|
||||
declare const _default: ConfigPlugin<ConfigData>;
|
||||
export default _default;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withBranchAndroid_1 = require("./withBranchAndroid");
|
||||
const withBranchIOS_1 = require("./withBranchIOS");
|
||||
const withBranch = (config, { apiKey, iosAppDomain, iosUniversalLinkDomains } = {}) => {
|
||||
config = withBranchAndroid_1.withBranchAndroid(config, { apiKey });
|
||||
config = withBranchIOS_1.withBranchIOS(config, {
|
||||
apiKey,
|
||||
iosAppDomain,
|
||||
iosUniversalLinkDomains,
|
||||
});
|
||||
return config;
|
||||
};
|
||||
let pkg = {
|
||||
name: "react-native-branch",
|
||||
};
|
||||
try {
|
||||
const branchPkg = require("react-native-branch/package.json");
|
||||
pkg = branchPkg;
|
||||
}
|
||||
catch (_a) { }
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withBranch, pkg.name, pkg.version);
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import { AndroidConfig } from "@expo/config-plugins";
|
||||
import type { ConfigPlugin } from "@expo/config-plugins";
|
||||
import type { ExpoConfig } from "@expo/config-types";
|
||||
export declare function getBranchApiKey(config: ExpoConfig): string | null;
|
||||
export declare function setBranchApiKey(apiKey: string, androidManifest: AndroidConfig.Manifest.AndroidManifest): AndroidConfig.Manifest.AndroidManifest;
|
||||
export declare const withBranchAndroid: ConfigPlugin<{
|
||||
apiKey?: string;
|
||||
}>;
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBranchAndroid = exports.setBranchApiKey = exports.getBranchApiKey = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const { addMetaDataItemToMainApplication, getMainApplicationOrThrow, removeMetaDataItemFromMainApplication, } = config_plugins_1.AndroidConfig.Manifest;
|
||||
const META_BRANCH_KEY = "io.branch.sdk.BranchKey";
|
||||
function getBranchApiKey(config) {
|
||||
var _a, _b, _c, _d;
|
||||
return (_d = (_c = (_b = (_a = config.android) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.branch) === null || _c === void 0 ? void 0 : _c.apiKey) !== null && _d !== void 0 ? _d : null;
|
||||
}
|
||||
exports.getBranchApiKey = getBranchApiKey;
|
||||
function setBranchApiKey(apiKey, androidManifest) {
|
||||
const mainApplication = getMainApplicationOrThrow(androidManifest);
|
||||
if (apiKey) {
|
||||
// If the item exists, add it back
|
||||
addMetaDataItemToMainApplication(mainApplication, META_BRANCH_KEY, apiKey);
|
||||
}
|
||||
else {
|
||||
// Remove any existing item
|
||||
removeMetaDataItemFromMainApplication(mainApplication, META_BRANCH_KEY);
|
||||
}
|
||||
return androidManifest;
|
||||
}
|
||||
exports.setBranchApiKey = setBranchApiKey;
|
||||
const withBranchAndroid = (config, data) => {
|
||||
var _a;
|
||||
const apiKey = (_a = data.apiKey) !== null && _a !== void 0 ? _a : getBranchApiKey(config);
|
||||
if (!apiKey) {
|
||||
throw new Error("Branch API key is required");
|
||||
}
|
||||
config = config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
config.modResults = setBranchApiKey(apiKey, config.modResults);
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.withBranchAndroid = withBranchAndroid;
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
import type { ConfigPlugin, InfoPlist } from "@expo/config-plugins";
|
||||
import type { ExpoConfig } from "@expo/config-types";
|
||||
import type { ConfigData } from "./types";
|
||||
export declare function getBranchApiKey(config: Pick<ExpoConfig, "ios">): string | null;
|
||||
export declare function setBranchApiKey(apiKey: string | null, infoPlist: InfoPlist): InfoPlist;
|
||||
export declare const withBranchIOS: ConfigPlugin<ConfigData>;
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withBranchIOS = exports.setBranchApiKey = exports.getBranchApiKey = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
function getBranchApiKey(config) {
|
||||
var _a, _b, _c, _d;
|
||||
return (_d = (_c = (_b = (_a = config.ios) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.branch) === null || _c === void 0 ? void 0 : _c.apiKey) !== null && _d !== void 0 ? _d : null;
|
||||
}
|
||||
exports.getBranchApiKey = getBranchApiKey;
|
||||
function setBranchApiKey(apiKey, infoPlist) {
|
||||
if (apiKey === null) {
|
||||
return infoPlist;
|
||||
}
|
||||
return {
|
||||
...infoPlist,
|
||||
branch_key: {
|
||||
live: apiKey,
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.setBranchApiKey = setBranchApiKey;
|
||||
const withBranchIOS = (config, data) => {
|
||||
var _a;
|
||||
// Ensure object exist
|
||||
if (!config.ios) {
|
||||
config.ios = {};
|
||||
}
|
||||
const apiKey = (_a = data.apiKey) !== null && _a !== void 0 ? _a : getBranchApiKey(config);
|
||||
if (!apiKey) {
|
||||
throw new Error("Branch API key is required");
|
||||
}
|
||||
// Update the infoPlist with the branch key and branch domain
|
||||
config = config_plugins_1.withInfoPlist(config, (config) => {
|
||||
config.modResults = setBranchApiKey(apiKey, config.modResults);
|
||||
if (data.iosAppDomain) {
|
||||
config.modResults.branch_app_domain = data.iosAppDomain;
|
||||
}
|
||||
else {
|
||||
delete config.modResults.branch_app_domain;
|
||||
}
|
||||
if (data.iosUniversalLinkDomains) {
|
||||
config.modResults.branch_universal_link_domains =
|
||||
data.iosUniversalLinkDomains;
|
||||
}
|
||||
else {
|
||||
delete config.modResults.branch_universal_link_domains;
|
||||
}
|
||||
return config;
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.withBranchIOS = withBranchIOS;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-branch",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Config plugin to auto configure react-native-branch on prebuild",
|
||||
"author": "650 Industries, Inc.",
|
||||
"license": "MIT",
|
||||
@@ -34,7 +34,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/config-plugins": "^4.1.0",
|
||||
"@expo/config-types": "^43.0.1"
|
||||
"@expo/config-types": "^45.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"expo-module-scripts": "^2.0.0"
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.expo.mycoolapp">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<queries>
|
||||
<!-- Support checking for http(s) links via the Linking API -->
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
|
||||
<activity android:name=".MainActivity" android:launchMode="singleTask" android:label="@string/app_name" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:windowSoftInputMode="adjustResize">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -0,0 +1,53 @@
|
||||
import { AndroidConfig } from "@expo/config-plugins";
|
||||
import { resolve } from "path";
|
||||
|
||||
import { getBranchApiKey, setBranchApiKey } from "../withBranchAndroid";
|
||||
|
||||
const { findMetaDataItem, getMainApplication, readAndroidManifestAsync } =
|
||||
AndroidConfig.Manifest;
|
||||
|
||||
const sampleManifestPath = resolve(
|
||||
__dirname,
|
||||
"./fixtures",
|
||||
"react-native-AndroidManifest.xml"
|
||||
);
|
||||
|
||||
describe(getBranchApiKey, () => {
|
||||
it(`returns null if no android branch api key is provided`, () => {
|
||||
expect(getBranchApiKey({ android: { config: {} } } as any)).toBe(null);
|
||||
});
|
||||
|
||||
it(`returns apikey if android branch api key is provided`, () => {
|
||||
expect(
|
||||
getBranchApiKey({
|
||||
android: { config: { branch: { apiKey: "MY-API-KEY" } } },
|
||||
} as any)
|
||||
).toBe("MY-API-KEY");
|
||||
});
|
||||
});
|
||||
|
||||
describe(setBranchApiKey, () => {
|
||||
it("sets branch api key in AndroidManifest.xml if given", async () => {
|
||||
let androidManifestJson = await readAndroidManifestAsync(
|
||||
sampleManifestPath
|
||||
);
|
||||
androidManifestJson = await setBranchApiKey(
|
||||
"MY-API-KEY",
|
||||
androidManifestJson
|
||||
);
|
||||
let mainApplication = getMainApplication(androidManifestJson);
|
||||
|
||||
expect(
|
||||
findMetaDataItem(mainApplication, "io.branch.sdk.BranchKey")
|
||||
).toBeGreaterThan(-1);
|
||||
|
||||
// Unset the item
|
||||
|
||||
androidManifestJson = await setBranchApiKey(null, androidManifestJson);
|
||||
mainApplication = getMainApplication(androidManifestJson);
|
||||
|
||||
expect(findMetaDataItem(mainApplication, "io.branch.sdk.BranchKey")).toBe(
|
||||
-1
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,27 @@
|
||||
import { getBranchApiKey, setBranchApiKey } from "../withBranchIOS";
|
||||
|
||||
describe(getBranchApiKey, () => {
|
||||
it(`returns null if no api key is provided`, () => {
|
||||
expect(getBranchApiKey({})).toBe(null);
|
||||
});
|
||||
|
||||
it(`returns the api key if provided`, () => {
|
||||
expect(
|
||||
getBranchApiKey({ ios: { config: { branch: { apiKey: "123" } } } })
|
||||
).toBe("123");
|
||||
});
|
||||
});
|
||||
|
||||
describe(setBranchApiKey, () => {
|
||||
it(`sets branch_key.live if the api key is given`, () => {
|
||||
expect(setBranchApiKey("123", {})).toMatchObject({
|
||||
branch_key: {
|
||||
live: "123",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it(`makes no changes to the infoPlist no api key is provided`, () => {
|
||||
expect(setBranchApiKey(null, {})).toMatchObject({});
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,9 @@
|
||||
import { createRunOncePlugin } from "@expo/config-plugins";
|
||||
import type { ConfigPlugin } from "@expo/config-plugins";
|
||||
|
||||
import type { ConfigData } from "./types";
|
||||
import { withBranchAndroid } from "./withBranchAndroid";
|
||||
import { withBranchIOS } from "./withBranchIOS";
|
||||
import type { ConfigData } from "./types";
|
||||
|
||||
const withBranch: ConfigPlugin<ConfigData> = (
|
||||
config,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { withInfoPlist } from "@expo/config-plugins";
|
||||
import type { ConfigPlugin, InfoPlist } from "@expo/config-plugins";
|
||||
import type { ExpoConfig } from "@expo/config-types";
|
||||
|
||||
import type { ConfigData } from "./types";
|
||||
|
||||
export function getBranchApiKey(config: Pick<ExpoConfig, "ios">) {
|
||||
@@ -8,7 +9,7 @@ export function getBranchApiKey(config: Pick<ExpoConfig, "ios">) {
|
||||
}
|
||||
|
||||
export function setBranchApiKey(
|
||||
apiKey: string,
|
||||
apiKey: string | null,
|
||||
infoPlist: InfoPlist
|
||||
): InfoPlist {
|
||||
if (apiKey === null) {
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
### @config-plugins/react-native-callkeep [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* **react-native-callkeep:** lint fix ([241d378](https://github.com/expo/config-plugins/commit/241d378a54327340df3663ef8f66cb8663e1e359))
|
||||
|
||||
### @config-plugins/react-native-callkeep [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-callkeep [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { XcodeProject } from "@expo/config-plugins";
|
||||
export declare function ensureHeaderSearchPath(project: XcodeProject, file: string): void;
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ensureHeaderSearchPath = void 0;
|
||||
const COMMENT_KEY = /_comment$/;
|
||||
function unquote(str) {
|
||||
if (str)
|
||||
return str.replace(/^"(.*)"$/, "$1");
|
||||
}
|
||||
function nonComments(obj) {
|
||||
const keys = Object.keys(obj);
|
||||
const newObj = {};
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (!COMMENT_KEY.test(keys[i])) {
|
||||
newObj[keys[i]] = obj[keys[i]];
|
||||
}
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
function ensureHeaderSearchPath(project, file) {
|
||||
const configurations = nonComments(project.pbxXCBuildConfigurationSection());
|
||||
const INHERITED = '"$(inherited)"';
|
||||
for (const config in configurations) {
|
||||
const buildSettings = configurations[config].buildSettings;
|
||||
if (unquote(buildSettings["PRODUCT_NAME"]) !== project.productName)
|
||||
continue;
|
||||
if (!buildSettings["HEADER_SEARCH_PATHS"]) {
|
||||
buildSettings["HEADER_SEARCH_PATHS"] = [INHERITED];
|
||||
}
|
||||
if (!buildSettings.HEADER_SEARCH_PATHS.includes(file)) {
|
||||
buildSettings["HEADER_SEARCH_PATHS"].push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ensureHeaderSearchPath = ensureHeaderSearchPath;
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
declare const withCallkeep: ConfigPlugin;
|
||||
export declare const withXcodeLinkBinaryWithLibraries: ConfigPlugin<{
|
||||
library: string;
|
||||
status?: string;
|
||||
}>;
|
||||
export default withCallkeep;
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withXcodeLinkBinaryWithLibraries = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const ensureHeaderSearchPath_1 = require("./ensureHeaderSearchPath");
|
||||
const withCallkeepHeaderSearchPath = (config) => {
|
||||
const headerSearchPath = `"$(SRCROOT)/../node_modules/react-native-callkeep/ios/RNCallKeep"`;
|
||||
return config_plugins_1.withXcodeProject(config, (config) => {
|
||||
ensureHeaderSearchPath_1.ensureHeaderSearchPath(config.modResults, headerSearchPath);
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withAndroidManifestService = (config) => {
|
||||
return config_plugins_1.withAndroidManifest(config, (config) => {
|
||||
// <service
|
||||
// android:name="io.wazo.callkeep.VoiceConnectionService"
|
||||
// android:label="Wazo"
|
||||
// android:permission="android.permission.BIND_TELECOM_CONNECTION_SERVICE"
|
||||
// // Use this to target android >= 11
|
||||
// android:foregroundServiceType="camera|microphone"
|
||||
// // For android < 11
|
||||
// android:foregroundServiceType="phoneCall"
|
||||
// >
|
||||
// <intent-filter>
|
||||
// <action android:name="android.telecom.ConnectionService" />
|
||||
// </intent-filter>
|
||||
// </service>;
|
||||
const app = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(config.modResults);
|
||||
if (!Array.isArray(app.service))
|
||||
app.service = [];
|
||||
if (!app.service.find((item) => item.$["android:name"] ===
|
||||
"io.wazo.callkeep.RNCallKeepBackgroundMessagingService")) {
|
||||
app.service.push({
|
||||
$: {
|
||||
"android:name": "io.wazo.callkeep.RNCallKeepBackgroundMessagingService",
|
||||
},
|
||||
});
|
||||
}
|
||||
// TODO: Update item
|
||||
if (!app.service.find((item) => item.$["android:name"] === "io.wazo.callkeep.VoiceConnectionService")) {
|
||||
app.service.push({
|
||||
$: {
|
||||
"android:name": "io.wazo.callkeep.VoiceConnectionService",
|
||||
// @ts-ignore
|
||||
"android:label": "Wazo",
|
||||
"android:permission": "android.permission.BIND_TELECOM_CONNECTION_SERVICE",
|
||||
// Use this to target android >= 11
|
||||
// "android:foregroundServiceType": "camera|microphone",
|
||||
// For android < 11
|
||||
"android:foregroundServiceType": "phoneCall",
|
||||
},
|
||||
"intent-filter": [
|
||||
{
|
||||
action: [
|
||||
{
|
||||
$: {
|
||||
"android:name": "android.telecom.ConnectionService",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withCallkeep = (config) => {
|
||||
config = config_plugins_1.withInfoPlist(config, (config) => {
|
||||
if (!Array.isArray(config.modResults.UIBackgroundModes)) {
|
||||
config.modResults.UIBackgroundModes = [];
|
||||
}
|
||||
if (!config.modResults.UIBackgroundModes.includes("voip")) {
|
||||
config.modResults.UIBackgroundModes.push("voip");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
config = withCallkeepHeaderSearchPath(config);
|
||||
config = exports.withXcodeLinkBinaryWithLibraries(config, {
|
||||
library: "Intents.framework",
|
||||
status: "optional",
|
||||
});
|
||||
config = exports.withXcodeLinkBinaryWithLibraries(config, {
|
||||
library: "CallKit.framework",
|
||||
});
|
||||
config = config_plugins_1.AndroidConfig.Permissions.withPermissions(config, [
|
||||
"android.permission.BIND_TELECOM_CONNECTION_SERVICE",
|
||||
"android.permission.FOREGROUND_SERVICE",
|
||||
"android.permission.READ_PHONE_STATE",
|
||||
"android.permission.CALL_PHONE",
|
||||
]);
|
||||
config = withAndroidManifestService(config);
|
||||
return config;
|
||||
};
|
||||
const withXcodeLinkBinaryWithLibraries = (config, { library, status }) => {
|
||||
return config_plugins_1.withXcodeProject(config, (config) => {
|
||||
const options = status === "optional" ? { weak: true } : {};
|
||||
const target = config_plugins_1.IOSConfig.XcodeUtils.getApplicationNativeTarget({
|
||||
project: config.modResults,
|
||||
projectName: config.modRequest.projectName,
|
||||
});
|
||||
config.modResults.addFramework(library, {
|
||||
target: target.uuid,
|
||||
...options,
|
||||
});
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withXcodeLinkBinaryWithLibraries = withXcodeLinkBinaryWithLibraries;
|
||||
exports.default = withCallkeep;
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-callkeep",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure callkeep on prebuild",
|
||||
"main": "build/withCallkeep.js",
|
||||
"types": "build/withCallkeep.d.ts",
|
||||
|
||||
@@ -6,11 +6,10 @@ function unquote(str: string) {
|
||||
if (str) return str.replace(/^"(.*)"$/, "$1");
|
||||
}
|
||||
function nonComments(obj: Record<string, any>) {
|
||||
var keys = Object.keys(obj),
|
||||
newObj: Record<string, any> = {},
|
||||
i = 0;
|
||||
const keys = Object.keys(obj);
|
||||
const newObj: Record<string, any> = {};
|
||||
|
||||
for (i; i < keys.length; i++) {
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
if (!COMMENT_KEY.test(keys[i])) {
|
||||
newObj[keys[i]] = obj[keys[i]];
|
||||
}
|
||||
@@ -26,7 +25,8 @@ export function ensureHeaderSearchPath(project: XcodeProject, file: string) {
|
||||
for (const config in configurations) {
|
||||
const buildSettings = configurations[config].buildSettings;
|
||||
|
||||
if (unquote(buildSettings["PRODUCT_NAME"]) != project.productName) continue;
|
||||
if (unquote(buildSettings["PRODUCT_NAME"]) !== project.productName)
|
||||
continue;
|
||||
|
||||
if (!buildSettings["HEADER_SEARCH_PATHS"]) {
|
||||
buildSettings["HEADER_SEARCH_PATHS"] = [INHERITED];
|
||||
|
||||
@@ -129,8 +129,7 @@ export const withXcodeLinkBinaryWithLibraries: ConfigPlugin<{
|
||||
status?: string;
|
||||
}> = (config, { library, status }) => {
|
||||
return withXcodeProject(config, (config) => {
|
||||
const options =
|
||||
status === "optional" ? { weak: true } : {};
|
||||
const options = status === "optional" ? { weak: true } : {};
|
||||
|
||||
const target = IOSConfig.XcodeUtils.getApplicationNativeTarget({
|
||||
project: config.modResults,
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-dynamic-app-icon [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-dynamic-app-icon [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
declare type IconSet = Record<string, {
|
||||
image: string;
|
||||
prerendered?: boolean;
|
||||
}>;
|
||||
declare const withDynamicIcon: ConfigPlugin<string[] | IconSet | void>;
|
||||
export default withDynamicIcon;
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const image_utils_1 = require("@expo/image-utils");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const folderName = "DynamicAppIcons";
|
||||
const size = 60;
|
||||
const scales = [2, 3];
|
||||
function arrayToImages(images) {
|
||||
return images.reduce((prev, curr, i) => ({ ...prev, [i]: { image: curr } }), {});
|
||||
}
|
||||
const withDynamicIcon = (config, props = {}) => {
|
||||
const _props = props || {};
|
||||
let prepped = {};
|
||||
if (Array.isArray(_props)) {
|
||||
prepped = arrayToImages(_props);
|
||||
}
|
||||
else if (_props) {
|
||||
prepped = _props;
|
||||
}
|
||||
config = withIconXcodeProject(config, { icons: prepped });
|
||||
config = withIconInfoPlist(config, { icons: prepped });
|
||||
config = withIconImages(config, { icons: prepped });
|
||||
return config;
|
||||
};
|
||||
function getIconName(name, size, scale) {
|
||||
const fileName = `${name}-Icon-${size}x${size}`;
|
||||
if (scale != null) {
|
||||
return `${fileName}@${scale}x.png`;
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
// @ts-ignore
|
||||
const pbxFile_1 = __importDefault(require("xcode/lib/pbxFile"));
|
||||
const withIconXcodeProject = (config, { icons }) => {
|
||||
return config_plugins_1.withXcodeProject(config, async (config) => {
|
||||
const groupPath = `${config.modRequest.projectName}/${folderName}`;
|
||||
const group = config_plugins_1.IOSConfig.XcodeUtils.ensureGroupRecursively(config.modResults, groupPath);
|
||||
const project = config.modResults;
|
||||
const opt = {};
|
||||
// Unlink old assets
|
||||
const groupId = Object.keys(project.hash.project.objects["PBXGroup"]).find((id) => {
|
||||
const _group = project.hash.project.objects["PBXGroup"][id];
|
||||
return _group.name === group.name;
|
||||
});
|
||||
if (!project.hash.project.objects["PBXVariantGroup"]) {
|
||||
project.hash.project.objects["PBXVariantGroup"] = {};
|
||||
}
|
||||
const variantGroupId = Object.keys(project.hash.project.objects["PBXVariantGroup"]).find((id) => {
|
||||
const _group = project.hash.project.objects["PBXVariantGroup"][id];
|
||||
return _group.name === group.name;
|
||||
});
|
||||
const children = [...(group.children || [])];
|
||||
for (const child of children) {
|
||||
const file = new pbxFile_1.default(path_1.default.join(group.name, child.comment), opt);
|
||||
file.target = opt ? opt.target : undefined;
|
||||
project.removeFromPbxBuildFileSection(file); // PBXBuildFile
|
||||
project.removeFromPbxFileReferenceSection(file); // PBXFileReference
|
||||
if (group) {
|
||||
if (groupId) {
|
||||
project.removeFromPbxGroup(file, groupId); //Group other than Resources (i.e. 'splash')
|
||||
}
|
||||
else if (variantGroupId) {
|
||||
project.removeFromPbxVariantGroup(file, variantGroupId); // PBXVariantGroup
|
||||
}
|
||||
}
|
||||
project.removeFromPbxResourcesBuildPhase(file); // PBXResourcesBuildPhase
|
||||
}
|
||||
// Link new assets
|
||||
await iterateIconsAsync({ icons }, async (key, icon, index) => {
|
||||
for (const scale of scales) {
|
||||
const iconFileName = getIconName(key, size, scale);
|
||||
if (!(group === null || group === void 0 ? void 0 : group.children.some(({ comment }) => comment === iconFileName))) {
|
||||
// Only write the file if it doesn't already exist.
|
||||
config.modResults = config_plugins_1.IOSConfig.XcodeUtils.addResourceFileToGroup({
|
||||
filepath: path_1.default.join(groupPath, iconFileName),
|
||||
groupName: groupPath,
|
||||
project: config.modResults,
|
||||
isBuildFile: true,
|
||||
verbose: true,
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("Skipping duplicate: ", iconFileName);
|
||||
}
|
||||
}
|
||||
});
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withIconInfoPlist = (config, { icons }) => {
|
||||
return config_plugins_1.withInfoPlist(config, async (config) => {
|
||||
const altIcons = {};
|
||||
await iterateIconsAsync({ icons }, async (key, icon) => {
|
||||
altIcons[key] = {
|
||||
CFBundleIconFiles: [
|
||||
// Must be a file path relative to the source root (not a icon set it seems).
|
||||
// i.e. `Bacon-Icon-60x60` when the image is `ios/somn/appIcons/[email protected]`
|
||||
getIconName(key, size),
|
||||
],
|
||||
UIPrerenderedIcon: !!icon.prerendered,
|
||||
};
|
||||
});
|
||||
function applyToPlist(key) {
|
||||
if (typeof config.modResults[key] !== "object" ||
|
||||
Array.isArray(config.modResults[key]) ||
|
||||
!config.modResults[key]) {
|
||||
config.modResults[key] = {};
|
||||
}
|
||||
// @ts-expect-error
|
||||
config.modResults[key].CFBundleAlternateIcons = altIcons;
|
||||
// @ts-expect-error
|
||||
config.modResults[key].CFBundlePrimaryIcon = {
|
||||
CFBundleIconFiles: ["AppIcon"],
|
||||
};
|
||||
}
|
||||
// Apply for both tablet and phone support
|
||||
applyToPlist("CFBundleIcons");
|
||||
applyToPlist("CFBundleIcons~ipad");
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withIconImages = (config, props) => {
|
||||
return config_plugins_1.withDangerousMod(config, [
|
||||
"ios",
|
||||
async (config) => {
|
||||
await createIconsAsync(config, props);
|
||||
return config;
|
||||
},
|
||||
]);
|
||||
};
|
||||
async function createIconsAsync(config, { icons }) {
|
||||
const iosRoot = path_1.default.join(config.modRequest.platformProjectRoot, config.modRequest.projectName);
|
||||
// Delete all existing assets
|
||||
await fs_1.default.promises
|
||||
.rmdir(path_1.default.join(iosRoot, folderName), { recursive: true })
|
||||
.catch(() => null);
|
||||
// Ensure directory exists
|
||||
await fs_1.default.promises.mkdir(path_1.default.join(iosRoot, folderName), { recursive: true });
|
||||
// Generate new assets
|
||||
await iterateIconsAsync({ icons }, async (key, icon) => {
|
||||
for (const scale of scales) {
|
||||
const iconFileName = getIconName(key, size, scale);
|
||||
const fileName = path_1.default.join(folderName, iconFileName);
|
||||
const outputPath = path_1.default.join(iosRoot, fileName);
|
||||
const scaledSize = scale * size;
|
||||
const { source } = await image_utils_1.generateImageAsync({
|
||||
projectRoot: config.modRequest.projectRoot,
|
||||
cacheType: "react-native-dynamic-app-icon",
|
||||
}, {
|
||||
name: iconFileName,
|
||||
src: icon.image,
|
||||
removeTransparency: true,
|
||||
backgroundColor: "#ffffff",
|
||||
resizeMode: "cover",
|
||||
width: scaledSize,
|
||||
height: scaledSize,
|
||||
});
|
||||
await fs_1.default.promises.writeFile(outputPath, source);
|
||||
}
|
||||
});
|
||||
}
|
||||
async function iterateIconsAsync({ icons }, callback) {
|
||||
const entries = Object.entries(icons);
|
||||
for (let i = 0; i < entries.length; i++) {
|
||||
const [key, val] = entries[i];
|
||||
await callback(key, val, i);
|
||||
}
|
||||
}
|
||||
exports.default = withDynamicIcon;
|
||||
//# sourceMappingURL=index.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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 truncated
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-dynamic-app-icon",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Config plugin to auto configure react-native-dynamic-app-icon",
|
||||
"main": "build/index.js",
|
||||
"types": "build/index.d.ts",
|
||||
|
||||
@@ -9,6 +9,8 @@ import {
|
||||
import { generateImageAsync } from "@expo/image-utils";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
// @ts-ignore
|
||||
import pbxFile from "xcode/lib/pbxFile";
|
||||
|
||||
const folderName = "DynamicAppIcons";
|
||||
const size = 60;
|
||||
@@ -56,9 +58,6 @@ function getIconName(name: string, size: number, scale?: number) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
import pbxFile from "xcode/lib/pbxFile";
|
||||
|
||||
const withIconXcodeProject: ConfigPlugin<Props> = (config, { icons }) => {
|
||||
return withXcodeProject(config, async (config) => {
|
||||
const groupPath = `${config.modRequest.projectName!}/${folderName}`;
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
### @config-plugins/react-native-google-cast [1.0.3](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-23)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* **react-native-google-cast:** lint fix ([21c4928](https://github.com/expo/config-plugins/commit/21c49280d49a3584863d8338e4b34c508249a595))
|
||||
|
||||
### @config-plugins/react-native-google-cast [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-google-cast [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withAndroidGoogleCast: ConfigPlugin<{
|
||||
/**
|
||||
* @default '+'
|
||||
*/
|
||||
androidPlayServicesCastFrameworkVersion?: string;
|
||||
/**
|
||||
* ??
|
||||
*/
|
||||
receiverAppId?: string;
|
||||
}>;
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.withAndroidGoogleCast = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const codeMod_1 = require("@expo/config-plugins/build/android/codeMod");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
const { addMetaDataItemToMainApplication, getMainApplicationOrThrow } = config_plugins_1.AndroidConfig.Manifest;
|
||||
const META_PROVIDER_CLASS = "com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME";
|
||||
const META_RECEIVER_APP_ID = "com.reactnative.googlecast.RECEIVER_APPLICATION_ID";
|
||||
const CUSTOM_ACTIVITY = "com.reactnative.googlecast.RNGCExpandedControllerActivity";
|
||||
async function ensureCustomActivityAsync({ mainApplication, }) {
|
||||
if (Array.isArray(mainApplication.activity)) {
|
||||
// Remove all activities matching the custom name
|
||||
mainApplication.activity = mainApplication.activity.filter((activity) => {
|
||||
var _a;
|
||||
return ((_a = activity.$) === null || _a === void 0 ? void 0 : _a["android:name"]) !== CUSTOM_ACTIVITY;
|
||||
});
|
||||
}
|
||||
else {
|
||||
mainApplication.activity = [];
|
||||
}
|
||||
// `<activity android:name="${CUSTOM_ACTIVITY}" />`
|
||||
mainApplication.activity.push({
|
||||
$: {
|
||||
"android:name": CUSTOM_ACTIVITY,
|
||||
},
|
||||
});
|
||||
return mainApplication;
|
||||
}
|
||||
const withAndroidManifestCast = (config, { receiverAppId } = {}) => {
|
||||
return config_plugins_1.withAndroidManifest(config, async (config) => {
|
||||
const mainApplication = getMainApplicationOrThrow(config.modResults);
|
||||
ensureCustomActivityAsync({ mainApplication });
|
||||
addMetaDataItemToMainApplication(mainApplication, META_PROVIDER_CLASS,
|
||||
// This is the native Java class
|
||||
"com.reactnative.googlecast.GoogleCastOptionsProvider");
|
||||
if (receiverAppId) {
|
||||
addMetaDataItemToMainApplication(mainApplication, META_RECEIVER_APP_ID, receiverAppId);
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withProjectBuildGradleVersion = (config, { version }) => {
|
||||
return config_plugins_1.withProjectBuildGradle(config, (config) => {
|
||||
if (config.modResults.language !== "groovy")
|
||||
throw new Error("react-native-google-cast config plugin does not support Kotlin /build.gradle yet.");
|
||||
config.modResults.contents = addGoogleCastVersionImport(config.modResults.contents, {
|
||||
version,
|
||||
}).contents;
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withAppBuildGradleImport = (config, { version }) => {
|
||||
return config_plugins_1.withAppBuildGradle(config, (config) => {
|
||||
if (config.modResults.language !== "groovy")
|
||||
throw new Error("react-native-google-cast config plugin does not support Kotlin app/build.gradle yet.");
|
||||
config.modResults.contents = addSafeExtGet(config.modResults.contents);
|
||||
config.modResults.contents = addGoogleCastImport(config.modResults.contents, {
|
||||
version,
|
||||
}).contents;
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withMainActivityLazyLoading = (config) => {
|
||||
return config_plugins_1.withMainActivity(config, async (config) => {
|
||||
const src = codeMod_1.addImports(config.modResults.contents, ["com.google.android.gms.cast.framework.CastContext"], config.modResults.language === "java");
|
||||
if (config.modResults.language === "java") {
|
||||
config.modResults.contents = addGoogleCastLazyLoadingImport(src).contents;
|
||||
}
|
||||
else {
|
||||
throw new Error("react-native-google-cast config plugin does not support kotlin MainActivity yet.");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
// castFrameworkVersion
|
||||
const withAndroidGoogleCast = (config, props) => {
|
||||
var _a, _b;
|
||||
config = withAndroidManifestCast(config, {
|
||||
receiverAppId: props.receiverAppId,
|
||||
});
|
||||
config = withMainActivityLazyLoading(config);
|
||||
config = withProjectBuildGradleVersion(config, {
|
||||
// gradle dep version
|
||||
version: (_a = props.androidPlayServicesCastFrameworkVersion) !== null && _a !== void 0 ? _a : "+",
|
||||
});
|
||||
config = withAppBuildGradleImport(config, {
|
||||
// gradle dep version
|
||||
version: (_b = props.androidPlayServicesCastFrameworkVersion) !== null && _b !== void 0 ? _b : "+",
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.withAndroidGoogleCast = withAndroidGoogleCast;
|
||||
function addGoogleCastLazyLoadingImport(src) {
|
||||
const newSrc = [];
|
||||
newSrc.push(" CastContext.getSharedInstance(this);");
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-google-cast-onCreate",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /super\.onCreate\(\w+\);/,
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
// TODO: Add this ability to autolinking
|
||||
// dependencies { implementation "com.google.android.gms:play-services-cast-framework:+" }
|
||||
function addGoogleCastImport(src, { version } = {}) {
|
||||
const newSrc = [];
|
||||
newSrc.push(` implementation "com.google.android.gms:play-services-cast-framework:\${safeExtGet('castFrameworkVersion', '${version}')}"`);
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-google-cast-dependencies",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /dependencies(?:\s+)?\{/,
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
function addSafeExtGet(src) {
|
||||
const tag = "safeExtGet";
|
||||
src = generateCode_1.removeContents({ src, tag }).contents;
|
||||
// If the source already has a safeExtGet method after removing this one, then go with the existing one.
|
||||
if (src.match(/def(?:\s+)?safeExtGet\(/)) {
|
||||
return src;
|
||||
}
|
||||
// Otherwise add a new one
|
||||
const newSrc = [];
|
||||
newSrc.push("def safeExtGet(prop, fallback) {", " rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback", "}");
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "safeExtGet",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
// This block can go anywhere in the upper scope
|
||||
anchor: /apply plugin/,
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
}).contents;
|
||||
}
|
||||
function addGoogleCastVersionImport(src, { version } = {}) {
|
||||
const newSrc = [];
|
||||
newSrc.push(` castFrameworkVersion = "${version}"`);
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-google-cast-version",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /ext(?:\s+)?\{/,
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
declare const _default: ConfigPlugin<void | {
|
||||
/**
|
||||
* @default '+'
|
||||
*/
|
||||
androidPlayServicesCastFrameworkVersion?: string | undefined;
|
||||
/**
|
||||
* @default 'CC1AD845'
|
||||
*/
|
||||
iosReceiverAppId?: string | undefined;
|
||||
/**
|
||||
* ??
|
||||
*/
|
||||
androidReceiverAppId?: string | undefined;
|
||||
}>;
|
||||
export default _default;
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const withAndroidGoogleCast_1 = require("./withAndroidGoogleCast");
|
||||
const withIosGoogleCast_1 = require("./withIosGoogleCast");
|
||||
const withGoogleCast = (config, _props) => {
|
||||
const props = _props || {};
|
||||
// TODO: Are the Android and iOS receiverAppId values the same?
|
||||
config = withIosGoogleCast_1.withIosGoogleCast(config, {
|
||||
receiverAppId: props.iosReceiverAppId,
|
||||
// disableDiscoveryAutostart?: boolean;
|
||||
// startDiscoveryAfterFirstTapOnCastButton?: boolean;
|
||||
});
|
||||
config = withAndroidGoogleCast_1.withAndroidGoogleCast(config, {
|
||||
receiverAppId: props.androidReceiverAppId,
|
||||
androidPlayServicesCastFrameworkVersion: props.androidPlayServicesCastFrameworkVersion,
|
||||
});
|
||||
return config;
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withGoogleCast, "react-native-google-cast");
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withIosGoogleCast: ConfigPlugin<{
|
||||
/**
|
||||
* @default 'CC1AD845'
|
||||
*/
|
||||
receiverAppId?: string;
|
||||
}>;
|
||||
export declare const MATCH_INIT: RegExp;
|
||||
declare type IosProps = {
|
||||
receiverAppId?: string | null;
|
||||
disableDiscoveryAutostart?: boolean;
|
||||
startDiscoveryAfterFirstTapOnCastButton?: boolean;
|
||||
};
|
||||
export declare function addGoogleCastAppDelegateDidFinishLaunchingWithOptions(src: string, { receiverAppId, disableDiscoveryAutostart, startDiscoveryAfterFirstTapOnCastButton, }?: IosProps): import("@expo/config-plugins/build/utils/generateCode").MergeResults;
|
||||
export {};
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addGoogleCastAppDelegateDidFinishLaunchingWithOptions = exports.MATCH_INIT = exports.withIosGoogleCast = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
/**
|
||||
* In Xcode, go to Signing & Capabilities, click + Capability and select Access WiFi Information. (This is required since iOS 12.)
|
||||
* Note that "Wireless Accessory Configuration" is unrelated.
|
||||
*
|
||||
* @param {*} config
|
||||
* @returns
|
||||
*/
|
||||
const withIosWifiEntitlements = (config) => {
|
||||
return config_plugins_1.withEntitlementsPlist(config, (config) => {
|
||||
config.modResults["com.apple.developer.networking.wifi-info"] = true;
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const LOCAL_NETWORK_USAGE = "${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi network";
|
||||
// const BLUETOOTH_ALWAYS_USAGE =
|
||||
// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices";
|
||||
// const BLUETOOTH_PERIPHERAL_USAGE =
|
||||
// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices";
|
||||
// const MICROPHONE_USAGE =
|
||||
// "${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens when pairing with nearby Cast devices";
|
||||
/**
|
||||
* On iOS, a dialog asking the user for the local network permission will now be displayed immediately when the app is opened.
|
||||
*
|
||||
* @param {*} config
|
||||
* @param {*} props.receiverAppId If using a custom receiver, make sure to replace `CC1AD845` with your custom receiver app id.
|
||||
* @returns
|
||||
*/
|
||||
const withIosLocalNetworkPermissions = (config, { receiverAppId = "CC1AD845" } = {}) => {
|
||||
return config_plugins_1.withInfoPlist(config, (config) => {
|
||||
if (!Array.isArray(config.modResults.NSBonjourServices)) {
|
||||
config.modResults.NSBonjourServices = [];
|
||||
}
|
||||
// Add required values
|
||||
config.modResults.NSBonjourServices.push("_googlecast._tcp", `_${receiverAppId}._googlecast._tcp`);
|
||||
// Remove duplicates
|
||||
config.modResults.NSBonjourServices = [
|
||||
...new Set(config.modResults.NSBonjourServices),
|
||||
];
|
||||
// For iOS 14+, you need to add local network permissions to Info.plist:
|
||||
// https://developers.google.com/cast/docs/ios_sender/ios_permissions_changes#updating_your_app_on_ios_14
|
||||
config.modResults.NSLocalNetworkUsageDescription =
|
||||
config.modResults.NSLocalNetworkUsageDescription || LOCAL_NETWORK_USAGE;
|
||||
return config;
|
||||
});
|
||||
};
|
||||
// const withIosGuestMode: ConfigPlugin = (config) => {
|
||||
// return withInfoPlist(config, (config) => {
|
||||
// config.modResults.NSBluetoothAlwaysUsageDescription =
|
||||
// config.modResults.NSBluetoothAlwaysUsageDescription ||
|
||||
// BLUETOOTH_ALWAYS_USAGE;
|
||||
// config.modResults.NSBluetoothPeripheralUsageDescription =
|
||||
// config.modResults.NSBluetoothPeripheralUsageDescription ||
|
||||
// BLUETOOTH_PERIPHERAL_USAGE;
|
||||
// config.modResults.NSMicrophoneUsageDescription =
|
||||
// config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE;
|
||||
// return config;
|
||||
// });
|
||||
// };
|
||||
// TODO: Use AppDelegate swizzling
|
||||
const withIosAppDelegateLoaded = (config, props) => {
|
||||
return config_plugins_1.withAppDelegate(config, (config) => {
|
||||
if (config.modResults.language !== "objc") {
|
||||
throw new Error("react-native-google-cast config plugin does not support Swift AppDelegate yet.");
|
||||
}
|
||||
config.modResults.contents =
|
||||
addGoogleCastAppDelegateDidFinishLaunchingWithOptions(config.modResults.contents, props).contents;
|
||||
config.modResults.contents = addGoogleCastAppDelegateImport(config.modResults.contents).contents;
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const withIosGoogleCast = (config, props) => {
|
||||
config = withIosWifiEntitlements(config);
|
||||
config = withIosLocalNetworkPermissions(config, {
|
||||
receiverAppId: props.receiverAppId,
|
||||
});
|
||||
config = withIosAppDelegateLoaded(config, {
|
||||
receiverAppId: props.receiverAppId,
|
||||
// disableDiscoveryAutostart?: boolean;
|
||||
// startDiscoveryAfterFirstTapOnCastButton?: boolean;
|
||||
});
|
||||
// TODO
|
||||
// config = withIosGuestMode(config)
|
||||
return config;
|
||||
};
|
||||
exports.withIosGoogleCast = withIosGoogleCast;
|
||||
// From expo-cli RNMaps setup
|
||||
exports.MATCH_INIT = /(?:(self\.|_)(\w+)\s?=\s?\[\[UMModuleRegistryAdapter alloc\])|(?:RCTBridge\s?\*\s?(\w+)\s?=\s?\[\[RCTBridge alloc\])|(\[self\.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions\])/g;
|
||||
function addGoogleCastAppDelegateDidFinishLaunchingWithOptions(src, { receiverAppId = null, disableDiscoveryAutostart = false, startDiscoveryAfterFirstTapOnCastButton = true, } = {}) {
|
||||
let newSrc = [];
|
||||
newSrc.push(
|
||||
// For extra safety
|
||||
"#if __has_include(<GoogleCast/GoogleCast.h>)",
|
||||
// TODO: This should probably read safely from a static file like the Info.plist
|
||||
` NSString *receiverAppID = ${receiverAppId
|
||||
? `@"${receiverAppId}"`
|
||||
: "kGCKDefaultMediaReceiverApplicationID"};`, " GCKDiscoveryCriteria *criteria = [[GCKDiscoveryCriteria alloc] initWithApplicationID:receiverAppID];", " GCKCastOptions* options = [[GCKCastOptions alloc] initWithDiscoveryCriteria:criteria];",
|
||||
// TODO: Same as above, read statically
|
||||
// ` options.disableDiscoveryAutostart = ${String(!!disableDiscoveryAutostart)};`,
|
||||
` options.startDiscoveryAfterFirstTapOnCastButton = ${String(!!startDiscoveryAfterFirstTapOnCastButton)};`, " [GCKCastContext setSharedInstanceWithOptions:options];", "#endif");
|
||||
newSrc = newSrc.filter(Boolean);
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-google-cast-didFinishLaunchingWithOptions",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: exports.MATCH_INIT,
|
||||
offset: 0,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
exports.addGoogleCastAppDelegateDidFinishLaunchingWithOptions = addGoogleCastAppDelegateDidFinishLaunchingWithOptions;
|
||||
function addGoogleCastAppDelegateImport(src) {
|
||||
const newSrc = [];
|
||||
newSrc.push("#if __has_include(<GoogleCast/GoogleCast.h>)", "#import <GoogleCast/GoogleCast.h>", "#endif");
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-google-cast-import",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /#import "AppDelegate\.h"/,
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-google-cast",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"description": "Config plugin to auto configure Google Cast on prebuild",
|
||||
"main": "build/withGoogleCast.js",
|
||||
"types": "build/withGoogleCast.d.ts",
|
||||
|
||||
@@ -6,12 +6,11 @@ import {
|
||||
withMainActivity,
|
||||
withProjectBuildGradle,
|
||||
} from "@expo/config-plugins";
|
||||
import { addImports } from "@expo/config-plugins/build/android/codeMod";
|
||||
import {
|
||||
mergeContents,
|
||||
removeContents,
|
||||
} from "@expo/config-plugins/build/utils/generateCode";
|
||||
import { addImports } from "@expo/config-plugins/build/android/codeMod";
|
||||
import fs from "fs";
|
||||
|
||||
const { addMetaDataItemToMainApplication, getMainApplicationOrThrow } =
|
||||
AndroidConfig.Manifest;
|
||||
@@ -121,7 +120,7 @@ const withAppBuildGradleImport: ConfigPlugin<{ version?: string }> = (
|
||||
|
||||
const withMainActivityLazyLoading: ConfigPlugin = (config) => {
|
||||
return withMainActivity(config, async (config) => {
|
||||
let src = addImports(
|
||||
const src = addImports(
|
||||
config.modResults.contents,
|
||||
["com.google.android.gms.cast.framework.CastContext"],
|
||||
config.modResults.language === "java"
|
||||
|
||||
@@ -22,12 +22,12 @@ const withIosWifiEntitlements: ConfigPlugin = (config) => {
|
||||
|
||||
const LOCAL_NETWORK_USAGE =
|
||||
"${PRODUCT_NAME} uses the local network to discover Cast-enabled devices on your WiFi network";
|
||||
const BLUETOOTH_ALWAYS_USAGE =
|
||||
"${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices";
|
||||
const BLUETOOTH_PERIPHERAL_USAGE =
|
||||
"${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices";
|
||||
const MICROPHONE_USAGE =
|
||||
"${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens when pairing with nearby Cast devices";
|
||||
// const BLUETOOTH_ALWAYS_USAGE =
|
||||
// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices";
|
||||
// const BLUETOOTH_PERIPHERAL_USAGE =
|
||||
// "${PRODUCT_NAME} uses Bluetooth to discover nearby Cast devices";
|
||||
// const MICROPHONE_USAGE =
|
||||
// "${PRODUCT_NAME} uses microphone access to listen for ultrasonic tokens when pairing with nearby Cast devices";
|
||||
|
||||
/**
|
||||
* On iOS, a dialog asking the user for the local network permission will now be displayed immediately when the app is opened.
|
||||
@@ -61,19 +61,19 @@ const withIosLocalNetworkPermissions: ConfigPlugin<{ receiverAppId?: string }> =
|
||||
});
|
||||
};
|
||||
|
||||
const withIosGuestMode: ConfigPlugin = (config) => {
|
||||
return withInfoPlist(config, (config) => {
|
||||
config.modResults.NSBluetoothAlwaysUsageDescription =
|
||||
config.modResults.NSBluetoothAlwaysUsageDescription ||
|
||||
BLUETOOTH_ALWAYS_USAGE;
|
||||
config.modResults.NSBluetoothPeripheralUsageDescription =
|
||||
config.modResults.NSBluetoothPeripheralUsageDescription ||
|
||||
BLUETOOTH_PERIPHERAL_USAGE;
|
||||
config.modResults.NSMicrophoneUsageDescription =
|
||||
config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE;
|
||||
return config;
|
||||
});
|
||||
};
|
||||
// const withIosGuestMode: ConfigPlugin = (config) => {
|
||||
// return withInfoPlist(config, (config) => {
|
||||
// config.modResults.NSBluetoothAlwaysUsageDescription =
|
||||
// config.modResults.NSBluetoothAlwaysUsageDescription ||
|
||||
// BLUETOOTH_ALWAYS_USAGE;
|
||||
// config.modResults.NSBluetoothPeripheralUsageDescription =
|
||||
// config.modResults.NSBluetoothPeripheralUsageDescription ||
|
||||
// BLUETOOTH_PERIPHERAL_USAGE;
|
||||
// config.modResults.NSMicrophoneUsageDescription =
|
||||
// config.modResults.NSMicrophoneUsageDescription || MICROPHONE_USAGE;
|
||||
// return config;
|
||||
// });
|
||||
// };
|
||||
|
||||
// TODO: Use AppDelegate swizzling
|
||||
const withIosAppDelegateLoaded: ConfigPlugin<IosProps> = (config, props) => {
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-pdf [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-pdf [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { ConfigPlugin } from "@expo/config-plugins";
|
||||
export declare const withAndroidPackagingOptions: ConfigPlugin;
|
||||
export declare function addAndroidPackagingOptions(src: string): import("@expo/config-plugins/build/utils/generateCode").MergeResults;
|
||||
declare const _default: ConfigPlugin<void>;
|
||||
export default _default;
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addAndroidPackagingOptions = exports.withAndroidPackagingOptions = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
let pkg = {
|
||||
name: "react-native-pdf",
|
||||
};
|
||||
try {
|
||||
pkg = require("react-native-pdf/package.json");
|
||||
}
|
||||
catch (_a) {
|
||||
// empty catch block
|
||||
}
|
||||
const withAndroidPackagingOptions = (config) => {
|
||||
return config_plugins_1.withAppBuildGradle(config, (config) => {
|
||||
if (config.modResults.language === "groovy") {
|
||||
config.modResults.contents = addAndroidPackagingOptions(config.modResults.contents).contents;
|
||||
}
|
||||
else {
|
||||
config_plugins_1.WarningAggregator.addWarningAndroid("@config-plugins/react-native-pdf", `Cannot automatically configure app build.gradle if it's not groovy`);
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
exports.withAndroidPackagingOptions = withAndroidPackagingOptions;
|
||||
function addAndroidPackagingOptions(src) {
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-pdf-packaging-options",
|
||||
src,
|
||||
newSrc: packagingOptionsContents,
|
||||
anchor: /android(?:\s+)?\{/,
|
||||
// Inside the android block.
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
exports.addAndroidPackagingOptions = addAndroidPackagingOptions;
|
||||
const packagingOptionsContents = `
|
||||
packagingOptions {
|
||||
pickFirst 'lib/x86/libc++_shared.so'
|
||||
pickFirst 'lib/x86_64/libjsc.so'
|
||||
pickFirst 'lib/arm64-v8a/libjsc.so'
|
||||
pickFirst 'lib/arm64-v8a/libc++_shared.so'
|
||||
pickFirst 'lib/x86_64/libc++_shared.so'
|
||||
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
|
||||
}
|
||||
`;
|
||||
const withReactNativePdf = (config) => {
|
||||
return exports.withAndroidPackagingOptions(config);
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withReactNativePdf, pkg.name, pkg.version);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-pdf",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Config plugin to auto configure react-native-pdf on prebuild",
|
||||
"main": "build/withPdf.js",
|
||||
"types": "build/withPdf.d.ts",
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
### @config-plugins/react-native-quick-actions [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
||||
|
||||
|
||||
### Other chores
|
||||
|
||||
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
|
||||
|
||||
### @config-plugins/react-native-quick-actions [1.0.1](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-16)
|
||||
|
||||
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import { ConfigPlugin, XML } from "@expo/config-plugins";
|
||||
import { MergeResults } from "@expo/config-plugins/build/utils/generateCode";
|
||||
export declare function addQuickActionsAppDelegateImport(src: string): MergeResults;
|
||||
export declare function addQuickActionsAppDelegateInit(src: string): MergeResults;
|
||||
declare const _default: ConfigPlugin<void | {
|
||||
iconType?: string | undefined;
|
||||
title: string;
|
||||
iconSymbolName?: string | undefined;
|
||||
iconFile?: string | undefined;
|
||||
subtitle?: string | undefined;
|
||||
/**
|
||||
* A unique string that the system passes to your app
|
||||
*/
|
||||
type: string;
|
||||
/**
|
||||
* An optional, app-defined dictionary. One use for this dictionary is to provide app version information, as described in the “App Launch and App Update Considerations for Quick Actions” section of the overview in UIApplicationShortcutItem Class Reference.
|
||||
*/
|
||||
userInfo?: XML.XMLObject | undefined;
|
||||
}[]>;
|
||||
export default _default;
|
||||
Loaded 100 of 116 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user