This commit is contained in:
Yamozha
2021-04-02 02:24:13 +03:00
parent c23950b545
commit 7256d79e2c
31493 changed files with 3036630 additions and 0 deletions

2
node_modules/expo-linking/.eslintrc.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
// @generated by expo-module-scripts
module.exports = require('expo-module-scripts/eslintrc.base.js');

48
node_modules/expo-linking/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,48 @@
# Changelog
## Unpublished
### 🛠 Breaking changes
### 🎉 New features
### 🐛 Bug fixes
## 2.0.1 — 2021-01-21
### 🎉 New features
- Added bare workflow support. ([#11560](https://github.com/expo/expo/pull/11560) by [@EvanBacon](https://github.com/EvanBacon))
- `Linking.createURL` creates URLs with two slashes in bare workflow. ([#11702](https://github.com/expo/expo/pull/11702) by [@EvanBacon](https://github.com/EvanBacon))
### 🐛 Bug fixes
- Removed `fbjs` dependency ([#11396](https://github.com/expo/expo/pull/11396) by [@cruzach](https://github.com/cruzach))
## 2.0.0 — 2020-12-08
_This version does not introduce any user-facing changes._
## 1.0.6 — 2020-11-17
### 🐛 Bug fixes
- Improved mechanism used to determine whether in bare or managed workflow. ([#10993](https://github.com/expo/expo/pull/10993) by [@esamelson](https://github.com/esamelson))
## 1.0.5 — 2020-10-22
### 🐛 Bug fixes
- Prevent crash in bare workflow if `Constants.manifest` isn't defined.
## 1.0.4 — 2020-08-18
_This version does not introduce any user-facing changes._
## 1.0.3 — 2020-05-29
_This version does not introduce any user-facing changes._
## 1.0.2 — 2020-05-27
_This version does not introduce any user-facing changes._

26
node_modules/expo-linking/README.md generated vendored Normal file
View File

@ -0,0 +1,26 @@
# expo-linking
Create and open deep links universally.
# API documentation
- [Documentation for the master branch](https://github.com/expo/expo/blob/master/docs/pages/versions/unversioned/sdk/linking.md)
- [Documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/linking/)
# Installation in managed Expo projects
For managed [managed](https://docs.expo.io/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.io/versions/latest/sdk/asset/). If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
# Installation in bare React Native projects
For bare React Native projects, you must ensure that you have [installed and configured the `react-native-unimodules` package](https://github.com/expo/expo/tree/master/packages/react-native-unimodules) before continuing.
### Add the package to your npm dependencies
```
expo install expo-linking
```
# Contributing
Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).

2
node_modules/expo-linking/build/ExpoLinking.d.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
import { Linking } from 'react-native';
export default Linking;

3
node_modules/expo-linking/build/ExpoLinking.js generated vendored Normal file
View File

@ -0,0 +1,3 @@
import { Linking } from 'react-native';
export default Linking;
//# sourceMappingURL=ExpoLinking.js.map

1
node_modules/expo-linking/build/ExpoLinking.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"ExpoLinking.js","sourceRoot":"","sources":["../src/ExpoLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,eAAe,OAAO,CAAC","sourcesContent":["import { Linking } from 'react-native';\nexport default Linking;\n"]}

9
node_modules/expo-linking/build/ExpoLinking.web.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
import { URLListener } from './Linking.types';
declare const _default: {
addEventListener(type: 'url', listener: URLListener): void;
removeEventListener(type: 'url', listener: URLListener): void;
canOpenURL(url: string): Promise<boolean>;
getInitialURL(): Promise<string>;
openURL(url: string): Promise<void>;
};
export default _default;

36
node_modules/expo-linking/build/ExpoLinking.web.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
import { Platform } from '@unimodules/core';
import invariant from 'invariant';
const EventTypes = ['url'];
const listeners = [];
export default {
addEventListener(type, listener) {
invariant(EventTypes.indexOf(type) !== -1, `Linking.addEventListener(): ${type} is not a valid event`);
const nativeListener = nativeEvent => listener({ url: window.location.href, nativeEvent });
listeners.push({ listener, nativeListener });
window.addEventListener('message', nativeListener, false);
},
removeEventListener(type, listener) {
invariant(EventTypes.indexOf(type) !== -1, `Linking.removeEventListener(): ${type} is not a valid event.`);
const listenerIndex = listeners.findIndex(pair => pair.listener === listener);
invariant(listenerIndex !== -1, 'Linking.removeEventListener(): cannot remove an unregistered event listener.');
const nativeListener = listeners[listenerIndex].nativeListener;
window.removeEventListener('message', nativeListener, false);
listeners.splice(listenerIndex, 1);
},
async canOpenURL(url) {
// In reality this should be able to return false for links like `chrome://` on chrome.
return true;
},
async getInitialURL() {
if (!Platform.isDOMAvailable)
return '';
return window.location.href;
},
async openURL(url) {
if (Platform.isDOMAvailable) {
// @ts-ignore
window.location = new URL(url, window.location).toString();
}
},
};
//# sourceMappingURL=ExpoLinking.web.js.map

View File

@ -0,0 +1 @@
{"version":3,"file":"ExpoLinking.web.js","sourceRoot":"","sources":["../src/ExpoLinking.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,SAAS,MAAM,WAAW,CAAC;AAIlC,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,CAAC;AAE3B,MAAM,SAAS,GAAmE,EAAE,CAAC;AAErF,eAAe;IACb,gBAAgB,CAAC,IAAW,EAAE,QAAqB;QACjD,SAAS,CACP,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAC/B,+BAA+B,IAAI,uBAAuB,CAC3D,CAAC;QACF,MAAM,cAAc,GAAsB,WAAW,CAAC,EAAE,CACtD,QAAQ,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QACvD,SAAS,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;IAC5D,CAAC;IAED,mBAAmB,CAAC,IAAW,EAAE,QAAqB;QACpD,SAAS,CACP,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAC/B,kCAAkC,IAAI,wBAAwB,CAC/D,CAAC;QACF,MAAM,aAAa,GAAG,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC;QAC9E,SAAS,CACP,aAAa,KAAK,CAAC,CAAC,EACpB,8EAA8E,CAC/E,CAAC;QACF,MAAM,cAAc,GAAG,SAAS,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC;QAC/D,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QAC7D,SAAS,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,GAAW;QAC1B,uFAAuF;QACvF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,aAAa;QACjB,IAAI,CAAC,QAAQ,CAAC,cAAc;YAAE,OAAO,EAAE,CAAC;QACxC,OAAO,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW;QACvB,IAAI,QAAQ,CAAC,cAAc,EAAE;YAC3B,aAAa;YACb,MAAM,CAAC,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC;SAC5D;IACH,CAAC;CACF,CAAC","sourcesContent":["import { Platform } from '@unimodules/core';\nimport invariant from 'invariant';\n\nimport { NativeURLListener, URLListener } from './Linking.types';\n\nconst EventTypes = ['url'];\n\nconst listeners: { listener: URLListener; nativeListener: NativeURLListener }[] = [];\n\nexport default {\n addEventListener(type: 'url', listener: URLListener): void {\n invariant(\n EventTypes.indexOf(type) !== -1,\n `Linking.addEventListener(): ${type} is not a valid event`\n );\n const nativeListener: NativeURLListener = nativeEvent =>\n listener({ url: window.location.href, nativeEvent });\n listeners.push({ listener, nativeListener });\n window.addEventListener('message', nativeListener, false);\n },\n\n removeEventListener(type: 'url', listener: URLListener): void {\n invariant(\n EventTypes.indexOf(type) !== -1,\n `Linking.removeEventListener(): ${type} is not a valid event.`\n );\n const listenerIndex = listeners.findIndex(pair => pair.listener === listener);\n invariant(\n listenerIndex !== -1,\n 'Linking.removeEventListener(): cannot remove an unregistered event listener.'\n );\n const nativeListener = listeners[listenerIndex].nativeListener;\n window.removeEventListener('message', nativeListener, false);\n listeners.splice(listenerIndex, 1);\n },\n\n async canOpenURL(url: string): Promise<boolean> {\n // In reality this should be able to return false for links like `chrome://` on chrome.\n return true;\n },\n\n async getInitialURL(): Promise<string> {\n if (!Platform.isDOMAvailable) return '';\n return window.location.href;\n },\n\n async openURL(url: string): Promise<void> {\n if (Platform.isDOMAvailable) {\n // @ts-ignore\n window.location = new URL(url, window.location).toString();\n }\n },\n};\n"]}

98
node_modules/expo-linking/build/Linking.d.ts generated vendored Normal file
View File

@ -0,0 +1,98 @@
import { ParsedURL, QueryParams, URLListener } from './Linking.types';
/**
* Create a URL that works for the environment the app is currently running in.
* The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.
*
* **Examples**
*
* - Bare: empty string
* - Standalone, Custom: `yourscheme:///path`
* - Web (dev): `https://localhost:19006/path`
* - Web (prod): `https://myapp.com/path`
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
*
* @param path addition path components to append to the base URL.
* @param queryParams An object of parameters that will be converted into a query string.
*/
export declare function makeUrl(path?: string, queryParams?: QueryParams, scheme?: string): string;
/**
* Create a URL that works for the environment the app is currently running in.
* The scheme in bare and standalone must be defined in the Expo config (app.config.js or app.json) under `expo.scheme`.
*
* **Examples**
*
* - Bare: `<scheme>://path` -- uses provided scheme or scheme from Expo config `scheme`.
* - Standalone, Custom: `yourscheme://path`
* - Web (dev): `https://localhost:19006/path`
* - Web (prod): `https://myapp.com/path`
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
*
* @param path addition path components to append to the base URL.
* @param scheme URI protocol `<scheme>://` that must be built into your native app.
* @param queryParams An object of parameters that will be converted into a query string.
*/
export declare function createURL(path: string, { scheme, queryParams, isTripleSlashed, }?: {
scheme?: string;
queryParams?: QueryParams;
isTripleSlashed?: boolean;
}): string;
/**
* Returns the components and query parameters for a given URL.
*
* @param url Input URL to parse
*/
export declare function parse(url: string): ParsedURL;
/**
* Add a handler to Linking changes by listening to the `url` event type
* and providing the handler
*
* See https://reactnative.dev/docs/linking.html#addeventlistener
*/
export declare function addEventListener(type: string, handler: URLListener): void;
/**
* Remove a handler by passing the `url` event type and the handler.
*
* See https://reactnative.dev/docs/linking.html#removeeventlistener
*/
export declare function removeEventListener(type: string, handler: URLListener): void;
/**
* **Native:** Parses the link that opened the app. If no link opened the app, all the fields will be \`null\`.
* **Web:** Parses the current window URL.
*/
export declare function parseInitialURLAsync(): Promise<ParsedURL>;
/**
* Launch an Android intent with optional extras
*
* @platform android
*/
export declare function sendIntent(action: string, extras?: {
key: string;
value: string | number | boolean;
}[]): Promise<void>;
/**
* Attempt to open the system settings for an the app.
*
* @platform ios
*/
export declare function openSettings(): Promise<void>;
/**
* If the app launch was triggered by an app link,
* it will give the link url, otherwise it will give `null`
*/
export declare function getInitialURL(): Promise<string | null>;
/**
* Try to open the given `url` with any of the installed apps.
*/
export declare function openURL(url: string): Promise<true>;
/**
* Determine whether or not an installed app can handle a given URL.
* On web this always returns true because there is no API for detecting what URLs can be opened.
*/
export declare function canOpenURL(url: string): Promise<boolean>;
/**
* Returns the initial URL followed by any subsequent changes to the URL.
*/
export declare function useUrl(): string | null;
export * from './Linking.types';

299
node_modules/expo-linking/build/Linking.js generated vendored Normal file
View File

@ -0,0 +1,299 @@
import { Platform, UnavailabilityError } from '@unimodules/core';
import Constants from 'expo-constants';
import invariant from 'invariant';
import qs from 'qs';
import { useEffect, useState } from 'react';
import URL from 'url-parse';
import NativeLinking from './ExpoLinking';
import { hasCustomScheme, resolveScheme } from './Schemes';
function validateURL(url) {
invariant(typeof url === 'string', 'Invalid URL: should be a string. Was: ' + url);
invariant(url, 'Invalid URL: cannot be empty');
}
function getHostUri() {
if (Constants.manifest?.hostUri) {
return Constants.manifest.hostUri;
}
else if (!Constants.manifest?.hostUri && !hasCustomScheme()) {
// we're probably not using up-to-date xdl, so just fake it for now
// we have to remove the /--/ on the end since this will be inserted again later
return removeScheme(Constants.linkingUri).replace(/\/--($|\/.*$)/, '');
}
else {
return null;
}
}
function isExpoHosted() {
const hostUri = getHostUri();
return !!(hostUri &&
(/^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(hostUri) ||
Constants.manifest?.developer));
}
function removeScheme(url) {
return url.replace(/^[a-zA-Z0-9+.-]+:\/\//, '');
}
function removePort(url) {
return url.replace(/(?=([a-zA-Z0-9+.-]+:\/\/)?[^/]):\d+/, '');
}
function removeLeadingSlash(url) {
return url.replace(/^\//, '');
}
function removeTrailingSlashAndQueryString(url) {
return url.replace(/\/?\?.*$/, '');
}
function ensureLeadingSlash(input, shouldAppend) {
const hasSlash = input.endsWith('/');
if (hasSlash && !shouldAppend) {
return input.substring(0, input.length - 1);
}
else if (!hasSlash && shouldAppend) {
return `${input}/`;
}
return input;
}
function ensureTrailingSlash(input, shouldAppend) {
const hasSlash = input.startsWith('/');
if (hasSlash && !shouldAppend) {
return input.substring(1);
}
else if (!hasSlash && shouldAppend) {
return `/${input}`;
}
return input;
}
/**
* Create a URL that works for the environment the app is currently running in.
* The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.
*
* **Examples**
*
* - Bare: empty string
* - Standalone, Custom: `yourscheme:///path`
* - Web (dev): `https://localhost:19006/path`
* - Web (prod): `https://myapp.com/path`
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
*
* @param path addition path components to append to the base URL.
* @param queryParams An object of parameters that will be converted into a query string.
*/
export function makeUrl(path = '', queryParams, scheme) {
return createURL(path, { queryParams, scheme, isTripleSlashed: true });
}
/**
* Create a URL that works for the environment the app is currently running in.
* The scheme in bare and standalone must be defined in the Expo config (app.config.js or app.json) under `expo.scheme`.
*
* **Examples**
*
* - Bare: `<scheme>://path` -- uses provided scheme or scheme from Expo config `scheme`.
* - Standalone, Custom: `yourscheme://path`
* - Web (dev): `https://localhost:19006/path`
* - Web (prod): `https://myapp.com/path`
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
*
* @param path addition path components to append to the base URL.
* @param scheme URI protocol `<scheme>://` that must be built into your native app.
* @param queryParams An object of parameters that will be converted into a query string.
*/
export function createURL(path, { scheme, queryParams = {}, isTripleSlashed = false, } = {}) {
if (Platform.OS === 'web') {
if (!Platform.isDOMAvailable)
return '';
const origin = ensureLeadingSlash(window.location.origin, false);
let queryString = qs.stringify(queryParams);
if (queryString) {
queryString = `?${queryString}`;
}
let outputPath = path;
if (outputPath)
outputPath = ensureTrailingSlash(path, true);
return encodeURI(`${origin}${outputPath}${queryString}`);
}
const resolvedScheme = resolveScheme({ scheme });
let hostUri = getHostUri() || '';
if (hasCustomScheme() && isExpoHosted()) {
hostUri = '';
}
if (path) {
if (isExpoHosted() && hostUri) {
path = `/--/${removeLeadingSlash(path)}`;
}
if (isTripleSlashed && !path.startsWith('/')) {
path = `/${path}`;
}
}
else {
path = '';
}
// merge user-provided query params with any that were already in the hostUri
// e.g. release-channel
let queryString = '';
const queryStringMatchResult = hostUri.match(/(.*)\?(.+)/);
if (queryStringMatchResult) {
hostUri = queryStringMatchResult[1];
queryString = queryStringMatchResult[2];
let paramsFromHostUri = {};
try {
const parsedParams = qs.parse(queryString);
if (typeof parsedParams === 'object') {
paramsFromHostUri = parsedParams;
}
}
catch (e) { }
queryParams = {
...queryParams,
...paramsFromHostUri,
};
}
queryString = qs.stringify(queryParams);
if (queryString) {
queryString = `?${queryString}`;
}
hostUri = ensureTrailingSlash(hostUri, !isTripleSlashed);
return encodeURI(`${resolvedScheme}:${isTripleSlashed ? '/' : ''}/${hostUri}${path}${queryString}`);
}
/**
* Returns the components and query parameters for a given URL.
*
* @param url Input URL to parse
*/
export function parse(url) {
validateURL(url);
const parsed = URL(url, /* parseQueryString */ true);
for (const param in parsed.query) {
parsed.query[param] = decodeURIComponent(parsed.query[param]);
}
const queryParams = parsed.query;
const hostUri = getHostUri() || '';
const hostUriStripped = removePort(removeTrailingSlashAndQueryString(hostUri));
let path = parsed.pathname || null;
let hostname = parsed.hostname || null;
let scheme = parsed.protocol || null;
if (scheme) {
// Remove colon at end
scheme = scheme.substring(0, scheme.length - 1);
}
if (path) {
path = removeLeadingSlash(path);
let expoPrefix = null;
if (hostUriStripped) {
const parts = hostUriStripped.split('/');
expoPrefix = parts
.slice(1)
.concat(['--/'])
.join('/');
}
if (isExpoHosted() && !hasCustomScheme() && expoPrefix && path.startsWith(expoPrefix)) {
path = path.substring(expoPrefix.length);
hostname = null;
}
else if (path.indexOf('+') > -1) {
path = path.substring(path.indexOf('+') + 1);
}
}
return {
hostname,
path,
queryParams,
scheme,
};
}
/**
* Add a handler to Linking changes by listening to the `url` event type
* and providing the handler
*
* See https://reactnative.dev/docs/linking.html#addeventlistener
*/
export function addEventListener(type, handler) {
NativeLinking.addEventListener(type, handler);
}
/**
* Remove a handler by passing the `url` event type and the handler.
*
* See https://reactnative.dev/docs/linking.html#removeeventlistener
*/
export function removeEventListener(type, handler) {
NativeLinking.removeEventListener(type, handler);
}
/**
* **Native:** Parses the link that opened the app. If no link opened the app, all the fields will be \`null\`.
* **Web:** Parses the current window URL.
*/
export async function parseInitialURLAsync() {
const initialUrl = await NativeLinking.getInitialURL();
if (!initialUrl) {
return {
scheme: null,
hostname: null,
path: null,
queryParams: null,
};
}
return parse(initialUrl);
}
/**
* Launch an Android intent with optional extras
*
* @platform android
*/
export async function sendIntent(action, extras) {
if (Platform.OS === 'android') {
return await NativeLinking.sendIntent(action, extras);
}
throw new UnavailabilityError('Linking', 'sendIntent');
}
/**
* Attempt to open the system settings for an the app.
*
* @platform ios
*/
export async function openSettings() {
if (Platform.OS === 'web') {
throw new UnavailabilityError('Linking', 'openSettings');
}
if (NativeLinking.openSettings) {
return await NativeLinking.openSettings();
}
await openURL('app-settings:');
}
/**
* If the app launch was triggered by an app link,
* it will give the link url, otherwise it will give `null`
*/
export async function getInitialURL() {
return (await NativeLinking.getInitialURL()) ?? null;
}
/**
* Try to open the given `url` with any of the installed apps.
*/
export async function openURL(url) {
validateURL(url);
return await NativeLinking.openURL(url);
}
/**
* Determine whether or not an installed app can handle a given URL.
* On web this always returns true because there is no API for detecting what URLs can be opened.
*/
export async function canOpenURL(url) {
validateURL(url);
return await NativeLinking.canOpenURL(url);
}
/**
* Returns the initial URL followed by any subsequent changes to the URL.
*/
export function useUrl() {
const [url, setLink] = useState(null);
function onChange(event) {
setLink(event.url);
}
useEffect(() => {
getInitialURL().then(url => setLink(url));
addEventListener('url', onChange);
return () => removeEventListener('url', onChange);
}, []);
return url;
}
export * from './Linking.types';
//# sourceMappingURL=Linking.js.map

1
node_modules/expo-linking/build/Linking.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

15
node_modules/expo-linking/build/Linking.types.d.ts generated vendored Normal file
View File

@ -0,0 +1,15 @@
export declare type QueryParams = {
[key: string]: string | undefined;
};
export declare type ParsedURL = {
scheme: string | null;
hostname: string | null;
path: string | null;
queryParams: QueryParams | null;
};
export declare type EventType = {
url: string;
nativeEvent?: MessageEvent;
};
export declare type URLListener = (event: EventType) => void;
export declare type NativeURLListener = (nativeEvent: MessageEvent) => void;

2
node_modules/expo-linking/build/Linking.types.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=Linking.types.js.map

1
node_modules/expo-linking/build/Linking.types.js.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"Linking.types.js","sourceRoot":"","sources":["../src/Linking.types.ts"],"names":[],"mappings":"","sourcesContent":["export type QueryParams = { [key: string]: string | undefined };\n\nexport type ParsedURL = {\n scheme: string | null;\n hostname: string | null;\n path: string | null;\n queryParams: QueryParams | null;\n};\n\nexport type EventType = { url: string; nativeEvent?: MessageEvent };\n\nexport type URLListener = (event: EventType) => void;\n\nexport type NativeURLListener = (nativeEvent: MessageEvent) => void;\n"]}

15
node_modules/expo-linking/build/Schemes.d.ts generated vendored Normal file
View File

@ -0,0 +1,15 @@
export declare function hasCustomScheme(): boolean;
/**
* Collect a list of platform schemes from the manifest.
*
* This method is based on the `Scheme` modules from `@expo/config-plugins`
* which are used for collecting the schemes before prebuilding a native app.
*
* - iOS: scheme -> ios.scheme -> ios.bundleIdentifier
* - Android: scheme -> android.scheme -> android.package
*/
export declare function collectManifestSchemes(): string[];
export declare function hasConstantsManifest(): boolean;
export declare function resolveScheme(props: {
scheme?: string;
}): string;

158
node_modules/expo-linking/build/Schemes.js generated vendored Normal file
View File

@ -0,0 +1,158 @@
import { Platform } from '@unimodules/core';
import Constants, { ExecutionEnvironment } from 'expo-constants';
export function hasCustomScheme() {
if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
// Bare always uses a custom scheme.
return true;
}
else if (Constants.executionEnvironment === ExecutionEnvironment.Standalone) {
// Standalone uses a custom scheme when one is defined.
const manifestSchemes = collectManifestSchemes();
return !!manifestSchemes.length;
}
// Store client uses the default scheme.
return false;
}
function getSchemes(config) {
if (config) {
if (Array.isArray(config.scheme)) {
const validate = (value) => {
return typeof value === 'string';
};
return config.scheme.filter(validate);
}
else if (typeof config.scheme === 'string') {
return [config.scheme];
}
}
return [];
}
// Valid schemes for the Expo client.
const EXPO_CLIENT_SCHEMES = Platform.select({
// Results from `npx uri-scheme list --info-path ios/Exponent/Supporting/Info.plist`
ios: [
'exp',
'exps',
'fb1696089354000816',
'host.exp.exponent',
'com.googleusercontent.apps.603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9',
],
// Collected manually
android: ['exp', 'exps'],
});
/**
* Collect a list of platform schemes from the manifest.
*
* This method is based on the `Scheme` modules from `@expo/config-plugins`
* which are used for collecting the schemes before prebuilding a native app.
*
* - iOS: scheme -> ios.scheme -> ios.bundleIdentifier
* - Android: scheme -> android.scheme -> android.package
*/
export function collectManifestSchemes() {
// ios.scheme, android.scheme, and scheme as an array are not yet added to the
// Expo config spec, but there's no harm in adding them early.
// They'll be added when we drop support for `expo build` or decide
// to have them only work with `eas build`.
const platformManifest = Platform.select({
ios: Constants.manifest?.ios,
android: Constants.manifest?.android,
web: {},
}) ?? {};
const schemes = getSchemes(Constants.manifest);
// Add the detached scheme after the manifest scheme for legacy ExpoKit support.
if (Constants.manifest?.detach?.scheme) {
schemes.push(Constants.manifest.detach.scheme);
}
// Add the unimplemented platform schemes last.
schemes.push(...getSchemes(platformManifest));
return schemes;
}
function getNativeAppIdScheme() {
// Add the native application identifier to the list of schemes for parity with `expo build`.
// The native app id has been added to builds for a long time to support Google Sign-In.
return (Platform.select({
ios: Constants.manifest?.ios?.bundleIdentifier,
// TODO: This may change to android.applicationId in the future.
android: Constants.manifest?.android?.package,
}) ?? null);
}
export function hasConstantsManifest() {
// Ensure the user has linked the expo-constants manifest in bare workflow.
return !!Object.keys(Constants.manifest ?? {}).length;
}
export function resolveScheme(props) {
if (Constants.executionEnvironment !== ExecutionEnvironment.StoreClient &&
!hasConstantsManifest()) {
throw new Error(`expo-linking needs access to the expo-constants manifest (app.json or app.config.js) to determine what URI scheme to use. Setup the manifest and rebuild: https://github.com/expo/expo/blob/master/packages/expo-constants/README.md`);
}
const manifestSchemes = collectManifestSchemes();
const nativeAppId = getNativeAppIdScheme();
if (!manifestSchemes.length) {
if (__DEV__) {
// Assert a config warning if no scheme is setup yet.
console.warn(`Linking requires a build-time setting \`scheme\` in the project's Expo config (app.config.js or app.json) for production apps, if it's left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. Learn more: https://docs.expo.io/versions/latest/workflow/linking/`);
}
else {
// Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`
throw new Error('Cannot make a deep link into a standalone app with no custom scheme defined');
}
}
// In the Expo client...
if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
if (props.scheme) {
// This enables users to use the fb or google redirects on iOS in the Expo client.
if (EXPO_CLIENT_SCHEMES.includes(props.scheme)) {
return props.scheme;
}
// Silently ignore to make bare workflow development easier.
}
// Fallback to the default client scheme.
return 'exp';
}
const schemes = [...manifestSchemes, nativeAppId];
if (props.scheme) {
if (__DEV__) {
// Bare workflow development assertion about the provided scheme matching the Expo config.
if (schemes.includes(props.scheme)) {
// TODO: Will this cause issues for things like Facebook or Google that use `reversed-client-id://` or `fb<FBID>:/`?
// Traditionally these APIs don't use the Linking API directly.
console.warn(`The provided Linking scheme '${props.scheme}' does not appear in the list of possible URI schemes in your Expo config. Expected one of: ${schemes.join(', ')}.`);
}
}
// Return the user provided value.
return props.scheme;
}
// If no scheme is provided, we'll guess what the scheme is based on the manifest.
// This is to attempt to keep managed apps working across expo build and EAS build.
// EAS build ejects the app before building it so we can assume that the user will
// be using one of defined schemes.
// If the native app id is the only scheme,
if (!!nativeAppId && !manifestSchemes.length) {
// Assert a config warning if no scheme is setup yet.
// This warning only applies to managed workflow EAS apps, as bare workflow
console.warn(`Linking requires a build-time setting \`scheme\` in the project's Expo config (app.config.js or app.json) for bare or production apps. Manually providing a \`scheme\` property can circumvent this warning. Using native app identifier as the scheme '${nativeAppId}'. Learn more: https://docs.expo.io/versions/latest/workflow/linking/`);
return nativeAppId;
}
// When the native app id is defined, it'll be added to the list of schemes, for most
// users this will be unexpected behavior and cause all apps to warn when the Linking API
// is used without a predefined scheme. For now, if the native app id is defined, require
// at least one more scheme to be added before throwing a warning.
// i.e. `scheme: ['foo', 'bar']` (unimplemented functionality).
const [scheme, ...extraSchemes] = manifestSchemes;
if (!scheme) {
const errorMessage = `Linking requires a build-time setting \`scheme\` in the project's Expo config (app.config.js or app.json) for bare or production apps. Manually providing a \`scheme\` property can circumvent this error. Learn more: https://docs.expo.io/versions/latest/workflow/linking/`;
// Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`
throw new Error(errorMessage);
}
if (extraSchemes.length) {
console.warn(`Linking found multiple possible URI schemes in your Expo config.\nUsing '${scheme}'. Ignoring: ${[
...extraSchemes,
nativeAppId,
]
.filter(Boolean)
.join(', ')}.\nPlease supply the preferred URI scheme to the Linking API.`);
}
return scheme;
}
//# sourceMappingURL=Schemes.js.map

1
node_modules/expo-linking/build/Schemes.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

49
node_modules/expo-linking/package.json generated vendored Normal file
View File

@ -0,0 +1,49 @@
{
"name": "expo-linking",
"version": "2.0.1",
"description": "Create and open deep links universally",
"main": "build/Linking.js",
"types": "build/Linking.d.ts",
"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-native",
"expo",
"expo-linking"
],
"repository": {
"type": "git",
"url": "https://github.com/expo/expo.git",
"directory": "packages/expo-linking"
},
"bugs": {
"url": "https://github.com/expo/expo/issues"
},
"author": "650 Industries, Inc.",
"license": "MIT",
"homepage": "https://docs.expo.io/versions/latest/sdk/linking",
"dependencies": {
"expo-constants": "~9.3.3",
"invariant": "^2.2.4",
"qs": "^6.5.0",
"url-parse": "^1.4.4"
},
"peerDependencies": {
"react-native": "*"
},
"devDependencies": {
"@types/qs": "^6.5.3",
"expo-module-scripts": "^1.2.0"
},
"jest": {
"preset": "expo-module-scripts"
},
"gitHead": "99e491260ccd7bd27c060b82247e475ce275deda"
}

2
node_modules/expo-linking/src/ExpoLinking.ts generated vendored Normal file
View File

@ -0,0 +1,2 @@
import { Linking } from 'react-native';
export default Linking;

53
node_modules/expo-linking/src/ExpoLinking.web.ts generated vendored Normal file
View File

@ -0,0 +1,53 @@
import { Platform } from '@unimodules/core';
import invariant from 'invariant';
import { NativeURLListener, URLListener } from './Linking.types';
const EventTypes = ['url'];
const listeners: { listener: URLListener; nativeListener: NativeURLListener }[] = [];
export default {
addEventListener(type: 'url', listener: URLListener): void {
invariant(
EventTypes.indexOf(type) !== -1,
`Linking.addEventListener(): ${type} is not a valid event`
);
const nativeListener: NativeURLListener = nativeEvent =>
listener({ url: window.location.href, nativeEvent });
listeners.push({ listener, nativeListener });
window.addEventListener('message', nativeListener, false);
},
removeEventListener(type: 'url', listener: URLListener): void {
invariant(
EventTypes.indexOf(type) !== -1,
`Linking.removeEventListener(): ${type} is not a valid event.`
);
const listenerIndex = listeners.findIndex(pair => pair.listener === listener);
invariant(
listenerIndex !== -1,
'Linking.removeEventListener(): cannot remove an unregistered event listener.'
);
const nativeListener = listeners[listenerIndex].nativeListener;
window.removeEventListener('message', nativeListener, false);
listeners.splice(listenerIndex, 1);
},
async canOpenURL(url: string): Promise<boolean> {
// In reality this should be able to return false for links like `chrome://` on chrome.
return true;
},
async getInitialURL(): Promise<string> {
if (!Platform.isDOMAvailable) return '';
return window.location.href;
},
async openURL(url: string): Promise<void> {
if (Platform.isDOMAvailable) {
// @ts-ignore
window.location = new URL(url, window.location).toString();
}
},
};

354
node_modules/expo-linking/src/Linking.ts generated vendored Normal file
View File

@ -0,0 +1,354 @@
import { Platform, UnavailabilityError } from '@unimodules/core';
import Constants from 'expo-constants';
import invariant from 'invariant';
import qs from 'qs';
import { useEffect, useState } from 'react';
import URL from 'url-parse';
import NativeLinking from './ExpoLinking';
import { ParsedURL, QueryParams, URLListener } from './Linking.types';
import { hasCustomScheme, resolveScheme } from './Schemes';
function validateURL(url: string): void {
invariant(typeof url === 'string', 'Invalid URL: should be a string. Was: ' + url);
invariant(url, 'Invalid URL: cannot be empty');
}
function getHostUri(): string | null {
if (Constants.manifest?.hostUri) {
return Constants.manifest.hostUri;
} else if (!Constants.manifest?.hostUri && !hasCustomScheme()) {
// we're probably not using up-to-date xdl, so just fake it for now
// we have to remove the /--/ on the end since this will be inserted again later
return removeScheme(Constants.linkingUri).replace(/\/--($|\/.*$)/, '');
} else {
return null;
}
}
function isExpoHosted(): boolean {
const hostUri = getHostUri();
return !!(
hostUri &&
(/^(.*\.)?(expo\.io|exp\.host|exp\.direct|expo\.test)(:.*)?(\/.*)?$/.test(hostUri) ||
Constants.manifest?.developer)
);
}
function removeScheme(url: string): string {
return url.replace(/^[a-zA-Z0-9+.-]+:\/\//, '');
}
function removePort(url: string): string {
return url.replace(/(?=([a-zA-Z0-9+.-]+:\/\/)?[^/]):\d+/, '');
}
function removeLeadingSlash(url: string): string {
return url.replace(/^\//, '');
}
function removeTrailingSlashAndQueryString(url: string): string {
return url.replace(/\/?\?.*$/, '');
}
function ensureLeadingSlash(input: string, shouldAppend: boolean): string {
const hasSlash = input.endsWith('/');
if (hasSlash && !shouldAppend) {
return input.substring(0, input.length - 1);
} else if (!hasSlash && shouldAppend) {
return `${input}/`;
}
return input;
}
function ensureTrailingSlash(input: string, shouldAppend: boolean): string {
const hasSlash = input.startsWith('/');
if (hasSlash && !shouldAppend) {
return input.substring(1);
} else if (!hasSlash && shouldAppend) {
return `/${input}`;
}
return input;
}
/**
* Create a URL that works for the environment the app is currently running in.
* The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.
*
* **Examples**
*
* - Bare: empty string
* - Standalone, Custom: `yourscheme:///path`
* - Web (dev): `https://localhost:19006/path`
* - Web (prod): `https://myapp.com/path`
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
*
* @param path addition path components to append to the base URL.
* @param queryParams An object of parameters that will be converted into a query string.
*/
export function makeUrl(path: string = '', queryParams?: QueryParams, scheme?: string): string {
return createURL(path, { queryParams, scheme, isTripleSlashed: true });
}
/**
* Create a URL that works for the environment the app is currently running in.
* The scheme in bare and standalone must be defined in the Expo config (app.config.js or app.json) under `expo.scheme`.
*
* **Examples**
*
* - Bare: `<scheme>://path` -- uses provided scheme or scheme from Expo config `scheme`.
* - Standalone, Custom: `yourscheme://path`
* - Web (dev): `https://localhost:19006/path`
* - Web (prod): `https://myapp.com/path`
* - Expo Client (dev): `exp://128.0.0.1:19000/--/path`
* - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`
*
* @param path addition path components to append to the base URL.
* @param scheme URI protocol `<scheme>://` that must be built into your native app.
* @param queryParams An object of parameters that will be converted into a query string.
*/
export function createURL(
path: string,
{
scheme,
queryParams = {},
isTripleSlashed = false,
}: {
scheme?: string;
queryParams?: QueryParams;
isTripleSlashed?: boolean;
} = {}
): string {
if (Platform.OS === 'web') {
if (!Platform.isDOMAvailable) return '';
const origin = ensureLeadingSlash(window.location.origin, false);
let queryString = qs.stringify(queryParams);
if (queryString) {
queryString = `?${queryString}`;
}
let outputPath = path;
if (outputPath) outputPath = ensureTrailingSlash(path, true);
return encodeURI(`${origin}${outputPath}${queryString}`);
}
const resolvedScheme = resolveScheme({ scheme });
let hostUri = getHostUri() || '';
if (hasCustomScheme() && isExpoHosted()) {
hostUri = '';
}
if (path) {
if (isExpoHosted() && hostUri) {
path = `/--/${removeLeadingSlash(path)}`;
}
if (isTripleSlashed && !path.startsWith('/')) {
path = `/${path}`;
}
} else {
path = '';
}
// merge user-provided query params with any that were already in the hostUri
// e.g. release-channel
let queryString = '';
const queryStringMatchResult = hostUri.match(/(.*)\?(.+)/);
if (queryStringMatchResult) {
hostUri = queryStringMatchResult[1];
queryString = queryStringMatchResult[2];
let paramsFromHostUri = {};
try {
const parsedParams = qs.parse(queryString);
if (typeof parsedParams === 'object') {
paramsFromHostUri = parsedParams;
}
} catch (e) {}
queryParams = {
...queryParams,
...paramsFromHostUri,
};
}
queryString = qs.stringify(queryParams);
if (queryString) {
queryString = `?${queryString}`;
}
hostUri = ensureTrailingSlash(hostUri, !isTripleSlashed);
return encodeURI(
`${resolvedScheme}:${isTripleSlashed ? '/' : ''}/${hostUri}${path}${queryString}`
);
}
/**
* Returns the components and query parameters for a given URL.
*
* @param url Input URL to parse
*/
export function parse(url: string): ParsedURL {
validateURL(url);
const parsed = URL(url, /* parseQueryString */ true);
for (const param in parsed.query) {
parsed.query[param] = decodeURIComponent(parsed.query[param]!);
}
const queryParams = parsed.query;
const hostUri = getHostUri() || '';
const hostUriStripped = removePort(removeTrailingSlashAndQueryString(hostUri));
let path = parsed.pathname || null;
let hostname = parsed.hostname || null;
let scheme = parsed.protocol || null;
if (scheme) {
// Remove colon at end
scheme = scheme.substring(0, scheme.length - 1);
}
if (path) {
path = removeLeadingSlash(path);
let expoPrefix: string | null = null;
if (hostUriStripped) {
const parts = hostUriStripped.split('/');
expoPrefix = parts
.slice(1)
.concat(['--/'])
.join('/');
}
if (isExpoHosted() && !hasCustomScheme() && expoPrefix && path.startsWith(expoPrefix)) {
path = path.substring(expoPrefix.length);
hostname = null;
} else if (path.indexOf('+') > -1) {
path = path.substring(path.indexOf('+') + 1);
}
}
return {
hostname,
path,
queryParams,
scheme,
};
}
/**
* Add a handler to Linking changes by listening to the `url` event type
* and providing the handler
*
* See https://reactnative.dev/docs/linking.html#addeventlistener
*/
export function addEventListener(type: string, handler: URLListener) {
NativeLinking.addEventListener(type, handler);
}
/**
* Remove a handler by passing the `url` event type and the handler.
*
* See https://reactnative.dev/docs/linking.html#removeeventlistener
*/
export function removeEventListener(type: string, handler: URLListener) {
NativeLinking.removeEventListener(type, handler);
}
/**
* **Native:** Parses the link that opened the app. If no link opened the app, all the fields will be \`null\`.
* **Web:** Parses the current window URL.
*/
export async function parseInitialURLAsync(): Promise<ParsedURL> {
const initialUrl = await NativeLinking.getInitialURL();
if (!initialUrl) {
return {
scheme: null,
hostname: null,
path: null,
queryParams: null,
};
}
return parse(initialUrl);
}
/**
* Launch an Android intent with optional extras
*
* @platform android
*/
export async function sendIntent(
action: string,
extras?: { key: string; value: string | number | boolean }[]
): Promise<void> {
if (Platform.OS === 'android') {
return await NativeLinking.sendIntent(action, extras);
}
throw new UnavailabilityError('Linking', 'sendIntent');
}
/**
* Attempt to open the system settings for an the app.
*
* @platform ios
*/
export async function openSettings(): Promise<void> {
if (Platform.OS === 'web') {
throw new UnavailabilityError('Linking', 'openSettings');
}
if (NativeLinking.openSettings) {
return await NativeLinking.openSettings();
}
await openURL('app-settings:');
}
/**
* If the app launch was triggered by an app link,
* it will give the link url, otherwise it will give `null`
*/
export async function getInitialURL(): Promise<string | null> {
return (await NativeLinking.getInitialURL()) ?? null;
}
/**
* Try to open the given `url` with any of the installed apps.
*/
export async function openURL(url: string): Promise<true> {
validateURL(url);
return await NativeLinking.openURL(url);
}
/**
* Determine whether or not an installed app can handle a given URL.
* On web this always returns true because there is no API for detecting what URLs can be opened.
*/
export async function canOpenURL(url: string): Promise<boolean> {
validateURL(url);
return await NativeLinking.canOpenURL(url);
}
/**
* Returns the initial URL followed by any subsequent changes to the URL.
*/
export function useUrl(): string | null {
const [url, setLink] = useState<string | null>(null);
function onChange(event: { url: string }) {
setLink(event.url);
}
useEffect(() => {
getInitialURL().then(url => setLink(url));
addEventListener('url', onChange);
return () => removeEventListener('url', onChange);
}, []);
return url;
}
export * from './Linking.types';

14
node_modules/expo-linking/src/Linking.types.ts generated vendored Normal file
View File

@ -0,0 +1,14 @@
export type QueryParams = { [key: string]: string | undefined };
export type ParsedURL = {
scheme: string | null;
hostname: string | null;
path: string | null;
queryParams: QueryParams | null;
};
export type EventType = { url: string; nativeEvent?: MessageEvent };
export type URLListener = (event: EventType) => void;
export type NativeURLListener = (nativeEvent: MessageEvent) => void;

193
node_modules/expo-linking/src/Schemes.ts generated vendored Normal file
View File

@ -0,0 +1,193 @@
import { Platform } from '@unimodules/core';
import Constants, { ExecutionEnvironment } from 'expo-constants';
export function hasCustomScheme(): boolean {
if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
// Bare always uses a custom scheme.
return true;
} else if (Constants.executionEnvironment === ExecutionEnvironment.Standalone) {
// Standalone uses a custom scheme when one is defined.
const manifestSchemes = collectManifestSchemes();
return !!manifestSchemes.length;
}
// Store client uses the default scheme.
return false;
}
function getSchemes(config: { scheme?: string | string[] }): string[] {
if (config) {
if (Array.isArray(config.scheme)) {
const validate = (value: any): value is string => {
return typeof value === 'string';
};
return config.scheme.filter<string>(validate);
} else if (typeof config.scheme === 'string') {
return [config.scheme];
}
}
return [];
}
// Valid schemes for the Expo client.
const EXPO_CLIENT_SCHEMES = Platform.select({
// Results from `npx uri-scheme list --info-path ios/Exponent/Supporting/Info.plist`
ios: [
'exp',
'exps',
'fb1696089354000816',
'host.exp.exponent',
'com.googleusercontent.apps.603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9',
],
// Collected manually
android: ['exp', 'exps'],
});
/**
* Collect a list of platform schemes from the manifest.
*
* This method is based on the `Scheme` modules from `@expo/config-plugins`
* which are used for collecting the schemes before prebuilding a native app.
*
* - iOS: scheme -> ios.scheme -> ios.bundleIdentifier
* - Android: scheme -> android.scheme -> android.package
*/
export function collectManifestSchemes(): string[] {
// ios.scheme, android.scheme, and scheme as an array are not yet added to the
// Expo config spec, but there's no harm in adding them early.
// They'll be added when we drop support for `expo build` or decide
// to have them only work with `eas build`.
const platformManifest =
Platform.select({
ios: Constants.manifest?.ios,
android: Constants.manifest?.android,
web: {},
}) ?? {};
const schemes = getSchemes(Constants.manifest as any);
// Add the detached scheme after the manifest scheme for legacy ExpoKit support.
if (Constants.manifest?.detach?.scheme) {
schemes.push(Constants.manifest.detach.scheme);
}
// Add the unimplemented platform schemes last.
schemes.push(...getSchemes(platformManifest));
return schemes;
}
function getNativeAppIdScheme(): string | null {
// Add the native application identifier to the list of schemes for parity with `expo build`.
// The native app id has been added to builds for a long time to support Google Sign-In.
return (
Platform.select({
ios: Constants.manifest?.ios?.bundleIdentifier,
// TODO: This may change to android.applicationId in the future.
android: Constants.manifest?.android?.package,
}) ?? null
);
}
export function hasConstantsManifest(): boolean {
// Ensure the user has linked the expo-constants manifest in bare workflow.
return !!Object.keys(Constants.manifest ?? {}).length;
}
export function resolveScheme(props: { scheme?: string }): string {
if (
Constants.executionEnvironment !== ExecutionEnvironment.StoreClient &&
!hasConstantsManifest()
) {
throw new Error(
`expo-linking needs access to the expo-constants manifest (app.json or app.config.js) to determine what URI scheme to use. Setup the manifest and rebuild: https://github.com/expo/expo/blob/master/packages/expo-constants/README.md`
);
}
const manifestSchemes = collectManifestSchemes();
const nativeAppId = getNativeAppIdScheme();
if (!manifestSchemes.length) {
if (__DEV__) {
// Assert a config warning if no scheme is setup yet.
console.warn(
`Linking requires a build-time setting \`scheme\` in the project's Expo config (app.config.js or app.json) for production apps, if it's left blank, your app may crash. The scheme does not apply to development in the Expo client but you should add it as soon as you start working with Linking to avoid creating a broken build. Learn more: https://docs.expo.io/versions/latest/workflow/linking/`
);
} else {
// Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`
throw new Error(
'Cannot make a deep link into a standalone app with no custom scheme defined'
);
}
}
// In the Expo client...
if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
if (props.scheme) {
// This enables users to use the fb or google redirects on iOS in the Expo client.
if (EXPO_CLIENT_SCHEMES.includes(props.scheme)) {
return props.scheme;
}
// Silently ignore to make bare workflow development easier.
}
// Fallback to the default client scheme.
return 'exp';
}
const schemes = [...manifestSchemes, nativeAppId];
if (props.scheme) {
if (__DEV__) {
// Bare workflow development assertion about the provided scheme matching the Expo config.
if (schemes.includes(props.scheme)) {
// TODO: Will this cause issues for things like Facebook or Google that use `reversed-client-id://` or `fb<FBID>:/`?
// Traditionally these APIs don't use the Linking API directly.
console.warn(
`The provided Linking scheme '${
props.scheme
}' does not appear in the list of possible URI schemes in your Expo config. Expected one of: ${schemes.join(
', '
)}.`
);
}
}
// Return the user provided value.
return props.scheme;
}
// If no scheme is provided, we'll guess what the scheme is based on the manifest.
// This is to attempt to keep managed apps working across expo build and EAS build.
// EAS build ejects the app before building it so we can assume that the user will
// be using one of defined schemes.
// If the native app id is the only scheme,
if (!!nativeAppId && !manifestSchemes.length) {
// Assert a config warning if no scheme is setup yet.
// This warning only applies to managed workflow EAS apps, as bare workflow
console.warn(
`Linking requires a build-time setting \`scheme\` in the project's Expo config (app.config.js or app.json) for bare or production apps. Manually providing a \`scheme\` property can circumvent this warning. Using native app identifier as the scheme '${nativeAppId}'. Learn more: https://docs.expo.io/versions/latest/workflow/linking/`
);
return nativeAppId;
}
// When the native app id is defined, it'll be added to the list of schemes, for most
// users this will be unexpected behavior and cause all apps to warn when the Linking API
// is used without a predefined scheme. For now, if the native app id is defined, require
// at least one more scheme to be added before throwing a warning.
// i.e. `scheme: ['foo', 'bar']` (unimplemented functionality).
const [scheme, ...extraSchemes] = manifestSchemes;
if (!scheme) {
const errorMessage = `Linking requires a build-time setting \`scheme\` in the project's Expo config (app.config.js or app.json) for bare or production apps. Manually providing a \`scheme\` property can circumvent this error. Learn more: https://docs.expo.io/versions/latest/workflow/linking/`;
// Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`
throw new Error(errorMessage);
}
if (extraSchemes.length) {
console.warn(
`Linking found multiple possible URI schemes in your Expo config.\nUsing '${scheme}'. Ignoring: ${[
...extraSchemes,
nativeAppId,
]
.filter(Boolean)
.join(', ')}.\nPlease supply the preferred URI scheme to the Linking API.`
);
}
return scheme;
}

8
node_modules/expo-linking/tsconfig.json generated vendored Normal file
View File

@ -0,0 +1,8 @@
{
"extends": "../expo-module-scripts/tsconfig.base",
"compilerOptions": {
"outDir": "./build"
},
"include": ["./src"],
"exclude": ["**/__mocks__/*", "**/__tests__/*"]
}