mirror of
https://github.com/expo/config-plugins.git
synced 2026-11-13 20:28:07 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99f18da4ed | ||
|
|
999cc00275 | ||
|
|
363d36b0bb |
No files matched your search
@@ -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
@@ -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 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
@@ -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 {};
|
||||
+124
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.addQuickActionsAppDelegateInit = exports.addQuickActionsAppDelegateImport = void 0;
|
||||
const config_plugins_1 = require("@expo/config-plugins");
|
||||
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
||||
const remapping = {
|
||||
iconType: "UIApplicationShortcutItemIconType",
|
||||
iconFile: "UIApplicationShortcutItemIconFile",
|
||||
iconSymbolName: "UIApplicationShortcutItemIconSymbolName",
|
||||
title: "UIApplicationShortcutItemTitle",
|
||||
subtitle: "UIApplicationShortcutItemSubtitle",
|
||||
type: "UIApplicationShortcutItemType",
|
||||
userInfo: "UIApplicationShortcutItemUserInfo",
|
||||
};
|
||||
// #import "RNQuickActionManager.h"
|
||||
// https://github.com/jordanbyron/react-native-quick-actions#adding-static-quick-actions---ios-only
|
||||
// https://developer.apple.com/documentation/uikit/menus_and_shortcuts/add_home_screen_quick_actions
|
||||
// TODO: Auto generate images in asset catalogues
|
||||
/**
|
||||
* Apply react-native-quick-actions configuration for Expo SDK 42 projects.
|
||||
*/
|
||||
const withReactNativeQuickActions = (config, _items) => {
|
||||
config = withQuickActionsAppDelegate(config);
|
||||
const items = _items || [];
|
||||
if (!Array.isArray(items) || !items.length) {
|
||||
return config;
|
||||
}
|
||||
return config_plugins_1.withInfoPlist(config, (config) => {
|
||||
config.modResults.UIApplicationShortcutItems = items.map((item) => {
|
||||
const result = {};
|
||||
for (const [key, value] of Object.entries(remapping)) {
|
||||
// @ts-expect-error
|
||||
const itemValue = item[key];
|
||||
if (itemValue) {
|
||||
result[value] = itemValue;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
});
|
||||
for (const index in config.modResults.UIApplicationShortcutItems) {
|
||||
const item = config.modResults.UIApplicationShortcutItems[index];
|
||||
for (const key of Object.keys(item)) {
|
||||
if (!item[key]) {
|
||||
// @ts-expect-error
|
||||
delete config.modResults.UIApplicationShortcutItems[index][key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
function addQuickActionsAppDelegateImport(src) {
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-quick-actions-import",
|
||||
src,
|
||||
newSrc: '#import "RNQuickActionManager.h"',
|
||||
anchor: /#import "AppDelegate\.h"/,
|
||||
offset: 1,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
exports.addQuickActionsAppDelegateImport = addQuickActionsAppDelegateImport;
|
||||
function addQuickActionsAppDelegateInit(src) {
|
||||
const newSrc = [];
|
||||
newSrc.push("- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler {", " [RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler];", "}");
|
||||
return generateCode_1.mergeContents({
|
||||
tag: "react-native-quick-actions-delegate",
|
||||
src,
|
||||
newSrc: newSrc.join("\n"),
|
||||
anchor: /-\s?\(BOOL\)application:\(UIApplication\s?\*\)application/,
|
||||
offset: 0,
|
||||
comment: "//",
|
||||
});
|
||||
}
|
||||
exports.addQuickActionsAppDelegateInit = addQuickActionsAppDelegateInit;
|
||||
const withQuickActionsAppDelegate = (config) => {
|
||||
return config_plugins_1.withAppDelegate(config, (config) => {
|
||||
if (config.modResults.language === "objc") {
|
||||
try {
|
||||
config.modResults.contents = addQuickActionsAppDelegateImport(config.modResults.contents).contents;
|
||||
config.modResults.contents = addQuickActionsAppDelegateInit(config.modResults.contents).contents;
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === "ERR_NO_MATCH") {
|
||||
throw new Error(`Cannot add QuickActions to the project's AppDelegate because it's malformed. Please report this with a copy of your project AppDelegate.`);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new Error("Cannot setup QuickActions because the AppDelegate is not Objective C");
|
||||
}
|
||||
return config;
|
||||
});
|
||||
};
|
||||
const pkg = {
|
||||
// Prevent this plugin from being run more than once.
|
||||
// This pattern enables users to safely migrate off of this
|
||||
// out-of-tree `@config-plugins/react-native-quick-actions` to a future
|
||||
// upstream plugin in `react-native-quick-actions`
|
||||
name: "react-native-quick-actions",
|
||||
// Indicates that this plugin is dangerously linked to a module,
|
||||
// and might not work with the latest version of that module.
|
||||
version: "UNVERSIONED",
|
||||
};
|
||||
exports.default = config_plugins_1.createRunOncePlugin(withReactNativeQuickActions, pkg.name, pkg.version);
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@config-plugins/react-native-quick-actions",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.2",
|
||||
"description": "Config plugin for react-native-quick-actions package",
|
||||
"main": "build/withReactNativeQuickActions.js",
|
||||
"types": "build/withReactNativeQuickActions.d.ts",
|
||||
|
||||
Reference in new issue
Block a user