diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index f61aba7e..f22a59e3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -42,7 +42,6 @@ body: - '@config-plugins/react-native-dynamic-app-icon' - '@config-plugins/react-native-google-cast' - '@config-plugins/react-native-pdf' - - '@config-plugins/react-native-quick-actions' - '@config-plugins/react-native-siri-shortcut' - '@config-plugins/react-native-webrtc' validations: diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 8beeb8b1..88453839 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -17,7 +17,7 @@ contact_links: url: https://github.com/adjust/react_native_sdk/issues - about: React Native Bluetooth Low Energy library name: 📦 react-native-ble-plx issues - url: https://github.com/Polidea/react-native-ble-plx/issues + url: https://github.com/dotintent/react-native-ble-plx/issues - about: >- A module provides upload, download, and files access API. Supports file stream read/write for process large files. @@ -36,9 +36,6 @@ contact_links: - about: A react native PDF view component, support ios and android platform name: 📦 react-native-pdf issues url: https://github.com/wonday/react-native-pdf/issues - - about: A react-native interface for Touch 3D home screen quick actions - name: 📦 react-native-quick-actions issues - url: https://github.com/jordanbyron/react-native-quick-actions/issues - about: A React Native library that enables you to use iOS 12+ Siri Shortcuts. name: 📦 react-native-siri-shortcut issues url: https://github.com/Gustash/react-native-siri-shortcut/issues diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5827836b..c2737c6f 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -83,12 +83,6 @@ updates: 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-siri-shortcut schedule: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 552c8fb5..b9f40218 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,7 +44,6 @@ jobs: react-native-siri-shortcut, react-native-google-cast, react-native-pdf, - # react-native-quick-actions, ] name: Test ${{ matrix.package }} on Node ${{ matrix.node }} steps: diff --git a/apps/react-native-quick-actions/app.config.js b/apps/react-native-quick-actions/app.config.js deleted file mode 100644 index c8df85db..00000000 --- a/apps/react-native-quick-actions/app.config.js +++ /dev/null @@ -1,16 +0,0 @@ -const path = require("path"); -const folderName = path.basename(__dirname); -const cleanName = folderName.replace(/[_\s-]/g, ""); -const appId = "dev.bacon." + cleanName; - -module.exports = ({ config }) => { - if (!config.extra) config.extra = {}; - // Expose CI env variables to the app - config.extra.CI = process.env.CI; - - if (!config.ios) config.ios = {}; - config.ios.bundleIdentifier = appId; - if (!config.android) config.android = {}; - config.android.package = appId; - return config; -}; diff --git a/apps/react-native-quick-actions/app.json b/apps/react-native-quick-actions/app.json deleted file mode 100644 index c4443bb2..00000000 --- a/apps/react-native-quick-actions/app.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "expo": { - "name": "quick-actions", - "icon": "https://icogen.vercel.app/api/icon?icon=🔌&color_hex=3F97EF", - "plugins": [ - [ - "@config-plugins/react-native-quick-actions", - [ - { - "title": "Take Photo", - "type": "photo", - "iconType": "UIApplicationShortcutIconTypeCapturePhoto" - } - ] - ] - ] - } -} diff --git a/apps/react-native-quick-actions/index.js b/apps/react-native-quick-actions/index.js deleted file mode 100644 index 58298e14..00000000 --- a/apps/react-native-quick-actions/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { registerRootComponent } from "expo"; - -import App from "./src/App"; - -registerRootComponent(App); diff --git a/apps/react-native-quick-actions/package.json b/apps/react-native-quick-actions/package.json deleted file mode 100644 index ec31a9d1..00000000 --- a/apps/react-native-quick-actions/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "@config-plugins-app/react-native-quick-actions", - "main": "./index.js", - "version": "1.0.0", - "scripts": { - "start": "expo start --dev-client", - "ios": "expo run:ios", - "android": "expo run:android" - }, - "dependencies": { - "@config-plugins/react-native-quick-actions": "*", - "expo": "^49.0.3", - "expo-splash-screen": "~0.20.4", - "expo-status-bar": "~1.6.0", - "react": "18.2.0", - "react-native": "0.72.3", - "react-native-quick-actions": "^0.3.13" - }, - "devDependencies": { - "@babel/core": "^7.20.0" - }, - "private": true -} diff --git a/apps/react-native-quick-actions/src/App.js b/apps/react-native-quick-actions/src/App.js deleted file mode 100644 index 8d2fc940..00000000 --- a/apps/react-native-quick-actions/src/App.js +++ /dev/null @@ -1,61 +0,0 @@ -import QuickActions from "react-native-quick-actions"; -import React from "react"; -import { Text, View } from "react-native"; - -import { DeviceEventEmitter } from "react-native"; - -function useQuickAction() { - const [item, setItem] = React.useState(null); - const isMounted = React.useRef(true); - React.useEffect(() => { - QuickActions.popInitialAction().then((action) => { - if (isMounted.current) setItem(action); - }); - const sub = DeviceEventEmitter.addListener( - "quickActionShortcut", - (data) => { - if (isMounted.current) { - setItem(data); - } - } - ); - return () => { - isMounted.current = false; - sub.remove(); - }; - }, []); - return item; -} - -function App() { - const action = useQuickAction(); - - React.useEffect(() => { - QuickActions.setShortcutItems([ - { - title: "Play Song", - subtitle: "NDA - Billie Eilish", - icon: "Play", - type: "alpha", - }, - { - title: "Shuffle", - icon: "Shuffle", - type: "beta", - }, - { - title: "Like Song", - icon: "Love", - type: "gamma", - }, - ]); - }, []); - - return ( - - Quick Actions - {action && {JSON.stringify(action, null, 2)}} - - ); -} -export default App; diff --git a/packages/react-native-quick-actions/.eslintrc.js b/packages/react-native-quick-actions/.eslintrc.js deleted file mode 100644 index 27201978..00000000 --- a/packages/react-native-quick-actions/.eslintrc.js +++ /dev/null @@ -1,2 +0,0 @@ -// @generated by expo-module-scripts -module.exports = require('expo-module-scripts/eslintrc.base.js'); diff --git a/packages/react-native-quick-actions/CHANGELOG.md b/packages/react-native-quick-actions/CHANGELOG.md deleted file mode 100644 index 92eb3b56..00000000 --- a/packages/react-native-quick-actions/CHANGELOG.md +++ /dev/null @@ -1,35 +0,0 @@ -### @config-plugins/react-native-quick-actions 5.0.0 - -- Expo SDK 48 support - -## @config-plugins/react-native-quick-actions [2.0.0](https://github.com/expo/config-plugins/compare/@config-plugins/react-native-quick-actions@1.0.2...@config-plugins/react-native-quick-actions@2.0.0) (2022-06-13) - -### ⚠ BREAKING CHANGES - -- add SDK 45 support (#79) - -### Features - -- add SDK 45 support ([#79](https://github.com/expo/config-plugins/issues/79)) ([96c72dd](https://github.com/expo/config-plugins/commit/96c72dda469ace2b9eafd38ba4d21f1bcd2e3cdf)) - -### Other chores - -- publish packages [no-ci] ([0c7b413](https://github.com/expo/config-plugins/commit/0c7b413a765e4b1ff92b9e3edc2b62077c41ce46)) - -### @config-plugins/react-native-quick-actions [1.0.2](https://github.com/expo/config-plugins/compare/@config-plugins/react-native-quick-actions@1.0.1...@config-plugins/react-native-quick-actions@1.0.2) (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/react-native-quick-actions@1.0.0...@config-plugins/react-native-quick-actions@1.0.1) (2022-03-16) - -### Continuous Integration - -- fix versions [skip ci] ([#53](https://github.com/expo/config-plugins/issues/53)) ([5de4ae3](https://github.com/expo/config-plugins/commit/5de4ae3e6182c32b7aa24d70ccd23a11663bb089)) - -## @config-plugins/react-native-quick-actions 1.0.0 (2022-03-15) - -### Other chores - -- upgrade @expo/config-plugins ([#49](https://github.com/expo/config-plugins/issues/49)) ([119e31e](https://github.com/expo/config-plugins/commit/119e31edf110409272ace750f02d651124e1a22d)) diff --git a/packages/react-native-quick-actions/README.md b/packages/react-native-quick-actions/README.md index 39d7f64b..faad8b29 100644 --- a/packages/react-native-quick-actions/README.md +++ b/packages/react-native-quick-actions/README.md @@ -1,7 +1,6 @@ # @config-plugins/react-native-quick-actions -> [!IMPORTANT] -> `react-native-quick-actions` is archived. Use [`expo-quick-action`](https://github.com/EvanBacon/expo-quick-actions) instead. +> [!IMPORTANT] > `react-native-quick-actions` is archived. Use [`expo-quick-action`](https://github.com/EvanBacon/expo-quick-actions) instead. This config plugin is now deprecated in favor of `expo-quick-action`. Expo Config Plugin to auto-configure [`react-native-quick-actions`](https://www.npmjs.com/package/react-native-quick-actions) when the native code is generated (`npx expo prebuild`). diff --git a/packages/react-native-quick-actions/app.plugin.js b/packages/react-native-quick-actions/app.plugin.js deleted file mode 100644 index 330aa582..00000000 --- a/packages/react-native-quick-actions/app.plugin.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require("./build/withReactNativeQuickActions"); \ No newline at end of file diff --git a/packages/react-native-quick-actions/build/withReactNativeQuickActions.d.ts b/packages/react-native-quick-actions/build/withReactNativeQuickActions.d.ts deleted file mode 100644 index ff9e3742..00000000 --- a/packages/react-native-quick-actions/build/withReactNativeQuickActions.d.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { MergeResults } from "@expo/config-plugins/build/utils/generateCode"; -import { ConfigPlugin, XML } from "expo/config-plugins"; -export declare function addQuickActionsAppDelegateImport(src: string): MergeResults; -export declare function addQuickActionsAppDelegateInit(src: string): MergeResults; -declare const _default: ConfigPlugin; -export default _default; diff --git a/packages/react-native-quick-actions/build/withReactNativeQuickActions.js b/packages/react-native-quick-actions/build/withReactNativeQuickActions.js deleted file mode 100644 index 952a6d7d..00000000 --- a/packages/react-native-quick-actions/build/withReactNativeQuickActions.js +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.addQuickActionsAppDelegateInit = exports.addQuickActionsAppDelegateImport = void 0; -const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode"); -const config_plugins_1 = require("expo/config-plugins"); -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 native configuration. - */ -const withReactNativeQuickActions = (config, _items) => { - config = withQuickActionsAppDelegate(config); - const items = _items || []; - if (!Array.isArray(items) || !items.length) { - return config; - } - return (0, 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 (0, 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 (0, 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 (0, config_plugins_1.withAppDelegate)(config, (config) => { - if (["objc", "objcpp"].includes(config.modResults.language)) { - 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 = (0, config_plugins_1.createRunOncePlugin)(withReactNativeQuickActions, pkg.name, pkg.version); diff --git a/packages/react-native-quick-actions/jest.config.js b/packages/react-native-quick-actions/jest.config.js deleted file mode 100644 index e539b3b1..00000000 --- a/packages/react-native-quick-actions/jest.config.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('expo-module-scripts/jest-preset-plugin'); diff --git a/packages/react-native-quick-actions/package.json b/packages/react-native-quick-actions/package.json deleted file mode 100644 index a6fc89d3..00000000 --- a/packages/react-native-quick-actions/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "@config-plugins/react-native-quick-actions", - "version": "6.0.0", - "description": "Config plugin for react-native-quick-actions package", - "main": "build/withReactNativeQuickActions.js", - "types": "build/withReactNativeQuickActions.d.ts", - "sideEffects": false, - "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/expo/config-plugins.git", - "directory": "packages/react-native-quick-actions" - }, - "scripts": { - "build": "expo-module build", - "clean": "expo-module clean", - "lint": "expo-module lint", - "test": "expo-module test", - "prepare": "expo-module prepare", - "prepublishOnly": "expo-module prepublishOnly", - "expo-module": "expo-module" - }, - "keywords": [ - "react", - "expo", - "config-plugins", - "prebuild", - "react-native-quick-actions" - ], - "peerDependencies": { - "expo": "^49" - }, - "devDependencies": { - "expo-module-scripts": "^3.0.3" - }, - "upstreamPackage": "react-native-quick-actions" -} diff --git a/packages/react-native-quick-actions/src/__tests__/__snapshots__/withReactNativeQuickActions.test.ts.snap b/packages/react-native-quick-actions/src/__tests__/__snapshots__/withReactNativeQuickActions.test.ts.snap deleted file mode 100644 index fe3aaab8..00000000 --- a/packages/react-native-quick-actions/src/__tests__/__snapshots__/withReactNativeQuickActions.test.ts.snap +++ /dev/null @@ -1,347 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`addQuickActionsAppDelegateImport adds import to Expo Modules AppDelegate 1`] = ` -"#import \\"AppDelegate.h\\" -// @generated begin react-native-quick-actions-import - expo prebuild (DO NOT MODIFY) sync-6ea4aa8a461f1aab4f2c38893cd59140deb974e4 -#import \\"RNQuickActionManager.h\\" -// @generated end react-native-quick-actions-import - -#import -#import -#import -#import -#import - -#import - -#if RCT_NEW_ARCH_ENABLED -#import -#import -#import -#import -#import -#import - -#import - -static NSString *const kRNConcurrentRoot = @\\"concurrentRoot\\"; - -@interface AppDelegate () { - RCTTurboModuleManager *_turboModuleManager; - RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; - std::shared_ptr _reactNativeConfig; - facebook::react::ContextContainer::Shared _contextContainer; -} -@end -#endif - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - RCTAppSetupPrepareApp(application); - - RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions]; - -#if RCT_NEW_ARCH_ENABLED - _contextContainer = std::make_shared(); - _reactNativeConfig = std::make_shared(); - _contextContainer->insert(\\"ReactNativeConfig\\", _reactNativeConfig); - _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; - bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; -#endif - - NSDictionary *initProps = [self prepareInitialProps]; - UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@\\"main\\" initialProperties:initProps]; - - rootView.backgroundColor = [UIColor whiteColor]; - self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [self.reactDelegate createRootViewController]; - rootViewController.view = rootView; - self.window.rootViewController = rootViewController; - [self.window makeKeyAndVisible]; - - [super application:application didFinishLaunchingWithOptions:launchOptions]; - - return YES; -} - -- (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge -{ - // If you'd like to export some custom RCTBridgeModules, add them here! - return @[]; -} - -/// This method controls whether the \`concurrentRoot\`feature of React18 is turned on or off. -/// -/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html -/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). -/// @return: \`true\` if the \`concurrentRoot\` feture is enabled. Otherwise, it returns \`false\`. -- (BOOL)concurrentRootEnabled -{ - // Switch this bool to turn on and off the concurrent root - return true; -} - -- (NSDictionary *)prepareInitialProps -{ - NSMutableDictionary *initProps = [NSMutableDictionary new]; -#if RCT_NEW_ARCH_ENABLED - initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]); -#endif - return initProps; -} - -- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge -{ -#if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@\\"index\\"]; -#else - return [[NSBundle mainBundle] URLForResource:@\\"main\\" withExtension:@\\"jsbundle\\"]; -#endif -} - -// Linking API -- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { - return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options]; -} - -// Universal Links -- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { - BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; - return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result; -} - -// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries -- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken -{ - return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; -} - -// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries -- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error -{ - return [super application:application didFailToRegisterForRemoteNotificationsWithError:error]; -} - -// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler -{ - return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; -} - -#if RCT_NEW_ARCH_ENABLED - -#pragma mark - RCTCxxBridgeDelegate - -- (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge -{ - _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge - delegate:self - jsInvoker:bridge.jsCallInvoker]; - return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager); -} - -#pragma mark RCTTurboModuleManagerDelegate - -- (Class)getModuleClassFromName:(const char *)name -{ - return RCTCoreModulesClassProvider(name); -} - -- (std::shared_ptr)getTurboModule:(const std::string &)name - jsInvoker:(std::shared_ptr)jsInvoker -{ - return nullptr; -} - -- (std::shared_ptr)getTurboModule:(const std::string &)name - initParams: - (const facebook::react::ObjCTurboModule::InitParams &)params -{ - return nullptr; -} - -- (id)getModuleInstanceFromClass:(Class)moduleClass -{ - return RCTAppSetupDefaultModuleFromClass(moduleClass); -} - -#endif - -@end" -`; - -exports[`addQuickActionsAppDelegateInit adds init to Expo Modules AppDelegate 1`] = ` -"#import \\"AppDelegate.h\\" - -#import -#import -#import -#import -#import - -#import - -#if RCT_NEW_ARCH_ENABLED -#import -#import -#import -#import -#import -#import - -#import - -static NSString *const kRNConcurrentRoot = @\\"concurrentRoot\\"; - -@interface AppDelegate () { - RCTTurboModuleManager *_turboModuleManager; - RCTSurfacePresenterBridgeAdapter *_bridgeAdapter; - std::shared_ptr _reactNativeConfig; - facebook::react::ContextContainer::Shared _contextContainer; -} -@end -#endif - -@implementation AppDelegate - -// @generated begin react-native-quick-actions-delegate - expo prebuild (DO NOT MODIFY) sync-c20e1981d7932e1a91e1d34dbf5c36e3ff230412 -- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler { - [RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler]; -} -// @generated end react-native-quick-actions-delegate -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - RCTAppSetupPrepareApp(application); - - RCTBridge *bridge = [self.reactDelegate createBridgeWithDelegate:self launchOptions:launchOptions]; - -#if RCT_NEW_ARCH_ENABLED - _contextContainer = std::make_shared(); - _reactNativeConfig = std::make_shared(); - _contextContainer->insert(\\"ReactNativeConfig\\", _reactNativeConfig); - _bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:bridge contextContainer:_contextContainer]; - bridge.surfacePresenter = _bridgeAdapter.surfacePresenter; -#endif - - NSDictionary *initProps = [self prepareInitialProps]; - UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@\\"main\\" initialProperties:initProps]; - - rootView.backgroundColor = [UIColor whiteColor]; - self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [self.reactDelegate createRootViewController]; - rootViewController.view = rootView; - self.window.rootViewController = rootViewController; - [self.window makeKeyAndVisible]; - - [super application:application didFinishLaunchingWithOptions:launchOptions]; - - return YES; -} - -- (NSArray> *)extraModulesForBridge:(RCTBridge *)bridge -{ - // If you'd like to export some custom RCTBridgeModules, add them here! - return @[]; -} - -/// This method controls whether the \`concurrentRoot\`feature of React18 is turned on or off. -/// -/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html -/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture). -/// @return: \`true\` if the \`concurrentRoot\` feture is enabled. Otherwise, it returns \`false\`. -- (BOOL)concurrentRootEnabled -{ - // Switch this bool to turn on and off the concurrent root - return true; -} - -- (NSDictionary *)prepareInitialProps -{ - NSMutableDictionary *initProps = [NSMutableDictionary new]; -#if RCT_NEW_ARCH_ENABLED - initProps[kRNConcurrentRoot] = @([self concurrentRootEnabled]); -#endif - return initProps; -} - -- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge -{ -#if DEBUG - return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@\\"index\\"]; -#else - return [[NSBundle mainBundle] URLForResource:@\\"main\\" withExtension:@\\"jsbundle\\"]; -#endif -} - -// Linking API -- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { - return [super application:application openURL:url options:options] || [RCTLinkingManager application:application openURL:url options:options]; -} - -// Universal Links -- (BOOL)application:(UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity restorationHandler:(nonnull void (^)(NSArray> * _Nullable))restorationHandler { - BOOL result = [RCTLinkingManager application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; - return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || result; -} - -// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries -- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken -{ - return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; -} - -// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries -- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error -{ - return [super application:application didFailToRegisterForRemoteNotificationsWithError:error]; -} - -// Explicitly define remote notification delegates to ensure compatibility with some third-party libraries -- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler -{ - return [super application:application didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler]; -} - -#if RCT_NEW_ARCH_ENABLED - -#pragma mark - RCTCxxBridgeDelegate - -- (std::unique_ptr)jsExecutorFactoryForBridge:(RCTBridge *)bridge -{ - _turboModuleManager = [[RCTTurboModuleManager alloc] initWithBridge:bridge - delegate:self - jsInvoker:bridge.jsCallInvoker]; - return RCTAppSetupDefaultJsExecutorFactory(bridge, _turboModuleManager); -} - -#pragma mark RCTTurboModuleManagerDelegate - -- (Class)getModuleClassFromName:(const char *)name -{ - return RCTCoreModulesClassProvider(name); -} - -- (std::shared_ptr)getTurboModule:(const std::string &)name - jsInvoker:(std::shared_ptr)jsInvoker -{ - return nullptr; -} - -- (std::shared_ptr)getTurboModule:(const std::string &)name - initParams: - (const facebook::react::ObjCTurboModule::InitParams &)params -{ - return nullptr; -} - -- (id)getModuleInstanceFromClass:(Class)moduleClass -{ - return RCTAppSetupDefaultModuleFromClass(moduleClass); -} - -#endif - -@end" -`; diff --git a/packages/react-native-quick-actions/src/__tests__/withReactNativeQuickActions.test.ts b/packages/react-native-quick-actions/src/__tests__/withReactNativeQuickActions.test.ts deleted file mode 100644 index 172df31e..00000000 --- a/packages/react-native-quick-actions/src/__tests__/withReactNativeQuickActions.test.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { getFixture } from "../../../../fixtures/getFixtures"; -import { - addQuickActionsAppDelegateImport, - addQuickActionsAppDelegateInit, -} from "../withReactNativeQuickActions"; - -const ExpoModulesAppDelegate = getFixture("AppDelegate.mm"); - -describe(addQuickActionsAppDelegateInit, () => { - it(`adds init to Expo Modules AppDelegate`, () => { - const results = addQuickActionsAppDelegateInit(ExpoModulesAppDelegate); - // matches a static snapshot - expect(results.contents).toMatchSnapshot(); - expect(results.contents).toMatch(/RNQuickActionManager/); - expect(results.contents).toMatch(/application:application/); - // did add new content - expect(results.didMerge).toBe(true); - // didn't remove old content - expect(results.didClear).toBe(false); - }); - it(`fails to add to a malformed app delegate`, () => { - expect(() => addQuickActionsAppDelegateInit(`foobar`)).toThrow(/foobar/); - }); -}); - -describe(addQuickActionsAppDelegateImport, () => { - it(`adds import to Expo Modules AppDelegate`, () => { - const results = addQuickActionsAppDelegateImport(ExpoModulesAppDelegate); - // matches a static snapshot - expect(results.contents).toMatchSnapshot(); - expect(results.contents).toMatch(/RNQuickActionManager/); - // did add new content - expect(results.didMerge).toBe(true); - // didn't remove old content - expect(results.didClear).toBe(false); - }); - - it(`fails to add to a malformed app delegate`, () => { - expect(() => addQuickActionsAppDelegateImport(`foobar`)).toThrow(/foobar/); - }); -}); diff --git a/packages/react-native-quick-actions/src/withReactNativeQuickActions.ts b/packages/react-native-quick-actions/src/withReactNativeQuickActions.ts deleted file mode 100644 index a0a9c71f..00000000 --- a/packages/react-native-quick-actions/src/withReactNativeQuickActions.ts +++ /dev/null @@ -1,161 +0,0 @@ -import { - mergeContents, - MergeResults, -} from "@expo/config-plugins/build/utils/generateCode"; -import { - ConfigPlugin, - createRunOncePlugin, - withAppDelegate, - withInfoPlist, - XML, -} from "expo/config-plugins"; - -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 native configuration. - */ -const withReactNativeQuickActions: ConfigPlugin< - | void - | { - // https://github.com/jordanbyron/react-native-quick-actions/blob/d94a7319e70dc0b7f882b8cd573b04ad3463d87b/RNQuickAction/RNQuickAction/RNQuickActionManager.m#L69-L99 - iconType?: "UIApplicationShortcutIconTypeLocation" | string; - title: string; - // UIApplicationShortcutItemIconSymbolName - iconSymbolName?: "square.stack.3d.up" | string; - iconFile?: string; - subtitle?: string; - /** - * 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; - }[] -> = (config, _items) => { - config = withQuickActionsAppDelegate(config); - - const items = _items || []; - - if (!Array.isArray(items) || !items.length) { - return config; - } - - return withInfoPlist(config, (config) => { - config.modResults.UIApplicationShortcutItems = items.map((item) => { - const result: Record = {}; - - 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 - ] as Record; - for (const key of Object.keys(item)) { - if (!item[key]) { - // @ts-expect-error - delete config.modResults.UIApplicationShortcutItems[index][key]; - } - } - } - - return config; - }); -}; - -export function addQuickActionsAppDelegateImport(src: string): MergeResults { - return mergeContents({ - tag: "react-native-quick-actions-import", - src, - newSrc: '#import "RNQuickActionManager.h"', - anchor: /#import "AppDelegate\.h"/, - offset: 1, - comment: "//", - }); -} - -export function addQuickActionsAppDelegateInit(src: string): MergeResults { - const newSrc = []; - newSrc.push( - "- (void)application:(UIApplication *)application performActionForShortcutItem:(UIApplicationShortcutItem *)shortcutItem completionHandler:(void (^)(BOOL succeeded)) completionHandler {", - " [RNQuickActionManager onQuickActionPress:shortcutItem completionHandler:completionHandler];", - "}" - ); - - return mergeContents({ - tag: "react-native-quick-actions-delegate", - src, - newSrc: newSrc.join("\n"), - anchor: /-\s?\(BOOL\)application:\(UIApplication\s?\*\)application/, - offset: 0, - comment: "//", - }); -} - -const withQuickActionsAppDelegate: ConfigPlugin = (config) => { - return withAppDelegate(config, (config) => { - if (["objc", "objcpp"].includes(config.modResults.language)) { - try { - config.modResults.contents = addQuickActionsAppDelegateImport( - config.modResults.contents - ).contents; - config.modResults.contents = addQuickActionsAppDelegateInit( - config.modResults.contents - ).contents; - } catch (error: any) { - 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", -}; - -export default createRunOncePlugin( - withReactNativeQuickActions, - pkg.name, - pkg.version -); diff --git a/packages/react-native-quick-actions/tsconfig.json b/packages/react-native-quick-actions/tsconfig.json deleted file mode 100644 index 901571ed..00000000 --- a/packages/react-native-quick-actions/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "expo-module-scripts/tsconfig.plugin", - "compilerOptions": { - "outDir": "./build" - }, - "include": ["./src"], - "exclude": ["**/__mocks__/*", "**/__tests__/*"] -} diff --git a/yarn.lock b/yarn.lock index 2cfbc5f5..eba561de 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13958,11 +13958,6 @@ react-native-pdf@^6.7.1: crypto-js "^3.2.0" deprecated-react-native-prop-types "^2.3.0" -react-native-quick-actions@^0.3.13: - version "0.3.13" - resolved "https://registry.yarnpkg.com/react-native-quick-actions/-/react-native-quick-actions-0.3.13.tgz#74431b0b30e98ac896e44cc1024c38864cfe2bbc" - integrity sha512-Vz13a0+NV0mzCh/29tNt0qDzWPh8i2srTQW8eCSzGFDArnVm1COTOhTD0FY0hWHlxRY0ahvX+BlezTDvsyAuMA== - react-native-safe-area-context@4.6.3: version "4.6.3" resolved "https://registry.yarnpkg.com/react-native-safe-area-context/-/react-native-safe-area-context-4.6.3.tgz#f06cfea05b1c4b018aa9758667a109f619c62b55"