expo-linking 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +3 -3
- package/build/ExpoLinking.d.ts +1 -0
- package/build/ExpoLinking.d.ts.map +1 -0
- package/build/ExpoLinking.web.d.ts +1 -0
- package/build/ExpoLinking.web.d.ts.map +1 -0
- package/build/Linking.d.ts +7 -3
- package/build/Linking.d.ts.map +1 -0
- package/build/Linking.js +7 -5
- package/build/Linking.js.map +1 -1
- package/build/Linking.types.d.ts +1 -0
- package/build/Linking.types.d.ts.map +1 -0
- package/build/Schemes.d.ts +5 -1
- package/build/Schemes.d.ts.map +1 -0
- package/build/Schemes.js +19 -14
- package/build/Schemes.js.map +1 -1
- package/package.json +4 -4
- package/src/Linking.ts +10 -7
- package/src/Schemes.ts +19 -14
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,21 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 3.1.0 — 2022-04-18
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- `addEventListener` returns `EmitterSubscription` rather than `void` ([#17014](https://github.com/expo/expo/pull/17014) by [@frankcalise](https://github.com/frankcalise))
|
|
18
|
+
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- `addEventListener` and `removeEventListener` only accept `'url'` as `type` param, rather than `string`
|
|
22
|
+
- `useURL` hook now cleans up `addEventListener` via `remove` rather than `removeEventListener` ([#17014](https://github.com/expo/expo/pull/17014) by [@frankcalise](https://github.com/frankcalise))
|
|
23
|
+
|
|
24
|
+
### 💡 Others
|
|
25
|
+
|
|
26
|
+
- Export public `Schemes` methods in main file. ([#17058](https://github.com/expo/expo/pull/17058) by [@Simek](https://github.com/Simek))
|
|
27
|
+
|
|
13
28
|
## 3.0.0 — 2021-12-03
|
|
14
29
|
|
|
15
30
|
### 🛠 Breaking changes
|
package/README.md
CHANGED
|
@@ -4,12 +4,12 @@ Create and open deep links universally.
|
|
|
4
4
|
|
|
5
5
|
# API documentation
|
|
6
6
|
|
|
7
|
-
- [Documentation for the
|
|
8
|
-
- [Documentation for the latest stable release](https://docs.expo.
|
|
7
|
+
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/linking.md)
|
|
8
|
+
- [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/linking/)
|
|
9
9
|
|
|
10
10
|
# Installation in managed Expo projects
|
|
11
11
|
|
|
12
|
-
For
|
|
12
|
+
For [managed](https://docs.expo.dev/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.dev/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.
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
package/build/ExpoLinking.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLinking.d.ts","sourceRoot":"","sources":["../src/ExpoLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExpoLinking.web.d.ts","sourceRoot":"","sources":["../src/ExpoLinking.web.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,WAAW,EAAE,MAAM,iBAAiB,CAAC;;2BAOxC,KAAK,YAAY,WAAW,GAAG,IAAI;8BAWhC,KAAK,YAAY,WAAW,GAAG,IAAI;oBAevC,MAAM,GAAG,QAAQ,OAAO,CAAC;qBAKxB,QAAQ,MAAM,CAAC;iBAKnB,MAAM,GAAG,QAAQ,IAAI,CAAC;;AArC3C,wBA2CE"}
|
package/build/Linking.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EmitterSubscription } from 'react-native';
|
|
1
2
|
import { CreateURLOptions, ParsedURL, QueryParams, SendIntentExtras, URLListener } from './Linking.types';
|
|
2
3
|
/**
|
|
3
4
|
* Create a URL that works for the environment the app is currently running in.
|
|
@@ -54,9 +55,10 @@ export declare function parse(url: string): ParsedURL;
|
|
|
54
55
|
* @param type The only valid type is `'url'`.
|
|
55
56
|
* @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type
|
|
56
57
|
* [`EventType`](#eventype).
|
|
58
|
+
* @return An EmitterSubscription that has the remove method from EventSubscription
|
|
57
59
|
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#addeventlistener).
|
|
58
60
|
*/
|
|
59
|
-
export declare function addEventListener(type:
|
|
61
|
+
export declare function addEventListener(type: 'url', handler: URLListener): EmitterSubscription;
|
|
60
62
|
/**
|
|
61
63
|
* Remove a handler by passing the `url` event type and the handler.
|
|
62
64
|
* @param type The only valid type is `'url'`.
|
|
@@ -64,7 +66,7 @@ export declare function addEventListener(type: string, handler: URLListener): vo
|
|
|
64
66
|
* [`EventType`](#eventype).
|
|
65
67
|
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#removeeventlistener).
|
|
66
68
|
*/
|
|
67
|
-
export declare function removeEventListener(type:
|
|
69
|
+
export declare function removeEventListener(type: 'url', handler: URLListener): void;
|
|
68
70
|
/**
|
|
69
71
|
* Helper method which wraps React Native's `Linking.getInitialURL()` in `Linking.parse()`.
|
|
70
72
|
* Parses the deep link information out of the URL used to open the experience initially.
|
|
@@ -75,7 +77,7 @@ export declare function removeEventListener(type: string, handler: URLListener):
|
|
|
75
77
|
export declare function parseInitialURLAsync(): Promise<ParsedURL>;
|
|
76
78
|
/**
|
|
77
79
|
* Launch an Android intent with extras.
|
|
78
|
-
* > Use [IntentLauncher](
|
|
80
|
+
* > Use [IntentLauncher](./intent-launcher) instead, `sendIntent` is only included in
|
|
79
81
|
* > `Linking` for API compatibility with React Native's Linking API.
|
|
80
82
|
* @platform android
|
|
81
83
|
*/
|
|
@@ -116,3 +118,5 @@ export declare function canOpenURL(url: string): Promise<boolean>;
|
|
|
116
118
|
*/
|
|
117
119
|
export declare function useURL(): string | null;
|
|
118
120
|
export * from './Linking.types';
|
|
121
|
+
export * from './Schemes';
|
|
122
|
+
//# sourceMappingURL=Linking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Linking.d.ts","sourceRoot":"","sources":["../src/Linking.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAInD,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAoEzB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,OAAO,CAAC,IAAI,GAAE,MAAW,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAE7F;AAGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,MAAM,EACZ,EAAE,MAAM,EAAE,WAAgB,EAAE,eAAuB,EAAE,GAAE,gBAAqB,GAC3E,MAAM,CAgER;AAGD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CA6C5C;AAGD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,GAAG,mBAAmB,CAEvF;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI,CAE3E;AAGD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,SAAS,CAAC,CAY/D;AAGD;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3F;AAGD;;;GAGG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAQlD;AAGD;;;GAGG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE5D;AAGD;;;;;;;GAOG;AACH,wBAAsB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxD;AAGD;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAG9D;AAGD;;;GAGG;AACH,wBAAgB,MAAM,IAAI,MAAM,GAAG,IAAI,CActC;AAED,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC"}
|
package/build/Linking.js
CHANGED
|
@@ -154,7 +154,7 @@ export function createURL(path, { scheme, queryParams = {}, isTripleSlashed = fa
|
|
|
154
154
|
paramsFromHostUri = parsedParams;
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
catch
|
|
157
|
+
catch { }
|
|
158
158
|
queryParams = {
|
|
159
159
|
...queryParams,
|
|
160
160
|
...paramsFromHostUri,
|
|
@@ -218,10 +218,11 @@ export function parse(url) {
|
|
|
218
218
|
* @param type The only valid type is `'url'`.
|
|
219
219
|
* @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type
|
|
220
220
|
* [`EventType`](#eventype).
|
|
221
|
+
* @return An EmitterSubscription that has the remove method from EventSubscription
|
|
221
222
|
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#addeventlistener).
|
|
222
223
|
*/
|
|
223
224
|
export function addEventListener(type, handler) {
|
|
224
|
-
NativeLinking.addEventListener(type, handler);
|
|
225
|
+
return NativeLinking.addEventListener(type, handler);
|
|
225
226
|
}
|
|
226
227
|
/**
|
|
227
228
|
* Remove a handler by passing the `url` event type and the handler.
|
|
@@ -256,7 +257,7 @@ export async function parseInitialURLAsync() {
|
|
|
256
257
|
// @needsAudit
|
|
257
258
|
/**
|
|
258
259
|
* Launch an Android intent with extras.
|
|
259
|
-
* > Use [IntentLauncher](
|
|
260
|
+
* > Use [IntentLauncher](./intent-launcher) instead, `sendIntent` is only included in
|
|
260
261
|
* > `Linking` for API compatibility with React Native's Linking API.
|
|
261
262
|
* @platform android
|
|
262
263
|
*/
|
|
@@ -328,10 +329,11 @@ export function useURL() {
|
|
|
328
329
|
}
|
|
329
330
|
useEffect(() => {
|
|
330
331
|
getInitialURL().then((url) => setLink(url));
|
|
331
|
-
addEventListener('url', onChange);
|
|
332
|
-
return () =>
|
|
332
|
+
const subscription = addEventListener('url', onChange);
|
|
333
|
+
return () => subscription.remove();
|
|
333
334
|
}, []);
|
|
334
335
|
return url;
|
|
335
336
|
}
|
|
336
337
|
export * from './Linking.types';
|
|
338
|
+
export * from './Schemes';
|
|
337
339
|
//# sourceMappingURL=Linking.js.map
|
package/build/Linking.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Linking.js","sourceRoot":"","sources":["../src/Linking.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,GAAG,MAAM,WAAW,CAAC;AAE5B,OAAO,aAAa,MAAM,eAAe,CAAC;AAQ1C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE3D,SAAS,WAAW,CAAC,GAAW;IAC9B,SAAS,CAAC,OAAO,GAAG,KAAK,QAAQ,EAAE,wCAAwC,GAAG,GAAG,CA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KAAK,UAAU,OAAO,CAAC,GAAW;IACvC,WAAW,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAC1C,CAAC;AAED,cAAc;AACd;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,WAAW,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,MAAM,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC7C,CAAC;AAED,cAAc;AACd;;;GAGG;AACH,MAAM,UAAU,MAAM;IACpB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAErD,SAAS,QAAQ,CAAC,KAAsB;QACtC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,SAAS,CAAC,GAAG,EAAE;QACb,aAAa,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAClC,OAAO,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpD,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,GAAG,CAAC;AACb,CAAC;AAED,cAAc,iBAAiB,CAAC","sourcesContent":["import Constants from 'expo-constants';\nimport { Platform, UnavailabilityError } from 'expo-modules-core';\nimport invariant from 'invariant';\nimport qs from 'qs';\nimport { useEffect, useState } from 'react';\nimport URL from 'url-parse';\n\nimport NativeLinking from './ExpoLinking';\nimport {\n CreateURLOptions,\n ParsedURL,\n QueryParams,\n SendIntentExtras,\n URLListener,\n} from './Linking.types';\nimport { hasCustomScheme, resolveScheme } from './Schemes';\n\nfunction validateURL(url: string): void {\n invariant(typeof url === 'string', 'Invalid URL: should be a string. Was: ' + url);\n invariant(url, 'Invalid URL: cannot be empty');\n}\n\nfunction getHostUri(): string | null {\n if (Constants.manifest?.hostUri) {\n return Constants.manifest.hostUri;\n } else if (Constants.manifest2?.extra?.expoClient?.hostUri) {\n return Constants.manifest2.extra.expoClient.hostUri;\n } else if (!hasCustomScheme()) {\n // we're probably not using up-to-date xdl, so just fake it for now\n // we have to remove the /--/ on the end since this will be inserted again later\n return removeScheme(Constants.linkingUri).replace(/\\/--($|\\/.*$)/, '');\n } else {\n return null;\n }\n}\n\nfunction isExpoHosted(): boolean {\n const hostUri = getHostUri();\n return !!(\n hostUri &&\n (/^(.*\\.)?(expo\\.io|exp\\.host|exp\\.direct|expo\\.test)(:.*)?(\\/.*)?$/.test(hostUri) ||\n Constants.manifest?.developer)\n );\n}\n\nfunction removeScheme(url: string): string {\n return url.replace(/^[a-zA-Z0-9+.-]+:\\/\\//, '');\n}\n\nfunction removePort(url: string): string {\n return url.replace(/(?=([a-zA-Z0-9+.-]+:\\/\\/)?[^/]):\\d+/, '');\n}\n\nfunction removeLeadingSlash(url: string): string {\n return url.replace(/^\\//, '');\n}\n\nfunction removeTrailingSlashAndQueryString(url: string): string {\n return url.replace(/\\/?\\?.*$/, '');\n}\n\nfunction ensureTrailingSlash(input: string, shouldAppend: boolean): string {\n const hasSlash = input.endsWith('/');\n if (hasSlash && !shouldAppend) {\n return input.substring(0, input.length - 1);\n } else if (!hasSlash && shouldAppend) {\n return `${input}/`;\n }\n return input;\n}\n\nfunction ensureLeadingSlash(input: string, shouldAppend: boolean): string {\n const hasSlash = input.startsWith('/');\n if (hasSlash && !shouldAppend) {\n return input.substring(1);\n } else if (!hasSlash && shouldAppend) {\n return `/${input}`;\n }\n return input;\n}\n\n// @needsAudit\n/**\n * Create a URL that works for the environment the app is currently running in.\n * The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.\n *\n * # Examples\n * - Bare: empty string\n * - Standalone, Custom: `yourscheme:///path`\n * - Web (dev): `https://localhost:19006/path`\n * - Web (prod): `https://myapp.com/path`\n * - Expo Client (dev): `exp://128.0.0.1:19000/--/path`\n * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`\n *\n * @param path addition path components to append to the base URL.\n * @param queryParams An object with a set of query parameters. These will be merged with any\n * Expo-specific parameters that are needed (e.g. release channel) and then appended to the URL\n * as a query string.\n * @param scheme Optional URI protocol to use in the URL `<scheme>:///`, when `undefined` the scheme\n * will be chosen from the Expo config (`app.config.js` or `app.json`).\n * @return A URL string which points to your app with the given deep link information.\n * @deprecated An alias for [`createURL()`](#linkingcreateurlpath-namedparameters). This method is\n * deprecated and will be removed in a future SDK version.\n */\nexport function makeUrl(path: string = '', queryParams?: QueryParams, scheme?: string): string {\n return createURL(path, { queryParams, scheme, isTripleSlashed: true });\n}\n\n// @needsAudit\n/**\n * Helper method for constructing a deep link into your app, given an optional path and set of query\n * parameters. Creates a URI scheme with two slashes by default.\n *\n * The scheme in bare and standalone must be defined in the Expo config (`app.config.js` or `app.json`)\n * under `expo.scheme`.\n *\n * # Examples\n * - Bare: `<scheme>://path` - uses provided scheme or scheme from Expo config `scheme`.\n * - Standalone, Custom: `yourscheme://path`\n * - Web (dev): `https://localhost:19006/path`\n * - Web (prod): `https://myapp.com/path`\n * - Expo Client (dev): `exp://128.0.0.1:19000/--/path`\n * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`\n *\n * @param path Addition path components to append to the base URL.\n * @param namedParameters Additional options object.\n * @return A URL string which points to your app with the given deep link information.\n */\nexport function createURL(\n path: string,\n { scheme, queryParams = {}, isTripleSlashed = false }: CreateURLOptions = {}\n): string {\n if (Platform.OS === 'web') {\n if (!Platform.isDOMAvailable) return '';\n\n const origin = ensureTrailingSlash(window.location.origin, false);\n let queryString = qs.stringify(queryParams);\n if (queryString) {\n queryString = `?${queryString}`;\n }\n\n let outputPath = path;\n if (outputPath) outputPath = ensureLeadingSlash(path, true);\n\n return encodeURI(`${origin}${outputPath}${queryString}`);\n }\n\n const resolvedScheme = resolveScheme({ scheme });\n\n let hostUri = getHostUri() || '';\n\n if (hasCustomScheme() && isExpoHosted()) {\n hostUri = '';\n }\n\n if (path) {\n if (isExpoHosted() && hostUri) {\n path = `/--/${removeLeadingSlash(path)}`;\n }\n if (isTripleSlashed && !path.startsWith('/')) {\n path = `/${path}`;\n }\n } else {\n path = '';\n }\n\n // merge user-provided query params with any that were already in the hostUri\n // e.g. release-channel\n let queryString = '';\n const queryStringMatchResult = hostUri.match(/(.*)\\?(.+)/);\n if (queryStringMatchResult) {\n hostUri = queryStringMatchResult[1];\n queryString = queryStringMatchResult[2];\n let paramsFromHostUri = {};\n try {\n const parsedParams = qs.parse(queryString);\n if (typeof parsedParams === 'object') {\n paramsFromHostUri = parsedParams;\n }\n } catch (e) {}\n queryParams = {\n ...queryParams,\n ...paramsFromHostUri,\n };\n }\n queryString = qs.stringify(queryParams);\n if (queryString) {\n queryString = `?${queryString}`;\n }\n\n hostUri = ensureLeadingSlash(hostUri, !isTripleSlashed);\n\n return encodeURI(\n `${resolvedScheme}:${isTripleSlashed ? '/' : ''}/${hostUri}${path}${queryString}`\n );\n}\n\n// @needsAudit\n/**\n * Helper method for parsing out deep link information from a URL.\n * @param url A URL that points to the currently running experience (e.g. an output of `Linking.createURL()`).\n * @return A `ParsedURL` object.\n */\nexport function parse(url: string): ParsedURL {\n validateURL(url);\n\n const parsed = URL(url, /* parseQueryString */ true);\n\n for (const param in parsed.query) {\n parsed.query[param] = decodeURIComponent(parsed.query[param]!);\n }\n const queryParams = parsed.query;\n\n const hostUri = getHostUri() || '';\n const hostUriStripped = removePort(removeTrailingSlashAndQueryString(hostUri));\n\n let path = parsed.pathname || null;\n let hostname = parsed.hostname || null;\n let scheme = parsed.protocol || null;\n\n if (scheme) {\n // Remove colon at end\n scheme = scheme.substring(0, scheme.length - 1);\n }\n\n if (path) {\n path = removeLeadingSlash(path);\n\n let expoPrefix: string | null = null;\n if (hostUriStripped) {\n const parts = hostUriStripped.split('/');\n expoPrefix = parts.slice(1).concat(['--/']).join('/');\n }\n\n if (isExpoHosted() && !hasCustomScheme() && expoPrefix && path.startsWith(expoPrefix)) {\n path = path.substring(expoPrefix.length);\n hostname = null;\n } else if (path.indexOf('+') > -1) {\n path = path.substring(path.indexOf('+') + 1);\n }\n }\n\n return {\n hostname,\n path,\n queryParams,\n scheme,\n };\n}\n\n// @needsAudit\n/**\n * Add a handler to `Linking` changes by listening to the `url` event type and providing the handler.\n * It is recommended to use the [`useURL()`](#useurl) hook instead.\n * @param type The only valid type is `'url'`.\n * @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type\n * [`EventType`](#eventype).\n * @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#addeventlistener).\n */\nexport function addEventListener(type: string, handler: URLListener): void {\n NativeLinking.addEventListener(type, handler);\n}\n\n/**\n * Remove a handler by passing the `url` event type and the handler.\n * @param type The only valid type is `'url'`.\n * @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type\n * [`EventType`](#eventype).\n * @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#removeeventlistener).\n */\nexport function removeEventListener(type: string, handler: URLListener): void {\n NativeLinking.removeEventListener(type, handler);\n}\n\n// @needsAudit\n/**\n * Helper method which wraps React Native's `Linking.getInitialURL()` in `Linking.parse()`.\n * Parses the deep link information out of the URL used to open the experience initially.\n * If no link opened the app, all the fields will be `null`.\n * > On the web it parses the current window URL.\n * @return A promise that resolves with `ParsedURL` object.\n */\nexport async function parseInitialURLAsync(): Promise<ParsedURL> {\n const initialUrl = await NativeLinking.getInitialURL();\n if (!initialUrl) {\n return {\n scheme: null,\n hostname: null,\n path: null,\n queryParams: null,\n };\n }\n\n return parse(initialUrl);\n}\n\n// @needsAudit\n/**\n * Launch an Android intent with extras.\n * > Use [IntentLauncher](../intent-launcher) instead, `sendIntent` is only included in\n * > `Linking` for API compatibility with React Native's Linking API.\n * @platform android\n */\nexport async function sendIntent(action: string, extras?: SendIntentExtras[]): Promise<void> {\n if (Platform.OS === 'android') {\n return await NativeLinking.sendIntent(action, extras);\n }\n throw new UnavailabilityError('Linking', 'sendIntent');\n}\n\n// @needsAudit\n/**\n * Open the operating system settings app and displays the app’s custom settings, if it has any.\n * @platform ios\n */\nexport async function openSettings(): Promise<void> {\n if (Platform.OS === 'web') {\n throw new UnavailabilityError('Linking', 'openSettings');\n }\n if (NativeLinking.openSettings) {\n return await NativeLinking.openSettings();\n }\n await openURL('app-settings:');\n}\n\n// @needsAudit\n/**\n * Get the URL that was used to launch the app if it was launched by a link.\n * @return The URL string that launched your app, or `null`.\n */\nexport async function getInitialURL(): Promise<string | null> {\n return (await NativeLinking.getInitialURL()) ?? null;\n}\n\n// @needsAudit\n/**\n * Attempt to open the given URL with an installed app. See the [Linking guide](/guides/linking)\n * for more information.\n * @param url A URL for the operating system to open, eg: `tel:5555555`, `exp://`.\n * @return A `Promise` that is fulfilled with `true` if the link is opened operating system\n * automatically or the user confirms the prompt to open the link. The `Promise` rejects if there\n * are no applications registered for the URL or the user cancels the dialog.\n */\nexport async function openURL(url: string): Promise<true> {\n validateURL(url);\n return await NativeLinking.openURL(url);\n}\n\n// @needsAudit\n/**\n * Determine whether or not an installed app can handle a given URL.\n * On web this always returns `true` because there is no API for detecting what URLs can be opened.\n * @param url The URL that you want to test can be opened.\n * @return A `Promise` object that is fulfilled with `true` if the URL can be handled, otherwise it\n * `false` if not.\n *\n * The `Promise` will reject on Android if it was impossible to check if the URL can be opened, and\n * on iOS if you didn't [add the specific scheme in the `LSApplicationQueriesSchemes` key inside **Info.plist**](/guides/linking#opening-links-to-other-apps).\n */\nexport async function canOpenURL(url: string): Promise<boolean> {\n validateURL(url);\n return await NativeLinking.canOpenURL(url);\n}\n\n// @needsAudit\n/**\n * Returns the initial URL followed by any subsequent changes to the URL.\n * @return Returns the initial URL or `null`.\n */\nexport function useURL(): string | null {\n const [url, setLink] = useState<string | null>(null);\n\n function onChange(event: { url: string }) {\n setLink(event.url);\n }\n\n useEffect(() => {\n getInitialURL().then((url) => setLink(url));\n addEventListener('url', onChange);\n return () => removeEventListener('url', onChange);\n }, []);\n\n return url;\n}\n\nexport * from './Linking.types';\n"]}
|
|
1
|
+
{"version":3,"file":"Linking.js","sourceRoot":"","sources":["../src/Linking.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,GAAG,MAAM,WAAW,CAAC;AAE5B,OAAO,aAAa,MAAM,eAAe,CAAC;AAQ1C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE3D,SAAS,WAAW,CAAC,GAAW;IAC9B,SAAS,CAAC,OAAO,GAAG,KAAK,QAAQ,EAAE,wCAAwC,GAAG,GAAG,CAAC,CAAC;IACnF,SAAS,CAAC,GAAG,EAAE,8BAA8B,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,UAAU;IACjB,IAAI,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE;QAC/B,OAAO,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;KACnC;SAAM,IAAI,SAAS,CAAC,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE;QAC1D,OAAO,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;KACrD;SAAM,IAAI,CAAC,eAAe,EAAE,EAAE;QAC7B,mEAAmE;QACnE,gFAAgF;QAChF,OAAO,YAAY,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;KACxE;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,SAAS,YAAY;IACnB,MAAM,OAAO,GAA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I,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,GAAG,CAAC;AACb,CAAC;AAED,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC","sourcesContent":["import Constants from 'expo-constants';\nimport { Platform, UnavailabilityError } from 'expo-modules-core';\nimport invariant from 'invariant';\nimport qs from 'qs';\nimport { useEffect, useState } from 'react';\nimport { EmitterSubscription } from 'react-native';\nimport URL from 'url-parse';\n\nimport NativeLinking from './ExpoLinking';\nimport {\n CreateURLOptions,\n ParsedURL,\n QueryParams,\n SendIntentExtras,\n URLListener,\n} from './Linking.types';\nimport { hasCustomScheme, resolveScheme } from './Schemes';\n\nfunction validateURL(url: string): void {\n invariant(typeof url === 'string', 'Invalid URL: should be a string. Was: ' + url);\n invariant(url, 'Invalid URL: cannot be empty');\n}\n\nfunction getHostUri(): string | null {\n if (Constants.manifest?.hostUri) {\n return Constants.manifest.hostUri;\n } else if (Constants.manifest2?.extra?.expoClient?.hostUri) {\n return Constants.manifest2.extra.expoClient.hostUri;\n } else if (!hasCustomScheme()) {\n // we're probably not using up-to-date xdl, so just fake it for now\n // we have to remove the /--/ on the end since this will be inserted again later\n return removeScheme(Constants.linkingUri).replace(/\\/--($|\\/.*$)/, '');\n } else {\n return null;\n }\n}\n\nfunction isExpoHosted(): boolean {\n const hostUri = getHostUri();\n return !!(\n hostUri &&\n (/^(.*\\.)?(expo\\.io|exp\\.host|exp\\.direct|expo\\.test)(:.*)?(\\/.*)?$/.test(hostUri) ||\n Constants.manifest?.developer)\n );\n}\n\nfunction removeScheme(url: string): string {\n return url.replace(/^[a-zA-Z0-9+.-]+:\\/\\//, '');\n}\n\nfunction removePort(url: string): string {\n return url.replace(/(?=([a-zA-Z0-9+.-]+:\\/\\/)?[^/]):\\d+/, '');\n}\n\nfunction removeLeadingSlash(url: string): string {\n return url.replace(/^\\//, '');\n}\n\nfunction removeTrailingSlashAndQueryString(url: string): string {\n return url.replace(/\\/?\\?.*$/, '');\n}\n\nfunction ensureTrailingSlash(input: string, shouldAppend: boolean): string {\n const hasSlash = input.endsWith('/');\n if (hasSlash && !shouldAppend) {\n return input.substring(0, input.length - 1);\n } else if (!hasSlash && shouldAppend) {\n return `${input}/`;\n }\n return input;\n}\n\nfunction ensureLeadingSlash(input: string, shouldAppend: boolean): string {\n const hasSlash = input.startsWith('/');\n if (hasSlash && !shouldAppend) {\n return input.substring(1);\n } else if (!hasSlash && shouldAppend) {\n return `/${input}`;\n }\n return input;\n}\n\n// @needsAudit\n/**\n * Create a URL that works for the environment the app is currently running in.\n * The scheme in bare and standalone must be defined in the app.json under `expo.scheme`.\n *\n * # Examples\n * - Bare: empty string\n * - Standalone, Custom: `yourscheme:///path`\n * - Web (dev): `https://localhost:19006/path`\n * - Web (prod): `https://myapp.com/path`\n * - Expo Client (dev): `exp://128.0.0.1:19000/--/path`\n * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`\n *\n * @param path addition path components to append to the base URL.\n * @param queryParams An object with a set of query parameters. These will be merged with any\n * Expo-specific parameters that are needed (e.g. release channel) and then appended to the URL\n * as a query string.\n * @param scheme Optional URI protocol to use in the URL `<scheme>:///`, when `undefined` the scheme\n * will be chosen from the Expo config (`app.config.js` or `app.json`).\n * @return A URL string which points to your app with the given deep link information.\n * @deprecated An alias for [`createURL()`](#linkingcreateurlpath-namedparameters). This method is\n * deprecated and will be removed in a future SDK version.\n */\nexport function makeUrl(path: string = '', queryParams?: QueryParams, scheme?: string): string {\n return createURL(path, { queryParams, scheme, isTripleSlashed: true });\n}\n\n// @needsAudit\n/**\n * Helper method for constructing a deep link into your app, given an optional path and set of query\n * parameters. Creates a URI scheme with two slashes by default.\n *\n * The scheme in bare and standalone must be defined in the Expo config (`app.config.js` or `app.json`)\n * under `expo.scheme`.\n *\n * # Examples\n * - Bare: `<scheme>://path` - uses provided scheme or scheme from Expo config `scheme`.\n * - Standalone, Custom: `yourscheme://path`\n * - Web (dev): `https://localhost:19006/path`\n * - Web (prod): `https://myapp.com/path`\n * - Expo Client (dev): `exp://128.0.0.1:19000/--/path`\n * - Expo Client (prod): `exp://exp.host/@yourname/your-app/--/path`\n *\n * @param path Addition path components to append to the base URL.\n * @param namedParameters Additional options object.\n * @return A URL string which points to your app with the given deep link information.\n */\nexport function createURL(\n path: string,\n { scheme, queryParams = {}, isTripleSlashed = false }: CreateURLOptions = {}\n): string {\n if (Platform.OS === 'web') {\n if (!Platform.isDOMAvailable) return '';\n\n const origin = ensureTrailingSlash(window.location.origin, false);\n let queryString = qs.stringify(queryParams);\n if (queryString) {\n queryString = `?${queryString}`;\n }\n\n let outputPath = path;\n if (outputPath) outputPath = ensureLeadingSlash(path, true);\n\n return encodeURI(`${origin}${outputPath}${queryString}`);\n }\n\n const resolvedScheme = resolveScheme({ scheme });\n\n let hostUri = getHostUri() || '';\n\n if (hasCustomScheme() && isExpoHosted()) {\n hostUri = '';\n }\n\n if (path) {\n if (isExpoHosted() && hostUri) {\n path = `/--/${removeLeadingSlash(path)}`;\n }\n if (isTripleSlashed && !path.startsWith('/')) {\n path = `/${path}`;\n }\n } else {\n path = '';\n }\n\n // merge user-provided query params with any that were already in the hostUri\n // e.g. release-channel\n let queryString = '';\n const queryStringMatchResult = hostUri.match(/(.*)\\?(.+)/);\n if (queryStringMatchResult) {\n hostUri = queryStringMatchResult[1];\n queryString = queryStringMatchResult[2];\n let paramsFromHostUri = {};\n try {\n const parsedParams = qs.parse(queryString);\n if (typeof parsedParams === 'object') {\n paramsFromHostUri = parsedParams;\n }\n } catch {}\n queryParams = {\n ...queryParams,\n ...paramsFromHostUri,\n };\n }\n queryString = qs.stringify(queryParams);\n if (queryString) {\n queryString = `?${queryString}`;\n }\n\n hostUri = ensureLeadingSlash(hostUri, !isTripleSlashed);\n\n return encodeURI(\n `${resolvedScheme}:${isTripleSlashed ? '/' : ''}/${hostUri}${path}${queryString}`\n );\n}\n\n// @needsAudit\n/**\n * Helper method for parsing out deep link information from a URL.\n * @param url A URL that points to the currently running experience (e.g. an output of `Linking.createURL()`).\n * @return A `ParsedURL` object.\n */\nexport function parse(url: string): ParsedURL {\n validateURL(url);\n\n const parsed = URL(url, /* parseQueryString */ true);\n\n for (const param in parsed.query) {\n parsed.query[param] = decodeURIComponent(parsed.query[param]!);\n }\n const queryParams = parsed.query;\n\n const hostUri = getHostUri() || '';\n const hostUriStripped = removePort(removeTrailingSlashAndQueryString(hostUri));\n\n let path = parsed.pathname || null;\n let hostname = parsed.hostname || null;\n let scheme = parsed.protocol || null;\n\n if (scheme) {\n // Remove colon at end\n scheme = scheme.substring(0, scheme.length - 1);\n }\n\n if (path) {\n path = removeLeadingSlash(path);\n\n let expoPrefix: string | null = null;\n if (hostUriStripped) {\n const parts = hostUriStripped.split('/');\n expoPrefix = parts.slice(1).concat(['--/']).join('/');\n }\n\n if (isExpoHosted() && !hasCustomScheme() && expoPrefix && path.startsWith(expoPrefix)) {\n path = path.substring(expoPrefix.length);\n hostname = null;\n } else if (path.indexOf('+') > -1) {\n path = path.substring(path.indexOf('+') + 1);\n }\n }\n\n return {\n hostname,\n path,\n queryParams,\n scheme,\n };\n}\n\n// @needsAudit\n/**\n * Add a handler to `Linking` changes by listening to the `url` event type and providing the handler.\n * It is recommended to use the [`useURL()`](#useurl) hook instead.\n * @param type The only valid type is `'url'`.\n * @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type\n * [`EventType`](#eventype).\n * @return An EmitterSubscription that has the remove method from EventSubscription\n * @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#addeventlistener).\n */\nexport function addEventListener(type: 'url', handler: URLListener): EmitterSubscription {\n return NativeLinking.addEventListener(type, handler);\n}\n\n/**\n * Remove a handler by passing the `url` event type and the handler.\n * @param type The only valid type is `'url'`.\n * @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type\n * [`EventType`](#eventype).\n * @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#removeeventlistener).\n */\nexport function removeEventListener(type: 'url', handler: URLListener): void {\n NativeLinking.removeEventListener(type, handler);\n}\n\n// @needsAudit\n/**\n * Helper method which wraps React Native's `Linking.getInitialURL()` in `Linking.parse()`.\n * Parses the deep link information out of the URL used to open the experience initially.\n * If no link opened the app, all the fields will be `null`.\n * > On the web it parses the current window URL.\n * @return A promise that resolves with `ParsedURL` object.\n */\nexport async function parseInitialURLAsync(): Promise<ParsedURL> {\n const initialUrl = await NativeLinking.getInitialURL();\n if (!initialUrl) {\n return {\n scheme: null,\n hostname: null,\n path: null,\n queryParams: null,\n };\n }\n\n return parse(initialUrl);\n}\n\n// @needsAudit\n/**\n * Launch an Android intent with extras.\n * > Use [IntentLauncher](./intent-launcher) instead, `sendIntent` is only included in\n * > `Linking` for API compatibility with React Native's Linking API.\n * @platform android\n */\nexport async function sendIntent(action: string, extras?: SendIntentExtras[]): Promise<void> {\n if (Platform.OS === 'android') {\n return await NativeLinking.sendIntent(action, extras);\n }\n throw new UnavailabilityError('Linking', 'sendIntent');\n}\n\n// @needsAudit\n/**\n * Open the operating system settings app and displays the app’s custom settings, if it has any.\n * @platform ios\n */\nexport async function openSettings(): Promise<void> {\n if (Platform.OS === 'web') {\n throw new UnavailabilityError('Linking', 'openSettings');\n }\n if (NativeLinking.openSettings) {\n return await NativeLinking.openSettings();\n }\n await openURL('app-settings:');\n}\n\n// @needsAudit\n/**\n * Get the URL that was used to launch the app if it was launched by a link.\n * @return The URL string that launched your app, or `null`.\n */\nexport async function getInitialURL(): Promise<string | null> {\n return (await NativeLinking.getInitialURL()) ?? null;\n}\n\n// @needsAudit\n/**\n * Attempt to open the given URL with an installed app. See the [Linking guide](/guides/linking)\n * for more information.\n * @param url A URL for the operating system to open, eg: `tel:5555555`, `exp://`.\n * @return A `Promise` that is fulfilled with `true` if the link is opened operating system\n * automatically or the user confirms the prompt to open the link. The `Promise` rejects if there\n * are no applications registered for the URL or the user cancels the dialog.\n */\nexport async function openURL(url: string): Promise<true> {\n validateURL(url);\n return await NativeLinking.openURL(url);\n}\n\n// @needsAudit\n/**\n * Determine whether or not an installed app can handle a given URL.\n * On web this always returns `true` because there is no API for detecting what URLs can be opened.\n * @param url The URL that you want to test can be opened.\n * @return A `Promise` object that is fulfilled with `true` if the URL can be handled, otherwise it\n * `false` if not.\n *\n * The `Promise` will reject on Android if it was impossible to check if the URL can be opened, and\n * on iOS if you didn't [add the specific scheme in the `LSApplicationQueriesSchemes` key inside **Info.plist**](/guides/linking#opening-links-to-other-apps).\n */\nexport async function canOpenURL(url: string): Promise<boolean> {\n validateURL(url);\n return await NativeLinking.canOpenURL(url);\n}\n\n// @needsAudit\n/**\n * Returns the initial URL followed by any subsequent changes to the URL.\n * @return Returns the initial URL or `null`.\n */\nexport function useURL(): string | null {\n const [url, setLink] = useState<string | null>(null);\n\n function onChange(event: { url: string }) {\n setLink(event.url);\n }\n\n useEffect(() => {\n getInitialURL().then((url) => setLink(url));\n const subscription = addEventListener('url', onChange);\n return () => subscription.remove();\n }, []);\n\n return url;\n}\n\nexport * from './Linking.types';\nexport * from './Schemes';\n"]}
|
package/build/Linking.types.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Linking.types.d.ts","sourceRoot":"","sources":["../src/Linking.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAG9B,oBAAY,WAAW,GAAG,QAAQ,CAAC;AAGnC,oBAAY,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB;;OAEG;IACH,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;CACjC,CAAC;AAGF,oBAAY,gBAAgB,GAAG;IAC7B;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAGF,oBAAY,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,YAAY,CAAC;CAC5B,CAAC;AAGF,oBAAY,WAAW,GAAG,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;AAGrD,oBAAY,iBAAiB,GAAG,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,CAAC;AAGpE,oBAAY,gBAAgB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC"}
|
package/build/Schemes.d.ts
CHANGED
|
@@ -9,8 +9,12 @@ export declare function hasCustomScheme(): boolean;
|
|
|
9
9
|
* - Android: scheme -> android.scheme -> android.package
|
|
10
10
|
*/
|
|
11
11
|
export declare function collectManifestSchemes(): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Ensure the user has linked the expo-constants manifest in bare workflow.
|
|
14
|
+
*/
|
|
12
15
|
export declare function hasConstantsManifest(): boolean;
|
|
13
|
-
export declare function resolveScheme(
|
|
16
|
+
export declare function resolveScheme(options: {
|
|
14
17
|
scheme?: string;
|
|
15
18
|
isSilent?: boolean;
|
|
16
19
|
}): string;
|
|
20
|
+
//# sourceMappingURL=Schemes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Schemes.d.ts","sourceRoot":"","sources":["../src/Schemes.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,IAAI,OAAO,CAWzC;AAkCD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,EAAE,CA0BjD;AAmBD;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,OAAO,CAK9C;AAGD,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,MAAM,CAiGtF"}
|
package/build/Schemes.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Constants, { ExecutionEnvironment } from 'expo-constants';
|
|
2
2
|
import { Platform } from 'expo-modules-core';
|
|
3
|
-
const LINKING_GUIDE_URL = `https://docs.expo.
|
|
3
|
+
const LINKING_GUIDE_URL = `https://docs.expo.dev/guides/linking/`;
|
|
4
|
+
// @docsMissing
|
|
4
5
|
export function hasCustomScheme() {
|
|
5
6
|
if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
|
|
6
7
|
// Bare always uses a custom scheme.
|
|
@@ -83,20 +84,24 @@ function getNativeAppIdScheme() {
|
|
|
83
84
|
Constants.manifest2?.extra?.expoClient?.android?.package,
|
|
84
85
|
}) ?? null);
|
|
85
86
|
}
|
|
87
|
+
// @needsAudit
|
|
88
|
+
/**
|
|
89
|
+
* Ensure the user has linked the expo-constants manifest in bare workflow.
|
|
90
|
+
*/
|
|
86
91
|
export function hasConstantsManifest() {
|
|
87
|
-
// Ensure the user has linked the expo-constants manifest in bare workflow.
|
|
88
92
|
return (!!Object.keys(Constants.manifest ?? {}).length ||
|
|
89
93
|
!!Object.keys(Constants.manifest2 ?? {}).length);
|
|
90
94
|
}
|
|
91
|
-
|
|
95
|
+
// @docsMissing
|
|
96
|
+
export function resolveScheme(options) {
|
|
92
97
|
if (Constants.executionEnvironment !== ExecutionEnvironment.StoreClient &&
|
|
93
98
|
!hasConstantsManifest()) {
|
|
94
|
-
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/
|
|
99
|
+
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/main/packages/expo-constants/README.md`);
|
|
95
100
|
}
|
|
96
101
|
const manifestSchemes = collectManifestSchemes();
|
|
97
102
|
const nativeAppId = getNativeAppIdScheme();
|
|
98
103
|
if (!manifestSchemes.length) {
|
|
99
|
-
if (__DEV__ && !
|
|
104
|
+
if (__DEV__ && !options.isSilent) {
|
|
100
105
|
// Assert a config warning if no scheme is setup yet. `isSilent` is used for warnings, but we'll ignore it for exceptions.
|
|
101
106
|
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: ${LINKING_GUIDE_URL}`);
|
|
102
107
|
}
|
|
@@ -107,10 +112,10 @@ export function resolveScheme(props) {
|
|
|
107
112
|
}
|
|
108
113
|
// In the Expo client...
|
|
109
114
|
if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
|
|
110
|
-
if (
|
|
115
|
+
if (options.scheme) {
|
|
111
116
|
// This enables users to use the fb or google redirects on iOS in the Expo client.
|
|
112
|
-
if (EXPO_CLIENT_SCHEMES.includes(
|
|
113
|
-
return
|
|
117
|
+
if (EXPO_CLIENT_SCHEMES.includes(options.scheme)) {
|
|
118
|
+
return options.scheme;
|
|
114
119
|
}
|
|
115
120
|
// Silently ignore to make bare workflow development easier.
|
|
116
121
|
}
|
|
@@ -118,26 +123,26 @@ export function resolveScheme(props) {
|
|
|
118
123
|
return 'exp';
|
|
119
124
|
}
|
|
120
125
|
const schemes = [...manifestSchemes, nativeAppId].filter(Boolean);
|
|
121
|
-
if (
|
|
126
|
+
if (options.scheme) {
|
|
122
127
|
if (__DEV__) {
|
|
123
128
|
// Bare workflow development assertion about the provided scheme matching the Expo config.
|
|
124
|
-
if (!schemes.includes(
|
|
129
|
+
if (!schemes.includes(options.scheme) && !options.isSilent) {
|
|
125
130
|
// TODO: Will this cause issues for things like Facebook or Google that use `reversed-client-id://` or `fb<FBID>:/`?
|
|
126
131
|
// Traditionally these APIs don't use the Linking API directly.
|
|
127
|
-
console.warn(`The provided Linking scheme '${
|
|
132
|
+
console.warn(`The provided Linking scheme '${options.scheme}' does not appear in the list of possible URI schemes in your Expo config. Expected one of: ${schemes
|
|
128
133
|
.map((scheme) => `'${scheme}'`)
|
|
129
134
|
.join(', ')}`);
|
|
130
135
|
}
|
|
131
136
|
}
|
|
132
137
|
// Return the user provided value.
|
|
133
|
-
return
|
|
138
|
+
return options.scheme;
|
|
134
139
|
}
|
|
135
140
|
// If no scheme is provided, we'll guess what the scheme is based on the manifest.
|
|
136
141
|
// This is to attempt to keep managed apps working across expo build and EAS build.
|
|
137
142
|
// EAS build ejects the app before building it so we can assume that the user will
|
|
138
143
|
// be using one of defined schemes.
|
|
139
144
|
// If the native app id is the only scheme,
|
|
140
|
-
if (!!nativeAppId && !manifestSchemes.length && !
|
|
145
|
+
if (!!nativeAppId && !manifestSchemes.length && !options.isSilent) {
|
|
141
146
|
// Assert a config warning if no scheme is setup yet.
|
|
142
147
|
// This warning only applies to managed workflow EAS apps, as bare workflow
|
|
143
148
|
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: ${LINKING_GUIDE_URL}`);
|
|
@@ -154,7 +159,7 @@ export function resolveScheme(props) {
|
|
|
154
159
|
// Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`
|
|
155
160
|
throw new Error(errorMessage);
|
|
156
161
|
}
|
|
157
|
-
if (extraSchemes.length && !
|
|
162
|
+
if (extraSchemes.length && !options.isSilent) {
|
|
158
163
|
console.warn(`Linking found multiple possible URI schemes in your Expo config.\nUsing '${scheme}'. Ignoring: ${[
|
|
159
164
|
...extraSchemes,
|
|
160
165
|
nativeAppId,
|
package/build/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D;IAC/D,MAAM,CAAC,MAAM,EAAE,GAAG,YAAY,CAAC,GAAG,eAAe,CAAC;IAElD,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,YAAY,GAAG,0NAA0N,iBAAiB,EAAE,CAAC;QACnQ,4GAA4G;QAC5G,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;KAC/B;IACD,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QAC1C,OAAO,CAAC,IAAI,CACV,4EAA4E,MAAM,gBAAgB;YAChG,GAAG,YAAY;YACf,WAAW;SACZ;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,+DAA+D,CAC7E,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport { Platform } from 'expo-modules-core';\n\nconst LINKING_GUIDE_URL = `https://docs.expo.io/guides/linking/`;\n\nexport function hasCustomScheme(): boolean {\n if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n // Bare always uses a custom scheme.\n return true;\n } else if (Constants.executionEnvironment === ExecutionEnvironment.Standalone) {\n // Standalone uses a custom scheme when one is defined.\n const manifestSchemes = collectManifestSchemes();\n return !!manifestSchemes.length;\n }\n // Store client uses the default scheme.\n return false;\n}\n\ntype SchemeConfig = {\n scheme?: string | string[];\n};\n\nfunction getSchemes(config: SchemeConfig | null | undefined): string[] {\n if (config) {\n if (Array.isArray(config.scheme)) {\n const validate = (value: any): value is string => {\n return typeof value === 'string';\n };\n return config.scheme.filter<string>(validate);\n } else if (typeof config.scheme === 'string') {\n return [config.scheme];\n }\n }\n return [];\n}\n\n// Valid schemes for the Expo client.\nconst EXPO_CLIENT_SCHEMES = Platform.select({\n // Results from `npx uri-scheme list --info-path ios/Exponent/Supporting/Info.plist`\n ios: [\n 'exp',\n 'exps',\n 'fb1696089354000816',\n 'host.exp.exponent',\n 'com.googleusercontent.apps.603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9',\n ],\n // Collected manually\n android: ['exp', 'exps'],\n});\n\n/**\n * Collect a list of platform schemes from the manifest.\n *\n * This method is based on the `Scheme` modules from `@expo/config-plugins`\n * which are used for collecting the schemes before prebuilding a native app.\n *\n * - iOS: scheme -> ios.scheme -> ios.bundleIdentifier\n * - Android: scheme -> android.scheme -> android.package\n */\nexport function collectManifestSchemes(): string[] {\n // ios.scheme, android.scheme, and scheme as an array are not yet added to the\n // Expo config spec, but there's no harm in adding them early.\n // They'll be added when we drop support for `expo build` or decide\n // to have them only work with `eas build`.\n const platformManifest =\n (Platform.select<any>({\n ios: Constants.manifest?.ios ?? Constants.manifest2?.extra?.expoClient?.ios,\n android: Constants.manifest?.android ?? Constants.manifest2?.extra?.expoClient?.android,\n web: {},\n }) as SchemeConfig) ?? {};\n\n const schemes = getSchemes(Constants.manifest ?? Constants.manifest2?.extra?.expoClient);\n\n // Add the detached scheme after the manifest scheme for legacy ExpoKit support.\n if (Constants.manifest?.detach?.scheme) {\n schemes.push(Constants.manifest.detach.scheme);\n }\n if (Constants.manifest2?.extra?.expoClient?.detach?.scheme) {\n schemes.push(Constants.manifest2.extra.expoClient.detach.scheme);\n }\n\n // Add the unimplemented platform schemes last.\n schemes.push(...getSchemes(platformManifest));\n\n return schemes;\n}\n\nfunction getNativeAppIdScheme(): string | null {\n // Add the native application identifier to the list of schemes for parity with `expo build`.\n // The native app id has been added to builds for a long time to support Google Sign-In.\n return (\n Platform.select({\n ios:\n Constants.manifest?.ios?.bundleIdentifier ??\n Constants.manifest2?.extra?.expoClient?.ios?.bundleIdentifier,\n // TODO: This may change to android.applicationId in the future.\n android:\n Constants.manifest?.android?.package ??\n Constants.manifest2?.extra?.expoClient?.android?.package,\n }) ?? null\n );\n}\n\nexport function hasConstantsManifest(): boolean {\n // Ensure the user has linked the expo-constants manifest in bare workflow.\n return (\n !!Object.keys(Constants.manifest ?? {}).length ||\n !!Object.keys(Constants.manifest2 ?? {}).length\n );\n}\n\nexport function resolveScheme(props: { scheme?: string; isSilent?: boolean }): string {\n if (\n Constants.executionEnvironment !== ExecutionEnvironment.StoreClient &&\n !hasConstantsManifest()\n ) {\n throw new Error(\n `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`\n );\n }\n\n const manifestSchemes = collectManifestSchemes();\n const nativeAppId = getNativeAppIdScheme();\n\n if (!manifestSchemes.length) {\n if (__DEV__ && !props.isSilent) {\n // Assert a config warning if no scheme is setup yet. `isSilent` is used for warnings, but we'll ignore it for exceptions.\n console.warn(\n `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: ${LINKING_GUIDE_URL}`\n );\n } else if (!__DEV__ || Constants.executionEnvironment !== ExecutionEnvironment.StoreClient) {\n // Throw in production or when not in store client. Use the __DEV__ flag so users can test this functionality with `expo start --no-dev`,\n throw new Error(\n 'Cannot make a deep link into a standalone app with no custom scheme defined'\n );\n }\n }\n\n // In the Expo client...\n if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n if (props.scheme) {\n // This enables users to use the fb or google redirects on iOS in the Expo client.\n if (EXPO_CLIENT_SCHEMES.includes(props.scheme)) {\n return props.scheme;\n }\n // Silently ignore to make bare workflow development easier.\n }\n // Fallback to the default client scheme.\n return 'exp';\n }\n\n const schemes = [...manifestSchemes, nativeAppId].filter(Boolean);\n\n if (props.scheme) {\n if (__DEV__) {\n // Bare workflow development assertion about the provided scheme matching the Expo config.\n if (!schemes.includes(props.scheme) && !props.isSilent) {\n // TODO: Will this cause issues for things like Facebook or Google that use `reversed-client-id://` or `fb<FBID>:/`?\n // Traditionally these APIs don't use the Linking API directly.\n console.warn(\n `The provided Linking scheme '${\n props.scheme\n }' does not appear in the list of possible URI schemes in your Expo config. Expected one of: ${schemes\n .map((scheme) => `'${scheme}'`)\n .join(', ')}`\n );\n }\n }\n // Return the user provided value.\n return props.scheme;\n }\n // If no scheme is provided, we'll guess what the scheme is based on the manifest.\n // This is to attempt to keep managed apps working across expo build and EAS build.\n // EAS build ejects the app before building it so we can assume that the user will\n // be using one of defined schemes.\n\n // If the native app id is the only scheme,\n if (!!nativeAppId && !manifestSchemes.length && !props.isSilent) {\n // Assert a config warning if no scheme is setup yet.\n // This warning only applies to managed workflow EAS apps, as bare workflow\n console.warn(\n `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: ${LINKING_GUIDE_URL}`\n );\n return nativeAppId;\n }\n // When the native app id is defined, it'll be added to the list of schemes, for most\n // users this will be unexpected behavior and cause all apps to warn when the Linking API\n // is used without a predefined scheme. For now, if the native app id is defined, require\n // at least one more scheme to be added before throwing a warning.\n // i.e. `scheme: ['foo', 'bar']` (unimplemented functionality).\n const [scheme, ...extraSchemes] = manifestSchemes;\n\n if (!scheme) {\n 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: ${LINKING_GUIDE_URL}`;\n // Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`\n throw new Error(errorMessage);\n }\n if (extraSchemes.length && !props.isSilent) {\n console.warn(\n `Linking found multiple possible URI schemes in your Expo config.\\nUsing '${scheme}'. Ignoring: ${[\n ...extraSchemes,\n nativeAppId,\n ]\n .filter(Boolean)\n .join(', ')}.\\nPlease supply the preferred URI scheme to the Linking API.`\n );\n }\n return scheme;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Schemes.js","sourceRoot":"","sources":["../src/Schemes.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAg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,CAAC;QACnQ,4GAA4G;QAC5G,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;KAC/B;IACD,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE;QAC5C,OAAO,CAAC,IAAI,CACV,4EAA4E,MAAM,gBAAgB;YAChG,GAAG,YAAY;YACf,WAAW;SACZ;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,IAAI,CAAC,+DAA+D,CAC7E,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport { Platform } from 'expo-modules-core';\n\nconst LINKING_GUIDE_URL = `https://docs.expo.dev/guides/linking/`;\n\n// @docsMissing\nexport function hasCustomScheme(): boolean {\n if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n // Bare always uses a custom scheme.\n return true;\n } else if (Constants.executionEnvironment === ExecutionEnvironment.Standalone) {\n // Standalone uses a custom scheme when one is defined.\n const manifestSchemes = collectManifestSchemes();\n return !!manifestSchemes.length;\n }\n // Store client uses the default scheme.\n return false;\n}\n\ntype SchemeConfig = {\n scheme?: string | string[];\n};\n\nfunction getSchemes(config: SchemeConfig | null | undefined): string[] {\n if (config) {\n if (Array.isArray(config.scheme)) {\n const validate = (value: any): value is string => {\n return typeof value === 'string';\n };\n return config.scheme.filter<string>(validate);\n } else if (typeof config.scheme === 'string') {\n return [config.scheme];\n }\n }\n return [];\n}\n\n// Valid schemes for the Expo client.\nconst EXPO_CLIENT_SCHEMES = Platform.select({\n // Results from `npx uri-scheme list --info-path ios/Exponent/Supporting/Info.plist`\n ios: [\n 'exp',\n 'exps',\n 'fb1696089354000816',\n 'host.exp.exponent',\n 'com.googleusercontent.apps.603386649315-vp4revvrcgrcjme51ebuhbkbspl048l9',\n ],\n // Collected manually\n android: ['exp', 'exps'],\n});\n\n/**\n * Collect a list of platform schemes from the manifest.\n *\n * This method is based on the `Scheme` modules from `@expo/config-plugins`\n * which are used for collecting the schemes before prebuilding a native app.\n *\n * - iOS: scheme -> ios.scheme -> ios.bundleIdentifier\n * - Android: scheme -> android.scheme -> android.package\n */\nexport function collectManifestSchemes(): string[] {\n // ios.scheme, android.scheme, and scheme as an array are not yet added to the\n // Expo config spec, but there's no harm in adding them early.\n // They'll be added when we drop support for `expo build` or decide\n // to have them only work with `eas build`.\n const platformManifest =\n (Platform.select<any>({\n ios: Constants.manifest?.ios ?? Constants.manifest2?.extra?.expoClient?.ios,\n android: Constants.manifest?.android ?? Constants.manifest2?.extra?.expoClient?.android,\n web: {},\n }) as SchemeConfig) ?? {};\n\n const schemes = getSchemes(Constants.manifest ?? Constants.manifest2?.extra?.expoClient);\n\n // Add the detached scheme after the manifest scheme for legacy ExpoKit support.\n if (Constants.manifest?.detach?.scheme) {\n schemes.push(Constants.manifest.detach.scheme);\n }\n if (Constants.manifest2?.extra?.expoClient?.detach?.scheme) {\n schemes.push(Constants.manifest2.extra.expoClient.detach.scheme);\n }\n\n // Add the unimplemented platform schemes last.\n schemes.push(...getSchemes(platformManifest));\n\n return schemes;\n}\n\nfunction getNativeAppIdScheme(): string | null {\n // Add the native application identifier to the list of schemes for parity with `expo build`.\n // The native app id has been added to builds for a long time to support Google Sign-In.\n return (\n Platform.select({\n ios:\n Constants.manifest?.ios?.bundleIdentifier ??\n Constants.manifest2?.extra?.expoClient?.ios?.bundleIdentifier,\n // TODO: This may change to android.applicationId in the future.\n android:\n Constants.manifest?.android?.package ??\n Constants.manifest2?.extra?.expoClient?.android?.package,\n }) ?? null\n );\n}\n\n// @needsAudit\n/**\n * Ensure the user has linked the expo-constants manifest in bare workflow.\n */\nexport function hasConstantsManifest(): boolean {\n return (\n !!Object.keys(Constants.manifest ?? {}).length ||\n !!Object.keys(Constants.manifest2 ?? {}).length\n );\n}\n\n// @docsMissing\nexport function resolveScheme(options: { scheme?: string; isSilent?: boolean }): string {\n if (\n Constants.executionEnvironment !== ExecutionEnvironment.StoreClient &&\n !hasConstantsManifest()\n ) {\n throw new Error(\n `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/main/packages/expo-constants/README.md`\n );\n }\n\n const manifestSchemes = collectManifestSchemes();\n const nativeAppId = getNativeAppIdScheme();\n\n if (!manifestSchemes.length) {\n if (__DEV__ && !options.isSilent) {\n // Assert a config warning if no scheme is setup yet. `isSilent` is used for warnings, but we'll ignore it for exceptions.\n console.warn(\n `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: ${LINKING_GUIDE_URL}`\n );\n } else if (!__DEV__ || Constants.executionEnvironment !== ExecutionEnvironment.StoreClient) {\n // Throw in production or when not in store client. Use the __DEV__ flag so users can test this functionality with `expo start --no-dev`,\n throw new Error(\n 'Cannot make a deep link into a standalone app with no custom scheme defined'\n );\n }\n }\n\n // In the Expo client...\n if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n if (options.scheme) {\n // This enables users to use the fb or google redirects on iOS in the Expo client.\n if (EXPO_CLIENT_SCHEMES.includes(options.scheme)) {\n return options.scheme;\n }\n // Silently ignore to make bare workflow development easier.\n }\n // Fallback to the default client scheme.\n return 'exp';\n }\n\n const schemes = [...manifestSchemes, nativeAppId].filter(Boolean);\n\n if (options.scheme) {\n if (__DEV__) {\n // Bare workflow development assertion about the provided scheme matching the Expo config.\n if (!schemes.includes(options.scheme) && !options.isSilent) {\n // TODO: Will this cause issues for things like Facebook or Google that use `reversed-client-id://` or `fb<FBID>:/`?\n // Traditionally these APIs don't use the Linking API directly.\n console.warn(\n `The provided Linking scheme '${\n options.scheme\n }' does not appear in the list of possible URI schemes in your Expo config. Expected one of: ${schemes\n .map((scheme) => `'${scheme}'`)\n .join(', ')}`\n );\n }\n }\n // Return the user provided value.\n return options.scheme;\n }\n // If no scheme is provided, we'll guess what the scheme is based on the manifest.\n // This is to attempt to keep managed apps working across expo build and EAS build.\n // EAS build ejects the app before building it so we can assume that the user will\n // be using one of defined schemes.\n\n // If the native app id is the only scheme,\n if (!!nativeAppId && !manifestSchemes.length && !options.isSilent) {\n // Assert a config warning if no scheme is setup yet.\n // This warning only applies to managed workflow EAS apps, as bare workflow\n console.warn(\n `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: ${LINKING_GUIDE_URL}`\n );\n return nativeAppId;\n }\n // When the native app id is defined, it'll be added to the list of schemes, for most\n // users this will be unexpected behavior and cause all apps to warn when the Linking API\n // is used without a predefined scheme. For now, if the native app id is defined, require\n // at least one more scheme to be added before throwing a warning.\n // i.e. `scheme: ['foo', 'bar']` (unimplemented functionality).\n const [scheme, ...extraSchemes] = manifestSchemes;\n\n if (!scheme) {\n 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: ${LINKING_GUIDE_URL}`;\n // Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`\n throw new Error(errorMessage);\n }\n if (extraSchemes.length && !options.isSilent) {\n console.warn(\n `Linking found multiple possible URI schemes in your Expo config.\\nUsing '${scheme}'. Ignoring: ${[\n ...extraSchemes,\n nativeAppId,\n ]\n .filter(Boolean)\n .join(', ')}.\\nPlease supply the preferred URI scheme to the Linking API.`\n );\n }\n return scheme;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-linking",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Create and open deep links universally",
|
|
5
5
|
"main": "build/Linking.js",
|
|
6
6
|
"types": "build/Linking.d.ts",
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/linking",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"expo-constants": "~13.
|
|
33
|
+
"expo-constants": "~13.1.0",
|
|
34
34
|
"invariant": "^2.2.4",
|
|
35
35
|
"qs": "^6.9.1",
|
|
36
|
-
"url-parse": "^1.
|
|
36
|
+
"url-parse": "^1.5.9"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/qs": "^6.5.3",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"jest": {
|
|
43
43
|
"preset": "expo-module-scripts"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "22dce752354bb429c84851bc4389abe47a766b1f"
|
|
46
46
|
}
|
package/src/Linking.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Platform, UnavailabilityError } from 'expo-modules-core';
|
|
|
3
3
|
import invariant from 'invariant';
|
|
4
4
|
import qs from 'qs';
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
|
+
import { EmitterSubscription } from 'react-native';
|
|
6
7
|
import URL from 'url-parse';
|
|
7
8
|
|
|
8
9
|
import NativeLinking from './ExpoLinking';
|
|
@@ -177,7 +178,7 @@ export function createURL(
|
|
|
177
178
|
if (typeof parsedParams === 'object') {
|
|
178
179
|
paramsFromHostUri = parsedParams;
|
|
179
180
|
}
|
|
180
|
-
} catch
|
|
181
|
+
} catch {}
|
|
181
182
|
queryParams = {
|
|
182
183
|
...queryParams,
|
|
183
184
|
...paramsFromHostUri,
|
|
@@ -255,10 +256,11 @@ export function parse(url: string): ParsedURL {
|
|
|
255
256
|
* @param type The only valid type is `'url'`.
|
|
256
257
|
* @param handler An [`URLListener`](#urllistener) function that takes an `event` object of the type
|
|
257
258
|
* [`EventType`](#eventype).
|
|
259
|
+
* @return An EmitterSubscription that has the remove method from EventSubscription
|
|
258
260
|
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#addeventlistener).
|
|
259
261
|
*/
|
|
260
|
-
export function addEventListener(type:
|
|
261
|
-
NativeLinking.addEventListener(type, handler);
|
|
262
|
+
export function addEventListener(type: 'url', handler: URLListener): EmitterSubscription {
|
|
263
|
+
return NativeLinking.addEventListener(type, handler);
|
|
262
264
|
}
|
|
263
265
|
|
|
264
266
|
/**
|
|
@@ -268,7 +270,7 @@ export function addEventListener(type: string, handler: URLListener): void {
|
|
|
268
270
|
* [`EventType`](#eventype).
|
|
269
271
|
* @see [React Native Docs Linking page](https://reactnative.dev/docs/linking#removeeventlistener).
|
|
270
272
|
*/
|
|
271
|
-
export function removeEventListener(type:
|
|
273
|
+
export function removeEventListener(type: 'url', handler: URLListener): void {
|
|
272
274
|
NativeLinking.removeEventListener(type, handler);
|
|
273
275
|
}
|
|
274
276
|
|
|
@@ -297,7 +299,7 @@ export async function parseInitialURLAsync(): Promise<ParsedURL> {
|
|
|
297
299
|
// @needsAudit
|
|
298
300
|
/**
|
|
299
301
|
* Launch an Android intent with extras.
|
|
300
|
-
* > Use [IntentLauncher](
|
|
302
|
+
* > Use [IntentLauncher](./intent-launcher) instead, `sendIntent` is only included in
|
|
301
303
|
* > `Linking` for API compatibility with React Native's Linking API.
|
|
302
304
|
* @platform android
|
|
303
305
|
*/
|
|
@@ -376,11 +378,12 @@ export function useURL(): string | null {
|
|
|
376
378
|
|
|
377
379
|
useEffect(() => {
|
|
378
380
|
getInitialURL().then((url) => setLink(url));
|
|
379
|
-
addEventListener('url', onChange);
|
|
380
|
-
return () =>
|
|
381
|
+
const subscription = addEventListener('url', onChange);
|
|
382
|
+
return () => subscription.remove();
|
|
381
383
|
}, []);
|
|
382
384
|
|
|
383
385
|
return url;
|
|
384
386
|
}
|
|
385
387
|
|
|
386
388
|
export * from './Linking.types';
|
|
389
|
+
export * from './Schemes';
|
package/src/Schemes.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import Constants, { ExecutionEnvironment } from 'expo-constants';
|
|
2
2
|
import { Platform } from 'expo-modules-core';
|
|
3
3
|
|
|
4
|
-
const LINKING_GUIDE_URL = `https://docs.expo.
|
|
4
|
+
const LINKING_GUIDE_URL = `https://docs.expo.dev/guides/linking/`;
|
|
5
5
|
|
|
6
|
+
// @docsMissing
|
|
6
7
|
export function hasCustomScheme(): boolean {
|
|
7
8
|
if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
|
|
8
9
|
// Bare always uses a custom scheme.
|
|
@@ -101,21 +102,25 @@ function getNativeAppIdScheme(): string | null {
|
|
|
101
102
|
);
|
|
102
103
|
}
|
|
103
104
|
|
|
105
|
+
// @needsAudit
|
|
106
|
+
/**
|
|
107
|
+
* Ensure the user has linked the expo-constants manifest in bare workflow.
|
|
108
|
+
*/
|
|
104
109
|
export function hasConstantsManifest(): boolean {
|
|
105
|
-
// Ensure the user has linked the expo-constants manifest in bare workflow.
|
|
106
110
|
return (
|
|
107
111
|
!!Object.keys(Constants.manifest ?? {}).length ||
|
|
108
112
|
!!Object.keys(Constants.manifest2 ?? {}).length
|
|
109
113
|
);
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
|
|
116
|
+
// @docsMissing
|
|
117
|
+
export function resolveScheme(options: { scheme?: string; isSilent?: boolean }): string {
|
|
113
118
|
if (
|
|
114
119
|
Constants.executionEnvironment !== ExecutionEnvironment.StoreClient &&
|
|
115
120
|
!hasConstantsManifest()
|
|
116
121
|
) {
|
|
117
122
|
throw new Error(
|
|
118
|
-
`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/
|
|
123
|
+
`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/main/packages/expo-constants/README.md`
|
|
119
124
|
);
|
|
120
125
|
}
|
|
121
126
|
|
|
@@ -123,7 +128,7 @@ export function resolveScheme(props: { scheme?: string; isSilent?: boolean }): s
|
|
|
123
128
|
const nativeAppId = getNativeAppIdScheme();
|
|
124
129
|
|
|
125
130
|
if (!manifestSchemes.length) {
|
|
126
|
-
if (__DEV__ && !
|
|
131
|
+
if (__DEV__ && !options.isSilent) {
|
|
127
132
|
// Assert a config warning if no scheme is setup yet. `isSilent` is used for warnings, but we'll ignore it for exceptions.
|
|
128
133
|
console.warn(
|
|
129
134
|
`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: ${LINKING_GUIDE_URL}`
|
|
@@ -138,10 +143,10 @@ export function resolveScheme(props: { scheme?: string; isSilent?: boolean }): s
|
|
|
138
143
|
|
|
139
144
|
// In the Expo client...
|
|
140
145
|
if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
|
|
141
|
-
if (
|
|
146
|
+
if (options.scheme) {
|
|
142
147
|
// This enables users to use the fb or google redirects on iOS in the Expo client.
|
|
143
|
-
if (EXPO_CLIENT_SCHEMES.includes(
|
|
144
|
-
return
|
|
148
|
+
if (EXPO_CLIENT_SCHEMES.includes(options.scheme)) {
|
|
149
|
+
return options.scheme;
|
|
145
150
|
}
|
|
146
151
|
// Silently ignore to make bare workflow development easier.
|
|
147
152
|
}
|
|
@@ -151,15 +156,15 @@ export function resolveScheme(props: { scheme?: string; isSilent?: boolean }): s
|
|
|
151
156
|
|
|
152
157
|
const schemes = [...manifestSchemes, nativeAppId].filter(Boolean);
|
|
153
158
|
|
|
154
|
-
if (
|
|
159
|
+
if (options.scheme) {
|
|
155
160
|
if (__DEV__) {
|
|
156
161
|
// Bare workflow development assertion about the provided scheme matching the Expo config.
|
|
157
|
-
if (!schemes.includes(
|
|
162
|
+
if (!schemes.includes(options.scheme) && !options.isSilent) {
|
|
158
163
|
// TODO: Will this cause issues for things like Facebook or Google that use `reversed-client-id://` or `fb<FBID>:/`?
|
|
159
164
|
// Traditionally these APIs don't use the Linking API directly.
|
|
160
165
|
console.warn(
|
|
161
166
|
`The provided Linking scheme '${
|
|
162
|
-
|
|
167
|
+
options.scheme
|
|
163
168
|
}' does not appear in the list of possible URI schemes in your Expo config. Expected one of: ${schemes
|
|
164
169
|
.map((scheme) => `'${scheme}'`)
|
|
165
170
|
.join(', ')}`
|
|
@@ -167,7 +172,7 @@ export function resolveScheme(props: { scheme?: string; isSilent?: boolean }): s
|
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
// Return the user provided value.
|
|
170
|
-
return
|
|
175
|
+
return options.scheme;
|
|
171
176
|
}
|
|
172
177
|
// If no scheme is provided, we'll guess what the scheme is based on the manifest.
|
|
173
178
|
// This is to attempt to keep managed apps working across expo build and EAS build.
|
|
@@ -175,7 +180,7 @@ export function resolveScheme(props: { scheme?: string; isSilent?: boolean }): s
|
|
|
175
180
|
// be using one of defined schemes.
|
|
176
181
|
|
|
177
182
|
// If the native app id is the only scheme,
|
|
178
|
-
if (!!nativeAppId && !manifestSchemes.length && !
|
|
183
|
+
if (!!nativeAppId && !manifestSchemes.length && !options.isSilent) {
|
|
179
184
|
// Assert a config warning if no scheme is setup yet.
|
|
180
185
|
// This warning only applies to managed workflow EAS apps, as bare workflow
|
|
181
186
|
console.warn(
|
|
@@ -195,7 +200,7 @@ export function resolveScheme(props: { scheme?: string; isSilent?: boolean }): s
|
|
|
195
200
|
// Throw in production, use the __DEV__ flag so users can test this functionality with `expo start --no-dev`
|
|
196
201
|
throw new Error(errorMessage);
|
|
197
202
|
}
|
|
198
|
-
if (extraSchemes.length && !
|
|
203
|
+
if (extraSchemes.length && !options.isSilent) {
|
|
199
204
|
console.warn(
|
|
200
205
|
`Linking found multiple possible URI schemes in your Expo config.\nUsing '${scheme}'. Ignoring: ${[
|
|
201
206
|
...extraSchemes,
|