mirror of
https://github.com/expo/config-plugins.git
synced 2026-11-14 10:08:06 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
987b109e46 | ||
|
|
226b2a6412 |
No files matched your search
@@ -1,3 +1,19 @@
|
|||||||
|
## @config-plugins/react-native-quick-actions [2.0.0](https://github.com/expo/config-plugins/compare/@config-plugins/[email protected]...@config-plugins/[email protected]) (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/[email protected]...@config-plugins/[email protected]) (2022-03-22)
|
### @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)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// @generated by expo-module-scripts
|
||||||
|
module.exports = require('expo-module-scripts/eslintrc.base.js');
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
# @config-plugins/react-native-siri-shortcut
|
||||||
|
|
||||||
|
Expo Config Plugin to auto configure [`react-native-siri-shortcut`](https://www.npmjs.com/package/react-native-siri-shortcut) when the native code is generated (`expo prebuild`).
|
||||||
|
|
||||||
|
## Expo installation
|
||||||
|
|
||||||
|
> Tested against Expo SDK 42
|
||||||
|
|
||||||
|
This package cannot be used in the "Expo Go" app because [it requires custom native code](https://docs.expo.io/workflow/customizing/).
|
||||||
|
|
||||||
|
- First install the package with yarn, npm, or [`expo install`](https://docs.expo.io/workflow/expo-cli/#expo-install).
|
||||||
|
|
||||||
|
```sh
|
||||||
|
expo install react-native-siri-shortcut @config-plugins/react-native-siri-shortcut
|
||||||
|
```
|
||||||
|
|
||||||
|
After installing this npm package, add the [config plugin](https://docs.expo.io/guides/config-plugins/) to the [`plugins`](https://docs.expo.io/versions/latest/config/app/#plugins) array of your `app.json` or `app.config.js`:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"expo": {
|
||||||
|
"plugins": ["@config-plugins/react-native-siri-shortcut"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, rebuild your app as described in the ["Adding custom native code"](https://docs.expo.io/workflow/customizing/) guide.
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
When working with Siri Shorcuts, you need to defined their identifiers on the Xcode project. To achieve the same result using this plugin, just pass an array of strings with the identifiers of your shortcuts, and they will be added automatically during the build cycle:
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"expo": {
|
||||||
|
"plugins": [
|
||||||
|
[
|
||||||
|
"@config-plugins/react-native-siri-shortcut",
|
||||||
|
[
|
||||||
|
"com.example.InitiateWorkout",
|
||||||
|
"com.example.FinishWorkout",
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("./build/withReactNativeSiriShortcut");
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"name": "@config-plugins/react-native-siri-shortcut",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "Config plugin for react-native-siri-shortcut package",
|
||||||
|
"main": "build/withReactNativeSiriShortcut.js",
|
||||||
|
"types": "build/withReactNativeSiriShortcut.d.ts",
|
||||||
|
"sideEffects": false,
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/expo/config-plugins.git",
|
||||||
|
"directory": "packages/react-native-siri-shortcut"
|
||||||
|
},
|
||||||
|
"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-siri-shortcut",
|
||||||
|
"expo-42"
|
||||||
|
],
|
||||||
|
"jest": {
|
||||||
|
"preset": "expo-module-scripts"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@expo/config-plugins": "^4.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"expo-module-scripts": "^2.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
import {
|
||||||
|
ConfigPlugin,
|
||||||
|
createRunOncePlugin,
|
||||||
|
withAppDelegate,
|
||||||
|
withInfoPlist,
|
||||||
|
withEntitlementsPlist,
|
||||||
|
} from "@expo/config-plugins";
|
||||||
|
import {
|
||||||
|
mergeContents,
|
||||||
|
MergeResults,
|
||||||
|
} from "@expo/config-plugins/build/utils/generateCode";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply react-native-siri-shortcut configuration for Expo SDK 44 projects.
|
||||||
|
*/
|
||||||
|
const withReactNativeSiriShortcut: ConfigPlugin<void | string[]> = (
|
||||||
|
config,
|
||||||
|
activityTypes
|
||||||
|
) => {
|
||||||
|
config = withSiriShortcutAppDelegate(config);
|
||||||
|
|
||||||
|
const items = activityTypes || [];
|
||||||
|
|
||||||
|
if (!Array.isArray(items) || !items.length) {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
return withInfoPlist(config, (config) => {
|
||||||
|
config.modResults.NSUserActivityTypes = items;
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export function addSiriShortcutAppDelegateImport(src: string): MergeResults {
|
||||||
|
return mergeContents({
|
||||||
|
tag: "react-native-siri-shortcut",
|
||||||
|
src,
|
||||||
|
newSrc: "#import <RNSiriShortcuts/RNSiriShortcuts.h>",
|
||||||
|
anchor: /#import "AppDelegate\.h"/,
|
||||||
|
offset: 1,
|
||||||
|
comment: "//",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addSiriShortcutAppDelegateInit(src: string): MergeResults {
|
||||||
|
const newSrc = [];
|
||||||
|
newSrc.push(
|
||||||
|
" BOOL shortcutResult = [RNSSSiriShortcuts application:application continueUserActivity:userActivity restorationHandler:restorationHandler];",
|
||||||
|
" if (shortcutResult) {",
|
||||||
|
" return [super application:application continueUserActivity:userActivity restorationHandler:restorationHandler] || shortcutResult;",
|
||||||
|
" }"
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(src);
|
||||||
|
return mergeContents({
|
||||||
|
tag: "react-native-siri-shortcut-delegate",
|
||||||
|
src,
|
||||||
|
newSrc: newSrc.join("\n"),
|
||||||
|
anchor:
|
||||||
|
/ return \[super application:application continueUserActivity:userActivity restorationHandler:restorationHandler\] \|\| result;/,
|
||||||
|
offset: -1,
|
||||||
|
comment: "//",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const withSiriEntitlements: ConfigPlugin = (config) => {
|
||||||
|
return withEntitlementsPlist(config, (config) => {
|
||||||
|
config.modResults["com.apple.developer.siri"] = true;
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const withSiriShortcutAppDelegate: ConfigPlugin = (config) => {
|
||||||
|
let cfg = withAppDelegate(config, (config) => {
|
||||||
|
if (["objc", "objcpp"].includes(config.modResults.language)) {
|
||||||
|
try {
|
||||||
|
config.modResults.contents = addSiriShortcutAppDelegateImport(
|
||||||
|
config.modResults.contents
|
||||||
|
).contents;
|
||||||
|
config.modResults.contents = addSiriShortcutAppDelegateInit(
|
||||||
|
config.modResults.contents
|
||||||
|
).contents;
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error.code === "ERR_NO_MATCH") {
|
||||||
|
throw new Error(
|
||||||
|
`Cannot add Siri Shortcut 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 Siri Shortcut because the AppDelegate is not Objective C"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
cfg = withSiriEntitlements(cfg);
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
};
|
||||||
|
|
||||||
|
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-siri-shortcut` to a future
|
||||||
|
// upstream plugin in `react-native-siri-shortcut`
|
||||||
|
name: "react-native-siri-shortcut",
|
||||||
|
// 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(
|
||||||
|
withReactNativeSiriShortcut,
|
||||||
|
pkg.name,
|
||||||
|
pkg.version
|
||||||
|
);
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "expo-module-scripts/tsconfig.plugin",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": "./build"
|
||||||
|
},
|
||||||
|
"include": ["./src"],
|
||||||
|
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
|
||||||
|
}
|
||||||
@@ -1402,7 +1402,7 @@
|
|||||||
node-forge "^1.2.1"
|
node-forge "^1.2.1"
|
||||||
nullthrows "^1.1.1"
|
nullthrows "^1.1.1"
|
||||||
|
|
||||||
"@expo/[email protected]", "@expo/[email protected]", "@expo/[email protected]", "@expo/[email protected]", "@expo/config-plugins@^4.0.14", "@expo/config-plugins@~4.1.4":
|
"@expo/[email protected]", "@expo/[email protected]", "@expo/[email protected]", "@expo/[email protected]", "@expo/config-plugins@^4.0.14", "@expo/config-plugins@^4.1.0", "@expo/config-plugins@~4.1.4":
|
||||||
version "4.1.4"
|
version "4.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/@expo/config-plugins/-/config-plugins-4.1.4.tgz#08e1a6314dc0f96cd165a748b5997b5ec75a84d0"
|
resolved "https://registry.yarnpkg.com/@expo/config-plugins/-/config-plugins-4.1.4.tgz#08e1a6314dc0f96cd165a748b5997b5ec75a84d0"
|
||||||
integrity sha512-fkOjXnSieQfVSWVLKhst0DnCAyeHksvWky1CldFCQllhDB1HHBiP09Z8pamVB783n3qr/1HNZiSp6k2iUcaSoA==
|
integrity sha512-fkOjXnSieQfVSWVLKhst0DnCAyeHksvWky1CldFCQllhDB1HHBiP09Z8pamVB783n3qr/1HNZiSp6k2iUcaSoA==
|
||||||
@@ -20118,8 +20118,10 @@ watchpack@^1.6.1:
|
|||||||
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.7.5.tgz#1267e6c55e0b9b5be44c2023aed5437a2c26c453"
|
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.7.5.tgz#1267e6c55e0b9b5be44c2023aed5437a2c26c453"
|
||||||
integrity sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ==
|
integrity sha512-9P3MWk6SrKjHsGkLT2KHXdQ/9SNkyoJbabxnKOoJepsvJjJG8uYTR3yTPxPQvNDI3w4Nz1xnE0TLHK4RIVe/MQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
|
chokidar "^3.4.1"
|
||||||
graceful-fs "^4.1.2"
|
graceful-fs "^4.1.2"
|
||||||
neo-async "^2.5.0"
|
neo-async "^2.5.0"
|
||||||
|
watchpack-chokidar2 "^2.0.1"
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
chokidar "^3.4.1"
|
chokidar "^3.4.1"
|
||||||
watchpack-chokidar2 "^2.0.1"
|
watchpack-chokidar2 "^2.0.1"
|
||||||
|
|||||||
Reference in new issue
Block a user