Compare commits

...
Author SHA1 Message Date
semantic-release-bot 363d36b0bb chore: 1.0.2
### [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)

### Features

* **react-native-webrtc:** add config mod for Android minSdkVersion 24 ([ff8b167](https://github.com/expo/config-plugins/commit/ff8b1677640a560ca98abd8a83f349b3a1ee9017))

### Bug Fixes

* **detox:** use improved xml generation ([#47](https://github.com/expo/config-plugins/issues/47)) ([6324eb0](https://github.com/expo/config-plugins/commit/6324eb041b3b4eb2318c0a1ea0297e3b7bf28f7c))

### Other chores

* 1.0.2 ([5f4e900](https://github.com/expo/config-plugins/commit/5f4e90059e4dd69579082aa7531b8ef7d2cc9a72)), closes [#60](https://github.com/expo/config-plugins/issues/60)
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
* **ci:** remove PR title validation action ([#62](https://github.com/expo/config-plugins/issues/62)) ([1648e85](https://github.com/expo/config-plugins/commit/1648e8598b959bf8140a2b984af0b8bb85a7e724))
* **ffmpeg-kit-react-native:** update plugin to use `AndroidConfig.Version.withBuildScriptExtMinimumVersion` ([#60](https://github.com/expo/config-plugins/issues/60)) ([c3a375b](https://github.com/expo/config-plugins/commit/c3a375b292d6405be7b3277d10ab4f8dbb006047))
* 1.0.1 ([39a9e63](https://github.com/expo/config-plugins/commit/39a9e63fe975122c5ffff0dd8975ea0dc7639720)), closes [#52](https://github.com/expo/config-plugins/issues/52) [#54](https://github.com/expo/config-plugins/issues/54) [#53](https://github.com/expo/config-plugins/issues/53) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#55](https://github.com/expo/config-plugins/issues/55)
* 2.1.0 ([e2d2b27](https://github.com/expo/config-plugins/commit/e2d2b27494b6a207932194c680de8cc6c1e7c02e))
* **repo:** add PR template ([#56](https://github.com/expo/config-plugins/issues/56)) ([eee366b](https://github.com/expo/config-plugins/commit/eee366bebcc42f4cdc4623f8b52790e3082a4472))
* 1.0.1 ([7ffc38a](https://github.com/expo/config-plugins/commit/7ffc38a808f4af7d098e3bddd84e69d9be083589)), closes [#52](https://github.com/expo/config-plugins/issues/52) [#54](https://github.com/expo/config-plugins/issues/54) [#53](https://github.com/expo/config-plugins/issues/53) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#55](https://github.com/expo/config-plugins/issues/55)
* 1.2.2 ([72fa3e1](https://github.com/expo/config-plugins/commit/72fa3e14ef3aa19c375457c81e8899c0ac13f4c9)), closes [#47](https://github.com/expo/config-plugins/issues/47)
* 2.0.2 ([480ec19](https://github.com/expo/config-plugins/commit/480ec19161587fb40fb2745511741f806083fc76)), closes [#52](https://github.com/expo/config-plugins/issues/52) [#54](https://github.com/expo/config-plugins/issues/54) [#53](https://github.com/expo/config-plugins/issues/53) [#55](https://github.com/expo/config-plugins/issues/55)
2022-03-22 18:31:12 +00:00
semantic-release-bot 37d11f1867 chore: 1.0.2
### [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (2022-03-22)

### Features

* **react-native-webrtc:** add config mod for Android minSdkVersion 24 ([ff8b167](https://github.com/expo/config-plugins/commit/ff8b1677640a560ca98abd8a83f349b3a1ee9017))

### Bug Fixes

* **detox:** use improved xml generation ([#47](https://github.com/expo/config-plugins/issues/47)) ([6324eb0](https://github.com/expo/config-plugins/commit/6324eb041b3b4eb2318c0a1ea0297e3b7bf28f7c))

### Other chores

* 1.0.2 ([5f4e900](https://github.com/expo/config-plugins/commit/5f4e90059e4dd69579082aa7531b8ef7d2cc9a72)), closes [#60](https://github.com/expo/config-plugins/issues/60)
* git ignore build folders ([#59](https://github.com/expo/config-plugins/issues/59)) ([d6050be](https://github.com/expo/config-plugins/commit/d6050beb2a5c68dc59287c27ec388c2002ec7904))
* **ci:** remove PR title validation action ([#62](https://github.com/expo/config-plugins/issues/62)) ([1648e85](https://github.com/expo/config-plugins/commit/1648e8598b959bf8140a2b984af0b8bb85a7e724))
* **ffmpeg-kit-react-native:** update plugin to use `AndroidConfig.Version.withBuildScriptExtMinimumVersion` ([#60](https://github.com/expo/config-plugins/issues/60)) ([c3a375b](https://github.com/expo/config-plugins/commit/c3a375b292d6405be7b3277d10ab4f8dbb006047))
* 1.0.1 ([39a9e63](https://github.com/expo/config-plugins/commit/39a9e63fe975122c5ffff0dd8975ea0dc7639720)), closes [#52](https://github.com/expo/config-plugins/issues/52) [#54](https://github.com/expo/config-plugins/issues/54) [#53](https://github.com/expo/config-plugins/issues/53) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#55](https://github.com/expo/config-plugins/issues/55)
* 1.0.1 ([97dcf1a](https://github.com/expo/config-plugins/commit/97dcf1aca63bb524217e731bded311a9c5dfdb28)), closes [#52](https://github.com/expo/config-plugins/issues/52) [#54](https://github.com/expo/config-plugins/issues/54) [#53](https://github.com/expo/config-plugins/issues/53) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#55](https://github.com/expo/config-plugins/issues/55)
* 2.1.0 ([e2d2b27](https://github.com/expo/config-plugins/commit/e2d2b27494b6a207932194c680de8cc6c1e7c02e))
* **repo:** add PR template ([#56](https://github.com/expo/config-plugins/issues/56)) ([eee366b](https://github.com/expo/config-plugins/commit/eee366bebcc42f4cdc4623f8b52790e3082a4472))
* 1.0.1 ([7ffc38a](https://github.com/expo/config-plugins/commit/7ffc38a808f4af7d098e3bddd84e69d9be083589)), closes [#52](https://github.com/expo/config-plugins/issues/52) [#54](https://github.com/expo/config-plugins/issues/54) [#53](https://github.com/expo/config-plugins/issues/53) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#48](https://github.com/expo/config-plugins/issues/48) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#49](https://github.com/expo/config-plugins/issues/49) [#49](https://github.com/expo/config-plugins/issues/49) [#46](https://github.com/expo/config-plugins/issues/46) [#3](https://github.com/expo/config-plugins/issues/3) [#55](https://github.com/expo/config-plugins/issues/55)
* 1.2.2 ([72fa3e1](https://github.com/expo/config-plugins/commit/72fa3e14ef3aa19c375457c81e8899c0ac13f4c9)), closes [#47](https://github.com/expo/config-plugins/issues/47)
* 2.0.2 ([480ec19](https://github.com/expo/config-plugins/commit/480ec19161587fb40fb2745511741f806083fc76)), closes [#52](https://github.com/expo/config-plugins/issues/52) [#54](https://github.com/expo/config-plugins/issues/54) [#53](https://github.com/expo/config-plugins/issues/53) [#55](https://github.com/expo/config-plugins/issues/55)
2022-03-22 18:31:09 +00:00
13 changed files with 536 additions and 2 deletions

No files matched your search

@@ -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
View File
@@ -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
View File
@@ -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":";;;;;AAAA,yDAO8B;AAC9B,mDAAuD;AACvD,4CAAoB;AACpB,gDAAwB;AAExB,MAAM,UAAU,GAAG,iBAAiB,CAAC;AACrC,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAQtB,SAAS,aAAa,CAAC,MAAgB;IACrC,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,EACtD,EAAE,CACH,CAAC;AACJ,CAAC;AAED,MAAM,eAAe,GAA4C,CAC/D,MAAM,EACN,KAAK,GAAG,EAAE,EACV,EAAE;IACF,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE,CAAC;IAE3B,IAAI,OAAO,GAAmB,EAAE,CAAC;IAEjC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;QACzB,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;KACjC;SAAM,IAAI,MAAM,EAAE;QACjB,OAAO,GAAG,MAAM,CAAC;KAClB;IAED,MAAM,GAAG,oBAAoB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;IAC1D,MAAM,GAAG,iBAAiB,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO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.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",
@@ -1,3 +1,10 @@
### @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
View File
@@ -0,0 +1,11 @@
import { ConfigPlugin } from "@expo/config-plugins";
export declare const withAndroidGoogleCast: ConfigPlugin<{
/**
* @default '+'
*/
androidPlayServicesCastFrameworkVersion?: string;
/**
* ??
*/
receiverAppId?: string;
}>;
+151
View File
@@ -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 generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
const codeMod_1 = require("@expo/config-plugins/build/android/codeMod");
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) => {
let 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
View File
@@ -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
View File
@@ -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
View File
@@ -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 {};
+124
View File
@@ -0,0 +1,124 @@
"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 = (config) => {
return config_plugins_1.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.2",
"description": "Config plugin to auto configure Google Cast on prebuild",
"main": "build/withGoogleCast.js",
"types": "build/withGoogleCast.d.ts",